liste_employeurs.inc.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <?php
  2. // --------
  3. // Sécurité
  4. // --------
  5. if (isValidConstant() != 1) {
  6. fermeSessionUtilisateur();
  7. }
  8. // ----------------------
  9. // Droit de l'utilisateur
  10. // ----------------------
  11. if ($_SESSION['gestion_site'] < 'Oui') {
  12. exit;
  13. }
  14. // ------------------------------
  15. // Caractéristiques du module
  16. // ------------------------------
  17. unset($module);
  18. $module = array(
  19. "titre" => "Gestion des employeurs",
  20. "urldest" => $SCRIPT_NAME . "?page=liste_employeurs",
  21. "recherche" => array("engin" => false),
  22. "jeton" => $jeton,
  23. "opradmin" => "Ajouter un employeur",
  24. "fenetre" => array(
  25. "nom" => "liste_employeurs",
  26. "titre" => "titre",
  27. "largeur" => "1200",
  28. "hauteur" => "550",
  29. "validation" => true,
  30. "champs" => array("lnoemployeur", "lnom", "lcontact", "ltitre", "ladresse1", "ladresse2", "lville", "lcodepostal", "ltelephone", "ltelecopieur", "lemail")
  31. ),
  32. "msgajoutbouton" => "Ajout d'une fiche d'employeur",
  33. "actionajoutbouton" => "Ajouter la fiche de l'employeur",
  34. "msgmodifbouton" => "Modification de la fiche d'un employeur",
  35. "actionmodifbouton" => "Modifier la fiche de l'employeur",
  36. "nombre_a_afficher" => array(
  37. 0 => array("refid" => 15, "valeur" => 15),
  38. 1 => array("refid" => 30, "valeur" => 30),
  39. 2 => array("refid" => 45, "valeur" => 45),
  40. 3 => array("refid" => 60, "valeur" => 60),
  41. 4 => array("refid" => 120, "valeur" => 120)
  42. ),
  43. "lientri" => true,
  44. "entete" => array(
  45. 1 => array("# Employeur" => "refemployeur", "largeur" => "145px"),
  46. 2 => array("Employeur" => "nomemployeur", "largeur" => "200px"),
  47. 3 => array("Contact" => "nomcontact", "largeur" => "200px"),
  48. 4 => array("Titre/Dept" => "dept", "largeur" => "125px"),
  49. 5 => array("Adresse" => "(adresse1+adresse2+ville+codepostal)", "largeur" => "165px"),
  50. 6 => array("Téléphone" => "numtel", "largeur" => "90px"),
  51. 7 => array("Télécopieur" => "numfax", "largeur" => "90px"),
  52. 8 => array("Adresse @" => "email", "largeur" => "200px"),
  53. 9 => array("Action" => "expression", "largeur" => "45px")
  54. ),
  55. "msg" => array(
  56. "maj_ok" => "Modification effectuée avec succès.",
  57. "maj_echec" => "L'opération de mise à jour de l'employeur a échouée."
  58. )
  59. );
  60. // ------------------
  61. // Requête sur le tri
  62. // ------------------
  63. $rtri = antiInjection($module["entete"][$tri][key($module["entete"][$tri])] . " " . $dir);
  64. // -----------------------
  65. // Opération de sauvegarde
  66. // -----------------------
  67. if (isset($action)) {
  68. $msg = "";
  69. $action = stripslashes(antiInjection($action));
  70. if ($action == "Modifier la fiche de l'employeur" || $action == "Ajouter la fiche de l'employeur") {
  71. $lnoemployeur = antiInjection($lnoemployeur);
  72. $lnom = antiInjection($lnom);
  73. $lcontact = antiInjection($lcontact);
  74. $ltitre = antiInjection(htmlspecialchars($ltitre, ENT_NOQUOTES, "UTF-8"));
  75. $ladresse1 = antiInjection($ladresse1);
  76. $ladresse2 = antiInjection($ladresse2);
  77. $lville = antiInjection($lville);
  78. $lcodepostal = antiInjection($lcodepostal);
  79. $ltelephone = antiInjection($ltelephone);
  80. $ltelecopieur = antiInjection($ltelecopieur);
  81. $lemail = antiInjection($lemail);
  82. if ($action == "Modifier la fiche de l'employeur") {
  83. $sqlparam["type"] = "UPDATE";
  84. $sqlparam["where"][] = "refemployeur = " . sprintf("%d", $lnoemployeur);
  85. } else {
  86. $sqlparam["type"] = "INSERT";
  87. $sqlparam["champs"]["refemployeur"] = sprintf("%d", $lnoemployeur);
  88. }
  89. $sqlparam["table"][] = "employeurs";
  90. $sqlparam["champs"]["nomemployeur"] = "'" . sprintf("%s", $lnom) . "'";
  91. $sqlparam["champs"]["nomcontact"] = "'" . sprintf("%s", $lcontact) . "'";
  92. $sqlparam["champs"]["dept"] = "'" . sprintf("%s", $ltitre) . "'";
  93. $sqlparam["champs"]["adresse1"] = "'" . sprintf("%s", $ladresse1) . "'";
  94. $sqlparam["champs"]["adresse2"] = "'" . sprintf("%s", $ladresse2) . "'";
  95. $sqlparam["champs"]["ville"] = "'" . sprintf("%s", $lville) . "'";
  96. $sqlparam["champs"]["codepostal"] = "'" . sprintf("%s", $lcodepostal) . "'";
  97. $sqlparam["champs"]["numtel"] = "'" . sprintf("%s", $ltelephone) . "'";
  98. $sqlparam["champs"]["numfax"] = "'" . sprintf("%s", $ltelecopieur) . "'";
  99. $sqlparam["champs"]["email"] = "'" . sprintf("%s", $lemail) . "'";
  100. // TODO - Mettre une valeur pour le champ «TitreContact» même s'il n'est pas utilisé.
  101. // TODO - Champ possiblement à retirer.
  102. $sqlparam["champs"]["titrecontact"] = "'vide'";
  103. $result = executerRequeteSql($sqlparam);
  104. if (isset($result)) {
  105. unset($lnoemployeur);
  106. unset($lnom);
  107. unset($lcontact);
  108. unset($ltitre);
  109. unset($ladresse1);
  110. unset($ladresse2);
  111. unset($lville);
  112. unset($lcodepostal);
  113. unset($ltelephone);
  114. unset($ltelecopieur);
  115. unset($lnoemployeur);
  116. unset($lemail);
  117. $lnoemployeur = -1;
  118. $lnom = '';
  119. $lcontact = '';
  120. $ltitre = '';
  121. $ladresse1 = '';
  122. $ladresse2 = '';
  123. $lville = '';
  124. $lcodepostal = '';
  125. $ltelephone = '';
  126. $ltelecopieur = '';
  127. $lemail = '';
  128. $module["resultatSQL"] = true;
  129. $module["message"] = $module["msg"]["maj_ok"];
  130. } else {
  131. $module["resultatSQL"] = false;
  132. $module["message"] = $module["msg"]["maj_echec"];
  133. }
  134. }
  135. } else {
  136. unset($lnom);
  137. unset($lcontact);
  138. unset($ltitre);
  139. unset($ladresse1);
  140. unset($ladresse2);
  141. unset($lville);
  142. unset($lcodepostal);
  143. unset($ltelephone);
  144. unset($ltelecopieur);
  145. unset($lnoemployeur);
  146. unset($lemail);
  147. $lnom = '';
  148. $lcontact = '';
  149. $ltitre = '';
  150. $ladresse1 = '';
  151. $ladresse2 = '';
  152. $lville = '';
  153. $lcodepostal = '';
  154. $ltelephone = '';
  155. $ltelecopieur = '';
  156. $lnoemployeur = '';
  157. $lemail = '';
  158. }
  159. $i = 0;
  160. unset($sqlparam);
  161. $sqlparam["table"][] = "employeurs";
  162. $sqlparam["champs"][] = "employeurs.refemployeur";
  163. $sqlparam["champs"][] = "employeurs.nomemployeur";
  164. $sqlparam["champs"][] = "employeurs.nomcontact";
  165. $sqlparam["champs"][] = "employeurs.dept";
  166. $sqlparam["champs"][] = "employeurs.adresse1";
  167. $sqlparam["champs"][] = "employeurs.adresse2";
  168. $sqlparam["champs"][] = "employeurs.ville";
  169. $sqlparam["champs"][] = "employeurs.codepostal";
  170. $sqlparam["champs"][] = "employeurs.numtel";
  171. $sqlparam["champs"][] = "employeurs.numfax";
  172. $sqlparam["champs"][] = "employeurs.email";
  173. $sqlparam["champs"][] = "(SELECT count(employeurs.refemployeur) FROM employeurs) as compte";
  174. $sqlparam["limite"] = ($nombreaffiche * ($nopage - 1)) . "," . $nombreaffiche + 1;
  175. $sqlparam["ordre"][] = $rtri;
  176. $result = executerRequeteSql($sqlparam);
  177. if (isset($result) && is_array($result) && count($result) > 0) {
  178. $module["compte"] = $result[0]["compte"];
  179. } else {
  180. $module["compte"] = 0;
  181. }
  182. print preparerModule($module);
  183. //Liste principale
  184. if (isset($result)) {
  185. $i = ($nopage - 1) * $nombreaffiche + 1;
  186. unset($style);
  187. $style = "border:1px solid #cfcfcf; font-family:arial, helvetica, sans-serif; font-size:9pt; ";
  188. $style .= "margin-left:5px; margin-right:5px; padding-right:10px;overflow-x:hidden; white-space:nowrap;";
  189. //Boucle de lecture
  190. foreach ($result as $clef => $champs) {
  191. $adresse1 = ($champs["adresse2"] != "") ? ", " . $champs["adresse2"] . ", " : ", ";
  192. $adresse2 = ($champs["adresse2"] != "") ? ",\" " . $champs["adresse2"] . "\", " : ", ";
  193. $telephone = ($champs["numtel"] != "") ? $champs["numtel"] : " ";
  194. $telecopieur = ($champs["numfax"] != "") ? $champs["numfax"] : " ";
  195. $email = (empty($champs["email"]) ? "&nbsp;" : $champs["email"]);
  196. print "<tr>\n";
  197. print "<td style='$style'>" . $i . "</td>";
  198. print "<td class='detail_liste' style='width:" . $module["entete"][1]["largeur"] . "px;'title=\"" . $champs["refemployeur"] . "\">" . $champs["refemployeur"] . "</td>";
  199. print "<td class='detail_liste' style='width:" . $module["entete"][2]["largeur"] . "px;' title=\"" . htmlentities($champs["nomemployeur"]) . "\">";
  200. print "<div style='overflow:hidden; white-space:nowrap; width:200px;'>" . htmlentities($champs["nomemployeur"], ENT_SUBSTITUTE, "UTF-8") . "</div></td>";
  201. print "<td class='detail_liste' style='width:" . $module["entete"][3]["largeur"] . "px;' title=\"" . $champs["nomcontact"] . "\">";
  202. print "<div style='overflow:hidden; white-space:nowrap; width:200px;'>" . htmlentities($champs["nomcontact"], ENT_SUBSTITUTE, "UTF-8") . "</div></td>";
  203. print "<td class='detail_liste' style=' width:" . $module["entete"][4]["largeur"] . "px;' title=\"" . $champs["dept"] . "\">";
  204. print "<div style='overflow:hidden; white-space:nowrap; width:125px;'>" . htmlentities($champs["dept"], ENT_SUBSTITUTE, "UTF-8") . "</div></td>";
  205. print "<td class='detail_liste' style='width:" . $module["entete"][5]["largeur"] . "px;' title=\"" . htmlentities($champs["adresse1"] . $adresse1 . $champs["ville"] . " " . $champs["codepostal"], ENT_SUBSTITUTE, "UTF-8") . "\">";
  206. print "<div style='overflow:hidden; white-space:nowrap; width:165px;'>" . htmlentities($champs["adresse1"] . $adresse1 . $champs["ville"] . " " . $champs["codepostal"], ENT_SUBSTITUTE, "UTF-8") . "</div></td>\n";
  207. print "<td class='detail_liste' style='width:" . $module["entete"][6]["largeur"] . "px;' title=\"" . $telephone . "\">";
  208. print htmlentities($telephone, ENT_SUBSTITUTE, "UTF-8") . "</td>\n";
  209. print "<td class='detail_liste' style='width:" . $module["entete"][7]["largeur"] . "px;' title=\"" . $telecopieur . "\">";
  210. print htmlentities($telecopieur, ENT_SUBSTITUTE, "UTF-8") . "</td>\n";
  211. print "<td class='detail_liste' style='width:" . $module["entete"][8]["largeur"] . "px;' title=\"" . $email . "\">";
  212. print "<div style='overflow:hidden; white-space:nowrap; width:200px;'>" . htmlentities($email, ENT_SUBSTITUTE, "UTF-8") . "</div></td>\n";
  213. print "<td class='detail_liste' style='width:30x;'>\n";
  214. print "<form action='' name='sous_formulaire$i'>";
  215. print prepareBoutonModifier(array($champs["refemployeur"], $champs["nomemployeur"], $champs["nomcontact"],
  216. $champs["dept"], $champs["adresse1"], $champs["adresse2"], $champs["ville"], $champs["codepostal"], $champs["numtel"],
  217. $champs["numfax"], $champs["email"]));
  218. print "</form>";
  219. print "</td>\n";
  220. print "</tr>\n";
  221. $i++;
  222. }
  223. print"</table>";
  224. ?>
  225. <script type='text/javascript'>
  226. function ValidationFormulaire()
  227. {
  228. var msgNom = "Nom de l'employeur requis.";
  229. var msgPersonne = "Nom de la personne contact requis.";
  230. var msgTitre = "Titre de la personne contact requis.";
  231. var msgAdresse = "Adresse requise.";
  232. var msgVille = "Nom de la ville requise.";
  233. var msgCodePostal1 = "Code postal requis.";
  234. var msgTel1 = "Numéro de téléphone requis.";
  235. var msgTel2 = "Numéro de télécopieur requis.";
  236. var msgEmail = "Adresse de courriel valide requise";
  237. var frm = document.frmEmp;
  238. if ($("#lnom").val() === "") {
  239. jAlert(msgNom);
  240. return false;
  241. } else if (frm.lcontact.value === "") {
  242. jAlert(msgPersonne);
  243. return false;
  244. } else if (frm.ltitre.value === "") {
  245. jAlert(msgTitre);
  246. return false;
  247. } else if (frm.ladresse1.value === "") {
  248. jAlert(msgAdresse);
  249. return false;
  250. } else if (frm.lville.value === "") {
  251. jAlert(msgVille);
  252. return false;
  253. } else if (!isPostCode(frm.lcodepostal.value)) {
  254. jAlert(msgCodePostal1);
  255. return false;
  256. } else if (!isTelephone(frm.ltelephone.value)) {
  257. jAlert(msgTel1);
  258. frm.ltelephone.focus();
  259. return false;
  260. } else if (!isTelephone(frm.ltelecopieur.value)) {
  261. jAlert(msgTel2);
  262. frm.ltelecopieur.focus();
  263. return false;
  264. } else if (!isCourrielValide(frm.lemail.value)) {
  265. jAlert(msgEmail);
  266. frm.lemail.focus();
  267. return false;
  268. }
  269. closeRemote();
  270. return true;
  271. }
  272. function modifpres() {
  273. var frm = document.frmModif;
  274. var valeurTexte = remove(frm.lcontact.value, "Madame ");
  275. valeurTexte = remove(valeurTexte, "Monsieur ");
  276. if (frm.lpresentation.selectedIndex > 0) {
  277. frm.lcontact.value = frm.lpresentation.value + " " + valeurTexte;
  278. }
  279. }
  280. // Mise en place des masques de saisie
  281. $(document).ready(function () {
  282. $("#lcodepostal").mask("a9a 9a9");
  283. $("#ltelephone").mask("(999) 999-9999");
  284. $("#ltelecopieur").mask("(999) 999-9999");
  285. $("#frmModif").validate();
  286. });
  287. </script>
  288. <?php
  289. // Pagination
  290. print "<table style='width:968px; margin:auto;'>";
  291. print "<tr><td style='vertical-align:bottom;'>";
  292. print $seqpage;
  293. print "</td>";
  294. print "<td style='width:320px; text-align:right;'>";
  295. //Haut de page
  296. if ($nombreaffiche > 15 && $module["compte"] > $nombreaffiche) {
  297. print "<a href='#hautpage' title='Aller en haut de la page'>Haut de page</a>";
  298. print "<a name='baspage'>";
  299. }
  300. print "</td></tr>";
  301. print "</table>";
  302. print fenetreModaleDebut($module["fenetre"], $SCRIPT_NAME, $jeton);
  303. print "<tr>";
  304. print "<td># Employeur : </td>";
  305. print "<td><INPUT type='text' id='lnoemployeur' name='lnoemployeur' ";
  306. print "style='border:0px; ' tabindex='0' value='" . $lnoemployeur . "' class='required'></td>";
  307. print "</tr>";
  308. print "<tr>";
  309. print "<td>Nom : </td>";
  310. print "<td>";
  311. print "<INPUT TYPE='text' id='lnom' NAME='lnom' Value='" . $lnom . "' SIZE='50' MAXLENGTH='50'";
  312. print "class='required '>";
  313. print "</td>";
  314. print "</tr>";
  315. print "<tr>";
  316. print "<td>Personne contact : </td>";
  317. print "<td>";
  318. print "<select name='lpresentation' onblur=\"javascript:modifpres()\" onclick=\"javascript:modifpres()\">";
  319. print "<option>-----</option>";
  320. print "<option>Madame</option>";
  321. print "<option>Monsieur</option>";
  322. print "</select>";
  323. print "<INPUT TYPE='text' NAME='lcontact' id='lcontact' Value='$lcontact' SIZE='50' MAXLENGTH='50' >";
  324. print "</td>";
  325. print "</tr>";
  326. print "<tr>";
  327. print "<td>Titre / Département : </td>";
  328. print "<td>";
  329. print "<INPUT TYPE='text' NAME='ltitre' id='ltitre' Value='$ltitre' SIZE='50' MAXLENGTH='50' >";
  330. print "</td>";
  331. print "</tr>";
  332. print "<tr>";
  333. print "<td>Adresse 1: </td>";
  334. print "<td>";
  335. print "<INPUT TYPE='text' NAME='ladresse1' id='ladresse1' Value='$ladresse1' SIZE='50' MAXLENGTH='50' >";
  336. print "</td>";
  337. print "</tr>";
  338. print "<tr>";
  339. print "<td>Adresse 2: </td>";
  340. print "<td>";
  341. print "<INPUT TYPE='text' NAME='ladresse2' id='ladresse2' Value='$ladresse2' SIZE='50' MAXLENGTH='50'><br>";
  342. print "</td>";
  343. print "</tr>";
  344. print "<tr>";
  345. print "<td>Ville : </td>";
  346. print "<td>";
  347. print "<INPUT TYPE='text' NAME='lville' id='lville' Value='$lville' SIZE='30' MAXLENGTH='30' ><br>";
  348. print "</td>";
  349. print "</tr>";
  350. print "<tr>";
  351. print "<td>Code postal : </td>";
  352. print "<td>";
  353. print "<INPUT TYPE='text' id='lcodepostal' NAME='lcodepostal' Value='$lcodepostal' SIZE='7' MAXLENGTH='7' >";
  354. print "</td>";
  355. print "</tr>";
  356. print "<tr>";
  357. print "<td>Téléphone : </td>";
  358. print "<td>";
  359. print "<INPUT class='mask_phone' TYPE='text'NAME='ltelephone' Value='$ltelephone' id='ltelephone' SIZE='14' MAXLENGTH='14' >";
  360. print "</td>";
  361. print "</tr>";
  362. print "<tr>";
  363. print "<td>Télécopieur : </td>";
  364. print "<td>";
  365. print "<INPUT class='mask_phone' TYPE='text' NAME='ltelecopieur' Value='$ltelecopieur' id='ltelecopieur' SIZE='14' MAXLENGTH='14' >";
  366. print "</td>";
  367. print "</tr>";
  368. print "<tr>";
  369. print "<td>Adresse de courriel : </td>";
  370. print "<td>";
  371. print "<INPUT TYPE='text' NAME='lemail' id='lemail' Value='$lemail' ";
  372. print "SIZE='50' MAXLENGTH='50' class='required email'><br>";
  373. print "</td >";
  374. print "</tr>";
  375. print fenetreModaleFin($module["actionmodifbouton"]);
  376. }