8795 sujets

Développement web côté serveur, CMS

Bonjour,
J'ai un script php qui me permet de générer un pdf, quand je l'utilise dans Firefox j'ai un double appel de la page, je n'est pourtant pas de CSS, IMG et aucun lien vide dans mon script...

<?php 
session_start() ; 
if(!isset($_SESSION["email"]) || $_SESSION["status_admin"] == "0")
{	
  header("Location: /index.php");
  exit();
}

if (isset($_GET["status_commande"]))
{
	$status_commande= $_GET["status_commande"];
	$num_commande = $_GET["num_commande"];
	$num_client = $_GET["num_client"];
	
	include ('../include/connect.php');	
	$sql_info_client = "SELECT * FROM client WHERE num_client = '".$num_client."'";
	$req_info_client = mysql_query($sql_info_client) or die('Erreur SQL !<br>'.$sql_info_client.'<br>'.mysql_error());
	$data = mysql_fetch_array($req_info_client);
	
	if($status_commande == "1")
	{		
		/////////////////////////////// MAIL pour commande en preparation ///////////////////////////////////////
		 $to      = $data['email'];
		 $subject = 'Commande Print : N° '.$num_commande.'';
		 $message = 'Cher/e '.$data['prenom'].' '.$data['nom'].', votre commande est en cours de réalisation'.'\r\n';
		 $message .= '';
		 $message = wordwrap($message, 70);
		 $headers = 'From: service@print.be' . "\r\n" .
		 'Reply-To: webmaster@print.be' . "\r\n" .
		 'X-Mailer: PHP/' . phpversion();
		 
		if(mail($to, $subject, $message, $headers))
		{
			$sql = "UPDATE `commande` SET `status_commande` = 2 WHERE `num_commande` = '$num_commande';";
			$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());	
			header("Location: commande_client_details.php?num_commande=$num_commande&num_client=$num_client");	
			exit();
		}
		else
		{
			header("Location: commande_client_details.php?num_commande=$num_commande&num_client=$num_client&mail=no");
			exit();
		} 
		
		
	}
	elseif($status_commande == "2")
	{
		/////////////////////////////// generation facture ///////////////////////////////////////
		require('facture/tfpdf.php');
		
		if(isset($_GET['num_commande']))
		{
			$num_commande = $_GET['num_commande'];
			$num_client = $_GET['num_client'];
			
			//generation du num de facturée
			$result_commande_livrer = mysql_query('SELECT * FROM commande WHERE status_commande = 3');  	
			if (!$result_commande_livrer) 
			{
				die('Impossible d\'exécuter la requête :' . mysql_error());
			}
			$total_commande_livrer = mysql_num_rows($result_commande_livrer);
			$num_facture = 20110001 + $total_commande_livrer;
				
			//insertion dans la db facture du num_client, num_commande et generation du num de facture
			$sql = "INSERT INTO facture (num_commande,num_client,num_facture,status) VALUES	('$num_commande','$num_client','$num_facture','')";
		    $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
			
			$result_info_commande = mysql_query('SELECT * FROM commande WHERE num_commande = '.$num_commande.'');
			if (!$result_info_commande) 
			{
				die('Impossible d\'exécuter la requête :' . mysql_error());
			}
			$data_commande = mysql_fetch_array($result_info_commande);
			
			$result_info_client = mysql_query('SELECT * FROM client WHERE num_client = '.$num_client.'');
			if (!$result_info_client) 
			{
				die('Impossible d\'exécuter la requête :' . mysql_error());
			}
			$data_client = mysql_fetch_array($result_info_client);
			
			$pdf=new tFPDF();
			$pdf->SetMargins(20,20);
			$pdf->AddPage();
			$pdf->Image('facture/img/logo_print.png',140,20,50);
			
			$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
			$pdf->SetFont('DejaVu','',14);
			$pdf->Cell(85,10,'Facture N° : '.$num_facture.'');
			$pdf->Ln();
			
			$pdf->SetFont('Arial','B',12);
			$pdf->Cell(85,3,'Date: '.$data_commande['date'].'',0,1);
			$pdf->Ln();
			
			$pdf->Cell(85,40);
			$pdf->Ln();
			
			$pdf->SetFont('Arial','B',12);
			$pdf->Cell(85,3,'De Print',0,1);
			$pdf->Ln();
			
			$pdf->SetFont('DejaVu','',10);
			$pdf->MultiCell(85,5,'45, rue royale
7500 Tournai
Belgique
N° TVA BE8154568464
facture@anyprint.be',0,1);
			
			
			$pdf->SetXY(120,77);
			$pdf->SetFont('Arial','B',12);
			$pdf->Cell(85,3,'Client : '.$data_commande['num_client'].'',0,1);
			$pdf->Ln();
			
			$pdf->SetX(120);
			$pdf->SetFont('DejaVu','',10);
			if($data_client["adresse_choisi"] == "0")
			{
			$pdf->MultiCell(85,5,''.$data_client['nom'].' '.$data_client['prenom'].'
'.$data_client["adresse_facturation"].'
'.$data_client["adresse_facturation_2"].'
'.$data_client["codepostal_facturation"].' '.$data_client["ville_facturation"].'
'.$data_client["pays_facturation"].'
Téléphone: '.$data_client['telephone'].'

Email: '.$data_client['email'].'
N° de TVA: '.$data_client['tva_facturation'].'',0,1);
			}
			else
			{
				$pdf->MultiCell(85,5,''.$data_client['nom'].' '.$data_client['prenom'].'
'.$data_client["adresse_societe"].'
'.$data_client["adresse_societe_2"].'
'.$data_client["codepostal_societe"].' '.$data_client["ville_societe"].'
'.$data_client["pays_societe"].'
Téléphone: '.$data_client['telephone'].'

Email: '.$data_client['email'].'
N° de TVA: '.$data_client['tva_facturation'].'',0,1);
			}
			$pdf->Ln();
			
			$pdf->SetFont('Arial','B',11);
			$pdf->Cell(85,3,'Paiement',0,1);
			$pdf->Ln();
			
			$pdf->SetFont('DejaVu','',10);
			$pdf->Cell(85,3,'Effectué le '.$data_commande['date'].' a '.$data_commande['heure'].'',0,1);
			
			//titre recap
			$pdf->SetXY(40,156);
			$pdf->SetFont('Arial','',10);
			$pdf->Cell(50,3,'Produit',0,1);
			
			$pdf->SetXY(100,156);
			$pdf->SetFont('Arial','',10);
			$pdf->Cell(50,3,'Description',0,1);
			
			$pdf->SetXY(165,156);
			$pdf->SetFont('Arial','',10);
			$pdf->Cell(50,3,'Prix',0,1);
			
			// ligne 1
			$pdf->Line(20,160,190,160);
			
			// recap
			$pdf->SetXY(30,165);
			$pdf->SetFont('Arial','',10);
			$pdf->Cell(50,3,'Flyers',0,1);
			
			$pdf->SetXY(90,165);
			$pdf->SetFont('DejaVu','',9);
			$pdf->MultiCell(50,4,'Grammage : '.$data_commande['grammage'].'
Format : '.$data_commande['format'].'
Impression : '.$data_commande['impression'].'
Pelliculage : '.$data_commande['pelliculage'].'
Finition : '.$data_commande['finition'].'
Quantité : '.$data_commande['quantite'].'
Livrer en : '.$data_commande['delais'].' jours',0,1);
			
			$pdf->SetXY(160,165);
			$pdf->SetFont('DejaVu','',10);
			$pdf->Cell(50,3,'125,00 €',0,1);
			
			//ligne 2
			$pdf->Line(20,198,190,198);
			
			$pdf->SetXY(150,205);
			$pdf->SetFont('DejaVu','',10);
			$pdf->Cell(50,3,'Prix HT : 125,00 €',0,1);
			
			$pdf->SetXY(148,210);
			$pdf->SetFont('DejaVu','',10);
			$pdf->Cell(50,3,'Prix TTC :',0,1);
			
			$pdf->SetXY(165,210);
			$pdf->SetFont('DejaVu','',10);
			$pdf->Cell(50,3,'145,00 €',0,1);
			
			//footer
			$pdf->SetY(270);
			$pdf->SetFont('DejaVu','',10);
			$pdf->Cell(170,3,'www.print.com',0,1,'C');
			
			$pdf->Output('facture/facture_all/Facture-'.$num_facture.'.pdf','F');
			$pdf->Close();
		}
		else
		{
			header("Location: admin/facture_client_all.php");
			exit();
		}

		
		/////////////////////////////// MAIL pour commande livrer ///////////////////////////////////////
		$to      = $data['email'];
		$subject = 'Commande Print : N° '.$num_commande.'';
		$message = 'Cher/e '.$data['prenom'].' '.$data['nom'].', commande livrer'.'\r\n';
		$message .= '';
		$message = wordwrap($message, 70);
		$headers = 'From: service@print.be' . "\r\n" .
		'Reply-To: webmaster@print.be' . "\r\n" .
		'X-Mailer: PHP/' . phpversion();
		// si mail envoyer, on update le champ status commande
		if(mail($to, $subject, $message, $headers))
		{
			$sql = "UPDATE `commande` SET `status_commande` = 3 WHERE `num_commande` = '$num_commande';";
			$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());	
			header("Location: commande_client_details.php?num_commande=$num_commande&num_client=$num_client");
			exit();
		}
		// Sinon mail pas envoyer, mail=no
		else
		{
			header("Location: commande_client_details.php?num_commande=$num_commande&num_client=$num_client&mail=no");
			exit();
		} 
	}
	else
	{
		header("Location: commande_client_details.php?num_commande=$num_commande&num_client=$num_client");
		exit();
	}
	mysql_close(); 	
}
else
{
	header("Location: commande_client_all.php");
	exit();
}	
?>


Merci d'avance
Modifié par Fz3ro (31 Jan 2011 - 16:04)