[Vtigercrm-commits] [vtiger-commits] r5307 - in /vtigercrm/branches/4.2: include/ modules/Invoice/ modules/Invoice/pdf_templates/ modules/Invoice/pdf_templates/lastpage/ modules/Orders/ modules/Orders/pdf_templates/ modules/Orders/pdf_templates/lastpage/ modules/Quotes/ modules/Quotes/pdf_templates/ modules/Quotes/pdf_templates/lastpage/
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Tue Apr 25 00:32:05 EDT 2006
Author: mmbrich
Date: Mon Apr 24 22:31:58 2006
New Revision: 5307
Log:
initial check-in of new PDF code.
Fixed errors resulting in the entityid's not being quoted in utils.php
Added:
vtigercrm/branches/4.2/include/VtigerPDF.php
vtigercrm/branches/4.2/modules/Invoice/pdf_data.php
vtigercrm/branches/4.2/modules/Invoice/pdf_templates/
vtigercrm/branches/4.2/modules/Invoice/pdf_templates/body.php
vtigercrm/branches/4.2/modules/Invoice/pdf_templates/footer.php
vtigercrm/branches/4.2/modules/Invoice/pdf_templates/header.php
vtigercrm/branches/4.2/modules/Invoice/pdf_templates/lastpage/
vtigercrm/branches/4.2/modules/Invoice/pdf_templates/lastpage/body.php
vtigercrm/branches/4.2/modules/Invoice/pdf_templates/lastpage/footer.php
vtigercrm/branches/4.2/modules/Invoice/pdf_templates/license.txt
vtigercrm/branches/4.2/modules/Orders/pdf_data.php
vtigercrm/branches/4.2/modules/Orders/pdf_dataso.php
vtigercrm/branches/4.2/modules/Orders/pdf_templates/
vtigercrm/branches/4.2/modules/Orders/pdf_templates/body.php
vtigercrm/branches/4.2/modules/Orders/pdf_templates/lastpage/
vtigercrm/branches/4.2/modules/Orders/pdf_templates/lastpage/body.php
vtigercrm/branches/4.2/modules/Orders/pdf_templates/lastpage/po_footer.php
vtigercrm/branches/4.2/modules/Orders/pdf_templates/lastpage/so_footer.php
vtigercrm/branches/4.2/modules/Orders/pdf_templates/license.txt
vtigercrm/branches/4.2/modules/Orders/pdf_templates/po_footer.php
vtigercrm/branches/4.2/modules/Orders/pdf_templates/po_header.php
vtigercrm/branches/4.2/modules/Orders/pdf_templates/so_footer.php
vtigercrm/branches/4.2/modules/Orders/pdf_templates/so_header.php
vtigercrm/branches/4.2/modules/Quotes/pdf_data.php
vtigercrm/branches/4.2/modules/Quotes/pdf_templates/
vtigercrm/branches/4.2/modules/Quotes/pdf_templates/body.php
vtigercrm/branches/4.2/modules/Quotes/pdf_templates/footer.php
vtigercrm/branches/4.2/modules/Quotes/pdf_templates/header.php
vtigercrm/branches/4.2/modules/Quotes/pdf_templates/lastpage/
vtigercrm/branches/4.2/modules/Quotes/pdf_templates/lastpage/body.php
vtigercrm/branches/4.2/modules/Quotes/pdf_templates/lastpage/footer.php
vtigercrm/branches/4.2/modules/Quotes/pdf_templates/license.txt
Modified:
vtigercrm/branches/4.2/include/utils.php
vtigercrm/branches/4.2/modules/Invoice/CreatePDF.php
vtigercrm/branches/4.2/modules/Orders/CreatePDF.php
vtigercrm/branches/4.2/modules/Orders/CreateSOPDF.php
vtigercrm/branches/4.2/modules/Quotes/CreatePDF.php
Modified: vtigercrm/branches/4.2/include/utils.php
==============================================================================
--- vtigercrm/branches/4.2/include/utils.php (original)
+++ vtigercrm/branches/4.2/include/utils.php Mon Apr 24 22:31:58 2006
@@ -2342,7 +2342,7 @@
global $vtlog;
$vtlog->logthis("in getQuoteName ".$quote_id,'info');
global $adb;
- $sql = "select * from quotes where quoteid=".$quote_id;
+ $sql = "select * from quotes where quoteid='".$quote_id."'";
$result = $adb->query($sql);
$quote_name = $adb->query_result($result,0,"subject");
return $quote_name;
@@ -2375,7 +2375,7 @@
global $vtlog;
$vtlog->logthis("in getSoName ".$so_id,'info');
global $adb;
- $sql = "select * from salesorder where salesorderid=".$so_id;
+ $sql = "select * from salesorder where salesorderid='".$so_id."'";
$result = $adb->query($sql);
$so_name = $adb->query_result($result,0,"subject");
return $so_name;
Modified: vtigercrm/branches/4.2/modules/Invoice/CreatePDF.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Invoice/CreatePDF.php (original)
+++ vtigercrm/branches/4.2/modules/Invoice/CreatePDF.php Mon Apr 24 22:31:58 2006
@@ -1,433 +1,86 @@
<?php
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is: vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-require('include/fpdf/fpdf.php');
-require_once('modules/Invoice/Invoice.php');
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * (c) 2005 Matthew Brichacek <mmbrich at fosslabs.com>
+ *
+ * Changes/Additions:
+ *
+ * (c) 2005 OpenCRM
+ * - Improved currency support
+ * - Fixed IE download bug
+ */
+
+require_once('include/database/PearDatabase.php');
+
+global $adb;
+global $app_strings;
+global $max_desc_size;
+global $max_prod_desc_size;
+global $products_per_page;
$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]);
-$iData[] = $account_name;
-$iData[] = $id;
-$iData[] = date('Y-m-d');
-//newly added for Sales Order No.
-if($focus->column_fields["salesorder_id"] != '')
+
+$sql="select currency_symbol from currency_info";
+$result = $adb->query($sql);
+$currency_symbol = $adb->query_result($result,0,'currency_symbol');
+
+/* ************ BEGIN USER CONFIG **************** */
+$endpage="0";
+$products_per_page="9";
+$max_prod_desc_size="75";
+$max_desc_size="175";
+/* *********** END USER CONFIG ****************** */
+
+require_once('include/VtigerPDF.php');
+require_once('pdf_data.php');
+$page_num='1';
+$pdf = new PDF( 'P', 'mm', 'A4' );
+$pdf->Open();
+
+$num_pages=ceil(($num_products/$products_per_page));
+$current_product=0;
+
+for($l=0;$l<$num_pages;$l++)
{
- $so_name = getSoName($focus->column_fields["salesorder_id"]);
-}
-else
-{
- $so_name = ' ';
-}
+ $line=array();
+ if($num_pages == $page_num)
+ $lastpage=1;
+
+ while($current_product != $page_num*$products_per_page)
+ {
+ $line[]=$product_line[$current_product];
+ $current_product++;
+ }
-$iData[] = $so_name;
+ $pdf->AddPage();
+ include("pdf_templates/header.php");
+ include("pdf_templates/body.php");
+ include("pdf_templates/footer.php");
-//setting the Customer Data
-$iCustData[] = $account_name;
+ $page_num++;
-if($focus->column_fields["purchaseorder"] != '')
-{
- $po_name = $focus->column_fields["purchaseorder"];
-}
-else
-{
- $po_name = ' ';
-}
-$iCustData[] = $po_name;
-
-if($focus->column_fields["duedate"] != '')
-{
- $due_date = $focus->column_fields["duedate"];
-}
-else
-{
- $due_date = ' ';
-}
-$iCustData[] = $due_date;
-
-//setting the billing address
-$bdata[] = $account_name;
-if($focus->column_fields["bill_street"] != '')
-{
- $bill_street = $focus->column_fields["bill_street"];
- $bdata[] = $bill_street;
-
-}
-
-if($focus->column_fields["bill_city"] != '')
-{
- $bill_city = $focus->column_fields["bill_city"];
- $bdata[] = $bill_city;
-}
-
-
-if($focus->column_fields["bill_state"] != '')
-{
- $bill_state = $focus->column_fields["bill_state"];
- $bdata[] = $bill_state;
-}
-
-
-if($focus->column_fields["bill_code"] != '')
-{
- $bill_code = $focus->column_fields["bill_code"];
- $bdata[] = $bill_code;
-}
-
-
-if($focus->column_fields["bill_country"] != '')
-{
- $bill_country = $focus->column_fields["bill_country"];
- $bdata[] = $bill_country;
-}
-
-for($i =0; $i <5; $i++)
-{
- if(sizeof($bdata) < 6)
+ if (($endpage) && ($lastpage))
{
- $bdata[] = ' ';
+ $pdf->AddPage();
+ include("pdf_templates/header.php");
+ include("pdf_templates/lastpage/body.php");
+ include("pdf_templates/lastpage/footer.php");
}
}
-//setting the shipping address
-$sdata[] = $account_name;
-if($focus->column_fields["ship_street"] != '')
-{
- $ship_street = $focus->column_fields["ship_street"];
- $sdata[] = $ship_street;
-}
-
-if($focus->column_fields["ship_city"] != '')
-{
- $ship_city = $focus->column_fields["ship_city"];
- $sdata[] = $ship_city;
-}
-
-
-if($focus->column_fields["ship_state"] != '')
-{
- $ship_state = $focus->column_fields["ship_state"];
- $sdata[] = $ship_state;
-}
-
-
-if($focus->column_fields["ship_code"] != '')
-{
- $ship_code = $focus->column_fields["ship_code"];
- $sdata[] = $ship_code;
-}
-
-
-if($focus->column_fields["ship_country"] != '')
-{
- $ship_country = $focus->column_fields["ship_country"];
- $sdata[] = $ship_country;
-}
-
-for($i =0; $i <5; $i++)
-{
- if(sizeof($sdata) < 6)
- {
- $sdata[] = ' ';
- }
-}
-
-//Getting the terms_conditions
-
-if($focus->column_fields["terms_conditions"] != '')
-{
- $conditions = $focus->column_fields["terms_conditions"];
-}
-else
-{
- $conditions = ' ';
-}
-
-//Getting the Company Address
-$add_query = "select * from organizationdetails";
-$result = $adb->query($add_query);
-$num_rows = $adb->num_rows($result);
-$org_field_array = Array('organizationame','address','city','state','country','code','phone','fax','website');
-
-$companyaddress = Array();
-$logo_name = '';
-
-if($num_rows == 1)
-{
- $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_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_website = $adb->query_result($result,0,"website");
-
- if($org_name != '')
- {
- $companyaddress[] = $org_name;
- }
- if($org_address != '' || $org_city != '' || $org_state != '')
- {
- $companyaddress[] = $org_address.' '.$org_city.' '.$org_state;
- }
- if($org_country != '' || $org_code!= '')
- {
- $companyaddress[] = $org_country.' '.$org_code;
- }
- if($org_phone != '' || $org_fax != '')
- {
- $companyaddress[] = $org_phone.' '.$org_fax;
- }
- if($org_website != '')
- {
- $companyaddress[] = $org_website;
- }
-
- for($i =0; $i < 4; $i++)
- {
- if(sizeof($companyaddress) < 5)
- {
- $companyaddress[] = ' ';
- }
- }
-
- $logo_name = $adb->query_result($result,0,"logoname");
-}
-//Getting the logo
-
-
-//getting the Product Data
-$query="select products.productname,products.unit_price,invoiceproductrel.* from invoiceproductrel inner join products on products.productid=invoiceproductrel.productid where invoiceid=".$id;
-
-$result = $adb->query($query);
-$num_rows=$adb->num_rows($result);
-for($i=1;$i<=$num_rows;$i++)
-{
- $temp_data = Array();
- $productname=$adb->query_result($result,$i-1,'productname');
- $unitprice=$adb->query_result($result,$i-1,'unit_price');
- $productid=$adb->query_result($result,$i-1,'productid');
- $qty=$adb->query_result($result,$i-1,'quantity');
- $listprice=$adb->query_result($result,$i-1,'listprice');
- $total = $qty*$listprice;
-
- $temp_data['productname'] = $productname;
- $temp_data['qty'] = $qty;
- $temp_data['unitprice'] = $unitprice;
- $temp_data['listprice'] = $listprice;
- $temp_data['total'] = $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);
-
- }
-}
-//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;
- if($ivData) 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);
-}
-}
-$iHead = array("Company","Invoice No.","Date","Sales Order No.");
-$iCustHeadDtls = array("Customer Name","Purchase Order","Due Date");
-$iHeadDtls = array("Product Name","Quantity","List Price","Unit Price","Total");
-
-$pdf = new PDF('P','mm','A4');
-$pdf->SetFont('Arial','',10);
-$pdf->AddPage();
-$pdf->setInvoiceTitle("Invoice",$logo_name,$companyaddress);
-$pdf->Ln();
-$pdf->setInvoiceDetails($iHead,$iData);
-$pdf->setAddress($bdata,$sdata);
-$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
-$pdf->setProductDetails($iHeadDtls,$iDataDtls);
-$pdf->setTotal($price_total,$conditions);
-$pdf->Output('Invoice.pdf','D');
+$pdf->Output('Invoice.pdf','D'); //added file name to make it work in IE, also forces the download giving the user the option to save
exit;
?>
Modified: vtigercrm/branches/4.2/modules/Orders/CreatePDF.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Orders/CreatePDF.php (original)
+++ vtigercrm/branches/4.2/modules/Orders/CreatePDF.php Mon Apr 24 22:31:58 2006
@@ -1,434 +1,87 @@
<?php
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is: vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-require('include/fpdf/fpdf.php');
-require_once('modules/Orders/Order.php');
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * (c) 2005 Matthew Brichacek <mmbrich at fosslabs.com>
+ *
+ * Changes/Additions:
+ *
+ * (c) 2005 OpenCRM
+ * - Improved currency support
+ * - Fixed IE download bug
+ */
+
+require_once('include/database/PearDatabase.php');
+
+global $adb;
+global $app_strings;
+global $max_desc_size;
+global $products_per_page;
+global $max_prod_desc_size;
$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]);
-$iData[] = $vendor_name;
-$iData[] = $id;
-$iData[] = date('Y-m-d');
-//newly added for Sales Order No.
-if($focus->column_fields["requisition_no"] != '')
+$sql="select currency_symbol from currency_info";
+$result = $adb->query($sql);
+$currency_symbol = $adb->query_result($result,0,'currency_symbol');
+
+/* ************ BEGIN USER CONFIG *************** */
+$endpage="0";
+$products_per_page="9";
+$max_desc_size="175";
+$max_prod_desc_size="75";
+/* ************ END USER CONFIG ***************** */
+
+require_once('include/VtigerPDF.php');
+require_once('pdf_data.php');
+
+$page_num='1';
+$pdf = new PDF( 'P', 'mm', 'A4' );
+$pdf->Open();
+
+$num_pages=ceil(($num_products/$products_per_page));
+$current_product=0;
+
+for($l=0;$l<$num_pages;$l++)
{
- $reqno = $focus->column_fields["requisition_no"];
-}
-else
-{
- $reqno = ' ';
-}
+ $line=array();
+ if($num_pages == $page_num)
+ $lastpage=1;
+
+ while($current_product != $page_num*$products_per_page)
+ {
+ $line[]=$product_line[$current_product];
+ $current_product++;
+ }
-$iData[] = $reqno;
+ $pdf->AddPage();
+ include("pdf_templates/po_header.php");
+ include("pdf_templates/body.php");
+ include("pdf_templates/po_footer.php");
-//setting the Customer Data
-$iCustData[] = $vendor_name;
+ $page_num++;
-if($focus->column_fields["tracking_no"] != '')
-{
- $trno = $focus->column_fields["tracking_no"];
-}
-else
-{
- $trno = ' ';
-}
-$iCustData[] = $trno;
-
-if($focus->column_fields["duedate"] != '')
-{
- $due_date = $focus->column_fields["duedate"];
-}
-else
-{
- $due_date = ' ';
-}
-$iCustData[] = $due_date;
-
-//setting the billing address
-$bdata[] = $vendor_name;
-if($focus->column_fields["bill_street"] != '')
-{
- $bill_street = $focus->column_fields["bill_street"];
- $bdata[] = $bill_street;
-
-}
-
-if($focus->column_fields["bill_city"] != '')
-{
- $bill_city = $focus->column_fields["bill_city"];
- $bdata[] = $bill_city;
+ if (($endpage) && ($lastpage))
+ {
+ $pdf->AddPage();
+ include("pdf_templates/po_header.php");
+ include("pdf_templates/lastpage/body.php");
+ include("pdf_templates/lastpage/po_footer.php");
+ }
}
-if($focus->column_fields["bill_state"] != '')
-{
- $bill_state = $focus->column_fields["bill_state"];
- $bdata[] = $bill_state;
-}
-
-
-if($focus->column_fields["bill_code"] != '')
-{
- $bill_code = $focus->column_fields["bill_code"];
- $bdata[] = $bill_code;
-}
-
-
-if($focus->column_fields["bill_country"] != '')
-{
- $bill_country = $focus->column_fields["bill_country"];
- $bdata[] = $bill_country;
-}
-
-for($i =0; $i <5; $i++)
-{
- if(sizeof($bdata) < 6)
- {
- $bdata[] = ' ';
- }
-}
-
-//setting the shipping address
-$sdata[] = $vendor_name;
-if($focus->column_fields["ship_street"] != '')
-{
- $ship_street = $focus->column_fields["ship_street"];
- $sdata[] = $ship_street;
-}
-
-if($focus->column_fields["ship_city"] != '')
-{
- $ship_city = $focus->column_fields["ship_city"];
- $sdata[] = $ship_city;
-}
-
-
-if($focus->column_fields["ship_state"] != '')
-{
- $ship_state = $focus->column_fields["ship_state"];
- $sdata[] = $ship_state;
-}
-
-
-if($focus->column_fields["ship_code"] != '')
-{
- $ship_code = $focus->column_fields["ship_code"];
- $sdata[] = $ship_code;
-}
-
-
-if($focus->column_fields["ship_country"] != '')
-{
- $ship_country = $focus->column_fields["ship_country"];
- $sdata[] = $ship_country;
-}
-
-for($i =0; $i <5; $i++)
-{
- if(sizeof($sdata) < 6)
- {
- $sdata[] = ' ';
- }
-}
-
-//Getting the terms_conditions
-
-if($focus->column_fields["terms_conditions"] != '')
-{
- $conditions = $focus->column_fields["terms_conditions"];
-}
-else
-{
- $conditions = ' ';
-}
-
-//Getting the Company Address
-$add_query = "select * from organizationdetails";
-$result = $adb->query($add_query);
-$num_rows = $adb->num_rows($result);
-$org_field_array = Array('organizationame','address','city','state','country','code','phone','fax','website');
-
-$companyaddress = Array();
-$logo_name = '';
-
-if($num_rows == 1)
-{
- $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_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_website = $adb->query_result($result,0,"website");
-
- if($org_name != '')
- {
- $companyaddress[] = $org_name;
- }
- if($org_address != '' || $org_city != '' || $org_state != '')
- {
- $companyaddress[] = $org_address.' '.$org_city.' '.$org_state;
- }
- if($org_country != '' || $org_code!= '')
- {
- $companyaddress[] = $org_country.' '.$org_code;
- }
- if($org_phone != '' || $org_fax != '')
- {
- $companyaddress[] = $org_phone.' '.$org_fax;
- }
- if($org_website != '')
- {
- $companyaddress[] = $org_website;
- }
-
- for($i =0; $i < 4; $i++)
- {
- if(sizeof($companyaddress) < 5)
- {
- $companyaddress[] = ' ';
- }
- }
-
- $logo_name = $adb->query_result($result,0,"logoname");
-}
-//Getting the logo
-
-
-
-//getting the Product Data
-$query="select products.productname,products.unit_price,poproductrel.* from poproductrel inner join products on products.productid=poproductrel.productid where purchaseorderid=".$id;
-
-$result = $adb->query($query);
-$num_rows=$adb->num_rows($result);
-for($i=1;$i<=$num_rows;$i++)
-{
- $temp_data = Array();
- $productname=$adb->query_result($result,$i-1,'productname');
- $unitprice=$adb->query_result($result,$i-1,'unit_price');
- $productid=$adb->query_result($result,$i-1,'productid');
- $qty=$adb->query_result($result,$i-1,'quantity');
- $listprice=$adb->query_result($result,$i-1,'listprice');
- $total = $qty*$listprice;
-
- $temp_data['productname'] = $productname;
- $temp_data['qty'] = $qty;
- $temp_data['unitprice'] = $unitprice;
- $temp_data['listprice'] = $listprice;
- $temp_data['total'] = $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);
-
- }
-}
-//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;
- if($ivData) 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);
-}
-}
-$iHead = array("Company","Purchase Order No.","Date","Requisition No.");
-$iCustHeadDtls = array("Customer Name","Tracking No","Due Date");
-$iHeadDtls = array("Product Name","Quantity","List Price","Unit Price","Total");
-
-$pdf = new PDF('P','mm','A4');
-$pdf->SetFont('Arial','',10);
-$pdf->AddPage();
-$pdf->setInvoiceTitle("Purchase Order",$logo_name,$companyaddress);
-$pdf->Ln();
-$pdf->setInvoiceDetails($iHead,$iData);
-$pdf->setAddress($bdata,$sdata);
-$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
-$pdf->setProductDetails($iHeadDtls,$iDataDtls);
-$pdf->setTotal($price_total,$conditions);
-$pdf->Output('POOrder.pdf','D');
+$pdf->Output('PurchaseOrder.pdf','D'); //added file name to make it work in IE, also forces the download giving the user the option to save
exit;
?>
Modified: vtigercrm/branches/4.2/modules/Orders/CreateSOPDF.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Orders/CreateSOPDF.php (original)
+++ vtigercrm/branches/4.2/modules/Orders/CreateSOPDF.php Mon Apr 24 22:31:58 2006
@@ -1,435 +1,88 @@
<?php
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is: vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-require('include/fpdf/fpdf.php');
-require_once('modules/Orders/SalesOrder.php');
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * (c) 2005 Matthew Brichacek <mmbrich at fosslabs.com>
+ *
+ * Changes/Additions:
+ *
+ * (c) 2005 OpenCRM
+ * - Improved currency support
+ * - Fixed IE download bug
+ */
+
+require_once('include/database/PearDatabase.php');
+
+global $adb;
+global $app_strings;
+global $products_per_page;
+global $max_desc_size;
+global $max_prod_desc_size;
$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]);
-$iData[] = $account_name;
-$iData[] = $id;
-$iData[] = date('Y-m-d');
-//newly added for Sales Order No.
-if($focus->column_fields["quote_id"] != '')
+
+$sql="select currency_symbol from currency_info";
+$result = $adb->query($sql);
+$currency_symbol = $adb->query_result($result,0,'currency_symbol');
+
+/* ************* BEGIN USER CONFIG *************** */
+$endpage="0";
+$products_per_page="9";
+$max_desc_size="75";
+$max_prod_desc_size="175";
+/* ************* END USER CONFIG ***************** */
+
+require_once('include/VtigerPDF.php');
+require_once('pdf_dataso.php');
+
+$page_num='1';
+$pdf = new PDF( 'P', 'mm', 'A4' );
+$pdf->Open();
+
+$num_pages=ceil(($num_products/$products_per_page));
+$current_product=0;
+
+for($l=0;$l<$num_pages;$l++)
{
- $qt_name = getQuoteName($focus->column_fields["quote_id"]);
-}
-else
-{
- $qt_name = ' ';
-}
+ $line=array();
+ if($num_pages == $page_num)
+ $lastpage=1;
+
+ while($current_product != $page_num*$products_per_page)
+ {
+ $line[]=$product_line[$current_product];
+ $current_product++;
+ }
-$iData[] = $qt_name;
+ $pdf->AddPage();
+ include("pdf_templates/so_header.php");
+ include("pdf_templates/body.php");
+ include("pdf_templates/so_footer.php");
-//$iData[] = $qtname;
+ $page_num++;
-//setting the Customer Data
-$iCustData[] = $account_name;
-
-if($focus->column_fields["purchaseorder"] != '')
-{
- $po_name = $focus->column_fields["purchaseorder"];
-}
-else
-{
- $po_name = ' ';
-}
-
-$iCustData[] = $po_name;
-
-if($focus->column_fields["duedate"] != '')
-{
- $due_date = $focus->column_fields["duedate"];
-}
-else
-{
- $due_date = ' ';
-}
-$iCustData[] = $due_date;
-
-//setting the billing address
-$bdata[] = $account_name;
-if($focus->column_fields["bill_street"] != '')
-{
- $bill_street = $focus->column_fields["bill_street"];
- $bdata[] = $bill_street;
-
-}
-
-if($focus->column_fields["bill_city"] != '')
-{
- $bill_city = $focus->column_fields["bill_city"];
- $bdata[] = $bill_city;
+ if (($endpage) && ($lastpage))
+ {
+ $pdf->AddPage();
+ include("pdf_templates/so_header.php");
+ include("pdf_templates/lastpage/body.php");
+ include("pdf_templates/lastpage/so_footer.php");
+ }
}
-if($focus->column_fields["bill_state"] != '')
-{
- $bill_state = $focus->column_fields["bill_state"];
- $bdata[] = $bill_state;
-}
-
-
-if($focus->column_fields["bill_code"] != '')
-{
- $bill_code = $focus->column_fields["bill_code"];
- $bdata[] = $bill_code;
-}
-
-
-if($focus->column_fields["bill_country"] != '')
-{
- $bill_country = $focus->column_fields["bill_country"];
- $bdata[] = $bill_country;
-}
-
-for($i =0; $i <5; $i++)
-{
- if(sizeof($bdata) < 6)
- {
- $bdata[] = ' ';
- }
-}
-
-//setting the shipping address
-$sdata[] = $account_name;
-if($focus->column_fields["ship_street"] != '')
-{
- $ship_street = $focus->column_fields["ship_street"];
- $sdata[] = $ship_street;
-}
-
-if($focus->column_fields["ship_city"] != '')
-{
- $ship_city = $focus->column_fields["ship_city"];
- $sdata[] = $ship_city;
-}
-
-
-if($focus->column_fields["ship_state"] != '')
-{
- $ship_state = $focus->column_fields["ship_state"];
- $sdata[] = $ship_state;
-}
-
-
-if($focus->column_fields["ship_code"] != '')
-{
- $ship_code = $focus->column_fields["ship_code"];
- $sdata[] = $ship_code;
-}
-
-
-if($focus->column_fields["ship_country"] != '')
-{
- $ship_country = $focus->column_fields["ship_country"];
- $sdata[] = $ship_country;
-}
-
-for($i =0; $i <5; $i++)
-{
- if(sizeof($sdata) < 6)
- {
- $sdata[] = ' ';
- }
-}
-
-//Getting the terms_conditions
-
-if($focus->column_fields["terms_conditions"] != '')
-{
- $conditions = $focus->column_fields["terms_conditions"];
-}
-else
-{
- $conditions = ' ';
-}
-
-//Getting the Company Address
-$add_query = "select * from organizationdetails";
-$result = $adb->query($add_query);
-$num_rows = $adb->num_rows($result);
-$org_field_array = Array('organizationame','address','city','state','country','code','phone','fax','website');
-
-$companyaddress = Array();
-$logo_name = '';
-
-if($num_rows == 1)
-{
- $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_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_website = $adb->query_result($result,0,"website");
-
- if($org_name != '')
- {
- $companyaddress[] = $org_name;
- }
- if($org_address != '' || $org_city != '' || $org_state != '')
- {
- $companyaddress[] = $org_address.' '.$org_city.' '.$org_state;
- }
- if($org_country != '' || $org_code!= '')
- {
- $companyaddress[] = $org_country.' '.$org_code;
- }
- if($org_phone != '' || $org_fax != '')
- {
- $companyaddress[] = $org_phone.' '.$org_fax;
- }
- if($org_website != '')
- {
- $companyaddress[] = $org_website;
- }
-
- for($i =0; $i < 4; $i++)
- {
- if(sizeof($companyaddress) < 5)
- {
- $companyaddress[] = ' ';
- }
- }
-
- $logo_name = $adb->query_result($result,0,"logoname");
-}
-//Getting the logo
-
-//getting the Product Data
-$query="select products.productname,products.unit_price,soproductrel.* from soproductrel inner join products on products.productid=soproductrel.productid where salesorderid=".$id;
-
-$result = $adb->query($query);
-$num_rows=$adb->num_rows($result);
-for($i=1;$i<=$num_rows;$i++)
-{
- $temp_data = Array();
- $productname=$adb->query_result($result,$i-1,'productname');
- $unitprice=$adb->query_result($result,$i-1,'unit_price');
- $productid=$adb->query_result($result,$i-1,'productid');
- $qty=$adb->query_result($result,$i-1,'quantity');
- $listprice=$adb->query_result($result,$i-1,'listprice');
- $total = $qty*$listprice;
-
- $temp_data['productname'] = $productname;
- $temp_data['qty'] = $qty;
- $temp_data['unitprice'] = $unitprice;
- $temp_data['listprice'] = $listprice;
- $temp_data['total'] = $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);
-
- }
-}
-//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;
- if($ivData) 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);
-}
-}
-$iHead = array("Company","Sales Order No.","Date","Quote Name.");
-$iCustHeadDtls = array("Customer Name","Purchase Order","Due Date");
-$iHeadDtls = array("Product Name","Quantity","List Price","Unit Price","Total");
-
-$pdf = new PDF('P','mm','A4');
-$pdf->SetFont('Arial','',10);
-$pdf->AddPage();
-$pdf->setInvoiceTitle("Sales Order",$logo_name,$companyaddress);
-$pdf->Ln();
-$pdf->setInvoiceDetails($iHead,$iData);
-$pdf->setAddress($bdata,$sdata);
-$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
-$pdf->setProductDetails($iHeadDtls,$iDataDtls);
-$pdf->setTotal($price_total,$conditions);
-$pdf->Output('SOOrder.pdf','D');
+$pdf->Output('SalesOrder.pdf','D'); //added file name to make it work in IE, also forces the download giving the user the option to save
exit;
?>
Modified: vtigercrm/branches/4.2/modules/Quotes/CreatePDF.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Quotes/CreatePDF.php (original)
+++ vtigercrm/branches/4.2/modules/Quotes/CreatePDF.php Mon Apr 24 22:31:58 2006
@@ -1,411 +1,88 @@
<?php
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is: vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-require('include/fpdf/fpdf.php');
-require_once('modules/Quotes/Quote.php');
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * (c) 2005 Matthew Brichacek <mmbrich at fosslabs.com>
+ *
+ *
+ * Changes/Additions:
+ *
+ * (c) 2005 OpenCRM
+ * - Improved currency support
+ * - Fixed IE download bug
+ */
+
+require_once('include/database/PearDatabase.php');
+
+global $adb;
+global $app_strings;
+global $max_desc_size;
+global $max_prod_desc_size;
+global $products_per_page;
$id = $_REQUEST['record'];
-global $adb;
-//retreiving the invoice info
-$focus = new Quote();
-$focus->retrieve_entity_info($_REQUEST['record'],"Quotes");
-$account_name = getAccountName($focus->column_fields[account_id]);
-$iData[] = $account_name;
-$iData[] = $id;
-$iData[] = date('Y-m-d');
+$sql="select currency_symbol from currency_info";
+$result = $adb->query($sql);
+$currency_symbol = $adb->query_result($result,0,'currency_symbol');
-//setting the Customer Data
-$iCustData[] = $account_name;
+/* ************* BEGIN USER CONFIG **************** */
+$endpage="0";
+$products_per_page="9";
+$max_prod_desc_size="75";
+$max_desc_size="175";
+/* ************ END USER CONFIG ******************* */
-if($focus->column_fields["validtill"] != '')
+require_once('include/VtigerPDF.php');
+require_once('pdf_data.php');
+
+$page_num='1';
+$pdf = new PDF( 'P', 'mm', 'A4' );
+$pdf->Open();
+
+$num_pages=ceil(($num_products/$products_per_page));
+$current_product=0;
+
+for($l=0;$l<$num_pages;$l++)
{
- $due_date = $focus->column_fields["validtill"];
-}
-else
-{
- $due_date = ' ';
-}
-$iCustData[] = $due_date;
+ $line=array();
+ if($num_pages == $page_num)
+ $lastpage=1;
+
+ while($current_product != $page_num*$products_per_page)
+ {
+ $line[]=$product_line[$current_product];
+ $current_product++;
+ }
-//setting the billing address
-$bdata[] = $account_name;
-if($focus->column_fields["bill_street"] != '')
-{
- $bill_street = $focus->column_fields["bill_street"];
- $bdata[] = $bill_street;
-
-}
+ $pdf->AddPage();
+ include("pdf_templates/header.php");
+ include("pdf_templates/body.php");
+ include("pdf_templates/footer.php");
-if($focus->column_fields["bill_city"] != '')
-{
- $bill_city = $focus->column_fields["bill_city"];
- $bdata[] = $bill_city;
+ $page_num++;
+
+ if (($endpage) && ($lastpage))
+ {
+ $pdf->AddPage();
+ include("pdf_templates/header.php");
+ include("pdf_templates/lastpage/body.php");
+ include("pdf_templates/lastpage/footer.php");
+ }
}
-if($focus->column_fields["bill_state"] != '')
-{
- $bill_state = $focus->column_fields["bill_state"];
- $bdata[] = $bill_state;
-}
-
-
-if($focus->column_fields["bill_code"] != '')
-{
- $bill_code = $focus->column_fields["bill_code"];
- $bdata[] = $bill_code;
-}
-
-
-if($focus->column_fields["bill_country"] != '')
-{
- $bill_country = $focus->column_fields["bill_country"];
- $bdata[] = $bill_country;
-}
-
-for($i =0; $i <5; $i++)
-{
- if(sizeof($bdata) < 6)
- {
- $bdata[] = ' ';
- }
-}
-
-//setting the shipping address
-$sdata[] = $account_name;
-if($focus->column_fields["ship_street"] != '')
-{
- $ship_street = $focus->column_fields["ship_street"];
- $sdata[] = $ship_street;
-}
-
-if($focus->column_fields["ship_city"] != '')
-{
- $ship_city = $focus->column_fields["ship_city"];
- $sdata[] = $ship_city;
-}
-
-
-if($focus->column_fields["ship_state"] != '')
-{
- $ship_state = $focus->column_fields["ship_state"];
- $sdata[] = $ship_state;
-}
-
-
-if($focus->column_fields["ship_code"] != '')
-{
- $ship_code = $focus->column_fields["ship_code"];
- $sdata[] = $ship_code;
-}
-
-
-if($focus->column_fields["ship_country"] != '')
-{
- $ship_country = $focus->column_fields["ship_country"];
- $sdata[] = $ship_country;
-}
-
-for($i =0; $i <5; $i++)
-{
- if(sizeof($sdata) < 6)
- {
- $sdata[] = ' ';
- }
-}
-
-//Getting the terms_conditions
-
-if($focus->column_fields["terms_conditions"] != '')
-{
- $conditions = $focus->column_fields["terms_conditions"];
-}
-else
-{
- $conditions = ' ';
-}
-
-//Getting the Company Address
-$add_query = "select * from organizationdetails";
-$result = $adb->query($add_query);
-$num_rows = $adb->num_rows($result);
-$org_field_array = Array('organizationame','address','city','state','country','code','phone','fax','website');
-
-$companyaddress = Array();
-$logo_name = '';
-
-if($num_rows == 1)
-{
- $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_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_website = $adb->query_result($result,0,"website");
-
- if($org_name != '')
- {
- $companyaddress[] = $org_name;
- }
- if($org_address != '' || $org_city != '' || $org_state != '')
- {
- $companyaddress[] = $org_address.' '.$org_city.' '.$org_state;
- }
- if($org_country != '' || $org_code!= '')
- {
- $companyaddress[] = $org_country.' '.$org_code;
- }
- if($org_phone != '' || $org_fax != '')
- {
- $companyaddress[] = $org_phone.' '.$org_fax;
- }
- if($org_website != '')
- {
- $companyaddress[] = $org_website;
- }
-
- for($i =0; $i < 4; $i++)
- {
- if(sizeof($companyaddress) < 5)
- {
- $companyaddress[] = ' ';
- }
- }
-
- $logo_name = $adb->query_result($result,0,"logoname");
-}
-//Getting the logo
-
-//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;
-
-$result = $adb->query($query);
-$num_rows=$adb->num_rows($result);
-for($i=1;$i<=$num_rows;$i++)
-{
- $temp_data = Array();
- $productname=$adb->query_result($result,$i-1,'productname');
- $unitprice=$adb->query_result($result,$i-1,'unit_price');
- $productid=$adb->query_result($result,$i-1,'productid');
- $qty=$adb->query_result($result,$i-1,'quantity');
- $listprice=$adb->query_result($result,$i-1,'listprice');
- $total = $qty*$listprice;
-
- $temp_data['productname'] = $productname;
- $temp_data['qty'] = $qty;
- $temp_data['unitprice'] = $unitprice;
- $temp_data['listprice'] = $listprice;
- $temp_data['total'] = $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);
-
- }
-}
-//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;
- if($ivData) 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);
-}
-}
-$iHead = array("Company","Quote No.","Date");
-$iCustHeadDtls = array("Customer Name","Valid Till");
-$iHeadDtls = array("Product Name","Quantity","List Price","Unit Price","Total");
-
-$pdf = new PDF('P','mm','A4');
-$pdf->SetFont('Arial','',10);
-$pdf->AddPage();
-$pdf->setInvoiceTitle("Quotes",$logo_name,$companyaddress);
-$pdf->Ln();
-$pdf->setInvoiceDetails($iHead,$iData);
-$pdf->setAddress($bdata,$sdata);
-$pdf->setCustomerDetails($iCustHeadDtls,$iCustData);
-$pdf->setProductDetails($iHeadDtls,$iDataDtls);
-$pdf->setTotal($price_total,$conditions);
-$pdf->Output('Quotes.pdf','D');
+$pdf->Output('Quote.pdf','D'); //added file name to make it work in IE, also forces the download giving the user the option to save
exit;
?>
More information about the vtigercrm-commits
mailing list