Magmodules_Fadello - Version 1.0.3

Version Notes

Fadello

Download this release

Release Info

Developer Magmodules
Extension Magmodules_Fadello
Version 1.0.3
Comparing to
See all releases


Code changes from version 1.0.2 to 1.0.3

app/code/community/Magmodules/Fadello/Block/Adminhtml/Renderer/Shipment.php CHANGED
@@ -29,7 +29,7 @@ class Magmodules_Fadello_Block_Adminhtml_Renderer_Shipment
29
  */
30
  public function render(Varien_Object $row)
31
  {
32
- $html = '';
33
 
34
  $orderId = $row->getEntityId();
35
  $status = $row->getFadelloStatus();
@@ -56,11 +56,16 @@ class Magmodules_Fadello_Block_Adminhtml_Renderer_Shipment
56
  $sMsg = $this->__('Ship This Order');
57
  $sImg = $this->getSkinUrl('images/fadello/export.png');
58
 
59
- // Ship Order
60
- $csUrl = $this->getUrl('*/fadello/createShipment', array('order_id' => $orderId));
61
- $csMsg = $this->__('Create Shipmentr');
62
  $csImg = $this->getSkinUrl('images/fadello/ship.png');
63
 
 
 
 
 
 
64
  if (!empty($status)) {
65
  if ($status == 'created') {
66
  $html .= '<a href="' . $cUrl . '"><img title="' . $cMsg . '" src="' . $cImg . '"></a>';
@@ -77,8 +82,23 @@ class Magmodules_Fadello_Block_Adminhtml_Renderer_Shipment
77
  }
78
  } else {
79
  $html .= '<a href="' . $csUrl . '"><img title="' . $csMsg . '" src="' . $csImg . '"></a>';
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
 
 
 
82
  return $html;
83
  }
84
 
29
  */
30
  public function render(Varien_Object $row)
31
  {
32
+ $html = '<div class="fadello-order-grid">';
33
 
34
  $orderId = $row->getEntityId();
35
  $status = $row->getFadelloStatus();
56
  $sMsg = $this->__('Ship This Order');
57
  $sImg = $this->getSkinUrl('images/fadello/export.png');
58
 
59
+ // Create Shipment
60
+ $csUrl = $this->getUrl('*/fadello/createShipment', array('order_id' => $orderId, 'colli' => 1));
61
+ $csMsg = $this->__('Create Shipment');
62
  $csImg = $this->getSkinUrl('images/fadello/ship.png');
63
 
64
+ // Create Multi Shipment
65
+ $csmUrl = $this->getUrl('*/fadello/createShipment', array('order_id' => $orderId));
66
+ $csmMsg = $this->__('Create Multi Colli');
67
+ $csmImg = $this->getSkinUrl('images/fadello/ship-mc.png');
68
+
69
  if (!empty($status)) {
70
  if ($status == 'created') {
71
  $html .= '<a href="' . $cUrl . '"><img title="' . $cMsg . '" src="' . $cImg . '"></a>';
82
  }
83
  } else {
84
  $html .= '<a href="' . $csUrl . '"><img title="' . $csMsg . '" src="' . $csImg . '"></a>';
85
+ $html .= '<form method="post" action="' . $csmUrl . '">
86
+ <input type="hidden" name="form_key" value="' . Mage::getSingleton('core/session')->getFormKey() .'">
87
+ <img title="' . $csmMsg . '" src="' . $csmImg . '" onclick="showColli(\'' . $orderId . '\')">
88
+ <select id="colli-' . $orderId . '" name="colli" onchange="this.form.submit()" class="colli-count">
89
+ <option value=""></option>
90
+ <option value="1">1</option>
91
+ <option value="2">2</option>
92
+ <option value="3">3</option>
93
+ <option value="4">4</option>
94
+ <option value="5">5</option>
95
+ <option value="6">6</option>
96
+ </select>
97
+ </form>';
98
  }
99
 
100
+ $html .= '</div>';
101
+
102
  return $html;
103
  }
104
 
app/code/community/Magmodules/Fadello/Block/Adminhtml/System/Config/Form/Field/Datetime.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magmodules.eu - http://www.magmodules.eu
4
+ *
5
+ * NOTICE OF LICENSE
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to info@magmodules.eu so we can send you a copy immediately.
13
+ *
14
+ * @category Magmodules
15
+ * @package Magmodules_Fadello
16
+ * @author Magmodules <info@magmodules.eu>
17
+ * @copyright Copyright (c) 2017 (http://www.magmodules.eu)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Magmodules_Fadello_Block_Adminhtml_System_Config_Form_Field_Datetime
22
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
23
+ {
24
+
25
+ /**
26
+ * @param Varien_Data_Form_Element_Abstract $element
27
+ *
28
+ * @return mixed
29
+ */
30
+ public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
31
+ {
32
+ return Mage::getModel('core/date')->date('Y-m-d H:i:s');
33
+ }
34
+
35
+ }
app/code/community/Magmodules/Fadello/Helper/Data.php CHANGED
@@ -31,7 +31,7 @@ class Magmodules_Fadello_Helper_Data extends Mage_Core_Helper_Abstract
31
  {
32
  $api = array();
33
 
34
- $afterCutoff = Mage::getStoreConfig('shipping/fadello/pu_name', $storeId);
35
  $cutoff = str_replace(' ', '', Mage::getStoreConfig('shipping/fadello/cutoff_time', $storeId));
36
  $date = $this->getDate($afterCutoff, $cutoff);
37
 
@@ -46,6 +46,7 @@ class Magmodules_Fadello_Helper_Data extends Mage_Core_Helper_Abstract
46
  $api['url'] = 'https://api.fadello.nl/desktopmodules/fadello_retailAPI/API/v1/';
47
  $api['ship_type'] = 'DC';
48
  $api['label'] = 'PDF';
 
49
  if ($detailed) {
50
  $api['pu_name'] = Mage::getStoreConfig('shipping/fadello/pu_name', $storeId);
51
  $api['pu_street'] = Mage::getStoreConfig('shipping/fadello/pu_street', $storeId);
@@ -69,6 +70,27 @@ class Magmodules_Fadello_Helper_Data extends Mage_Core_Helper_Abstract
69
  return false;
70
  }
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  /**
73
  * @return bool
74
  */
@@ -92,27 +114,6 @@ class Magmodules_Fadello_Helper_Data extends Mage_Core_Helper_Abstract
92
  return false;
93
  }
94
 
95
- /**
96
- * @param int $afterCutoff
97
- * @param $cutoff
98
- *
99
- * @return mixed
100
- */
101
- public function getDate($afterCutoff = 0, $cutoff)
102
- {
103
- $today = Mage::getModel('core/date')->date('d-m-Y');
104
- $tomorrow = Mage::getModel('core/date')->date("d-m-Y", time() + 86400);
105
- if ($afterCutoff) {
106
- $time = Mage::getModel('core/date')->date('Hi');
107
- $cutoff = (str_replace(':', '', $cutoff) + 100);
108
- if ($time > $cutoff) {
109
- return $tomorrow;
110
- }
111
- }
112
-
113
- return $today;
114
- }
115
-
116
  /**
117
  * @param $postcode
118
  *
@@ -156,4 +157,18 @@ class Magmodules_Fadello_Helper_Data extends Mage_Core_Helper_Abstract
156
  }
157
  }
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  }
31
  {
32
  $api = array();
33
 
34
+ $afterCutoff = Mage::getStoreConfig('shipping/fadello/after_cutoff', $storeId);
35
  $cutoff = str_replace(' ', '', Mage::getStoreConfig('shipping/fadello/cutoff_time', $storeId));
36
  $date = $this->getDate($afterCutoff, $cutoff);
37
 
46
  $api['url'] = 'https://api.fadello.nl/desktopmodules/fadello_retailAPI/API/v1/';
47
  $api['ship_type'] = 'DC';
48
  $api['label'] = 'PDF';
49
+
50
  if ($detailed) {
51
  $api['pu_name'] = Mage::getStoreConfig('shipping/fadello/pu_name', $storeId);
52
  $api['pu_street'] = Mage::getStoreConfig('shipping/fadello/pu_street', $storeId);
70
  return false;
71
  }
72
 
73
+ /**
74
+ * @param int $afterCutoff
75
+ * @param $cutoff
76
+ *
77
+ * @return mixed
78
+ */
79
+ public function getDate($afterCutoff = 0, $cutoff)
80
+ {
81
+ $today = Mage::getModel('core/date')->date('d-m-Y');
82
+ $tomorrow = Mage::getModel('core/date')->date("d-m-Y", time() + 86400);
83
+ if ($afterCutoff) {
84
+ $time = Mage::getModel('core/date')->date('Hi');
85
+ $cutoff = (str_replace(':', '', $cutoff) + 100);
86
+ if ($time > $cutoff) {
87
+ return $tomorrow;
88
+ }
89
+ }
90
+
91
+ return $today;
92
+ }
93
+
94
  /**
95
  * @return bool
96
  */
114
  return false;
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  /**
118
  * @param $postcode
119
  *
157
  }
158
  }
159
 
160
+ /**
161
+ * @param $data
162
+ */
163
+ public function addToLog($data)
164
+ {
165
+ if (Mage::getStoreConfig('shipping/fadello/debug')) {
166
+ if (is_array($data)) {
167
+ Mage::log(json_encode($data), null, 'fadello.log', false);
168
+ } else {
169
+ Mage::log($data, null, 'fadello.log', false);
170
+ }
171
+ }
172
+ }
173
+
174
  }
app/code/community/Magmodules/Fadello/Model/Api.php CHANGED
@@ -26,7 +26,7 @@ class Magmodules_Fadello_Model_Api extends Mage_Core_Helper_Abstract
26
  *
27
  * @return array
28
  */
29
- public function createShipment($orderId)
30
  {
31
  $result = array();
32
  $order = Mage::getModel('sales/order')->load($orderId);
@@ -45,7 +45,8 @@ class Magmodules_Fadello_Model_Api extends Mage_Core_Helper_Abstract
45
  return $result;
46
  }
47
 
48
- $post = json_encode($this->getPostOrderArray($config, $order));
 
49
 
50
  $request = curl_init();
51
  $requestUrl = $config['url'] . 'postOrder?' . $config['url_params'];
@@ -57,6 +58,7 @@ class Magmodules_Fadello_Model_Api extends Mage_Core_Helper_Abstract
57
  curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
58
  $content = curl_exec($request);
59
  $apiResult = json_decode($content, true);
 
60
 
61
  if (!empty($apiResult['Status'])) {
62
  if ($apiResult['Status'] == 'OK') {
@@ -69,6 +71,7 @@ class Magmodules_Fadello_Model_Api extends Mage_Core_Helper_Abstract
69
  ->setFadelloDeliverId($deliverId)
70
  ->setFadelloBarcode($barcode)
71
  ->setFadelloStatus($status)
 
72
  ->save();
73
 
74
  $url = Mage::helper("adminhtml")->getUrl('*/fadello/getPdf', array('order_id' => $orderId));
@@ -256,7 +259,7 @@ class Magmodules_Fadello_Model_Api extends Mage_Core_Helper_Abstract
256
  $shipments = $order->getShipmentsCollection();
257
  if (count($shipments)) {
258
  $result['status'] = 'Error';
259
- $result['error_msg'] = $this->__('Order %s allready shipped', $order->getInrementId());
260
  return $result;
261
  }
262
 
@@ -280,22 +283,23 @@ class Magmodules_Fadello_Model_Api extends Mage_Core_Helper_Abstract
280
 
281
  $order->setData('state', "complete")->setStatus("complete")->setFadelloStatus('shipped')->save();
282
  $result['status'] = 'Success';
283
- $result['success_msg'] = $this->__('Order %s shipped and completed', $order->getInrementId());
284
  return $result;
285
  }
286
 
287
  /**
288
- * @param $config
289
- * @param $order
 
290
  *
291
  * @return array
292
  */
293
- public function getPostOrderArray($config, $order)
294
  {
295
  $post = array();
296
  $post['Name'] = $config['pu_name'];
297
  $post['Phone'] = $config['pu_phone'];
298
- $post['YourRef'] = $order->getIncrementId() . time();
299
  $post['Note'] = '';
300
  $post['Email'] = $config['pu_email'];
301
  $post['ShipType'] = $config['ship_type'];
@@ -311,17 +315,18 @@ class Magmodules_Fadello_Model_Api extends Mage_Core_Helper_Abstract
311
  $post['PUdate'] = $config['pu_date'];
312
  $post['PUtime'] = $config['pickup_time'];
313
  $post['PUnote'] = '';
314
- $post['Deliver'][] = $this->getDeliveryData($config, $order);
315
  return $post;
316
  }
317
 
318
  /**
319
  * @param $config
320
  * @param $order
 
321
  *
322
  * @return array
323
  */
324
- public function getDeliveryData($config, $order)
325
  {
326
  $delivery = array();
327
  $shippingAddress = $order->getShippingAddress();
@@ -338,7 +343,7 @@ class Magmodules_Fadello_Model_Api extends Mage_Core_Helper_Abstract
338
  $delivery['DELemail'] = $order->getCustomerEmail();
339
  $delivery['DELdate'] = $config['del_date'];
340
  $delivery['DELtime'] = $config['del_time'];
341
- $delivery['DELAaantalColli'] = 1;
342
  $delivery['DELbarcodes'] = '';
343
  $delivery['CreateLabel'] = 'True';
344
  $delivery['DELnote'] = '';
26
  *
27
  * @return array
28
  */
29
+ public function createShipment($orderId, $colli)
30
  {
31
  $result = array();
32
  $order = Mage::getModel('sales/order')->load($orderId);
45
  return $result;
46
  }
47
 
48
+ $post = json_encode($this->getPostOrderArray($config, $order, $colli));
49
+ Mage::helper('fadello')->addToLog($post);
50
 
51
  $request = curl_init();
52
  $requestUrl = $config['url'] . 'postOrder?' . $config['url_params'];
58
  curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
59
  $content = curl_exec($request);
60
  $apiResult = json_decode($content, true);
61
+ Mage::helper('fadello')->addToLog($apiResult);
62
 
63
  if (!empty($apiResult['Status'])) {
64
  if ($apiResult['Status'] == 'OK') {
71
  ->setFadelloDeliverId($deliverId)
72
  ->setFadelloBarcode($barcode)
73
  ->setFadelloStatus($status)
74
+ ->setFadelloColli($colli)
75
  ->save();
76
 
77
  $url = Mage::helper("adminhtml")->getUrl('*/fadello/getPdf', array('order_id' => $orderId));
259
  $shipments = $order->getShipmentsCollection();
260
  if (count($shipments)) {
261
  $result['status'] = 'Error';
262
+ $result['error_msg'] = $this->__('Order %s allready shipped', $order->getIncrementId());
263
  return $result;
264
  }
265
 
283
 
284
  $order->setData('state', "complete")->setStatus("complete")->setFadelloStatus('shipped')->save();
285
  $result['status'] = 'Success';
286
+ $result['success_msg'] = $this->__('Order %s shipped and completed', $order->getIncrementId());
287
  return $result;
288
  }
289
 
290
  /**
291
+ * @param $config
292
+ * @param $order
293
+ * @param int $colli
294
  *
295
  * @return array
296
  */
297
+ public function getPostOrderArray($config, $order, $colli = 1)
298
  {
299
  $post = array();
300
  $post['Name'] = $config['pu_name'];
301
  $post['Phone'] = $config['pu_phone'];
302
+ $post['YourRef'] = $order->getIncrementId();
303
  $post['Note'] = '';
304
  $post['Email'] = $config['pu_email'];
305
  $post['ShipType'] = $config['ship_type'];
315
  $post['PUdate'] = $config['pu_date'];
316
  $post['PUtime'] = $config['pickup_time'];
317
  $post['PUnote'] = '';
318
+ $post['Deliver'][] = $this->getDeliveryData($config, $order, $colli);
319
  return $post;
320
  }
321
 
322
  /**
323
  * @param $config
324
  * @param $order
325
+ * @param $colli
326
  *
327
  * @return array
328
  */
329
+ public function getDeliveryData($config, $order, $colli)
330
  {
331
  $delivery = array();
332
  $shippingAddress = $order->getShippingAddress();
343
  $delivery['DELemail'] = $order->getCustomerEmail();
344
  $delivery['DELdate'] = $config['del_date'];
345
  $delivery['DELtime'] = $config['del_time'];
346
+ $delivery['DELAaantalColli'] = $colli;
347
  $delivery['DELbarcodes'] = '';
348
  $delivery['CreateLabel'] = 'True';
349
  $delivery['DELnote'] = '';
app/code/community/Magmodules/Fadello/Model/Carrier/ShippingMethod.php CHANGED
@@ -75,11 +75,9 @@ class Magmodules_Fadello_Model_Carrier_ShippingMethod extends Mage_Shipping_Mode
75
  }
76
 
77
  if ($this->getConfigData('stock_check')) {
78
-
79
  $configManageStock = (int) Mage::getStoreConfigFlag(self::XML_PATH_MANAGE_STOCK);
80
 
81
  foreach ($request->getAllItems() as $item) {
82
-
83
  if ($item->getProduct()->isVirtual()) {
84
  continue;
85
  }
@@ -126,7 +124,6 @@ class Magmodules_Fadello_Model_Carrier_ShippingMethod extends Mage_Shipping_Mode
126
  }
127
  }
128
  }
129
-
130
  }
131
 
132
  $prices = @unserialize($this->getConfigData('shipping_price'));
@@ -144,7 +141,6 @@ class Magmodules_Fadello_Model_Carrier_ShippingMethod extends Mage_Shipping_Mode
144
  $result = Mage::getModel('shipping/rate_result');
145
 
146
  if (empty($error)) {
147
-
148
  $method->setCarrier('fadello');
149
  $method->setCarrierTitle($name);
150
  $method->setMethod('fadello');
@@ -152,20 +148,61 @@ class Magmodules_Fadello_Model_Carrier_ShippingMethod extends Mage_Shipping_Mode
152
  $method->setPrice($shippingCost);
153
  $method->setCost('0.00');
154
  $result->append($method);
155
-
156
  } else {
157
-
158
  $error = Mage::getModel('shipping/rate_result_error');
159
  $method->setCarrier('fadello');
160
  $method->setCarrierTitle($name);
161
  $error->setErrorMessage($this->getConfigData('specificerrmsg'));
162
  $result->append($error);
163
-
164
  }
165
 
166
  return $result;
167
  }
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  /**
170
  * @return array
171
  */
75
  }
76
 
77
  if ($this->getConfigData('stock_check')) {
 
78
  $configManageStock = (int) Mage::getStoreConfigFlag(self::XML_PATH_MANAGE_STOCK);
79
 
80
  foreach ($request->getAllItems() as $item) {
 
81
  if ($item->getProduct()->isVirtual()) {
82
  continue;
83
  }
124
  }
125
  }
126
  }
 
127
  }
128
 
129
  $prices = @unserialize($this->getConfigData('shipping_price'));
141
  $result = Mage::getModel('shipping/rate_result');
142
 
143
  if (empty($error)) {
 
144
  $method->setCarrier('fadello');
145
  $method->setCarrierTitle($name);
146
  $method->setMethod('fadello');
148
  $method->setPrice($shippingCost);
149
  $method->setCost('0.00');
150
  $result->append($method);
 
151
  } else {
 
152
  $error = Mage::getModel('shipping/rate_result_error');
153
  $method->setCarrier('fadello');
154
  $method->setCarrierTitle($name);
155
  $error->setErrorMessage($this->getConfigData('specificerrmsg'));
156
  $result->append($error);
 
157
  }
158
 
159
  return $result;
160
  }
161
 
162
+ /**
163
+ * @return bool
164
+ */
165
+ public function isTrackingAvailable()
166
+ {
167
+ return true;
168
+ }
169
+
170
+ /**
171
+ * @param $trackingNumber
172
+ *
173
+ * @return bool|mixed
174
+ */
175
+ public function getTrackingInfo($trackingNumber)
176
+ {
177
+ $trackingResult = $this->getTracking($trackingNumber);
178
+
179
+ if ($trackingResult instanceof Mage_Shipping_Model_Tracking_Result) {
180
+ $trackings = $trackingResult->getAllTrackings();
181
+ if (is_array($trackings) && count($trackings) > 0) {
182
+ return $trackings[0];
183
+ }
184
+ }
185
+
186
+ return false;
187
+ }
188
+
189
+ /**
190
+ * @param $trackingNumber
191
+ *
192
+ * @return false|Mage_Core_Model_Abstract
193
+ */
194
+ public function getTracking($trackingNumber)
195
+ {
196
+ $trackingResult = Mage::getModel('shipping/tracking_result');
197
+ $trackingStatus = Mage::getModel('shipping/tracking_result_status');
198
+ $trackingStatus->setCarrier($this->_code);
199
+ $trackingStatus->setCarrierTitle($this->getConfigData('title'));
200
+ $trackingStatus->setTracking($trackingNumber);
201
+ $trackingResult->append($trackingStatus);
202
+
203
+ return $trackingResult;
204
+ }
205
+
206
  /**
207
  * @return array
208
  */
app/code/community/Magmodules/Fadello/controllers/Adminhtml/FadelloController.php CHANGED
@@ -26,9 +26,11 @@ class Magmodules_Fadello_Adminhtml_FadelloController extends Mage_Adminhtml_Cont
26
  */
27
  public function createShipmentAction()
28
  {
 
29
  $orderId = $this->getRequest()->getParam('order_id');
30
  if ($orderId > 0) {
31
- $result = Mage::getModel('fadello/api')->createShipment($orderId);
 
32
  if (!empty($result['success_msg'])) {
33
  Mage::getSingleton('core/session')->addSuccess($result['success_msg']);
34
  }
@@ -97,14 +99,39 @@ class Magmodules_Fadello_Adminhtml_FadelloController extends Mage_Adminhtml_Cont
97
  public function getPdfAction()
98
  {
99
  $orderId = $this->getRequest()->getParam('order_id');
 
 
100
  if ($orderId > 0) {
101
  $result = Mage::getModel('fadello/api')->getPdf($orderId);
102
  if (!empty($result['label_url']) && !empty($result['file_name'])) {
103
- header('Content-Type: application/pdf');
104
- header('Content-Disposition: attachment; filename=' . $result['file_name']);
105
- header('Pragma: no-cache');
106
- readfile($result['label_url']);
107
- exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  } else {
109
  if (!empty($result['error_msg'])) {
110
  Mage::getSingleton('core/session')->addError($result['error_msg']);
26
  */
27
  public function createShipmentAction()
28
  {
29
+
30
  $orderId = $this->getRequest()->getParam('order_id');
31
  if ($orderId > 0) {
32
+ $colli = $this->getRequest()->getParam('colli');
33
+ $result = Mage::getModel('fadello/api')->createShipment($orderId, $colli);
34
  if (!empty($result['success_msg'])) {
35
  Mage::getSingleton('core/session')->addSuccess($result['success_msg']);
36
  }
99
  public function getPdfAction()
100
  {
101
  $orderId = $this->getRequest()->getParam('order_id');
102
+ $download = $this->getRequest()->getParam('download', 0);
103
+
104
  if ($orderId > 0) {
105
  $result = Mage::getModel('fadello/api')->getPdf($orderId);
106
  if (!empty($result['label_url']) && !empty($result['file_name'])) {
107
+ $label = $result['label_url'];
108
+ if (strpos($label, ',') !== false) {
109
+ $colli = 1;
110
+ $labels = explode(',', $label);
111
+ $labelLinks = array();
112
+ foreach ($labels as $label) {
113
+ $url = $this->getUrl('*/fadello/getPdf', array('order_id' => $orderId, 'download' => $colli));
114
+ $labelLinks[] = '<a href="' . $url . '">Label ' . $colli . '</a>';
115
+ if ($download == $colli) {
116
+ $filename = 'Fadello-' . $result['increment_id'] . '-L' . $colli . '.pdf';
117
+ header('Content-Type: application/pdf');
118
+ header('Content-Disposition: attachment; filename=' . $filename);
119
+ header('Pragma: no-cache');
120
+ readfile($label);
121
+ exit;
122
+ }
123
+
124
+ $colli++;
125
+ }
126
+
127
+ Mage::getSingleton('core/session')->addSuccess('Download: ' . implode(', ', $labelLinks));
128
+ } else {
129
+ header('Content-Type: application/pdf');
130
+ header('Content-Disposition: attachment; filename=' . $result['file_name']);
131
+ header('Pragma: no-cache');
132
+ readfile($result['label_url']);
133
+ exit;
134
+ }
135
  } else {
136
  if (!empty($result['error_msg'])) {
137
  Mage::getSingleton('core/session')->addError($result['error_msg']);
app/code/community/Magmodules/Fadello/etc/config.xml CHANGED
@@ -21,7 +21,7 @@
21
  <config>
22
  <modules>
23
  <Magmodules_Fadello>
24
- <version>1.0.2</version>
25
  </Magmodules_Fadello>
26
  </modules>
27
  <global>
@@ -81,6 +81,13 @@
81
  </observers>
82
  </core_block_abstract_prepare_layout_before>
83
  </events>
 
 
 
 
 
 
 
84
  </adminhtml>
85
  <admin>
86
  <routers>
@@ -112,6 +119,7 @@
112
  <show_all_shipments>0</show_all_shipments>
113
  <after_cutoff>0</after_cutoff>
114
  <seperate_homenumber>0</seperate_homenumber>
 
115
  </fadello>
116
  </shipping>
117
  <carriers>
21
  <config>
22
  <modules>
23
  <Magmodules_Fadello>
24
+ <version>1.0.3</version>
25
  </Magmodules_Fadello>
26
  </modules>
27
  <global>
81
  </observers>
82
  </core_block_abstract_prepare_layout_before>
83
  </events>
84
+ <layout>
85
+ <updates>
86
+ <magmodules_fadello>
87
+ <file>magmodules_fadello.xml</file>
88
+ </magmodules_fadello>
89
+ </updates>
90
+ </layout>
91
  </adminhtml>
92
  <admin>
93
  <routers>
119
  <show_all_shipments>0</show_all_shipments>
120
  <after_cutoff>0</after_cutoff>
121
  <seperate_homenumber>0</seperate_homenumber>
122
+ <debug>0</debug>
123
  </fadello>
124
  </shipping>
125
  <carriers>
app/code/community/Magmodules/Fadello/etc/system.xml CHANGED
@@ -51,7 +51,6 @@
51
  <show_in_website>1</show_in_website>
52
  <show_in_store>1</show_in_store>
53
  </about_note>
54
-
55
  <extension_heading translate="label">
56
  <label>General Settings</label>
57
  <frontend_model>fadello/adminhtml_system_config_form_field_heading</frontend_model>
@@ -280,6 +279,24 @@
280
  <show_in_store>0</show_in_store>
281
  <tooltip>Enable this function to create shipments in depend of the selected shipment carrier.</tooltip>
282
  </show_all_shipments>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  </fields>
284
  </fadello>
285
  </groups>
51
  <show_in_website>1</show_in_website>
52
  <show_in_store>1</show_in_store>
53
  </about_note>
 
54
  <extension_heading translate="label">
55
  <label>General Settings</label>
56
  <frontend_model>fadello/adminhtml_system_config_form_field_heading</frontend_model>
279
  <show_in_store>0</show_in_store>
280
  <tooltip>Enable this function to create shipments in depend of the selected shipment carrier.</tooltip>
281
  </show_all_shipments>
282
+ <debug translate="label">
283
+ <label>Debug API calls</label>
284
+ <frontend_type>select</frontend_type>
285
+ <source_model>adminhtml/system_config_source_yesno</source_model>
286
+ <sort_order>64</sort_order>
287
+ <show_in_default>1</show_in_default>
288
+ <show_in_website>0</show_in_website>
289
+ <show_in_store>0</show_in_store>
290
+ <comment>Log API calls to var/log/fadello.log</comment>
291
+ </debug>
292
+ <magento_datetime translate="label">
293
+ <label>Magento Date &amp; Time</label>
294
+ <frontend_model>fadello/adminhtml_system_config_form_field_datetime</frontend_model>
295
+ <sort_order>65</sort_order>
296
+ <show_in_default>1</show_in_default>
297
+ <show_in_website>0</show_in_website>
298
+ <show_in_store>0</show_in_store>
299
+ </magento_datetime>
300
  </fields>
301
  </fadello>
302
  </groups>
app/code/community/Magmodules/Fadello/sql/fadello_setup/mysql4-upgrade-1.0.2-1.0.3.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magmodules.eu - http://www.magmodules.eu
4
+ *
5
+ * NOTICE OF LICENSE
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to info@magmodules.eu so we can send you a copy immediately.
13
+ *
14
+ * @category Magmodules
15
+ * @package Magmodules_Fadello
16
+ * @author Magmodules <info@magmodules.eu>
17
+ * @copyright Copyright (c) 2017 (http://www.magmodules.eu)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ $installer = new Mage_Sales_Model_Mysql4_Setup('core_setup');
22
+ $installer->startSetup();
23
+
24
+ $installer->addAttribute(
25
+ 'order', 'fadello_colli', array(
26
+ 'type' => 'int',
27
+ 'default' => 1,
28
+ 'label' => 'Fadello: Colli',
29
+ 'visible' => false,
30
+ 'required' => false,
31
+ 'visible_on_front' => false,
32
+ 'user_defined' => false,
33
+ )
34
+ );
35
+
36
+ $installer->getConnection()->addColumn(
37
+ $this->getTable('sales/order_grid'), 'fadello_colli',
38
+ 'int(1) default 1'
39
+ );
40
+ $installer->endSetup();
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Magmodules_Fadello</name>
4
- <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.magmodules.eu/license-agreement/">Single Server License</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Fadello</description>
11
  <notes>Fadello</notes>
12
  <authors><author><name>Magmodules</name><user>magmodules</user><email>info@magmodules.nl</email></author></authors>
13
- <date>2017-01-31</date>
14
- <time>10:06:40</time>
15
- <contents><target name="magecommunity"><dir name="Magmodules"><dir name="Fadello"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Availability.php" hash="64913b7814babacd1ca98be1f7b471df"/><file name="Shipping.php" hash="e3b5fbe95d7ba0c851ecdeb9af1a0828"/></dir><dir name="Renderer"><file name="Select.php" hash="0cec29d42fd9cd861947d81b77b5e8b8"/></dir></dir></dir><dir name="Renderer"><file name="Shipment.php" hash="e93d10328c8d0ac118cafd84b3bc9b65"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Heading.php" hash="bfd7dd907ddac09e81909a1a2922c9e0"/><file name="Note.php" hash="5a8bf11167605594868a392cc57c6579"/><file name="Version.php" hash="bb824bb532efc7446dc49f63e5fbc7be"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="eabc58ff518d33e6dce0d6dcf5391f4d"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Design"><file name="Availability.php" hash="416edf5e4a158fbd35157052289e41fb"/><file name="Shipping.php" hash="428c16b799df750709d6512cdded0884"/></dir></dir><dir name="Source"><file name="Days.php" hash="d2da23bd5162598137da002010c33272"/></dir></dir></dir></dir><file name="Api.php" hash="19dd3ee4b0418c2fae33e85b6a706f34"/><dir name="Carrier"><file name="ShippingMethod.php" hash="d1ab5b2bfdf59d17481e81c8ffd0f275"/></dir><file name="Observer.php" hash="afcb8e193677a8cd696d4db4013c1e69"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FadelloController.php" hash="b1ec6d48e97b82ac3e348bc9ec0a634b"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="c21568b2ecfbe36b0271e4e7fe37a0f3"/><file name="config.xml" hash="834a929a48159a6e55dc17c5da60d135"/><file name="system.xml" hash="7b7e83a214ca4ed3d82f5fa820078d0d"/></dir><dir name="sql"><dir name="fadello_setup"><file name="mysql4-install-0.9.0.php" hash="d51f8f1f961f798d1e7da372c02a4a32"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magmodules_Fadello.xml" hash="5565183cd8b0543c266a95077d90c622"/></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Magmodules_Fadello.csv" hash="396606fa364a8f170e15d6be1c408ebe"/></dir><dir name="nl_NL"><file name="Magmodules_Fadello.csv" hash="a99468173196eeeb79e2e9d6673d1fb1"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="fadello"><file name="close.png" hash="c057a83b891418703c155c9a1382f8b9"/><file name="export.png" hash="21cef3823db6739081aea971e5789fa9"/><file name="pdf.png" hash="8df694ac11eae7090ccad5062b415020"/><file name="ship.png" hash="05c70f071c5d3cfe6ffa86a1cd3561f7"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="magmodules"><dir name="fadello"><dir name="images"><file name="Fadello_logo3.png" hash="87130480e8187cf4c2fff28142440aa1"/></dir><file name="style.css" hash="ff9b3d7c2f1a166fee23007fc1ea7f4a"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="magmodules_fadello.xml" hash="569e347f70b4731daf77b6acc5a4488a"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Magmodules_Fadello</name>
4
+ <version>1.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.magmodules.eu/license-agreement/">Single Server License</license>
7
  <channel>community</channel>
10
  <description>Fadello</description>
11
  <notes>Fadello</notes>
12
  <authors><author><name>Magmodules</name><user>magmodules</user><email>info@magmodules.nl</email></author></authors>
13
+ <date>2017-04-14</date>
14
+ <time>12:14:56</time>
15
+ <contents><target name="magecommunity"><dir name="Magmodules"><dir name="Fadello"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Availability.php" hash="64913b7814babacd1ca98be1f7b471df"/><file name="Shipping.php" hash="e3b5fbe95d7ba0c851ecdeb9af1a0828"/></dir><dir name="Renderer"><file name="Select.php" hash="0cec29d42fd9cd861947d81b77b5e8b8"/></dir></dir></dir><dir name="Renderer"><file name="Shipment.php" hash="836b716e78bee03598dda5c475749669"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Datetime.php" hash="9ece732a223969d7560988b2b00b47a5"/><file name="Heading.php" hash="bfd7dd907ddac09e81909a1a2922c9e0"/><file name="Note.php" hash="5a8bf11167605594868a392cc57c6579"/><file name="Version.php" hash="bb824bb532efc7446dc49f63e5fbc7be"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="27e10b033696e2221127b6a49d09e8bc"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Design"><file name="Availability.php" hash="416edf5e4a158fbd35157052289e41fb"/><file name="Shipping.php" hash="428c16b799df750709d6512cdded0884"/></dir></dir><dir name="Source"><file name="Days.php" hash="d2da23bd5162598137da002010c33272"/></dir></dir></dir></dir><file name="Api.php" hash="3a677da9d1549bebcc764bf0ba9e27ea"/><dir name="Carrier"><file name="ShippingMethod.php" hash="5396c66e3506d615ddf7e5b8211a3289"/></dir><file name="Observer.php" hash="afcb8e193677a8cd696d4db4013c1e69"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FadelloController.php" hash="d9fed7e896b04c1864c66051071fa75f"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="c21568b2ecfbe36b0271e4e7fe37a0f3"/><file name="config.xml" hash="76370c3f3c55ecc667eda6f93f1e355e"/><file name="system.xml" hash="1f8b731c716137ab8e53692b312d4784"/></dir><dir name="sql"><dir name="fadello_setup"><file name="mysql4-install-0.9.0.php" hash="d51f8f1f961f798d1e7da372c02a4a32"/><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="896a3398d0130b90f48cf7b4d28f7074"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magmodules_Fadello.xml" hash="5565183cd8b0543c266a95077d90c622"/></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Magmodules_Fadello.csv" hash="396606fa364a8f170e15d6be1c408ebe"/></dir><dir name="nl_NL"><file name="Magmodules_Fadello.csv" hash="a99468173196eeeb79e2e9d6673d1fb1"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="fadello"><file name="close.png" hash="c057a83b891418703c155c9a1382f8b9"/><file name="export.png" hash="21cef3823db6739081aea971e5789fa9"/><file name="pdf.png" hash="8df694ac11eae7090ccad5062b415020"/><file name="ship-mc.png" hash="2d9815c51cd3b98c30e6c83a05ca29b5"/><file name="ship.png" hash="05c70f071c5d3cfe6ffa86a1cd3561f7"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="magmodules"><dir name="fadello"><dir name="images"><file name="Fadello_logo3.png" hash="87130480e8187cf4c2fff28142440aa1"/></dir><file name="style.css" hash="ff9b3d7c2f1a166fee23007fc1ea7f4a"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="magmodules_fadello.xml" hash="569e347f70b4731daf77b6acc5a4488a"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>7.9.9</max></php></required></dependencies>
18
  </package>
skin/adminhtml/default/default/images/fadello/ship-mc.png ADDED
Binary file