bonjour,

j'apprends à utiliser tcpdf pour générer mes rapport. Un ami m'a aidé à monter le script ci-dessous qui affiche les implantations des point de vente par Zone ( A,B,...Z). ce script affiche donc un état PDF par zone de A à Z avec saut de page après chaque zone. l'affichage est sans problème. Voici ce script TCPDF:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
 
<?php 
 
	include '../function/configConnexion.php';
 
	@session_start();
 
	if (!isset($_SESSION['cusr']))
 
	{
 
		header("Location:../index.php");		
 
	}
 
	//updateHistorique($_SESSION['cusr'],"Impression de la liste des  mouvements de stock");
 
// Include the main TCPDF library (search for installation path).
// Include the main TCPDF library (search for installation path).
require_once('tcpdf/examples/config/tcpdf_config_alt.php');
require_once('tcpdf/tcpdf.php');
 
 
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
 
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Félix');
$pdf->SetTitle('Etat des implantations par zone');
$pdf->SetSubject('Rapport');
$pdf->SetKeywords('Felix, PMUC');
 
// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING);
 
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
 
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
 
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
 
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
 
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
 
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
	require_once(dirname(__FILE__).'/lang/eng.php');
	$pdf->setLanguageArray($l);
}
 
// ---------------------------------------------------------
 
// set font
$pdf->SetFont('dejavusans', '', 10);
 
// add a page
$pdf->AddPage();
 
$html = '<h1 style="text-align:center">ETAT DES IMPLANTATIONS</h1><br/><br/>';
$pdf->writeHTML($html, true, false, true, false, '');
 
$reqq = "SELECT * FROM region WHERE idRegion='$_GET[region1]' ";
$rss = mysql_query($reqq);$i=1;
while ($lignee = mysql_fetch_array($rss))
 
{        
 
	extract($lignee);
 
}
 
 
 
$req = "SELECT  pointcourse.*,affectation.*,kiosque.* ,zone.libelle as libel,nomVille FROM zone, kiosque, affectation,ville, pointcourse 
WHERE zone.idVille=ville.idVille and affectation.idKiosque=kiosque.idKiosque and affectation.idpointCourse=pointcourse.idpointCourse and  datefin ='0000-00-00' 
and affectation.idVille in ( select idVille from ville where region='$_GET[region1]') 
and pointcourse.idzone=zone.idZone order by libel ,codeKiosque,libelle asc  " ;
 
$rs = mysql_query($req);$i=1;$position=0;
$zone = ""; $text = ""; $html = "";
while ($ligne = mysql_fetch_array($rs))
 
{        
	extract($ligne);
 
	if ($position==0) {
		$zone = $libel;
	}
 
 
	if ($zone!=$libel) {
		$zone = $libel;
		$html = '<table width="100%" border="1" cellpadding="2" cellspacing="0">
				  <tr>
					<td colspan="7" align="center">'. $nomRegion.'</td>
				  </tr>
				  <tr>
					<td width="5%" align="center" bgcolor="#E561A0">Line</td>
					<td width="6%" align="center" bgcolor="#E561A0">Kiosq</td>
					<td width="6%" align="center" bgcolor="#E561A0">Color</td>
					<td width="37%" align="center" bgcolor="#E561A0">Point course</td>
					<td width="13%" align="center" bgcolor="#E561A0">Dépot</td>
					<td width="5%" align="center" bgcolor="#E561A0">Zne</td>
					<td width="13%" align="center" bgcolor="#E561A0">Ville</td>
					<td width="15%" align="center" bgcolor="#E561A0">Palette</td>
				  </tr>'.$text.'
			  <tr>
				<td colspan="7" align="center">Total : '.($i-1).'</td>
			  </tr>
			</table>';
 
			// output the HTML content
			$pdf->writeHTML($html, true, false, true, false, ''); // ecriture de texte dans le document PDF
			$text = ""; $html = "";
			$i = 1;
 
 
			/*******SAUT DE PAGE *****/
			// reset pointer to the last page
			$pdf->lastPage();
 
			// add a page
			$pdf->AddPage();
 
			/*******FIN SAUT DE PAGE *****/
	}
 
		$text .= '<tr>
		<td>'.$i.'</td>
		<td>'.$codeKiosque.'</td>
		<td>'.$couleur.'</td>
		<td>'.$libelle.'</td>
		<td>'.$dateAffect.'</td>
		<td>'.$libel.'</td>
		<td>'.$nomVille.'</td>
		<td>'.$palette.'</td>
	  </tr>
	 ';
	$i++;$position=1;
}
 
 
$pdf->writeHTML('<table width="100%" border="1" cellpadding="2" cellspacing="0">
				  <tr>
					<td colspan="7" align="center">'.$nomRegion.'</td>
				  </tr>
				  <tr>
					<td width="5%" align="center" bgcolor="#E561A0">Line</td>
					<td width="6%" align="center" bgcolor="#E561A0">Kiosq</td>
					<td width="6%" align="center" bgcolor="#E561A0">Color</td>
					<td width="37%" align="center" bgcolor="#E561A0">Point course</td>
					<td width="13%" align="center" bgcolor="#E561A0">Dépot</td>
					<td width="5%" align="center" bgcolor="#E561A0">Zne</td>
					<td width="13%" align="center" bgcolor="#E561A0">Ville</td>
					<td width="15%" align="center" bgcolor="#E561A0">Palette</td>
				  </tr>'.$text.' <tr>
						<td colspan="7" align="center">Total : '.($i-1).'</td>
					  </tr>
			</table>', true, false, true, false, '');
 
 
// ---------------------------------------------------------
 
//Close and output PDF document
$pdf->Output('etat_implantation.pdf', 'I');
 
//============================================================+
// END OF FILE
//============================================================+
 
?>

J'ai voulu recycler ce script pour afficher en PDF, les réparations des kiosques par mois avec saut de page par mois 10, mois 11 et mois 12. Dans ma table, les réparations ont été effectuées du mois d'octobre au mois de décembre 2015. voici donc le nouveau script:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
 
 <?php
 
   include '../function/configConnexion.php';
 
   @session_start();
 
   if (!isset($_SESSION['cusr']))
 
   {
 
      header("Location:../index.php");      
 
   }
 
   //updateHistorique($_SESSION['cusr'],"Impression de la liste des  mouvements de stock");
 
// Include the main TCPDF library (search for installation path).
// Include the main TCPDF library (search for installation path).
require_once('tcpdf/examples/config/tcpdf_config_alt.php');
require_once('tcpdf/tcpdf.php');
 
 
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
 
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Félix');
$pdf->SetTitle('Etat des implantations par zone');
$pdf->SetSubject('Rapport');
$pdf->SetKeywords('Felix, PMUC');
 
// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING);
 
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
 
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
 
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
 
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
 
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
 
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
   require_once(dirname(__FILE__).'/lang/eng.php');
   $pdf->setLanguageArray($l);
}
 
// ---------------------------------------------------------
 
// set font
$pdf->SetFont('dejavusans', '', 10);
 
// add a page
$pdf->AddPage();
 
$html = '<h1 style="text-align:center">ETAT DES POINTS COURSES</h1><br/><br/>';
$pdf->writeHTML($html, true, false, true, false, '');
 
$reqq = "SELECT * FROM region WHERE idRegion='$_GET[region1]' ";
$rss = mysql_query($reqq);$i=1;
while ($lignee = mysql_fetch_array($rss))
 
{       
 
   extract($lignee);
 
}
 
 
 
 
 
  $req = "SELECT  reparation.*,month(dateRep) as mois, codeKiosque,libelle FROM  reparation, kiosque,pointcourse where  year(dateRep)='$_GET[annee1]' and idRegion= '$_GET[region1]' and Montant>0 and reparation.idKiosque=kiosque.idKiosque and reparation.lastPc=pointcourse.idPointCourse order by dateRep asc " ;
 
$rs = mysql_query($req);$i=1;$position=0;
$zone = ""; $text = ""; $html = "";
while ($ligne = mysql_fetch_array($rs))
 
{       
   extract($ligne);
 
   if ($position==0) {
      $zone = $mois;
   }
 
 
   if ($zone!=$mois) {
      $zone = $mois;
      $html = '<table width="100%" border="1" cellpadding="2" cellspacing="0">
              <tr>
               <td colspan="7" align="center">'. $nomRegion.'</td>
              </tr>
              <tr>
             <td width="8%" height="20"  bgcolor="#E561A0" > ligne</td>
              <td width="17%" align="center" bgcolor="#E561A0" >Date</td>
              <td width="10%" align="center" bgcolor="#E561A0" >Mois</td>
              <td width="10%" align="center" bgcolor="#E561A0" >Kiosque</td>
              <td width="10%" align="center" bgcolor="#E561A0" >Montant</td>
              <td width="10%" align="center" bgcolor="#E561A0">Prestataire</td>
              <td width="35%" align="center" bgcolor="#E561A0">Dernier point course</td>
               
              </tr>'.$text.'
           <tr>
            <td colspan="7" align="center">Total : '.($i-1).'</td>
           </tr>
         </table>';
 
         // output the HTML content
         $pdf->writeHTML($html, true, false, true, false, ''); // ecriture de texte dans le document PDF
         $text = ""; $html = "";
         $i = 1;
 
 
         /*******SAUT DE PAGE *****/
         // reset pointer to the last page
         $pdf->lastPage();
 
         // add a page
         $pdf->AddPage();
 
         /*******FIN SAUT DE PAGE *****/
   }
 
      $text .= '<tr>
      <td align="center" >'.$i.'</td>
      <td align="center" >'.$dateRep.'</td>
      <td align="center">'.$mois.'</td>
      <td align="center">'.$codeKiosque.'</td>
      <td align="center" >'.$Montant.'</td>
      <td align="center" >'.$technicien.'</td>
      <td align="center" >'.$libelle.'</td>
     </tr>
    ';
   $i++;$position=1;
}
 
 
$pdf->writeHTML('<table width="100%" border="1" cellpadding="2" cellspacing="0">
              <tr>
               <td colspan="7" align="center">'.$nomRegion.'</td>
              </tr>
              <tr>
                <td width="8%" height="20"  bgcolor="#E561A0" > ligne</td>
              <td width="17%" align="center" bgcolor="#E561A0" >Date</td>
              <td width="10%" align="center" bgcolor="#E561A0" >Mois</td>
              <td width="10%" align="center" bgcolor="#E561A0" >Kiosque</td>
              <td width="10%" align="center" bgcolor="#E561A0" >Montant</td>
              <td width="10%" align="center" bgcolor="#E561A0">Prestataire</td>
              <td width="35%" align="center" bgcolor="#E561A0">Dernier point course</td>
              </tr>'.$text.' <tr>
                  <td colspan="7" align="center">Total : '.($i-1).'</td>
                 </tr>
         </table>', true, false, true, false, '');
 
 
// ---------------------------------------------------------
 
//Close and output PDF document
$pdf->Output('etat_implantation.pdf', 'I');
 
//============================================================+
// END OF FILE
//============================================================+
 
?>
Le problème est que la page qui correspond au mois 12 ne s'affiche pas avec les données , plus tot une page blanche . la première page s'affiche bien avec le mois 10, la deuxième page avec le mois 11, la 3ème page est blanche sans les données du mois 12.

ça fait 3 jours que je narrive pas à régler ce problème

Aidez moi .

Cordialement.