123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955 |
- <?PHP
- // ------------------------------
- // Caractéristiques du module
- // ------------------------------
- unset($module);
- $module = array(
- "titre" => "Gestion des libérations",
- "urldest" => $SCRIPT_NAME . "?page=liste_liberations",
- "recherche" => array("engin" => true),
- "jeton" => $jeton,
- "opradmin" => "Ajouter une libération",
- "fenetre" => array(
- "nom" => "liste_liberations",
- "titre" => "titre",
- "largeur" => "1200",
- "hauteur" => "500",
- "champs" => array("lnoemployeur", "lnom", "lcontact", "ltitre", "ladresse1", "ladresse2", "lville", "lcodepostal", "ltelephone", "ltelecopieur", "lemail")
- ),
- "msgajoutbouton" => "Ajout de la libération",
- "msgmodifbouton" => "Modification de la libération",
- "actionmodifbouton" => "Modifier la libération",
- "nombre_a_afficher" => array(
- 0 => array("refid" => 15, "valeur" => 15),
- 1 => array("refid" => 30, "valeur" => 30),
- 2 => array("refid" => 45, "valeur" => 45),
- 3 => array("refid" => 60, "valeur" => 60),
- 4 => array("refid" => 120, "valeur" => 120),
- 5 => array("refid" => 240, "valeur" => 240)
- ),
- "colonneaction" => true,
- "lientri" => true,
- "entete" => array(
- 1 => array("Demandée par" => "concat(employes.nomfamille,employes.prenom)", "largeur" => "100px"), //130
- 2 => array("Employé" => "concat(employes.nomfamille, employes.prenom)", "largeur" => "150px"), //130
- 3 => array("Type" => "liberations.typeoperation", "largeur" => "60px"), //78px
- 4 => array("Date" => "ligneliberations.dateliberation", "largeur" => "75px"), //141px
- 5 => array("Article" => "articles.noarticle", "largeur" => "60px"), //65px
- 6 => array("Commentaire" => "ligneliberations.commentaire", "largeur" => "214px"),
- 7 => array("Durée" => "duree.duree", "largeur" => "56px"), //61px
- 8 => array("Lieu" => "ligneliberations.lieu", "largeur" => "89px"),
- 9 => array("Assumée par" => "ligneliberations.quipaye", "largeur" => "75px"), //105px
- 10 => array("Paiement" => "ligneliberations.paiement", "largeur" => "84px", "droit" => array("gestion_site" => "Oui")),
- 11 => array("En date du" => "ligneliberations.datepaiement", "largeur" => "88px", "droit" => array("gestion_site" => "Oui")), //95px
- 12 => array("<img alt=\"Pdf\" src=\"images/pdficon_small.gif\">" => "-1", "largeur" => "22px"),
- 13 => array("<img alt=\"Pdf\" src=\"images/icones/icones_20.png\">" => "-1", "largeur" => "22px")
- ),
- "msg" => array(
- "maj_ok" => "Création de la libération effectuée avec succès.",
- "maj_echec" => "L'opération de création de la libération a échouée.",
- "modif_ok" => "Modification de la libération effectuée avec succès.",
- "modif_echec" => "L'opération de modification de la libération a échouée.",
- "typeopr" => "Le type d'opération n'a pas été sélectionné.",
- "datecreation" => "La date de création n'a pas été inscrite ou est invalide.",
- "choixemp" => "L'employé n'a pas été sélectionné.",
- "dateliberation" => "Le format de la date de libération est invalide.",
- "numeroart" => "Le numéro d'article est inconnu.",
- "dateoccupee" => "La date de libération est déjà prise pour le même article pour ce membre.",
- "annulationimpossible" => "Il n'y a aucune demande de libération à annuler pour ce membre.",
- "dureevide" => "La durée est inconnue.",
- "commentairevide" => "Le commentaire est vide.",
- "lieuvide" => "Le lieu est vide.",
- "quipaye" => "L'organisme payeur n'a pas été choisit.",
- "rech_ok" => "La recherche a réussie.",
- "rech_echec" => "La recherche a été infructueuse ou a échouée.",
- "employeur_invalide" => "Employeur introuvable ou inconnu.",
- "annulationDemandee" => "Annulation de la demande déjà effectuée"
- )
- );
- // ------------------
- // Requête sur le tri
- // ------------------
- $rtri = antiInjection($module["entete"][$tri][key($module["entete"][$tri])] . " " . $dir);
- // -----------------------
- // Opération de sauvegarde
- // -----------------------
- //Conversion de la variable actionmultiple en action pour éviter le conflit.
- if (!empty($actionmultiple) && $actionmultiple != "-1") {
- $action = $actionmultiple;
- }
- if (isset($action)) {
- $msg = "";
- //Cueillette de données du module
- $action = stripslashes(antiInjection($action));
- //$noliberation = stripslashes(antiInjection($noliberation));
- switch ($action) {
- case "Accepter et imprimer":
- case "Accepter et envoyer par courriel":
- case "Modifier":
- case "Modifier et imprimer":
- unset($opereussie);
- unset($erreurid);
- unset($modemodif);
- $modemodif = false;
- $opereussie = true;
- if ($action == "Modifier" || $action == "Modifier et imprimer") {
- $modemodif = true;
- }
- if ($ltypeopr != "" && $ldatecreation != "" && $lreference != "") {
- // Validation du type d'opération
- $rltypeopr2 = antiInjection($ltypeopr);
- if ($rltypeopr2 != "1" && $rltypeopr2 != "2") {
- $opereussie = false;
- $erreurid = "typeopr";
- break;
- }
- // Validation de la date de création
- $rldatecreation = antiInjection($ldatecreation);
- if (strtotime($rldatecreation) == false) {
- $opereussie = false;
- $erreurid = "datecreation";
- break;
- }
- // La référence est le numéro de l'employé dans la bd
- $rlreference = antiInjection($lreference);
- unset($sqlparam, $result);
- $sqlparam["table"][] = "employes";
- $sqlparam["champs"][] = "CONCAT(nomfamille,\", \",prenom) as nomemploye";
- $sqlparam["where"][] = sprintf("refemploye = %d", $rlreference);
- $result = executerRequeteSql($sqlparam);
- if (!(isset($result) && is_array($result) && count($result) > 0)) {
- $msg = sprintf("L'employé «%s» n'est pas un membre connu.", $nomemploye);
- $opereussie = false;
- $erreurid = "choixemp";
- }
- // Conditions de base remplies
- // Le type d'opération
- // L'employé
- // La date de création du document
- // Toujours pas d'erreur, nous continuons.
- if ($opereussie) {
- //Lecture du numéro d'employé
- $nomemploye = $result[0]["nomemploye"];
- // Les différents tableaux de données
- $rdatelib = $datelib;
- $rlarticle = $larticle;
- $rcommentaire = $commentaire;
- $rlduree = $lduree;
- $rlieu = $lieu;
- $rlassumerpar = $lassumerpar;
- if ($action == "Modifier" || $action == "Modifier et imprimer") {
- $rlpaiement = $lpaiement;
- $rldatepaiement = $datepaiement;
- $rligneliberation = $ligneliberation;
- }
- //Calcul du nombre de ligne ;à insérer
- $nombreligne = sizeof($rdatelib);
- $nombreligne2 = $nombreligne;
- // Tableau des requêtes SQL à effectuer
- $tableausql = array();
- //Ajout du détail de la libération pour chaque ligne
- for ($x = 0; $x < $nombreligne; $x++) {
- // Validation sur la date
- $rdatelib2 = antiInjection($rdatelib[$x]);
- if (strtotime($rdatelib2) == false) {
- $opereussie = false;
- $erreurid = "dateliberation";
- break;
- }
- // Validation sur l'article
- $rlarticle2 = antiInjection($rlarticle[$x]);
- unset($sqlparam, $result1);
- $sqlparam["table"][] = "articles";
- $sqlparam["champs"][] = "refarticle";
- $sqlparam["where"][] = sprintf("refarticle='%s'", $rlarticle2);
- $result1 = executerRequeteSql($sqlparam);
- if (isset($result1) && is_array($result1) && sizeof($result1) > 0) {
- $refarticle = $result1[0]["refarticle"];
- } else {
- $opereussie = false;
- $erreurid = "numeroart";
- break;
- }
- //Validation sur le commentaire
- $rcommentaire2 = antiInjection($rcommentaire[$x]);
- if (empty($rcommentaire2)) {
- $opereussie = false;
- $erreurid = "commentairevide";
- break;
- }
- // Validation sur la durée
- $rlduree2 = antiInjection($rlduree[$x]);
- unset($sqlparam, $result2);
- $sqlparam["table"][] = "duree";
- $sqlparam["champs"][] = "refduree";
- $sqlparam["champs"][] = "duree";
- $sqlparam["where"][] = sprintf("refduree=%d", $rlduree2);
- $result2 = executerRequeteSql($sqlparam);
- if (isset($result2) && is_array($result2) && sizeof($result2) > 0) {
- $refduree = $result2[0]["refduree"];
- } else {
- $opereussie = false;
- $erreurid = "dureevide";
- break;
- }
- // Validation sur le lieu
- $rlieu2 = antiInjection($rlieu[$x]);
- if (empty($rlieu2)) {
- $opereussie = false;
- $erreurid = "lieuvide";
- break;
- }
- // Validation sur le payeur
- $rlassumerpar2 = antiInjection($rlassumerpar[$x]);
- if ($rlassumerpar2 != "Syndicat" && $rlassumerpar2 != "Employeur") {
- $opereussie = false;
- $erreurid = "quipaye";
- break;
- }
- //Validation sur le paiement
- if ($modemodif) {
- $rlpaiement2 = antiInjection($rlpaiement[$x]);
- $rldatepaiement2 = antiInjection($rldatepaiement[$x]);
- }
- // Date déjà demandée pour le même employé selon l'article
- unset($sqlparam, $result3);
- $sqlparam["table"][] = "liberations";
- $sqlparam["table"][] = "ligneliberations";
- $sqlparam["table"][] = "articles";
- $sqlparam["table"][] = "duree";
- $sqlparam["join"][] = "ligneliberations.refliberation = liberations.refliberation";
- $sqlparam["join"][] = "articles.refarticle=ligneliberations.refarticle";
- $sqlparam["join"][] = "duree.refduree=ligneliberations.duree";
- $sqlparam["champs"][] = "liberations.refemploye";
- $sqlparam["champs"][] = "articles.refarticle";
- $sqlparam["champs"][] = "unix_timestamp(ligneliberations.dateliberation) as dateliberation";
- $sqlparam["champs"][] = "SUM(If(liberations.typeoperation=1,duree.dureeNombre,0-dureeNombre)) AS calculduree";
- $sqlparam["groupe"][] = "liberations.refemploye";
- $sqlparam["groupe"][] = "ligneliberations.dateliberation";
- $sqlparam["groupe"][] = "articles.refarticle";
- $sqlparam["where"][] = sprintf("ligneliberations.refarticle=%d", $rlarticle2);
- $sqlparam["where"][] = "DATE_FORMAT(ligneliberations.dateliberation,'%Y-%m-%d')='$rdatelib2'";
- $sqlparam["where"][] = "liberations.refemploye=$rlreference";
- if ($modemodif) {
- $sqlparam["where"][] = sprintf("ligneliberations.refligneliberation<>%d", $rligneliberation[$x]);
- }
- $result3 = executerRequeteSql($sqlparam);
- if (isset($result3) && is_array($result3) && sizeof($result3) > 0) {
- if ($result3[0]["calculduree"] > 0 && $ltypeopr == 1) {
- $opereussie = false;
- $erreurid = "dateoccupee";
- $x = $nombreligne + 1;
- break;
- } elseif ($result3[0]["calculduree"] == 0 && $ltypeopr == 2) {
- $opereussie = false;
- $erreurid = "annulationimpossible";
- $x = $nombreligne + 1;
- break;
- }
- }
- if ($opereussie) {
- unset($sqlparam);
- if (!$modemodif) {
- $sqlparam["type"] = "INSERT";
- $sqlparam["champs"]["paiement"] = 0;
- } else {
- $sqlparam["type"] = "UPDATE";
- $sqlparam["where"][] = "ligneliberations.refligneliberation = " . sprintf("%d", $rligneliberation[$x]);
- $sqlparam["champs"]["paiement"] = sprintf("%d", $rlpaiement2);
- if ($rlpaiement2 == 2 && !empty($rldatepaiement2)) {
- $sqlparam["champs"]["datepaiement "] = sprintf("'%s'", $rldatepaiement2);
- }
- }
- $sqlparam["table"][] = "ligneliberations";
- $sqlparam["champs"]["dateliberation"] = sprintf("'%s'", "$rdatelib2 12:00:00");
- $sqlparam["champs"]["refarticle "] = sprintf("%d", $refarticle);
- $sqlparam["champs"]["commentaire "] = sprintf("'%s'", $rcommentaire2);
- $sqlparam["champs"]["duree "] = sprintf("%d", $refduree);
- $sqlparam["champs"]["lieu"] = sprintf("'%s'", $rlieu2);
- $sqlparam["champs"]["quipaye"] = sprintf("'%s'", $rlassumerpar2);
- $tableausql[] = $sqlparam;
- }
- }
- unset($cpt_opr);
- $cpt_opr = 0;
- if ($opereussie) {
- unset($sqlparam2);
- if (!$modemodif) {
- // Création de la libération
- unset($sqlparam);
- $sqlparam["type"] = "INSERT";
- $sqlparam["table"][] = "liberations";
- $sqlparam["champs"]["refemploye"] = sprintf("%d", $rlreference);
- $sqlparam["champs"]["datedemande"] = sprintf("'%s'", $rldatecreation . " 00:00");
- $sqlparam["champs"]["typeoperation"] = sprintf("%d", $rltypeopr2);
- $result = executerRequeteSql($sqlparam);
- $valeurnolib = $result;
- $sqlparam2 = $sqlparam;
- } else {
- $valeurnolib = antiInjection($liberation);
- }
- //Ajout du détail de la libération pour chaque ligne
- $nombreligne2 = sizeof($rdatelib);
- for ($x = 0; $x < $nombreligne2; $x++) {
- $tableausql[$x]["champs"]["refliberation"] = sprintf('%d', $valeurnolib);
- $result = executerRequeteSql($tableausql[$x]);
- if (isset($result)) {
- $cpt_opr++;
- }
- }
- // Suivi de création (auteur, date, commande sql)
- unset($sqlparam);
- if (!$modemodif) {
- $sqlparam["type"] = "INSERT";
- $sqlparam["champs"]["refliberation"] = sprintf("%d", $valeurnolib);
- $sqlparam["champs"]["utilisateur"] = sprintf("'%s'", $_SESSION['nomreel']);
- } else {
- $sqlparam["type"] = "UPDATE";
- $sqlparam["where"][] = "refliberation = " . sprintf("%d", $valeurnolib);
- }
- $sqlparam["champs"]["date"] = "'" . date("Y-m-d H:i:s") . "'"; //sprintf("'%s'", $rldatecreation . " 00:00");
- $sqlparam["table"][] = "suivilib";
- $result = executerRequeteSql($sqlparam);
- }
- }
- } else {
- $opereussie = false;
- if ($ltypeopr == "") {
- $erreurid = "typeopr";
- } elseif ($ldatecreation == "") {
- $erreurid = "datecreation";
- } elseif ($lreference == "") {
- $erreurid = "choixemp";
- }
- }
- unset($lreference);
- break;
- case "Copier la demande de libération":
- unset($opereussie);
- unset($erreurid);
- unset($modemodif);
- $modemodif = false;
- $opereussie = true;
- if ($ltypeopr != "" && $noliberation != "") {
- if (isLiberationCanceledCompletely($noliberation)) {
- unset($sqlparam, $result);
- $sqlparam["mode"] = "direct";
- $sqlparam["type"] = "INSERT";
- $sqla = "insert into liberations (refemploye, datedemande, typeoperation, archive) ";
- $sqlb = "SELECT refemploye, datedemande, typeoperation, 0 ";
- $sqlc = "from liberations ";
- $sqld = sprintf("where refliberation = %d", $noliberation);
- $sqlparam["sql"] = "$sqla $sqlb $sqlc $sqld";
- $result = executerRequeteSql($sqlparam);
- unset($sqlparam);
- $sqlparam["type"] = "INSERT";
- $sqlparam["mode"] = "direct";
- $sqle = "insert into ligneliberations (refliberation, dateliberation, refarticle, commentaire, duree, lieu, quipaye, datepaiement, paiement, archive) ";
- $sqlf = sprintf("SELECT %d, dateliberation, refarticle, commentaire, duree, lieu, quipaye, datepaiement, paiement, archive ", $result);
- $sqlg = "FROM ligneliberations ";
- $sqlh = sprintf("where refliberation = %d", $noliberation);
- $sqlparam["sql"] = "$sqle $sqlf $sqlg $sqlh";
- $result2 = executerRequeteSql($sqlparam);
- // Suivi de création (auteur, date, commande sql)
- unset($sqlparam, $result3);
- $sqlparam["type"] = "INSERT";
- $sqlparam["table"][] = "suivilib";
- $sqlparam["champs"]["refliberation"] = sprintf("%d", $result);
- $sqlparam["champs"]["utilisateur"] = sprintf("'%s'", $_SESSION['nomreel']);
- $sqlparam["champs"]["date"] = "'" . date("Y-m-d H:i:s") . "'";
- $result3 = executerRequeteSql($sqlparam);
- $module["msg"]["maj_ok"] = "Copie de la demande de libération réussie";
- $cpt_opr = 1;
- $nombreligne = 1;
- $opereussie = true;
- }
- }
- break;
- /* case "Annuler toutes les libérations":
- print $noliberation;
- break;
- unset($opereussie);
- unset($erreurid);
- unset($modemodif);
- $modemodif = false;
- $opereussie = true;
- if ($ltypeopr != "" && $noliberation != "") {
- if (!checkIfLiberationIsCanceledCompletely($noliberation)) {
- unset($sqlparam, $result);
- $sqlparam["type"] = "INSERT";
- $sqlparam["mode"] = "direct";
- $sqla = "insert into liberations (refemploye, datedemande, typeoperation, archive) ";
- $sqlb = "SELECT refemploye, datedemande, 2, 0 ";
- $sqlc = "from liberations ";
- $sqld = sprintf("where refliberation = %d", $noliberation);
- $sqlparam["sql"] = "$sqla $sqlb $sqlc $sqld";
- $result = executerRequeteSql($sqlparam);
- unset($sqlparam);
- $sqlparam["type"] = "INSERT";
- $sqlparam["mode"] = "direct";
- $sqle = "insert into ligneliberations (refliberation, dateliberation, refarticle, commentaire, duree, lieu, quipaye, datepaiement, paiement, archive) ";
- $sqlf = sprintf("SELECT %d, dateliberation, refarticle, commentaire, duree, lieu, quipaye, datepaiement, paiement, %d, archive ", $result, $noliberation);
- $sqlg = "FROM ligneliberations ";
- $sqlh = sprintf("where refliberation = %d", $noliberation);
- $sqlparam["sql"] = "$sqle $sqlf $sqlg $sqlh";
- $result2 = executerRequeteSql($sqlparam);
- // Suivi de création (auteur, date, commande sql)
- unset($sqlparam);
- $sqlparam["type"] = "INSERT";
- $sqlparam["table"][] = "suivilib";
- $sqlparam["champs"]["refliberation"] = sprintf("%d", $result);
- $sqlparam["champs"]["utilisateur"] = sprintf("'%s'", $_SESSION['nomreel']);
- $sqlparam["champs"]["date"] = "'" . date("Y-m-d H:i:s") . "'";
- $result3 = executerRequeteSql($sqlparam);
- $module["msg"]["maj_ok"] = "Annulation de la demande de libération réussie";
- $cpt_opr = 1;
- $nombreligne = 1;
- $opereussie = true;
- } else {
- //Pour simuler une erreur, requis plus bas
- $cpt_opr = 1;
- $nombreligne = 2;
- $erreurid = "annulationDemandee";
- $opereussie = true;
- }
- }
- break; */
- case "Annuler ces libérations":
- if (empty($actionmulti)) {
- break;
- }
- $taille = sizeof($actionmulti);
- //var_export($actionmulti);
- unset($opereussie);
- unset($erreurid);
- unset($modemodif);
- $modemodif = false;
- $opereussie = true;
- //printf ("rep: %b", checkIfLiberationIsCanceledCompletely($noliberation));
- if ($ltypeopr != "" && $noliberation != "") {
- $varresult = isLiberationCanceledCompletely($noliberation);
- if (!is_null($varresult) && !$varresult) {
- //Construit la clause where avec le numéro des lignes de détail à annuler.
- $valueWhere = "";
- foreach ($actionmulti as $clef) {
- $valueWhere .= $clef . ", ";
- }
- $valueWhere = substr(trim($valueWhere), 0, -1);
- $cpt_opr = 1;
- $nombreligne = 1;
- unset($sqlparam, $result);
- $sqlparam["type"] = "INSERT";
- $sqlparam["mode"] = "direct";
- $sqla = "insert into liberations (refemploye, datedemande, typeoperation, demandeOriginale, archive) ";
- $sqlb = sprintf("SELECT refemploye, datedemande, 2, %d, 0 ", $noliberation);
- $sqlc = "from liberations ";
- $sqld = sprintf("where refliberation = %d", $noliberation);
- $sqlparam["sql"] = "$sqla $sqlb $sqlc $sqld";
- $result = executerRequeteSql($sqlparam);
- unset($sqlparam);
- $sqlparam["type"] = "INSERT";
- $sqlparam["mode"] = "direct";
- $sqle = "insert into ligneliberations (refliberation, dateliberation, refarticle, commentaire, duree, lieu, quipaye, datepaiement, paiement, demandeOriginale, archive) ";
- $sqlf = sprintf("SELECT %d, dateliberation, refarticle, commentaire, duree, lieu, quipaye, datepaiement, paiement, refligneliberation, archive ", $result);
- $sqlg = "FROM ligneliberations ";
- $sqlh = sprintf("where refligneliberation in (%s)", $valueWhere);
- $sqlparam["sql"] = "$sqle $sqlf $sqlg $sqlh";
- $result2 = executerRequeteSql($sqlparam);
- // Suivi de création (auteur, date, commande sql)
- unset($sqlparam);
- $sqlparam["type"] = "INSERT";
- $sqlparam["table"][] = "suivilib";
- $sqlparam["champs"]["refliberation"] = sprintf("%d", $result);
- $sqlparam["champs"]["utilisateur"] = sprintf("'%s'", $_SESSION['nomreel']);
- $sqlparam["champs"]["date"] = "'" . date("Y-m-d H:i:s") . "'";
- $result3 = executerRequeteSql($sqlparam);
- $module["msg"]["maj_ok"] = "Annulation de la demande de libération réussie";
- $cpt_opr = 1;
- $nombreligne = 1;
- $opereussie = true;
- } else {
- //Pour simuler une erreur, requis plus bas
- $cpt_opr = 1;
- $nombreligne = 2;
- $erreurid = "annulationDemandee";
- $opereussie = true;
- }
- }
- break;
- }
- }
- if (isset($opereussie)) {
- if ($cpt_opr == $nombreligne) {
- $module["resultatSQL"] = true;
- if (!$modemodif) {
- $module["message"] = $module["msg"]["maj_ok"];
- } else {
- $module["message"] = $module["msg"]["modif_ok"];
- }
- } else {
- $module["resultatSQL"] = false;
- $module["message"] = $module["msg"][$erreurid];
- }
- }
- unset($periode);
- unset($datedebut, $datefin);
- $datedebut = getPeriodeCourante("début");
- $datefin = getPeriodeCourante("fin");
- $sqla = "(DATE_FORMAT(ligneliberations.dateliberation,\"%Y-%m-%d\") Between ";
- $sqlb = sprintf("\"%s\" And \"%s\") ", $datedebut, $datefin);
- $periode = "$sqla$sqlb";
- unset($sqlparam);
- $sqlparam["compte"] = "liberations.refliberation";
- $sqlparam["table"][] = "liberations";
- $sqlparam["table"][] = "ligneliberations";
- $sqlparam["table"][] = "employes";
- $sqlparam["table"][] = "articles";
- $sqlparam["table"][] = "duree";
- $sqlparam["table"][] = "suivilib";
- $sqlparam["join"][] = "ligneliberations.refliberation=liberations.refliberation";
- $sqlparam["join"][] = "liberations.refemploye=employes.refemploye";
- $sqlparam["join"][] = "ligneliberations.refarticle=articles.refarticle";
- $sqlparam["join"][] = "ligneliberations.duree=duree.refduree";
- $sqlparam["join"][] = array(0 => "left", 1 => "suivilib.refliberation=liberations.refliberation");
- $sqlparam["champs"][] = "employes.refemploye";
- $sqlparam["champs"][] = "concat(employes.nomfamille,\" \",employes.prenom) as nomemploye";
- $sqlparam["champs"][] = "liberations.typeoperation";
- $sqlparam["champs"][] = "unix_timestamp(ligneliberations.dateliberation) as dateliberation";
- $sqlparam["champs"][] = "articles.noarticle";
- $sqlparam["champs"][] = "ligneliberations.commentaire";
- $sqlparam["champs"][] = "duree.duree";
- $sqlparam["champs"][] = "ligneliberations.paiement";
- $sqlparam["champs"][] = "ligneliberations.quipaye";
- $sqlparam["champs"][] = "IF(ISNULL(ligneliberations.datepaiement),'',UNIX_TIMESTAMP(ligneliberations.datepaiement)) as datepaiement";
- $sqlparam["champs"][] = "ligneliberations.lieu";
- $sqlparam["champs"][] = "suivilib.utilisateur";
- $sqlparam["champs"][] = "liberations.refliberation";
- if (isset($ListeEmployeurs) && $ListeEmployeurs != "-1") {
- $sqlparam["where"][] = sprintf("employes.refemployeur=%d", $ListeEmployeurs);
- }
- if (isset($ListeEmployes) && $ListeEmployes != -1) {
- $sqlparam["where"][] = sprintf("employes.refemploye= %d", $ListeEmployes);
- }
- $sqlparam["limite"] = ($nombreaffiche * ($nopage - 1)) . "," . $nombreaffiche + 1;
- $sqlparam["ordre"][] = $rtri;
- if (isset($lreference) && !empty($lreference)) {
- $sqlparam["where"][] = "employes.refemploye=" . antiInjection($lreference);
- $module["recherche"]["lreference"] = $lreference;
- $module["recherchetri"] = $rtri;
- } elseif (isset($zonerecherche) && !empty($zonerecherche)) {
- $sqlparam["where"][] = "CONCAT(' ',employes.nomfamille, ' ',employes.prenom, articles.noarticle, duree.duree, ligneliberations.commentaire, ligneliberations.lieu, ligneliberations.datepaiement) like '%" . antiInjection($zonerecherche) . "%'";
- $module["recherche"]["zonerecherche"] = $zonerecherche;
- $module["recherchetri"] = $rtri;
- }
- //Si l'utilisateur fait partie d'un syndicat local
- if ($_SESSION['gestion_site'] < 'Oui') {
- $sqlparam["where"][] = sprintf("employes.refemployeur=%d", $_SESSION['employeur']);
- }
- // Selon la période en cours
- $sqlparam["where"][] = $periode;
- if (isset($ListeEmployeurs) && $ListeEmployeurs != "-1") {
- $module["listeEmployeurs"] = $ListeEmployeurs;
- } else {
- $module["listeEmployeurs"] = null;
- }
- if (isset($ListeEmployes) && $ListeEmployes != -1) {
- $module["listeEmployes"] = $ListeEmployes;
- } else {
- $module["listeEmployes"] = null;
- }
- $result = executerRequeteSql($sqlparam);
- if (isset($result) && is_array($result) && count($result) > 0) {
- $module["compte"] = $result[0]["compte"];
- } else {
- $module["compte"] = 0;
- }
- $i = 1;
- print preparerModule($module);
- //Liste principale;
- if (isset($result) && is_array($result)) {
- if (count($result) > 0) {
- $i = ($nopage - 1) * $nombreaffiche + 1;
- foreach ($result as $clef => $champs) {
- if ($i > ($nopage * $nombreaffiche)) {
- continue;
- }
- $type = ($champs["typeoperation"] == 1) ? "Demande" : "Annulation";
- $lieu = $champs["lieu"];
- $quipaye = $champs["quipaye"];
- if ($quipaye == "0") {
- $quipaye = "Indéterminé";
- }
- $datepaiement = ($champs["datepaiement"] == '0') ? "Non-assigné" : date("Y-m-d", $champs["datepaiement"]);
- $couleur = ($champs["typeoperation"] == 1) ? "" : "color:#ff0000;";
- $style = 'border:1px solid #cfcfcf; overflow:hidden; white-space:nowrap;';
- print "<tr style='$couleur' $couleur>\n";
- print "<td style='$style'>$i</td>\n";
- print "<td style='$style'>" . ecrireTexteLimite($champs["utilisateur"], 100) . "</td>\n";
- print "<td style='$style'>" . ecrireTexteLimite($champs["nomemploye"], 150) . "</td>\n";
- print "<td style='$style' title=\"$type\">$type</td>\n";
- print "<td style='$style' title=\"" . date("Y-m-d", $champs["dateliberation"]) . "\">" . date("Y-m-d", $champs["dateliberation"]) . "</td>\n";
- print "<td style='$style' title=\"" . $champs["noarticle"] . "\">" . $champs["noarticle"] . "</td>\n";
- print "<td style='$style' title=\"" . $champs["commentaire"] . "\"><div style='overflow:hidden; white-space:nowrap; width:202px;'>" . htmlentities($champs["commentaire"], ENT_SUBSTITUTE, "UTF-8") . "</div></td>\n";
- print "<td style='$style' title=\"" . $champs["duree"] . "\">" . $champs["duree"] . "</td>\n";
- print "<td style='$style'>" . ecrireTexteLimite($lieu, 79) . "</td>\n";
- print "<td style='$style' title=\"$quipaye\">$quipaye</td>\n";
- //TODO à corriger
- if ($_SESSION["gestion_site"] >= "Oui") {
- if ($champs["paiement"] == "0") {
- print "<td style='$style' title=\"Non-assigné\">Non-assigné</td>\n";
- print "<td style='$style' title=\"Non-assigné\">Non-assigné</td>\n";
- } elseif ($champs["paiement"] == "1") {
- print "<td style='$style' title=\"Non\">Non</td>\n";
- print "<td style='$style' title=\"À venir\">À venir</td>\n";
- } else {
- print "<td style='$style' title=\"Oui\">Oui</td>\n";
- print "<td style='$style' title=\"$datepaiement\">$datepaiement</td>\n";
- }
- }
- print "<td style='$style'><a href='#' onclick='ouvrefenetre(\"creation_liberation.php?lib=" . $champs["refliberation"] . "&sortie=ecran\");'><img alt=\"pdf\" src=\"images/pdficon_small.gif\"></a></td>\n";
- if ($_SESSION['gestion_site'] >= "Oui") {
- print "<td style='$style'>\n";
- //if (!checkIfLiberationIsCanceled($champs["refliberation"] )) {
- print "<INPUT class='modifier' title='Modifier' id='Modifier' TYPE='button' VALUE='Modifier' onclick=\"modifieLiberation(" . $champs["refemploye"] . "," . $champs["refliberation"] . ",'" . $GLOBALS["jeton"] . "');\">\n";
- //}
- print "</td>\n";
- } else {
- print "<td style='$style'> </td>\n";
- }
- print "</tr>\n";
- $i++;
- }
- } else {
- print "<tr><td colspan='12' style='text-align:center;'><h1>Aucune donnée pour la période sélectionnée.</h1></td></tr>";
- }
- }
- print"</table>";
- // Pagination
- print "<table style='width:1200px; margin:auto;'>";
- print "<tr><td style='vertical-align:bottom;'>";
- print $seqpage;
- print "</td>";
- print "<td style='width:320px; text-align:right;'>";
- //Haut de page
- if ($nombreaffiche > 15) {
- print "<a href='#hautpage' title='Aller en haut de la page'>Haut de page</a>";
- print "<a name='baspage'>";
- }
- print "</td></tr>";
- print "</table>";
- print "<span id='simon'></span>";
- print fenetreModaleDebut($module["fenetre"], $SCRIPT_NAME, $jeton);
- unset($titretemp);
- if (isset($module["actionajoutbouton"])) {
- $titretemp = $module["actionajoutbouton"];
- }
- $titretemp = 'Formulaire de détail';
- print fenetreModaleFin($titretemp);
- unset($cpt, $vide);
- $vide = true;
- ?>
- <script type="text/javascript" src='js/liberations.js'></script>
- <script type="text/javascript">
- //Ajoute la date du jour dans la case Date
- function metsDate(id) {
- if (verifieinfo()) {
- $("#" + id).val("<?php print date("Y-m-d"); ?>");
- $("#" + id).focus();
- }
- }
- //Vérifie si la date est déjà prise.
- function verifieDate(idm, id2) {
- //Vérification de la date si déjà prise pour la même employée.
- if (reponseBoolDate) {
- var typeopr;
- var notype;
- if ($("#opr1").prop('checked') || $("#opr").val() === "1") {
- typeopr = "demande";
- notype = 1;
- } else if ($("#opr2").prop('checked') || $("#opr").val() === "2") {
- typeopr = "annulation";
- notype = 2;
- }
- if ($("#lreference").val() !== "" && $("#" + idm).val() !== "") {
- var resultat = $.ajax({
- url: "obtdatelib.php",
- global: false,
- type: "POST",
- data: {
- prm1: escape($("#lreference").val()), // no de employe
- prm2: escape($("#" + idm).val()), // date de libération
- prm3: escape($("#" + id2).val()), // no article
- prm4: escape(notype) //1=demande, 2 = annulation
- },
- dataType: "html",
- async: false,
- error: function () {
- $("#" + id2).datepicker("hide");
- },
- success: function () {
- $("#" + id2).datepicker("hide");
- }
- }).responseText;
- if (resultat === "accepte") {
- if (nombre > 1) {
- for (x = 0; x < nombre; x++) {
- var nombrev = parseInt(idm.substring(2));
- if (x !== nombrev) {
- if ($("#" + idm).val() === $("#id" + x).val()) {
- resultat = "occupedate_" + typeopr;
- }
- }
- }
- }
- }
- if (resultat.indexOf("occupedatearticle") > -1) {
- var tablovide = resultat.split("_");
- var typeoprtemp = tablovide[1];
- jChoice("Cette date de libération (" + $("#" + idm).val() + ") avec l'article " + $("#" + id2 + " option:selected").text() + " pour ce membre (" + $("#zonerecherche2").val() + ") a déjà été demandée auparavant dans une " + typeoprtemp + "!\nVoulez-vous consulter le générateur de rapport?",
- function (r) {
- if (r) {
- window.location.href = "index2.php?page=generateur_rapports&jeton=<?php print $jeton; ?>";
- } else {
- $("#" + id2).val(0);
- $("#" + idm).val("");
- $("#" + idm).focus();
- }
- });
- reponseBoolDate = false;
- } else if (resultat.indexOf('occupedate') > -1 && resultat.indexOf('article') === -1 && (resultat.indexOf("_demande") > -1 || resultat.indexOf("_annulation") > -1)) {
- var typeoprtemp = "";
- var tablovide = resultat.split("_");
- typeoprtemp = tablovide[1];
- jChoice("Cette date de libération (" + $("#" + idm).val() + ") pour ce membre (" + $("#zonerecherche2").val() + ") a déjà été demandée auparavant dans une " + typeoprtemp + "!\nVoulez-vous consulter le générateur de rapport?",
- function (r) {
- if (r) {
- window.location.href = "index2.php?page=generateur_rapports&jeton=<?php print $jeton; ?>";
- } else {
- $("#" + idm).val("");
- $("#" + idm).focus();
- }
- });
- reponseBoolDate = false;
- } else if (resultat.indexOf('refus_annulation') > -1) {
- jAlert("Il n'y a pas de demande de libérations à annuler pour ce membre (" + $("#zonerecherche2").val() + ") à cette date!");
- $("#" + idm).val("");
- $("#" + idm).focus();
- reponseBoolDate = false;
- }
- }
- reponseBoolDate = false;
- }
- }
- // Ajoute une ligne à la table
- function addRow(id) {
- var thisnombre = nombre;
- var v1 = verifieinfo();
- var v2 = verifieLigne(thisnombre);
- if (v1 && v2) {
- var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];
- var col1 = "<input name=\"datelib[]\" style='min-width:80px;' value=\"\" id=\"id" + thisnombre + "\" onfocus=\"verifieinfo();\" onblur=\"verifieDate('id" + thisnombre + "','lart" + thisnombre + "');\" >";
- var col1b = "<img alt=\"Calendrier\" src=\"images/calendar.gif\" class=\"calendrier\" id=\"butdate" + thisnombre + "\" onclick =\"calendrier('id" + thisnombre + "');\">";
- var col3 = "<input class='boite_commentaire' name=\"commentaire[]\" id=\"com" + thisnombre + "\" value=\"\">";
- var col5 = "<input name=\"lieu[]\" id=\"lie" + thisnombre + "\" value=\"\">";
- var col6 = "<select NAME=\"lassumerpar[]\" id=\"las" + thisnombre + "\"><option>--------</option><option>Syndicat</option><option>Employeur</option></select>";
- var row = document.createElement("TR");
- row.id = "ligne" + thisnombre + "";
- var td1 = document.createElement("TD");
- td1.className = "liberationsdetail";
- td1.innerHTML = col1 + col1b; //+col1c;
- var td2 = document.createElement("TD");
- td2.className = "liberationsdetail";
- var obj2 = document.getElementById("lart0").cloneNode(true);
- obj2.id = "lart" + thisnombre + "";
- td2.appendChild(obj2);
- var td3 = document.createElement("TD");
- td3.className = "liberationsdetail";
- td3.innerHTML = col3;
- var td4 = document.createElement("TD");
- td4.className = "liberationsdetail";
- var obj4 = document.getElementById("ldur0").cloneNode(true);
- obj4.id = "ldur" + thisnombre + "";
- td4.appendChild(obj4);
- var td5 = document.createElement("TD");
- td5.className = "liberationsdetail";
- td5.innerHTML = col5;
- var td6 = document.createElement("TD");
- td6.className = "liberationsdetail";
- td6.innerHTML = col6;
- var td7 = document.createElement("TD");
- td7.className = "liberationsdetail";
- var obj7 = document.getElementById("0").cloneNode(true);
- obj7.id = nombre;
- td7.appendChild(obj7);
-
- var td8 = document.createElement("TD");
- td8.className = "liberationsdetail";
- var obj8 = document.getElementById("copie0").cloneNode(true);
- obj8.id = nombre;
- td8.appendChild(obj8);
-
- row.appendChild(td1);
- row.appendChild(td2);
- row.appendChild(td3);
- row.appendChild(td4);
- row.appendChild(td5);
- row.appendChild(td6);
- <?php
- if ($_SESSION["gestion_site"] == "Oui") {
- ?>
- if (mode_ajout === 0) {
- var col9 = "<select NAME=\"lpaiement[]\" id=\"lpa" + thisnombre + "\" onchange=\"creeDatePaiement('lpa'+nombre,'datepaiement" + thisnombre + "');\">";
- var col9a = "<option value=\"0\">--------</option><option value=\"1\">Non</option><option value=\"2\">Oui</option>";
- var col10 = "<input name=\"datepaiement[]\" id=\"datepaiement" + thisnombre + "\" size=\"10\" maxlength=\"10\" type=\"text\" readonly=\"readonly\" value=\"\">";
- var td9 = document.createElement("TD");
- td9.className = "liberationsdetail";
- td9.innerHTML = col9 + col9a;
- var td10 = document.createElement("TD");
- td10.innerHTML = col10;
- td10.className = "liberationsdetail";
- row.appendChild(td9);
- row.appendChild(td10);
- }
- <?php
- }
- ?>
- row.appendChild(td7);
- row.appendChild(td8);
-
- tbody.appendChild(row);
- $(document).ready(function () {
- $("#id" + thisnombre).datepicker({
- autoSize: true,
- onSelect: function () {
- reponseBoolDate = true;
- verifieDate('id' + thisnombre, 'lart' + thisnombre);
- }
- });
- $("#id" + thisnombre).datepicker("hide");
- nombre++;
- });
- }
- }
- function voirsolde() {
- var idemp = $("#zonerecherche2").val();
- var idlref = $('#lreference').val();
- if (idemp === '' || idemp === "Recherche" || idlref === '') {
- $("#zonerecherche2").focus();
- jAlert("Veuillez choisir l'employé parmi les membres");
- return false;
- } else {
- var reponseVerif = $.trim($.ajax({
- url: "obtsolde.php",
- global: false,
- type: "GET",
- data: {
- prm1: idlref,
- jeton: "<?php print $GLOBALS["jeton"]; ?>"
- },
- dataType: "html",
- async: false
- }).responseText);
- $("#voirsolde").html(reponseVerif).slideDown();
- }
- }
- $(document).ready(function () {
- //Charger le formulaire Ajax avant tout le monde
- $("#fenetremodale").load("obtformlib.php?prm1=-1");
- // Sur le clic du bouton d'ajout d'une libération,
- // réinitialisation de tous les champs du formulaire.
- $("#action_ajout").click(function () {
- mode_ajout = 1;
- $("#fenetremodale").load("obtformlib.php", {prm1: -1, jeton: "<?php print $GLOBALS["jeton"]; ?>"});
- //recommencer();
- });
- $("#frmModif").validate();
- $("voirsolde").blur(function () {
- $("#voirsolde").slideUp();
- });
- });</script>
- <?PHP
- if (isset($action2) && $action2 == "Afficher") {
- ?>
- <script type="text/javascript">
- $(document).ready(function () {
- changetitre(2);
- overlay();
- });
- </script>
- <?php
- }
|