More PDF Improvements

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

More PDF Improvements

tbannister
After I finished the PDF improvement to the Quotes module it was brought
to my attention that there are four seperate CreatePDF files.  So I made
some changes so they will all use the new format and a common PDF
creation object.  I created a PDFSheet.php file to placed in the
includes directory and I've included patch files to fix the
modules/Quotes/CreatePDF.php, modules/Orders/CreatePDF.php,
modules/Orders/CreateSOPDF.php, and modules/Invoice/CreatePDF.php files.

In addition some of the content of the display text in each module has
been moved to the includes/languages/en_us.lang.php file, requiring the
following entries to be added to the app_strings array (I inserted them
at line 500):
'INVOICE_ID'           => 'Invoice No.',
'INVOICE_DATE'         => 'Date',
'INVOICE_ACCOUNT'      => 'Account Name',
'INVOICE_TERMS'        => 'Terms & Conditions',

'QUOTE_TITLE'          => 'Service Quote',
'QUOTE_SERVICE_NUMBER' => 'Service Number',
'QUOTE_DATE'           => 'Date',
'QUOTE_SALESPERSON'    => 'Account Executive',
'QUOTE_TERMS'          => 'Terms & Conditions',

'SALES_REQUISITION'    => 'Requisition No.',
'SALES_SERVICE_NUMBER' => 'Sales No.',
'SALES_TERMS'          => 'Terms & Conditions',
'SALES_VENDOR'         => 'Vendor',
'SALES_DATE'           => 'Date',
'SALES_SALESPERSON'    => 'Account Executive',

'SHEET_ADJUST'         => 'Adjustment: ',
'SHEET_BILLING_HEADER' => 'Billing Address',
'SHEET_SERVICE_HEADER' => 'Service Address',
'SHEET_SUBTOTAL'       => 'Sub Total: ',
'SHEET_TAX'            => 'Tax: ',
'SHEET_TOTAL'          => 'Grand Total: ',

--
Tyler Bannister
NetAccess Systems Inc.
905-524-2001 xt432


--- CreatePDF.php.orig 2005-10-20 16:56:18.904173448 -0400
+++ CreatePDF.php.new 2005-10-20 16:54:59.772203336 -0400
@@ -8,15 +8,23 @@
  * All Rights Reserved.
 *
  ********************************************************************************/
-require('include/fpdf/fpdf.php');
+require('include/PDFSheet.php');
 require_once('modules/Invoice/Invoice.php');
 
+define('INVOICE_ID',      $app_strings['INVOICE_ID']);
+define('INVOICE_ACCOUNT', $app_strings['INVOICE_ACCOUNT']);
+define('INVOICE_DATE',    $app_strings['INVOICE_DATE']);
+define('INVOICE_TERMS',   $app_strings['INVOICE_TERMS']);
+
 $id = $_REQUEST['record'];
 global $adb;
 //retreiving the invoice info
 $focus = new Invoice();
 $focus->retrieve_entity_info($_REQUEST['record'],"Invoice");
+
 $account_name = getAccountName($focus->column_fields[account_id]);
+$title       = $focus->column_fields['subject'];
+
 $iData[] = $account_name;
 $iData[] = $id;
 $iData[] = date('Y-m-d');
@@ -226,211 +234,35 @@
 
  $temp_data['productname'] = $productname;
  $temp_data['qty'] = $qty;
- $temp_data['unitprice'] = $unitprice;
- $temp_data['listprice'] = $listprice;
- $temp_data['total'] = $total;
+ $temp_data['unitprice'] = sprintf('%0.2f',$unitprice);
+ $temp_data['listprice'] = sprintf('%0.2f',$listprice);
+ $temp_data['total']     = sprintf('%0.2f',$total);
  $iDataDtls[] = $temp_data;
 
 }
 //getting the Total Array
-$price_total[] = $focus->column_fields["hdnSubTotal"];
-$price_total[] = $focus->column_fields["txtTax"];
-$price_total[] = $focus->column_fields["txtAdjustment"];
-$price_total[] = $focus->column_fields["hdnGrandTotal"];
-
-class PDF extends FPDF
-{
-
-// Invoice Title
-function setInvoiceTitle($title,$logo_name,$caddress)
-{
- if($title != "")
- {
- if(isset($logo_name) && $logo_name != '')
- {
- $this->Image('test/logo/'.$logo_name,10,10,0,0);
- }
- else
- {
- //$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0);
- }
- for($i=0;$i<count($caddress);$i++)
- {
-
- $this->Ln();
- $this->Cell(40);
- $this->SetFont('','',10);
- $this->Cell(0,5,$caddress[$i],0,0,'L',0);
- }
- $this->Ln();
- $this->SetFillColor(224,235,255);
-     $this->SetTextColor(0);
-     $this->SetFont('','B',18);
-     $this->Cell(0,10,$title,0,0,'C',0);
+$price_total[] = sprintf('%0.2f',$focus->column_fields["hdnSubTotal"]);
+$price_total[] = sprintf('%0.2f',$focus->column_fields["txtTax"]);
+$price_total[] = sprintf('%0.2f',$focus->column_fields["txtAdjustment"]);
+$price_total[] = sprintf('%0.2f',$focus->column_fields["hdnGrandTotal"]);
 
- }
-}
-//Invoice Address
-function setAddress($billing="",$shipping="")
-{
-
- $this->Ln();
- $this->SetFillColor(224,235,255);
- $this->SetTextColor(0);
-     $this->SetFont('','B',10);
- $this->Cell(130,10,"Bill To:",0,0,'L',0);
- $this->Cell(0,10,"Ship To:",0,0,'L',0);
- for($i=0;$i<count($billing);$i++)
- {
- $this->Cell(17);
- $this->SetFont('','',10);
- $this->Cell(130,5,$billing[$i],0,0,'L',0);
- $this->Cell(0,5,$shipping[$i],0,0,'L',0);
- $this->Ln();
- }
-
-}
-//Invoice from
-function setInvoiceDetails($iHeader,$iData)
-{
-    $this->Ln();
-    $this->SetFillColor(162,200,243);
-    $this->SetTextColor(0);
-    $this->SetDrawColor(61,121,206);
-    //$this->SetLineWidth(.3);
-    $this->SetFont('Arial','B',10);
-    //Header
-    $this->Cell(15);
-    foreach($iHeader as $value)
-    {
-        $this->Cell(40,7,$value,1,0,'L',1);
-    }
-    $this->Ln();
-    $this->SetFillColor(233,241,253);
-    $this->SetTextColor(0);
-    $this->SetFont('');
-    //Data
-    $this->Cell(15);
-    $fill=0;
-    foreach($iData as $value)
-    {
- $this->Cell(40,6,$value,1,0,'L',0);
-    }
-    $this->Ln();
-}
-
-//customer Details
-function setCustomerDetails($iCHeader,$iCData)
-{
-    $this->Ln();
-    //$this->Cell(0);
-    $this->SetFillColor(162,200,243);
-    $this->SetTextColor(0);
-    $this->SetDrawColor(61,121,206);
-    //$this->SetLineWidth(.3);
-    $this->SetFont('Arial','B',10);
-    //Header
-    //$this->Cell(15);
-    foreach($iCHeader as $value)
-    {
-        $this->Cell(63,7,$value,1,0,'L',1);
-    }
-    $this->Ln();
-    $this->SetFillColor(233,241,253);
-    $this->SetTextColor(0);
-    $this->SetFont('');
-    //Data
-    //$this->Cell(15);
-    $fill=0;
-    foreach($iCData as $value)
-    {
- $this->Cell(63,6,$value,1,0,'L',0);
-    }
-    $this->Ln();
-}
-
-//Product Details
-function setProductDetails($ivHeader,$ivData)
-{
-    $this->Ln();
-    $this->Ln();
-    $this->SetFillColor(162,200,243);
-    $this->SetTextColor(0);
-    $this->SetDrawColor(61,121,206);
-    $this->SetLineWidth(.3);
-    $this->SetFont('Arial','B',10);
-    //Header
-    foreach($ivHeader as $value)
-    {
-        $this->Cell(38,7,$value,0,0,'L',0);
-    }
-    $this->Ln();
-    $this->SetDrawColor(0,0,0);
-    $this->SetLineWidth(.5);
-    $this->line(10,140,200,140);
-    $this->SetFillColor(233,241,253);
-    $this->SetTextColor(0);
-    $this->SetFont('');
-    //Data
-    $fill=0;
-     foreach($ivData as $key=>$value)
- {
-     $this->Cell(38,6,$value['productname'],0,0,'L',0);
- $this->Cell(38,6,$value['qty'],0,0,'L',0);
- $this->Cell(38,6,$value['unitprice'],0,0,'L',0);
- $this->Cell(38,6,$value['listprice'],0,0,'L',0);
- $this->Cell(38,6,$value['total'],0,0,'R',0);
- $this->Ln();
- }
-    $this->Ln();
-}
-
-function setTotal($price_total="",$conditions="")
-{
- $this->Ln();
- $this->SetDrawColor(0,0,0);
- $this->SetLineWidth(.3);
-// $this->line(10,200,200,200);
- $this->SetFillColor(224,235,255);
- $this->SetTextColor(0);
-     $this->SetFont('','B',10);
- $this->Cell(140,6,"Sub Total: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[0],1,0,'R',0);
-     $this->Ln(4);
- $this->Ln(4);
- $this->Cell(140,6,"Tax: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[1],1,0,'R',0);
- $this->Ln(4);
- $this->Ln(4);
- $this->Cell(140,6,"Adjustment: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[2],1,0,'R',0);
-     $this->Ln(4);
- $this->Ln(4);
- $this->Cell(140,6,"Grand total: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[3],1,0,'R',0);
- $this->Ln();
- $this->Ln();
- $this->Cell(0,8,"Terms & Conditions: ",0,0,'L',0);
- $this->Ln();
- $this->Cell(0,8,$conditions,0,0,'L',0);
-}
-}
 //$bdata = array("aaaaaaaaa","48/1,Katcherry Street","Rasipuram","Namakkal (D.T)");
 //$sdata = array("bbbbbb","48/9","","mmmm","Don City");
 $iHead = array("Company","Invoice No.","Date","Sales Order No.");
 $iCustHeadDtls = array("Customer Name","Purchase Order","Due Date");
 //$iCustData = array("Nortel Networks","usc-107565","26-05-2005");
-$iHeadDtls = array("Product Name","Quantity","List Price","Unit Price","Total");
+$iHeadDtls = array("Quantity","Product Name","List Price","Unit Price","Total");
 
-$pdf = new PDF('P','mm','A4');
-$pdf->SetFont('Arial','',10);
+$pdf = new PDFSheet();
+$pdf->setInvoiceHeader($title,$logo_name,$companyaddress);
+$pdf->setInvoiceFooter(INVOICE_TERMS,$conditions);
 $pdf->AddPage();
-$pdf->setInvoiceTitle("Invoice",$logo_name,$companyaddress);
 $pdf->Ln();
-$pdf->setInvoiceDetails($iHead,$iData);
 $pdf->setAddress($bdata,$sdata);
-$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
+$pdf->setInvoiceSummary(INVOICE_ID, $id,
+                        INVOICE_ACCOUNT, $account_name,
+                        INVOICE_DATE);
 $pdf->setProductDetails($iHeadDtls,$iDataDtls);
 $pdf->setTotal($price_total,$conditions);
-$pdf->Output();
+$pdf->Output('Invoice.pdf','D');
 ?>

--- CreatePDF.php.orig 2005-10-20 15:40:57.633511064 -0400
+++ CreatePDF.php.new 2005-10-20 16:54:13.686209472 -0400
@@ -8,15 +8,23 @@
  * All Rights Reserved.
 *
  ********************************************************************************/
-require('include/fpdf/fpdf.php');
+require('include/PDFSheet.php');
 require_once('modules/Orders/Order.php');
 
+define('SALES_TERMS',          $app_strings['SALES_TERMS']);
+define('SALES_REQUISITION',    $app_strings['SALES_REQUISITION']);
+define('SALES_VENDOR',         $app_strings['SALES_VENDOR']);
+define('SALES_DATE',           $app_strings['SALES_DATE']);
+
 $id = $_REQUEST['record'];
 global $adb;
 //retreiving the invoice info
 $focus = new Order();
 $focus->retrieve_entity_info($_REQUEST['record'],"Orders");
+
 $vendor_name = getVendorName($focus->column_fields[vendor_id]);
+$title       = $focus->column_fields['subject'];
+
 $iData[] = $vendor_name;
 $iData[] = $id;
 $iData[] = date('Y-m-d');
@@ -226,211 +234,35 @@
 
  $temp_data['productname'] = $productname;
  $temp_data['qty'] = $qty;
- $temp_data['unitprice'] = $unitprice;
- $temp_data['listprice'] = $listprice;
- $temp_data['total'] = $total;
+ $temp_data['unitprice'] = sprintf('%0.2f',$unitprice);
+ $temp_data['listprice'] = sprintf('%0.2f',$listprice);
+ $temp_data['total']     = sprintf('%0.2f',$total);
  $iDataDtls[] = $temp_data;
 
 }
 //getting the Total Array
-$price_total[] = $focus->column_fields["hdnSubTotal"];
-$price_total[] = $focus->column_fields["txtTax"];
-$price_total[] = $focus->column_fields["txtAdjustment"];
-$price_total[] = $focus->column_fields["hdnGrandTotal"];
-
-class PDF extends FPDF
-{
-
-// Invoice Title
-function setInvoiceTitle($title,$logo_name,$caddress)
-{
- if($title != "")
- {
- if(isset($logo_name) && $logo_name != '')
- {
- $this->Image('test/logo/'.$logo_name,10,10,0,0);
- }
- else
- {
- //$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0);
- }
- for($i=0;$i<count($caddress);$i++)
- {
-
- $this->Ln();
- $this->Cell(40);
- $this->SetFont('','',10);
- $this->Cell(0,5,$caddress[$i],0,0,'L',0);
- }
- $this->Ln();
- $this->SetFillColor(224,235,255);
-     $this->SetTextColor(0);
-     $this->SetFont('','B',18);
-     $this->Cell(0,10,$title,0,0,'C',0);
+$price_total[] = sprintf('%0.2f',$focus->column_fields["hdnSubTotal"]);
+$price_total[] = sprintf('%0.2f',$focus->column_fields["txtTax"]);
+$price_total[] = sprintf('%0.2f',$focus->column_fields["txtAdjustment"]);
+$price_total[] = sprintf('%0.2f',$focus->column_fields["hdnGrandTotal"]);
 
- }
-}
-//Invoice Address
-function setAddress($billing="",$shipping="")
-{
-
- $this->Ln();
- $this->SetFillColor(224,235,255);
- $this->SetTextColor(0);
-     $this->SetFont('','B',10);
- $this->Cell(130,10,"Bill To:",0,0,'L',0);
- $this->Cell(0,10,"Ship To:",0,0,'L',0);
- for($i=0;$i<count($billing);$i++)
- {
- $this->Cell(17);
- $this->SetFont('','',10);
- $this->Cell(130,5,$billing[$i],0,0,'L',0);
- $this->Cell(0,5,$shipping[$i],0,0,'L',0);
- $this->Ln();
- }
-
-}
-//Invoice from
-function setInvoiceDetails($iHeader,$iData)
-{
-    $this->Ln();
-    $this->SetFillColor(162,200,243);
-    $this->SetTextColor(0);
-    $this->SetDrawColor(61,121,206);
-    //$this->SetLineWidth(.3);
-    $this->SetFont('Arial','B',10);
-    //Header
-    $this->Cell(15);
-    foreach($iHeader as $value)
-    {
-        $this->Cell(40,7,$value,1,0,'L',1);
-    }
-    $this->Ln();
-    $this->SetFillColor(233,241,253);
-    $this->SetTextColor(0);
-    $this->SetFont('');
-    //Data
-    $this->Cell(15);
-    $fill=0;
-    foreach($iData as $value)
-    {
- $this->Cell(40,6,$value,1,0,'L',0);
-    }
-    $this->Ln();
-}
-
-//customer Details
-function setCustomerDetails($iCHeader,$iCData)
-{
-    $this->Ln();
-    //$this->Cell(0);
-    $this->SetFillColor(162,200,243);
-    $this->SetTextColor(0);
-    $this->SetDrawColor(61,121,206);
-    //$this->SetLineWidth(.3);
-    $this->SetFont('Arial','B',10);
-    //Header
-    //$this->Cell(15);
-    foreach($iCHeader as $value)
-    {
-        $this->Cell(63,7,$value,1,0,'L',1);
-    }
-    $this->Ln();
-    $this->SetFillColor(233,241,253);
-    $this->SetTextColor(0);
-    $this->SetFont('');
-    //Data
-    //$this->Cell(15);
-    $fill=0;
-    foreach($iCData as $value)
-    {
- $this->Cell(63,6,$value,1,0,'L',0);
-    }
-    $this->Ln();
-}
-
-//Product Details
-function setProductDetails($ivHeader,$ivData)
-{
-    $this->Ln();
-    $this->Ln();
-    $this->SetFillColor(162,200,243);
-    $this->SetTextColor(0);
-    $this->SetDrawColor(61,121,206);
-    $this->SetLineWidth(.3);
-    $this->SetFont('Arial','B',10);
-    //Header
-    foreach($ivHeader as $value)
-    {
-        $this->Cell(38,7,$value,0,0,'L',0);
-    }
-    $this->Ln();
-    $this->SetDrawColor(0,0,0);
-    $this->SetLineWidth(.5);
-    $this->line(10,140,200,140);
-    $this->SetFillColor(233,241,253);
-    $this->SetTextColor(0);
-    $this->SetFont('');
-    //Data
-    $fill=0;
-     foreach($ivData as $key=>$value)
- {
-     $this->Cell(38,6,$value['productname'],0,0,'L',0);
- $this->Cell(38,6,$value['qty'],0,0,'L',0);
- $this->Cell(38,6,$value['unitprice'],0,0,'L',0);
- $this->Cell(38,6,$value['listprice'],0,0,'L',0);
- $this->Cell(38,6,$value['total'],0,0,'R',0);
- $this->Ln();
- }
-    $this->Ln();
-}
-
-function setTotal($price_total="",$conditions="")
-{
- $this->Ln();
- $this->SetDrawColor(0,0,0);
- $this->SetLineWidth(.3);
-// $this->line(10,200,200,200);
- $this->SetFillColor(224,235,255);
- $this->SetTextColor(0);
-     $this->SetFont('','B',10);
- $this->Cell(140,6,"Sub Total: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[0],1,0,'R',0);
-     $this->Ln(4);
- $this->Ln(4);
- $this->Cell(140,6,"Tax: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[1],1,0,'R',0);
- $this->Ln(4);
- $this->Ln(4);
- $this->Cell(140,6,"Adjustment: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[2],1,0,'R',0);
-     $this->Ln(4);
- $this->Ln(4);
- $this->Cell(140,6,"Grand total: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[3],1,0,'R',0);
- $this->Ln();
- $this->Ln();
- $this->Cell(0,8,"Terms & Conditions: ",0,0,'L',0);
- $this->Ln();
- $this->Cell(0,8,$conditions,0,0,'L',0);
-}
-}
 //$bdata = array("aaaaaaaaa","48/1,Katcherry Street","Rasipuram","Namakkal (D.T)");
 //$sdata = array("bbbbbb","48/9","","mmmm","Don City");
 $iHead = array("Company","Purchase Order No.","Date","Requisition No.");
 $iCustHeadDtls = array("Customer Name","Tracking No","Due Date");
 //$iCustData = array("Nortel Networks","usc-107565","26-05-2005");
-$iHeadDtls = array("Product Name","Quantity","List Price","Unit Price","Total");
+$iHeadDtls = array("Quantity","Product Name","List Price","Unit Price","Total");
 
-$pdf = new PDF('P','mm','A4');
-$pdf->SetFont('Arial','',10);
+$pdf = new PDFSheet();
+$pdf->setInvoiceHeader($title,$logo_name,$companyaddress);
+$pdf->setInvoiceFooter(SALES_TERMS,$conditions);
 $pdf->AddPage();
-$pdf->setInvoiceTitle("Purchase Order",$logo_name,$companyaddress);
 $pdf->Ln();
-$pdf->setInvoiceDetails($iHead,$iData);
 $pdf->setAddress($bdata,$sdata);
-$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
+$pdf->setInvoiceSummary(SALES_REQUISITION,$id,
+                        SALES_VENDOR,$vendor_name,
+                        SALES_DATE);
 $pdf->setProductDetails($iHeadDtls,$iDataDtls);
 $pdf->setTotal($price_total,$conditions);
-$pdf->Output();
+$pdf->Output('Order.pdf','D');
 ?>

--- CreateSOPDF.php.orig 2005-10-20 16:15:39.555010888 -0400
+++ CreateSOPDF.php.new 2005-10-20 16:54:29.014879160 -0400
@@ -8,15 +8,24 @@
  * All Rights Reserved.
 *
  ********************************************************************************/
-require('include/fpdf/fpdf.php');
+require('include/PDFSheet.php');
 require_once('modules/Orders/SalesOrder.php');
 
+define('SALES_TERMS',          $app_strings['SALES_TERMS']);
+define('SALES_SERVICE_NUMBER', $app_strings['SALES_SERVICE_NUMBER']);
+define('SALES_SALESPERSON',    $app_strings['SALES_SALESPERSON']);
+define('SALES_DATE',           $app_strings['SALES_DATE']);
+
 $id = $_REQUEST['record'];
 global $adb;
 //retreiving the invoice info
 $focus = new SalesOrder();
 $focus->retrieve_entity_info($_REQUEST['record'],"SalesOrder");
+
 $account_name = getAccountName($focus->column_fields[account_id]);
+$title        = $focus->column_fields['subject'];
+$salesperson  = $current_user->first_name .' '. $current_user->last_name;
+
 $iData[] = $account_name;
 $iData[] = $id;
 $iData[] = date('Y-m-d');
@@ -229,211 +238,35 @@
 
  $temp_data['productname'] = $productname;
  $temp_data['qty'] = $qty;
- $temp_data['unitprice'] = $unitprice;
- $temp_data['listprice'] = $listprice;
- $temp_data['total'] = $total;
+ $temp_data['unitprice'] = sprintf('%0.2f',$unitprice);
+ $temp_data['listprice'] = sprintf('%0.2f',$listprice);
+ $temp_data['total']     = sprintf('%0.2f',$total);
  $iDataDtls[] = $temp_data;
 
 }
 //getting the Total Array
-$price_total[] = $focus->column_fields["hdnSubTotal"];
-$price_total[] = $focus->column_fields["txtTax"];
-$price_total[] = $focus->column_fields["txtAdjustment"];
-$price_total[] = $focus->column_fields["hdnGrandTotal"];
-
-class PDF extends FPDF
-{
-
-// Invoice Title
-function setInvoiceTitle($title,$logo_name,$caddress)
-{
- if($title != "")
- {
- if(isset($logo_name) && $logo_name != '')
- {
- $this->Image('test/logo/'.$logo_name,10,10,0,0);
- }
- else
- {
- //$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0);
- }
- for($i=0;$i<count($caddress);$i++)
- {
-
- $this->Ln();
- $this->Cell(40);
- $this->SetFont('','',10);
- $this->Cell(0,5,$caddress[$i],0,0,'L',0);
- }
- $this->Ln();
- $this->SetFillColor(224,235,255);
-     $this->SetTextColor(0);
-     $this->SetFont('','B',18);
-     $this->Cell(0,10,$title,0,0,'C',0);
+$price_total[] = sprintf('%0.2f', $focus->column_fields["hdnSubTotal"]);
+$price_total[] = sprintf('%0.2f', $focus->column_fields["txtTax"]);
+$price_total[] = sprintf('%0.2f', $focus->column_fields["txtAdjustment"]);
+$price_total[] = sprintf('%0.2f', $focus->column_fields["hdnGrandTotal"]);
 
- }
-}
-//Invoice Address
-function setAddress($billing="",$shipping="")
-{
-
- $this->Ln();
- $this->SetFillColor(224,235,255);
- $this->SetTextColor(0);
-     $this->SetFont('','B',10);
- $this->Cell(130,10,"Bill To:",0,0,'L',0);
- $this->Cell(0,10,"Ship To:",0,0,'L',0);
- for($i=0;$i<count($billing);$i++)
- {
- $this->Cell(17);
- $this->SetFont('','',10);
- $this->Cell(130,5,$billing[$i],0,0,'L',0);
- $this->Cell(0,5,$shipping[$i],0,0,'L',0);
- $this->Ln();
- }
-
-}
-//Invoice from
-function setInvoiceDetails($iHeader,$iData)
-{
-    $this->Ln();
-    $this->SetFillColor(162,200,243);
-    $this->SetTextColor(0);
-    $this->SetDrawColor(61,121,206);
-    //$this->SetLineWidth(.3);
-    $this->SetFont('Arial','B',10);
-    //Header
-    $this->Cell(15);
-    foreach($iHeader as $value)
-    {
-        $this->Cell(40,7,$value,1,0,'L',1);
-    }
-    $this->Ln();
-    $this->SetFillColor(233,241,253);
-    $this->SetTextColor(0);
-    $this->SetFont('');
-    //Data
-    $this->Cell(15);
-    $fill=0;
-    foreach($iData as $value)
-    {
- $this->Cell(40,6,$value,1,0,'L',0);
-    }
-    $this->Ln();
-}
-
-//customer Details
-function setCustomerDetails($iCHeader,$iCData)
-{
-    $this->Ln();
-    //$this->Cell(0);
-    $this->SetFillColor(162,200,243);
-    $this->SetTextColor(0);
-    $this->SetDrawColor(61,121,206);
-    //$this->SetLineWidth(.3);
-    $this->SetFont('Arial','B',10);
-    //Header
-    //$this->Cell(15);
-    foreach($iCHeader as $value)
-    {
-        $this->Cell(63,7,$value,1,0,'L',1);
-    }
-    $this->Ln();
-    $this->SetFillColor(233,241,253);
-    $this->SetTextColor(0);
-    $this->SetFont('');
-    //Data
-    //$this->Cell(15);
-    $fill=0;
-    foreach($iCData as $value)
-    {
- $this->Cell(63,6,$value,1,0,'L',0);
-    }
-    $this->Ln();
-}
-
-//Product Details
-function setProductDetails($ivHeader,$ivData)
-{
-    $this->Ln();
-    $this->Ln();
-    $this->SetFillColor(162,200,243);
-    $this->SetTextColor(0);
-    $this->SetDrawColor(61,121,206);
-    $this->SetLineWidth(.3);
-    $this->SetFont('Arial','B',10);
-    //Header
-    foreach($ivHeader as $value)
-    {
-        $this->Cell(38,7,$value,0,0,'L',0);
-    }
-    $this->Ln();
-    $this->SetDrawColor(0,0,0);
-    $this->SetLineWidth(.5);
-    $this->line(10,140,200,140);
-    $this->SetFillColor(233,241,253);
-    $this->SetTextColor(0);
-    $this->SetFont('');
-    //Data
-    $fill=0;
-     foreach($ivData as $key=>$value)
- {
-     $this->Cell(38,6,$value['productname'],0,0,'L',0);
- $this->Cell(38,6,$value['qty'],0,0,'L',0);
- $this->Cell(38,6,$value['unitprice'],0,0,'L',0);
- $this->Cell(38,6,$value['listprice'],0,0,'L',0);
- $this->Cell(38,6,$value['total'],0,0,'R',0);
- $this->Ln();
- }
-    $this->Ln();
-}
-
-function setTotal($price_total="",$conditions="")
-{
- $this->Ln();
- $this->SetDrawColor(0,0,0);
- $this->SetLineWidth(.3);
-// $this->line(10,200,200,200);
- $this->SetFillColor(224,235,255);
- $this->SetTextColor(0);
-     $this->SetFont('','B',10);
- $this->Cell(140,6,"Sub Total: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[0],1,0,'R',0);
-     $this->Ln(4);
- $this->Ln(4);
- $this->Cell(140,6,"Tax: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[1],1,0,'R',0);
- $this->Ln(4);
- $this->Ln(4);
- $this->Cell(140,6,"Adjustment: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[2],1,0,'R',0);
-     $this->Ln(4);
- $this->Ln(4);
- $this->Cell(140,6,"Grand total: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[3],1,0,'R',0);
- $this->Ln();
- $this->Ln();
- $this->Cell(0,8,"Terms & Conditions: ",0,0,'L',0);
- $this->Ln();
- $this->Cell(0,8,$conditions,0,0,'L',0);
-}
-}
 //$bdata = array("aaaaaaaaa","48/1,Katcherry Street","Rasipuram","Namakkal (D.T)");
 //$sdata = array("bbbbbb","48/9","","mmmm","Don City");
 $iHead = array("Company","Sales Order No.","Date","Quote Name.");
 $iCustHeadDtls = array("Customer Name","Purchase Order","Due Date");
 //$iCustData = array("Nortel Networks","usc-107565","26-05-2005");
-$iHeadDtls = array("Product Name","Quantity","List Price","Unit Price","Total");
+$iHeadDtls = array("Quantity","Product Name","List Price","Unit Price","Total");
 
-$pdf = new PDF('P','mm','A4');
-$pdf->SetFont('Arial','',10);
+$pdf = new PDFSheet();
+$pdf->setInvoiceHeader($title,$logo_name,$companyaddress);
+$pdf->setInvoiceFooter(SALES_TERMS, $conditions);
 $pdf->AddPage();
-$pdf->setInvoiceTitle("Sales Order",$logo_name,$companyaddress);
 $pdf->Ln();
-$pdf->setInvoiceDetails($iHead,$iData);
 $pdf->setAddress($bdata,$sdata);
-$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
+$pdf->setInvoiceSummary(SALES_SERVICE_NUMBER, $id,
+                        SALES_SALESPERSON,    $salesperson,
+                        SALES_DATE);
 $pdf->setProductDetails($iHeadDtls,$iDataDtls);
 $pdf->setTotal($price_total,$conditions);
-$pdf->Output();
+$pdf->Output('Order.pdf', 'D');
 ?>

--- CreatePDF.php.orig 2005-10-19 09:36:52.000000000 -0400
+++ CreatePDF.php.new 2005-10-20 16:52:08.721207040 -0400
@@ -8,8 +8,15 @@
  * All Rights Reserved.
 *
  ********************************************************************************/
-require('include/fpdf/fpdf.php');
+require('include/PDFSheet.php');
 require_once('modules/Quotes/Quote.php');
+define('QUOTE_BILLING_HEADER', $app_strings['QUOTE_BILLING_HEADER']);
+define('QUOTE_SERVICE_HEADER', $app_strings['QUOTE_SERVICE_HEADER']);
+define('QUOTE_TITLE',          $app_strings['QUOTE_TITLE']);
+define('QUOTE_SERVICE_NUMBER', $app_strings['QUOTE_SERVICE_NUMBER']);
+define('QUOTE_DATE',           $app_strings['QUOTE_DATE']);
+define('QUOTE_SALESPERSON',    $app_strings['QUOTE_SALESPERSON']);
+define('QUOTE_TERMS',          $app_strings['QUOTE_TERMS']);
 
 $id = $_REQUEST['record'];
 global $adb;
@@ -17,13 +24,16 @@
 $focus = new Quote();
 $focus->retrieve_entity_info($_REQUEST['record'],"Quotes");
 $account_name = getAccountName($focus->column_fields[account_id]);
-$iData[] = $account_name;
+$iData = array($account_name);
 $iData[] = $id;
 $iData[] = date('Y-m-d');
 
 //setting the Customer Data
-$iCustData[] = $account_name;
+//code contributed by Tyler Bannister for inproving quotes
+$iCustData = array($account_name);
 
+$title = $focus->column_fields['subject'];
+$salesperson = $current_user->first_name .' '. $current_user->last_name;
 if($focus->column_fields["duedate"] != '')
 {
  $due_date = $focus->column_fields["validtill"];
@@ -35,7 +45,7 @@
 $iCustData[] = $due_date;
 
 //setting the billing address
-$bdata[] = $account_name;
+$bdata = array('', $account_name);
 if($focus->column_fields["bill_street"] != '')
 {
         $bill_street = $focus->column_fields["bill_street"];
@@ -70,16 +80,16 @@
  $bdata[] = $bill_country;
 }
 
-for($i =0; $i <5; $i++)
+for($i =0; $i <10; $i++)
 {
- if(sizeof($bdata) < 6)
+ if(sizeof($bdata) < 11)
  {
  $bdata[] = ' ';
  }
 }
 
 //setting the shipping address
-$sdata[] = $account_name;
+$sdata = array('', $account_name);
 if($focus->column_fields["ship_street"] != '')
 {
         $ship_street = $focus->column_fields["ship_street"];
@@ -113,9 +123,9 @@
  $sdata[] = $ship_country;
 }
 
-for($i =0; $i <5; $i++)
+for($i =0; $i <10; $i++)
 {
- if(sizeof($sdata) < 6)
+ if(sizeof($sdata) < 11)
  {
  $sdata[] = ' ';
  }
@@ -143,14 +153,14 @@
 
 if($num_rows == 1)
 {
- $org_name = $adb->query_result($result,0,"organizationame");
+ $org_name    = $adb->query_result($result,0,"organizationame");
  $org_address = $adb->query_result($result,0,"address");
- $org_city = $adb->query_result($result,0,"city");
- $org_state = $adb->query_result($result,0,"state");
+ $org_city    = $adb->query_result($result,0,"city");
+ $org_state   = $adb->query_result($result,0,"state");
  $org_country = $adb->query_result($result,0,"country");
- $org_code = $adb->query_result($result,0,"code");
- $org_phone = $adb->query_result($result,0,"phone");
- $org_fax = $adb->query_result($result,0,"fax");
+ $org_code    = $adb->query_result($result,0,"code");
+ $org_phone   = $adb->query_result($result,0,"phone");
+ $org_fax     = $adb->query_result($result,0,"fax");
  $org_website = $adb->query_result($result,0,"website");
 
  if($org_name != '')
@@ -159,19 +169,22 @@
  }
  if($org_address != '' || $org_city != '' || $org_state != '')
  {
- $companyaddress[] = $org_address.' '.$org_city.' '.$org_state;
+ $companyaddress[] = $org_address;
+ $companyaddress[] = $org_city .', '.$org_state;
  }
  if($org_country != '' || $org_code!= '')
  {
  $companyaddress[] = $org_country.' '.$org_code;
  }
+ $companyaddress[] = '';
  if($org_phone != '' || $org_fax != '')
  {
- $companyaddress[] = $org_phone.' '.$org_fax;
+ $companyaddress[] = $app_strings['Phone_Short'] .': '. $org_phone;
+ $companyaddress[] = $app_strings['Fax'] .': '. $org_fax;
  }
  if($org_website != '')
  {
- $companyaddress[] = $org_website;
+ $companyaddress[] = $app_strings['Website_Short']. ': '. $org_website;
  }
 
  for($i =0; $i < 4; $i++)
@@ -188,6 +201,8 @@
 
 
 
+//$companyaddress = Array('AdventNet, Inc.','11 Sarathy Nagar','Velachery','Vijayanagar','Chennai - 600042');
+
 //getting the Product Data
 $query="select products.productname,products.unit_price,quotesproductrel.* from quotesproductrel inner join products on products.productid=quotesproductrel.productid where quoteid=".$id;
 
@@ -205,211 +220,36 @@
 
  $temp_data['productname'] = $productname;
  $temp_data['qty'] = $qty;
- $temp_data['unitprice'] = $unitprice;
- $temp_data['listprice'] = $listprice;
- $temp_data['total'] = $total;
+ $temp_data['unitprice'] = sprintf('%0.2f',$unitprice);
+ $temp_data['listprice'] = sprintf('%0.2f',$listprice);
+ $temp_data['total']     = sprintf('%0.2f',$total);
  $iDataDtls[] = $temp_data;
 
 }
 //getting the Total Array
-$price_total[] = $focus->column_fields["hdnSubTotal"];
-$price_total[] = $focus->column_fields["txtTax"];
-$price_total[] = $focus->column_fields["txtAdjustment"];
-$price_total[] = $focus->column_fields["hdnGrandTotal"];
-
-class PDF extends FPDF
-{
+$price_total[] = sprintf('%0.2f',$focus->column_fields["hdnSubTotal"]);
+$price_total[] = sprintf('%0.2f',$focus->column_fields["txtTax"]);
+$price_total[] = sprintf('%0.2f',$focus->column_fields["txtAdjustment"]);
+$price_total[] = sprintf('%0.2f',$focus->column_fields["hdnGrandTotal"]);
 
-// Invoice Title
-function setInvoiceTitle($title,$logo_name,$caddress)
-{
- if($title != "")
- {
- if(isset($logo_name) && $logo_name != '')
- {
- $this->Image('test/logo/'.$logo_name,10,10,0,0);
- }
- else
- {
- //$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0);
- }
- for($i=0;$i<count($caddress);$i++)
- {
-
- $this->Ln();
- $this->Cell(40);
- $this->SetFont('','',10);
- $this->Cell(0,5,$caddress[$i],0,0,'L',0);
- }
- $this->Ln();
- $this->SetFillColor(224,235,255);
-     $this->SetTextColor(0);
-     $this->SetFont('','B',18);
-     $this->Cell(0,10,$title,0,0,'C',0);
-
- }
-}
-//Invoice Address
-function setAddress($billing="",$shipping="")
-{
-
- $this->Ln();
- $this->SetFillColor(224,235,255);
- $this->SetTextColor(0);
-     $this->SetFont('','B',10);
- $this->Cell(130,10,"Bill To:",0,0,'L',0);
- $this->Cell(0,10,"Ship To:",0,0,'L',0);
- for($i=0;$i<count($billing);$i++)
- {
- $this->Cell(17);
- $this->SetFont('','',10);
- $this->Cell(130,5,$billing[$i],0,0,'L',0);
- $this->Cell(0,5,$shipping[$i],0,0,'L',0);
- $this->Ln();
- }
-
-}
-//Invoice from
-function setInvoiceDetails($iHeader,$iData)
-{
-    $this->Ln();
-    $this->SetFillColor(162,200,243);
-    $this->SetTextColor(0);
-    $this->SetDrawColor(61,121,206);
-    //$this->SetLineWidth(.3);
-    $this->SetFont('Arial','B',10);
-    //Header
-    $this->Cell(15);
-    foreach($iHeader as $value)
-    {
-        $this->Cell(40,7,$value,1,0,'L',1);
-    }
-    $this->Ln();
-    $this->SetFillColor(233,241,253);
-    $this->SetTextColor(0);
-    $this->SetFont('');
-    //Data
-    $this->Cell(15);
-    $fill=0;
-    foreach($iData as $value)
-    {
- $this->Cell(40,6,$value,1,0,'L',0);
-    }
-    $this->Ln();
-}
-
-//customer Details
-function setCustomerDetails($iCHeader,$iCData)
-{
-    $this->Ln();
-    //$this->Cell(0);
-    $this->SetFillColor(162,200,243);
-    $this->SetTextColor(0);
-    $this->SetDrawColor(61,121,206);
-    //$this->SetLineWidth(.3);
-    $this->SetFont('Arial','B',10);
-    //Header
-    //$this->Cell(15);
-    foreach($iCHeader as $value)
-    {
-        $this->Cell(63,7,$value,1,0,'L',1);
-    }
-    $this->Ln();
-    $this->SetFillColor(233,241,253);
-    $this->SetTextColor(0);
-    $this->SetFont('');
-    //Data
-    //$this->Cell(15);
-    $fill=0;
-    foreach($iCData as $value)
-    {
- $this->Cell(63,6,$value,1,0,'L',0);
-    }
-    $this->Ln();
-}
-
-//Product Details
-function setProductDetails($ivHeader,$ivData)
-{
-    $this->Ln();
-    $this->Ln();
-    $this->SetFillColor(162,200,243);
-    $this->SetTextColor(0);
-    $this->SetDrawColor(61,121,206);
-    $this->SetLineWidth(.3);
-    $this->SetFont('Arial','B',10);
-    //Header
-    foreach($ivHeader as $value)
-    {
-        $this->Cell(38,7,$value,0,0,'L',0);
-    }
-    $this->Ln();
-    $this->SetDrawColor(0,0,0);
-    $this->SetLineWidth(.5);
-    $this->line(10,140,200,140);
-    $this->SetFillColor(233,241,253);
-    $this->SetTextColor(0);
-    $this->SetFont('');
-    //Data
-    $fill=0;
-     foreach($ivData as $key=>$value)
- {
-     $this->Cell(38,6,$value['productname'],0,0,'L',0);
- $this->Cell(38,6,$value['qty'],0,0,'L',0);
- $this->Cell(38,6,$value['unitprice'],0,0,'L',0);
- $this->Cell(38,6,$value['listprice'],0,0,'L',0);
- $this->Cell(38,6,$value['total'],0,0,'R',0);
- $this->Ln();
- }
-    $this->Ln();
-}
-
-function setTotal($price_total="",$conditions="")
-{
- $this->Ln();
- $this->SetDrawColor(0,0,0);
- $this->SetLineWidth(.3);
-// $this->line(10,200,200,200);
- $this->SetFillColor(224,235,255);
- $this->SetTextColor(0);
-     $this->SetFont('','B',10);
- $this->Cell(140,6,"Sub Total: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[0],1,0,'R',0);
-     $this->Ln(4);
- $this->Ln(4);
- $this->Cell(140,6,"Tax: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[1],1,0,'R',0);
- $this->Ln(4);
- $this->Ln(4);
- $this->Cell(140,6,"Adjustment: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[2],1,0,'R',0);
-     $this->Ln(4);
- $this->Ln(4);
- $this->Cell(140,6,"Grand total: ",0,0,'R',0);
- $this->Cell(0,6,$price_total[3],1,0,'R',0);
- $this->Ln();
- $this->Ln();
- $this->Cell(0,8,"Terms & Conditions: ",0,0,'L',0);
- $this->Ln();
- $this->Cell(0,8,$conditions,0,0,'L',0);
-}
-}
 //$bdata = array("aaaaaaaaa","48/1,Katcherry Street","Rasipuram","Namakkal (D.T)");
 //$sdata = array("bbbbbb","48/9","","mmmm","Don City");
 $iHead = array("Company","Quote No.","Date");
 $iCustHeadDtls = array("Customer Name","Valid Till");
 //$iCustData = array("Nortel Networks","usc-107565","26-05-2005");
-$iHeadDtls = array("Product Name","Quantity","List Price","Unit Price","Total");
+$iHeadDtls = array("Quantity", "Product Name","List Price","Unit Price","Total");
 
-$pdf = new PDF('P','mm','A4');
-$pdf->SetFont('Arial','',10);
+$pdf = new PDFSheet();
+$pdf->setInvoiceHeader($title,$logo_name,$companyaddress);
+$pdf->setInvoiceFooter(QUOTE_TERMS, $conditions);
 $pdf->AddPage();
-$pdf->setInvoiceTitle("Quotes",$logo_name,$companyaddress);
 $pdf->Ln();
-$pdf->setInvoiceDetails($iHead,$iData);
 $pdf->setAddress($bdata,$sdata);
-$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
+$pdf->setInvoiceSummary(QUOTE_SERVICE_NUMBER,$id,
+                        QUOTE_SALESPERSON,$salesperson,
+                        QUOTE_DATE);
 $pdf->setProductDetails($iHeadDtls,$iDataDtls);
 $pdf->setTotal($price_total,$conditions);
-$pdf->Output();
+$pdf->Output('Quote.pdf','D');
+exit;
 ?>

FPDF($orientation,$unit,$format); $this->pdf_font = $font; $this->SetFont($this->pdf_font,'',10); } function Header() { if ($this->header_image != '') { $this->Image($this->header_image,10,10,0,0); } else { // $this->Image('themes/Aqua/images/blank.jpg',10,10,0,0); } if ($this->header_title != '') { $this->SetFillColor($this->pdf_fill_color[0], $this->pdf_fill_color[1], $this->pdf_fill_color[2]); $this->SetTextColor($this->title_text_color[0], $this->title_text_color[1], $this->title_text_color[2]); $this->Cell(80); $this->SetFont($this->pdf_font,'B',18); $this->Cell(30,10,$this->header_title,0,0,'C',0); } $this->SetTextColor($this->pdf_text_color[0], $this->pdf_text_color[1], $this->pdf_text_color[2]); $this->SetY(5); if (is_array($this->header_address)) { for($i=0;$iheader_address);$i++) { $this->Cell(150); $this->SetFont($this->pdf_font,'',8); $this->Cell(0,5,$this->header_address[$i],0,0,'L',0); $this->Ln(3.2); } } } function Footer() { $this->SetY(-20); $this->Cell(0,8,$this->footer_title,0,0,'C',0); $this->Ln(); $this->Cell(0,8,$this->footer_terms,0,0,'L',0); } function drawHeader($header,$width=40,$height=7) { $this->SetFillColor($this->header_fill_color[0], $this->header_fill_color[1], $this->header_fill_color[2]); $this->SetTextColor($this->header_text_color[0], $this->header_text_color[1], $this->header_text_color[2]); $this->SetDrawColor($this->table_border_color[0], $this->table_border_color[1], $this->table_border_color[2]); $this->SetFont($this->pdf_font,'B',10); $this->Cell($width,$height,$header,1,0,'C',1); $this->Ln(); } function drawCell($data,$width=40,$height=7) { $this->SetFont($this->pdf_font,'',8); $this->SetFillColor($this->table_fill_color[0], $this->table_fill_color[1], $this->table_fill_color[2]); $this->SetTextColor($this->table_text_color[0], $this->table_text_color[1], $this->table_text_color[2]); $this->Cell($width,$height,$data,1,0,'C',1); $this->Ln($height); } // $headers should be a one-dimensional array of headers // $data should be a two-dimensional array of data // $col_size should be a one-dimensional array of column widths function drawTable($headers, $data, $col_size = '', $x = -1, $y = -1) { if ($x != -1) { $this->SetLeftMargin($x); $this->SetX($x); } if ($y != -1) { $this->SetY($y); } if ($col_size == '') { $col_size = array_fill(0,sizeof($headers)-1, 190 / sizeof($headers)); } $this->SetFillColor($this->header_fill_color[0], $this->header_fill_color[1], $this->header_fill_color[2]); $this->SetTextColor($this->header_text_color[0], $this->header_text_color[1], $this->header_text_color[2]); $this->SetDrawColor($this->table_border_color[0], $this->table_border_color[1], $this->table_border_color[2]); $this->SetFont($this->pdf_font,'B',10); foreach ($headers as $num => $cell) { $this->Cell($col_size[$num],7,$cell,1,0,'C',1); } $this->Ln(); $size = 3.2; $this->SetFont($this->pdf_font,'',8); $this->SetFillColor($this->table_fill_color[0], $this->table_fill_color[1], $this->table_fill_color[2]); $this->SetTextColor($this->table_text_color[0], $this->table_text_color[1], $this->table_text_color[2]); $borders = 'LRT'; foreach ($data as $row => $set) { if ($row == 1) { $borders = 'LR'; } if ($row == sizeof($data) - 1) { $borders = 'LRB'; } if (is_array($set)) { foreach($set as $num => $cell) { $this->Cell($col_size[$num],$size,$cell,$borders,0,'L',1); } } else { $this->Cell($col_size[$num],$size,$set,$borders,0,'L',1); } $this->Ln($size); } if ($x != -1) { $this->SetLeftMargin(10); $this->SetX(10); } } // Invoice Title function setInvoiceHeader($title='',$logo_name='',$caddress='') { if(isset($logo_name) && $logo_name != '') { $this->header_image = 'test/logo/'.$logo_name; } $this->header_address = $caddress; $this->header_title = $title; } function setInvoiceFooter($title='', $terms='') { $this->footer_title = $title; $this->footer_terms = $terms; } // Invoice Address // Both $billing and $shipping should be arrays function setAddress($billing=array(), $shipping=array()) { $this->drawTable(array(SHEET_BILLING_HEADER),$billing, array(65),10,35); $this->drawTable(array(SHEET_SERVICE_HEADER),$shipping,array(65),85,35); } function setInvoiceSummary($service_title, $serviceid, $sales_title, $salesperson = '', $date_title) { $this->SetLeftMargin(160); $this->SetX(160); $this->SetY(35); $date = date('F j, Y'); $this->drawHeader($service_title); $this->drawCell($serviceid); $this->drawHeader($date_title); $this->drawCell($date); $this->drawHeader($sales_title); $this->drawCell($salesperson); $this->SetLeftMargin(10); $this->SetX(10); } //Product Details function setProductDetails($ivHeader,$ivData) { $this->Ln(); $this->Ln(); $data = array(); $col_sizes = array(20,110,20,20,20); foreach($ivData as $key=>$value) { $data[] = array($value['qty'], $value['productname'], $value['listprice'], $value['unitprice'], $value['total']); } $this->drawTable($ivHeader, $data, $col_sizes); } function setTotal($price_total="",$conditions="") { $this->Ln(); $this->SetDrawColor($this->divider_color[0], $this->divider_color[1], $this->divider_color[2]); $this->SetLineWidth(.3); // $this->line(10,200,200,200); $this->SetFillColor($this->table_fill_color[0], $this->table_fill_color[1], $this->table_fill_color[2]); $this->SetTextColor($this->table_text_color[0], $this->table_text_color[1], $this->table_text_color[2]); $this->SetFont($this->pdf_font,'B',10); $this->Cell(140,6,SHEET_SUBTOTAL,0,0,'R',0); $this->Cell(0,6,$price_total[0],1,0,'R',0); $this->Ln(4); $this->Ln(4); $this->Cell(140,6,SHEET_TAX,0,0,'R',0); $this->Cell(0,6,$price_total[1],1,0,'R',0); $this->Ln(4); $this->Ln(4); $this->Cell(140,6,SHEET_ADJUST,0,0,'R',0); $this->Cell(0,6,$price_total[2],1,0,'R',0); $this->Ln(4); $this->Ln(4); $this->Cell(140,6,SHEET_TOTAL,0,0,'R',0); $this->Cell(0,6,$price_total[3],1,0,'R',0); $this->Ln(); $this->Ln(); } } ?>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: More PDF Improvements

Sergio A. Kessler-2
hi tyler, are you diffing over cvs or over the v4.2 patch2 ?

/sergio
ps: can we configure the mailing list so the replys go to the list so
everyone can follow the conversation ?


On 10/20/05, Tyler Bannister <[hidden email]> wrote:

> After I finished the PDF improvement to the Quotes module it was brought
> to my attention that there are four seperate CreatePDF files.  So I made
> some changes so they will all use the new format and a common PDF
> creation object.  I created a PDFSheet.php file to placed in the
> includes directory and I've included patch files to fix the
> modules/Quotes/CreatePDF.php, modules/Orders/CreatePDF.php,
> modules/Orders/CreateSOPDF.php, and
> modules/Invoice/CreatePDF.php files.
>
> In addition some of the content of the display text in each module has
> been moved to the includes/languages/en_us.lang.php file,
> requiring the
> following entries to be added to the app_strings array (I inserted them
> at line 500):
> 'INVOICE_ID'           => 'Invoice No.',
> 'INVOICE_DATE'         => 'Date',
> 'INVOICE_ACCOUNT'      => 'Account Name',
> 'INVOICE_TERMS'        => 'Terms & Conditions',
>
> 'QUOTE_TITLE'          => 'Service Quote',
> 'QUOTE_SERVICE_NUMBER' => 'Service Number',
> 'QUOTE_DATE'           => 'Date',
> 'QUOTE_SALESPERSON'    => 'Account Executive',
> 'QUOTE_TERMS'          => 'Terms & Conditions',
>
> 'SALES_REQUISITION'    => 'Requisition No.',
> 'SALES_SERVICE_NUMBER' => 'Sales No.',
> 'SALES_TERMS'          => 'Terms & Conditions',
> 'SALES_VENDOR'         => 'Vendor',
> 'SALES_DATE'           => 'Date',
> 'SALES_SALESPERSON'    => 'Account Executive',
>
> 'SHEET_ADJUST'         => 'Adjustment: ',
> 'SHEET_BILLING_HEADER' => 'Billing Address',
> 'SHEET_SERVICE_HEADER' => 'Service Address',
> 'SHEET_SUBTOTAL'       => 'Sub Total: ',
> 'SHEET_TAX'            => 'Tax: ',
> 'SHEET_TOTAL'          => 'Grand Total: ',
>
> --
> Tyler Bannister
> NetAccess Systems Inc.
> 905-524-2001 xt432
>
>
>
> --- CreatePDF.php.orig  2005-10-20 16:56:18.904173448 -0400
> +++ CreatePDF.php.new   2005-10-20 16:54:59.772203336 -0400
> @@ -8,15 +8,23 @@
>   * All Rights Reserved.
>  *
>
> ********************************************************************************/
> -require('include/fpdf/fpdf.php');
> +require('include/PDFSheet.php');
>  require_once('modules/Invoice/Invoice.php');
>
> +define('INVOICE_ID',      $app_strings['INVOICE_ID']);
> +define('INVOICE_ACCOUNT',
> $app_strings['INVOICE_ACCOUNT']);
> +define('INVOICE_DATE',    $app_strings['INVOICE_DATE']);
> +define('INVOICE_TERMS',   $app_strings['INVOICE_TERMS']);
> +
>  $id = $_REQUEST['record'];
>  global $adb;
>  //retreiving the invoice info
>  $focus = new Invoice();
> $focus->retrieve_entity_info($_REQUEST['record'],"Invoice");
> +
>  $account_name =
> getAccountName($focus->column_fields[account_id]);
> +$title       = $focus->column_fields['subject'];
> +
>  $iData[] = $account_name;
>  $iData[] = $id;
>  $iData[] = date('Y-m-d');
> @@ -226,211 +234,35 @@
>
>         $temp_data['productname'] = $productname;
>         $temp_data['qty'] = $qty;
> -       $temp_data['unitprice'] = $unitprice;
> -       $temp_data['listprice'] = $listprice;
> -       $temp_data['total'] = $total;
> +       $temp_data['unitprice'] = sprintf('%0.2f',$unitprice);
> +       $temp_data['listprice'] = sprintf('%0.2f',$listprice);
> +       $temp_data['total']     = sprintf('%0.2f',$total);
>         $iDataDtls[] = $temp_data;
>
>  }
>  //getting the Total Array
> -$price_total[] = $focus->column_fields["hdnSubTotal"];
> -$price_total[] = $focus->column_fields["txtTax"];
> -$price_total[] = $focus->column_fields["txtAdjustment"];
> -$price_total[] = $focus->column_fields["hdnGrandTotal"];
> -
> -class PDF extends FPDF
> -{
> -
> -// Invoice Title
> -function setInvoiceTitle($title,$logo_name,$caddress)
> -{
> -       if($title != "")
> -       {
> -               if(isset($logo_name) && $logo_name != '')
> -               {
> -
> $this->Image('test/logo/'.$logo_name,10,10,0,0);
> -               }
> -               else
> -               {
> -
> //$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0);
> -               }
> -               for($i=0;$i<count($caddress);$i++)
> -               {
> -
> -                       $this->Ln();
> -                       $this->Cell(40);
> -                       $this->SetFont('','',10);
> -
> $this->Cell(0,5,$caddress[$i],0,0,'L',0);
> -               }
> -               $this->Ln();
> -               $this->SetFillColor(224,235,255);
> -               $this->SetTextColor(0);
> -               $this->SetFont('','B',18);
> -               $this->Cell(0,10,$title,0,0,'C',0);
> +$price_total[] =
> sprintf('%0.2f',$focus->column_fields["hdnSubTotal"]);
> +$price_total[] =
> sprintf('%0.2f',$focus->column_fields["txtTax"]);
> +$price_total[] =
> sprintf('%0.2f',$focus->column_fields["txtAdjustment"]);
> +$price_total[] =
> sprintf('%0.2f',$focus->column_fields["hdnGrandTotal"]);
>
> -       }
> -}
> -//Invoice Address
> -function setAddress($billing="",$shipping="")
> -{
> -
> -       $this->Ln();
> -       $this->SetFillColor(224,235,255);
> -       $this->SetTextColor(0);
> -       $this->SetFont('','B',10);
> -       $this->Cell(130,10,"Bill To:",0,0,'L',0);
> -       $this->Cell(0,10,"Ship To:",0,0,'L',0);
> -       for($i=0;$i<count($billing);$i++)
> -       {
> -               $this->Cell(17);
> -               $this->SetFont('','',10);
> -               $this->Cell(130,5,$billing[$i],0,0,'L',0);
> -               $this->Cell(0,5,$shipping[$i],0,0,'L',0);
> -               $this->Ln();
> -       }
> -
> -}
> -//Invoice from
> -function setInvoiceDetails($iHeader,$iData)
> -{
> -    $this->Ln();
> -    $this->SetFillColor(162,200,243);
> -    $this->SetTextColor(0);
> -    $this->SetDrawColor(61,121,206);
> -    //$this->SetLineWidth(.3);
> -    $this->SetFont('Arial','B',10);
> -    //Header
> -    $this->Cell(15);
> -    foreach($iHeader as $value)
> -    {
> -        $this->Cell(40,7,$value,1,0,'L',1);
> -    }
> -    $this->Ln();
> -    $this->SetFillColor(233,241,253);
> -    $this->SetTextColor(0);
> -    $this->SetFont('');
> -    //Data
> -    $this->Cell(15);
> -    $fill=0;
> -    foreach($iData as $value)
> -    {
> -               $this->Cell(40,6,$value,1,0,'L',0);
> -    }
> -    $this->Ln();
> -}
> -
> -//customer Details
> -function setCustomerDetails($iCHeader,$iCData)
> -{
> -    $this->Ln();
> -    //$this->Cell(0);
> -    $this->SetFillColor(162,200,243);
> -    $this->SetTextColor(0);
> -    $this->SetDrawColor(61,121,206);
> -    //$this->SetLineWidth(.3);
> -    $this->SetFont('Arial','B',10);
> -    //Header
> -    //$this->Cell(15);
> -    foreach($iCHeader as $value)
> -    {
> -        $this->Cell(63,7,$value,1,0,'L',1);
> -    }
> -    $this->Ln();
> -    $this->SetFillColor(233,241,253);
> -    $this->SetTextColor(0);
> -    $this->SetFont('');
> -    //Data
> -    //$this->Cell(15);
> -    $fill=0;
> -    foreach($iCData as $value)
> -    {
> -               $this->Cell(63,6,$value,1,0,'L',0);
> -    }
> -    $this->Ln();
> -}
> -
> -//Product Details
> -function setProductDetails($ivHeader,$ivData)
> -{
> -    $this->Ln();
> -    $this->Ln();
> -    $this->SetFillColor(162,200,243);
> -    $this->SetTextColor(0);
> -    $this->SetDrawColor(61,121,206);
> -    $this->SetLineWidth(.3);
> -    $this->SetFont('Arial','B',10);
> -    //Header
> -    foreach($ivHeader as $value)
> -    {
> -        $this->Cell(38,7,$value,0,0,'L',0);
> -    }
> -    $this->Ln();
> -    $this->SetDrawColor(0,0,0);
> -    $this->SetLineWidth(.5);
> -    $this->line(10,140,200,140);
> -    $this->SetFillColor(233,241,253);
> -    $this->SetTextColor(0);
> -    $this->SetFont('');
> -    //Data
> -    $fill=0;
> -       foreach($ivData as $key=>$value)
> -       {
> -
> $this->Cell(38,6,$value['productname'],0,0,'L',0);
> -               $this->Cell(38,6,$value['qty'],0,0,'L',0);
> -
> $this->Cell(38,6,$value['unitprice'],0,0,'L',0);
> -
> $this->Cell(38,6,$value['listprice'],0,0,'L',0);
> -
> $this->Cell(38,6,$value['total'],0,0,'R',0);
> -               $this->Ln();
> -       }
> -    $this->Ln();
> -}
> -
> -function setTotal($price_total="",$conditions="")
> -{
> -       $this->Ln();
> -       $this->SetDrawColor(0,0,0);
> -       $this->SetLineWidth(.3);
> -//     $this->line(10,200,200,200);
> -       $this->SetFillColor(224,235,255);
> -       $this->SetTextColor(0);
> -       $this->SetFont('','B',10);
> -       $this->Cell(140,6,"Sub Total: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[0],1,0,'R',0);
> -       $this->Ln(4);
> -       $this->Ln(4);
> -       $this->Cell(140,6,"Tax: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[1],1,0,'R',0);
> -       $this->Ln(4);
> -       $this->Ln(4);
> -       $this->Cell(140,6,"Adjustment: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[2],1,0,'R',0);
> -       $this->Ln(4);
> -       $this->Ln(4);
> -       $this->Cell(140,6,"Grand total: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[3],1,0,'R',0);
> -       $this->Ln();
> -       $this->Ln();
> -       $this->Cell(0,8,"Terms & Conditions: ",0,0,'L',0);
> -       $this->Ln();
> -       $this->Cell(0,8,$conditions,0,0,'L',0);
> -}
> -}
>  //$bdata = array("aaaaaaaaa","48/1,Katcherry
> Street","Rasipuram","Namakkal (D.T)");
>  //$sdata = array("bbbbbb","48/9","","mmmm","Don City");
>  $iHead = array("Company","Invoice No.","Date","Sales Order No.");
>  $iCustHeadDtls = array("Customer Name","Purchase Order","Due Date");
>  //$iCustData = array("Nortel
> Networks","usc-107565","26-05-2005");
> -$iHeadDtls = array("Product Name","Quantity","List Price","Unit
> Price","Total");
> +$iHeadDtls = array("Quantity","Product Name","List Price","Unit
> Price","Total");
>
> -$pdf = new PDF('P','mm','A4');
> -$pdf->SetFont('Arial','',10);
> +$pdf = new PDFSheet();
> +$pdf->setInvoiceHeader($title,$logo_name,$companyaddress);
> +$pdf->setInvoiceFooter(INVOICE_TERMS,$conditions);
>  $pdf->AddPage();
> -$pdf->setInvoiceTitle("Invoice",$logo_name,$companyaddress);
>  $pdf->Ln();
> -$pdf->setInvoiceDetails($iHead,$iData);
>  $pdf->setAddress($bdata,$sdata);
> -$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
> +$pdf->setInvoiceSummary(INVOICE_ID, $id,
> +                        INVOICE_ACCOUNT, $account_name,
> +                        INVOICE_DATE);
>  $pdf->setProductDetails($iHeadDtls,$iDataDtls);
>  $pdf->setTotal($price_total,$conditions);
> -$pdf->Output();
> +$pdf->Output('Invoice.pdf','D');
>  ?>
>
>
> --- CreatePDF.php.orig  2005-10-20 15:40:57.633511064 -0400
> +++ CreatePDF.php.new   2005-10-20 16:54:13.686209472 -0400
> @@ -8,15 +8,23 @@
>   * All Rights Reserved.
>  *
>
> ********************************************************************************/
> -require('include/fpdf/fpdf.php');
> +require('include/PDFSheet.php');
>  require_once('modules/Orders/Order.php');
>
> +define('SALES_TERMS',          $app_strings['SALES_TERMS']);
> +define('SALES_REQUISITION',
> $app_strings['SALES_REQUISITION']);
> +define('SALES_VENDOR',         $app_strings['SALES_VENDOR']);
> +define('SALES_DATE',           $app_strings['SALES_DATE']);
> +
>  $id = $_REQUEST['record'];
>  global $adb;
>  //retreiving the invoice info
>  $focus = new Order();
> $focus->retrieve_entity_info($_REQUEST['record'],"Orders");
> +
>  $vendor_name =
> getVendorName($focus->column_fields[vendor_id]);
> +$title       = $focus->column_fields['subject'];
> +
>  $iData[] = $vendor_name;
>  $iData[] = $id;
>  $iData[] = date('Y-m-d');
> @@ -226,211 +234,35 @@
>
>         $temp_data['productname'] = $productname;
>         $temp_data['qty'] = $qty;
> -       $temp_data['unitprice'] = $unitprice;
> -       $temp_data['listprice'] = $listprice;
> -       $temp_data['total'] = $total;
> +       $temp_data['unitprice'] = sprintf('%0.2f',$unitprice);
> +       $temp_data['listprice'] = sprintf('%0.2f',$listprice);
> +       $temp_data['total']     = sprintf('%0.2f',$total);
>         $iDataDtls[] = $temp_data;
>
>  }
>  //getting the Total Array
> -$price_total[] = $focus->column_fields["hdnSubTotal"];
> -$price_total[] = $focus->column_fields["txtTax"];
> -$price_total[] = $focus->column_fields["txtAdjustment"];
> -$price_total[] = $focus->column_fields["hdnGrandTotal"];
> -
> -class PDF extends FPDF
> -{
> -
> -// Invoice Title
> -function setInvoiceTitle($title,$logo_name,$caddress)
> -{
> -       if($title != "")
> -       {
> -               if(isset($logo_name) && $logo_name != '')
> -               {
> -
> $this->Image('test/logo/'.$logo_name,10,10,0,0);
> -               }
> -               else
> -               {
> -
> //$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0);
> -               }
> -               for($i=0;$i<count($caddress);$i++)
> -               {
> -
> -                       $this->Ln();
> -                       $this->Cell(40);
> -                       $this->SetFont('','',10);
> -
> $this->Cell(0,5,$caddress[$i],0,0,'L',0);
> -               }
> -               $this->Ln();
> -               $this->SetFillColor(224,235,255);
> -               $this->SetTextColor(0);
> -               $this->SetFont('','B',18);
> -               $this->Cell(0,10,$title,0,0,'C',0);
> +$price_total[] =
> sprintf('%0.2f',$focus->column_fields["hdnSubTotal"]);
> +$price_total[] =
> sprintf('%0.2f',$focus->column_fields["txtTax"]);
> +$price_total[] =
> sprintf('%0.2f',$focus->column_fields["txtAdjustment"]);
> +$price_total[] =
> sprintf('%0.2f',$focus->column_fields["hdnGrandTotal"]);
>
> -       }
> -}
> -//Invoice Address
> -function setAddress($billing="",$shipping="")
> -{
> -
> -       $this->Ln();
> -       $this->SetFillColor(224,235,255);
> -       $this->SetTextColor(0);
> -       $this->SetFont('','B',10);
> -       $this->Cell(130,10,"Bill To:",0,0,'L',0);
> -       $this->Cell(0,10,"Ship To:",0,0,'L',0);
> -       for($i=0;$i<count($billing);$i++)
> -       {
> -               $this->Cell(17);
> -               $this->SetFont('','',10);
> -               $this->Cell(130,5,$billing[$i],0,0,'L',0);
> -               $this->Cell(0,5,$shipping[$i],0,0,'L',0);
> -               $this->Ln();
> -       }
> -
> -}
> -//Invoice from
> -function setInvoiceDetails($iHeader,$iData)
> -{
> -    $this->Ln();
> -    $this->SetFillColor(162,200,243);
> -    $this->SetTextColor(0);
> -    $this->SetDrawColor(61,121,206);
> -    //$this->SetLineWidth(.3);
> -    $this->SetFont('Arial','B',10);
> -    //Header
> -    $this->Cell(15);
> -    foreach($iHeader as $value)
> -    {
> -        $this->Cell(40,7,$value,1,0,'L',1);
> -    }
> -    $this->Ln();
> -    $this->SetFillColor(233,241,253);
> -    $this->SetTextColor(0);
> -    $this->SetFont('');
> -    //Data
> -    $this->Cell(15);
> -    $fill=0;
> -    foreach($iData as $value)
> -    {
> -               $this->Cell(40,6,$value,1,0,'L',0);
> -    }
> -    $this->Ln();
> -}
> -
> -//customer Details
> -function setCustomerDetails($iCHeader,$iCData)
> -{
> -    $this->Ln();
> -    //$this->Cell(0);
> -    $this->SetFillColor(162,200,243);
> -    $this->SetTextColor(0);
> -    $this->SetDrawColor(61,121,206);
> -    //$this->SetLineWidth(.3);
> -    $this->SetFont('Arial','B',10);
> -    //Header
> -    //$this->Cell(15);
> -    foreach($iCHeader as $value)
> -    {
> -        $this->Cell(63,7,$value,1,0,'L',1);
> -    }
> -    $this->Ln();
> -    $this->SetFillColor(233,241,253);
> -    $this->SetTextColor(0);
> -    $this->SetFont('');
> -    //Data
> -    //$this->Cell(15);
> -    $fill=0;
> -    foreach($iCData as $value)
> -    {
> -               $this->Cell(63,6,$value,1,0,'L',0);
> -    }
> -    $this->Ln();
> -}
> -
> -//Product Details
> -function setProductDetails($ivHeader,$ivData)
> -{
> -    $this->Ln();
> -    $this->Ln();
> -    $this->SetFillColor(162,200,243);
> -    $this->SetTextColor(0);
> -    $this->SetDrawColor(61,121,206);
> -    $this->SetLineWidth(.3);
> -    $this->SetFont('Arial','B',10);
> -    //Header
> -    foreach($ivHeader as $value)
> -    {
> -        $this->Cell(38,7,$value,0,0,'L',0);
> -    }
> -    $this->Ln();
> -    $this->SetDrawColor(0,0,0);
> -    $this->SetLineWidth(.5);
> -    $this->line(10,140,200,140);
> -    $this->SetFillColor(233,241,253);
> -    $this->SetTextColor(0);
> -    $this->SetFont('');
> -    //Data
> -    $fill=0;
> -       foreach($ivData as $key=>$value)
> -       {
> -
> $this->Cell(38,6,$value['productname'],0,0,'L',0);
> -               $this->Cell(38,6,$value['qty'],0,0,'L',0);
> -
> $this->Cell(38,6,$value['unitprice'],0,0,'L',0);
> -
> $this->Cell(38,6,$value['listprice'],0,0,'L',0);
> -
> $this->Cell(38,6,$value['total'],0,0,'R',0);
> -               $this->Ln();
> -       }
> -    $this->Ln();
> -}
> -
> -function setTotal($price_total="",$conditions="")
> -{
> -       $this->Ln();
> -       $this->SetDrawColor(0,0,0);
> -       $this->SetLineWidth(.3);
> -//     $this->line(10,200,200,200);
> -       $this->SetFillColor(224,235,255);
> -       $this->SetTextColor(0);
> -       $this->SetFont('','B',10);
> -       $this->Cell(140,6,"Sub Total: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[0],1,0,'R',0);
> -       $this->Ln(4);
> -       $this->Ln(4);
> -       $this->Cell(140,6,"Tax: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[1],1,0,'R',0);
> -       $this->Ln(4);
> -       $this->Ln(4);
> -       $this->Cell(140,6,"Adjustment: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[2],1,0,'R',0);
> -       $this->Ln(4);
> -       $this->Ln(4);
> -       $this->Cell(140,6,"Grand total: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[3],1,0,'R',0);
> -       $this->Ln();
> -       $this->Ln();
> -       $this->Cell(0,8,"Terms & Conditions: ",0,0,'L',0);
> -       $this->Ln();
> -       $this->Cell(0,8,$conditions,0,0,'L',0);
> -}
> -}
>  //$bdata = array("aaaaaaaaa","48/1,Katcherry
> Street","Rasipuram","Namakkal (D.T)");
>  //$sdata = array("bbbbbb","48/9","","mmmm","Don City");
>  $iHead = array("Company","Purchase Order No.","Date","Requisition No.");
>  $iCustHeadDtls = array("Customer Name","Tracking No","Due Date");
>  //$iCustData = array("Nortel
> Networks","usc-107565","26-05-2005");
> -$iHeadDtls = array("Product Name","Quantity","List Price","Unit
> Price","Total");
> +$iHeadDtls = array("Quantity","Product Name","List Price","Unit
> Price","Total");
>
> -$pdf = new PDF('P','mm','A4');
> -$pdf->SetFont('Arial','',10);
> +$pdf = new PDFSheet();
> +$pdf->setInvoiceHeader($title,$logo_name,$companyaddress);
> +$pdf->setInvoiceFooter(SALES_TERMS,$conditions);
>  $pdf->AddPage();
> -$pdf->setInvoiceTitle("Purchase
> Order",$logo_name,$companyaddress);
>  $pdf->Ln();
> -$pdf->setInvoiceDetails($iHead,$iData);
>  $pdf->setAddress($bdata,$sdata);
> -$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
> +$pdf->setInvoiceSummary(SALES_REQUISITION,$id,
> +                        SALES_VENDOR,$vendor_name,
> +                        SALES_DATE);
>  $pdf->setProductDetails($iHeadDtls,$iDataDtls);
>  $pdf->setTotal($price_total,$conditions);
> -$pdf->Output();
> +$pdf->Output('Order.pdf','D');
>  ?>
>
>
> --- CreateSOPDF.php.orig        2005-10-20 16:15:39.555010888 -0400
> +++ CreateSOPDF.php.new 2005-10-20 16:54:29.014879160 -0400
> @@ -8,15 +8,24 @@
>   * All Rights Reserved.
>  *
>
> ********************************************************************************/
> -require('include/fpdf/fpdf.php');
> +require('include/PDFSheet.php');
>  require_once('modules/Orders/SalesOrder.php');
>
> +define('SALES_TERMS',          $app_strings['SALES_TERMS']);
> +define('SALES_SERVICE_NUMBER',
> $app_strings['SALES_SERVICE_NUMBER']);
> +define('SALES_SALESPERSON',
> $app_strings['SALES_SALESPERSON']);
> +define('SALES_DATE',           $app_strings['SALES_DATE']);
> +
>  $id = $_REQUEST['record'];
>  global $adb;
>  //retreiving the invoice info
>  $focus = new SalesOrder();
> $focus->retrieve_entity_info($_REQUEST['record'],"SalesOrder");
> +
>  $account_name =
> getAccountName($focus->column_fields[account_id]);
> +$title        = $focus->column_fields['subject'];
> +$salesperson  = $current_user->first_name .' '. $current_user->last_name;
> +
>  $iData[] = $account_name;
>  $iData[] = $id;
>  $iData[] = date('Y-m-d');
> @@ -229,211 +238,35 @@
>
>         $temp_data['productname'] = $productname;
>         $temp_data['qty'] = $qty;
> -       $temp_data['unitprice'] = $unitprice;
> -       $temp_data['listprice'] = $listprice;
> -       $temp_data['total'] = $total;
> +       $temp_data['unitprice'] = sprintf('%0.2f',$unitprice);
> +       $temp_data['listprice'] = sprintf('%0.2f',$listprice);
> +       $temp_data['total']     = sprintf('%0.2f',$total);
>         $iDataDtls[] = $temp_data;
>
>  }
>  //getting the Total Array
> -$price_total[] = $focus->column_fields["hdnSubTotal"];
> -$price_total[] = $focus->column_fields["txtTax"];
> -$price_total[] = $focus->column_fields["txtAdjustment"];
> -$price_total[] = $focus->column_fields["hdnGrandTotal"];
> -
> -class PDF extends FPDF
> -{
> -
> -// Invoice Title
> -function setInvoiceTitle($title,$logo_name,$caddress)
> -{
> -       if($title != "")
> -       {
> -               if(isset($logo_name) && $logo_name != '')
> -               {
> -
> $this->Image('test/logo/'.$logo_name,10,10,0,0);
> -               }
> -               else
> -               {
> -
> //$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0);
> -               }
> -               for($i=0;$i<count($caddress);$i++)
> -               {
> -
> -                       $this->Ln();
> -                       $this->Cell(40);
> -                       $this->SetFont('','',10);
> -
> $this->Cell(0,5,$caddress[$i],0,0,'L',0);
> -               }
> -               $this->Ln();
> -               $this->SetFillColor(224,235,255);
> -               $this->SetTextColor(0);
> -               $this->SetFont('','B',18);
> -               $this->Cell(0,10,$title,0,0,'C',0);
> +$price_total[] = sprintf('%0.2f',
> $focus->column_fields["hdnSubTotal"]);
> +$price_total[] = sprintf('%0.2f',
> $focus->column_fields["txtTax"]);
> +$price_total[] = sprintf('%0.2f',
> $focus->column_fields["txtAdjustment"]);
> +$price_total[] = sprintf('%0.2f',
> $focus->column_fields["hdnGrandTotal"]);
>
> -       }
> -}
> -//Invoice Address
> -function setAddress($billing="",$shipping="")
> -{
> -
> -       $this->Ln();
> -       $this->SetFillColor(224,235,255);
> -       $this->SetTextColor(0);
> -       $this->SetFont('','B',10);
> -       $this->Cell(130,10,"Bill To:",0,0,'L',0);
> -       $this->Cell(0,10,"Ship To:",0,0,'L',0);
> -       for($i=0;$i<count($billing);$i++)
> -       {
> -               $this->Cell(17);
> -               $this->SetFont('','',10);
> -               $this->Cell(130,5,$billing[$i],0,0,'L',0);
> -               $this->Cell(0,5,$shipping[$i],0,0,'L',0);
> -               $this->Ln();
> -       }
> -
> -}
> -//Invoice from
> -function setInvoiceDetails($iHeader,$iData)
> -{
> -    $this->Ln();
> -    $this->SetFillColor(162,200,243);
> -    $this->SetTextColor(0);
> -    $this->SetDrawColor(61,121,206);
> -    //$this->SetLineWidth(.3);
> -    $this->SetFont('Arial','B',10);
> -    //Header
> -    $this->Cell(15);
> -    foreach($iHeader as $value)
> -    {
> -        $this->Cell(40,7,$value,1,0,'L',1);
> -    }
> -    $this->Ln();
> -    $this->SetFillColor(233,241,253);
> -    $this->SetTextColor(0);
> -    $this->SetFont('');
> -    //Data
> -    $this->Cell(15);
> -    $fill=0;
> -    foreach($iData as $value)
> -    {
> -               $this->Cell(40,6,$value,1,0,'L',0);
> -    }
> -    $this->Ln();
> -}
> -
> -//customer Details
> -function setCustomerDetails($iCHeader,$iCData)
> -{
> -    $this->Ln();
> -    //$this->Cell(0);
> -    $this->SetFillColor(162,200,243);
> -    $this->SetTextColor(0);
> -    $this->SetDrawColor(61,121,206);
> -    //$this->SetLineWidth(.3);
> -    $this->SetFont('Arial','B',10);
> -    //Header
> -    //$this->Cell(15);
> -    foreach($iCHeader as $value)
> -    {
> -        $this->Cell(63,7,$value,1,0,'L',1);
> -    }
> -    $this->Ln();
> -    $this->SetFillColor(233,241,253);
> -    $this->SetTextColor(0);
> -    $this->SetFont('');
> -    //Data
> -    //$this->Cell(15);
> -    $fill=0;
> -    foreach($iCData as $value)
> -    {
> -               $this->Cell(63,6,$value,1,0,'L',0);
> -    }
> -    $this->Ln();
> -}
> -
> -//Product Details
> -function setProductDetails($ivHeader,$ivData)
> -{
> -    $this->Ln();
> -    $this->Ln();
> -    $this->SetFillColor(162,200,243);
> -    $this->SetTextColor(0);
> -    $this->SetDrawColor(61,121,206);
> -    $this->SetLineWidth(.3);
> -    $this->SetFont('Arial','B',10);
> -    //Header
> -    foreach($ivHeader as $value)
> -    {
> -        $this->Cell(38,7,$value,0,0,'L',0);
> -    }
> -    $this->Ln();
> -    $this->SetDrawColor(0,0,0);
> -    $this->SetLineWidth(.5);
> -    $this->line(10,140,200,140);
> -    $this->SetFillColor(233,241,253);
> -    $this->SetTextColor(0);
> -    $this->SetFont('');
> -    //Data
> -    $fill=0;
> -       foreach($ivData as $key=>$value)
> -       {
> -
> $this->Cell(38,6,$value['productname'],0,0,'L',0);
> -               $this->Cell(38,6,$value['qty'],0,0,'L',0);
> -
> $this->Cell(38,6,$value['unitprice'],0,0,'L',0);
> -
> $this->Cell(38,6,$value['listprice'],0,0,'L',0);
> -
> $this->Cell(38,6,$value['total'],0,0,'R',0);
> -               $this->Ln();
> -       }
> -    $this->Ln();
> -}
> -
> -function setTotal($price_total="",$conditions="")
> -{
> -       $this->Ln();
> -       $this->SetDrawColor(0,0,0);
> -       $this->SetLineWidth(.3);
> -//     $this->line(10,200,200,200);
> -       $this->SetFillColor(224,235,255);
> -       $this->SetTextColor(0);
> -       $this->SetFont('','B',10);
> -       $this->Cell(140,6,"Sub Total: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[0],1,0,'R',0);
> -       $this->Ln(4);
> -       $this->Ln(4);
> -       $this->Cell(140,6,"Tax: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[1],1,0,'R',0);
> -       $this->Ln(4);
> -       $this->Ln(4);
> -       $this->Cell(140,6,"Adjustment: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[2],1,0,'R',0);
> -       $this->Ln(4);
> -       $this->Ln(4);
> -       $this->Cell(140,6,"Grand total: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[3],1,0,'R',0);
> -       $this->Ln();
> -       $this->Ln();
> -       $this->Cell(0,8,"Terms & Conditions: ",0,0,'L',0);
> -       $this->Ln();
> -       $this->Cell(0,8,$conditions,0,0,'L',0);
> -}
> -}
>  //$bdata = array("aaaaaaaaa","48/1,Katcherry
> Street","Rasipuram","Namakkal (D.T)");
>  //$sdata = array("bbbbbb","48/9","","mmmm","Don City");
>  $iHead = array("Company","Sales Order No.","Date","Quote Name.");
>  $iCustHeadDtls = array("Customer Name","Purchase Order","Due Date");
>  //$iCustData = array("Nortel
> Networks","usc-107565","26-05-2005");
> -$iHeadDtls = array("Product Name","Quantity","List Price","Unit
> Price","Total");
> +$iHeadDtls = array("Quantity","Product Name","List Price","Unit
> Price","Total");
>
> -$pdf = new PDF('P','mm','A4');
> -$pdf->SetFont('Arial','',10);
> +$pdf = new PDFSheet();
> +$pdf->setInvoiceHeader($title,$logo_name,$companyaddress);
> +$pdf->setInvoiceFooter(SALES_TERMS, $conditions);
>  $pdf->AddPage();
> -$pdf->setInvoiceTitle("Sales
> Order",$logo_name,$companyaddress);
>  $pdf->Ln();
> -$pdf->setInvoiceDetails($iHead,$iData);
>  $pdf->setAddress($bdata,$sdata);
> -$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
> +$pdf->setInvoiceSummary(SALES_SERVICE_NUMBER, $id,
> +                        SALES_SALESPERSON,    $salesperson,
> +                        SALES_DATE);
>  $pdf->setProductDetails($iHeadDtls,$iDataDtls);
>  $pdf->setTotal($price_total,$conditions);
> -$pdf->Output();
> +$pdf->Output('Order.pdf', 'D');
>  ?>
>
>
> --- CreatePDF.php.orig  2005-10-19 09:36:52.000000000 -0400
> +++ CreatePDF.php.new   2005-10-20 16:52:08.721207040 -0400
> @@ -8,8 +8,15 @@
>   * All Rights Reserved.
>  *
>
> ********************************************************************************/
> -require('include/fpdf/fpdf.php');
> +require('include/PDFSheet.php');
>  require_once('modules/Quotes/Quote.php');
> +define('QUOTE_BILLING_HEADER',
> $app_strings['QUOTE_BILLING_HEADER']);
> +define('QUOTE_SERVICE_HEADER',
> $app_strings['QUOTE_SERVICE_HEADER']);
> +define('QUOTE_TITLE',          $app_strings['QUOTE_TITLE']);
> +define('QUOTE_SERVICE_NUMBER',
> $app_strings['QUOTE_SERVICE_NUMBER']);
> +define('QUOTE_DATE',           $app_strings['QUOTE_DATE']);
> +define('QUOTE_SALESPERSON',
> $app_strings['QUOTE_SALESPERSON']);
> +define('QUOTE_TERMS',          $app_strings['QUOTE_TERMS']);
>
>  $id = $_REQUEST['record'];
>  global $adb;
> @@ -17,13 +24,16 @@
>  $focus = new Quote();
> $focus->retrieve_entity_info($_REQUEST['record'],"Quotes");
>  $account_name =
> getAccountName($focus->column_fields[account_id]);
> -$iData[] = $account_name;
> +$iData = array($account_name);
>  $iData[] = $id;
>  $iData[] = date('Y-m-d');
>
>  //setting the Customer Data
> -$iCustData[] = $account_name;
> +//code contributed by Tyler Bannister for inproving quotes
> +$iCustData = array($account_name);
>
> +$title = $focus->column_fields['subject'];
> +$salesperson = $current_user->first_name .' '. $current_user->last_name;
>  if($focus->column_fields["duedate"] != '')
>  {
>         $due_date = $focus->column_fields["validtill"];
> @@ -35,7 +45,7 @@
>  $iCustData[] = $due_date;
>
>  //setting the billing address
> -$bdata[] = $account_name;
> +$bdata = array('', $account_name);
>  if($focus->column_fields["bill_street"] != '')
>  {
>          $bill_street =
> $focus->column_fields["bill_street"];
> @@ -70,16 +80,16 @@
>         $bdata[] = $bill_country;
>  }
>
> -for($i =0; $i <5; $i++)
> +for($i =0; $i <10; $i++)
>  {
> -       if(sizeof($bdata) < 6)
> +       if(sizeof($bdata) < 11)
>         {
>                 $bdata[] = ' ';
>         }
>  }
>
>  //setting the shipping address
> -$sdata[] = $account_name;
> +$sdata = array('', $account_name);
>  if($focus->column_fields["ship_street"] != '')
>  {
>          $ship_street =
> $focus->column_fields["ship_street"];
> @@ -113,9 +123,9 @@
>         $sdata[] = $ship_country;
>  }
>
> -for($i =0; $i <5; $i++)
> +for($i =0; $i <10; $i++)
>  {
> -       if(sizeof($sdata) < 6)
> +       if(sizeof($sdata) < 11)
>         {
>                 $sdata[] = ' ';
>         }
> @@ -143,14 +153,14 @@
>
>  if($num_rows == 1)
>  {
> -       $org_name =
> $adb->query_result($result,0,"organizationame");
> +       $org_name    =
> $adb->query_result($result,0,"organizationame");
>         $org_address =
> $adb->query_result($result,0,"address");
> -       $org_city = $adb->query_result($result,0,"city");
> -       $org_state = $adb->query_result($result,0,"state");
> +       $org_city    =
> $adb->query_result($result,0,"city");
> +       $org_state   =
> $adb->query_result($result,0,"state");
>         $org_country =
> $adb->query_result($result,0,"country");
> -       $org_code = $adb->query_result($result,0,"code");
> -       $org_phone = $adb->query_result($result,0,"phone");
> -       $org_fax = $adb->query_result($result,0,"fax");
> +       $org_code    =
> $adb->query_result($result,0,"code");
> +       $org_phone   =
> $adb->query_result($result,0,"phone");
> +       $org_fax     = $adb->query_result($result,0,"fax");
>         $org_website =
> $adb->query_result($result,0,"website");
>
>         if($org_name != '')
> @@ -159,19 +169,22 @@
>         }
>         if($org_address != '' || $org_city != '' || $org_state != '')
>         {
> -               $companyaddress[] = $org_address.' '.$org_city.'
> '.$org_state;
> +               $companyaddress[] = $org_address;
> +               $companyaddress[] = $org_city .', '.$org_state;
>         }
>         if($org_country != '' || $org_code!= '')
>         {
>                 $companyaddress[] = $org_country.' '.$org_code;
>         }
> +       $companyaddress[] = '';
>         if($org_phone != '' || $org_fax != '')
>         {
> -               $companyaddress[] = $org_phone.' '.$org_fax;
> +               $companyaddress[] = $app_strings['Phone_Short'] .': '.
> $org_phone;
> +               $companyaddress[] = $app_strings['Fax'] .': '. $org_fax;
>         }
>         if($org_website != '')
>         {
> -               $companyaddress[] = $org_website;
> +               $companyaddress[] = $app_strings['Website_Short']. ': '.
> $org_website;
>         }
>
>         for($i =0; $i < 4; $i++)
> @@ -188,6 +201,8 @@
>
>
>
> +//$companyaddress = Array('AdventNet, Inc.','11 Sarathy
> Nagar','Velachery','Vijayanagar','Chennai - 600042');
> +
>  //getting the Product Data
>  $query="select products.productname,products.unit_price,quotesproductrel.*
> from quotesproductrel inner join products on
> products.productid=quotesproductrel.productid where
> quoteid=".$id;
>
> @@ -205,211 +220,36 @@
>
>         $temp_data['productname'] = $productname;
>         $temp_data['qty'] = $qty;
> -       $temp_data['unitprice'] = $unitprice;
> -       $temp_data['listprice'] = $listprice;
> -       $temp_data['total'] = $total;
> +       $temp_data['unitprice'] = sprintf('%0.2f',$unitprice);
> +       $temp_data['listprice'] = sprintf('%0.2f',$listprice);
> +       $temp_data['total']     = sprintf('%0.2f',$total);
>         $iDataDtls[] = $temp_data;
>
>  }
>  //getting the Total Array
> -$price_total[] = $focus->column_fields["hdnSubTotal"];
> -$price_total[] = $focus->column_fields["txtTax"];
> -$price_total[] = $focus->column_fields["txtAdjustment"];
> -$price_total[] = $focus->column_fields["hdnGrandTotal"];
> -
> -class PDF extends FPDF
> -{
> +$price_total[] =
> sprintf('%0.2f',$focus->column_fields["hdnSubTotal"]);
> +$price_total[] =
> sprintf('%0.2f',$focus->column_fields["txtTax"]);
> +$price_total[] =
> sprintf('%0.2f',$focus->column_fields["txtAdjustment"]);
> +$price_total[] =
> sprintf('%0.2f',$focus->column_fields["hdnGrandTotal"]);
>
> -// Invoice Title
> -function setInvoiceTitle($title,$logo_name,$caddress)
> -{
> -       if($title != "")
> -       {
> -               if(isset($logo_name) && $logo_name != '')
> -               {
> -
> $this->Image('test/logo/'.$logo_name,10,10,0,0);
> -               }
> -               else
> -               {
> -
> //$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0);
> -               }
> -               for($i=0;$i<count($caddress);$i++)
> -               {
> -
> -                       $this->Ln();
> -                       $this->Cell(40);
> -                       $this->SetFont('','',10);
> -
> $this->Cell(0,5,$caddress[$i],0,0,'L',0);
> -               }
> -               $this->Ln();
> -               $this->SetFillColor(224,235,255);
> -               $this->SetTextColor(0);
> -               $this->SetFont('','B',18);
> -               $this->Cell(0,10,$title,0,0,'C',0);
> -
> -       }
> -}
> -//Invoice Address
> -function setAddress($billing="",$shipping="")
> -{
> -
> -       $this->Ln();
> -       $this->SetFillColor(224,235,255);
> -       $this->SetTextColor(0);
> -       $this->SetFont('','B',10);
> -       $this->Cell(130,10,"Bill To:",0,0,'L',0);
> -       $this->Cell(0,10,"Ship To:",0,0,'L',0);
> -       for($i=0;$i<count($billing);$i++)
> -       {
> -               $this->Cell(17);
> -               $this->SetFont('','',10);
> -               $this->Cell(130,5,$billing[$i],0,0,'L',0);
> -               $this->Cell(0,5,$shipping[$i],0,0,'L',0);
> -               $this->Ln();
> -       }
> -
> -}
> -//Invoice from
> -function setInvoiceDetails($iHeader,$iData)
> -{
> -    $this->Ln();
> -    $this->SetFillColor(162,200,243);
> -    $this->SetTextColor(0);
> -    $this->SetDrawColor(61,121,206);
> -    //$this->SetLineWidth(.3);
> -    $this->SetFont('Arial','B',10);
> -    //Header
> -    $this->Cell(15);
> -    foreach($iHeader as $value)
> -    {
> -        $this->Cell(40,7,$value,1,0,'L',1);
> -    }
> -    $this->Ln();
> -    $this->SetFillColor(233,241,253);
> -    $this->SetTextColor(0);
> -    $this->SetFont('');
> -    //Data
> -    $this->Cell(15);
> -    $fill=0;
> -    foreach($iData as $value)
> -    {
> -               $this->Cell(40,6,$value,1,0,'L',0);
> -    }
> -    $this->Ln();
> -}
> -
> -//customer Details
> -function setCustomerDetails($iCHeader,$iCData)
> -{
> -    $this->Ln();
> -    //$this->Cell(0);
> -    $this->SetFillColor(162,200,243);
> -    $this->SetTextColor(0);
> -    $this->SetDrawColor(61,121,206);
> -    //$this->SetLineWidth(.3);
> -    $this->SetFont('Arial','B',10);
> -    //Header
> -    //$this->Cell(15);
> -    foreach($iCHeader as $value)
> -    {
> -        $this->Cell(63,7,$value,1,0,'L',1);
> -    }
> -    $this->Ln();
> -    $this->SetFillColor(233,241,253);
> -    $this->SetTextColor(0);
> -    $this->SetFont('');
> -    //Data
> -    //$this->Cell(15);
> -    $fill=0;
> -    foreach($iCData as $value)
> -    {
> -               $this->Cell(63,6,$value,1,0,'L',0);
> -    }
> -    $this->Ln();
> -}
> -
> -//Product Details
> -function setProductDetails($ivHeader,$ivData)
> -{
> -    $this->Ln();
> -    $this->Ln();
> -    $this->SetFillColor(162,200,243);
> -    $this->SetTextColor(0);
> -    $this->SetDrawColor(61,121,206);
> -    $this->SetLineWidth(.3);
> -    $this->SetFont('Arial','B',10);
> -    //Header
> -    foreach($ivHeader as $value)
> -    {
> -        $this->Cell(38,7,$value,0,0,'L',0);
> -    }
> -    $this->Ln();
> -    $this->SetDrawColor(0,0,0);
> -    $this->SetLineWidth(.5);
> -    $this->line(10,140,200,140);
> -    $this->SetFillColor(233,241,253);
> -    $this->SetTextColor(0);
> -    $this->SetFont('');
> -    //Data
> -    $fill=0;
> -       foreach($ivData as $key=>$value)
> -       {
> -
> $this->Cell(38,6,$value['productname'],0,0,'L',0);
> -               $this->Cell(38,6,$value['qty'],0,0,'L',0);
> -
> $this->Cell(38,6,$value['unitprice'],0,0,'L',0);
> -
> $this->Cell(38,6,$value['listprice'],0,0,'L',0);
> -
> $this->Cell(38,6,$value['total'],0,0,'R',0);
> -               $this->Ln();
> -       }
> -    $this->Ln();
> -}
> -
> -function setTotal($price_total="",$conditions="")
> -{
> -       $this->Ln();
> -       $this->SetDrawColor(0,0,0);
> -       $this->SetLineWidth(.3);
> -//     $this->line(10,200,200,200);
> -       $this->SetFillColor(224,235,255);
> -       $this->SetTextColor(0);
> -       $this->SetFont('','B',10);
> -       $this->Cell(140,6,"Sub Total: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[0],1,0,'R',0);
> -       $this->Ln(4);
> -       $this->Ln(4);
> -       $this->Cell(140,6,"Tax: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[1],1,0,'R',0);
> -       $this->Ln(4);
> -       $this->Ln(4);
> -       $this->Cell(140,6,"Adjustment: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[2],1,0,'R',0);
> -       $this->Ln(4);
> -       $this->Ln(4);
> -       $this->Cell(140,6,"Grand total: ",0,0,'R',0);
> -       $this->Cell(0,6,$price_total[3],1,0,'R',0);
> -       $this->Ln();
> -       $this->Ln();
> -       $this->Cell(0,8,"Terms & Conditions: ",0,0,'L',0);
> -       $this->Ln();
> -       $this->Cell(0,8,$conditions,0,0,'L',0);
> -}
> -}
>  //$bdata = array("aaaaaaaaa","48/1,Katcherry
> Street","Rasipuram","Namakkal (D.T)");
>  //$sdata = array("bbbbbb","48/9","","mmmm","Don City");
>  $iHead = array("Company","Quote No.","Date");
>  $iCustHeadDtls = array("Customer Name","Valid Till");
>  //$iCustData = array("Nortel
> Networks","usc-107565","26-05-2005");
> -$iHeadDtls = array("Product Name","Quantity","List Price","Unit
> Price","Total");
> +$iHeadDtls = array("Quantity", "Product Name","List Price","Unit
> Price","Total");
>
> -$pdf = new PDF('P','mm','A4');
> -$pdf->SetFont('Arial','',10);
> +$pdf = new PDFSheet();
> +$pdf->setInvoiceHeader($title,$logo_name,$companyaddress);
> +$pdf->setInvoiceFooter(QUOTE_TERMS, $conditions);
>  $pdf->AddPage();
> -$pdf->setInvoiceTitle("Quotes",$logo_name,$companyaddress);
>  $pdf->Ln();
> -$pdf->setInvoiceDetails($iHead,$iData);
>  $pdf->setAddress($bdata,$sdata);
> -$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
> +$pdf->setInvoiceSummary(QUOTE_SERVICE_NUMBER,$id,
> +                        QUOTE_SALESPERSON,$salesperson,
> +                        QUOTE_DATE);
>  $pdf->setProductDetails($iHeadDtls,$iDataDtls);
>  $pdf->setTotal($price_total,$conditions);
> -$pdf->Output();
> +$pdf->Output('Quote.pdf','D');
> +exit;
>  ?>
>
>
> FPDF($orientation,$unit,$format); $this->pdf_font = $font;
> $this->SetFont($this->pdf_font,'',10); } function Header()
> { if ($this->header_image != '') {
> $this->Image($this->header_image,10,10,0,0); } else { //
> $this->Image('themes/Aqua/images/blank.jpg',10,10,0,0); }
> if ($this->header_title != '') {
> $this->SetFillColor($this->pdf_fill_color[0],
> $this->pdf_fill_color[1], $this->pdf_fill_color[2]);
> $this->SetTextColor($this->title_text_color[0],
> $this->title_text_color[1], $this->title_text_color[2]); $this->Cell(80);
> $this->SetFont($this->pdf_font,'B',18);
> $this->Cell(30,10,$this->header_title,0,0,'C',0); }
> $this->SetTextColor($this->pdf_text_color[0],
> $this->pdf_text_color[1], $this->pdf_text_color[2]); $this->SetY(5); if
> (is_array($this->header_address)) {
> for($i=0;$iheader_address);$i++) { $this->Cell(150);
> $this->SetFont($this->pdf_font,'',8);
> $this->Cell(0,5,$this->header_address[$i],0,0,'L',0);
> $this->Ln(3.2); } } } function Footer() { $this->SetY(-20);
> $this->Cell(0,8,$this->footer_title,0,0,'C',0);
> $this->Ln();
> $this->Cell(0,8,$this->footer_terms,0,0,'L',0); } function
> drawHeader($header,$width=40,$height=7) {
> $this->SetFillColor($this->header_fill_color[0],
> $this->header_fill_color[1], $this->header_fill_color[2]);
> $this->SetTextColor($this->header_text_color[0],
> $this->header_text_color[1], $this->header_text_color[2]);
> $this->SetDrawColor($this->table_border_color[0],
> $this->table_border_color[1], $this->table_border_color[2]);
> $this->SetFont($this->pdf_font,'B',10);
> $this->Cell($width,$height,$header,1,0,'C',1); $this->Ln();
> } function drawCell($data,$width=40,$height=7) {
> $this->SetFont($this->pdf_font,'',8);
> $this->SetFillColor($this->table_fill_color[0],
> $this->table_fill_color[1], $this->table_fill_color[2]);
> $this->SetTextColor($this->table_text_color[0],
> $this->table_text_color[1], $this->table_text_color[2]);
> $this->Cell($width,$height,$data,1,0,'C',1);
> $this->Ln($height); } // $headers should be a one-dimensional array of
> headers // $data should be a two-dimensional array of data // $col_size
> should be a one-dimensional array of column widths function
> drawTable($headers, $data, $col_size = '', $x = -1, $y = -1) { if ($x != -1)
> { $this->SetLeftMargin($x); $this->SetX($x); } if ($y != -1) {
> $this->SetY($y); } if ($col_size == '') { $col_size =
> array_fill(0,sizeof($headers)-1, 190 / sizeof($headers)); }
> $this->SetFillColor($this->header_fill_color[0],
> $this->header_fill_color[1], $this->header_fill_color[2]);
> $this->SetTextColor($this->header_text_color[0],
> $this->header_text_color[1], $this->header_text_color[2]);
> $this->SetDrawColor($this->table_border_color[0],
> $this->table_border_color[1], $this->table_border_color[2]);
> $this->SetFont($this->pdf_font,'B',10); foreach ($headers
> as $num => $cell) {
> $this->Cell($col_size[$num],7,$cell,1,0,'C',1); }
> $this->Ln(); $size = 3.2;
> $this->SetFont($this->pdf_font,'',8);
> $this->SetFillColor($this->table_fill_color[0],
> $this->table_fill_color[1], $this->table_fill_color[2]);
> $this->SetTextColor($this->table_text_color[0],
> $this->table_text_color[1], $this->table_text_color[2]); $borders = 'LRT';
> foreach ($data as $row => $set) { if ($row == 1) { $borders = 'LR'; } if
> ($row == sizeof($data) - 1) { $borders = 'LRB'; } if (is_array($set)) {
> foreach($set as $num => $cell) {
> $this->Cell($col_size[$num],$size,$cell,$borders,0,'L',1);
> } } else {
> $this->Cell($col_size[$num],$size,$set,$borders,0,'L',1); }
> $this->Ln($size); } if ($x != -1) { $this->SetLeftMargin(10);
> $this->SetX(10); } } // Invoice Title function
> setInvoiceHeader($title='',$logo_name='',$caddress='') {
> if(isset($logo_name) && $logo_name != '') { $this->header_image =
> 'test/logo/'.$logo_name; } $this->header_address = $caddress;
> $this->header_title = $title; } function setInvoiceFooter($title='',
> $terms='') { $this->footer_title = $title; $this->footer_terms = $terms; }
> // Invoice Address // Both $billing and $shipping should be arrays function
> setAddress($billing=array(), $shipping=array()) {
> $this->drawTable(array(SHEET_BILLING_HEADER),$billing,
> array(65),10,35);
> $this->drawTable(array(SHEET_SERVICE_HEADER),$shipping,array(65),85,35);
> } function setInvoiceSummary($service_title, $serviceid,
> $sales_title, $salesperson = '', $date_title) { $this->SetLeftMargin(160);
> $this->SetX(160); $this->SetY(35); $date = date('F j, Y');
> $this->drawHeader($service_title);
> $this->drawCell($serviceid); $this->drawHeader($date_title);
> $this->drawCell($date); $this->drawHeader($sales_title);
> $this->drawCell($salesperson); $this->SetLeftMargin(10); $this->SetX(10); }
> //Product Details function
> setProductDetails($ivHeader,$ivData) { $this->Ln();
> $this->Ln(); $data = array(); $col_sizes = array(20,110,20,20,20);
> foreach($ivData as $key=>$value) { $data[] = array($value['qty'],
> $value['productname'], $value['listprice'], $value['unitprice'],
> $value['total']); } $this->drawTable($ivHeader, $data, $col_sizes); }
> function setTotal($price_total="",$conditions="") {
> $this->Ln(); $this->SetDrawColor($this->divider_color[0],
> $this->divider_color[1], $this->divider_color[2]); $this->SetLineWidth(.3);
> // $this->line(10,200,200,200);
> $this->SetFillColor($this->table_fill_color[0],
> $this->table_fill_color[1], $this->table_fill_color[2]);
> $this->SetTextColor($this->table_text_color[0],
> $this->table_text_color[1], $this->table_text_color[2]);
> $this->SetFont($this->pdf_font,'B',10);
> $this->Cell(140,6,SHEET_SUBTOTAL,0,0,'R',0);
> $this->Cell(0,6,$price_total[0],1,0,'R',0); $this->Ln(4);
> $this->Ln(4); $this->Cell(140,6,SHEET_TAX,0,0,'R',0);
> $this->Cell(0,6,$price_total[1],1,0,'R',0); $this->Ln(4);
> $this->Ln(4); $this->Cell(140,6,SHEET_ADJUST,0,0,'R',0);
> $this->Cell(0,6,$price_total[2],1,0,'R',0); $this->Ln(4);
> $this->Ln(4); $this->Cell(140,6,SHEET_TOTAL,0,0,'R',0);
> $this->Cell(0,6,$price_total[3],1,0,'R',0); $this->Ln();
> $this->Ln(); } } ?>
>


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
vtigercrm-contributors mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vtigercrm-contributors
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: More PDF Improvements

tbannister
I'm diffing over the V4.2 patch2.

Sergio A. Kessler wrote:

>hi tyler, are you diffing over cvs or over the v4.2 patch2 ?
>
>/sergio
>ps: can we configure the mailing list so the replys go to the list so
>everyone can follow the conversation ?
>
>
>On 10/20/05, Tyler Bannister <[hidden email]> wrote:
>  
>
>>After I finished the PDF improvement to the Quotes module it was brought
>>to my attention that there are four seperate CreatePDF files.  So I made
>>some changes so they will all use the new format and a common PDF
>>creation object.  I created a PDFSheet.php file to placed in the
>>includes directory and I've included patch files to fix the
>>modules/Quotes/CreatePDF.php, modules/Orders/CreatePDF.php,
>>modules/Orders/CreateSOPDF.php, and
>>modules/Invoice/CreatePDF.php files.
>>
>>In addition some of the content of the display text in each module has
>>been moved to the includes/languages/en_us.lang.php file,
>>requiring the
>>following entries to be added to the app_strings array (I inserted them
>>at line 500):
>>'INVOICE_ID'           => 'Invoice No.',
>>'INVOICE_DATE'         => 'Date',
>>'INVOICE_ACCOUNT'      => 'Account Name',
>>'INVOICE_TERMS'        => 'Terms & Conditions',
>>
>>'QUOTE_TITLE'          => 'Service Quote',
>>'QUOTE_SERVICE_NUMBER' => 'Service Number',
>>'QUOTE_DATE'           => 'Date',
>>'QUOTE_SALESPERSON'    => 'Account Executive',
>>'QUOTE_TERMS'          => 'Terms & Conditions',
>>
>>'SALES_REQUISITION'    => 'Requisition No.',
>>'SALES_SERVICE_NUMBER' => 'Sales No.',
>>'SALES_TERMS'          => 'Terms & Conditions',
>>'SALES_VENDOR'         => 'Vendor',
>>'SALES_DATE'           => 'Date',
>>'SALES_SALESPERSON'    => 'Account Executive',
>>
>>'SHEET_ADJUST'         => 'Adjustment: ',
>>'SHEET_BILLING_HEADER' => 'Billing Address',
>>'SHEET_SERVICE_HEADER' => 'Service Address',
>>'SHEET_SUBTOTAL'       => 'Sub Total: ',
>>'SHEET_TAX'            => 'Tax: ',
>>'SHEET_TOTAL'          => 'Grand Total: ',
>>
>>--
>>Tyler Bannister
>>NetAccess Systems Inc.
>>905-524-2001 xt432
>>
>>
>>
>>--- CreatePDF.php.orig  2005-10-20 16:56:18.904173448 -0400
>>+++ CreatePDF.php.new   2005-10-20 16:54:59.772203336 -0400
>>@@ -8,15 +8,23 @@
>>  * All Rights Reserved.
>> *
>>
>>********************************************************************************/
>>-require('include/fpdf/fpdf.php');
>>+require('include/PDFSheet.php');
>> require_once('modules/Invoice/Invoice.php');
>>
>>+define('INVOICE_ID',      $app_strings['INVOICE_ID']);
>>+define('INVOICE_ACCOUNT',
>>$app_strings['INVOICE_ACCOUNT']);
>>+define('INVOICE_DATE',    $app_strings['INVOICE_DATE']);
>>+define('INVOICE_TERMS',   $app_strings['INVOICE_TERMS']);
>>+
>> $id = $_REQUEST['record'];
>> global $adb;
>> //retreiving the invoice info
>> $focus = new Invoice();
>>$focus->retrieve_entity_info($_REQUEST['record'],"Invoice");
>>+
>> $account_name =
>>getAccountName($focus->column_fields[account_id]);
>>+$title       = $focus->column_fields['subject'];
>>+
>> $iData[] = $account_name;
>> $iData[] = $id;
>> $iData[] = date('Y-m-d');
>>@@ -226,211 +234,35 @@
>>
>>        $temp_data['productname'] = $productname;
>>        $temp_data['qty'] = $qty;
>>-       $temp_data['unitprice'] = $unitprice;
>>-       $temp_data['listprice'] = $listprice;
>>-       $temp_data['total'] = $total;
>>+       $temp_data['unitprice'] = sprintf('%0.2f',$unitprice);
>>+       $temp_data['listprice'] = sprintf('%0.2f',$listprice);
>>+       $temp_data['total']     = sprintf('%0.2f',$total);
>>        $iDataDtls[] = $temp_data;
>>
>> }
>> //getting the Total Array
>>-$price_total[] = $focus->column_fields["hdnSubTotal"];
>>-$price_total[] = $focus->column_fields["txtTax"];
>>-$price_total[] = $focus->column_fields["txtAdjustment"];
>>-$price_total[] = $focus->column_fields["hdnGrandTotal"];
>>-
>>-class PDF extends FPDF
>>-{
>>-
>>-// Invoice Title
>>-function setInvoiceTitle($title,$logo_name,$caddress)
>>-{
>>-       if($title != "")
>>-       {
>>-               if(isset($logo_name) && $logo_name != '')
>>-               {
>>-
>>$this->Image('test/logo/'.$logo_name,10,10,0,0);
>>-               }
>>-               else
>>-               {
>>-
>>//$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0);
>>-               }
>>-               for($i=0;$i<count($caddress);$i++)
>>-               {
>>-
>>-                       $this->Ln();
>>-                       $this->Cell(40);
>>-                       $this->SetFont('','',10);
>>-
>>$this->Cell(0,5,$caddress[$i],0,0,'L',0);
>>-               }
>>-               $this->Ln();
>>-               $this->SetFillColor(224,235,255);
>>-               $this->SetTextColor(0);
>>-               $this->SetFont('','B',18);
>>-               $this->Cell(0,10,$title,0,0,'C',0);
>>+$price_total[] =
>>sprintf('%0.2f',$focus->column_fields["hdnSubTotal"]);
>>+$price_total[] =
>>sprintf('%0.2f',$focus->column_fields["txtTax"]);
>>+$price_total[] =
>>sprintf('%0.2f',$focus->column_fields["txtAdjustment"]);
>>+$price_total[] =
>>sprintf('%0.2f',$focus->column_fields["hdnGrandTotal"]);
>>
>>-       }
>>-}
>>-//Invoice Address
>>-function setAddress($billing="",$shipping="")
>>-{
>>-
>>-       $this->Ln();
>>-       $this->SetFillColor(224,235,255);
>>-       $this->SetTextColor(0);
>>-       $this->SetFont('','B',10);
>>-       $this->Cell(130,10,"Bill To:",0,0,'L',0);
>>-       $this->Cell(0,10,"Ship To:",0,0,'L',0);
>>-       for($i=0;$i<count($billing);$i++)
>>-       {
>>-               $this->Cell(17);
>>-               $this->SetFont('','',10);
>>-               $this->Cell(130,5,$billing[$i],0,0,'L',0);
>>-               $this->Cell(0,5,$shipping[$i],0,0,'L',0);
>>-               $this->Ln();
>>-       }
>>-
>>-}
>>-//Invoice from
>>-function setInvoiceDetails($iHeader,$iData)
>>-{
>>-    $this->Ln();
>>-    $this->SetFillColor(162,200,243);
>>-    $this->SetTextColor(0);
>>-    $this->SetDrawColor(61,121,206);
>>-    //$this->SetLineWidth(.3);
>>-    $this->SetFont('Arial','B',10);
>>-    //Header
>>-    $this->Cell(15);
>>-    foreach($iHeader as $value)
>>-    {
>>-        $this->Cell(40,7,$value,1,0,'L',1);
>>-    }
>>-    $this->Ln();
>>-    $this->SetFillColor(233,241,253);
>>-    $this->SetTextColor(0);
>>-    $this->SetFont('');
>>-    //Data
>>-    $this->Cell(15);
>>-    $fill=0;
>>-    foreach($iData as $value)
>>-    {
>>-               $this->Cell(40,6,$value,1,0,'L',0);
>>-    }
>>-    $this->Ln();
>>-}
>>-
>>-//customer Details
>>-function setCustomerDetails($iCHeader,$iCData)
>>-{
>>-    $this->Ln();
>>-    //$this->Cell(0);
>>-    $this->SetFillColor(162,200,243);
>>-    $this->SetTextColor(0);
>>-    $this->SetDrawColor(61,121,206);
>>-    //$this->SetLineWidth(.3);
>>-    $this->SetFont('Arial','B',10);
>>-    //Header
>>-    //$this->Cell(15);
>>-    foreach($iCHeader as $value)
>>-    {
>>-        $this->Cell(63,7,$value,1,0,'L',1);
>>-    }
>>-    $this->Ln();
>>-    $this->SetFillColor(233,241,253);
>>-    $this->SetTextColor(0);
>>-    $this->SetFont('');
>>-    //Data
>>-    //$this->Cell(15);
>>-    $fill=0;
>>-    foreach($iCData as $value)
>>-    {
>>-               $this->Cell(63,6,$value,1,0,'L',0);
>>-    }
>>-    $this->Ln();
>>-}
>>-
>>-//Product Details
>>-function setProductDetails($ivHeader,$ivData)
>>-{
>>-    $this->Ln();
>>-    $this->Ln();
>>-    $this->SetFillColor(162,200,243);
>>-    $this->SetTextColor(0);
>>-    $this->SetDrawColor(61,121,206);
>>-    $this->SetLineWidth(.3);
>>-    $this->SetFont('Arial','B',10);
>>-    //Header
>>-    foreach($ivHeader as $value)
>>-    {
>>-        $this->Cell(38,7,$value,0,0,'L',0);
>>-    }
>>-    $this->Ln();
>>-    $this->SetDrawColor(0,0,0);
>>-    $this->SetLineWidth(.5);
>>-    $this->line(10,140,200,140);
>>-    $this->SetFillColor(233,241,253);
>>-    $this->SetTextColor(0);
>>-    $this->SetFont('');
>>-    //Data
>>-    $fill=0;
>>-       foreach($ivData as $key=>$value)
>>-       {
>>-
>>$this->Cell(38,6,$value['productname'],0,0,'L',0);
>>-               $this->Cell(38,6,$value['qty'],0,0,'L',0);
>>-
>>$this->Cell(38,6,$value['unitprice'],0,0,'L',0);
>>-
>>$this->Cell(38,6,$value['listprice'],0,0,'L',0);
>>-
>>$this->Cell(38,6,$value['total'],0,0,'R',0);
>>-               $this->Ln();
>>-       }
>>-    $this->Ln();
>>-}
>>-
>>-function setTotal($price_total="",$conditions="")
>>-{
>>-       $this->Ln();
>>-       $this->SetDrawColor(0,0,0);
>>-       $this->SetLineWidth(.3);
>>-//     $this->line(10,200,200,200);
>>-       $this->SetFillColor(224,235,255);
>>-       $this->SetTextColor(0);
>>-       $this->SetFont('','B',10);
>>-       $this->Cell(140,6,"Sub Total: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[0],1,0,'R',0);
>>-       $this->Ln(4);
>>-       $this->Ln(4);
>>-       $this->Cell(140,6,"Tax: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[1],1,0,'R',0);
>>-       $this->Ln(4);
>>-       $this->Ln(4);
>>-       $this->Cell(140,6,"Adjustment: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[2],1,0,'R',0);
>>-       $this->Ln(4);
>>-       $this->Ln(4);
>>-       $this->Cell(140,6,"Grand total: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[3],1,0,'R',0);
>>-       $this->Ln();
>>-       $this->Ln();
>>-       $this->Cell(0,8,"Terms & Conditions: ",0,0,'L',0);
>>-       $this->Ln();
>>-       $this->Cell(0,8,$conditions,0,0,'L',0);
>>-}
>>-}
>> //$bdata = array("aaaaaaaaa","48/1,Katcherry
>>Street","Rasipuram","Namakkal (D.T)");
>> //$sdata = array("bbbbbb","48/9","","mmmm","Don City");
>> $iHead = array("Company","Invoice No.","Date","Sales Order No.");
>> $iCustHeadDtls = array("Customer Name","Purchase Order","Due Date");
>> //$iCustData = array("Nortel
>>Networks","usc-107565","26-05-2005");
>>-$iHeadDtls = array("Product Name","Quantity","List Price","Unit
>>Price","Total");
>>+$iHeadDtls = array("Quantity","Product Name","List Price","Unit
>>Price","Total");
>>
>>-$pdf = new PDF('P','mm','A4');
>>-$pdf->SetFont('Arial','',10);
>>+$pdf = new PDFSheet();
>>+$pdf->setInvoiceHeader($title,$logo_name,$companyaddress);
>>+$pdf->setInvoiceFooter(INVOICE_TERMS,$conditions);
>> $pdf->AddPage();
>>-$pdf->setInvoiceTitle("Invoice",$logo_name,$companyaddress);
>> $pdf->Ln();
>>-$pdf->setInvoiceDetails($iHead,$iData);
>> $pdf->setAddress($bdata,$sdata);
>>-$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
>>+$pdf->setInvoiceSummary(INVOICE_ID, $id,
>>+                        INVOICE_ACCOUNT, $account_name,
>>+                        INVOICE_DATE);
>> $pdf->setProductDetails($iHeadDtls,$iDataDtls);
>> $pdf->setTotal($price_total,$conditions);
>>-$pdf->Output();
>>+$pdf->Output('Invoice.pdf','D');
>> ?>
>>
>>
>>--- CreatePDF.php.orig  2005-10-20 15:40:57.633511064 -0400
>>+++ CreatePDF.php.new   2005-10-20 16:54:13.686209472 -0400
>>@@ -8,15 +8,23 @@
>>  * All Rights Reserved.
>> *
>>
>>********************************************************************************/
>>-require('include/fpdf/fpdf.php');
>>+require('include/PDFSheet.php');
>> require_once('modules/Orders/Order.php');
>>
>>+define('SALES_TERMS',          $app_strings['SALES_TERMS']);
>>+define('SALES_REQUISITION',
>>$app_strings['SALES_REQUISITION']);
>>+define('SALES_VENDOR',         $app_strings['SALES_VENDOR']);
>>+define('SALES_DATE',           $app_strings['SALES_DATE']);
>>+
>> $id = $_REQUEST['record'];
>> global $adb;
>> //retreiving the invoice info
>> $focus = new Order();
>>$focus->retrieve_entity_info($_REQUEST['record'],"Orders");
>>+
>> $vendor_name =
>>getVendorName($focus->column_fields[vendor_id]);
>>+$title       = $focus->column_fields['subject'];
>>+
>> $iData[] = $vendor_name;
>> $iData[] = $id;
>> $iData[] = date('Y-m-d');
>>@@ -226,211 +234,35 @@
>>
>>        $temp_data['productname'] = $productname;
>>        $temp_data['qty'] = $qty;
>>-       $temp_data['unitprice'] = $unitprice;
>>-       $temp_data['listprice'] = $listprice;
>>-       $temp_data['total'] = $total;
>>+       $temp_data['unitprice'] = sprintf('%0.2f',$unitprice);
>>+       $temp_data['listprice'] = sprintf('%0.2f',$listprice);
>>+       $temp_data['total']     = sprintf('%0.2f',$total);
>>        $iDataDtls[] = $temp_data;
>>
>> }
>> //getting the Total Array
>>-$price_total[] = $focus->column_fields["hdnSubTotal"];
>>-$price_total[] = $focus->column_fields["txtTax"];
>>-$price_total[] = $focus->column_fields["txtAdjustment"];
>>-$price_total[] = $focus->column_fields["hdnGrandTotal"];
>>-
>>-class PDF extends FPDF
>>-{
>>-
>>-// Invoice Title
>>-function setInvoiceTitle($title,$logo_name,$caddress)
>>-{
>>-       if($title != "")
>>-       {
>>-               if(isset($logo_name) && $logo_name != '')
>>-               {
>>-
>>$this->Image('test/logo/'.$logo_name,10,10,0,0);
>>-               }
>>-               else
>>-               {
>>-
>>//$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0);
>>-               }
>>-               for($i=0;$i<count($caddress);$i++)
>>-               {
>>-
>>-                       $this->Ln();
>>-                       $this->Cell(40);
>>-                       $this->SetFont('','',10);
>>-
>>$this->Cell(0,5,$caddress[$i],0,0,'L',0);
>>-               }
>>-               $this->Ln();
>>-               $this->SetFillColor(224,235,255);
>>-               $this->SetTextColor(0);
>>-               $this->SetFont('','B',18);
>>-               $this->Cell(0,10,$title,0,0,'C',0);
>>+$price_total[] =
>>sprintf('%0.2f',$focus->column_fields["hdnSubTotal"]);
>>+$price_total[] =
>>sprintf('%0.2f',$focus->column_fields["txtTax"]);
>>+$price_total[] =
>>sprintf('%0.2f',$focus->column_fields["txtAdjustment"]);
>>+$price_total[] =
>>sprintf('%0.2f',$focus->column_fields["hdnGrandTotal"]);
>>
>>-       }
>>-}
>>-//Invoice Address
>>-function setAddress($billing="",$shipping="")
>>-{
>>-
>>-       $this->Ln();
>>-       $this->SetFillColor(224,235,255);
>>-       $this->SetTextColor(0);
>>-       $this->SetFont('','B',10);
>>-       $this->Cell(130,10,"Bill To:",0,0,'L',0);
>>-       $this->Cell(0,10,"Ship To:",0,0,'L',0);
>>-       for($i=0;$i<count($billing);$i++)
>>-       {
>>-               $this->Cell(17);
>>-               $this->SetFont('','',10);
>>-               $this->Cell(130,5,$billing[$i],0,0,'L',0);
>>-               $this->Cell(0,5,$shipping[$i],0,0,'L',0);
>>-               $this->Ln();
>>-       }
>>-
>>-}
>>-//Invoice from
>>-function setInvoiceDetails($iHeader,$iData)
>>-{
>>-    $this->Ln();
>>-    $this->SetFillColor(162,200,243);
>>-    $this->SetTextColor(0);
>>-    $this->SetDrawColor(61,121,206);
>>-    //$this->SetLineWidth(.3);
>>-    $this->SetFont('Arial','B',10);
>>-    //Header
>>-    $this->Cell(15);
>>-    foreach($iHeader as $value)
>>-    {
>>-        $this->Cell(40,7,$value,1,0,'L',1);
>>-    }
>>-    $this->Ln();
>>-    $this->SetFillColor(233,241,253);
>>-    $this->SetTextColor(0);
>>-    $this->SetFont('');
>>-    //Data
>>-    $this->Cell(15);
>>-    $fill=0;
>>-    foreach($iData as $value)
>>-    {
>>-               $this->Cell(40,6,$value,1,0,'L',0);
>>-    }
>>-    $this->Ln();
>>-}
>>-
>>-//customer Details
>>-function setCustomerDetails($iCHeader,$iCData)
>>-{
>>-    $this->Ln();
>>-    //$this->Cell(0);
>>-    $this->SetFillColor(162,200,243);
>>-    $this->SetTextColor(0);
>>-    $this->SetDrawColor(61,121,206);
>>-    //$this->SetLineWidth(.3);
>>-    $this->SetFont('Arial','B',10);
>>-    //Header
>>-    //$this->Cell(15);
>>-    foreach($iCHeader as $value)
>>-    {
>>-        $this->Cell(63,7,$value,1,0,'L',1);
>>-    }
>>-    $this->Ln();
>>-    $this->SetFillColor(233,241,253);
>>-    $this->SetTextColor(0);
>>-    $this->SetFont('');
>>-    //Data
>>-    //$this->Cell(15);
>>-    $fill=0;
>>-    foreach($iCData as $value)
>>-    {
>>-               $this->Cell(63,6,$value,1,0,'L',0);
>>-    }
>>-    $this->Ln();
>>-}
>>-
>>-//Product Details
>>-function setProductDetails($ivHeader,$ivData)
>>-{
>>-    $this->Ln();
>>-    $this->Ln();
>>-    $this->SetFillColor(162,200,243);
>>-    $this->SetTextColor(0);
>>-    $this->SetDrawColor(61,121,206);
>>-    $this->SetLineWidth(.3);
>>-    $this->SetFont('Arial','B',10);
>>-    //Header
>>-    foreach($ivHeader as $value)
>>-    {
>>-        $this->Cell(38,7,$value,0,0,'L',0);
>>-    }
>>-    $this->Ln();
>>-    $this->SetDrawColor(0,0,0);
>>-    $this->SetLineWidth(.5);
>>-    $this->line(10,140,200,140);
>>-    $this->SetFillColor(233,241,253);
>>-    $this->SetTextColor(0);
>>-    $this->SetFont('');
>>-    //Data
>>-    $fill=0;
>>-       foreach($ivData as $key=>$value)
>>-       {
>>-
>>$this->Cell(38,6,$value['productname'],0,0,'L',0);
>>-               $this->Cell(38,6,$value['qty'],0,0,'L',0);
>>-
>>$this->Cell(38,6,$value['unitprice'],0,0,'L',0);
>>-
>>$this->Cell(38,6,$value['listprice'],0,0,'L',0);
>>-
>>$this->Cell(38,6,$value['total'],0,0,'R',0);
>>-               $this->Ln();
>>-       }
>>-    $this->Ln();
>>-}
>>-
>>-function setTotal($price_total="",$conditions="")
>>-{
>>-       $this->Ln();
>>-       $this->SetDrawColor(0,0,0);
>>-       $this->SetLineWidth(.3);
>>-//     $this->line(10,200,200,200);
>>-       $this->SetFillColor(224,235,255);
>>-       $this->SetTextColor(0);
>>-       $this->SetFont('','B',10);
>>-       $this->Cell(140,6,"Sub Total: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[0],1,0,'R',0);
>>-       $this->Ln(4);
>>-       $this->Ln(4);
>>-       $this->Cell(140,6,"Tax: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[1],1,0,'R',0);
>>-       $this->Ln(4);
>>-       $this->Ln(4);
>>-       $this->Cell(140,6,"Adjustment: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[2],1,0,'R',0);
>>-       $this->Ln(4);
>>-       $this->Ln(4);
>>-       $this->Cell(140,6,"Grand total: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[3],1,0,'R',0);
>>-       $this->Ln();
>>-       $this->Ln();
>>-       $this->Cell(0,8,"Terms & Conditions: ",0,0,'L',0);
>>-       $this->Ln();
>>-       $this->Cell(0,8,$conditions,0,0,'L',0);
>>-}
>>-}
>> //$bdata = array("aaaaaaaaa","48/1,Katcherry
>>Street","Rasipuram","Namakkal (D.T)");
>> //$sdata = array("bbbbbb","48/9","","mmmm","Don City");
>> $iHead = array("Company","Purchase Order No.","Date","Requisition No.");
>> $iCustHeadDtls = array("Customer Name","Tracking No","Due Date");
>> //$iCustData = array("Nortel
>>Networks","usc-107565","26-05-2005");
>>-$iHeadDtls = array("Product Name","Quantity","List Price","Unit
>>Price","Total");
>>+$iHeadDtls = array("Quantity","Product Name","List Price","Unit
>>Price","Total");
>>
>>-$pdf = new PDF('P','mm','A4');
>>-$pdf->SetFont('Arial','',10);
>>+$pdf = new PDFSheet();
>>+$pdf->setInvoiceHeader($title,$logo_name,$companyaddress);
>>+$pdf->setInvoiceFooter(SALES_TERMS,$conditions);
>> $pdf->AddPage();
>>-$pdf->setInvoiceTitle("Purchase
>>Order",$logo_name,$companyaddress);
>> $pdf->Ln();
>>-$pdf->setInvoiceDetails($iHead,$iData);
>> $pdf->setAddress($bdata,$sdata);
>>-$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
>>+$pdf->setInvoiceSummary(SALES_REQUISITION,$id,
>>+                        SALES_VENDOR,$vendor_name,
>>+                        SALES_DATE);
>> $pdf->setProductDetails($iHeadDtls,$iDataDtls);
>> $pdf->setTotal($price_total,$conditions);
>>-$pdf->Output();
>>+$pdf->Output('Order.pdf','D');
>> ?>
>>
>>
>>--- CreateSOPDF.php.orig        2005-10-20 16:15:39.555010888 -0400
>>+++ CreateSOPDF.php.new 2005-10-20 16:54:29.014879160 -0400
>>@@ -8,15 +8,24 @@
>>  * All Rights Reserved.
>> *
>>
>>********************************************************************************/
>>-require('include/fpdf/fpdf.php');
>>+require('include/PDFSheet.php');
>> require_once('modules/Orders/SalesOrder.php');
>>
>>+define('SALES_TERMS',          $app_strings['SALES_TERMS']);
>>+define('SALES_SERVICE_NUMBER',
>>$app_strings['SALES_SERVICE_NUMBER']);
>>+define('SALES_SALESPERSON',
>>$app_strings['SALES_SALESPERSON']);
>>+define('SALES_DATE',           $app_strings['SALES_DATE']);
>>+
>> $id = $_REQUEST['record'];
>> global $adb;
>> //retreiving the invoice info
>> $focus = new SalesOrder();
>>$focus->retrieve_entity_info($_REQUEST['record'],"SalesOrder");
>>+
>> $account_name =
>>getAccountName($focus->column_fields[account_id]);
>>+$title        = $focus->column_fields['subject'];
>>+$salesperson  = $current_user->first_name .' '. $current_user->last_name;
>>+
>> $iData[] = $account_name;
>> $iData[] = $id;
>> $iData[] = date('Y-m-d');
>>@@ -229,211 +238,35 @@
>>
>>        $temp_data['productname'] = $productname;
>>        $temp_data['qty'] = $qty;
>>-       $temp_data['unitprice'] = $unitprice;
>>-       $temp_data['listprice'] = $listprice;
>>-       $temp_data['total'] = $total;
>>+       $temp_data['unitprice'] = sprintf('%0.2f',$unitprice);
>>+       $temp_data['listprice'] = sprintf('%0.2f',$listprice);
>>+       $temp_data['total']     = sprintf('%0.2f',$total);
>>        $iDataDtls[] = $temp_data;
>>
>> }
>> //getting the Total Array
>>-$price_total[] = $focus->column_fields["hdnSubTotal"];
>>-$price_total[] = $focus->column_fields["txtTax"];
>>-$price_total[] = $focus->column_fields["txtAdjustment"];
>>-$price_total[] = $focus->column_fields["hdnGrandTotal"];
>>-
>>-class PDF extends FPDF
>>-{
>>-
>>-// Invoice Title
>>-function setInvoiceTitle($title,$logo_name,$caddress)
>>-{
>>-       if($title != "")
>>-       {
>>-               if(isset($logo_name) && $logo_name != '')
>>-               {
>>-
>>$this->Image('test/logo/'.$logo_name,10,10,0,0);
>>-               }
>>-               else
>>-               {
>>-
>>//$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0);
>>-               }
>>-               for($i=0;$i<count($caddress);$i++)
>>-               {
>>-
>>-                       $this->Ln();
>>-                       $this->Cell(40);
>>-                       $this->SetFont('','',10);
>>-
>>$this->Cell(0,5,$caddress[$i],0,0,'L',0);
>>-               }
>>-               $this->Ln();
>>-               $this->SetFillColor(224,235,255);
>>-               $this->SetTextColor(0);
>>-               $this->SetFont('','B',18);
>>-               $this->Cell(0,10,$title,0,0,'C',0);
>>+$price_total[] = sprintf('%0.2f',
>>$focus->column_fields["hdnSubTotal"]);
>>+$price_total[] = sprintf('%0.2f',
>>$focus->column_fields["txtTax"]);
>>+$price_total[] = sprintf('%0.2f',
>>$focus->column_fields["txtAdjustment"]);
>>+$price_total[] = sprintf('%0.2f',
>>$focus->column_fields["hdnGrandTotal"]);
>>
>>-       }
>>-}
>>-//Invoice Address
>>-function setAddress($billing="",$shipping="")
>>-{
>>-
>>-       $this->Ln();
>>-       $this->SetFillColor(224,235,255);
>>-       $this->SetTextColor(0);
>>-       $this->SetFont('','B',10);
>>-       $this->Cell(130,10,"Bill To:",0,0,'L',0);
>>-       $this->Cell(0,10,"Ship To:",0,0,'L',0);
>>-       for($i=0;$i<count($billing);$i++)
>>-       {
>>-               $this->Cell(17);
>>-               $this->SetFont('','',10);
>>-               $this->Cell(130,5,$billing[$i],0,0,'L',0);
>>-               $this->Cell(0,5,$shipping[$i],0,0,'L',0);
>>-               $this->Ln();
>>-       }
>>-
>>-}
>>-//Invoice from
>>-function setInvoiceDetails($iHeader,$iData)
>>-{
>>-    $this->Ln();
>>-    $this->SetFillColor(162,200,243);
>>-    $this->SetTextColor(0);
>>-    $this->SetDrawColor(61,121,206);
>>-    //$this->SetLineWidth(.3);
>>-    $this->SetFont('Arial','B',10);
>>-    //Header
>>-    $this->Cell(15);
>>-    foreach($iHeader as $value)
>>-    {
>>-        $this->Cell(40,7,$value,1,0,'L',1);
>>-    }
>>-    $this->Ln();
>>-    $this->SetFillColor(233,241,253);
>>-    $this->SetTextColor(0);
>>-    $this->SetFont('');
>>-    //Data
>>-    $this->Cell(15);
>>-    $fill=0;
>>-    foreach($iData as $value)
>>-    {
>>-               $this->Cell(40,6,$value,1,0,'L',0);
>>-    }
>>-    $this->Ln();
>>-}
>>-
>>-//customer Details
>>-function setCustomerDetails($iCHeader,$iCData)
>>-{
>>-    $this->Ln();
>>-    //$this->Cell(0);
>>-    $this->SetFillColor(162,200,243);
>>-    $this->SetTextColor(0);
>>-    $this->SetDrawColor(61,121,206);
>>-    //$this->SetLineWidth(.3);
>>-    $this->SetFont('Arial','B',10);
>>-    //Header
>>-    //$this->Cell(15);
>>-    foreach($iCHeader as $value)
>>-    {
>>-        $this->Cell(63,7,$value,1,0,'L',1);
>>-    }
>>-    $this->Ln();
>>-    $this->SetFillColor(233,241,253);
>>-    $this->SetTextColor(0);
>>-    $this->SetFont('');
>>-    //Data
>>-    //$this->Cell(15);
>>-    $fill=0;
>>-    foreach($iCData as $value)
>>-    {
>>-               $this->Cell(63,6,$value,1,0,'L',0);
>>-    }
>>-    $this->Ln();
>>-}
>>-
>>-//Product Details
>>-function setProductDetails($ivHeader,$ivData)
>>-{
>>-    $this->Ln();
>>-    $this->Ln();
>>-    $this->SetFillColor(162,200,243);
>>-    $this->SetTextColor(0);
>>-    $this->SetDrawColor(61,121,206);
>>-    $this->SetLineWidth(.3);
>>-    $this->SetFont('Arial','B',10);
>>-    //Header
>>-    foreach($ivHeader as $value)
>>-    {
>>-        $this->Cell(38,7,$value,0,0,'L',0);
>>-    }
>>-    $this->Ln();
>>-    $this->SetDrawColor(0,0,0);
>>-    $this->SetLineWidth(.5);
>>-    $this->line(10,140,200,140);
>>-    $this->SetFillColor(233,241,253);
>>-    $this->SetTextColor(0);
>>-    $this->SetFont('');
>>-    //Data
>>-    $fill=0;
>>-       foreach($ivData as $key=>$value)
>>-       {
>>-
>>$this->Cell(38,6,$value['productname'],0,0,'L',0);
>>-               $this->Cell(38,6,$value['qty'],0,0,'L',0);
>>-
>>$this->Cell(38,6,$value['unitprice'],0,0,'L',0);
>>-
>>$this->Cell(38,6,$value['listprice'],0,0,'L',0);
>>-
>>$this->Cell(38,6,$value['total'],0,0,'R',0);
>>-               $this->Ln();
>>-       }
>>-    $this->Ln();
>>-}
>>-
>>-function setTotal($price_total="",$conditions="")
>>-{
>>-       $this->Ln();
>>-       $this->SetDrawColor(0,0,0);
>>-       $this->SetLineWidth(.3);
>>-//     $this->line(10,200,200,200);
>>-       $this->SetFillColor(224,235,255);
>>-       $this->SetTextColor(0);
>>-       $this->SetFont('','B',10);
>>-       $this->Cell(140,6,"Sub Total: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[0],1,0,'R',0);
>>-       $this->Ln(4);
>>-       $this->Ln(4);
>>-       $this->Cell(140,6,"Tax: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[1],1,0,'R',0);
>>-       $this->Ln(4);
>>-       $this->Ln(4);
>>-       $this->Cell(140,6,"Adjustment: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[2],1,0,'R',0);
>>-       $this->Ln(4);
>>-       $this->Ln(4);
>>-       $this->Cell(140,6,"Grand total: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[3],1,0,'R',0);
>>-       $this->Ln();
>>-       $this->Ln();
>>-       $this->Cell(0,8,"Terms & Conditions: ",0,0,'L',0);
>>-       $this->Ln();
>>-       $this->Cell(0,8,$conditions,0,0,'L',0);
>>-}
>>-}
>> //$bdata = array("aaaaaaaaa","48/1,Katcherry
>>Street","Rasipuram","Namakkal (D.T)");
>> //$sdata = array("bbbbbb","48/9","","mmmm","Don City");
>> $iHead = array("Company","Sales Order No.","Date","Quote Name.");
>> $iCustHeadDtls = array("Customer Name","Purchase Order","Due Date");
>> //$iCustData = array("Nortel
>>Networks","usc-107565","26-05-2005");
>>-$iHeadDtls = array("Product Name","Quantity","List Price","Unit
>>Price","Total");
>>+$iHeadDtls = array("Quantity","Product Name","List Price","Unit
>>Price","Total");
>>
>>-$pdf = new PDF('P','mm','A4');
>>-$pdf->SetFont('Arial','',10);
>>+$pdf = new PDFSheet();
>>+$pdf->setInvoiceHeader($title,$logo_name,$companyaddress);
>>+$pdf->setInvoiceFooter(SALES_TERMS, $conditions);
>> $pdf->AddPage();
>>-$pdf->setInvoiceTitle("Sales
>>Order",$logo_name,$companyaddress);
>> $pdf->Ln();
>>-$pdf->setInvoiceDetails($iHead,$iData);
>> $pdf->setAddress($bdata,$sdata);
>>-$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
>>+$pdf->setInvoiceSummary(SALES_SERVICE_NUMBER, $id,
>>+                        SALES_SALESPERSON,    $salesperson,
>>+                        SALES_DATE);
>> $pdf->setProductDetails($iHeadDtls,$iDataDtls);
>> $pdf->setTotal($price_total,$conditions);
>>-$pdf->Output();
>>+$pdf->Output('Order.pdf', 'D');
>> ?>
>>
>>
>>--- CreatePDF.php.orig  2005-10-19 09:36:52.000000000 -0400
>>+++ CreatePDF.php.new   2005-10-20 16:52:08.721207040 -0400
>>@@ -8,8 +8,15 @@
>>  * All Rights Reserved.
>> *
>>
>>********************************************************************************/
>>-require('include/fpdf/fpdf.php');
>>+require('include/PDFSheet.php');
>> require_once('modules/Quotes/Quote.php');
>>+define('QUOTE_BILLING_HEADER',
>>$app_strings['QUOTE_BILLING_HEADER']);
>>+define('QUOTE_SERVICE_HEADER',
>>$app_strings['QUOTE_SERVICE_HEADER']);
>>+define('QUOTE_TITLE',          $app_strings['QUOTE_TITLE']);
>>+define('QUOTE_SERVICE_NUMBER',
>>$app_strings['QUOTE_SERVICE_NUMBER']);
>>+define('QUOTE_DATE',           $app_strings['QUOTE_DATE']);
>>+define('QUOTE_SALESPERSON',
>>$app_strings['QUOTE_SALESPERSON']);
>>+define('QUOTE_TERMS',          $app_strings['QUOTE_TERMS']);
>>
>> $id = $_REQUEST['record'];
>> global $adb;
>>@@ -17,13 +24,16 @@
>> $focus = new Quote();
>>$focus->retrieve_entity_info($_REQUEST['record'],"Quotes");
>> $account_name =
>>getAccountName($focus->column_fields[account_id]);
>>-$iData[] = $account_name;
>>+$iData = array($account_name);
>> $iData[] = $id;
>> $iData[] = date('Y-m-d');
>>
>> //setting the Customer Data
>>-$iCustData[] = $account_name;
>>+//code contributed by Tyler Bannister for inproving quotes
>>+$iCustData = array($account_name);
>>
>>+$title = $focus->column_fields['subject'];
>>+$salesperson = $current_user->first_name .' '. $current_user->last_name;
>> if($focus->column_fields["duedate"] != '')
>> {
>>        $due_date = $focus->column_fields["validtill"];
>>@@ -35,7 +45,7 @@
>> $iCustData[] = $due_date;
>>
>> //setting the billing address
>>-$bdata[] = $account_name;
>>+$bdata = array('', $account_name);
>> if($focus->column_fields["bill_street"] != '')
>> {
>>         $bill_street =
>>$focus->column_fields["bill_street"];
>>@@ -70,16 +80,16 @@
>>        $bdata[] = $bill_country;
>> }
>>
>>-for($i =0; $i <5; $i++)
>>+for($i =0; $i <10; $i++)
>> {
>>-       if(sizeof($bdata) < 6)
>>+       if(sizeof($bdata) < 11)
>>        {
>>                $bdata[] = ' ';
>>        }
>> }
>>
>> //setting the shipping address
>>-$sdata[] = $account_name;
>>+$sdata = array('', $account_name);
>> if($focus->column_fields["ship_street"] != '')
>> {
>>         $ship_street =
>>$focus->column_fields["ship_street"];
>>@@ -113,9 +123,9 @@
>>        $sdata[] = $ship_country;
>> }
>>
>>-for($i =0; $i <5; $i++)
>>+for($i =0; $i <10; $i++)
>> {
>>-       if(sizeof($sdata) < 6)
>>+       if(sizeof($sdata) < 11)
>>        {
>>                $sdata[] = ' ';
>>        }
>>@@ -143,14 +153,14 @@
>>
>> if($num_rows == 1)
>> {
>>-       $org_name =
>>$adb->query_result($result,0,"organizationame");
>>+       $org_name    =
>>$adb->query_result($result,0,"organizationame");
>>        $org_address =
>>$adb->query_result($result,0,"address");
>>-       $org_city = $adb->query_result($result,0,"city");
>>-       $org_state = $adb->query_result($result,0,"state");
>>+       $org_city    =
>>$adb->query_result($result,0,"city");
>>+       $org_state   =
>>$adb->query_result($result,0,"state");
>>        $org_country =
>>$adb->query_result($result,0,"country");
>>-       $org_code = $adb->query_result($result,0,"code");
>>-       $org_phone = $adb->query_result($result,0,"phone");
>>-       $org_fax = $adb->query_result($result,0,"fax");
>>+       $org_code    =
>>$adb->query_result($result,0,"code");
>>+       $org_phone   =
>>$adb->query_result($result,0,"phone");
>>+       $org_fax     = $adb->query_result($result,0,"fax");
>>        $org_website =
>>$adb->query_result($result,0,"website");
>>
>>        if($org_name != '')
>>@@ -159,19 +169,22 @@
>>        }
>>        if($org_address != '' || $org_city != '' || $org_state != '')
>>        {
>>-               $companyaddress[] = $org_address.' '.$org_city.'
>>'.$org_state;
>>+               $companyaddress[] = $org_address;
>>+               $companyaddress[] = $org_city .', '.$org_state;
>>        }
>>        if($org_country != '' || $org_code!= '')
>>        {
>>                $companyaddress[] = $org_country.' '.$org_code;
>>        }
>>+       $companyaddress[] = '';
>>        if($org_phone != '' || $org_fax != '')
>>        {
>>-               $companyaddress[] = $org_phone.' '.$org_fax;
>>+               $companyaddress[] = $app_strings['Phone_Short'] .': '.
>>$org_phone;
>>+               $companyaddress[] = $app_strings['Fax'] .': '. $org_fax;
>>        }
>>        if($org_website != '')
>>        {
>>-               $companyaddress[] = $org_website;
>>+               $companyaddress[] = $app_strings['Website_Short']. ': '.
>>$org_website;
>>        }
>>
>>        for($i =0; $i < 4; $i++)
>>@@ -188,6 +201,8 @@
>>
>>
>>
>>+//$companyaddress = Array('AdventNet, Inc.','11 Sarathy
>>Nagar','Velachery','Vijayanagar','Chennai - 600042');
>>+
>> //getting the Product Data
>> $query="select products.productname,products.unit_price,quotesproductrel.*
>>from quotesproductrel inner join products on
>>products.productid=quotesproductrel.productid where
>>quoteid=".$id;
>>
>>@@ -205,211 +220,36 @@
>>
>>        $temp_data['productname'] = $productname;
>>        $temp_data['qty'] = $qty;
>>-       $temp_data['unitprice'] = $unitprice;
>>-       $temp_data['listprice'] = $listprice;
>>-       $temp_data['total'] = $total;
>>+       $temp_data['unitprice'] = sprintf('%0.2f',$unitprice);
>>+       $temp_data['listprice'] = sprintf('%0.2f',$listprice);
>>+       $temp_data['total']     = sprintf('%0.2f',$total);
>>        $iDataDtls[] = $temp_data;
>>
>> }
>> //getting the Total Array
>>-$price_total[] = $focus->column_fields["hdnSubTotal"];
>>-$price_total[] = $focus->column_fields["txtTax"];
>>-$price_total[] = $focus->column_fields["txtAdjustment"];
>>-$price_total[] = $focus->column_fields["hdnGrandTotal"];
>>-
>>-class PDF extends FPDF
>>-{
>>+$price_total[] =
>>sprintf('%0.2f',$focus->column_fields["hdnSubTotal"]);
>>+$price_total[] =
>>sprintf('%0.2f',$focus->column_fields["txtTax"]);
>>+$price_total[] =
>>sprintf('%0.2f',$focus->column_fields["txtAdjustment"]);
>>+$price_total[] =
>>sprintf('%0.2f',$focus->column_fields["hdnGrandTotal"]);
>>
>>-// Invoice Title
>>-function setInvoiceTitle($title,$logo_name,$caddress)
>>-{
>>-       if($title != "")
>>-       {
>>-               if(isset($logo_name) && $logo_name != '')
>>-               {
>>-
>>$this->Image('test/logo/'.$logo_name,10,10,0,0);
>>-               }
>>-               else
>>-               {
>>-
>>//$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0);
>>-               }
>>-               for($i=0;$i<count($caddress);$i++)
>>-               {
>>-
>>-                       $this->Ln();
>>-                       $this->Cell(40);
>>-                       $this->SetFont('','',10);
>>-
>>$this->Cell(0,5,$caddress[$i],0,0,'L',0);
>>-               }
>>-               $this->Ln();
>>-               $this->SetFillColor(224,235,255);
>>-               $this->SetTextColor(0);
>>-               $this->SetFont('','B',18);
>>-               $this->Cell(0,10,$title,0,0,'C',0);
>>-
>>-       }
>>-}
>>-//Invoice Address
>>-function setAddress($billing="",$shipping="")
>>-{
>>-
>>-       $this->Ln();
>>-       $this->SetFillColor(224,235,255);
>>-       $this->SetTextColor(0);
>>-       $this->SetFont('','B',10);
>>-       $this->Cell(130,10,"Bill To:",0,0,'L',0);
>>-       $this->Cell(0,10,"Ship To:",0,0,'L',0);
>>-       for($i=0;$i<count($billing);$i++)
>>-       {
>>-               $this->Cell(17);
>>-               $this->SetFont('','',10);
>>-               $this->Cell(130,5,$billing[$i],0,0,'L',0);
>>-               $this->Cell(0,5,$shipping[$i],0,0,'L',0);
>>-               $this->Ln();
>>-       }
>>-
>>-}
>>-//Invoice from
>>-function setInvoiceDetails($iHeader,$iData)
>>-{
>>-    $this->Ln();
>>-    $this->SetFillColor(162,200,243);
>>-    $this->SetTextColor(0);
>>-    $this->SetDrawColor(61,121,206);
>>-    //$this->SetLineWidth(.3);
>>-    $this->SetFont('Arial','B',10);
>>-    //Header
>>-    $this->Cell(15);
>>-    foreach($iHeader as $value)
>>-    {
>>-        $this->Cell(40,7,$value,1,0,'L',1);
>>-    }
>>-    $this->Ln();
>>-    $this->SetFillColor(233,241,253);
>>-    $this->SetTextColor(0);
>>-    $this->SetFont('');
>>-    //Data
>>-    $this->Cell(15);
>>-    $fill=0;
>>-    foreach($iData as $value)
>>-    {
>>-               $this->Cell(40,6,$value,1,0,'L',0);
>>-    }
>>-    $this->Ln();
>>-}
>>-
>>-//customer Details
>>-function setCustomerDetails($iCHeader,$iCData)
>>-{
>>-    $this->Ln();
>>-    //$this->Cell(0);
>>-    $this->SetFillColor(162,200,243);
>>-    $this->SetTextColor(0);
>>-    $this->SetDrawColor(61,121,206);
>>-    //$this->SetLineWidth(.3);
>>-    $this->SetFont('Arial','B',10);
>>-    //Header
>>-    //$this->Cell(15);
>>-    foreach($iCHeader as $value)
>>-    {
>>-        $this->Cell(63,7,$value,1,0,'L',1);
>>-    }
>>-    $this->Ln();
>>-    $this->SetFillColor(233,241,253);
>>-    $this->SetTextColor(0);
>>-    $this->SetFont('');
>>-    //Data
>>-    //$this->Cell(15);
>>-    $fill=0;
>>-    foreach($iCData as $value)
>>-    {
>>-               $this->Cell(63,6,$value,1,0,'L',0);
>>-    }
>>-    $this->Ln();
>>-}
>>-
>>-//Product Details
>>-function setProductDetails($ivHeader,$ivData)
>>-{
>>-    $this->Ln();
>>-    $this->Ln();
>>-    $this->SetFillColor(162,200,243);
>>-    $this->SetTextColor(0);
>>-    $this->SetDrawColor(61,121,206);
>>-    $this->SetLineWidth(.3);
>>-    $this->SetFont('Arial','B',10);
>>-    //Header
>>-    foreach($ivHeader as $value)
>>-    {
>>-        $this->Cell(38,7,$value,0,0,'L',0);
>>-    }
>>-    $this->Ln();
>>-    $this->SetDrawColor(0,0,0);
>>-    $this->SetLineWidth(.5);
>>-    $this->line(10,140,200,140);
>>-    $this->SetFillColor(233,241,253);
>>-    $this->SetTextColor(0);
>>-    $this->SetFont('');
>>-    //Data
>>-    $fill=0;
>>-       foreach($ivData as $key=>$value)
>>-       {
>>-
>>$this->Cell(38,6,$value['productname'],0,0,'L',0);
>>-               $this->Cell(38,6,$value['qty'],0,0,'L',0);
>>-
>>$this->Cell(38,6,$value['unitprice'],0,0,'L',0);
>>-
>>$this->Cell(38,6,$value['listprice'],0,0,'L',0);
>>-
>>$this->Cell(38,6,$value['total'],0,0,'R',0);
>>-               $this->Ln();
>>-       }
>>-    $this->Ln();
>>-}
>>-
>>-function setTotal($price_total="",$conditions="")
>>-{
>>-       $this->Ln();
>>-       $this->SetDrawColor(0,0,0);
>>-       $this->SetLineWidth(.3);
>>-//     $this->line(10,200,200,200);
>>-       $this->SetFillColor(224,235,255);
>>-       $this->SetTextColor(0);
>>-       $this->SetFont('','B',10);
>>-       $this->Cell(140,6,"Sub Total: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[0],1,0,'R',0);
>>-       $this->Ln(4);
>>-       $this->Ln(4);
>>-       $this->Cell(140,6,"Tax: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[1],1,0,'R',0);
>>-       $this->Ln(4);
>>-       $this->Ln(4);
>>-       $this->Cell(140,6,"Adjustment: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[2],1,0,'R',0);
>>-       $this->Ln(4);
>>-       $this->Ln(4);
>>-       $this->Cell(140,6,"Grand total: ",0,0,'R',0);
>>-       $this->Cell(0,6,$price_total[3],1,0,'R',0);
>>-       $this->Ln();
>>-       $this->Ln();
>>-       $this->Cell(0,8,"Terms & Conditions: ",0,0,'L',0);
>>-       $this->Ln();
>>-       $this->Cell(0,8,$conditions,0,0,'L',0);
>>-}
>>-}
>> //$bdata = array("aaaaaaaaa","48/1,Katcherry
>>Street","Rasipuram","Namakkal (D.T)");
>> //$sdata = array("bbbbbb","48/9","","mmmm","Don City");
>> $iHead = array("Company","Quote No.","Date");
>> $iCustHeadDtls = array("Customer Name","Valid Till");
>> //$iCustData = array("Nortel
>>Networks","usc-107565","26-05-2005");
>>-$iHeadDtls = array("Product Name","Quantity","List Price","Unit
>>Price","Total");
>>+$iHeadDtls = array("Quantity", "Product Name","List Price","Unit
>>Price","Total");
>>
>>-$pdf = new PDF('P','mm','A4');
>>-$pdf->SetFont('Arial','',10);
>>+$pdf = new PDFSheet();
>>+$pdf->setInvoiceHeader($title,$logo_name,$companyaddress);
>>+$pdf->setInvoiceFooter(QUOTE_TERMS, $conditions);
>> $pdf->AddPage();
>>-$pdf->setInvoiceTitle("Quotes",$logo_name,$companyaddress);
>> $pdf->Ln();
>>-$pdf->setInvoiceDetails($iHead,$iData);
>> $pdf->setAddress($bdata,$sdata);
>>-$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
>>+$pdf->setInvoiceSummary(QUOTE_SERVICE_NUMBER,$id,
>>+                        QUOTE_SALESPERSON,$salesperson,
>>+                        QUOTE_DATE);
>> $pdf->setProductDetails($iHeadDtls,$iDataDtls);
>> $pdf->setTotal($price_total,$conditions);
>>-$pdf->Output();
>>+$pdf->Output('Quote.pdf','D');
>>+exit;
>> ?>
>>
>>
>>FPDF($orientation,$unit,$format); $this->pdf_font = $font;
>>$this->SetFont($this->pdf_font,'',10); } function Header()
>>{ if ($this->header_image != '') {
>>$this->Image($this->header_image,10,10,0,0); } else { //
>>$this->Image('themes/Aqua/images/blank.jpg',10,10,0,0); }
>>if ($this->header_title != '') {
>>$this->SetFillColor($this->pdf_fill_color[0],
>>$this->pdf_fill_color[1], $this->pdf_fill_color[2]);
>>$this->SetTextColor($this->title_text_color[0],
>>$this->title_text_color[1], $this->title_text_color[2]); $this->Cell(80);
>>$this->SetFont($this->pdf_font,'B',18);
>>$this->Cell(30,10,$this->header_title,0,0,'C',0); }
>>$this->SetTextColor($this->pdf_text_color[0],
>>$this->pdf_text_color[1], $this->pdf_text_color[2]); $this->SetY(5); if
>>(is_array($this->header_address)) {
>>for($i=0;$iheader_address);$i++) { $this->Cell(150);
>>$this->SetFont($this->pdf_font,'',8);
>>$this->Cell(0,5,$this->header_address[$i],0,0,'L',0);
>>$this->Ln(3.2); } } } function Footer() { $this->SetY(-20);
>>$this->Cell(0,8,$this->footer_title,0,0,'C',0);
>>$this->Ln();
>>$this->Cell(0,8,$this->footer_terms,0,0,'L',0); } function
>>drawHeader($header,$width=40,$height=7) {
>>$this->SetFillColor($this->header_fill_color[0],
>>$this->header_fill_color[1], $this->header_fill_color[2]);
>>$this->SetTextColor($this->header_text_color[0],
>>$this->header_text_color[1], $this->header_text_color[2]);
>>$this->SetDrawColor($this->table_border_color[0],
>>$this->table_border_color[1], $this->table_border_color[2]);
>>$this->SetFont($this->pdf_font,'B',10);
>>$this->Cell($width,$height,$header,1,0,'C',1); $this->Ln();
>>} function drawCell($data,$width=40,$height=7) {
>>$this->SetFont($this->pdf_font,'',8);
>>$this->SetFillColor($this->table_fill_color[0],
>>$this->table_fill_color[1], $this->table_fill_color[2]);
>>$this->SetTextColor($this->table_text_color[0],
>>$this->table_text_color[1], $this->table_text_color[2]);
>>$this->Cell($width,$height,$data,1,0,'C',1);
>>$this->Ln($height); } // $headers should be a one-dimensional array of
>>headers // $data should be a two-dimensional array of data // $col_size
>>should be a one-dimensional array of column widths function
>>drawTable($headers, $data, $col_size = '', $x = -1, $y = -1) { if ($x != -1)
>>{ $this->SetLeftMargin($x); $this->SetX($x); } if ($y != -1) {
>>$this->SetY($y); } if ($col_size == '') { $col_size =
>>array_fill(0,sizeof($headers)-1, 190 / sizeof($headers)); }
>>$this->SetFillColor($this->header_fill_color[0],
>>$this->header_fill_color[1], $this->header_fill_color[2]);
>>$this->SetTextColor($this->header_text_color[0],
>>$this->header_text_color[1], $this->header_text_color[2]);
>>$this->SetDrawColor($this->table_border_color[0],
>>$this->table_border_color[1], $this->table_border_color[2]);
>>$this->SetFont($this->pdf_font,'B',10); foreach ($headers
>>as $num => $cell) {
>>$this->Cell($col_size[$num],7,$cell,1,0,'C',1); }
>>$this->Ln(); $size = 3.2;
>>$this->SetFont($this->pdf_font,'',8);
>>$this->SetFillColor($this->table_fill_color[0],
>>$this->table_fill_color[1], $this->table_fill_color[2]);
>>$this->SetTextColor($this->table_text_color[0],
>>$this->table_text_color[1], $this->table_text_color[2]); $borders = 'LRT';
>>foreach ($data as $row => $set) { if ($row == 1) { $borders = 'LR'; } if
>>($row == sizeof($data) - 1) { $borders = 'LRB'; } if (is_array($set)) {
>>foreach($set as $num => $cell) {
>>$this->Cell($col_size[$num],$size,$cell,$borders,0,'L',1);
>>} } else {
>>$this->Cell($col_size[$num],$size,$set,$borders,0,'L',1); }
>>$this->Ln($size); } if ($x != -1) { $this->SetLeftMargin(10);
>>$this->SetX(10); } } // Invoice Title function
>>setInvoiceHeader($title='',$logo_name='',$caddress='') {
>>if(isset($logo_name) && $logo_name != '') { $this->header_image =
>>'test/logo/'.$logo_name; } $this->header_address = $caddress;
>>$this->header_title = $title; } function setInvoiceFooter($title='',
>>$terms='') { $this->footer_title = $title; $this->footer_terms = $terms; }
>>// Invoice Address // Both $billing and $shipping should be arrays function
>>setAddress($billing=array(), $shipping=array()) {
>>$this->drawTable(array(SHEET_BILLING_HEADER),$billing,
>>array(65),10,35);
>>$this->drawTable(array(SHEET_SERVICE_HEADER),$shipping,array(65),85,35);
>>} function setInvoiceSummary($service_title, $serviceid,
>>$sales_title, $salesperson = '', $date_title) { $this->SetLeftMargin(160);
>>$this->SetX(160); $this->SetY(35); $date = date('F j, Y');
>>$this->drawHeader($service_title);
>>$this->drawCell($serviceid); $this->drawHeader($date_title);
>>$this->drawCell($date); $this->drawHeader($sales_title);
>>$this->drawCell($salesperson); $this->SetLeftMargin(10); $this->SetX(10); }
>>//Product Details function
>>setProductDetails($ivHeader,$ivData) { $this->Ln();
>>$this->Ln(); $data = array(); $col_sizes = array(20,110,20,20,20);
>>foreach($ivData as $key=>$value) { $data[] = array($value['qty'],
>>$value['productname'], $value['listprice'], $value['unitprice'],
>>$value['total']); } $this->drawTable($ivHeader, $data, $col_sizes); }
>>function setTotal($price_total="",$conditions="") {
>>$this->Ln(); $this->SetDrawColor($this->divider_color[0],
>>$this->divider_color[1], $this->divider_color[2]); $this->SetLineWidth(.3);
>>// $this->line(10,200,200,200);
>>$this->SetFillColor($this->table_fill_color[0],
>>$this->table_fill_color[1], $this->table_fill_color[2]);
>>$this->SetTextColor($this->table_text_color[0],
>>$this->table_text_color[1], $this->table_text_color[2]);
>>$this->SetFont($this->pdf_font,'B',10);
>>$this->Cell(140,6,SHEET_SUBTOTAL,0,0,'R',0);
>>$this->Cell(0,6,$price_total[0],1,0,'R',0); $this->Ln(4);
>>$this->Ln(4); $this->Cell(140,6,SHEET_TAX,0,0,'R',0);
>>$this->Cell(0,6,$price_total[1],1,0,'R',0); $this->Ln(4);
>>$this->Ln(4); $this->Cell(140,6,SHEET_ADJUST,0,0,'R',0);
>>$this->Cell(0,6,$price_total[2],1,0,'R',0); $this->Ln(4);
>>$this->Ln(4); $this->Cell(140,6,SHEET_TOTAL,0,0,'R',0);
>>$this->Cell(0,6,$price_total[3],1,0,'R',0); $this->Ln();
>>$this->Ln(); } } ?>
>>
>>    
>>


--
Tyler Bannister
NetAccess Systems Inc.
905-524-2001 xt432



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
vtigercrm-contributors mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vtigercrm-contributors
Loading...