Alors je continu à bosser sur mes satané étiquette et j ai un nouveau début de résultat.
Donc en gros je pense que c'est bien ca, je dois me débrouiller avec des compteurs et des IF.
Voici mon dernier résultat qui me remplit bien toute mes cases comme il faut mais seul hic qui est d'ailleurs trés logiques (vous allez voir dans le code), mon premier patient ce répéte 3 fois sur la premiére ligne, le deuxiéme patient ce répéte 3 fois sur la deuxiéme ligne .....
Voici le code :
<?php
define('FPDF_FONTPATH','font/');
require('fpdf.php');
//Connect to your database
include("connec_pharma.php");
//Create new pdf file
$pdf=new FPDF('P','mm','A4');
//Open file
$pdf->Open();
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 8;
$y_axis = 8;
//Select the Products you want to show in your PDF file
//$result=mysql_query("SELECT idpat,ordo_num FROM ordonnance GROUP BY ordo_num");
$result=mysql_query("SELECT nompatient,ordo_num FROM patient AS p, ordonnance AS o WHERE p.numpatient = o.idpat GROUP BY ordo_num");
mysql_select_db('pharmacie') or die(mysql_error());
$resultfin = mysql_query($result);
//initialize counter ligne
$i = 0;
//initialize counter cols
$cptcol = 0;
//Set maximum rows per page
$max = 8;
//Set maximim cols per page
$maxcol = 3;
//Set Row Height
$row_height = 35;
//Set Cols Width
$cols_width = 70;
while($row = mysql_fetch_array($result))
{
//If the current row is the last one, create new page and print column title
if ($i == $max)
{
$pdf->AddPage();
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
if ($cptcol == 0)
{
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$cptcol = $cptcol + 1;
}
if ($cptcol == 1)
{
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis);
$pdf->SetX(78);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(78);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$cptcol = $cptcol + 1;
}
if ($cptcol == 2)
{
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis);
$pdf->SetX(148);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(148);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
$cptcol = 0;
}
}
//Create file
$pdf->Output();
?>
Encore une fois je suis conscient que le résultat affiché (la redondance est logique) mais j'essaye depuis 3 Hrs de modifier cela sans la redondance mais j'y arrive pas.
Ma logique (ca doit pas être logique) :
J'incrémente à la base un compteur $cptcol avec 0
SI $cptcol = à 0 alors on traite le SetX() normalement soit avec 8 (ce qui veux dire à 80 mm de la page)
la variable $cptcol prend +1
SI $cptcol = 1 alors la variable $cols_width prend 70
on traite le SetX() avec 8 + $cols_width
Si $cptcol = 2 alors la variable $cols_width prend 140
on traite le SetX() avec 8 + $cols_width
Si $cptcol = 3 on saute la ligne
$cptcol prend 0 et on recommence....
Voila en français je pense que c'est viable mais en PHP j'arrive pas à le transcrire et bien placer dans mon code.
Voici tout de même le code de mon essai :
<?php
//PDF USING MULTIPLE PAGES
//FILE CREATED BY: Carlos José Vásquez Sáez
//YOU CAN CONTACT ME: [email protected]
//FROM PUNTA ARENAS, MAGALLANES
//INOVO GROUP - http://www.inovo.cl
define('FPDF_FONTPATH','font/');
require('fpdf.php');
//Connect to your database
include("connec_pharma.php");
//Create new pdf file
$pdf=new FPDF('P','mm','A4');
//Open file
$pdf->Open();
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 8;
$y_axis = 8;
//Select the Products you want to show in your PDF file
//$result=mysql_query("SELECT idpat,ordo_num FROM ordonnance GROUP BY ordo_num");
$result=mysql_query("SELECT nompatient,ordo_num FROM patient AS p, ordonnance AS o WHERE p.numpatient = o.idpat GROUP BY ordo_num");
mysql_select_db('pharmacie') or die(mysql_error());
$resultfin = mysql_query($result);
//initialize counter ligne
$i = 0;
//initialize counter cols
$cptcol = 0;
//Set maximum rows per page
$max = 8;
//Set maximim cols per page
$maxcol = 3;
//Set Row Height
$row_height = 35;
//Set Cols Width
$cols_width = 0;
while($row = mysql_fetch_array($result))
{
//If the current row is the last one, create new page and print column title
if ($i == $max)
{
$pdf->AddPage();
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
if (cptcol == 1)
{
$cols_width = 70;
$cptcol = $cptcol + 1;
}
if (cptcol == 2)
{
$cols_width = 140;
$cptcol = $cptcol + 1;
}
$cols_width = 1;
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis);
$pdf->SetX(8 + $cols_width);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(8 + $cols_width);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
//Create file
$pdf->Output();
?>
VOili Voilou je need à mort un petit coup de pouce sur cela je vous en serez trés reconnaissant. Merci d'avance.