creation_liberation_apercu.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <?php
  2. define("LIBERATIONSWEB", 20091223);
  3. //Librairie de fonctions
  4. session_start();
  5. //Librairie de fonctions
  6. require (__DIR__ . '/vendor/autoload.php');
  7. require_once("lib/libconfig.inc.php");
  8. require_once("lib/libsession.inc.php");
  9. require_once("lib/libfonctions.inc.php");
  10. require_once("lib/libmysql.inc.php");
  11. require_once("lib/libencode.inc.php");
  12. require_once("lib/libcourriel.inc.php");
  13. require_once("lib/libcentrale.inc.php");
  14. require_once("fpdf/fpdf.php");
  15. class PDF extends FPDF {
  16. var $NomContact;
  17. var $Dept;
  18. var $NomEmployeur;
  19. var $EmployeursAdresse1;
  20. var $EmployeursVille;
  21. var $EmployeursCodePostal;
  22. var $DateDemande;
  23. var $NumEmploye;
  24. var $NomEmploye;
  25. var $EmployesAdresse;
  26. var $Opr;
  27. var $VilleEmploye;
  28. var $configCentrale;
  29. function WordWrap(&$text, $maxwidth) {
  30. $text = trim($text);
  31. if ($text === '')
  32. return 0;
  33. $space = $this->GetStringWidth(' ');
  34. $lines = explode("\n", $text);
  35. $text = '';
  36. $count = 0;
  37. foreach ($lines as $line) {
  38. $words = preg_split('/ +/', $line);
  39. $width = 0;
  40. foreach ($words as $word) {
  41. $wordwidth = $this->GetStringWidth($word);
  42. if ($wordwidth > $maxwidth) {
  43. // Word is too long, we cut it
  44. for ($i = 0; $i < strlen($word); $i++) {
  45. $wordwidth = $this->GetStringWidth(substr($word, $i, 1));
  46. if ($width + $wordwidth <= $maxwidth) {
  47. $width += $wordwidth;
  48. $text .= substr($word, $i, 1);
  49. } else {
  50. $width = $wordwidth;
  51. $text = rtrim($text) . "\n" . substr($word, $i, 1);
  52. $count++;
  53. }
  54. }
  55. } elseif ($width + $wordwidth <= $maxwidth) {
  56. $width += $wordwidth + $space;
  57. $text .= $word . ' ';
  58. } else {
  59. $width = $wordwidth + $space;
  60. $text = rtrim($text) . "\n" . $word . ' ';
  61. $count++;
  62. }
  63. }
  64. $text = rtrim($text) . "\n";
  65. $count++;
  66. }
  67. $text = rtrim($text);
  68. return $count;
  69. }
  70. //Entête de page
  71. function Header() {
  72. $Image41 = 'logo/' . $_SESSION["syndicat"] . "." . $_SESSION['logo'];
  73. $this->Image($Image41, 139, 25, 47, 22);
  74. //Employeur
  75. $x1 = 119;
  76. $x2 = 159;
  77. $x3 = 160;
  78. //Employeur
  79. $this->SetXY($x1, 54);
  80. $this->SetFont('Times', 'BU', 11);
  81. $etiquette64 = "Employeur";
  82. $this->Cell(52, 6, $etiquette64, 0, 0, 'L');
  83. $this->SetXY($x1, 60);
  84. $this->SetFont('Times', '', 11);
  85. $this->Cell(70, 5, $this->NomContact, 0, 0, 'L');
  86. $this->SetXY($x1, 65);
  87. $this->SetFont('Times', '', 11);
  88. $this->Cell(91, 5, $this->Dept, 0, 0, 'L');
  89. $this->SetXY($x1, 70);
  90. $this->SetFont('Times', '', 11);
  91. $this->Cell(91, 5, $this->NomEmployeur, 0, 0, 'L');
  92. $this->SetXY($x1, 75);
  93. $this->SetFont('Times', '', 11);
  94. $this->Cell(91, 5, $this->EmployeursAdresse1, 0, 0, 'L');
  95. $this->SetXY($x1, 80);
  96. $this->SetFont('Times', '', 11);
  97. $this->Cell(37, 5, $this->EmployeursVille, 0, 0, 'L');
  98. $this->SetXY($x2, 80);
  99. $this->SetFont('Times', '', 11);
  100. $this->Cell(30, 5, $this->EmployeursCodePostal, 0, 0, 'L');
  101. $this->SetXY($x3, 90);
  102. $this->SetFont('Times', '', 11);
  103. $this->Cell(28, 5, $this->DateDemande, 0, 0, 'L');
  104. //étiquette de détail
  105. $this->SetXY(119, 90);
  106. $this->SetFont('Times', 'B', 11);
  107. $DateDemande_etiquette = "Date de la demande :";
  108. $this->Cell(28, 5, $DateDemande_etiquette, 0, 0, 'L');
  109. $this->SetXY(25, 90);
  110. $this->SetFont('Times', 'B', 11);
  111. $etiquette46 = mb_convert_encoding("LA(LES) LIBÉRATION(S) SYNDICALE(S)", 'ISO-8859-1', 'UTF-8');
  112. $this->Cell(67, 6, $etiquette46, 0, 0, 'L');
  113. $this->SetXY(25, 95);
  114. $this->SetFont('Times', 'BU', 11);
  115. $etiquette56 = "DATE(S)";
  116. $this->Cell(16, 6, $etiquette56, 0, 0, 'L');
  117. $this->SetXY(64, 95);
  118. $this->SetFont('Times', 'BU', 11);
  119. $etiquette57 = "ARTICLE";
  120. $this->Cell(20, 6, $etiquette57, 0, 0, 'L');
  121. $this->SetXY(46, 95);
  122. $this->SetFont('Times', 'BU', 11);
  123. $etiquette59 = mb_convert_encoding("DURÉE", 'ISO-8859-1', 'UTF-8');
  124. $this->Cell(16, 6, $etiquette59, 0, 0, 'L');
  125. $this->SetXY(86, 95);
  126. $this->SetFont('Times', 'BU', 11);
  127. $etiquette71 = "LIEU";
  128. $this->Cell(20, 6, $etiquette71, 0, 0, 'L');
  129. $this->SetXY(119, 95);
  130. $this->SetFont('Times', 'BU', 11);
  131. $etiquette58 = "COMMENTAIRES";
  132. $this->Cell(29, 6, $etiquette58, 0, 0, 'L');
  133. //Employé
  134. $this->SetXY(25, 54);
  135. $this->SetFont('Times', 'BU', 11);
  136. $etiquette65 = mb_convert_encoding("Employé", 'ISO-8859-1', 'UTF-8');
  137. $this->Cell(52, 6, $etiquette65, 0, 0, 'L');
  138. $this->SetXY(25, 30);
  139. $this->SetFont('Times', 'B', 20);
  140. $this->Cell(113, 9, $this->Opr, 0, 0, 'C');
  141. $this->SetXY(25, 60);
  142. $this->SetFont('Times', '', 11);
  143. $this->Cell(60, 5, $this->NomEmploye, 0, 0, 'L');
  144. $this->SetXY(25, 65);
  145. $this->SetFont('Times', '', 11);
  146. $this->Cell(60, 5, $this->EmployesAdresse, 0, 0, 'L');
  147. $this->SetXY(25, 70);
  148. $this->SetFont('Times', '', 11);
  149. $this->Cell(59, 5, $this->VilleEmploye, 0, 0, 'L');
  150. $this->SetXY(25, 75);
  151. $this->SetFont('Times', '', 11);
  152. $etiquette66 = "Matricule :";
  153. $this->Cell(19, 5, $etiquette66, 0, 0, 'L');
  154. $this->SetXY(46, 75);
  155. $this->SetFont('Times', '', 11);
  156. $this->Cell(19, 5, $this->NumEmploye, 0, 0, 'L');
  157. $this->SetLineWidth(1);
  158. $this->Rect(25, 25, 113, 22);
  159. $this->SetY(100);
  160. }
  161. //Pied de page
  162. function Footer() {
  163. //Numéro de page
  164. //Positionnement à 1,5 cm du bas
  165. //Police Arial italique 8
  166. $this->SetY(-12);
  167. $this->SetFont('Arial', 'I', 8);
  168. $this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
  169. $etiquette52 = mb_convert_encoding($this->configCentrale["presidence_nom"] . ", " .
  170. $this->configCentrale["presidence_poste"], 'ISO-8859-1', 'UTF-8');
  171. $etiquette43 = mb_convert_encoding($this->configCentrale["syndicat_nom"], 'ISO-8859-1', 'UTF-8');
  172. $etiquette45 = mb_convert_encoding($this->configCentrale["adresse"] . ", " . $this->configCentrale["ville"] .
  173. " (" . $this->configCentrale["province"] . ") " . $this->configCentrale["codepostal"] .
  174. " Téléphone : " . str_replace(array("(", ")"), "", $this->configCentrale["telephone"]) .
  175. " Télécopieur : " . str_replace(array("(", ")"), "",
  176. $this->configCentrale["telecopieur"]), 'ISO-8859-1', 'UTF-8');
  177. $etiquette71 = mb_convert_encoding("À compléter par l'employeur et retourner par courriel à " .
  178. $this->configCentrale["courriel"], 'ISO-8859-1', 'UTF-8');
  179. // Ligne de signature
  180. $this->SetLineWidth(0);
  181. $this->Line(125, 218, 184, 218);
  182. // Nom de la personne à la présidence
  183. $this->SetXY(125, 220);
  184. $this->SetFont('Times', 'B', 9);
  185. $this->WordWrap($etiquette52, 57);
  186. $this->MultiCell(60, 4, $etiquette52);
  187. //Nom du syndicat
  188. $this->SetXY(25, 259);
  189. $this->SetFont('Times', 'B', 9);
  190. $this->Cell(160, 4, $etiquette43, 0, 0, 'C');
  191. // Adresse
  192. $this->SetXY(25, 264);
  193. $this->SetFont('Times', 'B', 9);
  194. $this->Cell(160, 4, $etiquette45, 0, 0, 'C');
  195. // Mention
  196. $this->SetXY(130, 232);
  197. $this->SetFont('Times', '', 9);
  198. $this->WordWrap($etiquette71, 38);
  199. $this->MultiCell(38, 3, $etiquette71);
  200. $this->SetLineWidth(1);
  201. $this->Line(25, 264, 184, 264);
  202. // Rectangle employeur
  203. $this->SetLineWidth(0);
  204. $this->Rect(29, 229, 145, 23);
  205. // Section employeur
  206. $this->SetXY(32, 227);
  207. $this->SetFont('Times', 'B', 9);
  208. $etiquette69 = "Section Employeur";
  209. $this->SetFillColor(255, 255, 255);
  210. $this->Cell(37, 4, $etiquette69, 0, 0, 'L', true);
  211. $this->SetXY(32, 227);
  212. $this->SetFillColor(0, 0, 0);
  213. $this->Cell(37, 4, $etiquette69, 0, 0, 'L', false);
  214. $this->SetLineWidth(0);
  215. $this->Rect(33, 234, 4, 4);
  216. // Case à cocher Acceptée
  217. $this->SetXY(41, 236);
  218. $this->SetFont('Times', 'B', 9);
  219. $etiquette73 = mb_convert_encoding("Acceptée", 'ISO-8859-1', 'UTF-8');
  220. $this->Cell(21, 4, $etiquette73, 0, 0, 'L');
  221. $this->SetLineWidth(0);
  222. $this->Rect(83, 234, 4, 4);
  223. // Case à cocher Refusée
  224. $this->SetXY(92, 235);
  225. $this->SetFont('Times', 'B', 9);
  226. $etiquette76 = mb_convert_encoding("Refusée", 'ISO-8859-1', 'UTF-8');
  227. $this->Cell(21, 4, $etiquette76, 0, 0, 'L');
  228. $this->SetLineWidth(0);
  229. $this->Line(34, 246, 66, 246);
  230. // Signature employeur
  231. $this->SetXY(38, 247);
  232. $this->SetFont('Times', 'B', 9);
  233. $etiquette78 = "Signature";
  234. $this->Cell(24, 4, $etiquette78, 0, 0, 'L');
  235. $this->SetLineWidth(0);
  236. $this->Line(75, 246, 107, 246);
  237. $this->SetXY(77, 247);
  238. $this->SetFont('Times', 'B', 9);
  239. $etiquette80 = "Date";
  240. $this->Cell(24, 4, $etiquette80, 0, 0, 'L');
  241. }
  242. }
  243. // ********************
  244. // Traitement principal
  245. // ********************
  246. //Traitement des paramètres
  247. $rlreference = antiInjection(filter_input(INPUT_GET, "lreference"));
  248. $rltypeopr = antiInjection(filter_input(INPUT_GET, "ltypeopr"));
  249. $rldatecreation = antiInjection(filter_input(INPUT_GET, "ldatecreation"));
  250. $rdatelib = antiInjection(filter_input(INPUT_GET, "datelib"));
  251. $rlarticle = antiInjection(filter_input(INPUT_GET, "larticle"));
  252. $rduree = antiInjection(filter_input(INPUT_GET, "lduree"));
  253. $rcommentaire = antiInjection(filter_input(INPUT_GET, "commentaire"));
  254. $rlieu = antiInjection(filter_input(INPUT_GET, "lieu"));
  255. $rlassumerpar = antiInjection(filter_input(INPUT_GET, "lassumerpar"));
  256. unset($sqlparam);
  257. $sqlparam["table"][] = "employes";
  258. $sqlparam["table"][] = "employeurs";
  259. $sqlparam["join"][] = "employes.refemployeur=employeurs.refemployeur";
  260. $sqlparam["champs"][] = "concat(IF(employes.presentation=-1,'Madame','Monsieur'),\" \","
  261. . "employes.prenom,\" \",employes.nomfamille) as nomemploye";
  262. $sqlparam["champs"][] = "CONCAT(employes.adresse1, if(isnull(employes.adresse2),' ',"
  263. . "CONCAT(' ',employes.adresse2))) AS adresse";
  264. $sqlparam["champs"][] = "CONCAT(employes.ville,\", \",LEFT(employes.codepostal,3),\" \","
  265. . "RIGHT(employes.codepostal,3)) as ville";
  266. $sqlparam["champs"][] = "employes.numtel";
  267. $sqlparam["champs"][] = "employes.numemploye";
  268. $sqlparam["champs"][] = "employeurs.nomemployeur";
  269. $sqlparam["champs"][] = "employeurs.nomcontact";
  270. $sqlparam["champs"][] = "employeurs.dept";
  271. $sqlparam["champs"][] = "employeurs.adresse1 as adresseemployeur";
  272. $sqlparam["champs"][] = "employes.ville as villeemployeur";
  273. $sqlparam["champs"][] = "CONCAT(LEFT(employes.codepostal,3),\" \",RIGHT(employes.codepostal,3)) as codepost2";
  274. $sqlparam["ordre"][] = "CONCAT(employes.nomfamille, ' ', employes.prenom) ASC";
  275. $sqlparam["where"][] = sprintf("refemploye=%d", $rlreference);
  276. $result = executerRequeteSql($sqlparam);
  277. unset($sqlparam);
  278. $sqlparam["table"][] = "articles";
  279. $sqlparam["champs"][] = "refarticle";
  280. $sqlparam["champs"][] = "noarticle";
  281. $sqlparam["ordre"][] = "noarticle ASC";
  282. $resultart = executerRequeteSql($sqlparam);
  283. unset($article_tab);
  284. if (isset($resultart)) {
  285. foreach ($resultart as $clef => $valeur) {
  286. $article_tab[$valeur["refarticle"]] = $valeur["noarticle"];
  287. }
  288. }
  289. unset($sqlparam);
  290. $sqlparam["table"][] = "duree";
  291. $sqlparam["champs"][] = "refduree";
  292. $sqlparam["champs"][] = "duree";
  293. $sqlparam["ordre"][] = "duree asc";
  294. $resultduree = executerRequeteSql($sqlparam);
  295. unset($duree_tab);
  296. if (isset($resultduree)) {
  297. foreach ($resultduree as $clef => $valeur) {
  298. $duree_tab[$valeur["refduree"]] = $valeur["duree"];
  299. }
  300. }
  301. //Si aucune libération, alors erreur
  302. if (!($result && is_array($result) && !empty($result))) {
  303. die("Erreur B");
  304. }
  305. //Instanciation de la classe dérivée
  306. $pdf = new PDF('P', 'mm', 'Letter');
  307. $champs = $result[0];
  308. //Info de l'employeur
  309. $pdf->NomContact = $champs["nomcontact"];
  310. $pdf->Dept = $champs["dept"];
  311. $pdf->NomEmployeur = $champs["nomemployeur"]; //2
  312. $pdf->EmployeursAdresse1 = stripslashes($champs["adresseemployeur"]); //3
  313. $pdf->EmployeursVille = $champs["villeemployeur"]; //4
  314. $pdf->EmployeursCodePostal = $champs["codepost2"]; //5
  315. //Info de l'employé
  316. $pdf->NumEmploye = mb_convert_encoding($champs["numemploye"], 'ISO-8859-1', 'UTF-8'); //0
  317. $pdf->NomEmploye = mb_convert_encoding($champs["nomemploye"], 'ISO-8859-1', 'UTF-8'); //1
  318. $pdf->EmployesAdresse = mb_convert_encoding($champs["adresse"], 'ISO-8859-1', 'UTF-8');
  319. $pdf->VilleEmploye = mb_convert_encoding($champs["ville"], 'ISO-8859-1', 'UTF-8');
  320. $pdf->Opr = mb_convert_encoding((($rltypeopr == 1) ? "Demande" : "Annulation") .
  321. " de libération", 'ISO-8859-1', 'UTF-8');
  322. $pdf->DateDemande = mb_convert_encoding($rldatecreation, 'ISO-8859-1', 'UTF-8');
  323. $pdf->SetMargins(25, 25);
  324. $pdf->AliasNbPages();
  325. $pdf->SetFont('Times', '', 9);
  326. $pdf->AddPage();
  327. $pdf->configCentrale = buildConfigCentrale();
  328. $nombreligne = sizeof($rdatelib);
  329. for ($i = 1; $i <= $nombreligne; $i++) {
  330. $pdf->datelib = mb_convert_encoding(antiInjection($rdatelib[$i - 1]));
  331. $pdf->SetX(25);
  332. $pdf->Cell(16, 4, $pdf->datelib, 0, 0, 'L');
  333. $rduree[$i - 1] = str_replace(",", "", $rduree[$i - 1]);
  334. $pdf->duree = $duree_tab[$rduree[$i - 1]];
  335. $pdf->SetX(46);
  336. $pdf->Cell(16, 4, $pdf->duree, 0, 0, 'L');
  337. $rlarticle[$i - 1] = str_replace(",", "", $rlarticle[$i - 1]);
  338. $pdf->article = mb_convert_encoding($article_tab[$rlarticle[$i - 1]]);
  339. $pdf->SetX(64);
  340. $pdf->Cell(15, 4, $pdf->article, 0, 0, 'L');
  341. $pdf->lieu = mb_convert_encoding(stripslashes($rlieu[$i - 1]));
  342. $pdf->SetX(86);
  343. $pdf->Cell(20, 4, $pdf->lieu, 0, 0, 'L');
  344. $pdf->commentaire = mb_convert_encoding(stripslashes($rcommentaire[$i - 1]));
  345. $pdf->SetX(119);
  346. $pdf->MultiCell(84, 4, $pdf->commentaire);
  347. if ($_SESSION["syndicatnom"] == "siiieq") {
  348. $pdf->ln();
  349. }
  350. }
  351. $pdf->Output();