Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PDF Invoice


bobg7

Recommended Posts

I'm trying to get the PDF Invoice contribution to also include the customers email address and phone number. I have it partly coded to work, ie: it gives the lines 'Email Address:' and 'Phone Number:' but it's not pulling the information.

 

Here is the invoice.php I'm using:

 

<?php
/*
 $Id: create_pdf,v 1.2 2005/03/08

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2005 osCommerce

 Released under the GNU General Public License

 Written by Neil Westlake ([email protected]) for www.Digiprintuk.com
*/

define('FPDF_FONTPATH','fpdf/font/');
require('fpdf/fpdf.php');
require('includes/application_top.php');
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ORDERS_INVOICE);

require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();

include(DIR_WS_CLASSES . 'order.php');

class PDF extends FPDF
{
//Page header

function Header()
{
global $oID;
 $date = strftime('%A, %d %B %Y');
//Logo
$this->Image('images/logo1.jpg',3,10,40);

// Invoice Number and date
$this->SetFont('Arial','B',10);
$this->SetTextColor(0,102,153);
$this->SetY(37);
$this->MultiCell(50,4,"Invoice: #" . $oID . "\n" . $date ,0,'L');

// Company Address
$this->SetX(0);
$this->SetY(10);
$this->SetFont('Arial','B',10);
$this->SetTextColor(0,102,153);
$this->Ln(0);
$this->Cell(149);
$this->MultiCell(50, 3.5, STORE_NAME_ADDRESS,0,'R');

}

function Footer()
{
//Position at 1.5 cm from bottom
$this->SetY(-19);
//Arial italic 8
$this->SetFont('Arial','',12);
$this->SetTextColor(0,102,153);
$this->Cell(0,10, PRINT_INVOICE_TEXT, 0,0,'C');
$this->SetY(-15);
   $this->Cell(0,10, PRINT_INVOICE_URL, 0,0,'C');
//Page number
//$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
function RoundedRect($x, $y, $w, $h,$r, $style = '')
{
	$k = $this->k;
	$hp = $this->h;
	if($style=='F')
		$op='f';
	elseif($style=='FD' or $style=='DF')
		$op='B';
	else
		$op='S';
	$MyArc = 4/3 * (sqrt(2) - 1);
	$this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k ));
	$xc = $x+$w-$r;
	$yc = $y+$r;
	$this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k ));

	$this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
	$xc = $x+$w-$r;
	$yc = $y+$h-$r;
	$this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k));
	$this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
	$xc = $x+$r;
	$yc = $y+$h-$r;
	$this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k));
	$this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
	$xc = $x+$r;
	$yc = $y+$r;
	$this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k ));
	$this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
	$this->_out($op);
}

function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
{
	$h = $this->h;
	$this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k,
		$x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
}

}
//Instanciation of inherited class
$pdf=new PDF();

// Set the Page Margins
$pdf->SetMargins(4,2,4);

//$pdf->AliasNbPages();
while (list($key, $oID) = each($_GET)) {
if ($key == "osCAdminID")
	break;
	 $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . $oID . "'");
	 $order = new order($oID);

// Add the first page
$pdf->AddPage();

//Draw the top line with invoice text
$pdf->Cell(50);
$pdf->SetY(62);
$pdf->SetDrawColor(153,153,153);
$pdf->Cell(15,.1,'',1,1,'L',1);
$pdf->SetFont('Arial','BI',15);
$pdf->SetTextColor(153,153,153);
$pdf->Text(22,63.5,'Invoice');
$pdf->SetY(62);
$pdf->SetDrawColor(153,153,153);
$pdf->Cell(38);
$pdf->Cell(160,.1,'',1,1,'L',1);

//Draw Box for Invoice Address
$pdf->SetDrawColor(0);
$pdf->SetLineWidth(0.5);
$pdf->SetFillColor(224);
$pdf->RoundedRect(3, 67, 90, 35, 2, 'DF');

//Draw the invoice address text
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(0);
$pdf->Text(8,71, ENTRY_SOLD_TO);
$pdf->SetX(0);
$pdf->SetY(74);
//$pdf->SetFont('Arial','B',8);
//$pdf->SetTextColor(0);
$pdf->Cell(5);
$pdf->MultiCell(70, 3.3, tep_address_format(1, $order->customer, '', '', "\n"),0,'L');

//Draw Box for Delivery Address
$pdf->SetDrawColor(0);
$pdf->SetLineWidth(0.5);
$pdf->SetFillColor(255);
$pdf->RoundedRect(112, 67, 90, 35, 2, 'DF');

//Draw the invoice delivery address text
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(0);
$pdf->Text(117,71,ENTRY_SHIP_TO);
$pdf->SetX(0);
$pdf->SetY(74);
$pdf->Cell(115);
$pdf->MultiCell(50, 3.3, tep_address_format(1, $order->delivery, '', '', "\n"),0,'L');

	//Draw Box for Order Number, Date & Payment method
$pdf->SetDrawColor(0);
$pdf->SetLineWidth(0.5);
$pdf->SetFillColor(224);
$pdf->RoundedRect(3, 107, 199, 11, 2, 'DF');

//Draw Order Number Text
$temp = str_replace(' ', ' ', PRINT_INVOICE_ORDERNR);
$pdf->Text(7,113, $temp . tep_db_input($oID));

//Draw Customer Email Address
$temp = str_replace(' ', ' ', PRINT_CUSTOMERS_EMAIL_ADDRESS);
$pdf->Text(5,32,$temp . tep_db_input ($order->info['customers_email_address']));

//Draw Customer Telephone
$temp = str_replace(' ', ' ', PRINT_CUSTOMERS_TELEPHONE);
$pdf->Text(5,36,$temp . tep_db_input ($order->info['customers_telephone']));

//Draw Date of Order Text
$temp = str_replace(' ', ' ', PRINT_INVOICE_DATE);
$pdf->Text(75,113,$temp . tep_date_short($order->info['date_purchased']));

//Draw Payment Method Text
$temp = substr ($order->info['payment_method'] , 0, 23);
$pdf->Text(130,113,ENTRY_PAYMENT_METHOD . ' ' . $temp);	
//$pdf->Cell(198,29,ENTRY_PAYMENT_METHOD . ' ' . $temp, 0, 0, 'R');

//Fields Name position
$Y_Fields_Name_position = 125;
//Table position, under Fields Name
$Y_Table_Position = 131;

//First create each Field Name
//Gray color filling each Field Name box
$pdf->SetFillColor(232,232,232);
//Bold Font for Field Name
$pdf->SetFont('Arial','B',10);
$pdf->SetY($Y_Fields_Name_position);
$pdf->SetX(5);
$pdf->Cell(10,6,'Qty',1,0,'C',1);
$pdf->SetX(15);
$pdf->Cell(25,6,TABLE_HEADING_PRODUCTS_MODEL,1,0,'C',1);
$pdf->SetX(40);
$pdf->Cell(80,6,TABLE_HEADING_PRODUCTS,1,0,'C',1);
//$pdf->SetX(105);
//$pdf->Cell(15,6,TABLE_HEADING_TAX,1,0,'C',1);
$pdf->SetX(120);
$pdf->Cell(20,6,TABLE_HEADING_PRICE_EXCLUDING_TAX,1,0,'C',1);
$pdf->SetX(140);
$pdf->Cell(20,6,TABLE_HEADING_PRICE_INCLUDING_TAX,1,0,'C',1);
$pdf->SetX(160);
$pdf->Cell(20,6,TABLE_HEADING_TOTAL_EXCLUDING_TAX,1,0,'C',1);
$pdf->SetX(180);
$pdf->Cell(20,6,TABLE_HEADING_TOTAL_INCLUDING_TAX,1,0,'C',1);
$pdf->Ln();

//Show the products information line by line
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
$pdf->SetFont('Arial','',10);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(5);
$pdf->MultiCell(10,6,$order->products[$i]['qty'],1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(40);
if (strlen($order->products[$i]['name']) > 40 && strlen($order->products[$i]['name']) < 50){
	$pdf->SetFont('Arial','',8);
	$pdf->MultiCell(80,6,$order->products[$i]['name'],1,'L');
	}
else if (strlen($order->products[$i]['name']) > 50){
	$pdf->SetFont('Arial','',8);
	$pdf->MultiCell(80,6,substr($order->products[$i]['name'],0,50),1,'L');
	}
else{
	$pdf->MultiCell(80,6,$order->products[$i]['name'],1,'L');
	}
$pdf->SetFont('Arial','',10);
//$pdf->SetY($Y_Table_Position);
//$pdf->SetX(95);
//$pdf->MultiCell(15,6,tep_display_tax_value($order->products[$i]['tax']) . '%',1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(15);
$pdf->MultiCell(25,6,$order->products[$i]['model'],1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(120);
$pdf->MultiCell(20,6,$currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(140);
$pdf->MultiCell(20,6,$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(160);
$pdf->MultiCell(20,6,$currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(180);
$pdf->MultiCell(20,6,$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']),1,'C');
$Y_Table_Position += 6;
}
for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
$pdf->SetY($Y_Table_Position);
$pdf->SetX(100);
$temp = substr ($order->totals[$i]['text'],0 ,3);
//if ($i == 3) $pdf->Text(10,10,$temp);
if ($temp == '<b>')
	{
	$pdf->SetFont('Arial','B',10);
	$temp2 = substr($order->totals[$i]['text'], 3);
	$order->totals[$i]['text'] = substr($temp2, 0, strlen($temp2)-4);
	}
$pdf->MultiCell(100,6,$order->totals[$i]['title'] . ' ' . $order->totals[$i]['text'],0,'R');
$Y_Table_Position += 5;
}
// Draw the shipping address for label
//Draw the invoice delivery address text
// $pdf->SetFont('Arial','B',11);
// $pdf->SetTextColor(0);
//$pdf->Text(117,61,ENTRY_SHIP_TO);
//$pdf->SetX(0);
// $pdf->SetY(240);
// $pdf->Cell(20);
// $pdf->MultiCell(50, 4, strtoupper(tep_address_format(1, $order->delivery, '', '', "\n")),0,'L');

	}
// PDF's created now output the file
$pdf->Output();
?>

 

And this is the code I added:

 

 //Draw Customer Email Address
  $temp = str_replace(' ', ' ', PRINT_CUSTOMERS_EMAIL_ADDRESS);
  $pdf->Text(5,32,$temp . tep_db_input ($order->info['customers_email_address']));

  //Draw Customer Telephone
  $temp = str_replace(' ', ' ', PRINT_CUSTOMERS_TELEPHONE);
  $pdf->Text(5,36,$temp . tep_db_input ($order->info['customers_telephone']));

 

Anyone have any idea what needs to be fixed so it will work?

 

Thanks in advance:

Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Link to comment
Share on other sites

I done did it :D all by myself :) ....

 

Here is the code I was having problems with:

 //Draw Customer Email Address
  $temp = str_replace(' ', ' ', PRINT_CUSTOMERS_EMAIL_ADDRESS);
  $pdf->Text(5,32,$temp . tep_db_input ($order->info['customers_email_address']));

  //Draw Customer Telephone
  $temp = str_replace(' ', ' ', PRINT_CUSTOMERS_TELEPHONE);
  $pdf->Text(5,36,$temp . tep_db_input ($order->info['customers_telephone']));

 

Here is the NEW code that is working:

//Draw Customer Email Address
$temp = str_replace(' ', ' ', PRINT_CUSTOMERS_EMAIL_ADDRESS);
$pdf->Text(5,32,$temp . tep_db_input ($order->customer['email_address']));

//Draw Customer Telephone
$temp = str_replace(' ', ' ', PRINT_CUSTOMERS_TELEPHONE);
$pdf->Text(5,36,$temp . tep_db_input ($order->customer['telephone']));

 

Note, I also had to define the PRINT_CUSTOMERS_TELEPHONE in admin > includes> languages > english > invoice.php to get it to display correctly so it should look like this on the last 2 lines before the ?>:

 

define('PRINT_CUSTOMERS_EMAIL_ADDRESS', 'Email Address: ');
define('PRINT_CUSTOMERS_TELEPHONE', 'Phone Number: ');

 

Hope this helps others who have been trying to get this to work. :thumbsup:

Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Link to comment
Share on other sites

Now if I can only get the attributes to show up I'll be cooking with bacon grease :lol:

Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going.

Link to comment
Share on other sites

  • 3 weeks later...

Hi bobg7,

 

I just installed this mod and spent today editting it to look the way I wanted.

I also needed the attributes on my invoices.

 

If you still haven't got yours working yet, you are more then welcome to use mine.

 

Here a screen shot

invoice_sample.jpg

 

Anyone else that would like to use my invoice layout feel free to email me at [email protected]

Edited by eyekandee
Link to comment
Share on other sites

  • 7 months later...

eyekandee very kindly sent me his code which is shown below. You might also want to use my own updates for the invoice + packingslip (with attributes) with slighly different formating - also below:

 

from eyekandee:

 

<?php
/*
 $Id: create_pdf,v 1.2 2005/03/08

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2005 osCommerce

 Released under the GNU General Public License

 Written by Neil Westlake ([email protected]) for www.Digiprintuk.com
*/

define('FPDF_FONTPATH','fpdf/font/');
require('fpdf/fpdf.php');
require('includes/application_top.php');
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ORDERS_INVOICE);

require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();

include(DIR_WS_CLASSES . 'order.php');

class PDF extends FPDF
{
//Page header

function Header()
{
global $oID;
$date = strftime('%A, %d %B %Y');

//logo and address
$this->Image('images/invoice_logo.jpg',10,0);
$this->SetFont('Times','B',16);
$this->SetY(2);
$this->SetX(1177);
$this->Cell(50,4,"INVOICE #: " . $oID,0,'L');

$this->SetFont('Times','',8);
$this->SetY(12);
$this->SetX(5);
$this->Cell(175,3,"EYE CANDY ENTERPRISES / EYEKANDEEAPPAREL.COM  11057 164th Street, SURREY, BC, CANADA   TEL: 604.616.4967",0,'L');

$this->SetFont('Times','',8);
$this->SetY(12);
$this->SetX(216);
$this->Cell(50,3,"GST Registration #: 85809 2232",0,'L');

}

function Footer()
{
//Position at 1.5 cm from bottom
$this->SetY(-25);
$this->SetX(5);
//Arial italic 8
$this->SetFont('times','',8);
$this->MultiCell(204,3, "EXCHANGE AND RETURN TERMS & CONDITIONS: All returns must be postmarked no later than 20 calendar days after the order is placed. In order to receive a refund. Any returns received within a 30 calander day period, must be an exchange or store credit only. All other returns will be sent back to the customer." . "\n" . "Your invoice and a duly completed Return Form must accompany your returned item(s) in order for Eye Kandee Apparel to process your refund." . "\n" . "All returned items MUST be in their original state and deemed to be in unworn condition before they can be accepted for a refund. They MUST have the tags attached." . "\n" . "Due to the intimate nature and hygienic standards of certain items, we regret that it is NOT possible for us to accept returns on panties, babydolls, bodysuits, hosiery, teddies, men’s briefs and boxer shorts. We also can not offer a return for discount items. If these items are returned to Eye Kandee Apparel they will be sent back to you at your expense.",0,1,'L');
//Page number
//$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
$this->Ln(1);
$this->SetX(5);
$this->Cell(271,3, "www.eyekandeeapparel.com",0,1,'C');
}
}
//Instanciation of inherited class
$pdf=new PDF();

// Set the Page Margins
$pdf->SetMargins(4,2,4);

//$pdf->AliasNbPages();
while (list($key, $oID) = each($_GET)) {
if ($key == "osCAdminID")
	break;
	 $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . $oID . "'");
	 $order = new order($oID);

// Add the first page
$pdf->AddPage();

//Draw the top line with invoice text
$pdf->SetY(17);
$pdf->SetX(6);
$pdf->SetDrawColor(153,153,153);
$pdf->Cell(204,.3,'',1,1,'L',1);


//Draw the invoice address text
$pdf->SetY(20);
$pdf->SetX(5);
$pdf->SetFont('Times','B',8);
$pdf->SetTextColor(0);
$pdf->Cell(50, 3, ENTRY_SOLD_TO, 0,1,'L');
$pdf->SetX(6);
$pdf->SetFont('Times','',8);
$pdf->SetTextColor(0);
$pdf->MultiCell(70, 3, tep_address_format(1, $order->customer, '', '', "\n"),0,'L');
$pdf->SetX(6);
$pdf->SetFont('Times','',8);
$pdf->SetTextColor(0);
$pdf->Cell(70,3, "TEL: " . $order->customer['telephone'], 0,'L');

//Draw invoice infomation text	
$pdf->SetY(20);
$pdf->SetX(135);
$pdf->SetFont('Times','',8);
$pdf->SetTextColor(0);
$pdf->Cell(20, 3, "Date: ", 0,1,'R');
$pdf->SetX(135);
$pdf->Cell(20, 3, "Invoice #: ", 0,1,'R');
$pdf->SetX(135);
$pdf->Cell(20, 3, "Customer ID: ", 0,1,'R');
$pdf->SetX(135);
$pdf->Cell(20, 3, "Store: ", 0,1,'R');
$pdf->SetX(135);
$pdf->Cell(20, 3, "Payment Type: ", 0,1,'R');

$pdf->SetY(20);
$pdf->SetX(153);
$pdf->SetFont('Times','B',8);
$pdf->SetTextColor(0);
$pdf->Cell(20, 3, tep_date_short($order->info['date_purchased']), 0,1,'L');
$pdf->SetX(153);
$pdf->Cell(20, 3, tep_db_input($oID), 0,1,'L');
$pdf->SetX(153);
$pdf->Cell(20, 3, '00' . $order->customer['id'], 0,1,'L');
$pdf->SetX(153);
$pdf->Cell(20, 3, STORE_NAME, 0,1,'L');
$pdf->SetX(153);
$temp = substr ($order->info['payment_method'] , 0, 23);
$pdf->Cell(20, 3, $temp, 0,1,'L');


//Fields Name position
$Y_Fields_Name_position = 40;
//Table position, under Fields Name
$Y_Table_Position = 47;

//First create each Field Name
//Gray color filling each Field Name box

//Bold Font for Field Name
$pdf->SetFont('Times','B',8);
$pdf->SetY($Y_Fields_Name_position);
$pdf->SetX(5);
$pdf->Cell(30,3,TABLE_HEADING_PRODUCTS_MODEL,0,0,'L');
$pdf->SetX(35);
$pdf->Cell(121,3,TABLE_HEADING_PRODUCTS,0,0,'L');
$pdf->SetX(156);
$pdf->Cell(10,3,"Qty",0,0,'C');
$pdf->SetX(166);
$pdf->Cell(22,3,"Price",0,0,'R');
$pdf->SetX(188);
$pdf->Cell(21,3,"Total",0,0,'R');

$pdf->SetY(44);
$pdf->SetX(6);
$pdf->SetDrawColor(153,153,153);
$pdf->Cell(204,.3,'',1,1,'L',1);
$pdf->Ln();

//Show the products information line by line
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
$pdf->SetFont('Times','',8);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(5);
$pdf->MultiCell(30,3,$order->products[$i]['model'],0,'L');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(35);

if (strlen($order->products[$i]['name']) > 40 && strlen($order->products[$i]['name']) < 50){
	$pdf->SetFont('Times','',8);
	$pdf->MultiCell(121,3,$order->products[$i]['name'],0,'L');
if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
	for ($j = 0; $j < $k; $j++) {
	$pdf->SetFont('Times','',6);
	$pdf->SetX(37);
	$pdf->MultiCell(121, 3, "- " . $order->products[$i]['attributes'][$j]['option'] . ": " . $order->products[$i]['attributes'][$j]['value'],0,'L');
	}
	}
	}
else if (strlen($order->products[$i]['name']) > 50){
	$pdf->SetFont('Times','',8);
	$pdf->MultiCell(121,3,$order->products[$i]['name'],0,'L');
if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
	for ($j = 0; $j < $k; $j++) {
	$pdf->SetFont('Times','',6);
	$pdf->SetX(37);
	$pdf->MultiCell(121, 3, "- " . $order->products[$i]['attributes'][$j]['option'] . ": " . $order->products[$i]['attributes'][$j]['value'],0,'L');
	}
	}
	}
else{
	$pdf->SetFont('Times','',8);
	$pdf->MultiCell(121,3,$order->products[$i]['name'],0,'L');
if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
	for ($j = 0; $j < $k; $j++) {
	$pdf->SetFont('Times','',6);
	$pdf->SetX(37);
	$pdf->MultiCell(121, 3, "- " . $order->products[$i]['attributes'][$j]['option'] . ": " . $order->products[$i]['attributes'][$j]['value'],0,'L');
	}
	}
	}

$pdf->SetFont('Times','',8);
//$pdf->SetY($Y_Table_Position);
//$pdf->SetX(95);
//$pdf->MultiCell(15,6,tep_display_tax_value($order->products[$i]['tax']) . '%',1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(156);
$pdf->MultiCell(10,3,$order->products[$i]['qty'],0,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(166);
$pdf->MultiCell(22,3,$currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']),0,'R');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(188);
$pdf->MultiCell(21,3,$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']),0,'R');
$Y_Table_Position += 10;
}
$Y_Table_Position += 1;
$pdf->SetY($Y_Table_Position);

$pdf->SetX(6);
$pdf->SetDrawColor(153,153,153);
$pdf->Cell(204,.3,'',1,1,'L',1);
$Y_Table_Position += 2;

for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
$pdf->SetY($Y_Table_Position);
$pdf->SetX(80);
$temp = substr ($order->totals[$i]['text'],0 ,3);
//if ($i == 3) $pdf->Text(10,10,$temp);
if ($temp == '<b>')
	{
	$pdf->SetFont('Times','B',8);
	$temp2 = substr($order->totals[$i]['text'], 3);
	$order->totals[$i]['text'] = substr($temp2, 0, strlen($temp2)-4);
	}
$pdf->MultiCell(130,3,strip_tags($order->totals[$i]['title']) . ' ' . strip_tags($order->totals[$i]['text']),0,'R');
$Y_Table_Position += 3;
}
// Top Right message Box
$pdf->SetFont('Times','',9);
$pdf->SetY(17);
$pdf->SetX(213);
$pdf->MultiCell(61,3,"\n" . "Thanks for ordering with Eye Kandee Apparel." . "\n" . "We appreciate your business!" . "\n\n" . "Free shipping on all orders over $100.00. To redeem enter coupon code FREESHIPPING on the payment option screen the next time you place an order." . "\n\n" . "Want some Eye Kandee Apparel Swag check out our free giveaways at eyekandeeapparel.com/enter_contest.php." ."\n\n",1,1,'R');

// Bottom message box
$pdf->SetFont('Times','',9);
$pdf->SetY(62);
$pdf->SetX(213);
$pdf->SetFillColor(225,225,225);
$pdf->Cell(61,4,"Company Use",1,1,'C',1);
$pdf->SetX(213);
$pdf->SetFillColor(225,225,225);
$pdf->Cell(61,125,"",1,1,'C',1);

}
// PDF's created now output the file
$pdf->Output();
?>

Link to comment
Share on other sites

My version (invoice first, then packingslip):

I have also changed the formatting and added a message + icon to the label.

 

<?php
/*
 $Id: create_pdf,v 1.4 2005/04/07

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License

 Written by Neil Westlake ([email protected]) for www.Digiprintuk.com

 Version History:
 1.1
 Initial release
 1.2
 Corrected problem displaying PDF when from a HTTPS URL.
 1.3
 Modified item display to allow page continuation when more than 20 products are on one invoice.
 1.4
 Corrected problem with page continuation, now invoices will allow for an unlimited amount of products on one invoice
*/

define('FPDF_FONTPATH','fpdf/font/');
require('fpdf/fpdf.php');

require('includes/application_top.php');
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ORDERS_INVOICE);

require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();

//include(DIR_WS_CLASSES . 'order.php');
include(DIR_WS_CLASSES . 'order.php');
 $order = new order($oID);

while (list($key, $oID) = each($_GET)) {
if ($key != "oID")
	break;
	 $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . $oID . "'");
	 $order = new order($oID);

class PDF extends FPDF
{
//Page header
function RoundedRect($x, $y, $w, $h,$r, $style = '')
{
	$k = $this->k;
	$hp = $this->h;
	if($style=='F')
		$op='f';
	elseif($style=='FD' or $style=='DF')
		$op='B';
	else
		$op='S';
	$MyArc = 4/3 * (sqrt(2) - 1);
	$this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k ));
	$xc = $x+$w-$r;
	$yc = $y+$r;
	$this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k ));

	$this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
	$xc = $x+$w-$r;
	$yc = $y+$h-$r;
	$this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k));
	$this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
	$xc = $x+$r;
	$yc = $y+$h-$r;
	$this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k));
	$this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
	$xc = $x+$r;
	$yc = $y+$r;
	$this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k ));
	$this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
	$this->_out($op);
}

function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
{
	$h = $this->h;
	$this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k,
		$x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
}

function Header()
{
global $oID;
 $date = strftime('%A, %d %B %Y');
//Logo
$this->Image('images/invoice_logo.jpg',3,5,80);

// Invoice Number and date
$this->SetFont('Arial','B',10);
$this->SetTextColor(0,0,0);
$this->SetY(38);
$this->MultiCell(85,4,"Invoice: #100" . $oID . "\nInvoice Date: " . $date . "\n" ,0,'L');

// Company Address
$this->SetX(0);
$this->SetY(10);
$this->SetFont('Arial','B',10);
$this->SetTextColor(0,0,0);
$this->Ln(0);
$this->Cell(129);
$this->MultiCell(70, 3.5, STORE_NAME_ADDRESS,0,'R');
}

function Footer()
{
//Position at 1.5 cm from bottom
$this->SetY(-15);
//Arial italic 8
$this->SetFont('Arial','B',10);
$this->SetTextColor(0,0,0);
$this->Cell(0,10, PRINT_INVOICE_TEXT, 0,0,'C');
$this->SetY(-10);
  	$this->Cell(0,10, PRINT_INVOICE_URL, 0,0,'C');
//Page number
//$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
//Instanciation of inherited class
$pdf=new PDF();

// Set the Page Margins
$pdf->SetMargins(6,2,6);

// Add the first page
$pdf->AddPage();

//Draw the top line with invoice text
$pdf->Cell(50);
$pdf->SetY(51);
$pdf->SetDrawColor(0,0,0);
$pdf->Cell(150,.1,'',1,1,'L',1);
$pdf->SetFont('Arial','BI',15);
$pdf->SetTextColor(0,0,0);
$pdf->Text(160,52.5,'Invoice');
$pdf->SetY(51);
$pdf->SetDrawColor(0,0,0);
$pdf->Cell(177);
$pdf->Cell(20,.1,'',1,1,'L',1);

// Invoice Number and date
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(0,0,0);
$pdf->SetY(55);
$pdf->MultiCell(85,4,"Customer Email: " . $order->customer['email_address'] . "\nCustomer Telephone: " . $order->customer['telephone'] . "\n" ,0,'L');

//Draw Box for Invoice Address
$pdf->SetDrawColor(0);
$pdf->SetLineWidth(0.2);
$pdf->SetFillColor(245);
$pdf->RoundedRect(6, 67, 90, 35, 2, 'DF');

//Draw the invoice address text
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(0);
$pdf->Text(11,77, ENTRY_SOLD_TO);
$pdf->SetX(0);
$pdf->SetY(80);
//$pdf->SetFont('Arial','B',8);
//$pdf->SetTextColor(0);
$pdf->Cell(9);
$pdf->MultiCell(70, 3.3, tep_address_format(1, $order->customer, '', '', "\n"),0,'L');

//Draw Box for Delivery Address
$pdf->SetDrawColor(0);
$pdf->SetLineWidth(0.2);
$pdf->SetFillColor(255);
$pdf->RoundedRect(108, 67, 90, 35, 2, 'DF');

//Draw the invoice delivery address text
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(0);
$pdf->Text(113,77,ENTRY_SHIP_TO);
$pdf->SetX(0);
$pdf->SetY(80);
$pdf->Cell(111);
$pdf->MultiCell(70, 3.3, tep_address_format(1, $order->delivery, '', '', "\n"),0,'L');

//Draw Box for Order Number, Date & Payment method
$pdf->SetDrawColor(0);
$pdf->SetLineWidth(0.2);
$pdf->SetFillColor(245);
$pdf->RoundedRect(6, 107, 192, 11, 2, 'DF');

//Draw Order Number Text
$temp = str_replace(' ', ' ', PRINT_INVOICE_ORDERNR);
$pdf->Text(10,114, $temp . tep_db_input($oID));	
//Draw Date of Order Text
$temp = str_replace(' ', ' ', PRINT_INVOICE_DATE);
$pdf->Text(60,114,$temp . tep_date_short($order->info['date_purchased']));	
//Draw Payment Method Text
$temp = substr ($order->info['payment_method'] , 0, 35);
$pdf->Text(112,114,ENTRY_PAYMENT_METHOD . ' ' . $temp);	
//$pdf->Cell(198,29,ENTRY_PAYMENT_METHOD . ' ' . $temp, 0, 0, 'R');

//Fields Name position
$Y_Fields_Name_position = 125;
//Table position, under Fields Name
$Y_Table_Position = 131;


function output_table_heading($Y_Fields_Name_position){
global $pdf;
//First create each Field Name
//Gray color filling each Field Name box
$pdf->SetFillColor(245);
//Bold Font for Field Name
$pdf->SetFont('Arial','B',10);
$pdf->SetY($Y_Fields_Name_position);
$pdf->SetX(6);
$pdf->Cell(9,6,'Qty',1,0,'C',1);
$pdf->SetX(15);
$pdf->Cell(27,6,TABLE_HEADING_PRODUCTS_MODEL,1,0,'C',1);
$pdf->SetX(40);
$pdf->Cell(78,6,TABLE_HEADING_PRODUCTS,1,0,'C',1);
//$pdf->SetX(105);
//$pdf->Cell(15,6,TABLE_HEADING_TAX,1,0,'C',1);
$pdf->SetX(118);
$pdf->Cell(20,6,TABLE_HEADING_PRICE_EXCLUDING_TAX,1,0,'C',1);
$pdf->SetX(138);
$pdf->Cell(20,6,TABLE_HEADING_PRICE_INCLUDING_TAX,1,0,'C',1);
$pdf->SetX(158);
$pdf->Cell(20,6,TABLE_HEADING_TOTAL_EXCLUDING_TAX,1,0,'C',1);
$pdf->SetX(178);
$pdf->Cell(20,6,TABLE_HEADING_TOTAL_INCLUDING_TAX,1,0,'C',1);
$pdf->Ln();
}
output_table_heading($Y_Fields_Name_position);
//Show the products information line by line
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {


//for attributes - start	
$thickness = 6;
$border_string = 'TB';
if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
	$border_string = '0';
	for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {

	$thickness += 3;
  }
}	

$pdf->SetFont('Arial','',10);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(6);
$pdf->MultiCell(9,$thickness ,$order->products[$i]['qty'],1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(40);



if (strlen($order->products[$i]['name']) > 40 && strlen($order->products[$i]['name']) < 55){
	$pdf->SetFont('Arial','',8);
	$pdf->MultiCell(78,6,$order->products[$i]['name'],$border_string,'L');
if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
	for ($j = 0; $j < $k; $j++) {
	$pdf->SetFont('Arial','',6);
	$pdf->SetX(40);
	if ($j == $k-1) { $att_border_string = 'B'; } else { $att_border_string = 0; }
	$pdf->MultiCell(78, 3, "- " . $order->products[$i]['attributes'][$j]['option'] . ": " . $order->products[$i]['attributes'][$j]['value'],$att_border_string,'L');
	}
}
	}
else if (strlen($order->products[$i]['name']) > 55){
	$pdf->SetFont('Arial','',8);
	$pdf->MultiCell(78,6,substr($order->products[$i]['name'],0,55),$border_string,'L');
if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
	for ($j = 0; $j < $k; $j++) {
	$pdf->SetFont('Arial','',6);
	$pdf->SetX(40);
	if ($j == $k-1) { $att_border_string = 'B'; } else { $att_border_string = 0; }
	$pdf->MultiCell(78, 3, "- " . $order->products[$i]['attributes'][$j]['option'] . ": " . $order->products[$i]['attributes'][$j]['value'],$att_border_string,'L');
	}
}
	}
else{
	$pdf->SetFont('Arial','',8);
	$pdf->MultiCell(78,6,$order->products[$i]['name'],$border_string,'L');

if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
	for ($j = 0; $j < $k; $j++) {
	$pdf->SetFont('Arial','',6);
	$pdf->SetX(40);
	if ($j == $k-1) { $att_border_string = 'B'; } else { $att_border_string = 0; }
	$pdf->MultiCell(78, 3, "- " . $order->products[$i]['attributes'][$j]['option'] . ": " . $order->products[$i]['attributes'][$j]['value'],$att_border_string,'L');
	}
}
}

$pdf->SetFont('Arial','',10);
//$pdf->SetY($Y_Table_Position);
//$pdf->SetX(95);
//$pdf->MultiCell(15,6,tep_display_tax_value($order->products[$i]['tax']) . '%',1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(15);
$pdf->SetFont('Arial','',8);
$pdf->MultiCell(25,$thickness ,$order->products[$i]['model'],1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(118);
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(20,$thickness ,$currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(138);
$pdf->MultiCell(20,$thickness ,$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(158);
$pdf->MultiCell(20,$thickness ,$currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']),1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(178);
$pdf->MultiCell(20,$thickness ,$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']),1,'C');
$Y_Table_Position += $thickness;

//for attributes - end

//Check for product line overflow
 $item_count++;
if ((is_long($item_count / 32) && $i >= 20) || ($i == 20)){
	$pdf->AddPage();
	//Fields Name position
	$Y_Fields_Name_position = 125;
	//Table position, under Fields Name
	$Y_Table_Position = 70;
	output_table_heading($Y_Table_Position-6);
	if ($i == 20) $item_count = 1;
}
}
for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
$pdf->SetY($Y_Table_Position + 5);
$pdf->SetX(90);
$temp = substr ($order->totals[$i]['text'],0 ,3);
//if ($i == 3) $pdf->Text(10,10,$temp);
if ($temp == '<b>')
	{
	$pdf->SetFont('Arial','B',10);
	$temp2 = substr($order->totals[$i]['text'], 3);
	$order->totals[$i]['text'] = substr($temp2, 0, strlen($temp2)-4);
	}
$pdf->MultiCell(106,6,$order->totals[$i]['title'] . ' ' . $order->totals[$i]['text'],0,'R');
$Y_Table_Position += 5;
}

$pdf->Image('images/invoice_logo.jpg',82,225,20);

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(0);
$pdf->Text(20,230,PRINT_INVOICE_STRAP);

$pdf->SetY(234);
$pdf->SetDrawColor(0,0,0);
$pdf->Cell(12);
$pdf->Cell(86,.1,'',1,1,'L',1);


$pdf->SetFont('Arial','B',12);
$pdf->SetTextColor(0);
$pdf->SetX(0);
$pdf->SetY(238);
$pdf->Cell(20);
$pdf->MultiCell(80, 4, strtoupper(tep_address_format(1, $order->delivery, '', '', "\n")),0,'L');

$pdf->SetY(268);
$pdf->SetDrawColor(0,0,0);
$pdf->Cell(12);
$pdf->Cell(86,.1,'',1,1,'L',1);

$pdf->SetFont('Arial','B',7);
$pdf->SetTextColor(0);
$pdf->Text(21,273,PRINT_INVOICE_SENT_BY);

$pdf->SetFont('Arial','B',7);
$pdf->SetTextColor(0);
$pdf->Text(45,277,PRINT_INVOICE_URL);

	}
// PDF's created now output the file
$pdf->Output();
?>

 

<?php
/*
 $Id: create_pdf,v 1.4 2005/04/07

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License

 Written by Neil Westlake ([email protected]) for www.Digiprintuk.com

 Version History:
 1.1
 Initial release
 1.2
 Corrected problem displaying PDF when from a HTTPS URL.
 1.3
 Modified item display to allow page continuation when more than 20 products are on one invoice.
 1.4
 Corrected problem with page continuation, now invoices will allow for an unlimited amount of products on one invoice
*/

define('FPDF_FONTPATH','fpdf/font/');
require('fpdf/fpdf.php');

require('includes/application_top.php');
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ORDERS_INVOICE);

require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();

//include(DIR_WS_CLASSES . 'order.php');
include(DIR_WS_CLASSES . 'order.php');
 $order = new order($oID);

while (list($key, $oID) = each($_GET)) {
if ($key != "oID")
	break;
	 $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . $oID . "'");
	 $order = new order($oID);

class PDF extends FPDF
{
//Page header
function RoundedRect($x, $y, $w, $h,$r, $style = '')
{
	$k = $this->k;
	$hp = $this->h;
	if($style=='F')
		$op='f';
	elseif($style=='FD' or $style=='DF')
		$op='B';
	else
		$op='S';
	$MyArc = 4/3 * (sqrt(2) - 1);
	$this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k ));
	$xc = $x+$w-$r;
	$yc = $y+$r;
	$this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k ));

	$this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
	$xc = $x+$w-$r;
	$yc = $y+$h-$r;
	$this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k));
	$this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
	$xc = $x+$r;
	$yc = $y+$h-$r;
	$this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k));
	$this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
	$xc = $x+$r;
	$yc = $y+$r;
	$this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k ));
	$this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
	$this->_out($op);
}

function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
{
	$h = $this->h;
	$this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k,
		$x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
}

function Header()
{
global $oID;
 $date = strftime('%A, %d %B %Y');
//Logo
$this->Image('images/invoice_logo.jpg',3,5,80);

// Invoice Number and date
$this->SetFont('Arial','B',10);
$this->SetTextColor(0,0,0);
$this->SetY(42);
$this->MultiCell(85,4,"Date: " . $date . "\n" ,0,'L');

// Company Address
$this->SetX(0);
$this->SetY(10);
$this->SetFont('Arial','B',10);
$this->SetTextColor(0,0,0);
$this->Ln(0);
$this->Cell(129);
$this->MultiCell(70, 3.5, STORE_NAME_ADDRESS,0,'R');
}

function Footer()
{
//Position at 1.5 cm from bottom
$this->SetY(-15);
//Arial italic 8
$this->SetFont('Arial','B',10);
$this->SetTextColor(0,0,0);
$this->Cell(0,10, PRINT_INVOICE_TEXT, 0,0,'C');
$this->SetY(-10);
  	$this->Cell(0,10, PRINT_INVOICE_URL, 0,0,'C');
//Page number
//$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
//Instanciation of inherited class
$pdf=new PDF();

// Set the Page Margins
$pdf->SetMargins(6,2,6);

// Add the first page
$pdf->AddPage();

//Draw the top line with invoice text
$pdf->Cell(50);
$pdf->SetY(51);
$pdf->SetDrawColor(0,0,0);
$pdf->Cell(142,.1,'',1,1,'L',1);
$pdf->SetFont('Arial','BI',15);
$pdf->SetTextColor(0,0,0);
$pdf->Text(151,52.5,'Delivery Note');
$pdf->SetY(51);
$pdf->SetDrawColor(0,0,0);
$pdf->Cell(182);
$pdf->Cell(15,.1,'',1,1,'L',1);

// Invoice Number and date
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(0,0,0);
$pdf->SetY(55);
$pdf->MultiCell(85,4,"Customer Email: " . $order->customer['email_address'] . "\nCustomer Telephone: " . $order->customer['telephone'] . "\n" ,0,'L');

//Draw Box for Invoice Address
$pdf->SetDrawColor(0);
$pdf->SetLineWidth(0.2);
$pdf->SetFillColor(245);
$pdf->RoundedRect(6, 67, 90, 35, 2, 'DF');

//Draw the invoice address text
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(0);
$pdf->Text(11,77, ENTRY_SOLD_TO);
$pdf->SetX(0);
$pdf->SetY(80);
//$pdf->SetFont('Arial','B',8);
//$pdf->SetTextColor(0);
$pdf->Cell(9);
$pdf->MultiCell(70, 3.3, tep_address_format(1, $order->customer, '', '', "\n"),0,'L');

//Draw Box for Delivery Address
$pdf->SetDrawColor(0);
$pdf->SetLineWidth(0.2);
$pdf->SetFillColor(255);
$pdf->RoundedRect(108, 67, 90, 35, 2, 'DF');

//Draw the invoice delivery address text
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(0);
$pdf->Text(113,77,ENTRY_SHIP_TO);
$pdf->SetX(0);
$pdf->SetY(80);
$pdf->Cell(111);
$pdf->MultiCell(70, 3.3, tep_address_format(1, $order->delivery, '', '', "\n"),0,'L');

//Draw Box for Order Number, Date & Payment method
$pdf->SetDrawColor(0);
$pdf->SetLineWidth(0.2);
$pdf->SetFillColor(245);
$pdf->RoundedRect(6, 107, 192, 11, 2, 'DF');

//Draw Order Number Text
$temp = str_replace(' ', ' ', PRINT_INVOICE_ORDERNR);
$pdf->Text(10,114, $temp . tep_db_input($oID));	
//Draw Date of Order Text
$temp = str_replace(' ', ' ', PRINT_INVOICE_DATE);
$pdf->Text(148,114,$temp . tep_date_short($order->info['date_purchased']));	
//Draw Payment Method Text
//$temp = substr ($order->info['payment_method'] , 0, 23);
//$pdf->Text(130,114,ENTRY_PAYMENT_METHOD . ' ' . $temp);	
//$pdf->Cell(198,29,ENTRY_PAYMENT_METHOD . ' ' . $temp, 0, 0, 'R');

//Fields Name position
$Y_Fields_Name_position = 125;
//Table position, under Fields Name
$Y_Table_Position = 131;


function output_table_heading($Y_Fields_Name_position){
global $pdf;
//First create each Field Name
//Gray color filling each Field Name box
$pdf->SetFillColor(245);
//Bold Font for Field Name
$pdf->SetFont('Arial','B',10);
$pdf->SetY($Y_Fields_Name_position);
$pdf->SetX(6);
$pdf->Cell(14,6,'Qty',1,0,'C',1);
$pdf->SetX(20);
$pdf->Cell(40,6,TABLE_HEADING_PRODUCTS_MODEL,1,0,'C',1);
$pdf->SetX(60);
$pdf->Cell(118,6,TABLE_HEADING_PRODUCTS,1,0,'C',1);
$pdf->SetX(178);
$pdf->Cell(20,6,TABLE_HEADING_SHIPPED,1,0,'C',1);
$pdf->Ln();
}
output_table_heading($Y_Fields_Name_position);
//Show the products information line by line
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
//start attrib
$thickness = 6;
$border_string = 'TB';
if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
	$border_string = '0';
	for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {

	$thickness += 3;
  }
}	

$pdf->SetFont('Arial','',10);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(6);
$pdf->MultiCell(14,$thickness,$order->products[$i]['qty'],1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(20);
$pdf->SetFont('Arial','',8);
$pdf->MultiCell(40,$thickness,$order->products[$i]['model'],1,'C');
$pdf->SetY($Y_Table_Position);
$pdf->SetX(60);

	if (strlen($order->products[$i]['name']) > 40 && strlen($order->products[$i]['name']) < 75){
	$pdf->SetFont('Arial','',8);
	$pdf->MultiCell(118,6,$order->products[$i]['name'],$border_string,'L');
if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
	for ($j = 0; $j < $k; $j++) {
	$pdf->SetFont('Arial','',6);
	$pdf->SetX(60);
	if ($j == $k-1) { $att_border_string = 'B'; } else { $att_border_string = 0; }
	$pdf->MultiCell(118, 3, "- " . $order->products[$i]['attributes'][$j]['option'] . ": " . $order->products[$i]['attributes'][$j]['value'],$att_border_string,'L');
	}
}
	}
else if (strlen($order->products[$i]['name']) > 75){
	$pdf->SetFont('Arial','',8);
	$pdf->MultiCell(118,6,substr($order->products[$i]['name'],0,75),$border_string,'L');
if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
	for ($j = 0; $j < $k; $j++) {
	$pdf->SetFont('Arial','',6);
	$pdf->SetX(60);
	if ($j == $k-1) { $att_border_string = 'B'; } else { $att_border_string = 0; }
	$pdf->MultiCell(118, 3, "- " . $order->products[$i]['attributes'][$j]['option'] . ": " . $order->products[$i]['attributes'][$j]['value'],$att_border_string,'L');
	}
}
	}
else{
	$pdf->SetFont('Arial','',8);
	$pdf->MultiCell(118,6,$order->products[$i]['name'],$border_string,'L');

if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
	for ($j = 0; $j < $k; $j++) {
	$pdf->SetFont('Arial','',6);
	$pdf->SetX(60);
	if ($j == $k-1) { $att_border_string = 'B'; } else { $att_border_string = 0; }
	$pdf->MultiCell(118, 3, "- " . $order->products[$i]['attributes'][$j]['option'] . ": " . $order->products[$i]['attributes'][$j]['value'],$att_border_string,'L');
	}
}
}



$pdf->SetY($Y_Table_Position);	
$pdf->SetX(178);
$pdf->MultiCell(20,$thickness,'',1,'L');	
$Y_Table_Position += $thickness;

//end attrib

//Check for product line overflow
 $item_count++;
if ((is_long($item_count / 32) && $i >= 20) || ($i == 20)){
	$pdf->AddPage();
	//Fields Name position
	$Y_Fields_Name_position = 125;
	//Table position, under Fields Name
	$Y_Table_Position = 70;
	output_table_heading($Y_Table_Position-6);
	if ($i == 20) $item_count = 1;
}
}
$pdf->Image('images/invoice_logo.jpg',82,225,20);

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(0);
$pdf->Text(20,230,PRINT_INVOICE_STRAP);

$pdf->SetY(234);
$pdf->SetDrawColor(0,0,0);
$pdf->Cell(12);
$pdf->Cell(86,.1,'',1,1,'L',1);


$pdf->SetFont('Arial','B',12);
$pdf->SetTextColor(0);
$pdf->SetX(0);
$pdf->SetY(238);
$pdf->Cell(20);
$pdf->MultiCell(80, 4, strtoupper(tep_address_format(1, $order->delivery, '', '', "\n")),0,'L');

$pdf->SetY(268);
$pdf->SetDrawColor(0,0,0);
$pdf->Cell(12);
$pdf->Cell(86,.1,'',1,1,'L',1);

$pdf->SetFont('Arial','B',7);
$pdf->SetTextColor(0);
$pdf->Text(21,273,PRINT_INVOICE_SENT_BY);

$pdf->SetFont('Arial','B',7);
$pdf->SetTextColor(0);
$pdf->Text(45,277,PRINT_INVOICE_URL);
	}
// PDF's created now output the file
$pdf->Output();
?>

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...