rapport_employes_croissant.php 7.5 KB

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