Version Notes
Official GLS Dispatch Extension
Download this release
Release Info
Developer | synergetic PHP Webdevelopment |
Extension | Official_GLS_Dispatch |
Version | 1.1.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.1.3
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid.php +82 -28
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Js.php +34 -0
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Error.php +45 -0
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Pdf.php +5 -5
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Qtyparcels.php +37 -0
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Qtyupdate.php +61 -0
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Job.php +39 -0
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Job/Grid.php +136 -0
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Job/Grid/Js.php +34 -0
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Job/Grid/Renderer/Action.php +48 -0
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Job/Grid/Renderer/Erroritems.php +50 -0
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Job/Grid/Renderer/Jobstatus.php +37 -0
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/Create/Gls.php +26 -91
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/Create/Gls/Packages.php +1 -6
- app/code/community/SynergeticAgency/Gls/Block/Adminhtml/System/Config/Note.php +1 -4
- app/code/community/SynergeticAgency/Gls/Exception.php +71 -0
- app/code/community/SynergeticAgency/Gls/Helper/Data.php +64 -0
- app/code/community/SynergeticAgency/Gls/Helper/Log.php +1 -1
- app/code/community/SynergeticAgency/Gls/Helper/Validate.php +138 -33
- app/code/community/SynergeticAgency/Gls/Model/Carrier.php +0 -1
- app/code/community/SynergeticAgency/Gls/Model/Country.php +15 -0
- app/code/community/SynergeticAgency/Gls/Model/Gls.php +175 -27
- app/code/community/SynergeticAgency/Gls/Model/Massprint.php +301 -0
- app/code/community/SynergeticAgency/Gls/Model/Observer.php +49 -5
- app/code/community/SynergeticAgency/Gls/Model/Resource/Service/Collection.php +1 -1
- app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Job.php +42 -0
- app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Job/Collection.php +42 -0
- app/code/community/SynergeticAgency/Gls/Model/Shipment.php +547 -5
- app/code/community/SynergeticAgency/Gls/Model/Shipment/Job.php +109 -0
- app/code/community/SynergeticAgency/Gls/Model/System/Config/Source/Weightunit.php +47 -0
- app/code/community/SynergeticAgency/Gls/controllers/Adminhtml/Gls/Shipment/JobController.php +130 -0
- app/code/community/SynergeticAgency/Gls/controllers/Adminhtml/Gls/ShipmentController.php +371 -516
- app/code/community/SynergeticAgency/Gls/data/synergeticagency_gls_setup/data-upgrade-1.0.0-1.1.0.php +91 -0
- app/code/community/SynergeticAgency/Gls/etc/adminhtml.xml +7 -0
- app/code/community/SynergeticAgency/Gls/etc/config.xml +27 -1
- app/code/community/SynergeticAgency/Gls/etc/system.xml +30 -0
- app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.1-0.1.2.php +0 -9
- app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-1.1.0-1.1.1.php +114 -0
- app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-1.1.1-1.1.2.php +38 -0
- app/design/adminhtml/base/default/layout/synergeticagency/gls.xml +16 -3
- app/design/adminhtml/base/default/template/gls/sales/order/shipment/create/gls/packages.phtml +2 -2
- app/design/adminhtml/base/default/template/gls/sales/order/shipment/view/gls.phtml +20 -4
- app/design/adminhtml/base/default/template/gls/shipment/grid/js.phtml +104 -0
- app/design/adminhtml/base/default/template/gls/shipment/job/grid/js.phtml +69 -0
- app/locale/de_DE/SynergeticAgency_Gls.csv +76 -2
- js/gls/admin.js +70 -0
- lib/SynergeticAgency/GlsConnector/Connector.php +20 -36
- lib/SynergeticAgency/GlsConnector/Log.php +1 -1
- lib/SynergeticAgency/GlsConnector/Model/Address.php +20 -20
- package.xml +4 -4
- var/tmp/gls/README.TXT +0 -0
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid.php
CHANGED
@@ -49,8 +49,8 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid extends Mage_
|
|
49 |
),
|
50 |
'main_table.shipment_id=shipment.entity_id',
|
51 |
array(
|
52 |
-
'shipment_increment_id'
|
53 |
-
'
|
54 |
)
|
55 |
)->joinLeft(
|
56 |
array(
|
@@ -58,10 +58,10 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid extends Mage_
|
|
58 |
),
|
59 |
'shipment.order_id=order.entity_id',
|
60 |
array(
|
61 |
-
'order_id'
|
62 |
-
'order_increment_id'
|
63 |
-
'
|
64 |
-
'order_date'
|
65 |
)
|
66 |
);
|
67 |
|
@@ -80,47 +80,101 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid extends Mage_
|
|
80 |
$helper = Mage::helper('synergeticagency_gls');
|
81 |
|
82 |
$this->addColumn('gls_shipment_id', array(
|
83 |
-
'header'
|
84 |
-
'index'
|
85 |
));
|
86 |
|
87 |
$this->addColumn('consignment_id', array(
|
88 |
-
'header'
|
89 |
-
'index'
|
90 |
));
|
91 |
|
92 |
$this->addColumn('order', array(
|
93 |
-
'header'
|
94 |
-
'align'
|
95 |
-
'index'
|
96 |
-
'renderer'
|
97 |
));
|
98 |
|
99 |
$this->addColumn('shipping_name', array(
|
100 |
-
'header'
|
101 |
-
'index'
|
|
|
102 |
));
|
103 |
|
104 |
$this->addColumn('shipment', array(
|
105 |
-
'header'
|
106 |
-
'align'
|
107 |
-
'index'
|
108 |
-
'
|
|
|
109 |
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
$this->addColumn('created_at', array(
|
111 |
-
'header'
|
112 |
-
'index'
|
113 |
-
'
|
|
|
114 |
));
|
115 |
|
116 |
$this->addColumn('pdf', array(
|
117 |
-
'header'
|
118 |
-
'align'
|
119 |
-
'renderer'
|
120 |
-
'filter'
|
121 |
-
'sortable'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
));
|
123 |
|
124 |
return parent::_prepareColumns();
|
125 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
49 |
),
|
50 |
'main_table.shipment_id=shipment.entity_id',
|
51 |
array(
|
52 |
+
'shipment_increment_id' => 'increment_id',
|
53 |
+
'shipping_date' => 'created_at'
|
54 |
)
|
55 |
)->joinLeft(
|
56 |
array(
|
58 |
),
|
59 |
'shipment.order_id=order.entity_id',
|
60 |
array(
|
61 |
+
'order_id' => 'entity_id',
|
62 |
+
'order_increment_id' => 'increment_id',
|
63 |
+
'order_shipping_name' => 'shipping_name',
|
64 |
+
'order_date' => 'created_at'
|
65 |
)
|
66 |
);
|
67 |
|
80 |
$helper = Mage::helper('synergeticagency_gls');
|
81 |
|
82 |
$this->addColumn('gls_shipment_id', array(
|
83 |
+
'header' => $helper->__('GLS Shipment ID'),
|
84 |
+
'index' => 'gls_shipment_id'
|
85 |
));
|
86 |
|
87 |
$this->addColumn('consignment_id', array(
|
88 |
+
'header' => $helper->__('GLS Consignment ID'),
|
89 |
+
'index' => 'consignment_id'
|
90 |
));
|
91 |
|
92 |
$this->addColumn('order', array(
|
93 |
+
'header' => Mage::helper('sales')->__('Order'),
|
94 |
+
'align' => 'left',
|
95 |
+
'index' => 'order_increment_id',
|
96 |
+
'renderer' => 'synergeticagency_gls/adminhtml_sales_gls_shipment_grid_renderer_order'
|
97 |
));
|
98 |
|
99 |
$this->addColumn('shipping_name', array(
|
100 |
+
'header' => Mage::helper('sales')->__('Ship to Name'),
|
101 |
+
'index' => 'order_shipping_name',
|
102 |
+
'filter_index' => 'order.shipping_name'
|
103 |
));
|
104 |
|
105 |
$this->addColumn('shipment', array(
|
106 |
+
'header' => Mage::helper('sales')->__('Shipments'),
|
107 |
+
'align' => 'left',
|
108 |
+
'index' => 'shipment_increment_id',
|
109 |
+
'filter_index' => 'shipment.increment_id',
|
110 |
+
'renderer' => 'synergeticagency_gls/adminhtml_sales_gls_shipment_grid_renderer_shipment',
|
111 |
));
|
112 |
+
|
113 |
+
$this->addColumn('error', array(
|
114 |
+
'header' => $helper->__('Error'),
|
115 |
+
'align' => 'left',
|
116 |
+
'index' => 'error_message',
|
117 |
+
'filter' => false,
|
118 |
+
'renderer' => 'synergeticagency_gls/adminhtml_sales_gls_shipment_grid_renderer_error',
|
119 |
+
));
|
120 |
+
|
121 |
$this->addColumn('created_at', array(
|
122 |
+
'header' => Mage::helper('sales')->__('Date Shipped'),
|
123 |
+
'index' => 'shipping_date',
|
124 |
+
'filter_index' => 'shipment.created_at',
|
125 |
+
'type' => 'datetime',
|
126 |
));
|
127 |
|
128 |
$this->addColumn('pdf', array(
|
129 |
+
'header' => Mage::helper('sales')->__('Action'),
|
130 |
+
'align' => 'left',
|
131 |
+
'renderer' => 'synergeticagency_gls/adminhtml_sales_gls_shipment_grid_renderer_pdf',
|
132 |
+
'filter' => false,
|
133 |
+
'sortable' => false,
|
134 |
+
));
|
135 |
+
|
136 |
+
$this->addColumn('qty_parcels', array(
|
137 |
+
'header' => $helper->__('Quantity parcels'),
|
138 |
+
'align' => 'left',
|
139 |
+
'renderer' => 'synergeticagency_gls/adminhtml_sales_gls_shipment_grid_renderer_qtyparcels',
|
140 |
+
'filter' => false,
|
141 |
+
'sortable' => false,
|
142 |
+
));
|
143 |
+
|
144 |
+
$this->addColumn('qty_update', array(
|
145 |
+
'header' => $helper->__('Quantity update'),
|
146 |
+
'align' => 'left',
|
147 |
+
'renderer' => 'synergeticagency_gls/adminhtml_sales_gls_shipment_grid_renderer_qtyupdate',
|
148 |
+
'filter' => false,
|
149 |
+
'sortable' => false,
|
150 |
+
'width' => '220px',
|
151 |
));
|
152 |
|
153 |
return parent::_prepareColumns();
|
154 |
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* prepares mass action
|
158 |
+
* @return $this
|
159 |
+
*/
|
160 |
+
protected function _prepareMassaction()
|
161 |
+
{
|
162 |
+
$this->setMassactionIdField('gls_shipment_id');
|
163 |
+
$this->getMassactionBlock()->setFormFieldName('gls_shipment_id');
|
164 |
+
|
165 |
+
$this->getMassactionBlock()->addItem('print', array(
|
166 |
+
'label'=> Mage::helper('synergeticagency_gls')->__('Print GLS labels'),
|
167 |
+
'url' => $this->getUrl('*/*/massprintshipment', array('' => '')),
|
168 |
+
));
|
169 |
+
|
170 |
+
return $this;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* @param $row Varien_Object
|
175 |
+
* @return string
|
176 |
+
*/
|
177 |
+
public function getRowUrl($row) {
|
178 |
+
return '';
|
179 |
+
}
|
180 |
}
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Js.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to info@synergetic.ag so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @category SynergetigAgency
|
17 |
+
* @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment
|
18 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Js
|
24 |
+
*/
|
25 |
+
class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Js extends Mage_Adminhtml_Block_Template {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* The Constructor initiates the template for the used Mage_Adminhtml_Block_Template
|
29 |
+
*/
|
30 |
+
public function _construct() {
|
31 |
+
$this->setTemplate('gls/shipment/grid/js.phtml');
|
32 |
+
parent::_construct();
|
33 |
+
}
|
34 |
+
}
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Error.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to info@synergetic.ag so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @category SynergetigAgency
|
17 |
+
* @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment\Grid\Renderer
|
18 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Error
|
24 |
+
*/
|
25 |
+
class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Error extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Renders the GLS shipment grid HTML for the given GLS shipment row
|
29 |
+
*
|
30 |
+
* @param Varien_Object $row
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function render(Varien_Object $row)
|
34 |
+
{
|
35 |
+
$errorMessage = trim($row->getErrorMessage());
|
36 |
+
if(!empty($errorMessage)) {
|
37 |
+
$errorCode = $row->getErrorCode();
|
38 |
+
if(empty($errorCode)) {
|
39 |
+
$errorCode = SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_UNDEFINED; // undefined
|
40 |
+
}
|
41 |
+
return sprintf($this->__('Error with error code:%s.'), $errorCode) . '<br />' . sprintf('<a href="%s#gls-error">%s</a>', Mage::helper('adminhtml')->getUrl('adminhtml/sales_shipment/view', array('shipment_id' => $row->getShipmentId())), $this->__('More information'));
|
42 |
+
}
|
43 |
+
return '';
|
44 |
+
}
|
45 |
+
}
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Pdf.php
CHANGED
@@ -33,14 +33,14 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Pdf
|
|
33 |
public function render(Varien_Object $row)
|
34 |
{
|
35 |
if($row->getPrinted()) {
|
36 |
-
$html = '<span>'.$this->__('Printed').'</span>';
|
37 |
-
|
38 |
$html = sprintf('<button onclick="setLocation(\'%s\');this.disabled=true;this.className += \' disabled\'" disabled="" class=" disabled">%s</button>', $this->getUrl('*/gls_shipment/print', array('id' => $row->getId())), $this->__('Printed'));
|
39 |
|
40 |
-
|
|
|
41 |
} else {
|
42 |
-
$html = sprintf('<button onclick="setLocation(\'%s\');this.disabled=true;this.className += \' disabled\'">%s</button>', $this->getUrl('*/gls_shipment/print', array('id' => $row->getId())), $this->__('Download PDF'));
|
43 |
}
|
44 |
-
|
|
|
45 |
}
|
46 |
}
|
33 |
public function render(Varien_Object $row)
|
34 |
{
|
35 |
if($row->getPrinted()) {
|
|
|
|
|
36 |
$html = sprintf('<button onclick="setLocation(\'%s\');this.disabled=true;this.className += \' disabled\'" disabled="" class=" disabled">%s</button>', $this->getUrl('*/gls_shipment/print', array('id' => $row->getId())), $this->__('Printed'));
|
37 |
|
38 |
+
} elseif($row->getJobId()) {
|
39 |
+
$html = sprintf('<button onclick="setLocation(\'%s\');this.disabled=true;this.className += \' disabled\'" disabled="" class=" disabled">%s</button>', $this->getUrl('*/gls_shipment/print', array('id' => $row->getId())), $this->__('In mass action'));
|
40 |
} else {
|
41 |
+
$html = sprintf('<button class="gls-print-button" data-id="%s" onclick="setLocation(\'%s\');this.disabled=true;this.className += \' disabled\'">%s</button>',$row->getId(), $this->getUrl('*/gls_shipment/print', array('id' => $row->getId())), $this->__('Download PDF'));
|
42 |
}
|
43 |
+
// the anchor is added to disable the click action for the checkbox
|
44 |
+
return '<a style="display: none" href=""></a>'.$html;
|
45 |
}
|
46 |
}
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Qtyparcels.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to info@synergetic.ag so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @category SynergetigAgency
|
17 |
+
* @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment\Grid\Renderer
|
18 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Qtyparcels
|
24 |
+
*/
|
25 |
+
class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Qtyparcels extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Renders the GLS shipment grid HTML for the given GLS shipment row
|
29 |
+
*
|
30 |
+
* @param Varien_Object $row
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function render(Varien_Object $row)
|
34 |
+
{
|
35 |
+
return '<span id="qty-parcels-'.$row->getId().'">' . $row->getShipmentParcels()->count(). '</span>';
|
36 |
+
}
|
37 |
+
}
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Qtyupdate.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to info@synergetic.ag so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @category SynergetigAgency
|
17 |
+
* @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment\Grid\Renderer
|
18 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Qtyupdate
|
24 |
+
*/
|
25 |
+
class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Qtyupdate extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Renders the GLS shipment grid HTML for the given GLS shipment row
|
29 |
+
*
|
30 |
+
* @param Varien_Object $row
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function render(Varien_Object $row)
|
34 |
+
{
|
35 |
+
if($row->getPrinted()) {
|
36 |
+
$html = '<span>' . $this->__('Already printed'). '</span>';
|
37 |
+
} elseif($row->getJobId()) {
|
38 |
+
$html = '<span>' . $this->__('In mass action'). '</span>';
|
39 |
+
} elseif(Mage::helper('synergeticagency_gls/validate')->isCashService($row->getMagentoShipment())) {
|
40 |
+
$html = '<span>' . $this->__('Not available with cash on delivery').'</span>';
|
41 |
+
} else {
|
42 |
+
$disabledDecrease = '';
|
43 |
+
$disabledIncrease = '';
|
44 |
+
if($row->getShipmentParcels()->count() == SynergeticAgency_Gls_Model_Shipment::GLS_SHIPMENT_MIN_PARCELS) {
|
45 |
+
$disabledDecrease = ' disabled';
|
46 |
+
}
|
47 |
+
if($row->getShipmentParcels()->count() >= SynergeticAgency_Gls_Model_Shipment::GLS_SHIPMENT_MAX_PARCELS) {
|
48 |
+
$disabledIncrease = ' disabled';
|
49 |
+
}
|
50 |
+
$html = '<div id="qty-parcels-wrap-'.$row->getId().'" class="qty-parcels-wrap" style="white-space: nowrap;">
|
51 |
+
<button class="qty-parcels-decrease qty-parcels-change'.$disabledDecrease.'" data-id="'.$row->getId().'" data-dir="-">-</button>
|
52 |
+
<input class="input-text qty-parcels-qty" autocomplete="off" value="'.$row->getShipmentParcels()->count().'" type="text" style="width: 50px;" name="qty_parcels['.$row->getId().']">
|
53 |
+
<button class="qty-parcels-increase qty-parcels-change'.$disabledIncrease.'" data-id="'.$row->getId().'" data-dir="+">+</button>
|
54 |
+
<button class="qty-parcels-submit" data-qty="'.$row->getShipmentParcels()->count().'" data-id="'.$row->getId().'"> '.$this->__('Update').' </button>
|
55 |
+
</div>';
|
56 |
+
$html .= '<span id="qty-parcels-printed-'.$row->getId().'" style="display:none;">' . $this->__('Already printed'). '</span>';
|
57 |
+
}
|
58 |
+
// the anchor is added to disable the click action for the checkbox
|
59 |
+
return '<a style="display: none" href=""></a>'.$html;
|
60 |
+
}
|
61 |
+
}
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Job.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to info@synergetic.ag so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @category SynergetigAgency
|
17 |
+
* @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls
|
18 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Job
|
24 |
+
*/
|
25 |
+
class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Job extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* The Constructor initiates the blockGroup, the controller and the headerText of the used Mage_Adminhtml_Block_Widget_Grid_Container
|
29 |
+
* The Connector also removes the button "add" from the used Mage_Adminhtml_Block_Widget_Grid_Container
|
30 |
+
*/
|
31 |
+
public function __construct()
|
32 |
+
{
|
33 |
+
$this->_blockGroup = 'synergeticagency_gls';
|
34 |
+
$this->_controller = 'adminhtml_sales_gls_shipment_job';
|
35 |
+
$this->_headerText = Mage::helper('synergeticagency_gls')->__('GLS mass action list');
|
36 |
+
parent::__construct();
|
37 |
+
$this->_removeButton('add');
|
38 |
+
}
|
39 |
+
}
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Job/Grid.php
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to info@synergetic.ag so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @category SynergetigAgency
|
17 |
+
* @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment
|
18 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Job_Grid
|
24 |
+
*/
|
25 |
+
class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Job_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* The Constructor initiates the id, the defaultSort and the defaultDir of the used Mage_Adminhtml_Block_Widget_Grid
|
29 |
+
*/
|
30 |
+
public function __construct()
|
31 |
+
{
|
32 |
+
parent::__construct();
|
33 |
+
$this->setId('synergeticagency_gls_shipment_job_grid');
|
34 |
+
$this->setDefaultSort('gls_shipment_job_id');
|
35 |
+
$this->setDefaultDir('DESC');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Prepare grid collection object
|
40 |
+
*
|
41 |
+
* @return SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid
|
42 |
+
*/
|
43 |
+
protected function _prepareCollection()
|
44 |
+
{
|
45 |
+
$collection = Mage::getResourceModel('synergeticagency_gls/shipment_job_collection');
|
46 |
+
$this->setCollection($collection);
|
47 |
+
parent::_prepareCollection();
|
48 |
+
return $this;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Prepare grid columns
|
53 |
+
*
|
54 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
55 |
+
*/
|
56 |
+
protected function _prepareColumns()
|
57 |
+
{
|
58 |
+
$helper = Mage::helper('synergeticagency_gls');
|
59 |
+
|
60 |
+
$this->addColumn('gls_shipment_job_id', array(
|
61 |
+
'header' => $helper->__('GLS Mass print ID'),
|
62 |
+
'index' => 'gls_shipment_job_id',
|
63 |
+
'width' => '100px'
|
64 |
+
));
|
65 |
+
|
66 |
+
$this->addColumn('job_status', array(
|
67 |
+
'header' => $helper->__('Process status'),
|
68 |
+
'renderer' => 'synergeticagency_gls/adminhtml_sales_gls_shipment_job_grid_renderer_jobstatus',
|
69 |
+
'index' => 'job_status',
|
70 |
+
'sortable' => false,
|
71 |
+
'filter' => false,
|
72 |
+
));
|
73 |
+
|
74 |
+
$this->addColumn('error_messages', array(
|
75 |
+
'header' => $helper->__('Error messages'),
|
76 |
+
'index' => 'error_messages',
|
77 |
+
'column_css_class' => 'job_error_messages',
|
78 |
+
'sortable' => false,
|
79 |
+
'filter' => false,
|
80 |
+
));
|
81 |
+
|
82 |
+
$this->addColumn('error_items', array(
|
83 |
+
'header' => $helper->__('Error shipment items'),
|
84 |
+
'renderer' => 'synergeticagency_gls/adminhtml_sales_gls_shipment_job_grid_renderer_erroritems',
|
85 |
+
'index' => 'error_items',
|
86 |
+
'column_css_class' => 'job_error_items',
|
87 |
+
'sortable' => false,
|
88 |
+
'filter' => false,
|
89 |
+
));
|
90 |
+
|
91 |
+
$this->addColumn('completed', array(
|
92 |
+
'header' => $helper->__('Completed'),
|
93 |
+
'index' => 'completed',
|
94 |
+
'type' => 'options',
|
95 |
+
'width' => '50px',
|
96 |
+
'column_css_class' => 'job_completed',
|
97 |
+
'options' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toArray()
|
98 |
+
));
|
99 |
+
|
100 |
+
$this->addColumn('printed', array(
|
101 |
+
'header' => $helper->__('Printed'),
|
102 |
+
'index' => 'printed',
|
103 |
+
'type' => 'options',
|
104 |
+
'width' => '50px',
|
105 |
+
'column_css_class' => 'job_printed',
|
106 |
+
'options' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toArray()
|
107 |
+
));
|
108 |
+
|
109 |
+
$this->addColumn('created_at', array(
|
110 |
+
'header' => Mage::helper('sales')->__('Date Created'),
|
111 |
+
'index' => 'created_at',
|
112 |
+
'type' => 'datetime',
|
113 |
+
'width' => '100px'
|
114 |
+
));
|
115 |
+
|
116 |
+
$this->addColumn('action', array(
|
117 |
+
'header' => Mage::helper('sales')->__('Action'),
|
118 |
+
'align' => 'left',
|
119 |
+
'column_css_class' => 'job_action',
|
120 |
+
'renderer' => 'synergeticagency_gls/adminhtml_sales_gls_shipment_job_grid_renderer_action',
|
121 |
+
'filter' => false,
|
122 |
+
'sortable' => false,
|
123 |
+
'width' => '150px',
|
124 |
+
));
|
125 |
+
|
126 |
+
return parent::_prepareColumns();
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* @param $row Varien_Object
|
131 |
+
* @return string
|
132 |
+
*/
|
133 |
+
public function getRowUrl($row) {
|
134 |
+
return '';
|
135 |
+
}
|
136 |
+
}
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Job/Grid/Js.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to info@synergetic.ag so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @category SynergetigAgency
|
17 |
+
* @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment
|
18 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Job_Grid_Js
|
24 |
+
*/
|
25 |
+
class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Job_Grid_Js extends Mage_Adminhtml_Block_Template {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* The Constructor initiates the template for the used Mage_Adminhtml_Block_Template
|
29 |
+
*/
|
30 |
+
public function _construct() {
|
31 |
+
$this->setTemplate('gls/shipment/job/grid/js.phtml');
|
32 |
+
parent::_construct();
|
33 |
+
}
|
34 |
+
}
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Job/Grid/Renderer/Action.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to info@synergetic.ag so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @category SynergetigAgency
|
17 |
+
* @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment
|
18 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Job_Grid_Renderer_Action
|
24 |
+
*/
|
25 |
+
class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Job_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Renders the button
|
29 |
+
*
|
30 |
+
* @param Varien_Object $row
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function render(Varien_Object $row)
|
34 |
+
{
|
35 |
+
if($row->getInProcess()) {
|
36 |
+
$html = sprintf('<button onclick="setLocation(\'%s\');this.disabled=true;this.className += \' disabled\'" disabled="" class=" disabled">%s</button>', $this->getUrl('*/gls_shipment_job/print', array('id' => $row->getId())), $this->__('In process'));
|
37 |
+
} elseif($row->getCompleted() && $row->getPrinted()) {
|
38 |
+
$html = sprintf('<button onclick="setLocation(\'%s\');this.disabled=true;this.className += \' disabled\'" disabled="" class=" disabled">%s</button>', $this->getUrl('*/gls_shipment_job/print', array('id' => $row->getId())), $this->__('Printed'));
|
39 |
+
} elseif($row->getCompleted() && !$row->getPrinted() && $row->getQtyItemsSuccessful()) {
|
40 |
+
$html = sprintf('<button onclick="setLocation(\'%s\');this.disabled=true;this.className += \' disabled\'">%s</button>', $this->getUrl('*/gls_shipment_job/print', array('id' => $row->getId())), $this->__('Download PDF'));
|
41 |
+
} elseif($row->getCompleted() && !$row->getPrinted() && !$row->getQtyItemsSuccessful()) {
|
42 |
+
$html = sprintf('<button onclick="setLocation(\'%s\');this.disabled=true;this.className += \' disabled\'" disabled="" class=" disabled">%s</button>', $this->getUrl('*/gls_shipment_job/print', array('id' => $row->getId())), $this->__('No valid shipments'));
|
43 |
+
} else {
|
44 |
+
$html = sprintf('<button onclick="setLocation(\'%s\');this.disabled=true;this.className += \' disabled\'" disabled="" class=" disabled">%s</button>', $this->getUrl('*/gls_shipment_job/print', array('id' => $row->getId())), $this->__('Pending'));
|
45 |
+
}
|
46 |
+
return $html;
|
47 |
+
}
|
48 |
+
}
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Job/Grid/Renderer/Erroritems.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to info@synergetic.ag so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @category SynergetigAgency
|
17 |
+
* @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment
|
18 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Job_Grid_Renderer_Erroritems
|
24 |
+
*/
|
25 |
+
class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Job_Grid_Renderer_Erroritems extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Renders the job status
|
29 |
+
*
|
30 |
+
* @param Varien_Object $row
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function render(Varien_Object $row)
|
34 |
+
{
|
35 |
+
$ret = '';
|
36 |
+
$errorItems = $row->getErrorItems();
|
37 |
+
if(!empty($errorItems)) {
|
38 |
+
$errorItems = json_decode($errorItems);
|
39 |
+
if(count($errorItems)) {
|
40 |
+
$retArray = array();
|
41 |
+
foreach($errorItems as $errorItem) {
|
42 |
+
$retArray[] = sprintf('<a href="%s">%s</a>', Mage::helper('adminhtml')->getUrl('adminhtml/sales_shipment/view', array('shipment_id' => $errorItem->shipment_id)), $errorItem->shipment_increment_id);
|
43 |
+
}
|
44 |
+
|
45 |
+
$ret = implode(', ',$retArray);
|
46 |
+
}
|
47 |
+
}
|
48 |
+
return '<span>'.$ret.'</span>';
|
49 |
+
}
|
50 |
+
}
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Job/Grid/Renderer/Jobstatus.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to info@synergetic.ag so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @category SynergetigAgency
|
17 |
+
* @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment
|
18 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Job_Grid_Renderer_Jobstatus
|
24 |
+
*/
|
25 |
+
class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Job_Grid_Renderer_Jobstatus extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Renders the job status
|
29 |
+
*
|
30 |
+
* @param Varien_Object $row
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function render(Varien_Object $row)
|
34 |
+
{
|
35 |
+
return '<div class="job-status-column" id="job-'.$row->getGlsShipmentJobId().'">'.$row->getStatus().'</div>';
|
36 |
+
}
|
37 |
+
}
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/Create/Gls.php
CHANGED
@@ -59,11 +59,8 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
59 |
* @return bool
|
60 |
*/
|
61 |
public function isCountryAvailable() {
|
62 |
-
$
|
63 |
-
|
64 |
-
$destCountry = $this->_getCurrentShipment()->getShippingAddress()->getCountryId();
|
65 |
-
return ($glsModel->isCountryOriginIdAvailable($storeCountry)
|
66 |
-
&& ($this->isDomestic() || $glsModel->isDestinationCountryAvailable($storeCountry,$destCountry)));
|
67 |
}
|
68 |
|
69 |
/**
|
@@ -95,40 +92,13 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
95 |
* @return bool
|
96 |
*/
|
97 |
public function isCombinationSelected($combinationId) {
|
98 |
-
$
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
}
|
104 |
-
break;
|
105 |
-
case SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_GUARANTEED:
|
106 |
-
if($this->isDomestic() && $this->isExpressShipping()) {
|
107 |
-
$return = true;
|
108 |
-
}
|
109 |
-
break;
|
110 |
-
case SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_SHOPDELIVERY:
|
111 |
-
if($this->isDomestic() && $this->isParcelshopDelivery()) {
|
112 |
-
$return = true;
|
113 |
-
}
|
114 |
-
break;
|
115 |
-
case SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_CASHSERVICE:
|
116 |
-
if($this->isDomestic() && $this->isCashService()) {
|
117 |
-
$return = true;
|
118 |
-
}
|
119 |
-
break;
|
120 |
-
case SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL:
|
121 |
-
if((!$this->isDomestic() || $this->matchCountry('FI')) && !$this->isParcelshopDelivery() && $this->isForeignShipping()) {
|
122 |
-
$return = true;
|
123 |
-
}
|
124 |
-
break;
|
125 |
-
case SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL_SHOPDELIVERY:
|
126 |
-
if(!$this->isDomestic() && $this->isParcelshopDelivery()) {
|
127 |
-
$return = true;
|
128 |
-
}
|
129 |
-
break;
|
130 |
}
|
131 |
-
return
|
132 |
}
|
133 |
|
134 |
/**
|
@@ -140,6 +110,8 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
140 |
* @return bool
|
141 |
*/
|
142 |
public function isServiceSelected($serviceId) {
|
|
|
|
|
143 |
$return = false;
|
144 |
switch($serviceId) {
|
145 |
|
@@ -147,16 +119,6 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
147 |
return $return;
|
148 |
}
|
149 |
|
150 |
-
/**
|
151 |
-
* Returns true, if current shipping method is a GLS "Standard" shipping
|
152 |
-
* Otherwise, this function returns false
|
153 |
-
*
|
154 |
-
* @return bool
|
155 |
-
*/
|
156 |
-
public function isStandardShipping() {
|
157 |
-
return $this->_getCurrentShipment()->getOrder()->getShippingMethod() == SynergeticAgency_Gls_Model_Carrier::CODE.'_'.SynergeticAgency_Gls_Model_Carrier::SHIPPING_RATE_STANDARD;
|
158 |
-
}
|
159 |
-
|
160 |
/**
|
161 |
* Returns true, if current shipping method is a GLS "Express" shipping
|
162 |
* Otherwise, this function returns false
|
@@ -164,7 +126,8 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
164 |
* @return bool
|
165 |
*/
|
166 |
public function isExpressShipping() {
|
167 |
-
|
|
|
168 |
}
|
169 |
|
170 |
/**
|
@@ -174,7 +137,8 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
174 |
* @return bool
|
175 |
*/
|
176 |
public function isForeignShipping() {
|
177 |
-
|
|
|
178 |
}
|
179 |
|
180 |
/**
|
@@ -185,8 +149,8 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
185 |
* @return bool
|
186 |
*/
|
187 |
public function matchCountry( $countryCode ) {
|
188 |
-
$
|
189 |
-
return
|
190 |
}
|
191 |
|
192 |
/**
|
@@ -197,8 +161,8 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
197 |
* @return bool
|
198 |
*/
|
199 |
public function isParcelshopDelivery() {
|
200 |
-
$
|
201 |
-
return
|
202 |
}
|
203 |
|
204 |
/**
|
@@ -209,12 +173,7 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
209 |
*/
|
210 |
public function isCashService() {
|
211 |
$shipment = $this->_getCurrentShipment();
|
212 |
-
|
213 |
-
if($shipment->getOrder()->getPayment()->getMethodInstance() instanceof SynergeticAgency_Gls_Model_Glscashondelivery) {
|
214 |
-
return true;
|
215 |
-
}
|
216 |
-
}
|
217 |
-
return false;
|
218 |
}
|
219 |
|
220 |
/**
|
@@ -253,7 +212,8 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
253 |
* @return int
|
254 |
*/
|
255 |
public function getParcelShopCombinationId() {
|
256 |
-
|
|
|
257 |
}
|
258 |
|
259 |
/**
|
@@ -293,15 +253,7 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
293 |
*/
|
294 |
public function getCountriesJson() {
|
295 |
$shipment = $this->_getCurrentShipment();
|
296 |
-
|
297 |
-
if($shipment) {
|
298 |
-
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $this->getStore());
|
299 |
-
$glsCountry = Mage::getModel('synergeticagency_gls/country')->load($storeCountry);
|
300 |
-
if($glsCountry->getId()) {
|
301 |
-
$jsonData = Mage::helper('core')->jsonEncode($glsCountry->getData());
|
302 |
-
}
|
303 |
-
}
|
304 |
-
return $jsonData;
|
305 |
}
|
306 |
|
307 |
/**
|
@@ -312,19 +264,7 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
312 |
*/
|
313 |
public function getJsonConfig() {
|
314 |
$shipment = $this->_getCurrentShipment();
|
315 |
-
|
316 |
-
if($shipment) {
|
317 |
-
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID,
|
318 |
-
$this->getStore());
|
319 |
-
/** @var Zend_Config_Json $jsonConfig */
|
320 |
-
$jsonConfig = Mage::getModel('synergeticagency_gls/jsonimport')->getCountry($storeCountry);
|
321 |
-
if($jsonConfig) {
|
322 |
-
$writer = new Zend_Config_Writer_Json();
|
323 |
-
$writer->setConfig($jsonConfig);
|
324 |
-
$jsonData = $writer->render();
|
325 |
-
}
|
326 |
-
}
|
327 |
-
return $jsonData;
|
328 |
}
|
329 |
|
330 |
/**
|
@@ -333,7 +273,8 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
333 |
* @return string
|
334 |
*/
|
335 |
public function getTargetCountry() {
|
336 |
-
|
|
|
337 |
}
|
338 |
|
339 |
/**
|
@@ -343,13 +284,7 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls exten
|
|
343 |
*/
|
344 |
public function isDomestic() {
|
345 |
$shipment = $this->_getCurrentShipment();
|
346 |
-
|
347 |
-
if($shipment) {
|
348 |
-
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $this->getStore());
|
349 |
-
$destCountry = $shipment->getShippingAddress()->getCountryId();
|
350 |
-
$return = $storeCountry == $destCountry;
|
351 |
-
}
|
352 |
-
return $return;
|
353 |
}
|
354 |
|
355 |
/**
|
59 |
* @return bool
|
60 |
*/
|
61 |
public function isCountryAvailable() {
|
62 |
+
$shipment = $this->_getCurrentShipment();
|
63 |
+
return Mage::helper('synergeticagency_gls/validate')->isCountryAvailable($shipment);
|
|
|
|
|
|
|
64 |
}
|
65 |
|
66 |
/**
|
92 |
* @return bool
|
93 |
*/
|
94 |
public function isCombinationSelected($combinationId) {
|
95 |
+
$glsModel = Mage::getModel('synergeticagency_gls/gls');
|
96 |
+
$shipment = $this->_getCurrentShipment();
|
97 |
+
$combinationByShipment = $glsModel->getCombinationByShipment($shipment,false);
|
98 |
+
if($combinationId === $combinationByShipment) {
|
99 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
+
return false;
|
102 |
}
|
103 |
|
104 |
/**
|
110 |
* @return bool
|
111 |
*/
|
112 |
public function isServiceSelected($serviceId) {
|
113 |
+
// this function is just an example for the moment
|
114 |
+
// originally it was used for the think green service, but think green is removed from the frontend and as well here
|
115 |
$return = false;
|
116 |
switch($serviceId) {
|
117 |
|
119 |
return $return;
|
120 |
}
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
/**
|
123 |
* Returns true, if current shipping method is a GLS "Express" shipping
|
124 |
* Otherwise, this function returns false
|
126 |
* @return bool
|
127 |
*/
|
128 |
public function isExpressShipping() {
|
129 |
+
$shipment = $this->_getCurrentShipment();
|
130 |
+
return Mage::helper('synergeticagency_gls/validate')->isExpressShipping($shipment);
|
131 |
}
|
132 |
|
133 |
/**
|
137 |
* @return bool
|
138 |
*/
|
139 |
public function isForeignShipping() {
|
140 |
+
$shipment = $this->_getCurrentShipment();
|
141 |
+
return Mage::helper('synergeticagency_gls/validate')->isForeignShipping($shipment);
|
142 |
}
|
143 |
|
144 |
/**
|
149 |
* @return bool
|
150 |
*/
|
151 |
public function matchCountry( $countryCode ) {
|
152 |
+
$shipment = $this->_getCurrentShipment();
|
153 |
+
return Mage::helper('synergeticagency_gls/validate')->matchCountry($countryCode,$shipment);
|
154 |
}
|
155 |
|
156 |
/**
|
161 |
* @return bool
|
162 |
*/
|
163 |
public function isParcelshopDelivery() {
|
164 |
+
$shipment = $this->_getCurrentShipment();
|
165 |
+
return Mage::helper('synergeticagency_gls/validate')->isParcelshopDelivery($shipment);
|
166 |
}
|
167 |
|
168 |
/**
|
173 |
*/
|
174 |
public function isCashService() {
|
175 |
$shipment = $this->_getCurrentShipment();
|
176 |
+
return Mage::helper('synergeticagency_gls/validate')->isCashService($shipment);
|
|
|
|
|
|
|
|
|
|
|
177 |
}
|
178 |
|
179 |
/**
|
212 |
* @return int
|
213 |
*/
|
214 |
public function getParcelShopCombinationId() {
|
215 |
+
$shipment = $this->_getCurrentShipment();
|
216 |
+
return Mage::helper('synergeticagency_gls/validate')->getParcelShopCombinationId($shipment);
|
217 |
}
|
218 |
|
219 |
/**
|
253 |
*/
|
254 |
public function getCountriesJson() {
|
255 |
$shipment = $this->_getCurrentShipment();
|
256 |
+
return Mage::helper('synergeticagency_gls/validate')->getCountriesJson($shipment);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
}
|
258 |
|
259 |
/**
|
264 |
*/
|
265 |
public function getJsonConfig() {
|
266 |
$shipment = $this->_getCurrentShipment();
|
267 |
+
return Mage::helper('synergeticagency_gls/validate')->getJsonConfig($shipment);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
}
|
269 |
|
270 |
/**
|
273 |
* @return string
|
274 |
*/
|
275 |
public function getTargetCountry() {
|
276 |
+
$shipment = $this->_getCurrentShipment();
|
277 |
+
return Mage::helper('synergeticagency_gls/validate')->getTargetCountry($shipment);
|
278 |
}
|
279 |
|
280 |
/**
|
284 |
*/
|
285 |
public function isDomestic() {
|
286 |
$shipment = $this->_getCurrentShipment();
|
287 |
+
return Mage::helper('synergeticagency_gls/validate')->isDomestic($shipment);
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
}
|
289 |
|
290 |
/**
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/Create/Gls/Packages.php
CHANGED
@@ -82,12 +82,7 @@ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls_Packa
|
|
82 |
*/
|
83 |
public function isCashService() {
|
84 |
$shipment = $this->_getCurrentShipment();
|
85 |
-
|
86 |
-
if($shipment->getOrder()->getPayment()->getMethodInstance() instanceof SynergeticAgency_Gls_Model_Glscashondelivery) {
|
87 |
-
return true;
|
88 |
-
}
|
89 |
-
}
|
90 |
-
return false;
|
91 |
}
|
92 |
|
93 |
/**
|
82 |
*/
|
83 |
public function isCashService() {
|
84 |
$shipment = $this->_getCurrentShipment();
|
85 |
+
return Mage::helper('synergeticagency_gls/validate')->isCashService($shipment);
|
|
|
|
|
|
|
|
|
|
|
86 |
}
|
87 |
|
88 |
/**
|
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/System/Config/Note.php
CHANGED
@@ -25,11 +25,8 @@
|
|
25 |
*/
|
26 |
|
27 |
/**
|
28 |
-
*
|
29 |
-
* @package SynergeticAgency_Gls
|
30 |
-
* @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
|
31 |
*/
|
32 |
-
|
33 |
class SynergeticAgency_Gls_Block_Adminhtml_System_Config_Note extends Mage_Adminhtml_Block_Abstract
|
34 |
implements Varien_Data_Form_Element_Renderer_Interface
|
35 |
{
|
25 |
*/
|
26 |
|
27 |
/**
|
28 |
+
* Class SynergeticAgency_Gls_Block_Adminhtml_System_Config_Note
|
|
|
|
|
29 |
*/
|
|
|
30 |
class SynergeticAgency_Gls_Block_Adminhtml_System_Config_Note extends Mage_Adminhtml_Block_Abstract
|
31 |
implements Varien_Data_Form_Element_Renderer_Interface
|
32 |
{
|
app/code/community/SynergeticAgency/Gls/Exception.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category SynergetigAgency
|
22 |
+
* @package SynergeticAgency\Gls\Model
|
23 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Class SynergeticAgency_Gls_Exception
|
29 |
+
*/
|
30 |
+
class SynergeticAgency_Gls_Exception extends Exception
|
31 |
+
{
|
32 |
+
|
33 |
+
/** Magento shipment to the GLS shipment is missing */
|
34 |
+
const GLS_ERROR_CODE_MAGE_SHIPMENT_MISSING = '00001';
|
35 |
+
/** label is already printed and can not be printed again */
|
36 |
+
const GLS_ERROR_CODE_LABEL_ALREADY_PRINTED = '00002';
|
37 |
+
/** The GLS basic configuration is incomplete */
|
38 |
+
const GLS_ERROR_CODE_CONFIGURATION_INCOMPLETE = '00003';
|
39 |
+
/** The GLS-API-Connector returned an error */
|
40 |
+
const GLS_ERROR_CODE_API_CONNECTOR_ERROR = '00005';
|
41 |
+
/** GLS API didin't return a correct consignment id */
|
42 |
+
const GLS_ERROR_CODE_CONSIGNMENTID_MISSING = '00006';
|
43 |
+
/** edit of gls shipment not possible -- already printed or invalid data */
|
44 |
+
const GLS_ERROR_CODE_SHIPMENT_EDIT_IMPOSSIBLE = '00007';
|
45 |
+
/** GLS shipment could not be saved */
|
46 |
+
const GLS_ERROR_CODE_SHIPMENT_NOT_SAVED = '00009';
|
47 |
+
/** GLS shipment could not be created */
|
48 |
+
const GLS_ERROR_CODE_SHIPMENT_NOT_CREATED = '00010';
|
49 |
+
/** PDF label could not be written to filesystem */
|
50 |
+
const GLS_ERROR_CODE_LABEL_IO_ERROR = '00011';
|
51 |
+
/** The GLS label retuned is no valid PDF */
|
52 |
+
const GLS_ERROR_CODE_LABEL_INVALID = '00013';
|
53 |
+
/** in mass print no valid label was returned */
|
54 |
+
const GLS_ERROR_CODE_MASS_LABEL_MISSING = '00080';
|
55 |
+
/** unefined error */
|
56 |
+
const GLS_ERROR_CODE_UNDEFINED = '99999';
|
57 |
+
|
58 |
+
|
59 |
+
/** @var string */
|
60 |
+
protected $code;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @param null $message
|
64 |
+
* @param string $code
|
65 |
+
*/
|
66 |
+
public function __construct($message = null, $code = '')
|
67 |
+
{
|
68 |
+
parent::__construct($message, 0);
|
69 |
+
$this->code = $code;
|
70 |
+
}
|
71 |
+
}
|
app/code/community/SynergeticAgency/Gls/Helper/Data.php
CHANGED
@@ -300,4 +300,68 @@ class SynergeticAgency_Gls_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
300 |
{
|
301 |
return (string) Mage::getConfig()->getNode()->modules->SynergeticAgency_Gls->version;
|
302 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
}
|
300 |
{
|
301 |
return (string) Mage::getConfig()->getNode()->modules->SynergeticAgency_Gls->version;
|
302 |
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* @param Mage_Sales_Model_Order $order
|
306 |
+
* @param string $comment
|
307 |
+
* @param bool|int $isError
|
308 |
+
* @param bool|int $save
|
309 |
+
* @throws Exception
|
310 |
+
*/
|
311 |
+
public function setOrderStatus($order,$comment,$isError=false,$save=true) {
|
312 |
+
$state = $order->getState();
|
313 |
+
$originalStatus = $order->getStatus();
|
314 |
+
$status = '';
|
315 |
+
switch($state) {
|
316 |
+
case Mage_Sales_Model_Order::STATE_NEW:
|
317 |
+
if($isError) {
|
318 |
+
$status = SynergeticAgency_Gls_Model_Gls::GLS_STATUS_PENDING_ERROR;
|
319 |
+
} else {
|
320 |
+
$status = SynergeticAgency_Gls_Model_Gls::GLS_STATUS_PENDING;
|
321 |
+
}
|
322 |
+
break;
|
323 |
+
case Mage_Sales_Model_Order::STATE_PROCESSING:
|
324 |
+
if($isError) {
|
325 |
+
$status = SynergeticAgency_Gls_Model_Gls::GLS_STATUS_PROCESSING_ERROR;
|
326 |
+
} else {
|
327 |
+
$status = SynergeticAgency_Gls_Model_Gls::GLS_STATUS_PROCESSING;
|
328 |
+
}
|
329 |
+
break;
|
330 |
+
case Mage_Sales_Model_Order::STATE_COMPLETE:
|
331 |
+
if(!$isError) {
|
332 |
+
$status = SynergeticAgency_Gls_Model_Gls::GLS_STATUS_COMPLETE;
|
333 |
+
}
|
334 |
+
break;
|
335 |
+
}
|
336 |
+
if(!empty($status) && $originalStatus != $status) {
|
337 |
+
$order->addStatusHistoryComment($comment, $status);
|
338 |
+
if($save) {
|
339 |
+
$order->save();
|
340 |
+
}
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* @param Mage_Core_Model_Store $store
|
346 |
+
* @return SynergeticAgency_GlsConnector_Connector
|
347 |
+
*/
|
348 |
+
public function getConnector($store) {
|
349 |
+
$connector = new SynergeticAgency_GlsConnector_Connector();
|
350 |
+
|
351 |
+
// in default sandbox is enabled
|
352 |
+
if( Mage::getStoreConfig('gls/general/sandbox',$store) !== '1' ){
|
353 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, "gls/general/sandbox is set to '0'", Zend_Log::INFO );
|
354 |
+
$connector->setGlsApiSandbox( false );
|
355 |
+
}
|
356 |
+
|
357 |
+
$connector->setGlsApiUrl(Mage::getStoreConfig('gls/general/api_url',$store));
|
358 |
+
$connector->setGlsApiAuthUsername( Mage::getStoreConfig('gls/general/apiAuthUsername',$store) );
|
359 |
+
$connector->setGlsApiAuthPassword( Mage::helper('core')->decrypt(Mage::getStoreConfig('gls/general/apiAuthPassword', $store)) );
|
360 |
+
|
361 |
+
// disabled by default
|
362 |
+
if(Mage::getStoreConfig('gls/general/connector_log_enabled',$store) === '1') {
|
363 |
+
$connector->getLog()->activate()->setLogFile(Mage::getBaseDir('log').DS.'SynergeticAgency_GlsConnector.log');
|
364 |
+
}
|
365 |
+
return $connector;
|
366 |
+
}
|
367 |
}
|
app/code/community/SynergeticAgency/Gls/Helper/Log.php
CHANGED
@@ -25,7 +25,7 @@
|
|
25 |
*/
|
26 |
|
27 |
/**
|
28 |
-
* GLS helper
|
29 |
*
|
30 |
* @category SynergeticAgency
|
31 |
* @package SynergeticAgency_Gls
|
25 |
*/
|
26 |
|
27 |
/**
|
28 |
+
* GLS helper log
|
29 |
*
|
30 |
* @category SynergeticAgency
|
31 |
* @package SynergeticAgency_Gls
|
app/code/community/SynergeticAgency/Gls/Helper/Validate.php
CHANGED
@@ -32,13 +32,14 @@ class SynergeticAgency_Gls_Helper_Validate extends Mage_Core_Helper_Abstract {
|
|
32 |
|
33 |
/**
|
34 |
* Check if destination of current shipment is for other country than origin shipping country of current store
|
|
|
35 |
* @return bool|null
|
36 |
*/
|
37 |
-
public function isDomestic() {
|
38 |
-
|
39 |
$return = null;
|
40 |
if($shipment) {
|
41 |
-
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $
|
42 |
$destCountry = $shipment->getShippingAddress()->getCountryId();
|
43 |
$return = $storeCountry == $destCountry;
|
44 |
}
|
@@ -47,23 +48,24 @@ class SynergeticAgency_Gls_Helper_Validate extends Mage_Core_Helper_Abstract {
|
|
47 |
|
48 |
/**
|
49 |
* Shipment to parcel shop? True if a parcel shop ID is given
|
|
|
50 |
* @return bool
|
51 |
*/
|
52 |
-
public function isParcelshopDelivery() {
|
53 |
-
$parcelShopId =
|
54 |
return !empty($parcelShopId);
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
* Gets Json Config for specific origin country supplied by gls
|
|
|
59 |
* @return string
|
60 |
*/
|
61 |
-
public function getJsonConfig() {
|
62 |
$jsonData = '{}';
|
63 |
-
$
|
64 |
-
if(SynergeticAgency_Gls_Helper_Validate::getCurrentShipment()) {
|
65 |
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID,
|
66 |
-
$
|
67 |
|
68 |
$jsonConfig = Mage::getModel('synergeticagency_gls/jsonimport')->getCountry($storeCountry);
|
69 |
if($jsonConfig) {
|
@@ -77,13 +79,14 @@ class SynergeticAgency_Gls_Helper_Validate extends Mage_Core_Helper_Abstract {
|
|
77 |
|
78 |
/**
|
79 |
* Gets config for specific origin country supplied by gls
|
|
|
80 |
* @return string
|
81 |
*/
|
82 |
-
public function getConfig() {
|
83 |
$jsonConfig = '';
|
84 |
-
if(
|
85 |
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID,
|
86 |
-
$
|
87 |
|
88 |
$jsonConfig = Mage::getModel('synergeticagency_gls/jsonimport')->getCountry($storeCountry);
|
89 |
|
@@ -93,13 +96,13 @@ class SynergeticAgency_Gls_Helper_Validate extends Mage_Core_Helper_Abstract {
|
|
93 |
|
94 |
/**
|
95 |
* get country config as json
|
|
|
96 |
* @return string
|
97 |
*/
|
98 |
-
public function getCountriesJson() {
|
99 |
-
$shipment = SynergeticAgency_Gls_Helper_Validate::getCurrentShipment();
|
100 |
$jsonData = '{}';
|
101 |
if($shipment) {
|
102 |
-
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $
|
103 |
$glsCountry = Mage::getModel('synergeticagency_gls/country')->load($storeCountry);
|
104 |
if($glsCountry->getId()) {
|
105 |
$jsonData = Mage::helper('core')->jsonEncode($glsCountry->getData());
|
@@ -110,12 +113,13 @@ class SynergeticAgency_Gls_Helper_Validate extends Mage_Core_Helper_Abstract {
|
|
110 |
|
111 |
/**
|
112 |
* get country config
|
|
|
113 |
* @return string
|
114 |
*/
|
115 |
-
public function getCountriesConfig() {
|
116 |
-
$
|
117 |
if($shipment) {
|
118 |
-
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID,
|
119 |
$glsCountry = Mage::getModel('synergeticagency_gls/country')->load($storeCountry);
|
120 |
}
|
121 |
return $glsCountry;
|
@@ -140,45 +144,146 @@ class SynergeticAgency_Gls_Helper_Validate extends Mage_Core_Helper_Abstract {
|
|
140 |
|
141 |
/**
|
142 |
* Get the current shipment method. Shipment methods are actually combinations of gls services
|
|
|
143 |
* @return int
|
144 |
*/
|
145 |
-
public function getParcelShopCombinationId() {
|
146 |
-
return
|
147 |
}
|
148 |
|
149 |
/**
|
150 |
* Gets current delivery country
|
|
|
151 |
* @return string
|
152 |
*/
|
153 |
-
public function getTargetCountry() {
|
154 |
-
return
|
155 |
}
|
156 |
|
157 |
/**
|
158 |
* is target delivery country allowed from source country
|
|
|
159 |
* @return bool
|
160 |
*/
|
161 |
-
public function isAllowedTargetCountry(){
|
162 |
|
163 |
-
$config =
|
164 |
|
165 |
$countryValidator = new Zend_Validate_InArray(array_keys($config->foreign->countries));
|
166 |
-
return $countryValidator->isValid(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
}
|
168 |
|
169 |
/**
|
170 |
-
*
|
171 |
-
*
|
|
|
|
|
172 |
*/
|
173 |
-
public function
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
175 |
}
|
176 |
|
177 |
/**
|
178 |
-
*
|
179 |
-
*
|
|
|
|
|
|
|
|
|
180 |
*/
|
181 |
-
public function
|
182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
}
|
184 |
}
|
32 |
|
33 |
/**
|
34 |
* Check if destination of current shipment is for other country than origin shipping country of current store
|
35 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
36 |
* @return bool|null
|
37 |
*/
|
38 |
+
public function isDomestic($shipment) {
|
39 |
+
//$shipment = SynergeticAgency_Gls_Helper_Validate::getCurrentShipment();
|
40 |
$return = null;
|
41 |
if($shipment) {
|
42 |
+
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $shipment->getStore());
|
43 |
$destCountry = $shipment->getShippingAddress()->getCountryId();
|
44 |
$return = $storeCountry == $destCountry;
|
45 |
}
|
48 |
|
49 |
/**
|
50 |
* Shipment to parcel shop? True if a parcel shop ID is given
|
51 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
52 |
* @return bool
|
53 |
*/
|
54 |
+
public function isParcelshopDelivery($shipment) {
|
55 |
+
$parcelShopId = $shipment->getShippingAddress()->getParcelshopId();
|
56 |
return !empty($parcelShopId);
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
* Gets Json Config for specific origin country supplied by gls
|
61 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
62 |
* @return string
|
63 |
*/
|
64 |
+
public function getJsonConfig($shipment) {
|
65 |
$jsonData = '{}';
|
66 |
+
if($shipment) {
|
|
|
67 |
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID,
|
68 |
+
$shipment->getStore());
|
69 |
|
70 |
$jsonConfig = Mage::getModel('synergeticagency_gls/jsonimport')->getCountry($storeCountry);
|
71 |
if($jsonConfig) {
|
79 |
|
80 |
/**
|
81 |
* Gets config for specific origin country supplied by gls
|
82 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
83 |
* @return string
|
84 |
*/
|
85 |
+
public function getConfig($shipment) {
|
86 |
$jsonConfig = '';
|
87 |
+
if($shipment) {
|
88 |
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID,
|
89 |
+
$shipment->getStore());
|
90 |
|
91 |
$jsonConfig = Mage::getModel('synergeticagency_gls/jsonimport')->getCountry($storeCountry);
|
92 |
|
96 |
|
97 |
/**
|
98 |
* get country config as json
|
99 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
100 |
* @return string
|
101 |
*/
|
102 |
+
public function getCountriesJson($shipment) {
|
|
|
103 |
$jsonData = '{}';
|
104 |
if($shipment) {
|
105 |
+
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $shipment->getStore());
|
106 |
$glsCountry = Mage::getModel('synergeticagency_gls/country')->load($storeCountry);
|
107 |
if($glsCountry->getId()) {
|
108 |
$jsonData = Mage::helper('core')->jsonEncode($glsCountry->getData());
|
113 |
|
114 |
/**
|
115 |
* get country config
|
116 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
117 |
* @return string
|
118 |
*/
|
119 |
+
public function getCountriesConfig($shipment) {
|
120 |
+
$glsCountry = null;
|
121 |
if($shipment) {
|
122 |
+
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $shipment->getStore());
|
123 |
$glsCountry = Mage::getModel('synergeticagency_gls/country')->load($storeCountry);
|
124 |
}
|
125 |
return $glsCountry;
|
144 |
|
145 |
/**
|
146 |
* Get the current shipment method. Shipment methods are actually combinations of gls services
|
147 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
148 |
* @return int
|
149 |
*/
|
150 |
+
public function getParcelShopCombinationId($shipment) {
|
151 |
+
return $this->isDomestic($shipment) ? SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_SHOPDELIVERY : SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL_SHOPDELIVERY;
|
152 |
}
|
153 |
|
154 |
/**
|
155 |
* Gets current delivery country
|
156 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
157 |
* @return string
|
158 |
*/
|
159 |
+
public function getTargetCountry($shipment) {
|
160 |
+
return $shipment->getShippingAddress()->getCountryId();
|
161 |
}
|
162 |
|
163 |
/**
|
164 |
* is target delivery country allowed from source country
|
165 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
166 |
* @return bool
|
167 |
*/
|
168 |
+
public function isAllowedTargetCountry($shipment){
|
169 |
|
170 |
+
$config = $this->getConfig($shipment);
|
171 |
|
172 |
$countryValidator = new Zend_Validate_InArray(array_keys($config->foreign->countries));
|
173 |
+
return $countryValidator->isValid($this->getTargetCountry($shipment));
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Returns true, if current shipping method is a GLS "Standard" shipping
|
178 |
+
* Otherwise, this function returns false
|
179 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
180 |
+
* @return bool
|
181 |
+
*/
|
182 |
+
public function isStandardShipping($shipment) {
|
183 |
+
return $shipment->getOrder()->getShippingMethod() == SynergeticAgency_Gls_Model_Carrier::CODE.'_'.SynergeticAgency_Gls_Model_Carrier::SHIPPING_RATE_STANDARD;
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Returns true, if current shipping method is a GLS "Express" shipping
|
188 |
+
* Otherwise, this function returns false
|
189 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
190 |
+
* @return bool
|
191 |
+
*/
|
192 |
+
public function isExpressShipping($shipment) {
|
193 |
+
return $shipment->getOrder()->getShippingMethod() == SynergeticAgency_Gls_Model_Carrier::CODE.'_'.SynergeticAgency_Gls_Model_Carrier::SHIPPING_RATE_EXPRESS;
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Returns true, if current shipping method is a GLS "Foreign" shipping
|
198 |
+
* Otherwise, this function returns false
|
199 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
200 |
+
* @return bool
|
201 |
+
*/
|
202 |
+
public function isForeignShipping($shipment) {
|
203 |
+
return $shipment->getOrder()->getShippingMethod() == SynergeticAgency_Gls_Model_Carrier::CODE.'_'.SynergeticAgency_Gls_Model_Carrier::SHIPPING_RATE_FOREIGNCOUNTRIES;
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
+
* Returns true, if payment method of current shipping is an instance of SynergeticAgency_Gls_Model_Glscashondelivery
|
208 |
+
* Returns false, if payment method of current shipping is not an instance of SynergeticAgency_Gls_Model_Glscashondelivery
|
209 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
210 |
+
* @return bool
|
211 |
*/
|
212 |
+
public function isCashService($shipment) {
|
213 |
+
if($shipment) {
|
214 |
+
if($shipment->getOrder()->getPayment()->getMethodInstance() instanceof SynergeticAgency_Gls_Model_Glscashondelivery) {
|
215 |
+
return true;
|
216 |
+
}
|
217 |
+
}
|
218 |
+
return false;
|
219 |
}
|
220 |
|
221 |
/**
|
222 |
+
* Returns true, if given country code(ISO-3166 Alpha 2) matches to the configured country of current store
|
223 |
+
* Returns false, if given country code(ISO-3166 Alpha 2) does nit match to the configured country of current store
|
224 |
+
*
|
225 |
+
* @param $countryCode
|
226 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
227 |
+
* @return bool
|
228 |
*/
|
229 |
+
public function matchCountry( $countryCode, $shipment ) {
|
230 |
+
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $shipment->getStore());
|
231 |
+
return strtoupper( $storeCountry ) === strtoupper( $countryCode );
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Returns true, if destination of current shipment is allowed by current Magento store configuration and GLS basis configuration.
|
236 |
+
* Returns false, if destination of current shipment is not allowed by current Magento store configuration and GLS basis configuration.
|
237 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
238 |
+
* @return bool
|
239 |
+
*/
|
240 |
+
public function isCountryAvailable($shipment) {
|
241 |
+
$glsModel = Mage::getModel('synergeticagency_gls/gls');
|
242 |
+
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $shipment->getStore());
|
243 |
+
$destCountry = $shipment->getShippingAddress()->getCountryId();
|
244 |
+
return ($glsModel->isCountryOriginIdAvailable($storeCountry)
|
245 |
+
&& ($this->isDomestic($shipment) || $glsModel->isDestinationCountryAvailable($storeCountry,$destCountry)));
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* @param int $combinationId
|
250 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
251 |
+
* @return bool
|
252 |
+
*/
|
253 |
+
public function isCombinationValid($combinationId,$shipment) {
|
254 |
+
$return = false;
|
255 |
+
switch ($combinationId) {
|
256 |
+
case SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL:
|
257 |
+
if($this->isDomestic($shipment) && !$this->isParcelshopDelivery($shipment) && !$this->isCashService($shipment)) {
|
258 |
+
$return = true;
|
259 |
+
}
|
260 |
+
break;
|
261 |
+
case SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_GUARANTEED:
|
262 |
+
if($this->isDomestic($shipment)) {
|
263 |
+
$return = true;
|
264 |
+
}
|
265 |
+
break;
|
266 |
+
case SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_SHOPDELIVERY:
|
267 |
+
if($this->isDomestic($shipment) && $this->isParcelshopDelivery($shipment)) {
|
268 |
+
$return = true;
|
269 |
+
}
|
270 |
+
break;
|
271 |
+
case SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_CASHSERVICE:
|
272 |
+
if($this->isDomestic($shipment) && $this->isCashService($shipment)) {
|
273 |
+
$return = true;
|
274 |
+
}
|
275 |
+
break;
|
276 |
+
case SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL:
|
277 |
+
if((!$this->isDomestic($shipment) || $this->matchCountry('FI',$shipment)) && !$this->isParcelshopDelivery($shipment) && $this->isForeignShipping($shipment)) {
|
278 |
+
$return = true;
|
279 |
+
}
|
280 |
+
break;
|
281 |
+
case SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL_SHOPDELIVERY:
|
282 |
+
if(!$this->isDomestic($shipment) && $this->isParcelshopDelivery($shipment)) {
|
283 |
+
$return = true;
|
284 |
+
}
|
285 |
+
break;
|
286 |
+
}
|
287 |
+
return $return;
|
288 |
}
|
289 |
}
|
app/code/community/SynergeticAgency/Gls/Model/Carrier.php
CHANGED
@@ -136,7 +136,6 @@ class SynergeticAgency_Gls_Model_Carrier
|
|
136 |
foreach ($this->_shippingConfigKeys AS $deliveryConfigKey) {
|
137 |
//@todo check price and name here as well and if empty disable
|
138 |
if($this->_glsConfig['active_'.$deliveryConfigKey] == '1'){
|
139 |
-
/** @var _Shipping_Helper_Data $expressMaxProducts */
|
140 |
$methodName = '_get'.Mage::helper('synergeticagency_gls')->underlineToCamelCase($deliveryConfigKey, TRUE).'Rate';
|
141 |
if(method_exists($this, $methodName)) {
|
142 |
$methodResult = $this->{$methodName}();
|
136 |
foreach ($this->_shippingConfigKeys AS $deliveryConfigKey) {
|
137 |
//@todo check price and name here as well and if empty disable
|
138 |
if($this->_glsConfig['active_'.$deliveryConfigKey] == '1'){
|
|
|
139 |
$methodName = '_get'.Mage::helper('synergeticagency_gls')->underlineToCamelCase($deliveryConfigKey, TRUE).'Rate';
|
140 |
if(method_exists($this, $methodName)) {
|
141 |
$methodResult = $this->{$methodName}();
|
app/code/community/SynergeticAgency/Gls/Model/Country.php
CHANGED
@@ -58,4 +58,19 @@ class SynergeticAgency_Gls_Model_Country extends Mage_Core_Model_Abstract {
|
|
58 |
}
|
59 |
return $this->_options;
|
60 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
58 |
}
|
59 |
return $this->_options;
|
60 |
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @param int $combinationId
|
64 |
+
* @return null|SynergeticAgency_Gls_Model_Resource_Service_Collection
|
65 |
+
*/
|
66 |
+
public function getAddonServicesByCombination($combinationId) {
|
67 |
+
$options = $this->getOptions();
|
68 |
+
if(empty($options)) return null;
|
69 |
+
foreach($options as $option) {
|
70 |
+
if($option->getCombination()->getId() == $combinationId) {
|
71 |
+
return $option->getAddonServices();
|
72 |
+
}
|
73 |
+
}
|
74 |
+
return null;
|
75 |
+
}
|
76 |
}
|
app/code/community/SynergeticAgency/Gls/Model/Gls.php
CHANGED
@@ -42,6 +42,15 @@ class SynergeticAgency_Gls_Model_Gls extends Mage_Core_Model_Abstract {
|
|
42 |
const SERVICE_GUARANTEED = 6;
|
43 |
const SERVICE_SHOPDELIVERY = 7;
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
/**
|
46 |
* Returns an array with available gls products available for inland shipping.
|
47 |
* A gls product in this module is a combination of gls services wrapped up to a product for better usability.
|
@@ -208,6 +217,140 @@ class SynergeticAgency_Gls_Model_Gls extends Mage_Core_Model_Abstract {
|
|
208 |
return $cashMax >= $grandTotal;
|
209 |
}
|
210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
/**
|
212 |
* Saves a GLS shipment. Shipments are saved in modules DB Tables additionally to the Magento Tables
|
213 |
* @param array $data
|
@@ -338,19 +481,19 @@ class SynergeticAgency_Gls_Model_Gls extends Mage_Core_Model_Abstract {
|
|
338 |
* Returns true if $data is valid
|
339 |
* Returns HTML formatted error string containing information of invalid data
|
340 |
* @param array $data
|
|
|
341 |
* @return bool|string
|
342 |
-
*
|
343 |
*/
|
344 |
-
public function validateGlsShipmentData($data) {
|
345 |
|
346 |
$validationResult = array();
|
347 |
|
348 |
-
$validationResult[] = $this->isValidWeight($data);
|
349 |
-
$validationResult[] = $this->isValidCashAmount($data);
|
350 |
$validationResult[] = $this->isValidShippingDate($data);
|
351 |
-
$validationResult[] = $this->isValidCashService($data);
|
352 |
-
$validationResult[] = $this->hasValidServices($data);
|
353 |
-
$validationResult[] = $this->isValidDestinationCountry($data);
|
354 |
$errorString = '';
|
355 |
foreach($validationResult AS $messages){
|
356 |
foreach($messages AS $message){
|
@@ -370,30 +513,31 @@ class SynergeticAgency_Gls_Model_Gls extends Mage_Core_Model_Abstract {
|
|
370 |
* Check if parcels weight(s) is(are)within allowed maximum weight in respect of given parcel data and the corresponding configuration
|
371 |
* In case the check is negative an appropriate error message(s) is getting returned (Zend validation)
|
372 |
* @param $data
|
|
|
373 |
* @return array
|
374 |
* @throws Zend_Locale_Exception
|
375 |
* @throws Zend_Validate_Exception
|
376 |
*/
|
377 |
-
public function isValidWeight($data){
|
378 |
|
379 |
$minWeight = 0.01;
|
380 |
|
381 |
$helper = Mage::helper('synergeticagency_gls/validate');
|
382 |
-
$config = $helper->getConfig();
|
383 |
-
$symbols = Zend_Locale_Data::getList(Mage::getStoreConfig('general/locale/code', $
|
384 |
|
385 |
-
switch($helper->isDomestic()){
|
386 |
case false:
|
387 |
-
switch($helper->isParcelshopDelivery()) {
|
388 |
case true:
|
389 |
-
$maxWeight = $config->foreign->countries->{$helper->getTargetCountry()}->parcelshopweight;
|
390 |
break;
|
391 |
default:
|
392 |
-
$maxWeight = $config->foreign->countries->{$helper->getTargetCountry()}->maxweight;
|
393 |
}
|
394 |
break;
|
395 |
default:
|
396 |
-
switch($helper->isParcelshopDelivery()) {
|
397 |
case true:
|
398 |
$maxWeight = $config->domestic->parcelshopweight;
|
399 |
break;
|
@@ -418,21 +562,22 @@ class SynergeticAgency_Gls_Model_Gls extends Mage_Core_Model_Abstract {
|
|
418 |
* Check if parcels cash on delivery amount(s) is(are)within allowed amount in respect of given parcel data and the corresponding configuration.
|
419 |
* In case the check is negative an appropriate error message(s) is getting returned (Zend validation)
|
420 |
* @param $data
|
|
|
421 |
* @return array
|
422 |
* @throws Zend_Locale_Exception
|
423 |
* @throws Zend_Validate_Exception
|
424 |
*/
|
425 |
-
public function isValidCashAmount($data){
|
426 |
|
427 |
$minAmount = 0.00;
|
428 |
|
429 |
$helper = Mage::helper('synergeticagency_gls/validate');
|
430 |
-
$config = $helper->getConfig();
|
431 |
-
$symbols = Zend_Locale_Data::getList(Mage::getStoreConfig('general/locale/code', $
|
432 |
|
433 |
-
switch($helper->isDomestic()){
|
434 |
case false:
|
435 |
-
$maxAmount = $config->foreign->countries->{$helper->getTargetCountry()}->cashmax;
|
436 |
break;
|
437 |
default:
|
438 |
$maxAmount = $config->domestic->cashmax;
|
@@ -476,13 +621,14 @@ class SynergeticAgency_Gls_Model_Gls extends Mage_Core_Model_Abstract {
|
|
476 |
* Check if submitted service combination is allowed
|
477 |
* In case the check is negative an appropriate error message(s) is getting returned (Zend validation)
|
478 |
* @param $data
|
|
|
479 |
* @return array
|
480 |
* @throws Zend_Validate_Exception
|
481 |
*/
|
482 |
-
public function hasValidServices($data){
|
483 |
|
484 |
$helper = Mage::helper('synergeticagency_gls/validate');
|
485 |
-
$countryConfig = $helper->getCountriesConfig();
|
486 |
$selectedCombination = $helper->getCombinationByCombinationId($countryConfig->options, $data['shipment']['gls']['combination']);
|
487 |
|
488 |
$serviceValidator = new Zend_Validate_InArray($selectedCombination['addon_services']);
|
@@ -505,15 +651,16 @@ class SynergeticAgency_Gls_Model_Gls extends Mage_Core_Model_Abstract {
|
|
505 |
* businessparcel vs. europarcel
|
506 |
* business parcel is just allowed for domestic shipment europarcel is just allowed for foreign country shipment
|
507 |
* @param $data
|
|
|
508 |
* @return array
|
509 |
*/
|
510 |
-
public function isValidDestinationCountry($data)
|
511 |
{
|
512 |
$helper = Mage::helper('synergeticagency_gls/validate');
|
513 |
-
$countryConfig = $helper->getCountriesConfig();
|
514 |
$selectedCombination = $helper->getCombinationByCombinationId($countryConfig->options, $data['shipment']['gls']['combination']);
|
515 |
$messages = array();
|
516 |
-
if((false === $selectedCombination['domestic'] && true === $helper->isDomestic()) || (false === $selectedCombination['foreign'] && false === $helper->isDomestic())){
|
517 |
$messages[0] = Mage::helper('synergeticagency_gls')->__("The selected product is not allowed for shipments target country");
|
518 |
}
|
519 |
|
@@ -523,12 +670,13 @@ class SynergeticAgency_Gls_Model_Gls extends Mage_Core_Model_Abstract {
|
|
523 |
/**
|
524 |
* Check if parcels cash on delivery is(are) allowed in respect of given package data and the corresponding configuration
|
525 |
* @param $data
|
|
|
526 |
* @return array
|
527 |
*/
|
528 |
-
public function isValidCashService($data)
|
529 |
{
|
530 |
$helper = Mage::helper('synergeticagency_gls/validate');
|
531 |
-
$countryConfig = $helper->getCountriesConfig();
|
532 |
$selectedCombination = $helper->getCombinationByCombinationId($countryConfig->options, $data['shipment']['gls']['combination']);
|
533 |
$messages = array();
|
534 |
foreach($data['shipment']['packages'] AS $package){
|
42 |
const SERVICE_GUARANTEED = 6;
|
43 |
const SERVICE_SHOPDELIVERY = 7;
|
44 |
|
45 |
+
const GLS_WEIGHT_UNIT_KG = 'kg';
|
46 |
+
const GLS_WEIGHT_UNIT_G = 'g';
|
47 |
+
|
48 |
+
const GLS_STATUS_PENDING = 'pending_gls';
|
49 |
+
const GLS_STATUS_PENDING_ERROR = 'pending_gls_error';
|
50 |
+
const GLS_STATUS_PROCESSING = 'processing_gls';
|
51 |
+
const GLS_STATUS_PROCESSING_ERROR = 'processing_gls_error';
|
52 |
+
const GLS_STATUS_COMPLETE = 'complete_gls';
|
53 |
+
|
54 |
/**
|
55 |
* Returns an array with available gls products available for inland shipping.
|
56 |
* A gls product in this module is a combination of gls services wrapped up to a product for better usability.
|
217 |
return $cashMax >= $grandTotal;
|
218 |
}
|
219 |
|
220 |
+
/**
|
221 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
222 |
+
* @return array
|
223 |
+
*/
|
224 |
+
public function prepareGlsShipmentData($shipment) {
|
225 |
+
$glsData = array();
|
226 |
+
$combination = $this->getCombinationByShipment($shipment);
|
227 |
+
if(!$combination) {
|
228 |
+
return false;
|
229 |
+
}
|
230 |
+
$service = $this->getServicesByCombinationAndShipment($combination,$shipment);
|
231 |
+
$glsData['combination'] = $combination;
|
232 |
+
$glsData['service'] = $service;
|
233 |
+
$glsData['shipping_date'] = date('Y-m-d'); // today
|
234 |
+
$glsData['return_label'] = Mage::getStoreConfig('gls/shipment/return_label_enabled',$shipment->getStore());
|
235 |
+
$weight = 0;
|
236 |
+
$items = $shipment->getOrder()->getAllItems();
|
237 |
+
if(count($items)) {
|
238 |
+
foreach($items as $item) {
|
239 |
+
$weight += (float)$item->getWeight() * (int)$item->getQtyOrdered();
|
240 |
+
}
|
241 |
+
}
|
242 |
+
if(empty($weight)) {
|
243 |
+
$weight = Mage::getStoreConfig('gls/shipment/weight', $shipment->getStore());
|
244 |
+
}
|
245 |
+
if(empty($weight)) {
|
246 |
+
return false;
|
247 |
+
}
|
248 |
+
// get unit
|
249 |
+
$weightUnit = Mage::getStoreConfig('gls/shipment/weight_unit', $shipment->getStore());
|
250 |
+
if($weightUnit == self::GLS_WEIGHT_UNIT_G) {
|
251 |
+
$weight = round($weight/1000,3);
|
252 |
+
}
|
253 |
+
// value should be greater than 0.1
|
254 |
+
if($weight <= 0.1 ) {
|
255 |
+
return false;
|
256 |
+
}
|
257 |
+
|
258 |
+
if(Mage::helper('synergeticagency_gls/validate')->isCashService($shipment)) {
|
259 |
+
$cashService = $shipment->getStore()->roundPrice($shipment->getOrder()->getGrandTotal());
|
260 |
+
$packages = array(
|
261 |
+
'weight' => $weight,
|
262 |
+
'cashservice' => $cashService
|
263 |
+
);
|
264 |
+
} else {
|
265 |
+
$packages = array(
|
266 |
+
'weight' => $weight
|
267 |
+
);
|
268 |
+
}
|
269 |
+
$data['shipment']['gls'] = $glsData;
|
270 |
+
$data['shipment']['packages'][] = $packages;
|
271 |
+
|
272 |
+
return $data;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* @param int $combinationId
|
277 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
278 |
+
* @param bool $withDefault
|
279 |
+
* @return array
|
280 |
+
*/
|
281 |
+
public function getServicesByCombinationAndShipment($combinationId,$shipment,$withDefault=true) {
|
282 |
+
// for the moment there is no condition in the order that can trigger a service
|
283 |
+
// because think green is not available in the frontend anymore
|
284 |
+
// but we have to check the default services
|
285 |
+
if(!$withDefault) {
|
286 |
+
return array();
|
287 |
+
}
|
288 |
+
|
289 |
+
$defaultServices = Mage::getStoreConfig('gls/shipment/default_services', $shipment->getStore());
|
290 |
+
if(empty($defaultServices)) {
|
291 |
+
return array();
|
292 |
+
}
|
293 |
+
|
294 |
+
$defaultServices = explode(',',$defaultServices);
|
295 |
+
foreach ($defaultServices as &$defaultService) {
|
296 |
+
$defaultService = intval($defaultService);
|
297 |
+
}
|
298 |
+
|
299 |
+
$storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $shipment->getStore());
|
300 |
+
$glsCountry = Mage::getModel('synergeticagency_gls/country')->load($storeCountry);
|
301 |
+
if(empty($glsCountry)) return array();
|
302 |
+
$services = $glsCountry->getAddonServicesByCombination($combinationId);
|
303 |
+
$serviceReturn = array();
|
304 |
+
/** @var SynergeticAgency_Gls_Model_Service $service */
|
305 |
+
if($services && count($services)) {
|
306 |
+
foreach ($services as $service) {
|
307 |
+
if (in_array($service->getId(), $defaultServices)) {
|
308 |
+
$serviceReturn[$service->getId()] = $service->getId(); // important to have the id as key because that is the value used later on
|
309 |
+
}
|
310 |
+
}
|
311 |
+
}
|
312 |
+
return $serviceReturn;
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
317 |
+
* @param bool $withDefault
|
318 |
+
* @return bool|int
|
319 |
+
*/
|
320 |
+
public function getCombinationByShipment($shipment,$withDefault=true) {
|
321 |
+
$helper = Mage::helper('synergeticagency_gls/validate');
|
322 |
+
if($helper->isDomestic($shipment) && ($helper->isStandardShipping($shipment)) && !$helper->isParcelshopDelivery($shipment) && !$helper->isCashService($shipment)) {
|
323 |
+
return SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL;
|
324 |
+
}
|
325 |
+
if($helper->isDomestic($shipment) && $helper->isExpressShipping($shipment)) {
|
326 |
+
return SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_GUARANTEED;
|
327 |
+
}
|
328 |
+
if($helper->isDomestic($shipment) && $helper->isParcelshopDelivery($shipment)) {
|
329 |
+
return SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_SHOPDELIVERY;
|
330 |
+
}
|
331 |
+
if($helper->isDomestic($shipment) && $helper->isCashService($shipment)) {
|
332 |
+
return SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_CASHSERVICE;
|
333 |
+
}
|
334 |
+
if((!$helper->isDomestic($shipment) || $helper->matchCountry('FI',$shipment)) && !$helper->isParcelshopDelivery($shipment) && $helper->isForeignShipping($shipment)) {
|
335 |
+
return SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL;
|
336 |
+
}
|
337 |
+
if(!$helper->isDomestic($shipment) && $helper->isParcelshopDelivery($shipment)) {
|
338 |
+
return SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL_SHOPDELIVERY;
|
339 |
+
}
|
340 |
+
if($withDefault) {
|
341 |
+
// none matched get the default
|
342 |
+
$defaultCombination = Mage::getStoreConfig('gls/shipment/default_combination', $shipment->getStore());
|
343 |
+
if (empty($defaultCombination)) {
|
344 |
+
return false;
|
345 |
+
}
|
346 |
+
// check if default combination is valid
|
347 |
+
if ($helper->isCombinationValid($defaultCombination, $shipment)) {
|
348 |
+
return $defaultCombination;
|
349 |
+
}
|
350 |
+
}
|
351 |
+
return false;
|
352 |
+
}
|
353 |
+
|
354 |
/**
|
355 |
* Saves a GLS shipment. Shipments are saved in modules DB Tables additionally to the Magento Tables
|
356 |
* @param array $data
|
481 |
* Returns true if $data is valid
|
482 |
* Returns HTML formatted error string containing information of invalid data
|
483 |
* @param array $data
|
484 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
485 |
* @return bool|string
|
|
|
486 |
*/
|
487 |
+
public function validateGlsShipmentData($data,$shipment) {
|
488 |
|
489 |
$validationResult = array();
|
490 |
|
491 |
+
$validationResult[] = $this->isValidWeight($data,$shipment);
|
492 |
+
$validationResult[] = $this->isValidCashAmount($data,$shipment);
|
493 |
$validationResult[] = $this->isValidShippingDate($data);
|
494 |
+
$validationResult[] = $this->isValidCashService($data,$shipment);
|
495 |
+
$validationResult[] = $this->hasValidServices($data,$shipment);
|
496 |
+
$validationResult[] = $this->isValidDestinationCountry($data,$shipment);
|
497 |
$errorString = '';
|
498 |
foreach($validationResult AS $messages){
|
499 |
foreach($messages AS $message){
|
513 |
* Check if parcels weight(s) is(are)within allowed maximum weight in respect of given parcel data and the corresponding configuration
|
514 |
* In case the check is negative an appropriate error message(s) is getting returned (Zend validation)
|
515 |
* @param $data
|
516 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
517 |
* @return array
|
518 |
* @throws Zend_Locale_Exception
|
519 |
* @throws Zend_Validate_Exception
|
520 |
*/
|
521 |
+
public function isValidWeight($data,$shipment){
|
522 |
|
523 |
$minWeight = 0.01;
|
524 |
|
525 |
$helper = Mage::helper('synergeticagency_gls/validate');
|
526 |
+
$config = $helper->getConfig($shipment);
|
527 |
+
$symbols = Zend_Locale_Data::getList(Mage::getStoreConfig('general/locale/code', $shipment->getStore()) , 'symbols');
|
528 |
|
529 |
+
switch($helper->isDomestic($shipment)){
|
530 |
case false:
|
531 |
+
switch($helper->isParcelshopDelivery($shipment)) {
|
532 |
case true:
|
533 |
+
$maxWeight = $config->foreign->countries->{$helper->getTargetCountry($shipment)}->parcelshopweight;
|
534 |
break;
|
535 |
default:
|
536 |
+
$maxWeight = $config->foreign->countries->{$helper->getTargetCountry($shipment)}->maxweight;
|
537 |
}
|
538 |
break;
|
539 |
default:
|
540 |
+
switch($helper->isParcelshopDelivery($shipment)) {
|
541 |
case true:
|
542 |
$maxWeight = $config->domestic->parcelshopweight;
|
543 |
break;
|
562 |
* Check if parcels cash on delivery amount(s) is(are)within allowed amount in respect of given parcel data and the corresponding configuration.
|
563 |
* In case the check is negative an appropriate error message(s) is getting returned (Zend validation)
|
564 |
* @param $data
|
565 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
566 |
* @return array
|
567 |
* @throws Zend_Locale_Exception
|
568 |
* @throws Zend_Validate_Exception
|
569 |
*/
|
570 |
+
public function isValidCashAmount($data,$shipment){
|
571 |
|
572 |
$minAmount = 0.00;
|
573 |
|
574 |
$helper = Mage::helper('synergeticagency_gls/validate');
|
575 |
+
$config = $helper->getConfig($shipment);
|
576 |
+
$symbols = Zend_Locale_Data::getList(Mage::getStoreConfig('general/locale/code', $shipment->getStore()) , 'symbols');
|
577 |
|
578 |
+
switch($helper->isDomestic($shipment)){
|
579 |
case false:
|
580 |
+
$maxAmount = $config->foreign->countries->{$helper->getTargetCountry($shipment)}->cashmax;
|
581 |
break;
|
582 |
default:
|
583 |
$maxAmount = $config->domestic->cashmax;
|
621 |
* Check if submitted service combination is allowed
|
622 |
* In case the check is negative an appropriate error message(s) is getting returned (Zend validation)
|
623 |
* @param $data
|
624 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
625 |
* @return array
|
626 |
* @throws Zend_Validate_Exception
|
627 |
*/
|
628 |
+
public function hasValidServices($data,$shipment){
|
629 |
|
630 |
$helper = Mage::helper('synergeticagency_gls/validate');
|
631 |
+
$countryConfig = $helper->getCountriesConfig($shipment);
|
632 |
$selectedCombination = $helper->getCombinationByCombinationId($countryConfig->options, $data['shipment']['gls']['combination']);
|
633 |
|
634 |
$serviceValidator = new Zend_Validate_InArray($selectedCombination['addon_services']);
|
651 |
* businessparcel vs. europarcel
|
652 |
* business parcel is just allowed for domestic shipment europarcel is just allowed for foreign country shipment
|
653 |
* @param $data
|
654 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
655 |
* @return array
|
656 |
*/
|
657 |
+
public function isValidDestinationCountry($data,$shipment)
|
658 |
{
|
659 |
$helper = Mage::helper('synergeticagency_gls/validate');
|
660 |
+
$countryConfig = $helper->getCountriesConfig($shipment);
|
661 |
$selectedCombination = $helper->getCombinationByCombinationId($countryConfig->options, $data['shipment']['gls']['combination']);
|
662 |
$messages = array();
|
663 |
+
if((false === $selectedCombination['domestic'] && true === $helper->isDomestic($shipment)) || (false === $selectedCombination['foreign'] && false === $helper->isDomestic($shipment))){
|
664 |
$messages[0] = Mage::helper('synergeticagency_gls')->__("The selected product is not allowed for shipments target country");
|
665 |
}
|
666 |
|
670 |
/**
|
671 |
* Check if parcels cash on delivery is(are) allowed in respect of given package data and the corresponding configuration
|
672 |
* @param $data
|
673 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
674 |
* @return array
|
675 |
*/
|
676 |
+
public function isValidCashService($data,$shipment)
|
677 |
{
|
678 |
$helper = Mage::helper('synergeticagency_gls/validate');
|
679 |
+
$countryConfig = $helper->getCountriesConfig($shipment);
|
680 |
$selectedCombination = $helper->getCombinationByCombinationId($countryConfig->options, $data['shipment']['gls']['combination']);
|
681 |
$messages = array();
|
682 |
foreach($data['shipment']['packages'] AS $package){
|
app/code/community/SynergeticAgency/Gls/Model/Massprint.php
ADDED
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category SynergetigAgency
|
22 |
+
* @package SynergeticAgency\Gls\Model
|
23 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Class SynergeticAgency_Gls_Model_Massprint
|
29 |
+
*/
|
30 |
+
class SynergeticAgency_Gls_Model_Massprint extends Mage_Core_Model_Abstract{
|
31 |
+
|
32 |
+
private $_lockFile;
|
33 |
+
private $_lockFilePath;
|
34 |
+
private $_debug=false;
|
35 |
+
/**
|
36 |
+
* Constructor - instantiate parent constructor and set path to config file
|
37 |
+
*/
|
38 |
+
function _construct() {
|
39 |
+
parent::_construct();
|
40 |
+
$this->_lockFilePath = Mage::getBaseDir('var') . DS . 'tmp' . DS . 'gls' . DS . 'massprint';
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* runs normally with cron
|
45 |
+
* background process for printing gls labels
|
46 |
+
*/
|
47 |
+
public function run(){
|
48 |
+
// locking with lockfile - process should run only once at a time
|
49 |
+
try {
|
50 |
+
$this->lock();
|
51 |
+
} catch(Exception $e) {
|
52 |
+
if($this->getDebug()) {
|
53 |
+
echo "\n".$e->getMessage();
|
54 |
+
}
|
55 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, $e->getMessage(), Zend_Log::DEBUG );
|
56 |
+
return null;
|
57 |
+
}
|
58 |
+
|
59 |
+
// determine next job to work on
|
60 |
+
$jobCollection = Mage::getModel( 'synergeticagency_gls/shipment_job' )->getCollection();
|
61 |
+
|
62 |
+
$jobCollection
|
63 |
+
->addFieldToSelect('*')
|
64 |
+
->addFieldToFilter( 'completed',array('eq' => 0) )
|
65 |
+
//->addFieldToFilter( 'in_process',array('eq' => 0) )
|
66 |
+
->setOrder('gls_shipment_job_id', 'asc')
|
67 |
+
->setPageSize(1) // work on one job only
|
68 |
+
->setCurPage(1)
|
69 |
+
->load();
|
70 |
+
|
71 |
+
if(!$jobCollection->count()) {
|
72 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, 'No available jobs to process', Zend_Log::DEBUG);
|
73 |
+
return null;
|
74 |
+
}
|
75 |
+
|
76 |
+
/** @var Synergeticagency_Gls_Model_Shipment_Job $job */
|
77 |
+
$job = $jobCollection->getFirstItem();
|
78 |
+
|
79 |
+
if($this->getDebug()) {
|
80 |
+
echo "\nDATA FOUND: JobId=" . $job->getGlsShipmentJobId();
|
81 |
+
}
|
82 |
+
|
83 |
+
// actualize actual working status into jobs table
|
84 |
+
if(!$job->getInProcess()) {
|
85 |
+
$job->setInProcess(1);
|
86 |
+
$job->save();
|
87 |
+
}
|
88 |
+
|
89 |
+
$glsShipmentCollection = $job->getUnprintedShipments();
|
90 |
+
|
91 |
+
if($glsShipmentCollection->count()) {
|
92 |
+
foreach ($glsShipmentCollection as $glsShipment) {
|
93 |
+
$glsShipment = Mage::getModel('synergeticagency_gls/shipment')->load($glsShipment->getData('gls_shipment_id'));
|
94 |
+
// todo think about that... this sets the sandbox flag to the current setting and not the setting when it was created...
|
95 |
+
$glsShipment->setSandbox(Mage::getStoreConfig('gls/general/sandbox', $glsShipment->getStore()));
|
96 |
+
|
97 |
+
if($this->getDebug()) {
|
98 |
+
echo "\nwork on glsShipment with id " . $glsShipment->getData('gls_shipment_id');
|
99 |
+
}
|
100 |
+
|
101 |
+
try {
|
102 |
+
$labels = $glsShipment->getLabels();
|
103 |
+
$targetTmpLabelFile = DS . trim($glsShipment->getLabelTempPath(), DS) . DS .
|
104 |
+
$glsShipment::GLS_SHIPMENT_LABEL_PDF_PREFIX_JOB . $job->getId().'_'.$glsShipment->getConsignmentId() . ".pdf";
|
105 |
+
$glsShipment->saveLabel(
|
106 |
+
$glsShipment->getConnector()->combineLabels($labels),
|
107 |
+
$targetTmpLabelFile
|
108 |
+
);
|
109 |
+
$glsShipment->save(); // save the label path
|
110 |
+
$job->setQtyItemsSuccessful((Integer)$job->getQtyItemsSuccessful() + 1); // increase successful
|
111 |
+
} catch (Exception $e) {
|
112 |
+
if($this->getDebug()) {
|
113 |
+
echo "\nException, drop shipment " . $glsShipment->getData('gls_shipment_id') . " from job " . $glsShipment->getData('job_id');
|
114 |
+
}
|
115 |
+
$job->setQtyItemsError((Integer)$job->getQtyItemsError() + 1); // increase errors
|
116 |
+
$errorItems = $job->getErrorItems();
|
117 |
+
if(!empty($errorItems)) {
|
118 |
+
$errorItems = json_decode($errorItems);
|
119 |
+
} else {
|
120 |
+
$errorItems = array();
|
121 |
+
}
|
122 |
+
if($glsShipment->getMagentoShipment()) {
|
123 |
+
$errorItems[] = array(
|
124 |
+
'shipment_id' => $glsShipment->getMagentoShipment()->getId(),
|
125 |
+
'shipment_increment_id' => $glsShipment->getMagentoShipment()->getIncrementId(),
|
126 |
+
);
|
127 |
+
}
|
128 |
+
if(count($errorItems)) {
|
129 |
+
$job->setErrorItems(json_encode($errorItems));
|
130 |
+
}
|
131 |
+
// note, that $glsShipment->getLabels() will set printed to 1
|
132 |
+
// in case of an error, the shipment should not defined as "printed=1"
|
133 |
+
// It is also very important to drop a unsuccessful shipment from the job
|
134 |
+
$glsShipment->setJobId(NULL);
|
135 |
+
$glsShipment->setPrinted(0);
|
136 |
+
$glsShipment->save();
|
137 |
+
}
|
138 |
+
// update the job for displaying it in the current state in the backend
|
139 |
+
$job->setQtyItemsOpen((Integer)$job->getQtyItemsOpen() - 1);
|
140 |
+
$job->save();
|
141 |
+
$glsShipment->clearInstance(); // freeup ram
|
142 |
+
}// end: foreach
|
143 |
+
}
|
144 |
+
|
145 |
+
$glsShipments = $job->getShipments();
|
146 |
+
if(!$glsShipments->count()) {
|
147 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, 'Mass print job has no shipments', Zend_Log::ERR );
|
148 |
+
if($this->getDebug()) {
|
149 |
+
echo "\nMass print job has no shipments";
|
150 |
+
}
|
151 |
+
$job->setInProcess(0);
|
152 |
+
$job->setCompleted(1);
|
153 |
+
$job->setErrorMessage(Mage::helper("synergeticagency_gls")->__('Mass print job has no shipments'));
|
154 |
+
$job->save();
|
155 |
+
return null;
|
156 |
+
}
|
157 |
+
$massprintLabels = array();
|
158 |
+
$filesToDelete = array();
|
159 |
+
foreach($glsShipments as $glsShipment) {
|
160 |
+
$labelFile = $glsShipment->getPdfFile();
|
161 |
+
if(empty($labelFile)) {
|
162 |
+
if($this->getDebug()) {
|
163 |
+
echo "\nNo pdf file in shipment with id: ".$glsShipment->getId();
|
164 |
+
}
|
165 |
+
if(!$glsShipment->getErrorMessage()) {
|
166 |
+
// don't overwrite existing errors
|
167 |
+
$glsShipment->setErrorMessage(get_class($this).': '.Mage::helper("synergeticagency_gls")->__('No PDF-file or file is not readable'));
|
168 |
+
$glsShipment->setErrorCode(SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_MASS_LABEL_MISSING);
|
169 |
+
}
|
170 |
+
// remove it from job
|
171 |
+
$glsShipment->setJobId(NULL);
|
172 |
+
$glsShipment->setPrinted(0);
|
173 |
+
$glsShipment->save();
|
174 |
+
continue;
|
175 |
+
}
|
176 |
+
$file = Mage::getBaseDir().DS.$labelFile;
|
177 |
+
if(!is_file($file) || !is_readable($file)) {
|
178 |
+
if($this->getDebug()) {
|
179 |
+
echo "\nNo PDF-file or file is not readable in shipment with id: ".$glsShipment->getId();
|
180 |
+
}
|
181 |
+
if(!$glsShipment->getErrorMessage()) {
|
182 |
+
// don't overwrite existing errors
|
183 |
+
$glsShipment->setErrorMessage(get_class($this).': '.Mage::helper("synergeticagency_gls")->__('No PDF-file or file is not readable'));
|
184 |
+
$glsShipment->setErrorCode(SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_MASS_LABEL_MISSING);
|
185 |
+
}
|
186 |
+
// remove it from job
|
187 |
+
$glsShipment->setJobId(NULL);
|
188 |
+
$glsShipment->setPrinted(0);
|
189 |
+
$glsShipment->save();
|
190 |
+
continue;
|
191 |
+
}
|
192 |
+
$massprintLabels[] = file_get_contents($file);
|
193 |
+
$filesToDelete[] = $file;
|
194 |
+
}
|
195 |
+
|
196 |
+
if(!count($massprintLabels)) {
|
197 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, 'Mass print job has no labels to print', Zend_Log::ERR );
|
198 |
+
if($this->getDebug()) {
|
199 |
+
echo "\nMass print job has no labels to print";
|
200 |
+
}
|
201 |
+
$job->setInProcess(0);
|
202 |
+
$job->setCompleted(1);
|
203 |
+
$job->setErrorMessage(Mage::helper("synergeticagency_gls")->__('Mass print job has no labels to print'));
|
204 |
+
$job->save();
|
205 |
+
return null;
|
206 |
+
}
|
207 |
+
|
208 |
+
$connector = new SynergeticAgency_GlsConnector_Connector();
|
209 |
+
try {
|
210 |
+
$combinedLabel = $connector->combineLabels($massprintLabels);
|
211 |
+
if($combinedLabel === false) {
|
212 |
+
if($this->getDebug()) {
|
213 |
+
echo "\nPDF combination error: Check the logs for detail";
|
214 |
+
}
|
215 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, 'PDF combination error: Check the logs for details', Zend_Log::ERR );
|
216 |
+
$job->setErrorMessage(Mage::helper("synergeticagency_gls")->__('PDF combination error: Check the logs for details'));
|
217 |
+
// leave the job in an open state - so it can run again and someone has to take care about
|
218 |
+
$job->save();
|
219 |
+
return null;
|
220 |
+
}
|
221 |
+
$targetTmpCombinedLabelFile = DS . trim( $job->getLabelTempPath(), DS ) . DS .
|
222 |
+
$job::GLS_SHIPMENT_JOB_LABEL_PDF_PREFIX_JOB.$job->getId() . ".pdf";
|
223 |
+
$ret = file_put_contents($targetTmpCombinedLabelFile,$combinedLabel);
|
224 |
+
if($ret === false) {
|
225 |
+
if($this->getDebug()) {
|
226 |
+
echo "\nPDF could not be written: Check file system permissions";
|
227 |
+
}
|
228 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, 'PDF could not be written: Check file system permissions', Zend_Log::ERR );
|
229 |
+
$job->setErrorMessage(Mage::helper("synergeticagency_gls")->__('PDF could not be written: Check file system permissions'));
|
230 |
+
// leave the job in an open state - so it can run again and someone has to take care about
|
231 |
+
$job->save();
|
232 |
+
return null;
|
233 |
+
}
|
234 |
+
// job is done
|
235 |
+
$job->setPdfFile(trim(str_replace(Mage::getBaseDir(),'',$targetTmpCombinedLabelFile),DS));
|
236 |
+
$job->setInProcess(0);
|
237 |
+
$job->setCompleted(1);
|
238 |
+
$job->save();
|
239 |
+
} catch(Exception $e) {
|
240 |
+
if($this->getDebug()) {
|
241 |
+
echo "\n".$e->getMessage();
|
242 |
+
}
|
243 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, 'Unspecific Error: '.$e->getMessage(), Zend_Log::ERR );
|
244 |
+
$job->setErrorMessage(Mage::helper("synergeticagency_gls")->__('Unspecific Error:').' '.$e->getMessage());
|
245 |
+
// leave the job in an open state - so it can run again and someone has to take care about
|
246 |
+
$job->save();
|
247 |
+
return null;
|
248 |
+
}
|
249 |
+
|
250 |
+
// cleanup
|
251 |
+
if(count($filesToDelete)) {
|
252 |
+
foreach($filesToDelete as $fileToDelete) {
|
253 |
+
@unlink($fileToDelete);
|
254 |
+
}
|
255 |
+
foreach($glsShipments as $glsShipment) {
|
256 |
+
$glsShipment->setPdfFile(NULL);
|
257 |
+
$glsShipment->save();
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
|
262 |
+
$this->unlock();
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* locks lock file
|
267 |
+
* @throws Exception
|
268 |
+
*/
|
269 |
+
private function lock() {
|
270 |
+
//check locking
|
271 |
+
$this->_lockFile = fopen($this->_lockFilePath, 'w') or die('Cannot create lock file');
|
272 |
+
if (!flock($this->_lockFile, LOCK_EX | LOCK_NB)) {
|
273 |
+
throw new Exception("currently locked by another process");
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* unlocks the lock file
|
279 |
+
*/
|
280 |
+
private function unlock() {
|
281 |
+
fclose($this->_lockFile);
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* sets the internal debug flag for testing
|
286 |
+
* @param bool $var
|
287 |
+
* @return $this
|
288 |
+
*/
|
289 |
+
public function setDebug($var) {
|
290 |
+
$this->_debug = $var;
|
291 |
+
return $this;
|
292 |
+
}
|
293 |
+
|
294 |
+
/**
|
295 |
+
* @return bool
|
296 |
+
*/
|
297 |
+
public function getDebug() {
|
298 |
+
return $this->_debug;
|
299 |
+
}
|
300 |
+
|
301 |
+
}
|
app/code/community/SynergeticAgency/Gls/Model/Observer.php
CHANGED
@@ -48,7 +48,7 @@ class SynergeticAgency_Gls_Model_Observer {
|
|
48 |
|
49 |
// Checking if GLS module is active at all
|
50 |
if ($config['active'] == '1') {
|
51 |
-
|
52 |
// Getting Store Country to build logo path
|
53 |
$country = Mage::getStoreConfig('general/country/default');
|
54 |
$countryCode = strtolower(Mage::getModel('directory/country')->loadByCode($country)->getIso2Code());
|
@@ -120,6 +120,8 @@ class SynergeticAgency_Gls_Model_Observer {
|
|
120 |
return null;
|
121 |
endif;
|
122 |
|
|
|
|
|
123 |
$store = $shipment->getStore();
|
124 |
// Return if global gls config is disabled.
|
125 |
if (!Mage::getStoreConfig('gls/general/active' , $store)) {
|
@@ -134,13 +136,30 @@ class SynergeticAgency_Gls_Model_Observer {
|
|
134 |
}
|
135 |
|
136 |
// Return if validation fails.
|
137 |
-
if ( false === $this->_validateGlsShipmentData($data) ){
|
138 |
return null;
|
139 |
}
|
140 |
|
141 |
$glsModel = Mage::getModel('synergeticagency_gls/gls');
|
142 |
$glsModel->saveGlsShipment($data, $shipment);
|
|
|
|
|
|
|
|
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
}
|
145 |
|
146 |
|
@@ -148,9 +167,10 @@ class SynergeticAgency_Gls_Model_Observer {
|
|
148 |
* Server side validation of gls shipment data in sales_order view
|
149 |
* This validation should never be triggered due to client side validation
|
150 |
* @param $data
|
|
|
151 |
* @return bool
|
152 |
*/
|
153 |
-
public function _validateGlsShipmentData($data) {
|
154 |
|
155 |
if (empty($data['shipment']['packages']) ) {
|
156 |
return false;
|
@@ -160,7 +180,7 @@ class SynergeticAgency_Gls_Model_Observer {
|
|
160 |
return false;
|
161 |
}
|
162 |
|
163 |
-
$errorMessages = Mage::getModel('synergeticagency_gls/gls')->validateGlsShipmentData($data);
|
164 |
if(true !== $errorMessages) {
|
165 |
return false;
|
166 |
}
|
@@ -178,10 +198,11 @@ class SynergeticAgency_Gls_Model_Observer {
|
|
178 |
public function checkGlsShipmentData(Varien_Event_Observer $observer)
|
179 |
{
|
180 |
$data = Mage::app()->getRequest()->getPost();
|
|
|
181 |
//at the moment this method is also getting called when label is printed
|
182 |
//check if post data...
|
183 |
if(isset($data['shipment']['gls']) && isset($data['shipment']['gls']['ship_with_gls']) && $data['shipment']['gls']['ship_with_gls'] == '1') {
|
184 |
-
$check = Mage::getModel('synergeticagency_gls/gls')->validateGlsShipmentData($data);
|
185 |
if ($check !== true) {
|
186 |
Mage::register('gls_shipment_error', true);
|
187 |
Mage::throwException($check);
|
@@ -201,6 +222,7 @@ class SynergeticAgency_Gls_Model_Observer {
|
|
201 |
->getCollection()
|
202 |
->addFieldToFilter('order_id',$orderId)
|
203 |
->addFieldToFilter('printed','0')
|
|
|
204 |
->setOrder('gls_shipment_id');
|
205 |
$hasUnprintedGlsShipments = $glsShipmentCollection->count();
|
206 |
if($hasUnprintedGlsShipments) {
|
@@ -232,6 +254,28 @@ class SynergeticAgency_Gls_Model_Observer {
|
|
232 |
}
|
233 |
}
|
234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
/**
|
236 |
* @param Mage_Adminhtml_Block_Sales_Order_Grid $grid
|
237 |
* @throws Exception
|
48 |
|
49 |
// Checking if GLS module is active at all
|
50 |
if ($config['active'] == '1') {
|
51 |
+
$logos = array();
|
52 |
// Getting Store Country to build logo path
|
53 |
$country = Mage::getStoreConfig('general/country/default');
|
54 |
$countryCode = strtolower(Mage::getModel('directory/country')->loadByCode($country)->getIso2Code());
|
120 |
return null;
|
121 |
endif;
|
122 |
|
123 |
+
$helper = Mage::helper('synergeticagency_gls');
|
124 |
+
|
125 |
$store = $shipment->getStore();
|
126 |
// Return if global gls config is disabled.
|
127 |
if (!Mage::getStoreConfig('gls/general/active' , $store)) {
|
136 |
}
|
137 |
|
138 |
// Return if validation fails.
|
139 |
+
if ( false === $this->_validateGlsShipmentData($data,$shipment) ){
|
140 |
return null;
|
141 |
}
|
142 |
|
143 |
$glsModel = Mage::getModel('synergeticagency_gls/gls');
|
144 |
$glsModel->saveGlsShipment($data, $shipment);
|
145 |
+
// set order status
|
146 |
+
$helper->setOrderStatus($shipment->getOrder(),$helper->__('GLS shipment successfully saved'));
|
147 |
+
|
148 |
+
}
|
149 |
|
150 |
+
/**
|
151 |
+
* sets the gls order state on invoice save
|
152 |
+
* @param $observer
|
153 |
+
*/
|
154 |
+
public function saveGlsOrderStatus($observer) {
|
155 |
+
$invoice = Mage::registry('current_invoice');
|
156 |
+
$order = $invoice->getOrder();
|
157 |
+
$glsShipments = Mage::getModel('synergeticagency_gls/shipment')->getCollection();
|
158 |
+
$glsShipments->addFieldToFilter('order_id',array('eq' => $order->getId()));
|
159 |
+
if($glsShipments->count()) {
|
160 |
+
$helper = Mage::helper('synergeticagency_gls');
|
161 |
+
$helper->setOrderStatus($order,$helper->__('Order with GLS-Shipment'));
|
162 |
+
}
|
163 |
}
|
164 |
|
165 |
|
167 |
* Server side validation of gls shipment data in sales_order view
|
168 |
* This validation should never be triggered due to client side validation
|
169 |
* @param $data
|
170 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
171 |
* @return bool
|
172 |
*/
|
173 |
+
public function _validateGlsShipmentData($data,$shipment) {
|
174 |
|
175 |
if (empty($data['shipment']['packages']) ) {
|
176 |
return false;
|
180 |
return false;
|
181 |
}
|
182 |
|
183 |
+
$errorMessages = Mage::getModel('synergeticagency_gls/gls')->validateGlsShipmentData($data,$shipment);
|
184 |
if(true !== $errorMessages) {
|
185 |
return false;
|
186 |
}
|
198 |
public function checkGlsShipmentData(Varien_Event_Observer $observer)
|
199 |
{
|
200 |
$data = Mage::app()->getRequest()->getPost();
|
201 |
+
$shipment = $observer->getEvent()->getShipment();
|
202 |
//at the moment this method is also getting called when label is printed
|
203 |
//check if post data...
|
204 |
if(isset($data['shipment']['gls']) && isset($data['shipment']['gls']['ship_with_gls']) && $data['shipment']['gls']['ship_with_gls'] == '1') {
|
205 |
+
$check = Mage::getModel('synergeticagency_gls/gls')->validateGlsShipmentData($data,$shipment);
|
206 |
if ($check !== true) {
|
207 |
Mage::register('gls_shipment_error', true);
|
208 |
Mage::throwException($check);
|
222 |
->getCollection()
|
223 |
->addFieldToFilter('order_id',$orderId)
|
224 |
->addFieldToFilter('printed','0')
|
225 |
+
->addFieldToFilter('job_id',array('null' => true))
|
226 |
->setOrder('gls_shipment_id');
|
227 |
$hasUnprintedGlsShipments = $glsShipmentCollection->count();
|
228 |
if($hasUnprintedGlsShipments) {
|
254 |
}
|
255 |
}
|
256 |
|
257 |
+
/**
|
258 |
+
* @param $observer
|
259 |
+
* @throws Exception
|
260 |
+
*/
|
261 |
+
public function addMassActionToOrderGrid($observer)
|
262 |
+
{
|
263 |
+
$block = $observer->getEvent()->getBlock();
|
264 |
+
if($block instanceof Mage_Adminhtml_Block_Widget_Grid_Massaction && $block->getRequest()->getControllerName() == 'sales_order')
|
265 |
+
{
|
266 |
+
$block->addItem('createGlsShipment', array(
|
267 |
+
'label' => Mage::helper('synergeticagency_gls')->__('Create GLS shipments'),
|
268 |
+
'url' => Mage::app()->getStore()->getUrl('adminhtml/gls_shipment/masscreate'),
|
269 |
+
));
|
270 |
+
|
271 |
+
$block->addItem('printGlsLabels', array(
|
272 |
+
'label' => Mage::helper('synergeticagency_gls')->__('Print GLS labels'),
|
273 |
+
'url' => Mage::app()->getStore()->getUrl('adminhtml/gls_shipment/massprint'),
|
274 |
+
));
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
|
279 |
/**
|
280 |
* @param Mage_Adminhtml_Block_Sales_Order_Grid $grid
|
281 |
* @throws Exception
|
app/code/community/SynergeticAgency/Gls/Model/Resource/Service/Collection.php
CHANGED
@@ -73,7 +73,7 @@ class SynergeticAgency_Gls_Model_Resource_Service_Collection extends Varien_Data
|
|
73 |
}
|
74 |
}
|
75 |
if($add) {
|
76 |
-
$item = Mage::getModel('synergeticagency_gls/service')
|
77 |
$item->setData($service->toArray());
|
78 |
$this->addItem($item);
|
79 |
}
|
73 |
}
|
74 |
}
|
75 |
if($add) {
|
76 |
+
$item = Mage::getModel('synergeticagency_gls/service');
|
77 |
$item->setData($service->toArray());
|
78 |
$this->addItem($item);
|
79 |
}
|
app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Job.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category SynergetigAgency
|
22 |
+
* @package SynergeticAgency\Gls\Model\Resource\Shipment
|
23 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* GLS shipment job resource model
|
29 |
+
*
|
30 |
+
* @category SynergeticAgency
|
31 |
+
* @package SynergeticAgency_Gls
|
32 |
+
* @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
|
33 |
+
*/
|
34 |
+
class SynergeticAgency_Gls_Model_Resource_Shipment_Job extends Mage_Core_Model_Resource_Db_Abstract {
|
35 |
+
|
36 |
+
/**
|
37 |
+
* This Constructor initiates synergeticagency_gls/shipment_job using the magic _init function of Mage_Core_Model_Abstract
|
38 |
+
*/
|
39 |
+
protected function _construct() {
|
40 |
+
$this->_init('synergeticagency_gls/shipment_job', 'gls_shipment_job_id');
|
41 |
+
}
|
42 |
+
}
|
app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Job/Collection.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category SynergetigAgency
|
22 |
+
* @package SynergeticAgency\Gls\Model\Shipment\Parcel
|
23 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* GLS shipment job collection
|
29 |
+
*
|
30 |
+
* @category SynergeticAgency
|
31 |
+
* @package SynergeticAgency_Gls
|
32 |
+
* @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
|
33 |
+
*/
|
34 |
+
class SynergeticAgency_Gls_Model_Resource_Shipment_Job_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
|
35 |
+
|
36 |
+
/**
|
37 |
+
* constructor for parcels
|
38 |
+
*/
|
39 |
+
protected function _construct() {
|
40 |
+
$this->_init('synergeticagency_gls/shipment_job');
|
41 |
+
}
|
42 |
+
}
|
app/code/community/SynergeticAgency/Gls/Model/Shipment.php
CHANGED
@@ -33,6 +33,11 @@
|
|
33 |
*/
|
34 |
class SynergeticAgency_Gls_Model_Shipment extends Mage_Core_Model_Abstract {
|
35 |
|
|
|
|
|
|
|
|
|
|
|
36 |
/**
|
37 |
* Shipments target address
|
38 |
* @var
|
@@ -46,11 +51,16 @@ class SynergeticAgency_Gls_Model_Shipment extends Mage_Core_Model_Abstract {
|
|
46 |
private $_shipmentParcels;
|
47 |
|
48 |
/**
|
49 |
-
*
|
50 |
-
|
|
|
|
|
|
|
|
|
51 |
*/
|
52 |
protected function _construct() {
|
53 |
$this->_init('synergeticagency_gls/shipment');
|
|
|
54 |
}
|
55 |
|
56 |
/**
|
@@ -69,11 +79,16 @@ class SynergeticAgency_Gls_Model_Shipment extends Mage_Core_Model_Abstract {
|
|
69 |
|
70 |
/**
|
71 |
* Get parcels for a shipment by shipment id)
|
72 |
-
* @
|
|
|
73 |
*/
|
74 |
-
public function getShipmentParcels() {
|
75 |
if(is_null($this->_shipmentParcels) && $this->getId()) {
|
76 |
-
$shipmentParcels = Mage::getModel('synergeticagency_gls/shipment_parcel')
|
|
|
|
|
|
|
|
|
77 |
if($shipmentParcels && count($shipmentParcels)) {
|
78 |
$this->_shipmentParcels = $shipmentParcels;
|
79 |
}
|
@@ -117,4 +132,531 @@ class SynergeticAgency_Gls_Model_Shipment extends Mage_Core_Model_Abstract {
|
|
117 |
}
|
118 |
return array();
|
119 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
}
|
33 |
*/
|
34 |
class SynergeticAgency_Gls_Model_Shipment extends Mage_Core_Model_Abstract {
|
35 |
|
36 |
+
const GLS_SHIPMENT_LABEL_PDF_PREFIX_JOB = "job_";
|
37 |
+
|
38 |
+
const GLS_SHIPMENT_MAX_PARCELS = 30;
|
39 |
+
|
40 |
+
const GLS_SHIPMENT_MIN_PARCELS = 1;
|
41 |
/**
|
42 |
* Shipments target address
|
43 |
* @var
|
51 |
private $_shipmentParcels;
|
52 |
|
53 |
/**
|
54 |
+
* @var
|
55 |
+
*/
|
56 |
+
private $_labelTempPath;
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Initialize model
|
60 |
*/
|
61 |
protected function _construct() {
|
62 |
$this->_init('synergeticagency_gls/shipment');
|
63 |
+
$this->setLabelTempPath();
|
64 |
}
|
65 |
|
66 |
/**
|
79 |
|
80 |
/**
|
81 |
* Get parcels for a shipment by shipment id)
|
82 |
+
* @param string $order
|
83 |
+
* @return null|SynergeticAgency_Gls_Model_Resource_Shipment_Parcel_Collection
|
84 |
*/
|
85 |
+
public function getShipmentParcels($order=Varien_Data_Collection::SORT_ORDER_ASC) {
|
86 |
if(is_null($this->_shipmentParcels) && $this->getId()) {
|
87 |
+
$shipmentParcels = Mage::getModel('synergeticagency_gls/shipment_parcel')
|
88 |
+
->getCollection()
|
89 |
+
->addFieldToFilter('gls_shipment_id',$this->getId())
|
90 |
+
->setOrder('gls_shipment_parcel_id',$order)
|
91 |
+
->load();
|
92 |
if($shipmentParcels && count($shipmentParcels)) {
|
93 |
$this->_shipmentParcels = $shipmentParcels;
|
94 |
}
|
132 |
}
|
133 |
return array();
|
134 |
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @return null|Mage_Sales_Model_Order_Shipment
|
138 |
+
*/
|
139 |
+
public function getMagentoShipment() {
|
140 |
+
$magentoShipment = $this->getData('magento_shipment');
|
141 |
+
if(empty($magentoShipment)) {
|
142 |
+
$this->setData('magento_shipment',Mage::getModel('sales/order_shipment')->load($this->getShipmentId()));
|
143 |
+
}
|
144 |
+
return $this->getData('magento_shipment');
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* @return array
|
149 |
+
* @throws Exception
|
150 |
+
*/
|
151 |
+
public function getLabels() {
|
152 |
+
// do prechecks
|
153 |
+
$this->doLabelChecks();
|
154 |
+
|
155 |
+
$connector = $this->getConnector();
|
156 |
+
$connectorShipment = $this->getConnectorShipment();
|
157 |
+
|
158 |
+
$this->setConnectorDeliveryAddress();
|
159 |
+
$this->setAlternateShipperAddress();
|
160 |
+
$this->setParcels();
|
161 |
+
$this->setReturnAddress();
|
162 |
+
$connector->setShipment( $connectorShipment );
|
163 |
+
Mage::helper("synergeticagency_gls/log")->logApi( __METHOD__, __LINE__, $connector->getShipment()->toJson() );
|
164 |
+
|
165 |
+
if( Mage::helper("synergeticagency_gls")->getGeneralGlsConfig('logging_enabled') == 1 ){
|
166 |
+
Mage::log( $connector->getShipment()->toJson(), Zend_Log::DEBUG );
|
167 |
+
}
|
168 |
+
|
169 |
+
try {
|
170 |
+
// send shipment to the GLS-API
|
171 |
+
$connector->createShipment();
|
172 |
+
} catch(Exception $e) {
|
173 |
+
// handle exceptions of the connector
|
174 |
+
$this->setError($e->getMessage(),$e->getCode());
|
175 |
+
}
|
176 |
+
|
177 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, "GLS-API Response: ConsignmentId = " . $connector->getShipment()->getConsignmentId(), Zend_Log::INFO );
|
178 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, $connector->getCurlResponse() );
|
179 |
+
|
180 |
+
|
181 |
+
if( Mage::helper("synergeticagency_gls")->getGeneralGlsConfig('logging_enabled') == 1 ){
|
182 |
+
Mage::log( $connector->getCurlResponse(), Zend_Log::DEBUG );
|
183 |
+
}
|
184 |
+
|
185 |
+
// process response of an sent shipment ----------------------------
|
186 |
+
// handle GLS-API Response Errors
|
187 |
+
if( $connector->getError()->hasError() === true ){
|
188 |
+
Mage::helper("synergeticagency_gls/log")->logApi( __METHOD__, __LINE__, "GLS-API Connector has caused an error: " . $connector->getError()->getMessage(), Zend_Log::ERR );
|
189 |
+
Mage::helper("synergeticagency_gls/log")->logApi( __METHOD__, __LINE__, $connector->getError()->getModelState(true) );
|
190 |
+
|
191 |
+
$errorCode = SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_API_CONNECTOR_ERROR;
|
192 |
+
$errorMessage = sprintf(Mage::helper('synergeticagency_gls')->__('GLS-API Connector has caused an error: %s'), $connector->getError()->getMessage()) .
|
193 |
+
"<br /><textarea name=\"gls_json_debug\" style=\"width: 80%;\">" . $connector->getShipment()->toJson() . $connector->getError()->getModelState( true ) .
|
194 |
+
"</textarea><br />";
|
195 |
+
$this->setError($errorMessage,$errorCode);
|
196 |
+
}
|
197 |
+
// get the shipment object right after the GLS-API Response for further processing
|
198 |
+
/** @var SynergeticAgency_GlsConnector_Model_Shipment $shipmentResponse */
|
199 |
+
$shipmentResponse = $connector->getShipment();
|
200 |
+
|
201 |
+
$consignmentId = $shipmentResponse->getConsignmentId();
|
202 |
+
if (empty($consignmentId)) {
|
203 |
+
Mage::helper("synergeticagency_gls/log")->logApi(__METHOD__, __LINE__, "No GLS ConsignmentId available or empty in GLS-API shipment response", Zend_Log::ERR);
|
204 |
+
$errorCode = SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_CONSIGNMENTID_MISSING;
|
205 |
+
$errorMessage = Mage::helper('synergeticagency_gls')->__('No GLS ConsignmentId available or empty in GLS-API shipment response');
|
206 |
+
$this->setError($errorMessage,$errorCode);
|
207 |
+
}
|
208 |
+
|
209 |
+
$labels = $shipmentResponse->getLabels();
|
210 |
+
if (!count($labels)) {
|
211 |
+
$errorCode = SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_LABEL_INVALID;
|
212 |
+
$errorMessage = sprintf(Mage::helper('synergeticagency_gls')->__('The label data with GLS-ConsignmentId %s obtained are not correct'),$consignmentId);
|
213 |
+
$this->setError($errorMessage,$errorCode);
|
214 |
+
}
|
215 |
+
|
216 |
+
foreach ($labels as &$label) {
|
217 |
+
$label = base64_decode($label);
|
218 |
+
$pdfCheckLine = $label;
|
219 |
+
$pdfCheckLine = trim(strtok($pdfCheckLine, "\n"));
|
220 |
+
if (!preg_match("/^%PDF-[0-9]+\\.[0-9]+$/", $pdfCheckLine)) {
|
221 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, sprintf("The label data with GLS-ConsignmentId %s obtained are not correct", $shipmentResponse->getConsignmentId()), Zend_Log::INFO );
|
222 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, "\$pdfCheckLine=" . substr ( $pdfCheckLine, 0, 25 ), Zend_Log::INFO );
|
223 |
+
$errorCode = SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_LABEL_INVALID;
|
224 |
+
$errorMessage = sprintf(Mage::helper('synergeticagency_gls')->__('The label data with GLS-ConsignmentId %s obtained are not correct'),$consignmentId);
|
225 |
+
$this->setError($errorMessage,$errorCode);
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
// add tracking codes to magento shipment
|
230 |
+
$this->addTracks();
|
231 |
+
|
232 |
+
// set returned api data back
|
233 |
+
$this->setConsignmentId($consignmentId);
|
234 |
+
$this->setPrinted(1);
|
235 |
+
$this->save();
|
236 |
+
|
237 |
+
// return the labels for further processing
|
238 |
+
return $labels;
|
239 |
+
}
|
240 |
+
|
241 |
+
|
242 |
+
/**
|
243 |
+
* save given $label string to $file
|
244 |
+
*
|
245 |
+
* @param string $label PDF string
|
246 |
+
* @param string $file full path/filename to save file
|
247 |
+
* @return bool|string $returnValue false, if something went wrong,
|
248 |
+
* $filename if saved successful
|
249 |
+
*/
|
250 |
+
|
251 |
+
/**
|
252 |
+
* save given $label string to $file
|
253 |
+
*
|
254 |
+
* @param string $label PDF string
|
255 |
+
* @param string $file full path/filename to save file
|
256 |
+
* @return bool|string $returnValue false, if something went wrong,
|
257 |
+
* $filename if saved successful
|
258 |
+
* @throws Exception
|
259 |
+
*/
|
260 |
+
public function saveLabel( $label, $file ){
|
261 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, "entered", Zend_Log::DEBUG );
|
262 |
+
|
263 |
+
$written = true;
|
264 |
+
$returnValue = false;
|
265 |
+
if( $label !== false ){
|
266 |
+
if (!$handle = fopen($file, "w")) {
|
267 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, " cannot open file " . $file, Zend_Log::WARN );
|
268 |
+
$written = false;
|
269 |
+
} else {
|
270 |
+
if (!fwrite($handle, $label)) {
|
271 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, " cannot write into file " . $file, Zend_Log::WARN );
|
272 |
+
$written = false;
|
273 |
+
} else {
|
274 |
+
$returnValue = $file;
|
275 |
+
}
|
276 |
+
fclose($handle);
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
if( $written === false ){
|
281 |
+
$errorCode = SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_LABEL_IO_ERROR;
|
282 |
+
$errorMessage = sprintf(Mage::helper('synergeticagency_gls')->__('Failed to write %s'),$file) ."<br />".
|
283 |
+
sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), $errorCode);
|
284 |
+
$this->setError($errorMessage,$errorCode);
|
285 |
+
}
|
286 |
+
|
287 |
+
$this->setPdfFile(trim(str_replace(Mage::getBaseDir(),'',$file),DS)); // remove base dir from file path for relative path
|
288 |
+
|
289 |
+
return $returnValue;
|
290 |
+
}
|
291 |
+
|
292 |
+
|
293 |
+
/**
|
294 |
+
* @return null|SynergeticAgency_GlsConnector_Connector
|
295 |
+
*/
|
296 |
+
public function getConnector() {
|
297 |
+
$connector = $this->getData('connector');
|
298 |
+
if(!$connector instanceof SynergeticAgency_GlsConnector_Connector) {
|
299 |
+
$connector = Mage::helper("synergeticagency_gls")->getConnector($this->getStore());
|
300 |
+
$this->setData('connector',$connector);
|
301 |
+
}
|
302 |
+
return $connector;
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* @param int $var
|
307 |
+
*/
|
308 |
+
public function setPrinted($var) {
|
309 |
+
$this->setData('printed',$var);
|
310 |
+
if($var == 1) { // only remove errors if $var is 1
|
311 |
+
$this->setErrorCode('');
|
312 |
+
$this->setErrorMessage('');
|
313 |
+
}
|
314 |
+
}
|
315 |
+
|
316 |
+
/**
|
317 |
+
* @return SynergeticAgency_GlsConnector_Model_Shipment
|
318 |
+
*/
|
319 |
+
private function getConnectorShipment() {
|
320 |
+
$connectorShipment = $this->getData('connector_shipment');
|
321 |
+
if($connectorShipment instanceof SynergeticAgency_GlsConnector_Model_Shipment) {
|
322 |
+
return $connectorShipment;
|
323 |
+
}
|
324 |
+
|
325 |
+
$connectorShipment = new SynergeticAgency_GlsConnector_Model_Shipment();
|
326 |
+
|
327 |
+
// reformat date without time
|
328 |
+
$shippingDate = date('Y-m-d',strtotime($this->getShippingDate()));
|
329 |
+
$this->setShippingDate($shippingDate);
|
330 |
+
// if shipping date is in the past and label is not printed set it to now
|
331 |
+
if(strtotime($shippingDate) < strtotime(date('Y-m-d'))) {
|
332 |
+
$shippingDate = date('Y-m-d');
|
333 |
+
$this->setShippingDate($shippingDate);
|
334 |
+
$this->save();
|
335 |
+
}
|
336 |
+
$magentoShipment = $this->getMagentoShipment();
|
337 |
+
$store = $this->getStore();
|
338 |
+
|
339 |
+
// set up shipment basic values
|
340 |
+
$shipperId = Mage::getStoreConfig('gls/general/customer_id', $store) .
|
341 |
+
" " .
|
342 |
+
Mage::getStoreConfig('gls/general/contact_id', $store);
|
343 |
+
$connectorShipment
|
344 |
+
->setCustomerId( Mage::getStoreConfig('gls/general/customer_id',$store) )
|
345 |
+
->setContactId( Mage::getStoreConfig('gls/general/contact_id',$store) )
|
346 |
+
->setShipperId($shipperId)
|
347 |
+
->setShipmentDate($this->getShippingDate() )
|
348 |
+
->setReference( $magentoShipment->getOrder()->getIncrementId() );
|
349 |
+
|
350 |
+
// set labelsize
|
351 |
+
$connectorShipment->setLabelSize( Mage::helper("synergeticagency_gls/data")->getShipmentGlsConfig('labelsize') );
|
352 |
+
|
353 |
+
// add useful references for shipment such as
|
354 |
+
// shipment id concatinated with dash and parcel id, printed date and the controller information
|
355 |
+
$shipmentReferences = array();
|
356 |
+
/** @var SynergeticAgency_Gls_Model_Shipment_Parcel $glsShipmentParcel */
|
357 |
+
foreach( $this->getShipmentParcels() AS $glsShipmentParcel){
|
358 |
+
$shipmentReferences[] = $this->getId() . "-" . $glsShipmentParcel->getData()['gls_shipment_parcel_id'];
|
359 |
+
}
|
360 |
+
$shipmentReferences[] = date( "r" );
|
361 |
+
$shipmentReferences[] = basename( __FILE__ );
|
362 |
+
|
363 |
+
$connectorShipment->setReferences( $shipmentReferences );
|
364 |
+
|
365 |
+
$this->setData('connector_shipment',$connectorShipment);
|
366 |
+
return $connectorShipment;
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* @return $this
|
371 |
+
* @throws Exception
|
372 |
+
*/
|
373 |
+
private function addTracks() {
|
374 |
+
$parcels = $this->getConnector()->getShipment()->getParcels();
|
375 |
+
$magentoShipment = $this->getMagentoShipment();
|
376 |
+
foreach($parcels as $parcel) {
|
377 |
+
$glsParcel = Mage::getModel('synergeticagency_gls/shipment_parcel')->load($parcel->getReferences()[0]);
|
378 |
+
if($glsParcel->getId()) {
|
379 |
+
$glsParcel->setTrackId($parcel->getTrackId());
|
380 |
+
$glsParcel->setLocation($parcel->getLocation());
|
381 |
+
$glsParcel->setParcelNumber($parcel->getParcelNumber());
|
382 |
+
$glsParcel->save();
|
383 |
+
|
384 |
+
$track = Mage::getModel('sales/order_shipment_track')
|
385 |
+
->setNumber($parcel->getParcelNumber()) //tracking number / awb number
|
386 |
+
->setCarrierCode(SynergeticAgency_Gls_Model_Carrier::CODE) //carrier code
|
387 |
+
->setTitle(SynergeticAgency_Gls_Model_Carrier::CARRIER_TITLE); //carrier title
|
388 |
+
$magentoShipment->addTrack($track);
|
389 |
+
}
|
390 |
+
}
|
391 |
+
$magentoShipment->save();
|
392 |
+
return $this;
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* @return Mage_Core_Model_Store
|
397 |
+
*/
|
398 |
+
public function getStore() {
|
399 |
+
if($this->getMagentoShipment() && $this->getMagentoShipment()->getId()) {
|
400 |
+
$store = $this->getMagentoShipment()->getStore();
|
401 |
+
} else {
|
402 |
+
$store = Mage::app()->getStore();
|
403 |
+
}
|
404 |
+
return $store;
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* @return $this
|
409 |
+
* @throws Exception
|
410 |
+
*/
|
411 |
+
private function doLabelChecks() {
|
412 |
+
$magentoShipment = $this->getMagentoShipment();
|
413 |
+
if(!$magentoShipment || !$magentoShipment->getId()) {
|
414 |
+
$errorCode = SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_MAGE_SHIPMENT_MISSING;
|
415 |
+
$errorMessage = Mage::helper('synergeticagency_gls')->__('Magento shipment is missing');
|
416 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, "Magento shipment is missing(Error-Code: $errorCode)", Zend_Log::ERR );
|
417 |
+
$this->setError($errorMessage,$errorCode);
|
418 |
+
}
|
419 |
+
|
420 |
+
if($this->getPrinted() == '1') {
|
421 |
+
$errorCode = SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_LABEL_ALREADY_PRINTED;
|
422 |
+
$errorMessage = Mage::helper('synergeticagency_gls')->__('GLS Label is already printed');
|
423 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, "GLS Label is already printed(Error-Code: $errorCode)", Zend_Log::ERR );
|
424 |
+
$this->setError($errorMessage,$errorCode);
|
425 |
+
}
|
426 |
+
|
427 |
+
$check = Mage::helper('synergeticagency_gls')->checkConfigSettings();
|
428 |
+
if($check !== true) {
|
429 |
+
$errorDetails = '';
|
430 |
+
if( is_array($check) ){
|
431 |
+
$errorDetails = "<br />";
|
432 |
+
foreach( $check AS $key => $value ){
|
433 |
+
$errorDetails.= $key . ": " . $value . "<br />";
|
434 |
+
}
|
435 |
+
}
|
436 |
+
$errorCode = SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_CONFIGURATION_INCOMPLETE;
|
437 |
+
$errorMessage = sprintf(Mage::helper('synergeticagency_gls')->__('The GLS %s has errors or is not complete'), Mage::helper('synergeticagency_gls')->__('Basic configuration'))." <br />".$errorDetails;
|
438 |
+
|
439 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, "The GLS Basic configuration has errors or is not complete(Error-Code: $errorCode)", Zend_Log::ERR );
|
440 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, var_export($check,1), Zend_Log::INFO );
|
441 |
+
|
442 |
+
$this->setError($errorMessage,$errorCode);
|
443 |
+
}
|
444 |
+
return $this;
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* @return $this
|
449 |
+
* @throws Exception
|
450 |
+
*/
|
451 |
+
private function setConnectorDeliveryAddress() {
|
452 |
+
$connectorShipment = $this->getConnectorShipment();
|
453 |
+
/** @var SynergeticAgency_GlsConnector_Model_Address $connectorDeliveryAddress */
|
454 |
+
$connectorDeliveryAddress = $connectorShipment->getAddresses( SynergeticAgency_GlsConnector_Model_Address::GLS_API_ADDRESS_DELIVERY );
|
455 |
+
$glsShipmentAddress = $this->getShipmentAddress();
|
456 |
+
if(!$glsShipmentAddress || !$glsShipmentAddress->getId()) {
|
457 |
+
$errorMessage = Mage::helper('synergeticagency_gls')->__('GLS Shipment could not be created');
|
458 |
+
$errorCode = SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_SHIPMENT_NOT_CREATED;
|
459 |
+
$this->setError($errorMessage,$errorCode);
|
460 |
+
}
|
461 |
+
|
462 |
+
$connectorDeliveryAddress
|
463 |
+
->setName1( $glsShipmentAddress->getName1())
|
464 |
+
->setName2( $glsShipmentAddress->getName2())
|
465 |
+
->setName3( $glsShipmentAddress->getName3())
|
466 |
+
->setStreet1( $glsShipmentAddress->getStreet1())
|
467 |
+
->setCountry( $glsShipmentAddress->getCountry())
|
468 |
+
->setZipCode($glsShipmentAddress->getZipCode())
|
469 |
+
->setCity( $glsShipmentAddress->getCity())
|
470 |
+
->setEmail( $glsShipmentAddress->getEmail())
|
471 |
+
->setPhone( $glsShipmentAddress->getPhone());
|
472 |
+
|
473 |
+
$parcelShopId = $this->getParcelshopId();
|
474 |
+
if(!empty($parcelShopId)) {
|
475 |
+
// todo: check in name context
|
476 |
+
$connectorDeliveryAddress->setContact( $glsShipmentAddress->getName1() );
|
477 |
+
}
|
478 |
+
|
479 |
+
return $this;
|
480 |
+
}
|
481 |
+
|
482 |
+
/**
|
483 |
+
* @return $this
|
484 |
+
*/
|
485 |
+
private function setAlternateShipperAddress() {
|
486 |
+
$store = $this->getStore();
|
487 |
+
if(Mage::getStoreConfig('gls/alternative_shipper/alternative_shipper_enabled',$store) === '1' && Mage::helper('synergeticagency_gls')->checkAlternativeShipper($store)) {
|
488 |
+
$addressAlternativeShipping = new SynergeticAgency_GlsConnector_Model_Address();
|
489 |
+
|
490 |
+
$addressAlternativeShipping->setType(SynergeticAgency_GlsConnector_Model_Address::GLS_API_ADDRESS_ALTERNATIVESHIPPING)
|
491 |
+
->setName1(Mage::getStoreConfig('gls/alternative_shipper/name1',$store))
|
492 |
+
->setName2(Mage::getStoreConfig('gls/alternative_shipper/name2',$store))
|
493 |
+
->setName3(Mage::getStoreConfig('gls/alternative_shipper/name3',$store))
|
494 |
+
->setStreet1(Mage::getStoreConfig('gls/alternative_shipper/street1',$store))
|
495 |
+
->setCountry(Mage::getStoreConfig('gls/alternative_shipper/country',$store))
|
496 |
+
->setZipCode(Mage::getStoreConfig('gls/alternative_shipper/zip_code',$store))
|
497 |
+
->setCity(Mage::getStoreConfig('gls/alternative_shipper/city',$store));
|
498 |
+
$this->getConnectorShipment()->addAddress( $addressAlternativeShipping );
|
499 |
+
}
|
500 |
+
return $this;
|
501 |
+
}
|
502 |
+
|
503 |
+
/**
|
504 |
+
* @return $this
|
505 |
+
* @throws Zend_Locale_Exception
|
506 |
+
*/
|
507 |
+
private function setParcels() {
|
508 |
+
|
509 |
+
$glsServices = $this->getServices();
|
510 |
+
$store = $this->getStore();
|
511 |
+
|
512 |
+
$connectorShipment = $this->getConnectorShipment();
|
513 |
+
$magentoShipment = $this->getMagentoShipment();
|
514 |
+
$resultingServices = array();
|
515 |
+
if($glsServices && count($glsServices)) {
|
516 |
+
foreach($glsServices as $glsService) {
|
517 |
+
$service = new SynergeticAgency_GlsConnector_Model_Service();
|
518 |
+
switch($glsService->getId()) {
|
519 |
+
case SynergeticAgency_Gls_Model_Gls::SERVICE_EMAILNOTIFICATION:
|
520 |
+
//$service = new SynergeticAgency_GlsConnector_Model_Service();
|
521 |
+
//$service->setName( );
|
522 |
+
// todo not available anymore??
|
523 |
+
//$service->setNotificationEmail($glsShipmentAddress->getEmail());
|
524 |
+
break;
|
525 |
+
case SynergeticAgency_Gls_Model_Gls::SERVICE_FLEXDELIVERY:
|
526 |
+
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_FLEXDELIVERYSERVICE );
|
527 |
+
break;
|
528 |
+
case SynergeticAgency_Gls_Model_Gls::SERVICE_THINKGREEN:
|
529 |
+
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_THINKGREENSERVICE);
|
530 |
+
break;
|
531 |
+
case SynergeticAgency_Gls_Model_Gls::SERVICE_PRIVATEDELIVERY:
|
532 |
+
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_PRIVATEDELIVERYSERVICE);
|
533 |
+
break;
|
534 |
+
case SynergeticAgency_Gls_Model_Gls::SERVICE_GUARANTEED:
|
535 |
+
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_GUARANTEED24SERVICE);
|
536 |
+
break;
|
537 |
+
}
|
538 |
+
if(!is_null($service->getName()) && $service->getName() !== '') {
|
539 |
+
$resultingServices[] = $service;
|
540 |
+
}
|
541 |
+
}
|
542 |
+
}
|
543 |
+
|
544 |
+
if($this->getReturnLabel() === '1' && Mage::helper('synergeticagency_gls')->checkReturnAddress($store)) {
|
545 |
+
$service = new SynergeticAgency_GlsConnector_Model_Service();
|
546 |
+
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_SHOPRETURNSERVICE);
|
547 |
+
$connectorShipment->setReturnLabel(true);
|
548 |
+
$resultingServices[] = $service;
|
549 |
+
}
|
550 |
+
|
551 |
+
foreach($this->getShipmentParcels() as $parcel) {
|
552 |
+
$connectorParcel = new SynergeticAgency_GlsConnector_Model_Parcel();
|
553 |
+
$connectorParcel->setWeight($parcel->getWeight());
|
554 |
+
$connectorParcel->setReferences( array($parcel->getId()) );
|
555 |
+
|
556 |
+
if($parcel->getCashservice() > 0) {
|
557 |
+
$service = new SynergeticAgency_GlsConnector_Model_Service();
|
558 |
+
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_CASHONDELIVERY);
|
559 |
+
$symbols = Zend_Locale_Data::getList(Mage::getStoreConfig('general/locale/code', $store) , 'symbols');
|
560 |
+
$info = new SynergeticAgency_GlsConnector_Model_Info();
|
561 |
+
$info->setName('amount');
|
562 |
+
$info->setValue(round(floatval(str_replace($symbols['decimal'], '.', $parcel->getCashservice())),2));
|
563 |
+
// special case: if amount has no dezimal point, add decimal point and zero,
|
564 |
+
// because info object is defined as string, but GLS needs "float string"
|
565 |
+
if( !strpos($info->getValue() , '.') ){
|
566 |
+
$info->setValue( $info->getValue() . ".0" );
|
567 |
+
}
|
568 |
+
$service->pushInfo($info);
|
569 |
+
|
570 |
+
$info = new SynergeticAgency_GlsConnector_Model_Info();
|
571 |
+
$info->setName('reference');
|
572 |
+
$info->setValue($magentoShipment->getOrder()->getIncrementId());
|
573 |
+
$service->pushInfo($info);
|
574 |
+
$connectorParcel->pushService($service);
|
575 |
+
}
|
576 |
+
|
577 |
+
if($this->getParcelshopId() !== '' && !is_null($this->getParcelshopId())) {
|
578 |
+
$service = new SynergeticAgency_GlsConnector_Model_Service();
|
579 |
+
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_SHOPDELIVERYSERVICE);
|
580 |
+
$info = new SynergeticAgency_GlsConnector_Model_Info();
|
581 |
+
$info->setName('parcelshopid');
|
582 |
+
$info->setValue($this->getParcelshopId());
|
583 |
+
$service->pushInfo($info);
|
584 |
+
$connectorParcel->pushService($service);
|
585 |
+
}
|
586 |
+
if(count($resultingServices))
|
587 |
+
{
|
588 |
+
foreach($resultingServices as $service) {
|
589 |
+
$connectorParcel->pushService($service);
|
590 |
+
}
|
591 |
+
}
|
592 |
+
$connectorShipment->pushParcel($connectorParcel);
|
593 |
+
}
|
594 |
+
return $this;
|
595 |
+
}
|
596 |
+
|
597 |
+
/**
|
598 |
+
* @return $this
|
599 |
+
*/
|
600 |
+
private function setReturnAddress() {
|
601 |
+
if($this->getReturnLabel() == '1') {
|
602 |
+
$store = $this->getStore();
|
603 |
+
$connectorShipment = $this->getConnectorShipment();
|
604 |
+
if (Mage::helper('synergeticagency_gls')->checkReturnAddress($store)) {
|
605 |
+
$addressReturn = new SynergeticAgency_GlsConnector_Model_Address();
|
606 |
+
$addressReturn->setType(SynergeticAgency_GlsConnector_Model_Address::GLS_API_ADDRESS_RETURN)
|
607 |
+
->setName1(Mage::getStoreConfig('gls/return_address/name1', $store))
|
608 |
+
->setName2(Mage::getStoreConfig('gls/return_address/name2', $store))
|
609 |
+
->setName3(Mage::getStoreConfig('gls/return_address/name3', $store))
|
610 |
+
->setStreet1(Mage::getStoreConfig('gls/return_address/street1', $store))
|
611 |
+
->setCountry(Mage::getStoreConfig('gls/return_address/country', $store))
|
612 |
+
->setZipCode(Mage::getStoreConfig('gls/return_address/zip_code', $store))
|
613 |
+
->setCity(Mage::getStoreConfig('gls/return_address/city', $store));
|
614 |
+
|
615 |
+
$connectorShipment->addAddress($addressReturn);
|
616 |
+
}
|
617 |
+
}
|
618 |
+
return $this;
|
619 |
+
}
|
620 |
+
|
621 |
+
/**
|
622 |
+
* @return mixed
|
623 |
+
*/
|
624 |
+
public function getLabelTempPath()
|
625 |
+
{
|
626 |
+
return $this->_labelTempPath;
|
627 |
+
}
|
628 |
+
|
629 |
+
/**
|
630 |
+
* @param bool $labelTempPath
|
631 |
+
* @return $this
|
632 |
+
*/
|
633 |
+
public function setLabelTempPath( $labelTempPath = false )
|
634 |
+
{
|
635 |
+
if( $labelTempPath !== false && is_dir($labelTempPath) && is_writable($labelTempPath) ){
|
636 |
+
$this->_labelTempPath = $labelTempPath;
|
637 |
+
} else {
|
638 |
+
$this->_labelTempPath = Mage::getBaseDir('var').DS."tmp".DS."gls";
|
639 |
+
}
|
640 |
+
|
641 |
+
return $this;
|
642 |
+
}
|
643 |
+
|
644 |
+
|
645 |
+
/**
|
646 |
+
* @param $errorMessage
|
647 |
+
* @param $errorCode
|
648 |
+
* @param bool $exception
|
649 |
+
* @throws Exception
|
650 |
+
*/
|
651 |
+
private function setError($errorMessage,$errorCode,$exception=true) {
|
652 |
+
$this->setErrorCode($errorCode);
|
653 |
+
$this->setErrorMessage($errorMessage);
|
654 |
+
if($this->getId()) {
|
655 |
+
// only save if id is present
|
656 |
+
$this->save(); // save error
|
657 |
+
}
|
658 |
+
if($exception) {
|
659 |
+
throw Mage::exception('SynergeticAgency_Gls',get_class($this).': '.$errorMessage . ' ' .sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'),$errorCode),$errorCode);
|
660 |
+
}
|
661 |
+
}
|
662 |
}
|
app/code/community/SynergeticAgency/Gls/Model/Shipment/Job.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category SynergetigAgency
|
22 |
+
* @package SynergeticAgency\Gls\Model\Shipment
|
23 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* GLS shipment job model
|
29 |
+
*
|
30 |
+
* @category SynergeticAgency
|
31 |
+
* @package SynergeticAgency_Gls
|
32 |
+
* @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
|
33 |
+
*/
|
34 |
+
class SynergeticAgency_Gls_Model_Shipment_Job extends Mage_Core_Model_Abstract {
|
35 |
+
|
36 |
+
const GLS_SHIPMENT_JOB_LABEL_PDF_PREFIX_JOB = "gls_combined_";
|
37 |
+
|
38 |
+
private $_labelTempPath;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* This Constructor initiates synergeticagency_gls/shipment_job using the magic _init function of Mage_Core_Model_Abstract
|
42 |
+
*/
|
43 |
+
protected function _construct() {
|
44 |
+
$this->_init('synergeticagency_gls/shipment_job');
|
45 |
+
$this->setLabelTempPath();
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @return SynergeticAgency_Gls_Model_Resource_Shipment_Collection
|
50 |
+
*/
|
51 |
+
public function getShipments() {
|
52 |
+
$glsShipmentCollection = Mage::getModel('synergeticagency_gls/shipment')->getCollection();
|
53 |
+
$glsShipmentCollection
|
54 |
+
->addFieldToFilter( 'job_id', array('eq' => $this->getGlsShipmentJobId()) )
|
55 |
+
->addOrder('gls_shipment_id',$glsShipmentCollection::SORT_ORDER_ASC)
|
56 |
+
->load();
|
57 |
+
return $glsShipmentCollection;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return SynergeticAgency_Gls_Model_Resource_Shipment_Collection
|
62 |
+
*/
|
63 |
+
public function getUnprintedShipments() {
|
64 |
+
$glsShipmentCollection = Mage::getModel('synergeticagency_gls/shipment')->getCollection();
|
65 |
+
$glsShipmentCollection
|
66 |
+
->addFieldToFilter( 'job_id', array('eq' => $this->getGlsShipmentJobId()) )
|
67 |
+
->addFieldToFilter('printed', array('neq' => '1'))
|
68 |
+
->addOrder('gls_shipment_id',$glsShipmentCollection::SORT_ORDER_ASC)
|
69 |
+
->load();
|
70 |
+
return $glsShipmentCollection;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @return mixed
|
75 |
+
*/
|
76 |
+
public function getLabelTempPath()
|
77 |
+
{
|
78 |
+
return $this->_labelTempPath;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @param bool $labelTempPath
|
83 |
+
* @return $this
|
84 |
+
*/
|
85 |
+
public function setLabelTempPath( $labelTempPath = false )
|
86 |
+
{
|
87 |
+
if( $labelTempPath !== false && is_dir($labelTempPath) && is_writable($labelTempPath) ){
|
88 |
+
$this->_labelTempPath = $labelTempPath;
|
89 |
+
} else {
|
90 |
+
$this->_labelTempPath = Mage::getBaseDir('var').DS."tmp".DS."gls";
|
91 |
+
}
|
92 |
+
|
93 |
+
return $this;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* @return string
|
98 |
+
*/
|
99 |
+
public function getStatus() {
|
100 |
+
$jobQty = intval($this->getQtyItemsOpen()) + intval($this->getQtyItemsSuccessful()) + intval($this->getQtyItemsError());
|
101 |
+
$itemsSuccessful = intval($this->getQtyItemsSuccessful());
|
102 |
+
$itemsError = intval($this->getQtyItemsError());
|
103 |
+
$ret = sprintf(Mage::helper('synergeticagency_gls')->__('%s of %s GLS shipments successfully processed.'), $itemsSuccessful, $jobQty);
|
104 |
+
if($itemsError) {
|
105 |
+
$ret .= '<br />'.sprintf(Mage::helper('synergeticagency_gls')->__('%s shipments could not be propcessed. Please check them manually.'), $itemsError);
|
106 |
+
}
|
107 |
+
return $ret;
|
108 |
+
}
|
109 |
+
}
|
app/code/community/SynergeticAgency/Gls/Model/System/Config/Source/Weightunit.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category SynergetigAgency
|
22 |
+
* @package SynergeticAgency\Gls\Model\System\Config\Source
|
23 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Used in creating options for GLS weight configuration
|
29 |
+
*
|
30 |
+
*/
|
31 |
+
class SynergeticAgency_Gls_Model_System_Config_Source_Weightunit
|
32 |
+
{
|
33 |
+
|
34 |
+
public function toOptionArray()
|
35 |
+
{
|
36 |
+
return [
|
37 |
+
[
|
38 |
+
'value' => SynergeticAgency_Gls_Model_Gls::GLS_WEIGHT_UNIT_G,
|
39 |
+
'label' => Mage::helper('synergeticagency_gls')->__(SynergeticAgency_Gls_Model_Gls::GLS_WEIGHT_UNIT_G)
|
40 |
+
],
|
41 |
+
[
|
42 |
+
'value' => SynergeticAgency_Gls_Model_Gls::GLS_WEIGHT_UNIT_KG,
|
43 |
+
'label' => Mage::helper('synergeticagency_gls')->__(SynergeticAgency_Gls_Model_Gls::GLS_WEIGHT_UNIT_KG)
|
44 |
+
]
|
45 |
+
];
|
46 |
+
}
|
47 |
+
}
|
app/code/community/SynergeticAgency/Gls/controllers/Adminhtml/Gls/Shipment/JobController.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to info@synergetic.ag so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @category SynergetigAgency
|
17 |
+
* @package SynergeticAgency\Gls\controllers\Adminhtml\Gls
|
18 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class SynergeticAgency_Gls_Adminhtml_Gls_Shipment_JobController
|
24 |
+
*/
|
25 |
+
class SynergeticAgency_Gls_Adminhtml_Gls_Shipment_JobController extends Mage_Adminhtml_Controller_Action {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Initialising the sales GLS job view
|
29 |
+
*/
|
30 |
+
public function indexAction()
|
31 |
+
{
|
32 |
+
$this->_title($this->__('GLS'))->_title($this->__('GLS mass action list'));
|
33 |
+
$this->loadLayout();
|
34 |
+
$this->_setActiveMenu('sales/sales');
|
35 |
+
$this->_addContent($this->getLayout()->createBlock('synergeticagency_gls/adminhtml_sales_gls_shipment_job'));
|
36 |
+
$this->renderLayout();
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Initialising the sales GLS job grid view
|
41 |
+
*/
|
42 |
+
public function gridAction()
|
43 |
+
{
|
44 |
+
$this->loadLayout();
|
45 |
+
$this->getResponse()->setBody(
|
46 |
+
$this->getLayout()->createBlock('synergeticagency_gls/adminhtml_sales_gls_shipment_job_grid')->toHtml()
|
47 |
+
);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* echos the current state of the grid as json for an ajax request
|
52 |
+
*/
|
53 |
+
public function ajaxAction() {
|
54 |
+
$glsShipmentJobIds = $this->getRequest()->getParam('jobIds');
|
55 |
+
if(!is_array($glsShipmentJobIds) || !count($glsShipmentJobIds)) {
|
56 |
+
echo json_encode(array());
|
57 |
+
die();
|
58 |
+
}
|
59 |
+
$jobCollection = Mage::getModel('synergeticagency_gls/shipment_job')->getCollection();
|
60 |
+
$jobCollection
|
61 |
+
->addFieldToSelect('*')
|
62 |
+
->addFieldToFilter('gls_shipment_job_id',array('in' => $glsShipmentJobIds))
|
63 |
+
->load();
|
64 |
+
$returnArray = array();
|
65 |
+
if($jobCollection->count()) {
|
66 |
+
foreach($jobCollection as $job) {
|
67 |
+
// can not be done like this bc the state of the job must be submitted
|
68 |
+
$noUpdates = 0;
|
69 |
+
if($job->getCompleted() && !$job->getPrinted() && !$job->getQtyItemsSuccessful()) {
|
70 |
+
$noUpdates = 1;
|
71 |
+
} elseif($job->getCompleted() && $job->getPrinted()) {
|
72 |
+
$noUpdates = 1;
|
73 |
+
}
|
74 |
+
$block = $this->getLayout()->createBlock('synergeticagency_gls/adminhtml_sales_gls_shipment_job_grid_renderer_action');
|
75 |
+
$button = $block->render($job);
|
76 |
+
$errorItems = $this->getLayout()->createBlock('synergeticagency_gls/adminhtml_sales_gls_shipment_job_grid_renderer_erroritems')->render($job);
|
77 |
+
$returnArray[] = array(
|
78 |
+
'id' => $job->getId(),
|
79 |
+
'status' => $job->getStatus(),
|
80 |
+
'printed' => $job->getPrinted() ? Mage::helper('synergeticagency_gls')->__('Yes') : Mage::helper('synergeticagency_gls')->__('No'),
|
81 |
+
'completed' => $job->getCompleted() ? Mage::helper('synergeticagency_gls')->__('Yes') : Mage::helper('synergeticagency_gls')->__('No'),
|
82 |
+
'error_messages' => $job->getErrorMessages(),
|
83 |
+
'error_items' => $errorItems,
|
84 |
+
'no_updates' => $noUpdates,
|
85 |
+
'action' => $button
|
86 |
+
);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
echo json_encode($returnArray);
|
90 |
+
die(); // not needed magento takes care about but just to be sure
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* download of combined pdf
|
95 |
+
* @return null
|
96 |
+
* @throws Exception
|
97 |
+
*/
|
98 |
+
public function printAction() {
|
99 |
+
$jobId = $this->getRequest()->getParam('id');
|
100 |
+
if(empty($jobId)) {
|
101 |
+
Mage::getSingleton('adminhtml/session')->addError('Mass job could not be loaded');
|
102 |
+
$this->_redirectReferer();
|
103 |
+
return null;
|
104 |
+
}
|
105 |
+
$job = Mage::getModel('synergeticagency_gls/shipment_job')->load($jobId);
|
106 |
+
if(!$job || !$job->getId() || $job->getPrinted() || !$job->getCompleted() || !$job->getPdfFile()) {
|
107 |
+
Mage::getSingleton('adminhtml/session')->addError('Mass job could not be loaded');
|
108 |
+
$this->_redirectReferer();
|
109 |
+
return null;
|
110 |
+
}
|
111 |
+
|
112 |
+
$pdfFile = Mage::getBaseDir().DS.$job->getPdfFile();
|
113 |
+
if(!is_file($pdfFile) || !is_readable($pdfFile)) {
|
114 |
+
Mage::getSingleton('adminhtml/session')->addError('PDF file invalid');
|
115 |
+
$this->_redirectReferer();
|
116 |
+
return null;
|
117 |
+
}
|
118 |
+
|
119 |
+
$job->setPrinted(1);
|
120 |
+
$job->save();
|
121 |
+
|
122 |
+
$name = pathinfo($pdfFile, PATHINFO_BASENAME);
|
123 |
+
$this->_prepareDownloadResponse($name, array(
|
124 |
+
'type' => 'filename',
|
125 |
+
'value' => $pdfFile,
|
126 |
+
),
|
127 |
+
'application/pdf'
|
128 |
+
);
|
129 |
+
}
|
130 |
+
}
|
app/code/community/SynergeticAgency/Gls/controllers/Adminhtml/Gls/ShipmentController.php
CHANGED
@@ -60,6 +60,67 @@ class SynergeticAgency_Gls_Adminhtml_Gls_ShipmentController extends Mage_Adminht
|
|
60 |
$this->renderLayout();
|
61 |
}
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
/**
|
64 |
* Initialising the sales GLS deliveries grid view
|
65 |
*/
|
@@ -72,238 +133,358 @@ class SynergeticAgency_Gls_Adminhtml_Gls_ShipmentController extends Mage_Adminht
|
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
-
*
|
76 |
-
* @todo Refactor printAction: Too much code in one function ;-(
|
77 |
-
* @return null
|
78 |
-
* @throws Exception
|
79 |
-
* @throws Zend_Locale_Exception
|
80 |
*/
|
81 |
-
public function
|
82 |
-
|
83 |
-
$
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
$glsShipment->setSandbox( Mage::getStoreConfig('gls/general/sandbox',$glsShipment->getStore()) );
|
88 |
-
$glsShipmentAddress = $glsShipment->getShipmentAddress();
|
89 |
-
$glsShipmentParcels = $glsShipment->getShipmentParcels();
|
90 |
-
|
91 |
-
$magentoShipment = Mage::getModel('sales/order_shipment')->load($glsShipment->getShipmentId());
|
92 |
-
$store = $magentoShipment->getStore();
|
93 |
-
|
94 |
-
// do prechecks
|
95 |
-
$check = $this->doChecks($magentoShipment,$glsShipment);
|
96 |
-
if($check === false) {
|
97 |
-
$this->_redirectReferer();
|
98 |
-
return null;
|
99 |
-
}
|
100 |
-
|
101 |
-
$connector = $this->getConnector($store);
|
102 |
-
$shipment = $this->getShipment($magentoShipment,$glsShipment,$store);
|
103 |
-
$deliveryAddress = $this->getDeliveryAddress($shipment,$glsShipmentAddress,$glsShipment);
|
104 |
-
if($deliveryAddress === false) {
|
105 |
-
$this->_redirectReferer();
|
106 |
-
return null;
|
107 |
-
}
|
108 |
-
$check = $this->setAlternateShipperAddress($shipment,$store);
|
109 |
-
if($check === false) {
|
110 |
$this->_redirectReferer();
|
111 |
return null;
|
112 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
|
|
|
124 |
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
-
$shipmentReferences[] = date( "r" );
|
135 |
-
$shipmentReferences[] = basename( __FILE__ );
|
136 |
-
|
137 |
-
$shipment->setReferences( $shipmentReferences );
|
138 |
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
if( $this->getGlsHelperData()->getGeneralGlsConfig('logging_enabled') == 1 ){
|
144 |
-
Mage::log( $connector->getShipment()->toJson(), Zend_Log::DEBUG );
|
145 |
}
|
|
|
|
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
$this->_redirectReferer();
|
154 |
return null;
|
155 |
}
|
156 |
|
157 |
-
$
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
if( $this->getGlsHelperData()->getGeneralGlsConfig('logging_enabled') == 1 ){
|
162 |
-
Mage::log( $connector->getCurlResponse(), Zend_Log::DEBUG );
|
163 |
}
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
Mage::getSingleton('adminhtml/session')->addError(
|
170 |
-
|
171 |
-
"<br /><textarea name=\"gls_json_debug\" style=\"width: 80%;\">" . $connector->getShipment()->toJson() . $connector->getError()->getModelState( true ) .
|
172 |
-
"</textarea><br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00005")
|
173 |
);
|
174 |
-
$this->
|
175 |
-
|
|
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
$this->_redirectReferer();
|
178 |
return null;
|
179 |
-
}
|
180 |
-
// get the shipment object right after the GLS-API Response for further processing
|
181 |
-
// i.e. to write the pdf into a file
|
182 |
-
/** @var SynergeticAgency_GlsConnector_Model_Shipment $shipmentResponse */
|
183 |
-
$shipmentResponse = $connector->getShipment();
|
184 |
-
|
185 |
-
$consignmentId = $shipmentResponse->getConsignmentId();
|
186 |
-
if(empty($consignmentId)) {
|
187 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
188 |
-
Mage::helper('synergeticagency_gls')->__('No GLS ConsignmentId available or empty in GLS-API shipment response') .
|
189 |
-
"<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00006")
|
190 |
-
);
|
191 |
-
$this->getGlsHelperLog()->logApi( __METHOD__, __LINE__, "No GLS ConsignmentId available or empty in GLS-API shipment response", Zend_Log::ERR );
|
192 |
-
$this->_redirectReferer();
|
193 |
-
return null;
|
194 |
-
}
|
195 |
|
196 |
-
|
197 |
-
|
198 |
-
$glsShipment->save();
|
199 |
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
}
|
216 |
-
$
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
// combine labels, if shipment response has more than one label
|
225 |
-
if( is_array($labels) ){
|
226 |
-
if( count($labels) > 1 ){
|
227 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, count($labels) . " Labels in GLS response", Zend_Log::INFO );
|
228 |
-
$tmpLabelFilesArray = array();
|
229 |
-
$tmpLabelPath = rtrim(Mage::getBaseDir('var') ,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
230 |
-
|
231 |
-
foreach( $labels as $key => $label){
|
232 |
-
$savedLabel = $this->decodeAndSaveLabel( $label, $tmpLabelPath . $shipmentResponse->getConsignmentId() . '.' . str_pad ( $key, 3, 0, STR_PAD_RIGHT ) . '.pdf');
|
233 |
-
if( $savedLabel !== false && is_readable($savedLabel) ){
|
234 |
-
$tmpLabelFilesArray[$key] = $savedLabel;
|
235 |
}
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
if( is_readable($combinedFile) ){
|
243 |
-
$labelHeaderData = file_get_contents( $combinedFile );
|
244 |
}
|
|
|
|
|
245 |
}
|
246 |
-
|
247 |
} else {
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
# print "SUCCESS base64_decode \$shipmentResponse->getLabels()[0]:<br><pre>" . ($shipmentResponse->getLabels()[0]) . "</pre><br>";
|
255 |
-
# $this->decodeAndSaveLabel( $shipmentResponse->getLabels()[0], $tmpLabelPath . date("Ymd-His") . "." . $shipmentResponse->getConsignmentId() . '.pdf' );
|
256 |
-
# exit();
|
257 |
-
#}
|
258 |
-
// just for debugging: write and save label STOP
|
259 |
-
|
260 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "One label in GLS response", Zend_Log::INFO );
|
261 |
-
$labelHeaderData = base64_decode($shipmentResponse->getLabels()[0]);
|
262 |
}
|
263 |
}
|
264 |
-
|
265 |
-
|
266 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$pdfCheckLine=" . substr ( $pdfCheckLine, 0, 25 ), Zend_Log::INFO );
|
267 |
-
if( !preg_match("/^%PDF-[0-9]+\\.[0-9]+$/", $pdfCheckLine) ){
|
268 |
-
|
269 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
270 |
-
sprintf(Mage::helper('synergeticagency_gls')->__('The label data with GLS-ConsignmentId %s obtained are not correct'), $shipmentResponse->getConsignmentId()) .
|
271 |
-
"<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00013")
|
272 |
-
);
|
273 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, sprintf("The label data with GLS-ConsignmentId %s obtained are not correct", $shipmentResponse->getConsignmentId()), Zend_Log::INFO );
|
274 |
-
|
275 |
-
$glsShipment->setPrinted(0);
|
276 |
-
$glsShipment->save();
|
277 |
-
|
278 |
-
$this->_redirectReferer();
|
279 |
-
return null;
|
280 |
}
|
|
|
281 |
|
282 |
-
|
283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
$this->_prepareDownloadResponse(
|
285 |
-
|
286 |
-
$
|
287 |
'application/pdf'
|
288 |
);
|
289 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "Label" . $shipmentResponse->getConsignmentId() . ".pdf sent to header", Zend_Log::INFO );
|
290 |
-
|
291 |
} else {
|
292 |
-
|
293 |
-
|
294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
);
|
296 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, sprintf('Creation of the label with the GLS-ConsignmentId %s failed'), $shipmentResponse->getConsignmentId(), Zend_Log::ERR );
|
297 |
$this->_redirectReferer();
|
298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
}
|
306 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
}
|
308 |
}
|
309 |
|
@@ -322,7 +503,7 @@ class SynergeticAgency_Gls_Adminhtml_Gls_ShipmentController extends Mage_Adminht
|
|
322 |
"<br />" . Mage::helper('synergeticagency_gls')->__('The shipment id is not set or found') .
|
323 |
"<br />" . Mage::helper('synergeticagency_gls')->__('or') .
|
324 |
"<br />" . Mage::helper('synergeticagency_gls')->__('The label has already been printed') .
|
325 |
-
"<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'),
|
326 |
);
|
327 |
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "GLS Shipment can not be edited. " . get_class($glsShipment) . "::id is not set/found or the label has already been printed: " . get_class($glsShipment) . "::printed == 1" , Zend_Log::ERR );
|
328 |
$this->_redirectReferer();
|
@@ -353,7 +534,7 @@ class SynergeticAgency_Gls_Adminhtml_Gls_ShipmentController extends Mage_Adminht
|
|
353 |
Mage::getSingleton('adminhtml/session')->addError(
|
354 |
Mage::helper('synergeticagency_gls')->__('GLS Shipment can not be saved') .
|
355 |
"<br />" . Mage::helper('synergeticagency_gls')->__('The label has already been printed') .
|
356 |
-
"<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'),
|
357 |
);
|
358 |
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "GLS Shipment can not be saved. The label has already been printed: " . get_class($glsShipment) . "::printed == 1" , Zend_Log::ERR );
|
359 |
$this->_redirect('adminhtml/sales_shipment/view/',array('shipment_id' => $shimentId));
|
@@ -377,7 +558,7 @@ class SynergeticAgency_Gls_Adminhtml_Gls_ShipmentController extends Mage_Adminht
|
|
377 |
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$data: " . var_export($data, 1), Zend_Log::INFO);
|
378 |
//$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$shipment: " . var_export($shipment, 1), Zend_Log::INFO);
|
379 |
//$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$glsShipment:" . var_export($glsShipment, 1), Zend_Log::INFO);
|
380 |
-
$this->getGlsHelperLog()->logException( $e, __METHOD__, __LINE__, Zend_Log::ERR, 'GLS Shipment could not be saved',
|
381 |
$this->_redirectReferer();
|
382 |
return null;
|
383 |
}
|
@@ -421,330 +602,4 @@ class SynergeticAgency_Gls_Adminhtml_Gls_ShipmentController extends Mage_Adminht
|
|
421 |
$this->glsHelperData = $glsHelperData;
|
422 |
}
|
423 |
|
424 |
-
|
425 |
-
|
426 |
-
/**
|
427 |
-
* @param Mage_Sales_Model_Order_Shipment $magentoShipment
|
428 |
-
* @param SynergeticAgency_Gls_Model_Shipment $glsShipment
|
429 |
-
* @return bool
|
430 |
-
*/
|
431 |
-
private function doChecks($magentoShipment,$glsShipment) {
|
432 |
-
if(!$magentoShipment->getId()) {
|
433 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
434 |
-
Mage::helper('synergeticagency_gls')->__('Magento shipment is missing') .
|
435 |
-
sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00001")
|
436 |
-
);
|
437 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "Magento shipment is missing(Error-Code: 00001)", Zend_Log::ERR );
|
438 |
-
return false;
|
439 |
-
}
|
440 |
-
|
441 |
-
if($glsShipment->getPrinted() == '1') {
|
442 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
443 |
-
Mage::helper('synergeticagency_gls')->__('GLS Label is already printed') .
|
444 |
-
sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00002")
|
445 |
-
);
|
446 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "GLS Label is already printed(Error-Code: 00002)", Zend_Log::ERR );
|
447 |
-
return false;
|
448 |
-
}
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
$check = Mage::helper('synergeticagency_gls')->checkConfigSettings();
|
453 |
-
if($check !== true) {
|
454 |
-
$errorDetails = '';
|
455 |
-
if( is_array($check) ){
|
456 |
-
$errorDetails = "<br />";
|
457 |
-
foreach( $check AS $key => $value ){
|
458 |
-
$errorDetails.= $key . ": " . $value . "<br />";
|
459 |
-
}
|
460 |
-
}
|
461 |
-
|
462 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
463 |
-
sprintf(Mage::helper('synergeticagency_gls')->__('The GLS %s has errors or is not complete'), Mage::helper('synergeticagency_gls')->__('Basic configuration')) .
|
464 |
-
sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00003") .
|
465 |
-
"<br />" . $errorDetails
|
466 |
-
);
|
467 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "The GLS Basic configuration has errors or is not complete(Error-Code: 00003)", Zend_Log::ERR );
|
468 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, var_export($check,1), Zend_Log::INFO );
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
return false;
|
473 |
-
}
|
474 |
-
return true;
|
475 |
-
}
|
476 |
-
|
477 |
-
/**
|
478 |
-
* @param Mage_Core_Model_Store $store
|
479 |
-
* @return SynergeticAgency_GlsConnector_Connector
|
480 |
-
*/
|
481 |
-
private function getConnector($store) {
|
482 |
-
$connector = new SynergeticAgency_GlsConnector_Connector();
|
483 |
-
|
484 |
-
// in default sandbox is enabled
|
485 |
-
if( Mage::getStoreConfig('gls/general/sandbox',$store) !== '1' ){
|
486 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "gls/general/sandbox is set to '0'", Zend_Log::INFO );
|
487 |
-
$connector->setGlsApiSandbox( false );
|
488 |
-
}
|
489 |
-
|
490 |
-
$connector->setGlsApiUrl(Mage::getStoreConfig('gls/general/api_url',$store));
|
491 |
-
$connector->setGlsApiAuthUsername( Mage::getStoreConfig('gls/general/apiAuthUsername',$store) );
|
492 |
-
$connector->setGlsApiAuthPassword( Mage::helper('core')->decrypt(Mage::getStoreConfig('gls/general/apiAuthPassword', $store)) );
|
493 |
-
|
494 |
-
// disabled by default
|
495 |
-
if(Mage::getStoreConfig('gls/general/connector_log_enabled',$store) === '1') {
|
496 |
-
$connector->getLog()->activate()->setLogFile(Mage::getBaseDir('log').DS.'SynergeticAgency_GlsConnector.log');
|
497 |
-
}
|
498 |
-
return $connector;
|
499 |
-
}
|
500 |
-
|
501 |
-
/**
|
502 |
-
* @param Mage_Sales_Model_Order_Shipment $magentoShipment
|
503 |
-
* @param SynergeticAgency_Gls_Model_Shipment $glsShipment
|
504 |
-
* @param Mage_Core_Model_Store $store
|
505 |
-
* @return SynergeticAgency_GlsConnector_Model_Shipment
|
506 |
-
*/
|
507 |
-
private function getShipment($magentoShipment,$glsShipment,$store) {
|
508 |
-
$shipment = new SynergeticAgency_GlsConnector_Model_Shipment();
|
509 |
-
|
510 |
-
|
511 |
-
// reformat date without time
|
512 |
-
$shippingDate = date('Y-m-d',strtotime($glsShipment->getShippingDate()));
|
513 |
-
$glsShipment->setShippingDate($shippingDate);
|
514 |
-
// if shipping date is in the past and label is not printed set it to now
|
515 |
-
if(strtotime($shippingDate) < strtotime(date('Y-m-d'))) {
|
516 |
-
$shippingDate = date('Y-m-d');
|
517 |
-
$glsShipment->setShippingDate($shippingDate);
|
518 |
-
$glsShipment->save();
|
519 |
-
}
|
520 |
-
|
521 |
-
// set up shipment basic values
|
522 |
-
$shipperId = Mage::getStoreConfig('gls/general/customer_id', $store) .
|
523 |
-
" " .
|
524 |
-
Mage::getStoreConfig('gls/general/contact_id', $store);
|
525 |
-
$shipment
|
526 |
-
->setCustomerId( Mage::getStoreConfig('gls/general/customer_id',$store) )
|
527 |
-
->setContactId( Mage::getStoreConfig('gls/general/contact_id',$store) )
|
528 |
-
->setShipperId($shipperId)
|
529 |
-
->setShipmentDate($glsShipment->getShippingDate() )
|
530 |
-
->setReference( $magentoShipment->getOrder()->getIncrementId() );
|
531 |
-
return $shipment;
|
532 |
-
}
|
533 |
-
|
534 |
-
/**
|
535 |
-
* @param SynergeticAgency_GlsConnector_Model_Shipment $shipment
|
536 |
-
* @param SynergeticAgency_Gls_Model_Shipment_Address $glsShipmentAddress
|
537 |
-
* @param SynergeticAgency_Gls_Model_Shipment $glsShipment
|
538 |
-
* @return bool|SynergeticAgency_GlsConnector_Model_Address
|
539 |
-
*/
|
540 |
-
private function getDeliveryAddress($shipment,$glsShipmentAddress,$glsShipment) {
|
541 |
-
|
542 |
-
/** @var SynergeticAgency_GlsConnector_Model_Address $deliveryAddress */
|
543 |
-
$deliveryAddress = $shipment->getAddresses( SynergeticAgency_GlsConnector_Model_Address::GLS_API_ADDRESS_DELIVERY );
|
544 |
-
|
545 |
-
try {
|
546 |
-
$deliveryAddress
|
547 |
-
->setName1( $glsShipmentAddress->getName1())
|
548 |
-
->setName2( $glsShipmentAddress->getName2())
|
549 |
-
->setName3( $glsShipmentAddress->getName3())
|
550 |
-
->setStreet1( $glsShipmentAddress->getStreet1())
|
551 |
-
->setCountry( $glsShipmentAddress->getCountry())
|
552 |
-
->setZipCode($glsShipmentAddress->getZipCode())
|
553 |
-
->setCity( $glsShipmentAddress->getCity())
|
554 |
-
->setEmail( $glsShipmentAddress->getEmail())
|
555 |
-
->setPhone( $glsShipmentAddress->getPhone());
|
556 |
-
|
557 |
-
$parcelShopId = $glsShipment->getParcelshopId();
|
558 |
-
if(!empty($parcelShopId)) {
|
559 |
-
// todo: check in name context
|
560 |
-
$deliveryAddress->setContact( $glsShipmentAddress->getName1() );
|
561 |
-
}
|
562 |
-
} catch( Exception $e ){
|
563 |
-
$this->getGlsHelperLog()->logException( $e, __METHOD__, __LINE__, Zend_Log::ERR, 'GLS Shipment could not be created', "00010" );
|
564 |
-
return false;
|
565 |
-
}
|
566 |
-
return $deliveryAddress;
|
567 |
-
}
|
568 |
-
|
569 |
-
/**
|
570 |
-
* @param SynergeticAgency_GlsConnector_Model_Shipment $shipment
|
571 |
-
* @param Mage_Core_Model_Store $store
|
572 |
-
* @return bool
|
573 |
-
*/
|
574 |
-
private function setAlternateShipperAddress($shipment,$store) {
|
575 |
-
if(Mage::getStoreConfig('gls/alternative_shipper/alternative_shipper_enabled',$store) === '1' && Mage::helper('synergeticagency_gls')->checkAlternativeShipper($store)) {
|
576 |
-
$addressAlternativeShipping = new SynergeticAgency_GlsConnector_Model_Address();
|
577 |
-
try {
|
578 |
-
$addressAlternativeShipping->setType(SynergeticAgency_GlsConnector_Model_Address::GLS_API_ADDRESS_ALTERNATIVESHIPPING)
|
579 |
-
->setName1(Mage::getStoreConfig('gls/alternative_shipper/name1',$store))
|
580 |
-
->setName2(Mage::getStoreConfig('gls/alternative_shipper/name2',$store))
|
581 |
-
->setName3(Mage::getStoreConfig('gls/alternative_shipper/name3',$store))
|
582 |
-
->setStreet1(Mage::getStoreConfig('gls/alternative_shipper/street1',$store))
|
583 |
-
->setCountry(Mage::getStoreConfig('gls/alternative_shipper/country',$store))
|
584 |
-
->setZipCode(Mage::getStoreConfig('gls/alternative_shipper/zip_code',$store))
|
585 |
-
->setCity(Mage::getStoreConfig('gls/alternative_shipper/city',$store));
|
586 |
-
} catch( Exception $e ){
|
587 |
-
$this->getGlsHelperLog()->logException( $e, __METHOD__, __LINE__, Zend_Log::ERR, 'GLS Shipment could not be created', "00011" );
|
588 |
-
return false;
|
589 |
-
}
|
590 |
-
$shipment->addAddress( $addressAlternativeShipping );
|
591 |
-
}
|
592 |
-
return true;
|
593 |
-
}
|
594 |
-
|
595 |
-
/**
|
596 |
-
* @param SynergeticAgency_GlsConnector_Model_Shipment $shipment
|
597 |
-
* @param Mage_Core_Model_Store $store
|
598 |
-
* @return bool
|
599 |
-
*/
|
600 |
-
private function setReturnAddress($shipment,$store) {
|
601 |
-
if(Mage::helper('synergeticagency_gls')->checkReturnAddress($store)) {
|
602 |
-
$addressReturn = new SynergeticAgency_GlsConnector_Model_Address();
|
603 |
-
try {
|
604 |
-
$addressReturn->setType(SynergeticAgency_GlsConnector_Model_Address::GLS_API_ADDRESS_RETURN)
|
605 |
-
->setName1(Mage::getStoreConfig('gls/return_address/name1',$store))
|
606 |
-
->setName2(Mage::getStoreConfig('gls/return_address/name2',$store))
|
607 |
-
->setName3(Mage::getStoreConfig('gls/return_address/name3',$store))
|
608 |
-
->setStreet1(Mage::getStoreConfig('gls/return_address/street1',$store))
|
609 |
-
->setCountry(Mage::getStoreConfig('gls/return_address/country',$store))
|
610 |
-
->setZipCode(Mage::getStoreConfig('gls/return_address/zip_code',$store))
|
611 |
-
->setCity(Mage::getStoreConfig('gls/return_address/city',$store));
|
612 |
-
} catch( Exception $e ){
|
613 |
-
$this->getGlsHelperLog()->logException( $e, __METHOD__, __LINE__, Zend_Log::ERR, 'GLS Shipment could not be created', "00011" );
|
614 |
-
return false;
|
615 |
-
}
|
616 |
-
$shipment->addAddress( $addressReturn );
|
617 |
-
}
|
618 |
-
return true;
|
619 |
-
}
|
620 |
-
|
621 |
-
/**
|
622 |
-
* @param SynergeticAgency_Gls_Model_Shipment $glsShipment
|
623 |
-
* @param array $glsShipmentParcels
|
624 |
-
* @param Mage_Core_Model_Store $store
|
625 |
-
* @param Mage_Sales_Model_Order_Shipment $magentoShipment
|
626 |
-
* @param SynergeticAgency_GlsConnector_Model_Shipment $shipment
|
627 |
-
*/
|
628 |
-
private function setParcels($glsShipment,$glsShipmentParcels,$store,$magentoShipment,$shipment) {
|
629 |
-
|
630 |
-
$glsServices = $glsShipment->getServices();
|
631 |
-
$resultingServices = array();
|
632 |
-
if($glsServices && count($glsServices)) {
|
633 |
-
foreach($glsServices as $glsService) {
|
634 |
-
$service = new SynergeticAgency_GlsConnector_Model_Service();
|
635 |
-
switch($glsService->getId()) {
|
636 |
-
case SynergeticAgency_Gls_Model_Gls::SERVICE_EMAILNOTIFICATION:
|
637 |
-
//$service = new SynergeticAgency_GlsConnector_Model_Service();
|
638 |
-
//$service->setName( );
|
639 |
-
// todo not available anymore??
|
640 |
-
//$service->setNotificationEmail($glsShipmentAddress->getEmail());
|
641 |
-
|
642 |
-
break;
|
643 |
-
case SynergeticAgency_Gls_Model_Gls::SERVICE_FLEXDELIVERY:
|
644 |
-
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_FLEXDELIVERYSERVICE );
|
645 |
-
break;
|
646 |
-
case SynergeticAgency_Gls_Model_Gls::SERVICE_THINKGREEN:
|
647 |
-
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_THINKGREENSERVICE);
|
648 |
-
break;
|
649 |
-
case SynergeticAgency_Gls_Model_Gls::SERVICE_PRIVATEDELIVERY:
|
650 |
-
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_PRIVATEDELIVERYSERVICE);
|
651 |
-
break;
|
652 |
-
case SynergeticAgency_Gls_Model_Gls::SERVICE_GUARANTEED:
|
653 |
-
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_GUARANTEED24SERVICE);
|
654 |
-
break;
|
655 |
-
}
|
656 |
-
if(!is_null($service->getName()) && $service->getName() !== '') {
|
657 |
-
$resultingServices[] = $service;
|
658 |
-
}
|
659 |
-
}
|
660 |
-
}
|
661 |
-
|
662 |
-
if($glsShipment->getReturnLabel() === '1' && Mage::helper('synergeticagency_gls')->checkReturnAddress($store)) {
|
663 |
-
$service = new SynergeticAgency_GlsConnector_Model_Service();
|
664 |
-
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_SHOPRETURNSERVICE);
|
665 |
-
$shipment->setReturnLabel(true);
|
666 |
-
$resultingServices[] = $service;
|
667 |
-
}
|
668 |
-
|
669 |
-
foreach($glsShipmentParcels as $parcel) {
|
670 |
-
$apiParcel = new SynergeticAgency_GlsConnector_Model_Parcel();
|
671 |
-
$apiParcel->setWeight($parcel->getWeight());
|
672 |
-
#// sorry, but we cannot use the database table fields
|
673 |
-
#// synergeticagency_gls_shipment_parcel.gls_shipment_parcel_id and
|
674 |
-
#// synergeticagency_gls_shipment_parcel.gls_shipment_id
|
675 |
-
#// as reference for the GLS-API, because the GLS-API just accepts non assosiate arrays here
|
676 |
-
#$apiParcel->pushReference( $parcel->getId(), "gls_shipment_parcel_id" );
|
677 |
-
#$apiParcel->pushReference( $glsShipment->getId(), "gls_shipment_id" );
|
678 |
-
$apiParcel->setReferences( array($parcel->getId()) );
|
679 |
-
|
680 |
-
if($parcel->getCashservice() > 0) {
|
681 |
-
$service = new SynergeticAgency_GlsConnector_Model_Service();
|
682 |
-
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_CASHONDELIVERY);
|
683 |
-
$symbols = Zend_Locale_Data::getList(Mage::getStoreConfig('general/locale/code', $store) , 'symbols');
|
684 |
-
$info = new SynergeticAgency_GlsConnector_Model_Info();
|
685 |
-
$info->setName('amount');
|
686 |
-
$info->setValue(round(floatval(str_replace($symbols['decimal'], '.', $parcel->getCashservice())),2));
|
687 |
-
// special case: if amount has no dezimal point, add decimal point and zero,
|
688 |
-
// because info object is defined as string, but GLS needs "float string"
|
689 |
-
if( !strpos($info->getValue() , '.') ){
|
690 |
-
$info->setValue( $info->getValue() . ".0" );
|
691 |
-
}
|
692 |
-
$service->pushInfo($info);
|
693 |
-
|
694 |
-
$info = new SynergeticAgency_GlsConnector_Model_Info();
|
695 |
-
$info->setName('reference');
|
696 |
-
$info->setValue($magentoShipment->getOrder()->getIncrementId());
|
697 |
-
$service->pushInfo($info);
|
698 |
-
$apiParcel->pushService($service);
|
699 |
-
}
|
700 |
-
|
701 |
-
if($glsShipment->getParcelshopId() !== '' && !is_null($glsShipment->getParcelshopId())) {
|
702 |
-
$service = new SynergeticAgency_GlsConnector_Model_Service();
|
703 |
-
$service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_SHOPDELIVERYSERVICE);
|
704 |
-
$info = new SynergeticAgency_GlsConnector_Model_Info();
|
705 |
-
$info->setName('parcelshopid');
|
706 |
-
$info->setValue($glsShipment->getParcelshopId());
|
707 |
-
$service->pushInfo($info);
|
708 |
-
$apiParcel->pushService($service);
|
709 |
-
}
|
710 |
-
if(count($resultingServices))
|
711 |
-
{
|
712 |
-
foreach($resultingServices as $service) {
|
713 |
-
$apiParcel->pushService($service);
|
714 |
-
}
|
715 |
-
}
|
716 |
-
$shipment->pushParcel($apiParcel);
|
717 |
-
}
|
718 |
-
}
|
719 |
-
|
720 |
-
|
721 |
-
/**
|
722 |
-
* decode base64 string and save to $file
|
723 |
-
*
|
724 |
-
* @param string $label base64 encoded string
|
725 |
-
* @param string $file full path/filename to save file
|
726 |
-
* @return bool|string $returnValue false, if something went wrong,
|
727 |
-
* $filename if saved successful
|
728 |
-
*/
|
729 |
-
private function decodeAndSaveLabel( $label, $file ){
|
730 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "entered", Zend_Log::DEBUG );
|
731 |
-
|
732 |
-
$returnValue = false;
|
733 |
-
|
734 |
-
$base64decodedLabel = base64_decode($label);
|
735 |
-
if( $base64decodedLabel !== false ){
|
736 |
-
if (!$handle = fopen($file, "w")) {
|
737 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, " cannot open file " . $file, Zend_Log::WARN );
|
738 |
-
} else {
|
739 |
-
if (!fwrite($handle, $base64decodedLabel)) {
|
740 |
-
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, " cannot write into file " . $file, Zend_Log::WARN );
|
741 |
-
} else {
|
742 |
-
$returnValue = $file;
|
743 |
-
}
|
744 |
-
fclose($handle);
|
745 |
-
}
|
746 |
-
}
|
747 |
-
|
748 |
-
return $returnValue;
|
749 |
-
}
|
750 |
}
|
60 |
$this->renderLayout();
|
61 |
}
|
62 |
|
63 |
+
/**
|
64 |
+
* Updates parcel quantity via ajax
|
65 |
+
*/
|
66 |
+
public function updateqtyAction() {
|
67 |
+
$id = $this->getRequest()->getParam('id',null);
|
68 |
+
$qty = $this->getRequest()->getParam('qty',null);
|
69 |
+
|
70 |
+
if(!is_numeric($id) || !is_numeric($qty)) {
|
71 |
+
echo json_encode(array('error' => $this->__('Request invalid')));
|
72 |
+
die();
|
73 |
+
}
|
74 |
+
$id = intval($id);
|
75 |
+
$qty = intval($qty);
|
76 |
+
$glsShipment = Mage::getModel('synergeticagency_gls/shipment')->load($id);
|
77 |
+
if(!$glsShipment || !$glsShipment->getId()) {
|
78 |
+
echo json_encode(array('error' => $this->__('Request invalid')));
|
79 |
+
die();
|
80 |
+
}
|
81 |
+
$parcels = $glsShipment->getShipmentParcels();
|
82 |
+
$origQty = $parcels->count();
|
83 |
+
if($qty === $origQty || $qty < SynergeticAgency_Gls_Model_Shipment::GLS_SHIPMENT_MIN_PARCELS || $qty > SynergeticAgency_Gls_Model_Shipment::GLS_SHIPMENT_MAX_PARCELS) {
|
84 |
+
echo json_encode(array('error' => sprintf($this->__('No valid number. Please enter numbers between %s and %s.'),SynergeticAgency_Gls_Model_Shipment::GLS_SHIPMENT_MIN_PARCELS, SynergeticAgency_Gls_Model_Shipment::GLS_SHIPMENT_MAX_PARCELS)));
|
85 |
+
die();
|
86 |
+
}
|
87 |
+
if(Mage::helper('synergeticagency_gls/validate')->isCashService($glsShipment->getMagentoShipment())) {
|
88 |
+
echo json_encode(array('error' => $this->__('Not available with cash on delivery')));
|
89 |
+
die();
|
90 |
+
}
|
91 |
+
if($glsShipment->getPrinted()) {
|
92 |
+
echo json_encode(array('error' => $this->__('Shipment already printed')));
|
93 |
+
die();
|
94 |
+
}
|
95 |
+
if($glsShipment->getJobId()) {
|
96 |
+
echo json_encode(array('error' => $this->__('Shipment in mass action')));
|
97 |
+
die();
|
98 |
+
}
|
99 |
+
if($qty < $origQty) {
|
100 |
+
$parcels = $glsShipment->getShipmentParcels(Varien_Data_Collection::SORT_ORDER_DESC); // different order
|
101 |
+
$qtyRemove = $origQty-$qty;
|
102 |
+
$i=0;
|
103 |
+
foreach($parcels as $parcel) {
|
104 |
+
if($i < $qtyRemove) {
|
105 |
+
$parcel->delete();
|
106 |
+
} else {
|
107 |
+
break;
|
108 |
+
}
|
109 |
+
$i++;
|
110 |
+
}
|
111 |
+
} else {
|
112 |
+
$qtyAdd = $qty-$origQty;
|
113 |
+
$firstParcel = $parcels->getFirstItem();
|
114 |
+
for($i=0;$i<$qtyAdd;$i++) {
|
115 |
+
$newParcel = clone $firstParcel;
|
116 |
+
$newParcel->setId(null);
|
117 |
+
$newParcel->save();
|
118 |
+
}
|
119 |
+
}
|
120 |
+
echo json_encode(array('success' => true));
|
121 |
+
die();
|
122 |
+
}
|
123 |
+
|
124 |
/**
|
125 |
* Initialising the sales GLS deliveries grid view
|
126 |
*/
|
133 |
}
|
134 |
|
135 |
/**
|
136 |
+
* Mass creation of magento shipments and gls shipments from order grid(sales_order_grid_massaction-select: createGlsShipment)
|
|
|
|
|
|
|
|
|
137 |
*/
|
138 |
+
public function masscreateAction() {
|
139 |
+
$orderIds = $this->getRequest()->getParam('order_ids');
|
140 |
+
if(!is_array($orderIds) || !count($orderIds)) {
|
141 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
142 |
+
Mage::helper('synergeticagency_gls')->__('Please select orders to process')
|
143 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
$this->_redirectReferer();
|
145 |
return null;
|
146 |
}
|
147 |
+
$helper = Mage::helper('synergeticagency_gls');
|
148 |
+
$createdOrderIds = array();
|
149 |
+
foreach($orderIds as $orderId) {
|
150 |
+
try {
|
151 |
+
$order = Mage::getModel('sales/order')->load((int)$orderId);
|
152 |
+
if (!$order || !$order->getId()) {
|
153 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('synergeticagency_gls')->__('Order is not available anymore. OrderId:').' '.$orderId);
|
154 |
+
continue;
|
155 |
+
}
|
156 |
|
157 |
+
if($order->getShipmentsCollection() && count($order->getShipmentsCollection())) {
|
158 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('synergeticagency_gls')->__('Shipment could not be created. Shipment already exists. OrderId:').' '.$order->getIncrementId());
|
159 |
+
//$helper->setOrderStatus($order,$helper->__('GLS shipment creating error:').' '.$helper->__('Shipment already exists'),true);
|
160 |
+
// we don't add error here, because its common to select already created ones and we don't want to have errors everywhere
|
161 |
+
continue;
|
162 |
+
}
|
163 |
|
164 |
+
if(!$order->canShip()) {
|
165 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('synergeticagency_gls')->__('Shipment could not be created. Please check order data manually. OrderId:').' '.$order->getIncrementId());
|
166 |
+
$helper->setOrderStatus($order,$helper->__('GLS shipment creating error:').' '.$helper->__('Undefined error'),true);
|
167 |
+
continue;
|
168 |
+
}
|
169 |
+
$store = $order->getStore();
|
170 |
+
$doNotify = (int)Mage::getStoreConfig('gls/shipment/notify_customer_shipment',$store);
|
171 |
|
172 |
+
$shipment = $order->prepareShipment();
|
173 |
|
174 |
+
$glsModel = Mage::getModel('synergeticagency_gls/gls');
|
175 |
+
$data = $glsModel->prepareGlsShipmentData($shipment);
|
176 |
+
if($data === false) {
|
177 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('synergeticagency_gls')->__('Shipment could not be created. Please check order data manually. OrderId:').' '.$order->getIncrementId());
|
178 |
+
$helper->setOrderStatus($order,$helper->__('GLS shipment creating error:').' '.$helper->__('Invalid order data for GLS shipment'),true);
|
179 |
+
continue;
|
180 |
+
}
|
181 |
+
$check = $glsModel->validateGlsShipmentData($data,$shipment);
|
182 |
+
if($check !== true) {
|
183 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('synergeticagency_gls')->__('Shipment could not be created. Please check order data manually. OrderId:').' '.$order->getIncrementId()." Error Message: ".$check);
|
184 |
+
$helper->setOrderStatus($order,$helper->__('GLS shipment creating error:').' '.$helper->__('Invalid order data for GLS shipment'),true);
|
185 |
+
continue;
|
186 |
+
}
|
187 |
|
188 |
+
$shipment->register();
|
189 |
+
$shipment->setEmailSent($doNotify);
|
190 |
+
$shipment->getOrder()->setIsInProcess(true);
|
191 |
+
Mage::getModel('core/resource_transaction')
|
192 |
+
->addObject($shipment)
|
193 |
+
->addObject($shipment->getOrder())
|
194 |
+
->save();
|
195 |
+
|
196 |
+
if ($doNotify) $shipment->sendEmail($doNotify, '');
|
197 |
+
|
198 |
+
// create gls shipment
|
199 |
+
try {
|
200 |
+
$glsModel->saveGlsShipment($data, $shipment);
|
201 |
+
$helper->setOrderStatus($order,$helper->__('GLS shipment created successful'));
|
202 |
+
$createdOrderIds[] = $order->getIncrementId();
|
203 |
+
} catch(Exception $e) {
|
204 |
+
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$data: " . var_export($data, 1), Zend_Log::INFO);
|
205 |
+
$this->getGlsHelperLog()->logException( $e, __METHOD__, __LINE__, Zend_Log::ERR, 'GLS Shipment could not be saved', SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_SHIPMENT_NOT_CREATED);
|
206 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('synergeticagency_gls')->__('Shipment could not be created. Please check order data manually. OrderId:').' '.$order->getIncrementId());
|
207 |
+
$helper->setOrderStatus($order,$helper->__('GLS shipment creating error:').' '.$helper->__('Undefined error'),true);
|
208 |
+
continue;
|
209 |
+
}
|
210 |
+
unset($shipment);
|
211 |
+
} catch(Exception $e) {
|
212 |
+
if (!empty($order) && $order->getIncrementId()) {
|
213 |
+
$orderId = $order->getIncrementId();
|
214 |
+
$helper->setOrderStatus($order,$helper->__('GLS shipment creating error:').' '.$helper->__('Undefined error'),true);
|
215 |
+
}
|
216 |
+
Mage::getSingleton('adminhtml/session')->addError('Exception (Order # ' . $orderId . '): ' . $e->getMessage());
|
217 |
+
}
|
218 |
}
|
|
|
|
|
|
|
|
|
219 |
|
220 |
+
if(count($createdOrderIds)) {
|
221 |
+
Mage::getSingleton('adminhtml/session')->addNotice(
|
222 |
+
Mage::helper('synergeticagency_gls')->__('Shipments created for following order ids:') . ' ' . implode(' / ', $createdOrderIds)
|
223 |
+
);
|
|
|
|
|
224 |
}
|
225 |
+
$this->_redirectReferer();
|
226 |
+
}
|
227 |
|
228 |
+
/**
|
229 |
+
* Mass print from gls shipment grid. This will prepare cron data(synergeticagency_gls_shipment_grid_massaction-select: print)
|
230 |
+
* This function will operate with gls-shipment ID's
|
231 |
+
*
|
232 |
+
*/
|
233 |
+
public function massprintshipmentAction() {
|
234 |
+
$glsShipmentIds = $this->getRequest()->getParam('gls_shipment_id');
|
235 |
+
$shipmentsCount = 0;
|
236 |
+
if(!is_array($glsShipmentIds) || !count($glsShipmentIds)) {
|
237 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
238 |
+
Mage::helper('synergeticagency_gls')->__('Please select shipments to process')
|
239 |
+
);
|
240 |
$this->_redirectReferer();
|
241 |
return null;
|
242 |
}
|
243 |
|
244 |
+
$maxShipments = (int)Mage::getStoreConfig('gls/shipment/max_batch_amount');
|
245 |
+
if(empty($maxShipments)) {
|
246 |
+
$maxShipments = 100;
|
|
|
|
|
|
|
247 |
}
|
248 |
|
249 |
+
$glsShipmentCollection = Mage::getModel('synergeticagency_gls/shipment')->getCollection();
|
250 |
+
$glsShipmentCollection
|
251 |
+
->addFieldToSelect('*') // needed fore save - otherwise we would have incomplete objects
|
252 |
+
->addFieldToFilter('gls_shipment_id',array('in' => $glsShipmentIds))
|
253 |
+
->addFieldToFilter('printed',array('neq' => 1))
|
254 |
+
->addFieldToFilter('job_id',array('null' => true))
|
255 |
+
->addOrder('gls_shipment_id',$glsShipmentCollection::SORT_ORDER_ASC) // FIFO
|
256 |
+
->load();
|
257 |
+
|
258 |
+
if($glsShipmentCollection->count() > 0) {
|
259 |
+
$job = Mage::getModel( 'synergeticagency_gls/shipment_job' );
|
260 |
+
$job->setDataChanges( true ); // otherwise no save is possible and we need the id
|
261 |
+
$job->setCreatedAt(Mage::getModel('core/date')->gmtDate());
|
262 |
+
$job->save();
|
263 |
+
foreach($glsShipmentCollection as $glsShipment) {
|
264 |
+
if($shipmentsCount >= $maxShipments) {
|
265 |
+
break;
|
266 |
+
}
|
267 |
+
$glsShipment->setJobId( $job->getId() );
|
268 |
+
$glsShipment->save();
|
269 |
+
$shipmentsCount++;
|
270 |
+
}
|
271 |
|
272 |
+
Mage::getSingleton('adminhtml/session')->addNotice(
|
273 |
+
sprintf(Mage::helper('synergeticagency_gls')->__('Successfully created mass print job with %s items'),$shipmentsCount)
|
274 |
+
);
|
275 |
+
$job->setQtyItemsOpen($shipmentsCount);
|
276 |
+
$job->save();
|
277 |
+
|
278 |
+
$this->_redirect('adminhtml/gls_shipment_job/index/');
|
279 |
+
} else {
|
280 |
Mage::getSingleton('adminhtml/session')->addError(
|
281 |
+
Mage::helper('synergeticagency_gls')->__('No labels could be printed')
|
|
|
|
|
282 |
);
|
283 |
+
$this->_redirectReferer();
|
284 |
+
}
|
285 |
+
}
|
286 |
|
287 |
+
/**
|
288 |
+
* Mass print from order grid. This will prepare cron data(sales_order_grid_massaction-select: printGlsLabels)
|
289 |
+
* This function will operate with order ID's
|
290 |
+
*
|
291 |
+
* @return null
|
292 |
+
* @throws Exception
|
293 |
+
*/
|
294 |
+
public function massprintAction() {
|
295 |
+
$orderIds = $this->getRequest()->getParam('order_ids');
|
296 |
+
if(!is_array($orderIds) || !count($orderIds)) {
|
297 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
298 |
+
Mage::helper('synergeticagency_gls')->__('Please select orders to process')
|
299 |
+
);
|
300 |
$this->_redirectReferer();
|
301 |
return null;
|
302 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
|
304 |
+
// sort orders by "first in, first out"
|
305 |
+
sort($orderIds,SORT_NUMERIC);
|
|
|
306 |
|
307 |
+
$maxShipments = (int)Mage::getStoreConfig('gls/shipment/max_batch_amount');
|
308 |
+
if(empty($maxShipments)) {
|
309 |
+
$maxShipments = 100;
|
310 |
+
}
|
311 |
+
$notProcessedOrders = array();
|
312 |
+
// use direct, to combine the labesls without using the cron. In this case a header will be sent including all labels.
|
313 |
+
// currently this "direct" implementation is implemented for testing purposes. However, this could be used as additional feature later on.
|
314 |
+
$direct = false;
|
315 |
+
$labels = array();
|
316 |
+
$errorMessages = array();
|
317 |
+
$shipmentsCount = 0;
|
318 |
+
$job = Mage::getModel('synergeticagency_gls/shipment_job');
|
319 |
+
$job->setDataChanges(true); // otherwise no save is possible and we need the id
|
320 |
+
$job->setCreatedAt(Mage::getModel('core/date')->gmtDate());
|
321 |
+
$job->save();
|
322 |
+
foreach($orderIds as $orderId) {
|
323 |
+
$glsShipmentCollection = Mage::getModel('synergeticagency_gls/shipment')->getCollection();
|
324 |
+
$glsShipmentCollection
|
325 |
+
->addFieldToFilter('printed',array('neq' => 1))
|
326 |
+
->addFieldToFilter('job_id',array('null' => true))
|
327 |
+
->addFieldToFilter('order_id',$orderId)
|
328 |
+
->load();
|
329 |
+
if(!$glsShipmentCollection->count()) {
|
330 |
+
$notProcessedOrders[] = $orderId;
|
331 |
+
continue;
|
332 |
}
|
333 |
+
foreach($glsShipmentCollection as $glsShipment) {
|
334 |
+
if($direct) {
|
335 |
+
try {
|
336 |
+
$glsShipmentLabels = $glsShipment->getLabels();
|
337 |
+
if(!count($glsShipmentLabels)) {
|
338 |
+
$notProcessedOrders[] = $orderId;
|
339 |
+
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
}
|
341 |
+
$labels = array_merge($labels,$glsShipmentLabels);
|
342 |
+
} catch (Exception $e) {
|
343 |
+
if(!$glsShipment->getErrorMessage()) {
|
344 |
+
$glsShipment->setErrorMessage($e->getMessage());
|
345 |
+
$glsShipment->setErrorCode(SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_UNDEFINED); // undefined
|
346 |
+
$glsShipment->save();
|
|
|
|
|
347 |
}
|
348 |
+
$errorMessages[] = $e->getMessage();
|
349 |
+
$notProcessedOrders[] = $orderId;
|
350 |
}
|
|
|
351 |
} else {
|
352 |
+
if($shipmentsCount > $maxShipments) {
|
353 |
+
break;
|
354 |
+
}
|
355 |
+
$shipmentsCount++;
|
356 |
+
$glsShipment->setJobId($job->getId());
|
357 |
+
$glsShipment->save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
}
|
359 |
}
|
360 |
+
if($shipmentsCount > $maxShipments) {
|
361 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
}
|
363 |
+
}
|
364 |
|
365 |
+
if(count($notProcessedOrders)) {
|
366 |
+
// get the increment ids
|
367 |
+
$incrementIds = array();
|
368 |
+
$orderCollection = Mage::getModel('sales/order')
|
369 |
+
->getCollection()
|
370 |
+
->addFieldToSelect('increment_id')
|
371 |
+
->addFieldToFilter('entity_id',array('in' => $notProcessedOrders))
|
372 |
+
->load();
|
373 |
+
foreach($orderCollection as $order) {
|
374 |
+
$incrementIds[] = $order->getIncrementId();
|
375 |
+
}
|
376 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
377 |
+
Mage::helper('synergeticagency_gls')->__('Following orders could not be processed:').' '.implode(' / ',$incrementIds)
|
378 |
+
);
|
379 |
+
}
|
380 |
+
if($direct) {
|
381 |
+
if(count($labels)) {
|
382 |
+
$connector = new SynergeticAgency_GlsConnector_Connector();
|
383 |
+
if(count($labels) === 1) {
|
384 |
+
$pdf = array_shift($labels);
|
385 |
+
} else {
|
386 |
+
$pdf = $connector->combineLabels($labels);
|
387 |
+
// optional enhancement: If you want to save the combined label in the filesstem,
|
388 |
+
// feel free to use i.e. the PHP function file_put_contents(http://php.net/manual/en/function.file-put-contents.php)
|
389 |
+
}
|
390 |
$this->_prepareDownloadResponse(
|
391 |
+
'combined_label_' .date('Y-m-d_His'). '.pdf',
|
392 |
+
$pdf,
|
393 |
'application/pdf'
|
394 |
);
|
|
|
|
|
395 |
} else {
|
396 |
+
if(count($errorMessages)) {
|
397 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
398 |
+
implode('<br />',$errorMessages)
|
399 |
+
);
|
400 |
+
}
|
401 |
+
Mage::getSingleton('adminhtml/session')->addNotice(
|
402 |
+
Mage::helper('synergeticagency_gls')->__('No labels could be printed')
|
403 |
+
);
|
404 |
+
$this->_redirectReferer();
|
405 |
+
}
|
406 |
+
} else {
|
407 |
+
if(!$shipmentsCount) {
|
408 |
+
// delete the job again;
|
409 |
+
$job->delete();
|
410 |
+
Mage::getSingleton('adminhtml/session')->addNotice(
|
411 |
+
Mage::helper('synergeticagency_gls')->__('No labels could be printed')
|
412 |
);
|
|
|
413 |
$this->_redirectReferer();
|
414 |
+
} else {
|
415 |
+
Mage::getSingleton('adminhtml/session')->addNotice(
|
416 |
+
sprintf(Mage::helper('synergeticagency_gls')->__('Successfully created mass print job with %s items'),$shipmentsCount)
|
417 |
+
);
|
418 |
+
$job->setQtyItemsOpen($shipmentsCount);
|
419 |
+
$job->save();
|
420 |
+
$this->_redirect('adminhtml/gls_shipment_job/index/');
|
421 |
+
}
|
422 |
+
}
|
423 |
+
}
|
424 |
+
|
425 |
+
/**
|
426 |
+
* collect data for shipment and create shipment using GLS API Connector
|
427 |
+
*/
|
428 |
+
public function printAction() {
|
429 |
+
|
430 |
+
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "entered", Zend_Log::DEBUG );
|
431 |
+
|
432 |
+
$glsShipmentId = $this->getRequest()->getParam('id');
|
433 |
+
$glsShipment = Mage::getModel('synergeticagency_gls/shipment')->load($glsShipmentId);
|
434 |
+
$glsShipment->setSandbox( Mage::getStoreConfig('gls/general/sandbox',$glsShipment->getStore()) );
|
435 |
+
try {
|
436 |
+
$labels = $glsShipment->getLabels();
|
437 |
+
} catch(Exception $e) {
|
438 |
+
if(!$glsShipment->getErrorMessage()) {
|
439 |
+
$glsShipment->setErrorMessage($e->getMessage());
|
440 |
+
$glsShipment->setErrorCode(SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_UNDEFINED);
|
441 |
+
$glsShipment->save();
|
442 |
}
|
443 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
444 |
+
$this->_redirectReferer();
|
445 |
+
return null;
|
446 |
+
}
|
447 |
+
|
448 |
+
if(empty($labels)) {
|
449 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('synergeticagency_gls')->__('The label data with GLS-ConsignmentId %s obtained are not correct'),$glsShipment->getConsignementId() .
|
450 |
+
"<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_LABEL_INVALID));
|
451 |
+
$this->_redirectReferer();
|
452 |
+
}
|
453 |
|
454 |
+
// combine labels, if shipment response has more than one label
|
455 |
+
$labelHeaderData = false;
|
456 |
+
if( count($labels) > 1 ){
|
457 |
+
Mage::helper("synergeticagency_gls/log")->log( __METHOD__, __LINE__, count($labels) . " Labels in GLS response", Zend_Log::INFO );
|
458 |
+
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "combine " . count($labels) . " GLS Labels into one file", Zend_Log::INFO );
|
459 |
+
try {
|
460 |
+
$labelHeaderData = $glsShipment->getConnector()->combineLabels($labels);
|
461 |
+
} catch(Exception $e) {
|
462 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('synergeticagency_gls')->__('The label data with GLS-ConsignmentId %s obtained are not correct'),$glsShipment->getConsignementId() .
|
463 |
+
"<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_LABEL_INVALID));
|
464 |
+
$this->_redirectReferer();
|
465 |
}
|
466 |
+
} else {
|
467 |
+
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "One label in GLS response", Zend_Log::INFO );
|
468 |
+
$labelHeaderData = array_shift($labels);
|
469 |
+
}
|
470 |
+
|
471 |
+
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$labelHeaderData=" . substr ( $labelHeaderData, 0, 25 ), Zend_Log::DEBUG );
|
472 |
+
if( $labelHeaderData !== false ){
|
473 |
+
$this->_prepareDownloadResponse(
|
474 |
+
$glsShipment->getConsignmentId() . '.pdf',
|
475 |
+
$labelHeaderData,
|
476 |
+
'application/pdf'
|
477 |
+
);
|
478 |
+
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "Label" . $glsShipment->getConsignmentId() . ".pdf sent to header", Zend_Log::INFO );
|
479 |
+
|
480 |
+
} else {
|
481 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
482 |
+
sprintf(Mage::helper('synergeticagency_gls')->__('Creation of the label with the GLS-ConsignmentId %s failed'), $glsShipment->getConsignmentId()) .
|
483 |
+
"<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_LABEL_INVALID)
|
484 |
+
);
|
485 |
+
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, sprintf('Creation of the label with the GLS-ConsignmentId %s failed'), $glsShipment->getConsignmentId(), Zend_Log::ERR );
|
486 |
+
$this->_redirectReferer();
|
487 |
+
return null;
|
488 |
}
|
489 |
}
|
490 |
|
503 |
"<br />" . Mage::helper('synergeticagency_gls')->__('The shipment id is not set or found') .
|
504 |
"<br />" . Mage::helper('synergeticagency_gls')->__('or') .
|
505 |
"<br />" . Mage::helper('synergeticagency_gls')->__('The label has already been printed') .
|
506 |
+
"<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_SHIPMENT_EDIT_IMPOSSIBLE)
|
507 |
);
|
508 |
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "GLS Shipment can not be edited. " . get_class($glsShipment) . "::id is not set/found or the label has already been printed: " . get_class($glsShipment) . "::printed == 1" , Zend_Log::ERR );
|
509 |
$this->_redirectReferer();
|
534 |
Mage::getSingleton('adminhtml/session')->addError(
|
535 |
Mage::helper('synergeticagency_gls')->__('GLS Shipment can not be saved') .
|
536 |
"<br />" . Mage::helper('synergeticagency_gls')->__('The label has already been printed') .
|
537 |
+
"<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_LABEL_ALREADY_PRINTED)
|
538 |
);
|
539 |
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "GLS Shipment can not be saved. The label has already been printed: " . get_class($glsShipment) . "::printed == 1" , Zend_Log::ERR );
|
540 |
$this->_redirect('adminhtml/sales_shipment/view/',array('shipment_id' => $shimentId));
|
558 |
$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$data: " . var_export($data, 1), Zend_Log::INFO);
|
559 |
//$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$shipment: " . var_export($shipment, 1), Zend_Log::INFO);
|
560 |
//$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$glsShipment:" . var_export($glsShipment, 1), Zend_Log::INFO);
|
561 |
+
$this->getGlsHelperLog()->logException( $e, __METHOD__, __LINE__, Zend_Log::ERR, 'GLS Shipment could not be saved', SynergeticAgency_Gls_Exception::GLS_ERROR_CODE_SHIPMENT_NOT_SAVED );
|
562 |
$this->_redirectReferer();
|
563 |
return null;
|
564 |
}
|
602 |
$this->glsHelperData = $glsHelperData;
|
603 |
}
|
604 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
605 |
}
|
app/code/community/SynergeticAgency/Gls/data/synergeticagency_gls_setup/data-upgrade-1.0.0-1.1.0.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category SynergetigAgency
|
22 |
+
* @package SynergeticAgency\Gls\data\synergeticagency_gls_setup
|
23 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
28 |
+
$installer = $this;
|
29 |
+
/**
|
30 |
+
* Install order statuses from config
|
31 |
+
*/
|
32 |
+
$data = array();
|
33 |
+
$statuses = array(
|
34 |
+
SynergeticAgency_Gls_Model_Gls::GLS_STATUS_PENDING => array('label' => 'Pending GLS'),
|
35 |
+
SynergeticAgency_Gls_Model_Gls::GLS_STATUS_PENDING_ERROR => array('label' => 'Pending GLS Error'),
|
36 |
+
SynergeticAgency_Gls_Model_Gls::GLS_STATUS_PROCESSING => array('label' => 'Processing GLS'),
|
37 |
+
SynergeticAgency_Gls_Model_Gls::GLS_STATUS_PROCESSING_ERROR => array('label' => 'Processing GLS Error'),
|
38 |
+
SynergeticAgency_Gls_Model_Gls::GLS_STATUS_COMPLETE => array('label' => 'Complete GLS')
|
39 |
+
);
|
40 |
+
foreach ($statuses as $code => $info) {
|
41 |
+
$data[] = array(
|
42 |
+
'status' => $code,
|
43 |
+
'label' => $info['label']
|
44 |
+
);
|
45 |
+
}
|
46 |
+
$installer->getConnection()->insertArray(
|
47 |
+
$installer->getTable('sales/order_status'),
|
48 |
+
array('status', 'label'),
|
49 |
+
$data
|
50 |
+
);
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Install order states from config
|
54 |
+
*/
|
55 |
+
$data = array();
|
56 |
+
$states = array(
|
57 |
+
Mage_Sales_Model_Order::STATE_NEW => array(
|
58 |
+
'statuses' => array(
|
59 |
+
SynergeticAgency_Gls_Model_Gls::GLS_STATUS_PENDING => array(),
|
60 |
+
SynergeticAgency_Gls_Model_Gls::GLS_STATUS_PENDING_ERROR => array()
|
61 |
+
)
|
62 |
+
),
|
63 |
+
Mage_Sales_Model_Order::STATE_PROCESSING => array(
|
64 |
+
'statuses' => array(
|
65 |
+
SynergeticAgency_Gls_Model_Gls::GLS_STATUS_PROCESSING => array(),
|
66 |
+
SynergeticAgency_Gls_Model_Gls::GLS_STATUS_PROCESSING_ERROR => array()
|
67 |
+
)
|
68 |
+
),
|
69 |
+
Mage_Sales_Model_Order::STATE_COMPLETE => array(
|
70 |
+
'statuses' => array(
|
71 |
+
SynergeticAgency_Gls_Model_Gls::GLS_STATUS_COMPLETE => array()
|
72 |
+
)
|
73 |
+
)
|
74 |
+
);
|
75 |
+
|
76 |
+
foreach ($states as $code => $info) {
|
77 |
+
if (isset($info['statuses'])) {
|
78 |
+
foreach ($info['statuses'] as $status => $statusInfo) {
|
79 |
+
$data[] = array(
|
80 |
+
'status' => $status,
|
81 |
+
'state' => $code,
|
82 |
+
'is_default' => is_array($statusInfo) && isset($statusInfo['@']['default']) ? 1 : 0
|
83 |
+
);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
$installer->getConnection()->insertArray(
|
88 |
+
$installer->getTable('sales/order_status_state'),
|
89 |
+
array('status', 'state', 'is_default'),
|
90 |
+
$data
|
91 |
+
);
|
app/code/community/SynergeticAgency/Gls/etc/adminhtml.xml
CHANGED
@@ -7,6 +7,13 @@
|
|
7 |
<title>GLS Shipments</title>
|
8 |
<action>adminhtml/gls_shipment/</action>
|
9 |
<sort_order>35</sort_order>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
</gls_shipments>
|
11 |
</children>
|
12 |
</sales>
|
7 |
<title>GLS Shipments</title>
|
8 |
<action>adminhtml/gls_shipment/</action>
|
9 |
<sort_order>35</sort_order>
|
10 |
+
<children>
|
11 |
+
<gls_shipment_jobs translate="title" module="synergeticagency_gls">
|
12 |
+
<title>GLS Shipment mass jobs</title>
|
13 |
+
<action>adminhtml/gls_shipment_job/</action>
|
14 |
+
<sort_order>10</sort_order>
|
15 |
+
</gls_shipment_jobs>
|
16 |
+
</children>
|
17 |
</gls_shipments>
|
18 |
</children>
|
19 |
</sales>
|
app/code/community/SynergeticAgency/Gls/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<SynergeticAgency_Gls>
|
5 |
-
<version>1.
|
6 |
</SynergeticAgency_Gls>
|
7 |
</modules>
|
8 |
<global>
|
@@ -23,6 +23,9 @@
|
|
23 |
<shipment_address>
|
24 |
<table>synergeticagency_gls_shipment_address</table>
|
25 |
</shipment_address>
|
|
|
|
|
|
|
26 |
</entities>
|
27 |
</synergeticagency_gls_resource>
|
28 |
</models>
|
@@ -113,6 +116,10 @@
|
|
113 |
<schedule><cron_expr>*/10 * * * *</cron_expr></schedule>
|
114 |
<run><model>synergeticagency_gls/jsonimport::run</model></run>
|
115 |
</synergeticagency_gls_jsonconfig_import>
|
|
|
|
|
|
|
|
|
116 |
</jobs>
|
117 |
</crontab>
|
118 |
<adminhtml>
|
@@ -142,6 +149,14 @@
|
|
142 |
</save_gls_shipment_data>
|
143 |
</observers>
|
144 |
</controller_action_postdispatch_adminhtml_sales_order_shipment_save>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
<sales_order_shipment_save_before>
|
146 |
<observers>
|
147 |
<check_gls_shipment_data>
|
@@ -166,6 +181,14 @@
|
|
166 |
</synergeticagency_gls_ordergrid_adminhtml_block_html_before>
|
167 |
</observers>
|
168 |
</adminhtml_block_html_before>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
</events>
|
170 |
<layout>
|
171 |
<updates>
|
@@ -240,6 +263,9 @@
|
|
240 |
<weight>0</weight>
|
241 |
<return_label_enabled>0</return_label_enabled>
|
242 |
<labelsize>A6</labelsize>
|
|
|
|
|
|
|
243 |
</shipment>
|
244 |
<alternative_shipper>
|
245 |
<alternative_shipper_enabled>0</alternative_shipper_enabled>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<SynergeticAgency_Gls>
|
5 |
+
<version>1.1.3</version>
|
6 |
</SynergeticAgency_Gls>
|
7 |
</modules>
|
8 |
<global>
|
23 |
<shipment_address>
|
24 |
<table>synergeticagency_gls_shipment_address</table>
|
25 |
</shipment_address>
|
26 |
+
<shipment_job>
|
27 |
+
<table>synergeticagency_gls_shipment_job</table>
|
28 |
+
</shipment_job>
|
29 |
</entities>
|
30 |
</synergeticagency_gls_resource>
|
31 |
</models>
|
116 |
<schedule><cron_expr>*/10 * * * *</cron_expr></schedule>
|
117 |
<run><model>synergeticagency_gls/jsonimport::run</model></run>
|
118 |
</synergeticagency_gls_jsonconfig_import>
|
119 |
+
<synergeticagency_gls_job_massprint>
|
120 |
+
<schedule><cron_expr>* * * * *</cron_expr></schedule>
|
121 |
+
<run><model>synergeticagency_gls/massprint::run</model></run>
|
122 |
+
</synergeticagency_gls_job_massprint>
|
123 |
</jobs>
|
124 |
</crontab>
|
125 |
<adminhtml>
|
149 |
</save_gls_shipment_data>
|
150 |
</observers>
|
151 |
</controller_action_postdispatch_adminhtml_sales_order_shipment_save>
|
152 |
+
<controller_action_postdispatch_adminhtml_sales_order_invoice_save>
|
153 |
+
<observers>
|
154 |
+
<save_gls_order_status>
|
155 |
+
<class>synergeticagency_gls/observer</class>
|
156 |
+
<method>saveGlsOrderStatus</method>
|
157 |
+
</save_gls_order_status>
|
158 |
+
</observers>
|
159 |
+
</controller_action_postdispatch_adminhtml_sales_order_invoice_save>
|
160 |
<sales_order_shipment_save_before>
|
161 |
<observers>
|
162 |
<check_gls_shipment_data>
|
181 |
</synergeticagency_gls_ordergrid_adminhtml_block_html_before>
|
182 |
</observers>
|
183 |
</adminhtml_block_html_before>
|
184 |
+
<core_block_abstract_prepare_layout_before>
|
185 |
+
<observers>
|
186 |
+
<synergeticagency_gls_core_block_abstract_prepare_layout_before>
|
187 |
+
<class>synergeticagency_gls/observer</class>
|
188 |
+
<method>addMassActionToOrderGrid</method>
|
189 |
+
</synergeticagency_gls_core_block_abstract_prepare_layout_before>
|
190 |
+
</observers>
|
191 |
+
</core_block_abstract_prepare_layout_before>
|
192 |
</events>
|
193 |
<layout>
|
194 |
<updates>
|
263 |
<weight>0</weight>
|
264 |
<return_label_enabled>0</return_label_enabled>
|
265 |
<labelsize>A6</labelsize>
|
266 |
+
<weight_unit>kg</weight_unit>
|
267 |
+
<max_batch_amount>100</max_batch_amount>
|
268 |
+
<notify_customer_shipment>0</notify_customer_shipment>
|
269 |
</shipment>
|
270 |
<alternative_shipper>
|
271 |
<alternative_shipper_enabled>0</alternative_shipper_enabled>
|
app/code/community/SynergeticAgency/Gls/etc/system.xml
CHANGED
@@ -212,6 +212,36 @@
|
|
212 |
<show_in_website>0</show_in_website>
|
213 |
<show_in_store>0</show_in_store>
|
214 |
</labelsize>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
</fields>
|
216 |
</shipment>
|
217 |
<alternative_shipper translate="label comment" module="synergeticagency_gls">
|
212 |
<show_in_website>0</show_in_website>
|
213 |
<show_in_store>0</show_in_store>
|
214 |
</labelsize>
|
215 |
+
<weight_unit translate="label comment">
|
216 |
+
<label>Weight unit</label>
|
217 |
+
<frontend_type>select</frontend_type>
|
218 |
+
<comment><![CDATA[Set the weight unit according to the unit chosen in your products]]></comment>
|
219 |
+
<source_model>synergeticagency_gls/system_config_source_weightunit</source_model>
|
220 |
+
<sort_order>150</sort_order>
|
221 |
+
<show_in_default>1</show_in_default>
|
222 |
+
<show_in_website>0</show_in_website>
|
223 |
+
<show_in_store>0</show_in_store>
|
224 |
+
</weight_unit>
|
225 |
+
<max_batch_amount translate="label comment">
|
226 |
+
<label>Maximum batch processing amount</label>
|
227 |
+
<frontend_type>text</frontend_type>
|
228 |
+
<validate>validate-number</validate>
|
229 |
+
<sort_order>160</sort_order>
|
230 |
+
<show_in_default>1</show_in_default>
|
231 |
+
<show_in_website>0</show_in_website>
|
232 |
+
<show_in_store>0</show_in_store>
|
233 |
+
<comment>Per 100 labels the memory consumption is ca. 500MB (PHP memory_limit). Please select a value that fits your environment.</comment>
|
234 |
+
</max_batch_amount>
|
235 |
+
<notify_customer_shipment>
|
236 |
+
<label>Notify customer on shipment creation</label>
|
237 |
+
<frontend_type>select</frontend_type>
|
238 |
+
<comment><![CDATA[Select if customer should be notified by mail, if shipment is created through batch processing.]]></comment>
|
239 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
240 |
+
<sort_order>170</sort_order>
|
241 |
+
<show_in_default>1</show_in_default>
|
242 |
+
<show_in_website>1</show_in_website>
|
243 |
+
<show_in_store>1</show_in_store>
|
244 |
+
</notify_customer_shipment>
|
245 |
</fields>
|
246 |
</shipment>
|
247 |
<alternative_shipper translate="label comment" module="synergeticagency_gls">
|
app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.1-0.1.2.php
CHANGED
@@ -72,15 +72,6 @@ Mage::getSingleton('eav/config')
|
|
72 |
->setData('used_in_forms', array('customer_address_edit','adminhtml_customer_address','customer_register_address'))
|
73 |
->save();
|
74 |
|
75 |
-
// todo remove later just for fixing
|
76 |
-
$installer->getConnection()->dropColumn($installer->getTable('sales/quote_address'), 'parcelshop_id');
|
77 |
-
$installer->getConnection()->dropColumn($installer->getTable('sales/order_address'), 'parcelshop_id');
|
78 |
-
$installer->getConnection()->dropColumn($installer->getTable('sales/quote_address'), 'parcelshop_name');
|
79 |
-
$installer->getConnection()->dropColumn($installer->getTable('sales/order_address'), 'parcelshop_name');
|
80 |
-
$installer->getConnection()->dropColumn($installer->getTable('sales/quote_address'), 'to_parcelshop');
|
81 |
-
$installer->getConnection()->dropColumn($installer->getTable('sales/order_address'), 'to_parcelshop');
|
82 |
-
|
83 |
-
|
84 |
/**
|
85 |
* add attribute parcelshop_id to quote_address table
|
86 |
*/
|
72 |
->setData('used_in_forms', array('customer_address_edit','adminhtml_customer_address','customer_register_address'))
|
73 |
->save();
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
/**
|
76 |
* add attribute parcelshop_id to quote_address table
|
77 |
*/
|
app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-1.1.0-1.1.1.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category SynergetigAgency
|
22 |
+
* @package SynergeticAgency\Gls\sql\synergeticagency_gls_setup
|
23 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
28 |
+
$installer = $this;
|
29 |
+
$installer->startSetup();
|
30 |
+
|
31 |
+
|
32 |
+
$table = $installer->getConnection()
|
33 |
+
->newTable($installer->getTable('synergeticagency_gls/shipment_job'))
|
34 |
+
->addColumn('gls_shipment_job_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
35 |
+
'identity' => true,
|
36 |
+
'unsigned' => true,
|
37 |
+
'nullable' => false,
|
38 |
+
'primary' => true,
|
39 |
+
), 'GLS Shipment Job ID')
|
40 |
+
->addColumn('completed', Varien_Db_Ddl_Table::TYPE_INTEGER, 1, array(
|
41 |
+
'unsigned' => true,
|
42 |
+
'nullable' => false,
|
43 |
+
'default' => 0,
|
44 |
+
), 'Completed')
|
45 |
+
->addColumn('in_process', Varien_Db_Ddl_Table::TYPE_INTEGER, 1, array(
|
46 |
+
'unsigned' => true,
|
47 |
+
'nullable' => false,
|
48 |
+
'default' => 0,
|
49 |
+
), 'Job currently in process')
|
50 |
+
->addColumn('printed', Varien_Db_Ddl_Table::TYPE_INTEGER, 1, array(
|
51 |
+
'unsigned' => true,
|
52 |
+
'nullable' => false,
|
53 |
+
'default' => 0,
|
54 |
+
), 'Job Printed')
|
55 |
+
->addColumn('qty_items_open', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
56 |
+
'unsigned' => true,
|
57 |
+
'nullable' => false,
|
58 |
+
'default' => 0,
|
59 |
+
), 'Qty open items to process')
|
60 |
+
->addColumn('qty_items_successful', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
61 |
+
'unsigned' => true,
|
62 |
+
'nullable' => false,
|
63 |
+
'default' => 0,
|
64 |
+
), 'Qty successful items')
|
65 |
+
->addColumn('qty_items_error', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
66 |
+
'unsigned' => true,
|
67 |
+
'nullable' => false,
|
68 |
+
'default' => 0,
|
69 |
+
), 'Qty failed items')
|
70 |
+
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
71 |
+
'nullable' => false,
|
72 |
+
), 'Job creation date')
|
73 |
+
->addColumn('error_messages', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
74 |
+
'nullable' => true,
|
75 |
+
), 'Error Messages')
|
76 |
+
->addColumn('pdf_file', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
77 |
+
'nullable' => true,
|
78 |
+
'default' => null,
|
79 |
+
), 'PDF File')
|
80 |
+
->setComment('GLS Massprint Shipment Job Table');
|
81 |
+
$installer->getConnection()->createTable($table);
|
82 |
+
|
83 |
+
$installer->getConnection()->addColumn($installer->getTable('synergeticagency_gls/shipment'),'job_id',array(
|
84 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
85 |
+
'unsigned' => true,
|
86 |
+
'nullable' => true,
|
87 |
+
'default' => null,
|
88 |
+
'comment' => 'Mass Print JobID'
|
89 |
+
));
|
90 |
+
|
91 |
+
$installer->getConnection()->addColumn($installer->getTable('synergeticagency_gls/shipment'),'pdf_file',array(
|
92 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
93 |
+
'nullable' => true,
|
94 |
+
'length' => 255,
|
95 |
+
'default' => null,
|
96 |
+
'comment' => 'PDF File Path'
|
97 |
+
));
|
98 |
+
|
99 |
+
$installer->getConnection()->addColumn($installer->getTable('synergeticagency_gls/shipment'),'error_code',array(
|
100 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
101 |
+
'nullable' => true,
|
102 |
+
'length' => 255,
|
103 |
+
'default' => null,
|
104 |
+
'comment' => 'GLS Error Code'
|
105 |
+
));
|
106 |
+
|
107 |
+
$installer->getConnection()->addColumn($installer->getTable('synergeticagency_gls/shipment'),'error_message',array(
|
108 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
109 |
+
'nullable' => true,
|
110 |
+
'default' => null,
|
111 |
+
'comment' => 'GLS Error Message'
|
112 |
+
));
|
113 |
+
|
114 |
+
$installer->endSetup();
|
app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-1.1.1-1.1.2.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SynergeticAgency_Gls
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category SynergetigAgency
|
22 |
+
* @package SynergeticAgency\Gls\sql\synergeticagency_gls_setup
|
23 |
+
* @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
28 |
+
$installer = $this;
|
29 |
+
$installer->startSetup();
|
30 |
+
|
31 |
+
$installer->getConnection()->addColumn($installer->getTable('synergeticagency_gls/shipment_job'),'error_items',array(
|
32 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
33 |
+
'nullable' => true,
|
34 |
+
'default' => null,
|
35 |
+
'comment' => 'Error Items Order Increment ID'
|
36 |
+
));
|
37 |
+
|
38 |
+
$installer->endSetup();
|
app/design/adminhtml/base/default/layout/synergeticagency/gls.xml
CHANGED
@@ -13,10 +13,23 @@
|
|
13 |
</reference>
|
14 |
<reference name="content">
|
15 |
<block type="synergeticagency_gls/adminhtml_sales_gls_shipment_edit" name="gls_shipment_edit">
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
</block>
|
20 |
</reference>
|
21 |
</adminhtml_gls_shipment_edit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
</layout>
|
13 |
</reference>
|
14 |
<reference name="content">
|
15 |
<block type="synergeticagency_gls/adminhtml_sales_gls_shipment_edit" name="gls_shipment_edit">
|
16 |
+
<block type="synergeticagency_gls/adminhtml_sales_gls_shipment_edit_form" name="gls_shipment_edit_form">
|
17 |
+
<block type="synergeticagency_gls/adminhtml_sales_gls_shipment_edit_form_packages" name="packages" />
|
18 |
+
</block>
|
19 |
</block>
|
20 |
</reference>
|
21 |
</adminhtml_gls_shipment_edit>
|
22 |
+
<adminhtml_gls_shipment_job_index>
|
23 |
+
<reference name="js">
|
24 |
+
<block type="synergeticagency_gls/adminhtml_sales_gls_shipment_job_grid_js" name="gls_job_grid_js" />
|
25 |
+
</reference>
|
26 |
+
</adminhtml_gls_shipment_job_index>
|
27 |
+
<adminhtml_gls_shipment_index>
|
28 |
+
<reference name="head">
|
29 |
+
<action method="addJs"><script>gls/admin.js</script></action>
|
30 |
+
</reference>
|
31 |
+
<reference name="js">
|
32 |
+
<block type="synergeticagency_gls/adminhtml_sales_gls_shipment_grid_js" name="gls_shipment_grid_js" />
|
33 |
+
</reference>
|
34 |
+
</adminhtml_gls_shipment_index>
|
35 |
</layout>
|
app/design/adminhtml/base/default/template/gls/sales/order/shipment/create/gls/packages.phtml
CHANGED
@@ -26,7 +26,7 @@
|
|
26 |
<tr class="option-row">
|
27 |
<td><input class="input-text shipping-weight" type="text" name="shipment[packages][package_<?php echo $i;?>][weight]" value="<?php echo $parcel->getWeight() ?>" /></td>
|
28 |
<td>
|
29 |
-
<input class="input-text cash-service <? echo ($this->isCashService() == true) ? '' : 'disabled'; ?>" <? echo ($this->isCashService() == true) ? '' : 'disabled'; ?> style=" <? echo ($this->isCashService() == true) ? '' : 'display:none'; ?>" type="text" name="shipment[packages][package_<?php echo $i;?>][cashservice]" value="<?php echo $this->getStore()->roundPrice($parcel->getCashservice()) ?>" />
|
30 |
</td>
|
31 |
<td class="gls-controls"><a class="addParcel" href=""><img src="<?php echo $this->getSkinUrl('images/icon_btn_add.gif');?>" /></a></td>
|
32 |
</tr>
|
@@ -36,7 +36,7 @@
|
|
36 |
<tr class="option-row">
|
37 |
<td><input class="input-text shipping-weight" type="text" name="shipment[packages][package_0][weight]" value="<?php echo $this->getWeight() ?>" /></td>
|
38 |
<td>
|
39 |
-
<input class="input-text cash-service <? echo ($this->isCashService() == true) ? '' : 'disabled'; ?>" <? echo ($this->isCashService() == true) ? '' : 'disabled'; ?> style=" <? echo ($this->isCashService() == true) ? '' : 'display:none'; ?>" type="text" name="shipment[packages][package_0][cashservice]" value="<?php echo $this->getCashAmount() ?>" />
|
40 |
</td>
|
41 |
<td class="gls-controls"><a class="addParcel" href=""><img src="<?php echo $this->getSkinUrl('images/icon_btn_add.gif');?>" /></a></td>
|
42 |
</tr>
|
26 |
<tr class="option-row">
|
27 |
<td><input class="input-text shipping-weight" type="text" name="shipment[packages][package_<?php echo $i;?>][weight]" value="<?php echo $parcel->getWeight() ?>" /></td>
|
28 |
<td>
|
29 |
+
<input class="input-text cash-service <?php echo ($this->isCashService() == true) ? '' : 'disabled'; ?>" <?php echo ($this->isCashService() == true) ? '' : 'disabled'; ?> style=" <?php echo ($this->isCashService() == true) ? '' : 'display:none'; ?>" type="text" name="shipment[packages][package_<?php echo $i;?>][cashservice]" value="<?php echo $this->getStore()->roundPrice($parcel->getCashservice()) ?>" />
|
30 |
</td>
|
31 |
<td class="gls-controls"><a class="addParcel" href=""><img src="<?php echo $this->getSkinUrl('images/icon_btn_add.gif');?>" /></a></td>
|
32 |
</tr>
|
36 |
<tr class="option-row">
|
37 |
<td><input class="input-text shipping-weight" type="text" name="shipment[packages][package_0][weight]" value="<?php echo $this->getWeight() ?>" /></td>
|
38 |
<td>
|
39 |
+
<input class="input-text cash-service <?php echo ($this->isCashService() == true) ? '' : 'disabled'; ?>" <?php echo ($this->isCashService() == true) ? '' : 'disabled'; ?> style=" <?php echo ($this->isCashService() == true) ? '' : 'display:none'; ?>" type="text" name="shipment[packages][package_0][cashservice]" value="<?php echo $this->getCashAmount() ?>" />
|
40 |
</td>
|
41 |
<td class="gls-controls"><a class="addParcel" href=""><img src="<?php echo $this->getSkinUrl('images/icon_btn_add.gif');?>" /></a></td>
|
42 |
</tr>
|
app/design/adminhtml/base/default/template/gls/sales/order/shipment/view/gls.phtml
CHANGED
@@ -28,7 +28,7 @@ if ($_glsShipment && $_glsShipment->getId()):
|
|
28 |
</td>
|
29 |
</tr>
|
30 |
<tr class="even">
|
31 |
-
<td><?php print $this->__('Shipping
|
32 |
<td>
|
33 |
<?php $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
34 |
echo Mage::app()->getLocale()->date(strtotime($_glsShipment->getShippingDate()))->toString($format); ?>
|
@@ -50,6 +50,17 @@ if ($_glsShipment && $_glsShipment->getId()):
|
|
50 |
<td><strong><?php echo $this->__('Status')?></strong></td>
|
51 |
<td><strong><?php echo $_glsShipment->getPrinted() == '1' ? $this->__('Printed') : $this->__('Not printed') ?></strong></td>
|
52 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
<tr class="odd">
|
54 |
<td colspan="2">
|
55 |
<?php echo $this->__('Packages') ?>
|
@@ -58,8 +69,8 @@ if ($_glsShipment && $_glsShipment->getId()):
|
|
58 |
<tr>
|
59 |
<th><?php echo $this->__('Parcel #');?></th>
|
60 |
<th><?php echo $this->__('Weight (in kg)');?></th>
|
61 |
-
<th><?php echo sprintf($this->__('Cash
|
62 |
-
<th><?php echo $this->__('Parcel
|
63 |
</tr>
|
64 |
<?php foreach ($_glsShipment->getShipmentParcels() as $parcel) : ?>
|
65 |
<tr>
|
@@ -77,7 +88,7 @@ if ($_glsShipment && $_glsShipment->getId()):
|
|
77 |
</table>
|
78 |
</div>
|
79 |
<p class="form-buttons">
|
80 |
-
<?php if($_glsShipment->getPrinted() != '1') : ?>
|
81 |
<button id="pdf" type="button" class="scalable save" onclick="setLocation('<?php echo $this->getUrl('adminhtml/gls_shipment/print', array('id' => $_glsShipment->getId())); ?>');this.disabled=true;this.className += ' disabled';document.getElementById('edit_gls_shipment').disabled=true;document.getElementById('edit_gls_shipment').className += ' disabled';" style="">
|
82 |
<span><?php echo $this->__("PDF") ?></span>
|
83 |
</button>
|
@@ -85,5 +96,10 @@ if ($_glsShipment && $_glsShipment->getId()):
|
|
85 |
<span><?php echo $this->helper('sales')->__('Edit') ?></span>
|
86 |
</button>
|
87 |
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
88 |
</p>
|
89 |
<?php endif; ?>
|
28 |
</td>
|
29 |
</tr>
|
30 |
<tr class="even">
|
31 |
+
<td><?php print $this->__('Shipping date') ?></td>
|
32 |
<td>
|
33 |
<?php $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
34 |
echo Mage::app()->getLocale()->date(strtotime($_glsShipment->getShippingDate()))->toString($format); ?>
|
50 |
<td><strong><?php echo $this->__('Status')?></strong></td>
|
51 |
<td><strong><?php echo $_glsShipment->getPrinted() == '1' ? $this->__('Printed') : $this->__('Not printed') ?></strong></td>
|
52 |
</tr>
|
53 |
+
<?php $errorMessage = trim($_glsShipment->getErrorMessage()); ?>
|
54 |
+
<?php if(!empty($errorMessage)) : ?>
|
55 |
+
<tr class="odd">
|
56 |
+
<td id="gls-error"> <br /> </td>
|
57 |
+
<td> </td>
|
58 |
+
</tr>
|
59 |
+
<tr class="even">
|
60 |
+
<td><strong style="color: red;"><?php echo $this->__('Error')?></strong></td>
|
61 |
+
<td><strong style="color: red;"><?php echo $this->__('Error-Code')?>:</strong> <?php echo $_glsShipment->getErrorCode();?><br /><strong style="color: red;"><?php echo $this->__('Error-Message')?>:</strong> <?php echo $_glsShipment->getErrorMessage();?></td>
|
62 |
+
</tr>
|
63 |
+
<?php endif;?>
|
64 |
<tr class="odd">
|
65 |
<td colspan="2">
|
66 |
<?php echo $this->__('Packages') ?>
|
69 |
<tr>
|
70 |
<th><?php echo $this->__('Parcel #');?></th>
|
71 |
<th><?php echo $this->__('Weight (in kg)');?></th>
|
72 |
+
<th><?php echo sprintf($this->__('Cash amount (in %s)'),$this->getCurrency()) ?></th>
|
73 |
+
<th><?php echo $this->__('Parcel number');?></th>
|
74 |
</tr>
|
75 |
<?php foreach ($_glsShipment->getShipmentParcels() as $parcel) : ?>
|
76 |
<tr>
|
88 |
</table>
|
89 |
</div>
|
90 |
<p class="form-buttons">
|
91 |
+
<?php if($_glsShipment->getPrinted() != '1' && !$_glsShipment->getJobId()) : ?>
|
92 |
<button id="pdf" type="button" class="scalable save" onclick="setLocation('<?php echo $this->getUrl('adminhtml/gls_shipment/print', array('id' => $_glsShipment->getId())); ?>');this.disabled=true;this.className += ' disabled';document.getElementById('edit_gls_shipment').disabled=true;document.getElementById('edit_gls_shipment').className += ' disabled';" style="">
|
93 |
<span><?php echo $this->__("PDF") ?></span>
|
94 |
</button>
|
96 |
<span><?php echo $this->helper('sales')->__('Edit') ?></span>
|
97 |
</button>
|
98 |
<?php endif; ?>
|
99 |
+
<?php if($_glsShipment->getJobId()) : ?>
|
100 |
+
<button id="pdf" type="button" class="scalable save disabled" disabled>
|
101 |
+
<span><?php echo $this->__("In mass action") ?></span>
|
102 |
+
</button>
|
103 |
+
<?php endif; ?>
|
104 |
</p>
|
105 |
<?php endif; ?>
|
app/design/adminhtml/base/default/template/gls/shipment/grid/js.phtml
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript">
|
2 |
+
var minParcels = <?php echo SynergeticAgency_Gls_Model_Shipment::GLS_SHIPMENT_MIN_PARCELS;?>;
|
3 |
+
var maxParcels = <?php echo SynergeticAgency_Gls_Model_Shipment::GLS_SHIPMENT_MAX_PARCELS;?>;
|
4 |
+
$$('.qty-parcels-change').each(function(elm){
|
5 |
+
elm.observe('click',function(event){
|
6 |
+
var dir = this.data('dir');
|
7 |
+
var qtyItem = this.up().select('.qty-parcels-qty').first();
|
8 |
+
var val = qtyItem.value;
|
9 |
+
|
10 |
+
if(!checkNumber(val)) {
|
11 |
+
alert('<?php echo sprintf(Mage::helper('synergeticagency_gls')->__('No valid number. Please enter numbers between %s and %s.'),SynergeticAgency_Gls_Model_Shipment::GLS_SHIPMENT_MIN_PARCELS, SynergeticAgency_Gls_Model_Shipment::GLS_SHIPMENT_MAX_PARCELS);?>');
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
val = parseInt(val);
|
15 |
+
|
16 |
+
if((dir == '-' && val <= (minParcels+1)) || (dir == '+' && val < minParcels)) {
|
17 |
+
this.up().select('.qty-parcels-decrease').first().addClassName('disabled');
|
18 |
+
} else {
|
19 |
+
this.up().select('.qty-parcels-decrease').first().removeClassName('disabled');
|
20 |
+
}
|
21 |
+
if((dir == '+' && val >= (maxParcels-1)) || (dir == '-' && val > maxParcels)) {
|
22 |
+
this.up().select('.qty-parcels-increase').first().addClassName('disabled');
|
23 |
+
} else {
|
24 |
+
this.up().select('.qty-parcels-increase').first().removeClassName('disabled');
|
25 |
+
}
|
26 |
+
if(dir == '+') {
|
27 |
+
if(val < maxParcels) {
|
28 |
+
qtyItem.value = val+1;
|
29 |
+
}
|
30 |
+
} else {
|
31 |
+
if(val > minParcels) {
|
32 |
+
qtyItem.value = val-1;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
});
|
36 |
+
});
|
37 |
+
|
38 |
+
$$('.qty-parcels-qty').each(function(elm){
|
39 |
+
elm.observe('keyup',function(event){
|
40 |
+
var val = this.value;
|
41 |
+
if(checkNumber(val)) {
|
42 |
+
if(val <= minParcels) {
|
43 |
+
this.up().select('.qty-parcels-decrease').first().addClassName('disabled');
|
44 |
+
} else {
|
45 |
+
this.up().select('.qty-parcels-decrease').first().removeClassName('disabled');
|
46 |
+
}
|
47 |
+
if(val >= maxParcels) {
|
48 |
+
this.up().select('.qty-parcels-increase').first().addClassName('disabled');
|
49 |
+
} else {
|
50 |
+
this.up().select('.qty-parcels-increase').first().removeClassName('disabled');
|
51 |
+
}
|
52 |
+
}
|
53 |
+
});
|
54 |
+
});
|
55 |
+
|
56 |
+
$$('.gls-print-button').each(function(elm){
|
57 |
+
elm.observe('click',function(event){
|
58 |
+
var id = this.data('id');
|
59 |
+
$('qty-parcels-wrap-'+id).hide();
|
60 |
+
$('qty-parcels-printed-'+id).show();
|
61 |
+
});
|
62 |
+
});
|
63 |
+
|
64 |
+
$$('.qty-parcels-submit').each(function(elm){
|
65 |
+
elm.observe('click',updateQtyRequest);
|
66 |
+
});
|
67 |
+
|
68 |
+
function updateQtyRequest() {
|
69 |
+
this.url = '<?php echo Mage::helper('adminhtml')->getUrl('*/*/updateqty') ?>';
|
70 |
+
this.updateQty = function () {
|
71 |
+
var self = this;
|
72 |
+
var qtyItem = self.up().select('.qty-parcels-qty').first();
|
73 |
+
var id = self.data('id');
|
74 |
+
var origQty = self.data('qty');
|
75 |
+
var qty = qtyItem.value;
|
76 |
+
if(!checkNumber(qty) || qty < minParcels || qty > maxParcels) {
|
77 |
+
alert('<?php echo sprintf(Mage::helper('synergeticagency_gls')->__('No valid number. Please enter numbers between %s and %s.'),SynergeticAgency_Gls_Model_Shipment::GLS_SHIPMENT_MIN_PARCELS, SynergeticAgency_Gls_Model_Shipment::GLS_SHIPMENT_MAX_PARCELS);?>');
|
78 |
+
return;
|
79 |
+
}
|
80 |
+
if(parseInt(qty) === parseInt(origQty)) {
|
81 |
+
alert('<?php echo Mage::helper('synergeticagency_gls')->__('Quantity is not changed');?>');
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
qty = parseInt(qty);
|
85 |
+
new Ajax.Request(self.url, {
|
86 |
+
parameters: {'qty':qty,'id':id},
|
87 |
+
onSuccess : function(transport) {
|
88 |
+
var response = transport.responseJSON || transport.responseText.evalJSON(true) || {};
|
89 |
+
if(typeof(response.error) !== 'undefined') {
|
90 |
+
alert(response.error);
|
91 |
+
return;
|
92 |
+
}
|
93 |
+
$('qty-parcels-'+id).update(qty);
|
94 |
+
self.data('qty',qty);
|
95 |
+
}
|
96 |
+
});
|
97 |
+
};
|
98 |
+
this.updateQty();
|
99 |
+
}
|
100 |
+
|
101 |
+
function checkNumber(n) {
|
102 |
+
return !isNaN(parseFloat(n)) && isFinite(n);
|
103 |
+
}
|
104 |
+
</script>
|
app/design/adminhtml/base/default/template/gls/shipment/job/grid/js.phtml
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript">
|
2 |
+
function JobRequest() {
|
3 |
+
|
4 |
+
this.poll = false;
|
5 |
+
|
6 |
+
this.url = '<?php echo Mage::helper('adminhtml')->getUrl('*/*/ajax') ?>';
|
7 |
+
|
8 |
+
this.activatePoll = function () {
|
9 |
+
this.poll = true;
|
10 |
+
this.runPoll();
|
11 |
+
};
|
12 |
+
|
13 |
+
this.disablePoll = function () {
|
14 |
+
clearTimeout(this.poll);
|
15 |
+
this.poll = false;
|
16 |
+
};
|
17 |
+
|
18 |
+
this.runPoll = function () {
|
19 |
+
var self = this;
|
20 |
+
var poll = setTimeout(function () {
|
21 |
+
var jobIds = [];
|
22 |
+
$$('.job-status-column').each(function(elem){
|
23 |
+
jobIds.push(elem.identify().replace('job-',''));
|
24 |
+
});
|
25 |
+
new Ajax.Request(self.url, {
|
26 |
+
parameters: {'jobIds[]':jobIds},
|
27 |
+
onSuccess : function(transport) {
|
28 |
+
var response = transport.responseJSON || transport.responseText.evalJSON(true) || {};
|
29 |
+
//console.log(response);
|
30 |
+
var noUpdates = 1;
|
31 |
+
if(response.length) {
|
32 |
+
response.each(function (item) {
|
33 |
+
/*if(!$('job-' + item.id)) {
|
34 |
+
window.location.reload();
|
35 |
+
}*/
|
36 |
+
if(!item.no_updates) {
|
37 |
+
noUpdates = 0;
|
38 |
+
}
|
39 |
+
$('job-' + item.id).update(item.status);
|
40 |
+
$('job-' + item.id).up().up().select('.job_completed').each(function (item2) {
|
41 |
+
item2.update(item.completed);
|
42 |
+
});
|
43 |
+
$('job-' + item.id).up().up().select('.job_printed').each(function (item2) {
|
44 |
+
item2.update(item.printed);
|
45 |
+
});
|
46 |
+
$('job-' + item.id).up().up().select('.job_error_messages').each(function (item2) {
|
47 |
+
item2.update(item.error_messages);
|
48 |
+
});
|
49 |
+
$('job-' + item.id).up().up().select('.job_action').each(function (item2) {
|
50 |
+
item2.update(item.action);
|
51 |
+
});
|
52 |
+
$('job-' + item.id).up().up().select('.job_error_items').each(function (item2) {
|
53 |
+
item2.update(item.error_items);
|
54 |
+
});
|
55 |
+
});
|
56 |
+
}
|
57 |
+
if(noUpdates) {
|
58 |
+
self.disablePoll();
|
59 |
+
} else {
|
60 |
+
self.runPoll();
|
61 |
+
}
|
62 |
+
}
|
63 |
+
});
|
64 |
+
}, 10000);
|
65 |
+
};
|
66 |
+
}
|
67 |
+
var jobRequest = new JobRequest();
|
68 |
+
jobRequest.activatePoll();
|
69 |
+
</script>
|
app/locale/de_DE/SynergeticAgency_Gls.csv
CHANGED
@@ -82,6 +82,7 @@
|
|
82 |
"Find ParcelShop, "PaketShop auswählen"
|
83 |
"Please select a ParcelShop, "Bitte wählen Sie einen PaketShop aus und teilen Sie uns mit, wen wir nach Eingang des Pakets per SMS und E-Mail benachrichtigen dürfen."
|
84 |
"Ship to ParcelShop, "An PaketShop liefern"
|
|
|
85 |
"ParcelShop name, "PaketShop-Name"
|
86 |
"GLS shipment list","Liste der GLS-Sendungen"
|
87 |
"GLS shipment ID","GLS-Sendungs-ID"
|
@@ -98,7 +99,7 @@
|
|
98 |
"Parcel number","Paketnummer"
|
99 |
"GLS shipment","GLS-Lieferung"
|
100 |
"Services","Services"
|
101 |
-
"Shipping
|
102 |
"Status","Status"
|
103 |
"Printed","Gedruckt"
|
104 |
"Not printed","Nicht gedruckt"
|
@@ -135,6 +136,32 @@
|
|
135 |
"Version","Version"
|
136 |
"Return address data","Rücksendeadresse"
|
137 |
"This address is mandatory for return labels","Diese Adresse muss für Retourenlabels gesetzt sein."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
"Available for specific countries only","Nur für ausgewählte Länder verfügbar"
|
139 |
"Support","Support"
|
140 |
"If you need assistance setting up the GLS credentials and GLS services","Wenn Sie Hilfe bei der Einrichtung der GLS-Zugangsdaten und GLS-Servicedienstleistungen benötigen"
|
@@ -180,4 +207,51 @@
|
|
180 |
"GLS - Cash on delivery","GLS - Nachnahme"
|
181 |
"Title","Titel"
|
182 |
"New Order Status","Neuer Bestellstatus"
|
183 |
-
"Instructions","Anleitung"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
"Find ParcelShop, "PaketShop auswählen"
|
83 |
"Please select a ParcelShop, "Bitte wählen Sie einen PaketShop aus und teilen Sie uns mit, wen wir nach Eingang des Pakets per SMS und E-Mail benachrichtigen dürfen."
|
84 |
"Ship to ParcelShop, "An PaketShop liefern"
|
85 |
+
"Ship to Parcelshop, "An PaketShop liefern"
|
86 |
"ParcelShop name, "PaketShop-Name"
|
87 |
"GLS shipment list","Liste der GLS-Sendungen"
|
88 |
"GLS shipment ID","GLS-Sendungs-ID"
|
99 |
"Parcel number","Paketnummer"
|
100 |
"GLS shipment","GLS-Lieferung"
|
101 |
"Services","Services"
|
102 |
+
"Shipping Date","Versanddatum"
|
103 |
"Status","Status"
|
104 |
"Printed","Gedruckt"
|
105 |
"Not printed","Nicht gedruckt"
|
136 |
"Version","Version"
|
137 |
"Return address data","Rücksendeadresse"
|
138 |
"This address is mandatory for return labels","Diese Adresse muss für Retourenlabels gesetzt sein."
|
139 |
+
"Create GLS shipments","GLS-Lieferungen erstellen"
|
140 |
+
"Print GLS labels","GLS-Labels drucken"
|
141 |
+
"Available for specific countries only","Nur für ausgewählte Länder verfügbar"
|
142 |
+
"Please select orders to process","Bitte wählen Sie Bestellungen für die Verarbeitung aus"
|
143 |
+
"Weight unit","Gewichtseinheit"
|
144 |
+
"Set the weight unit according to the unit chosen in your products","Bitte geben Sie an in welcher Gewichtseinheit Ihre Produkte gepflegt sind"
|
145 |
+
"g","Gramm"
|
146 |
+
"kg","Kilogramm"
|
147 |
+
"Per 100 labels the memory consumption is ca. 500MB (PHP memory_limit). Please select a value that fits your environment.","Pro 100 Lieferungen werden ca. 500MB Arbeitsspeicher benötigt (PHP memory_limit). Bitte wählen Sie den Wert entsprechend Ihrer Infrastruktur."
|
148 |
+
"Maximum batch processing amount","Maximale Anzahl Lieferungen für Stapelverarbeitung"
|
149 |
+
"Notify customer on shipment creation","Liefer-E-Mail an Kunde senden"
|
150 |
+
"Select if customer should be notified by mail, if shipment is created through batch processing.","Wählen Sie ob die Lieferungs-E-Mail an den Kunden gesendet werden soll, wenn die Lieferung durch die Stapelverarbeitung erstellt wurde."
|
151 |
+
"Order is not available anymore. OrderId:","Bestellung ist nicht verfügbar. BestellID:"
|
152 |
+
"Shipment could not be created. Please check order data manually. OrderId:","Lieferung konnte nicht angelegt werden. Bitte prüfen Sie die Bestelldaten manuell. BestellID:"
|
153 |
+
"Shipment could not be created. Shipment already exists. OrderId:","Lieferung konnte nicht angelegt werden. Lieferung existiert bereits. OrderId:"
|
154 |
+
"Sorry, this shipment can not be sent using GLS.","Diese Bestellung kann leider nicht mit GLS verschickt werden."
|
155 |
+
"Pending GLS","Ausstehend GLS"
|
156 |
+
"Pending GLS Error","Ausstehend GLS Error"
|
157 |
+
"Processing GLS","Verarbeitung GLS"
|
158 |
+
"Processing GLS Error","Verarbeitung GLS Error"
|
159 |
+
"Complete GLS","Vollständig GLS"
|
160 |
+
"GLS shipment creating error:","GLS Lieferungserstellung Error:"
|
161 |
+
"Shipment already exists","Lieferung existiert bereits"
|
162 |
+
"Undefined error","Undefinierter Fehler"
|
163 |
+
"Invalid order data for GLS shipment","Ungültige Bestelldaten für GLS Lieferung"
|
164 |
+
"Shipments created for following order ids:","Lieferungen für folgende Bestellungen wurden angelegt:"
|
165 |
"Available for specific countries only","Nur für ausgewählte Länder verfügbar"
|
166 |
"Support","Support"
|
167 |
"If you need assistance setting up the GLS credentials and GLS services","Wenn Sie Hilfe bei der Einrichtung der GLS-Zugangsdaten und GLS-Servicedienstleistungen benötigen"
|
207 |
"GLS - Cash on delivery","GLS - Nachnahme"
|
208 |
"Title","Titel"
|
209 |
"New Order Status","Neuer Bestellstatus"
|
210 |
+
"Instructions","Anleitung"
|
211 |
+
"Following orders could not be processed:","Folgende Bestellungen konnten nicht verarbeitet werden:"
|
212 |
+
"'No labels could be printed","Es konnten keine Lablels gedruckt werden"
|
213 |
+
"Successfully created mass print job with %s items","Eine Stapelverarbeitung mit %s Lieferungen wurde angelegt"
|
214 |
+
"GLS mass action list","GLS Stapelverarbeitungs-Liste"
|
215 |
+
"GLS Shipment mass jobs","GLS Stapelverarbeitungs-Jobs"
|
216 |
+
"In mass action","In Stapelverarbeitung"
|
217 |
+
"GLS Shipment Job ID","GLS Spaleverarbeitung ID"
|
218 |
+
"Completed","Abgeschlossen"
|
219 |
+
"In progress","In Verarbeitung"
|
220 |
+
"Amount","Anzahl"
|
221 |
+
"Successful","Erfolgreich"
|
222 |
+
"Error","Fehler"
|
223 |
+
"Please select shipments to process","Bitte wählen Sie Lieferungen für die Verarbeitung aus"
|
224 |
+
"Error-Code","Fehler-Code"
|
225 |
+
"Error-Message","Fehlermeldung"
|
226 |
+
"Error with error code:%s.","Fehler mit Fehler-Code %s."
|
227 |
+
"More information","Mehr Informationen"
|
228 |
+
"Failed to write %s","Schreiben von %s fehlgeschlagen"
|
229 |
+
"Mass print job has no shipments","Stapelverarbeitungs-Job enthält keine GLS-Lieferungen"
|
230 |
+
"Mass print job has no labels to print","Stapelverarbeitungs-Job enthält keine GLS-Labels zum Druck"
|
231 |
+
"PDF combination error: Check the logs for details","PDF-Zusammenführungs-Error: Prüfen Sie die GLS-Logs für Details"
|
232 |
+
"PDF could not be written: Check file system permissions","PDF konnte nicht geschrieben werden: Prüfen Sie die Dateisystem-Rechte"
|
233 |
+
"Unspecific Error:","Unspezifischer Fehler:"
|
234 |
+
"No PDF-file or file is not readable","Keine PDF-Datei in GLS-Lieferung oder Datei nicht lesbar"
|
235 |
+
"Process status","Prozessstatus"
|
236 |
+
"GLS Mass print ID","GLS Stapelverarbeitungs ID"
|
237 |
+
"%s of %s GLS shipments successfully processed.","%s von %s GLS Lieferungen erfolgreich verarbeitet."
|
238 |
+
"%s shipments could not be propcessed. Please check them manually.","%s Lieferungen konnten nicht verarbeitet werden. Bitte prüfen Sie diese manuell."
|
239 |
+
"In process","In Verarbeitung"
|
240 |
+
"Pending","Ausstehend"
|
241 |
+
"Mass job could not be loaded","Stapelverarbeitung konnte nicht geladen werden"
|
242 |
+
"PDF file invalid","PDF-Datei ungültig"
|
243 |
+
"No valid shipments","Keine gültigen Lieferungen"
|
244 |
+
"Error messages","Fehlermeldungen"
|
245 |
+
"Order with GLS-Shipment","Bestellung mit GLS Lieferung"
|
246 |
+
"Quantity parcels","Anzahl Packstücke"
|
247 |
+
"Quantity update","Anzahl aktualisieren"
|
248 |
+
"Already printed","Bereits gedruckt"
|
249 |
+
"No valid number. Please enter numbers between %s and %s.","Keine gültige Zahl. Bitte geben Sie Zahlen zwischen %s und %s ein."
|
250 |
+
"Quantity is not changed","Anzahl wurde nicht geändert"
|
251 |
+
"Request invalid","Anfrage ungültig"
|
252 |
+
"Not available with cash on delivery","Bei Nachnahme nicht möglich"
|
253 |
+
"Shipment already printed","Lieferung bereits gedruckt"
|
254 |
+
"Shipment in mass action","Lieferung in Stapelverarbeitung"
|
255 |
+
"Update","Aktualisieren"
|
256 |
+
"Error shipment items","Fehlerhafte Lieferungen"
|
257 |
+
"GLS shipment created successful","GLS Lieferung erfolgreich erstellt"
|
js/gls/admin.js
CHANGED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var PrototypeExtensions = {
|
2 |
+
data: function (elem, key, val) {
|
3 |
+
var DATA_REGEX = /data-([\w-]+)/;
|
4 |
+
var ii = 0;
|
5 |
+
var nattr = elem.attributes.length;
|
6 |
+
if (key && val) {
|
7 |
+
elem.setAttribute('data-' + key, val);
|
8 |
+
} else {
|
9 |
+
for (; ii < nattr; ++ii) {
|
10 |
+
var attr = elem.attributes[ii];
|
11 |
+
if (attr && attr.name) {
|
12 |
+
var m = attr.name.match(DATA_REGEX);
|
13 |
+
if (m && m.length > 1) {
|
14 |
+
var datakey = m[1];
|
15 |
+
if (datakey === key) {
|
16 |
+
return attr.value;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
}
|
20 |
+
}
|
21 |
+
}
|
22 |
+
return null;
|
23 |
+
}
|
24 |
+
};
|
25 |
+
|
26 |
+
Element.addMethods(PrototypeExtensions);
|
27 |
+
|
28 |
+
if (typeof tmpVarienGridMassaction == 'undefied') {
|
29 |
+
var tmpVarienGridMassaction = {};
|
30 |
+
}
|
31 |
+
tmpVarienGridMassaction = Class.create(varienGridMassaction, {
|
32 |
+
onGridRowClick: function (grid, evt) {
|
33 |
+
var tdElement = Event.findElement(evt, 'td');
|
34 |
+
var trElement = Event.findElement(evt, 'tr');
|
35 |
+
|
36 |
+
if($(tdElement).down('.qty-parcels-wrap')) {
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
if (!$(tdElement).down('input')) {
|
40 |
+
if ($(tdElement).down('a') || $(tdElement).down('select')) {
|
41 |
+
return;
|
42 |
+
}
|
43 |
+
if (trElement.title) {
|
44 |
+
setLocation(trElement.title);
|
45 |
+
}
|
46 |
+
else {
|
47 |
+
var checkbox = Element.select(trElement, 'input');
|
48 |
+
var isInput = Event.element(evt).tagName == 'input';
|
49 |
+
var checked = isInput ? checkbox[0].checked : !checkbox[0].checked;
|
50 |
+
|
51 |
+
if (checked) {
|
52 |
+
this.checkedString = varienStringArray.add(checkbox[0].value, this.checkedString);
|
53 |
+
} else {
|
54 |
+
this.checkedString = varienStringArray.remove(checkbox[0].value, this.checkedString);
|
55 |
+
}
|
56 |
+
this.grid.setCheckboxChecked(checkbox[0], checked);
|
57 |
+
this.updateCount();
|
58 |
+
}
|
59 |
+
return;
|
60 |
+
}
|
61 |
+
|
62 |
+
if (Event.element(evt).isMassactionCheckbox) {
|
63 |
+
this.setCheckbox(Event.element(evt));
|
64 |
+
} else if (checkbox = this.findCheckbox(evt)) {
|
65 |
+
checkbox.checked = !checkbox.checked;
|
66 |
+
this.setCheckbox(checkbox);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
});
|
70 |
+
varienGridMassaction = tmpVarienGridMassaction;
|
lib/SynergeticAgency/GlsConnector/Connector.php
CHANGED
@@ -13,6 +13,11 @@ class SynergeticAgency_GlsConnector_Connector
|
|
13 |
const GLS_API_CONNECTOR_FUNC_SHIPPING = "shipments";
|
14 |
const GLS_API_CONNECTOR_FUNC_JSON = "shipments/configuration";
|
15 |
|
|
|
|
|
|
|
|
|
|
|
16 |
private $host;
|
17 |
private $schema;
|
18 |
private $port;
|
@@ -176,9 +181,10 @@ class SynergeticAgency_GlsConnector_Connector
|
|
176 |
$this->curlExec();
|
177 |
} else {
|
178 |
if($this->getCurlErrorRetryCount() === $this->getCurlErrorRetry()) {
|
|
|
179 |
$logMessage = 'retry curlExec failed for ' . $this->getCurlErrorRetryCount() . ' times';
|
180 |
$this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::EMERG );
|
181 |
-
throw new Exception( $logMessage );
|
182 |
}
|
183 |
$this->setCurlErrorRetryCount( 0 );
|
184 |
}
|
@@ -241,6 +247,8 @@ class SynergeticAgency_GlsConnector_Connector
|
|
241 |
|
242 |
$logMessage = '\$this->getCurlResponse(): ' . var_export( $this->getCurlResponse(), 1);
|
243 |
$this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
|
|
|
|
|
244 |
|
245 |
} else {
|
246 |
$responseArray = json_decode($this->getCurlResponseBody());
|
@@ -1023,18 +1031,18 @@ class SynergeticAgency_GlsConnector_Connector
|
|
1023 |
* @param array $labels Array that contains serveral labels saved on the filesystem
|
1024 |
* Note, that these files must be base64 decoded,
|
1025 |
* because the used ZEND PDF can only handle base64_decoded files
|
1026 |
-
* @param bool $target
|
1027 |
* @return bool|string $returnValue returns false, if something went wrong
|
1028 |
* returns full path of combined file
|
1029 |
* @throws Zend_Pdf_Exception
|
1030 |
*/
|
1031 |
-
public function combineLabels( $labels
|
1032 |
{
|
|
|
|
|
|
|
1033 |
|
1034 |
-
$returnValue = false;
|
1035 |
$labelCount = 0;
|
1036 |
$labelPagesCount = 0;
|
1037 |
-
$maxLabelCount = 100;
|
1038 |
|
1039 |
// just to simulate more files than given in array $labels
|
1040 |
#$labels500 = array();
|
@@ -1047,57 +1055,33 @@ class SynergeticAgency_GlsConnector_Connector
|
|
1047 |
#$labels = $labels500;
|
1048 |
|
1049 |
// init Zend PDF
|
1050 |
-
// Note, that ZEND PDF can only handle base64_decoded files!
|
1051 |
$zendPDF = new Zend_Pdf();
|
1052 |
$zendPDF->properties['encoding'] = "utf-8";
|
1053 |
|
1054 |
$labelMerged = new Zend_Pdf();
|
1055 |
$labelMerged->properties['encoding'] = "utf-8";
|
1056 |
|
1057 |
-
$zendPDF = new Zend_Pdf();
|
1058 |
-
$loadedLabelFiles = array();
|
1059 |
-
$firstFile = false;
|
1060 |
foreach ($labels AS $key => $label) {
|
1061 |
-
if($firstFile === false ){
|
1062 |
-
$firstFile = $label;
|
1063 |
-
}
|
1064 |
-
|
1065 |
$logMessage = "clone Label No " . ++$labelCount;
|
1066 |
$this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
|
1067 |
try {
|
1068 |
-
$loadedLabelFiles
|
1069 |
-
|
1070 |
-
|
1071 |
-
foreach ($loadedLabelFiles[$key]->pages as $page) {
|
1072 |
$clonedPage = clone $page;
|
1073 |
$labelMerged->pages[] = $clonedPage;
|
1074 |
$logMessage = "clone Page No " . ++$labelPagesCount . " for Label No " . $labelCount;
|
1075 |
$this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
|
1076 |
}
|
|
|
1077 |
} catch (Exception $e) {
|
1078 |
$logMessage = $e->getMessage() . " => " . $label;
|
1079 |
$this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::ERR );
|
1080 |
}
|
1081 |
-
|
1082 |
-
if ($labelCount >= $maxLabelCount) {
|
1083 |
-
break;
|
1084 |
-
}
|
1085 |
}
|
1086 |
-
|
1087 |
-
|
1088 |
-
#header('Content-type: application/pdf');
|
1089 |
-
#echo $labelMerged->render();
|
1090 |
-
|
1091 |
-
// or save it into filesystem
|
1092 |
-
if( $target !== false && file_exists(dirname($target)) ){
|
1093 |
-
$returnValue = $target;
|
1094 |
-
|
1095 |
-
} else {
|
1096 |
-
$returnValue = $firstFile . ".combined.pdf";
|
1097 |
}
|
1098 |
-
|
1099 |
-
|
1100 |
-
return $returnValue;
|
1101 |
}
|
1102 |
-
|
1103 |
}
|
13 |
const GLS_API_CONNECTOR_FUNC_SHIPPING = "shipments";
|
14 |
const GLS_API_CONNECTOR_FUNC_JSON = "shipments/configuration";
|
15 |
|
16 |
+
/** Curl request timed out or was not reachable */
|
17 |
+
const GLS_API_CONNECTOR_ERROR_CODE_CURL_EXEC_FAILED = 30;
|
18 |
+
/** Curl request returned an error */
|
19 |
+
const GLS_API_CONNECTOR_ERROR_CODE_CURL_ERROR = 31;
|
20 |
+
|
21 |
private $host;
|
22 |
private $schema;
|
23 |
private $port;
|
181 |
$this->curlExec();
|
182 |
} else {
|
183 |
if($this->getCurlErrorRetryCount() === $this->getCurlErrorRetry()) {
|
184 |
+
$errorCode = self::GLS_API_CONNECTOR_ERROR_CODE_CURL_EXEC_FAILED;
|
185 |
$logMessage = 'retry curlExec failed for ' . $this->getCurlErrorRetryCount() . ' times';
|
186 |
$this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::EMERG );
|
187 |
+
throw new Exception( get_class($this).': '.$logMessage,$errorCode );
|
188 |
}
|
189 |
$this->setCurlErrorRetryCount( 0 );
|
190 |
}
|
247 |
|
248 |
$logMessage = '\$this->getCurlResponse(): ' . var_export( $this->getCurlResponse(), 1);
|
249 |
$this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
|
250 |
+
$errorCode = self::GLS_API_CONNECTOR_ERROR_CODE_CURL_ERROR;
|
251 |
+
throw new Exception( get_class($this).': '.$logMessage,$errorCode );
|
252 |
|
253 |
} else {
|
254 |
$responseArray = json_decode($this->getCurlResponseBody());
|
1031 |
* @param array $labels Array that contains serveral labels saved on the filesystem
|
1032 |
* Note, that these files must be base64 decoded,
|
1033 |
* because the used ZEND PDF can only handle base64_decoded files
|
|
|
1034 |
* @return bool|string $returnValue returns false, if something went wrong
|
1035 |
* returns full path of combined file
|
1036 |
* @throws Zend_Pdf_Exception
|
1037 |
*/
|
1038 |
+
public function combineLabels( $labels )
|
1039 |
{
|
1040 |
+
if( count($labels) === 1 ){
|
1041 |
+
return array_shift( $labels );
|
1042 |
+
}
|
1043 |
|
|
|
1044 |
$labelCount = 0;
|
1045 |
$labelPagesCount = 0;
|
|
|
1046 |
|
1047 |
// just to simulate more files than given in array $labels
|
1048 |
#$labels500 = array();
|
1055 |
#$labels = $labels500;
|
1056 |
|
1057 |
// init Zend PDF
|
|
|
1058 |
$zendPDF = new Zend_Pdf();
|
1059 |
$zendPDF->properties['encoding'] = "utf-8";
|
1060 |
|
1061 |
$labelMerged = new Zend_Pdf();
|
1062 |
$labelMerged->properties['encoding'] = "utf-8";
|
1063 |
|
|
|
|
|
|
|
1064 |
foreach ($labels AS $key => $label) {
|
|
|
|
|
|
|
|
|
1065 |
$logMessage = "clone Label No " . ++$labelCount;
|
1066 |
$this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
|
1067 |
try {
|
1068 |
+
$loadedLabelFiles = $zendPDF::parse($label);
|
1069 |
+
// add all pages from the loaded PDF to our new document
|
1070 |
+
foreach ($loadedLabelFiles->pages as $page) {
|
|
|
1071 |
$clonedPage = clone $page;
|
1072 |
$labelMerged->pages[] = $clonedPage;
|
1073 |
$logMessage = "clone Page No " . ++$labelPagesCount . " for Label No " . $labelCount;
|
1074 |
$this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
|
1075 |
}
|
1076 |
+
$loadedLabelFiles = null; // freeup ram
|
1077 |
} catch (Exception $e) {
|
1078 |
$logMessage = $e->getMessage() . " => " . $label;
|
1079 |
$this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::ERR );
|
1080 |
}
|
|
|
|
|
|
|
|
|
1081 |
}
|
1082 |
+
if(count($labelMerged->pages)) {
|
1083 |
+
return $labelMerged->render();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1084 |
}
|
1085 |
+
return false;
|
|
|
|
|
1086 |
}
|
|
|
1087 |
}
|
lib/SynergeticAgency/GlsConnector/Log.php
CHANGED
@@ -114,7 +114,7 @@ class SynergeticAgency_GlsConnector_Log
|
|
114 |
error_log("GLS Connector: Logfile: ".$this->getLogFile() . " is Not writable!!!");
|
115 |
}
|
116 |
} else {
|
117 |
-
error_log("GLS Connector: logging is NOT activated: " . (Integer)$this->isOn());
|
118 |
}
|
119 |
}
|
120 |
|
114 |
error_log("GLS Connector: Logfile: ".$this->getLogFile() . " is Not writable!!!");
|
115 |
}
|
116 |
} else {
|
117 |
+
//error_log("GLS Connector: logging is NOT activated: " . (Integer)$this->isOn());
|
118 |
}
|
119 |
}
|
120 |
|
lib/SynergeticAgency/GlsConnector/Model/Address.php
CHANGED
@@ -224,7 +224,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
224 |
|
225 |
/**
|
226 |
* @param $glsArray
|
227 |
-
* @return
|
228 |
*/
|
229 |
public function setGlsArray($glsArray) {
|
230 |
$this->glsArray = $glsArray;
|
@@ -234,7 +234,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
234 |
/**
|
235 |
* @param $key
|
236 |
* @param $value
|
237 |
-
* @return
|
238 |
*/
|
239 |
public function addGlsArrayValue( $key, $value ) {
|
240 |
$this->glsArray[$key] = $value;
|
@@ -250,7 +250,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
250 |
|
251 |
/**
|
252 |
* @param $type
|
253 |
-
* @return
|
254 |
*/
|
255 |
public function setType($type) {
|
256 |
$this->type = $type;
|
@@ -267,7 +267,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
267 |
|
268 |
/**
|
269 |
* @param string $id
|
270 |
-
* @return
|
271 |
*/
|
272 |
public function setId($id)
|
273 |
{
|
@@ -285,7 +285,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
285 |
|
286 |
/**
|
287 |
* @param $name1
|
288 |
-
* @return
|
289 |
*/
|
290 |
public function setName1($name1) {
|
291 |
//TODO: Implement filter in all setters (php filter)
|
@@ -303,7 +303,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
303 |
|
304 |
/**
|
305 |
* @param $name2
|
306 |
-
* @return
|
307 |
*/
|
308 |
public function setName2($name2) {
|
309 |
$this->name2 = substr($name2,0,40);
|
@@ -320,7 +320,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
320 |
|
321 |
/**
|
322 |
* @param $name3
|
323 |
-
* @return
|
324 |
*/
|
325 |
public function setName3($name3) {
|
326 |
$this->name3 = substr($name3,0,40);
|
@@ -337,7 +337,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
337 |
|
338 |
/**
|
339 |
* @param $street1
|
340 |
-
* @return
|
341 |
*/
|
342 |
public function setStreet1($street1) {
|
343 |
$this->street1 = substr($street1,0,40);
|
@@ -354,7 +354,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
354 |
|
355 |
/**
|
356 |
* @param $street2
|
357 |
-
* @return
|
358 |
*/
|
359 |
public function setStreet2($street2) {
|
360 |
$this->street2 = substr($street2,0,40);
|
@@ -372,7 +372,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
372 |
|
373 |
/**
|
374 |
* @param string $blockNo1
|
375 |
-
* @return
|
376 |
*/
|
377 |
public function setBlockNo1($blockNo1)
|
378 |
{
|
@@ -391,7 +391,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
391 |
|
392 |
/**
|
393 |
* @param string $blockNo2
|
394 |
-
* @return
|
395 |
*/
|
396 |
public function setBlockNo2($blockNo2)
|
397 |
{
|
@@ -408,7 +408,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
408 |
|
409 |
/**
|
410 |
* @param $country
|
411 |
-
* @return
|
412 |
*/
|
413 |
public function setCountry( $country ) {
|
414 |
|
@@ -427,7 +427,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
427 |
|
428 |
/**
|
429 |
* @param $zipCode
|
430 |
-
* @return
|
431 |
*/
|
432 |
public function setZipCode($zipCode) {
|
433 |
$this->zipCode = $zipCode;
|
@@ -444,7 +444,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
444 |
|
445 |
/**
|
446 |
* @param $city
|
447 |
-
* @return
|
448 |
*/
|
449 |
public function setCity($city) {
|
450 |
$this->city = $city;
|
@@ -462,7 +462,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
462 |
|
463 |
/**
|
464 |
* @param string $province
|
465 |
-
* @return
|
466 |
*/
|
467 |
public function setProvince($province)
|
468 |
{
|
@@ -482,7 +482,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
482 |
|
483 |
/**
|
484 |
* @param $contact
|
485 |
-
* @return
|
486 |
*/
|
487 |
public function setContact($contact) {
|
488 |
$this->contact = $contact;
|
@@ -499,7 +499,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
499 |
|
500 |
/**
|
501 |
* @param $email
|
502 |
-
* @return
|
503 |
*/
|
504 |
public function setEmail($email) {
|
505 |
$this->email = $email;
|
@@ -516,7 +516,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
516 |
|
517 |
/**
|
518 |
* @param $phone
|
519 |
-
* @return
|
520 |
*/
|
521 |
public function setPhone($phone) {
|
522 |
$this->phone = $phone;
|
@@ -533,7 +533,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
533 |
|
534 |
/**
|
535 |
* @param $mobile
|
536 |
-
* @return
|
537 |
*/
|
538 |
public function setMobile($mobile) {
|
539 |
$this->mobile = $mobile;
|
@@ -551,7 +551,7 @@ class SynergeticAgency_GlsConnector_Model_Address {
|
|
551 |
|
552 |
/**
|
553 |
* @param string $comments
|
554 |
-
* @return
|
555 |
*/
|
556 |
public function setComments($comments)
|
557 |
{
|
224 |
|
225 |
/**
|
226 |
* @param $glsArray
|
227 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
228 |
*/
|
229 |
public function setGlsArray($glsArray) {
|
230 |
$this->glsArray = $glsArray;
|
234 |
/**
|
235 |
* @param $key
|
236 |
* @param $value
|
237 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
238 |
*/
|
239 |
public function addGlsArrayValue( $key, $value ) {
|
240 |
$this->glsArray[$key] = $value;
|
250 |
|
251 |
/**
|
252 |
* @param $type
|
253 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
254 |
*/
|
255 |
public function setType($type) {
|
256 |
$this->type = $type;
|
267 |
|
268 |
/**
|
269 |
* @param string $id
|
270 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
271 |
*/
|
272 |
public function setId($id)
|
273 |
{
|
285 |
|
286 |
/**
|
287 |
* @param $name1
|
288 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
289 |
*/
|
290 |
public function setName1($name1) {
|
291 |
//TODO: Implement filter in all setters (php filter)
|
303 |
|
304 |
/**
|
305 |
* @param $name2
|
306 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
307 |
*/
|
308 |
public function setName2($name2) {
|
309 |
$this->name2 = substr($name2,0,40);
|
320 |
|
321 |
/**
|
322 |
* @param $name3
|
323 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
324 |
*/
|
325 |
public function setName3($name3) {
|
326 |
$this->name3 = substr($name3,0,40);
|
337 |
|
338 |
/**
|
339 |
* @param $street1
|
340 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
341 |
*/
|
342 |
public function setStreet1($street1) {
|
343 |
$this->street1 = substr($street1,0,40);
|
354 |
|
355 |
/**
|
356 |
* @param $street2
|
357 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
358 |
*/
|
359 |
public function setStreet2($street2) {
|
360 |
$this->street2 = substr($street2,0,40);
|
372 |
|
373 |
/**
|
374 |
* @param string $blockNo1
|
375 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
376 |
*/
|
377 |
public function setBlockNo1($blockNo1)
|
378 |
{
|
391 |
|
392 |
/**
|
393 |
* @param string $blockNo2
|
394 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
395 |
*/
|
396 |
public function setBlockNo2($blockNo2)
|
397 |
{
|
408 |
|
409 |
/**
|
410 |
* @param $country
|
411 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
412 |
*/
|
413 |
public function setCountry( $country ) {
|
414 |
|
427 |
|
428 |
/**
|
429 |
* @param $zipCode
|
430 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
431 |
*/
|
432 |
public function setZipCode($zipCode) {
|
433 |
$this->zipCode = $zipCode;
|
444 |
|
445 |
/**
|
446 |
* @param $city
|
447 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
448 |
*/
|
449 |
public function setCity($city) {
|
450 |
$this->city = $city;
|
462 |
|
463 |
/**
|
464 |
* @param string $province
|
465 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
466 |
*/
|
467 |
public function setProvince($province)
|
468 |
{
|
482 |
|
483 |
/**
|
484 |
* @param $contact
|
485 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
486 |
*/
|
487 |
public function setContact($contact) {
|
488 |
$this->contact = $contact;
|
499 |
|
500 |
/**
|
501 |
* @param $email
|
502 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
503 |
*/
|
504 |
public function setEmail($email) {
|
505 |
$this->email = $email;
|
516 |
|
517 |
/**
|
518 |
* @param $phone
|
519 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
520 |
*/
|
521 |
public function setPhone($phone) {
|
522 |
$this->phone = $phone;
|
533 |
|
534 |
/**
|
535 |
* @param $mobile
|
536 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
537 |
*/
|
538 |
public function setMobile($mobile) {
|
539 |
$this->mobile = $mobile;
|
551 |
|
552 |
/**
|
553 |
* @param string $comments
|
554 |
+
* @return SynergeticAgency_GlsConnector_Model_Address
|
555 |
*/
|
556 |
public function setComments($comments)
|
557 |
{
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Official_GLS_Dispatch</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
@@ -37,9 +37,9 @@ GLS Germany at a glance 
|
|
37 |
Visit our website https://gls-group.eu</description>
|
38 |
<notes>Official GLS Dispatch Extension</notes>
|
39 |
<authors><author><name>synergetic PHP Webdevelopment</name><user>php_synag</user><email>phpwebdevelopment@synag.de</email></author></authors>
|
40 |
-
<date>
|
41 |
-
<time>
|
42 |
-
<contents><target name="magecommunity"><dir name="SynergeticAgency"><dir name="Gls"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Gls"><dir name="Shipment"><dir name="Edit"><dir name="Form"><file name="Packages.php" hash="91f20e933a3bdccecd8f51cc65f64a15"/></dir><file name="Form.php" hash="130f4b5cc6cb5e35e12e8229116a8fd9"/></dir><file name="Edit.php" hash="b654dd3a6953012beeb01db0952580a4"/><dir name="Grid"><dir name="Renderer"><file name="Order.php" hash="84b8e9730bcd070f710e5b75d93d18f7"/><file name="Pdf.php" hash="271ef29c53abf26aa11d8a249f494db3"/><file name="Shipment.php" hash="336ae75186fa605a720dd9c6682249b3"/></dir></dir><file name="Grid.php" hash="c34a83ec1fd24e3329eea42c83b73fa0"/></dir><file name="Shipment.php" hash="e394cbdaee759e608ee1da17e7429bbd"/></dir><dir name="Order"><dir name="Address"><dir name="Form"><dir name="Attr"><file name="Parcelshopid.php" hash="5966474ca779e65a40e5325f377704c5"/></dir></dir></dir><dir name="Shipment"><dir name="Create"><dir name="Gls"><file name="Packages.php" hash="90e98ad4ba0cefd5a2ff7597c7282087"/></dir><file name="Gls.php" hash="1a35cf1f562363f693c8af750ca51d12"/><file name="Tracking.php" hash="c4d69cde80d2f647785ef95ca250a484"/></dir><dir name="View"><file name="Gls.php" hash="8841cb4c9ecd508e0192cf006288bed0"/><file name="Tracking.php" hash="eefb3ae8108758dc1b5212e18b62d0d9"/></dir></dir><dir name="Template"><dir name="Grid"><dir name="Renderer"><file name="Order.php" hash="57a77ece47021b109e9bb5f76fdfc0de"/></dir></dir></dir></dir></dir><dir name="System"><dir name="Config"><file name="Note.php" hash="3af47df0dff99e11650b70bff2261170"/></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><dir name="Parcelshop"><file name="Map.php" hash="95e614d0f081ca946970f8d8909c8e7d"/></dir><file name="Parcelshop.php" hash="e775188503153128246fee50fc45bad5"/></dir></dir><dir name="Form"><file name="Glscashondelivery.php" hash="e58ca6fd528c47d13c92aa60e66736db"/></dir></dir><dir name="Helper"><file name="Data.php" hash="e834d2c6ad67ec140f12b90f8879287d"/><file name="Log.php" hash="ff72f850515f2543d74cdafe758ed489"/><file name="Validate.php" hash="e3fcfface1fa779e84a97af0a0d050d7"/></dir><dir name="Model"><file name="Carrier.php" hash="1fd3232606e7747c3529a7c845bace6f"/><file name="Combination.php" hash="0f98dfc1621be095a62cb5636c18d549"/><file name="Country.php" hash="6c924cb0b18c5ab1f35318dbd9ea863d"/><file name="Gls.php" hash="0b6cb1ff7208b5a42c38deb44633f2a1"/><file name="Glscashondelivery.php" hash="8d5e0ceedcef3117bffbee3417dc9e08"/><file name="Jsonimport.php" hash="0ecb8306613536a30942a6ebdaa42bad"/><file name="Observer.php" hash="9f55a620de98843f11eeb5de72336865"/><file name="Product.php" hash="e1620ee8bfd2e339ecece8395c33d6d5"/><dir name="Resource"><dir name="Combination"><file name="Collection.php" hash="116ffac74da0a67d51e33e4287e435c3"/></dir><file name="Combination.php" hash="d67846f51d288506ca37694d5cbf34f3"/><dir name="Country"><file name="Collection.php" hash="70f548294111419f8dc76e4e92890118"/></dir><file name="Country.php" hash="a7c39d638370da328f66bef5568353c6"/><dir name="Product"><file name="Collection.php" hash="84050613e4f87df08bca6717eec901b8"/></dir><file name="Product.php" hash="eb93a5f933b5fd5d19311e096cdaae9d"/><dir name="Service"><file name="Collection.php" hash="cc7226bbe64460be82c63d1f6a9bfd05"/></dir><file name="Service.php" hash="3045a8e5be427920117b17d40620922a"/><dir name="Shipment"><dir name="Address"><file name="Collection.php" hash="c168ba8ba814fed8eb595a62e0dd5cd6"/></dir><file name="Address.php" hash="64828c17296560efb133d23a98e67a84"/><file name="Collection.php" hash="ce3796ddd9e0aa4b0d3ad392a197e745"/><dir name="Parcel"><file name="Collection.php" hash="70f3a3e4f49b8ec9ff66c421c9a35085"/></dir><file name="Parcel.php" hash="68d4501a688b8ef4bec43c2407058013"/></dir><file name="Shipment.php" hash="89b7956f988bdc2c26024e02865e7d89"/></dir><file name="Service.php" hash="cfa24a5d95416a3ca07406ee3a3a2703"/><dir name="Shipment"><file name="Address.php" hash="5e027a153566768b638a444cdf23f63c"/><file name="Parcel.php" hash="c739d558e2701f19104e1774d74fd68f"/></dir><file name="Shipment.php" hash="15b89fb358f1feea203f1afe0cebc996"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Country.php" hash="5e2e353feeddf2c767c12f7a3409689e"/><file name="Labelsize.php" hash="2beaad42e6e8f2a79ec6d0d7e15c752a"/><dir name="Payment"><file name="Shippingmethods.php" hash="cd31b98704fed4c33d2529a3689634fe"/></dir><file name="Product.php" hash="069126b5ca1874c6daf8335af2720a79"/><file name="Service.php" hash="9c92af191394c848387e32a8a65a4b25"/></dir></dir></dir></dir><dir name="config"><file name="combinations.php" hash="1191f3835ce1f07a2e19321324debd10"/><file name="countries.php" hash="c2662d70b50f3ef58775f5f043eb081a"/><file name="products.php" hash="3aec24a4a21d715df3cb15384eaef141"/><file name="services.php" hash="e72398afc6ca4b59b76392613f53d11d"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Gls"><file name="ShipmentController.php" hash="08493efd89ff0c6d4ff7eed91be8e9f3"/></dir></dir><file name="FrontendController.php" hash="a82a55cb65c2bd61dd6127e429f3ea0c"/></dir><dir name="data"><dir name="synergeticagency_gls_setup"><file name="data-install-0.1.0.php" hash="aeb81a59338eb10de8e8e12393821e46"/><file name="data-upgrade-0.1.0-0.1.1.php" hash="1e38465f87e4555abaadb59d8774faf6"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="046fb0feb6b47eb742f9c28a911d804f"/><file name="config.xml" hash="ffb98fbfdafef7e73298179749ad4757"/><file name="system.xml" hash="6bbd656829b8a487e852990173d62d74"/></dir><dir name="sql"><dir name="synergeticagency_gls_setup"><file name="install-0.1.0.php" hash="7e69be89f64cb3c841a9ace948a652d2"/><file name="upgrade-0.1.0-0.1.1.php" hash="7a58bfa3872c6e2d7fadae09179278ea"/><file name="upgrade-0.1.1-0.1.2.php" hash="e497ce202e932f95c8a7413fcfd5b791"/><file name="upgrade-0.1.2-0.1.3.php" hash="af5276700bf147971111d9feb8b751f1"/><file name="upgrade-0.1.3-0.1.4.php" hash="5021f44b21fb44f7bb193e92a20d584e"/><file name="upgrade-0.1.4-0.1.5.php" hash="95f12fb87ee236b9943fde5dc189dff0"/><file name="upgrade-0.1.5-0.1.6.php" hash="44fee4ba161db67a37729e498d5bb440"/><file name="upgrade-0.1.6-0.1.7.php" hash="133605d2298bdab5f04bce6aab395d68"/><file name="upgrade-0.2.0-0.2.1.php" hash="d6810125a8567c0ef45b06547c18b985"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="layout"><dir name="synergeticagency"><file name="gls.xml" hash="6afd9de85405f93be8843e4bf9153d97"/></dir></dir><dir name="template"><dir name="gls"><dir name="sales"><dir name="order"><dir name="address"><dir name="form"><dir name="attr"><file name="parcelshopid.phtml" hash="92aa59305e96a13cd64d272ed173da72"/></dir></dir></dir><dir name="shipment"><dir name="create"><dir name="gls"><file name="packages.phtml" hash="cd792e774d40db2fa5104608ef54b69a"/></dir><file name="gls.phtml" hash="279eaa2d0e7037b4ab7b2de394b5262d"/></dir><dir name="view"><file name="gls.phtml" hash="2846d470ed6eddcd64dff4f7138db5c7"/></dir></dir></dir></dir><dir name="shipment"><file name="edit.phtml" hash="337d714acc64c64c8aa579e20770985f"/></dir><dir name="system"><dir name="config"><file name="note.phtml" hash="a11fb5e7c72366a16c5618c560a152e3"/></dir><dir name="shipping"><file name="gls_applicable_country.phtml" hash="d664e96a471211cf549d876c33211d88"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="synergeticagency"><file name="gls.xml" hash="c467b4ac1ce8da629f478872b453ed32"/></dir></dir><dir name="template"><dir name="gls"><dir name="checkout"><dir name="onepage"><file name="billing_form_additional_parcelshop.phtml" hash="54fb0c007573d1354aeb74040328d67f"/><dir name="parcelshop"><file name="map.phtml" hash="a37985a1162cb40411933f697ec9efd9"/></dir><file name="shipping.phtml" hash="c706d0e8f4a17848e18ecd7e02303edc"/><file name="shipping_parcelshop.phtml" hash="545b904931d20a047cda48dc3d0a0442"/></dir></dir><dir name="form"><file name="glscashondelivery.phtml" hash="fe641f6afe8234f1b4dd85d63c694491"/></dir><file name="logoJs.phtml" hash="44b47e92ddd06e0fbc4c0d854562ca42"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SynergeticAgency_Gls.xml" hash="72ff227686c41d266f3ed18e2f91cc4a"/></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="SynergeticAgency_Gls.csv" hash="65061d39ddae8dadc7778fcfa4e0fe97"/></dir></dir></target><target name="mageweb"><dir name="js"><dir name="gls"><file name="admin.js" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="frontend.js" hash="0e3d9ddfd04850314e27db8056f5ec77"/></dir></dir></target><target name="magelib"><dir name="SynergeticAgency"><dir name="GlsConnector"><file name="Connector.php" hash="f9521143580953b482ce07bd893a963f"/><dir name="Log"><file name="README.TXT" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><file name="Log.php" hash="97bc6de9dc722d1a307b3925ea1a7035"/><dir name="Model"><file name="Address.php" hash="c7bf0afaabbd26e3bfa2348fd9ca63b4"/><file name="Error.php" hash="da50fd629c8e16565aa92d98a3b3ef1f"/><file name="Info.php" hash="7e479ae6c9f552cba9695f2d772b8bbf"/><file name="JsonConfig.php" hash="f77bd21973d025225782b808b8b46bc5"/><file name="Parcel.php" hash="1171e6366c35891727501ef71a2bdd29"/><file name="Service.php" hash="e8beafa1054f49cfda4e6c1ee92a625c"/><file name="Services.php" hash="82eda2f6f6d629b91d8f0dcc3671e7fa"/><file name="Shipment.php" hash="4a69d9082203e0994b46fa4cbf6f9e7d"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="images"><dir name="gls"><file name="gls-logo.png" hash="ed21df35da7d08b0189c7b4a31e837b0"/><file name="logo_thumb.png" hash="1e4ba5cac17e639155c562c144d48cc6"/></dir></dir><file name="gls.css" hash="96f81b24658997ec162d0bc3dc787eae"/></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="gls"><file name="frontend.css" hash="93299ba580ca5729a907983bf576ccda"/></dir></dir><dir name="images"><dir name="gls"><dir name="logo"><dir name="de"><file name="express.png" hash="47e2a758ced26660de70333341911825"/><file name="foreigncountries.png" hash="7c507a078ca887d4e4be26916d776513"/><file name="standard.png" hash="47e2a758ced26660de70333341911825"/><file name="thinkgreen.png" hash="fb5d79124a0873e57b2ab0f6dcf1810f"/></dir><dir name="default"><file name="express.png" hash="fb5d79124a0873e57b2ab0f6dcf1810f"/><file name="foreigncountries.png" hash="47e2a758ced26660de70333341911825"/><file name="standard.png" hash="47e2a758ced26660de70333341911825"/><file name="thinkgreen.png" hash="47e2a758ced26660de70333341911825"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="var"><dir name="import"><dir name="gls"><dir name="json"><file name="glsconfig.json.sample" hash="0aa187478b898b69ea327f4741bbddd8"/></dir></dir></dir></dir></target></contents>
|
43 |
<compatible/>
|
44 |
<dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies>
|
45 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Official_GLS_Dispatch</name>
|
4 |
+
<version>1.1.3</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
37 |
Visit our website https://gls-group.eu</description>
|
38 |
<notes>Official GLS Dispatch Extension</notes>
|
39 |
<authors><author><name>synergetic PHP Webdevelopment</name><user>php_synag</user><email>phpwebdevelopment@synag.de</email></author></authors>
|
40 |
+
<date>2017-03-26</date>
|
41 |
+
<time>18:20:50</time>
|
42 |
+
<contents><target name="magecommunity"><dir name="SynergeticAgency"><dir name="Gls"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Gls"><dir name="Shipment"><dir name="Edit"><dir name="Form"><file name="Packages.php" hash="91f20e933a3bdccecd8f51cc65f64a15"/></dir><file name="Form.php" hash="130f4b5cc6cb5e35e12e8229116a8fd9"/></dir><file name="Edit.php" hash="b654dd3a6953012beeb01db0952580a4"/><dir name="Grid"><file name="Js.php" hash="185fbbea3a3b6a8c69a65a5d421d6dd0"/><dir name="Renderer"><file name="Error.php" hash="bc76497e2b2593ef824be9f175e7ea13"/><file name="Order.php" hash="84b8e9730bcd070f710e5b75d93d18f7"/><file name="Pdf.php" hash="5477966b17b96d50ad8ef5d306d834c0"/><file name="Qtyparcels.php" hash="cfa3999873e4e599389deec4b0ab437e"/><file name="Qtyupdate.php" hash="b2e7d0db266700fa8b1943a65972d9fb"/><file name="Shipment.php" hash="336ae75186fa605a720dd9c6682249b3"/></dir></dir><file name="Grid.php" hash="bec275dbfc40df9af93de404aa452a9d"/><dir name="Job"><dir name="Grid"><file name="Js.php" hash="334519ac94d2312f0979c5a4f86606dc"/><dir name="Renderer"><file name="Action.php" hash="a74dfbb00cef125394d3e4cece2ea940"/><file name="Erroritems.php" hash="9aaeaa1bcdb92366bc00f54f645f1500"/><file name="Jobstatus.php" hash="dacbd1e16e981f1d0a4d71ba1d166a8f"/></dir></dir><file name="Grid.php" hash="688481fa76d51529d2f31f0b846eed40"/></dir><file name="Job.php" hash="834e7a8bdeb2b2de6133b08d5d3afcba"/></dir><file name="Shipment.php" hash="e394cbdaee759e608ee1da17e7429bbd"/></dir><dir name="Order"><dir name="Address"><dir name="Form"><dir name="Attr"><file name="Parcelshopid.php" hash="5966474ca779e65a40e5325f377704c5"/></dir></dir></dir><dir name="Shipment"><dir name="Create"><dir name="Gls"><file name="Packages.php" hash="15241e274ecd57916426f8bc5c5a3c21"/></dir><file name="Gls.php" hash="c6720bcda21952b30422e4df02feb5af"/><file name="Tracking.php" hash="c4d69cde80d2f647785ef95ca250a484"/></dir><dir name="View"><file name="Gls.php" hash="8841cb4c9ecd508e0192cf006288bed0"/><file name="Tracking.php" hash="eefb3ae8108758dc1b5212e18b62d0d9"/></dir></dir><dir name="Template"><dir name="Grid"><dir name="Renderer"><file name="Order.php" hash="57a77ece47021b109e9bb5f76fdfc0de"/></dir></dir></dir></dir></dir><dir name="System"><dir name="Config"><file name="Note.php" hash="3fed3b06327ccd605d24b08da310ef18"/></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><dir name="Parcelshop"><file name="Map.php" hash="95e614d0f081ca946970f8d8909c8e7d"/></dir><file name="Parcelshop.php" hash="e775188503153128246fee50fc45bad5"/></dir></dir><dir name="Form"><file name="Glscashondelivery.php" hash="e58ca6fd528c47d13c92aa60e66736db"/></dir></dir><file name="Exception.php" hash="cc10e7d436240ab0b4fc2f70c2871062"/><dir name="Helper"><file name="Data.php" hash="c19c91e3574d55d4062221a52ed46f6f"/><file name="Log.php" hash="922af6249fc30b9c6bedecb9bd26420d"/><file name="Validate.php" hash="23f59442d00aaa107a58d9c077670ef0"/></dir><dir name="Model"><file name="Carrier.php" hash="6708a24cfaaed45ae3423549fd6d78b9"/><file name="Combination.php" hash="0f98dfc1621be095a62cb5636c18d549"/><file name="Country.php" hash="8676759dfa7bcaaaacf7bc23b571296f"/><file name="Gls.php" hash="69d4e4ae041bb5ba593a81968a377317"/><file name="Glscashondelivery.php" hash="8d5e0ceedcef3117bffbee3417dc9e08"/><file name="Jsonimport.php" hash="0ecb8306613536a30942a6ebdaa42bad"/><file name="Massprint.php" hash="b780fba06d50a2ab31e273a05e814928"/><file name="Observer.php" hash="1dd642653bb6cb2620cc5f88481b75c3"/><file name="Product.php" hash="e1620ee8bfd2e339ecece8395c33d6d5"/><dir name="Resource"><dir name="Combination"><file name="Collection.php" hash="116ffac74da0a67d51e33e4287e435c3"/></dir><file name="Combination.php" hash="d67846f51d288506ca37694d5cbf34f3"/><dir name="Country"><file name="Collection.php" hash="70f548294111419f8dc76e4e92890118"/></dir><file name="Country.php" hash="a7c39d638370da328f66bef5568353c6"/><dir name="Product"><file name="Collection.php" hash="84050613e4f87df08bca6717eec901b8"/></dir><file name="Product.php" hash="eb93a5f933b5fd5d19311e096cdaae9d"/><dir name="Service"><file name="Collection.php" hash="f4846332843a1d5bc4c59ec31eabec83"/></dir><file name="Service.php" hash="3045a8e5be427920117b17d40620922a"/><dir name="Shipment"><dir name="Address"><file name="Collection.php" hash="c168ba8ba814fed8eb595a62e0dd5cd6"/></dir><file name="Address.php" hash="64828c17296560efb133d23a98e67a84"/><file name="Collection.php" hash="ce3796ddd9e0aa4b0d3ad392a197e745"/><dir name="Job"><file name="Collection.php" hash="a8f4269ad9f40c58b1a4d5e9e8d0f3db"/></dir><file name="Job.php" hash="7fd961f88885e7315cbd49c48973c7e3"/><dir name="Parcel"><file name="Collection.php" hash="70f3a3e4f49b8ec9ff66c421c9a35085"/></dir><file name="Parcel.php" hash="68d4501a688b8ef4bec43c2407058013"/></dir><file name="Shipment.php" hash="89b7956f988bdc2c26024e02865e7d89"/></dir><file name="Service.php" hash="cfa24a5d95416a3ca07406ee3a3a2703"/><dir name="Shipment"><file name="Address.php" hash="5e027a153566768b638a444cdf23f63c"/><file name="Job.php" hash="1cffe88751dcb45c888646ca2e1f662d"/><file name="Parcel.php" hash="c739d558e2701f19104e1774d74fd68f"/></dir><file name="Shipment.php" hash="a15aa6cf5d4e96cdad68a24670ef5bcb"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Country.php" hash="5e2e353feeddf2c767c12f7a3409689e"/><file name="Labelsize.php" hash="2beaad42e6e8f2a79ec6d0d7e15c752a"/><dir name="Payment"><file name="Shippingmethods.php" hash="cd31b98704fed4c33d2529a3689634fe"/></dir><file name="Product.php" hash="069126b5ca1874c6daf8335af2720a79"/><file name="Service.php" hash="9c92af191394c848387e32a8a65a4b25"/><file name="Weightunit.php" hash="01c5178b3b74a98009a64f8b28557904"/></dir></dir></dir></dir><dir name="config"><file name="combinations.php" hash="1191f3835ce1f07a2e19321324debd10"/><file name="countries.php" hash="c2662d70b50f3ef58775f5f043eb081a"/><file name="products.php" hash="3aec24a4a21d715df3cb15384eaef141"/><file name="services.php" hash="e72398afc6ca4b59b76392613f53d11d"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Gls"><dir name="Shipment"><file name="JobController.php" hash="639aded64679f2e6a8fb4292d572623e"/></dir><file name="ShipmentController.php" hash="97800ec491de9c799b4e665aa0ddfb1c"/></dir></dir><file name="FrontendController.php" hash="a82a55cb65c2bd61dd6127e429f3ea0c"/></dir><dir name="data"><dir name="synergeticagency_gls_setup"><file name="data-install-0.1.0.php" hash="aeb81a59338eb10de8e8e12393821e46"/><file name="data-upgrade-0.1.0-0.1.1.php" hash="1e38465f87e4555abaadb59d8774faf6"/><file name="data-upgrade-1.0.0-1.1.0.php" hash="4151ca4c05bacdb573cfae81c694e272"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8efe68e15f53ec6397f40c53dfb08dc2"/><file name="config.xml" hash="ef29ed7f6b0e101f8ed69485b2377183"/><file name="system.xml" hash="22ba82932accb0bbdabb46515463c41c"/></dir><dir name="sql"><dir name="synergeticagency_gls_setup"><file name="install-0.1.0.php" hash="7e69be89f64cb3c841a9ace948a652d2"/><file name="upgrade-0.1.0-0.1.1.php" hash="7a58bfa3872c6e2d7fadae09179278ea"/><file name="upgrade-0.1.1-0.1.2.php" hash="57db7b98af093b0546006d0e07707cba"/><file name="upgrade-0.1.2-0.1.3.php" hash="af5276700bf147971111d9feb8b751f1"/><file name="upgrade-0.1.3-0.1.4.php" hash="5021f44b21fb44f7bb193e92a20d584e"/><file name="upgrade-0.1.4-0.1.5.php" hash="95f12fb87ee236b9943fde5dc189dff0"/><file name="upgrade-0.1.5-0.1.6.php" hash="44fee4ba161db67a37729e498d5bb440"/><file name="upgrade-0.1.6-0.1.7.php" hash="133605d2298bdab5f04bce6aab395d68"/><file name="upgrade-0.2.0-0.2.1.php" hash="d6810125a8567c0ef45b06547c18b985"/><file name="upgrade-1.1.0-1.1.1.php" hash="f9d527468eb8f4911effb5e6e676c7f1"/><file name="upgrade-1.1.1-1.1.2.php" hash="fa60778b4057aa8504e81bb3450b22cc"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="layout"><dir name="synergeticagency"><file name="gls.xml" hash="971ba3e8ac12e2689b9cfc2a8d950246"/></dir></dir><dir name="template"><dir name="gls"><dir name="sales"><dir name="order"><dir name="address"><dir name="form"><dir name="attr"><file name="parcelshopid.phtml" hash="92aa59305e96a13cd64d272ed173da72"/></dir></dir></dir><dir name="shipment"><dir name="create"><dir name="gls"><file name="packages.phtml" hash="be20862da902a9761a990d623c04dc36"/></dir><file name="gls.phtml" hash="279eaa2d0e7037b4ab7b2de394b5262d"/></dir><dir name="view"><file name="gls.phtml" hash="adcc66bd8ac7e84a1bee12d1b26d6782"/></dir></dir></dir></dir><dir name="shipment"><file name="edit.phtml" hash="337d714acc64c64c8aa579e20770985f"/><dir name="grid"><file name="js.phtml" hash="b01c7e6695fa9bf4697f1173807dc5c8"/></dir><dir name="job"><dir name="grid"><file name="js.phtml" hash="e56dc3a88fe07226d57921728e4d88cf"/></dir></dir></dir><dir name="system"><dir name="config"><file name="note.phtml" hash="a11fb5e7c72366a16c5618c560a152e3"/></dir><dir name="shipping"><file name="gls_applicable_country.phtml" hash="d664e96a471211cf549d876c33211d88"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="synergeticagency"><file name="gls.xml" hash="c467b4ac1ce8da629f478872b453ed32"/></dir></dir><dir name="template"><dir name="gls"><dir name="checkout"><dir name="onepage"><file name="billing_form_additional_parcelshop.phtml" hash="54fb0c007573d1354aeb74040328d67f"/><dir name="parcelshop"><file name="map.phtml" hash="a37985a1162cb40411933f697ec9efd9"/></dir><file name="shipping.phtml" hash="c706d0e8f4a17848e18ecd7e02303edc"/><file name="shipping_parcelshop.phtml" hash="545b904931d20a047cda48dc3d0a0442"/></dir></dir><dir name="form"><file name="glscashondelivery.phtml" hash="fe641f6afe8234f1b4dd85d63c694491"/></dir><file name="logoJs.phtml" hash="44b47e92ddd06e0fbc4c0d854562ca42"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SynergeticAgency_Gls.xml" hash="72ff227686c41d266f3ed18e2f91cc4a"/></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="SynergeticAgency_Gls.csv" hash="9dd448377115c4a823489d5c76df2ef1"/></dir></dir></target><target name="mageweb"><dir name="js"><dir name="gls"><file name="admin.js" hash="a904c518cfa35075e8dbc8914932a20e"/><file name="frontend.js" hash="0e3d9ddfd04850314e27db8056f5ec77"/></dir></dir></target><target name="magelib"><dir name="SynergeticAgency"><dir name="GlsConnector"><file name="Connector.php" hash="895787a7c1d8982bfae99cab26c2e8a8"/><dir name="Log"><file name="README.TXT" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><file name="Log.php" hash="4cb4525e32704860442a66986b71287e"/><dir name="Model"><file name="Address.php" hash="b2a4a1ed32eaae9aaf9a3d1ef84d2730"/><file name="Error.php" hash="da50fd629c8e16565aa92d98a3b3ef1f"/><file name="Info.php" hash="7e479ae6c9f552cba9695f2d772b8bbf"/><file name="JsonConfig.php" hash="f77bd21973d025225782b808b8b46bc5"/><file name="Parcel.php" hash="1171e6366c35891727501ef71a2bdd29"/><file name="Service.php" hash="e8beafa1054f49cfda4e6c1ee92a625c"/><file name="Services.php" hash="82eda2f6f6d629b91d8f0dcc3671e7fa"/><file name="Shipment.php" hash="4a69d9082203e0994b46fa4cbf6f9e7d"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="images"><dir name="gls"><file name="gls-logo.png" hash="ed21df35da7d08b0189c7b4a31e837b0"/><file name="logo_thumb.png" hash="1e4ba5cac17e639155c562c144d48cc6"/></dir></dir><file name="gls.css" hash="96f81b24658997ec162d0bc3dc787eae"/></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="gls"><file name="frontend.css" hash="93299ba580ca5729a907983bf576ccda"/></dir></dir><dir name="images"><dir name="gls"><dir name="logo"><dir name="de"><file name="express.png" hash="47e2a758ced26660de70333341911825"/><file name="foreigncountries.png" hash="7c507a078ca887d4e4be26916d776513"/><file name="standard.png" hash="47e2a758ced26660de70333341911825"/><file name="thinkgreen.png" hash="fb5d79124a0873e57b2ab0f6dcf1810f"/></dir><dir name="default"><file name="express.png" hash="fb5d79124a0873e57b2ab0f6dcf1810f"/><file name="foreigncountries.png" hash="47e2a758ced26660de70333341911825"/><file name="standard.png" hash="47e2a758ced26660de70333341911825"/><file name="thinkgreen.png" hash="47e2a758ced26660de70333341911825"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="var"><dir name="import"><dir name="gls"><dir name="json"><file name="glsconfig.json.sample" hash="0aa187478b898b69ea327f4741bbddd8"/></dir></dir></dir><dir name="tmp"><dir name="gls"><file name="README.TXT" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></target></contents>
|
43 |
<compatible/>
|
44 |
<dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies>
|
45 |
</package>
|
var/tmp/gls/README.TXT
ADDED
File without changes
|