1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Sales_Model_Order_Pdf_Shipment extends Mage_Sales_Model_Order_Pdf_Abstract
35: {
36: 37: 38: 39: 40: 41:
42: protected function (Zend_Pdf_Page $page)
43: {
44:
45: $this->_setFontRegular($page, 10);
46: $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
47: $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
48: $page->setLineWidth(0.5);
49: $page->drawRectangle(25, $this->y, 570, $this->y-15);
50: $this->y -= 10;
51: $page->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0));
52:
53:
54: $lines[0][] = array(
55: 'text' => Mage::helper('sales')->__('Products'),
56: 'feed' => 100,
57: );
58:
59: $lines[0][] = array(
60: 'text' => Mage::helper('sales')->__('Qty'),
61: 'feed' => 35
62: );
63:
64: $lines[0][] = array(
65: 'text' => Mage::helper('sales')->__('SKU'),
66: 'feed' => 565,
67: 'align' => 'right'
68: );
69:
70: $lineBlock = array(
71: 'lines' => $lines,
72: 'height' => 10
73: );
74:
75: $this->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
76: $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
77: $this->y -= 20;
78: }
79:
80: 81: 82: 83: 84: 85:
86: public function getPdf($shipments = array())
87: {
88: $this->_beforeGetPdf();
89: $this->_initRenderer('shipment');
90:
91: $pdf = new Zend_Pdf();
92: $this->_setPdf($pdf);
93: $style = new Zend_Pdf_Style();
94: $this->_setFontBold($style, 10);
95: foreach ($shipments as $shipment) {
96: if ($shipment->getStoreId()) {
97: Mage::app()->getLocale()->emulate($shipment->getStoreId());
98: Mage::app()->setCurrentStore($shipment->getStoreId());
99: }
100: $page = $this->newPage();
101: $order = $shipment->getOrder();
102:
103: $this->insertLogo($page, $shipment->getStore());
104:
105: $this->insertAddress($page, $shipment->getStore());
106:
107: $this->insertOrder(
108: $page,
109: $shipment,
110: Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_SHIPMENT_PUT_ORDER_ID, $order->getStoreId())
111: );
112:
113: $this->insertDocumentNumber(
114: $page,
115: Mage::helper('sales')->__('Packingslip # ') . $shipment->getIncrementId()
116: );
117:
118: $this->_drawHeader($page);
119:
120: foreach ($shipment->getAllItems() as $item) {
121: if ($item->getOrderItem()->getParentItem()) {
122: continue;
123: }
124:
125: $this->_drawItem($item, $page, $order);
126: $page = end($pdf->pages);
127: }
128: }
129: $this->_afterGetPdf();
130: if ($shipment->getStoreId()) {
131: Mage::app()->getLocale()->revert();
132: }
133: return $pdf;
134: }
135:
136: 137: 138: 139: 140: 141:
142: public function newPage(array $settings = array())
143: {
144:
145: $page = $this->_getPdf()->newPage(Zend_Pdf_Page::SIZE_A4);
146: $this->_getPdf()->pages[] = $page;
147: $this->y = 800;
148: if (!empty($settings['table_header'])) {
149: $this->_drawHeader($page);
150: }
151: return $page;
152: }
153: }
154: