rapport_soldes.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 $NomEmployeur;
  18. var $DateLiberation;
  19. var $Commentaire;
  20. var $CalculDuree;
  21. var $Nombre;
  22. var $TOperation;
  23. var $NoArticle;
  24. var $Texte24;
  25. var $Texte27;
  26. var $Texte19;
  27. var $Texte20;
  28. var $syndicatnom;
  29. var $configCentrale;
  30. function WordWrap(&$text, $maxwidth) {
  31. $text = trim($text);
  32. if ($text === '')
  33. return 0;
  34. $space = $this->GetStringWidth(' ');
  35. $lines = explode("\n", $text);
  36. $text = '';
  37. $count = 0;
  38. foreach ($lines as $line) {
  39. $words = preg_split('/ +/', $line);
  40. $width = 0;
  41. foreach ($words as $word) {
  42. $wordwidth = $this->GetStringWidth($word);
  43. if ($wordwidth > $maxwidth) {
  44. // Word is too long, we cut it
  45. for ($i = 0; $i < strlen($word); $i++) {
  46. $wordwidth = $this->GetStringWidth(substr($word, $i, 1));
  47. if ($width + $wordwidth <= $maxwidth) {
  48. $width += $wordwidth;
  49. $text .= substr($word, $i, 1);
  50. } else {
  51. $width = $wordwidth;
  52. $text = rtrim($text) . "\n" . substr($word, $i, 1);
  53. $count++;
  54. }
  55. }
  56. } elseif ($width + $wordwidth <= $maxwidth) {
  57. $width += $wordwidth + $space;
  58. $text .= $word . ' ';
  59. } else {
  60. $width = $wordwidth + $space;
  61. $text = rtrim($text) . "\n" . $word . ' ';
  62. $count++;
  63. }
  64. }
  65. $text = rtrim($text) . "\n";
  66. $count++;
  67. }
  68. $text = rtrim($text);
  69. return $count;
  70. }
  71. // ****************************************************
  72. // Entête de page
  73. // ****************************************************
  74. function Header() {
  75. $Image41 = 'logo/' . $_SESSION["syndicat"] . "." . $_SESSION['logo'];
  76. $this->Image($Image41, 139, 25, 47, 22);
  77. $etiquette18 = "Compilation des soldes";
  78. $this->SetXY(26, 26);
  79. $this->SetFont('Times', 'BI', 20);
  80. $this->Cell(114, 8, $etiquette18, 0, 0, 'L');
  81. $this->SetLineWidth(1);
  82. $this->Line(25, 53, 189, 53);
  83. $this->SetXY(26, 47);
  84. $this->SetFont('Times', 'BI', 11);
  85. $NoArticle_etiquette = "Article";
  86. $this->Cell(14, 5, $NoArticle_etiquette, 0, 0, 'L');
  87. $this->SetXY(42, 47);
  88. $this->SetFont('Times', 'BI', 11);
  89. $NomEmployeur_etiquette = "Employeur";
  90. $this->Cell(40, 5, $NomEmployeur_etiquette, 0, 0, 'L');
  91. $this->SetXY(116, 45);
  92. $this->SetFont('Times', 'BI', 11);
  93. $Nombre_etiquette = "Selon la convention";
  94. $this->WordWrap($Nombre_etiquette, 22);
  95. $this->MultiCell(22, 4, $Nombre_etiquette);
  96. $this->SetXY(139, 47);
  97. $this->SetFont('Times', 'BI', 11);
  98. $calcul_etiquette = "Utilisation";
  99. $this->Cell(18, 5, $calcul_etiquette, 0, 0, 'C');
  100. $this->SetXY(160, 47);
  101. $this->SetFont('Times', 'BI', 11);
  102. $expression_etiquette = "Solde";
  103. $this->Cell(14, 5, $expression_etiquette, 0, 0, 'C');
  104. $this->SetY(55);
  105. }
  106. // ****************************************************
  107. // Pied de page
  108. // ****************************************************
  109. function Footer() {
  110. //Numéro de page
  111. //Positionnement à 1,5 cm du bas
  112. //Police Arial italique 8
  113. $this->SetY(-12);
  114. $this->SetFont('Arial', 'I', 8);
  115. $this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
  116. $etiquette43 = $this->configCentrale["syndicat_nom"];
  117. $etiquette45 = $this->configCentrale["adresse"] . ", " . $this->configCentrale["ville"] .
  118. " (" . $this->configCentrale["province"] . ") " . $this->configCentrale["codepostal"] .
  119. " Téléphone : " . str_replace(array("(", ")"), "", $this->configCentrale["telephone"]) .
  120. " Télécopieur : " . str_replace(array("(", ")"), "", $this->configCentrale["telecopieur"]);
  121. $this->SetLineWidth(0);
  122. $this->Line(25, 264, 184, 264);
  123. $this->SetXY(25, 259);
  124. $this->SetFont('Times', 'B', 9);
  125. $this->Cell(160, 4, mb_convert_encoding($etiquette43, 'ISO-8859-1', 'UTF-8'), 0, 0, 'C');
  126. $this->SetXY(25, 264);
  127. $this->SetFont('Times', 'B', 9);
  128. $this->Cell(160, 4, mb_convert_encoding($etiquette45, 'ISO-8859-1', 'UTF-8'), 0, 0, 'C');
  129. }
  130. }
  131. //Exécution de la requête SQL provenant de la compilation du solde.
  132. header('Content-Type: text/html; charset=$ENCODAGE');
  133. $connection = setConnectionSql();
  134. $sqlprinc = $_SESSION['requêteSQL'];
  135. mysqli_query($connection, "SET SQL_BIG_SELECTS=1");
  136. $result = mysqli_query($connection, "$sqlprinc") or die("La requête (3) a échouée.");
  137. //Instanciation de la classe dérivée
  138. $pdf = new PDF('P', 'mm', 'Letter');
  139. $pdf->SetMargins(25, 25);
  140. $pdf->AliasNbPages();
  141. $pdf->AddPage();
  142. $pdf->syndicatnom = $_SESSION["syndicatnom"];
  143. $pdf->configCentrale = buildConfigCentrale();
  144. $nomemploye = "";
  145. $nomemployeur = "";
  146. $calculduree = 0;
  147. $nombredeligne = 0;
  148. $calculduree2 = 0;
  149. $nombredeligne2 = 0;
  150. for ($i = 1; $i <= mysqli_num_rows($result); $i++) {
  151. $champs = mysqli_fetch_row($result);
  152. $valeur1 = $champs[1];
  153. $valeur2 = mb_convert_encoding($champs[2], 'ISO-8859-1', 'UTF-8');
  154. $valeur3 = sprintf("%1.1f", $champs[3]);
  155. $valeur4 = sprintf("%1.1f", $champs[4]);
  156. $valeur5 = sprintf("%1.1f", $champs[5]);
  157. $pdf->SetX(26);
  158. $pdf->SetFont('Times', '', 8);
  159. $pdf->Cell(14, 4, $valeur1, 0, 0, 'L');
  160. $pdf->SetX(42);
  161. $pdf->Cell(70, 4, $valeur2, 0, 0, 'L');
  162. $pdf->SetX(139);
  163. $pdf->Cell(14, 5, $valeur3, 0, 0, 'C');
  164. $pdf->SetX(116);
  165. $pdf->Cell(14, 5, $valeur4, 0, 0, 'C');
  166. $pdf->SetX(160);
  167. if ($champs[5] < 0) {
  168. $pdf->SetTextColor(255, 0, 0);
  169. }
  170. $pdf->Cell(14, 5, $valeur5, 0, 0, 'C');
  171. if ($champs[5] < 0) {
  172. $pdf->SetTextColor(0, 0, 0);
  173. }
  174. $pdf->ln();
  175. }
  176. $pdf->Output();