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_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf
35: {
36: 37: 38: 39: 40:
41: protected $_info;
42:
43: 44: 45: 46: 47:
48: protected $_request;
49:
50: 51: 52: 53: 54:
55: public function __construct(array $arguments)
56: {
57: $this->_info = $arguments['info'];
58: $this->_request = $arguments['request'];
59: }
60:
61: 62: 63: 64: 65: 66: 67:
68: public function render()
69: {
70: $pdf = new Zend_Pdf();
71:
72: $pdfBuilder = new Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder();
73:
74: $template = new Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
75: $pdfBuilder->setPage($template)
76: ->addProductName((string)$this->_info->ProductShortName)
77: ->addProductContentCode((string)$this->_info->ProductContentCode)
78:
79:
80: ->addSenderInfo($this->_info->Shipper)
81: ->addOriginInfo((string)$this->_info->OriginServiceArea->ServiceAreaCode)
82: ->addReceiveInfo($this->_info->Consignee)
83: ->addDestinationFacilityCode(
84: (string)$this->_info->Consignee->CountryCode,
85: (string)$this->_info->DestinationServiceArea->ServiceAreaCode,
86: (string)$this->_info->DestinationServiceArea->FacilityCode
87: )
88: ->addServiceFeaturesCodes()
89: ->addDeliveryDateCode()
90: ->addShipmentInformation($this->_request->getOrderShipment())
91: ->addDateInfo($this->_info->ShipmentDate)
92: ->addWeightInfo((string)$this->_info->ChargeableWeight, (string)$this->_info->WeightUnit)
93: ->addWaybillBarcode((string)$this->_info->AirwayBillNumber, (string)$this->_info->Barcodes->AWBBarCode)
94: ->addRoutingBarcode(
95: (string)$this->_info->DHLRoutingCode,
96: (string)$this->_info->DHLRoutingDataId,
97: (string)$this->_info->Barcodes->DHLRoutingBarCode
98: )
99: ->addBorder();
100:
101: $packages = array_values($this->_request->getPackages());
102: $i = 0;
103: foreach ($this->_info->Pieces->Piece as $piece) {
104: $page = new Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page($template);
105: $pdfBuilder->setPage($page)
106: ->addPieceNumber((int)$piece->PieceNumber, (int)$this->_info->Piece)
107: ->addContentInfo($packages[$i])
108: ->addPieceIdBarcode(
109: (string)$piece->DataIdentifier,
110: (string)$piece->LicensePlate,
111: (string)$piece->LicensePlateBarCode
112: );
113: array_push($pdf->pages, $page);
114: $i++;
115: }
116: return $pdf->render();
117: }
118: }
119: