Chronopost - Version 1.0.5

Version Notes

Compatibilité 1.9 validée, support du thème responsive par défaut de Magento 1.9
Déplacement des templates et skin de default/default vers base/default pour qu'ils puissent être pris en compte en cas de package / thème personnalisé ; voir détails ci-dessous
Ajout de la fonctionnalité de détection des conflits avec d'autres modules de transport
Compatibilité HTTPS de l'appel au Google Maps
Possibilité d'utiliser le module Chronorelais sans Google Maps
Limitation de la version de Google Maps à 3.17 pour prévenir d'une incompatibilité avec prototype 1.7 distribué par Magento
Alerte back-office en cas de disponibilité d'une nouvelle version du module
Remplacement des URLs de quickcost par défaut (http://wsshipping.chronopost.fr/wsQuickcost/services/ServiceQuickCost?wsdl => https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl)
Adresse du point relais remplacée par celle du client pour les étiquettes de retour
Correctifs mineurs (méthode Chronopost_Chronorelais_Helper_Webservice::getMethodIsAllowed, test de Ghostscript avec option '-v', suppression de 'Notices' PHP)

Download this release

Release Info

Developer Benjamin GOSSELET
Extension Chronopost
Version 1.0.5
Comparing to
See all releases


Code changes from version 1.0.3 to 1.0.5

Files changed (42) hide show
  1. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/Notification.php +31 -5
  2. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Fieldsetconflicts.php +46 -0
  3. app/code/community/Chronopost/Chronorelais/Block/Export/Orders/Grid.php +270 -270
  4. app/code/community/Chronopost/Chronorelais/Block/Sales/Bordereau/Grid.php +161 -159
  5. app/code/community/Chronopost/Chronorelais/Block/Sales/Order/Shipment/View.php +27 -98
  6. app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid.php +254 -252
  7. app/code/community/Chronopost/Chronorelais/Helper/Conflicts.php +158 -0
  8. app/code/community/Chronopost/Chronorelais/Helper/Data.php +350 -331
  9. app/code/community/Chronopost/Chronorelais/Helper/Webservice.php +445 -436
  10. app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelaisShipping.php +522 -522
  11. app/code/community/Chronopost/Chronorelais/Model/Sales/Quote/Address/Total/Shipping.php +207 -207
  12. app/code/community/Chronopost/Chronorelais/Model/Sales/Quote/Address/Total/Shipping.toDel.php +207 -0
  13. app/code/community/Chronopost/Chronorelais/controllers/AjaxController.php +446 -441
  14. app/code/community/Chronopost/Chronorelais/controllers/Checkout/OnepageController.php +246 -281
  15. app/code/community/Chronopost/Chronorelais/controllers/ExportController.php +447 -447
  16. app/code/community/Chronopost/Chronorelais/controllers/Sales/ImpressionController.php +1049 -1032
  17. app/code/community/Chronopost/Chronorelais/controllers/Sales/Order/ShipmentController.php +386 -386
  18. app/code/community/Chronopost/Chronorelais/etc/config.xml +452 -451
  19. app/code/community/Chronopost/Chronorelais/etc/system.xml +1582 -1545
  20. app/code/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php +1368 -1368
  21. app/code/community/Chronopost/Chronorelais/includes/countries.inc.php +524 -524
  22. app/design/adminhtml/default/default/template/chronorelais/notification.phtml +18 -4
  23. app/design/frontend/{default → base}/default/layout/chronorelais.xml +4 -4
  24. app/design/frontend/{default → base}/default/template/chronorelais/checkout/multishipping/shipping.phtml +152 -152
  25. app/design/frontend/{default → base}/default/template/chronorelais/checkout/multishipping/shipping_method/chronorelais.phtml +29 -29
  26. app/design/frontend/{default → base}/default/template/chronorelais/checkout/onepage/shipping_method.phtml +107 -92
  27. app/design/frontend/{default → base}/default/template/chronorelais/checkout/onepage/shipping_method/available.phtml +123 -123
  28. app/design/frontend/{default → base}/default/template/chronorelais/checkout/onepage/shipping_method/chronorelais.phtml +36 -29
  29. app/design/frontend/{default → base}/default/template/chronorelais/sales/order/history.phtml +80 -80
  30. app/design/frontend/{default → base}/default/template/chronorelais/sales/order/recent.phtml +79 -79
  31. app/locale/fr_FR/Chronopost_Chronorelais.csv +3 -2
  32. package.xml +16 -12
  33. skin/frontend/{default → base}/default/chronorelais/Logo-Chronopost.jpg +0 -0
  34. skin/frontend/{default → base}/default/chronorelais/Picto_Chrono_Relais.png +0 -0
  35. skin/frontend/{default → base}/default/chronorelais/ac.png +0 -0
  36. skin/frontend/{default → base}/default/chronorelais/chronopost.png +0 -0
  37. skin/frontend/{default → base}/default/chronorelais/chronorelais.css +46 -46
  38. skin/frontend/{default → base}/default/chronorelais/chronorelais.png +0 -0
  39. skin/frontend/{default → base}/default/chronorelais/chronorelaismap.js +574 -567
  40. skin/frontend/{default → base}/default/chronorelais/home.png +0 -0
  41. skin/frontend/{default → base}/default/chronorelais/ico_ac_shaded.gif +0 -0
  42. skin/frontend/default/default/chronorelais/Thumbs.db +0 -0
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/Notification.php CHANGED
@@ -2,6 +2,10 @@
2
  class Chronopost_Chronorelais_Block_Adminhtml_Notification extends Mage_Core_Block_Template
3
  {
4
  const XML_SEVERITY_ICONS_URL_PATH = 'system/adminnotification/severity_icons_url';
 
 
 
 
5
  protected function _prepareLayout()
6
  {
7
  parent::_prepareLayout();
@@ -23,7 +27,13 @@ class Chronopost_Chronorelais_Block_Adminhtml_Notification extends Mage_Core_Blo
23
  if (!Mage::getSingleton('admin/session')->isFirstPageAfterLogin()) {
24
  return false;
25
  }
 
 
26
 
 
 
 
 
27
  $_helper = Mage::helper('chronorelais');
28
  $account_number = $_helper->getConfigurationAccountNumber();
29
  $password = $_helper->getConfigurationAccountPass();
@@ -44,12 +54,28 @@ class Chronopost_Chronorelais_Block_Adminhtml_Notification extends Mage_Core_Blo
44
  $helperWS = Mage::helper('chronorelais/webservice');
45
  $webservbt = $helperWS->checkLogin($WSParams);
46
 
47
- if(!$webservbt) return true;
48
-
49
- $webservbt = (array)$webservbt;
50
- if($webservbt['errorCode'] != 0) { return true; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
- return false;
53
  }
54
 
55
  }
2
  class Chronopost_Chronorelais_Block_Adminhtml_Notification extends Mage_Core_Block_Template
3
  {
4
  const XML_SEVERITY_ICONS_URL_PATH = 'system/adminnotification/severity_icons_url';
5
+
6
+ const MODULE_RELEASES_XML_URL = 'http://connect20.magentocommerce.com/community/Chronopost/releases.xml';
7
+ //all community packages => http://connect20.magentocommerce.com/community/packages.xml
8
+
9
  protected function _prepareLayout()
10
  {
11
  parent::_prepareLayout();
27
  if (!Mage::getSingleton('admin/session')->isFirstPageAfterLogin()) {
28
  return false;
29
  }
30
+ return true;
31
+ }
32
 
33
+ public function getNotifications()
34
+ {
35
+ $notifications = array();
36
+ /* test if WS is ok */
37
  $_helper = Mage::helper('chronorelais');
38
  $account_number = $_helper->getConfigurationAccountNumber();
39
  $password = $_helper->getConfigurationAccountPass();
54
  $helperWS = Mage::helper('chronorelais/webservice');
55
  $webservbt = $helperWS->checkLogin($WSParams);
56
 
57
+ if(!$webservbt) {
58
+ $notifications[] = 'quickcost_not_available';
59
+ } else {
60
+ $webservbt = (array)$webservbt;
61
+ if(isset($webservbt['errorCode']) && $webservbt['errorCode'] != 0) {
62
+ $notifications[] = 'quickcost_not_available';
63
+ }
64
+ }
65
+
66
+ /* test if new version is available */
67
+ $currentVersion = (string)Mage::getConfig()->getModuleConfig("Chronopost_Chronorelais")->version;
68
+
69
+ $xml = simplexml_load_file(self::MODULE_RELEASES_XML_URL);
70
+ $nbRelease = count($xml->children());
71
+ $releases = $xml->children();
72
+ $lastRelease = $releases[$nbRelease-1];
73
+ if(version_compare($currentVersion, $lastRelease->v, '>')) {
74
+ $notifications[] = 'new_version';
75
+ }
76
+
77
+ return $notifications;
78
 
 
79
  }
80
 
81
  }
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Fieldsetconflicts.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Adminhtml_System_Config_Form_Fieldsetconflicts
3
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
4
+ {
5
+
6
+ /**
7
+ * Return footer html for fieldset
8
+ * Add extra tooltip comments to elements
9
+ *
10
+ * @param Varien_Data_Form_Element_Abstract $element
11
+ * @return string
12
+ */
13
+ protected function _getFooterHtml($element)
14
+ {
15
+ $html = '</tbody></table>';
16
+
17
+ $html .= '<div class="chronorelais_conflicts">';
18
+ $html .= '<button onclick="javascript:checkConflicts(); return false;" class="scalable" type="button" id="chronorelais_conflicts">';
19
+ $html .= ' <span>Lancer la vérification</span>';
20
+ $html .= '</button>';
21
+ $html .= '<div id="chronorelais_conflicts_result"></div>';
22
+ $html .= '</div>';
23
+
24
+ $html .= '</fieldset>' . $this->_getExtraJs($element, $tooltipsExist);
25
+
26
+ $html .= '<script type="text/javascript">' . "\r\n";
27
+ $html .= '//<![CDATA[' . "\r\n";
28
+ $html .= ' function checkConflicts() {' . "\r\n";
29
+ $html .= ' new Ajax.Request(\'' . Mage::getSingleton('adminhtml/url')->getUrl('chronorelais/ajax/checkConflicts') . '\', {' . "\r\n";
30
+ $html .= ' onSuccess: function(data) {' . "\r\n";
31
+ $html .= ' var response = data.responseText;' . "\r\n";
32
+ $html .= ' $(\'chronorelais_conflicts_result\').update(response).show();' . "\r\n";
33
+ $html .= ' }' . "\r\n";
34
+ $html .= ' });' . "\r\n";
35
+ $html .= ' }' . "\r\n";
36
+ $html .= '//]]>' . "\r\n";
37
+ $html .= '</script>' . "\r\n";
38
+
39
+ if ($element->getIsNested()) {
40
+ $html .= '</div></td></tr>';
41
+ } else {
42
+ $html .= '</div>';
43
+ }
44
+ return $html;
45
+ }
46
+ }
app/code/community/Chronopost/Chronorelais/Block/Export/Orders/Grid.php CHANGED
@@ -1,270 +1,270 @@
1
- <?php
2
- class Chronopost_Chronorelais_Block_Export_Orders_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
- {
4
-
5
- public function __construct()
6
- {
7
- parent::__construct();
8
- $this->setId('chronorelais_export_order_grid');
9
- $this->setUseAjax(false);
10
- $this->setDefaultSort('created_at');
11
- $this->setDefaultDir('DESC');
12
- $this->setSaveParametersInSession(true);
13
- }
14
-
15
- /**
16
- * Retrieve collection class
17
- *
18
- * @return string
19
- */
20
- protected function _getCollectionClass()
21
- {
22
- return 'sales/order_grid_collection';
23
- }
24
-
25
- protected function _prepareCollection()
26
- {
27
- $_chronopost_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronopost/deliver_on_saturday');
28
- $_chronorelais_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/deliver_on_saturday');
29
- if($_chronopost_deliver_saturday==1) { $_chronopost_deliver_saturday = 'Yes'; } else { $_chronopost_deliver_saturday = 'No';}
30
- if($_chronorelais_deliver_saturday==1) { $_chronorelais_deliver_saturday = 'Yes'; } else { $_chronorelais_deliver_saturday = 'No'; }
31
-
32
- $collection = Mage::getResourceModel($this->_getCollectionClass());
33
- $collection->join('order', 'main_table.entity_id = order.entity_id', 'shipping_description');
34
- $collection->join('order_payment', 'main_table.entity_id = order_payment.parent_id', 'method');
35
- $collection->getSelect()->joinLeft(array('oes' => Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status')), 'main_table.entity_id = oes.order_id', array("if(isNull(oes.livraison_le_samedi), CASE LOWER(SUBSTRING_INDEX(order.shipping_method,'_','1')) WHEN 'chronopost' THEN '$_chronopost_deliver_saturday' WHEN 'chronorelais' THEN '$_chronorelais_deliver_saturday' WHEN 'chronoexpress' THEN '--' ELSE 'No' END, oes.livraison_le_samedi) as livraison_le_samedi"));
36
- $collection->getSelect()->where('order.shipping_method LIKE "chronorelais%" OR order.shipping_method LIKE "chronopost%" OR order.shipping_method LIKE "chronoexpress%"');
37
-
38
- $this->setCollection($collection);
39
- return parent::_prepareCollection();
40
- }
41
-
42
- protected function _addColumnFilterToCollection($column)
43
- {
44
- if ($this->getCollection()) {
45
- $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
46
- if ($column->getFilterConditionCallback()) {
47
- call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
48
- } else {
49
- $cond = $column->getFilter()->getCondition();
50
- if ($field && isset($cond)) {
51
- // Le champ status est ambigu, il faut donc sp�cifier sa table lors de l'ajout pour filtrage
52
- $this->getCollection()->addFieldToFilter($field == "status" ? "main_table.status" : $field, $cond);
53
- }
54
- }
55
- }
56
- return $this;
57
- }
58
-
59
- protected function _prepareColumns()
60
- {
61
-
62
- $this->addColumn('real_order_id', array(
63
- 'header'=> Mage::helper('sales')->__('Order #'),
64
- 'width' => '80px',
65
- 'type' => 'text',
66
- 'index' => 'increment_id',
67
- 'filter' => false,
68
- ));
69
-
70
- if (!Mage::app()->isSingleStoreMode()) {
71
- $this->addColumn('store_id', array(
72
- 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
73
- 'index' => 'store_id',
74
- 'type' => 'store',
75
- 'store_view'=> true,
76
- 'display_deleted' => true,
77
- 'filter' => false,
78
- ));
79
- }
80
-
81
- $this->addColumn('created_at', array(
82
- 'header' => Mage::helper('sales')->__('Purchased On'),
83
- 'index' => 'created_at',
84
- 'type' => 'datetime',
85
- 'width' => '100px',
86
- 'filter' => false,
87
- ));
88
-
89
- $this->addColumn('billing_name', array(
90
- 'header' => Mage::helper('sales')->__('Bill to Name'),
91
- 'index' => 'billing_name',
92
- 'filter' => false,
93
- ));
94
-
95
- $this->addColumn('shipping_name', array(
96
- 'header' => Mage::helper('sales')->__('Ship to Name'),
97
- 'index' => 'shipping_name',
98
- 'filter' => false,
99
- ));
100
-
101
- $this->addColumn('base_grand_total', array(
102
- 'header' => Mage::helper('sales')->__('G.T. (Base)'),
103
- 'index' => 'base_grand_total',
104
- 'type' => 'currency',
105
- 'currency' => 'base_currency_code',
106
- 'filter' => false,
107
- ));
108
-
109
- $this->addColumn('grand_total', array(
110
- 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
111
- 'index' => 'grand_total',
112
- 'type' => 'currency',
113
- 'currency' => 'order_currency_code',
114
- 'filter' => false,
115
- ));
116
-
117
- $this->addColumn('shipping_description', array(
118
- 'header'=> Mage::helper('sales')->__('Shipping Method'),
119
- 'width' => '80px',
120
- 'type' => 'text',
121
- 'index' => 'shipping_description',
122
- 'filter' => false,
123
- 'truncate' => 30,
124
- 'escape' => true,
125
- ));
126
-
127
- $this->addColumn('payment', array(
128
- 'header' => Mage::helper('sales')->__('Mode de Paiement'),
129
- 'index' => 'method',
130
- 'width' => '100px',
131
- 'type' => 'text',
132
- 'filter' => false,
133
- ));
134
-
135
- if($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
136
- $this->addColumn('livraison_le_samedi', array(
137
- 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
138
- 'index' => 'livraison_le_samedi',
139
- 'width' => '100px',
140
- 'class' => 'a-center',
141
- 'filter' => false,
142
- ));
143
- }
144
-
145
- $this->addColumn('status', array(
146
- 'header' => Mage::helper('sales')->__('Status'),
147
- 'index' => 'status',
148
- 'type' => 'options',
149
- 'width' => '70px',
150
- 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
151
- ));
152
-
153
- if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
154
- $this->addColumn('action',
155
- array(
156
- 'header' => Mage::helper('sales')->__('Action'),
157
- 'width' => '50px',
158
- 'type' => 'action',
159
- 'getter' => 'getId',
160
- 'actions' => array(
161
- array(
162
- 'caption' => Mage::helper('sales')->__('View'),
163
- 'url' => array('base'=>'adminhtml/sales_order/view'),
164
- 'field' => 'order_id'
165
- )
166
- ),
167
- 'filter' => false,
168
- 'sortable' => false,
169
- 'index' => 'stores',
170
- 'is_system' => true,
171
- ));
172
- }
173
-
174
- return parent::_prepareColumns();
175
- }
176
-
177
- protected function _prepareMassaction111()
178
- {
179
- $this->setMassactionIdField('entity_id');
180
- $this->getMassactionBlock()->setFormFieldName('order_ids');
181
- $this->getMassactionBlock()->setUseSelectAll(false);
182
-
183
- $this->getMassactionBlock()->addItem('export_css', array(
184
- 'label'=> Mage::helper('chronorelais')->__('Export CSS'),
185
- 'url' => $this->getUrl('*/*/exportcss'),
186
- ));
187
- $this->getMassactionBlock()->addItem('export_cso', array(
188
- 'label'=> Mage::helper('chronorelais')->__('Export CSO'),
189
- 'url' => $this->getUrl('*/*/exportcso'),
190
- ));
191
-
192
- return $this;
193
- }
194
-
195
- protected function _prepareMassaction()
196
- {
197
- $this->setMassactionIdField('entity_id');
198
- $this->getMassactionBlock()->setFormFieldName('order_ids');
199
- $this->getMassactionBlock()->setUseSelectAll(false);
200
-
201
- if($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
202
- $shipping = array(
203
- 'Yes' => Mage::helper('chronorelais')->__('Yes'),
204
- 'No' => Mage::helper('chronorelais')->__('No'));
205
- $this->getMassactionBlock()->addItem('shipping', array(
206
- 'label' => Mage::helper('chronorelais')->__('Livraison le Samedi'),
207
- 'url' => $this->getUrl('*/*/massLivraisonSamediStatus', array('_current'=>true)),
208
- 'additional' => array(
209
- 'visibility' => array(
210
- 'name' => 'status',
211
- 'type' => 'select',
212
- 'class' => 'required-entry',
213
- 'style' => 'width:80px',
214
- 'label' => Mage::helper('chronorelais')->__('Status'),
215
- 'values' => $shipping
216
- )
217
- )
218
- ));
219
- }
220
-
221
- $export = array(
222
- 'css' => Mage::helper('chronorelais')->__('CSS Format'),
223
- 'cso' => Mage::helper('chronorelais')->__('CSO Format'));
224
- array_unshift($statuses, array('label'=>'', 'value'=>''));
225
- $this->getMassactionBlock()->addItem('export', array(
226
- 'label'=> Mage::helper('chronorelais')->__('Export'),
227
- 'url' => $this->getUrl('*/*/massExport', array('_current'=>true)),
228
- 'additional' => array(
229
- 'visibility' => array(
230
- 'name' => 'format',
231
- 'type' => 'select',
232
- 'class' => 'required-entry',
233
- 'label' => Mage::helper('chronorelais')->__('Format'),
234
- 'values' => $export
235
- )
236
- )
237
- ));
238
- return $this;
239
- }
240
-
241
- public function getRowUrl($row)
242
- {
243
- if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
244
- return $this->getUrl('adminhtml/sales_order/view', array('order_id' => $row->getId()));
245
- }
246
- return false;
247
- }
248
-
249
- public function getGridUrl()
250
- {
251
- return $this->getUrl('*/*/*', array('_current'=>true));
252
- }
253
-
254
- public function getAdditionalJavaScript()
255
- {
256
- echo "
257
- var element = document.getElementById('chronorelais_export_order_grid_massaction-select');
258
- element.selectedIndex = 1;
259
- if ('fireEvent' in element)
260
- element.fireEvent('onchange');
261
- else
262
- {
263
- var evt = document.createEvent('HTMLEvents');
264
- evt.initEvent('change', false, true);
265
- element.dispatchEvent(evt);
266
- }
267
- ";
268
- }
269
-
270
- }
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Export_Orders_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('chronorelais_export_order_grid');
9
+ $this->setUseAjax(false);
10
+ $this->setDefaultSort('created_at');
11
+ $this->setDefaultDir('DESC');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ /**
16
+ * Retrieve collection class
17
+ *
18
+ * @return string
19
+ */
20
+ protected function _getCollectionClass()
21
+ {
22
+ return 'sales/order_grid_collection';
23
+ }
24
+
25
+ protected function _prepareCollection()
26
+ {
27
+ $_chronopost_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronopost/deliver_on_saturday');
28
+ $_chronorelais_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/deliver_on_saturday');
29
+ if($_chronopost_deliver_saturday==1) { $_chronopost_deliver_saturday = 'Yes'; } else { $_chronopost_deliver_saturday = 'No';}
30
+ if($_chronorelais_deliver_saturday==1) { $_chronorelais_deliver_saturday = 'Yes'; } else { $_chronorelais_deliver_saturday = 'No'; }
31
+
32
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
33
+ $collection->join('order', 'main_table.entity_id = order.entity_id', 'shipping_description');
34
+ $collection->join('order_payment', 'main_table.entity_id = order_payment.parent_id', 'method');
35
+ $collection->getSelect()->joinLeft(array('oes' => Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status')), 'main_table.entity_id = oes.order_id', array("if(isNull(oes.livraison_le_samedi), CASE LOWER(SUBSTRING_INDEX(order.shipping_method,'_','1')) WHEN 'chronopost' THEN '$_chronopost_deliver_saturday' WHEN 'chronorelais' THEN '$_chronorelais_deliver_saturday' WHEN 'chronoexpress' THEN '--' ELSE 'No' END, oes.livraison_le_samedi) as livraison_le_samedi"));
36
+ $collection->getSelect()->where('order.shipping_method LIKE "chronorelais%" OR order.shipping_method LIKE "chronopost%" OR order.shipping_method LIKE "chronoexpress%"');
37
+
38
+ $this->setCollection($collection);
39
+ return parent::_prepareCollection();
40
+ }
41
+
42
+ protected function _addColumnFilterToCollection($column)
43
+ {
44
+ if ($this->getCollection()) {
45
+ $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
46
+ if ($column->getFilterConditionCallback()) {
47
+ call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
48
+ } else {
49
+ $cond = $column->getFilter()->getCondition();
50
+ if ($field && isset($cond)) {
51
+ // Le champ status est ambigu, il faut donc sp�cifier sa table lors de l'ajout pour filtrage
52
+ $this->getCollection()->addFieldToFilter($field == "status" ? "main_table.status" : $field, $cond);
53
+ }
54
+ }
55
+ }
56
+ return $this;
57
+ }
58
+
59
+ protected function _prepareColumns()
60
+ {
61
+
62
+ $this->addColumn('real_order_id', array(
63
+ 'header'=> Mage::helper('sales')->__('Order #'),
64
+ 'width' => '80px',
65
+ 'type' => 'text',
66
+ 'index' => 'increment_id',
67
+ 'filter' => false,
68
+ ));
69
+
70
+ if (!Mage::app()->isSingleStoreMode()) {
71
+ $this->addColumn('store_id', array(
72
+ 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
73
+ 'index' => 'store_id',
74
+ 'type' => 'store',
75
+ 'store_view'=> true,
76
+ 'display_deleted' => true,
77
+ 'filter' => false,
78
+ ));
79
+ }
80
+
81
+ $this->addColumn('created_at', array(
82
+ 'header' => Mage::helper('sales')->__('Purchased On'),
83
+ 'index' => 'created_at',
84
+ 'type' => 'datetime',
85
+ 'width' => '100px',
86
+ 'filter' => false,
87
+ ));
88
+
89
+ $this->addColumn('billing_name', array(
90
+ 'header' => Mage::helper('sales')->__('Bill to Name'),
91
+ 'index' => 'billing_name',
92
+ 'filter' => false,
93
+ ));
94
+
95
+ $this->addColumn('shipping_name', array(
96
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
97
+ 'index' => 'shipping_name',
98
+ 'filter' => false,
99
+ ));
100
+
101
+ $this->addColumn('base_grand_total', array(
102
+ 'header' => Mage::helper('sales')->__('G.T. (Base)'),
103
+ 'index' => 'base_grand_total',
104
+ 'type' => 'currency',
105
+ 'currency' => 'base_currency_code',
106
+ 'filter' => false,
107
+ ));
108
+
109
+ $this->addColumn('grand_total', array(
110
+ 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
111
+ 'index' => 'grand_total',
112
+ 'type' => 'currency',
113
+ 'currency' => 'order_currency_code',
114
+ 'filter' => false,
115
+ ));
116
+
117
+ $this->addColumn('shipping_description', array(
118
+ 'header'=> Mage::helper('sales')->__('Shipping Method'),
119
+ 'width' => '80px',
120
+ 'type' => 'text',
121
+ 'index' => 'shipping_description',
122
+ 'filter' => false,
123
+ 'truncate' => 30,
124
+ 'escape' => true,
125
+ ));
126
+
127
+ $this->addColumn('payment', array(
128
+ 'header' => Mage::helper('sales')->__('Mode de Paiement'),
129
+ 'index' => 'method',
130
+ 'width' => '100px',
131
+ 'type' => 'text',
132
+ 'filter' => false,
133
+ ));
134
+
135
+ if($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
136
+ $this->addColumn('livraison_le_samedi', array(
137
+ 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
138
+ 'index' => 'livraison_le_samedi',
139
+ 'width' => '100px',
140
+ 'class' => 'a-center',
141
+ 'filter' => false,
142
+ ));
143
+ }
144
+
145
+ $this->addColumn('status', array(
146
+ 'header' => Mage::helper('sales')->__('Status'),
147
+ 'index' => 'status',
148
+ 'type' => 'options',
149
+ 'width' => '70px',
150
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
151
+ ));
152
+
153
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
154
+ $this->addColumn('action',
155
+ array(
156
+ 'header' => Mage::helper('sales')->__('Action'),
157
+ 'width' => '50px',
158
+ 'type' => 'action',
159
+ 'getter' => 'getId',
160
+ 'actions' => array(
161
+ array(
162
+ 'caption' => Mage::helper('sales')->__('View'),
163
+ 'url' => array('base'=>'adminhtml/sales_order/view'),
164
+ 'field' => 'order_id'
165
+ )
166
+ ),
167
+ 'filter' => false,
168
+ 'sortable' => false,
169
+ 'index' => 'stores',
170
+ 'is_system' => true,
171
+ ));
172
+ }
173
+
174
+ return parent::_prepareColumns();
175
+ }
176
+
177
+ protected function _prepareMassaction111()
178
+ {
179
+ $this->setMassactionIdField('entity_id');
180
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
181
+ $this->getMassactionBlock()->setUseSelectAll(false);
182
+
183
+ $this->getMassactionBlock()->addItem('export_css', array(
184
+ 'label'=> Mage::helper('chronorelais')->__('Export CSS'),
185
+ 'url' => $this->getUrl('*/*/exportcss'),
186
+ ));
187
+ $this->getMassactionBlock()->addItem('export_cso', array(
188
+ 'label'=> Mage::helper('chronorelais')->__('Export CSO'),
189
+ 'url' => $this->getUrl('*/*/exportcso'),
190
+ ));
191
+
192
+ return $this;
193
+ }
194
+
195
+ protected function _prepareMassaction()
196
+ {
197
+ $this->setMassactionIdField('entity_id');
198
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
199
+ $this->getMassactionBlock()->setUseSelectAll(false);
200
+
201
+ if($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
202
+ $shipping = array(
203
+ 'Yes' => Mage::helper('chronorelais')->__('Yes'),
204
+ 'No' => Mage::helper('chronorelais')->__('No'));
205
+ $this->getMassactionBlock()->addItem('shipping', array(
206
+ 'label' => Mage::helper('chronorelais')->__('Livraison le Samedi'),
207
+ 'url' => $this->getUrl('*/*/massLivraisonSamediStatus', array('_current'=>true)),
208
+ 'additional' => array(
209
+ 'visibility' => array(
210
+ 'name' => 'status',
211
+ 'type' => 'select',
212
+ 'class' => 'required-entry',
213
+ 'style' => 'width:80px',
214
+ 'label' => Mage::helper('chronorelais')->__('Status'),
215
+ 'values' => $shipping
216
+ )
217
+ )
218
+ ));
219
+ }
220
+
221
+ $export = array(
222
+ 'css' => Mage::helper('chronorelais')->__('CSS Format'),
223
+ 'cso' => Mage::helper('chronorelais')->__('CSO Format'));
224
+ array_unshift($export, array('label'=>'', 'value'=>''));
225
+ $this->getMassactionBlock()->addItem('export', array(
226
+ 'label'=> Mage::helper('chronorelais')->__('Export'),
227
+ 'url' => $this->getUrl('*/*/massExport', array('_current'=>true)),
228
+ 'additional' => array(
229
+ 'visibility' => array(
230
+ 'name' => 'format',
231
+ 'type' => 'select',
232
+ 'class' => 'required-entry',
233
+ 'label' => Mage::helper('chronorelais')->__('Format'),
234
+ 'values' => $export
235
+ )
236
+ )
237
+ ));
238
+ return $this;
239
+ }
240
+
241
+ public function getRowUrl($row)
242
+ {
243
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
244
+ return $this->getUrl('adminhtml/sales_order/view', array('order_id' => $row->getId()));
245
+ }
246
+ return false;
247
+ }
248
+
249
+ public function getGridUrl()
250
+ {
251
+ return $this->getUrl('*/*/*', array('_current'=>true));
252
+ }
253
+
254
+ public function getAdditionalJavaScript()
255
+ {
256
+ echo "
257
+ var element = document.getElementById('chronorelais_export_order_grid_massaction-select');
258
+ element.selectedIndex = 1;
259
+ if ('fireEvent' in element)
260
+ element.fireEvent('onchange');
261
+ else
262
+ {
263
+ var evt = document.createEvent('HTMLEvents');
264
+ evt.initEvent('change', false, true);
265
+ element.dispatchEvent(evt);
266
+ }
267
+ ";
268
+ }
269
+
270
+ }
app/code/community/Chronopost/Chronorelais/Block/Sales/Bordereau/Grid.php CHANGED
@@ -1,160 +1,162 @@
1
- <?php
2
-
3
- class Chronopost_Chronorelais_Block_Sales_Bordereau_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
-
5
- public function __construct() {
6
- parent::__construct();
7
- $this->setTemplate('chronorelais/bordereau/grid.phtml'); /* Pour ajouter la phrase d'impression des bordereaux enxemplaires */
8
- $this->setId('sales_order_grid');
9
- $this->setDefaultSort('created_at');
10
- $this->setDefaultDir('DESC');
11
- }
12
-
13
- /**
14
- * Retrieve collection class
15
- *
16
- * @return string
17
- */
18
- protected function _getCollectionClass() {
19
- return 'sales/order_grid_collection';
20
- }
21
-
22
- protected function _prepareCollection() {
23
- $_chronopost_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronopost/deliver_on_saturday');
24
- $_chronorelais_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/deliver_on_saturday');
25
- if ($_chronopost_deliver_saturday == 1) {
26
- $_chronopost_deliver_saturday = 'Yes';
27
- } else {
28
- $_chronopost_deliver_saturday = 'No';
29
- }
30
- if ($_chronorelais_deliver_saturday == 1) {
31
- $_chronorelais_deliver_saturday = 'Yes';
32
- } else {
33
- $_chronorelais_deliver_saturday = 'No';
34
- }
35
-
36
- $collection = Mage::getResourceModel($this->_getCollectionClass());
37
- $collection->getSelect()->joinLeft(array('og' => $collection->getTable('sales/order')), 'main_table.entity_id = og.entity_id', array('CASE LOWER(SUBSTRING_INDEX(og.shipping_method,"_","1")) WHEN "chronoexpress" THEN "Chrono Express" WHEN "chronorelais" THEN "Chrono Relais" ELSE CONCAT(UCASE(SUBSTRING(SUBSTRING_INDEX(og.shipping_method,"_","1"),1,1)),LOWER(SUBSTRING(SUBSTRING_INDEX(og.shipping_method,"_","1"), 2))) END as chrono_shipping_method', 'og.total_qty_ordered'));
38
- $collection->getSelect()->joinLeft(array('osg' => $collection->getTable('sales/shipment_grid')), 'main_table.entity_id = osg.order_id', array('if(isNull(osg.increment_id) , "--" , GROUP_CONCAT(DISTINCT osg.increment_id SEPARATOR \', \')) as shipment_increment_id', 'GROUP_CONCAT(DISTINCT osg.created_at SEPARATOR \', \') as shipment_created_at'));
39
- $collection->getSelect()->joinLeft(array('ost' => $collection->getTable('sales/shipment_track')), 'main_table.entity_id = ost.order_id', array('if(isNull(ost.track_number) , "--" , GROUP_CONCAT(DISTINCT ost.track_number SEPARATOR \', \')) as track_number', 'if(isNull(ost.title) , "--" , GROUP_CONCAT(DISTINCT ost.title SEPARATOR \', \')) as title'));
40
- $collection->getSelect()->joinLeft(array('oes' => Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status')), 'main_table.entity_id = oes.order_id', array("if(isNull(oes.livraison_le_samedi), CASE LOWER(SUBSTRING_INDEX(og.shipping_method,'_','1')) WHEN 'chronopost' THEN '$_chronopost_deliver_saturday' WHEN 'chronorelais' THEN '$_chronorelais_deliver_saturday' WHEN 'chronoexpress' THEN '--' ELSE 'No' END, oes.livraison_le_samedi) as livraison_le_samedi"));
41
- $collection->getSelect()->where('og.shipping_method LIKE "chronorelais%" OR og.shipping_method LIKE "chronopost%" OR og.shipping_method LIKE "chronoexpress%"');
42
- $collection->getSelect()->group('main_table.entity_id');
43
- $sql = $collection->getSelectSql(true);
44
- $collection->getSelect()->reset()->from(
45
- array('e' => new Zend_Db_Expr("({$sql})")), array('e' => "*")
46
- );
47
-
48
- $this->setCollection($collection);
49
- return parent::_prepareCollection();
50
- }
51
-
52
- protected function _prepareColumns() {
53
-
54
- $this->addColumn('real_order_id', array(
55
- 'header' => Mage::helper('sales')->__('Order #'),
56
- 'width' => '100px',
57
- 'type' => 'text',
58
- 'index' => 'increment_id',
59
- 'filter' => false,
60
- ));
61
-
62
- $this->addColumn('created_at', array(
63
- 'header' => Mage::helper('sales')->__('Order Date'),
64
- 'index' => 'created_at',
65
- 'type' => 'datetime',
66
- 'filter' => false,
67
- ));
68
-
69
- $this->addColumn('shipment_increment_id', array(
70
- 'header' => Mage::helper('sales')->__('Shipment #'),
71
- 'index' => 'shipment_increment_id',
72
- 'type' => 'text',
73
- 'width' => '100px',
74
- 'filter' => false,
75
- ));
76
-
77
- $this->addColumn('shipment_created_at', array(
78
- 'header' => Mage::helper('sales')->__('Date Shipped'),
79
- 'index' => 'shipment_created_at',
80
- 'type' => 'datetime',
81
- 'filter' => false,
82
- ));
83
-
84
- $this->addColumn('shipping_name', array(
85
- 'header' => Mage::helper('sales')->__('Ship to Name'),
86
- 'index' => 'shipping_name',
87
- 'filter' => false,
88
- ));
89
-
90
- $this->addColumn('total_qty_ordered', array(
91
- 'header' => Mage::helper('sales')->__('Total Qty'),
92
- 'index' => 'total_qty_ordered',
93
- 'type' => 'number',
94
- 'filter' => false,
95
- ));
96
-
97
- $this->addColumn('track_number', array(
98
- 'header' => Mage::helper('sales')->__('Tracking'),
99
- 'index' => 'track_number',
100
- 'filter' => false,
101
- ));
102
-
103
- $this->addColumn('chrono_shipping_method', array(
104
- 'header' => Mage::helper('sales')->__('Mode de transport'),
105
- 'index' => 'chrono_shipping_method',
106
- 'type' => 'text',
107
- 'filter' => false,
108
- ));
109
-
110
- $this->addColumn('status', array(
111
- 'header' => Mage::helper('sales')->__('Status'),
112
- 'index' => 'status',
113
- 'type' => 'options',
114
- 'width' => '90px',
115
- 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
116
- ));
117
-
118
- if ($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
119
- $this->addColumn('livraison_le_samedi', array(
120
- 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
121
- 'index' => 'livraison_le_samedi',
122
- 'width' => '100px',
123
- 'class' => 'a-center',
124
- 'filter' => false,
125
- ));
126
- }
127
-
128
- return parent::_prepareColumns();
129
- }
130
-
131
- public function getRowUrl($row) {
132
- if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/shipment')) {
133
- return false;
134
- }
135
-
136
- return $this->getUrl('adminhtml/sales_order/view', array(
137
- 'order_id' => $row->getId(),
138
- )
139
- );
140
- }
141
-
142
- protected function _prepareMassaction() {
143
-
144
- $this->setMassactionIdField('entity_id');
145
- $this->getMassactionBlock()->setFormFieldName('order_ids');
146
- $this->getMassactionBlock()->setUseSelectAll(false);
147
-
148
- $this->getMassactionBlock()->addItem('print_bordereau', array(
149
- 'label' => Mage::helper('chronorelais')->__('Imprimer le bordereau'),
150
- 'url' => $this->getUrl('*/*/massPrintBordereau', array('_current' => true)),
151
- 'selected' => true,
152
- ));
153
-
154
- return $this;
155
- }
156
-
157
- public function getGridUrl() {
158
- return $this->getUrl('*/*/*', array('_current' => true));
159
- }
 
 
160
  }
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Block_Sales_Bordereau_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setTemplate('chronorelais/bordereau/grid.phtml'); /* Pour ajouter la phrase d'impression des bordereaux enxemplaires */
8
+ $this->setId('sales_order_grid');
9
+ $this->setDefaultSort('created_at');
10
+ $this->setDefaultDir('DESC');
11
+ }
12
+
13
+ /**
14
+ * Retrieve collection class
15
+ *
16
+ * @return string
17
+ */
18
+ protected function _getCollectionClass() {
19
+ return 'sales/order_grid_collection';
20
+ }
21
+
22
+ protected function _prepareCollection() {
23
+ $_chronopost_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronopost/deliver_on_saturday');
24
+ $_chronorelais_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/deliver_on_saturday');
25
+ if ($_chronopost_deliver_saturday == 1) {
26
+ $_chronopost_deliver_saturday = 'Yes';
27
+ } else {
28
+ $_chronopost_deliver_saturday = 'No';
29
+ }
30
+ if ($_chronorelais_deliver_saturday == 1) {
31
+ $_chronorelais_deliver_saturday = 'Yes';
32
+ } else {
33
+ $_chronorelais_deliver_saturday = 'No';
34
+ }
35
+
36
+ $trackNumberFieldName = Mage::helper('chronorelais')->getTrackNumberFieldName();
37
+
38
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
39
+ $collection->getSelect()->joinLeft(array('og' => $collection->getTable('sales/order')), 'main_table.entity_id = og.entity_id', array('CASE LOWER(SUBSTRING_INDEX(og.shipping_method,"_","1")) WHEN "chronoexpress" THEN "Chrono Express" WHEN "chronorelais" THEN "Chrono Relais" ELSE CONCAT(UCASE(SUBSTRING(SUBSTRING_INDEX(og.shipping_method,"_","1"),1,1)),LOWER(SUBSTRING(SUBSTRING_INDEX(og.shipping_method,"_","1"), 2))) END as chrono_shipping_method', 'og.total_qty_ordered'));
40
+ $collection->getSelect()->joinLeft(array('osg' => $collection->getTable('sales/shipment_grid')), 'main_table.entity_id = osg.order_id', array('if(isNull(osg.increment_id) , "--" , GROUP_CONCAT(DISTINCT osg.increment_id SEPARATOR \', \')) as shipment_increment_id', 'GROUP_CONCAT(DISTINCT osg.created_at SEPARATOR \', \') as shipment_created_at'));
41
+ $collection->getSelect()->joinLeft(array('ost' => $collection->getTable('sales/shipment_track')), 'main_table.entity_id = ost.order_id', array('if(isNull(ost.'.$trackNumberFieldName.') , "--" , GROUP_CONCAT(DISTINCT ost.'.$trackNumberFieldName.' SEPARATOR \', \')) as track_number', 'if(isNull(ost.title) , "--" , GROUP_CONCAT(DISTINCT ost.title SEPARATOR \', \')) as title'));
42
+ $collection->getSelect()->joinLeft(array('oes' => Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status')), 'main_table.entity_id = oes.order_id', array("if(isNull(oes.livraison_le_samedi), CASE LOWER(SUBSTRING_INDEX(og.shipping_method,'_','1')) WHEN 'chronopost' THEN '$_chronopost_deliver_saturday' WHEN 'chronorelais' THEN '$_chronorelais_deliver_saturday' WHEN 'chronoexpress' THEN '--' ELSE 'No' END, oes.livraison_le_samedi) as livraison_le_samedi"));
43
+ $collection->getSelect()->where('og.shipping_method LIKE "chronorelais%" OR og.shipping_method LIKE "chronopost%" OR og.shipping_method LIKE "chronoexpress%"');
44
+ $collection->getSelect()->group('main_table.entity_id');
45
+ $sql = $collection->getSelectSql(true);
46
+ $collection->getSelect()->reset()->from(
47
+ array('e' => new Zend_Db_Expr("({$sql})")), array('e' => "*")
48
+ );
49
+
50
+ $this->setCollection($collection);
51
+ return parent::_prepareCollection();
52
+ }
53
+
54
+ protected function _prepareColumns() {
55
+
56
+ $this->addColumn('real_order_id', array(
57
+ 'header' => Mage::helper('sales')->__('Order #'),
58
+ 'width' => '100px',
59
+ 'type' => 'text',
60
+ 'index' => 'increment_id',
61
+ 'filter' => false,
62
+ ));
63
+
64
+ $this->addColumn('created_at', array(
65
+ 'header' => Mage::helper('sales')->__('Order Date'),
66
+ 'index' => 'created_at',
67
+ 'type' => 'datetime',
68
+ 'filter' => false,
69
+ ));
70
+
71
+ $this->addColumn('shipment_increment_id', array(
72
+ 'header' => Mage::helper('sales')->__('Shipment #'),
73
+ 'index' => 'shipment_increment_id',
74
+ 'type' => 'text',
75
+ 'width' => '100px',
76
+ 'filter' => false,
77
+ ));
78
+
79
+ $this->addColumn('shipment_created_at', array(
80
+ 'header' => Mage::helper('sales')->__('Date Shipped'),
81
+ 'index' => 'shipment_created_at',
82
+ 'type' => 'datetime',
83
+ 'filter' => false,
84
+ ));
85
+
86
+ $this->addColumn('shipping_name', array(
87
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
88
+ 'index' => 'shipping_name',
89
+ 'filter' => false,
90
+ ));
91
+
92
+ $this->addColumn('total_qty_ordered', array(
93
+ 'header' => Mage::helper('sales')->__('Total Qty'),
94
+ 'index' => 'total_qty_ordered',
95
+ 'type' => 'number',
96
+ 'filter' => false,
97
+ ));
98
+
99
+ $this->addColumn('track_number', array(
100
+ 'header' => Mage::helper('sales')->__('Tracking'),
101
+ 'index' => 'track_number',
102
+ 'filter' => false,
103
+ ));
104
+
105
+ $this->addColumn('chrono_shipping_method', array(
106
+ 'header' => Mage::helper('sales')->__('Mode de transport'),
107
+ 'index' => 'chrono_shipping_method',
108
+ 'type' => 'text',
109
+ 'filter' => false,
110
+ ));
111
+
112
+ $this->addColumn('status', array(
113
+ 'header' => Mage::helper('sales')->__('Status'),
114
+ 'index' => 'status',
115
+ 'type' => 'options',
116
+ 'width' => '90px',
117
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
118
+ ));
119
+
120
+ if ($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
121
+ $this->addColumn('livraison_le_samedi', array(
122
+ 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
123
+ 'index' => 'livraison_le_samedi',
124
+ 'width' => '100px',
125
+ 'class' => 'a-center',
126
+ 'filter' => false,
127
+ ));
128
+ }
129
+
130
+ return parent::_prepareColumns();
131
+ }
132
+
133
+ public function getRowUrl($row) {
134
+ if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/shipment')) {
135
+ return false;
136
+ }
137
+
138
+ return $this->getUrl('adminhtml/sales_order/view', array(
139
+ 'order_id' => $row->getId(),
140
+ )
141
+ );
142
+ }
143
+
144
+ protected function _prepareMassaction() {
145
+
146
+ $this->setMassactionIdField('entity_id');
147
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
148
+ $this->getMassactionBlock()->setUseSelectAll(false);
149
+
150
+ $this->getMassactionBlock()->addItem('print_bordereau', array(
151
+ 'label' => Mage::helper('chronorelais')->__('Imprimer le bordereau'),
152
+ 'url' => $this->getUrl('*/*/massPrintBordereau', array('_current' => true)),
153
+ 'selected' => true,
154
+ ));
155
+
156
+ return $this;
157
+ }
158
+
159
+ public function getGridUrl() {
160
+ return $this->getUrl('*/*/*', array('_current' => true));
161
+ }
162
  }
app/code/community/Chronopost/Chronorelais/Block/Sales/Order/Shipment/View.php CHANGED
@@ -1,99 +1,28 @@
1
- <?php
2
- class Chronopost_Chronorelais_Block_Sales_Order_Shipment_View extends Mage_Adminhtml_Block_Widget_Form_Container
3
- {
4
-
5
- public function __construct()
6
- {
7
- $this->_objectId = 'shipment_id';
8
- $this->_controller = 'sales_order_shipment';
9
- $this->_mode = 'view';
10
-
11
- parent::__construct();
12
-
13
- $this->_removeButton('reset');
14
- $this->_removeButton('delete');
15
- $this->_updateButton('save', 'label', Mage::helper('sales')->__('Send Tracking Information'));
16
- $this->_updateButton('save', 'onclick', "setLocation('".$this->getEmailUrl()."')");
17
-
18
- //Ajout de l'impression de l'étiquette
19
- $_order = $this->getShipment()->getOrder();
20
- $_shippingMethod = explode("_",$_order->getShippingMethod());
21
- if (($_shippingMethod[0] == 'chronorelais' || $_shippingMethod[0] == 'chronopost' || $_shippingMethod[0] == 'chronoexpress')) {
22
- $this->_addButton('etiquette', array(
23
- 'label' => Mage::helper('chronorelais')->__('Etiquette Chronopost'),
24
- 'class' => 'save',
25
- 'onclick' => 'setLocation(\'' . $this->getPrintMondialRelayUrl() . '\')'
26
- )
27
- );
28
- }
29
-
30
- if ($this->getShipment()->getId()) {
31
- $this->_addButton('print', array(
32
- 'label' => Mage::helper('sales')->__('Print'),
33
- 'class' => 'save',
34
- 'onclick' => 'setLocation(\''.$this->getPrintUrl().'\')'
35
- )
36
- );
37
- }
38
- }
39
-
40
- /**
41
- * Retrieve shipment model instance
42
- *
43
- * @return Mage_Sales_Model_Order_Shipment
44
- */
45
- public function getShipment()
46
- {
47
- return Mage::registry('current_shipment');
48
- }
49
-
50
- public function getHeaderText()
51
- {
52
- if ($this->getShipment()->getEmailSent()) {
53
- $emailSent = Mage::helper('sales')->__('Shipment email sent');
54
- }
55
- else {
56
- $emailSent = Mage::helper('sales')->__('Shipment email not sent');
57
- }
58
-
59
- $header = Mage::helper('sales')->__('Shipment #%s (%s)', $this->getShipment()->getIncrementId(), $emailSent);
60
- return $header;
61
- }
62
-
63
- public function getBackUrl()
64
- {
65
- return $this->getUrl(
66
- '*/sales_order/view',
67
- array(
68
- 'order_id' => $this->getShipment()->getOrderId(),
69
- 'active_tab'=> 'order_shipments'
70
- ));
71
- }
72
-
73
- public function getEmailUrl()
74
- {
75
- return $this->getUrl('*/sales_order_shipment/email', array('shipment_id' => $this->getShipment()->getId()));
76
- }
77
-
78
- public function getPrintUrl()
79
- {
80
- return $this->getUrl('*/*/print', array(
81
- 'invoice_id' => $this->getShipment()->getId()
82
- ));
83
- }
84
-
85
- public function getPrintMondialRelayUrl()
86
- {
87
- return $this->getUrl('chronorelais/sales_impression/print', array(
88
- 'shipment_id' => $this->getShipment()->getId()
89
- ));
90
- }
91
-
92
- public function updateBackButtonUrl($flag)
93
- {
94
- if ($flag) {
95
- return $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/sales_shipment/') . '\')');
96
- }
97
- return $this;
98
- }
99
  }
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Sales_Order_Shipment_View extends Mage_Adminhtml_Block_Sales_Order_Shipment_View
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ //Ajout de l'impression de l'étiquette Chronopost
10
+ $_order = $this->getShipment()->getOrder();
11
+ $_shippingMethod = explode("_",$_order->getShippingMethod());
12
+ if (($_shippingMethod[0] == 'chronorelais' || $_shippingMethod[0] == 'chronopost' || $_shippingMethod[0] == 'chronoexpress')) {
13
+ $this->_addButton('etiquette', array(
14
+ 'label' => Mage::helper('chronorelais')->__('Etiquette Chronopost'),
15
+ 'class' => 'save',
16
+ 'onclick' => 'setLocation(\'' . $this->getPrintChronopostUrl() . '\')'
17
+ )
18
+ );
19
+ }
20
+ }
21
+
22
+ public function getPrintChronopostUrl()
23
+ {
24
+ return $this->getUrl('chronorelais/sales_impression/print', array(
25
+ 'shipment_id' => $this->getShipment()->getId()
26
+ ));
27
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  }
app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid.php CHANGED
@@ -1,252 +1,254 @@
1
- <?php
2
-
3
- class Chronopost_Chronorelais_Block_Sales_Shipment_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
-
5
- public function __construct() {
6
- parent::__construct();
7
- $this->setId('sales_order_grid');
8
- $this->setDefaultSort('created_at');
9
- $this->setDefaultDir('DESC');
10
- }
11
-
12
- /**
13
- * Retrieve collection class
14
- *
15
- * @return string
16
- */
17
- protected function _getCollectionClass() {
18
- return 'sales/order_grid_collection';
19
- }
20
-
21
- protected function _prepareCollection() {
22
- $_chronopost_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronopost/deliver_on_saturday');
23
- $_chronorelais_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/deliver_on_saturday');
24
- if ($_chronopost_deliver_saturday == 1) {
25
- $_chronopost_deliver_saturday = 'Yes';
26
- } else {
27
- $_chronopost_deliver_saturday = 'No';
28
- }
29
- if ($_chronorelais_deliver_saturday == 1) {
30
- $_chronorelais_deliver_saturday = 'Yes';
31
- } else {
32
- $_chronorelais_deliver_saturday = 'No';
33
- }
34
-
35
- $collection = Mage::getResourceModel($this->_getCollectionClass());
36
- $collection->getSelect()->joinLeft(array('og' => $collection->getTable('sales/order')), 'main_table.entity_id = og.entity_id', array('CASE LOWER(SUBSTRING_INDEX(og.shipping_method,"_","1")) WHEN "chronoexpress" THEN "Chrono Express" WHEN "chronorelais" THEN "Chrono Relais" ELSE CONCAT(UCASE(SUBSTRING(SUBSTRING_INDEX(og.shipping_method,"_","1"),1,1)),LOWER(SUBSTRING(SUBSTRING_INDEX(og.shipping_method,"_","1"), 2))) END as chrono_shipping_method', 'og.total_qty_ordered'));
37
- $collection->getSelect()->joinLeft(array('osg' => $collection->getTable('sales/shipment_grid')), 'main_table.entity_id = osg.order_id', array('if(isNull(osg.increment_id) , "--" , GROUP_CONCAT(DISTINCT osg.increment_id SEPARATOR \', \')) as shipment_increment_id', 'GROUP_CONCAT(DISTINCT osg.created_at SEPARATOR \', \') as shipment_created_at'));
38
- $collection->getSelect()->joinLeft(array('ost' => $collection->getTable('sales/shipment_track')), 'main_table.entity_id = ost.order_id', array('if(isNull(ost.track_number) , "--" , GROUP_CONCAT(DISTINCT ost.track_number SEPARATOR \', \')) as track_number', 'if(isNull(ost.title) , "--" , GROUP_CONCAT(DISTINCT ost.title SEPARATOR \', \')) as title'));
39
- $collection->getSelect()->joinLeft(array('oes' => Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status')), 'main_table.entity_id = oes.order_id', array("if(isNull(oes.livraison_le_samedi), CASE LOWER(SUBSTRING_INDEX(og.shipping_method,'_','1')) WHEN 'chronopost' THEN '$_chronopost_deliver_saturday' WHEN 'chronorelais' THEN '$_chronorelais_deliver_saturday' WHEN 'chronoexpress' THEN '--' ELSE 'No' END, oes.livraison_le_samedi) as livraison_le_samedi"));
40
- $collection->getSelect()->where('og.shipping_method LIKE "chronorelais%" OR og.shipping_method LIKE "chronopost%" OR og.shipping_method LIKE "chronoexpress%"');
41
- $collection->getSelect()->group('main_table.entity_id');
42
- $sql = $collection->getSelectSql(true);
43
- $collection->getSelect()->reset()->from(
44
- array('e' => new Zend_Db_Expr("({$sql})")), array('e' => "*")
45
- );
46
-
47
- $this->setCollection($collection);
48
- return parent::_prepareCollection();
49
- }
50
-
51
- protected function _prepareColumns() {
52
-
53
- $this->addColumn('real_order_id', array(
54
- 'header' => Mage::helper('sales')->__('Order #'),
55
- 'width' => '100px',
56
- 'type' => 'text',
57
- 'index' => 'increment_id',
58
- 'filter' => false,
59
- ));
60
-
61
- $this->addColumn('created_at', array(
62
- 'header' => Mage::helper('sales')->__('Order Date'),
63
- 'index' => 'created_at',
64
- 'type' => 'datetime',
65
- 'filter' => false,
66
- ));
67
-
68
- $this->addColumn('shipment_increment_id', array(
69
- 'header' => Mage::helper('sales')->__('Shipment #'),
70
- 'index' => 'shipment_increment_id',
71
- 'type' => 'text',
72
- 'width' => '100px',
73
- 'filter' => false,
74
- 'column_css_class' => 'shipment_ids'
75
- ));
76
-
77
- $this->addColumn('shipment_created_at', array(
78
- 'header' => Mage::helper('sales')->__('Date Shipped'),
79
- 'index' => 'shipment_created_at',
80
- 'type' => 'datetime',
81
- 'filter' => false,
82
- ));
83
-
84
- $this->addColumn('shipping_name', array(
85
- 'header' => Mage::helper('sales')->__('Ship to Name'),
86
- 'index' => 'shipping_name',
87
- 'filter' => false,
88
- ));
89
-
90
- $this->addColumn('total_qty_ordered', array(
91
- 'header' => Mage::helper('sales')->__('Total Qty'),
92
- 'index' => 'total_qty_ordered',
93
- 'type' => 'number',
94
- 'filter' => false,
95
- ));
96
-
97
- $this->addColumn('track_number', array(
98
- 'header' => Mage::helper('sales')->__('Tracking'),
99
- 'index' => 'track_number',
100
- 'filter' => false,
101
- ));
102
-
103
- $this->addColumn('chrono_shipping_method', array(
104
- 'header' => Mage::helper('sales')->__('Mode de transport'),
105
- 'index' => 'chrono_shipping_method',
106
- 'type' => 'text',
107
- 'filter' => false,
108
- ));
109
-
110
- if ($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
111
- $this->addColumn('livraison_le_samedi', array(
112
- 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
113
- 'index' => 'livraison_le_samedi',
114
- 'width' => '100px',
115
- 'class' => 'a-center',
116
- 'filter' => false,
117
- ));
118
- }
119
-
120
- $this->addColumn('etiquette_expedition', array(
121
- 'header' => Mage::helper('chronorelais')->__('Impression étiquette expédition'),
122
- 'type' => 'action',
123
- 'getter' => 'getId',
124
- 'column_css_class' => 'etiquette_expedition',
125
- 'actions' => array(
126
- array(
127
- 'caption' => Mage::helper('chronorelais')->__('Expédition'),
128
- 'url' => array(
129
- 'base' => 'chronorelais/sales_impression/print'
130
- ),
131
- 'field' => 'order_id'
132
- )
133
- ),
134
- 'filter' => false,
135
- 'sortable' => false,
136
- 'index' => 'stores'
137
- ));
138
-
139
- $this->addColumn('etiquette_retour', array(
140
- 'header' => Mage::helper('chronorelais')->__('Impression étiquette retour'),
141
- 'type' => 'action',
142
- 'getter' => 'getId',
143
- 'column_css_class' => 'etiquette_retour',
144
- 'actions' => array(
145
- array(
146
- 'caption' => Mage::helper('chronorelais')->__('Retour SAV'),
147
- 'url' => array(
148
- 'base' => 'chronorelais/sales_impression/printEtiquetteRetour'
149
- ),
150
- 'field' => 'order_id'
151
- )
152
- ),
153
- 'filter' => false,
154
- 'renderer' => 'Chronopost_Chronorelais_Block_Sales_Shipment_Grid_Renderer_Retoursav',
155
- 'sortable' => false,
156
- 'index' => 'stores'
157
- ));
158
-
159
- return parent::_prepareColumns();
160
- }
161
-
162
- public function getRowUrl($row) {
163
- if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/shipment')) {
164
- return false;
165
- }
166
-
167
- return $this->getUrl('adminhtml/sales_order/view', array(
168
- 'order_id' => $row->getId(),
169
- )
170
- );
171
- }
172
-
173
- protected function _prepareMassaction() {
174
-
175
- $this->setMassactionIdField('entity_id');
176
- $this->getMassactionBlock()->setFormFieldName('order_ids');
177
- $this->getMassactionBlock()->setUseSelectAll(false);
178
-
179
- $cmd = Mage::helper('chronorelais')->getConfigData('chronorelais/shipping/gs_path');
180
- $res_shell = shell_exec($cmd);
181
- if($res_shell !== null) {
182
- $this->getMassactionBlock()->addItem('print', array(
183
- 'label' => Mage::helper('chronorelais')->__('Imprimer les étiquettes'),
184
- 'url' => $this->getUrl('*/*/printMass', array('_current' => true)),
185
- ));
186
- }
187
-
188
- if ($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
189
-
190
- $shipping = array(
191
- 'Yes' => Mage::helper('chronorelais')->__('Yes'),
192
- 'No' => Mage::helper('chronorelais')->__('No'));
193
- $this->getMassactionBlock()->addItem('shipping', array(
194
- 'label' => Mage::helper('chronorelais')->__('Livraison le Samedi'),
195
- 'url' => $this->getUrl('*/*/massLivraisonSamediStatus', array('_current' => true)),
196
- 'additional' => array(
197
- 'visibility' => array(
198
- 'name' => 'status',
199
- 'type' => 'select',
200
- 'class' => 'required-entry',
201
- 'style' => 'width:80px',
202
- 'label' => Mage::helper('chronorelais')->__('Status'),
203
- 'values' => $shipping
204
- )
205
- )
206
- ));
207
- }
208
- return $this;
209
- }
210
-
211
- public function getGridUrl() {
212
- return $this->getUrl('*/*/*', array('_current' => true));
213
- }
214
-
215
- public function getAdditionalJavaScript() {
216
- echo "
217
- var tds = $$('#sales_order_grid_table tr td.shipment_ids');
218
- tds.each(function(item) {
219
- var chaine = item.innerHTML.replace(/^\s+/g,'').replace(/\s+$/g,'');
220
- var lienExpedition = $(item).next('.etiquette_expedition').down('a');
221
- var lienRetour = $(item).next('.etiquette_retour').down('a');
222
- if (chaine.split(', ').length > 1) {
223
- var contentExpedition = '';
224
- var contentRetour = '';
225
- var numbers = chaine.split(', ');
226
- for (var i=0; i<numbers.length; i++) {
227
- contentExpedition += '<a href=\"' + lienExpedition.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + numbers[i] + '/') + '\">Exp&eacute;dition ' + numbers[i] + '</a><br />';
228
- contentRetour += '<a href=\"' + lienRetour.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + numbers[i] + '/') + '\" >Retour SAV ' + numbers[i] + '</a><br />';
229
- }
230
- lienExpedition.up().innerHTML = contentExpedition;
231
- if(typeof lienRetour !== 'undefined')
232
- {
233
- lienRetour.up().innerHTML = contentRetour;
234
- }
235
- }
236
- else if(chaine.length > 2) {
237
- lienExpedition.up().innerHTML = '<a href=\"' + lienExpedition.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + chaine + '/') + '\">Exp&eacute;dition</a><br />';
238
- if(typeof lienRetour !== 'undefined')
239
- {
240
- lienRetour.up().innerHTML = '<a href=\"' + lienRetour.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + chaine + '/') + '\" >Retour SAV</a><br />';
241
- }
242
- }
243
- else {
244
- if(typeof lienRetour !== 'undefined')
245
- {
246
- lienRetour.up().innerHTML = '';
247
- }
248
- }
249
- });";
250
- }
251
-
252
- }
 
 
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Block_Sales_Shipment_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('sales_order_grid');
8
+ $this->setDefaultSort('created_at');
9
+ $this->setDefaultDir('DESC');
10
+ }
11
+
12
+ /**
13
+ * Retrieve collection class
14
+ *
15
+ * @return string
16
+ */
17
+ protected function _getCollectionClass() {
18
+ return 'sales/order_grid_collection';
19
+ }
20
+
21
+ protected function _prepareCollection() {
22
+ $_chronopost_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronopost/deliver_on_saturday');
23
+ $_chronorelais_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/deliver_on_saturday');
24
+ if ($_chronopost_deliver_saturday == 1) {
25
+ $_chronopost_deliver_saturday = 'Yes';
26
+ } else {
27
+ $_chronopost_deliver_saturday = 'No';
28
+ }
29
+ if ($_chronorelais_deliver_saturday == 1) {
30
+ $_chronorelais_deliver_saturday = 'Yes';
31
+ } else {
32
+ $_chronorelais_deliver_saturday = 'No';
33
+ }
34
+
35
+ $trackNumberFieldName = Mage::helper('chronorelais')->getTrackNumberFieldName();
36
+
37
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
38
+ $collection->getSelect()->joinLeft(array('og' => $collection->getTable('sales/order')), 'main_table.entity_id = og.entity_id', array('CASE LOWER(SUBSTRING_INDEX(og.shipping_method,"_","1")) WHEN "chronoexpress" THEN "Chrono Express" WHEN "chronorelais" THEN "Chrono Relais" ELSE CONCAT(UCASE(SUBSTRING(SUBSTRING_INDEX(og.shipping_method,"_","1"),1,1)),LOWER(SUBSTRING(SUBSTRING_INDEX(og.shipping_method,"_","1"), 2))) END as chrono_shipping_method', 'og.total_qty_ordered'));
39
+ $collection->getSelect()->joinLeft(array('osg' => $collection->getTable('sales/shipment_grid')), 'main_table.entity_id = osg.order_id', array('if(isNull(osg.increment_id) , "--" , GROUP_CONCAT(DISTINCT osg.increment_id SEPARATOR \', \')) as shipment_increment_id', 'GROUP_CONCAT(DISTINCT osg.created_at SEPARATOR \', \') as shipment_created_at'));
40
+ $collection->getSelect()->joinLeft(array('ost' => $collection->getTable('sales/shipment_track')), 'main_table.entity_id = ost.order_id', array('if(isNull(ost.'.$trackNumberFieldName.') , "--" , GROUP_CONCAT(DISTINCT ost.'.$trackNumberFieldName.' SEPARATOR \', \')) as track_number', 'if(isNull(ost.title) , "--" , GROUP_CONCAT(DISTINCT ost.title SEPARATOR \', \')) as title'));
41
+ $collection->getSelect()->joinLeft(array('oes' => Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status')), 'main_table.entity_id = oes.order_id', array("if(isNull(oes.livraison_le_samedi), CASE LOWER(SUBSTRING_INDEX(og.shipping_method,'_','1')) WHEN 'chronopost' THEN '$_chronopost_deliver_saturday' WHEN 'chronorelais' THEN '$_chronorelais_deliver_saturday' WHEN 'chronoexpress' THEN '--' ELSE 'No' END, oes.livraison_le_samedi) as livraison_le_samedi"));
42
+ $collection->getSelect()->where('og.shipping_method LIKE "chronorelais%" OR og.shipping_method LIKE "chronopost%" OR og.shipping_method LIKE "chronoexpress%"');
43
+ $collection->getSelect()->group('main_table.entity_id');
44
+ $sql = $collection->getSelectSql(true);
45
+ $collection->getSelect()->reset()->from(
46
+ array('e' => new Zend_Db_Expr("({$sql})")), array('e' => "*")
47
+ );
48
+
49
+ $this->setCollection($collection);
50
+ return parent::_prepareCollection();
51
+ }
52
+
53
+ protected function _prepareColumns() {
54
+
55
+ $this->addColumn('real_order_id', array(
56
+ 'header' => Mage::helper('sales')->__('Order #'),
57
+ 'width' => '100px',
58
+ 'type' => 'text',
59
+ 'index' => 'increment_id',
60
+ 'filter' => false,
61
+ ));
62
+
63
+ $this->addColumn('created_at', array(
64
+ 'header' => Mage::helper('sales')->__('Order Date'),
65
+ 'index' => 'created_at',
66
+ 'type' => 'datetime',
67
+ 'filter' => false,
68
+ ));
69
+
70
+ $this->addColumn('shipment_increment_id', array(
71
+ 'header' => Mage::helper('sales')->__('Shipment #'),
72
+ 'index' => 'shipment_increment_id',
73
+ 'type' => 'text',
74
+ 'width' => '100px',
75
+ 'filter' => false,
76
+ 'column_css_class' => 'shipment_ids'
77
+ ));
78
+
79
+ $this->addColumn('shipment_created_at', array(
80
+ 'header' => Mage::helper('sales')->__('Date Shipped'),
81
+ 'index' => 'shipment_created_at',
82
+ 'type' => 'datetime',
83
+ 'filter' => false,
84
+ ));
85
+
86
+ $this->addColumn('shipping_name', array(
87
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
88
+ 'index' => 'shipping_name',
89
+ 'filter' => false,
90
+ ));
91
+
92
+ $this->addColumn('total_qty_ordered', array(
93
+ 'header' => Mage::helper('sales')->__('Total Qty'),
94
+ 'index' => 'total_qty_ordered',
95
+ 'type' => 'number',
96
+ 'filter' => false,
97
+ ));
98
+
99
+ $this->addColumn('track_number', array(
100
+ 'header' => Mage::helper('sales')->__('Tracking'),
101
+ 'index' => 'track_number',
102
+ 'filter' => false,
103
+ ));
104
+
105
+ $this->addColumn('chrono_shipping_method', array(
106
+ 'header' => Mage::helper('sales')->__('Mode de transport'),
107
+ 'index' => 'chrono_shipping_method',
108
+ 'type' => 'text',
109
+ 'filter' => false,
110
+ ));
111
+
112
+ if ($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
113
+ $this->addColumn('livraison_le_samedi', array(
114
+ 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
115
+ 'index' => 'livraison_le_samedi',
116
+ 'width' => '100px',
117
+ 'class' => 'a-center',
118
+ 'filter' => false,
119
+ ));
120
+ }
121
+
122
+ $this->addColumn('etiquette_expedition', array(
123
+ 'header' => Mage::helper('chronorelais')->__('Impression étiquette expédition'),
124
+ 'type' => 'action',
125
+ 'getter' => 'getId',
126
+ 'column_css_class' => 'etiquette_expedition',
127
+ 'actions' => array(
128
+ array(
129
+ 'caption' => Mage::helper('chronorelais')->__('Expédition'),
130
+ 'url' => array(
131
+ 'base' => 'chronorelais/sales_impression/print'
132
+ ),
133
+ 'field' => 'order_id'
134
+ )
135
+ ),
136
+ 'filter' => false,
137
+ 'sortable' => false,
138
+ 'index' => 'stores'
139
+ ));
140
+
141
+ $this->addColumn('etiquette_retour', array(
142
+ 'header' => Mage::helper('chronorelais')->__('Impression étiquette retour'),
143
+ 'type' => 'action',
144
+ 'getter' => 'getId',
145
+ 'column_css_class' => 'etiquette_retour',
146
+ 'actions' => array(
147
+ array(
148
+ 'caption' => Mage::helper('chronorelais')->__('Retour SAV'),
149
+ 'url' => array(
150
+ 'base' => 'chronorelais/sales_impression/printEtiquetteRetour'
151
+ ),
152
+ 'field' => 'order_id'
153
+ )
154
+ ),
155
+ 'filter' => false,
156
+ 'renderer' => 'Chronopost_Chronorelais_Block_Sales_Shipment_Grid_Renderer_Retoursav',
157
+ 'sortable' => false,
158
+ 'index' => 'stores'
159
+ ));
160
+
161
+ return parent::_prepareColumns();
162
+ }
163
+
164
+ public function getRowUrl($row) {
165
+ if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/shipment')) {
166
+ return false;
167
+ }
168
+
169
+ return $this->getUrl('adminhtml/sales_order/view', array(
170
+ 'order_id' => $row->getId(),
171
+ )
172
+ );
173
+ }
174
+
175
+ protected function _prepareMassaction() {
176
+
177
+ $this->setMassactionIdField('entity_id');
178
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
179
+ $this->getMassactionBlock()->setUseSelectAll(false);
180
+
181
+ $cmd = Mage::helper('chronorelais')->getConfigData('chronorelais/shipping/gs_path')." -v";
182
+ $res_shell = shell_exec($cmd);
183
+ if($res_shell !== null) {
184
+ $this->getMassactionBlock()->addItem('print', array(
185
+ 'label' => Mage::helper('chronorelais')->__('Imprimer les étiquettes'),
186
+ 'url' => $this->getUrl('*/*/printMass', array('_current' => true)),
187
+ ));
188
+ }
189
+
190
+ if ($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
191
+
192
+ $shipping = array(
193
+ 'Yes' => Mage::helper('chronorelais')->__('Yes'),
194
+ 'No' => Mage::helper('chronorelais')->__('No'));
195
+ $this->getMassactionBlock()->addItem('shipping', array(
196
+ 'label' => Mage::helper('chronorelais')->__('Livraison le Samedi'),
197
+ 'url' => $this->getUrl('*/*/massLivraisonSamediStatus', array('_current' => true)),
198
+ 'additional' => array(
199
+ 'visibility' => array(
200
+ 'name' => 'status',
201
+ 'type' => 'select',
202
+ 'class' => 'required-entry',
203
+ 'style' => 'width:80px',
204
+ 'label' => Mage::helper('chronorelais')->__('Status'),
205
+ 'values' => $shipping
206
+ )
207
+ )
208
+ ));
209
+ }
210
+ return $this;
211
+ }
212
+
213
+ public function getGridUrl() {
214
+ return $this->getUrl('*/*/*', array('_current' => true));
215
+ }
216
+
217
+ public function getAdditionalJavaScript() {
218
+ echo "
219
+ var tds = $$('#sales_order_grid_table tr td.shipment_ids');
220
+ tds.each(function(item) {
221
+ var chaine = item.innerHTML.replace(/^\s+/g,'').replace(/\s+$/g,'');
222
+ var lienExpedition = $(item).next('.etiquette_expedition').down('a');
223
+ var lienRetour = $(item).next('.etiquette_retour').down('a');
224
+ if (chaine.split(', ').length > 1) {
225
+ var contentExpedition = '';
226
+ var contentRetour = '';
227
+ var numbers = chaine.split(', ');
228
+ for (var i=0; i<numbers.length; i++) {
229
+ contentExpedition += '<a href=\"' + lienExpedition.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + numbers[i] + '/') + '\">Exp&eacute;dition ' + numbers[i] + '</a><br />';
230
+ contentRetour += '<a href=\"' + lienRetour.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + numbers[i] + '/') + '\" >Retour SAV ' + numbers[i] + '</a><br />';
231
+ }
232
+ lienExpedition.up().innerHTML = contentExpedition;
233
+ if(typeof lienRetour !== 'undefined')
234
+ {
235
+ lienRetour.up().innerHTML = contentRetour;
236
+ }
237
+ }
238
+ else if(chaine.length > 2) {
239
+ lienExpedition.up().innerHTML = '<a href=\"' + lienExpedition.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + chaine + '/') + '\">Exp&eacute;dition</a><br />';
240
+ if(typeof lienRetour !== 'undefined')
241
+ {
242
+ lienRetour.up().innerHTML = '<a href=\"' + lienRetour.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + chaine + '/') + '\" >Retour SAV</a><br />';
243
+ }
244
+ }
245
+ else {
246
+ if(typeof lienRetour !== 'undefined')
247
+ {
248
+ lienRetour.up().innerHTML = '';
249
+ }
250
+ }
251
+ });";
252
+ }
253
+
254
+ }
app/code/community/Chronopost/Chronorelais/Helper/Conflicts.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Helper_Conflicts extends Mage_Core_Helper_Abstract {
4
+
5
+ const DEBUG = false;
6
+
7
+ var $rewrites;
8
+
9
+ var $whiteList = array("Mage_Adminhtml_Controller_Action", "Mage_Core_Controller_Front_Action");
10
+
11
+ public function checkForConflicts() {
12
+ $this->rewrites = array(
13
+ "chrono" => array(
14
+ "blocks" => array(),
15
+ "helpers" => array(),
16
+ "models" => array(),
17
+ "controllers" => array(),
18
+ ),
19
+ "other" => array(
20
+ "blocks" => array(),
21
+ "helpers" => array(),
22
+ "models" => array(),
23
+ "controllers" => array(),
24
+ ),
25
+ );
26
+
27
+ // Define pathes to check
28
+ $mageCodeDir = Mage::getBaseDir() . DS . 'app' . DS . 'code' . DS;
29
+ $modulePathes = array($mageCodeDir . 'local', $mageCodeDir . 'community');
30
+
31
+ $result = "";
32
+
33
+ // Recursively browse pathes
34
+ foreach ($modulePathes as $modulePath) {
35
+ $dir = new RecursiveDirectoryIterator($modulePath, FilesystemIterator::SKIP_DOTS);
36
+ $ite = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::SELF_FIRST);
37
+
38
+ // Get config.xml files
39
+ $configXmls = new RegexIterator($ite, '/^.+config\.xml$/i', RecursiveRegexIterator::GET_MATCH);
40
+
41
+ foreach ($configXmls as $configXml) {
42
+ if (self::DEBUG) $result .= '' . $configXml[0] . "\n";
43
+
44
+ // Parse XML to look for rewrites
45
+ $xml = simplexml_load_file($configXml[0]);
46
+ $rewrites = $xml->xpath('//rewrite');
47
+
48
+ while(list( , $node) = each($rewrites)) {
49
+ $moduleNode = $node->xpath("..");
50
+ $moduleName = $moduleNode[0]->getName();
51
+
52
+ // Filter route rewrites
53
+ if ($moduleName != "global") {
54
+ $typeNode = $moduleNode[0]->xpath("..");
55
+ $typeName = $typeNode[0]->getName();
56
+
57
+ // $result .= "Module : " . $moduleName . "\n";
58
+ // $result .= "Type : " . $typeName . "\n";
59
+
60
+ foreach ($node->children() as $child) {
61
+ $rewriteFrom = "Mage_" . str_replace(" ", "_", ucwords($moduleName . " " . substr($typeName, 0, -1) . " " . str_replace("_", " ", $child->getName())));
62
+
63
+ // $result .= "Rewrite from : " . $child->getName() . "\n";
64
+ if (self::DEBUG) $result .= "Rewrite from : " . $rewriteFrom . "\n";
65
+ if (self::DEBUG) $result .= "Rewrite to : " . $child->__toString() . "\n";
66
+
67
+ if (strpos($child->__toString(), "Chronopost_Chronorelais") !== false) {
68
+ $scope = "chrono";
69
+ } else {
70
+ $scope = "other";
71
+ }
72
+
73
+ if (!isset($this->rewrites[$scope][$typeName][$rewriteFrom])) {
74
+ $this->rewrites[$scope][$typeName][$rewriteFrom] = array();
75
+ }
76
+ $this->rewrites[$scope][$typeName][$rewriteFrom][] = $child->__toString(); // array("class" => $child->__toString());
77
+ }
78
+ }
79
+ }
80
+
81
+ if (self::DEBUG) $result .= "\n";
82
+ }
83
+
84
+ // Get controllers PHP files
85
+ $controllerPhps = new RegexIterator($ite, '/^.+controllers.+\.php$/i', RecursiveRegexIterator::GET_MATCH);
86
+
87
+ foreach ($controllerPhps as $controllerPhp) {
88
+ $className = "";
89
+ $scope = "";
90
+
91
+ $php_file = file_get_contents($controllerPhp[0]);
92
+ $tokens = token_get_all($php_file);
93
+ $class_token = false;
94
+ $extends_token = false;
95
+ foreach ($tokens as $token) {
96
+ if (is_array($token)) {
97
+ if ($token[0] == T_CLASS) {
98
+ $class_token = true;
99
+ } else if ($class_token && $token[0] == T_STRING) {
100
+ $className = $token[1];
101
+ $class_token = false;
102
+ } else if ($token[0] == T_EXTENDS) {
103
+ $extends_token = true;
104
+ } else if ($extends_token && $token[0] == T_STRING) {
105
+ if (self::DEBUG) {
106
+ $result .= 'File ' . $controllerPhp[0] . ":\n" .
107
+ " Class " . $className . "\n" .
108
+ " Extends " . $token[1] . "\n\n";
109
+ }
110
+
111
+ if (empty($scope)) {
112
+ if (strpos($className, "Chronopost_Chronorelais") !== false) {
113
+ $scope = "chrono";
114
+ } else {
115
+ $scope = "other";
116
+ }
117
+ }
118
+
119
+ if (!isset($this->rewrites[$scope]["controllers"][$token[1]])) {
120
+ $this->rewrites[$scope]["controllers"][$token[1]] = array();
121
+ }
122
+ $this->rewrites[$scope]["controllers"][$token[1]][] = $className; // array("class" => $className, "file" => $controllerPhp);
123
+
124
+ $className = "";
125
+ $extends_token = false;
126
+ }
127
+ }
128
+ }
129
+
130
+ // $className = str_replace(".php", "", str_replace($modulePath . DS, "", $controllerPhp[0]));
131
+ // $classNameArray = explode(DS, $className);
132
+ // $className = $classNameArray[0] . '_' . $classNameArray[1] . '_' . $classNameArray[3];
133
+
134
+ }
135
+ }
136
+
137
+ // Parse rewrites table to check for conflicts
138
+
139
+ foreach ($this->rewrites['chrono'] as $type => $rewrites) {
140
+ foreach ($rewrites as $from => $tos) {
141
+ if (!in_array($from, $this->whiteList) && isset($this->rewrites['other'][$type][$from])) {
142
+ // Houston, we have a rewrite
143
+ // $result .= "<p>[" . $type . "] Rewrite of Class <b>" . $from . "</b> by " . implode(', ', $tos) . " might conflict with rewrites from " . implode(', ', $this->rewrites['other'][$type][$from]) . "</p>\r\n";
144
+ $result .= "<p>[" . $type . "] La réécriture de la Classe <u>" . $from . "</u> par <u>" . implode(', ', $tos) . "</u> pourrait entrer en conflit avec les réécritures faites par <u>" . implode(', ', $this->rewrites['other'][$type][$from]) . "</u></p>\r\n";
145
+ }
146
+ }
147
+ }
148
+
149
+ if (empty($result)) {
150
+ $result = "Aucun conflit n'a été detecté au niveau des controleurs, des classes de block, des helpers ou des modèles.";
151
+ } else {
152
+ $result = "<p>Des conflits potentiels ont été détectés :</p>" . $result . "<p>Ces résultats sont à analyser individuellement. Ils offrent des pistes à étudier et ne remplacent pas une étude approfondie du code.</p>";
153
+ }
154
+
155
+ return $result;
156
+ }
157
+
158
+ }
app/code/community/Chronopost/Chronorelais/Helper/Data.php CHANGED
@@ -1,331 +1,350 @@
1
- <?php
2
-
3
- class Chronopost_Chronorelais_Helper_Data extends Mage_Core_Helper_Abstract {
4
- //Choronorelais settings for productCode
5
- const CHRONO_POST = '01'; // for France
6
- const CHRONO_POST_BAL = '58'; // For france avec option BAL
7
- const CHRONO_EXPRESS = '17'; // for Interantional
8
- const CHRONORELAIS = '86'; // for Chronorelais
9
- const CHRONOPOST_C10 = '02'; // for Chronopost C10
10
- const CHRONOPOST_C18 = '16'; // for Chronopost C18
11
- const CHRONOPOST_C18_BAL = '2M'; // for Chronopost C18 avec option BAL
12
- const CHRONOPOST_CClassic = '44'; // for Chronopost CClassic
13
- const CHRONOPOST_13H = '13H'; // for France
14
- const CHRONOPOST_13H_BAL = '13H BAL'; // for France BAL
15
- const CHRONOPOST_C10_STR = '10H'; // for Chronopost C10
16
- const CHRONOPOST_C18_STR = '18H'; // for Chronopost C18
17
- const CHRONOPOST_C18_BAL_STR = '18H BAL'; // for Chronopost C18 BAL
18
- const CHRONOPOST_CClassic_STR = 'CClassic'; // for Chronopost CClassic
19
- const CHRONOEXPRESS_EI = 'EI'; // for Interantional
20
- const CHRONORELAIS_PR = 'PR'; // for Chronorelais
21
- const CHRONOPOST_DEFAULT_COUNTRY = 'FR';
22
- const CHRONOPOST_TRACKING_URL = 'http://wsshipping.chronopost.fr/shipping/services/getReservedSkybill?reservationNumber={trackingNumber}';
23
- // if you are in a period outside thursday 18:00 to friday 15:00, there is no shipping on saturday
24
- var $SaturdayShippingDays = array(
25
- 'startday' => 'thursday',
26
- 'endday' => 'friday',
27
- 'starttime' => '18:00:00',
28
- 'endtime' => '15:00:00'
29
- );
30
-
31
- public function getConfigData($path) {
32
- return Mage::getStoreConfig($path, Mage::app()->getStore());
33
- }
34
-
35
- public function getSaturdayShippingDays() {
36
- return $this->SaturdayShippingDays;
37
- }
38
-
39
- public function getCurrentTimeByZone($timezone="Europe/Paris", $format="l H:i") {
40
- $d = new DateTime("now", new DateTimeZone($timezone));
41
- return $d->format($format);
42
- }
43
-
44
- public function isSendingDay() {
45
- $shipping_days = $this->getSaturdayShippingDays();
46
- $current_day = strtolower($this->getCurrentTimeByZone("Europe/Paris", "l"));
47
- $current_date = $this->getCurrentTimeByZone("Europe/Paris", "Y-m-d H:i:s");
48
- $current_datetime = explode(' ', $current_date);
49
-
50
- //get timestamps
51
- $start_timestamp = strtotime($current_datetime[0] . " " . $shipping_days['starttime']);
52
- $end_timestamp = strtotime($current_datetime[0] . " " . $shipping_days['endtime']);
53
- $current_timestamp = strtotime($current_date);
54
-
55
- $sending_day = false;
56
- if ($shipping_days['startday'] == $current_day && $current_timestamp >= $start_timestamp) {
57
- $sending_day = true;
58
- } elseif ($shipping_days['endday'] == $current_day && $current_timestamp <= $end_timestamp) {
59
- $sending_day = true;
60
- }
61
- return $sending_day;
62
- }
63
-
64
- /**
65
- * General Shipping configuration
66
- */
67
- public function getConfigurationAccountNumber() {
68
- return $this->getConfigData('chronorelais/shipping/account_number');
69
- }
70
-
71
- public function getConfigurationSubAccountNumber() {
72
- return $this->getConfigData('chronorelais/shipping/sub_account_number');
73
- }
74
-
75
- public function getConfigurationAccountPass() {
76
- return $this->getConfigData('chronorelais/shipping/account_pass');
77
- }
78
-
79
- public function getConfigurationTrackingViewUrl() {
80
- return $this->getConfigData('chronorelais/shipping/tracking_view_url');
81
- }
82
-
83
- public function getConfigurationGoogleMapAPIKey() {
84
- return $this->getConfigData('chronorelais/shipping/google_map_api');
85
- }
86
-
87
- public function getChronoProductCode($country, $code='') {
88
- $productcode = '';
89
- $code = strtolower($code);
90
-
91
- switch($code) {
92
- case 'chronorelais' :
93
- $productcode = self::CHRONORELAIS;
94
- break;
95
- case 'chronopost' :
96
- $productcode = self::CHRONO_POST;
97
- break;
98
- case 'chronoexpress' :
99
- $productcode = self::CHRONO_EXPRESS;
100
- break;
101
- case 'chronopostc10' :
102
- $productcode = self::CHRONOPOST_C10;
103
- break;
104
- case 'chronopostc18' :
105
- $productcode = self::CHRONOPOST_C18;
106
- break;
107
- case 'chronopostcclassic' :
108
- $productcode = self::CHRONOPOST_CClassic;
109
- break;
110
- }
111
- return $productcode;
112
- }
113
-
114
- public function getChronoProductCodeToShipment($code='') {
115
- $productcode = '';
116
- $code = strtolower($code);
117
-
118
- switch($code) {
119
- case 'chronorelais' :
120
- $productcode = self::CHRONORELAIS;
121
- break;
122
- case 'chronopost' :
123
- if($this->getConfigOptionBAL()) {
124
- $productcode = self::CHRONO_POST_BAL;
125
- }
126
- else {
127
- $productcode = self::CHRONO_POST;
128
- }
129
- break;
130
- case 'chronoexpress' :
131
- $productcode = self::CHRONO_EXPRESS;
132
- break;
133
- case 'chronopostc10' :
134
- $productcode = self::CHRONOPOST_C10;
135
- break;
136
- case 'chronopostc18' :
137
- if($this->getConfigOptionBAL()) {
138
- $productcode = self::CHRONOPOST_C18_BAL;
139
- }
140
- else {
141
- $productcode = self::CHRONOPOST_C18;
142
- }
143
- break;
144
- case 'chronopostcclassic' :
145
- $productcode = self::CHRONOPOST_CClassic;
146
- break;
147
- }
148
- return $productcode;
149
- }
150
-
151
- public function getChronoProductCodeString($code='') {
152
- $productcode = '';
153
- $code = strtolower($code);
154
-
155
- switch($code) {
156
- case 'chronorelais' : $productcode = self::CHRONORELAIS_PR; break;
157
- case 'chronopost' : $productcode = self::CHRONOPOST_13H; break;
158
- case 'chronoexpress' : $productcode = self::CHRONOEXPRESS_EI; break;
159
- case 'chronopostc10' : $productcode = self::CHRONOPOST_C10_STR; break;
160
- case 'chronopostc18' : $productcode = self::CHRONOPOST_C18_STR; break;
161
- case 'chronopostcclassic' : $productcode = self::CHRONOPOST_CClassic_STR; break;
162
- }
163
- return $productcode;
164
- }
165
-
166
- public function getChronoProductCodeStringWithBAL($code='') {
167
- $productcode = '';
168
- $code = strtolower($code);
169
-
170
- switch($code) {
171
- case 'chronorelais' : $productcode = self::CHRONORELAIS_PR; break;
172
- case 'chronopost' :
173
- if($this->getConfigOptionBAL()) {
174
- $productcode = self::CHRONOPOST_13H_BAL;
175
- }
176
- else {
177
- $productcode = self::CHRONOPOST_13H;
178
- }
179
- break;
180
- case 'chronoexpress' : $productcode = self::CHRONOEXPRESS_EI; break;
181
- case 'chronopostc10' : $productcode = self::CHRONOPOST_C10_STR; break;
182
- case 'chronopostc18' :
183
- if($this->getConfigOptionBAL()) {
184
- $productcode = self::CHRONOPOST_C18_BAL_STR;
185
- }
186
- else {
187
- $productcode = self::CHRONOPOST_C18_STR;
188
- }
189
- break;
190
- case 'chronopostcclassic' : $productcode = self::CHRONOPOST_CClassic_STR; break;
191
- }
192
- return $productcode;
193
- }
194
-
195
- public function getConfigurationTrackingUrl() {
196
- return self::CHRONOPOST_TRACKING_URL;
197
- }
198
-
199
- /**
200
- * Export configuration
201
- */
202
- public function getConfigurationFileExtension($export_type='css') {
203
- return $this->getConfigData('chronorelais/export_' . $export_type . '/file_extension');
204
- }
205
-
206
- public function getConfigurationFileCharset($export_type='css') {
207
- return $this->getConfigData('chronorelais/export_' . $export_type . '/file_charset');
208
- }
209
-
210
- public function getConfigurationEndOfLineCharacter($export_type='css') {
211
- return $this->getConfigData('chronorelais/export_' . $export_type . '/endofline_character');
212
- }
213
-
214
- public function getConfigurationFieldDelimiter($export_type='css') {
215
- return $this->getConfigData('chronorelais/export_' . $export_type . '/field_delimiter');
216
- }
217
-
218
- public function getConfigurationFieldSeparator($export_type='css') {
219
- return $this->getConfigData('chronorelais/export_' . $export_type . '/field_separator');
220
- }
221
-
222
- /**
223
- * Import configuration
224
- */
225
- public function getConfigurationSendEmail() {
226
- return $this->getConfigData('chronorelais/import/send_email');
227
- }
228
-
229
- public function getConfigurationIncludeComment() {
230
- return $this->getConfigData('chronorelais/import/include_comment');
231
- }
232
-
233
- public function getConfigurationDefaultTrackingTitle() {
234
- return $this->getConfigData('chronorelais/import/default_tracking_title');
235
- }
236
-
237
- public function getConfigurationShippingComment() {
238
- return $this->getConfigData('chronorelais/import/shipping_comment');
239
- }
240
-
241
- /**
242
- * Shipper Information
243
- */
244
- public function getConfigurationShipperInfo($field) {
245
- $fieldValue = '';
246
- if ($field) {
247
- if ($this->getConfigData('chronorelais/shipperinformation/' . $field)) {
248
- $fieldValue = $this->getConfigData('chronorelais/shipperinformation/' . $field);
249
- }
250
- }
251
- return $fieldValue;
252
- }
253
-
254
- /**
255
- * Chronopost Customer Information
256
- */
257
- public function getConfigurationCustomerInfo($field) {
258
- $fieldValue = '';
259
- if ($field) {
260
- if ($this->getConfigData('chronorelais/customerinformation/' . $field)) {
261
- $fieldValue = $this->getConfigData('chronorelais/customerinformation/' . $field);
262
- }
263
- }
264
- return $fieldValue;
265
- }
266
-
267
- /**
268
- * Import configuration
269
- */
270
- public function getConfigurationSkybillParam() {
271
- return $this->getConfigData('chronorelais/skybillparam/mode');
272
- }
273
-
274
- /*
275
- * Weight unit
276
- */
277
- public function getConfigWeightUnit() {
278
- return $this->getConfigData('chronorelais/weightunit/unit');
279
- }
280
-
281
- /*
282
- * Option BAL
283
- */
284
- public function getConfigOptionBAL() {
285
- return $this->getConfigData('chronorelais/optionbal/enabled');
286
- }
287
-
288
- public function hasOptionBAL($order) {
289
- $shippingMethod = explode('_',$order->getShippingMethod());
290
- $shippingMethod = $shippingMethod[1];
291
- $shippingMethodAllowBAL = array('chronopost','chronopostc18');
292
- if(in_array(strtolower($shippingMethod), $shippingMethodAllowBAL) && $this->getConfigOptionBAL()) {
293
- return true;
294
- }
295
- return false;
296
- }
297
-
298
- /*
299
- * Assurance Ad Valorem
300
- */
301
- public function assuranceAdValoremEnabled() {
302
- return $this->getConfigData('chronorelais/assurance/enabled');
303
- }
304
- public function assuranceAdValoremAmount() {
305
- return $this->getConfigData('chronorelais/assurance/amount');
306
- }
307
- public function getMaxAdValoremAmount() {
308
- return 20000;
309
- }
310
-
311
- /* Get Livraison le Samedi status by orderid */
312
-
313
- public function getLivraisonSamediStatus($order_id) {
314
- $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
315
- $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
316
- $select = $_connection->select()
317
- ->from($_table, 'livraison_le_samedi')
318
- ->where('order_id=?', $order_id);
319
- $status = $_connection->fetchOne($select);
320
- return $status;
321
- }
322
-
323
-
324
- /*
325
- * Return true si la méthode de livraison fait partie du contrat du marchant
326
- */
327
- public function shippingMethodEnabled($shippingMethod) {
328
- return true;
329
- }
330
-
331
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Helper_Data extends Mage_Core_Helper_Abstract {
4
+ //Choronorelais settings for productCode
5
+ const CHRONO_POST = '01'; // for France
6
+ const CHRONO_POST_BAL = '58'; // For france avec option BAL
7
+ const CHRONO_EXPRESS = '17'; // for Interantional
8
+ const CHRONORELAIS = '86'; // for Chronorelais
9
+ const CHRONOPOST_C10 = '02'; // for Chronopost C10
10
+ const CHRONOPOST_C18 = '16'; // for Chronopost C18
11
+ const CHRONOPOST_C18_BAL = '2M'; // for Chronopost C18 avec option BAL
12
+ const CHRONOPOST_CClassic = '44'; // for Chronopost CClassic
13
+ const CHRONOPOST_13H = '13H'; // for France
14
+ const CHRONOPOST_13H_BAL = '13H BAL'; // for France BAL
15
+ const CHRONOPOST_C10_STR = '10H'; // for Chronopost C10
16
+ const CHRONOPOST_C18_STR = '18H'; // for Chronopost C18
17
+ const CHRONOPOST_C18_BAL_STR = '18H BAL'; // for Chronopost C18 BAL
18
+ const CHRONOPOST_CClassic_STR = 'CClassic'; // for Chronopost CClassic
19
+ const CHRONOEXPRESS_EI = 'EI'; // for Interantional
20
+ const CHRONORELAIS_PR = 'PR'; // for Chronorelais
21
+ const CHRONOPOST_DEFAULT_COUNTRY = 'FR';
22
+ const CHRONOPOST_TRACKING_URL = 'http://wsshipping.chronopost.fr/shipping/services/getReservedSkybill?reservationNumber={trackingNumber}';
23
+ // if you are in a period outside thursday 18:00 to friday 15:00, there is no shipping on saturday
24
+ var $SaturdayShippingDays = array(
25
+ 'startday' => 'thursday',
26
+ 'endday' => 'friday',
27
+ 'starttime' => '18:00:00',
28
+ 'endtime' => '15:00:00'
29
+ );
30
+
31
+ public function getConfigData($path) {
32
+ return Mage::getStoreConfig($path, Mage::app()->getStore());
33
+ }
34
+
35
+ public function getSaturdayShippingDays() {
36
+ return $this->SaturdayShippingDays;
37
+ }
38
+
39
+ public function getCurrentTimeByZone($timezone="Europe/Paris", $format="l H:i") {
40
+ $d = new DateTime("now", new DateTimeZone($timezone));
41
+ return $d->format($format);
42
+ }
43
+
44
+ public function isSendingDay() {
45
+ $shipping_days = $this->getSaturdayShippingDays();
46
+ $current_day = strtolower($this->getCurrentTimeByZone("Europe/Paris", "l"));
47
+ $current_date = $this->getCurrentTimeByZone("Europe/Paris", "Y-m-d H:i:s");
48
+ $current_datetime = explode(' ', $current_date);
49
+
50
+ //get timestamps
51
+ $start_timestamp = strtotime($current_datetime[0] . " " . $shipping_days['starttime']);
52
+ $end_timestamp = strtotime($current_datetime[0] . " " . $shipping_days['endtime']);
53
+ $current_timestamp = strtotime($current_date);
54
+
55
+ $sending_day = false;
56
+ if ($shipping_days['startday'] == $current_day && $current_timestamp >= $start_timestamp) {
57
+ $sending_day = true;
58
+ } elseif ($shipping_days['endday'] == $current_day && $current_timestamp <= $end_timestamp) {
59
+ $sending_day = true;
60
+ }
61
+ return $sending_day;
62
+ }
63
+
64
+ /**
65
+ * General Shipping configuration
66
+ */
67
+ public function getConfigurationAccountNumber() {
68
+ return $this->getConfigData('chronorelais/shipping/account_number');
69
+ }
70
+
71
+ public function getConfigurationSubAccountNumber() {
72
+ return $this->getConfigData('chronorelais/shipping/sub_account_number');
73
+ }
74
+
75
+ public function getConfigurationAccountPass() {
76
+ return $this->getConfigData('chronorelais/shipping/account_pass');
77
+ }
78
+
79
+ public function getConfigurationTrackingViewUrl() {
80
+ return $this->getConfigData('chronorelais/shipping/tracking_view_url');
81
+ }
82
+
83
+ public function getConfigurationGoogleMapAPIKey() {
84
+ return $this->getConfigData('chronorelais/shipping/google_map_api');
85
+ }
86
+
87
+ public function getChronoProductCode($country, $code='') {
88
+ $productcode = '';
89
+ $code = strtolower($code);
90
+
91
+ switch($code) {
92
+ case 'chronorelais' :
93
+ $productcode = self::CHRONORELAIS;
94
+ break;
95
+ case 'chronopost' :
96
+ $productcode = self::CHRONO_POST;
97
+ break;
98
+ case 'chronoexpress' :
99
+ $productcode = self::CHRONO_EXPRESS;
100
+ break;
101
+ case 'chronopostc10' :
102
+ $productcode = self::CHRONOPOST_C10;
103
+ break;
104
+ case 'chronopostc18' :
105
+ $productcode = self::CHRONOPOST_C18;
106
+ break;
107
+ case 'chronopostcclassic' :
108
+ $productcode = self::CHRONOPOST_CClassic;
109
+ break;
110
+ }
111
+ return $productcode;
112
+ }
113
+
114
+ public function getChronoProductCodeToShipment($code='') {
115
+ $productcode = '';
116
+ $code = strtolower($code);
117
+
118
+ switch($code) {
119
+ case 'chronorelais' :
120
+ $productcode = self::CHRONORELAIS;
121
+ break;
122
+ case 'chronopost' :
123
+ if($this->getConfigOptionBAL()) {
124
+ $productcode = self::CHRONO_POST_BAL;
125
+ }
126
+ else {
127
+ $productcode = self::CHRONO_POST;
128
+ }
129
+ break;
130
+ case 'chronoexpress' :
131
+ $productcode = self::CHRONO_EXPRESS;
132
+ break;
133
+ case 'chronopostc10' :
134
+ $productcode = self::CHRONOPOST_C10;
135
+ break;
136
+ case 'chronopostc18' :
137
+ if($this->getConfigOptionBAL()) {
138
+ $productcode = self::CHRONOPOST_C18_BAL;
139
+ }
140
+ else {
141
+ $productcode = self::CHRONOPOST_C18;
142
+ }
143
+ break;
144
+ case 'chronopostcclassic' :
145
+ $productcode = self::CHRONOPOST_CClassic;
146
+ break;
147
+ }
148
+ return $productcode;
149
+ }
150
+
151
+ public function getChronoProductCodeString($code='') {
152
+ $productcode = '';
153
+ $code = strtolower($code);
154
+
155
+ switch($code) {
156
+ case 'chronorelais' : $productcode = self::CHRONORELAIS_PR; break;
157
+ case 'chronopost' : $productcode = self::CHRONOPOST_13H; break;
158
+ case 'chronoexpress' : $productcode = self::CHRONOEXPRESS_EI; break;
159
+ case 'chronopostc10' : $productcode = self::CHRONOPOST_C10_STR; break;
160
+ case 'chronopostc18' : $productcode = self::CHRONOPOST_C18_STR; break;
161
+ case 'chronopostcclassic' : $productcode = self::CHRONOPOST_CClassic_STR; break;
162
+ }
163
+ return $productcode;
164
+ }
165
+
166
+ public function getChronoProductCodeStringWithBAL($code='') {
167
+ $productcode = '';
168
+ $code = strtolower($code);
169
+
170
+ switch($code) {
171
+ case 'chronorelais' : $productcode = self::CHRONORELAIS_PR; break;
172
+ case 'chronopost' :
173
+ if($this->getConfigOptionBAL()) {
174
+ $productcode = self::CHRONOPOST_13H_BAL;
175
+ }
176
+ else {
177
+ $productcode = self::CHRONOPOST_13H;
178
+ }
179
+ break;
180
+ case 'chronoexpress' : $productcode = self::CHRONOEXPRESS_EI; break;
181
+ case 'chronopostc10' : $productcode = self::CHRONOPOST_C10_STR; break;
182
+ case 'chronopostc18' :
183
+ if($this->getConfigOptionBAL()) {
184
+ $productcode = self::CHRONOPOST_C18_BAL_STR;
185
+ }
186
+ else {
187
+ $productcode = self::CHRONOPOST_C18_STR;
188
+ }
189
+ break;
190
+ case 'chronopostcclassic' : $productcode = self::CHRONOPOST_CClassic_STR; break;
191
+ }
192
+ return $productcode;
193
+ }
194
+
195
+ public function getConfigurationTrackingUrl() {
196
+ return self::CHRONOPOST_TRACKING_URL;
197
+ }
198
+
199
+ /**
200
+ * Export configuration
201
+ */
202
+ public function getConfigurationFileExtension($export_type='css') {
203
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/file_extension');
204
+ }
205
+
206
+ public function getConfigurationFileCharset($export_type='css') {
207
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/file_charset');
208
+ }
209
+
210
+ public function getConfigurationEndOfLineCharacter($export_type='css') {
211
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/endofline_character');
212
+ }
213
+
214
+ public function getConfigurationFieldDelimiter($export_type='css') {
215
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/field_delimiter');
216
+ }
217
+
218
+ public function getConfigurationFieldSeparator($export_type='css') {
219
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/field_separator');
220
+ }
221
+
222
+ /**
223
+ * Import configuration
224
+ */
225
+ public function getConfigurationSendEmail() {
226
+ return $this->getConfigData('chronorelais/import/send_email');
227
+ }
228
+
229
+ public function getConfigurationIncludeComment() {
230
+ return $this->getConfigData('chronorelais/import/include_comment');
231
+ }
232
+
233
+ public function getConfigurationDefaultTrackingTitle() {
234
+ return $this->getConfigData('chronorelais/import/default_tracking_title');
235
+ }
236
+
237
+ public function getConfigurationShippingComment() {
238
+ return $this->getConfigData('chronorelais/import/shipping_comment');
239
+ }
240
+
241
+ /**
242
+ * Shipper Information
243
+ */
244
+ public function getConfigurationShipperInfo($field) {
245
+ $fieldValue = '';
246
+ if ($field) {
247
+ if ($this->getConfigData('chronorelais/shipperinformation/' . $field)) {
248
+ $fieldValue = $this->getConfigData('chronorelais/shipperinformation/' . $field);
249
+ }
250
+ }
251
+ return $fieldValue;
252
+ }
253
+
254
+ /**
255
+ * Chronopost Customer Information
256
+ */
257
+ public function getConfigurationCustomerInfo($field) {
258
+ $fieldValue = '';
259
+ if ($field) {
260
+ if ($this->getConfigData('chronorelais/customerinformation/' . $field)) {
261
+ $fieldValue = $this->getConfigData('chronorelais/customerinformation/' . $field);
262
+ }
263
+ }
264
+ return $fieldValue;
265
+ }
266
+
267
+ /**
268
+ * Import configuration
269
+ */
270
+ public function getConfigurationSkybillParam() {
271
+ return $this->getConfigData('chronorelais/skybillparam/mode');
272
+ }
273
+
274
+ /*
275
+ * Weight unit
276
+ */
277
+ public function getConfigWeightUnit() {
278
+ return $this->getConfigData('chronorelais/weightunit/unit');
279
+ }
280
+
281
+ /*
282
+ * Option BAL
283
+ */
284
+ public function getConfigOptionBAL() {
285
+ return $this->getConfigData('chronorelais/optionbal/enabled');
286
+ }
287
+
288
+ public function hasOptionBAL($order) {
289
+ $shippingMethod = explode('_',$order->getShippingMethod());
290
+ $shippingMethod = $shippingMethod[1];
291
+ $shippingMethodAllowBAL = array('chronopost','chronopostc18');
292
+ if(in_array(strtolower($shippingMethod), $shippingMethodAllowBAL) && $this->getConfigOptionBAL()) {
293
+ return true;
294
+ }
295
+ return false;
296
+ }
297
+
298
+ /*
299
+ * Assurance Ad Valorem
300
+ */
301
+ public function assuranceAdValoremEnabled() {
302
+ return $this->getConfigData('chronorelais/assurance/enabled');
303
+ }
304
+ public function assuranceAdValoremAmount() {
305
+ return $this->getConfigData('chronorelais/assurance/amount');
306
+ }
307
+ public function getMaxAdValoremAmount() {
308
+ return 20000;
309
+ }
310
+
311
+ /* Get Livraison le Samedi status by orderid */
312
+
313
+ public function getLivraisonSamediStatus($order_id) {
314
+ $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
315
+ $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
316
+ $select = $_connection->select()
317
+ ->from($_table, 'livraison_le_samedi')
318
+ ->where('order_id=?', $order_id);
319
+ $status = $_connection->fetchOne($select);
320
+ return $status;
321
+ }
322
+
323
+
324
+ /*
325
+ * Return true si la méthode de livraison fait partie du contrat du marchant
326
+ */
327
+ public function shippingMethodEnabled($shippingMethod) {
328
+ return true;
329
+ }
330
+
331
+ /*
332
+ * Return true if we can show google map
333
+ */
334
+ public function canShowGoogleMap() {
335
+ return $this->getConfigData('carriers/chronorelais/show_google_map');
336
+ }
337
+
338
+ /* return track number field name */
339
+ public function getTrackNumberFieldName() {
340
+ $magentoVersion = Mage::getVersionInfo();
341
+ //if($magentoVersion['minor'] > 4 || ($magentoVersion['minor'] == 4 && $magentoVersion['revision'] > 1)) { /* version > 1.4.1 */
342
+ if (version_compare(Mage::getVersion(), '1.5.1.0', '>')) {
343
+ return "track_number";
344
+ } else {
345
+ return "number";
346
+ }
347
+
348
+ }
349
+
350
+ }
app/code/community/Chronopost/Chronorelais/Helper/Webservice.php CHANGED
@@ -1,436 +1,445 @@
1
- <?php
2
-
3
- class Chronopost_Chronorelais_Helper_Webservice extends Mage_Core_Helper_Abstract {
4
-
5
- var $methodsAllowed = false;
6
-
7
- public function getPointsRelaisByCp($cp) {
8
-
9
- try {
10
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl",array('trace'=> 0,'connection_timeout'=>10));
11
- $webservbt = $client->__call("rechercheBtParCodeproduitEtCodepostalEtDate",array(0,$cp,0));
12
- return $webservbt;
13
- } catch (Exception $e) {
14
- $webservbt = $this->getPointsRelaisByPudo('',$cp);
15
- return $webservbt;
16
- }
17
- }
18
-
19
- /* get point relais by address */
20
- public function getPointRelaisByAddress() {
21
-
22
- $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
23
- $address = $quote->getShippingAddress();
24
- $helperData = Mage::helper('chronorelais');
25
-
26
- try {
27
- $client = new SoapClient("https://www.chronopost.fr/recherchebt-ws-cxf/PointRelaisServiceWS?wsdl", array('trace' => 0, 'connection_timeout' => 10));
28
-
29
- $params = array(
30
- 'accountNumber' => $helperData->getConfigurationAccountNumber(),
31
- 'password' => $helperData->getConfigurationAccountPass(),
32
- 'address' => $this->getFilledValue($address->getStreet(1)),
33
- 'zipCode' => $this->getFilledValue($address->getPostcode()),
34
- 'city' => $this->getFilledValue($address->getCity()),
35
- 'countryCode' => $this->getFilledValue($address->getCountryId()),
36
- 'type' => 'P',
37
- 'productCode' => '1',
38
- 'service' => 'T',
39
- 'weight' => 2000,
40
- 'shippingDate' => date('d/m/Y'),
41
- 'maxPointChronopost' => 5,
42
- 'maxDistanceSearch' => 10,
43
- 'holidayTolerant' => 1
44
- );
45
- $webservbt = $client->recherchePointChronopost($params);
46
-
47
- /* format $webservbt pour avoir le meme format que lors de l'appel du WS par code postal */
48
- if($webservbt->return->errorCode == 0)
49
- {
50
- /*
51
- * Format entrée
52
- *
53
- * accesPersonneMobiliteReduite
54
- actif
55
- adresse1
56
- adresse2
57
- adresse3
58
- codePays
59
- codePostal
60
- coordGeolocalisationLatitude
61
- coordGeolocalisationLongitude
62
- distanceEnMetre
63
- identifiant
64
- indiceDeLocalisation
65
- listeHoraireOuverture
66
- localite
67
- nom
68
- poidsMaxi
69
- typeDePoint
70
- urlGoogleMaps
71
- *
72
- * Format sortie
73
- * adresse1
74
- adresse2
75
- adresse3
76
- codePostal
77
- dateArriveColis
78
- horairesOuvertureDimanche ("10:00-12:30 14:30-19:00")
79
- horairesOuvertureJeudi
80
- horairesOuvertureLundi
81
- horairesOuvertureMardi
82
- horairesOuvertureMercredi
83
- horairesOuvertureSamedi
84
- horairesOuvertureVendredi
85
- identifiantChronopostPointA2PAS
86
- localite
87
- nomEnseigne
88
- *
89
- *
90
- *
91
- * 2013-02-19T10:42:40.196Z
92
- *
93
- */
94
- $listePr = $webservbt->return->listePointRelais;
95
- $return = array();
96
- foreach($listePr as $pr)
97
- {
98
- //$newPr = new object();
99
- $newPr = (object)array();
100
- $newPr->adresse1 = $pr->adresse1;
101
- $newPr->adresse2 = $pr->adresse2;
102
- $newPr->adresse3 = $pr->adresse3;
103
- $newPr->codePostal = $pr->codePostal;
104
- $newPr->identifiantChronopostPointA2PAS = $pr->identifiant;
105
- $newPr->localite = $pr->localite;
106
- $newPr->nomEnseigne = $pr->nom;
107
- $time = new DateTime;
108
- $newPr->dateArriveColis = $time->format(DateTime::ATOM);
109
- $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
110
- foreach($pr->listeHoraireOuverture as $horaire) {
111
- switch($horaire->jour) {
112
- case '1' : $newPr->horairesOuvertureLundi = $horaire->horairesAsString; break;
113
- case '2' : $newPr->horairesOuvertureMardi = $horaire->horairesAsString; break;
114
- case '3' : $newPr->horairesOuvertureMercredi = $horaire->horairesAsString; break;
115
- case '4' : $newPr->horairesOuvertureJeudi = $horaire->horairesAsString; break;
116
- case '5' : $newPr->horairesOuvertureVendredi = $horaire->horairesAsString; break;
117
- case '6' : $newPr->horairesOuvertureSamedi = $horaire->horairesAsString; break;
118
- case '7' : $newPr->horairesOuvertureDimanche = $horaire->horairesAsString; break;
119
- }
120
- }
121
- if(empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
122
- if(empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
123
- if(empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
124
- if(empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
125
- if(empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
126
- if(empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
127
- if(empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
128
-
129
- $return[] = $newPr;
130
- }
131
- return $return;
132
- }
133
- } catch (Exception $e) {
134
- return $this->getPointsRelaisByPudo($address);
135
- }
136
- }
137
-
138
- public function getDetailRelaisPoint($btcode) {
139
- try {
140
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl");
141
- $webservbt = $client->__call("rechercheBtParIdChronopostA2Pas",array($btcode));
142
- return $webservbt[0];
143
- } catch (Exception $e) {
144
- return $this->getDetailRelaisPointByPudo($btcode);
145
- }
146
- }
147
-
148
-
149
- /*
150
- *
151
- * WS de secours
152
- */
153
-
154
- public function getDetailRelaisPointByPudo($btcode) {
155
- $params = array(
156
- 'carrier' => 'CHR',
157
- 'key' => '75f6fe195dc88ceecbc0f8a2f70a8f3a',
158
- 'pudo_id' => $btcode,
159
- );
160
-
161
- try {
162
- $client = new SoapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?wsdl", array('trace' => 0, 'connection_timeout' => 10));
163
- $webservbt = $client->GetPudoDetails($params);
164
- $webservbt = json_decode(json_encode((object) simplexml_load_string($webservbt->GetPudoDetailsResult->any)), 1);
165
- if(!isset($webservbt['ERROR'])) {
166
- $return = array();
167
- $pr = $webservbt['PUDO_ITEMS']['PUDO_ITEM'];
168
- if($pr) {
169
- if($pr['@attributes']['active'] == 'true')
170
- {
171
- $newPr = (object)array();
172
- $newPr->adresse1 = $pr['ADDRESS1'];
173
- $newPr->adresse2 = is_array($pr['ADDRESS2']) ? implode(' ', $pr['ADDRESS2']) : $pr['ADDRESS2'];
174
- $newPr->adresse3 = is_array($pr['ADDRESS3']) ? implode(' ', $pr['ADDRESS3']) : $pr['ADDRESS3'];
175
- $newPr->codePostal = $pr['ZIPCODE'];
176
- $newPr->identifiantChronopostPointA2PAS = $pr['PUDO_ID'];
177
- $newPr->localite = $pr['CITY'];
178
- $newPr->nomEnseigne = $pr['NAME'];
179
- $time = new DateTime;
180
- $newPr->dateArriveColis = $time->format(DateTime::ATOM);
181
- $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
182
-
183
- if(isset($pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'])) {
184
- $listeHoraires = $pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'];
185
- foreach($listeHoraires as $horaire) {
186
- switch($horaire['DAY_ID']) {
187
- case '1' :
188
- if(!empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi .= ' ';
189
- $newPr->horairesOuvertureLundi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
190
- break;
191
- case '2' :
192
- if(!empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi .= ' ';
193
- $newPr->horairesOuvertureMardi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
194
- break;
195
- case '3' :
196
- if(!empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi .= ' ';
197
- $newPr->horairesOuvertureMercredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
198
- break;
199
- case '4' :
200
- if(!empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi .= ' ';
201
- $newPr->horairesOuvertureJeudi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
202
- break;
203
- case '5' :
204
- if(!empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi .= ' ';
205
- $newPr->horairesOuvertureVendredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
206
- break;
207
- case '6' :
208
- if(!empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi .= ' ';
209
- $newPr->horairesOuvertureSamedi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
210
- break;
211
- case '7' :
212
- if(!empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche .= ' ';
213
- $newPr->horairesOuvertureDimanche .= $horaire['START_TM'].'-'.$horaire['END_TM'];
214
- break;
215
- }
216
- }
217
- }
218
- if(empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
219
- if(empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
220
- if(empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
221
- if(empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
222
- if(empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
223
- if(empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
224
- if(empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
225
-
226
- return $newPr;
227
- }
228
- }
229
- }
230
- }
231
- catch (Exception $e) {
232
- return false;
233
- }
234
- return false;
235
- }
236
-
237
- public function getPointsRelaisByPudo($address = '', $cp = '') {
238
-
239
- $params = array(
240
- 'carrier' => 'CHR',
241
- 'key' => '75f6fe195dc88ceecbc0f8a2f70a8f3a',
242
- 'address' => $address ? $this->getFilledValue($address->getStreet(1)) : '',
243
- 'zipCode' => $address ? $this->getFilledValue($address->getPostcode()) : $cp,
244
- 'city' => $address ? $this->getFilledValue($address->getCity()) : 'Lille',
245
- 'countrycode' => $address ? $this->getFilledValue($address->getCountryId()) : '',
246
- 'requestID' => '1',
247
- 'date_from' => date('d/m/Y'),
248
- 'max_pudo_number' => 5,
249
- 'max_distance_search' => 10,
250
- 'weight' => 1,
251
- 'category' => '',
252
- 'holiday_tolerant' => 1,
253
- );
254
- try {
255
- $client = new SoapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?wsdl", array('trace' => 0, 'connection_timeout' => 10));
256
- $webservbt = $client->GetPudoList($params);
257
- $webservbt = json_decode(json_encode((object) simplexml_load_string($webservbt->GetPudoListResult->any)), 1);
258
- if(!isset($webservbt['ERROR'])) {
259
- $return = array();
260
-
261
- $listePr = $webservbt['PUDO_ITEMS']['PUDO_ITEM'];
262
- if($listePr) {
263
- foreach($listePr as $pr)
264
- {
265
- if($pr['@attributes']['active'] == 'true')
266
- {
267
- $newPr = (object)array();
268
- $newPr->adresse1 = $pr['ADDRESS1'];
269
- $newPr->adresse2 = is_array($pr['ADDRESS2']) ? implode(' ', $pr['ADDRESS2']) : $pr['ADDRESS2'];
270
- $newPr->adresse3 = is_array($pr['ADDRESS3']) ? implode(' ', $pr['ADDRESS3']) : $pr['ADDRESS3'];
271
- $newPr->codePostal = $pr['ZIPCODE'];
272
- $newPr->identifiantChronopostPointA2PAS = $pr['PUDO_ID'];
273
- $newPr->localite = $pr['CITY'];
274
- $newPr->nomEnseigne = $pr['NAME'];
275
- $time = new DateTime;
276
- $newPr->dateArriveColis = $time->format(DateTime::ATOM);
277
- $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
278
-
279
- if(isset($pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'])) {
280
- $listeHoraires = $pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'];
281
- foreach($listeHoraires as $horaire) {
282
- switch($horaire['DAY_ID']) {
283
- case '1' :
284
- if(!empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi .= ' ';
285
- $newPr->horairesOuvertureLundi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
286
- break;
287
- case '2' :
288
- if(!empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi .= ' ';
289
- $newPr->horairesOuvertureMardi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
290
- break;
291
- case '3' :
292
- if(!empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi .= ' ';
293
- $newPr->horairesOuvertureMercredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
294
- break;
295
- case '4' :
296
- if(!empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi .= ' ';
297
- $newPr->horairesOuvertureJeudi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
298
- break;
299
- case '5' :
300
- if(!empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi .= ' ';
301
- $newPr->horairesOuvertureVendredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
302
- break;
303
- case '6' :
304
- if(!empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi .= ' ';
305
- $newPr->horairesOuvertureSamedi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
306
- break;
307
- case '7' :
308
- if(!empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche .= ' ';
309
- $newPr->horairesOuvertureDimanche .= $horaire['START_TM'].'-'.$horaire['END_TM'];
310
- break;
311
- }
312
- }
313
- }
314
- if(empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
315
- if(empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
316
- if(empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
317
- if(empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
318
- if(empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
319
- if(empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
320
- if(empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
321
-
322
- $return[] = $newPr;
323
- }
324
- }
325
- return $return;
326
- }
327
- }
328
- }
329
- catch (Exception $e) {
330
- return false;
331
- }
332
- return false;
333
- }
334
-
335
-
336
- public function getQuickcost($quickCost,$quickcost_url = '') {
337
- if (!$quickcost_url) {
338
- //$quickcost_url = "http://wsshipping.chronopost.fr/wsQuickcost/services/ServiceQuickCost?wsdl";
339
- $quickcost_url = "https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl";
340
- }
341
- try {
342
- $client = new SoapClient($quickcost_url);
343
- $webservbt = $client->quickCost($quickCost);
344
-
345
- return $webservbt->return;
346
- } catch (Exception $e) {
347
- return false;
348
- }
349
- }
350
-
351
- public function checkLogin($quickCost,$quickcost_url = '') {
352
- if (!$quickcost_url) {
353
- $quickcost_url = "https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl";
354
- }
355
- try {
356
- $client = new SoapClient($quickcost_url);
357
- $webservbt = $client->calculateProducts($quickCost);
358
- return $webservbt;
359
- } catch (Exception $e) {
360
- return false;
361
- }
362
- }
363
-
364
- /*
365
- * Return true si la méthode de livraison fait partie du contrat
366
- */
367
- public function getMethodIsAllowed($code,$quote = '') {
368
- $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
369
- $address = $quote->getShippingAddress();
370
- $helperData = Mage::helper('chronorelais');
371
- $code = $helperData->getChronoProductCode('',$code);
372
- try {
373
- if($this->methodsAllowed === false) {
374
- $this->methodsAllowed = array();
375
- $client = new SoapClient("https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl", array('trace' => 0, 'connection_timeout' => 10));
376
- $params = array(
377
- 'accountNumber' => $helperData->getConfigurationAccountNumber(),
378
- 'password' => $helperData->getConfigurationAccountPass(),
379
- 'depCountryCode' => $helperData->getConfigurationShipperInfo('country'),
380
- 'depZipCode' => $helperData->getConfigurationShipperInfo('zipcode'),
381
- 'arrCountryCode' => $this->getFilledValue($address->getCountryId()),
382
- 'arrZipCode' => $this->getFilledValue($address->getPostcode()),
383
- 'arrCity' => $this->getFilledValue($address->getCity()),
384
- 'type' => 'M',
385
- 'weight' => 1
386
- );
387
- //print_r($params);
388
- $webservbt = $client->calculateProducts($params);
389
- //print_r($webservbt);
390
- if($webservbt->return->errorCode == 0)
391
- {
392
- if($webservbt->return->productList) {
393
- foreach($webservbt->return->productList as $product) {
394
- //echo $product->productCode.' ---- ';
395
- $this->methodsAllowed[] = $product->productCode;
396
- }
397
- }
398
- }
399
- }
400
- //print_r($this->methodsAllowed);
401
- if(!empty($this->methodsAllowed) && in_array($code, $this->methodsAllowed)) {
402
- return true;
403
- }
404
- return false;
405
- }catch(Exception $e) {
406
- return false;
407
- }
408
- }
409
-
410
-
411
-
412
-
413
-
414
-
415
-
416
-
417
-
418
- public function getFilledValue($value) {
419
- if ($value) {
420
- return $this->removeaccents(trim($value));
421
- } else {
422
- return '';
423
- }
424
- }
425
-
426
- public function removeaccents($string) {
427
- $stringToReturn = str_replace(
428
- array('à', 'á', 'â', 'ã', 'ä', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', '/', '\xa8'), array('a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', ' ', 'e'), $string);
429
- // Remove all remaining other unknown characters
430
- $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
431
- $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
432
- $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
433
- $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
434
- return $stringToReturn;
435
- }
436
- }
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Helper_Webservice extends Mage_Core_Helper_Abstract {
4
+
5
+ var $methodsAllowed = false;
6
+
7
+ public function getPointsRelaisByCp($cp) {
8
+
9
+ try {
10
+ $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl",array('trace'=> 0,'connection_timeout'=>10));
11
+ $webservbt = $client->__call("rechercheBtParCodeproduitEtCodepostalEtDate",array(0,$cp,0));
12
+ return $webservbt;
13
+ } catch (Exception $e) {
14
+ $webservbt = $this->getPointsRelaisByPudo('',$cp);
15
+ return $webservbt;
16
+ }
17
+ }
18
+
19
+ /* get point relais by address */
20
+ public function getPointRelaisByAddress() {
21
+
22
+ $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
23
+ $address = $quote->getShippingAddress();
24
+ $helperData = Mage::helper('chronorelais');
25
+
26
+ try {
27
+ $client = new SoapClient("https://www.chronopost.fr/recherchebt-ws-cxf/PointRelaisServiceWS?wsdl", array('trace' => 0, 'connection_timeout' => 10));
28
+
29
+ $params = array(
30
+ 'accountNumber' => $helperData->getConfigurationAccountNumber(),
31
+ 'password' => $helperData->getConfigurationAccountPass(),
32
+ 'address' => $this->getFilledValue($address->getStreet(1)),
33
+ 'zipCode' => $this->getFilledValue($address->getPostcode()),
34
+ 'city' => $this->getFilledValue($address->getCity()),
35
+ 'countryCode' => $this->getFilledValue($address->getCountryId()),
36
+ 'type' => 'P',
37
+ 'productCode' => '1',
38
+ 'service' => 'T',
39
+ 'weight' => 2000,
40
+ 'shippingDate' => date('d/m/Y'),
41
+ 'maxPointChronopost' => 5,
42
+ 'maxDistanceSearch' => 10,
43
+ 'holidayTolerant' => 1
44
+ );
45
+ $webservbt = $client->recherchePointChronopost($params);
46
+
47
+ /* format $webservbt pour avoir le meme format que lors de l'appel du WS par code postal */
48
+ if($webservbt->return->errorCode == 0)
49
+ {
50
+ /*
51
+ * Format entrée
52
+ *
53
+ * accesPersonneMobiliteReduite
54
+ actif
55
+ adresse1
56
+ adresse2
57
+ adresse3
58
+ codePays
59
+ codePostal
60
+ coordGeolocalisationLatitude
61
+ coordGeolocalisationLongitude
62
+ distanceEnMetre
63
+ identifiant
64
+ indiceDeLocalisation
65
+ listeHoraireOuverture
66
+ localite
67
+ nom
68
+ poidsMaxi
69
+ typeDePoint
70
+ urlGoogleMaps
71
+ *
72
+ * Format sortie
73
+ * adresse1
74
+ adresse2
75
+ adresse3
76
+ codePostal
77
+ dateArriveColis
78
+ horairesOuvertureDimanche ("10:00-12:30 14:30-19:00")
79
+ horairesOuvertureJeudi
80
+ horairesOuvertureLundi
81
+ horairesOuvertureMardi
82
+ horairesOuvertureMercredi
83
+ horairesOuvertureSamedi
84
+ horairesOuvertureVendredi
85
+ identifiantChronopostPointA2PAS
86
+ localite
87
+ nomEnseigne
88
+ *
89
+ *
90
+ *
91
+ * 2013-02-19T10:42:40.196Z
92
+ *
93
+ */
94
+ $listePr = $webservbt->return->listePointRelais;
95
+ $return = array();
96
+ foreach($listePr as $pr)
97
+ {
98
+ //$newPr = new object();
99
+ $newPr = (object)array();
100
+ $newPr->adresse1 = $pr->adresse1;
101
+ $newPr->adresse2 = $pr->adresse2;
102
+ $newPr->adresse3 = $pr->adresse3;
103
+ $newPr->codePostal = $pr->codePostal;
104
+ $newPr->identifiantChronopostPointA2PAS = $pr->identifiant;
105
+ $newPr->localite = $pr->localite;
106
+ $newPr->nomEnseigne = $pr->nom;
107
+ $time = new DateTime;
108
+ $newPr->dateArriveColis = $time->format(DateTime::ATOM);
109
+ $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
110
+ foreach($pr->listeHoraireOuverture as $horaire) {
111
+ switch($horaire->jour) {
112
+ case '1' : $newPr->horairesOuvertureLundi = $horaire->horairesAsString; break;
113
+ case '2' : $newPr->horairesOuvertureMardi = $horaire->horairesAsString; break;
114
+ case '3' : $newPr->horairesOuvertureMercredi = $horaire->horairesAsString; break;
115
+ case '4' : $newPr->horairesOuvertureJeudi = $horaire->horairesAsString; break;
116
+ case '5' : $newPr->horairesOuvertureVendredi = $horaire->horairesAsString; break;
117
+ case '6' : $newPr->horairesOuvertureSamedi = $horaire->horairesAsString; break;
118
+ case '7' : $newPr->horairesOuvertureDimanche = $horaire->horairesAsString; break;
119
+ }
120
+ }
121
+ if(empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
122
+ if(empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
123
+ if(empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
124
+ if(empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
125
+ if(empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
126
+ if(empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
127
+ if(empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
128
+
129
+ $return[] = $newPr;
130
+ }
131
+ return $return;
132
+ }
133
+ } catch (Exception $e) {
134
+ return $this->getPointsRelaisByPudo($address);
135
+ }
136
+ }
137
+
138
+ public function getDetailRelaisPoint($btcode) {
139
+ try {
140
+ $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl");
141
+ $webservbt = $client->__call("rechercheBtParIdChronopostA2Pas",array($btcode));
142
+ return $webservbt[0];
143
+ } catch (Exception $e) {
144
+ return $this->getDetailRelaisPointByPudo($btcode);
145
+ }
146
+ }
147
+
148
+
149
+ /*
150
+ *
151
+ * WS de secours
152
+ */
153
+
154
+ public function getDetailRelaisPointByPudo($btcode) {
155
+ $params = array(
156
+ 'carrier' => 'CHR',
157
+ 'key' => '75f6fe195dc88ceecbc0f8a2f70a8f3a',
158
+ 'pudo_id' => $btcode,
159
+ );
160
+
161
+ try {
162
+ $client = new SoapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?wsdl", array('trace' => 0, 'connection_timeout' => 10));
163
+ $webservbt = $client->GetPudoDetails($params);
164
+ $webservbt = json_decode(json_encode((object) simplexml_load_string($webservbt->GetPudoDetailsResult->any)), 1);
165
+ if(!isset($webservbt['ERROR'])) {
166
+ $return = array();
167
+ $pr = $webservbt['PUDO_ITEMS']['PUDO_ITEM'];
168
+ if($pr) {
169
+ if($pr['@attributes']['active'] == 'true')
170
+ {
171
+ $newPr = (object)array();
172
+ $newPr->adresse1 = $pr['ADDRESS1'];
173
+ $newPr->adresse2 = is_array($pr['ADDRESS2']) ? implode(' ', $pr['ADDRESS2']) : $pr['ADDRESS2'];
174
+ $newPr->adresse3 = is_array($pr['ADDRESS3']) ? implode(' ', $pr['ADDRESS3']) : $pr['ADDRESS3'];
175
+ $newPr->codePostal = $pr['ZIPCODE'];
176
+ $newPr->identifiantChronopostPointA2PAS = $pr['PUDO_ID'];
177
+ $newPr->localite = $pr['CITY'];
178
+ $newPr->nomEnseigne = $pr['NAME'];
179
+ $time = new DateTime;
180
+ $newPr->dateArriveColis = $time->format(DateTime::ATOM);
181
+ $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
182
+
183
+ if(isset($pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'])) {
184
+ $listeHoraires = $pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'];
185
+ foreach($listeHoraires as $horaire) {
186
+ switch($horaire['DAY_ID']) {
187
+ case '1' :
188
+ if(!empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi .= ' ';
189
+ $newPr->horairesOuvertureLundi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
190
+ break;
191
+ case '2' :
192
+ if(!empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi .= ' ';
193
+ $newPr->horairesOuvertureMardi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
194
+ break;
195
+ case '3' :
196
+ if(!empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi .= ' ';
197
+ $newPr->horairesOuvertureMercredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
198
+ break;
199
+ case '4' :
200
+ if(!empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi .= ' ';
201
+ $newPr->horairesOuvertureJeudi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
202
+ break;
203
+ case '5' :
204
+ if(!empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi .= ' ';
205
+ $newPr->horairesOuvertureVendredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
206
+ break;
207
+ case '6' :
208
+ if(!empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi .= ' ';
209
+ $newPr->horairesOuvertureSamedi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
210
+ break;
211
+ case '7' :
212
+ if(!empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche .= ' ';
213
+ $newPr->horairesOuvertureDimanche .= $horaire['START_TM'].'-'.$horaire['END_TM'];
214
+ break;
215
+ }
216
+ }
217
+ }
218
+ if(empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
219
+ if(empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
220
+ if(empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
221
+ if(empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
222
+ if(empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
223
+ if(empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
224
+ if(empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
225
+
226
+ return $newPr;
227
+ }
228
+ }
229
+ }
230
+ }
231
+ catch (Exception $e) {
232
+ return false;
233
+ }
234
+ return false;
235
+ }
236
+
237
+ public function getPointsRelaisByPudo($address = '', $cp = '') {
238
+
239
+ $params = array(
240
+ 'carrier' => 'CHR',
241
+ 'key' => '75f6fe195dc88ceecbc0f8a2f70a8f3a',
242
+ 'address' => $address ? $this->getFilledValue($address->getStreet(1)) : '',
243
+ 'zipCode' => $address ? $this->getFilledValue($address->getPostcode()) : $cp,
244
+ 'city' => $address ? $this->getFilledValue($address->getCity()) : 'Lille',
245
+ 'countrycode' => $address ? $this->getFilledValue($address->getCountryId()) : '',
246
+ 'requestID' => '1',
247
+ 'date_from' => date('d/m/Y'),
248
+ 'max_pudo_number' => 5,
249
+ 'max_distance_search' => 10,
250
+ 'weight' => 1,
251
+ 'category' => '',
252
+ 'holiday_tolerant' => 1,
253
+ );
254
+ try {
255
+ $client = new SoapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?wsdl", array('trace' => 0, 'connection_timeout' => 10));
256
+ $webservbt = $client->GetPudoList($params);
257
+ $webservbt = json_decode(json_encode((object) simplexml_load_string($webservbt->GetPudoListResult->any)), 1);
258
+ if(!isset($webservbt['ERROR'])) {
259
+ $return = array();
260
+
261
+ $listePr = $webservbt['PUDO_ITEMS']['PUDO_ITEM'];
262
+ if($listePr) {
263
+ foreach($listePr as $pr)
264
+ {
265
+ if($pr['@attributes']['active'] == 'true')
266
+ {
267
+ $newPr = (object)array();
268
+ $newPr->adresse1 = $pr['ADDRESS1'];
269
+ $newPr->adresse2 = is_array($pr['ADDRESS2']) ? implode(' ', $pr['ADDRESS2']) : $pr['ADDRESS2'];
270
+ $newPr->adresse3 = is_array($pr['ADDRESS3']) ? implode(' ', $pr['ADDRESS3']) : $pr['ADDRESS3'];
271
+ $newPr->codePostal = $pr['ZIPCODE'];
272
+ $newPr->identifiantChronopostPointA2PAS = $pr['PUDO_ID'];
273
+ $newPr->localite = $pr['CITY'];
274
+ $newPr->nomEnseigne = $pr['NAME'];
275
+ $time = new DateTime;
276
+ $newPr->dateArriveColis = $time->format(DateTime::ATOM);
277
+ $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
278
+
279
+ if(isset($pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'])) {
280
+ $listeHoraires = $pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'];
281
+ foreach($listeHoraires as $horaire) {
282
+ switch($horaire['DAY_ID']) {
283
+ case '1' :
284
+ if(!empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi .= ' ';
285
+ $newPr->horairesOuvertureLundi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
286
+ break;
287
+ case '2' :
288
+ if(!empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi .= ' ';
289
+ $newPr->horairesOuvertureMardi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
290
+ break;
291
+ case '3' :
292
+ if(!empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi .= ' ';
293
+ $newPr->horairesOuvertureMercredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
294
+ break;
295
+ case '4' :
296
+ if(!empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi .= ' ';
297
+ $newPr->horairesOuvertureJeudi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
298
+ break;
299
+ case '5' :
300
+ if(!empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi .= ' ';
301
+ $newPr->horairesOuvertureVendredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
302
+ break;
303
+ case '6' :
304
+ if(!empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi .= ' ';
305
+ $newPr->horairesOuvertureSamedi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
306
+ break;
307
+ case '7' :
308
+ if(!empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche .= ' ';
309
+ $newPr->horairesOuvertureDimanche .= $horaire['START_TM'].'-'.$horaire['END_TM'];
310
+ break;
311
+ }
312
+ }
313
+ }
314
+ if(empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
315
+ if(empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
316
+ if(empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
317
+ if(empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
318
+ if(empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
319
+ if(empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
320
+ if(empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
321
+
322
+ $return[] = $newPr;
323
+ }
324
+ }
325
+ return $return;
326
+ }
327
+ }
328
+ }
329
+ catch (Exception $e) {
330
+ return false;
331
+ }
332
+ return false;
333
+ }
334
+
335
+
336
+ public function getQuickcost($quickCost,$quickcost_url = '') {
337
+ if (!$quickcost_url) {
338
+ //$quickcost_url = "http://wsshipping.chronopost.fr/wsQuickcost/services/ServiceQuickCost?wsdl";
339
+ $quickcost_url = "https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl";
340
+ }
341
+ try {
342
+ $client = new SoapClient($quickcost_url);
343
+ $webservbt = $client->quickCost($quickCost);
344
+
345
+ return $webservbt->return;
346
+ } catch (Exception $e) {
347
+ return false;
348
+ }
349
+ }
350
+
351
+ public function checkLogin($quickCost,$quickcost_url = '') {
352
+ if (!$quickcost_url) {
353
+ $quickcost_url = "https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl";
354
+ }
355
+ try {
356
+ $client = new SoapClient($quickcost_url);
357
+ $webservbt = $client->calculateProducts($quickCost);
358
+ return $webservbt;
359
+ } catch (Exception $e) {
360
+ return false;
361
+ }
362
+ }
363
+
364
+ /*
365
+ * Return true si la méthode de livraison fait partie du contrat
366
+ */
367
+ public function getMethodIsAllowed($code,$quote = '') {
368
+ $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
369
+ $address = $quote->getShippingAddress();
370
+ $helperData = Mage::helper('chronorelais');
371
+ $code = $helperData->getChronoProductCode('',$code);
372
+ try {
373
+ if($this->methodsAllowed === false) {
374
+ $this->methodsAllowed = array();
375
+ $client = new SoapClient("https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl", array('trace' => 0, 'connection_timeout' => 10));
376
+ $params = array(
377
+ 'accountNumber' => $helperData->getConfigurationAccountNumber(),
378
+ 'password' => $helperData->getConfigurationAccountPass(),
379
+ 'depCountryCode' => $helperData->getConfigurationShipperInfo('country'),
380
+ 'depZipCode' => $helperData->getConfigurationShipperInfo('zipcode'),
381
+ 'arrCountryCode' => $this->getFilledValue($address->getCountryId()),
382
+ 'arrZipCode' => $this->getFilledValue($address->getPostcode()),
383
+ 'arrCity' => $this->getFilledValue($address->getCity()),
384
+ 'type' => 'M',
385
+ 'weight' => 1
386
+ );
387
+ //print_r($params);
388
+ $webservbt = $client->calculateProducts($params);
389
+ //print_r($webservbt);
390
+ if($webservbt->return->errorCode == 0)
391
+ {
392
+ /*if($webservbt->return->productList) {
393
+ foreach($webservbt->return->productList as $product) {
394
+ $this->methodsAllowed[] = $product->productCode;
395
+ }
396
+ }*/
397
+ if($webservbt->return->productList) {
398
+ if(is_array($webservbt->return->productList)) {
399
+ foreach($webservbt->return->productList as $product) {
400
+ $this->methodsAllowed[] = $product->productCode;
401
+ }
402
+ } else { /* cas ou il y a un seul résultat */
403
+ $product = $webservbt->return->productList;
404
+ $this->methodsAllowed[] = $product->productCode;
405
+ }
406
+
407
+ }
408
+ }
409
+ }
410
+ if(!empty($this->methodsAllowed) && in_array($code, $this->methodsAllowed)) {
411
+ return true;
412
+ }
413
+ return false;
414
+ }catch(Exception $e) {
415
+ return false;
416
+ }
417
+ }
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+ public function getFilledValue($value) {
428
+ if ($value) {
429
+ return $this->removeaccents(trim($value));
430
+ } else {
431
+ return '';
432
+ }
433
+ }
434
+
435
+ public function removeaccents($string) {
436
+ $stringToReturn = str_replace(
437
+ array('à', 'á', 'â', 'ã', 'ä', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', '/', '\xa8'), array('a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', ' ', 'e'), $string);
438
+ // Remove all remaining other unknown characters
439
+ $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
440
+ $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
441
+ $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
442
+ $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
443
+ return $stringToReturn;
444
+ }
445
+ }
app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelaisShipping.php CHANGED
@@ -1,523 +1,523 @@
1
- <?php
2
-
3
- /**
4
- * Magento Chronopost Chronorelais Module
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * @category Chronopost
17
- * @package Chronopost_Chronorelais
18
- * @copyright Copyright (c) 2008-10 Owebia (http://www.owebia.com/)
19
- * @author Antoine Lemoine
20
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
- */
22
-
23
- // Pour g�rer les cas o� il y a eu compilation
24
- if (file_exists(dirname(__FILE__).'/Chronopost_Chronorelais_includes_ChronorelaisShippingHelper.php')) include_once 'Chronopost_Chronorelais_includes_ChronorelaisShippingHelper.php';
25
- else include_once Mage::getBaseDir('code').'/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php';
26
-
27
-
28
-
29
- class OCS_Magento_Product implements OCS_Product {
30
- private $parent_cart_item;
31
- private $cart_item;
32
- private $cart_product;
33
- private $loaded_product;
34
- private $quantity;
35
-
36
- public function OCS_Magento_Product($cart_item, $parent_cart_item) {
37
- $this->cart_item = $cart_item;
38
- $this->cart_product = $cart_item->getProduct();
39
- $this->parent_cart_item = $parent_cart_item;
40
- $this->quantity = isset($parent_cart_item) ? $parent_cart_item->getQty() : $cart_item->getQty();
41
- }
42
-
43
- public function getOption($option_name, $get_by_id=false) {
44
- $value = null;
45
- $product = $this->cart_product;
46
- foreach ($product->getOptions() as $option) {
47
- if ($option->getTitle()==$option_name) {
48
- $custom_option = $product->getCustomOption('option_'.$option->getId());
49
- if ($custom_option) {
50
- $value = $custom_option->getValue();
51
- if ($option->getType()=='drop_down' && !$get_by_id) {
52
- $option_value = $option->getValueById($value);
53
- if ($option_value) $value = $option_value->getTitle();
54
- }
55
- }
56
- break;
57
- }
58
- }
59
- return $value;
60
- }
61
-
62
- public function getAttribute($attribute_name, $get_by_id=false) {
63
- $value = null;
64
- $product = $this->_getLoadedProduct();
65
- $attribute = $product->getResource()->getAttribute($attribute_name);
66
- if ($attribute) {
67
- $input_type = $attribute->getFrontend()->getInputType();
68
- switch ($input_type) {
69
- case 'select' :
70
- $value = $get_by_id ? $product->getData($attribute_name) : $product->getAttributeText($attribute_name);
71
- break;
72
- default :
73
- $value = $product->getData($attribute_name);
74
- break;
75
- }
76
- }
77
- return $value;
78
- }
79
-
80
- private function _getLoadedProduct() {
81
- if (!isset($this->loaded_product)) $this->loaded_product = Mage::getModel('catalog/product')->load($this->cart_product->getId());
82
- return $this->loaded_product;
83
- }
84
-
85
- public function getQuantity() {
86
- return $this->quantity;
87
- }
88
-
89
- public function getName() {
90
- return $this->cart_product->getName();
91
- }
92
-
93
- public function getSku() {
94
- return $this->cart_product->getSku();
95
- }
96
-
97
- public function getStockData($key) {
98
- $stock = $this->cart_product->getStockItem();
99
- switch ($key) {
100
- case 'is_in_stock':
101
- return (bool)$stock->getIsInStock();
102
- case 'quantity':
103
- $quantity = $stock->getQty();
104
- return $stock->getIsQtyDecimal() ? (float)$quantity : (int)$quantity;
105
- }
106
- return null;
107
- }
108
- }
109
-
110
- abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
111
- extends Mage_Shipping_Model_Carrier_Abstract
112
- {
113
- protected $_translate_inline;
114
- protected $_result;
115
- protected $_config;
116
- protected $_countries;
117
- protected $_helper;
118
- protected $_messages;
119
-
120
- /**
121
- * Collect rates for this shipping method based on information in $request
122
- *
123
- * @param Mage_Shipping_Model_Rate_Request $data
124
- * @return Mage_Shipping_Model_Rate_Result
125
- */
126
- public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
127
- // skip if not enabled
128
- if (!$this->__getConfigData('active')) return false;
129
-
130
- /*foreach ($request->_data as $key => $data) {
131
- echo $key.' => '.$data.'<br/>';
132
- }*/
133
- $helper = Mage::helper('chronorelais');
134
-
135
- $process = array(
136
- 'request' => $request,
137
- 'result' => Mage::getModel('shipping/rate_result'),
138
- 'cart.items' => array(),
139
- 'products' => array(),
140
- 'data' => array(
141
- 'module.version' => null,
142
- 'carrier.code' => $this->_code,
143
- 'cart.price_excluding_tax' => $request->_data['package_value_with_discount'],
144
- 'cart.price_including_tax' => null,
145
- 'cart.weight' => $request->_data['package_weight'],
146
- 'cart.weight.unit' => $helper->getConfigWeightUnit(),
147
- 'cart.quantity' => $request->_data['package_qty'],
148
- 'destination.country.code' => $request->_data['dest_country_id'],
149
- 'destination.country.name' => null,
150
- 'destination.region.code' => $request->_data['dest_region_code'],
151
- 'destination.postcode' => $request->_data['dest_postcode'],
152
- 'origin.country.code' => $request->_data['country_id'],
153
- 'origin.country.name' => null,
154
- 'origin.region.code' => $request->_data['region_id'],
155
- 'origin.postcode' => $request->_data['postcode'],
156
- 'customer.group.id' => null,
157
- 'customer.group.code' => null,
158
- 'free_shipping' => $request->getFreeShipping(),
159
- 'store.id' => $request->_data['store_id'],
160
- 'store.code' => null,
161
- 'store.name' => null,
162
- 'store.address' => null,
163
- 'store.phone' => null,
164
- 'date.timestamp' => null,
165
- 'date.year' => null,
166
- 'date.month' => null,
167
- 'date.day' => null,
168
- 'date.hour' => null,
169
- 'date.minute' => null,
170
- 'date.second' => null,
171
- ),
172
- 'stop_to_first_match' => null,
173
- 'config' => null,
174
- );
175
-
176
- $items = $request->getAllItems();
177
- for ($i=0, $n=count($items); $i<$n; $i++) {
178
- $item = $items[$i];
179
- if ($item->getProduct() instanceof Mage_Catalog_Model_Product) $process['cart.items'][$item->getId()] = $item;
180
- }
181
-
182
- $process_result = $this->_process($process);
183
-
184
- return $process['result'];
185
- }
186
-
187
-
188
- public function getAllowedMethods() {
189
- $process = array();
190
- $config = $this->_getConfig();
191
- $allowed_methods = array();
192
- if (count($config)>0) {
193
- foreach ($config as $row) $allowed_methods[$row['*code']] = isset($row['label']) ? $row['label']['value'] : 'No label';
194
- }
195
- return $allowed_methods;
196
- }
197
-
198
- public function isTrackingAvailable() {
199
- return true;
200
- }
201
-
202
- public function getTrackingInfo($tracking_number) {
203
- $tracking_url = Mage::helper('chronorelais')->getConfigurationTrackingViewUrl();
204
- $parts = explode(':',$tracking_number);
205
- if (count($parts)>=2) {
206
- $tracking_number = $parts[1];
207
-
208
- $process = array();
209
- $config = $this->_getConfig();
210
-
211
- if (isset($config[$parts[0]]['tracking_url'])) {
212
- $row = $config[$parts[0]];
213
- $tmp_tracking_url = $this->_helper->getRowProperty($row,'tracking_url');
214
- if (isset($tmp_tracking_url)) $tracking_url = $tmp_tracking_url;
215
- }
216
- }
217
-
218
- $tracking_status = Mage::getModel('shipping/tracking_result_status')
219
- ->setCarrier($this->_code)
220
- ->setCarrierTitle($this->__getConfigData('title'))
221
- ->setTracking($tracking_number)
222
- ->addData(
223
- array(
224
- 'status'=>'<a target="_blank" href="'.str_replace('{tracking_number}',$tracking_number,$tracking_url).'">'.__('track the package').'</a>'
225
- )
226
- )
227
- ;
228
- $tracking_result = Mage::getModel('shipping/tracking_result')
229
- ->append($tracking_status)
230
- ;
231
-
232
- if ($trackings = $tracking_result->getAllTrackings()) return $trackings[0];
233
- return false;
234
- }
235
-
236
-
237
- /***************************************************************************************************************************/
238
-
239
- protected function _process(&$process) {
240
- $store = Mage::app()->getStore($process['data']['store.id']);
241
- $mage_config = Mage::getConfig();
242
- $timestamp = time();
243
- $customer_group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();
244
- $helper = Mage::helper('chronorelais');
245
- // Pour les commandes depuis Adminhtml
246
- if ($customer_group_id==0) {
247
- $customer_group_id2 = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getCustomerGroupId();
248
- if (isset($customer_group_id2)) $customer_group_id = $customer_group_id2;
249
- }
250
-
251
- $customer_group_code = Mage::getSingleton('customer/group')->load($customer_group_id)->getData('customer_group_code');
252
- $process['data'] = array_merge($process['data'],array(
253
- 'customer.group.id' => $customer_group_id,
254
- 'customer.group.code' => $customer_group_code,
255
- 'destination.country.name' => $this->__getCountryName($process['data']['destination.country.code']),
256
- 'origin.country.name' => $this->__getCountryName($process['data']['origin.country.code']),
257
- 'cart.weight.unit' => $helper->getConfigWeightUnit(),/*Mage::getStoreConfig('chronorelais/shipping/weight_unit')*/
258
- 'store.code' => $store->getCode(),
259
- 'store.name' => $store->getConfig('general/store_information/name'),
260
- 'store.address' => $store->getConfig('general/store_information/address'),
261
- 'store.phone' => $store->getConfig('general/store_information/phone'),
262
- 'date.timestamp' => $timestamp,
263
- 'date.year' => (int)date('Y',$timestamp),
264
- 'date.month' => (int)date('m',$timestamp),
265
- 'date.day' => (int)date('d',$timestamp),
266
- 'date.hour' => (int)date('H',$timestamp),
267
- 'date.minute' => (int)date('i',$timestamp),
268
- 'date.second' => (int)date('s',$timestamp),
269
- 'module.version' => (string)$mage_config->getNode('modules/Chronopost_Chronorelais/version'),
270
- ));
271
-
272
- $weight_limit = $this->__getConfigData('weight_limit'); /* weight_limit in kg */
273
- $productWeightOverLimit = false;
274
-
275
- foreach ($process['cart.items'] as $id => $item) {
276
- if ($item->getProduct()->getTypeId()!='configurable') {
277
- $parent_item_id = $item->getParentItemId();
278
- $itemWeight = $item->getWeight();
279
- if($helper->getConfigWeightUnit() == 'g')
280
- {
281
- $itemWeight = $itemWeight / 1000; // conversion g => kg
282
- }
283
- if($itemWeight > $weight_limit) {
284
- $productWeightOverLimit = true;
285
- }
286
- $process['products'][] = new OCS_Magento_Product($item, isset($process['cart.items'][$parent_item_id]) ? $process['cart.items'][$parent_item_id] : null);
287
- }
288
- }
289
-
290
- if (!$process['data']['free_shipping']) {
291
- foreach ($process['cart.items'] as $item) {
292
- if ($item->getProduct() instanceof Mage_Catalog_Model_Product) {
293
- if ($item->getFreeShipping()) $process['data']['free_shipping'] = true;
294
- else {
295
- $process['data']['free_shipping'] = false;
296
- break;
297
- }
298
- }
299
- }
300
- }
301
-
302
- $process['data']['cart.price_including_tax'] = $this->__getCartTaxAmount($process)+$process['data']['cart.price_excluding_tax'];
303
- $process['stop_to_first_match'] = $this->__getConfigData('stop_to_first_match');
304
- $process['config'] = $this->_getConfig();
305
- $compression = $this->__getConfigData('auto_compression');
306
- if ($compression=='compress') {
307
- Mage::getConfig()->saveConfig('carriers/'.$this->_code.'/config',$this->_helper->formatConfig(true));
308
- } else if ($compression=='uncompress') {
309
- Mage::getConfig()->saveConfig('carriers/'.$this->_code.'/config',$this->_helper->formatConfig(false));
310
- }
311
-
312
- $this->_helper->debug = (int)(isset($_GET['debug']) ? $_GET['debug'] : $this->__getConfigData('debug'));
313
- $http_request = Mage::app()->getFrontController()->getRequest();
314
- $this->_helper->debug = $this->_helper->debug && $http_request->getRouteName()=='checkout' && $http_request->getControllerName()=='cart';
315
- if ($this->_helper->debug) $this->_helper->setDebugHeader($process);
316
-
317
- $value_found = false;
318
- $process_continue = true;
319
-
320
- //Set error messages if not any matching
321
- /*$errorMsg = '';
322
- $defaultErrorMsg = Mage::helper('shipping')->__('The shipping module is not available.');
323
- $configErrorMsg = $this->__getConfigData('specificerrmsg');
324
- $configErrorMsg = ($configErrorMsg ? $configErrorMsg : $defaultErrorMsg);*/
325
- $freeShippingEnable = $this->__getConfigData('free_shipping_enable');
326
- $freeShippingSubtotal = $this->__getConfigData('free_shipping_subtotal');
327
- $applicationFee = $this->__getConfigData('application_fee');
328
- $handlingFee = $this->__getConfigData('handling_fee');
329
-
330
- /* On autorise chronopost > 30 Kg si tous les produits sont <= 30 Kg */
331
- if($productWeightOverLimit) {
332
- $value_found = false;
333
- $process_continue = false;
334
- }
335
-
336
- $helperWS = Mage::helper('chronorelais/webservice');
337
- /* Si Chronorelais => test Si WS fonctionne */
338
- if($this->_code == 'chronorelais') {
339
- $shippingAddress = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getShippingAddress();
340
- $webservice = $helperWS->getPointsRelaisByCp($shippingAddress->getPostcode());
341
- if($webservice === false) {
342
- $value_found = false;
343
- $process_continue = false;
344
- }
345
- }
346
-
347
- /* Si C10, CClassic ou C18 => On vérifie si la méthode fait partie du contrat */
348
- $methodsToCheck = array('chronopostc18','chronopostc10','chronopostcclassic');
349
- if(in_array($this->_code, $methodsToCheck))
350
- {
351
- $isAllowed = $helperWS->getMethodIsAllowed($this->_code);
352
- if($isAllowed === false) {
353
- $value_found = false;
354
- $process_continue = false;
355
- }
356
- }
357
-
358
- if($process_continue) {
359
- foreach ($process['config'] as $row) {
360
- $result = $this->_helper->processRow($process,$row);
361
- $this->_addMessages($this->_helper->getMessages());
362
- if ($result && $result->success) {
363
- $value_found = true;
364
- $fees = $result->result;
365
- if($applicationFee) { $fees += $applicationFee; }
366
- if($handlingFee) { $fees += $handlingFee; }
367
- if($freeShippingEnable && ($freeShippingSubtotal<=$process['data']['cart.price_excluding_tax'])) {
368
- $fees = 0;
369
- }
370
- $this->__appendMethod($process,$row,$fees);
371
- if ($process['stop_to_first_match']) break;
372
- }
373
- }
374
- }
375
-
376
- $this->_helper->printDebug();
377
-
378
- //$this->_appendErrors($process,$this->_messages);
379
- //if (!$value_found) $this->__appendError($process,$this->__($configErrorMsg));
380
- }
381
-
382
- protected function _getConfig() {
383
- if (!isset($this->_config)) {
384
- $this->_helper = new ChronorelaisShippingHelper($this->__getConfigData('config'));
385
- $this->_config = $this->_helper->getConfig();
386
- $this->_addMessages($this->_helper->getMessages());
387
- }
388
- return $this->_config;
389
- }
390
-
391
- protected function _getMethodText($process, $row, $property) {
392
- if (!isset($row[$property])) return '';
393
-
394
- $output = '';
395
- /*$i = 0;
396
- foreach ($process['request']->_data as $key => $data) {
397
- if ($i>12) $output .= $key.' => '.$data.'<br/>';
398
- $i++;
399
- }*/
400
-
401
- return $output . ' '.$this->_helper->evalInput($process,$row,$property,str_replace(
402
- array('{cart.weight}','{cart.price_including_tax}','{cart.price_excluding_tax}'),
403
- array(
404
- $process['data']['cart.weight'].$process['data']['cart.weight.unit'],
405
- $this->__formatPrice($process['data']['cart.price_including_tax']),
406
- $this->__formatPrice($process['data']['cart.price_excluding_tax'])
407
- ),
408
- $this->_helper->getRowProperty($row,$property)
409
- ));
410
- }
411
-
412
- protected function _addMessages($messages) {
413
- if (!is_array($messages)) $messages = array($messages);
414
- if (!is_array($this->_messages)) $this->_messages = $messages;
415
- else $this->_messages = array_merge($this->_messages,$messages);
416
- }
417
-
418
- protected function _appendErrors(&$process, $messages) {
419
- if (is_array($messages)) {
420
- foreach ($messages as $message) {
421
- $this->__appendError($process,$this->__($message));
422
- }
423
- }
424
- }
425
-
426
- /***************************************************************************************************************************/
427
-
428
- protected function __getConfigData($key) {
429
- return $this->getConfigData($key);
430
- }
431
-
432
- protected function __appendMethod(&$process, $row, $fees) {
433
- $method = Mage::getModel('shipping/rate_result_method')
434
- ->setCarrier($this->_code)
435
- ->setCarrierTitle($this->__getConfigData('title'))
436
- ->setMethod($row['*code'])
437
- ->setMethodTitle($this->_getMethodText($process,$row,'label'))
438
- ->setMethodDescription($this->_getMethodText($process,$row,'description'))
439
- ->setMethodLogo($this->__getConfigData('logo_url'))
440
- ->setPrice($fees)
441
- ->setCost($fees)
442
- ;
443
- $process['result']->append($method);
444
- }
445
-
446
- protected function __appendError(&$process, $message) {
447
- if (isset($process['result'])) {
448
- $error = Mage::getModel('shipping/rate_result_error')
449
- ->setCarrier($this->_code)
450
- ->setCarrierTitle($this->__getConfigData('title'))
451
- ->setErrorMessage($message)
452
- ;
453
- $process['result']->append($error);
454
- }
455
- }
456
-
457
- protected function __formatPrice($price) {
458
- if (!isset($this->_core_helper)) $this->_core_helper = Mage::helper('core');
459
- return $this->_core_helper->currency($price);
460
- }
461
-
462
- protected function __($message) {
463
- $args = func_get_args();
464
- $message = array_shift($args);
465
- if ($message instanceof OCS_Message) {
466
- $args = $message->args;
467
- $message = $message->message;
468
- }
469
-
470
- $output = Mage::helper('shipping')->__($message);
471
- if (count($args)==0) return $output;
472
-
473
- if (!isset($this->_translate_inline)) $this->_translate_inline = Mage::getSingleton('core/translate')->getTranslateInline();
474
- if ($this->_translate_inline) {
475
- $parts = explode('}}{{',$output);
476
- $parts[0] = vsprintf($parts[0],$args);
477
- return implode('}}{{',$parts);
478
- }
479
- else return vsprintf($output,$args);
480
- }
481
-
482
- protected function __getCountryName($country_code) {
483
- return Mage::getModel('directory/country')->load($country_code)->getName();
484
- //return Mage::app()->getLocale()->getCountryTranslation($country_code);
485
- /*if (!isset($this->_countries)) {
486
- // deprecated
487
- //$this->_countries = Mage::getModel('core/locale')->getLocale()->getCountryTranslationList();
488
- $this->_countries = Mage::getModel('core/locale')->getLocale()->getTranslationList('territory',null,2);
489
- }
490
- return isset($this->_countries[$country_code]) ? $this->_countries[$country_code] : $country_code;*/
491
- }
492
-
493
- /*
494
- protected function __getCartTaxAmount($process) {
495
- $tax_amount = 0;
496
-
497
- foreach ($process['cart.items'] as $item) {
498
- $tax_class_id = $item->getProduct()->getTaxClassId();
499
- $request = Mage::getSingleton('tax/calculation')->getRateRequest();
500
- $request->setProductClassId($tax_class_id);
501
- $vat_rate = Mage::getSingleton('tax/calculation')->getRate($request);
502
- $vat_rate = isset($rates[$tax_class_id]) ? $rates[$tax_class_id] : 0;
503
-
504
- if ($vat_rate > 0) $vat_to_add = $item->getData('row_total_with_discount')*$vat_rate/100;
505
- else $vat_to_add = $item->getData('tax_amount');
506
- //echo $item->getProduct()->getName().', '.$item->getData('row_total_with_discount').', '.$vat_rate.', '.$vat_to_add.'<br />';
507
- $tax_amount += $vat_to_add;
508
- }
509
- //echo 'tax:'.$tax_amount.'<br />';
510
- return $tax_amount;
511
- }
512
- */
513
-
514
- protected function __getCartTaxAmount($process) {
515
- $tax_amount = 0;
516
- foreach ($process['cart.items'] as $item) {
517
- $tax_amount += $item->getData('tax_amount');
518
- }
519
- return $tax_amount;
520
- }
521
- }
522
-
523
  ?>
1
+ <?php
2
+
3
+ /**
4
+ * Magento Chronopost Chronorelais Module
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Chronopost
17
+ * @package Chronopost_Chronorelais
18
+ * @copyright Copyright (c) 2008-10 Owebia (http://www.owebia.com/)
19
+ * @author Antoine Lemoine
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ // Pour g�rer les cas o� il y a eu compilation
24
+ if (file_exists(dirname(__FILE__).'/Chronopost_Chronorelais_includes_ChronorelaisShippingHelper.php')) include_once 'Chronopost_Chronorelais_includes_ChronorelaisShippingHelper.php';
25
+ else include_once Mage::getBaseDir('code').'/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php';
26
+
27
+
28
+
29
+ class OCS_Magento_Product implements OCS_Product {
30
+ private $parent_cart_item;
31
+ private $cart_item;
32
+ private $cart_product;
33
+ private $loaded_product;
34
+ private $quantity;
35
+
36
+ public function OCS_Magento_Product($cart_item, $parent_cart_item) {
37
+ $this->cart_item = $cart_item;
38
+ $this->cart_product = $cart_item->getProduct();
39
+ $this->parent_cart_item = $parent_cart_item;
40
+ $this->quantity = isset($parent_cart_item) ? $parent_cart_item->getQty() : $cart_item->getQty();
41
+ }
42
+
43
+ public function getOption($option_name, $get_by_id=false) {
44
+ $value = null;
45
+ $product = $this->cart_product;
46
+ foreach ($product->getOptions() as $option) {
47
+ if ($option->getTitle()==$option_name) {
48
+ $custom_option = $product->getCustomOption('option_'.$option->getId());
49
+ if ($custom_option) {
50
+ $value = $custom_option->getValue();
51
+ if ($option->getType()=='drop_down' && !$get_by_id) {
52
+ $option_value = $option->getValueById($value);
53
+ if ($option_value) $value = $option_value->getTitle();
54
+ }
55
+ }
56
+ break;
57
+ }
58
+ }
59
+ return $value;
60
+ }
61
+
62
+ public function getAttribute($attribute_name, $get_by_id=false) {
63
+ $value = null;
64
+ $product = $this->_getLoadedProduct();
65
+ $attribute = $product->getResource()->getAttribute($attribute_name);
66
+ if ($attribute) {
67
+ $input_type = $attribute->getFrontend()->getInputType();
68
+ switch ($input_type) {
69
+ case 'select' :
70
+ $value = $get_by_id ? $product->getData($attribute_name) : $product->getAttributeText($attribute_name);
71
+ break;
72
+ default :
73
+ $value = $product->getData($attribute_name);
74
+ break;
75
+ }
76
+ }
77
+ return $value;
78
+ }
79
+
80
+ private function _getLoadedProduct() {
81
+ if (!isset($this->loaded_product)) $this->loaded_product = Mage::getModel('catalog/product')->load($this->cart_product->getId());
82
+ return $this->loaded_product;
83
+ }
84
+
85
+ public function getQuantity() {
86
+ return $this->quantity;
87
+ }
88
+
89
+ public function getName() {
90
+ return $this->cart_product->getName();
91
+ }
92
+
93
+ public function getSku() {
94
+ return $this->cart_product->getSku();
95
+ }
96
+
97
+ public function getStockData($key) {
98
+ $stock = $this->cart_product->getStockItem();
99
+ switch ($key) {
100
+ case 'is_in_stock':
101
+ return (bool)$stock->getIsInStock();
102
+ case 'quantity':
103
+ $quantity = $stock->getQty();
104
+ return $stock->getIsQtyDecimal() ? (float)$quantity : (int)$quantity;
105
+ }
106
+ return null;
107
+ }
108
+ }
109
+
110
+ abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
111
+ extends Mage_Shipping_Model_Carrier_Abstract
112
+ {
113
+ protected $_translate_inline;
114
+ protected $_result;
115
+ protected $_config;
116
+ protected $_countries;
117
+ protected $_helper;
118
+ protected $_messages;
119
+
120
+ /**
121
+ * Collect rates for this shipping method based on information in $request
122
+ *
123
+ * @param Mage_Shipping_Model_Rate_Request $data
124
+ * @return Mage_Shipping_Model_Rate_Result
125
+ */
126
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
127
+ // skip if not enabled
128
+ if (!$this->__getConfigData('active')) return false;
129
+
130
+ /*foreach ($request->_data as $key => $data) {
131
+ echo $key.' => '.$data.'<br/>';
132
+ }*/
133
+ $helper = Mage::helper('chronorelais');
134
+
135
+ $process = array(
136
+ 'request' => $request,
137
+ 'result' => Mage::getModel('shipping/rate_result'),
138
+ 'cart.items' => array(),
139
+ 'products' => array(),
140
+ 'data' => array(
141
+ 'module.version' => null,
142
+ 'carrier.code' => $this->_code,
143
+ 'cart.price_excluding_tax' => $request->_data['package_value_with_discount'],
144
+ 'cart.price_including_tax' => null,
145
+ 'cart.weight' => $request->_data['package_weight'],
146
+ 'cart.weight.unit' => $helper->getConfigWeightUnit(),
147
+ 'cart.quantity' => $request->_data['package_qty'],
148
+ 'destination.country.code' => $request->_data['dest_country_id'],
149
+ 'destination.country.name' => null,
150
+ 'destination.region.code' => $request->_data['dest_region_code'],
151
+ 'destination.postcode' => $request->_data['dest_postcode'],
152
+ 'origin.country.code' => $request->_data['country_id'],
153
+ 'origin.country.name' => null,
154
+ 'origin.region.code' => $request->_data['region_id'],
155
+ 'origin.postcode' => $request->_data['postcode'],
156
+ 'customer.group.id' => null,
157
+ 'customer.group.code' => null,
158
+ 'free_shipping' => $request->getFreeShipping(),
159
+ 'store.id' => $request->_data['store_id'],
160
+ 'store.code' => null,
161
+ 'store.name' => null,
162
+ 'store.address' => null,
163
+ 'store.phone' => null,
164
+ 'date.timestamp' => null,
165
+ 'date.year' => null,
166
+ 'date.month' => null,
167
+ 'date.day' => null,
168
+ 'date.hour' => null,
169
+ 'date.minute' => null,
170
+ 'date.second' => null,
171
+ ),
172
+ 'stop_to_first_match' => null,
173
+ 'config' => null,
174
+ );
175
+
176
+ $items = $request->getAllItems();
177
+ for ($i=0, $n=count($items); $i<$n; $i++) {
178
+ $item = $items[$i];
179
+ if ($item->getProduct() instanceof Mage_Catalog_Model_Product) $process['cart.items'][$item->getId()] = $item;
180
+ }
181
+
182
+ $process_result = $this->_process($process);
183
+
184
+ return $process['result'];
185
+ }
186
+
187
+
188
+ public function getAllowedMethods() {
189
+ $process = array();
190
+ $config = $this->_getConfig();
191
+ $allowed_methods = array();
192
+ if (count($config)>0) {
193
+ foreach ($config as $row) $allowed_methods[$row['*code']] = isset($row['label']) ? $row['label']['value'] : 'No label';
194
+ }
195
+ return $allowed_methods;
196
+ }
197
+
198
+ public function isTrackingAvailable() {
199
+ return true;
200
+ }
201
+
202
+ public function getTrackingInfo($tracking_number) {
203
+ $tracking_url = Mage::helper('chronorelais')->getConfigurationTrackingViewUrl();
204
+ $parts = explode(':',$tracking_number);
205
+ if (count($parts)>=2) {
206
+ $tracking_number = $parts[1];
207
+
208
+ $process = array();
209
+ $config = $this->_getConfig();
210
+
211
+ if (isset($config[$parts[0]]['tracking_url'])) {
212
+ $row = $config[$parts[0]];
213
+ $tmp_tracking_url = $this->_helper->getRowProperty($row,'tracking_url');
214
+ if (isset($tmp_tracking_url)) $tracking_url = $tmp_tracking_url;
215
+ }
216
+ }
217
+
218
+ $tracking_status = Mage::getModel('shipping/tracking_result_status')
219
+ ->setCarrier($this->_code)
220
+ ->setCarrierTitle($this->__getConfigData('title'))
221
+ ->setTracking($tracking_number)
222
+ ->addData(
223
+ array(
224
+ 'status'=>'<a target="_blank" href="'.str_replace('{tracking_number}',$tracking_number,$tracking_url).'">'.__('track the package').'</a>'
225
+ )
226
+ )
227
+ ;
228
+ $tracking_result = Mage::getModel('shipping/tracking_result')
229
+ ->append($tracking_status)
230
+ ;
231
+
232
+ if ($trackings = $tracking_result->getAllTrackings()) return $trackings[0];
233
+ return false;
234
+ }
235
+
236
+
237
+ /***************************************************************************************************************************/
238
+
239
+ protected function _process(&$process) {
240
+ $store = Mage::app()->getStore($process['data']['store.id']);
241
+ $mage_config = Mage::getConfig();
242
+ $timestamp = time();
243
+ $customer_group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();
244
+ $helper = Mage::helper('chronorelais');
245
+ // Pour les commandes depuis Adminhtml
246
+ if ($customer_group_id==0) {
247
+ $customer_group_id2 = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getCustomerGroupId();
248
+ if (isset($customer_group_id2)) $customer_group_id = $customer_group_id2;
249
+ }
250
+
251
+ $customer_group_code = Mage::getSingleton('customer/group')->load($customer_group_id)->getData('customer_group_code');
252
+ $process['data'] = array_merge($process['data'],array(
253
+ 'customer.group.id' => $customer_group_id,
254
+ 'customer.group.code' => $customer_group_code,
255
+ 'destination.country.name' => $this->__getCountryName($process['data']['destination.country.code']),
256
+ 'origin.country.name' => $this->__getCountryName($process['data']['origin.country.code']),
257
+ 'cart.weight.unit' => $helper->getConfigWeightUnit(),/*Mage::getStoreConfig('chronorelais/shipping/weight_unit')*/
258
+ 'store.code' => $store->getCode(),
259
+ 'store.name' => $store->getConfig('general/store_information/name'),
260
+ 'store.address' => $store->getConfig('general/store_information/address'),
261
+ 'store.phone' => $store->getConfig('general/store_information/phone'),
262
+ 'date.timestamp' => $timestamp,
263
+ 'date.year' => (int)date('Y',$timestamp),
264
+ 'date.month' => (int)date('m',$timestamp),
265
+ 'date.day' => (int)date('d',$timestamp),
266
+ 'date.hour' => (int)date('H',$timestamp),
267
+ 'date.minute' => (int)date('i',$timestamp),
268
+ 'date.second' => (int)date('s',$timestamp),
269
+ 'module.version' => (string)$mage_config->getNode('modules/Chronopost_Chronorelais/version'),
270
+ ));
271
+
272
+ $weight_limit = $this->__getConfigData('weight_limit'); /* weight_limit in kg */
273
+ $productWeightOverLimit = false;
274
+
275
+ foreach ($process['cart.items'] as $id => $item) {
276
+ if ($item->getProduct()->getTypeId()!='configurable') {
277
+ $parent_item_id = $item->getParentItemId();
278
+ $itemWeight = $item->getWeight();
279
+ if($helper->getConfigWeightUnit() == 'g')
280
+ {
281
+ $itemWeight = $itemWeight / 1000; // conversion g => kg
282
+ }
283
+ if($itemWeight > $weight_limit) {
284
+ $productWeightOverLimit = true;
285
+ }
286
+ $process['products'][] = new OCS_Magento_Product($item, isset($process['cart.items'][$parent_item_id]) ? $process['cart.items'][$parent_item_id] : null);
287
+ }
288
+ }
289
+
290
+ if (!$process['data']['free_shipping']) {
291
+ foreach ($process['cart.items'] as $item) {
292
+ if ($item->getProduct() instanceof Mage_Catalog_Model_Product) {
293
+ if ($item->getFreeShipping()) $process['data']['free_shipping'] = true;
294
+ else {
295
+ $process['data']['free_shipping'] = false;
296
+ break;
297
+ }
298
+ }
299
+ }
300
+ }
301
+
302
+ $process['data']['cart.price_including_tax'] = $this->__getCartTaxAmount($process)+$process['data']['cart.price_excluding_tax'];
303
+ $process['stop_to_first_match'] = $this->__getConfigData('stop_to_first_match');
304
+ $process['config'] = $this->_getConfig();
305
+ $compression = $this->__getConfigData('auto_compression');
306
+ if ($compression=='compress') {
307
+ Mage::getConfig()->saveConfig('carriers/'.$this->_code.'/config',$this->_helper->formatConfig(true));
308
+ } else if ($compression=='uncompress') {
309
+ Mage::getConfig()->saveConfig('carriers/'.$this->_code.'/config',$this->_helper->formatConfig(false));
310
+ }
311
+
312
+ $this->_helper->debug = (int)(isset($_GET['debug']) ? $_GET['debug'] : $this->__getConfigData('debug'));
313
+ $http_request = Mage::app()->getFrontController()->getRequest();
314
+ $this->_helper->debug = $this->_helper->debug && $http_request->getRouteName()=='checkout' && $http_request->getControllerName()=='cart';
315
+ if ($this->_helper->debug) $this->_helper->setDebugHeader($process);
316
+
317
+ $value_found = false;
318
+ $process_continue = true;
319
+
320
+ //Set error messages if not any matching
321
+ /*$errorMsg = '';
322
+ $defaultErrorMsg = Mage::helper('shipping')->__('The shipping module is not available.');
323
+ $configErrorMsg = $this->__getConfigData('specificerrmsg');
324
+ $configErrorMsg = ($configErrorMsg ? $configErrorMsg : $defaultErrorMsg);*/
325
+ $freeShippingEnable = $this->__getConfigData('free_shipping_enable');
326
+ $freeShippingSubtotal = $this->__getConfigData('free_shipping_subtotal');
327
+ $applicationFee = $this->__getConfigData('application_fee');
328
+ $handlingFee = $this->__getConfigData('handling_fee');
329
+
330
+ /* On autorise chronopost > 30 Kg si tous les produits sont <= 30 Kg */
331
+ if($productWeightOverLimit) {
332
+ $value_found = false;
333
+ $process_continue = false;
334
+ }
335
+
336
+ $helperWS = Mage::helper('chronorelais/webservice');
337
+ /* Si Chronorelais => test Si WS fonctionne */
338
+ if($this->_code == 'chronorelais') {
339
+ $shippingAddress = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getShippingAddress();
340
+ $webservice = $helperWS->getPointsRelaisByCp($shippingAddress->getPostcode());
341
+ if($webservice === false) {
342
+ $value_found = false;
343
+ $process_continue = false;
344
+ }
345
+ }
346
+
347
+ /* Si C10, CClassic ou C18 => On vérifie si la méthode fait partie du contrat */
348
+ $methodsToCheck = array('chronopostc18','chronopostc10','chronopostcclassic');
349
+ if(in_array($this->_code, $methodsToCheck))
350
+ {
351
+ $isAllowed = $helperWS->getMethodIsAllowed($this->_code);
352
+ if($isAllowed === false) {
353
+ $value_found = false;
354
+ $process_continue = false;
355
+ }
356
+ }
357
+
358
+ if($process_continue) {
359
+ foreach ($process['config'] as $row) {
360
+ $result = $this->_helper->processRow($process,$row);
361
+ $this->_addMessages($this->_helper->getMessages());
362
+ if ($result && $result->success) {
363
+ $value_found = true;
364
+ $fees = $result->result;
365
+ if($applicationFee) { $fees += $applicationFee; }
366
+ if($handlingFee) { $fees += $handlingFee; }
367
+ if($freeShippingEnable && ($freeShippingSubtotal<=$process['data']['cart.price_excluding_tax'])) {
368
+ $fees = 0;
369
+ }
370
+ $this->__appendMethod($process,$row,$fees);
371
+ if ($process['stop_to_first_match']) break;
372
+ }
373
+ }
374
+ }
375
+
376
+ $this->_helper->printDebug();
377
+
378
+ //$this->_appendErrors($process,$this->_messages);
379
+ //if (!$value_found) $this->__appendError($process,$this->__($configErrorMsg));
380
+ }
381
+
382
+ protected function _getConfig() {
383
+ if (!isset($this->_config)) {
384
+ $this->_helper = new ChronorelaisShippingHelper($this->__getConfigData('config'));
385
+ $this->_config = $this->_helper->getConfig();
386
+ $this->_addMessages($this->_helper->getMessages());
387
+ }
388
+ return $this->_config;
389
+ }
390
+
391
+ protected function _getMethodText($process, $row, $property) {
392
+ if (!isset($row[$property])) return '';
393
+
394
+ $output = '';
395
+ /*$i = 0;
396
+ foreach ($process['request']->_data as $key => $data) {
397
+ if ($i>12) $output .= $key.' => '.$data.'<br/>';
398
+ $i++;
399
+ }*/
400
+
401
+ return $output . ' '.$this->_helper->evalInput($process,$row,$property,str_replace(
402
+ array('{cart.weight}','{cart.price_including_tax}','{cart.price_excluding_tax}'),
403
+ array(
404
+ $process['data']['cart.weight'].$process['data']['cart.weight.unit'],
405
+ $this->__formatPrice($process['data']['cart.price_including_tax']),
406
+ $this->__formatPrice($process['data']['cart.price_excluding_tax'])
407
+ ),
408
+ $this->_helper->getRowProperty($row,$property)
409
+ ));
410
+ }
411
+
412
+ protected function _addMessages($messages) {
413
+ if (!is_array($messages)) $messages = array($messages);
414
+ if (!is_array($this->_messages)) $this->_messages = $messages;
415
+ else $this->_messages = array_merge($this->_messages,$messages);
416
+ }
417
+
418
+ protected function _appendErrors(&$process, $messages) {
419
+ if (is_array($messages)) {
420
+ foreach ($messages as $message) {
421
+ $this->__appendError($process,$this->__($message));
422
+ }
423
+ }
424
+ }
425
+
426
+ /***************************************************************************************************************************/
427
+
428
+ protected function __getConfigData($key) {
429
+ return $this->getConfigData($key);
430
+ }
431
+
432
+ protected function __appendMethod(&$process, $row, $fees) {
433
+ $method = Mage::getModel('shipping/rate_result_method')
434
+ ->setCarrier($this->_code)
435
+ ->setCarrierTitle($this->__getConfigData('title'))
436
+ ->setMethod($row['*code'])
437
+ ->setMethodTitle($this->_getMethodText($process,$row,'label'))
438
+ ->setMethodDescription($this->_getMethodText($process,$row,'description'))
439
+ ->setMethodLogo($this->__getConfigData('logo_url'))
440
+ ->setPrice($fees)
441
+ ->setCost($fees)
442
+ ;
443
+ $process['result']->append($method);
444
+ }
445
+
446
+ protected function __appendError(&$process, $message) {
447
+ if (isset($process['result'])) {
448
+ $error = Mage::getModel('shipping/rate_result_error')
449
+ ->setCarrier($this->_code)
450
+ ->setCarrierTitle($this->__getConfigData('title'))
451
+ ->setErrorMessage($message)
452
+ ;
453
+ $process['result']->append($error);
454
+ }
455
+ }
456
+
457
+ protected function __formatPrice($price) {
458
+ if (!isset($this->_core_helper)) $this->_core_helper = Mage::helper('core');
459
+ return $this->_core_helper->currency($price);
460
+ }
461
+
462
+ protected function __($message) {
463
+ $args = func_get_args();
464
+ $message = array_shift($args);
465
+ if ($message instanceof OCS_Message) {
466
+ $args = $message->args;
467
+ $message = $message->message;
468
+ }
469
+
470
+ $output = Mage::helper('shipping')->__($message);
471
+ if (count($args)==0) return $output;
472
+
473
+ if (!isset($this->_translate_inline)) $this->_translate_inline = Mage::getSingleton('core/translate')->getTranslateInline();
474
+ if ($this->_translate_inline) {
475
+ $parts = explode('}}{{',$output);
476
+ $parts[0] = vsprintf($parts[0],$args);
477
+ return implode('}}{{',$parts);
478
+ }
479
+ else return vsprintf($output,$args);
480
+ }
481
+
482
+ protected function __getCountryName($country_code) {
483
+ return Mage::getModel('directory/country')->load($country_code)->getName();
484
+ //return Mage::app()->getLocale()->getCountryTranslation($country_code);
485
+ /*if (!isset($this->_countries)) {
486
+ // deprecated
487
+ //$this->_countries = Mage::getModel('core/locale')->getLocale()->getCountryTranslationList();
488
+ $this->_countries = Mage::getModel('core/locale')->getLocale()->getTranslationList('territory',null,2);
489
+ }
490
+ return isset($this->_countries[$country_code]) ? $this->_countries[$country_code] : $country_code;*/
491
+ }
492
+
493
+ /*
494
+ protected function __getCartTaxAmount($process) {
495
+ $tax_amount = 0;
496
+
497
+ foreach ($process['cart.items'] as $item) {
498
+ $tax_class_id = $item->getProduct()->getTaxClassId();
499
+ $request = Mage::getSingleton('tax/calculation')->getRateRequest();
500
+ $request->setProductClassId($tax_class_id);
501
+ $vat_rate = Mage::getSingleton('tax/calculation')->getRate($request);
502
+ $vat_rate = isset($rates[$tax_class_id]) ? $rates[$tax_class_id] : 0;
503
+
504
+ if ($vat_rate > 0) $vat_to_add = $item->getData('row_total_with_discount')*$vat_rate/100;
505
+ else $vat_to_add = $item->getData('tax_amount');
506
+ //echo $item->getProduct()->getName().', '.$item->getData('row_total_with_discount').', '.$vat_rate.', '.$vat_to_add.'<br />';
507
+ $tax_amount += $vat_to_add;
508
+ }
509
+ //echo 'tax:'.$tax_amount.'<br />';
510
+ return $tax_amount;
511
+ }
512
+ */
513
+
514
+ protected function __getCartTaxAmount($process) {
515
+ $tax_amount = 0;
516
+ foreach ($process['cart.items'] as $item) {
517
+ $tax_amount += $item->getData('tax_amount');
518
+ }
519
+ return $tax_amount;
520
+ }
521
+ }
522
+
523
  ?>
app/code/community/Chronopost/Chronorelais/Model/Sales/Quote/Address/Total/Shipping.php CHANGED
@@ -1,207 +1,207 @@
1
- <?php
2
- /**
3
- * Magento
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@magentocommerce.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.magentocommerce.com for more information.
20
- *
21
- * @category Mage
22
- * @package Mage_Sales
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
-
28
- class Chronopost_Chronorelais_Model_Sales_Quote_Address_Total_Shipping extends Mage_Sales_Model_Quote_Address_Total_Abstract
29
- {
30
- public function __construct()
31
- {
32
- $this->setCode('shipping');
33
- }
34
-
35
- /**
36
- * Collect totals information about shipping
37
- *
38
- * @param Mage_Sales_Model_Quote_Address $address
39
- * @return Mage_Sales_Model_Quote_Address_Total_Shipping
40
- */
41
- public function collect(Mage_Sales_Model_Quote_Address $address)
42
- {
43
- parent::collect($address);
44
-
45
- $oldWeight = $address->getWeight();
46
- $address->setWeight(0);
47
- $address->setFreeMethodWeight(0);
48
- $this->_setAmount(0)
49
- ->_setBaseAmount(0);
50
-
51
- $items = $this->_getAddressItems($address);
52
- if (!count($items)) {
53
- return $this;
54
- }
55
-
56
- $method = $address->getShippingMethod();
57
- $freeAddress= $address->getFreeShipping();
58
-
59
- $addressWeight = $address->getWeight();
60
- $freeMethodWeight = $address->getFreeMethodWeight();
61
-
62
- $addressQty = 0;
63
-
64
- foreach ($items as $item) {
65
- /**
66
- * Skip if this item is virtual
67
- */
68
- if ($item->getProduct()->isVirtual()) {
69
- continue;
70
- }
71
-
72
- /**
73
- * Children weight we calculate for parent
74
- */
75
- if ($item->getParentItem()) {
76
- continue;
77
- }
78
-
79
- if ($item->getHasChildren() && $item->isShipSeparately()) {
80
- foreach ($item->getChildren() as $child) {
81
- if ($child->getProduct()->isVirtual()) {
82
- continue;
83
- }
84
- $addressQty += $child->getTotalQty();
85
-
86
- if (!$item->getProduct()->getWeightType()) {
87
- $itemWeight = $child->getWeight();
88
- $itemQty = $child->getTotalQty();
89
- $rowWeight = $itemWeight*$itemQty;
90
- $addressWeight += $rowWeight;
91
- if ($freeAddress || $child->getFreeShipping()===true) {
92
- $rowWeight = 0;
93
- } elseif (is_numeric($child->getFreeShipping())) {
94
- $freeQty = $child->getFreeShipping();
95
- if ($itemQty>$freeQty) {
96
- $rowWeight = $itemWeight*($itemQty-$freeQty);
97
- }
98
- else {
99
- $rowWeight = 0;
100
- }
101
- }
102
- $freeMethodWeight += $rowWeight;
103
- $item->setRowWeight($rowWeight);
104
- }
105
- }
106
- if ($item->getProduct()->getWeightType()) {
107
- $itemWeight = $item->getWeight();
108
- $rowWeight = $itemWeight*$item->getQty();
109
- $addressWeight+= $rowWeight;
110
- if ($freeAddress || $item->getFreeShipping()===true) {
111
- $rowWeight = 0;
112
- } elseif (is_numeric($item->getFreeShipping())) {
113
- $freeQty = $item->getFreeShipping();
114
- if ($item->getQty()>$freeQty) {
115
- $rowWeight = $itemWeight*($item->getQty()-$freeQty);
116
- }
117
- else {
118
- $rowWeight = 0;
119
- }
120
- }
121
- $freeMethodWeight+= $rowWeight;
122
- $item->setRowWeight($rowWeight);
123
- }
124
- }
125
- else {
126
- if (!$item->getProduct()->isVirtual()) {
127
- $addressQty += $item->getQty();
128
- }
129
- $itemWeight = $item->getWeight();
130
- $rowWeight = $itemWeight*$item->getQty();
131
- $addressWeight+= $rowWeight;
132
- if ($freeAddress || $item->getFreeShipping()===true) {
133
- $rowWeight = 0;
134
- } elseif (is_numeric($item->getFreeShipping())) {
135
- $freeQty = $item->getFreeShipping();
136
- if ($item->getQty()>$freeQty) {
137
- $rowWeight = $itemWeight*($item->getQty()-$freeQty);
138
- }
139
- else {
140
- $rowWeight = 0;
141
- }
142
- }
143
- $freeMethodWeight+= $rowWeight;
144
- $item->setRowWeight($rowWeight);
145
- }
146
- }
147
-
148
- if (isset($addressQty)) {
149
- $address->setItemQty($addressQty);
150
- }
151
-
152
- $address->setWeight($addressWeight);
153
- $address->setFreeMethodWeight($freeMethodWeight);
154
-
155
- $address->collectShippingRates();
156
-
157
- $this->_setAmount(0)
158
- ->_setBaseAmount(0);
159
-
160
- $method = $address->getShippingMethod();
161
-
162
- if ($method) {
163
- foreach ($address->getAllShippingRates() as $rate) {
164
- if ($rate->getCode()==$method) {
165
- $amountPrice = $address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
166
- $this->_setAmount($amountPrice);
167
- $this->_setBaseAmount($rate->getPrice());
168
- if(!$address->getShippingDescription()) {
169
- $address->setShippingDescription($rate->getCarrierTitle().' - '.$rate->getMethodTitle());
170
- }
171
- break;
172
- }
173
- }
174
- }
175
-
176
- return $this;
177
- }
178
-
179
- /**
180
- * Add shipping totals information to address object
181
- *
182
- * @param Mage_Sales_Model_Quote_Address $address
183
- * @return Mage_Sales_Model_Quote_Address_Total_Shipping
184
- */
185
- public function fetch(Mage_Sales_Model_Quote_Address $address)
186
- {
187
- $amount = $address->getShippingAmount();
188
- if ($amount!=0 || $address->getShippingDescription()) {
189
- $address->addTotal(array(
190
- 'code'=>$this->getCode(),
191
- 'title'=>Mage::helper('sales')->__('Shipping & Handling').' ('.$address->getShippingDescription().')',
192
- 'value'=>$address->getShippingAmount()
193
- ));
194
- }
195
- return $this;
196
- }
197
-
198
- /**
199
- * Get Shipping label
200
- *
201
- * @return string
202
- */
203
- public function getLabel()
204
- {
205
- return Mage::helper('sales')->__('Shipping');
206
- }
207
- }
1
+ <?php
2
+ /**
3
+ * Magento
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@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Sales
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Chronopost_Chronorelais_Model_Sales_Quote_Address_Total_Shipping extends Mage_Sales_Model_Quote_Address_Total_Abstract
29
+ {
30
+ public function __construct()
31
+ {
32
+ $this->setCode('shipping');
33
+ }
34
+
35
+ /**
36
+ * Collect totals information about shipping
37
+ *
38
+ * @param Mage_Sales_Model_Quote_Address $address
39
+ * @return Mage_Sales_Model_Quote_Address_Total_Shipping
40
+ */
41
+ public function collect(Mage_Sales_Model_Quote_Address $address)
42
+ {
43
+ parent::collect($address);
44
+
45
+ $oldWeight = $address->getWeight();
46
+ $address->setWeight(0);
47
+ $address->setFreeMethodWeight(0);
48
+ $this->_setAmount(0)
49
+ ->_setBaseAmount(0);
50
+
51
+ $items = $this->_getAddressItems($address);
52
+ if (!count($items)) {
53
+ return $this;
54
+ }
55
+
56
+ $method = $address->getShippingMethod();
57
+ $freeAddress= $address->getFreeShipping();
58
+
59
+ $addressWeight = $address->getWeight();
60
+ $freeMethodWeight = $address->getFreeMethodWeight();
61
+
62
+ $addressQty = 0;
63
+
64
+ foreach ($items as $item) {
65
+ /**
66
+ * Skip if this item is virtual
67
+ */
68
+ if ($item->getProduct()->isVirtual()) {
69
+ continue;
70
+ }
71
+
72
+ /**
73
+ * Children weight we calculate for parent
74
+ */
75
+ if ($item->getParentItem()) {
76
+ continue;
77
+ }
78
+
79
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
80
+ foreach ($item->getChildren() as $child) {
81
+ if ($child->getProduct()->isVirtual()) {
82
+ continue;
83
+ }
84
+ $addressQty += $child->getTotalQty();
85
+
86
+ if (!$item->getProduct()->getWeightType()) {
87
+ $itemWeight = $child->getWeight();
88
+ $itemQty = $child->getTotalQty();
89
+ $rowWeight = $itemWeight*$itemQty;
90
+ $addressWeight += $rowWeight;
91
+ if ($freeAddress || $child->getFreeShipping()===true) {
92
+ $rowWeight = 0;
93
+ } elseif (is_numeric($child->getFreeShipping())) {
94
+ $freeQty = $child->getFreeShipping();
95
+ if ($itemQty>$freeQty) {
96
+ $rowWeight = $itemWeight*($itemQty-$freeQty);
97
+ }
98
+ else {
99
+ $rowWeight = 0;
100
+ }
101
+ }
102
+ $freeMethodWeight += $rowWeight;
103
+ $item->setRowWeight($rowWeight);
104
+ }
105
+ }
106
+ if ($item->getProduct()->getWeightType()) {
107
+ $itemWeight = $item->getWeight();
108
+ $rowWeight = $itemWeight*$item->getQty();
109
+ $addressWeight+= $rowWeight;
110
+ if ($freeAddress || $item->getFreeShipping()===true) {
111
+ $rowWeight = 0;
112
+ } elseif (is_numeric($item->getFreeShipping())) {
113
+ $freeQty = $item->getFreeShipping();
114
+ if ($item->getQty()>$freeQty) {
115
+ $rowWeight = $itemWeight*($item->getQty()-$freeQty);
116
+ }
117
+ else {
118
+ $rowWeight = 0;
119
+ }
120
+ }
121
+ $freeMethodWeight+= $rowWeight;
122
+ $item->setRowWeight($rowWeight);
123
+ }
124
+ }
125
+ else {
126
+ if (!$item->getProduct()->isVirtual()) {
127
+ $addressQty += $item->getQty();
128
+ }
129
+ $itemWeight = $item->getWeight();
130
+ $rowWeight = $itemWeight*$item->getQty();
131
+ $addressWeight+= $rowWeight;
132
+ if ($freeAddress || $item->getFreeShipping()===true) {
133
+ $rowWeight = 0;
134
+ } elseif (is_numeric($item->getFreeShipping())) {
135
+ $freeQty = $item->getFreeShipping();
136
+ if ($item->getQty()>$freeQty) {
137
+ $rowWeight = $itemWeight*($item->getQty()-$freeQty);
138
+ }
139
+ else {
140
+ $rowWeight = 0;
141
+ }
142
+ }
143
+ $freeMethodWeight+= $rowWeight;
144
+ $item->setRowWeight($rowWeight);
145
+ }
146
+ }
147
+
148
+ if (isset($addressQty)) {
149
+ $address->setItemQty($addressQty);
150
+ }
151
+
152
+ $address->setWeight($addressWeight);
153
+ $address->setFreeMethodWeight($freeMethodWeight);
154
+
155
+ $address->collectShippingRates();
156
+
157
+ $this->_setAmount(0)
158
+ ->_setBaseAmount(0);
159
+
160
+ $method = $address->getShippingMethod();
161
+
162
+ if ($method) {
163
+ foreach ($address->getAllShippingRates() as $rate) {
164
+ if ($rate->getCode()==$method) {
165
+ $amountPrice = $address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
166
+ $this->_setAmount($amountPrice);
167
+ $this->_setBaseAmount($rate->getPrice());
168
+ if(!$address->getShippingDescription()) {
169
+ $address->setShippingDescription($rate->getCarrierTitle().' - '.$rate->getMethodTitle());
170
+ }
171
+ break;
172
+ }
173
+ }
174
+ }
175
+
176
+ return $this;
177
+ }
178
+
179
+ /**
180
+ * Add shipping totals information to address object
181
+ *
182
+ * @param Mage_Sales_Model_Quote_Address $address
183
+ * @return Mage_Sales_Model_Quote_Address_Total_Shipping
184
+ */
185
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
186
+ {
187
+ $amount = $address->getShippingAmount();
188
+ if ($amount!=0 || $address->getShippingDescription()) {
189
+ $address->addTotal(array(
190
+ 'code'=>$this->getCode(),
191
+ 'title'=>Mage::helper('sales')->__('Shipping & Handling').' ('.$address->getShippingDescription().')',
192
+ 'value'=>$address->getShippingAmount()
193
+ ));
194
+ }
195
+ return $this;
196
+ }
197
+
198
+ /**
199
+ * Get Shipping label
200
+ *
201
+ * @return string
202
+ */
203
+ public function getLabel()
204
+ {
205
+ return Mage::helper('sales')->__('Shipping');
206
+ }
207
+ }
app/code/community/Chronopost/Chronorelais/Model/Sales/Quote/Address/Total/Shipping.toDel.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
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@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Sales
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Chronopost_Chronorelais_Model_Sales_Quote_Address_Total_Shipping extends Mage_Sales_Model_Quote_Address_Total_Abstract
29
+ {
30
+ public function __construct()
31
+ {
32
+ $this->setCode('shipping');
33
+ }
34
+
35
+ /**
36
+ * Collect totals information about shipping
37
+ *
38
+ * @param Mage_Sales_Model_Quote_Address $address
39
+ * @return Mage_Sales_Model_Quote_Address_Total_Shipping
40
+ */
41
+ public function collect(Mage_Sales_Model_Quote_Address $address)
42
+ {
43
+ parent::collect($address);
44
+
45
+ $oldWeight = $address->getWeight();
46
+ $address->setWeight(0);
47
+ $address->setFreeMethodWeight(0);
48
+ $this->_setAmount(0)
49
+ ->_setBaseAmount(0);
50
+
51
+ $items = $this->_getAddressItems($address);
52
+ if (!count($items)) {
53
+ return $this;
54
+ }
55
+
56
+ $method = $address->getShippingMethod();
57
+ $freeAddress= $address->getFreeShipping();
58
+
59
+ $addressWeight = $address->getWeight();
60
+ $freeMethodWeight = $address->getFreeMethodWeight();
61
+
62
+ $addressQty = 0;
63
+
64
+ foreach ($items as $item) {
65
+ /**
66
+ * Skip if this item is virtual
67
+ */
68
+ if ($item->getProduct()->isVirtual()) {
69
+ continue;
70
+ }
71
+
72
+ /**
73
+ * Children weight we calculate for parent
74
+ */
75
+ if ($item->getParentItem()) {
76
+ continue;
77
+ }
78
+
79
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
80
+ foreach ($item->getChildren() as $child) {
81
+ if ($child->getProduct()->isVirtual()) {
82
+ continue;
83
+ }
84
+ $addressQty += $child->getTotalQty();
85
+
86
+ if (!$item->getProduct()->getWeightType()) {
87
+ $itemWeight = $child->getWeight();
88
+ $itemQty = $child->getTotalQty();
89
+ $rowWeight = $itemWeight*$itemQty;
90
+ $addressWeight += $rowWeight;
91
+ if ($freeAddress || $child->getFreeShipping()===true) {
92
+ $rowWeight = 0;
93
+ } elseif (is_numeric($child->getFreeShipping())) {
94
+ $freeQty = $child->getFreeShipping();
95
+ if ($itemQty>$freeQty) {
96
+ $rowWeight = $itemWeight*($itemQty-$freeQty);
97
+ }
98
+ else {
99
+ $rowWeight = 0;
100
+ }
101
+ }
102
+ $freeMethodWeight += $rowWeight;
103
+ $item->setRowWeight($rowWeight);
104
+ }
105
+ }
106
+ if ($item->getProduct()->getWeightType()) {
107
+ $itemWeight = $item->getWeight();
108
+ $rowWeight = $itemWeight*$item->getQty();
109
+ $addressWeight+= $rowWeight;
110
+ if ($freeAddress || $item->getFreeShipping()===true) {
111
+ $rowWeight = 0;
112
+ } elseif (is_numeric($item->getFreeShipping())) {
113
+ $freeQty = $item->getFreeShipping();
114
+ if ($item->getQty()>$freeQty) {
115
+ $rowWeight = $itemWeight*($item->getQty()-$freeQty);
116
+ }
117
+ else {
118
+ $rowWeight = 0;
119
+ }
120
+ }
121
+ $freeMethodWeight+= $rowWeight;
122
+ $item->setRowWeight($rowWeight);
123
+ }
124
+ }
125
+ else {
126
+ if (!$item->getProduct()->isVirtual()) {
127
+ $addressQty += $item->getQty();
128
+ }
129
+ $itemWeight = $item->getWeight();
130
+ $rowWeight = $itemWeight*$item->getQty();
131
+ $addressWeight+= $rowWeight;
132
+ if ($freeAddress || $item->getFreeShipping()===true) {
133
+ $rowWeight = 0;
134
+ } elseif (is_numeric($item->getFreeShipping())) {
135
+ $freeQty = $item->getFreeShipping();
136
+ if ($item->getQty()>$freeQty) {
137
+ $rowWeight = $itemWeight*($item->getQty()-$freeQty);
138
+ }
139
+ else {
140
+ $rowWeight = 0;
141
+ }
142
+ }
143
+ $freeMethodWeight+= $rowWeight;
144
+ $item->setRowWeight($rowWeight);
145
+ }
146
+ }
147
+
148
+ if (isset($addressQty)) {
149
+ $address->setItemQty($addressQty);
150
+ }
151
+
152
+ $address->setWeight($addressWeight);
153
+ $address->setFreeMethodWeight($freeMethodWeight);
154
+
155
+ $address->collectShippingRates();
156
+
157
+ $this->_setAmount(0)
158
+ ->_setBaseAmount(0);
159
+
160
+ $method = $address->getShippingMethod();
161
+
162
+ if ($method) {
163
+ foreach ($address->getAllShippingRates() as $rate) {
164
+ if ($rate->getCode()==$method) {
165
+ $amountPrice = $address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
166
+ $this->_setAmount($amountPrice);
167
+ $this->_setBaseAmount($rate->getPrice());
168
+ if(!$address->getShippingDescription()) {
169
+ $address->setShippingDescription($rate->getCarrierTitle().' - '.$rate->getMethodTitle());
170
+ }
171
+ break;
172
+ }
173
+ }
174
+ }
175
+
176
+ return $this;
177
+ }
178
+
179
+ /**
180
+ * Add shipping totals information to address object
181
+ *
182
+ * @param Mage_Sales_Model_Quote_Address $address
183
+ * @return Mage_Sales_Model_Quote_Address_Total_Shipping
184
+ */
185
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
186
+ {
187
+ $amount = $address->getShippingAmount();
188
+ if ($amount!=0 || $address->getShippingDescription()) {
189
+ $address->addTotal(array(
190
+ 'code'=>$this->getCode(),
191
+ 'title'=>Mage::helper('sales')->__('Shipping & Handling').' ('.$address->getShippingDescription().')',
192
+ 'value'=>$address->getShippingAmount()
193
+ ));
194
+ }
195
+ return $this;
196
+ }
197
+
198
+ /**
199
+ * Get Shipping label
200
+ *
201
+ * @return string
202
+ */
203
+ public function getLabel()
204
+ {
205
+ return Mage::helper('sales')->__('Shipping');
206
+ }
207
+ }
app/code/community/Chronopost/Chronorelais/controllers/AjaxController.php CHANGED
@@ -1,441 +1,446 @@
1
- <?php
2
-
3
- /**
4
- * Magento Chronopost Chronorelais Module
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * @category Chronopost
17
- * @package Chronopost_Chronorelais
18
- * @copyright Copyright (c) 2008-10 Owebia (http://www.owebia.com/)
19
- * @author Antoine Lemoine
20
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
- */
22
- class Chronopost_Chronorelais_AjaxController extends Chronopost_Chronorelais_Controller_Abstract {
23
-
24
- private function getPropertyHelper($row_id, $property_key, $property) {
25
- $cleaned_property = $this->cleanKey($property_key);
26
- $prefix = "r-" . $row_id . "-p-" . $cleaned_property;
27
- $value = isset($property['original_value']) ? $property['original_value'] : (isset($property['value']) ? $property['value'] : '');
28
-
29
- switch ($property_key) {
30
- case 'enabled':
31
- $enabled = $value !== false;
32
- return "<p><select id=\"" . $prefix . "\" class=\"field\">"
33
- . "<option value=\"0\"" . ($enabled ? '' : ' selected="selected"') . ">" . $this->__('Disabled') . "</option>"
34
- . "<option value=\"1\"" . ($enabled ? ' selected="selected"' : '') . ">" . $this->__('Enabled') . "</option>"
35
- . "</select><p>";
36
- break;
37
- case 'label':
38
- case 'description':
39
- return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
40
- . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
41
- . "<p>"
42
- . $this->button('Destination country', "ocseditor.insertAtCaret(this,'{destination.country.name}');")
43
- . $this->button('Cart weight', "ocseditor.insertAtCaret(this,'{cart.weight}');")
44
- . $this->button('Cart quantity', "ocseditor.insertAtCaret(this,'{cart.quantity}');")
45
- . $this->button('Price including tax', "ocseditor.insertAtCaret(this,'{cart.price_including_tax}');")
46
- . $this->button('Price excluding tax', "ocseditor.insertAtCaret(this,'{cart.price_excluding_tax}');")
47
- . "</p>"
48
- . "</fieldset>";
49
- break;
50
- case 'fees':
51
- return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
52
- . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
53
- . "<p><span class=\"buttons-set-label\">" . $this->__('Cart') . "</span>"
54
- . $this->button('Weight', "ocseditor.insertAtCaret(this,'{cart.weight}');")
55
- . $this->button('Products quantity', "ocseditor.insertAtCaret(this,'{cart.quantity}');")
56
- . $this->button('Price including tax', "ocseditor.insertAtCaret(this,'{cart.price_including_tax}');")
57
- . $this->button('Price excluding tax', "ocseditor.insertAtCaret(this,'{cart.price_excluding_tax}');")
58
- . "</p>"
59
- . "<p><span class=\"buttons-set-label\">" . $this->__('Selection') . "</span>"
60
- . $this->button('Weight', "ocseditor.insertAtCaret(this,'{selection.weight}');")
61
- . $this->button('Products quantity', "ocseditor.insertAtCaret(this,'{selection.quantity}');")
62
- . "</p>"
63
- . "<p><span class=\"buttons-set-label\">" . $this->__('Product') . "</span>"
64
- . $this->button('Weight', "ocseditor.insertAtCaret(this,'{product.weight}');")
65
- . $this->button('Quantity', "ocseditor.insertAtCaret(this,'{product.quantity}');")
66
- . "</p>"
67
- . "</fieldset>";
68
- break;
69
- case 'conditions':
70
- return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
71
- . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
72
- . "<p><span class=\"buttons-set-label\">" . $this->__('Cart') . "</span>"
73
- . $this->button('Weight', "ocseditor.insertAtCaret(this,'{cart.weight}');")
74
- . $this->button('Products quantity', "ocseditor.insertAtCaret(this,'{cart.quantity}');")
75
- . $this->button('Price including tax', "ocseditor.insertAtCaret(this,'{cart.price_including_tax}');")
76
- . $this->button('Price excluding tax', "ocseditor.insertAtCaret(this,'{cart.price_excluding_tax}');")
77
- . "</p>"
78
- . "</fieldset>";
79
- break;
80
- case 'customer_groups':
81
- return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
82
- . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
83
- . "<p>"
84
- . $this->button('Not logged in', "ocseditor.insertAtCaret(this,'NOT LOGGED IN');")
85
- . "</p>"
86
- . "</fieldset>";
87
- break;
88
- case 'tracking_url':
89
- return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
90
- . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
91
- . "<p>"
92
- . $this->button('Tracking number', "ocseditor.insertAtCaret(this,'{tracking_number}');")
93
- . "</p>"
94
- . "</fieldset>";
95
- break;
96
- case 'destination':
97
- case 'origin':
98
- $parsed_value = $this->parseAddressFilter($value);
99
- $excluding = $parsed_value['excluding'];
100
- return "<div class=\"address-filters-property\"><p>"
101
- . "<input type=\"radio\" class=\"excluding\" id=\"" . $prefix . "-exluding-0\" name=\"" . $prefix . "-exluding\""
102
- . " value=\"0\"" . (!$excluding ? " checked=\"checked\"" : '') . " onclick=\"ocseditor.updateCountries(this);\"/>"
103
- . "<label for=\"" . $prefix . "-exluding-0\"> " . $this->__('Limit to') . "</label> &nbsp; "
104
- . "<input type=\"radio\" class=\"excluding\" id=\"" . $prefix . "-exluding-1\" name=\"" . $prefix . "-exluding\""
105
- . " value=\"1\"" . ($excluding ? " checked=\"checked\"" : '') . " onclick=\"ocseditor.updateCountries(this);\"/>"
106
- . "<label for=\"" . $prefix . "-exluding-1\"> " . $this->__('Exclude') . "</label></p>"
107
- . "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
108
- . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Display') . "</legend>"
109
- . "<p>"
110
- . $this->button('Display original input', "ocseditor.displayCountry('original-value',this,false);")
111
- . $this->button('Display corrected names', "ocseditor.displayCountry('full-value',this,false);")
112
- . $this->button('Display codes', "ocseditor.displayCountry('compact-value',this,true);")
113
- . "</p>"
114
- . "</fieldset>"
115
- . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Preview') . "</legend>"
116
- . "<div class=\"address-filter-list\">" . $this->getAddressFilters($parsed_value) . "</div>"
117
- . "</fieldset>"
118
- . "</div>"
119
- ;
120
- break;
121
- case '*comment' :
122
- $lines = explode("\n", trim($value));
123
- for ($i = 0; $i < count($lines); $i++) {
124
- $lines[$i] = preg_replace('/^# ?/', '', $lines[$i]);
125
- }
126
- $value = implode("\n", $lines);
127
- return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>";
128
- default :
129
- return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>";
130
- }
131
- }
132
-
133
- private function getAddressFilters($data) {
134
- $address_filters = array();
135
- foreach ($data['countries'] as $country) {
136
- $address_filters[] = new AddressFilter($country);
137
- }
138
- return implode('', $address_filters);
139
- }
140
-
141
- private function parseAddressFilter($address_filter) {
142
- $output = array(
143
- 'excluding' => false,
144
- 'countries' => array(),
145
- 'original' => $address_filter,
146
- );
147
-
148
- $address_filter = str_replace(array("\r\n", "\r", "\n"), array(',', ',', ','), $address_filter);
149
-
150
- if (preg_match('# *\* *- *\((.*)\) *#s', $address_filter, $result)) {
151
- $address_filter = $result[1];
152
- $output['excluding'] = true;
153
- }
154
-
155
- $tmp_address_filter_array = explode(',', trim($address_filter));
156
-
157
- $concat = false;
158
- $concatened = '';
159
- $address_filter_array = array();
160
- $i = 0;
161
-
162
- foreach ($tmp_address_filter_array as $address_filter) {
163
- if ($concat)
164
- $concatened .= ',' . $address_filter;
165
- else {
166
- if ($i < count($tmp_address_filter_array) - 1 && preg_match('#\(#', $address_filter)) {
167
- $concat = true;
168
- $concatened .= $address_filter;
169
- } else
170
- $address_filter_array[] = $address_filter;
171
- }
172
- if (preg_match('#\)#', $address_filter)) {
173
- $address_filter_array[] = $concatened;
174
- $concatened = '';
175
- $concat = false;
176
- }
177
- $i++;
178
- }
179
-
180
- foreach ($address_filter_array as $address_filter) {
181
- $address_filter = trim($address_filter);
182
- if (trim($address_filter) != '') {
183
- if (preg_match('# *([^,(]+) *(-)? *(?:\( *(-)? *(.*)\))? *#s', $address_filter, $result)) {
184
- $country_code = $result[1];
185
-
186
- $region_codes = array();
187
- if(isset($result[4])) {
188
- $region_codes = explode(',', $result[4]);
189
- $in_array = false;
190
- for ($i = count($region_codes); --$i >= 0;) {
191
- $code = trim($region_codes[$i]);
192
- $region_codes[$i] = $code;
193
- }
194
- }
195
-
196
- /* $in_array = in_array($address['region_code'],$region_codes,true) || in_array($address['postcode'],$region_codes,true); */
197
- $excluding_region = (isset($result[2]) && $result[2] == '-') || (isset($result[3]) && $result[3] == '-');
198
- $output['countries'][] = array(
199
- 'excluding' => $excluding_region,
200
- 'country_code' => $country_code,
201
- 'region_codes' => implode(',', $region_codes),
202
- 'original' => $address_filter,
203
- );
204
- } else {
205
- $output['countries'][] = array(
206
- 'excluding' => null,
207
- 'country_code' => $address_filter,
208
- 'region_codes' => null,
209
- 'original' => $address_filter,
210
- );
211
- }
212
- }
213
- }
214
- return $output;
215
- }
216
-
217
- private function getRowUI($row, $selected) {
218
- $row['_ID_']['value'] = isset($row['_ID_']['value']) ? $row['_ID_']['value'] : uniqid('c');
219
- $row_id = $row['_ID_']['value'];
220
-
221
- if (isset($row['lines'])) {
222
- $output = "<div id=\"r-" . $row_id . "-container\" class=\"row-container has-error ignored-lines" . ($selected ? ' selected' : '') . "\">"
223
- . "<div class=\"row-header\" onclick=\"ocseditor.selectRow('" . $row_id . "');\">"
224
- . "<div class=\"row-actions\">"
225
- . $this->button('Apply changes', "ocseditor.applyChanges();")
226
- . $this->button('Delete', "ocseditor.removeRow(this);", 'delete')
227
- . "</div>"
228
- . "<div class=\"row-title\">" . $this->__('Ignored lines') . "</div></div>"
229
- . "<div class=\"properties-container\"><textarea class=\"field\">" . $row['lines'] . "</textarea></div></div>";
230
- return $output;
231
- }
232
-
233
- if (!isset($row['label'])) {
234
- $row['label']['value'] = $this->__('New shipping method');
235
- }
236
-
237
- $properties = array(
238
- 'enabled' => 'Enabled',
239
- 'code' => 'Code',
240
- 'label' => 'Label',
241
- 'description' => 'Description',
242
- 'destination' => 'Destination',
243
- 'origin' => 'Origin',
244
- 'conditions' => 'Conditions',
245
- 'fees' => 'Fees',
246
- 'customer_groups' => 'Customer groups',
247
- 'tracking_url' => 'Tracking url',
248
- '*comment' => 'Comment',
249
- );
250
-
251
- $label = $row['label']['value'];
252
- $output = "<div id=\"r-" . $row_id . "-container\" class=\"row-container" . ($selected ? ' selected' : '') . "\">"
253
- . "<div class=\"row-header\" onclick=\"ocseditor.selectRow('" . $row_id . "');\">"
254
- . "<div class=\"row-actions\">" . $this->button('Delete', "ocseditor.removeRow(this);", 'delete') . "</div><div class=\"row-title\">" . $label . "</div></div>"
255
- . "<div class=\"properties-container\">";
256
- $list = "<ul class=\"properties-list\">";
257
- $j = 0;
258
- foreach ($properties as $property_key => $label) {
259
- $cleaned_property = $this->cleanKey($property_key);
260
- $value = isset($row[$property_key]) ? trim($row[$property_key]['value']) : '';
261
- $property = isset($row[$property_key]) ? $row[$property_key] : '';
262
-
263
- $list .= "<li id=\"r-" . $row_id . "-p-" . $cleaned_property . "-item\" class=\"property-item" . ($j == 0 ? ' selected' : '')
264
- . (empty($value) ? ' empty' : '')
265
- . "\" onclick=\"ocseditor.selectProperty('" . $row_id . "','" . $cleaned_property . "');\">" . $this->__($label) . "</li>";
266
- $output .= "<div id=\"r-" . $row_id . "-p-" . $cleaned_property . "-container\" class=\"property-container"
267
- . ($j == 0 ? ' selected' : '') . "\" property-name=\"" . $property_key . "\">"
268
- . "<div class=\"buttons-set\" style=\"text-align:right;\">" . $this->button('Help', "ocseditor.help('property." . $property_key . "');", 'help') . "</div>"
269
- . $this->getPropertyHelper($row_id, $property_key, $property) . "</div>";
270
- $j++;
271
- }
272
- foreach ($row as $property_key => $property) {
273
- if (!isset($properties[$property_key]) && substr($property_key, 0, 1) != '*') {
274
- $label = $property_key;
275
- $cleaned_property = $this->cleanKey($property_key);
276
- $value = isset($row[$property_key]) ? trim($row[$property_key]['value']) : '';
277
- $list .= "<li id=\"r-" . $row_id . "-p-" . $cleaned_property . "-item\" class=\"property-item" . ($j == 0 ? ' selected' : '')
278
- . (empty($value) ? ' empty' : '') . ($cleaned_property == '_ID_' ? ' hide' : '')
279
- . "\" onclick=\"ocseditor.selectProperty('" . $row_id . "','" . $cleaned_property . "');\">" . $this->__($label) . "</li>";
280
- $output .= "<div id=\"r-" . $row_id . "-p-" . $cleaned_property . "-container\" class=\"property-container"
281
- . ($j == 0 ? ' selected' : '') . "\" property-name=\"" . $property_key . "\">"
282
- . "<div class=\"buttons-set\" style=\"text-align:right;\">" . $this->button('Help', "ocseditor.help('property." . $property_key . "');", 'help') . "</div>"
283
- . $this->getPropertyHelper($row_id, $property_key, $property) . "</div>";
284
- $j++;
285
- }
286
- }
287
- $output .= $list . "</div></div>";
288
- return $output;
289
- }
290
-
291
- private function getConfigErrors($config) {
292
- $script = "ocseditor.resetErrors();";
293
- foreach ($config as $row_code => $row) {
294
- if (isset($row['*messages'])) {
295
- $error = '';
296
- foreach ($row['*messages'] as $message) {
297
- $error .= "<p>" . $this->__($message) . "</p>";
298
- }
299
- if ($error != '')
300
- $script .= "ocseditor.setError('" . $row['_ID_']['value'] . "','','" . $this->jsEscape($error) . "');";
301
- }
302
- foreach ($row as $property_key => $property) {
303
- if (isset($property['messages'])) {
304
- $error = '';
305
- foreach ($property['messages'] as $message) {
306
- $error .= "<p>" . $this->__($message) . "</p>";
307
- }
308
- if ($error != '') {
309
- $script .= "ocseditor.setError('" . $row['_ID_']['value'] . "','" . $property_key . "','"
310
- . $this->jsEscape($error
311
- . ($property['value'] != $property['original_value'] ?
312
- "<p>"
313
- . $this->button('Correct', "ocseditor.correct('" . $row['_ID_']['value'] . "','" . $property_key . "','" . $this->jsEscape($property['value']) . "');")
314
- . "</p>" : '')
315
- ) . "');";
316
- }
317
- }
318
- }
319
- }
320
- //$script .= "alert('".str_replace(array("\r\n","\n","\'","'"),array(" "," ","\\\'","\'"),$script)."');";
321
- return $script;
322
- }
323
-
324
- private function loadConfig($input) {
325
- include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
326
-
327
- $helper = new ChronorelaisShippingHelper($input);
328
- $helper->checkConfig();
329
- $config = $helper->getConfig();
330
- //print_r($config);
331
-
332
- $output = "<div class=\"buttons-set\">"
333
- . $this->button('Add a shipping method', "ocseditor.addRow();", 'add')
334
- . "</div><div class=\"config-container\">";
335
- $i = 0;
336
- foreach ($config as &$row) {
337
- $output .= $this->getRowUI($row, $i == 0);
338
- $i++;
339
- }
340
- $output .= "</div><script type=\"text/javascript\">" . $this->getConfigErrors($config) . "</script>";
341
- return $output;
342
- }
343
-
344
- public function indexAction() {
345
- header('Content-Type: text/html; charset=UTF-8');
346
-
347
- include_once $this->getIncludingPath('countries.inc.php');
348
-
349
- switch ($_POST['what']) {
350
- case 'open':
351
- $output = ""
352
- // Donate page
353
- //.$this->page('donate',"Support the development of Chronorelais Shipping extension",$this->__('{ocseditor.donate-page.content}'))
354
- // Help page
355
- . $this->page('help', "Chronorelais Shipping extension help", '')
356
- // Main page
357
- . $this->pageHeader("Chronorelais Shipping configuration editor", $this->button('Save', "ocseditor.save();", 'save')
358
- . $this->button('Export', "ocseditor.saveToFile();", '')
359
- . $this->button('Load', "ocseditor.showConfigLoader();", '')
360
- . $this->button('Close', "ocseditor.close();", 'cancel')
361
- )
362
- . "<div id=\"ocs-editor-config-loader\">"
363
- . "<textarea></textarea>"
364
- . "<div class=\"buttons-set\">"
365
- . $this->button('Load', "ocseditor.loadConfig();", '')
366
- . $this->button('Cancel', "ocseditor.hideConfigLoader();", 'cancel')
367
- . "</div>"
368
- . "</div>"
369
- . "<div id=\"ocs-editor-config-container\">" . $this->loadConfig($_POST['input']) . "</div>"
370
- /* ."<div class=\"donate-container\">"
371
- ."<table cellspacing=\"0\"><tr>"
372
- ."<td>".$this->__('You appreciate this extension and would like to help?')."</td>"
373
- ."<td class=\"form-buttons\">"
374
- .$this->button('Donate',"ocseditor.openPage('donate');",'donate')
375
- ."</td>"
376
- ."</tr></table>"
377
- ."</div>" */
378
- ;
379
- echo $output;
380
- exit;
381
- case 'help':
382
- echo $this->__('{ocseditor.help.' . $_POST['input'] . '}');
383
- exit;
384
- case 'add-row':
385
- echo $this->getRowUI(array(), true);
386
- exit;
387
- case 'load-config':
388
- echo $this->loadConfig($_POST['config']);
389
- exit;
390
- case 'check-config':
391
- include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
392
-
393
- $helper = new ChronorelaisShippingHelper(urldecode($_POST['config']));
394
- $helper->checkConfig();
395
- print_r($helper->getConfig(), $out);
396
- //$script = "alert('".$this->jsEscape(urldecode($_POST['config']))."');";
397
- $script = $this->getConfigErrors($helper->getConfig());
398
- //$script = "alert('".$this->jsEscape($this->getConfigErrors($helper->getConfig()))."');";
399
- break;
400
- case 'save-to-file':
401
- include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
402
-
403
- $helper = new ChronorelaisShippingHelper(urldecode($_POST['config']));
404
- $formatted_config = $helper->formatConfig(false);
405
- $this->forceDownload('chronorelais-shipping-config.txt', $formatted_config);
406
- exit;
407
- case 'get-address-filters':
408
- $result = $this->parseAddressFilter($_POST['input']);
409
- echo $this->getAddressFilters($result);
410
- exit;
411
- }
412
-
413
- echo "<script type=\"text/javascript\">" . $script . "</script>";
414
- exit;
415
- }
416
-
417
- public function checkloginAction() {
418
- $params = $this->getRequest()->getParams();
419
- $account_number = $params['account_number'];
420
- $sub_account_number = $params['sub_account_number'];
421
- $account_pass = $params['account_pass'];
422
- $helper = Mage::helper('chronorelais');
423
-
424
- $WSParams = array(
425
- 'accountNumber' => $account_number,
426
- 'password' => $account_pass,
427
- 'depCountryCode' => $helper->getConfigurationShipperInfo('country'),
428
- 'depZipCode' => $helper->getConfigurationShipperInfo('zipcode'),
429
- 'arrCountryCode' => $helper->getConfigurationShipperInfo('country'),
430
- 'arrZipCode' => $helper->getConfigurationShipperInfo('zipcode'),
431
- 'arrCity' => $helper->getConfigurationShipperInfo('city'),
432
- 'type' => 'M',
433
- 'weight' => 1
434
- );
435
-
436
- $helperWS = Mage::helper('chronorelais/webservice');
437
- $webservbt = (array)$helperWS->checkLogin($WSParams);
438
-
439
- echo json_encode($webservbt);
440
- }
441
- }
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento Chronopost Chronorelais Module
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Chronopost
17
+ * @package Chronopost_Chronorelais
18
+ * @copyright Copyright (c) 2008-10 Owebia (http://www.owebia.com/)
19
+ * @author Antoine Lemoine
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ class Chronopost_Chronorelais_AjaxController extends Chronopost_Chronorelais_Controller_Abstract {
23
+
24
+ private function getPropertyHelper($row_id, $property_key, $property) {
25
+ $cleaned_property = $this->cleanKey($property_key);
26
+ $prefix = "r-" . $row_id . "-p-" . $cleaned_property;
27
+ $value = isset($property['original_value']) ? $property['original_value'] : (isset($property['value']) ? $property['value'] : '');
28
+
29
+ switch ($property_key) {
30
+ case 'enabled':
31
+ $enabled = $value !== false;
32
+ return "<p><select id=\"" . $prefix . "\" class=\"field\">"
33
+ . "<option value=\"0\"" . ($enabled ? '' : ' selected="selected"') . ">" . $this->__('Disabled') . "</option>"
34
+ . "<option value=\"1\"" . ($enabled ? ' selected="selected"' : '') . ">" . $this->__('Enabled') . "</option>"
35
+ . "</select><p>";
36
+ break;
37
+ case 'label':
38
+ case 'description':
39
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
40
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
41
+ . "<p>"
42
+ . $this->button('Destination country', "ocseditor.insertAtCaret(this,'{destination.country.name}');")
43
+ . $this->button('Cart weight', "ocseditor.insertAtCaret(this,'{cart.weight}');")
44
+ . $this->button('Cart quantity', "ocseditor.insertAtCaret(this,'{cart.quantity}');")
45
+ . $this->button('Price including tax', "ocseditor.insertAtCaret(this,'{cart.price_including_tax}');")
46
+ . $this->button('Price excluding tax', "ocseditor.insertAtCaret(this,'{cart.price_excluding_tax}');")
47
+ . "</p>"
48
+ . "</fieldset>";
49
+ break;
50
+ case 'fees':
51
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
52
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
53
+ . "<p><span class=\"buttons-set-label\">" . $this->__('Cart') . "</span>"
54
+ . $this->button('Weight', "ocseditor.insertAtCaret(this,'{cart.weight}');")
55
+ . $this->button('Products quantity', "ocseditor.insertAtCaret(this,'{cart.quantity}');")
56
+ . $this->button('Price including tax', "ocseditor.insertAtCaret(this,'{cart.price_including_tax}');")
57
+ . $this->button('Price excluding tax', "ocseditor.insertAtCaret(this,'{cart.price_excluding_tax}');")
58
+ . "</p>"
59
+ . "<p><span class=\"buttons-set-label\">" . $this->__('Selection') . "</span>"
60
+ . $this->button('Weight', "ocseditor.insertAtCaret(this,'{selection.weight}');")
61
+ . $this->button('Products quantity', "ocseditor.insertAtCaret(this,'{selection.quantity}');")
62
+ . "</p>"
63
+ . "<p><span class=\"buttons-set-label\">" . $this->__('Product') . "</span>"
64
+ . $this->button('Weight', "ocseditor.insertAtCaret(this,'{product.weight}');")
65
+ . $this->button('Quantity', "ocseditor.insertAtCaret(this,'{product.quantity}');")
66
+ . "</p>"
67
+ . "</fieldset>";
68
+ break;
69
+ case 'conditions':
70
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
71
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
72
+ . "<p><span class=\"buttons-set-label\">" . $this->__('Cart') . "</span>"
73
+ . $this->button('Weight', "ocseditor.insertAtCaret(this,'{cart.weight}');")
74
+ . $this->button('Products quantity', "ocseditor.insertAtCaret(this,'{cart.quantity}');")
75
+ . $this->button('Price including tax', "ocseditor.insertAtCaret(this,'{cart.price_including_tax}');")
76
+ . $this->button('Price excluding tax', "ocseditor.insertAtCaret(this,'{cart.price_excluding_tax}');")
77
+ . "</p>"
78
+ . "</fieldset>";
79
+ break;
80
+ case 'customer_groups':
81
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
82
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
83
+ . "<p>"
84
+ . $this->button('Not logged in', "ocseditor.insertAtCaret(this,'NOT LOGGED IN');")
85
+ . "</p>"
86
+ . "</fieldset>";
87
+ break;
88
+ case 'tracking_url':
89
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
90
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
91
+ . "<p>"
92
+ . $this->button('Tracking number', "ocseditor.insertAtCaret(this,'{tracking_number}');")
93
+ . "</p>"
94
+ . "</fieldset>";
95
+ break;
96
+ case 'destination':
97
+ case 'origin':
98
+ $parsed_value = $this->parseAddressFilter($value);
99
+ $excluding = $parsed_value['excluding'];
100
+ return "<div class=\"address-filters-property\"><p>"
101
+ . "<input type=\"radio\" class=\"excluding\" id=\"" . $prefix . "-exluding-0\" name=\"" . $prefix . "-exluding\""
102
+ . " value=\"0\"" . (!$excluding ? " checked=\"checked\"" : '') . " onclick=\"ocseditor.updateCountries(this);\"/>"
103
+ . "<label for=\"" . $prefix . "-exluding-0\"> " . $this->__('Limit to') . "</label> &nbsp; "
104
+ . "<input type=\"radio\" class=\"excluding\" id=\"" . $prefix . "-exluding-1\" name=\"" . $prefix . "-exluding\""
105
+ . " value=\"1\"" . ($excluding ? " checked=\"checked\"" : '') . " onclick=\"ocseditor.updateCountries(this);\"/>"
106
+ . "<label for=\"" . $prefix . "-exluding-1\"> " . $this->__('Exclude') . "</label></p>"
107
+ . "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
108
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Display') . "</legend>"
109
+ . "<p>"
110
+ . $this->button('Display original input', "ocseditor.displayCountry('original-value',this,false);")
111
+ . $this->button('Display corrected names', "ocseditor.displayCountry('full-value',this,false);")
112
+ . $this->button('Display codes', "ocseditor.displayCountry('compact-value',this,true);")
113
+ . "</p>"
114
+ . "</fieldset>"
115
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Preview') . "</legend>"
116
+ . "<div class=\"address-filter-list\">" . $this->getAddressFilters($parsed_value) . "</div>"
117
+ . "</fieldset>"
118
+ . "</div>"
119
+ ;
120
+ break;
121
+ case '*comment' :
122
+ $lines = explode("\n", trim($value));
123
+ for ($i = 0; $i < count($lines); $i++) {
124
+ $lines[$i] = preg_replace('/^# ?/', '', $lines[$i]);
125
+ }
126
+ $value = implode("\n", $lines);
127
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>";
128
+ default :
129
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>";
130
+ }
131
+ }
132
+
133
+ private function getAddressFilters($data) {
134
+ $address_filters = array();
135
+ foreach ($data['countries'] as $country) {
136
+ $address_filters[] = new AddressFilter($country);
137
+ }
138
+ return implode('', $address_filters);
139
+ }
140
+
141
+ private function parseAddressFilter($address_filter) {
142
+ $output = array(
143
+ 'excluding' => false,
144
+ 'countries' => array(),
145
+ 'original' => $address_filter,
146
+ );
147
+
148
+ $address_filter = str_replace(array("\r\n", "\r", "\n"), array(',', ',', ','), $address_filter);
149
+
150
+ if (preg_match('# *\* *- *\((.*)\) *#s', $address_filter, $result)) {
151
+ $address_filter = $result[1];
152
+ $output['excluding'] = true;
153
+ }
154
+
155
+ $tmp_address_filter_array = explode(',', trim($address_filter));
156
+
157
+ $concat = false;
158
+ $concatened = '';
159
+ $address_filter_array = array();
160
+ $i = 0;
161
+
162
+ foreach ($tmp_address_filter_array as $address_filter) {
163
+ if ($concat)
164
+ $concatened .= ',' . $address_filter;
165
+ else {
166
+ if ($i < count($tmp_address_filter_array) - 1 && preg_match('#\(#', $address_filter)) {
167
+ $concat = true;
168
+ $concatened .= $address_filter;
169
+ } else
170
+ $address_filter_array[] = $address_filter;
171
+ }
172
+ if (preg_match('#\)#', $address_filter)) {
173
+ $address_filter_array[] = $concatened;
174
+ $concatened = '';
175
+ $concat = false;
176
+ }
177
+ $i++;
178
+ }
179
+
180
+ foreach ($address_filter_array as $address_filter) {
181
+ $address_filter = trim($address_filter);
182
+ if (trim($address_filter) != '') {
183
+ if (preg_match('# *([^,(]+) *(-)? *(?:\( *(-)? *(.*)\))? *#s', $address_filter, $result)) {
184
+ $country_code = $result[1];
185
+
186
+ $region_codes = array();
187
+ if(isset($result[4])) {
188
+ $region_codes = explode(',', $result[4]);
189
+ $in_array = false;
190
+ for ($i = count($region_codes); --$i >= 0;) {
191
+ $code = trim($region_codes[$i]);
192
+ $region_codes[$i] = $code;
193
+ }
194
+ }
195
+
196
+ /* $in_array = in_array($address['region_code'],$region_codes,true) || in_array($address['postcode'],$region_codes,true); */
197
+ $excluding_region = (isset($result[2]) && $result[2] == '-') || (isset($result[3]) && $result[3] == '-');
198
+ $output['countries'][] = array(
199
+ 'excluding' => $excluding_region,
200
+ 'country_code' => $country_code,
201
+ 'region_codes' => implode(',', $region_codes),
202
+ 'original' => $address_filter,
203
+ );
204
+ } else {
205
+ $output['countries'][] = array(
206
+ 'excluding' => null,
207
+ 'country_code' => $address_filter,
208
+ 'region_codes' => null,
209
+ 'original' => $address_filter,
210
+ );
211
+ }
212
+ }
213
+ }
214
+ return $output;
215
+ }
216
+
217
+ private function getRowUI($row, $selected) {
218
+ $row['_ID_']['value'] = isset($row['_ID_']['value']) ? $row['_ID_']['value'] : uniqid('c');
219
+ $row_id = $row['_ID_']['value'];
220
+
221
+ if (isset($row['lines'])) {
222
+ $output = "<div id=\"r-" . $row_id . "-container\" class=\"row-container has-error ignored-lines" . ($selected ? ' selected' : '') . "\">"
223
+ . "<div class=\"row-header\" onclick=\"ocseditor.selectRow('" . $row_id . "');\">"
224
+ . "<div class=\"row-actions\">"
225
+ . $this->button('Apply changes', "ocseditor.applyChanges();")
226
+ . $this->button('Delete', "ocseditor.removeRow(this);", 'delete')
227
+ . "</div>"
228
+ . "<div class=\"row-title\">" . $this->__('Ignored lines') . "</div></div>"
229
+ . "<div class=\"properties-container\"><textarea class=\"field\">" . $row['lines'] . "</textarea></div></div>";
230
+ return $output;
231
+ }
232
+
233
+ if (!isset($row['label'])) {
234
+ $row['label']['value'] = $this->__('New shipping method');
235
+ }
236
+
237
+ $properties = array(
238
+ 'enabled' => 'Enabled',
239
+ 'code' => 'Code',
240
+ 'label' => 'Label',
241
+ 'description' => 'Description',
242
+ 'destination' => 'Destination',
243
+ 'origin' => 'Origin',
244
+ 'conditions' => 'Conditions',
245
+ 'fees' => 'Fees',
246
+ 'customer_groups' => 'Customer groups',
247
+ 'tracking_url' => 'Tracking url',
248
+ '*comment' => 'Comment',
249
+ );
250
+
251
+ $label = $row['label']['value'];
252
+ $output = "<div id=\"r-" . $row_id . "-container\" class=\"row-container" . ($selected ? ' selected' : '') . "\">"
253
+ . "<div class=\"row-header\" onclick=\"ocseditor.selectRow('" . $row_id . "');\">"
254
+ . "<div class=\"row-actions\">" . $this->button('Delete', "ocseditor.removeRow(this);", 'delete') . "</div><div class=\"row-title\">" . $label . "</div></div>"
255
+ . "<div class=\"properties-container\">";
256
+ $list = "<ul class=\"properties-list\">";
257
+ $j = 0;
258
+ foreach ($properties as $property_key => $label) {
259
+ $cleaned_property = $this->cleanKey($property_key);
260
+ $value = isset($row[$property_key]) ? trim($row[$property_key]['value']) : '';
261
+ $property = isset($row[$property_key]) ? $row[$property_key] : '';
262
+
263
+ $list .= "<li id=\"r-" . $row_id . "-p-" . $cleaned_property . "-item\" class=\"property-item" . ($j == 0 ? ' selected' : '')
264
+ . (empty($value) ? ' empty' : '')
265
+ . "\" onclick=\"ocseditor.selectProperty('" . $row_id . "','" . $cleaned_property . "');\">" . $this->__($label) . "</li>";
266
+ $output .= "<div id=\"r-" . $row_id . "-p-" . $cleaned_property . "-container\" class=\"property-container"
267
+ . ($j == 0 ? ' selected' : '') . "\" property-name=\"" . $property_key . "\">"
268
+ . "<div class=\"buttons-set\" style=\"text-align:right;\">" . $this->button('Help', "ocseditor.help('property." . $property_key . "');", 'help') . "</div>"
269
+ . $this->getPropertyHelper($row_id, $property_key, $property) . "</div>";
270
+ $j++;
271
+ }
272
+ foreach ($row as $property_key => $property) {
273
+ if (!isset($properties[$property_key]) && substr($property_key, 0, 1) != '*') {
274
+ $label = $property_key;
275
+ $cleaned_property = $this->cleanKey($property_key);
276
+ $value = isset($row[$property_key]) ? trim($row[$property_key]['value']) : '';
277
+ $list .= "<li id=\"r-" . $row_id . "-p-" . $cleaned_property . "-item\" class=\"property-item" . ($j == 0 ? ' selected' : '')
278
+ . (empty($value) ? ' empty' : '') . ($cleaned_property == '_ID_' ? ' hide' : '')
279
+ . "\" onclick=\"ocseditor.selectProperty('" . $row_id . "','" . $cleaned_property . "');\">" . $this->__($label) . "</li>";
280
+ $output .= "<div id=\"r-" . $row_id . "-p-" . $cleaned_property . "-container\" class=\"property-container"
281
+ . ($j == 0 ? ' selected' : '') . "\" property-name=\"" . $property_key . "\">"
282
+ . "<div class=\"buttons-set\" style=\"text-align:right;\">" . $this->button('Help', "ocseditor.help('property." . $property_key . "');", 'help') . "</div>"
283
+ . $this->getPropertyHelper($row_id, $property_key, $property) . "</div>";
284
+ $j++;
285
+ }
286
+ }
287
+ $output .= $list . "</div></div>";
288
+ return $output;
289
+ }
290
+
291
+ private function getConfigErrors($config) {
292
+ $script = "ocseditor.resetErrors();";
293
+ foreach ($config as $row_code => $row) {
294
+ if (isset($row['*messages'])) {
295
+ $error = '';
296
+ foreach ($row['*messages'] as $message) {
297
+ $error .= "<p>" . $this->__($message) . "</p>";
298
+ }
299
+ if ($error != '')
300
+ $script .= "ocseditor.setError('" . $row['_ID_']['value'] . "','','" . $this->jsEscape($error) . "');";
301
+ }
302
+ foreach ($row as $property_key => $property) {
303
+ if (isset($property['messages'])) {
304
+ $error = '';
305
+ foreach ($property['messages'] as $message) {
306
+ $error .= "<p>" . $this->__($message) . "</p>";
307
+ }
308
+ if ($error != '') {
309
+ $script .= "ocseditor.setError('" . $row['_ID_']['value'] . "','" . $property_key . "','"
310
+ . $this->jsEscape($error
311
+ . ($property['value'] != $property['original_value'] ?
312
+ "<p>"
313
+ . $this->button('Correct', "ocseditor.correct('" . $row['_ID_']['value'] . "','" . $property_key . "','" . $this->jsEscape($property['value']) . "');")
314
+ . "</p>" : '')
315
+ ) . "');";
316
+ }
317
+ }
318
+ }
319
+ }
320
+ //$script .= "alert('".str_replace(array("\r\n","\n","\'","'"),array(" "," ","\\\'","\'"),$script)."');";
321
+ return $script;
322
+ }
323
+
324
+ private function loadConfig($input) {
325
+ include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
326
+
327
+ $helper = new ChronorelaisShippingHelper($input);
328
+ $helper->checkConfig();
329
+ $config = $helper->getConfig();
330
+ //print_r($config);
331
+
332
+ $output = "<div class=\"buttons-set\">"
333
+ . $this->button('Add a shipping method', "ocseditor.addRow();", 'add')
334
+ . "</div><div class=\"config-container\">";
335
+ $i = 0;
336
+ foreach ($config as &$row) {
337
+ $output .= $this->getRowUI($row, $i == 0);
338
+ $i++;
339
+ }
340
+ $output .= "</div><script type=\"text/javascript\">" . $this->getConfigErrors($config) . "</script>";
341
+ return $output;
342
+ }
343
+
344
+ public function indexAction() {
345
+ header('Content-Type: text/html; charset=UTF-8');
346
+
347
+ include_once $this->getIncludingPath('countries.inc.php');
348
+
349
+ switch ($_POST['what']) {
350
+ case 'open':
351
+ $output = ""
352
+ // Donate page
353
+ //.$this->page('donate',"Support the development of Chronorelais Shipping extension",$this->__('{ocseditor.donate-page.content}'))
354
+ // Help page
355
+ . $this->page('help', "Chronorelais Shipping extension help", '')
356
+ // Main page
357
+ . $this->pageHeader("Chronorelais Shipping configuration editor", $this->button('Save', "ocseditor.save();", 'save')
358
+ . $this->button('Export', "ocseditor.saveToFile();", '')
359
+ . $this->button('Load', "ocseditor.showConfigLoader();", '')
360
+ . $this->button('Close', "ocseditor.close();", 'cancel')
361
+ )
362
+ . "<div id=\"ocs-editor-config-loader\">"
363
+ . "<textarea></textarea>"
364
+ . "<div class=\"buttons-set\">"
365
+ . $this->button('Load', "ocseditor.loadConfig();", '')
366
+ . $this->button('Cancel', "ocseditor.hideConfigLoader();", 'cancel')
367
+ . "</div>"
368
+ . "</div>"
369
+ . "<div id=\"ocs-editor-config-container\">" . $this->loadConfig($_POST['input']) . "</div>"
370
+ /* ."<div class=\"donate-container\">"
371
+ ."<table cellspacing=\"0\"><tr>"
372
+ ."<td>".$this->__('You appreciate this extension and would like to help?')."</td>"
373
+ ."<td class=\"form-buttons\">"
374
+ .$this->button('Donate',"ocseditor.openPage('donate');",'donate')
375
+ ."</td>"
376
+ ."</tr></table>"
377
+ ."</div>" */
378
+ ;
379
+ echo $output;
380
+ exit;
381
+ case 'help':
382
+ echo $this->__('{ocseditor.help.' . $_POST['input'] . '}');
383
+ exit;
384
+ case 'add-row':
385
+ echo $this->getRowUI(array(), true);
386
+ exit;
387
+ case 'load-config':
388
+ echo $this->loadConfig($_POST['config']);
389
+ exit;
390
+ case 'check-config':
391
+ include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
392
+
393
+ $helper = new ChronorelaisShippingHelper(urldecode($_POST['config']));
394
+ $helper->checkConfig();
395
+ print_r($helper->getConfig(), $out);
396
+ //$script = "alert('".$this->jsEscape(urldecode($_POST['config']))."');";
397
+ $script = $this->getConfigErrors($helper->getConfig());
398
+ //$script = "alert('".$this->jsEscape($this->getConfigErrors($helper->getConfig()))."');";
399
+ break;
400
+ case 'save-to-file':
401
+ include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
402
+
403
+ $helper = new ChronorelaisShippingHelper(urldecode($_POST['config']));
404
+ $formatted_config = $helper->formatConfig(false);
405
+ $this->forceDownload('chronorelais-shipping-config.txt', $formatted_config);
406
+ exit;
407
+ case 'get-address-filters':
408
+ $result = $this->parseAddressFilter($_POST['input']);
409
+ echo $this->getAddressFilters($result);
410
+ exit;
411
+ }
412
+
413
+ echo "<script type=\"text/javascript\">" . $script . "</script>";
414
+ exit;
415
+ }
416
+
417
+ public function checkloginAction() {
418
+ $params = $this->getRequest()->getParams();
419
+ $account_number = $params['account_number'];
420
+ $sub_account_number = $params['sub_account_number'];
421
+ $account_pass = $params['account_pass'];
422
+ $helper = Mage::helper('chronorelais');
423
+
424
+ $WSParams = array(
425
+ 'accountNumber' => $account_number,
426
+ 'password' => $account_pass,
427
+ 'depCountryCode' => $helper->getConfigurationShipperInfo('country'),
428
+ 'depZipCode' => $helper->getConfigurationShipperInfo('zipcode'),
429
+ 'arrCountryCode' => $helper->getConfigurationShipperInfo('country'),
430
+ 'arrZipCode' => $helper->getConfigurationShipperInfo('zipcode'),
431
+ 'arrCity' => $helper->getConfigurationShipperInfo('city'),
432
+ 'type' => 'M',
433
+ 'weight' => 1
434
+ );
435
+
436
+ $helperWS = Mage::helper('chronorelais/webservice');
437
+ $webservbt = (array)$helperWS->checkLogin($WSParams);
438
+
439
+ echo json_encode($webservbt);
440
+ }
441
+
442
+ public function checkConflictsAction() {
443
+ // Vérification
444
+ echo '<pre style="background: #000; color: #FFF; padding: 5px 10px; margin-top: 5px; border: 1px solid #0F0; font-family: Courier, Sans Serif; white-space: normal; text-indent: -20px; padding-left: 30px; line-height: 15px;">' . Mage::helper('chronorelais/conflicts')->checkForConflicts() . '</pre>';
445
+ }
446
+ }
app/code/community/Chronopost/Chronorelais/controllers/Checkout/OnepageController.php CHANGED
@@ -1,282 +1,247 @@
1
- <?php
2
-
3
- require_once 'Mage/Checkout/controllers/OnepageController.php';
4
-
5
- class Chronopost_Chronorelais_Checkout_OnepageController extends Mage_Checkout_OnepageController {
6
-
7
- protected $_sectionUpdateFunctions = array(
8
- 'payment-method' => '_getPaymentMethodsHtml',
9
- 'shipping-method' => '_getShippingMethodsHtml',
10
- 'review' => '_getReviewHtml',
11
- 'shipping-method-chronorelais' => '_getReviewHtml',
12
- );
13
-
14
- /**
15
- * Get payment method step html
16
- *
17
- * @return string
18
- */
19
- protected function _getChronoRelaisHtml() {
20
- return $this->getLayout()->getBlock('root')->toHtml();
21
- }
22
-
23
- /**
24
- * Checkout page
25
- */
26
- public function indexAction() {
27
- if (!extension_loaded('soap')) {
28
- if (Mage::helper('chronorelais')->getConfigData('carriers/chronopost/active') || Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/active') || Mage::helper('chronorelais')->getConfigData('carriers/chronoexpress/active')) {
29
- Mage::getSingleton('checkout/session')->addError($this->__('The SOAP extension is not installed in the server. Please contact the site administrator. Sorry for inconvenience.'));
30
- $this->_redirect('checkout/cart');
31
- return;
32
- }
33
- }
34
- parent::indexAction();
35
- }
36
-
37
- /**
38
- * save checkout billing address
39
- */
40
- public function saveBillingAction() {
41
- if ($this->_expireAjax()) {
42
- return;
43
- }
44
- if ($this->getRequest()->isPost()) {
45
- // $postData = $this->getRequest()->getPost('billing', array());
46
- // $data = $this->_filterPostData($postData);
47
- $data = $this->getRequest()->getPost('billing', array());
48
- $customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
49
-
50
- if (isset($data['email'])) {
51
- $data['email'] = trim($data['email']);
52
- }
53
- $result = $this->getOnepage()->saveBilling($data, $customerAddressId);
54
-
55
- if (!isset($result['error'])) {
56
- /* check quote for virtual */
57
- if ($this->getOnepage()->getQuote()->isVirtual()) {
58
- $result['goto_section'] = 'payment';
59
- $result['update_section'] = array(
60
- 'name' => 'payment-method',
61
- 'html' => $this->_getPaymentMethodsHtml()
62
- );
63
- } elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
64
- $result['goto_section'] = 'shipping_method';
65
- $result['update_section'] = array(
66
- 'name' => 'shipping-method',
67
- 'html' => $this->_getShippingMethodsHtml()
68
- );
69
-
70
- $result['allow_sections'] = array('shipping');
71
- $result['duplicateBillingInfo'] = 'true';
72
-
73
- //WEC chronorelais
74
- if (isset($_SESSION["customer_shipping_address_reference"])) {
75
- unset($_SESSION["customer_shipping_address_reference"]);
76
- }
77
-
78
- if (!array_key_exists("company", $data)) {
79
- $data["company"] = "";
80
- }
81
-
82
- $_SESSION["customer_shipping_address_reference"]["data"] = $data;
83
- $_SESSION["customer_shipping_address_reference"]["customerAddressId"] = $customerAddressId;
84
- $_SESSION["customer_shipping_address_reference"]["available"] = false;
85
- //ENDWEC
86
- } else {
87
- $result['goto_section'] = 'shipping';
88
- }
89
- }
90
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
91
- }
92
- }
93
-
94
- /**
95
- * Shipping address save action
96
- */
97
- public function saveShippingAction() {
98
- if ($this->_expireAjax()) {
99
- return;
100
- }
101
- if ($this->getRequest()->isPost()) {
102
- $data = $this->getRequest()->getPost('shipping', array());
103
- $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
104
- $result = $this->getOnepage()->saveShipping($data, $customerAddressId);
105
-
106
- if (!isset($result['error'])) {
107
- $result['goto_section'] = 'shipping_method';
108
- $result['update_section'] = array(
109
- 'name' => 'shipping-method',
110
- 'html' => $this->_getShippingMethodsHtml()
111
- );
112
- }
113
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
114
- }
115
-
116
- //WEC chronorelais
117
- if (isset($_SESSION["customer_shipping_address_reference"])) {
118
- unset($_SESSION["customer_shipping_address_reference"]);
119
- }
120
- if (!array_key_exists("company", $data)) {
121
- $data["company"] = "";
122
- }
123
- $_SESSION["customer_shipping_address_reference"]["data"] = $data;
124
- $_SESSION["customer_shipping_address_reference"]["customerAddressId"] = $customerAddressId;
125
- $_SESSION["customer_shipping_address_reference"]["available"] = false;
126
-
127
- //ENDWEC
128
- }
129
-
130
- /**
131
- * Shipping method save action
132
- */
133
- public function saveShippingMethodAction() {
134
- if ($this->_expireAjax()) {
135
- return;
136
- }
137
- if ($this->getRequest()->isPost()) {
138
-
139
- //WEC chronorelais
140
- if ($_SESSION["customer_shipping_address_reference"]["available"]) {
141
- $data = $_SESSION["customer_shipping_address_reference"]["data"];
142
- $customerAddressId = $_SESSION["customer_shipping_address_reference"]["customerAddressId"];
143
- $_SESSION["customer_shipping_address_reference"]["available"] = false;
144
-
145
- $result = $this->getOnepage()->saveShipping($data, $customerAddressId);
146
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
147
- }
148
-
149
- $method = $this->getRequest()->getParam('shipping_method');
150
- $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
151
- $address = $quote->getShippingAddress();
152
-
153
- if (substr($this->getRequest()->getParam('shipping_method'), 0, 12) == "chronorelais") {
154
- $relaisId = $this->getRequest()->getParam('shipping_method_chronorelais');
155
- if ($relaisId != "") {
156
-
157
- $helper = Mage::helper('chronorelais/webservice');
158
- $relais = $helper->getDetailRelaisPoint($relaisId);
159
-
160
- if ($relais) {
161
- $address->setCity($relais->localite)
162
- ->setPostcode($relais->codePostal)
163
- ->setStreet(trim($relais->adresse1 . "\n" . $relais->adresse2 . " " . $relais->adresse3))
164
- ->setCompany($relais->nomEnseigne)
165
- ->setWRelayPointCode($relais->identifiantChronopostPointA2PAS)
166
- ->save()
167
- ->setCollectShippingRates(true);
168
-
169
- $_SESSION["customer_shipping_address_reference"]["available"] = true;
170
- }
171
- }
172
- }
173
-
174
- $methodTitle = "";
175
- if (isset($relais->localite)) {
176
- $methodTitle = ' - ' . $relais->nomEnseigne . ' - ' . trim($relais->adresse1 . " " . $relais->adresse2 . " " . $relais->adresse3) . ' - ' . $relais->codePostal . ' - ' . $relais->localite;
177
- }
178
- if ($method) {
179
- foreach ($address->getAllShippingRates() as $rate) {
180
- if ($rate->getCode() == $method) {
181
- $address->setShippingDescription($rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle() . $methodTitle);
182
- break;
183
- }
184
- }
185
- }
186
- //ENDWEC chronorelais
187
-
188
- $data = $this->getRequest()->getPost('shipping_method', '');
189
- $result = $this->getOnepage()->saveShippingMethod($data);
190
- /*
191
- $result will have erro data if shipping method is empty
192
- */
193
- if (!$result) {
194
- Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method', array('request' => $this->getRequest(),
195
- 'quote' => $this->getOnepage()->getQuote()));
196
- $this->getOnepage()->getQuote()->collectTotals();
197
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
198
-
199
- $result['goto_section'] = 'payment';
200
- $result['update_section'] = array(
201
- 'name' => 'payment-method',
202
- 'html' => $this->_getPaymentMethodsHtml()
203
- );
204
- }
205
- $this->getOnepage()->getQuote()->collectTotals()->save();
206
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
207
- }
208
- }
209
-
210
- /**
211
- * Get relais
212
- */
213
- public function getRelaisAction() {
214
- if ($this->_expireAjax()) {
215
- return;
216
- }
217
- $result = array();
218
- $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
219
- $address = $quote->getShippingAddress();
220
- $postcode = $address->getPostcode();
221
-
222
- if (extension_loaded('soap')) {
223
-
224
- $helper = Mage::helper('chronorelais/webservice');
225
- $webservbt = $helper->getPointRelaisByAddress();
226
-
227
- if ($webservbt) {
228
- $this->loadLayout('checkout_onepage_shippingchronorelais');
229
- $result['goto_section'] = 'shipping-method';
230
- $result['update_section'] = array(
231
- 'name' => 'shipping-method-chronorelais',
232
- 'html' => $this->_getChronoRelaisHtml()
233
- );
234
- $result['relaypoints'] = $webservbt;
235
- } else {
236
- $result['error'] = true;
237
- $result['message'] = $this->__('No point relay is associated with this postcode');
238
- }
239
- } else {
240
- $result['error'] = true;
241
- $result['message'] = $this->__('Sorry for inconvenience, The SOAP extension is not installed in the server. Please contact the site administrator.');
242
- }
243
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
244
- }
245
-
246
- /**
247
- * Change shipping postal code
248
- */
249
- public function changePostalCodeAction() {
250
- if ($this->_expireAjax()) {
251
- return;
252
- }
253
- $result = array();
254
- $webservbt = array();
255
- $postcode = $this->getRequest()->getPost('mappostalcode');
256
- if ($postcode) {
257
- $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
258
- $address = $quote->getShippingAddress();
259
- $address->setPostcode($postcode)
260
- ->save()
261
- ->setCollectShippingRates(true);
262
-
263
- $helper = Mage::helper('chronorelais/webservice');
264
- $webservbt = $helper->getPointsRelaisByCp($postcode);
265
-
266
- }
267
- if ($webservbt) {
268
- $this->loadLayout('checkout_onepage_shippingchronorelais');
269
- $result['goto_section'] = 'shipping-method';
270
- $result['update_section'] = array(
271
- 'name' => 'shipping-method-chronorelais',
272
- 'html' => $this->_getChronoRelaisHtml()
273
- );
274
- $result['relaypoints'] = $webservbt;
275
- } else {
276
- $result['error'] = true;
277
- $result['message'] = $this->__('No point relay is associated with this postcode');
278
- }
279
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
280
- }
281
-
282
  }
1
+ <?php
2
+
3
+ require_once 'Mage/Checkout/controllers/OnepageController.php';
4
+
5
+ class Chronopost_Chronorelais_Checkout_OnepageController extends Mage_Checkout_OnepageController {
6
+
7
+ protected $_sectionUpdateFunctions = array(
8
+ 'payment-method' => '_getPaymentMethodsHtml',
9
+ 'shipping-method' => '_getShippingMethodsHtml',
10
+ 'review' => '_getReviewHtml',
11
+ 'shipping-method-chronorelais' => '_getReviewHtml',
12
+ );
13
+
14
+ /**
15
+ * Get payment method step html
16
+ *
17
+ * @return string
18
+ */
19
+ protected function _getChronoRelaisHtml() {
20
+ return $this->getLayout()->getBlock('root')->toHtml();
21
+ }
22
+
23
+ /**
24
+ * Checkout page
25
+ */
26
+ public function indexAction() {
27
+ if (!extension_loaded('soap')) {
28
+ if (Mage::helper('chronorelais')->getConfigData('carriers/chronopost/active') || Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/active') || Mage::helper('chronorelais')->getConfigData('carriers/chronoexpress/active')) {
29
+ Mage::getSingleton('checkout/session')->addError($this->__('The SOAP extension is not installed in the server. Please contact the site administrator. Sorry for inconvenience.'));
30
+ $this->_redirect('checkout/cart');
31
+ return;
32
+ }
33
+ }
34
+ parent::indexAction();
35
+ }
36
+
37
+ /**
38
+ * save checkout billing address
39
+ */
40
+ public function saveBillingAction() {
41
+ if ($this->_expireAjax()) {
42
+ return;
43
+ }
44
+ if ($this->getRequest()->isPost()) {
45
+ // $postData = $this->getRequest()->getPost('billing', array());
46
+ // $data = $this->_filterPostData($postData);
47
+ $data = $this->getRequest()->getPost('billing', array());
48
+ $customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
49
+
50
+ if (isset($data['email'])) {
51
+ $data['email'] = trim($data['email']);
52
+ }
53
+ $result = $this->getOnepage()->saveBilling($data, $customerAddressId);
54
+
55
+ if (!isset($result['error'])) {
56
+ /* check quote for virtual */
57
+ if ($this->getOnepage()->getQuote()->isVirtual()) {
58
+ $result['goto_section'] = 'payment';
59
+ $result['update_section'] = array(
60
+ 'name' => 'payment-method',
61
+ 'html' => $this->_getPaymentMethodsHtml()
62
+ );
63
+ } elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
64
+ $result['goto_section'] = 'shipping_method';
65
+ $result['update_section'] = array(
66
+ 'name' => 'shipping-method',
67
+ 'html' => $this->_getShippingMethodsHtml()
68
+ );
69
+
70
+ $result['allow_sections'] = array('shipping');
71
+ $result['duplicateBillingInfo'] = 'true';
72
+
73
+ //WEC chronorelais
74
+ if (isset($_SESSION["customer_shipping_address_reference"])) {
75
+ unset($_SESSION["customer_shipping_address_reference"]);
76
+ }
77
+
78
+ if (!array_key_exists("company", $data)) {
79
+ $data["company"] = "";
80
+ }
81
+
82
+ $_SESSION["customer_shipping_address_reference"]["data"] = $data;
83
+ $_SESSION["customer_shipping_address_reference"]["customerAddressId"] = $customerAddressId;
84
+ $_SESSION["customer_shipping_address_reference"]["available"] = false;
85
+ //ENDWEC
86
+ } else {
87
+ $result['goto_section'] = 'shipping';
88
+ }
89
+ }
90
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Shipping address save action
96
+ */
97
+ public function saveShippingAction() {
98
+ parent::saveShippingAction();
99
+
100
+ //WEC chronorelais
101
+ if (isset($_SESSION["customer_shipping_address_reference"])) {
102
+ unset($_SESSION["customer_shipping_address_reference"]);
103
+ }
104
+ if (!array_key_exists("company", $data)) {
105
+ $data["company"] = "";
106
+ }
107
+ $_SESSION["customer_shipping_address_reference"]["data"] = $data;
108
+ $_SESSION["customer_shipping_address_reference"]["customerAddressId"] = $customerAddressId;
109
+ $_SESSION["customer_shipping_address_reference"]["available"] = false;
110
+ //ENDWEC
111
+ }
112
+
113
+ /**
114
+ * Shipping method save action
115
+ */
116
+ public function saveShippingMethodAction() {
117
+ if ($this->_expireAjax()) {
118
+ return;
119
+ }
120
+ if ($this->getRequest()->isPost()) {
121
+
122
+ //WEC chronorelais
123
+ if ($_SESSION["customer_shipping_address_reference"]["available"]) {
124
+ $data = $_SESSION["customer_shipping_address_reference"]["data"];
125
+ $customerAddressId = $_SESSION["customer_shipping_address_reference"]["customerAddressId"];
126
+ $_SESSION["customer_shipping_address_reference"]["available"] = false;
127
+
128
+ $result = $this->getOnepage()->saveShipping($data, $customerAddressId);
129
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
130
+ }
131
+
132
+ $method = $this->getRequest()->getParam('shipping_method');
133
+ $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
134
+ $address = $quote->getShippingAddress();
135
+
136
+ if (substr($this->getRequest()->getParam('shipping_method'), 0, 12) == "chronorelais") {
137
+ $relaisId = $this->getRequest()->getParam('shipping_method_chronorelais');
138
+ if ($relaisId != "") {
139
+
140
+ $helper = Mage::helper('chronorelais/webservice');
141
+ $relais = $helper->getDetailRelaisPoint($relaisId);
142
+
143
+ if ($relais) {
144
+ $address->setCity($relais->localite)
145
+ ->setPostcode($relais->codePostal)
146
+ ->setStreet(trim($relais->adresse1 . "\n" . $relais->adresse2 . " " . $relais->adresse3))
147
+ ->setCompany($relais->nomEnseigne)
148
+ ->setWRelayPointCode($relais->identifiantChronopostPointA2PAS)
149
+ ->save()
150
+ ->setCollectShippingRates(true);
151
+
152
+ $_SESSION["customer_shipping_address_reference"]["available"] = true;
153
+ }
154
+ }
155
+ }
156
+
157
+ $methodTitle = "";
158
+ if (isset($relais->localite)) {
159
+ $methodTitle = ' - ' . $relais->nomEnseigne . ' - ' . trim($relais->adresse1 . " " . $relais->adresse2 . " " . $relais->adresse3) . ' - ' . $relais->codePostal . ' - ' . $relais->localite;
160
+ }
161
+ if ($method) {
162
+ foreach ($address->getAllShippingRates() as $rate) {
163
+ if ($rate->getCode() == $method) {
164
+ $address->setShippingDescription($rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle() . $methodTitle);
165
+ break;
166
+ }
167
+ }
168
+ }
169
+ //ENDWEC chronorelais
170
+
171
+ parent::saveShippingMethodAction();
172
+ }
173
+ }
174
+
175
+ /**
176
+ * Get relais
177
+ */
178
+ public function getRelaisAction() {
179
+ if ($this->_expireAjax()) {
180
+ return;
181
+ }
182
+ $result = array();
183
+ $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
184
+ $address = $quote->getShippingAddress();
185
+ $postcode = $address->getPostcode();
186
+
187
+ if (extension_loaded('soap')) {
188
+
189
+ $helper = Mage::helper('chronorelais/webservice');
190
+ $webservbt = $helper->getPointRelaisByAddress();
191
+
192
+ if ($webservbt) {
193
+ $this->loadLayout('checkout_onepage_shippingchronorelais');
194
+ $result['goto_section'] = 'shipping-method';
195
+ $result['update_section'] = array(
196
+ 'name' => 'shipping-method-chronorelais',
197
+ 'html' => $this->_getChronoRelaisHtml()
198
+ );
199
+ $result['relaypoints'] = $webservbt;
200
+ } else {
201
+ $result['error'] = true;
202
+ $result['message'] = $this->__('No point relay is associated with this postcode');
203
+ }
204
+ } else {
205
+ $result['error'] = true;
206
+ $result['message'] = $this->__('Sorry for inconvenience, The SOAP extension is not installed in the server. Please contact the site administrator.');
207
+ }
208
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
209
+ }
210
+
211
+ /**
212
+ * Change shipping postal code
213
+ */
214
+ public function changePostalCodeAction() {
215
+ if ($this->_expireAjax()) {
216
+ return;
217
+ }
218
+ $result = array();
219
+ $webservbt = array();
220
+ $postcode = $this->getRequest()->getPost('mappostalcode');
221
+ if ($postcode) {
222
+ $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
223
+ $address = $quote->getShippingAddress();
224
+ $address->setPostcode($postcode)
225
+ ->save()
226
+ ->setCollectShippingRates(true);
227
+
228
+ $helper = Mage::helper('chronorelais/webservice');
229
+ $webservbt = $helper->getPointsRelaisByCp($postcode);
230
+
231
+ }
232
+ if ($webservbt) {
233
+ $this->loadLayout('checkout_onepage_shippingchronorelais');
234
+ $result['goto_section'] = 'shipping-method';
235
+ $result['update_section'] = array(
236
+ 'name' => 'shipping-method-chronorelais',
237
+ 'html' => $this->_getChronoRelaisHtml()
238
+ );
239
+ $result['relaypoints'] = $webservbt;
240
+ } else {
241
+ $result['error'] = true;
242
+ $result['message'] = $this->__('No point relay is associated with this postcode');
243
+ }
244
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
245
+ }
246
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  }
app/code/community/Chronopost/Chronorelais/controllers/ExportController.php CHANGED
@@ -1,448 +1,448 @@
1
- <?php
2
-
3
- class Chronopost_Chronorelais_ExportController extends Mage_Adminhtml_Controller_Action {
4
-
5
- /**
6
- * Constructor
7
- */
8
- protected function _construct() {
9
- $this->setUsedModuleName('Chronopost_Chronorelais');
10
- }
11
-
12
- /**
13
- * Main action : show orders list
14
- */
15
- public function indexAction() {
16
- $this->loadLayout()
17
- ->_setActiveMenu('sales/chronorelais/export')
18
- ->_addContent($this->getLayout()->createBlock('chronorelais/export_orders'))
19
- ->renderLayout();
20
- }
21
-
22
- public function getValue($value) {
23
- return ($value != '' ? $value : '');
24
- }
25
-
26
- public function removeSpclChars($text) {
27
- //return ereg_replace("[^0-9a-zA-Z]", "", $text);
28
- return preg_replace("/[^0-9a-zA-Z]/", "", $text);
29
- }
30
-
31
- public function massLivraisonSamediStatusAction() {
32
- if ($this->getRequest()->getPost('status')) {
33
- $this->saveLivraisonSamediStatusAction();
34
- }
35
- }
36
-
37
- public function massExportAction() {
38
- if ($this->getRequest()->getPost('format') == 'css') {
39
- $this->exportcssAction();
40
- } elseif ($this->getRequest()->getPost('format') == 'cso') {
41
- $this->exportcsoAction();
42
- }
43
- }
44
-
45
- /**
46
- * Export CSS Action
47
- * Generates a CSV file to download (CSS format)
48
- */
49
- public function exportcssAction() {
50
- /* get the orders */
51
- $orderIds = $this->getRequest()->getPost('order_ids');
52
-
53
- /**
54
- * Get configuration
55
- */
56
- $separator = Mage::helper('chronorelais')->getConfigurationFieldSeparator('css');
57
- $delimiter = Mage::helper('chronorelais')->getConfigurationFieldDelimiter('css');
58
-
59
- if ($delimiter == 'simple_quote') {
60
- $delimiter = "'";
61
- } else if ($delimiter == 'double_quotes') {
62
- $delimiter = '"';
63
- } else {
64
- $delimiter = '';
65
- }
66
- $lineBreak = Mage::helper('chronorelais')->getConfigurationEndOfLineCharacter('css');
67
- if ($lineBreak == 'lf') {
68
- $lineBreak = "\n";
69
- } else if ($lineBreak == 'cr') {
70
- $lineBreak = "\r";
71
- } else if ($lineBreak == 'crlf') {
72
- $lineBreak = "\r\n";
73
- }
74
- $fileExtension = Mage::helper('chronorelais')->getConfigurationFileExtension('css');
75
- $fileCharset = Mage::helper('chronorelais')->getConfigurationFileCharset('css');
76
-
77
- /* set the filename */
78
- $filename = 'orders_exportcss_' . Mage::getSingleton('core/date')->date('Ymd_His') . $fileExtension;
79
-
80
- /* initialize the content variable */
81
- $content = '';
82
- $helper = Mage::helper('chronorelais');
83
- $weightUnit = $helper->getConfigWeightUnit();
84
- if (!empty($orderIds)) {
85
- foreach ($orderIds as $orderId) {
86
-
87
- /* get the order */
88
- $order = Mage::getModel('sales/order')->load($orderId);
89
- $address = $order->getShippingAddress();
90
- $billingAddress = $order->getBillingAddress();
91
-
92
- $_shippingMethod = explode('_', $order->getShippingMethod());
93
-
94
- /* customer id */
95
- $content = $this->_addFieldToCsv($content, $delimiter, ($order->getCustomerId() ? $order->getCustomerId() : $address->getLastname()));
96
- $content .= $separator;
97
- /* Nom du point relais OU soci�t� si livraison � domicile */
98
- //$content = $this->_addFieldToCsv($content, $delimiter, $_shippingMethod[0] == "chronorelais" ? $address->getCompany() : "");
99
- $content = $this->_addFieldToCsv($content, $delimiter, $address->getCompany());
100
- $content .= $separator;
101
- /* customer name */
102
- $content = $this->_addFieldToCsv($content, $delimiter, ($address->getName() ? $address->getName() : $billingAddress->getName()));
103
- $content .= $separator;
104
- /* street address */
105
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(1)));
106
- $content .= $separator;
107
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(2)));
108
- $content .= $separator;
109
- /* postal code */
110
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getPostcode()));
111
- $content .= $separator;
112
- /* city */
113
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCity()));
114
- $content .= $separator;
115
- /* country code */
116
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCountry()));
117
- $content .= $separator;
118
- /* telephone */
119
- $telephone = trim(ereg_replace("[^0-9.-]", " ", $address->getTelephone()));
120
- $telephone = (strlen($telephone) >= 10 ? $telephone : '');
121
- $content = $this->_addFieldToCsv($content, $delimiter, $telephone);
122
- $content .= $separator;
123
- /* email */
124
- $customer_email = ($address->getEmail()) ? $address->getEmail() : ($billingAddress->getEmail() ? $billingAddress->getEmail() : $order->getCustomerEmail());
125
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($customer_email));
126
- $content .= $separator;
127
- /* chronorelay point */
128
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getWRelayPointCode()));
129
- $content .= $separator;
130
- /* real order id */
131
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($order->getRealOrderId()));
132
- $content .= $separator;
133
-
134
-
135
- /* total weight (in kg) */
136
- $order_weight = number_format($order->getWeight(), 2, '.', '');
137
- if($weightUnit == 'g') {
138
- $order_weight = $order_weight / 1000;
139
- }
140
- //$order_weight = $order_weight * 1000;
141
- $content = $this->_addFieldToCsv($content, $delimiter, $order_weight);
142
- $content .= $separator;
143
-
144
- /* productCode */
145
- $productCode = ''; //Default code for chronorelais
146
- $productCode = Mage::helper('chronorelais')->getChronoProductCodeString($_shippingMethod[0]);
147
- $content = $this->_addFieldToCsv($content, $delimiter, $productCode);
148
- $content .= $separator;
149
-
150
- /* Livraison Samedi */
151
- $SaturdayShipping = 'L'; //default value for the saturday shipping
152
- $send_day = strtolower(date('l'));
153
- if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
154
- if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($orderId)) {
155
- $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
156
- } else {
157
- if ($_deliver_on_saturday == 'Yes') {
158
- $_deliver_on_saturday = 1;
159
- } else {
160
- $_deliver_on_saturday = 0;
161
- }
162
- }
163
- $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
164
- if ($_deliver_on_saturday && $is_sending_day == true) {
165
- $SaturdayShipping = 'S';
166
- } elseif (!$_deliver_on_saturday && $is_sending_day == true) {
167
- $SaturdayShipping = 'L';
168
- }
169
- }
170
- $content = $this->_addFieldToCsv($content, $delimiter, $SaturdayShipping);
171
- $content .= $separator;
172
-
173
- /* empty fields */
174
- $content = $this->_addFieldToCsv($content, $delimiter, 0);
175
- $content .= $separator;
176
- $content = $this->_addFieldToCsv($content, $delimiter, 0);
177
- $content .= $lineBreak;
178
- }
179
-
180
- /* decode the content, depending on the charset */
181
- if ($fileCharset == 'ISO-8859-1') {
182
- $content = utf8_decode($content);
183
- }
184
-
185
- /* pick file mime type, depending on the extension */
186
- if ($fileExtension == '.txt') {
187
- $fileMimeType = 'text/plain';
188
- } else if ($fileExtension == '.csv') {
189
- $fileMimeType = 'application/csv';
190
- } else if ($fileExtension == '.chr') {
191
- $fileMimeType = 'application/chr';
192
- } else {
193
- // default
194
- $fileMimeType = 'text/plain';
195
- }
196
-
197
- /* download the file */
198
- return $this->_prepareDownloadResponse($filename, $content, $fileMimeType . '; charset="' . $fileCharset . '"');
199
- } else {
200
- $this->_getSession()->addError($this->__('No Order has been selected'));
201
- }
202
- }
203
-
204
- /**
205
- * Export CSO Action
206
- * Generates a CSV file to download (CSO format)
207
- */
208
- public function exportcsoAction() {
209
- /* get the orders */
210
- $orderIds = $this->getRequest()->getPost('order_ids');
211
-
212
- /**
213
- * Get configuration
214
- */
215
- $separator = Mage::helper('chronorelais')->getConfigurationFieldSeparator('cso');
216
- $delimiter = Mage::helper('chronorelais')->getConfigurationFieldDelimiter('cso');
217
- if ($delimiter == 'simple_quote') {
218
- $delimiter = "'";
219
- } else if ($delimiter == 'double_quotes') {
220
- $delimiter = '"';
221
- } else {
222
- $delimiter = '';
223
- }
224
- $lineBreak = Mage::helper('chronorelais')->getConfigurationEndOfLineCharacter('cso');
225
- if ($lineBreak == 'lf') {
226
- $lineBreak = "\n";
227
- } else if ($lineBreak == 'cr') {
228
- $lineBreak = "\r";
229
- } else if ($lineBreak == 'crlf') {
230
- $lineBreak = "\r\n";
231
- }
232
- $fileExtension = Mage::helper('chronorelais')->getConfigurationFileExtension('cso');
233
- $fileCharset = Mage::helper('chronorelais')->getConfigurationFileCharset('cso');
234
-
235
- /* set the filename */
236
- $filename = 'orders_exportcso_' . Mage::getSingleton('core/date')->date('Ymd_His') . $fileExtension;
237
-
238
- /* initialize the content variable */
239
- $content = '';
240
- $helper = Mage::helper('chronorelais');
241
- $weightUnit = $helper->getConfigWeightUnit();
242
- if (!empty($orderIds)) {
243
- foreach ($orderIds as $orderId) {
244
-
245
- /* get the order */
246
- $order = Mage::getModel('sales/order')->load($orderId);
247
- $address = $order->getShippingAddress();
248
- $billingAddress = $order->getBillingAddress();
249
-
250
- /* customer id */
251
- $content = $this->_addFieldToCsv($content, $delimiter, ($order->getCustomerId() ? $order->getCustomerId() : $address->getLastname()));
252
- $content .= $separator;
253
- /* Nom du point relais OU soci�t� si livraison � domicile */
254
- //$content = $this->_addFieldToCsv($content, $delimiter, $_shippingMethod[0] == "chronorelais" ? $address->getCompany() : "");
255
- $content = $this->_addFieldToCsv($content, $delimiter, $address->getCompany());
256
- $content .= $separator;
257
- /* empty */
258
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
259
- $content .= $separator;
260
- /* street address */
261
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(1)));
262
- $content .= $separator;
263
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(2)));
264
- $content .= $separator;
265
- /* Code Porte */
266
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
267
- $content .= $separator;
268
- /* country code */
269
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCountry()));
270
- $content .= $separator;
271
- /* postal code */
272
- $content = $this->_addFieldToCsv($content, $delimiter, $this->removeSpclChars($this->getValue($address->getPostcode())));
273
- $content .= $separator;
274
- /* city */
275
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(strtoupper($address->getCity())));
276
- $content .= $separator;
277
- /* lastname */
278
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getLastname()));
279
- $content .= $separator;
280
- /* firstname */
281
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getFirstname()));
282
- $content .= $separator;
283
- /* telephone */
284
- //$telephone = trim(ereg_replace("[^0-9.-]", " ", $address->getTelephone()));
285
- $telephone = trim(preg_replace("/[^0-9\.\-]/", " ", $address->getTelephone()));
286
-
287
- $telephone = (strlen($telephone) >= 10 ? $telephone : '');
288
- $content = $this->_addFieldToCsv($content, $delimiter, $telephone);
289
- $content .= $separator;
290
- /* email */
291
- $customer_email = ($address->getEmail()) ? $address->getEmail() : ($billingAddress->getEmail() ? $billingAddress->getEmail() : $order->getCustomerEmail());
292
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($customer_email));
293
- $content .= $separator;
294
- /* VAT number */
295
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
296
- $content .= $separator;
297
- /* productCode */
298
- $productCode = ''; //Default code for chronorelais
299
- $_shippingMethod = explode('_', $order->getShippingMethod());
300
- if ($_shippingMethod[0] == "chronopost") { // Conditions for chronorelais code
301
- $productCode = 1;
302
- } elseif ($_shippingMethod[0] == "chronorelais") {
303
- //$productCode = 6; //for chronorelais
304
- } else {
305
- $productCode = 4; //for chronoexpress
306
- }
307
- $content = $this->_addFieldToCsv($content, $delimiter, $productCode);
308
- $content .= $separator;
309
- /* real order id */
310
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($order->getRealOrderId()));
311
- $content .= $separator;
312
-
313
- /* total weight (in g)*/
314
- $order_weight = number_format($order->getWeight(), 2, '.', '');
315
- if($weightUnit == 'kg') {
316
- $order_weight = $order_weight * 1000;
317
- }
318
- $content = $this->_addFieldToCsv($content, $delimiter, $order_weight);
319
- $content .= $separator;
320
-
321
- /* Valeur Assur�e field */
322
- $content = $this->_addFieldToCsv($content, $delimiter, 0);
323
- $content .= $separator;
324
- /* Inform the recipient by e-mail field */
325
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue("N"));
326
- $content .= $separator;
327
- /* Print Waybill field */
328
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue("O"));
329
- $content .= $separator;
330
- /* sub-account field */
331
- $sub_account = Mage::helper('chronorelais')->getConfigurationSubAccountNumber();
332
- $content = $this->_addFieldToCsv($content, $delimiter, (strlen($sub_account) == 3 ? $sub_account : ""));
333
- $content .= $separator;
334
- /* Nature of item field */
335
- $content = $this->_addFieldToCsv($content, $delimiter, 2);
336
- $content .= $separator;
337
- /* Description of Consignment field */
338
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
339
- $content .= $separator;
340
- /* Print pro-forma (customs) field */
341
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue("N"));
342
- $content .= $separator;
343
- /* Declared value (customs) field */
344
- $content = $this->_addFieldToCsv($content, $delimiter, 0);
345
- $content .= $separator;
346
- /* Livraison Samedi (Delivery Saturday) field */
347
- $SaturdayShipping = 0; //default value for the saturday shipping
348
- $send_day = strtolower(date('l'));
349
- if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
350
- if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($orderId)) {
351
- $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
352
- } else {
353
- if ($_deliver_on_saturday == 'Yes') {
354
- $_deliver_on_saturday = 1;
355
- } else {
356
- $_deliver_on_saturday = 0;
357
- }
358
- }
359
- $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
360
- if ($_deliver_on_saturday && $is_sending_day) {
361
- $SaturdayShipping = 1;
362
- } elseif (!$_deliver_on_saturday && $is_sending_day) {
363
- $SaturdayShipping = 2;
364
- }
365
- }
366
- $content = $this->_addFieldToCsv($content, $delimiter, $SaturdayShipping);
367
- $content .= $lineBreak;
368
- }
369
-
370
- /* decode the content, depending on the charset */
371
- if ($fileCharset == 'ISO-8859-1') {
372
- $content = utf8_decode($content);
373
- }
374
-
375
- /* pick file mime type, depending on the extension */
376
- if ($fileExtension == '.txt') {
377
- $fileMimeType = 'text/plain';
378
- } else if ($fileExtension == '.csv') {
379
- $fileMimeType = 'application/csv';
380
- } else if ($fileExtension == '.chr') {
381
- $fileMimeType = 'application/chr';
382
- } else {
383
- // default
384
- $fileMimeType = 'text/plain';
385
- }
386
-
387
- /* download the file */
388
- return $this->_prepareDownloadResponse($filename, $content, $fileMimeType . '; charset="' . $fileCharset . '"');
389
- } else {
390
- $this->_getSession()->addError($this->__('No Order has been selected'));
391
- }
392
- }
393
-
394
- /* Save the Livraison le Samedi status to orders */
395
-
396
- public function saveLivraisonSamediStatusAction() {
397
- /* get the orders */
398
- $orderIds = $this->getRequest()->getPost('order_ids');
399
- $status = $this->getRequest()->getPost('status');
400
- $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
401
- $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
402
- $exceptions = array();
403
-
404
- foreach ($orderIds as $orderId) {
405
- $order_details = Mage::getModel('sales/order')->load($orderId);
406
- $shipping_method = '';
407
- $livraison_le_samedi = $status;
408
- if ($shipping_method = $order_details->getShippingMethod()) {
409
- $shipping_method = explode('_', $shipping_method);
410
- if ($shipping_method[0] == 'chronoexpress') {
411
- $livraison_le_samedi = '--';
412
- }
413
- }
414
- $condition = array(
415
- $_connection->quoteInto('order_id = ?', $orderId),
416
- );
417
- $_connection->delete($_table, $condition);
418
-
419
- $dataLine = array(
420
- 'order_id' => $orderId,
421
- 'livraison_le_samedi' => $livraison_le_samedi
422
- );
423
- try {
424
- $_connection->insert($_table, $dataLine);
425
- } catch (Exception $e) {
426
- $exceptions[] = Mage::helper('chronorelais')->__('Order assigning error: ' . $e->getMessage());
427
- }
428
- }
429
- if ($exceptions) {
430
- $this->_getSession()->addError($exceptions);
431
- } else {
432
- $this->_getSession()->addSuccess($this->__('Livraison le Samedi statut a &eacute;t&eacute; ajout&eacute;'));
433
- }
434
- $this->_redirect('*/*/index');
435
- }
436
-
437
- /**
438
- * Add a new field to the csv file
439
- * @param csvContent : the current csv content
440
- * @param fieldDelimiter : the delimiter character
441
- * @param fieldContent : the content to add
442
- * @return : the concatenation of current content and content to add
443
- */
444
- private function _addFieldToCsv($csvContent, $fieldDelimiter, $fieldContent) {
445
- return $csvContent . $fieldDelimiter . $fieldContent . $fieldDelimiter;
446
- }
447
-
448
  }
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_ExportController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ /**
6
+ * Constructor
7
+ */
8
+ protected function _construct() {
9
+ $this->setUsedModuleName('Chronopost_Chronorelais');
10
+ }
11
+
12
+ /**
13
+ * Main action : show orders list
14
+ */
15
+ public function indexAction() {
16
+ $this->loadLayout()
17
+ ->_setActiveMenu('sales/chronorelais/export')
18
+ ->_addContent($this->getLayout()->createBlock('chronorelais/export_orders'))
19
+ ->renderLayout();
20
+ }
21
+
22
+ public function getValue($value) {
23
+ return ($value != '' ? $value : '');
24
+ }
25
+
26
+ public function removeSpclChars($text) {
27
+ //return ereg_replace("[^0-9a-zA-Z]", "", $text);
28
+ return preg_replace("/[^0-9a-zA-Z]/", "", $text);
29
+ }
30
+
31
+ public function massLivraisonSamediStatusAction() {
32
+ if ($this->getRequest()->getPost('status')) {
33
+ $this->saveLivraisonSamediStatusAction();
34
+ }
35
+ }
36
+
37
+ public function massExportAction() {
38
+ if ($this->getRequest()->getPost('format') == 'css') {
39
+ $this->exportcssAction();
40
+ } elseif ($this->getRequest()->getPost('format') == 'cso') {
41
+ $this->exportcsoAction();
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Export CSS Action
47
+ * Generates a CSV file to download (CSS format)
48
+ */
49
+ public function exportcssAction() {
50
+ /* get the orders */
51
+ $orderIds = $this->getRequest()->getPost('order_ids');
52
+
53
+ /**
54
+ * Get configuration
55
+ */
56
+ $separator = Mage::helper('chronorelais')->getConfigurationFieldSeparator('css');
57
+ $delimiter = Mage::helper('chronorelais')->getConfigurationFieldDelimiter('css');
58
+
59
+ if ($delimiter == 'simple_quote') {
60
+ $delimiter = "'";
61
+ } else if ($delimiter == 'double_quotes') {
62
+ $delimiter = '"';
63
+ } else {
64
+ $delimiter = '';
65
+ }
66
+ $lineBreak = Mage::helper('chronorelais')->getConfigurationEndOfLineCharacter('css');
67
+ if ($lineBreak == 'lf') {
68
+ $lineBreak = "\n";
69
+ } else if ($lineBreak == 'cr') {
70
+ $lineBreak = "\r";
71
+ } else if ($lineBreak == 'crlf') {
72
+ $lineBreak = "\r\n";
73
+ }
74
+ $fileExtension = Mage::helper('chronorelais')->getConfigurationFileExtension('css');
75
+ $fileCharset = Mage::helper('chronorelais')->getConfigurationFileCharset('css');
76
+
77
+ /* set the filename */
78
+ $filename = 'orders_exportcss_' . Mage::getSingleton('core/date')->date('Ymd_His') . $fileExtension;
79
+
80
+ /* initialize the content variable */
81
+ $content = '';
82
+ $helper = Mage::helper('chronorelais');
83
+ $weightUnit = $helper->getConfigWeightUnit();
84
+ if (!empty($orderIds)) {
85
+ foreach ($orderIds as $orderId) {
86
+
87
+ /* get the order */
88
+ $order = Mage::getModel('sales/order')->load($orderId);
89
+ $address = $order->getShippingAddress();
90
+ $billingAddress = $order->getBillingAddress();
91
+
92
+ $_shippingMethod = explode('_', $order->getShippingMethod());
93
+
94
+ /* customer id */
95
+ $content = $this->_addFieldToCsv($content, $delimiter, ($order->getCustomerId() ? $order->getCustomerId() : $address->getLastname()));
96
+ $content .= $separator;
97
+ /* Nom du point relais OU soci�t� si livraison � domicile */
98
+ //$content = $this->_addFieldToCsv($content, $delimiter, $_shippingMethod[0] == "chronorelais" ? $address->getCompany() : "");
99
+ $content = $this->_addFieldToCsv($content, $delimiter, $address->getCompany());
100
+ $content .= $separator;
101
+ /* customer name */
102
+ $content = $this->_addFieldToCsv($content, $delimiter, ($address->getName() ? $address->getName() : $billingAddress->getName()));
103
+ $content .= $separator;
104
+ /* street address */
105
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(1)));
106
+ $content .= $separator;
107
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(2)));
108
+ $content .= $separator;
109
+ /* postal code */
110
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getPostcode()));
111
+ $content .= $separator;
112
+ /* city */
113
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCity()));
114
+ $content .= $separator;
115
+ /* country code */
116
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCountry()));
117
+ $content .= $separator;
118
+ /* telephone */
119
+ $telephone = trim(ereg_replace("[^0-9.-]", " ", $address->getTelephone()));
120
+ $telephone = (strlen($telephone) >= 10 ? $telephone : '');
121
+ $content = $this->_addFieldToCsv($content, $delimiter, $telephone);
122
+ $content .= $separator;
123
+ /* email */
124
+ $customer_email = ($address->getEmail()) ? $address->getEmail() : ($billingAddress->getEmail() ? $billingAddress->getEmail() : $order->getCustomerEmail());
125
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($customer_email));
126
+ $content .= $separator;
127
+ /* chronorelay point */
128
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getWRelayPointCode()));
129
+ $content .= $separator;
130
+ /* real order id */
131
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($order->getRealOrderId()));
132
+ $content .= $separator;
133
+
134
+
135
+ /* total weight (in kg) */
136
+ $order_weight = number_format($order->getWeight(), 2, '.', '');
137
+ if($weightUnit == 'g') {
138
+ $order_weight = $order_weight / 1000;
139
+ }
140
+ //$order_weight = $order_weight * 1000;
141
+ $content = $this->_addFieldToCsv($content, $delimiter, $order_weight);
142
+ $content .= $separator;
143
+
144
+ /* productCode */
145
+ $productCode = ''; //Default code for chronorelais
146
+ $productCode = Mage::helper('chronorelais')->getChronoProductCodeString($_shippingMethod[0]);
147
+ $content = $this->_addFieldToCsv($content, $delimiter, $productCode);
148
+ $content .= $separator;
149
+
150
+ /* Livraison Samedi */
151
+ $SaturdayShipping = 'L'; //default value for the saturday shipping
152
+ $send_day = strtolower(date('l'));
153
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
154
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($orderId)) {
155
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
156
+ } else {
157
+ if ($_deliver_on_saturday == 'Yes') {
158
+ $_deliver_on_saturday = 1;
159
+ } else {
160
+ $_deliver_on_saturday = 0;
161
+ }
162
+ }
163
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
164
+ if ($_deliver_on_saturday && $is_sending_day == true) {
165
+ $SaturdayShipping = 'S';
166
+ } elseif (!$_deliver_on_saturday && $is_sending_day == true) {
167
+ $SaturdayShipping = 'L';
168
+ }
169
+ }
170
+ $content = $this->_addFieldToCsv($content, $delimiter, $SaturdayShipping);
171
+ $content .= $separator;
172
+
173
+ /* empty fields */
174
+ $content = $this->_addFieldToCsv($content, $delimiter, 0);
175
+ $content .= $separator;
176
+ $content = $this->_addFieldToCsv($content, $delimiter, 0);
177
+ $content .= $lineBreak;
178
+ }
179
+
180
+ /* decode the content, depending on the charset */
181
+ if ($fileCharset == 'ISO-8859-1') {
182
+ $content = utf8_decode($content);
183
+ }
184
+
185
+ /* pick file mime type, depending on the extension */
186
+ if ($fileExtension == '.txt') {
187
+ $fileMimeType = 'text/plain';
188
+ } else if ($fileExtension == '.csv') {
189
+ $fileMimeType = 'application/csv';
190
+ } else if ($fileExtension == '.chr') {
191
+ $fileMimeType = 'application/chr';
192
+ } else {
193
+ // default
194
+ $fileMimeType = 'text/plain';
195
+ }
196
+
197
+ /* download the file */
198
+ return $this->_prepareDownloadResponse($filename, $content, $fileMimeType . '; charset="' . $fileCharset . '"');
199
+ } else {
200
+ $this->_getSession()->addError($this->__('No Order has been selected'));
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Export CSO Action
206
+ * Generates a CSV file to download (CSO format)
207
+ */
208
+ public function exportcsoAction() {
209
+ /* get the orders */
210
+ $orderIds = $this->getRequest()->getPost('order_ids');
211
+
212
+ /**
213
+ * Get configuration
214
+ */
215
+ $separator = Mage::helper('chronorelais')->getConfigurationFieldSeparator('cso');
216
+ $delimiter = Mage::helper('chronorelais')->getConfigurationFieldDelimiter('cso');
217
+ if ($delimiter == 'simple_quote') {
218
+ $delimiter = "'";
219
+ } else if ($delimiter == 'double_quotes') {
220
+ $delimiter = '"';
221
+ } else {
222
+ $delimiter = '';
223
+ }
224
+ $lineBreak = Mage::helper('chronorelais')->getConfigurationEndOfLineCharacter('cso');
225
+ if ($lineBreak == 'lf') {
226
+ $lineBreak = "\n";
227
+ } else if ($lineBreak == 'cr') {
228
+ $lineBreak = "\r";
229
+ } else if ($lineBreak == 'crlf') {
230
+ $lineBreak = "\r\n";
231
+ }
232
+ $fileExtension = Mage::helper('chronorelais')->getConfigurationFileExtension('cso');
233
+ $fileCharset = Mage::helper('chronorelais')->getConfigurationFileCharset('cso');
234
+
235
+ /* set the filename */
236
+ $filename = 'orders_exportcso_' . Mage::getSingleton('core/date')->date('Ymd_His') . $fileExtension;
237
+
238
+ /* initialize the content variable */
239
+ $content = '';
240
+ $helper = Mage::helper('chronorelais');
241
+ $weightUnit = $helper->getConfigWeightUnit();
242
+ if (!empty($orderIds)) {
243
+ foreach ($orderIds as $orderId) {
244
+
245
+ /* get the order */
246
+ $order = Mage::getModel('sales/order')->load($orderId);
247
+ $address = $order->getShippingAddress();
248
+ $billingAddress = $order->getBillingAddress();
249
+
250
+ /* customer id */
251
+ $content = $this->_addFieldToCsv($content, $delimiter, ($order->getCustomerId() ? $order->getCustomerId() : $address->getLastname()));
252
+ $content .= $separator;
253
+ /* Nom du point relais OU soci�t� si livraison � domicile */
254
+ //$content = $this->_addFieldToCsv($content, $delimiter, $_shippingMethod[0] == "chronorelais" ? $address->getCompany() : "");
255
+ $content = $this->_addFieldToCsv($content, $delimiter, $address->getCompany());
256
+ $content .= $separator;
257
+ /* empty */
258
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
259
+ $content .= $separator;
260
+ /* street address */
261
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(1)));
262
+ $content .= $separator;
263
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(2)));
264
+ $content .= $separator;
265
+ /* Code Porte */
266
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
267
+ $content .= $separator;
268
+ /* country code */
269
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCountry()));
270
+ $content .= $separator;
271
+ /* postal code */
272
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->removeSpclChars($this->getValue($address->getPostcode())));
273
+ $content .= $separator;
274
+ /* city */
275
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(strtoupper($address->getCity())));
276
+ $content .= $separator;
277
+ /* lastname */
278
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getLastname()));
279
+ $content .= $separator;
280
+ /* firstname */
281
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getFirstname()));
282
+ $content .= $separator;
283
+ /* telephone */
284
+ //$telephone = trim(ereg_replace("[^0-9.-]", " ", $address->getTelephone()));
285
+ $telephone = trim(preg_replace("/[^0-9\.\-]/", " ", $address->getTelephone()));
286
+
287
+ $telephone = (strlen($telephone) >= 10 ? $telephone : '');
288
+ $content = $this->_addFieldToCsv($content, $delimiter, $telephone);
289
+ $content .= $separator;
290
+ /* email */
291
+ $customer_email = ($address->getEmail()) ? $address->getEmail() : ($billingAddress->getEmail() ? $billingAddress->getEmail() : $order->getCustomerEmail());
292
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($customer_email));
293
+ $content .= $separator;
294
+ /* VAT number */
295
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
296
+ $content .= $separator;
297
+ /* productCode */
298
+ $productCode = ''; //Default code for chronorelais
299
+ $_shippingMethod = explode('_', $order->getShippingMethod());
300
+ if ($_shippingMethod[0] == "chronopost") { // Conditions for chronorelais code
301
+ $productCode = 1;
302
+ } elseif ($_shippingMethod[0] == "chronorelais") {
303
+ //$productCode = 6; //for chronorelais
304
+ } else {
305
+ $productCode = 4; //for chronoexpress
306
+ }
307
+ $content = $this->_addFieldToCsv($content, $delimiter, $productCode);
308
+ $content .= $separator;
309
+ /* real order id */
310
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($order->getRealOrderId()));
311
+ $content .= $separator;
312
+
313
+ /* total weight (in g)*/
314
+ $order_weight = number_format($order->getWeight(), 2, '.', '');
315
+ if($weightUnit == 'kg') {
316
+ $order_weight = $order_weight * 1000;
317
+ }
318
+ $content = $this->_addFieldToCsv($content, $delimiter, $order_weight);
319
+ $content .= $separator;
320
+
321
+ /* Valeur Assur�e field */
322
+ $content = $this->_addFieldToCsv($content, $delimiter, 0);
323
+ $content .= $separator;
324
+ /* Inform the recipient by e-mail field */
325
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue("N"));
326
+ $content .= $separator;
327
+ /* Print Waybill field */
328
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue("O"));
329
+ $content .= $separator;
330
+ /* sub-account field */
331
+ $sub_account = Mage::helper('chronorelais')->getConfigurationSubAccountNumber();
332
+ $content = $this->_addFieldToCsv($content, $delimiter, (strlen($sub_account) == 3 ? $sub_account : ""));
333
+ $content .= $separator;
334
+ /* Nature of item field */
335
+ $content = $this->_addFieldToCsv($content, $delimiter, 2);
336
+ $content .= $separator;
337
+ /* Description of Consignment field */
338
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
339
+ $content .= $separator;
340
+ /* Print pro-forma (customs) field */
341
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue("N"));
342
+ $content .= $separator;
343
+ /* Declared value (customs) field */
344
+ $content = $this->_addFieldToCsv($content, $delimiter, 0);
345
+ $content .= $separator;
346
+ /* Livraison Samedi (Delivery Saturday) field */
347
+ $SaturdayShipping = 0; //default value for the saturday shipping
348
+ $send_day = strtolower(date('l'));
349
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
350
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($orderId)) {
351
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
352
+ } else {
353
+ if ($_deliver_on_saturday == 'Yes') {
354
+ $_deliver_on_saturday = 1;
355
+ } else {
356
+ $_deliver_on_saturday = 0;
357
+ }
358
+ }
359
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
360
+ if ($_deliver_on_saturday && $is_sending_day) {
361
+ $SaturdayShipping = 1;
362
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
363
+ $SaturdayShipping = 2;
364
+ }
365
+ }
366
+ $content = $this->_addFieldToCsv($content, $delimiter, $SaturdayShipping);
367
+ $content .= $lineBreak;
368
+ }
369
+
370
+ /* decode the content, depending on the charset */
371
+ if ($fileCharset == 'ISO-8859-1') {
372
+ $content = utf8_decode($content);
373
+ }
374
+
375
+ /* pick file mime type, depending on the extension */
376
+ if ($fileExtension == '.txt') {
377
+ $fileMimeType = 'text/plain';
378
+ } else if ($fileExtension == '.csv') {
379
+ $fileMimeType = 'application/csv';
380
+ } else if ($fileExtension == '.chr') {
381
+ $fileMimeType = 'application/chr';
382
+ } else {
383
+ // default
384
+ $fileMimeType = 'text/plain';
385
+ }
386
+
387
+ /* download the file */
388
+ return $this->_prepareDownloadResponse($filename, $content, $fileMimeType . '; charset="' . $fileCharset . '"');
389
+ } else {
390
+ $this->_getSession()->addError($this->__('No Order has been selected'));
391
+ }
392
+ }
393
+
394
+ /* Save the Livraison le Samedi status to orders */
395
+
396
+ public function saveLivraisonSamediStatusAction() {
397
+ /* get the orders */
398
+ $orderIds = $this->getRequest()->getPost('order_ids');
399
+ $status = $this->getRequest()->getPost('status');
400
+ $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
401
+ $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
402
+ $exceptions = array();
403
+
404
+ foreach ($orderIds as $orderId) {
405
+ $order_details = Mage::getModel('sales/order')->load($orderId);
406
+ $shipping_method = '';
407
+ $livraison_le_samedi = $status;
408
+ if ($shipping_method = $order_details->getShippingMethod()) {
409
+ $shipping_method = explode('_', $shipping_method);
410
+ if ($shipping_method[0] == 'chronoexpress') {
411
+ $livraison_le_samedi = '--';
412
+ }
413
+ }
414
+ $condition = array(
415
+ $_connection->quoteInto('order_id = ?', $orderId),
416
+ );
417
+ $_connection->delete($_table, $condition);
418
+
419
+ $dataLine = array(
420
+ 'order_id' => $orderId,
421
+ 'livraison_le_samedi' => $livraison_le_samedi
422
+ );
423
+ try {
424
+ $_connection->insert($_table, $dataLine);
425
+ } catch (Exception $e) {
426
+ $exceptions[] = Mage::helper('chronorelais')->__('Order assigning error: ' . $e->getMessage());
427
+ }
428
+ }
429
+ if ($exceptions) {
430
+ $this->_getSession()->addError($exceptions);
431
+ } else {
432
+ $this->_getSession()->addSuccess($this->__('Livraison le Samedi statut a &eacute;t&eacute; ajout&eacute;'));
433
+ }
434
+ $this->_redirect('*/*/index');
435
+ }
436
+
437
+ /**
438
+ * Add a new field to the csv file
439
+ * @param csvContent : the current csv content
440
+ * @param fieldDelimiter : the delimiter character
441
+ * @param fieldContent : the content to add
442
+ * @return : the concatenation of current content and content to add
443
+ */
444
+ private function _addFieldToCsv($csvContent, $fieldDelimiter, $fieldContent) {
445
+ return $csvContent . $fieldDelimiter . $fieldContent . $fieldDelimiter;
446
+ }
447
+
448
  }
app/code/community/Chronopost/Chronorelais/controllers/Sales/ImpressionController.php CHANGED
@@ -1,1033 +1,1050 @@
1
- <?php
2
-
3
- require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
4
-
5
- class Chronopost_Chronorelais_Sales_ImpressionController extends Mage_Adminhtml_Sales_Order_ShipmentController {
6
-
7
- protected $_trackingNumbers = '';
8
-
9
- /**
10
- * Additional initialization
11
- *
12
- */
13
- protected function _construct() {
14
- $this->setUsedModuleName('Chronopost_Chronorelais');
15
- }
16
-
17
- /**
18
- * Shipping grid
19
- */
20
- public function indexAction() {
21
- if (!extension_loaded('soap')) {
22
- $this->_getSession()->addError($this->__('The SOAP extension is not installed in the server. Please contact the site administrator. Sorry for inconvenience.'));
23
- return $this->_redirectReferer();
24
- }
25
- $cmdTestGs = Mage::helper('chronorelais')->getConfigData('chronorelais/shipping/gs_path');
26
- if(shell_exec($cmdTestGs) === null) {
27
- $this->_getSession()->addNotice($this->__('Please install %s on your server to print mass','<a href="http://www.ghostscript.com/download/" target="_blank">Ghostscript</a>'));
28
- }
29
- $this->loadLayout()
30
- ->_setActiveMenu('sales/chronorelais')
31
- ->_addContent($this->getLayout()->createBlock('chronorelais/sales_impression'))
32
- ->renderLayout();
33
- }
34
-
35
- /**
36
- * Save shipment and order in one transaction
37
- * @param Mage_Sales_Model_Order_Shipment $shipment
38
- */
39
- protected function _saveShipment($shipment) {
40
- $shipment->getOrder()->setIsInProcess(true);
41
- $transactionSave = Mage::getModel('core/resource_transaction')
42
- ->addObject($shipment)
43
- ->addObject($shipment->getOrder())
44
- ->save();
45
-
46
- return $this;
47
- }
48
-
49
- /**
50
- * Declare headers and content file in response for file download
51
- *
52
- * @param string $fileName
53
- * @param string|array $content set to null to avoid starting output, $contentLength should be set explicitly in
54
- * that case
55
- * @param string $contentType
56
- * @param int $contentLength explicit content length, if strlen($content) isn't applicable
57
- * @return Mage_Core_Controller_Varien_Action
58
- */
59
- protected function _prepareDownloadResponse(
60
- $fileName,
61
- $content,
62
- $contentType = 'application/octet-stream',
63
- $contentLength = null)
64
- {
65
- $session = Mage::getSingleton('admin/session');
66
- if ($session->isFirstPageAfterLogin()) {
67
- $this->_redirect($session->getUser()->getStartupPageUrl());
68
- return $this;
69
- }
70
-
71
- $isFile = false;
72
- $file = null;
73
- if (is_array($content)) {
74
- if (!isset($content['type']) || !isset($content['value'])) {
75
- return $this;
76
- }
77
- if ($content['type'] == 'filename') {
78
- $isFile = true;
79
- $file = $content['value'];
80
- $contentLength = filesize($file);
81
- }
82
- }
83
-
84
- $this->getResponse()
85
- ->setHttpResponseCode(200)
86
- ->setHeader('Pragma', 'public', true)
87
- ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
88
- ->setHeader('Content-type', $contentType, true)
89
- ->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength, true)
90
- ->setHeader('Content-Disposition', 'attachment; filename="'.$fileName.'"', true)
91
- ->setHeader('Last-Modified', date('r'), true);
92
-
93
- if (!is_null($content)) {
94
- if ($isFile) {
95
- $this->getResponse()->clearBody();
96
- $this->getResponse()->sendHeaders();
97
-
98
- $ioAdapter = new Varien_Io_File();
99
- $ioAdapter->open(array('path' => $ioAdapter->dirname($file)));
100
- $ioAdapter->streamOpen($file, 'r');
101
- while ($buffer = $ioAdapter->streamRead()) {
102
- print $buffer;
103
- }
104
- $ioAdapter->streamClose();
105
- if (!empty($content['rm'])) {
106
- $ioAdapter->rm($file);
107
- }
108
-
109
- exit(0);
110
- } else {
111
- $this->getResponse()->setBody($content);
112
- }
113
- }
114
- return $this;
115
- }
116
-
117
- protected function _processDownloadMass($urls) {
118
-
119
- $helper = Mage::helper('downloadable/download');
120
- $countUrl = count($urls);
121
- $indice = 1;
122
- $filesSize = 0;
123
- $content = '';
124
-
125
- $paths = array();
126
-
127
- foreach ($urls as $url) {
128
- $helper->setResource($url, 'url');
129
- $fileName = $helper->getFilename();
130
- $fileName = explode('reservationNumber=', $fileName);
131
- $fileName = $fileName[1];
132
- $filesSize = $helper->getFilesize();
133
- $contentType = $helper->getContentType();
134
-
135
- /* save pdf file */
136
- $path = Mage::getBaseDir('media').'/chronopost/' . $fileName . '.pdf';
137
- file_put_contents($path, file_get_contents($url));
138
- $paths[] = $path;
139
- }
140
-
141
- /* creation d'un pdf unique */
142
- $pdfMergeFileName = "merged-".date('YmdHis').".pdf";
143
- $pathMerge = Mage::getBaseDir('media')."/chronopost/".$pdfMergeFileName;
144
- $cmd = Mage::helper('chronorelais')->getConfigData('chronorelais/shipping/gs_path').' -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="'.$pathMerge.'" -dBATCH '. implode(' ', $paths);
145
- $res_shell = shell_exec($cmd);
146
-
147
- /* suppression des pdf temp */
148
- foreach ($paths as $path) {
149
- if(is_file($path)) {
150
- unlink($path);
151
- }
152
- }
153
-
154
- if ($res_shell === null) {
155
- return $this->_redirectReferer();
156
- }
157
- else {
158
- $this->_prepareDownloadResponse($pdfMergeFileName,array(
159
- 'type' => 'filename',
160
- 'value' => $pathMerge
161
- ));
162
- unlink($pathMerge);
163
- }
164
- }
165
-
166
- protected function getTrackingNumber($shipmentId) {
167
- $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
168
-
169
- //On récupère le numéro de tracking
170
- $tracks = $shipment->getTracksCollection();
171
- foreach ($tracks as $track) {
172
- if ($track->getParentId() == $shipmentId) {
173
- $this->_trackingNumbers .= $track->getnumber();
174
- }
175
- }
176
-
177
- return $this->_trackingNumbers;
178
- }
179
-
180
- protected function getFilledValue($value) {
181
- if ($value) {
182
- return $this->removeaccents(trim($value));
183
- } else {
184
- return '';
185
- }
186
- }
187
-
188
- protected function checkMobileNumber($value) {
189
- if ($reqvalue = trim($value)) {
190
- $_number = substr($reqvalue, 0, 2);
191
- $fixed_array = array('01', '02', '03', '04', '05', '06', '06');
192
- if (in_array($_number, $fixed_array)) {
193
- return $reqvalue;
194
- } else {
195
- return '';
196
- }
197
- }
198
- }
199
-
200
- protected function getExpeditionParams($shipment, $_shippingMethod) {
201
- $_order = $shipment->getOrder();
202
- $_shippingAddress = $shipment->getShippingAddress();
203
- $_billingAddress = $shipment->getBillingAddress();
204
- $_helper = Mage::helper('chronorelais');
205
-
206
- $shippingMethodAllow = array('chronorelais','chronopost','chronoexpress','chronopostc10','chronopostc18','chronopostcclassic');
207
- if (in_array($_shippingMethod[0],$shippingMethodAllow)) {
208
- $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
209
-
210
- //esdParams parameters
211
- $esdParams = array(
212
- 'height' => '',
213
- 'width' => '',
214
- 'length' => ''
215
- );
216
-
217
- //header parameters
218
- $header = array(
219
- 'idEmit' => 'CHRFR',
220
- 'accountNumber' => $_helper->getConfigurationAccountNumber(),
221
- 'subAccount' => $_helper->getConfigurationSubAccountNumber()
222
- );
223
-
224
- //shipper parameters
225
- $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
226
- $shipper = array(
227
- 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
228
- 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
229
- 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
230
- 'shipperCivility' => $_helper->getConfigurationShipperInfo('civility'),
231
- 'shipperContactName' => $_helper->getConfigurationShipperInfo('contactname'),
232
- 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
233
- 'shipperEmail' => $_helper->getConfigurationShipperInfo('email'),
234
- 'shipperMobilePhone' => $shipperMobilePhone,
235
- 'shipperName' => $_helper->getConfigurationShipperInfo('name'),
236
- 'shipperName2' => $_helper->getConfigurationShipperInfo('name2'),
237
- 'shipperPhone' => $_helper->getConfigurationShipperInfo('phone'),
238
- 'shipperPreAlert' => '',
239
- 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
240
- );
241
-
242
- //customer parameters
243
- $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
244
- $customer = array(
245
- 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
246
- 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
247
- 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
248
- 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
249
- 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
250
- 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
251
- 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
252
- 'customerMobilePhone' => $customerMobilePhone,
253
- 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
254
- 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
255
- 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
256
- 'customerPreAlert' => '',
257
- 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
258
- );
259
-
260
- //recipient parameters
261
- $recipient_address = $_shippingAddress->getStreet();
262
- if (!isset($recipient_address[1])) {
263
- $recipient_address[1] = '';
264
- }
265
- $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
266
- $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
267
- $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
268
- $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
269
- //remove any alphabets in phone number
270
-
271
- //$recipientPhone = trim(ereg_replace("[^0-9.-]", " ", $_shippingAddress->getTelephone()));
272
- $recipientPhone = trim(preg_replace("/[^0-9\.\-]/", " ", $_shippingAddress->getTelephone()));
273
-
274
- $recipient = array(
275
- 'recipientAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
276
- 'recipientAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
277
- 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
278
- 'recipientContactName' => $recipientName2,
279
- 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
280
- 'recipientEmail' => $customer_email,
281
- 'recipientMobilePhone' => $recipientMobilePhone,
282
- 'recipientName' => $recipientName,
283
- 'recipientName2' => $recipientName2,
284
- 'recipientPhone' => $recipientPhone,
285
- 'recipientPreAlert' => '',
286
- 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
287
- );
288
-
289
- //ref parameters
290
- $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
291
- if (!$recipientRef) {
292
- $recipientRef = $_order->getCustomerId();
293
- }
294
- $shipperRef = $_order->getRealOrderId();
295
-
296
- $ref = array(
297
- 'recipientRef' => $recipientRef,
298
- 'shipperRef' => $shipperRef
299
- );
300
-
301
- //skybill parameters
302
- /* Livraison Samedi (Delivery Saturday) field */
303
- $SaturdayShipping = 0; //default value for the saturday shipping
304
- $send_day = strtolower(date('l'));
305
- if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
306
- if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
307
- $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
308
- } else {
309
- if ($_deliver_on_saturday == 'Yes') {
310
- $_deliver_on_saturday = 1;
311
- } else {
312
- $_deliver_on_saturday = 0;
313
- }
314
- }
315
- $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
316
- if ($_deliver_on_saturday && $is_sending_day) {
317
- $SaturdayShipping = 6;
318
- } elseif (!$_deliver_on_saturday && $is_sending_day) {
319
- $SaturdayShipping = 1;
320
- }
321
- }
322
-
323
- $weight = 0;
324
- foreach ($shipment->getItemsCollection() as $item) {
325
- $weight += $item->weight * $item->qty;
326
- }
327
- if ($_helper->getConfigWeightUnit() == 'g') {
328
- $weight = $weight / 1000; /* conversion g => kg */
329
- }
330
- $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
331
-
332
- $skybill = array(
333
- 'codCurrency' => 'EUR',
334
- 'codValue' => '',
335
- 'content1' => '',
336
- 'content2' => '',
337
- 'content3' => '',
338
- 'content4' => '',
339
- 'content5' => '',
340
- 'customsCurrency' => 'EUR',
341
- 'customsValue' => '',
342
- 'evtCode' => 'DC',
343
- 'insuredCurrency' => 'EUR',
344
- 'insuredValue' => '',
345
- 'objectType' => 'MAR',
346
- 'productCode' => $_helper->getChronoProductCodeToShipment($_shippingMethod[0]),
347
- 'service' => $SaturdayShipping,
348
- 'shipDate' => date('c'),
349
- 'shipHour' => date('H'),
350
- 'weight' => $weight,
351
- 'weightUnit' => 'KGM'
352
- );
353
-
354
- $skybillParams = array(
355
- 'mode' => $_helper->getConfigurationSkybillParam()
356
- );
357
-
358
- $expeditionArray = array(
359
- 'esdParams' => $esdParams,
360
- 'header' => $header,
361
- 'shipper' => $shipper,
362
- 'customer' => $customer,
363
- 'recipient' => $recipient,
364
- 'ref' => $ref,
365
- 'skybill' => $skybill,
366
- 'skybillParams' => $skybillParams,
367
- 'password' => $_helper->getConfigurationAccountPass(),
368
- 'option' => '0'
369
- );
370
- //printArray($expeditionArray); exit;
371
- return $expeditionArray;
372
- }
373
- }
374
-
375
- protected function getEtiquetteUrl($shipmentId) {
376
- //On récupère les infos d'expédition
377
- $reservationNumber = '';
378
- $_helper = Mage::helper('chronorelais');
379
-
380
- $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
381
- if ($_shipTracks = $shipment->getAllTracks()) {
382
- foreach ($_shipTracks as $_shipTrack) {
383
- if ($_shipTrack->getNumber() && $_shipTrack->getChronoReservationNumber()) {
384
- $reservationNumber = $_shipTrack->getChronoReservationNumber();
385
- break;
386
- }
387
- }
388
- if ($reservationNumber) {
389
- return $reservationNumber;
390
- }
391
- }
392
-
393
- $_order = $shipment->getOrder();
394
- $_shippingMethod = explode("_", $_order->getShippingMethod());
395
-
396
- $expeditionArray = $this->getExpeditionParams($shipment, $_shippingMethod);
397
- $tracking_number = '';
398
- if ($expeditionArray) {
399
- $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
400
- try {
401
- $webservbt = $client->__call("reservationExpeditionV2", $expeditionArray);
402
- if (!$webservbt->errorCode && $webservbt->reservationNumber) {
403
- $tracking_number = $webservbt->skybillNumber;
404
- // Add tracking number for the shipment if not already exists.
405
- if (!$this->_trackingNumbers && $webservbt->skybillNumber) {
406
- $track = Mage::getModel('sales/order_shipment_track')
407
- ->setNumber($webservbt->skybillNumber)
408
- ->setCarrier(ucwords($_shippingMethod[0]))
409
- ->setCarrierCode($_shippingMethod[0])
410
- ->setTitle(ucwords($_shippingMethod[0]))
411
- ->setChronoReservationNumber($webservbt->reservationNumber)
412
- ->setPopup(1);
413
- $shipment->addTrack($track);
414
-
415
- $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
416
- $tracking_title = $this->__('Track Your Order');
417
- $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
418
-
419
- //$shipment->register();
420
- $comment = '';
421
- $shipment->setEmailSent(true);
422
- $this->_saveShipment($shipment);
423
- $shipment->sendEmail(1, $tracking_order . $comment);
424
- }
425
- return $webservbt->reservationNumber;
426
- } else {
427
- $this->_getSession()->addError($_helper->__($webservbt->errorMessage));
428
- }
429
- } catch (SoapFault $fault) {
430
- $this->_getSession()->addError($_helper->__($fault->faultstring));
431
- }
432
- }
433
- }
434
-
435
- public function getShipmentByOrderId($orderId) {
436
- $_shipment = Mage::getResourceModel('sales/order_shipment_grid_collection')
437
- ->addAttributeToFilter('order_id', $orderId)
438
- ->getAllIds();
439
- return $_shipment;
440
- }
441
-
442
- public function getShipmentByIncrementId($incrementId) {
443
- $_shipment = Mage::getResourceModel('sales/order_shipment_grid_collection')
444
- ->addAttributeToFilter('increment_id', $incrementId)
445
- ->getAllIds();
446
- return $_shipment;
447
- }
448
-
449
- public function initShipment($orderId,$savedQtys = '') {
450
- $order = Mage::getModel('sales/order')->load($orderId);
451
-
452
- /**
453
- * Check order existing
454
- */
455
- if (!$order->getId()) {
456
- $this->_getSession()->addError($this->__('The order no longer exists.'));
457
- return false;
458
- }
459
- /**
460
- * Check shipment is available to create separate from invoice
461
- */
462
- if ($order->getForcedDoShipmentWithInvoice()) {
463
- $this->_getSession()->addError($this->__('Cannot do shipment for the order separately from invoice.'));
464
- return false;
465
- }
466
- /**
467
- * Check shipment create availability
468
- */
469
- /* if (!$order->canShip()) {
470
- $this->_getSession()->addError($this->__('Cannot do shipment for the order.'));
471
- return false;
472
- } */
473
- if(empty($savedQtys))
474
- $savedQtys = $this->_getItemQtys();
475
- $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($savedQtys);
476
- if(Mage::registry('current_shipment')) Mage::unregister ('current_shipment');
477
- Mage::register('current_shipment', $shipment);
478
- return $shipment;
479
- }
480
-
481
- public function createNewShipment($orderId,$savedQtys = '') {
482
- $_helper = Mage::helper('chronorelais');
483
- $reservationNumber = '';
484
- try {
485
- if ($shipment = $this->initShipment($orderId,$savedQtys)) {
486
- $shipment->register();
487
-
488
- $_order = $shipment->getOrder();
489
- $_shippingMethod = explode("_", $_order->getShippingMethod());
490
-
491
- $expeditionArray = $this->getExpeditionParams($shipment, $_shippingMethod);
492
- $tracking_number = '';
493
- if ($expeditionArray) {
494
-
495
- $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
496
- try {
497
- $expedition = $client->__call("reservationExpeditionV2", $expeditionArray);
498
- if (!$expedition->errorCode && $expedition->skybillNumber) {
499
- $tracking_number = $expedition->skybillNumber;
500
- $track = Mage::getModel('sales/order_shipment_track')
501
- ->setNumber($expedition->skybillNumber)
502
- ->setCarrier(ucwords($_shippingMethod[0]))
503
- ->setCarrierCode($_shippingMethod[0])
504
- ->setTitle(ucwords($_shippingMethod[0]))
505
- ->setChronoReservationNumber($expedition->reservationNumber)
506
- ->setPopup(1);
507
- $shipment->addTrack($track);
508
- $reservationNumber = $expedition->reservationNumber;
509
- } else {
510
- $this->_getSession()->addError($_helper->__($expedition->errorMessage));
511
- return;
512
- }
513
- } catch (SoapFault $fault) {
514
- $this->_getSession()->addError($_helper->__($fault->faultstring));
515
- return;
516
- }
517
- }
518
-
519
- $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
520
- $tracking_title = $this->__('Track Your Order');
521
- $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
522
-
523
- $comment = '';
524
- $shipment->setEmailSent(true);
525
- $this->_saveShipment($shipment);
526
- $shipment->sendEmail(1, $tracking_order . $comment);
527
- $this->_getSession()->addSuccess($this->__('Shipment was successfully created.'));
528
- return $reservationNumber;
529
- } else {
530
- $this->_forward('noRoute');
531
- return;
532
- }
533
- } catch (Mage_Core_Exception $e) {
534
- $this->_getSession()->addError($e->getMessage());
535
- return;
536
- } catch (Exception $e) {
537
- $this->_getSession()->addError($this->__('Can not save shipment: ' . $e->getMessage()));
538
- return;
539
- }
540
- }
541
-
542
- public function printMassAction() {
543
- $orderIds = $this->getRequest()->getParam('order_ids');
544
- $trackNumberUrls = array();
545
- $helper = Mage::helper('chronorelais');
546
- foreach ($orderIds as $orderId) {
547
- if ($_shipments = $this->getShipmentByOrderId($orderId)) {
548
- if (count($_shipments) == 1) {
549
- $shipmentId = $_shipments[0];
550
- $trackNumber = $this->getEtiquetteUrl($shipmentId);
551
- if ($trackNumber)
552
- $trackNumberUrls[] = str_replace('{trackingNumber}', $trackNumber, $helper->getConfigurationTrackingUrl());
553
- } else {
554
- foreach ($_shipments as $_shipment) {
555
- $trackNumber = $this->getEtiquetteUrl($_shipment);
556
- if ($trackNumber)
557
- $trackNumberUrls[] = str_replace('{trackingNumber}', $trackNumber, $helper->getConfigurationTrackingUrl());
558
- }
559
- }
560
- } else {
561
-
562
- $order = Mage::getModel('sales/order')->load($orderId);
563
-
564
- /* If shipping method is Chronopost => check if shipping weight isn't over limit */
565
- $chronopostMethods = array('chronopost_chronopost','chronoexpress_chronoexpress','chronorelais_chronorelais','chronopostc10_chronopostC10','chronopostc18_chronopostC18','chronopostcclassic_chronopostCClassic');
566
- $shippingMethod = $order->getShippingMethod();
567
- if(in_array($shippingMethod, $chronopostMethods)) {
568
- $weightShipping = 0;
569
- $shippingMethod = explode("_", $shippingMethod);
570
- $shippingMethod = $shippingMethod[0];
571
- $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
572
- foreach ($order->getItemsCollection() as $item) {
573
- $weightShipping += $item->getWeight()*$item->getQtyOrdered();
574
- }
575
- if($helper->getConfigWeightUnit() == 'g')
576
- {
577
- $weightShipping = $weightShipping / 1000; // conversion g => kg
578
- }
579
- if($weightShipping > $weight_limit) {
580
- /* multi shipping. 1 shipment by product */
581
- $trackingNumber = array();
582
- foreach ($order->getItemsCollection() as $item) {
583
- $qty = $item->getQtyOrdered();
584
- for($i = 1; $i <= $qty; $i++) {
585
- $trackingNumber = $this->createNewShipment($orderId,array($item->getId() => '1'));
586
- if ($trackingNumber)
587
- $trackNumberUrls[] = str_replace('{trackingNumber}', $trackingNumber, $helper->getConfigurationTrackingUrl());
588
- }
589
- }
590
- }
591
- else {
592
- $trackingNumber = $this->createNewShipment($orderId);
593
- if ($trackingNumber)
594
- $trackNumberUrls[] = str_replace('{trackingNumber}', $trackingNumber, $helper->getConfigurationTrackingUrl());
595
- }
596
- }
597
- else {
598
- $trackingNumber = $this->createNewShipment($orderId);
599
- if ($trackingNumber)
600
- $trackNumberUrls[] = str_replace('{trackingNumber}', $trackingNumber, $helper->getConfigurationTrackingUrl());
601
- }
602
- }
603
- }
604
- if (count($trackNumberUrls)) {
605
- $this->_processDownloadMass($trackNumberUrls);
606
- //exit(0);
607
- }
608
- else
609
- return $this->_redirectReferer();
610
- }
611
-
612
- public function printAction() {
613
- // Appel via order_id
614
- $orderId = $this->getRequest()->getParam('order_id');
615
- $helper = Mage::helper('chronorelais');
616
- if ($orderId) {
617
- if ($_shipments = $this->getShipmentByOrderId($orderId)) {
618
- if (count($_shipments) == 1) {
619
- $shipmentId = $_shipments[0];
620
- $trackingNumber = $this->getEtiquetteUrl($shipmentId);
621
- } else {
622
- $track = "Cette commande contient plusieurs expéditions, cliquez sur chaque lien pour obtenir les étiquettes :<br>";
623
- foreach ($_shipments as $_shipment) {
624
- $url = str_replace('{trackingNumber}', $this->getEtiquetteUrl($_shipment), $helper->getConfigurationTrackingUrl());
625
- $track .= '<a target="_blank" href="' . $url . '">' . $url . '</a><br />';
626
- }
627
- echo $track;
628
- return;
629
- }
630
- } else {
631
- $order = Mage::getModel('sales/order')->load($orderId);
632
-
633
- /* If shipping method is Chronopost => check if shipping weight isn't over limit */
634
- $chronopostMethods = array('chronopost_chronopost','chronoexpress_chronoexpress','chronorelais_chronorelais','chronopostc10_chronopostC10','chronopostc18_chronopostC18','chronopostcclassic_chronopostCClassic');
635
- $shippingMethod = $order->getShippingMethod();
636
- if(in_array($shippingMethod, $chronopostMethods)) {
637
- $weightShipping = 0;
638
- $shippingMethod = explode("_", $shippingMethod);
639
- $shippingMethod = $shippingMethod[0];
640
- $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
641
- foreach ($order->getItemsCollection() as $item) {
642
- $weightShipping += $item->getWeight()*$item->getQtyOrdered();
643
- }
644
- if($helper->getConfigWeightUnit() == 'g')
645
- {
646
- $weightShipping = $weightShipping / 1000; // conversion g => kg
647
- }
648
- if($weightShipping > $weight_limit) {
649
- /* multi shipping. 1 shipment by product */
650
- $trackingNumber = array();
651
- foreach ($order->getItemsCollection() as $item) {
652
- $qty = $item->getQtyOrdered();
653
- for($i = 1; $i <= $qty; $i++) {
654
- $trackingNumber[] = $this->createNewShipment($orderId,array($item->getId() => '1'));
655
- }
656
- }
657
- }
658
- else {
659
- $trackingNumber = $this->createNewShipment($orderId);
660
- }
661
- }
662
- else {
663
- $trackingNumber = $this->createNewShipment($orderId);
664
- }
665
- }
666
- } else {
667
- $shipmentId = $this->getRequest()->getParam('shipment_id');
668
- if ($shipmentId) {
669
- $trackingNumber = $this->getEtiquetteUrl($shipmentId);
670
- } else {
671
- $shipmentIncrementId = $this->getRequest()->getParam('shipment_increment_id');
672
- $shipmentId = $this->getShipmentByIncrementId($shipmentIncrementId);
673
- $trackingNumber = $this->getEtiquetteUrl($shipmentId[0]);
674
- }
675
- }
676
-
677
-
678
- if ($trackingNumber) {
679
- try {
680
- if(is_array($trackingNumber)) {
681
- $trackNumberUrls = array();
682
- foreach($trackingNumber as $track) {
683
- $trackNumberUrls[] = str_replace('{trackingNumber}', $track, $helper->getConfigurationTrackingUrl());
684
- }
685
- $this->_processDownloadMass($trackNumberUrls);
686
- //exit(0);
687
- }
688
- else {
689
- $tracking_url = str_replace('{trackingNumber}', $trackingNumber, $helper->getConfigurationTrackingUrl());
690
- $this->_prepareDownloadResponse('Etiquette_chronopost.pdf', file_get_contents($tracking_url));
691
- //$this->_processDownload($tracking_url, 'url');
692
- //exit(0);
693
- }
694
- } catch (Mage_Core_Exception $e) {
695
- $this->_getSession()->addError($helper->__('Désolé, une erreur est survenu lors de la récupération de l\'étiquetes. Merci de contacter Chronopost ou de réessayer plus tard'));
696
- }
697
- }
698
- else
699
- return $this->_redirectReferer();
700
- }
701
-
702
- public function massLivraisonSamediStatusAction() {
703
- if ($this->getRequest()->getPost('status')) {
704
- $this->saveLivraisonSamediStatusAction();
705
- }
706
- }
707
-
708
- /* Save the Livraison le Samedi status to orders */
709
-
710
- public function saveLivraisonSamediStatusAction() {
711
- /* get the orders */
712
- $orderIds = $this->getRequest()->getPost('order_ids');
713
- $status = $this->getRequest()->getPost('status');
714
- $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
715
- $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
716
- $exceptions = array();
717
-
718
- foreach ($orderIds as $orderId) {
719
- $order_details = Mage::getModel('sales/order')->load($orderId);
720
- $shipping_method = '';
721
- $livraison_le_samedi = $status;
722
- if ($shipping_method = $order_details->getShippingMethod()) {
723
- $shipping_method = explode('_', $shipping_method);
724
- if ($shipping_method[0] == 'chronoexpress') {
725
- $livraison_le_samedi = '--';
726
- }
727
- }
728
- $condition = array(
729
- $_connection->quoteInto('order_id = ?', $orderId),
730
- );
731
- $_connection->delete($_table, $condition);
732
-
733
- $dataLine = array(
734
- 'order_id' => $orderId,
735
- 'livraison_le_samedi' => $livraison_le_samedi
736
- );
737
- try {
738
- $_connection->insert($_table, $dataLine);
739
- } catch (Exception $e) {
740
- $exceptions[] = Mage::helper('chronorelais')->__('Order assigning error: ' . $e->getMessage());
741
- }
742
- }
743
- if ($exceptions) {
744
- $this->_getSession()->addError($exceptions);
745
- } else {
746
- $this->_getSession()->addSuccess($this->__('Livraison le Samedi statut a &eacute;t&eacute; ajout&eacute;'));
747
- }
748
- $this->_redirect('*/*/index');
749
- }
750
-
751
- /* Remove accents characters */
752
-
753
- public function removeaccents($string) {
754
- $stringToReturn = str_replace(
755
- array('à', 'á', 'â', 'ã', 'ä', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', '/', '\xa8'), array('a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', ' ', 'e'), $string);
756
- // Remove all remaining other unknown characters
757
- $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
758
- $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
759
- $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
760
- $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
761
- return $stringToReturn;
762
- }
763
-
764
- /*
765
- * *******************************************************************
766
- * ******************** ETIQUETTE DE RETOUR **************************
767
- * *******************************************************************
768
- */
769
-
770
- public function printEtiquetteRetourAction() {
771
- $shipmentIncrementId = $this->getRequest()->getParam('shipment_increment_id');
772
- $shipmentId = $this->getShipmentByIncrementId($shipmentIncrementId);
773
- $shipmentId = $shipmentId[0];
774
- $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
775
- $_order = $shipment->getOrder();
776
- $_shippingAddress = $shipment->getShippingAddress();
777
- $_billingAddress = $shipment->getBillingAddress();
778
- $trackingNumber = $this->getEtiquetteRetourUrl($shipment);
779
-
780
- if ($trackingNumber) {
781
- try {
782
- $tracking_url = str_replace('{trackingNumber}', $trackingNumber, Mage::helper('chronorelais')->getConfigurationTrackingUrl());
783
- $path = $this->savePdf($tracking_url, $shipmentId);
784
-
785
- /*
786
- * TODO adexos : Send mail with pdf to customer
787
- */
788
- $message_email .= 'Bonjour,
789
- <br />Vous allez bientôt effectuer un envoi Chronopost . La personne qui vous a adressé ce mail a déjà préparé la lettre de transport que vous utiliserez. Après impression, apposez la lettre de transport dans une pochette plastique adhésive et collez la sur votre envoi. Attention le code à barres doit être bien apparent.
790
- <br />Cordialement,';
791
-
792
- $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
793
-
794
- $mail = new Zend_Mail('utf-8');
795
- $mail->setBodyHtml($message_email);
796
- $mail->setFrom(Mage::getStoreConfig('contacts/email/recipient_email'));
797
- $mail->setSubject($_order->getStoreName(1) . ' : Etiquette de retour chronopost');
798
- $mail->createAttachment(file_get_contents($path), Zend_Mime::TYPE_OCTETSTREAM, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'etiquette_retour.pdf');
799
-
800
- $mail->addTo($customer_email);
801
- $mail->send();
802
-
803
- $mail->clearRecipients();
804
- $mail->addTo(Mage::getStoreConfig('contacts/email/recipient_email'));
805
- $mail->send();
806
-
807
- $this->_getSession()->addSuccess(Mage::helper('chronorelais')->__('L\'etiquette de retour à bien été envoyée au client.'));
808
- } catch (Mage_Core_Exception $e) {
809
- $this->_getSession()->addError(Mage::helper('chronorelais')->__('Désolé, une erreure est survenu lors de la récupération de l\'étiquetes. Merci de contacter Chronopost ou de réessayer plus tard'));
810
- }
811
- }
812
- return $this->_redirectReferer();
813
- }
814
-
815
- protected function getEtiquetteRetourParams($shipment, $_shippingMethod) {
816
- $_order = $shipment->getOrder();
817
- $_shippingAddress = $shipment->getShippingAddress();
818
- $_billingAddress = $shipment->getBillingAddress();
819
- $_helper = Mage::helper('chronorelais');
820
-
821
- if ($_shippingAddress->getCountryId() != 'FR') {
822
- $this->_getSession()->addError($_helper->__('Les retours sont disponibles uniquement pour la France'));
823
- return;
824
- }
825
- $shippingMethodAllow = array('chronorelais','chronopost','chronopostc10','chronopostc18');
826
- if (!in_array($_shippingMethod[0], $shippingMethodAllow)) {
827
- $this->_getSession()->addError($_helper->__('Les retours ne sont pas disponibles pour le mode de livraison ' . $_shippingMethod[0]));
828
- return;
829
- }
830
-
831
- if (in_array($_shippingMethod[0], $shippingMethodAllow)) {
832
- $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
833
-
834
- //esdParams parameters
835
- $esdParams = array(
836
- 'height' => '',
837
- 'width' => '',
838
- 'length' => ''
839
- );
840
-
841
- //header parameters
842
- $header = array(
843
- 'idEmit' => 'CHRFR',
844
- 'accountNumber' => $_helper->getConfigurationAccountNumber(),
845
- 'subAccount' => $_helper->getConfigurationSubAccountNumber()
846
- );
847
-
848
- //shipper parameters
849
- $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
850
- $recipient = array(
851
- 'recipientAdress1' => $_helper->getConfigurationShipperInfo('address1'),
852
- 'recipientAdress2' => $_helper->getConfigurationShipperInfo('address2'),
853
- 'recipientCity' => $_helper->getConfigurationShipperInfo('city'),
854
- 'recipientCivility' => $_helper->getConfigurationShipperInfo('civility'),
855
- 'recipientContactName' => $_helper->getConfigurationShipperInfo('contactname'),
856
- 'recipientCountry' => $_helper->getConfigurationShipperInfo('country'),
857
- 'recipientEmail' => $_helper->getConfigurationShipperInfo('email'),
858
- 'recipientMobilePhone' => $shipperMobilePhone,
859
- 'recipientName' => $_helper->getConfigurationShipperInfo('name'),
860
- 'recipientName2' => $_helper->getConfigurationShipperInfo('name2'),
861
- 'recipientPhone' => $_helper->getConfigurationShipperInfo('phone'),
862
- 'recipientPreAlert' => '',
863
- 'recipientZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
864
- );
865
-
866
- //customer parameters
867
- $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
868
- $customer = array(
869
- 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
870
- 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
871
- 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
872
- 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
873
- 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
874
- 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
875
- 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
876
- 'customerMobilePhone' => $customerMobilePhone,
877
- 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
878
- 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
879
- 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
880
- 'customerPreAlert' => '',
881
- 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
882
- );
883
-
884
- //recipient parameters
885
- $recipient_address = $_shippingAddress->getStreet();
886
- if (!isset($recipient_address[1])) {
887
- $recipient_address[1] = '';
888
- }
889
- $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
890
- $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
891
- $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
892
- $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
893
- //remove any alphabets in phone number
894
-
895
- //$recipientPhone = trim(ereg_replace("[^0-9.-]", " ", $_shippingAddress->getTelephone()));
896
- $recipientPhone = trim(preg_replace("/[^0-9\.\-]/", " ", $_shippingAddress->getTelephone()));
897
-
898
-
899
- $shipper = array(
900
- 'shipperAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
901
- 'shipperAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
902
- 'shipperCity' => $this->getFilledValue($_shippingAddress->getCity()),
903
- 'shipperCivility' => 'M',
904
- 'shipperContactName' => $recipientName2,
905
- 'shipperCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
906
- 'shipperEmail' => $customer_email,
907
- 'shipperMobilePhone' => $recipientMobilePhone,
908
- 'shipperName' => $recipientName,
909
- 'shipperName2' => $recipientName2,
910
- 'shipperPhone' => $recipientPhone,
911
- 'shipperPreAlert' => '',
912
- 'shipperZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
913
- );
914
-
915
- //ref parameters
916
- $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
917
- if (!$recipientRef) {
918
- $recipientRef = $_order->getCustomerId();
919
- }
920
- $shipperRef = $_order->getRealOrderId();
921
-
922
- $ref = array(
923
- 'recipientRef' => $recipientRef,
924
- 'shipperRef' => $shipperRef
925
- );
926
-
927
- //skybill parameters
928
- /* Livraison Samedi (Delivery Saturday) field */
929
- $SaturdayShipping = 0; //default value for the saturday shipping
930
- $send_day = strtolower(date('l'));
931
- if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
932
- if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
933
- $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
934
- } else {
935
- if ($_deliver_on_saturday == 'Yes') {
936
- $_deliver_on_saturday = 1;
937
- } else {
938
- $_deliver_on_saturday = 0;
939
- }
940
- }
941
- $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
942
- if ($_deliver_on_saturday && $is_sending_day) {
943
- $SaturdayShipping = 6;
944
- } elseif (!$_deliver_on_saturday && $is_sending_day) {
945
- $SaturdayShipping = 1;
946
- }
947
- }
948
-
949
- $weight = 0;
950
- foreach ($shipment->getItemsCollection() as $item) {
951
- $weight += $item->weight * $item->qty;
952
- }
953
- if ($_helper->getConfigWeightUnit() == 'g') {
954
- $weight = $weight / 1000; /* conversion g => kg */
955
- }
956
- $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
957
-
958
- $skybill = array(
959
- 'codCurrency' => 'EUR',
960
- 'codValue' => '',
961
- 'content1' => '',
962
- 'content2' => '',
963
- 'content3' => '',
964
- 'content4' => '',
965
- 'content5' => '',
966
- 'customsCurrency' => 'EUR',
967
- 'customsValue' => '',
968
- 'evtCode' => 'DC',
969
- 'insuredCurrency' => 'EUR',
970
- 'insuredValue' => '',
971
- 'objectType' => 'MAR',
972
- 'productCode' => $_helper::CHRONO_POST,
973
- 'service' => $SaturdayShipping,
974
- 'shipDate' => date('c'),
975
- 'shipHour' => date('H'),
976
- 'weight' => $weight,
977
- 'weightUnit' => 'KGM'
978
- );
979
-
980
- $skybillParams = array(
981
- 'mode' => $_helper->getConfigurationSkybillParam()
982
- );
983
-
984
- $expeditionArray = array(
985
- 'esdParams' => $esdParams,
986
- 'header' => $header,
987
- 'shipper' => $shipper,
988
- 'customer' => $customer,
989
- 'recipient' => $recipient,
990
- 'ref' => $ref,
991
- 'skybill' => $skybill,
992
- 'skybillParams' => $skybillParams,
993
- 'password' => $_helper->getConfigurationAccountPass(),
994
- 'option' => '0'
995
- );
996
- //printArray($expeditionArray); exit;
997
- return $expeditionArray;
998
- }
999
- }
1000
-
1001
- protected function getEtiquetteRetourUrl($shipment) {
1002
- //On récupère les infos d'expédition
1003
- $reservationNumber = '';
1004
- $_helper = Mage::helper('chronorelais');
1005
-
1006
- $_order = $shipment->getOrder();
1007
- $_shippingMethod = explode("_", $_order->getShippingMethod());
1008
-
1009
- $expeditionArray = $this->getEtiquetteRetourParams($shipment, $_shippingMethod);
1010
- $tracking_number = '';
1011
- if ($expeditionArray) {
1012
- $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
1013
- try {
1014
- $webservbt = $client->__call("reservationExpeditionV2", $expeditionArray);
1015
- if (!$webservbt->errorCode && $webservbt->reservationNumber) {
1016
- $tracking_number = $webservbt->skybillNumber;
1017
- return $webservbt->reservationNumber;
1018
- } else {
1019
- $this->_getSession()->addError($_helper->__($webservbt->errorMessage));
1020
- }
1021
- } catch (SoapFault $fault) {
1022
- $this->_getSession()->addError($_helper->__($fault->faultstring));
1023
- }
1024
- }
1025
- }
1026
-
1027
- protected function savePdf($url, $shipmentId) {
1028
- $path = 'media/chronopost/etiquetteRetour-' . $shipmentId . '.pdf';
1029
- file_put_contents($path, file_get_contents($url));
1030
- return $path;
1031
- }
1032
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1033
  }
1
+ <?php
2
+
3
+ require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
4
+
5
+ class Chronopost_Chronorelais_Sales_ImpressionController extends Mage_Adminhtml_Sales_Order_ShipmentController {
6
+
7
+ protected $_trackingNumbers = '';
8
+
9
+ /**
10
+ * Additional initialization
11
+ *
12
+ */
13
+ protected function _construct() {
14
+ $this->setUsedModuleName('Chronopost_Chronorelais');
15
+ }
16
+
17
+ /**
18
+ * Shipping grid
19
+ */
20
+ public function indexAction() {
21
+ if (!extension_loaded('soap')) {
22
+ $this->_getSession()->addError($this->__('The SOAP extension is not installed in the server. Please contact the site administrator. Sorry for inconvenience.'));
23
+ return $this->_redirectReferer();
24
+ }
25
+ $cmdTestGs = Mage::helper('chronorelais')->getConfigData('chronorelais/shipping/gs_path')." -v";
26
+ if(shell_exec($cmdTestGs) === null) {
27
+ $this->_getSession()->addNotice($this->__('Please install %s on your server to print mass','<a href="http://www.ghostscript.com/download/" target="_blank">Ghostscript</a>'));
28
+ }
29
+ $this->loadLayout()
30
+ ->_setActiveMenu('sales/chronorelais')
31
+ ->_addContent($this->getLayout()->createBlock('chronorelais/sales_impression'))
32
+ ->renderLayout();
33
+ }
34
+
35
+ /**
36
+ * Save shipment and order in one transaction
37
+ * @param Mage_Sales_Model_Order_Shipment $shipment
38
+ */
39
+ protected function _saveShipment($shipment) {
40
+ $shipment->getOrder()->setIsInProcess(true);
41
+ $transactionSave = Mage::getModel('core/resource_transaction')
42
+ ->addObject($shipment)
43
+ ->addObject($shipment->getOrder())
44
+ ->save();
45
+
46
+ return $this;
47
+ }
48
+
49
+ /**
50
+ * Declare headers and content file in response for file download
51
+ *
52
+ * @param string $fileName
53
+ * @param string|array $content set to null to avoid starting output, $contentLength should be set explicitly in
54
+ * that case
55
+ * @param string $contentType
56
+ * @param int $contentLength explicit content length, if strlen($content) isn't applicable
57
+ * @return Mage_Core_Controller_Varien_Action
58
+ */
59
+ protected function _prepareDownloadResponse(
60
+ $fileName,
61
+ $content,
62
+ $contentType = 'application/octet-stream',
63
+ $contentLength = null)
64
+ {
65
+ $session = Mage::getSingleton('admin/session');
66
+ if ($session->isFirstPageAfterLogin()) {
67
+ $this->_redirect($session->getUser()->getStartupPageUrl());
68
+ return $this;
69
+ }
70
+
71
+ $isFile = false;
72
+ $file = null;
73
+ if (is_array($content)) {
74
+ if (!isset($content['type']) || !isset($content['value'])) {
75
+ return $this;
76
+ }
77
+ if ($content['type'] == 'filename') {
78
+ $isFile = true;
79
+ $file = $content['value'];
80
+ $contentLength = filesize($file);
81
+ }
82
+ }
83
+
84
+ $this->getResponse()
85
+ ->setHttpResponseCode(200)
86
+ ->setHeader('Pragma', 'public', true)
87
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
88
+ ->setHeader('Content-type', $contentType, true)
89
+ ->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength, true)
90
+ ->setHeader('Content-Disposition', 'attachment; filename="'.$fileName.'"', true)
91
+ ->setHeader('Last-Modified', date('r'), true);
92
+
93
+ if (!is_null($content)) {
94
+ if ($isFile) {
95
+ $this->getResponse()->clearBody();
96
+ $this->getResponse()->sendHeaders();
97
+
98
+ $ioAdapter = new Varien_Io_File();
99
+ $ioAdapter->open(array('path' => $ioAdapter->dirname($file)));
100
+ $ioAdapter->streamOpen($file, 'r');
101
+ while ($buffer = $ioAdapter->streamRead()) {
102
+ print $buffer;
103
+ }
104
+ $ioAdapter->streamClose();
105
+ if (!empty($content['rm'])) {
106
+ $ioAdapter->rm($file);
107
+ }
108
+
109
+ exit(0);
110
+ } else {
111
+ $this->getResponse()->setBody($content);
112
+ }
113
+ }
114
+ return $this;
115
+ }
116
+
117
+ protected function _processDownloadMass($urls) {
118
+
119
+ $helper = Mage::helper('downloadable/download');
120
+ $countUrl = count($urls);
121
+ $indice = 1;
122
+ $filesSize = 0;
123
+ $content = '';
124
+
125
+ $paths = array();
126
+ $this->createMediaChronopostFolder();
127
+ foreach ($urls as $url) {
128
+ $helper->setResource($url, 'url');
129
+ $fileName = $helper->getFilename();
130
+ $fileName = explode('reservationNumber=', $fileName);
131
+ $fileName = $fileName[1];
132
+ $filesSize = $helper->getFilesize();
133
+ $contentType = $helper->getContentType();
134
+
135
+ /* save pdf file */
136
+ $path = Mage::getBaseDir('media').'/chronopost/' . $fileName . '.pdf';
137
+ file_put_contents($path, file_get_contents($url));
138
+ $paths[] = $path;
139
+ }
140
+
141
+ /* creation d'un pdf unique */
142
+ $pdfMergeFileName = "merged-".date('YmdHis').".pdf";
143
+ $pathMerge = Mage::getBaseDir('media')."/chronopost/".$pdfMergeFileName;
144
+ $cmd = Mage::helper('chronorelais')->getConfigData('chronorelais/shipping/gs_path').' -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="'.$pathMerge.'" -dBATCH '. implode(' ', $paths);
145
+ $res_shell = shell_exec($cmd);
146
+
147
+ /* suppression des pdf temp */
148
+ foreach ($paths as $path) {
149
+ if(is_file($path)) {
150
+ unlink($path);
151
+ }
152
+ }
153
+
154
+ if ($res_shell === null) {
155
+ return $this->_redirectReferer();
156
+ }
157
+ else {
158
+ $this->_prepareDownloadResponse($pdfMergeFileName,array(
159
+ 'type' => 'filename',
160
+ 'value' => $pathMerge
161
+ ));
162
+ unlink($pathMerge);
163
+ }
164
+ }
165
+
166
+ protected function getTrackingNumber($shipmentId) {
167
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
168
+
169
+ //On récupère le numéro de tracking
170
+ $tracks = $shipment->getTracksCollection();
171
+ foreach ($tracks as $track) {
172
+ if ($track->getParentId() == $shipmentId) {
173
+ $this->_trackingNumbers .= $track->getnumber();
174
+ }
175
+ }
176
+
177
+ return $this->_trackingNumbers;
178
+ }
179
+
180
+ protected function getFilledValue($value) {
181
+ if ($value) {
182
+ return $this->removeaccents(trim($value));
183
+ } else {
184
+ return '';
185
+ }
186
+ }
187
+
188
+ protected function checkMobileNumber($value) {
189
+ if ($reqvalue = trim($value)) {
190
+ $_number = substr($reqvalue, 0, 2);
191
+ $fixed_array = array('01', '02', '03', '04', '05', '06', '06');
192
+ if (in_array($_number, $fixed_array)) {
193
+ return $reqvalue;
194
+ } else {
195
+ return '';
196
+ }
197
+ }
198
+ }
199
+
200
+ protected function getExpeditionParams($shipment, $_shippingMethod) {
201
+ $_order = $shipment->getOrder();
202
+ $_shippingAddress = $shipment->getShippingAddress();
203
+ $_billingAddress = $shipment->getBillingAddress();
204
+ $_helper = Mage::helper('chronorelais');
205
+
206
+ $shippingMethodAllow = array('chronorelais','chronopost','chronoexpress','chronopostc10','chronopostc18','chronopostcclassic');
207
+ if (in_array($_shippingMethod[0],$shippingMethodAllow)) {
208
+ $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
209
+
210
+ //esdParams parameters
211
+ $esdParams = array(
212
+ 'height' => '',
213
+ 'width' => '',
214
+ 'length' => ''
215
+ );
216
+
217
+ //header parameters
218
+ $header = array(
219
+ 'idEmit' => 'MAG',
220
+ 'accountNumber' => $_helper->getConfigurationAccountNumber(),
221
+ 'subAccount' => $_helper->getConfigurationSubAccountNumber()
222
+ );
223
+
224
+ //shipper parameters
225
+ $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
226
+ $shipper = array(
227
+ 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
228
+ 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
229
+ 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
230
+ 'shipperCivility' => $_helper->getConfigurationShipperInfo('civility'),
231
+ 'shipperContactName' => $_helper->getConfigurationShipperInfo('contactname'),
232
+ 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
233
+ 'shipperEmail' => $_helper->getConfigurationShipperInfo('email'),
234
+ 'shipperMobilePhone' => $shipperMobilePhone,
235
+ 'shipperName' => $_helper->getConfigurationShipperInfo('name'),
236
+ 'shipperName2' => $_helper->getConfigurationShipperInfo('name2'),
237
+ 'shipperPhone' => $_helper->getConfigurationShipperInfo('phone'),
238
+ 'shipperPreAlert' => '',
239
+ 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
240
+ );
241
+
242
+ //customer parameters
243
+ $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
244
+ $customer = array(
245
+ 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
246
+ 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
247
+ 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
248
+ 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
249
+ 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
250
+ 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
251
+ 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
252
+ 'customerMobilePhone' => $customerMobilePhone,
253
+ 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
254
+ 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
255
+ 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
256
+ 'customerPreAlert' => '',
257
+ 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
258
+ );
259
+
260
+ //recipient parameters
261
+ $recipient_address = $_shippingAddress->getStreet();
262
+ if (!isset($recipient_address[1])) {
263
+ $recipient_address[1] = '';
264
+ }
265
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
266
+ $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
267
+ $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
268
+ $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
269
+ //remove any alphabets in phone number
270
+
271
+ //$recipientPhone = trim(ereg_replace("[^0-9.-]", " ", $_shippingAddress->getTelephone()));
272
+ $recipientPhone = trim(preg_replace("/[^0-9\.\-]/", " ", $_shippingAddress->getTelephone()));
273
+
274
+ $recipient = array(
275
+ 'recipientAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
276
+ 'recipientAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
277
+ 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
278
+ 'recipientContactName' => $recipientName2,
279
+ 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
280
+ 'recipientEmail' => $customer_email,
281
+ 'recipientMobilePhone' => $recipientMobilePhone,
282
+ 'recipientName' => $recipientName,
283
+ 'recipientName2' => $recipientName2,
284
+ 'recipientPhone' => $recipientPhone,
285
+ 'recipientPreAlert' => '',
286
+ 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
287
+ );
288
+
289
+ //ref parameters
290
+ $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
291
+ if (!$recipientRef) {
292
+ $recipientRef = $_order->getCustomerId();
293
+ }
294
+ $shipperRef = $_order->getRealOrderId();
295
+
296
+ $ref = array(
297
+ 'recipientRef' => $recipientRef,
298
+ 'shipperRef' => $shipperRef
299
+ );
300
+
301
+ //skybill parameters
302
+ /* Livraison Samedi (Delivery Saturday) field */
303
+ $SaturdayShipping = 0; //default value for the saturday shipping
304
+ $send_day = strtolower(date('l'));
305
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
306
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
307
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
308
+ } else {
309
+ if ($_deliver_on_saturday == 'Yes') {
310
+ $_deliver_on_saturday = 1;
311
+ } else {
312
+ $_deliver_on_saturday = 0;
313
+ }
314
+ }
315
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
316
+ if ($_deliver_on_saturday && $is_sending_day) {
317
+ $SaturdayShipping = 6;
318
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
319
+ $SaturdayShipping = 1;
320
+ }
321
+ }
322
+
323
+ $weight = 0;
324
+ foreach ($shipment->getItemsCollection() as $item) {
325
+ $weight += $item->weight * $item->qty;
326
+ }
327
+ if ($_helper->getConfigWeightUnit() == 'g') {
328
+ $weight = $weight / 1000; /* conversion g => kg */
329
+ }
330
+ $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
331
+
332
+ $skybill = array(
333
+ 'codCurrency' => 'EUR',
334
+ 'codValue' => '',
335
+ 'content1' => '',
336
+ 'content2' => '',
337
+ 'content3' => '',
338
+ 'content4' => '',
339
+ 'content5' => '',
340
+ 'customsCurrency' => 'EUR',
341
+ 'customsValue' => '',
342
+ 'evtCode' => 'DC',
343
+ 'insuredCurrency' => 'EUR',
344
+ 'insuredValue' => '',
345
+ 'objectType' => 'MAR',
346
+ 'productCode' => $_helper->getChronoProductCodeToShipment($_shippingMethod[0]),
347
+ 'service' => $SaturdayShipping,
348
+ 'shipDate' => date('c'),
349
+ 'shipHour' => date('H'),
350
+ 'weight' => $weight,
351
+ 'weightUnit' => 'KGM'
352
+ );
353
+
354
+ $skybillParams = array(
355
+ 'mode' => $_helper->getConfigurationSkybillParam()
356
+ );
357
+
358
+ $expeditionArray = array(
359
+ 'esdParams' => $esdParams,
360
+ 'header' => $header,
361
+ 'shipper' => $shipper,
362
+ 'customer' => $customer,
363
+ 'recipient' => $recipient,
364
+ 'ref' => $ref,
365
+ 'skybill' => $skybill,
366
+ 'skybillParams' => $skybillParams,
367
+ 'password' => $_helper->getConfigurationAccountPass(),
368
+ 'option' => '0'
369
+ );
370
+ //printArray($expeditionArray); exit;
371
+ return $expeditionArray;
372
+ }
373
+ }
374
+
375
+ protected function getEtiquetteUrl($shipmentId) {
376
+ //On récupère les infos d'expédition
377
+ $reservationNumber = '';
378
+ $_helper = Mage::helper('chronorelais');
379
+
380
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
381
+ if ($_shipTracks = $shipment->getAllTracks()) {
382
+ foreach ($_shipTracks as $_shipTrack) {
383
+ if ($_shipTrack->getNumber() && $_shipTrack->getChronoReservationNumber()) {
384
+ $reservationNumber = $_shipTrack->getChronoReservationNumber();
385
+ break;
386
+ }
387
+ }
388
+ if ($reservationNumber) {
389
+ return $reservationNumber;
390
+ }
391
+ }
392
+
393
+ $_order = $shipment->getOrder();
394
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
395
+
396
+ $expeditionArray = $this->getExpeditionParams($shipment, $_shippingMethod);
397
+ $tracking_number = '';
398
+ if ($expeditionArray) {
399
+ $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
400
+ try {
401
+ $webservbt = $client->__call("reservationExpeditionV2", $expeditionArray);
402
+ if (!$webservbt->errorCode && $webservbt->reservationNumber) {
403
+ $tracking_number = $webservbt->skybillNumber;
404
+ // Add tracking number for the shipment if not already exists.
405
+ if (!$this->_trackingNumbers && $webservbt->skybillNumber) {
406
+ $track = Mage::getModel('sales/order_shipment_track')
407
+ ->setNumber($webservbt->skybillNumber)
408
+ ->setCarrier(ucwords($_shippingMethod[0]))
409
+ ->setCarrierCode($_shippingMethod[0])
410
+ ->setTitle(ucwords($_shippingMethod[0]))
411
+ ->setChronoReservationNumber($webservbt->reservationNumber)
412
+ ->setPopup(1);
413
+ $shipment->addTrack($track);
414
+
415
+ $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
416
+ $tracking_title = $this->__('Track Your Order');
417
+ $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
418
+
419
+ //$shipment->register();
420
+ $comment = '';
421
+ $shipment->setEmailSent(true);
422
+ $this->_saveShipment($shipment);
423
+ $shipment->sendEmail(1, $tracking_order . $comment);
424
+ }
425
+ return $webservbt->reservationNumber;
426
+ } else {
427
+ $this->_getSession()->addError($_helper->__($webservbt->errorMessage));
428
+ }
429
+ } catch (SoapFault $fault) {
430
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
431
+ }
432
+ }
433
+ }
434
+
435
+ public function getShipmentByOrderId($orderId) {
436
+ $_shipment = Mage::getResourceModel('sales/order_shipment_grid_collection')
437
+ ->addAttributeToFilter('order_id', $orderId)
438
+ ->getAllIds();
439
+ return $_shipment;
440
+ }
441
+
442
+ public function getShipmentByIncrementId($incrementId) {
443
+ $_shipment = Mage::getResourceModel('sales/order_shipment_grid_collection')
444
+ ->addAttributeToFilter('increment_id', $incrementId)
445
+ ->getAllIds();
446
+ return $_shipment;
447
+ }
448
+
449
+ public function initShipment($orderId,$savedQtys = '') {
450
+ $order = Mage::getModel('sales/order')->load($orderId);
451
+
452
+ /**
453
+ * Check order existing
454
+ */
455
+ if (!$order->getId()) {
456
+ $this->_getSession()->addError($this->__('The order no longer exists.'));
457
+ return false;
458
+ }
459
+ /**
460
+ * Check shipment is available to create separate from invoice
461
+ */
462
+ if ($order->getForcedDoShipmentWithInvoice()) {
463
+ $this->_getSession()->addError($this->__('Cannot do shipment for the order separately from invoice.'));
464
+ return false;
465
+ }
466
+ /**
467
+ * Check shipment create availability
468
+ */
469
+ /* if (!$order->canShip()) {
470
+ $this->_getSession()->addError($this->__('Cannot do shipment for the order.'));
471
+ return false;
472
+ } */
473
+ if(empty($savedQtys))
474
+ $savedQtys = $this->_getItemQtys();
475
+ $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($savedQtys);
476
+ if(Mage::registry('current_shipment')) Mage::unregister ('current_shipment');
477
+ Mage::register('current_shipment', $shipment);
478
+ return $shipment;
479
+ }
480
+
481
+ public function createNewShipment($orderId,$savedQtys = '') {
482
+ $_helper = Mage::helper('chronorelais');
483
+ $reservationNumber = '';
484
+ try {
485
+ if ($shipment = $this->initShipment($orderId,$savedQtys)) {
486
+ $shipment->register();
487
+
488
+ $_order = $shipment->getOrder();
489
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
490
+
491
+ $expeditionArray = $this->getExpeditionParams($shipment, $_shippingMethod);
492
+ $tracking_number = '';
493
+ if ($expeditionArray) {
494
+
495
+ $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
496
+ try {
497
+ $expedition = $client->__call("reservationExpeditionV2", $expeditionArray);
498
+ if (!$expedition->errorCode && $expedition->skybillNumber) {
499
+ $tracking_number = $expedition->skybillNumber;
500
+ $track = Mage::getModel('sales/order_shipment_track')
501
+ ->setNumber($expedition->skybillNumber)
502
+ ->setCarrier(ucwords($_shippingMethod[0]))
503
+ ->setCarrierCode($_shippingMethod[0])
504
+ ->setTitle(ucwords($_shippingMethod[0]))
505
+ ->setChronoReservationNumber($expedition->reservationNumber)
506
+ ->setPopup(1);
507
+ $shipment->addTrack($track);
508
+ $reservationNumber = $expedition->reservationNumber;
509
+ } else {
510
+ $this->_getSession()->addError($_helper->__($expedition->errorMessage));
511
+ return;
512
+ }
513
+ } catch (SoapFault $fault) {
514
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
515
+ return;
516
+ }
517
+ }
518
+
519
+ $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
520
+ $tracking_title = $this->__('Track Your Order');
521
+ $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
522
+
523
+ $comment = '';
524
+ $shipment->setEmailSent(true);
525
+ $this->_saveShipment($shipment);
526
+ $shipment->sendEmail(1, $tracking_order . $comment);
527
+ $this->_getSession()->addSuccess($this->__('Shipment was successfully created.'));
528
+ return $reservationNumber;
529
+ } else {
530
+ $this->_forward('noRoute');
531
+ return;
532
+ }
533
+ } catch (Mage_Core_Exception $e) {
534
+ $this->_getSession()->addError($e->getMessage());
535
+ return;
536
+ } catch (Exception $e) {
537
+ $this->_getSession()->addError($this->__('Can not save shipment: ' . $e->getMessage()));
538
+ return;
539
+ }
540
+ }
541
+
542
+ public function printMassAction() {
543
+ $orderIds = $this->getRequest()->getParam('order_ids');
544
+ $trackNumberUrls = array();
545
+ $helper = Mage::helper('chronorelais');
546
+ foreach ($orderIds as $orderId) {
547
+ if ($_shipments = $this->getShipmentByOrderId($orderId)) {
548
+ if (count($_shipments) == 1) {
549
+ $shipmentId = $_shipments[0];
550
+ $trackNumber = $this->getEtiquetteUrl($shipmentId);
551
+ if ($trackNumber)
552
+ $trackNumberUrls[] = str_replace('{trackingNumber}', $trackNumber, $helper->getConfigurationTrackingUrl());
553
+ } else {
554
+ foreach ($_shipments as $_shipment) {
555
+ $trackNumber = $this->getEtiquetteUrl($_shipment);
556
+ if ($trackNumber)
557
+ $trackNumberUrls[] = str_replace('{trackingNumber}', $trackNumber, $helper->getConfigurationTrackingUrl());
558
+ }
559
+ }
560
+ } else {
561
+
562
+ $order = Mage::getModel('sales/order')->load($orderId);
563
+
564
+ /* If shipping method is Chronopost => check if shipping weight isn't over limit */
565
+ $chronopostMethods = array('chronopost','chronoexpress','chronorelais','chronopostc10','chronopostc18','chronopostcclassic');
566
+ $shippingMethod = $order->getShippingMethod();
567
+ $shippingMethod = explode("_", $shippingMethod);
568
+ $shippingMethod = $shippingMethod[0];
569
+ if(in_array($shippingMethod, $chronopostMethods)) {
570
+ $weightShipping = 0;
571
+ $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
572
+ foreach ($order->getItemsCollection() as $item) {
573
+ $weightShipping += $item->getWeight()*$item->getQtyOrdered();
574
+ }
575
+ if($helper->getConfigWeightUnit() == 'g')
576
+ {
577
+ $weightShipping = $weightShipping / 1000; // conversion g => kg
578
+ }
579
+ if($weightShipping > $weight_limit) {
580
+ /* multi shipping. 1 shipment by product */
581
+ $trackingNumber = array();
582
+ foreach ($order->getItemsCollection() as $item) {
583
+ $qty = $item->getQtyOrdered();
584
+ for($i = 1; $i <= $qty; $i++) {
585
+ $trackingNumber = $this->createNewShipment($orderId,array($item->getId() => '1'));
586
+ if ($trackingNumber)
587
+ $trackNumberUrls[] = str_replace('{trackingNumber}', $trackingNumber, $helper->getConfigurationTrackingUrl());
588
+ }
589
+ }
590
+ }
591
+ else {
592
+ $trackingNumber = $this->createNewShipment($orderId);
593
+ if ($trackingNumber)
594
+ $trackNumberUrls[] = str_replace('{trackingNumber}', $trackingNumber, $helper->getConfigurationTrackingUrl());
595
+ }
596
+ }
597
+ else {
598
+ $trackingNumber = $this->createNewShipment($orderId);
599
+ if ($trackingNumber)
600
+ $trackNumberUrls[] = str_replace('{trackingNumber}', $trackingNumber, $helper->getConfigurationTrackingUrl());
601
+ }
602
+ }
603
+ }
604
+ if (count($trackNumberUrls)) {
605
+ $this->_processDownloadMass($trackNumberUrls);
606
+ //exit(0);
607
+ }
608
+ else
609
+ return $this->_redirectReferer();
610
+ }
611
+
612
+ public function printAction() {
613
+ // Appel via order_id
614
+ $orderId = $this->getRequest()->getParam('order_id');
615
+ $helper = Mage::helper('chronorelais');
616
+ if ($orderId) {
617
+ if ($_shipments = $this->getShipmentByOrderId($orderId)) {
618
+ if (count($_shipments) == 1) {
619
+ $shipmentId = $_shipments[0];
620
+ $trackingNumber = $this->getEtiquetteUrl($shipmentId);
621
+ } else {
622
+ $track = "Cette commande contient plusieurs expéditions, cliquez sur chaque lien pour obtenir les étiquettes :<br>";
623
+ foreach ($_shipments as $_shipment) {
624
+ $url = str_replace('{trackingNumber}', $this->getEtiquetteUrl($_shipment), $helper->getConfigurationTrackingUrl());
625
+ $track .= '<a target="_blank" href="' . $url . '">' . $url . '</a><br />';
626
+ }
627
+ echo $track;
628
+ return;
629
+ }
630
+ } else {
631
+ $order = Mage::getModel('sales/order')->load($orderId);
632
+
633
+ /* If shipping method is Chronopost => check if shipping weight isn't over limit */
634
+ $chronopostMethods = array('chronopost','chronoexpress','chronorelais','chronopostc10','chronopostc18','chronopostcclassic');
635
+ $shippingMethod = $order->getShippingMethod();
636
+ $shippingMethod = explode("_", $shippingMethod);
637
+ $shippingMethod = $shippingMethod[0];
638
+ if(in_array($shippingMethod, $chronopostMethods)) {
639
+ $weightShipping = 0;
640
+ $shippingMethod = explode("_", $shippingMethod);
641
+ $shippingMethod = $shippingMethod[0];
642
+ $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
643
+ foreach ($order->getItemsCollection() as $item) {
644
+ $weightShipping += $item->getWeight()*$item->getQtyOrdered();
645
+ }
646
+ if($helper->getConfigWeightUnit() == 'g')
647
+ {
648
+ $weightShipping = $weightShipping / 1000; // conversion g => kg
649
+ }
650
+ if($weightShipping > $weight_limit) {
651
+ /* multi shipping. 1 shipment by product */
652
+ $trackingNumber = array();
653
+ foreach ($order->getItemsCollection() as $item) {
654
+ $qty = $item->getQtyOrdered();
655
+ for($i = 1; $i <= $qty; $i++) {
656
+ $trackingNumber[] = $this->createNewShipment($orderId,array($item->getId() => '1'));
657
+ }
658
+ }
659
+ }
660
+ else {
661
+ $trackingNumber = $this->createNewShipment($orderId);
662
+ }
663
+ }
664
+ else {
665
+ $trackingNumber = $this->createNewShipment($orderId);
666
+ }
667
+ }
668
+ } else {
669
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
670
+ if ($shipmentId) {
671
+ $trackingNumber = $this->getEtiquetteUrl($shipmentId);
672
+ } else {
673
+ $shipmentIncrementId = $this->getRequest()->getParam('shipment_increment_id');
674
+ $shipmentId = $this->getShipmentByIncrementId($shipmentIncrementId);
675
+ $trackingNumber = $this->getEtiquetteUrl($shipmentId[0]);
676
+ }
677
+ }
678
+
679
+
680
+ if ($trackingNumber) {
681
+ try {
682
+ if(is_array($trackingNumber)) {
683
+ $trackNumberUrls = array();
684
+ foreach($trackingNumber as $track) {
685
+ $trackNumberUrls[] = str_replace('{trackingNumber}', $track, $helper->getConfigurationTrackingUrl());
686
+ }
687
+ $this->_processDownloadMass($trackNumberUrls);
688
+ //exit(0);
689
+ }
690
+ else {
691
+ $tracking_url = str_replace('{trackingNumber}', $trackingNumber, $helper->getConfigurationTrackingUrl());
692
+ $this->_prepareDownloadResponse('Etiquette_chronopost.pdf', file_get_contents($tracking_url));
693
+ //$this->_processDownload($tracking_url, 'url');
694
+ //exit(0);
695
+ }
696
+ } catch (Mage_Core_Exception $e) {
697
+ $this->_getSession()->addError($helper->__('Désolé, une erreur est survenu lors de la récupération de l\'étiquetes. Merci de contacter Chronopost ou de réessayer plus tard'));
698
+ }
699
+ }
700
+ else
701
+ return $this->_redirectReferer();
702
+ }
703
+
704
+ public function massLivraisonSamediStatusAction() {
705
+ if ($this->getRequest()->getPost('status')) {
706
+ $this->saveLivraisonSamediStatusAction();
707
+ }
708
+ }
709
+
710
+ /* Save the Livraison le Samedi status to orders */
711
+
712
+ public function saveLivraisonSamediStatusAction() {
713
+ /* get the orders */
714
+ $orderIds = $this->getRequest()->getPost('order_ids');
715
+ $status = $this->getRequest()->getPost('status');
716
+ $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
717
+ $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
718
+ $exceptions = array();
719
+
720
+ foreach ($orderIds as $orderId) {
721
+ $order_details = Mage::getModel('sales/order')->load($orderId);
722
+ $shipping_method = '';
723
+ $livraison_le_samedi = $status;
724
+ if ($shipping_method = $order_details->getShippingMethod()) {
725
+ $shipping_method = explode('_', $shipping_method);
726
+ if ($shipping_method[0] == 'chronoexpress') {
727
+ $livraison_le_samedi = '--';
728
+ }
729
+ }
730
+ $condition = array(
731
+ $_connection->quoteInto('order_id = ?', $orderId),
732
+ );
733
+ $_connection->delete($_table, $condition);
734
+
735
+ $dataLine = array(
736
+ 'order_id' => $orderId,
737
+ 'livraison_le_samedi' => $livraison_le_samedi
738
+ );
739
+ try {
740
+ $_connection->insert($_table, $dataLine);
741
+ } catch (Exception $e) {
742
+ $exceptions[] = Mage::helper('chronorelais')->__('Order assigning error: ' . $e->getMessage());
743
+ }
744
+ }
745
+ if ($exceptions) {
746
+ $this->_getSession()->addError($exceptions);
747
+ } else {
748
+ $this->_getSession()->addSuccess($this->__('Livraison le Samedi statut a &eacute;t&eacute; ajout&eacute;'));
749
+ }
750
+ $this->_redirect('*/*/index');
751
+ }
752
+
753
+ /* Remove accents characters */
754
+
755
+ public function removeaccents($string) {
756
+ $stringToReturn = str_replace(
757
+ array('à', 'á', 'â', 'ã', 'ä', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', '/', '\xa8'), array('a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', ' ', 'e'), $string);
758
+ // Remove all remaining other unknown characters
759
+ $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
760
+ $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
761
+ $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
762
+ $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
763
+ return $stringToReturn;
764
+ }
765
+
766
+ /*
767
+ * *******************************************************************
768
+ * ******************** ETIQUETTE DE RETOUR **************************
769
+ * *******************************************************************
770
+ */
771
+
772
+ public function printEtiquetteRetourAction() {
773
+ $shipmentIncrementId = $this->getRequest()->getParam('shipment_increment_id');
774
+ $shipmentId = $this->getShipmentByIncrementId($shipmentIncrementId);
775
+ $shipmentId = $shipmentId[0];
776
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
777
+ $_order = $shipment->getOrder();
778
+ $_shippingAddress = $shipment->getShippingAddress();
779
+ $_billingAddress = $shipment->getBillingAddress();
780
+ $trackingNumber = $this->getEtiquetteRetourUrl($shipment);
781
+
782
+ if ($trackingNumber) {
783
+ try {
784
+ $tracking_url = str_replace('{trackingNumber}', $trackingNumber, Mage::helper('chronorelais')->getConfigurationTrackingUrl());
785
+ $path = $this->savePdf($tracking_url, $shipmentId);
786
+
787
+ /*
788
+ * TODO adexos : Send mail with pdf to customer
789
+ */
790
+ $message_email = 'Bonjour,
791
+ <br />Vous allez bientôt effectuer un envoi Chronopost. La personne qui vous a adressé ce mail a déjà préparé la lettre de transport que vous utiliserez. Après impression, apposez la lettre de transport dans une pochette plastique adhésive et collez la sur votre envoi. Attention le code à barres doit être bien apparent.
792
+ <br />Cordialement,';
793
+
794
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
795
+
796
+ $mail = new Zend_Mail('utf-8');
797
+ $mail->setBodyHtml($message_email);
798
+ $mail->setFrom(Mage::getStoreConfig('contacts/email/recipient_email'));
799
+ $mail->setSubject($_order->getStoreName(1) . ' : Etiquette de retour chronopost');
800
+ $mail->createAttachment(file_get_contents($path), Zend_Mime::TYPE_OCTETSTREAM, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'etiquette_retour.pdf');
801
+
802
+ $mail->addTo($customer_email);
803
+ $mail->send();
804
+
805
+ $mail->clearRecipients();
806
+ $mail->addTo(Mage::getStoreConfig('contacts/email/recipient_email'));
807
+ $mail->send();
808
+
809
+ $this->_getSession()->addSuccess(Mage::helper('chronorelais')->__('L\'etiquette de retour à bien été envoyée au client.'));
810
+ } catch (Mage_Core_Exception $e) {
811
+ $this->_getSession()->addError(Mage::helper('chronorelais')->__('Désolé, une erreure est survenu lors de la récupération de l\'étiquetes. Merci de contacter Chronopost ou de réessayer plus tard'));
812
+ }
813
+ }
814
+ return $this->_redirectReferer();
815
+ }
816
+
817
+ protected function getEtiquetteRetourParams($shipment, $_shippingMethod) {
818
+ $_order = $shipment->getOrder();
819
+ $_shippingAddress = $shipment->getShippingAddress();
820
+ $_billingAddress = $shipment->getBillingAddress();
821
+ $_helper = Mage::helper('chronorelais');
822
+
823
+ if ($_shippingAddress->getCountryId() != 'FR') {
824
+ $this->_getSession()->addError($_helper->__('Les retours sont disponibles uniquement pour la France'));
825
+ return;
826
+ }
827
+ $shippingMethodAllow = array('chronorelais','chronopost','chronopostc10','chronopostc18');
828
+ if (!in_array($_shippingMethod[0], $shippingMethodAllow)) {
829
+ $this->_getSession()->addError($_helper->__('Les retours ne sont pas disponibles pour le mode de livraison ' . $_shippingMethod[0]));
830
+ return;
831
+ }
832
+
833
+ if (in_array($_shippingMethod[0], $shippingMethodAllow)) {
834
+ $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
835
+
836
+ //esdParams parameters
837
+ $esdParams = array(
838
+ 'height' => '',
839
+ 'width' => '',
840
+ 'length' => ''
841
+ );
842
+
843
+ //header parameters
844
+ $header = array(
845
+ 'idEmit' => 'MAG',
846
+ 'accountNumber' => $_helper->getConfigurationAccountNumber(),
847
+ 'subAccount' => $_helper->getConfigurationSubAccountNumber()
848
+ );
849
+
850
+ //shipper parameters
851
+ $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
852
+ $recipient = array(
853
+ 'recipientAdress1' => $_helper->getConfigurationShipperInfo('address1'),
854
+ 'recipientAdress2' => $_helper->getConfigurationShipperInfo('address2'),
855
+ 'recipientCity' => $_helper->getConfigurationShipperInfo('city'),
856
+ 'recipientCivility' => $_helper->getConfigurationShipperInfo('civility'),
857
+ 'recipientContactName' => $_helper->getConfigurationShipperInfo('contactname'),
858
+ 'recipientCountry' => $_helper->getConfigurationShipperInfo('country'),
859
+ 'recipientEmail' => $_helper->getConfigurationShipperInfo('email'),
860
+ 'recipientMobilePhone' => $shipperMobilePhone,
861
+ 'recipientName' => $_helper->getConfigurationShipperInfo('name'),
862
+ 'recipientName2' => $_helper->getConfigurationShipperInfo('name2'),
863
+ 'recipientPhone' => $_helper->getConfigurationShipperInfo('phone'),
864
+ 'recipientPreAlert' => '',
865
+ 'recipientZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
866
+ );
867
+
868
+ //customer parameters
869
+ $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
870
+ $customer = array(
871
+ 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
872
+ 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
873
+ 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
874
+ 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
875
+ 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
876
+ 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
877
+ 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
878
+ 'customerMobilePhone' => $customerMobilePhone,
879
+ 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
880
+ 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
881
+ 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
882
+ 'customerPreAlert' => '',
883
+ 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
884
+ );
885
+
886
+ //recipient parameters
887
+ $_recipientAddress = $_shippingAddress;
888
+ if ($_shippingMethod[0] == 'chronorelais') {
889
+ // Nicolas, le 27/11/2014 : si Chronorelais, on doit utiliser l'adresse de facturation, non de livraison (qui est celle du relais)
890
+ $_recipientAddress = $_billingAddress;
891
+ }
892
+ $recipient_address = $_recipientAddress->getStreet();
893
+
894
+ // Champs forcément basés sur l'adresse de livraison
895
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
896
+ $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
897
+ $recipientName = $this->getFilledValue($_recipientAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
898
+ $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
899
+ //remove any alphabets in phone number
900
+
901
+ //$recipientPhone = trim(ereg_replace("[^0-9.-]", " ", $_shippingAddress->getTelephone()));
902
+ $recipientPhone = trim(preg_replace("/[^0-9\.\-]/", " ", $_shippingAddress->getTelephone()));
903
+ if (!isset($recipient_address[1])) {
904
+ $recipient_address[1] = '';
905
+ }
906
+
907
+ $shipper = array(
908
+ 'shipperAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
909
+ 'shipperAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
910
+ 'shipperCity' => $this->getFilledValue($_recipientAddress->getCity()),
911
+ 'shipperCivility' => 'M',
912
+ 'shipperContactName' => $recipientName2,
913
+ 'shipperCountry' => $this->getFilledValue($_recipientAddress->getCountryId()),
914
+ 'shipperEmail' => $customer_email,
915
+ 'shipperMobilePhone' => $recipientMobilePhone,
916
+ 'shipperName' => $recipientName,
917
+ 'shipperName2' => $recipientName2,
918
+ 'shipperPhone' => $recipientPhone,
919
+ 'shipperPreAlert' => '',
920
+ 'shipperZipCode' => $this->getFilledValue($_recipientAddress->getPostcode()),
921
+ );
922
+
923
+ //ref parameters
924
+ $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
925
+ if (!$recipientRef) {
926
+ $recipientRef = $_order->getCustomerId();
927
+ }
928
+ $shipperRef = $_order->getRealOrderId();
929
+
930
+ $ref = array(
931
+ 'recipientRef' => $recipientRef,
932
+ 'shipperRef' => $shipperRef
933
+ );
934
+
935
+ //skybill parameters
936
+ /* Livraison Samedi (Delivery Saturday) field */
937
+ $SaturdayShipping = 0; //default value for the saturday shipping
938
+ $send_day = strtolower(date('l'));
939
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
940
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
941
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
942
+ } else {
943
+ if ($_deliver_on_saturday == 'Yes') {
944
+ $_deliver_on_saturday = 1;
945
+ } else {
946
+ $_deliver_on_saturday = 0;
947
+ }
948
+ }
949
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
950
+ if ($_deliver_on_saturday && $is_sending_day) {
951
+ $SaturdayShipping = 6;
952
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
953
+ $SaturdayShipping = 1;
954
+ }
955
+ }
956
+
957
+ $weight = 0;
958
+ foreach ($shipment->getItemsCollection() as $item) {
959
+ $weight += $item->weight * $item->qty;
960
+ }
961
+ if ($_helper->getConfigWeightUnit() == 'g') {
962
+ $weight = $weight / 1000; /* conversion g => kg */
963
+ }
964
+ $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
965
+
966
+ $skybill = array(
967
+ 'codCurrency' => 'EUR',
968
+ 'codValue' => '',
969
+ 'content1' => '',
970
+ 'content2' => '',
971
+ 'content3' => '',
972
+ 'content4' => '',
973
+ 'content5' => '',
974
+ 'customsCurrency' => 'EUR',
975
+ 'customsValue' => '',
976
+ 'evtCode' => 'DC',
977
+ 'insuredCurrency' => 'EUR',
978
+ 'insuredValue' => '',
979
+ 'objectType' => 'MAR',
980
+ 'productCode' => Chronopost_Chronorelais_Helper_Data::CHRONO_POST,
981
+ 'service' => $SaturdayShipping,
982
+ 'shipDate' => date('c'),
983
+ 'shipHour' => date('H'),
984
+ 'weight' => $weight,
985
+ 'weightUnit' => 'KGM'
986
+ );
987
+
988
+ $skybillParams = array(
989
+ 'mode' => $_helper->getConfigurationSkybillParam()
990
+ );
991
+
992
+ $expeditionArray = array(
993
+ 'esdParams' => $esdParams,
994
+ 'header' => $header,
995
+ 'shipper' => $shipper,
996
+ 'customer' => $customer,
997
+ 'recipient' => $recipient,
998
+ 'ref' => $ref,
999
+ 'skybill' => $skybill,
1000
+ 'skybillParams' => $skybillParams,
1001
+ 'password' => $_helper->getConfigurationAccountPass(),
1002
+ 'option' => '0'
1003
+ );
1004
+
1005
+ return $expeditionArray;
1006
+ }
1007
+ }
1008
+
1009
+ protected function getEtiquetteRetourUrl($shipment) {
1010
+ //On récupère les infos d'expédition
1011
+ $reservationNumber = '';
1012
+ $_helper = Mage::helper('chronorelais');
1013
+
1014
+ $_order = $shipment->getOrder();
1015
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
1016
+
1017
+ $expeditionArray = $this->getEtiquetteRetourParams($shipment, $_shippingMethod);
1018
+ $tracking_number = '';
1019
+ if ($expeditionArray) {
1020
+ $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
1021
+ try {
1022
+ $webservbt = $client->__call("reservationExpeditionV2", $expeditionArray);
1023
+ if (!$webservbt->errorCode && $webservbt->reservationNumber) {
1024
+ $tracking_number = $webservbt->skybillNumber;
1025
+ return $webservbt->reservationNumber;
1026
+ } else {
1027
+ $this->_getSession()->addError($_helper->__($webservbt->errorMessage));
1028
+ }
1029
+ } catch (SoapFault $fault) {
1030
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
1031
+ }
1032
+ }
1033
+ }
1034
+
1035
+ protected function savePdf($url, $shipmentId) {
1036
+ $this->createMediaChronopostFolder();
1037
+ $path = 'media/chronopost/etiquetteRetour-' . $shipmentId . '.pdf';
1038
+ file_put_contents($path, file_get_contents($url));
1039
+ return $path;
1040
+ }
1041
+
1042
+ /* create folder media/chronopost if not exist */
1043
+ protected function createMediaChronopostFolder() {
1044
+ $path = 'media/chronopost';
1045
+ if(!is_dir($path)) {
1046
+ mkdir($path,0777);
1047
+ }
1048
+ }
1049
+
1050
  }
app/code/community/Chronopost/Chronorelais/controllers/Sales/Order/ShipmentController.php CHANGED
@@ -1,386 +1,386 @@
1
- <?php
2
-
3
- require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
4
-
5
- class Chronopost_Chronorelais_Sales_Order_ShipmentController extends Mage_Adminhtml_Sales_Order_ShipmentController {
6
-
7
- /**
8
- * Save shipment
9
- * We can save only new shipment. Existing shipments are not editable
10
- */
11
- public function getFilledValue($value) {
12
- if ($value) {
13
- return $this->removeaccents(trim($value));
14
- } else {
15
- return '';
16
- }
17
- }
18
-
19
- public function checkMobileNumber($value) {
20
- if ($reqvalue = trim($value)) {
21
- $_number = substr($reqvalue, 0, 2);
22
- $fixed_array = array('01', '02', '03', '04', '05', '06', '06');
23
- if (in_array($_number, $fixed_array)) {
24
- return $reqvalue;
25
- } else {
26
- return '';
27
- }
28
- }
29
- }
30
-
31
- protected function saveAndCreateEtiquette($shipment) {
32
- $shipment->register();
33
-
34
- //Si l'expedition est réalisé par Mondial Relay, on créé le tracking automatiquement.
35
-
36
- $_order = $shipment->getOrder();
37
- $_shippingMethod = explode("_", $_order->getShippingMethod());
38
-
39
- $_shippingAddress = $shipment->getShippingAddress();
40
- $_billingAddress = $shipment->getBillingAddress();
41
- $_helper = Mage::helper('chronorelais');
42
-
43
- $shippingMethodAllow = array('chronorelais','chronopost','chronoexpress','chronopostc10','chronopostc18','chronopostcclassic');
44
- if (in_array($_shippingMethod[0],$shippingMethodAllow)) {
45
-
46
- $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
47
-
48
- //esdParams parameters
49
- $esdParams = array(
50
- 'height' => '',
51
- 'width' => '',
52
- 'length' => ''
53
- );
54
-
55
- //header parameters
56
- $header = array(
57
- 'idEmit' => 'CHRFR',
58
- 'accountNumber' => $_helper->getConfigurationAccountNumber(),
59
- 'subAccount' => $_helper->getConfigurationSubAccountNumber()
60
- );
61
-
62
- //shipper parameters
63
- $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
64
- $shipper = array(
65
- 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
66
- 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
67
- 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
68
- 'shipperCivility' => $_helper->getConfigurationShipperInfo('civility'),
69
- 'shipperContactName' => $_helper->getConfigurationShipperInfo('contactname'),
70
- 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
71
- 'shipperEmail' => $_helper->getConfigurationShipperInfo('email'),
72
- 'shipperMobilePhone' => $shipperMobilePhone,
73
- 'shipperName' => $_helper->getConfigurationShipperInfo('name'),
74
- 'shipperName2' => $_helper->getConfigurationShipperInfo('name2'),
75
- 'shipperPhone' => $_helper->getConfigurationShipperInfo('phone'),
76
- 'shipperPreAlert' => '',
77
- 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
78
- );
79
-
80
- //customer parameters
81
- $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
82
- $customer = array(
83
- 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
84
- 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
85
- 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
86
- 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
87
- 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
88
- 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
89
- 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
90
- 'customerMobilePhone' => $customerMobilePhone,
91
- 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
92
- 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
93
- 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
94
- 'customerPreAlert' => '',
95
- 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
96
- );
97
-
98
- //recipient parameters
99
- $recipient_address = $_shippingAddress->getStreet();
100
- if (!isset($recipient_address[1])) {
101
- $recipient_address[1] = '';
102
- }
103
- $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
104
- $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
105
- $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
106
- $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
107
- //remove any alphabets in phone number
108
-
109
- //$recipientPhone = trim(ereg_replace("[^0-9.-]", " ", $_shippingAddress->getTelephone()));
110
- $recipientPhone = trim(preg_replace("/[^0-9\.\-]/", " ", $_shippingAddress->getTelephone()));
111
-
112
- $recipient = array(
113
- 'recipientAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
114
- 'recipientAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
115
- 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
116
- 'recipientContactName' => $recipientName2,
117
- 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
118
- 'recipientEmail' => $customer_email,
119
- 'recipientMobilePhone' => $recipientMobilePhone,
120
- 'recipientName' => $recipientName,
121
- 'recipientName2' => $recipientName2,
122
- 'recipientPhone' => $recipientPhone,
123
- 'recipientPreAlert' => '',
124
- 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
125
- );
126
-
127
- //ref parameters
128
- $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
129
- if (!$recipientRef) {
130
- $recipientRef = $_order->getCustomerId();
131
- }
132
- $shipperRef = $_order->getRealOrderId();
133
-
134
- $ref = array(
135
- 'recipientRef' => $recipientRef,
136
- 'shipperRef' => $shipperRef
137
- );
138
-
139
- //skybill parameters
140
- /* Livraison Samedi (Delivery Saturday) field */
141
- $SaturdayShipping = 0; //default value for the saturday shipping
142
- $send_day = strtolower(date('l'));
143
- if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
144
- if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
145
- $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
146
- } else {
147
- if ($_deliver_on_saturday == 'Yes') {
148
- $_deliver_on_saturday = 1;
149
- } else {
150
- $_deliver_on_saturday = 0;
151
- }
152
- }
153
- $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
154
- if ($_deliver_on_saturday && $is_sending_day) {
155
- $SaturdayShipping = 1;
156
- } elseif (!$_deliver_on_saturday && $is_sending_day) {
157
- $SaturdayShipping = 6;
158
- }
159
- }
160
-
161
- $weight = 0;
162
- foreach ($shipment->getItemsCollection() as $item) {
163
- $weight += $item->weight * $item->qty;
164
- }
165
- if ($_helper->getConfigWeightUnit() == 'g') {
166
- $weight = $weight / 1000; /* conversion g => kg */
167
- }
168
- $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
169
-
170
- $skybill = array(
171
- 'codCurrency' => 'EUR',
172
- 'codValue' => '',
173
- 'content1' => '',
174
- 'content2' => '',
175
- 'content3' => '',
176
- 'content4' => '',
177
- 'content5' => '',
178
- 'customsCurrency' => 'EUR',
179
- 'customsValue' => '',
180
- 'evtCode' => 'DC',
181
- 'insuredCurrency' => 'EUR',
182
- 'insuredValue' => '',
183
- 'objectType' => 'MAR',
184
- 'productCode' => $_helper->getChronoProductCodeToShipment($_shippingMethod[0]),
185
- 'service' => $SaturdayShipping,
186
- 'shipDate' => date('c'),
187
- 'shipHour' => date('H'),
188
- 'weight' => $weight,
189
- 'weightUnit' => 'KGM'
190
- );
191
-
192
- $expeditionArray = array(
193
- 'esdParams' => $esdParams,
194
- 'header' => $header,
195
- 'shipper' => $shipper,
196
- 'customer' => $customer,
197
- 'recipient' => $recipient,
198
- 'ref' => $ref,
199
- 'skybill' => $skybill,
200
- 'skybillParams' => $_helper->getConfigurationSkybillParam(),
201
- 'password' => $_helper->getConfigurationAccountPass(),
202
- 'option' => '0'
203
- );
204
-
205
- $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
206
- try {
207
- $expedition = $client->__call("reservationExpeditionV2", $expeditionArray);
208
- if (!$expedition->errorCode && $expedition->skybillNumber) {
209
- $track = Mage::getModel('sales/order_shipment_track')
210
- ->setNumber($expedition->skybillNumber)
211
- ->setCarrier(ucwords($_shippingMethod[0]))
212
- ->setCarrierCode($_shippingMethod[0])
213
- ->setTitle(ucwords($_shippingMethod[0]))
214
- ->setChronoReservationNumber($expedition->reservationNumber)
215
- ->setPopup(1);
216
- $shipment->addTrack($track);
217
- } else {
218
- $this->_getSession()->addError($_helper->__($expedition->errorMessage));
219
- $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
220
- return;
221
- }
222
- } catch (SoapFault $fault) {
223
- $this->_getSession()->addError($_helper->__($fault->faultstring));
224
- $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
225
- return;
226
- }
227
- }
228
-
229
- $comment = '';
230
- if (!empty($data['comment_text'])) {
231
- $shipment->addComment($data['comment_text'], isset($data['comment_customer_notify']));
232
- $comment = $data['comment_text'];
233
- }
234
-
235
- if (!empty($data['send_email'])) {
236
- $shipment->setEmailSent(true);
237
- }
238
-
239
- $this->_saveShipment($shipment);
240
- $shipment->sendEmail(!empty($data['send_email']), $comment);
241
- $this->_getSession()->addSuccess($this->__('Shipment was successfully created.'));
242
- $this->_redirect('adminhtml/sales_order/view', array('order_id' => $shipment->getOrderId()));
243
- return;
244
- }
245
-
246
- /**
247
- * Initialize shipment model instance
248
- *
249
- * @return Mage_Sales_Model_Order_Shipment|bool
250
- */
251
- protected function _initShipment()
252
- {
253
- $this->_title($this->__('Sales'))->_title($this->__('Shipments'));
254
- $helper = Mage::helper('chronorelais');
255
- $shipment = false;
256
- $shipmentId = $this->getRequest()->getParam('shipment_id');
257
- $orderId = $this->getRequest()->getParam('order_id');
258
- if ($shipmentId) {
259
- $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
260
- } elseif ($orderId) {
261
- $order = Mage::getModel('sales/order')->load($orderId);
262
-
263
- /**
264
- * Check order existing
265
- */
266
- if (!$order->getId()) {
267
- $this->_getSession()->addError($this->__('The order no longer exists.'));
268
- return false;
269
- }
270
- /**
271
- * Check shipment is available to create separate from invoice
272
- */
273
- if ($order->getForcedDoShipmentWithInvoice()) {
274
- $this->_getSession()->addError($this->__('Cannot do shipment for the order separately from invoice.'));
275
- return false;
276
- }
277
- /**
278
- * Check shipment create availability
279
- */
280
- if (!$order->canShip()) {
281
- $this->_getSession()->addError($this->__('Cannot do shipment for the order.'));
282
- return false;
283
- }
284
- $savedQtys = $this->_getItemQtys();
285
-
286
- /* If shipping method is Chronopost => check if shipping weight isn't over limit */
287
- $chronopostMethods = array('chronopost_chronopost','chronoexpress_chronoexpress','chronorelais_chronorelais','chronopostc10_chronopostC10','chronopostc18_chronopostC18','chronopostcclassic_chronopostCClassic');
288
- $shippingMethod = $order->getShippingMethod();
289
- if(in_array($shippingMethod, $chronopostMethods)) {
290
- $weightShipping = 0;
291
- $shippingMethod = explode("_", $shippingMethod);
292
- $shippingMethod = $shippingMethod[0];
293
- $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
294
- foreach($savedQtys as $iditem => $qty) {
295
- $item = $order->getItemById($iditem);
296
- $weightShipping += $item->getWeight()*$qty;
297
- }
298
- if($helper->getConfigWeightUnit() == 'g')
299
- {
300
- $weightShipping = $weightShipping / 1000; // conversion g => kg
301
- }
302
- if($weightShipping > $weight_limit) {
303
-
304
- /* Create one shipment by product ordered */
305
- foreach($savedQtys as $iditem => $qty) {
306
- $item = $order->getItemById($iditem);
307
- $weightShipping += $item->getWeight()*$qty;
308
- for($i = 1; $i <= $qty; $i++) {
309
- $shipment[] = Mage::getModel('sales/service_order', $order)->prepareShipment(array($item->getId() => '1'));
310
-
311
- }
312
- }
313
-
314
-
315
- //$this->_getSession()->addError($this->__('Le poids total de l\'expédition est supérieur au poids limite pour une livraison '.$shippingMethod));
316
- //return false;
317
- }
318
- }
319
-
320
-
321
- if(!$shipment)
322
- {
323
- $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($savedQtys);
324
-
325
- $tracks = $this->getRequest()->getPost('tracking');
326
- if ($tracks) {
327
- foreach ($tracks as $data) {
328
- if (empty($data['number'])) {
329
- Mage::throwException($this->__('Tracking number cannot be empty.'));
330
- }
331
- $track = Mage::getModel('sales/order_shipment_track')
332
- ->addData($data);
333
- $shipment->addTrack($track);
334
- }
335
- }
336
- }
337
- }
338
-
339
- Mage::register('current_shipment', $shipment);
340
- return $shipment;
341
- }
342
-
343
- public function saveAction() {
344
- $data = $this->getRequest()->getPost('shipment');
345
- $shipmentId = $this->getRequest()->getParam('shipment_id');
346
- $orderId = $this->getRequest()->getParam('order_id');
347
-
348
- try {
349
-
350
- if ($shipment = $this->_initShipment()) {
351
- if(is_array($shipment))
352
- {
353
- foreach($shipment as $ship) {
354
- $this->saveAndCreateEtiquette($ship);
355
- }
356
- }
357
- else
358
- {
359
- $this->saveAndCreateEtiquette($shipment);
360
- }
361
- } else {
362
- $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
363
- return;
364
- }
365
-
366
- } catch (Mage_Core_Exception $e) {
367
- $this->_getSession()->addError($e->getMessage());
368
- } catch (Exception $e) {
369
- $this->_getSession()->addError($this->__('Can not save shipment: ' . $e->getMessage()));
370
- }
371
- //$this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
372
- $this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
373
- }
374
-
375
- public function removeaccents($string) {
376
- $stringToReturn = str_replace(
377
- array('�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '/', '\xa8'), array('a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', ' ', 'e'), $string);
378
- // Remove all remaining other unknown characters
379
- $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
380
- $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
381
- $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
382
- $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
383
- return $stringToReturn;
384
- }
385
-
386
- }
1
+ <?php
2
+
3
+ require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
4
+
5
+ class Chronopost_Chronorelais_Sales_Order_ShipmentController extends Mage_Adminhtml_Sales_Order_ShipmentController {
6
+
7
+ /**
8
+ * Save shipment
9
+ * We can save only new shipment. Existing shipments are not editable
10
+ */
11
+ public function getFilledValue($value) {
12
+ if ($value) {
13
+ return $this->removeaccents(trim($value));
14
+ } else {
15
+ return '';
16
+ }
17
+ }
18
+
19
+ public function checkMobileNumber($value) {
20
+ if ($reqvalue = trim($value)) {
21
+ $_number = substr($reqvalue, 0, 2);
22
+ $fixed_array = array('01', '02', '03', '04', '05', '06', '06');
23
+ if (in_array($_number, $fixed_array)) {
24
+ return $reqvalue;
25
+ } else {
26
+ return '';
27
+ }
28
+ }
29
+ }
30
+
31
+ protected function saveAndCreateEtiquette($shipment) {
32
+ $shipment->register();
33
+
34
+ //Si l'expedition est réalisé par Mondial Relay, on créé le tracking automatiquement.
35
+
36
+ $_order = $shipment->getOrder();
37
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
38
+
39
+ $_shippingAddress = $shipment->getShippingAddress();
40
+ $_billingAddress = $shipment->getBillingAddress();
41
+ $_helper = Mage::helper('chronorelais');
42
+
43
+ $shippingMethodAllow = array('chronorelais','chronopost','chronoexpress','chronopostc10','chronopostc18','chronopostcclassic');
44
+ if (in_array($_shippingMethod[0],$shippingMethodAllow)) {
45
+
46
+ $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
47
+
48
+ //esdParams parameters
49
+ $esdParams = array(
50
+ 'height' => '',
51
+ 'width' => '',
52
+ 'length' => ''
53
+ );
54
+
55
+ //header parameters
56
+ $header = array(
57
+ 'idEmit' => 'MAG',
58
+ 'accountNumber' => $_helper->getConfigurationAccountNumber(),
59
+ 'subAccount' => $_helper->getConfigurationSubAccountNumber()
60
+ );
61
+
62
+ //shipper parameters
63
+ $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
64
+ $shipper = array(
65
+ 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
66
+ 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
67
+ 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
68
+ 'shipperCivility' => $_helper->getConfigurationShipperInfo('civility'),
69
+ 'shipperContactName' => $_helper->getConfigurationShipperInfo('contactname'),
70
+ 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
71
+ 'shipperEmail' => $_helper->getConfigurationShipperInfo('email'),
72
+ 'shipperMobilePhone' => $shipperMobilePhone,
73
+ 'shipperName' => $_helper->getConfigurationShipperInfo('name'),
74
+ 'shipperName2' => $_helper->getConfigurationShipperInfo('name2'),
75
+ 'shipperPhone' => $_helper->getConfigurationShipperInfo('phone'),
76
+ 'shipperPreAlert' => '',
77
+ 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
78
+ );
79
+
80
+ //customer parameters
81
+ $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
82
+ $customer = array(
83
+ 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
84
+ 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
85
+ 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
86
+ 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
87
+ 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
88
+ 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
89
+ 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
90
+ 'customerMobilePhone' => $customerMobilePhone,
91
+ 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
92
+ 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
93
+ 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
94
+ 'customerPreAlert' => '',
95
+ 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
96
+ );
97
+
98
+ //recipient parameters
99
+ $recipient_address = $_shippingAddress->getStreet();
100
+ if (!isset($recipient_address[1])) {
101
+ $recipient_address[1] = '';
102
+ }
103
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
104
+ $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
105
+ $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
106
+ $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
107
+ //remove any alphabets in phone number
108
+
109
+ //$recipientPhone = trim(ereg_replace("[^0-9.-]", " ", $_shippingAddress->getTelephone()));
110
+ $recipientPhone = trim(preg_replace("/[^0-9\.\-]/", " ", $_shippingAddress->getTelephone()));
111
+
112
+ $recipient = array(
113
+ 'recipientAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
114
+ 'recipientAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
115
+ 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
116
+ 'recipientContactName' => $recipientName2,
117
+ 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
118
+ 'recipientEmail' => $customer_email,
119
+ 'recipientMobilePhone' => $recipientMobilePhone,
120
+ 'recipientName' => $recipientName,
121
+ 'recipientName2' => $recipientName2,
122
+ 'recipientPhone' => $recipientPhone,
123
+ 'recipientPreAlert' => '',
124
+ 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
125
+ );
126
+
127
+ //ref parameters
128
+ $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
129
+ if (!$recipientRef) {
130
+ $recipientRef = $_order->getCustomerId();
131
+ }
132
+ $shipperRef = $_order->getRealOrderId();
133
+
134
+ $ref = array(
135
+ 'recipientRef' => $recipientRef,
136
+ 'shipperRef' => $shipperRef
137
+ );
138
+
139
+ //skybill parameters
140
+ /* Livraison Samedi (Delivery Saturday) field */
141
+ $SaturdayShipping = 0; //default value for the saturday shipping
142
+ $send_day = strtolower(date('l'));
143
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
144
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
145
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
146
+ } else {
147
+ if ($_deliver_on_saturday == 'Yes') {
148
+ $_deliver_on_saturday = 1;
149
+ } else {
150
+ $_deliver_on_saturday = 0;
151
+ }
152
+ }
153
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
154
+ if ($_deliver_on_saturday && $is_sending_day) {
155
+ $SaturdayShipping = 1;
156
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
157
+ $SaturdayShipping = 6;
158
+ }
159
+ }
160
+
161
+ $weight = 0;
162
+ foreach ($shipment->getItemsCollection() as $item) {
163
+ $weight += $item->weight * $item->qty;
164
+ }
165
+ if ($_helper->getConfigWeightUnit() == 'g') {
166
+ $weight = $weight / 1000; /* conversion g => kg */
167
+ }
168
+ $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
169
+
170
+ $skybill = array(
171
+ 'codCurrency' => 'EUR',
172
+ 'codValue' => '',
173
+ 'content1' => '',
174
+ 'content2' => '',
175
+ 'content3' => '',
176
+ 'content4' => '',
177
+ 'content5' => '',
178
+ 'customsCurrency' => 'EUR',
179
+ 'customsValue' => '',
180
+ 'evtCode' => 'DC',
181
+ 'insuredCurrency' => 'EUR',
182
+ 'insuredValue' => '',
183
+ 'objectType' => 'MAR',
184
+ 'productCode' => $_helper->getChronoProductCodeToShipment($_shippingMethod[0]),
185
+ 'service' => $SaturdayShipping,
186
+ 'shipDate' => date('c'),
187
+ 'shipHour' => date('H'),
188
+ 'weight' => $weight,
189
+ 'weightUnit' => 'KGM'
190
+ );
191
+
192
+ $expeditionArray = array(
193
+ 'esdParams' => $esdParams,
194
+ 'header' => $header,
195
+ 'shipper' => $shipper,
196
+ 'customer' => $customer,
197
+ 'recipient' => $recipient,
198
+ 'ref' => $ref,
199
+ 'skybill' => $skybill,
200
+ 'skybillParams' => $_helper->getConfigurationSkybillParam(),
201
+ 'password' => $_helper->getConfigurationAccountPass(),
202
+ 'option' => '0'
203
+ );
204
+
205
+ $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
206
+ try {
207
+ $expedition = $client->__call("reservationExpeditionV2", $expeditionArray);
208
+ if (!$expedition->errorCode && $expedition->skybillNumber) {
209
+ $track = Mage::getModel('sales/order_shipment_track')
210
+ ->setNumber($expedition->skybillNumber)
211
+ ->setCarrier(ucwords($_shippingMethod[0]))
212
+ ->setCarrierCode($_shippingMethod[0])
213
+ ->setTitle(ucwords($_shippingMethod[0]))
214
+ ->setChronoReservationNumber($expedition->reservationNumber)
215
+ ->setPopup(1);
216
+ $shipment->addTrack($track);
217
+ } else {
218
+ $this->_getSession()->addError($_helper->__($expedition->errorMessage));
219
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
220
+ return;
221
+ }
222
+ } catch (SoapFault $fault) {
223
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
224
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
225
+ return;
226
+ }
227
+ }
228
+
229
+ $comment = '';
230
+ if (!empty($data['comment_text'])) {
231
+ $shipment->addComment($data['comment_text'], isset($data['comment_customer_notify']));
232
+ $comment = $data['comment_text'];
233
+ }
234
+
235
+ if (!empty($data['send_email'])) {
236
+ $shipment->setEmailSent(true);
237
+ }
238
+
239
+ $this->_saveShipment($shipment);
240
+ $shipment->sendEmail(!empty($data['send_email']), $comment);
241
+ $this->_getSession()->addSuccess($this->__('Shipment was successfully created.'));
242
+ $this->_redirect('adminhtml/sales_order/view', array('order_id' => $shipment->getOrderId()));
243
+ return;
244
+ }
245
+
246
+ /**
247
+ * Initialize shipment model instance
248
+ *
249
+ * @return Mage_Sales_Model_Order_Shipment|bool
250
+ */
251
+ protected function _initShipment()
252
+ {
253
+ $this->_title($this->__('Sales'))->_title($this->__('Shipments'));
254
+ $helper = Mage::helper('chronorelais');
255
+ $shipment = false;
256
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
257
+ $orderId = $this->getRequest()->getParam('order_id');
258
+ if ($shipmentId) {
259
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
260
+ } elseif ($orderId) {
261
+ $order = Mage::getModel('sales/order')->load($orderId);
262
+
263
+ /**
264
+ * Check order existing
265
+ */
266
+ if (!$order->getId()) {
267
+ $this->_getSession()->addError($this->__('The order no longer exists.'));
268
+ return false;
269
+ }
270
+ /**
271
+ * Check shipment is available to create separate from invoice
272
+ */
273
+ if ($order->getForcedDoShipmentWithInvoice()) {
274
+ $this->_getSession()->addError($this->__('Cannot do shipment for the order separately from invoice.'));
275
+ return false;
276
+ }
277
+ /**
278
+ * Check shipment create availability
279
+ */
280
+ if (!$order->canShip()) {
281
+ $this->_getSession()->addError($this->__('Cannot do shipment for the order.'));
282
+ return false;
283
+ }
284
+ $savedQtys = $this->_getItemQtys();
285
+
286
+ /* If shipping method is Chronopost => check if shipping weight isn't over limit */
287
+ $chronopostMethods = array('chronopost_chronopost','chronoexpress_chronoexpress','chronorelais_chronorelais','chronopostc10_chronopostC10','chronopostc18_chronopostC18','chronopostcclassic_chronopostCClassic');
288
+ $shippingMethod = $order->getShippingMethod();
289
+ if(in_array($shippingMethod, $chronopostMethods)) {
290
+ $weightShipping = 0;
291
+ $shippingMethod = explode("_", $shippingMethod);
292
+ $shippingMethod = $shippingMethod[0];
293
+ $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
294
+ foreach($savedQtys as $iditem => $qty) {
295
+ $item = $order->getItemById($iditem);
296
+ $weightShipping += $item->getWeight()*$qty;
297
+ }
298
+ if($helper->getConfigWeightUnit() == 'g')
299
+ {
300
+ $weightShipping = $weightShipping / 1000; // conversion g => kg
301
+ }
302
+ if($weightShipping > $weight_limit) {
303
+
304
+ /* Create one shipment by product ordered */
305
+ foreach($savedQtys as $iditem => $qty) {
306
+ $item = $order->getItemById($iditem);
307
+ $weightShipping += $item->getWeight()*$qty;
308
+ for($i = 1; $i <= $qty; $i++) {
309
+ $shipment[] = Mage::getModel('sales/service_order', $order)->prepareShipment(array($item->getId() => '1'));
310
+
311
+ }
312
+ }
313
+
314
+
315
+ //$this->_getSession()->addError($this->__('Le poids total de l\'expédition est supérieur au poids limite pour une livraison '.$shippingMethod));
316
+ //return false;
317
+ }
318
+ }
319
+
320
+
321
+ if(!$shipment)
322
+ {
323
+ $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($savedQtys);
324
+
325
+ $tracks = $this->getRequest()->getPost('tracking');
326
+ if ($tracks) {
327
+ foreach ($tracks as $data) {
328
+ if (empty($data['number'])) {
329
+ Mage::throwException($this->__('Tracking number cannot be empty.'));
330
+ }
331
+ $track = Mage::getModel('sales/order_shipment_track')
332
+ ->addData($data);
333
+ $shipment->addTrack($track);
334
+ }
335
+ }
336
+ }
337
+ }
338
+
339
+ Mage::register('current_shipment', $shipment);
340
+ return $shipment;
341
+ }
342
+
343
+ public function saveAction() {
344
+ $data = $this->getRequest()->getPost('shipment');
345
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
346
+ $orderId = $this->getRequest()->getParam('order_id');
347
+
348
+ try {
349
+
350
+ if ($shipment = $this->_initShipment()) {
351
+ if(is_array($shipment))
352
+ {
353
+ foreach($shipment as $ship) {
354
+ $this->saveAndCreateEtiquette($ship);
355
+ }
356
+ }
357
+ else
358
+ {
359
+ $this->saveAndCreateEtiquette($shipment);
360
+ }
361
+ } else {
362
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
363
+ return;
364
+ }
365
+
366
+ } catch (Mage_Core_Exception $e) {
367
+ $this->_getSession()->addError($e->getMessage());
368
+ } catch (Exception $e) {
369
+ $this->_getSession()->addError($this->__('Can not save shipment: ' . $e->getMessage()));
370
+ }
371
+ //$this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
372
+ $this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
373
+ }
374
+
375
+ public function removeaccents($string) {
376
+ $stringToReturn = str_replace(
377
+ array('�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '/', '\xa8'), array('a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', ' ', 'e'), $string);
378
+ // Remove all remaining other unknown characters
379
+ $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
380
+ $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
381
+ $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
382
+ $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
383
+ return $stringToReturn;
384
+ }
385
+
386
+ }
app/code/community/Chronopost/Chronorelais/etc/config.xml CHANGED
@@ -1,452 +1,453 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Chronopost_Chronorelais>
5
- <version>1.0.3</version>
6
- <depends>
7
- <Mage_Shipping />
8
- <Mage_Sales />
9
- <Mage_Adminhtml />
10
- </depends>
11
- </Chronopost_Chronorelais>
12
- </modules>
13
-
14
- <global>
15
- <models>
16
- <chronorelais>
17
- <class>Chronopost_Chronorelais_Model</class>
18
- </chronorelais>
19
- <sales>
20
- <rewrite>
21
- <quote_address_total_shipping>Chronopost_Chronorelais_Model_Sales_Quote_Address_Total_Shipping</quote_address_total_shipping>
22
- </rewrite>
23
- </sales>
24
- </models>
25
- <blocks>
26
- <chronorelais>
27
- <class>Chronopost_Chronorelais_Block</class>
28
- </chronorelais>
29
- <adminhtml>
30
- <rewrite>
31
- <sales_order_shipment_view>Chronopost_Chronorelais_Block_Sales_Order_Shipment_View</sales_order_shipment_view>
32
- </rewrite>
33
- </adminhtml>
34
- </blocks>
35
- <helpers>
36
- <chronorelais>
37
- <class>Chronopost_Chronorelais_Helper</class>
38
- </chronorelais>
39
- </helpers>
40
-
41
- <resources>
42
- <sales>
43
- <shipping>
44
- <carriers>
45
- <chronorelais>
46
- <class>Chronopost_Chronorelais_Model_Carrier_Chronorelais</class>
47
- </chronorelais>
48
- <chronopost>
49
- <class>Chronopost_Chronorelais_Model_Carrier_Chronopost</class>
50
- </chronopost>
51
- <chronoexpress>
52
- <class>Chronopost_Chronorelais_Model_Carrier_Chronoexpress</class>
53
- </chronoexpress>
54
- </carriers>
55
- </shipping>
56
- </sales>
57
- <chronorelais_setup>
58
- <setup>
59
- <module>Chronopost_Chronorelais</module>
60
- <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
61
- </setup>
62
- <connection>
63
- <use>core_setup</use>
64
- </connection>
65
- </chronorelais_setup>
66
- <chronorelais_write>
67
- <connection>
68
- <use>core_write</use>
69
- </connection>
70
- </chronorelais_write>
71
-
72
- <chronorelais_read>
73
- <connection>
74
- <use>core_read</use>
75
- </connection>
76
- </chronorelais_read>
77
- </resources>
78
-
79
- <rewrite>
80
- <chronopost_chronorelais_checkout_onepage>
81
- <from><![CDATA[#^/checkout/onepage/#]]>
82
- </from>
83
- <to>/chronorelais/checkout_onepage/</to>
84
- </chronopost_chronorelais_checkout_onepage>
85
- <chronopost_chronorelais_checkout_multishipping>
86
- <from><![CDATA[#^/checkout/multishipping/#]]>
87
- </from>
88
- <to>/chronorelais/checkout_multishipping/</to>
89
- </chronopost_chronorelais_checkout_multishipping>
90
- <chronopost_chronorelais_sales_order_shipment>
91
- <from><![CDATA[#^/.*sales_order_shipment/save/#]]>
92
- </from>
93
- <to>/chronorelais/sales_order_shipment/save/</to>
94
- </chronopost_chronorelais_sales_order_shipment>
95
- </rewrite>
96
-
97
- <fieldsets>
98
- <sales_copy_order_billing_address>
99
- <w_relay_point_code>
100
- <to_order>*</to_order>
101
- </w_relay_point_code>
102
- </sales_copy_order_billing_address>
103
- <sales_copy_order_shipping_address>
104
- <w_relay_point_code>
105
- <to_order>*</to_order>
106
- </w_relay_point_code>
107
- </sales_copy_order_shipping_address>
108
- <sales_convert_quote_address>
109
- <w_relay_point_code>
110
- <to_order_address>*</to_order_address>
111
- <to_customer_address>*</to_customer_address>
112
- </w_relay_point_code>
113
- </sales_convert_quote_address>
114
- <sales_convert_order_address>
115
- <w_relay_point_code>
116
- <to_quote_address>*</to_quote_address>
117
- </w_relay_point_code>
118
- </sales_convert_order_address>
119
- <customer_address>
120
- <w_relay_point_code>
121
- <to_quote_address>*</to_quote_address>
122
- </w_relay_point_code>
123
- </customer_address>
124
- </fieldsets>
125
-
126
- </global>
127
-
128
- <frontend>
129
- <routers>
130
- <chronorelais>
131
- <use>standard</use>
132
- <args>
133
- <module>Chronopost_Chronorelais</module>
134
- <frontName>chronorelais</frontName>
135
- </args>
136
- </chronorelais>
137
- </routers>
138
-
139
- <layout>
140
- <updates>
141
- <chronorelais>
142
- <file>chronorelais.xml</file>
143
- </chronorelais>
144
- </updates>
145
- </layout>
146
- <translate>
147
- <modules>
148
- <Chronopost_Chronorelais>
149
- <files>
150
- <default>Chronopost_Chronorelais.csv</default>
151
- </files>
152
- </Chronopost_Chronorelais>
153
- </modules>
154
- </translate>
155
- </frontend>
156
-
157
- <admin>
158
- <routers>
159
- <chronorelais>
160
- <use>admin</use>
161
- <args>
162
- <module>Chronopost_Chronorelais</module>
163
- <frontName>chronorelais</frontName>
164
- </args>
165
- </chronorelais>
166
- </routers>
167
- </admin>
168
-
169
- <adminhtml>
170
- <layout>
171
- <updates>
172
- <chronorelais>
173
- <file>chronorelais.xml</file>
174
- </chronorelais>
175
- </updates>
176
- </layout>
177
- <menu>
178
- <sales>
179
- <children>
180
- <chronorelais translate="title"> <!-- TODO faire marcher : module="chronorelais" (aussi dans les children) -->
181
- <title>Chronopost</title>
182
- <sort_order>15</sort_order>
183
- <children>
184
- <export translate="title">
185
- <title>Export</title>
186
- <action>chronorelais/export</action>
187
- <sort_order>10</sort_order>
188
- </export>
189
- <import translate="title">
190
- <title>Import</title>
191
- <action>chronorelais/import</action>
192
- <sort_order>20</sort_order>
193
- </import>
194
- <impression translate="title" module="sales">
195
- <title>Impression des étiquettes</title>
196
- <action>chronorelais/sales_impression</action>
197
- <sort_order>30</sort_order>
198
- </impression>
199
- <bordereau translate="title" module="sales">
200
- <title>Bordereau de fin de journée</title>
201
- <action>chronorelais/sales_bordereau</action>
202
- <sort_order>40</sort_order>
203
- </bordereau>
204
- </children>
205
- </chronorelais>
206
- </children>
207
- </sales>
208
- </menu>
209
- <acl>
210
- <resources>
211
- <admin>
212
- <children>
213
- <sales>
214
- <children>
215
- <chronorelais translate="title">
216
- <title>Chronopost</title>
217
- <sort_order>15</sort_order>
218
- <children>
219
- <export translate="title">
220
- <title>Export</title>
221
- <sort_order>10</sort_order>
222
- </export>
223
- <import translate="title">
224
- <title>Import</title>
225
- <sort_order>20</sort_order>
226
- </import>
227
- <impression translate="title" module="sales">
228
- <title>Impression des étiquettes</title>
229
- <sort_order>30</sort_order>
230
- </impression>
231
- </children>
232
- </chronorelais>
233
- </children>
234
- </sales>
235
- <system>
236
- <children>
237
- <config>
238
- <children>
239
- <chronorelais translate="title" module="chronorelais">
240
- <title>Chronopost</title>
241
- <sort_order>100</sort_order>
242
- </chronorelais>
243
- </children>
244
- </config>
245
- </children>
246
- </system>
247
- </children>
248
- </admin>
249
- </resources>
250
- </acl>
251
-
252
- <translate>
253
- <modules>
254
- <Chronopost_Chronorelais>
255
- <files>
256
- <default>Chronopost_Chronorelais.csv</default>
257
- </files>
258
- </Chronopost_Chronorelais>
259
- </modules>
260
- </translate>
261
-
262
- </adminhtml>
263
-
264
- <default>
265
- <chronorelais>
266
- <shipping>
267
- <google_map_api>ABQIAAAAZvdukOwsytNocL5anZKqZxS51Nc8ngbKeRYi0kVLSLeRaqOKHRSLs6O150txpwWCDcct2mH4X-G6OA</google_map_api>
268
- <tracking_view_url><![CDATA[http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?lang=fr_FR&listeNumeros={tracking_number}]]>
269
- </tracking_view_url>
270
- <gs_path>/usr/bin/gs</gs_path>
271
- </shipping>
272
- <export_css>
273
- <file_extension>.chr</file_extension>
274
- <file_charset>ASCII-7</file_charset>
275
- <endofline_character>crlf</endofline_character>
276
- <field_delimiter>none</field_delimiter>
277
- <field_separator>;</field_separator>
278
- </export_css>
279
- <export_cso>
280
- <file_extension>.txt</file_extension>
281
- <file_charset>ISO-8859-1</file_charset>
282
- <endofline_character>crlf</endofline_character>
283
- <field_delimiter>none</field_delimiter>
284
- <field_separator>;</field_separator>
285
- </export_cso>
286
- <import>
287
- <default_tracking_title>Chronopost - Chronopost livraison express à domicile</default_tracking_title>
288
- <send_email>1</send_email>
289
- <shipping_comment></shipping_comment>
290
- <include_comment>0</include_comment>
291
- </import>
292
- </chronorelais>
293
- <carriers>
294
- <chronopost>
295
- <active>0</active>
296
- <title>Chronopost-Livraison express à domicile avant 13H</title>
297
- <model>Chronopost_Chronorelais_Model_Carrier_Chronopost</model>
298
- <tracking_view_url></tracking_view_url>
299
- <config>
300
- # Chronopost
301
- {
302
- label: "Chronopost-Livraison express à domicile avant 13H",
303
- code: "chronopost",
304
- description: "Colis livré le lendemain matin avant 13h à votre domicile. La veille de la livraison, vous êtes averti par e-mail et SMS.
305
- Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
306
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
307
- destination: "FR,MC",
308
- fees: "{table {cart.weight} in 2.00:17.56, 3.00:18.40, 4.00:19.24, 5.00:20.08, 6.00:20.92, 7.00:21.76, 8.00:22.60, 9.00:23.44, 10.00:24.28, 15.00:28.48, 20.00:32.68, 25.00:36.88, 30.00:41.08}",
309
- }
310
-
311
- # Chronopost Corse
312
- {
313
- label: "Chronopost livraison express à domicile en Corse",
314
- code: "chronopost_corse",
315
- description: "Colis livré le lendemain avant 13h, à l’adresse de votre choix.
316
- Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.
317
- En cas d’absence, le colis est mis en instance dans le bureau de Poste le plus proche.",
318
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
319
- destination: "FR(20*)",
320
- fees: "{table {cart.weight} in 2.00:19.56, 3.00:20.40, 4.00:21.24, 5.00:22.08, 6.00:22.92, 7.00:23.76, 8.00:24.60, 9.00:25.44, 10.00:26.28, 15.00:30.48, 20.00:34.68, 25.00:38.88, 30.00:43.08}",
321
- }
322
- </config>
323
- <weight_limit>30</weight_limit>
324
- <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
325
- <logo_url>chronopost.png</logo_url>
326
- <debug>0</debug>
327
- <stop_to_first_match>0</stop_to_first_match>
328
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
329
- <sort_order>1</sort_order>
330
- </chronopost>
331
- <chronoexpress>
332
- <active>0</active>
333
- <title>Chronopost Livraison express partout dans le monde</title>
334
- <model>Chronopost_Chronorelais_Model_Carrier_Chronoexpress</model>
335
- <tracking_view_url></tracking_view_url>
336
- <config>
337
- # Chronoexpress
338
- {
339
- label: "Chronopost Livraison express partout dans le monde",
340
- code: "chronoexpress",
341
- description: "Colis livré en 1 à 3 jours vers l'Europe, en 48h vers les DOM et en 2 à 5 jours vers le reste du monde.
342
- Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
343
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
344
- destination: "DE,BE,BG,CY,DK,ES,EE,FI,GR,IE,IT,LV,LT,MT,NL,PL,PT,CZ,RO,SK,AT,HU,LU,GB,SI,SE,GF,YT,GP,MQ,RE",
345
- fees: "{table {cart.weight} in 0.50:30.94, 1.00:45.07, 1.50:55.26, 2.00:65.45, 2.50:75.64, 3.00:85.83, 3.50:88.72, 4.00:91.61, 4.50:94.50, 5.00:97.39, 30.00:97.39}",
346
- }
347
- </config>
348
- <weight_limit>30</weight_limit>
349
- <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
350
- <logo_url>Logo-Chronopost.jpg</logo_url>
351
- <debug>0</debug>
352
- <stop_to_first_match>0</stop_to_first_match>
353
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
354
- <sort_order>1</sort_order>
355
- </chronoexpress>
356
- <chronorelais>
357
- <active>0</active>
358
- <title>Chrono Relais</title>
359
- <model>Chronopost_Chronorelais_Model_Carrier_Chronorelais</model>
360
- <tracking_view_url></tracking_view_url>
361
- <config>
362
- # Chronorelais
363
- {
364
- label: "Chrono Relais : livraison express en relais Pickup",
365
- code: "chronorelais",
366
- description: "Colis livré en Chronopost le lendemain avant 13 h dans le relais Pickup de votre choix.
367
- Vous êtes averti par email ou SMS de l’arrivée du colis dans le point.
368
- Délai à compter de la prise en charge du colis par Chronopost.",
369
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
370
- destination: "FR",
371
- fees: "{table {cart.weight} in 2.00:17.56, 3.00:18.40, 4.00:19.24, 5.00:20.08, 6.00:20.92, 7.00:21.76, 8.00:22.60, 9.00:23.44, 10.00:24.28, 15.00:28.48, 20.00:32.68, 25.00:36.88, 30.00:41.08}",
372
- }
373
-
374
- # Voir exemple sur mode "Chronopost" pour un tarif spécifique pour la Corse
375
- </config>
376
- <weight_limit>20</weight_limit>
377
- <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
378
- <logo_url>chronorelais.png</logo_url>
379
- <debug>0</debug>
380
- <stop_to_first_match>0</stop_to_first_match>
381
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
382
- <sort_order>2</sort_order>
383
- </chronorelais>
384
- <chronopostc10>
385
- <active>0</active>
386
- <title>Chronopost-Livraison express à domicile avant 10H</title>
387
- <model>Chronopost_Chronorelais_Model_Carrier_ChronopostC10</model>
388
- <tracking_view_url></tracking_view_url>
389
- <config>
390
- # ChronopostC10
391
- {
392
- label: "Chronopost-Livraison express à domicile avant 10H",
393
- code: "chronopostC10",
394
- description: "Colis livré le lendemain matin avant 10h à votre domicile. La veille de la livraison, vous êtes averti par e-mail et SMS.
395
- Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
396
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
397
- destination: "FR,MC",
398
- fees: "{table {cart.weight} in 2.00:17.56, 3.00:18.40, 4.00:19.24, 5.00:20.08, 6.00:20.92, 7.00:21.76, 8.00:22.60, 9.00:23.44, 10.00:24.28, 15.00:28.48, 20.00:32.68, 25.00:36.88, 30.00:41.08}",
399
- }
400
- </config>
401
- <weight_limit>30</weight_limit>
402
- <quickcost_url>http://wsshipping.chronopost.fr/wsQuickcost/services/ServiceQuickCost?wsdl</quickcost_url>
403
- <logo_url>chronopost.png</logo_url>
404
- <debug>0</debug>
405
- <stop_to_first_match>0</stop_to_first_match>
406
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
407
- <sort_order>3</sort_order>
408
- </chronopostc10>
409
- <chronopostc18>
410
- <active>0</active>
411
- <title>Chronopost-Livraison express à domicile avant 18H</title>
412
- <model>Chronopost_Chronorelais_Model_Carrier_ChronopostC18</model>
413
- <tracking_view_url></tracking_view_url>
414
- <config>
415
- # ChronopostC18
416
- {
417
- label: "Chronopost-Livraison express à domicile avant 18H",
418
- code: "chronopostC18",
419
- description: "Colis livré le lendemain matin avant 18h à votre domicile. La veille de la livraison, vous êtes averti par e-mail et SMS.
420
- Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
421
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
422
- destination: "FR,MC",
423
- fees: "{table {cart.weight} in 2.00:17.56, 3.00:18.40, 4.00:19.24, 5.00:20.08, 6.00:20.92, 7.00:21.76, 8.00:22.60, 9.00:23.44, 10.00:24.28, 15.00:28.48, 20.00:32.68, 25.00:36.88, 30.00:41.08}",
424
- }
425
- </config>
426
- <weight_limit>30</weight_limit>
427
- <quickcost>0</quickcost>
428
- <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
429
- <logo_url>chronopost.png</logo_url>
430
- <debug>0</debug>
431
- <stop_to_first_match>0</stop_to_first_match>
432
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
433
- <sort_order>4</sort_order>
434
- </chronopostc18>
435
- <chronopostcclassic>
436
- <active>0</active>
437
- <title>Chronopost Livraison dans certaines villes Européennes</title>
438
- <model>Chronopost_Chronorelais_Model_Carrier_ChronopostCClassic</model>
439
- <tracking_view_url></tracking_view_url>
440
- <config></config>
441
- <weight_limit>30</weight_limit>
442
- <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
443
- <logo_url>chronopost.png</logo_url>
444
- <debug>0</debug>
445
- <stop_to_first_match>0</stop_to_first_match>
446
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
447
- <sort_order>5</sort_order>
448
- </chronopostcclassic>
449
- </carriers>
450
- </default>
451
-
 
452
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Chronopost_Chronorelais>
5
+ <version>1.0.5</version>
6
+ <depends>
7
+ <Mage_Shipping />
8
+ <Mage_Sales />
9
+ <Mage_Adminhtml />
10
+ </depends>
11
+ </Chronopost_Chronorelais>
12
+ </modules>
13
+
14
+ <global>
15
+ <models>
16
+ <chronorelais>
17
+ <class>Chronopost_Chronorelais_Model</class>
18
+ </chronorelais>
19
+ <!--<sales>
20
+ <rewrite>
21
+ <quote_address_total_shipping>Chronopost_Chronorelais_Model_Sales_Quote_Address_Total_Shipping</quote_address_total_shipping>
22
+ </rewrite>
23
+ </sales>-->
24
+ </models>
25
+ <blocks>
26
+ <chronorelais>
27
+ <class>Chronopost_Chronorelais_Block</class>
28
+ </chronorelais>
29
+ <adminhtml>
30
+ <rewrite>
31
+ <sales_order_shipment_view>Chronopost_Chronorelais_Block_Sales_Order_Shipment_View</sales_order_shipment_view>
32
+ </rewrite>
33
+ </adminhtml>
34
+ </blocks>
35
+ <helpers>
36
+ <chronorelais>
37
+ <class>Chronopost_Chronorelais_Helper</class>
38
+ </chronorelais>
39
+ </helpers>
40
+
41
+ <resources>
42
+ <sales>
43
+ <shipping>
44
+ <carriers>
45
+ <chronorelais>
46
+ <class>Chronopost_Chronorelais_Model_Carrier_Chronorelais</class>
47
+ </chronorelais>
48
+ <chronopost>
49
+ <class>Chronopost_Chronorelais_Model_Carrier_Chronopost</class>
50
+ </chronopost>
51
+ <chronoexpress>
52
+ <class>Chronopost_Chronorelais_Model_Carrier_Chronoexpress</class>
53
+ </chronoexpress>
54
+ </carriers>
55
+ </shipping>
56
+ </sales>
57
+ <chronorelais_setup>
58
+ <setup>
59
+ <module>Chronopost_Chronorelais</module>
60
+ <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
61
+ </setup>
62
+ <connection>
63
+ <use>core_setup</use>
64
+ </connection>
65
+ </chronorelais_setup>
66
+ <chronorelais_write>
67
+ <connection>
68
+ <use>core_write</use>
69
+ </connection>
70
+ </chronorelais_write>
71
+
72
+ <chronorelais_read>
73
+ <connection>
74
+ <use>core_read</use>
75
+ </connection>
76
+ </chronorelais_read>
77
+ </resources>
78
+
79
+ <rewrite>
80
+ <chronopost_chronorelais_checkout_onepage>
81
+ <from><![CDATA[#^/checkout/onepage/#]]>
82
+ </from>
83
+ <to>/chronorelais/checkout_onepage/</to>
84
+ </chronopost_chronorelais_checkout_onepage>
85
+ <chronopost_chronorelais_checkout_multishipping>
86
+ <from><![CDATA[#^/checkout/multishipping/#]]>
87
+ </from>
88
+ <to>/chronorelais/checkout_multishipping/</to>
89
+ </chronopost_chronorelais_checkout_multishipping>
90
+ <chronopost_chronorelais_sales_order_shipment>
91
+ <from><![CDATA[#^/.*sales_order_shipment/save/#]]>
92
+ </from>
93
+ <to>/chronorelais/sales_order_shipment/save/</to>
94
+ </chronopost_chronorelais_sales_order_shipment>
95
+ </rewrite>
96
+
97
+ <fieldsets>
98
+ <sales_copy_order_billing_address>
99
+ <w_relay_point_code>
100
+ <to_order>*</to_order>
101
+ </w_relay_point_code>
102
+ </sales_copy_order_billing_address>
103
+ <sales_copy_order_shipping_address>
104
+ <w_relay_point_code>
105
+ <to_order>*</to_order>
106
+ </w_relay_point_code>
107
+ </sales_copy_order_shipping_address>
108
+ <sales_convert_quote_address>
109
+ <w_relay_point_code>
110
+ <to_order_address>*</to_order_address>
111
+ <to_customer_address>*</to_customer_address>
112
+ </w_relay_point_code>
113
+ </sales_convert_quote_address>
114
+ <sales_convert_order_address>
115
+ <w_relay_point_code>
116
+ <to_quote_address>*</to_quote_address>
117
+ </w_relay_point_code>
118
+ </sales_convert_order_address>
119
+ <customer_address>
120
+ <w_relay_point_code>
121
+ <to_quote_address>*</to_quote_address>
122
+ </w_relay_point_code>
123
+ </customer_address>
124
+ </fieldsets>
125
+
126
+ </global>
127
+
128
+ <frontend>
129
+ <routers>
130
+ <chronorelais>
131
+ <use>standard</use>
132
+ <args>
133
+ <module>Chronopost_Chronorelais</module>
134
+ <frontName>chronorelais</frontName>
135
+ </args>
136
+ </chronorelais>
137
+ </routers>
138
+
139
+ <layout>
140
+ <updates>
141
+ <chronorelais>
142
+ <file>chronorelais.xml</file>
143
+ </chronorelais>
144
+ </updates>
145
+ </layout>
146
+ <translate>
147
+ <modules>
148
+ <Chronopost_Chronorelais>
149
+ <files>
150
+ <default>Chronopost_Chronorelais.csv</default>
151
+ </files>
152
+ </Chronopost_Chronorelais>
153
+ </modules>
154
+ </translate>
155
+ </frontend>
156
+
157
+ <admin>
158
+ <routers>
159
+ <chronorelais>
160
+ <use>admin</use>
161
+ <args>
162
+ <module>Chronopost_Chronorelais</module>
163
+ <frontName>chronorelais</frontName>
164
+ </args>
165
+ </chronorelais>
166
+ </routers>
167
+ </admin>
168
+
169
+ <adminhtml>
170
+ <layout>
171
+ <updates>
172
+ <chronorelais>
173
+ <file>chronorelais.xml</file>
174
+ </chronorelais>
175
+ </updates>
176
+ </layout>
177
+ <menu>
178
+ <sales>
179
+ <children>
180
+ <chronorelais translate="title"> <!-- TODO faire marcher : module="chronorelais" (aussi dans les children) -->
181
+ <title>Chronopost</title>
182
+ <sort_order>15</sort_order>
183
+ <children>
184
+ <export translate="title">
185
+ <title>Export</title>
186
+ <action>chronorelais/export</action>
187
+ <sort_order>10</sort_order>
188
+ </export>
189
+ <import translate="title">
190
+ <title>Import</title>
191
+ <action>chronorelais/import</action>
192
+ <sort_order>20</sort_order>
193
+ </import>
194
+ <impression translate="title" module="sales">
195
+ <title>Impression des étiquettes</title>
196
+ <action>chronorelais/sales_impression</action>
197
+ <sort_order>30</sort_order>
198
+ </impression>
199
+ <bordereau translate="title" module="sales">
200
+ <title>Bordereau de fin de journée</title>
201
+ <action>chronorelais/sales_bordereau</action>
202
+ <sort_order>40</sort_order>
203
+ </bordereau>
204
+ </children>
205
+ </chronorelais>
206
+ </children>
207
+ </sales>
208
+ </menu>
209
+ <acl>
210
+ <resources>
211
+ <admin>
212
+ <children>
213
+ <sales>
214
+ <children>
215
+ <chronorelais translate="title">
216
+ <title>Chronopost</title>
217
+ <sort_order>15</sort_order>
218
+ <children>
219
+ <export translate="title">
220
+ <title>Export</title>
221
+ <sort_order>10</sort_order>
222
+ </export>
223
+ <import translate="title">
224
+ <title>Import</title>
225
+ <sort_order>20</sort_order>
226
+ </import>
227
+ <impression translate="title" module="sales">
228
+ <title>Impression des étiquettes</title>
229
+ <sort_order>30</sort_order>
230
+ </impression>
231
+ </children>
232
+ </chronorelais>
233
+ </children>
234
+ </sales>
235
+ <system>
236
+ <children>
237
+ <config>
238
+ <children>
239
+ <chronorelais translate="title" module="chronorelais">
240
+ <title>Chronopost</title>
241
+ <sort_order>100</sort_order>
242
+ </chronorelais>
243
+ </children>
244
+ </config>
245
+ </children>
246
+ </system>
247
+ </children>
248
+ </admin>
249
+ </resources>
250
+ </acl>
251
+
252
+ <translate>
253
+ <modules>
254
+ <Chronopost_Chronorelais>
255
+ <files>
256
+ <default>Chronopost_Chronorelais.csv</default>
257
+ </files>
258
+ </Chronopost_Chronorelais>
259
+ </modules>
260
+ </translate>
261
+
262
+ </adminhtml>
263
+
264
+ <default>
265
+ <chronorelais>
266
+ <shipping>
267
+ <google_map_api></google_map_api>
268
+ <tracking_view_url><![CDATA[http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?lang=fr_FR&listeNumeros={tracking_number}]]>
269
+ </tracking_view_url>
270
+ <gs_path>/usr/bin/gs</gs_path>
271
+ </shipping>
272
+ <export_css>
273
+ <file_extension>.chr</file_extension>
274
+ <file_charset>ASCII-7</file_charset>
275
+ <endofline_character>crlf</endofline_character>
276
+ <field_delimiter>none</field_delimiter>
277
+ <field_separator>;</field_separator>
278
+ </export_css>
279
+ <export_cso>
280
+ <file_extension>.txt</file_extension>
281
+ <file_charset>ISO-8859-1</file_charset>
282
+ <endofline_character>crlf</endofline_character>
283
+ <field_delimiter>none</field_delimiter>
284
+ <field_separator>;</field_separator>
285
+ </export_cso>
286
+ <import>
287
+ <default_tracking_title>Chronopost - Chronopost livraison express à domicile</default_tracking_title>
288
+ <send_email>1</send_email>
289
+ <shipping_comment></shipping_comment>
290
+ <include_comment>0</include_comment>
291
+ </import>
292
+ </chronorelais>
293
+ <carriers>
294
+ <chronopost>
295
+ <active>0</active>
296
+ <title>Chronopost-Livraison express à domicile avant 13H</title>
297
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronopost</model>
298
+ <tracking_view_url></tracking_view_url>
299
+ <config>
300
+ # Chronopost
301
+ {
302
+ label: "Chronopost-Livraison express à domicile avant 13H",
303
+ code: "chronopost",
304
+ description: "Colis livré le lendemain matin avant 13h à votre domicile. La veille de la livraison, vous êtes averti par e-mail et SMS.
305
+ Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
306
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
307
+ destination: "FR,MC",
308
+ fees: "{table {cart.weight} in 2.00:17.56, 3.00:18.40, 4.00:19.24, 5.00:20.08, 6.00:20.92, 7.00:21.76, 8.00:22.60, 9.00:23.44, 10.00:24.28, 15.00:28.48, 20.00:32.68, 25.00:36.88, 30.00:41.08}",
309
+ }
310
+
311
+ # Chronopost Corse
312
+ {
313
+ label: "Chronopost livraison express à domicile en Corse",
314
+ code: "chronopost_corse",
315
+ description: "Colis livré le lendemain avant 13h, à l’adresse de votre choix.
316
+ Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.
317
+ En cas d’absence, le colis est mis en instance dans le bureau de Poste le plus proche.",
318
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
319
+ destination: "FR(20*)",
320
+ fees: "{table {cart.weight} in 2.00:19.56, 3.00:20.40, 4.00:21.24, 5.00:22.08, 6.00:22.92, 7.00:23.76, 8.00:24.60, 9.00:25.44, 10.00:26.28, 15.00:30.48, 20.00:34.68, 25.00:38.88, 30.00:43.08}",
321
+ }
322
+ </config>
323
+ <weight_limit>30</weight_limit>
324
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
325
+ <logo_url>chronopost.png</logo_url>
326
+ <debug>0</debug>
327
+ <stop_to_first_match>0</stop_to_first_match>
328
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
329
+ <sort_order>1</sort_order>
330
+ </chronopost>
331
+ <chronoexpress>
332
+ <active>0</active>
333
+ <title>Chronopost Livraison express partout dans le monde</title>
334
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronoexpress</model>
335
+ <tracking_view_url></tracking_view_url>
336
+ <config>
337
+ # Chronoexpress
338
+ {
339
+ label: "Chronopost Livraison express partout dans le monde",
340
+ code: "chronoexpress",
341
+ description: "Colis livré en 1 à 3 jours vers l'Europe, en 48h vers les DOM et en 2 à 5 jours vers le reste du monde.
342
+ Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
343
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
344
+ destination: "DE,BE,BG,CY,DK,ES,EE,FI,GR,IE,IT,LV,LT,MT,NL,PL,PT,CZ,RO,SK,AT,HU,LU,GB,SI,SE,GF,YT,GP,MQ,RE",
345
+ fees: "{table {cart.weight} in 0.50:30.94, 1.00:45.07, 1.50:55.26, 2.00:65.45, 2.50:75.64, 3.00:85.83, 3.50:88.72, 4.00:91.61, 4.50:94.50, 5.00:97.39, 30.00:97.39}",
346
+ }
347
+ </config>
348
+ <weight_limit>30</weight_limit>
349
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
350
+ <logo_url>Logo-Chronopost.jpg</logo_url>
351
+ <debug>0</debug>
352
+ <stop_to_first_match>0</stop_to_first_match>
353
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
354
+ <sort_order>1</sort_order>
355
+ </chronoexpress>
356
+ <chronorelais>
357
+ <active>0</active>
358
+ <title>Chrono Relais</title>
359
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronorelais</model>
360
+ <tracking_view_url></tracking_view_url>
361
+ <config>
362
+ # Chronorelais
363
+ {
364
+ label: "Chrono Relais : livraison express en relais Pickup",
365
+ code: "chronorelais",
366
+ description: "Colis livré en Chronopost le lendemain avant 13 h dans le relais Pickup de votre choix.
367
+ Vous êtes averti par email ou SMS de l’arrivée du colis dans le point.
368
+ Délai à compter de la prise en charge du colis par Chronopost.",
369
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
370
+ destination: "FR",
371
+ fees: "{table {cart.weight} in 2.00:17.56, 3.00:18.40, 4.00:19.24, 5.00:20.08, 6.00:20.92, 7.00:21.76, 8.00:22.60, 9.00:23.44, 10.00:24.28, 15.00:28.48, 20.00:32.68, 25.00:36.88, 30.00:41.08}",
372
+ }
373
+
374
+ # Voir exemple sur mode "Chronopost" pour un tarif spécifique pour la Corse
375
+ </config>
376
+ <weight_limit>20</weight_limit>
377
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
378
+ <show_google_map>1</show_google_map>
379
+ <logo_url>chronorelais.png</logo_url>
380
+ <debug>0</debug>
381
+ <stop_to_first_match>0</stop_to_first_match>
382
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
383
+ <sort_order>2</sort_order>
384
+ </chronorelais>
385
+ <chronopostc10>
386
+ <active>0</active>
387
+ <title>Chronopost-Livraison express à domicile avant 10H</title>
388
+ <model>Chronopost_Chronorelais_Model_Carrier_ChronopostC10</model>
389
+ <tracking_view_url></tracking_view_url>
390
+ <config>
391
+ # ChronopostC10
392
+ {
393
+ label: "Chronopost-Livraison express à domicile avant 10H",
394
+ code: "chronopostC10",
395
+ description: "Colis livré le lendemain matin avant 10h à votre domicile. La veille de la livraison, vous êtes averti par e-mail et SMS.
396
+ Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
397
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
398
+ destination: "FR,MC",
399
+ fees: "{table {cart.weight} in 2.00:17.56, 3.00:18.40, 4.00:19.24, 5.00:20.08, 6.00:20.92, 7.00:21.76, 8.00:22.60, 9.00:23.44, 10.00:24.28, 15.00:28.48, 20.00:32.68, 25.00:36.88, 30.00:41.08}",
400
+ }
401
+ </config>
402
+ <weight_limit>30</weight_limit>
403
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
404
+ <logo_url>chronopost.png</logo_url>
405
+ <debug>0</debug>
406
+ <stop_to_first_match>0</stop_to_first_match>
407
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
408
+ <sort_order>3</sort_order>
409
+ </chronopostc10>
410
+ <chronopostc18>
411
+ <active>0</active>
412
+ <title>Chronopost-Livraison express à domicile avant 18H</title>
413
+ <model>Chronopost_Chronorelais_Model_Carrier_ChronopostC18</model>
414
+ <tracking_view_url></tracking_view_url>
415
+ <config>
416
+ # ChronopostC18
417
+ {
418
+ label: "Chronopost-Livraison express à domicile avant 18H",
419
+ code: "chronopostC18",
420
+ description: "Colis livré le lendemain matin avant 18h à votre domicile. La veille de la livraison, vous êtes averti par e-mail et SMS.
421
+ Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
422
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
423
+ destination: "FR,MC",
424
+ fees: "{table {cart.weight} in 2.00:17.56, 3.00:18.40, 4.00:19.24, 5.00:20.08, 6.00:20.92, 7.00:21.76, 8.00:22.60, 9.00:23.44, 10.00:24.28, 15.00:28.48, 20.00:32.68, 25.00:36.88, 30.00:41.08}",
425
+ }
426
+ </config>
427
+ <weight_limit>30</weight_limit>
428
+ <quickcost>0</quickcost>
429
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
430
+ <logo_url>chronopost.png</logo_url>
431
+ <debug>0</debug>
432
+ <stop_to_first_match>0</stop_to_first_match>
433
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
434
+ <sort_order>4</sort_order>
435
+ </chronopostc18>
436
+ <chronopostcclassic>
437
+ <active>0</active>
438
+ <title>Chronopost Livraison dans certaines villes Européennes</title>
439
+ <model>Chronopost_Chronorelais_Model_Carrier_ChronopostCClassic</model>
440
+ <tracking_view_url></tracking_view_url>
441
+ <config></config>
442
+ <weight_limit>30</weight_limit>
443
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
444
+ <logo_url>chronopost.png</logo_url>
445
+ <debug>0</debug>
446
+ <stop_to_first_match>0</stop_to_first_match>
447
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
448
+ <sort_order>5</sort_order>
449
+ </chronopostcclassic>
450
+ </carriers>
451
+ </default>
452
+
453
  </config>
app/code/community/Chronopost/Chronorelais/etc/system.xml CHANGED
@@ -1,1546 +1,1583 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <tabs>
4
- <chronopost translate="label" module="chronorelais">
5
- <label>Chronopost</label>
6
- <sort_order>200</sort_order>
7
- </chronopost>
8
- </tabs>
9
- <sections>
10
- <carriers>
11
- <groups>
12
- <chronopost translate="label">
13
- <label>Chronopost</label>
14
- <frontend_type>text</frontend_type>
15
- <sort_order>20</sort_order>
16
- <show_in_default>1</show_in_default>
17
- <show_in_website>1</show_in_website>
18
- <show_in_store>1</show_in_store>
19
- <fields>
20
- <active translate="label">
21
- <label>Enabled</label>
22
- <frontend_type>select</frontend_type>
23
- <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
24
- <source_model>adminhtml/system_config_source_yesno</source_model>
25
- <sort_order>1</sort_order>
26
- <show_in_default>1</show_in_default>
27
- <show_in_website>1</show_in_website>
28
- <show_in_store>1</show_in_store>
29
- </active>
30
- <title translate="label">
31
- <label>Title</label>
32
- <frontend_type>text</frontend_type>
33
- <sort_order>2</sort_order>
34
- <show_in_default>1</show_in_default>
35
- <show_in_website>1</show_in_website>
36
- <show_in_store>1</show_in_store>
37
- </title>
38
- <config translate="label">
39
- <label>Configuration</label>
40
- <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
41
- <comment>{configuration_syntax_help}</comment>
42
- <frontend_type>textarea</frontend_type>
43
- <sort_order>3</sort_order>
44
- <show_in_default>1</show_in_default>
45
- <show_in_website>1</show_in_website>
46
- <show_in_store>1</show_in_store>
47
- </config>
48
- <weight_limit translate="label">
49
- <label>Weight Limit</label>
50
- <frontend_type>text</frontend_type>
51
- <comment>in Kg</comment>
52
- <sort_order>7</sort_order>
53
- <show_in_default>1</show_in_default>
54
- <show_in_website>1</show_in_website>
55
- <show_in_store>1</show_in_store>
56
- </weight_limit>
57
- <quickcost translate="label">
58
- <label>Quickcost</label>
59
- <frontend_type>select</frontend_type>
60
- <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
61
- <source_model>adminhtml/system_config_source_yesno</source_model>
62
- <sort_order>10</sort_order>
63
- <show_in_default>1</show_in_default>
64
- <show_in_website>1</show_in_website>
65
- <show_in_store>0</show_in_store>
66
- </quickcost>
67
- <quickcost_url>
68
- <label>Quickcost Url</label>
69
- <frontend_type>text</frontend_type>
70
- <sort_order>11</sort_order>
71
- <show_in_default>1</show_in_default>
72
- <show_in_website>1</show_in_website>
73
- <show_in_store>0</show_in_store>
74
- </quickcost_url>
75
- <free_shipping_enable translate="label">
76
- <label>Free Shipping on the Amount</label>
77
- <frontend_type>select</frontend_type>
78
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
79
- <sort_order>12</sort_order>
80
- <show_in_default>1</show_in_default>
81
- <show_in_website>1</show_in_website>
82
- <show_in_store>1</show_in_store>
83
- </free_shipping_enable>
84
- <free_shipping_subtotal translate="label">
85
- <label>Minimum Amount for Free Shipping</label>
86
- <frontend_type>text</frontend_type>
87
- <sort_order>13</sort_order>
88
- <show_in_default>1</show_in_default>
89
- <show_in_website>1</show_in_website>
90
- <show_in_store>0</show_in_store>
91
- </free_shipping_subtotal>
92
- <application_fee translate="label">
93
- <label>Application Fee</label>
94
- <frontend_type>text</frontend_type>
95
- <sort_order>14</sort_order>
96
- <show_in_default>1</show_in_default>
97
- <show_in_website>1</show_in_website>
98
- <show_in_store>1</show_in_store>
99
- </application_fee>
100
- <handling_fee translate="label">
101
- <label>Handling Fee</label>
102
- <frontend_type>text</frontend_type>
103
- <sort_order>15</sort_order>
104
- <show_in_default>1</show_in_default>
105
- <show_in_website>1</show_in_website>
106
- <show_in_store>1</show_in_store>
107
- </handling_fee>
108
- <logo_url>
109
- <label>Logo Url</label>
110
- <frontend_type>text</frontend_type>
111
- <comment>{logo_ulr_help}</comment>
112
- <sort_order>18</sort_order>
113
- <show_in_default>1</show_in_default>
114
- <show_in_website>1</show_in_website>
115
- <show_in_store>1</show_in_store>
116
- </logo_url>
117
- <debug>
118
- <label>Debug</label>
119
- <comment>{debug_help}</comment>
120
- <frontend_type>text</frontend_type>
121
- <sort_order>20</sort_order>
122
- <show_in_default>1</show_in_default>
123
- <show_in_website>1</show_in_website>
124
- <show_in_store>1</show_in_store>
125
- </debug>
126
- <!--<stop_to_first_match translate="label">
127
- <label>Stop to first match</label>
128
- <frontend_type>select</frontend_type>
129
- <source_model>adminhtml/system_config_source_yesno</source_model>
130
- <sort_order>22</sort_order>
131
- <show_in_default>1</show_in_default>
132
- <show_in_website>1</show_in_website>
133
- <show_in_store>1</show_in_store>
134
- </stop_to_first_match>-->
135
- <deliver_on_saturday translate="label comment">
136
- <label>Livraison le Samedi</label>
137
- <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
138
- <frontend_type>select</frontend_type>
139
- <source_model>adminhtml/system_config_source_yesno</source_model>
140
- <sort_order>23</sort_order>
141
- <show_in_default>1</show_in_default>
142
- <show_in_website>1</show_in_website>
143
- <show_in_store>1</show_in_store>
144
- </deliver_on_saturday>
145
- <!--<showmethod translate="label">
146
- <label>Show Method if Not Applicable</label>
147
- <frontend_type>select</frontend_type>
148
- <sort_order>30</sort_order>
149
- <frontend_class>shipping-skip-hide</frontend_class>
150
- <source_model>adminhtml/system_config_source_yesno</source_model>
151
- <show_in_default>1</show_in_default>
152
- <show_in_website>1</show_in_website>
153
- <show_in_store>0</show_in_store>
154
- </showmethod>
155
- <specificerrmsg translate="label">
156
- <label>Displayed Error Message</label>
157
- <frontend_type>textarea</frontend_type>
158
- <sort_order>31</sort_order>
159
- <show_in_default>1</show_in_default>
160
- <show_in_website>1</show_in_website>
161
- <show_in_store>1</show_in_store>
162
- </specificerrmsg>-->
163
- <sort_order translate="label">
164
- <label>Sort order</label>
165
- <frontend_type>text</frontend_type>
166
- <sort_order>100</sort_order>
167
- <show_in_default>1</show_in_default>
168
- <show_in_website>1</show_in_website>
169
- <show_in_store>1</show_in_store>
170
- </sort_order>
171
- </fields>
172
- </chronopost>
173
-
174
- <chronoexpress translate="label">
175
- <label>Chrono Express</label>
176
- <frontend_type>text</frontend_type>
177
- <sort_order>21</sort_order>
178
- <show_in_default>1</show_in_default>
179
- <show_in_website>1</show_in_website>
180
- <show_in_store>1</show_in_store>
181
- <fields>
182
- <active translate="label">
183
- <label>Enabled</label>
184
- <frontend_type>select</frontend_type>
185
- <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
186
- <source_model>adminhtml/system_config_source_yesno</source_model>
187
- <sort_order>1</sort_order>
188
- <show_in_default>1</show_in_default>
189
- <show_in_website>1</show_in_website>
190
- <show_in_store>1</show_in_store>
191
- </active>
192
- <title translate="label">
193
- <label>Title</label>
194
- <frontend_type>text</frontend_type>
195
- <sort_order>2</sort_order>
196
- <show_in_default>1</show_in_default>
197
- <show_in_website>1</show_in_website>
198
- <show_in_store>1</show_in_store>
199
- </title>
200
- <config translate="label">
201
- <label>Configuration</label>
202
- <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
203
- <comment>{configuration_syntax_help}</comment>
204
- <frontend_type>textarea</frontend_type>
205
- <sort_order>3</sort_order>
206
- <show_in_default>1</show_in_default>
207
- <show_in_website>1</show_in_website>
208
- <show_in_store>1</show_in_store>
209
- </config>
210
- <weight_limit translate="label">
211
- <label>Weight Limit</label>
212
- <frontend_type>text</frontend_type>
213
- <comment>in Kg</comment>
214
- <sort_order>7</sort_order>
215
- <show_in_default>1</show_in_default>
216
- <show_in_website>1</show_in_website>
217
- <show_in_store>1</show_in_store>
218
- </weight_limit>
219
- <quickcost translate="label">
220
- <label>Quickcost</label>
221
- <frontend_type>select</frontend_type>
222
- <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
223
- <source_model>adminhtml/system_config_source_yesno</source_model>
224
- <sort_order>10</sort_order>
225
- <show_in_default>1</show_in_default>
226
- <show_in_website>1</show_in_website>
227
- <show_in_store>0</show_in_store>
228
- </quickcost>
229
- <quickcost_url>
230
- <label>Quickcost Url</label>
231
- <frontend_type>text</frontend_type>
232
- <sort_order>11</sort_order>
233
- <show_in_default>1</show_in_default>
234
- <show_in_website>1</show_in_website>
235
- <show_in_store>0</show_in_store>
236
- </quickcost_url>
237
- <free_shipping_enable translate="label">
238
- <label>Free Shipping on the Amount</label>
239
- <frontend_type>select</frontend_type>
240
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
241
- <sort_order>12</sort_order>
242
- <show_in_default>1</show_in_default>
243
- <show_in_website>1</show_in_website>
244
- <show_in_store>1</show_in_store>
245
- </free_shipping_enable>
246
- <free_shipping_subtotal translate="label">
247
- <label>Minimum Amount for Free Shipping</label>
248
- <frontend_type>text</frontend_type>
249
- <sort_order>13</sort_order>
250
- <show_in_default>1</show_in_default>
251
- <show_in_website>1</show_in_website>
252
- <show_in_store>0</show_in_store>
253
- </free_shipping_subtotal>
254
- <application_fee translate="label">
255
- <label>Application Fee</label>
256
- <frontend_type>text</frontend_type>
257
- <sort_order>14</sort_order>
258
- <show_in_default>1</show_in_default>
259
- <show_in_website>1</show_in_website>
260
- <show_in_store>1</show_in_store>
261
- </application_fee>
262
- <handling_fee translate="label">
263
- <label>Handling Fee</label>
264
- <frontend_type>text</frontend_type>
265
- <sort_order>15</sort_order>
266
- <show_in_default>1</show_in_default>
267
- <show_in_website>1</show_in_website>
268
- <show_in_store>1</show_in_store>
269
- </handling_fee>
270
- <logo_url>
271
- <label>Logo Url</label>
272
- <frontend_type>text</frontend_type>
273
- <comment>{logo_ulr_help}</comment>
274
- <sort_order>18</sort_order>
275
- <show_in_default>1</show_in_default>
276
- <show_in_website>1</show_in_website>
277
- <show_in_store>1</show_in_store>
278
- </logo_url>
279
- <debug>
280
- <label>Debug</label>
281
- <comment>{debug_help}</comment>
282
- <frontend_type>text</frontend_type>
283
- <sort_order>20</sort_order>
284
- <show_in_default>1</show_in_default>
285
- <show_in_website>1</show_in_website>
286
- <show_in_store>1</show_in_store>
287
- </debug>
288
- <!--<stop_to_first_match translate="label">
289
- <label>Stop to first match</label>
290
- <frontend_type>select</frontend_type>
291
- <source_model>adminhtml/system_config_source_yesno</source_model>
292
- <sort_order>22</sort_order>
293
- <show_in_default>1</show_in_default>
294
- <show_in_website>1</show_in_website>
295
- <show_in_store>1</show_in_store>
296
- </stop_to_first_match>-->
297
- <!-- deliver_on_saturday not included in chronoexpress only -->
298
- <!--<showmethod translate="label">
299
- <label>Show Method if Not Applicable</label>
300
- <frontend_type>select</frontend_type>
301
- <sort_order>30</sort_order>
302
- <frontend_class>shipping-skip-hide</frontend_class>
303
- <source_model>adminhtml/system_config_source_yesno</source_model>
304
- <show_in_default>1</show_in_default>
305
- <show_in_website>1</show_in_website>
306
- <show_in_store>0</show_in_store>
307
- </showmethod>
308
- <specificerrmsg translate="label">
309
- <label>Displayed Error Message</label>
310
- <frontend_type>textarea</frontend_type>
311
- <sort_order>31</sort_order>
312
- <show_in_default>1</show_in_default>
313
- <show_in_website>1</show_in_website>
314
- <show_in_store>1</show_in_store>
315
- </specificerrmsg>-->
316
- <sort_order translate="label">
317
- <label>Sort order</label>
318
- <frontend_type>text</frontend_type>
319
- <sort_order>100</sort_order>
320
- <show_in_default>1</show_in_default>
321
- <show_in_website>1</show_in_website>
322
- <show_in_store>1</show_in_store>
323
- </sort_order>
324
- </fields>
325
- </chronoexpress>
326
-
327
- <chronorelais translate="label">
328
- <label>Chrono Relais</label>
329
- <frontend_type>text</frontend_type>
330
- <sort_order>22</sort_order>
331
- <show_in_default>1</show_in_default>
332
- <show_in_website>1</show_in_website>
333
- <show_in_store>1</show_in_store>
334
- <fields>
335
- <active translate="label">
336
- <label>Enabled</label>
337
- <frontend_type>select</frontend_type>
338
- <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
339
- <source_model>adminhtml/system_config_source_yesno</source_model>
340
- <sort_order>1</sort_order>
341
- <show_in_default>1</show_in_default>
342
- <show_in_website>1</show_in_website>
343
- <show_in_store>1</show_in_store>
344
- </active>
345
- <title translate="label">
346
- <label>Title</label>
347
- <frontend_type>text</frontend_type>
348
- <sort_order>2</sort_order>
349
- <show_in_default>1</show_in_default>
350
- <show_in_website>1</show_in_website>
351
- <show_in_store>1</show_in_store>
352
- </title>
353
- <config translate="label">
354
- <label>Configuration</label>
355
- <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
356
- <comment>{configuration_syntax_help}</comment>
357
- <frontend_type>textarea</frontend_type>
358
- <sort_order>3</sort_order>
359
- <show_in_default>1</show_in_default>
360
- <show_in_website>1</show_in_website>
361
- <show_in_store>1</show_in_store>
362
- </config>
363
- <weight_limit translate="label">
364
- <label>Weight Limit</label>
365
- <frontend_type>text</frontend_type>
366
- <comment>in Kg</comment>
367
- <sort_order>7</sort_order>
368
- <show_in_default>1</show_in_default>
369
- <show_in_website>1</show_in_website>
370
- <show_in_store>1</show_in_store>
371
- </weight_limit>
372
- <quickcost translate="label">
373
- <label>Quickcost</label>
374
- <frontend_type>select</frontend_type>
375
- <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
376
- <source_model>adminhtml/system_config_source_yesno</source_model>
377
- <sort_order>10</sort_order>
378
- <show_in_default>1</show_in_default>
379
- <show_in_website>1</show_in_website>
380
- <show_in_store>0</show_in_store>
381
- </quickcost>
382
- <quickcost_url>
383
- <label>Quickcost Url</label>
384
- <frontend_type>text</frontend_type>
385
- <sort_order>11</sort_order>
386
- <show_in_default>1</show_in_default>
387
- <show_in_website>1</show_in_website>
388
- <show_in_store>0</show_in_store>
389
- </quickcost_url>
390
- <free_shipping_enable translate="label">
391
- <label>Free Shipping with Minimum Order Amount</label>
392
- <frontend_type>select</frontend_type>
393
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
394
- <sort_order>12</sort_order>
395
- <show_in_default>1</show_in_default>
396
- <show_in_website>1</show_in_website>
397
- <show_in_store>1</show_in_store>
398
- </free_shipping_enable>
399
- <free_shipping_subtotal translate="label">
400
- <label>Minimum Order Amount for Free Shipping</label>
401
- <frontend_type>text</frontend_type>
402
- <sort_order>13</sort_order>
403
- <show_in_default>1</show_in_default>
404
- <show_in_website>1</show_in_website>
405
- <show_in_store>1</show_in_store>
406
- </free_shipping_subtotal>
407
- <application_fee translate="label">
408
- <label>Application Fee</label>
409
- <frontend_type>text</frontend_type>
410
- <sort_order>14</sort_order>
411
- <show_in_default>1</show_in_default>
412
- <show_in_website>1</show_in_website>
413
- <show_in_store>1</show_in_store>
414
- </application_fee>
415
- <handling_fee translate="label">
416
- <label>Handling Fee</label>
417
- <frontend_type>text</frontend_type>
418
- <sort_order>15</sort_order>
419
- <show_in_default>1</show_in_default>
420
- <show_in_website>1</show_in_website>
421
- <show_in_store>1</show_in_store>
422
- </handling_fee>
423
- <logo_url>
424
- <label>Logo Url</label>
425
- <frontend_type>text</frontend_type>
426
- <comment>{logo_ulr_help}</comment>
427
- <sort_order>18</sort_order>
428
- <show_in_default>1</show_in_default>
429
- <show_in_website>1</show_in_website>
430
- <show_in_store>1</show_in_store>
431
- </logo_url>
432
- <debug>
433
- <label>Debug</label>
434
- <comment>{debug_help}</comment>
435
- <frontend_type>text</frontend_type>
436
- <sort_order>20</sort_order>
437
- <show_in_default>1</show_in_default>
438
- <show_in_website>1</show_in_website>
439
- <show_in_store>1</show_in_store>
440
- </debug>
441
- <!--<stop_to_first_match translate="label">
442
- <label>Stop to first match</label>
443
- <frontend_type>select</frontend_type>
444
- <source_model>adminhtml/system_config_source_yesno</source_model>
445
- <sort_order>22</sort_order>
446
- <show_in_default>1</show_in_default>
447
- <show_in_website>1</show_in_website>
448
- <show_in_store>1</show_in_store>
449
- </stop_to_first_match>-->
450
- <deliver_on_saturday translate="label comment">
451
- <label>Livraison le Samedi</label>
452
- <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
453
- <frontend_type>select</frontend_type>
454
- <source_model>adminhtml/system_config_source_yesno</source_model>
455
- <sort_order>23</sort_order>
456
- <show_in_default>1</show_in_default>
457
- <show_in_website>1</show_in_website>
458
- <show_in_store>1</show_in_store>
459
- </deliver_on_saturday>
460
- <!--<showmethod translate="label">
461
- <label>Show Method if Not Applicable</label>
462
- <frontend_type>select</frontend_type>
463
- <sort_order>30</sort_order>
464
- <frontend_class>shipping-skip-hide</frontend_class>
465
- <source_model>adminhtml/system_config_source_yesno</source_model>
466
- <show_in_default>1</show_in_default>
467
- <show_in_website>1</show_in_website>
468
- <show_in_store>0</show_in_store>
469
- </showmethod>
470
- <specificerrmsg translate="label">
471
- <label>Displayed Error Message</label>
472
- <frontend_type>textarea</frontend_type>
473
- <sort_order>31</sort_order>
474
- <show_in_default>1</show_in_default>
475
- <show_in_website>1</show_in_website>
476
- <show_in_store>1</show_in_store>
477
- </specificerrmsg>-->
478
- <sort_order translate="label">
479
- <label>Sort order</label>
480
- <frontend_type>text</frontend_type>
481
- <sort_order>100</sort_order>
482
- <show_in_default>1</show_in_default>
483
- <show_in_website>1</show_in_website>
484
- <show_in_store>1</show_in_store>
485
- </sort_order>
486
- </fields>
487
- </chronorelais>
488
-
489
- <!-- C10 Livraison avant 10H -->
490
- <chronopostc10 translate="label">
491
- <label>Chronopost C10</label>
492
- <frontend_type>text</frontend_type>
493
- <sort_order>23</sort_order>
494
- <show_in_default>1</show_in_default>
495
- <show_in_website>1</show_in_website>
496
- <show_in_store>1</show_in_store>
497
- <fields>
498
- <active translate="label">
499
- <label>Enabled</label>
500
- <frontend_type>select</frontend_type>
501
- <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
502
- <source_model>adminhtml/system_config_source_yesno</source_model>
503
- <sort_order>1</sort_order>
504
- <show_in_default>1</show_in_default>
505
- <show_in_website>1</show_in_website>
506
- <show_in_store>1</show_in_store>
507
- </active>
508
- <title translate="label">
509
- <label>Title</label>
510
- <frontend_type>text</frontend_type>
511
- <sort_order>2</sort_order>
512
- <show_in_default>1</show_in_default>
513
- <show_in_website>1</show_in_website>
514
- <show_in_store>1</show_in_store>
515
- </title>
516
- <config translate="label">
517
- <label>Configuration</label>
518
- <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
519
- <comment>{configuration_syntax_help}</comment>
520
- <frontend_type>textarea</frontend_type>
521
- <sort_order>3</sort_order>
522
- <show_in_default>1</show_in_default>
523
- <show_in_website>1</show_in_website>
524
- <show_in_store>1</show_in_store>
525
- </config>
526
- <weight_limit translate="label">
527
- <label>Weight Limit</label>
528
- <frontend_type>text</frontend_type>
529
- <comment>in Kg</comment>
530
- <sort_order>7</sort_order>
531
- <show_in_default>1</show_in_default>
532
- <show_in_website>1</show_in_website>
533
- <show_in_store>1</show_in_store>
534
- </weight_limit>
535
- <quickcost translate="label">
536
- <label>Quickcost</label>
537
- <frontend_type>select</frontend_type>
538
- <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
539
- <source_model>adminhtml/system_config_source_yesno</source_model>
540
- <sort_order>10</sort_order>
541
- <show_in_default>1</show_in_default>
542
- <show_in_website>1</show_in_website>
543
- <show_in_store>0</show_in_store>
544
- </quickcost>
545
- <quickcost_url>
546
- <label>Quickcost Url</label>
547
- <frontend_type>text</frontend_type>
548
- <sort_order>11</sort_order>
549
- <show_in_default>1</show_in_default>
550
- <show_in_website>1</show_in_website>
551
- <show_in_store>0</show_in_store>
552
- </quickcost_url>
553
- <free_shipping_enable translate="label">
554
- <label>Free Shipping on the Amount</label>
555
- <frontend_type>select</frontend_type>
556
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
557
- <sort_order>12</sort_order>
558
- <show_in_default>1</show_in_default>
559
- <show_in_website>1</show_in_website>
560
- <show_in_store>1</show_in_store>
561
- </free_shipping_enable>
562
- <free_shipping_subtotal translate="label">
563
- <label>Minimum Amount for Free Shipping</label>
564
- <frontend_type>text</frontend_type>
565
- <sort_order>13</sort_order>
566
- <show_in_default>1</show_in_default>
567
- <show_in_website>1</show_in_website>
568
- <show_in_store>0</show_in_store>
569
- </free_shipping_subtotal>
570
- <application_fee translate="label">
571
- <label>Application Fee</label>
572
- <frontend_type>text</frontend_type>
573
- <sort_order>14</sort_order>
574
- <show_in_default>1</show_in_default>
575
- <show_in_website>1</show_in_website>
576
- <show_in_store>1</show_in_store>
577
- </application_fee>
578
- <handling_fee translate="label">
579
- <label>Handling Fee</label>
580
- <frontend_type>text</frontend_type>
581
- <sort_order>15</sort_order>
582
- <show_in_default>1</show_in_default>
583
- <show_in_website>1</show_in_website>
584
- <show_in_store>1</show_in_store>
585
- </handling_fee>
586
- <logo_url>
587
- <label>Logo Url</label>
588
- <frontend_type>text</frontend_type>
589
- <comment>{logo_ulr_help}</comment>
590
- <sort_order>18</sort_order>
591
- <show_in_default>1</show_in_default>
592
- <show_in_website>1</show_in_website>
593
- <show_in_store>1</show_in_store>
594
- </logo_url>
595
- <debug>
596
- <label>Debug</label>
597
- <comment>{debug_help}</comment>
598
- <frontend_type>text</frontend_type>
599
- <sort_order>20</sort_order>
600
- <show_in_default>1</show_in_default>
601
- <show_in_website>1</show_in_website>
602
- <show_in_store>1</show_in_store>
603
- </debug>
604
- <!--<stop_to_first_match translate="label">
605
- <label>Stop to first match</label>
606
- <frontend_type>select</frontend_type>
607
- <source_model>adminhtml/system_config_source_yesno</source_model>
608
- <sort_order>22</sort_order>
609
- <show_in_default>1</show_in_default>
610
- <show_in_website>1</show_in_website>
611
- <show_in_store>1</show_in_store>
612
- </stop_to_first_match>-->
613
- <deliver_on_saturday translate="label comment">
614
- <label>Livraison le Samedi</label>
615
- <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
616
- <frontend_type>select</frontend_type>
617
- <source_model>adminhtml/system_config_source_yesno</source_model>
618
- <sort_order>23</sort_order>
619
- <show_in_default>1</show_in_default>
620
- <show_in_website>1</show_in_website>
621
- <show_in_store>1</show_in_store>
622
- </deliver_on_saturday>
623
- <!--<showmethod translate="label">
624
- <label>Show Method if Not Applicable</label>
625
- <frontend_type>select</frontend_type>
626
- <sort_order>30</sort_order>
627
- <frontend_class>shipping-skip-hide</frontend_class>
628
- <source_model>adminhtml/system_config_source_yesno</source_model>
629
- <show_in_default>1</show_in_default>
630
- <show_in_website>1</show_in_website>
631
- <show_in_store>0</show_in_store>
632
- </showmethod>
633
- <specificerrmsg translate="label">
634
- <label>Displayed Error Message</label>
635
- <frontend_type>textarea</frontend_type>
636
- <sort_order>31</sort_order>
637
- <show_in_default>1</show_in_default>
638
- <show_in_website>1</show_in_website>
639
- <show_in_store>1</show_in_store>
640
- </specificerrmsg>-->
641
- <sort_order translate="label">
642
- <label>Sort order</label>
643
- <frontend_type>text</frontend_type>
644
- <sort_order>100</sort_order>
645
- <show_in_default>1</show_in_default>
646
- <show_in_website>1</show_in_website>
647
- <show_in_store>1</show_in_store>
648
- </sort_order>
649
- </fields>
650
- </chronopostc10>
651
-
652
- <!-- C18 Livraison avant 18H -->
653
- <chronopostc18 translate="label">
654
- <label>Chronopost C18</label>
655
- <frontend_type>text</frontend_type>
656
- <sort_order>24</sort_order>
657
- <show_in_default>1</show_in_default>
658
- <show_in_website>1</show_in_website>
659
- <show_in_store>1</show_in_store>
660
- <fields>
661
- <active translate="label">
662
- <label>Enabled</label>
663
- <frontend_type>select</frontend_type>
664
- <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
665
- <source_model>adminhtml/system_config_source_yesno</source_model>
666
- <sort_order>1</sort_order>
667
- <show_in_default>1</show_in_default>
668
- <show_in_website>1</show_in_website>
669
- <show_in_store>1</show_in_store>
670
- </active>
671
- <title translate="label">
672
- <label>Title</label>
673
- <frontend_type>text</frontend_type>
674
- <sort_order>2</sort_order>
675
- <show_in_default>1</show_in_default>
676
- <show_in_website>1</show_in_website>
677
- <show_in_store>1</show_in_store>
678
- </title>
679
- <config translate="label">
680
- <label>Configuration</label>
681
- <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
682
- <comment>{configuration_syntax_help}</comment>
683
- <frontend_type>textarea</frontend_type>
684
- <sort_order>3</sort_order>
685
- <show_in_default>1</show_in_default>
686
- <show_in_website>1</show_in_website>
687
- <show_in_store>1</show_in_store>
688
- </config>
689
- <weight_limit translate="label">
690
- <label>Weight Limit</label>
691
- <frontend_type>text</frontend_type>
692
- <comment>in Kg</comment>
693
- <sort_order>7</sort_order>
694
- <show_in_default>1</show_in_default>
695
- <show_in_website>1</show_in_website>
696
- <show_in_store>1</show_in_store>
697
- </weight_limit>
698
- <quickcost translate="label">
699
- <label>Quickcost</label>
700
- <frontend_type>select</frontend_type>
701
- <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
702
- <source_model>adminhtml/system_config_source_yesno</source_model>
703
- <sort_order>10</sort_order>
704
- <show_in_default>0</show_in_default>
705
- <show_in_website>0</show_in_website>
706
- <show_in_store>0</show_in_store>
707
- </quickcost>
708
- <quickcost_url>
709
- <label>Quickcost Url</label>
710
- <frontend_type>text</frontend_type>
711
- <sort_order>11</sort_order>
712
- <show_in_default>0</show_in_default>
713
- <show_in_website>0</show_in_website>
714
- <show_in_store>0</show_in_store>
715
- </quickcost_url>
716
- <free_shipping_enable translate="label">
717
- <label>Free Shipping on the Amount</label>
718
- <frontend_type>select</frontend_type>
719
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
720
- <sort_order>12</sort_order>
721
- <show_in_default>1</show_in_default>
722
- <show_in_website>1</show_in_website>
723
- <show_in_store>1</show_in_store>
724
- </free_shipping_enable>
725
- <free_shipping_subtotal translate="label">
726
- <label>Minimum Amount for Free Shipping</label>
727
- <frontend_type>text</frontend_type>
728
- <sort_order>13</sort_order>
729
- <show_in_default>1</show_in_default>
730
- <show_in_website>1</show_in_website>
731
- <show_in_store>0</show_in_store>
732
- </free_shipping_subtotal>
733
- <application_fee translate="label">
734
- <label>Application Fee</label>
735
- <frontend_type>text</frontend_type>
736
- <sort_order>14</sort_order>
737
- <show_in_default>1</show_in_default>
738
- <show_in_website>1</show_in_website>
739
- <show_in_store>1</show_in_store>
740
- </application_fee>
741
- <handling_fee translate="label">
742
- <label>Handling Fee</label>
743
- <frontend_type>text</frontend_type>
744
- <sort_order>15</sort_order>
745
- <show_in_default>1</show_in_default>
746
- <show_in_website>1</show_in_website>
747
- <show_in_store>1</show_in_store>
748
- </handling_fee>
749
- <logo_url>
750
- <label>Logo Url</label>
751
- <frontend_type>text</frontend_type>
752
- <comment>{logo_ulr_help}</comment>
753
- <sort_order>18</sort_order>
754
- <show_in_default>1</show_in_default>
755
- <show_in_website>1</show_in_website>
756
- <show_in_store>1</show_in_store>
757
- </logo_url>
758
- <debug>
759
- <label>Debug</label>
760
- <comment>{debug_help}</comment>
761
- <frontend_type>text</frontend_type>
762
- <sort_order>20</sort_order>
763
- <show_in_default>1</show_in_default>
764
- <show_in_website>1</show_in_website>
765
- <show_in_store>1</show_in_store>
766
- </debug>
767
- <!--<stop_to_first_match translate="label">
768
- <label>Stop to first match</label>
769
- <frontend_type>select</frontend_type>
770
- <source_model>adminhtml/system_config_source_yesno</source_model>
771
- <sort_order>22</sort_order>
772
- <show_in_default>1</show_in_default>
773
- <show_in_website>1</show_in_website>
774
- <show_in_store>1</show_in_store>
775
- </stop_to_first_match>-->
776
- <deliver_on_saturday translate="label comment">
777
- <label>Livraison le Samedi</label>
778
- <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
779
- <frontend_type>select</frontend_type>
780
- <source_model>adminhtml/system_config_source_yesno</source_model>
781
- <sort_order>23</sort_order>
782
- <show_in_default>1</show_in_default>
783
- <show_in_website>1</show_in_website>
784
- <show_in_store>1</show_in_store>
785
- </deliver_on_saturday>
786
- <!--<showmethod translate="label">
787
- <label>Show Method if Not Applicable</label>
788
- <frontend_type>select</frontend_type>
789
- <sort_order>30</sort_order>
790
- <frontend_class>shipping-skip-hide</frontend_class>
791
- <source_model>adminhtml/system_config_source_yesno</source_model>
792
- <show_in_default>1</show_in_default>
793
- <show_in_website>1</show_in_website>
794
- <show_in_store>0</show_in_store>
795
- </showmethod>
796
- <specificerrmsg translate="label">
797
- <label>Displayed Error Message</label>
798
- <frontend_type>textarea</frontend_type>
799
- <sort_order>31</sort_order>
800
- <show_in_default>1</show_in_default>
801
- <show_in_website>1</show_in_website>
802
- <show_in_store>1</show_in_store>
803
- </specificerrmsg>-->
804
- <sort_order translate="label">
805
- <label>Sort order</label>
806
- <frontend_type>text</frontend_type>
807
- <sort_order>100</sort_order>
808
- <show_in_default>1</show_in_default>
809
- <show_in_website>1</show_in_website>
810
- <show_in_store>1</show_in_store>
811
- </sort_order>
812
- </fields>
813
- </chronopostc18>
814
-
815
- <!-- CClassic Livraison dans certaines villes Européennes -->
816
- <chronopostcclassic translate="label">
817
- <label>Chronopost CClassic</label>
818
- <frontend_type>text</frontend_type>
819
- <sort_order>25</sort_order>
820
- <show_in_default>1</show_in_default>
821
- <show_in_website>1</show_in_website>
822
- <show_in_store>1</show_in_store>
823
- <fields>
824
- <active translate="label">
825
- <label>Enabled</label>
826
- <frontend_type>select</frontend_type>
827
- <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
828
- <source_model>adminhtml/system_config_source_yesno</source_model>
829
- <sort_order>1</sort_order>
830
- <show_in_default>1</show_in_default>
831
- <show_in_website>1</show_in_website>
832
- <show_in_store>1</show_in_store>
833
- </active>
834
- <title translate="label">
835
- <label>Title</label>
836
- <frontend_type>text</frontend_type>
837
- <sort_order>2</sort_order>
838
- <show_in_default>1</show_in_default>
839
- <show_in_website>1</show_in_website>
840
- <show_in_store>1</show_in_store>
841
- </title>
842
- <config translate="label">
843
- <label>Configuration</label>
844
- <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
845
- <comment>{configuration_syntax_help}</comment>
846
- <frontend_type>textarea</frontend_type>
847
- <sort_order>3</sort_order>
848
- <show_in_default>1</show_in_default>
849
- <show_in_website>1</show_in_website>
850
- <show_in_store>1</show_in_store>
851
- </config>
852
- <weight_limit translate="label">
853
- <label>Weight Limit</label>
854
- <frontend_type>text</frontend_type>
855
- <comment>in Kg</comment>
856
- <sort_order>7</sort_order>
857
- <show_in_default>1</show_in_default>
858
- <show_in_website>1</show_in_website>
859
- <show_in_store>1</show_in_store>
860
- </weight_limit>
861
- <quickcost translate="label">
862
- <label>Quickcost</label>
863
- <frontend_type>select</frontend_type>
864
- <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
865
- <source_model>adminhtml/system_config_source_yesno</source_model>
866
- <sort_order>10</sort_order>
867
- <show_in_default>1</show_in_default>
868
- <show_in_website>1</show_in_website>
869
- <show_in_store>0</show_in_store>
870
- </quickcost>
871
- <quickcost_url>
872
- <label>Quickcost Url</label>
873
- <frontend_type>text</frontend_type>
874
- <sort_order>11</sort_order>
875
- <show_in_default>1</show_in_default>
876
- <show_in_website>1</show_in_website>
877
- <show_in_store>0</show_in_store>
878
- </quickcost_url>
879
- <free_shipping_enable translate="label">
880
- <label>Free Shipping on the Amount</label>
881
- <frontend_type>select</frontend_type>
882
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
883
- <sort_order>12</sort_order>
884
- <show_in_default>1</show_in_default>
885
- <show_in_website>1</show_in_website>
886
- <show_in_store>1</show_in_store>
887
- </free_shipping_enable>
888
- <free_shipping_subtotal translate="label">
889
- <label>Minimum Amount for Free Shipping</label>
890
- <frontend_type>text</frontend_type>
891
- <sort_order>13</sort_order>
892
- <show_in_default>1</show_in_default>
893
- <show_in_website>1</show_in_website>
894
- <show_in_store>0</show_in_store>
895
- </free_shipping_subtotal>
896
- <application_fee translate="label">
897
- <label>Application Fee</label>
898
- <frontend_type>text</frontend_type>
899
- <sort_order>14</sort_order>
900
- <show_in_default>1</show_in_default>
901
- <show_in_website>1</show_in_website>
902
- <show_in_store>1</show_in_store>
903
- </application_fee>
904
- <handling_fee translate="label">
905
- <label>Handling Fee</label>
906
- <frontend_type>text</frontend_type>
907
- <sort_order>15</sort_order>
908
- <show_in_default>1</show_in_default>
909
- <show_in_website>1</show_in_website>
910
- <show_in_store>1</show_in_store>
911
- </handling_fee>
912
- <logo_url>
913
- <label>Logo Url</label>
914
- <frontend_type>text</frontend_type>
915
- <comment>{logo_ulr_help}</comment>
916
- <sort_order>18</sort_order>
917
- <show_in_default>1</show_in_default>
918
- <show_in_website>1</show_in_website>
919
- <show_in_store>1</show_in_store>
920
- </logo_url>
921
- <debug>
922
- <label>Debug</label>
923
- <comment>{debug_help}</comment>
924
- <frontend_type>text</frontend_type>
925
- <sort_order>20</sort_order>
926
- <show_in_default>1</show_in_default>
927
- <show_in_website>1</show_in_website>
928
- <show_in_store>1</show_in_store>
929
- </debug>
930
- <!--<stop_to_first_match translate="label">
931
- <label>Stop to first match</label>
932
- <frontend_type>select</frontend_type>
933
- <source_model>adminhtml/system_config_source_yesno</source_model>
934
- <sort_order>22</sort_order>
935
- <show_in_default>1</show_in_default>
936
- <show_in_website>1</show_in_website>
937
- <show_in_store>1</show_in_store>
938
- </stop_to_first_match>-->
939
- <deliver_on_saturday translate="label comment">
940
- <label>Livraison le Samedi</label>
941
- <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
942
- <frontend_type>select</frontend_type>
943
- <source_model>adminhtml/system_config_source_yesno</source_model>
944
- <sort_order>23</sort_order>
945
- <show_in_default>1</show_in_default>
946
- <show_in_website>1</show_in_website>
947
- <show_in_store>1</show_in_store>
948
- </deliver_on_saturday>
949
- <!--<showmethod translate="label">
950
- <label>Show Method if Not Applicable</label>
951
- <frontend_type>select</frontend_type>
952
- <sort_order>30</sort_order>
953
- <frontend_class>shipping-skip-hide</frontend_class>
954
- <source_model>adminhtml/system_config_source_yesno</source_model>
955
- <show_in_default>1</show_in_default>
956
- <show_in_website>1</show_in_website>
957
- <show_in_store>0</show_in_store>
958
- </showmethod>
959
- <specificerrmsg translate="label">
960
- <label>Displayed Error Message</label>
961
- <frontend_type>textarea</frontend_type>
962
- <sort_order>31</sort_order>
963
- <show_in_default>1</show_in_default>
964
- <show_in_website>1</show_in_website>
965
- <show_in_store>1</show_in_store>
966
- </specificerrmsg>-->
967
- <sort_order translate="label">
968
- <label>Sort order</label>
969
- <frontend_type>text</frontend_type>
970
- <sort_order>100</sort_order>
971
- <show_in_default>1</show_in_default>
972
- <show_in_website>1</show_in_website>
973
- <show_in_store>1</show_in_store>
974
- </sort_order>
975
- </fields>
976
- </chronopostcclassic>
977
-
978
- </groups>
979
- </carriers>
980
- </sections>
981
-
982
- <sections>
983
- <chronorelais>
984
- <label>Configuration</label>
985
- <tab>chronopost</tab>
986
- <frontend_type>text</frontend_type>
987
- <sort_order>2000</sort_order>
988
- <show_in_default>1</show_in_default>
989
- <show_in_website>1</show_in_website>
990
- <show_in_store>1</show_in_store>
991
- <groups>
992
- <shipping translate="label">
993
- <label>General</label>
994
- <frontend_type>text</frontend_type>
995
- <sort_order>10</sort_order>
996
- <show_in_default>1</show_in_default>
997
- <show_in_website>1</show_in_website>
998
- <show_in_store>1</show_in_store>
999
- <fields>
1000
- <account_number translate="label">
1001
- <label>N° de compte Chronopost</label>
1002
- <frontend_type>text</frontend_type>
1003
- <sort_order>7</sort_order>
1004
- <show_in_default>1</show_in_default>
1005
- <show_in_website>1</show_in_website>
1006
- <show_in_store>1</show_in_store>
1007
- </account_number>
1008
- <sub_account_number translate="label">
1009
- <label>N° de sous-compte</label>
1010
- <comment>must be 3 digits or empty</comment>
1011
- <frontend_type>text</frontend_type>
1012
- <sort_order>8</sort_order>
1013
- <show_in_default>1</show_in_default>
1014
- <show_in_website>1</show_in_website>
1015
- <show_in_store>1</show_in_store>
1016
- </sub_account_number>
1017
- <account_pass translate="label">
1018
- <label>Mot de passe Chronopost</label>
1019
- <frontend_type>text</frontend_type>
1020
- <button_label>Vérifier mes identifiants</button_label>
1021
- <frontend_model>chronorelais/adminhtml_system_config_checklogin</frontend_model>
1022
- <sort_order>9</sort_order>
1023
- <show_in_default>1</show_in_default>
1024
- <show_in_website>1</show_in_website>
1025
- <show_in_store>1</show_in_store>
1026
- </account_pass>
1027
- <google_map_api translate="label">
1028
- <label>Google Map v3 API Key</label>
1029
- <comment>The Google Maps JavaScript API Version 2 has been officially deprecated. Please use v3 API now. Get your key at https://code.google.com/apis/console/.</comment>
1030
- <frontend_type>text</frontend_type>
1031
- <sort_order>10</sort_order>
1032
- <show_in_default>1</show_in_default>
1033
- <show_in_website>1</show_in_website>
1034
- <show_in_store>1</show_in_store>
1035
- </google_map_api>
1036
- <tracking_view_url translate="label">
1037
- <label>Tracking URL</label>
1038
- <comment>For English language, replace fr_FR with en_GB in the above url</comment>
1039
- <frontend_type>text</frontend_type>
1040
- <sort_order>20</sort_order>
1041
- <show_in_default>1</show_in_default>
1042
- <show_in_website>1</show_in_website>
1043
- <show_in_store>1</show_in_store>
1044
- </tracking_view_url>
1045
- <gs_path translate="label">
1046
- <label>Chemin GS</label>
1047
- <comment>Chemin d'accès à la commande gs (Ghostscript)</comment>
1048
- <frontend_type>text</frontend_type>
1049
- <sort_order>21</sort_order>
1050
- <show_in_default>1</show_in_default>
1051
- <show_in_website>0</show_in_website>
1052
- <show_in_store>0</show_in_store>
1053
- </gs_path>
1054
-
1055
- </fields>
1056
- </shipping>
1057
- <export_css translate="label">
1058
- <label>Export Configuration CSS</label>
1059
- <frontend_type>text</frontend_type>
1060
- <sort_order>20</sort_order>
1061
- <show_in_default>1</show_in_default>
1062
- <show_in_website>1</show_in_website>
1063
- <show_in_store>1</show_in_store>
1064
- <fields>
1065
- <file_extension translate="label">
1066
- <label>File Extension</label>
1067
- <frontend_type>select</frontend_type>
1068
- <source_model>chronorelais/config_source_fileExtension</source_model>
1069
- <sort_order>10</sort_order>
1070
- <show_in_default>1</show_in_default>
1071
- <show_in_website>1</show_in_website>
1072
- <show_in_store>1</show_in_store>
1073
- </file_extension>
1074
- <file_charset translate="label">
1075
- <label>File Charset</label>
1076
- <frontend_type>select</frontend_type>
1077
- <source_model>chronorelais/config_source_fileCharset</source_model>
1078
- <sort_order>20</sort_order>
1079
- <show_in_default>1</show_in_default>
1080
- <show_in_website>1</show_in_website>
1081
- <show_in_store>1</show_in_store>
1082
- </file_charset>
1083
- <endofline_character translate="label">
1084
- <label>End Of Line Character</label>
1085
- <frontend_type>select</frontend_type>
1086
- <source_model>chronorelais/config_source_endOfLineCharacter</source_model>
1087
- <sort_order>30</sort_order>
1088
- <show_in_default>1</show_in_default>
1089
- <show_in_website>1</show_in_website>
1090
- <show_in_store>1</show_in_store>
1091
- </endofline_character>
1092
- <field_delimiter translate="label">
1093
- <label>Field Delimiter</label>
1094
- <frontend_type>select</frontend_type>
1095
- <source_model>chronorelais/config_source_fieldDelimiter</source_model>
1096
- <sort_order>40</sort_order>
1097
- <show_in_default>1</show_in_default>
1098
- <show_in_website>1</show_in_website>
1099
- <show_in_store>1</show_in_store>
1100
- </field_delimiter>
1101
- <field_separator translate="label">
1102
- <label>Field Separator</label>
1103
- <frontend_type>select</frontend_type>
1104
- <source_model>chronorelais/config_source_fieldSeparator</source_model>
1105
- <sort_order>50</sort_order>
1106
- <show_in_default>1</show_in_default>
1107
- <show_in_website>1</show_in_website>
1108
- <show_in_store>1</show_in_store>
1109
- </field_separator>
1110
- </fields>
1111
- </export_css>
1112
- <export_cso translate="label">
1113
- <label>Export Configuration CSO</label>
1114
- <frontend_type>text</frontend_type>
1115
- <sort_order>21</sort_order>
1116
- <show_in_default>1</show_in_default>
1117
- <show_in_website>1</show_in_website>
1118
- <show_in_store>1</show_in_store>
1119
- <fields>
1120
- <file_extension translate="label">
1121
- <label>File Extension</label>
1122
- <frontend_type>select</frontend_type>
1123
- <source_model>chronorelais/config_source_fileExtension</source_model>
1124
- <sort_order>10</sort_order>
1125
- <show_in_default>1</show_in_default>
1126
- <show_in_website>1</show_in_website>
1127
- <show_in_store>1</show_in_store>
1128
- </file_extension>
1129
- <file_charset translate="label">
1130
- <label>File Charset</label>
1131
- <frontend_type>select</frontend_type>
1132
- <source_model>chronorelais/config_source_fileCharset</source_model>
1133
- <sort_order>20</sort_order>
1134
- <show_in_default>1</show_in_default>
1135
- <show_in_website>1</show_in_website>
1136
- <show_in_store>1</show_in_store>
1137
- </file_charset>
1138
- <endofline_character translate="label">
1139
- <label>End Of Line Character</label>
1140
- <frontend_type>select</frontend_type>
1141
- <source_model>chronorelais/config_source_endOfLineCharacter</source_model>
1142
- <sort_order>30</sort_order>
1143
- <show_in_default>1</show_in_default>
1144
- <show_in_website>1</show_in_website>
1145
- <show_in_store>1</show_in_store>
1146
- </endofline_character>
1147
- <field_delimiter translate="label">
1148
- <label>Field Delimiter</label>
1149
- <frontend_type>select</frontend_type>
1150
- <source_model>chronorelais/config_source_fieldDelimiter</source_model>
1151
- <sort_order>40</sort_order>
1152
- <show_in_default>1</show_in_default>
1153
- <show_in_website>1</show_in_website>
1154
- <show_in_store>1</show_in_store>
1155
- </field_delimiter>
1156
- <field_separator translate="label">
1157
- <label>Field Separator</label>
1158
- <frontend_type>select</frontend_type>
1159
- <source_model>chronorelais/config_source_fieldSeparator</source_model>
1160
- <sort_order>50</sort_order>
1161
- <show_in_default>1</show_in_default>
1162
- <show_in_website>1</show_in_website>
1163
- <show_in_store>1</show_in_store>
1164
- </field_separator>
1165
- </fields>
1166
- </export_cso>
1167
- <import translate="label">
1168
- <label>Import Configuration</label>
1169
- <frontend_type>text</frontend_type>
1170
- <sort_order>30</sort_order>
1171
- <show_in_default>1</show_in_default>
1172
- <show_in_website>1</show_in_website>
1173
- <show_in_store>1</show_in_store>
1174
- <fields>
1175
- <default_tracking_title translate="label comment">
1176
- <label>Default Tracking Title</label>
1177
- <frontend_type>text</frontend_type>
1178
- <sort_order>10</sort_order>
1179
- <show_in_default>1</show_in_default>
1180
- <show_in_website>1</show_in_website>
1181
- <show_in_store>1</show_in_store>
1182
- <comment>This value can be changed in the import form</comment>
1183
- </default_tracking_title>
1184
- <send_email translate="label comment">
1185
- <label>Send an e-mail</label>
1186
- <frontend_type>select</frontend_type>
1187
- <source_model>adminhtml/system_config_source_yesno</source_model>
1188
- <sort_order>20</sort_order>
1189
- <show_in_default>1</show_in_default>
1190
- <show_in_website>1</show_in_website>
1191
- <show_in_store>1</show_in_store>
1192
- <comment>Send shipping confirmation to the customer</comment>
1193
- </send_email>
1194
- <shipping_comment translate="label comment">
1195
- <label>Shipping Comment</label>
1196
- <frontend_type>text</frontend_type>
1197
- <sort_order>30</sort_order>
1198
- <show_in_default>1</show_in_default>
1199
- <show_in_website>1</show_in_website>
1200
- <show_in_store>1</show_in_store>
1201
- <comment>Internal comment, can be left empty</comment>
1202
- </shipping_comment>
1203
- <include_comment translate="label comment">
1204
- <label>Include comment into e-mail</label>
1205
- <frontend_type>select</frontend_type>
1206
- <source_model>adminhtml/system_config_source_yesno</source_model>
1207
- <sort_order>40</sort_order>
1208
- <show_in_default>1</show_in_default>
1209
- <show_in_website>1</show_in_website>
1210
- <show_in_store>1</show_in_store>
1211
- <comment>Only applies if the shipping comment is set</comment>
1212
- </include_comment>
1213
- </fields>
1214
- </import>
1215
-
1216
- <shipperinformation translate="label">
1217
- <label>Shipper Information for Labels printing</label>
1218
- <frontend_type>text</frontend_type>
1219
- <sort_order>40</sort_order>
1220
- <show_in_default>1</show_in_default>
1221
- <show_in_website>1</show_in_website>
1222
- <show_in_store>1</show_in_store>
1223
- <fields>
1224
- <civility translate="label">
1225
- <label>Shipper Civility</label>
1226
- <frontend_type>select</frontend_type>
1227
- <source_model>chronorelais/config_source_civility</source_model>
1228
- <sort_order>10</sort_order>
1229
- <show_in_default>1</show_in_default>
1230
- <show_in_website>1</show_in_website>
1231
- <show_in_store>1</show_in_store>
1232
- </civility>
1233
- <name translate="label comment">
1234
- <label>Shipper Name</label>
1235
- <frontend_type>text</frontend_type>
1236
- <sort_order>20</sort_order>
1237
- <show_in_default>1</show_in_default>
1238
- <show_in_website>1</show_in_website>
1239
- <show_in_store>1</show_in_store>
1240
- <comment>Company name</comment>
1241
- </name>
1242
- <name2 translate="label comment">
1243
- <label>Shipper Name2</label>
1244
- <frontend_type>text</frontend_type>
1245
- <sort_order>30</sort_order>
1246
- <show_in_default>1</show_in_default>
1247
- <show_in_website>1</show_in_website>
1248
- <show_in_store>1</show_in_store>
1249
- <comment>[Optional]</comment>
1250
- </name2>
1251
- <address1 translate="label">
1252
- <label>Shipper Address1</label>
1253
- <frontend_type>text</frontend_type>
1254
- <sort_order>40</sort_order>
1255
- <show_in_default>1</show_in_default>
1256
- <show_in_website>1</show_in_website>
1257
- <show_in_store>1</show_in_store>
1258
- </address1>
1259
- <address2 translate="label comment">
1260
- <label>Shipper Address2</label>
1261
- <frontend_type>text</frontend_type>
1262
- <sort_order>50</sort_order>
1263
- <show_in_default>1</show_in_default>
1264
- <show_in_website>1</show_in_website>
1265
- <show_in_store>1</show_in_store>
1266
- <comment>[Optional]</comment>
1267
- </address2>
1268
- <zipcode translate="label">
1269
- <label>Shipper Zipcode</label>
1270
- <frontend_type>text</frontend_type>
1271
- <sort_order>60</sort_order>
1272
- <show_in_default>1</show_in_default>
1273
- <show_in_website>1</show_in_website>
1274
- <show_in_store>1</show_in_store>
1275
- </zipcode>
1276
- <city translate="label">
1277
- <label>Shipper City</label>
1278
- <frontend_type>text</frontend_type>
1279
- <sort_order>70</sort_order>
1280
- <show_in_default>1</show_in_default>
1281
- <show_in_website>1</show_in_website>
1282
- <show_in_store>1</show_in_store>
1283
- </city>
1284
- <country translate="label">
1285
- <label>Shipper Country</label>
1286
- <frontend_type>select</frontend_type>
1287
- <sort_order>80</sort_order>
1288
- <source_model>adminhtml/system_config_source_country</source_model>
1289
- <show_in_default>1</show_in_default>
1290
- <show_in_website>1</show_in_website>
1291
- <show_in_store>1</show_in_store>
1292
- </country>
1293
- <contactname translate="label">
1294
- <label>Shipper Contact Name</label>
1295
- <frontend_type>text</frontend_type>
1296
- <sort_order>90</sort_order>
1297
- <show_in_default>1</show_in_default>
1298
- <show_in_website>1</show_in_website>
1299
- <show_in_store>1</show_in_store>
1300
- </contactname>
1301
- <email translate="label">
1302
- <label>Shipper Email</label>
1303
- <frontend_type>text</frontend_type>
1304
- <sort_order>100</sort_order>
1305
- <show_in_default>1</show_in_default>
1306
- <show_in_website>1</show_in_website>
1307
- <show_in_store>1</show_in_store>
1308
- <comment>[Optional]</comment>
1309
- </email>
1310
- <phone translate="label comment">
1311
- <label>Shipper Telephone</label>
1312
- <frontend_type>text</frontend_type>
1313
- <sort_order>110</sort_order>
1314
- <show_in_default>1</show_in_default>
1315
- <show_in_website>1</show_in_website>
1316
- <show_in_store>1</show_in_store>
1317
- <comment>[Optional]</comment>
1318
- </phone>
1319
- <mobilephone translate="label comment">
1320
- <label>Shipper Mobile</label>
1321
- <frontend_type>text</frontend_type>
1322
- <sort_order>120</sort_order>
1323
- <show_in_default>1</show_in_default>
1324
- <show_in_website>1</show_in_website>
1325
- <show_in_store>1</show_in_store>
1326
- <comment>[Optional]</comment>
1327
- </mobilephone>
1328
- </fields>
1329
- </shipperinformation>
1330
-
1331
- <customerinformation translate="label">
1332
- <label>Chronopost Customer Account Information for Labels printing</label>
1333
- <frontend_type>text</frontend_type>
1334
- <sort_order>50</sort_order>
1335
- <show_in_default>1</show_in_default>
1336
- <show_in_website>1</show_in_website>
1337
- <show_in_store>1</show_in_store>
1338
- <fields>
1339
- <civility translate="label">
1340
- <label>Customer Civility</label>
1341
- <frontend_type>select</frontend_type>
1342
- <source_model>chronorelais/config_source_civility</source_model>
1343
- <sort_order>10</sort_order>
1344
- <show_in_default>1</show_in_default>
1345
- <show_in_website>1</show_in_website>
1346
- <show_in_store>1</show_in_store>
1347
- </civility>
1348
- <name translate="label comment">
1349
- <label>Customer Name </label>
1350
- <frontend_type>text</frontend_type>
1351
- <sort_order>20</sort_order>
1352
- <show_in_default>1</show_in_default>
1353
- <show_in_website>1</show_in_website>
1354
- <show_in_store>1</show_in_store>
1355
- <comment>Company name</comment>
1356
- </name>
1357
- <name2 translate="label comment">
1358
- <label>Customer Name2</label>
1359
- <frontend_type>text</frontend_type>
1360
- <sort_order>30</sort_order>
1361
- <show_in_default>1</show_in_default>
1362
- <show_in_website>1</show_in_website>
1363
- <show_in_store>1</show_in_store>
1364
- <comment>[Optional]</comment>
1365
- </name2>
1366
- <address1 translate="label">
1367
- <label>Customer Address1</label>
1368
- <frontend_type>text</frontend_type>
1369
- <sort_order>40</sort_order>
1370
- <show_in_default>1</show_in_default>
1371
- <show_in_website>1</show_in_website>
1372
- <show_in_store>1</show_in_store>
1373
- </address1>
1374
- <address2 translate="label comment">
1375
- <label>Customer Address2</label>
1376
- <frontend_type>text</frontend_type>
1377
- <sort_order>50</sort_order>
1378
- <show_in_default>1</show_in_default>
1379
- <show_in_website>1</show_in_website>
1380
- <show_in_store>1</show_in_store>
1381
- <comment>[Optional]</comment>
1382
- </address2>
1383
- <zipcode translate="label">
1384
- <label>Customer Zipcode</label>
1385
- <frontend_type>text</frontend_type>
1386
- <sort_order>60</sort_order>
1387
- <show_in_default>1</show_in_default>
1388
- <show_in_website>1</show_in_website>
1389
- <show_in_store>1</show_in_store>
1390
- </zipcode>
1391
- <city translate="label">
1392
- <label>Customer City</label>
1393
- <frontend_type>text</frontend_type>
1394
- <sort_order>70</sort_order>
1395
- <show_in_default>1</show_in_default>
1396
- <show_in_website>1</show_in_website>
1397
- <show_in_store>1</show_in_store>
1398
- </city>
1399
- <country translate="label">
1400
- <label>Customer Country</label>
1401
- <frontend_type>select</frontend_type>
1402
- <sort_order>80</sort_order>
1403
- <source_model>adminhtml/system_config_source_country</source_model>
1404
- <show_in_default>1</show_in_default>
1405
- <show_in_website>1</show_in_website>
1406
- <show_in_store>1</show_in_store>
1407
- </country>
1408
- <contactname translate="label">
1409
- <label>Customer Contact Name</label>
1410
- <frontend_type>text</frontend_type>
1411
- <sort_order>90</sort_order>
1412
- <show_in_default>1</show_in_default>
1413
- <show_in_website>1</show_in_website>
1414
- <show_in_store>1</show_in_store>
1415
- </contactname>
1416
- <email translate="label">
1417
- <label>Customer Email</label>
1418
- <frontend_type>text</frontend_type>
1419
- <sort_order>100</sort_order>
1420
- <show_in_default>1</show_in_default>
1421
- <show_in_website>1</show_in_website>
1422
- <show_in_store>1</show_in_store>
1423
- <comment>[Optional]</comment>
1424
- </email>
1425
- <phone translate="label comment">
1426
- <label>Customer Telephone</label>
1427
- <frontend_type>text</frontend_type>
1428
- <sort_order>110</sort_order>
1429
- <show_in_default>1</show_in_default>
1430
- <show_in_website>1</show_in_website>
1431
- <show_in_store>1</show_in_store>
1432
- <comment>[Optional]</comment>
1433
- </phone>
1434
- <mobilephone translate="label comment">
1435
- <label>Customer Mobile</label>
1436
- <frontend_type>text</frontend_type>
1437
- <sort_order>120</sort_order>
1438
- <show_in_default>1</show_in_default>
1439
- <show_in_website>1</show_in_website>
1440
- <show_in_store>1</show_in_store>
1441
- <comment>[Optional]</comment>
1442
- </mobilephone>
1443
- </fields>
1444
- </customerinformation>
1445
-
1446
- <skybillparam translate="label">
1447
- <label>Skybill Parameters for Labels printing</label>
1448
- <frontend_type>text</frontend_type>
1449
- <sort_order>60</sort_order>
1450
- <show_in_default>1</show_in_default>
1451
- <show_in_website>1</show_in_website>
1452
- <show_in_store>1</show_in_store>
1453
- <fields>
1454
- <mode translate="label">
1455
- <label>Print Mode</label>
1456
- <frontend_type>select</frontend_type>
1457
- <source_model>chronorelais/config_source_printMode</source_model>
1458
- <sort_order>10</sort_order>
1459
- <show_in_default>1</show_in_default>
1460
- <show_in_website>1</show_in_website>
1461
- <show_in_store>1</show_in_store>
1462
- <required>1</required>
1463
- </mode>
1464
- </fields>
1465
- </skybillparam>
1466
-
1467
- <weightunit translate="label">
1468
- <label>Weight unit for the store</label>
1469
- <frontend_type>text</frontend_type>
1470
- <sort_order>70</sort_order>
1471
- <show_in_default>1</show_in_default>
1472
- <show_in_website>1</show_in_website>
1473
- <show_in_store>1</show_in_store>
1474
- <fields>
1475
- <unit translate="label">
1476
- <label>Weight unit</label>
1477
- <frontend_type>select</frontend_type>
1478
- <source_model>chronorelais/config_source_weightUnit</source_model>
1479
- <sort_order>10</sort_order>
1480
- <show_in_default>1</show_in_default>
1481
- <show_in_website>1</show_in_website>
1482
- <show_in_store>1</show_in_store>
1483
- <required>1</required>
1484
- </unit>
1485
- </fields>
1486
- </weightunit>
1487
-
1488
- <optionbal translate="label">
1489
- <label>Option BAL</label>
1490
- <frontend_type>text</frontend_type>
1491
- <sort_order>80</sort_order>
1492
- <show_in_default>1</show_in_default>
1493
- <show_in_website>1</show_in_website>
1494
- <show_in_store>1</show_in_store>
1495
- <fields>
1496
- <enabled translate="label">
1497
- <label>Activer l'option BAL de Chronopost</label>
1498
- <frontend_type>select</frontend_type>
1499
- <source_model>adminhtml/system_config_source_yesno</source_model>
1500
- <comment>Vérifiez que cette option figure dans votre contrat</comment>
1501
- <sort_order>10</sort_order>
1502
- <show_in_default>1</show_in_default>
1503
- <show_in_website>1</show_in_website>
1504
- <show_in_store>1</show_in_store>
1505
- <required>1</required>
1506
- </enabled>
1507
- </fields>
1508
- </optionbal>
1509
-
1510
- <assurance translate="label">
1511
- <label>Assurance Ad Valorem</label>
1512
- <frontend_type>text</frontend_type>
1513
- <frontend_model>chronorelais/adminhtml_system_config_form_fieldsetassurance</frontend_model>
1514
- <sort_order>90</sort_order>
1515
- <show_in_default>1</show_in_default>
1516
- <show_in_website>1</show_in_website>
1517
- <show_in_store>1</show_in_store>
1518
- <fields>
1519
- <enabled translate="label">
1520
- <label>Activer l'Ad Valorem</label>
1521
- <frontend_type>select</frontend_type>
1522
- <source_model>adminhtml/system_config_source_yesno</source_model>
1523
- <sort_order>1</sort_order>
1524
- <show_in_default>1</show_in_default>
1525
- <show_in_website>1</show_in_website>
1526
- <show_in_store>1</show_in_store>
1527
- <required>1</required>
1528
- </enabled>
1529
- <amount translate="label">
1530
- <label>Montant minimum à assurer</label>
1531
- <frontend_type>text</frontend_type>
1532
- <sort_order>2</sort_order>
1533
- <show_in_default>1</show_in_default>
1534
- <show_in_website>1</show_in_website>
1535
- <show_in_store>1</show_in_store>
1536
- <required>0</required>
1537
- <validate>validate-number</validate>
1538
- </amount>
1539
- </fields>
1540
- </assurance>
1541
-
1542
- </groups>
1543
- </chronorelais>
1544
- </sections>
1545
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1546
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <chronopost translate="label" module="chronorelais">
5
+ <label>Chronopost</label>
6
+ <sort_order>200</sort_order>
7
+ </chronopost>
8
+ </tabs>
9
+ <sections>
10
+ <carriers>
11
+ <groups>
12
+ <chronopost translate="label">
13
+ <label>Chronopost</label>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>20</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <fields>
20
+ <active translate="label">
21
+ <label>Enabled</label>
22
+ <frontend_type>select</frontend_type>
23
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
24
+ <source_model>adminhtml/system_config_source_yesno</source_model>
25
+ <sort_order>1</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ </active>
30
+ <title translate="label">
31
+ <label>Title</label>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>2</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ </title>
38
+ <config translate="label">
39
+ <label>Configuration</label>
40
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
41
+ <comment>{configuration_syntax_help}</comment>
42
+ <frontend_type>textarea</frontend_type>
43
+ <sort_order>3</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ </config>
48
+ <weight_limit translate="label">
49
+ <label>Weight Limit</label>
50
+ <frontend_type>text</frontend_type>
51
+ <comment>in Kg</comment>
52
+ <sort_order>7</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </weight_limit>
57
+ <quickcost translate="label">
58
+ <label>Quickcost</label>
59
+ <frontend_type>select</frontend_type>
60
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
61
+ <source_model>adminhtml/system_config_source_yesno</source_model>
62
+ <sort_order>10</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>0</show_in_store>
66
+ </quickcost>
67
+ <quickcost_url>
68
+ <label>Quickcost Url</label>
69
+ <frontend_type>text</frontend_type>
70
+ <sort_order>11</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>0</show_in_store>
74
+ </quickcost_url>
75
+ <free_shipping_enable translate="label">
76
+ <label>Free Shipping on the Amount</label>
77
+ <frontend_type>select</frontend_type>
78
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
79
+ <sort_order>12</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ </free_shipping_enable>
84
+ <free_shipping_subtotal translate="label">
85
+ <label>Minimum Amount for Free Shipping</label>
86
+ <frontend_type>text</frontend_type>
87
+ <sort_order>13</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>0</show_in_store>
91
+ </free_shipping_subtotal>
92
+ <application_fee translate="label">
93
+ <label>Application Fee</label>
94
+ <frontend_type>text</frontend_type>
95
+ <sort_order>14</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>1</show_in_store>
99
+ </application_fee>
100
+ <handling_fee translate="label">
101
+ <label>Handling Fee</label>
102
+ <frontend_type>text</frontend_type>
103
+ <sort_order>15</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>1</show_in_store>
107
+ </handling_fee>
108
+ <logo_url>
109
+ <label>Logo Url</label>
110
+ <frontend_type>text</frontend_type>
111
+ <comment>{logo_ulr_help}</comment>
112
+ <sort_order>18</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ </logo_url>
117
+ <debug>
118
+ <label>Debug</label>
119
+ <comment>{debug_help}</comment>
120
+ <frontend_type>text</frontend_type>
121
+ <sort_order>20</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>1</show_in_store>
125
+ </debug>
126
+ <!--<stop_to_first_match translate="label">
127
+ <label>Stop to first match</label>
128
+ <frontend_type>select</frontend_type>
129
+ <source_model>adminhtml/system_config_source_yesno</source_model>
130
+ <sort_order>22</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>1</show_in_store>
134
+ </stop_to_first_match>-->
135
+ <deliver_on_saturday translate="label comment">
136
+ <label>Livraison le Samedi</label>
137
+ <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
138
+ <frontend_type>select</frontend_type>
139
+ <source_model>adminhtml/system_config_source_yesno</source_model>
140
+ <sort_order>23</sort_order>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_website>1</show_in_website>
143
+ <show_in_store>1</show_in_store>
144
+ </deliver_on_saturday>
145
+ <!--<showmethod translate="label">
146
+ <label>Show Method if Not Applicable</label>
147
+ <frontend_type>select</frontend_type>
148
+ <sort_order>30</sort_order>
149
+ <frontend_class>shipping-skip-hide</frontend_class>
150
+ <source_model>adminhtml/system_config_source_yesno</source_model>
151
+ <show_in_default>1</show_in_default>
152
+ <show_in_website>1</show_in_website>
153
+ <show_in_store>0</show_in_store>
154
+ </showmethod>
155
+ <specificerrmsg translate="label">
156
+ <label>Displayed Error Message</label>
157
+ <frontend_type>textarea</frontend_type>
158
+ <sort_order>31</sort_order>
159
+ <show_in_default>1</show_in_default>
160
+ <show_in_website>1</show_in_website>
161
+ <show_in_store>1</show_in_store>
162
+ </specificerrmsg>-->
163
+ <sort_order translate="label">
164
+ <label>Sort order</label>
165
+ <frontend_type>text</frontend_type>
166
+ <sort_order>100</sort_order>
167
+ <show_in_default>1</show_in_default>
168
+ <show_in_website>1</show_in_website>
169
+ <show_in_store>1</show_in_store>
170
+ </sort_order>
171
+ </fields>
172
+ </chronopost>
173
+
174
+ <chronoexpress translate="label">
175
+ <label>Chrono Express</label>
176
+ <frontend_type>text</frontend_type>
177
+ <sort_order>21</sort_order>
178
+ <show_in_default>1</show_in_default>
179
+ <show_in_website>1</show_in_website>
180
+ <show_in_store>1</show_in_store>
181
+ <fields>
182
+ <active translate="label">
183
+ <label>Enabled</label>
184
+ <frontend_type>select</frontend_type>
185
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
186
+ <source_model>adminhtml/system_config_source_yesno</source_model>
187
+ <sort_order>1</sort_order>
188
+ <show_in_default>1</show_in_default>
189
+ <show_in_website>1</show_in_website>
190
+ <show_in_store>1</show_in_store>
191
+ </active>
192
+ <title translate="label">
193
+ <label>Title</label>
194
+ <frontend_type>text</frontend_type>
195
+ <sort_order>2</sort_order>
196
+ <show_in_default>1</show_in_default>
197
+ <show_in_website>1</show_in_website>
198
+ <show_in_store>1</show_in_store>
199
+ </title>
200
+ <config translate="label">
201
+ <label>Configuration</label>
202
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
203
+ <comment>{configuration_syntax_help}</comment>
204
+ <frontend_type>textarea</frontend_type>
205
+ <sort_order>3</sort_order>
206
+ <show_in_default>1</show_in_default>
207
+ <show_in_website>1</show_in_website>
208
+ <show_in_store>1</show_in_store>
209
+ </config>
210
+ <weight_limit translate="label">
211
+ <label>Weight Limit</label>
212
+ <frontend_type>text</frontend_type>
213
+ <comment>in Kg</comment>
214
+ <sort_order>7</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>1</show_in_store>
218
+ </weight_limit>
219
+ <quickcost translate="label">
220
+ <label>Quickcost</label>
221
+ <frontend_type>select</frontend_type>
222
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
223
+ <source_model>adminhtml/system_config_source_yesno</source_model>
224
+ <sort_order>10</sort_order>
225
+ <show_in_default>1</show_in_default>
226
+ <show_in_website>1</show_in_website>
227
+ <show_in_store>0</show_in_store>
228
+ </quickcost>
229
+ <quickcost_url>
230
+ <label>Quickcost Url</label>
231
+ <frontend_type>text</frontend_type>
232
+ <sort_order>11</sort_order>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_website>1</show_in_website>
235
+ <show_in_store>0</show_in_store>
236
+ </quickcost_url>
237
+ <free_shipping_enable translate="label">
238
+ <label>Free Shipping on the Amount</label>
239
+ <frontend_type>select</frontend_type>
240
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
241
+ <sort_order>12</sort_order>
242
+ <show_in_default>1</show_in_default>
243
+ <show_in_website>1</show_in_website>
244
+ <show_in_store>1</show_in_store>
245
+ </free_shipping_enable>
246
+ <free_shipping_subtotal translate="label">
247
+ <label>Minimum Amount for Free Shipping</label>
248
+ <frontend_type>text</frontend_type>
249
+ <sort_order>13</sort_order>
250
+ <show_in_default>1</show_in_default>
251
+ <show_in_website>1</show_in_website>
252
+ <show_in_store>0</show_in_store>
253
+ </free_shipping_subtotal>
254
+ <application_fee translate="label">
255
+ <label>Application Fee</label>
256
+ <frontend_type>text</frontend_type>
257
+ <sort_order>14</sort_order>
258
+ <show_in_default>1</show_in_default>
259
+ <show_in_website>1</show_in_website>
260
+ <show_in_store>1</show_in_store>
261
+ </application_fee>
262
+ <handling_fee translate="label">
263
+ <label>Handling Fee</label>
264
+ <frontend_type>text</frontend_type>
265
+ <sort_order>15</sort_order>
266
+ <show_in_default>1</show_in_default>
267
+ <show_in_website>1</show_in_website>
268
+ <show_in_store>1</show_in_store>
269
+ </handling_fee>
270
+ <logo_url>
271
+ <label>Logo Url</label>
272
+ <frontend_type>text</frontend_type>
273
+ <comment>{logo_ulr_help}</comment>
274
+ <sort_order>18</sort_order>
275
+ <show_in_default>1</show_in_default>
276
+ <show_in_website>1</show_in_website>
277
+ <show_in_store>1</show_in_store>
278
+ </logo_url>
279
+ <debug>
280
+ <label>Debug</label>
281
+ <comment>{debug_help}</comment>
282
+ <frontend_type>text</frontend_type>
283
+ <sort_order>20</sort_order>
284
+ <show_in_default>1</show_in_default>
285
+ <show_in_website>1</show_in_website>
286
+ <show_in_store>1</show_in_store>
287
+ </debug>
288
+ <!--<stop_to_first_match translate="label">
289
+ <label>Stop to first match</label>
290
+ <frontend_type>select</frontend_type>
291
+ <source_model>adminhtml/system_config_source_yesno</source_model>
292
+ <sort_order>22</sort_order>
293
+ <show_in_default>1</show_in_default>
294
+ <show_in_website>1</show_in_website>
295
+ <show_in_store>1</show_in_store>
296
+ </stop_to_first_match>-->
297
+ <!-- deliver_on_saturday not included in chronoexpress only -->
298
+ <!--<showmethod translate="label">
299
+ <label>Show Method if Not Applicable</label>
300
+ <frontend_type>select</frontend_type>
301
+ <sort_order>30</sort_order>
302
+ <frontend_class>shipping-skip-hide</frontend_class>
303
+ <source_model>adminhtml/system_config_source_yesno</source_model>
304
+ <show_in_default>1</show_in_default>
305
+ <show_in_website>1</show_in_website>
306
+ <show_in_store>0</show_in_store>
307
+ </showmethod>
308
+ <specificerrmsg translate="label">
309
+ <label>Displayed Error Message</label>
310
+ <frontend_type>textarea</frontend_type>
311
+ <sort_order>31</sort_order>
312
+ <show_in_default>1</show_in_default>
313
+ <show_in_website>1</show_in_website>
314
+ <show_in_store>1</show_in_store>
315
+ </specificerrmsg>-->
316
+ <sort_order translate="label">
317
+ <label>Sort order</label>
318
+ <frontend_type>text</frontend_type>
319
+ <sort_order>100</sort_order>
320
+ <show_in_default>1</show_in_default>
321
+ <show_in_website>1</show_in_website>
322
+ <show_in_store>1</show_in_store>
323
+ </sort_order>
324
+ </fields>
325
+ </chronoexpress>
326
+
327
+ <chronorelais translate="label">
328
+ <label>Chrono Relais</label>
329
+ <frontend_type>text</frontend_type>
330
+ <sort_order>22</sort_order>
331
+ <show_in_default>1</show_in_default>
332
+ <show_in_website>1</show_in_website>
333
+ <show_in_store>1</show_in_store>
334
+ <fields>
335
+ <active translate="label">
336
+ <label>Enabled</label>
337
+ <frontend_type>select</frontend_type>
338
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
339
+ <source_model>adminhtml/system_config_source_yesno</source_model>
340
+ <sort_order>1</sort_order>
341
+ <show_in_default>1</show_in_default>
342
+ <show_in_website>1</show_in_website>
343
+ <show_in_store>1</show_in_store>
344
+ </active>
345
+ <title translate="label">
346
+ <label>Title</label>
347
+ <frontend_type>text</frontend_type>
348
+ <sort_order>2</sort_order>
349
+ <show_in_default>1</show_in_default>
350
+ <show_in_website>1</show_in_website>
351
+ <show_in_store>1</show_in_store>
352
+ </title>
353
+ <config translate="label">
354
+ <label>Configuration</label>
355
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
356
+ <comment>{configuration_syntax_help}</comment>
357
+ <frontend_type>textarea</frontend_type>
358
+ <sort_order>3</sort_order>
359
+ <show_in_default>1</show_in_default>
360
+ <show_in_website>1</show_in_website>
361
+ <show_in_store>1</show_in_store>
362
+ </config>
363
+ <weight_limit translate="label">
364
+ <label>Weight Limit</label>
365
+ <frontend_type>text</frontend_type>
366
+ <comment>in Kg</comment>
367
+ <sort_order>7</sort_order>
368
+ <show_in_default>1</show_in_default>
369
+ <show_in_website>1</show_in_website>
370
+ <show_in_store>1</show_in_store>
371
+ </weight_limit>
372
+ <quickcost translate="label">
373
+ <label>Quickcost</label>
374
+ <frontend_type>select</frontend_type>
375
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
376
+ <source_model>adminhtml/system_config_source_yesno</source_model>
377
+ <sort_order>10</sort_order>
378
+ <show_in_default>1</show_in_default>
379
+ <show_in_website>1</show_in_website>
380
+ <show_in_store>0</show_in_store>
381
+ </quickcost>
382
+ <quickcost_url>
383
+ <label>Quickcost Url</label>
384
+ <frontend_type>text</frontend_type>
385
+ <sort_order>11</sort_order>
386
+ <show_in_default>1</show_in_default>
387
+ <show_in_website>1</show_in_website>
388
+ <show_in_store>0</show_in_store>
389
+ </quickcost_url>
390
+ <show_google_map translate="label">
391
+ <label>Show Google Map</label>
392
+ <frontend_type>select</frontend_type>
393
+ <source_model>adminhtml/system_config_source_yesno</source_model>
394
+ <sort_order>12</sort_order>
395
+ <show_in_default>1</show_in_default>
396
+ <show_in_website>1</show_in_website>
397
+ <show_in_store>1</show_in_store>
398
+ </show_google_map>
399
+ <free_shipping_enable translate="label">
400
+ <label>Free Shipping with Minimum Order Amount</label>
401
+ <frontend_type>select</frontend_type>
402
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
403
+ <sort_order>12</sort_order>
404
+ <show_in_default>1</show_in_default>
405
+ <show_in_website>1</show_in_website>
406
+ <show_in_store>1</show_in_store>
407
+ </free_shipping_enable>
408
+ <free_shipping_subtotal translate="label">
409
+ <label>Minimum Order Amount for Free Shipping</label>
410
+ <frontend_type>text</frontend_type>
411
+ <sort_order>13</sort_order>
412
+ <show_in_default>1</show_in_default>
413
+ <show_in_website>1</show_in_website>
414
+ <show_in_store>1</show_in_store>
415
+ </free_shipping_subtotal>
416
+ <application_fee translate="label">
417
+ <label>Application Fee</label>
418
+ <frontend_type>text</frontend_type>
419
+ <sort_order>14</sort_order>
420
+ <show_in_default>1</show_in_default>
421
+ <show_in_website>1</show_in_website>
422
+ <show_in_store>1</show_in_store>
423
+ </application_fee>
424
+ <handling_fee translate="label">
425
+ <label>Handling Fee</label>
426
+ <frontend_type>text</frontend_type>
427
+ <sort_order>15</sort_order>
428
+ <show_in_default>1</show_in_default>
429
+ <show_in_website>1</show_in_website>
430
+ <show_in_store>1</show_in_store>
431
+ </handling_fee>
432
+ <logo_url>
433
+ <label>Logo Url</label>
434
+ <frontend_type>text</frontend_type>
435
+ <comment>{logo_ulr_help}</comment>
436
+ <sort_order>18</sort_order>
437
+ <show_in_default>1</show_in_default>
438
+ <show_in_website>1</show_in_website>
439
+ <show_in_store>1</show_in_store>
440
+ </logo_url>
441
+ <debug>
442
+ <label>Debug</label>
443
+ <comment>{debug_help}</comment>
444
+ <frontend_type>text</frontend_type>
445
+ <sort_order>20</sort_order>
446
+ <show_in_default>1</show_in_default>
447
+ <show_in_website>1</show_in_website>
448
+ <show_in_store>1</show_in_store>
449
+ </debug>
450
+ <!--<stop_to_first_match translate="label">
451
+ <label>Stop to first match</label>
452
+ <frontend_type>select</frontend_type>
453
+ <source_model>adminhtml/system_config_source_yesno</source_model>
454
+ <sort_order>22</sort_order>
455
+ <show_in_default>1</show_in_default>
456
+ <show_in_website>1</show_in_website>
457
+ <show_in_store>1</show_in_store>
458
+ </stop_to_first_match>-->
459
+ <deliver_on_saturday translate="label comment">
460
+ <label>Livraison le Samedi</label>
461
+ <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
462
+ <frontend_type>select</frontend_type>
463
+ <source_model>adminhtml/system_config_source_yesno</source_model>
464
+ <sort_order>23</sort_order>
465
+ <show_in_default>1</show_in_default>
466
+ <show_in_website>1</show_in_website>
467
+ <show_in_store>1</show_in_store>
468
+ </deliver_on_saturday>
469
+ <!--<showmethod translate="label">
470
+ <label>Show Method if Not Applicable</label>
471
+ <frontend_type>select</frontend_type>
472
+ <sort_order>30</sort_order>
473
+ <frontend_class>shipping-skip-hide</frontend_class>
474
+ <source_model>adminhtml/system_config_source_yesno</source_model>
475
+ <show_in_default>1</show_in_default>
476
+ <show_in_website>1</show_in_website>
477
+ <show_in_store>0</show_in_store>
478
+ </showmethod>
479
+ <specificerrmsg translate="label">
480
+ <label>Displayed Error Message</label>
481
+ <frontend_type>textarea</frontend_type>
482
+ <sort_order>31</sort_order>
483
+ <show_in_default>1</show_in_default>
484
+ <show_in_website>1</show_in_website>
485
+ <show_in_store>1</show_in_store>
486
+ </specificerrmsg>-->
487
+ <sort_order translate="label">
488
+ <label>Sort order</label>
489
+ <frontend_type>text</frontend_type>
490
+ <sort_order>100</sort_order>
491
+ <show_in_default>1</show_in_default>
492
+ <show_in_website>1</show_in_website>
493
+ <show_in_store>1</show_in_store>
494
+ </sort_order>
495
+ </fields>
496
+ </chronorelais>
497
+
498
+ <!-- C10 Livraison avant 10H -->
499
+ <chronopostc10 translate="label">
500
+ <label>Chronopost C10</label>
501
+ <frontend_type>text</frontend_type>
502
+ <sort_order>23</sort_order>
503
+ <show_in_default>1</show_in_default>
504
+ <show_in_website>1</show_in_website>
505
+ <show_in_store>1</show_in_store>
506
+ <fields>
507
+ <active translate="label">
508
+ <label>Enabled</label>
509
+ <frontend_type>select</frontend_type>
510
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
511
+ <source_model>adminhtml/system_config_source_yesno</source_model>
512
+ <sort_order>1</sort_order>
513
+ <show_in_default>1</show_in_default>
514
+ <show_in_website>1</show_in_website>
515
+ <show_in_store>1</show_in_store>
516
+ </active>
517
+ <title translate="label">
518
+ <label>Title</label>
519
+ <frontend_type>text</frontend_type>
520
+ <sort_order>2</sort_order>
521
+ <show_in_default>1</show_in_default>
522
+ <show_in_website>1</show_in_website>
523
+ <show_in_store>1</show_in_store>
524
+ </title>
525
+ <config translate="label">
526
+ <label>Configuration</label>
527
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
528
+ <comment>{configuration_syntax_help}</comment>
529
+ <frontend_type>textarea</frontend_type>
530
+ <sort_order>3</sort_order>
531
+ <show_in_default>1</show_in_default>
532
+ <show_in_website>1</show_in_website>
533
+ <show_in_store>1</show_in_store>
534
+ </config>
535
+ <weight_limit translate="label">
536
+ <label>Weight Limit</label>
537
+ <frontend_type>text</frontend_type>
538
+ <comment>in Kg</comment>
539
+ <sort_order>7</sort_order>
540
+ <show_in_default>1</show_in_default>
541
+ <show_in_website>1</show_in_website>
542
+ <show_in_store>1</show_in_store>
543
+ </weight_limit>
544
+ <quickcost translate="label">
545
+ <label>Quickcost</label>
546
+ <frontend_type>select</frontend_type>
547
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
548
+ <source_model>adminhtml/system_config_source_yesno</source_model>
549
+ <sort_order>10</sort_order>
550
+ <show_in_default>1</show_in_default>
551
+ <show_in_website>1</show_in_website>
552
+ <show_in_store>0</show_in_store>
553
+ </quickcost>
554
+ <quickcost_url>
555
+ <label>Quickcost Url</label>
556
+ <frontend_type>text</frontend_type>
557
+ <sort_order>11</sort_order>
558
+ <show_in_default>1</show_in_default>
559
+ <show_in_website>1</show_in_website>
560
+ <show_in_store>0</show_in_store>
561
+ </quickcost_url>
562
+ <free_shipping_enable translate="label">
563
+ <label>Free Shipping on the Amount</label>
564
+ <frontend_type>select</frontend_type>
565
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
566
+ <sort_order>12</sort_order>
567
+ <show_in_default>1</show_in_default>
568
+ <show_in_website>1</show_in_website>
569
+ <show_in_store>1</show_in_store>
570
+ </free_shipping_enable>
571
+ <free_shipping_subtotal translate="label">
572
+ <label>Minimum Amount for Free Shipping</label>
573
+ <frontend_type>text</frontend_type>
574
+ <sort_order>13</sort_order>
575
+ <show_in_default>1</show_in_default>
576
+ <show_in_website>1</show_in_website>
577
+ <show_in_store>0</show_in_store>
578
+ </free_shipping_subtotal>
579
+ <application_fee translate="label">
580
+ <label>Application Fee</label>
581
+ <frontend_type>text</frontend_type>
582
+ <sort_order>14</sort_order>
583
+ <show_in_default>1</show_in_default>
584
+ <show_in_website>1</show_in_website>
585
+ <show_in_store>1</show_in_store>
586
+ </application_fee>
587
+ <handling_fee translate="label">
588
+ <label>Handling Fee</label>
589
+ <frontend_type>text</frontend_type>
590
+ <sort_order>15</sort_order>
591
+ <show_in_default>1</show_in_default>
592
+ <show_in_website>1</show_in_website>
593
+ <show_in_store>1</show_in_store>
594
+ </handling_fee>
595
+ <logo_url>
596
+ <label>Logo Url</label>
597
+ <frontend_type>text</frontend_type>
598
+ <comment>{logo_ulr_help}</comment>
599
+ <sort_order>18</sort_order>
600
+ <show_in_default>1</show_in_default>
601
+ <show_in_website>1</show_in_website>
602
+ <show_in_store>1</show_in_store>
603
+ </logo_url>
604
+ <debug>
605
+ <label>Debug</label>
606
+ <comment>{debug_help}</comment>
607
+ <frontend_type>text</frontend_type>
608
+ <sort_order>20</sort_order>
609
+ <show_in_default>1</show_in_default>
610
+ <show_in_website>1</show_in_website>
611
+ <show_in_store>1</show_in_store>
612
+ </debug>
613
+ <!--<stop_to_first_match translate="label">
614
+ <label>Stop to first match</label>
615
+ <frontend_type>select</frontend_type>
616
+ <source_model>adminhtml/system_config_source_yesno</source_model>
617
+ <sort_order>22</sort_order>
618
+ <show_in_default>1</show_in_default>
619
+ <show_in_website>1</show_in_website>
620
+ <show_in_store>1</show_in_store>
621
+ </stop_to_first_match>-->
622
+ <deliver_on_saturday translate="label comment">
623
+ <label>Livraison le Samedi</label>
624
+ <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
625
+ <frontend_type>select</frontend_type>
626
+ <source_model>adminhtml/system_config_source_yesno</source_model>
627
+ <sort_order>23</sort_order>
628
+ <show_in_default>1</show_in_default>
629
+ <show_in_website>1</show_in_website>
630
+ <show_in_store>1</show_in_store>
631
+ </deliver_on_saturday>
632
+ <!--<showmethod translate="label">
633
+ <label>Show Method if Not Applicable</label>
634
+ <frontend_type>select</frontend_type>
635
+ <sort_order>30</sort_order>
636
+ <frontend_class>shipping-skip-hide</frontend_class>
637
+ <source_model>adminhtml/system_config_source_yesno</source_model>
638
+ <show_in_default>1</show_in_default>
639
+ <show_in_website>1</show_in_website>
640
+ <show_in_store>0</show_in_store>
641
+ </showmethod>
642
+ <specificerrmsg translate="label">
643
+ <label>Displayed Error Message</label>
644
+ <frontend_type>textarea</frontend_type>
645
+ <sort_order>31</sort_order>
646
+ <show_in_default>1</show_in_default>
647
+ <show_in_website>1</show_in_website>
648
+ <show_in_store>1</show_in_store>
649
+ </specificerrmsg>-->
650
+ <sort_order translate="label">
651
+ <label>Sort order</label>
652
+ <frontend_type>text</frontend_type>
653
+ <sort_order>100</sort_order>
654
+ <show_in_default>1</show_in_default>
655
+ <show_in_website>1</show_in_website>
656
+ <show_in_store>1</show_in_store>
657
+ </sort_order>
658
+ </fields>
659
+ </chronopostc10>
660
+
661
+ <!-- C18 Livraison avant 18H -->
662
+ <chronopostc18 translate="label">
663
+ <label>Chronopost C18</label>
664
+ <frontend_type>text</frontend_type>
665
+ <sort_order>24</sort_order>
666
+ <show_in_default>1</show_in_default>
667
+ <show_in_website>1</show_in_website>
668
+ <show_in_store>1</show_in_store>
669
+ <fields>
670
+ <active translate="label">
671
+ <label>Enabled</label>
672
+ <frontend_type>select</frontend_type>
673
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
674
+ <source_model>adminhtml/system_config_source_yesno</source_model>
675
+ <sort_order>1</sort_order>
676
+ <show_in_default>1</show_in_default>
677
+ <show_in_website>1</show_in_website>
678
+ <show_in_store>1</show_in_store>
679
+ </active>
680
+ <title translate="label">
681
+ <label>Title</label>
682
+ <frontend_type>text</frontend_type>
683
+ <sort_order>2</sort_order>
684
+ <show_in_default>1</show_in_default>
685
+ <show_in_website>1</show_in_website>
686
+ <show_in_store>1</show_in_store>
687
+ </title>
688
+ <config translate="label">
689
+ <label>Configuration</label>
690
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
691
+ <comment>{configuration_syntax_help}</comment>
692
+ <frontend_type>textarea</frontend_type>
693
+ <sort_order>3</sort_order>
694
+ <show_in_default>1</show_in_default>
695
+ <show_in_website>1</show_in_website>
696
+ <show_in_store>1</show_in_store>
697
+ </config>
698
+ <weight_limit translate="label">
699
+ <label>Weight Limit</label>
700
+ <frontend_type>text</frontend_type>
701
+ <comment>in Kg</comment>
702
+ <sort_order>7</sort_order>
703
+ <show_in_default>1</show_in_default>
704
+ <show_in_website>1</show_in_website>
705
+ <show_in_store>1</show_in_store>
706
+ </weight_limit>
707
+ <quickcost translate="label">
708
+ <label>Quickcost</label>
709
+ <frontend_type>select</frontend_type>
710
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
711
+ <source_model>adminhtml/system_config_source_yesno</source_model>
712
+ <sort_order>10</sort_order>
713
+ <show_in_default>0</show_in_default>
714
+ <show_in_website>0</show_in_website>
715
+ <show_in_store>0</show_in_store>
716
+ </quickcost>
717
+ <quickcost_url>
718
+ <label>Quickcost Url</label>
719
+ <frontend_type>text</frontend_type>
720
+ <sort_order>11</sort_order>
721
+ <show_in_default>0</show_in_default>
722
+ <show_in_website>0</show_in_website>
723
+ <show_in_store>0</show_in_store>
724
+ </quickcost_url>
725
+ <free_shipping_enable translate="label">
726
+ <label>Free Shipping on the Amount</label>
727
+ <frontend_type>select</frontend_type>
728
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
729
+ <sort_order>12</sort_order>
730
+ <show_in_default>1</show_in_default>
731
+ <show_in_website>1</show_in_website>
732
+ <show_in_store>1</show_in_store>
733
+ </free_shipping_enable>
734
+ <free_shipping_subtotal translate="label">
735
+ <label>Minimum Amount for Free Shipping</label>
736
+ <frontend_type>text</frontend_type>
737
+ <sort_order>13</sort_order>
738
+ <show_in_default>1</show_in_default>
739
+ <show_in_website>1</show_in_website>
740
+ <show_in_store>0</show_in_store>
741
+ </free_shipping_subtotal>
742
+ <application_fee translate="label">
743
+ <label>Application Fee</label>
744
+ <frontend_type>text</frontend_type>
745
+ <sort_order>14</sort_order>
746
+ <show_in_default>1</show_in_default>
747
+ <show_in_website>1</show_in_website>
748
+ <show_in_store>1</show_in_store>
749
+ </application_fee>
750
+ <handling_fee translate="label">
751
+ <label>Handling Fee</label>
752
+ <frontend_type>text</frontend_type>
753
+ <sort_order>15</sort_order>
754
+ <show_in_default>1</show_in_default>
755
+ <show_in_website>1</show_in_website>
756
+ <show_in_store>1</show_in_store>
757
+ </handling_fee>
758
+ <logo_url>
759
+ <label>Logo Url</label>
760
+ <frontend_type>text</frontend_type>
761
+ <comment>{logo_ulr_help}</comment>
762
+ <sort_order>18</sort_order>
763
+ <show_in_default>1</show_in_default>
764
+ <show_in_website>1</show_in_website>
765
+ <show_in_store>1</show_in_store>
766
+ </logo_url>
767
+ <debug>
768
+ <label>Debug</label>
769
+ <comment>{debug_help}</comment>
770
+ <frontend_type>text</frontend_type>
771
+ <sort_order>20</sort_order>
772
+ <show_in_default>1</show_in_default>
773
+ <show_in_website>1</show_in_website>
774
+ <show_in_store>1</show_in_store>
775
+ </debug>
776
+ <!--<stop_to_first_match translate="label">
777
+ <label>Stop to first match</label>
778
+ <frontend_type>select</frontend_type>
779
+ <source_model>adminhtml/system_config_source_yesno</source_model>
780
+ <sort_order>22</sort_order>
781
+ <show_in_default>1</show_in_default>
782
+ <show_in_website>1</show_in_website>
783
+ <show_in_store>1</show_in_store>
784
+ </stop_to_first_match>-->
785
+ <deliver_on_saturday translate="label comment">
786
+ <label>Livraison le Samedi</label>
787
+ <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
788
+ <frontend_type>select</frontend_type>
789
+ <source_model>adminhtml/system_config_source_yesno</source_model>
790
+ <sort_order>23</sort_order>
791
+ <show_in_default>1</show_in_default>
792
+ <show_in_website>1</show_in_website>
793
+ <show_in_store>1</show_in_store>
794
+ </deliver_on_saturday>
795
+ <!--<showmethod translate="label">
796
+ <label>Show Method if Not Applicable</label>
797
+ <frontend_type>select</frontend_type>
798
+ <sort_order>30</sort_order>
799
+ <frontend_class>shipping-skip-hide</frontend_class>
800
+ <source_model>adminhtml/system_config_source_yesno</source_model>
801
+ <show_in_default>1</show_in_default>
802
+ <show_in_website>1</show_in_website>
803
+ <show_in_store>0</show_in_store>
804
+ </showmethod>
805
+ <specificerrmsg translate="label">
806
+ <label>Displayed Error Message</label>
807
+ <frontend_type>textarea</frontend_type>
808
+ <sort_order>31</sort_order>
809
+ <show_in_default>1</show_in_default>
810
+ <show_in_website>1</show_in_website>
811
+ <show_in_store>1</show_in_store>
812
+ </specificerrmsg>-->
813
+ <sort_order translate="label">
814
+ <label>Sort order</label>
815
+ <frontend_type>text</frontend_type>
816
+ <sort_order>100</sort_order>
817
+ <show_in_default>1</show_in_default>
818
+ <show_in_website>1</show_in_website>
819
+ <show_in_store>1</show_in_store>
820
+ </sort_order>
821
+ </fields>
822
+ </chronopostc18>
823
+
824
+ <!-- CClassic Livraison dans certaines villes Européennes -->
825
+ <chronopostcclassic translate="label">
826
+ <label>Chronopost CClassic</label>
827
+ <frontend_type>text</frontend_type>
828
+ <sort_order>25</sort_order>
829
+ <show_in_default>1</show_in_default>
830
+ <show_in_website>1</show_in_website>
831
+ <show_in_store>1</show_in_store>
832
+ <fields>
833
+ <active translate="label">
834
+ <label>Enabled</label>
835
+ <frontend_type>select</frontend_type>
836
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
837
+ <source_model>adminhtml/system_config_source_yesno</source_model>
838
+ <sort_order>1</sort_order>
839
+ <show_in_default>1</show_in_default>
840
+ <show_in_website>1</show_in_website>
841
+ <show_in_store>1</show_in_store>
842
+ </active>
843
+ <title translate="label">
844
+ <label>Title</label>
845
+ <frontend_type>text</frontend_type>
846
+ <sort_order>2</sort_order>
847
+ <show_in_default>1</show_in_default>
848
+ <show_in_website>1</show_in_website>
849
+ <show_in_store>1</show_in_store>
850
+ </title>
851
+ <config translate="label">
852
+ <label>Configuration</label>
853
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
854
+ <comment>{configuration_syntax_help}</comment>
855
+ <frontend_type>textarea</frontend_type>
856
+ <sort_order>3</sort_order>
857
+ <show_in_default>1</show_in_default>
858
+ <show_in_website>1</show_in_website>
859
+ <show_in_store>1</show_in_store>
860
+ </config>
861
+ <weight_limit translate="label">
862
+ <label>Weight Limit</label>
863
+ <frontend_type>text</frontend_type>
864
+ <comment>in Kg</comment>
865
+ <sort_order>7</sort_order>
866
+ <show_in_default>1</show_in_default>
867
+ <show_in_website>1</show_in_website>
868
+ <show_in_store>1</show_in_store>
869
+ </weight_limit>
870
+ <quickcost translate="label">
871
+ <label>Quickcost</label>
872
+ <frontend_type>select</frontend_type>
873
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
874
+ <source_model>adminhtml/system_config_source_yesno</source_model>
875
+ <sort_order>10</sort_order>
876
+ <show_in_default>1</show_in_default>
877
+ <show_in_website>1</show_in_website>
878
+ <show_in_store>0</show_in_store>
879
+ </quickcost>
880
+ <quickcost_url>
881
+ <label>Quickcost Url</label>
882
+ <frontend_type>text</frontend_type>
883
+ <sort_order>11</sort_order>
884
+ <show_in_default>1</show_in_default>
885
+ <show_in_website>1</show_in_website>
886
+ <show_in_store>0</show_in_store>
887
+ </quickcost_url>
888
+ <free_shipping_enable translate="label">
889
+ <label>Free Shipping on the Amount</label>
890
+ <frontend_type>select</frontend_type>
891
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
892
+ <sort_order>12</sort_order>
893
+ <show_in_default>1</show_in_default>
894
+ <show_in_website>1</show_in_website>
895
+ <show_in_store>1</show_in_store>
896
+ </free_shipping_enable>
897
+ <free_shipping_subtotal translate="label">
898
+ <label>Minimum Amount for Free Shipping</label>
899
+ <frontend_type>text</frontend_type>
900
+ <sort_order>13</sort_order>
901
+ <show_in_default>1</show_in_default>
902
+ <show_in_website>1</show_in_website>
903
+ <show_in_store>0</show_in_store>
904
+ </free_shipping_subtotal>
905
+ <application_fee translate="label">
906
+ <label>Application Fee</label>
907
+ <frontend_type>text</frontend_type>
908
+ <sort_order>14</sort_order>
909
+ <show_in_default>1</show_in_default>
910
+ <show_in_website>1</show_in_website>
911
+ <show_in_store>1</show_in_store>
912
+ </application_fee>
913
+ <handling_fee translate="label">
914
+ <label>Handling Fee</label>
915
+ <frontend_type>text</frontend_type>
916
+ <sort_order>15</sort_order>
917
+ <show_in_default>1</show_in_default>
918
+ <show_in_website>1</show_in_website>
919
+ <show_in_store>1</show_in_store>
920
+ </handling_fee>
921
+ <logo_url>
922
+ <label>Logo Url</label>
923
+ <frontend_type>text</frontend_type>
924
+ <comment>{logo_ulr_help}</comment>
925
+ <sort_order>18</sort_order>
926
+ <show_in_default>1</show_in_default>
927
+ <show_in_website>1</show_in_website>
928
+ <show_in_store>1</show_in_store>
929
+ </logo_url>
930
+ <debug>
931
+ <label>Debug</label>
932
+ <comment>{debug_help}</comment>
933
+ <frontend_type>text</frontend_type>
934
+ <sort_order>20</sort_order>
935
+ <show_in_default>1</show_in_default>
936
+ <show_in_website>1</show_in_website>
937
+ <show_in_store>1</show_in_store>
938
+ </debug>
939
+ <!--<stop_to_first_match translate="label">
940
+ <label>Stop to first match</label>
941
+ <frontend_type>select</frontend_type>
942
+ <source_model>adminhtml/system_config_source_yesno</source_model>
943
+ <sort_order>22</sort_order>
944
+ <show_in_default>1</show_in_default>
945
+ <show_in_website>1</show_in_website>
946
+ <show_in_store>1</show_in_store>
947
+ </stop_to_first_match>-->
948
+ <deliver_on_saturday translate="label comment">
949
+ <label>Livraison le Samedi</label>
950
+ <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
951
+ <frontend_type>select</frontend_type>
952
+ <source_model>adminhtml/system_config_source_yesno</source_model>
953
+ <sort_order>23</sort_order>
954
+ <show_in_default>1</show_in_default>
955
+ <show_in_website>1</show_in_website>
956
+ <show_in_store>1</show_in_store>
957
+ </deliver_on_saturday>
958
+ <!--<showmethod translate="label">
959
+ <label>Show Method if Not Applicable</label>
960
+ <frontend_type>select</frontend_type>
961
+ <sort_order>30</sort_order>
962
+ <frontend_class>shipping-skip-hide</frontend_class>
963
+ <source_model>adminhtml/system_config_source_yesno</source_model>
964
+ <show_in_default>1</show_in_default>
965
+ <show_in_website>1</show_in_website>
966
+ <show_in_store>0</show_in_store>
967
+ </showmethod>
968
+ <specificerrmsg translate="label">
969
+ <label>Displayed Error Message</label>
970
+ <frontend_type>textarea</frontend_type>
971
+ <sort_order>31</sort_order>
972
+ <show_in_default>1</show_in_default>
973
+ <show_in_website>1</show_in_website>
974
+ <show_in_store>1</show_in_store>
975
+ </specificerrmsg>-->
976
+ <sort_order translate="label">
977
+ <label>Sort order</label>
978
+ <frontend_type>text</frontend_type>
979
+ <sort_order>100</sort_order>
980
+ <show_in_default>1</show_in_default>
981
+ <show_in_website>1</show_in_website>
982
+ <show_in_store>1</show_in_store>
983
+ </sort_order>
984
+ </fields>
985
+ </chronopostcclassic>
986
+
987
+ </groups>
988
+ </carriers>
989
+ </sections>
990
+
991
+ <sections>
992
+ <chronorelais>
993
+ <label>Configuration</label>
994
+ <tab>chronopost</tab>
995
+ <frontend_type>text</frontend_type>
996
+ <sort_order>2000</sort_order>
997
+ <show_in_default>1</show_in_default>
998
+ <show_in_website>1</show_in_website>
999
+ <show_in_store>1</show_in_store>
1000
+ <groups>
1001
+ <shipping translate="label">
1002
+ <label>General</label>
1003
+ <frontend_type>text</frontend_type>
1004
+ <sort_order>10</sort_order>
1005
+ <show_in_default>1</show_in_default>
1006
+ <show_in_website>1</show_in_website>
1007
+ <show_in_store>1</show_in_store>
1008
+ <fields>
1009
+ <account_number translate="label">
1010
+ <label> de compte Chronopost</label>
1011
+ <frontend_type>text</frontend_type>
1012
+ <sort_order>7</sort_order>
1013
+ <show_in_default>1</show_in_default>
1014
+ <show_in_website>1</show_in_website>
1015
+ <show_in_store>1</show_in_store>
1016
+ </account_number>
1017
+ <sub_account_number translate="label">
1018
+ <label> de sous-compte</label>
1019
+ <comment>must be 3 digits or empty</comment>
1020
+ <frontend_type>text</frontend_type>
1021
+ <sort_order>8</sort_order>
1022
+ <show_in_default>1</show_in_default>
1023
+ <show_in_website>1</show_in_website>
1024
+ <show_in_store>1</show_in_store>
1025
+ </sub_account_number>
1026
+ <account_pass translate="label">
1027
+ <label>Mot de passe Chronopost</label>
1028
+ <frontend_type>text</frontend_type>
1029
+ <button_label>Vérifier mes identifiants</button_label>
1030
+ <frontend_model>chronorelais/adminhtml_system_config_checklogin</frontend_model>
1031
+ <sort_order>9</sort_order>
1032
+ <show_in_default>1</show_in_default>
1033
+ <show_in_website>1</show_in_website>
1034
+ <show_in_store>1</show_in_store>
1035
+ </account_pass>
1036
+ <google_map_api translate="label">
1037
+ <label>Google Map v3 API Key</label>
1038
+ <comment>The Google Maps JavaScript API Version 2 has been officially deprecated. Please use v3 API now. Get your key at https://code.google.com/apis/console/.</comment>
1039
+ <frontend_type>text</frontend_type>
1040
+ <sort_order>10</sort_order>
1041
+ <show_in_default>1</show_in_default>
1042
+ <show_in_website>1</show_in_website>
1043
+ <show_in_store>1</show_in_store>
1044
+ </google_map_api>
1045
+ <tracking_view_url translate="label">
1046
+ <label>Tracking URL</label>
1047
+ <comment>For English language, replace fr_FR with en_GB in the above url</comment>
1048
+ <frontend_type>text</frontend_type>
1049
+ <sort_order>20</sort_order>
1050
+ <show_in_default>1</show_in_default>
1051
+ <show_in_website>1</show_in_website>
1052
+ <show_in_store>1</show_in_store>
1053
+ </tracking_view_url>
1054
+ <gs_path translate="label">
1055
+ <label>Chemin GS</label>
1056
+ <comment>Chemin d'accès à la commande gs (Ghostscript)</comment>
1057
+ <frontend_type>text</frontend_type>
1058
+ <sort_order>21</sort_order>
1059
+ <show_in_default>1</show_in_default>
1060
+ <show_in_website>0</show_in_website>
1061
+ <show_in_store>0</show_in_store>
1062
+ </gs_path>
1063
+
1064
+ </fields>
1065
+ </shipping>
1066
+ <export_css translate="label">
1067
+ <label>Export Configuration CSS</label>
1068
+ <frontend_type>text</frontend_type>
1069
+ <sort_order>20</sort_order>
1070
+ <show_in_default>1</show_in_default>
1071
+ <show_in_website>1</show_in_website>
1072
+ <show_in_store>1</show_in_store>
1073
+ <fields>
1074
+ <file_extension translate="label">
1075
+ <label>File Extension</label>
1076
+ <frontend_type>select</frontend_type>
1077
+ <source_model>chronorelais/config_source_fileExtension</source_model>
1078
+ <sort_order>10</sort_order>
1079
+ <show_in_default>1</show_in_default>
1080
+ <show_in_website>1</show_in_website>
1081
+ <show_in_store>1</show_in_store>
1082
+ </file_extension>
1083
+ <file_charset translate="label">
1084
+ <label>File Charset</label>
1085
+ <frontend_type>select</frontend_type>
1086
+ <source_model>chronorelais/config_source_fileCharset</source_model>
1087
+ <sort_order>20</sort_order>
1088
+ <show_in_default>1</show_in_default>
1089
+ <show_in_website>1</show_in_website>
1090
+ <show_in_store>1</show_in_store>
1091
+ </file_charset>
1092
+ <endofline_character translate="label">
1093
+ <label>End Of Line Character</label>
1094
+ <frontend_type>select</frontend_type>
1095
+ <source_model>chronorelais/config_source_endOfLineCharacter</source_model>
1096
+ <sort_order>30</sort_order>
1097
+ <show_in_default>1</show_in_default>
1098
+ <show_in_website>1</show_in_website>
1099
+ <show_in_store>1</show_in_store>
1100
+ </endofline_character>
1101
+ <field_delimiter translate="label">
1102
+ <label>Field Delimiter</label>
1103
+ <frontend_type>select</frontend_type>
1104
+ <source_model>chronorelais/config_source_fieldDelimiter</source_model>
1105
+ <sort_order>40</sort_order>
1106
+ <show_in_default>1</show_in_default>
1107
+ <show_in_website>1</show_in_website>
1108
+ <show_in_store>1</show_in_store>
1109
+ </field_delimiter>
1110
+ <field_separator translate="label">
1111
+ <label>Field Separator</label>
1112
+ <frontend_type>select</frontend_type>
1113
+ <source_model>chronorelais/config_source_fieldSeparator</source_model>
1114
+ <sort_order>50</sort_order>
1115
+ <show_in_default>1</show_in_default>
1116
+ <show_in_website>1</show_in_website>
1117
+ <show_in_store>1</show_in_store>
1118
+ </field_separator>
1119
+ </fields>
1120
+ </export_css>
1121
+ <export_cso translate="label">
1122
+ <label>Export Configuration CSO</label>
1123
+ <frontend_type>text</frontend_type>
1124
+ <sort_order>21</sort_order>
1125
+ <show_in_default>1</show_in_default>
1126
+ <show_in_website>1</show_in_website>
1127
+ <show_in_store>1</show_in_store>
1128
+ <fields>
1129
+ <file_extension translate="label">
1130
+ <label>File Extension</label>
1131
+ <frontend_type>select</frontend_type>
1132
+ <source_model>chronorelais/config_source_fileExtension</source_model>
1133
+ <sort_order>10</sort_order>
1134
+ <show_in_default>1</show_in_default>
1135
+ <show_in_website>1</show_in_website>
1136
+ <show_in_store>1</show_in_store>
1137
+ </file_extension>
1138
+ <file_charset translate="label">
1139
+ <label>File Charset</label>
1140
+ <frontend_type>select</frontend_type>
1141
+ <source_model>chronorelais/config_source_fileCharset</source_model>
1142
+ <sort_order>20</sort_order>
1143
+ <show_in_default>1</show_in_default>
1144
+ <show_in_website>1</show_in_website>
1145
+ <show_in_store>1</show_in_store>
1146
+ </file_charset>
1147
+ <endofline_character translate="label">
1148
+ <label>End Of Line Character</label>
1149
+ <frontend_type>select</frontend_type>
1150
+ <source_model>chronorelais/config_source_endOfLineCharacter</source_model>
1151
+ <sort_order>30</sort_order>
1152
+ <show_in_default>1</show_in_default>
1153
+ <show_in_website>1</show_in_website>
1154
+ <show_in_store>1</show_in_store>
1155
+ </endofline_character>
1156
+ <field_delimiter translate="label">
1157
+ <label>Field Delimiter</label>
1158
+ <frontend_type>select</frontend_type>
1159
+ <source_model>chronorelais/config_source_fieldDelimiter</source_model>
1160
+ <sort_order>40</sort_order>
1161
+ <show_in_default>1</show_in_default>
1162
+ <show_in_website>1</show_in_website>
1163
+ <show_in_store>1</show_in_store>
1164
+ </field_delimiter>
1165
+ <field_separator translate="label">
1166
+ <label>Field Separator</label>
1167
+ <frontend_type>select</frontend_type>
1168
+ <source_model>chronorelais/config_source_fieldSeparator</source_model>
1169
+ <sort_order>50</sort_order>
1170
+ <show_in_default>1</show_in_default>
1171
+ <show_in_website>1</show_in_website>
1172
+ <show_in_store>1</show_in_store>
1173
+ </field_separator>
1174
+ </fields>
1175
+ </export_cso>
1176
+ <import translate="label">
1177
+ <label>Import Configuration</label>
1178
+ <frontend_type>text</frontend_type>
1179
+ <sort_order>30</sort_order>
1180
+ <show_in_default>1</show_in_default>
1181
+ <show_in_website>1</show_in_website>
1182
+ <show_in_store>1</show_in_store>
1183
+ <fields>
1184
+ <default_tracking_title translate="label comment">
1185
+ <label>Default Tracking Title</label>
1186
+ <frontend_type>text</frontend_type>
1187
+ <sort_order>10</sort_order>
1188
+ <show_in_default>1</show_in_default>
1189
+ <show_in_website>1</show_in_website>
1190
+ <show_in_store>1</show_in_store>
1191
+ <comment>This value can be changed in the import form</comment>
1192
+ </default_tracking_title>
1193
+ <send_email translate="label comment">
1194
+ <label>Send an e-mail</label>
1195
+ <frontend_type>select</frontend_type>
1196
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1197
+ <sort_order>20</sort_order>
1198
+ <show_in_default>1</show_in_default>
1199
+ <show_in_website>1</show_in_website>
1200
+ <show_in_store>1</show_in_store>
1201
+ <comment>Send shipping confirmation to the customer</comment>
1202
+ </send_email>
1203
+ <shipping_comment translate="label comment">
1204
+ <label>Shipping Comment</label>
1205
+ <frontend_type>text</frontend_type>
1206
+ <sort_order>30</sort_order>
1207
+ <show_in_default>1</show_in_default>
1208
+ <show_in_website>1</show_in_website>
1209
+ <show_in_store>1</show_in_store>
1210
+ <comment>Internal comment, can be left empty</comment>
1211
+ </shipping_comment>
1212
+ <include_comment translate="label comment">
1213
+ <label>Include comment into e-mail</label>
1214
+ <frontend_type>select</frontend_type>
1215
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1216
+ <sort_order>40</sort_order>
1217
+ <show_in_default>1</show_in_default>
1218
+ <show_in_website>1</show_in_website>
1219
+ <show_in_store>1</show_in_store>
1220
+ <comment>Only applies if the shipping comment is set</comment>
1221
+ </include_comment>
1222
+ </fields>
1223
+ </import>
1224
+
1225
+ <shipperinformation translate="label">
1226
+ <label>Shipper Information for Labels printing</label>
1227
+ <frontend_type>text</frontend_type>
1228
+ <sort_order>40</sort_order>
1229
+ <show_in_default>1</show_in_default>
1230
+ <show_in_website>1</show_in_website>
1231
+ <show_in_store>1</show_in_store>
1232
+ <fields>
1233
+ <civility translate="label">
1234
+ <label>Shipper Civility</label>
1235
+ <frontend_type>select</frontend_type>
1236
+ <source_model>chronorelais/config_source_civility</source_model>
1237
+ <sort_order>10</sort_order>
1238
+ <show_in_default>1</show_in_default>
1239
+ <show_in_website>1</show_in_website>
1240
+ <show_in_store>1</show_in_store>
1241
+ </civility>
1242
+ <name translate="label comment">
1243
+ <label>Shipper Name</label>
1244
+ <frontend_type>text</frontend_type>
1245
+ <sort_order>20</sort_order>
1246
+ <show_in_default>1</show_in_default>
1247
+ <show_in_website>1</show_in_website>
1248
+ <show_in_store>1</show_in_store>
1249
+ <comment>Company name</comment>
1250
+ </name>
1251
+ <name2 translate="label comment">
1252
+ <label>Shipper Name2</label>
1253
+ <frontend_type>text</frontend_type>
1254
+ <sort_order>30</sort_order>
1255
+ <show_in_default>1</show_in_default>
1256
+ <show_in_website>1</show_in_website>
1257
+ <show_in_store>1</show_in_store>
1258
+ <comment>[Optional]</comment>
1259
+ </name2>
1260
+ <address1 translate="label">
1261
+ <label>Shipper Address1</label>
1262
+ <frontend_type>text</frontend_type>
1263
+ <sort_order>40</sort_order>
1264
+ <show_in_default>1</show_in_default>
1265
+ <show_in_website>1</show_in_website>
1266
+ <show_in_store>1</show_in_store>
1267
+ </address1>
1268
+ <address2 translate="label comment">
1269
+ <label>Shipper Address2</label>
1270
+ <frontend_type>text</frontend_type>
1271
+ <sort_order>50</sort_order>
1272
+ <show_in_default>1</show_in_default>
1273
+ <show_in_website>1</show_in_website>
1274
+ <show_in_store>1</show_in_store>
1275
+ <comment>[Optional]</comment>
1276
+ </address2>
1277
+ <zipcode translate="label">
1278
+ <label>Shipper Zipcode</label>
1279
+ <frontend_type>text</frontend_type>
1280
+ <sort_order>60</sort_order>
1281
+ <show_in_default>1</show_in_default>
1282
+ <show_in_website>1</show_in_website>
1283
+ <show_in_store>1</show_in_store>
1284
+ </zipcode>
1285
+ <city translate="label">
1286
+ <label>Shipper City</label>
1287
+ <frontend_type>text</frontend_type>
1288
+ <sort_order>70</sort_order>
1289
+ <show_in_default>1</show_in_default>
1290
+ <show_in_website>1</show_in_website>
1291
+ <show_in_store>1</show_in_store>
1292
+ </city>
1293
+ <country translate="label">
1294
+ <label>Shipper Country</label>
1295
+ <frontend_type>select</frontend_type>
1296
+ <sort_order>80</sort_order>
1297
+ <source_model>adminhtml/system_config_source_country</source_model>
1298
+ <show_in_default>1</show_in_default>
1299
+ <show_in_website>1</show_in_website>
1300
+ <show_in_store>1</show_in_store>
1301
+ </country>
1302
+ <contactname translate="label">
1303
+ <label>Shipper Contact Name</label>
1304
+ <frontend_type>text</frontend_type>
1305
+ <sort_order>90</sort_order>
1306
+ <show_in_default>1</show_in_default>
1307
+ <show_in_website>1</show_in_website>
1308
+ <show_in_store>1</show_in_store>
1309
+ </contactname>
1310
+ <email translate="label">
1311
+ <label>Shipper Email</label>
1312
+ <frontend_type>text</frontend_type>
1313
+ <sort_order>100</sort_order>
1314
+ <show_in_default>1</show_in_default>
1315
+ <show_in_website>1</show_in_website>
1316
+ <show_in_store>1</show_in_store>
1317
+ <comment>[Optional]</comment>
1318
+ </email>
1319
+ <phone translate="label comment">
1320
+ <label>Shipper Telephone</label>
1321
+ <frontend_type>text</frontend_type>
1322
+ <sort_order>110</sort_order>
1323
+ <show_in_default>1</show_in_default>
1324
+ <show_in_website>1</show_in_website>
1325
+ <show_in_store>1</show_in_store>
1326
+ <comment>[Optional]</comment>
1327
+ </phone>
1328
+ <mobilephone translate="label comment">
1329
+ <label>Shipper Mobile</label>
1330
+ <frontend_type>text</frontend_type>
1331
+ <sort_order>120</sort_order>
1332
+ <show_in_default>1</show_in_default>
1333
+ <show_in_website>1</show_in_website>
1334
+ <show_in_store>1</show_in_store>
1335
+ <comment>[Optional]</comment>
1336
+ </mobilephone>
1337
+ </fields>
1338
+ </shipperinformation>
1339
+
1340
+ <customerinformation translate="label">
1341
+ <label>Chronopost Customer Account Information for Labels printing</label>
1342
+ <frontend_type>text</frontend_type>
1343
+ <sort_order>50</sort_order>
1344
+ <show_in_default>1</show_in_default>
1345
+ <show_in_website>1</show_in_website>
1346
+ <show_in_store>1</show_in_store>
1347
+ <fields>
1348
+ <civility translate="label">
1349
+ <label>Customer Civility</label>
1350
+ <frontend_type>select</frontend_type>
1351
+ <source_model>chronorelais/config_source_civility</source_model>
1352
+ <sort_order>10</sort_order>
1353
+ <show_in_default>1</show_in_default>
1354
+ <show_in_website>1</show_in_website>
1355
+ <show_in_store>1</show_in_store>
1356
+ </civility>
1357
+ <name translate="label comment">
1358
+ <label>Customer Name </label>
1359
+ <frontend_type>text</frontend_type>
1360
+ <sort_order>20</sort_order>
1361
+ <show_in_default>1</show_in_default>
1362
+ <show_in_website>1</show_in_website>
1363
+ <show_in_store>1</show_in_store>
1364
+ <comment>Company name</comment>
1365
+ </name>
1366
+ <name2 translate="label comment">
1367
+ <label>Customer Name2</label>
1368
+ <frontend_type>text</frontend_type>
1369
+ <sort_order>30</sort_order>
1370
+ <show_in_default>1</show_in_default>
1371
+ <show_in_website>1</show_in_website>
1372
+ <show_in_store>1</show_in_store>
1373
+ <comment>[Optional]</comment>
1374
+ </name2>
1375
+ <address1 translate="label">
1376
+ <label>Customer Address1</label>
1377
+ <frontend_type>text</frontend_type>
1378
+ <sort_order>40</sort_order>
1379
+ <show_in_default>1</show_in_default>
1380
+ <show_in_website>1</show_in_website>
1381
+ <show_in_store>1</show_in_store>
1382
+ </address1>
1383
+ <address2 translate="label comment">
1384
+ <label>Customer Address2</label>
1385
+ <frontend_type>text</frontend_type>
1386
+ <sort_order>50</sort_order>
1387
+ <show_in_default>1</show_in_default>
1388
+ <show_in_website>1</show_in_website>
1389
+ <show_in_store>1</show_in_store>
1390
+ <comment>[Optional]</comment>
1391
+ </address2>
1392
+ <zipcode translate="label">
1393
+ <label>Customer Zipcode</label>
1394
+ <frontend_type>text</frontend_type>
1395
+ <sort_order>60</sort_order>
1396
+ <show_in_default>1</show_in_default>
1397
+ <show_in_website>1</show_in_website>
1398
+ <show_in_store>1</show_in_store>
1399
+ </zipcode>
1400
+ <city translate="label">
1401
+ <label>Customer City</label>
1402
+ <frontend_type>text</frontend_type>
1403
+ <sort_order>70</sort_order>
1404
+ <show_in_default>1</show_in_default>
1405
+ <show_in_website>1</show_in_website>
1406
+ <show_in_store>1</show_in_store>
1407
+ </city>
1408
+ <country translate="label">
1409
+ <label>Customer Country</label>
1410
+ <frontend_type>select</frontend_type>
1411
+ <sort_order>80</sort_order>
1412
+ <source_model>adminhtml/system_config_source_country</source_model>
1413
+ <show_in_default>1</show_in_default>
1414
+ <show_in_website>1</show_in_website>
1415
+ <show_in_store>1</show_in_store>
1416
+ </country>
1417
+ <contactname translate="label">
1418
+ <label>Customer Contact Name</label>
1419
+ <frontend_type>text</frontend_type>
1420
+ <sort_order>90</sort_order>
1421
+ <show_in_default>1</show_in_default>
1422
+ <show_in_website>1</show_in_website>
1423
+ <show_in_store>1</show_in_store>
1424
+ </contactname>
1425
+ <email translate="label">
1426
+ <label>Customer Email</label>
1427
+ <frontend_type>text</frontend_type>
1428
+ <sort_order>100</sort_order>
1429
+ <show_in_default>1</show_in_default>
1430
+ <show_in_website>1</show_in_website>
1431
+ <show_in_store>1</show_in_store>
1432
+ <comment>[Optional]</comment>
1433
+ </email>
1434
+ <phone translate="label comment">
1435
+ <label>Customer Telephone</label>
1436
+ <frontend_type>text</frontend_type>
1437
+ <sort_order>110</sort_order>
1438
+ <show_in_default>1</show_in_default>
1439
+ <show_in_website>1</show_in_website>
1440
+ <show_in_store>1</show_in_store>
1441
+ <comment>[Optional]</comment>
1442
+ </phone>
1443
+ <mobilephone translate="label comment">
1444
+ <label>Customer Mobile</label>
1445
+ <frontend_type>text</frontend_type>
1446
+ <sort_order>120</sort_order>
1447
+ <show_in_default>1</show_in_default>
1448
+ <show_in_website>1</show_in_website>
1449
+ <show_in_store>1</show_in_store>
1450
+ <comment>[Optional]</comment>
1451
+ </mobilephone>
1452
+ </fields>
1453
+ </customerinformation>
1454
+
1455
+ <skybillparam translate="label">
1456
+ <label>Skybill Parameters for Labels printing</label>
1457
+ <frontend_type>text</frontend_type>
1458
+ <sort_order>60</sort_order>
1459
+ <show_in_default>1</show_in_default>
1460
+ <show_in_website>1</show_in_website>
1461
+ <show_in_store>1</show_in_store>
1462
+ <fields>
1463
+ <mode translate="label">
1464
+ <label>Print Mode</label>
1465
+ <frontend_type>select</frontend_type>
1466
+ <source_model>chronorelais/config_source_printMode</source_model>
1467
+ <sort_order>10</sort_order>
1468
+ <show_in_default>1</show_in_default>
1469
+ <show_in_website>1</show_in_website>
1470
+ <show_in_store>1</show_in_store>
1471
+ <required>1</required>
1472
+ </mode>
1473
+ </fields>
1474
+ </skybillparam>
1475
+
1476
+ <weightunit translate="label">
1477
+ <label>Weight unit for the store</label>
1478
+ <frontend_type>text</frontend_type>
1479
+ <sort_order>70</sort_order>
1480
+ <show_in_default>1</show_in_default>
1481
+ <show_in_website>1</show_in_website>
1482
+ <show_in_store>1</show_in_store>
1483
+ <fields>
1484
+ <unit translate="label">
1485
+ <label>Weight unit</label>
1486
+ <frontend_type>select</frontend_type>
1487
+ <source_model>chronorelais/config_source_weightUnit</source_model>
1488
+ <sort_order>10</sort_order>
1489
+ <show_in_default>1</show_in_default>
1490
+ <show_in_website>1</show_in_website>
1491
+ <show_in_store>1</show_in_store>
1492
+ <required>1</required>
1493
+ </unit>
1494
+ </fields>
1495
+ </weightunit>
1496
+
1497
+ <optionbal translate="label">
1498
+ <label>Option BAL</label>
1499
+ <frontend_type>text</frontend_type>
1500
+ <sort_order>80</sort_order>
1501
+ <show_in_default>1</show_in_default>
1502
+ <show_in_website>1</show_in_website>
1503
+ <show_in_store>1</show_in_store>
1504
+ <fields>
1505
+ <enabled translate="label">
1506
+ <label>Activer l'option BAL de Chronopost</label>
1507
+ <frontend_type>select</frontend_type>
1508
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1509
+ <comment>Vérifiez que cette option figure dans votre contrat</comment>
1510
+ <sort_order>10</sort_order>
1511
+ <show_in_default>1</show_in_default>
1512
+ <show_in_website>1</show_in_website>
1513
+ <show_in_store>1</show_in_store>
1514
+ <required>1</required>
1515
+ </enabled>
1516
+ </fields>
1517
+ </optionbal>
1518
+
1519
+ <assurance translate="label">
1520
+ <label>Assurance Ad Valorem</label>
1521
+ <frontend_type>text</frontend_type>
1522
+ <frontend_model>chronorelais/adminhtml_system_config_form_fieldsetassurance</frontend_model>
1523
+ <sort_order>90</sort_order>
1524
+ <show_in_default>1</show_in_default>
1525
+ <show_in_website>1</show_in_website>
1526
+ <show_in_store>1</show_in_store>
1527
+ <fields>
1528
+ <enabled translate="label">
1529
+ <label>Activer l'Ad Valorem</label>
1530
+ <frontend_type>select</frontend_type>
1531
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1532
+ <sort_order>1</sort_order>
1533
+ <show_in_default>1</show_in_default>
1534
+ <show_in_website>1</show_in_website>
1535
+ <show_in_store>1</show_in_store>
1536
+ <required>1</required>
1537
+ </enabled>
1538
+ <amount translate="label">
1539
+ <label>Montant minimum à assurer</label>
1540
+ <frontend_type>text</frontend_type>
1541
+ <sort_order>2</sort_order>
1542
+ <show_in_default>1</show_in_default>
1543
+ <show_in_website>1</show_in_website>
1544
+ <show_in_store>1</show_in_store>
1545
+ <required>0</required>
1546
+ <validate>validate-number</validate>
1547
+ </amount>
1548
+ </fields>
1549
+ </assurance>
1550
+
1551
+ <conflicts translate="label">
1552
+ <label>Vérificateur de conflits</label>
1553
+ <frontend_type>text</frontend_type>
1554
+ <frontend_model>chronorelais/adminhtml_system_config_form_fieldsetconflicts</frontend_model>
1555
+ <sort_order>100</sort_order>
1556
+ <show_in_default>1</show_in_default>
1557
+ <show_in_website>1</show_in_website>
1558
+ <show_in_store>1</show_in_store>
1559
+ <comment>
1560
+ <![CDATA[
1561
+ Chronopost fournit cet outil de vérification de conflits avec d'autres modules. Il vérifie si d'autres modules suchargent les classes, modèles, helpers et controlleurs personnalisés par le module Chronopost.<br />
1562
+ Cet outil vise à vous faciliter le débogage en cas de dysfonctionnement. En cas de doute sur son utilisation, rapprochez-vous de votre agence, ou contactez le support technique Chronopost au 0825 885 866 (numéro Indigo).
1563
+ ]]>
1564
+ </comment>
1565
+ <!--<fields>
1566
+ <conflicts translate="label">
1567
+ <label>Mot de passe Chronopost</label>
1568
+ <frontend_type>text</frontend_type>
1569
+ <button_label>Vérifier mes identifiants</button_label>
1570
+ <frontend_model>chronorelais/adminhtml_system_config_checklogin</frontend_model>
1571
+ <sort_order>9</sort_order>
1572
+ <show_in_default>1</show_in_default>
1573
+ <show_in_website>1</show_in_website>
1574
+ <show_in_store>1</show_in_store>
1575
+ </conflicts>
1576
+ </fields>-->
1577
+ </conflicts>
1578
+
1579
+ </groups>
1580
+ </chronorelais>
1581
+ </sections>
1582
+
1583
  </config>
app/code/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php CHANGED
@@ -1,1368 +1,1368 @@
1
- <?php
2
-
3
- /**
4
- * Magento Chronopost Chronorelais Module
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * @category Chronopost
17
- * @package Chronopost_Chronorelais
18
- * @copyright Copyright (c) 2008-10 Owebia (http://www.owebia.com/)
19
- * @author Antoine Lemoine
20
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
- */
22
- class ChronorelaisShippingHelper {
23
-
24
- public static $DEBUG_INDEX_COUNTER = 0;
25
- public static $FLOAT_REGEX = '[-]?\d+(?:[.]\d+)?';
26
- public static $POSITIVE_FLOAT_REGEX = '\d+(?:[.]\d+)?';
27
- public static $COUPLE_REGEX = '(?:[0-9.]+|\*) *(?:\[|\])? *\: *[0-9.]+';
28
- public static $UNCOMPRESSED_STRINGS = array(
29
- ' product.attribute.',
30
- ' product.option.',
31
- ' product.stock.',
32
- '{product.attribute.',
33
- '{product.option.',
34
- '{product.stock.',
35
- '{product.weight}',
36
- '{product.quantity}',
37
- '{cart.weight}',
38
- '{cart.quantity}',
39
- '{cart.price_including_tax}',
40
- '{cart.price_excluding_tax}',
41
- '{cart.',
42
- '{customvar.',
43
- '{selection.weight}',
44
- '{selection.quantity}',
45
- '{selection.',
46
- '{destination.country.',
47
- '{foreach ',
48
- '{/foreach}',
49
- );
50
- public static $COMPRESSED_STRINGS = array(
51
- ' p.a.',
52
- ' p.o.',
53
- ' p.s.',
54
- '{p.a.',
55
- '{p.o.',
56
- '{p.s.',
57
- '{p.w}',
58
- '{p.qty}',
59
- '{c.w}',
60
- '{c.qty}',
61
- '{c.pit}',
62
- '{c.pet}',
63
- '{c.',
64
- '{v.',
65
- '{s.w}',
66
- '{s.qty}',
67
- '{s.',
68
- '{dest.ctry.',
69
- '{each ',
70
- '{/each}',
71
- );
72
- protected $_input;
73
- protected $_config;
74
- protected $_messages;
75
- protected $_formula_cache;
76
- protected $_expression_cache;
77
- public $debug = 0;
78
- public $debug_output = '';
79
- public $debug_header = null;
80
-
81
- public function ChronorelaisShippingHelper($input) {
82
- $this->_formula_cache = array();
83
- $this->_messages = array();
84
- $this->_input = $input;
85
- $this->_config = array();
86
- $this->_parseInput();
87
- }
88
-
89
- private function debug($text, $level = 10) {
90
- if ($this->debug >= $level)
91
- $this->debug_output .= "<p>" . $text . "</p>";
92
- }
93
-
94
- public function printDebug() {
95
- if ($this->debug > 0) {
96
- $index = self::$DEBUG_INDEX_COUNTER++;
97
- echo "<style rel=\"stylesheet\" type=\"text/css\">"
98
- . ".osh-formula{color:#f90;} .osh-key{color:#0099f7;}"
99
- . ".osh-error{color:#f00;} .osh-warning{color:#ff0;} .osh-info{color:#7bf700;}"
100
- . ".osh-debug{background:#000;color:#bbb;position:absolute;top:0;left:0;width:100%;z-index:100;-moz-opacity:0.9;opacity:0.9;text-align:left;white-space:pre-wrap;}"
101
- . ".osh-debug-content{padding:10px;}"
102
- . ".osh-replacement{color:#ff3000;}"
103
- . "</style>"
104
- . "<div id=\"osh-debug-" . $index . "\" class=\"osh-debug\"><pre class=\"osh-debug-content\"><span style=\"float:right;cursor:pointer;\" onclick=\"document.getElementById('osh-debug-" . $index . "').style.display = 'none';\">[<span style=\"padding:0 5px;color:#f00;\">X</span>]</span>"
105
- . "<p>" . $this->debug_header . "</p>" . $this->debug_output . "</pre></div>";
106
- }
107
- }
108
-
109
- public function setDebugHeader($process) {
110
- $header = 'DEBUG app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronorelaisShippingHelper.php<br/>';
111
- foreach ($process['data'] as $key => $data) {
112
- $header .= ' <span class="osh-key">' . $key . '</span> = <span class="osh-formula">' . $this->_toString($data) . '</span><br/>';
113
- }
114
- $this->debug_header = $header;
115
- }
116
-
117
- public function getConfig() {
118
- return $this->_config;
119
- }
120
-
121
- public function getMessages() {
122
- $messages = $this->_messages;
123
- $this->_messages = array();
124
- return $messages;
125
- }
126
-
127
- public function formatConfig($compress) {
128
- $output = '';
129
- foreach ($this->_config as $code => $row) {
130
- if (!isset($row['lines'])) {
131
- if (isset($row['*comment']['value'])) {
132
- $output .= trim($row['*comment']['value']) . "\n";
133
- }
134
- $output .= '{' . ($compress ? '' : "\n");
135
- foreach ($row as $key => $property) {
136
- if (substr($key, 0, 1) != '*') {
137
- $value = $property['value'];
138
- if (isset($property['comment']))
139
- $output .= ($compress ? '' : "\t") . '/* ' . $property['comment'] . ' */' . ($compress ? '' : "\n");
140
- $output .= ($compress ? '' : "\t") . $key . ':' . ($compress ? '' : ' ');
141
- if (is_bool($value))
142
- $output .= $value ? 'true' : 'false';
143
- else if (is_int($value))
144
- $output .= $value;
145
- else if ((string) ((float) $value) == $value)
146
- $output .= $value;
147
- else
148
- $output .= '"' . str_replace('"', '\\"', $value) . '"';
149
- $output .= ',' . ($compress ? '' : "\n");
150
- }
151
- }
152
- if ($compress)
153
- $output = preg_replace('/,$/', '', $output);
154
- $output .= "}\n" . ($compress ? '' : "\n");
155
- } else {
156
- $output .= $row['lines'] . "\n";
157
- }
158
- }
159
- return $compress ? $this->compress($output) : $this->uncompress($output);
160
- }
161
-
162
- public function checkConfig() {
163
- $process = array(
164
- 'result' => null,
165
- 'data' => array(
166
- 'cart.price_excluding_tax' => 0,
167
- 'cart.price_including_tax' => 0,
168
- 'destination.country.code' => '',
169
- 'destination.country.name' => '',
170
- 'destination.region.code' => '',
171
- 'destination.postcode' => '',
172
- 'origin.country.code' => '',
173
- 'origin.country.name' => '',
174
- 'origin.region.code' => '',
175
- 'origin.postcode' => '',
176
- 'free_shipping' => false,
177
- 'customer.group.id' => '',
178
- 'customer.group.code' => '',
179
- 'cart.weight' => 0,
180
- 'cart.weight.unit' => 'kg',
181
- 'cart.quantity' => 0,
182
- ),
183
- 'cart.items' => array(),
184
- 'products' => array(),
185
- 'config' => $this->_config,
186
- );
187
- foreach ($this->_config as $code => &$row) {
188
- $this->processRow($process, $row, $check_all_conditions = true);
189
- foreach ($row as $property_key => $property_value) {
190
- if (substr($property_key, 0, 1) != '*')
191
- $this->getRowProperty($row, $property_key);
192
- }
193
- }
194
- }
195
-
196
- public function processRow($process, &$row, $is_checking = false) {
197
- if (!isset($row['*code']) || !isset($process['data']['carrier.code']))
198
- return;
199
-
200
- self::debug('process row <span class="osh-key">' . $row['*code'] . '</span>', 1);
201
- if (!isset($row['label']['value']))
202
- $row['label']['value'] = '***';
203
-
204
- $enabled = $this->getRowProperty($row, 'enabled');
205
- if (isset($enabled)) {
206
- if (!$is_checking && !$enabled) {
207
- $this->addMessage('info', $row, 'enabled', 'Configuration disabled');
208
- return new OCS_Result(false);
209
- }
210
- }
211
-
212
- $conditions = $this->getRowProperty($row, 'conditions');
213
- if (isset($conditions)) {
214
- $result = $this->_processFormula($process, $row, 'conditions', $conditions, $is_checking);
215
- if (!$is_checking) {
216
- if (!$result->success)
217
- return $result;
218
- if (!$result->result) {
219
- $this->addMessage('info', $row, 'conditions', "The cart doesn't match conditions");
220
- return new OCS_Result(false);
221
- }
222
- }
223
- }
224
-
225
- $destination = $this->getRowProperty($row, 'destination');
226
- if (isset($destination)) {
227
- $destination_match = $this->_addressMatch($destination, array(
228
- 'country_code' => $process['data']['destination.country.code'],
229
- 'region_code' => $process['data']['destination.region.code'],
230
- 'postcode' => $process['data']['destination.postcode']
231
- ));
232
- if (!$is_checking && !$destination_match) {
233
- $this->addMessage('info', $row, 'destination', "The shipping method doesn't cover the zone");
234
- return new OCS_Result(false);
235
- }
236
- }
237
-
238
- $origin = $this->getRowProperty($row, 'origin');
239
- if (isset($origin)) {
240
- $origin_match = $this->_addressMatch($origin, array(
241
- 'country_code' => $process['data']['origin.country.code'],
242
- 'region_code' => $process['data']['origin.region.code'],
243
- 'postcode' => $process['data']['origin.postcode']
244
- ));
245
- if (!$is_checking && !$origin_match) {
246
- $this->addMessage('info', $row, 'origin', "The shipping method doesn't match to shipping origin");
247
- return new OCS_Result(false);
248
- }
249
- }
250
-
251
- $customer_groups = $this->getRowProperty($row, 'customer_groups');
252
- if (isset($customer_groups)) {
253
- $groups = explode(',', $customer_groups);
254
- $group_match = false;
255
- //self::debug('code:'.$process['data']['customer.group.code'].', id:'.$process['data']['customer.group.id']);
256
- foreach ($groups as $group) {
257
- $group = trim($group);
258
- if ($group == $process['data']['customer.group.code'] || is_int($group) && $group == $process['data']['customer.group.id'] || $group == '*') {
259
- $group_match = true;
260
- break;
261
- }
262
- }
263
- if (!$is_checking && !$group_match) {
264
- $this->addMessage('info', $row, 'customer_groups', "The shipping method doesn't match to customer group (%s)", $process['data']['customer.group.code']);
265
- return new OCS_Result(false);
266
- }
267
- }
268
-
269
- //Chronopost quickcost method for dynamic price if it is set enabled
270
- $quickcost = Mage::getStoreConfig('carriers/' . $process['data']['carrier.code'] . '/quickcost');
271
- if ($quickcost) {
272
- if ($quickCostValues = $this->getQuickCostValue($process['data'])) {
273
- if ($quickCostValues->errorCode == 0) {
274
- return new OCS_Result(true, (float) $quickCostValues->amountTTC);
275
- } else {
276
- $this->addMessage('error', $row, 'chronopost', $quickCostValues->errorMessage);
277
- return new OCS_Result(false);
278
- }
279
- } else { /* if false => WS inaccessible donc on prend les prix de la grille */
280
- //return new OCS_Result(false);
281
- }
282
- }
283
-
284
- /* Prix via la grille du BO */
285
- $fees = $this->getRowProperty($row, 'fees');
286
- if (isset($fees)) {
287
- $result = $this->_processFormula($process, $row, 'fees', $fees, $is_checking);
288
- if (!$result->success)
289
- return $result;
290
- self::debug(' => <span class="osh-info">result = <span class="osh-formula">' . $this->_toString($result->result) . '</span>', 1);
291
- return new OCS_Result(true, (float) $result->result);
292
- }
293
-
294
- return new OCS_Result(false);
295
- }
296
-
297
- public function getQuickCostValue($processData) {
298
- $quickCost = array();
299
- $_helper = Mage::helper('chronorelais');
300
- $account_number = $_helper->getConfigurationAccountNumber();
301
- $password = $_helper->getConfigurationAccountPass();
302
- $productCode = $_helper->getChronoProductCode($processData['destination.country.code'], $processData['carrier.code']);
303
- $origin_postcode = $_helper->getConfigurationShipperInfo('zipcode');
304
-
305
- //to get arrival code
306
- $arrCode = $processData['destination.postcode'];
307
- if ($processData['carrier.code'] == 'chronoexpress' || $processData['carrier.code'] == 'chronopostcclassic') {
308
- $arrCode = $processData['destination.country.code'];
309
- }
310
-
311
- $cartWeight = $processData['cart.weight'];
312
- if ($_helper->getConfigWeightUnit() == 'g') {
313
- $cartWeight = $cartWeight / 1000; /* conversion g => kg */
314
- }
315
- $quickCost = array(
316
- 'accountNumber' => $account_number,
317
- 'password' => $password,
318
- 'depCode' => $origin_postcode,
319
- 'arrCode' => $arrCode,
320
- 'weight' => $cartWeight,
321
- 'productCode' => $productCode,
322
- 'type' => 'M'
323
- );
324
-
325
- $quickcost_url = Mage::helper('chronorelais')->getConfigData('carriers/' . $processData['carrier.code'] . '/quickcost_url');
326
-
327
- $helperWS = Mage::helper('chronorelais/webservice');
328
- return $helperWS->getQuickcost($quickCost,$quickcost_url);
329
- }
330
-
331
- public function getRowProperty(&$row, $key, $original_row = null, $original_key = null) {
332
- $property = null;
333
- $output = null;
334
- if (isset($original_row) && isset($original_key) && $original_row['*code'] == $row['*code'] && $original_key == $key) {
335
- $this->addMessage('error', $row, $key, 'Infinite loop %s', "<span class=\"code\">{" . $row['*code'] . '.' . $key . "}</span>");
336
- return array('error' => 'Infinite loop');
337
- }
338
- if (isset($row[$key]['value'])) {
339
- $property = $row[$key]['value'];
340
- $output = $property;
341
- self::debug(' get <span class="osh-key">' . $row['*code'] . '</span>.<span class="osh-key">' . $key . '</span> = <span class="osh-formula">' . $this->_toString($property) . '</span>', 5);
342
- preg_match_all('/{([a-z0-9_]+)\.([a-z0-9_]+)}/i', $output, $result_set, PREG_SET_ORDER);
343
- foreach ($result_set as $result) {
344
- list($original, $ref_code, $ref_key) = $result;
345
- if (!in_array($ref_code, array('module', 'date', 'store', 'cart', 'product', 'selection', 'customvar'))) {
346
- if ($ref_code == $row['code']['value'] && $ref_key == $key) {
347
- $this->addMessage('error', $row, $key, 'Infinite loop %s', "<span class=\"code\">" . $original . "</span>");
348
- return null;
349
- }
350
- if (isset($this->_config[$ref_code][$ref_key]['value'])) {
351
- $replacement = $this->getRowProperty($this->_config[$ref_code], $ref_key, isset($original_row) ? $original_row : $row, isset($original_key) ? $original_key : $key);
352
- if (is_array($replacement) && isset($replacement['error'])) {
353
- return isset($original_row) ? $replacement : 'false';
354
- }
355
- } else {
356
- $this->addMessage('error', $row, $key, 'Non-existent property %s', "<span class=\"code\">" . $original . "</span>");
357
- $replacement = 'null';
358
- }
359
- $output = $this->replace($original, $replacement, $output);
360
- }
361
- }
362
- } else {
363
- self::debug(' get <span class="osh-key">' . $row['*code'] . '</span>.<span class="osh-key">' . $key . '</span> = <span class="osh-formula">null</span>', 5);
364
- }
365
- return $output;
366
- }
367
-
368
- protected function _toString($value) {
369
- if (!isset($value))
370
- return 'null';
371
- else if (is_bool($value))
372
- return $value ? 'true' : 'false';
373
- else
374
- return $value;
375
- }
376
-
377
- protected function replace($from, $to, $input) {
378
- if ($from === $to)
379
- return $input;
380
- if (strpos($input, $from) === false)
381
- return $input;
382
- $to = $this->_toString($to);
383
- self::debug(' replace <span class="osh-replacement">' . $this->_toString($from) . '</span> by <span class="osh-replacement">' . $to . '</span> =&gt; <span class="osh-formula">' . str_replace($from, '<span class="osh-replacement">' . $to . '</span>', $input) . '</span>', 5);
384
- return str_replace($from, $to, $input);
385
- }
386
-
387
- protected function _min() {
388
- $args = func_get_args();
389
- $min = null;
390
- foreach ($args as $arg) {
391
- if (isset($arg) && (!isset($min) || $min > $arg))
392
- $min = $arg;
393
- }
394
- return $min;
395
- }
396
-
397
- protected function _max() {
398
- $args = func_get_args();
399
- $max = null;
400
- foreach ($args as $arg) {
401
- if (isset($arg) && (!isset($max) || $max < $arg))
402
- $max = $arg;
403
- }
404
- return $max;
405
- }
406
-
407
- protected function _processFormula($process, &$row, $property_key, $formula_string, $is_checking, $use_cache = true) {
408
- $result = $this->_prepareFormula($process, $row, $property_key, $formula_string, $is_checking, $use_cache);
409
- if (!$result->success)
410
- return $result;
411
-
412
- $eval_result = $this->_evalFormula($result->result);
413
- if (!isset($eval_result)) {
414
- $this->addMessage('error', $row, $property_key, 'Invalid formula');
415
- $result = new OCS_Result(false);
416
- if ($use_cache)
417
- $this->setCache($formula_string, $result);
418
- return $result;
419
- }
420
- self::debug(' formula evaluation = <span class="osh-formula">' . $this->_toString($eval_result) . '</span>', 10);
421
- $result = new OCS_Result(true, $eval_result);
422
- if ($use_cache)
423
- $this->setCache($formula_string, $result);
424
- return $result;
425
- }
426
-
427
- public function evalInput($process, $row, $property_key, $input) {
428
- $result = $this->_prepareFormula($process, $row, $property_key, $input, $is_checking = false, $use_cache = true);
429
- return $result->success ? $result->result : $input;
430
- }
431
-
432
- protected function setCache($expression, $value) {
433
- if ($value instanceof OCS_Result) {
434
- $this->_formula_cache[$expression] = $value;
435
- self::debug(' cache <span class="osh-replacement">' . $expression . '</span> = <span class="osh-formula">' . $this->_toString($this->_formula_cache[$expression]) . '</span>', 10);
436
- } else {
437
- $value = $this->_toString($value);
438
- $this->_expression_cache[$expression] = $value;
439
- self::debug(' cache <span class="osh-replacement">' . $expression . '</span> = <span class="osh-formula">' . $value . '</span>', 10);
440
- }
441
- }
442
-
443
- protected function _prepareFormula($process, $row, $property_key, $formula_string, $is_checking, $use_cache = true) {
444
- if ($use_cache && isset($this->_formula_cache[$formula_string])) {
445
- $result = $this->_formula_cache[$formula_string];
446
- self::debug(' get cached formula <span class="osh-replacement">' . $formula_string . '</span> = <span class="osh-formula">' . $this->_toString($result->result) . '</span>', 10);
447
- return $result;
448
- }
449
-
450
- $formula = $formula_string;
451
- //self::debug(' formula = <span class="osh-formula">'.$formula.'</span>',10);
452
-
453
- while (preg_match("#{foreach product\.((?:attribute|option)\.(?:[a-z0-9_]+))}(.*){/foreach}#i", $formula, $result)) {
454
- $original = $result[0];
455
- if ($use_cache && isset($this->_expression_cache[$original])) {
456
- $replacement = $this->_expression_cache[$original];
457
- self::debug(' get cached expression <span class="osh-replacement">' . $original . '</span> = <span class="osh-formula">' . $replacement . '</span>', 10);
458
- } else {
459
- $replacement = 0;
460
- list($filter_property_type, $filter_property_name) = explode('.', $result[1]);
461
- $selections = array();
462
- self::debug(' :: foreach <span class="osh-key">' . $filter_property_type . '</span>.<span class="osh-key">' . $filter_property_name . '</span>', 10);
463
- foreach ($process['products'] as $product) {
464
- $tmp_value = $this->_getProductProperty($product, $filter_property_type, $filter_property_name, $get_by_id = false);
465
- self::debug(' products[<span class="osh-formula">' . $product->getName() . '</span>].<span class="osh-key">' . $filter_property_type . '</span>.<span class="osh-key">' . $filter_property_name . '</span> = <span class="osh-formula">' . $this->_toString($tmp_value) . '</span>', 10);
466
- $key = 'val_' . $tmp_value;
467
- $sel = isset($selections[$key]) ? $selections[$key] : null;
468
- $selections[$key]['products'][] = $product;
469
- $selections[$key]['weight'] = (isset($sel['weight']) ? $sel['weight'] : 0) + $product->getAttribute('weight') * $product->getQuantity();
470
- $selections[$key]['quantity'] = (isset($sel['quantity']) ? $sel['quantity'] : 0) + $product->getQuantity();
471
- }
472
- self::debug(' :: start foreach', 10);
473
- foreach ($selections as $selection) {
474
- $process2 = $process;
475
- $process2['products'] = $selection['products'];
476
- $process2['data']['selection.quantity'] = $selection['quantity'];
477
- $process2['data']['selection.weight'] = $selection['weight'];
478
- $process_result = $this->_processFormula($process2, $row, $property_key, $result[2], $is_checking, $tmp_use_cache = false);
479
- $replacement += $process_result->result;
480
- }
481
- self::debug(' :: end foreach <span class="osh-key">' . $filter_property_type . '</span>.<span class="osh-key">' . $filter_property_name . '</span>', 10);
482
- if ($use_cache)
483
- $this->setCache($original, $replacement);
484
- }
485
- $formula = $this->replace($original, $replacement, $formula);
486
- }
487
-
488
- $formula = str_replace(array("\n", "\t"), array('', ''), $formula);
489
-
490
- while (preg_match("#{customvar\.([a-z0-9_]+)}#i", $formula, $result)) {
491
- $original = $result[0];
492
- $replacement = Mage::getModel('core/variable')->loadByCode($result[1])->getValue('plain');
493
- $formula = $this->replace($original, $replacement, $formula);
494
- }
495
-
496
- $first_product = isset($process['products'][0]) ? $process['products'][0] : null;
497
- if (!isset($process['data']['selection.weight']))
498
- $process['data']['selection.weight'] = $process['data']['cart.weight'];
499
- if (!isset($process['data']['selection.quantity']))
500
- $process['data']['selection.quantity'] = $process['data']['cart.quantity'];
501
- $process['data']['product.weight'] = isset($first_product) ? $first_product->getAttribute('weight') : 0;
502
- $process['data']['product.quantity'] = isset($first_product) ? $first_product->getQuantity() : 0;
503
-
504
- foreach ($process['data'] as $original => $replacement) {
505
- $formula = $this->replace('{' . $original . '}', $replacement, $formula);
506
- }
507
-
508
- if (isset($first_product)) {
509
- while (preg_match("#{product\.(attribute|option|stock)\.([a-z0-9_]+)}#i", $formula, $result)) {
510
- $original = $result[0];
511
- switch ($result[1]) {
512
- case 'attribute': $replacement = $first_product->getAttribute($result[2]);
513
- break;
514
- case 'option': $replacement = $first_product->getOption($result[2]);
515
- break;
516
- case 'stock': $replacement = $first_product->getStockData($result[2]);
517
- break;
518
- }
519
- $formula = $this->replace($original, $replacement, $formula);
520
- }
521
- }
522
-
523
- //while (preg_match("/{(count|all|any) (attribute|option) '([^'\)]+)' ?(==|<=|>=|<|>|!=) ?(".self::$FLOAT_REGEX."|true|false|'[^'\)]*')}/",$formula,$result)
524
- // || preg_match("/{(sum|count distinct) (attribute|option) '([^'\)]+)'}/",$formula,$result))
525
- while (preg_match("/{(count) products(?: where ([^}]+))?}/i", $formula, $result) || preg_match("/{(sum|count distinct) product\.(attribute|option)\.([a-z0-9_]+)(?: where ([^}]+))?}/i", $formula, $result)) {
526
- $original = $result[0];
527
- if ($use_cache && isset($this->_expression_cache[$original])) {
528
- $replacement = $this->_expression_cache[$original];
529
- self::debug(' get cached expression <span class="osh-replacement">' . $original . '</span> = <span class="osh-formula">' . $replacement . '</span>', 10);
530
- } else {
531
- $replacement = $this->_processProductProperty($process['products'], $result);
532
- if ($use_cache)
533
- $this->setCache($result[0], $replacement);
534
- }
535
- $formula = $this->replace($original, $replacement, $formula);
536
- }
537
-
538
- //while (preg_match("/{table '([^']+)' ([^}]+)}/",$formula,$result))
539
- while (preg_match("/{table ([^}]+) in ([0-9\.:,\*\[\] ]+)}/i", $formula, $result)) {
540
- $original = $result[0];
541
- if ($use_cache && isset($this->_expression_cache[$original])) {
542
- $replacement = $this->_expression_cache[$original];
543
- self::debug(' get cached expression <span class="osh-replacement">' . $original . '</span> = <span class="osh-formula">' . $replacement . '</span>', 10);
544
- } else {
545
- $reference_value = $this->_evalFormula($result[1]);
546
- if (isset($reference_value)) {
547
- $fees_table_string = $result[2];
548
-
549
- if (!preg_match('#^' . self::$COUPLE_REGEX . '(?:, *' . self::$COUPLE_REGEX . ')*$#', $fees_table_string)) {
550
- $this->addMessage('error', $row, $property_key, 'Error in table %s', '<span class="osh-formula">' . htmlentities($result[0]) . '</span>');
551
- $result = new OCS_Result(false);
552
- if ($use_cache)
553
- $this->setCache($formula_string, $result);
554
- return $result;
555
- }
556
- $fees_table = explode(',', $fees_table_string);
557
-
558
- $replacement = null;
559
- foreach ($fees_table as $item) {
560
- $fee_data = explode(':', $item);
561
-
562
- $fee = trim($fee_data[1]);
563
- $max_value = trim($fee_data[0]);
564
-
565
- $last_char = $max_value{strlen($max_value) - 1};
566
- if ($last_char == '[')
567
- $including_max_value = false;
568
- else if ($last_char == ']')
569
- $including_max_value = true;
570
- else
571
- $including_max_value = true;
572
-
573
- $max_value = str_replace(array('[', ']'), '', $max_value);
574
-
575
- if ($max_value == '*' || $including_max_value && $reference_value <= $max_value || !$including_max_value && $reference_value < $max_value) {
576
- $replacement = $fee; //$this->_calculateFee($process,$fee,$var);
577
- break;
578
- }
579
- }
580
- }
581
- $replacement = $this->_toString($replacement);
582
- if ($use_cache)
583
- $this->setCache($original, $replacement);
584
- }
585
- $formula = $this->replace($original, $replacement, $formula);
586
- }
587
- $result = new OCS_Result(true, $formula);
588
- return $result;
589
- }
590
-
591
- protected function _evalFormula($formula) {
592
- if (is_bool($formula))
593
- return $formula;
594
- if (!preg_match('/^(?:floor|ceil|round|max|min|rand|pow|pi|sqrt|log|exp|abs|int|float|true|false|null|and|or|in|substr|strtolower'
595
- . '|in_array\(\'(?:[^\']*)\', *array\( *(?:\'(?:[^\']+)\') *(?: *, *\'(?:[^\']+)\')* *\) *\)'
596
- . '|\'[^\']*\'|[0-9,\'\.\-\(\)\*\/\?\:\+\<\>\=\&\|%! ])*$/', $formula)) {
597
- $errors = array(
598
- PREG_NO_ERROR => 'PREG_NO_ERROR',
599
- PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR',
600
- PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR',
601
- PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR',
602
- PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR',
603
- PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR',
604
- );
605
- $error = preg_last_error();
606
- if (isset($errors[$error]))
607
- $error = $errors[$error];
608
- self::debug(' doesn\'t match (' . $error . ')', 10);
609
- return null;
610
- }
611
- $formula = str_replace(
612
- array('min', 'max'), array('$this->_min', '$this->_max'), $formula
613
- );
614
- $eval_result = null;
615
- @eval('$eval_result = (' . $formula . ');');
616
- return $eval_result;
617
- }
618
-
619
- protected function _getOptionsAndData($string) {
620
- if (preg_match('/^(\\s*\(\\s*([^\] ]*)\\s*\)\\s*)/', $string, $result)) {
621
- $options = $result[2];
622
- $data = str_replace($result[1], '', $string);
623
- } else {
624
- $options = '';
625
- $data = $string;
626
- }
627
- return array(
628
- 'options' => $options,
629
- 'data' => $data,
630
- );
631
- }
632
-
633
- public function compress($input) {
634
- if (preg_match_all("/{table (.*) in (" . self::$COUPLE_REGEX . "(?:, *" . self::$COUPLE_REGEX . ")*)}/imsU", $input, $result, PREG_SET_ORDER)) {
635
- foreach ($result as $result_i) {
636
- $fees_table = explode(',', $result_i[2]);
637
- $value = null;
638
- foreach ($fees_table as $index => $item) {
639
- list($max_value, $fee) = explode(':', $item);
640
- $last_char = $max_value{strlen($max_value) - 1};
641
- if (in_array($last_char, array('[', ']'))) {
642
- $including_char = $last_char;
643
- $max_value = str_replace(array('[', ']'), '', $max_value);
644
- }
645
- else
646
- $including_char = '';
647
- $fees_table[$index] = ((float) $max_value) . $including_char . ':' . ((float) $fee);
648
- }
649
- $input = str_replace($result_i[2], implode(',', $fees_table), $input);
650
- $input = str_replace($result_i[1], trim($result_i[1]), $input);
651
- }
652
- }
653
- if (preg_match_all("#{foreach ([^}]*)}(.*){/foreach}#imsU", $input, $result, PREG_SET_ORDER)) {
654
- foreach ($result as $result_i) {
655
- $input = str_replace($result_i[1], trim($result_i[1]), $input);
656
- $input = str_replace($result_i[2], trim($result_i[2]), $input);
657
- }
658
- }
659
- return '$$' . str_replace(
660
- self::$UNCOMPRESSED_STRINGS, self::$COMPRESSED_STRINGS, $input
661
- );
662
- }
663
-
664
- public function uncompress($input) {
665
- if (preg_match_all("/{table (.*) in (" . self::$COUPLE_REGEX . "(?:, *" . self::$COUPLE_REGEX . ")*)}/iU", $input, $result, PREG_SET_ORDER)) {
666
- foreach ($result as $result_i) {
667
- $fees_table = explode(',', $result_i[2]);
668
- $value = null;
669
- foreach ($fees_table as $index => $item) {
670
- list($max_value, $fee) = explode(':', $item);
671
- $last_char = $max_value{strlen($max_value) - 1};
672
- if (in_array($last_char, array('[', ']'))) {
673
- $including_char = $last_char;
674
- $max_value = str_replace(array('[', ']'), '', $max_value);
675
- }
676
- else
677
- $including_char = '';
678
- $max_value = (float) $max_value;
679
- $fee = (float) $fee;
680
- $new_max_value = number_format($max_value, 2, '.', '');
681
- $new_fee = number_format($fee, 2, '.', '');
682
- $fees_table[$index] = (((float) $new_max_value) == $max_value ? $new_max_value : $max_value) . $including_char . ':'
683
- . (((float) $new_fee) == $fee ? $new_fee : $fee);
684
- }
685
- $input = str_replace($result_i[2], implode(', ', $fees_table), $input);
686
- $input = str_replace($result_i[1], trim($result_i[1]), $input);
687
- }
688
- }
689
- if (preg_match_all("#{foreach ([^}]*)}(.*){/foreach}#iU", $input, $result, PREG_SET_ORDER)) {
690
- foreach ($result as $result_i) {
691
- $input = str_replace($result_i[1], trim($result_i[1]), $input);
692
- $input = str_replace($result_i[2], trim($result_i[2]), $input);
693
- }
694
- }
695
- return str_replace(
696
- self::$COMPRESSED_STRINGS, self::$UNCOMPRESSED_STRINGS, $input
697
- );
698
- }
699
-
700
- public function parseProperty($input) {
701
- $value = $input === 'false' || $input === 'true' ? $input == 'true' : str_replace('\"', '"', preg_replace('/^(?:"|\')(.*)(?:"|\')$/s', '$1', $input));
702
- return $value === '' ? null : $value;
703
- }
704
-
705
- public function cleanProperty(&$row, $key) {
706
- $input = $row[$key]['value'];
707
- if (is_string($input)) {
708
- $input = str_replace(array("\n"), array(''), $input);
709
- while (preg_match('/({TABLE |{SUM |{COUNT | DISTINCT | IN )/', $input, $resi)) {
710
- $input = str_replace($resi[0], strtolower($resi[0]), $input);
711
- }
712
-
713
- while (preg_match('/{{customVar code=([a-zA-Z0-9_-]+)}}/', $input, $resi)) {
714
- $input = str_replace($resi[0], '{customvar.' . $resi[1] . '}', $input);
715
- }
716
-
717
- $regex = "{(weight|products_quantity|price_including_tax|price_excluding_tax|country)}";
718
- if (preg_match('/' . $regex . '/', $input, $resi)) {
719
- $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
720
- while (preg_match('/' . $regex . '/', $input, $resi)) {
721
- switch ($resi[1]) {
722
- case 'price_including_tax':
723
- case 'price_excluding_tax':
724
- case 'weight':
725
- $input = str_replace($resi[0], "{cart." . $resi[1] . "}", $input);
726
- break;
727
- case 'products_quantity': $input = str_replace($resi[0], "{cart.quantity}", $input);
728
- break;
729
- case 'country': $input = str_replace($resi[0], "{destination.country.name}", $input);
730
- break;
731
- }
732
- }
733
- }
734
-
735
- $regex1 = "{copy '([a-zA-Z0-9_]+)'\.'([a-zA-Z0-9_]+)'}";
736
- if (preg_match('/' . $regex1 . '/', $input, $resi)) {
737
- $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
738
- while (preg_match('/' . $regex1 . '/', $input, $resi))
739
- $input = str_replace($resi[0], '{' . $resi[1] . '.' . $resi[2] . '}', $input);
740
- }
741
-
742
- $regex1 = "{(count|all|any) (attribute|option) '([^'\)]+)' ?((?:==|<=|>=|<|>|!=) ?(?:" . self::$FLOAT_REGEX . "|true|false|'[^'\)]*'))}";
743
- $regex2 = "{(sum) (attribute|option) '([^'\)]+)'}";
744
- if (preg_match('/' . $regex1 . '/', $input, $resi) || preg_match('/' . $regex2 . '/', $input, $resi)) {
745
- $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
746
- while (preg_match('/' . $regex1 . '/', $input, $resi) || preg_match('/' . $regex2 . '/', $input, $resi)) {
747
- switch ($resi[1]) {
748
- case 'count': $input = str_replace($resi[0], "{count products where product." . $resi[2] . "s." . $resi[3] . $resi[4] . "}", $input);
749
- break;
750
- case 'all': $input = str_replace($resi[0], "{count products where product." . $resi[2] . "s." . $resi[3] . $resi[4] . "}=={products_quantity}", $input);
751
- break;
752
- case 'any': $input = str_replace($resi[0], "{count products where product." . $resi[2] . "s." . $resi[3] . $resi[4] . "}>0", $input);
753
- break;
754
- case 'sum': $input = str_replace($resi[0], "{sum product." . $resi[2] . "." . $resi[3] . "}", $input);
755
- break;
756
- }
757
- }
758
- }
759
-
760
- $regex = "((?:{| )product.(?:attribute|option))s.";
761
- if (preg_match('/' . $regex . '/', $input, $resi)) {
762
- $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
763
- while (preg_match('/' . $regex . '/', $input, $resi)) {
764
- $input = str_replace($resi[0], $resi[1] . '.', $input);
765
- }
766
- }
767
-
768
- $regex = "{table '([^']+)' (" . self::$COUPLE_REGEX . "(?:, *" . self::$COUPLE_REGEX . ")*)}";
769
- if (preg_match('/' . $regex . '/', $input, $resi)) {
770
- $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
771
- while (preg_match('/' . $regex . '/', $input, $resi)) {
772
- switch ($resi[1]) {
773
- case 'products_quantity':
774
- $input = str_replace($resi[0], "{table {cart.weight} in " . $resi[2] . "}*{cart.quantity}", $input);
775
- break;
776
- default:
777
- $input = str_replace($resi[0], "{table {cart." . $resi[1] . "} in " . $resi[2] . "}", $input);
778
- break;
779
- }
780
- }
781
- }
782
- }
783
- $row[$key]['value'] = $input;
784
- }
785
-
786
- protected function _parseInput() {
787
- $config_string = str_replace(
788
- array('&gt;', '&lt;', '“', '”', utf8_encode(chr(147)), utf8_encode(chr(148)), '&laquo;', '&raquo;', "\r\n", "\t"), array('>', '<', '"', '"', '"', '"', '"', '"', "\n", ' '), $this->_input
789
- );
790
-
791
- if (substr($config_string, 0, 2) == '$$')
792
- $config_string = $this->uncompress(substr($config_string, 2, strlen($config_string)));
793
-
794
- //echo ini_get('pcre.backtrack_limit');
795
- //exit;
796
-
797
- $row_regex = ' *([a-z0-9_]+)\\s*:\\s*("(?:(?:[^"]|\\\\")*[^\\\\])?"|' . self::$FLOAT_REGEX . '|false|true)\\s*(,)? *(?:\\n)?';
798
- if (!preg_match_all('/((?:#+[^{\\n]*\\s+)*)\\s*(#)?{\\s*(' . $row_regex . ')+\\s*}/i', $config_string, $result, PREG_SET_ORDER)) {
799
- $errors = array(
800
- PREG_NO_ERROR => 'PREG_NO_ERROR',
801
- PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR',
802
- PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR',
803
- PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR',
804
- PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR',
805
- PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR',
806
- );
807
- $error = preg_last_error();
808
- if (isset($errors[$error]))
809
- $error = $errors[$error];
810
- self::debug(' preg_match_all error (' . $error . ')', 10);
811
- }
812
-
813
- $this->_config = array();
814
- $available_keys = array(
815
- 'code', 'label', 'enabled', 'description', 'fees', 'conditions', 'destination', 'origin', 'customer_groups', 'tracking_url',
816
- 'fees_table', 'fees_formula', 'fixed_fees', 'reference_value',
817
- 'prices_range', 'weights_range', 'product_properties',
818
- 'free_shipping__fees_table', 'free_shipping__fees_formula', 'free_shipping__fixed_fees', 'free_shipping__label',
819
- );
820
-
821
- foreach ($result as $block) {
822
- $deprecated_properties = array();
823
- $unknown_properties = array();
824
- $missing_semicolon = array();
825
- $obsolete_disabling_method = array();
826
-
827
- //$before = strstr($config_string,$block[0],true); // Seulement compatible avec PHP 5.3.0
828
- list($before) = explode($block[0], $config_string, 2);
829
- if ($before !== false && trim($before) != '') {
830
- $config_string = substr($config_string, strlen($before));
831
- $this->_addIgnoredLines(trim($before));
832
- $this->addMessage('info', $row = null, null, 'Ignored lines %s', '<div class="code">' . trim($before) . '</div>');
833
- }
834
-
835
- $config_string = str_replace($block[0], '', $config_string);
836
- preg_match_all('/' . $row_regex . '/i', $block[0], $result2, PREG_SET_ORDER);
837
- $block_string = $block[0];
838
-
839
- $row = array();
840
- $i = 1;
841
- foreach ($result2 as $data) {
842
- $key = $data[1];
843
- if (in_array($key, $available_keys) || substr($key, 0, 1) == '_') {
844
- $property = $this->parseProperty($data[2]);
845
- if (isset($property)) {
846
- $row[$key] = array('value' => $property, 'original_value' => $property);
847
- $this->cleanProperty($row, $key);
848
- }
849
- if ($i > 2) {
850
- $block_string = str_replace($data[0], $i == 3 ? "...\n" : '', $block_string);
851
- }
852
- if ($i != count($result2) && !isset($data[3]) || isset($data[3]) && $data[3] != ',') {
853
- if (preg_match('/^("|\')(.{40})(.*)("|\')$/s', $data[2], $resultx))
854
- $missing_semicolon[] = trim(str_replace($data[2], $resultx[1] . $resultx[2] . ' ...' . $resultx[4], $data[0]));
855
- else
856
- $missing_semicolon[] = trim($data[0]);
857
- }
858
- } else {
859
- if (!in_array($key, $unknown_properties))
860
- $unknown_properties[] = $key;
861
- }
862
- $i++;
863
- }
864
- if ($block[1] != '')
865
- $row['*comment']['value'] = $block[1];
866
- if ($block[2] == '#' && !isset($row['enabled'])) {
867
- $row['enabled'] = array('value' => false);
868
- $obsolete_disabling_method[] = $block_string;
869
- }
870
-
871
- $formula_fields_to_check = array();
872
- if (isset($row['conditions']))
873
- $formula_fields_to_check[] = 'conditions';
874
- if (isset($row['fees']))
875
- $formula_fields_to_check[] = 'fees';
876
-
877
- if (count($formula_fields_to_check) > 0) {
878
- foreach ($formula_fields_to_check as $property) {
879
- $property_value = $row[$property]['value'];
880
- if (preg_match('/{ +/', $property_value)) {
881
- $this->addMessage('warning', $row, $property, 'There are unwanted spaces after char `%s`', '{');
882
- $property_value = preg_replace('/{ +/', '{', $property_value);
883
- }
884
- if (preg_match('/ +}/', $property_value)) {
885
- $this->addMessage('warning', $row, $property, 'There are unwanted spaces before char `%s`', '}');
886
- $property_value = preg_replace('/ +}/', '}', $property_value);
887
- }
888
- if (preg_match('/ +/', $property_value)) {
889
- $this->addMessage('warning', $row, $property, 'There are unwanted multiples spaces `%s`', preg_replace('/( +)/', '<span class="osh-formula">*$1*</span>', $property_value));
890
- $property_value = preg_replace('/ +/', ' ', $property_value);
891
- }
892
- $row[$property]['value'] = trim($property_value);
893
- }
894
- }
895
-
896
- $float_value_regex = '\\s*(' . self::$POSITIVE_FLOAT_REGEX . '|\*)\\s*';
897
- $conditions = array();
898
- if (isset($row['prices_range'])) {
899
- if (!in_array('prices_range', $deprecated_properties))
900
- $deprecated_properties[] = 'prices_range';
901
-
902
- $result = $this->_getOptionsAndData($row['prices_range']['value']);
903
- $options = $result['options'];
904
- $prices_range = $result['data'];
905
-
906
- if (($options == '' || in_array($options, array('incl.tax', 'ttc'))) && preg_match('/^\\s*(\[|\])?' . $float_value_regex . '=>' . $float_value_regex . '(\[|\])?\\s*$/', $prices_range, $result)) {
907
- $min_price_included = $result[1] == '[';
908
- $min_price = $result[2] == '*' ? -1 : (float) $result[2];
909
- $max_price = $result[3] == '*' ? -1 : (float) $result[3];
910
- $max_price_included = !isset($result[4]) || $result[4] == ']' || $result[4] == '';
911
-
912
- $tax_included = $options != '' && in_array($options, array('incl.tax', 'ttc')) || isset($row['reference_value']) && $row['reference_value']['value'] == 'price_including_tax';
913
- $price = $tax_included ? '{cart.price_including_tax}' : '{cart.price_excluding_tax}';
914
-
915
- if ($min_price != -1)
916
- $conditions[] = $price . '>' . ($min_price_included ? '=' : '') . $min_price;
917
- if ($max_price != -1)
918
- $conditions[] = $price . '<' . ($max_price_included ? '=' : '') . $max_price;
919
- }
920
- else
921
- $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">prices_range</span>', '<span class="osh-formula">' . $row['prices_range']['value'] . '</span>');
922
- unset($row['prices_range']);
923
- }
924
- if (isset($row['weights_range'])) {
925
- if (!in_array('weights_range', $deprecated_properties))
926
- $deprecated_properties[] = 'weights_range';
927
- if (preg_match('/^\\s*(\[|\])?' . $float_value_regex . '=>' . $float_value_regex . '(\[|\])?\\s*$/', $row['weights_range']['value'], $result)) {
928
- $min_weight_included = $result[1] == '[';
929
- $min_weight = $result[2] == '*' ? -1 : (float) $result[2];
930
- $max_weight = $result[3] == '*' ? -1 : (float) $result[3];
931
- $max_weight_included = !isset($result[4]) || $result[4] == ']' || $result[4] == '';
932
-
933
- if ($min_weight != -1)
934
- $conditions[] = '{cart.weight}>' . ($min_weight_included ? '=' : '') . $min_weight;
935
- if ($max_weight != -1)
936
- $conditions[] = '{cart.weight}<' . ($max_weight_included ? '=' : '') . $max_weight;
937
- }
938
- else
939
- $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">weights_range</span>', '<span class="osh-formula">' . $row['weights_range']['value'] . '</span>');
940
- unset($row['weights_range']);
941
- }
942
- if (isset($row['product_properties'])) {
943
- if (!in_array('product_properties', $deprecated_properties))
944
- $deprecated_properties[] = 'product_properties';
945
- $product_property_regex = "\\s*(and|or)? *\((?:(all|any|sum) )?(attribute|option) '([^'\)]+)' ?(==|=|<=|>=|<|>|!=) ?(" . self::$FLOAT_REGEX . "|true|false|'[^'\)]*')\)\\s*";
946
- if (preg_match('/^(' . $product_property_regex . ')+$/', $row['product_properties']['value'], $result)) {
947
- preg_match_all('/' . $product_property_regex . '/', $row['product_properties']['value'], $results, PREG_SET_ORDER);
948
- $product_properties_condition = '';
949
- foreach ($results as $result) {
950
- $and_or = $result[1];
951
- if ($and_or == '')
952
- $and_or = 'and';
953
- $any_all_sum = $result[2];
954
- if ($any_all_sum == '')
955
- $any_all_sum = 'any';
956
- $property_type = $result[3];
957
- $property_name = $result[4];
958
- $cmp_symbol = $result[5];
959
- if ($cmp_symbol == '=')
960
- $cmp_symbol = '==';
961
- $cmp_value = $result[6];
962
-
963
- $product_properties_condition .= $product_properties_condition == '' ? '' : ' ' . $and_or . ' ';
964
- switch ($any_all_sum) {
965
- case 'sum':
966
- $product_properties_condition .= "{sum product." . $property_type . "." . $property_name . "}" . $cmp_symbol . $cmp_value;
967
- break;
968
- case 'all':
969
- $product_properties_condition .= "{count products where product." . $property_type . "." . $property_name . $cmp_symbol . $cmp_value . "}=={products_quantity}";
970
- break;
971
- case 'any':
972
- $product_properties_condition .= "{count products where product." . $property_type . "." . $property_name . $cmp_symbol . $cmp_value . "}>0";
973
- break;
974
- }
975
- }
976
- if ($product_properties_condition != '')
977
- $conditions[] = $product_properties_condition;
978
- }
979
- else
980
- $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">product_properties</span>', '<span class="osh-formula">' . $row['product_properties']['value'] . '</span>');
981
- unset($row['product_properties']);
982
- }
983
- if (count($conditions) > 0)
984
- $row['conditions'] = array('value' => count($conditions) == 1 ? $conditions[0] : '(' . implode(') && (', $conditions) . ')');
985
-
986
- $fees = array();
987
- if (isset($row['fees_table'])) {
988
- if (!in_array('fees_table', $deprecated_properties))
989
- $deprecated_properties[] = 'fees_table';
990
- $options_and_data = $this->_getOptionsAndData($row['fees_table']['value']);
991
- $options = $options_and_data['options'];
992
- $fees_table_string = $options_and_data['data'];
993
-
994
- $var = null;
995
- if ($options == '')
996
- $var = (isset($row['reference_value']) ? $row['reference_value']['value'] : 'weight');
997
- else if (in_array($options, array('incl.tax', 'ttc')))
998
- $var = 'price_including_tax';
999
- else if (in_array($options, array('excl.tax', 'ht')))
1000
- $var = 'price_excluding_tax';
1001
-
1002
- if (isset($var)) {
1003
- if ($var == 'price')
1004
- $var = 'price_excluding_tax';
1005
- if ($var == 'products_quantity')
1006
- $var = 'quantity';
1007
- if (preg_match('/^[[:space:]]*\*[[:space:]]*:[[:space:]]*(' . $float_value_regex . ')[[:space:]]*$/s', $fees_table_string, $result))
1008
- $fees[] = $result[1];
1009
- else
1010
- $fees[] = "{table {cart." . $var . "} in " . str_replace(' ', '', $fees_table_string) . "}" . ($var == 'quantity' ? '*{cart.quantity}' : '');
1011
- }
1012
- else
1013
- $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">fees_table</span>', '<span class="osh-formula">' . $row['fees_table']['value'] . '</span>');
1014
- unset($row['fees_table']);
1015
- }
1016
- if (isset($row['fees_formula'])) {
1017
- if (!in_array('fees_formula', $deprecated_properties))
1018
- $deprecated_properties[] = 'fees_formula';
1019
- $fees[] = str_replace(' ', '', $row['fees_formula']['value']);
1020
- unset($row['fees_formula']);
1021
- }
1022
- if (isset($row['fixed_fees'])) {
1023
- if (!in_array('fixed_fees', $deprecated_properties))
1024
- $deprecated_properties[] = 'fixed_fees';
1025
- if ($row['fixed_fees']['value'] != 0 || count($fees) == 0)
1026
- $fees[] = str_replace(' ', '', $row['fixed_fees']['value']);
1027
- unset($row['fixed_fees']);
1028
- }
1029
- if (!isset($row['fees']) && count($fees) > 0)
1030
- $row['fees'] = array('value' => implode('+', $fees));
1031
-
1032
- $fs_fees = array();
1033
- if (isset($row['free_shipping__fees_table'])) {
1034
- if (!in_array('free_shipping__fees_table', $deprecated_properties))
1035
- $deprecated_properties[] = 'free_shipping__fees_table';
1036
- $options_and_data = $this->_getOptionsAndData($row['free_shipping__fees_table']['value']);
1037
- $options = $options_and_data['options'];
1038
- $fees_table_string = $options_and_data['data'];
1039
-
1040
- $var = null;
1041
- if ($options == '')
1042
- $var = isset($row['reference_value']) ? $row['reference_value']['value'] : 'weight';
1043
- else if (in_array($options, array('incl.tax', 'ttc')))
1044
- $var = 'price_including_tax';
1045
- else if (in_array($options, array('excl.tax', 'ht')))
1046
- $var = 'price_excluding_tax';
1047
- if ($var == 'price')
1048
- $var = 'price_excluding_tax';
1049
-
1050
- if (isset($var)) {
1051
- if ($var == 'price')
1052
- $var = 'price_excluding_tax';
1053
- if ($var == 'products_quantity')
1054
- $var = 'quantity';
1055
- if (preg_match('/^[[:space:]]*\*[[:space:]]*:[[:space:]]*(' . $float_value_regex . ')[[:space:]]*$/s', $fees_table_string, $result))
1056
- $fs_fees[] = $result[1];
1057
- else
1058
- $fs_fees[] = "{table {cart." . $var . "} in " . str_replace(' ', '', $fees_table_string) . "}" . ($var == 'quantity' ? '*{cart.quantity}' : '');
1059
- }
1060
- else
1061
- $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">free_shipping__fees_table</span>', '<span class="osh-formula">' . $row['free_shipping__fees_table']['value'] . '</span>');
1062
- unset($row['free_shipping__fees_table']);
1063
- }
1064
- if (isset($row['free_shipping__fees_formula'])) {
1065
- if (!in_array('free_shipping__fees_formula', $deprecated_properties))
1066
- $deprecated_properties[] = 'free_shipping__fees_formula';
1067
- $fs_fees[] = str_replace(' ', '', $row['free_shipping__fees_formula']['value']);
1068
- unset($row['free_shipping__fees_formula']);
1069
- }
1070
- if (isset($row['free_shipping__fixed_fees'])) {
1071
- if (!in_array('free_shipping__fixed_fees', $deprecated_properties))
1072
- $deprecated_properties[] = 'free_shipping__fixed_fees';
1073
- if ($row['free_shipping__fixed_fees']['value'] != 0 || count($fees) == 0)
1074
- $fs_fees[] = str_replace(' ', '', $row['free_shipping__fixed_fees']['value']);
1075
- unset($row['free_shipping__fixed_fees']);
1076
- }
1077
-
1078
- if (isset($row['reference_value'])) {
1079
- if (!in_array('reference_value', $deprecated_properties))
1080
- $deprecated_properties[] = 'reference_value';
1081
- unset($row['reference_value']);
1082
- }
1083
-
1084
- if (count($fs_fees) > 0) {
1085
- $row2 = $row;
1086
- if (isset($row['code']))
1087
- $row2['code']['value'] = $row['code']['value'] . '__free_shipping';
1088
- $row2['fees']['value'] = implode('+', $fs_fees);
1089
- $row2['conditions']['value'] = isset($row2['conditions']) ? '(' . $row2['conditions'] + ') and {free_shipping}' : '{free_shipping}';
1090
- $row['conditions']['value'] = isset($row['conditions']) ? '(' . $row['conditions'] + ') and !{free_shipping}' : '!{free_shipping}';
1091
- if (isset($row['free_shipping__label'])) {
1092
- if (!in_array('free_shipping__label', $deprecated_properties))
1093
- $deprecated_properties[] = 'free_shipping__label';
1094
- $row2['label']['value'] = $row['free_shipping__label']['value'];
1095
- unset($row['free_shipping__label']);
1096
- unset($row2['free_shipping__label']);
1097
- }
1098
- $this->_addRow($row2);
1099
- }
1100
- if (count($unknown_properties) > 0)
1101
- $this->addMessage('error', $row, null, 'Usage of unknown properties %s', ': <span class="osh-key">' . implode('</span>, <span class="osh-key">', $unknown_properties) . '</span>');
1102
- if (count($deprecated_properties) > 0)
1103
- $this->addMessage('warning', $row, null, 'Usage of deprecated properties %s', ': <span class="osh-key">' . implode('</span>, <span class="osh-key">', $deprecated_properties) . '</span>');
1104
- if (count($obsolete_disabling_method) > 0)
1105
- $this->addMessage('warning', $row, null, 'Usage of obsolete method to disabling a shipping method (`#` before `{`)%s', '<div class="code">' . implode('<br />', $obsolete_disabling_method) . '</div>');
1106
- if (count($missing_semicolon) > 0)
1107
- $this->addMessage('warning', $row, null, 'A semicolon is missing at the end of following lines %s', '<div class="code">' . implode('<br />', $missing_semicolon) . '</div>');
1108
- $this->_addRow($row);
1109
- }
1110
- if (trim($config_string) != '') {
1111
- $this->_addIgnoredLines(trim($config_string));
1112
- $row = null;
1113
- $this->addMessage('info', $row, null, 'Ignored lines %s', '<div class="code">' . trim($config_string) . '</div>');
1114
- }
1115
- }
1116
-
1117
- public function addMessage($type, &$row, $property) {
1118
- $args = func_get_args();
1119
- array_shift($args);
1120
- array_shift($args);
1121
- array_shift($args);
1122
- $message = new OCS_Message($type, $args);
1123
- if (isset($row)) {
1124
- if (isset($property)) {
1125
- $row[$property]['messages'][] = $message;
1126
- } else {
1127
- $row['*messages'][] = $message;
1128
- }
1129
- }
1130
- $this->_messages[] = $message;
1131
- self::debug(' => <span class="osh-' . $message->type . '">' . $message->toString() . '</span>', 1);
1132
- }
1133
-
1134
- protected function _addRow(&$row) {
1135
- if (isset($row['code'])) {
1136
- $key = $row['code']['value'];
1137
- if (isset($this->_config[$key]))
1138
- $this->addMessage('error', $row, 'code', 'The property `code` must be unique, `%s` has been found twice', $key);
1139
- while (isset($this->_config[$key]))
1140
- $key .= rand(0, 9);
1141
- //$row['code'] = $key;
1142
- } else {
1143
- $i = 1;
1144
- do {
1145
- $key = 'code_auto' . sprintf('%03d', $i);
1146
- $i++;
1147
- } while (isset($this->_config[$key]));
1148
- }
1149
- $row['*code'] = $key;
1150
- $this->_config[$key] = $row;
1151
- }
1152
-
1153
- protected function _addIgnoredLines($lines) {
1154
- $this->_config[] = array('lines' => $lines);
1155
- }
1156
-
1157
- protected function _addressMatch($address_filter, $address) {
1158
- $excluding = false;
1159
- if (preg_match('# *\* *- *\((.*)\) *#s', $address_filter, $result)) {
1160
- $address_filter = $result[1];
1161
- $excluding = true;
1162
- }
1163
-
1164
- $tmp_address_filter_array = explode(',', trim($address_filter));
1165
-
1166
- $concat = false;
1167
- $concatened = '';
1168
- $address_filter_array = array();
1169
- $i = 0;
1170
-
1171
- foreach ($tmp_address_filter_array as $address_filter) {
1172
- if ($concat)
1173
- $concatened .= ',' . $address_filter;
1174
- else {
1175
- if ($i < count($tmp_address_filter_array) - 1 && preg_match('#\(#', $address_filter)) {
1176
- $concat = true;
1177
- $concatened .= $address_filter;
1178
- }
1179
- else
1180
- $address_filter_array[] = $address_filter;
1181
- }
1182
- if (preg_match('#\)#', $address_filter)) {
1183
- $address_filter_array[] = $concatened;
1184
- $concatened = '';
1185
- $concat = false;
1186
- }
1187
- $i++;
1188
- }
1189
-
1190
- foreach ($address_filter_array as $address_filter) {
1191
- if (preg_match('# *([A-Z]{2}) *(-)? *(?:\( *(-)? *(.*)\))? *#s', $address_filter, $result)) {
1192
- $country_code = $result[1];
1193
- if ($address['country_code'] == $country_code) {
1194
- self::debug(' country code <span class="osh-replacement">' . $address['country_code'] . '</span> matches', 5);
1195
- if (!isset($result[4]) || $result[4] == '')
1196
- return !$excluding;
1197
- else {
1198
- $region_codes = explode(',', $result[4]);
1199
- $in_array = false;
1200
- for ($i = count($region_codes); --$i >= 0;) {
1201
- $code = trim($region_codes[$i]);
1202
- $region_codes[$i] = $code;
1203
- if ($address['region_code'] === $code) {
1204
- self::debug(' region code <span class="osh-replacement">' . $address['region_code'] . '</span> matches', 5);
1205
- $in_array = true;
1206
- } else if ($address['postcode'] === $code) {
1207
- self::debug(' postcode <span class="osh-replacement">' . $address['postcode'] . '</span> matches', 5);
1208
- $in_array = true;
1209
- } else if (strpos($code, '*') !== false && preg_match('/^' . str_replace('*', '(?:.*)', $code) . '$/', $address['postcode'])) {
1210
- self::debug(' postcode <span class="osh-replacement">' . $address['postcode'] . '</span> matches <span class="osh-formula">' . $code . '</span>', 5);
1211
- $in_array = true;
1212
- }
1213
- if ($in_array)
1214
- break;
1215
- }
1216
- if (!$in_array) {
1217
- self::debug(' region code <span class="osh-replacement">' . $address['region_code'] . '</span> and postcode <span class="osh-replacement">' . $address['postcode'] . '</span> don\'t match', 5);
1218
- }
1219
- // Vérification stricte
1220
- /* $in_array = in_array($address['region_code'],$region_codes,true) || in_array($address['postcode'],$region_codes,true); */
1221
- $excluding_region = $result[2] == '-' || $result[3] == '-';
1222
- if ($excluding_region && !$in_array || !$excluding_region && $in_array)
1223
- return !$excluding;
1224
- }
1225
- }
1226
- }
1227
- }
1228
- return $excluding;
1229
- }
1230
-
1231
- protected function _getProductProperty($product, $property_type, $property_name, $get_by_id = false) {
1232
- switch ($property_type) {
1233
- case 'attribute':
1234
- case 'attributes': return $product->getAttribute($property_name, $get_by_id);
1235
- case 'option':
1236
- case 'options': return $product->getOption($property_name, $get_by_id);
1237
- case 'stock': return $product->getStockData($property_name);
1238
- }
1239
- return null;
1240
- }
1241
-
1242
- protected function _processProductProperty($products, $regex_result) {
1243
- // COUNT, SUM or COUNT DISTINCT
1244
- $operation = strtolower($regex_result[1]);
1245
- switch ($operation) {
1246
- case 'sum':
1247
- case 'count distinct':
1248
- $property_type = $regex_result[2];
1249
- $property_name = $regex_result[3];
1250
- $conditions = isset($regex_result[4]) ? $regex_result[4] : null;
1251
- break;
1252
- case 'count':
1253
- $conditions = isset($regex_result[2]) ? $regex_result[2] : null;
1254
- break;
1255
- }
1256
-
1257
- self::debug(' :: start <span class="osh-replacement">' . $regex_result[0] . '</span>', 10);
1258
-
1259
- $return_value = 0;
1260
-
1261
- preg_match_all('/product\.(attribute(?:s)?|option(?:s)?|stock)\.([a-z0-9_]+)(?:\.(id))?/i', $conditions, $properties_regex_result, PREG_SET_ORDER);
1262
- $properties = array();
1263
- foreach ($properties_regex_result as $property_regex_result) {
1264
- $key = $property_regex_result[0];
1265
- if (!isset($properties[$key]))
1266
- $properties[$key] = $property_regex_result;
1267
- }
1268
-
1269
- foreach ($products as $product) {
1270
- if (isset($conditions) && $conditions != '') {
1271
- $formula = $conditions;
1272
- foreach ($properties as $property) {
1273
- $value = $this->_getProductProperty(
1274
- $product, $tmp_property_type = $property[1], $tmp_property_name = $property[2], $get_by_id = isset($property[3]) && $property[3] == 'id'
1275
- );
1276
- //$formula = $this->replace($property[0],$value,$formula);
1277
- $from = $property[0];
1278
- $to = is_string($value) || empty($value) ? "'" . $value . "'" : $value;
1279
- $formula = str_replace($from, $to, $formula);
1280
- self::debug(' replace <span class="osh-replacement">' . $from . '</span> by <span class="osh-replacement">' . $to . '</span> =&gt; <span class="osh-formula">' . str_replace($from, '<span class="osh-replacement">' . $to . '</span>', $formula) . '</span>', 5);
1281
- }
1282
- $eval_result = $this->_evalFormula($formula);
1283
- if (!isset($eval_result))
1284
- return 'null';
1285
- }
1286
- else
1287
- $eval_result = true;
1288
-
1289
- if ($eval_result == true) {
1290
- switch ($operation) {
1291
- case 'sum':
1292
- $value = $this->_getProductProperty($product, $property_type, $property_name);
1293
- //self::debug($product->getSku().'.'.$property_type.'.'.$property_name.' = "'.$value.'" x '.$product->getQuantity(),10);
1294
- $return_value += $value * $product->getQuantity();
1295
- break;
1296
- case 'count distinct':
1297
- if (!isset($distinct_values))
1298
- $distinct_values = array();
1299
- $value = $this->_getProductProperty($product, $property_type, $property_name);
1300
- if (!in_array($value, $distinct_values)) {
1301
- $distinct_values[] = $value;
1302
- $return_value++;
1303
- }
1304
- break;
1305
- case 'count':
1306
- $return_value += $product->getQuantity();
1307
- break;
1308
- }
1309
- }
1310
- }
1311
-
1312
- self::debug(' :: end <span class="osh-replacement">' . $regex_result[0] . '</span>', 10);
1313
-
1314
- return $return_value;
1315
- }
1316
-
1317
- }
1318
-
1319
- interface OCS_Product {
1320
-
1321
- public function getOption($option);
1322
-
1323
- public function getAttribute($attribute);
1324
-
1325
- public function getName();
1326
-
1327
- public function getSku();
1328
-
1329
- public function getQuantity();
1330
-
1331
- public function getStockData($key);
1332
- }
1333
-
1334
- class OCS_Message {
1335
-
1336
- public $type;
1337
- public $message;
1338
- public $args;
1339
-
1340
- public function OCS_Message($type, $args) {
1341
- $this->type = $type;
1342
- $this->message = array_shift($args);
1343
- $this->args = $args;
1344
- }
1345
-
1346
- public function toString() {
1347
- return vsprintf($this->message, $this->args);
1348
- }
1349
-
1350
- }
1351
-
1352
- class OCS_Result {
1353
-
1354
- public $success;
1355
- public $result;
1356
-
1357
- public function OCS_Result($success, $result = null) {
1358
- $this->success = $success;
1359
- $this->result = $result;
1360
- }
1361
-
1362
- public function __toString() {
1363
- return is_bool($this->result) ? ($this->result ? 'true' : 'false') : (string) $this->result;
1364
- }
1365
-
1366
- }
1367
-
1368
- ?>
1
+ <?php
2
+
3
+ /**
4
+ * Magento Chronopost Chronorelais Module
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Chronopost
17
+ * @package Chronopost_Chronorelais
18
+ * @copyright Copyright (c) 2008-10 Owebia (http://www.owebia.com/)
19
+ * @author Antoine Lemoine
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ class ChronorelaisShippingHelper {
23
+
24
+ public static $DEBUG_INDEX_COUNTER = 0;
25
+ public static $FLOAT_REGEX = '[-]?\d+(?:[.]\d+)?';
26
+ public static $POSITIVE_FLOAT_REGEX = '\d+(?:[.]\d+)?';
27
+ public static $COUPLE_REGEX = '(?:[0-9.]+|\*) *(?:\[|\])? *\: *[0-9.]+';
28
+ public static $UNCOMPRESSED_STRINGS = array(
29
+ ' product.attribute.',
30
+ ' product.option.',
31
+ ' product.stock.',
32
+ '{product.attribute.',
33
+ '{product.option.',
34
+ '{product.stock.',
35
+ '{product.weight}',
36
+ '{product.quantity}',
37
+ '{cart.weight}',
38
+ '{cart.quantity}',
39
+ '{cart.price_including_tax}',
40
+ '{cart.price_excluding_tax}',
41
+ '{cart.',
42
+ '{customvar.',
43
+ '{selection.weight}',
44
+ '{selection.quantity}',
45
+ '{selection.',
46
+ '{destination.country.',
47
+ '{foreach ',
48
+ '{/foreach}',
49
+ );
50
+ public static $COMPRESSED_STRINGS = array(
51
+ ' p.a.',
52
+ ' p.o.',
53
+ ' p.s.',
54
+ '{p.a.',
55
+ '{p.o.',
56
+ '{p.s.',
57
+ '{p.w}',
58
+ '{p.qty}',
59
+ '{c.w}',
60
+ '{c.qty}',
61
+ '{c.pit}',
62
+ '{c.pet}',
63
+ '{c.',
64
+ '{v.',
65
+ '{s.w}',
66
+ '{s.qty}',
67
+ '{s.',
68
+ '{dest.ctry.',
69
+ '{each ',
70
+ '{/each}',
71
+ );
72
+ protected $_input;
73
+ protected $_config;
74
+ protected $_messages;
75
+ protected $_formula_cache;
76
+ protected $_expression_cache;
77
+ public $debug = 0;
78
+ public $debug_output = '';
79
+ public $debug_header = null;
80
+
81
+ public function ChronorelaisShippingHelper($input) {
82
+ $this->_formula_cache = array();
83
+ $this->_messages = array();
84
+ $this->_input = $input;
85
+ $this->_config = array();
86
+ $this->_parseInput();
87
+ }
88
+
89
+ private function debug($text, $level = 10) {
90
+ if ($this->debug >= $level)
91
+ $this->debug_output .= "<p>" . $text . "</p>";
92
+ }
93
+
94
+ public function printDebug() {
95
+ if ($this->debug > 0) {
96
+ $index = self::$DEBUG_INDEX_COUNTER++;
97
+ echo "<style rel=\"stylesheet\" type=\"text/css\">"
98
+ . ".osh-formula{color:#f90;} .osh-key{color:#0099f7;}"
99
+ . ".osh-error{color:#f00;} .osh-warning{color:#ff0;} .osh-info{color:#7bf700;}"
100
+ . ".osh-debug{background:#000;color:#bbb;position:absolute;top:0;left:0;width:100%;z-index:100;-moz-opacity:0.9;opacity:0.9;text-align:left;white-space:pre-wrap;}"
101
+ . ".osh-debug-content{padding:10px;}"
102
+ . ".osh-replacement{color:#ff3000;}"
103
+ . "</style>"
104
+ . "<div id=\"osh-debug-" . $index . "\" class=\"osh-debug\"><pre class=\"osh-debug-content\"><span style=\"float:right;cursor:pointer;\" onclick=\"document.getElementById('osh-debug-" . $index . "').style.display = 'none';\">[<span style=\"padding:0 5px;color:#f00;\">X</span>]</span>"
105
+ . "<p>" . $this->debug_header . "</p>" . $this->debug_output . "</pre></div>";
106
+ }
107
+ }
108
+
109
+ public function setDebugHeader($process) {
110
+ $header = 'DEBUG app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronorelaisShippingHelper.php<br/>';
111
+ foreach ($process['data'] as $key => $data) {
112
+ $header .= ' <span class="osh-key">' . $key . '</span> = <span class="osh-formula">' . $this->_toString($data) . '</span><br/>';
113
+ }
114
+ $this->debug_header = $header;
115
+ }
116
+
117
+ public function getConfig() {
118
+ return $this->_config;
119
+ }
120
+
121
+ public function getMessages() {
122
+ $messages = $this->_messages;
123
+ $this->_messages = array();
124
+ return $messages;
125
+ }
126
+
127
+ public function formatConfig($compress) {
128
+ $output = '';
129
+ foreach ($this->_config as $code => $row) {
130
+ if (!isset($row['lines'])) {
131
+ if (isset($row['*comment']['value'])) {
132
+ $output .= trim($row['*comment']['value']) . "\n";
133
+ }
134
+ $output .= '{' . ($compress ? '' : "\n");
135
+ foreach ($row as $key => $property) {
136
+ if (substr($key, 0, 1) != '*') {
137
+ $value = $property['value'];
138
+ if (isset($property['comment']))
139
+ $output .= ($compress ? '' : "\t") . '/* ' . $property['comment'] . ' */' . ($compress ? '' : "\n");
140
+ $output .= ($compress ? '' : "\t") . $key . ':' . ($compress ? '' : ' ');
141
+ if (is_bool($value))
142
+ $output .= $value ? 'true' : 'false';
143
+ else if (is_int($value))
144
+ $output .= $value;
145
+ else if ((string) ((float) $value) == $value)
146
+ $output .= $value;
147
+ else
148
+ $output .= '"' . str_replace('"', '\\"', $value) . '"';
149
+ $output .= ',' . ($compress ? '' : "\n");
150
+ }
151
+ }
152
+ if ($compress)
153
+ $output = preg_replace('/,$/', '', $output);
154
+ $output .= "}\n" . ($compress ? '' : "\n");
155
+ } else {
156
+ $output .= $row['lines'] . "\n";
157
+ }
158
+ }
159
+ return $compress ? $this->compress($output) : $this->uncompress($output);
160
+ }
161
+
162
+ public function checkConfig() {
163
+ $process = array(
164
+ 'result' => null,
165
+ 'data' => array(
166
+ 'cart.price_excluding_tax' => 0,
167
+ 'cart.price_including_tax' => 0,
168
+ 'destination.country.code' => '',
169
+ 'destination.country.name' => '',
170
+ 'destination.region.code' => '',
171
+ 'destination.postcode' => '',
172
+ 'origin.country.code' => '',
173
+ 'origin.country.name' => '',
174
+ 'origin.region.code' => '',
175
+ 'origin.postcode' => '',
176
+ 'free_shipping' => false,
177
+ 'customer.group.id' => '',
178
+ 'customer.group.code' => '',
179
+ 'cart.weight' => 0,
180
+ 'cart.weight.unit' => 'kg',
181
+ 'cart.quantity' => 0,
182
+ ),
183
+ 'cart.items' => array(),
184
+ 'products' => array(),
185
+ 'config' => $this->_config,
186
+ );
187
+ foreach ($this->_config as $code => &$row) {
188
+ $this->processRow($process, $row, $check_all_conditions = true);
189
+ foreach ($row as $property_key => $property_value) {
190
+ if (substr($property_key, 0, 1) != '*')
191
+ $this->getRowProperty($row, $property_key);
192
+ }
193
+ }
194
+ }
195
+
196
+ public function processRow($process, &$row, $is_checking = false) {
197
+ if (!isset($row['*code']) || !isset($process['data']['carrier.code']))
198
+ return;
199
+
200
+ self::debug('process row <span class="osh-key">' . $row['*code'] . '</span>', 1);
201
+ if (!isset($row['label']['value']))
202
+ $row['label']['value'] = '***';
203
+
204
+ $enabled = $this->getRowProperty($row, 'enabled');
205
+ if (isset($enabled)) {
206
+ if (!$is_checking && !$enabled) {
207
+ $this->addMessage('info', $row, 'enabled', 'Configuration disabled');
208
+ return new OCS_Result(false);
209
+ }
210
+ }
211
+
212
+ $conditions = $this->getRowProperty($row, 'conditions');
213
+ if (isset($conditions)) {
214
+ $result = $this->_processFormula($process, $row, 'conditions', $conditions, $is_checking);
215
+ if (!$is_checking) {
216
+ if (!$result->success)
217
+ return $result;
218
+ if (!$result->result) {
219
+ $this->addMessage('info', $row, 'conditions', "The cart doesn't match conditions");
220
+ return new OCS_Result(false);
221
+ }
222
+ }
223
+ }
224
+
225
+ $destination = $this->getRowProperty($row, 'destination');
226
+ if (isset($destination)) {
227
+ $destination_match = $this->_addressMatch($destination, array(
228
+ 'country_code' => $process['data']['destination.country.code'],
229
+ 'region_code' => $process['data']['destination.region.code'],
230
+ 'postcode' => $process['data']['destination.postcode']
231
+ ));
232
+ if (!$is_checking && !$destination_match) {
233
+ $this->addMessage('info', $row, 'destination', "The shipping method doesn't cover the zone");
234
+ return new OCS_Result(false);
235
+ }
236
+ }
237
+
238
+ $origin = $this->getRowProperty($row, 'origin');
239
+ if (isset($origin)) {
240
+ $origin_match = $this->_addressMatch($origin, array(
241
+ 'country_code' => $process['data']['origin.country.code'],
242
+ 'region_code' => $process['data']['origin.region.code'],
243
+ 'postcode' => $process['data']['origin.postcode']
244
+ ));
245
+ if (!$is_checking && !$origin_match) {
246
+ $this->addMessage('info', $row, 'origin', "The shipping method doesn't match to shipping origin");
247
+ return new OCS_Result(false);
248
+ }
249
+ }
250
+
251
+ $customer_groups = $this->getRowProperty($row, 'customer_groups');
252
+ if (isset($customer_groups)) {
253
+ $groups = explode(',', $customer_groups);
254
+ $group_match = false;
255
+ //self::debug('code:'.$process['data']['customer.group.code'].', id:'.$process['data']['customer.group.id']);
256
+ foreach ($groups as $group) {
257
+ $group = trim($group);
258
+ if ($group == $process['data']['customer.group.code'] || is_int($group) && $group == $process['data']['customer.group.id'] || $group == '*') {
259
+ $group_match = true;
260
+ break;
261
+ }
262
+ }
263
+ if (!$is_checking && !$group_match) {
264
+ $this->addMessage('info', $row, 'customer_groups', "The shipping method doesn't match to customer group (%s)", $process['data']['customer.group.code']);
265
+ return new OCS_Result(false);
266
+ }
267
+ }
268
+
269
+ //Chronopost quickcost method for dynamic price if it is set enabled
270
+ $quickcost = Mage::getStoreConfig('carriers/' . $process['data']['carrier.code'] . '/quickcost');
271
+ if ($quickcost) {
272
+ if ($quickCostValues = $this->getQuickCostValue($process['data'])) {
273
+ if ($quickCostValues->errorCode == 0) {
274
+ return new OCS_Result(true, (float) $quickCostValues->amountTTC);
275
+ } else {
276
+ $this->addMessage('error', $row, 'chronopost', $quickCostValues->errorMessage);
277
+ return new OCS_Result(false);
278
+ }
279
+ } else { /* if false => WS inaccessible donc on prend les prix de la grille */
280
+ //return new OCS_Result(false);
281
+ }
282
+ }
283
+
284
+ /* Prix via la grille du BO */
285
+ $fees = $this->getRowProperty($row, 'fees');
286
+ if (isset($fees)) {
287
+ $result = $this->_processFormula($process, $row, 'fees', $fees, $is_checking);
288
+ if (!$result->success)
289
+ return $result;
290
+ self::debug(' => <span class="osh-info">result = <span class="osh-formula">' . $this->_toString($result->result) . '</span>', 1);
291
+ return new OCS_Result(true, (float) $result->result);
292
+ }
293
+
294
+ return new OCS_Result(false);
295
+ }
296
+
297
+ public function getQuickCostValue($processData) {
298
+ $quickCost = array();
299
+ $_helper = Mage::helper('chronorelais');
300
+ $account_number = $_helper->getConfigurationAccountNumber();
301
+ $password = $_helper->getConfigurationAccountPass();
302
+ $productCode = $_helper->getChronoProductCode($processData['destination.country.code'], $processData['carrier.code']);
303
+ $origin_postcode = $_helper->getConfigurationShipperInfo('zipcode');
304
+
305
+ //to get arrival code
306
+ $arrCode = $processData['destination.postcode'];
307
+ if ($processData['carrier.code'] == 'chronoexpress' || $processData['carrier.code'] == 'chronopostcclassic') {
308
+ $arrCode = $processData['destination.country.code'];
309
+ }
310
+
311
+ $cartWeight = $processData['cart.weight'];
312
+ if ($_helper->getConfigWeightUnit() == 'g') {
313
+ $cartWeight = $cartWeight / 1000; /* conversion g => kg */
314
+ }
315
+ $quickCost = array(
316
+ 'accountNumber' => $account_number,
317
+ 'password' => $password,
318
+ 'depCode' => $origin_postcode,
319
+ 'arrCode' => $arrCode,
320
+ 'weight' => $cartWeight,
321
+ 'productCode' => $productCode,
322
+ 'type' => 'M'
323
+ );
324
+
325
+ $quickcost_url = Mage::helper('chronorelais')->getConfigData('carriers/' . $processData['carrier.code'] . '/quickcost_url');
326
+
327
+ $helperWS = Mage::helper('chronorelais/webservice');
328
+ return $helperWS->getQuickcost($quickCost,$quickcost_url);
329
+ }
330
+
331
+ public function getRowProperty(&$row, $key, $original_row = null, $original_key = null) {
332
+ $property = null;
333
+ $output = null;
334
+ if (isset($original_row) && isset($original_key) && $original_row['*code'] == $row['*code'] && $original_key == $key) {
335
+ $this->addMessage('error', $row, $key, 'Infinite loop %s', "<span class=\"code\">{" . $row['*code'] . '.' . $key . "}</span>");
336
+ return array('error' => 'Infinite loop');
337
+ }
338
+ if (isset($row[$key]['value'])) {
339
+ $property = $row[$key]['value'];
340
+ $output = $property;
341
+ self::debug(' get <span class="osh-key">' . $row['*code'] . '</span>.<span class="osh-key">' . $key . '</span> = <span class="osh-formula">' . $this->_toString($property) . '</span>', 5);
342
+ preg_match_all('/{([a-z0-9_]+)\.([a-z0-9_]+)}/i', $output, $result_set, PREG_SET_ORDER);
343
+ foreach ($result_set as $result) {
344
+ list($original, $ref_code, $ref_key) = $result;
345
+ if (!in_array($ref_code, array('module', 'date', 'store', 'cart', 'product', 'selection', 'customvar'))) {
346
+ if ($ref_code == $row['code']['value'] && $ref_key == $key) {
347
+ $this->addMessage('error', $row, $key, 'Infinite loop %s', "<span class=\"code\">" . $original . "</span>");
348
+ return null;
349
+ }
350
+ if (isset($this->_config[$ref_code][$ref_key]['value'])) {
351
+ $replacement = $this->getRowProperty($this->_config[$ref_code], $ref_key, isset($original_row) ? $original_row : $row, isset($original_key) ? $original_key : $key);
352
+ if (is_array($replacement) && isset($replacement['error'])) {
353
+ return isset($original_row) ? $replacement : 'false';
354
+ }
355
+ } else {
356
+ $this->addMessage('error', $row, $key, 'Non-existent property %s', "<span class=\"code\">" . $original . "</span>");
357
+ $replacement = 'null';
358
+ }
359
+ $output = $this->replace($original, $replacement, $output);
360
+ }
361
+ }
362
+ } else {
363
+ self::debug(' get <span class="osh-key">' . $row['*code'] . '</span>.<span class="osh-key">' . $key . '</span> = <span class="osh-formula">null</span>', 5);
364
+ }
365
+ return $output;
366
+ }
367
+
368
+ protected function _toString($value) {
369
+ if (!isset($value))
370
+ return 'null';
371
+ else if (is_bool($value))
372
+ return $value ? 'true' : 'false';
373
+ else
374
+ return $value;
375
+ }
376
+
377
+ protected function replace($from, $to, $input) {
378
+ if ($from === $to)
379
+ return $input;
380
+ if (strpos($input, $from) === false)
381
+ return $input;
382
+ $to = $this->_toString($to);
383
+ self::debug(' replace <span class="osh-replacement">' . $this->_toString($from) . '</span> by <span class="osh-replacement">' . $to . '</span> =&gt; <span class="osh-formula">' . str_replace($from, '<span class="osh-replacement">' . $to . '</span>', $input) . '</span>', 5);
384
+ return str_replace($from, $to, $input);
385
+ }
386
+
387
+ protected function _min() {
388
+ $args = func_get_args();
389
+ $min = null;
390
+ foreach ($args as $arg) {
391
+ if (isset($arg) && (!isset($min) || $min > $arg))
392
+ $min = $arg;
393
+ }
394
+ return $min;
395
+ }
396
+
397
+ protected function _max() {
398
+ $args = func_get_args();
399
+ $max = null;
400
+ foreach ($args as $arg) {
401
+ if (isset($arg) && (!isset($max) || $max < $arg))
402
+ $max = $arg;
403
+ }
404
+ return $max;
405
+ }
406
+
407
+ protected function _processFormula($process, &$row, $property_key, $formula_string, $is_checking, $use_cache = true) {
408
+ $result = $this->_prepareFormula($process, $row, $property_key, $formula_string, $is_checking, $use_cache);
409
+ if (!$result->success)
410
+ return $result;
411
+
412
+ $eval_result = $this->_evalFormula($result->result);
413
+ if (!isset($eval_result)) {
414
+ $this->addMessage('error', $row, $property_key, 'Invalid formula');
415
+ $result = new OCS_Result(false);
416
+ if ($use_cache)
417
+ $this->setCache($formula_string, $result);
418
+ return $result;
419
+ }
420
+ self::debug(' formula evaluation = <span class="osh-formula">' . $this->_toString($eval_result) . '</span>', 10);
421
+ $result = new OCS_Result(true, $eval_result);
422
+ if ($use_cache)
423
+ $this->setCache($formula_string, $result);
424
+ return $result;
425
+ }
426
+
427
+ public function evalInput($process, $row, $property_key, $input) {
428
+ $result = $this->_prepareFormula($process, $row, $property_key, $input, $is_checking = false, $use_cache = true);
429
+ return $result->success ? $result->result : $input;
430
+ }
431
+
432
+ protected function setCache($expression, $value) {
433
+ if ($value instanceof OCS_Result) {
434
+ $this->_formula_cache[$expression] = $value;
435
+ self::debug(' cache <span class="osh-replacement">' . $expression . '</span> = <span class="osh-formula">' . $this->_toString($this->_formula_cache[$expression]) . '</span>', 10);
436
+ } else {
437
+ $value = $this->_toString($value);
438
+ $this->_expression_cache[$expression] = $value;
439
+ self::debug(' cache <span class="osh-replacement">' . $expression . '</span> = <span class="osh-formula">' . $value . '</span>', 10);
440
+ }
441
+ }
442
+
443
+ protected function _prepareFormula($process, $row, $property_key, $formula_string, $is_checking, $use_cache = true) {
444
+ if ($use_cache && isset($this->_formula_cache[$formula_string])) {
445
+ $result = $this->_formula_cache[$formula_string];
446
+ self::debug(' get cached formula <span class="osh-replacement">' . $formula_string . '</span> = <span class="osh-formula">' . $this->_toString($result->result) . '</span>', 10);
447
+ return $result;
448
+ }
449
+
450
+ $formula = $formula_string;
451
+ //self::debug(' formula = <span class="osh-formula">'.$formula.'</span>',10);
452
+
453
+ while (preg_match("#{foreach product\.((?:attribute|option)\.(?:[a-z0-9_]+))}(.*){/foreach}#i", $formula, $result)) {
454
+ $original = $result[0];
455
+ if ($use_cache && isset($this->_expression_cache[$original])) {
456
+ $replacement = $this->_expression_cache[$original];
457
+ self::debug(' get cached expression <span class="osh-replacement">' . $original . '</span> = <span class="osh-formula">' . $replacement . '</span>', 10);
458
+ } else {
459
+ $replacement = 0;
460
+ list($filter_property_type, $filter_property_name) = explode('.', $result[1]);
461
+ $selections = array();
462
+ self::debug(' :: foreach <span class="osh-key">' . $filter_property_type . '</span>.<span class="osh-key">' . $filter_property_name . '</span>', 10);
463
+ foreach ($process['products'] as $product) {
464
+ $tmp_value = $this->_getProductProperty($product, $filter_property_type, $filter_property_name, $get_by_id = false);
465
+ self::debug(' products[<span class="osh-formula">' . $product->getName() . '</span>].<span class="osh-key">' . $filter_property_type . '</span>.<span class="osh-key">' . $filter_property_name . '</span> = <span class="osh-formula">' . $this->_toString($tmp_value) . '</span>', 10);
466
+ $key = 'val_' . $tmp_value;
467
+ $sel = isset($selections[$key]) ? $selections[$key] : null;
468
+ $selections[$key]['products'][] = $product;
469
+ $selections[$key]['weight'] = (isset($sel['weight']) ? $sel['weight'] : 0) + $product->getAttribute('weight') * $product->getQuantity();
470
+ $selections[$key]['quantity'] = (isset($sel['quantity']) ? $sel['quantity'] : 0) + $product->getQuantity();
471
+ }
472
+ self::debug(' :: start foreach', 10);
473
+ foreach ($selections as $selection) {
474
+ $process2 = $process;
475
+ $process2['products'] = $selection['products'];
476
+ $process2['data']['selection.quantity'] = $selection['quantity'];
477
+ $process2['data']['selection.weight'] = $selection['weight'];
478
+ $process_result = $this->_processFormula($process2, $row, $property_key, $result[2], $is_checking, $tmp_use_cache = false);
479
+ $replacement += $process_result->result;
480
+ }
481
+ self::debug(' :: end foreach <span class="osh-key">' . $filter_property_type . '</span>.<span class="osh-key">' . $filter_property_name . '</span>', 10);
482
+ if ($use_cache)
483
+ $this->setCache($original, $replacement);
484
+ }
485
+ $formula = $this->replace($original, $replacement, $formula);
486
+ }
487
+
488
+ $formula = str_replace(array("\n", "\t"), array('', ''), $formula);
489
+
490
+ while (preg_match("#{customvar\.([a-z0-9_]+)}#i", $formula, $result)) {
491
+ $original = $result[0];
492
+ $replacement = Mage::getModel('core/variable')->loadByCode($result[1])->getValue('plain');
493
+ $formula = $this->replace($original, $replacement, $formula);
494
+ }
495
+
496
+ $first_product = isset($process['products'][0]) ? $process['products'][0] : null;
497
+ if (!isset($process['data']['selection.weight']))
498
+ $process['data']['selection.weight'] = $process['data']['cart.weight'];
499
+ if (!isset($process['data']['selection.quantity']))
500
+ $process['data']['selection.quantity'] = $process['data']['cart.quantity'];
501
+ $process['data']['product.weight'] = isset($first_product) ? $first_product->getAttribute('weight') : 0;
502
+ $process['data']['product.quantity'] = isset($first_product) ? $first_product->getQuantity() : 0;
503
+
504
+ foreach ($process['data'] as $original => $replacement) {
505
+ $formula = $this->replace('{' . $original . '}', $replacement, $formula);
506
+ }
507
+
508
+ if (isset($first_product)) {
509
+ while (preg_match("#{product\.(attribute|option|stock)\.([a-z0-9_]+)}#i", $formula, $result)) {
510
+ $original = $result[0];
511
+ switch ($result[1]) {
512
+ case 'attribute': $replacement = $first_product->getAttribute($result[2]);
513
+ break;
514
+ case 'option': $replacement = $first_product->getOption($result[2]);
515
+ break;
516
+ case 'stock': $replacement = $first_product->getStockData($result[2]);
517
+ break;
518
+ }
519
+ $formula = $this->replace($original, $replacement, $formula);
520
+ }
521
+ }
522
+
523
+ //while (preg_match("/{(count|all|any) (attribute|option) '([^'\)]+)' ?(==|<=|>=|<|>|!=) ?(".self::$FLOAT_REGEX."|true|false|'[^'\)]*')}/",$formula,$result)
524
+ // || preg_match("/{(sum|count distinct) (attribute|option) '([^'\)]+)'}/",$formula,$result))
525
+ while (preg_match("/{(count) products(?: where ([^}]+))?}/i", $formula, $result) || preg_match("/{(sum|count distinct) product\.(attribute|option)\.([a-z0-9_]+)(?: where ([^}]+))?}/i", $formula, $result)) {
526
+ $original = $result[0];
527
+ if ($use_cache && isset($this->_expression_cache[$original])) {
528
+ $replacement = $this->_expression_cache[$original];
529
+ self::debug(' get cached expression <span class="osh-replacement">' . $original . '</span> = <span class="osh-formula">' . $replacement . '</span>', 10);
530
+ } else {
531
+ $replacement = $this->_processProductProperty($process['products'], $result);
532
+ if ($use_cache)
533
+ $this->setCache($result[0], $replacement);
534
+ }
535
+ $formula = $this->replace($original, $replacement, $formula);
536
+ }
537
+
538
+ //while (preg_match("/{table '([^']+)' ([^}]+)}/",$formula,$result))
539
+ while (preg_match("/{table ([^}]+) in ([0-9\.:,\*\[\] ]+)}/i", $formula, $result)) {
540
+ $original = $result[0];
541
+ if ($use_cache && isset($this->_expression_cache[$original])) {
542
+ $replacement = $this->_expression_cache[$original];
543
+ self::debug(' get cached expression <span class="osh-replacement">' . $original . '</span> = <span class="osh-formula">' . $replacement . '</span>', 10);
544
+ } else {
545
+ $reference_value = $this->_evalFormula($result[1]);
546
+ if (isset($reference_value)) {
547
+ $fees_table_string = $result[2];
548
+
549
+ if (!preg_match('#^' . self::$COUPLE_REGEX . '(?:, *' . self::$COUPLE_REGEX . ')*$#', $fees_table_string)) {
550
+ $this->addMessage('error', $row, $property_key, 'Error in table %s', '<span class="osh-formula">' . htmlentities($result[0]) . '</span>');
551
+ $result = new OCS_Result(false);
552
+ if ($use_cache)
553
+ $this->setCache($formula_string, $result);
554
+ return $result;
555
+ }
556
+ $fees_table = explode(',', $fees_table_string);
557
+
558
+ $replacement = null;
559
+ foreach ($fees_table as $item) {
560
+ $fee_data = explode(':', $item);
561
+
562
+ $fee = trim($fee_data[1]);
563
+ $max_value = trim($fee_data[0]);
564
+
565
+ $last_char = $max_value{strlen($max_value) - 1};
566
+ if ($last_char == '[')
567
+ $including_max_value = false;
568
+ else if ($last_char == ']')
569
+ $including_max_value = true;
570
+ else
571
+ $including_max_value = true;
572
+
573
+ $max_value = str_replace(array('[', ']'), '', $max_value);
574
+
575
+ if ($max_value == '*' || $including_max_value && $reference_value <= $max_value || !$including_max_value && $reference_value < $max_value) {
576
+ $replacement = $fee; //$this->_calculateFee($process,$fee,$var);
577
+ break;
578
+ }
579
+ }
580
+ }
581
+ $replacement = $this->_toString($replacement);
582
+ if ($use_cache)
583
+ $this->setCache($original, $replacement);
584
+ }
585
+ $formula = $this->replace($original, $replacement, $formula);
586
+ }
587
+ $result = new OCS_Result(true, $formula);
588
+ return $result;
589
+ }
590
+
591
+ protected function _evalFormula($formula) {
592
+ if (is_bool($formula))
593
+ return $formula;
594
+ if (!preg_match('/^(?:floor|ceil|round|max|min|rand|pow|pi|sqrt|log|exp|abs|int|float|true|false|null|and|or|in|substr|strtolower'
595
+ . '|in_array\(\'(?:[^\']*)\', *array\( *(?:\'(?:[^\']+)\') *(?: *, *\'(?:[^\']+)\')* *\) *\)'
596
+ . '|\'[^\']*\'|[0-9,\'\.\-\(\)\*\/\?\:\+\<\>\=\&\|%! ])*$/', $formula)) {
597
+ $errors = array(
598
+ PREG_NO_ERROR => 'PREG_NO_ERROR',
599
+ PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR',
600
+ PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR',
601
+ PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR',
602
+ PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR',
603
+ PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR',
604
+ );
605
+ $error = preg_last_error();
606
+ if (isset($errors[$error]))
607
+ $error = $errors[$error];
608
+ self::debug(' doesn\'t match (' . $error . ')', 10);
609
+ return null;
610
+ }
611
+ $formula = str_replace(
612
+ array('min', 'max'), array('$this->_min', '$this->_max'), $formula
613
+ );
614
+ $eval_result = null;
615
+ @eval('$eval_result = (' . $formula . ');');
616
+ return $eval_result;
617
+ }
618
+
619
+ protected function _getOptionsAndData($string) {
620
+ if (preg_match('/^(\\s*\(\\s*([^\] ]*)\\s*\)\\s*)/', $string, $result)) {
621
+ $options = $result[2];
622
+ $data = str_replace($result[1], '', $string);
623
+ } else {
624
+ $options = '';
625
+ $data = $string;
626
+ }
627
+ return array(
628
+ 'options' => $options,
629
+ 'data' => $data,
630
+ );
631
+ }
632
+
633
+ public function compress($input) {
634
+ if (preg_match_all("/{table (.*) in (" . self::$COUPLE_REGEX . "(?:, *" . self::$COUPLE_REGEX . ")*)}/imsU", $input, $result, PREG_SET_ORDER)) {
635
+ foreach ($result as $result_i) {
636
+ $fees_table = explode(',', $result_i[2]);
637
+ $value = null;
638
+ foreach ($fees_table as $index => $item) {
639
+ list($max_value, $fee) = explode(':', $item);
640
+ $last_char = $max_value{strlen($max_value) - 1};
641
+ if (in_array($last_char, array('[', ']'))) {
642
+ $including_char = $last_char;
643
+ $max_value = str_replace(array('[', ']'), '', $max_value);
644
+ }
645
+ else
646
+ $including_char = '';
647
+ $fees_table[$index] = ((float) $max_value) . $including_char . ':' . ((float) $fee);
648
+ }
649
+ $input = str_replace($result_i[2], implode(',', $fees_table), $input);
650
+ $input = str_replace($result_i[1], trim($result_i[1]), $input);
651
+ }
652
+ }
653
+ if (preg_match_all("#{foreach ([^}]*)}(.*){/foreach}#imsU", $input, $result, PREG_SET_ORDER)) {
654
+ foreach ($result as $result_i) {
655
+ $input = str_replace($result_i[1], trim($result_i[1]), $input);
656
+ $input = str_replace($result_i[2], trim($result_i[2]), $input);
657
+ }
658
+ }
659
+ return '$$' . str_replace(
660
+ self::$UNCOMPRESSED_STRINGS, self::$COMPRESSED_STRINGS, $input
661
+ );
662
+ }
663
+
664
+ public function uncompress($input) {
665
+ if (preg_match_all("/{table (.*) in (" . self::$COUPLE_REGEX . "(?:, *" . self::$COUPLE_REGEX . ")*)}/iU", $input, $result, PREG_SET_ORDER)) {
666
+ foreach ($result as $result_i) {
667
+ $fees_table = explode(',', $result_i[2]);
668
+ $value = null;
669
+ foreach ($fees_table as $index => $item) {
670
+ list($max_value, $fee) = explode(':', $item);
671
+ $last_char = $max_value{strlen($max_value) - 1};
672
+ if (in_array($last_char, array('[', ']'))) {
673
+ $including_char = $last_char;
674
+ $max_value = str_replace(array('[', ']'), '', $max_value);
675
+ }
676
+ else
677
+ $including_char = '';
678
+ $max_value = (float) $max_value;
679
+ $fee = (float) $fee;
680
+ $new_max_value = number_format($max_value, 2, '.', '');
681
+ $new_fee = number_format($fee, 2, '.', '');
682
+ $fees_table[$index] = (((float) $new_max_value) == $max_value ? $new_max_value : $max_value) . $including_char . ':'
683
+ . (((float) $new_fee) == $fee ? $new_fee : $fee);
684
+ }
685
+ $input = str_replace($result_i[2], implode(', ', $fees_table), $input);
686
+ $input = str_replace($result_i[1], trim($result_i[1]), $input);
687
+ }
688
+ }
689
+ if (preg_match_all("#{foreach ([^}]*)}(.*){/foreach}#iU", $input, $result, PREG_SET_ORDER)) {
690
+ foreach ($result as $result_i) {
691
+ $input = str_replace($result_i[1], trim($result_i[1]), $input);
692
+ $input = str_replace($result_i[2], trim($result_i[2]), $input);
693
+ }
694
+ }
695
+ return str_replace(
696
+ self::$COMPRESSED_STRINGS, self::$UNCOMPRESSED_STRINGS, $input
697
+ );
698
+ }
699
+
700
+ public function parseProperty($input) {
701
+ $value = $input === 'false' || $input === 'true' ? $input == 'true' : str_replace('\"', '"', preg_replace('/^(?:"|\')(.*)(?:"|\')$/s', '$1', $input));
702
+ return $value === '' ? null : $value;
703
+ }
704
+
705
+ public function cleanProperty(&$row, $key) {
706
+ $input = $row[$key]['value'];
707
+ if (is_string($input)) {
708
+ $input = str_replace(array("\n"), array(''), $input);
709
+ while (preg_match('/({TABLE |{SUM |{COUNT | DISTINCT | IN )/', $input, $resi)) {
710
+ $input = str_replace($resi[0], strtolower($resi[0]), $input);
711
+ }
712
+
713
+ while (preg_match('/{{customVar code=([a-zA-Z0-9_-]+)}}/', $input, $resi)) {
714
+ $input = str_replace($resi[0], '{customvar.' . $resi[1] . '}', $input);
715
+ }
716
+
717
+ $regex = "{(weight|products_quantity|price_including_tax|price_excluding_tax|country)}";
718
+ if (preg_match('/' . $regex . '/', $input, $resi)) {
719
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
720
+ while (preg_match('/' . $regex . '/', $input, $resi)) {
721
+ switch ($resi[1]) {
722
+ case 'price_including_tax':
723
+ case 'price_excluding_tax':
724
+ case 'weight':
725
+ $input = str_replace($resi[0], "{cart." . $resi[1] . "}", $input);
726
+ break;
727
+ case 'products_quantity': $input = str_replace($resi[0], "{cart.quantity}", $input);
728
+ break;
729
+ case 'country': $input = str_replace($resi[0], "{destination.country.name}", $input);
730
+ break;
731
+ }
732
+ }
733
+ }
734
+
735
+ $regex1 = "{copy '([a-zA-Z0-9_]+)'\.'([a-zA-Z0-9_]+)'}";
736
+ if (preg_match('/' . $regex1 . '/', $input, $resi)) {
737
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
738
+ while (preg_match('/' . $regex1 . '/', $input, $resi))
739
+ $input = str_replace($resi[0], '{' . $resi[1] . '.' . $resi[2] . '}', $input);
740
+ }
741
+
742
+ $regex1 = "{(count|all|any) (attribute|option) '([^'\)]+)' ?((?:==|<=|>=|<|>|!=) ?(?:" . self::$FLOAT_REGEX . "|true|false|'[^'\)]*'))}";
743
+ $regex2 = "{(sum) (attribute|option) '([^'\)]+)'}";
744
+ if (preg_match('/' . $regex1 . '/', $input, $resi) || preg_match('/' . $regex2 . '/', $input, $resi)) {
745
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
746
+ while (preg_match('/' . $regex1 . '/', $input, $resi) || preg_match('/' . $regex2 . '/', $input, $resi)) {
747
+ switch ($resi[1]) {
748
+ case 'count': $input = str_replace($resi[0], "{count products where product." . $resi[2] . "s." . $resi[3] . $resi[4] . "}", $input);
749
+ break;
750
+ case 'all': $input = str_replace($resi[0], "{count products where product." . $resi[2] . "s." . $resi[3] . $resi[4] . "}=={products_quantity}", $input);
751
+ break;
752
+ case 'any': $input = str_replace($resi[0], "{count products where product." . $resi[2] . "s." . $resi[3] . $resi[4] . "}>0", $input);
753
+ break;
754
+ case 'sum': $input = str_replace($resi[0], "{sum product." . $resi[2] . "." . $resi[3] . "}", $input);
755
+ break;
756
+ }
757
+ }
758
+ }
759
+
760
+ $regex = "((?:{| )product.(?:attribute|option))s.";
761
+ if (preg_match('/' . $regex . '/', $input, $resi)) {
762
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
763
+ while (preg_match('/' . $regex . '/', $input, $resi)) {
764
+ $input = str_replace($resi[0], $resi[1] . '.', $input);
765
+ }
766
+ }
767
+
768
+ $regex = "{table '([^']+)' (" . self::$COUPLE_REGEX . "(?:, *" . self::$COUPLE_REGEX . ")*)}";
769
+ if (preg_match('/' . $regex . '/', $input, $resi)) {
770
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
771
+ while (preg_match('/' . $regex . '/', $input, $resi)) {
772
+ switch ($resi[1]) {
773
+ case 'products_quantity':
774
+ $input = str_replace($resi[0], "{table {cart.weight} in " . $resi[2] . "}*{cart.quantity}", $input);
775
+ break;
776
+ default:
777
+ $input = str_replace($resi[0], "{table {cart." . $resi[1] . "} in " . $resi[2] . "}", $input);
778
+ break;
779
+ }
780
+ }
781
+ }
782
+ }
783
+ $row[$key]['value'] = $input;
784
+ }
785
+
786
+ protected function _parseInput() {
787
+ $config_string = str_replace(
788
+ array('&gt;', '&lt;', '“', '”', utf8_encode(chr(147)), utf8_encode(chr(148)), '&laquo;', '&raquo;', "\r\n", "\t"), array('>', '<', '"', '"', '"', '"', '"', '"', "\n", ' '), $this->_input
789
+ );
790
+
791
+ if (substr($config_string, 0, 2) == '$$')
792
+ $config_string = $this->uncompress(substr($config_string, 2, strlen($config_string)));
793
+
794
+ //echo ini_get('pcre.backtrack_limit');
795
+ //exit;
796
+
797
+ $row_regex = ' *([a-z0-9_]+)\\s*:\\s*("(?:(?:[^"]|\\\\")*[^\\\\])?"|' . self::$FLOAT_REGEX . '|false|true)\\s*(,)? *(?:\\n)?';
798
+ if (!preg_match_all('/((?:#+[^{\\n]*\\s+)*)\\s*(#)?{\\s*(' . $row_regex . ')+\\s*}/i', $config_string, $result, PREG_SET_ORDER)) {
799
+ $errors = array(
800
+ PREG_NO_ERROR => 'PREG_NO_ERROR',
801
+ PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR',
802
+ PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR',
803
+ PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR',
804
+ PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR',
805
+ PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR',
806
+ );
807
+ $error = preg_last_error();
808
+ if (isset($errors[$error]))
809
+ $error = $errors[$error];
810
+ self::debug(' preg_match_all error (' . $error . ')', 10);
811
+ }
812
+
813
+ $this->_config = array();
814
+ $available_keys = array(
815
+ 'code', 'label', 'enabled', 'description', 'fees', 'conditions', 'destination', 'origin', 'customer_groups', 'tracking_url',
816
+ 'fees_table', 'fees_formula', 'fixed_fees', 'reference_value',
817
+ 'prices_range', 'weights_range', 'product_properties',
818
+ 'free_shipping__fees_table', 'free_shipping__fees_formula', 'free_shipping__fixed_fees', 'free_shipping__label',
819
+ );
820
+
821
+ foreach ($result as $block) {
822
+ $deprecated_properties = array();
823
+ $unknown_properties = array();
824
+ $missing_semicolon = array();
825
+ $obsolete_disabling_method = array();
826
+
827
+ //$before = strstr($config_string,$block[0],true); // Seulement compatible avec PHP 5.3.0
828
+ list($before) = explode($block[0], $config_string, 2);
829
+ if ($before !== false && trim($before) != '') {
830
+ $config_string = substr($config_string, strlen($before));
831
+ $this->_addIgnoredLines(trim($before));
832
+ $this->addMessage('info', $row = null, null, 'Ignored lines %s', '<div class="code">' . trim($before) . '</div>');
833
+ }
834
+
835
+ $config_string = str_replace($block[0], '', $config_string);
836
+ preg_match_all('/' . $row_regex . '/i', $block[0], $result2, PREG_SET_ORDER);
837
+ $block_string = $block[0];
838
+
839
+ $row = array();
840
+ $i = 1;
841
+ foreach ($result2 as $data) {
842
+ $key = $data[1];
843
+ if (in_array($key, $available_keys) || substr($key, 0, 1) == '_') {
844
+ $property = $this->parseProperty($data[2]);
845
+ if (isset($property)) {
846
+ $row[$key] = array('value' => $property, 'original_value' => $property);
847
+ $this->cleanProperty($row, $key);
848
+ }
849
+ if ($i > 2) {
850
+ $block_string = str_replace($data[0], $i == 3 ? "...\n" : '', $block_string);
851
+ }
852
+ if ($i != count($result2) && !isset($data[3]) || isset($data[3]) && $data[3] != ',') {
853
+ if (preg_match('/^("|\')(.{40})(.*)("|\')$/s', $data[2], $resultx))
854
+ $missing_semicolon[] = trim(str_replace($data[2], $resultx[1] . $resultx[2] . ' ...' . $resultx[4], $data[0]));
855
+ else
856
+ $missing_semicolon[] = trim($data[0]);
857
+ }
858
+ } else {
859
+ if (!in_array($key, $unknown_properties))
860
+ $unknown_properties[] = $key;
861
+ }
862
+ $i++;
863
+ }
864
+ if ($block[1] != '')
865
+ $row['*comment']['value'] = $block[1];
866
+ if ($block[2] == '#' && !isset($row['enabled'])) {
867
+ $row['enabled'] = array('value' => false);
868
+ $obsolete_disabling_method[] = $block_string;
869
+ }
870
+
871
+ $formula_fields_to_check = array();
872
+ if (isset($row['conditions']))
873
+ $formula_fields_to_check[] = 'conditions';
874
+ if (isset($row['fees']))
875
+ $formula_fields_to_check[] = 'fees';
876
+
877
+ if (count($formula_fields_to_check) > 0) {
878
+ foreach ($formula_fields_to_check as $property) {
879
+ $property_value = $row[$property]['value'];
880
+ if (preg_match('/{ +/', $property_value)) {
881
+ $this->addMessage('warning', $row, $property, 'There are unwanted spaces after char `%s`', '{');
882
+ $property_value = preg_replace('/{ +/', '{', $property_value);
883
+ }
884
+ if (preg_match('/ +}/', $property_value)) {
885
+ $this->addMessage('warning', $row, $property, 'There are unwanted spaces before char `%s`', '}');
886
+ $property_value = preg_replace('/ +}/', '}', $property_value);
887
+ }
888
+ if (preg_match('/ +/', $property_value)) {
889
+ $this->addMessage('warning', $row, $property, 'There are unwanted multiples spaces `%s`', preg_replace('/( +)/', '<span class="osh-formula">*$1*</span>', $property_value));
890
+ $property_value = preg_replace('/ +/', ' ', $property_value);
891
+ }
892
+ $row[$property]['value'] = trim($property_value);
893
+ }
894
+ }
895
+
896
+ $float_value_regex = '\\s*(' . self::$POSITIVE_FLOAT_REGEX . '|\*)\\s*';
897
+ $conditions = array();
898
+ if (isset($row['prices_range'])) {
899
+ if (!in_array('prices_range', $deprecated_properties))
900
+ $deprecated_properties[] = 'prices_range';
901
+
902
+ $result = $this->_getOptionsAndData($row['prices_range']['value']);
903
+ $options = $result['options'];
904
+ $prices_range = $result['data'];
905
+
906
+ if (($options == '' || in_array($options, array('incl.tax', 'ttc'))) && preg_match('/^\\s*(\[|\])?' . $float_value_regex . '=>' . $float_value_regex . '(\[|\])?\\s*$/', $prices_range, $result)) {
907
+ $min_price_included = $result[1] == '[';
908
+ $min_price = $result[2] == '*' ? -1 : (float) $result[2];
909
+ $max_price = $result[3] == '*' ? -1 : (float) $result[3];
910
+ $max_price_included = !isset($result[4]) || $result[4] == ']' || $result[4] == '';
911
+
912
+ $tax_included = $options != '' && in_array($options, array('incl.tax', 'ttc')) || isset($row['reference_value']) && $row['reference_value']['value'] == 'price_including_tax';
913
+ $price = $tax_included ? '{cart.price_including_tax}' : '{cart.price_excluding_tax}';
914
+
915
+ if ($min_price != -1)
916
+ $conditions[] = $price . '>' . ($min_price_included ? '=' : '') . $min_price;
917
+ if ($max_price != -1)
918
+ $conditions[] = $price . '<' . ($max_price_included ? '=' : '') . $max_price;
919
+ }
920
+ else
921
+ $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">prices_range</span>', '<span class="osh-formula">' . $row['prices_range']['value'] . '</span>');
922
+ unset($row['prices_range']);
923
+ }
924
+ if (isset($row['weights_range'])) {
925
+ if (!in_array('weights_range', $deprecated_properties))
926
+ $deprecated_properties[] = 'weights_range';
927
+ if (preg_match('/^\\s*(\[|\])?' . $float_value_regex . '=>' . $float_value_regex . '(\[|\])?\\s*$/', $row['weights_range']['value'], $result)) {
928
+ $min_weight_included = $result[1] == '[';
929
+ $min_weight = $result[2] == '*' ? -1 : (float) $result[2];
930
+ $max_weight = $result[3] == '*' ? -1 : (float) $result[3];
931
+ $max_weight_included = !isset($result[4]) || $result[4] == ']' || $result[4] == '';
932
+
933
+ if ($min_weight != -1)
934
+ $conditions[] = '{cart.weight}>' . ($min_weight_included ? '=' : '') . $min_weight;
935
+ if ($max_weight != -1)
936
+ $conditions[] = '{cart.weight}<' . ($max_weight_included ? '=' : '') . $max_weight;
937
+ }
938
+ else
939
+ $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">weights_range</span>', '<span class="osh-formula">' . $row['weights_range']['value'] . '</span>');
940
+ unset($row['weights_range']);
941
+ }
942
+ if (isset($row['product_properties'])) {
943
+ if (!in_array('product_properties', $deprecated_properties))
944
+ $deprecated_properties[] = 'product_properties';
945
+ $product_property_regex = "\\s*(and|or)? *\((?:(all|any|sum) )?(attribute|option) '([^'\)]+)' ?(==|=|<=|>=|<|>|!=) ?(" . self::$FLOAT_REGEX . "|true|false|'[^'\)]*')\)\\s*";
946
+ if (preg_match('/^(' . $product_property_regex . ')+$/', $row['product_properties']['value'], $result)) {
947
+ preg_match_all('/' . $product_property_regex . '/', $row['product_properties']['value'], $results, PREG_SET_ORDER);
948
+ $product_properties_condition = '';
949
+ foreach ($results as $result) {
950
+ $and_or = $result[1];
951
+ if ($and_or == '')
952
+ $and_or = 'and';
953
+ $any_all_sum = $result[2];
954
+ if ($any_all_sum == '')
955
+ $any_all_sum = 'any';
956
+ $property_type = $result[3];
957
+ $property_name = $result[4];
958
+ $cmp_symbol = $result[5];
959
+ if ($cmp_symbol == '=')
960
+ $cmp_symbol = '==';
961
+ $cmp_value = $result[6];
962
+
963
+ $product_properties_condition .= $product_properties_condition == '' ? '' : ' ' . $and_or . ' ';
964
+ switch ($any_all_sum) {
965
+ case 'sum':
966
+ $product_properties_condition .= "{sum product." . $property_type . "." . $property_name . "}" . $cmp_symbol . $cmp_value;
967
+ break;
968
+ case 'all':
969
+ $product_properties_condition .= "{count products where product." . $property_type . "." . $property_name . $cmp_symbol . $cmp_value . "}=={products_quantity}";
970
+ break;
971
+ case 'any':
972
+ $product_properties_condition .= "{count products where product." . $property_type . "." . $property_name . $cmp_symbol . $cmp_value . "}>0";
973
+ break;
974
+ }
975
+ }
976
+ if ($product_properties_condition != '')
977
+ $conditions[] = $product_properties_condition;
978
+ }
979
+ else
980
+ $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">product_properties</span>', '<span class="osh-formula">' . $row['product_properties']['value'] . '</span>');
981
+ unset($row['product_properties']);
982
+ }
983
+ if (count($conditions) > 0)
984
+ $row['conditions'] = array('value' => count($conditions) == 1 ? $conditions[0] : '(' . implode(') && (', $conditions) . ')');
985
+
986
+ $fees = array();
987
+ if (isset($row['fees_table'])) {
988
+ if (!in_array('fees_table', $deprecated_properties))
989
+ $deprecated_properties[] = 'fees_table';
990
+ $options_and_data = $this->_getOptionsAndData($row['fees_table']['value']);
991
+ $options = $options_and_data['options'];
992
+ $fees_table_string = $options_and_data['data'];
993
+
994
+ $var = null;
995
+ if ($options == '')
996
+ $var = (isset($row['reference_value']) ? $row['reference_value']['value'] : 'weight');
997
+ else if (in_array($options, array('incl.tax', 'ttc')))
998
+ $var = 'price_including_tax';
999
+ else if (in_array($options, array('excl.tax', 'ht')))
1000
+ $var = 'price_excluding_tax';
1001
+
1002
+ if (isset($var)) {
1003
+ if ($var == 'price')
1004
+ $var = 'price_excluding_tax';
1005
+ if ($var == 'products_quantity')
1006
+ $var = 'quantity';
1007
+ if (preg_match('/^[[:space:]]*\*[[:space:]]*:[[:space:]]*(' . $float_value_regex . ')[[:space:]]*$/s', $fees_table_string, $result))
1008
+ $fees[] = $result[1];
1009
+ else
1010
+ $fees[] = "{table {cart." . $var . "} in " . str_replace(' ', '', $fees_table_string) . "}" . ($var == 'quantity' ? '*{cart.quantity}' : '');
1011
+ }
1012
+ else
1013
+ $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">fees_table</span>', '<span class="osh-formula">' . $row['fees_table']['value'] . '</span>');
1014
+ unset($row['fees_table']);
1015
+ }
1016
+ if (isset($row['fees_formula'])) {
1017
+ if (!in_array('fees_formula', $deprecated_properties))
1018
+ $deprecated_properties[] = 'fees_formula';
1019
+ $fees[] = str_replace(' ', '', $row['fees_formula']['value']);
1020
+ unset($row['fees_formula']);
1021
+ }
1022
+ if (isset($row['fixed_fees'])) {
1023
+ if (!in_array('fixed_fees', $deprecated_properties))
1024
+ $deprecated_properties[] = 'fixed_fees';
1025
+ if ($row['fixed_fees']['value'] != 0 || count($fees) == 0)
1026
+ $fees[] = str_replace(' ', '', $row['fixed_fees']['value']);
1027
+ unset($row['fixed_fees']);
1028
+ }
1029
+ if (!isset($row['fees']) && count($fees) > 0)
1030
+ $row['fees'] = array('value' => implode('+', $fees));
1031
+
1032
+ $fs_fees = array();
1033
+ if (isset($row['free_shipping__fees_table'])) {
1034
+ if (!in_array('free_shipping__fees_table', $deprecated_properties))
1035
+ $deprecated_properties[] = 'free_shipping__fees_table';
1036
+ $options_and_data = $this->_getOptionsAndData($row['free_shipping__fees_table']['value']);
1037
+ $options = $options_and_data['options'];
1038
+ $fees_table_string = $options_and_data['data'];
1039
+
1040
+ $var = null;
1041
+ if ($options == '')
1042
+ $var = isset($row['reference_value']) ? $row['reference_value']['value'] : 'weight';
1043
+ else if (in_array($options, array('incl.tax', 'ttc')))
1044
+ $var = 'price_including_tax';
1045
+ else if (in_array($options, array('excl.tax', 'ht')))
1046
+ $var = 'price_excluding_tax';
1047
+ if ($var == 'price')
1048
+ $var = 'price_excluding_tax';
1049
+
1050
+ if (isset($var)) {
1051
+ if ($var == 'price')
1052
+ $var = 'price_excluding_tax';
1053
+ if ($var == 'products_quantity')
1054
+ $var = 'quantity';
1055
+ if (preg_match('/^[[:space:]]*\*[[:space:]]*:[[:space:]]*(' . $float_value_regex . ')[[:space:]]*$/s', $fees_table_string, $result))
1056
+ $fs_fees[] = $result[1];
1057
+ else
1058
+ $fs_fees[] = "{table {cart." . $var . "} in " . str_replace(' ', '', $fees_table_string) . "}" . ($var == 'quantity' ? '*{cart.quantity}' : '');
1059
+ }
1060
+ else
1061
+ $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">free_shipping__fees_table</span>', '<span class="osh-formula">' . $row['free_shipping__fees_table']['value'] . '</span>');
1062
+ unset($row['free_shipping__fees_table']);
1063
+ }
1064
+ if (isset($row['free_shipping__fees_formula'])) {
1065
+ if (!in_array('free_shipping__fees_formula', $deprecated_properties))
1066
+ $deprecated_properties[] = 'free_shipping__fees_formula';
1067
+ $fs_fees[] = str_replace(' ', '', $row['free_shipping__fees_formula']['value']);
1068
+ unset($row['free_shipping__fees_formula']);
1069
+ }
1070
+ if (isset($row['free_shipping__fixed_fees'])) {
1071
+ if (!in_array('free_shipping__fixed_fees', $deprecated_properties))
1072
+ $deprecated_properties[] = 'free_shipping__fixed_fees';
1073
+ if ($row['free_shipping__fixed_fees']['value'] != 0 || count($fees) == 0)
1074
+ $fs_fees[] = str_replace(' ', '', $row['free_shipping__fixed_fees']['value']);
1075
+ unset($row['free_shipping__fixed_fees']);
1076
+ }
1077
+
1078
+ if (isset($row['reference_value'])) {
1079
+ if (!in_array('reference_value', $deprecated_properties))
1080
+ $deprecated_properties[] = 'reference_value';
1081
+ unset($row['reference_value']);
1082
+ }
1083
+
1084
+ if (count($fs_fees) > 0) {
1085
+ $row2 = $row;
1086
+ if (isset($row['code']))
1087
+ $row2['code']['value'] = $row['code']['value'] . '__free_shipping';
1088
+ $row2['fees']['value'] = implode('+', $fs_fees);
1089
+ $row2['conditions']['value'] = isset($row2['conditions']) ? '(' . $row2['conditions'] + ') and {free_shipping}' : '{free_shipping}';
1090
+ $row['conditions']['value'] = isset($row['conditions']) ? '(' . $row['conditions'] + ') and !{free_shipping}' : '!{free_shipping}';
1091
+ if (isset($row['free_shipping__label'])) {
1092
+ if (!in_array('free_shipping__label', $deprecated_properties))
1093
+ $deprecated_properties[] = 'free_shipping__label';
1094
+ $row2['label']['value'] = $row['free_shipping__label']['value'];
1095
+ unset($row['free_shipping__label']);
1096
+ unset($row2['free_shipping__label']);
1097
+ }
1098
+ $this->_addRow($row2);
1099
+ }
1100
+ if (count($unknown_properties) > 0)
1101
+ $this->addMessage('error', $row, null, 'Usage of unknown properties %s', ': <span class="osh-key">' . implode('</span>, <span class="osh-key">', $unknown_properties) . '</span>');
1102
+ if (count($deprecated_properties) > 0)
1103
+ $this->addMessage('warning', $row, null, 'Usage of deprecated properties %s', ': <span class="osh-key">' . implode('</span>, <span class="osh-key">', $deprecated_properties) . '</span>');
1104
+ if (count($obsolete_disabling_method) > 0)
1105
+ $this->addMessage('warning', $row, null, 'Usage of obsolete method to disabling a shipping method (`#` before `{`)%s', '<div class="code">' . implode('<br />', $obsolete_disabling_method) . '</div>');
1106
+ if (count($missing_semicolon) > 0)
1107
+ $this->addMessage('warning', $row, null, 'A semicolon is missing at the end of following lines %s', '<div class="code">' . implode('<br />', $missing_semicolon) . '</div>');
1108
+ $this->_addRow($row);
1109
+ }
1110
+ if (trim($config_string) != '') {
1111
+ $this->_addIgnoredLines(trim($config_string));
1112
+ $row = null;
1113
+ $this->addMessage('info', $row, null, 'Ignored lines %s', '<div class="code">' . trim($config_string) . '</div>');
1114
+ }
1115
+ }
1116
+
1117
+ public function addMessage($type, &$row, $property) {
1118
+ $args = func_get_args();
1119
+ array_shift($args);
1120
+ array_shift($args);
1121
+ array_shift($args);
1122
+ $message = new OCS_Message($type, $args);
1123
+ if (isset($row)) {
1124
+ if (isset($property)) {
1125
+ $row[$property]['messages'][] = $message;
1126
+ } else {
1127
+ $row['*messages'][] = $message;
1128
+ }
1129
+ }
1130
+ $this->_messages[] = $message;
1131
+ self::debug(' => <span class="osh-' . $message->type . '">' . $message->toString() . '</span>', 1);
1132
+ }
1133
+
1134
+ protected function _addRow(&$row) {
1135
+ if (isset($row['code'])) {
1136
+ $key = $row['code']['value'];
1137
+ if (isset($this->_config[$key]))
1138
+ $this->addMessage('error', $row, 'code', 'The property `code` must be unique, `%s` has been found twice', $key);
1139
+ while (isset($this->_config[$key]))
1140
+ $key .= rand(0, 9);
1141
+ //$row['code'] = $key;
1142
+ } else {
1143
+ $i = 1;
1144
+ do {
1145
+ $key = 'code_auto' . sprintf('%03d', $i);
1146
+ $i++;
1147
+ } while (isset($this->_config[$key]));
1148
+ }
1149
+ $row['*code'] = $key;
1150
+ $this->_config[$key] = $row;
1151
+ }
1152
+
1153
+ protected function _addIgnoredLines($lines) {
1154
+ $this->_config[] = array('lines' => $lines);
1155
+ }
1156
+
1157
+ protected function _addressMatch($address_filter, $address) {
1158
+ $excluding = false;
1159
+ if (preg_match('# *\* *- *\((.*)\) *#s', $address_filter, $result)) {
1160
+ $address_filter = $result[1];
1161
+ $excluding = true;
1162
+ }
1163
+
1164
+ $tmp_address_filter_array = explode(',', trim($address_filter));
1165
+
1166
+ $concat = false;
1167
+ $concatened = '';
1168
+ $address_filter_array = array();
1169
+ $i = 0;
1170
+
1171
+ foreach ($tmp_address_filter_array as $address_filter) {
1172
+ if ($concat)
1173
+ $concatened .= ',' . $address_filter;
1174
+ else {
1175
+ if ($i < count($tmp_address_filter_array) - 1 && preg_match('#\(#', $address_filter)) {
1176
+ $concat = true;
1177
+ $concatened .= $address_filter;
1178
+ }
1179
+ else
1180
+ $address_filter_array[] = $address_filter;
1181
+ }
1182
+ if (preg_match('#\)#', $address_filter)) {
1183
+ $address_filter_array[] = $concatened;
1184
+ $concatened = '';
1185
+ $concat = false;
1186
+ }
1187
+ $i++;
1188
+ }
1189
+
1190
+ foreach ($address_filter_array as $address_filter) {
1191
+ if (preg_match('# *([A-Z]{2}) *(-)? *(?:\( *(-)? *(.*)\))? *#s', $address_filter, $result)) {
1192
+ $country_code = $result[1];
1193
+ if ($address['country_code'] == $country_code) {
1194
+ self::debug(' country code <span class="osh-replacement">' . $address['country_code'] . '</span> matches', 5);
1195
+ if (!isset($result[4]) || $result[4] == '')
1196
+ return !$excluding;
1197
+ else {
1198
+ $region_codes = explode(',', $result[4]);
1199
+ $in_array = false;
1200
+ for ($i = count($region_codes); --$i >= 0;) {
1201
+ $code = trim($region_codes[$i]);
1202
+ $region_codes[$i] = $code;
1203
+ if ($address['region_code'] === $code) {
1204
+ self::debug(' region code <span class="osh-replacement">' . $address['region_code'] . '</span> matches', 5);
1205
+ $in_array = true;
1206
+ } else if ($address['postcode'] === $code) {
1207
+ self::debug(' postcode <span class="osh-replacement">' . $address['postcode'] . '</span> matches', 5);
1208
+ $in_array = true;
1209
+ } else if (strpos($code, '*') !== false && preg_match('/^' . str_replace('*', '(?:.*)', $code) . '$/', $address['postcode'])) {
1210
+ self::debug(' postcode <span class="osh-replacement">' . $address['postcode'] . '</span> matches <span class="osh-formula">' . $code . '</span>', 5);
1211
+ $in_array = true;
1212
+ }
1213
+ if ($in_array)
1214
+ break;
1215
+ }
1216
+ if (!$in_array) {
1217
+ self::debug(' region code <span class="osh-replacement">' . $address['region_code'] . '</span> and postcode <span class="osh-replacement">' . $address['postcode'] . '</span> don\'t match', 5);
1218
+ }
1219
+ // Vérification stricte
1220
+ /* $in_array = in_array($address['region_code'],$region_codes,true) || in_array($address['postcode'],$region_codes,true); */
1221
+ $excluding_region = $result[2] == '-' || $result[3] == '-';
1222
+ if ($excluding_region && !$in_array || !$excluding_region && $in_array)
1223
+ return !$excluding;
1224
+ }
1225
+ }
1226
+ }
1227
+ }
1228
+ return $excluding;
1229
+ }
1230
+
1231
+ protected function _getProductProperty($product, $property_type, $property_name, $get_by_id = false) {
1232
+ switch ($property_type) {
1233
+ case 'attribute':
1234
+ case 'attributes': return $product->getAttribute($property_name, $get_by_id);
1235
+ case 'option':
1236
+ case 'options': return $product->getOption($property_name, $get_by_id);
1237
+ case 'stock': return $product->getStockData($property_name);
1238
+ }
1239
+ return null;
1240
+ }
1241
+
1242
+ protected function _processProductProperty($products, $regex_result) {
1243
+ // COUNT, SUM or COUNT DISTINCT
1244
+ $operation = strtolower($regex_result[1]);
1245
+ switch ($operation) {
1246
+ case 'sum':
1247
+ case 'count distinct':
1248
+ $property_type = $regex_result[2];
1249
+ $property_name = $regex_result[3];
1250
+ $conditions = isset($regex_result[4]) ? $regex_result[4] : null;
1251
+ break;
1252
+ case 'count':
1253
+ $conditions = isset($regex_result[2]) ? $regex_result[2] : null;
1254
+ break;
1255
+ }
1256
+
1257
+ self::debug(' :: start <span class="osh-replacement">' . $regex_result[0] . '</span>', 10);
1258
+
1259
+ $return_value = 0;
1260
+
1261
+ preg_match_all('/product\.(attribute(?:s)?|option(?:s)?|stock)\.([a-z0-9_]+)(?:\.(id))?/i', $conditions, $properties_regex_result, PREG_SET_ORDER);
1262
+ $properties = array();
1263
+ foreach ($properties_regex_result as $property_regex_result) {
1264
+ $key = $property_regex_result[0];
1265
+ if (!isset($properties[$key]))
1266
+ $properties[$key] = $property_regex_result;
1267
+ }
1268
+
1269
+ foreach ($products as $product) {
1270
+ if (isset($conditions) && $conditions != '') {
1271
+ $formula = $conditions;
1272
+ foreach ($properties as $property) {
1273
+ $value = $this->_getProductProperty(
1274
+ $product, $tmp_property_type = $property[1], $tmp_property_name = $property[2], $get_by_id = isset($property[3]) && $property[3] == 'id'
1275
+ );
1276
+ //$formula = $this->replace($property[0],$value,$formula);
1277
+ $from = $property[0];
1278
+ $to = is_string($value) || empty($value) ? "'" . $value . "'" : $value;
1279
+ $formula = str_replace($from, $to, $formula);
1280
+ self::debug(' replace <span class="osh-replacement">' . $from . '</span> by <span class="osh-replacement">' . $to . '</span> =&gt; <span class="osh-formula">' . str_replace($from, '<span class="osh-replacement">' . $to . '</span>', $formula) . '</span>', 5);
1281
+ }
1282
+ $eval_result = $this->_evalFormula($formula);
1283
+ if (!isset($eval_result))
1284
+ return 'null';
1285
+ }
1286
+ else
1287
+ $eval_result = true;
1288
+
1289
+ if ($eval_result == true) {
1290
+ switch ($operation) {
1291
+ case 'sum':
1292
+ $value = $this->_getProductProperty($product, $property_type, $property_name);
1293
+ //self::debug($product->getSku().'.'.$property_type.'.'.$property_name.' = "'.$value.'" x '.$product->getQuantity(),10);
1294
+ $return_value += $value * $product->getQuantity();
1295
+ break;
1296
+ case 'count distinct':
1297
+ if (!isset($distinct_values))
1298
+ $distinct_values = array();
1299
+ $value = $this->_getProductProperty($product, $property_type, $property_name);
1300
+ if (!in_array($value, $distinct_values)) {
1301
+ $distinct_values[] = $value;
1302
+ $return_value++;
1303
+ }
1304
+ break;
1305
+ case 'count':
1306
+ $return_value += $product->getQuantity();
1307
+ break;
1308
+ }
1309
+ }
1310
+ }
1311
+
1312
+ self::debug(' :: end <span class="osh-replacement">' . $regex_result[0] . '</span>', 10);
1313
+
1314
+ return $return_value;
1315
+ }
1316
+
1317
+ }
1318
+
1319
+ interface OCS_Product {
1320
+
1321
+ public function getOption($option);
1322
+
1323
+ public function getAttribute($attribute);
1324
+
1325
+ public function getName();
1326
+
1327
+ public function getSku();
1328
+
1329
+ public function getQuantity();
1330
+
1331
+ public function getStockData($key);
1332
+ }
1333
+
1334
+ class OCS_Message {
1335
+
1336
+ public $type;
1337
+ public $message;
1338
+ public $args;
1339
+
1340
+ public function OCS_Message($type, $args) {
1341
+ $this->type = $type;
1342
+ $this->message = array_shift($args);
1343
+ $this->args = $args;
1344
+ }
1345
+
1346
+ public function toString() {
1347
+ return vsprintf($this->message, $this->args);
1348
+ }
1349
+
1350
+ }
1351
+
1352
+ class OCS_Result {
1353
+
1354
+ public $success;
1355
+ public $result;
1356
+
1357
+ public function OCS_Result($success, $result = null) {
1358
+ $this->success = $success;
1359
+ $this->result = $result;
1360
+ }
1361
+
1362
+ public function __toString() {
1363
+ return is_bool($this->result) ? ($this->result ? 'true' : 'false') : (string) $this->result;
1364
+ }
1365
+
1366
+ }
1367
+
1368
+ ?>
app/code/community/Chronopost/Chronorelais/includes/countries.inc.php CHANGED
@@ -1,525 +1,525 @@
1
- <?php
2
-
3
-
4
- class Country
5
- {
6
- private static $LOADED = false;
7
- private static $COUNTRIES = array(
8
- 'code2name' => array(
9
- 'AF' => 'Afghanistan',
10
- 'ZA' => 'Afrique du Sud',
11
- 'AX' => 'Åland',
12
- 'AL' => 'Albanie',
13
- 'DZ' => 'Algérie',
14
- 'DE' => 'Allemagne',
15
- 'AD' => 'Andorre',
16
- 'AO' => 'Angola',
17
- 'AI' => 'Anguilla',
18
- 'AQ' => 'Antarctique',
19
- 'AG' => 'Antigua-et-Barbuda',
20
- 'AN' => 'Antilles néerlandaises',
21
- 'SA' => 'Arabie saoudite',
22
- 'AR' => 'Argentine',
23
- 'AM' => 'Arménie',
24
- 'AW' => 'Aruba',
25
- 'AU' => 'Australie',
26
- 'AT' => 'Autriche',
27
- 'AZ' => 'Azerbaïdjan',
28
- 'BS' => 'Bahamas',
29
- 'BH' => 'Bahreïn',
30
- 'BD' => 'Bangladesh',
31
- 'BB' => 'Barbade',
32
- 'BY' => 'Biélorussie',
33
- 'BE' => 'Belgique',
34
- 'BZ' => 'Belize',
35
- 'BJ' => 'Bénin',
36
- 'BM' => 'Bermudes',
37
- 'BT' => 'Bhoutan',
38
- 'BO' => 'Bolivie',
39
- 'BA' => 'Bosnie-Herzégovine',
40
- 'BW' => 'Botswana',
41
- 'BV' => 'Île Bouvet',
42
- 'BR' => 'Brésil',
43
- 'BN' => 'Brunei',
44
- 'BG' => 'Bulgarie',
45
- 'BF' => 'Burkina Faso',
46
- 'BI' => 'Burundi',
47
- 'KY' => 'Îles Caïmans',
48
- 'KH' => 'Cambodge',
49
- 'CM' => 'Cameroun',
50
- 'CA' => 'Canada',
51
- 'CV' => 'Cap-Vert',
52
- 'CF' => 'République centrafricaine',
53
- 'CL' => 'Chili',
54
- 'CN' => 'Chine',
55
- 'CX' => 'Île Christmas',
56
- 'CY' => 'Chypre',
57
- 'CC' => 'Îles Cocos',
58
- 'CO' => 'Colombie',
59
- 'KM' => 'Comores',
60
- 'CG' => 'Congo',
61
- 'CD' => 'République démocratique du Congo',
62
- 'CK' => 'Îles Cook',
63
- 'KR' => 'Corée du Sud',
64
- 'KP' => 'Corée du Nord',
65
- 'CR' => 'Costa Rica',
66
- 'CI' => "Côte d'Ivoire",
67
- 'HR' => 'Croatie',
68
- 'CU' => 'Cuba',
69
- 'DK' => 'Danemark',
70
- 'DJ' => 'Djibouti',
71
- 'DO' => 'République dominicaine',
72
- 'DM' => 'Dominique',
73
- 'EG' => 'Égypte',
74
- 'SV' => 'Salvador',
75
- 'AE' => 'Émirats arabes unis',
76
- 'EC' => 'Équateur',
77
- 'ER' => 'Érythrée',
78
- 'ES' => 'Espagne',
79
- 'EE' => 'Estonie',
80
- 'US' => 'États-Unis',
81
- 'ET' => 'Éthiopie',
82
- 'FK' => 'Îles Malouines',
83
- 'FO' => 'Îles Féroé',
84
- 'FJ' => 'Fidji',
85
- 'FI' => 'Finlande',
86
- 'FR' => 'France',
87
- 'GA' => 'Gabon',
88
- 'GM' => 'Gambie',
89
- 'GE' => 'Géorgie',
90
- 'GS' => 'Géorgie du Sud-et-les Îles Sandwich du Sud',
91
- 'GH' => 'Ghana',
92
- 'GI' => 'Gibraltar',
93
- 'GR' => 'Grèce',
94
- 'GD' => 'Grenade',
95
- 'GL' => 'Groenland',
96
- 'GP' => 'Guadeloupe',
97
- 'GU' => 'Guam',
98
- 'GT' => 'Guatemala',
99
- 'GG' => 'Guernesey',
100
- 'GN' => 'Guinée',
101
- 'GW' => 'Guinée-Bissau',
102
- 'GQ' => 'Guinée équatoriale',
103
- 'GY' => 'Guyana',
104
- 'GF' => 'Guyane Française',
105
- 'HT' => 'Haïti',
106
- 'HM' => 'Îles Heard-et-MacDonald',
107
- 'HN' => 'Honduras',
108
- 'HK' => 'Hong Kong',
109
- 'HU' => 'Hongrie',
110
- 'IM' => 'Île de Man',
111
- 'UM' => 'Îles mineures éloignées des États-Unis',
112
- 'VG' => 'Îles Vierges britanniques',
113
- 'VI' => 'Îles Vierges américaines',
114
- 'IN' => 'Inde',
115
- 'ID' => 'Indonésie',
116
- 'IR' => 'Iran',
117
- 'IQ' => 'Irak',
118
- 'IE' => 'Irlande',
119
- 'IS' => 'Islande',
120
- 'IL' => 'Israël',
121
- 'IT' => 'Italie',
122
- 'JM' => 'Jamaïque',
123
- 'JP' => 'Japon',
124
- 'JE' => 'Jersey',
125
- 'JO' => 'Jordanie',
126
- 'KZ' => 'Kazakhstan',
127
- 'KE' => 'Kenya',
128
- 'KG' => 'Kirghizistan',
129
- 'KI' => 'Kiribati',
130
- 'KW' => 'Koweït',
131
- 'LA' => 'Laos',
132
- 'LS' => 'Lesotho',
133
- 'LV' => 'Lettonie',
134
- 'LB' => 'Liban',
135
- 'LR' => 'Libéria',
136
- 'LY' => 'Libye',
137
- 'LI' => 'Liechtenstein',
138
- 'LT' => 'Lituanie',
139
- 'LU' => 'Luxembourg',
140
- 'MO' => 'Macao',
141
- 'MK' => 'Macédoine',
142
- 'MG' => 'Madagascar',
143
- 'MY' => 'Malaisie',
144
- 'MW' => 'Malawi',
145
- 'MV' => 'Maldives',
146
- 'ML' => 'Mali',
147
- 'MT' => 'Malte',
148
- 'MP' => 'Îles Mariannes du Nord',
149
- 'MA' => 'Maroc',
150
- 'MH' => 'Îles Marshall',
151
- 'MQ' => 'Martinique',
152
- 'MU' => 'Île Maurice',
153
- 'MR' => 'Mauritanie',
154
- 'YT' => 'Mayotte',
155
- 'MX' => 'Mexique',
156
- 'FM' => 'Micronésie',
157
- 'MD' => 'Moldavie',
158
- 'MC' => 'Monaco',
159
- 'MN' => 'Mongolie',
160
- 'ME' => 'Monténégro',
161
- 'MS' => 'Montserrat',
162
- 'MZ' => 'Mozambique',
163
- 'MM' => 'Birmanie',
164
- 'NA' => 'Namibie',
165
- 'NR' => 'Nauru',
166
- 'NP' => 'Népal',
167
- 'NI' => 'Nicaragua',
168
- 'NE' => 'Niger',
169
- 'NG' => 'Nigéria',
170
- 'NU' => 'Niué',
171
- 'NF' => 'Île Norfolk',
172
- 'NO' => 'Norvège',
173
- 'NC' => 'Nouvelle-Calédonie',
174
- 'NZ' => 'Nouvelle-Zélande',
175
- 'IO' => "Territoire britannique de l'océan Indien",
176
- 'OM' => 'Oman',
177
- 'UG' => 'Ouganda',
178
- 'UZ' => 'Ouzbékistan',
179
- 'PK' => 'Pakistan',
180
- 'PW' => 'Palaos',
181
- 'PS' => 'Palestine',
182
- 'PA' => 'Panamá',
183
- 'PG' => 'Papouasie-Nouvelle-Guinée',
184
- 'PY' => 'Paraguay',
185
- 'NL' => 'Pays-Bas',
186
- 'PE' => 'Pérou',
187
- 'PH' => 'Philippines',
188
- 'PN' => 'Îles Pitcairn',
189
- 'PL' => 'Pologne',
190
- 'PF' => 'Polynésie Française',
191
- 'PR' => 'Porto Rico',
192
- 'PT' => 'Portugal',
193
- 'QA' => 'Qatar',
194
- 'RE' => 'La Réunion',
195
- 'RO' => 'Roumanie',
196
- 'GB' => 'Royaume-Uni',
197
- 'RU' => 'Russie',
198
- 'RW' => 'Rwanda',
199
- 'EH' => 'Sahara occidental',
200
- 'BL' => 'Saint-Barthélemy',
201
- 'KN' => 'Saint-Christophe-et-Niévès',
202
- 'SM' => 'Saint-Marin',
203
- 'MF' => 'Saint-Martin',
204
- 'PM' => 'Saint-Pierre-et-Miquelon',
205
- 'VA' => 'Vatican',
206
- 'VC' => 'Saint-Vincent-et-les Grenadines',
207
- 'SH' => 'Sainte-Hélène',
208
- 'LC' => 'Sainte-Lucie',
209
- 'SB' => 'Îles Salomon',
210
- 'WS' => 'Samoa',
211
- 'AS' => 'Samoa américaines',
212
- 'ST' => 'São Tomé-et-Principe',
213
- 'SN' => 'Sénégal',
214
- 'RS' => 'Serbie',
215
- 'SC' => 'Seychelles',
216
- 'SL' => 'Sierra Leone',
217
- 'SG' => 'Singapour',
218
- 'SK' => 'Slovaquie',
219
- 'SI' => 'Slovénie',
220
- 'SO' => 'Somalie',
221
- 'SD' => 'Soudan',
222
- 'LK' => 'Sri Lanka',
223
- 'SE' => 'Suède',
224
- 'CH' => 'Suisse',
225
- 'SR' => 'Suriname',
226
- 'SJ' => 'Svalbard et île Jan Mayen',
227
- 'SZ' => 'Swaziland',
228
- 'SY' => 'Syrie',
229
- 'TJ' => 'Tadjikistan',
230
- 'TW' => 'Taïwan',
231
- 'TZ' => 'Tanzanie',
232
- 'TD' => 'Tchad',
233
- 'CZ' => 'République tchèque',
234
- 'TF' => 'Terres Australes et Antarctiques Françaises',
235
- 'TH' => 'Thaïlande',
236
- 'TL' => 'Timor oriental',
237
- 'TG' => 'Togo',
238
- 'TK' => 'Tokelau',
239
- 'TO' => 'Tonga',
240
- 'TT' => 'Trinité-et-Tobago',
241
- 'TN' => 'Tunisie',
242
- 'TM' => 'Turkménistan',
243
- 'TC' => 'Îles Turques-et-Caïques',
244
- 'TR' => 'Turquie',
245
- 'TV' => 'Tuvalu',
246
- 'UA' => 'Ukraine',
247
- 'UY' => 'Uruguay',
248
- 'VU' => 'Vanuatu',
249
- 'VE' => 'Venezuela',
250
- 'VN' => 'Viêt Nam',
251
- 'WF' => 'Wallis-et-Futuna',
252
- 'YE' => 'Yémen',
253
- 'ZM' => 'Zambie',
254
- 'ZW' => 'Zimbabwe',
255
- ),
256
- 'code2soft-cleaned-name' => null,
257
- 'code2hard-cleaned-name' => null,
258
- 'replacement' => array(
259
- 'reunion' => 'RE',
260
- 'france-metropolitaine' => 'FR',
261
- 'guyane' => 'GF',
262
- 'taaf' => 'TF',
263
- 'terres-australes-francaises' => 'TF',
264
- 'usa' => 'US',
265
- 'hollande' => 'NL',
266
- 'grande-bretagne' => 'GB',
267
- 'vietnam' => 'VN',
268
- 'belarus' => 'BY',
269
- 'brunei-darussalam' => 'BN',
270
- 'cayman' => 'KY',
271
- 'caiman' => 'KY',
272
- 'caimanes' => 'KY',
273
- 'cocos-keeling' => 'CC',
274
- 'keeling' => 'CC',
275
- 'centrafrique' => 'CF',
276
- 'congo-brazzaville' => 'CG',
277
- 'congo-kinshasa' => 'CD',
278
- 'zaire' => 'CD',
279
- 'san-marin' => 'SM',
280
- 'surinam' => 'SR',
281
- 'myanmar' => 'MM',
282
- 'saint-christophe-nevis' => 'KN',
283
- 'saint-kitts-nevis' => 'KN',
284
- 'falkland' => 'FK',
285
- 'el-salvador' => 'SV',
286
- 'lithuanie' => 'LT',
287
- 'turks-caiques' => 'TC',
288
- 'vierges-des-etats-unis' => 'VI',
289
- 'etat-de-la-cite-du-vatican' => 'VA',
290
- 'etats-federes-de-micronesie' => 'FM',
291
- 'r-a-s-chinoise-de-hong-kong' => 'HK',
292
- 'r-a-s-chinoise-de-macao' => 'MO',
293
- ),
294
- );
295
-
296
- public static function loadCache() {
297
- $filename = 'var/cache/countries.txt';
298
- if (!file_exists($filename)) {
299
- self::$COUNTRIES['code2soft-cleaned-name'] = array();
300
- self::$COUNTRIES['code2hard-cleaned-name'] = array();
301
- foreach (self::$COUNTRIES['code2name'] as $_code => $_name) {
302
- $soft_cleaned = self::softClean($_name);
303
- self::$COUNTRIES['code2soft-cleaned-name'][$_code] = $soft_cleaned;
304
- self::$COUNTRIES['code2hard-cleaned-name'][$_code] = self::hardClean($soft_cleaned);
305
- }
306
- $fp = fopen($filename,'w');
307
- fwrite($fp, serialize(self::$COUNTRIES));
308
- //file_put_contents('var/cache/countries.txt',serialize(self::$COUNTRIES));
309
- } else {
310
- self::$COUNTRIES = unserialize(file_get_contents($filename));
311
- }
312
- }
313
-
314
- public static function getCountryNameByCode($code) {
315
- return isset(self::$COUNTRIES['code2name'][$code]) ? self::$COUNTRIES['code2name'][$code] : null;
316
- }
317
-
318
- public static function getCountryCodeByName($name, $name_type=null) {
319
- $suffix = isset($name_type) ? $name_type.'-' : '';
320
- if (!self::$LOADED) self::loadCache();
321
- $code = array_search($name, self::$COUNTRIES['code2'.$suffix.'name']);
322
- return $code!==false ? $code : null;
323
- }
324
-
325
- public static function getCountryCodeByReplacedName($cleaned_name) {
326
- if (isset(self::$COUNTRIES['replacement'][$cleaned_name])) return self::$COUNTRIES['replacement'][$cleaned_name];
327
- return null;
328
- }
329
-
330
- public static function softClean($input) {
331
- $input = mb_strtolower($input,'UTF-8');
332
- $input = preg_replace('/[ -\.]+/','-',trim($input));
333
- //echo '"'.$input.'" => ';
334
- $input = str_replace(
335
- array(' ','ç','é','è','ê','ë','à','á','â','ä','ã','å','ô','ö','ù','û','ü','î','ï','ÿ'),
336
- array('-','c','e','e','e','e','a','a','a','a','a','a','o','o','u','u','u','i','i','y'),
337
- $input
338
- );
339
- //echo '"'.$input.'", ';
340
- $input = preg_replace("/^st-/",'saint-',$input);
341
- $input = preg_replace("/^ste-/",'sainte-',$input);
342
- $input = preg_replace("/-&-/",'-et-',$input);
343
- return $input;
344
- }
345
-
346
- public static function hardClean($input) {
347
- //$output = preg_match('/ivoire/',$input);
348
- //if ($output) echo '"'.$input.'" => ';
349
- $input = preg_replace("/^(?:les|le|la|l'|ile|iles)-/",'',$input);
350
- $input = preg_replace("/-(?:ile|iles)$/",'',$input);
351
- $input = preg_replace("/-(?:(?:et|les)-)+/",'-',$input);
352
- $input = preg_replace("/(?:[^a-z0-9]+)/",'-',$input);
353
- //if ($output) echo '"'.$input.'",<br/>';
354
- return $input;
355
- }
356
-
357
- }
358
-
359
- class AddressFilter extends Country
360
- {
361
- private $data;
362
- private $code;
363
- private $name;
364
- private $classes;
365
- private $label;
366
- private $arranged;
367
- private $address_filters_list;
368
-
369
- public function AddressFilter($data) {
370
- //$input = trim($input);
371
- $this->data = $data;
372
- $this->classes = array();
373
- $this->address_filters_list = null;
374
- $this->parse();
375
- }
376
-
377
- public function parse($recursive=true) {
378
- if (strlen($this->data['country_code'])==2) {
379
- $code = strtoupper($this->data['country_code']);
380
- $name = Country::getCountryNameByCode($code);
381
-
382
- if (isset($name)) {
383
- $this->code = $code;
384
- $this->name = $name;
385
- $this->classes[] = 'known';
386
- }
387
- }
388
- if (!isset($this->name)) {
389
- $code = Country::getCountryCodeByName($this->data['country_code']);
390
- if (!isset($code)) {
391
- $this->classes[] = 'soft-cleaned';
392
- $cleaned_name = Country::softClean($this->data['country_code']);
393
- $code = Country::getCountryCodeByName($cleaned_name,'soft-cleaned');
394
- }
395
- if (!isset($code)) {
396
- $this->classes[] = 'replaced';
397
- $code = Country::getCountryCodeByReplacedName($cleaned_name);
398
- }
399
- if (!isset($code)) {
400
- $this->classes[] = 'hard-cleaned';
401
- $cleaned_name = Country::hardClean($cleaned_name);
402
- $code = Country::getCountryCodeByName($cleaned_name,'hard-cleaned');
403
- }
404
- if (!isset($code)) {
405
- $this->classes[] = 'replaced';
406
- $code = Country::getCountryCodeByReplacedName($cleaned_name);
407
- }
408
- if (isset($code)) {
409
- $this->code = $code;
410
- $this->name = Country::getCountryNameByCode($code);
411
- $this->classes[] = 'known';
412
- } else {
413
- $this->classes[] = 'unknown';
414
- }
415
- }
416
-
417
- if ($recursive && $this->hasClass('unknown')) {
418
- if (!isset($cleaned_name)) $cleaned_name = Country::hardClean(Country::softClean($this->data['original']));
419
- switch ($cleaned_name) {
420
- case 'corse':
421
- $this->data = array(
422
- 'exclusion' => false,
423
- 'country_code' => 'FR',
424
- 'region_codes' => '2A,2B',
425
- 'original' => $this->data['original'],
426
- );
427
- $this->classes = array('replaced');
428
- $this->parse(false);
429
- break;
430
- case 'uk':
431
- $this->data = array(
432
- 'exclusion' => false,
433
- 'country_code' => 'GB',
434
- 'region_codes' => '',
435
- 'original' => $this->data['original'],
436
- );
437
- $this->classes = array('replaced');
438
- $this->parse(false);
439
- break;
440
- case 'union-europeenne':
441
- case 'ue':
442
- $this->createAddressFilterGroup(
443
- array('DE','AT','BE','BG','CY','DK','ES','EE','FI','FR','GR','HU','IE','IT','LV','LT','LU','MT','NL','PL','PT','CZ','RO','GB','SK','SI','SE'),
444
- $code = 'UE',
445
- $name = 'Union européenne'
446
- );
447
- break;
448
- case 'dom':
449
- $this->createAddressFilterGroup(
450
- array('GP','MQ','GF','RE'),
451
- $code = 'DOM',
452
- $name = "Département d'Outre-Mer"
453
- );
454
- break;
455
- case 'com':
456
- $this->createAddressFilterGroup(
457
- array('PF','PM','WF','YT','MF','BL'),
458
- $code = 'COM',
459
- $name = "Collectivités d'Outre-Mer"
460
- );
461
- break;
462
- case 'outre-mer':
463
- $this->createAddressFilterGroup(
464
- array('DOM','COM','NC','TF'),
465
- $code = "Outre-Mer",
466
- $name = "Outre-Mer"
467
- );
468
- break;
469
- }
470
- }
471
-
472
- if ($this->hasClass('known')) {
473
- if ($this->hasClass('replaced') || $this->hasClass('hard-cleaned')) $this->label = '<span class="bad">'.$this->data['original'].'</span> '.$this->name;
474
- else $this->label = $this->name;
475
- if (isset($this->data['region_codes']) && $this->data['region_codes']!='') {
476
- $this->label .= ' ('.$this->data['region_codes'].')';
477
- }
478
- } else {
479
- $this->label = $this->data['original'];
480
- }
481
- }
482
-
483
- public function createAddressFilterGroup($countries, $code, $name) {
484
- $this->address_filters_list = array();
485
- foreach ($countries as $country_code) {
486
- $this->address_filters_list[] = new AddressFilter(array('country_code' => $country_code, 'original' => $country_code));
487
- }
488
- $this->classes = array('known');
489
- $this->code = $code;
490
- $this->name = $name;
491
- }
492
-
493
- public function hasClass($class) {
494
- return in_array($class,$this->classes);
495
- }
496
-
497
- public function __toString() {
498
- $output = '';
499
- if (isset($this->address_filters_list)) {
500
- $compact_value = $this->code;
501
- $full_value = $this->name;
502
- $output .= '<span class="address-filter address-filter-group"'
503
- .' full-value="'.$full_value.'" compact-value="'.$compact_value.'" original-value="'.$this->data['original'].'"><span class="address-filter-group-label">'.$this->label.'</span>';
504
- foreach ($this->address_filters_list as $address_filter) {
505
- $output .= $address_filter;
506
- }
507
- $output .= '</span>';
508
- } else {
509
- if (isset($this->code)) {
510
- $compact_value = $this->code.(isset($this->data['region_codes']) && $this->data['region_codes']!='' ? '('.$this->data['region_codes'].')' : '');
511
- $full_value = $this->name.(isset($this->data['region_codes']) && $this->data['region_codes']!='' ? ' ('.$this->data['region_codes'].')' : '');
512
- } else {
513
- $compact_value = $this->data['original'];
514
- $full_value = $this->data['original'];
515
- }
516
- $output .= '<span class="address-filter country-'.$this->code.' '.implode(' ',$this->classes)
517
- .'" country-code="'.$this->code.'" full-value="'.$full_value.'" compact-value="'.$compact_value.'" original-value="'.$this->data['original'].'">'
518
- .$this->label.'</span>';
519
- }
520
- return $output;
521
- }
522
- }
523
-
524
-
525
  ?>
1
+ <?php
2
+
3
+
4
+ class Country
5
+ {
6
+ private static $LOADED = false;
7
+ private static $COUNTRIES = array(
8
+ 'code2name' => array(
9
+ 'AF' => 'Afghanistan',
10
+ 'ZA' => 'Afrique du Sud',
11
+ 'AX' => 'Åland',
12
+ 'AL' => 'Albanie',
13
+ 'DZ' => 'Algérie',
14
+ 'DE' => 'Allemagne',
15
+ 'AD' => 'Andorre',
16
+ 'AO' => 'Angola',
17
+ 'AI' => 'Anguilla',
18
+ 'AQ' => 'Antarctique',
19
+ 'AG' => 'Antigua-et-Barbuda',
20
+ 'AN' => 'Antilles néerlandaises',
21
+ 'SA' => 'Arabie saoudite',
22
+ 'AR' => 'Argentine',
23
+ 'AM' => 'Arménie',
24
+ 'AW' => 'Aruba',
25
+ 'AU' => 'Australie',
26
+ 'AT' => 'Autriche',
27
+ 'AZ' => 'Azerbaïdjan',
28
+ 'BS' => 'Bahamas',
29
+ 'BH' => 'Bahreïn',
30
+ 'BD' => 'Bangladesh',
31
+ 'BB' => 'Barbade',
32
+ 'BY' => 'Biélorussie',
33
+ 'BE' => 'Belgique',
34
+ 'BZ' => 'Belize',
35
+ 'BJ' => 'Bénin',
36
+ 'BM' => 'Bermudes',
37
+ 'BT' => 'Bhoutan',
38
+ 'BO' => 'Bolivie',
39
+ 'BA' => 'Bosnie-Herzégovine',
40
+ 'BW' => 'Botswana',
41
+ 'BV' => 'Île Bouvet',
42
+ 'BR' => 'Brésil',
43
+ 'BN' => 'Brunei',
44
+ 'BG' => 'Bulgarie',
45
+ 'BF' => 'Burkina Faso',
46
+ 'BI' => 'Burundi',
47
+ 'KY' => 'Îles Caïmans',
48
+ 'KH' => 'Cambodge',
49
+ 'CM' => 'Cameroun',
50
+ 'CA' => 'Canada',
51
+ 'CV' => 'Cap-Vert',
52
+ 'CF' => 'République centrafricaine',
53
+ 'CL' => 'Chili',
54
+ 'CN' => 'Chine',
55
+ 'CX' => 'Île Christmas',
56
+ 'CY' => 'Chypre',
57
+ 'CC' => 'Îles Cocos',
58
+ 'CO' => 'Colombie',
59
+ 'KM' => 'Comores',
60
+ 'CG' => 'Congo',
61
+ 'CD' => 'République démocratique du Congo',
62
+ 'CK' => 'Îles Cook',
63
+ 'KR' => 'Corée du Sud',
64
+ 'KP' => 'Corée du Nord',
65
+ 'CR' => 'Costa Rica',
66
+ 'CI' => "Côte d'Ivoire",
67
+ 'HR' => 'Croatie',
68
+ 'CU' => 'Cuba',
69
+ 'DK' => 'Danemark',
70
+ 'DJ' => 'Djibouti',
71
+ 'DO' => 'République dominicaine',
72
+ 'DM' => 'Dominique',
73
+ 'EG' => 'Égypte',
74
+ 'SV' => 'Salvador',
75
+ 'AE' => 'Émirats arabes unis',
76
+ 'EC' => 'Équateur',
77
+ 'ER' => 'Érythrée',
78
+ 'ES' => 'Espagne',
79
+ 'EE' => 'Estonie',
80
+ 'US' => 'États-Unis',
81
+ 'ET' => 'Éthiopie',
82
+ 'FK' => 'Îles Malouines',
83
+ 'FO' => 'Îles Féroé',
84
+ 'FJ' => 'Fidji',
85
+ 'FI' => 'Finlande',
86
+ 'FR' => 'France',
87
+ 'GA' => 'Gabon',
88
+ 'GM' => 'Gambie',
89
+ 'GE' => 'Géorgie',
90
+ 'GS' => 'Géorgie du Sud-et-les Îles Sandwich du Sud',
91
+ 'GH' => 'Ghana',
92
+ 'GI' => 'Gibraltar',
93
+ 'GR' => 'Grèce',
94
+ 'GD' => 'Grenade',
95
+ 'GL' => 'Groenland',
96
+ 'GP' => 'Guadeloupe',
97
+ 'GU' => 'Guam',
98
+ 'GT' => 'Guatemala',
99
+ 'GG' => 'Guernesey',
100
+ 'GN' => 'Guinée',
101
+ 'GW' => 'Guinée-Bissau',
102
+ 'GQ' => 'Guinée équatoriale',
103
+ 'GY' => 'Guyana',
104
+ 'GF' => 'Guyane Française',
105
+ 'HT' => 'Haïti',
106
+ 'HM' => 'Îles Heard-et-MacDonald',
107
+ 'HN' => 'Honduras',
108
+ 'HK' => 'Hong Kong',
109
+ 'HU' => 'Hongrie',
110
+ 'IM' => 'Île de Man',
111
+ 'UM' => 'Îles mineures éloignées des États-Unis',
112
+ 'VG' => 'Îles Vierges britanniques',
113
+ 'VI' => 'Îles Vierges américaines',
114
+ 'IN' => 'Inde',
115
+ 'ID' => 'Indonésie',
116
+ 'IR' => 'Iran',
117
+ 'IQ' => 'Irak',
118
+ 'IE' => 'Irlande',
119
+ 'IS' => 'Islande',
120
+ 'IL' => 'Israël',
121
+ 'IT' => 'Italie',
122
+ 'JM' => 'Jamaïque',
123
+ 'JP' => 'Japon',
124
+ 'JE' => 'Jersey',
125
+ 'JO' => 'Jordanie',
126
+ 'KZ' => 'Kazakhstan',
127
+ 'KE' => 'Kenya',
128
+ 'KG' => 'Kirghizistan',
129
+ 'KI' => 'Kiribati',
130
+ 'KW' => 'Koweït',
131
+ 'LA' => 'Laos',
132
+ 'LS' => 'Lesotho',
133
+ 'LV' => 'Lettonie',
134
+ 'LB' => 'Liban',
135
+ 'LR' => 'Libéria',
136
+ 'LY' => 'Libye',
137
+ 'LI' => 'Liechtenstein',
138
+ 'LT' => 'Lituanie',
139
+ 'LU' => 'Luxembourg',
140
+ 'MO' => 'Macao',
141
+ 'MK' => 'Macédoine',
142
+ 'MG' => 'Madagascar',
143
+ 'MY' => 'Malaisie',
144
+ 'MW' => 'Malawi',
145
+ 'MV' => 'Maldives',
146
+ 'ML' => 'Mali',
147
+ 'MT' => 'Malte',
148
+ 'MP' => 'Îles Mariannes du Nord',
149
+ 'MA' => 'Maroc',
150
+ 'MH' => 'Îles Marshall',
151
+ 'MQ' => 'Martinique',
152
+ 'MU' => 'Île Maurice',
153
+ 'MR' => 'Mauritanie',
154
+ 'YT' => 'Mayotte',
155
+ 'MX' => 'Mexique',
156
+ 'FM' => 'Micronésie',
157
+ 'MD' => 'Moldavie',
158
+ 'MC' => 'Monaco',
159
+ 'MN' => 'Mongolie',
160
+ 'ME' => 'Monténégro',
161
+ 'MS' => 'Montserrat',
162
+ 'MZ' => 'Mozambique',
163
+ 'MM' => 'Birmanie',
164
+ 'NA' => 'Namibie',
165
+ 'NR' => 'Nauru',
166
+ 'NP' => 'Népal',
167
+ 'NI' => 'Nicaragua',
168
+ 'NE' => 'Niger',
169
+ 'NG' => 'Nigéria',
170
+ 'NU' => 'Niué',
171
+ 'NF' => 'Île Norfolk',
172
+ 'NO' => 'Norvège',
173
+ 'NC' => 'Nouvelle-Calédonie',
174
+ 'NZ' => 'Nouvelle-Zélande',
175
+ 'IO' => "Territoire britannique de l'océan Indien",
176
+ 'OM' => 'Oman',
177
+ 'UG' => 'Ouganda',
178
+ 'UZ' => 'Ouzbékistan',
179
+ 'PK' => 'Pakistan',
180
+ 'PW' => 'Palaos',
181
+ 'PS' => 'Palestine',
182
+ 'PA' => 'Panamá',
183
+ 'PG' => 'Papouasie-Nouvelle-Guinée',
184
+ 'PY' => 'Paraguay',
185
+ 'NL' => 'Pays-Bas',
186
+ 'PE' => 'Pérou',
187
+ 'PH' => 'Philippines',
188
+ 'PN' => 'Îles Pitcairn',
189
+ 'PL' => 'Pologne',
190
+ 'PF' => 'Polynésie Française',
191
+ 'PR' => 'Porto Rico',
192
+ 'PT' => 'Portugal',
193
+ 'QA' => 'Qatar',
194
+ 'RE' => 'La Réunion',
195
+ 'RO' => 'Roumanie',
196
+ 'GB' => 'Royaume-Uni',
197
+ 'RU' => 'Russie',
198
+ 'RW' => 'Rwanda',
199
+ 'EH' => 'Sahara occidental',
200
+ 'BL' => 'Saint-Barthélemy',
201
+ 'KN' => 'Saint-Christophe-et-Niévès',
202
+ 'SM' => 'Saint-Marin',
203
+ 'MF' => 'Saint-Martin',
204
+ 'PM' => 'Saint-Pierre-et-Miquelon',
205
+ 'VA' => 'Vatican',
206
+ 'VC' => 'Saint-Vincent-et-les Grenadines',
207
+ 'SH' => 'Sainte-Hélène',
208
+ 'LC' => 'Sainte-Lucie',
209
+ 'SB' => 'Îles Salomon',
210
+ 'WS' => 'Samoa',
211
+ 'AS' => 'Samoa américaines',
212
+ 'ST' => 'São Tomé-et-Principe',
213
+ 'SN' => 'Sénégal',
214
+ 'RS' => 'Serbie',
215
+ 'SC' => 'Seychelles',
216
+ 'SL' => 'Sierra Leone',
217
+ 'SG' => 'Singapour',
218
+ 'SK' => 'Slovaquie',
219
+ 'SI' => 'Slovénie',
220
+ 'SO' => 'Somalie',
221
+ 'SD' => 'Soudan',
222
+ 'LK' => 'Sri Lanka',
223
+ 'SE' => 'Suède',
224
+ 'CH' => 'Suisse',
225
+ 'SR' => 'Suriname',
226
+ 'SJ' => 'Svalbard et île Jan Mayen',
227
+ 'SZ' => 'Swaziland',
228
+ 'SY' => 'Syrie',
229
+ 'TJ' => 'Tadjikistan',
230
+ 'TW' => 'Taïwan',
231
+ 'TZ' => 'Tanzanie',
232
+ 'TD' => 'Tchad',
233
+ 'CZ' => 'République tchèque',
234
+ 'TF' => 'Terres Australes et Antarctiques Françaises',
235
+ 'TH' => 'Thaïlande',
236
+ 'TL' => 'Timor oriental',
237
+ 'TG' => 'Togo',
238
+ 'TK' => 'Tokelau',
239
+ 'TO' => 'Tonga',
240
+ 'TT' => 'Trinité-et-Tobago',
241
+ 'TN' => 'Tunisie',
242
+ 'TM' => 'Turkménistan',
243
+ 'TC' => 'Îles Turques-et-Caïques',
244
+ 'TR' => 'Turquie',
245
+ 'TV' => 'Tuvalu',
246
+ 'UA' => 'Ukraine',
247
+ 'UY' => 'Uruguay',
248
+ 'VU' => 'Vanuatu',
249
+ 'VE' => 'Venezuela',
250
+ 'VN' => 'Viêt Nam',
251
+ 'WF' => 'Wallis-et-Futuna',
252
+ 'YE' => 'Yémen',
253
+ 'ZM' => 'Zambie',
254
+ 'ZW' => 'Zimbabwe',
255
+ ),
256
+ 'code2soft-cleaned-name' => null,
257
+ 'code2hard-cleaned-name' => null,
258
+ 'replacement' => array(
259
+ 'reunion' => 'RE',
260
+ 'france-metropolitaine' => 'FR',
261
+ 'guyane' => 'GF',
262
+ 'taaf' => 'TF',
263
+ 'terres-australes-francaises' => 'TF',
264
+ 'usa' => 'US',
265
+ 'hollande' => 'NL',
266
+ 'grande-bretagne' => 'GB',
267
+ 'vietnam' => 'VN',
268
+ 'belarus' => 'BY',
269
+ 'brunei-darussalam' => 'BN',
270
+ 'cayman' => 'KY',
271
+ 'caiman' => 'KY',
272
+ 'caimanes' => 'KY',
273
+ 'cocos-keeling' => 'CC',
274
+ 'keeling' => 'CC',
275
+ 'centrafrique' => 'CF',
276
+ 'congo-brazzaville' => 'CG',
277
+ 'congo-kinshasa' => 'CD',
278
+ 'zaire' => 'CD',
279
+ 'san-marin' => 'SM',
280
+ 'surinam' => 'SR',
281
+ 'myanmar' => 'MM',
282
+ 'saint-christophe-nevis' => 'KN',
283
+ 'saint-kitts-nevis' => 'KN',
284
+ 'falkland' => 'FK',
285
+ 'el-salvador' => 'SV',
286
+ 'lithuanie' => 'LT',
287
+ 'turks-caiques' => 'TC',
288
+ 'vierges-des-etats-unis' => 'VI',
289
+ 'etat-de-la-cite-du-vatican' => 'VA',
290
+ 'etats-federes-de-micronesie' => 'FM',
291
+ 'r-a-s-chinoise-de-hong-kong' => 'HK',
292
+ 'r-a-s-chinoise-de-macao' => 'MO',
293
+ ),
294
+ );
295
+
296
+ public static function loadCache() {
297
+ $filename = 'var/cache/countries.txt';
298
+ if (!file_exists($filename)) {
299
+ self::$COUNTRIES['code2soft-cleaned-name'] = array();
300
+ self::$COUNTRIES['code2hard-cleaned-name'] = array();
301
+ foreach (self::$COUNTRIES['code2name'] as $_code => $_name) {
302
+ $soft_cleaned = self::softClean($_name);
303
+ self::$COUNTRIES['code2soft-cleaned-name'][$_code] = $soft_cleaned;
304
+ self::$COUNTRIES['code2hard-cleaned-name'][$_code] = self::hardClean($soft_cleaned);
305
+ }
306
+ $fp = fopen($filename,'w');
307
+ fwrite($fp, serialize(self::$COUNTRIES));
308
+ //file_put_contents('var/cache/countries.txt',serialize(self::$COUNTRIES));
309
+ } else {
310
+ self::$COUNTRIES = unserialize(file_get_contents($filename));
311
+ }
312
+ }
313
+
314
+ public static function getCountryNameByCode($code) {
315
+ return isset(self::$COUNTRIES['code2name'][$code]) ? self::$COUNTRIES['code2name'][$code] : null;
316
+ }
317
+
318
+ public static function getCountryCodeByName($name, $name_type=null) {
319
+ $suffix = isset($name_type) ? $name_type.'-' : '';
320
+ if (!self::$LOADED) self::loadCache();
321
+ $code = array_search($name, self::$COUNTRIES['code2'.$suffix.'name']);
322
+ return $code!==false ? $code : null;
323
+ }
324
+
325
+ public static function getCountryCodeByReplacedName($cleaned_name) {
326
+ if (isset(self::$COUNTRIES['replacement'][$cleaned_name])) return self::$COUNTRIES['replacement'][$cleaned_name];
327
+ return null;
328
+ }
329
+
330
+ public static function softClean($input) {
331
+ $input = mb_strtolower($input,'UTF-8');
332
+ $input = preg_replace('/[ -\.]+/','-',trim($input));
333
+ //echo '"'.$input.'" => ';
334
+ $input = str_replace(
335
+ array(' ','ç','é','è','ê','ë','à','á','â','ä','ã','å','ô','ö','ù','û','ü','î','ï','ÿ'),
336
+ array('-','c','e','e','e','e','a','a','a','a','a','a','o','o','u','u','u','i','i','y'),
337
+ $input
338
+ );
339
+ //echo '"'.$input.'", ';
340
+ $input = preg_replace("/^st-/",'saint-',$input);
341
+ $input = preg_replace("/^ste-/",'sainte-',$input);
342
+ $input = preg_replace("/-&-/",'-et-',$input);
343
+ return $input;
344
+ }
345
+
346
+ public static function hardClean($input) {
347
+ //$output = preg_match('/ivoire/',$input);
348
+ //if ($output) echo '"'.$input.'" => ';
349
+ $input = preg_replace("/^(?:les|le|la|l'|ile|iles)-/",'',$input);
350
+ $input = preg_replace("/-(?:ile|iles)$/",'',$input);
351
+ $input = preg_replace("/-(?:(?:et|les)-)+/",'-',$input);
352
+ $input = preg_replace("/(?:[^a-z0-9]+)/",'-',$input);
353
+ //if ($output) echo '"'.$input.'",<br/>';
354
+ return $input;
355
+ }
356
+
357
+ }
358
+
359
+ class AddressFilter extends Country
360
+ {
361
+ private $data;
362
+ private $code;
363
+ private $name;
364
+ private $classes;
365
+ private $label;
366
+ private $arranged;
367
+ private $address_filters_list;
368
+
369
+ public function AddressFilter($data) {
370
+ //$input = trim($input);
371
+ $this->data = $data;
372
+ $this->classes = array();
373
+ $this->address_filters_list = null;
374
+ $this->parse();
375
+ }
376
+
377
+ public function parse($recursive=true) {
378
+ if (strlen($this->data['country_code'])==2) {
379
+ $code = strtoupper($this->data['country_code']);
380
+ $name = Country::getCountryNameByCode($code);
381
+
382
+ if (isset($name)) {
383
+ $this->code = $code;
384
+ $this->name = $name;
385
+ $this->classes[] = 'known';
386
+ }
387
+ }
388
+ if (!isset($this->name)) {
389
+ $code = Country::getCountryCodeByName($this->data['country_code']);
390
+ if (!isset($code)) {
391
+ $this->classes[] = 'soft-cleaned';
392
+ $cleaned_name = Country::softClean($this->data['country_code']);
393
+ $code = Country::getCountryCodeByName($cleaned_name,'soft-cleaned');
394
+ }
395
+ if (!isset($code)) {
396
+ $this->classes[] = 'replaced';
397
+ $code = Country::getCountryCodeByReplacedName($cleaned_name);
398
+ }
399
+ if (!isset($code)) {
400
+ $this->classes[] = 'hard-cleaned';
401
+ $cleaned_name = Country::hardClean($cleaned_name);
402
+ $code = Country::getCountryCodeByName($cleaned_name,'hard-cleaned');
403
+ }
404
+ if (!isset($code)) {
405
+ $this->classes[] = 'replaced';
406
+ $code = Country::getCountryCodeByReplacedName($cleaned_name);
407
+ }
408
+ if (isset($code)) {
409
+ $this->code = $code;
410
+ $this->name = Country::getCountryNameByCode($code);
411
+ $this->classes[] = 'known';
412
+ } else {
413
+ $this->classes[] = 'unknown';
414
+ }
415
+ }
416
+
417
+ if ($recursive && $this->hasClass('unknown')) {
418
+ if (!isset($cleaned_name)) $cleaned_name = Country::hardClean(Country::softClean($this->data['original']));
419
+ switch ($cleaned_name) {
420
+ case 'corse':
421
+ $this->data = array(
422
+ 'exclusion' => false,
423
+ 'country_code' => 'FR',
424
+ 'region_codes' => '2A,2B',
425
+ 'original' => $this->data['original'],
426
+ );
427
+ $this->classes = array('replaced');
428
+ $this->parse(false);
429
+ break;
430
+ case 'uk':
431
+ $this->data = array(
432
+ 'exclusion' => false,
433
+ 'country_code' => 'GB',
434
+ 'region_codes' => '',
435
+ 'original' => $this->data['original'],
436
+ );
437
+ $this->classes = array('replaced');
438
+ $this->parse(false);
439
+ break;
440
+ case 'union-europeenne':
441
+ case 'ue':
442
+ $this->createAddressFilterGroup(
443
+ array('DE','AT','BE','BG','CY','DK','ES','EE','FI','FR','GR','HU','IE','IT','LV','LT','LU','MT','NL','PL','PT','CZ','RO','GB','SK','SI','SE'),
444
+ $code = 'UE',
445
+ $name = 'Union européenne'
446
+ );
447
+ break;
448
+ case 'dom':
449
+ $this->createAddressFilterGroup(
450
+ array('GP','MQ','GF','RE'),
451
+ $code = 'DOM',
452
+ $name = "Département d'Outre-Mer"
453
+ );
454
+ break;
455
+ case 'com':
456
+ $this->createAddressFilterGroup(
457
+ array('PF','PM','WF','YT','MF','BL'),
458
+ $code = 'COM',
459
+ $name = "Collectivités d'Outre-Mer"
460
+ );
461
+ break;
462
+ case 'outre-mer':
463
+ $this->createAddressFilterGroup(
464
+ array('DOM','COM','NC','TF'),
465
+ $code = "Outre-Mer",
466
+ $name = "Outre-Mer"
467
+ );
468
+ break;
469
+ }
470
+ }
471
+
472
+ if ($this->hasClass('known')) {
473
+ if ($this->hasClass('replaced') || $this->hasClass('hard-cleaned')) $this->label = '<span class="bad">'.$this->data['original'].'</span> '.$this->name;
474
+ else $this->label = $this->name;
475
+ if (isset($this->data['region_codes']) && $this->data['region_codes']!='') {
476
+ $this->label .= ' ('.$this->data['region_codes'].')';
477
+ }
478
+ } else {
479
+ $this->label = $this->data['original'];
480
+ }
481
+ }
482
+
483
+ public function createAddressFilterGroup($countries, $code, $name) {
484
+ $this->address_filters_list = array();
485
+ foreach ($countries as $country_code) {
486
+ $this->address_filters_list[] = new AddressFilter(array('country_code' => $country_code, 'original' => $country_code));
487
+ }
488
+ $this->classes = array('known');
489
+ $this->code = $code;
490
+ $this->name = $name;
491
+ }
492
+
493
+ public function hasClass($class) {
494
+ return in_array($class,$this->classes);
495
+ }
496
+
497
+ public function __toString() {
498
+ $output = '';
499
+ if (isset($this->address_filters_list)) {
500
+ $compact_value = $this->code;
501
+ $full_value = $this->name;
502
+ $output .= '<span class="address-filter address-filter-group"'
503
+ .' full-value="'.$full_value.'" compact-value="'.$compact_value.'" original-value="'.$this->data['original'].'"><span class="address-filter-group-label">'.$this->label.'</span>';
504
+ foreach ($this->address_filters_list as $address_filter) {
505
+ $output .= $address_filter;
506
+ }
507
+ $output .= '</span>';
508
+ } else {
509
+ if (isset($this->code)) {
510
+ $compact_value = $this->code.(isset($this->data['region_codes']) && $this->data['region_codes']!='' ? '('.$this->data['region_codes'].')' : '');
511
+ $full_value = $this->name.(isset($this->data['region_codes']) && $this->data['region_codes']!='' ? ' ('.$this->data['region_codes'].')' : '');
512
+ } else {
513
+ $compact_value = $this->data['original'];
514
+ $full_value = $this->data['original'];
515
+ }
516
+ $output .= '<span class="address-filter country-'.$this->code.' '.implode(' ',$this->classes)
517
+ .'" country-code="'.$this->code.'" full-value="'.$full_value.'" compact-value="'.$compact_value.'" original-value="'.$this->data['original'].'">'
518
+ .$this->label.'</span>';
519
+ }
520
+ return $output;
521
+ }
522
+ }
523
+
524
+
525
  ?>
app/design/adminhtml/default/default/template/chronorelais/notification.phtml CHANGED
@@ -3,7 +3,8 @@
3
  * @see Chronopost_Chronorelais_Block_Adminhtml_Notification
4
  */
5
  ?>
6
- <?php if ($this->canShow()): ?>
 
7
  <script type="text/javascript">
8
  //<![CDATA[
9
  var messagePopupClosed = false;
@@ -43,11 +44,24 @@
43
  <div class="message-popup-content">
44
  <div class="message">
45
  <span class="message-icon message-notice" style="background-image:url(<?php echo $this->getSeverityIconsUrl() ?>);">Notice</span>
 
46
  <p class="message-text">
47
- Le quickcost est momentanément indisponible, les prix renseignés dans la grille tarifaire sont appliqués.
48
- <br />
49
- Veuillez les vérifier.
 
 
 
 
 
 
 
 
 
 
 
50
  </p>
 
51
  </div>
52
  </div>
53
  </div>
3
  * @see Chronopost_Chronorelais_Block_Adminhtml_Notification
4
  */
5
  ?>
6
+ <?php $notifications = $this->getNotifications();?>
7
+ <?php if ($this->canShow() && count($notifications) > 0): ?>
8
  <script type="text/javascript">
9
  //<![CDATA[
10
  var messagePopupClosed = false;
44
  <div class="message-popup-content">
45
  <div class="message">
46
  <span class="message-icon message-notice" style="background-image:url(<?php echo $this->getSeverityIconsUrl() ?>);">Notice</span>
47
+ <?php foreach($notifications as $notif): ?>
48
  <p class="message-text">
49
+ <?php
50
+ switch($notif) {
51
+ case 'quickcost_not_available':
52
+ echo 'Le quickcost est momentanément indisponible, les prix renseignés dans la grille tarifaire sont appliqués.
53
+ <br />
54
+ Veuillez les vérifier.';
55
+ break;
56
+
57
+ case 'new_version':
58
+ echo 'Une nouvelle version du module Chronopost est disponible.';
59
+ echo 'Vous pouvez la télécharger <a href="http://www.magentocommerce.com/magento-connect/chronopost.html" target="_blank">ici</a>';
60
+ break;
61
+ }
62
+ ?>
63
  </p>
64
+ <?php endforeach; ?>
65
  </div>
66
  </div>
67
  </div>
app/design/frontend/{default → base}/default/layout/chronorelais.xml RENAMED
@@ -5,7 +5,7 @@
5
  <action method="addItem"><type>skin_css</type><name>chronorelais/chronorelais.css</name></action>
6
  </reference>
7
  </default>
8
-
9
  <checkout_onepage_index>
10
  <reference name="checkout.onepage.shipping_method">
11
  <action method="setTemplate"><template>chronorelais/checkout/onepage/shipping_method.phtml</template></action>
@@ -14,7 +14,7 @@
14
  </block>
15
  </reference>
16
  </checkout_onepage_index>
17
-
18
  <!-- -->
19
  <checkout_multishipping_shipping>
20
  <update handle="checkout_multishipping"/>
@@ -24,7 +24,7 @@
24
  </reference>
25
  </checkout_multishipping_shipping>
26
  <!-- -->
27
-
28
  <checkout_onepage_shippingmethod>
29
  <remove name="right"/>
30
  <remove name="left"/>
@@ -56,5 +56,5 @@
56
  <action method="setTemplate"><template>chronorelais/sales/order/history.phtml</template></action>
57
  </reference>
58
  </sales_order_history>
59
-
60
  </layout>
5
  <action method="addItem"><type>skin_css</type><name>chronorelais/chronorelais.css</name></action>
6
  </reference>
7
  </default>
8
+
9
  <checkout_onepage_index>
10
  <reference name="checkout.onepage.shipping_method">
11
  <action method="setTemplate"><template>chronorelais/checkout/onepage/shipping_method.phtml</template></action>
14
  </block>
15
  </reference>
16
  </checkout_onepage_index>
17
+
18
  <!-- -->
19
  <checkout_multishipping_shipping>
20
  <update handle="checkout_multishipping"/>
24
  </reference>
25
  </checkout_multishipping_shipping>
26
  <!-- -->
27
+
28
  <checkout_onepage_shippingmethod>
29
  <remove name="right"/>
30
  <remove name="left"/>
56
  <action method="setTemplate"><template>chronorelais/sales/order/history.phtml</template></action>
57
  </reference>
58
  </sales_order_history>
59
+
60
  </layout>
app/design/frontend/{default → base}/default/template/chronorelais/checkout/multishipping/shipping.phtml RENAMED
@@ -1,152 +1,152 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-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@magentocommerce.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.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php
28
- /**
29
- * Multishipping checkout shipping template
30
- *
31
- * @see Mage_Checkout_Block_Multishipping_Shipping
32
- */
33
- ?>
34
- <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=<?php echo Mage::helper('chronorelais')->getConfigurationGoogleMapAPIKey()?>" type="text/javascript"></script>
35
- <script type="text/javascript" src="<?php echo $this->getSkinUrl('chronorelais/chronorelaismap.js') ?>"></script>
36
- <script type="text/javascript">
37
- //<![CDATA[
38
- var Picto_Chrono_Relais = '<?php echo $this->getSkinUrl('chronorelais/Picto_Chrono_Relais.png')?>';
39
- var Home_Chrono_Icon = '<?php echo $this->getSkinUrl('chronorelais/home.png')?>';
40
- //]]>
41
- </script>
42
-
43
- <div class="multiple-checkout">
44
- <div class="page-title">
45
- <h1><?php echo $this->__('Select Shipping Method') ?></h1>
46
- </div>
47
- <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
48
- <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="shipping_method_form">
49
- <?php foreach ($this->getAddresses() as $_index => $_address): ?>
50
- <div class="col2-set">
51
- <h2 class="legend"><?php echo $this->__('Address %s of %s', ($_index+1), $this->getAddressCount()) ?></h2>
52
- <div class="col-1 col-narrow">
53
- <div class="box">
54
- <div class="box-title">
55
- <h3><?php echo $this->__('Shipping To') ?> <span class="separator">|</span> <a href="<?php echo $this->getAddressEditUrl($_address) ?>"><?php echo $this->__('Change') ?></a></h3>
56
- </div>
57
- <div class="box-content">
58
- <address><?php echo $_address->format('html') ?></address>
59
- </div>
60
- </div>
61
- <div class="box box-sp-methods">
62
- <div class="pointer"></div>
63
- <div class="box-title">
64
- <h3><?php echo $this->__('Shipping Method') ?></h3>
65
- </div>
66
- <div class="box-content">
67
- <?php if (!($_shippingRateGroups = $this->getShippingRates($_address))): ?>
68
- <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
69
- <?php else: ?>
70
- <dl class="sp-methods">
71
- <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
72
- <dt><?php echo $this->getCarrierName($code) ?></dt>
73
- <dd>
74
- <ul>
75
- <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
76
- <li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"' ?>>
77
- <?php if ($_rate->getErrorMessage()): ?>
78
- <?php echo $_rate->getCarrierTitle() ?>: <?php echo $_rate->getErrorMessage() ?>
79
- <?php else: ?>
80
- <?php /*if ($_sole) : ?>
81
- <span class="no-display"><input type="radio" name="shipping_method[<?php echo $_address->getId() ?>]" value="<?php echo $this->htmlEscape($_rate->getCode()) ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>" checked="checked"/></span>
82
- <?php else:*/ ?>
83
- <input type="radio" name="shipping_method[<?php echo $_address->getId() ?>]" value="<?php echo $this->htmlEscape($_rate->getCode()) ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod($_address)) echo ' checked="checked"' ?> class="radio" onclick="<?php if($code=="chronorelais"): ?>shippingMethod.getrelais('<?php echo $this->getUrl('checkout/multishipping/getMultiRelais')?>?zip=<?php echo $_address->getPostcode() ?>&index=<?php echo $_address->getId() ?>', <?php echo $_address->getId() ?>, '<?php echo $_address->getPostcode() ?> <?php echo $_address->getCity() ?>')<?php else: ?>shippingMethod.hiderelais(<?php echo $_address->getId() ?>)<?php endif; ?>" />
84
- <?php //endif; ?>
85
- <label for="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
86
- <?php $_excl = $this->getShippingPrice($_address, $_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
87
- <?php $_incl = $this->getShippingPrice($_address, $_rate->getPrice(), true); ?>
88
- <?php echo $_excl; ?>
89
- <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
90
- (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
91
- <?php endif; ?>
92
- </label>
93
- <?php endif ?>
94
- </li>
95
- <?php endforeach; ?>
96
- </ul>
97
- </dd>
98
- <?php endforeach; ?>
99
- </dl>
100
- <?php endif; ?>
101
- </div>
102
- </div>
103
- </div>
104
- <div class="col-2 col-wide">
105
- <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress_checkbox', $_address); ?>
106
- <h3><?php echo $this->__('Items') ?> <span class="separator">|</span> <a href="<?php echo $this->getItemsEditUrl($_address) ?>"><?php echo $this->__('Edit Items') ?></a></h3>
107
- <table class="data-table" id="shipping-table-<?php echo $_address->getId() ?>">
108
- <col />
109
- <col width="1" />
110
- <thead>
111
- <tr>
112
- <th><?php echo $this->__('Product Name') ?></th>
113
- <th class="a-center"><?php echo $this->__('Qty') ?></th>
114
- </tr>
115
- </thead>
116
- <tbody>
117
- <?php foreach ($this->getAddressItems($_address) as $_item): ?>
118
- <tr>
119
- <td>
120
- <?php echo $this->getItemHtml($_item->getQuoteItem()) ?>
121
- </td>
122
- <td class="a-center"><?php echo $_item->getQty() ?></td>
123
- </tr>
124
- <?php endforeach; ?>
125
- </tbody>
126
- </table>
127
- <script type="text/javascript">decorateTable('shipping-table-<?php echo $_address->getId() ?>')</script>
128
- <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress', $_address); ?>
129
- </div>
130
-
131
- <span style="display: none;" class="please-wait" id="loading-process"><img class="v-middle" title="<?php echo $this->__('Loading...')?>" alt="<?php echo $this->__('Loading...')?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>"> <?php echo $this->__('Loading...')?></span>
132
- <div id="checkout-shipping-method-chronorelais-load_<?php echo $_address->getId() ?>" class="chronorelais-list" style="clear: both;">
133
- <?php if($this->getAddressShippingMethod($_address)=="chronorelais_chronorelais"): ?>
134
- <?php Mage::getSingleton('core/session')->setMultiPostcode($_address->getPostcode()); ?>
135
- <?php echo $this->getChildHtml('relaislist') ?>
136
- <?php endif; ?>
137
- </div>
138
- </div>
139
- <?php endforeach; ?>
140
- <?php echo $this->getChildHtml('checkout_billing_items') ?>
141
- <div class="buttons-set">
142
- <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back to Select Addresses') ?></a></p>
143
- <button type="submit" title="<?php echo $this->__('Continue to Billing Information') ?>" class="button"><span><span><?php echo $this->__('Continue to Billing Information') ?></span></span></button>
144
- </div>
145
- </form>
146
-
147
- <script type="text/javascript">
148
- //<![CDATA[
149
- var shippingMethod = new MultiShippingMethod();
150
- //]]>
151
- </script>
152
- </div>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Multishipping checkout shipping template
30
+ *
31
+ * @see Mage_Checkout_Block_Multishipping_Shipping
32
+ */
33
+ ?>
34
+ <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=<?php echo Mage::helper('chronorelais')->getConfigurationGoogleMapAPIKey()?>" type="text/javascript"></script>
35
+ <script type="text/javascript" src="<?php echo $this->getSkinUrl('chronorelais/chronorelaismap.js') ?>"></script>
36
+ <script type="text/javascript">
37
+ //<![CDATA[
38
+ var Picto_Chrono_Relais = '<?php echo $this->getSkinUrl('chronorelais/Picto_Chrono_Relais.png')?>';
39
+ var Home_Chrono_Icon = '<?php echo $this->getSkinUrl('chronorelais/home.png')?>';
40
+ //]]>
41
+ </script>
42
+
43
+ <div class="multiple-checkout">
44
+ <div class="page-title">
45
+ <h1><?php echo $this->__('Select Shipping Method') ?></h1>
46
+ </div>
47
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
48
+ <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="shipping_method_form">
49
+ <?php foreach ($this->getAddresses() as $_index => $_address): ?>
50
+ <div class="col2-set">
51
+ <h2 class="legend"><?php echo $this->__('Address %s of %s', ($_index+1), $this->getAddressCount()) ?></h2>
52
+ <div class="col-1 col-narrow">
53
+ <div class="box">
54
+ <div class="box-title">
55
+ <h3><?php echo $this->__('Shipping To') ?> <span class="separator">|</span> <a href="<?php echo $this->getAddressEditUrl($_address) ?>"><?php echo $this->__('Change') ?></a></h3>
56
+ </div>
57
+ <div class="box-content">
58
+ <address><?php echo $_address->format('html') ?></address>
59
+ </div>
60
+ </div>
61
+ <div class="box box-sp-methods">
62
+ <div class="pointer"></div>
63
+ <div class="box-title">
64
+ <h3><?php echo $this->__('Shipping Method') ?></h3>
65
+ </div>
66
+ <div class="box-content">
67
+ <?php if (!($_shippingRateGroups = $this->getShippingRates($_address))): ?>
68
+ <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
69
+ <?php else: ?>
70
+ <dl class="sp-methods">
71
+ <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
72
+ <dt><?php echo $this->getCarrierName($code) ?></dt>
73
+ <dd>
74
+ <ul>
75
+ <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
76
+ <li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"' ?>>
77
+ <?php if ($_rate->getErrorMessage()): ?>
78
+ <?php echo $_rate->getCarrierTitle() ?>: <?php echo $_rate->getErrorMessage() ?>
79
+ <?php else: ?>
80
+ <?php /*if ($_sole) : ?>
81
+ <span class="no-display"><input type="radio" name="shipping_method[<?php echo $_address->getId() ?>]" value="<?php echo $this->htmlEscape($_rate->getCode()) ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>" checked="checked"/></span>
82
+ <?php else:*/ ?>
83
+ <input type="radio" name="shipping_method[<?php echo $_address->getId() ?>]" value="<?php echo $this->htmlEscape($_rate->getCode()) ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod($_address)) echo ' checked="checked"' ?> class="radio" onclick="<?php if($code=="chronorelais"): ?>shippingMethod.getrelais('<?php echo $this->getUrl('checkout/multishipping/getMultiRelais')?>?zip=<?php echo $_address->getPostcode() ?>&index=<?php echo $_address->getId() ?>', <?php echo $_address->getId() ?>, '<?php echo $_address->getPostcode() ?> <?php echo $_address->getCity() ?>')<?php else: ?>shippingMethod.hiderelais(<?php echo $_address->getId() ?>)<?php endif; ?>" />
84
+ <?php //endif; ?>
85
+ <label for="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
86
+ <?php $_excl = $this->getShippingPrice($_address, $_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
87
+ <?php $_incl = $this->getShippingPrice($_address, $_rate->getPrice(), true); ?>
88
+ <?php echo $_excl; ?>
89
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
90
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
91
+ <?php endif; ?>
92
+ </label>
93
+ <?php endif ?>
94
+ </li>
95
+ <?php endforeach; ?>
96
+ </ul>
97
+ </dd>
98
+ <?php endforeach; ?>
99
+ </dl>
100
+ <?php endif; ?>
101
+ </div>
102
+ </div>
103
+ </div>
104
+ <div class="col-2 col-wide">
105
+ <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress_checkbox', $_address); ?>
106
+ <h3><?php echo $this->__('Items') ?> <span class="separator">|</span> <a href="<?php echo $this->getItemsEditUrl($_address) ?>"><?php echo $this->__('Edit Items') ?></a></h3>
107
+ <table class="data-table" id="shipping-table-<?php echo $_address->getId() ?>">
108
+ <col />
109
+ <col width="1" />
110
+ <thead>
111
+ <tr>
112
+ <th><?php echo $this->__('Product Name') ?></th>
113
+ <th class="a-center"><?php echo $this->__('Qty') ?></th>
114
+ </tr>
115
+ </thead>
116
+ <tbody>
117
+ <?php foreach ($this->getAddressItems($_address) as $_item): ?>
118
+ <tr>
119
+ <td>
120
+ <?php echo $this->getItemHtml($_item->getQuoteItem()) ?>
121
+ </td>
122
+ <td class="a-center"><?php echo $_item->getQty() ?></td>
123
+ </tr>
124
+ <?php endforeach; ?>
125
+ </tbody>
126
+ </table>
127
+ <script type="text/javascript">decorateTable('shipping-table-<?php echo $_address->getId() ?>')</script>
128
+ <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress', $_address); ?>
129
+ </div>
130
+
131
+ <span style="display: none;" class="please-wait" id="loading-process"><img class="v-middle" title="<?php echo $this->__('Loading...')?>" alt="<?php echo $this->__('Loading...')?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>"> <?php echo $this->__('Loading...')?></span>
132
+ <div id="checkout-shipping-method-chronorelais-load_<?php echo $_address->getId() ?>" class="chronorelais-list" style="clear: both;">
133
+ <?php if($this->getAddressShippingMethod($_address)=="chronorelais_chronorelais"): ?>
134
+ <?php Mage::getSingleton('core/session')->setMultiPostcode($_address->getPostcode()); ?>
135
+ <?php echo $this->getChildHtml('relaislist') ?>
136
+ <?php endif; ?>
137
+ </div>
138
+ </div>
139
+ <?php endforeach; ?>
140
+ <?php echo $this->getChildHtml('checkout_billing_items') ?>
141
+ <div class="buttons-set">
142
+ <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back to Select Addresses') ?></a></p>
143
+ <button type="submit" title="<?php echo $this->__('Continue to Billing Information') ?>" class="button"><span><span><?php echo $this->__('Continue to Billing Information') ?></span></span></button>
144
+ </div>
145
+ </form>
146
+
147
+ <script type="text/javascript">
148
+ //<![CDATA[
149
+ var shippingMethod = new MultiShippingMethod();
150
+ //]]>
151
+ </script>
152
+ </div>
app/design/frontend/{default → base}/default/template/chronorelais/checkout/multishipping/shipping_method/chronorelais.phtml RENAMED
@@ -1,30 +1,30 @@
1
- <?php if(count($this->getChronorelais())>0): ?>
2
- <?php
3
- $postcode = Mage::getSingleton('core/session')->getMultiPostcode();
4
- ?>
5
- <div class="chronorelaismap">
6
- <div class="mappostalcode">
7
- <form id="mappostalcodeform_%%id%%" onsubmit="return false;" action="#">
8
- <input type="text" name="mappostalcode[%%id%%]" id="mappostalcode_%%id%%" value="<?php echo $postcode ?>" class="input-text" onkeyup="if (event.keyCode == 13) shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/multishipping/getMultiRelais')?>?index=%%id%%', %%id%%)" />
9
- <button onclick="shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/multishipping/getMultiRelais')?>?index=%%id%%', %%id%%);" id="mappostalcodebtn_%%id%%" class="button" type="button"><span><span><?php echo $this->__('Changer mon code postal')?></span></span></button>
10
- <span style="display: none;" class="please-wait" id="postalcode-please-wait_%%id%%"><img class="v-middle" title="<?php echo $this->__('Loading map...')?>" alt="<?php echo $this->__('Loading map...')?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>"> <?php echo $this->__('Loading map...')?></span>
11
- </form>
12
- </div>
13
- <div id="chronomap_%%id%%" class="chronomap"></div>
14
- </div>
15
- <p style="margin: 0;"><?php echo $this->__('Veuillez choisir parmi les 5 relais Pickup affich&eacute;s ci-dessous celui qui servira d\'adresse de livraison.')?></p>
16
- <dl class="sp-methods-chronorelais">
17
- <dt><?php echo $this->__('Chronorelay points')?></dt>
18
- <dd>
19
- <ul>
20
- <?php foreach($this->getChronorelais() as $key=>$chronorelais): ?>
21
- <li>
22
- <input name="shipping_method_chronorelais[%%id%%]" type="radio" value="<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" id="s_method_chronorelais_%%id%%_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" class="radio" onclick="loadMyPoint('<?php echo $chronorelais->identifiantChronopostPointA2PAS;//$key?>')" />
23
- <label for="s_method_chronorelais_%%id%%_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>"><?php echo $chronorelais->nomEnseigne.' - '.$chronorelais->adresse1.' - '.$chronorelais->codePostal.' - '.$chronorelais->localite;?></label>
24
- </li>
25
- <?php endforeach; ?>
26
- </ul>
27
- </dd>
28
- </dl>
29
-
30
  <?php endif; ?>
1
+ <?php if(count($this->getChronorelais())>0): ?>
2
+ <?php
3
+ $postcode = Mage::getSingleton('core/session')->getMultiPostcode();
4
+ ?>
5
+ <div class="chronorelaismap">
6
+ <div class="mappostalcode">
7
+ <form id="mappostalcodeform_%%id%%" onsubmit="return false;" action="#">
8
+ <input type="text" name="mappostalcode[%%id%%]" id="mappostalcode_%%id%%" value="<?php echo $postcode ?>" class="input-text" onkeyup="if (event.keyCode == 13) shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/multishipping/getMultiRelais')?>?index=%%id%%', %%id%%)" />
9
+ <button onclick="shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/multishipping/getMultiRelais')?>?index=%%id%%', %%id%%);" id="mappostalcodebtn_%%id%%" class="button" type="button"><span><span><?php echo $this->__('Changer mon code postal')?></span></span></button>
10
+ <span style="display: none;" class="please-wait" id="postalcode-please-wait_%%id%%"><img class="v-middle" title="<?php echo $this->__('Loading map...')?>" alt="<?php echo $this->__('Loading map...')?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>"> <?php echo $this->__('Loading map...')?></span>
11
+ </form>
12
+ </div>
13
+ <div id="chronomap_%%id%%" class="chronomap"></div>
14
+ </div>
15
+ <p style="margin: 0;"><?php echo $this->__('Veuillez choisir parmi les 5 relais Pickup affich&eacute;s ci-dessous celui qui servira d\'adresse de livraison.')?></p>
16
+ <dl class="sp-methods-chronorelais">
17
+ <dt><?php echo $this->__('Chronorelay points')?></dt>
18
+ <dd>
19
+ <ul>
20
+ <?php foreach($this->getChronorelais() as $key=>$chronorelais): ?>
21
+ <li>
22
+ <input name="shipping_method_chronorelais[%%id%%]" type="radio" value="<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" id="s_method_chronorelais_%%id%%_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" class="radio" onclick="loadMyPoint('<?php echo $chronorelais->identifiantChronopostPointA2PAS;//$key?>')" />
23
+ <label for="s_method_chronorelais_%%id%%_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>"><?php echo $chronorelais->nomEnseigne.' - '.$chronorelais->adresse1.' - '.$chronorelais->codePostal.' - '.$chronorelais->localite;?></label>
24
+ </li>
25
+ <?php endforeach; ?>
26
+ </ul>
27
+ </dd>
28
+ </dl>
29
+
30
  <?php endif; ?>
app/design/frontend/{default → base}/default/template/chronorelais/checkout/onepage/shipping_method.phtml RENAMED
@@ -1,93 +1,108 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-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@magentocommerce.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.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php $isSoColissimoSimplicite = Mage::getConfig()->getModuleConfig('LaPoste_SoColissimoSimplicite')->is('active'); ?>
28
-
29
- <script src="http://maps.googleapis.com/maps/api/js?sensor=false<?php if (Mage::helper('chronorelais')->getConfigurationGoogleMapAPIKey()): ?>&amp;key=<?php echo Mage::helper('chronorelais')->getConfigurationGoogleMapAPIKey() ?><?php endif; ?>" type="text/javascript"></script>
30
- <script type="text/javascript" src="<?php echo $this->getSkinUrl('chronorelais/chronorelaismap.js') ?>"></script>
31
- <script type="text/javascript">
32
- //<![CDATA[
33
- var Picto_Chrono_Relais = '<?php echo $this->getSkinUrl('chronorelais/Picto_Chrono_Relais.png')?>';
34
- var Home_Chrono_Icon = '<?php echo $this->getSkinUrl('chronorelais/home.png')?>';
35
- //]]>
36
- </script>
37
- <form id="co-shipping-method-form" action="">
38
- <div id="checkout-shipping-method-load">
39
- <?php echo $this->getChildHtml('available') ?>
40
- </div>
41
- <?php if(!empty($isSoColissimoSimplicite)) : ?>
42
- <?php $_helper = Mage::helper('socolissimosimplicite'); ?>
43
- <script type="text/javascript">
44
- //<![CDATA[
45
- // update method save to redirect onSuccess to method which deals with colissimo choice
46
- ShippingMethod.prototype.saveWithColissimo = function(){
47
- if (checkout.loadWaiting!=false) return;
48
- if (this.validate()) {
49
- checkout.setLoadWaiting('shipping-method');
50
- var request = new Ajax.Request(
51
- this.saveUrl,
52
- {
53
- method:'post',
54
- onComplete: this.onComplete,
55
- onSuccess: this.redirectToColissimo,
56
- onFailure: checkout.ajaxFailure.bind(checkout),
57
- parameters: Form.serialize(this.form)
58
- }
59
- );
60
- }
61
- };
62
- // check if colissimo is selected, then redirect on form which post data on this platform
63
- ShippingMethod.prototype.redirectToColissimo = function(transport){
64
- var rateCodeSoColissimoSimplicite = '<?php echo $_helper->getRateCode()?>';
65
- var urlFormSoColissimoSimplicite = '<?php echo $_helper->getFormUrl()?>';
66
- var methods = document.getElementsByName('shipping_method');
67
- for (var i=0; i<methods.length; i++) {
68
- if (methods[i].value == rateCodeSoColissimoSimplicite && methods[i].checked) {
69
- window.location = urlFormSoColissimoSimplicite;
70
- }
71
- }
72
- // pass to next step (= default onSave binding
73
- ShippingMethod.prototype.nextStep(transport);
74
- };
75
- //]]>
76
- </script>
77
- <?php endif; ?>
78
- <script type="text/javascript">
79
- //<![CDATA[
80
- var shippingMethod = new ShippingMethod('co-shipping-method-form', "<?php echo $this->getUrl('checkout/onepage/saveShippingMethod') ?>");
81
- //]]>
82
- </script>
83
- <div id="onepage-checkout-shipping-method-additional-load">
84
- <?php echo $this->getChildHtml('additional') ?>
85
- </div>
86
- <div class="buttons-set" id="shipping-method-buttons-container">
87
- <p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
88
- <button type="button" class="button" onclick=" <?php if(!empty($isSoColissimoSimplicite)) : ?>shippingMethod.saveWithColissimo()<?php else: ?>shippingMethod.save()<?php endif;?>"><span><span><?php echo $this->__('Continue') ?></span></span></button>
89
- <span id="shipping-method-please-wait" class="please-wait" style="display:none;">
90
- <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
91
- </span>
92
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  </form>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php $isSoColissimoSimplicite = Mage::getConfig()->getModuleConfig('LaPoste_SoColissimoSimplicite')->is('active'); ?>
28
+
29
+ <script src="//maps.googleapis.com/maps/api/js?v=3.17&sensor=false<?php if (Mage::helper('chronorelais')->getConfigurationGoogleMapAPIKey()): ?>&amp;key=<?php echo Mage::helper('chronorelais')->getConfigurationGoogleMapAPIKey() ?><?php endif; ?>" type="text/javascript"></script>
30
+ <script type="text/javascript" src="<?php echo $this->getSkinUrl('chronorelais/chronorelaismap.js') ?>"></script>
31
+ <script type="text/javascript">
32
+ //<![CDATA[
33
+ var Picto_Chrono_Relais = '<?php echo $this->getSkinUrl('chronorelais/Picto_Chrono_Relais.png')?>';
34
+ var Home_Chrono_Icon = '<?php echo $this->getSkinUrl('chronorelais/home.png')?>';
35
+ //]]>
36
+ </script>
37
+ <form id="co-shipping-method-form" action="">
38
+ <div id="checkout-shipping-method-load">
39
+ <?php echo $this->getChildHtml('available') ?>
40
+ </div>
41
+
42
+ <script type="text/javascript">
43
+ /* add click event on shipping methods */
44
+
45
+ $('checkout-shipping-method-load').on('click', 'input[name=shipping_method]', function(event, element) {
46
+ var shippingMethodSelected = element.value;
47
+ if(shippingMethodSelected=="chronorelais_chronorelais") {
48
+ shippingMethod.getrelais('<?php echo $this->getUrl("checkout/onepage/getRelais")?>');
49
+ } else {
50
+ shippingMethod.hiderelais();
51
+ }
52
+ });
53
+
54
+ </script>
55
+
56
+ <?php if(!empty($isSoColissimoSimplicite)) : ?>
57
+ <?php $_helper = Mage::helper('socolissimosimplicite'); ?>
58
+ <script type="text/javascript">
59
+ //<![CDATA[
60
+ // update method save to redirect onSuccess to method which deals with colissimo choice
61
+ ShippingMethod.prototype.saveWithColissimo = function(){
62
+ if (checkout.loadWaiting!=false) return;
63
+ if (this.validate()) {
64
+ checkout.setLoadWaiting('shipping-method');
65
+ var request = new Ajax.Request(
66
+ this.saveUrl,
67
+ {
68
+ method:'post',
69
+ onComplete: this.onComplete,
70
+ onSuccess: this.redirectToColissimo,
71
+ onFailure: checkout.ajaxFailure.bind(checkout),
72
+ parameters: Form.serialize(this.form)
73
+ }
74
+ );
75
+ }
76
+ };
77
+ // check if colissimo is selected, then redirect on form which post data on this platform
78
+ ShippingMethod.prototype.redirectToColissimo = function(transport){
79
+ var rateCodeSoColissimoSimplicite = '<?php echo $_helper->getRateCode()?>';
80
+ var urlFormSoColissimoSimplicite = '<?php echo $_helper->getFormUrl()?>';
81
+ var methods = document.getElementsByName('shipping_method');
82
+ for (var i=0; i<methods.length; i++) {
83
+ if (methods[i].value == rateCodeSoColissimoSimplicite && methods[i].checked) {
84
+ window.location = urlFormSoColissimoSimplicite;
85
+ }
86
+ }
87
+ // pass to next step (= default onSave binding
88
+ ShippingMethod.prototype.nextStep(transport);
89
+ };
90
+ //]]>
91
+ </script>
92
+ <?php endif; ?>
93
+ <script type="text/javascript">
94
+ //<![CDATA[
95
+ var shippingMethod = new ShippingMethod('co-shipping-method-form', "<?php echo $this->getUrl('checkout/onepage/saveShippingMethod') ?>");
96
+ //]]>
97
+ </script>
98
+ <div id="onepage-checkout-shipping-method-additional-load">
99
+ <?php echo $this->getChildHtml('additional') ?>
100
+ </div>
101
+ <div class="buttons-set" id="shipping-method-buttons-container">
102
+ <p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
103
+ <button type="button" class="button" onclick=" <?php if(!empty($isSoColissimoSimplicite)) : ?>shippingMethod.saveWithColissimo()<?php else: ?>shippingMethod.save()<?php endif;?>"><span><span><?php echo $this->__('Continue') ?></span></span></button>
104
+ <span id="shipping-method-please-wait" class="please-wait" style="display:none;">
105
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
106
+ </span>
107
+ </div>
108
  </form>
app/design/frontend/{default → base}/default/template/chronorelais/checkout/onepage/shipping_method/available.phtml RENAMED
@@ -1,124 +1,124 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-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@magentocommerce.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.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
28
- <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
29
- <?php else: ?>
30
- <dl class="sp-methods">
31
- <?php $shippingCodePrice = array(); ?>
32
- <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
33
- <dt><?php echo $this->getCarrierName($code) ?></dt>
34
- <dd>
35
- <ul>
36
- <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
37
- <?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
38
- <li>
39
- <?php if ($_rate->getErrorMessage()): ?>
40
- <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
41
- <?php else: ?>
42
- <table>
43
- <tr><td class="method-radio">
44
- <?php /*if ($_sole) : ?>
45
- <span class="no-display"><input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" onclick="<?php if($code=="chronorelais"): ?>shippingMethod.getrelais('<?php echo $this->getUrl('checkout/onepage/getRelais')?>')<?php else: ?>shippingMethod.hiderelais()<?php endif; ?>" /></span>
46
- <?php else:*/ ?>
47
- <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php /*if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"'*/ ?> class="radio" onclick="<?php if($code=="chronorelais"): ?>shippingMethod.getrelais('<?php echo $this->getUrl('checkout/onepage/getRelais')?>')<?php else: ?>shippingMethod.hiderelais()<?php endif; ?>" />
48
- <?php //endif; ?>
49
- </td>
50
- <?php if(Mage::getStoreConfig('carriers/'.$code.'/logo_url')): ?>
51
- <td class="method-image"><img src="<?php echo $this->getSkinUrl("chronorelais/".Mage::getStoreConfig('carriers/'.$code.'/logo_url')); ?>" alt="" /></td>
52
- <?php endif; ?>
53
- <td class="method-contents">
54
- <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
55
- <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
56
- <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
57
- <?php echo $_excl; ?>
58
- <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
59
- (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
60
- <?php endif; ?>
61
- </label>
62
- <?php if($_rate->getMethodDescription()): ?>
63
- <div class="method-description">
64
- <?php echo $_rate->getMethodDescription()?>
65
- </div>
66
- <?php endif;?>
67
-
68
- <?php // disponibilit� de la plateforme soco ?>
69
- <?php if(Mage::getConfig()->getModuleConfig('LaPoste_SoColissimoSimplicite')->is('active')) : ?>
70
- <?php $helper = Mage::helper('socolissimosimplicite'); ?>
71
- <?php
72
- $serviceIsAvailable = true;
73
- if ($helper->getServiceIsAvailable() and $helper->getServiceIsAvailableUrl() != '') {
74
- $serviceIsAvailable = $helper->checkserviceAvailability();
75
- }
76
- ?>
77
- <?php if ($_rate->getCode() == 'socolissimosimplicite_socolissimosimplicite' and !$serviceIsAvailable): ?>
78
- <ul class="messages"><li class="error-msg"><ul><li><?php echo $helper->getServiceNotAvailableMessage(); ?></li></ul></li></ul>
79
- <?php endif ?>
80
- <?php endif; ?>
81
- </td>
82
- </tr>
83
- </table>
84
- <?php if($code=="chronorelais"): ?>
85
- <div id="checkout-shipping-method-chronorelais-load" class="chronorelais-list">
86
- <?php echo $this->getChildHtml('relaislist') ?>
87
- </div>
88
- <?php endif; ?>
89
- <?php endif ?>
90
- </li>
91
- <?php endforeach; ?>
92
- </ul>
93
- </dd>
94
- <?php endforeach; ?>
95
- </dl>
96
- <script type="text/javascript">
97
- //<![CDATA[
98
- <?php if (!empty($shippingCodePrice)): ?>
99
- var shippingCodePrice = {<?php echo implode(',',$shippingCodePrice); ?>};
100
- <?php endif; ?>
101
-
102
- $$('input[type="radio"][name="shipping_method"]').each(function(el){
103
- Event.observe(el, 'click', function(){
104
- if (el.checked == true) {
105
- var getShippingCode = el.getValue();
106
- <?php if (!empty($shippingCodePrice)): ?>
107
- var newPrice = shippingCodePrice[getShippingCode];
108
- if (!lastPrice) {
109
- lastPrice = newPrice;
110
- quoteBaseGrandTotal += newPrice;
111
- }
112
- if (newPrice != lastPrice) {
113
- quoteBaseGrandTotal += (newPrice-lastPrice);
114
- lastPrice = newPrice;
115
- }
116
- <?php endif; ?>
117
- checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
118
- return false;
119
- }
120
- });
121
- });
122
- //]]>
123
- </script>
124
  <?php endif; ?>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
28
+ <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
29
+ <?php else: ?>
30
+ <dl class="sp-methods">
31
+ <?php $shippingCodePrice = array(); ?>
32
+ <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
33
+ <dt><?php echo $this->getCarrierName($code) ?></dt>
34
+ <dd>
35
+ <ul>
36
+ <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
37
+ <?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
38
+ <li>
39
+ <?php if ($_rate->getErrorMessage()): ?>
40
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
41
+ <?php else: ?>
42
+ <table>
43
+ <tr><td class="method-radio" style="vertical-align: top;">
44
+ <?php /*if ($_sole) : ?>
45
+ <span class="no-display"><input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" onclick="<?php if($code=="chronorelais"): ?>shippingMethod.getrelais('<?php echo $this->getUrl('checkout/onepage/getRelais')?>')<?php else: ?>shippingMethod.hiderelais()<?php endif; ?>" /></span>
46
+ <?php else:*/ ?>
47
+ <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php /*if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"'*/ ?> class="radio" />
48
+ <?php //endif; ?>
49
+ </td>
50
+ <td class="method-contents">
51
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
52
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
53
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
54
+ <?php echo $_excl; ?>
55
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
56
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
57
+ <?php endif; ?>
58
+ </label>
59
+ <?php if($_rate->getMethodDescription()): ?>
60
+ <div class="method-description">
61
+ <?php if(Mage::getStoreConfig('carriers/'.$code.'/logo_url')): ?>
62
+ <img src="<?php echo $this->getSkinUrl("chronorelais/".Mage::getStoreConfig('carriers/'.$code.'/logo_url')); ?>" alt="" style="float: left; margin-right: 5px;" />
63
+ <?php endif; ?>
64
+ <?php echo $_rate->getMethodDescription()?>
65
+ </div>
66
+ <?php endif;?>
67
+
68
+ <?php // disponibilit� de la plateforme soco ?>
69
+ <?php if(Mage::getConfig()->getModuleConfig('LaPoste_SoColissimoSimplicite')->is('active')) : ?>
70
+ <?php $helper = Mage::helper('socolissimosimplicite'); ?>
71
+ <?php
72
+ $serviceIsAvailable = true;
73
+ if ($helper->getServiceIsAvailable() and $helper->getServiceIsAvailableUrl() != '') {
74
+ $serviceIsAvailable = $helper->checkserviceAvailability();
75
+ }
76
+ ?>
77
+ <?php if ($_rate->getCode() == 'socolissimosimplicite_socolissimosimplicite' and !$serviceIsAvailable): ?>
78
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $helper->getServiceNotAvailableMessage(); ?></li></ul></li></ul>
79
+ <?php endif ?>
80
+ <?php endif; ?>
81
+ </td>
82
+ </tr>
83
+ </table>
84
+ <?php if($code=="chronorelais"): ?>
85
+ <div id="checkout-shipping-method-chronorelais-load" class="chronorelais-list">
86
+ <?php echo $this->getChildHtml('relaislist') ?>
87
+ </div>
88
+ <?php endif; ?>
89
+ <?php endif ?>
90
+ </li>
91
+ <?php endforeach; ?>
92
+ </ul>
93
+ </dd>
94
+ <?php endforeach; ?>
95
+ </dl>
96
+ <script type="text/javascript">
97
+ //<![CDATA[
98
+ <?php if (!empty($shippingCodePrice)): ?>
99
+ var shippingCodePrice = {<?php echo implode(',',$shippingCodePrice); ?>};
100
+ <?php endif; ?>
101
+
102
+ $$('input[type="radio"][name="shipping_method"]').each(function(el){
103
+ Event.observe(el, 'click', function(){
104
+ if (el.checked == true) {
105
+ var getShippingCode = el.getValue();
106
+ <?php if (!empty($shippingCodePrice)): ?>
107
+ var newPrice = shippingCodePrice[getShippingCode];
108
+ if (!lastPrice) {
109
+ lastPrice = newPrice;
110
+ quoteBaseGrandTotal += newPrice;
111
+ }
112
+ if (newPrice != lastPrice) {
113
+ quoteBaseGrandTotal += (newPrice-lastPrice);
114
+ lastPrice = newPrice;
115
+ }
116
+ <?php endif; ?>
117
+ checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
118
+ return false;
119
+ }
120
+ });
121
+ });
122
+ //]]>
123
+ </script>
124
  <?php endif; ?>
app/design/frontend/{default → base}/default/template/chronorelais/checkout/onepage/shipping_method/chronorelais.phtml RENAMED
@@ -1,30 +1,37 @@
1
- <?php if(count($this->getChronorelais())>0): ?>
2
- <?php
3
- $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
4
- $address = $quote->getShippingAddress();
5
- $postcode = $address->getPostcode();
6
- ?>
7
- <div class="chronorelaismap">
8
- <div class="mappostalcode">
9
- <input type="text" name="mappostalcode" id="mappostalcode" value="<?php echo $postcode ?>" class="input-text" onkeydown="if (event.keyCode == 13) shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/onepage/changePostalCode')?>')" />
10
- <button onclick="shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/onepage/changePostalCode')?>');" id="mappostalcodebtn" class="button" type="button"><span><span><?php echo $this->__('Changer mon code postal')?></span></span></button>
11
- <span style="display: none;" class="please-wait" id="postalcode-please-wait"><img class="v-middle" title="<?php echo $this->__('Loading map...')?>" alt="<?php echo $this->__('Loading map...')?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>"> <?php echo $this->__('Loading map...')?></span>
12
- </div>
13
- <div id="chronomap" class="chronomap"></div>
14
- </div>
15
- <p style="margin: 0;"><?php echo $this->__('Veuillez choisir parmi les 5 relais Pickup affich&eacute;s ci-dessous celui qui servira d\'adresse de livraison.')?></p>
16
- <dl class="sp-methods-chronorelais">
17
- <dt><?php echo $this->__('Chronorelay points')?></dt>
18
- <dd>
19
- <ul>
20
- <?php foreach($this->getChronorelais() as $key=>$chronorelais): ?>
21
- <li>
22
- <input name="shipping_method_chronorelais" type="radio" value="<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" id="s_method_chronorelais_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" class="radio" onclick="loadMyPoint('<?php echo $chronorelais->identifiantChronopostPointA2PAS;//$key?>')" />
23
- <label for="s_method_chronorelais_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>"><?php echo $chronorelais->nomEnseigne.' - '.$chronorelais->adresse1.' - '.$chronorelais->codePostal.' - '.$chronorelais->localite;?></label>
24
- </li>
25
- <?php endforeach; ?>
26
- </ul>
27
- </dd>
28
- </dl>
29
-
 
 
 
 
 
 
 
30
  <?php endif; ?>
1
+ <?php if(count($this->getChronorelais())>0): ?>
2
+ <?php
3
+ $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
4
+ $address = $quote->getShippingAddress();
5
+ $postcode = $address->getPostcode();
6
+
7
+ $helperData = Mage::helper('chronorelais');
8
+ ?>
9
+ <div class="chronorelaismap">
10
+ <div class="mappostalcode">
11
+ <input type="text" name="mappostalcode" id="mappostalcode" value="<?php echo $postcode ?>" class="input-text" onkeydown="if (event.keyCode == 13) shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/onepage/changePostalCode')?>')" />
12
+ <button onclick="shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/onepage/changePostalCode')?>');" id="mappostalcodebtn" class="button" type="button"><span><span><?php echo $this->__('Changer mon code postal')?></span></span></button>
13
+ <span style="display: none;" class="please-wait" id="postalcode-please-wait"><img class="v-middle" title="<?php echo $this->__('Loading map...')?>" alt="<?php echo $this->__('Loading map...')?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>"> <?php echo $this->__('Loading map...')?></span>
14
+ </div>
15
+ <?php if($helperData->canShowGoogleMap()): ?>
16
+ <div id="chronomap" class="chronomap"></div>
17
+ <?php endif; ?>
18
+ </div>
19
+ <p style="margin: 0;"><?php echo $this->__('Veuillez choisir parmi les 5 relais Pickup affich&eacute;s ci-dessous celui qui servira d\'adresse de livraison.')?></p>
20
+ <dl class="sp-methods-chronorelais">
21
+ <dt><?php echo $this->__('Chronorelay points')?></dt>
22
+ <dd>
23
+ <ul>
24
+ <?php foreach($this->getChronorelais() as $key=>$chronorelais): ?>
25
+ <li>
26
+ <?php
27
+ $onClick = $helperData->canShowGoogleMap() ? "loadMyPoint('".$chronorelais->identifiantChronopostPointA2PAS."')" : ""; //$key
28
+ ?>
29
+ <input name="shipping_method_chronorelais" type="radio" value="<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" id="s_method_chronorelais_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" class="radio" onclick="<?php echo $onClick; ?>" />
30
+ <label for="s_method_chronorelais_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>"><?php echo $chronorelais->nomEnseigne.' - '.$chronorelais->adresse1.' - '.$chronorelais->codePostal.' - '.$chronorelais->localite;?></label>
31
+ </li>
32
+ <?php endforeach; ?>
33
+ </ul>
34
+ </dd>
35
+ </dl>
36
+
37
  <?php endif; ?>
app/design/frontend/{default → base}/default/template/chronorelais/sales/order/history.phtml RENAMED
@@ -1,80 +1,80 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-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@magentocommerce.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.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
28
- <?php $_orders = $this->getOrders(); ?>
29
- <div class="page-title">
30
- <h1><?php echo $this->__('My Orders') ?></h1>
31
- </div>
32
- <?php echo $this->getPagerHtml(); ?>
33
- <?php if($_orders->getSize()): ?>
34
- <table class="data-table" id="my-orders-table">
35
- <col width="1" />
36
- <col width="1" />
37
- <col />
38
- <col width="1" />
39
- <col width="1" />
40
- <col width="1" />
41
- <thead>
42
- <tr>
43
- <th><?php echo $this->__('Order #') ?></th>
44
- <th><?php echo $this->__('Date') ?></th>
45
- <th><?php echo $this->__('Ship To') ?></th>
46
- <th><span class="nobr"><?php echo $this->__('Order Total') ?></span></th>
47
- <th><span class="nobr"><?php echo $this->__('Order Status') ?></span></th>
48
- <th>&nbsp;</th>
49
- </tr>
50
- </thead>
51
- <tbody>
52
- <?php $_odd = ''; ?>
53
- <?php foreach ($_orders as $_order): ?>
54
- <tr>
55
- <td><?php echo $_order->getRealOrderId() ?></td>
56
- <td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
57
- <td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
58
- <td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
59
- <td><em><?php echo $_order->getStatusLabel() ?></em></td>
60
- <td class="a-center">
61
- <span class="nobr"><a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>
62
- <?php /*<span class="separator">|</span><a href="<?php echo $this->getTrackUrl($_order) ?>"><?php echo $this->__('Track Order') ?></a>&nbsp;*/ ?>
63
- <?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
64
- <span class="separator">|</span> <a href="<?php echo $this->getReorderUrl($_order) ?>" class="link-reorder"><?php echo $this->__('Reorder') ?></a>
65
- <?php endif ?>
66
- </span>
67
- <br />
68
- <?php if ($_order->getTracksCollection()->count()) : ?>
69
- <a href="#" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','top=50,left=50,width=800,height=600,resizable=yes,scrollbars=yes'); return false;" title="<?php echo $this->__('Track Your Order') ?>"><?php echo $this->__('Track Your Order') ?></a>
70
- <?php endif; ?>
71
- </td>
72
- </tr>
73
- <?php endforeach; ?>
74
- </tbody>
75
- </table>
76
- <script type="text/javascript">decorateTable('my-orders-table');</script>
77
- <?php echo $this->getPagerHtml(); ?>
78
- <?php else: ?>
79
- <p><?php echo $this->__('You have placed no orders.'); ?></p>
80
- <?php endif ?>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
28
+ <?php $_orders = $this->getOrders(); ?>
29
+ <div class="page-title">
30
+ <h1><?php echo $this->__('My Orders') ?></h1>
31
+ </div>
32
+ <?php echo $this->getPagerHtml(); ?>
33
+ <?php if($_orders->getSize()): ?>
34
+ <table class="data-table" id="my-orders-table">
35
+ <col width="1" />
36
+ <col width="1" />
37
+ <col />
38
+ <col width="1" />
39
+ <col width="1" />
40
+ <col width="1" />
41
+ <thead>
42
+ <tr>
43
+ <th><?php echo $this->__('Order #') ?></th>
44
+ <th><?php echo $this->__('Date') ?></th>
45
+ <th><?php echo $this->__('Ship To') ?></th>
46
+ <th><span class="nobr"><?php echo $this->__('Order Total') ?></span></th>
47
+ <th><span class="nobr"><?php echo $this->__('Order Status') ?></span></th>
48
+ <th>&nbsp;</th>
49
+ </tr>
50
+ </thead>
51
+ <tbody>
52
+ <?php $_odd = ''; ?>
53
+ <?php foreach ($_orders as $_order): ?>
54
+ <tr>
55
+ <td><?php echo $_order->getRealOrderId() ?></td>
56
+ <td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
57
+ <td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
58
+ <td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
59
+ <td><em><?php echo $_order->getStatusLabel() ?></em></td>
60
+ <td class="a-center">
61
+ <span class="nobr"><a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>
62
+ <?php /*<span class="separator">|</span><a href="<?php echo $this->getTrackUrl($_order) ?>"><?php echo $this->__('Track Order') ?></a>&nbsp;*/ ?>
63
+ <?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
64
+ <span class="separator">|</span> <a href="<?php echo $this->getReorderUrl($_order) ?>" class="link-reorder"><?php echo $this->__('Reorder') ?></a>
65
+ <?php endif ?>
66
+ </span>
67
+ <br />
68
+ <?php if ($_order->getTracksCollection()->count()) : ?>
69
+ <a href="#" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','top=50,left=50,width=800,height=600,resizable=yes,scrollbars=yes'); return false;" title="<?php echo $this->__('Track Your Order') ?>"><?php echo $this->__('Track Your Order') ?></a>
70
+ <?php endif; ?>
71
+ </td>
72
+ </tr>
73
+ <?php endforeach; ?>
74
+ </tbody>
75
+ </table>
76
+ <script type="text/javascript">decorateTable('my-orders-table');</script>
77
+ <?php echo $this->getPagerHtml(); ?>
78
+ <?php else: ?>
79
+ <p><?php echo $this->__('You have placed no orders.'); ?></p>
80
+ <?php endif ?>
app/design/frontend/{default → base}/default/template/chronorelais/sales/order/recent.phtml RENAMED
@@ -1,79 +1,79 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-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@magentocommerce.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.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <div class="box-account box-recent">
28
- <?php $_orders = $this->getOrders(); ?>
29
- <div class="box-head">
30
- <h2><?php echo $this->__('Recent Orders') ?></h2>
31
- <?php if( sizeof($_orders->getItems()) > 0 ): ?><a href="<?php echo $this->getUrl('sales/order/history') ?>"><?php echo $this->__('View All') ?></a><?php endif; ?>
32
- </div>
33
- <?php if( sizeof($_orders->getItems()) > 0 ): ?>
34
- <table class="data-table" id="my-orders-table">
35
- <col width="1" />
36
- <col width="1" />
37
- <col />
38
- <col width="1" />
39
- <col width="1" />
40
- <col width="1" />
41
- <thead>
42
- <tr>
43
- <th><?php echo $this->__('Order #') ?></th>
44
- <th><?php echo $this->__('Date') ?></th>
45
- <th><?php echo $this->__('Ship To') ?></th>
46
- <th><span class="nobr"><?php echo $this->__('Order Total') ?></span></th>
47
- <th><?php echo $this->__('Status') ?></th>
48
- <th>&nbsp;</th>
49
- </tr>
50
- </thead>
51
- <tbody>
52
- <?php foreach ($_orders as $_order): ?>
53
- <tr>
54
- <td><?php echo $_order->getRealOrderId() ?></td>
55
- <td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
56
- <td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
57
- <td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
58
- <td><em><?php echo $_order->getStatusLabel() ?></em></td>
59
- <td class="a-center">
60
- <span class="nobr">
61
- <a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>
62
- <?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
63
- <span class="separator">|</span> <a href="<?php echo $this->getReorderUrl($_order) ?>" class="link-reorder"><?php echo $this->__('Reorder') ?></a>
64
- <?php endif ?>
65
- </span>
66
- <br />
67
- <?php if ($_order->getTracksCollection()->count()) : ?>
68
- <a href="#" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','top=50,left=50,width=800,height=600,resizable=yes,scrollbars=yes'); return false;" title="<?php echo $this->__('Track Your Order') ?>"><?php echo $this->__('Track Your Order') ?></a>
69
- <?php endif; ?>
70
- </td>
71
- </tr>
72
- <?php endforeach; ?>
73
- </tbody>
74
- </table>
75
- <script type="text/javascript">decorateTable('my-orders-table')</script>
76
- <?php else: ?>
77
- <p><?php echo $this->__('You have placed no orders.'); ?></p>
78
- <?php endif; ?>
79
- </div>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div class="box-account box-recent">
28
+ <?php $_orders = $this->getOrders(); ?>
29
+ <div class="box-head">
30
+ <h2><?php echo $this->__('Recent Orders') ?></h2>
31
+ <?php if( sizeof($_orders->getItems()) > 0 ): ?><a href="<?php echo $this->getUrl('sales/order/history') ?>"><?php echo $this->__('View All') ?></a><?php endif; ?>
32
+ </div>
33
+ <?php if( sizeof($_orders->getItems()) > 0 ): ?>
34
+ <table class="data-table" id="my-orders-table">
35
+ <col width="1" />
36
+ <col width="1" />
37
+ <col />
38
+ <col width="1" />
39
+ <col width="1" />
40
+ <col width="1" />
41
+ <thead>
42
+ <tr>
43
+ <th><?php echo $this->__('Order #') ?></th>
44
+ <th><?php echo $this->__('Date') ?></th>
45
+ <th><?php echo $this->__('Ship To') ?></th>
46
+ <th><span class="nobr"><?php echo $this->__('Order Total') ?></span></th>
47
+ <th><?php echo $this->__('Status') ?></th>
48
+ <th>&nbsp;</th>
49
+ </tr>
50
+ </thead>
51
+ <tbody>
52
+ <?php foreach ($_orders as $_order): ?>
53
+ <tr>
54
+ <td><?php echo $_order->getRealOrderId() ?></td>
55
+ <td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
56
+ <td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
57
+ <td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
58
+ <td><em><?php echo $_order->getStatusLabel() ?></em></td>
59
+ <td class="a-center">
60
+ <span class="nobr">
61
+ <a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>
62
+ <?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
63
+ <span class="separator">|</span> <a href="<?php echo $this->getReorderUrl($_order) ?>" class="link-reorder"><?php echo $this->__('Reorder') ?></a>
64
+ <?php endif ?>
65
+ </span>
66
+ <br />
67
+ <?php if ($_order->getTracksCollection()->count()) : ?>
68
+ <a href="#" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','top=50,left=50,width=800,height=600,resizable=yes,scrollbars=yes'); return false;" title="<?php echo $this->__('Track Your Order') ?>"><?php echo $this->__('Track Your Order') ?></a>
69
+ <?php endif; ?>
70
+ </td>
71
+ </tr>
72
+ <?php endforeach; ?>
73
+ </tbody>
74
+ </table>
75
+ <script type="text/javascript">decorateTable('my-orders-table')</script>
76
+ <?php else: ?>
77
+ <p><?php echo $this->__('You have placed no orders.'); ?></p>
78
+ <?php endif; ?>
79
+ </div>
app/locale/fr_FR/Chronopost_Chronorelais.csv CHANGED
@@ -29,6 +29,7 @@
29
  "Handling Fee","Frais de traitement"
30
  "Logo Url","Url du logo"
31
  "Weight Limit","Limite de poids"
 
32
  "Free Shipping on the Amount","Livraison gratuite fonction du montant"
33
  "Minimum Amount for Free Shipping","Montant minimum pour livraison gratuite"
34
  "Semicolon","Point virgule"
@@ -669,7 +670,7 @@ fees: <span class=""string"">""{{customVar code=my_var}}*5.00""</span>,<br/>
669
  &nbsp;&nbsp;&nbsp;conditions: <span class=""string"">""({cart.price_excluding_tax} &gt;= 10) and ({cart.price_excluding_tax} &lt; 50)""</span>,<br/>
670
  <br/>
671
  <br/>
672
- <span class=""comment""># Tranches de poids</span><br/>
673
  <br/>
674
  &nbsp;&nbsp;&nbsp;<span class=""comment""># De 0.5 exclu à 3 inclu</span><br/>
675
  &nbsp;&nbsp;&nbsp;conditions: <span class=""string"">""({cart.weight} &gt; 0.5) and ({cart.weight} &lt;= 3.0)""</span>,<br/>
@@ -687,7 +688,7 @@ fees: <span class=""string"">""{{customVar code=my_var}}*5.00""</span>,<br/>
687
  &nbsp;&nbsp;&nbsp;conditions: <span class=""string"">""!{free_shipping}""</span>,<br/>
688
  <br/>
689
  <br/>
690
- <span class=""comment""># Attribut ou option des produits</span><br/>
691
  <br/>
692
  &nbsp;&nbsp;&nbsp;<span class=""comment""># Si au moins un produit possède l'attribut 'color' égal à 'Bleu'</span><br/>
693
  &nbsp;&nbsp;&nbsp;conditions: <span class=""string"">""{count products where product.attribute.color=='Bleu'}&gt;1""</span>,<br/>
29
  "Handling Fee","Frais de traitement"
30
  "Logo Url","Url du logo"
31
  "Weight Limit","Limite de poids"
32
+ "Show Google Map","Afficher la carte google"
33
  "Free Shipping on the Amount","Livraison gratuite fonction du montant"
34
  "Minimum Amount for Free Shipping","Montant minimum pour livraison gratuite"
35
  "Semicolon","Point virgule"
670
  &nbsp;&nbsp;&nbsp;conditions: <span class=""string"">""({cart.price_excluding_tax} &gt;= 10) and ({cart.price_excluding_tax} &lt; 50)""</span>,<br/>
671
  <br/>
672
  <br/>
673
+ <span class=""comment""># Tranches de poids</span><br/>
674
  <br/>
675
  &nbsp;&nbsp;&nbsp;<span class=""comment""># De 0.5 exclu à 3 inclu</span><br/>
676
  &nbsp;&nbsp;&nbsp;conditions: <span class=""string"">""({cart.weight} &gt; 0.5) and ({cart.weight} &lt;= 3.0)""</span>,<br/>
688
  &nbsp;&nbsp;&nbsp;conditions: <span class=""string"">""!{free_shipping}""</span>,<br/>
689
  <br/>
690
  <br/>
691
+ <span class=""comment""># Attribut ou option des produits</span><br/>
692
  <br/>
693
  &nbsp;&nbsp;&nbsp;<span class=""comment""># Si au moins un produit possède l'attribut 'color' égal à 'Bleu'</span><br/>
694
  &nbsp;&nbsp;&nbsp;conditions: <span class=""string"">""{count products where product.attribute.color=='Bleu'}&gt;1""</span>,<br/>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Chronopost</name>
4
- <version>1.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -19,7 +19,7 @@ Afin de vous accompagner dans le d&#xE9;veloppement des sites e-marchands sur la
19
  Le calcul du co&#xFB;t du transport (via logiciel QuickCost)&#xD;
20
  Le suivi int&#xE9;gr&#xE9;&#xD;
21
  Le choix entre 3 solutions possibles d'&#xE9;tiquetage des envois selon les besoins de l'e-commer&#xE7;ant&#xD;
22
- Test&#xE9; et valid&#xE9; sur Magento 1.7.0&#xD;
23
  &#xD;
24
  --&gt; Un manuel d'installation est &#xE0; votre disposition sur Magento Connect afin de vous guider dans l'installation du module. (A lire imp&#xE9;rativement)&#xD;
25
  &#xD;
@@ -27,18 +27,22 @@ ATTENTION : Pour toute mise en production du module Chronopost, un contrat avec
27
  &#xD;
28
  R&#xE9;alisation Adexos&#xD;
29
  &#xD;
30
- Ce module est d&#xE9;vellop&#xE9; &#xE0; partir de l'extension Owebia Shipping 2</description>
31
- <notes>Version destin&#xE9;e &#xE0; Magento 1.6.X et sup&#xE9;rieures. Test&#xE9;e sur Magento 1.7.0.&#xD;
32
- ------------&#xD;
33
- Int&#xE9;gration de l'API Google Maps v3.&#xD;
34
- Ajout d'un exemple de configuration de tarifs sp&#xE9;cifiques pour la Corse.&#xD;
35
- Correction d'un bug qui passait les commandes en invit&#xE9; au lieu de cr&#xE9;er le compte pour un nouveau client.&#xD;
36
- Divers correctifs mineurs.&#xD;
 
 
 
 
37
  </notes>
38
  <authors><author><name>Benjamin GOSSELET</name><user>Chronopost</user><email>bgosselet@adexos.fr</email></author></authors>
39
- <date>2013-12-04</date>
40
- <time>09:44:41</time>
41
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="chronorelais"><dir name="bordereau"><file name="grid.phtml" hash="0eca2119f27219d6bb568c2d1f50dbaf"/></dir><dir name="config"><file name="checklogin.phtml" hash="5455c412136bb8aee5dc7376ec7db2e8"/></dir><dir name="import"><file name="form.phtml" hash="356aadf2bb0182b23f7af38888a0cd38"/></dir><file name="notification.phtml" hash="e706e5d080a768c30e399b0259bdeb6a"/><dir name="sales"><dir name="order"><dir name="view"><dir name="tab"><file name="info.phtml" hash="3c30b03519879b7ef0e5b37f44f4d823"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="chronorelais.xml" hash="98a5bb79ecf4b9924dc3157cdada3c67"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="chronorelais.xml" hash="940f6bbecfea90954bd6166cde50ad99"/></dir><dir name="template"><dir name="chronorelais"><dir name="checkout"><dir name="multishipping"><file name="shipping.phtml" hash="907963f1564fe4b8e54492d66bc69b4b"/><dir name="shipping_method"><file name="chronorelais.phtml" hash="6b5d24fc6b59bba4a18185e4d5df84a8"/></dir></dir><dir name="onepage"><dir name="shipping_method"><file name="available.phtml" hash="d0596b238d7daf5e858583add7da7b3f"/><file name="chronorelais.phtml" hash="061e1430d504c505ef6845d4435235af"/></dir><file name="shipping_method.phtml" hash="c218579e6c7f82921fd36a9a4d3a39af"/></dir></dir><dir name="sales"><dir name="order"><file name="history.phtml" hash="0fbf2362562fc2ee25d9843d1fc3ab3e"/><file name="recent.phtml" hash="2c9a57fd83862a931956a8e95a2d82bb"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Chronopost"><dir name="Chronorelais"><dir name="Block"><dir name="Adminhtml"><file name="Notification.php" hash="f8496d3e31ae22a567cabd35ad99f320"/><dir name="System"><dir name="Config"><file name="Checklogin.php" hash="163f40010cc47a564a7655ede95d73b0"/><dir name="Form"><dir name="Field"><file name="Config.php" hash="b38741ddd97fcae5dd276239fb3c6b70"/><file name="Enabled.php" hash="c04ab5ade5716bdb3da170961215d7bf"/></dir><file name="Fieldsetassurance.php" hash="b5dbc90058d4d2cd8365965e2a2dc821"/></dir></dir></dir></dir><dir name="Checkout"><dir name="Multishipping"><dir name="Shipping"><dir name="Method"><file name="Chronorelais.php" hash="867238885e2aee05a729ba2e8b6f5d51"/></dir></dir></dir><dir name="Onepage"><dir name="Shipping"><dir name="Method"><file name="Chronorelais.php" hash="2abbc99d42ac0b6d3c97a4de32130cd6"/></dir></dir></dir></dir><file name="Detail.php" hash="42437d3c2c262e10f62e7b83ad73ccad"/><dir name="Export"><dir name="Orders"><file name="Grid.php" hash="ff2868c86da4e6b7eaeb1aa0bf30487b"/></dir><file name="Orders.php" hash="9ada10bd85cb58122e722b3e82c71e37"/></dir><file name="Filter.php" hash="07712e19ee91e331e8e141d075a787a3"/><dir name="Import"><file name="Form.php" hash="56c6e3787c05e58d57b48ec4b1421468"/></dir><dir name="Sales"><dir name="Bordereau"><file name="Grid.php" hash="9448cd1620e69f11c6f21641a90a9902"/></dir><file name="Bordereau.php" hash="699028f61947ea13f6939c2d2e1be01d"/><file name="Impression.php" hash="619599b136b9cc49f01dba5b08ee8428"/><dir name="Order"><dir name="Shipment"><file name="View.php" hash="f5407d7d14aa59acb844479da5046900"/></dir></dir><dir name="Shipment"><dir name="Grid"><dir name="Renderer"><file name="Retoursav.php" hash="c3a1fb0229bc2a4fa4d24d5808f58114"/></dir></dir><file name="Grid.php" hash="b03748ccfa87407c6433f4c8921c53e4"/></dir></dir></dir><dir name="Controller"><file name="Abstract.php" hash="94680cd88c6af59764dedb613b08d5f6"/></dir><dir name="Helper"><file name="Data.php" hash="1d2dee890e665476c4810afc4d0dc98b"/><file name="Webservice.php" hash="edb401b16e629107b9a0bb1dacf9fb83"/></dir><dir name="Model"><dir name="Carrier"><file name="AbstractChronorelais.php" hash="f4957f6d660c4adb0328f9f2d73da1e2"/><file name="AbstractChronorelaisShipping.php" hash="7f02d9e251beb198cec128aaf59efcaf"/><file name="Chronoexpress.php" hash="bc867a6b98966ada549a0b81ec334b64"/><file name="Chronopost.php" hash="c4d4525447d2801d28d921eaedc35a9a"/><file name="ChronopostC10.php" hash="bb642a19103ce9a40ef1725fd5cf22bd"/><file name="ChronopostC18.php" hash="85419f76cf74e93d7385dd98c04587a7"/><file name="ChronopostCClassic.php" hash="2195866755728930b16695d06d06feb1"/><file name="Chronorelais.php" hash="5cfcb83c23d05585fdc50f8b2747fc40"/></dir><dir name="Config"><dir name="Source"><file name="Civility.php" hash="fe6ec6eebe6faffdd0bb65479d91cd5d"/><file name="EndOfLineCharacter.php" hash="3fe6b6069a9efdc29ad0d3f7d1cf4794"/><file name="FieldDelimiter.php" hash="3e023d40aeca50932e62ff97eed6317e"/><file name="FieldSeparator.php" hash="ce30c5974a893bd5467334d574dd578a"/><file name="FileCharset.php" hash="6cc4ebab95735bd121af16e0eedd90d6"/><file name="FileExtension.php" hash="597c3e78e7584bf7c4b7b2ebad6d2a65"/><file name="PrintMode.php" hash="67e8a6e98e12c7e72624ba5322076c00"/><file name="WeightUnit.php" hash="97ed82ddf61e05a094ba1a04982d0010"/></dir></dir><dir name="Sales"><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Shipping.php" hash="2e69db363011f84ef2cdb5d0e9d4c4df"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AjaxController.php" hash="bed16f4f85b7fadd6301962ddc6220d1"/><dir name="Checkout"><file name="MultishippingController.php" hash="5841817a54f05995454e4b0bbc792f4d"/><file name="OnepageController.php" hash="b70eea145708edc145858d7cf5fae091"/></dir><file name="ExportController.php" hash="95c2e7ced2aa718b6ed8140095bed4ff"/><file name="ImportController.php" hash="964bf705b593bede1fc3b93e02fb37f2"/><file name="RelaisController.php" hash="5d48155ddb7cc2d4effbbfdeb4f3946d"/><dir name="Sales"><file name="BordereauController.php" hash="1102091b04b0af8f0d88bb6888f5fffd"/><file name="ImpressionController.php" hash="1ce3e14175a18178f3553aa41154730d"/><dir name="Order"><file name="ShipmentController.php" hash="c29fa819dfef9be64404be682b86dd8a"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="d9da736b2ff001c09cf1c492a896b3e8"/><file name="system.xml" hash="c4cf1c01931456dfa97c87a32ff5ff36"/></dir><dir name="includes"><file name="ChronorelaisShippingHelper.php" hash="832b11c52bff65c0dfe69fd798f218ce"/><file name="countries.inc.php" hash="04ff96cd7f0b985c4dfda52b8609b9d5"/></dir><dir name="sql"><dir name="chronorelais_setup"><file name="mysql4-install-0.1.0.php" hash="c307802a7bd10c1ecce06799b04569c2"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="ea3358055a851a96b673c721202045be"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="961f41dc1012d0917504f9bb5f5d106c"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="b85470889421f652c3d01b96072f579c"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="def69d0ae26b0d130d2ce6e0838e5d7f"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Chronopost_Chronorelais.csv" hash="76475aa4fa500c135a666e47bab62ddf"/></dir><dir name="fr_FR"><file name="Chronopost_Chronorelais.csv" hash="3f383558f7019b884d9c01ceab372ce4"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="chronorelais"><file name="Logo-Chronopost.jpg" hash="cc1226ebcd7236ce021076657ac22265"/><file name="Picto_Chrono_Relais.png" hash="1ea0f0c410d237adf23d5905cd8431f5"/><file name="Thumbs.db" hash="2e16ed23c37d1aa29a6caf73f513a648"/><file name="ac.png" hash="0c04f70da35d43a2636cfbd6ad2b10d5"/><file name="chronopost.png" hash="51ec3f1b8f0c970749ff24000bf7c162"/><file name="chronorelais.css" hash="a8d0ec0c82669a100a8951b31e6604ea"/><file name="chronorelais.png" hash="b3a8e94469113e5814c268cc6de66a2e"/><file name="chronorelaismap.js" hash="eee78175275ed0545dcdc710186ddbef"/><file name="home.png" hash="7904b495e94047eb3406e260bc660cce"/><file name="ico_ac_shaded.gif" hash="e55d9b2071fb976cf5331b6273a40731"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="chronorelais"><file name="chronorelais.css" hash="0a50cd0eebbe49540ad32294b4ffa2bd"/><file name="picto.gif" hash="9b11332763c74ebe43a25f8329b5347b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="WSChronopost_Chronorelais.xml" hash="e614759d6b46c0c25f6c26d6e9dff45a"/></dir></target><target name="mage"><dir name="js"><dir name="chronopost"><dir name="chronorelais"><file name="chronorelais.js" hash="9c55c7a13327be44a8c4fde0f272fb35"/><file name="ocseditor.css" hash="1bfc847153768d6729cdad7cb1abe443"/><file name="ocseditor.js" hash="8b7f29ddf7faff2fd3a63af18ba666aa"/></dir></dir></dir></target></contents>
42
  <compatible/>
43
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
44
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Chronopost</name>
4
+ <version>1.0.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
19
  Le calcul du co&#xFB;t du transport (via logiciel QuickCost)&#xD;
20
  Le suivi int&#xE9;gr&#xE9;&#xD;
21
  Le choix entre 3 solutions possibles d'&#xE9;tiquetage des envois selon les besoins de l'e-commer&#xE7;ant&#xD;
22
+ Test&#xE9; et valid&#xE9; sur Magento 1.9.0&#xD;
23
  &#xD;
24
  --&gt; Un manuel d'installation est &#xE0; votre disposition sur Magento Connect afin de vous guider dans l'installation du module. (A lire imp&#xE9;rativement)&#xD;
25
  &#xD;
27
  &#xD;
28
  R&#xE9;alisation Adexos&#xD;
29
  &#xD;
30
+ Ce module est d&#xE9;velopp&#xE9; &#xE0; partir de l'extension Owebia Shipping 2</description>
31
+ <notes>Compatibilit&#xE9; 1.9 valid&#xE9;e, support du th&#xE8;me responsive par d&#xE9;faut de Magento 1.9&#xD;
32
+ D&#xE9;placement des templates et skin de default/default vers base/default pour qu'ils puissent &#xEA;tre pris en compte en cas de package / th&#xE8;me personnalis&#xE9; ; voir d&#xE9;tails ci-dessous&#xD;
33
+ Ajout de la fonctionnalit&#xE9; de d&#xE9;tection des conflits avec d'autres modules de transport&#xD;
34
+ Compatibilit&#xE9; HTTPS de l'appel au Google Maps&#xD;
35
+ Possibilit&#xE9; d'utiliser le module Chronorelais sans Google Maps&#xD;
36
+ Limitation de la version de Google Maps &#xE0; 3.17 pour pr&#xE9;venir d'une incompatibilit&#xE9; avec prototype 1.7 distribu&#xE9; par Magento&#xD;
37
+ Alerte back-office en cas de disponibilit&#xE9; d'une nouvelle version du module&#xD;
38
+ Remplacement des URLs de quickcost par d&#xE9;faut (http://wsshipping.chronopost.fr/wsQuickcost/services/ServiceQuickCost?wsdl =&gt; https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl)&#xD;
39
+ Adresse du point relais remplac&#xE9;e par celle du client pour les &#xE9;tiquettes de retour&#xD;
40
+ Correctifs mineurs (m&#xE9;thode Chronopost_Chronorelais_Helper_Webservice::getMethodIsAllowed, test de Ghostscript avec option '-v', suppression de 'Notices' PHP)&#xD;
41
  </notes>
42
  <authors><author><name>Benjamin GOSSELET</name><user>Chronopost</user><email>bgosselet@adexos.fr</email></author></authors>
43
+ <date>2014-12-22</date>
44
+ <time>10:00:07</time>
45
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="chronorelais"><dir name="bordereau"><file name="grid.phtml" hash="0eca2119f27219d6bb568c2d1f50dbaf"/></dir><dir name="config"><file name="checklogin.phtml" hash="5455c412136bb8aee5dc7376ec7db2e8"/></dir><dir name="import"><file name="form.phtml" hash="356aadf2bb0182b23f7af38888a0cd38"/></dir><file name="notification.phtml" hash="8bada98676c671f4937feb47b26c73fa"/><dir name="sales"><dir name="order"><dir name="view"><dir name="tab"><file name="info.phtml" hash="3c30b03519879b7ef0e5b37f44f4d823"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="chronorelais.xml" hash="98a5bb79ecf4b9924dc3157cdada3c67"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="chronorelais.xml" hash="c1ffe70e9836bd14e342d8c2c17c3b15"/></dir><dir name="template"><dir name="chronorelais"><dir name="checkout"><dir name="multishipping"><file name="shipping.phtml" hash="89ac65c42722975ec8b872a1e69b5ae9"/><dir name="shipping_method"><file name="chronorelais.phtml" hash="f184ce28e619c185434810545bc82d9f"/></dir></dir><dir name="onepage"><dir name="shipping_method"><file name="available.phtml" hash="6e432bb687e8384cd7a20d282368bbb6"/><file name="chronorelais.phtml" hash="a4b081aae173c01d21cf5b1e69afcbc1"/></dir><file name="shipping_method.phtml" hash="b2710ed8991a3d22bf743ce7a500e999"/></dir></dir><dir name="sales"><dir name="order"><file name="history.phtml" hash="67bfaad7cff5ab92b5bd1c00581c6a8f"/><file name="recent.phtml" hash="7288560d442eadf3d8c19a40f80a9765"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Chronopost"><dir name="Chronorelais"><dir name="Block"><dir name="Adminhtml"><file name="Notification.php" hash="7f8d18949d90c2a21d9b5b4fa28f3952"/><dir name="System"><dir name="Config"><file name="Checklogin.php" hash="163f40010cc47a564a7655ede95d73b0"/><dir name="Form"><dir name="Field"><file name="Config.php" hash="b38741ddd97fcae5dd276239fb3c6b70"/><file name="Enabled.php" hash="c04ab5ade5716bdb3da170961215d7bf"/></dir><file name="Fieldsetassurance.php" hash="b5dbc90058d4d2cd8365965e2a2dc821"/><file name="Fieldsetconflicts.php" hash="d7eef1a172e60d7212ed388b85a22574"/></dir></dir></dir></dir><dir name="Checkout"><dir name="Multishipping"><dir name="Shipping"><dir name="Method"><file name="Chronorelais.php" hash="867238885e2aee05a729ba2e8b6f5d51"/></dir></dir></dir><dir name="Onepage"><dir name="Shipping"><dir name="Method"><file name="Chronorelais.php" hash="2abbc99d42ac0b6d3c97a4de32130cd6"/></dir></dir></dir></dir><file name="Detail.php" hash="42437d3c2c262e10f62e7b83ad73ccad"/><dir name="Export"><dir name="Orders"><file name="Grid.php" hash="79c4b566772f3d2b21d712b963c34b48"/></dir><file name="Orders.php" hash="9ada10bd85cb58122e722b3e82c71e37"/></dir><file name="Filter.php" hash="07712e19ee91e331e8e141d075a787a3"/><dir name="Import"><file name="Form.php" hash="56c6e3787c05e58d57b48ec4b1421468"/></dir><dir name="Sales"><dir name="Bordereau"><file name="Grid.php" hash="70b124d41c6e8c7a4f02bc9b607c9ebb"/></dir><file name="Bordereau.php" hash="699028f61947ea13f6939c2d2e1be01d"/><file name="Impression.php" hash="619599b136b9cc49f01dba5b08ee8428"/><dir name="Order"><dir name="Shipment"><file name="View.php" hash="826e9972daef7b7d8e6d92ed83449aaf"/></dir></dir><dir name="Shipment"><dir name="Grid"><dir name="Renderer"><file name="Retoursav.php" hash="c3a1fb0229bc2a4fa4d24d5808f58114"/></dir></dir><file name="Grid.php" hash="542fc30fe5d9f299ac55519ce9359e8f"/></dir></dir></dir><dir name="Controller"><file name="Abstract.php" hash="94680cd88c6af59764dedb613b08d5f6"/></dir><dir name="Helper"><file name="Conflicts.php" hash="e34d9c718f4941df85d05f709baf1e11"/><file name="Data.php" hash="4a3b9a2df40170dc46e0b5583f4de21f"/><file name="Webservice.php" hash="53c94c2612ba43df05dd495bd7c89279"/></dir><dir name="Model"><dir name="Carrier"><file name="AbstractChronorelais.php" hash="f4957f6d660c4adb0328f9f2d73da1e2"/><file name="AbstractChronorelaisShipping.php" hash="487657a9d9e1bebba87b9bad313abde0"/><file name="Chronoexpress.php" hash="bc867a6b98966ada549a0b81ec334b64"/><file name="Chronopost.php" hash="c4d4525447d2801d28d921eaedc35a9a"/><file name="ChronopostC10.php" hash="bb642a19103ce9a40ef1725fd5cf22bd"/><file name="ChronopostC18.php" hash="85419f76cf74e93d7385dd98c04587a7"/><file name="ChronopostCClassic.php" hash="2195866755728930b16695d06d06feb1"/><file name="Chronorelais.php" hash="5cfcb83c23d05585fdc50f8b2747fc40"/></dir><dir name="Config"><dir name="Source"><file name="Civility.php" hash="fe6ec6eebe6faffdd0bb65479d91cd5d"/><file name="EndOfLineCharacter.php" hash="3fe6b6069a9efdc29ad0d3f7d1cf4794"/><file name="FieldDelimiter.php" hash="3e023d40aeca50932e62ff97eed6317e"/><file name="FieldSeparator.php" hash="ce30c5974a893bd5467334d574dd578a"/><file name="FileCharset.php" hash="6cc4ebab95735bd121af16e0eedd90d6"/><file name="FileExtension.php" hash="597c3e78e7584bf7c4b7b2ebad6d2a65"/><file name="PrintMode.php" hash="67e8a6e98e12c7e72624ba5322076c00"/><file name="WeightUnit.php" hash="97ed82ddf61e05a094ba1a04982d0010"/></dir></dir><dir name="Sales"><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Shipping.php" hash="fbc2d92286b2df2d2b8f35c018788f4a"/><file name="Shipping.toDel.php" hash="fbc2d92286b2df2d2b8f35c018788f4a"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AjaxController.php" hash="8f3ecaf7f50a06ffd167f1e4aea2763c"/><dir name="Checkout"><file name="MultishippingController.php" hash="5841817a54f05995454e4b0bbc792f4d"/><file name="OnepageController.php" hash="33e1e6eb3d145e4f0fd8b9e14a8bb076"/></dir><file name="ExportController.php" hash="cd56c718918c650c30a078e90dae0b9c"/><file name="ImportController.php" hash="964bf705b593bede1fc3b93e02fb37f2"/><file name="RelaisController.php" hash="5d48155ddb7cc2d4effbbfdeb4f3946d"/><dir name="Sales"><file name="BordereauController.php" hash="1102091b04b0af8f0d88bb6888f5fffd"/><file name="ImpressionController.php" hash="e1119e044e9521c956768da68bce1b31"/><dir name="Order"><file name="ShipmentController.php" hash="17a8ed4d056abb4d989502a6b5ed443d"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="2b17e21894eeda5c8a39dd45e67f4877"/><file name="system.xml" hash="6a2a5d899b4fe440ea04acf2e1551b8f"/></dir><dir name="includes"><file name="ChronorelaisShippingHelper.php" hash="8f94b3f4780a6d3211a934b5ebaa53c7"/><file name="countries.inc.php" hash="16888220015fbc818e273d0b64c99742"/></dir><dir name="sql"><dir name="chronorelais_setup"><file name="mysql4-install-0.1.0.php" hash="c307802a7bd10c1ecce06799b04569c2"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="ea3358055a851a96b673c721202045be"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="961f41dc1012d0917504f9bb5f5d106c"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="b85470889421f652c3d01b96072f579c"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="def69d0ae26b0d130d2ce6e0838e5d7f"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Chronopost_Chronorelais.csv" hash="76475aa4fa500c135a666e47bab62ddf"/></dir><dir name="fr_FR"><file name="Chronopost_Chronorelais.csv" hash="a842d358c8f3dcf5b397d0683ac03c38"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="chronorelais"><file name="Logo-Chronopost.jpg" hash="cc1226ebcd7236ce021076657ac22265"/><file name="Picto_Chrono_Relais.png" hash="1ea0f0c410d237adf23d5905cd8431f5"/><file name="ac.png" hash="0c04f70da35d43a2636cfbd6ad2b10d5"/><file name="chronopost.png" hash="51ec3f1b8f0c970749ff24000bf7c162"/><file name="chronorelais.css" hash="c76cc51ae175137605f532fcf6d16588"/><file name="chronorelais.png" hash="b3a8e94469113e5814c268cc6de66a2e"/><file name="chronorelaismap.js" hash="afb57f8faa01720aa64da585c62407d7"/><file name="home.png" hash="7904b495e94047eb3406e260bc660cce"/><file name="ico_ac_shaded.gif" hash="e55d9b2071fb976cf5331b6273a40731"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="chronorelais"><file name="chronorelais.css" hash="0a50cd0eebbe49540ad32294b4ffa2bd"/><file name="picto.gif" hash="9b11332763c74ebe43a25f8329b5347b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="WSChronopost_Chronorelais.xml" hash="e614759d6b46c0c25f6c26d6e9dff45a"/></dir></target><target name="mage"><dir name="js"><dir name="chronopost"><dir name="chronorelais"><file name="chronorelais.js" hash="9c55c7a13327be44a8c4fde0f272fb35"/><file name="ocseditor.css" hash="1bfc847153768d6729cdad7cb1abe443"/><file name="ocseditor.js" hash="8b7f29ddf7faff2fd3a63af18ba666aa"/></dir></dir></dir></target></contents>
46
  <compatible/>
47
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
48
  </package>
skin/frontend/{default → base}/default/chronorelais/Logo-Chronopost.jpg RENAMED
File without changes
skin/frontend/{default → base}/default/chronorelais/Picto_Chrono_Relais.png RENAMED
File without changes
skin/frontend/{default → base}/default/chronorelais/ac.png RENAMED
File without changes
skin/frontend/{default → base}/default/chronorelais/chronopost.png RENAMED
File without changes
skin/frontend/{default → base}/default/chronorelais/chronorelais.css RENAMED
@@ -1,46 +1,46 @@
1
- /* styles for chrono relais */
2
-
3
- .chronorelais-list { }
4
- .sp-methods-chronorelais { padding:5px 20px;}
5
- sp-methods-chronorelais dd li { clear:both;}
6
- .chronorelaismap { margin:20px 0px 10px 0px; }
7
- .chronorelaismap .mappostalcode { margin-bottom:10px; text-align:right;}
8
- .sp-methods .method-description { clear:both; }
9
- .sp-methods .method-radio, .sp-methods .method-image, .sp-methods .method-contents { }
10
- .sp-methods .method-image { padding:0 10px;}
11
-
12
- /*****************************
13
- sw-Gmap
14
- *******************************/
15
- .chronomap { height:450px; width:100%; overflow:hidden!mportant; font:82.5%/1.3 Arial,Helvetica,sans-serif; background-color: #E5E3DF; border: 1px solid #aaa;}
16
- .chronomap *{float:none;overflow:visible;font-family: Arial,sans-serif;}
17
- .chronomap a {color:#0000cc;outline:none;}
18
- .chronomap h4{font-size:14px;margin-bottom:6px;border-bottom:1px solid #ccc;}
19
- .chronomap h2{font-size:16px;margin:2px 10px 6px 0; font-weight:bold;}
20
-
21
- /*****************************
22
- Infowindow
23
- *******************************/
24
- .chronomap .sw-infowindow a{cursor:pointer;}
25
- #sw-infowindow-info{max-height:400px}
26
- #sw-infowindow-hor{height:150px}
27
- .sw-map-adresse-wrp{min-height:90px}
28
- .sw-map-adresse{font-size:1.2em;margin:5px 0 8px 0;line-height:1.45em;}
29
- .sw-map-tools a{font-size:12px;}
30
- .chronomap .sw-desc{display:block;font-weight:bold;line-height:16px;float:none!important;width:auto;}
31
- .chronomap .sw-help{display:block;float:none!important;width:auto;clear:both;}
32
- .sw-map-itin-tools{font-size:11px;padding:8px 0;display:block;}
33
- .sw-back-link{font-size:11px;display:block;text-align:right;margin:0px ;}
34
- #sw-sendbymail-wrap{height:220px;overflow:hidden;}
35
- .chronomap .sw-textarea{height:30px;}
36
- .sw-tool-itineraire{height:220px;}
37
- /*****************************
38
- Tables
39
- *******************************/
40
- .sw-table {border-collapse:collapse; width:100%;}
41
- .sw-table td {font-size:1.2em;border-bottom:1px solid #ccc; padding:1px 0px;}
42
- .sw-table th{background:#eee;font-size:1.3em;border-top:1px solid #555}
43
- #sw-table-horaire-client td ,#sw-table-horaire-depot td{width:50%;}
44
- #sw-table-horaire-client{}
45
- #sw-table-horaire-depot{margin-top:8px;}
46
- /*****************************
1
+ /* styles for chrono relais */
2
+
3
+ .chronorelais-list { }
4
+ .sp-methods-chronorelais { padding:5px 20px;}
5
+ sp-methods-chronorelais dd li { clear:both;}
6
+ .chronorelaismap { margin:20px 0px 10px 0px; }
7
+ .chronorelaismap .mappostalcode { margin-bottom:10px; text-align:right;}
8
+ .sp-methods .method-description { clear:both; }
9
+ .sp-methods .method-radio, .sp-methods .method-image, .sp-methods .method-contents { }
10
+ .sp-methods .method-image { padding:0 10px;}
11
+
12
+ /*****************************
13
+ sw-Gmap
14
+ *******************************/
15
+ .chronomap { height:450px; width:100%; overflow:hidden!mportant; font:82.5%/1.3 Arial,Helvetica,sans-serif; background-color: #E5E3DF; border: 1px solid #aaa;}
16
+ .chronomap *{float:none;overflow:visible;font-family: Arial,sans-serif;}
17
+ .chronomap a {color:#0000cc;outline:none;}
18
+ .chronomap h4{font-size:1em;margin-bottom:6px;border-bottom:1px solid #ccc;}
19
+ .chronomap h2{font-size:1em;margin:2px 10px 6px 0; font-weight:bold;}
20
+
21
+ /*****************************
22
+ Infowindow
23
+ *******************************/
24
+ .chronomap .sw-infowindow a{cursor:pointer;}
25
+ #sw-infowindow-info{max-height:400px}
26
+ #sw-infowindow-hor{height:150px}
27
+ .sw-map-adresse-wrp{min-height:90px}
28
+ .sw-map-adresse{font-size:1em;margin:5px 0 8px 0;line-height:1.45em;}
29
+ .sw-map-tools a{font-size:.9em;}
30
+ .chronomap .sw-desc{display:block;font-weight:bold;line-height:16px;float:none!important;width:auto;}
31
+ .chronomap .sw-help{display:block;float:none!important;width:auto;clear:both;}
32
+ .sw-map-itin-tools{font-size:.8em;padding:8px 0;display:block;}
33
+ .sw-back-link{font-size:.8em;display:block;text-align:right;margin:0px ;}
34
+ #sw-sendbymail-wrap{height:220px;overflow:hidden;}
35
+ .chronomap .sw-textarea{height:30px;}
36
+ .sw-tool-itineraire{height:220px;}
37
+ /*****************************
38
+ Tables
39
+ *******************************/
40
+ .sw-table {border-collapse:collapse; width:100%;}
41
+ .sw-table td {font-size:1em;border-bottom:1px solid #ccc; padding:1px 0px;}
42
+ .sw-table th{background:#eee;font-size:1em;border-top:1px solid #555}
43
+ #sw-table-horaire-client td ,#sw-table-horaire-depot td{width:50%;}
44
+ #sw-table-horaire-client{}
45
+ #sw-table-horaire-depot{margin-top:8px;}
46
+ /*****************************
skin/frontend/{default → base}/default/chronorelais/chronorelais.png RENAMED
File without changes
skin/frontend/{default → base}/default/chronorelais/chronorelaismap.js RENAMED
@@ -1,567 +1,574 @@
1
- var gmarkers = [];
2
- var map;
3
- var homeaddress = "";
4
- var addressrelais = [];
5
- var relaylatan = [];
6
- var next_pt = 0;
7
- var hidehomeicon = false;
8
- var currentInfoWindow;
9
-
10
- function loadMyPoint(i) {
11
- google.maps.event.trigger(gmarkers[i], "click");
12
- }
13
-
14
- var bounds = new google.maps.LatLngBounds();
15
- function loadRelayMap(address, relaisArray, nextpt, mapid) {
16
- var geo = new google.maps.Geocoder();
17
-
18
- var myOptions = {
19
- zoom: 5,
20
- center: new google.maps.LatLng(47.37285025362682, 2.4172996312499784),
21
- mapTypeId: google.maps.MapTypeId.ROADMAP
22
- }
23
- map = new google.maps.Map(document.getElementById(mapid), myOptions);
24
-
25
- var blueIcon = new google.maps.MarkerImage(Picto_Chrono_Relais);
26
-
27
- var homeIcon = new google.maps.MarkerImage(Home_Chrono_Icon);
28
-
29
- if(!homeaddress && !hidehomeicon) {
30
- var ship_address = getShipAddress(); //get shipping address to set home address
31
- homeaddress = relaisArray.codePostal + " " + relaisArray.localite;
32
- if(ship_address) { homeaddress = ship_address+" "+homeaddress; }
33
-
34
- geo.geocode({'address': homeaddress}, function(results, status) {
35
- if (status == google.maps.GeocoderStatus.OK) {
36
- var point = results[0].geometry.location;
37
- var marker = new google.maps.Marker({
38
- position: point,
39
- map: map,
40
- title: 'home',
41
- icon: homeIcon
42
- });
43
- map.setCenter(point, 11);
44
- }
45
- });
46
- }
47
-
48
- function createTabbedMarker(point, relaisArray) {
49
- addressrelais.push(relaisArray);
50
- var label = nextpt;
51
- var relaypoint_id = relaisArray.identifiantChronopostPointA2PAS;
52
- var marker = new google.maps.Marker({map: map, position: point, title:relaisArray.nomEnseigne, icon:blueIcon});
53
-
54
- var infowindow = new google.maps.InfoWindow({
55
- content: '<div style="width: 400px;"><div style="width: 190px; float: left;"><h2>Infos</h2>'+getMarkerInfoContent(relaisArray) + getActionsForm(addressrelais.length)+'</div><div style="margin-left: 10px; padding-left: 10px; border-left: 1px solid #000; float: left;"><h2>Horaires</h2><div style="width: 189px">'+getHorairesTab(relaisArray, true)+'</div></div></div>'
56
- });
57
-
58
- google.maps.event.addListener(marker, 'click', function() {
59
- if(document.getElementById('s_method_chronorelais_'+relaisArray.identifiantChronopostPointA2PAS))
60
- document.getElementById('s_method_chronorelais_'+relaisArray.identifiantChronopostPointA2PAS).checked = true;
61
-
62
- if (currentInfoWindow) {
63
- currentInfoWindow.close();
64
- }
65
- infowindow.open(map,marker);
66
- currentInfoWindow = infowindow;
67
- });
68
-
69
- gmarkers[relaypoint_id] = marker;
70
- return marker;
71
- }
72
-
73
- function showAddress(address, relaisArray) {
74
- var search = address;
75
- // ====== Perform the Geocoding ======
76
- geo.geocode({'address': search}, function(results, status)
77
- {
78
- // If that was successful
79
- if (status == google.maps.GeocoderStatus.OK) {
80
- // Loop through the results, placing markers
81
- //for (var i=0; i<result.Placemark.length; i++) {
82
- for (var i=0; i<1; i++) {
83
- var p = results[i].geometry.location;
84
- relaylatan.push(p);
85
- var marker = createTabbedMarker(p, relaisArray);
86
- // ==== Each time a point is found, extent the bounds ato include it =====
87
- bounds.extend(p);
88
- }
89
- // centre the map on the first result
90
- //!homeaddress && hidehomeicon &&
91
- if(nextpt==5) {
92
- var p = results[0].geometry.location;
93
- // ===== determine the zoom level from the bounds =====
94
- map.fitBounds(bounds);
95
- // ===== determine the centre from the bounds ======
96
- map.setCenter(bounds.getCenter());
97
- }
98
- }
99
- // ====== Decode the error status ======
100
- else {
101
- var reason = "Code " + status;
102
- /*
103
- if (reasons[status]) {
104
- reason = reasons[status]
105
- }
106
- */
107
- alert('Could not find "' + search + '" ' + reason);
108
- }
109
- });
110
- }
111
- showAddress(address, relaisArray);
112
- } // end of loadRelayMap function
113
-
114
- function addEvent( obj, type, fn ) {
115
- if ( obj.attachEvent ) {
116
- obj["e"+type+fn] = fn;
117
- obj[type+fn] = function() { obj["e"+type+fn]( window.event ) };
118
- obj.attachEvent( "on"+type, obj[type+fn] );
119
- }
120
- else{
121
- obj.addEventListener( type, fn, false );
122
- }
123
- }
124
-
125
- function getMarkerInfoContent(relaisArray){
126
- var icoPath = Picto_Chrono_Relais;
127
- var content="<div class=\"sw-map-adresse-wrp\" style=\"background-image: url("+ icoPath +"); background-repeat: no-repeat;padding-left:50px;\">"
128
- + "<h2>"+relaisArray.nomEnseigne+"</h2>"
129
- + "<div class=\"sw-map-adresse\">"
130
- + parseAdresse(relaisArray)
131
- + relaisArray.codePostal + " " + relaisArray.localite
132
- + "</div></div>";
133
- return content;
134
- }
135
- function getActionsForm(label)
136
- {
137
- var html = '<div class="sw-map-tools"><a href="javascript:printPage('+label+')">Imprimer</a>'
138
- + '</div>';
139
- return html;
140
- }
141
-
142
- function getHorairesTab(anArray, highlight)
143
- {
144
- var userAgent = navigator.userAgent.toLowerCase();
145
- var msie = /msie/.test( userAgent ) && !/opera/.test( userAgent );
146
-
147
- var rs = "" ;
148
- rs = "<table id=\"sw-table-horaire\" class=\"sw-table\"";
149
- if(msie) {
150
- rs += " style=\"width:auto;\"";
151
- }
152
- rs += ">"
153
- + "<tr><td>Lun:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureLundi, 1, highlight) +"</tr>"
154
- + "<tr><td>Mar:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureMardi, 2, highlight) +"</tr>"
155
- + "<tr><td>Mer:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureMercredi, 3, highlight) +"</tr>"
156
- + "<tr><td>Jeu:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureJeudi, 4, highlight) +"</tr>"
157
- + "<tr><td>Ven:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureVendredi, 5, highlight) +"</tr>"
158
- + "<tr><td>Sam:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureSamedi, 6, highlight) +"</tr>"
159
- + "<tr><td>Dim:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureDimanche, 0, highlight) +"</tr>"
160
- + "</table>" ;
161
- return rs ;
162
- }
163
-
164
- function parseAdresse(anArray)
165
- {
166
- var address = anArray.adresse1 + "<br />" ;
167
- if (anArray.adresse2)
168
- address += anArray.adresse2 + "<br />" ;
169
- if (anArray.adresse3)
170
- address += anArray.adresse3 + "<br />" ;
171
- return address ;
172
- }
173
-
174
- function parseHorairesOuverture(value , day, highlight)
175
- {
176
- var rs = "" ;
177
-
178
- var now = new Date() ;
179
- var today = now.getDay() ; // number of day
180
- var attributedCell = "" ;
181
- var reg = new RegExp(" ", "g");
182
-
183
- var horaires = value.split(reg) ;
184
-
185
- for (var i=0; i < horaires.length; i++)
186
- {
187
- // first define the attributes for the current cell
188
- /* Aucun jour n'est mis en exergue car on ne sait pas quel sera le jour de livraison
189
- if ( highlight == true && day == today)
190
- {
191
- attributedCell = "style=\"color:red;\"" ;
192
- }
193
- else
194
- {
195
- */
196
- attributedCell = "" ;
197
- /*
198
- }
199
- */
200
-
201
- // so, re-format time
202
- if (horaires[i] == "00:00-00:00")
203
- {
204
- horaires[i] = "<td "+attributedCell+">Ferm&eacute;</td>" ;
205
- }
206
- else
207
- {
208
- horaires[i] = "<td "+attributedCell+">"+horaires[i]+"</td>" ;
209
- }
210
-
211
- // yeah, concatenates result to the returned value
212
- rs += horaires[i] ;
213
- }
214
-
215
- return rs ;
216
- }
217
-
218
- function printPage(i)
219
- {
220
- var fen=open("","Impression");
221
- fen.focus();
222
- var baseURL = "http://www.chronopost.fr/transport-express/webdav/site/chronov4/groups/administrators/public/Chronomaps/" ;
223
- var latlngpoint = relaylatan[i-1];
224
- if(latlngpoint) {
225
- fen.location.href = baseURL
226
- + "print-result.html?request=print&"
227
- + btQueryString(addressrelais[i-1], true).replace(/00%3A00-00%3A00/gi, 'Ferm%E9')
228
- + "&rtype=chronorelais"
229
- + "&icnname=ac"
230
- + "&lat=" + latlngpoint.lat()
231
- + "&lng=" + latlngpoint.lng()
232
- + "&sw-form-type-point=opt_chrlas"
233
- + "&is_print_direction=" + false
234
- + "&from_addr="
235
- + "&to_addr=";
236
- }
237
- }
238
-
239
- function btQueryString(anArray, needEscape)
240
- {
241
- var rs = "" ;
242
- for (key in anArray)
243
- {
244
- if (needEscape == true)
245
- {
246
- if(anArray[key]) {
247
- if (rs != "")
248
- rs += "&"
249
- rs += key +"=" + escape(anArray[key]) ;
250
- }
251
- }
252
- else
253
- {
254
- if(anArray[key]) {
255
- if (rs != "")
256
- rs += "_-_"
257
- rs += key +"=" + anArray[key] ;
258
- }
259
- }
260
- }
261
- return rs ;
262
- }
263
-
264
- function getShipAddress() {
265
- var ship_address = '';
266
- if($('shipping:same_as_billing').checked) {
267
- if ($('billing-address-select') && $('billing-address-select').value) {
268
- var e = $('billing-address-select');
269
- var address_value = e.options[e.selectedIndex].text;
270
- var shipping_address = address_value.split(',');
271
- if(shipping_address[1]) {
272
- ship_address = shipping_address[1];
273
- }
274
- } else {
275
- if($('billing:street1')) { ship_address = $('billing:street1').value; }
276
- if($('billing:street2')) { ship_address = ship_address+" "+$('billing:street2').value; }
277
- if($('billing:street3')) { ship_address = ship_address+" "+$('billing:street3').value; }
278
- }
279
- } else {
280
- if ($('shipping-address-select') && $('shipping-address-select').value) {
281
- var e = $('shipping-address-select');
282
- var address_value = e.options[e.selectedIndex].text;
283
- var shipping_address = address_value.split(',');
284
- if(shipping_address[1]) {
285
- ship_address = shipping_address[1];
286
- }
287
- } else {
288
- if($('shipping:street1')) { ship_address = $('shipping:street1').value; }
289
- if($('shipping:street2')) { ship_address = ship_address+" "+$('shipping:street2').value; }
290
- if($('shipping:street3')) { ship_address = ship_address+" "+$('shipping:street3').value; }
291
- }
292
- }
293
- return ship_address;
294
- }
295
-
296
- /** Map content end **/
297
-
298
-
299
- // shipping method
300
- var ShippingMethod = Class.create();
301
- ShippingMethod.prototype = {
302
- initialize: function(form, saveUrl){
303
- this.form = form;
304
- if ($(this.form)) {
305
- $(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
306
- }
307
- this.saveUrl = saveUrl;
308
- this.validator = new Validation(this.form);
309
- this.onSave = this.nextStep.bindAsEventListener(this);
310
- this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
311
- },
312
-
313
- validate: function() {
314
- var methods = document.getElementsByName('shipping_method');
315
- if (methods.length==0) {
316
- alert(Translator.translate('Your order cannot be completed at this time as there is no shipping methods available for it. Please make neccessary changes in your shipping address.'));
317
- return false;
318
- }
319
-
320
- if(!this.validator.validate()) {
321
- return false;
322
- }
323
-
324
- for (var i=0; i<methods.length; i++) {
325
- if (methods[i].checked) {
326
- if (methods[i].value == 'chronorelais_chronorelais') {
327
- var submethods = document.getElementsByName('shipping_method_chronorelais');
328
- if (submethods.length==0) {
329
- alert(Translator.translate('Your order cannot be completed at this time as there is no shipping methods available for it. Please make neccessary changes in your shipping address.'));
330
- return false;
331
- }
332
- for (var j=0; j<submethods.length; j++) {
333
- if (submethods[j].checked) {
334
- return true;
335
- }
336
- }
337
- } else {
338
- return true;
339
- }
340
- }
341
- }
342
- alert(Translator.translate('Please specify shipping method.'));
343
- return false;
344
- },
345
-
346
- getrelais: function(url){
347
- if (checkout.loadWaiting!=false) return;
348
- //if (this.validate()) {
349
- checkout.setLoadWaiting('shipping-method');
350
- hidehomeicon = false;
351
- var request = new Ajax.Request(
352
- url,
353
- {
354
- method:'post',
355
- onComplete: this.onComplete,
356
- onSuccess: this.onSave,
357
- onFailure: checkout.ajaxFailure.bind(checkout),
358
- parameters: Form.serialize(this.form)
359
- }
360
- );
361
- //}
362
- },
363
-
364
- changePostalCode: function(url){
365
- if (checkout.loadWaiting!=false) return;
366
- //if (this.validate()) {
367
- if(!$('mappostalcode').value) { return false; }
368
- checkout.setLoadWaiting('shipping-method');
369
- $('mappostalcodebtn').hide();
370
- $('postalcode-please-wait').show();
371
- $('postalcode-please-wait').style.opacity = '0.5';
372
- hidehomeicon = true;
373
- var request = new Ajax.Request(
374
- url,
375
- {
376
- method:'post',
377
- onComplete: this.onComplete,
378
- onSuccess: this.onSave,
379
- onFailure: checkout.ajaxFailure.bind(checkout),
380
- parameters: Form.serialize(this.form)
381
- }
382
- );
383
- //}
384
- },
385
-
386
- hiderelais: function(url){
387
- if($('checkout-shipping-method-chronorelais-load')) {
388
- $('checkout-shipping-method-chronorelais-load').innerHTML = "";
389
- }
390
- },
391
-
392
- save: function(){
393
-
394
- if (checkout.loadWaiting!=false) return;
395
- if (this.validate()) {
396
- checkout.setLoadWaiting('shipping-method');
397
- var request = new Ajax.Request(
398
- this.saveUrl,
399
- {
400
- method:'post',
401
- onComplete: this.onComplete,
402
- onSuccess: this.onSave,
403
- onFailure: checkout.ajaxFailure.bind(checkout),
404
- parameters: Form.serialize(this.form)
405
- }
406
- );
407
- }
408
- },
409
-
410
- resetLoadWaiting: function(transport){
411
- checkout.setLoadWaiting(false);
412
- },
413
-
414
- nextStep: function(transport){
415
- if (transport && transport.responseText){
416
- try{
417
- response = eval('(' + transport.responseText + ')');
418
- }
419
- catch (e) {
420
- response = {};
421
- }
422
- }
423
-
424
- if (response.error) {
425
- alert(response.message);
426
- if($('mappostalcodebtn')) { $('mappostalcodebtn').show(); }
427
- if($('postalcode-please-wait')) { $('postalcode-please-wait').hide(); }
428
- return false;
429
- }
430
-
431
- if (response.update_section) {
432
- $('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
433
- response.update_section.html.evalScripts();
434
-
435
- if(response.relaypoints) {
436
- if(response.relaypoints.length>0) {
437
- var relayaddress = "";
438
- gmarkers = [];
439
- addressrelais = [];
440
- relaylatan = [];
441
- homeaddress = "";
442
- next_pt = 0;
443
- bounds = new google.maps.LatLngBounds();
444
- for(var s=0; s<response.relaypoints.length; s++) {
445
- next_pt = s+1;
446
- relayaddress = response.relaypoints[s].adresse1;
447
- if(response.relaypoints[s].codePostal)
448
- relayaddress += " "+response.relaypoints[s].codePostal;
449
- if(response.relaypoints[s].localite)
450
- relayaddress += " "+response.relaypoints[s].localite;
451
- loadRelayMap(relayaddress, response.relaypoints[s], next_pt, "chronomap");
452
- }
453
- }
454
- }
455
- }
456
-
457
- payment.initWhatIsCvvListeners();
458
-
459
- if (response.goto_section) {
460
- checkout.gotoSection(response.goto_section);
461
- checkout.reloadProgressBlock();
462
- return;
463
- }
464
-
465
- if (response.payment_methods_html) {
466
- $('checkout-payment-method-load').update(response.payment_methods_html);
467
- }
468
-
469
- checkout.setShippingMethod();
470
- }
471
- }
472
-
473
- // shipping method
474
- var multiindex = "";
475
- var MultiShippingMethod = Class.create();
476
- MultiShippingMethod.prototype = {
477
- initialize: function(){
478
- this.loadWaiting = false;
479
- this.onComplete = this.complete.bindAsEventListener(this);
480
- },
481
-
482
- getrelais: function(url, index, home){
483
- if (this.loadWaiting!=false) return;
484
- this.loadWaiting = true;
485
- homeaddress = home;
486
- hidehomeicon = false;
487
- multiindex = "_" + index;
488
- var request = new Ajax.Request(
489
- url,
490
- {
491
- method:'post',
492
- onComplete: this.onComplete
493
- }
494
- );
495
-
496
- },
497
-
498
- changePostalCode: function(url, index){
499
- if (this.loadWaiting!=false) return;
500
- this.loadWaiting = true;
501
- multiindex = "_" + index;
502
- if(!$('mappostalcode' + multiindex).value) { return false; }
503
- homeaddress = $('mappostalcode' + multiindex).value;
504
- $('mappostalcodebtn' + multiindex).hide();
505
- $('postalcode-please-wait' + multiindex).show();
506
- $('postalcode-please-wait' + multiindex).style.opacity = '0.5';
507
- hidehomeicon = true;
508
- var request = new Ajax.Request(
509
- url + '&zip=' + $('mappostalcode' + multiindex).value,
510
- {
511
- method:'post',
512
- onComplete: this.onComplete
513
- }
514
- );
515
- },
516
-
517
- hiderelais: function(url, index){
518
- if($('checkout-shipping-method-chronorelais-load_' + index)) {
519
- $('checkout-shipping-method-chronorelais-load_' + index).innerHTML = "";
520
- }
521
- },
522
-
523
- complete: function(transport){
524
- this.loadWaiting = false;
525
-
526
- if (transport && transport.responseText){
527
- try{
528
- response = eval('(' + transport.responseText + ')');
529
- }
530
- catch (e) {
531
- response = {};
532
- }
533
- }
534
-
535
- if (response.error) {
536
- alert(response.message);
537
- if($('mappostalcodebtn' + multiindex)) { $('mappostalcodebtn' + multiindex).show(); }
538
- if($('postalcode-please-wait' + multiindex)) { $('postalcode-please-wait' + multiindex).hide(); }
539
- return false;
540
- }
541
-
542
- if (response.update_section) {
543
- $(response.update_section.name).update(response.update_section.html);
544
- response.update_section.html.evalScripts();
545
-
546
- if(response.relaypoints) {
547
- if(response.relaypoints.length>0) {
548
- var relayaddress = "";
549
- gmarkers = [];
550
- addressrelais = [];
551
- relaylatan = [];
552
- next_pt = 0;
553
- bounds = new google.maps.LatLngBounds();
554
- for(var s=0; s<response.relaypoints.length; s++) {
555
- next_pt = s+1;
556
- relayaddress = response.relaypoints[s].adresse1;
557
- if(response.relaypoints[s].codePostal)
558
- relayaddress += " "+response.relaypoints[s].codePostal;
559
- if(response.relaypoints[s].localite)
560
- relayaddress += " "+response.relaypoints[s].localite;
561
- loadRelayMap(relayaddress, response.relaypoints[s], next_pt, 'chronomap' + multiindex);
562
- }
563
- }
564
- }
565
- }
566
- }
567
- }
 
 
 
 
 
 
 
1
+ var gmarkers = [];
2
+ var map;
3
+ var homeaddress = "";
4
+ var addressrelais = [];
5
+ var relaylatan = [];
6
+ var next_pt = 0;
7
+ var hidehomeicon = false;
8
+ var currentInfoWindow;
9
+
10
+ function loadMyPoint(i) {
11
+ google.maps.event.trigger(gmarkers[i], "click");
12
+ }
13
+
14
+ var bounds = new google.maps.LatLngBounds();
15
+ function loadRelayMap(address, relaisArray, nextpt, mapid) {
16
+ var geo = new google.maps.Geocoder();
17
+
18
+ var myOptions = {
19
+ zoom: 5,
20
+ center: new google.maps.LatLng(47.37285025362682, 2.4172996312499784),
21
+ mapTypeId: google.maps.MapTypeId.ROADMAP
22
+ }
23
+ map = new google.maps.Map(document.getElementById(mapid), myOptions);
24
+
25
+ var blueIcon = new google.maps.MarkerImage(Picto_Chrono_Relais);
26
+
27
+ var homeIcon = new google.maps.MarkerImage(Home_Chrono_Icon);
28
+
29
+ if(!homeaddress && !hidehomeicon) {
30
+ var ship_address = getShipAddress(); //get shipping address to set home address
31
+ homeaddress = relaisArray.codePostal + " " + relaisArray.localite;
32
+ if(ship_address) { homeaddress = ship_address+" "+homeaddress; }
33
+
34
+ geo.geocode({'address': homeaddress}, function(results, status) {
35
+ if (status == google.maps.GeocoderStatus.OK) {
36
+ var point = results[0].geometry.location;
37
+ var marker = new google.maps.Marker({
38
+ position: point,
39
+ map: map,
40
+ title: 'home',
41
+ icon: homeIcon
42
+ });
43
+ map.setCenter(point, 11);
44
+ }
45
+ });
46
+ }
47
+
48
+ function createTabbedMarker(point, relaisArray) {
49
+ addressrelais.push(relaisArray);
50
+ var label = nextpt;
51
+ var relaypoint_id = relaisArray.identifiantChronopostPointA2PAS;
52
+ var marker = new google.maps.Marker({map: map, position: point, title:relaisArray.nomEnseigne, icon:blueIcon});
53
+
54
+ var infowindow;
55
+ if (window.innerWidth < 700) {
56
+ infowindow = new google.maps.InfoWindow({
57
+ content: '<div style=""><div style="float: left;"><h2>Infos</h2>'+getMarkerInfoContent(relaisArray)+'</div><div style="margin-left: 10px; padding-left: 10px; border-left: 1px solid #000; float: left;"><h2>Horaires</h2><div style="">'+getHorairesTab(relaisArray, true)+'</div></div></div>'
58
+ });
59
+ } else {
60
+ infowindow = new google.maps.InfoWindow({
61
+ content: '<div style="width: 400px;"><div style="width: 190px; float: left;"><h2>Infos</h2>'+getMarkerInfoContent(relaisArray) + getActionsForm(addressrelais.length)+'</div><div style="margin-left: 10px; padding-left: 10px; border-left: 1px solid #000; float: left;"><h2>Horaires</h2><div style="width: 189px">'+getHorairesTab(relaisArray, true)+'</div></div></div>'
62
+ });
63
+ }
64
+
65
+ google.maps.event.addListener(marker, 'click', function() {
66
+ if(document.getElementById('s_method_chronorelais_'+relaisArray.identifiantChronopostPointA2PAS))
67
+ document.getElementById('s_method_chronorelais_'+relaisArray.identifiantChronopostPointA2PAS).checked = true;
68
+
69
+ if (currentInfoWindow) {
70
+ currentInfoWindow.close();
71
+ }
72
+ infowindow.open(map,marker);
73
+ currentInfoWindow = infowindow;
74
+ });
75
+
76
+ gmarkers[relaypoint_id] = marker;
77
+ return marker;
78
+ }
79
+
80
+ function showAddress(address, relaisArray) {
81
+ var search = address;
82
+ // ====== Perform the Geocoding ======
83
+ geo.geocode({'address': search}, function(results, status)
84
+ {
85
+ // If that was successful
86
+ if (status == google.maps.GeocoderStatus.OK) {
87
+ // Loop through the results, placing markers
88
+ //for (var i=0; i<result.Placemark.length; i++) {
89
+ for (var i=0; i<1; i++) {
90
+ var p = results[i].geometry.location;
91
+ relaylatan.push(p);
92
+ var marker = createTabbedMarker(p, relaisArray);
93
+ // ==== Each time a point is found, extent the bounds ato include it =====
94
+ bounds.extend(p);
95
+ }
96
+ // centre the map on the first result
97
+ //!homeaddress && hidehomeicon &&
98
+ if(nextpt==5) {
99
+ var p = results[0].geometry.location;
100
+ // ===== determine the zoom level from the bounds =====
101
+ map.fitBounds(bounds);
102
+ // ===== determine the centre from the bounds ======
103
+ map.setCenter(bounds.getCenter());
104
+ }
105
+ }
106
+ // ====== Decode the error status ======
107
+ else {
108
+ var reason = "Code " + status;
109
+ /*
110
+ if (reasons[status]) {
111
+ reason = reasons[status]
112
+ }
113
+ */
114
+ alert('Could not find "' + search + '" ' + reason);
115
+ }
116
+ });
117
+ }
118
+ showAddress(address, relaisArray);
119
+ } // end of loadRelayMap function
120
+
121
+ function addEvent( obj, type, fn ) {
122
+ if ( obj.attachEvent ) {
123
+ obj["e"+type+fn] = fn;
124
+ obj[type+fn] = function() { obj["e"+type+fn]( window.event ) };
125
+ obj.attachEvent( "on"+type, obj[type+fn] );
126
+ }
127
+ else{
128
+ obj.addEventListener( type, fn, false );
129
+ }
130
+ }
131
+
132
+ function getMarkerInfoContent(relaisArray){
133
+ var icoPath = Picto_Chrono_Relais;
134
+ var content="<div class=\"sw-map-adresse-wrp\" style=\"background-image: url("+ icoPath +"); background-repeat: no-repeat;padding-left:50px;\">"
135
+ + "<h2>"+relaisArray.nomEnseigne+"</h2>"
136
+ + "<div class=\"sw-map-adresse\">"
137
+ + parseAdresse(relaisArray)
138
+ + relaisArray.codePostal + " " + relaisArray.localite
139
+ + "</div></div>";
140
+ return content;
141
+ }
142
+ function getActionsForm(label)
143
+ {
144
+ var html = '<div class="sw-map-tools"><a href="javascript:printPage('+label+')">Imprimer</a>'
145
+ + '</div>';
146
+ return html;
147
+ }
148
+
149
+ function getHorairesTab(anArray, highlight)
150
+ {
151
+ var userAgent = navigator.userAgent.toLowerCase();
152
+ var msie = /msie/.test( userAgent ) && !/opera/.test( userAgent );
153
+
154
+ var rs = "" ;
155
+ rs = "<table id=\"sw-table-horaire\" class=\"sw-table\"";
156
+ if(msie) {
157
+ rs += " style=\"width:auto;\"";
158
+ }
159
+ rs += ">"
160
+ + "<tr><td>Lun:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureLundi, 1, highlight) +"</tr>"
161
+ + "<tr><td>Mar:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureMardi, 2, highlight) +"</tr>"
162
+ + "<tr><td>Mer:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureMercredi, 3, highlight) +"</tr>"
163
+ + "<tr><td>Jeu:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureJeudi, 4, highlight) +"</tr>"
164
+ + "<tr><td>Ven:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureVendredi, 5, highlight) +"</tr>"
165
+ + "<tr><td>Sam:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureSamedi, 6, highlight) +"</tr>"
166
+ + "<tr><td>Dim:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureDimanche, 0, highlight) +"</tr>"
167
+ + "</table>" ;
168
+ return rs ;
169
+ }
170
+
171
+ function parseAdresse(anArray)
172
+ {
173
+ var address = anArray.adresse1 + "<br />" ;
174
+ if (anArray.adresse2)
175
+ address += anArray.adresse2 + "<br />" ;
176
+ if (anArray.adresse3)
177
+ address += anArray.adresse3 + "<br />" ;
178
+ return address ;
179
+ }
180
+
181
+ function parseHorairesOuverture(value , day, highlight)
182
+ {
183
+ var rs = "" ;
184
+
185
+ var now = new Date() ;
186
+ var today = now.getDay() ; // number of day
187
+ var attributedCell = "" ;
188
+ var reg = new RegExp(" ", "g");
189
+
190
+ var horaires = value.split(reg) ;
191
+
192
+ for (var i=0; i < horaires.length; i++)
193
+ {
194
+ // first define the attributes for the current cell
195
+ /* Aucun jour n'est mis en exergue car on ne sait pas quel sera le jour de livraison
196
+ if ( highlight == true && day == today)
197
+ {
198
+ attributedCell = "style=\"color:red;\"" ;
199
+ }
200
+ else
201
+ {
202
+ */
203
+ attributedCell = "" ;
204
+ /*
205
+ }
206
+ */
207
+
208
+ // so, re-format time
209
+ if (horaires[i] == "00:00-00:00")
210
+ {
211
+ horaires[i] = "<td "+attributedCell+">Ferm&eacute;</td>" ;
212
+ }
213
+ else
214
+ {
215
+ horaires[i] = "<td "+attributedCell+">"+horaires[i]+"</td>" ;
216
+ }
217
+
218
+ // yeah, concatenates result to the returned value
219
+ rs += horaires[i] ;
220
+ }
221
+
222
+ return rs ;
223
+ }
224
+
225
+ function printPage(i)
226
+ {
227
+ var fen=open("","Impression");
228
+ fen.focus();
229
+ var baseURL = "http://www.chronopost.fr/transport-express/webdav/site/chronov4/groups/administrators/public/Chronomaps/" ;
230
+ var latlngpoint = relaylatan[i-1];
231
+ if(latlngpoint) {
232
+ fen.location.href = baseURL
233
+ + "print-result.html?request=print&"
234
+ + btQueryString(addressrelais[i-1], true).replace(/00%3A00-00%3A00/gi, 'Ferm%E9')
235
+ + "&rtype=chronorelais"
236
+ + "&icnname=ac"
237
+ + "&lat=" + latlngpoint.lat()
238
+ + "&lng=" + latlngpoint.lng()
239
+ + "&sw-form-type-point=opt_chrlas"
240
+ + "&is_print_direction=" + false
241
+ + "&from_addr="
242
+ + "&to_addr=";
243
+ }
244
+ }
245
+
246
+ function btQueryString(anArray, needEscape)
247
+ {
248
+ var rs = "" ;
249
+ for (key in anArray)
250
+ {
251
+ if (needEscape == true)
252
+ {
253
+ if(anArray[key]) {
254
+ if (rs != "")
255
+ rs += "&"
256
+ rs += key +"=" + escape(anArray[key]) ;
257
+ }
258
+ }
259
+ else
260
+ {
261
+ if(anArray[key]) {
262
+ if (rs != "")
263
+ rs += "_-_"
264
+ rs += key +"=" + anArray[key] ;
265
+ }
266
+ }
267
+ }
268
+ return rs ;
269
+ }
270
+
271
+ function getShipAddress() {
272
+ var ship_address = '';
273
+ if($('shipping:same_as_billing').checked) {
274
+ if ($('billing-address-select') && $('billing-address-select').value) {
275
+ var e = $('billing-address-select');
276
+ var address_value = e.options[e.selectedIndex].text;
277
+ var shipping_address = address_value.split(',');
278
+ if(shipping_address[1]) {
279
+ ship_address = shipping_address[1];
280
+ }
281
+ } else {
282
+ if($('billing:street1')) { ship_address = $('billing:street1').value; }
283
+ if($('billing:street2')) { ship_address = ship_address+" "+$('billing:street2').value; }
284
+ if($('billing:street3')) { ship_address = ship_address+" "+$('billing:street3').value; }
285
+ }
286
+ } else {
287
+ if ($('shipping-address-select') && $('shipping-address-select').value) {
288
+ var e = $('shipping-address-select');
289
+ var address_value = e.options[e.selectedIndex].text;
290
+ var shipping_address = address_value.split(',');
291
+ if(shipping_address[1]) {
292
+ ship_address = shipping_address[1];
293
+ }
294
+ } else {
295
+ if($('shipping:street1')) { ship_address = $('shipping:street1').value; }
296
+ if($('shipping:street2')) { ship_address = ship_address+" "+$('shipping:street2').value; }
297
+ if($('shipping:street3')) { ship_address = ship_address+" "+$('shipping:street3').value; }
298
+ }
299
+ }
300
+ return ship_address;
301
+ }
302
+
303
+ /** Map content end **/
304
+
305
+
306
+ // shipping method
307
+ var ShippingMethod = Class.create();
308
+ ShippingMethod.prototype = {
309
+ initialize: function(form, saveUrl){
310
+ this.form = form;
311
+ if ($(this.form)) {
312
+ $(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
313
+ }
314
+ this.saveUrl = saveUrl;
315
+ this.validator = new Validation(this.form);
316
+ this.onSave = this.nextStep.bindAsEventListener(this);
317
+ this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
318
+ },
319
+
320
+ validate: function() {
321
+ var methods = document.getElementsByName('shipping_method');
322
+ if (methods.length==0) {
323
+ alert(Translator.translate('Your order cannot be completed at this time as there is no shipping methods available for it. Please make neccessary changes in your shipping address.'));
324
+ return false;
325
+ }
326
+
327
+ if(!this.validator.validate()) {
328
+ return false;
329
+ }
330
+
331
+ for (var i=0; i<methods.length; i++) {
332
+ if (methods[i].checked) {
333
+ if (methods[i].value == 'chronorelais_chronorelais') {
334
+ var submethods = document.getElementsByName('shipping_method_chronorelais');
335
+ if (submethods.length==0) {
336
+ alert(Translator.translate('Your order cannot be completed at this time as there is no shipping methods available for it. Please make neccessary changes in your shipping address.'));
337
+ return false;
338
+ }
339
+ for (var j=0; j<submethods.length; j++) {
340
+ if (submethods[j].checked) {
341
+ return true;
342
+ }
343
+ }
344
+ } else {
345
+ return true;
346
+ }
347
+ }
348
+ }
349
+ alert(Translator.translate('Please specify shipping method.'));
350
+ return false;
351
+ },
352
+
353
+ getrelais: function(url){
354
+ if (checkout.loadWaiting!=false) return;
355
+ //if (this.validate()) {
356
+ checkout.setLoadWaiting('shipping-method');
357
+ hidehomeicon = false;
358
+ var request = new Ajax.Request(
359
+ url,
360
+ {
361
+ method:'post',
362
+ onComplete: this.onComplete,
363
+ onSuccess: this.onSave,
364
+ onFailure: checkout.ajaxFailure.bind(checkout),
365
+ parameters: Form.serialize(this.form)
366
+ }
367
+ );
368
+ //}
369
+ },
370
+
371
+ changePostalCode: function(url){
372
+ if (checkout.loadWaiting!=false) return;
373
+ //if (this.validate()) {
374
+ if(!$('mappostalcode').value) { return false; }
375
+ checkout.setLoadWaiting('shipping-method');
376
+ $('mappostalcodebtn').hide();
377
+ $('postalcode-please-wait').show();
378
+ $('postalcode-please-wait').style.opacity = '0.5';
379
+ hidehomeicon = true;
380
+ var request = new Ajax.Request(
381
+ url,
382
+ {
383
+ method:'post',
384
+ onComplete: this.onComplete,
385
+ onSuccess: this.onSave,
386
+ onFailure: checkout.ajaxFailure.bind(checkout),
387
+ parameters: Form.serialize(this.form)
388
+ }
389
+ );
390
+ //}
391
+ },
392
+
393
+ hiderelais: function(url){
394
+ if($('checkout-shipping-method-chronorelais-load')) {
395
+ $('checkout-shipping-method-chronorelais-load').innerHTML = "";
396
+ }
397
+ },
398
+
399
+ save: function(){
400
+
401
+ if (checkout.loadWaiting!=false) return;
402
+ if (this.validate()) {
403
+ checkout.setLoadWaiting('shipping-method');
404
+ var request = new Ajax.Request(
405
+ this.saveUrl,
406
+ {
407
+ method:'post',
408
+ onComplete: this.onComplete,
409
+ onSuccess: this.onSave,
410
+ onFailure: checkout.ajaxFailure.bind(checkout),
411
+ parameters: Form.serialize(this.form)
412
+ }
413
+ );
414
+ }
415
+ },
416
+
417
+ resetLoadWaiting: function(transport){
418
+ checkout.setLoadWaiting(false);
419
+ },
420
+
421
+ nextStep: function(transport){
422
+ if (transport && transport.responseText){
423
+ try{
424
+ response = eval('(' + transport.responseText + ')');
425
+ }
426
+ catch (e) {
427
+ response = {};
428
+ }
429
+ }
430
+
431
+ if (response.error) {
432
+ alert(response.message);
433
+ if($('mappostalcodebtn')) { $('mappostalcodebtn').show(); }
434
+ if($('postalcode-please-wait')) { $('postalcode-please-wait').hide(); }
435
+ return false;
436
+ }
437
+
438
+ if (response.update_section) {
439
+ $('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
440
+ response.update_section.html.evalScripts();
441
+
442
+ if(response.relaypoints) {
443
+ if(response.relaypoints.length>0) {
444
+ var relayaddress = "";
445
+ gmarkers = [];
446
+ addressrelais = [];
447
+ relaylatan = [];
448
+ homeaddress = "";
449
+ next_pt = 0;
450
+ bounds = new google.maps.LatLngBounds();
451
+ for(var s=0; s<response.relaypoints.length; s++) {
452
+ next_pt = s+1;
453
+ relayaddress = response.relaypoints[s].adresse1;
454
+ if(response.relaypoints[s].codePostal)
455
+ relayaddress += " "+response.relaypoints[s].codePostal;
456
+ if(response.relaypoints[s].localite)
457
+ relayaddress += " "+response.relaypoints[s].localite;
458
+ loadRelayMap(relayaddress, response.relaypoints[s], next_pt, "chronomap");
459
+ }
460
+ }
461
+ }
462
+ }
463
+
464
+ payment.initWhatIsCvvListeners();
465
+
466
+ if (response.goto_section) {
467
+ checkout.gotoSection(response.goto_section);
468
+ checkout.reloadProgressBlock();
469
+ return;
470
+ }
471
+
472
+ if (response.payment_methods_html) {
473
+ $('checkout-payment-method-load').update(response.payment_methods_html);
474
+ }
475
+
476
+ checkout.setShippingMethod();
477
+ }
478
+ }
479
+
480
+ // shipping method
481
+ var multiindex = "";
482
+ var MultiShippingMethod = Class.create();
483
+ MultiShippingMethod.prototype = {
484
+ initialize: function(){
485
+ this.loadWaiting = false;
486
+ this.onComplete = this.complete.bindAsEventListener(this);
487
+ },
488
+
489
+ getrelais: function(url, index, home){
490
+ if (this.loadWaiting!=false) return;
491
+ this.loadWaiting = true;
492
+ homeaddress = home;
493
+ hidehomeicon = false;
494
+ multiindex = "_" + index;
495
+ var request = new Ajax.Request(
496
+ url,
497
+ {
498
+ method:'post',
499
+ onComplete: this.onComplete
500
+ }
501
+ );
502
+
503
+ },
504
+
505
+ changePostalCode: function(url, index){
506
+ if (this.loadWaiting!=false) return;
507
+ this.loadWaiting = true;
508
+ multiindex = "_" + index;
509
+ if(!$('mappostalcode' + multiindex).value) { return false; }
510
+ homeaddress = $('mappostalcode' + multiindex).value;
511
+ $('mappostalcodebtn' + multiindex).hide();
512
+ $('postalcode-please-wait' + multiindex).show();
513
+ $('postalcode-please-wait' + multiindex).style.opacity = '0.5';
514
+ hidehomeicon = true;
515
+ var request = new Ajax.Request(
516
+ url + '&zip=' + $('mappostalcode' + multiindex).value,
517
+ {
518
+ method:'post',
519
+ onComplete: this.onComplete
520
+ }
521
+ );
522
+ },
523
+
524
+ hiderelais: function(url, index){
525
+ if($('checkout-shipping-method-chronorelais-load_' + index)) {
526
+ $('checkout-shipping-method-chronorelais-load_' + index).innerHTML = "";
527
+ }
528
+ },
529
+
530
+ complete: function(transport){
531
+ this.loadWaiting = false;
532
+
533
+ if (transport && transport.responseText){
534
+ try{
535
+ response = eval('(' + transport.responseText + ')');
536
+ }
537
+ catch (e) {
538
+ response = {};
539
+ }
540
+ }
541
+
542
+ if (response.error) {
543
+ alert(response.message);
544
+ if($('mappostalcodebtn' + multiindex)) { $('mappostalcodebtn' + multiindex).show(); }
545
+ if($('postalcode-please-wait' + multiindex)) { $('postalcode-please-wait' + multiindex).hide(); }
546
+ return false;
547
+ }
548
+
549
+ if (response.update_section) {
550
+ $(response.update_section.name).update(response.update_section.html);
551
+ response.update_section.html.evalScripts();
552
+
553
+ if(response.relaypoints) {
554
+ if(response.relaypoints.length>0) {
555
+ var relayaddress = "";
556
+ gmarkers = [];
557
+ addressrelais = [];
558
+ relaylatan = [];
559
+ next_pt = 0;
560
+ bounds = new google.maps.LatLngBounds();
561
+ for(var s=0; s<response.relaypoints.length; s++) {
562
+ next_pt = s+1;
563
+ relayaddress = response.relaypoints[s].adresse1;
564
+ if(response.relaypoints[s].codePostal)
565
+ relayaddress += " "+response.relaypoints[s].codePostal;
566
+ if(response.relaypoints[s].localite)
567
+ relayaddress += " "+response.relaypoints[s].localite;
568
+ loadRelayMap(relayaddress, response.relaypoints[s], next_pt, 'chronomap' + multiindex);
569
+ }
570
+ }
571
+ }
572
+ }
573
+ }
574
+ }
skin/frontend/{default → base}/default/chronorelais/home.png RENAMED
File without changes
skin/frontend/{default → base}/default/chronorelais/ico_ac_shaded.gif RENAMED
File without changes
skin/frontend/default/default/chronorelais/Thumbs.db DELETED
Binary file