Transsmart_Shipping - Version 1.0.2

Version Notes

1.0.2

Download this release

Release Info

Developer Techtwo Webdevelopment B.V.
Extension Transsmart_Shipping
Version 1.0.2
Comparing to
See all releases


Code changes from version 1.0.1 to 1.0.2

app/code/community/Transsmart/Shipping/Helper/Shipment.php CHANGED
@@ -1,774 +1,781 @@
1
- <?php
2
-
3
- /**
4
- * @category Transsmart
5
- * @package Transsmart_Shipping
6
- * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
- */
8
- class Transsmart_Shipping_Helper_Shipment extends Mage_Core_Helper_Abstract
9
- {
10
- const XML_PATH_DEFAULT_CARRIERPROFILE = 'transsmart_shipping/default_shipment/carrierprofile';
11
- const XML_PATH_DEFAULT_SHIPMENTLOCATION = 'transsmart_shipping/default_shipment/shipmentlocation';
12
- const XML_PATH_DEFAULT_EMAILTYPE = 'transsmart_shipping/default_shipment/emailtype';
13
- const XML_PATH_DEFAULT_INCOTERM = 'transsmart_shipping/default_shipment/incoterm';
14
- const XML_PATH_DEFAULT_COSTCENTER = 'transsmart_shipping/default_shipment/costcenter';
15
- const XML_PATH_DEFAULT_PACKAGETYPE = 'transsmart_shipping/default_shipment/packagetype';
16
-
17
- const XML_PATH_MAPPING_STREET = 'transsmart_shipping/mapping/street';
18
- const XML_PATH_MAPPING_STREETNO = 'transsmart_shipping/mapping/streetno';
19
- const XML_PATH_MAPPING_STREET2 = 'transsmart_shipping/mapping/street2';
20
- const XML_PATH_MAPPING_COUNTRY_OF_ORIGIN = 'transsmart_shipping/mapping/country_of_origin';
21
- const XML_PATH_MAPPING_HS_CODE = 'transsmart_shipping/mapping/hs_code';
22
- const XML_PATH_MAPPING_REASON_OF_EXPORT = 'transsmart_shipping/mapping/reason_of_export';
23
-
24
- // OR'ed values for the 'transsmart_flags' field in the shipment table
25
- const FLAG_BOOK_ON_CREATE = 1;
26
- const FLAG_BOOKANDPRINT_ON_CREATE = 2;
27
-
28
- /**
29
- * Get all possible Transsmart shipment statuses.
30
- *
31
- * @return array
32
- */
33
- public function getShipmentStatuses()
34
- {
35
- return array(
36
- 'NONE' => $this->__('NONE'),
37
- 'NEW' => $this->__('NEW'),
38
- 'BOOK' => $this->__('BOOK'),
39
- 'LABL' => $this->__('LABL'),
40
- 'MANI' => $this->__('MANI'),
41
- 'ACCEP' => $this->__('ACCEP'),
42
- 'TRNS' => $this->__('TRNS'),
43
- 'DONE' => $this->__('DONE'),
44
- 'APOD' => $this->__('APOD'),
45
- 'REFU' => $this->__('REFU'),
46
- 'ERR' => $this->__('ERR'),
47
- 'DEL' => $this->__('DEL'),
48
- 'ONHOLD' => $this->__('ONHOLD'),
49
- );
50
- }
51
-
52
- /**
53
- * Get configured default carrierprofile for the given shipment or store.
54
- *
55
- * @param Mage_Sales_Model_Order_Shipment|null $shipment
56
- * @param null $store
57
- * @return int
58
- */
59
- public function getDefaultCarrierprofileId($shipment = null, $store = null)
60
- {
61
- $defaultValue = false;
62
- if ($shipment instanceof Mage_Sales_Model_Order_Shipment) {
63
- $shippingMethod = $shipment->getOrder()->getShippingMethod(false);
64
- $carrierprofile = Mage::getModel('transsmart_shipping/carrierprofile')
65
- ->loadByShippingMethodCode($shippingMethod);
66
- $defaultValue = $carrierprofile->getId();
67
- if (!$defaultValue) {
68
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_CARRIERPROFILE, $shipment->getStore());
69
- }
70
- }
71
- if (!$defaultValue) {
72
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_CARRIERPROFILE, $store);
73
- }
74
- return $defaultValue;
75
- }
76
-
77
- /**
78
- * Get configured default shipmentlocation for the given store.
79
- *
80
- * @param null $store
81
- * @return int
82
- */
83
- public function getDefaultShipmentlocationId($store = null)
84
- {
85
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_SHIPMENTLOCATION, $store);
86
- if (!$defaultValue) {
87
- $ids = Mage::getResourceModel('transsmart_shipping/shipmentlocation_collection')
88
- ->addFieldToFilter('is_default', array('eq' => 1))
89
- ->setPageSize(1)
90
- ->getAllIds();
91
- if (count($ids)) {
92
- $defaultValue = $ids[0];
93
- }
94
- }
95
- return $defaultValue;
96
- }
97
-
98
- /**
99
- * Get configured default emailtype for the given store.
100
- *
101
- * @param null $store
102
- * @return int
103
- */
104
- public function getDefaultEmailtypeId($store = null)
105
- {
106
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_EMAILTYPE, $store);
107
- if (!$defaultValue) {
108
- $ids = Mage::getResourceModel('transsmart_shipping/emailtype_collection')
109
- ->addFieldToFilter('is_default', array('eq' => 1))
110
- ->setPageSize(1)
111
- ->getAllIds();
112
- if (count($ids)) {
113
- $defaultValue = $ids[0];
114
- }
115
- }
116
- return $defaultValue;
117
- }
118
-
119
- /**
120
- * Get configured default incoterm for the given store.
121
- *
122
- * @param null $store
123
- * @return int
124
- */
125
- public function getDefaultIncotermId($store = null)
126
- {
127
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_INCOTERM, $store);
128
- if (!$defaultValue) {
129
- $ids = Mage::getResourceModel('transsmart_shipping/incoterm_collection')
130
- ->addFieldToFilter('is_default', array('eq' => 1))
131
- ->setPageSize(1)
132
- ->getAllIds();
133
- if (count($ids)) {
134
- $defaultValue = $ids[0];
135
- }
136
- }
137
- return $defaultValue;
138
- }
139
-
140
- /**
141
- * Get configured default costcenter for the given store.
142
- *
143
- * @param null $store
144
- * @return int
145
- */
146
- public function getDefaultCostcenterId($store = null)
147
- {
148
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_COSTCENTER, $store);
149
- if (!$defaultValue) {
150
- $ids = Mage::getResourceModel('transsmart_shipping/costcenter_collection')
151
- ->addFieldToFilter('is_default', array('eq' => 1))
152
- ->setPageSize(1)
153
- ->getAllIds();
154
- if (count($ids)) {
155
- $defaultValue = $ids[0];
156
- }
157
- }
158
- return $defaultValue;
159
- }
160
-
161
- /**
162
- * Get configured default packagetype for the given store.
163
- *
164
- * @param null $store
165
- * @return int
166
- */
167
- public function getDefaultPackagetypeId($store = null)
168
- {
169
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_PACKAGETYPE, $store);
170
- if (!$defaultValue) {
171
- $ids = Mage::getResourceModel('transsmart_shipping/packagetype_collection')
172
- ->addFieldToFilter('is_default', array('eq' => 1))
173
- ->setPageSize(1)
174
- ->getAllIds();
175
- if (count($ids)) {
176
- $defaultValue = $ids[0];
177
- }
178
- }
179
- return $defaultValue;
180
- }
181
-
182
- /**
183
- * Get the street and housenumber from the given address. If there's only one street field, try to split it into
184
- * separate fields.
185
- *
186
- * @param Mage_Sales_Model_Order_Address $address
187
- * @param mixed $store
188
- * @return array
189
- */
190
- protected function _getStreetFields($address, $store = null)
191
- {
192
- if ($address->hasTranssmartServicepointId()) {
193
- // for addresses from the location selector, always use predetermined fields
194
- $street = $address->getStreet(1);
195
- $streetNo = $address->getStreet(2);
196
- $street2 = $address->getStreet(3);
197
- }
198
- else {
199
- // read config settings for street fields mapping
200
- $mappingStreet = Mage::getStoreConfig(self::XML_PATH_MAPPING_STREET, $store);
201
- $mappingStreetNo = Mage::getStoreConfig(self::XML_PATH_MAPPING_STREETNO, $store);
202
- $mappingStreet2 = Mage::getStoreConfig(self::XML_PATH_MAPPING_STREET2, $store);
203
-
204
- // get street value
205
- switch ($mappingStreet) {
206
- case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::NONE:
207
- $street = '';
208
- break;
209
- case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::FULL:
210
- $street = trim(implode(' ', $address->getStreet()));
211
- break;
212
- default:
213
- $street = $address->getStreet($mappingStreet);
214
- }
215
-
216
- // get streetno value
217
- switch ($mappingStreetNo) {
218
- case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::NONE:
219
- $streetNo = '';
220
- break;
221
- case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::FULL:
222
- $streetNo = trim(implode(' ', $address->getStreet()));
223
- break;
224
- default:
225
- $streetNo = $address->getStreet($mappingStreetNo);
226
- }
227
-
228
- // get street2 value
229
- switch ($mappingStreet2) {
230
- case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::NONE:
231
- $street2 = '';
232
- break;
233
- case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::FULL:
234
- $street2 = trim(implode(' ', $address->getStreet()));
235
- break;
236
- default:
237
- $street2 = $address->getStreet($mappingStreet2);
238
- }
239
-
240
- // automatic house number detection
241
- if ($mappingStreet == $mappingStreetNo) {
242
- $streetNo = '';
243
-
244
- if (preg_match('/^(.*) ([0-9]+ .*)$/', $street, $matches)) {
245
- $street = $matches[1];
246
- $streetNo = $matches[2];
247
- }
248
- elseif (preg_match('/^(.*) ([0-9]+.*)$/', $street, $matches)) {
249
- $street = $matches[1];
250
- $streetNo = $matches[2];
251
- }
252
- elseif (preg_match('/^(.*) ([0-9]+.*)$/', $street, $matches)) {
253
- $street = $matches[1];
254
- $streetNo = $matches[2];
255
- }
256
- }
257
- }
258
-
259
- // house number cannot be empty
260
- if ($streetNo === '') {
261
- $streetNo = '.';
262
- }
263
-
264
- return array($street, $streetNo, $street2);
265
- }
266
-
267
- /**
268
- * Export the given shipment to the Transsmart API.
269
- *
270
- * @param Mage_Sales_Model_Order_Shipment $shipment
271
- * @param bool $allowPrint
272
- */
273
- public function doExport($shipment, $allowPrint = true)
274
- {
275
- // is it already exported?
276
- if ($shipment->getTranssmartDocumentId()) {
277
- return;
278
- }
279
-
280
- /** @var Transsmart_Shipping_Model_Carrierprofile $carrierprofile */
281
- $carrierprofile = Mage::getModel('transsmart_shipping/carrierprofile')
282
- ->load($shipment->getTranssmartCarrierprofileId());
283
- if (!$carrierprofile->getId()) {
284
- return;
285
- }
286
-
287
- $store = $shipment->getStore();
288
- $address = $shipment->getShippingAddress();
289
- $invoiceAddress = $shipment->getBillingAddress();
290
-
291
- // check if the order has a pickup address (location selector is used)
292
- $pickupAddress = Mage::helper('transsmart_shipping/pickupaddress')
293
- ->getPickupAddressFromOrder($shipment->getOrder());
294
- $servicePointId = null;
295
- if ($pickupAddress) {
296
- $address = $pickupAddress;
297
- $invoiceAddress = $shipment->getShippingAddress();
298
- $servicePointId = $pickupAddress->getTranssmartServicepointId();
299
- }
300
-
301
- // determine address name and contact
302
- $addressName = $address->getCompany();
303
- $addressContact = $address->getName();
304
- if ($addressName == '') {
305
- $addressName = $addressContact;
306
- }
307
-
308
- // determine invoice address name and contact
309
- $invoiceAddressName = $invoiceAddress->getCompany();
310
- $invoiceAddressContact = $invoiceAddress->getName();
311
- if ($invoiceAddressName == '') {
312
- $invoiceAddressName = $invoiceAddressContact;
313
- }
314
-
315
- // split street fields into street and house number
316
- list($addressStreet, $addressStreetNo, $addressStreet2) =
317
- $this->_getStreetFields($address, $store);
318
- list($invoiceAddressStreet, $invoiceAddressStreetNo, $invoiceAddressStreet2) =
319
- $this->_getStreetFields($invoiceAddress, $store);
320
-
321
- // calculate shipment value and prepare delivery note lines
322
- $shipmentValue = 0.0;
323
- $deliveryNoteInfoLines = array();
324
- /** @var Mage_Sales_Model_Order_Shipment_Item $_item */
325
- foreach ($shipment->getAllItems() as $_item) {
326
- $shipmentValue += $_item->getPrice() * $_item->getQty();
327
-
328
- $_line = array(
329
- 'ArticleId' => $_item->getSku(),
330
- 'ArticleName' => $_item->getName(),
331
- 'Description' => $_item->getDescription(),
332
- 'Price' => $_item->getPrice(),
333
- 'Currency' => $store->getCurrentCurrencyCode(),
334
- 'Quantity' => $_item->getQty(),
335
- 'QuantityBackorder' => floatval($_item->getOrderItem()->getQtyBackordered()),
336
- 'QuantityOrder' => $_item->getOrderItem()->getQtyOrdered(),
337
- 'CountryOfOrigin' => Mage::getStoreConfig('shipping/origin/country_id', $store),
338
- 'ReasonOfExport' => 'Sale',
339
- );
340
-
341
- $_additionalFields = array(
342
- 'Description' => 'description',
343
- 'CountryOfOrigin' => Mage::getStoreConfig(self::XML_PATH_MAPPING_COUNTRY_OF_ORIGIN, $store),
344
- 'HSCode' => Mage::getStoreConfig(self::XML_PATH_MAPPING_HS_CODE, $store),
345
- 'ReasonOfExport' => Mage::getStoreConfig(self::XML_PATH_MAPPING_REASON_OF_EXPORT, $store),
346
- );
347
- $_product = $_item->getOrderItem()->getProduct();
348
- foreach ($_additionalFields as $_field => $_attributeCode) {
349
- if (empty($_attributeCode)) {
350
- continue;
351
- }
352
- if ($_attribute = $_product->getResource()->getAttribute($_attributeCode)) {
353
- if ($_attribute->getBackendType() == 'int' && $_attribute->getFrontendInput() == 'select') {
354
- // dropdown or multiselect field; use the frontend label
355
- $_attribute->setStoreId($store->getId());
356
- $_value = $_attribute->getFrontend()->getValue($_product);
357
- }
358
- else {
359
- $_value = $_product->getData($_attributeCode);
360
- }
361
- if ($_value) {
362
- $_line[$_field] = $_value;
363
- }
364
- }
365
- }
366
-
367
- $deliveryNoteInfoLines[] = $_line;
368
- }
369
-
370
- // prepare the document
371
- $document = array(
372
- 'Reference' => $shipment->getIncrementId(),
373
- 'CarrierProfileId' => $carrierprofile->getId(),
374
- 'CarrierId' => $carrierprofile->getCarrierId(),
375
- 'ServiceLevelTimeId' => $carrierprofile->getServicelevelTimeId(),
376
- 'ServiceLevelOtherId' => $carrierprofile->getServicelevelOtherId(),
377
- 'ShipmentLocationId' => $shipment->getTranssmartShipmentlocationId(),
378
- 'MailTypeId' => $shipment->getTranssmartEmailtypeId(),
379
- 'IncotermId' => $shipment->getTranssmartIncotermId(),
380
- 'CostCenterId' => $shipment->getTranssmartCostcenterId(),
381
- 'RefOrder' => $shipment->getOrder()->getIncrementId(),
382
- 'RefServicePoint' => $servicePointId,
383
- 'ShipmentValue' => $shipmentValue,
384
- 'AddressEmailPickup' => Mage::getStoreConfig('trans_email/ident_general/email', $store),
385
- 'AddressName' => $addressName,
386
- 'AddressContact' => $addressContact,
387
- 'AddressStreet' => $addressStreet,
388
- 'AddressStreetNo' => $addressStreetNo,
389
- 'AddressStreet2' => $addressStreet2,
390
- 'AddressZipcode' => $address->getPostcode(),
391
- 'AddressCity' => $address->getCity(),
392
- 'AddressState' => $address->getRegionCode(),
393
- 'AddressCountry' => $address->getCountry(),
394
- 'AddressPhone' => $address->getTelephone(),
395
- 'AddressFax' => $address->getFax(),
396
- 'AddressEmail' => $shipment->getShippingAddress()->getEmail(),
397
- 'AddressCustomerNo' => $address->getCustomerId(),
398
- 'AddressNameInvoice' => $invoiceAddressName,
399
- 'AddressContactInvoice' => $invoiceAddressContact,
400
- 'AddressStreetInvoice' => $invoiceAddressStreet,
401
- 'AddressStreetNoInvoice' => $invoiceAddressStreetNo,
402
- 'AddressStreet2Invoice' => $invoiceAddressStreet2,
403
- 'AddressZipcodeInvoice' => $invoiceAddress->getPostcode(),
404
- 'AddressCityInvoice' => $invoiceAddress->getCity(),
405
- 'AddressStateInvoice' => $invoiceAddress->getRegionCode(),
406
- 'AddressCountryInvoice' => $invoiceAddress->getCountry(),
407
- 'AddressPhoneInvoice' => $invoiceAddress->getTelephone(),
408
- 'AddressFaxInvoice' => $invoiceAddress->getFax(),
409
- 'AddressEmailInvoice' => $invoiceAddress->getEmail(),
410
- 'AddressCustomerNoInvoice' => $invoiceAddress->getCustomerId(),
411
- 'AddressVatNumberInvoice' => $shipment->getOrder()->getCustomerTaxvat(),
412
- 'ColliInformation' => unserialize($shipment->getTranssmartPackages()),
413
- 'DeliveryNoteInfo' => array(
414
- array(
415
- 'DeliveryNoteInfoLines' => $deliveryNoteInfoLines
416
- )
417
- )
418
- );
419
-
420
- // dispatch event so other extensions can update the document
421
- $transport = new Varien_Object(array('document' => $document));
422
- Mage::dispatchEvent('transsmart_shipping_shipment_export_before', array(
423
- 'shipment' => $shipment,
424
- 'transport' => $transport
425
- ));
426
- $document = $transport->getDocument();
427
-
428
- // send the document to Transsmart
429
- $response = Mage::helper('transsmart_shipping')->getApiClient()->createDocument($document);
430
-
431
- // save document ID and status into shipment record
432
- if (isset($response['Id']) && isset($response['Status'])) {
433
- $shipment->setTranssmartDocumentId($response['Id']);
434
- $shipment->setTranssmartStatus($response['Status']);
435
-
436
- $shipment->getResource()->saveAttribute($shipment, array(
437
- 'transsmart_document_id',
438
- 'transsmart_status'
439
- ));
440
-
441
- // book and print if flags indicate so
442
- $flags = (int)$shipment->getTranssmartFlags();
443
- try {
444
- if (($flags & Transsmart_Shipping_Helper_Shipment::FLAG_BOOKANDPRINT_ON_CREATE)) {
445
- if ($allowPrint) {
446
- $this->doBookAndPrint($shipment);
447
- }
448
- else {
449
- $this->doBooking($shipment);
450
- }
451
- }
452
- elseif (($flags & Transsmart_Shipping_Helper_Shipment::FLAG_BOOK_ON_CREATE)) {
453
- $this->doBooking($shipment);
454
- }
455
- }
456
- catch (Exception $exception) {
457
- Mage::logException($exception);
458
- }
459
- }
460
- }
461
-
462
- /**
463
- * Create Transsmart API documents for all shipments that need to be exported.
464
- */
465
- public function doMassExport()
466
- {
467
- /** @var Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection */
468
- $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection');
469
-
470
- // we need only valid Transsmart shipments without document ID
471
- $shipmentCollection
472
- ->addFieldToFilter('transsmart_carrierprofile_id', array('notnull' => true))
473
- ->addFieldToFilter('transsmart_shipmentlocation_id', array('notnull' => true))
474
- ->addFieldToFilter('transsmart_emailtype_id', array('notnull' => true))
475
- ->addFieldToFilter('transsmart_incoterm_id', array('notnull' => true))
476
- ->addFieldToFilter('transsmart_costcenter_id', array('notnull' => true))
477
- ->addFieldToFilter('transsmart_packages', array('notnull' => true))
478
- ->addFieldToFilter('transsmart_document_id', array('null' => true));
479
-
480
- /** @var Mage_Sales_Model_Order_Shipment $_shipment */
481
- foreach ($shipmentCollection as $_shipment) {
482
- // set original data manually (because we didn't call object load())
483
- $_shipment->setOrigData();
484
-
485
- $this->doExport($_shipment, false);
486
- }
487
-
488
- // group documentIds for all book-and-print shipments with the same QZ Host and Selected Printer
489
- $groupedCalls = $this->_getMassPrintGroupedCalls($shipmentCollection, true);
490
- if (count($groupedCalls) == 0) {
491
- return;
492
- }
493
-
494
- $idsToSync = array();
495
- try {
496
- // call Transsmart API doLabel method for each group (doBooking was already called in doExport)
497
- foreach ($groupedCalls as $_call) {
498
- $idsToSync += $_call['doc_ids'];
499
- Mage::helper('transsmart_shipping')->getApiClient()->doLabel(
500
- $_call['doc_ids'],
501
- Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
502
- false,
503
- false,
504
- $_call['qz_host'],
505
- $_call['selected_printer']
506
- );
507
- }
508
- }
509
- catch (Exception $exception) {
510
- $this->_massSyncDocuments($shipmentCollection, $idsToSync);
511
- throw $exception;
512
- }
513
- $this->_massSyncDocuments($shipmentCollection, $idsToSync);
514
- }
515
-
516
- /**
517
- * Call doBookAndPrint for a Transsmart shipment and process the response. Returns TRUE if successful.
518
- *
519
- * @param Mage_Sales_Model_Order_Shipment $shipment
520
- * @return bool
521
- * @throws Exception
522
- */
523
- public function doBookAndPrint($shipment)
524
- {
525
- if (!$shipment->getTranssmartDocumentId()) {
526
- Mage::throwException($this->__('Transsmart document ID is not known.'));
527
- }
528
-
529
- try {
530
- // call Transsmart API doBookAndPrint method
531
- Mage::helper('transsmart_shipping')->getApiClient()->doBookAndPrint(
532
- $shipment->getTranssmartDocumentId(),
533
- Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
534
- false,
535
- Mage::getStoreConfig(
536
- Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_QZHOST,
537
- $shipment->getStore()
538
- ),
539
- Mage::getStoreConfig(
540
- Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_SELECTEDPRINTER,
541
- $shipment->getStore()
542
- )
543
- );
544
- }
545
- catch (Exception $exception) {
546
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
547
- throw $exception;
548
- }
549
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
550
-
551
- return true;
552
- }
553
-
554
- /**
555
- * Call doBooking for a Transsmart shipment and process the response. Returns TRUE if successful.
556
- *
557
- * @param Mage_Sales_Model_Order_Shipment $shipment
558
- * @return bool
559
- * @throws Exception
560
- */
561
- public function doBooking($shipment)
562
- {
563
- if (!$shipment->getTranssmartDocumentId()) {
564
- Mage::throwException($this->__('Transsmart document ID is not known.'));
565
- }
566
-
567
- try {
568
- // call Transsmart API doBooking method
569
- Mage::helper('transsmart_shipping')->getApiClient()->doBooking(
570
- $shipment->getTranssmartDocumentId()
571
- );
572
- }
573
- catch (Exception $exception) {
574
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
575
- throw $exception;
576
- }
577
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
578
-
579
- return true;
580
- }
581
-
582
- /**
583
- * Call doLabel for a Transsmart shipment.
584
- *
585
- * @param Mage_Sales_Model_Order_Shipment $shipment
586
- * @return bool
587
- * @throws Exception
588
- */
589
- public function doLabel($shipment)
590
- {
591
- if (!$shipment->getTranssmartDocumentId()) {
592
- Mage::throwException($this->__('Transsmart document ID is not known.'));
593
- }
594
-
595
- try {
596
- // call Transsmart API doLabel method
597
- Mage::helper('transsmart_shipping')->getApiClient()->doLabel(
598
- $shipment->getTranssmartDocumentId(),
599
- Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
600
- false,
601
- false,
602
- Mage::getStoreConfig(
603
- Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_QZHOST,
604
- $shipment->getStore()
605
- ),
606
- Mage::getStoreConfig(
607
- Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_SELECTEDPRINTER,
608
- $shipment->getStore()
609
- )
610
- );
611
- }
612
- catch (Exception $exception) {
613
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
614
- throw $exception;
615
- }
616
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
617
-
618
- return true;
619
- }
620
-
621
- /**
622
- * Group documentIds for shipments with the same QZ Host and Selected Printer.
623
- * Used by doMassBookAndPrint and doMassLabel
624
- *
625
- * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
626
- * @param bool $onlyWithBookAndPrintFlag
627
- * @return array
628
- */
629
- protected function _getMassPrintGroupedCalls($shipmentCollection, $onlyWithBookAndPrintFlag)
630
- {
631
- // group documentIds for shipments with the same QZ Host and Selected Printer.
632
- $groupedCalls = array();
633
- foreach ($shipmentCollection as $_shipment) {
634
- if (!$_shipment->getTranssmartDocumentId()) {
635
- continue;
636
- }
637
-
638
- // do we need only shipments with the FLAG_BOOKANDPRINT_ON_CREATE flag?
639
- if ($onlyWithBookAndPrintFlag) {
640
- $_flags = (int)$_shipment->getTranssmartFlags();
641
- if (($_flags & Transsmart_Shipping_Helper_Shipment::FLAG_BOOKANDPRINT_ON_CREATE) == 0) {
642
- continue;
643
- }
644
- }
645
-
646
- $_qzHost = Mage::getStoreConfig(
647
- Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_QZHOST,
648
- $_shipment->getStore()
649
- );
650
- $_selectedPrinter = Mage::getStoreConfig(
651
- Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_SELECTEDPRINTER,
652
- $_shipment->getStore()
653
- );
654
-
655
- $_groupKey = $_qzHost . ':' . $_selectedPrinter;
656
- if (!isset($groupedCalls[$_groupKey])) {
657
- $groupedCalls[$_groupKey] = array(
658
- 'qz_host' => $_qzHost,
659
- 'selected_printer' => $_selectedPrinter,
660
- 'doc_ids' => array()
661
- );
662
- }
663
-
664
- $groupedCalls[$_groupKey]['doc_ids'][] = $_shipment->getTranssmartDocumentId();
665
- }
666
-
667
- return $groupedCalls;
668
- }
669
-
670
- /**
671
- * Synchronize status for the given shipments. If idsToSync array is given, only those document IDs will be synced.
672
- * Used by doMassBookAndPrint and doMassLabel
673
- *
674
- * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
675
- * @param array|null $idsToSync
676
- */
677
- protected function _massSyncDocuments($shipmentCollection, $idsToSync = null)
678
- {
679
- if (!is_null($idsToSync) && count($idsToSync) == 0) {
680
- return;
681
- }
682
-
683
- foreach ($shipmentCollection as $_shipment) {
684
- $_documentId = $_shipment->getTranssmartDocumentId();
685
- if (!$_documentId || (!is_null($idsToSync) && !in_array($_documentId, $idsToSync))) {
686
- continue;
687
- }
688
-
689
- try {
690
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($_shipment);
691
- }
692
- catch (Mage_Core_Exception $exception) {
693
- Mage::logException($exception);
694
- }
695
- }
696
- }
697
-
698
- /**
699
- * Call doBookAndPrint for multiple Transsmart shipments at once.
700
- *
701
- * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
702
- * @return bool
703
- * @throws Exception
704
- */
705
- public function doMassBookAndPrint($shipmentCollection)
706
- {
707
- // group documentIds for shipments with the same QZ Host and Selected Printer.
708
- $groupedCalls = $this->_getMassPrintGroupedCalls($shipmentCollection, false);
709
- if (count($groupedCalls) == 0) {
710
- return;
711
- }
712
-
713
- $idsToSync = array();
714
- try {
715
- // call Transsmart API doLabel method for each group
716
- foreach ($groupedCalls as $_call) {
717
- $idsToSync += $_call['doc_ids'];
718
- Mage::helper('transsmart_shipping')->getApiClient()->doBookAndPrint(
719
- $_call['doc_ids'],
720
- Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
721
- false,
722
- $_call['qz_host'],
723
- $_call['selected_printer']
724
- );
725
- }
726
- }
727
- catch (Exception $exception) {
728
- $this->_massSyncDocuments($shipmentCollection, $idsToSync);
729
- throw $exception;
730
- }
731
- $this->_massSyncDocuments($shipmentCollection, $idsToSync);
732
-
733
- return true;
734
- }
735
-
736
- /**
737
- * Call doLabel for multiple Transsmart shipments at once.
738
- *
739
- * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
740
- * @return bool
741
- * @throws Exception
742
- */
743
- public function doMassLabel($shipmentCollection)
744
- {
745
- // group documentIds for shipments with the same QZ Host and Selected Printer.
746
- $groupedCalls = $this->_getMassPrintGroupedCalls($shipmentCollection, false);
747
- if (count($groupedCalls) == 0) {
748
- return;
749
- }
750
-
751
- $idsToSync = array();
752
- try {
753
- // call Transsmart API doLabel method for each group
754
- foreach ($groupedCalls as $_call) {
755
- $idsToSync += $_call['doc_ids'];
756
- Mage::helper('transsmart_shipping')->getApiClient()->doLabel(
757
- $_call['doc_ids'],
758
- Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
759
- false,
760
- false,
761
- $_call['qz_host'],
762
- $_call['selected_printer']
763
- );
764
- }
765
- }
766
- catch (Exception $exception) {
767
- $this->_massSyncDocuments($shipmentCollection, $idsToSync);
768
- throw $exception;
769
- }
770
- $this->_massSyncDocuments($shipmentCollection, $idsToSync);
771
-
772
- return true;
773
- }
774
- }
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Transsmart
5
+ * @package Transsmart_Shipping
6
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
+ */
8
+ class Transsmart_Shipping_Helper_Shipment extends Mage_Core_Helper_Abstract
9
+ {
10
+ const XML_PATH_DEFAULT_CARRIERPROFILE = 'transsmart_shipping/default_shipment/carrierprofile';
11
+ const XML_PATH_DEFAULT_SHIPMENTLOCATION = 'transsmart_shipping/default_shipment/shipmentlocation';
12
+ const XML_PATH_DEFAULT_EMAILTYPE = 'transsmart_shipping/default_shipment/emailtype';
13
+ const XML_PATH_DEFAULT_INCOTERM = 'transsmart_shipping/default_shipment/incoterm';
14
+ const XML_PATH_DEFAULT_COSTCENTER = 'transsmart_shipping/default_shipment/costcenter';
15
+ const XML_PATH_DEFAULT_PACKAGETYPE = 'transsmart_shipping/default_shipment/packagetype';
16
+
17
+ const XML_PATH_MAPPING_STREET = 'transsmart_shipping/mapping/street';
18
+ const XML_PATH_MAPPING_STREETNO = 'transsmart_shipping/mapping/streetno';
19
+ const XML_PATH_MAPPING_STREET2 = 'transsmart_shipping/mapping/street2';
20
+ const XML_PATH_MAPPING_COUNTRY_OF_ORIGIN = 'transsmart_shipping/mapping/country_of_origin';
21
+ const XML_PATH_MAPPING_HS_CODE = 'transsmart_shipping/mapping/hs_code';
22
+ const XML_PATH_MAPPING_REASON_OF_EXPORT = 'transsmart_shipping/mapping/reason_of_export';
23
+
24
+ // OR'ed values for the 'transsmart_flags' field in the shipment table
25
+ const FLAG_BOOK_ON_CREATE = 1;
26
+ const FLAG_BOOKANDPRINT_ON_CREATE = 2;
27
+
28
+ /**
29
+ * Get all possible Transsmart shipment statuses.
30
+ *
31
+ * @return array
32
+ */
33
+ public function getShipmentStatuses()
34
+ {
35
+ return array(
36
+ 'NONE' => $this->__('NONE'),
37
+ 'NEW' => $this->__('NEW'),
38
+ 'BOOK' => $this->__('BOOK'),
39
+ 'LABL' => $this->__('LABL'),
40
+ 'MANI' => $this->__('MANI'),
41
+ 'ACCEP' => $this->__('ACCEP'),
42
+ 'TRNS' => $this->__('TRNS'),
43
+ 'DONE' => $this->__('DONE'),
44
+ 'APOD' => $this->__('APOD'),
45
+ 'REFU' => $this->__('REFU'),
46
+ 'ERR' => $this->__('ERR'),
47
+ 'DEL' => $this->__('DEL'),
48
+ 'ONHOLD' => $this->__('ONHOLD'),
49
+ );
50
+ }
51
+
52
+ /**
53
+ * Get configured default carrierprofile for the given shipment or store.
54
+ *
55
+ * @param Mage_Sales_Model_Order_Shipment|null $shipment
56
+ * @param null $store
57
+ * @return int
58
+ */
59
+ public function getDefaultCarrierprofileId($shipment = null, $store = null)
60
+ {
61
+ $defaultValue = false;
62
+ if ($shipment instanceof Mage_Sales_Model_Order_Shipment) {
63
+ $shippingMethod = $shipment->getOrder()->getShippingMethod(false);
64
+ $carrierprofile = Mage::getModel('transsmart_shipping/carrierprofile')
65
+ ->loadByShippingMethodCode($shippingMethod);
66
+ $defaultValue = $carrierprofile->getId();
67
+ if (!$defaultValue) {
68
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_CARRIERPROFILE, $shipment->getStore());
69
+ }
70
+ }
71
+ if (!$defaultValue) {
72
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_CARRIERPROFILE, $store);
73
+ }
74
+ return $defaultValue;
75
+ }
76
+
77
+ /**
78
+ * Get configured default shipmentlocation for the given store.
79
+ *
80
+ * @param null $store
81
+ * @return int
82
+ */
83
+ public function getDefaultShipmentlocationId($store = null)
84
+ {
85
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_SHIPMENTLOCATION, $store);
86
+ if (!$defaultValue) {
87
+ $ids = Mage::getResourceModel('transsmart_shipping/shipmentlocation_collection')
88
+ ->addFieldToFilter('is_default', array('eq' => 1))
89
+ ->setPageSize(1)
90
+ ->getAllIds();
91
+ if (count($ids)) {
92
+ $defaultValue = $ids[0];
93
+ }
94
+ }
95
+ return $defaultValue;
96
+ }
97
+
98
+ /**
99
+ * Get configured default emailtype for the given store.
100
+ *
101
+ * @param null $store
102
+ * @return int
103
+ */
104
+ public function getDefaultEmailtypeId($store = null)
105
+ {
106
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_EMAILTYPE, $store);
107
+ if (!$defaultValue) {
108
+ $ids = Mage::getResourceModel('transsmart_shipping/emailtype_collection')
109
+ ->addFieldToFilter('is_default', array('eq' => 1))
110
+ ->setPageSize(1)
111
+ ->getAllIds();
112
+ if (count($ids)) {
113
+ $defaultValue = $ids[0];
114
+ }
115
+ }
116
+ return $defaultValue;
117
+ }
118
+
119
+ /**
120
+ * Get configured default incoterm for the given store.
121
+ *
122
+ * @param null $store
123
+ * @return int
124
+ */
125
+ public function getDefaultIncotermId($store = null)
126
+ {
127
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_INCOTERM, $store);
128
+ if (!$defaultValue) {
129
+ $ids = Mage::getResourceModel('transsmart_shipping/incoterm_collection')
130
+ ->addFieldToFilter('is_default', array('eq' => 1))
131
+ ->setPageSize(1)
132
+ ->getAllIds();
133
+ if (count($ids)) {
134
+ $defaultValue = $ids[0];
135
+ }
136
+ }
137
+ return $defaultValue;
138
+ }
139
+
140
+ /**
141
+ * Get configured default costcenter for the given store.
142
+ *
143
+ * @param null $store
144
+ * @return int
145
+ */
146
+ public function getDefaultCostcenterId($store = null)
147
+ {
148
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_COSTCENTER, $store);
149
+ if (!$defaultValue) {
150
+ $ids = Mage::getResourceModel('transsmart_shipping/costcenter_collection')
151
+ ->addFieldToFilter('is_default', array('eq' => 1))
152
+ ->setPageSize(1)
153
+ ->getAllIds();
154
+ if (count($ids)) {
155
+ $defaultValue = $ids[0];
156
+ }
157
+ }
158
+ return $defaultValue;
159
+ }
160
+
161
+ /**
162
+ * Get configured default packagetype for the given store.
163
+ *
164
+ * @param null $store
165
+ * @return int
166
+ */
167
+ public function getDefaultPackagetypeId($store = null)
168
+ {
169
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_PACKAGETYPE, $store);
170
+ if (!$defaultValue) {
171
+ $ids = Mage::getResourceModel('transsmart_shipping/packagetype_collection')
172
+ ->addFieldToFilter('is_default', array('eq' => 1))
173
+ ->setPageSize(1)
174
+ ->getAllIds();
175
+ if (count($ids)) {
176
+ $defaultValue = $ids[0];
177
+ }
178
+ }
179
+ return $defaultValue;
180
+ }
181
+
182
+ /**
183
+ * Get the street and housenumber from the given address. If there's only one street field, try to split it into
184
+ * separate fields.
185
+ *
186
+ * @param Mage_Sales_Model_Order_Address $address
187
+ * @param mixed $store
188
+ * @return array
189
+ */
190
+ protected function _getStreetFields($address, $store = null)
191
+ {
192
+ if ($address->hasTranssmartServicepointId()) {
193
+ // for addresses from the location selector, always use predetermined fields
194
+ $street = $address->getStreet(1);
195
+ $streetNo = $address->getStreet(2);
196
+ $street2 = $address->getStreet(3);
197
+ }
198
+ else {
199
+ // read config settings for street fields mapping
200
+ $mappingStreet = Mage::getStoreConfig(self::XML_PATH_MAPPING_STREET, $store);
201
+ $mappingStreetNo = Mage::getStoreConfig(self::XML_PATH_MAPPING_STREETNO, $store);
202
+ $mappingStreet2 = Mage::getStoreConfig(self::XML_PATH_MAPPING_STREET2, $store);
203
+
204
+ // get street value
205
+ switch ($mappingStreet) {
206
+ case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::NONE:
207
+ $street = '';
208
+ break;
209
+ case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::FULL:
210
+ $street = trim(implode(' ', $address->getStreet()));
211
+ break;
212
+ default:
213
+ $street = $address->getStreet($mappingStreet);
214
+ }
215
+
216
+ // get streetno value
217
+ switch ($mappingStreetNo) {
218
+ case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::NONE:
219
+ $streetNo = '';
220
+ break;
221
+ case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::FULL:
222
+ $streetNo = trim(implode(' ', $address->getStreet()));
223
+ break;
224
+ default:
225
+ $streetNo = $address->getStreet($mappingStreetNo);
226
+ }
227
+
228
+ // get street2 value
229
+ switch ($mappingStreet2) {
230
+ case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::NONE:
231
+ $street2 = '';
232
+ break;
233
+ case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::FULL:
234
+ $street2 = trim(implode(' ', $address->getStreet()));
235
+ break;
236
+ default:
237
+ $street2 = $address->getStreet($mappingStreet2);
238
+ }
239
+
240
+ // automatic house number detection
241
+ if ($mappingStreet == $mappingStreetNo) {
242
+ $streetNo = '';
243
+
244
+ if (preg_match('/^(.*) ([0-9]+ .*)$/', $street, $matches)) {
245
+ $street = $matches[1];
246
+ $streetNo = $matches[2];
247
+ }
248
+ elseif (preg_match('/^(.*) ([0-9]+.*)$/', $street, $matches)) {
249
+ $street = $matches[1];
250
+ $streetNo = $matches[2];
251
+ }
252
+ elseif (preg_match('/^(.*) ([0-9]+.*)$/', $street, $matches)) {
253
+ $street = $matches[1];
254
+ $streetNo = $matches[2];
255
+ }
256
+ }
257
+ }
258
+
259
+ // house number cannot be empty
260
+ if ($streetNo === '') {
261
+ $streetNo = '.';
262
+ }
263
+
264
+ return array($street, $streetNo, $street2);
265
+ }
266
+
267
+ /**
268
+ * Export the given shipment to the Transsmart API.
269
+ *
270
+ * @param Mage_Sales_Model_Order_Shipment $shipment
271
+ * @param bool $allowPrint
272
+ */
273
+ public function doExport($shipment, $allowPrint = true)
274
+ {
275
+ // is it already exported?
276
+ if ($shipment->getTranssmartDocumentId()) {
277
+ return;
278
+ }
279
+
280
+ /** @var Transsmart_Shipping_Model_Carrierprofile $carrierprofile */
281
+ $carrierprofile = Mage::getModel('transsmart_shipping/carrierprofile')
282
+ ->load($shipment->getTranssmartCarrierprofileId());
283
+ if (!$carrierprofile->getId()) {
284
+ return;
285
+ }
286
+
287
+ $store = $shipment->getStore();
288
+ $address = $shipment->getShippingAddress();
289
+ $invoiceAddress = $shipment->getBillingAddress();
290
+
291
+ // check if the order has a pickup address (location selector is used)
292
+ $pickupAddress = Mage::helper('transsmart_shipping/pickupaddress')
293
+ ->getPickupAddressFromOrder($shipment->getOrder());
294
+ $servicePointId = null;
295
+ if ($pickupAddress) {
296
+ $address = $pickupAddress;
297
+ $invoiceAddress = $shipment->getShippingAddress();
298
+ $servicePointId = $pickupAddress->getTranssmartServicepointId();
299
+ }
300
+
301
+ // determine address name and contact
302
+ $addressName = $address->getCompany();
303
+ $addressContact = $address->getName();
304
+ if ($addressName == '') {
305
+ $addressName = $addressContact;
306
+ }
307
+
308
+ // determine invoice address name and contact
309
+ $invoiceAddressName = $invoiceAddress->getCompany();
310
+ $invoiceAddressContact = $invoiceAddress->getName();
311
+ if ($invoiceAddressName == '') {
312
+ $invoiceAddressName = $invoiceAddressContact;
313
+ }
314
+
315
+ // split street fields into street and house number
316
+ list($addressStreet, $addressStreetNo, $addressStreet2) =
317
+ $this->_getStreetFields($address, $store);
318
+ list($invoiceAddressStreet, $invoiceAddressStreetNo, $invoiceAddressStreet2) =
319
+ $this->_getStreetFields($invoiceAddress, $store);
320
+
321
+ /** @var Mage_Core_Helper_String $stringHelper */
322
+ $stringHelper = Mage::helper('core/string');
323
+
324
+ // calculate shipment value and prepare delivery note lines
325
+ $shipmentValue = 0.0;
326
+ $deliveryNoteInfoLines = array();
327
+ /** @var Mage_Sales_Model_Order_Shipment_Item $_item */
328
+ foreach ($shipment->getAllItems() as $_item) {
329
+ if ($_item->getOrderItem()->getParentItem()) {
330
+ continue;
331
+ }
332
+
333
+ $shipmentValue += $_item->getPrice() * $_item->getQty();
334
+
335
+ $_line = array(
336
+ 'ArticleId' => $_item->getSku(),
337
+ 'ArticleName' => $stringHelper->substr($_item->getName(), 0, 45),
338
+ 'Description' => $stringHelper->substr($_item->getDescription(), 0, 510),
339
+ 'Price' => $_item->getPrice(),
340
+ 'Currency' => $store->getCurrentCurrencyCode(),
341
+ 'Quantity' => $_item->getQty(),
342
+ 'QuantityBackorder' => floatval($_item->getOrderItem()->getQtyBackordered()),
343
+ 'QuantityOrder' => $_item->getOrderItem()->getQtyOrdered(),
344
+ 'CountryOfOrigin' => Mage::getStoreConfig('shipping/origin/country_id', $store),
345
+ 'ReasonOfExport' => 'Sale',
346
+ );
347
+
348
+ $_additionalFields = array(
349
+ 'Description' => 'description',
350
+ 'CountryOfOrigin' => Mage::getStoreConfig(self::XML_PATH_MAPPING_COUNTRY_OF_ORIGIN, $store),
351
+ 'HSCode' => Mage::getStoreConfig(self::XML_PATH_MAPPING_HS_CODE, $store),
352
+ 'ReasonOfExport' => Mage::getStoreConfig(self::XML_PATH_MAPPING_REASON_OF_EXPORT, $store),
353
+ );
354
+ $_product = $_item->getOrderItem()->getProduct();
355
+ foreach ($_additionalFields as $_field => $_attributeCode) {
356
+ if (empty($_attributeCode)) {
357
+ continue;
358
+ }
359
+ if ($_attribute = $_product->getResource()->getAttribute($_attributeCode)) {
360
+ if ($_attribute->getBackendType() == 'int' && $_attribute->getFrontendInput() == 'select') {
361
+ // dropdown or multiselect field; use the frontend label
362
+ $_attribute->setStoreId($store->getId());
363
+ $_value = $_attribute->getFrontend()->getValue($_product);
364
+ }
365
+ else {
366
+ $_value = $_product->getData($_attributeCode);
367
+ }
368
+ if ($_value) {
369
+ $_line[$_field] = $_value;
370
+ }
371
+ }
372
+ }
373
+
374
+ $deliveryNoteInfoLines[] = $_line;
375
+ }
376
+
377
+ // prepare the document
378
+ $document = array(
379
+ 'Reference' => $shipment->getIncrementId(),
380
+ 'CarrierProfileId' => $carrierprofile->getId(),
381
+ //'CarrierId' => $carrierprofile->getCarrierId(),
382
+ //'ServiceLevelTimeId' => $carrierprofile->getServicelevelTimeId(),
383
+ //'ServiceLevelOtherId' => $carrierprofile->getServicelevelOtherId(),
384
+ 'ShipmentLocationId' => $shipment->getTranssmartShipmentlocationId(),
385
+ 'MailTypeId' => $shipment->getTranssmartEmailtypeId(),
386
+ 'IncotermId' => $shipment->getTranssmartIncotermId(),
387
+ 'CostCenterId' => $shipment->getTranssmartCostcenterId(),
388
+ 'RefOrder' => $shipment->getOrder()->getIncrementId(),
389
+ 'RefServicePoint' => $servicePointId,
390
+ 'ShipmentValue' => $shipmentValue,
391
+ 'AddressEmailPickup' => Mage::getStoreConfig('trans_email/ident_general/email', $store),
392
+ 'AddressName' => $addressName,
393
+ 'AddressContact' => $addressContact,
394
+ 'AddressStreet' => $addressStreet,
395
+ 'AddressStreetNo' => $addressStreetNo,
396
+ 'AddressStreet2' => $addressStreet2,
397
+ 'AddressZipcode' => $address->getPostcode(),
398
+ 'AddressCity' => $address->getCity(),
399
+ 'AddressState' => $address->getRegionCode(),
400
+ 'AddressCountry' => $address->getCountry(),
401
+ 'AddressPhone' => $address->getTelephone(),
402
+ 'AddressFax' => $address->getFax(),
403
+ 'AddressEmail' => $shipment->getShippingAddress()->getEmail(),
404
+ 'AddressCustomerNo' => $address->getCustomerId(),
405
+ 'AddressNameInvoice' => $invoiceAddressName,
406
+ 'AddressContactInvoice' => $invoiceAddressContact,
407
+ 'AddressStreetInvoice' => $invoiceAddressStreet,
408
+ 'AddressStreetNoInvoice' => $invoiceAddressStreetNo,
409
+ 'AddressStreet2Invoice' => $invoiceAddressStreet2,
410
+ 'AddressZipcodeInvoice' => $invoiceAddress->getPostcode(),
411
+ 'AddressCityInvoice' => $invoiceAddress->getCity(),
412
+ 'AddressStateInvoice' => $invoiceAddress->getRegionCode(),
413
+ 'AddressCountryInvoice' => $invoiceAddress->getCountry(),
414
+ 'AddressPhoneInvoice' => $invoiceAddress->getTelephone(),
415
+ 'AddressFaxInvoice' => $invoiceAddress->getFax(),
416
+ 'AddressEmailInvoice' => $invoiceAddress->getEmail(),
417
+ 'AddressCustomerNoInvoice' => $invoiceAddress->getCustomerId(),
418
+ 'AddressVatNumberInvoice' => $shipment->getOrder()->getCustomerTaxvat(),
419
+ 'ColliInformation' => unserialize($shipment->getTranssmartPackages()),
420
+ 'DeliveryNoteInfo' => array(
421
+ array(
422
+ 'DeliveryNoteInfoLines' => $deliveryNoteInfoLines
423
+ )
424
+ )
425
+ );
426
+
427
+ // dispatch event so other extensions can update the document
428
+ $transport = new Varien_Object(array('document' => $document));
429
+ Mage::dispatchEvent('transsmart_shipping_shipment_export_before', array(
430
+ 'shipment' => $shipment,
431
+ 'transport' => $transport
432
+ ));
433
+ $document = $transport->getDocument();
434
+
435
+ // send the document to Transsmart
436
+ $response = Mage::helper('transsmart_shipping')->getApiClient()->createDocument($document);
437
+
438
+ // save document ID and status into shipment record
439
+ if (isset($response['Id']) && isset($response['Status'])) {
440
+ $shipment->setTranssmartDocumentId($response['Id']);
441
+ $shipment->setTranssmartStatus($response['Status']);
442
+
443
+ $shipment->getResource()->saveAttribute($shipment, array(
444
+ 'transsmart_document_id',
445
+ 'transsmart_status'
446
+ ));
447
+
448
+ // book and print if flags indicate so
449
+ $flags = (int)$shipment->getTranssmartFlags();
450
+ try {
451
+ if (($flags & Transsmart_Shipping_Helper_Shipment::FLAG_BOOKANDPRINT_ON_CREATE)) {
452
+ if ($allowPrint) {
453
+ $this->doBookAndPrint($shipment);
454
+ }
455
+ else {
456
+ $this->doBooking($shipment);
457
+ }
458
+ }
459
+ elseif (($flags & Transsmart_Shipping_Helper_Shipment::FLAG_BOOK_ON_CREATE)) {
460
+ $this->doBooking($shipment);
461
+ }
462
+ }
463
+ catch (Exception $exception) {
464
+ Mage::logException($exception);
465
+ }
466
+ }
467
+ }
468
+
469
+ /**
470
+ * Create Transsmart API documents for all shipments that need to be exported.
471
+ */
472
+ public function doMassExport()
473
+ {
474
+ /** @var Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection */
475
+ $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection');
476
+
477
+ // we need only valid Transsmart shipments without document ID
478
+ $shipmentCollection
479
+ ->addFieldToFilter('transsmart_carrierprofile_id', array('notnull' => true))
480
+ ->addFieldToFilter('transsmart_shipmentlocation_id', array('notnull' => true))
481
+ ->addFieldToFilter('transsmart_emailtype_id', array('notnull' => true))
482
+ ->addFieldToFilter('transsmart_incoterm_id', array('notnull' => true))
483
+ ->addFieldToFilter('transsmart_costcenter_id', array('notnull' => true))
484
+ ->addFieldToFilter('transsmart_packages', array('notnull' => true))
485
+ ->addFieldToFilter('transsmart_document_id', array('null' => true));
486
+
487
+ /** @var Mage_Sales_Model_Order_Shipment $_shipment */
488
+ foreach ($shipmentCollection as $_shipment) {
489
+ // set original data manually (because we didn't call object load())
490
+ $_shipment->setOrigData();
491
+
492
+ $this->doExport($_shipment, false);
493
+ }
494
+
495
+ // group documentIds for all book-and-print shipments with the same QZ Host and Selected Printer
496
+ $groupedCalls = $this->_getMassPrintGroupedCalls($shipmentCollection, true);
497
+ if (count($groupedCalls) == 0) {
498
+ return;
499
+ }
500
+
501
+ $idsToSync = array();
502
+ try {
503
+ // call Transsmart API doLabel method for each group (doBooking was already called in doExport)
504
+ foreach ($groupedCalls as $_call) {
505
+ $idsToSync += $_call['doc_ids'];
506
+ Mage::helper('transsmart_shipping')->getApiClient()->doLabel(
507
+ $_call['doc_ids'],
508
+ Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
509
+ false,
510
+ false,
511
+ $_call['qz_host'],
512
+ $_call['selected_printer']
513
+ );
514
+ }
515
+ }
516
+ catch (Exception $exception) {
517
+ $this->_massSyncDocuments($shipmentCollection, $idsToSync);
518
+ throw $exception;
519
+ }
520
+ $this->_massSyncDocuments($shipmentCollection, $idsToSync);
521
+ }
522
+
523
+ /**
524
+ * Call doBookAndPrint for a Transsmart shipment and process the response. Returns TRUE if successful.
525
+ *
526
+ * @param Mage_Sales_Model_Order_Shipment $shipment
527
+ * @return bool
528
+ * @throws Exception
529
+ */
530
+ public function doBookAndPrint($shipment)
531
+ {
532
+ if (!$shipment->getTranssmartDocumentId()) {
533
+ Mage::throwException($this->__('Transsmart document ID is not known.'));
534
+ }
535
+
536
+ try {
537
+ // call Transsmart API doBookAndPrint method
538
+ Mage::helper('transsmart_shipping')->getApiClient()->doBookAndPrint(
539
+ $shipment->getTranssmartDocumentId(),
540
+ Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
541
+ false,
542
+ Mage::getStoreConfig(
543
+ Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_QZHOST,
544
+ $shipment->getStore()
545
+ ),
546
+ Mage::getStoreConfig(
547
+ Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_SELECTEDPRINTER,
548
+ $shipment->getStore()
549
+ )
550
+ );
551
+ }
552
+ catch (Exception $exception) {
553
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
554
+ throw $exception;
555
+ }
556
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
557
+
558
+ return true;
559
+ }
560
+
561
+ /**
562
+ * Call doBooking for a Transsmart shipment and process the response. Returns TRUE if successful.
563
+ *
564
+ * @param Mage_Sales_Model_Order_Shipment $shipment
565
+ * @return bool
566
+ * @throws Exception
567
+ */
568
+ public function doBooking($shipment)
569
+ {
570
+ if (!$shipment->getTranssmartDocumentId()) {
571
+ Mage::throwException($this->__('Transsmart document ID is not known.'));
572
+ }
573
+
574
+ try {
575
+ // call Transsmart API doBooking method
576
+ Mage::helper('transsmart_shipping')->getApiClient()->doBooking(
577
+ $shipment->getTranssmartDocumentId()
578
+ );
579
+ }
580
+ catch (Exception $exception) {
581
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
582
+ throw $exception;
583
+ }
584
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
585
+
586
+ return true;
587
+ }
588
+
589
+ /**
590
+ * Call doLabel for a Transsmart shipment.
591
+ *
592
+ * @param Mage_Sales_Model_Order_Shipment $shipment
593
+ * @return bool
594
+ * @throws Exception
595
+ */
596
+ public function doLabel($shipment)
597
+ {
598
+ if (!$shipment->getTranssmartDocumentId()) {
599
+ Mage::throwException($this->__('Transsmart document ID is not known.'));
600
+ }
601
+
602
+ try {
603
+ // call Transsmart API doLabel method
604
+ Mage::helper('transsmart_shipping')->getApiClient()->doLabel(
605
+ $shipment->getTranssmartDocumentId(),
606
+ Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
607
+ false,
608
+ false,
609
+ Mage::getStoreConfig(
610
+ Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_QZHOST,
611
+ $shipment->getStore()
612
+ ),
613
+ Mage::getStoreConfig(
614
+ Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_SELECTEDPRINTER,
615
+ $shipment->getStore()
616
+ )
617
+ );
618
+ }
619
+ catch (Exception $exception) {
620
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
621
+ throw $exception;
622
+ }
623
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
624
+
625
+ return true;
626
+ }
627
+
628
+ /**
629
+ * Group documentIds for shipments with the same QZ Host and Selected Printer.
630
+ * Used by doMassBookAndPrint and doMassLabel
631
+ *
632
+ * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
633
+ * @param bool $onlyWithBookAndPrintFlag
634
+ * @return array
635
+ */
636
+ protected function _getMassPrintGroupedCalls($shipmentCollection, $onlyWithBookAndPrintFlag)
637
+ {
638
+ // group documentIds for shipments with the same QZ Host and Selected Printer.
639
+ $groupedCalls = array();
640
+ foreach ($shipmentCollection as $_shipment) {
641
+ if (!$_shipment->getTranssmartDocumentId()) {
642
+ continue;
643
+ }
644
+
645
+ // do we need only shipments with the FLAG_BOOKANDPRINT_ON_CREATE flag?
646
+ if ($onlyWithBookAndPrintFlag) {
647
+ $_flags = (int)$_shipment->getTranssmartFlags();
648
+ if (($_flags & Transsmart_Shipping_Helper_Shipment::FLAG_BOOKANDPRINT_ON_CREATE) == 0) {
649
+ continue;
650
+ }
651
+ }
652
+
653
+ $_qzHost = Mage::getStoreConfig(
654
+ Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_QZHOST,
655
+ $_shipment->getStore()
656
+ );
657
+ $_selectedPrinter = Mage::getStoreConfig(
658
+ Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_SELECTEDPRINTER,
659
+ $_shipment->getStore()
660
+ );
661
+
662
+ $_groupKey = $_qzHost . ':' . $_selectedPrinter;
663
+ if (!isset($groupedCalls[$_groupKey])) {
664
+ $groupedCalls[$_groupKey] = array(
665
+ 'qz_host' => $_qzHost,
666
+ 'selected_printer' => $_selectedPrinter,
667
+ 'doc_ids' => array()
668
+ );
669
+ }
670
+
671
+ $groupedCalls[$_groupKey]['doc_ids'][] = $_shipment->getTranssmartDocumentId();
672
+ }
673
+
674
+ return $groupedCalls;
675
+ }
676
+
677
+ /**
678
+ * Synchronize status for the given shipments. If idsToSync array is given, only those document IDs will be synced.
679
+ * Used by doMassBookAndPrint and doMassLabel
680
+ *
681
+ * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
682
+ * @param array|null $idsToSync
683
+ */
684
+ protected function _massSyncDocuments($shipmentCollection, $idsToSync = null)
685
+ {
686
+ if (!is_null($idsToSync) && count($idsToSync) == 0) {
687
+ return;
688
+ }
689
+
690
+ foreach ($shipmentCollection as $_shipment) {
691
+ $_documentId = $_shipment->getTranssmartDocumentId();
692
+ if (!$_documentId || (!is_null($idsToSync) && !in_array($_documentId, $idsToSync))) {
693
+ continue;
694
+ }
695
+
696
+ try {
697
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($_shipment);
698
+ }
699
+ catch (Mage_Core_Exception $exception) {
700
+ Mage::logException($exception);
701
+ }
702
+ }
703
+ }
704
+
705
+ /**
706
+ * Call doBookAndPrint for multiple Transsmart shipments at once.
707
+ *
708
+ * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
709
+ * @return bool
710
+ * @throws Exception
711
+ */
712
+ public function doMassBookAndPrint($shipmentCollection)
713
+ {
714
+ // group documentIds for shipments with the same QZ Host and Selected Printer.
715
+ $groupedCalls = $this->_getMassPrintGroupedCalls($shipmentCollection, false);
716
+ if (count($groupedCalls) == 0) {
717
+ return;
718
+ }
719
+
720
+ $idsToSync = array();
721
+ try {
722
+ // call Transsmart API doLabel method for each group
723
+ foreach ($groupedCalls as $_call) {
724
+ $idsToSync += $_call['doc_ids'];
725
+ Mage::helper('transsmart_shipping')->getApiClient()->doBookAndPrint(
726
+ $_call['doc_ids'],
727
+ Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
728
+ false,
729
+ $_call['qz_host'],
730
+ $_call['selected_printer']
731
+ );
732
+ }
733
+ }
734
+ catch (Exception $exception) {
735
+ $this->_massSyncDocuments($shipmentCollection, $idsToSync);
736
+ throw $exception;
737
+ }
738
+ $this->_massSyncDocuments($shipmentCollection, $idsToSync);
739
+
740
+ return true;
741
+ }
742
+
743
+ /**
744
+ * Call doLabel for multiple Transsmart shipments at once.
745
+ *
746
+ * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
747
+ * @return bool
748
+ * @throws Exception
749
+ */
750
+ public function doMassLabel($shipmentCollection)
751
+ {
752
+ // group documentIds for shipments with the same QZ Host and Selected Printer.
753
+ $groupedCalls = $this->_getMassPrintGroupedCalls($shipmentCollection, false);
754
+ if (count($groupedCalls) == 0) {
755
+ return;
756
+ }
757
+
758
+ $idsToSync = array();
759
+ try {
760
+ // call Transsmart API doLabel method for each group
761
+ foreach ($groupedCalls as $_call) {
762
+ $idsToSync += $_call['doc_ids'];
763
+ Mage::helper('transsmart_shipping')->getApiClient()->doLabel(
764
+ $_call['doc_ids'],
765
+ Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
766
+ false,
767
+ false,
768
+ $_call['qz_host'],
769
+ $_call['selected_printer']
770
+ );
771
+ }
772
+ }
773
+ catch (Exception $exception) {
774
+ $this->_massSyncDocuments($shipmentCollection, $idsToSync);
775
+ throw $exception;
776
+ }
777
+ $this->_massSyncDocuments($shipmentCollection, $idsToSync);
778
+
779
+ return true;
780
+ }
781
+ }
app/code/community/Transsmart/Shipping/etc/config.xml CHANGED
@@ -9,7 +9,7 @@
9
  <config>
10
  <modules>
11
  <Transsmart_Shipping>
12
- <version>1.0.1</version>
13
  </Transsmart_Shipping>
14
  </modules>
15
  <global>
9
  <config>
10
  <modules>
11
  <Transsmart_Shipping>
12
+ <version>1.0.2</version>
13
  </Transsmart_Shipping>
14
  </modules>
15
  <global>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Transsmart_Shipping</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Transsmart Magento connector</summary>
10
  <description>Integrates Transsmart Shipping into Magento.</description>
11
- <notes>1.0.1</notes>
12
  <authors><author><name>Techtwo Webdevelopment B.V.</name><user>techtwo</user><email>info@techtwo.nl</email></author><author><name>Bastiaan Heeren</name><user>techtwobastiaan</user><email>bastiaan@techtwo.nl</email></author></authors>
13
- <date>2016-01-21</date>
14
- <time>12:36:17</time>
15
- <contents><target name="magecommunity"><dir name="Transsmart"><dir name="Shipping"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="bafce0b64ee9545b3a355df1b0b8e18d"/><dir name="Shipment"><dir name="Create"><file name="Detail.php" hash="b8b8b391b781f5d9de8b2578ad84d540"/><file name="Package.php" hash="7054391262f4bcc78d77bbd8d7131d61"/></dir><dir name="Masscreate"><file name="Form.php" hash="1bef6372fca204ba939fca5a02f3fa3d"/></dir><file name="Masscreate.php" hash="244adc0427800e5df7ea050947cff0d5"/><dir name="View"><file name="Detail.php" hash="0c5a780a5a4095164b02b06a5cd5ec16"/><file name="Package.php" hash="ccdda1fc1a9710ff1d317575fd53baa7"/></dir></dir><dir name="View"><dir name="Tab"><file name="Shipments.php" hash="e8b2006ed7c6541ea61c309123457c7c"/></dir></dir></dir><dir name="Shipment"><dir name="Grid"><dir name="Renderer"><file name="Link.php" hash="f42b111af0b6fa7dbdd171b9ef9f5655"/></dir></dir><file name="Grid.php" hash="931e2c538a9f61c62fc838d441419c48"/></dir></dir><dir name="Shipping"><dir name="Location"><file name="Info.php" hash="fa01c870d4a5cd521ed312a447f10dda"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Fetch.php" hash="43361767a4367c59fea55c23bb52aaed"/></dir><dir name="Fieldset"><dir name="Carrierprofile"><file name="Header.php" hash="01bda5320d4fcb5493f7fc2fd7ec01ac"/></dir><file name="Carrierprofile.php" hash="a75608f6b98458f1797d41d24a52030b"/><file name="Versioninfo.php" hash="84f740e55f0abc8fda7d95d26a638214"/></dir></dir></dir></dir></dir><dir name="Location"><file name="Selector.php" hash="f13d261827cb806fcc14c73058128653"/></dir></dir><dir name="Helper"><file name="Data.php" hash="32590b34298ed7ee39ebc011485e970e"/><file name="Location.php" hash="59dd6de96da501192e995f3688cba950"/><file name="Pickupaddress.php" hash="c71ad4ae7e2c4536a2d57c18d57b8919"/><file name="Shipment.php" hash="521150f7ac5e16f23ccd6939bec2bea5"/></dir><dir name="Model"><file name="Abstract.php" hash="5b8973d5f3ce40cd641e9f16cdcd6620"/><dir name="Adminhtml"><file name="Observer.php" hash="3664f0727b0159ccdeff1cf256b5fccf"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Localized.php" hash="3f7ee8815b1f71168ba3fe2f2eb6389f"/></dir><dir name="Source"><dir name="Basedata"><file name="Abstract.php" hash="ac0c0632d16278357cc4128b3a5ef9a8"/><file name="Carrierprofile.php" hash="f01d6e81905f9481a8906253ccfc24e3"/><file name="Costcenter.php" hash="4dabd6942ab4e27e8c7e7032e3d01ca9"/><file name="Emailtype.php" hash="5d5d02c41970795f42e86ec4184a1072"/><file name="Incoterm.php" hash="8724e4b8bd9267fe843d62ffaa939b1e"/><file name="Packagetype.php" hash="6277448d89f3eeaae2dd15dd8a318af1"/><file name="Shipmentlocation.php" hash="f025e24746908e9c5aea82109f3b79fa"/></dir><file name="Environment.php" hash="4d011d8f728c3582022178da0c26ea66"/><dir name="Mapping"><file name="Attribute.php" hash="f2302357356f4c4b6f43cc63c408722a"/><file name="Street.php" hash="e42fa0ede4bc76876cf0c1f783189e87"/></dir><file name="Method.php" hash="672e247ef3764ff9294607102b152c78"/></dir></dir></dir></dir><file name="Carrier.php" hash="9aac846543c6b82cd3a06f9e307593ae"/><file name="Carrierprofile.php" hash="fb3bc266d34c00dbc10b76e89f6de20f"/><file name="Client.php" hash="9dbd3fc487adedecfc28d84eb7137842"/><file name="Costcenter.php" hash="bf6a9a5a95fa7cf1e0a609c6e0cf6365"/><file name="Emailtype.php" hash="b7128a27c6937c63f9a8ba14510dad13"/><file name="Incoterm.php" hash="8ebd437537680f375568f7873607ef87"/><file name="Observer.php" hash="e42f9c5c5a241e9ed8fef967fe194dee"/><file name="Packagetype.php" hash="d9f5012184c0e52429be7396e4081c69"/><dir name="Resource"><dir name="Carrier"><file name="Collection.php" hash="aabffe27624593ec59d489aaea12319c"/></dir><file name="Carrier.php" hash="57b812414155d31fe39977be1483ab1e"/><dir name="Carrierprofile"><file name="Collection.php" hash="59c40952ae124b257a30eebd72651df7"/></dir><file name="Carrierprofile.php" hash="53d9e49e8cf00b080f80489a476e43ef"/><dir name="Costcenter"><file name="Collection.php" hash="e338f05492a12988d3066bbc2f7569fe"/></dir><file name="Costcenter.php" hash="338db8721bcd09dabbece8e9c862ac92"/><dir name="Emailtype"><file name="Collection.php" hash="fe4ee29a8af109be50e7d928a8d5a9c3"/></dir><file name="Emailtype.php" hash="27b7d676aabf4e16891ccadee409aeba"/><dir name="Incoterm"><file name="Collection.php" hash="7490a144291e1b2a81f5c243173627e3"/></dir><file name="Incoterm.php" hash="5076d4828c71f71178d7d33213d2e735"/><dir name="Packagetype"><file name="Collection.php" hash="f20c13999570a2338feaf1f8af72c85b"/></dir><file name="Packagetype.php" hash="b8de7857c71a26be8915a67c38a1d347"/><dir name="Servicelevel"><dir name="Other"><file name="Collection.php" hash="c48542bc38fc957c97b90bcc2d0d0773"/></dir><file name="Other.php" hash="df8672bc7a5383a6a985703ece13041d"/><dir name="Time"><file name="Collection.php" hash="ee5e6e59deed414768205cc695b4cda3"/></dir><file name="Time.php" hash="2fc0d74b96cf8b7fe38593d9bdaf1a82"/></dir><dir name="Shipmentlocation"><file name="Collection.php" hash="c284bdadf29cf34160e7f8af189f5a43"/></dir><file name="Shipmentlocation.php" hash="99792ed958bffa3d333453888be4b1c4"/><dir name="Sync"><file name="Collection.php" hash="5b837d6fc0fde6c0a7ebef66132d7bcd"/></dir><file name="Sync.php" hash="a538626ff74fa096eb20c95ccf936794"/></dir><dir name="Sales"><dir name="Resource"><file name="Order.php" hash="f078ab890e8a294a75183bcbbb667f2e"/></dir></dir><dir name="Servicelevel"><file name="Other.php" hash="cf779fc0762b7e34974605256d941993"/><file name="Time.php" hash="60188779fd9cfb1e237fd915090acb53"/></dir><file name="Shipmentlocation.php" hash="38147d641e55c3b68a9cecd123081993"/><dir name="Shipping"><dir name="Carrier"><file name="Abstract.php" hash="65c5fc48da295a19c90153ac693c523f"/><file name="Delivery.php" hash="5c2faa12f798aea53343a657bd7c7010"/><file name="Pickup.php" hash="436630941a50a968cf54e929e25fd0c3"/></dir></dir><file name="Sync.php" hash="2343389f501ff24a846f2b4c6311a822"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Transsmart"><dir name="Shipping"><file name="LocationController.php" hash="9ed198c21dd4569cc604c19d6865a74b"/><file name="ShipmentController.php" hash="67e443bfcdc4afc3478dcf3bc80282e7"/></dir></dir><file name="TranssmartController.php" hash="b5b688249bce5a74bef95319674e5698"/></dir><file name="LocationController.php" hash="f39c3a08069cefc6169c9eed12a97f63"/></dir><dir name="etc"><file name="adminhtml.xml" hash="07f3353cf1d7275e528a18b9883b206f"/><file name="config.xml" hash="cda2f4323a1d812080821a57f9f8c9a6"/><file name="jstranslator.xml" hash="b50cf9cd74e37d6e34b3e360f3353313"/><file name="system.xml" hash="913acd885f5c4a1d33182f022720fe10"/></dir><dir name="sql"><dir name="transsmart_shipping_setup"><file name="install-1.0.0.php" hash="242d4b2aff6d23151dcca7c9cadab352"/></dir></dir><dir name="ssl"><file name="CARoot.crt" hash="f85d1ff17b0079709f131f3ce3f288d2"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="layout"><file name="transsmart_shipping.xml" hash="c0578eb781adc2df96e79fe776e387da"/></dir><dir name="template"><dir name="transsmart"><dir name="shipping"><dir name="location"><file name="info.phtml" hash="74ce67c6f39c308995a478279ca1e1bc"/><file name="selector.phtml" hash="841e1d59d042c2b53c622593150675c6"/></dir><dir name="sales"><dir name="order"><dir name="address"><dir name="form"><file name="container.phtml" hash="57a3f3de61e96127659dbf53952a0b33"/></dir></dir><dir name="shipment"><dir name="address"><dir name="form"><file name="container.phtml" hash="9763785687d9f4dfa03d6d1887a3f867"/></dir></dir><dir name="create"><file name="action.phtml" hash="164c1c632265816113e8eb172762871c"/><file name="detail.phtml" hash="c12734fe34fb4a526eb29075d2b80120"/><file name="package.phtml" hash="a39776c6e5f95112e10b9dbc9e29bd14"/></dir><dir name="masscreate"><file name="form.phtml" hash="5e2a281942e88379fa28698a85e519ec"/></dir><dir name="view"><file name="detail.phtml" hash="e901e78ba712f7e99b82409a07c9dedd"/><file name="package.phtml" hash="4ba3f81ed371d87542102974566cb522"/></dir></dir></dir></dir><dir name="system"><dir name="config"><dir name="form"><dir name="field"><file name="fetch.phtml" hash="bf8377c0df88e37305d0d39b5ad72101"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="transsmart_shipping.xml" hash="99c0e35e1ef97c0251485fee9b39297e"/></dir><dir name="template"><dir name="transsmart"><dir name="shipping"><dir name="location"><file name="selector.phtml" hash="25000d2769c4e282cdb07dbdc6cb1722"/></dir><dir name="onepage"><dir name="progress"><file name="pickup.phtml" hash="e3874f42cb1d4a9629069d50c39f338e"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Transsmart_Shipping.xml" hash="1f526fc89db267b44b7425e2ff645a68"/></dir></target><target name="magelocale"><dir><dir name="nl_NL"><file name="Transsmart_Shipping.csv" hash="759cb6f310ac469a52513c7eede0ce54"/></dir></dir></target><target name="mageweb"><dir name="js"><dir name="transsmart"><dir name="shipping"><dir name="admin"><file name="pickup_selector.js" hash="7da3ddbbd8e5e4adc4a134faaa7fee0b"/></dir><file name="base64.js" hash="795b1ac117d08652a3a43552c83332ac"/><file name="logger.js" hash="b852d48e077a6114ffe56bd647d1ea5c"/><file name="pickup_selector.js" hash="f01e4051c39218c8354a7f28ed1638ed"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="transsmart"><dir name="shipping"><dir name="images"><file name="arrow.png" hash="5b0966d990b40b3510cd2bb57081812d"/><file name="checkmark.png" hash="e5cf08c5943037b8ccc3a5449febdb7b"/><file name="close-btn.png" hash="975d2b3ee2879d4e4b812df8351ccf05"/><file name="info-icon.png" hash="a6baeffe65721d6995f8f06b1669a0ad"/><file name="loader.gif" hash="c5cd7f5300576ab4c88202b42f6ded62"/><file name="radio.png" hash="f149b9aa48f1c3a9da34173c40c882dc"/></dir><file name="pickup_selector.css" hash="9e4b6c280cfd0e2dc6d2d05714b94073"/><file name="styles.css" hash="d61eebd814903f153eb2210bf5f27c5f"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="transsmart"><dir name="shipping"><dir name="images"><file name="arrow.png" hash="5b0966d990b40b3510cd2bb57081812d"/><file name="close-btn.png" hash="975d2b3ee2879d4e4b812df8351ccf05"/><file name="info-icon.png" hash="a6baeffe65721d6995f8f06b1669a0ad"/><file name="loader.gif" hash="c5cd7f5300576ab4c88202b42f6ded62"/><file name="radio.png" hash="f149b9aa48f1c3a9da34173c40c882dc"/></dir><file name="pickup_selector.css" hash="9e4b6c280cfd0e2dc6d2d05714b94073"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.29</min><max>5.9.9</max></php><extension><name>curl</name><min/><max/></extension></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Transsmart_Shipping</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Transsmart Magento connector</summary>
10
  <description>Integrates Transsmart Shipping into Magento.</description>
11
+ <notes>1.0.2</notes>
12
  <authors><author><name>Techtwo Webdevelopment B.V.</name><user>techtwo</user><email>info@techtwo.nl</email></author><author><name>Bastiaan Heeren</name><user>techtwobastiaan</user><email>bastiaan@techtwo.nl</email></author></authors>
13
+ <date>2016-01-22</date>
14
+ <time>09:43:17</time>
15
+ <contents><target name="magecommunity"><dir name="Transsmart"><dir name="Shipping"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="bafce0b64ee9545b3a355df1b0b8e18d"/><dir name="Shipment"><dir name="Create"><file name="Detail.php" hash="b8b8b391b781f5d9de8b2578ad84d540"/><file name="Package.php" hash="7054391262f4bcc78d77bbd8d7131d61"/></dir><dir name="Masscreate"><file name="Form.php" hash="1bef6372fca204ba939fca5a02f3fa3d"/></dir><file name="Masscreate.php" hash="244adc0427800e5df7ea050947cff0d5"/><dir name="View"><file name="Detail.php" hash="0c5a780a5a4095164b02b06a5cd5ec16"/><file name="Package.php" hash="ccdda1fc1a9710ff1d317575fd53baa7"/></dir></dir><dir name="View"><dir name="Tab"><file name="Shipments.php" hash="e8b2006ed7c6541ea61c309123457c7c"/></dir></dir></dir><dir name="Shipment"><dir name="Grid"><dir name="Renderer"><file name="Link.php" hash="f42b111af0b6fa7dbdd171b9ef9f5655"/></dir></dir><file name="Grid.php" hash="931e2c538a9f61c62fc838d441419c48"/></dir></dir><dir name="Shipping"><dir name="Location"><file name="Info.php" hash="fa01c870d4a5cd521ed312a447f10dda"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Fetch.php" hash="43361767a4367c59fea55c23bb52aaed"/></dir><dir name="Fieldset"><dir name="Carrierprofile"><file name="Header.php" hash="01bda5320d4fcb5493f7fc2fd7ec01ac"/></dir><file name="Carrierprofile.php" hash="a75608f6b98458f1797d41d24a52030b"/><file name="Versioninfo.php" hash="84f740e55f0abc8fda7d95d26a638214"/></dir></dir></dir></dir></dir><dir name="Location"><file name="Selector.php" hash="f13d261827cb806fcc14c73058128653"/></dir></dir><dir name="Helper"><file name="Data.php" hash="32590b34298ed7ee39ebc011485e970e"/><file name="Location.php" hash="59dd6de96da501192e995f3688cba950"/><file name="Pickupaddress.php" hash="c71ad4ae7e2c4536a2d57c18d57b8919"/><file name="Shipment.php" hash="c2e09ac937b0187499a085ab75f4cc74"/></dir><dir name="Model"><file name="Abstract.php" hash="5b8973d5f3ce40cd641e9f16cdcd6620"/><dir name="Adminhtml"><file name="Observer.php" hash="3664f0727b0159ccdeff1cf256b5fccf"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Localized.php" hash="3f7ee8815b1f71168ba3fe2f2eb6389f"/></dir><dir name="Source"><dir name="Basedata"><file name="Abstract.php" hash="ac0c0632d16278357cc4128b3a5ef9a8"/><file name="Carrierprofile.php" hash="f01d6e81905f9481a8906253ccfc24e3"/><file name="Costcenter.php" hash="4dabd6942ab4e27e8c7e7032e3d01ca9"/><file name="Emailtype.php" hash="5d5d02c41970795f42e86ec4184a1072"/><file name="Incoterm.php" hash="8724e4b8bd9267fe843d62ffaa939b1e"/><file name="Packagetype.php" hash="6277448d89f3eeaae2dd15dd8a318af1"/><file name="Shipmentlocation.php" hash="f025e24746908e9c5aea82109f3b79fa"/></dir><file name="Environment.php" hash="4d011d8f728c3582022178da0c26ea66"/><dir name="Mapping"><file name="Attribute.php" hash="f2302357356f4c4b6f43cc63c408722a"/><file name="Street.php" hash="e42fa0ede4bc76876cf0c1f783189e87"/></dir><file name="Method.php" hash="672e247ef3764ff9294607102b152c78"/></dir></dir></dir></dir><file name="Carrier.php" hash="9aac846543c6b82cd3a06f9e307593ae"/><file name="Carrierprofile.php" hash="fb3bc266d34c00dbc10b76e89f6de20f"/><file name="Client.php" hash="9dbd3fc487adedecfc28d84eb7137842"/><file name="Costcenter.php" hash="bf6a9a5a95fa7cf1e0a609c6e0cf6365"/><file name="Emailtype.php" hash="b7128a27c6937c63f9a8ba14510dad13"/><file name="Incoterm.php" hash="8ebd437537680f375568f7873607ef87"/><file name="Observer.php" hash="e42f9c5c5a241e9ed8fef967fe194dee"/><file name="Packagetype.php" hash="d9f5012184c0e52429be7396e4081c69"/><dir name="Resource"><dir name="Carrier"><file name="Collection.php" hash="aabffe27624593ec59d489aaea12319c"/></dir><file name="Carrier.php" hash="57b812414155d31fe39977be1483ab1e"/><dir name="Carrierprofile"><file name="Collection.php" hash="59c40952ae124b257a30eebd72651df7"/></dir><file name="Carrierprofile.php" hash="53d9e49e8cf00b080f80489a476e43ef"/><dir name="Costcenter"><file name="Collection.php" hash="e338f05492a12988d3066bbc2f7569fe"/></dir><file name="Costcenter.php" hash="338db8721bcd09dabbece8e9c862ac92"/><dir name="Emailtype"><file name="Collection.php" hash="fe4ee29a8af109be50e7d928a8d5a9c3"/></dir><file name="Emailtype.php" hash="27b7d676aabf4e16891ccadee409aeba"/><dir name="Incoterm"><file name="Collection.php" hash="7490a144291e1b2a81f5c243173627e3"/></dir><file name="Incoterm.php" hash="5076d4828c71f71178d7d33213d2e735"/><dir name="Packagetype"><file name="Collection.php" hash="f20c13999570a2338feaf1f8af72c85b"/></dir><file name="Packagetype.php" hash="b8de7857c71a26be8915a67c38a1d347"/><dir name="Servicelevel"><dir name="Other"><file name="Collection.php" hash="c48542bc38fc957c97b90bcc2d0d0773"/></dir><file name="Other.php" hash="df8672bc7a5383a6a985703ece13041d"/><dir name="Time"><file name="Collection.php" hash="ee5e6e59deed414768205cc695b4cda3"/></dir><file name="Time.php" hash="2fc0d74b96cf8b7fe38593d9bdaf1a82"/></dir><dir name="Shipmentlocation"><file name="Collection.php" hash="c284bdadf29cf34160e7f8af189f5a43"/></dir><file name="Shipmentlocation.php" hash="99792ed958bffa3d333453888be4b1c4"/><dir name="Sync"><file name="Collection.php" hash="5b837d6fc0fde6c0a7ebef66132d7bcd"/></dir><file name="Sync.php" hash="a538626ff74fa096eb20c95ccf936794"/></dir><dir name="Sales"><dir name="Resource"><file name="Order.php" hash="f078ab890e8a294a75183bcbbb667f2e"/></dir></dir><dir name="Servicelevel"><file name="Other.php" hash="cf779fc0762b7e34974605256d941993"/><file name="Time.php" hash="60188779fd9cfb1e237fd915090acb53"/></dir><file name="Shipmentlocation.php" hash="38147d641e55c3b68a9cecd123081993"/><dir name="Shipping"><dir name="Carrier"><file name="Abstract.php" hash="65c5fc48da295a19c90153ac693c523f"/><file name="Delivery.php" hash="5c2faa12f798aea53343a657bd7c7010"/><file name="Pickup.php" hash="436630941a50a968cf54e929e25fd0c3"/></dir></dir><file name="Sync.php" hash="2343389f501ff24a846f2b4c6311a822"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Transsmart"><dir name="Shipping"><file name="LocationController.php" hash="9ed198c21dd4569cc604c19d6865a74b"/><file name="ShipmentController.php" hash="67e443bfcdc4afc3478dcf3bc80282e7"/></dir></dir><file name="TranssmartController.php" hash="b5b688249bce5a74bef95319674e5698"/></dir><file name="LocationController.php" hash="f39c3a08069cefc6169c9eed12a97f63"/></dir><dir name="etc"><file name="adminhtml.xml" hash="07f3353cf1d7275e528a18b9883b206f"/><file name="config.xml" hash="c321a512326bf2adb9b8dc54f13928f3"/><file name="jstranslator.xml" hash="b50cf9cd74e37d6e34b3e360f3353313"/><file name="system.xml" hash="913acd885f5c4a1d33182f022720fe10"/></dir><dir name="sql"><dir name="transsmart_shipping_setup"><file name="install-1.0.0.php" hash="242d4b2aff6d23151dcca7c9cadab352"/></dir></dir><dir name="ssl"><file name="CARoot.crt" hash="f85d1ff17b0079709f131f3ce3f288d2"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="layout"><file name="transsmart_shipping.xml" hash="c0578eb781adc2df96e79fe776e387da"/></dir><dir name="template"><dir name="transsmart"><dir name="shipping"><dir name="location"><file name="info.phtml" hash="74ce67c6f39c308995a478279ca1e1bc"/><file name="selector.phtml" hash="841e1d59d042c2b53c622593150675c6"/></dir><dir name="sales"><dir name="order"><dir name="address"><dir name="form"><file name="container.phtml" hash="57a3f3de61e96127659dbf53952a0b33"/></dir></dir><dir name="shipment"><dir name="address"><dir name="form"><file name="container.phtml" hash="9763785687d9f4dfa03d6d1887a3f867"/></dir></dir><dir name="create"><file name="action.phtml" hash="164c1c632265816113e8eb172762871c"/><file name="detail.phtml" hash="c12734fe34fb4a526eb29075d2b80120"/><file name="package.phtml" hash="a39776c6e5f95112e10b9dbc9e29bd14"/></dir><dir name="masscreate"><file name="form.phtml" hash="5e2a281942e88379fa28698a85e519ec"/></dir><dir name="view"><file name="detail.phtml" hash="e901e78ba712f7e99b82409a07c9dedd"/><file name="package.phtml" hash="4ba3f81ed371d87542102974566cb522"/></dir></dir></dir></dir><dir name="system"><dir name="config"><dir name="form"><dir name="field"><file name="fetch.phtml" hash="bf8377c0df88e37305d0d39b5ad72101"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="transsmart_shipping.xml" hash="99c0e35e1ef97c0251485fee9b39297e"/></dir><dir name="template"><dir name="transsmart"><dir name="shipping"><dir name="location"><file name="selector.phtml" hash="25000d2769c4e282cdb07dbdc6cb1722"/></dir><dir name="onepage"><dir name="progress"><file name="pickup.phtml" hash="e3874f42cb1d4a9629069d50c39f338e"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Transsmart_Shipping.xml" hash="1f526fc89db267b44b7425e2ff645a68"/></dir></target><target name="magelocale"><dir><dir name="nl_NL"><file name="Transsmart_Shipping.csv" hash="759cb6f310ac469a52513c7eede0ce54"/></dir></dir></target><target name="mageweb"><dir name="js"><dir name="transsmart"><dir name="shipping"><dir name="admin"><file name="pickup_selector.js" hash="7da3ddbbd8e5e4adc4a134faaa7fee0b"/></dir><file name="base64.js" hash="795b1ac117d08652a3a43552c83332ac"/><file name="logger.js" hash="b852d48e077a6114ffe56bd647d1ea5c"/><file name="pickup_selector.js" hash="f01e4051c39218c8354a7f28ed1638ed"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="transsmart"><dir name="shipping"><dir name="images"><file name="arrow.png" hash="5b0966d990b40b3510cd2bb57081812d"/><file name="checkmark.png" hash="e5cf08c5943037b8ccc3a5449febdb7b"/><file name="close-btn.png" hash="975d2b3ee2879d4e4b812df8351ccf05"/><file name="info-icon.png" hash="a6baeffe65721d6995f8f06b1669a0ad"/><file name="loader.gif" hash="c5cd7f5300576ab4c88202b42f6ded62"/><file name="radio.png" hash="f149b9aa48f1c3a9da34173c40c882dc"/></dir><file name="pickup_selector.css" hash="9e4b6c280cfd0e2dc6d2d05714b94073"/><file name="styles.css" hash="d61eebd814903f153eb2210bf5f27c5f"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="transsmart"><dir name="shipping"><dir name="images"><file name="arrow.png" hash="5b0966d990b40b3510cd2bb57081812d"/><file name="close-btn.png" hash="975d2b3ee2879d4e4b812df8351ccf05"/><file name="info-icon.png" hash="a6baeffe65721d6995f8f06b1669a0ad"/><file name="loader.gif" hash="c5cd7f5300576ab4c88202b42f6ded62"/><file name="radio.png" hash="f149b9aa48f1c3a9da34173c40c882dc"/></dir><file name="pickup_selector.css" hash="9e4b6c280cfd0e2dc6d2d05714b94073"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.29</min><max>5.9.9</max></php><extension><name>curl</name><min/><max/></extension></required></dependencies>
18
  </package>