/fortic-php/lib/php/forticFunctions.php
PHP | 6741 lines | 4955 code | 426 blank | 1360 comment | 1013 complexity | 6a6b0c1e47c92f4016271135e094691a MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
- <?php
- if(!defined("PHP_LIBRARY_FORTICFUNCTIONS")){define("PHP_LIBRARY_FORTICFUNCTIONS",1);
- ///////////////////////////////////////////////////////////////////////////////////////
- // nom: forticFunctions.php
- // auteur: Youri Reddy-Girard
- // Modifs: Daniel Cédilotte -- changeUTF16
- // date: 20/10/2002
- // desc: Librairie de fonctions de FORtIC
- //
- // modifié: Sylvie Caron Ajout du type de lieu - réf: demande #31 (améliorations 2005-2006)
- // modifié: R. Franche : mettre "0 dans lt_id dans la fonction addUpdateLieu
- // modifié: Sylvie Caron Ajout du lieu dans la liste des animateurs - réf: demande #37 (améliorations 2006-2007)
- // Fonctions ajoutées: formatNameLieu
- // Fonctions modifiées: getSQLStmtReqLieuAdminlieu, getSQLStmtReqSessionAnimateur
- // modifié: S. Caron : réf: demande #63 Liste Janvier 2008 Séparer l'affichage du code de session et de l'atelier + ajout petit icône pour le tri de colonne
- // Fonctions ajoutées: formatSessionCode et formatSessionDescription
- //
- // $Id: forticFunctions.php,v 1.140 2008/07/03 18:29:46 stacil Exp $
- // $Id: forticFunctions.php,v 1.140 2008/07/03 18:29:46 stacil Exp $
- // 2007/08/22 R. Franche : correction fonction getSQLStmtInsLieuAdmin, il manquait le return
- // 2008/03/25 R. Franche : lors du login : chercher lieu d'après son numéro OU sa description
- // pour éviter la création de lieu en double
- // 2008/04/25 R. Franche : correction fonction getSQLStmtReqLieuFromNoOuDescr : ajout addslash pour nom de lieu avec quote
- ///////////////////////////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // ajoutUsagerLDAP($sArrayLDAP, $sUsrLDAPCode)
- // Ajoute l'usager dans Fortic en provenance de LDAP
- // IN: $conn: objet de connexion avec la db (doit être déjà ouvert)
- // $sArrayLDAP: tableau des informations de LDAP
- // $sUsrLDAPCode: code de l'usager LDAP
- // &$nUsrID: retour de l'ID de l'usager Fortic
- // OUT: aucun
- ///////////////////////////////////////////////////////////////////////////////////////
- function ajouterUsagerLDAP($conn, $sArrayLDAP, $sUsrLDAPCode, &$nUsrID)
- {
- // importation des données (LDAP -> USAGER)
- // on ouvre la transaction
- $result = pg_query($conn, "BEGIN;");
- if (!$result){ bugFromPG($conn); }
-
- //Traitement du lieu LDAP vs Fortic
- addUpdateLieu($conn, $sArrayLDAP[3], $sArrayLDAP[4], &$nLieuID);
-
- //insertion de la fiche du nouvel usager
- $result = pg_query($conn, getSQLStmtInsUsager($sUsrLDAPCode, changeUTF16($sArrayLDAP[0]),
- changeUTF16($sArrayLDAP[1]), $nLieuID));
-
- if (!$result){ bugFromPG($conn); }
-
- //retrouver la fiche qu'on vient de créer
- $bFicheFound=fillVarFromDBStd($conn, getSQLStmtReqUsagerLAST(), &$nUsrID);
-
- //update de la fiche
- $result = pg_query($conn, getSQLStmtUpdUsagerLDAP($nUsrID, changeUTF16($sArrayLDAP[0]),
- changeUTF16($sArrayLDAP[1]),$sArrayLDAP[2], $sArrayLDAP[5],
- changeUTF16($sArrayLDAP[6]), "t", $nLieuID, "t"));
- if (!$result){ bugFromPG($conn); }
-
- // insertion du type d'usager
- $result = pg_query($conn, getSQLStmtInsUsagerUsrType($nUsrID, 1));
- if (!$result){ bugFromPG($conn); }
-
- // on ferme la transaction
- $result = pg_query($conn, "COMMIT;");
- if (!$result){ bugFromPG($conn); }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // addUpdateLieu($conn, , $nolieuLDAP, $lieuDesc, &$nLieuID)
- // Ajoute ou met à jour un lieu en provenance de d'un usager LDAP
- // IN: $conn: objet de connexion avec la db (doit être déjà ouvert)
- // $nolieuLDAP : numéro du lieu en provenance de LDAP */
- // $lieuDesc : Description du lieu
- // $nLieuID : numéro du lieu dans la bd Fortic
- // OUT: aucun
- ///////////////////////////////////////////////////////////////////////////////////////
- function addUpdateLieu($conn, $nolieuLDAP, $lieuDesc, &$nLieuID){
-
- // Aller chercher dans Fortic le lieu de l'usager LDAP
- // 2008/03 : chercher le lieu d'après non numéro OU sa description pour éviter le création de doubles
- $bFicheFound=fillVarFromDBStd($conn, getSQLStmtReqLieuFromNoOuDescr($nolieuLDAP, $lieuDesc),
- &$Li_id, &$Li_lieu, &$Li_no, &$Li_adresse,
- &$Li_trajet, &$Li_trajetURL, &$Li_telephone,
- &$Li_valide, &$Li_dateUpdate, &$Li_dateCreation);
-
- // Si on ne trouve pas le lieu, on le crée
- if($bFicheFound != true) {
- // Si la description du lieu est vide, on met Lieu avec son numéro
- if(isset($lieuDesc) == false || $lieuDesc == "") {
- $lieuDesc = "Lieu_".$nolieuLDAP;
- }
- // Insertion minimum
- $result = pg_query($conn, getSQLStmtInsLieu($lieuDesc));
- if (!$result){ bugFromPG($conn); }
- // Aller chercher la clée de la nouvelle entrée
- $bFicheFound=fillVarFromDBStd($conn, getSQLStmtReqLieuLAST(), &$nLieuID);
- // Compléter les informations du lieu
- $result = pg_query($conn, getSQLStmtUpdLieu($nLieuID, $lieuDesc,
- $nolieuLDAP, "", "", "", "",
- "t","t","0"));
- if (!$result){ bugFromPG($conn); }
- } else {
- // Affecter l'ID du lieu à la variable
- $nLieuID = $Li_id;
- }
- }
-
-
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // addUpdateUsagerFromLDAP($conn, $codeUsager)
- // Ajoute ou met à jour l'usager dans Fortic en provenance de LDAP
- // IN: $conn: objet de connexion avec la db (doit être déjà ouvert)
- // $codeUsager : code de l'usager à ajouter
- // OUT: aucun
- ///////////////////////////////////////////////////////////////////////////////////////
- function addUpdateUsagerFromLDAP($conn, $codeUsager)
- {
- global $ldap_var;
-
- // Connexion au serveur LDAP
- $conLDAP = ldap_connect($ldap_var[db][host], $ldap_var[db][port]);
- if(!$conLDAP) { //Connexion au serveur LDAP non-réussi, on quitteM
- bugFromLDAP($conLDAP);
- } else {
- //Si options LDAP on les appliquent
- if ( count($ldap_var["ldap_options"]) > 0) {
- OptionConnexion_LDAP($conLDAP);
- }
- }
- // Filtre pour rechercher seulement le code d'usager
- $filtre ="(&(".$ldap_var[db][searchKey]."=".$codeUsager.")".$filtre.$ldap_var[db][filter].")";
- //Recherche l'info complete de l'usager dans la base ldap
- $codeRetour = Recherche_LDAP($conLDAP,$filtre, &$sArrayRechLdap);
-
- //Vérifie le code de retour pour savoir si l'usager existe dans l'annuaire
- if ($codeRetour >= 0) {
- $sArrayLDAP = array(trim($sArrayRechLdap[0][0]), // Nom
- trim($sArrayRechLdap[0][1]), //Prénom
- trim($sArrayRechLdap[0][2]), //Email
- trim($sArrayRechLdap[0][3]), //lieuID
- trim($sArrayRechLdap[0][4]), //lieuDescr
- trim($sArrayRechLdap[0][5]), //Téléphone
- trim($sArrayRechLdap[0][6])); //Fonction
-
- //vérifie si l'usager existe déjà dans la base Fortic sinon on l'ajoute
- $bUserFound=fillVarFromDBStd($conn, getSQLStmtReqUsagerFromLogin($codeUsager),
- &$nUsrID, &$sLDAP);
- if ($bUserFound){ // l'usager existe déjà dans FORTIC, met à jour
- //Traitement du lieu LDAP vs Fortic
- addUpdateLieu($conn, $sArrayLDAP[3], $sArrayLDAP[4], &$nLieuID);
- // Mise à jour de l'usager
- $result = pg_query($conn, getSQLStmtUpdUsagerLDAP($nUsrID,
- changeUTF16($sArrayLDAP[0]),
- changeUTF16($sArrayLDAP[1]),
- $sArrayLDAP[2], $sArrayLDAP[5],
- changeUTF16($sArrayLDAP[6]), "t",
- $nLieuID, "t"));
- } else { //Nouvel usager on l'ajoute
- ajouterUsagerLDAP($conn, $sArrayLDAP, $codeUsager, &$nUsrID);
- }
- }
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // bugFromLdap($conn)
- // méthode appellée losrqu'on a un problème avec l'exécution d'une requête ou à établir
- // la connexion avec le serveur LDAP.
- ///////////////////////////////////////////////////////////////////////////////////////
- function bugFromLDAP($conn){
- echo _("Probleme avec la connexion LDAP");
- //echo pg_last_error($conn);
- //on quitte tous les script (pas de niasage)
- exit;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // fillArrFromArray( $pg, $pgSize, $nbRecordTotal, $nbPage,
- // &$arrnUsrLogin, &$arrUsrNom, &$arrUsrPrenom,
- // &$arrUsrLieuID, &$arrUsrLieu, &$arrUsrFonction)
- // remplit les tableaux de variables reçus en paramètre avec les valeurs contenus dans un
- // Array de SESSION "UsagerLieuLDAP"(provenant d'une requête LDAP)
- // De plus ce type de requête tient compte de la notion des pages. On peut donc
- // se positionner sur la Xe page de résultat directement
- // ATTENTION : Cette fonction est très spécifique et remplit toujours le même
- // nombre de tableau et dans un ordre très spécifique.
- // IN:
- // $pg: quelle page on veut se positionner
- // $pgSize: la grandeur des page (nb d'enregistrement par page)
- // $nbRecordTotal: nb d'entrée dans le tableau de SESSION
- // $arrUsrLogin: 1er tableau à remplir
- // $arrUsrNom: 2e tableau à remplir
- // $arr...: Xe tableau à remplir
- // OUT: -1: erreur lors de l'exécution de la requête
- // (int >= 0): nb de rangées résultantes de la requête
- ///////////////////////////////////////////////////////////////////////////////////////
- function fillArrFromArray( $pg, $pgSize, $nbRecordTotal, $nbPage, &$arrnUsrLogin,
- &$arrUsrNom, &$arrUsrPrenom,&$arrUsrLieuID, &$arrUsrLieu,
- &$arrUsrFonction){
-
- $nbPage = ceil($nbRecordTotal/$pgSize);
- if ($nbRecordTotal>0){
- $offset = ($pg-1)*$pgSize;
- $limit = $offset + $pgSize;
- $nbRow = min($nbRecordTotal,$limit)- $offset;
- for($iRow=0; $iRow<$nbRow; $iRow++,$offset++){
- $arrnUsrLogin[$iRow] = $_SESSION["UsagerLieuLDAP"][5][$offset];
- $arrUsrNom[$iRow] = $_SESSION["UsagerLieuLDAP"][0][$offset];
- $arrUsrPrenom[$iRow] = $_SESSION["UsagerLieuLDAP"][1][$offset];
- $arrUsrLieuID[$iRow] = $_SESSION["UsagerLieuLDAP"][2][$offset];
- $arrUsrLieu[$iRow] = $_SESSION["UsagerLieuLDAP"][3][$offset];
- $arrUsrFonction[$iRow] = $_SESSION["UsagerLieuLDAP"][4][$offset];
- }
- return ($nbRow);
- }
- else{
- return (0);
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // fillUsrFromLDAPServer($login, $mdp, &$bLoginValide, &$sArrayLDAP)
- // remplit le usr_id de l'usager en fonction de ce qu'on trouvé dans ldap qui avait
- // le même login et mot de passe que celui fournit en paramètre
- // IN: $login: nom d'usager
- // $mdp: mot de passe
- // &$bLoginValide : si on a de quoi de valide sur ldap, on met true ici
- // &$sArrayLDAP : informations extraites du serveur LDAP
- // OUT: 1: user retrouvé dans ldap
- // 0: user non retrouvé dans ldap
- ///////////////////////////////////////////////////////////////////////////////////////
- function fillUsrFromLDAPServer( $login, $mdp, &$bLoginValide, &$sArrayLDAP ){
- global $ldap_var;
- $OkLDAP = 0;
- $bLoginValide = false;
-
- // Connexion au serveur LDAP
- $conLDAP = ldap_connect( $ldap_var[ 'db' ][ 'host' ], $ldap_var[ 'db' ][ 'port' ] );
-
- //Connexion au serveur LDAP. Si non-réussi, on quitte
- if( $conLDAP !== false ) {
- //Si options LDAP on les appliquent
- if ( count($ldap_var["ldap_options"]) > 0) {
- OptionConnexion_LDAP($conLDAP);
- }
- // Filtre pour rechercher seulement le code d'usager
- $filtre = "(&(" . $ldap_var[ "db" ][ "searchKey" ] . "=" . $login. ")" . $ldap_var[ "db" ][ "filter" ] . ")";
-
- //Recherche l'usager dans la base ldap
- $codeRetour = Recherche_LDAP( $conLDAP, $filtre, &$sArrayRechLdap );
- $sArrayRechLdap = $sArrayRechLdap[ 0 ];
-
- //Vérifie le code de retour pour savoir si l'usager existe dans l'annuaire
- if( $codeRetour >= 0 ) {
- $OkLDAP = 1;
- if( $codeRetour > 0 ) {
- //Récuppère le dn pour permettre de faire le nouveau bind
- $dn = $sArrayRechLdap[ 7 ];
- //Si pas de mot de passe fournit on en génère un bidon pour être certain de ne pas faire un bind anonyme
- if( $mdp == "" ){
- $mdp = crypt( microtime() );
- }
-
- // Si l'authentification a réussie, retourne les infos de l'usager ainsi qu'un code de retour valide
- if( @ldap_bind( $conLDAP, $dn, $mdp ) ){
- //if( ldap_compare( $conLDAP, $dn, "userpassword", $mdp ) ){
- $sArrayLDAP = array( trim( $sArrayRechLdap[ 0 ] ), trim( $sArrayRechLdap[ 1 ] ), trim( $sArrayRechLdap[ 2 ] ),
- trim( $sArrayRechLdap[ 3 ] ), trim( $sArrayRechLdap[ 4 ] ), trim( $sArrayRechLdap[ 5 ] ), trim( $sArrayRechLdap[ 6 ] ) );
- $bLoginValide = true;
- }
- }
- }
-
- ldap_unbind( $conLDAP );
- }
-
- return $OkLDAP;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // OptionConnexion_LDAP
- // Affecte les options de connexion à l'annaire LDAP s'il y a lieu
- // IN: $conLDAP :Connexion au serveur ldap
- // OUT: -----
- ///////////////////////////////////////////////////////////////////////////////////////
- function OptionConnexion_LDAP( $conLDAP){
- global $ldap_var;
-
- for( $i=0; is_array($ldap_var["ldap_options"]) && $i < count($ldap_var["ldap_options"]); $i++ ) {
- if( isset( $ldap_var["ldap_options"][$i] ) && strpos( $ldap_var["ldap_options"][$i], ";" ) ) {
- $param = explode(";",$ldap_var["ldap_options"][$i]);
- ldap_set_option($conLDAP, constant($param[0]) ,$param[1]);
- }
- }
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- // Recherche_LDAP
- // Recherche des informations selon le filtre spécifié
- // IN: $conLDAP :Connexion au serveur ldap
- // $filtre : filtre de recherche
- // &$sArrayLDAP : informations extraites du serveur LDAP
- // OUT: nb: nb. user retrouvé dans ldap
- // 0: user non retrouvé dans ldap
- // -1: connexion impossible
- ///////////////////////////////////////////////////////////////////////////////////////
- function Recherche_LDAP( $conLDAP, $filtre, $sArrayLDAP ){
- global $ldap_var;
- $codeRetour = 0;
-
- // La connexion au serveur LDAP est établit on fait un premier bind
- if( isset( $ldap_var[ 'db' ][ 'bind_dn' ] ) ) {
- //Si aucun code de bind n'est défini on fait un alors un bind anonyme
- $bindLDAP = ldap_bind( $conLDAP, $ldap_var[ 'db' ][ 'bind_dn' ], $ldap_var[ 'db' ][ 'bind_pwd' ] );
- } else {
- // Sinon on fait une connexion avec un usager ayant les droits nécessaires dans l'annuaire
- $bindLDAP = ldap_bind( $conLDAP );
- }
-
- // Bind au serveur LDAP non-réussi, on quitte
- if( !$bindLDAP ) {
- $codeRetour = -1;
- } else {
- // Liste des variables à retourner lors du search
- $restrictions = array( $ldap_var[ 'info' ][ 'nom' ], $ldap_var[ 'info' ][ 'prenom' ], $ldap_var[ 'info' ][ 'email' ],
- $ldap_var[ 'info' ][ 'lieuID' ], $ldap_var[ 'info' ][ 'lieuDescr' ], $ldap_var[ 'info' ][ 'telephone' ],
- $ldap_var[ 'info' ][ 'fonction' ], $ldap_var[ 'db' ][ 'searchKey' ] );
-
- // Cherche le dn de l'usager et met les enregistrements dans un tableau pour le traitement
- $arrayRecherche = ldap_search( $conLDAP, $ldap_var[ 'db' ][ 'searchBase' ], $filtre, $restrictions );
- $info = ldap_get_entries($conLDAP, $arrayRecherche);
- $codeRetour = count( $info ) - 1;
-
- // Retourne toutes les informations de l'usager selon l'annuaire
- for( $i = 0; is_array($info) && $i < $codeRetour; $i++) {
- $entree = $info[ $i ];
-
- //Correction si l'usager n'a pas de numéro de téléphone dans ldap
- if ( !isset( $entree[ $ldap_var[ 'info' ][ 'telephone'] ] ) ||
- !is_array( $entree[ $ldap_var[ 'info' ][ 'telephone'] ] ) ){
- $entree[ $ldap_var[ 'info' ][ 'telephone' ] ] = array( "" );
- }
-
- $sArrayLDAP[ $i ] = array( $entree[ $ldap_var[ 'info' ][ 'nom' ] ][ 0 ], $entree[ $ldap_var[ 'info' ][ 'prenom' ] ][ 0 ],
- $entree[ $ldap_var[ 'info' ][ 'email'] ][ 0 ], strtolower( $entree[ $ldap_var[ 'info' ]['lieuID' ] ][ 0 ] ),
- $entree[ $ldap_var[ 'info' ][ 'lieuDescr'] ][ 0 ], $entree[ $ldap_var[ 'info' ][ 'telephone'] ][ 0 ],
- $entree[ $ldap_var[ 'info' ][ 'fonction'] ][ 0 ], $entree[ 'dn' ],
- strtolower( $entree[ $ldap_var[ 'db' ][ 'searchKey' ] ][ 0 ] ) );
- }
- }
-
- return $codeRetour;
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- // Recherche_LDAP_Import
- // Recherche des informations selon le filtre spécifié
- // IN: $conLDAP :Connexion au serveur ldap
- // $filtre : filtre de recherche
- // &$sArrayLDAP : informations extraites du serveur LDAP
- // OUT: nb: nb. user retrouvé dans ldap
- // 0: user non retrouvé dans ldap
- // -1: connexion impossible
- ///////////////////////////////////////////////////////////////////////////////////////
- function Recherche_LDAP_Import($conLDAP, $filtre, $sArrayLDAP){
- global $ldap_var;
- $codeRetour = 0;
-
- //La connexion au serveur LDAP est établit on fait un premier bind
- //Si aucun code de bind n'est défini on fait un alors un bind anonyme
- //sinon on fait une connexion avec un usager ayant lesdroits nécessaires dans l'annuaire'
- if(isset($ldap_var[db][bind_dn])) //Le LDAP n'est pas anonyme
- {
- $bindLDAP = ldap_bind($conLDAP, $ldap_var[db][bind_dn],$ldap_var[db][bind_pwd]);
- }
- else //La recherche anonyme est permise
- {
- $bindLDAP = ldap_bind($conLDAP);
- }
-
- if(!$bindLDAP) //Bind au serveur LDAP non-réussi, on quitte
- {
- ldap_unbind($conLDAP); //Déconnexion
- $codeRetour = -1;
- return $codeRetour; //Arrêt COMPLET de l'application (-1)
- }
-
- //Liste des variables à retourner lors du search
- $restrictions = array($ldap_var[info][nom],
- $ldap_var[info][prenom],
- $ldap_var[info][email],
- $ldap_var[info][lieuID],
- $ldap_var[info][lieuDescr],
- $ldap_var[info][telephone],
- $ldap_var[info][fonction],
- $ldap_var[db][searchKey]);
-
- // Aller chercher le dn de l'usager
-
- $arrayRecherche = ldap_search($conLDAP,$ldap_var[db][searchBase],
- $filtre, $restrictions);
-
- // Mettre les enregistrements dans un tableau pour le traitement
- $info = ldap_get_entries($conLDAP, $arrayRecherche);
-
- $codeRetour = count($info) - 1;
-
- for( $i = 0; is_array($info) && $i < (count($info)-1); $i++){
- $arrayNom[$i] = changeUTF16($info[$i][$ldap_var[info][nom]][0]);
- $arrayPrenom[$i] = changeUTF16($info[$i][$ldap_var[info][prenom]][0]);
- $arrayLieuID[$i] = $info[$i][$ldap_var[info][lieuID]][0];
- $arrayLieuDescr[$i] = changeUTF16($info[$i][$ldap_var[info][lieuDescr]][0]);
- $arrayFonction[$i] = changeUTF16($info[$i][$ldap_var[info][fonction]][0]);
- $arrayKey[$i] = $info[$i][$ldap_var[db][searchKey]][0];
- }
-
- $sArrayLDAP[0] = $arrayNom;
- $sArrayLDAP[1] = $arrayPrenom;
- $sArrayLDAP[2] = $arrayLieuID;
- $sArrayLDAP[3] = $arrayLieuDescr;
- $sArrayLDAP[4] = $arrayFonction;
- $sArrayLDAP[5] = $arrayKey;
-
- return $codeRetour;
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT LDAP
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqLieuxLDAP($mot, $motlnk, $adminlieu_id, $tech_id, $valide, $indx){
- $SQLStmt="SELECT li_id, li_lieu, li_no, li_adresse, li_trajet, li_valide";
- $SQLStmt.=" FROM lieu";
- $SQLStmt.=" WHERE li_id = li_id";
- $SQLStmt.=" AND li_ldap ='t'";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt.="(li_lieu ILIKE '%".fixPGQuote($arrMot[$i])."%'";
- $SQLStmt.=" OR li_adresse ILIKE '%".fixPGQuote($arrMot[$i])."%')";
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if (is_numeric($adminlieu_id)){
- $SQLStmt.=" AND li_id IN (";
- $SQLStmt.=" SELECT li_id";
- $SQLStmt.=" FROM lieuadmin";
- $SQLStmt.=" WHERE usr_id=".$adminlieu_id;
- $SQLStmt.=")";
- }
- if (is_numeric($tech_id)){
- $SQLStmt.=" AND li_id IN (";
- $SQLStmt.=" SELECT li_id";
- $SQLStmt.=" FROM lieusupport";
- $SQLStmt.=" WHERE usr_id=".$tech_id;
- $SQLStmt.=")";
- }
- if ($valide!=""){
- if (!strcasecmp($valide,"t")){
- $SQLStmt.=" AND li_valide='t'";
- }
- else{
- $SQLStmt.=" AND li_valide='f'";
- }
- }
- if ($indx!=""){
- if ($indx=="lieua"){
- $SQLStmt.=" ORDER BY li_lieu ASC";
- }
- elseif ($indx=="lieud"){
- $SQLStmt.=" ORDER BY li_lieu DESC";
- }
- elseif ($indx=="adressea"){
- $SQLStmt.=" ORDER BY li_adresse ASC";
- }
- elseif ($indx=="adressed"){
- $SQLStmt.=" ORDER BY li_adresse DESC";
- }
- elseif ($indx=="trajeta"){
- $SQLStmt.=" ORDER BY li_trajet ASC";
- }
- elseif ($indx=="trajetd"){
- $SQLStmt.=" ORDER BY li_trajet DESC";
- }
- elseif ($indx=="lieunoa"){
- $SQLStmt.=" ORDER BY li_no ASC";
- }
- elseif ($indx=="lieunod"){
- $SQLStmt.=" ORDER BY li_no DESC";
- }
- else
- {
- $SQLStmt.=" ORDER BY li_lieu ASC"; // ordre alphabetique de nom par defaut
- }
- }
- return $SQLStmt;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne le filtre necessaire pour faire la recherche LDAP par lieu
- ///////////////////////////////////////////////////////////////////////////////////////
- function getFiltreUsagersLdap($mot, $li_no){
- global $ldap_var;
- $filtre.="(&";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- for ($i=0; $i<count($arrMot); $i++){
- $rech = verifMot($mot);
- if($rech !="" ){
- $filtre.="(".$ldap_var[info][nom]."=".$rech."*)";
- }
- }
- }
-
- //Lieu recherché
- if ($li_no !=""){
- $filtre.="(".$ldap_var[info][lieuID]."=".$li_no.")";
- }
- //Filtre suplémentaire spécial.
- $filtre .= $ldap_var[db][filter];
- $filtre .=")";
- return $filtre;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // verifMot($input)
- // Enlève les caractères *? de la chaine
- // IN: $input: string qu'on veut vérifier
- // OUT: string épurée
- ///////////////////////////////////////////////////////////////////////////////////////
- function verifMot($input){
-
- $result = strtr($input,"*?","//");
- $result = trim($result);
- return ($result);
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- // TriArrayLDAP($cle)
- // Tri le Array de SESSION "UsagerLieuLDAP"(provenant d'une requête LDAP)
- // IN: $cle: Cle de tri
- // OUT: Array de SESSION trié
- // True cle valide
- ///////////////////////////////////////////////////////////////////////////////////////
- function TriArray($cle){
-
- //Extrait la partie ordre de tri
- $typeTri = substr($cle,-1);
- //Ajuste l'ordre pour un tri descendant ou ascendant par défaut
- if($typeTri == "d" || $typeTri == "D"){
- $ordre = "SORT_DESC";
- }
- else {
- $ordre = "SORT_ASC";
- }
- //Extrait la partie du mot qui indique la cle de tri
- $cleTri = substr($cle,0, -1);
- //Ajuste les clés pour un tri par fonction
- if($cleTri == "type") {
- $cle1 = 4; //Fonction
- $cle2 = 0; //Nom
- $cle3 = 1; //Prenom
- $cle4 = 2; //LieuID
- }
- else if ($cleTri == "lieu") {
- $cle1 = 2; //LieuID
- $cle2 = 0; //Nom
- $cle3 = 1; //Prenom
- $cle4 = 4; //Fonction
-
- }
- else { //Tri par défaut (Nom, Prénom, LieuID, Fonction)
- $cle1 = 0; //Nom
- $cle2 = 1; //Prenom
- $cle3 = 2; //LieuID
- $cle4 = 4; //Fonction
- }
-
- //Tri du tableau complet
- if($typeTri == "d" || $typeTri == "D"){
- array_multisort($_SESSION["UsagerLieuLDAP"][$cle1], SORT_DESC,
- $_SESSION["UsagerLieuLDAP"][$cle2], SORT_DESC,
- $_SESSION["UsagerLieuLDAP"][$cle3], SORT_DESC,
- $_SESSION["UsagerLieuLDAP"][$cle4], SORT_DESC,
- $_SESSION["UsagerLieuLDAP"][3],
- $_SESSION["UsagerLieuLDAP"][5]);
- }
- else{
- array_multisort($_SESSION["UsagerLieuLDAP"][$cle1], SORT_ASC,
- $_SESSION["UsagerLieuLDAP"][$cle2], SORT_ASC,
- $_SESSION["UsagerLieuLDAP"][$cle3], SORT_ASC,
- $_SESSION["UsagerLieuLDAP"][$cle4], SORT_ASC,
- $_SESSION["UsagerLieuLDAP"][3],
- $_SESSION["UsagerLieuLDAP"][5]);
- }
- return (true);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // connextToPG($conn)
- // établit la connexion avec le serveur Postgresql
- ///////////////////////////////////////////////////////////////////////////////////////
- function connectToPG( $conn_str ){
- if( !$conn = pg_connect( $conn_str ) ) { bugFromPG( $conn ); };
- return $conn;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // bugFromPG($conn)
- // méthode appellée losrqu'on a un problème avec l'exécution d'une requête ou à établir
- // la connexion avec le serveur Postgresql.
- ///////////////////////////////////////////////////////////////////////////////////////
- function bugFromPG($conn){
- echo _("Probleme avec la BD PostgreSQL");
- echo pg_last_error($conn);
- //on quitte tous les script (pas de niasage)
- exit;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // changeUTF16($chaine)
- // méthode appellée pour convertir les lignes LDap d'UTF-8 à UTF-16
- //
- // IN: $chaine
- // OUT: retourne la chaine UTF-8 ou ISO-8859-1, convertie en UTF-16
- ///////////////////////////////////////////////////////////////////////////////////////
- function changeUTF16( $chaine ){
- return mb_convert_encoding( $chaine, "ISO-8859-1","UTF-8" )."\n" ;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Met un space HTML lorsqu'il n'y aucune valeur a afficher
- ///////////////////////////////////////////////////////////////////////////////////////
- function convNoDataToHTMLSpace($value){
- if (($value=="") || (!isset($value))){
- return(" ");
- }
- else{
- return($value);
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // fillArrFromDBStd($conn, $sqlstmt, $arrVal0 = NULL, $arrVal1 = NULL, ...)
- // remplit les tableaux de variables reçu en paramètre avec la valeur des
- // rangées retournées par la requête sql fournie en paramètre
- // ATTENTION : l'ordre des variables spécifiées en paramètre doit être le même
- // que l'odre des champs dans la requête
- // [SUPPORTE 40 tableaux]
- // IN: $conn: objet de connexion avec la db (doit être déjà ouvert)
- // $sqlstmt: requête SQL à exécuter
- // $arrVal1: 1er tableau à remplir
- // $arrVal2: 2e tableau à remplir
- // $arrValX: Xe tableau à remplir
- // OUT: -1: erreur lors de l'exécution de la requête
- // (int): nb de rangées résultantes de la requête
- ///////////////////////////////////////////////////////////////////////////////////////
- function fillArrFromDBStd($conn, $sqlstmt, $arrVal0 = NULL, $arrVal1 = NULL, $arrVal2 = NULL, $arrVal3 = NULL, $arrVal4 = NULL, $arrVal5 = NULL, $arrVal6 = NULL, $arrVal7 = NULL, $arrVal8 = NULL, $arrVal9 = NULL, $arrVal10 = NULL, $arrVal11 = NULL, $arrVal12 = NULL, $arrVal13 = NULL, $arrVal14 = NULL, $arrVal15 = NULL, $arrVal16 = NULL, $arrVal17 = NULL, $arrVal18 = NULL, $arrVal19 = NULL, $arrVal20 = NULL, $arrVal21 = NULL, $arrVal22 = NULL, $arrVal23 = NULL, $arrVal24 = NULL, $arrVal25 = NULL, $arrVal26 = NULL, $arrVal27 = NULL, $arrVal28 = NULL, $arrVal29 = NULL, $arrVal30 = NULL, $arrVal31 = NULL, $arrVal32 = NULL, $arrVal33 = NULL, $arrVal34 = NULL, $arrVal35 = NULL, $arrVal36 = NULL, $arrVal37 = NULL, $arrVal38 = NULL, $arrVal39 = NULL){
- $nbRow = -1;
-
- // tableau dynamique
- $nbArray = func_num_args() - 2;
- for( $i = 0; $i < $nbArray; $i++ ){
- $name = "arrVal" . $i;
- $args[ $i ] =& $$name;
-
- // S'assure que ce qui sera retourné sera au moins un tableau vide
- if( is_null( $args[ $i ] ) ){
- $args[ $i ] = array();
- }
- }
-
- // bd time
- $result = pg_query( $conn, $sqlstmt );
- if( $result > 0 ){
- $nbRow = pg_num_rows( $result );
- $nbLoop = min( $nbArray, pg_num_fields( $result ) );
-
- for( $iRow = 0; $iRow < $nbRow; $iRow++ ){
- for( $iCol = 0; $iCol < $nbLoop; $iCol++ ){
- $args[ $iCol ][ $iRow ] = pg_result( $result, $iRow, $iCol );
- }
- }
- pg_free_result( $result );
- }
- return $nbRow;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // fillArrFromDBStdWithPg($conn, $sqlstmt, $page_no, $page_size, $nbPage, $nbRecordTotal, $arrVal0 = NULL, $arrVal1 = NULL, ...)
- // remplit les tableaux de variables reçus en paramètre avec la valeur des
- // rangées retournées par la requête sql fournie en paramètre. De plus
- // ce type de requête tient compte de la notion des pages. On peut donc
- // se positionner sur la Xe page de résultat directement
- // ATTENTION : l'ordre des variables spécifiées en paramètre doit être le même
- // que l'odre des champs dans la requête
- // [SUPPORTE 40 tableaux]
- // IN: $conn: objet de connexion avec la db (doit être déjà ouvert)
- // $sqlstmt: requête SQL à exécuter
- // $page_no: quelle page on veut se positionner
- // $pgSize: la grandeur des page (nb d'enregistrement par page)
- // $page_size: nb de page résultant de la requête
- // $nbRecordTotal: nb d'enregistrement résultant de la requête
- // $arrVal1: 1er tableau à remplir
- // $arrVal2: 2e tableau à remplir
- // $arrValX: Xe tableau à remplir
- // OUT: -1: erreur lors de l'exécution de la requête
- // (int >= 0): nb de rangées résultantes de la requête
- ///////////////////////////////////////////////////////////////////////////////////////
- function fillArrFromDBStdWithPg($conn, $sqlstmt, $page_no, $page_size, $nbPage, $nbRecordTotal, $arrVal0 = NULL, $arrVal1 = NULL, $arrVal2 = NULL,
- $arrVal3 = NULL, $arrVal4 = NULL, $arrVal5 = NULL, $arrVal6 = NULL, $arrVal7 = NULL, $arrVal8 = NULL, $arrVal9 = NULL, $arrVal10 = NULL,
- $arrVal11 = NULL, $arrVal12 = NULL, $arrVal13 = NULL, $arrVal14 = NULL, $arrVal15 = NULL, $arrVal16 = NULL, $arrVal17 = NULL,
- $arrVal18 = NULL, $arrVal19 = NULL, $arrVal20 = NULL, $arrVal21 = NULL, $arrVal22 = NULL, $arrVal23 = NULL, $arrVal24 = NULL,
- $arrVal25 = NULL, $arrVal26 = NULL, $arrVal27 = NULL, $arrVal28 = NULL, $arrVal29 = NULL, $arrVal30 = NULL, $arrVal31 = NULL,
- $arrVal32 = NULL, $arrVal33 = NULL, $arrVal34 = NULL, $arrVal35 = NULL, $arrVal36 = NULL, $arrVal37 = NULL, $arrVal38 = NULL, $arrVal39 = NULL){
- $retour = -1;
-
- // Création d'un tableau dynamique de pointeurs vers les tableaux de valeurs reçues
- $nbArray = func_num_args()-2;
- for( $i = 0; $i < $nbArray; $i++ ){
- $name = "arrVal" . $i;
- $args[ $i ] = &$$name;
- }
-
- // Fait la requête en ôtant tout ce qui suit "ORDER BY"
- if( $result = pg_query( $conn, eregi_replace( " ORDER BY .*" , "", $sqlstmt ) ) ){
- $retour = 0;
- $nbRecordTotal = pg_num_rows( $result );
- if( $nbRecordTotal > 0 ){
- $nbPage = ceil( $nbRecordTotal / $page_size );
- $limit = $page_size;
- if (isset($page_no) )
- $offset = ( $page_no - 1 ) * $page_size;
- else
- $offset = 0;
-
- // on refait la requête avec des nouveaux paramètres
- $result = pg_query( $conn, $sqlstmt . " LIMIT " . $limit . " OFFSET " . $offset );
- $nbRow = pg_num_rows($result);
- $nbCol = min( $nbArray, pg_num_fields( $result ) );
- for( $iRow = 0; $iRow < $nbRow; $iRow++ ){
- for( $iCol=0; $iCol < $nbCol; $iCol++ ){
- $args[ $iCol ][ $iRow ] = pg_result( $result, $iRow, $iCol );
- }
- }
- pg_free_result( $result ); // Libère la mémoire inutilisée
- $retour = $nbRow;
- }
- }
-
- return $retour;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // fillVarFromDBStd($conn, $sqlstmt, &$val1, &$val2, &$val3)
- // remplit les variables reçues en paramètre avec la valeur de la première
- // rangée du résultat de la requête (arrangez vous pour que la requête
- // sql n'ait qu'une seule rangée de résultat)
- // ATTENTION : l'ordre des variables spécifiées en paramètre doit être le même
- // que l'odre des champs dans la requête
- // [SUPPORTE 40 variables]
- // IN: $conn: objet de connexion avec la db (doit être déjà ouvert)
- // $sqlstmt: requête SQL à exécuter
- // $val1: 1ere variable à remplir
- // $val2: 2e variable à remplir
- // $valX: Xe variable à remplir
- ///////////////////////////////////////////////////////////////////////////////////////
- function fillVarFromDBStd($conn, $sqlstmt, $val0 = NULL, $val1 = NULL, $val2 = NULL, $val3 = NULL, $val4 = NULL, $val5 = NULL, $val6 = NULL, $val7 = NULL, $val8 = NULL, $val9 = NULL, $val10 = NULL, $val11 = NULL, $val12 = NULL, $val13 = NULL, $val14 = NULL, $val15 = NULL, $val16 = NULL, $val17 = NULL, $val18 = NULL, $val19 = NULL, $val20 = NULL, $val21 = NULL, $val22 = NULL, $val23 = NULL, $val24 = NULL, $val25 = NULL, $val26 = NULL, $val27 = NULL, $val28 = NULL, $val29 = NULL, $val30 = NULL, $val31 = NULL, $val32 = NULL, $val33 = NULL, $val34 = NULL, $val35 = NULL, $val36 = NULL, $val37 = NULL, $val38 = NULL, $val39 = NULL){
- // tableau dynamique
- $nbVariable = func_num_args()-2;
- for ($i=0; $i<$nbVariable; $i++){
- $name = "val" . $i;
- $args[$i]=&$$name;
- }
- //echo "fillVarFromDBStd: " . $sqlstmt . "<br>";
- $result = pg_query($conn, $sqlstmt);
- if (!$result){ bugFromPG($conn); }
- if($result>0){
- $nbRow=pg_num_rows($result);
- $nbLoop=min($nbVariable,pg_num_fields($result));
- if($nbRow==1){
- for($iCol=0; $iCol<$nbLoop; $iCol++){
- $args[$iCol]=pg_result($result, 0, $iCol);
- }
- pg_free_result($result);
- return(true);
- }
- pg_free_result($result);
- }
- return(false);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // fixPGQuote($input)
- // fixe les quote pour que la requête demeure sécuritaire dans postgres..
- // IN: $input: string qu'on veut sécuriser
- // OUT: string sécurisé
- ///////////////////////////////////////////////////////////////////////////////////////
- function fixPGQuote($input){
- // Peut être remplacé par 'pg_escape_string' mais doit être utilisé avec une connexion à Postgres 7.2
- return (addslashes($input));
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // getWordStemRegExp()
- // Retourne une expression reguliere qui permet de reconnaitre le debut d'un mot
- // a l'interieur d'une chaine quelconque.
- // OUT: expression reguliere
- ///////////////////////////////////////////////////////////////////////////////////////
- function getWordStemRegExp(){
- // Tout caractere pouvant se trouver au debut d'un mot.
- return( "[ -.,?!:;([\']" );
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // accentInsensitiveLike()
- // Retourne une chaine pouvant remplacer une expression LIKE ou ILIKE afin
- // d'effectuer un "pattern matching".
- // Les expressions régulières sont beaucoup plus rapides que LIKE ou ILIKE
- // IN: $field_name Nom du champ
- // $field_value Valeur du champ
- // $case_insensitive true si l'on veut que la comparaison ne tienne pas compte
- // de la casse
- // OUT: clause SQL
- ///////////////////////////////////////////////////////////////////////////////////////
- function accentInsensitiveLike($field_name, $field_value, $case_insensitive = true) {
- $regexp_op = ( $case_insensitive == true ) ? "~*" : "~";
-
- // Fait une recherche avec une expression régulière qui cherche la valeur qui commence un champ ou qui se situe après un charactère qui ne fait pas alphanumérique
- return "( " . $field_name . " " . $regexp_op . " E'^" . $field_value . "|[^\w]" . $field_value . "' )";
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // flushCourriel()
- // Envoit tous les courriels qui devraient etre envoyes
- ///////////////////////////////////////////////////////////////////////////////////////
- function flushCourriel(){
- //echo "Les courriels n'ont pas été flushés par le fichier 'forticFunctions.php'.";
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // formatCR($sTemp)
- // formate la sortie de manière à remplacer les CR par des <br> (les ENTERS)
- // IN: $sTemp: string à afficher
- // OUT: (string) le résultat du string une fois formaté
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatCR($sTemp){
- return (str_replace("\r","<br/>",$sTemp));
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Set le format d'affichage pour les dates.
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatDate($dTemp, $format){
- if ( (isDate($dTemp)) || (isTimeStamp($dTemp)) ){
- return date($format,strtotime($dTemp));
- }
- else{
- return $dTemp;
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Set le format d'affichage pour les dates.
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatDateInterval($dTemp1, $dTemp2, $style, $dateFormat, $timeFormat){
- if ($style=="date"){
- if ( ((isDate($dTemp1))||(isTimeStamp($dTemp1))) && ((isDate($dTemp2))||(isTimeStamp($dTemp2))) ){
- $sDateTemp1 = date($dateFormat, strtotime($dTemp1));
- $sDateTemp2 = date($dateFormat, strtotime($dTemp2));
- if ($sDateTemp1 != $sDateTemp2){
- $output = $sDateTemp1." "._("au")." ".$sDateTemp2;
- }
- else{
- $output = $sDateTemp1;
- }
- }
- elseif( (isDate($dTemp1))||(isTimeStamp($dTemp1)) ){
- $sDateTemp1 = date($dateFormat, strtotime($dTemp1));
- $output = $sDateTemp1." "._("au")." "._("n/a");
- }
- elseif( (isDate($dTemp2))||(isTimeStamp($dTemp2)) ){
- $sDateTemp2 = date($dateFormat, strtotime($dTemp2));
- $output = _("n/a")." "._("au")." ".$sDateTemp2;
- }
- else{
- $output = _("dates indeterminees");
- }
- }
- elseif ($style=="time"){
- if ( (isTimeStamp($dTemp1)) && (isTimeStamp($dTemp2)) ){
- $sDateTemp1 = date($dateFormat, strtotime($dTemp1));
- $sDateTemp2 = date($dateFormat, strtotime($dTemp2));
- $sTimeTemp1 = date($timeFormat, strtotime($dTemp1));
- $sTimeTemp2 = date($timeFormat, strtotime($dTemp2));
- if ($sDateTemp1 == $sDateTemp2){
- $output = $sDateTemp1." ".$sTimeTemp1." "._("a")." ".$sTimeTemp2;
- }
- else{
- $output = $sDateTemp1." ".$sTimeTemp1." "._("a")." ".$sTimeTemp2." (".$sDateTemp1.")";
- }
- }
- elseif( (isTimeStamp($dTemp1))||(isTimeStamp($dTemp1)) ){
- $sDateTemp1 = date($dateFormat, strtotime($dTemp1));
- $sTimeTemp1 = date($timeFormat, strtotime($dTemp1));
- $output = $sDateTemp1." ".$sTimeTemp1." "._("a")." "._("n/a");
- }
- elseif( (isTimeStamp($dTemp2))||(isTimeStamp($dTemp2)) ){
- $sDateTemp2 = date($dateFormat, strtotime($dTemp2));
- $sTimeTemp2 = date($timeFormat, strtotime($dTemp2));
- $output = _("n/a")." "._("a")." ".$sDateTemp2." ".$sTimeTemp2;
- }
- else{
- $output = _("moment indetermine");
- }
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatDateLimite($dTemp, $dTempDisplay, $classOK="", $classNOT="", $classHOPE="")
- // affiche la datelimite en couleur
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatDateLimite( $dTemp, $format, $classOK = "", $classNOT = "", $classHOPE = "" ){
- $output = "";
- $class = "";
- if( isDate( $dTemp ) ){
- $today = strtotime( date( "Y-m-d" ) );
- $limite = strtotime( $dTemp );
-
- // Si la date limite n'est pas arrivé ou qu'elle est aujourd'hui et qu'on ne reçoit pas de classe HOPE
- if( ( $today < $limite || ( $today == $limite && $classHOPE == "" ) ) && $classOK != "" ){
- $class = $classOK;
- // Si la date limite est dépassée
- } elseif( $today > $limite && $classNOT != "" ){
- $class = $classNOT;
- // Si la date limite est aujourd'hui
- } elseif( $today == $limite && $classHOPE != "" ){
- $class = $classHOPE;
- }
-
- $output = formatDate( $dTemp, $format );
- if( $class != "" ){
- $output = "<span class='" . $class . "'>" . $output . "</span>";
- }
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatGabaritSub($sInput, $class=NULL)
- // formate la sortie pour qu'on puisse voir si c'est un sous-gabarit
- // IN: $sInput: t ou f : designant si system
- // OUT: (string) ce qu'on affiche sur la page
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatGabaritSub($sInput, $class=NULL){
- $state1=_("sous-gabarit");
- $state2=_("gabarit");
- if ($sInput=="t"){
- if ($class!=""){
- $output="<span class=\"".$class."\">".$state1."</span>";
- }
- else{
- $output=$state1;
- }
- }
- else{
- if ($class!=""){
- $output="<span class=\"".$class."\">".$state2."</span>";
- }
- else{
- $output=$state2;
- }
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatGabaritSystem($sInput, $class=NULL)
- // formate la sortie pour qu'on puisse voir si c'est un gabarit system
- // IN: $sInput: t ou f : designant si system
- // OUT: (string) ce qu'on affiche sur la page
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatGabaritSystem($sInput, $class=NULL){
- $state="("._("Systeme").")";
- if ($sInput=="t"){
- if ($class!=""){
- $output="<span class=\"".$class."\">".$state."</span>";
- }
- else{
- $output=$state;
- }
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // formatHTML($sTemp)
- // formate la sortie pour qu'on puisse l'afficher sur du html sans qu'elle n'utilise de
- // mot réservé propore au html.
- // IN: $sTemp: string à afficher
- // OUT: (string) le résultat du string une fois formaté
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatHTML($sTemp){
- return (htmlentities($sTemp));
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // formatJS($sTemp)
- // formate la sortie pour qu'on puisse l'afficher sur du html sans qu'elle n'utilise de
- // mot réservé propore au html.
- // IN: $sTemp: string à afficher
- // OUT: (string) le résultat du string une fois formaté
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatJS($sTemp){
- return (addslashes($sTemp));
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Set le format d'affichage d'un nom.
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatName($sNom, $sPrenom){
- if (($sNom!="") && ($sPrenom!="")){
- return (strtoupper($sNom).", ".$sPrenom);
- }
- elseif ($sNom!=""){
- return (strtoupper($sNom));
- }
- elseif ($sPrenom!=""){
- return ($sPrenom);
- }
- else{
- return ( _("sans nom") );
- }
- }
-
- //S.C. 2007-03-28 demande #37 Ajout de la fonction formatNameLieu
- ///////////////////////////////////////////////////////////////////////////////////////
- // Set le format d'affichage d'un nom et le # lieu de travail
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatNameLieu($sNom, $sPrenom, $sLieu){
- if (($sNom!="") && ($sPrenom!="") && ($sLieu!="")){
- return (strtoupper($sNom).", ".$sPrenom." (".$sLieu.")");
- }
- if (($sNom!="") && ($sPrenom!="")){
- return (strtoupper($sNom).", ".$sPrenom);
- }
- elseif ($sNom!=""){
- return (strtoupper($sNom));
- }
- elseif ($sPrenom!=""){
- return ($sPrenom);
- }
- elseif ($sLieu!=""){
- return ($sLieu);
- }
- else{
- return ( _("vide") );
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatNbInscription($nbIns, $nbMax, $classOK=NULL, $classNOT=NULL)
- // formate le nombre d'inscription. Losrque c'est plein, ou pas plein, on a la possibilité
- // de changer le style sheet (couleur ou autres)
- // IN: $nbIns nombre de personne actuellement inscrit
- // $nbMax nombre maximal de personne
- // $classOK class si le nombre de personne permet l'inscription encore
- // $classNOT class si la session est pleine
- // OUT: (string) le résultat du string une fois formaté
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatNbInscription($nbIns, $nbMax, $classOK=NULL, $classNOT=NULL){
- unset($output);
- if (is_numeric($nbIns) && is_numeric($nbMax)){
- if ($nbIns < $nbMax){
- $class = $classOK;
- }
- else{
- $class = $classNOT;
- }
- //output
- if ($class!=""){
- $output = "<span class=\"".$class."\">".$nbIns."/".$nbMax."</span>";
- }
- else{
- $output = $nbIns."/".$nbMax;
- }
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // formatNote($sNote $class)
- // Set le format d'affichage pour les notes de sessions
- // IN: $sNote note à écrire
- // $class est-ce qu'il y a une classe auquel on veux lier (CSS)
- // OUT: (string) affichage du code avec l'atelier et le projet
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatNote( $sNote, $class = "" ){
- if ( $sNote != "" ){
- $sNote = "(" . $sNote . ")";
- if ( $class != "" ){
- $sNote = "<span class='" . $class . "'>" . $sNote . "</span>";
- }
- }
-
- return $sNote;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // formatParamString($sParam, $sParamValeur)
- // Set le format les parametre SQL et leurs valeurs
- // IN: $sParam: string contenant les parametres SQL separes par des virgules
- // $sParameValeur: string contenant les valeurs des parametres SQL separees par des virgules
- // OUT: (string) une belle ligne qui nous fait le resume
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatParamString($sParam, $sParamValeur){
- unset($output);
- if (($sParam!="") || ($sParamValeur!= "")){
- $arrParam = split(",", $sParam);
- $arrParamValeur = split(",", $sParamValeur);
- unset($arrOutput);
- for ($i=0; $i<count($arrParam); $i++){
- $arrOutput[$i] = $arrParam[$i]." = ".$arrParamValeur[$i];
- }
- $output = join(", ", $arrOutput);
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // function formatPresence
- // Retourne une chaine approprie dependamment du statut de presence recu.
- // IN: $sTemp: (oui, non, ind)
- // $sTemp statut de presence
- // $expire assume une expiration de date
- // OUT: (string) le résultat du string une fois formaté
- ///////////////////////////////////////////////////////////////////////////////
- function formatPresence($sTemps, $statut, $expire) {
- if( $statut == "t" ) {
- $output = $sTemps[0];
- }
- else if( $statut == "f" ) {
- $output = $sTemps[1];
- }
- else {
- $output = $expire ? $sTemps[1] : $sTemps[2];
- }
-
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatRequeteSQL
- // formate la sortie pour qu'on puisse afficher du code SQL lisible.
- // IN: $sTemp: string à afficher
- // OUT: (string) le résultat du string une fois formaté
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatRequeteSQL($sTemp){
- $output=$sTemp;
- $output=str_replace(" FROM ", "\rFROM ", $output);
- $output=str_replace(" from ", "\rFROM ", $output);
- $output=str_replace(" WHERE ", "\rWHERE ", $output);
- $output=str_replace(" where ", "\rWHERE ", $output);
- $output=str_replace(" AND ", "\rAND ", $output);
- $output=str_replace(" and ", "\rAND ", $output);
- $output=str_replace(" OR ", "\rOR ", $output);
- $output=str_replace(" or ", "\rOR ", $output);
- $output=str_replace(" GROUP BY ", "\rGROUP BY ", $output);
- $output=str_replace(" group by ", "\rGROUP BY ", $output);
- $output=str_replace(" ORDER BY ", "\rORDER BY ", $output);
- $output=str_replace(" order by ", "\rORDER BY ", $output);
- //$output=wordwrap($output, $width, "\r");
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // formatSeance($sSesCode, $sAtelier, $sProjet, $sSeaCode)
- // Set le format d'affichage pour les codes de sessions
- // IN: $sCode code de session
- // $sAtelier nom de l'atelier parent
- // $sProjet projet parent
- // OUT: (string) affichage du code avec l'atelier et le projet
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatSeance($sSesCode, $sAtelier, $sProjet, $sSeaCode){
- $session = formatSession($sSesCode, $sAtelier, $sProjet);
- return ($session." : "._("seance")." ".$sSeaCode);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // formatSession($sSesCode, $sAtelier, $sProjet)
- // Set le format d'affichage pour les codes de sessions
- // IN: sSesCode code de session
- // $sAtelier nom de l'atelier parent
- // $sProjet projet parent
- // OUT: (string) affichage du code avec l'atelier et le projet
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatSession($sSesCode, $sAtelier, $sProjet){
- if( ( $sSesCode != "" ) && ( $sAtelier != "" ) ){
- return ($sSesCode." [".$sAtelier."]");
- } else {
- return $sSesCode;
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // formatSessionCode($sSesCode, $sAtelier, $sProjet)
- // Set le format d'affichage pour les codes de sessions
- // IN: sSesCode code de session
- // $sAtelier nom de l'atelier parent
- // $sProjet projet parent
- // OUT: (string) affichage du code de la session
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatSessionCode($sSesCode, $sAtelier, $sProjet){
- return $sSesCode;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // formatSessionDescription($sSesCode, $sAtelier, $sProjet)
- // Set le format d'affichage pour la description de la session
- // IN: sSesCode code de session
- // $sAtelier nom de l'atelier parent
- // $sProjet projet parent
- // OUT: (string) affichage de l'atelier et du projet
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatSessionDescription($sSesCode, $sAtelier, $sProjet){
- return $sAtelier;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatSessionInscriptibleComplete( $nbInscription, $nbInscriptionMax, $sesAnnule, $dSesLimite, $separator, $classOK = "", $classNOT = "" )
- // Set le format d'affichage lorsqu'une session est "non-inscriptible"
- // IN: $nbIns nombre de personne actuellement inscrit
- // $nbMax nombre maximal de personne pouvant s'inscrire
- // $sesAnnule "t" ou "f" qui dit si la sessions est annulée
- // $dSesLimite date limite de la session
- // $separator separateur à l'affichage entre chaque raison qui rend une session "non-inscriptible"
- // $classOK -- Inutile --
- // $classNOT class si la session est pleine
- // OUT: (string) le résultat du string une fois formaté
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatSessionInscriptibleComplete( $nbInscription, $nbInscriptionMax, $sesAnnule, $dSesLimite, $separator, $classOK = "", $classNOT = "" ){
- $output = "";
- $arrNOT = array();
-
- // Création des messages d'erreur
- if( $nbInscription >= $nbInscriptionMax ){
- $arrNOT[] = _("session complete");
- }
- if( $sesAnnule == "t" ){
- $arrNOT[]= _("session annulee");
- }
- if( ( isDate( $dSesLimite ) ) && ( strtotime( date( "Y-m-d" ) ) > strtotime( $dSesLimite ) ) ){
- $arrNOT[] = _("date limite depassee");
- }
-
- // Si des messages d'erreur ont été créés, on les affiche
- if( count( $arrNOT ) > 0 ){
- if( $classNOT != "" ){
- $output = "<span class='" . $classNOT . "'>"._("non inscriptible :")." " . implode( $separator, $arrNOT ) . "</span>";
- } else {
- $output = _("non inscriptible :")." " . implode( $separator, $arrNOT );
- }
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatStateActivite($classNOT, $separator, $args)
- // JE M'EXCUSE CETTE FONCTION EST AFFREUSE(youri). Vous pouvez la refaire si vous voulez.
- // affiche l'état d'une fiche dans un listing (ex: recherche). Dès que la fiche parent,
- // ou la fiche actuelle est annulée ou invalide, cette fonction affiche (annulé) ou (invalide).
- // IN: $classNOT class (pour le span) du style sheet si la fiche est invalide ou annulée
- // $separator separateur entre les 2 messages possible pour la fiche
- // $prj_valide t ou f
- // $act_valide t ou f
- // $act_annule t ou f
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatStateActivite($classNOT, $separator, $args){
- //config
- $arrState[0]=array("f","("._("invalide").")"); // projet
- $arrState[1]=array("f","("._("invalide").")"); // activite
- $arrState[2]=array("t","("._("annule").")"); // activite
- //ne pas toucher
- $MINPARAM = 2;
- unset($arrStateMatch);
- $iMatch=0;
- $args=func_get_args();
- for ($i = $MINPARAM; $i < count($args); $i++){
- if (!strcasecmp($args[$i], $arrState[$i-$MINPARAM][0])){
- $arrStateMatch[$iMatch]=$arrState[$i-$MINPARAM][1];
- $iMatch++;
- }
- }
- //le output
- unset($output);
- if (is_array($arrStateMatch)){
- $arrStateMatch=array_unique($arrStateMatch);
- if($classNOT!=""){
- $output="<span class=\"".$classNOT."\">".join($separator, $arrStateMatch)."</span>";
- }
- else{
- $output=join($separator, $arrStateMatch);
- }
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatStateActiviteComplete($classOK, $classNOT, $separator, $args)
- // JE M'EXCUSE CETTE FONCTION EST AFFREUSE(youri). Vous pouvez la refaire si vous voulez.
- // affiche l'état d'une activite en fonction si la fiche ou la fiche parent est
- // annulée ou invalide ou autres.
- // IN: $classOK class (pour le span) du style sheet si la fiche est valide et active
- // $classNOT class (pour le span) du style sheet si la fiche est invalide ou annulée
- // $separator separateur entre les différents messages de non validité
- // $prj_valide t ou f
- // $act_valide t ou f
- // $act_annule t ou f
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatStateActiviteComplete($classOK, $classNOT, $separator, $args){
- //config: tableau qui fait la comparaison et affiche ce qui suit si la comparaison fit
- $arrState[0]=array("f",_("projet invalide") ); // projet
- $arrState[1]=array("f",_("activite invalide") ); // activite
- $arrState[2]=array("t",_("activite annulee") ); // activite
- $stateOK="actif";
- //ne pas toucher
- $MINPARAM = 3;
- unset($arrStateMatch);
- $iMatch=0;
- $args=func_get_args();
- for ($i = $MINPARAM; $i < count($args); $i++){
- if (!strcasecmp($args[$i], $arrState[$i-$MINPARAM][0])){
- $arrStateMatch[$iMatch]=$arrState[$i-$MINPARAM][1];
- $iMatch++;
- }
- }
- //le output
- unset($output);
- if (is_array($arrStateMatch)){
- if($classNOT!=""){
- $output="<span class=\"".$classNOT."\">".join($separator, $arrStateMatch)."</span>";
- }
- else{
- $output=join($seperator, $arrStateMatch);
- }
- }
- else{
- if($classOK!=""){
- $output="<span class=\"".$classOK."\">".$stateOK."</span>";
- }
- else{
- $output=$stateOK;
- }
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatStateAnnule($annule, $class=NULL)
- // Affiche un texte si c'est annulé.
- // IN: $valide: 't' si valide
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatStateAnnule($annule, $class=NULL){
- $state="("._("annule").")";
- if ($annule=="t"){
- if ($class!=""){
- $output="<span class=\"".$class."\">".$state."</span>";
- }
- else{
- $output=$state;
- }
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatStateFormation($classNOT, $separator, $args)
- // Affiche l'état d'une fiche dans un listing (ex: recherche) d'après les informations reçues
- // IN: $classNOT class (pour le span) du style sheet si la fiche est invalide ou annulée
- // $separator separateur entre les 2 messages possible pour la fiche
- // $prj_valide t par défaut
- // $atl_valide t par défaut
- // $ses_valide t par défaut
- // $ses_annule f par défaut
- // $sea_valide t par défaut
- // $sea_annule f par défaut
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatStateFormation( $classNOT = "", $separator = "", $prj_valide = "t", $atl_valide = "t", $ses_valide = "t", $ses_annule = "f", $sea_valide = "t", $sea_annule = "f" ){
- $output = "";
-
- if( $prj_valide != "t" || $atl_valide != "t" || $ses_valide != "t" || $sea_valide != "t" ){
- $output .= "("._("invalide").")";
- }
-
- if( $ses_annule != "f" || $sea_annule != "f" ){
- if( $output != "" ){
- $output .= $separator;
- }
- $output .= "("._("annulee").")";
- }
-
- // Met une classe CSS à notre état si elle a été fournit
- if( $output != "" && $classNOT != "" ){
- $output = "<span class='" . $classNOT . "'>" . $output . "</span>";
- }
-
- return $output;
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatStateFormationComplete($classOK, $classNOT, $separator, $args)
- // JE M'EXCUSE CETTE FONCTION EST AFFREUSE(youri). Vous pouvez la refaire si vous voulez.
- // affiche l'état d'une fiche (projet, atelier, session, seance) en fonction si la
- // fiche ou la fiche parent est annulé ou invalide ou autres.
- // IN: $classOK class (pour le span) du style sheet si la fiche est valide et active
- // $classNOT class (pour le span) du style sheet si la fiche est invalide ou annulée
- // $separator separateur entre les différents messages de non validité
- // $prj_valide t ou f
- // $atl_valide t ou f
- // $ses_valide t ou f
- // $ses_annule t ou f
- // $sea_valide t ou f
- // $sea_annule t ou f
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatStateFormationComplete($classOK, $classNOT, $separator, $args){
- //config: tableau qui fait la comparaison et affiche ce qui suit si la comparaison fit
- $arrState[0]=array("f",_("projet invalide") ); // projet
- $arrState[1]=array("f",_("atelier invalide") ); // atelier
- $arrState[2]=array("f",_("session invalide") ); // session
- $arrState[3]=array("t",_("session annulee") ); // session
- $arrState[4]=array("f",_("seance invalide") ); // seance
- $arrState[5]=array("t",-("seance annulee") ); // seance
- $stateOK="actif";
- //ne pas toucher
- $MINPARAM = 3;
- $ok=true;
- unset($arrStateMatch);
- $iMatch=0;
- $args=func_get_args();
- for ($i = $MINPARAM; $i < count($args); $i++){
- if (!strcasecmp($args[$i], $arrState[$i-$MINPARAM][0])){
- $ok=false;
- $arrStateMatch[$iMatch]=$arrState[$i-$MINPARAM][1];
- $iMatch++;
- }
- }
- //le output
- unset($output);
- if ($ok==true){
- if($classOK!=""){
- $output="<span class=\"".$classOK."\">".$stateOK."</span>";
- }
- else{
- $output=$stateOK;
- }
- }
- else{
- if (is_array($arrStateMatch)){
- if($classNOT!=""){
- $output="<span class=\"".$classNOT."\">".join($separator, $arrStateMatch)."</span>";
- }
- else{
- $output=join($seperator, $arrStateMatch);
- }
- }
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatStateAnnule($annule, $class=NULL)
- // Affiche un texte si c'est annulé.
- // IN: $valide: 't' si valide
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatStateInscription( $inscriptionEtat, $classOK = "", $classNOT = "", $classHOPE = ""){
- $format = '<span class="%s">%s</span>';
- switch( strtolower( $inscriptionEtat ) ){
- case "t" :
- $etat = _("Valide");
- $class = $classOK;
- break;
- case "f" :
- $etat = _("Invalide");
- $class = $classNOT;
- break;
- case "" :
- $etat = _("A valider");
- $class = $classHOPE;
- break;
- default :
- $etat = "";
- $class = "";
- }
-
- if( $class <> "" ){
- $output = sprintf( $format, $class, $etat );
- } else {
- $output = $etat;
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // formatStateValid($valide, $class=NULL)
- // Affiche un texte si c'est valide ou invalide.
- // IN: $valide: 't' si valide
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatStateValid( $valide, $class = "" ){
- $output = "";
-
- if( $valide == "f" ){
- $output = "("._("invalide").")";
-
- if( $class <> "" ){
- $output = "<span class='" . $class . "'>" . $output . "</span>";
- }
- }
-
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function formatTelephone($sTel, $countryCode = "ca")
- // formate la sortie pour qu'on puisse afficher le numéro teléphone
- // IN: $sTel: no de tel
- // OUT: (string) le résultat du telephone une fois formaté
- ///////////////////////////////////////////////////////////////////////////////////////
- function formatTelephone($sTel){
- global $cfgCountry;
- $output=$sTel;
- switch ($cfgCountry){
- case "us":
- case "ca":
- if (ereg("^[^0-9]*"."([0-9]{3})"."[^0-9]*"."([0-9]{3})"."[^0-9]*"."([0-9]{4})"."[^0-9]*"."([0-9]*)$", $sTel, $regs)){
- if ($regs[4]!=""){
- $output = "(".$regs[1].") ".$regs[2]."-".$regs[3]." ext:".$regs[4];
- } else {
- $output = "(".$regs[1].") ".$regs[2]."-".$regs[3];
- }
- }
- break;
- default:
- break;
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function generatePassword($nbLen, $numPercent, $bUseCase=false)
- // Retourne le mot de passe généré automatiquement
- // méthode tient compte de ne pas séparer les mot entre guillemet
- // IN: $nbLen longueur désiré du mot de passe
- // $numPercent pourcentage des chances que le char soit un nombre
- // $bUseCase est-ce qu'on veut utiliser le case dans les lettres
- // OUT: (string) mot de passe
- ///////////////////////////////////////////////////////////////////////////////////////
- function generatePassword($nbLen, $numPercent, $bUseCase=false){
- unset($psw);
- for($i=0; $i<$nbLen; $i++){
- if (rand(0,100)<$numPercent){
- //on met un chiffre
- $char = chr(rand(48,57));
- }
- else{
- if ($bUseCase){
- if (rand(0,1)==0){
- //on met une lettre minuscule
- $char = chr(rand(97,122));
- }
- else{
- //on met une lettre majuscule
- $char = chr(rand(65,90));
- }
- }
- else{
- //on met une lettre minuscule
- $char = chr(rand(97,122));
- }
- }
- $psw.=$char;
- }
- return ($psw);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // getArrayFromStringMot($sQuery)
- // Retourne le tableau contenant les différents mot pour le moteur de recherche. Cette
- // méthode tient compte de ne pas séparer les mot entre guillemet
- // IN: $sQuery: string de requête fait sur la page web
- // OUT: (array) tableau contenant chaque mot de la requête dans un éléments
- ///////////////////////////////////////////////////////////////////////////////////////
- function getArrayFromStringMot( $sQuery ){
- // Retourne la liste de tous les éléments qui sont entourés par des guillemets doubles OU qui sont des mots
- $nb_match = preg_match_all( "(\"[^\"]+\"|\w+)", $sQuery, $list );
-
- // Pour chaque élément, remplace les guillemets par rien
- foreach( $list[ 0 ] as $id => $element ){
- $list[ 0 ][ $id ] = str_replace( "\"", "", $list[ 0 ][ $id ] );
- }
-
- // Comme PREG_MATCH_ALL retourne un array avec un array par séquence et que nous n'en avons qu'une, on retourne la première
- return $list[ 0 ];
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function getMaxStrlenFromArray($arrTemp)
- // Retourne le plus grand strlen de tous les éléments du tableaux
- // IN: $arrTemp tableau à parser
- // OUT: (integer) la plus grand strlen des éléments du tableau
- ///////////////////////////////////////////////////////////////////////////////////////
- function getMaxStrlenFromArray($arrTemp){
- $themax = 0;
- for ($i=0; $i<count($arrTemp); $i++){
- $temp = strlen($arrTemp[$i]);
- if($temp>$themax){
- $themax = $temp;
- }
- }
- return ($themax);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function getMoney($sInput)
- // Retourne un nombre avec deux décimales. On enlève toutes les currency. On veut rien
- // savoir. Comme ça tout le monde (international) est content!
- // voici le format comme on le veut : XXXXXXX.XX (x = [0-9])
- // IN: $sInput: le montant à vérifier
- // OUT: si le nombre est valide:
- ///////////////////////////////////////////////////////////////////////////////////////
- function getMoney($sInput){
- if (ereg("([0-9]*[.]{0,1}[0-9]{1,2})",$sInput,$regs)){
- return ($regs[1]);
- }
- return (0);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne un string HTML contenant les textbox pour un noTel
- ///////////////////////////////////////////////////////////////////////////////////////
- function getTBTelephone($tbName, $sTel, $bExt, $class, $jsOnChange){
- global $cfgCountry;
- $output = "<input class=\"".$class."\" type=\"hidden\" name=\"".$tbName."\" value=\"".formatHTML($sTel)."\" />";
- switch ($cfgCountry){
- case "us":
- case "ca":
- $jsOnchange = "this.form.".$tbName.".value=this.form.".$tbName."_1.value+this.form.".$tbName."_2.value+this.form.".$tbName."_3.value+this.form.".$tbName."_4.value;".$jsOnChange;
- ereg("^[^0-9]*"."([0-9]{3})"."[^0-9]*"."([0-9]{3})"."[^0-9]*"."([0-9]{4})"."[^0-9]*"."([0-9]*)$", $sTel, $regs);
- $output .= "( ";
- $output .= "<input class=\"".$class."\" type=\"text\" name=\"".$tbName."_1\" value=\"".$regs[1]."\" size=\"3\" maxlength=\"3\" onchange=\"".$jsOnchange."\" onfocus=\"select(this);\" onkeyup=\"if (this.value.length==3) { this.form.".$tbName."_2.focus(); }\" />";
- $output .= " ) ";
- $output .= "<input class=\"".$class."\" type=\"text\" name=\"".$tbName."_2\" value=\"".$regs[2]."\" size=\"3\" maxlength=\"3\" onchange=\"".$jsOnchange."\" onfocus=\"select(this);\" onkeyup=\"if (this.value.length==3) { this.form.".$tbName."_3.focus(); }\" />";
- $output .= " - ";
- $output .= "<input class=\"".$class."\" type=\"text\" name=\"".$tbName."_3\" value=\"".$regs[3]."\" size=\"4\" maxlength=\"4\" onchange=\"".$jsOnchange."\" onfocus=\"select(this);\" />";
- if ($bExt){
- $output .= " ext:";
- $output .= "<input class=\"".$class."\" type=\"text\" name=\"".$tbName."_4\" value=\"".$regs[4]."\" size=\"4\" maxlength=\"4\" onchange=\"".$jsOnchange."\" onfocus=\"select(this);\" />";
- } else {
- $output .= "<input class=\"".$class."\" type=\"hidden\" name=\"".$tbName."_4\" value=\"".$regs[4]."\" />";
- }
- break;
- default:
- $output = _("Code d'identification du pays inconnu");
- break;
- }
- return $output;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function getQueryStringUpdated($querystring)
- // Modifie le querystring en fonction des variables et valeurs fournies en paramètres
- // Si la variable en paramètre existe déjà dans le querystring, sa valeur sera modifiée
- // pour la nouvelle valeur spécifiée. Si la variable n'existe pas, alors le champs sera
- // ajouter au querystring avec la valeur soumissionnée.
- // ex: newQS = getQueryStringUpdated($HTTP_SERVER_VARS["QUERY_STRING"], "mode", "edit");
- // IN: $querystring: le querystring actuel (ex:"mode=display&pg=1&indx=alpha")
- // $var1: variable dans le querystring qu'on veux ajouter au modifier (ex: "mode")
- // $val1: valeur à mettre dans la première variable (ex: "edit")
- // $var2: 2e variable à modifier ou ajouter
- // $val2: valeur de la 2e variable
- // $varX: Xe variable à modifier ou ajouter
- // $valX: valeur de la Xe variable
- // OUT: (querystringNew) le nouveau querystring
- ///////////////////////////////////////////////////////////////////////////////////////
- function getQueryStringUpdated( $query_string ){
- // Enlève les ? du début de la string
- while( isset( $query_string[ 0 ] ) && $query_string[ 0 ] == "?" ){
- $query_string = substr( $query_string, 1 );
- }
-
- // Fait la liste de tous les éléments GET de l'URL
- $query_tab = explode( "&", $query_string );
- $list_elements = array();
- foreach( $query_tab as $element ){
- list( $nom, $valeur ) = explode( "=", $element );
- if( $valeur <> "" ){
- $list_elements[ $nom ] = $valeur;
- }
- }
-
- // On passe par-dessus le premier parce que c'est QUERY_STRING
- $num_args = func_num_args();
- for( $i = 1; $i < $num_args; $i = $i + 2 ){
- // Fetch les informations de l'argument
- $nom_arg = urlencode( func_get_arg( $i ) );
- if( $num_args >= ( $i + 1 ) ){
- $val_arg = urlencode( func_get_arg( $i + 1 ) );
- } else {
- $val_arg = "";
- }
-
- $list_elements[ $nom_arg ] = $val_arg;
- }
-
- // Bâtit la string à retourner
- $query_string = "";
- $premier_element = true;
- foreach( $list_elements as $nom => $valeur ){
- if( !$premier_element ){
- $query_string .= "&";
- } else {
- $premier_element = false;
- }
- $query_string .= $nom . "=" . $valeur;
- }
- return $query_string;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelActivite($act_id){
- $SQLStmt="DELETE FROM activite";
- $SQLStmt.=" WHERE act_id=".$act_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelActiviteArray($arrnTemp){
- $SQLStmt="DELETE FROM activite";
- $SQLStmt.=" WHERE act_id<>act_id";
- for ($i=0; $i<=count($arrnTemp); $i++){
- if (is_numeric($arrnTemp[$i])){
- $SQLStmt.=" OR act_id=".$arrnTemp[$i];
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelActiviteFromProjet($prj_id){
- $SQLStmt="DELETE FROM activite";
- $SQLStmt.=" WHERE prj_id=".$prj_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelAtelier($atl_id){
- $SQLStmt="DELETE FROM atelier";
- $SQLStmt.=" WHERE atl_id=".$atl_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelAtelierArray($arrnTemp){
- $SQLStmt = "Delete From atelier a Where a.atl_id <> a.atl_id";
- foreach( $arrnTemp as $atl_id ) {
- if( is_numeric( $atl_id ) ){
- $SQLStmt .= " Or ( a.atl_id = '" . $atl_id . "' And a.atl_id Not In ( Select s.atl_id From session s Where a.atl_id = s.atl_id ) )";
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelAtelierClasse($atl_id){
- $SQLStmt="DELETE FROM atelier_classe";
- $SQLStmt.=" WHERE atl_id=".$atl_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelAtelierClientele($atl_id){
- $SQLStmt="DELETE FROM atelier_clientele";
- $SQLStmt.=" WHERE atl_id=".$atl_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelAtelierExpertise($atl_id){
- $SQLStmt="DELETE FROM atelier_expertise";
- $SQLStmt.=" WHERE atl_id=".$atl_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelAtelierProjet($atl_id){
- $SQLStmt="DELETE FROM projet_atelier";
- $SQLStmt.=" WHERE atl_id=".$atl_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelCedule($ced_id){
- $SQLStmt="DELETE FROM ceduleur";
- $SQLStmt.=" WHERE ced_id=".$ced_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelCeduleArray($arrnTemp){
- $SQLStmt="DELETE FROM ceduleur";
- $SQLStmt.=" WHERE ced_id<>ced_id";
- for ($i=0; $i<=count($arrnTemp); $i++){
- if (is_numeric($arrnTemp[$i])){
- $SQLStmt.=" OR ced_id=".$arrnTemp[$i];
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelClasseArray($arrnTemp){
- return (getSQLStmtDelNodeArray($arrnTemp));
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- /* $Author: stacil $ [$Date: 2008/07/03 18:29:46 $]
- function getSQLStmtDelClienteleArray($arrnTemp){
- $SQLStmt="DELETE FROM clientele";
- $SQLStmt.=" WHERE cli_id<>cli_id";
- for ($i=0; $i<=count($arrnTemp); $i++){
- if ($arrnTemp[$i]!="" && is_numeric($arrnTemp[$i])){
- $SQLStmt.=" OR cli_id=".$arrnTemp[$i];
- }
- }
- return $SQLStmt;
- }
- */
- function getSQLStmtDelClienteleArray($arrnTemp){
- return (getSQLStmtDelNodeArray($arrnTemp));
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelExpertiseArray($arrnTemp){
- return (getSQLStmtDelNodeArray($arrnTemp));
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelGabarit($gab_id){
- $SQLStmt="DELETE FROM gabarit";
- $SQLStmt.=" WHERE gab_id=".$gab_id;
- $SQLStmt.=" AND gab_system='f'";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelGabaritArray($arrnTemp){
- $SQLStmt="DELETE FROM gabarit";
- $SQLStmt.=" WHERE gab_id<>gab_id";
- for ($i=0; $i<=count($arrnTemp); $i++){
- if (is_numeric($arrnTemp[$i])){
- $SQLStmt.=" OR (gab_id=".$arrnTemp[$i];
- $SQLStmt.=" AND gab_system='f')";
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelGabaritBaliseArray($gab_id, $arrnTemp){
- $SQLStmt="DELETE FROM gabaritBalise";
- $SQLStmt.=" WHERE gab_id = ".$gab_id;
- $SQLStmt.=" AND ( gb_id <> gb_id";
- for ($i=0; $i<=count($arrnTemp); $i++){
- if ($arrnTemp[$i]!="" && is_numeric($arrnTemp[$i])){
- $SQLStmt.=" OR gb_id=".$arrnTemp[$i];
- }
- }
- $SQLStmt.=")";
- return $SQLStmt;
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour valider si la premiere seance de la
- // session est depassee
- // Ajouté par Francine Bolduc le 2 mars 2010
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqSessionTermineBySesId($ses_id){
- $SQLStmt = "";
-
- if( is_numeric( $ses_id ) && $ses_id != null){
- $SQLStmt = "SELECT MIN(SUBSTR(sea_datedebut::text,1,10)) as db
- FROM seance
- WHERE ses_id = '" . $ses_id . "'" . " AND sea_valide='t'";
- }
- return $SQLStmt;
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelInscription($usrid, $sesid){
- $SQLStmt="DELETE FROM inscriptionSession";
- $SQLStmt.=" WHERE usr_id=".$usrid;
- $SQLStmt.=" AND ses_id=".$sesid;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelInscriptionArray($arrnTemp){
- $SQLStmt="DELETE FROM inscriptionSession";
- $SQLStmt.=" WHERE ses_id<>ses_id";
- for ($i=0; $i<=count($arrnTemp); $i++){
- ereg("^([0-9]+)[.]{1}([0-9]+)$",$arrnTemp[$i],$regs);
- $usager=$regs[1];
- $session=$regs[2];
- if ((is_numeric($usager))&&(is_numeric($session))){
- $SQLStmt.=" OR ( usr_id=".$usager;
- $SQLStmt.=" AND ses_id=".$session.")";
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelLieu($li_id){
- $SQLStmt="DELETE FROM lieu";
- $SQLStmt.=" WHERE li_id=".$li_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelLieuAdmin($li_id){
- $SQLStmt="DELETE FROM lieuAdmin";
- $SQLStmt.=" WHERE li_id=".$li_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelLieuSupport($li_id){
- $SQLStmt="DELETE FROM lieuSupport";
- $SQLStmt.=" WHERE li_id=".$li_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelLieuArray($arrnTemp){
- $SQLStmt="DELETE FROM lieu";
- $SQLStmt.=" WHERE li_id<>li_id";
- for ($i=0; $i<=count($arrnTemp); $i++){
- if (is_numeric($arrnTemp[$i])){
- $SQLStmt.=" OR li_id=".$arrnTemp[$i];
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelNodeArray($arrnTemp){
- $SQLStmt="DELETE FROM nodes";
- $SQLStmt.=" WHERE node<>node";
- for ($i=0; $i<=count($arrnTemp); $i++){
- if (is_numeric($arrnTemp[$i])){
- $SQLStmt.=" OR node=".$arrnTemp[$i];
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelPresence($sea_id){
- $SQLStmt="DELETE FROM presence";
- $SQLStmt.=" WHERE sea_id=".$sea_id;
- return $SQLStmt;
- }
-
- function getSQLStmtDelProjetAdmin($prj_id){
- $SQLStmt="DELETE FROM projetAdmin";
- $SQLStmt.=" WHERE prj_id=".$prj_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelProjetArray($arrnTemp){
- $SQLStmt="DELETE FROM projet";
- $SQLStmt.=" WHERE prj_id<>prj_id";
- for ($i=0; $i<=count($arrnTemp); $i++){
- if (is_numeric($arrnTemp[$i])){
- $SQLStmt.=" OR prj_id=".$arrnTemp[$i];
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelSeance($sea_id){
- $SQLStmt="DELETE FROM seance";
- $SQLStmt.=" WHERE sea_id=".$sea_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelSeanceArray($arrnTemp){
- $SQLStmt="DELETE FROM seance";
- $SQLStmt.=" WHERE sea_id<>sea_id";
- for ($i=0; $i<=count($arrnTemp); $i++){
- if (is_numeric($arrnTemp[$i])){
- $SQLStmt.=" OR sea_id=".$arrnTemp[$i];
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelSession($ses_id){
- $SQLStmt="DELETE FROM session";
- $SQLStmt.=" WHERE ses_id=".$ses_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelSessionAnimation($ses_id){
- $SQLStmt="DELETE FROM animation";
- $SQLStmt.=" WHERE ses_id=".$ses_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelSessionArray($arrnTemp){
- $SQLStmt="DELETE FROM session";
- $SQLStmt.=" WHERE ses_id<>ses_id";
- for ($i=0; $i<=count($arrnTemp); $i++){
- if (is_numeric($arrnTemp[$i])){
- $SQLStmt.=" OR ses_id=".$arrnTemp[$i];
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelUsager($usr_id){
- $SQLStmt="DELETE FROM usager";
- $SQLStmt.=" WHERE usr_id=".$usr_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
- // IN: $arrnTemp: tableau contenant les ID a supprimer
- // OUT: (sqlstmt) requête sql effectuant la supression
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelUsagerArray($arrnTemp){
- $SQLStmt="DELETE FROM usager";
- $SQLStmt.=" WHERE usr_id<>usr_id";
- for ($i=0; $i<=count($arrnTemp); $i++){
- if (is_numeric($arrnTemp[$i])){
- $SQLStmt.=" OR usr_id=".$arrnTemp[$i];
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un DELETE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtDelUsagerUsrTypeArray($usr_id, $arrnTemp){
- $SQLStmt="DELETE FROM usager_usagerType";
- $SQLStmt.=" WHERE usr_id=".$usr_id;
- $SQLStmt.=" AND (ut_id<>ut_id";
- for ($i=0; $i<=count($arrnTemp); $i++){
- if (is_numeric($arrnTemp[$i])){
- $SQLStmt.=" OR ut_id=".$arrnTemp[$i];
- }
- }
- $SQLStmt.=")";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsActivite($act_activite, $prj_id){
- $SQLStmt="INSERT INTO activite";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="act_activite,";
- $SQLValue.="'".fixPGQuote($act_activite)."',";
- $SQLField.="prj_id)";
- if (is_numeric($prj_id)){
- $SQLValue.=$prj_id.")";
- }
- else{
- $SQLValue.="NULL)";
- }
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsAtelier($atl_atelier){
- $SQLStmt="INSERT INTO atelier";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="atl_atelier)";
- $SQLValue.="'".fixPGQuote($atl_atelier)."')";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsAtelierClasse($atl_id, $cla_id){
- $SQLStmt="INSERT INTO atelier_classe";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="atl_id,";
- $SQLValue.=$atl_id.",";
- $SQLField.="cla_id)";
- $SQLValue.=$cla_id.")";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsAtelierClientele($atl_id, $cli_id){
- $SQLStmt="INSERT INTO atelier_clientele";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="atl_id,";
- $SQLValue.=$atl_id.",";
- $SQLField.="cli_id)";
- $SQLValue.=$cli_id.")";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsAtelierExpertise($atl_id, $exp_id){
- $SQLStmt="INSERT INTO atelier_expertise";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="atl_id,";
- $SQLValue.=$atl_id.",";
- $SQLField.="exp_id)";
- $SQLValue.=$exp_id.")";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsAtelierProjet($atl_id, $prj_id){
- $SQLStmt="INSERT INTO projet_atelier";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="atl_id,";
- $SQLValue.=$atl_id.",";
- $SQLField.="prj_id)";
- $SQLValue.=$prj_id.")";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsCedule($ced_cedule, $gab_id){
- $SQLStmt="INSERT INTO ceduleur";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="ced_cedule,";
- $SQLValue.="'".fixPGQuote($ced_cedule)."',";
- $SQLField.="gab_id)";
- $SQLValue.=$gab_id.")";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsClasse($parent, $label){
- return (getSQLStmtInsNode(1, $parent, $label));
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- /* $Author: stacil $ [$Date: 2008/07/03 18:29:46 $]
- function getSQLStmtInsClientele($cli_clientele, $cli_description){
- $SQLStmt="INSERT INTO clientele";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField=$SQLField."cli_clientele,";
- $SQLValue=$SQLValue."'".fixPGQuote($cli_clientele)."',";
- $SQLField=$SQLField."cli_description)";
- $SQLValue=$SQLValue."'".fixPGQuote($cli_description)."')";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return $SQLStmt;
- }
- */
- function getSQLStmtInsClientele($parent, $label) {
- return (getSQLStmtInsNode(3, $parent, $label));
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsCourriel($gab_id, $cou_paramValeur){
- // cou_paramValeur = no_fiche_session,id_usager (SSSSS,UUUUU)
- return "INSERT INTO courriel ( gab_id, cou_paramValeur ) VALUES ( '" . $gab_id."'," . "'" . fixPGQuote( $cou_paramValeur ) . "')";
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsGabarit($gab_gabarit){
- $SQLStmt="INSERT INTO gabarit";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="gab_gabarit)";
- $SQLValue.="'".fixPGQuote($gab_gabarit)."')";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsGabaritBalise($gab_id, $gb_balise, $gb_champ, $gb_description){
- $SQLStmt="INSERT INTO gabaritBalise";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField=$SQLField."gab_id,";
- $SQLValue=$SQLValue.$gab_id.",";
- $SQLField=$SQLField."gb_balise,";
- $SQLValue=$SQLValue."'".fixPGQuote($gb_balise)."',";
- $SQLField=$SQLField."gb_champ,";
- $SQLValue=$SQLValue."'".fixPGQuote($gb_champ)."',";
- $SQLField=$SQLField."gb_description)";
- $SQLValue=$SQLValue."'".fixPGQuote($gb_description)."')";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsInscription($usr_id, $ses_id, $is_ipsoumission, $ie_id, $is_majpar_usr_id){
- $SQLStmt="INSERT INTO inscriptionSession";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="usr_id,";
- $SQLValue.=$usr_id.",";
- $SQLField.="ses_id,";
- $SQLValue.=$ses_id.",";
- $SQLField.="is_datesoumission,";
- $SQLValue.="NOW(),";
- $SQLField.="is_ipsoumission,";
- $SQLValue.="'".fixPGQuote($is_ipsoumission)."',";
- $SQLField.="ie_id,";
- $SQLValue.=$ie_id.",";
- $SQLField.='lieu_id_aInscription,';
- $SQLValue.="(SELECT Li_id from Usager WHERE usr_id=".$usr_id."),";
- $SQLField.="is_majpar_usr_id)";
- $SQLValue.=$is_majpar_usr_id.")";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsLieu($li_lieu){
- $SQLStmt="INSERT INTO lieu";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="li_lieu)";
- $SQLValue.="'".fixPGQuote($li_lieu)."')";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsExpertise($parent, $label){
- return (getSQLStmtInsNode(2, $parent, $label));
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsLieuAdmin($li_id, $usr_id, $la_responsable)
- {
- return getSQLStmtInsLieuAdminFull($li_id, $usr_id, $la_responsable, 'f');
- }
-
-
-
- function getSQLStmtInsLieuAdminFull($li_id, $usr_id, $la_responsable, $la_loi90){
- $SQLStmt="INSERT INTO lieuAdmin";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="li_id,";
- $SQLValue.=$li_id.",";
- $SQLField.="usr_id,";
- $SQLValue.=$usr_id.",";
- $SQLField.="la_responsable,";
- if (!strcasecmp($la_responsable,"t")){
- $SQLValue.="'t',";
- }
- else{
- $SQLValue.="'f',";
- }
-
- $SQLField.="la_courriel_loi90)";
-
- if (!strcasecmp($la_loi90,"t"))
- {
- $SQLValue.="'t')";
- }
- else
- {
- $SQLValue.="'f')";
- };
-
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsLieuSupport($li_id, $usr_id, $ls_responsable){
- $SQLStmt="INSERT INTO lieuSupport";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="li_id,";
- $SQLValue.=$li_id.",";
- $SQLField.="usr_id,";
- $SQLValue.=$usr_id.",";
- $SQLField.="ls_responsable)";
- if (!strcasecmp($ls_responsable,"t")){
- $SQLValue.="'t')";
- }
- else{
- $SQLValue.="'f')";
- }
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsNode($tr_id, $parent, $label){
- $SQLStmt="INSERT INTO nodes";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="tr_id,";
- if (is_numeric($tr_id)){
- $SQLValue.=$tr_id.",";
- }
- else{
- $SQLValue.="NULL,";
- }
- $SQLField.="parent,";
- if (is_numeric($parent)){
- $SQLValue.=$parent.",";
- }
- else{
- $SQLValue.="NULL,";
- }
- $SQLField.="etiquette)";
- $SQLValue.="'".fixPGQuote($label)."')";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsPresence($sea_id, $usr_id, $pr_presence){
- $SQLStmt="INSERT INTO presence";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="sea_id,";
- $SQLValue.=$sea_id.",";
- $SQLField.="usr_id,";
- $SQLValue.=$usr_id.",";
- $SQLField.="pr_presence)";
- if (!strcasecmp($pr_presence,"t")){
- $SQLValue.="'t')";
- }
- else{
- $SQLValue.="'f')";
- }
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsProjet($prj_projet, $pt_id){
- $SQLStmt="INSERT INTO projet";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="prj_projet,";
- $SQLValue.="'".fixPGQuote($prj_projet)."',";
- $SQLField.="pt_id)";
- $SQLValue.=$pt_id.")";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- function getSQLStmtInsProjetAdmin($prj_id, $usr_id, $pa_responsable){
- $SQLStmt="INSERT INTO projetAdmin";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="prj_id,";
- $SQLValue.=$prj_id.",";
- $SQLField.="usr_id,";
- $SQLValue.=$usr_id.",";
- $SQLField.="pa_responsable)";
- if (!strcasecmp($pa_responsable,"t")){
- $SQLValue.="'t')";
- }
- else{
- $SQLValue.="'f')";
- }
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsSeance($ses_id){
- $SQLStmt="INSERT INTO seance";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="ses_id)";
- $SQLValue.=$ses_id.")";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsSession($prj_id, $atl_id){
- $SQLStmt="INSERT INTO session";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="prj_id,";
- $SQLValue.=$prj_id.",";
- $SQLField.="atl_id)";
- $SQLValue.=$atl_id.")";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsSessionAnimation($ses_id, $usr_id, $an_responsable){
- $SQLStmt="INSERT INTO animation";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="ses_id,";
- $SQLValue.=$ses_id.",";
- $SQLField.="usr_id,";
- $SQLValue.=$usr_id.",";
- $SQLField.="an_responsable)";
- if (!strcasecmp($an_responsable,"t")){
- $SQLValue.="'t')";
- }
- else{
- $SQLValue.="'f')";
- }
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsUsager($usr_login, $usr_nom, $usr_prenom, $li_id){
- $SQLStmt="INSERT INTO usager";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="usr_login,";
- $SQLValue.="'".fixPGQuote(rtrim($usr_login))."',";
- $SQLField.="usr_nom,";
- $SQLValue.="'".fixPGQuote(rtrim($usr_nom))."',";
- $SQLField.="usr_prenom,";
- $SQLValue.="'".fixPGQuote(rtrim($usr_prenom))."',";
- $SQLField.="li_id)";
- if (is_numeric($li_id)){
- $SQLValue.=$li_id.")";
- }
- else{
- $SQLValue.="NULL)";
- }
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un INSERT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtInsUsagerUsrType($usr_id, $ut_id){
- $SQLStmt="INSERT INTO usager_usagerType";
- $SQLField="(";
- $SQLValue="VALUES(";
- $SQLField.="usr_id,";
- $SQLValue.=$usr_id.",";
- $SQLField.="ut_id)";
- $SQLValue.=$ut_id.")";
- //Building SQLStmt
- $SQLStmt.=$SQLField.$SQLValue;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdActivite($id, $act_activite, $act_description, $act_lieu, $act_datedebut, $act_datefin, $act_frais, $act_annule, $act_annuleraison, $prj_id, $act_valide){
- $SQLStmt="UPDATE activite SET";
- $SQLStmt.=" act_activite = '".fixPGQuote($act_activite)."',";
- $SQLStmt.=" act_description = '".fixPGQuote($act_description)."',";
- $SQLStmt.=" act_lieu = '".fixPGQuote($act_lieu)."',";
- if (isTimeStamp($act_datedebut)){
- $SQLStmt.=" act_datedebut = '".fixPGQuote($act_datedebut)."',";
- }
- else{
- $SQLStmt.=" act_datedebut = NULL,";
- }
- if (isTimeStamp($act_datefin)){
- $SQLStmt.=" act_datefin = '".fixPGQuote($act_datefin)."',";
- }
- else{
- $SQLStmt.=" act_datefin = NULL,";
- }
- $SQLStmt.=" act_frais = '".fixPGQuote($act_frais)."',";
- if (!strcasecmp($act_annule,"t")){
- $SQLStmt.=" act_annule = 't',";
- }
- else{
- $SQLStmt.=" act_annule = 'f',";
- }
- $SQLStmt.=" act_annuleraison = '".fixPGQuote($act_annuleraison)."',";
- if (is_numeric($prj_id)){
- $SQLStmt.=" prj_id = ".fixPGQuote($prj_id).",";
- }
- else{
- $SQLStmt.=" prj_id = NULL,";
- }
- if (!strcasecmp($act_valide,"t")){
- $SQLStmt.=" act_valide = 't'";
- }
- else{
- $SQLStmt.=" act_valide = 'f'";
- }
- $SQLStmt.=" WHERE act_id = ".$id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdAtelier($id, $atl_atelier, $atl_description, $atl_url, $atl_prealable, $atl_condition, $atl_calendrier, $atl_fraistypique, $atl_note, $atl_commentaire, $atl_alacartedisponible, $usr_id, $atl_valide){
- $SQLStmt="UPDATE atelier SET";
- $SQLStmt.=" atl_atelier = '".fixPGQuote($atl_atelier)."',";
- $SQLStmt.=" atl_description = '".fixPGQuote($atl_description)."',";
- $SQLStmt.=" atl_url = '".fixPGQuote($atl_url)."',";
- $SQLStmt.=" atl_prealable = '".fixPGQuote($atl_prealable)."',";
- $SQLStmt.=" atl_condition = '".fixPGQuote($atl_condition)."',";
- $SQLStmt.=" atl_calendrier = '".fixPGQuote($atl_calendrier)."',";
- $SQLStmt.=" atl_fraistypique = '".fixPGQuote($atl_fraistypique)."',";
- $SQLStmt.=" atl_note = '".fixPGQuote($atl_note)."',";
- $SQLStmt.=" atl_commentaire = '".fixPGQuote($atl_commentaire)."',";
- if (!strcasecmp($atl_alacartedisponible,"t")){
- $SQLStmt.=" atl_alacartedisponible = 't',";
- }
- else{
- $SQLStmt.=" atl_alacartedisponible = 'f',";
- }
- if (is_numeric($usr_id)){
- $SQLStmt.=" usr_id = ".fixPGQuote($usr_id).",";
- }
- else{
- $SQLStmt.=" usr_id = NULL,";
- }
- if (!strcasecmp($atl_valide,"t")){
- $SQLStmt.=" atl_valide = 't'";
- }
- else{
- $SQLStmt.=" atl_valide = 'f'";
- }
- $SQLStmt.=" WHERE atl_id = ".$id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdCedule($id, $ced_cedule, $gab_id, $ced_paramValeur, $ced_intervalle, $ced_dateNext, $ced_valide){
- $SQLStmt="UPDATE ceduleur SET";
- $SQLStmt.=" ced_cedule = '".fixPGQuote($ced_cedule)."',";
- if (is_numeric($gab_id)){
- $SQLStmt.=" gab_id = ". $gab_id.",";
- }
- else{
- $SQLStmt.=" gab_id = NULL,";
- }
- $SQLStmt.=" ced_paramValeur = '".fixPGQuote($ced_paramValeur)."',";
- if (is_numeric($ced_intervalle)){
- $SQLStmt.=" ced_intervalle = ". $ced_intervalle.",";
- }
- else{
- $SQLStmt.=" ced_intervalle = NULL,";
- }
- if (isTimeStamp($ced_dateNext)){
- $SQLStmt.=" ced_dateNext = '".fixPGQuote($ced_dateNext)."',";
- }
- else{
- $SQLStmt.=" ced_dateNext = NULL,";
- }
- if (!strcasecmp($ced_valide,"t")){
- $SQLStmt.=" ced_valide = 't'";
- }
- else{
- $SQLStmt.=" ced_valide = 'f'";
- }
- $SQLStmt.=" WHERE ced_id = ".$id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdClasse($node, $parent, $label){
- return getSQLStmtUpdNode($node, 1, $parent, $label);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- /* $Author: stacil $ [$Date: 2008/07/03 18:29:46 $]
- function getSQLStmtUpdClientele($cli_id, $cli_clientele, $cli_description){
- $SQLStmt="UPDATE clientele SET";
- $SQLStmt.=" cli_clientele = '".fixPGQuote($cli_clientele)."',";
- $SQLStmt.=" cli_description = '".fixPGQuote($cli_description)."'";
- $SQLStmt.=" WHERE cli_id = ".$cli_id;
- return $SQLStmt;
- }
- */
- function getSQLStmtUpdClientele($node, $parent, $label) {
- return getSQLStmtUpdNode($node, 3, $parent, $label);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdGabarit($id, $gab_gabarit, $gab_system, $gab_description, $gab_requeteSQL, $gab_param, $gab_TO, $gab_CC, $gab_BCC, $gab_objet, $gab_body, $gab_valide, $gab_multicourriel){
- $SQLStmt="UPDATE gabarit SET";
- $SQLStmt.=" gab_gabarit = '".fixPGQuote($gab_gabarit)."',";
- if (!strcasecmp($gab_system,"t")){
- $SQLStmt.=" gab_system = 't',";
- }
- else{
- $SQLStmt.=" gab_system = 'f',";
- }
- $SQLStmt.=" gab_description = '".fixPGQuote($gab_description)."',";
- $SQLStmt.=" gab_requeteSQL = '".fixPGQuote($gab_requeteSQL)."',";
- $SQLStmt.=" gab_param = '".fixPGQuote($gab_param)."',";
- $SQLStmt.=" gab_TO = '".fixPGQuote($gab_TO)."',";
- $SQLStmt.=" gab_CC = '".fixPGQuote($gab_CC)."',";
- $SQLStmt.=" gab_BCC = '".fixPGQuote($gab_BCC)."',";
- $SQLStmt.=" gab_objet = '".fixPGQuote($gab_objet)."',";
- $SQLStmt.=" gab_body = '".fixPGQuote($gab_body)."',";
- if (!strcasecmp($gab_valide,"t")){
- $SQLStmt.=" gab_valide = 't',";
- }
- else{
- $SQLStmt.=" gab_valide = 'f',";
- }
- if (!strcasecmp($gab_multicourriel,"t")){
- $SQLStmt.=" gab_multicourriel = 't'";
- }
- else{
- $SQLStmt.=" gab_multicourriel = 'f'";
- }
- $SQLStmt.=" WHERE gab_id = ".$id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdGabaritBalise($gab_id, $gb_id, $gb_balise, $gb_champ, $gb_description){
- $SQLStmt="UPDATE gabaritBalise SET";
- $SQLStmt.=" gb_balise = '".fixPGQuote($gb_balise)."',";
- $SQLStmt.=" gb_champ = '".fixPGQuote($gb_champ)."',";
- $SQLStmt.=" gb_description = '".fixPGQuote($gb_description)."'";
- $SQLStmt.=" WHERE gb_id = ".$gb_id;
- $SQLStmt.=" AND gab_id = ".$gab_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdExpertise($node, $parent, $label){
- return getSQLStmtUpdNode($node, 2, $parent, $label);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdInscriptionEtat($usr_id, $ses_id, $oldetat, $ie_id, $is_majpar_usr_id){
- $SQLStmt="UPDATE inscriptionSession SET";
- if (is_numeric($ie_id)){
- $SQLStmt.=" ie_id = ". $ie_id.",";
- }
- else{
- $SQLStmt.=" ie_id = NULL,";
- }
- if (is_numeric($is_majpar_usr_id)){
- $SQLStmt.=" is_majpar_usr_id = ".$is_majpar_usr_id;
- }
- else{
- $SQLStmt.=" is_majpar_usr_id = NULL";
- }
- $SQLStmt.=" WHERE usr_id = ".$usr_id;
- $SQLStmt.=" AND ses_id = ".$ses_id;
- if (is_numeric($oldetat)){
- $SQLStmt.=" AND ie_id = ".$oldetat;
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdLieu($id, $li_lieu, $newno, $li_adresse, $li_trajet, $li_trajetURL, $li_telephone, $li_ldap, $li_valide, $lt_id){
- $SQLStmt="UPDATE lieu SET";
- $SQLStmt.=" li_lieu = '".fixPGQuote($li_lieu)."',";
- if ( $newno!="" ){
- $SQLStmt.=" li_no = '".$newno."',";
- }
- else{
- $SQLStmt.=" li_no = NULL,";
- }
- if ($lt_id == "") $lt_id = "0"; // ajout 2006/09/18 R.Franche
- $SQLStmt.=" li_adresse = '".fixPGQuote($li_adresse)."',";
- $SQLStmt.=" li_trajet = '".fixPGQuote($li_trajet)."',";
- $SQLStmt.=" li_trajetURL = '".fixPGQuote($li_trajetURL)."',";
- $SQLStmt.=" li_telephone = '".fixPGQuote($li_telephone)."',";
- $SQLStmt.=" lt_id = '".fixPGQuote($lt_id)."',";
- if (!strcasecmp($li_ldap,"t")){
- $SQLStmt.=" li_ldap = 't',";
- }
- else{
- $SQLStmt.=" li_ldap = 'f',";
- }
- if (!strcasecmp($li_valide,"t")){
- $SQLStmt.=" li_valide = 't'";
- }
- else{
- $SQLStmt.=" li_valide = 'f'";
- }
- $SQLStmt.=" WHERE li_id = ".$id;
- //echo $SQLStmt;
- return $SQLStmt;
-
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdNode($node, $tr_id, $parent, $label){
- $SQLStmt="UPDATE nodes SET";
- if (is_numeric($tr_id)){
- $SQLStmt.=" tr_id = ".$tr_id.",";
- }
- else{
- $SQLStmt.=" tr_id = NULL,";
- }
- if (is_numeric($parent)){
- $SQLStmt.=" parent = ".$parent.",";
- }
- else{
- $SQLStmt.=" parent = NULL,";
- }
- $SQLStmt.=" etiquette = '".fixPGQuote($label)."'";
- $SQLStmt.=" WHERE node = ".$node;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdProjet($id, $prj_projet, $prj_description, $prj_prefixe, $prj_url, $prj_datedebut, $prj_datefin, $prj_datelimite, $prj_fraisglobaux, $pt_id, $prj_valide){
- $SQLStmt="UPDATE projet SET";
- $SQLStmt.=" prj_projet = '".fixPGQuote($prj_projet)."',";
- $SQLStmt.=" prj_description = '".fixPGQuote($prj_description)."',";
- $SQLStmt.=" prj_prefixe = '".fixPGQuote($prj_prefixe)."',";
- $SQLStmt.=" prj_url = '".fixPGQuote($prj_url)."',";
- if (isDate($prj_datedebut)){
- $SQLStmt.=" prj_datedebut = '".fixPGQuote($prj_datedebut)."',";
- }
- else{
- $SQLStmt.=" prj_datedebut = NULL,";
- }
- if (isDate($prj_datefin)){
- $SQLStmt.=" prj_datefin = '".fixPGQuote($prj_datefin)."',";
- }
- else{
- $SQLStmt.=" prj_datefin = NULL,";
- }
- if (isDate($prj_datelimite)){
- $SQLStmt.=" prj_datelimite = '".fixPGQuote($prj_datelimite)."',";
- }
- else{
- $SQLStmt.=" prj_datelimite = NULL,";
- }
- $SQLStmt.=" prj_fraisglobaux = '".fixPGQuote($prj_fraisglobaux)."',";
- $SQLStmt.=" pt_id = '".fixPGQuote($pt_id)."',";
- if (!strcasecmp($prj_valide,"t")){
- $SQLStmt.=" prj_valide = 't'";
- }
- else{
- $SQLStmt.=" prj_valide = 'f'";
- }
- $SQLStmt.=" WHERE prj_id = ".$id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdSeance($id, $ses_id, $sea_dateDebut, $sea_dateFin, $sea_duree, $li_id, $sea_lieudetail, $sea_materiel, $sea_materielAnimation, $sea_fraisAnimation, $sea_fraisProduction, $sea_fraisLiberation, $sea_fraisLocation, $sea_fraisAutre, $sea_note, $sea_commentaire, $sea_annule, $sea_annuleRaison, $sea_valide){
- $SQLStmt="UPDATE seance SET";
- if (is_numeric($ses_id)){
- $SQLStmt.=" ses_id = ".$ses_id.",";
- }
- else{
- $SQLStmt.=" ses_id = NULL,";
- }
- if (isTimeStamp($sea_dateDebut)){
- $SQLStmt.=" sea_datedebut = '".fixPGQuote($sea_dateDebut)."',";
- }
- else{
- $SQLStmt.=" sea_datedebut = NULL,";
- }
- if (isTimeStamp($sea_dateFin)){
- $SQLStmt.=" sea_datefin = '".fixPGQuote($sea_dateFin)."',";
- }
- else{
- $SQLStmt.=" sea_datefin = NULL,";
- }
- if (is_numeric($sea_duree)){
- $SQLStmt.=" sea_duree = ".$sea_duree.",";
- }
- else{
- $SQLStmt.=" sea_duree = NULL,";
- }
- if (is_numeric($li_id)){
- $SQLStmt.=" li_id = ".$li_id.",";
- }
- else{
- $SQLStmt.=" li_id = NULL,";
- }
- $SQLStmt.=" sea_lieudetail = '".fixPGQuote($sea_lieudetail)."',";
- $SQLStmt.=" sea_materiel = '".fixPGQuote($sea_materiel)."',";
- $SQLStmt.=" sea_materielAnimation = '".fixPGQuote($sea_materielAnimation)."',";
- $SQLStmt.=" sea_fraisAnimation = '".getMoney($sea_fraisAnimation)."',";
- $SQLStmt.=" sea_fraisProduction = '".getMoney($sea_fraisProduction)."',";
- $SQLStmt.=" sea_fraisLiberation = '".getMoney($sea_fraisLiberation)."',";
- $SQLStmt.=" sea_fraisLocation = '".getMoney($sea_fraisLocation)."',";
- $SQLStmt.=" sea_fraisAutre = '".getMoney($sea_fraisAutre)."',";
- $SQLStmt.=" sea_note = '".fixPGQuote($sea_note)."',";
- $SQLStmt.=" sea_commentaire = '".fixPGQuote($sea_commentaire)."',";
- if (!strcasecmp($sea_annule,"t")){
- $SQLStmt.=" sea_annule = 't',";
- }
- else{
- $SQLStmt.=" sea_annule = 'f',";
- }
- $SQLStmt.=" sea_annuleRaison = '".fixPGQuote($sea_annuleRaison)."',";
- if (!strcasecmp($sea_valide,"t")){
- $SQLStmt.=" sea_valide = 't'";
- }
- else{
- $SQLStmt.=" sea_valide = 'f'";
- }
- $SQLStmt.=" WHERE sea_id = ".$id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdSession($id, $prj_id, $atl_id, $ses_notemini, $ses_note, $ses_commentaire, $ses_dateLimite, $ses_nbMin, $ses_nbMax, $ses_frais, $ses_coutparusager, $ses_regionnal, $ses_annule, $ses_annuleraison, $ses_valide){
- $SQLStmt="UPDATE session SET";
- if (is_numeric($prj_id)){
- $SQLStmt.=" prj_id = ".$prj_id.",";
- }
- else{
- $SQLStmt.=" prj_id = NULL,";
- }
- if (is_numeric($atl_id)){
- $SQLStmt.=" atl_id = ".$atl_id.",";
- }
- else{
- $SQLStmt.=" atl_id = NULL,";
- }
- $SQLStmt.=" ses_notemini = '".fixPGQuote($ses_notemini)."',";
- $SQLStmt.=" ses_note = '".fixPGQuote($ses_note)."',";
- $SQLStmt.=" ses_commentaire = '".fixPGQuote($ses_commentaire)."',";
- if (isDate($ses_dateLimite)){
- $SQLStmt.=" ses_dateLimite = '".fixPGQuote($ses_dateLimite)."',";
- }
- else{
- $SQLStmt.=" ses_dateLimite = NULL,";
- }
- if (is_numeric($ses_nbMin)){
- $SQLStmt.=" ses_nbMin = ".$ses_nbMin.",";
- }
- else{
- $SQLStmt.=" ses_nbMin = 0,";
- }
- if (is_numeric($ses_nbMax)){
- $SQLStmt.=" ses_nbMax = ".$ses_nbMax.",";
- }
- else{
- $SQLStmt.=" ses_nbMax = 0,";
- }
- $SQLStmt.=" ses_frais = '".fixPGQuote($ses_frais)."',";
- if (is_numeric($ses_coutparusager)){
- $SQLStmt.=" ses_coutParUsager = $ses_coutparusager,";
- }
- else{
- $SQLStmt.=" ses_coutParUsager = NULL,";
- }
- if (!strcasecmp($ses_regionnal,"t")){
- $SQLStmt.=" ses_regionnal = 't',";
- }
- else{
- $SQLStmt.=" ses_regionnal = 'f',";
- }
- if (!strcasecmp($ses_annule,"t")){
- $SQLStmt.=" ses_annule = 't',";
- }
- else{
- $SQLStmt.=" ses_annule = 'f',";
- }
- $SQLStmt.=" ses_annuleraison = '".fixPGQuote($ses_annuleraison)."',";
- if (!strcasecmp($ses_valide,"t")){
- $SQLStmt.=" ses_valide = 't'";
- }
- else{
- $SQLStmt.=" ses_valide = 'f'";
- }
- $SQLStmt.=" WHERE ses_id = ".$id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdUsager($id, $usr_nom, $usr_prenom, $usr_email, $usr_url, $usr_telRejoindre, $usr_telTravail, $usr_telMaison, $usr_telCellulaire, $usr_telPage, $usr_telFax, $usr_adresse, $usr_ville, $usr_codePostal, $usr_societe, $usr_fonction, $usr_nas, $usr_dateNaissance, $usr_commentaire, $usr_interet, $usr_LDAP, $li_id, $usr_valide, $usr_locale){
- $SQLStmt="UPDATE usager SET";
- $SQLStmt.=" usr_nom = '".fixPGQuote(rtrim($usr_nom))."',";
- $SQLStmt.=" usr_prenom = '".fixPGQuote(rtrim($usr_prenom))."',";
- $SQLStmt.=" usr_email = '".fixPGQuote($usr_email)."',";
- $SQLStmt.=" usr_url = '".fixPGQuote($usr_url)."',";
- $SQLStmt.=" usr_telRejoindre = '".fixPGQuote($usr_telRejoindre)."',";
- $SQLStmt.=" usr_telTravail = '".fixPGQuote($usr_telTravail)."',";
- $SQLStmt.=" usr_telMaison = '".fixPGQuote($usr_telMaison)."',";
- $SQLStmt.=" usr_telCellulaire = '".fixPGQuote($usr_telCellulaire)."',";
- $SQLStmt.=" usr_telPage = '".fixPGQuote($usr_telPage)."',";
- $SQLStmt.=" usr_telFax = '".fixPGQuote($usr_telFax)."',";
- $SQLStmt.=" usr_adresse = '".fixPGQuote($usr_adresse)."',";
- $SQLStmt.=" usr_ville = '".fixPGQuote($usr_ville)."',";
- $SQLStmt.=" usr_codePostal = '".fixPGQuote($usr_codePostal)."',";
- $SQLStmt.=" usr_societe = '".fixPGQuote($usr_societe)."',";
- $SQLStmt.=" usr_fonction = '".fixPGQuote($usr_fonction)."',";
- $SQLStmt.=" usr_locale = '".fixPGQuote($usr_locale)."',";
- $SQLStmt.=" usr_nas = '".fixPGQuote($usr_nas)."',";
- if (isDate($usr_dateNaissance)){
- $SQLStmt.=" usr_dateNaissance = '".fixPGQuote($usr_dateNaissance)."',";
- }
- else{
- $SQLStmt.=" usr_dateNaissance = NULL,";
- }
- $SQLStmt.=" usr_commentaire = '".fixPGQuote($usr_commentaire)."',";
- $SQLStmt.=" usr_interet = '".fixPGQuote($usr_interet)."',";
- if (!strcasecmp($usr_LDAP,"t")){
- $SQLStmt.=" usr_LDAP = 't',";
- }
- else{
- $SQLStmt.=" usr_LDAP = 'f',";
- }
- if (is_numeric($li_id)){
- $SQLStmt.=" li_id = ".fixPGQuote($li_id).",";
- }
- else{
- $SQLStmt.=" li_id = NULL,";
- }
- if (!strcasecmp($usr_valide,"t")){
- $SQLStmt.=" usr_valide = 't'";
- }
- else{
- $SQLStmt.=" usr_valide = 'f'";
- }
- $SQLStmt.=" WHERE usr_id = ".$id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdUsagerLimited($id, $usr_nom, $usr_prenom, $usr_email, $usr_url, $usr_telRejoindre, $usr_telTravail, $usr_telMaison, $usr_telCellulaire, $usr_telPage, $usr_telFax, $usr_adresse, $usr_ville, $usr_codePostal, $usr_societe, $usr_fonction, $usr_dateNaissance, $usr_locale){
- $SQLStmt="UPDATE usager SET";
- $SQLStmt.=" usr_nom = '".fixPGQuote(rtrim($usr_nom))."',";
- $SQLStmt.=" usr_prenom = '".fixPGQuote(rtrim($usr_prenom))."',";
- $SQLStmt.=" usr_email = '".fixPGQuote($usr_email)."',";
- $SQLStmt.=" usr_url = '".fixPGQuote($usr_url)."',";
- $SQLStmt.=" usr_telRejoindre = '".fixPGQuote($usr_telRejoindre)."',";
- $SQLStmt.=" usr_telTravail = '".fixPGQuote($usr_telTravail)."',";
- $SQLStmt.=" usr_telMaison = '".fixPGQuote($usr_telMaison)."',";
- $SQLStmt.=" usr_telCellulaire = '".fixPGQuote($usr_telCellulaire)."',";
- $SQLStmt.=" usr_telPage = '".fixPGQuote($usr_telPage)."',";
- $SQLStmt.=" usr_telFax = '".fixPGQuote($usr_telFax)."',";
- $SQLStmt.=" usr_adresse = '".fixPGQuote($usr_adresse)."',";
- $SQLStmt.=" usr_ville = '".fixPGQuote($usr_ville)."',";
- $SQLStmt.=" usr_codePostal = '".fixPGQuote($usr_codePostal)."',";
- $SQLStmt.=" usr_societe = '".fixPGQuote($usr_societe)."',";
- $SQLStmt.=" usr_fonction = '".fixPGQuote($usr_fonction)."',";
- $SQLStmt.=" usr_locale = '".fixPGQuote($usr_locale)."',";
- if (isDate($usr_dateNaissance)){
- $SQLStmt.=" usr_dateNaissance = '".fixPGQuote($usr_dateNaissance)."'";
- }
- else{
- $SQLStmt.=" usr_dateNaissance = NULL";
- }
- $SQLStmt.=" WHERE usr_id = ".$id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdUsagerLDAP($id, $usr_nom, $usr_prenom, $usr_email, $usr_telTravail, $usr_fonction, $usr_LDAP, $li_id, $usr_valide){
- $SQLStmt="UPDATE usager SET";
- $SQLStmt.=" usr_nom = '".fixPGQuote(rtrim($usr_nom))."',";
- $SQLStmt.=" usr_prenom = '".fixPGQuote(rtrim($usr_prenom))."',";
- $SQLStmt.=" usr_email = '".fixPGQuote($usr_email)."',";
- $SQLStmt.=" usr_telTravail = '".fixPGQuote($usr_telTravail)."',";
- $SQLStmt.=" usr_fonction = '".fixPGQuote($usr_fonction)."',";
- if (!strcasecmp($usr_LDAP,"t")){
- $SQLStmt.=" usr_LDAP = 't',";
- }
- else{
- $SQLStmt.=" usr_LDAP = 'f',";
- }
- if (is_numeric($li_id)){
- $SQLStmt.=" li_id = ".fixPGQuote($li_id).",";
- }
- else{
- $SQLStmt.=" li_id = NULL,";
- }
- if (!strcasecmp($usr_valide,"t")){
- $SQLStmt.=" usr_valide = 't'";
- }
- else{
- $SQLStmt.=" usr_valide = 'f'";
- }
- $SQLStmt.=" WHERE usr_id = ".$id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdUsagerLogged($usr_id, $usr_enLigne){
- $SQLStmt="UPDATE usager SET";
- if (!strcasecmp($usr_enLigne,"t")){
- $SQLStmt.=" usr_enLigne = 't',";
- $SQLStmt.=" usr_dernierAcces = NOW()";
- }
- else{
- $SQLStmt.=" usr_enLigne = 'f'";
- }
- $SQLStmt.=" WHERE usr_id = " . $usr_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un UPDATE
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtUpdUsagerPassword($id, $usr_psw){
- $SQLStmt="UPDATE usager SET";
- $SQLStmt.=" usr_psw = '".fixPGQuote($usr_psw)."'";
- $SQLStmt.=" WHERE usr_id = ".$id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqActivite($act_id){
- $SQLStmt="SELECT act_activite, act_description, act_lieu, TO_CHAR(activite.act_datedebut, 'YYYY-MM-DD HH24:MI:SS') AS act_datedebut, TO_CHAR(activite.act_datefin, 'YYYY-MM-DD HH24:MI:SS') AS act_datefin, act_frais, act_annule, act_annuleraison, projet.prj_id, projet.prj_projet, projet.prj_valide, act_valide, TO_CHAR(activite.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') AS dateUpdate, TO_CHAR(activite.dateCreation, 'YYYY-MM-DD HH24:MI:SS') AS dateCreation";
- $SQLStmt.=" FROM activite, projet";
- $SQLStmt.=" WHERE activite.prj_id = projet.prj_id";
- $SQLStmt.=" AND act_id=".$act_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqActiviteLAST(){
- $SQLStmt="SELECT MAX(act_id) FROM activite";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqActivites($prj_id, $indx){
- $SQLStmt="SELECT act_id, act_activite, act_lieu, TO_CHAR(activite.act_datedebut, 'YYYY-MM-DD HH24:MI:SS'), TO_CHAR(activite.act_datefin, 'YYYY-MM-DD HH24:MI:SS') AS act_datefin, act_annule, act_annuleraison, projet.prj_id, projet.prj_projet, projet.prj_valide, act_valide";
- $SQLStmt.=" FROM activite, projet";
- $SQLStmt.=" WHERE activite.prj_id = projet.prj_id";
- if (is_numeric($prj_id)){
- $SQLStmt.=" AND activite.prj_id=".$prj_id;
- }
- if ($indx!=""){
- if ($indx=="datea"){
- $SQLStmt.=" ORDER BY act_dateDebut ASC, act_dateFin ASC";
- }
- elseif ($indx=="dated"){
- $SQLStmt.=" ORDER BY act_dateDebut DESC, act_dateFin DESC";
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqAtelier($atl_id){
- $SQLStmt="SELECT atl_atelier, atl_description, atl_url, atl_prealable, atl_condition, atl_calendrier, atl_fraistypique, atl_note, atl_commentaire, atl_alacartedisponible, usager.usr_id, usager.usr_nom, usager.usr_prenom, usager.usr_email, usager.usr_telRejoindre, atl_valide, TO_CHAR(atelier.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') AS dateUpdate, TO_CHAR(atelier.dateCreation, 'YYYY-MM-DD HH24:MI:SS') AS dateCreation";
- $SQLStmt.=" FROM atelier LEFT JOIN usager ON atelier.usr_id = usager.usr_id";
- $SQLStmt.=" WHERE atl_id=".$atl_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqAtelierClasses($atl_id){
- $SQLStmt="SELECT classe.cla_id, classe.cla_Complete";
- $SQLStmt.=" FROM atelier_classe, classe";
- $SQLStmt.=" WHERE atelier_classe.cla_id=classe.cla_id";
- $SQLStmt.=" AND atelier_classe.atl_id = " . $atl_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqAtelierClienteles($atl_id){
- $SQLStmt="SELECT clientele.cli_id, clientele.cli_clientele, clientele.cli_complete";
- $SQLStmt.=" FROM atelier_clientele, clientele";
- $SQLStmt.=" WHERE atelier_clientele.cli_id=clientele.cli_id";
- $SQLStmt.=" AND atelier_clientele.atl_id = " . $atl_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqAtelierExpertises($atl_id){
- $SQLStmt="SELECT expertise.exp_id, expertise.exp_Complete";
- $SQLStmt.=" FROM atelier_expertise, expertise";
- $SQLStmt.=" WHERE atelier_expertise.exp_id=expertise.exp_id";
- $SQLStmt.=" AND atelier_expertise.atl_id = " . $atl_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqAtelierLAST(){
- $SQLStmt="SELECT MAX(atl_id) FROM atelier";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqAtelierProjets($atl_id){
- $SQLStmt="SELECT projet.prj_id, projet.prj_projet";
- $SQLStmt.=" FROM projet, projet_atelier";
- $SQLStmt.=" WHERE projet.prj_id = projet_atelier.prj_id";
- $SQLStmt.=" AND projet_atelier.atl_id = ".$atl_id;
- $SQLStmt.=" ORDER BY projet.prj_projet";
- return($SQLStmt);
- }
-
- function getSQLStmtReqAtelierProjetsAdminProjet($atl_id, $usrid){
- $subsql = "SELECT prj_id FROM projetAdmin WHERE usr_id = $usrid";
-
- $SQLStmt="SELECT projet.prj_id, projet.prj_projet";
- $SQLStmt.=" FROM projet, projet_atelier";
- $SQLStmt.=" WHERE projet.prj_id = projet_atelier.prj_id";
- $SQLStmt.=" AND projet_atelier.atl_id = ".$atl_id;
- $SQLStmt.=" AND projet.prj_id IN ($subsql)";
- $SQLStmt.=" ORDER BY projet.prj_projet";
-
- return($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqAteliers($mot, $motlnk, $prj_id, $cla_id, $exp_id, $cli_id, $alacarte, $valide, $indx){
- $SQLStmt="SELECT atelier.atl_id, atl_atelier, atl_description, atl_alacartedisponible, atl_valide, get_projetListe_for_atelier(atelier.atl_id,' + ') as projetListe, COUNT(session.ses_id) as nbSession, SUM(get_nbInscriptionSession(session.ses_id)) as nbInscription";
- $SQLStmt.=" FROM atelier LEFT JOIN session ON atelier.atl_id = session.atl_id";
- $SQLStmt.=" WHERE atelier.atl_id = atelier.atl_id";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt .= " ( ";
- $SQLStmt .= accentInsensitiveLike("atl_atelier", $arrMot[$i]);
- $SQLStmt .= " OR " . accentInsensitiveLike("atl_description", $arrMot[$i]);
- $SQLStmt .= " ) ";
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if (is_numeric($prj_id)){
- $SQLStmt.=" AND atelier.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM projet_atelier";
- $SQLStmt.=" WHERE prj_id=".$prj_id;
- $SQLStmt.=")";
- }
- if (is_numeric($cla_id)){
- $SQLStmt.=" AND atelier.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM atelier_classe";
- $SQLStmt.=" WHERE cla_id=".$cla_id;
- $SQLStmt.=")";
- }
- if (is_numeric($exp_id)){
- $SQLStmt.=" AND atelier.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM atelier_expertise";
- $SQLStmt.=" WHERE exp_id=".$exp_id;
- $SQLStmt.=")";
- }
- if (is_numeric($cli_id)){
- $SQLStmt.=" AND atelier.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM atelier_clientele";
- $SQLStmt.=" WHERE cli_id=".$cli_id;
- $SQLStmt.=")";
- }
- if ($alacarte!=""){
- if (!strcasecmp($alacarte,"t")){
- $SQLStmt.=" AND atl_alacarteDisponible ='t'";
- } else {
- $SQLStmt.=" AND atl_alacarteDisponible ='f'";
- }
- }
- if ($valide!=""){
- if (!strcasecmp($valide,"t")){
- $SQLStmt.=" AND atl_valide='t'";
- } else {
- $SQLStmt.=" AND atl_valide='f'";
- }
- }
- $SQLStmt.=" GROUP BY atelier.atl_id, atl_atelier, atl_description, atl_alacartedisponible, atl_valide";
- if ($indx!=""){
- if ($indx=="ateliera") {
- $SQLStmt.=" ORDER BY atl_atelier ASC";
- } else if ($indx=="atelierd") {
- $SQLStmt.=" ORDER BY atl_atelier DESC";
- } else if ($indx=="projeta") {
- $SQLStmt.=" ORDER BY projetListe ASC";
- } else if ($indx=="projetd") {
- $SQLStmt.=" ORDER BY projetListe DESC";
- } else if ($indx=="nbsessiona") {
- $SQLStmt.=" ORDER BY nbSession ASC";
- } else if ($indx=="nbsessiond") {
- $SQLStmt.=" ORDER BY nbSession DESC";
- } else if ($indx=="nbinscriptiona") {
- $SQLStmt.=" ORDER BY nbInscription ASC";
- } else if ($indx=="nbinscriptiond") {
- $SQLStmt.=" ORDER BY nbInscription DESC";
- }
- }
- return $SQLStmt;
- }
-
- function getSQLStmtReqAteliersAdminProjet($mot, $motlnk, $prj_id, $cla_id, $exp_id, $cli_id, $alacarte, $valide, $usrid, $indx){
- $SQLStmt="SELECT atelier.atl_id, atl_atelier, atl_description, atl_alacartedisponible, atl_valide, get_projetListe_for_atelier(atelier.atl_id,' + ') as projetListe, COUNT(session.ses_id) as nbSession, SUM(get_nbInscriptionSession(session.ses_id)) as nbInscription";
- $SQLStmt.=" FROM atelier LEFT JOIN session ON atelier.atl_id = session.atl_id";
- $SQLStmt.=" WHERE atelier.atl_id = atelier.atl_id";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt .= accentInsensitiveLike("atl_atelier", $arrMot[$i]);
- $SQLStmt .= " OR " . accentInsensitiveLike("atl_description", $arrMot[$i]);
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if (is_numeric($prj_id)){
- $SQLStmt.=" AND atelier.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM projet_atelier";
- $SQLStmt.=" WHERE prj_id=".$prj_id;
- $SQLStmt.=")";
- }
- if (is_numeric($cla_id)){
- $SQLStmt.=" AND atelier.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM atelier_classe";
- $SQLStmt.=" WHERE cla_id=".$cla_id;
- $SQLStmt.=")";
- }
- if (is_numeric($exp_id)){
- $SQLStmt.=" AND atelier.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM atelier_expertise";
- $SQLStmt.=" WHERE exp_id=".$exp_id;
- $SQLStmt.=")";
- }
- if (is_numeric($cli_id)){
- $SQLStmt.=" AND atelier.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM atelier_clientele";
- $SQLStmt.=" WHERE cli_id=".$cli_id;
- $SQLStmt.=")";
- }
- if (is_numeric($usrid)){
- $SQLStmt.=" AND atelier.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM projetadmin JOIN projet_atelier USING (prj_id)";
- $SQLStmt.=" WHERE usr_id = $usrid";
- $SQLStmt.=")";
- }
- if ($alacarte!=""){
- if (!strcasecmp($alacarte,"t")){
- $SQLStmt.=" AND atl_alacarteDisponible ='t'";
- } else {
- $SQLStmt.=" AND atl_alacarteDisponible ='f'";
- }
- }
- if ($valide!=""){
- if (!strcasecmp($valide,"t")){
- $SQLStmt.=" AND atl_valide='t'";
- } else {
- $SQLStmt.=" AND atl_valide='f'";
- }
- }
- $SQLStmt.=" GROUP BY atelier.atl_id, atl_atelier, atl_description, atl_alacartedisponible, atl_valide";
- if ($indx!=""){
- if ($indx=="ateliera") {
- $SQLStmt.=" ORDER BY atl_atelier ASC";
- } else if ($indx=="atelierd") {
- $SQLStmt.=" ORDER BY atl_atelier DESC";
- } else if ($indx=="projeta") {
- $SQLStmt.=" ORDER BY projetListe ASC";
- } else if ($indx=="projetd") {
- $SQLStmt.=" ORDER BY projetListe DESC";
- } else if ($indx=="nbsessiona") {
- $SQLStmt.=" ORDER BY nbSession ASC";
- } else if ($indx=="nbsessiond") {
- $SQLStmt.=" ORDER BY nbSession DESC";
- } else if ($indx=="nbinscriptiona") {
- $SQLStmt.=" ORDER BY nbInscription ASC";
- } else if ($indx=="nbinscriptiond") {
- $SQLStmt.=" ORDER BY nbInscription DESC";
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqCedule($ced_id){
- $SQLStmt="SELECT ced_id, ced_cedule, ceduleur.gab_id, gabarit.gab_gabarit, gabarit.gab_param, gabarit.gab_valide, ced_paramValeur, ced_intervalle, TO_CHAR(ceduleur.ced_dateLast, 'YYYY-MM-DD HH24:MI:SS') AS ced_dateLast, TO_CHAR(ceduleur.ced_dateNext, 'YYYY-MM-DD HH24:MI:SS') AS ced_dateNext, ced_valide, TO_CHAR(ceduleur.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') AS dateUpdate, TO_CHAR(ceduleur.dateCreation, 'YYYY-MM-DD HH24:MI:SS') AS dateCreation";
- $SQLStmt.=" FROM ceduleur Left Join gabarit On ceduleur.gab_id = gabarit.gab_id";
- $SQLStmt.=" Where ceduleur.ced_id = ".$ced_id;
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqCeduleLAST(){
- $SQLStmt="SELECT MAX(ced_id) FROM ceduleur";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqCedules($mot, $motlnk, $gabarit, $valide, $gab_valide, $indx){
- $SQLStmt="SELECT ced_id, ced_cedule, ceduleur.gab_id, gabarit.gab_gabarit, gabarit.gab_param, gabarit.gab_valide, ced_paramValeur, ced_intervalle, ced_valide";
- $SQLStmt.=" FROM ceduleur LEFT JOIN gabarit ON ceduleur.gab_id = gabarit.gab_id WHERE 1=1";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt.="(ced_cedule ILIKE '%".fixPGQuote($arrMot[$i])."%'";
- $SQLStmt.=" OR gabarit.gab_gabarit ILIKE '%".fixPGQuote($arrMot[$i])."%')";
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if (is_numeric($gabarit)){
- $SQLStmt.=" AND gabarit.gab_id = ".$gabarit;
- }
- if ($valide!=""){
- if (!strcasecmp($valide,"t")){
- $SQLStmt.=" AND ced_valide='t'";
- } else {
- $SQLStmt.=" AND ced_valide='f'";
- }
- }
- if ($gab_valide!=""){
- if (!strcasecmp($gab_valide,"t")){
- $SQLStmt.=" AND gab_valide='t'";
- } else {
- $SQLStmt.=" AND gab_valide='f'";
- }
- }
- if ($indx!=""){
- if ($indx=="cedulea") {
- $SQLStmt.=" ORDER BY ced_cedule ASC, gab_gabarit ASC";
- } else if ($indx=="ceduled") {
- $SQLStmt.=" ORDER BY ced_cedule DESC, gab_gabarit DESC";
- } else if ($indx=="gabarita") {
- $SQLStmt.=" ORDER BY gab_gabarit ASC, ced_cedule ASC";
- } else if ($indx=="gabaritd") {
- $SQLStmt.=" ORDER BY gab_gabarit DESC, ced_cedule DESC";
- } else if ($indx=="intervallea") {
- $SQLStmt.=" ORDER BY ced_intervalle ASC, ced_cedule ASC";
- } else if ($indx=="intervalled") {
- $SQLStmt.=" ORDER BY ced_intervalle DESC, ced_cedule DESC";
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqGabaritBalises($gab_id){
- $SQLStmt="SELECT gb_id, gb_balise, gb_champ, gb_description";
- $SQLStmt.=" FROM gabaritBalise";
- $SQLStmt.=" WHERE gb_id = gb_id";
- if (is_numeric($gab_id)){
- $SQLStmt.=" AND gab_id = ".$gab_id;
- }
- $SQLStmt.=" ORDER BY gb_balise";
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqGabarit($gab_id){
- $SQLStmt="SELECT gab_id, gab_gabarit, gab_system, gab_description, gab_requeteSQL, gab_param, gab_TO, gab_CC, gab_BCC, gab_objet, gab_body, gab_valide, gab_multicourriel, TO_CHAR(gabarit.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') AS dateUpdate, TO_CHAR(gabarit.dateCreation, 'YYYY-MM-DD HH24:MI:SS') AS dateCreation";
- $SQLStmt.=" FROM gabarit";
- $SQLStmt.=" WHERE gab_id = ".$gab_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqGabaritGabaritLAST(){
- $SQLStmt="SELECT MAX(gab_id) FROM gabarit";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqGabaritLAST(){
- $SQLStmt="SELECT MAX(gab_id) FROM gabarit";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqGabaritParam($gab_id){
- $SQLStmt="SELECT gab_id, gab_gabarit, gab_param";
- $SQLStmt.=" FROM gabarit";
- $SQLStmt.=" WHERE gab_id = ".$gab_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqGabarits($mot, $motlnk, $parent, $system, $valide, $indx){
- $SQLStmt="SELECT gabarit.gab_id, gab_gabarit, gab_system, gab_valide, COUNT(gabaritBalise.gb_id) AS nbBalise";
- $SQLStmt.=" FROM gabarit LEFT JOIN gabaritBalise ON gabarit.gab_id = gabaritBalise.gab_id";
- $SQLStmt.=" WHERE gabarit.gab_id = gabarit.gab_id";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt.="(gab_gabarit ILIKE '%".fixPGQuote($arrMot[$i])."%'";
- $SQLStmt.=" OR gab_description ILIKE '%".fixPGQuote($arrMot[$i])."%')";
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if ($system!=""){
- if (!strcasecmp($system,"t")){
- $SQLStmt.=" AND gab_system='t'";
- } else {
- $SQLStmt.=" AND gab_system='f'";
- }
- }
- if ($valide!=""){
- if (!strcasecmp($valide,"t")){
- $SQLStmt.=" AND gab_valide='t'";
- } else {
- $SQLStmt.=" AND gab_valide='f'";
- }
- }
- $SQLStmt.=" GROUP BY gabarit.gab_id, gab_gabarit, gab_system, gab_valide";
- if ($indx!=""){
- if ($indx=="gabarita") {
- $SQLStmt.=" ORDER BY gab_gabarit ASC";
- } else if ($indx=="gabaritd") {
- $SQLStmt.=" ORDER BY gab_gabarit DESC";
- } else if ($indx=="balisea") {
- $SQLStmt.=" ORDER BY nbBalise ASC, gab_gabarit ASC";
- } else if ($indx=="balised") {
- $SQLStmt.=" ORDER BY nbBalise DESC, gab_gabarit DESC";
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqInscription($usr_id, $ses_id){
- return"Select insSes.usr_id, uusager.usr_nom, uusager.usr_prenom, uusager.usr_email, lieu.li_id,
- lieu.li_lieu, insSes.ses_id, session.ses_code, session.atl_id, atelier.atl_atelier, session.prj_id, projet.prj_projet,
- TO_CHAR( insSes.is_datesoumission, 'YYYY-MM-DD HH24:MI:SS' ) AS is_datesoumission, is_ipsoumission, insSes.ie_id,
- insEt.ie_etat, insEt.ie_OK, insSes.is_majpar_usr_id, ausager.usr_nom, ausager.usr_prenom, ausager.usr_email
- From inscriptionSession insSes
- Left Join usager uusager On insSes.usr_id = uusager.usr_id
- Left Join lieu On insSes.lieu_id_ainscription = lieu.li_id
- Left Join usager ausager On insSes.is_majpar_usr_id = ausager.usr_id
- Left Join inscriptionEtat insEt On insSes.ie_id = insEt.ie_id
- Left Join session On insSes.ses_id = session.ses_id
- Left Join atelier On session.atl_id = atelier.atl_id
- Left Join projet On session.prj_id = projet.prj_id
- Where insSes.usr_id = '".$usr_id."' And insSes.ses_id = '".$ses_id."'";
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqUsagerAdminLieuOK($usr_id, $adminlieu_id){
- $SQLStmt="SELECT usr_id";
- $SQLStmt.=" FROM usager";
- $SQLStmt.=" WHERE usr_id = ".$usr_id;
- if (is_numeric($adminlieu_id)) {
- $SQLStmt.=" AND usager.li_id IN (";
- $SQLStmt.=" SELECT li_id";
- $SQLStmt.=" FROM lieuadmin";
- $SQLStmt.=" WHERE usr_id=".$adminlieu_id;
- $SQLStmt.=")";
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqInscriptionsFromSeance($seance){
- $SQLStmt="SELECT inscriptionSession.usr_id, usager.usr_nom, usager.usr_prenom";
- $SQLStmt.=" FROM inscriptionSession, usager, inscriptionEtat";
- $SQLStmt.=" WHERE inscriptionSession.usr_id = usager.usr_id";
- $SQLStmt.=" AND inscriptionSession.ie_id = inscriptionEtat.ie_id";
- $SQLStmt.=" AND inscriptionEtat.ie_OK = 't'";
- if (is_numeric($seance)){
- $SQLStmt.=" AND inscriptionSession.ses_id = (";
- $SQLStmt.=" SELECT ses_id";
- $SQLStmt.=" FROM seance";
- $SQLStmt.=" WHERE sea_id = ".$seance;
- $SQLStmt.=")";
- }
- $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
- return $SQLStmt;
- }
-
- //Retourne toutes les inscriptions selon les critaires, sauf la validé qui n'est pas vérifier.
- function getSQLStmtReqInscriptions($mot, $motlnk, $session, $etat, $projet, $lieu, $arrFicheID, $nbjourstart, $indx){
- return getSQLStmtReqInscriptionsFull($mot, $motlnk, $session, $etat, "", $projet, $lieu, $arrFicheID, $nbjourstart, $indx);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqInscriptionsFull($mot, $motlnk, $session, $etat, $ie_ok, $projet, $lieu, $arrFicheID, $nbjourstart, $indx){
-
- $SQLStmt="SELECT inscriptionSession.usr_id, usager.usr_nom, usager.usr_prenom, usager.usr_email, lieu.li_id, lieu.li_lieu, inscriptionSession.ses_id, session.ses_code, session.atl_id, atl_atelier, TO_CHAR(inscriptionSession.is_datesoumission, 'YYYY-MM-DD HH24:MI:SS') AS is_datesoumission, is_ipsoumission, inscriptionSession.ie_id, inscriptionEtat.ie_etat, inscriptionEtat.ie_count, inscriptionEtat.ie_OK, is_majpar_usr_id, is_etatupdateraison, usager.usr_fonction";
- $SQLStmt.=" FROM inscriptionSession, usager, lieu, session LEFT JOIN seance USING (ses_id), atelier, inscriptionEtat";
- $SQLStmt.=" WHERE inscriptionSession.usr_id = usager.usr_id";
- $SQLStmt.=" AND inscriptionSession.lieu_id_ainscription = lieu.li_id";
- $SQLStmt.=" AND inscriptionSession.ses_id = session.ses_id";
- $SQLStmt.=" AND session.atl_id = atelier.atl_id";
- $SQLStmt.=" AND inscriptionSession.ie_id = inscriptionEtat.ie_id";
- // $SQLStmt.=" AND seance.ses_id = session.ses_id";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt.="(usr_nom ILIKE '%".fixPGQuote($arrMot[$i])."%'";
- $SQLStmt.=" OR usr_prenom ILIKE '%".fixPGQuote($arrMot[$i])."%')";
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if (is_array($session)){
- $SQLStmt.= " AND (inscriptionSession.ses_id=$session[0]";
- for( $i=1; $i<count($session); $i++ ) {
- $SQLStmt.=" OR inscriptionSession.ses_id=".$session[$i];
- }
- $SQLStmt.= ")";
- }
- if (is_numeric($session)){
- $SQLStmt.=" AND inscriptionSession.ses_id=".$session;
- }
- if (is_numeric($etat)){
- $SQLStmt.=" AND inscriptionSession.ie_id=".$etat;
- }
- if($ie_ok != ""){
- if($ie_ok == "null"){
- $SQLStmt.=" AND inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok is null)";
- } else {
- $SQLStmt.=" AND inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok ='$ie_ok')";
- }
- }
- if (is_numeric($projet)){
- $SQLStmt.=" AND session.prj_id=".$projet;
- }
- if (is_numeric($lieu)){
- $SQLStmt.=" AND lieu.li_id=".$lieu;
- }
- if (is_array($arrFicheID)){
- $SQLStmt.=" AND (inscriptionSession.ses_id <> inscriptionSession.ses_id";
- for ($i=0; $i<count($arrFicheID); $i++){
- ereg("^([0-9]+)[.]{1}([0-9]+)$",$arrFicheID[$i],$regs);
- $usr_id=$regs[1];
- $ses_id=$regs[2];
- if ((is_numeric($usr_id))&&(is_numeric($ses_id))){
- $SQLStmt.=" OR (inscriptionSession.usr_id=".$usr_id;
- $SQLStmt.=" AND inscriptionSession.ses_id=".$ses_id.")";
- }
- }
- $SQLStmt.=" )";
- }
- $SQLStmt .= " GROUP BY inscriptionSession.usr_id, usager.usr_nom, usager.usr_prenom, usager.usr_email, lieu.li_id, lieu.li_lieu, inscriptionSession.ses_id, session.ses_code, session.atl_id, atl_atelier, is_datesoumission, is_ipsoumission, inscriptionSession.ie_id, inscriptionEtat.ie_etat, inscriptionEtat.ie_count, inscriptionEtat.ie_OK, is_majpar_usr_id, is_etatupdateraison, usager.usr_fonction";
- if (is_numeric($nbjourstart)){
- $SQLStmt.=" HAVING min(seance.sea_dateDebut) BETWEEN CURRENT_DATE AND CURRENT_DATE+". $nbjourstart;
- }
- if ($indx!=""){
- if ($indx=="noma"){
- $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
- } else if ($indx=="nomd") {
- $SQLStmt.=" ORDER BY usr_nom DESC, usr_prenom DESC";
- } else if ($indx=="lieua") {
- $SQLStmt.=" ORDER BY li_lieu ASC";
- } else if ($indx=="lieud") {
- $SQLStmt.=" ORDER BY li_lieu DESC";
- } else if ($indx=="sessiona") {
- $SQLStmt.=" ORDER BY ses_code ASC";
- } else if ($indx=="sessiond") {
- $SQLStmt.=" ORDER BY ses_code DESC";
- } else if ($indx=="datea") {
- $SQLStmt.=" ORDER BY is_datesoumission ASC";
- } else if ($indx=="dated") {
- $SQLStmt.=" ORDER BY is_datesoumission DESC";
- } else if ($indx=="etata") {
- $SQLStmt.=" ORDER BY ie_OK ASC, ie_etat ASC";
- } else if ($indx=="etatd") {
- $SQLStmt.=" ORDER BY ie_OK DESC, ie_etat DESC";
- } else if ($indx=="usrtitrea") {
- $SQLStmt.=" ORDER BY usager.usr_fonction ASC";
- } else if ($indx=="usrtitred") {
- $SQLStmt.=" ORDER BY usager.usr_fonction DESC";
- }
- }
- return $SQLStmt;
- }
-
- function getSQLStmtReqInscriptionsAdminProjet($mot, $motlnk, $session, $etat, $projet, $lieu, $arrFicheID, $nbjourstart, $usrid, $indx){
- return getSQLStmtReqInscriptionsAdminProjetFull( $mot, $motlnk, $session, $etat, "", $projet, $lieu, $arrFicheID, $nbjourstart, $usrid, $indx );
- }
-
-
- function getSQLStmtReqInscriptionsAdminProjetFull( $mot, $motlnk, $session, $etat, $ie_ok, $projet, $lieu, $arrFicheID, $nbjourstart, $usrid, $indx ){
- $SQLStmt="Select inscriptionSession.usr_id, usager.usr_nom, usager.usr_prenom, usager.usr_email, lieu.li_id, lieu.li_lieu, inscriptionSession.ses_id, session.ses_code, session.atl_id, atl_atelier, TO_CHAR(inscriptionSession.is_datesoumission, 'YYYY-MM-DD HH24:MI:SS') AS is_datesoumission, is_ipsoumission, inscriptionSession.ie_id, inscriptionEtat.ie_etat, inscriptionEtat.ie_count, inscriptionEtat.ie_OK, is_majpar_usr_id, is_etatupdateraison, usager.usr_fonction";
- $SQLStmt .= " From inscriptionSession
- Left Join usager On inscriptionSession.usr_id = usager.usr_id
- Left Join lieu On inscriptionSession.lieu_id_ainscription = lieu.li_id
- Left Join session On inscriptionSession.ses_id = session.ses_id
- Left Join seance On session.ses_id = seance.ses_id
- Left Join atelier On session.atl_id = atelier.atl_id
- Left Join inscriptionEtat On inscriptionSession.ie_id = inscriptionEtat.ie_id";
-
- $where = "";
- // Recherche le ou les mots demandés par l'usager
- if( $mot != "" ){
- if( strtolower( $motlnk ) != "or" ){
- $motlnk="and"; //valeur par defaut : securite
- }
-
- $arrMot = getArrayFromStringMot($mot);
- if( count( $arrMot ) > 0 ){
- $where = "(";
- for( $i = 0; $i < count( $arrMot ); $i++ ){
- $where .= accentInsensitiveLike( "usr_nom", $arrMot[$i] );
-
- if( $i < count( $arrMot ) - 1 ){
- $where .= " " . $motlnk . " "; //OR ou AND
- }
- }
- $where .= ") And ";
- }
- }
-
- // Recherche parmi les sessions reçues si une liste est fournie
- if ( is_array( $session ) && count( $session ) > 0 ){
- $where .= "( ";
- for( $i = 0; $i < count( $session ); $i++ ){
- if( $i <> 0 ){
- $where .= "Or ";
- }
- $where .= "inscriptionSession.ses_id = '" . $session[ $i ] . "' ";
- }
- $where .= ") And ";
- } else if( is_numeric( $session ) ){
- $where .= "inscriptionSession.ses_id = '" . $session . "' And ";
- }
- if( is_numeric( $etat ) ){
- $where .= "inscriptionSession.ie_id = '" . $etat . "' And ";
- }
- if($ie_ok != ""){
- if($ie_ok == "null"){
- $where.="inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok is null) AND ";
- } else {
- $where.="inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok ='$ie_ok') AND ";
- }
- }
- if( is_numeric( $projet ) ){
- $where .= "session.prj_id = '" . $projet . "' And ";
- }
- if( is_numeric( $lieu ) ){
- $where .= "lieu.li_id = '" . $lieu . "' And ";
- }
- if( is_array( $arrFicheID ) && count( $arrFicheID ) > 0 ){
- $where .= " ( ";
- for( $i = 0; $i < count( $arrFicheID ); $i++ ){
- if( $i <> 0 ){
- $where .= "Or ";
- }
- ereg( "^([0-9]+)[.]{1}([0-9]+)$", $arrFicheID[$i], $regs );
- $usr_id = $regs[1];
- $ses_id = $regs[2];
- if( ( is_numeric( $usr_id ) ) && ( is_numeric( $ses_id ) ) ){
- $where .= "( inscriptionSession.usr_id = '" . $usr_id . "' And inscriptionSession.ses_id = '" . $ses_id . "' ) ";
- }
- }
- $where .= " ) And ";
- }
-
- // Recherche l'admin-projet
- $where .= "session.prj_id IN ( SELECT prj_id FROM projetAdmin WHERE usr_id = '" . $usrid . "' )";
-
- $SQLStmt .= " Where " . $where . " GROUP BY inscriptionSession.usr_id, usager.usr_nom, usager.usr_prenom, usager.usr_email, lieu.li_id, lieu.li_lieu, inscriptionSession.ses_id, session.ses_code, session.atl_id, atl_atelier, is_datesoumission, is_ipsoumission, inscriptionSession.ie_id, inscriptionEtat.ie_etat, inscriptionEtat.ie_count, inscriptionEtat.ie_OK, is_majpar_usr_id, is_etatupdateraison, usager.usr_fonction";
-
- if( is_numeric( $nbjourstart ) ){
- $SQLStmt .= " HAVING min( seance.sea_dateDebut ) BETWEEN CURRENT_DATE AND CURRENT_DATE + " . $nbjourstart;
- }
- switch( $indx ){
- case "noma" :
- $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
- break;
- case "nomd" :
- $SQLStmt.=" ORDER BY usr_nom DESC, usr_prenom DESC";
- break;
- case "lieua" :
- $SQLStmt.=" ORDER BY li_lieu ASC";
- break;
- case "lieud" :
- $SQLStmt.=" ORDER BY li_lieu DESC";
- break;
- case "sessiona" :
- $SQLStmt.=" ORDER BY ses_code ASC";
- break;
- case "sessiond" :
- $SQLStmt.=" ORDER BY ses_code DESC";
- break;
- case "datea" :
- $SQLStmt.=" ORDER BY is_datesoumission ASC";
- break;
- case "dated" :
- $SQLStmt.=" ORDER BY is_datesoumission DESC";
- break;
- case "etata" :
- $SQLStmt.=" ORDER BY ie_OK ASC, ie_etat ASC";
- break;
- case "etatd" :
- $SQLStmt.=" ORDER BY ie_OK DESC, ie_etat DESC";
- break;
- case "usrtitrea" :
- $SQLStmt.=" ORDER BY usager.usr_fonction ASC";
- break;
- case "usrtitred" :
- $SQLStmt.=" ORDER BY usager.usr_fonction DESC";
- break;
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqInscriptionsAnimateur($mot, $motlnk, $session, $etat, $svalide, $projet, $lieu, $arrFicheID, $animID, $nbjourstart, $indx){
- $SQLStmt="SELECT inscriptionSession.usr_id, usager.usr_nom, usager.usr_prenom, usager.usr_email, usager.usr_fonction, lieu.li_id, lieu.li_lieu, inscriptionSession.ses_id, session.ses_code, session.atl_id, atl_atelier, TO_CHAR(inscriptionSession.is_datesoumission, 'YYYY-MM-DD HH24:MI:SS') AS is_datesoumission, is_ipsoumission, inscriptionSession.ie_id, inscriptionEtat.ie_etat, inscriptionEtat.ie_count, inscriptionEtat.ie_OK, is_majpar_usr_id, is_etatupdateraison";
- $SQLStmt.=" FROM inscriptionSession, usager, lieu, session LEFT JOIN seance USING (ses_id), atelier, inscriptionEtat";
- $SQLStmt.=" WHERE inscriptionSession.usr_id = usager.usr_id";
- $SQLStmt.=" AND inscriptionSession.lieu_id_ainscription = lieu.li_id";
- $SQLStmt.=" AND inscriptionSession.ses_id = session.ses_id";
- $SQLStmt.=" AND session.atl_id = atelier.atl_id";
- $SQLStmt.=" AND inscriptionSession.ie_id = inscriptionEtat.ie_id";
- // $SQLStmt.=" AND seance.ses_id = session.ses_id";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt.="(usr_nom ILIKE '%".fixPGQuote($arrMot[$i])."%'";
- $SQLStmt.=" OR usr_prenom ILIKE '%".fixPGQuote($arrMot[$i])."%')";
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if (is_array($session)){
- $SQLStmt.= " AND (inscriptionSession.ses_id=$session[0]";
- for( $i=1; $i<count($session); $i++ ) {
- $SQLStmt.=" OR inscriptionSession.ses_id=".$session[$i];
- }
- $SQLStmt.= ")";
- }
- if (is_numeric($session)){
- $SQLStmt.=" AND inscriptionSession.ses_id=".$session;
- }
- if (is_numeric($etat)){
- $SQLStmt.=" AND inscriptionSession.ie_id=".$etat;
- }
- if($svalide != ""){
- if($svalide == "null"){
- $SQLStmt.=" AND inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok is null)";
- } else {
- $SQLStmt.=" AND inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok ='$svalide')";
- }
- }
- if (is_numeric($projet)){
- $SQLStmt.=" AND session.prj_id=".$projet;
- }
- if (is_numeric($lieu)){
- $SQLStmt.=" AND lieu.li_id=".$lieu;
- }
- if (is_array($arrFicheID)){
- $SQLStmt.=" AND (inscriptionSession.ses_id <> inscriptionSession.ses_id";
- for ($i=0; $i<count($arrFicheID); $i++){
- ereg("^([0-9]+)[.]{1}([0-9]+)$",$arrFicheID[$i],$regs);
- $usr_id=$regs[1];
- $ses_id=$regs[2];
- if ((is_numeric($usr_id))&&(is_numeric($ses_id))){
- $SQLStmt.=" OR (inscriptionSession.usr_id=".$usr_id;
- $SQLStmt.=" AND inscriptionSession.ses_id=".$ses_id.")";
- }
- }
- $SQLStmt.=" )";
- }
- // specifique pour Animateur
- if (is_numeric($animID)){
- $SQLStmt.=" AND inscriptionSession.ses_id IN (";
- $SQLStmt.=" SELECT ses_id";
- $SQLStmt.=" FROM animation";
- $SQLStmt.=" WHERE usr_id=".$animID;
- $SQLStmt.=")";
- }
- $SQLStmt .= " GROUP BY inscriptionSession.usr_id, usager.usr_nom, usager.usr_prenom, usager.usr_email, usager.usr_fonction, lieu.li_id, lieu.li_lieu, inscriptionSession.ses_id, session.ses_code, session.atl_id, atl_atelier, is_datesoumission, is_ipsoumission, inscriptionSession.ie_id, inscriptionEtat.ie_etat, inscriptionEtat.ie_count, inscriptionEtat.ie_OK, is_majpar_usr_id, is_etatupdateraison";
- if (is_numeric($nbjourstart)){
- $SQLStmt.=" HAVING min(seance.sea_dateDebut) BETWEEN CURRENT_DATE AND CURRENT_DATE+". $nbjourstart;
- }
- if ($indx!=""){
- if ($indx=="noma"){
- $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
- } else if ($indx=="nomd") {
- $SQLStmt.=" ORDER BY usr_nom DESC, usr_prenom DESC";
- } else if ($indx=="fonctiona") {
- $SQLStmt.=" ORDER BY usr_fonction ASC";
- } else if ($indx=="fonctiond") {
- $SQLStmt.=" ORDER BY usr_fonction DESC";
- } else if ($indx=="lieua") {
- $SQLStmt.=" ORDER BY li_lieu ASC";
- } else if ($indx=="lieud") {
- $SQLStmt.=" ORDER BY li_lieu DESC";
- } else if ($indx=="sessiona") {
- $SQLStmt.=" ORDER BY ses_code ASC";
- } else if ($indx=="sessiond") {
- $SQLStmt.=" ORDER BY ses_code DESC";
- } else if ($indx=="datea") {
- $SQLStmt.=" ORDER BY is_datesoumission ASC";
- } else if ($indx=="dated") {
- $SQLStmt.=" ORDER BY is_datesoumission DESC";
- } else if ($indx=="etata") {
- $SQLStmt.=" ORDER BY ie_OK ASC, ie_etat ASC";
- } else if ($indx=="etatd") {
- $SQLStmt.=" ORDER BY ie_OK DESC, ie_etat DESC";
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqInscriptionsArraySesBefore($usr_id, $arrnSesID){
- $SQLStmt="SELECT inscriptionSession.ses_id, inscriptionSession.ie_id, inscriptionEtat.ie_count, inscriptionEtat.ie_OK";
- $SQLStmt.=" FROM inscriptionSession, inscriptionEtat";
- $SQLStmt.=" WHERE inscriptionSession.ie_id = inscriptionEtat.ie_id";
- if (count($arrnSesID)>0){
- $SQLStmt.=" AND (inscriptionSession.ses_id <> inscriptionSession.ses_id";
- for ($i=0; $i<count($arrnSesID); $i++){
- $ses_id = $arrnSesID[$i];
- if ((is_numeric($usr_id))&&(is_numeric($ses_id))){
- $SQLStmt.=" OR (inscriptionSession.usr_id=".$usr_id;
- $SQLStmt.=" AND inscriptionSession.ses_id=".$ses_id.")";
- }
- }
- $SQLStmt.=" )";
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqInscriptionsArrayUsrBefore($ses_id, $arrnUsrID){
- $SQLStmt="SELECT inscriptionSession.usr_id, inscriptionSession.ie_id, inscriptionEtat.ie_count";
- $SQLStmt.=" FROM inscriptionSession, inscriptionEtat";
- $SQLStmt.=" WHERE inscriptionSession.ie_id = inscriptionEtat.ie_id";
- if (count($arrnUsrID)>0){
- $SQLStmt.=" AND (inscriptionSession.ses_id <> inscriptionSession.ses_id";
- for ($i=0; $i<count($arrnUsrID); $i++){
- $usr_id = $arrnUsrID[$i];
- if ((is_numeric($usr_id))&&(is_numeric($ses_id))){
- $SQLStmt.=" OR (inscriptionSession.usr_id=".$usr_id;
- $SQLStmt.=" AND inscriptionSession.ses_id=".$ses_id.")";
- }
- }
- $SQLStmt.=" )";
- }
- return $SQLStmt;
- }
-
- function getSQLStmtReqInscriptionsLimited($mot, $motlnk, $session, $etat, $projet, $lieu, $arrFicheID, $adminlieu, $nbjourstart, $indx)
- {
- return getSQLStmtReqInscriptionsLimitedFull($mot, $motlnk, $session, $etat,"", $projet, $lieu, $arrFicheID, $adminlieu, $nbjourstart, $indx);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqInscriptionsLimitedFull($mot, $motlnk, $session, $etat,$ie_ok, $projet, $lieu, $arrFicheID, $adminlieu, $nbjourstart, $indx){
- $SQLStmt="SELECT inscriptionSession.usr_id, usager.usr_nom, usager.usr_prenom, usager.usr_email, lieu.li_id, lieu.li_lieu, inscriptionSession.ses_id, session.ses_code, session.atl_id, atl_atelier, TO_CHAR(inscriptionSession.is_datesoumission, 'YYYY-MM-DD HH24:MI:SS') AS is_datesoumission, is_ipsoumission, inscriptionSession.ie_id, inscriptionEtat.ie_etat, inscriptionEtat.ie_count, inscriptionEtat.ie_OK, is_majpar_usr_id, is_etatupdateraison, prochaineseance(inscriptionSession.ses_id) AS dateSeance, usager.usr_fonction";
- $SQLStmt.=" FROM inscriptionSession, usager, lieu, session LEFT JOIN seance USING (ses_id), atelier, inscriptionEtat";
- $SQLStmt.=" WHERE inscriptionSession.usr_id = usager.usr_id";
- $SQLStmt.=" AND inscriptionSession.lieu_id_ainscription = lieu.li_id";
- $SQLStmt.=" AND inscriptionSession.ses_id = session.ses_id";
- $SQLStmt.=" AND session.atl_id = atelier.atl_id";
- $SQLStmt.=" AND inscriptionSession.ie_id = inscriptionEtat.ie_id";
- // $SQLStmt.=" AND seance.ses_id = session.ses_id";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt.="(usr_nom ILIKE '%".fixPGQuote($arrMot[$i])."%'";
- $SQLStmt.=" OR usr_prenom ILIKE '%".fixPGQuote($arrMot[$i])."%')";
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if (is_array($session)){
- $SQLStmt.= " AND (inscriptionSession.ses_id=$session[0]";
- for( $i=1; $i<count($session); $i++ ) {
- $SQLStmt.=" OR inscriptionSession.ses_id=".$session[$i];
- }
- $SQLStmt.= ")";
- }
- if (is_numeric($session)){
- $SQLStmt.=" AND inscriptionSession.ses_id=".$session;
- }
- if($ie_ok != "" && $ie_ok != "tout"){
- if($ie_ok == "null"){
- $SQLStmt.=" AND inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok is null)";
- } else {
- $SQLStmt.=" AND inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok ='$ie_ok')";
- }
- }
- if (is_numeric($etat)){
- $SQLStmt.=" AND inscriptionSession.ie_id=".$etat;
- }
- if (is_numeric($projet)){
- $SQLStmt.=" AND session.prj_id=".$projet;
- }
- if (is_numeric($lieu)){
- $SQLStmt.=" AND lieu.li_id=".$lieu;
- }
- if (is_array($arrFicheID)){
- $SQLStmt.=" AND (inscriptionSession.ses_id <> inscriptionSession.ses_id";
- for ($i=0; $i<count($arrFicheID); $i++){
- ereg("^([0-9]+)[.]{1}([0-9]+)$",$arrFicheID[$i],$regs);
- $usr_id=$regs[1];
- $ses_id=$regs[2];
- if ((is_numeric($usr_id))&&(is_numeric($ses_id))){
- $SQLStmt.=" OR (inscriptionSession.usr_id=".$usr_id;
- $SQLStmt.=" AND inscriptionSession.ses_id=".$ses_id.")";
- }
- }
- $SQLStmt.=" )";
- }
- // specifique pour LIMITED
- if (is_numeric($adminlieu)){
- $SQLStmt.=" AND usager.li_id IN (";
- $SQLStmt.=" SELECT li_id";
- $SQLStmt.=" FROM lieuadmin";
- $SQLStmt.=" WHERE usr_id=".$adminlieu;
- $SQLStmt.=")";
- }
- $SQLStmt .= " GROUP BY inscriptionSession.usr_id, usager.usr_nom, usager.usr_prenom, usager.usr_email, lieu.li_id, lieu.li_lieu, inscriptionSession.ses_id, session.ses_code, session.atl_id, atl_atelier, is_datesoumission, is_ipsoumission, inscriptionSession.ie_id, inscriptionEtat.ie_etat, inscriptionEtat.ie_count, inscriptionEtat.ie_OK, is_majpar_usr_id, is_etatupdateraison, dateSeance, usager.usr_fonction";
- if (is_numeric($nbjourstart)){
- $SQLStmt.=" HAVING min(seance.sea_dateDebut) BETWEEN CURRENT_DATE AND CURRENT_DATE+". $nbjourstart;
- }
- if ($indx!=""){
- if ($indx=="noma"){
- $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
- } else if ($indx=="nomd") {
- $SQLStmt.=" ORDER BY usr_nom DESC, usr_prenom DESC";
- } else if ($indx=="lieua") {
- $SQLStmt.=" ORDER BY li_lieu ASC";
- } else if ($indx=="lieud") {
- $SQLStmt.=" ORDER BY li_lieu DESC";
- } else if ($indx=="sessiona") {
- $SQLStmt.=" ORDER BY ses_code ASC";
- } else if ($indx=="sessiond") {
- $SQLStmt.=" ORDER BY ses_code DESC";
- } else if ($indx=="datea") {
- $SQLStmt.=" ORDER BY dateSeance ASC";
- } else if ($indx=="dated") {
- $SQLStmt.=" ORDER BY dateSeance DESC";
- } else if ($indx=="etata") {
- $SQLStmt.=" ORDER BY ie_OK ASC, ie_etat ASC";
- } else if ($indx=="etatd") {
- $SQLStmt.=" ORDER BY ie_OK DESC, ie_etat DESC";
- } else if ($indx=="usrtitrea") {
- $SQLStmt.=" ORDER BY usager.usr_fonction ASC";
- } else if ($indx=="usrtitred") {
- $SQLStmt.=" ORDER BY usager.usr_fonction DESC";
- }
- }
- return $SQLStmt;
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqLieu($li_id){
- $SQLStmt="SELECT li_id, li_lieu, li_no, li_adresse, li_trajet, li_trajetURL, li_telephone, li_ldap, li_valide, TO_CHAR(lieu.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') AS dateUpdate, TO_CHAR(lieu.dateCreation, 'YYYY-MM-DD HH24:MI:SS') AS dateCreation, lt_id";
- $SQLStmt.=" FROM lieu";
- $SQLStmt.=" WHERE li_id = ".$li_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqLieuType($lt_id){
- $SQLStmt="SELECT lt_type FROM lieutype";
- $SQLStmt.=" WHERE lieu.lt_id =".$lt_id;
- return ($SQLStmt);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqLieuLAST(){
- $SQLStmt="SELECT MAX(li_id) FROM lieu";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqLieuFromNo($li_no){
- $SQLStmt="SELECT li_id, li_lieu, li_no, li_adresse, li_trajet, li_trajetURL, li_telephone, li_valide, TO_CHAR(lieu.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') AS dateUpdate, TO_CHAR(lieu.dateCreation, 'YYYY-MM-DD HH24:MI:SS') AS dateCreation";
- $SQLStmt.=" FROM lieu";
- $SQLStmt.=" WHERE li_id = li_id";
- if ($li_no!=""){
- $SQLStmt.=" AND li_no = '".$li_no."'";
- }else{
- $SQLStmt.=" AND li_no IS NULL";
- }
- return ($SQLStmt);
- }
-
- // 2008/03 rechercher un lieu de la table «lieu» d'après son numéro OU sa description
- function getSQLStmtReqLieuFromNoOuDescr($li_no, $li_lieu){
- $SQLStmt="SELECT li_id, li_lieu, li_no, li_adresse, li_trajet, li_trajetURL, li_telephone, li_valide, TO_CHAR(lieu.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') AS dateUpdate, TO_CHAR(lieu.dateCreation, 'YYYY-MM-DD HH24:MI:SS') AS dateCreation";
- $SQLStmt.=" FROM lieu";
- $SQLStmt.=" WHERE li_id = li_id";
- if ($li_no!=""){
- $SQLStmt.=" AND li_no = '".$li_no."'";
- }elseif ($li_lieu!=""){
- $SQLStmt.=" AND li_lieu = '".addslashes($li_lieu)."'";
- }else{
- $SQLStmt.=" AND li_no IS NULL";
- }
- $SQLStmt.=" LIMIT 1";
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqLieuxInscriptions($adminlieu_id, $valide, $indx){
- $SQLStmt="SELECT lieu.li_id, li_lieu, li_valide, count(inscriptionSession.ie_id) as nbInscription, (SELECT count(*) FROM inscriptionSession is2, usager u2 WHERE is2.ie_id = 1 AND is2.usr_id = u2.usr_id AND u2.li_id = lieu.li_id) as nbInscriptionApprove";
- $SQLStmt.=" FROM lieu LEFT JOIN inscriptionSession ON lieu.li_id = inscriptionSession.lieu_id_ainscription LEFT JOIN usager ON usager.usr_id = inscriptionSession.usr_id";
- $SQLStmt.=" WHERE lieu.li_id = lieu.li_id";
- if (is_numeric($adminlieu_id)){
- $SQLStmt.=" AND lieu.li_id IN (";
- $SQLStmt.=" SELECT li_id";
- $SQLStmt.=" FROM lieuadmin";
- $SQLStmt.=" WHERE usr_id=".$adminlieu_id;
- $SQLStmt.=")";
- }
- if ($valide!=""){
- if (!strcasecmp($valide,"t")){
- $SQLStmt.=" AND li_valide='t'";
- }
- else{
- $SQLStmt.=" AND li_valide='f'";
- }
- }
- $SQLStmt.=" GROUP BY lieu.li_id, li_lieu, li_valide";
- if ($indx!=""){
- if ($indx=="lieua"){
- $SQLStmt.=" ORDER BY li_lieu ASC";
- }
- elseif ($indx=="lieud"){
- $SQLStmt.=" ORDER BY li_lieu DESC";
- }
- elseif ($indx=="adressea"){
- $SQLStmt.=" ORDER BY li_adresse ASC";
- }
- elseif ($indx=="adressed"){
- $SQLStmt.=" ORDER BY li_adresse DESC";
- }
- elseif ($indx=="trajeta"){
- $SQLStmt.=" ORDER BY li_trajet ASC";
- }
- elseif ($indx=="trajetd"){
- $SQLStmt.=" ORDER BY li_trajet DESC";
- }
- else
- {
- $SQLStmt.=" ORDER BY li_lieu ASC"; // ordre alphabetique de nom par defaut
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqLieuAdminlieu( $li_id ){
- return "Select la.usr_id, la.la_responsable, u.usr_nom, u.usr_prenom, l.li_no
- From lieuAdmin la
- Left Join usager u On la.usr_id = u.usr_id
- Left Join lieu l On u.li_id = l.li_id
- Where la.li_id = '" . $li_id . "'
- Order By u.usr_nom, u.usr_prenom";
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqLieuAdminLieuOK($li_id, $adminlieu_id){
- $SQLStmt="SELECT li_id";
- $SQLStmt.=" FROM lieuAdmin";
- $SQLStmt.=" WHERE li_id = ".$li_id;
- if (is_numeric($adminlieu_id)){
- $SQLStmt.=" AND usr_id=".$adminlieu_id;
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqLieuTechnicien($li_id){
- $SQLStmt="SELECT lieuSupport.usr_id, lieuSupport.ls_responsable, usager.usr_nom, usager.usr_prenom";
- $SQLStmt.=" FROM lieuSupport, usager";
- $SQLStmt.=" WHERE lieuSupport.usr_id = usager.usr_id";
- $SQLStmt.=" AND lieuSupport.li_id = ".$li_id;
- $SQLStmt.=" ORDER BY usager.usr_nom, usager.usr_prenom";
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqLieux( $mot, $motlnk, $adminlieu_id, $tech_id, $lieu_type, $valide, $indx ){
- $SQLStmt = "Select li_id, li_lieu, li_no, li_adresse, li_trajet, li_valide";
- $SQLStmt .= " From lieu";
- $SQLStmt .= " Where li_id = li_id";
-
- if( $mot != "" ){
- if( $motlnk != strtolower( "or" ) ){
- $motlnk = "And"; //valeur par defaut : securite
- }
-
- $arrMot = getArrayFromStringMot( $mot );
- $SQLStmt .= " And ( ";
- for( $i = 0; $i < count( $arrMot ); $i++ ){
- $SQLStmt .= "( li_lieu Ilike '%" . fixPGQuote( $arrMot[$i] ) . "%'";
- $SQLStmt .= " Or li_adresse Ilike '%" . fixPGQuote( $arrMot[ $i ] ) . "%')";
- if( $i < count( $arrMot ) - 1 ){
- $SQLStmt .= " " . $motlnk . " "; //OR ou AND
- }
- }
- $SQLStmt .= ")";
- }
- if( is_numeric( $lieu_type ) ){
- $SQLStmt .= ' And lt_id = ' . $lieu_type;
- }
-
- if( is_numeric( $adminlieu_id ) ){
- $SQLStmt .= " And li_id In ( Select li_id From lieuadmin Where usr_id = " . $adminlieu_id . " )";
- }
-
- if( is_numeric( $tech_id ) ){
- $SQLStmt .= " And li_id In ( Select li_id From lieusupport Where usr_id = " . $tech_id . " )";
- }
-
- if( $valide != "" ){
- if( $valide == "t" ){
- $SQLStmt .= " And li_valide = 't'";
- } else {
- $SQLStmt .= " And li_valide = 'f'";
- }
- }
-
- switch( $indx ){
- case "lieua" :
- $SQLStmt .= " Order By li_lieu ASC";
- break;
- case "lieud" :
- $SQLStmt .= " Order By li_lieu DESC";
- break;
- case "adressea" :
- $SQLStmt .= " Order By li_adresse ASC";
- break;
- case "adressed" :
- $SQLStmt .= " Order By li_adresse DESC";
- break;
- case "trajeta" :
- $SQLStmt .= " Order By li_trajet ASC";
- break;
- case "trajetd" :
- $SQLStmt .= " Order By li_trajet DESC";
- break;
- case "lieunoa" :
- $SQLStmt .= " Order By li_no ASC";
- break;
- case "lieunod" :
- $SQLStmt .= " Order By li_no DESC";
- break;
- default :
- // ordre alphabetique de nom par defaut
- $SQLStmt .= " Order By li_lieu ASC";
- break;
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqPresences($sea_id){
- /*$SQLStmt="SELECT presence.usr_id, usr_nom, usr_prenom, pr_presence";
- $SQLStmt.=" FROM presence, usager";
- $SQLStmt.=" WHERE presence.usr_id = usager.usr_id";
- $SQLStmt.=" AND sea_id = ".$sea_id;*/
- $SQLStmt.="SELECT inscriptionSession.usr_id, usager.usr_nom, usager.usr_prenom, pr_presence";
- $SQLStmt.=" FROM inscriptionSession, inscriptionEtat, usager LEFT JOIN (";
- $SQLStmt.= " SELECT presence.usr_id,pr_presence";
- $SQLStmt.= " FROM presence";
- if (is_numeric($sea_id)){
- $SQLStmt.= " WHERE sea_id =".$sea_id;
- }
- $SQLStmt.= ") PRES ON usager.usr_id = PRES.usr_id";
- $SQLStmt.=" WHERE inscriptionSession.usr_id = usager.usr_id";
- $SQLStmt.=" AND inscriptionSession.ie_id = inscriptionEtat.ie_id";
- $SQLStmt.=" AND inscriptionEtat.ie_OK = 't'";
- if (is_numeric($sea_id)){
- $SQLStmt.=" AND inscriptionSession.ses_id = (";
- $SQLStmt.=" SELECT ses_id";
- $SQLStmt.=" FROM seance";
- $SQLStmt.=" WHERE sea_id = ".$sea_id;
- $SQLStmt.=")";
- }
- $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
- return($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqProjet($prj_id){
- $SQLStmt="SELECT prj_projet, prj_description, prj_prefixe, prj_url, prj_datedebut, prj_datefin, prj_datelimite, prj_fraisglobaux, projet.pt_id, projetType.pt_type, prj_valide, TO_CHAR(projet.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') AS dateUpdate, TO_CHAR(projet.dateCreation, 'YYYY-MM-DD HH24:MI:SS') AS dateCreation";
- $SQLStmt.=" FROM projet, projetType";
- $SQLStmt.=" WHERE projet.pt_id = projetType.pt_id";
- $SQLStmt.=" AND prj_id = ".$prj_id;
- return($SQLStmt);
- }
-
- function getSQLStmtReqProjetAdminprojet($prj_id){
- $SQLStmt="SELECT projetAdmin.usr_id, projetAdmin.pa_responsable, usager.usr_nom, usager.usr_prenom";
- $SQLStmt.=" FROM projetAdmin, usager";
- $SQLStmt.=" WHERE projetAdmin.usr_id = usager.usr_id";
- $SQLStmt.=" AND projetAdmin.prj_id = ".$prj_id;
- $SQLStmt.=" ORDER BY usager.usr_nom, usager.usr_prenom";
- return ($SQLStmt);
- }
-
- function getSQLStmtReqAdminProjetSessions( $usrid ) {
- return "SELECT ses_id FROM projetAdmin JOIN session USING ( prj_id ) WHERE usr_id = '" . $usrid . "'";
- }
-
- function getSQLStmtReqAdminProjetSeances($usrid)
- {
- $sql = "SELECT sea_id FROM projetAdmin JOIN session USING (prj_id)";
- $sql .= " JOIN seance USING (ses_id)";
- $sql .= " WHERE usr_id = $usrid";
-
- return $sql;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqProjetLAST(){
- $SQLStmt="SELECT MAX(prj_id) FROM projet";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqProjets($mot, $motlnk, $type, $dateOK, $valide, $indx){
- $SQLStmt="SELECT projet.prj_id, prj_projet, prj_datedebut, prj_datefin, prj_datelimite, projet.pt_id, projetType.pt_type, prj_valide, COUNT(session.ses_id) as nbSession, SUM(get_nbInscriptionSession(session.ses_id)) as nbInscription";
- $SQLStmt.=" FROM projet LEFT JOIN session ON projet.prj_id = session.prj_id, projetType";
- $SQLStmt.=" WHERE projet.pt_id = projetType.pt_id";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt.="(prj_projet ILIKE '%".fixPGQuote($arrMot[$i])."%'";
- $SQLStmt.=" OR pt_type ILIKE '%".fixPGQuote($arrMot[$i])."%')";
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if ($dateOK!=""){
- if (!strcasecmp($dateOK,"t")){
- $SQLStmt.=" AND (prj_dateFin >= CURRENT_DATE OR prj_dateFin IS NULL)";
- }
- else{
- $SQLStmt.=" AND (prj_dateFin < CURRENT_DATE)";
- }
- }
- if ($valide!=""){
- if (!strcasecmp($valide,"t")){
- $SQLStmt.=" AND prj_valide='t'";
- } else {
- $SQLStmt.=" AND prj_valide='f'";
- }
- }
- if (is_numeric($type)){
- $SQLStmt.=" AND projet.pt_id=".$type;
- }
- $SQLStmt.=" GROUP BY projet.prj_id, prj_projet, prj_datedebut, prj_datefin, prj_datelimite, projet.pt_id, projetType.pt_type, prj_valide";
- if ($indx!=""){
- if ($indx=="projeta"){
- $SQLStmt.=" ORDER BY prj_projet ASC";
- } else if ($indx=="projetd") {
- $SQLStmt.=" ORDER BY prj_projet DESC";
- } else if ($indx=="typea") {
- $SQLStmt.=" ORDER BY pt_type ASC";
- } else if ($indx=="typed") {
- $SQLStmt.=" ORDER BY pt_type DESC";
- } else if ($indx=="datea") {
- $SQLStmt.=" ORDER BY prj_dateDebut ASC, prj_dateFin ASC";
- } else if ($indx=="dated") {
- $SQLStmt.=" ORDER BY prj_dateDebut DESC, prj_dateFin DESC";
- } else if ($indx=="nbsessiona") {
- $SQLStmt.=" ORDER BY nbSession ASC";
- } else if ($indx=="nbsessiond") {
- $SQLStmt.=" ORDER BY nbSession DESC";
- } else if ($indx=="nbinscriptiona") {
- $SQLStmt.=" ORDER BY nbInscription ASC";
- } else if ($indx=="nbinscriptiond") {
- $SQLStmt.=" ORDER BY nbInscription DESC";
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqProjetsComplets($mot, $motlnk, $type, $dateOK, $valide, $indx){
- $SQLStmt="SELECT projet.prj_id, prj_projet, prj_description, prj_url, prj_datedebut, prj_datefin, prj_datelimite, projet.pt_id, projetType.pt_type, prj_valide, COUNT(session.ses_id) as nbSession, SUM(get_nbInscriptionSession(session.ses_id)) as nbInscription";
- $SQLStmt.=" FROM projet LEFT JOIN session ON projet.prj_id = session.prj_id, projetType";
- $SQLStmt.=" WHERE projet.pt_id = projetType.pt_id";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
-
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt.="(prj_projet ILIKE '%".fixPGQuote($arrMot[$i])."%'";
- $SQLStmt.=" OR pt_type ILIKE '%".fixPGQuote($arrMot[$i])."%')";
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if ($dateOK!=""){
- if (!strcasecmp($dateOK,"t")){
- $SQLStmt.=" AND (prj_dateFin >= CURRENT_DATE OR prj_dateFin IS NULL)";
- }
- else{
- $SQLStmt.=" AND (prj_dateFin < CURRENT_DATE)";
- }
- }
- if ($valide!=""){
- if (!strcasecmp($valide,"t")){
- $SQLStmt.=" AND prj_valide='t'";
- }
- else{
- $SQLStmt.=" AND prj_valide='f'";
- }
- }
- if (is_numeric($type)){
- $SQLStmt.=" AND projet.pt_id=".$type;
- }
- $SQLStmt.=" GROUP BY projet.prj_id, prj_projet, prj_description, prj_url, prj_datedebut, prj_datefin, prj_datelimite, projet.pt_id, projetType.pt_type, prj_valide";
- if ($indx!=""){
- if ($indx=="projeta"){
- $SQLStmt.=" ORDER BY prj_projet ASC";
- }
- elseif ($indx=="projetd"){
- $SQLStmt.=" ORDER BY prj_projet DESC";
- }
- elseif ($indx=="typea"){
- $SQLStmt.=" ORDER BY pt_type ASC";
- }
- elseif ($indx=="typed"){
- $SQLStmt.=" ORDER BY pt_type DESC";
- }
- elseif ($indx=="datea"){
- $SQLStmt.=" ORDER BY prj_dateDebut ASC, prj_dateFin ASC";
- }
- elseif ($indx=="dated"){
- $SQLStmt.=" ORDER BY prj_dateDebut DESC, prj_dateFin DESC";
- }
- elseif ($indx=="nbsessiona"){
- $SQLStmt.=" ORDER BY nbSession ASC";
- }
- elseif ($indx=="nbsessiond"){
- $SQLStmt.=" ORDER BY nbSession DESC";
- }
- elseif ($indx=="nbinscriptiona"){
- $SQLStmt.=" ORDER BY nbInscription ASC";
- }
- elseif ($indx=="nbinscriptiond"){
- $SQLStmt.=" ORDER BY nbInscription DESC";
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqSeance($sea_id){
- $SQLStmt="SELECT get_seanceCode(sea_id), session.ses_id, session.ses_code, session.ses_annule, session.ses_valide, projet.prj_id, projet.prj_projet, projet.prj_valide, atelier.atl_id, atelier.atl_atelier, atelier.atl_valide, TO_CHAR(seance.sea_dateDebut, 'YYYY-MM-DD HH24:MI:SS') AS sea_dateDebut, TO_CHAR(seance.sea_dateFin, 'YYYY-MM-DD HH24:MI:SS') AS sea_dateFin, sea_duree, seance.li_id, li_lieu, sea_lieudetail, sea_materiel, sea_materielanimation, sea_fraisanimation, sea_fraisproduction, sea_fraisliberation, sea_fraislocation, sea_fraisautre, (sea_fraisanimation+sea_fraisproduction+sea_fraisliberation+sea_fraislocation+sea_fraisautre) AS fraisTotal, sea_note, sea_commentaire, sea_annule, sea_annuleraison, sea_valide, TO_CHAR(seance.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') AS dateUpdate, TO_CHAR(seance.dateCreation, 'YYYY-MM-DD HH24:MI:SS') AS dateCreation, get_nbInscriptionSessionOK(seance.ses_id) AS nbInscription, get_nbPresence(seance.sea_id)";
- $SQLStmt.=" FROM seance LEFT JOIN lieu ON seance.li_id = lieu.li_id, session, atelier, projet";
- $SQLStmt.=" WHERE seance.ses_id = session.ses_id";
- $SQLStmt.=" AND session.atl_id = atelier.atl_id";
- $SQLStmt.=" AND session.prj_id = projet.prj_id";
- $SQLStmt.=" AND seance.sea_id = ".$sea_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqSeanceLAST(){
- $SQLStmt="SELECT MAX(sea_id) FROM seance";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqSeances($prj_id, $atl_id, $ses_id, $sea_annule, $valide, $arrFicheID, $indx, $usr_id = null){
- $SQLStmt="SELECT seance.sea_id, get_seanceCode(seance.sea_id), session.ses_id, session.ses_code, session.ses_annule, session.ses_valide, atelier.atl_id, atelier.atl_atelier, atelier.atl_valide, projet.prj_id, projet.prj_projet, projet.prj_valide, TO_CHAR(seance.sea_dateDebut, 'YYYY-MM-DD HH24:MI:SS') AS sea_dateDebut, TO_CHAR(seance.sea_dateFin, 'YYYY-MM-DD HH24:MI:SS') AS sea_dateFin, sea_duree, seance.li_id, li_lieu, sea_lieudetail, sea_annule, sea_annuleraison, sea_valide";
- if (is_numeric($usr_id)) {
- $SQLStmt.=", pr_presence FROM seance LEFT JOIN presence ON (presence.sea_id = seance.sea_id AND presence.usr_id = $usr_id) LEFT JOIN lieu ON seance.li_id = lieu.li_id";
- } else {
- $SQLStmt.=" FROM seance LEFT JOIN lieu ON seance.li_id = lieu.li_id";
- }
- $SQLStmt.=" LEFT JOIN session ON seance.ses_id = session.ses_id";
- $SQLStmt.=" LEFT JOIN atelier ON session.atl_id = atelier.atl_id";
- $SQLStmt.=" LEFT JOIN projet ON session.prj_id = projet.prj_id";
- $SQLStmt.=" WHERE seance.sea_id = seance.sea_id";
- if (is_numeric($prj_id)){
- $SQLStmt.=" AND session.prj_id = ".$prj_id;
- }
- if (is_numeric($atl_id)){
- $SQLStmt.=" AND session.atl_id = ".$atl_id;
- }
- if (is_numeric($ses_id)){
- $SQLStmt.=" AND session.ses_id = ".$ses_id;
- }
- if ($sea_annule!=""){
- if (!strcasecmp($sea_annule,"t")){
- $SQLStmt.=" AND sea_annule='t'";
- }
- else{
- $SQLStmt.=" AND sea_annule='f'";
- }
- }
- if ($valide!=""){
- if (!strcasecmp($valide,"t")){
- $SQLStmt.=" AND prj_valide='t'";
- $SQLStmt.=" AND atl_valide='t'";
- $SQLStmt.=" AND ses_valide='t'";
- $SQLStmt.=" AND sea_valide='t'";
- }
- else{
- $SQLStmt.=" AND prj_valide='f'";
- $SQLStmt.=" AND atl_valide='f'";
- $SQLStmt.=" AND ses_valide='f'";
- $SQLStmt.=" AND sea_valide='f'";
- }
- }
- if( is_array( $arrFicheID ) && count( $arrFicheID ) > 0 ){
- $SQLStmt.=" AND (seance.sea_id <> seance.sea_id";
- for ($i=0; $i<count($arrFicheID); $i++){
- if (is_numeric($arrFicheID[$i])){
- $SQLStmt.=" OR seance.sea_id=".$arrFicheID[$i];
- }
- }
- $SQLStmt.=" )";
- }
- if ($indx!=""){
- if ($indx=="datea"){
- $SQLStmt.=" ORDER BY sea_dateDebut ASC, sea_dateFin ASC";
- }
- elseif ($indx=="dated"){
- $SQLStmt.=" ORDER BY sea_dateDebut DESC, sea_dateFin DESC";
- }
- }
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqSession($ses_id){
- $SQLStmt = "SELECT projet.prj_id, projet.prj_projet, projet.prj_valide, atelier.atl_id, atelier.atl_atelier, atelier.atl_valide, ses_no, ses_code, ses_notemini, ses_note, ses_commentaire, ses_datelimite, ses_nbmin, ses_nbmax, ses_frais, ses_regionnal, ses_annule, ses_annuleraison, ses_valide, TO_CHAR(session.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') AS dateUpdate, TO_CHAR(session.dateCreation, 'YYYY-MM-DD HH24:MI:SS') AS dateCreation, count(seance.ses_id) as nbSeance, get_nbInscriptionSession(session.ses_id) as nbInscription, ses_coutParUsager";
- $SQLStmt.=" FROM session LEFT JOIN seance ON session.ses_id = seance.ses_id, projet, atelier";
- $SQLStmt.=" WHERE session.prj_id = projet.prj_id";
- $SQLStmt.=" AND session.atl_id = atelier.atl_id";
- $SQLStmt.=" AND session.ses_id = ".$ses_id;
- $SQLStmt.=" GROUP BY projet.prj_id, projet.prj_projet, projet.prj_valide, atelier.atl_id, atelier.atl_atelier, atelier.atl_valide, ses_no, ses_code, ses_notemini, ses_note, ses_commentaire, ses_datelimite, ses_nbmin, ses_nbmax, ses_frais, ses_regionnal, ses_annule, ses_annuleraison, ses_valide, session.dateupdate, session.datecreation, nbInscription, ses_coutParUsager";
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqSessionAnimateur($ses_id){
- $SQLStmt="SELECT animation.usr_id, animation.an_responsable, usager.usr_nom, usager.usr_prenom, usager.usr_email, lieu.li_no ";
- $SQLStmt.=" FROM animation, usager, lieu";
- $SQLStmt.=" WHERE animation.usr_id = usager.usr_id";
- $SQLStmt.=" AND animation.ses_id = ".$ses_id. "AND usager.li_id = lieu.li_id"; // 2007-03-23 demande #37 ajout du lieu
- $SQLStmt.=" ORDER BY usager.usr_nom, usager.usr_prenom";
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqSessionLAST(){
- $SQLStmt="SELECT MAX(ses_id) FROM session";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqSessions( $mot, $motlnk, $prj_id, $atl_id, $cla_id, $exp_id, $cli_id, $ses_annule, $nbjourstart, $datelimiteOK, $nbinsOK, $valide, $arrFicheID, $indx,$dateDebut = "", $dateFin = "" ){
- $SQLStmt = "Select ses.ses_id, pro.prj_id, prj_projet, pro.prj_valide, ate.atl_id,
- ate.atl_atelier, ate.atl_valide, ses_code, ses_notemini, ses_datelimite, ses_nbMin,
- ses_nbMax, ses_regionnal, ses_annule, ses_annuleraison, ses_valide, COUNT( sea.sea_id ) As nbSeance,
- get_nbInscriptionSession( ses.ses_id ) As nbInscription, TO_CHAR( MIN( sea_dateDebut ), 'YYYY-MM-DD HH24:MI:SS' ) As dSeaDebMin,
- TO_CHAR( MAX( sea_dateDebut ), 'YYYY-MM-DD HH24:MI:SS' ) as dSeaDebMax, get_nbInscriptionSessionAValider( ses.ses_id ),
- ses_coutParUsager, ses_commentaire
- From session ses
- Left Join seance sea On ses.ses_id = sea.ses_id
- Left Join projet pro On ses.prj_id = pro.prj_id
- Left Join projetType prt On pro.pt_id = prt.pt_id
- Left Join atelier ate On ses.atl_id = ate.atl_id";
-
- $where = "";
-
- // La recherche peut être faite pour chaque mot ou pour le groupe au complet
- if( $motlnk != "and" && $motlnk != "or" ){
- $motlnk="and"; //valeur par defaut : securite
- }
-
- // Créé une table des mots recherchés
- $arrMot = getArrayFromStringMot( $mot );
- if( count( $arrMot ) > 0 ){
- $where .= " ( ";
- for( $i = 0; $i < count( $arrMot ); $i++ ){
-
- // Vérifie si le mot est dans la colonne 'ATL_ATELIER'
- $where .= accentInsensitiveLike( "atl_atelier", $arrMot[ $i ] );
- // Ou, vérifie si le mot est dans la colonne 'ATL_DESCRIPTION'
- $where .= " OR " . accentInsensitiveLike( "atl_description", $arrMot[ $i ] );
- // Ou, vérifie si le mot est dans la colonne 'SES_CODE'
- $where .= " OR " . accentInsensitiveLike( "ses_code", $arrMot[ $i ] );
-
- // Ajoute le bon mot selon la requête de l'usager
- if( $i < ( count( $arrMot ) - 1 ) ){
- $where .= ") " . $motlnk . " ("; //OR ou AND
- }
- }
- $where .= " ) ";
- }
-
- if( is_numeric( $prj_id ) ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where.="ses.prj_id = " . $prj_id;
- }
- if( is_numeric( $atl_id ) ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= "ses.atl_id = " . $atl_id;
- }
- if( is_numeric( $cla_id ) ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= "ses.atl_id IN ( SELECT atl_id FROM atelier_classe WHERE cla_id = " . $cla_id . " )";
- }
- if( is_numeric( $exp_id ) ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= "ses.atl_id IN ( SELECT atl_id FROM atelier_expertise WHERE exp_id = " . $exp_id . " )";
- }
- if( is_numeric( $cli_id ) ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= "ses.atl_id IN ( SELECT atl_id FROM atelier_clientele WHERE cli_id = " . $cli_id . ")";
- }
- if( $ses_annule != "" ){
- if( strtolower( $ses_annule ) == "t" ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= "ses_annule = 't'";
- } else {
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= "ses_annule = 'f'";
- }
- }
- if( $datelimiteOK != "" ){
- if( !strcasecmp( $datelimiteOK, "t" ) ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= "( ses_dateLimite >= CURRENT_DATE OR ses_dateLimite IS NULL )";
- } else {
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= "ses_dateLimite < CURRENT_DATE";
- }
- }
-
- if( $dateDebut != "" ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= "sea.sea_datedebut >= '" . $dateDebut . "'";
- }
-
- if( $dateFin != "" ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= "sea.sea_datedebut <= '" . $dateFin . "'";
- }
-
- if( $valide != "" ){
- if( $valide == "t" ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= "prj_valide = 't' AND atl_valide = 't' AND ses_valide = 't'";
- } else if( $valide == "f" ){
- if( $where != "" ){
- $where .= " AND ";
- }
- // Dès que l'une de ces 3 entités est invalide, la session le devient
- $where .= "( prj_valide = 'f' Or atl_valide = 'f' Or ses_valide = 'f' )";
- }
- }
-
- if( is_array( $arrFicheID ) ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= "( ses.ses_id <> ses.ses_id";
- foreach( $arrFicheID as $fiche_id ){
- if( is_numeric( $fiche_id ) ){
- $where .= " OR ses.ses_id=" . $fiche_id;
- }
- }
- $where .= " )";
- }
-
- if( $where != "" ){
- $where = " WHERE " . $where;
- }
- $SQLStmt .= $where . " GROUP BY ses.ses_id, pro.prj_id, pro.prj_projet, pro.prj_valide, ate.atl_id, ate.atl_atelier,
- ate.atl_valide, ses_code, ses_notemini, ses_datelimite, ses_nbmin, ses_nbmax, ses_regionnal, ses_annule, ses_annuleraison,
- ses_valide, ses_coutParUsager, ses_commentaire";
-
- if( is_numeric( $nbjourstart ) || $nbinsOK != "" ){
- $SQLStmt .= " HAVING true"; // Malheureusement, cette clause ne change rien mais elle rend les prochaines lignes plus facile à bâtire
- if( is_numeric( $nbjourstart ) ){
- $SQLStmt .= " AND prochaineseance( ses.ses_id ) BETWEEN CURRENT_DATE AND CURRENT_DATE + " . $nbjourstart;
- }
- if( $nbinsOK != "" ){
- if( strtolower( $nbinsOK ) == "t" ){
- $SQLStmt .= " AND get_nbInscriptionSession( ses.ses_id ) < ses_nbMax";
- } else {
- $SQLStmt .= " AND get_nbInscriptionSession( ses.ses_id ) >= ses_nbMax";
- }
- }
- }
-
- // Cast $INDX en string car comparer 0 avec une string retourne toujours vrai
- switch( ( string ) $indx ){
- case "sessiona" :
- $SQLStmt .= " ORDER BY ses_code ASC";
- break;
- case "sessiond" :
- $SQLStmt .= " ORDER BY ses_code DESC";
- break;
- case "descriptiona" :
- $SQLStmt .= " ORDER BY atl_atelier ASC";
- break;
- case "descriptiond" :
- $SQLStmt .= " ORDER BY atl_atelier DESC";
- break;
- case "dateseaa" :
- $SQLStmt .= " ORDER BY dSeaDebMin ASC";
- break;
- case "datesead" :
- $SQLStmt .= " ORDER BY dSeaDebMin DESC";
- break;
- case "datelima" :
- $SQLStmt .= " ORDER BY ses_datelimite ASC";
- break;
- case "datelimd" :
- $SQLStmt .= " ORDER BY ses_datelimite DESC";
- break;
- case "nbinscriptiona" :
- $SQLStmt .= " ORDER BY nbInscription ASC";
- break;
- case "nbinscriptiond" :
- $SQLStmt .= " ORDER BY nbInscription DESC";
- break;
- case "couta" :
- $SQLStmt .= " ORDER BY ses_coutParUsager ASC";
- break;
- case "coutd" :
- $SQLStmt .= " ORDER BY ses_coutParUsager DESC";
- break;
- default :
- break;
- }
-
- return $SQLStmt;
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type multi records
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqSessionsArray($arrFicheID){
- $SQLStmt="SELECT session.ses_id, session.prj_id, prj_projet, session.atl_id, atl_atelier, ses_code";
- $SQLStmt.=" FROM session, projet, projetType, atelier";
- $SQLStmt.=" WHERE session.prj_id = projet.prj_id";
- $SQLStmt.=" AND projet.pt_id = projetType.pt_id";
- $SQLStmt.=" AND session.atl_id = atelier.atl_id";
- // seulement ce qui est dans le ficheID
- $SQLStmt.=" AND (session.ses_id <> session.ses_id";
- for ($i=0; $i<count($arrFicheID); $i++){
- if (is_numeric($arrFicheID[$i])){
- $SQLStmt.=" OR session.ses_id=".$arrFicheID[$i];
- }
- }
- $SQLStmt.=" )";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqSessionsCart($arrnCartSesID){
- $SQLStmt="SELECT session.ses_id, session.prj_id, prj_projet, projet.pt_id, pt_type, session.atl_id, atl_atelier, ses_code, ses_notemini, ses_datelimite, ses_nbMin, ses_nbMax, ses_annule, ses_annuleraison, ses_valide, count(seance.sea_id) as nbSeance, get_nbInscriptionSession(session.ses_id) as nbInscription, TO_CHAR(min(sea_dateDebut), 'YYYY-MM-DD HH24:MI:SS') as dSeaDebMin, TO_CHAR(max(sea_dateDebut), 'YYYY-MM-DD HH24:MI:SS') as dSeaDebMax";
- $SQLStmt.=" FROM session LEFT JOIN seance ON session.ses_id = seance.ses_id, projet, projetType, atelier";
- $SQLStmt.=" WHERE session.prj_id = projet.prj_id";
- $SQLStmt.=" AND projet.pt_id = projetType.pt_id";
- $SQLStmt.=" AND session.atl_id = atelier.atl_id";
- $SQLStmt.=" AND (session.ses_id <> session.ses_id";
- for ($i=0; $i<count($arrnCartSesID); $i++){
- if (is_numeric($arrnCartSesID[$i])){
- $SQLStmt.=" OR session.ses_id=".$arrnCartSesID[$i];
- }
- }
- $SQLStmt.=" )";
- $SQLStmt.=" GROUP BY session.ses_id, session.prj_id, prj_projet, projet.pt_id, pt_type, session.atl_id, atl_atelier, ses_code, ses_notemini, ses_datelimite, ses_nbmin, ses_nbmax, ses_annule, ses_annuleraison, ses_valide";
- $SQLStmt.=" ORDER BY ses_code ASC";
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
-
- function getSQLStmtReqSessionsFromAnimateur($mot, $motlnk, $prj_id, $atl_id, $cla_id, $exp_id, $cli_id, $ses_annule, $nbjourstart, $datelimiteOK, $nbinsOK, $valide, $arrFicheID, $userID, $indx, $dateDebut = "", $dateFin = ""){
- $SQLStmt="SELECT session.ses_id, projet.prj_id, prj_projet, projet.prj_valide, atelier.atl_id, atelier.atl_atelier, atelier.atl_valide, ses_code, ses_notemini, ses_datelimite, ses_nbMin, ses_nbMax, ses_regionnal, ses_annule, ses_annuleraison, ses_valide, count(seance.sea_id) as nbSeance, get_nbInscriptionSession(session.ses_id) as nbInscription, TO_CHAR(min(sea_dateDebut), 'YYYY-MM-DD HH24:MI:SS') as dSeaDebMin, TO_CHAR(max(sea_dateDebut), 'YYYY-MM-DD HH24:MI:SS') as dSeaDebMax, get_nbInscriptionSessionAValider(session.ses_id), ses_coutParUsager";
- $SQLStmt.=" FROM animation JOIN (session LEFT JOIN seance USING (ses_id)) USING (ses_id), projet, projetType, atelier";
- $SQLStmt.=" WHERE session.prj_id = projet.prj_id";
- $SQLStmt.=" AND projet.pt_id = projetType.pt_id";
- $SQLStmt.=" AND session.atl_id = atelier.atl_id";
- $SQLStmt.=" AND animation.usr_id = $userID";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt .= " ( ";
- $SQLStmt .= accentInsensitiveLike("atl_atelier", $arrMot[$i]);
- $SQLStmt .= " OR " . accentInsensitiveLike("atl_description", $arrMot[$i]);
- $SQLStmt .= " OR " . accentInsensitiveLike("ses_code", $arrMot[$i]);
- $SQLStmt .= " ) ";
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if (is_numeric($prj_id)){
- $SQLStmt.=" AND session.prj_id = ".$prj_id;
- }
- if (is_numeric($atl_id)){
- $SQLStmt.=" AND session.atl_id = ".$atl_id;
- }
- if (is_numeric($cla_id)){
- $SQLStmt.=" AND session.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM atelier_classe";
- $SQLStmt.=" WHERE cla_id=".$cla_id;
- $SQLStmt.=")";
- }
- if (is_numeric($exp_id)){
- $SQLStmt.=" AND session.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM atelier_expertise";
- $SQLStmt.=" WHERE exp_id=".$exp_id;
- $SQLStmt.=")";
- }
- if (is_numeric($cli_id)){
- $SQLStmt.=" AND session.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM atelier_clientele";
- $SQLStmt.=" WHERE cli_id=".$cli_id;
- $SQLStmt.=")";
- }
- if ($ses_annule!=""){
- if (!strcasecmp($ses_annule,"t")){
- $SQLStmt.=" AND ses_annule='t'";
- }
- else{
- $SQLStmt.=" AND ses_annule='f'";
- }
- }
- if ($datelimiteOK!=""){
- if (!strcasecmp($datelimiteOK,"t")){
- $SQLStmt.=" AND (ses_dateLimite >= CURRENT_DATE OR ses_dateLimite IS NULL)";
- }
- else{
- $SQLStmt.=" AND ses_dateLimite < CURRENT_DATE";
- }
- }
- if($dateDebut != ""){
- $SQLStmt.=" AND seance.sea_datedebut >= '$dateDebut'";
- }
-
- if($dateFin != ""){
- $SQLStmt.=" AND seance.sea_datedebut <= '$dateFin'";
- }
- if ($valide!=""){
- if (!strcasecmp($valide,"t")){
- $SQLStmt.=" AND prj_valide='t'";
- $SQLStmt.=" AND atl_valide='t'";
- $SQLStmt.=" AND ses_valide='t'";
- }
- else{
- $SQLStmt.=" AND prj_valide='f'";
- $SQLStmt.=" AND atl_valide='f'";
- $SQLStmt.=" AND ses_valide='f'";
- }
- }
- if (is_array($arrFicheID)){
- $SQLStmt.=" AND (session.ses_id <> session.ses_id";
- for ($i=0; $i<count($arrFicheID); $i++){
- if (is_numeric($arrFicheID[$i])){
- $SQLStmt.=" OR session.ses_id=".$arrFicheID[$i];
- }
- }
- $SQLStmt.=" )";
- }
- $SQLStmt.=" GROUP BY session.ses_id, projet.prj_id, projet.prj_projet, projet.prj_valide, atelier.atl_id, atelier.atl_atelier, atelier.atl_valide, ses_code, ses_notemini, ses_datelimite, ses_nbmin, ses_nbmax, ses_regionnal, ses_annule, ses_annuleraison, ses_valide, ses_coutParUsager";
- $SQLStmt.=" HAVING true";
- if (is_numeric($nbjourstart)){
- $SQLStmt.=" AND prochaineseance(session.ses_id) BETWEEN CURRENT_DATE AND CURRENT_DATE+". $nbjourstart;
- }
- if ($nbinsOK!=""){
- if (!strcasecmp($nbinsOK,"t")){
- $SQLStmt.=" AND get_nbInscriptionSession(session.ses_id) < ses_nbMax";
- }
- else{
- $SQLStmt.=" AND get_nbInscriptionSession(session.ses_id) >= ses_nbMax";
- }
- }
- if ($indx!=""){
- if ($indx=="sessiona"){
- $SQLStmt.=" ORDER BY ses_code ASC";
- }
- elseif ($indx=="sessiond"){
- $SQLStmt.=" ORDER BY ses_code DESC";
- }
- elseif ($indx=="dateseaa"){
- $SQLStmt.=" ORDER BY dSeaDebMin ASC";
- }
- elseif ($indx=="datesead"){
- $SQLStmt.=" ORDER BY dSeaDebMin DESC";
- }
- elseif ($indx=="datelima"){
- $SQLStmt.=" ORDER BY ses_datelimite ASC";
- }
- elseif ($indx=="datelimd"){
- $SQLStmt.=" ORDER BY ses_datelimite DESC";
- }
- elseif ($indx=="nbinscriptiona"){
- $SQLStmt.=" ORDER BY nbInscription ASC";
- }
- elseif ($indx=="nbinscriptiond"){
- $SQLStmt.=" ORDER BY nbInscription DESC";
- }
- elseif ($indx=="couta"){
- $SQLStmt.=" ORDER BY ses_coutParUsager ASC";
- }
- elseif ($indx=="coutd"){
- $SQLStmt.=" ORDER BY ses_coutParUsager DESC";
- }
- }
- return ($SQLStmt);
- }
-
-
- function getSQLStmtReqSessionsFromAdminProjet($mot, $motlnk, $prj_id, $atl_id, $cla_id, $exp_id, $cli_id, $ses_annule, $nbjourstart, $datelimiteOK, $nbinsOK, $valide, $arrFicheID, $usrid, $indx,$dateDebut = "", $dateFin = ""){
- $SQLStmt="SELECT session.ses_id, projet.prj_id, prj_projet, projet.prj_valide, atelier.atl_id, atelier.atl_atelier, atelier.atl_valide, ses_code, ses_notemini, ses_datelimite, ses_nbMin, ses_nbMax, ses_regionnal, ses_annule, ses_annuleraison, ses_valide, count(seance.sea_id) as nbSeance, get_nbInscriptionSession(session.ses_id) as nbInscription, TO_CHAR(min(sea_dateDebut), 'YYYY-MM-DD HH24:MI:SS') as dSeaDebMin, TO_CHAR(max(sea_dateDebut), 'YYYY-MM-DD HH24:MI:SS') as dSeaDebMax, get_nbInscriptionSessionAValider(session.ses_id), ses_coutParUsager";
- $SQLStmt.=" FROM session LEFT JOIN seance ON session.ses_id = seance.ses_id, projet, projetType, atelier";
- $SQLStmt.=" WHERE session.prj_id = projet.prj_id";
- $SQLStmt .= " AND session.prj_id IN (";
- $SQLStmt .= " SELECT prj_id FROM projetAdmin WHERE usr_id = $usrid";
- $SQLStmt .= ")";
- $SQLStmt.=" AND projet.pt_id = projetType.pt_id";
- $SQLStmt.=" AND session.atl_id = atelier.atl_id";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt .= " ( ";
- $SQLStmt .= accentInsensitiveLike("atl_atelier", $arrMot[$i]);
- $SQLStmt .= " OR " . accentInsensitiveLike("atl_description", $arrMot[$i]);
- $SQLStmt .= " OR " . accentInsensitiveLike("ses_code", $arrMot[$i]);
- $SQLStmt .= " ) ";
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if (is_numeric($prj_id)){
- $SQLStmt.=" AND session.prj_id = ".$prj_id;
- }
- if (is_numeric($atl_id)){
- $SQLStmt.=" AND session.atl_id = ".$atl_id;
- }
- if (is_numeric($cla_id)){
- $SQLStmt.=" AND session.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM atelier_classe";
- $SQLStmt.=" WHERE cla_id=".$cla_id;
- $SQLStmt.=")";
- }
- if (is_numeric($exp_id)){
- $SQLStmt.=" AND session.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM atelier_expertise";
- $SQLStmt.=" WHERE exp_id=".$exp_id;
- $SQLStmt.=")";
- }
- if (is_numeric($cli_id)){
- $SQLStmt.=" AND session.atl_id IN (";
- $SQLStmt.=" SELECT atl_id";
- $SQLStmt.=" FROM atelier_clientele";
- $SQLStmt.=" WHERE cli_id=".$cli_id;
- $SQLStmt.=")";
- }
- if ($ses_annule!=""){
- if (!strcasecmp($ses_annule,"t")){
- $SQLStmt.=" AND ses_annule='t'";
- }
- else{
- $SQLStmt.=" AND ses_annule='f'";
- }
- }
- if ($datelimiteOK!=""){
- if (!strcasecmp($datelimiteOK,"t")){
- $SQLStmt.=" AND (ses_dateLimite >= CURRENT_DATE OR ses_dateLimite IS NULL)";
- }
- else{
- $SQLStmt.=" AND ses_dateLimite < CURRENT_DATE";
- }
- }
-
-
- if($dateDebut != ""){
- $SQLStmt.=" AND seance.sea_datedebut >= '$dateDebut'";
- }
-
- if($dateFin != ""){
- $SQLStmt.=" AND seance.sea_datedebut <= '$dateFin'";
- }
-
-
- if ($valide!=""){
- if (!strcasecmp($valide,"t")){
- $SQLStmt.=" AND prj_valide='t'";
- $SQLStmt.=" AND atl_valide='t'";
- $SQLStmt.=" AND ses_valide='t'";
- }
- else{
- $SQLStmt.=" AND prj_valide='f'";
- $SQLStmt.=" AND atl_valide='f'";
- $SQLStmt.=" AND ses_valide='f'";
- }
- }
- if (is_array($arrFicheID)){
- $SQLStmt.=" AND (session.ses_id <> session.ses_id";
- for ($i=0; $i<count($arrFicheID); $i++){
- if (is_numeric($arrFicheID[$i])){
- $SQLStmt.=" OR session.ses_id=".$arrFicheID[$i];
- }
- }
- $SQLStmt.=" )";
- }
- $SQLStmt.=" GROUP BY session.ses_id, projet.prj_id, projet.prj_projet, projet.prj_valide, atelier.atl_id, atelier.atl_atelier, atelier.atl_valide, ses_code, ses_notemini, ses_datelimite, ses_nbmin, ses_nbmax, ses_regionnal, ses_annule, ses_annuleraison, ses_valide, ses_coutParUsager";
- $SQLStmt.=" HAVING true";
- if (is_numeric($nbjourstart)){
- $SQLStmt.=" AND prochaineseance(session.ses_id) BETWEEN CURRENT_DATE AND CURRENT_DATE+". $nbjourstart;
- }
- if ($nbinsOK!=""){
- if (!strcasecmp($nbinsOK,"t")){
- $SQLStmt.=" AND get_nbInscriptionSession(session.ses_id) < ses_nbMax";
- }
- else{
- $SQLStmt.=" AND get_nbInscriptionSession(session.ses_id) >= ses_nbMax";
- }
- }
- if ($indx!=""){
- if ($indx=="sessiona"){
- $SQLStmt.=" ORDER BY ses_code ASC";
- }
- elseif ($indx=="sessiond"){
- $SQLStmt.=" ORDER BY ses_code DESC";
- }
- elseif ($indx=="dateseaa"){
- $SQLStmt.=" ORDER BY dSeaDebMin ASC";
- }
- elseif ($indx=="datesead"){
- $SQLStmt.=" ORDER BY dSeaDebMin DESC";
- }
- elseif ($indx=="datelima"){
- $SQLStmt.=" ORDER BY ses_datelimite ASC";
- }
- elseif ($indx=="datelimd"){
- $SQLStmt.=" ORDER BY ses_datelimite DESC";
- }
- elseif ($indx=="nbinscriptiona"){
- $SQLStmt.=" ORDER BY nbInscription ASC";
- }
- elseif ($indx=="nbinscriptiond"){
- $SQLStmt.=" ORDER BY nbInscription DESC";
- }
- elseif ($indx=="couta"){
- $SQLStmt.=" ORDER BY ses_coutParUsager ASC";
- }
- elseif ($indx=="coutd"){
- $SQLStmt.=" ORDER BY ses_coutParUsager DESC";
- }
- }
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqSessionsFromAtelier($atl_id){
- $SQLStmt="SELECT session.ses_id, session.prj_id, prj_projet, projet.pt_id, pt_type, session.atl_id, atl_atelier, ses_code, ses_notemini, ses_datelimite, ses_nbmin, ses_nbmax, ses_annule, ses_annuleraison, ses_valide, count(seance.ses_id) as nbSeance, get_nbInscriptionSession(session.ses_id) as nbInscription, TO_CHAR(min(sea_dateDebut), 'YYYY-MM-DD HH24:MI:SS') as dSeaDebMin, TO_CHAR(max(sea_dateDebut), 'YYYY-MM-DD HH24:MI:SS') as dSeaDebMax";
- $SQLStmt.=" FROM session LEFT JOIN seance ON session.ses_id = seance.ses_id, projet, projetType, atelier";
- $SQLStmt.=" WHERE session.prj_id = projet.prj_id";
- $SQLStmt.=" AND projet.pt_id = projetType.pt_id";
- $SQLStmt.=" AND session.atl_id = atelier.atl_id";
- $SQLStmt.=" AND session.atl_id = ".$atl_id;
- $SQLStmt.=" GROUP BY session.ses_id, session.prj_id, prj_projet, projet.pt_id, pt_type, session.atl_id, atl_atelier, ses_code, ses_notemini, ses_datelimite, ses_nbmin, ses_nbmax, ses_annule, ses_annuleraison, ses_valide";
- echo $SQLStmt.=" ORDER BY session.ses_code";
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqSessionsPortfolio( $usr_id_INSCRIT, $histo, $order_by = "" ){
- $SQLStmt = 'Select session.ses_id, session.prj_id, prj_projet, projet.pt_id, pt_type, session.atl_id, atl_atelier, ses_code, ses_notemini, ses_datelimite, ses_nbMin, ses_nbMax, ses_regionnal, ses_annule, ses_annuleraison, ses_valide, Count( seance.sea_id ) as nbSeance, get_nbInscriptionSession( session.ses_id ) as nbInscription, To_Char( Min( sea_dateDebut ), \'YYYY-MM-DD HH24:MI:SS\' ) as dSeaDebMin, To_Char( Max( sea_dateDebut ), \'YYYY-MM-DD HH24:MI:SS\' ) as dSeaDebMax, get_nbPresencePerSessionUser( session.ses_id, inscriptionSession.usr_id ) As nbPresence, inscriptionEtat.ie_OK, atl_valide, prj_valide
- FROM session
- LEFT JOIN seance ON session.ses_id = seance.ses_id
- LEFT JOIN projet ON session.prj_id = projet.prj_id
- LEFT JOIN projetType ON projet.pt_id = projetType.pt_id
- LEFT JOIN atelier ON session.atl_id = atelier.atl_id
- LEFT JOIN inscriptionSession ON session.ses_id = inscriptionSession.ses_id
- LEFT JOIN inscriptionEtat ON inscriptionSession.ie_id = inscriptionEtat.ie_id
- WHERE inscriptionSession.usr_id = \'' . $usr_id_INSCRIT . '\'
- GROUP BY session.ses_id, session.prj_id, prj_projet, projet.pt_id, pt_type, session.atl_id, atl_atelier, ses_code, ses_notemini, ses_datelimite, ses_nbmin, ses_nbmax, ses_regionnal, ses_annule, ses_annuleraison, ses_valide, inscriptionSession.usr_id, inscriptionEtat.ie_OK, atl_valide, prj_valide';
-
- // On retourne soit l'historique future, passée ou toute
- if( $histo == 'futur' ){
- $SQLStmt .= ' HAVING ( max( sea_dateFin ) >= CURRENT_DATE OR min( sea_dateDebut ) IS NULL )';
- } elseif( $histo == 'termine' ){
- $SQLStmt .= ' HAVING inscriptionEtat.ie_OK = \'t\' AND max( sea_dateFin ) < CURRENT_DATE';
- }
-
- switch( $order_by ) {
- case 'sessiona' :
- $SQLStmt .= ' Order By ses_code Asc';
- break;
- case 'sessiond' :
- $SQLStmt .= ' Order By ses_code Desc';
- break;
- case 'dateseaa' :
- $SQLStmt .= ' Order By dSeaDebMin Asc';
- break;
- case 'datesead' :
- $SQLStmt .= ' Order By dSeaDebMin Desc';
- break;
- case 'datelima' :
- $SQLStmt .= ' Order By ses_datelimite Asc';
- break;
- case 'datelimd' :
- $SQLStmt .= ' Order By ses_datelimite Desc';
- break;
- case 'nbinscriptiona' :
- $SQLStmt .= ' Order By nbInscription Asc';
- break;
- case 'nbinscriptiond' :
- $SQLStmt .= ' Order By nbInscription Desc';
- break;
- case 'couta' :
- $SQLStmt .= ' Order By ses_coutParUsager Asc';
- break;
- case 'coutd' :
- $SQLStmt .= ' Order By ses_coutParUsager Desc';
- break;
- default :
- $SQLStmt .= ' Order By dSeaDebMin Desc, ses_code Asc';
- }
- return $SQLStmt;
- }
-
- function getSQLStmtReqSousHierarchies($branchID, $treeID) {
- $sql = "SELECT node, etiquette FROM nodes";
- if (is_numeric($branchID)) {
- $sql .= " WHERE parent = $branchID";
- }
- else {
- $sql .= " WHERE parent IS NULL";
- }
- $sql .= " AND tr_id = $treeID";
-
- return $sql;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type 1 record
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqUsager($usr_id){
- $SQLStmt="SELECT usr_nom, usr_prenom, usr_email, usr_URL, usr_telRejoindre, usr_telTravail, usr_telMaison, usr_telCellulaire, usr_telPage, usr_telFax, usr_adresse, usr_ville, usr_codePostal, usr_societe, usr_fonction, usr_nas, usr_dateNaissance, usr_commentaire, usr_interet, usr_LDAP, usr_login, TO_CHAR(usager.usr_dernieracces, 'YYYY-MM-DD HH24:MI:SS') AS usr_dernieracces, usager.li_id, lieu.li_lieu, usr_enligne, usr_valide, TO_CHAR(usager.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') AS dateUpdate, TO_CHAR(usager.dateCreation, 'YYYY-MM-DD HH24:MI:SS') AS dateCreation, usr_locale";
- $SQLStmt.=" FROM usager, lieu";
- $SQLStmt.=" WHERE usager.li_id = lieu.li_id";
- $SQLStmt.=" AND usr_id = ".$usr_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqUsagerLAST(){
- $SQLStmt="SELECT MAX(usr_id) FROM usager";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type 1 record
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqUsagerFromLDAP($usr_ldapcode){
- $SQLStmt="SELECT usr_id";
- $SQLStmt.=" FROM usager";
- $SQLStmt.=" WHERE usr_ldapcode = '".fixPGQuote($usr_ldapcode)."'";
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type 1 record
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqUsagerFromLogin($usr_login){
- $SQLStmt="SELECT usr_id, usr_ldap";
- $SQLStmt.=" FROM usager";
- $SQLStmt.=" WHERE usr_login = '".fixPGQuote($usr_login)."'";
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type 1 record
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqUsagerFromLoginPsw($usr_login, $usr_psw){
- $SQLStmt="SELECT usr_id";
- $SQLStmt.=" FROM usager";
- $SQLStmt.=" WHERE usr_login = '".fixPGQuote($usr_login)."'";
- $SQLStmt.=" AND usr_psw = '".fixPGQuote($usr_psw)."'";
- $SQLStmt.=" AND usr_ldap = 'f'";
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type multi records
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqUsagers($mot, $motlnk, $ut_id, $li_id, $adminlieu_id, $valide, $arrFicheID, $indx){
- $SQLStmt="SELECT usr_id, usr_nom, usr_prenom, usr_email, usr_enligne, usr_valide, usager.li_id, lieu.li_lieu, get_usagerTypeListe(usr_id, ' + ') AS usagerTypeListe, usager.usr_ldap";
- $SQLStmt.=" FROM usager, lieu";
- $SQLStmt.=" WHERE usr_id = usr_id";
- $SQLStmt.=" AND usager.li_id = lieu.li_id";
- if ($mot!=""){
- if ($motlnk!="and" && $motlnk!="or"){
- $motlnk="and"; //valeur par defaut : securite
- }
- $arrMot=getArrayFromStringMot($mot);
- $SQLStmt.=" AND (";
- for ($i=0; $i<count($arrMot); $i++){
- $SQLStmt.="(usr_nom ILIKE '%".fixPGQuote($arrMot[$i])."%'";
- $SQLStmt.=" OR usr_prenom ILIKE '%".fixPGQuote($arrMot[$i])."%'";
- $SQLStmt.=" OR usr_prenom||' '||usr_nom ILIKE '%".fixPGQuote($arrMot[$i])."%')";
- if ($i<count($arrMot)-1){
- $SQLStmt.=" ".$motlnk." "; //OR ou AND
- }
- }
- $SQLStmt.=")";
- }
- if (is_numeric($ut_id)){
- $SQLStmt.=" AND usr_id IN (";
- $SQLStmt.=" SELECT usr_id";
- $SQLStmt.=" FROM usager_usagerType";
- $SQLStmt.=" WHERE ut_id=".$ut_id;
- $SQLStmt.=")";
- }
- if (is_numeric($li_id)){
- $SQLStmt.=" AND usager.li_id = ".$li_id;
- }
- if (is_numeric($adminlieu_id)){
- $SQLStmt.=" AND usager.li_id IN (";
- $SQLStmt.=" SELECT li_id";
- $SQLStmt.=" FROM lieuadmin";
- $SQLStmt.=" WHERE usr_id=".$adminlieu_id;
- $SQLStmt.=")";
- }
- if ($valide!=""){
- if (!strcasecmp($valide,"t")){
- $SQLStmt.=" AND usr_valide='t'";
- }
- else{
- $SQLStmt.=" AND usr_valide='f'";
- }
- }
- if (is_array($arrFicheID)){
- $SQLStmt.=" AND (usager.usr_id <> usager.usr_id";
- for ($i=0; $i<count($arrFicheID); $i++){
- if (is_numeric($arrFicheID[$i])){
- $SQLStmt.=" OR usager.usr_id=".$arrFicheID[$i];
- }
- }
- $SQLStmt.=" )";
- }
- if ($indx!=""){
- if ($indx=="noma"){
- $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
- }
- elseif ($indx=="nomd"){
- $SQLStmt.=" ORDER BY usr_nom DESC, usr_prenom DESC";
- }
- elseif ($indx=="lieua"){
- $SQLStmt.=" ORDER BY li_lieu ASC";
- }
- elseif ($indx=="lieud"){
- $SQLStmt.=" ORDER BY li_lieu DESC";
- }
- elseif ($indx=="typea"){
- $SQLStmt.=" ORDER BY usagerTypeListe ASC";
- }
- elseif ($indx=="typed"){
- $SQLStmt.=" ORDER BY usagerTypeListe DESC";
- }
- }
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type multi records
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqUsagersArray($arrFicheID){
- $SQLStmt="SELECT usr_id, usr_nom, usr_prenom";
- $SQLStmt.=" FROM usager";
- $SQLStmt.=" WHERE (usager.usr_id <> usager.usr_id";
- for ($i=0; $i<count($arrFicheID); $i++){
- if (is_numeric($arrFicheID[$i])){
- $SQLStmt.=" OR usager.usr_id=".$arrFicheID[$i];
- }
- }
- $SQLStmt.=" )";
- return $SQLStmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT -type 1 record
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqUsagerGeneral($usr_id){
- $SQLStmt="SELECT usr_nom, usr_prenom, usr_locale";
- $SQLStmt.=" FROM usager";
- $SQLStmt.=" WHERE usr_id = " . $usr_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqUsagerTypeForSecID($sec_id){
- $SQLStmt="SELECT usagerType.ut_id, usagerType.ut_type";
- $SQLStmt.=" FROM usagerType";
- $SQLStmt.=" WHERE usagerType.sec_id <= " . $sec_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqUsagerTypeForUser($usr_id){
- $SQLStmt="SELECT usagerType.ut_id, usagerType.ut_type, usagerType.sec_id";
- $SQLStmt.=" FROM usager_usagerType, usagerType";
- $SQLStmt.=" WHERE usager_usagerType.ut_id=usagerType.ut_id";
- $SQLStmt.=" AND usr_id = " . $usr_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqUsagerTypeLogin($usr_id){
- $SQLStmt="SELECT usagerType.ut_id, usagerType.sec_id";
- $SQLStmt.=" FROM usager_usagertype, usagerType";
- $SQLStmt.=" WHERE usager_usagerType.ut_id = usagerType.ut_id";
- $SQLStmt.=" AND usr_id = " . $usr_id;
- return ($SQLStmt);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function getTimeStamp($date, $time)
- // Retourne le timestamp en fonction de la date et l'heure passées en paramètres
- // IN: $date: la date
- // $time: l'heure
- // OUT: (string-timestamp) le timestamp
- ///////////////////////////////////////////////////////////////////////////////////////
- function getTimeStamp($date, $time){
- if (isDate($date)){
- $time = str_replace("h",":",$time);
- if (isTime24($time)){
- $timestamp = $date." ".$time;
- }
- else{
- $timestamp = $date;
- }
- }
- return($timestamp);
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // getValFromQueryString($querystring, $var)
- // Retourne la valeur d'une des variables qui se trouve dans le querystring.
- // IN: $querystring: le querystring actuel (ex:"mode=display&pg=1&indx=alpha")
- // $var: variable dans le querystring qu'on veux la valeur (ex: "mode")
- // OUT: (string) la valeur de la variable (ex: "display")
- ///////////////////////////////////////////////////////////////////////////////////////
- function getValFromQueryString($querystring, $var){
- $var=urlencode($var);
- ereg("(^".$var."=|&".$var."=)([^&|^=|^\?]*)", $querystring, $regs); //regs[2]=valeur de var
- return(urldecode($regs[2]));
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la nouvelle string avec les limites acceptées.
- ///////////////////////////////////////////////////////////////////////////////////////
- function getWrapString($sIn,$width,$sBreak){
- if (strlen($sIn)>$width){
- return(substr($sIn,0,$width-strlen($sBreak)).$sBreak);
- }
- else{
- return($sIn);
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function isDate($sInput)
- // Retourne true si le input reçu en paramètre est une date valide. Voici les formats
- // acceptés: yyyy-mm-dd ou yyyy/mm/dd ou dd-mm-yyyy ou dd/mm/yyyy
- // IN: $sInput: la date à vérifier
- // OUT: true: date false: ??
- ///////////////////////////////////////////////////////////////////////////////////////
- function isDate($sInput){
- // yyyy-mm-dd ou yyyy/mm/dd
- if (ereg("(^[0-9]{4})"."(/|-)"."([0-9]{2})"."(/|-)"."([0-9]{2}$)", $sInput, $regs)){
- if (checkdate($regs[3], $regs[5], $regs[1])){
- return true;
- }
- }
- // dd-mm-yyyy ou dd/mm/yyyy
- elseif (ereg("(^[0-9]{2})"."(/|-)"."([0-9]{2})"."(/|-)"."([0-9]{4}$)", $sInput, $regs)){
- if (checkdate($regs[3], $regs[1], $regs[5])){
- return true;
- }
- }
- return false;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function isEmail($sTemp)
- // Retourne true si le input reçu en paramètre est un email.
- ///////////////////////////////////////////////////////////////////////////////////////
- function isEmail($sTemp){
- return (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@'. '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $sTemp));
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function isInscriptionOK($nbInscription, $nbInscriptionMax, $sesAnnule, $dSesLimite)
- // Retourne true si les données nous confirme que la session peut permettre l'inscription d'usager
- // IN: $nbInscription nombre d'inscription actuellement
- // $nbInscriptionMax nombre max d'ins que la session peut prendre
- // $sesAnnule 't' si la session est annulée
- // $dSesLimite date limite pour inscription à la session
- // OUT: true: inscription acceptée
- ///////////////////////////////////////////////////////////////////////////////////////
- function isInscriptionOK($nbInscription, $nbInscriptionMax, $sesAnnule, $dSesLimite){
- if ($nbInscription >= $nbInscriptionMax){
- //echo "(complet)";
- return false;
- }
- if ($sesAnnule == "t"){
- //echo "(annule)";
- return false;
- }
- if ( (isDate($dSesLimite)) && (strtotime(date("Y-m-d"))>strtotime($dSesLimite)) ){
- return false;
- }
- return true;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function isTime24($sInput)
- // Retourne true si le input reçu en paramètre est une heure valide. Voici les formats
- // acceptés: hh:mm:ss hh:mm
- // IN: $sInput: la date à vérifier
- // OUT: true: heure false: ??
- ///////////////////////////////////////////////////////////////////////////////////////
- function isTime24($sInput){
- //hh:mm:ss
- if (ereg("(^[0-9]{1,2})"."(:)"."([0-9]{1,2})"."(:)"."([0-9]{1,2}$)", $sInput, $regs)){
- if (($regs[1]<=23) && ($regs[3]<=59) && ($regs[5]<=59)){
- return true;
- }
- }
- //hh:mm
- elseif (ereg("(^[0-9]{1,2})"."(:)"."([0-9]{1,2}$)", $sInput, $regs)){
- if (($regs[1]<=23) && ($regs[3]<=59)){
- return true;
- }
- }
- return false;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function isTimeStamp($sInput)
- // Retourne true si le input reçu en paramètre est un timestamp valide.
- // IN: $sInput: timestamp à vérifier
- // OUT: true: timestamp false: ??
- ///////////////////////////////////////////////////////////////////////////////////////
- function isTimeStamp($sInput){
- //vrai timestamp
- if (ereg("^([^[:space:]]*)"."[[:space:]]"."([^[:space:]]*)$", $sInput, $regs)){
- if ( (isDate($regs[1])) && (isTime24($regs[2])) ){
- return true;
- }
- }
- return false;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // printResultPage($hlink, $pg, $nbPage, $nbPageMax, $querystring)
- // Retourne les page résultante après une recherche.
- // IN: $hlink: lien vers laquelle on va pointer (résultat)
- // $pg: numéro de page actuelle (nombre)
- // $nbPage: nombre de page de résultat de recherche
- // $nbPageMax: maximum de page à afficher dans la barre de navigation
- // $querystring: querystring actuel, ça va nous permettre de l'ajouter au lien
- // $var: variable dans le querystring qu'on veux la valeur (ex: "mode")
- ///////////////////////////////////////////////////////////////////////////////////////
- function getResultPage( $hlink, $class, $htmlHeader, $no_page, $nbPage, $nbPageMax, $querystring ){
- $querystring = getQueryStringUpdated( $querystring, "mode", "display");
- $output = $htmlHeader;
-
- // Les points de suspensions s'ajoutent quand on coupe la liste en quelque part
- $add_suspension = true;
-
- // S'il n'y a pas assé de pages à afficher à gauche, on en transfert à droite
- if( ( $no_page - ceil( $nbPageMax / 2 ) ) < 0 ){
- $nb_gauche = ( $no_page % ceil( $nbPageMax / 2 ) ) - 1;
- $nb_droite = $nbPageMax - ( $nb_gauche % $nbPageMax );
- // La même chose mais à l'inverse
- } elseif( ( $no_page + floor( $nbPageMax / 2 ) ) > $nbPage ){
- $nb_droite = $no_page - $nbPage;
- $nb_gauche = $nbPageMax - ( $nb_droite % $nbPageMax );
- // Sinon, on divise le nombre plus ou moins également
- } else {
- $nb_gauche = ceil( $nbPageMax / 2 );
- $nb_droite = floor( $nbPageMax / 2 );
- }
-
- // Si on est plus loin que la page #1, on affiche les flêches vers la gauche
- if( $no_page > 1 ){
- $output .= "<a href='" . $hlink . "?" . getQueryStringUpdated( $querystring, "pg", 1 ) . "'>|<</a>";
- $output .= "<a href='" . $hlink . "?" . getQueryStringUpdated( $querystring, "pg", $no_page - 1 ) . "'><<</a>";
- }
-
- // Affiche de toutes les pages
- for( $page = 1; $page <= $nbPage; $page++ ){
- // Si la page est dans la zone que l'on veut afficher, on l'affiche
- if( $page >= $no_page - $nb_gauche && $page <= $no_page + $nb_droite ){
- if( $page <> $no_page ){
- $output .= "<a href='" . $hlink . "?" . getQueryStringUpdated( $querystring, "pg", $page ) . "'>" . $page . "</a>";
- } else {
- $output .= "<a class='page_presente'>" . $page . "</a>";
- }
- $add_suspension = true;
- // Sinon, on met des points de suspension
- } else {
- if( $add_suspension ) {
- // Juste une fois
- $add_suspension = false;
- $output .= "<a>[...]</a>";
- }
- }
- }
-
- // Si on est moins loin que la dernière page, on affiche les flèches vers la droite
- if( $no_page < $nbPage ){
- $output .= "<a href='" . $hlink . "?" . getQueryStringUpdated( $querystring, "pg", $no_page + 1 ) . "'>>></a>";
- $output .= "<a href='" . $hlink . "?" . getQueryStringUpdated( $querystring, "pg", $nbPage ) . "'>>|</a>";
- }
-
- // Ajoute la classe s'il y a lieu
- if( $output <> "" && $class <> "" ){
- $output = "<span class='" . $class . "'>".$output."</span>";
- }
-
- return $output;
- }
-
- // Fait l'affichage de la fonction "getResultPage"
- function printResultPage( $hlink, $class, $htmlHeader, $no_page, $nbPage, $nbPageMax, $querystring ){
- echo getResultPage( $hlink, $class, $htmlHeader, $no_page, $nbPage, $nbPageMax, $querystring );
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // printResultPageButton( $pg, $nbPage, $nbPageMax, $class=null )
- // Affiche des boutons menant vers d'auters pages de la même recherche
- // IN: $pg: numéro de page actuelle (nombre)
- // $nbPage: nombre de page de résultat de recherche
- // $nbPageMax: maximum de page à afficher dans la barre de navigation
- // $class: paramètre inutile pour le moment, implémenté en vue d'ajouts éventuels
- ///////////////////////////////////////////////////////////////////////////////////////
- function getResultPageButton( $no_page, $nbPage, $nbPageMax, $class = "" ){
- $output = "";
-
- // Les points de suspensions s'ajoutent quand on coupe la liste en quelque part
- $add_suspension = true;
- // Manière que les boutons devront être affichés par sprintf
- $gabarit_bouton = '<button type=\'submit\' name=\'pg\' value=\'%1$s\'%3$s><span>%2$s</span></button>';
-
- // S'il n'y a pas assé de pages à afficher à gauche, on en transfert à droite
- if( ( $no_page - ceil( $nbPageMax / 2 ) ) < 0 ){
- $nb_gauche = ( $no_page % ceil( $nbPageMax / 2 ) ) - 1;
- $nb_droite = $nbPageMax - ( $nb_gauche % $nbPageMax );
- // La même chose mais à l'inverse
- } elseif( ( $no_page + floor( $nbPageMax / 2 ) ) > $nbPage ){
- $nb_droite = $no_page - $nbPage;
- $nb_gauche = $nbPageMax - ( $nb_droite % $nbPageMax );
- // Sinon, on divise le nombre plus ou moins également
- } else {
- $nb_gauche = ceil( $nbPageMax / 2 );
- $nb_droite = floor( $nbPageMax / 2 );
- }
-
- // Si on est plus loin que la page #1, on affiche les flêches vers la gauche
- if( $no_page > 1 ){
- $output .= sprintf( $gabarit_bouton, "1", "|<", "" );
- $output .= sprintf( $gabarit_bouton, ( $no_page - 1 ), "<<", "" );
- }
-
- // Affiche de toutes les pages
- for( $page = 1; $page <= $nbPage; $page++ ){
- // Si la page est dans la zone que l'on veut afficher, on l'affiche
- if( $page >= $no_page - $nb_gauche && $page <= $no_page + $nb_droite ){
- if( $page <> $no_page ){
- $output .= sprintf( $gabarit_bouton, $page, $page, "" );
- } else {
- $output .= sprintf( $gabarit_bouton, $page, $page, " class='page_presente' disabled='disabled'" );
- }
- $add_suspension = true;
- // Sinon, on met des points de suspension
- } else {
- if( $add_suspension ) {
- // Juste une fois
- $add_suspension = false;
- $output .= sprintf( $gabarit_bouton, $no_page, "...", " disabled='disabled'" );
- }
- }
- }
-
- // Si on est moins loin que la dernière page, on affiche les flèches vers la droite
- if( $no_page < $nbPage ){
- $output .= sprintf( $gabarit_bouton, ( $no_page + 1 ), ">>", "" );
- $output .= sprintf( $gabarit_bouton, $nbPage, ">|", "" );
- }
-
- // Ajoute la classe s'il y a lieu
- if( $output <> "" && $class <> "" ){
- $output = "<span class='" . $class . "'>" . $output . "</span>";
- }
-
- return $output;
- }
-
- // Fait l'affichage de la fonction "getResultPageButton"
- function printResultPageButton( $pg, $nbPage, $nbPageMax, $class = "" ){
- echo getResultPageButton( $pg, $nbPage, $nbPageMax, $class );
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // printResultSum($pg, $pageSize, $nbRecordTotal)
- // Affiche les pages résultantes après une recherche.
- // IN: $hlink: lien vers laquelle on va pointer (résultat)
- // $pg: numéro de page actuelle (nombre)
- // $nbPage: nombre de page de résultat de recherche
- // $nbPageMax: maximum de page à afficher dans la barre de navigation
- // $querystring: querystring actuel, ça va nous permettre de l'ajouter au lien
- // $var: variable dans le querystring qu'on veux la valeur (ex: "mode")
- ///////////////////////////////////////////////////////////////////////////////////////
- function getResultSum( $pg, $pageSize, $nbRecordTotal, $str_affichage = "" ){
- if ( $str_affichage == "" ){ $str_affichage = _("resultats %s a %s sur %s"); }
- if ( !is_numeric( $pg ) ){ $pg = 1; }
- $premier_affiche = ( ( $pg - 1 ) * $pageSize + 1 );
- $dernier_affiche = min( ( $pg * $pageSize ), $nbRecordTotal );
-
- return sprintf( $str_affichage, $premier_affiche, $dernier_affiche, $nbRecordTotal );
- }
-
- function printResultSum( $pg, $pageSize, $nbRecordTotal ){
- echo getResultSum( $pg, $pageSize, $nbRecordTotal );
- }
-
- //getVersionBD
- //retourne la version actuelle de la base de données sous forme de chaine de caractères
- //OUT : Version actuelle de la BD ou false si un problème est rencontré lors de la vérification
- //NOTE : Le formulaire appelant doit, au préalable, s'être connecté à la base de données
- function getVersionBD(){
- $version = "";
- $sql = "SELECT no_version from CVS where date_version=(SELECT max(date_version) from cvs);";
- if ( $result = pg_query($sql) ){
- $version = pg_fetch_result($result,0,0);
- }else{
- $version = false;
- }
- return $version;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // getSqlStmtModifiedEnvoyerCourrier($origstmt)
- // Retourne une requête SQL comprenant seulement des usr_id unique pour envoyer
- // des courriels. Nécessaire pour éviter les duplicatas. Utilise aussi usr_nom et
- // usr_prenom pour les classer en ordre alphabétique.
- // IN: $origstmt: requête originale
- // OUT: $modstmt: requête modifiée
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtModifiedEnvoyerCourrier($origstmt){
- $modstmt="SELECT usr_id, usr_nom, usr_prenom FROM (";
- $modstmt.=$origstmt;
- $modstmt.=") AS table_env_cour GROUP BY usr_id, usr_nom, usr_prenom ORDER BY usr_nom ASC, usr_prenom ASC";
- return $modstmt;
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // function isSessionOpen()
- // retourne true si une session de fortic est en cours
- // OUT: TRUE si session en cours
- ///////////////////////////////////////////////////////////////////////////////////////
- function isSessionOpen(){
- global $_SESSION;
- if (is_numeric($_SESSION["FORTIC_nLoggedUsrID"])){
- return true;
- }
- else{
- return false;
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // sessionLogin($nUsrID, $sApplicationKey, $nSessionExpire, $sLogin, $sUsagerTypeIDList, $sSecIDList)
- // méthode appellée pour mettre à jour les variables de session lorsque l'usager se log
- // IN: $nUsrID: usr_id de l'usager loggé
- // $sApplicationKey: clé d'application de fortic (pour éviter que 2 fortic roule en même temps)
- // $sLogin: login du user loggé
- // $sNom: nom de famille du user loggé
- // $sPrenom: prénom du user loggé
- // $sUsagerTypeIDList: liste des type d'usager assigné au user
- // $sSecIDList: liste des id de sécurité assossié au type d'usager du user
- ///////////////////////////////////////////////////////////////////////////////////////
- function sessionLogin($nUsrID, $sApplicationKey, $sLogin, $sNom, $sPrenom, $sUsagerTypeIDList, $sSecIDList){
- global $_SESSION;
- $_SESSION["FORTIC_nLoggedUsrID"] = $nUsrID;
- $_SESSION["FORTIC_sApplicationKey"] = $sApplicationKey;
- $_SESSION["FORTIC_sLogin"] = $sLogin;
- $_SESSION["FORTIC_sNom"] = $sNom;
- $_SESSION["FORTIC_sPrenom"] = $sPrenom;
- $_SESSION["FORTIC_sUsagerTypeIDList"] = $sUsagerTypeIDList;
- $_SESSION["FORTIC_sSecIDList"] = $sSecIDList;
- $_SESSION["FORTIC_sCartSesIDList"] = "";
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // sessionLogout()
- // méthode appellée pour libérer les variables de session lorsque l'usager se delog
- ///////////////////////////////////////////////////////////////////////////////////////
- function sessionLogout(){
- global $_SESSION;
- unset($_SESSION["FORTIC_nLoggedUsrID"]);
- unset($_SESSION["FORTIC_sApplicationKey"]);
- unset($_SESSION["FORTIC_sLogin"]);
- unset($_SESSION["FORTIC_sNom"] );
- unset($_SESSION["FORTIC_sPrenom"]);
- unset($_SESSION["FORTIC_sUsagerTypeIDList"]);
- unset($_SESSION["FORTIC_sSecIDList"]);
- unset($_SESSION["FORTIC_sCartSesIDList"]);
- session_unset();
- session_destroy();
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqAtelierDetail( $atl_id ){
- $SQLStmt = "Select a.atl_atelier, a.atl_description, a.atl_url, a.atl_prealable, a.atl_condition, a.atl_calendrier, a.atl_fraistypique,
- a.atl_note, a.atl_commentaire, a.atl_alacartedisponible, 'NON IMPLÉMENTÉ', usager.usr_id, usager.usr_nom, usager.usr_prenom,
- usager.usr_email, usager.usr_telRejoindre, a.atl_valide, TO_CHAR(a.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') As dateUpdate,
- TO_CHAR(a.dateCreation, 'YYYY-MM-DD HH24:MI:SS') As dateCreation
- From atelier a
- Left Join usager On a.usr_id = usager.usr_id
- Where a.atl_id != '0'";
-
- if( $atl_id != 0 ){
- $SQLStmt.=" And a.atl_id = '" . $atl_id . "'";
- }
-
- return $SQLStmt;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour faire un SELECT
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqAtelierOffreService( $prj_id = 0 ){
- return "Select distinct a.atl_id, a.atl_atelier, substr( a.atl_atelier, 0, 75 ) as atl_short
- From atelier a
- Inner Join session s On s.atl_id = a.atl_id
- Inner Join projet p On p.prj_id = s.prj_id
- Inner Join seance se On s.ses_id = se.ses_id
- Where a.atl_valide = 't' And p.pt_id = '1' And p.prj_id = '" . $prj_id . "' And se.sea_datefin > Now()
- Order by atl_atelier";
- }
-
- function getSQLStmtReqAtelierOffreServiceAdminLieu( $prj_id = 0 ){
- // Pour éviter que le titre de l'atelier ne sorte de l'en-tête du catalogue, on en retourne aussi une version de 75 caractères
- return "Select distinct a.atl_id, a.atl_atelier, substr( a.atl_atelier, 0, 75 ) as atl_short
- From atelier a
- Left join projet_atelier pa On pa.atl_id = a.atl_id
- Left Join projet p On p.prj_id = pa.prj_id
- Where a.atl_valide = 't' And p.pt_id = '1' And a.atl_alacartedisponible Is True And p.prj_id = '" . $prj_id . "'
- Group By atl_atelier, a.atl_id
- Order By atl_atelier";
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne les projets
- // Ajouté par Olivier Sackhouse le 7 janvier 2008
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqProjOffreServ($prj_id = 0){
- $SQLStmt = "Select projet.prj_id, projet.prj_projet
- From projet
- Where projet.pt_id = '1' And projet.prj_valide = '1' ";
-
- if( $prj_id != 0 ){
- $SQLStmt .= "And projet.prj_id = '" . $prj_id . "' ";
- }
-
- $SQLStmt .= "Order By projet.prj_projet";
-
- return $SQLStmt;
- }
-
-
- function getSQLStmtReqSessionsOffreServices( $mot, $motlnk, $prj_id, $atl_id, $cla_id, $exp_id, $cli_id, $ses_annule,
- $nbjourstart, $datelimiteOK, $nbinsOK, $valide, $arrFicheId, $indx ){
- $SQLStmt = "Select ses.ses_id, pro.prj_id, prj_projet, pro.prj_valide, ate.atl_id,
- ate.atl_atelier, ate.atl_valide, ses_code, ses_notemini, ses_datelimite, ses_nbMin,
- ses_nbMax, ses_regionnal, ses_annule, ses_annuleraison, ses_valide, COUNT( sea.sea_id ) As nbSeance,
- get_nbInscriptionSession( ses.ses_id ) As nbInscription, TO_CHAR( MIN( sea_dateDebut ), 'YYYY-MM-DD HH24:MI:SS' ) As dSeaDebMin,
- TO_CHAR( MAX( sea_dateDebut ), 'YYYY-MM-DD HH24:MI:SS' ) As dSeaDebMax, get_nbInscriptionSessionAValider( ses.ses_id ),
- ses_coutParUsager, ses_commentaire, 'NON IMPLÉMENTÉ', 'NON IMPLÉMENTÉ', get_nbInscriptionSession( ses.ses_id ) As nbInscription
- From session ses
- Left Join seance sea On ses.ses_id = sea.ses_id
- Left Join projet pro On ses.prj_id = pro.prj_id
- Left Join projetType prt On pro.pt_id = prt.pt_id
- Left Join atelier ate On ses.atl_id = ate.atl_id";
-
- $where = "";
-
- // La recherche peut être faite pour chaque mot ou pour le groupe au complet
- if( $motlnk != "and" && $motlnk != "or" ){
- $motlnk = "and"; //valeur par defaut : securite
- }
-
- // Créé une table des mots recherchés
- $arrMot = getArrayFromStringMot( $mot );
- $nb_mots = count( $arrMot );
- if( $nb_mots > 0 ){
- $where .= " ( ";
- for( $i = 0; $i < $nb_mots; $i++ ){
- // Vérifie si le mot est dans la colonne 'ATL_ATELIER'
- $where .= accentInsensitiveLike( "atl_atelier", $arrMot[ $i ] );
- // Ou, vérifie si le mot est dans la colonne 'ATL_DESCRIPTION'
- $where .= " OR " . accentInsensitiveLike( "atl_description", $arrMot[ $i ] );
- // Ou, vérifie si le mot est dans la colonne 'SES_CODE'
- $where .= " OR " . accentInsensitiveLike( "ses_code", $arrMot[ $i ] );
-
- // Ajoute le bon mot selon la requête de l'usager
- if( $i < ( $nb_mots - 1 ) ){
- $where .= ") " . $motlnk . " ("; //OR ou AND
- }
- }
- $where .= " ) ";
- }
-
- if( is_numeric( $prj_id ) ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= " ses.prj_id = '" . $prj_id . "'";
- }
-
- if( is_numeric( $atl_id ) ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= " ses.atl_id = '" . $atl_id . "'";
- }
-
- if( is_numeric( $cla_id ) ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= " ses.atl_id In ( Select atl_id From atelier_classe Where cla_id = '".$cla_id . "' )";
- }
-
- if( is_numeric( $exp_id ) ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= " ses.atl_id In ( Select atl_id From atelier_expertise Where exp_id = '".$exp_id . "' )";
- }
-
- if( is_numeric( $cli_id ) ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= " ses.atl_id In ( Select atl_id From atelier_clientele Where cli_id = '".$cli_id . "' )";
- }
-
- if( $ses_annule != "" ){
- if( $where != "" ){
- $where .= " AND ";
- }
- if( to_lower( $ses_annule ) == "t" ){
- $where.=" ses_annule = 't'";
- } else {
- $where.=" ses_annule = 'f'";
- }
- }
-
- if( $datelimiteOK != "" ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= " sea.ses_id = ses.ses_id And (sea.sea_datefin > Now() OR sea.sea_datefin is null)";
- }
-
- if( $valide != "" ){
- if( $where != "" ){
- $where .= " AND ";
- }
- if( to_lower( $valide ) == "t" ){
- $where.=" prj_valide = 't' And atl_valide = 't' And ses_valide = 't'";
- } else {
- $where.=" prj_valide = 'f' And atl_valide = 'f' And ses_valide = 'f'";
- }
- }
-
- if( count( $arrFicheId ) > 0 ){
- if( $where != "" ){
- $where .= " AND ";
- }
- $where .= " ( ses.ses_id <> ses.ses_id";
- for( $i=0; $i < count( $arrFicheId ); $i++ ){
- if( is_numeric( $arrFicheId[ $i ] ) ){
- $where .= " Or ses.ses_id = '" . $arrFicheId[ $i ] . "'";
- }
- }
- $where .= " )";
- }
-
- if( $where != "" ){
- $where = " WHERE " . $where;
- }
- $SQLStmt .= $where . " GROUP BY ses.ses_id, pro.prj_id, pro.prj_projet, pro.prj_valide, ate.atl_id, ate.atl_atelier,
- ate.atl_valide, ses_code, ses_notemini, ses_datelimite, ses_nbmin, ses_nbmax, ses_regionnal, ses_annule, ses_annuleraison,
- ses_valide, ses_coutParUsager, ses_commentaire";
-
- if( is_numeric( $nbjourstart ) || $nbinsOK != "" ){
- $SQLStmt .= " Having true"; // Malheureusement, cette clause ne change rien mais elle rend les prochaines lignes plus facile à bâtire
- if( is_numeric( $nbjourstart ) ){
- $SQLStmt .= " And prochaineseance( ses.ses_id ) BETWEEN CURRENT_DATE And CURRENT_DATE + '" . $nbjourstart . "'";
- }
- if ( $nbinsOK != "" ){
- if( strtolwer( $nbinsOK ) == "t" ){
- $SQLStmt .= " And get_nbInscriptionSession( ses.ses_id ) < ses_nbMax";
- } else {
- $SQLStmt .= " And get_nbInscriptionSession( ses.ses_id ) >= ses_nbMax";
- }
- }
- }
-
- // Cast $INDX en string car comparer 0 avec une string retourne toujours vrai
- switch( ( string ) $indx ){
- case "sessiona" :
- $SQLStmt .= " ORDER BY ses_code ASC";
- break;
- case "sessiond" :
- $SQLStmt .= " ORDER BY ses_code DESC";
- break;
- case "descriptiona" :
- $SQLStmt .= " ORDER BY atl_atelier ASC";
- break;
- case "descriptiond" :
- $SQLStmt .= " ORDER BY atl_atelier DESC";
- break;
- case "dateseaa" :
- $SQLStmt .= " ORDER BY dSeaDebMin ASC";
- break;
- case "datesead" :
- $SQLStmt .= " ORDER BY dSeaDebMin DESC";
- break;
- case "datelima" :
- $SQLStmt .= " ORDER BY ses_datelimite ASC";
- break;
- case "datelimd" :
- $SQLStmt .= " ORDER BY ses_datelimite DESC";
- break;
- case "nbinscriptiona" :
- $SQLStmt .= " ORDER BY nbInscription ASC";
- break;
- case "nbinscriptiond" :
- $SQLStmt .= " ORDER BY nbInscription DESC";
- break;
- case "couta" :
- $SQLStmt .= " ORDER BY ses_coutParUsager ASC";
- break;
- case "coutd" :
- $SQLStmt .= " ORDER BY ses_coutParUsager DESC";
- break;
- default :
- break;
- }
-
- return $SQLStmt;
- }
-
- function getSQLStmtReqProjOffreServFull(){
- return "Select distinct p.prj_id, p.prj_projet, a.atl_id, a.atl_atelier, a.datecreation
- From atelier a
- Inner Join session s On s.atl_id = a.atl_id
- Inner join projet_atelier pa On pa.atl_id = a.atl_id
- Inner Join projet p On p.prj_id = pa.prj_id
- Inner Join seance se On s.ses_id = se.ses_id
- Where a.atl_valide And s.ses_annule Is False And s.ses_valide Is True And p.pt_id = 1 And ((se.sea_datefin > Now()
- And se.sea_datedebut > Now()) or (se.sea_datefin is null And se.sea_datedebut is null)) And se.sea_valide Is True
- AND (p.prj_dateFin >= CURRENT_DATE OR p.prj_dateFin IS NULL) AND p.prj_valide='t'
- Group By p.prj_id, p.prj_projet, a.atl_atelier, a.atl_id, a.datecreation
- Order By p.prj_projet, a.atl_atelier";
- }
-
- function getSQLStmtReqProjOffreServAdminLieu(){
- return "Select distinct p.prj_id, p.prj_projet, a.atl_id, a.atl_atelier, a.datecreation
- From atelier a
- Inner join projet_atelier pa On pa.atl_id = a.atl_id
- Inner Join projet p On p.prj_id = pa.prj_id
- Where a.atl_valide And p.pt_id = 1 And a.atl_alacartedisponible Is True
- Group By p.prj_id, p.prj_projet, a.atl_atelier, a.atl_id, a.datecreation
- Order By p.prj_projet, a.atl_atelier";
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////
- // Retourne la requete SQL necessaire pour les offre de services
- // Ajouté par Olivier Sackhouse le 7 janvier 2008
- ///////////////////////////////////////////////////////////////////////////////////////
- function getSQLStmtReqOffreServByProjId($proj_id){
- $SQLStmt = "";
-
- if( is_numeric( $proj_id ) && $proj_id != 0 ){
- $SQLStmt = "Select ses_code, atl.atl_atelier, sum( sea_duree ), ses.ses_coutparusager
- From session As ses
- Inner Join atelier atl On ses.atl_id = atl.atl_id
- Inner Join seance sea On sea.ses_id = ses.ses_id
- Where ses_datelimite < now() And ses.prj_id = '" . $proj_id . "'
- Group by ses_code, atl.atl_atelier, ses.ses_coutparusager";
- }
-
- return $SQLStmt;
- }
-
- /**
- * Ajoute la fonction array_intersect_key si elle n'existe pas deja (PHP < 5.1)
- *
- * @param $isec Le tableau contenant les clés maîtres à vérifier.
- * @param $keys Un tableau contenant les clés à comparer.
- * @param ... Un tableau contenant les clés à comparer.
- * @return Tableau contenant toutes les entrées du tableau $isec qui ont des clés présentes dans tous les arguments.
- * @author Rod Byrnes -> http://www.php.net/manual/fr/function.array-intersect-key.php#74956
- */
- if( !function_exists( 'array_intersect_key' ) ) {
- function array_intersect_key( $isec, $keys ){
- $argc = func_num_args();
- if( $argc > 2 ) {
- for( $i = 1; !empty( $isec ) && $i < $argc; $i++ ) {
- $arr = func_get_arg($i);
- foreach( array_keys( $isec ) as $key ) {
- if( !isset( $arr[ $key ] ) ) {
- unset( $isec[ $key ] );
- }
- }
- }
- return $isec;
- } else {
- $res = array();
- foreach( array_keys( $isec ) as $key ){
- if( isset( $keys[$key] ) ){
- $res[$key] = $isec[$key];
- }
- }
- return $res;
- }
- }
- }
-
- function tranlateUsagerTypes( &$arrIDTypes, &$arrNomTypes ){
- //Mettre les bons noms de type d'usager dans l'array $arrNomTypes
- //(Requis pour permettre que les noms des types d'usagers puissent être affichés dans plus d'une langue
- for( $index = 0; $index < count( $arrIDTypes ); $index++ ){
- switch ( $arrIDTypes[$index] ){
- case 1:
- $arrNomTypes[ $index ] = _( "Usager" );
- break;
- case 2:
- $arrNomTypes[ $index ] = _( "Technicien" );
- break;
- case 3:
- $arrNomTypes[ $index ] = _( "Animateur(trice)" );
- break;
- case 4:
- $arrNomTypes[ $index ] = _( "Administrateur(trice) - Lieu" );
- break;
- case 6:
- $arrNomTypes[ $index ] = _( "Administrateur(trice) - General" );
- break;
- case 7:
- $arrNomTypes[ $index ] = _( "Superadministrateur(trice)" );
- break;
- case 8:
- $arrNomTypes[ $index ] = _( "Administrateur(trice) - Projet" );
- break;
- }
- }
- }
-
- //Retourne true si les fichiers gettext (.mo) correspondant à la string Locale reçue en paramêtre sont disponibles
- function isSupportedLocale( $locale ){
- return array_key_exists( $locale, getHandledLocalesList() );
- }
-
- function getHandledLocalesList(){
- //Trouver le bon chemin ( relatif ) qui permet d'accéder à la ressource gettext
- global $cfgMODir;
- $prefix = "./";
- $itt = 5;
- while( !file_exists($prefix.$cfgMODir) && $itt > 0 ){
- $itt--;
- $prefix .= "../";
- }
-
- //Identifier toutes les chaînes locales supportées par fortic ( c-a-d les noms de tous les dossiers dans le répertoire gettext )
- $localeStrings = array( );
- $locale = getLocalesList();
- $dirPath = $prefix.$cfgMODir;
- if ($handle = opendir($dirPath)) {
- //Lire tous les éléments contenus dans le répertoire
- while (false !== ($file = readdir($handle))) {
- //Ne pas traiter la référence au dossier actuel, celle au dossier parent et celle vers le dossier svn
- if ($file != "." && $file != ".." && $file != ".svn" ) {
- //Vérification que ce que l'on regarde est un dossier et porte un nom qui est reconnu comme une chaine locale.
- if (is_dir("$dirPath/$file") && array_key_exists( $file, $locale ) ) {
- $localeStrings[ $file ] = $locale[ $file ];
- }
- }
- }
- closedir($handle);
- }
- return $localeStrings;
- }
-
- function getLocalesList(){
- $locales = array();
- $locales[ "in" ] = "Bahasa Indonesia";
- $locales[ "in_ID" ] = "Bahasa Indonesia (Indonesia)";
- $locales[ "ms" ] = "Bahasa Melayu";
- $locales[ "ms_MY" ] = "Bahasa Melayu (Malaysia)";
- $locales[ "ca" ] = "Català";
- $locales[ "ca_ES" ] = "Català (Espanya)";
- $locales[ "da" ] = "Dansk";
- $locales[ "da_DK" ] = "Dansk (Danmark)";
- $locales[ "de" ] = "Deutsch";
- $locales[ "de_DE" ] = "Deutsch (Deutschland)";
- $locales[ "de_LU" ] = "Deutsch (Luxemburg)";
- $locales[ "de_AT" ] = "Deutsch (Österreich)";
- $locales[ "de_CH" ] = "Deutsch (Schweiz)";
- $locales[ "et" ] = "Eesti";
- $locales[ "et_EE" ] = "Eesti (Eesti)";
- $locales[ "en" ] = "English";
- $locales[ "en_AU" ] = "English (Australia)";
- $locales[ "en_CA" ] = "English (Canada)";
- $locales[ "en_IN" ] = "English (India)";
- $locales[ "en_IE" ] = "English (Ireland)";
- $locales[ "en_MT" ] = "English (Malta)";
- $locales[ "en_NZ" ] = "English (New Zealand)";
- $locales[ "en_PH" ] = "English (Philippines)";
- $locales[ "en_SG" ] = "English (Singapore)";
- $locales[ "en_ZA" ] = "English (South Africa)";
- $locales[ "en_GB" ] = "English (United Kingdom)";
- $locales[ "en_US" ] = "English (United States)";
- $locales[ "es" ] = "Español";
- $locales[ "es_AR" ] = "Español (Argentina)";
- $locales[ "es_BO" ] = "Español (Bolivia)";
- $locales[ "es_CL" ] = "Español (Chile)";
- $locales[ "es_CO" ] = "Español (Colombia)";
- $locales[ "es_CR" ] = "Español (Costa Rica)";
- $locales[ "es_EC" ] = "Español (Ecuador)";
- $locales[ "es_SV" ] = "Español (El Salvador)";
- $locales[ "es_ES" ] = "Español (España)";
- $locales[ "es_US" ] = "Español (Estados Unidos)";
- $locales[ "es_HN" ] = "Español (Honduras)";
- $locales[ "es_MX" ] = "Español (México)";
- $locales[ "es_NI" ] = "Español (Nicaragua)";
- $locales[ "es_PY" ] = "Español (Paraguay)";
- $locales[ "es_PE" ] = "Español (Perú)";
- $locales[ "es_PR" ] = "Español (Puerto Rico)";
- $locales[ "es_DO" ] = "Español (República Dominicana)";
- $locales[ "es_UY" ] = "Español (Uruguay)";
- $locales[ "es_VE" ] = "Español (Venezuela)";
- $locales[ "fr" ] = "Français";
- $locales[ "fr_BE" ] = "Français (Belgique)";
- $locales[ "fr_CA" ] = "Français (Canada)";
- $locales[ "fr_FR" ] = "Français (France)";
- $locales[ "fr_LU" ] = "Français (Luxembourg)";
- $locales[ "fr_CH" ] = "Français (Suisse)";
- $locales[ "ga" ] = "Gaeilge";
- $locales[ "ga_IE" ] = "Gaeilge (Éire)";
- $locales[ "hr" ] = "Hrvatski";
- $locales[ "hr_HR" ] = "Hrvatski (Hrvatska)";
- $locales[ "is" ] = "Íslenska";
- $locales[ "is_IS" ] = "Íslenska (Ísland)";
- $locales[ "it" ] = "Italiano";
- $locales[ "it_IT" ] = "Italiano (Italia)";
- $locales[ "it_CH" ] = "Italiano (Svizzera)";
- $locales[ "lv" ] = "Latviešu";
- $locales[ "lv_LV" ] = "Latviešu (Latvija)";
- $locales[ "hu" ] = "Magyar";
- $locales[ "hu_HU" ] = "Magyar (Magyarország)";
- $locales[ "mt" ] = "Malti";
- $locales[ "mt_MT" ] = "Malti (Malta)";
- $locales[ "nl" ] = "Nederlands";
- $locales[ "nl_BE" ] = "Nederlands (België)";
- $locales[ "nl_NL" ] = "Nederlands (Nederland)";
- $locales[ "no" ] = "Norsk";
- $locales[ "no_NO" ] = "Norsk (Norge)";
- $locales[ "pl" ] = "Polski";
- $locales[ "pl_PL" ] = "Polski (Polska)";
- $locales[ "pt" ] = "Português";
- $locales[ "pt_PT" ] = "Português (Portugal)";
- $locales[ "pt_BR" ] = "Português (Brasil)";
- $locales[ "tr" ] = "Türkçe";
- $locales[ "tr_TR" ] = "Türkçe (Türkiye)";
- $locales[ "sq_AL" ] = "Shqipe (Shqipëria)";
- $locales[ "fi" ] = "Suomi";
- $locales[ "fi_FI" ] = "Suomi (Suomi)";
- $locales[ "sv" ] = "Svenska";
- $locales[ "sv_SE" ] = "Svenska (Sverige)";
- return $locales;
- }
-
- /*************************************************************************
- * Titre : Fonctions de test
- * Description : Une séries de fonctions pour tester les différents protocoles et la configuration du server PHP
- * Auteur : Richard Rail
- *************************************************************************/
-
- /*
- * lister_config_php($droit_ecriture = true, $variables = true, $extension = true) crée une liste
- * des configurations du serveur PHP necessaire à Fortic sous le format d'un tableau clef => valeur
- * dont la clef est le nom de la configuration et la valeur est un boolean expriment si la configuration
- * est adéquate pour le serveur PHP.
- *
- * @param $droit_ecriture - inclure les droits en écriture dans la liste
- * @param $variables - inclure les variables dans la liste
- * @param $extension - inclure les extensions dans la liste
- *
- * @return Array - un tableau clef=>valeur des configuration=>valide
- */
- function lister_config_php($droit_ecriture = true, $variables = true, $extension = true){
- $config = array();
- if($variables){
- $config['phpversion'] = (substr(phpversion(),0,1) >= 5);
-
- $config['short_open_tag'] = ini_get('short_open_tag') == true;
- $config['register_argc_argv'] = ini_get('register_argc_argv') == true;
- $config['magic_quotes_gpc'] = ini_get('magic_quotes_gpc') == false;
- $config['allow_call_time_pass_reference'] = ini_get('allow_call_time_pass_reference') == true;
- }
- if($extension){
- $extensions = get_loaded_extensions();
- $config['php_gettext'] = in_array( 'gettext', $extensions );
- $config['php_pgsql'] = in_array( 'pgsql', $extensions );
- $config['php_ldap'] = in_array( 'ldap', $extensions );
- }
- if($droit_ecriture){
- $config['ecriture_config'] = is_writable( rechercher_fichier('config') );
- $config['ecriture_config_file'] = is_writable( rechercher_fichier('config/config.php') );
- $config['ecriture_mise_a_jour'] = is_writable( rechercher_fichier('lib/bd_scripts') );
- $config['ecriture_log'] = is_writable( rechercher_fichier('log') );
- $config['ecriture_pdf'] = is_writable( rechercher_fichier('pdf') );
- }
- return $config;
- }
-
- /*
- * tester_connexion_postgresql($connection_string) teste la connexion au serveur postgresql et retourne
- * un message d'erreur approprié selon le cas.
- *
- * @param $connection_string - la string de connexion
- *
- * @return Array - retourne un tableau d'erreur
- */
- $resultat_erreur;
- function tester_connexion_postgresql($connection_string){
- /* Avant de pleurer, je tien à dire que j'ai fais de longues recherche et en PHP 5, il n'y a pas de moyen avec Pg_connect
- * d'avoir un numérau d'érreur, donc la seule façon de donnée un resultat de test, c'est faire sois-même le reportage
- * d'érreur et de passée des expressions régulaire pour voir si le message semble a celui d'un erreur X.
- */
- $error_reporting_old = error_reporting();
- error_reporting(E_WARNING);
- set_error_handler("error_handler_conn_postgresql");
-
- $conn = pg_connect($connection_string);
-
- restore_error_handler();
- error_reporting($error_reporting_old);
- if($conn){
- return array('succes' => 'succes');
- } else { //S'il y a un erreur la function error_handler_conn_postgresql va avoir mis l'erreur dans resultat_erreur
- return $GLOBALS['resultat_erreur'];
- }
- }
- /*
- * error_handler_conn_postgresql remplace le 'error handler' par default pour la fonction tester_connexion_postgresql
- */
- function error_handler_conn_postgresql($errorNumber, $errorMessage, $errorFile, $errorLine, $vars){
- global $resultat_erreur;
- $resultat_erreur = array();
- $pre = '/Unable to connect to PostgreSQL server: ';
- if( preg_match($pre.'.*database.*does not exist/',$errorMessage)){
- $resultat_erreur['database'] = 'La base de donnée n\a pas été trouvé.';
- } else if( preg_match($pre.'.*password authentication failed for user.*/',$errorMessage)){
- $resultat_erreur['authentification'] = 'L\'authentification est invalide.';
- } else if( preg_match($pre.'.*Connection refused.*/',$errorMessage)){
- $resultat_erreur['connexion'] = 'Le serveur est non accesible ou le port n\'est pas en ecoute ou est bloqué.';
- } else if( preg_match($pre.'.*Unknown host.*/',$errorMessage)){
- $resultat_erreur['connexion'] = 'Nom de l\'hôte est inconnue';
- } else {
- $resultat_erreur['erreur'] = $errorMessage;
- }
- }
-
- /*
- * tester_serveur_SMTP($serveur) teste la connexion au serveur SMTP et retourne
- * un message d'erreur approprié selon le cas.
- *
- * @param $connection_string - la string de connexion
- *
- * @return Array - retourne un tableau d'erreur
- */
- function tester_serveur_SMTP($serveur){
- require_once("../lib/php/phpmailer/class.phpmailer.php");
- $mail = new PHPMailer();
- $mail->SetLanguage("fr","../lib/php/phpmailer/");
- $mail->IsSMTP();
- $mail->Host = $serveur;
- $mail->From = "noreply@noreply.com";
- $mail->AddAddress("noreply@noreply.com");
- $mail->FromName = "Test";
- $mail->Subject = 'Test';
- $mail->Body = 'Test';
- $mail->SMTPAuth = false;
- if($mail->Send()) {
- return array("succes" => 'Le serveur est accessible');
- } else {
- return array("erreur" => 'Le serveur n\'est pas accessible');
- }
- }
-
- /*
- * tester_ldap($serveur, $port, $bind_rdn, $bind_password, $base_dn, $filtre, $infos)
- * teste la connexion au serveur LDAP et retourne un message d'erreur approprié selon le cas.
- *
- * @param $serveur - string du serveur à se connecter
- * @param $port - string du port
- * @param $bind_rdn - string du rdn
- * @param $bind_password - string du mot de passe
- * @param $base_dn - string du dn
- * @param $filtre - string du filtre ldap
- * @param $infos - array d'informations a tester dans ldap
- *
- * @return Array - retourne un tableau d'erreur
- */
- function tester_ldap($serveur, $port, $bind_rdn, $bind_password, $base_dn, $filtre, $infos){
- $resultat = null;
- //S'il n'y a pas de filtre on va tenter de s'en faire un pour pas que sa plante
- if($filtre == ''){
- $filtre = explode(',',$bind_rdn);
- $filtre = '('.$filtre[0].')';
- }
-
- $error_reporting_old = error_reporting();
- error_reporting(0);
- $conLDAP = ldap_connect( $serveur, $port );
- //Si options LDAP on les appliquent
- if ( count($ldap_var["ldap_options"]) > 0) {
- OptionConnexion_LDAP($conLDAP);
- }
- if(ldap_errno($conLDAP) == 0){
- ldap_bind($conLDAP, $bind_rdn, $bind_password)
- && ( $arrayRecherche = ldap_search($conLDAP, $base_dn, $filtre) )
- && ( $ldap_info = ldap_get_entries($conLDAP, $arrayRecherche) );
- }
-
- if(ldap_errno($conLDAP) != 0){
- switch(ldap_errno($conLDAP)){
- case 81: //Can't contact LDAP server
- $resultat = array('connexion'=>'Erreur de connection au serveur LDAP');
- break;
- case 49: //Invalid credentials
- $resultat = array('credentials'=>'Erreur de connection au serveur LDAP');
- break;
- case 87: //Bad search filter
- $resultat = array('filtre'=>'Filtre invalide');
- break;
- case 32: //No such object
- $resultat = array('base_dn'=>'La base de recherche est invalide');
- break;
- default:
- $resultat = array('erreur'=>'Erreur inconnue #'.ldap_errno($conLDAP) . ' : ' . ldap_error($conLDAP) . ' |'.$bind_password.'|');
- break;
- }//switch
- } else {
- $resultat = array();
-
- // Tentative de rendre l'application compatible avec OpenLDAP
- if( $ldap_info[ 'count' ] == 1 ){
- $ldap_info = $ldap_info[ 0 ];
- }
- foreach( $infos as $info ){
- if( !in_array($info, $ldap_info) ){
- $resultat["$info"] = $info. ' n\'est pas une information valide';
- }
- }
- }
-
- if(is_array($resultat) && count($resultat) == 0) $resultat = array('succes' => 'succes');
- ldap_close( $conLDAP );
- error_reporting($error_reporting_old);
- return $resultat;
- }
-
- /*
- * rechercher_fichier($fichier) cherche le fichier $fichier en reculant de plus en plus dans l'arborescence
- * et arrête à la racine du serveur PHP
- *
- * @param $fichier - fichier à trouvé (peut être un dossier)
- *
- * @return string - chemin jusqu'au dossier ( ../../../fichier ) ou FALSE s'il ne le trouve pas
- */
- function rechercher_fichier($fichier){
- $env = getenv("SCRIPT_NAME");
- //on compte le nombre de dossier entre le script et la racine du serveur
- $nb_bon_max = count( explode('/',$env) ) - 1;
-
- while( $nb_bon_max-- >0 ){
- if( file_exists($fichier) ) return $fichier;
- $fichier = '../' . $fichier;
- }
- return false;
- }
-
- }// fin du define PHP_LIBRARY_FORTICFUNCTIONS
- ?>