rapport_employes_employeur.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <?php
  2. define("LIBERATIONSWEB", 20091223);
  3. session_start();
  4. //Librairie de fonctions
  5. require_once (__DIR__ . '/vendor/autoload.php');
  6. require_once("lib/libconfig.inc.php");
  7. require_once("lib/libsession.inc.php");
  8. require_once("lib/libfonctions.inc.php");
  9. require_once("lib/libmysql.inc.php");
  10. require_once("lib/libencode.inc.php");
  11. require_once("lib/libcourriel.inc.php");
  12. require_once("lib/libliberations.inc.php");
  13. require_once("lib/libcentrale.inc.php");
  14. require_once("fpdf/fpdf.php");
  15. class PDF extends FPDF {
  16. var $NomEmploye;
  17. var $NumEmploye;
  18. var $Adresse1;
  19. var $Adresse2;
  20. var $Ville;
  21. var $CodePostal;
  22. var $NumeroTel;
  23. var $Texte17;
  24. var $Texte18;
  25. var $Nomemployeur;
  26. var $configCentrale;
  27. function WordWrap(&$text, $maxwidth) {
  28. $text = trim($text);
  29. if ($text === '')
  30. return 0;
  31. $space = $this->GetStringWidth(' ');
  32. $lines = explode("\n", $text);
  33. $text = '';
  34. $count = 0;
  35. foreach ($lines as $line) {
  36. $words = preg_split('/ +/', $line);
  37. $width = 0;
  38. foreach ($words as $word) {
  39. $wordwidth = $this->GetStringWidth($word);
  40. if ($wordwidth > $maxwidth) {
  41. // Word is too long, we cut it
  42. for ($i = 0; $i < strlen($word); $i++) {
  43. $wordwidth = $this->GetStringWidth(substr($word, $i, 1));
  44. if ($width + $wordwidth <= $maxwidth) {
  45. $width += $wordwidth;
  46. $text .= substr($word, $i, 1);
  47. } else {
  48. $width = $wordwidth;
  49. $text = rtrim($text) . "\n" . substr($word, $i, 1);
  50. $count++;
  51. }
  52. }
  53. } elseif ($width + $wordwidth <= $maxwidth) {
  54. $width += $wordwidth + $space;
  55. $text .= $word . ' ';
  56. } else {
  57. $width = $wordwidth + $space;
  58. $text = rtrim($text) . "\n" . $word . ' ';
  59. $count++;
  60. }
  61. }
  62. $text = rtrim($text) . "\n";
  63. $count++;
  64. }
  65. $text = rtrim($text);
  66. return $count;
  67. }
  68. //Entête de page
  69. function Header() {
  70. $this->SetXY(26, 49);
  71. $this->SetFont('Times', 'BI', 11);
  72. $NomEmploye_etiquette = mb_convert_encoding("Employé", 'ISO-8859-1', 'UTF-8');
  73. $this->Cell(44, 5, $NomEmploye_etiquette, 0, 0, 'L');
  74. $this->SetXY(73, 49);
  75. $this->SetFont('Times', 'BI', 11);
  76. $NumEmploye_etiquette = mb_convert_encoding("Employé #", 'ISO-8859-1', 'UTF-8');
  77. $this->Cell(21, 5, $NumEmploye_etiquette, 0, 0, 'L');
  78. $this->SetXY(96, 49);
  79. $this->SetFont('Times', 'BI', 11);
  80. $Adresse1_etiquette = "Adresse";
  81. $this->Cell(70, 5, $Adresse1_etiquette, 0, 0, 'L');
  82. $this->SetXY(168, 49);
  83. $this->SetFont('Times', 'BI', 11);
  84. $Ville_etiquette = "Ville";
  85. $this->Cell(36, 5, $Ville_etiquette, 0, 0, 'L');
  86. $this->SetXY(206, 49);
  87. $this->SetFont('Times', 'BI', 11);
  88. $CodePostal_etiquette = "Code postal";
  89. $this->Cell(18, 5, $CodePostal_etiquette, 0, 0, 'L');
  90. // Ancien 216 -> 226
  91. $this->SetXY(226, 49);
  92. $this->SetFont('Times', 'BI', 11);
  93. $NumeroTel_etiquette = mb_convert_encoding("Téléphone", 'ISO-8859-1', 'UTF-8');
  94. $this->Cell(27, 5, $NumeroTel_etiquette, 0, 0, 'L');
  95. $this->SetLineWidth(1);
  96. $this->Line(25, 56, 243, 56);
  97. $this->SetXY(25, 26);
  98. $this->SetFont('Times', 'BI', 20);
  99. $etiquette16 = mb_convert_encoding("Liste des employés par employeur", 'ISO-8859-1', 'UTF-8');
  100. $this->Cell(119, 8, $etiquette16, 0, 0, 'L');
  101. $Image21 = 'logo/' . $_SESSION["syndicat"] . "." . $_SESSION['logo'];
  102. $this->Image($Image21, 197, 25, 47, 22);
  103. $this->SetXY(25, 37);
  104. $this->SetFont('Times', 'B', 14);
  105. $etiquette17 = "Nom de l'employeur : " . mb_convert_encoding($this->Nomemployeur, 'ISO-8859-1', 'UTF-8');
  106. $this->Cell(119, 8, $etiquette17, 0, 0, 'L');
  107. $this->SetY(58);
  108. }
  109. //Pied de page
  110. function Footer() {
  111. //Numéro de page
  112. //Positionnement à 1,5 cm du bas
  113. //Police Arial italique 8
  114. $this->SetY(-10);
  115. $this->SetFont('Arial', 'I', 8);
  116. $this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
  117. $this->SetLineWidth(0);
  118. $this->Line(26, 205, 244, 205);
  119. $etiquette43 = $this->configCentrale["syndicat_nom"];
  120. $etiquette45 = $this->configCentrale["adresse"] . ", " . $this->configCentrale["ville"] .
  121. " (" . $this->configCentrale["province"] . ") " . $this->configCentrale["codepostal"] .
  122. " Téléphone : " . str_replace(array("(", ")"), "", $this->configCentrale["telephone"]) .
  123. " Télécopieur : " . str_replace(array("(", ")"), "", $this->configCentrale["telecopieur"]);
  124. $this->SetXY(25, 201);
  125. $this->SetFont('Times', 'B', 9);
  126. $this->Cell(219, 4, mb_convert_encoding($etiquette43, 'ISO-8859-1', 'UTF-8'), 0, 0, 'C');
  127. $this->SetXY(25, 205);
  128. $this->SetFont('Times', 'B', 9);
  129. $this->Cell(219, 4, mb_convert_encoding($etiquette45, 'ISO-8859-1', 'UTF-8'), 0, 0, 'C');
  130. }
  131. }
  132. $i = 0;
  133. unset($sqlparam);
  134. $sqlparam["table"][] = "employes";
  135. $sqlparam["table"][] = "employeurs";
  136. $sqlparam["join"][] = "employes.refemployeur=employeurs.refemployeur";
  137. $sqlparam["champs"][] = "CONCAT(employes.nomfamille,', ',employes.prenom) as nomemploye";
  138. $sqlparam["champs"][] = "CONCAT(employes.adresse1, if(isnull(employes.adresse2),' ',"
  139. . "CONCAT(' ',employes.adresse2))) AS adresse";
  140. $sqlparam["champs"][] = "employes.ville";
  141. $sqlparam["champs"][] = "CONCAT(LEFT(employes.codepostal,3),\" \",RIGHT(employes.codepostal,3)) as codepost";
  142. $sqlparam["champs"][] = "employes.numtel";
  143. $sqlparam["champs"][] = "employes.numemploye";
  144. $sqlparam["champs"][] = "employeurs.nomemployeur";
  145. $sqlparam["ordre"][] = "CONCAT(employes.nomfamille, 's ', employes.prenom) ASC";
  146. // Titre
  147. $rapport_source = "rapport_employes_employeur";
  148. require("lib/librapports.inc.php");
  149. $result = executerRequeteSql($sqlparam);
  150. // ****************************************************
  151. // Vérification de la présence de détails dans la liste
  152. // ****************************************************
  153. if (!($result && is_array($result) && !empty($result))) {
  154. print"<center>Aucun employé pour cet employeur!";
  155. print "<br>";
  156. print "<input type='button' onclick='javascript:window.close();' value='Fermer'></center>";
  157. die();
  158. }
  159. //Instanciation de la classe dérivée
  160. $pdf = new PDF('L', 'mm', 'Letter');
  161. $pdf->Nomemployeur = $result[0]["nomemployeur"];
  162. $pdf->SetMargins(25, 25);
  163. $pdf->AliasNbPages();
  164. $pdf->SetFont('Times', '', 9);
  165. $pdf->AddPage();
  166. $pdf->configCentrale = buildConfigCentrale();
  167. foreach ($result as $clef => $champs) {
  168. $pdf->NomEmploye = mb_convert_encoding($champs["nomemploye"], 'ISO-8859-1', 'UTF-8'); //0
  169. $pdf->NumEmploye = mb_convert_encoding($champs["numemploye"], 'ISO-8859-1', 'UTF-8'); //1
  170. $pdf->Adresse = mb_convert_encoding($champs["adresse"], 'ISO-8859-1', 'UTF-8'); //2
  171. $pdf->Ville = mb_convert_encoding(substr($champs["ville"], 0, 20), 'ISO-8859-1', 'UTF-8'); //3
  172. $pdf->CodePostal = mb_convert_encoding($champs["codepost"], 'ISO-8859-1', 'UTF-8'); //4
  173. $pdf->NumeroTel = mb_convert_encoding(formatPhone($champs["numtel"]), 'ISO-8859-1', 'UTF-8'); //5
  174. $pdf->SetX(26);
  175. $pdf->SetFont('Times', '', 8);
  176. $pdf->Cell(44, 4, $pdf->NomEmploye, 0, 0, 'L');
  177. $pdf->SetX(72);
  178. $pdf->SetFont('Times', '', 8);
  179. $pdf->Cell(21, 4, $pdf->NumEmploye, 0, 0, 'L');
  180. $pdf->SetX(95);
  181. $pdf->SetFont('Times', '', 8);
  182. $pdf->Cell(52, 4, $pdf->Adresse, 0, 0, 'L');
  183. $pdf->SetX(167);
  184. $pdf->SetFont('Times', '', 8);
  185. $pdf->Cell(36, 4, $pdf->Ville, 0, 0, 'L');
  186. $pdf->SetX(205);
  187. $pdf->SetFont('Times', '', 8);
  188. $pdf->Cell(18, 4, $pdf->CodePostal, 0, 0, 'L');
  189. $pdf->SetX(225);
  190. $pdf->SetFont('Times', '', 8);
  191. $pdf->Cell(27, 4, $pdf->NumeroTel, 0, 0, 'L');
  192. $pdf->Ln();
  193. }
  194. $pdf->Output();