PageRenderTime 54ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/fortic-php/lib/php/forticFunctions.php

https://bitbucket.org/forticpdm/fortic
PHP | 6741 lines | 4955 code | 426 blank | 1360 comment | 1013 complexity | 6a6b0c1e47c92f4016271135e094691a MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
  1. <?php
  2. if(!defined("PHP_LIBRARY_FORTICFUNCTIONS")){define("PHP_LIBRARY_FORTICFUNCTIONS",1);
  3. ///////////////////////////////////////////////////////////////////////////////////////
  4. // nom: forticFunctions.php
  5. // auteur: Youri Reddy-Girard
  6. // Modifs: Daniel C�dilotte -- changeUTF16
  7. // date: 20/10/2002
  8. // desc: Librairie de fonctions de FORtIC
  9. //
  10. // modifi�: Sylvie Caron Ajout du type de lieu - r�f: demande #31 (am�liorations 2005-2006)
  11. // modifi�: R. Franche : mettre "0 dans lt_id dans la fonction addUpdateLieu
  12. // modifi�: Sylvie Caron Ajout du lieu dans la liste des animateurs - r�f: demande #37 (am�liorations 2006-2007)
  13. // Fonctions ajout�es: formatNameLieu
  14. // Fonctions modifi�es: getSQLStmtReqLieuAdminlieu, getSQLStmtReqSessionAnimateur
  15. // 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
  16. // Fonctions ajout�es: formatSessionCode et formatSessionDescription
  17. //
  18. // $Id: forticFunctions.php,v 1.140 2008/07/03 18:29:46 stacil Exp $
  19. // $Id: forticFunctions.php,v 1.140 2008/07/03 18:29:46 stacil Exp $
  20. // 2007/08/22 R. Franche : correction fonction getSQLStmtInsLieuAdmin, il manquait le return
  21. // 2008/03/25 R. Franche : lors du login : chercher lieu d'apr�s son num�ro OU sa description
  22. // pour �viter la cr�ation de lieu en double
  23. // 2008/04/25 R. Franche : correction fonction getSQLStmtReqLieuFromNoOuDescr : ajout addslash pour nom de lieu avec quote
  24. ///////////////////////////////////////////////////////////////////////////////////////
  25. ///////////////////////////////////////////////////////////////////////////////////////
  26. // ajoutUsagerLDAP($sArrayLDAP, $sUsrLDAPCode)
  27. // Ajoute l'usager dans Fortic en provenance de LDAP
  28. // IN: $conn: objet de connexion avec la db (doit �tre d�j� ouvert)
  29. // $sArrayLDAP: tableau des informations de LDAP
  30. // $sUsrLDAPCode: code de l'usager LDAP
  31. // &$nUsrID: retour de l'ID de l'usager Fortic
  32. // OUT: aucun
  33. ///////////////////////////////////////////////////////////////////////////////////////
  34. function ajouterUsagerLDAP($conn, $sArrayLDAP, $sUsrLDAPCode, &$nUsrID)
  35. {
  36. // importation des donn�es (LDAP -> USAGER)
  37. // on ouvre la transaction
  38. $result = pg_query($conn, "BEGIN;");
  39. if (!$result){ bugFromPG($conn); }
  40. //Traitement du lieu LDAP vs Fortic
  41. addUpdateLieu($conn, $sArrayLDAP[3], $sArrayLDAP[4], &$nLieuID);
  42. //insertion de la fiche du nouvel usager
  43. $result = pg_query($conn, getSQLStmtInsUsager($sUsrLDAPCode, changeUTF16($sArrayLDAP[0]),
  44. changeUTF16($sArrayLDAP[1]), $nLieuID));
  45. if (!$result){ bugFromPG($conn); }
  46. //retrouver la fiche qu'on vient de cr�er
  47. $bFicheFound=fillVarFromDBStd($conn, getSQLStmtReqUsagerLAST(), &$nUsrID);
  48. //update de la fiche
  49. $result = pg_query($conn, getSQLStmtUpdUsagerLDAP($nUsrID, changeUTF16($sArrayLDAP[0]),
  50. changeUTF16($sArrayLDAP[1]),$sArrayLDAP[2], $sArrayLDAP[5],
  51. changeUTF16($sArrayLDAP[6]), "t", $nLieuID, "t"));
  52. if (!$result){ bugFromPG($conn); }
  53. // insertion du type d'usager
  54. $result = pg_query($conn, getSQLStmtInsUsagerUsrType($nUsrID, 1));
  55. if (!$result){ bugFromPG($conn); }
  56. // on ferme la transaction
  57. $result = pg_query($conn, "COMMIT;");
  58. if (!$result){ bugFromPG($conn); }
  59. }
  60. ///////////////////////////////////////////////////////////////////////////////////////
  61. // addUpdateLieu($conn, , $nolieuLDAP, $lieuDesc, &$nLieuID)
  62. // Ajoute ou met � jour un lieu en provenance de d'un usager LDAP
  63. // IN: $conn: objet de connexion avec la db (doit �tre d�j� ouvert)
  64. // $nolieuLDAP : num�ro du lieu en provenance de LDAP */
  65. // $lieuDesc : Description du lieu
  66. // $nLieuID : num�ro du lieu dans la bd Fortic
  67. // OUT: aucun
  68. ///////////////////////////////////////////////////////////////////////////////////////
  69. function addUpdateLieu($conn, $nolieuLDAP, $lieuDesc, &$nLieuID){
  70. // Aller chercher dans Fortic le lieu de l'usager LDAP
  71. // 2008/03 : chercher le lieu d'apr�s non num�ro OU sa description pour �viter le cr�ation de doubles
  72. $bFicheFound=fillVarFromDBStd($conn, getSQLStmtReqLieuFromNoOuDescr($nolieuLDAP, $lieuDesc),
  73. &$Li_id, &$Li_lieu, &$Li_no, &$Li_adresse,
  74. &$Li_trajet, &$Li_trajetURL, &$Li_telephone,
  75. &$Li_valide, &$Li_dateUpdate, &$Li_dateCreation);
  76. // Si on ne trouve pas le lieu, on le cr�e
  77. if($bFicheFound != true) {
  78. // Si la description du lieu est vide, on met Lieu avec son num�ro
  79. if(isset($lieuDesc) == false || $lieuDesc == "") {
  80. $lieuDesc = "Lieu_".$nolieuLDAP;
  81. }
  82. // Insertion minimum
  83. $result = pg_query($conn, getSQLStmtInsLieu($lieuDesc));
  84. if (!$result){ bugFromPG($conn); }
  85. // Aller chercher la cl�e de la nouvelle entr�e
  86. $bFicheFound=fillVarFromDBStd($conn, getSQLStmtReqLieuLAST(), &$nLieuID);
  87. // Compl�ter les informations du lieu
  88. $result = pg_query($conn, getSQLStmtUpdLieu($nLieuID, $lieuDesc,
  89. $nolieuLDAP, "", "", "", "",
  90. "t","t","0"));
  91. if (!$result){ bugFromPG($conn); }
  92. } else {
  93. // Affecter l'ID du lieu � la variable
  94. $nLieuID = $Li_id;
  95. }
  96. }
  97. ///////////////////////////////////////////////////////////////////////////////////////
  98. // addUpdateUsagerFromLDAP($conn, $codeUsager)
  99. // Ajoute ou met � jour l'usager dans Fortic en provenance de LDAP
  100. // IN: $conn: objet de connexion avec la db (doit �tre d�j� ouvert)
  101. // $codeUsager : code de l'usager � ajouter
  102. // OUT: aucun
  103. ///////////////////////////////////////////////////////////////////////////////////////
  104. function addUpdateUsagerFromLDAP($conn, $codeUsager)
  105. {
  106. global $ldap_var;
  107. // Connexion au serveur LDAP
  108. $conLDAP = ldap_connect($ldap_var[db][host], $ldap_var[db][port]);
  109. if(!$conLDAP) { //Connexion au serveur LDAP non-r�ussi, on quitteM
  110. bugFromLDAP($conLDAP);
  111. } else {
  112. //Si options LDAP on les appliquent
  113. if ( count($ldap_var["ldap_options"]) > 0) {
  114. OptionConnexion_LDAP($conLDAP);
  115. }
  116. }
  117. // Filtre pour rechercher seulement le code d'usager
  118. $filtre ="(&(".$ldap_var[db][searchKey]."=".$codeUsager.")".$filtre.$ldap_var[db][filter].")";
  119. //Recherche l'info complete de l'usager dans la base ldap
  120. $codeRetour = Recherche_LDAP($conLDAP,$filtre, &$sArrayRechLdap);
  121. //V�rifie le code de retour pour savoir si l'usager existe dans l'annuaire
  122. if ($codeRetour >= 0) {
  123. $sArrayLDAP = array(trim($sArrayRechLdap[0][0]), // Nom
  124. trim($sArrayRechLdap[0][1]), //Pr�nom
  125. trim($sArrayRechLdap[0][2]), //Email
  126. trim($sArrayRechLdap[0][3]), //lieuID
  127. trim($sArrayRechLdap[0][4]), //lieuDescr
  128. trim($sArrayRechLdap[0][5]), //T�l�phone
  129. trim($sArrayRechLdap[0][6])); //Fonction
  130. //v�rifie si l'usager existe d�j� dans la base Fortic sinon on l'ajoute
  131. $bUserFound=fillVarFromDBStd($conn, getSQLStmtReqUsagerFromLogin($codeUsager),
  132. &$nUsrID, &$sLDAP);
  133. if ($bUserFound){ // l'usager existe d�j� dans FORTIC, met � jour
  134. //Traitement du lieu LDAP vs Fortic
  135. addUpdateLieu($conn, $sArrayLDAP[3], $sArrayLDAP[4], &$nLieuID);
  136. // Mise � jour de l'usager
  137. $result = pg_query($conn, getSQLStmtUpdUsagerLDAP($nUsrID,
  138. changeUTF16($sArrayLDAP[0]),
  139. changeUTF16($sArrayLDAP[1]),
  140. $sArrayLDAP[2], $sArrayLDAP[5],
  141. changeUTF16($sArrayLDAP[6]), "t",
  142. $nLieuID, "t"));
  143. } else { //Nouvel usager on l'ajoute
  144. ajouterUsagerLDAP($conn, $sArrayLDAP, $codeUsager, &$nUsrID);
  145. }
  146. }
  147. }
  148. ///////////////////////////////////////////////////////////////////////////////////////
  149. // bugFromLdap($conn)
  150. // m�thode appell�e losrqu'on a un probl�me avec l'ex�cution d'une requ�te ou � �tablir
  151. // la connexion avec le serveur LDAP.
  152. ///////////////////////////////////////////////////////////////////////////////////////
  153. function bugFromLDAP($conn){
  154. echo _("Probleme avec la connexion LDAP");
  155. //echo pg_last_error($conn);
  156. //on quitte tous les script (pas de niasage)
  157. exit;
  158. }
  159. ///////////////////////////////////////////////////////////////////////////////////////
  160. // fillArrFromArray( $pg, $pgSize, $nbRecordTotal, $nbPage,
  161. // &$arrnUsrLogin, &$arrUsrNom, &$arrUsrPrenom,
  162. // &$arrUsrLieuID, &$arrUsrLieu, &$arrUsrFonction)
  163. // remplit les tableaux de variables re�us en param�tre avec les valeurs contenus dans un
  164. // Array de SESSION "UsagerLieuLDAP"(provenant d'une requ�te LDAP)
  165. // De plus ce type de requ�te tient compte de la notion des pages. On peut donc
  166. // se positionner sur la Xe page de r�sultat directement
  167. // ATTENTION : Cette fonction est tr�s sp�cifique et remplit toujours le m�me
  168. // nombre de tableau et dans un ordre tr�s sp�cifique.
  169. // IN:
  170. // $pg: quelle page on veut se positionner
  171. // $pgSize: la grandeur des page (nb d'enregistrement par page)
  172. // $nbRecordTotal: nb d'entr�e dans le tableau de SESSION
  173. // $arrUsrLogin: 1er tableau � remplir
  174. // $arrUsrNom: 2e tableau � remplir
  175. // $arr...: Xe tableau � remplir
  176. // OUT: -1: erreur lors de l'ex�cution de la requ�te
  177. // (int >= 0): nb de rang�es r�sultantes de la requ�te
  178. ///////////////////////////////////////////////////////////////////////////////////////
  179. function fillArrFromArray( $pg, $pgSize, $nbRecordTotal, $nbPage, &$arrnUsrLogin,
  180. &$arrUsrNom, &$arrUsrPrenom,&$arrUsrLieuID, &$arrUsrLieu,
  181. &$arrUsrFonction){
  182. $nbPage = ceil($nbRecordTotal/$pgSize);
  183. if ($nbRecordTotal>0){
  184. $offset = ($pg-1)*$pgSize;
  185. $limit = $offset + $pgSize;
  186. $nbRow = min($nbRecordTotal,$limit)- $offset;
  187. for($iRow=0; $iRow<$nbRow; $iRow++,$offset++){
  188. $arrnUsrLogin[$iRow] = $_SESSION["UsagerLieuLDAP"][5][$offset];
  189. $arrUsrNom[$iRow] = $_SESSION["UsagerLieuLDAP"][0][$offset];
  190. $arrUsrPrenom[$iRow] = $_SESSION["UsagerLieuLDAP"][1][$offset];
  191. $arrUsrLieuID[$iRow] = $_SESSION["UsagerLieuLDAP"][2][$offset];
  192. $arrUsrLieu[$iRow] = $_SESSION["UsagerLieuLDAP"][3][$offset];
  193. $arrUsrFonction[$iRow] = $_SESSION["UsagerLieuLDAP"][4][$offset];
  194. }
  195. return ($nbRow);
  196. }
  197. else{
  198. return (0);
  199. }
  200. }
  201. ///////////////////////////////////////////////////////////////////////////////////////
  202. // fillUsrFromLDAPServer($login, $mdp, &$bLoginValide, &$sArrayLDAP)
  203. // remplit le usr_id de l'usager en fonction de ce qu'on trouv� dans ldap qui avait
  204. // le m�me login et mot de passe que celui fournit en param�tre
  205. // IN: $login: nom d'usager
  206. // $mdp: mot de passe
  207. // &$bLoginValide : si on a de quoi de valide sur ldap, on met true ici
  208. // &$sArrayLDAP : informations extraites du serveur LDAP
  209. // OUT: 1: user retrouv� dans ldap
  210. // 0: user non retrouv� dans ldap
  211. ///////////////////////////////////////////////////////////////////////////////////////
  212. function fillUsrFromLDAPServer( $login, $mdp, &$bLoginValide, &$sArrayLDAP ){
  213. global $ldap_var;
  214. $OkLDAP = 0;
  215. $bLoginValide = false;
  216. // Connexion au serveur LDAP
  217. $conLDAP = ldap_connect( $ldap_var[ 'db' ][ 'host' ], $ldap_var[ 'db' ][ 'port' ] );
  218. //Connexion au serveur LDAP. Si non-r�ussi, on quitte
  219. if( $conLDAP !== false ) {
  220. //Si options LDAP on les appliquent
  221. if ( count($ldap_var["ldap_options"]) > 0) {
  222. OptionConnexion_LDAP($conLDAP);
  223. }
  224. // Filtre pour rechercher seulement le code d'usager
  225. $filtre = "(&(" . $ldap_var[ "db" ][ "searchKey" ] . "=" . $login. ")" . $ldap_var[ "db" ][ "filter" ] . ")";
  226. //Recherche l'usager dans la base ldap
  227. $codeRetour = Recherche_LDAP( $conLDAP, $filtre, &$sArrayRechLdap );
  228. $sArrayRechLdap = $sArrayRechLdap[ 0 ];
  229. //V�rifie le code de retour pour savoir si l'usager existe dans l'annuaire
  230. if( $codeRetour >= 0 ) {
  231. $OkLDAP = 1;
  232. if( $codeRetour > 0 ) {
  233. //R�cupp�re le dn pour permettre de faire le nouveau bind
  234. $dn = $sArrayRechLdap[ 7 ];
  235. //Si pas de mot de passe fournit on en g�n�re un bidon pour �tre certain de ne pas faire un bind anonyme
  236. if( $mdp == "" ){
  237. $mdp = crypt( microtime() );
  238. }
  239. // Si l'authentification a r�ussie, retourne les infos de l'usager ainsi qu'un code de retour valide
  240. if( @ldap_bind( $conLDAP, $dn, $mdp ) ){
  241. //if( ldap_compare( $conLDAP, $dn, "userpassword", $mdp ) ){
  242. $sArrayLDAP = array( trim( $sArrayRechLdap[ 0 ] ), trim( $sArrayRechLdap[ 1 ] ), trim( $sArrayRechLdap[ 2 ] ),
  243. trim( $sArrayRechLdap[ 3 ] ), trim( $sArrayRechLdap[ 4 ] ), trim( $sArrayRechLdap[ 5 ] ), trim( $sArrayRechLdap[ 6 ] ) );
  244. $bLoginValide = true;
  245. }
  246. }
  247. }
  248. ldap_unbind( $conLDAP );
  249. }
  250. return $OkLDAP;
  251. }
  252. ///////////////////////////////////////////////////////////////////////////////////////
  253. // OptionConnexion_LDAP
  254. // Affecte les options de connexion � l'annaire LDAP s'il y a lieu
  255. // IN: $conLDAP :Connexion au serveur ldap
  256. // OUT: -----
  257. ///////////////////////////////////////////////////////////////////////////////////////
  258. function OptionConnexion_LDAP( $conLDAP){
  259. global $ldap_var;
  260. for( $i=0; is_array($ldap_var["ldap_options"]) && $i < count($ldap_var["ldap_options"]); $i++ ) {
  261. if( isset( $ldap_var["ldap_options"][$i] ) && strpos( $ldap_var["ldap_options"][$i], ";" ) ) {
  262. $param = explode(";",$ldap_var["ldap_options"][$i]);
  263. ldap_set_option($conLDAP, constant($param[0]) ,$param[1]);
  264. }
  265. }
  266. }
  267. ///////////////////////////////////////////////////////////////////////////////////////
  268. // Recherche_LDAP
  269. // Recherche des informations selon le filtre sp�cifi�
  270. // IN: $conLDAP :Connexion au serveur ldap
  271. // $filtre : filtre de recherche
  272. // &$sArrayLDAP : informations extraites du serveur LDAP
  273. // OUT: nb: nb. user retrouv� dans ldap
  274. // 0: user non retrouv� dans ldap
  275. // -1: connexion impossible
  276. ///////////////////////////////////////////////////////////////////////////////////////
  277. function Recherche_LDAP( $conLDAP, $filtre, $sArrayLDAP ){
  278. global $ldap_var;
  279. $codeRetour = 0;
  280. // La connexion au serveur LDAP est �tablit on fait un premier bind
  281. if( isset( $ldap_var[ 'db' ][ 'bind_dn' ] ) ) {
  282. //Si aucun code de bind n'est d�fini on fait un alors un bind anonyme
  283. $bindLDAP = ldap_bind( $conLDAP, $ldap_var[ 'db' ][ 'bind_dn' ], $ldap_var[ 'db' ][ 'bind_pwd' ] );
  284. } else {
  285. // Sinon on fait une connexion avec un usager ayant les droits n�cessaires dans l'annuaire
  286. $bindLDAP = ldap_bind( $conLDAP );
  287. }
  288. // Bind au serveur LDAP non-r�ussi, on quitte
  289. if( !$bindLDAP ) {
  290. $codeRetour = -1;
  291. } else {
  292. // Liste des variables � retourner lors du search
  293. $restrictions = array( $ldap_var[ 'info' ][ 'nom' ], $ldap_var[ 'info' ][ 'prenom' ], $ldap_var[ 'info' ][ 'email' ],
  294. $ldap_var[ 'info' ][ 'lieuID' ], $ldap_var[ 'info' ][ 'lieuDescr' ], $ldap_var[ 'info' ][ 'telephone' ],
  295. $ldap_var[ 'info' ][ 'fonction' ], $ldap_var[ 'db' ][ 'searchKey' ] );
  296. // Cherche le dn de l'usager et met les enregistrements dans un tableau pour le traitement
  297. $arrayRecherche = ldap_search( $conLDAP, $ldap_var[ 'db' ][ 'searchBase' ], $filtre, $restrictions );
  298. $info = ldap_get_entries($conLDAP, $arrayRecherche);
  299. $codeRetour = count( $info ) - 1;
  300. // Retourne toutes les informations de l'usager selon l'annuaire
  301. for( $i = 0; is_array($info) && $i < $codeRetour; $i++) {
  302. $entree = $info[ $i ];
  303. //Correction si l'usager n'a pas de num�ro de t�l�phone dans ldap
  304. if ( !isset( $entree[ $ldap_var[ 'info' ][ 'telephone'] ] ) ||
  305. !is_array( $entree[ $ldap_var[ 'info' ][ 'telephone'] ] ) ){
  306. $entree[ $ldap_var[ 'info' ][ 'telephone' ] ] = array( "" );
  307. }
  308. $sArrayLDAP[ $i ] = array( $entree[ $ldap_var[ 'info' ][ 'nom' ] ][ 0 ], $entree[ $ldap_var[ 'info' ][ 'prenom' ] ][ 0 ],
  309. $entree[ $ldap_var[ 'info' ][ 'email'] ][ 0 ], strtolower( $entree[ $ldap_var[ 'info' ]['lieuID' ] ][ 0 ] ),
  310. $entree[ $ldap_var[ 'info' ][ 'lieuDescr'] ][ 0 ], $entree[ $ldap_var[ 'info' ][ 'telephone'] ][ 0 ],
  311. $entree[ $ldap_var[ 'info' ][ 'fonction'] ][ 0 ], $entree[ 'dn' ],
  312. strtolower( $entree[ $ldap_var[ 'db' ][ 'searchKey' ] ][ 0 ] ) );
  313. }
  314. }
  315. return $codeRetour;
  316. }
  317. ///////////////////////////////////////////////////////////////////////////////////////
  318. // Recherche_LDAP_Import
  319. // Recherche des informations selon le filtre sp�cifi�
  320. // IN: $conLDAP :Connexion au serveur ldap
  321. // $filtre : filtre de recherche
  322. // &$sArrayLDAP : informations extraites du serveur LDAP
  323. // OUT: nb: nb. user retrouv� dans ldap
  324. // 0: user non retrouv� dans ldap
  325. // -1: connexion impossible
  326. ///////////////////////////////////////////////////////////////////////////////////////
  327. function Recherche_LDAP_Import($conLDAP, $filtre, $sArrayLDAP){
  328. global $ldap_var;
  329. $codeRetour = 0;
  330. //La connexion au serveur LDAP est �tablit on fait un premier bind
  331. //Si aucun code de bind n'est d�fini on fait un alors un bind anonyme
  332. //sinon on fait une connexion avec un usager ayant lesdroits n�cessaires dans l'annuaire'
  333. if(isset($ldap_var[db][bind_dn])) //Le LDAP n'est pas anonyme
  334. {
  335. $bindLDAP = ldap_bind($conLDAP, $ldap_var[db][bind_dn],$ldap_var[db][bind_pwd]);
  336. }
  337. else //La recherche anonyme est permise
  338. {
  339. $bindLDAP = ldap_bind($conLDAP);
  340. }
  341. if(!$bindLDAP) //Bind au serveur LDAP non-r�ussi, on quitte
  342. {
  343. ldap_unbind($conLDAP); //D�connexion
  344. $codeRetour = -1;
  345. return $codeRetour; //Arr�t COMPLET de l'application (-1)
  346. }
  347. //Liste des variables � retourner lors du search
  348. $restrictions = array($ldap_var[info][nom],
  349. $ldap_var[info][prenom],
  350. $ldap_var[info][email],
  351. $ldap_var[info][lieuID],
  352. $ldap_var[info][lieuDescr],
  353. $ldap_var[info][telephone],
  354. $ldap_var[info][fonction],
  355. $ldap_var[db][searchKey]);
  356. // Aller chercher le dn de l'usager
  357. $arrayRecherche = ldap_search($conLDAP,$ldap_var[db][searchBase],
  358. $filtre, $restrictions);
  359. // Mettre les enregistrements dans un tableau pour le traitement
  360. $info = ldap_get_entries($conLDAP, $arrayRecherche);
  361. $codeRetour = count($info) - 1;
  362. for( $i = 0; is_array($info) && $i < (count($info)-1); $i++){
  363. $arrayNom[$i] = changeUTF16($info[$i][$ldap_var[info][nom]][0]);
  364. $arrayPrenom[$i] = changeUTF16($info[$i][$ldap_var[info][prenom]][0]);
  365. $arrayLieuID[$i] = $info[$i][$ldap_var[info][lieuID]][0];
  366. $arrayLieuDescr[$i] = changeUTF16($info[$i][$ldap_var[info][lieuDescr]][0]);
  367. $arrayFonction[$i] = changeUTF16($info[$i][$ldap_var[info][fonction]][0]);
  368. $arrayKey[$i] = $info[$i][$ldap_var[db][searchKey]][0];
  369. }
  370. $sArrayLDAP[0] = $arrayNom;
  371. $sArrayLDAP[1] = $arrayPrenom;
  372. $sArrayLDAP[2] = $arrayLieuID;
  373. $sArrayLDAP[3] = $arrayLieuDescr;
  374. $sArrayLDAP[4] = $arrayFonction;
  375. $sArrayLDAP[5] = $arrayKey;
  376. return $codeRetour;
  377. }
  378. ///////////////////////////////////////////////////////////////////////////////////////
  379. // Retourne la requete SQL necessaire pour faire un SELECT LDAP
  380. ///////////////////////////////////////////////////////////////////////////////////////
  381. function getSQLStmtReqLieuxLDAP($mot, $motlnk, $adminlieu_id, $tech_id, $valide, $indx){
  382. $SQLStmt="SELECT li_id, li_lieu, li_no, li_adresse, li_trajet, li_valide";
  383. $SQLStmt.=" FROM lieu";
  384. $SQLStmt.=" WHERE li_id = li_id";
  385. $SQLStmt.=" AND li_ldap ='t'";
  386. if ($mot!=""){
  387. if ($motlnk!="and" && $motlnk!="or"){
  388. $motlnk="and"; //valeur par defaut : securite
  389. }
  390. $arrMot=getArrayFromStringMot($mot);
  391. $SQLStmt.=" AND (";
  392. for ($i=0; $i<count($arrMot); $i++){
  393. $SQLStmt.="(li_lieu ILIKE '%".fixPGQuote($arrMot[$i])."%'";
  394. $SQLStmt.=" OR li_adresse ILIKE '%".fixPGQuote($arrMot[$i])."%')";
  395. if ($i<count($arrMot)-1){
  396. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  397. }
  398. }
  399. $SQLStmt.=")";
  400. }
  401. if (is_numeric($adminlieu_id)){
  402. $SQLStmt.=" AND li_id IN (";
  403. $SQLStmt.=" SELECT li_id";
  404. $SQLStmt.=" FROM lieuadmin";
  405. $SQLStmt.=" WHERE usr_id=".$adminlieu_id;
  406. $SQLStmt.=")";
  407. }
  408. if (is_numeric($tech_id)){
  409. $SQLStmt.=" AND li_id IN (";
  410. $SQLStmt.=" SELECT li_id";
  411. $SQLStmt.=" FROM lieusupport";
  412. $SQLStmt.=" WHERE usr_id=".$tech_id;
  413. $SQLStmt.=")";
  414. }
  415. if ($valide!=""){
  416. if (!strcasecmp($valide,"t")){
  417. $SQLStmt.=" AND li_valide='t'";
  418. }
  419. else{
  420. $SQLStmt.=" AND li_valide='f'";
  421. }
  422. }
  423. if ($indx!=""){
  424. if ($indx=="lieua"){
  425. $SQLStmt.=" ORDER BY li_lieu ASC";
  426. }
  427. elseif ($indx=="lieud"){
  428. $SQLStmt.=" ORDER BY li_lieu DESC";
  429. }
  430. elseif ($indx=="adressea"){
  431. $SQLStmt.=" ORDER BY li_adresse ASC";
  432. }
  433. elseif ($indx=="adressed"){
  434. $SQLStmt.=" ORDER BY li_adresse DESC";
  435. }
  436. elseif ($indx=="trajeta"){
  437. $SQLStmt.=" ORDER BY li_trajet ASC";
  438. }
  439. elseif ($indx=="trajetd"){
  440. $SQLStmt.=" ORDER BY li_trajet DESC";
  441. }
  442. elseif ($indx=="lieunoa"){
  443. $SQLStmt.=" ORDER BY li_no ASC";
  444. }
  445. elseif ($indx=="lieunod"){
  446. $SQLStmt.=" ORDER BY li_no DESC";
  447. }
  448. else
  449. {
  450. $SQLStmt.=" ORDER BY li_lieu ASC"; // ordre alphabetique de nom par defaut
  451. }
  452. }
  453. return $SQLStmt;
  454. }
  455. ///////////////////////////////////////////////////////////////////////////////////////
  456. // Retourne le filtre necessaire pour faire la recherche LDAP par lieu
  457. ///////////////////////////////////////////////////////////////////////////////////////
  458. function getFiltreUsagersLdap($mot, $li_no){
  459. global $ldap_var;
  460. $filtre.="(&";
  461. if ($mot!=""){
  462. if ($motlnk!="and" && $motlnk!="or"){
  463. $motlnk="and"; //valeur par defaut : securite
  464. }
  465. $arrMot=getArrayFromStringMot($mot);
  466. for ($i=0; $i<count($arrMot); $i++){
  467. $rech = verifMot($mot);
  468. if($rech !="" ){
  469. $filtre.="(".$ldap_var[info][nom]."=".$rech."*)";
  470. }
  471. }
  472. }
  473. //Lieu recherch�
  474. if ($li_no !=""){
  475. $filtre.="(".$ldap_var[info][lieuID]."=".$li_no.")";
  476. }
  477. //Filtre supl�mentaire sp�cial.
  478. $filtre .= $ldap_var[db][filter];
  479. $filtre .=")";
  480. return $filtre;
  481. }
  482. ///////////////////////////////////////////////////////////////////////////////////////
  483. // verifMot($input)
  484. // Enl�ve les caract�res *? de la chaine
  485. // IN: $input: string qu'on veut v�rifier
  486. // OUT: string �pur�e
  487. ///////////////////////////////////////////////////////////////////////////////////////
  488. function verifMot($input){
  489. $result = strtr($input,"*?","//");
  490. $result = trim($result);
  491. return ($result);
  492. }
  493. ///////////////////////////////////////////////////////////////////////////////////////
  494. // TriArrayLDAP($cle)
  495. // Tri le Array de SESSION "UsagerLieuLDAP"(provenant d'une requ�te LDAP)
  496. // IN: $cle: Cle de tri
  497. // OUT: Array de SESSION tri�
  498. // True cle valide
  499. ///////////////////////////////////////////////////////////////////////////////////////
  500. function TriArray($cle){
  501. //Extrait la partie ordre de tri
  502. $typeTri = substr($cle,-1);
  503. //Ajuste l'ordre pour un tri descendant ou ascendant par d�faut
  504. if($typeTri == "d" || $typeTri == "D"){
  505. $ordre = "SORT_DESC";
  506. }
  507. else {
  508. $ordre = "SORT_ASC";
  509. }
  510. //Extrait la partie du mot qui indique la cle de tri
  511. $cleTri = substr($cle,0, -1);
  512. //Ajuste les cl�s pour un tri par fonction
  513. if($cleTri == "type") {
  514. $cle1 = 4; //Fonction
  515. $cle2 = 0; //Nom
  516. $cle3 = 1; //Prenom
  517. $cle4 = 2; //LieuID
  518. }
  519. else if ($cleTri == "lieu") {
  520. $cle1 = 2; //LieuID
  521. $cle2 = 0; //Nom
  522. $cle3 = 1; //Prenom
  523. $cle4 = 4; //Fonction
  524. }
  525. else { //Tri par d�faut (Nom, Pr�nom, LieuID, Fonction)
  526. $cle1 = 0; //Nom
  527. $cle2 = 1; //Prenom
  528. $cle3 = 2; //LieuID
  529. $cle4 = 4; //Fonction
  530. }
  531. //Tri du tableau complet
  532. if($typeTri == "d" || $typeTri == "D"){
  533. array_multisort($_SESSION["UsagerLieuLDAP"][$cle1], SORT_DESC,
  534. $_SESSION["UsagerLieuLDAP"][$cle2], SORT_DESC,
  535. $_SESSION["UsagerLieuLDAP"][$cle3], SORT_DESC,
  536. $_SESSION["UsagerLieuLDAP"][$cle4], SORT_DESC,
  537. $_SESSION["UsagerLieuLDAP"][3],
  538. $_SESSION["UsagerLieuLDAP"][5]);
  539. }
  540. else{
  541. array_multisort($_SESSION["UsagerLieuLDAP"][$cle1], SORT_ASC,
  542. $_SESSION["UsagerLieuLDAP"][$cle2], SORT_ASC,
  543. $_SESSION["UsagerLieuLDAP"][$cle3], SORT_ASC,
  544. $_SESSION["UsagerLieuLDAP"][$cle4], SORT_ASC,
  545. $_SESSION["UsagerLieuLDAP"][3],
  546. $_SESSION["UsagerLieuLDAP"][5]);
  547. }
  548. return (true);
  549. }
  550. ///////////////////////////////////////////////////////////////////////////////////////
  551. // connextToPG($conn)
  552. // �tablit la connexion avec le serveur Postgresql
  553. ///////////////////////////////////////////////////////////////////////////////////////
  554. function connectToPG( $conn_str ){
  555. if( !$conn = pg_connect( $conn_str ) ) { bugFromPG( $conn ); };
  556. return $conn;
  557. }
  558. ///////////////////////////////////////////////////////////////////////////////////////
  559. // bugFromPG($conn)
  560. // m�thode appell�e losrqu'on a un probl�me avec l'ex�cution d'une requ�te ou � �tablir
  561. // la connexion avec le serveur Postgresql.
  562. ///////////////////////////////////////////////////////////////////////////////////////
  563. function bugFromPG($conn){
  564. echo _("Probleme avec la BD PostgreSQL");
  565. echo pg_last_error($conn);
  566. //on quitte tous les script (pas de niasage)
  567. exit;
  568. }
  569. ///////////////////////////////////////////////////////////////////////////////////////
  570. // changeUTF16($chaine)
  571. // m�thode appell�e pour convertir les lignes LDap d'UTF-8 � UTF-16
  572. //
  573. // IN: $chaine
  574. // OUT: retourne la chaine UTF-8 ou ISO-8859-1, convertie en UTF-16
  575. ///////////////////////////////////////////////////////////////////////////////////////
  576. function changeUTF16( $chaine ){
  577. return mb_convert_encoding( $chaine, "ISO-8859-1","UTF-8" )."\n" ;
  578. }
  579. ///////////////////////////////////////////////////////////////////////////////////////
  580. // Met un space HTML lorsqu'il n'y aucune valeur a afficher
  581. ///////////////////////////////////////////////////////////////////////////////////////
  582. function convNoDataToHTMLSpace($value){
  583. if (($value=="") || (!isset($value))){
  584. return("&nbsp;");
  585. }
  586. else{
  587. return($value);
  588. }
  589. }
  590. ///////////////////////////////////////////////////////////////////////////////////////
  591. // fillArrFromDBStd($conn, $sqlstmt, $arrVal0 = NULL, $arrVal1 = NULL, ...)
  592. // remplit les tableaux de variables re�u en param�tre avec la valeur des
  593. // rang�es retourn�es par la requ�te sql fournie en param�tre
  594. // ATTENTION : l'ordre des variables sp�cifi�es en param�tre doit �tre le m�me
  595. // que l'odre des champs dans la requ�te
  596. // [SUPPORTE 40 tableaux]
  597. // IN: $conn: objet de connexion avec la db (doit �tre d�j� ouvert)
  598. // $sqlstmt: requ�te SQL � ex�cuter
  599. // $arrVal1: 1er tableau � remplir
  600. // $arrVal2: 2e tableau � remplir
  601. // $arrValX: Xe tableau � remplir
  602. // OUT: -1: erreur lors de l'ex�cution de la requ�te
  603. // (int): nb de rang�es r�sultantes de la requ�te
  604. ///////////////////////////////////////////////////////////////////////////////////////
  605. 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){
  606. $nbRow = -1;
  607. // tableau dynamique
  608. $nbArray = func_num_args() - 2;
  609. for( $i = 0; $i < $nbArray; $i++ ){
  610. $name = "arrVal" . $i;
  611. $args[ $i ] =& $$name;
  612. // S'assure que ce qui sera retourn� sera au moins un tableau vide
  613. if( is_null( $args[ $i ] ) ){
  614. $args[ $i ] = array();
  615. }
  616. }
  617. // bd time
  618. $result = pg_query( $conn, $sqlstmt );
  619. if( $result > 0 ){
  620. $nbRow = pg_num_rows( $result );
  621. $nbLoop = min( $nbArray, pg_num_fields( $result ) );
  622. for( $iRow = 0; $iRow < $nbRow; $iRow++ ){
  623. for( $iCol = 0; $iCol < $nbLoop; $iCol++ ){
  624. $args[ $iCol ][ $iRow ] = pg_result( $result, $iRow, $iCol );
  625. }
  626. }
  627. pg_free_result( $result );
  628. }
  629. return $nbRow;
  630. }
  631. ///////////////////////////////////////////////////////////////////////////////////////
  632. // fillArrFromDBStdWithPg($conn, $sqlstmt, $page_no, $page_size, $nbPage, $nbRecordTotal, $arrVal0 = NULL, $arrVal1 = NULL, ...)
  633. // remplit les tableaux de variables re�us en param�tre avec la valeur des
  634. // rang�es retourn�es par la requ�te sql fournie en param�tre. De plus
  635. // ce type de requ�te tient compte de la notion des pages. On peut donc
  636. // se positionner sur la Xe page de r�sultat directement
  637. // ATTENTION : l'ordre des variables sp�cifi�es en param�tre doit �tre le m�me
  638. // que l'odre des champs dans la requ�te
  639. // [SUPPORTE 40 tableaux]
  640. // IN: $conn: objet de connexion avec la db (doit �tre d�j� ouvert)
  641. // $sqlstmt: requ�te SQL � ex�cuter
  642. // $page_no: quelle page on veut se positionner
  643. // $pgSize: la grandeur des page (nb d'enregistrement par page)
  644. // $page_size: nb de page r�sultant de la requ�te
  645. // $nbRecordTotal: nb d'enregistrement r�sultant de la requ�te
  646. // $arrVal1: 1er tableau � remplir
  647. // $arrVal2: 2e tableau � remplir
  648. // $arrValX: Xe tableau � remplir
  649. // OUT: -1: erreur lors de l'ex�cution de la requ�te
  650. // (int >= 0): nb de rang�es r�sultantes de la requ�te
  651. ///////////////////////////////////////////////////////////////////////////////////////
  652. function fillArrFromDBStdWithPg($conn, $sqlstmt, $page_no, $page_size, $nbPage, $nbRecordTotal, $arrVal0 = NULL, $arrVal1 = NULL, $arrVal2 = NULL,
  653. $arrVal3 = NULL, $arrVal4 = NULL, $arrVal5 = NULL, $arrVal6 = NULL, $arrVal7 = NULL, $arrVal8 = NULL, $arrVal9 = NULL, $arrVal10 = NULL,
  654. $arrVal11 = NULL, $arrVal12 = NULL, $arrVal13 = NULL, $arrVal14 = NULL, $arrVal15 = NULL, $arrVal16 = NULL, $arrVal17 = NULL,
  655. $arrVal18 = NULL, $arrVal19 = NULL, $arrVal20 = NULL, $arrVal21 = NULL, $arrVal22 = NULL, $arrVal23 = NULL, $arrVal24 = NULL,
  656. $arrVal25 = NULL, $arrVal26 = NULL, $arrVal27 = NULL, $arrVal28 = NULL, $arrVal29 = NULL, $arrVal30 = NULL, $arrVal31 = NULL,
  657. $arrVal32 = NULL, $arrVal33 = NULL, $arrVal34 = NULL, $arrVal35 = NULL, $arrVal36 = NULL, $arrVal37 = NULL, $arrVal38 = NULL, $arrVal39 = NULL){
  658. $retour = -1;
  659. // Cr�ation d'un tableau dynamique de pointeurs vers les tableaux de valeurs re�ues
  660. $nbArray = func_num_args()-2;
  661. for( $i = 0; $i < $nbArray; $i++ ){
  662. $name = "arrVal" . $i;
  663. $args[ $i ] = &$$name;
  664. }
  665. // Fait la requ�te en �tant tout ce qui suit "ORDER BY"
  666. if( $result = pg_query( $conn, eregi_replace( " ORDER BY .*" , "", $sqlstmt ) ) ){
  667. $retour = 0;
  668. $nbRecordTotal = pg_num_rows( $result );
  669. if( $nbRecordTotal > 0 ){
  670. $nbPage = ceil( $nbRecordTotal / $page_size );
  671. $limit = $page_size;
  672. if (isset($page_no) )
  673. $offset = ( $page_no - 1 ) * $page_size;
  674. else
  675. $offset = 0;
  676. // on refait la requ�te avec des nouveaux param�tres
  677. $result = pg_query( $conn, $sqlstmt . " LIMIT " . $limit . " OFFSET " . $offset );
  678. $nbRow = pg_num_rows($result);
  679. $nbCol = min( $nbArray, pg_num_fields( $result ) );
  680. for( $iRow = 0; $iRow < $nbRow; $iRow++ ){
  681. for( $iCol=0; $iCol < $nbCol; $iCol++ ){
  682. $args[ $iCol ][ $iRow ] = pg_result( $result, $iRow, $iCol );
  683. }
  684. }
  685. pg_free_result( $result ); // Lib�re la m�moire inutilis�e
  686. $retour = $nbRow;
  687. }
  688. }
  689. return $retour;
  690. }
  691. ///////////////////////////////////////////////////////////////////////////////////////
  692. // fillVarFromDBStd($conn, $sqlstmt, &$val1, &$val2, &$val3)
  693. // remplit les variables re�ues en param�tre avec la valeur de la premi�re
  694. // rang�e du r�sultat de la requ�te (arrangez vous pour que la requ�te
  695. // sql n'ait qu'une seule rang�e de r�sultat)
  696. // ATTENTION : l'ordre des variables sp�cifi�es en param�tre doit �tre le m�me
  697. // que l'odre des champs dans la requ�te
  698. // [SUPPORTE 40 variables]
  699. // IN: $conn: objet de connexion avec la db (doit �tre d�j� ouvert)
  700. // $sqlstmt: requ�te SQL � ex�cuter
  701. // $val1: 1ere variable � remplir
  702. // $val2: 2e variable � remplir
  703. // $valX: Xe variable � remplir
  704. ///////////////////////////////////////////////////////////////////////////////////////
  705. 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){
  706. // tableau dynamique
  707. $nbVariable = func_num_args()-2;
  708. for ($i=0; $i<$nbVariable; $i++){
  709. $name = "val" . $i;
  710. $args[$i]=&$$name;
  711. }
  712. //echo "fillVarFromDBStd: " . $sqlstmt . "<br>";
  713. $result = pg_query($conn, $sqlstmt);
  714. if (!$result){ bugFromPG($conn); }
  715. if($result>0){
  716. $nbRow=pg_num_rows($result);
  717. $nbLoop=min($nbVariable,pg_num_fields($result));
  718. if($nbRow==1){
  719. for($iCol=0; $iCol<$nbLoop; $iCol++){
  720. $args[$iCol]=pg_result($result, 0, $iCol);
  721. }
  722. pg_free_result($result);
  723. return(true);
  724. }
  725. pg_free_result($result);
  726. }
  727. return(false);
  728. }
  729. ///////////////////////////////////////////////////////////////////////////////////////
  730. // fixPGQuote($input)
  731. // fixe les quote pour que la requ�te demeure s�curitaire dans postgres..
  732. // IN: $input: string qu'on veut s�curiser
  733. // OUT: string s�curis�
  734. ///////////////////////////////////////////////////////////////////////////////////////
  735. function fixPGQuote($input){
  736. // Peut �tre remplac� par 'pg_escape_string' mais doit �tre utilis� avec une connexion � Postgres 7.2
  737. return (addslashes($input));
  738. }
  739. ///////////////////////////////////////////////////////////////////////////////////////
  740. // getWordStemRegExp()
  741. // Retourne une expression reguliere qui permet de reconnaitre le debut d'un mot
  742. // a l'interieur d'une chaine quelconque.
  743. // OUT: expression reguliere
  744. ///////////////////////////////////////////////////////////////////////////////////////
  745. function getWordStemRegExp(){
  746. // Tout caractere pouvant se trouver au debut d'un mot.
  747. return( "[ -.,?!:;([\']" );
  748. }
  749. ///////////////////////////////////////////////////////////////////////////////////////
  750. // accentInsensitiveLike()
  751. // Retourne une chaine pouvant remplacer une expression LIKE ou ILIKE afin
  752. // d'effectuer un "pattern matching".
  753. // Les expressions r�guli�res sont beaucoup plus rapides que LIKE ou ILIKE
  754. // IN: $field_name Nom du champ
  755. // $field_value Valeur du champ
  756. // $case_insensitive true si l'on veut que la comparaison ne tienne pas compte
  757. // de la casse
  758. // OUT: clause SQL
  759. ///////////////////////////////////////////////////////////////////////////////////////
  760. function accentInsensitiveLike($field_name, $field_value, $case_insensitive = true) {
  761. $regexp_op = ( $case_insensitive == true ) ? "~*" : "~";
  762. // 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
  763. return "( " . $field_name . " " . $regexp_op . " E'^" . $field_value . "|[^\w]" . $field_value . "' )";
  764. }
  765. ///////////////////////////////////////////////////////////////////////////////////////
  766. // flushCourriel()
  767. // Envoit tous les courriels qui devraient etre envoyes
  768. ///////////////////////////////////////////////////////////////////////////////////////
  769. function flushCourriel(){
  770. //echo "Les courriels n'ont pas �t� flush�s par le fichier 'forticFunctions.php'.";
  771. }
  772. ///////////////////////////////////////////////////////////////////////////////////////
  773. // formatCR($sTemp)
  774. // formate la sortie de mani�re � remplacer les CR par des <br> (les ENTERS)
  775. // IN: $sTemp: string � afficher
  776. // OUT: (string) le r�sultat du string une fois format�
  777. ///////////////////////////////////////////////////////////////////////////////////////
  778. function formatCR($sTemp){
  779. return (str_replace("\r","<br/>",$sTemp));
  780. }
  781. ///////////////////////////////////////////////////////////////////////////////////////
  782. // Set le format d'affichage pour les dates.
  783. ///////////////////////////////////////////////////////////////////////////////////////
  784. function formatDate($dTemp, $format){
  785. if ( (isDate($dTemp)) || (isTimeStamp($dTemp)) ){
  786. return date($format,strtotime($dTemp));
  787. }
  788. else{
  789. return $dTemp;
  790. }
  791. }
  792. ///////////////////////////////////////////////////////////////////////////////////////
  793. // Set le format d'affichage pour les dates.
  794. ///////////////////////////////////////////////////////////////////////////////////////
  795. function formatDateInterval($dTemp1, $dTemp2, $style, $dateFormat, $timeFormat){
  796. if ($style=="date"){
  797. if ( ((isDate($dTemp1))||(isTimeStamp($dTemp1))) && ((isDate($dTemp2))||(isTimeStamp($dTemp2))) ){
  798. $sDateTemp1 = date($dateFormat, strtotime($dTemp1));
  799. $sDateTemp2 = date($dateFormat, strtotime($dTemp2));
  800. if ($sDateTemp1 != $sDateTemp2){
  801. $output = $sDateTemp1." "._("au")." ".$sDateTemp2;
  802. }
  803. else{
  804. $output = $sDateTemp1;
  805. }
  806. }
  807. elseif( (isDate($dTemp1))||(isTimeStamp($dTemp1)) ){
  808. $sDateTemp1 = date($dateFormat, strtotime($dTemp1));
  809. $output = $sDateTemp1." "._("au")." "._("n/a");
  810. }
  811. elseif( (isDate($dTemp2))||(isTimeStamp($dTemp2)) ){
  812. $sDateTemp2 = date($dateFormat, strtotime($dTemp2));
  813. $output = _("n/a")." "._("au")." ".$sDateTemp2;
  814. }
  815. else{
  816. $output = _("dates indeterminees");
  817. }
  818. }
  819. elseif ($style=="time"){
  820. if ( (isTimeStamp($dTemp1)) && (isTimeStamp($dTemp2)) ){
  821. $sDateTemp1 = date($dateFormat, strtotime($dTemp1));
  822. $sDateTemp2 = date($dateFormat, strtotime($dTemp2));
  823. $sTimeTemp1 = date($timeFormat, strtotime($dTemp1));
  824. $sTimeTemp2 = date($timeFormat, strtotime($dTemp2));
  825. if ($sDateTemp1 == $sDateTemp2){
  826. $output = $sDateTemp1." ".$sTimeTemp1." "._("a")." ".$sTimeTemp2;
  827. }
  828. else{
  829. $output = $sDateTemp1." ".$sTimeTemp1." "._("a")." ".$sTimeTemp2." (".$sDateTemp1.")";
  830. }
  831. }
  832. elseif( (isTimeStamp($dTemp1))||(isTimeStamp($dTemp1)) ){
  833. $sDateTemp1 = date($dateFormat, strtotime($dTemp1));
  834. $sTimeTemp1 = date($timeFormat, strtotime($dTemp1));
  835. $output = $sDateTemp1." ".$sTimeTemp1." "._("a")." "._("n/a");
  836. }
  837. elseif( (isTimeStamp($dTemp2))||(isTimeStamp($dTemp2)) ){
  838. $sDateTemp2 = date($dateFormat, strtotime($dTemp2));
  839. $sTimeTemp2 = date($timeFormat, strtotime($dTemp2));
  840. $output = _("n/a")." "._("a")." ".$sDateTemp2." ".$sTimeTemp2;
  841. }
  842. else{
  843. $output = _("moment indetermine");
  844. }
  845. }
  846. return $output;
  847. }
  848. ///////////////////////////////////////////////////////////////////////////////////////
  849. // function formatDateLimite($dTemp, $dTempDisplay, $classOK="", $classNOT="", $classHOPE="")
  850. // affiche la datelimite en couleur
  851. ///////////////////////////////////////////////////////////////////////////////////////
  852. function formatDateLimite( $dTemp, $format, $classOK = "", $classNOT = "", $classHOPE = "" ){
  853. $output = "";
  854. $class = "";
  855. if( isDate( $dTemp ) ){
  856. $today = strtotime( date( "Y-m-d" ) );
  857. $limite = strtotime( $dTemp );
  858. // Si la date limite n'est pas arriv� ou qu'elle est aujourd'hui et qu'on ne re�oit pas de classe HOPE
  859. if( ( $today < $limite || ( $today == $limite && $classHOPE == "" ) ) && $classOK != "" ){
  860. $class = $classOK;
  861. // Si la date limite est d�pass�e
  862. } elseif( $today > $limite && $classNOT != "" ){
  863. $class = $classNOT;
  864. // Si la date limite est aujourd'hui
  865. } elseif( $today == $limite && $classHOPE != "" ){
  866. $class = $classHOPE;
  867. }
  868. $output = formatDate( $dTemp, $format );
  869. if( $class != "" ){
  870. $output = "<span class='" . $class . "'>" . $output . "</span>";
  871. }
  872. }
  873. return $output;
  874. }
  875. ///////////////////////////////////////////////////////////////////////////////////////
  876. // function formatGabaritSub($sInput, $class=NULL)
  877. // formate la sortie pour qu'on puisse voir si c'est un sous-gabarit
  878. // IN: $sInput: t ou f : designant si system
  879. // OUT: (string) ce qu'on affiche sur la page
  880. ///////////////////////////////////////////////////////////////////////////////////////
  881. function formatGabaritSub($sInput, $class=NULL){
  882. $state1=_("sous-gabarit");
  883. $state2=_("gabarit");
  884. if ($sInput=="t"){
  885. if ($class!=""){
  886. $output="<span class=\"".$class."\">".$state1."</span>";
  887. }
  888. else{
  889. $output=$state1;
  890. }
  891. }
  892. else{
  893. if ($class!=""){
  894. $output="<span class=\"".$class."\">".$state2."</span>";
  895. }
  896. else{
  897. $output=$state2;
  898. }
  899. }
  900. return $output;
  901. }
  902. ///////////////////////////////////////////////////////////////////////////////////////
  903. // function formatGabaritSystem($sInput, $class=NULL)
  904. // formate la sortie pour qu'on puisse voir si c'est un gabarit system
  905. // IN: $sInput: t ou f : designant si system
  906. // OUT: (string) ce qu'on affiche sur la page
  907. ///////////////////////////////////////////////////////////////////////////////////////
  908. function formatGabaritSystem($sInput, $class=NULL){
  909. $state="("._("Systeme").")";
  910. if ($sInput=="t"){
  911. if ($class!=""){
  912. $output="<span class=\"".$class."\">".$state."</span>";
  913. }
  914. else{
  915. $output=$state;
  916. }
  917. }
  918. return $output;
  919. }
  920. ///////////////////////////////////////////////////////////////////////////////////////
  921. // formatHTML($sTemp)
  922. // formate la sortie pour qu'on puisse l'afficher sur du html sans qu'elle n'utilise de
  923. // mot r�serv� propore au html.
  924. // IN: $sTemp: string � afficher
  925. // OUT: (string) le r�sultat du string une fois format�
  926. ///////////////////////////////////////////////////////////////////////////////////////
  927. function formatHTML($sTemp){
  928. return (htmlentities($sTemp));
  929. }
  930. ///////////////////////////////////////////////////////////////////////////////////////
  931. // formatJS($sTemp)
  932. // formate la sortie pour qu'on puisse l'afficher sur du html sans qu'elle n'utilise de
  933. // mot r�serv� propore au html.
  934. // IN: $sTemp: string � afficher
  935. // OUT: (string) le r�sultat du string une fois format�
  936. ///////////////////////////////////////////////////////////////////////////////////////
  937. function formatJS($sTemp){
  938. return (addslashes($sTemp));
  939. }
  940. ///////////////////////////////////////////////////////////////////////////////////////
  941. // Set le format d'affichage d'un nom.
  942. ///////////////////////////////////////////////////////////////////////////////////////
  943. function formatName($sNom, $sPrenom){
  944. if (($sNom!="") && ($sPrenom!="")){
  945. return (strtoupper($sNom).", ".$sPrenom);
  946. }
  947. elseif ($sNom!=""){
  948. return (strtoupper($sNom));
  949. }
  950. elseif ($sPrenom!=""){
  951. return ($sPrenom);
  952. }
  953. else{
  954. return ( _("sans nom") );
  955. }
  956. }
  957. //S.C. 2007-03-28 demande #37 Ajout de la fonction formatNameLieu
  958. ///////////////////////////////////////////////////////////////////////////////////////
  959. // Set le format d'affichage d'un nom et le # lieu de travail
  960. ///////////////////////////////////////////////////////////////////////////////////////
  961. function formatNameLieu($sNom, $sPrenom, $sLieu){
  962. if (($sNom!="") && ($sPrenom!="") && ($sLieu!="")){
  963. return (strtoupper($sNom).", ".$sPrenom." (".$sLieu.")");
  964. }
  965. if (($sNom!="") && ($sPrenom!="")){
  966. return (strtoupper($sNom).", ".$sPrenom);
  967. }
  968. elseif ($sNom!=""){
  969. return (strtoupper($sNom));
  970. }
  971. elseif ($sPrenom!=""){
  972. return ($sPrenom);
  973. }
  974. elseif ($sLieu!=""){
  975. return ($sLieu);
  976. }
  977. else{
  978. return ( _("vide") );
  979. }
  980. }
  981. ///////////////////////////////////////////////////////////////////////////////////////
  982. // function formatNbInscription($nbIns, $nbMax, $classOK=NULL, $classNOT=NULL)
  983. // formate le nombre d'inscription. Losrque c'est plein, ou pas plein, on a la possibilit�
  984. // de changer le style sheet (couleur ou autres)
  985. // IN: $nbIns nombre de personne actuellement inscrit
  986. // $nbMax nombre maximal de personne
  987. // $classOK class si le nombre de personne permet l'inscription encore
  988. // $classNOT class si la session est pleine
  989. // OUT: (string) le r�sultat du string une fois format�
  990. ///////////////////////////////////////////////////////////////////////////////////////
  991. function formatNbInscription($nbIns, $nbMax, $classOK=NULL, $classNOT=NULL){
  992. unset($output);
  993. if (is_numeric($nbIns) && is_numeric($nbMax)){
  994. if ($nbIns < $nbMax){
  995. $class = $classOK;
  996. }
  997. else{
  998. $class = $classNOT;
  999. }
  1000. //output
  1001. if ($class!=""){
  1002. $output = "<span class=\"".$class."\">".$nbIns."/".$nbMax."</span>";
  1003. }
  1004. else{
  1005. $output = $nbIns."/".$nbMax;
  1006. }
  1007. }
  1008. return $output;
  1009. }
  1010. ///////////////////////////////////////////////////////////////////////////////////////
  1011. // formatNote($sNote $class)
  1012. // Set le format d'affichage pour les notes de sessions
  1013. // IN: $sNote note � �crire
  1014. // $class est-ce qu'il y a une classe auquel on veux lier (CSS)
  1015. // OUT: (string) affichage du code avec l'atelier et le projet
  1016. ///////////////////////////////////////////////////////////////////////////////////////
  1017. function formatNote( $sNote, $class = "" ){
  1018. if ( $sNote != "" ){
  1019. $sNote = "(" . $sNote . ")";
  1020. if ( $class != "" ){
  1021. $sNote = "<span class='" . $class . "'>" . $sNote . "</span>";
  1022. }
  1023. }
  1024. return $sNote;
  1025. }
  1026. ///////////////////////////////////////////////////////////////////////////////////////
  1027. // formatParamString($sParam, $sParamValeur)
  1028. // Set le format les parametre SQL et leurs valeurs
  1029. // IN: $sParam: string contenant les parametres SQL separes par des virgules
  1030. // $sParameValeur: string contenant les valeurs des parametres SQL separees par des virgules
  1031. // OUT: (string) une belle ligne qui nous fait le resume
  1032. ///////////////////////////////////////////////////////////////////////////////////////
  1033. function formatParamString($sParam, $sParamValeur){
  1034. unset($output);
  1035. if (($sParam!="") || ($sParamValeur!= "")){
  1036. $arrParam = split(",", $sParam);
  1037. $arrParamValeur = split(",", $sParamValeur);
  1038. unset($arrOutput);
  1039. for ($i=0; $i<count($arrParam); $i++){
  1040. $arrOutput[$i] = $arrParam[$i]." = ".$arrParamValeur[$i];
  1041. }
  1042. $output = join(", ", $arrOutput);
  1043. }
  1044. return $output;
  1045. }
  1046. ///////////////////////////////////////////////////////////////////////////////
  1047. // function formatPresence
  1048. // Retourne une chaine approprie dependamment du statut de presence recu.
  1049. // IN: $sTemp: (oui, non, ind)
  1050. // $sTemp statut de presence
  1051. // $expire assume une expiration de date
  1052. // OUT: (string) le r�sultat du string une fois format�
  1053. ///////////////////////////////////////////////////////////////////////////////
  1054. function formatPresence($sTemps, $statut, $expire) {
  1055. if( $statut == "t" ) {
  1056. $output = $sTemps[0];
  1057. }
  1058. else if( $statut == "f" ) {
  1059. $output = $sTemps[1];
  1060. }
  1061. else {
  1062. $output = $expire ? $sTemps[1] : $sTemps[2];
  1063. }
  1064. return $output;
  1065. }
  1066. ///////////////////////////////////////////////////////////////////////////////////////
  1067. // function formatRequeteSQL
  1068. // formate la sortie pour qu'on puisse afficher du code SQL lisible.
  1069. // IN: $sTemp: string � afficher
  1070. // OUT: (string) le r�sultat du string une fois format�
  1071. ///////////////////////////////////////////////////////////////////////////////////////
  1072. function formatRequeteSQL($sTemp){
  1073. $output=$sTemp;
  1074. $output=str_replace(" FROM ", "\rFROM ", $output);
  1075. $output=str_replace(" from ", "\rFROM ", $output);
  1076. $output=str_replace(" WHERE ", "\rWHERE ", $output);
  1077. $output=str_replace(" where ", "\rWHERE ", $output);
  1078. $output=str_replace(" AND ", "\rAND ", $output);
  1079. $output=str_replace(" and ", "\rAND ", $output);
  1080. $output=str_replace(" OR ", "\rOR ", $output);
  1081. $output=str_replace(" or ", "\rOR ", $output);
  1082. $output=str_replace(" GROUP BY ", "\rGROUP BY ", $output);
  1083. $output=str_replace(" group by ", "\rGROUP BY ", $output);
  1084. $output=str_replace(" ORDER BY ", "\rORDER BY ", $output);
  1085. $output=str_replace(" order by ", "\rORDER BY ", $output);
  1086. //$output=wordwrap($output, $width, "\r");
  1087. return $output;
  1088. }
  1089. ///////////////////////////////////////////////////////////////////////////////////////
  1090. // formatSeance($sSesCode, $sAtelier, $sProjet, $sSeaCode)
  1091. // Set le format d'affichage pour les codes de sessions
  1092. // IN: $sCode code de session
  1093. // $sAtelier nom de l'atelier parent
  1094. // $sProjet projet parent
  1095. // OUT: (string) affichage du code avec l'atelier et le projet
  1096. ///////////////////////////////////////////////////////////////////////////////////////
  1097. function formatSeance($sSesCode, $sAtelier, $sProjet, $sSeaCode){
  1098. $session = formatSession($sSesCode, $sAtelier, $sProjet);
  1099. return ($session." : "._("seance")." ".$sSeaCode);
  1100. }
  1101. ///////////////////////////////////////////////////////////////////////////////////////
  1102. // formatSession($sSesCode, $sAtelier, $sProjet)
  1103. // Set le format d'affichage pour les codes de sessions
  1104. // IN: sSesCode code de session
  1105. // $sAtelier nom de l'atelier parent
  1106. // $sProjet projet parent
  1107. // OUT: (string) affichage du code avec l'atelier et le projet
  1108. ///////////////////////////////////////////////////////////////////////////////////////
  1109. function formatSession($sSesCode, $sAtelier, $sProjet){
  1110. if( ( $sSesCode != "" ) && ( $sAtelier != "" ) ){
  1111. return ($sSesCode." [".$sAtelier."]");
  1112. } else {
  1113. return $sSesCode;
  1114. }
  1115. }
  1116. ///////////////////////////////////////////////////////////////////////////////////////
  1117. // formatSessionCode($sSesCode, $sAtelier, $sProjet)
  1118. // Set le format d'affichage pour les codes de sessions
  1119. // IN: sSesCode code de session
  1120. // $sAtelier nom de l'atelier parent
  1121. // $sProjet projet parent
  1122. // OUT: (string) affichage du code de la session
  1123. ///////////////////////////////////////////////////////////////////////////////////////
  1124. function formatSessionCode($sSesCode, $sAtelier, $sProjet){
  1125. return $sSesCode;
  1126. }
  1127. ///////////////////////////////////////////////////////////////////////////////////////
  1128. // formatSessionDescription($sSesCode, $sAtelier, $sProjet)
  1129. // Set le format d'affichage pour la description de la session
  1130. // IN: sSesCode code de session
  1131. // $sAtelier nom de l'atelier parent
  1132. // $sProjet projet parent
  1133. // OUT: (string) affichage de l'atelier et du projet
  1134. ///////////////////////////////////////////////////////////////////////////////////////
  1135. function formatSessionDescription($sSesCode, $sAtelier, $sProjet){
  1136. return $sAtelier;
  1137. }
  1138. ///////////////////////////////////////////////////////////////////////////////////////
  1139. // function formatSessionInscriptibleComplete( $nbInscription, $nbInscriptionMax, $sesAnnule, $dSesLimite, $separator, $classOK = "", $classNOT = "" )
  1140. // Set le format d'affichage lorsqu'une session est "non-inscriptible"
  1141. // IN: $nbIns nombre de personne actuellement inscrit
  1142. // $nbMax nombre maximal de personne pouvant s'inscrire
  1143. // $sesAnnule "t" ou "f" qui dit si la sessions est annul�e
  1144. // $dSesLimite date limite de la session
  1145. // $separator separateur � l'affichage entre chaque raison qui rend une session "non-inscriptible"
  1146. // $classOK -- Inutile --
  1147. // $classNOT class si la session est pleine
  1148. // OUT: (string) le r�sultat du string une fois format�
  1149. ///////////////////////////////////////////////////////////////////////////////////////
  1150. function formatSessionInscriptibleComplete( $nbInscription, $nbInscriptionMax, $sesAnnule, $dSesLimite, $separator, $classOK = "", $classNOT = "" ){
  1151. $output = "";
  1152. $arrNOT = array();
  1153. // Cr�ation des messages d'erreur
  1154. if( $nbInscription >= $nbInscriptionMax ){
  1155. $arrNOT[] = _("session complete");
  1156. }
  1157. if( $sesAnnule == "t" ){
  1158. $arrNOT[]= _("session annulee");
  1159. }
  1160. if( ( isDate( $dSesLimite ) ) && ( strtotime( date( "Y-m-d" ) ) > strtotime( $dSesLimite ) ) ){
  1161. $arrNOT[] = _("date limite depassee");
  1162. }
  1163. // Si des messages d'erreur ont �t� cr��s, on les affiche
  1164. if( count( $arrNOT ) > 0 ){
  1165. if( $classNOT != "" ){
  1166. $output = "<span class='" . $classNOT . "'>"._("non inscriptible :")." " . implode( $separator, $arrNOT ) . "</span>";
  1167. } else {
  1168. $output = _("non inscriptible :")." " . implode( $separator, $arrNOT );
  1169. }
  1170. }
  1171. return $output;
  1172. }
  1173. ///////////////////////////////////////////////////////////////////////////////////////
  1174. // function formatStateActivite($classNOT, $separator, $args)
  1175. // JE M'EXCUSE CETTE FONCTION EST AFFREUSE(youri). Vous pouvez la refaire si vous voulez.
  1176. // affiche l'�tat d'une fiche dans un listing (ex: recherche). D�s que la fiche parent,
  1177. // ou la fiche actuelle est annul�e ou invalide, cette fonction affiche (annul�) ou (invalide).
  1178. // IN: $classNOT class (pour le span) du style sheet si la fiche est invalide ou annul�e
  1179. // $separator separateur entre les 2 messages possible pour la fiche
  1180. // $prj_valide t ou f
  1181. // $act_valide t ou f
  1182. // $act_annule t ou f
  1183. ///////////////////////////////////////////////////////////////////////////////////////
  1184. function formatStateActivite($classNOT, $separator, $args){
  1185. //config
  1186. $arrState[0]=array("f","("._("invalide").")"); // projet
  1187. $arrState[1]=array("f","("._("invalide").")"); // activite
  1188. $arrState[2]=array("t","("._("annule").")"); // activite
  1189. //ne pas toucher
  1190. $MINPARAM = 2;
  1191. unset($arrStateMatch);
  1192. $iMatch=0;
  1193. $args=func_get_args();
  1194. for ($i = $MINPARAM; $i < count($args); $i++){
  1195. if (!strcasecmp($args[$i], $arrState[$i-$MINPARAM][0])){
  1196. $arrStateMatch[$iMatch]=$arrState[$i-$MINPARAM][1];
  1197. $iMatch++;
  1198. }
  1199. }
  1200. //le output
  1201. unset($output);
  1202. if (is_array($arrStateMatch)){
  1203. $arrStateMatch=array_unique($arrStateMatch);
  1204. if($classNOT!=""){
  1205. $output="<span class=\"".$classNOT."\">".join($separator, $arrStateMatch)."</span>";
  1206. }
  1207. else{
  1208. $output=join($separator, $arrStateMatch);
  1209. }
  1210. }
  1211. return $output;
  1212. }
  1213. ///////////////////////////////////////////////////////////////////////////////////////
  1214. // function formatStateActiviteComplete($classOK, $classNOT, $separator, $args)
  1215. // JE M'EXCUSE CETTE FONCTION EST AFFREUSE(youri). Vous pouvez la refaire si vous voulez.
  1216. // affiche l'�tat d'une activite en fonction si la fiche ou la fiche parent est
  1217. // annul�e ou invalide ou autres.
  1218. // IN: $classOK class (pour le span) du style sheet si la fiche est valide et active
  1219. // $classNOT class (pour le span) du style sheet si la fiche est invalide ou annul�e
  1220. // $separator separateur entre les diff�rents messages de non validit�
  1221. // $prj_valide t ou f
  1222. // $act_valide t ou f
  1223. // $act_annule t ou f
  1224. ///////////////////////////////////////////////////////////////////////////////////////
  1225. function formatStateActiviteComplete($classOK, $classNOT, $separator, $args){
  1226. //config: tableau qui fait la comparaison et affiche ce qui suit si la comparaison fit
  1227. $arrState[0]=array("f",_("projet invalide") ); // projet
  1228. $arrState[1]=array("f",_("activite invalide") ); // activite
  1229. $arrState[2]=array("t",_("activite annulee") ); // activite
  1230. $stateOK="actif";
  1231. //ne pas toucher
  1232. $MINPARAM = 3;
  1233. unset($arrStateMatch);
  1234. $iMatch=0;
  1235. $args=func_get_args();
  1236. for ($i = $MINPARAM; $i < count($args); $i++){
  1237. if (!strcasecmp($args[$i], $arrState[$i-$MINPARAM][0])){
  1238. $arrStateMatch[$iMatch]=$arrState[$i-$MINPARAM][1];
  1239. $iMatch++;
  1240. }
  1241. }
  1242. //le output
  1243. unset($output);
  1244. if (is_array($arrStateMatch)){
  1245. if($classNOT!=""){
  1246. $output="<span class=\"".$classNOT."\">".join($separator, $arrStateMatch)."</span>";
  1247. }
  1248. else{
  1249. $output=join($seperator, $arrStateMatch);
  1250. }
  1251. }
  1252. else{
  1253. if($classOK!=""){
  1254. $output="<span class=\"".$classOK."\">".$stateOK."</span>";
  1255. }
  1256. else{
  1257. $output=$stateOK;
  1258. }
  1259. }
  1260. return $output;
  1261. }
  1262. ///////////////////////////////////////////////////////////////////////////////////////
  1263. // function formatStateAnnule($annule, $class=NULL)
  1264. // Affiche un texte si c'est annul�.
  1265. // IN: $valide: 't' si valide
  1266. ///////////////////////////////////////////////////////////////////////////////////////
  1267. function formatStateAnnule($annule, $class=NULL){
  1268. $state="("._("annule").")";
  1269. if ($annule=="t"){
  1270. if ($class!=""){
  1271. $output="<span class=\"".$class."\">".$state."</span>";
  1272. }
  1273. else{
  1274. $output=$state;
  1275. }
  1276. }
  1277. return $output;
  1278. }
  1279. ///////////////////////////////////////////////////////////////////////////////////////
  1280. // function formatStateFormation($classNOT, $separator, $args)
  1281. // Affiche l'�tat d'une fiche dans un listing (ex: recherche) d'apr�s les informations re�ues
  1282. // IN: $classNOT class (pour le span) du style sheet si la fiche est invalide ou annul�e
  1283. // $separator separateur entre les 2 messages possible pour la fiche
  1284. // $prj_valide t par d�faut
  1285. // $atl_valide t par d�faut
  1286. // $ses_valide t par d�faut
  1287. // $ses_annule f par d�faut
  1288. // $sea_valide t par d�faut
  1289. // $sea_annule f par d�faut
  1290. ///////////////////////////////////////////////////////////////////////////////////////
  1291. function formatStateFormation( $classNOT = "", $separator = "", $prj_valide = "t", $atl_valide = "t", $ses_valide = "t", $ses_annule = "f", $sea_valide = "t", $sea_annule = "f" ){
  1292. $output = "";
  1293. if( $prj_valide != "t" || $atl_valide != "t" || $ses_valide != "t" || $sea_valide != "t" ){
  1294. $output .= "("._("invalide").")";
  1295. }
  1296. if( $ses_annule != "f" || $sea_annule != "f" ){
  1297. if( $output != "" ){
  1298. $output .= $separator;
  1299. }
  1300. $output .= "("._("annulee").")";
  1301. }
  1302. // Met une classe CSS � notre �tat si elle a �t� fournit
  1303. if( $output != "" && $classNOT != "" ){
  1304. $output = "<span class='" . $classNOT . "'>" . $output . "</span>";
  1305. }
  1306. return $output;
  1307. }
  1308. ///////////////////////////////////////////////////////////////////////////////////////
  1309. // function formatStateFormationComplete($classOK, $classNOT, $separator, $args)
  1310. // JE M'EXCUSE CETTE FONCTION EST AFFREUSE(youri). Vous pouvez la refaire si vous voulez.
  1311. // affiche l'�tat d'une fiche (projet, atelier, session, seance) en fonction si la
  1312. // fiche ou la fiche parent est annul� ou invalide ou autres.
  1313. // IN: $classOK class (pour le span) du style sheet si la fiche est valide et active
  1314. // $classNOT class (pour le span) du style sheet si la fiche est invalide ou annul�e
  1315. // $separator separateur entre les diff�rents messages de non validit�
  1316. // $prj_valide t ou f
  1317. // $atl_valide t ou f
  1318. // $ses_valide t ou f
  1319. // $ses_annule t ou f
  1320. // $sea_valide t ou f
  1321. // $sea_annule t ou f
  1322. ///////////////////////////////////////////////////////////////////////////////////////
  1323. function formatStateFormationComplete($classOK, $classNOT, $separator, $args){
  1324. //config: tableau qui fait la comparaison et affiche ce qui suit si la comparaison fit
  1325. $arrState[0]=array("f",_("projet invalide") ); // projet
  1326. $arrState[1]=array("f",_("atelier invalide") ); // atelier
  1327. $arrState[2]=array("f",_("session invalide") ); // session
  1328. $arrState[3]=array("t",_("session annulee") ); // session
  1329. $arrState[4]=array("f",_("seance invalide") ); // seance
  1330. $arrState[5]=array("t",-("seance annulee") ); // seance
  1331. $stateOK="actif";
  1332. //ne pas toucher
  1333. $MINPARAM = 3;
  1334. $ok=true;
  1335. unset($arrStateMatch);
  1336. $iMatch=0;
  1337. $args=func_get_args();
  1338. for ($i = $MINPARAM; $i < count($args); $i++){
  1339. if (!strcasecmp($args[$i], $arrState[$i-$MINPARAM][0])){
  1340. $ok=false;
  1341. $arrStateMatch[$iMatch]=$arrState[$i-$MINPARAM][1];
  1342. $iMatch++;
  1343. }
  1344. }
  1345. //le output
  1346. unset($output);
  1347. if ($ok==true){
  1348. if($classOK!=""){
  1349. $output="<span class=\"".$classOK."\">".$stateOK."</span>";
  1350. }
  1351. else{
  1352. $output=$stateOK;
  1353. }
  1354. }
  1355. else{
  1356. if (is_array($arrStateMatch)){
  1357. if($classNOT!=""){
  1358. $output="<span class=\"".$classNOT."\">".join($separator, $arrStateMatch)."</span>";
  1359. }
  1360. else{
  1361. $output=join($seperator, $arrStateMatch);
  1362. }
  1363. }
  1364. }
  1365. return $output;
  1366. }
  1367. ///////////////////////////////////////////////////////////////////////////////////////
  1368. // function formatStateAnnule($annule, $class=NULL)
  1369. // Affiche un texte si c'est annul�.
  1370. // IN: $valide: 't' si valide
  1371. ///////////////////////////////////////////////////////////////////////////////////////
  1372. function formatStateInscription( $inscriptionEtat, $classOK = "", $classNOT = "", $classHOPE = ""){
  1373. $format = '<span class="%s">%s</span>';
  1374. switch( strtolower( $inscriptionEtat ) ){
  1375. case "t" :
  1376. $etat = _("Valide");
  1377. $class = $classOK;
  1378. break;
  1379. case "f" :
  1380. $etat = _("Invalide");
  1381. $class = $classNOT;
  1382. break;
  1383. case "" :
  1384. $etat = _("A valider");
  1385. $class = $classHOPE;
  1386. break;
  1387. default :
  1388. $etat = "";
  1389. $class = "";
  1390. }
  1391. if( $class <> "" ){
  1392. $output = sprintf( $format, $class, $etat );
  1393. } else {
  1394. $output = $etat;
  1395. }
  1396. return $output;
  1397. }
  1398. ///////////////////////////////////////////////////////////////////////////////////////
  1399. // formatStateValid($valide, $class=NULL)
  1400. // Affiche un texte si c'est valide ou invalide.
  1401. // IN: $valide: 't' si valide
  1402. ///////////////////////////////////////////////////////////////////////////////////////
  1403. function formatStateValid( $valide, $class = "" ){
  1404. $output = "";
  1405. if( $valide == "f" ){
  1406. $output = "("._("invalide").")";
  1407. if( $class <> "" ){
  1408. $output = "<span class='" . $class . "'>" . $output . "</span>";
  1409. }
  1410. }
  1411. return $output;
  1412. }
  1413. ///////////////////////////////////////////////////////////////////////////////////////
  1414. // function formatTelephone($sTel, $countryCode = "ca")
  1415. // formate la sortie pour qu'on puisse afficher le num�ro tel�phone
  1416. // IN: $sTel: no de tel
  1417. // OUT: (string) le r�sultat du telephone une fois format�
  1418. ///////////////////////////////////////////////////////////////////////////////////////
  1419. function formatTelephone($sTel){
  1420. global $cfgCountry;
  1421. $output=$sTel;
  1422. switch ($cfgCountry){
  1423. case "us":
  1424. case "ca":
  1425. if (ereg("^[^0-9]*"."([0-9]{3})"."[^0-9]*"."([0-9]{3})"."[^0-9]*"."([0-9]{4})"."[^0-9]*"."([0-9]*)$", $sTel, $regs)){
  1426. if ($regs[4]!=""){
  1427. $output = "(".$regs[1].") ".$regs[2]."-".$regs[3]." ext:".$regs[4];
  1428. } else {
  1429. $output = "(".$regs[1].") ".$regs[2]."-".$regs[3];
  1430. }
  1431. }
  1432. break;
  1433. default:
  1434. break;
  1435. }
  1436. return $output;
  1437. }
  1438. ///////////////////////////////////////////////////////////////////////////////////////
  1439. // function generatePassword($nbLen, $numPercent, $bUseCase=false)
  1440. // Retourne le mot de passe g�n�r� automatiquement
  1441. // m�thode tient compte de ne pas s�parer les mot entre guillemet
  1442. // IN: $nbLen longueur d�sir� du mot de passe
  1443. // $numPercent pourcentage des chances que le char soit un nombre
  1444. // $bUseCase est-ce qu'on veut utiliser le case dans les lettres
  1445. // OUT: (string) mot de passe
  1446. ///////////////////////////////////////////////////////////////////////////////////////
  1447. function generatePassword($nbLen, $numPercent, $bUseCase=false){
  1448. unset($psw);
  1449. for($i=0; $i<$nbLen; $i++){
  1450. if (rand(0,100)<$numPercent){
  1451. //on met un chiffre
  1452. $char = chr(rand(48,57));
  1453. }
  1454. else{
  1455. if ($bUseCase){
  1456. if (rand(0,1)==0){
  1457. //on met une lettre minuscule
  1458. $char = chr(rand(97,122));
  1459. }
  1460. else{
  1461. //on met une lettre majuscule
  1462. $char = chr(rand(65,90));
  1463. }
  1464. }
  1465. else{
  1466. //on met une lettre minuscule
  1467. $char = chr(rand(97,122));
  1468. }
  1469. }
  1470. $psw.=$char;
  1471. }
  1472. return ($psw);
  1473. }
  1474. ///////////////////////////////////////////////////////////////////////////////////////
  1475. // getArrayFromStringMot($sQuery)
  1476. // Retourne le tableau contenant les diff�rents mot pour le moteur de recherche. Cette
  1477. // m�thode tient compte de ne pas s�parer les mot entre guillemet
  1478. // IN: $sQuery: string de requ�te fait sur la page web
  1479. // OUT: (array) tableau contenant chaque mot de la requ�te dans un �l�ments
  1480. ///////////////////////////////////////////////////////////////////////////////////////
  1481. function getArrayFromStringMot( $sQuery ){
  1482. // Retourne la liste de tous les �l�ments qui sont entour�s par des guillemets doubles OU qui sont des mots
  1483. $nb_match = preg_match_all( "(\"[^\"]+\"|\w+)", $sQuery, $list );
  1484. // Pour chaque �l�ment, remplace les guillemets par rien
  1485. foreach( $list[ 0 ] as $id => $element ){
  1486. $list[ 0 ][ $id ] = str_replace( "\"", "", $list[ 0 ][ $id ] );
  1487. }
  1488. // 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
  1489. return $list[ 0 ];
  1490. }
  1491. ///////////////////////////////////////////////////////////////////////////////////////
  1492. // function getMaxStrlenFromArray($arrTemp)
  1493. // Retourne le plus grand strlen de tous les �l�ments du tableaux
  1494. // IN: $arrTemp tableau � parser
  1495. // OUT: (integer) la plus grand strlen des �l�ments du tableau
  1496. ///////////////////////////////////////////////////////////////////////////////////////
  1497. function getMaxStrlenFromArray($arrTemp){
  1498. $themax = 0;
  1499. for ($i=0; $i<count($arrTemp); $i++){
  1500. $temp = strlen($arrTemp[$i]);
  1501. if($temp>$themax){
  1502. $themax = $temp;
  1503. }
  1504. }
  1505. return ($themax);
  1506. }
  1507. ///////////////////////////////////////////////////////////////////////////////////////
  1508. // function getMoney($sInput)
  1509. // Retourne un nombre avec deux d�cimales. On enl�ve toutes les currency. On veut rien
  1510. // savoir. Comme �a tout le monde (international) est content!
  1511. // voici le format comme on le veut : XXXXXXX.XX (x = [0-9])
  1512. // IN: $sInput: le montant � v�rifier
  1513. // OUT: si le nombre est valide:
  1514. ///////////////////////////////////////////////////////////////////////////////////////
  1515. function getMoney($sInput){
  1516. if (ereg("([0-9]*[.]{0,1}[0-9]{1,2})",$sInput,$regs)){
  1517. return ($regs[1]);
  1518. }
  1519. return (0);
  1520. }
  1521. ///////////////////////////////////////////////////////////////////////////////////////
  1522. // Retourne un string HTML contenant les textbox pour un noTel
  1523. ///////////////////////////////////////////////////////////////////////////////////////
  1524. function getTBTelephone($tbName, $sTel, $bExt, $class, $jsOnChange){
  1525. global $cfgCountry;
  1526. $output = "<input class=\"".$class."\" type=\"hidden\" name=\"".$tbName."\" value=\"".formatHTML($sTel)."\" />";
  1527. switch ($cfgCountry){
  1528. case "us":
  1529. case "ca":
  1530. $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;
  1531. ereg("^[^0-9]*"."([0-9]{3})"."[^0-9]*"."([0-9]{3})"."[^0-9]*"."([0-9]{4})"."[^0-9]*"."([0-9]*)$", $sTel, $regs);
  1532. $output .= "( ";
  1533. $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(); }\" />";
  1534. $output .= " ) ";
  1535. $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(); }\" />";
  1536. $output .= " - ";
  1537. $output .= "<input class=\"".$class."\" type=\"text\" name=\"".$tbName."_3\" value=\"".$regs[3]."\" size=\"4\" maxlength=\"4\" onchange=\"".$jsOnchange."\" onfocus=\"select(this);\" />";
  1538. if ($bExt){
  1539. $output .= " ext:";
  1540. $output .= "<input class=\"".$class."\" type=\"text\" name=\"".$tbName."_4\" value=\"".$regs[4]."\" size=\"4\" maxlength=\"4\" onchange=\"".$jsOnchange."\" onfocus=\"select(this);\" />";
  1541. } else {
  1542. $output .= "<input class=\"".$class."\" type=\"hidden\" name=\"".$tbName."_4\" value=\"".$regs[4]."\" />";
  1543. }
  1544. break;
  1545. default:
  1546. $output = _("Code d'identification du pays inconnu");
  1547. break;
  1548. }
  1549. return $output;
  1550. }
  1551. ///////////////////////////////////////////////////////////////////////////////////////
  1552. // function getQueryStringUpdated($querystring)
  1553. // Modifie le querystring en fonction des variables et valeurs fournies en param�tres
  1554. // Si la variable en param�tre existe d�j� dans le querystring, sa valeur sera modifi�e
  1555. // pour la nouvelle valeur sp�cifi�e. Si la variable n'existe pas, alors le champs sera
  1556. // ajouter au querystring avec la valeur soumissionn�e.
  1557. // ex: newQS = getQueryStringUpdated($HTTP_SERVER_VARS["QUERY_STRING"], "mode", "edit");
  1558. // IN: $querystring: le querystring actuel (ex:"mode=display&pg=1&indx=alpha")
  1559. // $var1: variable dans le querystring qu'on veux ajouter au modifier (ex: "mode")
  1560. // $val1: valeur � mettre dans la premi�re variable (ex: "edit")
  1561. // $var2: 2e variable � modifier ou ajouter
  1562. // $val2: valeur de la 2e variable
  1563. // $varX: Xe variable � modifier ou ajouter
  1564. // $valX: valeur de la Xe variable
  1565. // OUT: (querystringNew) le nouveau querystring
  1566. ///////////////////////////////////////////////////////////////////////////////////////
  1567. function getQueryStringUpdated( $query_string ){
  1568. // Enl�ve les ? du d�but de la string
  1569. while( isset( $query_string[ 0 ] ) && $query_string[ 0 ] == "?" ){
  1570. $query_string = substr( $query_string, 1 );
  1571. }
  1572. // Fait la liste de tous les �l�ments GET de l'URL
  1573. $query_tab = explode( "&", $query_string );
  1574. $list_elements = array();
  1575. foreach( $query_tab as $element ){
  1576. list( $nom, $valeur ) = explode( "=", $element );
  1577. if( $valeur <> "" ){
  1578. $list_elements[ $nom ] = $valeur;
  1579. }
  1580. }
  1581. // On passe par-dessus le premier parce que c'est QUERY_STRING
  1582. $num_args = func_num_args();
  1583. for( $i = 1; $i < $num_args; $i = $i + 2 ){
  1584. // Fetch les informations de l'argument
  1585. $nom_arg = urlencode( func_get_arg( $i ) );
  1586. if( $num_args >= ( $i + 1 ) ){
  1587. $val_arg = urlencode( func_get_arg( $i + 1 ) );
  1588. } else {
  1589. $val_arg = "";
  1590. }
  1591. $list_elements[ $nom_arg ] = $val_arg;
  1592. }
  1593. // B�tit la string � retourner
  1594. $query_string = "";
  1595. $premier_element = true;
  1596. foreach( $list_elements as $nom => $valeur ){
  1597. if( !$premier_element ){
  1598. $query_string .= "&";
  1599. } else {
  1600. $premier_element = false;
  1601. }
  1602. $query_string .= $nom . "=" . $valeur;
  1603. }
  1604. return $query_string;
  1605. }
  1606. ///////////////////////////////////////////////////////////////////////////////////////
  1607. // Retourne la requete SQL necessaire pour faire un DELETE
  1608. ///////////////////////////////////////////////////////////////////////////////////////
  1609. function getSQLStmtDelActivite($act_id){
  1610. $SQLStmt="DELETE FROM activite";
  1611. $SQLStmt.=" WHERE act_id=".$act_id;
  1612. return $SQLStmt;
  1613. }
  1614. ///////////////////////////////////////////////////////////////////////////////////////
  1615. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1616. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1617. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1618. ///////////////////////////////////////////////////////////////////////////////////////
  1619. function getSQLStmtDelActiviteArray($arrnTemp){
  1620. $SQLStmt="DELETE FROM activite";
  1621. $SQLStmt.=" WHERE act_id<>act_id";
  1622. for ($i=0; $i<=count($arrnTemp); $i++){
  1623. if (is_numeric($arrnTemp[$i])){
  1624. $SQLStmt.=" OR act_id=".$arrnTemp[$i];
  1625. }
  1626. }
  1627. return $SQLStmt;
  1628. }
  1629. ///////////////////////////////////////////////////////////////////////////////////////
  1630. // Retourne la requete SQL necessaire pour faire un DELETE
  1631. ///////////////////////////////////////////////////////////////////////////////////////
  1632. function getSQLStmtDelActiviteFromProjet($prj_id){
  1633. $SQLStmt="DELETE FROM activite";
  1634. $SQLStmt.=" WHERE prj_id=".$prj_id;
  1635. return $SQLStmt;
  1636. }
  1637. ///////////////////////////////////////////////////////////////////////////////////////
  1638. // Retourne la requete SQL necessaire pour faire un DELETE
  1639. ///////////////////////////////////////////////////////////////////////////////////////
  1640. function getSQLStmtDelAtelier($atl_id){
  1641. $SQLStmt="DELETE FROM atelier";
  1642. $SQLStmt.=" WHERE atl_id=".$atl_id;
  1643. return $SQLStmt;
  1644. }
  1645. ///////////////////////////////////////////////////////////////////////////////////////
  1646. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1647. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1648. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1649. ///////////////////////////////////////////////////////////////////////////////////////
  1650. function getSQLStmtDelAtelierArray($arrnTemp){
  1651. $SQLStmt = "Delete From atelier a Where a.atl_id <> a.atl_id";
  1652. foreach( $arrnTemp as $atl_id ) {
  1653. if( is_numeric( $atl_id ) ){
  1654. $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 ) )";
  1655. }
  1656. }
  1657. return $SQLStmt;
  1658. }
  1659. ///////////////////////////////////////////////////////////////////////////////////////
  1660. // Retourne la requete SQL necessaire pour faire un DELETE
  1661. ///////////////////////////////////////////////////////////////////////////////////////
  1662. function getSQLStmtDelAtelierClasse($atl_id){
  1663. $SQLStmt="DELETE FROM atelier_classe";
  1664. $SQLStmt.=" WHERE atl_id=".$atl_id;
  1665. return $SQLStmt;
  1666. }
  1667. ///////////////////////////////////////////////////////////////////////////////////////
  1668. // Retourne la requete SQL necessaire pour faire un DELETE
  1669. ///////////////////////////////////////////////////////////////////////////////////////
  1670. function getSQLStmtDelAtelierClientele($atl_id){
  1671. $SQLStmt="DELETE FROM atelier_clientele";
  1672. $SQLStmt.=" WHERE atl_id=".$atl_id;
  1673. return $SQLStmt;
  1674. }
  1675. ///////////////////////////////////////////////////////////////////////////////////////
  1676. // Retourne la requete SQL necessaire pour faire un DELETE
  1677. ///////////////////////////////////////////////////////////////////////////////////////
  1678. function getSQLStmtDelAtelierExpertise($atl_id){
  1679. $SQLStmt="DELETE FROM atelier_expertise";
  1680. $SQLStmt.=" WHERE atl_id=".$atl_id;
  1681. return $SQLStmt;
  1682. }
  1683. ///////////////////////////////////////////////////////////////////////////////////////
  1684. // Retourne la requete SQL necessaire pour faire un DELETE
  1685. ///////////////////////////////////////////////////////////////////////////////////////
  1686. function getSQLStmtDelAtelierProjet($atl_id){
  1687. $SQLStmt="DELETE FROM projet_atelier";
  1688. $SQLStmt.=" WHERE atl_id=".$atl_id;
  1689. return $SQLStmt;
  1690. }
  1691. ///////////////////////////////////////////////////////////////////////////////////////
  1692. // Retourne la requete SQL necessaire pour faire un DELETE
  1693. ///////////////////////////////////////////////////////////////////////////////////////
  1694. function getSQLStmtDelCedule($ced_id){
  1695. $SQLStmt="DELETE FROM ceduleur";
  1696. $SQLStmt.=" WHERE ced_id=".$ced_id;
  1697. return $SQLStmt;
  1698. }
  1699. ///////////////////////////////////////////////////////////////////////////////////////
  1700. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1701. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1702. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1703. ///////////////////////////////////////////////////////////////////////////////////////
  1704. function getSQLStmtDelCeduleArray($arrnTemp){
  1705. $SQLStmt="DELETE FROM ceduleur";
  1706. $SQLStmt.=" WHERE ced_id<>ced_id";
  1707. for ($i=0; $i<=count($arrnTemp); $i++){
  1708. if (is_numeric($arrnTemp[$i])){
  1709. $SQLStmt.=" OR ced_id=".$arrnTemp[$i];
  1710. }
  1711. }
  1712. return $SQLStmt;
  1713. }
  1714. ///////////////////////////////////////////////////////////////////////////////////////
  1715. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1716. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1717. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1718. ///////////////////////////////////////////////////////////////////////////////////////
  1719. function getSQLStmtDelClasseArray($arrnTemp){
  1720. return (getSQLStmtDelNodeArray($arrnTemp));
  1721. }
  1722. ///////////////////////////////////////////////////////////////////////////////////////
  1723. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1724. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1725. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1726. ///////////////////////////////////////////////////////////////////////////////////////
  1727. /* $Author: stacil $ [$Date: 2008/07/03 18:29:46 $]
  1728. function getSQLStmtDelClienteleArray($arrnTemp){
  1729. $SQLStmt="DELETE FROM clientele";
  1730. $SQLStmt.=" WHERE cli_id<>cli_id";
  1731. for ($i=0; $i<=count($arrnTemp); $i++){
  1732. if ($arrnTemp[$i]!="" && is_numeric($arrnTemp[$i])){
  1733. $SQLStmt.=" OR cli_id=".$arrnTemp[$i];
  1734. }
  1735. }
  1736. return $SQLStmt;
  1737. }
  1738. */
  1739. function getSQLStmtDelClienteleArray($arrnTemp){
  1740. return (getSQLStmtDelNodeArray($arrnTemp));
  1741. }
  1742. ///////////////////////////////////////////////////////////////////////////////////////
  1743. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1744. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1745. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1746. ///////////////////////////////////////////////////////////////////////////////////////
  1747. function getSQLStmtDelExpertiseArray($arrnTemp){
  1748. return (getSQLStmtDelNodeArray($arrnTemp));
  1749. }
  1750. ///////////////////////////////////////////////////////////////////////////////////////
  1751. // Retourne la requete SQL necessaire pour faire un DELETE
  1752. ///////////////////////////////////////////////////////////////////////////////////////
  1753. function getSQLStmtDelGabarit($gab_id){
  1754. $SQLStmt="DELETE FROM gabarit";
  1755. $SQLStmt.=" WHERE gab_id=".$gab_id;
  1756. $SQLStmt.=" AND gab_system='f'";
  1757. return $SQLStmt;
  1758. }
  1759. ///////////////////////////////////////////////////////////////////////////////////////
  1760. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1761. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1762. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1763. ///////////////////////////////////////////////////////////////////////////////////////
  1764. function getSQLStmtDelGabaritArray($arrnTemp){
  1765. $SQLStmt="DELETE FROM gabarit";
  1766. $SQLStmt.=" WHERE gab_id<>gab_id";
  1767. for ($i=0; $i<=count($arrnTemp); $i++){
  1768. if (is_numeric($arrnTemp[$i])){
  1769. $SQLStmt.=" OR (gab_id=".$arrnTemp[$i];
  1770. $SQLStmt.=" AND gab_system='f')";
  1771. }
  1772. }
  1773. return $SQLStmt;
  1774. }
  1775. ///////////////////////////////////////////////////////////////////////////////////////
  1776. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1777. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1778. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1779. ///////////////////////////////////////////////////////////////////////////////////////
  1780. function getSQLStmtDelGabaritBaliseArray($gab_id, $arrnTemp){
  1781. $SQLStmt="DELETE FROM gabaritBalise";
  1782. $SQLStmt.=" WHERE gab_id = ".$gab_id;
  1783. $SQLStmt.=" AND ( gb_id <> gb_id";
  1784. for ($i=0; $i<=count($arrnTemp); $i++){
  1785. if ($arrnTemp[$i]!="" && is_numeric($arrnTemp[$i])){
  1786. $SQLStmt.=" OR gb_id=".$arrnTemp[$i];
  1787. }
  1788. }
  1789. $SQLStmt.=")";
  1790. return $SQLStmt;
  1791. }
  1792. ///////////////////////////////////////////////////////////////////////////////////////
  1793. // Retourne la requete SQL necessaire pour valider si la premiere seance de la
  1794. // session est depassee
  1795. // Ajout� par Francine Bolduc le 2 mars 2010
  1796. ///////////////////////////////////////////////////////////////////////////////////////
  1797. function getSQLStmtReqSessionTermineBySesId($ses_id){
  1798. $SQLStmt = "";
  1799. if( is_numeric( $ses_id ) && $ses_id != null){
  1800. $SQLStmt = "SELECT MIN(SUBSTR(sea_datedebut::text,1,10)) as db
  1801. FROM seance
  1802. WHERE ses_id = '" . $ses_id . "'" . " AND sea_valide='t'";
  1803. }
  1804. return $SQLStmt;
  1805. }
  1806. ///////////////////////////////////////////////////////////////////////////////////////
  1807. // Retourne la requete SQL necessaire pour faire un DELETE
  1808. ///////////////////////////////////////////////////////////////////////////////////////
  1809. function getSQLStmtDelInscription($usrid, $sesid){
  1810. $SQLStmt="DELETE FROM inscriptionSession";
  1811. $SQLStmt.=" WHERE usr_id=".$usrid;
  1812. $SQLStmt.=" AND ses_id=".$sesid;
  1813. return $SQLStmt;
  1814. }
  1815. ///////////////////////////////////////////////////////////////////////////////////////
  1816. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1817. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1818. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1819. ///////////////////////////////////////////////////////////////////////////////////////
  1820. function getSQLStmtDelInscriptionArray($arrnTemp){
  1821. $SQLStmt="DELETE FROM inscriptionSession";
  1822. $SQLStmt.=" WHERE ses_id<>ses_id";
  1823. for ($i=0; $i<=count($arrnTemp); $i++){
  1824. ereg("^([0-9]+)[.]{1}([0-9]+)$",$arrnTemp[$i],$regs);
  1825. $usager=$regs[1];
  1826. $session=$regs[2];
  1827. if ((is_numeric($usager))&&(is_numeric($session))){
  1828. $SQLStmt.=" OR ( usr_id=".$usager;
  1829. $SQLStmt.=" AND ses_id=".$session.")";
  1830. }
  1831. }
  1832. return $SQLStmt;
  1833. }
  1834. ///////////////////////////////////////////////////////////////////////////////////////
  1835. // Retourne la requete SQL necessaire pour faire un DELETE
  1836. ///////////////////////////////////////////////////////////////////////////////////////
  1837. function getSQLStmtDelLieu($li_id){
  1838. $SQLStmt="DELETE FROM lieu";
  1839. $SQLStmt.=" WHERE li_id=".$li_id;
  1840. return $SQLStmt;
  1841. }
  1842. ///////////////////////////////////////////////////////////////////////////////////////
  1843. // Retourne la requete SQL necessaire pour faire un DELETE
  1844. ///////////////////////////////////////////////////////////////////////////////////////
  1845. function getSQLStmtDelLieuAdmin($li_id){
  1846. $SQLStmt="DELETE FROM lieuAdmin";
  1847. $SQLStmt.=" WHERE li_id=".$li_id;
  1848. return $SQLStmt;
  1849. }
  1850. ///////////////////////////////////////////////////////////////////////////////////////
  1851. // Retourne la requete SQL necessaire pour faire un DELETE
  1852. ///////////////////////////////////////////////////////////////////////////////////////
  1853. function getSQLStmtDelLieuSupport($li_id){
  1854. $SQLStmt="DELETE FROM lieuSupport";
  1855. $SQLStmt.=" WHERE li_id=".$li_id;
  1856. return $SQLStmt;
  1857. }
  1858. ///////////////////////////////////////////////////////////////////////////////////////
  1859. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1860. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1861. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1862. ///////////////////////////////////////////////////////////////////////////////////////
  1863. function getSQLStmtDelLieuArray($arrnTemp){
  1864. $SQLStmt="DELETE FROM lieu";
  1865. $SQLStmt.=" WHERE li_id<>li_id";
  1866. for ($i=0; $i<=count($arrnTemp); $i++){
  1867. if (is_numeric($arrnTemp[$i])){
  1868. $SQLStmt.=" OR li_id=".$arrnTemp[$i];
  1869. }
  1870. }
  1871. return $SQLStmt;
  1872. }
  1873. ///////////////////////////////////////////////////////////////////////////////////////
  1874. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1875. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1876. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1877. ///////////////////////////////////////////////////////////////////////////////////////
  1878. function getSQLStmtDelNodeArray($arrnTemp){
  1879. $SQLStmt="DELETE FROM nodes";
  1880. $SQLStmt.=" WHERE node<>node";
  1881. for ($i=0; $i<=count($arrnTemp); $i++){
  1882. if (is_numeric($arrnTemp[$i])){
  1883. $SQLStmt.=" OR node=".$arrnTemp[$i];
  1884. }
  1885. }
  1886. return $SQLStmt;
  1887. }
  1888. ///////////////////////////////////////////////////////////////////////////////////////
  1889. // Retourne la requete SQL necessaire pour faire un DELETE
  1890. ///////////////////////////////////////////////////////////////////////////////////////
  1891. function getSQLStmtDelPresence($sea_id){
  1892. $SQLStmt="DELETE FROM presence";
  1893. $SQLStmt.=" WHERE sea_id=".$sea_id;
  1894. return $SQLStmt;
  1895. }
  1896. function getSQLStmtDelProjetAdmin($prj_id){
  1897. $SQLStmt="DELETE FROM projetAdmin";
  1898. $SQLStmt.=" WHERE prj_id=".$prj_id;
  1899. return $SQLStmt;
  1900. }
  1901. ///////////////////////////////////////////////////////////////////////////////////////
  1902. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1903. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1904. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1905. ///////////////////////////////////////////////////////////////////////////////////////
  1906. function getSQLStmtDelProjetArray($arrnTemp){
  1907. $SQLStmt="DELETE FROM projet";
  1908. $SQLStmt.=" WHERE prj_id<>prj_id";
  1909. for ($i=0; $i<=count($arrnTemp); $i++){
  1910. if (is_numeric($arrnTemp[$i])){
  1911. $SQLStmt.=" OR prj_id=".$arrnTemp[$i];
  1912. }
  1913. }
  1914. return $SQLStmt;
  1915. }
  1916. ///////////////////////////////////////////////////////////////////////////////////////
  1917. // Retourne la requete SQL necessaire pour faire un DELETE
  1918. ///////////////////////////////////////////////////////////////////////////////////////
  1919. function getSQLStmtDelSeance($sea_id){
  1920. $SQLStmt="DELETE FROM seance";
  1921. $SQLStmt.=" WHERE sea_id=".$sea_id;
  1922. return $SQLStmt;
  1923. }
  1924. ///////////////////////////////////////////////////////////////////////////////////////
  1925. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1926. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1927. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1928. ///////////////////////////////////////////////////////////////////////////////////////
  1929. function getSQLStmtDelSeanceArray($arrnTemp){
  1930. $SQLStmt="DELETE FROM seance";
  1931. $SQLStmt.=" WHERE sea_id<>sea_id";
  1932. for ($i=0; $i<=count($arrnTemp); $i++){
  1933. if (is_numeric($arrnTemp[$i])){
  1934. $SQLStmt.=" OR sea_id=".$arrnTemp[$i];
  1935. }
  1936. }
  1937. return $SQLStmt;
  1938. }
  1939. ///////////////////////////////////////////////////////////////////////////////////////
  1940. // Retourne la requete SQL necessaire pour faire un DELETE
  1941. ///////////////////////////////////////////////////////////////////////////////////////
  1942. function getSQLStmtDelSession($ses_id){
  1943. $SQLStmt="DELETE FROM session";
  1944. $SQLStmt.=" WHERE ses_id=".$ses_id;
  1945. return $SQLStmt;
  1946. }
  1947. ///////////////////////////////////////////////////////////////////////////////////////
  1948. // Retourne la requete SQL necessaire pour faire un DELETE
  1949. ///////////////////////////////////////////////////////////////////////////////////////
  1950. function getSQLStmtDelSessionAnimation($ses_id){
  1951. $SQLStmt="DELETE FROM animation";
  1952. $SQLStmt.=" WHERE ses_id=".$ses_id;
  1953. return $SQLStmt;
  1954. }
  1955. ///////////////////////////////////////////////////////////////////////////////////////
  1956. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1957. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1958. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1959. ///////////////////////////////////////////////////////////////////////////////////////
  1960. function getSQLStmtDelSessionArray($arrnTemp){
  1961. $SQLStmt="DELETE FROM session";
  1962. $SQLStmt.=" WHERE ses_id<>ses_id";
  1963. for ($i=0; $i<=count($arrnTemp); $i++){
  1964. if (is_numeric($arrnTemp[$i])){
  1965. $SQLStmt.=" OR ses_id=".$arrnTemp[$i];
  1966. }
  1967. }
  1968. return $SQLStmt;
  1969. }
  1970. ///////////////////////////////////////////////////////////////////////////////////////
  1971. // Retourne la requete SQL necessaire pour faire un DELETE
  1972. ///////////////////////////////////////////////////////////////////////////////////////
  1973. function getSQLStmtDelUsager($usr_id){
  1974. $SQLStmt="DELETE FROM usager";
  1975. $SQLStmt.=" WHERE usr_id=".$usr_id;
  1976. return $SQLStmt;
  1977. }
  1978. ///////////////////////////////////////////////////////////////////////////////////////
  1979. // Retourne la requete SQL necessaire pour faire un DELETE sur un ARRAY
  1980. // IN: $arrnTemp: tableau contenant les ID a supprimer
  1981. // OUT: (sqlstmt) requ�te sql effectuant la supression
  1982. ///////////////////////////////////////////////////////////////////////////////////////
  1983. function getSQLStmtDelUsagerArray($arrnTemp){
  1984. $SQLStmt="DELETE FROM usager";
  1985. $SQLStmt.=" WHERE usr_id<>usr_id";
  1986. for ($i=0; $i<=count($arrnTemp); $i++){
  1987. if (is_numeric($arrnTemp[$i])){
  1988. $SQLStmt.=" OR usr_id=".$arrnTemp[$i];
  1989. }
  1990. }
  1991. return $SQLStmt;
  1992. }
  1993. ///////////////////////////////////////////////////////////////////////////////////////
  1994. // Retourne la requete SQL necessaire pour faire un DELETE
  1995. ///////////////////////////////////////////////////////////////////////////////////////
  1996. function getSQLStmtDelUsagerUsrTypeArray($usr_id, $arrnTemp){
  1997. $SQLStmt="DELETE FROM usager_usagerType";
  1998. $SQLStmt.=" WHERE usr_id=".$usr_id;
  1999. $SQLStmt.=" AND (ut_id<>ut_id";
  2000. for ($i=0; $i<=count($arrnTemp); $i++){
  2001. if (is_numeric($arrnTemp[$i])){
  2002. $SQLStmt.=" OR ut_id=".$arrnTemp[$i];
  2003. }
  2004. }
  2005. $SQLStmt.=")";
  2006. return $SQLStmt;
  2007. }
  2008. ///////////////////////////////////////////////////////////////////////////////////////
  2009. // Retourne la requete SQL necessaire pour faire un INSERT
  2010. ///////////////////////////////////////////////////////////////////////////////////////
  2011. function getSQLStmtInsActivite($act_activite, $prj_id){
  2012. $SQLStmt="INSERT INTO activite";
  2013. $SQLField="(";
  2014. $SQLValue="VALUES(";
  2015. $SQLField.="act_activite,";
  2016. $SQLValue.="'".fixPGQuote($act_activite)."',";
  2017. $SQLField.="prj_id)";
  2018. if (is_numeric($prj_id)){
  2019. $SQLValue.=$prj_id.")";
  2020. }
  2021. else{
  2022. $SQLValue.="NULL)";
  2023. }
  2024. //Building SQLStmt
  2025. $SQLStmt.=$SQLField.$SQLValue;
  2026. return ($SQLStmt);
  2027. }
  2028. ///////////////////////////////////////////////////////////////////////////////////////
  2029. // Retourne la requete SQL necessaire pour faire un INSERT
  2030. ///////////////////////////////////////////////////////////////////////////////////////
  2031. function getSQLStmtInsAtelier($atl_atelier){
  2032. $SQLStmt="INSERT INTO atelier";
  2033. $SQLField="(";
  2034. $SQLValue="VALUES(";
  2035. $SQLField.="atl_atelier)";
  2036. $SQLValue.="'".fixPGQuote($atl_atelier)."')";
  2037. //Building SQLStmt
  2038. $SQLStmt.=$SQLField.$SQLValue;
  2039. return ($SQLStmt);
  2040. }
  2041. ///////////////////////////////////////////////////////////////////////////////////////
  2042. // Retourne la requete SQL necessaire pour faire un INSERT
  2043. ///////////////////////////////////////////////////////////////////////////////////////
  2044. function getSQLStmtInsAtelierClasse($atl_id, $cla_id){
  2045. $SQLStmt="INSERT INTO atelier_classe";
  2046. $SQLField="(";
  2047. $SQLValue="VALUES(";
  2048. $SQLField.="atl_id,";
  2049. $SQLValue.=$atl_id.",";
  2050. $SQLField.="cla_id)";
  2051. $SQLValue.=$cla_id.")";
  2052. //Building SQLStmt
  2053. $SQLStmt.=$SQLField.$SQLValue;
  2054. return ($SQLStmt);
  2055. }
  2056. ///////////////////////////////////////////////////////////////////////////////////////
  2057. // Retourne la requete SQL necessaire pour faire un INSERT
  2058. ///////////////////////////////////////////////////////////////////////////////////////
  2059. function getSQLStmtInsAtelierClientele($atl_id, $cli_id){
  2060. $SQLStmt="INSERT INTO atelier_clientele";
  2061. $SQLField="(";
  2062. $SQLValue="VALUES(";
  2063. $SQLField.="atl_id,";
  2064. $SQLValue.=$atl_id.",";
  2065. $SQLField.="cli_id)";
  2066. $SQLValue.=$cli_id.")";
  2067. //Building SQLStmt
  2068. $SQLStmt.=$SQLField.$SQLValue;
  2069. return ($SQLStmt);
  2070. }
  2071. ///////////////////////////////////////////////////////////////////////////////////////
  2072. // Retourne la requete SQL necessaire pour faire un INSERT
  2073. ///////////////////////////////////////////////////////////////////////////////////////
  2074. function getSQLStmtInsAtelierExpertise($atl_id, $exp_id){
  2075. $SQLStmt="INSERT INTO atelier_expertise";
  2076. $SQLField="(";
  2077. $SQLValue="VALUES(";
  2078. $SQLField.="atl_id,";
  2079. $SQLValue.=$atl_id.",";
  2080. $SQLField.="exp_id)";
  2081. $SQLValue.=$exp_id.")";
  2082. //Building SQLStmt
  2083. $SQLStmt.=$SQLField.$SQLValue;
  2084. return ($SQLStmt);
  2085. }
  2086. ///////////////////////////////////////////////////////////////////////////////////////
  2087. // Retourne la requete SQL necessaire pour faire un INSERT
  2088. ///////////////////////////////////////////////////////////////////////////////////////
  2089. function getSQLStmtInsAtelierProjet($atl_id, $prj_id){
  2090. $SQLStmt="INSERT INTO projet_atelier";
  2091. $SQLField="(";
  2092. $SQLValue="VALUES(";
  2093. $SQLField.="atl_id,";
  2094. $SQLValue.=$atl_id.",";
  2095. $SQLField.="prj_id)";
  2096. $SQLValue.=$prj_id.")";
  2097. //Building SQLStmt
  2098. $SQLStmt.=$SQLField.$SQLValue;
  2099. return ($SQLStmt);
  2100. }
  2101. ///////////////////////////////////////////////////////////////////////////////////////
  2102. // Retourne la requete SQL necessaire pour faire un INSERT
  2103. ///////////////////////////////////////////////////////////////////////////////////////
  2104. function getSQLStmtInsCedule($ced_cedule, $gab_id){
  2105. $SQLStmt="INSERT INTO ceduleur";
  2106. $SQLField="(";
  2107. $SQLValue="VALUES(";
  2108. $SQLField.="ced_cedule,";
  2109. $SQLValue.="'".fixPGQuote($ced_cedule)."',";
  2110. $SQLField.="gab_id)";
  2111. $SQLValue.=$gab_id.")";
  2112. //Building SQLStmt
  2113. $SQLStmt.=$SQLField.$SQLValue;
  2114. return ($SQLStmt);
  2115. }
  2116. ///////////////////////////////////////////////////////////////////////////////////////
  2117. // Retourne la requete SQL necessaire pour faire un INSERT
  2118. ///////////////////////////////////////////////////////////////////////////////////////
  2119. function getSQLStmtInsClasse($parent, $label){
  2120. return (getSQLStmtInsNode(1, $parent, $label));
  2121. }
  2122. ///////////////////////////////////////////////////////////////////////////////////////
  2123. // Retourne la requete SQL necessaire pour faire un INSERT
  2124. ///////////////////////////////////////////////////////////////////////////////////////
  2125. /* $Author: stacil $ [$Date: 2008/07/03 18:29:46 $]
  2126. function getSQLStmtInsClientele($cli_clientele, $cli_description){
  2127. $SQLStmt="INSERT INTO clientele";
  2128. $SQLField="(";
  2129. $SQLValue="VALUES(";
  2130. $SQLField=$SQLField."cli_clientele,";
  2131. $SQLValue=$SQLValue."'".fixPGQuote($cli_clientele)."',";
  2132. $SQLField=$SQLField."cli_description)";
  2133. $SQLValue=$SQLValue."'".fixPGQuote($cli_description)."')";
  2134. //Building SQLStmt
  2135. $SQLStmt.=$SQLField.$SQLValue;
  2136. return $SQLStmt;
  2137. }
  2138. */
  2139. function getSQLStmtInsClientele($parent, $label) {
  2140. return (getSQLStmtInsNode(3, $parent, $label));
  2141. }
  2142. ///////////////////////////////////////////////////////////////////////////////////////
  2143. // Retourne la requete SQL necessaire pour faire un INSERT
  2144. ///////////////////////////////////////////////////////////////////////////////////////
  2145. function getSQLStmtInsCourriel($gab_id, $cou_paramValeur){
  2146. // cou_paramValeur = no_fiche_session,id_usager (SSSSS,UUUUU)
  2147. return "INSERT INTO courriel ( gab_id, cou_paramValeur ) VALUES ( '" . $gab_id."'," . "'" . fixPGQuote( $cou_paramValeur ) . "')";
  2148. }
  2149. ///////////////////////////////////////////////////////////////////////////////////////
  2150. // Retourne la requete SQL necessaire pour faire un INSERT
  2151. ///////////////////////////////////////////////////////////////////////////////////////
  2152. function getSQLStmtInsGabarit($gab_gabarit){
  2153. $SQLStmt="INSERT INTO gabarit";
  2154. $SQLField="(";
  2155. $SQLValue="VALUES(";
  2156. $SQLField.="gab_gabarit)";
  2157. $SQLValue.="'".fixPGQuote($gab_gabarit)."')";
  2158. //Building SQLStmt
  2159. $SQLStmt.=$SQLField.$SQLValue;
  2160. return ($SQLStmt);
  2161. }
  2162. ///////////////////////////////////////////////////////////////////////////////////////
  2163. // Retourne la requete SQL necessaire pour faire un INSERT
  2164. ///////////////////////////////////////////////////////////////////////////////////////
  2165. function getSQLStmtInsGabaritBalise($gab_id, $gb_balise, $gb_champ, $gb_description){
  2166. $SQLStmt="INSERT INTO gabaritBalise";
  2167. $SQLField="(";
  2168. $SQLValue="VALUES(";
  2169. $SQLField=$SQLField."gab_id,";
  2170. $SQLValue=$SQLValue.$gab_id.",";
  2171. $SQLField=$SQLField."gb_balise,";
  2172. $SQLValue=$SQLValue."'".fixPGQuote($gb_balise)."',";
  2173. $SQLField=$SQLField."gb_champ,";
  2174. $SQLValue=$SQLValue."'".fixPGQuote($gb_champ)."',";
  2175. $SQLField=$SQLField."gb_description)";
  2176. $SQLValue=$SQLValue."'".fixPGQuote($gb_description)."')";
  2177. //Building SQLStmt
  2178. $SQLStmt.=$SQLField.$SQLValue;
  2179. return $SQLStmt;
  2180. }
  2181. ///////////////////////////////////////////////////////////////////////////////////////
  2182. // Retourne la requete SQL necessaire pour faire un INSERT
  2183. ///////////////////////////////////////////////////////////////////////////////////////
  2184. function getSQLStmtInsInscription($usr_id, $ses_id, $is_ipsoumission, $ie_id, $is_majpar_usr_id){
  2185. $SQLStmt="INSERT INTO inscriptionSession";
  2186. $SQLField="(";
  2187. $SQLValue="VALUES(";
  2188. $SQLField.="usr_id,";
  2189. $SQLValue.=$usr_id.",";
  2190. $SQLField.="ses_id,";
  2191. $SQLValue.=$ses_id.",";
  2192. $SQLField.="is_datesoumission,";
  2193. $SQLValue.="NOW(),";
  2194. $SQLField.="is_ipsoumission,";
  2195. $SQLValue.="'".fixPGQuote($is_ipsoumission)."',";
  2196. $SQLField.="ie_id,";
  2197. $SQLValue.=$ie_id.",";
  2198. $SQLField.='lieu_id_aInscription,';
  2199. $SQLValue.="(SELECT Li_id from Usager WHERE usr_id=".$usr_id."),";
  2200. $SQLField.="is_majpar_usr_id)";
  2201. $SQLValue.=$is_majpar_usr_id.")";
  2202. //Building SQLStmt
  2203. $SQLStmt.=$SQLField.$SQLValue;
  2204. return $SQLStmt;
  2205. }
  2206. ///////////////////////////////////////////////////////////////////////////////////////
  2207. // Retourne la requete SQL necessaire pour faire un INSERT
  2208. ///////////////////////////////////////////////////////////////////////////////////////
  2209. function getSQLStmtInsLieu($li_lieu){
  2210. $SQLStmt="INSERT INTO lieu";
  2211. $SQLField="(";
  2212. $SQLValue="VALUES(";
  2213. $SQLField.="li_lieu)";
  2214. $SQLValue.="'".fixPGQuote($li_lieu)."')";
  2215. //Building SQLStmt
  2216. $SQLStmt.=$SQLField.$SQLValue;
  2217. return ($SQLStmt);
  2218. }
  2219. ///////////////////////////////////////////////////////////////////////////////////////
  2220. // Retourne la requete SQL necessaire pour faire un INSERT
  2221. ///////////////////////////////////////////////////////////////////////////////////////
  2222. function getSQLStmtInsExpertise($parent, $label){
  2223. return (getSQLStmtInsNode(2, $parent, $label));
  2224. }
  2225. ///////////////////////////////////////////////////////////////////////////////////////
  2226. // Retourne la requete SQL necessaire pour faire un INSERT
  2227. ///////////////////////////////////////////////////////////////////////////////////////
  2228. function getSQLStmtInsLieuAdmin($li_id, $usr_id, $la_responsable)
  2229. {
  2230. return getSQLStmtInsLieuAdminFull($li_id, $usr_id, $la_responsable, 'f');
  2231. }
  2232. function getSQLStmtInsLieuAdminFull($li_id, $usr_id, $la_responsable, $la_loi90){
  2233. $SQLStmt="INSERT INTO lieuAdmin";
  2234. $SQLField="(";
  2235. $SQLValue="VALUES(";
  2236. $SQLField.="li_id,";
  2237. $SQLValue.=$li_id.",";
  2238. $SQLField.="usr_id,";
  2239. $SQLValue.=$usr_id.",";
  2240. $SQLField.="la_responsable,";
  2241. if (!strcasecmp($la_responsable,"t")){
  2242. $SQLValue.="'t',";
  2243. }
  2244. else{
  2245. $SQLValue.="'f',";
  2246. }
  2247. $SQLField.="la_courriel_loi90)";
  2248. if (!strcasecmp($la_loi90,"t"))
  2249. {
  2250. $SQLValue.="'t')";
  2251. }
  2252. else
  2253. {
  2254. $SQLValue.="'f')";
  2255. };
  2256. //Building SQLStmt
  2257. $SQLStmt.=$SQLField.$SQLValue;
  2258. return ($SQLStmt);
  2259. }
  2260. ///////////////////////////////////////////////////////////////////////////////////////
  2261. // Retourne la requete SQL necessaire pour faire un INSERT
  2262. ///////////////////////////////////////////////////////////////////////////////////////
  2263. function getSQLStmtInsLieuSupport($li_id, $usr_id, $ls_responsable){
  2264. $SQLStmt="INSERT INTO lieuSupport";
  2265. $SQLField="(";
  2266. $SQLValue="VALUES(";
  2267. $SQLField.="li_id,";
  2268. $SQLValue.=$li_id.",";
  2269. $SQLField.="usr_id,";
  2270. $SQLValue.=$usr_id.",";
  2271. $SQLField.="ls_responsable)";
  2272. if (!strcasecmp($ls_responsable,"t")){
  2273. $SQLValue.="'t')";
  2274. }
  2275. else{
  2276. $SQLValue.="'f')";
  2277. }
  2278. //Building SQLStmt
  2279. $SQLStmt.=$SQLField.$SQLValue;
  2280. return ($SQLStmt);
  2281. }
  2282. ///////////////////////////////////////////////////////////////////////////////////////
  2283. // Retourne la requete SQL necessaire pour faire un INSERT
  2284. ///////////////////////////////////////////////////////////////////////////////////////
  2285. function getSQLStmtInsNode($tr_id, $parent, $label){
  2286. $SQLStmt="INSERT INTO nodes";
  2287. $SQLField="(";
  2288. $SQLValue="VALUES(";
  2289. $SQLField.="tr_id,";
  2290. if (is_numeric($tr_id)){
  2291. $SQLValue.=$tr_id.",";
  2292. }
  2293. else{
  2294. $SQLValue.="NULL,";
  2295. }
  2296. $SQLField.="parent,";
  2297. if (is_numeric($parent)){
  2298. $SQLValue.=$parent.",";
  2299. }
  2300. else{
  2301. $SQLValue.="NULL,";
  2302. }
  2303. $SQLField.="etiquette)";
  2304. $SQLValue.="'".fixPGQuote($label)."')";
  2305. //Building SQLStmt
  2306. $SQLStmt.=$SQLField.$SQLValue;
  2307. return ($SQLStmt);
  2308. }
  2309. ///////////////////////////////////////////////////////////////////////////////////////
  2310. // Retourne la requete SQL necessaire pour faire un INSERT
  2311. ///////////////////////////////////////////////////////////////////////////////////////
  2312. function getSQLStmtInsPresence($sea_id, $usr_id, $pr_presence){
  2313. $SQLStmt="INSERT INTO presence";
  2314. $SQLField="(";
  2315. $SQLValue="VALUES(";
  2316. $SQLField.="sea_id,";
  2317. $SQLValue.=$sea_id.",";
  2318. $SQLField.="usr_id,";
  2319. $SQLValue.=$usr_id.",";
  2320. $SQLField.="pr_presence)";
  2321. if (!strcasecmp($pr_presence,"t")){
  2322. $SQLValue.="'t')";
  2323. }
  2324. else{
  2325. $SQLValue.="'f')";
  2326. }
  2327. //Building SQLStmt
  2328. $SQLStmt.=$SQLField.$SQLValue;
  2329. return ($SQLStmt);
  2330. }
  2331. ///////////////////////////////////////////////////////////////////////////////////////
  2332. // Retourne la requete SQL necessaire pour faire un INSERT
  2333. ///////////////////////////////////////////////////////////////////////////////////////
  2334. function getSQLStmtInsProjet($prj_projet, $pt_id){
  2335. $SQLStmt="INSERT INTO projet";
  2336. $SQLField="(";
  2337. $SQLValue="VALUES(";
  2338. $SQLField.="prj_projet,";
  2339. $SQLValue.="'".fixPGQuote($prj_projet)."',";
  2340. $SQLField.="pt_id)";
  2341. $SQLValue.=$pt_id.")";
  2342. //Building SQLStmt
  2343. $SQLStmt.=$SQLField.$SQLValue;
  2344. return ($SQLStmt);
  2345. }
  2346. function getSQLStmtInsProjetAdmin($prj_id, $usr_id, $pa_responsable){
  2347. $SQLStmt="INSERT INTO projetAdmin";
  2348. $SQLField="(";
  2349. $SQLValue="VALUES(";
  2350. $SQLField.="prj_id,";
  2351. $SQLValue.=$prj_id.",";
  2352. $SQLField.="usr_id,";
  2353. $SQLValue.=$usr_id.",";
  2354. $SQLField.="pa_responsable)";
  2355. if (!strcasecmp($pa_responsable,"t")){
  2356. $SQLValue.="'t')";
  2357. }
  2358. else{
  2359. $SQLValue.="'f')";
  2360. }
  2361. //Building SQLStmt
  2362. $SQLStmt.=$SQLField.$SQLValue;
  2363. return ($SQLStmt);
  2364. }
  2365. ///////////////////////////////////////////////////////////////////////////////////////
  2366. // Retourne la requete SQL necessaire pour faire un INSERT
  2367. ///////////////////////////////////////////////////////////////////////////////////////
  2368. function getSQLStmtInsSeance($ses_id){
  2369. $SQLStmt="INSERT INTO seance";
  2370. $SQLField="(";
  2371. $SQLValue="VALUES(";
  2372. $SQLField.="ses_id)";
  2373. $SQLValue.=$ses_id.")";
  2374. //Building SQLStmt
  2375. $SQLStmt.=$SQLField.$SQLValue;
  2376. return ($SQLStmt);
  2377. }
  2378. ///////////////////////////////////////////////////////////////////////////////////////
  2379. // Retourne la requete SQL necessaire pour faire un INSERT
  2380. ///////////////////////////////////////////////////////////////////////////////////////
  2381. function getSQLStmtInsSession($prj_id, $atl_id){
  2382. $SQLStmt="INSERT INTO session";
  2383. $SQLField="(";
  2384. $SQLValue="VALUES(";
  2385. $SQLField.="prj_id,";
  2386. $SQLValue.=$prj_id.",";
  2387. $SQLField.="atl_id)";
  2388. $SQLValue.=$atl_id.")";
  2389. //Building SQLStmt
  2390. $SQLStmt.=$SQLField.$SQLValue;
  2391. return ($SQLStmt);
  2392. }
  2393. ///////////////////////////////////////////////////////////////////////////////////////
  2394. // Retourne la requete SQL necessaire pour faire un INSERT
  2395. ///////////////////////////////////////////////////////////////////////////////////////
  2396. function getSQLStmtInsSessionAnimation($ses_id, $usr_id, $an_responsable){
  2397. $SQLStmt="INSERT INTO animation";
  2398. $SQLField="(";
  2399. $SQLValue="VALUES(";
  2400. $SQLField.="ses_id,";
  2401. $SQLValue.=$ses_id.",";
  2402. $SQLField.="usr_id,";
  2403. $SQLValue.=$usr_id.",";
  2404. $SQLField.="an_responsable)";
  2405. if (!strcasecmp($an_responsable,"t")){
  2406. $SQLValue.="'t')";
  2407. }
  2408. else{
  2409. $SQLValue.="'f')";
  2410. }
  2411. //Building SQLStmt
  2412. $SQLStmt.=$SQLField.$SQLValue;
  2413. return ($SQLStmt);
  2414. }
  2415. ///////////////////////////////////////////////////////////////////////////////////////
  2416. // Retourne la requete SQL necessaire pour faire un INSERT
  2417. ///////////////////////////////////////////////////////////////////////////////////////
  2418. function getSQLStmtInsUsager($usr_login, $usr_nom, $usr_prenom, $li_id){
  2419. $SQLStmt="INSERT INTO usager";
  2420. $SQLField="(";
  2421. $SQLValue="VALUES(";
  2422. $SQLField.="usr_login,";
  2423. $SQLValue.="'".fixPGQuote(rtrim($usr_login))."',";
  2424. $SQLField.="usr_nom,";
  2425. $SQLValue.="'".fixPGQuote(rtrim($usr_nom))."',";
  2426. $SQLField.="usr_prenom,";
  2427. $SQLValue.="'".fixPGQuote(rtrim($usr_prenom))."',";
  2428. $SQLField.="li_id)";
  2429. if (is_numeric($li_id)){
  2430. $SQLValue.=$li_id.")";
  2431. }
  2432. else{
  2433. $SQLValue.="NULL)";
  2434. }
  2435. //Building SQLStmt
  2436. $SQLStmt.=$SQLField.$SQLValue;
  2437. return ($SQLStmt);
  2438. }
  2439. ///////////////////////////////////////////////////////////////////////////////////////
  2440. // Retourne la requete SQL necessaire pour faire un INSERT
  2441. ///////////////////////////////////////////////////////////////////////////////////////
  2442. function getSQLStmtInsUsagerUsrType($usr_id, $ut_id){
  2443. $SQLStmt="INSERT INTO usager_usagerType";
  2444. $SQLField="(";
  2445. $SQLValue="VALUES(";
  2446. $SQLField.="usr_id,";
  2447. $SQLValue.=$usr_id.",";
  2448. $SQLField.="ut_id)";
  2449. $SQLValue.=$ut_id.")";
  2450. //Building SQLStmt
  2451. $SQLStmt.=$SQLField.$SQLValue;
  2452. return ($SQLStmt);
  2453. }
  2454. ///////////////////////////////////////////////////////////////////////////////////////
  2455. // Retourne la requete SQL necessaire pour faire un UPDATE
  2456. ///////////////////////////////////////////////////////////////////////////////////////
  2457. function getSQLStmtUpdActivite($id, $act_activite, $act_description, $act_lieu, $act_datedebut, $act_datefin, $act_frais, $act_annule, $act_annuleraison, $prj_id, $act_valide){
  2458. $SQLStmt="UPDATE activite SET";
  2459. $SQLStmt.=" act_activite = '".fixPGQuote($act_activite)."',";
  2460. $SQLStmt.=" act_description = '".fixPGQuote($act_description)."',";
  2461. $SQLStmt.=" act_lieu = '".fixPGQuote($act_lieu)."',";
  2462. if (isTimeStamp($act_datedebut)){
  2463. $SQLStmt.=" act_datedebut = '".fixPGQuote($act_datedebut)."',";
  2464. }
  2465. else{
  2466. $SQLStmt.=" act_datedebut = NULL,";
  2467. }
  2468. if (isTimeStamp($act_datefin)){
  2469. $SQLStmt.=" act_datefin = '".fixPGQuote($act_datefin)."',";
  2470. }
  2471. else{
  2472. $SQLStmt.=" act_datefin = NULL,";
  2473. }
  2474. $SQLStmt.=" act_frais = '".fixPGQuote($act_frais)."',";
  2475. if (!strcasecmp($act_annule,"t")){
  2476. $SQLStmt.=" act_annule = 't',";
  2477. }
  2478. else{
  2479. $SQLStmt.=" act_annule = 'f',";
  2480. }
  2481. $SQLStmt.=" act_annuleraison = '".fixPGQuote($act_annuleraison)."',";
  2482. if (is_numeric($prj_id)){
  2483. $SQLStmt.=" prj_id = ".fixPGQuote($prj_id).",";
  2484. }
  2485. else{
  2486. $SQLStmt.=" prj_id = NULL,";
  2487. }
  2488. if (!strcasecmp($act_valide,"t")){
  2489. $SQLStmt.=" act_valide = 't'";
  2490. }
  2491. else{
  2492. $SQLStmt.=" act_valide = 'f'";
  2493. }
  2494. $SQLStmt.=" WHERE act_id = ".$id;
  2495. return $SQLStmt;
  2496. }
  2497. ///////////////////////////////////////////////////////////////////////////////////////
  2498. // Retourne la requete SQL necessaire pour faire un UPDATE
  2499. ///////////////////////////////////////////////////////////////////////////////////////
  2500. 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){
  2501. $SQLStmt="UPDATE atelier SET";
  2502. $SQLStmt.=" atl_atelier = '".fixPGQuote($atl_atelier)."',";
  2503. $SQLStmt.=" atl_description = '".fixPGQuote($atl_description)."',";
  2504. $SQLStmt.=" atl_url = '".fixPGQuote($atl_url)."',";
  2505. $SQLStmt.=" atl_prealable = '".fixPGQuote($atl_prealable)."',";
  2506. $SQLStmt.=" atl_condition = '".fixPGQuote($atl_condition)."',";
  2507. $SQLStmt.=" atl_calendrier = '".fixPGQuote($atl_calendrier)."',";
  2508. $SQLStmt.=" atl_fraistypique = '".fixPGQuote($atl_fraistypique)."',";
  2509. $SQLStmt.=" atl_note = '".fixPGQuote($atl_note)."',";
  2510. $SQLStmt.=" atl_commentaire = '".fixPGQuote($atl_commentaire)."',";
  2511. if (!strcasecmp($atl_alacartedisponible,"t")){
  2512. $SQLStmt.=" atl_alacartedisponible = 't',";
  2513. }
  2514. else{
  2515. $SQLStmt.=" atl_alacartedisponible = 'f',";
  2516. }
  2517. if (is_numeric($usr_id)){
  2518. $SQLStmt.=" usr_id = ".fixPGQuote($usr_id).",";
  2519. }
  2520. else{
  2521. $SQLStmt.=" usr_id = NULL,";
  2522. }
  2523. if (!strcasecmp($atl_valide,"t")){
  2524. $SQLStmt.=" atl_valide = 't'";
  2525. }
  2526. else{
  2527. $SQLStmt.=" atl_valide = 'f'";
  2528. }
  2529. $SQLStmt.=" WHERE atl_id = ".$id;
  2530. return $SQLStmt;
  2531. }
  2532. ///////////////////////////////////////////////////////////////////////////////////////
  2533. // Retourne la requete SQL necessaire pour faire un UPDATE
  2534. ///////////////////////////////////////////////////////////////////////////////////////
  2535. function getSQLStmtUpdCedule($id, $ced_cedule, $gab_id, $ced_paramValeur, $ced_intervalle, $ced_dateNext, $ced_valide){
  2536. $SQLStmt="UPDATE ceduleur SET";
  2537. $SQLStmt.=" ced_cedule = '".fixPGQuote($ced_cedule)."',";
  2538. if (is_numeric($gab_id)){
  2539. $SQLStmt.=" gab_id = ". $gab_id.",";
  2540. }
  2541. else{
  2542. $SQLStmt.=" gab_id = NULL,";
  2543. }
  2544. $SQLStmt.=" ced_paramValeur = '".fixPGQuote($ced_paramValeur)."',";
  2545. if (is_numeric($ced_intervalle)){
  2546. $SQLStmt.=" ced_intervalle = ". $ced_intervalle.",";
  2547. }
  2548. else{
  2549. $SQLStmt.=" ced_intervalle = NULL,";
  2550. }
  2551. if (isTimeStamp($ced_dateNext)){
  2552. $SQLStmt.=" ced_dateNext = '".fixPGQuote($ced_dateNext)."',";
  2553. }
  2554. else{
  2555. $SQLStmt.=" ced_dateNext = NULL,";
  2556. }
  2557. if (!strcasecmp($ced_valide,"t")){
  2558. $SQLStmt.=" ced_valide = 't'";
  2559. }
  2560. else{
  2561. $SQLStmt.=" ced_valide = 'f'";
  2562. }
  2563. $SQLStmt.=" WHERE ced_id = ".$id;
  2564. return $SQLStmt;
  2565. }
  2566. ///////////////////////////////////////////////////////////////////////////////////////
  2567. // Retourne la requete SQL necessaire pour faire un UPDATE
  2568. ///////////////////////////////////////////////////////////////////////////////////////
  2569. function getSQLStmtUpdClasse($node, $parent, $label){
  2570. return getSQLStmtUpdNode($node, 1, $parent, $label);
  2571. }
  2572. ///////////////////////////////////////////////////////////////////////////////////////
  2573. // Retourne la requete SQL necessaire pour faire un UPDATE
  2574. ///////////////////////////////////////////////////////////////////////////////////////
  2575. /* $Author: stacil $ [$Date: 2008/07/03 18:29:46 $]
  2576. function getSQLStmtUpdClientele($cli_id, $cli_clientele, $cli_description){
  2577. $SQLStmt="UPDATE clientele SET";
  2578. $SQLStmt.=" cli_clientele = '".fixPGQuote($cli_clientele)."',";
  2579. $SQLStmt.=" cli_description = '".fixPGQuote($cli_description)."'";
  2580. $SQLStmt.=" WHERE cli_id = ".$cli_id;
  2581. return $SQLStmt;
  2582. }
  2583. */
  2584. function getSQLStmtUpdClientele($node, $parent, $label) {
  2585. return getSQLStmtUpdNode($node, 3, $parent, $label);
  2586. }
  2587. ///////////////////////////////////////////////////////////////////////////////////////
  2588. // Retourne la requete SQL necessaire pour faire un UPDATE
  2589. ///////////////////////////////////////////////////////////////////////////////////////
  2590. 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){
  2591. $SQLStmt="UPDATE gabarit SET";
  2592. $SQLStmt.=" gab_gabarit = '".fixPGQuote($gab_gabarit)."',";
  2593. if (!strcasecmp($gab_system,"t")){
  2594. $SQLStmt.=" gab_system = 't',";
  2595. }
  2596. else{
  2597. $SQLStmt.=" gab_system = 'f',";
  2598. }
  2599. $SQLStmt.=" gab_description = '".fixPGQuote($gab_description)."',";
  2600. $SQLStmt.=" gab_requeteSQL = '".fixPGQuote($gab_requeteSQL)."',";
  2601. $SQLStmt.=" gab_param = '".fixPGQuote($gab_param)."',";
  2602. $SQLStmt.=" gab_TO = '".fixPGQuote($gab_TO)."',";
  2603. $SQLStmt.=" gab_CC = '".fixPGQuote($gab_CC)."',";
  2604. $SQLStmt.=" gab_BCC = '".fixPGQuote($gab_BCC)."',";
  2605. $SQLStmt.=" gab_objet = '".fixPGQuote($gab_objet)."',";
  2606. $SQLStmt.=" gab_body = '".fixPGQuote($gab_body)."',";
  2607. if (!strcasecmp($gab_valide,"t")){
  2608. $SQLStmt.=" gab_valide = 't',";
  2609. }
  2610. else{
  2611. $SQLStmt.=" gab_valide = 'f',";
  2612. }
  2613. if (!strcasecmp($gab_multicourriel,"t")){
  2614. $SQLStmt.=" gab_multicourriel = 't'";
  2615. }
  2616. else{
  2617. $SQLStmt.=" gab_multicourriel = 'f'";
  2618. }
  2619. $SQLStmt.=" WHERE gab_id = ".$id;
  2620. return $SQLStmt;
  2621. }
  2622. ///////////////////////////////////////////////////////////////////////////////////////
  2623. // Retourne la requete SQL necessaire pour faire un UPDATE
  2624. ///////////////////////////////////////////////////////////////////////////////////////
  2625. function getSQLStmtUpdGabaritBalise($gab_id, $gb_id, $gb_balise, $gb_champ, $gb_description){
  2626. $SQLStmt="UPDATE gabaritBalise SET";
  2627. $SQLStmt.=" gb_balise = '".fixPGQuote($gb_balise)."',";
  2628. $SQLStmt.=" gb_champ = '".fixPGQuote($gb_champ)."',";
  2629. $SQLStmt.=" gb_description = '".fixPGQuote($gb_description)."'";
  2630. $SQLStmt.=" WHERE gb_id = ".$gb_id;
  2631. $SQLStmt.=" AND gab_id = ".$gab_id;
  2632. return $SQLStmt;
  2633. }
  2634. ///////////////////////////////////////////////////////////////////////////////////////
  2635. // Retourne la requete SQL necessaire pour faire un UPDATE
  2636. ///////////////////////////////////////////////////////////////////////////////////////
  2637. function getSQLStmtUpdExpertise($node, $parent, $label){
  2638. return getSQLStmtUpdNode($node, 2, $parent, $label);
  2639. }
  2640. ///////////////////////////////////////////////////////////////////////////////////////
  2641. // Retourne la requete SQL necessaire pour faire un UPDATE
  2642. ///////////////////////////////////////////////////////////////////////////////////////
  2643. function getSQLStmtUpdInscriptionEtat($usr_id, $ses_id, $oldetat, $ie_id, $is_majpar_usr_id){
  2644. $SQLStmt="UPDATE inscriptionSession SET";
  2645. if (is_numeric($ie_id)){
  2646. $SQLStmt.=" ie_id = ". $ie_id.",";
  2647. }
  2648. else{
  2649. $SQLStmt.=" ie_id = NULL,";
  2650. }
  2651. if (is_numeric($is_majpar_usr_id)){
  2652. $SQLStmt.=" is_majpar_usr_id = ".$is_majpar_usr_id;
  2653. }
  2654. else{
  2655. $SQLStmt.=" is_majpar_usr_id = NULL";
  2656. }
  2657. $SQLStmt.=" WHERE usr_id = ".$usr_id;
  2658. $SQLStmt.=" AND ses_id = ".$ses_id;
  2659. if (is_numeric($oldetat)){
  2660. $SQLStmt.=" AND ie_id = ".$oldetat;
  2661. }
  2662. return $SQLStmt;
  2663. }
  2664. ///////////////////////////////////////////////////////////////////////////////////////
  2665. // Retourne la requete SQL necessaire pour faire un UPDATE
  2666. ///////////////////////////////////////////////////////////////////////////////////////
  2667. function getSQLStmtUpdLieu($id, $li_lieu, $newno, $li_adresse, $li_trajet, $li_trajetURL, $li_telephone, $li_ldap, $li_valide, $lt_id){
  2668. $SQLStmt="UPDATE lieu SET";
  2669. $SQLStmt.=" li_lieu = '".fixPGQuote($li_lieu)."',";
  2670. if ( $newno!="" ){
  2671. $SQLStmt.=" li_no = '".$newno."',";
  2672. }
  2673. else{
  2674. $SQLStmt.=" li_no = NULL,";
  2675. }
  2676. if ($lt_id == "") $lt_id = "0"; // ajout 2006/09/18 R.Franche
  2677. $SQLStmt.=" li_adresse = '".fixPGQuote($li_adresse)."',";
  2678. $SQLStmt.=" li_trajet = '".fixPGQuote($li_trajet)."',";
  2679. $SQLStmt.=" li_trajetURL = '".fixPGQuote($li_trajetURL)."',";
  2680. $SQLStmt.=" li_telephone = '".fixPGQuote($li_telephone)."',";
  2681. $SQLStmt.=" lt_id = '".fixPGQuote($lt_id)."',";
  2682. if (!strcasecmp($li_ldap,"t")){
  2683. $SQLStmt.=" li_ldap = 't',";
  2684. }
  2685. else{
  2686. $SQLStmt.=" li_ldap = 'f',";
  2687. }
  2688. if (!strcasecmp($li_valide,"t")){
  2689. $SQLStmt.=" li_valide = 't'";
  2690. }
  2691. else{
  2692. $SQLStmt.=" li_valide = 'f'";
  2693. }
  2694. $SQLStmt.=" WHERE li_id = ".$id;
  2695. //echo $SQLStmt;
  2696. return $SQLStmt;
  2697. }
  2698. ///////////////////////////////////////////////////////////////////////////////////////
  2699. // Retourne la requete SQL necessaire pour faire un UPDATE
  2700. ///////////////////////////////////////////////////////////////////////////////////////
  2701. function getSQLStmtUpdNode($node, $tr_id, $parent, $label){
  2702. $SQLStmt="UPDATE nodes SET";
  2703. if (is_numeric($tr_id)){
  2704. $SQLStmt.=" tr_id = ".$tr_id.",";
  2705. }
  2706. else{
  2707. $SQLStmt.=" tr_id = NULL,";
  2708. }
  2709. if (is_numeric($parent)){
  2710. $SQLStmt.=" parent = ".$parent.",";
  2711. }
  2712. else{
  2713. $SQLStmt.=" parent = NULL,";
  2714. }
  2715. $SQLStmt.=" etiquette = '".fixPGQuote($label)."'";
  2716. $SQLStmt.=" WHERE node = ".$node;
  2717. return ($SQLStmt);
  2718. }
  2719. ///////////////////////////////////////////////////////////////////////////////////////
  2720. // Retourne la requete SQL necessaire pour faire un UPDATE
  2721. ///////////////////////////////////////////////////////////////////////////////////////
  2722. function getSQLStmtUpdProjet($id, $prj_projet, $prj_description, $prj_prefixe, $prj_url, $prj_datedebut, $prj_datefin, $prj_datelimite, $prj_fraisglobaux, $pt_id, $prj_valide){
  2723. $SQLStmt="UPDATE projet SET";
  2724. $SQLStmt.=" prj_projet = '".fixPGQuote($prj_projet)."',";
  2725. $SQLStmt.=" prj_description = '".fixPGQuote($prj_description)."',";
  2726. $SQLStmt.=" prj_prefixe = '".fixPGQuote($prj_prefixe)."',";
  2727. $SQLStmt.=" prj_url = '".fixPGQuote($prj_url)."',";
  2728. if (isDate($prj_datedebut)){
  2729. $SQLStmt.=" prj_datedebut = '".fixPGQuote($prj_datedebut)."',";
  2730. }
  2731. else{
  2732. $SQLStmt.=" prj_datedebut = NULL,";
  2733. }
  2734. if (isDate($prj_datefin)){
  2735. $SQLStmt.=" prj_datefin = '".fixPGQuote($prj_datefin)."',";
  2736. }
  2737. else{
  2738. $SQLStmt.=" prj_datefin = NULL,";
  2739. }
  2740. if (isDate($prj_datelimite)){
  2741. $SQLStmt.=" prj_datelimite = '".fixPGQuote($prj_datelimite)."',";
  2742. }
  2743. else{
  2744. $SQLStmt.=" prj_datelimite = NULL,";
  2745. }
  2746. $SQLStmt.=" prj_fraisglobaux = '".fixPGQuote($prj_fraisglobaux)."',";
  2747. $SQLStmt.=" pt_id = '".fixPGQuote($pt_id)."',";
  2748. if (!strcasecmp($prj_valide,"t")){
  2749. $SQLStmt.=" prj_valide = 't'";
  2750. }
  2751. else{
  2752. $SQLStmt.=" prj_valide = 'f'";
  2753. }
  2754. $SQLStmt.=" WHERE prj_id = ".$id;
  2755. return $SQLStmt;
  2756. }
  2757. ///////////////////////////////////////////////////////////////////////////////////////
  2758. // Retourne la requete SQL necessaire pour faire un UPDATE
  2759. ///////////////////////////////////////////////////////////////////////////////////////
  2760. 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){
  2761. $SQLStmt="UPDATE seance SET";
  2762. if (is_numeric($ses_id)){
  2763. $SQLStmt.=" ses_id = ".$ses_id.",";
  2764. }
  2765. else{
  2766. $SQLStmt.=" ses_id = NULL,";
  2767. }
  2768. if (isTimeStamp($sea_dateDebut)){
  2769. $SQLStmt.=" sea_datedebut = '".fixPGQuote($sea_dateDebut)."',";
  2770. }
  2771. else{
  2772. $SQLStmt.=" sea_datedebut = NULL,";
  2773. }
  2774. if (isTimeStamp($sea_dateFin)){
  2775. $SQLStmt.=" sea_datefin = '".fixPGQuote($sea_dateFin)."',";
  2776. }
  2777. else{
  2778. $SQLStmt.=" sea_datefin = NULL,";
  2779. }
  2780. if (is_numeric($sea_duree)){
  2781. $SQLStmt.=" sea_duree = ".$sea_duree.",";
  2782. }
  2783. else{
  2784. $SQLStmt.=" sea_duree = NULL,";
  2785. }
  2786. if (is_numeric($li_id)){
  2787. $SQLStmt.=" li_id = ".$li_id.",";
  2788. }
  2789. else{
  2790. $SQLStmt.=" li_id = NULL,";
  2791. }
  2792. $SQLStmt.=" sea_lieudetail = '".fixPGQuote($sea_lieudetail)."',";
  2793. $SQLStmt.=" sea_materiel = '".fixPGQuote($sea_materiel)."',";
  2794. $SQLStmt.=" sea_materielAnimation = '".fixPGQuote($sea_materielAnimation)."',";
  2795. $SQLStmt.=" sea_fraisAnimation = '".getMoney($sea_fraisAnimation)."',";
  2796. $SQLStmt.=" sea_fraisProduction = '".getMoney($sea_fraisProduction)."',";
  2797. $SQLStmt.=" sea_fraisLiberation = '".getMoney($sea_fraisLiberation)."',";
  2798. $SQLStmt.=" sea_fraisLocation = '".getMoney($sea_fraisLocation)."',";
  2799. $SQLStmt.=" sea_fraisAutre = '".getMoney($sea_fraisAutre)."',";
  2800. $SQLStmt.=" sea_note = '".fixPGQuote($sea_note)."',";
  2801. $SQLStmt.=" sea_commentaire = '".fixPGQuote($sea_commentaire)."',";
  2802. if (!strcasecmp($sea_annule,"t")){
  2803. $SQLStmt.=" sea_annule = 't',";
  2804. }
  2805. else{
  2806. $SQLStmt.=" sea_annule = 'f',";
  2807. }
  2808. $SQLStmt.=" sea_annuleRaison = '".fixPGQuote($sea_annuleRaison)."',";
  2809. if (!strcasecmp($sea_valide,"t")){
  2810. $SQLStmt.=" sea_valide = 't'";
  2811. }
  2812. else{
  2813. $SQLStmt.=" sea_valide = 'f'";
  2814. }
  2815. $SQLStmt.=" WHERE sea_id = ".$id;
  2816. return $SQLStmt;
  2817. }
  2818. ///////////////////////////////////////////////////////////////////////////////////////
  2819. // Retourne la requete SQL necessaire pour faire un UPDATE
  2820. ///////////////////////////////////////////////////////////////////////////////////////
  2821. 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){
  2822. $SQLStmt="UPDATE session SET";
  2823. if (is_numeric($prj_id)){
  2824. $SQLStmt.=" prj_id = ".$prj_id.",";
  2825. }
  2826. else{
  2827. $SQLStmt.=" prj_id = NULL,";
  2828. }
  2829. if (is_numeric($atl_id)){
  2830. $SQLStmt.=" atl_id = ".$atl_id.",";
  2831. }
  2832. else{
  2833. $SQLStmt.=" atl_id = NULL,";
  2834. }
  2835. $SQLStmt.=" ses_notemini = '".fixPGQuote($ses_notemini)."',";
  2836. $SQLStmt.=" ses_note = '".fixPGQuote($ses_note)."',";
  2837. $SQLStmt.=" ses_commentaire = '".fixPGQuote($ses_commentaire)."',";
  2838. if (isDate($ses_dateLimite)){
  2839. $SQLStmt.=" ses_dateLimite = '".fixPGQuote($ses_dateLimite)."',";
  2840. }
  2841. else{
  2842. $SQLStmt.=" ses_dateLimite = NULL,";
  2843. }
  2844. if (is_numeric($ses_nbMin)){
  2845. $SQLStmt.=" ses_nbMin = ".$ses_nbMin.",";
  2846. }
  2847. else{
  2848. $SQLStmt.=" ses_nbMin = 0,";
  2849. }
  2850. if (is_numeric($ses_nbMax)){
  2851. $SQLStmt.=" ses_nbMax = ".$ses_nbMax.",";
  2852. }
  2853. else{
  2854. $SQLStmt.=" ses_nbMax = 0,";
  2855. }
  2856. $SQLStmt.=" ses_frais = '".fixPGQuote($ses_frais)."',";
  2857. if (is_numeric($ses_coutparusager)){
  2858. $SQLStmt.=" ses_coutParUsager = $ses_coutparusager,";
  2859. }
  2860. else{
  2861. $SQLStmt.=" ses_coutParUsager = NULL,";
  2862. }
  2863. if (!strcasecmp($ses_regionnal,"t")){
  2864. $SQLStmt.=" ses_regionnal = 't',";
  2865. }
  2866. else{
  2867. $SQLStmt.=" ses_regionnal = 'f',";
  2868. }
  2869. if (!strcasecmp($ses_annule,"t")){
  2870. $SQLStmt.=" ses_annule = 't',";
  2871. }
  2872. else{
  2873. $SQLStmt.=" ses_annule = 'f',";
  2874. }
  2875. $SQLStmt.=" ses_annuleraison = '".fixPGQuote($ses_annuleraison)."',";
  2876. if (!strcasecmp($ses_valide,"t")){
  2877. $SQLStmt.=" ses_valide = 't'";
  2878. }
  2879. else{
  2880. $SQLStmt.=" ses_valide = 'f'";
  2881. }
  2882. $SQLStmt.=" WHERE ses_id = ".$id;
  2883. return $SQLStmt;
  2884. }
  2885. ///////////////////////////////////////////////////////////////////////////////////////
  2886. // Retourne la requete SQL necessaire pour faire un UPDATE
  2887. ///////////////////////////////////////////////////////////////////////////////////////
  2888. 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){
  2889. $SQLStmt="UPDATE usager SET";
  2890. $SQLStmt.=" usr_nom = '".fixPGQuote(rtrim($usr_nom))."',";
  2891. $SQLStmt.=" usr_prenom = '".fixPGQuote(rtrim($usr_prenom))."',";
  2892. $SQLStmt.=" usr_email = '".fixPGQuote($usr_email)."',";
  2893. $SQLStmt.=" usr_url = '".fixPGQuote($usr_url)."',";
  2894. $SQLStmt.=" usr_telRejoindre = '".fixPGQuote($usr_telRejoindre)."',";
  2895. $SQLStmt.=" usr_telTravail = '".fixPGQuote($usr_telTravail)."',";
  2896. $SQLStmt.=" usr_telMaison = '".fixPGQuote($usr_telMaison)."',";
  2897. $SQLStmt.=" usr_telCellulaire = '".fixPGQuote($usr_telCellulaire)."',";
  2898. $SQLStmt.=" usr_telPage = '".fixPGQuote($usr_telPage)."',";
  2899. $SQLStmt.=" usr_telFax = '".fixPGQuote($usr_telFax)."',";
  2900. $SQLStmt.=" usr_adresse = '".fixPGQuote($usr_adresse)."',";
  2901. $SQLStmt.=" usr_ville = '".fixPGQuote($usr_ville)."',";
  2902. $SQLStmt.=" usr_codePostal = '".fixPGQuote($usr_codePostal)."',";
  2903. $SQLStmt.=" usr_societe = '".fixPGQuote($usr_societe)."',";
  2904. $SQLStmt.=" usr_fonction = '".fixPGQuote($usr_fonction)."',";
  2905. $SQLStmt.=" usr_locale = '".fixPGQuote($usr_locale)."',";
  2906. $SQLStmt.=" usr_nas = '".fixPGQuote($usr_nas)."',";
  2907. if (isDate($usr_dateNaissance)){
  2908. $SQLStmt.=" usr_dateNaissance = '".fixPGQuote($usr_dateNaissance)."',";
  2909. }
  2910. else{
  2911. $SQLStmt.=" usr_dateNaissance = NULL,";
  2912. }
  2913. $SQLStmt.=" usr_commentaire = '".fixPGQuote($usr_commentaire)."',";
  2914. $SQLStmt.=" usr_interet = '".fixPGQuote($usr_interet)."',";
  2915. if (!strcasecmp($usr_LDAP,"t")){
  2916. $SQLStmt.=" usr_LDAP = 't',";
  2917. }
  2918. else{
  2919. $SQLStmt.=" usr_LDAP = 'f',";
  2920. }
  2921. if (is_numeric($li_id)){
  2922. $SQLStmt.=" li_id = ".fixPGQuote($li_id).",";
  2923. }
  2924. else{
  2925. $SQLStmt.=" li_id = NULL,";
  2926. }
  2927. if (!strcasecmp($usr_valide,"t")){
  2928. $SQLStmt.=" usr_valide = 't'";
  2929. }
  2930. else{
  2931. $SQLStmt.=" usr_valide = 'f'";
  2932. }
  2933. $SQLStmt.=" WHERE usr_id = ".$id;
  2934. return $SQLStmt;
  2935. }
  2936. ///////////////////////////////////////////////////////////////////////////////////////
  2937. // Retourne la requete SQL necessaire pour faire un UPDATE
  2938. ///////////////////////////////////////////////////////////////////////////////////////
  2939. 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){
  2940. $SQLStmt="UPDATE usager SET";
  2941. $SQLStmt.=" usr_nom = '".fixPGQuote(rtrim($usr_nom))."',";
  2942. $SQLStmt.=" usr_prenom = '".fixPGQuote(rtrim($usr_prenom))."',";
  2943. $SQLStmt.=" usr_email = '".fixPGQuote($usr_email)."',";
  2944. $SQLStmt.=" usr_url = '".fixPGQuote($usr_url)."',";
  2945. $SQLStmt.=" usr_telRejoindre = '".fixPGQuote($usr_telRejoindre)."',";
  2946. $SQLStmt.=" usr_telTravail = '".fixPGQuote($usr_telTravail)."',";
  2947. $SQLStmt.=" usr_telMaison = '".fixPGQuote($usr_telMaison)."',";
  2948. $SQLStmt.=" usr_telCellulaire = '".fixPGQuote($usr_telCellulaire)."',";
  2949. $SQLStmt.=" usr_telPage = '".fixPGQuote($usr_telPage)."',";
  2950. $SQLStmt.=" usr_telFax = '".fixPGQuote($usr_telFax)."',";
  2951. $SQLStmt.=" usr_adresse = '".fixPGQuote($usr_adresse)."',";
  2952. $SQLStmt.=" usr_ville = '".fixPGQuote($usr_ville)."',";
  2953. $SQLStmt.=" usr_codePostal = '".fixPGQuote($usr_codePostal)."',";
  2954. $SQLStmt.=" usr_societe = '".fixPGQuote($usr_societe)."',";
  2955. $SQLStmt.=" usr_fonction = '".fixPGQuote($usr_fonction)."',";
  2956. $SQLStmt.=" usr_locale = '".fixPGQuote($usr_locale)."',";
  2957. if (isDate($usr_dateNaissance)){
  2958. $SQLStmt.=" usr_dateNaissance = '".fixPGQuote($usr_dateNaissance)."'";
  2959. }
  2960. else{
  2961. $SQLStmt.=" usr_dateNaissance = NULL";
  2962. }
  2963. $SQLStmt.=" WHERE usr_id = ".$id;
  2964. return $SQLStmt;
  2965. }
  2966. ///////////////////////////////////////////////////////////////////////////////////////
  2967. // Retourne la requete SQL necessaire pour faire un UPDATE
  2968. ///////////////////////////////////////////////////////////////////////////////////////
  2969. function getSQLStmtUpdUsagerLDAP($id, $usr_nom, $usr_prenom, $usr_email, $usr_telTravail, $usr_fonction, $usr_LDAP, $li_id, $usr_valide){
  2970. $SQLStmt="UPDATE usager SET";
  2971. $SQLStmt.=" usr_nom = '".fixPGQuote(rtrim($usr_nom))."',";
  2972. $SQLStmt.=" usr_prenom = '".fixPGQuote(rtrim($usr_prenom))."',";
  2973. $SQLStmt.=" usr_email = '".fixPGQuote($usr_email)."',";
  2974. $SQLStmt.=" usr_telTravail = '".fixPGQuote($usr_telTravail)."',";
  2975. $SQLStmt.=" usr_fonction = '".fixPGQuote($usr_fonction)."',";
  2976. if (!strcasecmp($usr_LDAP,"t")){
  2977. $SQLStmt.=" usr_LDAP = 't',";
  2978. }
  2979. else{
  2980. $SQLStmt.=" usr_LDAP = 'f',";
  2981. }
  2982. if (is_numeric($li_id)){
  2983. $SQLStmt.=" li_id = ".fixPGQuote($li_id).",";
  2984. }
  2985. else{
  2986. $SQLStmt.=" li_id = NULL,";
  2987. }
  2988. if (!strcasecmp($usr_valide,"t")){
  2989. $SQLStmt.=" usr_valide = 't'";
  2990. }
  2991. else{
  2992. $SQLStmt.=" usr_valide = 'f'";
  2993. }
  2994. $SQLStmt.=" WHERE usr_id = ".$id;
  2995. return $SQLStmt;
  2996. }
  2997. ///////////////////////////////////////////////////////////////////////////////////////
  2998. // Retourne la requete SQL necessaire pour faire un UPDATE
  2999. ///////////////////////////////////////////////////////////////////////////////////////
  3000. function getSQLStmtUpdUsagerLogged($usr_id, $usr_enLigne){
  3001. $SQLStmt="UPDATE usager SET";
  3002. if (!strcasecmp($usr_enLigne,"t")){
  3003. $SQLStmt.=" usr_enLigne = 't',";
  3004. $SQLStmt.=" usr_dernierAcces = NOW()";
  3005. }
  3006. else{
  3007. $SQLStmt.=" usr_enLigne = 'f'";
  3008. }
  3009. $SQLStmt.=" WHERE usr_id = " . $usr_id;
  3010. return $SQLStmt;
  3011. }
  3012. ///////////////////////////////////////////////////////////////////////////////////////
  3013. // Retourne la requete SQL necessaire pour faire un UPDATE
  3014. ///////////////////////////////////////////////////////////////////////////////////////
  3015. function getSQLStmtUpdUsagerPassword($id, $usr_psw){
  3016. $SQLStmt="UPDATE usager SET";
  3017. $SQLStmt.=" usr_psw = '".fixPGQuote($usr_psw)."'";
  3018. $SQLStmt.=" WHERE usr_id = ".$id;
  3019. return $SQLStmt;
  3020. }
  3021. ///////////////////////////////////////////////////////////////////////////////////////
  3022. // Retourne la requete SQL necessaire pour faire un SELECT
  3023. ///////////////////////////////////////////////////////////////////////////////////////
  3024. function getSQLStmtReqActivite($act_id){
  3025. $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";
  3026. $SQLStmt.=" FROM activite, projet";
  3027. $SQLStmt.=" WHERE activite.prj_id = projet.prj_id";
  3028. $SQLStmt.=" AND act_id=".$act_id;
  3029. return $SQLStmt;
  3030. }
  3031. ///////////////////////////////////////////////////////////////////////////////////////
  3032. // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
  3033. ///////////////////////////////////////////////////////////////////////////////////////
  3034. function getSQLStmtReqActiviteLAST(){
  3035. $SQLStmt="SELECT MAX(act_id) FROM activite";
  3036. return $SQLStmt;
  3037. }
  3038. ///////////////////////////////////////////////////////////////////////////////////////
  3039. // Retourne la requete SQL necessaire pour faire un SELECT
  3040. ///////////////////////////////////////////////////////////////////////////////////////
  3041. function getSQLStmtReqActivites($prj_id, $indx){
  3042. $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";
  3043. $SQLStmt.=" FROM activite, projet";
  3044. $SQLStmt.=" WHERE activite.prj_id = projet.prj_id";
  3045. if (is_numeric($prj_id)){
  3046. $SQLStmt.=" AND activite.prj_id=".$prj_id;
  3047. }
  3048. if ($indx!=""){
  3049. if ($indx=="datea"){
  3050. $SQLStmt.=" ORDER BY act_dateDebut ASC, act_dateFin ASC";
  3051. }
  3052. elseif ($indx=="dated"){
  3053. $SQLStmt.=" ORDER BY act_dateDebut DESC, act_dateFin DESC";
  3054. }
  3055. }
  3056. return $SQLStmt;
  3057. }
  3058. ///////////////////////////////////////////////////////////////////////////////////////
  3059. // Retourne la requete SQL necessaire pour faire un SELECT
  3060. ///////////////////////////////////////////////////////////////////////////////////////
  3061. function getSQLStmtReqAtelier($atl_id){
  3062. $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";
  3063. $SQLStmt.=" FROM atelier LEFT JOIN usager ON atelier.usr_id = usager.usr_id";
  3064. $SQLStmt.=" WHERE atl_id=".$atl_id;
  3065. return ($SQLStmt);
  3066. }
  3067. ///////////////////////////////////////////////////////////////////////////////////////
  3068. // Retourne la requete SQL necessaire pour faire un SELECT
  3069. ///////////////////////////////////////////////////////////////////////////////////////
  3070. function getSQLStmtReqAtelierClasses($atl_id){
  3071. $SQLStmt="SELECT classe.cla_id, classe.cla_Complete";
  3072. $SQLStmt.=" FROM atelier_classe, classe";
  3073. $SQLStmt.=" WHERE atelier_classe.cla_id=classe.cla_id";
  3074. $SQLStmt.=" AND atelier_classe.atl_id = " . $atl_id;
  3075. return ($SQLStmt);
  3076. }
  3077. ///////////////////////////////////////////////////////////////////////////////////////
  3078. // Retourne la requete SQL necessaire pour faire un SELECT
  3079. ///////////////////////////////////////////////////////////////////////////////////////
  3080. function getSQLStmtReqAtelierClienteles($atl_id){
  3081. $SQLStmt="SELECT clientele.cli_id, clientele.cli_clientele, clientele.cli_complete";
  3082. $SQLStmt.=" FROM atelier_clientele, clientele";
  3083. $SQLStmt.=" WHERE atelier_clientele.cli_id=clientele.cli_id";
  3084. $SQLStmt.=" AND atelier_clientele.atl_id = " . $atl_id;
  3085. return ($SQLStmt);
  3086. }
  3087. ///////////////////////////////////////////////////////////////////////////////////////
  3088. // Retourne la requete SQL necessaire pour faire un SELECT
  3089. ///////////////////////////////////////////////////////////////////////////////////////
  3090. function getSQLStmtReqAtelierExpertises($atl_id){
  3091. $SQLStmt="SELECT expertise.exp_id, expertise.exp_Complete";
  3092. $SQLStmt.=" FROM atelier_expertise, expertise";
  3093. $SQLStmt.=" WHERE atelier_expertise.exp_id=expertise.exp_id";
  3094. $SQLStmt.=" AND atelier_expertise.atl_id = " . $atl_id;
  3095. return ($SQLStmt);
  3096. }
  3097. ///////////////////////////////////////////////////////////////////////////////////////
  3098. // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
  3099. ///////////////////////////////////////////////////////////////////////////////////////
  3100. function getSQLStmtReqAtelierLAST(){
  3101. $SQLStmt="SELECT MAX(atl_id) FROM atelier";
  3102. return $SQLStmt;
  3103. }
  3104. ///////////////////////////////////////////////////////////////////////////////////////
  3105. // Retourne la requete SQL necessaire pour faire un SELECT
  3106. ///////////////////////////////////////////////////////////////////////////////////////
  3107. function getSQLStmtReqAtelierProjets($atl_id){
  3108. $SQLStmt="SELECT projet.prj_id, projet.prj_projet";
  3109. $SQLStmt.=" FROM projet, projet_atelier";
  3110. $SQLStmt.=" WHERE projet.prj_id = projet_atelier.prj_id";
  3111. $SQLStmt.=" AND projet_atelier.atl_id = ".$atl_id;
  3112. $SQLStmt.=" ORDER BY projet.prj_projet";
  3113. return($SQLStmt);
  3114. }
  3115. function getSQLStmtReqAtelierProjetsAdminProjet($atl_id, $usrid){
  3116. $subsql = "SELECT prj_id FROM projetAdmin WHERE usr_id = $usrid";
  3117. $SQLStmt="SELECT projet.prj_id, projet.prj_projet";
  3118. $SQLStmt.=" FROM projet, projet_atelier";
  3119. $SQLStmt.=" WHERE projet.prj_id = projet_atelier.prj_id";
  3120. $SQLStmt.=" AND projet_atelier.atl_id = ".$atl_id;
  3121. $SQLStmt.=" AND projet.prj_id IN ($subsql)";
  3122. $SQLStmt.=" ORDER BY projet.prj_projet";
  3123. return($SQLStmt);
  3124. }
  3125. ///////////////////////////////////////////////////////////////////////////////////////
  3126. // Retourne la requete SQL necessaire pour faire un SELECT
  3127. ///////////////////////////////////////////////////////////////////////////////////////
  3128. function getSQLStmtReqAteliers($mot, $motlnk, $prj_id, $cla_id, $exp_id, $cli_id, $alacarte, $valide, $indx){
  3129. $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";
  3130. $SQLStmt.=" FROM atelier LEFT JOIN session ON atelier.atl_id = session.atl_id";
  3131. $SQLStmt.=" WHERE atelier.atl_id = atelier.atl_id";
  3132. if ($mot!=""){
  3133. if ($motlnk!="and" && $motlnk!="or"){
  3134. $motlnk="and"; //valeur par defaut : securite
  3135. }
  3136. $arrMot=getArrayFromStringMot($mot);
  3137. $SQLStmt.=" AND (";
  3138. for ($i=0; $i<count($arrMot); $i++){
  3139. $SQLStmt .= " ( ";
  3140. $SQLStmt .= accentInsensitiveLike("atl_atelier", $arrMot[$i]);
  3141. $SQLStmt .= " OR " . accentInsensitiveLike("atl_description", $arrMot[$i]);
  3142. $SQLStmt .= " ) ";
  3143. if ($i<count($arrMot)-1){
  3144. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  3145. }
  3146. }
  3147. $SQLStmt.=")";
  3148. }
  3149. if (is_numeric($prj_id)){
  3150. $SQLStmt.=" AND atelier.atl_id IN (";
  3151. $SQLStmt.=" SELECT atl_id";
  3152. $SQLStmt.=" FROM projet_atelier";
  3153. $SQLStmt.=" WHERE prj_id=".$prj_id;
  3154. $SQLStmt.=")";
  3155. }
  3156. if (is_numeric($cla_id)){
  3157. $SQLStmt.=" AND atelier.atl_id IN (";
  3158. $SQLStmt.=" SELECT atl_id";
  3159. $SQLStmt.=" FROM atelier_classe";
  3160. $SQLStmt.=" WHERE cla_id=".$cla_id;
  3161. $SQLStmt.=")";
  3162. }
  3163. if (is_numeric($exp_id)){
  3164. $SQLStmt.=" AND atelier.atl_id IN (";
  3165. $SQLStmt.=" SELECT atl_id";
  3166. $SQLStmt.=" FROM atelier_expertise";
  3167. $SQLStmt.=" WHERE exp_id=".$exp_id;
  3168. $SQLStmt.=")";
  3169. }
  3170. if (is_numeric($cli_id)){
  3171. $SQLStmt.=" AND atelier.atl_id IN (";
  3172. $SQLStmt.=" SELECT atl_id";
  3173. $SQLStmt.=" FROM atelier_clientele";
  3174. $SQLStmt.=" WHERE cli_id=".$cli_id;
  3175. $SQLStmt.=")";
  3176. }
  3177. if ($alacarte!=""){
  3178. if (!strcasecmp($alacarte,"t")){
  3179. $SQLStmt.=" AND atl_alacarteDisponible ='t'";
  3180. } else {
  3181. $SQLStmt.=" AND atl_alacarteDisponible ='f'";
  3182. }
  3183. }
  3184. if ($valide!=""){
  3185. if (!strcasecmp($valide,"t")){
  3186. $SQLStmt.=" AND atl_valide='t'";
  3187. } else {
  3188. $SQLStmt.=" AND atl_valide='f'";
  3189. }
  3190. }
  3191. $SQLStmt.=" GROUP BY atelier.atl_id, atl_atelier, atl_description, atl_alacartedisponible, atl_valide";
  3192. if ($indx!=""){
  3193. if ($indx=="ateliera") {
  3194. $SQLStmt.=" ORDER BY atl_atelier ASC";
  3195. } else if ($indx=="atelierd") {
  3196. $SQLStmt.=" ORDER BY atl_atelier DESC";
  3197. } else if ($indx=="projeta") {
  3198. $SQLStmt.=" ORDER BY projetListe ASC";
  3199. } else if ($indx=="projetd") {
  3200. $SQLStmt.=" ORDER BY projetListe DESC";
  3201. } else if ($indx=="nbsessiona") {
  3202. $SQLStmt.=" ORDER BY nbSession ASC";
  3203. } else if ($indx=="nbsessiond") {
  3204. $SQLStmt.=" ORDER BY nbSession DESC";
  3205. } else if ($indx=="nbinscriptiona") {
  3206. $SQLStmt.=" ORDER BY nbInscription ASC";
  3207. } else if ($indx=="nbinscriptiond") {
  3208. $SQLStmt.=" ORDER BY nbInscription DESC";
  3209. }
  3210. }
  3211. return $SQLStmt;
  3212. }
  3213. function getSQLStmtReqAteliersAdminProjet($mot, $motlnk, $prj_id, $cla_id, $exp_id, $cli_id, $alacarte, $valide, $usrid, $indx){
  3214. $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";
  3215. $SQLStmt.=" FROM atelier LEFT JOIN session ON atelier.atl_id = session.atl_id";
  3216. $SQLStmt.=" WHERE atelier.atl_id = atelier.atl_id";
  3217. if ($mot!=""){
  3218. if ($motlnk!="and" && $motlnk!="or"){
  3219. $motlnk="and"; //valeur par defaut : securite
  3220. }
  3221. $arrMot=getArrayFromStringMot($mot);
  3222. $SQLStmt.=" AND (";
  3223. for ($i=0; $i<count($arrMot); $i++){
  3224. $SQLStmt .= accentInsensitiveLike("atl_atelier", $arrMot[$i]);
  3225. $SQLStmt .= " OR " . accentInsensitiveLike("atl_description", $arrMot[$i]);
  3226. if ($i<count($arrMot)-1){
  3227. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  3228. }
  3229. }
  3230. $SQLStmt.=")";
  3231. }
  3232. if (is_numeric($prj_id)){
  3233. $SQLStmt.=" AND atelier.atl_id IN (";
  3234. $SQLStmt.=" SELECT atl_id";
  3235. $SQLStmt.=" FROM projet_atelier";
  3236. $SQLStmt.=" WHERE prj_id=".$prj_id;
  3237. $SQLStmt.=")";
  3238. }
  3239. if (is_numeric($cla_id)){
  3240. $SQLStmt.=" AND atelier.atl_id IN (";
  3241. $SQLStmt.=" SELECT atl_id";
  3242. $SQLStmt.=" FROM atelier_classe";
  3243. $SQLStmt.=" WHERE cla_id=".$cla_id;
  3244. $SQLStmt.=")";
  3245. }
  3246. if (is_numeric($exp_id)){
  3247. $SQLStmt.=" AND atelier.atl_id IN (";
  3248. $SQLStmt.=" SELECT atl_id";
  3249. $SQLStmt.=" FROM atelier_expertise";
  3250. $SQLStmt.=" WHERE exp_id=".$exp_id;
  3251. $SQLStmt.=")";
  3252. }
  3253. if (is_numeric($cli_id)){
  3254. $SQLStmt.=" AND atelier.atl_id IN (";
  3255. $SQLStmt.=" SELECT atl_id";
  3256. $SQLStmt.=" FROM atelier_clientele";
  3257. $SQLStmt.=" WHERE cli_id=".$cli_id;
  3258. $SQLStmt.=")";
  3259. }
  3260. if (is_numeric($usrid)){
  3261. $SQLStmt.=" AND atelier.atl_id IN (";
  3262. $SQLStmt.=" SELECT atl_id";
  3263. $SQLStmt.=" FROM projetadmin JOIN projet_atelier USING (prj_id)";
  3264. $SQLStmt.=" WHERE usr_id = $usrid";
  3265. $SQLStmt.=")";
  3266. }
  3267. if ($alacarte!=""){
  3268. if (!strcasecmp($alacarte,"t")){
  3269. $SQLStmt.=" AND atl_alacarteDisponible ='t'";
  3270. } else {
  3271. $SQLStmt.=" AND atl_alacarteDisponible ='f'";
  3272. }
  3273. }
  3274. if ($valide!=""){
  3275. if (!strcasecmp($valide,"t")){
  3276. $SQLStmt.=" AND atl_valide='t'";
  3277. } else {
  3278. $SQLStmt.=" AND atl_valide='f'";
  3279. }
  3280. }
  3281. $SQLStmt.=" GROUP BY atelier.atl_id, atl_atelier, atl_description, atl_alacartedisponible, atl_valide";
  3282. if ($indx!=""){
  3283. if ($indx=="ateliera") {
  3284. $SQLStmt.=" ORDER BY atl_atelier ASC";
  3285. } else if ($indx=="atelierd") {
  3286. $SQLStmt.=" ORDER BY atl_atelier DESC";
  3287. } else if ($indx=="projeta") {
  3288. $SQLStmt.=" ORDER BY projetListe ASC";
  3289. } else if ($indx=="projetd") {
  3290. $SQLStmt.=" ORDER BY projetListe DESC";
  3291. } else if ($indx=="nbsessiona") {
  3292. $SQLStmt.=" ORDER BY nbSession ASC";
  3293. } else if ($indx=="nbsessiond") {
  3294. $SQLStmt.=" ORDER BY nbSession DESC";
  3295. } else if ($indx=="nbinscriptiona") {
  3296. $SQLStmt.=" ORDER BY nbInscription ASC";
  3297. } else if ($indx=="nbinscriptiond") {
  3298. $SQLStmt.=" ORDER BY nbInscription DESC";
  3299. }
  3300. }
  3301. return $SQLStmt;
  3302. }
  3303. ///////////////////////////////////////////////////////////////////////////////////////
  3304. // Retourne la requete SQL necessaire pour faire un SELECT
  3305. ///////////////////////////////////////////////////////////////////////////////////////
  3306. function getSQLStmtReqCedule($ced_id){
  3307. $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";
  3308. $SQLStmt.=" FROM ceduleur Left Join gabarit On ceduleur.gab_id = gabarit.gab_id";
  3309. $SQLStmt.=" Where ceduleur.ced_id = ".$ced_id;
  3310. return $SQLStmt;
  3311. }
  3312. ///////////////////////////////////////////////////////////////////////////////////////
  3313. // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
  3314. ///////////////////////////////////////////////////////////////////////////////////////
  3315. function getSQLStmtReqCeduleLAST(){
  3316. $SQLStmt="SELECT MAX(ced_id) FROM ceduleur";
  3317. return $SQLStmt;
  3318. }
  3319. ///////////////////////////////////////////////////////////////////////////////////////
  3320. // Retourne la requete SQL necessaire pour faire un SELECT
  3321. ///////////////////////////////////////////////////////////////////////////////////////
  3322. function getSQLStmtReqCedules($mot, $motlnk, $gabarit, $valide, $gab_valide, $indx){
  3323. $SQLStmt="SELECT ced_id, ced_cedule, ceduleur.gab_id, gabarit.gab_gabarit, gabarit.gab_param, gabarit.gab_valide, ced_paramValeur, ced_intervalle, ced_valide";
  3324. $SQLStmt.=" FROM ceduleur LEFT JOIN gabarit ON ceduleur.gab_id = gabarit.gab_id WHERE 1=1";
  3325. if ($mot!=""){
  3326. if ($motlnk!="and" && $motlnk!="or"){
  3327. $motlnk="and"; //valeur par defaut : securite
  3328. }
  3329. $arrMot=getArrayFromStringMot($mot);
  3330. $SQLStmt.=" AND (";
  3331. for ($i=0; $i<count($arrMot); $i++){
  3332. $SQLStmt.="(ced_cedule ILIKE '%".fixPGQuote($arrMot[$i])."%'";
  3333. $SQLStmt.=" OR gabarit.gab_gabarit ILIKE '%".fixPGQuote($arrMot[$i])."%')";
  3334. if ($i<count($arrMot)-1){
  3335. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  3336. }
  3337. }
  3338. $SQLStmt.=")";
  3339. }
  3340. if (is_numeric($gabarit)){
  3341. $SQLStmt.=" AND gabarit.gab_id = ".$gabarit;
  3342. }
  3343. if ($valide!=""){
  3344. if (!strcasecmp($valide,"t")){
  3345. $SQLStmt.=" AND ced_valide='t'";
  3346. } else {
  3347. $SQLStmt.=" AND ced_valide='f'";
  3348. }
  3349. }
  3350. if ($gab_valide!=""){
  3351. if (!strcasecmp($gab_valide,"t")){
  3352. $SQLStmt.=" AND gab_valide='t'";
  3353. } else {
  3354. $SQLStmt.=" AND gab_valide='f'";
  3355. }
  3356. }
  3357. if ($indx!=""){
  3358. if ($indx=="cedulea") {
  3359. $SQLStmt.=" ORDER BY ced_cedule ASC, gab_gabarit ASC";
  3360. } else if ($indx=="ceduled") {
  3361. $SQLStmt.=" ORDER BY ced_cedule DESC, gab_gabarit DESC";
  3362. } else if ($indx=="gabarita") {
  3363. $SQLStmt.=" ORDER BY gab_gabarit ASC, ced_cedule ASC";
  3364. } else if ($indx=="gabaritd") {
  3365. $SQLStmt.=" ORDER BY gab_gabarit DESC, ced_cedule DESC";
  3366. } else if ($indx=="intervallea") {
  3367. $SQLStmt.=" ORDER BY ced_intervalle ASC, ced_cedule ASC";
  3368. } else if ($indx=="intervalled") {
  3369. $SQLStmt.=" ORDER BY ced_intervalle DESC, ced_cedule DESC";
  3370. }
  3371. }
  3372. return $SQLStmt;
  3373. }
  3374. ///////////////////////////////////////////////////////////////////////////////////////
  3375. // Retourne la requete SQL necessaire pour faire un SELECT
  3376. ///////////////////////////////////////////////////////////////////////////////////////
  3377. function getSQLStmtReqGabaritBalises($gab_id){
  3378. $SQLStmt="SELECT gb_id, gb_balise, gb_champ, gb_description";
  3379. $SQLStmt.=" FROM gabaritBalise";
  3380. $SQLStmt.=" WHERE gb_id = gb_id";
  3381. if (is_numeric($gab_id)){
  3382. $SQLStmt.=" AND gab_id = ".$gab_id;
  3383. }
  3384. $SQLStmt.=" ORDER BY gb_balise";
  3385. return ($SQLStmt);
  3386. }
  3387. ///////////////////////////////////////////////////////////////////////////////////////
  3388. // Retourne la requete SQL necessaire pour faire un SELECT
  3389. ///////////////////////////////////////////////////////////////////////////////////////
  3390. function getSQLStmtReqGabarit($gab_id){
  3391. $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";
  3392. $SQLStmt.=" FROM gabarit";
  3393. $SQLStmt.=" WHERE gab_id = ".$gab_id;
  3394. return ($SQLStmt);
  3395. }
  3396. ///////////////////////////////////////////////////////////////////////////////////////
  3397. // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
  3398. ///////////////////////////////////////////////////////////////////////////////////////
  3399. function getSQLStmtReqGabaritGabaritLAST(){
  3400. $SQLStmt="SELECT MAX(gab_id) FROM gabarit";
  3401. return $SQLStmt;
  3402. }
  3403. ///////////////////////////////////////////////////////////////////////////////////////
  3404. // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
  3405. ///////////////////////////////////////////////////////////////////////////////////////
  3406. function getSQLStmtReqGabaritLAST(){
  3407. $SQLStmt="SELECT MAX(gab_id) FROM gabarit";
  3408. return $SQLStmt;
  3409. }
  3410. ///////////////////////////////////////////////////////////////////////////////////////
  3411. // Retourne la requete SQL necessaire pour faire un SELECT
  3412. ///////////////////////////////////////////////////////////////////////////////////////
  3413. function getSQLStmtReqGabaritParam($gab_id){
  3414. $SQLStmt="SELECT gab_id, gab_gabarit, gab_param";
  3415. $SQLStmt.=" FROM gabarit";
  3416. $SQLStmt.=" WHERE gab_id = ".$gab_id;
  3417. return ($SQLStmt);
  3418. }
  3419. ///////////////////////////////////////////////////////////////////////////////////////
  3420. // Retourne la requete SQL necessaire pour faire un SELECT
  3421. ///////////////////////////////////////////////////////////////////////////////////////
  3422. function getSQLStmtReqGabarits($mot, $motlnk, $parent, $system, $valide, $indx){
  3423. $SQLStmt="SELECT gabarit.gab_id, gab_gabarit, gab_system, gab_valide, COUNT(gabaritBalise.gb_id) AS nbBalise";
  3424. $SQLStmt.=" FROM gabarit LEFT JOIN gabaritBalise ON gabarit.gab_id = gabaritBalise.gab_id";
  3425. $SQLStmt.=" WHERE gabarit.gab_id = gabarit.gab_id";
  3426. if ($mot!=""){
  3427. if ($motlnk!="and" && $motlnk!="or"){
  3428. $motlnk="and"; //valeur par defaut : securite
  3429. }
  3430. $arrMot=getArrayFromStringMot($mot);
  3431. $SQLStmt.=" AND (";
  3432. for ($i=0; $i<count($arrMot); $i++){
  3433. $SQLStmt.="(gab_gabarit ILIKE '%".fixPGQuote($arrMot[$i])."%'";
  3434. $SQLStmt.=" OR gab_description ILIKE '%".fixPGQuote($arrMot[$i])."%')";
  3435. if ($i<count($arrMot)-1){
  3436. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  3437. }
  3438. }
  3439. $SQLStmt.=")";
  3440. }
  3441. if ($system!=""){
  3442. if (!strcasecmp($system,"t")){
  3443. $SQLStmt.=" AND gab_system='t'";
  3444. } else {
  3445. $SQLStmt.=" AND gab_system='f'";
  3446. }
  3447. }
  3448. if ($valide!=""){
  3449. if (!strcasecmp($valide,"t")){
  3450. $SQLStmt.=" AND gab_valide='t'";
  3451. } else {
  3452. $SQLStmt.=" AND gab_valide='f'";
  3453. }
  3454. }
  3455. $SQLStmt.=" GROUP BY gabarit.gab_id, gab_gabarit, gab_system, gab_valide";
  3456. if ($indx!=""){
  3457. if ($indx=="gabarita") {
  3458. $SQLStmt.=" ORDER BY gab_gabarit ASC";
  3459. } else if ($indx=="gabaritd") {
  3460. $SQLStmt.=" ORDER BY gab_gabarit DESC";
  3461. } else if ($indx=="balisea") {
  3462. $SQLStmt.=" ORDER BY nbBalise ASC, gab_gabarit ASC";
  3463. } else if ($indx=="balised") {
  3464. $SQLStmt.=" ORDER BY nbBalise DESC, gab_gabarit DESC";
  3465. }
  3466. }
  3467. return $SQLStmt;
  3468. }
  3469. ///////////////////////////////////////////////////////////////////////////////////////
  3470. // Retourne la requete SQL necessaire pour faire un SELECT
  3471. ///////////////////////////////////////////////////////////////////////////////////////
  3472. function getSQLStmtReqInscription($usr_id, $ses_id){
  3473. return"Select insSes.usr_id, uusager.usr_nom, uusager.usr_prenom, uusager.usr_email, lieu.li_id,
  3474. lieu.li_lieu, insSes.ses_id, session.ses_code, session.atl_id, atelier.atl_atelier, session.prj_id, projet.prj_projet,
  3475. TO_CHAR( insSes.is_datesoumission, 'YYYY-MM-DD HH24:MI:SS' ) AS is_datesoumission, is_ipsoumission, insSes.ie_id,
  3476. insEt.ie_etat, insEt.ie_OK, insSes.is_majpar_usr_id, ausager.usr_nom, ausager.usr_prenom, ausager.usr_email
  3477. From inscriptionSession insSes
  3478. Left Join usager uusager On insSes.usr_id = uusager.usr_id
  3479. Left Join lieu On insSes.lieu_id_ainscription = lieu.li_id
  3480. Left Join usager ausager On insSes.is_majpar_usr_id = ausager.usr_id
  3481. Left Join inscriptionEtat insEt On insSes.ie_id = insEt.ie_id
  3482. Left Join session On insSes.ses_id = session.ses_id
  3483. Left Join atelier On session.atl_id = atelier.atl_id
  3484. Left Join projet On session.prj_id = projet.prj_id
  3485. Where insSes.usr_id = '".$usr_id."' And insSes.ses_id = '".$ses_id."'";
  3486. }
  3487. ///////////////////////////////////////////////////////////////////////////////////////
  3488. // Retourne la requete SQL necessaire pour faire un SELECT
  3489. ///////////////////////////////////////////////////////////////////////////////////////
  3490. function getSQLStmtReqUsagerAdminLieuOK($usr_id, $adminlieu_id){
  3491. $SQLStmt="SELECT usr_id";
  3492. $SQLStmt.=" FROM usager";
  3493. $SQLStmt.=" WHERE usr_id = ".$usr_id;
  3494. if (is_numeric($adminlieu_id)) {
  3495. $SQLStmt.=" AND usager.li_id IN (";
  3496. $SQLStmt.=" SELECT li_id";
  3497. $SQLStmt.=" FROM lieuadmin";
  3498. $SQLStmt.=" WHERE usr_id=".$adminlieu_id;
  3499. $SQLStmt.=")";
  3500. }
  3501. return $SQLStmt;
  3502. }
  3503. ///////////////////////////////////////////////////////////////////////////////////////
  3504. // Retourne la requete SQL necessaire pour faire un SELECT
  3505. ///////////////////////////////////////////////////////////////////////////////////////
  3506. function getSQLStmtReqInscriptionsFromSeance($seance){
  3507. $SQLStmt="SELECT inscriptionSession.usr_id, usager.usr_nom, usager.usr_prenom";
  3508. $SQLStmt.=" FROM inscriptionSession, usager, inscriptionEtat";
  3509. $SQLStmt.=" WHERE inscriptionSession.usr_id = usager.usr_id";
  3510. $SQLStmt.=" AND inscriptionSession.ie_id = inscriptionEtat.ie_id";
  3511. $SQLStmt.=" AND inscriptionEtat.ie_OK = 't'";
  3512. if (is_numeric($seance)){
  3513. $SQLStmt.=" AND inscriptionSession.ses_id = (";
  3514. $SQLStmt.=" SELECT ses_id";
  3515. $SQLStmt.=" FROM seance";
  3516. $SQLStmt.=" WHERE sea_id = ".$seance;
  3517. $SQLStmt.=")";
  3518. }
  3519. $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
  3520. return $SQLStmt;
  3521. }
  3522. //Retourne toutes les inscriptions selon les critaires, sauf la valid� qui n'est pas v�rifier.
  3523. function getSQLStmtReqInscriptions($mot, $motlnk, $session, $etat, $projet, $lieu, $arrFicheID, $nbjourstart, $indx){
  3524. return getSQLStmtReqInscriptionsFull($mot, $motlnk, $session, $etat, "", $projet, $lieu, $arrFicheID, $nbjourstart, $indx);
  3525. }
  3526. ///////////////////////////////////////////////////////////////////////////////////////
  3527. // Retourne la requete SQL necessaire pour faire un SELECT
  3528. ///////////////////////////////////////////////////////////////////////////////////////
  3529. function getSQLStmtReqInscriptionsFull($mot, $motlnk, $session, $etat, $ie_ok, $projet, $lieu, $arrFicheID, $nbjourstart, $indx){
  3530. $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";
  3531. $SQLStmt.=" FROM inscriptionSession, usager, lieu, session LEFT JOIN seance USING (ses_id), atelier, inscriptionEtat";
  3532. $SQLStmt.=" WHERE inscriptionSession.usr_id = usager.usr_id";
  3533. $SQLStmt.=" AND inscriptionSession.lieu_id_ainscription = lieu.li_id";
  3534. $SQLStmt.=" AND inscriptionSession.ses_id = session.ses_id";
  3535. $SQLStmt.=" AND session.atl_id = atelier.atl_id";
  3536. $SQLStmt.=" AND inscriptionSession.ie_id = inscriptionEtat.ie_id";
  3537. // $SQLStmt.=" AND seance.ses_id = session.ses_id";
  3538. if ($mot!=""){
  3539. if ($motlnk!="and" && $motlnk!="or"){
  3540. $motlnk="and"; //valeur par defaut : securite
  3541. }
  3542. $arrMot=getArrayFromStringMot($mot);
  3543. $SQLStmt.=" AND (";
  3544. for ($i=0; $i<count($arrMot); $i++){
  3545. $SQLStmt.="(usr_nom ILIKE '%".fixPGQuote($arrMot[$i])."%'";
  3546. $SQLStmt.=" OR usr_prenom ILIKE '%".fixPGQuote($arrMot[$i])."%')";
  3547. if ($i<count($arrMot)-1){
  3548. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  3549. }
  3550. }
  3551. $SQLStmt.=")";
  3552. }
  3553. if (is_array($session)){
  3554. $SQLStmt.= " AND (inscriptionSession.ses_id=$session[0]";
  3555. for( $i=1; $i<count($session); $i++ ) {
  3556. $SQLStmt.=" OR inscriptionSession.ses_id=".$session[$i];
  3557. }
  3558. $SQLStmt.= ")";
  3559. }
  3560. if (is_numeric($session)){
  3561. $SQLStmt.=" AND inscriptionSession.ses_id=".$session;
  3562. }
  3563. if (is_numeric($etat)){
  3564. $SQLStmt.=" AND inscriptionSession.ie_id=".$etat;
  3565. }
  3566. if($ie_ok != ""){
  3567. if($ie_ok == "null"){
  3568. $SQLStmt.=" AND inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok is null)";
  3569. } else {
  3570. $SQLStmt.=" AND inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok ='$ie_ok')";
  3571. }
  3572. }
  3573. if (is_numeric($projet)){
  3574. $SQLStmt.=" AND session.prj_id=".$projet;
  3575. }
  3576. if (is_numeric($lieu)){
  3577. $SQLStmt.=" AND lieu.li_id=".$lieu;
  3578. }
  3579. if (is_array($arrFicheID)){
  3580. $SQLStmt.=" AND (inscriptionSession.ses_id <> inscriptionSession.ses_id";
  3581. for ($i=0; $i<count($arrFicheID); $i++){
  3582. ereg("^([0-9]+)[.]{1}([0-9]+)$",$arrFicheID[$i],$regs);
  3583. $usr_id=$regs[1];
  3584. $ses_id=$regs[2];
  3585. if ((is_numeric($usr_id))&&(is_numeric($ses_id))){
  3586. $SQLStmt.=" OR (inscriptionSession.usr_id=".$usr_id;
  3587. $SQLStmt.=" AND inscriptionSession.ses_id=".$ses_id.")";
  3588. }
  3589. }
  3590. $SQLStmt.=" )";
  3591. }
  3592. $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";
  3593. if (is_numeric($nbjourstart)){
  3594. $SQLStmt.=" HAVING min(seance.sea_dateDebut) BETWEEN CURRENT_DATE AND CURRENT_DATE+". $nbjourstart;
  3595. }
  3596. if ($indx!=""){
  3597. if ($indx=="noma"){
  3598. $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
  3599. } else if ($indx=="nomd") {
  3600. $SQLStmt.=" ORDER BY usr_nom DESC, usr_prenom DESC";
  3601. } else if ($indx=="lieua") {
  3602. $SQLStmt.=" ORDER BY li_lieu ASC";
  3603. } else if ($indx=="lieud") {
  3604. $SQLStmt.=" ORDER BY li_lieu DESC";
  3605. } else if ($indx=="sessiona") {
  3606. $SQLStmt.=" ORDER BY ses_code ASC";
  3607. } else if ($indx=="sessiond") {
  3608. $SQLStmt.=" ORDER BY ses_code DESC";
  3609. } else if ($indx=="datea") {
  3610. $SQLStmt.=" ORDER BY is_datesoumission ASC";
  3611. } else if ($indx=="dated") {
  3612. $SQLStmt.=" ORDER BY is_datesoumission DESC";
  3613. } else if ($indx=="etata") {
  3614. $SQLStmt.=" ORDER BY ie_OK ASC, ie_etat ASC";
  3615. } else if ($indx=="etatd") {
  3616. $SQLStmt.=" ORDER BY ie_OK DESC, ie_etat DESC";
  3617. } else if ($indx=="usrtitrea") {
  3618. $SQLStmt.=" ORDER BY usager.usr_fonction ASC";
  3619. } else if ($indx=="usrtitred") {
  3620. $SQLStmt.=" ORDER BY usager.usr_fonction DESC";
  3621. }
  3622. }
  3623. return $SQLStmt;
  3624. }
  3625. function getSQLStmtReqInscriptionsAdminProjet($mot, $motlnk, $session, $etat, $projet, $lieu, $arrFicheID, $nbjourstart, $usrid, $indx){
  3626. return getSQLStmtReqInscriptionsAdminProjetFull( $mot, $motlnk, $session, $etat, "", $projet, $lieu, $arrFicheID, $nbjourstart, $usrid, $indx );
  3627. }
  3628. function getSQLStmtReqInscriptionsAdminProjetFull( $mot, $motlnk, $session, $etat, $ie_ok, $projet, $lieu, $arrFicheID, $nbjourstart, $usrid, $indx ){
  3629. $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";
  3630. $SQLStmt .= " From inscriptionSession
  3631. Left Join usager On inscriptionSession.usr_id = usager.usr_id
  3632. Left Join lieu On inscriptionSession.lieu_id_ainscription = lieu.li_id
  3633. Left Join session On inscriptionSession.ses_id = session.ses_id
  3634. Left Join seance On session.ses_id = seance.ses_id
  3635. Left Join atelier On session.atl_id = atelier.atl_id
  3636. Left Join inscriptionEtat On inscriptionSession.ie_id = inscriptionEtat.ie_id";
  3637. $where = "";
  3638. // Recherche le ou les mots demand�s par l'usager
  3639. if( $mot != "" ){
  3640. if( strtolower( $motlnk ) != "or" ){
  3641. $motlnk="and"; //valeur par defaut : securite
  3642. }
  3643. $arrMot = getArrayFromStringMot($mot);
  3644. if( count( $arrMot ) > 0 ){
  3645. $where = "(";
  3646. for( $i = 0; $i < count( $arrMot ); $i++ ){
  3647. $where .= accentInsensitiveLike( "usr_nom", $arrMot[$i] );
  3648. if( $i < count( $arrMot ) - 1 ){
  3649. $where .= " " . $motlnk . " "; //OR ou AND
  3650. }
  3651. }
  3652. $where .= ") And ";
  3653. }
  3654. }
  3655. // Recherche parmi les sessions re�ues si une liste est fournie
  3656. if ( is_array( $session ) && count( $session ) > 0 ){
  3657. $where .= "( ";
  3658. for( $i = 0; $i < count( $session ); $i++ ){
  3659. if( $i <> 0 ){
  3660. $where .= "Or ";
  3661. }
  3662. $where .= "inscriptionSession.ses_id = '" . $session[ $i ] . "' ";
  3663. }
  3664. $where .= ") And ";
  3665. } else if( is_numeric( $session ) ){
  3666. $where .= "inscriptionSession.ses_id = '" . $session . "' And ";
  3667. }
  3668. if( is_numeric( $etat ) ){
  3669. $where .= "inscriptionSession.ie_id = '" . $etat . "' And ";
  3670. }
  3671. if($ie_ok != ""){
  3672. if($ie_ok == "null"){
  3673. $where.="inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok is null) AND ";
  3674. } else {
  3675. $where.="inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok ='$ie_ok') AND ";
  3676. }
  3677. }
  3678. if( is_numeric( $projet ) ){
  3679. $where .= "session.prj_id = '" . $projet . "' And ";
  3680. }
  3681. if( is_numeric( $lieu ) ){
  3682. $where .= "lieu.li_id = '" . $lieu . "' And ";
  3683. }
  3684. if( is_array( $arrFicheID ) && count( $arrFicheID ) > 0 ){
  3685. $where .= " ( ";
  3686. for( $i = 0; $i < count( $arrFicheID ); $i++ ){
  3687. if( $i <> 0 ){
  3688. $where .= "Or ";
  3689. }
  3690. ereg( "^([0-9]+)[.]{1}([0-9]+)$", $arrFicheID[$i], $regs );
  3691. $usr_id = $regs[1];
  3692. $ses_id = $regs[2];
  3693. if( ( is_numeric( $usr_id ) ) && ( is_numeric( $ses_id ) ) ){
  3694. $where .= "( inscriptionSession.usr_id = '" . $usr_id . "' And inscriptionSession.ses_id = '" . $ses_id . "' ) ";
  3695. }
  3696. }
  3697. $where .= " ) And ";
  3698. }
  3699. // Recherche l'admin-projet
  3700. $where .= "session.prj_id IN ( SELECT prj_id FROM projetAdmin WHERE usr_id = '" . $usrid . "' )";
  3701. $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";
  3702. if( is_numeric( $nbjourstart ) ){
  3703. $SQLStmt .= " HAVING min( seance.sea_dateDebut ) BETWEEN CURRENT_DATE AND CURRENT_DATE + " . $nbjourstart;
  3704. }
  3705. switch( $indx ){
  3706. case "noma" :
  3707. $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
  3708. break;
  3709. case "nomd" :
  3710. $SQLStmt.=" ORDER BY usr_nom DESC, usr_prenom DESC";
  3711. break;
  3712. case "lieua" :
  3713. $SQLStmt.=" ORDER BY li_lieu ASC";
  3714. break;
  3715. case "lieud" :
  3716. $SQLStmt.=" ORDER BY li_lieu DESC";
  3717. break;
  3718. case "sessiona" :
  3719. $SQLStmt.=" ORDER BY ses_code ASC";
  3720. break;
  3721. case "sessiond" :
  3722. $SQLStmt.=" ORDER BY ses_code DESC";
  3723. break;
  3724. case "datea" :
  3725. $SQLStmt.=" ORDER BY is_datesoumission ASC";
  3726. break;
  3727. case "dated" :
  3728. $SQLStmt.=" ORDER BY is_datesoumission DESC";
  3729. break;
  3730. case "etata" :
  3731. $SQLStmt.=" ORDER BY ie_OK ASC, ie_etat ASC";
  3732. break;
  3733. case "etatd" :
  3734. $SQLStmt.=" ORDER BY ie_OK DESC, ie_etat DESC";
  3735. break;
  3736. case "usrtitrea" :
  3737. $SQLStmt.=" ORDER BY usager.usr_fonction ASC";
  3738. break;
  3739. case "usrtitred" :
  3740. $SQLStmt.=" ORDER BY usager.usr_fonction DESC";
  3741. break;
  3742. }
  3743. return $SQLStmt;
  3744. }
  3745. ///////////////////////////////////////////////////////////////////////////////////////
  3746. // Retourne la requete SQL necessaire pour faire un SELECT
  3747. ///////////////////////////////////////////////////////////////////////////////////////
  3748. function getSQLStmtReqInscriptionsAnimateur($mot, $motlnk, $session, $etat, $svalide, $projet, $lieu, $arrFicheID, $animID, $nbjourstart, $indx){
  3749. $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";
  3750. $SQLStmt.=" FROM inscriptionSession, usager, lieu, session LEFT JOIN seance USING (ses_id), atelier, inscriptionEtat";
  3751. $SQLStmt.=" WHERE inscriptionSession.usr_id = usager.usr_id";
  3752. $SQLStmt.=" AND inscriptionSession.lieu_id_ainscription = lieu.li_id";
  3753. $SQLStmt.=" AND inscriptionSession.ses_id = session.ses_id";
  3754. $SQLStmt.=" AND session.atl_id = atelier.atl_id";
  3755. $SQLStmt.=" AND inscriptionSession.ie_id = inscriptionEtat.ie_id";
  3756. // $SQLStmt.=" AND seance.ses_id = session.ses_id";
  3757. if ($mot!=""){
  3758. if ($motlnk!="and" && $motlnk!="or"){
  3759. $motlnk="and"; //valeur par defaut : securite
  3760. }
  3761. $arrMot=getArrayFromStringMot($mot);
  3762. $SQLStmt.=" AND (";
  3763. for ($i=0; $i<count($arrMot); $i++){
  3764. $SQLStmt.="(usr_nom ILIKE '%".fixPGQuote($arrMot[$i])."%'";
  3765. $SQLStmt.=" OR usr_prenom ILIKE '%".fixPGQuote($arrMot[$i])."%')";
  3766. if ($i<count($arrMot)-1){
  3767. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  3768. }
  3769. }
  3770. $SQLStmt.=")";
  3771. }
  3772. if (is_array($session)){
  3773. $SQLStmt.= " AND (inscriptionSession.ses_id=$session[0]";
  3774. for( $i=1; $i<count($session); $i++ ) {
  3775. $SQLStmt.=" OR inscriptionSession.ses_id=".$session[$i];
  3776. }
  3777. $SQLStmt.= ")";
  3778. }
  3779. if (is_numeric($session)){
  3780. $SQLStmt.=" AND inscriptionSession.ses_id=".$session;
  3781. }
  3782. if (is_numeric($etat)){
  3783. $SQLStmt.=" AND inscriptionSession.ie_id=".$etat;
  3784. }
  3785. if($svalide != ""){
  3786. if($svalide == "null"){
  3787. $SQLStmt.=" AND inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok is null)";
  3788. } else {
  3789. $SQLStmt.=" AND inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok ='$svalide')";
  3790. }
  3791. }
  3792. if (is_numeric($projet)){
  3793. $SQLStmt.=" AND session.prj_id=".$projet;
  3794. }
  3795. if (is_numeric($lieu)){
  3796. $SQLStmt.=" AND lieu.li_id=".$lieu;
  3797. }
  3798. if (is_array($arrFicheID)){
  3799. $SQLStmt.=" AND (inscriptionSession.ses_id <> inscriptionSession.ses_id";
  3800. for ($i=0; $i<count($arrFicheID); $i++){
  3801. ereg("^([0-9]+)[.]{1}([0-9]+)$",$arrFicheID[$i],$regs);
  3802. $usr_id=$regs[1];
  3803. $ses_id=$regs[2];
  3804. if ((is_numeric($usr_id))&&(is_numeric($ses_id))){
  3805. $SQLStmt.=" OR (inscriptionSession.usr_id=".$usr_id;
  3806. $SQLStmt.=" AND inscriptionSession.ses_id=".$ses_id.")";
  3807. }
  3808. }
  3809. $SQLStmt.=" )";
  3810. }
  3811. // specifique pour Animateur
  3812. if (is_numeric($animID)){
  3813. $SQLStmt.=" AND inscriptionSession.ses_id IN (";
  3814. $SQLStmt.=" SELECT ses_id";
  3815. $SQLStmt.=" FROM animation";
  3816. $SQLStmt.=" WHERE usr_id=".$animID;
  3817. $SQLStmt.=")";
  3818. }
  3819. $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";
  3820. if (is_numeric($nbjourstart)){
  3821. $SQLStmt.=" HAVING min(seance.sea_dateDebut) BETWEEN CURRENT_DATE AND CURRENT_DATE+". $nbjourstart;
  3822. }
  3823. if ($indx!=""){
  3824. if ($indx=="noma"){
  3825. $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
  3826. } else if ($indx=="nomd") {
  3827. $SQLStmt.=" ORDER BY usr_nom DESC, usr_prenom DESC";
  3828. } else if ($indx=="fonctiona") {
  3829. $SQLStmt.=" ORDER BY usr_fonction ASC";
  3830. } else if ($indx=="fonctiond") {
  3831. $SQLStmt.=" ORDER BY usr_fonction DESC";
  3832. } else if ($indx=="lieua") {
  3833. $SQLStmt.=" ORDER BY li_lieu ASC";
  3834. } else if ($indx=="lieud") {
  3835. $SQLStmt.=" ORDER BY li_lieu DESC";
  3836. } else if ($indx=="sessiona") {
  3837. $SQLStmt.=" ORDER BY ses_code ASC";
  3838. } else if ($indx=="sessiond") {
  3839. $SQLStmt.=" ORDER BY ses_code DESC";
  3840. } else if ($indx=="datea") {
  3841. $SQLStmt.=" ORDER BY is_datesoumission ASC";
  3842. } else if ($indx=="dated") {
  3843. $SQLStmt.=" ORDER BY is_datesoumission DESC";
  3844. } else if ($indx=="etata") {
  3845. $SQLStmt.=" ORDER BY ie_OK ASC, ie_etat ASC";
  3846. } else if ($indx=="etatd") {
  3847. $SQLStmt.=" ORDER BY ie_OK DESC, ie_etat DESC";
  3848. }
  3849. }
  3850. return $SQLStmt;
  3851. }
  3852. ///////////////////////////////////////////////////////////////////////////////////////
  3853. // Retourne la requete SQL necessaire pour faire un SELECT
  3854. ///////////////////////////////////////////////////////////////////////////////////////
  3855. function getSQLStmtReqInscriptionsArraySesBefore($usr_id, $arrnSesID){
  3856. $SQLStmt="SELECT inscriptionSession.ses_id, inscriptionSession.ie_id, inscriptionEtat.ie_count, inscriptionEtat.ie_OK";
  3857. $SQLStmt.=" FROM inscriptionSession, inscriptionEtat";
  3858. $SQLStmt.=" WHERE inscriptionSession.ie_id = inscriptionEtat.ie_id";
  3859. if (count($arrnSesID)>0){
  3860. $SQLStmt.=" AND (inscriptionSession.ses_id <> inscriptionSession.ses_id";
  3861. for ($i=0; $i<count($arrnSesID); $i++){
  3862. $ses_id = $arrnSesID[$i];
  3863. if ((is_numeric($usr_id))&&(is_numeric($ses_id))){
  3864. $SQLStmt.=" OR (inscriptionSession.usr_id=".$usr_id;
  3865. $SQLStmt.=" AND inscriptionSession.ses_id=".$ses_id.")";
  3866. }
  3867. }
  3868. $SQLStmt.=" )";
  3869. }
  3870. return $SQLStmt;
  3871. }
  3872. ///////////////////////////////////////////////////////////////////////////////////////
  3873. // Retourne la requete SQL necessaire pour faire un SELECT
  3874. ///////////////////////////////////////////////////////////////////////////////////////
  3875. function getSQLStmtReqInscriptionsArrayUsrBefore($ses_id, $arrnUsrID){
  3876. $SQLStmt="SELECT inscriptionSession.usr_id, inscriptionSession.ie_id, inscriptionEtat.ie_count";
  3877. $SQLStmt.=" FROM inscriptionSession, inscriptionEtat";
  3878. $SQLStmt.=" WHERE inscriptionSession.ie_id = inscriptionEtat.ie_id";
  3879. if (count($arrnUsrID)>0){
  3880. $SQLStmt.=" AND (inscriptionSession.ses_id <> inscriptionSession.ses_id";
  3881. for ($i=0; $i<count($arrnUsrID); $i++){
  3882. $usr_id = $arrnUsrID[$i];
  3883. if ((is_numeric($usr_id))&&(is_numeric($ses_id))){
  3884. $SQLStmt.=" OR (inscriptionSession.usr_id=".$usr_id;
  3885. $SQLStmt.=" AND inscriptionSession.ses_id=".$ses_id.")";
  3886. }
  3887. }
  3888. $SQLStmt.=" )";
  3889. }
  3890. return $SQLStmt;
  3891. }
  3892. function getSQLStmtReqInscriptionsLimited($mot, $motlnk, $session, $etat, $projet, $lieu, $arrFicheID, $adminlieu, $nbjourstart, $indx)
  3893. {
  3894. return getSQLStmtReqInscriptionsLimitedFull($mot, $motlnk, $session, $etat,"", $projet, $lieu, $arrFicheID, $adminlieu, $nbjourstart, $indx);
  3895. }
  3896. ///////////////////////////////////////////////////////////////////////////////////////
  3897. // Retourne la requete SQL necessaire pour faire un SELECT
  3898. ///////////////////////////////////////////////////////////////////////////////////////
  3899. function getSQLStmtReqInscriptionsLimitedFull($mot, $motlnk, $session, $etat,$ie_ok, $projet, $lieu, $arrFicheID, $adminlieu, $nbjourstart, $indx){
  3900. $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";
  3901. $SQLStmt.=" FROM inscriptionSession, usager, lieu, session LEFT JOIN seance USING (ses_id), atelier, inscriptionEtat";
  3902. $SQLStmt.=" WHERE inscriptionSession.usr_id = usager.usr_id";
  3903. $SQLStmt.=" AND inscriptionSession.lieu_id_ainscription = lieu.li_id";
  3904. $SQLStmt.=" AND inscriptionSession.ses_id = session.ses_id";
  3905. $SQLStmt.=" AND session.atl_id = atelier.atl_id";
  3906. $SQLStmt.=" AND inscriptionSession.ie_id = inscriptionEtat.ie_id";
  3907. // $SQLStmt.=" AND seance.ses_id = session.ses_id";
  3908. if ($mot!=""){
  3909. if ($motlnk!="and" && $motlnk!="or"){
  3910. $motlnk="and"; //valeur par defaut : securite
  3911. }
  3912. $arrMot=getArrayFromStringMot($mot);
  3913. $SQLStmt.=" AND (";
  3914. for ($i=0; $i<count($arrMot); $i++){
  3915. $SQLStmt.="(usr_nom ILIKE '%".fixPGQuote($arrMot[$i])."%'";
  3916. $SQLStmt.=" OR usr_prenom ILIKE '%".fixPGQuote($arrMot[$i])."%')";
  3917. if ($i<count($arrMot)-1){
  3918. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  3919. }
  3920. }
  3921. $SQLStmt.=")";
  3922. }
  3923. if (is_array($session)){
  3924. $SQLStmt.= " AND (inscriptionSession.ses_id=$session[0]";
  3925. for( $i=1; $i<count($session); $i++ ) {
  3926. $SQLStmt.=" OR inscriptionSession.ses_id=".$session[$i];
  3927. }
  3928. $SQLStmt.= ")";
  3929. }
  3930. if (is_numeric($session)){
  3931. $SQLStmt.=" AND inscriptionSession.ses_id=".$session;
  3932. }
  3933. if($ie_ok != "" && $ie_ok != "tout"){
  3934. if($ie_ok == "null"){
  3935. $SQLStmt.=" AND inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok is null)";
  3936. } else {
  3937. $SQLStmt.=" AND inscriptionSession.ie_id IN(SELECT ie_id from inscriptionEtat where ie_ok ='$ie_ok')";
  3938. }
  3939. }
  3940. if (is_numeric($etat)){
  3941. $SQLStmt.=" AND inscriptionSession.ie_id=".$etat;
  3942. }
  3943. if (is_numeric($projet)){
  3944. $SQLStmt.=" AND session.prj_id=".$projet;
  3945. }
  3946. if (is_numeric($lieu)){
  3947. $SQLStmt.=" AND lieu.li_id=".$lieu;
  3948. }
  3949. if (is_array($arrFicheID)){
  3950. $SQLStmt.=" AND (inscriptionSession.ses_id <> inscriptionSession.ses_id";
  3951. for ($i=0; $i<count($arrFicheID); $i++){
  3952. ereg("^([0-9]+)[.]{1}([0-9]+)$",$arrFicheID[$i],$regs);
  3953. $usr_id=$regs[1];
  3954. $ses_id=$regs[2];
  3955. if ((is_numeric($usr_id))&&(is_numeric($ses_id))){
  3956. $SQLStmt.=" OR (inscriptionSession.usr_id=".$usr_id;
  3957. $SQLStmt.=" AND inscriptionSession.ses_id=".$ses_id.")";
  3958. }
  3959. }
  3960. $SQLStmt.=" )";
  3961. }
  3962. // specifique pour LIMITED
  3963. if (is_numeric($adminlieu)){
  3964. $SQLStmt.=" AND usager.li_id IN (";
  3965. $SQLStmt.=" SELECT li_id";
  3966. $SQLStmt.=" FROM lieuadmin";
  3967. $SQLStmt.=" WHERE usr_id=".$adminlieu;
  3968. $SQLStmt.=")";
  3969. }
  3970. $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";
  3971. if (is_numeric($nbjourstart)){
  3972. $SQLStmt.=" HAVING min(seance.sea_dateDebut) BETWEEN CURRENT_DATE AND CURRENT_DATE+". $nbjourstart;
  3973. }
  3974. if ($indx!=""){
  3975. if ($indx=="noma"){
  3976. $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
  3977. } else if ($indx=="nomd") {
  3978. $SQLStmt.=" ORDER BY usr_nom DESC, usr_prenom DESC";
  3979. } else if ($indx=="lieua") {
  3980. $SQLStmt.=" ORDER BY li_lieu ASC";
  3981. } else if ($indx=="lieud") {
  3982. $SQLStmt.=" ORDER BY li_lieu DESC";
  3983. } else if ($indx=="sessiona") {
  3984. $SQLStmt.=" ORDER BY ses_code ASC";
  3985. } else if ($indx=="sessiond") {
  3986. $SQLStmt.=" ORDER BY ses_code DESC";
  3987. } else if ($indx=="datea") {
  3988. $SQLStmt.=" ORDER BY dateSeance ASC";
  3989. } else if ($indx=="dated") {
  3990. $SQLStmt.=" ORDER BY dateSeance DESC";
  3991. } else if ($indx=="etata") {
  3992. $SQLStmt.=" ORDER BY ie_OK ASC, ie_etat ASC";
  3993. } else if ($indx=="etatd") {
  3994. $SQLStmt.=" ORDER BY ie_OK DESC, ie_etat DESC";
  3995. } else if ($indx=="usrtitrea") {
  3996. $SQLStmt.=" ORDER BY usager.usr_fonction ASC";
  3997. } else if ($indx=="usrtitred") {
  3998. $SQLStmt.=" ORDER BY usager.usr_fonction DESC";
  3999. }
  4000. }
  4001. return $SQLStmt;
  4002. }
  4003. ///////////////////////////////////////////////////////////////////////////////////////
  4004. // Retourne la requete SQL necessaire pour faire un SELECT
  4005. ///////////////////////////////////////////////////////////////////////////////////////
  4006. function getSQLStmtReqLieu($li_id){
  4007. $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";
  4008. $SQLStmt.=" FROM lieu";
  4009. $SQLStmt.=" WHERE li_id = ".$li_id;
  4010. return ($SQLStmt);
  4011. }
  4012. ///////////////////////////////////////////////////////////////////////////////////////
  4013. // Retourne la requete SQL necessaire pour faire un SELECT
  4014. ///////////////////////////////////////////////////////////////////////////////////////
  4015. function getSQLStmtReqLieuType($lt_id){
  4016. $SQLStmt="SELECT lt_type FROM lieutype";
  4017. $SQLStmt.=" WHERE lieu.lt_id =".$lt_id;
  4018. return ($SQLStmt);
  4019. }
  4020. ///////////////////////////////////////////////////////////////////////////////////////
  4021. // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
  4022. ///////////////////////////////////////////////////////////////////////////////////////
  4023. function getSQLStmtReqLieuLAST(){
  4024. $SQLStmt="SELECT MAX(li_id) FROM lieu";
  4025. return $SQLStmt;
  4026. }
  4027. ///////////////////////////////////////////////////////////////////////////////////////
  4028. // Retourne la requete SQL necessaire pour faire un SELECT
  4029. ///////////////////////////////////////////////////////////////////////////////////////
  4030. function getSQLStmtReqLieuFromNo($li_no){
  4031. $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";
  4032. $SQLStmt.=" FROM lieu";
  4033. $SQLStmt.=" WHERE li_id = li_id";
  4034. if ($li_no!=""){
  4035. $SQLStmt.=" AND li_no = '".$li_no."'";
  4036. }else{
  4037. $SQLStmt.=" AND li_no IS NULL";
  4038. }
  4039. return ($SQLStmt);
  4040. }
  4041. // 2008/03 rechercher un lieu de la table �lieu� d'apr�s son num�ro OU sa description
  4042. function getSQLStmtReqLieuFromNoOuDescr($li_no, $li_lieu){
  4043. $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";
  4044. $SQLStmt.=" FROM lieu";
  4045. $SQLStmt.=" WHERE li_id = li_id";
  4046. if ($li_no!=""){
  4047. $SQLStmt.=" AND li_no = '".$li_no."'";
  4048. }elseif ($li_lieu!=""){
  4049. $SQLStmt.=" AND li_lieu = '".addslashes($li_lieu)."'";
  4050. }else{
  4051. $SQLStmt.=" AND li_no IS NULL";
  4052. }
  4053. $SQLStmt.=" LIMIT 1";
  4054. return ($SQLStmt);
  4055. }
  4056. ///////////////////////////////////////////////////////////////////////////////////////
  4057. // Retourne la requete SQL necessaire pour faire un SELECT
  4058. ///////////////////////////////////////////////////////////////////////////////////////
  4059. function getSQLStmtReqLieuxInscriptions($adminlieu_id, $valide, $indx){
  4060. $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";
  4061. $SQLStmt.=" FROM lieu LEFT JOIN inscriptionSession ON lieu.li_id = inscriptionSession.lieu_id_ainscription LEFT JOIN usager ON usager.usr_id = inscriptionSession.usr_id";
  4062. $SQLStmt.=" WHERE lieu.li_id = lieu.li_id";
  4063. if (is_numeric($adminlieu_id)){
  4064. $SQLStmt.=" AND lieu.li_id IN (";
  4065. $SQLStmt.=" SELECT li_id";
  4066. $SQLStmt.=" FROM lieuadmin";
  4067. $SQLStmt.=" WHERE usr_id=".$adminlieu_id;
  4068. $SQLStmt.=")";
  4069. }
  4070. if ($valide!=""){
  4071. if (!strcasecmp($valide,"t")){
  4072. $SQLStmt.=" AND li_valide='t'";
  4073. }
  4074. else{
  4075. $SQLStmt.=" AND li_valide='f'";
  4076. }
  4077. }
  4078. $SQLStmt.=" GROUP BY lieu.li_id, li_lieu, li_valide";
  4079. if ($indx!=""){
  4080. if ($indx=="lieua"){
  4081. $SQLStmt.=" ORDER BY li_lieu ASC";
  4082. }
  4083. elseif ($indx=="lieud"){
  4084. $SQLStmt.=" ORDER BY li_lieu DESC";
  4085. }
  4086. elseif ($indx=="adressea"){
  4087. $SQLStmt.=" ORDER BY li_adresse ASC";
  4088. }
  4089. elseif ($indx=="adressed"){
  4090. $SQLStmt.=" ORDER BY li_adresse DESC";
  4091. }
  4092. elseif ($indx=="trajeta"){
  4093. $SQLStmt.=" ORDER BY li_trajet ASC";
  4094. }
  4095. elseif ($indx=="trajetd"){
  4096. $SQLStmt.=" ORDER BY li_trajet DESC";
  4097. }
  4098. else
  4099. {
  4100. $SQLStmt.=" ORDER BY li_lieu ASC"; // ordre alphabetique de nom par defaut
  4101. }
  4102. }
  4103. return $SQLStmt;
  4104. }
  4105. ///////////////////////////////////////////////////////////////////////////////////////
  4106. // Retourne la requete SQL necessaire pour faire un SELECT
  4107. ///////////////////////////////////////////////////////////////////////////////////////
  4108. function getSQLStmtReqLieuAdminlieu( $li_id ){
  4109. return "Select la.usr_id, la.la_responsable, u.usr_nom, u.usr_prenom, l.li_no
  4110. From lieuAdmin la
  4111. Left Join usager u On la.usr_id = u.usr_id
  4112. Left Join lieu l On u.li_id = l.li_id
  4113. Where la.li_id = '" . $li_id . "'
  4114. Order By u.usr_nom, u.usr_prenom";
  4115. }
  4116. ///////////////////////////////////////////////////////////////////////////////////////
  4117. // Retourne la requete SQL necessaire pour faire un SELECT
  4118. ///////////////////////////////////////////////////////////////////////////////////////
  4119. function getSQLStmtReqLieuAdminLieuOK($li_id, $adminlieu_id){
  4120. $SQLStmt="SELECT li_id";
  4121. $SQLStmt.=" FROM lieuAdmin";
  4122. $SQLStmt.=" WHERE li_id = ".$li_id;
  4123. if (is_numeric($adminlieu_id)){
  4124. $SQLStmt.=" AND usr_id=".$adminlieu_id;
  4125. }
  4126. return $SQLStmt;
  4127. }
  4128. ///////////////////////////////////////////////////////////////////////////////////////
  4129. // Retourne la requete SQL necessaire pour faire un SELECT
  4130. ///////////////////////////////////////////////////////////////////////////////////////
  4131. function getSQLStmtReqLieuTechnicien($li_id){
  4132. $SQLStmt="SELECT lieuSupport.usr_id, lieuSupport.ls_responsable, usager.usr_nom, usager.usr_prenom";
  4133. $SQLStmt.=" FROM lieuSupport, usager";
  4134. $SQLStmt.=" WHERE lieuSupport.usr_id = usager.usr_id";
  4135. $SQLStmt.=" AND lieuSupport.li_id = ".$li_id;
  4136. $SQLStmt.=" ORDER BY usager.usr_nom, usager.usr_prenom";
  4137. return ($SQLStmt);
  4138. }
  4139. ///////////////////////////////////////////////////////////////////////////////////////
  4140. // Retourne la requete SQL necessaire pour faire un SELECT
  4141. ///////////////////////////////////////////////////////////////////////////////////////
  4142. function getSQLStmtReqLieux( $mot, $motlnk, $adminlieu_id, $tech_id, $lieu_type, $valide, $indx ){
  4143. $SQLStmt = "Select li_id, li_lieu, li_no, li_adresse, li_trajet, li_valide";
  4144. $SQLStmt .= " From lieu";
  4145. $SQLStmt .= " Where li_id = li_id";
  4146. if( $mot != "" ){
  4147. if( $motlnk != strtolower( "or" ) ){
  4148. $motlnk = "And"; //valeur par defaut : securite
  4149. }
  4150. $arrMot = getArrayFromStringMot( $mot );
  4151. $SQLStmt .= " And ( ";
  4152. for( $i = 0; $i < count( $arrMot ); $i++ ){
  4153. $SQLStmt .= "( li_lieu Ilike '%" . fixPGQuote( $arrMot[$i] ) . "%'";
  4154. $SQLStmt .= " Or li_adresse Ilike '%" . fixPGQuote( $arrMot[ $i ] ) . "%')";
  4155. if( $i < count( $arrMot ) - 1 ){
  4156. $SQLStmt .= " " . $motlnk . " "; //OR ou AND
  4157. }
  4158. }
  4159. $SQLStmt .= ")";
  4160. }
  4161. if( is_numeric( $lieu_type ) ){
  4162. $SQLStmt .= ' And lt_id = ' . $lieu_type;
  4163. }
  4164. if( is_numeric( $adminlieu_id ) ){
  4165. $SQLStmt .= " And li_id In ( Select li_id From lieuadmin Where usr_id = " . $adminlieu_id . " )";
  4166. }
  4167. if( is_numeric( $tech_id ) ){
  4168. $SQLStmt .= " And li_id In ( Select li_id From lieusupport Where usr_id = " . $tech_id . " )";
  4169. }
  4170. if( $valide != "" ){
  4171. if( $valide == "t" ){
  4172. $SQLStmt .= " And li_valide = 't'";
  4173. } else {
  4174. $SQLStmt .= " And li_valide = 'f'";
  4175. }
  4176. }
  4177. switch( $indx ){
  4178. case "lieua" :
  4179. $SQLStmt .= " Order By li_lieu ASC";
  4180. break;
  4181. case "lieud" :
  4182. $SQLStmt .= " Order By li_lieu DESC";
  4183. break;
  4184. case "adressea" :
  4185. $SQLStmt .= " Order By li_adresse ASC";
  4186. break;
  4187. case "adressed" :
  4188. $SQLStmt .= " Order By li_adresse DESC";
  4189. break;
  4190. case "trajeta" :
  4191. $SQLStmt .= " Order By li_trajet ASC";
  4192. break;
  4193. case "trajetd" :
  4194. $SQLStmt .= " Order By li_trajet DESC";
  4195. break;
  4196. case "lieunoa" :
  4197. $SQLStmt .= " Order By li_no ASC";
  4198. break;
  4199. case "lieunod" :
  4200. $SQLStmt .= " Order By li_no DESC";
  4201. break;
  4202. default :
  4203. // ordre alphabetique de nom par defaut
  4204. $SQLStmt .= " Order By li_lieu ASC";
  4205. break;
  4206. }
  4207. return $SQLStmt;
  4208. }
  4209. ///////////////////////////////////////////////////////////////////////////////////////
  4210. // Retourne la requete SQL necessaire pour faire un SELECT
  4211. ///////////////////////////////////////////////////////////////////////////////////////
  4212. function getSQLStmtReqPresences($sea_id){
  4213. /*$SQLStmt="SELECT presence.usr_id, usr_nom, usr_prenom, pr_presence";
  4214. $SQLStmt.=" FROM presence, usager";
  4215. $SQLStmt.=" WHERE presence.usr_id = usager.usr_id";
  4216. $SQLStmt.=" AND sea_id = ".$sea_id;*/
  4217. $SQLStmt.="SELECT inscriptionSession.usr_id, usager.usr_nom, usager.usr_prenom, pr_presence";
  4218. $SQLStmt.=" FROM inscriptionSession, inscriptionEtat, usager LEFT JOIN (";
  4219. $SQLStmt.= " SELECT presence.usr_id,pr_presence";
  4220. $SQLStmt.= " FROM presence";
  4221. if (is_numeric($sea_id)){
  4222. $SQLStmt.= " WHERE sea_id =".$sea_id;
  4223. }
  4224. $SQLStmt.= ") PRES ON usager.usr_id = PRES.usr_id";
  4225. $SQLStmt.=" WHERE inscriptionSession.usr_id = usager.usr_id";
  4226. $SQLStmt.=" AND inscriptionSession.ie_id = inscriptionEtat.ie_id";
  4227. $SQLStmt.=" AND inscriptionEtat.ie_OK = 't'";
  4228. if (is_numeric($sea_id)){
  4229. $SQLStmt.=" AND inscriptionSession.ses_id = (";
  4230. $SQLStmt.=" SELECT ses_id";
  4231. $SQLStmt.=" FROM seance";
  4232. $SQLStmt.=" WHERE sea_id = ".$sea_id;
  4233. $SQLStmt.=")";
  4234. }
  4235. $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
  4236. return($SQLStmt);
  4237. }
  4238. ///////////////////////////////////////////////////////////////////////////////////////
  4239. // Retourne la requete SQL necessaire pour faire un SELECT
  4240. ///////////////////////////////////////////////////////////////////////////////////////
  4241. function getSQLStmtReqProjet($prj_id){
  4242. $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";
  4243. $SQLStmt.=" FROM projet, projetType";
  4244. $SQLStmt.=" WHERE projet.pt_id = projetType.pt_id";
  4245. $SQLStmt.=" AND prj_id = ".$prj_id;
  4246. return($SQLStmt);
  4247. }
  4248. function getSQLStmtReqProjetAdminprojet($prj_id){
  4249. $SQLStmt="SELECT projetAdmin.usr_id, projetAdmin.pa_responsable, usager.usr_nom, usager.usr_prenom";
  4250. $SQLStmt.=" FROM projetAdmin, usager";
  4251. $SQLStmt.=" WHERE projetAdmin.usr_id = usager.usr_id";
  4252. $SQLStmt.=" AND projetAdmin.prj_id = ".$prj_id;
  4253. $SQLStmt.=" ORDER BY usager.usr_nom, usager.usr_prenom";
  4254. return ($SQLStmt);
  4255. }
  4256. function getSQLStmtReqAdminProjetSessions( $usrid ) {
  4257. return "SELECT ses_id FROM projetAdmin JOIN session USING ( prj_id ) WHERE usr_id = '" . $usrid . "'";
  4258. }
  4259. function getSQLStmtReqAdminProjetSeances($usrid)
  4260. {
  4261. $sql = "SELECT sea_id FROM projetAdmin JOIN session USING (prj_id)";
  4262. $sql .= " JOIN seance USING (ses_id)";
  4263. $sql .= " WHERE usr_id = $usrid";
  4264. return $sql;
  4265. }
  4266. ///////////////////////////////////////////////////////////////////////////////////////
  4267. // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
  4268. ///////////////////////////////////////////////////////////////////////////////////////
  4269. function getSQLStmtReqProjetLAST(){
  4270. $SQLStmt="SELECT MAX(prj_id) FROM projet";
  4271. return $SQLStmt;
  4272. }
  4273. ///////////////////////////////////////////////////////////////////////////////////////
  4274. // Retourne la requete SQL necessaire pour faire un SELECT
  4275. ///////////////////////////////////////////////////////////////////////////////////////
  4276. function getSQLStmtReqProjets($mot, $motlnk, $type, $dateOK, $valide, $indx){
  4277. $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";
  4278. $SQLStmt.=" FROM projet LEFT JOIN session ON projet.prj_id = session.prj_id, projetType";
  4279. $SQLStmt.=" WHERE projet.pt_id = projetType.pt_id";
  4280. if ($mot!=""){
  4281. if ($motlnk!="and" && $motlnk!="or"){
  4282. $motlnk="and"; //valeur par defaut : securite
  4283. }
  4284. $arrMot=getArrayFromStringMot($mot);
  4285. $SQLStmt.=" AND (";
  4286. for ($i=0; $i<count($arrMot); $i++){
  4287. $SQLStmt.="(prj_projet ILIKE '%".fixPGQuote($arrMot[$i])."%'";
  4288. $SQLStmt.=" OR pt_type ILIKE '%".fixPGQuote($arrMot[$i])."%')";
  4289. if ($i<count($arrMot)-1){
  4290. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  4291. }
  4292. }
  4293. $SQLStmt.=")";
  4294. }
  4295. if ($dateOK!=""){
  4296. if (!strcasecmp($dateOK,"t")){
  4297. $SQLStmt.=" AND (prj_dateFin >= CURRENT_DATE OR prj_dateFin IS NULL)";
  4298. }
  4299. else{
  4300. $SQLStmt.=" AND (prj_dateFin < CURRENT_DATE)";
  4301. }
  4302. }
  4303. if ($valide!=""){
  4304. if (!strcasecmp($valide,"t")){
  4305. $SQLStmt.=" AND prj_valide='t'";
  4306. } else {
  4307. $SQLStmt.=" AND prj_valide='f'";
  4308. }
  4309. }
  4310. if (is_numeric($type)){
  4311. $SQLStmt.=" AND projet.pt_id=".$type;
  4312. }
  4313. $SQLStmt.=" GROUP BY projet.prj_id, prj_projet, prj_datedebut, prj_datefin, prj_datelimite, projet.pt_id, projetType.pt_type, prj_valide";
  4314. if ($indx!=""){
  4315. if ($indx=="projeta"){
  4316. $SQLStmt.=" ORDER BY prj_projet ASC";
  4317. } else if ($indx=="projetd") {
  4318. $SQLStmt.=" ORDER BY prj_projet DESC";
  4319. } else if ($indx=="typea") {
  4320. $SQLStmt.=" ORDER BY pt_type ASC";
  4321. } else if ($indx=="typed") {
  4322. $SQLStmt.=" ORDER BY pt_type DESC";
  4323. } else if ($indx=="datea") {
  4324. $SQLStmt.=" ORDER BY prj_dateDebut ASC, prj_dateFin ASC";
  4325. } else if ($indx=="dated") {
  4326. $SQLStmt.=" ORDER BY prj_dateDebut DESC, prj_dateFin DESC";
  4327. } else if ($indx=="nbsessiona") {
  4328. $SQLStmt.=" ORDER BY nbSession ASC";
  4329. } else if ($indx=="nbsessiond") {
  4330. $SQLStmt.=" ORDER BY nbSession DESC";
  4331. } else if ($indx=="nbinscriptiona") {
  4332. $SQLStmt.=" ORDER BY nbInscription ASC";
  4333. } else if ($indx=="nbinscriptiond") {
  4334. $SQLStmt.=" ORDER BY nbInscription DESC";
  4335. }
  4336. }
  4337. return $SQLStmt;
  4338. }
  4339. ///////////////////////////////////////////////////////////////////////////////////////
  4340. // Retourne la requete SQL necessaire pour faire un SELECT
  4341. ///////////////////////////////////////////////////////////////////////////////////////
  4342. function getSQLStmtReqProjetsComplets($mot, $motlnk, $type, $dateOK, $valide, $indx){
  4343. $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";
  4344. $SQLStmt.=" FROM projet LEFT JOIN session ON projet.prj_id = session.prj_id, projetType";
  4345. $SQLStmt.=" WHERE projet.pt_id = projetType.pt_id";
  4346. if ($mot!=""){
  4347. if ($motlnk!="and" && $motlnk!="or"){
  4348. $motlnk="and"; //valeur par defaut : securite
  4349. }
  4350. $arrMot=getArrayFromStringMot($mot);
  4351. $SQLStmt.=" AND (";
  4352. for ($i=0; $i<count($arrMot); $i++){
  4353. $SQLStmt.="(prj_projet ILIKE '%".fixPGQuote($arrMot[$i])."%'";
  4354. $SQLStmt.=" OR pt_type ILIKE '%".fixPGQuote($arrMot[$i])."%')";
  4355. if ($i<count($arrMot)-1){
  4356. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  4357. }
  4358. }
  4359. $SQLStmt.=")";
  4360. }
  4361. if ($dateOK!=""){
  4362. if (!strcasecmp($dateOK,"t")){
  4363. $SQLStmt.=" AND (prj_dateFin >= CURRENT_DATE OR prj_dateFin IS NULL)";
  4364. }
  4365. else{
  4366. $SQLStmt.=" AND (prj_dateFin < CURRENT_DATE)";
  4367. }
  4368. }
  4369. if ($valide!=""){
  4370. if (!strcasecmp($valide,"t")){
  4371. $SQLStmt.=" AND prj_valide='t'";
  4372. }
  4373. else{
  4374. $SQLStmt.=" AND prj_valide='f'";
  4375. }
  4376. }
  4377. if (is_numeric($type)){
  4378. $SQLStmt.=" AND projet.pt_id=".$type;
  4379. }
  4380. $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";
  4381. if ($indx!=""){
  4382. if ($indx=="projeta"){
  4383. $SQLStmt.=" ORDER BY prj_projet ASC";
  4384. }
  4385. elseif ($indx=="projetd"){
  4386. $SQLStmt.=" ORDER BY prj_projet DESC";
  4387. }
  4388. elseif ($indx=="typea"){
  4389. $SQLStmt.=" ORDER BY pt_type ASC";
  4390. }
  4391. elseif ($indx=="typed"){
  4392. $SQLStmt.=" ORDER BY pt_type DESC";
  4393. }
  4394. elseif ($indx=="datea"){
  4395. $SQLStmt.=" ORDER BY prj_dateDebut ASC, prj_dateFin ASC";
  4396. }
  4397. elseif ($indx=="dated"){
  4398. $SQLStmt.=" ORDER BY prj_dateDebut DESC, prj_dateFin DESC";
  4399. }
  4400. elseif ($indx=="nbsessiona"){
  4401. $SQLStmt.=" ORDER BY nbSession ASC";
  4402. }
  4403. elseif ($indx=="nbsessiond"){
  4404. $SQLStmt.=" ORDER BY nbSession DESC";
  4405. }
  4406. elseif ($indx=="nbinscriptiona"){
  4407. $SQLStmt.=" ORDER BY nbInscription ASC";
  4408. }
  4409. elseif ($indx=="nbinscriptiond"){
  4410. $SQLStmt.=" ORDER BY nbInscription DESC";
  4411. }
  4412. }
  4413. return $SQLStmt;
  4414. }
  4415. ///////////////////////////////////////////////////////////////////////////////////////
  4416. // Retourne la requete SQL necessaire pour faire un SELECT
  4417. ///////////////////////////////////////////////////////////////////////////////////////
  4418. function getSQLStmtReqSeance($sea_id){
  4419. $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)";
  4420. $SQLStmt.=" FROM seance LEFT JOIN lieu ON seance.li_id = lieu.li_id, session, atelier, projet";
  4421. $SQLStmt.=" WHERE seance.ses_id = session.ses_id";
  4422. $SQLStmt.=" AND session.atl_id = atelier.atl_id";
  4423. $SQLStmt.=" AND session.prj_id = projet.prj_id";
  4424. $SQLStmt.=" AND seance.sea_id = ".$sea_id;
  4425. return ($SQLStmt);
  4426. }
  4427. ///////////////////////////////////////////////////////////////////////////////////////
  4428. // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
  4429. ///////////////////////////////////////////////////////////////////////////////////////
  4430. function getSQLStmtReqSeanceLAST(){
  4431. $SQLStmt="SELECT MAX(sea_id) FROM seance";
  4432. return $SQLStmt;
  4433. }
  4434. ///////////////////////////////////////////////////////////////////////////////////////
  4435. // Retourne la requete SQL necessaire pour faire un SELECT
  4436. ///////////////////////////////////////////////////////////////////////////////////////
  4437. function getSQLStmtReqSeances($prj_id, $atl_id, $ses_id, $sea_annule, $valide, $arrFicheID, $indx, $usr_id = null){
  4438. $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";
  4439. if (is_numeric($usr_id)) {
  4440. $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";
  4441. } else {
  4442. $SQLStmt.=" FROM seance LEFT JOIN lieu ON seance.li_id = lieu.li_id";
  4443. }
  4444. $SQLStmt.=" LEFT JOIN session ON seance.ses_id = session.ses_id";
  4445. $SQLStmt.=" LEFT JOIN atelier ON session.atl_id = atelier.atl_id";
  4446. $SQLStmt.=" LEFT JOIN projet ON session.prj_id = projet.prj_id";
  4447. $SQLStmt.=" WHERE seance.sea_id = seance.sea_id";
  4448. if (is_numeric($prj_id)){
  4449. $SQLStmt.=" AND session.prj_id = ".$prj_id;
  4450. }
  4451. if (is_numeric($atl_id)){
  4452. $SQLStmt.=" AND session.atl_id = ".$atl_id;
  4453. }
  4454. if (is_numeric($ses_id)){
  4455. $SQLStmt.=" AND session.ses_id = ".$ses_id;
  4456. }
  4457. if ($sea_annule!=""){
  4458. if (!strcasecmp($sea_annule,"t")){
  4459. $SQLStmt.=" AND sea_annule='t'";
  4460. }
  4461. else{
  4462. $SQLStmt.=" AND sea_annule='f'";
  4463. }
  4464. }
  4465. if ($valide!=""){
  4466. if (!strcasecmp($valide,"t")){
  4467. $SQLStmt.=" AND prj_valide='t'";
  4468. $SQLStmt.=" AND atl_valide='t'";
  4469. $SQLStmt.=" AND ses_valide='t'";
  4470. $SQLStmt.=" AND sea_valide='t'";
  4471. }
  4472. else{
  4473. $SQLStmt.=" AND prj_valide='f'";
  4474. $SQLStmt.=" AND atl_valide='f'";
  4475. $SQLStmt.=" AND ses_valide='f'";
  4476. $SQLStmt.=" AND sea_valide='f'";
  4477. }
  4478. }
  4479. if( is_array( $arrFicheID ) && count( $arrFicheID ) > 0 ){
  4480. $SQLStmt.=" AND (seance.sea_id <> seance.sea_id";
  4481. for ($i=0; $i<count($arrFicheID); $i++){
  4482. if (is_numeric($arrFicheID[$i])){
  4483. $SQLStmt.=" OR seance.sea_id=".$arrFicheID[$i];
  4484. }
  4485. }
  4486. $SQLStmt.=" )";
  4487. }
  4488. if ($indx!=""){
  4489. if ($indx=="datea"){
  4490. $SQLStmt.=" ORDER BY sea_dateDebut ASC, sea_dateFin ASC";
  4491. }
  4492. elseif ($indx=="dated"){
  4493. $SQLStmt.=" ORDER BY sea_dateDebut DESC, sea_dateFin DESC";
  4494. }
  4495. }
  4496. return ($SQLStmt);
  4497. }
  4498. ///////////////////////////////////////////////////////////////////////////////////////
  4499. // Retourne la requete SQL necessaire pour faire un SELECT
  4500. ///////////////////////////////////////////////////////////////////////////////////////
  4501. function getSQLStmtReqSession($ses_id){
  4502. $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";
  4503. $SQLStmt.=" FROM session LEFT JOIN seance ON session.ses_id = seance.ses_id, projet, atelier";
  4504. $SQLStmt.=" WHERE session.prj_id = projet.prj_id";
  4505. $SQLStmt.=" AND session.atl_id = atelier.atl_id";
  4506. $SQLStmt.=" AND session.ses_id = ".$ses_id;
  4507. $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";
  4508. return ($SQLStmt);
  4509. }
  4510. ///////////////////////////////////////////////////////////////////////////////////////
  4511. // Retourne la requete SQL necessaire pour faire un SELECT
  4512. ///////////////////////////////////////////////////////////////////////////////////////
  4513. function getSQLStmtReqSessionAnimateur($ses_id){
  4514. $SQLStmt="SELECT animation.usr_id, animation.an_responsable, usager.usr_nom, usager.usr_prenom, usager.usr_email, lieu.li_no ";
  4515. $SQLStmt.=" FROM animation, usager, lieu";
  4516. $SQLStmt.=" WHERE animation.usr_id = usager.usr_id";
  4517. $SQLStmt.=" AND animation.ses_id = ".$ses_id. "AND usager.li_id = lieu.li_id"; // 2007-03-23 demande #37 ajout du lieu
  4518. $SQLStmt.=" ORDER BY usager.usr_nom, usager.usr_prenom";
  4519. return ($SQLStmt);
  4520. }
  4521. ///////////////////////////////////////////////////////////////////////////////////////
  4522. // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
  4523. ///////////////////////////////////////////////////////////////////////////////////////
  4524. function getSQLStmtReqSessionLAST(){
  4525. $SQLStmt="SELECT MAX(ses_id) FROM session";
  4526. return $SQLStmt;
  4527. }
  4528. ///////////////////////////////////////////////////////////////////////////////////////
  4529. // Retourne la requete SQL necessaire pour faire un SELECT
  4530. ///////////////////////////////////////////////////////////////////////////////////////
  4531. function getSQLStmtReqSessions( $mot, $motlnk, $prj_id, $atl_id, $cla_id, $exp_id, $cli_id, $ses_annule, $nbjourstart, $datelimiteOK, $nbinsOK, $valide, $arrFicheID, $indx,$dateDebut = "", $dateFin = "" ){
  4532. $SQLStmt = "Select ses.ses_id, pro.prj_id, prj_projet, pro.prj_valide, ate.atl_id,
  4533. ate.atl_atelier, ate.atl_valide, ses_code, ses_notemini, ses_datelimite, ses_nbMin,
  4534. ses_nbMax, ses_regionnal, ses_annule, ses_annuleraison, ses_valide, COUNT( sea.sea_id ) As nbSeance,
  4535. get_nbInscriptionSession( ses.ses_id ) As nbInscription, TO_CHAR( MIN( sea_dateDebut ), 'YYYY-MM-DD HH24:MI:SS' ) As dSeaDebMin,
  4536. TO_CHAR( MAX( sea_dateDebut ), 'YYYY-MM-DD HH24:MI:SS' ) as dSeaDebMax, get_nbInscriptionSessionAValider( ses.ses_id ),
  4537. ses_coutParUsager, ses_commentaire
  4538. From session ses
  4539. Left Join seance sea On ses.ses_id = sea.ses_id
  4540. Left Join projet pro On ses.prj_id = pro.prj_id
  4541. Left Join projetType prt On pro.pt_id = prt.pt_id
  4542. Left Join atelier ate On ses.atl_id = ate.atl_id";
  4543. $where = "";
  4544. // La recherche peut �tre faite pour chaque mot ou pour le groupe au complet
  4545. if( $motlnk != "and" && $motlnk != "or" ){
  4546. $motlnk="and"; //valeur par defaut : securite
  4547. }
  4548. // Cr�� une table des mots recherch�s
  4549. $arrMot = getArrayFromStringMot( $mot );
  4550. if( count( $arrMot ) > 0 ){
  4551. $where .= " ( ";
  4552. for( $i = 0; $i < count( $arrMot ); $i++ ){
  4553. // V�rifie si le mot est dans la colonne 'ATL_ATELIER'
  4554. $where .= accentInsensitiveLike( "atl_atelier", $arrMot[ $i ] );
  4555. // Ou, v�rifie si le mot est dans la colonne 'ATL_DESCRIPTION'
  4556. $where .= " OR " . accentInsensitiveLike( "atl_description", $arrMot[ $i ] );
  4557. // Ou, v�rifie si le mot est dans la colonne 'SES_CODE'
  4558. $where .= " OR " . accentInsensitiveLike( "ses_code", $arrMot[ $i ] );
  4559. // Ajoute le bon mot selon la requ�te de l'usager
  4560. if( $i < ( count( $arrMot ) - 1 ) ){
  4561. $where .= ") " . $motlnk . " ("; //OR ou AND
  4562. }
  4563. }
  4564. $where .= " ) ";
  4565. }
  4566. if( is_numeric( $prj_id ) ){
  4567. if( $where != "" ){
  4568. $where .= " AND ";
  4569. }
  4570. $where.="ses.prj_id = " . $prj_id;
  4571. }
  4572. if( is_numeric( $atl_id ) ){
  4573. if( $where != "" ){
  4574. $where .= " AND ";
  4575. }
  4576. $where .= "ses.atl_id = " . $atl_id;
  4577. }
  4578. if( is_numeric( $cla_id ) ){
  4579. if( $where != "" ){
  4580. $where .= " AND ";
  4581. }
  4582. $where .= "ses.atl_id IN ( SELECT atl_id FROM atelier_classe WHERE cla_id = " . $cla_id . " )";
  4583. }
  4584. if( is_numeric( $exp_id ) ){
  4585. if( $where != "" ){
  4586. $where .= " AND ";
  4587. }
  4588. $where .= "ses.atl_id IN ( SELECT atl_id FROM atelier_expertise WHERE exp_id = " . $exp_id . " )";
  4589. }
  4590. if( is_numeric( $cli_id ) ){
  4591. if( $where != "" ){
  4592. $where .= " AND ";
  4593. }
  4594. $where .= "ses.atl_id IN ( SELECT atl_id FROM atelier_clientele WHERE cli_id = " . $cli_id . ")";
  4595. }
  4596. if( $ses_annule != "" ){
  4597. if( strtolower( $ses_annule ) == "t" ){
  4598. if( $where != "" ){
  4599. $where .= " AND ";
  4600. }
  4601. $where .= "ses_annule = 't'";
  4602. } else {
  4603. if( $where != "" ){
  4604. $where .= " AND ";
  4605. }
  4606. $where .= "ses_annule = 'f'";
  4607. }
  4608. }
  4609. if( $datelimiteOK != "" ){
  4610. if( !strcasecmp( $datelimiteOK, "t" ) ){
  4611. if( $where != "" ){
  4612. $where .= " AND ";
  4613. }
  4614. $where .= "( ses_dateLimite >= CURRENT_DATE OR ses_dateLimite IS NULL )";
  4615. } else {
  4616. if( $where != "" ){
  4617. $where .= " AND ";
  4618. }
  4619. $where .= "ses_dateLimite < CURRENT_DATE";
  4620. }
  4621. }
  4622. if( $dateDebut != "" ){
  4623. if( $where != "" ){
  4624. $where .= " AND ";
  4625. }
  4626. $where .= "sea.sea_datedebut >= '" . $dateDebut . "'";
  4627. }
  4628. if( $dateFin != "" ){
  4629. if( $where != "" ){
  4630. $where .= " AND ";
  4631. }
  4632. $where .= "sea.sea_datedebut <= '" . $dateFin . "'";
  4633. }
  4634. if( $valide != "" ){
  4635. if( $valide == "t" ){
  4636. if( $where != "" ){
  4637. $where .= " AND ";
  4638. }
  4639. $where .= "prj_valide = 't' AND atl_valide = 't' AND ses_valide = 't'";
  4640. } else if( $valide == "f" ){
  4641. if( $where != "" ){
  4642. $where .= " AND ";
  4643. }
  4644. // D�s que l'une de ces 3 entit�s est invalide, la session le devient
  4645. $where .= "( prj_valide = 'f' Or atl_valide = 'f' Or ses_valide = 'f' )";
  4646. }
  4647. }
  4648. if( is_array( $arrFicheID ) ){
  4649. if( $where != "" ){
  4650. $where .= " AND ";
  4651. }
  4652. $where .= "( ses.ses_id <> ses.ses_id";
  4653. foreach( $arrFicheID as $fiche_id ){
  4654. if( is_numeric( $fiche_id ) ){
  4655. $where .= " OR ses.ses_id=" . $fiche_id;
  4656. }
  4657. }
  4658. $where .= " )";
  4659. }
  4660. if( $where != "" ){
  4661. $where = " WHERE " . $where;
  4662. }
  4663. $SQLStmt .= $where . " GROUP BY ses.ses_id, pro.prj_id, pro.prj_projet, pro.prj_valide, ate.atl_id, ate.atl_atelier,
  4664. ate.atl_valide, ses_code, ses_notemini, ses_datelimite, ses_nbmin, ses_nbmax, ses_regionnal, ses_annule, ses_annuleraison,
  4665. ses_valide, ses_coutParUsager, ses_commentaire";
  4666. if( is_numeric( $nbjourstart ) || $nbinsOK != "" ){
  4667. $SQLStmt .= " HAVING true"; // Malheureusement, cette clause ne change rien mais elle rend les prochaines lignes plus facile � b�tire
  4668. if( is_numeric( $nbjourstart ) ){
  4669. $SQLStmt .= " AND prochaineseance( ses.ses_id ) BETWEEN CURRENT_DATE AND CURRENT_DATE + " . $nbjourstart;
  4670. }
  4671. if( $nbinsOK != "" ){
  4672. if( strtolower( $nbinsOK ) == "t" ){
  4673. $SQLStmt .= " AND get_nbInscriptionSession( ses.ses_id ) < ses_nbMax";
  4674. } else {
  4675. $SQLStmt .= " AND get_nbInscriptionSession( ses.ses_id ) >= ses_nbMax";
  4676. }
  4677. }
  4678. }
  4679. // Cast $INDX en string car comparer 0 avec une string retourne toujours vrai
  4680. switch( ( string ) $indx ){
  4681. case "sessiona" :
  4682. $SQLStmt .= " ORDER BY ses_code ASC";
  4683. break;
  4684. case "sessiond" :
  4685. $SQLStmt .= " ORDER BY ses_code DESC";
  4686. break;
  4687. case "descriptiona" :
  4688. $SQLStmt .= " ORDER BY atl_atelier ASC";
  4689. break;
  4690. case "descriptiond" :
  4691. $SQLStmt .= " ORDER BY atl_atelier DESC";
  4692. break;
  4693. case "dateseaa" :
  4694. $SQLStmt .= " ORDER BY dSeaDebMin ASC";
  4695. break;
  4696. case "datesead" :
  4697. $SQLStmt .= " ORDER BY dSeaDebMin DESC";
  4698. break;
  4699. case "datelima" :
  4700. $SQLStmt .= " ORDER BY ses_datelimite ASC";
  4701. break;
  4702. case "datelimd" :
  4703. $SQLStmt .= " ORDER BY ses_datelimite DESC";
  4704. break;
  4705. case "nbinscriptiona" :
  4706. $SQLStmt .= " ORDER BY nbInscription ASC";
  4707. break;
  4708. case "nbinscriptiond" :
  4709. $SQLStmt .= " ORDER BY nbInscription DESC";
  4710. break;
  4711. case "couta" :
  4712. $SQLStmt .= " ORDER BY ses_coutParUsager ASC";
  4713. break;
  4714. case "coutd" :
  4715. $SQLStmt .= " ORDER BY ses_coutParUsager DESC";
  4716. break;
  4717. default :
  4718. break;
  4719. }
  4720. return $SQLStmt;
  4721. }
  4722. ///////////////////////////////////////////////////////////////////////////////////////
  4723. // Retourne la requete SQL necessaire pour faire un SELECT -type multi records
  4724. ///////////////////////////////////////////////////////////////////////////////////////
  4725. function getSQLStmtReqSessionsArray($arrFicheID){
  4726. $SQLStmt="SELECT session.ses_id, session.prj_id, prj_projet, session.atl_id, atl_atelier, ses_code";
  4727. $SQLStmt.=" FROM session, projet, projetType, atelier";
  4728. $SQLStmt.=" WHERE session.prj_id = projet.prj_id";
  4729. $SQLStmt.=" AND projet.pt_id = projetType.pt_id";
  4730. $SQLStmt.=" AND session.atl_id = atelier.atl_id";
  4731. // seulement ce qui est dans le ficheID
  4732. $SQLStmt.=" AND (session.ses_id <> session.ses_id";
  4733. for ($i=0; $i<count($arrFicheID); $i++){
  4734. if (is_numeric($arrFicheID[$i])){
  4735. $SQLStmt.=" OR session.ses_id=".$arrFicheID[$i];
  4736. }
  4737. }
  4738. $SQLStmt.=" )";
  4739. return $SQLStmt;
  4740. }
  4741. ///////////////////////////////////////////////////////////////////////////////////////
  4742. // Retourne la requete SQL necessaire pour faire un SELECT
  4743. ///////////////////////////////////////////////////////////////////////////////////////
  4744. function getSQLStmtReqSessionsCart($arrnCartSesID){
  4745. $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";
  4746. $SQLStmt.=" FROM session LEFT JOIN seance ON session.ses_id = seance.ses_id, projet, projetType, atelier";
  4747. $SQLStmt.=" WHERE session.prj_id = projet.prj_id";
  4748. $SQLStmt.=" AND projet.pt_id = projetType.pt_id";
  4749. $SQLStmt.=" AND session.atl_id = atelier.atl_id";
  4750. $SQLStmt.=" AND (session.ses_id <> session.ses_id";
  4751. for ($i=0; $i<count($arrnCartSesID); $i++){
  4752. if (is_numeric($arrnCartSesID[$i])){
  4753. $SQLStmt.=" OR session.ses_id=".$arrnCartSesID[$i];
  4754. }
  4755. }
  4756. $SQLStmt.=" )";
  4757. $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";
  4758. $SQLStmt.=" ORDER BY ses_code ASC";
  4759. return ($SQLStmt);
  4760. }
  4761. ///////////////////////////////////////////////////////////////////////////////////////
  4762. // Retourne la requete SQL necessaire pour faire un SELECT
  4763. ///////////////////////////////////////////////////////////////////////////////////////
  4764. 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 = ""){
  4765. $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";
  4766. $SQLStmt.=" FROM animation JOIN (session LEFT JOIN seance USING (ses_id)) USING (ses_id), projet, projetType, atelier";
  4767. $SQLStmt.=" WHERE session.prj_id = projet.prj_id";
  4768. $SQLStmt.=" AND projet.pt_id = projetType.pt_id";
  4769. $SQLStmt.=" AND session.atl_id = atelier.atl_id";
  4770. $SQLStmt.=" AND animation.usr_id = $userID";
  4771. if ($mot!=""){
  4772. if ($motlnk!="and" && $motlnk!="or"){
  4773. $motlnk="and"; //valeur par defaut : securite
  4774. }
  4775. $arrMot=getArrayFromStringMot($mot);
  4776. $SQLStmt.=" AND (";
  4777. for ($i=0; $i<count($arrMot); $i++){
  4778. $SQLStmt .= " ( ";
  4779. $SQLStmt .= accentInsensitiveLike("atl_atelier", $arrMot[$i]);
  4780. $SQLStmt .= " OR " . accentInsensitiveLike("atl_description", $arrMot[$i]);
  4781. $SQLStmt .= " OR " . accentInsensitiveLike("ses_code", $arrMot[$i]);
  4782. $SQLStmt .= " ) ";
  4783. if ($i<count($arrMot)-1){
  4784. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  4785. }
  4786. }
  4787. $SQLStmt.=")";
  4788. }
  4789. if (is_numeric($prj_id)){
  4790. $SQLStmt.=" AND session.prj_id = ".$prj_id;
  4791. }
  4792. if (is_numeric($atl_id)){
  4793. $SQLStmt.=" AND session.atl_id = ".$atl_id;
  4794. }
  4795. if (is_numeric($cla_id)){
  4796. $SQLStmt.=" AND session.atl_id IN (";
  4797. $SQLStmt.=" SELECT atl_id";
  4798. $SQLStmt.=" FROM atelier_classe";
  4799. $SQLStmt.=" WHERE cla_id=".$cla_id;
  4800. $SQLStmt.=")";
  4801. }
  4802. if (is_numeric($exp_id)){
  4803. $SQLStmt.=" AND session.atl_id IN (";
  4804. $SQLStmt.=" SELECT atl_id";
  4805. $SQLStmt.=" FROM atelier_expertise";
  4806. $SQLStmt.=" WHERE exp_id=".$exp_id;
  4807. $SQLStmt.=")";
  4808. }
  4809. if (is_numeric($cli_id)){
  4810. $SQLStmt.=" AND session.atl_id IN (";
  4811. $SQLStmt.=" SELECT atl_id";
  4812. $SQLStmt.=" FROM atelier_clientele";
  4813. $SQLStmt.=" WHERE cli_id=".$cli_id;
  4814. $SQLStmt.=")";
  4815. }
  4816. if ($ses_annule!=""){
  4817. if (!strcasecmp($ses_annule,"t")){
  4818. $SQLStmt.=" AND ses_annule='t'";
  4819. }
  4820. else{
  4821. $SQLStmt.=" AND ses_annule='f'";
  4822. }
  4823. }
  4824. if ($datelimiteOK!=""){
  4825. if (!strcasecmp($datelimiteOK,"t")){
  4826. $SQLStmt.=" AND (ses_dateLimite >= CURRENT_DATE OR ses_dateLimite IS NULL)";
  4827. }
  4828. else{
  4829. $SQLStmt.=" AND ses_dateLimite < CURRENT_DATE";
  4830. }
  4831. }
  4832. if($dateDebut != ""){
  4833. $SQLStmt.=" AND seance.sea_datedebut >= '$dateDebut'";
  4834. }
  4835. if($dateFin != ""){
  4836. $SQLStmt.=" AND seance.sea_datedebut <= '$dateFin'";
  4837. }
  4838. if ($valide!=""){
  4839. if (!strcasecmp($valide,"t")){
  4840. $SQLStmt.=" AND prj_valide='t'";
  4841. $SQLStmt.=" AND atl_valide='t'";
  4842. $SQLStmt.=" AND ses_valide='t'";
  4843. }
  4844. else{
  4845. $SQLStmt.=" AND prj_valide='f'";
  4846. $SQLStmt.=" AND atl_valide='f'";
  4847. $SQLStmt.=" AND ses_valide='f'";
  4848. }
  4849. }
  4850. if (is_array($arrFicheID)){
  4851. $SQLStmt.=" AND (session.ses_id <> session.ses_id";
  4852. for ($i=0; $i<count($arrFicheID); $i++){
  4853. if (is_numeric($arrFicheID[$i])){
  4854. $SQLStmt.=" OR session.ses_id=".$arrFicheID[$i];
  4855. }
  4856. }
  4857. $SQLStmt.=" )";
  4858. }
  4859. $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";
  4860. $SQLStmt.=" HAVING true";
  4861. if (is_numeric($nbjourstart)){
  4862. $SQLStmt.=" AND prochaineseance(session.ses_id) BETWEEN CURRENT_DATE AND CURRENT_DATE+". $nbjourstart;
  4863. }
  4864. if ($nbinsOK!=""){
  4865. if (!strcasecmp($nbinsOK,"t")){
  4866. $SQLStmt.=" AND get_nbInscriptionSession(session.ses_id) < ses_nbMax";
  4867. }
  4868. else{
  4869. $SQLStmt.=" AND get_nbInscriptionSession(session.ses_id) >= ses_nbMax";
  4870. }
  4871. }
  4872. if ($indx!=""){
  4873. if ($indx=="sessiona"){
  4874. $SQLStmt.=" ORDER BY ses_code ASC";
  4875. }
  4876. elseif ($indx=="sessiond"){
  4877. $SQLStmt.=" ORDER BY ses_code DESC";
  4878. }
  4879. elseif ($indx=="dateseaa"){
  4880. $SQLStmt.=" ORDER BY dSeaDebMin ASC";
  4881. }
  4882. elseif ($indx=="datesead"){
  4883. $SQLStmt.=" ORDER BY dSeaDebMin DESC";
  4884. }
  4885. elseif ($indx=="datelima"){
  4886. $SQLStmt.=" ORDER BY ses_datelimite ASC";
  4887. }
  4888. elseif ($indx=="datelimd"){
  4889. $SQLStmt.=" ORDER BY ses_datelimite DESC";
  4890. }
  4891. elseif ($indx=="nbinscriptiona"){
  4892. $SQLStmt.=" ORDER BY nbInscription ASC";
  4893. }
  4894. elseif ($indx=="nbinscriptiond"){
  4895. $SQLStmt.=" ORDER BY nbInscription DESC";
  4896. }
  4897. elseif ($indx=="couta"){
  4898. $SQLStmt.=" ORDER BY ses_coutParUsager ASC";
  4899. }
  4900. elseif ($indx=="coutd"){
  4901. $SQLStmt.=" ORDER BY ses_coutParUsager DESC";
  4902. }
  4903. }
  4904. return ($SQLStmt);
  4905. }
  4906. 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 = ""){
  4907. $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";
  4908. $SQLStmt.=" FROM session LEFT JOIN seance ON session.ses_id = seance.ses_id, projet, projetType, atelier";
  4909. $SQLStmt.=" WHERE session.prj_id = projet.prj_id";
  4910. $SQLStmt .= " AND session.prj_id IN (";
  4911. $SQLStmt .= " SELECT prj_id FROM projetAdmin WHERE usr_id = $usrid";
  4912. $SQLStmt .= ")";
  4913. $SQLStmt.=" AND projet.pt_id = projetType.pt_id";
  4914. $SQLStmt.=" AND session.atl_id = atelier.atl_id";
  4915. if ($mot!=""){
  4916. if ($motlnk!="and" && $motlnk!="or"){
  4917. $motlnk="and"; //valeur par defaut : securite
  4918. }
  4919. $arrMot=getArrayFromStringMot($mot);
  4920. $SQLStmt.=" AND (";
  4921. for ($i=0; $i<count($arrMot); $i++){
  4922. $SQLStmt .= " ( ";
  4923. $SQLStmt .= accentInsensitiveLike("atl_atelier", $arrMot[$i]);
  4924. $SQLStmt .= " OR " . accentInsensitiveLike("atl_description", $arrMot[$i]);
  4925. $SQLStmt .= " OR " . accentInsensitiveLike("ses_code", $arrMot[$i]);
  4926. $SQLStmt .= " ) ";
  4927. if ($i<count($arrMot)-1){
  4928. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  4929. }
  4930. }
  4931. $SQLStmt.=")";
  4932. }
  4933. if (is_numeric($prj_id)){
  4934. $SQLStmt.=" AND session.prj_id = ".$prj_id;
  4935. }
  4936. if (is_numeric($atl_id)){
  4937. $SQLStmt.=" AND session.atl_id = ".$atl_id;
  4938. }
  4939. if (is_numeric($cla_id)){
  4940. $SQLStmt.=" AND session.atl_id IN (";
  4941. $SQLStmt.=" SELECT atl_id";
  4942. $SQLStmt.=" FROM atelier_classe";
  4943. $SQLStmt.=" WHERE cla_id=".$cla_id;
  4944. $SQLStmt.=")";
  4945. }
  4946. if (is_numeric($exp_id)){
  4947. $SQLStmt.=" AND session.atl_id IN (";
  4948. $SQLStmt.=" SELECT atl_id";
  4949. $SQLStmt.=" FROM atelier_expertise";
  4950. $SQLStmt.=" WHERE exp_id=".$exp_id;
  4951. $SQLStmt.=")";
  4952. }
  4953. if (is_numeric($cli_id)){
  4954. $SQLStmt.=" AND session.atl_id IN (";
  4955. $SQLStmt.=" SELECT atl_id";
  4956. $SQLStmt.=" FROM atelier_clientele";
  4957. $SQLStmt.=" WHERE cli_id=".$cli_id;
  4958. $SQLStmt.=")";
  4959. }
  4960. if ($ses_annule!=""){
  4961. if (!strcasecmp($ses_annule,"t")){
  4962. $SQLStmt.=" AND ses_annule='t'";
  4963. }
  4964. else{
  4965. $SQLStmt.=" AND ses_annule='f'";
  4966. }
  4967. }
  4968. if ($datelimiteOK!=""){
  4969. if (!strcasecmp($datelimiteOK,"t")){
  4970. $SQLStmt.=" AND (ses_dateLimite >= CURRENT_DATE OR ses_dateLimite IS NULL)";
  4971. }
  4972. else{
  4973. $SQLStmt.=" AND ses_dateLimite < CURRENT_DATE";
  4974. }
  4975. }
  4976. if($dateDebut != ""){
  4977. $SQLStmt.=" AND seance.sea_datedebut >= '$dateDebut'";
  4978. }
  4979. if($dateFin != ""){
  4980. $SQLStmt.=" AND seance.sea_datedebut <= '$dateFin'";
  4981. }
  4982. if ($valide!=""){
  4983. if (!strcasecmp($valide,"t")){
  4984. $SQLStmt.=" AND prj_valide='t'";
  4985. $SQLStmt.=" AND atl_valide='t'";
  4986. $SQLStmt.=" AND ses_valide='t'";
  4987. }
  4988. else{
  4989. $SQLStmt.=" AND prj_valide='f'";
  4990. $SQLStmt.=" AND atl_valide='f'";
  4991. $SQLStmt.=" AND ses_valide='f'";
  4992. }
  4993. }
  4994. if (is_array($arrFicheID)){
  4995. $SQLStmt.=" AND (session.ses_id <> session.ses_id";
  4996. for ($i=0; $i<count($arrFicheID); $i++){
  4997. if (is_numeric($arrFicheID[$i])){
  4998. $SQLStmt.=" OR session.ses_id=".$arrFicheID[$i];
  4999. }
  5000. }
  5001. $SQLStmt.=" )";
  5002. }
  5003. $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";
  5004. $SQLStmt.=" HAVING true";
  5005. if (is_numeric($nbjourstart)){
  5006. $SQLStmt.=" AND prochaineseance(session.ses_id) BETWEEN CURRENT_DATE AND CURRENT_DATE+". $nbjourstart;
  5007. }
  5008. if ($nbinsOK!=""){
  5009. if (!strcasecmp($nbinsOK,"t")){
  5010. $SQLStmt.=" AND get_nbInscriptionSession(session.ses_id) < ses_nbMax";
  5011. }
  5012. else{
  5013. $SQLStmt.=" AND get_nbInscriptionSession(session.ses_id) >= ses_nbMax";
  5014. }
  5015. }
  5016. if ($indx!=""){
  5017. if ($indx=="sessiona"){
  5018. $SQLStmt.=" ORDER BY ses_code ASC";
  5019. }
  5020. elseif ($indx=="sessiond"){
  5021. $SQLStmt.=" ORDER BY ses_code DESC";
  5022. }
  5023. elseif ($indx=="dateseaa"){
  5024. $SQLStmt.=" ORDER BY dSeaDebMin ASC";
  5025. }
  5026. elseif ($indx=="datesead"){
  5027. $SQLStmt.=" ORDER BY dSeaDebMin DESC";
  5028. }
  5029. elseif ($indx=="datelima"){
  5030. $SQLStmt.=" ORDER BY ses_datelimite ASC";
  5031. }
  5032. elseif ($indx=="datelimd"){
  5033. $SQLStmt.=" ORDER BY ses_datelimite DESC";
  5034. }
  5035. elseif ($indx=="nbinscriptiona"){
  5036. $SQLStmt.=" ORDER BY nbInscription ASC";
  5037. }
  5038. elseif ($indx=="nbinscriptiond"){
  5039. $SQLStmt.=" ORDER BY nbInscription DESC";
  5040. }
  5041. elseif ($indx=="couta"){
  5042. $SQLStmt.=" ORDER BY ses_coutParUsager ASC";
  5043. }
  5044. elseif ($indx=="coutd"){
  5045. $SQLStmt.=" ORDER BY ses_coutParUsager DESC";
  5046. }
  5047. }
  5048. return ($SQLStmt);
  5049. }
  5050. ///////////////////////////////////////////////////////////////////////////////////////
  5051. // Retourne la requete SQL necessaire pour faire un SELECT
  5052. ///////////////////////////////////////////////////////////////////////////////////////
  5053. function getSQLStmtReqSessionsFromAtelier($atl_id){
  5054. $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";
  5055. $SQLStmt.=" FROM session LEFT JOIN seance ON session.ses_id = seance.ses_id, projet, projetType, atelier";
  5056. $SQLStmt.=" WHERE session.prj_id = projet.prj_id";
  5057. $SQLStmt.=" AND projet.pt_id = projetType.pt_id";
  5058. $SQLStmt.=" AND session.atl_id = atelier.atl_id";
  5059. $SQLStmt.=" AND session.atl_id = ".$atl_id;
  5060. $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";
  5061. echo $SQLStmt.=" ORDER BY session.ses_code";
  5062. return ($SQLStmt);
  5063. }
  5064. ///////////////////////////////////////////////////////////////////////////////////////
  5065. // Retourne la requete SQL necessaire pour faire un SELECT
  5066. ///////////////////////////////////////////////////////////////////////////////////////
  5067. function getSQLStmtReqSessionsPortfolio( $usr_id_INSCRIT, $histo, $order_by = "" ){
  5068. $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
  5069. FROM session
  5070. LEFT JOIN seance ON session.ses_id = seance.ses_id
  5071. LEFT JOIN projet ON session.prj_id = projet.prj_id
  5072. LEFT JOIN projetType ON projet.pt_id = projetType.pt_id
  5073. LEFT JOIN atelier ON session.atl_id = atelier.atl_id
  5074. LEFT JOIN inscriptionSession ON session.ses_id = inscriptionSession.ses_id
  5075. LEFT JOIN inscriptionEtat ON inscriptionSession.ie_id = inscriptionEtat.ie_id
  5076. WHERE inscriptionSession.usr_id = \'' . $usr_id_INSCRIT . '\'
  5077. 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';
  5078. // On retourne soit l'historique future, pass�e ou toute
  5079. if( $histo == 'futur' ){
  5080. $SQLStmt .= ' HAVING ( max( sea_dateFin ) >= CURRENT_DATE OR min( sea_dateDebut ) IS NULL )';
  5081. } elseif( $histo == 'termine' ){
  5082. $SQLStmt .= ' HAVING inscriptionEtat.ie_OK = \'t\' AND max( sea_dateFin ) < CURRENT_DATE';
  5083. }
  5084. switch( $order_by ) {
  5085. case 'sessiona' :
  5086. $SQLStmt .= ' Order By ses_code Asc';
  5087. break;
  5088. case 'sessiond' :
  5089. $SQLStmt .= ' Order By ses_code Desc';
  5090. break;
  5091. case 'dateseaa' :
  5092. $SQLStmt .= ' Order By dSeaDebMin Asc';
  5093. break;
  5094. case 'datesead' :
  5095. $SQLStmt .= ' Order By dSeaDebMin Desc';
  5096. break;
  5097. case 'datelima' :
  5098. $SQLStmt .= ' Order By ses_datelimite Asc';
  5099. break;
  5100. case 'datelimd' :
  5101. $SQLStmt .= ' Order By ses_datelimite Desc';
  5102. break;
  5103. case 'nbinscriptiona' :
  5104. $SQLStmt .= ' Order By nbInscription Asc';
  5105. break;
  5106. case 'nbinscriptiond' :
  5107. $SQLStmt .= ' Order By nbInscription Desc';
  5108. break;
  5109. case 'couta' :
  5110. $SQLStmt .= ' Order By ses_coutParUsager Asc';
  5111. break;
  5112. case 'coutd' :
  5113. $SQLStmt .= ' Order By ses_coutParUsager Desc';
  5114. break;
  5115. default :
  5116. $SQLStmt .= ' Order By dSeaDebMin Desc, ses_code Asc';
  5117. }
  5118. return $SQLStmt;
  5119. }
  5120. function getSQLStmtReqSousHierarchies($branchID, $treeID) {
  5121. $sql = "SELECT node, etiquette FROM nodes";
  5122. if (is_numeric($branchID)) {
  5123. $sql .= " WHERE parent = $branchID";
  5124. }
  5125. else {
  5126. $sql .= " WHERE parent IS NULL";
  5127. }
  5128. $sql .= " AND tr_id = $treeID";
  5129. return $sql;
  5130. }
  5131. ///////////////////////////////////////////////////////////////////////////////////////
  5132. // Retourne la requete SQL necessaire pour faire un SELECT -type 1 record
  5133. ///////////////////////////////////////////////////////////////////////////////////////
  5134. function getSQLStmtReqUsager($usr_id){
  5135. $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";
  5136. $SQLStmt.=" FROM usager, lieu";
  5137. $SQLStmt.=" WHERE usager.li_id = lieu.li_id";
  5138. $SQLStmt.=" AND usr_id = ".$usr_id;
  5139. return ($SQLStmt);
  5140. }
  5141. ///////////////////////////////////////////////////////////////////////////////////////
  5142. // Retourne la requete SQL necessaire pour faire un SELECT -type:LAST
  5143. ///////////////////////////////////////////////////////////////////////////////////////
  5144. function getSQLStmtReqUsagerLAST(){
  5145. $SQLStmt="SELECT MAX(usr_id) FROM usager";
  5146. return $SQLStmt;
  5147. }
  5148. ///////////////////////////////////////////////////////////////////////////////////////
  5149. // Retourne la requete SQL necessaire pour faire un SELECT -type 1 record
  5150. ///////////////////////////////////////////////////////////////////////////////////////
  5151. function getSQLStmtReqUsagerFromLDAP($usr_ldapcode){
  5152. $SQLStmt="SELECT usr_id";
  5153. $SQLStmt.=" FROM usager";
  5154. $SQLStmt.=" WHERE usr_ldapcode = '".fixPGQuote($usr_ldapcode)."'";
  5155. return ($SQLStmt);
  5156. }
  5157. ///////////////////////////////////////////////////////////////////////////////////////
  5158. // Retourne la requete SQL necessaire pour faire un SELECT -type 1 record
  5159. ///////////////////////////////////////////////////////////////////////////////////////
  5160. function getSQLStmtReqUsagerFromLogin($usr_login){
  5161. $SQLStmt="SELECT usr_id, usr_ldap";
  5162. $SQLStmt.=" FROM usager";
  5163. $SQLStmt.=" WHERE usr_login = '".fixPGQuote($usr_login)."'";
  5164. return ($SQLStmt);
  5165. }
  5166. ///////////////////////////////////////////////////////////////////////////////////////
  5167. // Retourne la requete SQL necessaire pour faire un SELECT -type 1 record
  5168. ///////////////////////////////////////////////////////////////////////////////////////
  5169. function getSQLStmtReqUsagerFromLoginPsw($usr_login, $usr_psw){
  5170. $SQLStmt="SELECT usr_id";
  5171. $SQLStmt.=" FROM usager";
  5172. $SQLStmt.=" WHERE usr_login = '".fixPGQuote($usr_login)."'";
  5173. $SQLStmt.=" AND usr_psw = '".fixPGQuote($usr_psw)."'";
  5174. $SQLStmt.=" AND usr_ldap = 'f'";
  5175. return ($SQLStmt);
  5176. }
  5177. ///////////////////////////////////////////////////////////////////////////////////////
  5178. // Retourne la requete SQL necessaire pour faire un SELECT -type multi records
  5179. ///////////////////////////////////////////////////////////////////////////////////////
  5180. function getSQLStmtReqUsagers($mot, $motlnk, $ut_id, $li_id, $adminlieu_id, $valide, $arrFicheID, $indx){
  5181. $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";
  5182. $SQLStmt.=" FROM usager, lieu";
  5183. $SQLStmt.=" WHERE usr_id = usr_id";
  5184. $SQLStmt.=" AND usager.li_id = lieu.li_id";
  5185. if ($mot!=""){
  5186. if ($motlnk!="and" && $motlnk!="or"){
  5187. $motlnk="and"; //valeur par defaut : securite
  5188. }
  5189. $arrMot=getArrayFromStringMot($mot);
  5190. $SQLStmt.=" AND (";
  5191. for ($i=0; $i<count($arrMot); $i++){
  5192. $SQLStmt.="(usr_nom ILIKE '%".fixPGQuote($arrMot[$i])."%'";
  5193. $SQLStmt.=" OR usr_prenom ILIKE '%".fixPGQuote($arrMot[$i])."%'";
  5194. $SQLStmt.=" OR usr_prenom||' '||usr_nom ILIKE '%".fixPGQuote($arrMot[$i])."%')";
  5195. if ($i<count($arrMot)-1){
  5196. $SQLStmt.=" ".$motlnk." "; //OR ou AND
  5197. }
  5198. }
  5199. $SQLStmt.=")";
  5200. }
  5201. if (is_numeric($ut_id)){
  5202. $SQLStmt.=" AND usr_id IN (";
  5203. $SQLStmt.=" SELECT usr_id";
  5204. $SQLStmt.=" FROM usager_usagerType";
  5205. $SQLStmt.=" WHERE ut_id=".$ut_id;
  5206. $SQLStmt.=")";
  5207. }
  5208. if (is_numeric($li_id)){
  5209. $SQLStmt.=" AND usager.li_id = ".$li_id;
  5210. }
  5211. if (is_numeric($adminlieu_id)){
  5212. $SQLStmt.=" AND usager.li_id IN (";
  5213. $SQLStmt.=" SELECT li_id";
  5214. $SQLStmt.=" FROM lieuadmin";
  5215. $SQLStmt.=" WHERE usr_id=".$adminlieu_id;
  5216. $SQLStmt.=")";
  5217. }
  5218. if ($valide!=""){
  5219. if (!strcasecmp($valide,"t")){
  5220. $SQLStmt.=" AND usr_valide='t'";
  5221. }
  5222. else{
  5223. $SQLStmt.=" AND usr_valide='f'";
  5224. }
  5225. }
  5226. if (is_array($arrFicheID)){
  5227. $SQLStmt.=" AND (usager.usr_id <> usager.usr_id";
  5228. for ($i=0; $i<count($arrFicheID); $i++){
  5229. if (is_numeric($arrFicheID[$i])){
  5230. $SQLStmt.=" OR usager.usr_id=".$arrFicheID[$i];
  5231. }
  5232. }
  5233. $SQLStmt.=" )";
  5234. }
  5235. if ($indx!=""){
  5236. if ($indx=="noma"){
  5237. $SQLStmt.=" ORDER BY usr_nom ASC, usr_prenom ASC";
  5238. }
  5239. elseif ($indx=="nomd"){
  5240. $SQLStmt.=" ORDER BY usr_nom DESC, usr_prenom DESC";
  5241. }
  5242. elseif ($indx=="lieua"){
  5243. $SQLStmt.=" ORDER BY li_lieu ASC";
  5244. }
  5245. elseif ($indx=="lieud"){
  5246. $SQLStmt.=" ORDER BY li_lieu DESC";
  5247. }
  5248. elseif ($indx=="typea"){
  5249. $SQLStmt.=" ORDER BY usagerTypeListe ASC";
  5250. }
  5251. elseif ($indx=="typed"){
  5252. $SQLStmt.=" ORDER BY usagerTypeListe DESC";
  5253. }
  5254. }
  5255. return $SQLStmt;
  5256. }
  5257. ///////////////////////////////////////////////////////////////////////////////////////
  5258. // Retourne la requete SQL necessaire pour faire un SELECT -type multi records
  5259. ///////////////////////////////////////////////////////////////////////////////////////
  5260. function getSQLStmtReqUsagersArray($arrFicheID){
  5261. $SQLStmt="SELECT usr_id, usr_nom, usr_prenom";
  5262. $SQLStmt.=" FROM usager";
  5263. $SQLStmt.=" WHERE (usager.usr_id <> usager.usr_id";
  5264. for ($i=0; $i<count($arrFicheID); $i++){
  5265. if (is_numeric($arrFicheID[$i])){
  5266. $SQLStmt.=" OR usager.usr_id=".$arrFicheID[$i];
  5267. }
  5268. }
  5269. $SQLStmt.=" )";
  5270. return $SQLStmt;
  5271. }
  5272. ///////////////////////////////////////////////////////////////////////////////////////
  5273. // Retourne la requete SQL necessaire pour faire un SELECT -type 1 record
  5274. ///////////////////////////////////////////////////////////////////////////////////////
  5275. function getSQLStmtReqUsagerGeneral($usr_id){
  5276. $SQLStmt="SELECT usr_nom, usr_prenom, usr_locale";
  5277. $SQLStmt.=" FROM usager";
  5278. $SQLStmt.=" WHERE usr_id = " . $usr_id;
  5279. return ($SQLStmt);
  5280. }
  5281. ///////////////////////////////////////////////////////////////////////////////////////
  5282. // Retourne la requete SQL necessaire pour faire un SELECT
  5283. ///////////////////////////////////////////////////////////////////////////////////////
  5284. function getSQLStmtReqUsagerTypeForSecID($sec_id){
  5285. $SQLStmt="SELECT usagerType.ut_id, usagerType.ut_type";
  5286. $SQLStmt.=" FROM usagerType";
  5287. $SQLStmt.=" WHERE usagerType.sec_id <= " . $sec_id;
  5288. return ($SQLStmt);
  5289. }
  5290. ///////////////////////////////////////////////////////////////////////////////////////
  5291. // Retourne la requete SQL necessaire pour faire un SELECT
  5292. ///////////////////////////////////////////////////////////////////////////////////////
  5293. function getSQLStmtReqUsagerTypeForUser($usr_id){
  5294. $SQLStmt="SELECT usagerType.ut_id, usagerType.ut_type, usagerType.sec_id";
  5295. $SQLStmt.=" FROM usager_usagerType, usagerType";
  5296. $SQLStmt.=" WHERE usager_usagerType.ut_id=usagerType.ut_id";
  5297. $SQLStmt.=" AND usr_id = " . $usr_id;
  5298. return ($SQLStmt);
  5299. }
  5300. ///////////////////////////////////////////////////////////////////////////////////////
  5301. // Retourne la requete SQL necessaire pour faire un SELECT
  5302. ///////////////////////////////////////////////////////////////////////////////////////
  5303. function getSQLStmtReqUsagerTypeLogin($usr_id){
  5304. $SQLStmt="SELECT usagerType.ut_id, usagerType.sec_id";
  5305. $SQLStmt.=" FROM usager_usagertype, usagerType";
  5306. $SQLStmt.=" WHERE usager_usagerType.ut_id = usagerType.ut_id";
  5307. $SQLStmt.=" AND usr_id = " . $usr_id;
  5308. return ($SQLStmt);
  5309. }
  5310. ///////////////////////////////////////////////////////////////////////////////////////
  5311. // function getTimeStamp($date, $time)
  5312. // Retourne le timestamp en fonction de la date et l'heure pass�es en param�tres
  5313. // IN: $date: la date
  5314. // $time: l'heure
  5315. // OUT: (string-timestamp) le timestamp
  5316. ///////////////////////////////////////////////////////////////////////////////////////
  5317. function getTimeStamp($date, $time){
  5318. if (isDate($date)){
  5319. $time = str_replace("h",":",$time);
  5320. if (isTime24($time)){
  5321. $timestamp = $date." ".$time;
  5322. }
  5323. else{
  5324. $timestamp = $date;
  5325. }
  5326. }
  5327. return($timestamp);
  5328. }
  5329. ///////////////////////////////////////////////////////////////////////////////////////
  5330. // getValFromQueryString($querystring, $var)
  5331. // Retourne la valeur d'une des variables qui se trouve dans le querystring.
  5332. // IN: $querystring: le querystring actuel (ex:"mode=display&pg=1&indx=alpha")
  5333. // $var: variable dans le querystring qu'on veux la valeur (ex: "mode")
  5334. // OUT: (string) la valeur de la variable (ex: "display")
  5335. ///////////////////////////////////////////////////////////////////////////////////////
  5336. function getValFromQueryString($querystring, $var){
  5337. $var=urlencode($var);
  5338. ereg("(^".$var."=|&".$var."=)([^&|^=|^\?]*)", $querystring, $regs); //regs[2]=valeur de var
  5339. return(urldecode($regs[2]));
  5340. }
  5341. ///////////////////////////////////////////////////////////////////////////////////////
  5342. // Retourne la nouvelle string avec les limites accept�es.
  5343. ///////////////////////////////////////////////////////////////////////////////////////
  5344. function getWrapString($sIn,$width,$sBreak){
  5345. if (strlen($sIn)>$width){
  5346. return(substr($sIn,0,$width-strlen($sBreak)).$sBreak);
  5347. }
  5348. else{
  5349. return($sIn);
  5350. }
  5351. }
  5352. ///////////////////////////////////////////////////////////////////////////////////////
  5353. // function isDate($sInput)
  5354. // Retourne true si le input re�u en param�tre est une date valide. Voici les formats
  5355. // accept�s: yyyy-mm-dd ou yyyy/mm/dd ou dd-mm-yyyy ou dd/mm/yyyy
  5356. // IN: $sInput: la date � v�rifier
  5357. // OUT: true: date false: ??
  5358. ///////////////////////////////////////////////////////////////////////////////////////
  5359. function isDate($sInput){
  5360. // yyyy-mm-dd ou yyyy/mm/dd
  5361. if (ereg("(^[0-9]{4})"."(/|-)"."([0-9]{2})"."(/|-)"."([0-9]{2}$)", $sInput, $regs)){
  5362. if (checkdate($regs[3], $regs[5], $regs[1])){
  5363. return true;
  5364. }
  5365. }
  5366. // dd-mm-yyyy ou dd/mm/yyyy
  5367. elseif (ereg("(^[0-9]{2})"."(/|-)"."([0-9]{2})"."(/|-)"."([0-9]{4}$)", $sInput, $regs)){
  5368. if (checkdate($regs[3], $regs[1], $regs[5])){
  5369. return true;
  5370. }
  5371. }
  5372. return false;
  5373. }
  5374. ///////////////////////////////////////////////////////////////////////////////////////
  5375. // function isEmail($sTemp)
  5376. // Retourne true si le input re�u en param�tre est un email.
  5377. ///////////////////////////////////////////////////////////////////////////////////////
  5378. function isEmail($sTemp){
  5379. return (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@'. '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $sTemp));
  5380. }
  5381. ///////////////////////////////////////////////////////////////////////////////////////
  5382. // function isInscriptionOK($nbInscription, $nbInscriptionMax, $sesAnnule, $dSesLimite)
  5383. // Retourne true si les donn�es nous confirme que la session peut permettre l'inscription d'usager
  5384. // IN: $nbInscription nombre d'inscription actuellement
  5385. // $nbInscriptionMax nombre max d'ins que la session peut prendre
  5386. // $sesAnnule 't' si la session est annul�e
  5387. // $dSesLimite date limite pour inscription � la session
  5388. // OUT: true: inscription accept�e
  5389. ///////////////////////////////////////////////////////////////////////////////////////
  5390. function isInscriptionOK($nbInscription, $nbInscriptionMax, $sesAnnule, $dSesLimite){
  5391. if ($nbInscription >= $nbInscriptionMax){
  5392. //echo "(complet)";
  5393. return false;
  5394. }
  5395. if ($sesAnnule == "t"){
  5396. //echo "(annule)";
  5397. return false;
  5398. }
  5399. if ( (isDate($dSesLimite)) && (strtotime(date("Y-m-d"))>strtotime($dSesLimite)) ){
  5400. return false;
  5401. }
  5402. return true;
  5403. }
  5404. ///////////////////////////////////////////////////////////////////////////////////////
  5405. // function isTime24($sInput)
  5406. // Retourne true si le input re�u en param�tre est une heure valide. Voici les formats
  5407. // accept�s: hh:mm:ss hh:mm
  5408. // IN: $sInput: la date � v�rifier
  5409. // OUT: true: heure false: ??
  5410. ///////////////////////////////////////////////////////////////////////////////////////
  5411. function isTime24($sInput){
  5412. //hh:mm:ss
  5413. if (ereg("(^[0-9]{1,2})"."(:)"."([0-9]{1,2})"."(:)"."([0-9]{1,2}$)", $sInput, $regs)){
  5414. if (($regs[1]<=23) && ($regs[3]<=59) && ($regs[5]<=59)){
  5415. return true;
  5416. }
  5417. }
  5418. //hh:mm
  5419. elseif (ereg("(^[0-9]{1,2})"."(:)"."([0-9]{1,2}$)", $sInput, $regs)){
  5420. if (($regs[1]<=23) && ($regs[3]<=59)){
  5421. return true;
  5422. }
  5423. }
  5424. return false;
  5425. }
  5426. ///////////////////////////////////////////////////////////////////////////////////////
  5427. // function isTimeStamp($sInput)
  5428. // Retourne true si le input re�u en param�tre est un timestamp valide.
  5429. // IN: $sInput: timestamp � v�rifier
  5430. // OUT: true: timestamp false: ??
  5431. ///////////////////////////////////////////////////////////////////////////////////////
  5432. function isTimeStamp($sInput){
  5433. //vrai timestamp
  5434. if (ereg("^([^[:space:]]*)"."[[:space:]]"."([^[:space:]]*)$", $sInput, $regs)){
  5435. if ( (isDate($regs[1])) && (isTime24($regs[2])) ){
  5436. return true;
  5437. }
  5438. }
  5439. return false;
  5440. }
  5441. ///////////////////////////////////////////////////////////////////////////////////////
  5442. // printResultPage($hlink, $pg, $nbPage, $nbPageMax, $querystring)
  5443. // Retourne les page r�sultante apr�s une recherche.
  5444. // IN: $hlink: lien vers laquelle on va pointer (r�sultat)
  5445. // $pg: num�ro de page actuelle (nombre)
  5446. // $nbPage: nombre de page de r�sultat de recherche
  5447. // $nbPageMax: maximum de page � afficher dans la barre de navigation
  5448. // $querystring: querystring actuel, �a va nous permettre de l'ajouter au lien
  5449. // $var: variable dans le querystring qu'on veux la valeur (ex: "mode")
  5450. ///////////////////////////////////////////////////////////////////////////////////////
  5451. function getResultPage( $hlink, $class, $htmlHeader, $no_page, $nbPage, $nbPageMax, $querystring ){
  5452. $querystring = getQueryStringUpdated( $querystring, "mode", "display");
  5453. $output = $htmlHeader;
  5454. // Les points de suspensions s'ajoutent quand on coupe la liste en quelque part
  5455. $add_suspension = true;
  5456. // S'il n'y a pas ass� de pages � afficher � gauche, on en transfert � droite
  5457. if( ( $no_page - ceil( $nbPageMax / 2 ) ) < 0 ){
  5458. $nb_gauche = ( $no_page % ceil( $nbPageMax / 2 ) ) - 1;
  5459. $nb_droite = $nbPageMax - ( $nb_gauche % $nbPageMax );
  5460. // La m�me chose mais � l'inverse
  5461. } elseif( ( $no_page + floor( $nbPageMax / 2 ) ) > $nbPage ){
  5462. $nb_droite = $no_page - $nbPage;
  5463. $nb_gauche = $nbPageMax - ( $nb_droite % $nbPageMax );
  5464. // Sinon, on divise le nombre plus ou moins �galement
  5465. } else {
  5466. $nb_gauche = ceil( $nbPageMax / 2 );
  5467. $nb_droite = floor( $nbPageMax / 2 );
  5468. }
  5469. // Si on est plus loin que la page #1, on affiche les fl�ches vers la gauche
  5470. if( $no_page > 1 ){
  5471. $output .= "<a href='" . $hlink . "?" . getQueryStringUpdated( $querystring, "pg", 1 ) . "'>|&lt;</a>";
  5472. $output .= "<a href='" . $hlink . "?" . getQueryStringUpdated( $querystring, "pg", $no_page - 1 ) . "'>&lt;&lt;</a>";
  5473. }
  5474. // Affiche de toutes les pages
  5475. for( $page = 1; $page <= $nbPage; $page++ ){
  5476. // Si la page est dans la zone que l'on veut afficher, on l'affiche
  5477. if( $page >= $no_page - $nb_gauche && $page <= $no_page + $nb_droite ){
  5478. if( $page <> $no_page ){
  5479. $output .= "<a href='" . $hlink . "?" . getQueryStringUpdated( $querystring, "pg", $page ) . "'>" . $page . "</a>";
  5480. } else {
  5481. $output .= "<a class='page_presente'>" . $page . "</a>";
  5482. }
  5483. $add_suspension = true;
  5484. // Sinon, on met des points de suspension
  5485. } else {
  5486. if( $add_suspension ) {
  5487. // Juste une fois
  5488. $add_suspension = false;
  5489. $output .= "<a>[...]</a>";
  5490. }
  5491. }
  5492. }
  5493. // Si on est moins loin que la derni�re page, on affiche les fl�ches vers la droite
  5494. if( $no_page < $nbPage ){
  5495. $output .= "<a href='" . $hlink . "?" . getQueryStringUpdated( $querystring, "pg", $no_page + 1 ) . "'>&gt;&gt;</a>";
  5496. $output .= "<a href='" . $hlink . "?" . getQueryStringUpdated( $querystring, "pg", $nbPage ) . "'>&gt;|</a>";
  5497. }
  5498. // Ajoute la classe s'il y a lieu
  5499. if( $output <> "" && $class <> "" ){
  5500. $output = "<span class='" . $class . "'>".$output."</span>";
  5501. }
  5502. return $output;
  5503. }
  5504. // Fait l'affichage de la fonction "getResultPage"
  5505. function printResultPage( $hlink, $class, $htmlHeader, $no_page, $nbPage, $nbPageMax, $querystring ){
  5506. echo getResultPage( $hlink, $class, $htmlHeader, $no_page, $nbPage, $nbPageMax, $querystring );
  5507. }
  5508. ///////////////////////////////////////////////////////////////////////////////////////
  5509. // printResultPageButton( $pg, $nbPage, $nbPageMax, $class=null )
  5510. // Affiche des boutons menant vers d'auters pages de la m�me recherche
  5511. // IN: $pg: num�ro de page actuelle (nombre)
  5512. // $nbPage: nombre de page de r�sultat de recherche
  5513. // $nbPageMax: maximum de page � afficher dans la barre de navigation
  5514. // $class: param�tre inutile pour le moment, impl�ment� en vue d'ajouts �ventuels
  5515. ///////////////////////////////////////////////////////////////////////////////////////
  5516. function getResultPageButton( $no_page, $nbPage, $nbPageMax, $class = "" ){
  5517. $output = "";
  5518. // Les points de suspensions s'ajoutent quand on coupe la liste en quelque part
  5519. $add_suspension = true;
  5520. // Mani�re que les boutons devront �tre affich�s par sprintf
  5521. $gabarit_bouton = '<button type=\'submit\' name=\'pg\' value=\'%1$s\'%3$s><span>%2$s</span></button>';
  5522. // S'il n'y a pas ass� de pages � afficher � gauche, on en transfert � droite
  5523. if( ( $no_page - ceil( $nbPageMax / 2 ) ) < 0 ){
  5524. $nb_gauche = ( $no_page % ceil( $nbPageMax / 2 ) ) - 1;
  5525. $nb_droite = $nbPageMax - ( $nb_gauche % $nbPageMax );
  5526. // La m�me chose mais � l'inverse
  5527. } elseif( ( $no_page + floor( $nbPageMax / 2 ) ) > $nbPage ){
  5528. $nb_droite = $no_page - $nbPage;
  5529. $nb_gauche = $nbPageMax - ( $nb_droite % $nbPageMax );
  5530. // Sinon, on divise le nombre plus ou moins �galement
  5531. } else {
  5532. $nb_gauche = ceil( $nbPageMax / 2 );
  5533. $nb_droite = floor( $nbPageMax / 2 );
  5534. }
  5535. // Si on est plus loin que la page #1, on affiche les fl�ches vers la gauche
  5536. if( $no_page > 1 ){
  5537. $output .= sprintf( $gabarit_bouton, "1", "|&lt;", "" );
  5538. $output .= sprintf( $gabarit_bouton, ( $no_page - 1 ), "&lt;&lt;", "" );
  5539. }
  5540. // Affiche de toutes les pages
  5541. for( $page = 1; $page <= $nbPage; $page++ ){
  5542. // Si la page est dans la zone que l'on veut afficher, on l'affiche
  5543. if( $page >= $no_page - $nb_gauche && $page <= $no_page + $nb_droite ){
  5544. if( $page <> $no_page ){
  5545. $output .= sprintf( $gabarit_bouton, $page, $page, "" );
  5546. } else {
  5547. $output .= sprintf( $gabarit_bouton, $page, $page, " class='page_presente' disabled='disabled'" );
  5548. }
  5549. $add_suspension = true;
  5550. // Sinon, on met des points de suspension
  5551. } else {
  5552. if( $add_suspension ) {
  5553. // Juste une fois
  5554. $add_suspension = false;
  5555. $output .= sprintf( $gabarit_bouton, $no_page, "...", " disabled='disabled'" );
  5556. }
  5557. }
  5558. }
  5559. // Si on est moins loin que la derni�re page, on affiche les fl�ches vers la droite
  5560. if( $no_page < $nbPage ){
  5561. $output .= sprintf( $gabarit_bouton, ( $no_page + 1 ), "&gt;&gt;", "" );
  5562. $output .= sprintf( $gabarit_bouton, $nbPage, "&gt;|", "" );
  5563. }
  5564. // Ajoute la classe s'il y a lieu
  5565. if( $output <> "" && $class <> "" ){
  5566. $output = "<span class='" . $class . "'>" . $output . "</span>";
  5567. }
  5568. return $output;
  5569. }
  5570. // Fait l'affichage de la fonction "getResultPageButton"
  5571. function printResultPageButton( $pg, $nbPage, $nbPageMax, $class = "" ){
  5572. echo getResultPageButton( $pg, $nbPage, $nbPageMax, $class );
  5573. }
  5574. ///////////////////////////////////////////////////////////////////////////////////////
  5575. // printResultSum($pg, $pageSize, $nbRecordTotal)
  5576. // Affiche les pages r�sultantes apr�s une recherche.
  5577. // IN: $hlink: lien vers laquelle on va pointer (r�sultat)
  5578. // $pg: num�ro de page actuelle (nombre)
  5579. // $nbPage: nombre de page de r�sultat de recherche
  5580. // $nbPageMax: maximum de page � afficher dans la barre de navigation
  5581. // $querystring: querystring actuel, �a va nous permettre de l'ajouter au lien
  5582. // $var: variable dans le querystring qu'on veux la valeur (ex: "mode")
  5583. ///////////////////////////////////////////////////////////////////////////////////////
  5584. function getResultSum( $pg, $pageSize, $nbRecordTotal, $str_affichage = "" ){
  5585. if ( $str_affichage == "" ){ $str_affichage = _("resultats %s a %s sur %s"); }
  5586. if ( !is_numeric( $pg ) ){ $pg = 1; }
  5587. $premier_affiche = ( ( $pg - 1 ) * $pageSize + 1 );
  5588. $dernier_affiche = min( ( $pg * $pageSize ), $nbRecordTotal );
  5589. return sprintf( $str_affichage, $premier_affiche, $dernier_affiche, $nbRecordTotal );
  5590. }
  5591. function printResultSum( $pg, $pageSize, $nbRecordTotal ){
  5592. echo getResultSum( $pg, $pageSize, $nbRecordTotal );
  5593. }
  5594. //getVersionBD
  5595. //retourne la version actuelle de la base de donn�es sous forme de chaine de caract�res
  5596. //OUT : Version actuelle de la BD ou false si un probl�me est rencontr� lors de la v�rification
  5597. //NOTE : Le formulaire appelant doit, au pr�alable, s'�tre connect� � la base de donn�es
  5598. function getVersionBD(){
  5599. $version = "";
  5600. $sql = "SELECT no_version from CVS where date_version=(SELECT max(date_version) from cvs);";
  5601. if ( $result = pg_query($sql) ){
  5602. $version = pg_fetch_result($result,0,0);
  5603. }else{
  5604. $version = false;
  5605. }
  5606. return $version;
  5607. }
  5608. ///////////////////////////////////////////////////////////////////////////////////////
  5609. // getSqlStmtModifiedEnvoyerCourrier($origstmt)
  5610. // Retourne une requ�te SQL comprenant seulement des usr_id unique pour envoyer
  5611. // des courriels. N�cessaire pour �viter les duplicatas. Utilise aussi usr_nom et
  5612. // usr_prenom pour les classer en ordre alphab�tique.
  5613. // IN: $origstmt: requ�te originale
  5614. // OUT: $modstmt: requ�te modifi�e
  5615. ///////////////////////////////////////////////////////////////////////////////////////
  5616. function getSQLStmtModifiedEnvoyerCourrier($origstmt){
  5617. $modstmt="SELECT usr_id, usr_nom, usr_prenom FROM (";
  5618. $modstmt.=$origstmt;
  5619. $modstmt.=") AS table_env_cour GROUP BY usr_id, usr_nom, usr_prenom ORDER BY usr_nom ASC, usr_prenom ASC";
  5620. return $modstmt;
  5621. }
  5622. ///////////////////////////////////////////////////////////////////////////////////////
  5623. // function isSessionOpen()
  5624. // retourne true si une session de fortic est en cours
  5625. // OUT: TRUE si session en cours
  5626. ///////////////////////////////////////////////////////////////////////////////////////
  5627. function isSessionOpen(){
  5628. global $_SESSION;
  5629. if (is_numeric($_SESSION["FORTIC_nLoggedUsrID"])){
  5630. return true;
  5631. }
  5632. else{
  5633. return false;
  5634. }
  5635. }
  5636. ///////////////////////////////////////////////////////////////////////////////////////
  5637. // sessionLogin($nUsrID, $sApplicationKey, $nSessionExpire, $sLogin, $sUsagerTypeIDList, $sSecIDList)
  5638. // m�thode appell�e pour mettre � jour les variables de session lorsque l'usager se log
  5639. // IN: $nUsrID: usr_id de l'usager logg�
  5640. // $sApplicationKey: cl� d'application de fortic (pour �viter que 2 fortic roule en m�me temps)
  5641. // $sLogin: login du user logg�
  5642. // $sNom: nom de famille du user logg�
  5643. // $sPrenom: pr�nom du user logg�
  5644. // $sUsagerTypeIDList: liste des type d'usager assign� au user
  5645. // $sSecIDList: liste des id de s�curit� assossi� au type d'usager du user
  5646. ///////////////////////////////////////////////////////////////////////////////////////
  5647. function sessionLogin($nUsrID, $sApplicationKey, $sLogin, $sNom, $sPrenom, $sUsagerTypeIDList, $sSecIDList){
  5648. global $_SESSION;
  5649. $_SESSION["FORTIC_nLoggedUsrID"] = $nUsrID;
  5650. $_SESSION["FORTIC_sApplicationKey"] = $sApplicationKey;
  5651. $_SESSION["FORTIC_sLogin"] = $sLogin;
  5652. $_SESSION["FORTIC_sNom"] = $sNom;
  5653. $_SESSION["FORTIC_sPrenom"] = $sPrenom;
  5654. $_SESSION["FORTIC_sUsagerTypeIDList"] = $sUsagerTypeIDList;
  5655. $_SESSION["FORTIC_sSecIDList"] = $sSecIDList;
  5656. $_SESSION["FORTIC_sCartSesIDList"] = "";
  5657. }
  5658. ///////////////////////////////////////////////////////////////////////////////////////
  5659. // sessionLogout()
  5660. // m�thode appell�e pour lib�rer les variables de session lorsque l'usager se delog
  5661. ///////////////////////////////////////////////////////////////////////////////////////
  5662. function sessionLogout(){
  5663. global $_SESSION;
  5664. unset($_SESSION["FORTIC_nLoggedUsrID"]);
  5665. unset($_SESSION["FORTIC_sApplicationKey"]);
  5666. unset($_SESSION["FORTIC_sLogin"]);
  5667. unset($_SESSION["FORTIC_sNom"] );
  5668. unset($_SESSION["FORTIC_sPrenom"]);
  5669. unset($_SESSION["FORTIC_sUsagerTypeIDList"]);
  5670. unset($_SESSION["FORTIC_sSecIDList"]);
  5671. unset($_SESSION["FORTIC_sCartSesIDList"]);
  5672. session_unset();
  5673. session_destroy();
  5674. }
  5675. ///////////////////////////////////////////////////////////////////////////////////////
  5676. // Retourne la requete SQL necessaire pour faire un SELECT
  5677. ///////////////////////////////////////////////////////////////////////////////////////
  5678. function getSQLStmtReqAtelierDetail( $atl_id ){
  5679. $SQLStmt = "Select a.atl_atelier, a.atl_description, a.atl_url, a.atl_prealable, a.atl_condition, a.atl_calendrier, a.atl_fraistypique,
  5680. a.atl_note, a.atl_commentaire, a.atl_alacartedisponible, 'NON IMPL�MENT�', usager.usr_id, usager.usr_nom, usager.usr_prenom,
  5681. usager.usr_email, usager.usr_telRejoindre, a.atl_valide, TO_CHAR(a.dateUpdate, 'YYYY-MM-DD HH24:MI:SS') As dateUpdate,
  5682. TO_CHAR(a.dateCreation, 'YYYY-MM-DD HH24:MI:SS') As dateCreation
  5683. From atelier a
  5684. Left Join usager On a.usr_id = usager.usr_id
  5685. Where a.atl_id != '0'";
  5686. if( $atl_id != 0 ){
  5687. $SQLStmt.=" And a.atl_id = '" . $atl_id . "'";
  5688. }
  5689. return $SQLStmt;
  5690. }
  5691. ///////////////////////////////////////////////////////////////////////////////////////
  5692. // Retourne la requete SQL necessaire pour faire un SELECT
  5693. ///////////////////////////////////////////////////////////////////////////////////////
  5694. function getSQLStmtReqAtelierOffreService( $prj_id = 0 ){
  5695. return "Select distinct a.atl_id, a.atl_atelier, substr( a.atl_atelier, 0, 75 ) as atl_short
  5696. From atelier a
  5697. Inner Join session s On s.atl_id = a.atl_id
  5698. Inner Join projet p On p.prj_id = s.prj_id
  5699. Inner Join seance se On s.ses_id = se.ses_id
  5700. Where a.atl_valide = 't' And p.pt_id = '1' And p.prj_id = '" . $prj_id . "' And se.sea_datefin > Now()
  5701. Order by atl_atelier";
  5702. }
  5703. function getSQLStmtReqAtelierOffreServiceAdminLieu( $prj_id = 0 ){
  5704. // 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
  5705. return "Select distinct a.atl_id, a.atl_atelier, substr( a.atl_atelier, 0, 75 ) as atl_short
  5706. From atelier a
  5707. Left join projet_atelier pa On pa.atl_id = a.atl_id
  5708. Left Join projet p On p.prj_id = pa.prj_id
  5709. Where a.atl_valide = 't' And p.pt_id = '1' And a.atl_alacartedisponible Is True And p.prj_id = '" . $prj_id . "'
  5710. Group By atl_atelier, a.atl_id
  5711. Order By atl_atelier";
  5712. }
  5713. ///////////////////////////////////////////////////////////////////////////////////////
  5714. // Retourne les projets
  5715. // Ajout� par Olivier Sackhouse le 7 janvier 2008
  5716. ///////////////////////////////////////////////////////////////////////////////////////
  5717. function getSQLStmtReqProjOffreServ($prj_id = 0){
  5718. $SQLStmt = "Select projet.prj_id, projet.prj_projet
  5719. From projet
  5720. Where projet.pt_id = '1' And projet.prj_valide = '1' ";
  5721. if( $prj_id != 0 ){
  5722. $SQLStmt .= "And projet.prj_id = '" . $prj_id . "' ";
  5723. }
  5724. $SQLStmt .= "Order By projet.prj_projet";
  5725. return $SQLStmt;
  5726. }
  5727. function getSQLStmtReqSessionsOffreServices( $mot, $motlnk, $prj_id, $atl_id, $cla_id, $exp_id, $cli_id, $ses_annule,
  5728. $nbjourstart, $datelimiteOK, $nbinsOK, $valide, $arrFicheId, $indx ){
  5729. $SQLStmt = "Select ses.ses_id, pro.prj_id, prj_projet, pro.prj_valide, ate.atl_id,
  5730. ate.atl_atelier, ate.atl_valide, ses_code, ses_notemini, ses_datelimite, ses_nbMin,
  5731. ses_nbMax, ses_regionnal, ses_annule, ses_annuleraison, ses_valide, COUNT( sea.sea_id ) As nbSeance,
  5732. get_nbInscriptionSession( ses.ses_id ) As nbInscription, TO_CHAR( MIN( sea_dateDebut ), 'YYYY-MM-DD HH24:MI:SS' ) As dSeaDebMin,
  5733. TO_CHAR( MAX( sea_dateDebut ), 'YYYY-MM-DD HH24:MI:SS' ) As dSeaDebMax, get_nbInscriptionSessionAValider( ses.ses_id ),
  5734. ses_coutParUsager, ses_commentaire, 'NON IMPL�MENT�', 'NON IMPL�MENT�', get_nbInscriptionSession( ses.ses_id ) As nbInscription
  5735. From session ses
  5736. Left Join seance sea On ses.ses_id = sea.ses_id
  5737. Left Join projet pro On ses.prj_id = pro.prj_id
  5738. Left Join projetType prt On pro.pt_id = prt.pt_id
  5739. Left Join atelier ate On ses.atl_id = ate.atl_id";
  5740. $where = "";
  5741. // La recherche peut �tre faite pour chaque mot ou pour le groupe au complet
  5742. if( $motlnk != "and" && $motlnk != "or" ){
  5743. $motlnk = "and"; //valeur par defaut : securite
  5744. }
  5745. // Cr�� une table des mots recherch�s
  5746. $arrMot = getArrayFromStringMot( $mot );
  5747. $nb_mots = count( $arrMot );
  5748. if( $nb_mots > 0 ){
  5749. $where .= " ( ";
  5750. for( $i = 0; $i < $nb_mots; $i++ ){
  5751. // V�rifie si le mot est dans la colonne 'ATL_ATELIER'
  5752. $where .= accentInsensitiveLike( "atl_atelier", $arrMot[ $i ] );
  5753. // Ou, v�rifie si le mot est dans la colonne 'ATL_DESCRIPTION'
  5754. $where .= " OR " . accentInsensitiveLike( "atl_description", $arrMot[ $i ] );
  5755. // Ou, v�rifie si le mot est dans la colonne 'SES_CODE'
  5756. $where .= " OR " . accentInsensitiveLike( "ses_code", $arrMot[ $i ] );
  5757. // Ajoute le bon mot selon la requ�te de l'usager
  5758. if( $i < ( $nb_mots - 1 ) ){
  5759. $where .= ") " . $motlnk . " ("; //OR ou AND
  5760. }
  5761. }
  5762. $where .= " ) ";
  5763. }
  5764. if( is_numeric( $prj_id ) ){
  5765. if( $where != "" ){
  5766. $where .= " AND ";
  5767. }
  5768. $where .= " ses.prj_id = '" . $prj_id . "'";
  5769. }
  5770. if( is_numeric( $atl_id ) ){
  5771. if( $where != "" ){
  5772. $where .= " AND ";
  5773. }
  5774. $where .= " ses.atl_id = '" . $atl_id . "'";
  5775. }
  5776. if( is_numeric( $cla_id ) ){
  5777. if( $where != "" ){
  5778. $where .= " AND ";
  5779. }
  5780. $where .= " ses.atl_id In ( Select atl_id From atelier_classe Where cla_id = '".$cla_id . "' )";
  5781. }
  5782. if( is_numeric( $exp_id ) ){
  5783. if( $where != "" ){
  5784. $where .= " AND ";
  5785. }
  5786. $where .= " ses.atl_id In ( Select atl_id From atelier_expertise Where exp_id = '".$exp_id . "' )";
  5787. }
  5788. if( is_numeric( $cli_id ) ){
  5789. if( $where != "" ){
  5790. $where .= " AND ";
  5791. }
  5792. $where .= " ses.atl_id In ( Select atl_id From atelier_clientele Where cli_id = '".$cli_id . "' )";
  5793. }
  5794. if( $ses_annule != "" ){
  5795. if( $where != "" ){
  5796. $where .= " AND ";
  5797. }
  5798. if( to_lower( $ses_annule ) == "t" ){
  5799. $where.=" ses_annule = 't'";
  5800. } else {
  5801. $where.=" ses_annule = 'f'";
  5802. }
  5803. }
  5804. if( $datelimiteOK != "" ){
  5805. if( $where != "" ){
  5806. $where .= " AND ";
  5807. }
  5808. $where .= " sea.ses_id = ses.ses_id And (sea.sea_datefin > Now() OR sea.sea_datefin is null)";
  5809. }
  5810. if( $valide != "" ){
  5811. if( $where != "" ){
  5812. $where .= " AND ";
  5813. }
  5814. if( to_lower( $valide ) == "t" ){
  5815. $where.=" prj_valide = 't' And atl_valide = 't' And ses_valide = 't'";
  5816. } else {
  5817. $where.=" prj_valide = 'f' And atl_valide = 'f' And ses_valide = 'f'";
  5818. }
  5819. }
  5820. if( count( $arrFicheId ) > 0 ){
  5821. if( $where != "" ){
  5822. $where .= " AND ";
  5823. }
  5824. $where .= " ( ses.ses_id <> ses.ses_id";
  5825. for( $i=0; $i < count( $arrFicheId ); $i++ ){
  5826. if( is_numeric( $arrFicheId[ $i ] ) ){
  5827. $where .= " Or ses.ses_id = '" . $arrFicheId[ $i ] . "'";
  5828. }
  5829. }
  5830. $where .= " )";
  5831. }
  5832. if( $where != "" ){
  5833. $where = " WHERE " . $where;
  5834. }
  5835. $SQLStmt .= $where . " GROUP BY ses.ses_id, pro.prj_id, pro.prj_projet, pro.prj_valide, ate.atl_id, ate.atl_atelier,
  5836. ate.atl_valide, ses_code, ses_notemini, ses_datelimite, ses_nbmin, ses_nbmax, ses_regionnal, ses_annule, ses_annuleraison,
  5837. ses_valide, ses_coutParUsager, ses_commentaire";
  5838. if( is_numeric( $nbjourstart ) || $nbinsOK != "" ){
  5839. $SQLStmt .= " Having true"; // Malheureusement, cette clause ne change rien mais elle rend les prochaines lignes plus facile � b�tire
  5840. if( is_numeric( $nbjourstart ) ){
  5841. $SQLStmt .= " And prochaineseance( ses.ses_id ) BETWEEN CURRENT_DATE And CURRENT_DATE + '" . $nbjourstart . "'";
  5842. }
  5843. if ( $nbinsOK != "" ){
  5844. if( strtolwer( $nbinsOK ) == "t" ){
  5845. $SQLStmt .= " And get_nbInscriptionSession( ses.ses_id ) < ses_nbMax";
  5846. } else {
  5847. $SQLStmt .= " And get_nbInscriptionSession( ses.ses_id ) >= ses_nbMax";
  5848. }
  5849. }
  5850. }
  5851. // Cast $INDX en string car comparer 0 avec une string retourne toujours vrai
  5852. switch( ( string ) $indx ){
  5853. case "sessiona" :
  5854. $SQLStmt .= " ORDER BY ses_code ASC";
  5855. break;
  5856. case "sessiond" :
  5857. $SQLStmt .= " ORDER BY ses_code DESC";
  5858. break;
  5859. case "descriptiona" :
  5860. $SQLStmt .= " ORDER BY atl_atelier ASC";
  5861. break;
  5862. case "descriptiond" :
  5863. $SQLStmt .= " ORDER BY atl_atelier DESC";
  5864. break;
  5865. case "dateseaa" :
  5866. $SQLStmt .= " ORDER BY dSeaDebMin ASC";
  5867. break;
  5868. case "datesead" :
  5869. $SQLStmt .= " ORDER BY dSeaDebMin DESC";
  5870. break;
  5871. case "datelima" :
  5872. $SQLStmt .= " ORDER BY ses_datelimite ASC";
  5873. break;
  5874. case "datelimd" :
  5875. $SQLStmt .= " ORDER BY ses_datelimite DESC";
  5876. break;
  5877. case "nbinscriptiona" :
  5878. $SQLStmt .= " ORDER BY nbInscription ASC";
  5879. break;
  5880. case "nbinscriptiond" :
  5881. $SQLStmt .= " ORDER BY nbInscription DESC";
  5882. break;
  5883. case "couta" :
  5884. $SQLStmt .= " ORDER BY ses_coutParUsager ASC";
  5885. break;
  5886. case "coutd" :
  5887. $SQLStmt .= " ORDER BY ses_coutParUsager DESC";
  5888. break;
  5889. default :
  5890. break;
  5891. }
  5892. return $SQLStmt;
  5893. }
  5894. function getSQLStmtReqProjOffreServFull(){
  5895. return "Select distinct p.prj_id, p.prj_projet, a.atl_id, a.atl_atelier, a.datecreation
  5896. From atelier a
  5897. Inner Join session s On s.atl_id = a.atl_id
  5898. Inner join projet_atelier pa On pa.atl_id = a.atl_id
  5899. Inner Join projet p On p.prj_id = pa.prj_id
  5900. Inner Join seance se On s.ses_id = se.ses_id
  5901. 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()
  5902. And se.sea_datedebut > Now()) or (se.sea_datefin is null And se.sea_datedebut is null)) And se.sea_valide Is True
  5903. AND (p.prj_dateFin >= CURRENT_DATE OR p.prj_dateFin IS NULL) AND p.prj_valide='t'
  5904. Group By p.prj_id, p.prj_projet, a.atl_atelier, a.atl_id, a.datecreation
  5905. Order By p.prj_projet, a.atl_atelier";
  5906. }
  5907. function getSQLStmtReqProjOffreServAdminLieu(){
  5908. return "Select distinct p.prj_id, p.prj_projet, a.atl_id, a.atl_atelier, a.datecreation
  5909. From atelier a
  5910. Inner join projet_atelier pa On pa.atl_id = a.atl_id
  5911. Inner Join projet p On p.prj_id = pa.prj_id
  5912. Where a.atl_valide And p.pt_id = 1 And a.atl_alacartedisponible Is True
  5913. Group By p.prj_id, p.prj_projet, a.atl_atelier, a.atl_id, a.datecreation
  5914. Order By p.prj_projet, a.atl_atelier";
  5915. }
  5916. ///////////////////////////////////////////////////////////////////////////////////////
  5917. // Retourne la requete SQL necessaire pour les offre de services
  5918. // Ajout� par Olivier Sackhouse le 7 janvier 2008
  5919. ///////////////////////////////////////////////////////////////////////////////////////
  5920. function getSQLStmtReqOffreServByProjId($proj_id){
  5921. $SQLStmt = "";
  5922. if( is_numeric( $proj_id ) && $proj_id != 0 ){
  5923. $SQLStmt = "Select ses_code, atl.atl_atelier, sum( sea_duree ), ses.ses_coutparusager
  5924. From session As ses
  5925. Inner Join atelier atl On ses.atl_id = atl.atl_id
  5926. Inner Join seance sea On sea.ses_id = ses.ses_id
  5927. Where ses_datelimite < now() And ses.prj_id = '" . $proj_id . "'
  5928. Group by ses_code, atl.atl_atelier, ses.ses_coutparusager";
  5929. }
  5930. return $SQLStmt;
  5931. }
  5932. /**
  5933. * Ajoute la fonction array_intersect_key si elle n'existe pas deja (PHP < 5.1)
  5934. *
  5935. * @param $isec Le tableau contenant les cl�s ma�tres � v�rifier.
  5936. * @param $keys Un tableau contenant les cl�s � comparer.
  5937. * @param ... Un tableau contenant les cl�s � comparer.
  5938. * @return Tableau contenant toutes les entr�es du tableau $isec qui ont des cl�s pr�sentes dans tous les arguments.
  5939. * @author Rod Byrnes -> http://www.php.net/manual/fr/function.array-intersect-key.php#74956
  5940. */
  5941. if( !function_exists( 'array_intersect_key' ) ) {
  5942. function array_intersect_key( $isec, $keys ){
  5943. $argc = func_num_args();
  5944. if( $argc > 2 ) {
  5945. for( $i = 1; !empty( $isec ) && $i < $argc; $i++ ) {
  5946. $arr = func_get_arg($i);
  5947. foreach( array_keys( $isec ) as $key ) {
  5948. if( !isset( $arr[ $key ] ) ) {
  5949. unset( $isec[ $key ] );
  5950. }
  5951. }
  5952. }
  5953. return $isec;
  5954. } else {
  5955. $res = array();
  5956. foreach( array_keys( $isec ) as $key ){
  5957. if( isset( $keys[$key] ) ){
  5958. $res[$key] = $isec[$key];
  5959. }
  5960. }
  5961. return $res;
  5962. }
  5963. }
  5964. }
  5965. function tranlateUsagerTypes( &$arrIDTypes, &$arrNomTypes ){
  5966. //Mettre les bons noms de type d'usager dans l'array $arrNomTypes
  5967. //(Requis pour permettre que les noms des types d'usagers puissent �tre affich�s dans plus d'une langue
  5968. for( $index = 0; $index < count( $arrIDTypes ); $index++ ){
  5969. switch ( $arrIDTypes[$index] ){
  5970. case 1:
  5971. $arrNomTypes[ $index ] = _( "Usager" );
  5972. break;
  5973. case 2:
  5974. $arrNomTypes[ $index ] = _( "Technicien" );
  5975. break;
  5976. case 3:
  5977. $arrNomTypes[ $index ] = _( "Animateur(trice)" );
  5978. break;
  5979. case 4:
  5980. $arrNomTypes[ $index ] = _( "Administrateur(trice) - Lieu" );
  5981. break;
  5982. case 6:
  5983. $arrNomTypes[ $index ] = _( "Administrateur(trice) - General" );
  5984. break;
  5985. case 7:
  5986. $arrNomTypes[ $index ] = _( "Superadministrateur(trice)" );
  5987. break;
  5988. case 8:
  5989. $arrNomTypes[ $index ] = _( "Administrateur(trice) - Projet" );
  5990. break;
  5991. }
  5992. }
  5993. }
  5994. //Retourne true si les fichiers gettext (.mo) correspondant � la string Locale re�ue en param�tre sont disponibles
  5995. function isSupportedLocale( $locale ){
  5996. return array_key_exists( $locale, getHandledLocalesList() );
  5997. }
  5998. function getHandledLocalesList(){
  5999. //Trouver le bon chemin ( relatif ) qui permet d'acc�der � la ressource gettext
  6000. global $cfgMODir;
  6001. $prefix = "./";
  6002. $itt = 5;
  6003. while( !file_exists($prefix.$cfgMODir) && $itt > 0 ){
  6004. $itt--;
  6005. $prefix .= "../";
  6006. }
  6007. //Identifier toutes les cha�nes locales support�es par fortic ( c-a-d les noms de tous les dossiers dans le r�pertoire gettext )
  6008. $localeStrings = array( );
  6009. $locale = getLocalesList();
  6010. $dirPath = $prefix.$cfgMODir;
  6011. if ($handle = opendir($dirPath)) {
  6012. //Lire tous les �l�ments contenus dans le r�pertoire
  6013. while (false !== ($file = readdir($handle))) {
  6014. //Ne pas traiter la r�f�rence au dossier actuel, celle au dossier parent et celle vers le dossier svn
  6015. if ($file != "." && $file != ".." && $file != ".svn" ) {
  6016. //V�rification que ce que l'on regarde est un dossier et porte un nom qui est reconnu comme une chaine locale.
  6017. if (is_dir("$dirPath/$file") && array_key_exists( $file, $locale ) ) {
  6018. $localeStrings[ $file ] = $locale[ $file ];
  6019. }
  6020. }
  6021. }
  6022. closedir($handle);
  6023. }
  6024. return $localeStrings;
  6025. }
  6026. function getLocalesList(){
  6027. $locales = array();
  6028. $locales[ "in" ] = "Bahasa Indonesia";
  6029. $locales[ "in_ID" ] = "Bahasa Indonesia (Indonesia)";
  6030. $locales[ "ms" ] = "Bahasa Melayu";
  6031. $locales[ "ms_MY" ] = "Bahasa Melayu (Malaysia)";
  6032. $locales[ "ca" ] = "Catal�";
  6033. $locales[ "ca_ES" ] = "Catal� (Espanya)";
  6034. $locales[ "da" ] = "Dansk";
  6035. $locales[ "da_DK" ] = "Dansk (Danmark)";
  6036. $locales[ "de" ] = "Deutsch";
  6037. $locales[ "de_DE" ] = "Deutsch (Deutschland)";
  6038. $locales[ "de_LU" ] = "Deutsch (Luxemburg)";
  6039. $locales[ "de_AT" ] = "Deutsch (�sterreich)";
  6040. $locales[ "de_CH" ] = "Deutsch (Schweiz)";
  6041. $locales[ "et" ] = "Eesti";
  6042. $locales[ "et_EE" ] = "Eesti (Eesti)";
  6043. $locales[ "en" ] = "English";
  6044. $locales[ "en_AU" ] = "English (Australia)";
  6045. $locales[ "en_CA" ] = "English (Canada)";
  6046. $locales[ "en_IN" ] = "English (India)";
  6047. $locales[ "en_IE" ] = "English (Ireland)";
  6048. $locales[ "en_MT" ] = "English (Malta)";
  6049. $locales[ "en_NZ" ] = "English (New Zealand)";
  6050. $locales[ "en_PH" ] = "English (Philippines)";
  6051. $locales[ "en_SG" ] = "English (Singapore)";
  6052. $locales[ "en_ZA" ] = "English (South Africa)";
  6053. $locales[ "en_GB" ] = "English (United Kingdom)";
  6054. $locales[ "en_US" ] = "English (United States)";
  6055. $locales[ "es" ] = "Espa�ol";
  6056. $locales[ "es_AR" ] = "Espa�ol (Argentina)";
  6057. $locales[ "es_BO" ] = "Espa�ol (Bolivia)";
  6058. $locales[ "es_CL" ] = "Espa�ol (Chile)";
  6059. $locales[ "es_CO" ] = "Espa�ol (Colombia)";
  6060. $locales[ "es_CR" ] = "Espa�ol (Costa Rica)";
  6061. $locales[ "es_EC" ] = "Espa�ol (Ecuador)";
  6062. $locales[ "es_SV" ] = "Espa�ol (El Salvador)";
  6063. $locales[ "es_ES" ] = "Espa�ol (Espa�a)";
  6064. $locales[ "es_US" ] = "Espa�ol (Estados Unidos)";
  6065. $locales[ "es_HN" ] = "Espa�ol (Honduras)";
  6066. $locales[ "es_MX" ] = "Espa�ol (M�xico)";
  6067. $locales[ "es_NI" ] = "Espa�ol (Nicaragua)";
  6068. $locales[ "es_PY" ] = "Espa�ol (Paraguay)";
  6069. $locales[ "es_PE" ] = "Espa�ol (Per�)";
  6070. $locales[ "es_PR" ] = "Espa�ol (Puerto Rico)";
  6071. $locales[ "es_DO" ] = "Espa�ol (Rep�blica Dominicana)";
  6072. $locales[ "es_UY" ] = "Espa�ol (Uruguay)";
  6073. $locales[ "es_VE" ] = "Espa�ol (Venezuela)";
  6074. $locales[ "fr" ] = "Fran�ais";
  6075. $locales[ "fr_BE" ] = "Fran�ais (Belgique)";
  6076. $locales[ "fr_CA" ] = "Fran�ais (Canada)";
  6077. $locales[ "fr_FR" ] = "Fran�ais (France)";
  6078. $locales[ "fr_LU" ] = "Fran�ais (Luxembourg)";
  6079. $locales[ "fr_CH" ] = "Fran�ais (Suisse)";
  6080. $locales[ "ga" ] = "Gaeilge";
  6081. $locales[ "ga_IE" ] = "Gaeilge (�ire)";
  6082. $locales[ "hr" ] = "Hrvatski";
  6083. $locales[ "hr_HR" ] = "Hrvatski (Hrvatska)";
  6084. $locales[ "is" ] = "�slenska";
  6085. $locales[ "is_IS" ] = "�slenska (�sland)";
  6086. $locales[ "it" ] = "Italiano";
  6087. $locales[ "it_IT" ] = "Italiano (Italia)";
  6088. $locales[ "it_CH" ] = "Italiano (Svizzera)";
  6089. $locales[ "lv" ] = "Latvie&#x161;u";
  6090. $locales[ "lv_LV" ] = "Latvie&#x161;u (Latvija)";
  6091. $locales[ "hu" ] = "Magyar";
  6092. $locales[ "hu_HU" ] = "Magyar (Magyarorsz�g)";
  6093. $locales[ "mt" ] = "Malti";
  6094. $locales[ "mt_MT" ] = "Malti (Malta)";
  6095. $locales[ "nl" ] = "Nederlands";
  6096. $locales[ "nl_BE" ] = "Nederlands (Belgi�)";
  6097. $locales[ "nl_NL" ] = "Nederlands (Nederland)";
  6098. $locales[ "no" ] = "Norsk";
  6099. $locales[ "no_NO" ] = "Norsk (Norge)";
  6100. $locales[ "pl" ] = "Polski";
  6101. $locales[ "pl_PL" ] = "Polski (Polska)";
  6102. $locales[ "pt" ] = "Portugu�s";
  6103. $locales[ "pt_PT" ] = "Portugu�s (Portugal)";
  6104. $locales[ "pt_BR" ] = "Portugu�s (Brasil)";
  6105. $locales[ "tr" ] = "T�rk�e";
  6106. $locales[ "tr_TR" ] = "T�rk�e (T�rkiye)";
  6107. $locales[ "sq_AL" ] = "Shqipe (Shqip�ria)";
  6108. $locales[ "fi" ] = "Suomi";
  6109. $locales[ "fi_FI" ] = "Suomi (Suomi)";
  6110. $locales[ "sv" ] = "Svenska";
  6111. $locales[ "sv_SE" ] = "Svenska (Sverige)";
  6112. return $locales;
  6113. }
  6114. /*************************************************************************
  6115. * Titre : Fonctions de test
  6116. * Description : Une s�ries de fonctions pour tester les diff�rents protocoles et la configuration du server PHP
  6117. * Auteur : Richard Rail
  6118. *************************************************************************/
  6119. /*
  6120. * lister_config_php($droit_ecriture = true, $variables = true, $extension = true) cr�e une liste
  6121. * des configurations du serveur PHP necessaire � Fortic sous le format d'un tableau clef => valeur
  6122. * dont la clef est le nom de la configuration et la valeur est un boolean expriment si la configuration
  6123. * est ad�quate pour le serveur PHP.
  6124. *
  6125. * @param $droit_ecriture - inclure les droits en �criture dans la liste
  6126. * @param $variables - inclure les variables dans la liste
  6127. * @param $extension - inclure les extensions dans la liste
  6128. *
  6129. * @return Array - un tableau clef=>valeur des configuration=>valide
  6130. */
  6131. function lister_config_php($droit_ecriture = true, $variables = true, $extension = true){
  6132. $config = array();
  6133. if($variables){
  6134. $config['phpversion'] = (substr(phpversion(),0,1) >= 5);
  6135. $config['short_open_tag'] = ini_get('short_open_tag') == true;
  6136. $config['register_argc_argv'] = ini_get('register_argc_argv') == true;
  6137. $config['magic_quotes_gpc'] = ini_get('magic_quotes_gpc') == false;
  6138. $config['allow_call_time_pass_reference'] = ini_get('allow_call_time_pass_reference') == true;
  6139. }
  6140. if($extension){
  6141. $extensions = get_loaded_extensions();
  6142. $config['php_gettext'] = in_array( 'gettext', $extensions );
  6143. $config['php_pgsql'] = in_array( 'pgsql', $extensions );
  6144. $config['php_ldap'] = in_array( 'ldap', $extensions );
  6145. }
  6146. if($droit_ecriture){
  6147. $config['ecriture_config'] = is_writable( rechercher_fichier('config') );
  6148. $config['ecriture_config_file'] = is_writable( rechercher_fichier('config/config.php') );
  6149. $config['ecriture_mise_a_jour'] = is_writable( rechercher_fichier('lib/bd_scripts') );
  6150. $config['ecriture_log'] = is_writable( rechercher_fichier('log') );
  6151. $config['ecriture_pdf'] = is_writable( rechercher_fichier('pdf') );
  6152. }
  6153. return $config;
  6154. }
  6155. /*
  6156. * tester_connexion_postgresql($connection_string) teste la connexion au serveur postgresql et retourne
  6157. * un message d'erreur appropri� selon le cas.
  6158. *
  6159. * @param $connection_string - la string de connexion
  6160. *
  6161. * @return Array - retourne un tableau d'erreur
  6162. */
  6163. $resultat_erreur;
  6164. function tester_connexion_postgresql($connection_string){
  6165. /* 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
  6166. * 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
  6167. * d'�rreur et de pass�e des expressions r�gulaire pour voir si le message semble a celui d'un erreur X.
  6168. */
  6169. $error_reporting_old = error_reporting();
  6170. error_reporting(E_WARNING);
  6171. set_error_handler("error_handler_conn_postgresql");
  6172. $conn = pg_connect($connection_string);
  6173. restore_error_handler();
  6174. error_reporting($error_reporting_old);
  6175. if($conn){
  6176. return array('succes' => 'succes');
  6177. } else { //S'il y a un erreur la function error_handler_conn_postgresql va avoir mis l'erreur dans resultat_erreur
  6178. return $GLOBALS['resultat_erreur'];
  6179. }
  6180. }
  6181. /*
  6182. * error_handler_conn_postgresql remplace le 'error handler' par default pour la fonction tester_connexion_postgresql
  6183. */
  6184. function error_handler_conn_postgresql($errorNumber, $errorMessage, $errorFile, $errorLine, $vars){
  6185. global $resultat_erreur;
  6186. $resultat_erreur = array();
  6187. $pre = '/Unable to connect to PostgreSQL server: ';
  6188. if( preg_match($pre.'.*database.*does not exist/',$errorMessage)){
  6189. $resultat_erreur['database'] = 'La base de donn�e n\a pas �t� trouv�.';
  6190. } else if( preg_match($pre.'.*password authentication failed for user.*/',$errorMessage)){
  6191. $resultat_erreur['authentification'] = 'L\'authentification est invalide.';
  6192. } else if( preg_match($pre.'.*Connection refused.*/',$errorMessage)){
  6193. $resultat_erreur['connexion'] = 'Le serveur est non accesible ou le port n\'est pas en ecoute ou est bloqu�.';
  6194. } else if( preg_match($pre.'.*Unknown host.*/',$errorMessage)){
  6195. $resultat_erreur['connexion'] = 'Nom de l\'h�te est inconnue';
  6196. } else {
  6197. $resultat_erreur['erreur'] = $errorMessage;
  6198. }
  6199. }
  6200. /*
  6201. * tester_serveur_SMTP($serveur) teste la connexion au serveur SMTP et retourne
  6202. * un message d'erreur appropri� selon le cas.
  6203. *
  6204. * @param $connection_string - la string de connexion
  6205. *
  6206. * @return Array - retourne un tableau d'erreur
  6207. */
  6208. function tester_serveur_SMTP($serveur){
  6209. require_once("../lib/php/phpmailer/class.phpmailer.php");
  6210. $mail = new PHPMailer();
  6211. $mail->SetLanguage("fr","../lib/php/phpmailer/");
  6212. $mail->IsSMTP();
  6213. $mail->Host = $serveur;
  6214. $mail->From = "noreply@noreply.com";
  6215. $mail->AddAddress("noreply@noreply.com");
  6216. $mail->FromName = "Test";
  6217. $mail->Subject = 'Test';
  6218. $mail->Body = 'Test';
  6219. $mail->SMTPAuth = false;
  6220. if($mail->Send()) {
  6221. return array("succes" => 'Le serveur est accessible');
  6222. } else {
  6223. return array("erreur" => 'Le serveur n\'est pas accessible');
  6224. }
  6225. }
  6226. /*
  6227. * tester_ldap($serveur, $port, $bind_rdn, $bind_password, $base_dn, $filtre, $infos)
  6228. * teste la connexion au serveur LDAP et retourne un message d'erreur appropri� selon le cas.
  6229. *
  6230. * @param $serveur - string du serveur � se connecter
  6231. * @param $port - string du port
  6232. * @param $bind_rdn - string du rdn
  6233. * @param $bind_password - string du mot de passe
  6234. * @param $base_dn - string du dn
  6235. * @param $filtre - string du filtre ldap
  6236. * @param $infos - array d'informations a tester dans ldap
  6237. *
  6238. * @return Array - retourne un tableau d'erreur
  6239. */
  6240. function tester_ldap($serveur, $port, $bind_rdn, $bind_password, $base_dn, $filtre, $infos){
  6241. $resultat = null;
  6242. //S'il n'y a pas de filtre on va tenter de s'en faire un pour pas que sa plante
  6243. if($filtre == ''){
  6244. $filtre = explode(',',$bind_rdn);
  6245. $filtre = '('.$filtre[0].')';
  6246. }
  6247. $error_reporting_old = error_reporting();
  6248. error_reporting(0);
  6249. $conLDAP = ldap_connect( $serveur, $port );
  6250. //Si options LDAP on les appliquent
  6251. if ( count($ldap_var["ldap_options"]) > 0) {
  6252. OptionConnexion_LDAP($conLDAP);
  6253. }
  6254. if(ldap_errno($conLDAP) == 0){
  6255. ldap_bind($conLDAP, $bind_rdn, $bind_password)
  6256. && ( $arrayRecherche = ldap_search($conLDAP, $base_dn, $filtre) )
  6257. && ( $ldap_info = ldap_get_entries($conLDAP, $arrayRecherche) );
  6258. }
  6259. if(ldap_errno($conLDAP) != 0){
  6260. switch(ldap_errno($conLDAP)){
  6261. case 81: //Can't contact LDAP server
  6262. $resultat = array('connexion'=>'Erreur de connection au serveur LDAP');
  6263. break;
  6264. case 49: //Invalid credentials
  6265. $resultat = array('credentials'=>'Erreur de connection au serveur LDAP');
  6266. break;
  6267. case 87: //Bad search filter
  6268. $resultat = array('filtre'=>'Filtre invalide');
  6269. break;
  6270. case 32: //No such object
  6271. $resultat = array('base_dn'=>'La base de recherche est invalide');
  6272. break;
  6273. default:
  6274. $resultat = array('erreur'=>'Erreur inconnue #'.ldap_errno($conLDAP) . ' : ' . ldap_error($conLDAP) . ' |'.$bind_password.'|');
  6275. break;
  6276. }//switch
  6277. } else {
  6278. $resultat = array();
  6279. // Tentative de rendre l'application compatible avec OpenLDAP
  6280. if( $ldap_info[ 'count' ] == 1 ){
  6281. $ldap_info = $ldap_info[ 0 ];
  6282. }
  6283. foreach( $infos as $info ){
  6284. if( !in_array($info, $ldap_info) ){
  6285. $resultat["$info"] = $info. ' n\'est pas une information valide';
  6286. }
  6287. }
  6288. }
  6289. if(is_array($resultat) && count($resultat) == 0) $resultat = array('succes' => 'succes');
  6290. ldap_close( $conLDAP );
  6291. error_reporting($error_reporting_old);
  6292. return $resultat;
  6293. }
  6294. /*
  6295. * rechercher_fichier($fichier) cherche le fichier $fichier en reculant de plus en plus dans l'arborescence
  6296. * et arr�te � la racine du serveur PHP
  6297. *
  6298. * @param $fichier - fichier � trouv� (peut �tre un dossier)
  6299. *
  6300. * @return string - chemin jusqu'au dossier ( ../../../fichier ) ou FALSE s'il ne le trouve pas
  6301. */
  6302. function rechercher_fichier($fichier){
  6303. $env = getenv("SCRIPT_NAME");
  6304. //on compte le nombre de dossier entre le script et la racine du serveur
  6305. $nb_bon_max = count( explode('/',$env) ) - 1;
  6306. while( $nb_bon_max-- >0 ){
  6307. if( file_exists($fichier) ) return $fichier;
  6308. $fichier = '../' . $fichier;
  6309. }
  6310. return false;
  6311. }
  6312. }// fin du define PHP_LIBRARY_FORTICFUNCTIONS
  6313. ?>