1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14:
15: class IllApps_Shipsync_Model_Shipment_Request extends IllApps_Shipsync_Model_Shipment_Abstract
16: {
17: protected $_masterTrackingId = false;
18: protected $_isMasterPackage = true;
19:
20:
21: 22: 23: 24: 25:
26: public function getShipperDetails()
27: {
28: $details = array(
29: 'Contact' => array(
30: 'CompanyName' => $this->getShipperCompany(),
31: 'PhoneNumber' => $this->getShipperPhone()
32: ),
33: 'Address' => array(
34: 'StreetLines' => $this->getShipperStreetLines(),
35: 'City' => $this->getShipperCity(),
36: 'PostalCode' => $this->getShipperPostalCode(),
37: 'CountryCode' => $this->getShipperCountryCode()
38: )
39: );
40:
41: if ($this->getShipperStateOrProvinceCode() != '') {
42: $details['Address']['StateOrProvinceCode'] = $this->getShipperStateOrProvinceCode();
43: }
44:
45: return $details;
46: }
47:
48: 49: 50: 51: 52:
53: public function getRecipientDetails()
54: {
55: $recipient = array(
56: 'Contact' => array(
57: 'PersonName' => $this->getRecipientAddress()->getName(),
58: 'PhoneNumber' => $this->getRecipientAddress()->getTelephone()
59: ),
60: 'Address' => array(
61: 'StreetLines' => $this->getRecipientAddress()->getStreet(),
62: 'City' => $this->getRecipientAddress()->getCity(),
63: 'StateOrProvinceCode' => $this->getRecipientAddress()->getRegionCode(),
64: 'PostalCode' => $this->getRecipientAddress()->getPostcode(),
65: 'CountryCode' => $this->getRecipientAddress()->getCountryId(),
66: 'Residential' => $this->getResidential()
67: )
68: );
69:
70: if ($this->getRecipientAddress()->getCompany() != '') {
71: $recipient['Contact']['CompanyName'] = $this->getRecipientAddress()->getCompany();
72: }
73:
74: return $recipient;
75: }
76:
77: 78: 79: 80: 81:
82: public function getLabelSpecification()
83: {
84: return array(
85: 'LabelFormatType' => 'COMMON2D',
86: 'ImageType' => Mage::getStoreConfig('carriers/fedex/label_image'),
87: 'LabelStockType' => Mage::getStoreConfig('carriers/fedex/label_stock'),
88: 'LabelPrintingOrientation' => Mage::getStoreConfig('carriers/fedex/label_orientation'),
89: 'CustomerSpecifiedDetail' => array(
90: 'DocTabContent' => array(
91: 'DocTabContentType' => 'STANDARD'
92: )
93: )
94: );
95: }
96:
97: 98: 99: 100: 101:
102: public function getSmartPostDetails()
103: {
104: $detail = array(
105: 'Indicia' => Mage::getStoreConfig('carriers/fedex/smartpost_indicia_type'),
106: 'AncillaryEndorsement' => Mage::getStoreConfig('carriers/fedex/smartpost_endorsement'),
107: 'SpecialServices' => 'USPS_DELIVERY_CONFIRMATION',
108: 'HubId' => Mage::getStoreConfig('carriers/fedex/smartpost_hub_id')
109: );
110:
111: return Mage::getStoreConfig('carriers/fedex/smartpost_customer_manifest_id') ? array_merge($detail, Mage::getStoreConfig('carriers/fedex/smartpost_customer_manifest_id')) : $detail;
112: }
113:
114: 115: 116: 117: 118:
119: public function setMasterTrackingId($id)
120: {
121: foreach ($id as $key => $val) {
122: $arr[$key] = $val;
123: }
124: $this->_masterTrackingId = $arr;
125: return $this;
126: }
127:
128: 129: 130: 131: 132:
133: public function getMasterTrackingId()
134: {
135: return $this->_masterTrackingId;
136: }
137:
138: 139: 140: 141: 142:
143: public function getPackageCount()
144: {
145: return Mage::getStoreConfig('carriers/fedex/mps_shipments') ? count($this->getPackages()) : 1;
146: }
147:
148: 149: 150: 151: 152:
153: public function getTotalShipmentWeight()
154: {
155: $total = 0;
156:
157: foreach ($this->getPackages() as $package) {
158: $total += $package->getWeight();
159: }
160:
161: return $total;
162: }
163:
164: 165: 166: 167: 168:
169: public function getTransactionType()
170: {
171: return $this->getStore()->getConfig('shipping/origin/country_id') != $this->getRecipientAddress()->getCountryId() ? 'International' : 'Domestic';
172: }
173:
174: 175: 176: 177: 178:
179: public function getTransactionMethod()
180: {
181: return ($this->getServiceType() == 'GROUND_HOME_DELIVERY' || $this->getServiceType() == 'FEDEX_GROUND') ? 'Ground' : 'Express';
182: }
183:
184: 185: 186: 187: 188:
189: public function getMpsData()
190: {
191: if (!Mage::getStoreConfig('carriers/fedex/mps_shipments')) {
192: return array(
193: 'PackageCount' => 1
194: );
195: }
196:
197: else if ($this->getMasterTrackingId()) {
198: return array(
199: 'MasterTrackingId' => $this->getMasterTrackingId(),
200: 'PackageCount' => $this->getPackageCount(),
201: 'TotalShipmentWeight' => $this->getTotalShipmentWeight()
202: );
203: } else {
204: return array(
205: 'PackageCount' => $this->getPackageCount(),
206: 'TotalShipmentWeight' => $this->getTotalShipmentWeight()
207: );
208: }
209: }
210:
211: 212: 213: 214: 215:
216: public function setIsChildPackage()
217: {
218: $this->_isMasterPackage = false;
219: return $this;
220: }
221:
222: 223: 224: 225: 226:
227: public function isMasterBool()
228: {
229: return $this->_isMasterPackage;
230: }
231:
232: public function getPayorAccount()
233: {
234: return Mage::getStoreConfig('carriers/fedex/third_party') ? Mage::getStoreConfig('carriers/fedex/third_party_fedex_account') : $this->getFedexAccount();
235: }
236:
237: public function getPayorAccountCountry()
238: {
239: return Mage::getStoreConfig('carriers/fedex/third_party') ? Mage::getStoreConfig('carriers/fedex/third_party_fedex_account') : $this->getFedexAccountCountry();
240: }
241:
242: public function getPayorType()
243: {
244: return Mage::getStoreConfig('carriers/fedex/third_party') ? 'THIRD_PARTY' : 'SENDER';
245: }
246: }
247: