Compare commits

..

1 Commits

Author SHA1 Message Date
xdrm-brackets 88fe7f04e7 [webpack.teacher.view] instant-filter new design + filter count 2018-03-08 18:00:39 +01:00
97 changed files with 11262 additions and 10619 deletions

5
.gitignore vendored
View File

@ -3,7 +3,4 @@
/vendor
/public_html/css
/public_html/js
/node_modules
/backup
/tmp
/public_html/tmp
/node_modules

View File

@ -6,7 +6,6 @@
if( !defined('__CONFIG__') ) define('__CONFIG__', __ROOT__.'/config' );
if( !defined('__BUILD__') ) define('__BUILD__', __ROOT__.'/build' );
if( !defined('__PUBLIC__') ) define('__PUBLIC__', __ROOT__.'/public_html' );
if( !defined('__BACKUP__') ) define('__BACKUP__', __ROOT__.'/backup' );
/* ACTIVE LE DEBUGGAGE (WARNING + EXCEPTION)

View File

@ -16,14 +16,14 @@
interface AuthSystem{
/** VERIFICATION DES ACCES EN FONCTION DE PERMISSIONS ATTENDUES
*
* @param array $expected Liste des permissions attendues
*
* @return Error Erreur associée à la permission (Success/PermissionError/TokenError/etc)
*
*/
public static function permission(array $expected) : Error;
/* VERIFICATION DES ACCES EN FONCTION DE PERMISSIONS ATTENDUES
*
* @expected<array> Liste des permissions attendues
*
* @return error<Error> Erreur associée à la permission (Success/PermissionError/TokenError/etc)
*
*/
public static function permission($expected);
}
?>

View File

@ -23,14 +23,35 @@
/* (1) Init session variables
---------------------------------------------------------*/
if( !isset($_SESSION['CAS']) || !is_array($_SESSION['CAS']) ) $_SESSION['CAS'] = [];
if( !isset($_SESSION['AUTH']) || !is_array($_SESSION['AUTH']) ) $_SESSION['AUTH'] = [];
if( !isset($_SESSION['AvailableDepartments']) || !is_array($_SESSION['AvailableDepartments']) ) $_SESSION['AvailableDepartments'] = [];
if( !isset($_SESSION['VERSION']) || !is_array($_SESSION['VERSION']) ) $_SESSION['VERSION'] = [];
if( !isset($_SESSION['CurrentDepartmentId']) || !is_int($_SESSION['CurrentDepartmentId']) ) $_SESSION['CurrentDepartmentId'] = null;
if( !isset($_SESSION['CAS']) || !is_array($_SESSION['CAS']) ) $_SESSION['CAS'] = [];
if( !isset($_SESSION['AUTH']) || !is_array($_SESSION['AUTH']) ) $_SESSION['AUTH'] = [];
/* (2) Process AUTH
/* (2) Check CAS
---------------------------------------------------------*/
if( isset($_SESSION['CAS']['login']) && isset($_SESSION['CAS']['ticket']) ){
/* (1) Get professor repo */
/** @var professor $prof_repo */
$prof_repo = Repo::getRepo('professor');
/* (2) Get professor with this login */
$by_login = $prof_repo->getByLogin($_SESSION['CAS']['login']);
/* (3) If found -> store useful information */
if( is_array($by_login) && isset($by_login['idProfesseur']) && isset($by_login['admin']) ){
$_SESSION['CAS']['admin'] = (bool) $by_login['admin'];
$_SESSION['CAS']['id'] = (int) $by_login['idProfesseur'];
/* (4) If no login found -> remove CAS auth */
}else
$_SESSION['CAS'] = [];
}
/* (3) Process AUTH
---------------------------------------------------------*/
/* (1) cas_admin | cas_user */
if( isset($_SESSION['CAS']['admin']) && is_bool($_SESSION['CAS']['admin']) ){
@ -48,7 +69,7 @@
$_SESSION['AUTH'] = \array_diff($_SESSION['AUTH'], ['cas_admin']);
}
/* (3) Other permissions */
/* (2) Other permissions */
// TODO
}
@ -58,19 +79,22 @@
/** VERIFICATION DES ACCES EN FONCTION DE PERMISSIONS ATTENDUES
*
* @param array $expected Liste des permissions attendues
*
* @return Error Erreur associée à la permission (Success/PermissionError/TokenError/etc)
*
*/
public static function permission(array $expected) : Error{
/* VERIFICATION DES ACCES EN FONCTION DE PERMISSIONS ATTENDUES
*
* @expected<array> Liste des permissions attendues
*
* @return error<Error> Erreur associée à la permission (Success/PermissionError/TokenError/etc)
*
*/
public static function permission($expected){
/* (1) Check format -> if not array of array(s) -> ERROR
---------------------------------------------------------*/
/* (1) If not array -> ERROR */
if( !is_array($expected) )
return new Error(Err::FormatError);
/* (1) If not array of array(s) -> ERROR */
/* (2) If not array of array(s) -> ERROR */
foreach($expected as $permission_group)
if( !is_array($permission_group) )
return new Error(Err::FormatError);

View File

@ -16,15 +16,15 @@
class Checker{
/** VERIFICATIONS DES TYPES UTILES GENERIQUES
/* VERIFICATIONS DES TYPES UTILES GENERIQUES
*
* @param String $type Type que l'on veut verifier
* @param mixed $value Valeur a verifier
* @type<String> Type que l'on veut verifier
* @value<mixed*> Valeur a verifier
*
* @return Boolean Retourne si oui ou non la valeur @value est du bon type @type
* @return match<Boolean> Retourne si oui ou non la valeur @value est du bon type @type
*
*/
public static function run(String $type, $value) : bool {
public static function run($type, $value){
$checker = true;
/* [0] On verifie que $value n'est pas nul
@ -44,10 +44,6 @@
// On recupere le sous-type si défini
$flags = isset($match[3]) ? explode(',', substr($match[3], 1)) : null;
// Si numeric -> to String
if( is_numeric($value) )
$value = (string) $value;
// On effectue la verification de taille
$lenCheck = $checker && is_string($value) && strlen($value) <= $max && strlen($value) >= $min;
@ -95,11 +91,6 @@
return $checker && is_numeric($value) && $value <= 2147483647 && $value >= 0;
break;
// Entier relatif (neg ou pos)
case 'int':
return $checker && is_int($value);
break;
// String quelconque (peut etre vide)
case 'text':
return $checker && is_string($value);
@ -152,7 +143,7 @@
break;
case "float":
return $checker && ( is_int($value) || is_float($value) );
return $checker && is_float($value);
break;
default:

View File

@ -11,34 +11,23 @@
/* (1) Attributes
---------------------------------------------------------*/
/* (1) Static */
/** @var Config? */
private static $inst = null; // singleton instance
private static function config_path() : String { return __ROOT__.'/config/modules.json'; }
/** @var array[String] */
private static function config_path(){ return __ROOT__.'/config/modules.json'; }
public static $allowed_http_methods = [ "GET", "POST", "PUT", "DELETE" ];
/* (2) Instance */
/** @var array */
private $raw;
/** @var array */
public $index;
/** @var Error */
public $error;
/** (2) Private constructor
/* (2) Private constructor
*
* @param String|null $path Configuration path
* @path<String> Configuration path
*
---------------------------------------------------------*/
private function __construct(?String $path=null){
private function __construct($path=null){
// Set default error
$this->error = new Error(Err::Success);
@ -127,9 +116,9 @@
/** (3) Static singleton 'get-or-create'
/* (3) Static singleton 'get-or-create'
*
* @return Config Configuration singleton
* @return inst<Config> Configuration singleton
*
---------------------------------------------------------*/
public static function get() : Config{

View File

@ -15,15 +15,15 @@
class ModuleFactory{
/** INSTANCIE UN MODULE
/* INSTANCIE UN MODULE
*
* @param String $module Nom du module
* @param array $arguments [OPTIONNEL] Arguments à passer au constructeur
* @module<String> Nom du module
* @arguments<Array> [OPTIONNEL] Arguments à passer au constructeur
*
* @return object|false Instance du module en question
* @return instance<Module> Instance du module en question
*
*/
public static function getModule(String $module, array $arguments=[]){
public static function getModule($module, $arguments=[]){
/* (1) On gère les arguments */
$arguments = is_array($arguments) ? $arguments : [];

View File

@ -5,50 +5,35 @@
use \api\core\AuthSystem;
use \api\core\ModuleFactory;
use \api\core\Config;
use database\core\Repo;
use \error\core\Error;
use \error\core\Error;
use \error\core\Err;
class Request{
// Constantes
/** @var array[bool] */
private static $default_options = [ 'download' => false ];
/** @var AuthSystem|null */
private static $authsystem = null;
// Attributs prives utiles (initialisation)
/** @var array */
private $id; // chemin extrait de l'URI
/** @var array */
private $raw_params; // paramètres reçus
/** @var array */
private $params; // paramètres donnés à la fonction
/** @var array */
private $options; // options
/** @var String */
private $http_method; // methode HTTP appelante
// Contiendra l'etat de la requete
/** @var Error */
public $error;
/** (0) Constructeur d'une requete de module
/* (0) Constructeur d'une requete de module
*
* @param String|null $uri URI relative de l'appel
* @param array|null $params Tableau associatif contenant les parametres utiles au traitement
* @param String|null $forced_method Méthode demandée (optionnel)
* @uri<String> URI relative de l'appel
* @param<Array> Tableau associatif contenant les parametres utiles au traitement
* @forced_method<String> Méthode demandée (optionnel)
*
* @return instance<Request> Instance crée
*
---------------------------------------------------------*/
public function __construct($uri=null, $params=null, $forced_method=null){
@ -59,44 +44,38 @@ use \error\core\Error;
/** (1) Constructeur d'une requete de module (delegation)
/* (1) Constructeur d'une requete de module (delegation)
*
* @param String|null $uri URI relative de l'appel
* @param array|null $params Tableau associatif contenant les parametres utiles au traitement
* @param String|null $forced_method Méthode demandée (optionnel)
* @uri<String> URI relative de l'appel
* @param<Array> Tableau associatif contenant les parametres utiles au traitement
* @forced_method<String> Méthode demandée (optionnel)
*
* @return boolean Retourne si oui ou non tout s'est bien passe
* @return status<Boolean> Retourne si oui ou non tout s'est bien passe
*
---------------------------------------------------------*/
private function buildRequestObject($uri=null, $params=null, $forced_method=null) :bool{
private function buildRequestObject($uri=null, $params=null, $forced_method=null){
/* (1) Initialisation
---------------------------------------------------------*/
/* (1) Erreur par défaut */
$this->error = new Error(Err::Success);
/* (2) Si pas parametre manquant, on quitte */
if( is_null($uri) ){
$this->error->set(Err::MissingPath);
return false;
}
if( is_null($uri) )
return $this->error->set(Err::MissingPath);
/* (2) On vérifie la configuration
---------------------------------------------------------*/
/* (1) Dispatch if error */
if( Config::get()->error->get() != Err::Success ){
$this->error = Config::get()->error;
return false;
}
if( Config::get()->error->get() != Err::Success )
return ($this->error = Config::get()->error);
/* (3) Verification des types des parametres
---------------------------------------------------------*/
/* (1) Si path est une <string> */
if( !is_string($uri) ){
$this->error->set(Err::WrongPathModule);
return false;
}
if( !is_string($uri) ) // Si le type est incorrect
return $this->error->set(Err::WrongPathModule);
/* (2) Add slash at the beginning of URI */
if( !preg_match('@^\/@', $uri) )
@ -106,10 +85,8 @@ use \error\core\Error;
$this->raw_params = (is_array($params)) ? $params : [];
/* (4) On définit en constante la méthode HTTP */
if( !isset($_SERVER['REQUEST_METHOD']) && !is_string($forced_method) ){
$this->error->set(Err::UnknownHttpMethod);
return false;
}
if( !isset($_SERVER['REQUEST_METHOD']) && !is_string($forced_method) )
return $this->error->set(Err::UnknownHttpMethod);
$this->http_method = is_string($forced_method) ? strtoupper($forced_method) : strtoupper($_SERVER['REQUEST_METHOD']);
@ -152,14 +129,14 @@ use \error\core\Error;
/** (2) Definit le systeme d'authentification
/* (2) Definit le systeme d'authentification
*
* @param AuthSystem $instance Instance de type AuthSystem
* @instance<AuthSystem> Instance de type AuthSystem
*
* @return boolean Whether the AuthSystem is valid or not
* @return success<Boolean> Whether the AuthSystem is valid or not
*
---------------------------------------------------------*/
public static function setAuthSystem( ?AuthSystem $instance=null) : bool{
public static function setAuthSystem($instance=null){
/* (1) Check instance type */
if( !($instance instanceof AuthSystem) )
return false;
@ -172,22 +149,20 @@ use \error\core\Error;
/** (3) Verification du format et de la coherence du chemin specifie
/* (3) Verification du format et de la coherence du chemin specifie
*
* @param String $uri URI d'appel (commence par /)
* @URI<String> URI d'appel (commence par /)
*
* @return boolean Retourne si oui ou non l'objet est correct
* @return validity<Boolean> Retourne si oui ou non l'objet est correct
*
---------------------------------------------------------*/
private function checkURI(String $uri) : bool{
private function checkURI($uri){
/* (1) Verification format general
---------------------------------------------------------*/
/* (1) If wrong format -> exit */
if( !preg_match('@^\/[^\/]*(\/[^\/]*)*\/?$@', $uri) ){
$this->error->set(Err::WrongPathModule);
return false;
}
if( !preg_match('@^\/[^\/]*(\/[^\/]*)*\/?$@', $uri) )
return $this->error->set(Err::WrongPathModule);
/* (2) Add ending '/' if not there */
if( $uri[strlen($uri)-1] != '/' )
@ -213,10 +188,8 @@ use \error\core\Error;
}
/* (2) If @path not found -> exit */
if( is_null($path) ){
$this->error->set(Err::UnknownModule);
return false;
}
if( is_null($path) )
return $this->error->set(Err::UnknownModule);
/* (3) Extract URI parameters
@ -229,10 +202,8 @@ use \error\core\Error;
$uri_end = "/$uri_end";
/* (3) If invalid format, return error */
if( !preg_match('@^((?:\/[^\/]*)*)\/?$@', $uri_end, $uri_match) ){
$this->error->set(Err::InvalidURI);
return false;
}
if( !preg_match('@^((?:\/[^\/]*)*)\/?$@', $uri_end, $uri_match) )
return $this->error->set(Err::InvalidURI);
/* (4) Add each URI parameter to the parameter store */
$uri_args = array_slice( explode('/', $uri_match[1]), 1);
@ -248,16 +219,12 @@ use \error\core\Error;
$doc_req = $this->http_method == 'OPTIONS';
/* (2) Check if HTTP method is in allowed methods */
if( !in_array($this->http_method, Config::$allowed_http_methods) && !$doc_req ){
$this->error->set(Err::UnknownHttpMethod, $this->http_method);
return false;
}
if( !in_array($this->http_method, Config::$allowed_http_methods) && !$doc_req )
return $this->error->set(Err::UnknownHttpMethod, $this->http_method);
/* (3) Check if HTTP method is defined for this @path */
if( !isset(Config::get()->index[$path][$this->http_method]) && !$doc_req ){
$this->error->set(Err::UnknownMethod, $this->http_method);
return false;
}
if( !isset(Config::get()->index[$path][$this->http_method]) && !$doc_req )
return $this->error->set(Err::UnknownMethod, $this->http_method);
@ -274,12 +241,12 @@ use \error\core\Error;
/** (4) Retourne si on a la permission d'executer cette methode
/* (4) Retourne si on a la permission d'executer cette methode
*
* @return bool Retourne si on a les droits ou pas pour executer cette methode
* @return permission<bool> Retourne si on a les droits ou pas pour executer cette methode
*
---------------------------------------------------------*/
private function checkPermission() : bool{
private function checkPermission(){
/* (1) On recupere les informations utiles
---------------------------------------------------------*/
@ -296,10 +263,8 @@ use \error\core\Error;
if( !is_object(self::$authsystem) || !self::$authsystem instanceof AuthSystem ){
// try to load default AuthSystem
if( !file_exists(__BUILD__.'/api/core/AuthSystemDefault.php') ){
$this->error->set(Err::UnreachableResource);
return false;
}
if( !file_exists(__BUILD__.'/api/core/AuthSystemDefault.php') )
return $this->error->set(Err::UnreachableResource);
// load default AuthSystem class
$classname = '\\api\\core\\AuthSystemDefault';
@ -323,29 +288,25 @@ use \error\core\Error;
/** (5) Verification du type des parametres envoyes
/* (5) Verification du type des parametres envoyes
*
* @return bool Retourne si oui ou non les parametres ont le bon type
* @return correct<bool> Retourne si oui ou non les parametres ont le bon type
*
---------------------------------------------------------*/
private function checkParams() : bool{
private function checkParams(){
/* (1) On verifie qu'il ne manque aucun parametre
---------------------------------------------------------*/
/* (1) Si @params n'est pas un tableau */
if( !is_array($this->raw_params) ){
$this->error->set(Err::MissingParam);
return false;
}
if( !is_array($this->raw_params) )
return $this->error->set(Err::MissingParam);
/* (2) On récupère les données de la méthode */
$method = Config::get()->index[$this->id['path']][$this->id['method']];
/* (3) Si pas 'parameters' dans la config */
if( !isset($method['par']) || !is_array($method['par']) ){
$this->error->set(Err::ConfigError);
return false;
}
if( !isset($method['par']) || !is_array($method['par']) )
return $this->error->set(Err::ConfigError);
/* (2) Si le type est defini, pour chaque param, on teste
@ -355,22 +316,16 @@ use \error\core\Error;
/* (2.1) Vérification des données
---------------------------------------------------------*/
/* (1) Si @name n'est pas une string */
if( !is_string($name) ){
$this->error->set(Err::ConfigError);
return false;
}
if( !is_string($name) )
return $this->error->set(Err::ConfigError);
/* (2) Si @config n'est pas un tableau */
if( !is_array($config) ){
$this->error->set(Err::ConfigError);
return false;
}
if( !is_array($config) )
return $this->error->set(Err::ConfigError);
/* (3) So @config['typ] manquant ou incorrect */
if( !isset($config['typ']) || !is_string($config['typ']) ) {
$this->error->set(Err::ConfigError);
return false;
}
if( !isset($config['typ']) || !is_string($config['typ']) )
return $this->error->set(Err::ConfigError);
/* (2.2) Gestion des spécifications
@ -393,12 +348,10 @@ use \error\core\Error;
$default = $config['def'];
/* (3.1.2) If FILE and not null -> Check type */
if( $config['typ'] != 'FILE' || $default != null ){
if( !Checker::run($config['typ'], $default) ) {
$this->error->set(Err::WrongDefaultParam, $rename, $config['typ']);
return false;
}
}
if( $config['typ'] != 'FILE' || $default != null )
if( !Checker::run($config['typ'], $default) )
return $this->error->set(Err::WrongDefaultParam, $rename, $config['typ']);
}
/* (4) Si de type 'FILE' + fichier existe => on enregistre la ref. */
@ -406,10 +359,8 @@ use \error\core\Error;
$this->params[$rename] = &$_FILES[$name];
/* (4) Si param obligatoire et manquant -> erreur */
if( !isset($this->raw_params[$name]) && !$optional ) {
$this->error->set(Err::MissingParam, $rename);
return false;
}
if( !isset($this->raw_params[$name]) && !$optional )
return $this->error->set(Err::MissingParam, $rename);
/* (2.3) Gestion des valeurs
@ -431,10 +382,8 @@ use \error\core\Error;
$this->raw_params[$name] = $json_rep['json'];
// Si la verification est fausse, on retourne faux
if( !Checker::run($config['typ'], $this->raw_params[$name]) ){
$this->error->set(Err::WrongParam, $rename, $config['typ']);
return false;
}
if( !Checker::run($config['typ'], $this->raw_params[$name]) )
return $this->error->set(Err::WrongParam, $rename, $config['typ']);
// Sinon, on ajoute aux params qu'on enverra à l'appel
else
@ -453,12 +402,12 @@ use \error\core\Error;
/** (6) Ajout des options a partir de la configuration
/* (6) Ajout des options a partir de la configuration
*
* @return bool Retourne FAUS en cas d'erreur
* @return correct<bool> Retourne FAUS en cas d'erreur
*
---------------------------------------------------------*/
private function buildOptions() : bool{
private function buildOptions(){
/* (1) On récupère les options de la méthode en cours
---------------------------------------------------------*/
@ -498,12 +447,12 @@ use \error\core\Error;
/** (7) Execute le traitement associe et remplie la reponse
/* (7) Execute le traitement associe et remplie la reponse
*
* @return Response Retourne une reponse de type <Response> si tout s'est bien passe
* @return answer<Response> Retourne une reponse de type <Response> si tout s'est bien passe
*
---------------------------------------------------------*/
public function dispatch() : Response{
public function dispatch(){
/* (1) Vérifications de niveau 0
---------------------------------------------------------*/
@ -554,11 +503,6 @@ use \error\core\Error;
/* (3) On ajoute les données */
$response->appendAll($returned);
/* (4) Si le Debug est actif on ajoute le debug des repo */
if(Repo::isDebugEnabled()){
$response->append("repoDebug" , Repo::getDebug());
}
/* (4) On retourne la réponse */
return $response;
@ -566,11 +510,10 @@ use \error\core\Error;
/** (8) Gestion d'un téléchargement HTTP
*
* @return Response
*/
public function download($returned) : Response{
/* (8) Gestion d'un téléchargement HTTP
*
*/
public function download($returned){
/* (1) Vérification des erreurs et paramètres
---------------------------------------------------------*/
@ -607,51 +550,46 @@ use \error\core\Error;
/* (2) On affiche le contenu */
echo $returned['body'];
return new Response();
return true;
}
/* (3) Gestion du téléchargement différé (AJAX)
---------------------------------------------------------*/
/* (1) Create if not exists public_html/tmp */
if( !is_dir(__PUBLIC__.'/tmp') ){
mkdir(__PUBLIC__.'/tmp');
chmod(__PUBLIC__.'/tmp', 0775);
}
/* (2) On génère les noms de fichiers utiles */
/* (1) On génère les noms de fichiers utiles */
$target_fname = '/tmp/download_'.uniqid().'.php'; // cible
$buffer_fname = __ROOT__.'/tmp/content_'.uniqid().'.php'; // buffer
/* (3) On écrit le BODY dans un fichier buffer */
/* (2) On écrit le BODY dans un fichier buffer */
$buffer_file = fopen($buffer_fname, 'w');
fwrite($buffer_file, $returned['body']);
fclose($buffer_file);
/* (4) On crée le fichier cible */
/* (3) On crée le fichier cible */
$target_fnameroot = __PUBLIC__.$target_fname;
$taret_file = fopen($target_fnameroot, 'w');
fwrite($taret_file, '<?php'.PHP_EOL);
/* (5) Script qui écrira les headers */
foreach($returned['headers'] as $header=>$value)
fwrite($taret_file, 'header(\''.$header.': '.$value.'\');'.PHP_EOL);
/* (6) Script qui écrira le contenu du buffer */
/* (4) Script qui écrira les headers */
foreach($returned['headers'] as $header=>$value)
fwrite($taret_file, "header(\"$header: $value\");".PHP_EOL);
/* (5) Script qui écrira le contenu du buffer */
chmod($buffer_fname, 0775);
fwrite($taret_file, "readfile('$buffer_fname');".PHP_EOL);
/* (7) Script qui supprimera les fichiers: buffer+target */
/* (6) Script qui supprimera les fichiers: buffer+target */
fwrite($taret_file, "unlink('$buffer_fname');".PHP_EOL);
fwrite($taret_file, "unlink(__FILE__);".PHP_EOL);
fwrite($taret_file, '?>'.PHP_EOL);
/* (8) On ferme le fichier cible */
/* (7) On ferme le fichier cible */
fclose($taret_file);
chmod($target_fnameroot, 0775);
/* (9) On envoie la réponse contenant le lien du fichier cible */
/* (8) On envoie la réponse contenant le lien du fichier cible */
$response = new Response($this->error);
$response->append('link', $target_fname);
@ -661,13 +599,12 @@ use \error\core\Error;
/** (9) Getter générique
/* (9) Getter générique
*
* @param String $index Index de l'attribut
* @index<String> Index de l'attribut
*
* @return mixed
---------------------------------------------------------*/
public function get(?String $index=null){
public function get($index=null){
switch($index){

View File

@ -17,36 +17,31 @@
class Response{
// Attributs prives utiles (initialisation)
/** @var array */
private $data;
/** @var Error */
public $error;
/** CONSTRUCTEUR D'UNE REPONSE DE MODULE
/* CONSTRUCTEUR D'UNE REPONSE DE MODULE
*
* @param Error $error Erreur passee par la requete (si existe)
* @error<ModuleError> Erreur passee par la requete (si existe)
*
*/
public function __construct(?Error $error=null){
public function __construct($error=null){
if( !( $error instanceof Error ) )
$error = new Error(Err::Success);
$this->data = [];
$this->error = $error;
}
/* AJOUTE UNE DONNEE A LA REPONSE
/** AJOUTE UNE DONNEE A LA REPONSE
*
* @param String $key Le nom de la valeur a ajouter
* @param mixed $value La valeur a ajouter
* @key<String> Le nom de la valeur a ajouter
* @value<mixed*> La valeur a ajouter
*
* @return Response
*/
public function append(String $key, $value) : Response{
public function append($key, $value){
// Ajoute une entree pour la cle @key et de valeur @value
$this->data[$key] = $value;
@ -54,13 +49,12 @@
}
/** AJOUTE TOUTES LES DONNEES A LA REPONSE
/* AJOUTE TOUTES LES DONNEES A LA REPONSE
*
* @param array $dataset Le tableau associatif correspondant a la reponse
* @dataset<Array> Le tableau associatif correspondant a la reponse
*
* @return Response
*/
public function appendAll(array $dataset) : Response{
public function appendAll($dataset){
// Si ce n'est pas un tableau, on ne fais rien
if( !is_array($dataset) )
return $this;
@ -78,16 +72,17 @@
return $this;
}
/* RECUPERE UNE DONNEE DE LA REPONSE
/** RECUPERE UNE DONNEE DE LA REPONSE
*
* @param String $key Le nom de la valeur a recuperer
* @key<String> Le nom de la valeur a recuperer
*
* @return mixed|null La valeur a cette cle, NULL si aucune valeur pour cette cle
* @return value<mixed*> La valeur a cette cle
* @return error<null> Retourne NULL si aucune valeur pour cette cle
*
*/
public function get(String $key){
public function get($key){
// Si la valeur de cle @key n'existe pas, on retourne NULL
if( !isset($this->data[$key]) )
return null;
@ -97,9 +92,9 @@
}
/** RECUPERE TOUTES LES DONNEES DE LA REPONSE
/* RECUPERE TOUTES LES DONNEES DE LA REPONSE
*
* @return array Les donnees de la reponse
* @return data<Array> Les donnees de la reponse
*
*/
public function getAll(){
@ -108,12 +103,12 @@
}
/** SERIALISATION A PARTIR DES DONNEES
/* SERIALISATION A PARTIR DES DONNEES
*
* @return String Retourne les donnees serialisees
* @return json<String> Retourne les donnees serialisees
*
*/
public function serialize() : String{
public function serialize(){
// Code Http
$this->error->setHttpCode();

View File

@ -11,7 +11,6 @@ namespace api\module;
use database\core\Repo;
use database\repo\professor;
use database\repo\meta;
use error\core\Error;
use error\core\Err;
@ -20,15 +19,10 @@ class casController{
/* (1) Authentication callback
*
* @popup_mode<boolean> Whether to manage the popup
* @GET[ticket]<String> CAS callback @ticket
*
* @return headers|body<array> The download content
* @return professors<array> The professor(s) data
*
---------------------------------------------------------*/
public static function get($args){
$popup_mode = false;
extract($args);
// login: https://sso.univ-pau.fr/cas/login?service=http://ptut.com:8080/api/v/1.0/cas
@ -51,32 +45,11 @@ class casController{
// Launch PopUp
// window.pop = window.open('https://sso.univ-pau.fr/cas/login?service=http://ptut.com:8080/api/v/1.0/cas', '_blank', 'location=no,height=1024,width=1024,scrollbars=yes,status=no');
/* (0) Initialize
/* (0) Global DOWNLOAD data
---------------------------------------------------------*/
/* (1) Global DOWNLOAD data */
$headers = ['Content-Type' => 'text/html; charset=UTF-8' ];
/* (2) If @popup_mode */
if( $popup_mode !== 0 ){
$body_start = "Veuillez patienter...<br>Vous allez être redirigés<script type='text/javascript'>( typeof window.opener.cas_callback === 'function' ) && window.opener.cas_callback(";
$body_end = "); window.close();</script>";
/* (3) Else -> redirection */
}else{
$homepage = ($_SERVER['SERVER_NAME'] == 'ptut.com' ) ? 'http' : 'https';
$homepage .= '://'.$_SERVER['HTTP_HOST'].'/home';
$body_start = "Veuillez patienter...<br>Vous allez être redirigés<script type='text/javascript'>console.log(";
$body_end = "); document.location = '$homepage'; </script>";
}
/* (4) Reset SESSION */
// $_SESSION['CAS'] = [];
$headers = ['Content-Type' => 'text/html; charset=UTF-8' ];
$body_start = "Veuillez patienter...<br>Vous allez être redirigés<script type='text/javascript'>window.opener.cas_callback(";
$body_end = ");window.close();</script>";
/* (1) Check if already connected
@ -93,111 +66,49 @@ class casController{
/* (2) Fail if no ticket */
if( !isset($_GET['ticket']) || !is_string($_GET['ticket']) || strlen($_GET['ticket']) < 1 )
return [ 'headers' => $headers, 'body' => $body_start.'-1'.$body_end ];
return [ 'headers' => $headers, 'body' => $body_start.'null'.$body_end ];
/* (2) Check ticket (validate)
---------------------------------------------------------*/
/* (1) Build useful variables */
$service = ($_SERVER['SERVER_PORT'] == 80) ? 'http' : 'https';
$service .= '://'.$_SERVER['HTTP_HOST'].'/api/v/1.0/cas/'.$popup_mode;
$service = ($_SERVER['SERVER_NAME'] == 'ptut.com' ) ? 'http' : 'https';
$service .= '://'.$_SERVER['HTTP_HOST'].'/api/v/1.0/cas';
$ticket = urlencode($_GET['ticket']);
$validate_url = "https://sso.univ-pau.fr/cas/serviceValidate?ticket=$ticket&service=$service";
/* (2) Configure & Prepare CURL */
$ch = \curl_init();
$ch = curl_init();
\curl_setopt($ch, CURLOPT_URL, $validate_url);
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $validate_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
/* (3) Execute CURL & Close it */
$output = \curl_exec($ch);
\curl_close($ch);
$output = curl_exec($ch);
curl_close($ch);
/* (4) Fail if not validated */
if( strpos($output, 'user') === false )
return [ 'headers' => $headers, 'body' => $body_start.'-2'.$body_end ];
return [ 'headers' => $headers, 'body' => $body_start.'null'.$body_end ];
/* (5) Extract cas_login */
$cas_login = trim(strip_tags($output));
/* (6) Check empty */
if( strlen($cas_login) < 1 )
return [ 'headers' => $headers, 'body' => $body_start.'-2'.$body_end ];
return [ 'headers' => $headers, 'body' => $body_start.'null'.$body_end ];
/* (3) Meta database: check if @cas_login referenced
/* (3) Store data in session
---------------------------------------------------------*/
/** @var professor $prof_repo */
$prof_repo = Repo::getRepo('professor');
/** @var meta $meta_repo */
$meta_repo = Repo::getRepo('meta');
/* (1) Get the list of linked departments for this @cas_login */
$departments = $meta_repo->get_prof_departments($cas_login);
/* (2) Failure: if no department for @cas_login */
if( count($departments) === 0 )
return [ 'headers' => $headers, 'body' => $body_start.'-3'.$body_end ];
/* (3) Set departments data */
$_SESSION['AvailableDepartments'] = $departments;
/* (4) Choose first department by default */
$_SESSION['CurrentDepartmentId'] = $departments[0]['idDep'];
$_SESSION['VERSION'] = [
'list' => $departments[0]['versions'],
'current' => null
];
/* (5) select version with default = 1 */
foreach($_SESSION['VERSION']['list'] as $v){
if( $v['default'] == 1 ){
$_SESSION['VERSION']['current'] = intval($v['iddatabase']);
$_SESSION['CurrentDatabase'] = $v['dbName'];
break;
}
}
/* (6) if no default -> select first */
if( !is_int($_SESSION['VERSION']) ){
$_SESSION['VERSION']['current'] = intval($_SESSION['VERSION']['list'][0]['iddatabase']);
$_SESSION['CurrentDatabase'] = $_SESSION['VERSION']['list'][0]['dbName'];
}
/* (7) Use this department's database */
Repo::switchDatabase($_SESSION['CurrentDatabase']);
/* (4) Fetch @cas_login professor data
---------------------------------------------------------*/
/* (1) Try to fetch professor */
$by_login = $prof_repo->getByLogin($cas_login);
/* (2) If not found -> reset SESSION */
if( !is_array($by_login) || !isset($by_login['idProfesseur']) || !isset($by_login['admin']) )
return [ 'headers' => $headers, 'body' => $body_start.'-4'.$body_end ];
/* (5) Store data in session
---------------------------------------------------------*/
/* (1) Security */
\session_regenerate_id();
/* (2) Store CAS user data in SESSION */
$_SESSION['CAS'] = [
'login' => $cas_login,
'ticket' => $ticket,
'id' => (int) $by_login['idProfesseur'],
'admin' => (bool) $by_login['admin']
'ticket' => $ticket
];
/* (3) Success CAS login */
/* (2) Success CAS login */
return [
'headers' => $headers,
'body' => $body_start."'".$_SESSION['CAS']['login']."'".$body_end
@ -207,56 +118,20 @@ class casController{
/* (2) Logout from CAS server
*
* @return logged_out<bool> Whether you have been logged out
*
---------------------------------------------------------*/
public function put(){
/* (1) Call logout script
---------------------------------------------------------*/
/* (1) Build useful variables */
$logout_url = "https://sso.univ-pau.fr/cas/logout";
/* (2) Configure & Prepare CURL */
$ch = \curl_init();
\curl_setopt($ch, CURLOPT_URL, $logout_url);
\curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
/* (3) Execute CURL & Close it */
$output = \curl_exec($ch);
\curl_close($ch);
/* (4) Error if no output */
if( strlen($output) < 1 )
return ['logged_out' => false, 'redirect_url' => $logout_url];
/* (4) Destroy session */
\session_destroy();
/* (5) Return if logged out */
return ['logged_out' => true, 'redirect_url' => $logout_url];
}
/* (3) Logout (not from CAS server)
*
* @return logged_out<bool> Whether you have been logged out
*
---------------------------------------------------------*/
public function delete(){
\session_destroy();
/* (1) Remove CAS credentials */
$_SESSION['CAS'] = [];
/* (2) Re-process AuthSystemDefault */
new \api\core\AuthSystemDefault();
/* (3) Return if logged out */
return ['logged_out' => true];
return ['logged_out' => !in_array('cas_user', $_SESSION['AUTH'])];
}
}
}

View File

@ -6,18 +6,18 @@
* Time: 19:36
*/
namespace api\module\department;
namespace api\module\departement;
use database\core\Repo;
use database\repo\department;
use database\repo\departement;
class errorsController
{
public static function get($args){
/** @var department $repo */
$repo = Repo::getRepo("department");
/** @var departement $repo */
$repo = Repo::getRepo("departement");
return ["data" => $repo->getErrors()];
}

View File

@ -1,182 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 10/05/18
* Time: 13:03
*/
namespace api\module\department;
use database\core\Repo;
use database\repo\cours;
use database\repo\formation;
use database\repo\td;
use database\repo\tp;
use database\repo\ue;
use PhpOffice\PhpSpreadsheet\Reader\Xls\Style\Border;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Borders;
class exportController
{
public function get($args){
/** @var ue $ueRepo */
$ueRepo = Repo::getRepo("ue");
/** @var cours $cmRepo */
$cmRepo = Repo::getRepo("cours");
/** @var td $tdRepo */
$tdRepo = Repo::getRepo("td");
/** @var tp $tpRepo */
$tpRepo = Repo::getRepo("tp");
/** @var formation $formationRepo */
$formationRepo = Repo::getRepo("formation");
$ues = $ueRepo->exportUE();
$formations = [];
//cache formations labels
foreach ($formationRepo->get(null) as $form){
$formations[$form["idForm"]] = $form["labelForm"];
}
$formatFormations = function(String $formationsId) use ($formations) : String{
$returned = "";
foreach (json_decode($formationsId,true) as $form){
$returned .= $formations[$form]."+";
}
return rtrim($returned,"+");
};
$spreadsheet = new Spreadsheet();
$excel = $spreadsheet->getActiveSheet();
//set up base document
$arrayHeaders = ["Code","Intitulé","Statut","V.H.","Cours","NbGr","Enseignant","TD","NbGr","Enseignant","TP","NbGr","Enseignant","Equ. TD","Total"];
$excel->setCellValue("B2","CODIFICATION DES UE");
$i = 1;
foreach ($arrayHeaders as $header){
$excel->setCellValueByColumnAndRow($i,4,$header);
$i++;
}
$excel->freezePane("O5");
//set up state variables
$currentFormation = null;
$currentLine = 5;
foreach ($ues as $ue){
if($currentFormation != $ue["labelFormation"]){
$currentFormation = $ue["labelFormation"];
$excel->setCellValue("A$currentLine",$ue["labelFormation"]);
$excel->getStyle("A$currentLine")->getFont()->setBold(true)->setSize(11);
$excel->getStyle("A$currentLine:O$currentLine")->getBorders()->getTop()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE);
$currentLine += 2;
}
//get all groups data
$cm = $cmRepo->getGroups($ue["code"]);
$td = $tdRepo->getGroups($ue["code"]);
$tp = $tpRepo->getGroups($ue["code"]);
//set UE header
$nbrGroupeCM = count($cm);
$nbrGroupeTD = count($td);
$nbrGroupeTP = count($tp);
$volumeUE = $ue["volumeCours"] + $ue["volumeTD"] + $ue["volumeTP"];
$equiTDUE = $nbrGroupeCM*1.5*$ue["volumeCours"] + $nbrGroupeTD*$ue["volumeTD"] + $nbrGroupeTP*$ue["volumeTP"];
$excel->setCellValue("A$currentLine",$ue["code"]);
$excel->setCellValue("B$currentLine",$ue["label"]);
$excel->setCellValue("C$currentLine",$ue["required"] == 1? "OBL" : "OPT");
$excel->setCellValue("D$currentLine","$volumeUE");
$excel->setCellValue("E$currentLine","{$ue["volumeCours"]}");
$excel->setCellValue("F$currentLine","$nbrGroupeCM");
$excel->setCellValue("H$currentLine","{$ue["volumeTD"]}");
$excel->setCellValue("I$currentLine","$nbrGroupeTD");
$excel->setCellValue("K$currentLine","{$ue["volumeTP"]}");
$excel->setCellValue("L$currentLine","$nbrGroupeTP");
$excel->setCellValue("O$currentLine","$equiTDUE");
$excel->getStyle("A$currentLine:O$currentLine")->getFont()->setBold( true )->setSize(9);
$currentLine++;
$nbrLine = max($nbrGroupeCM,$nbrGroupeTD,$nbrGroupeTP)-1;
foreach (range(0,$nbrLine) as $n){
$excel->setCellValue("A$currentLine",$ue["code"]);
$excel->setCellValue("B$currentLine",$ue["label"]);
$equiTD = 0;
if(isset($cm[$n])){
$excel->setCellValue("E$currentLine","{$cm[$n]["volume"]}");
$excel->setCellValue("F$currentLine",$formatFormations($cm[$n]["formations"]));
$excel->setCellValue("G$currentLine",$cm[$n]["lastName"]." ".$cm[$n]["firstName"]);
$equiTD += 1.5*$cm[$n]["volume"];
}
if(isset($td[$n])){
$excel->setCellValue("H$currentLine","{$td[$n]["volume"]}");
$excel->setCellValue("I$currentLine",$formatFormations($td[$n]["formations"]));
$excel->setCellValue("J$currentLine",$td[$n]["lastName"]." ".$td[$n]["firstName"]);
$equiTD += $td[$n]["volume"];
}
if(isset($tp[$n])){
$excel->setCellValue("K$currentLine","{$tp[$n]["volume"]}");
$excel->setCellValue("L$currentLine",$formatFormations($tp[$n]["formations"]));
$excel->setCellValue("M$currentLine",$tp[$n]["lastName"]." ".$tp[$n]["firstName"]);
$equiTD += $tp[$n]["volume"];
}
$excel->setCellValue("N$currentLine","$equiTD");
$excel->getStyle("A$currentLine:O$currentLine")->getFont()->setSize(8);
$currentLine++;
}
$currentLine++;
}
//resize all columns
foreach(range('A','O') as $columnID) {
$excel->getColumnDimension($columnID)->setAutoSize(true);
}
//set content type headers
// header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
//reating writer
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xls($spreadsheet);
//as phpSpreadSheet do not support output on the buffer, we have to write in a temp file then read it
//create temporary file;
$file = tmpfile();
//get URI
$metaDatas = stream_get_meta_data($file);
$tmpFilename = $metaDatas['uri'];
//close file pointer
fclose($file);
//write data
$writer->save("$tmpFilename");
//get file content
return [
'headers' => [
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'Content-Disposition' => 'attachment; filename=archive.xls'
],
'body' => file_get_contents($tmpFilename)
];
}
}

View File

@ -1,25 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 08/03/18
* Time: 17:36
*/
namespace api\module\department;
use database\core\Repo;
use database\repo\department;
class statsController
{
public static function get($args){
/** @var department $repo */
$repo = Repo::getRepo("department");
return ["data" => $repo->getStats()];
}
}

View File

@ -1,28 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 07/05/18
* Time: 17:59
*/
namespace api\module\department\version;
use database\core\Repo;
class switchController
{
public function get($args){
$version = null;
extract($args);
$versionData = Repo::getRepo("meta")->getVersionById($version);
$_SESSION['CurrentDatabase'] = $versionData["dbName"];
$_SESSION['VERSION']['current'] = intval( $version );
return ["success" => true];
}
}

View File

@ -1,158 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 15/03/18
* Time: 15:50
*/
namespace api\module\department;
use database\core\Repo;
use database\repo\meta;
use error\core\Error;
use error\core\Err;
use database\repo\department;
use Ifsnop\Mysqldump\Mysqldump;
class versionController{
/* (4) List available versions for this department
*
* @return versions<array> Version list
*
---------------------------------------------------------*/
public function get($args){
//search for the current department in the session and return its versions
/** @var meta $depRepo */
$depRepo = Repo::getRepo("meta");
//if no department found, return an empty array
return ['versions' => $depRepo->getAllVersions($_SESSION['CurrentDepartmentId']) ];
}
/* (5) Remove an existing version for this department
*
* @version<int> Version name (typically snapshot date)
*
* @return deleted<bool> Whether the version has been deleted
*
---------------------------------------------------------*/
public function delete($args){
$version = null;
extract($args);
/* (1) Try to delete */
$deleted = Repo::getRepo("meta")->deleteVersion($version);
if( !$deleted )
return ['error' => new Error(Err::ModuleError)];
/* (2) Update version list */
$_SESSION['VERSION']['list'] = Repo::getRepo("meta")->getAllVersions($_SESSION['CurrentDepartmentId']);
/* (3) Update current */
$_SESSION['VERSION']['current'] = null;
// select version with default = 1
foreach($_SESSION['VERSION']['list'] as $v){
if( $v['default'] == 1 ){
$_SESSION['VERSION']['current'] = intval($v['iddatabase']);
$_SESSION['CurrentDatabase'] = $v['dbName'];
break;
}
}
// if no default -> select first
if( !is_int($_SESSION['VERSION']) ){
$_SESSION['VERSION']['current'] = intval($_SESSION['VERSION']['list'][0]['iddatabase']);
$_SESSION['CurrentDatabase'] = $_SESSION['VERSION']['list'][0]['dbName'];
}
return ['deleted' => true];
}
/* (6) Creates a new version (snapshot of database) from now
*
* @return created_id<String> The created version id (date)
*
---------------------------------------------------------*/
public function post($args){
$label = null;
extract($args);
/* (2) Try to create the snapshot */
try{
/* (2.1) Get database configuration */
$conf = Repo::getDBConfig();
/* (2.2) Try to dump the database */
/** @var Mysqldump*/
$dump = new Mysqldump(
'mysql:host='.$conf['host'].';dbname='.$_SESSION['CurrentDatabase'],
$conf['username'],
$conf['password']
);
//create temporary file;
$file = tmpfile();
//get URI
$metaDatas = stream_get_meta_data($file);
$tmpFilename = $metaDatas['uri'];
//close file pointer
fclose($file);
//fill the file with sql dump
$dump->start($tmpFilename);
/** @var department $depRepo */
$depRepo = Repo::getRepo("department");
$dbName = $depRepo->createVersionDatabase($_SESSION['CurrentDepartmentId'],file_get_contents($tmpFilename));
/** @var meta $metaRep */
$metaRep = Repo::getRepo("meta");
$versionId = $metaRep->createVersion($label, $dbName,$_SESSION['CurrentDepartmentId'] ,false);
/* (2.5) Return status */
return ['created_id' => $versionId ];
/* (3) On error -> dispatch error */
}catch(\Exception $e){
return ['error' => new Error(Err::RepoError)];
}
}
/* (6) Modify a version and use it
*
*
* @return bool success
*
---------------------------------------------------------*/
public function put($args){
$label = null;
$version = null;
$default = null;
extract($args);
/** @var meta $metaRepo */
$metaRepo = Repo::getRepo("meta");
/* (4) Return status */
return [ 'updated' => $metaRepo->updateVersion($version,$label,$default) ];
}
}

View File

@ -1,164 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 15/03/18
* Time: 11:47
*/
namespace api\module;
use database\core\Repo;
use database\repo\database;
use database\repo\department;
use database\repo\meta;
use database\repo\professor;
class departmentController
{
/* (1) Get 1 | all departments
*
* @id_dep<int> [OPT] Department id
*
* @return departments<array> Matching departments
*
---------------------------------------------------------*/
public function get($args){
$id_dep = null;
extract($args);
/** @var meta $meta_repo */
$meta_repo = Repo::getRepo('meta');
/* (1) Get the list of linked departments for this @cas_login */
$departments = $meta_repo->get_prof_departments($_SESSION['CAS']['login']);
/* (2) If no @id_dep -> return all */
if( is_null($id_dep) )
return ['departments' => $departments];
/* (3) If @id_dep -> Only add elements that are @id_dep */
$filtered = [];
foreach($departments as $dep){
if( $dep['idDep'] == $id_dep ){
$filtered[] = $dep;
break;
}
}
/* (4) Return filtered departments */
return ['departments' => $filtered];
}
public function put($args){
$department = 0;
extract($args);
/** @var meta $meta_repo */
$meta_repo = Repo::getRepo('meta');
$deps = $meta_repo->get_prof_departments($_SESSION['CAS']['login']);
if( count($deps) > 0 ){
foreach($deps as $dep){
if( $dep['idDep'] == $department ){
$_SESSION['AvailableDepartments'] = $deps;
$_SESSION['CurrentDepartmentId'] = $dep['idDep'];
$_SESSION['VERSION'] = [
'list' => $dep['versions'],
'current' => null
];
// select version with default = 1
foreach($_SESSION['VERSION']['list'] as $v){
if( $v['default'] == 1 ){
$_SESSION['VERSION']['current'] = intval($v['iddatabase']);
$_SESSION['CurrentDatabase'] = $v['dbName'];
break;
}
}
// if no default -> select first
if( !is_int($_SESSION['VERSION']) ){
$_SESSION['VERSION']['current'] = intval($_SESSION['VERSION']['list'][0]['iddatabase']);
$_SESSION['CurrentDatabase'] = $_SESSION['VERSION']['list'][0]['dbName'];
}
return ['switched' => true];
}
}
}
return ['switched' => false];
}
public function post($args){
$name = null;
extract($args);
/** @var meta $metaRepo */
$metaRepo = Repo::getRepo("meta");
/** @var professor $profRep */
$profRep = Repo::getRepo("professor");
/** @var database $dbRepo */
$dbRepo = Repo::getRepo("database");
//create the department in the meta database
$depId = $metaRepo->createDepartment($name);
//link the current user to that department
$metaRepo->link($_SESSION['CAS']['login'],$depId);
//create the database and init the structure
$dbName = $dbRepo->init($depId);
//link the new database to the department
$metaRepo->createVersion("Version 1",$dbName,$depId,true);
//get the current user data from current department
$user = $profRep->get($_SESSION['CAS']['id'])[0];
//switch our connexion to that database
Repo::switchDatabase($dbName);
//create the default admin in the new database (categories are common to all department)
$profRep->create($user["lastName"],
$user["firstName"],
$user["Categorie_idCategorie"],
$user["hoursToDo"],
$user["abreviation"],
true,
$user["casLogin"]);
//update user session
$departments = $metaRepo->get_prof_departments($user["casLogin"]);
$_SESSION['AvailableDepartments'] = $departments;
//we are good now
return [];
}
}

View File

@ -63,11 +63,9 @@ class excelController
$addEU = function() use (&$UECode,&$allUE,&$UE){
//determine if UE is disabled (if cours+td+tp = 0)
$totalVH = 0;
if(is_array($UE["groups"]) && count($UE["groups"]) > 0){
foreach ($UE["groups"] as $groups){
foreach ($groups as $group){
$totalVH += $group["VH"];
}
foreach ($UE["groups"] as $groups){
foreach ($groups as $group){
$totalVH += $group["VH"];
}
}
@ -350,10 +348,6 @@ class excelController
/** @var tp $tpRepo */
$tpRepo = Repo::getRepo("tp");
$CoursToLink = [];
$TDToLink = [];
$TPToLink = [];
foreach ($allUE as $codeUE => $UE){
if($UE["defaultFormation"]){
@ -383,25 +377,22 @@ class excelController
switch ($type){
case "Course":
$CoursToLink[] = ["id" => $coursRepo->create( $codeUE,
$allProf[$group["professor"]]["dbId"],
$UE["disabled"] ? $UE["CourseVH"] : $group["VH"],
[]),
"form" => $formations];
$coursRepo->create( $codeUE,
$allProf[$group["professor"]]["dbId"],
$UE["disabled"] ? $UE["CourseVH"] : $group["VH"],
$formations);
break;
case "TD":
$TDToLink[] = ["id" => $tdRepo->create($codeUE,
$allProf[$group["professor"]]["dbId"],
$UE["disabled"] ? $UE["TdVH"] : $group["VH"],
[]),
"form" => $formations];
$tdRepo->create($codeUE,
$allProf[$group["professor"]]["dbId"],
$UE["disabled"] ? $UE["TdVH"] : $group["VH"],
$formations);
break;
case "TP":
$TPToLink[] = ["id" => $tpRepo->create($codeUE,
$allProf[$group["professor"]]["dbId"],
$UE["disabled"] ? $UE["TpVH"] : $group["VH"],
[]),
"form" => $formations];
$tpRepo->create($codeUE,
$allProf[$group["professor"]]["dbId"],
$UE["disabled"] ? $UE["TpVH"] : $group["VH"],
$formations);
break;
}
@ -410,28 +401,7 @@ class excelController
}
}
Repo::enableStacking();
foreach ($CoursToLink as $cour){
foreach ($cour["form"] as $formation){
$coursRepo->linkFormation($formation,$cour["id"]);
}
}
foreach ($TDToLink as $cour){
foreach ($cour["form"] as $formation){
$tdRepo->linkFormation($formation,$cour["id"]);
}
}
foreach ($TPToLink as $cour){
foreach ($cour["form"] as $formation){
$tpRepo->linkFormation($formation,$cour["id"]);
}
}
Repo::flushStack();
//return [ 'data' => ["professors" => $allProf, "formations" => $allFormations, "UEs" => $allUE ] ];
return["data" => true];
return [ 'data' => ["professors" => $allProf, "formations" => $allFormations, "UEs" => $allUE ] ];
}catch (Exception $e){
return [ 'error' => new Error(Err::UnknownError) ];
}

View File

@ -14,7 +14,7 @@ use database\core\Repo;
class formationController
{
public function get($args){
public static function get($args){
$form_id = null;
extract($args);
@ -24,37 +24,4 @@ class formationController
return ['formations' => $repo->get($form_id)];
}
public function post($args){
$label = null;
$isInternal = null;
extract($args);
/** @var \database\repo\formation $repo */
$repo = Repo::getRepo("formation");
return ['idFormation' => $repo->create($label,$isInternal)];
}
public function put($args){
$idFormation = null;
$label = null;
$isInternal = null;
extract($args);
/** @var \database\repo\formation $repo */
$repo = Repo::getRepo("formation");
return ['success' => $repo->update($idFormation,$label,$isInternal)];
}
public function delete($args){
$idFormation = null;
extract($args);
/** @var \database\repo\formation $repo */
$repo = Repo::getRepo("formation");
return ['success' => $repo->delete($idFormation)];
}
}

View File

@ -10,7 +10,6 @@ namespace api\module\professor;
use database\core\Repo;
use database\repo\category;
use database\repo\formation;
use database\repo\ue;
use error\core\Error;
@ -21,7 +20,6 @@ class filterController{
/* (1) Get professor ID(s) matching a specific filter
*
* @categories<array> [OPT] Array of categories IDS
* @formations<array> [OPT] Array of formation IDS
* @ues<array> [OPT] Array of UE codes
*
@ -30,21 +28,22 @@ class filterController{
---------------------------------------------------------*/
public static function post($args){
$categories = [];
$formations = [];
$ues = [];
extract($args);
/** @var ue $ue_repo */
$ue_repo = Repo::getRepo('ue');
/* (1) If no filter -> return error
---------------------------------------------------------*/
/* (1) Pre-process conditions */
$no_category = !is_array($categories) || count($categories) < 1;
$no_ue = !is_array($ues) || count($ues) < 1;
$no_formation = !is_array($formations) || count($formations) < 1;
/* (2) Exit if no filter */
if( $no_category && $no_ue && $no_formation )
if( $no_ue && $no_formation )
return ['error' => new Error(Err::MissingParam, 'You must give at least 1 parameter')];
/* (3) Init. result array (only keys used for unicity) */
@ -52,35 +51,7 @@ class filterController{
/* (2) Filter by categories
---------------------------------------------------------*/
if( is_array($categories) ){
/** @var category $cat_repo */
$cat_repo = Repo::getRepo('category');
/* (1) For each formation -> get request */
foreach($categories as $cat_id){
// 1. Ignore if wrong format
if( !is_numeric($cat_id) || !is_int($cat_id) )
continue;
// 2. Get from repo
$fetched_ids = $cat_repo->getProfessors( intval($cat_id) );
// 3. Add in unique set
foreach($fetched_ids as $prof_id)
$matches_uniq[ intval($prof_id['idProfesseur']) ] = null;
}
}
/* (3) Filter by formation
/* (2) Filter by formation
---------------------------------------------------------*/
if( is_array($formations) ){
@ -108,7 +79,7 @@ class filterController{
/* (4) Filter by ue
/* (3) Filter by ue
---------------------------------------------------------*/
if( is_array($ues) ){

View File

@ -1,437 +0,0 @@
<?php
namespace api\module\professor;
use database\core\Repo;
use database\repo\prof;
use database\repo\cours;
use database\repo\td;
use database\repo\tp;
use database\repo\formation;
use error\core\Error;
use error\core\Err;
class pdfController{
/* (1) Get professor PDF fiche matching a specific ID
*
* @prof_id<array> Professor ID
*
* @return download<File> The PDF fiche
---------------------------------------------------------*/
public static function get($args){
$prof_id = -1;
extract($args);
if(!$_SESSION["CAS"]["admin"] && $_SESSION["CAS"]["id"] != $prof_id){
return [
'headers' => ["Content-Type" => "text/html"],
'body' => "Unauthorized access"
];
}
/* (0) Initialize
---------------------------------------------------------*/
/* (1) Initialize data structure */
$data = [
'prof' => [],
'cours' => [],
'td' => [],
'tp' => [],
'form' => []
];
/* (2) Get repositories */
/** @var professor $prof_repo */
$prof_repo = Repo::getRepo('professor');
/** @var formation $form_repo */
$form_repo = Repo::getRepo('formation');
/** @var cours $cours_repo */
$cours_repo = Repo::getRepo('cours');
/** @var td $td_repo */
$td_repo = Repo::getRepo('td');
/** @var tp $tp_repo */
$tp_repo = Repo::getRepo('tp');
/* (1) Get professor data
---------------------------------------------------------*/
/* (1) Request */
$fetched = $prof_repo->getWithVH($prof_id);
/* (2) Error */
if( count($fetched) < 1 )
return ['error' => new Error(Err::NoMatchFound)];
/* (3) Extract data */
$data['prof'] = $fetched[0];
/* (2) Get each Cours
---------------------------------------------------------*/
/* (1) Request */
$fetched = $cours_repo->getForProfessor($prof_id);
/* (2) Store data if no error */
if( !is_null($fetched) )
$data['cours'] = $fetched;
/* (3) For each Cours -> parse formation list */
foreach($data['cours'] as $kcours=>$cours)
$data['cours'][$kcours]['formations'] = json_decode($cours['formations']);
/* (3) get each TD
---------------------------------------------------------*/
/* (1) Request */
$fetched = $td_repo->getForProfessor($prof_id);
/* (2) Store data if no error */
if( !is_null($fetched) )
$data['td'] = $fetched;
/* (3) For each TD -> parse formation list */
foreach($data['td'] as $ktd=>$td)
$data['td'][$ktd]['formations'] = json_decode($td['formations']);
/* (4) get each TP
---------------------------------------------------------*/
/* (1) Request */
$fetched = $tp_repo->getForProfessor($prof_id);
/* (2) Store data if no error */
if( !is_null($fetched) )
$data['tp'] = $fetched;
/* (3) For each TP -> parse formation list */
foreach($data['tp'] as $ktp=>$tp)
$data['tp'][$ktp]['formations'] = json_decode($tp['formations']);
/* (5) Get formations (id => label)
---------------------------------------------------------*/
/* (1) Request */
$fetched = $form_repo->get(null);
/* (2) Error: no formation found */
if( !is_array($fetched) )
return ['error' => new Error(Err::RepoError)];
/* (3) Reference formations by key = idForm */
foreach($fetched as $form)
$data['form'][intval($form['idForm'])] = $form;
/* (6) Render PDF
---------------------------------------------------------*/
/* (1) Generate body */
$body = self::generate_pdf_body($data);
/* (2) Set headers */
$fullname = $data['prof']['firstName'].' '.$data['prof']['lastName'];
$date = date('d-m-Y');
$title = "Fiche enseignant - $fullname ($date)";
$headers = [
// 'Content-Description' => 'File Transfer',
'Content-Transfer-Encoding' => 'binary',
'Content-Disposition' => 'attachment; filename="'.$title.'"',
'Cache-Control' => 'public, must-revalidate, max-age=0',
'Pragma' => 'public',
'X-Generator' => 'mPDF',
'Expires' => 'Sat, 26 Jul 1997 05:00:00 GMT',
'Last-Modified' => gmdate('D, d M Y H:i:s').' GMT',
'Content-Type' => 'application/pdf'
];
/* (3) Generate download */
return [
'headers' => $headers,
'body' => $body
];
}
private static function generate_pdf_body($data){
/* (1) Format data
---------------------------------------------------------*/
/* (1) Get fullname */
$fullname = $data['prof']['firstName'].' '.$data['prof']['lastName'];
/* (2) Get formatted date */
$date = date('d-m-Y');
/* (3) Total horaire */
$total_h = floatval($data['prof']['VHCours'])
+ floatval($data['prof']['VHTd'])
+ floatval($data['prof']['VHTp']);
$equiTD = floatval($data['prof']['equiTD']);
/* (4) Heures manquantes */
// TOTAL_H or equiTD ???
$missing_h = floatval($data['prof']['hoursToDo']) - $equiTD;
$missing_h = $missing_h < 0 ? 0 : $missing_h;
/* (5) Heures sup */
$sup_h = $equiTD > floatval($data['prof']['hoursToDo']) ? $equiTD - floatval($data['prof']['hoursToDo']) : 0;
/* (2) Initialize PDF
---------------------------------------------------------*/
/* (1) Get Font default directory */
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
/* (2) Get Font data */
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
/* (3) Create PDF file */
$pdf = new \Mpdf\Mpdf([
'mode' => 'utf-8',
'defaultCssFile' => __PUBLIC__.'/css/pdf.css',
'tempDir' => __ROOT__.'/tmp',
'fontDir' => array_merge($fontDirs, [ __PUBLIC__.'/font/' ]),
'fontdata' => $fontData + [
'Fira Sans' => [
'R' => 'FiraSans-Regular.ttf'
]
],
'default_font' => 'Fira Sans'
]);
/* (4) Set PDF title */
$pdf->SetTitle("Fiche enseignant - $fullname ($date)");
/* (5) Store SVG */
$svg_warning = '<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" height="10" width="10" viewBox="0 0 1792 1792">
<path d="m 1024,1375 v -190 q 0,-14 -9.5,-23.5 Q 1005,1152 992,1152 H 800 q -13,0 -22.5,9.5 -9.5,9.5 -9.5,23.5 v 190 q 0,14 9.5,23.5 9.5,9.5 22.5,9.5 h 192 q 13,0 22.5,-9.5 9.5,-9.5 9.5,-23.5 z m -2,-374 18,-459 q 0,-12 -10,-19 -13,-11 -24,-11 H 786 q -11,0 -24,11 -10,7 -10,21 l 17,457 q 0,10 10,16.5 10,6.5 24,6.5 h 185 q 14,0 23.5,-6.5 9.5,-6.5 10.5,-16.5 z m -14,-934 768,1408 q 35,63 -2,126 -17,29 -46.5,46 -29.5,17 -63.5,17 H 128 Q 94,1664 64.5,1647 35,1630 18,1601 -19,1538 16,1475 L 784,67 q 17,-31 47,-49 30,-18 65,-18 35,0 65,18 30,18 47,49 z" style="fill: #ea4b35" />
</svg>';
/* (3) Set Header|Footer
---------------------------------------------------------*/
/* (1) Set Header content (Left, Right) */
$header_content = [
'C' => [ 'color' => '#aaa', 'content' => "Fiche enseignant $fullname" ],
'line' => 1
];
/* (2) Apply Header */
$pdf->setHeader([
'odd' => $header_content,
'even' => $header_content
]);
/* (1) Set Footer content (Left, Right) */
$footer_content = [
'L' => [ 'color' => '#aaa', 'content' => "Généré le $date" ],
'R' => [ 'color' => '#aaa', 'content' => 'Page {PAGENO} sur {nbpg}' ],
'line' => 1
];
/* (2) Apply Footer */
$pdf->setFooter([
'odd' => $footer_content,
'even' => $footer_content
]);
/* (4) Page 1 - Récapitulatif
---------------------------------------------------------*/
/* (1) Initialize page */
$pdf->AddPage();
/* (2) Write content */
$pdf->WriteHTML('<br>
<h3>1. Récapitulatif</h3>
<hr>
<article>
<p>
La liste des informations récapitulative est basée sur les données de tous les enseignants enregistrés à ce jour.
</p>
<blockquote>
Il est à noter qu\'elle contient les données générées au '.$date.'. Elle peut ne plus être à jour.
</blockquote>
<br><br><br>
<table>
<thead>
<tr>
<td class="color ac">Donnée</td>
<td class="color ac">Valeur</td>
</tr>
</thead>
<tbody>
<tr>
<td class="ar">Heures à faire</td>
<td>'.$data['prof']['hoursToDo'].' h</td>
</tr>
<tr>
<td class="ar">Equivalents TD</td>
<td>'.$data['prof']['equiTD'].' h</td>
</tr>
<tr>
<td class="ar">Heures programmées</td>
<td>'.$total_h.' h</td>
</tr>
<tr>
<td class="ar">Sous service</td>
<td>'.( $missing_h>0 ? "$svg_warning $missing_h" : $missing_h).' h</td>
</tr>
<tr>
<td class="ar">Sur service</td>
<td>'.$sup_h.' h</td>
</tr>
</tbody>
</table>
</article>
');
/* (5) Page 2 - Enseignements
---------------------------------------------------------*/
/* (1) Initialize page */
$pdf->AddPage();
/* (2) Write content */
$pdf->WriteHTML('<br>
<h3>2. Enseignements</h3>
<hr>
<article>
<p>
La liste des enseignements générée dans le tableau ci-dessous est uniquement à titre informatif et n\'est pas contractuelle.
</p>
<blockquote>
Il est à noter qu\'elle contient les données générées au '.$date.'. Elle peut ne plus être à jour.
</blockquote>
<br><br><br>
<table>
<thead>
<tr>
<th colspan="5" class="ac">Liste des enseignements programmés</th>
</tr>
<tr>
<td class="color ac">Code UE</td>
<td class="color ac">Nom UE</td>
<td class="color ac">Prestation</td>
<td class="color ac">volume horaire</td>
<td class="color ac">formations</td>
</tr>
</thead>
<tbody>');
/* (3) List Cours */
foreach($data['cours'] as $kc=>$c){
$pdf->WriteHTML('<tr>
<td>'.$c['code'].'</td>
<td>'.$c['label'].'</td>
<td>Cours</td>
<td>'.$c['volume'].' heures</td>
<td><ul>');
// print formations
foreach($c['formations'] as $f)
if( isset($data['form'][$f]) )
$pdf->WriteHTML('<li>'.$data['form'][$f]['labelForm'].'</li>');
$pdf->WriteHTML('</ul></td></tr>');
}
/* (4) List TD */
foreach($data['td'] as $kc=>$c){
$pdf->WriteHTML('<tr>
<td>'.$c['code'].'</td>
<td>'.$c['label'].'</td>
<td>TD</td>
<td>'.$c['volume'].' heures</td>
<td><ul>');
// print formations
foreach($c['formations'] as $f)
if( isset($data['form'][$f]) )
$pdf->WriteHTML('<li>'.$data['form'][$f]['labelForm'].'</li>');
$pdf->WriteHTML('</ul></td></tr>');
}
/* (5) List TP */
foreach($data['tp'] as $kc=>$c){
$pdf->WriteHTML('<tr>
<td>'.$c['code'].'</td>
<td>'.$c['label'].'</td>
<td>TP</td>
<td>'.$c['volume'].' heures</td>
<td><ul>');
// print formations
foreach($c['formations'] as $f)
if( isset($data['form'][$f]) )
$pdf->WriteHTML('<li>'.$data['form'][$f]['labelForm'].'</li>');
$pdf->WriteHTML('</ul></td></tr>');
}
/* (6) End HTML */
$pdf->WriteHTML('</tr>
</tbody>
</table>
</article>');
/* (N) Print out PDF file
---------------------------------------------------------*/
return $pdf->Output("Fiche enseignant - $fullname ($date)", 'S');
}
}

View File

@ -0,0 +1,29 @@
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 27/02/18
* Time: 16:19
*/
namespace api\module\professor;
use database\core\Repo;
use database\repo\professor;
class statsController{
public static function get($args){
$idProf = 0;
extract($args);
//get data from the database
/** @var professor $profRepo */
$profRepo = Repo::getRepo("professor");
$VH = $profRepo->getWithVH($idProf);
return ["data" => $VH];
}
}

View File

@ -84,29 +84,13 @@ class professorController{
/** @var professor $prof_repo */
$prof_repo = Repo::getRepo('professor');
/* (1) Check for unique field to be unique
---------------------------------------------------------*/
/* (1) Check @firstName + @lastName */
$exists = $prof_repo->exists($lastName, $firstName, $casLogin);
/* (1) Check if professor already exists */
$exists = $prof_repo->exists($lastName, $firstName);
/* (2) If found -> already exists */
if( !is_null($exists) )
return ['error' => new Error(Err::AlreadyExists)];
/* (3) if @casLogin -> check unique */
if( !is_null($casLogin) ){
/* (1) Check if @casLogin already exists */
$exists = $prof_repo->getByLogin($casLogin);
/* (2) If found -> already exists */
if( !is_null($exists) )
return ['error' => new Error(Err::AlreadyExists)];
}
/* (3) Else try to create */
$repo_rtn = $prof_repo->create(
$lastName,
@ -161,7 +145,6 @@ class professorController{
* @initials<int> [OPT] The professor's initials
* @isAdmin<bool> [OPT] Whether the professor is an admin
* @casLogin<String> [OPT] The professor's CAS username
* @remCas<bool> [OPT] Whether to remove the CAS login (only works if @casLogin is NULL)
*
* @return updated<bool> Whether it has been updated
*
@ -175,55 +158,13 @@ class professorController{
$initials = null;
$isAdmin = null;
$casLogin = null;
$remCas = true;
extract($args);
/* Get the professor repo */
/** @var professor $prof_repo */
$prof_repo = Repo::getRepo('professor');
/* (1) If @casLogin -> check unique
---------------------------------------------------------*/
if( !is_null($casLogin) ){
/* (1) Check if @casLogin already exists */
$exists_cas = $prof_repo->getByLogin($casLogin);
/* (2) If found -> already exists */
if( !is_null($exists_cas) )
return ['error' => new Error(Err::AlreadyExists)];
}
/* (2) If @lastName or @firstName -> check unique
---------------------------------------------------------*/
if( !is_null($firstName) || !is_null($lastName) ){
/* (1) Try to fetch @prof_id data */
$fetched = $prof_repo->get($prof_id);
/* (2) Error if cannot find */
if( count($fetched) < 1 )
return ['error' => new Error(Err::NoMatchFound)];
/* (3) Extract @firstName + @lastName */
$names = [
'lastName' => is_null($lastName) ? $fetched[0]['lastName'] : $lastName,
'firstName' => is_null($firstName) ? $fetched[0]['firstName'] : $firstName
];
/* (4) Check if exists */
$exists = $prof_repo->exists($names['lastName'], $names['firstName']);
/* (2) If found -> already exists */
if( !is_null($exists) )
return ['error' => new Error(Err::AlreadyExists)];
}
/* (3) Try to update */
/* (1) Try to update */
return ['updated' => $prof_repo->update(
$prof_id,
$lastName,
@ -232,7 +173,7 @@ class professorController{
$hoursToDo,
$initials,
$isAdmin,
$remCas === true && is_null($casLogin) ? '' : $casLogin
$casLogin
)];
}

View File

@ -1,191 +0,0 @@
<?php
namespace api\module\ue;
use database\core\Repo;
use database\repo\cours;
use error\core\Error;
use error\core\Err;
class coursController{
/* (1) Create a new Cours
*
* @code<String> UE code
*
* @return groups<array> The list of groups for this UE
*
---------------------------------------------------------*/
public static function post($args){
$code = "";
$idProf = null;
$volume = 0;
$formations = [];
extract($args);
/* Get the repos */
/** @var cours $cours_repo */
$cours_repo = Repo::getRepo('cours');
/** @var ue $ue_repo */
$ue_repo = Repo::getRepo('ue');
/* (1) Fetch default formation from UE
---------------------------------------------------------*/
/* (1) Try to fetch the cours' UE */
$fetched_ue = $ue_repo->get($code);
/* (2) Manage error */
if( !is_array($fetched_ue) || count($fetched_ue) < 1 )
return ['error' => new Error(Err::RepoError)];
$defaultForm = intval($fetched_ue[0]['idForm']);
/* (3) Add to formation list if got a valid default formation */
if( is_int($defaultForm) && $defaultForm >= 0 && !in_array($defaultForm, $formations) )
$formations[] = $defaultForm;
/* (2) Create the cours
---------------------------------------------------------*/
/* (1) Try to create cours */
$created_id = $cours_repo->create($code, $idProf, $volume, $formations);
/* (2) Manage error */
if( is_null($created_id) || !is_int($created_id) )
return ['error' => new Error(Err::RepoError)];
return ['created_id' => $created_id, 'formations' => $formations];
}
/* (2) Get groups for a specific UE
*
* @code<String> UE code
*
* @return groups<array> The list of groups for this UE
*
---------------------------------------------------------*/
public static function get($args){
$code = "";
extract($args);
/* Get the cours repo */
/** @var cours $cours_repo */
$cours_repo = Repo::getRepo('cours');
/* (1) Try to fetch data */
$fetched = $cours_repo->getGroups($code);
/* (2) Manage error */
if( is_null($fetched) || !is_array($fetched) )
return ['error' => new Error(Err::RepoError)];
/* (3) Parse JSON list */
foreach($fetched as $f=>$v)
$fetched[$f]['formations'] = json_decode($v['formations']);
return ['groups' => $fetched];
}
/* (3) Updates an existing Cours
*
* @idCours<int> Id of the Cours to update
* @idProf<int> [OPT] The new professor ID (-1 to unset)
* @volume<int> [OPT] The new number of hours for the Cours
* @add_form<array> List of ids of formations to add
* @rem_form<array> List of ids of formations to remove
*
* @return updated<bool> Whether the Cours have been updated
*
---------------------------------------------------------*/
public static function put($args){
$idCours = -1;
$idProf = null;
$volume = null;
$add_form = [];
$rem_form = [];
extract($args);
/* Get the cours repo */
/** @var cours $cours_repo */
$cours_repo = Repo::getRepo('cours');
/* (1) If nothing to do -> error */
if( is_null($idProf) && is_null($volume) && count($add_form) + count($rem_form) == 0)
return ['error' => new Error(Err::MissingParam)];
/* (2) If have to update @idProf */
if( !is_null($idProf) ){
// call repo
$updated = $cours_repo->updateProf($idCours, $idProf < 0 ? NULL : $idProf );
// if error -> dispatch
if( !$updated )
return ['error' => new Error(Err::RepoError)];
}
/* (3) If have to update @volume */
if( !is_null($volume) ){
// call repo
$updated = $cours_repo->updateVolume($idCours, $volume);
// if error -> dispatch
if( !$updated )
return ['error' => new Error(Err::RepoError)];
}
/* (4) If have to add formations -> add them */
if( count($add_form) > 0 ){
foreach($add_form as $id_form)
$cours_repo->linkFormation($id_form, $idCours);
}
/* (5) If have to remove formations -> remove them */
if( count($rem_form) > 0 ){
foreach($rem_form as $id_form)
$cours_repo->unlinkFormation($id_form, $idCours);
}
return ['updated' => true];
}
/* (4) Deletes an existing Cours
*
* @idCours<int> Id of the Cours
*
* @return deleted<bool> Whether it has been deleted
*
---------------------------------------------------------*/
public static function delete($args){
$idCours = 0;
extract($args);
/* Get the cours repo */
/** @var cours $cours_repo */
$cours_repo = Repo::getRepo('cours');
/* (1) Dispatch response from repo */
return ['deleted' => $cours_repo->delete($idCours)];
}
}

View File

@ -1,191 +0,0 @@
<?php
namespace api\module\ue;
use database\core\Repo;
use database\repo\td;
use error\core\Error;
use error\core\Err;
class tdController{
/* (1) Create a new TD
*
* @code<String> UE code
*
* @return groups<array> The list of groups for this UE
*
---------------------------------------------------------*/
public static function post($args){
$code = "";
$idProf = null;
$volume = 0;
$formations = [];
extract($args);
/* Get the repos */
/** @var td $td_repo */
$td_repo = Repo::getRepo('td');
/** @var ue $ue_repo */
$ue_repo = Repo::getRepo('ue');
/* (1) Fetch default formation from UE
---------------------------------------------------------*/
/* (1) Try to fetch the TD' UE */
$fetched_ue = $ue_repo->get($code);
/* (2) Manage error */
if( !is_array($fetched_ue) || count($fetched_ue) < 1 )
return ['error' => new Error(Err::RepoError)];
$defaultForm = intval($fetched_ue[0]['idForm']);
/* (3) Add to formation list if got a valid default formation */
if( is_int($defaultForm) && $defaultForm >= 0 && !in_array($defaultForm, $formations) )
$formations[] = $defaultForm;
/* (2) Create the TD
---------------------------------------------------------*/
/* (1) Try to create td */
$created_id = $td_repo->create($code, $idProf, $volume, $formations);
/* (2) Manage error */
if( is_null($created_id) || !is_int($created_id) )
return ['error' => new Error(Err::RepoError)];
return ['created_id' => $created_id, 'formations' => $formations];
}
/* (2) Get groups for a specific UE
*
* @code<String> UE code
*
* @return groups<array> The list of groups for this UE
*
---------------------------------------------------------*/
public static function get($args){
$code = "";
extract($args);
/* Get the td repo */
/** @var td $td_repo */
$td_repo = Repo::getRepo('td');
/* (1) Try to fetch data */
$fetched = $td_repo->getGroups($code);
/* (2) Manage error */
if( is_null($fetched) || !is_array($fetched) )
return ['error' => new Error(Err::RepoError)];
/* (3) Parse JSON list */
foreach($fetched as $f=>$v)
$fetched[$f]['formations'] = json_decode($v['formations']);
return ['groups' => $fetched];
}
/* (3) Updates an existing TD
*
* @idTD<int> Id of the TD to update
* @idProf<int> [OPT] The new professor ID (-1 to unset)
* @volume<int> [OPT] The new number of hours for the TD
* @add_form<array> List of ids of formations to add
* @rem_form<array> List of ids of formations to remove
*
* @return updated<bool> Whether the TD have been updated
*
---------------------------------------------------------*/
public static function put($args){
$idTD = -1;
$idProf = null;
$volume = null;
$add_form = [];
$rem_form = [];
extract($args);
/* Get the td repo */
/** @var td $td_repo */
$td_repo = Repo::getRepo('td');
/* (1) If nothing to do -> error */
if( is_null($idProf) && is_null($volume) && count($add_form) + count($rem_form) == 0)
return ['error' => new Error(Err::MissingParam)];
/* (2) If have to update @idProf */
if( !is_null($idProf) ){
// call repo
$updated = $td_repo->updateProf($idTD, $idProf < 0 ? NULL : $idProf );
// if error -> dispatch
if( !$updated )
return ['error' => new Error(Err::RepoError)];
}
/* (3) If have to update @volume */
if( !is_null($volume) ){
// call repo
$updated = $td_repo->updateVolume($idTD, $volume);
// if error -> dispatch
if( !$updated )
return ['error' => new Error(Err::RepoError)];
}
/* (4) If have to add formations -> add them */
if( count($add_form) > 0 ){
foreach($add_form as $id_form)
$td_repo->linkFormation($id_form, $idTD);
}
/* (5) If have to remove formations -> remove them */
if( count($rem_form) > 0 ){
foreach($rem_form as $id_form)
$td_repo->unlinkFormation($id_form, $idTD);
}
return ['updated' => true];
}
/* (4) Deletes an existing TD
*
* @idTD<int> Id of the TD
*
* @return deleted<bool> Whether it has been deleted
*
---------------------------------------------------------*/
public static function delete($args){
$idTD = 0;
extract($args);
/* Get the td repo */
/** @var td $td_repo */
$td_repo = Repo::getRepo('td');
/* (1) Dispatch response from repo */
return ['deleted' => $td_repo->delete($idTD)];
}
}

View File

@ -1,191 +0,0 @@
<?php
namespace api\module\ue;
use database\core\Repo;
use database\repo\tp;
use error\core\Error;
use error\core\Err;
class tpController{
/* (1) Create a new TP
*
* @code<String> UE code
*
* @return groups<array> The list of groups for this UE
*
---------------------------------------------------------*/
public static function post($args){
$code = "";
$idProf = null;
$volume = 0;
$formations = [];
extract($args);
/* Get the repos */
/** @var tp $tp_repo */
$tp_repo = Repo::getRepo('tp');
/** @var ue $ue_repo */
$ue_repo = Repo::getRepo('ue');
/* (1) Fetch default formation from UE
---------------------------------------------------------*/
/* (1) Try to fetch the TP' UE */
$fetched_ue = $ue_repo->get($code);
/* (2) Manage error */
if( !is_array($fetched_ue) || count($fetched_ue) < 1 )
return ['error' => new Error(Err::RepoError)];
$defaultForm = intval($fetched_ue[0]['idForm']);
/* (3) Add to formation list if got a valid default formation */
if( is_int($defaultForm) && $defaultForm >= 0 && !in_array($defaultForm, $formations) )
$formations[] = $defaultForm;
/* (2) Create the TP
---------------------------------------------------------*/
/* (1) Try to create tp */
$created_id = $tp_repo->create($code, $idProf, $volume, $formations);
/* (2) Manage error */
if( is_null($created_id) || !is_int($created_id) )
return ['error' => new Error(Err::RepoError)];
return ['created_id' => $created_id, 'formations' => $formations];
}
/* (2) Get groups for a specific UE
*
* @code<String> UE code
*
* @return groups<array> The list of groups for this UE
*
---------------------------------------------------------*/
public static function get($args){
$code = "";
extract($args);
/* Get the tp repo */
/** @var tp $tp_repo */
$tp_repo = Repo::getRepo('tp');
/* (1) Try to fetch data */
$fetched = $tp_repo->getGroups($code);
/* (2) Manage error */
if( is_null($fetched) || !is_array($fetched) )
return ['error' => new Error(Err::RepoError)];
/* (3) Parse JSON list */
foreach($fetched as $f=>$v)
$fetched[$f]['formations'] = json_decode($v['formations']);
return ['groups' => $fetched];
}
/* (3) Updates an existing TP
*
* @idTP<int> Id of the TP to update
* @idProf<int> [OPT] The new professor ID (-1 to unset)
* @volume<int> [OPT] The new number of hours for the TP
* @add_form<array> List of ids of formations to add
* @rem_form<array> List of ids of formations to remove
*
* @return updated<bool> Whether the TP have been updated
*
---------------------------------------------------------*/
public static function put($args){
$idTP = -1;
$idProf = null;
$volume = null;
$add_form = [];
$rem_form = [];
extract($args);
/* Get the tp repo */
/** @var tp $tp_repo */
$tp_repo = Repo::getRepo('tp');
/* (1) If nothing to do -> error */
if( is_null($idProf) && is_null($volume) && count($add_form) + count($rem_form) == 0)
return ['error' => new Error(Err::MissingParam)];
/* (2) If have to update @idProf */
if( !is_null($idProf) ){
// call repo
$updated = $tp_repo->updateProf($idTP, $idProf < 0 ? NULL : $idProf );
// if error -> dispatch
if( !$updated )
return ['error' => new Error(Err::RepoError)];
}
/* (3) If have to update @volume */
if( !is_null($volume) ){
// call repo
$updated = $tp_repo->updateVolume($idTP, $volume);
// if error -> dispatch
if( !$updated )
return ['error' => new Error(Err::RepoError)];
}
/* (4) If have to add formations -> add them */
if( count($add_form) > 0 ){
foreach($add_form as $id_form)
$tp_repo->linkFormation($id_form, $idTP);
}
/* (5) If have to remove formations -> remove them */
if( count($rem_form) > 0 ){
foreach($rem_form as $id_form)
$tp_repo->unlinkFormation($id_form, $idTP);
}
return ['updated' => true];
}
/* (4) Deletes an existing TP
*
* @idTP<int> Id of the TP
*
* @return deleted<bool> Whether it has been deleted
*
---------------------------------------------------------*/
public static function delete($args){
$idTP = 0;
extract($args);
/* Get the tp repo */
/** @var tp $tp_repo */
$tp_repo = Repo::getRepo('tp');
/* (1) Dispatch response from repo */
return ['deleted' => $tp_repo->delete($idTP)];
}
}

View File

@ -36,161 +36,10 @@ class ueController{
/* (1) Get All ues or 1 by its code (if set) */
$fetched = $ue_repo->get($code);
/* (2) Parse 'formations' from json array */
foreach($fetched as $f=>$v)
$fetched[$f]['formations'] = \json_decode($v['formations']);
/* (3) Return data */
return ['ues' => $fetched];
}
/* (2) Creates a new UE
*
* @code<String> The code of the UE
* @label<String> The UE label (name)
* @required<bool> If the UE is required
* @volumeCours<float> The UE required volume of COURSES
* @volumeTD<float> The UE required volume of TD
* @volumeTP<float> The UE required volume of TP
* @disabled<bool> [OPT] If it is disabled
* @defaultFormation<int> [OPT] If there is a foreign key for a default formation (if only one formation)
*
* @return created_code<int> The created UE code (if no error)
*
---------------------------------------------------------*/
public static function post($args){
$code = "";
$label = "";
$required = false;
$volumeCours = 0;
$volumeTD = 0;
$volumeTP = 0;
$disabled = true;
$defaultFormation = -1;
extract($args);
/* Get the ue repo */
/** @var ue $ue_repo */
$ue_repo = Repo::getRepo('ue');
/* (1) Check if ue code already exists */
$exists = $ue_repo->get($code);
/* (2) If found -> already exists */
if( count($exists) > 0 )
return ['error' => new Error(Err::AlreadyExists)];
/* (3) Else try to create */
$repo_rtn = $ue_repo->create(
$code,
$label,
$required,
$volumeCours,
$volumeTD,
$volumeTP,
$disabled,
is_int($defaultFormation) && $defaultFormation < 0 ? null : $defaultFormation
);
/* (4) If repo error -> return it */
if( is_null($repo_rtn) )
return ['error' => new Error(Err::RepoError)];
/* (5) Else return UID */
return ['created_code' => $repo_rtn];
}
/* (3) Deletes an existing UE
*
* @code<String> The UE code
*
* @return deleted<bool> Whether it has been removed
*
---------------------------------------------------------*/
public static function delete($args){
$code = '';
extract($args);
/* Get the ue repo */
/** @var ue $ue_repo */
$ue_repo = Repo::getRepo('ue');
/* (1) Try to delete */
return ['deleted' => $ue_repo->delete($code)];
}
/* (4) Edits an existing UE
*
* @code<String> The code of the UE
* @new_code<String> [OPT] The new code of the UE
* @label<String> [OPT] The UE label (name)
* @required<bool> [OPT] If the UE is required
* @volumeCours<float> [OPT] The UE required volume of COURSES
* @volumeTD<float> [OPT] The UE required volume of TD
* @volumeTP<float> [OPT] The UE required volume of TP
* @disabled<bool> [OPT] If it is disabled
* @defaultFormation<int> [OPT] default formation for this UE (-1 to unset, NULL to ignore)
*
* @return updated<bool> Whether it has been updated
*
---------------------------------------------------------*/
public static function put($args){
$code = "";
$new_code = "";
$label = "";
$required = false;
$volumeCours = 0;
$volumeTD = 0;
$volumeTP = 0;
$disabled = true;
$defaultFormation = null;
extract($args);
/* Get the ue repo */
/** @var ue $ue_repo */
$ue_repo = Repo::getRepo('ue');
/* (1) Check for @new_code to be unique (not already used)
---------------------------------------------------------*/
if( !is_null($new_code) ){
/* (1) Check @new_code */
$exists = $ue_repo->get($new_code);
/* (2) If found -> already exists */
if( count($exists) > 0 )
return ['error' => new Error(Err::AlreadyExists)];
}
/* (2) Try to update
---------------------------------------------------------*/
return ['updated' => $ue_repo->update(
$code,
$new_code,
$label,
$required,
$volumeCours,
$volumeTD,
$volumeTP,
$disabled,
$defaultFormation
)];
}
}

View File

@ -11,7 +11,6 @@
**************************/
namespace database\core;
use database\core\PDOWrapper\PDOWrapper;
use \error\core\Error;
use \error\core\Err;
@ -19,7 +18,7 @@
class DatabaseDriver{
/* STATIC ATTRIBUTES */
private static function conf() : array{
private static function conf(){
// YOUR CONFIGURATION BEHIND
$path = __CONFIG__.'/database-driver.json';
@ -37,10 +36,11 @@
return $parsed;
}
/** @var DatabaseDriver[] */
private static $path; // Databases configurations files
private static $config; // PDO configurations
private static $instance = []; // Database driver instance list
/** @var Error */
public $error;
/* ATTRIBUTES */
@ -52,16 +52,15 @@
/** CONSTRUCTOR OF A DATABASE DRIVER
/* CONSTRUCTOR OF A DATABASE DRIVER
*
* @param String $host Database Server's host
* @param String $dbname Database name
* @param String $username Database username
* @param String $password Database password
* @param bool $debug
* @host<String> Database Server's host
* @dbname<String> Database name
* @username<String> Database username
* @password<String> Database password
*
*/
private function __construct(String $host, String $dbname, String $username, String $password, bool $debug = false){
private function __construct($host, $dbname, $username, $password){
/* (2) Stores configuration */
$this->host = $host;
$this->dbname = $dbname;
@ -70,19 +69,14 @@
try{
$this->pdo = new PDOWrapper('mysql:host='.$this->host.';dbname='.$this->dbname.';charset=utf8', $this->username, $this->password, [
$this->pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->dbname.';charset=utf8', $this->username, $this->password, [
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
\PDO::ATTR_TIMEOUT => 5,
\PDO::ERRMODE_EXCEPTION => true
\PDO::ATTR_TIMEOUT => 5
]);
$this->pdo->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, false);
$this->pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
if($debug){
$this->pdo->enableDebug();
}
// On signale que tout s'est bien passe
$this->error = new Error(Err::Success);
@ -98,20 +92,22 @@
**** Multiton Management (static) ****
************************************************/
/** ADDS A NEW CONNECTION
/* ADDS A NEW CONNECTION
*
* @param String $label [optional] Database Label
* @label<String> [optional] Database Label
*
* @return boolean If added successfully
* @return status<Boolean> If added successfully
*
*/
private static function add(String $label='default') : bool{
private static function add($label=null){
$conf = self::conf();
/* [1] Default values
=========================================================*/
/* (1) If label isn't given */
is_null($label) && ($label = 'default');
/* (1) If label and no path */
/* (2) If label and no path */
if( $label !== 'default' && !isset($conf[$label]) )
return false;
@ -122,20 +118,12 @@
/* (1) If local -> instanciates with local configuration */
// if( !checkdnsrr($_SERVER['SERVER_NAME'], 'NS') )
if(!isset($conf[$label]['local']['debug'])){
$conf[$label]['local']['debug'] = false;
}
self::$instance[$label] = new DatabaseDriver($conf[$label]['local']['host'], $conf[$label]['local']['dbname'], $conf[$label]['local']['user'], $conf[$label]['local']['password']);
/* (2) If Remote -> instanciates with Remote configuration */
// else
// self::$instance[$label] = new DatabaseDriver($conf[$label]['remote']['host'], $conf[$label]['remote']['dbname'], $conf[$label]['remote']['user'], $conf[$label]['remote']['password']);
if(isset($_SESSION['CurrentDatabase']) && is_string($_SESSION['CurrentDatabase'])){
$conf[$label]['local']['dbname'] = $_SESSION['CurrentDatabase'];
}else{
$_SESSION["CurrentDatabase"] = $conf[$label]['local']['dbname'];
}
self::$instance[$label] = new DatabaseDriver($conf[$label]['local']['host'], $conf[$label]['local']['dbname'], $conf[$label]['local']['user'], $conf[$label]['local']['password'],$conf[$label]['local']['debug']);
return true ;
return true;
}catch(\Exception $e){
@ -147,20 +135,22 @@
}
/** GET A DATABASE DRIVER INSTANCE
/* GET A DATABASE DRIVER INSTANCE
*
* @param String $label [optional] Driver's label
* @throws \Exception
* @return DatabaseDriver Multiton
* @label<String> [optional] Driver's label
*
* @return driver<Database> Multiton
*
*/
public static function get(String $label='default') : DatabaseDriver{
public static function get($label=null){
$conf = self::conf();
/* [1] Checks arguments
=========================================================*/
/* (1) Label default value */
is_null($label) && ($label = 'default');
/* (1) If no label, or unknown label */
/* (2) If no label, or unknown label */
if( !isset(self::$instance[$label]) ){
/* (2.1) Try to add the configuration if exists */
@ -181,68 +171,29 @@
/** retourne la connection statique
* @param String|null $label
* @throws \Exception
* @param null $label
* @return \PDO
*/
public static function getPDO(?String $label=null) : \PDO{
if(is_string($label)){
$instance = self::get($label);
}else{
$instance = self::get();
}
public static function getPDO($label=null){
$instance = self::get($label);
return $instance->pdo;
}
/**
* @return \PDO
*/
public function pdo(){
return $this->pdo;
}
/**
* @return array
*/
public function getConfig(){
return [
'host' => $this->host,
'dbname' => $this->dbname,
'username' => $this->username,
'password' => $this->password
'username' => $this->username
];
}
/**
* enable request stacking
*/
public function enableStacking(){
$this->pdo->enableStacking();
}
/**
* send all the stacked request and flush the stack
*/
public function flushStack(){
$this->pdo->executeStack();
}
/** get all debug data
* @return array
*/
public function getDebug() : array{
return $this->pdo->getDebug();
}
/**
* @return bool
*/
public function isDebugEnabled() : bool {
return $this->pdo->isDebugEnabled();
}
}

View File

@ -1,65 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 30/08/16
* Time: 17:42
*/
namespace database\core\PDOWrapper;
class PDOStatementWrapper extends \PDOStatement
{
/** @var String */
private $statement;
/** @var array */
private $parameters;
/** @var PDOWrapper */
private $connexion;
/**
* PDOStatementWrapper constructor.
* @param String $statement
* @param PDOWrapper $connexion
*/
public function __construct(String $statement, PDOWrapper $connexion)
{
$this->statement = $statement;
$this->connexion = $connexion;
}
/**
* @param array $input_parameters
* @return bool
*/
public function execute($input_parameters = []) : bool
{
$this->parameters = $input_parameters;
$this->connexion->stackStatement($this);
return true;
}
/**
* @return string
*/
public function getStatement() : String
{
return $this->statement;
}
/**
* @return array
*/
public function getParameters() : array
{
return $this->parameters;
}
}

View File

@ -1,198 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 30/08/16
* Time: 17:26
*/
namespace database\core\PDOWrapper;
class PDOWrapper extends \PDO
{
/** @var PDOStatementWrapper[] */
private $statements = [];
/** @var bool */
private $stacking = false;
/** @var array */
private $debug = [];
/** @var bool */
private $debugEnabled = false;
/**
* PDOWrapper constructor.
* @param String $dsn
* @param String $username
* @param String $passwd
* @param array $options
*/
public function __construct(String $dsn, String $username, String $passwd, array $options = [])
{
parent::__construct($dsn, $username, $passwd, $options);
}
/**
* @param string $statement
* @param array $options
* @return \PDOStatement
*/
public function prepare($statement, $options = []) : \PDOStatement
{
if($this->debugEnabled){
$this->storeDebug();
}
if($this->stacking){
return new PDOStatementWrapper($statement, $this);
}else{
$st = parent::prepare($statement, $options);
if($st === false){
throw new \PDOException("There is an error in your SQL statement");
}
return $st;
}
}
/**
* @throws \ReflectionException
*
* @return void
*/
private function storeDebug(){
//get all the debug info about the repo
$prepareStack = debug_backtrace(0,3)[1];
$stack = debug_backtrace(0,3)[2];
//create the reflection object
$f = new \ReflectionMethod($stack["class"],$stack["function"]);
//get only the repo name
$className = explode("\\",$stack["class"]);
$className = $className[count($className)-1];
$result = [];
//if we are flushing a stack, just count the number of request stacked
if($stack["function"] == "executeStack"){
$result["StackedRequest"] = true;
$result["numberOfStackedRequest"] = substr_count($prepareStack["args"][0],";");
//if we are not stacking, log the repo call
}else if(!$this->stacking){
//store results
$result["repoName"] = $className;
$result["methodName"] = $stack["function"];
$result["args"] = [];
foreach ($f->getParameters() as $key => $param) {
$result["args"][$param->name] = $stack["args"][$key];
}
//else we are stacking a request, we should not log it
}else{
return;
}
$this->debug[] = $result;
}
/**
* @return array
*/
public function getDebug() : array{
return $this->debug;
}
/**
* Enable request stacking
*/
public function enableStacking(){
$this->stacking = true;
}
/**
* @return bool
*/
public function isDebugEnabled() : bool{
return $this->debugEnabled;
}
/**
* @param PDOStatementWrapper $st
*/
public function stackStatement(PDOStatementWrapper $st){
array_push($this->statements,$st);
}
/**
* Enable repo debug
*/
public function enableDebug(){
$this->debugEnabled = true;
}
/**
* disable repo debug
*/
public function disableDebug(){
$this->debugEnabled = false;
}
/** Execute the stored request stack
* @return bool
*/
public function executeStack(){
//init the statements and the generator of number
$finalStatement = '';
$finalExecute = [];
$i = 0;
//for each request stacked
foreach ($this->statements as $request){
$statement = $request->getStatement();
// we have to modify the parameters index at the same time that we modify the request, so we use static class attribute
$tempParametes = $request->getParameters();
//find the given pattern in the request, then call our function and replace the matched string by the return value of our function
$finalStatement .= rtrim(preg_replace_callback("/(:[a-z_\-0-9]*)/is",function($matches) use (&$i,&$tempParametes){
//copy the parameter with the modified index
$tempParametes[":$i"] = $tempParametes[$matches[0]];
//delete the old index
unset($tempParametes[$matches[0]]);
//return the modified string for replacement
return ":".$i++;
},$statement),';').';';
$finalExecute += $tempParametes;
}
//disable stacking
$this->stacking = false;
//enable prepare emulation (native prepare do not accept stacked requests
parent::setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
$this->beginTransaction();
$req = $this->prepare($finalStatement);
$success = $req->execute($finalExecute);
//as we execute multiple query that we don't fetch, we have to close the cursor if we want to do other requests later
$req->closeCursor();
$this->commit();
//using beginTransaction/commit disable the autocommit, we re-activate it
$this->setAttribute(\PDO::ATTR_AUTOCOMMIT,1);
parent::setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
return $success;
}
}

View File

@ -12,7 +12,6 @@
namespace database\core;
use database\core\PDOWrapper\PDOWrapper;
use \error\core\Error;
use \error\core\Err;
@ -21,9 +20,6 @@
/* (1) Driver
---------------------------------------------------------*/
/**
* @var DatabaseDriver
*/
private static $driver = null;
public static function setDriver(DatabaseDriver $driver){ self::$driver = $driver; }
@ -61,30 +57,6 @@
return $instance;
}
public static function enableStacking(){
static::$driver->enableStacking();
}
public static function flushStack(){
static::$driver->flushStack();
}
public static function getDebug() : array{
return static::$driver->getDebug();
}
public static function isDebugEnabled() : bool{
return static::$driver->isDebugEnabled();
}
public static function switchDatabase(string $dbName){
return static::$driver->pdo()->exec("USE $dbName;SET autocommit=1;");
}
public static function getDBConfig() : array{
return static::$driver->getConfig();
}

View File

@ -41,14 +41,14 @@ class category extends Repo_i{
LEFT JOIN UE U ON Cours.UE_code = U.code
GROUP BY Prof.Categorie_idCategorie, U.disabled
HAVING U.disabled = 0) VHCours ON VHCours.idCat = Cat.idCategorie
LEFT JOIN (SELECT IFNULL(SUM(TD.volume),0) VHTd , Prof.Categorie_idCategorie idCat
FROM Professeur Prof
LEFT JOIN TD ON TD.Professeur_idProfesseur = Prof.idProfesseur
LEFT JOIN UE U2 ON TD.UE_code = U2.code
GROUP BY Prof.Categorie_idCategorie, U2.disabled
HAVING U2.disabled = 0) VHTd ON VHTd.idCat = Cat.idCategorie
LEFT JOIN (SELECT IFNULL(SUM(TP.volume),0) VHTp, Prof.Categorie_idCategorie idCat
FROM Professeur Prof
LEFT JOIN TP ON TP.Professeur_idProfesseur = Prof.idProfesseur
@ -105,37 +105,4 @@ class category extends Repo_i{
}
/* (5) Gets all professors who teaches a category by ids (array)
*
* @cat_id<int> The category id
*
* @return professors<array> The professors' UID matching the @cat_id category
*
---------------------------------------------------------*/
public function getProfessors(int $cat_id) : array{
/* (1) Prepare statement */
$st = $this->pdo->prepare("SELECT idProfesseur FROM Professeur WHERE Categorie_idCategorie = :cat_id;");
/* (2) Bind params and execute statement */
if( is_bool($st) ) return [];
$success = $st->execute([ ':cat_id' => $cat_id ]);
/* (3) Manage error */
if( !$success )
return [];
/* (4) Get data */
$fetched = $st->fetchAll();
/* (5) Return [] on no result */
if( $fetched === false )
return [];
/* (6) Return data */
return $fetched;
}
}

View File

@ -13,282 +13,75 @@ use database\core\Repo_i;
class cours extends Repo_i {
/* (1) Create a new Cours
*
* @code<String> The code of the UE containing the Cours
* @idProf<String> [OPT] The ID of the prof who teaches the Cours
* @volume<float> The number of hours (float)
* @formations<array> The list of formations for that Cours (list of int)
* @return created_code<String> Code of the created UE (NULL on error)
*
* @return created_id<int> UID of the created Cours (NULL on error)
*
---------------------------------------------------------*/
public function create(string $code, ?int $idProf, float $volume, array $formations) : ?int{
/* (1) Prepare statement */
$st = $this->pdo->prepare('INSERT INTO Cours(UE_code, Professeur_idProfesseur, volume)
VALUE(:UE, :idProf, :vol)');
/* (2) Manage statement error */
if( is_bool($st) )
return NULL;
/* (3) Try to execute request */
$success = $st->execute([
':UE' => $code,
':idProf' => $idProf,
':vol' => $volume
public function create(string $codeUE, ?int $idProf, float $volume, array $formations) : int{
//create the group
$st = $this->pdo->prepare("INSERT INTO Cours(UE_code, Professeur_idProfesseur, volume)
VALUE(:UE, :idProf, :vol)");
$st->execute([
"UE" => $codeUE,
"idProf" => $idProf,
"vol" => $volume
]);
/* (4) Manage error */
if( !$success )
return NULL;
$idCours = $this->pdo->lastInsertId();
/* (5) Store @created_id */
$created_id = (int) $this->pdo->lastInsertId();
/* (6) We are done if there is no formations */
if( count($formations) <= 0)
return $created_id;
/* (7) Else -> create each formation */
foreach($formations as $form_id){
// 1. Ignore if wrong format
if( !is_int($form_id) || $form_id < 0 )
continue;
// 2. Link formation to created Cours
$this->linkFormation($form_id, $created_id);
//if there is formations, link them with the group
if(count($formations) > 0){
$linkSt = $this->pdo->prepare("INSERT INTO GroupeCours(Formation_idFormation, Cours_idCours)
VALUE (:form, :cours)");
foreach ($formations as $form){
$linkSt->execute([
"form" => $form,
"cours" => $idCours
]);
}
}
/* (7) Return @created_id */
return $created_id;
return $idCours;
}
/* (2) Unlink a formation from a Cours
*
* @idFormation<int> Id of the formation
* @idCours<int> Id of the Cours
*
* @return unlinked<bool> Whether it has been unlinked
*
---------------------------------------------------------*/
public function unlinkFormation(int $idFormation, int $idCours) : bool{
$st = $this->pdo->prepare("DELETE FROM GroupeCours WHERE Cours_idCours = :cours AND Formation_idFormation = :form");
/* (1) Prepare statement */
$st = $this->pdo->prepare('DELETE FROM GroupeCours WHERE Cours_idCours = :cours AND Formation_idFormation = :form');
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) EXecute and dispatch status */
return $st->execute([
':cours' => $idCours,
':form' => $idFormation
"cours" => $idCours,
"form" => $idFormation
]);
}
/* (3) Link a formation to a Cours
*
* @idFormation<int> Id of the formation
* @idCours<int> Id of the Cours
*
* @return linked<bool> Whether it has been linked
*
---------------------------------------------------------*/
public function linkFormation(int $idFormation, int $idCours) : bool{
$st = $this->pdo->prepare("INSERT INTO GroupeCours(Cours_idCours,Formation_idFormation)
VALUE(:cours, :form)");
/* (1) Try to remove first if it already exists */
$this->unlinkFormation($idFormation, $idCours);
/* (2) Prepare statement */
$st = $this->pdo->prepare('INSERT INTO GroupeCours(Cours_idCours,Formation_idFormation)
VALUE(:cours, :form)');
/* (3) Manage statement error */
if( is_bool($st) )
return false;
/* (4) EXecute and dispatch status */
return $st->execute([
':cours' => $idCours,
':form' => $idFormation
"cours" => $idCours,
"form" => $idFormation
]);
}
public function updateProf(?int $prof) : bool {
$st = $this->pdo->prepare("UPDATE Cours SET Professeur_idProfesseur = :prof");
/* (4.1) Updates an existing Cours
*
* @idCours<int> Id of the Cours
* @idProf<int> [OPT] Id of the prof (NULL to set to NULL)
*
* @return updated<bool> Whether it has been updated
*
---------------------------------------------------------*/
public function updateProf(int $idCours, ?int $idProf) : bool {
/* (1) Prepare statement */
$st = $this->pdo->prepare('UPDATE Cours
SET Professeur_idProfesseur = :idProf
WHERE idCours = :idCours');
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) Execute and dispatch status */
return $st->execute([ ':idCours' => $idCours, ':idProf' => $idProf ]);
return $st->execute([
"prof" => $prof
]);
}
/* (4.2) Updates an existing Cours
*
* @idCours<int> Id of the Cours
* @volume<float> [OPT] The new number of hours
*
* @return updated<bool> Whether it has been updated
*
---------------------------------------------------------*/
public function updateVolume(int $idCours, float $volume) : bool {
/* (1) Prepare statement */
$st = $this->pdo->prepare('UPDATE Cours
SET volume = :volume
WHERE idCours = :idCours');
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) Execute and dispatch status */
return $st->execute([ ':idCours' => $idCours, ':volume' => $volume ]);
public function updateVolume(float $volume) : bool {
$st = $this->pdo->prepare("UPDATE Cours SET volume = :vol");
return $st->execute([
"vol" => $volume
]);
}
/* (5) Deletes an existing cours
*
* @idCours<int> Id of the Cours
*
* @return deleted<bool> Whether it has been deleted
*
---------------------------------------------------------*/
public function delete(int $id) :bool {
/* (1) Prepare statement */
$st = $this->pdo->prepare("DELETE FROM Cours WHERE idCours = :id");
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) Execute and dispatch status */
return $st->execute([ ':id' => $id ]);
}
/* (6) Get groups for a specific UE
*
* @code<String> UE code
*
* @return groups<array> The list of groups for this UE
* NULL on error
*
---------------------------------------------------------*/
public function getGroups(String $code) : ?array{
/* (1) Prepare statement */
$st = $this->pdo->prepare("SELECT
c.UE_code code,
c.idCours,
p.idProfesseur idProf,
p.firstName,
p.lastName,
IFNULL(lform.flist, '[]') formations,
c.volume
FROM Cours c
LEFT JOIN ( SELECT gc.Cours_idCours idCours, CONCAT('[', GROUP_CONCAT(DISTINCT gc.Formation_idFormation),']') flist
FROM GroupeCours gc
GROUP BY gc.Cours_idCours
ORDER BY gc.Formation_idFormation DESC
) lform ON c.idCours = lform.idCours
LEFT JOIN Professeur p ON p.idProfesseur = c.Professeur_idProfesseur
WHERE c.UE_code = :code;");
/* (2) Check statement */
if( is_bool($st) )
return NULL;
/* (3) Execute statement */
$success = $st->execute([':code' => $code]);
/* (4) Check error */
if( !$success )
return NULL;
/* (5) Dispatch fetch result */
return $st->fetchAll();
}
/* (7) Get groups for a specific Professor
*
* @prof_id<int> Professor ID
*
* @return groups<array> The list of groups for this Professor
* NULL on error
*
---------------------------------------------------------*/
public function getForProfessor(int $prof_id) : ?array{
/* (1) Prepare statement */
$st = $this->pdo->prepare("SELECT
c.UE_code code,
ue.label label,
c.idCours,
IFNULL(lform.flist, '[]') formations,
c.volume
FROM Cours c
LEFT JOIN ( SELECT gc.Cours_idCours idCours, CONCAT('[', GROUP_CONCAT(DISTINCT gc.Formation_idFormation),']') flist
FROM GroupeCours gc
GROUP BY gc.Cours_idCours
ORDER BY gc.Formation_idFormation DESC
) lform ON c.idCours = lform.idCours
JOIN UE ue ON ue.code = c.UE_code
WHERE c.Professeur_idProfesseur = :prof_id;");
/* (2) Check statement */
if( is_bool($st) )
return NULL;
/* (3) Execute statement */
$success = $st->execute([':prof_id' => $prof_id]);
/* (4) Check error */
if( !$success )
return NULL;
/* (5) Dispatch fetch result */
return $st->fetchAll();
return $st->execute([
"id" => $id
]);
}
}

View File

@ -1,266 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 09/05/18
* Time: 16:55
*/
namespace database\repo;
use database\core\Repo;
use database\core\Repo_i;
class database extends Repo_i {
/**
* @param int $depId
* @return String the name of the department database
* @throws \Exception
*/
public function init(int $depId) : String{
/** @var department $metaRep */
$metaRep = Repo::getRepo("department");
$SQL = "
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Table `Categorie`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Categorie` (
`idCategorie` INT(11) NOT NULL,
`labelCategorie` VARCHAR(100) NOT NULL,
PRIMARY KEY (`idCategorie`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `Professeur`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Professeur` (
`idProfesseur` INT(11) NOT NULL AUTO_INCREMENT,
`casLogin` VARCHAR(50) NULL DEFAULT NULL,
`lastName` VARCHAR(50) NULL DEFAULT NULL,
`firstName` VARCHAR(50) NULL DEFAULT NULL,
`abreviation` VARCHAR(10) NULL DEFAULT NULL COMMENT 'Abreviation used in the excel document',
`admin` TINYINT(4) NOT NULL DEFAULT 0,
`hoursToDo` INT(11) NOT NULL DEFAULT 0,
`Categorie_idCategorie` INT(11) NOT NULL,
PRIMARY KEY (`idProfesseur`),
INDEX `fk_Professeur_Categorie1_idx` (`Categorie_idCategorie` ASC),
CONSTRAINT `fk_Professeur_Categorie1`
FOREIGN KEY (`Categorie_idCategorie`)
REFERENCES `Categorie` (`idCategorie`)
ON DELETE NO ACTION
ON UPDATE CASCADE)
ENGINE = InnoDB
AUTO_INCREMENT = 34
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `Formation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Formation` (
`idFormation` INT(11) NOT NULL AUTO_INCREMENT,
`labelFormation` VARCHAR(50) NULL DEFAULT NULL,
`isInternal` TINYINT(4) NULL DEFAULT 1,
PRIMARY KEY (`idFormation`))
ENGINE = InnoDB
AUTO_INCREMENT = 20
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `UE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `UE` (
`code` VARCHAR(20) NOT NULL,
`label` VARCHAR(100) NOT NULL,
`required` TINYINT(4) NOT NULL DEFAULT 1,
`volumeCours` FLOAT NOT NULL DEFAULT 0,
`volumeTP` FLOAT NOT NULL DEFAULT 0,
`volumeTD` FLOAT NOT NULL,
`disabled` TINYINT(4) NOT NULL DEFAULT 0,
`Formation_idFormation` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`code`),
INDEX `fk_UE_Formation1_idx` (`Formation_idFormation` ASC),
CONSTRAINT `fk_UE_Formation1`
FOREIGN KEY (`Formation_idFormation`)
REFERENCES `Formation` (`idFormation`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
COMMENT = 'Table contenant le code et le label des UE';
-- -----------------------------------------------------
-- Table `Cours`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Cours` (
`idCours` INT(11) NOT NULL AUTO_INCREMENT,
`UE_code` VARCHAR(20) NOT NULL,
`Professeur_idProfesseur` INT(11) NULL DEFAULT NULL,
`volume` FLOAT NOT NULL DEFAULT 0,
PRIMARY KEY (`idCours`),
INDEX `fk_Cours_UE_idx` (`UE_code` ASC),
INDEX `fk_Cours_Professeur1_idx` (`Professeur_idProfesseur` ASC),
CONSTRAINT `fk_Cours_Professeur1`
FOREIGN KEY (`Professeur_idProfesseur`)
REFERENCES `Professeur` (`idProfesseur`)
ON DELETE SET NULL
ON UPDATE SET NULL,
CONSTRAINT `fk_Cours_UE`
FOREIGN KEY (`UE_code`)
REFERENCES `UE` (`code`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
AUTO_INCREMENT = 88
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `GroupeCours`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `GroupeCours` (
`Formation_idFormation` INT(11) NOT NULL,
`Cours_idCours` INT(11) NOT NULL,
PRIMARY KEY (`Formation_idFormation`, `Cours_idCours`),
INDEX `fk_Formation_has_Cours_Cours1_idx` (`Cours_idCours` ASC),
INDEX `fk_Formation_has_Cours_Formation1_idx` (`Formation_idFormation` ASC),
CONSTRAINT `fk_Formation_has_Cours_Cours1`
FOREIGN KEY (`Cours_idCours`)
REFERENCES `Cours` (`idCours`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_Formation_has_Cours_Formation1`
FOREIGN KEY (`Formation_idFormation`)
REFERENCES `Formation` (`idFormation`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `TD`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `TD` (
`idTD` INT(11) NOT NULL AUTO_INCREMENT,
`UE_code` VARCHAR(20) NOT NULL,
`Professeur_idProfesseur` INT(11) NULL DEFAULT NULL,
`volume` FLOAT NOT NULL DEFAULT 0,
PRIMARY KEY (`idTD`),
INDEX `fk_TD_UE1_idx` (`UE_code` ASC),
INDEX `fk_TD_Professeur1_idx` (`Professeur_idProfesseur` ASC),
CONSTRAINT `fk_TD_Professeur1`
FOREIGN KEY (`Professeur_idProfesseur`)
REFERENCES `Professeur` (`idProfesseur`)
ON DELETE SET NULL
ON UPDATE SET NULL,
CONSTRAINT `fk_TD_UE1`
FOREIGN KEY (`UE_code`)
REFERENCES `UE` (`code`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
AUTO_INCREMENT = 107
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `GroupeTD`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `GroupeTD` (
`Formation_idFormation` INT(11) NOT NULL,
`TD_idTD` INT(11) NOT NULL,
PRIMARY KEY (`Formation_idFormation`, `TD_idTD`),
INDEX `fk_Formation_has_TD_TD1_idx` (`TD_idTD` ASC),
INDEX `fk_Formation_has_TD_Formation1_idx` (`Formation_idFormation` ASC),
CONSTRAINT `fk_Formation_has_TD_Formation1`
FOREIGN KEY (`Formation_idFormation`)
REFERENCES `Formation` (`idFormation`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_Formation_has_TD_TD1`
FOREIGN KEY (`TD_idTD`)
REFERENCES `TD` (`idTD`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `TP`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `TP` (
`idTP` INT(11) NOT NULL AUTO_INCREMENT,
`UE_code` VARCHAR(20) NOT NULL,
`Professeur_idProfesseur` INT(11) NULL DEFAULT NULL,
`volume` FLOAT NOT NULL DEFAULT 0,
PRIMARY KEY (`idTP`),
INDEX `fk_TP_UE1_idx` (`UE_code` ASC),
INDEX `fk_TP_Professeur1_idx` (`Professeur_idProfesseur` ASC),
CONSTRAINT `fk_TP_Professeur1`
FOREIGN KEY (`Professeur_idProfesseur`)
REFERENCES `Professeur` (`idProfesseur`)
ON DELETE SET NULL
ON UPDATE SET NULL,
CONSTRAINT `fk_TP_UE1`
FOREIGN KEY (`UE_code`)
REFERENCES `UE` (`code`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
AUTO_INCREMENT = 164
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `GroupeTP`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `GroupeTP` (
`Formation_idFormation` INT(11) NOT NULL,
`TP_idTP` INT(11) NOT NULL,
PRIMARY KEY (`Formation_idFormation`, `TP_idTP`),
INDEX `fk_Formation_has_TP_TP1_idx` (`TP_idTP` ASC),
INDEX `fk_Formation_has_TP_Formation1_idx` (`Formation_idFormation` ASC),
CONSTRAINT `fk_Formation_has_TP_Formation1`
FOREIGN KEY (`Formation_idFormation`)
REFERENCES `Formation` (`idFormation`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_Formation_has_TP_TP1`
FOREIGN KEY (`TP_idTP`)
REFERENCES `TP` (`idTP`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
LOCK TABLES `Categorie` WRITE;
/*!40000 ALTER TABLE `Categorie` DISABLE KEYS */;
INSERT INTO `Categorie` VALUES (1,'Professeurs et Maîtres de Conférences'),(2,'ATERs'),(3,'CDDs enseignement'),(4,'Doctorants Vacataires'),(5,'Permanents UPPA'),(6,'Vacataires extérieurs');
/*!40000 ALTER TABLE `Categorie` ENABLE KEYS */;
UNLOCK TABLES;
";
return $metaRep->createVersionDatabase($depId,$SQL);
}
}

View File

@ -0,0 +1,91 @@
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 05/03/18
* Time: 19:39
*/
namespace database\repo;
use database\core\Repo_i;
class departement extends Repo_i
{
public function getErrors() : array {
$results = [];
/* (1) Find Groups without formation bound */
$GroupWithoutFormation = $this->pdo->prepare("
(SELECT 'NO_FORMATION_ASSIGNED' errorType, 'Cours' entityType, idCours id FROM Cours WHERE idCours NOT IN (SELECT Cours_idCours FROM GroupeCours))
UNION
(SELECT 'NO_FORMATION_ASSIGNED' errorType, 'TD' entityType, idTD id FROM TD WHERE idTD NOT IN (SELECT TD_idTD FROM GroupeTD))
UNION
(SELECT 'NO_FORMATION_ASSIGNED' errorType, 'TP' entityType, idTP id FROM TP WHERE idTP NOT IN (SELECT TP_idTP FROM GroupeTP))");
$GroupWithoutFormation->execute([]);
$results = array_merge($results,$GroupWithoutFormation->fetchAll());
/* (2) Find Groups without a professor bound */
$GroupWithoutProfessor = $this->pdo->prepare("
(SELECT 'NO_PROFESSOR_ASSIGNED' errorType, 'Cours' entityType, idCours id FROM Cours WHERE Professeur_idProfesseur IS NULL)
UNION
(SELECT 'NO_PROFESSOR_ASSIGNED' errorType, 'TD' entityType, idTD id FROM TD WHERE Professeur_idProfesseur IS NULL)
UNION
(SELECT 'NO_PROFESSOR_ASSIGNED' errorType, 'TP' entityType, idTP id FROM TP WHERE Professeur_idProfesseur IS NULL)");
$GroupWithoutProfessor->execute([]);
$results = array_merge($results,$GroupWithoutProfessor->fetchAll());
/* (3) Find Groups a null VH */
$GroupWithNullVH = $this->pdo->prepare("
(SELECT 'NULL_VH' errorType, 'Cours' entityType, idCours id FROM Cours WHERE volume = 0)
UNION
(SELECT 'NULL_VH' errorType, 'TD' entityType, idTD id FROM TD WHERE volume = 0)
UNION
(SELECT 'NULL_VH' errorType, 'TP' entityType, idTP id FROM TP WHERE volume = 0)");
$GroupWithNullVH->execute([]);
$results = array_merge($results,$GroupWithNullVH->fetchAll());
/* (4) Find UE with an incorrect VH in the groups compared to what's supposed to be */
$UEWithIncorrectGroupVH = $this->pdo->prepare("
(SELECT 'UNEQUIVALENT_VH' errorType, 'Cours' entityType, U.code
FROM UE U
WHERE
0 != (SELECT MOD(SUM(volume),U.volumeCours) modCours FROM Cours WHERE UE_code = U.code GROUP BY Cours.UE_code)
)
UNION
(SELECT 'UNEQUIVALENT_VH' errorType, 'TD' entityType, U.code
FROM UE U
WHERE
0 != (SELECT MOD(SUM(volume),U.volumeTD) modCours FROM TD WHERE UE_code = U.code GROUP BY TD.UE_code)
)
UNION
(SELECT 'UNEQUIVALENT_VH' errorType, 'TP' entityType, U.code
FROM UE U
WHERE
0 != (SELECT MOD(SUM(volume),U.volumeTP) modCours FROM TP WHERE UE_code = U.code GROUP BY TP.UE_code)
)");
$UEWithIncorrectGroupVH->execute([]);
$results = array_merge($results,$UEWithIncorrectGroupVH->fetchAll());
return $results;
}
}

View File

@ -1,179 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 05/03/18
* Time: 19:39
*/
namespace database\repo;
use database\core\Repo;
use database\core\Repo_i;
class department extends Repo_i
{
public function getErrors() : array {
$results = [];
/* (1) Find Groups without formation bound */
$GroupWithoutFormation = $this->pdo->prepare("
(SELECT 'NO_FORMATION_ASSIGNED' errorType, 'Cours' entityType, idCours id FROM Cours WHERE idCours NOT IN (SELECT Cours_idCours FROM GroupeCours))
UNION
(SELECT 'NO_FORMATION_ASSIGNED' errorType, 'TD' entityType, idTD id FROM TD WHERE idTD NOT IN (SELECT TD_idTD FROM GroupeTD))
UNION
(SELECT 'NO_FORMATION_ASSIGNED' errorType, 'TP' entityType, idTP id FROM TP WHERE idTP NOT IN (SELECT TP_idTP FROM GroupeTP))");
$GroupWithoutFormation->execute([]);
$results = array_merge($results,$GroupWithoutFormation->fetchAll());
/* (2) Find Groups without a professor bound */
$GroupWithoutProfessor = $this->pdo->prepare("
(SELECT 'NO_PROFESSOR_ASSIGNED' errorType, 'Cours' entityType, idCours id FROM Cours WHERE Professeur_idProfesseur IS NULL)
UNION
(SELECT 'NO_PROFESSOR_ASSIGNED' errorType, 'TD' entityType, idTD id FROM TD WHERE Professeur_idProfesseur IS NULL)
UNION
(SELECT 'NO_PROFESSOR_ASSIGNED' errorType, 'TP' entityType, idTP id FROM TP WHERE Professeur_idProfesseur IS NULL)");
$GroupWithoutProfessor->execute([]);
$results = array_merge($results,$GroupWithoutProfessor->fetchAll());
/* (3) Find Groups a null VH */
$GroupWithNullVH = $this->pdo->prepare("
(SELECT 'NULL_VH' errorType, 'Cours' entityType, idCours id FROM Cours WHERE volume = 0)
UNION
(SELECT 'NULL_VH' errorType, 'TD' entityType, idTD id FROM TD WHERE volume = 0)
UNION
(SELECT 'NULL_VH' errorType, 'TP' entityType, idTP id FROM TP WHERE volume = 0)");
$GroupWithNullVH->execute([]);
$results = array_merge($results,$GroupWithNullVH->fetchAll());
/* (4) Find UE with an incorrect VH in the groups compared to what's supposed to be */
$UEWithIncorrectGroupVH = $this->pdo->prepare("
(SELECT 'UNEQUIVALENT_VH' errorType, 'Cours' entityType, U.code
FROM UE U
WHERE
0 != (SELECT MOD(SUM(volume),U.volumeCours) modCours FROM Cours WHERE UE_code = U.code GROUP BY Cours.UE_code)
)
UNION
(SELECT 'UNEQUIVALENT_VH' errorType, 'TD' entityType, U.code
FROM UE U
WHERE
0 != (SELECT MOD(SUM(volume),U.volumeTD) modCours FROM TD WHERE UE_code = U.code GROUP BY TD.UE_code)
)
UNION
(SELECT 'UNEQUIVALENT_VH' errorType, 'TP' entityType, U.code
FROM UE U
WHERE
0 != (SELECT MOD(SUM(volume),U.volumeTP) modCours FROM TP WHERE UE_code = U.code GROUP BY TP.UE_code)
)");
$UEWithIncorrectGroupVH->execute([]);
$results = array_merge($results,$UEWithIncorrectGroupVH->fetchAll());
return $results;
}
public function getStats() : array{
/* (1) Potentiel horaire du département */
$Potentiel = $this->pdo->prepare("SELECT SUM(hoursToDo) potentiel
FROM Professeur
WHERE Categorie_idCategorie IN (1,2,3)
GROUP BY Categorie_idCategorie IN (1,2,3);");
$Potentiel->execute([]);
$results = $Potentiel->fetch();
/* (2) Sous-service (professeurs ayant moins d'heure prévu que d'heure du) */
/** @var professor $ProfRepo */
$ProfRepo = Repo::getRepo("professor");
$profs = $ProfRepo->getWithVH(null);
$results["sous_service"] = 0;
$results["heures_comp"] = 0;
$results["heures_vacataire"] = 0;
foreach ($profs as $prof){
if(in_array($prof["idCat"],[1,2,3,4]) and $prof["equiTD"] < $prof["hoursToDo"]){
$results["sous_service"] += $prof["hoursToDo"] - $prof["equiTD"];
/* (3) Heures effectués par des vacataires */
}else if(in_array($prof["idCat"],[5,6])){
$results["heures_vacataire"] += $prof["equiTD"];
}
/* (4) Heures complementaires */
if(is_numeric($prof["VHComp"])){
$results["heures_comp"] += $prof["VHComp"];
}
}
/* (5) Heures effectuées pour des départements exterieurs */
//je crois que j'ai créé un montre - Lucas - 2018
$HDepExt = $this->pdo->prepare("
SELECT U.disabled disabled,
count(U.code) nbrUe,
SUM((IFNULL(T1.VolumeCours,0)*IFNULL(tauxInfoCours,0) + IFNULL(T2.VolumeTD,0)*IFNULL(tauxInfoTD,0) + IFNULL(T3.VolumeTP,0)*IFNULL(tauxInfoTP,0))) totalInfo,
SUM((IFNULL(T1.VolumeCours,0)*(1-IFNULL(tauxInfoCours,0)) + IFNULL(T2.VolumeTD,0)*(1-IFNULL(tauxInfoTD,0)) + IFNULL(T3.VolumeTP,0)*(1-IFNULL(tauxInfoTP,0)))) totalExterieur
FROM UE U
LEFT JOIN (SELECT SUM(F.isInternal)/count(F.idFormation) tauxInfoCours,SUM(C.volume)*1.5 VolumeCours, C.UE_code code_UE
FROM Cours C
JOIN GroupeCours C2 ON C.idCours = C2.Cours_idCours
JOIN Formation F ON C2.Formation_idFormation = F.idFormation
GROUP BY C.UE_code) T1 ON U.code = T1.code_UE
LEFT JOIN (SELECT SUM(F.isInternal)/count(F.idFormation) tauxInfoTD,SUM(T1.volume) VolumeTD, T1.UE_code code_UE
FROM TD T1
JOIN GroupeTD GT ON T1.idTD = GT.TD_idTD
JOIN Formation F ON GT.Formation_idFormation = F.idFormation
GROUP BY T1.UE_code) T2 ON U.code = T2.code_UE
LEFT JOIN (SELECT SUM(F.isInternal)/count(F.idFormation) tauxInfoTP,SUM(T1.volume) VolumeTP, T1.UE_code code_UE
FROM TP T1
JOIN GroupeTP TP2 ON T1.idTP = TP2.TP_idTP
JOIN Formation F ON TP2.Formation_idFormation = F.idFormation
GROUP BY T1.UE_code) T3 ON U.code = T3.code_UE
GROUP BY U.disabled");
$HDepExt->execute([]);
$HDepExtData = $HDepExt->fetchAll();
$results = array_merge($results,[
"heures_exterieur" => $HDepExtData[0]["totalExterieur"],
"heures_ue_desactive" => $HDepExtData[1]["totalExterieur"] + $HDepExtData[1]["totalInfo"],
"nbr_ue_desactive" => $HDepExtData[1]["nbrUe"]
]);
return $results;
}
public function createVersionDatabase(String $depId, String $SQL) : String{
$dbName = uniqid($depId)."";
$this->pdo->exec("CREATE DATABASE $dbName; USE $dbName;".$SQL."USE {$_SESSION["CurrentDatabase"]};SET autocommit=1;");
$this->pdo->setAttribute(\PDO::ATTR_AUTOCOMMIT,1);
return $dbName;
}
}

View File

@ -42,26 +42,6 @@ class formation extends Repo_i {
}
public function update(int $idFormation, ?String $label, ?bool $isInternal) : bool{
$req = "";
$execute = [];
if($label != null){
$req .= "labelFormation=:label,";
$execute["label"] = $label;
}
if($isInternal != null){
$req .= "isInternal=:isInternal,";
$execute["isInternal"] = $isInternal?1:0;
}
$req = rtrim($req,",");
$execute["idFormation"] = $idFormation;
$st = $this->pdo->prepare("UPDATE `Formation` SET $req WHERE idFormation=:idFormation");
return $st->execute($execute);
}
/* (2) Check if a formation exists (by its label)

View File

@ -1,351 +0,0 @@
<?php
namespace database\repo;
use database\core\Repo_i;
class meta extends Repo_i {
/* (1) Creates a new professor
*
* @casLogin<String> The professor's cas login
* @firstName<String> [OPT] The professor's firstName
* @lastName<String> [OPT] The professor's lastName
*
* @return created<bool> Whether the professor has been created
*
---------------------------------------------------------*/
public function create_prof(String $casLogin, ?String $firstName, ?String $lastName) : bool{
/* (1) Create user in meta database
---------------------------------------------------------*/
/* (1) Try to insert user */
$st = $this->pdo->prepare("INSERT INTO
meta_vhost.casUser(casLogin, firstName, lastName)
VALUES(:cas_login, :first_name, :last_name)");
/* (2) Manage statement error */
if( is_bool($st) )
return FALSE;
/* (3) Try to execute */
$success = $st->execute([
':cas_login' => $casLogin,
':first_name' => $firstName,
':last_name' => $lastName
]);
/* (4) Dispatch execution error */
return $success;
}
/* (2) Check if a professor exists (by its casLogin)
*
* @casLogin<String> The professor's cas login
*
* @return exists<bool> Whether the professor exists
*
---------------------------------------------------------*/
public function prof_exists(String $casLogin) : bool{
/* (1) Prepare Statement */
$st = $this->pdo->prepare("SELECT casLogin
FROM meta_vhost.casUser
WHERE casLogin = :cas_login;");
/* (2) Statement eror */
if( is_bool($st) )
return FALSE;
/* (3) Bind params and execute */
$success = $st->execute([ ':cas_login' => $casLogin ]);
/* (4) Manage execution error */
if( !$success )
return FALSE;
/* (7) Return That it exists */
return is_array( $st->fetch() );
}
/* (3) Get available departments for a CAS login
*
* @casLogin<String> The professor's CAS username
*
* @return departments<array> The list of available departments (empty on error)
*
---------------------------------------------------------*/
public function get_prof_departments(String $casLogin) : array{
/* (1) Prepare Statement */
$st = $this->pdo->prepare("SELECT d2.iddepartement idDep, d2.label labelDep
FROM meta_vhost.casUser
JOIN meta_vhost.linkedDep D ON casUser.casLogin = D.casUser_casLogin
JOIN meta_vhost.departement d2 ON D.departement_iddepartement = d2.iddepartement
WHERE casLogin = :cas_login");
/* (2) Check if statement error */
if( is_bool($st) )
return [];
/* (3) Bind params and execute sstatement */
$success = $st->execute([ ':cas_login' => $casLogin ]);
/* (4) Manage error */
if( !$success )
return [];
/* (5) Get data */
$fetched = $st->fetchAll();
/* (6) Return [] on no result */
if( $fetched === false )
return [];
/* (7) Add all possible databases to the department */
foreach ($fetched as &$dep){
$st = $this->pdo->prepare("SELECT *
FROM meta_vhost.`databases`
WHERE departement_iddepartement = :idDep
ORDER BY meta_vhost.`databases`.`default` DESC ");
$st->execute(["idDep" => $dep["idDep"]]);
$dep["versions"] = $st->fetchAll();
}
/* (8) Return data */
return $fetched;
}
/* (4) Deletes a professor
*
* @casLogin<String> The professor's CAS username
*
* @return deleted<bool> Whether the professor have been deleeted successfully
*
---------------------------------------------------------*/
public function delete_prof(String $casLogin) : bool{
/* (1) Prepare statement */
$st = $this->pdo->prepare('DELETE FROM meta_vhost.casUser
WHERE casLogin = :cas_login');
/* (2) Manage statement error */
if( is_bool($st) )
return FALSE;
/* (3) Try to execute */
$success = $st->execute([ ':cas_login' => $casLogin ]);
/* (4) Dispatch execution error */
return $success;
}
/* (5) Check if a link exists
*
* @casLogin<String> The professor's cas login
* @idDep<int> The department id
*
* @return exists<bool> Whether the professor exists
*
---------------------------------------------------------*/
public function link_exists(String $casLogin, int $idDep) : bool{
/* (1) Prepare Statement */
$st = $this->pdo->prepare("SELECT *
FROM meta_vhost.linkedDep
WHERE departement_iddepartement = :id_dep
AND casUser_casLogin = :cas_login");
/* (2) Statement eror */
if( is_bool($st) )
return FALSE;
/* (3) Bind params and execute */
$success = $st->execute([
':id_dep' => $idDep,
':cas_login' => $casLogin
]);
/* (4) Manage execution error */
if( !$success )
return FALSE;
/* (7) Return That it exists */
return is_array( $st->fetch() );
}
/* (6) Associates a professor to a department
*
* @casLogin<String> The professor's CAS username
* @idDep<int> The department id
*
* @return linked<bool> Whether the link have been created
*
---------------------------------------------------------*/
public function link(String $casLogin, int $idDep) : bool{
/* (1) Prepare statement */
$st = $this->pdo->prepare("INSERT INTO meta_vhost.linkedDep(departement_iddepartement, casUser_casLogin)
VALUES(:id_dep, :cas_login);");
/* (2) Manage statement error */
if( is_bool($st) )
return FALSE;
/* (3) Try to execute request */
$success = $st->execute([
':id_dep' => $idDep,
':cas_login' => $casLogin
]);
/* (4) Dispatch execution error */
return $success;
}
/* (7) Remove a department from a professor
*
* @casLogin<String> The professor's CAS username
* @idDep<int> The department id
*
* @return unlinked<bool> Whether the link have been removed
*
---------------------------------------------------------*/
public function unlink(String $casLogin, int $idDep) : bool{
/* (1) Prepare statement */
$st = $this->pdo->prepare("DELETE FROM meta_vhost.linkedDep
WHERE departement_iddepartement = :id_dep
AND casUser_casLogin = :cas_login;");
/* (2) Manage statement error */
if( is_bool($st) )
return FALSE;
/* (3) Try to execute request */
$success = $st->execute([
':id_dep' => $idDep,
':cas_login' => $casLogin
]);
/* (4) Dispatch execution error */
return $success;
}
public function deleteVersion(int $version) : bool{
//get version data
$st = $this->pdo->prepare("SELECT * FROM meta_vhost.`databases` WHERE iddatabase = :id");
$st->execute(["id" => $version]);
$versionData = $st->fetch();
if( !is_array($versionData) || $versionData["default"] == 1){
return false;
}
//delete database
$versionDatabase = $versionData['dbName'];
$this->pdo->exec("DROP DATABASE $versionDatabase;");
//remove from meta
$st = $this->pdo->prepare("DELETE FROM meta_vhost.`databases` WHERE iddatabase = :id");
return $st->execute(["id" => $version]);
}
public function createVersion(String $label, String $dbName, int $depId, bool $isDefault = false) : int{
$st = $this->pdo->prepare("INSERT INTO meta_vhost.`databases`(label, dbName, `default`, departement_iddepartement)
VALUE (:label,:dbName,:default,:depId)");
$st->execute([
"label" => $label,
"dbName" => $dbName,
"default" => $isDefault? 1 : 0,
"depId" => $depId
]);
return $this->pdo->lastInsertId();
}
public function getVersionById(int $id) : array{
$st = $this->pdo->prepare("SELECT * FROM meta_vhost.`databases` WHERE iddatabase = :idVersion");
$st->execute(["idVersion" => $id]);
$fetched = $st->fetch();
return $fetched == false ? [] : $fetched;
}
public function getAllVersions(int $idDep) : array {
$st = $this->pdo->prepare("SELECT * FROM meta_vhost.`databases` WHERE departement_iddepartement = :idDep");
$st->execute(["idDep" => $idDep]);
return $st->fetchAll();
}
public function updateVersion(int $version, ?String $label, ?bool $default) : bool{
//you can't un-default a version, you have to choose another version to be the default one
if($default == false){
return false;
}
$set = "";
$execute = [];
if($label != null){
$set .= "label=:label,";
$execute["label"] = $label;
}
if($default != null){
$set .= "`default`=:default,";
$execute["default"] = $default?1:0;
//if default = true, set previous default version to non-default
if($default == true){
$req = $this->pdo->prepare("UPDATE meta_vhost.`databases` SET `default`=0 WHERE departement_iddepartement=:idDep");
$req->execute(["idDep" => $_SESSION['CurrentDepartmentId']]);
}
}
$set = rtrim($set,",");
$execute["idVersion"] = $version;
$st = $this->pdo->prepare("UPDATE meta_vhost.`databases` SET $set WHERE iddatabase=:idVersion");
return $st->execute($execute);
}
public function createDepartment(String $name) : int{
$st = $this->pdo->prepare("INSERT INTO meta_vhost.departement(label) VALUE (:label)");
$st->execute(["label" => $name]);
return $this->pdo->lastInsertId();
}
}

View File

@ -10,7 +10,6 @@ namespace database\repo;
use database\core\Repo_i;
use database\core\Repo;
class professor extends Repo_i {
@ -28,21 +27,14 @@ class professor extends Repo_i {
* @return prof_id<int> The professor's UID (or -1 on error)
*
---------------------------------------------------------*/
public function create(string $lastName, string $firstName, int $category, int $hoursToDo = 0, ?string $initials = null , bool $isAdmin = false , ?string $casLogin = null ) : ?int{
public function create(string $lastName, string $firstName, int $category, $hoursToDo = 0, $initials = "", $isAdmin = false , $casLogin = "" ) : ?int{
/* (1) Create professor into local database
---------------------------------------------------------*/
/* (1) Prepare Statement */
$st = $this->pdo->prepare("INSERT INTO
Professeur(`casLogin`, `lastName`, `firstName`, `abreviation`, `admin`, `hoursToDo`, `Categorie_idCategorie`)
VALUE (:casLogin, :lastName, :firstName, :abrev, :is_admin, :hoursToDo, :cat);");
/* (2) Manage statement error */
if( is_bool($st) )
return NULL;
/* (3) Bind params and execute */
/* (2) Bind params and execute */
$success = $st->execute([
':casLogin' => $casLogin,
':lastName' => $lastName,
@ -53,44 +45,12 @@ class professor extends Repo_i {
':cat' => $category
]);
/* (4) If execution error -> dispatch */
/* (3) Manage error */
if( !$success )
return NULL;
/* (5) Store id */
$id_prof = $this->pdo->lastInsertId();
/* (6) Exit now if no meta database to udpate */
if( is_null($casLogin) )
return $id_prof;
/* (2) Synchronize meta database
---------------------------------------------------------*/
/** @var meta $meta_repo */
$meta_repo = Repo::getRepo('meta');
/* (1) If user does not exist */
if( !$meta_repo->prof_exists($casLogin) ){
/* (2) Try to create -> dispatch error */
if( !$meta_repo->create_prof($casLogin, $firstName, $lastName) )
return NULL;
}
/* (3) If link already exists -> done */
if( $meta_repo->link_exists($casLogin, $_SESSION['CurrentDepartmentId']) )
return $id_prof;
/* (4) Else: try to link prof to dep -> dispatch error */
if( !$meta_repo->link($casLogin, $_SESSION['CurrentDepartmentId']) )
return NULL;
/* (5) If reached here -> Success */
return $id_prof;
/* (4) Return inserted ID */
return $this->pdo->lastInsertId();
}
@ -104,35 +64,25 @@ class professor extends Repo_i {
* @return prof_id<int> The professor's UID (or NULL on error)
*
---------------------------------------------------------*/
public function exists(string $lastName, string $firstName, ?string $casLogin = null) : ?int{
public function exists(string $lastName, string $firstName) : ?int{
/* (1) Manage if @casLogin given/ignored */
$cond = is_null($casLogin) ? '' : 'OR `casLogin` = :casLogin';
$parm = is_null($casLogin) ? [] : [':casLogin' => $casLogin];
/* (2) Prepare Statement */
/* (1) Prepare Statement */
$st = $this->pdo->prepare("SELECT idProfesseur
FROM Professeur
WHERE ( firstName = :firstName AND lastName = :lastName )
$cond;");
WHERE firstName = :firstName
AND lastName = :lastName");
/* (3) Statement eror */
if( is_bool($st) )
return NULL;
/* (4) Bind params and execute */
$params = array_merge([
/* (2) Bind params and execute */
$success = $st->execute([
':firstName' => $firstName,
':lastName' => $lastName
], $parm);
]);
$success = $st->execute($params);
/* (5) Return NULL on error */
/* (3) Return NULL on error */
if( !$success )
return NULL;
/* (7) Return @prof_id or NULL if nothing found */
/* (4) Return @prof_id or NULL if nothing found */
return $st->fetch()['idProfesseur'] ?: NULL;
}
@ -141,7 +91,7 @@ class professor extends Repo_i {
/* (3) Updates a professor's data
/* (3) Check if a professor exists (by its names)
*
* @idProf<int> The professor's UID
* @lastName<String> [OPT] The professor's new lastName
@ -157,29 +107,6 @@ class professor extends Repo_i {
---------------------------------------------------------*/
public function update(int $id, ?String $lastName, ?String $firstName, ?int $category, ?int $hoursToDo, ?String $initials, ?bool $isAdmin, ?String $casLogin) : bool{
/* (1) Check professor data
---------------------------------------------------------*/
/* (1) Try to fetch professor's data */
$prof = $this->get($id);
/* (2) Error: no professor found */
if( count($prof) === 0 )
return FALSE;
/* (3) Take first matching professor */
$prof = $prof[0];
/* (4) Extract old CAS login */
$oldCasLogin = $prof['casLogin'];
/* (2) Update current database
---------------------------------------------------------*/
/* (1) Build request */
$build_rq = [];
$bind_param = [ ':idProfesseur' => $id ];
@ -203,78 +130,7 @@ class professor extends Repo_i {
$st = $this->pdo->prepare($sql_rq);
/* (5) Return execution success */
$success = $st->execute($bind_param);
/* (6) Manage execution error */
if( !$success )
return FALSE;
/* (7) If do not have to update 'meta' database -> success */
if( is_null($casLogin) )
return TRUE;
/** @var meta $meta_repo */
$meta_repo = Repo::getRepo('meta');
/* (3) Synchronize meta database -> remove old value
---------------------------------------------------------*/
if( !is_null($oldCasLogin) && strlen($oldCasLogin) > 0 ){
/* Proccess only if professor exists */
if( $meta_repo->prof_exists($oldCasLogin) ){
/* (1) If link exists -> remove it */
if( $meta_repo->link_exists($oldCasLogin, $_SESSION['CurrentDepartmentId']) ){
/* (2) Try to unlink-> ignore error */
$meta_repo->unlink($oldCasLogin, $_SESSION['CurrentDepartmentId']);
}
/* (3) If has no more department -> remove professor */
if( count( $meta_repo->get_prof_departments($oldCasLogin) ) == 0 ){
/* (4) Try to remove professor -> dispatch error */
if( !$meta_repo->delete_prof($oldCasLogin) )
return FALSE;
}
}
}
/* (4) Synchronize meta database -> create new
---------------------------------------------------------*/
if( !is_null($casLogin) && strlen($casLogin) > 0 ){
/* (1) If user does not exist */
if( !$meta_repo->prof_exists($casLogin) ){
/* (2) Try to create -> dispatch error */
if( !$meta_repo->create_prof($casLogin, $prof['firstName'], $prof['lastName']) )
return FALSE;
}
/* (3) If link already exists -> done */
if( $meta_repo->link_exists($casLogin, $_SESSION['CurrentDepartmentId']) )
return TRUE;
/* (4) Else: try to link prof to dep -> dispatch error */
if( !$meta_repo->link($casLogin, $_SESSION['CurrentDepartmentId']) )
return FALSE;
}
/* (5) If reached here -> Success */
return TRUE;
return $st->execute($bind_param);
}
@ -321,7 +177,7 @@ class professor extends Repo_i {
$parm = is_null($prof_id) ? [] : [':id' => $prof_id];
/* (2) Prepare Statement */
$st = $this->pdo->prepare("SELECT * FROM `Professeur`$cond ORDER BY firstName, lastName ASC");
$st = $this->pdo->prepare("SELECT * FROM `Professeur`$cond ORDER BY abreviation ASC");
/* (3) Bind params and execute statement */
if( is_bool($st) ) return [];
@ -358,25 +214,21 @@ class professor extends Repo_i {
/* (1) Prepare Statement */
$st = $this->pdo->prepare("SELECT * FROM `Professeur` WHERE `casLogin` = :cas_login");
/* (2) Check if statement error */
if( is_bool($st) )
return NULL;
/* (3) Bind params and execute statement */
/* (2) Bind params and execute statement */
$success = $st->execute([ ':cas_login' => $cas_login ]);
/* (4) Manage error */
/* (3) Manage error */
if( !$success )
return NULL;
/* (5) Get data */
/* (4) Get data */
$fetched = $st->fetch();
/* (6) Return NULL on no result */
/* (5) Return NULL on no result */
if( $fetched === false )
return NULL;
/* (7) Return data */
/* (6) Return data */
return $fetched;
}
@ -433,8 +285,7 @@ class professor extends Repo_i {
AND VHTp.idProf = Prof.idProfesseur
AND VHTd.idProf = Prof.idProfesseur
GROUP BY
Prof.idProfesseur
ORDER BY Prof.firstName, Prof.lastName ASC;");
Prof.idProfesseur;");
/* (3) Bind params and execute statement */
if( is_bool($st) ) return [];
@ -468,7 +319,7 @@ class professor extends Repo_i {
$prof['VHComp'] = round($prof['equiTD'] - $prof['hoursToDo'], 2);
$prof['VHComp'] = ( $prof['VHComp'] < 0 ) ? 0 : $prof['VHComp'];
}else{
$prof["equiTD"] = $prof["VHTd"] + (2/3)*$prof["VHTp"] + 1.5*$prof["VHCours"];
$VH["equiTD"] = $prof["VHTd"] + (2/3)*$prof["VHTp"] + 1.5*$prof["VHCours"];
if(is_numeric($prof["hoursToDo"]) and $prof["hoursToDo"] > 0){
$prof['VHComp'] = round($prof['equiTD'] - $prof['hoursToDo'], 2);
$prof['VHComp'] = ( $prof['VHComp'] < 0 ) ? 0 : $prof['VHComp'];
@ -493,77 +344,11 @@ class professor extends Repo_i {
---------------------------------------------------------*/
public function delete(int $id) : bool{
/** @var meta $meta_repo */
$meta_repo = Repo::getRepo('meta');
/* (1) Try to fetch professor data
---------------------------------------------------------*/
/* (1) Try to fetch */
$prof = $this->get($id);
/* (2) Error: if not found */
if( count($prof) === 0 )
return false;
/* (3) Take first matching professor */
$prof = $prof[0];
/* (4) Extract @casLogin */
$casLogin = $prof['casLogin'];
/* (2) Remove professor from current database
---------------------------------------------------------*/
/* (1) Prepare statement */
$st = $this->pdo->prepare("DELETE FROM `Professeur` WHERE `idProfesseur` = :id");
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) Return the execution status */
$success = $st->execute([ ':id' => $id ]);
/* (4) Error: on execution error */
if( !$success )
return false;
/* (5) Success if no @casLogin to update in meta */
if( !$meta_repo->prof_exists($casLogin) )
return TRUE;
/* (3) Synchronize meta database
---------------------------------------------------------*/
/* Proccess only if professor exists */
if( $meta_repo->prof_exists($casLogin) ){
/* (1) If link exists -> remove it */
if( $meta_repo->link_exists($casLogin, $_SESSION['CurrentDepartmentId']) ){
/* (2) Try to unlink-> ignore error */
$meta_repo->unlink($casLogin, $_SESSION['CurrentDepartmentId']);
}
/* (3) If has no more department -> remove professor */
if( count( $meta_repo->get_prof_departments($casLogin) ) == 0 ){
/* (4) Try to remove professor -> dispatch error */
if( !$meta_repo->delete_prof($casLogin) )
return FALSE;
}
}
return TRUE;
/* (2) Return the execution status */
return $st->execute([ ':id' => $id ]);
}

View File

@ -13,282 +13,76 @@ use database\core\Repo_i;
class td extends Repo_i {
/* (1) Create a new TD
*
* @code<String> The code of the UE containing the TD
* @idProf<String> [OPT] The ID of the prof who teaches the TD
* @volume<float> The number of hours (float)
* @formations<array> The list of formations for that TD (list of int)
* @return created_code<String> Code of the created UE (NULL on error)
*
* @return created_id<int> UID of the created TD (NULL on error)
*
---------------------------------------------------------*/
public function create(string $code, ?int $idProf, float $volume, array $formations) : ?int{
public function create(string $codeUE, ?int $idProf, float $volume, array $formations) : int{
//create the group
$st = $this->pdo->prepare("INSERT INTO TD(UE_code, Professeur_idProfesseur, volume)
VALUE(:UE, :idProf, :vol)");
/* (1) Prepare statement */
$st = $this->pdo->prepare('INSERT INTO TD(UE_code, Professeur_idProfesseur, volume)
VALUE(:UE, :idProf, :vol)');
/* (2) Manage statement error */
if( is_bool($st) )
return NULL;
/* (3) Try to execute request */
$success = $st->execute([
':UE' => $code,
':idProf' => $idProf,
':vol' => $volume
$st->execute([
"UE" => $codeUE,
"idProf" => $idProf,
"vol" => $volume
]);
/* (4) Manage error */
if( !$success )
return NULL;
$idTD = $this->pdo->lastInsertId();
/* (5) Store @created_id */
$created_id = (int) $this->pdo->lastInsertId();
/* (6) We are done if there is no formations */
if( count($formations) <= 0)
return $created_id;
/* (7) Else -> create each formation */
foreach($formations as $form_id){
// 1. Ignore if wrong format
if( !is_int($form_id) || $form_id < 0 )
continue;
// 2. Link formation to created TD
$this->linkFormation($form_id, $created_id);
//if there is formations, link them with the group
if(count($formations) > 0){
$linkSt = $this->pdo->prepare("INSERT INTO GroupeTD(Formation_idFormation, TD_idTD)
VALUE (:form, :TD)");
foreach ($formations as $form){
$linkSt->execute([
"form" => $form,
"TD" => $idTD
]);
}
}
/* (7) Return @created_id */
return $created_id;
return $idTD;
}
/* (2) Unlink a formation from a TD
*
* @idFormation<int> Id of the formation
* @idTD<int> Id of the TD
*
* @return unlinked<bool> Whether it has been unlinked
*
---------------------------------------------------------*/
public function unlinkFormation(int $idFormation, int $idTD) : bool{
$st = $this->pdo->prepare("DELETE FROM GroupeTD WHERE TD_idTD = :TD AND Formation_idFormation = :form");
/* (1) Prepare statement */
$st = $this->pdo->prepare('DELETE FROM GroupeTD WHERE TD_idTD = :td AND Formation_idFormation = :form');
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) EXecute and dispatch status */
return $st->execute([
':td' => $idTD,
':form' => $idFormation
"TD" => $idTD,
"form" => $idFormation
]);
}
/* (3) Link a formation to a TD
*
* @idFormation<int> Id of the formation
* @idTD<int> Id of the TD
*
* @return linked<bool> Whether it has been linked
*
---------------------------------------------------------*/
public function linkFormation(int $idFormation, int $idTD) : bool{
$st = $this->pdo->prepare("INSERT INTO GroupeTD(TD_idTD,Formation_idFormation)
VALUE(:TD, :form)");
/* (1) Try to remove first if it already exists */
$this->unlinkFormation($idFormation, $idTD);
/* (2) Prepare statement */
$st = $this->pdo->prepare('INSERT INTO GroupeTD(TD_idTD,Formation_idFormation)
VALUE(:td, :form)');
/* (3) Manage statement error */
if( is_bool($st) )
return false;
/* (4) EXecute and dispatch status */
return $st->execute([
':td' => $idTD,
':form' => $idFormation
"TD" => $idTD,
"form" => $idFormation
]);
}
public function updateProf(?int $prof) : bool {
$st = $this->pdo->prepare("UPDATE TD SET Professeur_idProfesseur = :prof");
/* (4.1) Updates an existing TD
*
* @idTD<int> Id of the TD
* @idProf<int> [OPT] Id of the prof (NULL to set to NULL)
*
* @return updated<bool> Whether it has been updated
*
---------------------------------------------------------*/
public function updateProf(int $idTD, ?int $idProf) : bool {
/* (1) Prepare statement */
$st = $this->pdo->prepare('UPDATE TD
SET Professeur_idProfesseur = :idProf
WHERE idTD = :idTD');
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) Execute and dispatch status */
return $st->execute([ ':idTD' => $idTD, ':idProf' => $idProf ]);
return $st->execute([
"prof" => $prof
]);
}
/* (4.2) Updates an existing TD
*
* @idTD<int> Id of the TD
* @volume<float> [OPT] The new number of hours
*
* @return updated<bool> Whether it has been updated
*
---------------------------------------------------------*/
public function updateVolume(int $idTD, float $volume) : bool {
/* (1) Prepare statement */
$st = $this->pdo->prepare('UPDATE TD
SET volume = :volume
WHERE idTD = :idTD');
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) Execute and dispatch status */
return $st->execute([ ':idTD' => $idTD, ':volume' => $volume ]);
public function updateVolume(float $volume) : bool {
$st = $this->pdo->prepare("UPDATE TD SET volume = :vol");
return $st->execute([
"vol" => $volume
]);
}
/* (5) Deletes an existing td
*
* @idTD<int> Id of the TD
*
* @return deleted<bool> Whether it has been deleted
*
---------------------------------------------------------*/
public function delete(int $id) :bool {
/* (1) Prepare statement */
$st = $this->pdo->prepare("DELETE FROM TD WHERE idTD = :id");
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) Execute and dispatch status */
return $st->execute([ ':id' => $id ]);
}
/* (x) Get groups for a specific UE
*
* @code<String> UE code
*
* @return groups<array> The list of groups for this UE
* NULL on error
*
---------------------------------------------------------*/
public function getGroups(String $code) : ?array{
/* (1) Prepare statement */
$st = $this->pdo->prepare("SELECT
c.UE_code code,
c.idTD,
p.idProfesseur idProf,
p.firstName,
p.lastName,
IFNULL(lform.flist, '[]') formations,
c.volume
FROM TD c
LEFT JOIN ( SELECT gc.TD_idTD idTD, CONCAT('[', GROUP_CONCAT(DISTINCT gc.Formation_idFormation),']') flist
FROM GroupeTD gc
GROUP BY gc.TD_idTD
ORDER BY gc.Formation_idFormation DESC
) lform ON c.idTD = lform.idTD
LEFT JOIN Professeur p ON p.idProfesseur = c.Professeur_idProfesseur
WHERE c.UE_code = :code;");
/* (2) Check statement */
if( is_bool($st) )
return NULL;
/* (3) Execute statement */
$success = $st->execute([':code' => $code]);
/* (4) Check error */
if( !$success )
return NULL;
/* (5) Dispatch fetch result */
return $st->fetchAll();
}
/* (7) Get groups for a specific Professor
*
* @prof_id<int> Professor ID
*
* @return groups<array> The list of groups for this Professor
* NULL on error
*
---------------------------------------------------------*/
public function getForProfessor(int $prof_id) : ?array{
/* (1) Prepare statement */
$st = $this->pdo->prepare("SELECT
td.UE_code code,
ue.label label,
td.idTD,
IFNULL(lform.flist, '[]') formations,
td.volume
FROM TD td
LEFT JOIN ( SELECT gtd.TD_idTD idTD, CONCAT('[', GROUP_CONCAT(DISTINCT gtd.Formation_idFormation),']') flist
FROM GroupeTD gtd
GROUP BY gtd.TD_idTD
ORDER BY gtd.Formation_idFormation DESC
) lform ON td.idTD = lform.idTD
JOIN UE ue ON ue.code = td.UE_code
WHERE td.Professeur_idProfesseur = :prof_id;");
/* (2) Check statement */
if( is_bool($st) )
return NULL;
/* (3) Execute statement */
$success = $st->execute([':prof_id' => $prof_id]);
/* (4) Check error */
if( !$success )
return NULL;
/* (5) Dispatch fetch result */
return $st->fetchAll();
return $st->execute([
"id" => $id
]);
}
}

View File

@ -13,282 +13,75 @@ use database\core\Repo_i;
class tp extends Repo_i {
/* (1) Create a new TP
*
* @code<String> The code of the UE containing the TP
* @idProf<String> [OPT] The ID of the prof who teaches the TP
* @volume<float> The number of hours (float)
* @formations<array> The list of formations for that TP (list of int)
* @return created_code<String> Code of the created UE (NULL on error)
*
* @return created_id<int> UID of the created TP (NULL on error)
*
---------------------------------------------------------*/
public function create(string $code, ?int $idProf, float $volume, array $formations) : ?int{
/* (1) Prepare statement */
$st = $this->pdo->prepare('INSERT INTO TP(UE_code, Professeur_idProfesseur, volume)
VALUE(:UE, :idProf, :vol)');
/* (2) Manage statement error */
if( is_bool($st) )
return NULL;
/* (3) Try to execute request */
$success = $st->execute([
':UE' => $code,
':idProf' => $idProf,
':vol' => $volume
public function create(string $codeUE, ?int $idProf, float $volume, array $formations) : int{
//create the group
$st = $this->pdo->prepare("INSERT INTO TP(UE_code, Professeur_idProfesseur, volume)
VALUE(:UE, :idProf, :vol)");
$st->execute([
"UE" => $codeUE,
"idProf" => $idProf,
"vol" => $volume
]);
/* (4) Manage error */
if( !$success )
return NULL;
$idTP = $this->pdo->lastInsertId();
/* (5) Store @created_id */
$created_id = (int) $this->pdo->lastInsertId();
/* (6) We are done if there is no formations */
if( count($formations) <= 0)
return $created_id;
/* (7) Else -> create each formation */
foreach($formations as $form_id){
// 1. Ignore if wrong format
if( !is_int($form_id) || $form_id < 0 )
continue;
// 2. Link formation to created TP
$this->linkFormation($form_id, $created_id);
//if there is formations, link them with the group
if(count($formations) > 0){
$linkSt = $this->pdo->prepare("INSERT INTO GroupeTP(Formation_idFormation, TP_idTP)
VALUE (:form, :TP)");
foreach ($formations as $form){
$linkSt->execute([
"form" => $form,
"TP" => $idTP
]);
}
}
/* (7) Return @created_id */
return $created_id;
return $idTP;
}
/* (2) Unlink a formation from a TP
*
* @idFormation<int> Id of the formation
* @idTP<int> Id of the TP
*
* @return unlinked<bool> Whether it has been unlinked
*
---------------------------------------------------------*/
public function unlinkFormation(int $idFormation, int $idTP) : bool{
$st = $this->pdo->prepare("DELETE FROM GroupeTP WHERE TP_idTP = :TP AND Formation_idFormation = :form");
/* (1) Prepare statement */
$st = $this->pdo->prepare('DELETE FROM GroupeTP WHERE TP_idTP = :tp AND Formation_idFormation = :form');
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) EXecute and dispatch status */
return $st->execute([
':tp' => $idTP,
':form' => $idFormation
"TP" => $idTP,
"form" => $idFormation
]);
}
/* (3) Link a formation to a TP
*
* @idFormation<int> Id of the formation
* @idTP<int> Id of the TP
*
* @return linked<bool> Whether it has been linked
*
---------------------------------------------------------*/
public function linkFormation(int $idFormation, int $idTP) : bool{
$st = $this->pdo->prepare("INSERT INTO GroupeTP(TP_idTP,Formation_idFormation)
VALUE(:TP, :form)");
/* (1) Try to remove first if it already exists */
$this->unlinkFormation($idFormation, $idTP);
/* (2) Prepare statement */
$st = $this->pdo->prepare('INSERT INTO GroupeTP(TP_idTP,Formation_idFormation)
VALUE(:tp, :form)');
/* (3) Manage statement error */
if( is_bool($st) )
return false;
/* (4) EXecute and dispatch status */
return $st->execute([
':tp' => $idTP,
':form' => $idFormation
"TP" => $idTP,
"form" => $idFormation
]);
}
public function updateProf(?int $prof) : bool {
$st = $this->pdo->prepare("UPDATE TP SET Professeur_idProfesseur = :prof");
/* (4.1) Updates an existing TP
*
* @idTP<int> Id of the TP
* @idProf<int> [OPT] Id of the prof (NULL to set to NULL)
*
* @return updated<bool> Whether it has been updated
*
---------------------------------------------------------*/
public function updateProf(int $idTP, ?int $idProf) : bool {
/* (1) Prepare statement */
$st = $this->pdo->prepare('UPDATE TP
SET Professeur_idProfesseur = :idProf
WHERE idTP = :idTP');
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) Execute and dispatch status */
return $st->execute([ ':idTP' => $idTP, ':idProf' => $idProf ]);
return $st->execute([
"prof" => $prof
]);
}
/* (4.2) Updates an existing TP
*
* @idTP<int> Id of the TP
* @volume<float> [OPT] The new number of hours
*
* @return updated<bool> Whether it has been updated
*
---------------------------------------------------------*/
public function updateVolume(int $idTP, float $volume) : bool {
/* (1) Prepare statement */
$st = $this->pdo->prepare('UPDATE TP
SET volume = :volume
WHERE idTP = :idTP');
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) Execute and dispatch status */
return $st->execute([ ':idTP' => $idTP, ':volume' => $volume ]);
public function updateVolume(float $volume) : bool {
$st = $this->pdo->prepare("UPDATE TP SET volume = :vol");
return $st->execute([
"vol" => $volume
]);
}
/* (5) Deletes an existing tp
*
* @idTP<int> Id of the TP
*
* @return deleted<bool> Whether it has been deleted
*
---------------------------------------------------------*/
public function delete(int $id) :bool {
/* (1) Prepare statement */
$st = $this->pdo->prepare("DELETE FROM TP WHERE idTP = :id");
/* (2) Manage statement error */
if( is_bool($st) )
return false;
/* (3) Execute and dispatch status */
return $st->execute([ ':id' => $id ]);
}
/* (x) Get groups for a specific UE
*
* @code<String> UE code
*
* @return groups<array> The list of groups for this UE
* NULL on error
*
---------------------------------------------------------*/
public function getGroups(String $code) : ?array{
/* (1) Prepare statement */
$st = $this->pdo->prepare("SELECT
c.UE_code code,
c.idTP,
p.idProfesseur idProf,
p.firstName,
p.lastName,
IFNULL(lform.flist, '[]') formations,
c.volume
FROM TP c
LEFT JOIN ( SELECT gc.TP_idTP idTP, CONCAT('[', GROUP_CONCAT(DISTINCT gc.Formation_idFormation),']') flist
FROM GroupeTP gc
GROUP BY gc.TP_idTP
ORDER BY gc.Formation_idFormation DESC
) lform ON c.idTP = lform.idTP
LEFT JOIN Professeur p ON p.idProfesseur = c.Professeur_idProfesseur
WHERE c.UE_code = :code;");
/* (2) Check statement */
if( is_bool($st) )
return NULL;
/* (3) Execute statement */
$success = $st->execute([':code' => $code]);
/* (4) Check error */
if( !$success )
return NULL;
/* (5) Dispatch fetch result */
return $st->fetchAll();
}
/* (7) Get groups for a specific Professor
*
* @prof_id<int> Professor ID
*
* @return groups<array> The list of groups for this Professor
* NULL on error
*
---------------------------------------------------------*/
public function getForProfessor(int $prof_id) : ?array{
/* (1) Prepare statement */
$st = $this->pdo->prepare("SELECT
tp.UE_code code,
ue.label label,
tp.idTP,
IFNULL(lform.flist, '[]') formations,
tp.volume
FROM TP tp
LEFT JOIN ( SELECT gtp.TP_idTP idTP, CONCAT('[', GROUP_CONCAT(DISTINCT gtp.Formation_idFormation),']') flist
FROM GroupeTP gtp
GROUP BY gtp.TP_idTP
ORDER BY gtp.Formation_idFormation DESC
) lform ON tp.idTP = lform.idTP
JOIN UE ue ON ue.code = tp.UE_code
WHERE tp.Professeur_idProfesseur = :prof_id;");
/* (2) Check statement */
if( is_bool($st) )
return NULL;
/* (3) Execute statement */
$success = $st->execute([':prof_id' => $prof_id]);
/* (4) Check error */
if( !$success )
return NULL;
/* (5) Dispatch fetch result */
return $st->fetchAll();
return $st->execute([
"id" => $id
]);
}
}

View File

@ -18,17 +18,16 @@ class ue extends Repo_i {
*
* @code<String> The code of the UE
* @label<String> The UE label (name)
* @required<bool> If the UE is required
* @volumeCours<float> The UE required volume of COURSES
* @volumeTD<float> The UE required volume of TD
* @volumeTP<float> The UE required volume of TP
* @disabled<bool> [OPT] If it is disabled
* @defaultFormation<int> [OPT] If there is a foreign key for a default formation (if only one formation)
* @disabled<bool> If it is disabled
* @defaultFormation<bool> If there is a foreign key for a default formation (if only one formation)
*
* @return created_code<String> Code of the created UE (NULL on error)
*
---------------------------------------------------------*/
public function create(string $code, string $label, bool $required, float $volumeCours, float $volumeTD, float $volumeTP, bool $disabled = false, ?int $defaultFormation = null) : ?string {
public function create(string $code, string $label, bool $required, float $volumeCours, float $volumeTD, float $volumeTP, bool $disabled = false, ?int $defaultFormation = null) : ?int {
/* (1) Prepare request */
$st = $this->pdo->prepare("INSERT INTO UE(`code`, `label`, `required`, `volumeCours`, `volumeTD`, `volumeTP`, `disabled`, `Formation_idFormation`)
@ -40,14 +39,14 @@ class ue extends Repo_i {
/* (3) Bind params and execute request */
$success = $st->execute([
':code' => $code,
':label' => $label,
':required' => $required ? 1 : 0,
':volCours' => $volumeCours,
':volTD' => $volumeTD,
':volTP' => $volumeTP,
':disabled' => $disabled ? 1 : 0,
':idFormation' => $defaultFormation
"code" => $code,
"label" => $label,
"required" => $required ? 1 : 0,
"volCours" => $volumeCours,
"volTD" => $volumeTD,
"volTP" => $volumeTP,
"disabled" => $disabled ? 1 : 0,
"idFormation" => $defaultFormation
]);
/* (4) Manage execution error */
@ -55,7 +54,7 @@ class ue extends Repo_i {
return null;
/* (5) Return insert id */
return $code;
return $this->pdo->lastInsertId();
}
@ -63,45 +62,33 @@ class ue extends Repo_i {
/* (2) Updates an UE data
*
* @code<String> The UE code
* @new_code<String> [OPT] The new UE code
* @label<String> [OPT] The UE's new label
* @required<bool> [OPT] Whether the UE is required
* @volumeCours<float> [OPT] The UE's new volume of COURSES
* @volumeTD<float> [OPT] The UE's new volume of TD
* @volumeTP<float> [OPT] The UE's new volume of TP
* @disabled<bool> [OPT] Whether the UE is disabled
* @defaultFormation<int> [OPT] The default formation foreign key (-1 to unset)
* @defaultFormation<int> [OPT] The default formation foreign key
*
* @return updated<bool> Whether the update have been successful
*
---------------------------------------------------------*/
public function update(string $code, ?String $new_code, ?String $label, ?bool $required, ?float $volumeCours, ?float $volumeTD, ?float $volumeTP, ?bool $disabled, ?int $defaultFormation) : bool{
public function update(string $code, ?String $label, ?bool $required, ?float $volumeCours, ?float $volumeTD, ?float $volumeTP, ?bool $disabled, ?int $defaultFormation) : bool{
/* (1) Build request */
$build_rq = [];
$bind_param = [ ':code' => $code ];
if( !is_null($new_code) ){ $build_rq[] = '`code` = :new_code'; $bind_param[':new_code'] = $new_code; }
if( !is_null($label) ){ $build_rq[] = '`label` = :label'; $bind_param[':label'] = $label; }
if( !is_null($required) ){ $build_rq[] = '`required` = :required'; $bind_param[':required'] = $required?1:0; }
if( !is_null($required) ){ $build_rq[] = '`required` = :required'; $bind_param[':required'] = $required; }
if( !is_null($volumeCours) ){ $build_rq[] = '`volumeCours` = :volumeCours'; $bind_param[':volumeCours'] = $volumeCours; }
if( !is_null($volumeTD) ){ $build_rq[] = '`volumeTD` = :volumeTD'; $bind_param[':volumeTD'] = $volumeTD; }
if( !is_null($volumeTP) ){ $build_rq[] = '`volumeTP` = :volumeTP'; $bind_param[':volumeTP'] = $volumeTP; }
if( !is_null($disabled) ){ $build_rq[] = '`disabled` = :disabled'; $bind_param[':disabled'] = $disabled?1:0; }
// not null @defaultFormation -> set it
if( !is_null($defaultFormation) ){
// if @defaultFormation is (-1) -> unset
if( $defaultFormation < 0 ){ $build_rq[] = '`Formation_idFormation` = NULL'; }
// else -> set to new value
else{ $build_rq[] = '`Formation_idFormation` = :defaultFormation'; $bind_param[':defaultFormation'] = $defaultFormation; }
}
if( !is_null($disabled) ){ $build_rq[] = '`disabled` = :disabled'; $bind_param[':disabled'] = $disabled; }
if( !is_null($defaultFormation) ){ $build_rq[] = '`Formation_idFormation` = :defaultFormation'; $bind_param[':defaultFormation'] = $defaultFormation; }
/* (2) ERROR if no updated field */
if( count($build_rq) <= 0 )
if( count($build_rq) <= 0 || count($bind_param) <= 1 )
return FALSE;
/* (3) Build request */
@ -173,63 +160,14 @@ class ue extends Repo_i {
* @return ues<array> The UEs matching code (NULL on error)
*
---------------------------------------------------------*/
public function get(?String $code=null) : array{
public function get(?String $code=null) : ?array{
/* (1) Manage if no id given */
$cond = is_null($code) ? '' : 'HAVING `ue`.`code` = :code';
$cond = is_null($code) ? '' : ' WHERE `code` = :code';
$parm = is_null($code) ? [] : [':code' => $code];
/* (2) Prepare Statement */
$st = $this->pdo->prepare("
SELECT
ue.code,
ue.label,
ue.disabled,
ue.required,
ue.volumeCours,
ue.volumeTD,
ue.volumeTP,
IFNULL(ue.Formation_idFormation, -1) idForm,
fdef.labelFormation labelForm,
IFNULL(formlist.formations, '[]') formations,
IFNULL(formlist.nbrCours,0) nbrCours,
IFNULL(formlist.nbrTD,0) nbrTD,
IFNULL(formlist.nbrTP,0) nbrTP,
IFNULL(formlist.modCours,0) modCours,
IFNULL(formlist.modTD,0) modTD,
IFNULL(formlist.modTP,0) modTP,
IFNULL(formlist.nbrProfCours,0) nbrProfCours,
IFNULL(formlist.nbrProfTD,0) nbrProfTD,
IFNULL(formlist.nbrProfTP,0) nbrProfTP
FROM UE ue
LEFT JOIN Formation fdef ON ue.Formation_idFormation = fdef.idFormation
LEFT JOIN (
SELECT ue2.code code, CONCAT('[',GROUP_CONCAT(DISTINCT Formation.idFormation), ']') formations,
count(DISTINCT C.idCours) nbrCours, count(DISTINCT T.idTD) nbrTD, count(DISTINCT T2.idTP) nbrTP,
MOD(volC.vol,ue2.volumeCours) modCours,
MOD(volTD.vol,ue2.volumeTD) modTD,
MOD(volTP.vol,ue2.volumeTP) modTP,
count(DISTINCT C.Professeur_idProfesseur,C.idCours) nbrProfCours,
count(DISTINCT T.Professeur_idProfesseur,T.idTD) nbrProfTD,
count(DISTINCT T2.Professeur_idProfesseur,T2.idTP) nbrProfTP
FROM UE ue2
LEFT JOIN (SELECT sum(CO.volume) vol, CO.UE_code FROM Cours CO GROUP BY CO.UE_code) volC ON ue2.code = volC.UE_code
LEFT JOIN (SELECT sum(TD2.volume) vol, TD2.UE_code FROM TD TD2 GROUP BY TD2.UE_code) volTD ON ue2.code = volTD.UE_code
LEFT JOIN (SELECT sum(TP2.volume) vol, TP2.UE_code FROM TP TP2 GROUP BY TP2.UE_code) volTP ON ue2.code = volTP.UE_code
LEFT JOIN Cours C ON ue2.code = C.UE_code
LEFT JOIN TD T ON ue2.code = T.UE_code
LEFT JOIN TP T2 ON ue2.code = T2.UE_code
LEFT JOIN GroupeCours C2 ON C.idCours = C2.Cours_idCours
LEFT JOIN GroupeTD TD2 ON T.idTD = TD2.TD_idTD
LEFT JOIN GroupeTP TP2 ON T2.idTP = TP2.TP_idTP
JOIN Formation ON C2.Formation_idFormation = Formation.idFormation
OR TD2.Formation_idFormation = Formation.idFormation
OR TP2.Formation_idFormation = Formation.idFormation
GROUP BY `ue2`.`code`
) formlist ON formlist.code = ue.code
GROUP BY `ue`.`code`
$cond
ORDER BY `ue`.`label` ASC");
$st = $this->pdo->prepare("SELECT * FROM `UE`$cond GROUP BY `label` ASC");
/* (3) Bind params and execute statement */
if( is_bool($st) ) return [];
@ -290,13 +228,4 @@ class ue extends Repo_i {
return $fetched;
}
public function exportUE() : array{
$st = $this->pdo->prepare("SELECT * FROM UE
LEFT JOIN Formation
ON UE.Formation_idFormation = Formation.idFormation
ORDER BY Formation_idFormation IS NULL DESC, Formation_idFormation ASC");
$st->execute();
return $st->fetchAll();
}
}

View File

@ -28,11 +28,8 @@
echo "window._SERVER = ".json_encode([
'session' => [
'name' => $_SESSION['CAS']['login'],
'connected' => isset($_SESSION['AUTH']) ? count($_SESSION['AUTH']) > 0 : false,
'departments' => array_map(function($d){ return [ 'id' => $d['idDep'], 'label' => $d['labelDep']]; }, $_SESSION['AvailableDepartments']),
'department_id' => $_SESSION['CurrentDepartmentId'],
'version' => $_SESSION['VERSION']
'name' => $_SESSION['NAME'],
'connected' => isset($_SESSION['AUTH']) ? count($_SESSION['AUTH']) > 0 : false
]
])."\n";

View File

@ -33,43 +33,19 @@
}
/* (2) Only teacher */
if( !in_array('cas_admin', $_SESSION['AUTH']) ){
// redirection
if( $this->pagename != "fiche" ){
header('Location: /fiche/');
die();
}
// deconnection
if( $this->uri == 'logout' || $this->uri == 'logout/' ){
\session_destroy();
header('Location: /');
die();
}
// load page
include __PUBLIC__."/page/fiche.php";
die();
}
/* (3) Build page file name */
/* (1) Build page file name */
$page_fname = __PUBLIC__."/page/".$this->pagename.".php";
/* (4) If page does not exist -> 404 */
/* (2) If page does not exist -> 404 */
if( !file_exists($page_fname) )
include __PUBLIC__.'/page/404.php';
/* (5) Set URI arguments */
/* (3) Set URI arguments */
$_GET['uri'] = explode('/', $this->uri);
/* (6) Load page */
/* (4) Load page */
include __PUBLIC__."/page/".$this->pagename.".php";
}

View File

@ -26,10 +26,6 @@
},
"require": {
"phpoffice/phpspreadsheet": "^1.1",
"phpstan/phpstan": "^0.9.2",
"ifsnop/mysqldump-php": "2.*",
"setasign/fpdf": "1.8.1",
"mpdf/mpdf": "^7.0",
"php" : ">= 7.1"
"phpstan/phpstan": "^0.9.2"
}
}

358
composer.lock generated
View File

@ -4,60 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "d300af5ed297b7cdfbfda9d2604a8f95",
"content-hash": "18a1824304295027ad9aa6050280670b",
"packages": [
{
"name": "ifsnop/mysqldump-php",
"version": "v2.4",
"source": {
"type": "git",
"url": "https://github.com/ifsnop/mysqldump-php.git",
"reference": "2a633b3da5db1e5bdc39c1b71c697ef197c39eeb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ifsnop/mysqldump-php/zipball/2a633b3da5db1e5bdc39c1b71c697ef197c39eeb",
"reference": "2a633b3da5db1e5bdc39c1b71c697ef197c39eeb",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"squizlabs/php_codesniffer": "1.*"
},
"type": "library",
"autoload": {
"psr-4": {
"Ifsnop\\": "src/Ifsnop/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Diego Torres",
"homepage": "https://github.com/ifsnop",
"role": "Developer"
}
],
"description": "This is a php version of linux's mysqldump in terminal \"$ mysqldump -u username -p...\"",
"homepage": "https://github.com/ifsnop/mysqldump-php",
"keywords": [
"backup",
"database",
"dump",
"export",
"mysql",
"mysqldump",
"pdo",
"sqlite"
],
"time": "2018-03-07T22:27:23+00:00"
},
{
"name": "jean85/pretty-package-versions",
"version": "1.1",
@ -109,73 +57,6 @@
],
"time": "2018-01-21T13:54:22+00:00"
},
{
"name": "mpdf/mpdf",
"version": "v7.0.3",
"source": {
"type": "git",
"url": "https://github.com/mpdf/mpdf.git",
"reference": "5681a0cae1eea197143d5d27f06e19b0523cd8d6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mpdf/mpdf/zipball/5681a0cae1eea197143d5d27f06e19b0523cd8d6",
"reference": "5681a0cae1eea197143d5d27f06e19b0523cd8d6",
"shasum": ""
},
"require": {
"ext-gd": "*",
"ext-mbstring": "*",
"paragonie/random_compat": "^1.4|^2.0",
"php": "^5.6 || ~7.0.0 || ~7.1.0 || ~7.2.0",
"psr/log": "^1.0",
"setasign/fpdi": "1.6.*"
},
"require-dev": {
"mockery/mockery": "^0.9.5",
"phpunit/phpunit": "^5.0",
"squizlabs/php_codesniffer": "^2.7.0",
"tracy/tracy": "^2.4"
},
"suggest": {
"ext-bcmath": "Needed for generation of some types of barcodes",
"ext-xml": "Needed mainly for SVG manipulation",
"ext-zlib": "Needed for compression of embedded resources, such as fonts"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-development": "7.0-dev"
}
},
"autoload": {
"psr-4": {
"Mpdf\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0"
],
"authors": [
{
"name": "Matěj Humpál",
"role": "Developer, maintainer"
},
{
"name": "Ian Back",
"role": "Developer (retired)"
}
],
"description": "A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support",
"homepage": "https://mpdf.github.io",
"keywords": [
"pdf",
"php",
"utf-8"
],
"time": "2018-01-03T07:32:36+00:00"
},
{
"name": "nette/bootstrap",
"version": "v2.4.5",
@ -642,16 +523,16 @@
},
{
"name": "nikic/php-parser",
"version": "v3.1.5",
"version": "v3.1.4",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce"
"reference": "e57b3a09784f846411aa7ed664eedb73e3399078"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bb87e28e7d7b8d9a7fda231d37457c9210faf6ce",
"reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/e57b3a09784f846411aa7ed664eedb73e3399078",
"reference": "e57b3a09784f846411aa7ed664eedb73e3399078",
"shasum": ""
},
"require": {
@ -689,7 +570,7 @@
"parser",
"php"
],
"time": "2018-02-28T20:30:58+00:00"
"time": "2018-01-25T21:31:33+00:00"
},
{
"name": "ocramius/package-versions",
@ -740,66 +621,18 @@
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"time": "2018-02-05T13:05:30+00:00"
},
{
"name": "paragonie/random_compat",
"version": "v2.0.11",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/5da4d3c796c275c55f057af5a643ae297d96b4d8",
"reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8",
"shasum": ""
},
"require": {
"php": ">=5.2.0"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
},
"type": "library",
"autoload": {
"files": [
"lib/random.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com",
"homepage": "https://paragonie.com"
}
],
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
"keywords": [
"csprng",
"pseudorandom",
"random"
],
"time": "2017-09-27T21:40:39+00:00"
},
{
"name": "phpoffice/phpspreadsheet",
"version": "1.2.0",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "8380fb3ad28242093c18d0baa9b7e67fb429ea84"
"reference": "a2771e562e3a17c0d512d2009e38fd628beece90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/8380fb3ad28242093c18d0baa9b7e67fb429ea84",
"reference": "8380fb3ad28242093c18d0baa9b7e67fb429ea84",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/a2771e562e3a17c0d512d2009e38fd628beece90",
"reference": "a2771e562e3a17c0d512d2009e38fd628beece90",
"shasum": ""
},
"require": {
@ -829,6 +662,8 @@
},
"suggest": {
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
"ext-dom": "Option to read and write HTML files",
"ext-gd": "Required for exact column width autocalculation",
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
"tecnick.com/tcpdf": "Option for rendering PDF with PDF Writer"
@ -841,7 +676,7 @@
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1-or-later"
"LGPL-2.1"
],
"authors": [
{
@ -872,7 +707,7 @@
"xls",
"xlsx"
],
"time": "2018-03-04T20:41:15+00:00"
"time": "2018-01-28T12:37:15+00:00"
},
{
"name": "phpstan/phpdoc-parser",
@ -982,65 +817,18 @@
"description": "PHPStan - PHP Static Analysis Tool",
"time": "2018-01-28T13:22:19+00:00"
},
{
"name": "psr/log",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2016-10-10T12:19:37+00:00"
},
{
"name": "psr/simple-cache",
"version": "1.0.1",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/simple-cache.git",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
"reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/753fa598e8f3b9966c886fe13f370baa45ef0e24",
"reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24",
"shasum": ""
},
"require": {
@ -1075,108 +863,20 @@
"psr-16",
"simple-cache"
],
"time": "2017-10-23T01:57:42+00:00"
},
{
"name": "setasign/fpdf",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/Setasign/FPDF.git",
"reference": "2c68c9e6c034ac3187d25968790139a73184cdb1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Setasign/FPDF/zipball/2c68c9e6c034ac3187d25968790139a73184cdb1",
"reference": "2c68c9e6c034ac3187d25968790139a73184cdb1",
"shasum": ""
},
"type": "library",
"autoload": {
"classmap": [
"fpdf.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"no usage restriction"
],
"authors": [
{
"name": "Olivier Plathey",
"email": "oliver@fpdf.org",
"homepage": "http://fpdf.org/"
}
],
"description": "FPDF is a PHP class which allows to generate PDF files with pure PHP. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.",
"homepage": "http://www.fpdf.org",
"keywords": [
"fpdf",
"pdf"
],
"time": "2016-01-01T17:47:15+00:00"
},
{
"name": "setasign/fpdi",
"version": "1.6.2",
"source": {
"type": "git",
"url": "https://github.com/Setasign/FPDI.git",
"reference": "a6ad58897a6d97cc2d2cd2adaeda343b25a368ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Setasign/FPDI/zipball/a6ad58897a6d97cc2d2cd2adaeda343b25a368ea",
"reference": "a6ad58897a6d97cc2d2cd2adaeda343b25a368ea",
"shasum": ""
},
"suggest": {
"setasign/fpdf": "FPDI will extend this class but as it is also possible to use \"tecnickcom/tcpdf\" as an alternative there's no fixed dependency configured.",
"setasign/fpdi-fpdf": "Use this package to automatically evaluate dependencies to FPDF.",
"setasign/fpdi-tcpdf": "Use this package to automatically evaluate dependencies to TCPDF."
},
"type": "library",
"autoload": {
"classmap": [
"filters/",
"fpdi.php",
"fpdf_tpl.php",
"fpdi_pdf_parser.php",
"pdf_context.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan Slabon",
"email": "jan.slabon@setasign.com",
"homepage": "https://www.setasign.com"
}
],
"description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.",
"homepage": "https://www.setasign.com/fpdi",
"keywords": [
"fpdf",
"fpdi",
"pdf"
],
"time": "2017-05-11T14:25:49+00:00"
"time": "2017-01-02T13:31:39+00:00"
},
{
"name": "symfony/console",
"version": "v4.0.6",
"version": "v4.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "555c8dbe0ae9e561740451eabdbed2cc554b6a51"
"reference": "36d5b41e7d4e1ccf0370f6babe966c08ef0a1488"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/555c8dbe0ae9e561740451eabdbed2cc554b6a51",
"reference": "555c8dbe0ae9e561740451eabdbed2cc554b6a51",
"url": "https://api.github.com/repos/symfony/console/zipball/36d5b41e7d4e1ccf0370f6babe966c08ef0a1488",
"reference": "36d5b41e7d4e1ccf0370f6babe966c08ef0a1488",
"shasum": ""
},
"require": {
@ -1231,20 +931,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2018-02-26T15:55:47+00:00"
"time": "2018-01-29T09:06:29+00:00"
},
{
"name": "symfony/finder",
"version": "v4.0.6",
"version": "v4.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "44a796d2ecc2a16a5fc8f2956a34ee617934d55f"
"reference": "8b08180f2b7ccb41062366b9ad91fbc4f1af8601"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/44a796d2ecc2a16a5fc8f2956a34ee617934d55f",
"reference": "44a796d2ecc2a16a5fc8f2956a34ee617934d55f",
"url": "https://api.github.com/repos/symfony/finder/zipball/8b08180f2b7ccb41062366b9ad91fbc4f1af8601",
"reference": "8b08180f2b7ccb41062366b9ad91fbc4f1af8601",
"shasum": ""
},
"require": {
@ -1280,7 +980,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2018-03-05T18:28:26+00:00"
"time": "2018-01-03T07:38:00+00:00"
},
{
"name": "symfony/polyfill-mbstring",

Binary file not shown.

View File

@ -4,8 +4,7 @@
"host" : "mariadb",
"dbname" : "vhost",
"user" : "php",
"password" : "4JB1dtbrIC8pT935",
"debug" : true
"password" : "4JB1dtbrIC8pT935"
},
"remote": {
"host" : "db_remote_host",

View File

@ -1,6 +1,4 @@
{
"POST": {
"des": "Returns the API documentation",
"per": [],
@ -26,21 +24,25 @@
"GET": {
"des": "Authenticatation callback (used by third-party OAuth)",
"per": [],
"par": {
"URL0": { "des": "Whether to manage a popup", "typ": "id", "opt": true, "ren": "popup_mode", "def": 0 }
},
"par": {},
"opt": { "download": true }
},
"POST": {
"des": "Login if not already authenticated",
"per": [],
"par": {}
},
"PUT": {
"des": "Real logout to change login",
"per": [["cas_user"]],
"des": "Check if authenticated",
"per": [],
"par": {}
},
"DELETE": {
"des": "Logout",
"per": [["cas_user"]],
"per": [],
"par": {}
}
@ -63,121 +65,20 @@
"excel":{
"POST": {
"des": "Import data from an Excel file",
"per": [["cas_admin"]],
"per": [],
"par": {
}
}
},
"department":{
"GET": {
"des": "Get one or all departments",
"per": [["cas_user"]],
"par": {
"URL0": { "des": "Optional department id.", "typ": "id", "ren": "id_dep", "opt": true }
},
"out": {
"departments": { "des": "department list", "typ": "array" }
}
},
"POST": {
"des": "Create a new Department",
"per": [["cas_user"]],
"par": {
"name": { "des": "Name of the department", "typ": "text"}
}
},
"PUT":{
"des": "Switch the user on another department database",
"per": [["cas_user"]],
"par": {
"URL0": {"des": "Department id", "typ": "id", "ren": "department" }
},
"out": {
"switched": { "des": "Whether the department has been switched", "typ": "bool" }
}
},
"departement":{
"errors":{
"GET": {
"des": "Get the list of incoherence of the department",
"per": [["cas_admin"]],
"per": [],
"par": {
}
}
},
"stats":{
"GET": {
"des": "Get the statistics about the department",
"per": [["cas_admin"]],
"par": {
}
}
},
"export":{
"GET": {
"des": "Export the data of the current department and version to a Excel file",
"per": [["cas_admin"]],
"par": {},
"opt": { "download": true }
}
},
"version":{
"switch":{
"GET": {
"des": "Switch database version for the current session",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "The version id", "typ": "id", "ren": "version" }
},
"out": {
"sucess": { "des": "success of the operation", "typ": "bool" }
}
}
},
"GET": {
"des": "Get the list of the versions of the department",
"per": [["cas_admin"]],
"par": {},
"out": {
"versions": { "des": "List of available versions", "typ": "array" }
}
},
"POST": {
"des": "Create a backup if the name is empty, execute the backup if the name is set",
"per": [["cas_admin"]],
"par": {
"label": { "des": "Label of the version", "typ": "text" }
},
"out": {
"created_id": { "des": "The id of the created version", "typ": "varchar(10,10,alphanumeric)" }
}
},
"PUT": {
"des": "Update a version and switch to this version",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "id of the version", "typ": "id", "ren": "version" },
"label": { "des": "Label de la version", "typ": "text", "opt": true },
"default": { "des": "Whether this version should be used on login", "typ": "bool", "opt": true }
},
"out": {
"updated": { "des": "Whether the version has been switched|applied", "typ": "bool" }
}
},
"DELETE": {
"des": "Delete a backup",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "The version id", "typ": "id", "ren": "version" }
},
"out": {
"deleted": { "des": "Whether the version has been deleted", "typ": "bool" }
}
}
}
},
@ -185,7 +86,7 @@
"POST": {
"des": "Creates a new professor",
"per": [["cas_admin"]],
"per": [],
"par": {
"firstName": { "des": "Professor last name.", "typ": "varchar(2,30,alphanumeric)" },
"lastName": { "des": "Professor first name.", "typ": "varchar(2,30,alphanumeric)" },
@ -202,7 +103,7 @@
"GET": {
"des": "Get one or all professors",
"per": [["cas_admin"]],
"per": [],
"par": {
"URL0": { "des": "Whether to return VH", "typ": "id", "ren": "with_vh" },
"URL1": { "des": "Optional professor UID.", "typ": "id", "ren": "prof_id", "opt": true }
@ -214,7 +115,7 @@
"DELETE": {
"des": "Deletes an existing professor",
"per": [["cas_admin"]],
"per": [],
"par": {
"URL0": { "des": "Professor UID.", "typ": "id", "ren": "prof_id" }
},
@ -225,7 +126,7 @@
"PUT": {
"des": "Edits an existing professor",
"per": [["cas_admin"]],
"per": [],
"par": {
"URL0": { "des": "Optional professor UID.", "typ": "id", "ren": "prof_id" },
"firstName": { "des": "Professor last name.", "typ": "varchar(2,30,alphanumeric)", "opt": true },
@ -234,20 +135,29 @@
"hoursToDo": { "des": "Number of hours professor have to do", "typ": "id", "opt": true },
"initials": { "des": "Professor initials", "typ": "varchar(2,8,letters)", "opt": true },
"isAdmin": { "des": "Whether professor is an admin", "typ": "boolean", "opt": true },
"casLogin": { "des": "Optional CAS username", "typ": "varchar(6,16,letters)", "opt": true },
"remCas": { "des": "Unset CAS username", "typ": "boolean", "def": false, "opt": true }
"casLogin": { "des": "Optional CAS username", "typ": "varchar(6,16,letters)", "opt": true }
},
"out": {
"updated": { "des": "Whether the professor has been updated", "typ": "boolean" }
}
},
"stats": {
"GET":{
"des": "Get statistics of the professor",
"per": [],
"par":{
"URL0": {"des" : "Id of the professor", "typ": "id", "ren": "idProf", "opt" : false}
}
}
},
"filter": {
"POST": {
"des": "Get matching professors (only ids) for a given filter",
"per": [["cas_admin"]],
"per": [],
"par": {
"categories": { "des": "Optional category ID list", "typ": "array<id>", "opt": true },
"formations": { "des": "Optional formation ID list", "typ": "array<id>", "opt": true },
"ues": { "des": "Optional UE code list", "typ": "array<varchar(2,30,alphanumeric)>", "opt": true }
},
@ -255,19 +165,6 @@
"matches": { "des": "Matching professor UID(s)", "typ": "array<id>" }
}
}
},
"pdf": {
"GET": {
"des": "Get a professor's fiche",
"per": [["cas_admin"], ["cas_user"]],
"par": {
"URL0": { "des": "Optional professor UID.", "typ": "id", "ren": "prof_id" }
},
"opt": { "download": true }
}
}
@ -277,266 +174,50 @@
"POST": {
"des": "Creates a new UE",
"per": [["cas_admin"]],
"per": [],
"par": {
"code": { "des": "UE code.", "typ": "varchar(4,20,alphanumeric)" },
"label": { "des": "UE label", "typ": "varchar(4,30,alphanumeric)" },
"required": { "des": "If UE is required", "typ": "bool" },
"volumeCours": { "des": "Number of course hours for UE", "typ": "float" },
"volumeTD": { "des": "Number of TD hours for UE", "typ": "float" },
"volumeTP": { "des": "Number of TP hours for UE", "typ": "float" },
"disabled": { "des": "Whether UE is disabled", "typ": "boolean" },
"defaultFormation": { "des": "UID for optional default formation (-1 if none)", "typ": "int", "opt": true, "def": -1 }
"code": { "des": "UE code.", "typ": "varchar(2,30,alphanumeric)" },
"label": { "des": "UE label", "typ": "varchar(2,30,alphanumeric)" },
"required": { "des": "If UE is required", "typ": "bool" },
"volumeCours": { "des": "Number of course hours for UE", "typ": "float" },
"volumeTD": { "des": "Number of TD hours for UE", "typ": "float" },
"volumeTP": { "des": "Number of TP hours for UE", "typ": "float" },
"disabled": { "des": "Whether UE is disabled", "typ": "boolean" },
"defaultFormation": { "des": "UID for optional default formation", "typ": "id", "opt": true }
},
"out": {
"created_code": { "des": "Created UE code", "typ": "varchar(4,20,alphanumeric)" }
"created_code": { "des": "Created UE code", "typ": "varchar(2,30,alphanumeric)" }
}
},
"GET": {
"des": "Get one or all UE",
"per": [["cas_admin"]],
"per": [],
"par": {
"URL0": { "des": "Optional UE code.", "typ": "varchar(4,20,alphanumeric)", "ren": "code", "opt": true }
"URL0": { "des": "Optional UE code.", "typ": "varchar(2,30,alphanumeric)", "ren": "code", "opt": true }
},
"out": {
"ues": { "des": "UE list", "typ": "array" }
}
},
"DELETE": {
"des": "Deletes an existing UE",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "UE code.", "typ": "varchar(4,20,alphanumeric)", "ren": "code" }
},
"out": {
"deleted": { "des": "Whether it has been deleted", "typ": "boolean" }
}
},
"PUT": {
"des": "Edits an existing UE",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "UE code.", "typ": "varchar(4,20,alphanumeric)", "ren": "code" },
"new_code": { "des": "UE new code", "typ": "varchar(4,20,alphanumeric)", "opt": true },
"label": { "des": "UE label", "typ": "varchar(4,30,alphanumeric)", "opt": true },
"required": { "des": "If UE is required", "typ": "bool", "opt": true },
"volumeCours": { "des": "Number of course hours for UE", "typ": "float", "opt": true },
"volumeTD": { "des": "Number of TD hours for UE", "typ": "float", "opt": true },
"volumeTP": { "des": "Number of TP hours for UE", "typ": "float", "opt": true },
"disabled": { "des": "Whether UE is disabled", "typ": "boolean", "opt": true },
"defaultFormation": { "des": "UID for optional default formation (-1 for none)", "typ": "int", "opt": true }
},
"out": {
"updated": { "des": "Whether the UE has been updated", "typ": "boolean" }
}
},
"cours": {
"POST": {
"des" : "Creates a new Cours for an UE",
"per": [["cas_admin"]],
"par": {
"code": { "des": "Code of the UE", "typ": "varchar(4,20,alphanumeric)" },
"idProf": { "des": "Id of the professor", "typ": "id", "opt": true },
"volume": { "des": "Number of hours for Cours", "typ": "id", "opt": true, "def": 0 },
"formations": { "des": "List of formations (ids)", "typ": "array<id>", "opt": true, "def": [] }
},
"out": {
"created_id" : { "des": "The id of the created Cours", "typ": "id" },
"formations" : { "des": "The ids of the linked formations", "typ": "array<id>" }
}
},
"GET": {
"des" : "Get all cours data about a given UE",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "Code of the UE", "typ": "varchar(4,20,alphanumeric)", "ren": "code" }
}
},
"PUT": {
"des" : "Updates an existing Cours",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "Id of the Cours", "typ": "id", "ren": "idCours" },
"idProf": { "des": "Id of the professor (-1 to unset)", "typ": "int", "opt": true },
"volume": { "des": "Number of hours for Cours", "typ": "float", "opt": true },
"add_form": { "des": "Id of formations to add", "typ": "array<id>", "opt": true, "def": [] },
"rem_form": { "des": "Id of formations to remove", "typ": "array<id>", "opt": true, "def": [] }
},
"out": {
"updated" : { "des": "Whether it has been updated", "typ": "bool" }
}
},
"DELETE": {
"des" : "Deletes an existing Cours",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "Id of the Cours", "typ": "id", "ren": "idCours" }
},
"out": {
"deleted" : { "des": "Whether it has been deleted", "typ": "bool" }
}
}
},
"td": {
"POST": {
"des" : "Creates a new TD for an UE",
"per": [["cas_admin"]],
"par": {
"code": { "des": "Code of the UE", "typ": "varchar(4,20,alphanumeric)" },
"idProf": { "des": "Id of the professor", "typ": "id", "opt": true },
"volume": { "des": "Number of hours for TD", "typ": "id", "opt": true, "def": 0 },
"formations": { "des": "List of formations (ids)", "typ": "array<id>", "opt": true, "def": [] }
},
"out": {
"created_id" : { "des": "The id of the created TD", "typ": "id" },
"formations" : { "des": "The ids of the linked formations", "typ": "array<id>" }
}
},
"GET": {
"des" : "Get all TD data about a given UE",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "Code of the UE", "typ": "varchar(4,20,alphanumeric)", "ren": "code" }
}
},
"PUT": {
"des" : "Updates an existing TD",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "Id of the TD", "typ": "id", "ren": "idTD" },
"idProf": { "des": "Id of the professor (-1 to unset)", "typ": "int", "opt": true },
"volume": { "des": "Number of hours for TD", "typ": "float", "opt": true },
"add_form": { "des": "Id of formations to add", "typ": "array<id>", "opt": true, "def": [] },
"rem_form": { "des": "Id of formations to remove", "typ": "array<id>", "opt": true, "def": [] }
},
"out": {
"updated" : { "des": "Whether it has been updated", "typ": "bool" }
}
},
"DELETE": {
"des" : "Deletes an existing TD",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "Id of the TD", "typ": "id", "ren": "idTD" }
},
"out": {
"deleted" : { "des": "Whether it has been deleted", "typ": "bool" }
}
}
},
"tp": {
"POST": {
"des" : "Creates a new TP for an UE",
"per": [["cas_admin"]],
"par": {
"code": { "des": "Code of the UE", "typ": "varchar(4,20,alphanumeric)" },
"idProf": { "des": "Id of the professor", "typ": "id", "opt": true },
"volume": { "des": "Number of hours for TP", "typ": "id", "opt": true, "def": 0 },
"formations": { "des": "List of formations (ids)", "typ": "array<id>", "opt": true, "def": [] }
},
"out": {
"created_id" : { "des": "The id of the created TP", "typ": "id" },
"formations" : { "des": "The ids of the linked formations", "typ": "array<id>" }
}
},
"GET": {
"des" : "Get all TP data about a given UE",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "Code of the UE", "typ": "varchar(4,20,alphanumeric)", "ren": "code" }
}
},
"PUT": {
"des" : "Updates an existing TP",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "Id of the TP", "typ": "id", "ren": "idTP" },
"idProf": { "des": "Id of the professor (-1 to unset)", "typ": "int", "opt": true },
"volume": { "des": "Number of hours for TP", "typ": "float", "opt": true },
"add_form": { "des": "Id of formations to add", "typ": "array<id>", "opt": true, "def": [] },
"rem_form": { "des": "Id of formations to remove", "typ": "array<id>", "opt": true, "def": [] }
},
"out": {
"updated" : { "des": "Whether it has been updated", "typ": "bool" }
}
},
"DELETE": {
"des" : "Deletes an existing TP",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "Id of the TP", "typ": "id", "ren": "idTP" }
},
"out": {
"deleted" : { "des": "Whether it has been deleted", "typ": "bool" }
}
}
}
},
"formation": {
"GET":{
"des": "Get all data about a formation",
"per": [["cas_admin"]],
"per": [],
"par": {
"URL0":{"des" : "Id of the formation", "typ": "id", "ren": "form_id", "opt" : true }
}
},
"POST":{
"des": "Create a new formation",
"per": [["cas_admin"]],
"par": {
"label":{"des" : "name of the formation", "typ": "text" },
"isInternal":{"des" : "is this formation internal to the department", "typ": "bool" }
}
},
"PUT":{
"des": "Update a formation",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "Id of the formation", "typ": "id", "ren": "idFormation" },
"label":{"des" : "name of the formation", "typ": "text", "opt":true },
"isInternal":{"des" : "is this formation internal to the department", "typ": "bool", "opt":true }
}
},
"DELETE":{
"des": "Delete a formation",
"per": [["cas_admin"]],
"par": {
"URL0": { "des": "Id of the formation", "typ": "id", "ren": "idFormation" }
}
}
},
"category": {
"GET": {
"des" : "Get all data about a given category | all",
"per": [["cas_admin"]],
"per": [],
"par": {
"URL0": { "des": "Id of the category", "typ": "id", "ren": "cat_id", "opt": true }
}

9419
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,7 @@
"node-sass": "^4.7.2",
"sass-loader": "^6.0.6",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.5.16",
"vue-template-compiler": "^2.5.9",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.5"
}

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
enable-background="new 0 0 44 43"
height="43px"
id="Layer_1"
version="1.1"
viewBox="0 0 44 43"
width="44px"
xml:space="preserve"
sodipodi:docname="admin-disabled.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06"><metadata
id="metadata9"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs7" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1015"
id="namedview5"
showgrid="false"
inkscape:zoom="10.976744"
inkscape:cx="26.47426"
inkscape:cy="19.2405"
inkscape:window-x="0"
inkscape:window-y="29"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1"
inkscape:snap-midpoints="true" /><path
style="fill:#231f20"
d="M 28.492188 0 C 24.532187 0.00675 20.571922 1.5262344 17.544922 4.5527344 C 16.198022 5.8996337 15.192784 7.4685221 14.484375 9.1425781 L 8.4960938 3.1542969 L 5.7675781 5.8847656 L 39.873047 39.990234 L 42.601562 37.259766 L 35.001953 29.660156 C 36.615245 28.891394 38.130701 27.834142 39.478516 26.486328 C 45.531516 20.433328 45.4915 10.578391 39.4375 4.5253906 C 36.4115 1.4988906 32.452188 -0.00675 28.492188 0 z M 33.714844 6.8730469 C 34.738469 6.8730469 35.761469 7.2634219 36.542969 8.0449219 C 38.105969 9.6079219 38.104969 12.138172 36.542969 13.701172 C 34.980969 15.264172 32.449719 15.264172 30.886719 13.701172 C 29.323719 12.139172 29.324719 9.6079219 30.886719 8.0449219 C 31.667719 7.2634219 32.691219 6.8730469 33.714844 6.8730469 z M 13.433594 18.46875 C 13.588826 19.402362 13.811332 20.312408 14.113281 21.173828 L 1.0644531 34.224609 C 1.0614531 34.228609 1.0615936 34.226469 1.0585938 34.230469 L 1 34.171875 C 0.327 34.913875 0.65429688 34.655578 0.65429688 34.767578 L 0.37109375 42.101562 C 0.37209375 42.702563 0.89804686 43.144531 1.4980469 43.144531 L 8.7695312 42.925781 C 8.8805313 42.925781 8.6437656 43.231594 9.3847656 42.558594 L 9.5429688 42.714844 L 9.5527344 42.705078 L 11.664062 40.59375 L 11.130859 36.380859 L 15.375 36.373047 L 15.357422 32.101562 L 19.441406 32.816406 L 19.550781 32.707031 L 22.453125 29.804688 C 23.563502 30.302632 24.697457 30.656819 25.839844 30.875 L 13.433594 18.46875 z "
id="fill-edit" /></svg>

Before

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="32px"
id="Layer_1"
style="enable-background:new 0 0 32 32;"
version="1.1"
viewBox="0 0 32 32"
width="32px"
xml:space="preserve"
sodipodi:docname="back.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06"><metadata
id="metadata9"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs7" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1015"
id="namedview5"
showgrid="false"
inkscape:zoom="7.375"
inkscape:cx="16"
inkscape:cy="16"
inkscape:window-x="0"
inkscape:window-y="29"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" /><path
d="M 12,6 C 11.469,6 11.005141,6.1930781 10.619141,6.5800781 L 2.6621094,14.537109 C 2.3341094,14.865109 2,15.271 2,16 c 0,0.729 0.2794844,1.080266 0.6464844,1.447266 l 7.9726566,7.972656 C 11.005141,25.806922 11.469,26 12,26 c 1.188,0 2,-1.016 2,-2 0,-0.516 -0.186078,-0.986859 -0.580078,-1.380859 L 8.8007812,18 H 28 c 1.104,0 2,-0.896 2,-2 0,-1.104 -0.896,-2 -2,-2 H 8.8007812 L 13.419922,9.3808594 C 13.813922,8.9868594 14,8.516 14,8 14,7.016 13.187,6 12,6 Z"
id="fill-edit"
inkscape:connector-curvature="0" /></svg>

Before

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
enable-background="new 0 0 49 49"
height="49px"
id="Layer_1"
version="1.1"
viewBox="0 0 49 49"
width="49px"
xml:space="preserve"
sodipodi:docname="bell-disabled.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06"><metadata
id="metadata15"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs13" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1015"
id="namedview11"
showgrid="false"
inkscape:zoom="4.8163265"
inkscape:cx="24.5"
inkscape:cy="24.5"
inkscape:window-x="0"
inkscape:window-y="29"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" /><path
inkscape:connector-curvature="0"
id="fill-edit"
d="M 45.771484,-0.05664062 37.193359,8.5214844 c -1.615,-1.068 -3.436625,-1.8444688 -5.390625,-2.2304688 C 31.455734,3.8680156 29.3295,2 26.8125,2 24.2945,2 22.326516,3.8680156 21.978516,6.2910156 15.096516,7.6530156 10,13.719 10,21 V 32 H 8.75 c -2.209,0 -4,1.791 -4,4 0,1.352 0.6732187,2.541625 1.6992188,3.265625 L 0.19335938,45.521484 3.7285156,49.056641 49.306641,3.4785156 Z M 42.416016,14.369141 16.785156,40 H 44.75 c 2.209,0 4,-1.791 4,-4 0,-2.209 -1.791,-4 -4,-4 H 44 V 21 c 0,-2.383 -0.577984,-4.630859 -1.583984,-6.630859 z M 22,42 c 0,2.762 2.239,5 5,5 2.762,0 5,-2.238 5,-5 z" /></svg>

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
enable-background="new 0 0 49 49"
height="49px"
id="Layer_1"
version="1.1"
viewBox="0 0 49 49"
width="49px"
xml:space="preserve"
sodipodi:docname="bell.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06"><metadata
id="metadata15"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
id="defs13" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1015"
id="namedview11"
showgrid="false"
inkscape:zoom="13.622629"
inkscape:cx="18.4695"
inkscape:cy="26.961408"
inkscape:window-x="0"
inkscape:window-y="29"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" /><path
style="fill:#231f20"
d="m 27.025617,2.0000004 c -2.518,0 -4.581688,1.8680156 -4.929688,4.2910156 C 15.214929,7.653016 10.025627,13.719 10.025627,21 V 32 H 9.0256266 c -2.209,0 -4.0000002,1.791 -4.0000002,4 0,2.209 1.7910002,4 4.0000002,4 H 45.025617 c 2.209,0 4,-1.791 4,-4 0,-2.209 -1.791,-4 -4,-4 h -1 V 21 c 0,-7.281 -5.188312,-13.346984 -12.070312,-14.708984 -0.348,-2.423 -2.411688,-4.2910156 -4.929688,-4.2910156 z M 22.025617,42 c 0,2.762 2.239,5 5,5 2.762,0 5,-2.238 5,-5 z"
id="fill-edit"
inkscape:connector-curvature="0" /></svg>

Before

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
enable-background="new 0 0 500 500"
height="500px"
id="Layer_1"
version="1.1"
viewBox="0 0 500 500"
width="500px"
xml:space="preserve"
sodipodi:docname="pin-disabled.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06"><metadata
id="metadata9"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs7" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1015"
id="namedview5"
showgrid="false"
inkscape:zoom="0.6675088"
inkscape:cx="186.10652"
inkscape:cy="69.51775"
inkscape:window-x="0"
inkscape:window-y="29"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1"
inkscape:snap-page="true" /><path
style="clip-rule:evenodd;fill:#010101;fill-rule:evenodd"
d="M 463.1543 1 L 349.9375 114.2168 L 349.9375 77.375 L 363.56836 77.375 C 376.10336 77.375 386.2832 67.198109 386.2832 54.662109 C 386.2832 42.126109 376.10336 31.949219 363.56836 31.949219 L 136.43164 31.949219 C 123.89564 31.949219 113.71875 42.126109 113.71875 54.662109 C 113.71875 67.199109 123.89564 77.375 136.43164 77.375 L 150.06055 77.375 L 150.06055 232.73828 L 82.828125 300.60742 C 79.465125 303.87442 77.376953 308.50466 77.376953 313.59766 C 77.376953 323.58866 85.459234 331.77148 95.365234 331.77148 L 132.38281 331.77148 L 1 463.1543 L 36.845703 499 L 499 36.845703 L 463.1543 1 z M 213.6582 77.375 C 223.6532 77.375 231.83008 85.552828 231.83008 95.548828 L 231.83008 213.65625 C 231.83008 223.65225 223.6542 231.82812 213.6582 231.82812 C 203.6642 231.82812 195.48633 223.65225 195.48633 213.65625 L 195.48633 95.548828 C 195.48633 85.552828 203.6642 77.375 213.6582 77.375 z M 352.55469 235.29102 L 222.74414 365.10156 L 222.74414 445.33984 C 222.74414 457.87584 232.92103 468.05078 245.45703 468.05078 C 257.99403 468.05078 268.17188 457.87584 268.17188 445.33984 L 268.17188 331.77148 L 404.63281 331.77148 C 414.53181 331.77148 422.62305 323.58866 422.62305 313.59766 C 422.62305 308.60466 420.61847 304.06211 417.35547 300.78711 L 352.55469 235.29102 z "
id="fill-edit" /></svg>

Before

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
enable-background="new 0 0 500 500"
height="500px"
id="Layer_1"
version="1.1"
viewBox="0 0 500 500"
width="500px"
xml:space="preserve"
sodipodi:docname="pin.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06"><metadata
id="metadata9"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs7" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1015"
id="namedview5"
showgrid="false"
inkscape:zoom="0.6675088"
inkscape:cx="186.10652"
inkscape:cy="69.51775"
inkscape:window-x="0"
inkscape:window-y="29"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1"
inkscape:snap-page="true" /><path
d="m 150.061,232.739 -67.232,67.868 c -3.363,3.267 -5.453,7.898 -5.453,12.991 0,9.991 8.083,18.173 17.989,18.173 H 222.744 V 445.34 c 0,12.536 10.177,22.711 22.713,22.711 12.537,0 22.715,-10.175 22.715,-22.711 V 331.771 h 136.46 c 9.899,0 17.992,-8.182 17.992,-18.173 0,-4.993 -2.006,-9.536 -5.269,-12.811 L 349.938,232.644 V 77.375 h 13.631 c 12.535,0 22.715,-10.177 22.715,-22.713 0,-12.536 -10.18,-22.713 -22.715,-22.713 H 136.432 c -12.536,0 -22.713,10.177 -22.713,22.713 0,12.537 10.177,22.713 22.713,22.713 h 13.629 V 232.739 Z M 231.83,95.548 v 118.109 c 0,9.996 -8.176,18.172 -18.172,18.172 -9.994,0 -18.171,-8.176 -18.171,-18.172 V 95.548 c 0,-9.996 8.177,-18.173 18.171,-18.173 9.995,0 18.172,8.177 18.172,18.173 z"
id="fill-edit"
inkscape:connector-curvature="0"
style="clip-rule:evenodd;fill:#010101;fill-rule:evenodd" /></svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -1,61 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="32"
viewBox="0 0 32 32"
width="32"
version="1.1"
id="svg6"
sodipodi:docname="switch.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06">
<metadata
id="metadata12">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1022"
id="namedview8"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="4.9166667"
inkscape:cx="24"
inkscape:cy="29.898306"
inkscape:window-x="0"
inkscape:window-y="29"
inkscape:window-maximized="1"
inkscape:current-layer="svg6" />
<path
d="M 23.384615,24.615384 V 18.461538 H 8.615385 v 6.153846 L 0,15.999999 8.615385,7.3846151 v 6.1538459 h 14.76923 V 7.3846151 L 32,15.999999 Z"
id="fill-edit"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccccc"
style="stroke-width:1.23076928" />
</svg>

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
enable-background="new 0 0 24 24"
height="24px"
id="Layer_1"
version="1.1"
viewBox="0 0 24 24"
width="24px"
xml:space="preserve"
sodipodi:docname="time.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06"><metadata
id="metadata13"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
id="defs11" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1015"
id="namedview9"
showgrid="false"
inkscape:zoom="9.8333333"
inkscape:cx="12"
inkscape:cy="12"
inkscape:window-x="0"
inkscape:window-y="29"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" /><path
d="m 12,2.0344069 c -5.5018378,0 -9.9631017,4.4620943 -9.9631017,9.9655931 0,5.503499 4.4612639,9.965593 9.9631017,9.965593 5.502668,0 9.963102,-4.462094 9.963102,-9.965593 0,-5.5034988 -4.460434,-9.9655931 -9.963102,-9.9655931 z m 3.664016,13.8762581 -0.290663,0.290663 c -0.241665,0.241666 -0.649424,0.253292 -0.903547,0.02408 l -3.753707,-3.28449 C 10.460316,12.71254 10.266817,12.244987 10.283427,11.902835 l 0.347965,-5.9245446 c 0.01827,-0.3429825 0.313086,-0.6220191 0.656068,-0.6220191 h 0.40942 c 0.342982,0 0.636967,0.2790366 0.653577,0.6211886 l 0.28485,4.9279861 c 0.01744,0.342982 0.217582,0.830466 0.444299,1.08708 l 2.610985,3.012931 c 0.226718,0.256614 0.215921,0.663542 -0.02657,0.905208 z"
id="fill-edit"
inkscape:connector-curvature="0"
style="clip-rule:evenodd;fill-rule:evenodd;stroke-width:0.83046609" /></svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="1792"
viewBox="0 0 1792 1792"
width="1792"
version="1.1"
id="svg4"
sodipodi:docname="warning_radio.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06">
<metadata
id="metadata10">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1015"
id="namedview6"
showgrid="false"
inkscape:zoom="0.13169643"
inkscape:cx="896"
inkscape:cy="896"
inkscape:window-x="0"
inkscape:window-y="29"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" />
<path
d="m 1024,1375 v -190 q 0,-14 -9.5,-23.5 Q 1005,1152 992,1152 H 800 q -13,0 -22.5,9.5 -9.5,9.5 -9.5,23.5 v 190 q 0,14 9.5,23.5 9.5,9.5 22.5,9.5 h 192 q 13,0 22.5,-9.5 9.5,-9.5 9.5,-23.5 z m -2,-374 18,-459 q 0,-12 -10,-19 -13,-11 -24,-11 H 786 q -11,0 -24,11 -10,7 -10,21 l 17,457 q 0,10 10,16.5 10,6.5 24,6.5 h 185 q 14,0 23.5,-6.5 9.5,-6.5 10.5,-16.5 z m -14,-934 768,1408 q 35,63 -2,126 -17,29 -46.5,46 -29.5,17 -63.5,17 H 128 Q 94,1664 64.5,1647 35,1630 18,1601 -19,1538 16,1475 L 784,67 q 17,-31 47,-49 30,-18 65,-18 35,0 65,18 30,18 47,49 z"
id="fill-edit"
inkscape:connector-curvature="0" />
</svg>

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -8,18 +8,16 @@
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
enable-background="new 0 0 24 24"
height="24px"
id="Layer_1"
version="1.1"
version="1.0"
viewBox="0 0 24 24"
width="24px"
xml:space="preserve"
sodipodi:docname="plus.svg"
sodipodi:docname="warning_radio.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06"><metadata
id="metadata9"><rdf:RDF><cc:Work
id="metadata13"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs7" /><sodipodi:namedview
id="defs11" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
@ -30,7 +28,7 @@
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1015"
id="namedview5"
id="namedview9"
showgrid="false"
inkscape:zoom="9.8333333"
inkscape:cx="12"
@ -39,7 +37,6 @@
inkscape:window-y="29"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" /><path
d="m 23.008475,14.610169 h -8.5 v 8.5 c 0,0.276 -0.224,0.5 -0.5,0.5 h -4 c -0.2760004,0 -0.5000004,-0.224 -0.5000004,-0.5 v -8.5 h -8.5 c -0.27600002,0 -0.50000002,-0.224 -0.50000002,-0.5 v -4 c 0,-0.2759995 0.224,-0.4999995 0.50000002,-0.4999995 h 8.5 v -8.5 c 0,-0.27600001 0.224,-0.50000001 0.5000004,-0.50000001 h 4 c 0.276,0 0.5,0.224 0.5,0.50000001 v 8.5 h 8.5 c 0.276,0 0.5,0.224 0.5,0.4999995 v 4 c 0,0.276 -0.224,0.5 -0.5,0.5 z"
d="M 12,2 C 6.5,2 2,6.5 2,12 2,17.5 6.5,22 12,22 17.5,22 22,17.5 22,12 22,6.5 17.5,2 12,2 Z m 0,2 c 4.4,0 8,3.6 8,8 0,4.4 -3.6,8 -8,8 C 7.6,20 4,16.4 4,12 4,7.6 7.6,4 12,4 Z m -1,3 v 6 h 2 V 7 Z m 0,8 v 2 h 2 v -2 z"
id="fill-edit"
inkscape:connector-curvature="0"
style="clip-rule:evenodd;fill-rule:evenodd" /></svg>
inkscape:connector-curvature="0" /></svg>

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -39,7 +39,6 @@
<p>Prenez la fusée pour retourner à l'accueil en un clic</p>
</div>
</body>
</html>

View File

@ -3,33 +3,46 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=.6">
<meta name="viewport" content="width=device-width, initial-scale=0.4">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Espace enseignant</title>
<title>Gestion des enseignants</title>
<!-- Icon -->
<link rel='shortcut icon' href='/favicon.ico'>
<!-- Icon -->
<link rel='shortcut icon' href='/favicon.ico'>
<!-- CSS dependencies -->
<link href="https://fonts.googleapis.com/css?family=Fira+Sans" rel="stylesheet">
<link rel='stylesheet' type='text/css' href='/css/layout.css'>
<!-- CSS dependencies -->
<link href="https://fonts.googleapis.com/css?family=Fira+Sans" rel="stylesheet">
<link rel='stylesheet' type='text/css' href='/css/font-loader.css'>
<link rel='stylesheet' type='text/css' href='/css/global.css'>
<link rel='stylesheet' type='text/css' href='/css/pop-up.css'>
<link rel='stylesheet' type='text/css' href='/css/layout.css'>
<link rel='stylesheet' type='text/css' href='/css/menu.css'>
<link rel='stylesheet' type='text/css' href='/css/header.css'>
<link rel='stylesheet' type='text/css' href='/css/container.css'>
<!-- JS dependencies -->
<script type='text/javascript' src='/js/_SERVER.js'></script>
</head>
<body>
<div id="WRAPPER" class='login'>
<div id='main-vue'></div>
<div id='LOGIN_REDIRECT'>
<div class='icon'></div>
<div class='title'><b>P</b><i>lateforme</i> <b>A</b><i>ssistée de</i> <b>T</b><i>raitement</i> <b>A</b><i>dministratif des</i> <b>T</b><i>aches d'</i><b>E</b><i>nseignement</i></div>
<a href="/api/v/1.0/professor/pdf/<?php echo $_SESSION['CAS']["id"]; ?>"><button style='font-weight: normal; margin-bottom: 1em;'>Télécharger ma fiche</button></a>
<a href="/fiche/logout"><button style='font-weight: normal'>Me déconnecter</button></a>
<!-- POPUP WINDOW -->
<div id='POPUP'>
<div class='header'></div>
<div class='body'></div>
<div class='footer'></div>
</div>
<div id='POPUP-BG'></div>
</div>
<!-- Main loop -->
<script type='text/javascript' src='/js/bundle@fiche.js'></script>
</body>
</html>

View File

@ -3,31 +3,30 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=.6">
<meta name="viewport" content="width=device-width, initial-scale=0.4">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Connexion</title>
<title>PTUT web title</title>
<!-- Icon -->
<link rel='shortcut icon' href='/favicon.ico'>
<!-- Icon -->
<link rel='shortcut icon' href='/favicon.ico'>
<!-- CSS dependencies -->
<link href="https://fonts.googleapis.com/css?family=Fira+Sans" rel="stylesheet">
<link rel='stylesheet' type='text/css' href='/css/font-loader.css'>
<link rel='stylesheet' type='text/css' href='/css/global.css'>
<link rel='stylesheet' type='text/css' href='/css/pop-up.css'>
<link rel='stylesheet' type='text/css' href='/css/layout.css'>
<link rel='stylesheet' type='text/css' href='/css/menu.css'>
<link rel='stylesheet' type='text/css' href='/css/header.css'>
<link rel='stylesheet' type='text/css' href='/css/container.css'>
<link rel='stylesheet' type='text/css' href='/css/container/svg.css'>
<!-- CSS dependencies -->
<link href="https://fonts.googleapis.com/css?family=Fira+Sans" rel="stylesheet">
<link rel='stylesheet' type='text/css' href='/css/font-loader.css'>
<link rel='stylesheet' type='text/css' href='/css/global.css'>
<link rel='stylesheet' type='text/css' href='/css/pop-up.css'>
<link rel='stylesheet' type='text/css' href='/css/layout.css'>
<link rel='stylesheet' type='text/css' href='/css/menu.css'>
<link rel='stylesheet' type='text/css' href='/css/header.css'>
<link rel='stylesheet' type='text/css' href='/css/container.css'>
<!-- JS dependencies -->
<script type='text/javascript' src='/js/_SERVER.js'></script>
<!-- JS dependencies -->
<script type='text/javascript' src='/js/_SERVER.js'></script>
</head>
<body class='loading'>
<body>
<div id='main-vue'></div>
@ -44,7 +43,6 @@
<!-- Main loop -->
<script type='text/javascript' src='/js/bundle@home.js' onload="document.body.className=''"></script>
<script type='text/javascript' src='/js/bundle@home.js'></script>
</body>
</html>

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=.6">
<meta name="viewport" content="width=device-width, initial-scale=0.4">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
@ -24,7 +24,7 @@
<script type='text/javascript' src='/js/_SERVER.js'></script>
</head>
<body class='loading'>
<body>
<div id='main-vue'></div>
@ -41,6 +41,6 @@
<!-- Main loop -->
<script type='text/javascript' src='/js/bundle@login.js' onload="document.body.className=''"></script>
<script type='text/javascript' src='/js/bundle@login.js'></script>
</body>
</html>

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=.6">
<meta name="viewport" content="width=device-width, initial-scale=0.4">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
@ -26,7 +26,7 @@
<script type='text/javascript' src='/js/_SERVER.js'></script>
</head>
<body class='loading'>
<body>
<div id='main-vue'></div>
@ -43,6 +43,6 @@
<!-- Main loop -->
<script type='text/javascript' src='/js/bundle@settings.js' onload="document.body.className=''"></script>
<script type='text/javascript' src='/js/bundle@settings.js'></script>
</body>
</html>

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=.6">
<meta name="viewport" content="width=device-width, initial-scale=0.4">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
@ -26,7 +26,7 @@
<script type='text/javascript' src='/js/_SERVER.js'></script>
</head>
<body class='loading'>
<body>
<div id='main-vue'></div>
@ -43,6 +43,6 @@
<!-- Main loop -->
<script type='text/javascript' src='/js/bundle@teacher.js' onload="document.body.className=''"></script>
<script type='text/javascript' src='/js/bundle@teacher.js'></script>
</body>
</html>

View File

@ -3,11 +3,11 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=.6">
<meta name="viewport" content="width=device-width, initial-scale=0.4">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Gestion des UEs</title>
<title>Gestion des enseignants</title>
<!-- Icon -->
<link rel='shortcut icon' href='/favicon.ico'>
@ -26,7 +26,7 @@
<script type='text/javascript' src='/js/_SERVER.js'></script>
</head>
<body class='loading'>
<body>
<div id='main-vue'></div>
@ -43,6 +43,6 @@
<!-- Main loop -->
<script type='text/javascript' src='/js/bundle@ue.js' onload="document.body.className=''"></script>
<script type='text/javascript' src='/js/bundle@ue.js'></script>
</body>
</html>

View File

@ -72,6 +72,18 @@ module.exports = [ {
module: mod_common,
devtool: (process.env.NODE_ENV==='development') ? '#eval-source-map' : false
}, {
name: "fiche",
entry: './webpack/page/fiche.js',
output: {
path: path.resolve(__dirname, './public_html/js/bundle'),
publicPath: '/js/bundle/',
filename: 'fiche@0.js'
},
module: mod_common,
devtool: (process.env.NODE_ENV==='development') ? '#eval-source-map' : false
}, {
name: "settings",

View File

@ -1,43 +1,6 @@
<template>
<div id='CONTAINER' class='list'>
<svg xmlns="http://www.w3.org/2000/svg" :viewBox="gstore.viewBox">
<template v-if="gstore.dimensions">
<path
:d="'m ' + (gstore.dimensions.padding + gstore.dimensions.text.size) + ',' + (gstore.dimensions.padding) + ' ' +
'0,' + (gstore.dimensions.axis.height + gstore.dimensions.padding) + ' ' +
(gstore.dimensions.axis.width) + ',0'"></path>
<text
class="precision"
:x="gstore.dimensions.padding + gstore.dimensions.text.size"
:y="gstore.dimensions.text.alignV + gstore.dimensions.axis.height + gstore.dimensions.padding">0</text>
<template v-for="i in gstore.dimensions.axis.precision">
<path
class="precision"
:d="'m ' + (gstore.dimensions.padding + gstore.dimensions.text.size + (i*gstore.dimensions.axis.width/gstore.dimensions.axis.precision)) + ',' + (gstore.dimensions.padding) + ' ' +
'0,' + (gstore.dimensions.axis.height+gstore.dimensions.padding) + ' '"></path>
<text
class="precision"
:x="gstore.dimensions.padding + gstore.dimensions.text.size + (i*gstore.dimensions.axis.width/gstore.dimensions.axis.precision)"
:y="gstore.dimensions.text.alignV + gstore.dimensions.axis.height + gstore.dimensions.padding">{{ i*gstore.maxValue/gstore.dimensions.axis.precision }}</text>
</template>
<template v-for="(value, key, i) in gstore.stats">
<text
:x="gstore.dimensions.text.size + gstore.dimensions.padding - gstore.dimensions.text.alignH"
:y="i*(gstore.dimensions.bin.width + gstore.dimensions.bin.spacing) + gstore.dimensions.padding + gstore.dimensions.text.alignV"
>{{ key }}</text>
<rect
:class="gstore.colors[i] + ' hiding'"
:x="gstore.dimensions.text.size + gstore.dimensions.padding + 1"
:y="i*(gstore.dimensions.bin.width+gstore.dimensions.bin.spacing) + gstore.dimensions.padding"
:height="gstore.dimensions.bin.width"
:width="gstore.dimensions.bin.margin + (gstore.dimensions.axis.width * value)/gstore.maxValue"
:data-info="value">
<title>{{ (gstore.titles && gstore.titles[key]) ? value + ' ' + gstore.titles[key] : value }}</title>
</rect>
</template>
</template>
</svg>
<section>bla</section>
<section>bla</section>
@ -67,17 +30,7 @@
export default {
name: 'CONTAINER_PAGE1',
data(){
return {
gstore: gstore.get
}
}
}
window.onload = function() {
let allRect = document.getElementsByTagName('rect');
for (let rect of allRect) {
rect.classList.remove('hiding');
return { gstore: gstore.get }
}
}

View File

@ -4,12 +4,12 @@
<div class='card filter'>
<div v-for='(filter_grp, gname) in gstore.filters' :title='gname' data-unblur-filter>
<div v-for='(filter_grp, gname) in gstore.filters' :title='gname'>
<div class='fold-toggle' :data-show='gstore.filters[gname][0].visible?1:0' @click='gstore.show_fgroup(gname)' :data-count='gstore.filters[gname][0].active.length' data-unblur-filter>{{ gname }}</div>
<div class='fold-toggle' :data-show='gstore.filters[gname][0].visible?1:0' @click='gstore.show_fgroup(gname)' :data-count='gstore.filters[gname][0].active.length'>{{ gname }}</div>
<div class='fold' data-unblur-filter>
<span v-for='(data, i) in filter_grp' v-if='i > 0' :class="data.active == true ? 'active' : ''" @click='gstore.toggle_filter(gname, i); gstore.filter_handler(gname);' :title='data.code' data-unblur-filter>{{ data.name }}</span>
<div class='fold'>
<span v-for='(data, i) in filter_grp' v-if='i > 0' :class="data.active == true ? 'active' : ''" @click='gstore.toggle_filter(gname, i); gstore.filter_handler(gname);' :title='data.code'>{{ data.name }}</span>
</div>
</div>
@ -19,7 +19,7 @@
<div class='card container'>
<input class='card instant-search neutral' type='text' @keyup='gstore.is_handler($event)' placeholder='Recherche instantannée' id='teacher_view_instant_search'>
<button class='card toggle valid' :data-active='gstore.create_card?1:0' @click='gstore.create_card=!gstore.create_card' title='Créer un enseignant'>+</button>
<button class='card toggle valid' :data-active='gstore.create_card?1:0' @click='gstore.create_card=!gstore.create_card'>+</button>
<section class='valid' data-create='' v-show='gstore.create_card'>
@ -33,10 +33,6 @@
</h1>
<div class='table'>
<div title='équivalents TD'>
<span>0</span>
<span>HETD</span>
</div>
<div>
<span><input type='text' placeholder='???' v-model='gstore.create_h'></span>
<span>heures à faire</span>
@ -47,11 +43,10 @@
<div class='footer'>
<button class='valid' @click='gstore.ic_handler()'>Créer l'enseignant</button>
<button class='neutral' @click='gstore.ic_reset(); gstore.create_card=false'>Annuler</button>
</div>
</section>
<section v-if='gstore.professors.length <= 0' data-anim='0'>Aucun enseignant trouvé</section>
<section v-if='gstore.professors.length <= 0'>Aucun enseignant trouvé</section>
<section v-for='(prof, pi) in gstore.professors'
:class="gstore.edit_i==pi ? 'search' : ''"
@ -63,9 +58,9 @@
<!-- if VIEW MODE -->
<div class='goo-menu' v-show='gstore.edit_i!=pi'>
<div class='admin' :data-admin='prof.idProfesseur' :data-active='prof.admin?1:0' title='Admin' @click="gstore.ia_handler(pi)"></div>
<div class='remove' :data-remove='prof.idProfesseur' title='Supprimer' @click="gstore.ir_handler(prof.idProfesseur)"></div>
<div class='edit' :data-edit='prof.idProfesseur' title='Modifier' @click="gstore.ie_toggle(pi)"></div>
<div class='admin' :data-admin='prof.idProfesseur' :data-active='prof.admin?1:0' @click="gstore.ia_handler(pi)"></div>
<div class='remove' :data-remove='prof.idProfesseur' @click="gstore.ir_handler($event.currentTarget.getAttribute('data-remove'))"></div>
<div class='edit' :data-edit='prof.idProfesseur' @click="gstore.ie_toggle(pi)"></div>
</div>
<!-- if VIEW MODE -->
@ -78,7 +73,7 @@
<!-- endif -->
<!-- if VIEW MODE -->
<h1 v-show='gstore.edit_i!=pi' :class="prof.hoursToDo > prof.equiTD ? 'warning' : ''" :title="prof.hoursToDo > prof.equiTD ? 'Attention: heures manquantes' : ''">{{ prof.firstName }} {{ prof.lastName }} <span :data-visible='prof.casLogin.length'>({{ prof.casLogin }})</span></h1>
<h1 v-show='gstore.edit_i!=pi' :class="prof.hoursToDo > prof.equiTD ? 'warning' : ''">{{ prof.firstName }} {{ prof.lastName }} <span :data-visible='prof.casLogin.length'>({{ prof.casLogin }})</span></h1>
<!-- if EDIT MODE -->
<h1 v-show='gstore.edit_i==pi' :class="prof.hoursToDo > prof.equiTD ? 'warning' : ''">
<input type='text' placeholder='Prénom Nom' v-model='gstore.edit_name'>
@ -88,47 +83,38 @@
<div class='table'>
<div title='équivalents TD'>
<span>{{ prof.equiTD }}</span>
<span>HETD</span>
</div>
<!-- if EDIT MODE -->
<div v-show='gstore.edit_i==pi'>
<span><input type='text' placeholder='???' v-model='gstore.edit_h'></span>
<div>
<!-- if VIEW MODE -->
<span v-show='gstore.edit_i!=pi'>{{prof.hoursToDo}}</span>
<!-- if EDIT MODE -->
<span v-show='gstore.edit_i==pi'><input type='text' placeholder='???' v-model='gstore.edit_h'></span>
<!-- endif -->
<span>heures à faire</span>
</div>
<!-- endif -->
<div title='heures de décalage' v-show='gstore.edit_i!=pi'>
<span :data-error='prof.equiTD < prof.hoursToDo?1:0' :data-success='prof.equiTD < prof.hoursToDo?0:1'>{{ Math.floor( (prof.equiTD < prof.hoursToDo ? prof.hoursToDo-prof.equiTD : prof.equiTD-prof.hoursToDo)*100 )/100 }}</span>
<span>{{ prof.equiTD < prof.hoursToDo ? 'sous-service' : 'sur-service' }}</span>
<div>
<span>{{ prof.equiTD }}</span>
<span>heures prévues</span>
</div>
</div>
<!-- if VIEW MODE -->
<div v-show='gstore.edit_i!=pi' class='pdfdl' title='Télécharger la fiche' @click='gstore.id_handler(prof.idProfesseur)'>fiche</div>
<div v-show='gstore.edit_i!=pi' class='sub'><strong>{{ prof.VHCours + prof.VHTd + prof.VHTp }}h</strong> physiques prévues</div>
<!-- if EDIT MODE -->
<div v-show='gstore.edit_i==pi' :class="gstore.edit_err.length > 0 ? 'sub warning' : 'sub'" :data-valid='gstore.edit_err_valid?1:0'>{{ gstore.edit_err }}</div>
<!-- endif -->
<div class='footer'>
<!-- if VIEW MODE -->
<span v-show='gstore.edit_i!=pi' :class="(prof.VHCours == 0) ? 'course' : 'course active'">{{ prof.VHCours }}h <span>CM</span></span>
<span v-show='gstore.edit_i!=pi' :class="(prof.VHCours == 0) ? 'course' : 'course active'">{{ prof.VHCours }}h <span>Cours</span></span>
<hr v-show='gstore.edit_i!=pi'>
<span v-show='gstore.edit_i!=pi' :class="(prof.VHTd == 0) ? 'td' : 'td active'" >{{ prof.VHTd }}h <span>TD</span></span>
<span v-show='gstore.edit_i!=pi' :class="(prof.VHTd == 0) ? 'td' : 'td active'">{{ prof.VHTd }}h <span>TD</span></span>
<hr v-show='gstore.edit_i!=pi'>
<span v-show='gstore.edit_i!=pi' :class="(prof.VHTp == 0) ? 'tp' : 'tp active'" >{{ prof.VHTp }}h <span>TP</span></span>
<span v-show='gstore.edit_i!=pi' :class="(prof.VHTp == 0) ? 'tp' : 'tp active'">{{ prof.VHTp }}h <span>TP</span></span>
<!-- if EDIT MODE -->
<button v-show='gstore.edit_i==pi' class='search' @click='gstore.ie_handler(pi)'>Modifier l'enseignant</button>
<button v-show='gstore.edit_i==pi' class='grey' @click='gstore.ie_toggle(-1)'>Annuler</button>
<!-- endif -->
</div>
<div class='info'>
<strong>{{ prof.hoursToDo }}h</strong> à faire, <strong>{{ prof.VHCours + prof.VHTd + prof.VHTp }}h</strong> présentielles
</div>
</section>
</div>
@ -147,22 +133,7 @@
name: 'CONTAINER_VIEW',
data(){
return { gstore: gstore.get }
},
beforeMount(){
// set onblur to hide filter
window.onblur.link('teacher.filter', (e) => {
// ignore [data-unblur-filter] elements
if( e.target.getAttribute('data-unblur-filter') !== null )
return;
// else: hide
gstore.get.show_fgroup(-1);
});
}
}
</script>
</script>

View File

@ -1,195 +0,0 @@
<template>
<div id='CONTAINER' class='list'>
<div class='list container' data-anim-incoming='1' :data-anim-bounce='gstore.nav_anim.out?1:0'>
<section class='filter'>
<button class='back reflow search' @click='$router.back()'>Retour</button>
</section>
<!-- FILTERS -->
<section class='filter'>
<div style='flex-basis: 3.2em'></div>
<div :data-filter='gstore.order.current===0?1:0' @click='gstore.order_toggle(0)'>enseignant <span class='arrow' :data-way='gstore.order.way'></span></div>
<div :data-filter='gstore.order.current===1?1:0' @click='gstore.order_toggle(1)'>volume horaire <span class='arrow' :data-way='gstore.order.way'></span></div>
<div :data-filter='gstore.order.current===2?1:0' @click='gstore.order_toggle(2)'>formations <span class='arrow' :data-way='gstore.order.way'></span></div>
</section>
<!-- CREATE -->
<section class='create'
data-anim-incoming='1'
:data-anim-bounce='gstore.nav_anim.out?1:0'>
<div class='icon' @click='gstore.ccreate()'></div>
<select v-model='gstore.ccrea.prof'>
<option value='-1'>Aucun enseignant affecté</option>
<option v-for='p in gstore.manage.prof' :value='p.idProfesseur'>{{ `${p.firstName} ${p.lastName}` }}</option>
</select>
<select v-model='gstore.ccrea.type' class='min'>
<option value='-' disabled>Type</option>
<option value='0'>CM</option>
<option value='1'>TD</option>
<option value='2'>TP</option>
</select>
<input type='text' placeholder='volume' v-model='gstore.ccrea.vol'>
<div style='margin-left: 1em;' :class="gstore.ccrea.err.length > 0 ? (gstore.ccrea.valid ? 'warning valid' : 'warning invalid') : ''" :data-valid='gstore.ccrea.valid?1:0'>{{ gstore.ccrea.err }}</div>
</section>
<section class='filter'></section>
<!-- COURS -->
<section class='bcours'
v-for='(c,i) in gstore.manage.cours'
:data-id='c.idCours'
data-anim-incoming='1'
:data-anim-bounce='gstore.nav_anim.out?1:0'
:data-prof='c.idProf'
:data-vol='c.volume'
:data-form='c.formations.join(`|`)'>
<div class='icon remove' @click='gstore.rem(0, i)'></div>
<select v-model='c.new_prof' @change='gstore.upd_prof(0, i)'>
<option value='-1' v-show='c.idProf!=-1'>Aucun enseignant affecté</option>
<option v-for='p in gstore.manage.prof' :value='p.idProfesseur' v-show='p.idProfesseur!=c.idProf'>{{ `${p.firstName} ${p.lastName}` }}</option>
</select>
<div class='cm reflow active'>{{ c.volume }}</div>
<div class='taglist'>
<div v-for='f in c.formations' data-action>
<span class='tag'>{{ gstore.form_by_id(f).labelForm || '???' }}</span>
<span data-remove @click='gstore.rem_form(0, i, f)'></span>
</div>
<div data-action>
<select class='tag' v-model='gstore.manage.cours[i].add_form'>
<option value='-' selected disabled>Ajouter</option>
<option
v-for='f in gstore.formations'
v-show='c.formations.indexOf(f.idForm) < 0'
:value='f.idForm'>{{ f.labelForm }}</option>
</select>
<span class='pointer' data-create @click='gstore.add_form(0, i)'></span>
</div>
</div>
</section>
<!-- TD -->
<section class='btd'
v-for='(td,i) in gstore.manage.td'
:data-id='td.idTD'
data-anim-incoming='1'
:data-anim-bounce='gstore.nav_anim.out?1:0'
:data-prof='td.idProf'
:data-vol='td.volume'
:data-form='td.formations.join(`|`)'>
<div class='icon remove' @click='gstore.rem(1, i)'></div>
<select v-model='td.new_prof' @change='gstore.upd_prof(1, i)'>
<option value='-1' v-show='td.idProf!=-1'>Aucun enseignant affecté</option>
<option v-for='p in gstore.manage.prof' :value='p.idProfesseur' v-show='p.idProfesseur!=td.idProf'>{{ `${p.firstName} ${p.lastName}` }}</option>
</select>
<div class='td reflow active'>{{ td.volume }}</div>
<div class='taglist'>
<div v-for='f in td.formations' data-action>
<span class='tag'>{{ gstore.form_by_id(f).labelForm || '???' }}</span>
<span data-remove @click='gstore.rem_form(1, i, f)'></span>
</div>
<div data-action>
<select class='tag'v-model='gstore.manage.td[i].add_form'>
<option value='-' selected disabled>Ajouter</option>
<option
v-for='f in gstore.formations'
v-show='td.formations.indexOf(f.idForm) < 0'
:value='f.idForm'>{{ f.labelForm }}</option>
</select>
<span class='pointer' data-create @click='gstore.add_form(1, i)'></span>
</div>
</div>
</section>
<!-- TP -->
<section class='btp'
v-for='(tp,i) in gstore.manage.tp'
:data-id='tp.idTP'
data-anim-incoming='1'
:data-anim-bounce='gstore.nav_anim.out?1:0'
:data-prof='tp.idProf'
:data-vol='tp.volume'
:data-form='tp.formations.join(`|`)'>
<div class='icon remove' @click='gstore.rem(2, i)'></div>
<select v-model='tp.new_prof' @change='gstore.upd_prof(2, i)'>
<option value='-1' v-show='tp.idProf!=-1'>Aucun enseignant affecté</option>
<option v-for='p in gstore.manage.prof' :value='p.idProfesseur' v-show='p.idProfesseur!=tp.idProf'>{{ `${p.firstName} ${p.lastName}` }}</option>
</select>
<div class='tp reflow active'>{{ tp.volume }}</div>
<div class='taglist'>
<div v-for='f in tp.formations' data-action>
<span class='tag'>{{ gstore.form_by_id(f).labelForm || '???' }}</span>
<span data-remove @click='gstore.rem_form(2, i, f)'></span>
</div>
<div data-action>
<select class='tag' v-model='gstore.manage.tp[i].add_form'>
<option value='-' selected disabled>Ajouter</option>
<option
v-for='f in gstore.formations'
v-show='tp.formations.indexOf(f.idForm) < 0'
:value='f.idForm'>{{ f.labelForm }}</option>
</select>
<span class='pointer' data-create @click='gstore.add_form(2, i)'></span>
</div>
</div>
</section>
</div>
</div>
</template>
<script>
export default {
name: 'CONTAINER_VIEW',
data(){
return { gstore: gstore.get }
},
beforeMount(){
/* (1) Try to load data */
gstore.get.load_ue_groups(this.$route.params.code, 3).catch( (err) => { // try at max 3 times (200ms each) for UE to be loaded
/* (2) On error -> go to 'view' page */
gstore.get.router.push('/ue/view/');
});
}
}
</script>

View File

@ -1,154 +1,38 @@
<template>
<div id='CONTAINER' class='card'>
<div id='CONTAINER' class='card' style="top: 0; height: 100%">
<div class='card filter'>
<div class="card container" style="width: 100%">
<section v-if='gstore.ues.length <= 0'>Aucun enseignant trouvé</section>
<div v-for='(filter_grp, gname) in gstore.filters' :title='gname' data-unblur-filter>
<section v-for='ue in gstore.ues' :data-id='ue.code'>
<span class='category'>{{ ue.code }}</span>
<h1>{{ ue.label }}</h1>
<div class='fold-toggle' :data-show='gstore.filters[gname][0].visible?1:0' @click='gstore.show_fgroup(gname)' :data-count='gstore.filters[gname][0].active.length' data-unblur-filter>{{ gname }}</div>
<div class='table'>
<div>
<span>{{ue.volumeCours}}</span>
<span>heures de cours</span>
</div>
<div>
<span>{{ue.volumeTD}}</span>
<span>heures de TD</span>
</div>
<div>
<span>{{ue.volumeTP}}</span>
<span>heures de TP</span>
</div>
</div>
<div class='fold' data-unblur-filter>
<span v-for='(data, i) in filter_grp' v-if='i > 0' :class="data.active == true ? 'active' : ''" @click='gstore.toggle_filter(gname, i); gstore.filter_handler(gname);' :title='data.code' data-unblur-filter>{{ data.name }}</span>
</div>
<div class='sub'><strong>ZOU</strong> équivalents TD</div>
</div>
</div>
<div class='card container' :data-anim-outgoing='gstore.nav_anim.in?1:0'>
<input data-anim='0' class='card instant-search neutral' type='text' @keyup='gstore.is_handler($event)' placeholder='Recherche instantannée' id='ue_view_instant_search'>
<button data-anim='0' class='card toggle valid' :data-active='gstore.create_card?1:0' @click='gstore.create_card=!gstore.create_card' title='Créer une UE'>+</button>
<section class='valid' data-create='' v-show='gstore.create_card'>
<select v-model='gstore.create_form' class='category'>
<option selected='selected' disabled='disabled' value='-'>Formation par défaut</option>
<option value='-1'>Aucune formation par défaut</option>
<option v-for='form in gstore.formations' :value='form.idForm'>{{ form.labelForm }}</option>
</select>
<h1 class='pin'>
<input type='text' placeholder='Libellé' v-model='gstore.create_label'>
<span data-visible='1'>(<input type='text' placeholder='code' v-model='gstore.create_code'>)</span>
</h1>
<div class='table little'>
<div>
<span class='notlast active reflow' data-error='0'>0 CM</span>
</div>
<div>
<span class='notlast active reflow' data-error='0'>0 TD</span>
</div>
<div>
<span class='notlast active reflow' data-error='0'>0 TP</span>
</div>
</div>
<div :class="gstore.create_err.length > 0 ? 'sub warning' : 'sub'" :data-valid='gstore.create_err_valid?1:0'>{{ gstore.create_err }}</div>
<div class='footer'>
<span class='course'><input type='text' placeholder='???' v-model='gstore.create_vol.c'><span>Cours</span></span>
<hr>
<span class='td'><input type='text' placeholder='???' v-model='gstore.create_vol.td'><span>TD</span></span>
<hr>
<span class='tp'><input type='text' placeholder='???' v-model='gstore.create_vol.tp'><span>TP</span></span>
</div>
<div class='footer'>
<button class='valid' @click='gstore.ic_handler()'>Créer l'UE</button>
<button class='neutral' @click='gstore.ic_reset(); gstore.create_card=false'>Annuler</button>
</div>
</section>
<section v-if='gstore.ues.length <= 0' data-anim='0'>Aucune UE trouvée</section>
<section v-for='(ue, pi) in gstore.ues'
:class="gstore.edit_i==pi ? 'search' : ''"
:data-id='ue.code'
:data-label='ue.label'>
<!-- if VIEW MODE -->
<div class='goo-menu' v-show='gstore.edit_i!=pi'>
<div class='enabled' :data-enabled='ue.code' :data-active='ue.disabled?0:1' title='UE activée' @click="gstore.ia_handler(pi)"></div>
<div class='required' :data-required='ue.code' :data-active='ue.required?1:0' title='UE obligatoire' @click="gstore.io_handler(pi)"></div>
<div class='remove' :data-remove='ue.code' title='Supprimer' @click="gstore.ir_handler(ue.code)"></div>
<div class='edit' :data-edit='ue.code' title='Modifier' @click="gstore.ie_toggle(pi)"></div>
</div>
<!-- if VIEW MODE -->
<span v-show='gstore.edit_i!=pi' class='category'>{{ ue.labelForm || 'Aucune formation par défaut' }}</span>
<!-- if EDIT MODE -->
<select v-show='gstore.edit_i==pi' v-model='gstore.edit_form' class='category'>
<option selected='selected' disabled='disabled' value='-'>Formation par défaut</option>
<option value='-1'>Aucune formation par défaut</option>
<option v-for='form in gstore.formations' :value='form.idForm'>{{ form.labelForm }}</option>
</select>
<!-- endif -->
<!-- if VIEW MODE -->
<h1 v-show='gstore.edit_i!=pi' :class='ue.required?`pin`:`pin disabled`' :title='ue.required?`obligatoire`:`optionnelle`'><span :data-strike='ue.disabled?1:0'>{{ ue.label }}</span><span :data-visible='1'>({{ ue.code }})</span></h1>
<!-- if EDIT MODE -->
<h1 v-show='gstore.edit_i==pi' :class='ue.required?`pin`:`pin disabled`'>
<input type='text' placeholder='Libellé' v-model='gstore.edit_label'>
<!-- <span :data-visible='1'>({{ ue.code }})</span> -->
<span data-visible='1'>(<input type='text' placeholder='code' v-model='gstore.edit_code'>)</span>
</h1>
<!-- endif -->
<div class='table little'>
<div>
<span class='active reflow' :data-error='ue.nbrCours>ue.nbrProfCours || ue.modCours > 0?1:0'>{{ ue.nbrCours }} CM</span>
<span v-show='ue.nbrCours>ue.nbrProfCours' class='notlast user-icon reflow nospace' :data-tooltip='`${ue.nbrCours-ue.nbrProfCours} enseignant(s) manquant(s)`'></span>
<span v-show='ue.modCours > 0' class='notlast time-icon reflow nospace' :data-tooltip='`${ue.volumeCours-ue.modCours} à ajouter | ${ue.modCours} à enlever`'></span>
</div>
<div>
<span class='active reflow' :data-error='ue.nbrTD>ue.nbrProfTD || ue.modTD > 0?1:0'>{{ ue.nbrTD }} TD</span>
<span v-show='ue.nbrTD>ue.nbrProfTD' class='notlast user-icon reflow nospace' :data-tooltip='`${ue.nbrCours-ue.nbrProfCours} enseignant(s) manquant(s)`'></span>
<span v-show='ue.modTD > 0' class='notlast time-icon reflow nospace' :data-tooltip='`${ue.volumeTD-ue.modTD} à ajouter | ${ue.modTD} à enlever`'></span>
</div>
<div>
<span class='active reflow' :data-error='ue.nbrTP>ue.nbrProfTP || ue.modTP > 0?1:0'>{{ ue.nbrTP }} TP</span>
<span v-show='ue.nbrTP>ue.nbrProfTP' class='notlast user-icon reflow nospace' :data-tooltip='`${ue.nbrCours-ue.nbrProfCours} enseignant(s) manquant(s)`'></span>
<span v-show='ue.modTP > 0' class='notlast time-icon reflow nospace' :data-tooltip='`${ue.volumeTP-ue.modTP} à ajouter | ${ue.modTP} à enlever`'></span>
</div>
</div>
<!-- if VIEW MODE -->
<div v-show='gstore.edit_i!=pi' class='taglist'>
<span v-if='ue.formations.length==0' class='tag invalid'>Aucune formation</span>
<span v-for='form_id in ue.formations' :class="!!gstore.form_by_id(form_id).isInternal ? 'tag search' : 'tag'">{{ gstore.form_by_id(form_id).labelForm || '???' }}</span>
</div>
<!-- if EDIT MODE -->
<div v-show='gstore.edit_i==pi' :class="gstore.edit_err.length > 0 ? 'sub warning' : 'sub'" :data-valid='gstore.edit_err_valid?1:0'>{{ gstore.edit_err }}</div>
<!-- endif -->
<!-- if VIEW MODE -->
<div class='footer' v-show='gstore.edit_i!=pi'>
<button class='neutral' @click='gstore.nav_in(pi)'>Configurer</button>
</div>
<!-- if EDIT MODE -->
<div class='footer' v-show='gstore.edit_i==pi'>
<button class='search' @click='gstore.ie_handler(pi)'>Modifier l'UE</button>
<button class='grey' @click='gstore.ie_toggle(-1)'>Annuler</button>
</div>
<!-- endif -->
<div class='info'>
<strong class='cm reflow'>{{ ue.volumeCours}}</strong> CM
<strong class='td reflow'>{{ ue.volumeTD}}</strong> TD
<strong class='tp reflow'>{{ ue.volumeTP }}</strong> TP
<strong>{{ ue.volumeCours + ue.volumeTD + ue.volumeTP }}h</strong>
</div>
</section>
</div>
<div class='footer'>
<span :class="(ue.volumeCours == 0) ? 'course' : 'course active'">{{ ue.volumeCours }}</span><hr>
<span :class="(ue.volumeTD == 0) ? 'td' : 'td active'">{{ ue.volumeTD }}</span><hr>
<span :class="(ue.volumeTP == 0) ? 'tp' : 'tp active'">{{ ue.volumeTP }}</span>
</div>
</section>
</div>
</div>
@ -163,22 +47,7 @@
name: 'CONTAINER_VIEW',
data(){
return { gstore: gstore.get }
},
beforeMount(){
// set onblur to hide filter
window.onblur.link('ue.filter', (e) => {
// ignore [data-unblur-filter] elements
if( e.target.getAttribute('data-unblur-filter') !== null )
return;
// else: hide
gstore.get.show_fgroup(-1);
});
}
}
}
</script>s

View File

@ -1,7 +1,6 @@
import {GlobalStore} from '../lib/gstore'
import {APIClient} from '../lib/api-client'
import {PopUp} from '../lib/pop-up'
import {OnBlurManager} from '../lib/onblur'
import {GlobalStore} from '../lib/gstore'
import {APIClient} from '../lib/api-client'
import {PopUp} from '../lib/pop-up'
require('../lib/css-class-override')
window.gstore = new GlobalStore();
@ -9,25 +8,18 @@ window.gstore = new GlobalStore();
/* (1) Global data
---------------------------------------------------------*/
/* (1) Get URL host */
gstore.add('HOST', document.URL.replace(/^((?:https?:\/\/)?[^\/]+)*(?:.+)$/, '$1'));
/* (2) Get list of URI arguments */
/* (1) Get Full URI */
gstore.add('URI', document.URL.replace(/^(?:\/\/|[^\/]+)*/, '').split('/').filter(function(i){ return i.length; }));
/* (3) Get if local version or prod */
/* (2) Get if local version or prod */
gstore.add('is_local', document.URL.replace(/^https?:\/\/([^\/:]+).*$/, '$1') == 'ptut.com');
/* (4) API instance */
window.api = new APIClient(gstore.get.is_local ? 'http://ptut.com:8080/api/v/1.0/' : `${gstore.get.HOST}/api/v/1.0/`);
/* (3) API instance */
window.api = new APIClient(gstore.get.is_local ? 'http://ptut.com:8080/api/v/1.0/' : 'https://ptut.xdrm.io/api/v/1.0/');
/* (5) PopUp instance */
/* (4) PopUp instance */
window.popup = new PopUp();
/* (6) Create class in window */
window.onblur = new OnBlurManager(document.body);
/* (2) Main components
@ -49,6 +41,10 @@ gstore.add('menu_item', {
label: 'Gestion UE',
url: 'ue',
icon: 'ue'
}, fiche: {
label: 'Fiches',
url: 'fiche',
icon: 'fiche'
}, settings: {
label: 'Administration',
url: 'settings',

View File

@ -1,78 +1 @@
/* (1) Load statistics
---------------------------------------------------------*/
/* (1) Initialize list */
gstore.add('stats', null);
gstore.add('dimensions', null);
/* (2) Get statistics */
api.call('GET department/stats', {}, function(rs) {
// {1} If error -> abort //
if (rs.error !== 0) {
return console.log('No formation found, error: ' + rs.error);
}
let maxValue = null; // plus haute valeur des stats
let maxLabelLength = null; // plus longues chaîne de caractères pour les stats
let data = {}; // ensemble des statistiques à transmettre à VueJS
let map = {
"potentiel" : "Heures potentielles",
"sous_service" : "Heures en sous-services",
"heures_comp" : "Heures comp.",
"heures_vacataire" : "Heures vacataires",
"heures_exterieur" : "Heures à l'extérieurs",
"heures_ue_desactive" : "Heures UE annulées",
"nbr_ue_desactive" : "Nombre d'UE annulées"
};
for (let stat in rs.data) {
// détection de la plus grande valeur statistique
maxValue = rs.data[stat] > maxValue ? rs.data[stat] : maxValue;
// détection du plus grand nom présent
maxLabelLength = map[stat].length > maxLabelLength ? map[stat].length : maxLabelLength;
data[map[stat]] = Math.round(rs.data[stat] * 100) / 100;
}
// légendes à afficher en plus de la valeur
gstore.get.titles = {};
gstore.get.titles[map['heures_ue_desactive']] = `sur ${data[map['nbr_ue_desactive']]} UE annulées`;
// statistiques à ne pas afficher
delete data[map['nbr_ue_desactive']];
gstore.get.stats = data;
gstore.get.dimensions = {
padding: 5,
text: {
size: maxLabelLength * 8.5,
alignH: 5,
alignV: 20,
},
bin: {
count: Object.keys(gstore.get.stats).length,
width: 30,
spacing: 15,
margin: 5
}
};
if (maxValue != null) {
let magnitude = Math.pow(10, maxValue.length-1)/2; // ordre de grandeur du nombre
maxValue = Math.round(
((gstore.get.dimensions.bin.margin/100)+1) // on rajoute la marge afin qu'un "bin" ne dépasse jamais sur la droite
* maxValue / magnitude ) * magnitude;
}
gstore.get.maxValue = maxValue;
gstore.get.dimensions.axis = {
height: (gstore.get.dimensions.bin.count*gstore.get.dimensions.bin.width) + ((gstore.get.dimensions.bin.count)*gstore.get.dimensions.bin.spacing),
width: 500,
precision: 4
};
gstore.get.viewBox = `0 0 ${gstore.get.dimensions.axis.width + gstore.get.dimensions.text.size + 50} ${gstore.get.dimensions.axis.height + 30}`;
});
gstore.add('colors', ["blue", "yellow", "green", "red", "purple", "lightblue", "lightred", "lightyellow", "lightgreen", "lightpurple"]);
gstore.add('blo', 12);

View File

@ -1,24 +1,10 @@
gstore.add('popup_opened', false);
gstore.add('popup_click', function(){
/* (1) Do nothing if already opened */
if( gstore.get.popup_opened )
return;
/* (2) Store that popup is opened */
gstore.get.popup_opened = true;
/* (3) Open popup */
window.pop = window.open('https://sso.univ-pau.fr/cas/login?service='+window.api.target+'cas/1', '_blank', 'location=no,height=1024,width=1024,scrollbars=yes,status=no');
/* (4) Clear interval (optional) */
!isNaN(window.popint) && clearInterval(window.popint);
/* (5) Check if popup closed -> abort */
window.popint = setInterval(function(){ window.pop.closed && window.cas_callback(-5); }, 500);
/* (1) Open popup */
window.pop = window.open('https://sso.univ-pau.fr/cas/login?service='+window.api.target+'cas', '_blank', 'location=no,height=1024,width=1024,scrollbars=yes,status=no');
/* (2) If popup closed -> abort */
window.popint = setInterval(function(){ window.pop.closed && window.cas_callback(null); }, 500);
});

View File

@ -106,14 +106,7 @@ gstore.add('filter_handler', function(){
/* (3) Get Filters
---------------------------------------------------------*/
/* (1) Define global filter */
gstore.add('filters', {
categories: [{ visible: false, active: [] }],
formations: [{ visible: false, active: [] }],
ues: [{ visible: false, active: [] }]
});
/* (2) Define filter group show/hide */
/* (1) Define filter group show/hide */
gstore.add('show_fgroup', function(gname){
var opened = gstore.get.filters[gname] != null && gstore.get.filters[gname][0].visible;
@ -131,7 +124,7 @@ gstore.add('show_fgroup', function(gname){
});
/* (3) Define filter item toggle */
/* (2) Define filter item toggle */
gstore.add('toggle_filter', function(gname, i){
// {1} If wrong @gname -> abort //
@ -147,14 +140,23 @@ gstore.add('toggle_filter', function(gname, i){
// {4} Update active table //
gstore.get.filters[gname][0].active.splice(0);
console.log(gstore.get.filters[gname][0].active);
for( var f = 1 ; f < gstore.get.filters[gname].length ; f++ )
if( gstore.get.filters[gname][f].active )
gstore.get.filters[gname][0].active.push(f);
console.log(gstore.get.filters[gname][0].active);
});
/* (4) Get Formations */
/* (2) Define global filter */
gstore.add('filters', {
formations: [{ visible: false, active: [] }],
ues: [{ visible: false, active: [] }]
});
/* (3) Get Formations */
api.call('GET formation', {}, function(rs){
// {1} If error -> abort //
@ -171,7 +173,7 @@ api.call('GET formation', {}, function(rs){
});
/* (5) Get UEs */
/* (4) Get UEs */
api.call('GET ue', {}, function(rs){
// {1} If error -> abort //
@ -188,23 +190,6 @@ api.call('GET ue', {}, function(rs){
});
/* (6) Get professor categories */
api.call('GET category', {}, function(rs){
// {1} If error -> abort //
if( rs.error !== 0 ) return console.log('No category found, error: '+rs.error);
console.log(rs);
// {2} Format category filters //
for( var i = 0 ; i < rs.categories.length ; i++ )
gstore.get.filters.categories.push({
code: rs.categories[i].idCategorie,
name: rs.categories[i].labelCategorie,
active: false
});
});
@ -281,17 +266,7 @@ gstore.add('create_h', '');
gstore.add('create_err_valid', false);
gstore.add('create_err', '');
/* (4) Define reset handler */
gstore.add('ic_reset', function(){
gstore.add('create_cat', '-');
gstore.add('create_name', '');
gstore.add('create_cas', '');
gstore.add('create_h', '');
gstore.add('create_err_valid', false);
gstore.add('create_err', '');
});
/* (5) Define create handler */
/* (4) Define create handler */
gstore.add('ic_handler', function(prof_id){
/* (4.1) Trim text input */
@ -355,7 +330,7 @@ gstore.add('ic_handler', function(prof_id){
/* (4.5.2.1) Manage 'already exist' error */
if( rs.error == 29 ){
gstore.get.create_err = 'Le couple Nom-Prénom ou l\'identifiant sont déja utilisés.';
gstore.get.create_err = 'Le couple Nom-Prénom est déja utilisé.';
return setTimeout(() => gstore.add('create_err', ''), 2000);
}
@ -553,14 +528,11 @@ gstore.add('ie_handler', function(prof_i){
/* (5.7) Création de la requête */
var rq = {};
( name[0] != prof.firstName ) && ( rq.firstName = name[0] );
( name[1] != prof.lastName ) && ( rq.lastName = name[1] );
( cat != prof.idCat ) && ( rq.category = cat );
( hour != prof.hoursToDo ) && ( rq.hoursToDo = hour );
// if empty cas -> request to remove cas login
( cas != prof.casLogin ) && ( ( cas.length > 0 ) && ( rq.casLogin = cas ) || ( rq.remCas = true ) );
( cas != prof.casLogin ) && ( rq.casLogin = cas );
// update initials whatever have been modified (to avoid API error when no field given)
rq.initials = name[0].substr(0,2) + name[1].substr(0,2);
@ -582,18 +554,11 @@ gstore.add('ie_handler', function(prof_i){
/* (5.8.1) Delete professor */
api.call('PUT professor/'+prof.idProfesseur, rq, function(rs){
/* (5.8.1.1) Manage 'already exist' error */
if( rs.error == 29 ){
gstore.get.edit_err = 'Le couple Nom-Prénom ou l\'identifiant sont déja utilisés.';
return setTimeout(() => gstore.add('edit_err', ''), 2000);
}
/* (5.8.1.2) Abort on error */
/* (5.8.1.1) Abort on error */
if( rs.error !== 0 || rs.updated !== true )
return reject(rs.error);
/* (5.8.1.3) Success */
/* (5.8.1.2) Success */
resolve();
});
@ -610,16 +575,7 @@ gstore.add('ie_handler', function(prof_i){
gstore.get.professors[prof_i].casLogin = cas;
gstore.get.professors[prof_i].hoursToDo = hour;
/* (5.9.2) Try to set the category label */
var ci = gstore.get.filters.categories.map( (data, i) => { return ( data.code && data.code == cat ) ? i : ''; }).join('');
/* (5.9.3) Exit if not found */
if( isNaN(ci) ) return gstore.add('edit_i', -1);
/* (5.9.4) If found -> set category label */
gstore.get.professors[prof_i].categorie = gstore.get.filters.categories[ci].name;
/* (5.9.5) Remove edit mode */
/* (5.9.2) Remove edit mode */
gstore.add('edit_i', -1);
@ -667,38 +623,4 @@ gstore.add('ia_handler', function(prof_i){
});
});
/* (9) Manage instant download fiche
---------------------------------------------------------*/
/* (1) Define download handler */
gstore.add('id_handler', function(prof_id){
/* (1) Abort if wrong prof_id */
if( prof_id == null || isNaN(prof_id) )
return;
/* (2.1) Find index in gstore */
var gi = gstore.get.professors.map( (data, i) => { return ( data.idProfesseur && data.idProfesseur == prof_id ) ? i : ''; }).join('');
/* (2.2) Exit if not found */
if( isNaN(gi) ) return;
var local = gstore.get.professors[gi];
/* (3.1) Update in database */
api.call(`GET professor/pdf/${local.idProfesseur}`, {}, function(rs){
/* (3.1.1) Abort on error */
if( rs.error !== 0 || rs.link == null )
return console.log('Impossible de télécharger la fiche, erreur '+rs.error);
/* (3.1.2) Success */
document.location = rs.link;
});
});

File diff suppressed because it is too large Load Diff

View File

@ -1,81 +0,0 @@
/* OnBlur Manager Class */
export class OnBlurManager{
/* (1) Initialize an OnBlurManager
*
* @root<Element> The root element to work in
*
---------------------------------------------------------*/
constructor(root){
/* (1) Error: invalid @root argument */
if( !(root instanceof Element) )
throw new Error(`[OnBlurManager::new] expected argument to be of type (Element), received (${typeof root})`);
/* (2) Store as attribute */
this.root = root;
/* (3) Initialize @callback list */
this.callback = {};
/* (4) Bind to event */
this.root.addEventListener('click', function(e){
// launch each callback
for( var c of Object.keys(this.callback) )
this.callback[c](e);
}.bind(this) );
}
/* (2) Add a @callback
*
* @index<String> String to name the callback for removing
* @callback<Function> Function to link to callback
*
* @return linked<bool> Whether the callback has been linked
*
---------------------------------------------------------*/
link(index, callback){
/* (1) Fail: invalid @index or @callback arguments */
if( typeof index !== 'string' || !(callback instanceof Function) ){
console.error(`[OnBlurManager::link] expected (String, Function), received (${typeof index}, ${typeof callback})`);
return false;
}
/* (2) Add to list of callbacks */
return ( this.callback[index] = callback ) instanceof Function;
}
/* (3) Unlink a @callback
*
* @index<String> Name of the callback to remove
*
* @return unlinked<bool> Whether the callback has been unlinked
*
---------------------------------------------------------*/
unlink(index, callback){
/* (1) Fail: invalid @index argument */
if( typeof index !== 'string' ){
console.error(`[OnBlurManager::unlink] expected (String), received (${typeof index})`);
return false;
}
/* (2) Remove from list of callbacks */
return ( delete this.callback[index] );
}
}

View File

@ -32,56 +32,22 @@ window.cas_callback = function(cas_login){
setTimeout( function(){ if( window.pop.closed ){
/* (2) Stop interval that checks if window closed */
!isNaN(window.popint) && clearInterval(window.popint);
clearInterval(window.popint);
/* (3) If no login -> error */
if( cas_login === null ){
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.';
gstore.get.login_class = 'invalid';
// re-activate button
gstore.add('popup_opened', false);
setTimeout(function(){ gstore.get.login_class = 'neutral'; }, 3000);
/* (4) If error code -> display error */
}else if( !isNaN(cas_login) ){
gstore.get.login_class = 'invalid';
switch(cas_login){
case -1:
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.<br>(errcode: no_ticket_received)';
break;
case -2:
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.<br>(errcode: cas_not_authed)';
break;
case -3:
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.<br>(errcode: no_meta_department)';
break;
case -4:
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.<br>(errcode: no_matching_professor)';
break;
case -5:
gstore.get.login_error_text = 'Erreur de connexion. Veuillez réessayer.<br>(errcode: popup_interrupt)';
break;
}
// re-activate button
gstore.add('popup_opened', false);
setTimeout(function(){ gstore.get.login_class = 'neutral'; }, 3000);
setTimeout(function(){ gstore.get.login_class = 'neutral'; }, 1500);
/* (4) If login -> reload page */
}else{
gstore.get.login_error_text = 'Vous êtes connectés. Vous allez être redirigé.';
gstore.get.login_class = 'valid';
var redirect_url = `/${gstore.get.URI.join('/')}`;
setTimeout(function(){ document.location = redirect_url; }, 3000);
setTimeout(function(){ document.location = '/'; }, 1500);
}

View File

@ -1,13 +1,8 @@
export default{ 0: [
{
name: 'view',
path: '/ue/view/',
component: require('../component/ue/view.vue').default
}, {
name: 'manage',
path: '/ue/manage/:code',
component: require('../component/ue/manage.vue').default
}, {
path: '*',
redirect: '/ue/view/'

View File

@ -1,5 +1,5 @@
// BACKGROUND COLOR
$bg-color: darken(#eef2f5, 5%);
$bg-color: #eef2f5;
$primary-color: #545f75;
$primary-color: #54627c;
$secondary-color: #b8c0c8;
@ -23,19 +23,16 @@ $rd-form-valid-color: '20d696';
$rd-form-neutral-color: 'b8c0c8';
$rd-form-search-color: '1d74e5';
$rd-form-invalid-color: 'ea4b35';
$rd-form-primary-color: '54627c';
// Menu
$menu-bg: #333;
$menu-bg: #fff;
$menu-item-inactive: 'b9c4ce';
$menu-item-width: 2.5em;
$menu-width: 4em;
$menu-item-width: 3em;
$menu-width: #{$menu-item-width + 1em};
// Header
$header-bg: #fff;
$header-height-noratio: 4em;
$header-font-size-ratio: 0.8;
$header-height: #{$header-height-noratio * $header-font-size-ratio};
$header-height: 3em;
$c404-bubble-width: 40vh;

View File

@ -18,74 +18,804 @@
z-index: 100;
// card container
&.card{
display: flex;
flex-direction: row;
justify-content: flex-start;
flex-wrap: wrap;
}
}
@keyframes bg-fade{
to{ background-color: lighten($bg-color, 5%); }
}
// bounce
@keyframes bounce-up{
from{ transform: scale(.95); }
to{ transform: scale(1); }
}
// animation for incoming element
@keyframes incoming{
from{ transform: translateY(-2em); opacity: 0; }
to{ transform: translateY(0); opacity: 1; }
}
// animation for outgoing element
@keyframes outgoing{
from{ transform: translateY(0); opacity: 1; }
to{ transform: translateY(2em); opacity: 0; }
}
/* [1] List style
---------------------------------*/
@import 'container/list';
#CONTAINER > div.list{
display: flex;
// flex properties
flex-direction: column;
justify-content: flex-start;
& > *:first-child{ margin-top: 1em; }
& > *:last-child{ margin-bottom: 3em; }
/* (1) List element */
& > section{
display: block;
margin: .3em 1em;
padding: .8em 1em;
border-radius: 5px / 5px;
background-color: #fff;
}
/* (2) List title */
& > h1{
display: inline-block;
margin: 0 1.2em;
margin-top: .8em;
font-size: inherit;
color: darken($secondary-color, 5%);
}
/* (3) List separator */
& > hr{
display: block;
position: relative;
margin: 1em 1.5em;
border: 0;
border-bottom: 2px solid darken($bg-color, 5%);
}
}
/* [2] Card style
/* [3] Card style -> container
---------------------------------*/
@import 'container/card';
#CONTAINER.card > div.card.container{
order: 2;
flex: 1 0 calc( 100% - 20em );
display: flex;
min-height: 100%;
// flex properties
flex-direction: row;
justify-content: space-between;
align-items: flex-start;
align-content: flex-start;
flex-wrap: wrap;
// background-color: #f00;
z-index: 101;
overflow: hidden;
/* [3.1] Card style -> instant-search
---------------------------------*/
& > input.instant-search{
display: inline-block;
position: relative;
// - marg - padd - [NEW] - separ
flex: 0 1 calc( 100% - 2*1em - 2*.5em - 2em - 2*1em );
// animation for navigation -> each card-list element
#CONTAINER > div.container{
margin: 1em .5em;
padding: .5em 1em;
margin-right: 0;
border-radius: 3px / 3px;
background-color: #fff;
box-shadow: 0 2px 2px darken(#fff, 10%);
& + button.card.toggle{
display: inline-block;
position: relative;
flex: 0 0 calc( 2em - 2*.5em );
margin: 1em .5em;
margin-left: 0;
font-weight: bold;
}
& > section:not([data-anim='0']),
& > input:not([data-anim='0']),
& > h1:not([data-anim='0']),
& > button:not([data-anim='0']){
animation: bounce-up .2s ease-out;
}
/* (1) Card container */
& > section{
flex: 1 1 0;
display: flex;
position: relative;
margin: 1em .5em;
padding: 1.5em;
border-radius: 3px / 3px;
border: 1px solid transparent;
box-shadow: 0 1px 1px darken(#fff, 20%);
box-shadow: 0 1px 1px darken(#fff, 20%);
&.invalid{ box-shadow: 0; border: 1px solid $form-invalid-color; }
&.valid{ box-shadow: 0; border: 1px solid $form-valid-color; }
&.search{ box-shadow: 0; border: 1px solid $form-search-color; }
background-color: #fff;
color: $primary-color;
// flex
flex-direction: column;
justify-content: flex-start;
flex-wrap: nowrap;
&[data-create]{
border: 1px solid $form-valid-color;
}
// hidden mode
&.search-hidden,
&.filter-hidden{ display: none; }
/* (2) REMOVE+EDIT+ADMIN button */
& > div.goo-menu{
$btn-size: 1.5em;
$btn-space: 0em;
$nb-btn: 3;
$nb-spc: $nb-btn - 1;
$cont-w: $btn-size * $nb-btn + $nb-spc * $btn-space;
display: inline-block;
position: absolute;
top: 1em;
left: calc( 100% - 1em - #{$btn-size} - .5em );
width: $btn-size;
height: $btn-size;
-webkit-filter: url('/asset/svg/filter.svg#goo-menu') drop-shadow(-5px 0 0 #fff);
filter: url('/asset/svg/filter.svg#goo-menu') drop-shadow(-5px 0 0 #fff);
cursor: pointer;
z-index: 103;
/* (2.1) Pan all on hover */
&:hover{
left: calc( 100% - 1em - #{$cont-w} - .5em - 1em );
width: calc( #{$cont-w} + 1em );
/* (2.1.1) lighter color on hover */
& > div.remove[data-remove],
& > div.edit[data-edit],
& > div.admin[data-admin]{
background-color: darken(#fff, 12%);
/* (2.1.2) displace all but 1st element */
&.edit[data-edit]{ left: calc( 100% - #{$btn-size * 2 + $btn-space} ); }
&.remove[data-remove]{ left: calc( 100% - #{$btn-size * 3 + $btn-space * 2} ); }
}
}
/* (2.2) Design elements */
& > div.remove[data-remove],
& > div.edit[data-edit],
& > div.admin[data-admin]{
display: inline-block;
position: absolute;
top: 0;
left: calc( 100% - #{$btn-size} );
width: $btn-size;
height: $btn-size;
border-radius: 50%;
transition: background-color .1s ease-in-out,
left .2s ease-in-out;
background: #fff url('/asset/svg/cross.svg@aaaaaa') center center no-repeat;
background-size: auto 50%;
cursor: pointer;
z-index: 103;
/* (2.1) Feedback */
&:hover{ background-image: url('/asset/svg/cross.svg@#{$rd-form-invalid-color}'); }
/* (2.2) EDIT button */
&.edit[data-edit]{
background-image: url('/asset/svg/a.svg@aaaaaa');
background-size: auto 60%;
z-index: 104;
&:hover{ background-image: url('/asset/svg/a.svg@#{$rd-form-search-color}'); }
}
/* (2.3) ADMIN switch */
&.admin[data-admin]{
background-image: url('/asset/svg/admin.svg@aaaaaa');
z-index: 105;
&:hover{ background-image: url('/asset/svg/admin.svg@555555'); }
&[data-active='1']{ background-image: url('/asset/svg/admin.svg@f4bd18'); }
&[data-active='1']:hover{ background-image: url('/asset/svg/admin.svg@f4a118'); }
}
}
}
/* (4) Card generic title */
& > span.category,
& > select.category{
display: block;
position: relative;
width: calc( 100% - 1em );
margin-bottom: .5em;
font-size: .7em;
color: darken($secondary-color, 10%);
text-transform: uppercase;
letter-spacing: .05em;
z-index: 102;
}
/* (4-edit) Card generic title (select) */
& > select.category{
width: calc( 100% + 1em );
height: 3em;
margin: 0;
padding: 0;
margin-left: -.4em; // emulate no <select>
margin-top: -1em; // replace as if not a select
margin-bottom: -.3em; // fix layout for following elements
// remove border
border: 0;
border-radius: 0;
// remove arrow
-webkit-appearance: none; /* Safari and Chrome */
-moz-appearance: none; /* Firefox */
appearance: none;
background: transparent url('/asset/svg/down_arrow.svg@bbbbbb') right .5em center no-repeat;
background-size: auto 80%;
font-size: .7em;
letter-spacing: .05em;
font-family: inherit;
}
/* (5) Card title */
& > h1{
display: flex;
position: relative;
color: darken($primary-color, 5%);
font-size: 1em;
// flex
flex-direction: row;
justify-content: flex-start;
flex-wrap: nowrap;
&.warning:before{
content: '';
display: inline-block;
position: relative;
width: 1em;
height: 1em;
margin-right: .3em;
background: url('/asset/svg/warning_radio.svg@#{$rd-form-invalid-color}') center bottom no-repeat;
background-size: auto 90%;
text-anchor: center;
}
/* (5-edit) Card title -> edit inputs */
& input{
display: inline-block;
position: relative;
width: 10em;
flex-shrink: 1;
flex-grow: 1;
margin: 0;
padding: 0;
border-radius: 0;
border: 0;
color: darken($primary-color, 5%);
font-size: 1em;
font-weight: bold;
font-family: inherit;
background: transparent;
}
/* (5.1) Sub-content */
& > span[data-visible]{
display: inline-block;
color: $secondary-color;
margin: 0;
margin-left: .5em;
transform: scale(.9);
white-space: nowrap;
&[data-visible='0']{ display: none; }
/* (5.1-edit) input*/
& > input{
text-align: center;
}
}
}
/* (6) Card 2-column array */
& > div.table{
display: flex;
position: relative;
margin-top: 1em;
padding: .5em;
border-radius: 3px / 3px;
border: 1px solid darken(#fff, 15%);
// flex properties
flex-direction: row;
justify-content: space-around;
align-items: center;
flex-wrap: nowrap;
/* (6.1) Column */
& > div{
display: flex;
position: relative;
height: 2.3em;
padding: 0 .4em;
border-left: 1px solid darken(#fff, 15%);
color: darken($secondary-color, 20%);
&:first-child{ border-left: 0; }
// flex properties
flex-direction: row;
justify-content: space-between;
align-items: center;
flex-wrap: nowrap;
/* (6.1.1) Column Emphasis */
& > span,
& > span:first-child{
display: block;
position: relative;
margin-right: .3em;
font-size: 1.5em;
letter-spacing: .05em;
/* (6.1.1-edit) Editable text entry */
& > input{
display: inline-block;
width: 2em;
margin: 0;
padding: 0;
font-size: .9em;
text-align: center;
border-radius: 0;
border: 0;
}
}
/* (6.2) Column Emphasis */
& > span:last-child{
display: block;
position: relative;
min-width: 4em;
max-width: 6em;
font-size: .8em;
letter-spacing: .05em;
text-transform: uppercase;
overflow: hidden;
}
}
}
/* (7) Card footer */
& > div.footer{
display: flex;
position: relative;
margin-top: 1.3em;
margin-left: -1.5em;
height: 3.5em;
// 100% + parent.margin - padding
width: calc( 100% + 2*1.5em - 2*2em );
// remove card bottom padding
margin-bottom: -1.5em;
padding: 0 2em;
border-top: 1px solid darken(#fff, 10%);
border-radius: 0 0 3px 3px;
background-color: #fafbfd;
// flex properties
flex-direction: row;
justify-content: space-between;
align-items: center;
flex-wrap: nowrap;
/* (7.1) Card footer element */
& > span{
display: flex;
position: relative;
height: 1.3em;
color: darken($secondary-color, 20%);
// center text
flex-direction: row;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
&:before{
content: '';
display: inline-block;
position: relative;
width: 1.3em;
height: 1.3em;
margin-right: .4em;
background: transparent center center no-repeat;
background-size: 80% auto;
}
// specific icons
&.course:before{ background-image: url('/asset/svg/course.svg@#{$menu-item-inactive}'); }
&.td:before{ background-image: url('/asset/svg/td.svg@#{$menu-item-inactive}'); }
&.tp:before{ background-image: url('/asset/svg/tp.svg@#{$menu-item-inactive}'); }
// hover icons
&.course.active:before{ background-image: url('/asset/svg/course.svg@5bb8f0'); }
&.td.active:before{ background-image: url('/asset/svg/td.svg@20b565'); }
&.tp.active:before{ background-image: url('/asset/svg/tp.svg@e85456'); }
& > span{
display: inline;
padding-left: .5em;
color: #bbb;
font-size: .9em;
text-transform: uppercase;
}
}
/* (7.1-edit) Card button submit */
& > button{
margin: auto;
}
/* (7.2) Card footer separator */
& > hr{
display: block;
position: relative;
width: 1px;
height: 1em;
border: 0;
background-color: darken(#fff, 10%);
}
}
/* (8) Card sub */
& > div.sub{
display: inline-block;
margin-top: 1em;
color: lighten($primary-color, 20%);
&:before{
content: '';
display: inline-block;
position: relative;
width: 0em;
height: 1em;
background: center bottom -.1em no-repeat;
background-size: auto .9em;
text-anchor: center;
}
&.warning{
color: $form-invalid-color;
&:before{
width: 1em;
margin-right: .3em;
background-image: url('/asset/svg/warning_radio.svg@#{$rd-form-invalid-color}');
}
&[data-valid='1']{
color: $form-valid-color;
}
}
}
&[data-anim-outgoing='1']{
& > section,
& > input,
& > h1,
& > button{ animation: outgoing .4s ease-in-out forwards; }
}
&[data-anim-incoming='1']{
& > section,
& > input,
& > h1,
& > button{ animation: incoming .4s ease-in-out; }
}
/* [4] Card style -> filter
---------------------------------*/
#CONTAINER.card > div.card.filter{
order: 1;
flex: 1 0 calc( 90% );
display: flex;
min-height: calc( 4em - 2*.5em - 2*.5em );
margin: .5em;
padding: .5em;
border-radius: 3px / 3px;
background-color: #fff;
// background-color: #0f0;
box-shadow: 0 2px 2px darken(#fff, 10%);
// flex
flex-direction: row;
justify-content: flex-start;
align-items: center;
flex-wrap: wrap;
z-index: 110;
overflow: visible;
// overflow-y: visible;
/* (1) Filter Group */
& > div[title]{
flex: 0 1 5em;
display: block;
position: relative;
margin: .5em 1em;
/* (1.1) Title content */
& > div.fold-toggle{
content: attr(title);
display: inline-block;
position: relative;
padding-right: 1em;
font-size: .8em;
color: darken($secondary-color, 10%);
text-transform: uppercase;
letter-spacing: .05em;
cursor: pointer;
transition: color .2s ease-in-out;
&:hover{
color: $primary-color;
}
&[data-count]:after{
content: attr(data-count);
display: inline-block;
position: absolute;
margin-top: -.1em;
margin-left: .5em;
width: 1em;
height: clac( 1.5em - 2*.2em );
padding: .2em .5em;
border-radius: 3px;
background: $form-valid-color;
color: #fff;
font-size: .8em;
text-align: center;
}
// greyed when 0
&[data-count='0']:after{ background-color: #ddd; }
}
/* (1.2) Filter box */
& > div.fold{
display: none;
position: absolute;
width: 15em;
height: 15em;
margin-top: 2em;
border: 1px solid #ddd;
border-radius: 3px;
background-color: #fff;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
flex-wrap: nowrap;
overflow: hidden;
overflow-y: auto;
/* (1.3) Filter item */
& > span{
display: block;
position: relative;
padding: .5em 0;
padding-left: 2em;
background-color: #fff;
&:hover{ background-color: darken(#fff,5%); }
&:nth-child(2n){
background-color: #f9f9f9;
&:hover{ background-color: darken(#f9f9f9,5%); }
}
-moz-user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
transition: background-color .2s ease-in-out;
/* (1.3.1) Pseudo-checkbox */
&:before{
content: '';
display: block;
position: absolute;
margin-top: .2em;
margin-left: calc( .5em - 2em );
width: calc( 1em - .2em );
height: calc( 1em - .2em );
border-radius: 50%;
background: $form-valid-color;
transform: scale(0);
transition: transform .1s ease-in-out;
cursor: pointer;
}
/* (1.3.2) Active pseudo-checkbox */
&.active:before{
transform: scale(1);
}
}
}
// only show item box if filter_group has 'data-show'
& > div.fold-toggle[data-show='1'] + div.fold{
display: flex;
}
}
// &[data-anim-bounce='1']{
// & > section,
// & > input,
// & > h1,
// & > button{ animation: bounce-up .6s ease-in-out reverse forwards; }
// }
}

View File

@ -1,814 +0,0 @@
@import '../constants';
/* [3] Card style -> container
---------------------------------*/
#CONTAINER.card > div.card.container{
order: 2;
flex: 1 0 calc( 100% - 20em );
display: flex;
min-height: 100%;
// flex properties
flex-direction: row;
justify-content: flex-start;
align-items: stretch;
align-content: flex-start;
flex-wrap: wrap;
margin: .5em;
z-index: 101;
overflow: auto;
/* [3.1] Card style -> instant-search
---------------------------------*/
& > input.instant-search{
display: inline-block;
position: relative;
flex: 1 0 80%; // 70% to almost fill the line
height: 1.2em;
margin: .5em;
padding: .5em 1em;
margin-right: 0;
border-radius: 3px / 3px;
background-color: #fff;
box-shadow: 0 2px 2px darken(#fff, 10%);
& + button.card.toggle{
display: inline-block;
position: relative;
flex: 0 0 calc( 2em - 2*.5em );
margin: .5em;
color: transparent;
font-weight: bold;
background: #fff url('/asset/svg/plus.svg@#{$rd-form-valid-color}') center center no-repeat;
background-size: 40% auto;
}
}
/* (1) Card container */
& > section{
flex: 1 1 20em;
display: flex;
position: relative;
margin: .5em;
padding: 1.5em;
border-radius: 3px / 3px;
border: 1px solid transparent;
box-shadow: 0 1px 1px darken(#fff, 20%);
&.invalid{ box-shadow: 0; border: 1px solid $form-invalid-color; }
&.valid{ box-shadow: 0; border: 1px solid $form-valid-color; }
&.search{ box-shadow: 0; border: 1px solid $form-search-color; }
background-color: #fff;
color: $primary-color;
// flex
flex-direction: column;
justify-content: space-between;
flex-wrap: nowrap;
z-index: 102;
&[data-create]{
border: 1px solid $form-valid-color;
}
// hidden mode
&.search-hidden,
&.filter-hidden{ display: none; }
/* (2) REMOVE+EDIT+ADMIN button */
& > div.goo-menu{
$btn-size: 1.8em;
$btn-space: 0em;
$nb-btn: 4;
$nb-spc: $nb-btn - 1;
$cont-w: $btn-size * $nb-btn + $nb-spc * $btn-space;
display: inline-block;
position: absolute;
top: 1em;
left: calc( 100% - 1em - #{$btn-size} - .5em );
width: $btn-size;
height: $btn-size;
-webkit-filter: url('/asset/svg/filter.svg#goo-menu') drop-shadow(-5px 0 0 #fff);
filter: url('/asset/svg/filter.svg#goo-menu') drop-shadow(-5px 0 0 #fff);
cursor: pointer;
z-index: 103;
/* (2.1) Pan all on hover */
&:hover{
left: calc( 100% - 1em - #{$cont-w} - .5em - 1em );
width: calc( #{$cont-w} + 1em );
/* (2.1.1) lighter color on hover */
& > div.remove[data-remove],
& > div.edit[data-edit],
& > div.enabled[data-enabled],
& > div.required[data-required],
& > div.admin[data-admin]{
background-color: darken(#fff, 12%);
/* (2.1.2) displace all but 1st element */
&.edit[data-edit]{ left: calc( 100% - #{$btn-size * 2 + $btn-space} ); }
&.remove[data-remove]{ left: calc( 100% - #{$btn-size * 3 + $btn-space * 2} ); }
&.required[data-required]{ left: calc( 100% - #{$btn-size * 4 + $btn-space * 3} ); }
}
}
/* (2.2) Design elements */
& > div.remove[data-remove],
& > div.edit[data-edit],
& > div.enabled[data-enabled],
& > div.required[data-required],
& > div.admin[data-admin]{
display: inline-block;
position: absolute;
top: 0;
left: calc( 100% - #{$btn-size} );
width: $btn-size;
height: $btn-size;
border-radius: 50%;
transition: background-color .1s ease-in-out,
left .2s ease-in-out;
background: #fff url('/asset/svg/cross.svg@aaaaaa') center center no-repeat;
background-size: auto 50%;
cursor: pointer;
z-index: 103;
/* (2.1) Feedback */
&:hover{ background-image: url('/asset/svg/cross.svg@#{$rd-form-invalid-color}'); }
/* (2.2) EDIT button */
&.edit[data-edit]{
background-image: url('/asset/svg/a.svg@aaaaaa');
background-size: auto 60%;
z-index: 104;
&:hover{ background-image: url('/asset/svg/a.svg@#{$rd-form-search-color}'); }
}
/* (2.3) ADMIN switch */
&.admin[data-admin]{
background-image: url('/asset/svg/admin-disabled.svg@aaaaaa');
z-index: 105;
&:hover{ background-image: url('/asset/svg/admin-disabled.svg@555555'); }
&[data-active='1']{ background-image: url('/asset/svg/admin.svg@f4bd18'); }
&[data-active='1']:hover{ background-image: url('/asset/svg/admin.svg@f4a118'); }
}
/* (2.3) DISABLED switch */
&.enabled[data-enabled]{
background-image: url('/asset/svg/bell-disabled.svg@aaaaaa');
z-index: 105;
&:hover{ background-image: url('/asset/svg/bell-disabled.svg@555555'); }
&[data-active='1']{ background-image: url('/asset/svg/bell.svg@f4bd18'); }
&[data-active='1']:hover{ background-image: url('/asset/svg/bell.svg@f4a118'); }
}
/* (2.4) REQUIRED switch */
&.required[data-required]{
background-image: url('/asset/svg/pin-disabled.svg@aaaaaa');
z-index: 104;
&:hover{ background-image: url('/asset/svg/pin-disabled.svg@555555'); }
&[data-active='1']{ background-image: url('/asset/svg/pin.svg@f4bd18'); }
&[data-active='1']:hover{ background-image: url('/asset/svg/pin.svg@f4a118'); }
}
}
}
/* (4) Card generic title */
& > span.category,
& > select.category{
display: block;
position: relative;
width: calc( 100% - 1em );
margin-bottom: .5em;
font-size: .7em;
color: darken($secondary-color, 10%);
text-transform: uppercase;
letter-spacing: .05em;
z-index: 102;
}
/* (4-edit) Card generic title (select) */
& > select.category{
width: calc( 100% + 1em );
height: 3em;
margin: 0;
padding: 0;
margin-left: -.4em; // emulate no <select>
margin-top: -1em; // replace as if not a select
margin-bottom: -.3em; // fix layout for following elements
// remove border
border: 0;
border-radius: 0;
// remove arrow
-webkit-appearance: none; /* Safari and Chrome */
-moz-appearance: none; /* Firefox */
appearance: none;
background: transparent url('/asset/svg/down_arrow.svg@bbbbbb') right .5em center no-repeat;
background-size: auto 80%;
font-size: .7em;
letter-spacing: .05em;
font-family: inherit;
}
/* (5) Card title */
& > h1{
display: flex;
position: relative;
color: darken($primary-color, 5%);
font-size: 1em;
margin: .4em 0;
// flex
flex-direction: row;
justify-content: flex-start;
flex-wrap: nowrap;
// &.warning:before{
// content: '';
// display: inline-block;
// position: relative;
// width: 1.2em;
// height: 1em;
// margin-right: .3em;
// background: url('/asset/svg/warning_radio.svg@#{$rd-form-invalid-color}') center bottom no-repeat;
// background-size: auto 90%;
// text-anchor: center;
// }
/* (5-edit) Card title -> edit inputs */
& input{
display: inline-block;
position: relative;
width: 10em;
flex-shrink: 1;
flex-grow: 1;
margin: 0;
padding: 0;
border-radius: 0;
border: 0;
color: darken($primary-color, 5%);
font-size: 1em;
font-weight: bold;
font-family: inherit;
background: transparent;
}
/* (5.1) Sub-content */
& > span[data-visible]{
display: inline-block;
color: $secondary-color;
margin: 0;
margin-left: .5em;
transform: scale(.9);
white-space: nowrap;
&[data-visible='0']{ display: none; }
/* (5.1-edit) input*/
& > input{
text-align: center;
}
}
}
/* (6) Card 2-column array */
& > div.table{
display: flex;
position: relative;
margin-top: 1em;
padding: .5em;
border-radius: 3px / 3px;
border: 1px solid darken(#fff, 15%);
// flex properties
flex-direction: row;
justify-content: space-around;
align-items: center;
flex-wrap: nowrap;
&.little{
font-size: .7em;
white-space: nowrap;
}
/* (6.1) Column */
& > div{
flex: 1;
display: flex;
position: relative;
height: 2.3em;
padding: 0 .4em;
border-left: 1px solid darken(#fff, 15%);
color: darken($secondary-color, 20%);
&:first-child{ border-left: 0; }
// flex properties
flex-direction: row;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
/* (6.1.1) Column Emphasis */
& > span,
& > span:first-child{
display: block;
position: relative;
margin-right: .3em;
font-size: 1.5em;
letter-spacing: .05em;
/* (6.1.1-edit) Editable text entry */
& > input{
display: inline-block;
width: 2em;
margin: 0;
padding: 0;
font-size: .9em;
text-align: center;
border-radius: 0;
border: 0;
}
}
/* (6.2) Column Emphasis */
& > span:last-child:not(.notlast){
display: block;
position: relative;
min-width: 4em;
max-width: 6em;
font-size: .8em;
letter-spacing: .05em;
text-transform: uppercase;
overflow: hidden;
}
}
}
/* (7) Card footer */
& > div.footer{
display: flex;
position: relative;
margin-top: 1.3em;
margin-left: -1.5em;
height: 3.5em;
// 100% + parent.margin - padding
width: calc( 100% + 2*1.5em - 2*2em );
// remove card bottom padding
margin-bottom: -1.5em;
padding: 0 2em;
border-top: 1px solid darken(#fff, 10%);
&:last-of-type{ border-radius: 0 0 3px 3px; }
background-color: #fafbfd;
// flex properties
flex-direction: row;
justify-content: space-between;
align-items: center;
align-content: center;
flex-wrap: nowrap;
/* (7.1) Card footer element */
& > span{
display: flex;
position: relative;
height: 1.3em;
color: darken($secondary-color, 20%);
// center text
flex-direction: row;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
&:before{
content: '';
display: inline-block;
position: relative;
width: 1.3em;
height: 1.3em;
margin-right: .4em;
background: transparent center center no-repeat;
background-size: 80% auto;
}
// specific icons
&.course:before{ background-image: url('/asset/svg/course.svg@#{$menu-item-inactive}'); }
&.td:before{ background-image: url('/asset/svg/td.svg@#{$menu-item-inactive}'); }
&.tp:before{ background-image: url('/asset/svg/tp.svg@#{$menu-item-inactive}'); }
// hover icons
&.course.active:before{ background-image: url('/asset/svg/course.svg@5bb8f0'); }
&.td.active:before{ background-image: url('/asset/svg/td.svg@20b565'); }
&.tp.active:before{ background-image: url('/asset/svg/tp.svg@e85456'); }
& > span{
display: inline;
padding-left: .5em;
color: #bbb;
font-size: .9em;
text-transform: uppercase;
}
/* (7.1-edit) Card footer input */
& > input{
width: 2.5em;
margin: 0;
padding: 0;
border: 0;
}
}
/* (7.1-edit) Card button submit */
& > button{
margin: auto;
}
/* (7.2) Card footer separator */
& > hr{
display: block;
position: relative;
width: 1px;
height: 1em;
border: 0;
background-color: darken(#fff, 10%);
}
}
/* (8) Card sub */
& > div.sub{
display: inline-block;
margin-top: 1em;
color: lighten($primary-color, 20%);
}
/* (8) Card sub */
& > div.pdfdl{
display: inline-block;
margin-top: 1em;
color: lighten($primary-color, 20%);
transition: color .1s ease-in-out;
cursor: pointer;
&:before{
content: '';
display: inline-block;
position: relative;
top: .2em;
width: 1em;
height: 1em;
margin-right: .5em;
background: url('/asset/svg/fiche.svg@#{$menu-item-inactive}') center center no-repeat;
background-size: contain;
}
&:hover{
color: #333;
&:before{ background-image: url('/asset/svg/fiche.svg@ea4C3a'); }
}
}
/* (9) Infobar */
& > div.info{
display: block;
position: relative;
margin-top: 2.1em;
margin-left: -2.1em;
height: auto;
width: calc( 100% + 2*2.1em - 2*1em);
margin-bottom: -2.1em;
padding: .3em 1em;
border-top: 1px solid #f3f3f3;
background-color: darken(#fafbfd,1%);
font-size: .7em;
color: #bbb;
}
}
}
/* [4] Card style -> filter
---------------------------------*/
#CONTAINER.card > div.card.filter{
order: 1;
flex: 1 0 calc( 90% );
display: flex;
min-height: calc( 4em - 2*.5em - 2*.5em );
margin: 1em;
margin-bottom: .5em;
padding: .5em;
border-radius: 3px / 3px;
background-color: #fff;
// background-color: #0f0;
box-shadow: 0 2px 2px darken(#fff, 10%);
// flex
flex-direction: row;
justify-content: flex-start;
align-items: center;
flex-wrap: wrap;
z-index: 110;
overflow: visible;
// overflow-y: visible;
/* (1) Filter Group */
& > div[title]{
flex: 0 1 5em;
display: block;
position: relative;
margin: .5em 1em;
/* (1.1) Title content */
& > div.fold-toggle{
content: attr(title);
display: inline-block;
position: relative;
padding-right: 1em;
font-size: .8em;
color: darken($secondary-color, 10%);
text-transform: uppercase;
letter-spacing: .05em;
cursor: pointer;
transition: color .2s ease-in-out;
&:hover{
color: $primary-color;
}
&[data-count]:after{
content: attr(data-count);
display: inline-block;
position: absolute;
margin-top: -.1em;
margin-left: .5em;
width: 1em;
height: clac( 1.5em - 2*.2em );
padding: .2em .5em;
border-radius: 3px;
background: $form-valid-color;
color: #fff;
font-size: .8em;
text-align: center;
}
// greyed when 0
&[data-count='0']:after{ background-color: #ddd; }
}
/* (1.2) Filter box */
& > div.fold{
display: none;
position: absolute;
width: 15em;
max-height: 25em;
margin-top: 1em;
z-index: 110;
border: 1px solid #ddd;
border-radius: 3px;
background-color: #fff;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
flex-wrap: nowrap;
overflow: hidden;
overflow-y: auto;
/* (1.3) Filter item */
& > span{
display: block;
position: relative;
padding: .5em 0;
padding-left: 2em;
background-color: #fff;
&:hover{ background-color: darken(#fff,5%); }
&:nth-child(2n){
background-color: #f9f9f9;
&:hover{ background-color: darken(#f9f9f9,5%); }
}
-moz-user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
transition: background-color .2s ease-in-out;
/* (1.3.1) Pseudo-checkbox */
&:before{
content: '';
display: block;
position: absolute;
margin-top: .2em;
margin-left: calc( .5em - 2em );
width: calc( 1em - .2em );
height: calc( 1em - .2em );
border-radius: 50%;
background: $form-valid-color;
transform: scale(0);
transition: transform .1s ease-in-out;
cursor: pointer;
}
/* (1.3.2) Active pseudo-checkbox */
&.active:before{
transform: scale(1);
}
}
}
// only show item box if filter_group has 'data-show'
& > div.fold-toggle[data-show='1'] + div.fold{
display: flex;
}
}
}

View File

@ -1,200 +0,0 @@
@import '../constants';
/* [3] List style -> container
---------------------------------*/
#CONTAINER.list{
animation: bg-fade .2s ease-out forwards;
}
#CONTAINER > div.list.container{
display: flex;
// flex properties
flex-direction: row;
justify-content: stretch;
align-items: flex-start;
flex-wrap: wrap;
/* (1) List element */
& > section{
order: -100000;
flex: 1 1 90%;
display: flex;
margin: 0;
padding: .8em 1em;
border-bottom: 1px solid #eee;
background-color: #fff;
// no border-bottom for last child
&:last-of-type{ border-bottom: 0; }
// flex properties
flex-direction: row;
justify-content: flex-start;
align-items: center;
flex-wrap: nowrap;
/* (1.1) Element item */
& > div:not(.icon),
& > select,
& > input{
flex: 0 1 30%;
// fix
&.taglist{
margin: 0;
margin-left: 1.5em;
}
}
/* (1.2) Hover animation */
transition: border-left-color .3s ease-in-out;
&:not(.filter){
border-left: .2em solid #fff;
&:hover{ background-color: darken(#fff,1%); }
&.create:hover{ border-left-color: $form-valid-color; }
&:hover,
&.bcours:hover{ border-left-color: $form-search-color; }
&.btd:hover{ border-left-color: $form-valid-color; }
&.btp:hover{ border-left-color: $form-invalid-color; }
}
/* (1.3) Select elements*/
& > select{
display: block;
position: relative;
height: 1.8em;
margin: 0;
margin-right: 1em;
padding: .2em .5em;
padding-right: 1em;
border: 1px solid lighten($form-neutral-color, 5%);
border-radius: 3px;
background: transparent url('/asset/svg/down_arrow.svg@bbbbbb') right .5em bottom .1em no-repeat;
background-size: auto 80%;
color: #999;
font-size: .8em;
cursor: default;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
// flex: 0 1 15em;
&.min{ flex: 0 1 5em; }
}
/* (1.4) Input */
& > input{
display: inline-block;
position: relative;
min-width: 0;
margin: 0;
padding: .22em .5em;
flex: 0 1 5em;
}
/* (1.5) Icon (remove) */
& > div.icon{
display: inline-block;
width: 1.2em;
height: 1.2em;
margin-right: 1em;
background: url('/asset/svg/plus.svg@aaaaaa') center center no-repeat;
background-size: 60% auto;
overflow: hidden;
cursor: pointer;
&:hover{ background-image: url('/asset/svg/plus.svg@#{$rd-form-valid-color}'); }
&.remove{
background-image: url('/asset/svg/cross.svg@aaaaaa');
&:hover{ background-image: url('/asset/svg/cross.svg@#{$rd-form-invalid-color}'); }
}
&.hidden{ background: transparent; }
}
}
/* (2) Filter */
& > section.filter{
background-color: transparent;
text-transform: uppercase;
color: #aaa;
font-size: .8em;
font-weight: bold;
text-shadow: 1px 1px 2px #fff;
& > div{
cursor: default;
& > span.arrow{
display: inline-block;
position: relative;
width: 1.5em;
height: 1.5em;
margin-bottom: -.3em;
background: url() center center no-repeat;
background-size: auto 100%;
cursor: pointer;
}
// selected filter
&[data-filter='1']{
color: $primary-color;
& > span.arrow{
&[data-way='-1']{ background-image: url('/asset/svg/up_arrow.svg@555555'); }
&[data-way='1']{ background-image: url('/asset/svg/down_arrow.svg@555555'); }
}
}
}
}
/* Tags color -> darker */
.tag,
& > section > select{
color: $primary-color;
}
}

View File

@ -1,126 +0,0 @@
/* COULEUR POUR LE GRAPH SVG */
$svg-blue: #3366CC;
$svg-red: #DC3912;
$svg-yellow: #FF9900;
$svg-green: #109618;
$svg-purple: #990099;
$svg-lightblue: #0099C6;
$svg-lightred: #DD4477;
$svg-lightyellow: #F1CA3A;
$svg-lightgreen: #AAAA11;
$svg-lightpurple: #994499;
svg {
width: 100%;
height: 30vh;
margin: 10px;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-moz-user-select: none; /* Firefox */
user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */
path {
fill: none;
fill-rule: evenodd;
stroke: rgb(0, 0, 0);
stroke-width: 1px;
stroke-linecap: butt;
stroke-linejoin: miter;
stroke-opacity: 1;
&.precision {
stroke-width: 0.2px;
}
}
rect.hiding {
width: 0;
}
rect {
transition: width 0.75s;
cursor: pointer;
color: rgb(0, 0, 0);
clip-rule: nonzero;
display: inline;
overflow: visible;
visibility: visible;
opacity: 1;
isolation: auto;
mix-blend-mode: normal;
color-interpolation: sRGB;
color-interpolation-filters: linearRGB;
fill-opacity: 1;
fill-rule: nonzero;
stroke: none;
stroke-width: 1px;
stroke-linecap: butt;
stroke-linejoin: miter;
stroke-miterlimit: 4;
stroke-dasharray: none;
stroke-dashoffset: 0;
stroke-opacity: 1;
color-rendering: auto;
image-rendering: auto;
shape-rendering: auto;
text-rendering: auto;
}
text {
text-anchor: end;
&.precision {
text-anchor: middle;
fill: #666666;
font-size: 13px;
}
}
.blue {
fill: $svg-blue
}
.red {
fill: $svg-red
}
.yellow {
fill: $svg-yellow
}
.green {
fill: $svg-green
}
.purple {
fill: $svg-purple
}
.lightblue {
fill: $svg-lightblue
}
.lightred {
fill: $svg-lightred
}
.lightyellow {
fill: $svg-lightyellow
}
.lightgreen {
fill: $svg-lightgreen
}
.lightpurple {
fill: $svg-lightpurple
}
}

View File

@ -1,25 +1,235 @@
@import 'constants';
/* (1) Input */
@import 'global/input';
/* (1) Champs de texte */
input[type=text], .neutral > input[type=text],
input[type=mail], .neutral > input[type=mail],
input[type=password], .neutral > input[type=password],
select, .neutral > select,
input[type=text].neutral,
input[type=mail].neutral,
input[type=password].neutral,
select.neutral{
/* (2) Button */
@import 'global/button';
display: inline-block;
margin: 1em;
padding: .5em 1em;
/* (3) classes that add icons before text */
@import 'global/before-icon';
border-radius: 3px;
border: 1px solid $form-neutral-color;
/* (4) tags */
@import 'global/tag';
background-color: #fff;
font-family: inherit;
color: lighten($primary-color, 15%);
transition: border .2s ease-in-out,
color .2s ease-in-out;
&:focus, &:hover{
border-color: darken($form-neutral-color, 10%);
color: $primary-color;
}
}
.error, [data-error='1']{ font-weight: bold; color: $form-invalid-color; }
.success, [data-success='1']{ color: $form-valid-color; }
select{
width: 100%;
display: block;
background: #fff;
option{
padding: .5em;
}
}
// Champs valides
.valid > input[type=text],
.valid > input[type=mail],
.valid > input[type=password],
.valid > select,
input.valid[type=text],
input.valid[type=mail],
input.valid[type=password],
select.valid{
border-color: darken($form-valid-color, 0%);
&:focus, &:hover{
border-color: darken($form-valid-color, 10%);
}
}
// Champs neutres
.invalid > input[type=text],
.invalid > input[type=mail],
.invalid > input[type=password],
.invalid > select,
input.invalid[type=text],
input.invalid[type=mail],
input.invalid[type=password],
select.invalid{
border-color: darken($form-invalid-color, 0%);
&:focus, &:hover{
border-color: darken($form-invalid-color, 10%);
}
}
// Champs neutres
.search > input[type=text],
.search > input[type=mail],
.search > input[type=password],
.search > select,
input.search[type=text],
input.search[type=mail],
input.search[type=password]{
border-color: darken($form-search-color, 0%);
&:focus, &:hover{
border-color: darken($form-search-color, 10%);
}
}
/* (2) Boutons */
button, .neutral > button,
input[type=button], .neutral > input[type=button],
input[type=submit], .neutral > input[type=submit],
button.neutral,
input[type=button].neutral,
input[type=submit].neutral{
/* (4) Links */
display: inline-block;
position: relative;
padding: .5em 1em;
border-radius: 3px;
border: 1px solid $form-neutral-color;
background: #fff center center no-repeat;
text-transform: uppercase;
font-weight: normal;
font-family: inherit;
color: $primary-color;
cursor: pointer;
transition: color .2s ease-in-out,
border-color .1s ease-in-out,
background .2s ease-in-out;
&:hover, &[data-active='1']{
color: #fff;
border-color: $form-neutral-color;
background-color: $form-neutral-color;
}
}
// Boutons grisés
button:disabled,
button.grey, .grey > button,
input[type=button].grey, .grey > input[type=button],
input[type=submit].grey, .grey > input[type=submit]{
color: $form-grey-color;
&:hover, &[data-active='1']{
color: #fff;
border-color: $form-grey-color;
background-color: $form-grey-color;
}
cursor: default;
}
// Boutons valides
button.valid, .valid > button,
input[type=button].valid, .valid > input[type=button],
input[type=submit].valid, .valid > input[type=submit]{
color: $form-valid-color;
&:hover, &[data-active='1']{
color: #fff;
border-color: $form-valid-color;
background-color: $form-valid-color;
}
}
// Boutons invalides
button.invalid, .invalid > button,
input[type=button].invalid, .invalid > input[type=button],
input[type=submit].invalid, .invalid > input[type=submit]{
color: $form-invalid-color;
&:hover, &[data-active='1']{
color: #fff;
border-color: $form-invalid-color;
background-color: $form-invalid-color;
}
}
// Boutons recherche
button.search, .search > button,
input[type=button].search, .search > input[type=button],
input[type=submit].search, .search > input[type=submit]{
color: $form-search-color;
&:hover, &[data-active='1']{
color: #fff;
border-color: $form-search-color;
background-color: $form-search-color;
}
}
// Boutons quand action validee
.invalid > button.active,
button.invalid.active,
button.active{
background-color: #fff;
background-image: url('/src/static/container/active@#{$rd-form-invalid-color}.svg') !important;
background-size: 1em auto;
color: transparent !important;
}
button.valid.active,
.valid > button.active{
background-image: url('/src/static/container/active@#{$rd-form-valid-color}.svg') !important;
}
button.neutral.active,
.neutral > button.active{
background-image: url('/src/static/container/active@#{$rd-form-neutral-color}.svg') !important;
}
button.search.active,
.search > button.active{
background-image: url('/src/static/container/active@#{$rd-form-search-color}.svg') !important;
}
// Liens
a{
color: inherit;
text-decoration: none;
@ -42,112 +252,8 @@ a{
}
}
/* (5) Greyed text */
// Textes
.grey{
color: $secondary-color;
}
/* (6) pointer cursor (2 times the class to increase priority) */
.pointer.pointer{
cursor: pointer;
}
/* (7) Mono font */
.mono{
font-family: 'Mono';
font-size: .9em;
}
/* (8) Striked text */
[data-strike='1'],
.strike{
text-decoration: line-through;
opacity: .5;
}
/* (9) Icons (1em wide) */
.user-icon, .time-icon{
display: block;
position: relative;
width: 1em;
height: 1em;
background: url('/asset/svg/teacher.svg@#{$rd-form-neutral-color}') center center no-repeat;
background-size: contain;
&.time-icon{
background-image: url('/asset/svg/time.svg@#{$rd-form-neutral-color}');
}
}
/* (10) Toggling tooltip on hover */
[data-tooltip]{
position: relative;
cursor: pointer;
&:before{
content: attr(data-tooltip);
display: block;
position: absolute;
top: calc( 100% + 1em );
left: 50%;
margin-left: -.1em;
padding: .4em .6em;
border-radius: 3px / 3px;
box-shadow: 0 0 .5em 0 #fff;
font-size: .7em;
color: #ddd;
letter-spacing: 0;
background-color: #444;
transform: translateX(-50%) translateY(-50%) scale(0);
transition: transform .1s ease-in-out;
z-index: 999;
}
&:hover:not([data-tooltip='']):before{
transform: translateX(-50%) translateY(0) scale(1);
}
&:after{
content: '';
display: block;
position: absolute;
top: calc( 100% + .6em );
left: 50%;
width: .4em;
height: .4em;
background-color: #444;
transform: translateX(-50%) rotate(45deg) scale(0);
transition: transform .1s ease-in-out;
z-index: 1000;
}
&:hover:not([data-tooltip='']):after{
transform: translateX(-50%) rotate(45deg) scale(1);
}
}

View File

@ -1,209 +0,0 @@
@import '../constants';
/* (1) Warning icon */
.warning,
.user,
.time,
.pin,
.cm,
.back,
.td,
.tp{
// add icon before
&:before{
content: '';
display: inline-block;
position: relative;
width: 1.2em;
height: 1em;
margin-right: .3em;
background: url('/asset/svg/warning.svg@#{$rd-form-invalid-color}') center center no-repeat;
background-size: auto 90%;
}
&.nospace:before{
margin-right: 0;
}
&.reflow{
white-space: nowrap;
&:before{
font-size: 1.2em;
background-position: center bottom;
background-size: auto 70%;
}
}
&.big{
&:before{
font-size: 1.5em;
}
}
// icon color variants
&.neutral:before{ background-image: url('/asset/svg/warning.svg@#{$rd-form-neutral-color}'); }
&.valid:before{ background-image: url('/asset/svg/warning.svg@#{$rd-form-valid-color}'); }
&.search:before{ background-image: url('/asset/svg/warning.svg@#{$rd-form-search-color}'); }
// force red text
&.invalid{ color: $form-invalid-color; }
&[data-valid='1']{ color: $form-valid-color; }
&[data-neutral='1']{ color: $form-neutral-color; }
&[data-search='1']{ color: $form-search-color; }
}
/* (2) Pin icon */
.pin{
// add icon before
&:before{
background-image: url('/asset/svg/pin.svg@f4bd18');
}
// icon color variants
&.disabled:before{ background-image: url('/asset/svg/pin-disabled.svg@#{$rd-form-neutral-color}'); }
&.neutral:before{ background-image: url('/asset/svg/pin.svg@#{$rd-form-neutral-color}'); }
&.valid:before{ background-image: url('/asset/svg/pin.svg@#{$rd-form-valid-color}'); }
&.search:before{ background-image: url('/asset/svg/pin.svg@#{$rd-form-search-color}'); }
}
/* (3) CM */
.cm{
// add icon before
&:before{
background-image: url('/asset/svg/course.svg@#{$menu-item-inactive}');
}
&.active:before{ background-image: url('/asset/svg/course.svg@5bb8f0'); }
// icon color variants
&.neutral:before{ background-image: url('/asset/svg/course.svg@#{$rd-form-neutral-color}'); }
&.valid:before{ background-image: url('/asset/svg/course.svg@#{$rd-form-valid-color}'); }
&.search:before{ background-image: url('/asset/svg/course.svg@#{$rd-form-search-color}'); }
}
/* (4) TD */
.td{
// add icon before
&:before{
background-image: url('/asset/svg/td.svg@#{$menu-item-inactive}');
}
&.active:before{ background-image: url('/asset/svg/td.svg@20b565'); }
// icon color variants
&.neutral:before{ background-image: url('/asset/svg/td.svg@#{$rd-form-neutral-color}'); }
&.valid:before{ background-image: url('/asset/svg/td.svg@#{$rd-form-valid-color}'); }
&.search:before{ background-image: url('/asset/svg/td.svg@#{$rd-form-search-color}'); }
}
/* (5) TP */
.tp{
// add icon before
&:before{
background-image: url('/asset/svg/tp.svg@#{$menu-item-inactive}');
}
&.active:before{ background-image: url('/asset/svg/tp.svg@e85456'); }
// icon color variants
&.neutral:before{ background-image: url('/asset/svg/tp.svg@#{$rd-form-neutral-color}'); }
&.valid:before{ background-image: url('/asset/svg/tp.svg@#{$rd-form-valid-color}'); }
&.search:before{ background-image: url('/asset/svg/tp.svg@#{$rd-form-search-color}'); }
}
/* (6) USER */
.user{
// add icon before
&:before{
background-image: url('/asset/svg/teacher.svg@#{$menu-item-inactive}');
}
// icon color variants
&.neutral:before{ background-image: url('/asset/svg/teacher.svg@#{$rd-form-neutral-color}'); }
&.invalid:before{ background-image: url('/asset/svg/teacher.svg@#{$rd-form-invalid-color}'); }
&.valid:before{ background-image: url('/asset/svg/teacher.svg@#{$rd-form-valid-color}'); }
&.search:before{ background-image: url('/asset/svg/teacher.svg@#{$rd-form-search-color}'); }
}
/* (7) TIME */
.time{
// add icon before
&:before{
background-image: url('/asset/svg/time.svg@#{$menu-item-inactive}');
}
// icon color variants
&.neutral:before{ background-image: url('/asset/svg/time.svg@#{$rd-form-neutral-color}'); }
&.invalid:before{ background-image: url('/asset/svg/time.svg@#{$rd-form-invalid-color}'); }
&.valid:before{ background-image: url('/asset/svg/time.svg@#{$rd-form-valid-color}'); }
&.search:before{ background-image: url('/asset/svg/time.svg@#{$rd-form-search-color}'); }
}
/* (8) BACK */
.back{
// add icon before
&:before{
background-image: url('/asset/svg/back.svg@#{$menu-item-inactive}');
}
// icon color variants
&.neutral:before{ background-image: url('/asset/svg/back.svg@#{$rd-form-neutral-color}'); }
&.invalid:before{ background-image: url('/asset/svg/back.svg@#{$rd-form-invalid-color}'); }
&.valid:before{ background-image: url('/asset/svg/back.svg@#{$rd-form-valid-color}'); }
&.search:before{ background-image: url('/asset/svg/back.svg@#{$rd-form-search-color}'); }
// hover
&:hover:before{ background-image: url('/asset/svg/back.svg@ffffff'); }
}

View File

@ -1,102 +0,0 @@
@import '../constants';
/* (1) BUTTON (neutral) */
button, .neutral > button,
input[type=button], .neutral > input[type=button],
input[type=submit], .neutral > input[type=submit],
button.neutral,
input[type=button].neutral,
input[type=submit].neutral{
display: inline-block;
position: relative;
padding: .5em 1em;
border-radius: 3px;
border: 1px solid $form-neutral-color;
background: #fff center center no-repeat;
text-transform: uppercase;
font-weight: normal;
font-family: inherit;
color: $primary-color;
cursor: pointer;
transition: color .2s ease-in-out,
border-color .1s ease-in-out,
background .2s ease-in-out;
&:hover, &[data-active='1']{
color: #fff;
border-color: $form-neutral-color;
background-color: $form-neutral-color;
}
}
/* (1) valid */
button.valid, .valid > button,
input[type=button].valid, .valid > input[type=button],
input[type=submit].valid, .valid > input[type=submit]{
color: $form-valid-color;
&:hover, &[data-active='1']{
color: #fff;
border-color: $form-valid-color;
background-color: $form-valid-color;
}
}
/* (1) invalid */
button.invalid, .invalid > button,
input[type=button].invalid, .invalid > input[type=button],
input[type=submit].invalid, .invalid > input[type=submit]{
color: $form-invalid-color;
&:hover, &[data-active='1']{
color: #fff;
border-color: $form-invalid-color;
background-color: $form-invalid-color;
}
}
/* (1) search */
button.search, .search > button,
input[type=button].search, .search > input[type=button],
input[type=submit].search, .search > input[type=submit]{
color: $form-search-color;
&:hover, &[data-active='1']{
color: #fff;
border-color: $form-search-color;
background-color: $form-search-color;
}
}
/* (1) valid grey */
button:disabled,
button.grey, .grey > button,
input[type=button].grey, .grey > input[type=button],
input[type=submit].grey, .grey > input[type=submit]{
color: $form-grey-color;
&:hover, &[data-active='1']{
color: #fff;
border-color: $form-grey-color;
background-color: $form-grey-color;
}
cursor: default;
}

View File

@ -1,123 +0,0 @@
@import '../constants';
/* (1) INPUT (neutral) */
input[type=text], .neutral > input[type=text],
input[type=mail], .neutral > input[type=mail],
input[type=password], .neutral > input[type=password],
select, .neutral > select,
input[type=text].neutral,
input[type=mail].neutral,
input[type=password].neutral,
select.neutral{
display: inline-block;
margin: 1em;
padding: .5em 1em;
border-radius: 3px;
border: 1px solid $form-neutral-color;
background-color: #fff;
font-family: inherit;
color: lighten($primary-color, 15%);
transition: border .2s ease-in-out,
color .2s ease-in-out;
&:focus, &:hover{
border-color: darken($form-neutral-color, 10%);
color: $primary-color;
}
}
/* (2) SELECT (neutral) */
select{
width: 100%;
display: block;
background: #fff;
option{
padding: .5em;
}
}
/* (1)(2) valid */
.valid > input[type=text],
.valid > input[type=mail],
.valid > input[type=password],
.valid > select,
input.valid[type=text],
input.valid[type=mail],
input.valid[type=password],
select.valid{
border-color: darken($form-valid-color, 0%);
&:focus, &:hover{
border-color: darken($form-valid-color, 10%);
}
}
/* (1)(2) invalid */
.invalid > input[type=text],
.invalid > input[type=mail],
.invalid > input[type=password],
.invalid > select,
input.invalid[type=text],
input.invalid[type=mail],
input.invalid[type=password],
select.invalid{
border-color: darken($form-invalid-color, 0%);
&:focus, &:hover{
border-color: darken($form-invalid-color, 10%);
}
}
/* (1)(2) search */
.search > input[type=text],
.search > input[type=mail],
.search > input[type=password],
.search > select,
input.search[type=text],
input.search[type=mail],
input.search[type=password]{
border-color: darken($form-search-color, 0%);
&:focus, &:hover{
border-color: darken($form-search-color, 10%);
}
}
/* (1)(2) grey */
.grey > input[type=text],
.grey > input[type=mail],
.grey > input[type=password],
.grey > select,
input.grey[type=text],
input.grey[type=mail],
input.grey[type=password]{
border-color: darken($form-grey-color, 0%);
&:focus, &:hover{
border-color: darken($form-grey-color, 10%);
}
}

View File

@ -1,118 +0,0 @@
@import '../constants';
/* (1) Tag list */
.taglist{
display: flex;
margin-top: 1em;
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;
flex-wrap: wrap;
/* (9.1) inner tags */
& .tag,
& [data-action] .tag + span[data-remove],
& [data-action] .tag + span[data-create]{
display: inline-block;
position: relative;
padding: .2em .5em;
margin-top: .1em;
margin-bottom: .1em;
margin-right: .5em;
border: 1px solid lighten($form-neutral-color, 5%);
border-radius: 3px;
background-color: #f9f9f9;
color: #999;
font-size: .8em;
white-space: nowrap;
cursor: default;
&.valid{ border-color: lighten($form-valid-color, 20%); }
&.invalid{ border-color: lighten($form-invalid-color, 20%); }
&.search{ border-color: lighten($form-search-color, 10%); }
}
/* (9.2) container for action tags */
& [data-action]{
display: flex;
flex-direction: row;
justify-content: center;
flex-wrap: nowrap;
.tag{
border-radius: 3px 0 0 3px;
margin-right: 0;
/* (9.2.1) Removable tags */
& + span[data-remove]{
display: inline-block;
position: relative;
width: .8em;
height: 1.3em;
border-left: 0;
border-radius: 0 3px 3px 0;
background: #fff url('/asset/svg/cross.svg@aaaaaa') center center no-repeat;
background-size: 40% auto;
cursor: pointer;
z-index: 102;
&:hover{ background-image: url('/asset/svg/cross.svg@#{$rd-form-invalid-color}'); }
}
/* (9.2.2) NEW tags */
& + span[data-create]{
display: inline-block;
position: relative;
width: .8em;
height: 1.3em;
border-left: 0;
border-radius: 0 3px 3px 0;
background: #fff url('/asset/svg/plus.svg@aaaaaa') center center no-repeat;
background-size: 40% auto;
cursor: pointer;
z-index: 102;
&:hover{ background-image: url('/asset/svg/plus.svg@#{$rd-form-valid-color}'); }
}
}
}
/* (9.3) select tag */
& select.tag{
height: 1.8em;
margin-left: 0;
padding-right: 1em;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background: transparent url('/asset/svg/down_arrow.svg@bbbbbb') right .5em bottom .1em no-repeat;
background-size: auto 80%;
}
}

View File

@ -7,214 +7,15 @@
top: 0;
left: 0;
width: 100%;
height: calc( #{$header-height-noratio} - 1px );
height: calc( #{$header-height} - 1px );
background-color: $header-bg;
border-bottom: 1px solid #e3e7eb;
// flex properties
flex-direction: row;
justify-content: flex-start;
align-items: center;
font-size: #{$header-font-size-ratio}em;
flex-direction: row;
justify-content: space-around;
align-items: center;
z-index: 150;
/* (1) left-side managers */
& > div.departments,
& > div.versions,
& > div.global-export{
/* (1.1) Current status */
& > div.current{
display: block;
position: relative;
margin-left: 1em;
padding: .5em 1em;
padding-left: .7em;
border: 1px solid #ddd;
border-radius: 3px;
box-shadow: 0 2px 2px #fff;
transition: box-shadow .2s ease-in-out;
cursor: pointer;
// hover animation
&:hover{ box-shadow: 0 2px 2px darken(#fff,10%); }
// current: EXPORT / CREATE / EDIT / REMOVE icons
span.export,
span.create,
span.edit,
span.remove{
display: inline-block;
position: relative;
top: .2em;
width: 1em;
height: 1em;
border-radius: 3px;
background: center center no-repeat;
background-size: 80% auto;
&.export{
background-image: url('/asset/svg/fiche.svg@b8c0c8');
background-size: 100% auto;
&:hover{
background-image: url('/asset/svg/fiche.svg@#{$rd-form-invalid-color}');
}
}
&.create{
background-image: url('/asset/svg/plus.svg@b8c0c8');
&:hover{
background-image: url('/asset/svg/plus.svg@#{$rd-form-valid-color}');
}
}
&.edit{
background-image: url('/asset/svg/a.svg@b8c0c8');
&:hover{
background-image: url('/asset/svg/a.svg@#{$rd-form-search-color}');
}
}
&.remove{
background-image: url('/asset/svg/cross.svg@b8c0c8');
&:hover{
background-image: url('/asset/svg/cross.svg@#{$rd-form-invalid-color}');
}
}
&:last-child{
margin-right: .5em;
}
}
&:hover > span.export{
background-image: url('/asset/svg/fiche.svg@#{$rd-form-invalid-color}');
}
overflow: hidden;
// editable input
& > input[type='text']{
display: inline-block;
position: relative;
width: 100%;
max-width: 10em;
margin: 0;
padding: 0;
border: none;
border-radius: 0;
// background-color: #f00;
font-size: inherit;
color: inherit;
}
}
/* (1.2) Version dialog (to switch to another) */
& > div.department-dialog,
& > div.version-dialog{
display: block;
position: absolute;
margin-top: 0;
margin-left: 0;
&.department-dialog{ margin-left: 1em; }
// padding: 1em .5em;
border: 1px solid #ddd;
border-top: 0;
border-radius: 0 0 3px 3px;
&>:first-child{ border-top: 1px solid #ddd; }
background-color: #fff;
// box-shadow: 0 2px 2px #ddd;
overflow: hidden;
/* (1.2.1) version items */
& > span{
display: block;
position: relative;
padding: .5em 1em;
padding-left: 2em;
background-color: #fff;
transition: background-color .2s ease-in-out;
cursor: pointer;
// hover animation
&:hover{ background-color: darken(#fff, 5%); }
// switch+create icons
&:before{
content: '';
display: block;
position: absolute;
top: calc( 50% - 1em/2 );
left: calc( .5em/2 + 1em/2 );
width: 1em;
height: 1em;
background: url('/asset/svg/switch.svg@#{$rd-form-primary-color}') center center no-repeat;
background-size: auto 80%;
}
// create icon specifications
&[data-id='-1']{
&:before{
background-image: url('/asset/svg/plus.svg@#{$rd-form-valid-color}');
background-size: auto 60%;
}
}
}
}
}
/* (2) Department | Version | Export layout */
& > div.departments > div.current{
margin-right: 0;
padding-left: 1em;
border-radius: 3px 0 0 3px;
}
& > div.versions > div.current{
margin-left: 0;
border-radius: 0;
border-left: 0;
}
& > div.global-export > div.current{
margin-left: 0;
border-radius: 0 3px 3px 0;
border-left: 0;
}
}

View File

@ -13,40 +13,8 @@ body{
width: 100%;
height: 100%;
font-size: 17px;
font-size: 16px;
font-family: 'Fira Sans';
&.loading{
@keyframes fadein{
from{ opacity: 0; }
to{ opacity: 1; }
}
background: #dee6ec;
&:after{
content: "Chargement en cours";
display: block;
position: fixed;
top: 50%;
left: 50%;
color: #333;
font-size: 4vw;
opacity: 0;
text-shadow: 2px 2px 0 #fff;
transform: translateX(-50%) translateY(-50%);
animation: fadein 1s ease-in-out alternate infinite;
}
}
}
@ -104,7 +72,7 @@ body{
}
}
$easter-egg-timeout: 10;
$easter-egg-timeout: 5;
div.icon{
display: block;
@ -281,13 +249,5 @@ body.body404{
}
.downloadButton{
text-decoration: none;
color: #3f4a5e;
box-shadow: 0px 0px 1px 1px #7f8d9b;
background: whitesmoke;
padding: 10px;
border-radius: 2px;
}

View File

@ -25,7 +25,6 @@
// flex properties
flex-direction: column;
justify-content: space-around;
// justify-content: flex-start;
align-items: center;
z-index: 101;
@ -38,13 +37,13 @@
width: $menu-item-width;
height: $menu-item-width;
margin: .5em;
margin-top: .5em;
background: $menu-bg center center no-repeat;
background-size: auto 50%;
transition: background-position .1s ease-in-out;
transition: all .1s ease-in-out;
cursor: pointer;
@ -59,16 +58,20 @@
&[data-icon='login']{ background-image: url('/asset/svg/login.svg@#{$menu-item-inactive}'); }
&[data-icon='logout']{ background-image: url('/asset/svg/logout.svg@#{$menu-item-inactive}'); }
/* (2) On hover */
&:hover, &.active{
background-size: auto 55%;
}
&[data-icon='home']:hover, &[data-icon='home'].active{ background-image: url('/asset/svg/home.svg@10d197'); }
&[data-icon='teacher']:hover, &[data-icon='teacher'].active{ background-image: url('/asset/svg/teacher.svg@edb910'); }
&[data-icon='ue']:hover, &[data-icon='ue'].active{ background-image: url('/asset/svg/ue.svg@1fc9ef'); }
&[data-icon='settings']:hover, &[data-icon='settings'].active{ background-image: url('/asset/svg/settings.svg@dab245'); }
&[data-icon='settings']:hover, &[data-icon='settings'].active{ background-image: url('/asset/svg/settings.svg@545f75'); }
&[data-icon='fiche']:hover, &[data-icon='fiche'].active{ background-image: url('/asset/svg/fiche.svg@ea4C3a'); }
&[data-icon='login']:hover, &[data-icon='login'].active{ background-image: url('/asset/svg/login.svg@dab245'); }
&[data-icon='logout']:hover, &[data-icon='logout'].active{ background-image: url('/asset/svg/logout.svg@dab245'); }
/* (2) Label */
/* (3) Label */
&:after{
content: attr(data-label);
@ -97,7 +100,7 @@
z-index: -1;
}
/* (3) Display label on item hover */
/* (4) Display label on item hover */
&:hover:after{
display: block;
left: calc( 100% + 1em );

View File

@ -1,95 +0,0 @@
/* (1) Reset
---------------------------------------------------------*/
*{
margin: 0;
padding: 0;
}
body{
background-color: #fff;
font-size: 16px;
color: #444;
}
/* (2) Basic layout
---------------------------------------------------------*/
article{
// Titles
h3{
color: #555;
}
// Titles' separators
hr{
display: block;
border-style: solid;
border-width: 1px;
}
// paragraphs
p{
text-indent: 2em;
}
// links
a{
color: #2d92cc;
text-decoration: underline;
}
// quotes
blockquote{
margin-left: 0;
padding-left: 1em;
border-left: 2px solid #eee;
color: #999;
}
// tables
table{
border-collapse: collapse;
color: #555;
tr{
td{
padding: .2em 1em;
border: 1px dotted rgb(221, 221, 221);
background-color: #fff;
}
// each other row is darker
&:nth-child(2n) td{
background-color: #eee;
}
}
// table headers bold revert
thead tr th{
font-weight: normal;
}
thead tr td.color,
thead tr th.color{
background-color: rgb(75, 189, 209);
color: #fff;
}
td.ar{ text-align: right; }
td.ac{ text-align: center; }
td.al{ text-align: left; }
}
}

View File

@ -2,45 +2,9 @@
<div id='HEADER'>
<!-- Department management -->
<div class='departments' data-unblur-department>
<div class='current' data-unblur-department>
<span class='create' @click='!department.create?(department.newLabel="")+(department.create=true):d_create()'></span>
<span class='remove' @click='d_remove()'></span>
<input v-if='department.create' type='text' placeholder='Nouveau nom' v-model='department.newLabel' size=''>
<span v-if='!department.create' @click='department.dialog=!department.dialog' data-unblur-department>{{ get_dcurrent().label }}</span>
</div>
<div class='department-dialog' v-show='department.dialog' data-unblur-department>
<span v-for='d in department.list' v-show='d.id!=department.current' @click='d_switch(d.id)' data-unblur-department>{{ d.label }}</span>
</div>
</div>
<!-- Version management -->
<div class='versions' data-unblur-version>
<div class='current' :data-id='get_vcurrent().id' data-unblur-version>
<span class='remove' @click='v_remove()'></span>
<span class='edit' @click='!version.edit?(version.newName="")+(version.edit=true):v_edit()'></span>
<input v-if='version.edit' type='text' :placeholder='get_vcurrent().name' v-model='version.newName' size=''>
<span v-if='!version.edit' @click='version.dialog=!version.dialog' data-unblur-version>{{ get_vcurrent().name }}</span>
</div>
<div class='version-dialog' v-show='version.dialog' data-unblur-version>
<span v-for='v in version.list' @click='v_switch(v.id)' v-show='v.id!=version.current' :data-id='v.id' data-unblur-version> {{ v.name }} </span>
<span @click='v_create()' data-unblur-version data-id='-1'>Créer</span>
</div>
</div>
<!-- Export all -->
<div class='global-export'>
<div class='current export' @click='global_export()'>
<span class='export'></span>
exporter
</div>
<!-- Header Icon+Title -->
<div id='header-icon'>
<div class='header-title'>{{ gstore.header_title }}</div>
</div>
</div>
@ -54,453 +18,8 @@ export default {
data(){
return {
gstore: gstore.get,
is_connected: _SERVER.session.connected,
department: {
dialog: false,
current: _SERVER.session.department_id,
list: _SERVER.session.departments,
create: false,
newLabel: ''
},
version: {
dialog: false,
current: -1,
list: [],
edit: false,
newName: ''
}
is_connected: _SERVER.session.connected
};
},
methods: {
/* (1) Get current department data
---------------------------------------------------------*/
get_dcurrent(id){
// use @current, if invalid argument @id
( isNaN(id) ) && ( id = this.department.current );
// search in @list where id is @current
for( var d in this.department.list )
if( this.department.list[d].id == id )
return this.department.list[d];
return { id: -2, name: null };
},
/* (2) Get current version data
---------------------------------------------------------*/
get_vcurrent(id){
// use @version.current, if invalid argument @id
( isNaN(id) ) && ( id = this.version.current );
// search in @ist where id is @id
for( var v in this.version.list )
if( this.version.list[v].id == id )
return this.version.list[v];
return { id: -2, name: '-' };
},
/* (3) Switch to other department
---------------------------------------------------------*/
d_switch(id){
// 1. De-activate dialogs
this.department.dialog = false;
this.version.dialog = false;
// 2. Do nothing if no change
if( this.department.current == id )
return;
// 3. Ask for department change
api.call(`PUT department/${id}`, {}, function(rs){
// 1. error -> do nothing
if( rs.error !== 0 || rs.switched !== true )
return;
// 2. Update GUI
this.department.current = id;
// 3. Reload page if needed
setTimeout(() => { document.location = ''; }, 200);
}.bind(this));
},
/* (4) Switch to other version
---------------------------------------------------------*/
v_switch(id){
// 1. De-activate dialogs
this.department.dialog = false;
this.version.dialog = false;
// 2. Do nothing if no change
if( this.version.current == id )
return;
// 3. Ask for department change
api.call(`GET department/version/switch/${id}`, {}, function(rs){
// 1. error -> do nothing
if( rs.error !== 0 )
return;
// 2. Update GUI
this.version.current = id;
// 3. Reload page if needed
setTimeout(() => { document.location = ''; }, 200);
}.bind(this));
},
/* (5) Create a new empty department
---------------------------------------------------------*/
d_create(){
// 1. De-activate dialogs
this.department.dialog = false;
this.version.dialog = false;
// get current department
var cur = this.get_dcurrent();
if( cur.id < 0 || this.department.newLabel.length < 1 ){
this.department.create = false;
return;
}
var newlabel = this.department.newLabel;
// 2. Popup confirm
(new Promise( (resolve, reject) => {
popup.ask({
title: 'Confirmation de création de département',
content: `Le nouveau département <b>${newlabel}</b> va être créé; il ne contiendra aucune donnée, il permet de gérer plusieurs départements ne partageant pas les mêmes UEs, enseignants, formations, etc<br><br>Voulez-vous créer un nouveau département vide ?`,
action: 'Créer',
type: 'valid'
}, (popup_rs) => { popup_rs && resolve() });
// 3. On popup confirm
})).then( () => {
// Call API to create a new department
api.call(`POST department/`, {name:newlabel}, function(rs){
// 1. error -> popup
if( rs.error !== 0 || !rs.hasOwnProperty('created_id') ){
return popup.ask({
title: 'Erreur ('+rs.error+')',
content: 'La création de département a échoué.',
action: 'OK',
type: 'neutral'
}, () => {});
}
// 3. Update GUI
this.department.list.push( { id: parseInt(rs.created_id), name: newlabel } );
}.bind(this));
});
},
/* (5) Create a new version from now
---------------------------------------------------------*/
v_create(){
// 1. De-activate dialogs
this.department.dialog = false;
this.version.dialog = false;
// 2. Popup confirm
(new Promise( (resolve, reject) => {
popup.ask({
title: 'Confirmation de création de version',
content: `Une sauvegarde (ou version) va être crée à partir de l'état actuel des données de tout le département<br><br>Voulez-vous créer cette sauvegarde ?`,
action: 'Créer',
type: 'valid'
}, (popup_rs) => { popup_rs && resolve() });
// 3. On popup confirm
})).then( () => {
let newVersionName = `${this.get_vcurrent().name}*`;
// Call API to create a new version
api.call(`POST department/version/`, {label:newVersionName}, function(rs){
// 1. error -> popup
if( rs.error !== 0 || !rs.hasOwnProperty('created_id') ){
return popup.ask({
title: 'Erreur ('+rs.error+')',
content: 'La création de version à échoué.',
action: 'OK',
type: 'neutral'
}, () => {});
}
// 3. Update GUI
this.version.list.push( { id: parseInt(rs.created_id), name: newVersionName } );
}.bind(this));
});
},
/* (6) Rename a version
---------------------------------------------------------*/
v_edit(){
// get current version
var cur = this.get_vcurrent();
if( cur.id < 0 || this.version.newName.length < 1 ){
this.version.edit = false;
return;
}
var newname = this.version.newName;
// 2. Popup confirm
(new Promise( (resolve, reject) => {
popup.ask({
title: 'Confirmation de modification de version',
content: `La version <b>${cur.name}</b> va être renommée en <b>${newname}</b><br><br>Voulez-vous valider cette modification ?`,
action: 'Valider',
type: 'search'
}, (popup_rs) => { popup_rs && resolve() });
// 3. On popup confirm
})).then( () => {
// Call API to create a new version
api.call(`PUT department/version/${cur.id}`, {label:newname}, function(rs){
// 1. error -> popup
if( rs.error !== 0 || !rs.hasOwnProperty('updated') ){
return popup.ask({
title: 'Erreur ('+rs.error+')',
content: 'La modification a échoué.',
action: 'OK',
type: 'neutral'
}, () => {});
}
// 3. Update GUI
cur.name = newname;
}.bind(this));
}).finally( () => {
this.version.edit = false;
})
},
/* (7) Remove a department
---------------------------------------------------------*/
d_remove(){
// get current department
var cur = this.get_dcurrent();
if( cur.id < 0 )
return;
// if last department -> forbid
if( this.department.list.length < 2 ){
return popup.ask({
title: 'Dernier départment',
content: `Le département <b>${cur.label}</b> ne peut être supprimé car il est le dernier disponible`,
action: 'OK',
type: 'invalid'
});
}
// 2. Popup confirm
(new Promise( (resolve, reject) => {
popup.ask({
title: 'Confirmation de suppression',
content: `Le département <b>${cur.label}</b> va être supprimé. Toutes les données seront perdues de manière définitive</b><br><br>Voulez-vous supprimer ce département ?`,
action: 'Supprimer',
type: 'invalid'
}, (popup_rs) => { popup_rs && resolve() });
// 3. On popup confirm
})).then( () => {
// Call API to delete the current department
api.call(`DELETE department/${cur.id}`, {}, function(rs){
// 1. error -> popup
if( rs.error !== 0 || !rs.hasOwnProperty('deleted') ){
return popup.ask({
title: 'Erreur ('+rs.error+')',
content: 'La suppression a échoué.',
action: 'OK',
type: 'neutral'
}, () => {});
}
// 3. Reload page
document.location = '';
}.bind(this));
});
},
/* (7) Remove a version
---------------------------------------------------------*/
v_remove(){
// get current version
var cur = this.get_vcurrent();
if( cur.id < 0 )
return;
// if last version -> forbid
if( this.version.list.length < 2 ){
return popup.ask({
title: 'Dernière version',
content: `La version <b>${cur.name}</b> ne peut être supprimée car il ne reste aucune autre version pour ce département`,
action: 'OK',
type: 'invalid'
});
}
// 2. Popup confirm
(new Promise( (resolve, reject) => {
popup.ask({
title: 'Confirmation de suppression',
content: `La version <b>${cur.name}</b> va être supprimée. Toutes les données seront perdues de manière définitive</b><br><br>Voulez-vous supprimer cette version ?`,
action: 'Supprimer',
type: 'invalid'
}, (popup_rs) => { popup_rs && resolve() });
// 3. On popup confirm
})).then( () => {
// Call API to create a new version
api.call(`DELETE department/version/${cur.id}`, {}, function(rs){
// 1. error -> popup
if( rs.error !== 0 || !rs.hasOwnProperty('deleted') ){
return popup.ask({
title: 'Erreur ('+rs.error+')',
content: 'La suppression a échoué.',
action: 'OK',
type: 'neutral'
}, () => {});
}
// 3. Reload page
document.location = '';
}.bind(this));
});
},
/* (x) Exports all data about this department's version
---------------------------------------------------------*/
global_export(){
api.call(`GET department/export`, {}, function(rs){
// 1. error -> popup
if( rs.error !== 0 || !rs.hasOwnProperty('link') ){
return popup.ask({
title: 'Erreur ('+rs.error+')',
content: 'L\'export a échoué.',
action: 'OK',
type: 'neutral'
}, () => {});
}
// 2. Launch download
document.location = rs.link;
}.bind(this));
}
},
beforeMount(){
/* (1) Try to fetch versions from API */
api.call('GET department/version', {}, function(rs){
// 1. Manage error
if( rs.error !== 0 || !rs.hasOwnProperty('versions') )
return;
// 2. Init version list
this.version.list = [];
// 3. Store versions
for( var ver of rs.versions ){
// if current version -> set @version.current
if( _SERVER.session.version.current === ver.iddatabase )
this.version.current = ver.iddatabase
// add version to list
this.version.list.push( { id: ver.iddatabase, name: ver.label, new_name: ver.label } );
}
this.version
}.bind(this) );
/* (2) Set onblur to hide department lists */
window.onblur.link('header.department', (e) => {
// only hide not [data-unblur-department] elements
if( e.target.getAttribute('data-unblur-department') === null )
this.department.dialog = false;
// only hide not [data-unblur-version] elements
if( e.target.getAttribute('data-unblur-version') === null )
this.version.dialog = false;
});
}
}
</script>

View File

@ -6,7 +6,7 @@
<div class='icon' @mouseover='gstore.icon.start' @mouseout='gstore.icon.stop'></div>
<div class='title'><b>P</b><i>lateforme</i> <b>A</b><i>ssistée de</i> <b>T</b><i>raitement</i> <b>A</b><i>dministratif des</i> <b>T</b><i>aches d'</i><b>E</b><i>nseignement</i></div>
<button :class='gstore.login_class' @click='gstore.popup_click'>Me connecter</button>
<span :class='gstore.login_class' v-html='gstore.login_error_text'></span>
<span :class='gstore.login_class'>{{ gstore.login_error_text }}</span>
</div>