liste_employeurs.inc.php 16 KB

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