Mage_Sales_Model_Order_Pdf_Invoice Class Reference

Inheritance diagram for Mage_Sales_Model_Order_Pdf_Invoice:

Mage_Sales_Model_Order_Pdf_Abstract Varien_Object

List of all members.

Public Member Functions

 getPdf ($invoices=array())
 newPage (array $settings=array())


Detailed Description

Definition at line 35 of file Invoice.php.


Member Function Documentation

getPdf ( invoices = array()  ) 

Definition at line 37 of file Invoice.php.

00038     {
00039         $this->_beforeGetPdf();
00040         $this->_initRenderer('invoice');
00041 
00042         $pdf = new Zend_Pdf();
00043         $this->_setPdf($pdf);
00044         $style = new Zend_Pdf_Style();
00045         $this->_setFontBold($style, 10);
00046 
00047         foreach ($invoices as $invoice) {
00048             if ($invoice->getStoreId()) {
00049                 Mage::app()->getLocale()->emulate($invoice->getStoreId());
00050             }
00051             $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
00052             $pdf->pages[] = $page;
00053 
00054             $order = $invoice->getOrder();
00055 
00056             /* Add image */
00057             $this->insertLogo($page, $invoice->getStore());
00058 
00059             /* Add address */
00060             $this->insertAddress($page, $invoice->getStore());
00061 
00062             /* Add head */
00063             $this->insertOrder($page, $order, Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId()));
00064 
00065 
00066             $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
00067             $this->_setFontRegular($page);
00068             $page->drawText(Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId(), 35, 780, 'UTF-8');
00069 
00070             /* Add table */
00071             $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
00072             $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
00073             $page->setLineWidth(0.5);
00074 
00075             $page->drawRectangle(25, $this->y, 570, $this->y -15);
00076             $this->y -=10;
00077 
00078             /* Add table head */
00079             $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
00080             $page->drawText(Mage::helper('sales')->__('Product'), 35, $this->y, 'UTF-8');
00081             $page->drawText(Mage::helper('sales')->__('SKU'), 240, $this->y, 'UTF-8');
00082             $page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8');
00083             $page->drawText(Mage::helper('sales')->__('QTY'), 430, $this->y, 'UTF-8');
00084             $page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8');
00085             $page->drawText(Mage::helper('sales')->__('Subtotal'), 535, $this->y, 'UTF-8');
00086 
00087             $this->y -=15;
00088 
00089             $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
00090 
00091             /* Add body */
00092             foreach ($invoice->getAllItems() as $item){
00093                 if ($item->getOrderItem()->getParentItem()) {
00094                     continue;
00095                 }
00096 
00097                 if ($this->y < 15) {
00098                     $page = $this->newPage(array('table_header' => true));
00099                 }
00100 
00101                 /* Draw item */
00102                 $page = $this->_drawItem($item, $page, $order);
00103             }
00104 
00105             /* Add totals */
00106             $page = $this->insertTotals($page, $invoice);
00107 
00108             if ($invoice->getStoreId()) {
00109                 Mage::app()->getLocale()->revert();
00110             }
00111         }
00112 
00113         $this->_afterGetPdf();
00114 
00115         return $pdf;
00116     }

newPage ( array settings = array()  ) 

Create new page and assign to PDF object

Parameters:
array $settings
Returns:
Zend_Pdf_Page

Reimplemented from Mage_Sales_Model_Order_Pdf_Abstract.

Definition at line 124 of file Invoice.php.

00125     {
00126         /* Add new table head */
00127         $page = $this->_getPdf()->newPage(Zend_Pdf_Page::SIZE_A4);
00128         $this->_getPdf()->pages[] = $page;
00129         $this->y = 800;
00130 
00131         if (!empty($settings['table_header'])) {
00132             $this->_setFontRegular($page);
00133             $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
00134             $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
00135             $page->setLineWidth(0.5);
00136             $page->drawRectangle(25, $this->y, 570, $this->y-15);
00137             $this->y -=10;
00138 
00139             $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
00140             $page->drawText(Mage::helper('sales')->__('Product'), 35, $this->y, 'UTF-8');
00141             $page->drawText(Mage::helper('sales')->__('SKU'), 240, $this->y, 'UTF-8');
00142             $page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8');
00143             $page->drawText(Mage::helper('sales')->__('QTY'), 430, $this->y, 'UTF-8');
00144             $page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8');
00145             $page->drawText(Mage::helper('sales')->__('Subtotal'), 535, $this->y, 'UTF-8');
00146 
00147             $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
00148             $this->y -=20;
00149         }
00150 
00151         return $page;
00152     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:47 2009 for Magento by  doxygen 1.5.8