Chronopost - Version 1.2.0

Version Notes

Version destinée à Magento 1.6.X et supérieures. Testée sur Magento 1.9.2.
------------
Intégration du mode de livraison Chrono Europe

Download this release

Release Info

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


Code changes from version 1.0.6 to 1.2.0

Files changed (58) hide show
  1. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/Form/Renderer/Config/Date.php +23 -0
  2. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/Notification.php +81 -81
  3. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Checklogin.php +44 -44
  4. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Fieldsetconflicts.php +47 -46
  5. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Rdvconfig.php +29 -0
  6. app/code/community/Chronopost/Chronorelais/Block/Checkout/Onepage/Shipping/Method/Chronopostsrdv.php +18 -0
  7. app/code/community/Chronopost/Chronorelais/Block/Checkout/Onepage/Shipping/Method/Chronorelais.php +15 -14
  8. app/code/community/Chronopost/Chronorelais/Block/Detail.php +6 -17
  9. app/code/community/Chronopost/Chronorelais/Block/Export/Orders/Grid.php +278 -270
  10. app/code/community/Chronopost/Chronorelais/Block/Filter.php +10 -25
  11. app/code/community/Chronopost/Chronorelais/Block/Sales/Bordereau/Grid.php +161 -161
  12. app/code/community/Chronopost/Chronorelais/Block/Sales/Order/Shipment/View.php +27 -27
  13. app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid.php +259 -254
  14. app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid/Renderer/Retoursav.php +31 -28
  15. app/code/community/Chronopost/Chronorelais/Controller/Abstract.php +9 -5
  16. app/code/community/Chronopost/Chronorelais/Helper/Conflicts.php +159 -161
  17. app/code/community/Chronopost/Chronorelais/Helper/Data.php +463 -350
  18. app/code/community/Chronopost/Chronorelais/Helper/Webservice.php +727 -449
  19. app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelaisShipping.php +517 -522
  20. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronoexpress.php +1 -2
  21. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronopost.php +1 -2
  22. app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostC10.php +2 -2
  23. app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostC18.php +2 -2
  24. app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostCClassic.php +2 -2
  25. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronopostsameday.php +33 -0
  26. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronopostsrdv.php +85 -0
  27. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronorelais.php +2 -2
  28. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronorelaisdom.php +7 -0
  29. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronorelaiseurope.php +7 -0
  30. app/code/community/Chronopost/Chronorelais/Model/Config/Backend/Date.php +17 -0
  31. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Civility.php +2 -2
  32. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Day.php +16 -0
  33. app/code/community/Chronopost/Chronorelais/Model/Config/Source/FieldDelimiter.php +2 -2
  34. app/code/community/Chronopost/Chronorelais/Model/Config/Source/FileCharset.php +2 -2
  35. app/code/community/Chronopost/Chronorelais/Model/Config/Source/FileExtension.php +1 -1
  36. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Hour.php +13 -0
  37. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Margetype.php +11 -0
  38. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Minute.php +13 -0
  39. app/code/community/Chronopost/Chronorelais/Model/Config/Source/PrintMode.php +1 -1
  40. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Time.php +31 -0
  41. app/code/community/Chronopost/Chronorelais/Model/Observer.php +271 -0
  42. app/code/community/Chronopost/Chronorelais/Model/Sales/Quote/Address/Total/Shipping.php +206 -207
  43. app/code/community/Chronopost/Chronorelais/Model/Sales/Quote/Address/Total/Shipping.toDel.php +206 -207
  44. app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/AjaxController.php +432 -446
  45. app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/ExportController.php +634 -447
  46. app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/ImportController.php +0 -8
  47. app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/Sales/BordereauController.php +3 -6
  48. app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/Sales/ImpressionController.php +1135 -1049
  49. app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/Sales/Order/ShipmentController.php +429 -386
  50. app/code/community/Chronopost/Chronorelais/controllers/Checkout/MultishippingController.php +13 -19
  51. app/code/community/Chronopost/Chronorelais/controllers/Checkout/OnepageController.php +0 -249
  52. app/code/community/Chronopost/Chronorelais/controllers/IndexController.php +11 -0
  53. app/code/community/Chronopost/Chronorelais/controllers/RelaisController.php +97 -8
  54. app/code/community/Chronopost/Chronorelais/controllers/SrdvController.php +38 -0
  55. app/code/community/Chronopost/Chronorelais/etc/config.xml +673 -465
  56. app/code/community/Chronopost/Chronorelais/etc/system.xml +2433 -1583
  57. app/code/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php +1465 -1368
  58. app/code/community/Chronopost/Chronorelais/includes/countries.inc.php +141 -524
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/Form/Renderer/Config/Date.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Adminhtml_Form_Renderer_Config_Date extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $element->setStyle('width:70px;')
8
+ ->setName($element->getName() . '[]');
9
+
10
+ if ($element->getValue()) {
11
+ $values = explode(':', $element->getValue());
12
+ } else {
13
+ $values = array();
14
+ }
15
+
16
+ $date = $element->setValues(Mage::getSingleton('chronorelais/config_source_day')->toOptionArray())->setValue(isset($values[0]) ? $values[0] : null)->getElementHtml();
17
+ $heure = $element->setValues(Mage::getSingleton('chronorelais/config_source_hour')->toOptionArray())->setValue(isset($values[1]) ? $values[1] : null)->getElementHtml();
18
+ $minutes = $element->setValues(Mage::getSingleton('chronorelais/config_source_minute')->toOptionArray())->setValue(isset($values[2]) ? $values[2] : null)->getElementHtml();
19
+ return Mage::helper('adminhtml')->__('Date') . ' : ' . $date
20
+ . ' '
21
+ . Mage::helper('adminhtml')->__('Heure') . ' : ' . $heure.' '.$minutes;
22
+ }
23
+ }
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/Notification.php CHANGED
@@ -1,81 +1,81 @@
1
- <?php
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();
12
- if (!$this->getTemplate()) {
13
- $this->setTemplate('chronorelais/notification.phtml');
14
- }
15
- return $this;
16
- }
17
-
18
- public function getSeverityIconsUrl()
19
- {
20
- return (Mage::app()->getFrontController()->getRequest()->isSecure() ? 'https://' : 'http://')
21
- . sprintf(Mage::getStoreConfig(self::XML_SEVERITY_ICONS_URL_PATH), Mage::getVersion(),
22
- 'SEVERITY_NOTICE');
23
- }
24
-
25
- public function canShow()
26
- {
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();
40
- $origin_postcode = $_helper->getConfigurationShipperInfo('zipcode');
41
-
42
- $WSParams = array(
43
- 'accountNumber' => $account_number,
44
- 'password' => $password,
45
- 'depCountryCode' => $_helper->getConfigurationShipperInfo('country'),
46
- 'depZipCode' => $origin_postcode,
47
- 'arrCountryCode' => $_helper->getConfigurationShipperInfo('country'),
48
- 'arrZipCode' => $origin_postcode,
49
- 'arrCity' => $_helper->getConfigurationShipperInfo('city'),
50
- 'type' => 'M',
51
- 'weight' => 1
52
- );
53
-
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
- }
1
+ <?php
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();
12
+ if (!$this->getTemplate()) {
13
+ $this->setTemplate('chronorelais/notification.phtml');
14
+ }
15
+ return $this;
16
+ }
17
+
18
+ public function getSeverityIconsUrl()
19
+ {
20
+ return (Mage::app()->getFrontController()->getRequest()->isSecure() ? 'https://' : 'http://')
21
+ . sprintf(Mage::getStoreConfig(self::XML_SEVERITY_ICONS_URL_PATH), Mage::getVersion(),
22
+ 'SEVERITY_NOTICE');
23
+ }
24
+
25
+ public function canShow()
26
+ {
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();
40
+ $origin_postcode = $_helper->getConfigurationShipperInfo('zipcode');
41
+
42
+ $WSParams = array(
43
+ 'accountNumber' => $account_number,
44
+ 'password' => $password,
45
+ 'depCountryCode' => $_helper->getConfigurationShipperInfo('country'),
46
+ 'depZipCode' => $origin_postcode,
47
+ 'arrCountryCode' => $_helper->getConfigurationShipperInfo('country'),
48
+ 'arrZipCode' => $origin_postcode,
49
+ 'arrCity' => $_helper->getConfigurationShipperInfo('city'),
50
+ 'type' => 'M',
51
+ 'weight' => 1
52
+ );
53
+
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[0];
73
+ if(version_compare($lastRelease->v, $currentVersion, '>')) {
74
+ $notifications[] = 'new_version';
75
+ }
76
+
77
+ return $notifications;
78
+
79
+ }
80
+
81
+ }
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Checklogin.php CHANGED
@@ -1,44 +1,44 @@
1
- <?php
2
- class Chronopost_Chronorelais_Block_Adminhtml_System_Config_Checklogin extends Mage_Adminhtml_Block_System_Config_Form_Field
3
- {
4
- protected function _prepareLayout()
5
- {
6
- parent::_prepareLayout();
7
- if (!$this->getTemplate()) {
8
- $this->setTemplate('chronorelais/config/checklogin.phtml');
9
- }
10
- return $this;
11
- }
12
-
13
- /**
14
- * Unset some non-related element parameters
15
- *
16
- * @param Varien_Data_Form_Element_Abstract $element
17
- * @return string
18
- */
19
- public function render(Varien_Data_Form_Element_Abstract $element)
20
- {
21
- $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
22
- return parent::render($element);
23
- }
24
-
25
- /**
26
- * Get the button and scripts contents
27
- *
28
- * @param Varien_Data_Form_Element_Abstract $element
29
- * @return string
30
- */
31
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
32
- {
33
- $html = parent::_getElementHtml($element);
34
- $originalData = $element->getOriginalData();
35
- $this->addData(array(
36
- 'button_label' => Mage::helper('chronorelais')->__($originalData['button_label']),
37
- 'html_id' => $element->getHtmlId(),
38
- 'ajax_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/chronorelais_ajax/checklogin')
39
- ));
40
-
41
-
42
- return $html.$this->_toHtml();
43
- }
44
- }
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Adminhtml_System_Config_Checklogin extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ protected function _prepareLayout()
5
+ {
6
+ parent::_prepareLayout();
7
+ if (!$this->getTemplate()) {
8
+ $this->setTemplate('chronorelais/config/checklogin.phtml');
9
+ }
10
+ return $this;
11
+ }
12
+
13
+ /**
14
+ * Unset some non-related element parameters
15
+ *
16
+ * @param Varien_Data_Form_Element_Abstract $element
17
+ * @return string
18
+ */
19
+ public function render(Varien_Data_Form_Element_Abstract $element)
20
+ {
21
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
22
+ return parent::render($element);
23
+ }
24
+
25
+ /**
26
+ * Get the button and scripts contents
27
+ *
28
+ * @param Varien_Data_Form_Element_Abstract $element
29
+ * @return string
30
+ */
31
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
32
+ {
33
+ $html = parent::_getElementHtml($element);
34
+ $originalData = $element->getOriginalData();
35
+ $this->addData(array(
36
+ 'button_label' => Mage::helper('chronorelais')->__($originalData['button_label']),
37
+ 'html_id' => $element->getHtmlId(),
38
+ 'ajax_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/chronorelais_ajax/checklogin')
39
+ ));
40
+
41
+
42
+ return $html.$this->_toHtml();
43
+ }
44
+ }
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Fieldsetconflicts.php CHANGED
@@ -1,46 +1,47 @@
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('adminhtml/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
- }
 
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
+ $tooltipsExist = false;
16
+ $html = '</tbody></table>';
17
+
18
+ $html .= '<div class="chronorelais_conflicts">';
19
+ $html .= '<button onclick="javascript:checkConflicts(); return false;" class="scalable" type="button" id="chronorelais_conflicts">';
20
+ $html .= ' <span>Lancer la vérification</span>';
21
+ $html .= '</button>';
22
+ $html .= '<div id="chronorelais_conflicts_result"></div>';
23
+ $html .= '</div>';
24
+
25
+ $html .= '</fieldset>' . $this->_getExtraJs($element, $tooltipsExist);
26
+
27
+ $html .= '<script type="text/javascript">' . "\r\n";
28
+ $html .= '//<![CDATA[' . "\r\n";
29
+ $html .= ' function checkConflicts() {' . "\r\n";
30
+ $html .= ' new Ajax.Request(\'' . Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/chronorelais_ajax/checkConflicts') . '\', {' . "\r\n";
31
+ $html .= ' onSuccess: function(data) {' . "\r\n";
32
+ $html .= ' var response = data.responseText;' . "\r\n";
33
+ $html .= ' $(\'chronorelais_conflicts_result\').update(response).show();' . "\r\n";
34
+ $html .= ' }' . "\r\n";
35
+ $html .= ' });' . "\r\n";
36
+ $html .= ' }' . "\r\n";
37
+ $html .= '//]]>' . "\r\n";
38
+ $html .= '</script>' . "\r\n";
39
+
40
+ if ($element->getIsNested()) {
41
+ $html .= '</div></td></tr>';
42
+ } else {
43
+ $html .= '</div>';
44
+ }
45
+ return $html;
46
+ }
47
+ }
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Rdvconfig.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Adminhtml_System_Config_Rdvconfig extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ protected function _prepareLayout()
5
+ {
6
+ parent::_prepareLayout();
7
+ if (!$this->getTemplate()) {
8
+ $this->setTemplate('chronorelais/config/rdvconfig.phtml');
9
+ }
10
+ return $this;
11
+ }
12
+
13
+ /**
14
+ * Get the button and scripts contents
15
+ *
16
+ * @param Varien_Data_Form_Element_Abstract $element
17
+ * @return string
18
+ */
19
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
20
+ {
21
+ $html = parent::_getElementHtml($element);
22
+ $this->addData(array(
23
+ 'html_id' => $element->getHtmlId(),
24
+ 'value' => $element->getValue()
25
+ ));
26
+
27
+ return $html.$this->_toHtml();
28
+ }
29
+ }
app/code/community/Chronopost/Chronorelais/Block/Checkout/Onepage/Shipping/Method/Chronopostsrdv.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Block_Checkout_Onepage_Shipping_Method_Chronopostsrdv extends Mage_Checkout_Block_Onepage_Abstract {
4
+
5
+ protected function getCarrierModel() {
6
+ return Mage::getSingleton("chronorelais/carrier_chronopostsrdv");
7
+ }
8
+ public function getSearchDeliverySlot() {
9
+ /* appel WS SearchDeliverySlot pour récupérer les créneaux de livraison permettant de construire le semainier */
10
+ $helper = Mage::helper('chronorelais/webservice');
11
+ return $helper->getSearchDeliverySlot($this->getSrdvConfig());
12
+ }
13
+
14
+ public function getSrdvConfig() {
15
+ $carrierModel = $this->getCarrierModel();
16
+ return Mage::getStoreConfig('carriers/'.$carrierModel->getCarrierCode().'/rdv_config');
17
+ }
18
+ }
app/code/community/Chronopost/Chronorelais/Block/Checkout/Onepage/Shipping/Method/Chronorelais.php CHANGED
@@ -38,22 +38,23 @@ class Chronopost_Chronorelais_Block_Checkout_Onepage_Shipping_Method_Chronorelai
38
  protected $_chronorelais;
39
 
40
  public function getChronorelais() {
41
- if (empty($this->_chronorelais)) {
42
- $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
43
- $address = $quote->getShippingAddress();
44
- $postcode = $address->getPostcode();
45
- $helper = Mage::helper('chronorelais/webservice');
46
- $params = $this->getRequest()->getParams();
47
- if(isset($params['mappostalcode']))
48
- {
49
- $webservbt = $helper->getPointsRelaisByCp($params['mappostalcode']);
50
- }
51
- else
52
- {
53
- $webservbt = $helper->getPointRelaisByAddress();
54
  }
55
- $this->_chronorelais = $webservbt;
56
  }
 
57
 
58
  return $this->_chronorelais;
59
  }
38
  protected $_chronorelais;
39
 
40
  public function getChronorelais() {
41
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
42
+ $helper = Mage::helper('chronorelais/webservice');
43
+ $params = $this->getRequest()->getParams();
44
+ if(isset($params['mappostalcode']))
45
+ {
46
+ $webservbt = $helper->getPointsRelaisByCp($params['mappostalcode']);
47
+ }
48
+ else
49
+ {
50
+ $shippingMethodCode = '';
51
+ if(isset($params['shipping_method'])) {
52
+ $shippingMethodCode = explode("_", $params['shipping_method']);
53
+ $shippingMethodCode = $shippingMethodCode[0];
54
  }
55
+ $webservbt = $helper->getPointRelaisByAddress($shippingMethodCode);
56
  }
57
+ $this->_chronorelais = $webservbt;
58
 
59
  return $this->_chronorelais;
60
  }
app/code/community/Chronopost/Chronorelais/Block/Detail.php CHANGED
@@ -1,29 +1,18 @@
1
  <?php
2
  class Chronopost_Chronorelais_Block_Detail extends Mage_Core_Block_Template
3
  {
 
4
 
5
- public function _prepareLayout()
6
- {
7
- return parent::_prepareLayout();
8
- }
9
 
10
- public function getRelaisPoint(){
11
-
12
-
13
  $btcode = $this->getRequest()->getParam ( 'btcode' );
14
 
15
  if($btcode){
16
- $result = Mage::getModel('shipping/rate_result');
17
- ini_set("soap.wsdl_cache_enabled", "0");
18
- $helper = Mage::helper('chronorelais/webservice');
19
- $webservbt = $helper->getDetailRelaisPoint($btcode);
20
-
21
- return $webservbt;
22
- }
23
- else{
24
- return false;
25
  }
 
26
  }
27
-
28
  }
29
  ?>
1
  <?php
2
  class Chronopost_Chronorelais_Block_Detail extends Mage_Core_Block_Template
3
  {
4
+ public function getRelaisPoint(){
5
 
 
 
 
 
6
 
 
 
 
7
  $btcode = $this->getRequest()->getParam ( 'btcode' );
8
 
9
  if($btcode){
10
+ $result = Mage::getModel('shipping/rate_result');
11
+ ini_set("soap.wsdl_cache_enabled", "0");
12
+ $helper = Mage::helper('chronorelais/webservice');
13
+ return $helper->getDetailRelaisPoint($btcode);
 
 
 
 
 
14
  }
15
+ return false;
16
  }
 
17
  }
18
  ?>
app/code/community/Chronopost/Chronorelais/Block/Export/Orders/Grid.php CHANGED
@@ -1,270 +1,278 @@
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(new Zend_Db_Expr("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
- }
 
 
 
 
 
 
 
 
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) {
30
+ $_chronopost_deliver_saturday = 'Yes';
31
+ } else {
32
+ $_chronopost_deliver_saturday = 'No';
33
+ }
34
+ if($_chronorelais_deliver_saturday==1) {
35
+ $_chronorelais_deliver_saturday = 'Yes';
36
+ } else {
37
+ $_chronorelais_deliver_saturday = 'No';
38
+ }
39
+
40
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
41
+ $collection->join('order', 'main_table.entity_id = order.entity_id', 'shipping_description');
42
+ $collection->join('order_payment', 'main_table.entity_id = order_payment.parent_id', 'method');
43
+ $collection->getSelect()->joinLeft(array('oes' => Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status')), 'main_table.entity_id = oes.order_id', array(new Zend_Db_Expr("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")));
44
+ $collection->getSelect()->where('order.shipping_method LIKE "chronorelais%" OR order.shipping_method LIKE "chronopost%" OR order.shipping_method LIKE "chronoexpress%"');
45
+
46
+ $this->setCollection($collection);
47
+ return parent::_prepareCollection();
48
+ }
49
+
50
+ protected function _addColumnFilterToCollection($column)
51
+ {
52
+ if ($this->getCollection()) {
53
+ $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
54
+ if ($column->getFilterConditionCallback()) {
55
+ call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
56
+ } else {
57
+ $cond = $column->getFilter()->getCondition();
58
+ if ($field && isset($cond)) {
59
+ // Le champ status est ambigu, il faut donc sp�cifier sa table lors de l'ajout pour filtrage
60
+ $this->getCollection()->addFieldToFilter($field == "status" ? "main_table.status" : $field, $cond);
61
+ }
62
+ }
63
+ }
64
+ return $this;
65
+ }
66
+
67
+ protected function _prepareColumns()
68
+ {
69
+
70
+ $this->addColumn('real_order_id', array(
71
+ 'header'=> Mage::helper('sales')->__('Order #'),
72
+ 'width' => '80px',
73
+ 'type' => 'text',
74
+ 'index' => 'increment_id',
75
+ 'filter' => false,
76
+ ));
77
+
78
+ if (!Mage::app()->isSingleStoreMode()) {
79
+ $this->addColumn('store_id', array(
80
+ 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
81
+ 'index' => 'store_id',
82
+ 'type' => 'store',
83
+ 'store_view'=> true,
84
+ 'display_deleted' => true,
85
+ 'filter' => false,
86
+ ));
87
+ }
88
+
89
+ $this->addColumn('created_at', array(
90
+ 'header' => Mage::helper('sales')->__('Purchased On'),
91
+ 'index' => 'created_at',
92
+ 'type' => 'datetime',
93
+ 'width' => '100px',
94
+ 'filter' => false,
95
+ ));
96
+
97
+ $this->addColumn('billing_name', array(
98
+ 'header' => Mage::helper('sales')->__('Bill to Name'),
99
+ 'index' => 'billing_name',
100
+ 'filter' => false,
101
+ ));
102
+
103
+ $this->addColumn('shipping_name', array(
104
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
105
+ 'index' => 'shipping_name',
106
+ 'filter' => false,
107
+ ));
108
+
109
+ $this->addColumn('base_grand_total', array(
110
+ 'header' => Mage::helper('sales')->__('G.T. (Base)'),
111
+ 'index' => 'base_grand_total',
112
+ 'type' => 'currency',
113
+ 'currency' => 'base_currency_code',
114
+ 'filter' => false,
115
+ ));
116
+
117
+ $this->addColumn('grand_total', array(
118
+ 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
119
+ 'index' => 'grand_total',
120
+ 'type' => 'currency',
121
+ 'currency' => 'order_currency_code',
122
+ 'filter' => false,
123
+ ));
124
+
125
+ $this->addColumn('shipping_description', array(
126
+ 'header'=> Mage::helper('sales')->__('Shipping Method'),
127
+ 'width' => '80px',
128
+ 'type' => 'text',
129
+ 'index' => 'shipping_description',
130
+ 'filter' => false,
131
+ 'truncate' => 30,
132
+ 'escape' => true,
133
+ ));
134
+
135
+ $this->addColumn('payment', array(
136
+ 'header' => Mage::helper('sales')->__('Mode de Paiement'),
137
+ 'index' => 'method',
138
+ 'width' => '100px',
139
+ 'type' => 'text',
140
+ 'filter' => false,
141
+ ));
142
+
143
+ if(Mage::helper('chronorelais')->isSendingDay()) {
144
+ $this->addColumn('livraison_le_samedi', array(
145
+ 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
146
+ 'index' => 'livraison_le_samedi',
147
+ 'width' => '100px',
148
+ 'class' => 'a-center',
149
+ 'filter' => false,
150
+ ));
151
+ }
152
+
153
+ $this->addColumn('status', array(
154
+ 'header' => Mage::helper('sales')->__('Status'),
155
+ 'index' => 'status',
156
+ 'type' => 'options',
157
+ 'width' => '70px',
158
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
159
+ ));
160
+
161
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
162
+ $this->addColumn('action',
163
+ array(
164
+ 'header' => Mage::helper('sales')->__('Action'),
165
+ 'width' => '50px',
166
+ 'type' => 'action',
167
+ 'getter' => 'getId',
168
+ 'actions' => array(
169
+ array(
170
+ 'caption' => Mage::helper('sales')->__('View'),
171
+ 'url' => array('base'=>'adminhtml/sales_order/view'),
172
+ 'field' => 'order_id'
173
+ )
174
+ ),
175
+ 'filter' => false,
176
+ 'sortable' => false,
177
+ 'index' => 'stores',
178
+ 'is_system' => true,
179
+ ));
180
+ }
181
+
182
+ return parent::_prepareColumns();
183
+ }
184
+
185
+ protected function _prepareMassaction111()
186
+ {
187
+ $this->setMassactionIdField('entity_id');
188
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
189
+ $this->getMassactionBlock()->setUseSelectAll(false);
190
+
191
+ $this->getMassactionBlock()->addItem('export_css', array(
192
+ 'label'=> Mage::helper('chronorelais')->__('Export CSS'),
193
+ 'url' => $this->getUrl('*/*/exportcss'),
194
+ ));
195
+ $this->getMassactionBlock()->addItem('export_cso', array(
196
+ 'label'=> Mage::helper('chronorelais')->__('Export CSO'),
197
+ 'url' => $this->getUrl('*/*/exportcso'),
198
+ ));
199
+
200
+ return $this;
201
+ }
202
+
203
+ protected function _prepareMassaction()
204
+ {
205
+ $this->setMassactionIdField('entity_id');
206
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
207
+ $this->getMassactionBlock()->setUseSelectAll(false);
208
+
209
+ if(Mage::helper('chronorelais')->isSendingDay()) {
210
+ $shipping = array(
211
+ 'Yes' => Mage::helper('chronorelais')->__('Yes'),
212
+ 'No' => Mage::helper('chronorelais')->__('No'));
213
+ $this->getMassactionBlock()->addItem('shipping', array(
214
+ 'label' => Mage::helper('chronorelais')->__('Livraison le Samedi'),
215
+ 'url' => $this->getUrl('*/*/massLivraisonSamediStatus', array('_current'=>true)),
216
+ 'additional' => array(
217
+ 'visibility' => array(
218
+ 'name' => 'status',
219
+ 'type' => 'select',
220
+ 'class' => 'required-entry',
221
+ 'style' => 'width:80px',
222
+ 'label' => Mage::helper('chronorelais')->__('Status'),
223
+ 'values' => $shipping
224
+ )
225
+ )
226
+ ));
227
+ }
228
+
229
+ $export = array(
230
+ 'css' => Mage::helper('chronorelais')->__('CSS Format'),
231
+ 'cso' => Mage::helper('chronorelais')->__('CSO Format'));
232
+ array_unshift($export, array('label'=>'', 'value'=>''));
233
+ $this->getMassactionBlock()->addItem('export', array(
234
+ 'label'=> Mage::helper('chronorelais')->__('Export'),
235
+ 'url' => $this->getUrl('*/*/massExport', array('_current'=>true)),
236
+ 'additional' => array(
237
+ 'visibility' => array(
238
+ 'name' => 'format',
239
+ 'type' => 'select',
240
+ 'class' => 'required-entry',
241
+ 'label' => Mage::helper('chronorelais')->__('Format'),
242
+ 'values' => $export
243
+ )
244
+ )
245
+ ));
246
+ return $this;
247
+ }
248
+
249
+ public function getRowUrl($row)
250
+ {
251
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
252
+ return $this->getUrl('adminhtml/sales_order/view', array('order_id' => $row->getId()));
253
+ }
254
+ return false;
255
+ }
256
+
257
+ public function getGridUrl()
258
+ {
259
+ return $this->getUrl('*/*/*', array('_current'=>true));
260
+ }
261
+
262
+ public function getAdditionalJavaScript()
263
+ {
264
+ echo "
265
+ var element = document.getElementById('chronorelais_export_order_grid_massaction-select');
266
+ element.selectedIndex = 1;
267
+ if ('fireEvent' in element)
268
+ element.fireEvent('onchange');
269
+ else
270
+ {
271
+ var evt = document.createEvent('HTMLEvents');
272
+ evt.initEvent('change', false, true);
273
+ element.dispatchEvent(evt);
274
+ }
275
+ ";
276
+ }
277
+
278
+ }
app/code/community/Chronopost/Chronorelais/Block/Filter.php CHANGED
@@ -1,44 +1,29 @@
1
  <?php
2
  class Chronopost_Chronorelais_Block_Filter extends Mage_Core_Block_Template
3
  {
4
-
5
- public function _prepareLayout()
6
- {
7
- return parent::_prepareLayout();
8
- }
9
-
10
-
11
  public function getRelaisPoints(){
12
-
13
  $zipcode = $this->getRequest()->getParam ( 'zipcode' );
14
 
15
  if( $zipcode && $zipcode!="" ){
16
- $result = Mage::getModel('shipping/rate_result');
17
- $helper = Mage::helper('chronorelais/webservice');
18
- $webservbt = $helper->getPointsRelaisByCp($zipcode);
19
-
20
- return $webservbt;
21
- }
22
- else{
23
- return false;
24
  }
 
25
  }
26
 
27
  public function getmethodeCode(){
28
-
29
  $zipcode = $this->getRequest()->getParam ( 'methodecode' );
30
 
31
  if($zipcode){
32
- $result = Mage::getModel('shipping/rate_result');
33
  ini_set("soap.wsdl_cache_enabled", "0");
34
- $helper = Mage::helper('chronorelais/webservice');
35
- $webservbt = $helper->getPointsRelaisByCp($zipcode);
36
- return $webservbt;
37
- }
38
- else{
39
- return false;
40
  }
 
41
  }
42
-
43
  }
44
  ?>
1
  <?php
2
  class Chronopost_Chronorelais_Block_Filter extends Mage_Core_Block_Template
3
  {
 
 
 
 
 
 
 
4
  public function getRelaisPoints(){
5
+
6
  $zipcode = $this->getRequest()->getParam ( 'zipcode' );
7
 
8
  if( $zipcode && $zipcode!="" ){
9
+ $result = Mage::getModel('shipping/rate_result');
10
+ $helper = Mage::helper('chronorelais/webservice');
11
+ return $helper->getPointsRelaisByCp($zipcode);
 
 
 
 
 
12
  }
13
+ return false;
14
  }
15
 
16
  public function getmethodeCode(){
17
+
18
  $zipcode = $this->getRequest()->getParam ( 'methodecode' );
19
 
20
  if($zipcode){
21
+ $result = Mage::getModel('shipping/rate_result');
22
  ini_set("soap.wsdl_cache_enabled", "0");
23
+ $helper = Mage::helper('chronorelais/webservice');
24
+ return $helper->getPointsRelaisByCp($zipcode);
 
 
 
 
25
  }
26
+ return false;
27
  }
 
28
  }
29
  ?>
app/code/community/Chronopost/Chronorelais/Block/Sales/Bordereau/Grid.php CHANGED
@@ -1,162 +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
- $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(new Zend_Db_Expr('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(new Zend_Db_Expr('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(new Zend_Db_Expr("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
  }
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(new Zend_Db_Expr('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(new Zend_Db_Expr('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(new Zend_Db_Expr("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 (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,28 +1,28 @@
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('adminhtml/chronorelais_sales_impression/print', array(
25
- 'shipment_id' => $this->getShipment()->getId()
26
- ));
27
- }
28
  }
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('adminhtml/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,254 +1,259 @@
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(new Zend_Db_Expr('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(new Zend_Db_Expr('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(new Zend_Db_Expr("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' => '*/*/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' => '*/*/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
- }
 
 
 
 
 
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(new Zend_Db_Expr('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(new Zend_Db_Expr('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(new Zend_Db_Expr("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 (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' => '*/*/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' => '*/*/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
+ $this->getMassactionBlock()->addItem('cancel', array(
182
+ 'label' => Mage::helper('chronorelais')->__('Annuler les étiquettes'),
183
+ 'url' => $this->getUrl('*/*/cancelMass', array('_current' => true)),
184
+ ));
185
+
186
+ $cmd = Mage::helper('chronorelais')->getConfigData('chronorelais/shipping/gs_path')." -v";
187
+ $res_shell = shell_exec($cmd);
188
+ if($res_shell !== null) {
189
+ $this->getMassactionBlock()->addItem('print', array(
190
+ 'label' => Mage::helper('chronorelais')->__('Imprimer les étiquettes'),
191
+ 'url' => $this->getUrl('*/*/printMass', array('_current' => true)),
192
+ ));
193
+ }
194
+
195
+ if (Mage::helper('chronorelais')->isSendingDay()) {
196
+
197
+ $shipping = array(
198
+ 'Yes' => Mage::helper('chronorelais')->__('Yes'),
199
+ 'No' => Mage::helper('chronorelais')->__('No'));
200
+ $this->getMassactionBlock()->addItem('shipping', array(
201
+ 'label' => Mage::helper('chronorelais')->__('Livraison le Samedi'),
202
+ 'url' => $this->getUrl('*/*/massLivraisonSamediStatus', array('_current' => true)),
203
+ 'additional' => array(
204
+ 'visibility' => array(
205
+ 'name' => 'status',
206
+ 'type' => 'select',
207
+ 'class' => 'required-entry',
208
+ 'style' => 'width:80px',
209
+ 'label' => Mage::helper('chronorelais')->__('Status'),
210
+ 'values' => $shipping
211
+ )
212
+ )
213
+ ));
214
+ }
215
+ return $this;
216
+ }
217
+
218
+ public function getGridUrl() {
219
+ return $this->getUrl('*/*/*', array('_current' => true));
220
+ }
221
+
222
+ public function getAdditionalJavaScript() {
223
+ echo "
224
+ var tds = $$('#sales_order_grid_table tr td.shipment_ids');
225
+ tds.each(function(item) {
226
+ var chaine = item.innerHTML.replace(/^\s+/g,'').replace(/\s+$/g,'');
227
+ var lienExpedition = $(item).next('.etiquette_expedition').down('a');
228
+ var lienRetour = $(item).next('.etiquette_retour').down('a');
229
+ if (chaine.split(', ').length > 1) {
230
+ var contentExpedition = '';
231
+ var contentRetour = '';
232
+ var numbers = chaine.split(', ');
233
+ for (var i=0; i<numbers.length; i++) {
234
+ contentExpedition += '<a href=\"' + lienExpedition.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + numbers[i] + '/') + '\">Exp&eacute;dition ' + numbers[i] + '</a><br />';
235
+ contentRetour += '<a href=\"' + lienRetour.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + numbers[i] + '/') + '\" >Retour SAV ' + numbers[i] + '</a><br />';
236
+ }
237
+ lienExpedition.up().innerHTML = contentExpedition;
238
+ if(typeof lienRetour !== 'undefined')
239
+ {
240
+ lienRetour.up().innerHTML = contentRetour;
241
+ }
242
+ }
243
+ else if(chaine.length > 2) {
244
+ lienExpedition.up().innerHTML = '<a href=\"' + lienExpedition.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + chaine + '/') + '\">Exp&eacute;dition</a><br />';
245
+ if(typeof lienRetour !== 'undefined')
246
+ {
247
+ lienRetour.up().innerHTML = '<a href=\"' + lienRetour.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + chaine + '/') + '\" >Retour SAV</a><br />';
248
+ }
249
+ }
250
+ else {
251
+ if(typeof lienRetour !== 'undefined')
252
+ {
253
+ lienRetour.up().innerHTML = '';
254
+ }
255
+ }
256
+ });";
257
+ }
258
+
259
+ }
app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid/Renderer/Retoursav.php CHANGED
@@ -1,28 +1,31 @@
1
- <?php
2
- class Chronopost_Chronorelais_Block_Sales_Shipment_Grid_Renderer_Retoursav
3
- extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
4
- {
5
-
6
- public function render(Varien_Object $row)
7
- {
8
- $actions = $this->getColumn()->getActions();
9
- if ( empty($actions) || !is_array($actions) ) {
10
- return '&nbsp;';
11
- }
12
- $countryId = $row->getShippingAddress()->getCountryId();
13
-
14
- if($countryId != 'FR')
15
- return '';
16
- $out = '';
17
- $i = 0;
18
- foreach ($actions as $action){
19
- if (is_array($action) ) {
20
- if($i > 0)
21
- $out .= '<br />';
22
- $out .= $this->_toLinkHtml($action, $row);
23
- $i++;
24
- }
25
- }
26
- return $out;
27
- }
28
- }
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Sales_Shipment_Grid_Renderer_Retoursav
3
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
4
+ {
5
+
6
+ public function render(Varien_Object $row)
7
+ {
8
+ $actions = $this->getColumn()->getActions();
9
+ if ( empty($actions) || !is_array($actions) ) {
10
+ return '&nbsp;';
11
+ }
12
+ $countryId = $row->getShippingAddress()->getCountryId();
13
+ $shippingMethodCode = strtolower($row->getChronoShippingMethod());
14
+
15
+ if($countryId != 'FR' && strpos($shippingMethodCode, 'chronorelaiseurope') === false) {
16
+ return '';
17
+ }
18
+ $out = '';
19
+ $i = 0;
20
+ foreach ($actions as $action){
21
+ if (is_array($action) ) {
22
+ if($i > 0) {
23
+ $out .= '<br />';
24
+ }
25
+ $out .= $this->_toLinkHtml($action, $row);
26
+ $i++;
27
+ }
28
+ }
29
+ return $out;
30
+ }
31
+ }
app/code/community/Chronopost/Chronorelais/Controller/Abstract.php CHANGED
@@ -29,17 +29,22 @@ class Chronopost_Chronorelais_Controller_Abstract extends Mage_Adminhtml_Control
29
  $args = $message->args;
30
  $message = $message->message;
31
  }
32
-
33
  $output = Mage::helper('shipping')->__($message);
34
- if (count($args)==0) return $output;
 
 
35
 
36
- if (!isset($this->_translate_inline)) $this->_translate_inline = Mage::getSingleton('core/translate')->getTranslateInline();
 
 
37
  if ($this->_translate_inline) {
38
  $parts = explode('}}{{',$output);
39
  $parts[0] = vsprintf($parts[0],$args);
40
  return implode('}}{{',$parts);
 
 
41
  }
42
- else return vsprintf($output,$args);
43
  }
44
 
45
  protected function getIncludingPath($path) {
@@ -81,7 +86,6 @@ class Chronopost_Chronorelais_Controller_Abstract extends Mage_Adminhtml_Control
81
  header('Content-disposition: attachment; filename="'.$filename.'"');
82
  header('Content-Type: application/force-download');
83
  header('Content-Transfer-Encoding: '.$mime_type."\n"); // Surtout ne pas enlever le \n
84
- //header('Content-Length: '.filesize($filename));
85
  header('Pragma: no-cache');
86
  header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
87
  header('Expires: 0');
29
  $args = $message->args;
30
  $message = $message->message;
31
  }
32
+
33
  $output = Mage::helper('shipping')->__($message);
34
+ if (count($args)==0) {
35
+ return $output;
36
+ }
37
 
38
+ if (!isset($this->_translate_inline)) {
39
+ $this->_translate_inline = Mage::getSingleton('core/translate')->getTranslateInline();
40
+ }
41
  if ($this->_translate_inline) {
42
  $parts = explode('}}{{',$output);
43
  $parts[0] = vsprintf($parts[0],$args);
44
  return implode('}}{{',$parts);
45
+ } else {
46
+ return vsprintf($output,$args);
47
  }
 
48
  }
49
 
50
  protected function getIncludingPath($path) {
86
  header('Content-disposition: attachment; filename="'.$filename.'"');
87
  header('Content-Type: application/force-download');
88
  header('Content-Transfer-Encoding: '.$mime_type."\n"); // Surtout ne pas enlever le \n
 
89
  header('Pragma: no-cache');
90
  header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
91
  header('Expires: 0');
app/code/community/Chronopost/Chronorelais/Helper/Conflicts.php CHANGED
@@ -1,161 +1,159 @@
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
-
36
- if(!is_dir($modulePath)) { continue; }
37
-
38
- $dir = new RecursiveDirectoryIterator($modulePath, FilesystemIterator::SKIP_DOTS);
39
- $ite = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::SELF_FIRST);
40
-
41
- // Get config.xml files
42
- $configXmls = new RegexIterator($ite, '/^.+config\.xml$/i', RecursiveRegexIterator::GET_MATCH);
43
-
44
- foreach ($configXmls as $configXml) {
45
- if (self::DEBUG) $result .= '' . $configXml[0] . "\n";
46
-
47
- // Parse XML to look for rewrites
48
- $xml = simplexml_load_file($configXml[0]);
49
- $rewrites = $xml->xpath('//rewrite');
50
-
51
- while(list( , $node) = each($rewrites)) {
52
- $moduleNode = $node->xpath("..");
53
- $moduleName = $moduleNode[0]->getName();
54
-
55
- // Filter route rewrites
56
- if ($moduleName != "global") {
57
- $typeNode = $moduleNode[0]->xpath("..");
58
- $typeName = $typeNode[0]->getName();
59
-
60
- // $result .= "Module : " . $moduleName . "\n";
61
- // $result .= "Type : " . $typeName . "\n";
62
-
63
- foreach ($node->children() as $child) {
64
- $rewriteFrom = "Mage_" . str_replace(" ", "_", ucwords($moduleName . " " . substr($typeName, 0, -1) . " " . str_replace("_", " ", $child->getName())));
65
-
66
- // $result .= "Rewrite from : " . $child->getName() . "\n";
67
- if (self::DEBUG) $result .= "Rewrite from : " . $rewriteFrom . "\n";
68
- if (self::DEBUG) $result .= "Rewrite to : " . $child->__toString() . "\n";
69
-
70
- if (strpos($child->__toString(), "Chronopost_Chronorelais") !== false) {
71
- $scope = "chrono";
72
- } else {
73
- $scope = "other";
74
- }
75
-
76
- if (!isset($this->rewrites[$scope][$typeName][$rewriteFrom])) {
77
- $this->rewrites[$scope][$typeName][$rewriteFrom] = array();
78
- }
79
- $this->rewrites[$scope][$typeName][$rewriteFrom][] = $child->__toString(); // array("class" => $child->__toString());
80
- }
81
- }
82
- }
83
-
84
- if (self::DEBUG) $result .= "\n";
85
- }
86
-
87
- // Get controllers PHP files
88
- $controllerPhps = new RegexIterator($ite, '/^.+controllers.+\.php$/i', RecursiveRegexIterator::GET_MATCH);
89
-
90
- foreach ($controllerPhps as $controllerPhp) {
91
- $className = "";
92
- $scope = "";
93
-
94
- $php_file = file_get_contents($controllerPhp[0]);
95
- $tokens = token_get_all($php_file);
96
- $class_token = false;
97
- $extends_token = false;
98
- foreach ($tokens as $token) {
99
- if (is_array($token)) {
100
- if ($token[0] == T_CLASS) {
101
- $class_token = true;
102
- } else if ($class_token && $token[0] == T_STRING) {
103
- $className = $token[1];
104
- $class_token = false;
105
- } else if ($token[0] == T_EXTENDS) {
106
- $extends_token = true;
107
- } else if ($extends_token && $token[0] == T_STRING) {
108
- if (self::DEBUG) {
109
- $result .= 'File ' . $controllerPhp[0] . ":\n" .
110
- " Class " . $className . "\n" .
111
- " Extends " . $token[1] . "\n\n";
112
- }
113
-
114
- if (empty($scope)) {
115
- if (strpos($className, "Chronopost_Chronorelais") !== false) {
116
- $scope = "chrono";
117
- } else {
118
- $scope = "other";
119
- }
120
- }
121
-
122
- if (!isset($this->rewrites[$scope]["controllers"][$token[1]])) {
123
- $this->rewrites[$scope]["controllers"][$token[1]] = array();
124
- }
125
- $this->rewrites[$scope]["controllers"][$token[1]][] = $className; // array("class" => $className, "file" => $controllerPhp);
126
-
127
- $className = "";
128
- $extends_token = false;
129
- }
130
- }
131
- }
132
-
133
- // $className = str_replace(".php", "", str_replace($modulePath . DS, "", $controllerPhp[0]));
134
- // $classNameArray = explode(DS, $className);
135
- // $className = $classNameArray[0] . '_' . $classNameArray[1] . '_' . $classNameArray[3];
136
-
137
- }
138
- }
139
-
140
- // Parse rewrites table to check for conflicts
141
-
142
- foreach ($this->rewrites['chrono'] as $type => $rewrites) {
143
- foreach ($rewrites as $from => $tos) {
144
- if (!in_array($from, $this->whiteList) && isset($this->rewrites['other'][$type][$from])) {
145
- // Houston, we have a rewrite
146
- // $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";
147
- $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";
148
- }
149
- }
150
- }
151
-
152
- if (empty($result)) {
153
- $result = "Aucun conflit n'a été detecté au niveau des controleurs, des classes de block, des helpers ou des modèles.";
154
- } else {
155
- $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>";
156
- }
157
-
158
- return $result;
159
- }
160
-
161
- }
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
+
36
+ if(!is_dir($modulePath)) {
37
+ continue;
38
+ }
39
+
40
+ $dir = new RecursiveDirectoryIterator($modulePath, FilesystemIterator::SKIP_DOTS);
41
+ $ite = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::SELF_FIRST);
42
+
43
+ // Get config.xml files
44
+ $configXmls = new RegexIterator($ite, '/^.+config\.xml$/i', RecursiveRegexIterator::GET_MATCH);
45
+
46
+ foreach ($configXmls as $configXml) {
47
+ if (self::DEBUG) {
48
+ $result .= '' . $configXml[0] . "\n";
49
+ }
50
+
51
+ // Parse XML to look for rewrites
52
+ $xml = simplexml_load_file($configXml[0]);
53
+ $rewrites = $xml->xpath('//rewrite');
54
+
55
+ while(list( , $node) = each($rewrites)) {
56
+ $moduleNode = $node->xpath("..");
57
+ $moduleName = $moduleNode[0]->getName();
58
+
59
+ // Filter route rewrites
60
+ if ($moduleName != "global") {
61
+ $typeNode = $moduleNode[0]->xpath("..");
62
+ $typeName = $typeNode[0]->getName();
63
+
64
+ foreach ($node->children() as $child) {
65
+ $rewriteFrom = "Mage_" . str_replace(" ", "_", ucwords($moduleName . " " . substr($typeName, 0, -1) . " " . str_replace("_", " ", $child->getName())));
66
+
67
+ if (self::DEBUG) {
68
+ $result .= "Rewrite from : " . $rewriteFrom . "\n";
69
+ $result .= "Rewrite to : " . $child->__toString() . "\n";
70
+ }
71
+
72
+ if (strpos($child->__toString(), "Chronopost_Chronorelais") !== false) {
73
+ $scope = "chrono";
74
+ } else {
75
+ $scope = "other";
76
+ }
77
+
78
+ if (!isset($this->rewrites[$scope][$typeName][$rewriteFrom])) {
79
+ $this->rewrites[$scope][$typeName][$rewriteFrom] = array();
80
+ }
81
+ $this->rewrites[$scope][$typeName][$rewriteFrom][] = $child->__toString();
82
+ }
83
+ }
84
+ }
85
+
86
+ if (self::DEBUG) {
87
+ $result .= "\n";
88
+ }
89
+ }
90
+
91
+ // Get controllers PHP files
92
+ $controllerPhps = new RegexIterator($ite, '/^.+controllers.+\.php$/i', RecursiveRegexIterator::GET_MATCH);
93
+
94
+ foreach ($controllerPhps as $controllerPhp) {
95
+ $className = "";
96
+ $scope = "";
97
+
98
+ $php_file = file_get_contents($controllerPhp[0]);
99
+ $tokens = token_get_all($php_file);
100
+ $class_token = false;
101
+ $extends_token = false;
102
+ foreach ($tokens as $token) {
103
+ if (is_array($token)) {
104
+ if ($token[0] == T_CLASS) {
105
+ $class_token = true;
106
+ } else if ($class_token && $token[0] == T_STRING) {
107
+ $className = $token[1];
108
+ $class_token = false;
109
+ } else if ($token[0] == T_EXTENDS) {
110
+ $extends_token = true;
111
+ } else if ($extends_token && $token[0] == T_STRING) {
112
+ if (self::DEBUG) {
113
+ $result .= 'File ' . $controllerPhp[0] . ":\n" .
114
+ " Class " . $className . "\n" .
115
+ " Extends " . $token[1] . "\n\n";
116
+ }
117
+
118
+ if (empty($scope)) {
119
+ if (strpos($className, "Chronopost_Chronorelais") !== false) {
120
+ $scope = "chrono";
121
+ } else {
122
+ $scope = "other";
123
+ }
124
+ }
125
+
126
+ if (!isset($this->rewrites[$scope]["controllers"][$token[1]])) {
127
+ $this->rewrites[$scope]["controllers"][$token[1]] = array();
128
+ }
129
+ $this->rewrites[$scope]["controllers"][$token[1]][] = $className;
130
+
131
+ $className = "";
132
+ $extends_token = false;
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+
139
+ // Parse rewrites table to check for conflicts
140
+
141
+ foreach ($this->rewrites['chrono'] as $type => $rewrites) {
142
+ foreach ($rewrites as $from => $tos) {
143
+ if (!in_array($from, $this->whiteList) && isset($this->rewrites['other'][$type][$from])) {
144
+ // Houston, we have a rewrite
145
+ $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";
146
+ }
147
+ }
148
+ }
149
+
150
+ if (empty($result)) {
151
+ $result = "Aucun conflit n'a été detecté au niveau des controleurs, des classes de block, des helpers ou des modèles.";
152
+ } else {
153
+ $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>";
154
+ }
155
+
156
+ return $result;
157
+ }
158
+
159
+ }
 
 
app/code/community/Chronopost/Chronorelais/Helper/Data.php CHANGED
@@ -1,350 +1,463 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
24
+ const CHRONORELAISEUROPE = '49'; // for Chronorelais Europe
25
+ const CHRONORELAISEUROPE_STR = 'PRU'; // for Chronorelais Europe
26
+
27
+ const CHRONORELAISDOM = '4P'; // for Chronorelais DOM
28
+ const CHRONORELAISDOM_STR = 'PRDOM'; // for Chronorelais DOM
29
+
30
+ const CHRONOPOST_SMD = '4I'; // for Chronopost SAMEDAY
31
+ const CHRONOPOST_SMD_STR = 'SMD'; // for Chronopost SAMEDAY
32
+
33
+ const CHRONOPOST_SRDV = '2O'; // for Chronopost Sur Rendez-vous 'O' majuscule et non 0
34
+ const CHRONOPOST_SRDV_STR = 'SRDV'; // for Chronopost Sur Rendez-vous
35
+
36
+ // if you are in a period outside thursday 18:00 to friday 15:00, there is no shipping on saturday
37
+ var $SaturdayShippingDays = array(
38
+ 'startday' => 'thursday',
39
+ 'endday' => 'friday',
40
+ 'starttime' => '18:00:00',
41
+ 'endtime' => '15:00:00'
42
+ );
43
+
44
+ public function getConfigData($path) {
45
+ return Mage::getStoreConfig($path, Mage::app()->getStore());
46
+ }
47
+
48
+ public function getSaturdayShippingDays() {
49
+
50
+ $starday = explode(":",$this->getConfigData("chronorelais/saturday/startday"));
51
+ $endday = explode(":",$this->getConfigData("chronorelais/saturday/endday"));
52
+
53
+ $saturdayDays = array();
54
+ $saturdayDays['startday'] = (count($starday) == 3 && isset($starday[0])) ? $starday[0] : $this->SaturdayShippingDays['startday'];
55
+ $saturdayDays['starttime'] = (count($starday) == 3 && isset($starday[1])) ? $starday[1].':'.$starday[2].':00' : $this->SaturdayShippingDays['starttime'];
56
+ $saturdayDays['endday'] = (count($endday) == 3 && isset($endday[0])) ? $endday[0] : $this->SaturdayShippingDays['endday'];
57
+ $saturdayDays['endtime'] = (count($endday) == 3 && isset($endday[1])) ? $endday[1].':'.$endday[2].':00' : $this->SaturdayShippingDays['endtime'];
58
+
59
+ return $saturdayDays;
60
+ }
61
+
62
+ public function getCurrentTimeByZone($timezone="Europe/Paris", $format="l H:i") {
63
+ $d = new DateTime("now", new DateTimeZone($timezone));
64
+ return $d->format($format);
65
+ }
66
+
67
+ public function isSendingDay() {
68
+ $shipping_days = $this->getSaturdayShippingDays();
69
+ $current_day = strtolower($this->getCurrentTimeByZone("Europe/Paris", "l"));
70
+ $current_date = $this->getCurrentTimeByZone("Europe/Paris", "Y-m-d H:i:s");
71
+ $current_datetime = explode(' ', $current_date);
72
+
73
+ //get timestamps
74
+ $start_timestamp = strtotime($current_datetime[0] . " " . $shipping_days['starttime']);
75
+ $end_timestamp = strtotime($current_datetime[0] . " " . $shipping_days['endtime']);
76
+ $current_timestamp = strtotime($current_date);
77
+
78
+ $sending_day = false;
79
+ /*if ( ($shipping_days['startday'] == $current_day && $current_timestamp >= $start_timestamp) || ($shipping_days['endday'] == $current_day && $current_timestamp <= $end_timestamp) ) {
80
+ $sending_day = true;
81
+ }*/
82
+ if ( $current_timestamp >= $start_timestamp && $current_timestamp <= $end_timestamp ) {
83
+ $sending_day = true;
84
+ }
85
+ return $sending_day;
86
+ }
87
+
88
+ /**
89
+ * General Shipping configuration
90
+ */
91
+ public function getConfigurationAccountNumber() {
92
+ return $this->getConfigData('chronorelais/shipping/account_number');
93
+ }
94
+
95
+ public function getConfigurationSubAccountNumber() {
96
+ return $this->getConfigData('chronorelais/shipping/sub_account_number');
97
+ }
98
+
99
+ public function getConfigurationAccountPass() {
100
+ return $this->getConfigData('chronorelais/shipping/account_pass');
101
+ }
102
+
103
+ public function getConfigurationTrackingViewUrl() {
104
+ return $this->getConfigData('chronorelais/shipping/tracking_view_url');
105
+ }
106
+
107
+ public function getConfigurationGoogleMapAPIKey() {
108
+ return $this->getConfigData('chronorelais/shipping/google_map_api');
109
+ }
110
+
111
+ public function getChronoProductCode($country, $code='') {
112
+ $productcode = '';
113
+ $code = strtolower($code);
114
+
115
+ switch($code) {
116
+ case 'chronorelais' :
117
+ $productcode = static::CHRONORELAIS;
118
+ break;
119
+ case 'chronopost' :
120
+ $productcode = static::CHRONO_POST;
121
+ break;
122
+ case 'chronoexpress' :
123
+ $productcode = static::CHRONO_EXPRESS;
124
+ break;
125
+ case 'chronopostc10' :
126
+ $productcode = static::CHRONOPOST_C10;
127
+ break;
128
+ case 'chronopostc18' :
129
+ $productcode = static::CHRONOPOST_C18;
130
+ break;
131
+ case 'chronopostcclassic' :
132
+ $productcode = static::CHRONOPOST_CClassic;
133
+ break;
134
+ case 'chronorelaiseurope' :
135
+ $productcode = static::CHRONORELAISEUROPE;
136
+ break;
137
+ case 'chronorelaisdom' :
138
+ $productcode = static::CHRONORELAISDOM;
139
+ break;
140
+ case 'chronopostsameday' :
141
+ $productcode = static::CHRONOPOST_SMD;
142
+ break;
143
+ case 'chronopostsrdv' :
144
+ $productcode = static::CHRONOPOST_SRDV;
145
+ break;
146
+ default :
147
+ $productcode = static::CHRONO_POST;
148
+ break;
149
+ }
150
+ return $productcode;
151
+ }
152
+
153
+ public function getChronoProductCodeToShipment($code='') {
154
+ $productcode = '';
155
+ $code = strtolower($code);
156
+
157
+ switch($code) {
158
+ case 'chronorelais' :
159
+ $productcode = static::CHRONORELAIS;
160
+ break;
161
+ case 'chronopost' :
162
+ if($this->getConfigOptionBAL()) {
163
+ $productcode = static::CHRONO_POST_BAL;
164
+ }
165
+ else {
166
+ $productcode = static::CHRONO_POST;
167
+ }
168
+ break;
169
+ case 'chronoexpress' :
170
+ $productcode = static::CHRONO_EXPRESS;
171
+ break;
172
+ case 'chronopostc10' :
173
+ $productcode = static::CHRONOPOST_C10;
174
+ break;
175
+ case 'chronopostc18' :
176
+ if($this->getConfigOptionBAL()) {
177
+ $productcode = static::CHRONOPOST_C18_BAL;
178
+ }
179
+ else {
180
+ $productcode = static::CHRONOPOST_C18;
181
+ }
182
+ break;
183
+ case 'chronopostcclassic' :
184
+ $productcode = static::CHRONOPOST_CClassic;
185
+ break;
186
+ case 'chronorelaiseurope' :
187
+ $productcode = static::CHRONORELAISEUROPE;
188
+ break;
189
+ case 'chronorelaisdom' :
190
+ $productcode = static::CHRONORELAISDOM;
191
+ break;
192
+ case 'chronopostsameday' :
193
+ $productcode = static::CHRONOPOST_SMD;
194
+ break;
195
+ case 'chronopostsrdv' :
196
+ $productcode = static::CHRONOPOST_SRDV;
197
+ break;
198
+ default :
199
+ $productcode = static::CHRONO_POST;
200
+ break;
201
+ }
202
+ return $productcode;
203
+ }
204
+
205
+ public function getChronoProductCodeString($code='') {
206
+ $productcode = '';
207
+ $code = strtolower($code);
208
+
209
+ switch($code) {
210
+ case 'chronorelais' :
211
+ $productcode = static::CHRONORELAIS_PR;
212
+ break;
213
+ case 'chronopost' :
214
+ $productcode = static::CHRONOPOST_13H;
215
+ break;
216
+ case 'chronoexpress' :
217
+ $productcode = static::CHRONOEXPRESS_EI;
218
+ break;
219
+ case 'chronopostc10' :
220
+ $productcode = static::CHRONOPOST_C10_STR;
221
+ break;
222
+ case 'chronopostc18' :
223
+ $productcode = static::CHRONOPOST_C18_STR;
224
+ break;
225
+ case 'chronopostcclassic' :
226
+ $productcode = static::CHRONOPOST_CClassic_STR;
227
+ break;
228
+ case 'chronorelaiseurope' :
229
+ $productcode = static::CHRONORELAISEUROPE_STR;
230
+ break;
231
+ case 'chronorelaisdom' :
232
+ $productcode = static::CHRONORELAISDOM_STR;
233
+ break;
234
+ case 'chronopostsameday' :
235
+ $productcode = static::CHRONOPOST_SMD_STR;
236
+ break;
237
+ case 'chronopostsrdv' :
238
+ $productcode = static::CHRONOPOST_SRDV_STR;
239
+ break;
240
+ default :
241
+ $productcode = static::CHRONOPOST_13H;
242
+ break;
243
+ }
244
+ return $productcode;
245
+ }
246
+
247
+ public function getChronoProductCodeStringWithBAL($code='') {
248
+ $productcode = '';
249
+ $code = strtolower($code);
250
+
251
+ switch($code) {
252
+ case 'chronorelais' :
253
+ $productcode = static::CHRONORELAIS_PR;
254
+ break;
255
+ case 'chronopost' :
256
+ if($this->getConfigOptionBAL()) {
257
+ $productcode = static::CHRONOPOST_13H_BAL;
258
+ }
259
+ else {
260
+ $productcode = static::CHRONOPOST_13H;
261
+ }
262
+ break;
263
+ case 'chronoexpress' :
264
+ $productcode = static::CHRONOEXPRESS_EI;
265
+ break;
266
+ case 'chronopostc10' :
267
+ $productcode = static::CHRONOPOST_C10_STR;
268
+ break;
269
+ case 'chronopostc18' :
270
+ if($this->getConfigOptionBAL()) {
271
+ $productcode = static::CHRONOPOST_C18_BAL_STR;
272
+ }
273
+ else {
274
+ $productcode = static::CHRONOPOST_C18_STR;
275
+ }
276
+ break;
277
+ case 'chronopostcclassic' :
278
+ $productcode = static::CHRONOPOST_CClassic_STR;
279
+ break;
280
+ case 'chronorelaiseurope' :
281
+ $productcode = static::CHRONORELAISEUROPE_STR;
282
+ break;
283
+ case 'chronorelaisdom' :
284
+ $productcode = static::CHRONORELAISDOM_STR;
285
+ break;
286
+ case 'chronopostsrdv' :
287
+ $productcode = static::CHRONOPOST_SRDV_STR;
288
+ break;
289
+ default :
290
+ $productcode = static::CHRONOPOST_13H;
291
+ break;
292
+ }
293
+ return $productcode;
294
+ }
295
+
296
+ public function getConfigurationTrackingUrl() {
297
+ return static::CHRONOPOST_TRACKING_URL;
298
+ }
299
+
300
+ /**
301
+ * Export configuration
302
+ */
303
+ public function getConfigurationFileExtension($export_type='css') {
304
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/file_extension');
305
+ }
306
+
307
+ public function getConfigurationFileCharset($export_type='css') {
308
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/file_charset');
309
+ }
310
+
311
+ public function getConfigurationEndOfLineCharacter($export_type='css') {
312
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/endofline_character');
313
+ }
314
+
315
+ public function getConfigurationFieldDelimiter($export_type='css') {
316
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/field_delimiter');
317
+ }
318
+
319
+ public function getConfigurationFieldSeparator($export_type='css') {
320
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/field_separator');
321
+ }
322
+
323
+ /**
324
+ * Import configuration
325
+ */
326
+ public function getConfigurationSendEmail() {
327
+ return $this->getConfigData('chronorelais/import/send_email');
328
+ }
329
+
330
+ public function getConfigurationIncludeComment() {
331
+ return $this->getConfigData('chronorelais/import/include_comment');
332
+ }
333
+
334
+ public function getConfigurationDefaultTrackingTitle() {
335
+ return $this->getConfigData('chronorelais/import/default_tracking_title');
336
+ }
337
+
338
+ public function getConfigurationShippingComment() {
339
+ return $this->getConfigData('chronorelais/import/shipping_comment');
340
+ }
341
+
342
+ /**
343
+ * Shipper Information
344
+ */
345
+ public function getConfigurationShipperInfo($field) {
346
+ $fieldValue = '';
347
+ if ($field && $this->getConfigData('chronorelais/shipperinformation/' . $field)) {
348
+ $fieldValue = $this->getConfigData('chronorelais/shipperinformation/' . $field);
349
+ }
350
+ return $fieldValue;
351
+ }
352
+
353
+ /**
354
+ * Chronopost Customer Information
355
+ */
356
+ public function getConfigurationCustomerInfo($field) {
357
+ $fieldValue = '';
358
+ if ($field && $this->getConfigData('chronorelais/customerinformation/' . $field)) {
359
+ $fieldValue = $this->getConfigData('chronorelais/customerinformation/' . $field);
360
+ }
361
+ return $fieldValue;
362
+ }
363
+
364
+ /**
365
+ * Import configuration
366
+ */
367
+ public function getConfigurationSkybillParam() {
368
+ return $this->getConfigData('chronorelais/skybillparam/mode');
369
+ }
370
+
371
+ /*
372
+ * Weight unit
373
+ */
374
+ public function getConfigWeightUnit() {
375
+ return $this->getConfigData('chronorelais/weightunit/unit');
376
+ }
377
+
378
+ /*
379
+ * Option BAL
380
+ */
381
+ public function getConfigOptionBAL() {
382
+ return $this->getConfigData('chronorelais/optionbal/enabled');
383
+ }
384
+
385
+ public function hasOptionBAL($order) {
386
+ $shippingMethod = explode('_',$order->getShippingMethod());
387
+ $shippingMethod = $shippingMethod[1];
388
+ $shippingMethodAllowBAL = array('chronopost','chronopostc18');
389
+ if(in_array(strtolower($shippingMethod), $shippingMethodAllowBAL) && $this->getConfigOptionBAL()) {
390
+ return true;
391
+ }
392
+ return false;
393
+ }
394
+
395
+ /*
396
+ * Assurance Ad Valorem
397
+ */
398
+ public function assuranceAdValoremEnabled() {
399
+ return $this->getConfigData('chronorelais/assurance/enabled');
400
+ }
401
+ public function assuranceAdValoremAmount() {
402
+ return $this->getConfigData('chronorelais/assurance/amount');
403
+ }
404
+ public function getMaxAdValoremAmount() {
405
+ return 20000;
406
+ }
407
+
408
+ /* Get Livraison le Samedi status by orderid */
409
+
410
+ public function getLivraisonSamediStatus($order_id) {
411
+ $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
412
+ $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
413
+ $select = $_connection->select()
414
+ ->from($_table, 'livraison_le_samedi')
415
+ ->where('order_id=?', $order_id);
416
+ $status = $_connection->fetchOne($select);
417
+ return $status;
418
+ }
419
+
420
+
421
+ /*
422
+ * Return true si la méthode de livraison fait partie du contrat du marchant
423
+ */
424
+ public function shippingMethodEnabled($shippingMethod) {
425
+ return true;
426
+ }
427
+
428
+ /*
429
+ * Return true if we can show google map
430
+ */
431
+ public function canShowGoogleMap() {
432
+ return $this->getConfigData('carriers/chronorelais/show_google_map');
433
+ }
434
+
435
+ /* return track number field name */
436
+ public function getTrackNumberFieldName() {
437
+ if (version_compare(Mage::getVersion(), '1.5.1.0', '>')) {
438
+ return "track_number";
439
+ } else {
440
+ return "number";
441
+ }
442
+
443
+ }
444
+
445
+ public function addMargeToQuickcost($quickcost_val,$carrierCode = '', $firstPassage = true) {
446
+ if($carrierCode) {
447
+
448
+ $quickcostMarge = Mage::getStoreConfig('carriers/' . $carrierCode . '/quickcost_marge');
449
+ $quickcostMargeType = Mage::getStoreConfig('carriers/' . $carrierCode . '/quickcost_marge_type');
450
+
451
+ if($quickcostMarge) {
452
+ if($quickcostMargeType == 'amount') {
453
+ $quickcost_val += $quickcostMarge;
454
+ } elseif($quickcostMargeType == 'prcent') {
455
+ $quickcost_val += $quickcost_val * $quickcostMarge / 100;
456
+ }
457
+ }
458
+ }
459
+
460
+ return $quickcost_val;
461
+ }
462
+
463
+ }
app/code/community/Chronopost/Chronorelais/Helper/Webservice.php CHANGED
@@ -1,449 +1,727 @@
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
- $quote = Mage::getSingleton('checkout/cart')->getQuote();
24
- $address = $quote->getShippingAddress();
25
- $helperData = Mage::helper('chronorelais');
26
-
27
- try {
28
- $client = new SoapClient("https://www.chronopost.fr/recherchebt-ws-cxf/PointRelaisServiceWS?wsdl", array('trace' => 0, 'connection_timeout' => 10));
29
-
30
- $params = array(
31
- 'accountNumber' => $helperData->getConfigurationAccountNumber(),
32
- 'password' => $helperData->getConfigurationAccountPass(),
33
- 'address' => $this->getFilledValue($address->getStreet(1)),
34
- 'zipCode' => $this->getFilledValue($address->getPostcode()),
35
- 'city' => $this->getFilledValue($address->getCity()),
36
- 'countryCode' => $this->getFilledValue($address->getCountryId()),
37
- 'type' => 'P',
38
- 'productCode' => '1',
39
- 'service' => 'T',
40
- 'weight' => 2000,
41
- 'shippingDate' => date('d/m/Y'),
42
- 'maxPointChronopost' => 5,
43
- 'maxDistanceSearch' => 15,
44
- 'holidayTolerant' => 1
45
- );
46
- $webservbt = $client->recherchePointChronopost($params);
47
-
48
- /* format $webservbt pour avoir le meme format que lors de l'appel du WS par code postal */
49
- if($webservbt->return->errorCode == 0)
50
- {
51
- /*
52
- * Format entrée
53
- *
54
- * accesPersonneMobiliteReduite
55
- actif
56
- adresse1
57
- adresse2
58
- adresse3
59
- codePays
60
- codePostal
61
- coordGeolocalisationLatitude
62
- coordGeolocalisationLongitude
63
- distanceEnMetre
64
- identifiant
65
- indiceDeLocalisation
66
- listeHoraireOuverture
67
- localite
68
- nom
69
- poidsMaxi
70
- typeDePoint
71
- urlGoogleMaps
72
- *
73
- * Format sortie
74
- * adresse1
75
- adresse2
76
- adresse3
77
- codePostal
78
- dateArriveColis
79
- horairesOuvertureDimanche ("10:00-12:30 14:30-19:00")
80
- horairesOuvertureJeudi
81
- horairesOuvertureLundi
82
- horairesOuvertureMardi
83
- horairesOuvertureMercredi
84
- horairesOuvertureSamedi
85
- horairesOuvertureVendredi
86
- identifiantChronopostPointA2PAS
87
- localite
88
- nomEnseigne
89
- *
90
- *
91
- *
92
- * 2013-02-19T10:42:40.196Z
93
- *
94
- */
95
- $listePr = $webservbt->return->listePointRelais;
96
- if(count($webservbt->return->listePointRelais) == 1) {
97
- $listePr = array($listePr);
98
- }
99
- $return = array();
100
- foreach($listePr as $pr)
101
- {
102
- //$newPr = new object();
103
- $newPr = (object)array();
104
- $newPr->adresse1 = $pr->adresse1;
105
- $newPr->adresse2 = $pr->adresse2;
106
- $newPr->adresse3 = $pr->adresse3;
107
- $newPr->codePostal = $pr->codePostal;
108
- $newPr->identifiantChronopostPointA2PAS = $pr->identifiant;
109
- $newPr->localite = $pr->localite;
110
- $newPr->nomEnseigne = $pr->nom;
111
- $time = new DateTime;
112
- $newPr->dateArriveColis = $time->format(DateTime::ATOM);
113
- $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
114
- foreach($pr->listeHoraireOuverture as $horaire) {
115
- switch($horaire->jour) {
116
- case '1' : $newPr->horairesOuvertureLundi = $horaire->horairesAsString; break;
117
- case '2' : $newPr->horairesOuvertureMardi = $horaire->horairesAsString; break;
118
- case '3' : $newPr->horairesOuvertureMercredi = $horaire->horairesAsString; break;
119
- case '4' : $newPr->horairesOuvertureJeudi = $horaire->horairesAsString; break;
120
- case '5' : $newPr->horairesOuvertureVendredi = $horaire->horairesAsString; break;
121
- case '6' : $newPr->horairesOuvertureSamedi = $horaire->horairesAsString; break;
122
- case '7' : $newPr->horairesOuvertureDimanche = $horaire->horairesAsString; break;
123
- }
124
- }
125
- if(empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
126
- if(empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
127
- if(empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
128
- if(empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
129
- if(empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
130
- if(empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
131
- if(empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
132
-
133
- $return[] = $newPr;
134
- }
135
- return $return;
136
- }
137
- } catch (Exception $e) {
138
- return $this->getPointsRelaisByPudo($address);
139
- }
140
- }
141
-
142
- public function getDetailRelaisPoint($btcode) {
143
- try {
144
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl");
145
- $webservbt = $client->__call("rechercheBtParIdChronopostA2Pas",array($btcode));
146
- return $webservbt[0];
147
- } catch (Exception $e) {
148
- return $this->getDetailRelaisPointByPudo($btcode);
149
- }
150
- }
151
-
152
-
153
- /*
154
- *
155
- * WS de secours
156
- */
157
-
158
- public function getDetailRelaisPointByPudo($btcode) {
159
- $params = array(
160
- 'carrier' => 'CHR',
161
- 'key' => '75f6fe195dc88ceecbc0f8a2f70a8f3a',
162
- 'pudo_id' => $btcode,
163
- );
164
-
165
- try {
166
- $client = new SoapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?wsdl", array('trace' => 0, 'connection_timeout' => 10));
167
- $webservbt = $client->GetPudoDetails($params);
168
- $webservbt = json_decode(json_encode((object) simplexml_load_string($webservbt->GetPudoDetailsResult->any)), 1);
169
- if(!isset($webservbt['ERROR'])) {
170
- $return = array();
171
- $pr = $webservbt['PUDO_ITEMS']['PUDO_ITEM'];
172
- if($pr) {
173
- if($pr['@attributes']['active'] == 'true')
174
- {
175
- $newPr = (object)array();
176
- $newPr->adresse1 = $pr['ADDRESS1'];
177
- $newPr->adresse2 = is_array($pr['ADDRESS2']) ? implode(' ', $pr['ADDRESS2']) : $pr['ADDRESS2'];
178
- $newPr->adresse3 = is_array($pr['ADDRESS3']) ? implode(' ', $pr['ADDRESS3']) : $pr['ADDRESS3'];
179
- $newPr->codePostal = $pr['ZIPCODE'];
180
- $newPr->identifiantChronopostPointA2PAS = $pr['PUDO_ID'];
181
- $newPr->localite = $pr['CITY'];
182
- $newPr->nomEnseigne = $pr['NAME'];
183
- $time = new DateTime;
184
- $newPr->dateArriveColis = $time->format(DateTime::ATOM);
185
- $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
186
-
187
- if(isset($pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'])) {
188
- $listeHoraires = $pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'];
189
- foreach($listeHoraires as $horaire) {
190
- switch($horaire['DAY_ID']) {
191
- case '1' :
192
- if(!empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi .= ' ';
193
- $newPr->horairesOuvertureLundi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
194
- break;
195
- case '2' :
196
- if(!empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi .= ' ';
197
- $newPr->horairesOuvertureMardi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
198
- break;
199
- case '3' :
200
- if(!empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi .= ' ';
201
- $newPr->horairesOuvertureMercredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
202
- break;
203
- case '4' :
204
- if(!empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi .= ' ';
205
- $newPr->horairesOuvertureJeudi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
206
- break;
207
- case '5' :
208
- if(!empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi .= ' ';
209
- $newPr->horairesOuvertureVendredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
210
- break;
211
- case '6' :
212
- if(!empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi .= ' ';
213
- $newPr->horairesOuvertureSamedi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
214
- break;
215
- case '7' :
216
- if(!empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche .= ' ';
217
- $newPr->horairesOuvertureDimanche .= $horaire['START_TM'].'-'.$horaire['END_TM'];
218
- break;
219
- }
220
- }
221
- }
222
- if(empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
223
- if(empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
224
- if(empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
225
- if(empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
226
- if(empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
227
- if(empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
228
- if(empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
229
-
230
- return $newPr;
231
- }
232
- }
233
- }
234
- }
235
- catch (Exception $e) {
236
- return false;
237
- }
238
- return false;
239
- }
240
-
241
- public function getPointsRelaisByPudo($address = '', $cp = '') {
242
-
243
- $params = array(
244
- 'carrier' => 'CHR',
245
- 'key' => '75f6fe195dc88ceecbc0f8a2f70a8f3a',
246
- 'address' => $address ? $this->getFilledValue($address->getStreet(1)) : '',
247
- 'zipCode' => $address ? $this->getFilledValue($address->getPostcode()) : $cp,
248
- 'city' => $address ? $this->getFilledValue($address->getCity()) : 'Lille',
249
- 'countrycode' => $address ? $this->getFilledValue($address->getCountryId()) : '',
250
- 'requestID' => '1',
251
- 'date_from' => date('d/m/Y'),
252
- 'max_pudo_number' => 5,
253
- 'max_distance_search' => 10,
254
- 'weight' => 1,
255
- 'category' => '',
256
- 'holiday_tolerant' => 1,
257
- );
258
- try {
259
- $client = new SoapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?wsdl", array('trace' => 0, 'connection_timeout' => 10));
260
- $webservbt = $client->GetPudoList($params);
261
- $webservbt = json_decode(json_encode((object) simplexml_load_string($webservbt->GetPudoListResult->any)), 1);
262
- if(!isset($webservbt['ERROR'])) {
263
- $return = array();
264
-
265
- $listePr = $webservbt['PUDO_ITEMS']['PUDO_ITEM'];
266
- if($listePr) {
267
- foreach($listePr as $pr)
268
- {
269
- if($pr['@attributes']['active'] == 'true')
270
- {
271
- $newPr = (object)array();
272
- $newPr->adresse1 = $pr['ADDRESS1'];
273
- $newPr->adresse2 = is_array($pr['ADDRESS2']) ? implode(' ', $pr['ADDRESS2']) : $pr['ADDRESS2'];
274
- $newPr->adresse3 = is_array($pr['ADDRESS3']) ? implode(' ', $pr['ADDRESS3']) : $pr['ADDRESS3'];
275
- $newPr->codePostal = $pr['ZIPCODE'];
276
- $newPr->identifiantChronopostPointA2PAS = $pr['PUDO_ID'];
277
- $newPr->localite = $pr['CITY'];
278
- $newPr->nomEnseigne = $pr['NAME'];
279
- $time = new DateTime;
280
- $newPr->dateArriveColis = $time->format(DateTime::ATOM);
281
- $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
282
-
283
- if(isset($pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'])) {
284
- $listeHoraires = $pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'];
285
- foreach($listeHoraires as $horaire) {
286
- switch($horaire['DAY_ID']) {
287
- case '1' :
288
- if(!empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi .= ' ';
289
- $newPr->horairesOuvertureLundi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
290
- break;
291
- case '2' :
292
- if(!empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi .= ' ';
293
- $newPr->horairesOuvertureMardi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
294
- break;
295
- case '3' :
296
- if(!empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi .= ' ';
297
- $newPr->horairesOuvertureMercredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
298
- break;
299
- case '4' :
300
- if(!empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi .= ' ';
301
- $newPr->horairesOuvertureJeudi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
302
- break;
303
- case '5' :
304
- if(!empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi .= ' ';
305
- $newPr->horairesOuvertureVendredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
306
- break;
307
- case '6' :
308
- if(!empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi .= ' ';
309
- $newPr->horairesOuvertureSamedi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
310
- break;
311
- case '7' :
312
- if(!empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche .= ' ';
313
- $newPr->horairesOuvertureDimanche .= $horaire['START_TM'].'-'.$horaire['END_TM'];
314
- break;
315
- }
316
- }
317
- }
318
- if(empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
319
- if(empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
320
- if(empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
321
- if(empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
322
- if(empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
323
- if(empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
324
- if(empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
325
-
326
- $return[] = $newPr;
327
- }
328
- }
329
- return $return;
330
- }
331
- }
332
- }
333
- catch (Exception $e) {
334
- return false;
335
- }
336
- return false;
337
- }
338
-
339
-
340
- public function getQuickcost($quickCost,$quickcost_url = '') {
341
- if (!$quickcost_url) {
342
- //$quickcost_url = "http://wsshipping.chronopost.fr/wsQuickcost/services/ServiceQuickCost?wsdl";
343
- $quickcost_url = "https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl";
344
- }
345
- try {
346
- $client = new SoapClient($quickcost_url);
347
- $webservbt = $client->quickCost($quickCost);
348
-
349
- return $webservbt->return;
350
- } catch (Exception $e) {
351
- return false;
352
- }
353
- }
354
-
355
- public function checkLogin($quickCost,$quickcost_url = '') {
356
- if (!$quickcost_url) {
357
- $quickcost_url = "https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl";
358
- }
359
- try {
360
- $client = new SoapClient($quickcost_url);
361
- $webservbt = $client->calculateProducts($quickCost);
362
- return $webservbt;
363
- } catch (Exception $e) {
364
- return false;
365
- }
366
- }
367
-
368
- /*
369
- * Return true si la méthode de livraison fait partie du contrat
370
- */
371
- public function getMethodIsAllowed($code,$quote = '') {
372
- $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
373
- $address = $quote->getShippingAddress();
374
- $helperData = Mage::helper('chronorelais');
375
- $code = $helperData->getChronoProductCode('',$code);
376
- try {
377
- if($this->methodsAllowed === false) {
378
- $this->methodsAllowed = array();
379
- $client = new SoapClient("https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl", array('trace' => 0, 'connection_timeout' => 10));
380
- $params = array(
381
- 'accountNumber' => $helperData->getConfigurationAccountNumber(),
382
- 'password' => $helperData->getConfigurationAccountPass(),
383
- 'depCountryCode' => $helperData->getConfigurationShipperInfo('country'),
384
- 'depZipCode' => $helperData->getConfigurationShipperInfo('zipcode'),
385
- 'arrCountryCode' => $this->getFilledValue($address->getCountryId()),
386
- 'arrZipCode' => $this->getFilledValue($address->getPostcode()),
387
- 'arrCity' => $this->getFilledValue($address->getCity()),
388
- 'type' => 'M',
389
- 'weight' => 1
390
- );
391
- //print_r($params);
392
- $webservbt = $client->calculateProducts($params);
393
- //print_r($webservbt);
394
- if($webservbt->return->errorCode == 0)
395
- {
396
- /*if($webservbt->return->productList) {
397
- foreach($webservbt->return->productList as $product) {
398
- $this->methodsAllowed[] = $product->productCode;
399
- }
400
- }*/
401
- if($webservbt->return->productList) {
402
- if(is_array($webservbt->return->productList)) {
403
- foreach($webservbt->return->productList as $product) {
404
- $this->methodsAllowed[] = $product->productCode;
405
- }
406
- } else { /* cas ou il y a un seul résultat */
407
- $product = $webservbt->return->productList;
408
- $this->methodsAllowed[] = $product->productCode;
409
- }
410
-
411
- }
412
- }
413
- }
414
- if(!empty($this->methodsAllowed) && in_array($code, $this->methodsAllowed)) {
415
- return true;
416
- }
417
- return false;
418
- }catch(Exception $e) {
419
- return false;
420
- }
421
- }
422
-
423
-
424
-
425
-
426
-
427
-
428
-
429
-
430
-
431
- public function getFilledValue($value) {
432
- if ($value) {
433
- return $this->removeaccents(trim($value));
434
- } else {
435
- return '';
436
- }
437
- }
438
-
439
- public function removeaccents($string) {
440
- $stringToReturn = str_replace(
441
- 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);
442
- // Remove all remaining other unknown characters
443
- $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
444
- $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
445
- $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
446
- $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
447
- return $stringToReturn;
448
- }
449
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ return $client->__call("rechercheBtParCodeproduitEtCodepostalEtDate",array(0,$cp,0));
12
+ } catch (Exception $e) {
13
+ return $this->getPointsRelaisByPudo('',$cp);
14
+ }
15
+ }
16
+
17
+ /* get point relais by address */
18
+ public function getPointRelaisByAddress($shippingMethodCode = 'chronorelais') {
19
+
20
+ if(!$shippingMethodCode) {
21
+ return false;
22
+ }
23
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
24
+ $address = $quote->getShippingAddress();
25
+ $helperData = Mage::helper('chronorelais');
26
+
27
+ try {
28
+
29
+ $pointRelaisWs = 'https://www.chronopost.fr/recherchebt-ws-cxf/PointRelaisServiceWS?wsdl';
30
+ $pointRelaisWsMethod = Mage::getStoreConfig('carriers/'.$shippingMethodCode.'/point_relai_ws_method');
31
+ $pointRelaisProductCode = $helperData->getChronoProductCode($address->getCountryId(),$shippingMethodCode);
32
+ $pointRelaisService = 'T';
33
+ $addAddressToWs = Mage::getStoreConfig('carriers/'.$shippingMethodCode.'/add_address_to_ws');
34
+ $maxPointChronopost = Mage::getStoreConfig('carriers/'.$shippingMethodCode.'/max_point_chronopost');
35
+
36
+ $maxDistanceSearch = Mage::getStoreConfig('carriers/'.$shippingMethodCode.'/max_distance_search');
37
+
38
+ $client = new SoapClient($pointRelaisWs, array('trace' => 0, 'connection_timeout' => 10));
39
+
40
+ /* si dom => on ne met pas le code ISO mais un code spécifique, sinon le relai dom ne fonctionne pas */
41
+ $countryDomCode = $this->getCountryDomCode();
42
+ $countryId = $address->getCountryId();
43
+
44
+ if(isset($countryDomCode[$countryId])) {
45
+ $countryId = $countryDomCode[$countryId];
46
+ }
47
+
48
+ $params = array(
49
+ 'accountNumber' => $helperData->getConfigurationAccountNumber(),
50
+ 'password' => $helperData->getConfigurationAccountPass(),
51
+ 'zipCode' => $this->getFilledValue($address->getPostcode()),
52
+ 'city' => $this->getFilledValue($address->getCity()),
53
+ 'countryCode' => $this->getFilledValue($countryId),
54
+ 'type' => 'P',
55
+ 'productCode' => $pointRelaisProductCode,
56
+ 'service' => $pointRelaisService,
57
+ 'weight' => 2000,
58
+ 'shippingDate' => date('d/m/Y'),
59
+ 'maxPointChronopost' => $maxPointChronopost,
60
+ 'maxDistanceSearch' => $maxDistanceSearch,
61
+ 'holidayTolerant' => 1
62
+ );
63
+ if($addAddressToWs) {
64
+ $params['address'] = $this->getFilledValue($address->getStreet(1));
65
+ }
66
+ $webservbt = $client->$pointRelaisWsMethod($params);
67
+
68
+ /* format $webservbt pour avoir le meme format que lors de l'appel du WS par code postal */
69
+ if($webservbt->return->errorCode == 0)
70
+ {
71
+ /*
72
+ * Format entrée
73
+ *
74
+ * accesPersonneMobiliteReduite
75
+ actif
76
+ adresse1
77
+ adresse2
78
+ adresse3
79
+ codePays
80
+ codePostal
81
+ coordGeolocalisationLatitude
82
+ coordGeolocalisationLongitude
83
+ distanceEnMetre
84
+ identifiant
85
+ indiceDeLocalisation
86
+ listeHoraireOuverture
87
+ localite
88
+ nom
89
+ poidsMaxi
90
+ typeDePoint
91
+ urlGoogleMaps
92
+ *
93
+ * Format sortie
94
+ * adresse1
95
+ adresse2
96
+ adresse3
97
+ codePostal
98
+ dateArriveColis
99
+ horairesOuvertureDimanche ("10:00-12:30 14:30-19:00")
100
+ horairesOuvertureJeudi
101
+ horairesOuvertureLundi
102
+ horairesOuvertureMardi
103
+ horairesOuvertureMercredi
104
+ horairesOuvertureSamedi
105
+ horairesOuvertureVendredi
106
+ identifiantChronopostPointA2PAS
107
+ localite
108
+ nomEnseigne
109
+ *
110
+ *
111
+ *
112
+ * 2013-02-19T10:42:40.196Z
113
+ *
114
+ */
115
+ $listePr = $webservbt->return->listePointRelais;
116
+ if(count($webservbt->return->listePointRelais) == 1) {
117
+ $listePr = array($listePr);
118
+ }
119
+ $return = array();
120
+ foreach($listePr as $pr)
121
+ {
122
+ $newPr = (object)array();
123
+ $newPr->adresse1 = $pr->adresse1;
124
+ $newPr->adresse2 = $pr->adresse2;
125
+ $newPr->adresse3 = $pr->adresse3;
126
+ $newPr->codePostal = $pr->codePostal;
127
+ $newPr->identifiantChronopostPointA2PAS = $pr->identifiant;
128
+ $newPr->localite = $pr->localite;
129
+ $newPr->nomEnseigne = $pr->nom;
130
+ $time = new DateTime;
131
+ $newPr->dateArriveColis = $time->format(DateTime::ATOM);
132
+ $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
133
+ foreach($pr->listeHoraireOuverture as $horaire) {
134
+ switch($horaire->jour) {
135
+ case '1' :
136
+ $newPr->horairesOuvertureLundi = $horaire->horairesAsString;
137
+ break;
138
+ case '2' :
139
+ $newPr->horairesOuvertureMardi = $horaire->horairesAsString;
140
+ break;
141
+ case '3' :
142
+ $newPr->horairesOuvertureMercredi = $horaire->horairesAsString;
143
+ break;
144
+ case '4' :
145
+ $newPr->horairesOuvertureJeudi = $horaire->horairesAsString;
146
+ break;
147
+ case '5' :
148
+ $newPr->horairesOuvertureVendredi = $horaire->horairesAsString;
149
+ break;
150
+ case '6' :
151
+ $newPr->horairesOuvertureSamedi = $horaire->horairesAsString;
152
+ break;
153
+ case '7' :
154
+ $newPr->horairesOuvertureDimanche = $horaire->horairesAsString;
155
+ break;
156
+ default : break;
157
+ }
158
+ }
159
+ if(empty($newPr->horairesOuvertureLundi)) {
160
+ $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
161
+ }
162
+ if(empty($newPr->horairesOuvertureMardi)) {
163
+ $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
164
+ }
165
+ if(empty($newPr->horairesOuvertureMercredi)) {
166
+ $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
167
+ }
168
+ if(empty($newPr->horairesOuvertureJeudi)) {
169
+ $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
170
+ }
171
+ if(empty($newPr->horairesOuvertureVendredi)) {
172
+ $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
173
+ }
174
+ if(empty($newPr->horairesOuvertureSamedi)) {
175
+ $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
176
+ }
177
+ if(empty($newPr->horairesOuvertureDimanche)) {
178
+ $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
179
+ }
180
+
181
+ $return[] = $newPr;
182
+ }
183
+ return $return;
184
+ }
185
+ } catch (Exception $e) {
186
+ return $this->getPointsRelaisByPudo($address);
187
+ }
188
+ }
189
+
190
+ protected function getCountryDomCode() {
191
+ return array(
192
+ 'RE' => 'REU',
193
+ 'MQ' => 'MTQ',
194
+ 'GP' => 'GLP',
195
+ 'MX' => 'MYT',
196
+ 'GF' => 'GUF'
197
+ );
198
+ }
199
+
200
+ public function getDetailRelaisPoint($btcode) {
201
+ try {
202
+ $helperData = Mage::helper('chronorelais');
203
+ $params = array(
204
+ 'accountNumber' => $helperData->getConfigurationAccountNumber(),
205
+ 'password' => $helperData->getConfigurationAccountPass(),
206
+ 'identifiant' => $btcode
207
+ );
208
+
209
+ $client = new SoapClient("https://www.chronopost.fr/recherchebt-ws-cxf/PointRelaisServiceWS");
210
+ $webservbt = $client->__call("rechercheDetailPointChronopost",$params);
211
+
212
+ return $webservbt[0];
213
+ } catch (Exception $e) {
214
+ return $this->getDetailRelaisPointByPudo($btcode);
215
+ }
216
+ }
217
+
218
+
219
+ /*
220
+ *
221
+ * WS de secours
222
+ */
223
+
224
+ public function getDetailRelaisPointByPudo($btcode) {
225
+ $params = array(
226
+ 'carrier' => 'CHR',
227
+ 'key' => '75f6fe195dc88ceecbc0f8a2f70a8f3a',
228
+ 'pudo_id' => $btcode,
229
+ );
230
+
231
+ try {
232
+ $client = new SoapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?wsdl", array('trace' => 0, 'connection_timeout' => 10));
233
+ $webservbt = $client->GetPudoDetails($params);
234
+ $webservbt = json_decode(json_encode((object) simplexml_load_string($webservbt->GetPudoDetailsResult->any)), 1);
235
+ if(!isset($webservbt['ERROR'])) {
236
+ $pr = $webservbt['PUDO_ITEMS']['PUDO_ITEM'];
237
+ if($pr && $pr['@attributes']['active'] == 'true') {
238
+ $newPr = (object)array();
239
+ $newPr->adresse1 = $pr['ADDRESS1'];
240
+ $newPr->adresse2 = is_array($pr['ADDRESS2']) ? implode(' ', $pr['ADDRESS2']) : $pr['ADDRESS2'];
241
+ $newPr->adresse3 = is_array($pr['ADDRESS3']) ? implode(' ', $pr['ADDRESS3']) : $pr['ADDRESS3'];
242
+ $newPr->codePostal = $pr['ZIPCODE'];
243
+ $newPr->identifiantChronopostPointA2PAS = $pr['PUDO_ID'];
244
+ $newPr->localite = $pr['CITY'];
245
+ $newPr->nomEnseigne = $pr['NAME'];
246
+ $time = new DateTime;
247
+ $newPr->dateArriveColis = $time->format(DateTime::ATOM);
248
+ $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
249
+
250
+ if(isset($pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'])) {
251
+ $listeHoraires = $pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'];
252
+ foreach($listeHoraires as $horaire) {
253
+ switch($horaire['DAY_ID']) {
254
+ case '1' :
255
+ if(!empty($newPr->horairesOuvertureLundi)) {
256
+ $newPr->horairesOuvertureLundi .= ' ';
257
+ }
258
+ $newPr->horairesOuvertureLundi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
259
+ break;
260
+ case '2' :
261
+ if(!empty($newPr->horairesOuvertureMardi)) {
262
+ $newPr->horairesOuvertureMardi .= ' ';
263
+ }
264
+ $newPr->horairesOuvertureMardi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
265
+ break;
266
+ case '3' :
267
+ if(!empty($newPr->horairesOuvertureMercredi)) {
268
+ $newPr->horairesOuvertureMercredi .= ' ';
269
+ }
270
+ $newPr->horairesOuvertureMercredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
271
+ break;
272
+ case '4' :
273
+ if(!empty($newPr->horairesOuvertureJeudi)) {
274
+ $newPr->horairesOuvertureJeudi .= ' ';
275
+ }
276
+ $newPr->horairesOuvertureJeudi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
277
+ break;
278
+ case '5' :
279
+ if(!empty($newPr->horairesOuvertureVendredi)) {
280
+ $newPr->horairesOuvertureVendredi .= ' ';
281
+ }
282
+ $newPr->horairesOuvertureVendredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
283
+ break;
284
+ case '6' :
285
+ if(!empty($newPr->horairesOuvertureSamedi)) {
286
+ $newPr->horairesOuvertureSamedi .= ' ';
287
+ }
288
+ $newPr->horairesOuvertureSamedi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
289
+ break;
290
+ case '7' :
291
+ if(!empty($newPr->horairesOuvertureDimanche)) {
292
+ $newPr->horairesOuvertureDimanche .= ' ';
293
+ }
294
+ $newPr->horairesOuvertureDimanche .= $horaire['START_TM'].'-'.$horaire['END_TM'];
295
+ break;
296
+ default :
297
+ break;
298
+ }
299
+ }
300
+ }
301
+ if(empty($newPr->horairesOuvertureLundi)) {
302
+ $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
303
+ }
304
+ if(empty($newPr->horairesOuvertureMardi)) {
305
+ $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
306
+ }
307
+ if(empty($newPr->horairesOuvertureMercredi)) {
308
+ $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
309
+ }
310
+ if(empty($newPr->horairesOuvertureJeudi)) {
311
+ $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
312
+ }
313
+ if(empty($newPr->horairesOuvertureVendredi)) {
314
+ $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
315
+ }
316
+ if(empty($newPr->horairesOuvertureSamedi)) {
317
+ $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
318
+ }
319
+ if(empty($newPr->horairesOuvertureDimanche)) {
320
+ $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
321
+ }
322
+
323
+ return $newPr;
324
+ }
325
+ }
326
+ }
327
+ catch (Exception $e) {
328
+ return false;
329
+ }
330
+ return false;
331
+ }
332
+
333
+ public function getPointsRelaisByPudo($address = '', $cp = '') {
334
+
335
+ $params = array(
336
+ 'carrier' => 'CHR',
337
+ 'key' => '75f6fe195dc88ceecbc0f8a2f70a8f3a',
338
+ 'address' => $address ? $this->getFilledValue($address->getStreet(1)) : '',
339
+ 'zipCode' => $address ? $this->getFilledValue($address->getPostcode()) : $cp,
340
+ 'city' => $address ? $this->getFilledValue($address->getCity()) : 'Lille',
341
+ 'countrycode' => $address ? $this->getFilledValue($address->getCountryId()) : '',
342
+ 'requestID' => '1',
343
+ 'date_from' => date('d/m/Y'),
344
+ 'max_pudo_number' => 5,
345
+ 'max_distance_search' => 10,
346
+ 'weight' => 1,
347
+ 'category' => '',
348
+ 'holiday_tolerant' => 1,
349
+ );
350
+ try {
351
+ $client = new SoapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?wsdl", array('trace' => 0, 'connection_timeout' => 10));
352
+ $webservbt = $client->GetPudoList($params);
353
+ $webservbt = json_decode(json_encode((object) simplexml_load_string($webservbt->GetPudoListResult->any)), 1);
354
+ if(!isset($webservbt['ERROR'])) {
355
+ $return = array();
356
+
357
+ $listePr = $webservbt['PUDO_ITEMS']['PUDO_ITEM'];
358
+ if($listePr) {
359
+ foreach($listePr as $pr)
360
+ {
361
+ if($pr['@attributes']['active'] == 'true')
362
+ {
363
+ $newPr = (object)array();
364
+ $newPr->adresse1 = $pr['ADDRESS1'];
365
+ $newPr->adresse2 = is_array($pr['ADDRESS2']) ? implode(' ', $pr['ADDRESS2']) : $pr['ADDRESS2'];
366
+ $newPr->adresse3 = is_array($pr['ADDRESS3']) ? implode(' ', $pr['ADDRESS3']) : $pr['ADDRESS3'];
367
+ $newPr->codePostal = $pr['ZIPCODE'];
368
+ $newPr->identifiantChronopostPointA2PAS = $pr['PUDO_ID'];
369
+ $newPr->localite = $pr['CITY'];
370
+ $newPr->nomEnseigne = $pr['NAME'];
371
+ $time = new DateTime;
372
+ $newPr->dateArriveColis = $time->format(DateTime::ATOM);
373
+ $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
374
+
375
+ if(isset($pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'])) {
376
+ $listeHoraires = $pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'];
377
+ foreach($listeHoraires as $horaire) {
378
+ switch($horaire['DAY_ID']) {
379
+ case '1' :
380
+ if(!empty($newPr->horairesOuvertureLundi)) {
381
+ $newPr->horairesOuvertureLundi .= ' ';
382
+ }
383
+ $newPr->horairesOuvertureLundi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
384
+ break;
385
+ case '2' :
386
+ if(!empty($newPr->horairesOuvertureMardi)) {
387
+ $newPr->horairesOuvertureMardi .= ' ';
388
+ }
389
+ $newPr->horairesOuvertureMardi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
390
+ break;
391
+ case '3' :
392
+ if(!empty($newPr->horairesOuvertureMercredi)) {
393
+ $newPr->horairesOuvertureMercredi .= ' ';
394
+ }
395
+ $newPr->horairesOuvertureMercredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
396
+ break;
397
+ case '4' :
398
+ if(!empty($newPr->horairesOuvertureJeudi)) {
399
+ $newPr->horairesOuvertureJeudi .= ' ';
400
+ }
401
+ $newPr->horairesOuvertureJeudi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
402
+ break;
403
+ case '5' :
404
+ if(!empty($newPr->horairesOuvertureVendredi)) {
405
+ $newPr->horairesOuvertureVendredi .= ' ';
406
+ }
407
+ $newPr->horairesOuvertureVendredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
408
+ break;
409
+ case '6' :
410
+ if(!empty($newPr->horairesOuvertureSamedi)) {
411
+ $newPr->horairesOuvertureSamedi .= ' ';
412
+ }
413
+ $newPr->horairesOuvertureSamedi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
414
+ break;
415
+ case '7' :
416
+ if(!empty($newPr->horairesOuvertureDimanche)) {
417
+ $newPr->horairesOuvertureDimanche .= ' ';
418
+ }
419
+ $newPr->horairesOuvertureDimanche .= $horaire['START_TM'].'-'.$horaire['END_TM'];
420
+ break;
421
+ }
422
+ }
423
+ }
424
+ if(empty($newPr->horairesOuvertureLundi)) {
425
+ $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
426
+ }
427
+ if(empty($newPr->horairesOuvertureMardi)) {
428
+ $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
429
+ }
430
+ if(empty($newPr->horairesOuvertureMercredi)) {
431
+ $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
432
+ }
433
+ if(empty($newPr->horairesOuvertureJeudi)) {
434
+ $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
435
+ }
436
+ if(empty($newPr->horairesOuvertureVendredi)) {
437
+ $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
438
+ }
439
+ if(empty($newPr->horairesOuvertureSamedi)) {
440
+ $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
441
+ }
442
+ if(empty($newPr->horairesOuvertureDimanche)) {
443
+ $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
444
+ }
445
+
446
+ $return[] = $newPr;
447
+ }
448
+ }
449
+ return $return;
450
+ }
451
+ }
452
+ }
453
+ catch (Exception $e) {
454
+ return false;
455
+ }
456
+ return false;
457
+ }
458
+
459
+
460
+ public function getQuickcost($quickCost,$quickcost_url = '') {
461
+ if (!$quickcost_url) {
462
+ $quickcost_url = "https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl";
463
+ }
464
+ try {
465
+ $client = new SoapClient($quickcost_url);
466
+ $webservbt = $client->quickCost($quickCost);
467
+
468
+ return $webservbt->return;
469
+ } catch (Exception $e) {
470
+ return false;
471
+ }
472
+ }
473
+
474
+ public function checkLogin($quickCost,$quickcost_url = '') {
475
+ if (!$quickcost_url) {
476
+ $quickcost_url = "https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl";
477
+ }
478
+ try {
479
+ $client = new SoapClient($quickcost_url);
480
+ $webservbt = $client->calculateProducts($quickCost);
481
+ return $webservbt;
482
+ } catch (Exception $e) {
483
+ return false;
484
+ }
485
+ }
486
+
487
+ /*
488
+ * Return true si la méthode de livraison fait partie du contrat
489
+ */
490
+ public function getMethodIsAllowed($code,$quote = '') {
491
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
492
+ $address = $quote->getShippingAddress();
493
+ $helperData = Mage::helper('chronorelais');
494
+ $code = $helperData->getChronoProductCode('',$code);
495
+ try {
496
+ if($this->methodsAllowed === false) {
497
+ $this->methodsAllowed = array();
498
+ $client = new SoapClient("https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl", array('trace' => 0, 'connection_timeout' => 10));
499
+ $params = array(
500
+ 'accountNumber' => $helperData->getConfigurationAccountNumber(),
501
+ 'password' => $helperData->getConfigurationAccountPass(),
502
+ 'depCountryCode' => $helperData->getConfigurationShipperInfo('country'),
503
+ 'depZipCode' => $helperData->getConfigurationShipperInfo('zipcode'),
504
+ 'arrCountryCode' => $this->getFilledValue($address->getCountryId()),
505
+ 'arrZipCode' => $this->getFilledValue($address->getPostcode()),
506
+ 'arrCity' => $address->getCity() ? $this->getFilledValue($address->getCity()) : '-',
507
+ 'type' => 'M',
508
+ 'weight' => 1
509
+ );
510
+ $webservbt = $client->calculateProducts($params);
511
+ if($webservbt->return->errorCode == 0 && $webservbt->return->productList)
512
+ {
513
+ if(is_array($webservbt->return->productList)) {
514
+ foreach($webservbt->return->productList as $product) {
515
+ $this->methodsAllowed[] = $product->productCode;
516
+ }
517
+ } else { /* cas ou il y a un seul résultat */
518
+ $product = $webservbt->return->productList;
519
+ $this->methodsAllowed[] = $product->productCode;
520
+ }
521
+ }
522
+ }
523
+ if(!empty($this->methodsAllowed) && in_array($code, $this->methodsAllowed)) {
524
+ return true;
525
+ }
526
+ return false;
527
+ }catch(Exception $e) {
528
+ return false;
529
+ }
530
+ }
531
+
532
+
533
+ public function getFilledValue($value) {
534
+ if ($value) {
535
+ return $this->removeaccents(trim($value));
536
+ } else {
537
+ return '';
538
+ }
539
+ }
540
+
541
+ public function removeaccents($string) {
542
+ $stringToReturn = str_replace(
543
+ 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);
544
+ // Remove all remaining other unknown characters
545
+ $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
546
+ $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
547
+ $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
548
+ $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
549
+ return $stringToReturn;
550
+ }
551
+
552
+ public function cancelSkybill($skybillNumber = '') {
553
+ if($skybillNumber) {
554
+ try {
555
+
556
+ $client = new SoapClient("https://www.chronopost.fr/tracking-cxf/TrackingServiceWS?wsdl",array('trace'=> 0,'connection_timeout'=>10));
557
+
558
+ $helperData = Mage::helper('chronorelais');
559
+ $params = array(
560
+ 'accountNumber' => $helperData->getConfigurationAccountNumber(),
561
+ 'password' => $helperData->getConfigurationAccountPass(),
562
+ 'skybillNumber' => $skybillNumber,
563
+ 'language' => Mage::app()->getLocale()->getLocaleCode()
564
+ );
565
+
566
+ return $client->cancelSkybill($params);
567
+ } catch (Exception $e) {
568
+ return false;
569
+ }
570
+ }
571
+ return false;
572
+ }
573
+
574
+ /* Livraison sur rendez-vous */
575
+ public function getSearchDeliverySlot($_srdvConfig = '') {
576
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
577
+
578
+ $_shippingAddress = $quote->getShippingAddress();
579
+ $recipient_address = $_shippingAddress->getStreet();
580
+ if (!isset($recipient_address[1])) {
581
+ $recipient_address[1] = '';
582
+ }
583
+
584
+ $_helper = Mage::helper('chronorelais');
585
+ try {
586
+
587
+ $soapHeaders = array();
588
+ $namespace = 'http://cxf.soap.ws.creneau.chronopost.fr/';
589
+ $soapHeaders[] = new SoapHeader($namespace, 'password', $_helper->getConfigurationAccountPass());
590
+ $soapHeaders[] = new SoapHeader($namespace, 'accountNumber', $_helper->getConfigurationAccountNumber());
591
+
592
+ $client = new SoapClient("https://www.chronopost.fr/rdv-cxf/services/CreneauServiceWS?wsdl", array('trace' => 1, 'connection_timeout' => 10));
593
+ $client->__setSoapHeaders($soapHeaders);
594
+
595
+ $_srdvConfig = json_decode($_srdvConfig,true);
596
+
597
+ /* definition date de debut */
598
+ $dateBegin = date('Y-m-d H:i:s');
599
+ if(isset($_srdvConfig['dateRemiseColis_nbJour']) && $_srdvConfig['dateRemiseColis_nbJour'] > 0) {
600
+ $dateBegin = date('Y-m-d', strtotime('+'.(int)$_srdvConfig['dateRemiseColis_nbJour'].' day'));
601
+ } elseif(isset($_srdvConfig['dateRemiseColis_jour']) && isset($_srdvConfig['dateRemiseColis_heures'])) {
602
+ $jour_text = date('l', strtotime("Sunday +".$_srdvConfig['dateRemiseColis_jour']." days"));
603
+ $dateBegin = date('Y-m-d', strtotime('next '.$jour_text)).' '.$_srdvConfig['dateRemiseColis_heures'].':'.$_srdvConfig['dateRemiseColis_minutes'].':00';
604
+ }
605
+ $dateBegin = date('Y-m-d',strtotime($dateBegin)).'T'.date('H:i:s',strtotime($dateBegin));
606
+
607
+ $params = array(
608
+
609
+ 'callerTool' => 'RDVWS',
610
+ 'productType' => 'RDV',
611
+
612
+ 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
613
+ 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
614
+ 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode'),
615
+ 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
616
+ 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
617
+
618
+ 'recipientAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
619
+ 'recipientAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
620
+ 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
621
+ 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
622
+ 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
623
+
624
+ 'weight' => 1,
625
+ 'dateBegin' => $dateBegin,
626
+ 'shipperDeliverySlotClosed' => '',
627
+ 'currency' => 'EUR',
628
+ 'isDeliveryDate' => 0,
629
+ 'slotType' => 'J'
630
+ );
631
+
632
+
633
+ for($i = 1; $i <= 4; $i++) {
634
+
635
+ /* tarif des niveaux tarifaires */
636
+ if(isset($_srdvConfig['N'.$i.'_price'])) {
637
+ $params['rateN'.$i] = $_srdvConfig['N'.$i.'_price'];
638
+ }
639
+
640
+ /* niveaux tarifaires fermés */
641
+ if(isset($_srdvConfig['N'.$i.'_status']) && $_srdvConfig['N'.$i.'_status'] == 0) {
642
+ if(!isset($params['rateLevelsNotShow'])) {
643
+ $params['rateLevelsNotShow'] = array();
644
+ }
645
+ $params['rateLevelsNotShow'][]= 'N'.$i;
646
+ }
647
+ }
648
+
649
+ /* creneaux à fermer */
650
+ if(isset($_srdvConfig['creneaux'])) {
651
+ foreach($_srdvConfig['creneaux'] as $_creneau) {
652
+
653
+ $jour_debut_text = date('l', Mage::getModel('core/date')->timestamp(strtotime("Sunday +".$_creneau['creneaux_debut_jour']." days")));
654
+ $jour_fin_text = date('l', Mage::getModel('core/date')->timestamp(strtotime("Sunday +".$_creneau['creneaux_fin_jour']." days")));
655
+
656
+ $dateDebut = '';
657
+ $dateFin = '';
658
+
659
+ /* creation de creneaux aux bons formats, pour 6 semaines consécutives */
660
+ for($indiceWeek = 0; $indiceWeek < 6; $indiceWeek++) {
661
+
662
+ if(empty($dateDebut)) {
663
+ $dateDebut = date('Y-m-d', Mage::getModel('core/date')->timestamp(strtotime('next '.$jour_debut_text))).' '.(int)$_creneau['creneaux_debut_heures'].':'.(int)$_creneau['creneaux_debut_minutes'].':00';
664
+ $dateFin = date('Y-m-d', Mage::getModel('core/date')->timestamp(strtotime('next '.$jour_fin_text))).' '.(int)$_creneau['creneaux_fin_heures'].':'.(int)$_creneau['creneaux_fin_minutes'].':00';
665
+ if(date('N') >= $_creneau['creneaux_debut_jour']) {
666
+ $dateDebut = date('Y-m-d', Mage::getModel('core/date')->timestamp(strtotime(date('Y-m-d',strtotime($dateDebut)).' -7 day'))).' '.(int)$_creneau['creneaux_debut_heures'].':'.(int)$_creneau['creneaux_debut_minutes'].':00';
667
+ }
668
+ if(date('N') >= $_creneau['creneaux_fin_jour']) {
669
+ $dateFin = date('Y-m-d', Mage::getModel('core/date')->timestamp(strtotime(date('Y-m-d',strtotime($dateFin)).' -7 day'))).' '.(int)$_creneau['creneaux_fin_heures'].':'.(int)$_creneau['creneaux_fin_minutes'].':00';
670
+ }
671
+
672
+ } else {
673
+ $dateDebut = date('Y-m-d', Mage::getModel('core/date')->timestamp(strtotime($jour_debut_text.' next week '.date('Y-m-d',Mage::getModel('core/date')->timestamp(strtotime($dateDebut)))))).' '.(int)$_creneau['creneaux_debut_heures'].':'.(int)$_creneau['creneaux_debut_minutes'].':00';
674
+ $dateFin = date('Y-m-d', Mage::getModel('core/date')->timestamp(strtotime($jour_fin_text.' next week '.date('Y-m-d',Mage::getModel('core/date')->timestamp(strtotime($dateFin)))))).' '.(int)$_creneau['creneaux_fin_heures'].':'.(int)$_creneau['creneaux_fin_minutes'].':00';
675
+ }
676
+
677
+ $dateDebutStr = date('Y-m-d',Mage::getModel('core/date')->timestamp(strtotime($dateDebut))).'T'.date('H:i:s',Mage::getModel('core/date')->timestamp(strtotime($dateDebut)));
678
+ $dateFinStr = date('Y-m-d',Mage::getModel('core/date')->timestamp(strtotime($dateFin))).'T'.date('H:i:s',Mage::getModel('core/date')->timestamp(strtotime($dateFin)));
679
+
680
+ if(!isset($params['shipperDeliverySlotClosed'])) {
681
+ $params['shipperDeliverySlotClosed'] = array();
682
+ }
683
+ $params['shipperDeliverySlotClosed'][] = $dateDebutStr."/".$dateFinStr;
684
+ }
685
+ }
686
+ }
687
+
688
+ $webservbt = $client->searchDeliverySlot($params);
689
+ if($webservbt->return->code == 0) {
690
+ return $webservbt;
691
+ }
692
+ return false;
693
+ }catch(Exception $e) {
694
+ return false;
695
+ }
696
+ }
697
+
698
+ public function confirmDeliverySlot($rdvInfo = '') {
699
+ $_helper = Mage::helper('chronorelais');
700
+ try {
701
+
702
+ $soapHeaders = array();
703
+ $namespace = 'http://cxf.soap.ws.creneau.chronopost.fr/';
704
+ $soapHeaders[] = new SoapHeader($namespace, 'password', $_helper->getConfigurationAccountPass());
705
+ $soapHeaders[] = new SoapHeader($namespace, 'accountNumber', $_helper->getConfigurationAccountNumber());
706
+
707
+ $client = new SoapClient("https://www.chronopost.fr/rdv-cxf/services/CreneauServiceWS?wsdl", array('trace' => 1, 'connection_timeout' => 10));
708
+ $client->__setSoapHeaders($soapHeaders);
709
+
710
+ $params = array(
711
+ 'callerTool' => 'RDVWS',
712
+ 'productType' => 'RDV',
713
+
714
+ 'codeSlot' => $rdvInfo['deliverySlotCode'],
715
+ 'meshCode' => $rdvInfo['meshCode'],
716
+ 'transactionID' => $rdvInfo['transactionID'],
717
+ 'rank' => $rdvInfo['rank'],
718
+ 'position' => $rdvInfo['rank'],
719
+ 'dateSelected' => $rdvInfo['deliveryDate']
720
+ );
721
+
722
+ return $client->confirmDeliverySlot($params);
723
+ }catch(Exception $e) {
724
+ return false;
725
+ }
726
+ }
727
+ }
app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelaisShipping.php CHANGED
@@ -1,523 +1,518 @@
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 il y a eu compilation
24
+ if (file_exists(dirname(__FILE__).'/Chronopost_Chronorelais_includes_ChronorelaisShippingHelper.php')) {
25
+ include_once 'Chronopost_Chronorelais_includes_ChronorelaisShippingHelper.php';
26
+ }
27
+ else {
28
+ include_once Mage::getBaseDir('code').'/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php';
29
+ }
30
+
31
+ class OCS_Magento_Product implements OCS_Product {
32
+ private $parent_cart_item;
33
+ private $cart_item;
34
+ private $cart_product;
35
+ private $loaded_product;
36
+ private $quantity;
37
+
38
+ public function OCS_Magento_Product($cart_item, $parent_cart_item) {
39
+ $this->cart_item = $cart_item;
40
+ $this->cart_product = $cart_item->getProduct();
41
+ $this->parent_cart_item = $parent_cart_item;
42
+ $this->quantity = isset($parent_cart_item) ? $parent_cart_item->getQty() : $cart_item->getQty();
43
+ }
44
+
45
+ public function getOption($option_name, $get_by_id=false) {
46
+ $value = null;
47
+ $product = $this->cart_product;
48
+ foreach ($product->getOptions() as $option) {
49
+ if ($option->getTitle()==$option_name) {
50
+ $custom_option = $product->getCustomOption('option_'.$option->getId());
51
+ if ($custom_option) {
52
+ $value = $custom_option->getValue();
53
+ if ($option->getType()=='drop_down' && !$get_by_id) {
54
+ $option_value = $option->getValueById($value);
55
+ if ($option_value) {
56
+ $value = $option_value->getTitle();
57
+ }
58
+ }
59
+ }
60
+ break;
61
+ }
62
+ }
63
+ return $value;
64
+ }
65
+
66
+ public function getAttribute($attribute_name, $get_by_id=false) {
67
+ $value = null;
68
+ $product = $this->_getLoadedProduct();
69
+ $attribute = $product->getResource()->getAttribute($attribute_name);
70
+ if ($attribute) {
71
+ $input_type = $attribute->getFrontend()->getInputType();
72
+ if($input_type == 'select') {
73
+ $value = $get_by_id ? $product->getData($attribute_name) : $product->getAttributeText($attribute_name);
74
+ } else {
75
+ $value = $product->getData($attribute_name);
76
+ }
77
+ }
78
+ return $value;
79
+ }
80
+
81
+ private function _getLoadedProduct() {
82
+ if (!isset($this->loaded_product)) {
83
+ $this->loaded_product = Mage::getModel('catalog/product')->load($this->cart_product->getId());
84
+ }
85
+ return $this->loaded_product;
86
+ }
87
+
88
+ public function getQuantity() {
89
+ return $this->quantity;
90
+ }
91
+
92
+ public function getName() {
93
+ return $this->cart_product->getName();
94
+ }
95
+
96
+ public function getSku() {
97
+ return $this->cart_product->getSku();
98
+ }
99
+
100
+ public function getStockData($key) {
101
+ $stock = $this->cart_product->getStockItem();
102
+ if($key == 'is_in_stock') {
103
+ return (bool)$stock->getIsInStock();
104
+ } elseif($key == 'quantity') {
105
+ $quantity = $stock->getQty();
106
+ return $stock->getIsQtyDecimal() ? (float)$quantity : (int)$quantity;
107
+ }
108
+ return null;
109
+ }
110
+ }
111
+
112
+ abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
113
+ extends Mage_Shipping_Model_Carrier_Abstract
114
+ {
115
+ protected $_translate_inline;
116
+ protected $_result;
117
+ protected $_config;
118
+ protected $_countries;
119
+ protected $_helper;
120
+ protected $_messages;
121
+
122
+ protected $_checkContract = false;
123
+ protected $_checkRelaiWs = false;
124
+
125
+ /**
126
+ * Collect rates for this shipping method based on information in $request
127
+ *
128
+ * @param Mage_Shipping_Model_Rate_Request $data
129
+ * @return Mage_Shipping_Model_Rate_Result
130
+ */
131
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
132
+ // skip if not enabled
133
+ if (!$this->__getConfigData('active')) {
134
+ return false;
135
+ }
136
+
137
+ $helper = Mage::helper('chronorelais');
138
+
139
+ $process = array(
140
+ 'request' => $request,
141
+ 'result' => Mage::getModel('shipping/rate_result'),
142
+ 'cart.items' => array(),
143
+ 'products' => array(),
144
+ 'data' => array(
145
+ 'module.version' => null,
146
+ 'carrier.code' => $this->_code,
147
+ 'cart.price_excluding_tax' => $request->_data['package_value_with_discount'],
148
+ 'cart.price_including_tax' => null,
149
+ 'cart.weight' => $request->_data['package_weight'],
150
+ 'cart.weight.unit' => $helper->getConfigWeightUnit(),
151
+ 'cart.quantity' => $request->_data['package_qty'],
152
+ 'destination.country.code' => $request->_data['dest_country_id'],
153
+ 'destination.country.name' => null,
154
+ 'destination.region.code' => $request->_data['dest_region_code'],
155
+ 'destination.postcode' => $request->_data['dest_postcode'],
156
+ 'origin.country.code' => $request->_data['country_id'],
157
+ 'origin.country.name' => null,
158
+ 'origin.region.code' => $request->_data['region_id'],
159
+ 'origin.postcode' => $request->_data['postcode'],
160
+ 'customer.group.id' => null,
161
+ 'customer.group.code' => null,
162
+ 'free_shipping' => $request->getFreeShipping(),
163
+ 'store.id' => $request->_data['store_id'],
164
+ 'store.code' => null,
165
+ 'store.name' => null,
166
+ 'store.address' => null,
167
+ 'store.phone' => null,
168
+ 'date.timestamp' => null,
169
+ 'date.year' => null,
170
+ 'date.month' => null,
171
+ 'date.day' => null,
172
+ 'date.hour' => null,
173
+ 'date.minute' => null,
174
+ 'date.second' => null,
175
+ ),
176
+ 'stop_to_first_match' => null,
177
+ 'config' => null,
178
+ );
179
+
180
+ $items = $request->getAllItems();
181
+ for ($i=0, $n=count($items); $i<$n; $i++) {
182
+ $item = $items[$i];
183
+ if ($item->getProduct() instanceof Mage_Catalog_Model_Product) {
184
+ $process['cart.items'][$item->getId()] = $item;
185
+ }
186
+ }
187
+
188
+ $this->_process($process);
189
+
190
+ return $process['result'];
191
+ }
192
+
193
+
194
+ public function getAllowedMethods() {
195
+ $config = $this->_getConfig();
196
+ $allowed_methods = array();
197
+ if (count($config)>0) {
198
+ foreach ($config as $row) {
199
+ $allowed_methods[$row['*code']] = isset($row['label']) ? $row['label']['value'] : 'No label';
200
+ }
201
+ }
202
+ return $allowed_methods;
203
+ }
204
+
205
+ public function isTrackingAvailable() {
206
+ return true;
207
+ }
208
+
209
+ public function getTrackingInfo($tracking_number) {
210
+ $tracking_url = Mage::helper('chronorelais')->getConfigurationTrackingViewUrl();
211
+ $parts = explode(':',$tracking_number);
212
+ if (count($parts)>=2) {
213
+ $tracking_number = $parts[1];
214
+
215
+ $config = $this->_getConfig();
216
+
217
+ if (isset($config[$parts[0]]['tracking_url'])) {
218
+ $row = $config[$parts[0]];
219
+ $tmp_tracking_url = $this->_helper->getRowProperty($row,'tracking_url');
220
+ if (isset($tmp_tracking_url)) {
221
+ $tracking_url = $tmp_tracking_url;
222
+ }
223
+ }
224
+ }
225
+
226
+ $tracking_status = Mage::getModel('shipping/tracking_result_status')
227
+ ->setCarrier($this->_code)
228
+ ->setCarrierTitle($this->__getConfigData('title'))
229
+ ->setTracking($tracking_number)
230
+ ->addData(
231
+ array(
232
+ 'status'=>'<a target="_blank" href="'.str_replace('{tracking_number}',$tracking_number,$tracking_url).'">'.__('track the package').'</a>'
233
+ )
234
+ );
235
+ $tracking_result = Mage::getModel('shipping/tracking_result')
236
+ ->append($tracking_status);
237
+
238
+ if ($trackings = $tracking_result->getAllTrackings()) {
239
+ return $trackings[0];
240
+ }
241
+ return false;
242
+ }
243
+
244
+
245
+ /***************************************************************************************************************************/
246
+
247
+ protected function _process(&$process) {
248
+ $store = Mage::app()->getStore($process['data']['store.id']);
249
+ $mage_config = Mage::getConfig();
250
+ $timestamp = time();
251
+ $customer_group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();
252
+ $helper = Mage::helper('chronorelais');
253
+ // Pour les commandes depuis Adminhtml
254
+ if ($customer_group_id==0) {
255
+ $customer_group_id2 = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getCustomerGroupId();
256
+ if (isset($customer_group_id2)) {
257
+ $customer_group_id = $customer_group_id2;
258
+ }
259
+ }
260
+
261
+ $customer_group_code = Mage::getSingleton('customer/group')->load($customer_group_id)->getData('customer_group_code');
262
+ $process['data'] = array_merge($process['data'],array(
263
+ 'customer.group.id' => $customer_group_id,
264
+ 'customer.group.code' => $customer_group_code,
265
+ 'destination.country.name' => $this->__getCountryName($process['data']['destination.country.code']),
266
+ 'origin.country.name' => $this->__getCountryName($process['data']['origin.country.code']),
267
+ 'cart.weight.unit' => $helper->getConfigWeightUnit(),
268
+ 'store.code' => $store->getCode(),
269
+ 'store.name' => $store->getConfig('general/store_information/name'),
270
+ 'store.address' => $store->getConfig('general/store_information/address'),
271
+ 'store.phone' => $store->getConfig('general/store_information/phone'),
272
+ 'date.timestamp' => $timestamp,
273
+ 'date.year' => (int)date('Y',$timestamp),
274
+ 'date.month' => (int)date('m',$timestamp),
275
+ 'date.day' => (int)date('d',$timestamp),
276
+ 'date.hour' => (int)date('H',$timestamp),
277
+ 'date.minute' => (int)date('i',$timestamp),
278
+ 'date.second' => (int)date('s',$timestamp),
279
+ 'module.version' => (string)$mage_config->getNode('modules/Chronopost_Chronorelais/version'),
280
+ ));
281
+
282
+ $weight_limit = $this->__getConfigData('weight_limit'); /* weight_limit in kg */
283
+ $productWeightOverLimit = false;
284
+
285
+ foreach ($process['cart.items'] as $item) {
286
+ if ($item->getProduct()->getTypeId()!='configurable') {
287
+ $parent_item_id = $item->getParentItemId();
288
+ $itemWeight = $item->getWeight();
289
+ if($helper->getConfigWeightUnit() == 'g')
290
+ {
291
+ $itemWeight = $itemWeight / 1000; // conversion g => kg
292
+ }
293
+ if($itemWeight > $weight_limit) {
294
+ $productWeightOverLimit = true;
295
+ }
296
+ $process['products'][] = new OCS_Magento_Product($item, isset($process['cart.items'][$parent_item_id]) ? $process['cart.items'][$parent_item_id] : null);
297
+ }
298
+ }
299
+
300
+ if (!$process['data']['free_shipping']) {
301
+ foreach ($process['cart.items'] as $item) {
302
+ if ($item->getProduct() instanceof Mage_Catalog_Model_Product) {
303
+ if ($item->getFreeShipping()) {
304
+ $process['data']['free_shipping'] = true;
305
+ } else {
306
+ $process['data']['free_shipping'] = false;
307
+ break;
308
+ }
309
+ }
310
+ }
311
+ }
312
+
313
+ $process['data']['cart.price_including_tax'] = $this->__getCartTaxAmount($process)+$process['data']['cart.price_excluding_tax'];
314
+ $process['stop_to_first_match'] = $this->__getConfigData('stop_to_first_match');
315
+ $process['config'] = $this->_getConfig();
316
+ $compression = $this->__getConfigData('auto_compression');
317
+ if ($compression=='compress') {
318
+ Mage::getConfig()->saveConfig('carriers/'.$this->_code.'/config',$this->_helper->formatConfig(true));
319
+ } else if ($compression=='uncompress') {
320
+ Mage::getConfig()->saveConfig('carriers/'.$this->_code.'/config',$this->_helper->formatConfig(false));
321
+ }
322
+
323
+ $this->_helper->debug = (int)(isset($_GET['debug']) ? $_GET['debug'] : $this->__getConfigData('debug'));
324
+ $http_request = Mage::app()->getFrontController()->getRequest();
325
+ $this->_helper->debug = $this->_helper->debug && $http_request->getRouteName()=='checkout' && $http_request->getControllerName()=='cart';
326
+ if ($this->_helper->debug) {
327
+ $this->_helper->setDebugHeader($process);
328
+ }
329
+
330
+ $value_found = false;
331
+ $process_continue = true;
332
+
333
+ //Set error messages if not any matching
334
+ $freeShippingEnable = $this->__getConfigData('free_shipping_enable');
335
+ $freeShippingSubtotal = $this->__getConfigData('free_shipping_subtotal');
336
+ $applicationFee = $this->__getConfigData('application_fee');
337
+ $handlingFee = $this->__getConfigData('handling_fee');
338
+
339
+ /* On autorise chronopost > 30 Kg si tous les produits sont <= 30 Kg */
340
+ if($productWeightOverLimit) {
341
+ $value_found = false;
342
+ $process_continue = false;
343
+ }
344
+
345
+ $process_continue = $this->validateMethod();
346
+
347
+ if($process_continue) {
348
+ foreach ($process['config'] as $row) {
349
+ $result = $this->_helper->processRow($process,$row);
350
+ $this->_addMessages($this->_helper->getMessages());
351
+ if ($result && $result->success) {
352
+ $value_found = true;
353
+ $fees = $result->result;
354
+ if($applicationFee) {
355
+ $fees += $applicationFee;
356
+ }
357
+ if($handlingFee) {
358
+ $fees += $handlingFee;
359
+ }
360
+ if($freeShippingEnable && ($freeShippingSubtotal<=$process['data']['cart.price_excluding_tax'])) {
361
+ $fees = 0;
362
+ }
363
+ $this->__appendMethod($process,$row,$fees);
364
+ if ($process['stop_to_first_match']) {
365
+ break;
366
+ }
367
+ }
368
+ }
369
+ }
370
+
371
+ $this->_helper->printDebug();
372
+ }
373
+
374
+ /* Additional conditions to show shipping method, each shipping method model might have their own validateMethod function */
375
+ protected function validateMethod() {
376
+ $helperWS = Mage::helper('chronorelais/webservice');
377
+
378
+ /* Chronorelais => test Si WS fonctionne */
379
+ if($this->_checkRelaiWs) {
380
+ $shippingAddress = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getShippingAddress();
381
+ $webservice = $helperWS->getPointsRelaisByCp($shippingAddress->getPostcode());
382
+ if($webservice === false) {
383
+ return false;
384
+ }
385
+ }
386
+
387
+ if($this->_checkContract) {
388
+ $isAllowed = $helperWS->getMethodIsAllowed($this->_code);
389
+ if($isAllowed === false) {
390
+ return false;
391
+ }
392
+ }
393
+ return true;
394
+ }
395
+
396
+ protected function _getConfig() {
397
+ if (!isset($this->_config)) {
398
+ $this->_helper = new ChronorelaisShippingHelper($this->__getConfigData('config'));
399
+ $this->_config = $this->_helper->getConfig();
400
+ $this->_addMessages($this->_helper->getMessages());
401
+ }
402
+ return $this->_config;
403
+ }
404
+
405
+ protected function _getMethodText($process, $row, $property) {
406
+ if (!isset($row[$property])) {
407
+ return '';
408
+ }
409
+
410
+ $output = '';
411
+
412
+ return $output . ' '.$this->_helper->evalInput($process,$row,$property,str_replace(
413
+ array('{cart.weight}','{cart.price_including_tax}','{cart.price_excluding_tax}'),
414
+ array(
415
+ $process['data']['cart.weight'].$process['data']['cart.weight.unit'],
416
+ $this->__formatPrice($process['data']['cart.price_including_tax']),
417
+ $this->__formatPrice($process['data']['cart.price_excluding_tax'])
418
+ ),
419
+ $this->_helper->getRowProperty($row,$property)
420
+ ));
421
+ }
422
+
423
+ protected function _addMessages($messages) {
424
+ if (!is_array($messages)) {
425
+ $messages = array($messages);
426
+ }
427
+ if (!is_array($this->_messages)) {
428
+ $this->_messages = $messages;
429
+ } else {
430
+ $this->_messages = array_merge($this->_messages,$messages);
431
+ }
432
+ }
433
+
434
+ protected function _appendErrors(&$process, $messages) {
435
+ if (is_array($messages)) {
436
+ foreach ($messages as $message) {
437
+ $this->__appendError($process,$this->__($message));
438
+ }
439
+ }
440
+ }
441
+
442
+ /***************************************************************************************************************************/
443
+
444
+ protected function __getConfigData($key) {
445
+ return $this->getConfigData($key);
446
+ }
447
+
448
+ protected function __appendMethod(&$process, $row, $fees) {
449
+ $method = Mage::getModel('shipping/rate_result_method')
450
+ ->setCarrier($this->_code)
451
+ ->setCarrierTitle($this->__getConfigData('title'))
452
+ ->setMethod($row['*code'])
453
+ ->setMethodTitle($this->_getMethodText($process,$row,'label'))
454
+ ->setMethodDescription($this->_getMethodText($process,$row,'description'))
455
+ ->setMethodLogo($this->__getConfigData('logo_url'))
456
+ ->setPrice($fees)
457
+ ->setCost($fees)
458
+ ;
459
+ $process['result']->append($method);
460
+ }
461
+
462
+ protected function __appendError(&$process, $message) {
463
+ if (isset($process['result'])) {
464
+ $error = Mage::getModel('shipping/rate_result_error')
465
+ ->setCarrier($this->_code)
466
+ ->setCarrierTitle($this->__getConfigData('title'))
467
+ ->setErrorMessage($message)
468
+ ;
469
+ $process['result']->append($error);
470
+ }
471
+ }
472
+
473
+ protected function __formatPrice($price) {
474
+ if (!isset($this->_core_helper)) {
475
+ $this->_core_helper = Mage::helper('core');
476
+ }
477
+ return $this->_core_helper->currency($price);
478
+ }
479
+
480
+ protected function __($message) {
481
+ $args = func_get_args();
482
+ $message = array_shift($args);
483
+ if ($message instanceof OCS_Message) {
484
+ $args = $message->args;
485
+ $message = $message->message;
486
+ }
487
+
488
+ $output = Mage::helper('shipping')->__($message);
489
+ if (count($args)==0) {
490
+ return $output;
491
+ }
492
+
493
+ if (!isset($this->_translate_inline)) {
494
+ $this->_translate_inline = Mage::getSingleton('core/translate')->getTranslateInline();
495
+ }
496
+ if ($this->_translate_inline) {
497
+ $parts = explode('}}{{',$output);
498
+ $parts[0] = vsprintf($parts[0],$args);
499
+ return implode('}}{{',$parts);
500
+ } else {
501
+ return vsprintf($output,$args);
502
+ }
503
+ }
504
+
505
+ protected function __getCountryName($country_code) {
506
+ return Mage::getModel('directory/country')->load($country_code)->getName();
507
+ }
508
+
509
+ protected function __getCartTaxAmount($process) {
510
+ $tax_amount = 0;
511
+ foreach ($process['cart.items'] as $item) {
512
+ $tax_amount += $item->getData('tax_amount');
513
+ }
514
+ return $tax_amount;
515
+ }
516
+ }
517
+
 
 
 
 
 
518
  ?>
app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronoexpress.php CHANGED
@@ -1,6 +1,5 @@
1
  <?php
2
  class Chronopost_Chronorelais_Model_Carrier_Chronoexpress extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
  {
4
- protected $_code = 'chronoexpress';
5
-
6
  }
1
  <?php
2
  class Chronopost_Chronorelais_Model_Carrier_Chronoexpress extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
  {
4
+ protected $_code = 'chronoexpress';
 
5
  }
app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronopost.php CHANGED
@@ -1,6 +1,5 @@
1
  <?php
2
  class Chronopost_Chronorelais_Model_Carrier_Chronopost extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
  {
4
- protected $_code = 'chronopost';
5
-
6
  }
1
  <?php
2
  class Chronopost_Chronorelais_Model_Carrier_Chronopost extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
  {
4
+ protected $_code = 'chronopost';
 
5
  }
app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostC10.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  class Chronopost_Chronorelais_Model_Carrier_ChronopostC10 extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
  {
4
- protected $_code = 'chronopostc10';
5
-
6
  }
1
  <?php
2
  class Chronopost_Chronorelais_Model_Carrier_ChronopostC10 extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
  {
4
+ protected $_code = 'chronopostc10';
5
+ protected $_checkContract = true;
6
  }
app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostC18.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  class Chronopost_Chronorelais_Model_Carrier_ChronopostC18 extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
  {
4
- protected $_code = 'chronopostc18';
5
-
6
  }
1
  <?php
2
  class Chronopost_Chronorelais_Model_Carrier_ChronopostC18 extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
  {
4
+ protected $_code = 'chronopostc18';
5
+ protected $_checkContract = true;
6
  }
app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostCClassic.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  class Chronopost_Chronorelais_Model_Carrier_ChronopostCClassic extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
  {
4
- protected $_code = 'chronopostcclassic';
5
-
6
  }
1
  <?php
2
  class Chronopost_Chronorelais_Model_Carrier_ChronopostCClassic extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
  {
4
+ protected $_code = 'chronopostcclassic';
5
+ protected $_checkContract = true;
6
  }
app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronopostsameday.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Model_Carrier_Chronopostsameday extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
4
+ {
5
+
6
+ protected $_code = 'chronopostsameday';
7
+ protected $_checkContract = true;
8
+
9
+ protected function validateMethod()
10
+ {
11
+ $validate = parent::validateMethod();
12
+
13
+ // Check if we should auto disable the module (it's past hour)
14
+ $deliveryTimeLimitConf = Mage::getStoreConfig('carriers/' . $this->getCarrierCode() . '/delivery_time_limit');
15
+ // Safe fallback
16
+ if (!$deliveryTimeLimitConf) {
17
+ $deliveryTimeLimitConf = '15:00';
18
+ }
19
+ $deliveryTimeLimit = new DateTime(date('Y-m-d') . ' ' . $deliveryTimeLimitConf . ':00');
20
+ $currentTime = new DateTime('NOW');
21
+
22
+ if ($validate === true) {
23
+ if (Mage::getModel('core/date')->timestamp($currentTime->getTimestamp())
24
+ <= $deliveryTimeLimit->getTimestamp()) {
25
+ $validate = true;
26
+ } else {
27
+ $validate = false;
28
+ }
29
+ }
30
+
31
+ return $validate;
32
+ }
33
+ }
app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronopostsrdv.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Model_Carrier_Chronopostsrdv extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
4
+ {
5
+
6
+ protected $_code = 'chronopostsrdv';
7
+ protected $_checkContract = true;
8
+
9
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
10
+ $result = parent::collectRates($request);
11
+ return $this->updatePriceAndLabel($result);
12
+ }
13
+
14
+ /* update shipping method price and label to add date and hours */
15
+ public function updatePriceAndLabel($result) {
16
+ $rates = $result->getAllRates();
17
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
18
+
19
+ if(!$quote) {
20
+ return $result;
21
+ }
22
+
23
+ $shippingAddress = $quote->getShippingAddress();
24
+
25
+ if(!$shippingAddress || !$shippingAddress->getShippingMethod()) { // || !isset($_SESSION['chronopostsrdv_creneaux_info'])
26
+ //return $result;
27
+ }
28
+
29
+ // We will rebuild it later
30
+ $result->reset();
31
+
32
+ /*$price = $_srdvConfig[$tarifLevel."_price"];
33
+ $price = $_helper->addMargeToQuickcost($price,$this->_code, false);*/
34
+
35
+ foreach ($rates as $rate) {
36
+
37
+ if($rate->getMethod() == $this->_code) {
38
+
39
+ /*if(!$rate->getOriginalPrice()) {
40
+ $rate->setOriginalPrice($rate->getPrice());
41
+ }*/
42
+
43
+
44
+ $_srdvConfig = Mage::getStoreConfig('carriers/chronopostsrdv/rdv_config');
45
+ $_srdvConfig = json_decode($_srdvConfig,true);
46
+
47
+ $_helper = Mage::helper('chronorelais');
48
+
49
+ if(isset($_SESSION['chronopostsrdv_creneaux_info'])) {
50
+ $chronopostsrdv_creneaux_info = $_SESSION['chronopostsrdv_creneaux_info'];
51
+ $tarifLevel = $chronopostsrdv_creneaux_info['tariffLevel'];
52
+ $price = $_srdvConfig[$tarifLevel."_price"] + $rate->getCost();
53
+
54
+ $_dateRdvStart = new DateTime($chronopostsrdv_creneaux_info['deliveryDate']);
55
+ $_dateRdvStart->setTime($chronopostsrdv_creneaux_info['startHour'],$chronopostsrdv_creneaux_info['startMinutes']);
56
+
57
+ $_dateRdvEnd = new DateTime($chronopostsrdv_creneaux_info['deliveryDate']);
58
+ $_dateRdvEnd->setTime($chronopostsrdv_creneaux_info['endHour'],$chronopostsrdv_creneaux_info['endMinutes']);
59
+
60
+ $methodTitle = $rate->getMethodTitle();
61
+ $methodTitle .= ' - '.$_helper->__('Le').' '.$_dateRdvStart->format('d/m/Y');
62
+ $methodTitle .= ' '.$_helper->__('entre %s et %s',$_dateRdvStart->format('H:i'),$_dateRdvEnd->format('H:i'));
63
+ $rate->setData('method_title',$methodTitle);
64
+
65
+ } else {
66
+ $minimal_price = '';
67
+ for($i = 1; $i <= 4; $i++) {
68
+ if($minimal_price === '' || isset($_srdvConfig["N".$i."_price"]) && $_srdvConfig["N".$i."_price"] < $minimal_price) {
69
+ $minimal_price = $_srdvConfig["N".$i."_price"];
70
+ }
71
+ }
72
+ $price = $minimal_price + $rate->getCost();
73
+ }
74
+
75
+ $rate->setPrice($price);
76
+
77
+ $shippingAddress->setShippingDescription($methodTitle);
78
+
79
+ }
80
+
81
+ $result->append($rate);
82
+ }
83
+ return $result;
84
+ }
85
+ }
app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronorelais.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  class Chronopost_Chronorelais_Model_Carrier_Chronorelais extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
  {
4
- protected $_code = 'chronorelais';
5
-
6
  }
1
  <?php
2
  class Chronopost_Chronorelais_Model_Carrier_Chronorelais extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
  {
4
+ protected $_code = 'chronorelais';
5
+ protected $_checkRelaiWs = true;
6
  }
app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronorelaisdom.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Carrier_Chronorelaisdom extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
+ {
4
+ protected $_code = 'chronorelaisdom';
5
+ protected $_checkContract = true;
6
+ protected $_checkRelaiWs = true;
7
+ }
app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronorelaiseurope.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Carrier_Chronorelaiseurope extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
+ {
4
+ protected $_code = 'chronorelaiseurope';
5
+ protected $_checkContract = true;
6
+ protected $_checkRelaiWs = true;
7
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Backend/Date.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * System config file field backend model
4
+ *
5
+ * @category Adexos
6
+ * @package Adexos_Productcustomizer
7
+ * @author Adexos
8
+ */
9
+ class Chronopost_Chronorelais_Model_Config_Backend_Date extends Mage_Core_Model_Config_Data
10
+ {
11
+ protected function _beforeSave()
12
+ {
13
+ $range = $this->getValue();
14
+ $this->setValue($range[0].':'.$range[1].':'.$range[2]);
15
+ return $this;
16
+ }
17
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/Civility.php CHANGED
@@ -6,7 +6,7 @@ class Chronopost_Chronorelais_Model_Config_Source_Civility
6
  return array(
7
  array('value'=>'E', 'label'=>Mage::helper('chronorelais')->__('Madame')),
8
  array('value'=>'L', 'label'=>Mage::helper('chronorelais')->__('Mademoiselle')),
9
- array('value'=>'M', 'label'=>Mage::helper('chronorelais')->__('Monsieur'))
10
  );
11
  }
12
- }
6
  return array(
7
  array('value'=>'E', 'label'=>Mage::helper('chronorelais')->__('Madame')),
8
  array('value'=>'L', 'label'=>Mage::helper('chronorelais')->__('Mademoiselle')),
9
+ array('value'=>'M', 'label'=>Mage::helper('chronorelais')->__('Monsieur'))
10
  );
11
  }
12
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/Day.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_Day
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>'monday', 'label'=>Mage::helper('chronorelais')->__('Monday')),
8
+ array('value'=>'tuesday', 'label'=>Mage::helper('chronorelais')->__('Tuesday')),
9
+ array('value'=>'wednesday', 'label'=>Mage::helper('chronorelais')->__('Wednesday')),
10
+ array('value'=>'thursday', 'label'=>Mage::helper('chronorelais')->__('Thursday')),
11
+ array('value'=>'friday', 'label'=>Mage::helper('chronorelais')->__('Friday')),
12
+ array('value'=>'saturday', 'label'=>Mage::helper('chronorelais')->__('Saturday')),
13
+ array('value'=>'sunday', 'label'=>Mage::helper('chronorelais')->__('Sunday'))
14
+ );
15
+ }
16
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/FieldDelimiter.php CHANGED
@@ -4,9 +4,9 @@ class Chronopost_Chronorelais_Model_Config_Source_FieldDelimiter
4
  public function toOptionArray()
5
  {
6
  return array(
7
- array('value'=>'none', 'label'=>Mage::helper('chronorelais')->__('None')),
8
  array('value'=>'simple_quote', 'label'=>Mage::helper('chronorelais')->__('Simple Quote')),
9
  array('value'=>'double_quotes', 'label'=>Mage::helper('chronorelais')->__('Double Quotes'))
10
  );
11
  }
12
- }
4
  public function toOptionArray()
5
  {
6
  return array(
7
+ array('value'=>'none', 'label'=>Mage::helper('chronorelais')->__('None')),
8
  array('value'=>'simple_quote', 'label'=>Mage::helper('chronorelais')->__('Simple Quote')),
9
  array('value'=>'double_quotes', 'label'=>Mage::helper('chronorelais')->__('Double Quotes'))
10
  );
11
  }
12
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/FileCharset.php CHANGED
@@ -6,7 +6,7 @@ class Chronopost_Chronorelais_Model_Config_Source_FileCharset
6
  return array(
7
  array('value'=>'ISO-8859-1', 'label'=>Mage::helper('chronorelais')->__('ISO-8859-1')),
8
  array('value'=>'UTF-8', 'label'=>Mage::helper('chronorelais')->__('UTF-8')),
9
- array('value'=>'ASCII-7', 'label'=>Mage::helper('chronorelais')->__('ASCII-7 Bits'))
10
  );
11
  }
12
- }
6
  return array(
7
  array('value'=>'ISO-8859-1', 'label'=>Mage::helper('chronorelais')->__('ISO-8859-1')),
8
  array('value'=>'UTF-8', 'label'=>Mage::helper('chronorelais')->__('UTF-8')),
9
+ array('value'=>'ASCII-7', 'label'=>Mage::helper('chronorelais')->__('ASCII-7 Bits'))
10
  );
11
  }
12
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/FileExtension.php CHANGED
@@ -6,7 +6,7 @@ class Chronopost_Chronorelais_Model_Config_Source_FileExtension
6
  return array(
7
  array('value'=>'.txt', 'label'=>Mage::helper('chronorelais')->__('.txt')),
8
  array('value'=>'.csv', 'label'=>Mage::helper('chronorelais')->__('.csv')),
9
- array('value'=>'.chr', 'label'=>Mage::helper('chronorelais')->__('.chr'))
10
  );
11
  }
12
  }
6
  return array(
7
  array('value'=>'.txt', 'label'=>Mage::helper('chronorelais')->__('.txt')),
8
  array('value'=>'.csv', 'label'=>Mage::helper('chronorelais')->__('.csv')),
9
+ array('value'=>'.chr', 'label'=>Mage::helper('chronorelais')->__('.chr'))
10
  );
11
  }
12
  }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/Hour.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_Hour
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ $hour = array();
7
+ for($i = 0; $i <= 23; $i++) {
8
+ $hour_str = str_pad($i, 2, '0',STR_PAD_LEFT);
9
+ $hour[] = array('value' => $hour_str, 'label' => $hour_str);
10
+ }
11
+ return $hour;
12
+ }
13
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/Margetype.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_Margetype
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>'prcent', 'label'=>Mage::helper('chronorelais')->__('Percentage')." (%)"),
8
+ array('value'=>'amount', 'label'=>Mage::helper('chronorelais')->__('Amount')." (€)")
9
+ );
10
+ }
11
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/Minute.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_Minute
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ $minute = array();
7
+ for($i = 0; $i <= 59; $i++) {
8
+ $minute_str = str_pad($i, 2, '0',STR_PAD_LEFT);
9
+ $minute[] = array('value' => $minute_str, 'label' => $minute_str);
10
+ }
11
+ return $minute;
12
+ }
13
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/PrintMode.php CHANGED
@@ -6,7 +6,7 @@ class Chronopost_Chronorelais_Model_Config_Source_PrintMode
6
  return array(
7
  array('value'=>'PDF', 'label'=>Mage::helper('chronorelais')->__('Print PDF Laser with proof')),
8
  array('value'=>'SPD', 'label'=>Mage::helper('chronorelais')->__('Print PDF laser without proof')),
9
- array('value'=>'THE', 'label'=>Mage::helper('chronorelais')->__('Print PDF thermal'))
10
  );
11
  }
12
  }
6
  return array(
7
  array('value'=>'PDF', 'label'=>Mage::helper('chronorelais')->__('Print PDF Laser with proof')),
8
  array('value'=>'SPD', 'label'=>Mage::helper('chronorelais')->__('Print PDF laser without proof')),
9
+ array('value'=>'THE', 'label'=>Mage::helper('chronorelais')->__('Print PDF thermal'))
10
  );
11
  }
12
  }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/Time.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_Time
3
+ {
4
+ /**
5
+ * 07:00 / 07 :30 / 08:00 / 08 :30 / 09:00 / 09 :30 / 10:00 / 10 :30 / 11:00
6
+ * 11:30 / 12:00 / 12 :30 / 13:00 / 13 :30 / 14:00 / 14 :30 / 15:00
7
+ * @return type
8
+ */
9
+ public function toOptionArray()
10
+ {
11
+ return array(
12
+ array('value'=>'07:00', 'label'=>Mage::helper('chronorelais')->__('7 AM')),
13
+ array('value'=>'07:30', 'label'=>Mage::helper('chronorelais')->__('7.30 AM')),
14
+ array('value'=>'08:00', 'label'=>Mage::helper('chronorelais')->__('8 AM')),
15
+ array('value'=>'08:30', 'label'=>Mage::helper('chronorelais')->__('8.30 AM')),
16
+ array('value'=>'09:00', 'label'=>Mage::helper('chronorelais')->__('9 AM')),
17
+ array('value'=>'09:30', 'label'=>Mage::helper('chronorelais')->__('9.30 AM')),
18
+ array('value'=>'10:00', 'label'=>Mage::helper('chronorelais')->__('10 AM')),
19
+ array('value'=>'10:30', 'label'=>Mage::helper('chronorelais')->__('10.30 AM')),
20
+ array('value'=>'11:00', 'label'=>Mage::helper('chronorelais')->__('11 AM')),
21
+ array('value'=>'11:30', 'label'=>Mage::helper('chronorelais')->__('11.30 AM')),
22
+ array('value'=>'12:00', 'label'=>Mage::helper('chronorelais')->__('12 AM')),
23
+ array('value'=>'12:30', 'label'=>Mage::helper('chronorelais')->__('12.30 AM')),
24
+ array('value'=>'13:00', 'label'=>Mage::helper('chronorelais')->__('1 PM')),
25
+ array('value'=>'13:30', 'label'=>Mage::helper('chronorelais')->__('1.30 PM')),
26
+ array('value'=>'14:00', 'label'=>Mage::helper('chronorelais')->__('2 PM')),
27
+ array('value'=>'14:30', 'label'=>Mage::helper('chronorelais')->__('2.30 PM')),
28
+ array('value'=>'15:00', 'label'=>Mage::helper('chronorelais')->__('3 PM'))
29
+ );
30
+ }
31
+ }
app/code/community/Chronopost/Chronorelais/Model/Observer.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Model_Observer
4
+ {
5
+ public function checkSoapExists() {
6
+ if (!extension_loaded('soap') && (Mage::helper('chronorelais')->getConfigData('carriers/chronopost/active') || Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/active') || Mage::helper('chronorelais')->getConfigData('carriers/chronoexpress/active'))) {
7
+ Mage::getSingleton('checkout/session')->addError(Mage::helper('chronorelais')->__('The SOAP extension is not installed in the server. Please contact the site administrator. Sorry for inconvenience.'));
8
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl("checkout/cart"));
9
+ return;
10
+ }
11
+ }
12
+
13
+ public function saveBillingBefore() {
14
+ $request = Mage::app()->getRequest();
15
+ $data = $request->getPost('billing', array());
16
+ $customerAddressId = $request->getPost('billing_address_id', false);
17
+
18
+ if (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
19
+
20
+ //WEC chronorelais
21
+ if (isset($_SESSION["customer_shipping_address_reference"])) {
22
+ unset($_SESSION["customer_shipping_address_reference"]);
23
+ }
24
+
25
+ if (!array_key_exists("company", $data)) {
26
+ $data["company"] = "";
27
+ }
28
+
29
+ $_SESSION["customer_shipping_address_reference"]["data"] = $data;
30
+ $_SESSION["customer_shipping_address_reference"]["customerAddressId"] = $customerAddressId;
31
+ $_SESSION["customer_shipping_address_reference"]["available"] = false;
32
+ //ENDWEC
33
+ }
34
+ }
35
+
36
+ public function saveShippingBefore() {
37
+ $request = Mage::app()->getRequest();
38
+ $data = $request->getPost('shipping', array());
39
+ $customerAddressId = $request->getPost('shipping_address_id', false);
40
+
41
+ //WEC chronorelais
42
+ if (isset($_SESSION["customer_shipping_address_reference"])) {
43
+ unset($_SESSION["customer_shipping_address_reference"]);
44
+ }
45
+ if (!array_key_exists("company", $data)) {
46
+ $data["company"] = "";
47
+ }
48
+ $_SESSION["customer_shipping_address_reference"]["data"] = $data;
49
+ $_SESSION["customer_shipping_address_reference"]["customerAddressId"] = $customerAddressId;
50
+ $_SESSION["customer_shipping_address_reference"]["available"] = false;
51
+ //ENDWEC
52
+ }
53
+
54
+ public function saveShippingMethodBefore() {
55
+ $request = Mage::app()->getRequest();
56
+ $onepage = Mage::getSingleton('checkout/type_onepage');
57
+ //WEC chronorelais
58
+
59
+ if ($_SESSION["customer_shipping_address_reference"]["available"]) {
60
+ $data = $_SESSION["customer_shipping_address_reference"]["data"];
61
+ $customerAddressId = $_SESSION["customer_shipping_address_reference"]["customerAddressId"];
62
+ $_SESSION["customer_shipping_address_reference"]["available"] = false;
63
+
64
+ $result = $onepage->saveShipping($data, $customerAddressId);
65
+ if(!Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links')) {
66
+ Mage::app()->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
67
+ }
68
+ }
69
+
70
+ $method = $request->getParam('shipping_method');
71
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
72
+ $address = $quote->getShippingAddress();
73
+
74
+ $shippingMethodSelected = $request->getParam('shipping_method');
75
+
76
+ $methodTitle = "";
77
+
78
+ /* Chronorelais */
79
+ if(strpos($shippingMethodSelected,'chronorelais') !== false) {
80
+ $relaisId = $request->getParam('shipping_method_chronorelais');
81
+ if ($relaisId != "") {
82
+ $helper = Mage::helper('chronorelais/webservice');
83
+ $relais = $helper->getDetailRelaisPoint($relaisId);
84
+
85
+ if ($relais) {
86
+ $address->setCity($relais->localite)
87
+ ->setPostcode($relais->codePostal)
88
+ ->setStreet(trim($relais->adresse1 . "\n" . $relais->adresse2 . " " . $relais->adresse3))
89
+ ->setCompany($relais->nomEnseigne)
90
+ ->setWRelayPointCode($relais->identifiantChronopostPointA2PAS)
91
+ ->save()
92
+ ->setCollectShippingRates(true);
93
+
94
+ $_SESSION['chronopost_relais_id'] = $relaisId;
95
+
96
+ $_SESSION["customer_shipping_address_reference"]["available"] = true;
97
+
98
+ if (isset($relais->localite)) {
99
+ $methodTitle = ' - ' . $relais->nomEnseigne . ' - ' . trim($relais->adresse1 . " " . $relais->adresse2 . " " . $relais->adresse3) . ' - ' . $relais->codePostal . ' - ' . $relais->localite;
100
+ }
101
+ }
102
+ } else {
103
+ if(!Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links')) {
104
+ $result['error'] = true;
105
+ $result['message'] = Mage::helper('chronorelais')->__('Veuillez sélectionner votre point relais');
106
+ echo Mage::helper('core')->jsonEncode($result);
107
+ exit;
108
+ }
109
+ }
110
+ } else {
111
+ unset($_SESSION['chronopost_relais_id']);
112
+ }
113
+
114
+ /* Chronopostsrdv */
115
+ if(strpos($shippingMethodSelected,'chronopostsrdv') !== false) {
116
+ $rdvInfo = $request->getParam('chronopostsrdv_creneaux_info');
117
+
118
+ if ($rdvInfo != "") {
119
+ $helper = Mage::helper('chronorelais/webservice');
120
+
121
+ /* vérification creneau ok */
122
+ $rdvInfo = json_decode($rdvInfo,true);
123
+
124
+ $confirm = $helper->confirmDeliverySlot($rdvInfo);
125
+ if($confirm->return->code == 0) {
126
+
127
+ $rdvInfo['productCode'] = $confirm->return->productService->productCode;
128
+ $rdvInfo['serviceCode'] = $confirm->return->productService->serviceCode;
129
+
130
+ $_SESSION['chronopostsrdv_creneaux_info'] = $rdvInfo;
131
+
132
+ /* Important : permet de mettre à jour libellé method + prix */
133
+ $address->setChronopostsrdvCreneauxInfo(json_encode($rdvInfo))
134
+ ->save()
135
+ ->setCollectShippingRates(true);
136
+
137
+ } else {
138
+ $result['error'] = true;
139
+ $result['message'] = Mage::helper('chronorelais')->__($confirm->return->message);
140
+ echo Mage::helper('core')->jsonEncode($result);
141
+ exit;
142
+ }
143
+
144
+ } else {
145
+ if(!Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links')) {
146
+ $result['error'] = true;
147
+ $result['message'] = Mage::helper('chronorelais')->__('Veuillez sélectionner votre horaire de rendez-vous');
148
+ echo Mage::helper('core')->jsonEncode($result);
149
+ exit;
150
+ }
151
+ }
152
+ } else {
153
+ unset($_SESSION['chronopostsrdv_creneaux_info']);
154
+ }
155
+
156
+ if ($method) {
157
+ foreach ($address->getAllShippingRates() as $rate) {
158
+ if ($rate->getCode() == $method) {
159
+ $address->setShippingDescription($rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle() . $methodTitle);
160
+ break;
161
+ }
162
+ }
163
+ }
164
+ //ENDWEC chronorelais
165
+ }
166
+
167
+ public function updateShippingAddress($observer) {
168
+
169
+ $address = $observer->getEvent()->getAddress();
170
+ $shippingMethodSelected = $address->getShippingMethod();
171
+
172
+ $onepage = Mage::getSingleton('checkout/type_onepage');
173
+ //WEC chronorelais
174
+
175
+ if(strpos($shippingMethodSelected,'chronorelais') !== false) {
176
+ $relaisId = $_SESSION['chronopost_relais_id'];
177
+ if ($relaisId != "") {
178
+ $helper = Mage::helper('chronorelais/webservice');
179
+ $relais = $helper->getDetailRelaisPoint($relaisId);
180
+
181
+ if ($relais) {
182
+ $address->setCity($relais->localite)
183
+ ->setPostcode($relais->codePostal)
184
+ ->setStreet(trim($relais->adresse1 . "\n" . $relais->adresse2 . " " . $relais->adresse3))
185
+ ->setCompany($relais->nomEnseigne)
186
+ ->setWRelayPointCode($relais->identifiantChronopostPointA2PAS)
187
+ ->save()
188
+ ->setCollectShippingRates(true);
189
+
190
+ $_SESSION["customer_shipping_address_reference"]["available"] = true;
191
+ }
192
+ } else {
193
+ /*$result['error'] = true;
194
+ $result['message'] = Mage::helper('chronorelais')->__('Veuillez sélectionner votre point relais');
195
+ echo Mage::helper('core')->jsonEncode($result);
196
+ exit;*/
197
+ }
198
+ }
199
+
200
+ /* Chronopostsrdv */
201
+ if(strpos($shippingMethodSelected,'chronopostsrdv') !== false) {
202
+ $rdvInfo = $_SESSION['chronopostsrdv_creneaux_info'];
203
+
204
+ if ($rdvInfo != "") {
205
+ $helper = Mage::helper('chronorelais/webservice');
206
+
207
+ /* vérification creneau ok */
208
+ $confirm = $helper->confirmDeliverySlot($rdvInfo);
209
+
210
+ if($confirm->return->code == 0) {
211
+
212
+ $rdvInfo['productCode'] = $confirm->return->productService->productCode;
213
+ $rdvInfo['serviceCode'] = $confirm->return->productService->serviceCode;
214
+
215
+ /* Important : permet de mettre à jour libellé method + prix */
216
+ $address->setChronopostsrdvCreneauxInfo(json_encode($rdvInfo))
217
+ ->setCollectShippingRates(true)->collectShippingRates()->save();
218
+
219
+ } else {
220
+ $result['error'] = true;
221
+ $result['message'] = Mage::helper('chronorelais')->__($confirm->return->message);
222
+ echo Mage::helper('core')->jsonEncode($result);
223
+ exit;
224
+ }
225
+
226
+ } else {
227
+ if(!Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links')) {
228
+ $result['error'] = true;
229
+ $result['message'] = Mage::helper('chronorelais')->__('Veuillez sélectionner votre horaire de rendez-vous');
230
+ echo Mage::helper('core')->jsonEncode($result);
231
+ exit;
232
+ }
233
+ }
234
+ }
235
+
236
+ $methodTitle = "";
237
+ if (isset($relais->localite)) {
238
+ $methodTitle = ' - ' . $relais->nomEnseigne . ' - ' . trim($relais->adresse1 . " " . $relais->adresse2 . " " . $relais->adresse3) . ' - ' . $relais->codePostal . ' - ' . $relais->localite;
239
+ }
240
+ if ($method) {
241
+ foreach ($address->getAllShippingRates() as $rate) {
242
+ if ($rate->getCode() == $method) {
243
+ $address->setShippingDescription($rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle() . $methodTitle);
244
+ break;
245
+ }
246
+ }
247
+ }
248
+ //ENDWEC chronorelais
249
+ }
250
+
251
+ public function checkRelayPoint($observer) {
252
+
253
+ if(Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links')) {
254
+ $_quote = Mage::helper('checkout')->getQuote();
255
+ $address = $_quote->getShippingAddress();
256
+
257
+ $shippingMethodSelected = $address->getShippingMethod();
258
+
259
+ if(strpos($shippingMethodSelected,'chronorelais') !== false) {
260
+ $relaisId = $_SESSION['chronopost_relais_id'];
261
+ if ($relaisId == "") {
262
+ Mage::throwException(Mage::helper('checkout')->__('Veuillez sélectionner votre point relais'));
263
+ }
264
+ }
265
+ }
266
+
267
+ unset($_SESSION['chronopostsrdv_creneaux_info']);
268
+ }
269
+
270
+
271
+ }
app/code/community/Chronopost/Chronorelais/Model/Sales/Quote/Address/Total/Shipping.php CHANGED
@@ -1,207 +1,206 @@
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
+ $address->setWeight(0);
46
+ $address->setFreeMethodWeight(0);
47
+ $this->_setAmount(0)
48
+ ->_setBaseAmount(0);
49
+
50
+ $items = $this->_getAddressItems($address);
51
+ if (!count($items)) {
52
+ return $this;
53
+ }
54
+
55
+ $method = $address->getShippingMethod();
56
+ $freeAddress= $address->getFreeShipping();
57
+
58
+ $addressWeight = $address->getWeight();
59
+ $freeMethodWeight = $address->getFreeMethodWeight();
60
+
61
+ $addressQty = 0;
62
+
63
+ foreach ($items as $item) {
64
+ /**
65
+ * Skip if this item is virtual
66
+ */
67
+ if ($item->getProduct()->isVirtual()) {
68
+ continue;
69
+ }
70
+
71
+ /**
72
+ * Children weight we calculate for parent
73
+ */
74
+ if ($item->getParentItem()) {
75
+ continue;
76
+ }
77
+
78
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
79
+ foreach ($item->getChildren() as $child) {
80
+ if ($child->getProduct()->isVirtual()) {
81
+ continue;
82
+ }
83
+ $addressQty += $child->getTotalQty();
84
+
85
+ if (!$item->getProduct()->getWeightType()) {
86
+ $itemWeight = $child->getWeight();
87
+ $itemQty = $child->getTotalQty();
88
+ $rowWeight = $itemWeight*$itemQty;
89
+ $addressWeight += $rowWeight;
90
+ if ($freeAddress || $child->getFreeShipping()===true) {
91
+ $rowWeight = 0;
92
+ } elseif (is_numeric($child->getFreeShipping())) {
93
+ $freeQty = $child->getFreeShipping();
94
+ if ($itemQty>$freeQty) {
95
+ $rowWeight = $itemWeight*($itemQty-$freeQty);
96
+ }
97
+ else {
98
+ $rowWeight = 0;
99
+ }
100
+ }
101
+ $freeMethodWeight += $rowWeight;
102
+ $item->setRowWeight($rowWeight);
103
+ }
104
+ }
105
+ if ($item->getProduct()->getWeightType()) {
106
+ $itemWeight = $item->getWeight();
107
+ $rowWeight = $itemWeight*$item->getQty();
108
+ $addressWeight+= $rowWeight;
109
+ if ($freeAddress || $item->getFreeShipping()===true) {
110
+ $rowWeight = 0;
111
+ } elseif (is_numeric($item->getFreeShipping())) {
112
+ $freeQty = $item->getFreeShipping();
113
+ if ($item->getQty()>$freeQty) {
114
+ $rowWeight = $itemWeight*($item->getQty()-$freeQty);
115
+ }
116
+ else {
117
+ $rowWeight = 0;
118
+ }
119
+ }
120
+ $freeMethodWeight+= $rowWeight;
121
+ $item->setRowWeight($rowWeight);
122
+ }
123
+ }
124
+ else {
125
+ if (!$item->getProduct()->isVirtual()) {
126
+ $addressQty += $item->getQty();
127
+ }
128
+ $itemWeight = $item->getWeight();
129
+ $rowWeight = $itemWeight*$item->getQty();
130
+ $addressWeight+= $rowWeight;
131
+ if ($freeAddress || $item->getFreeShipping()===true) {
132
+ $rowWeight = 0;
133
+ } elseif (is_numeric($item->getFreeShipping())) {
134
+ $freeQty = $item->getFreeShipping();
135
+ if ($item->getQty()>$freeQty) {
136
+ $rowWeight = $itemWeight*($item->getQty()-$freeQty);
137
+ }
138
+ else {
139
+ $rowWeight = 0;
140
+ }
141
+ }
142
+ $freeMethodWeight+= $rowWeight;
143
+ $item->setRowWeight($rowWeight);
144
+ }
145
+ }
146
+
147
+ if (isset($addressQty)) {
148
+ $address->setItemQty($addressQty);
149
+ }
150
+
151
+ $address->setWeight($addressWeight);
152
+ $address->setFreeMethodWeight($freeMethodWeight);
153
+
154
+ $address->collectShippingRates();
155
+
156
+ $this->_setAmount(0)
157
+ ->_setBaseAmount(0);
158
+
159
+ $method = $address->getShippingMethod();
160
+
161
+ if ($method) {
162
+ foreach ($address->getAllShippingRates() as $rate) {
163
+ if ($rate->getCode()==$method) {
164
+ $amountPrice = $address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
165
+ $this->_setAmount($amountPrice);
166
+ $this->_setBaseAmount($rate->getPrice());
167
+ if(!$address->getShippingDescription()) {
168
+ $address->setShippingDescription($rate->getCarrierTitle().' - '.$rate->getMethodTitle());
169
+ }
170
+ break;
171
+ }
172
+ }
173
+ }
174
+
175
+ return $this;
176
+ }
177
+
178
+ /**
179
+ * Add shipping totals information to address object
180
+ *
181
+ * @param Mage_Sales_Model_Quote_Address $address
182
+ * @return Mage_Sales_Model_Quote_Address_Total_Shipping
183
+ */
184
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
185
+ {
186
+ $amount = $address->getShippingAmount();
187
+ if ($amount!=0 || $address->getShippingDescription()) {
188
+ $address->addTotal(array(
189
+ 'code'=>$this->getCode(),
190
+ 'title'=>Mage::helper('sales')->__('Shipping & Handling').' ('.$address->getShippingDescription().')',
191
+ 'value'=>$address->getShippingAmount()
192
+ ));
193
+ }
194
+ return $this;
195
+ }
196
+
197
+ /**
198
+ * Get Shipping label
199
+ *
200
+ * @return string
201
+ */
202
+ public function getLabel()
203
+ {
204
+ return Mage::helper('sales')->__('Shipping');
205
+ }
206
+ }
 
app/code/community/Chronopost/Chronorelais/Model/Sales/Quote/Address/Total/Shipping.toDel.php CHANGED
@@ -1,207 +1,206 @@
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
+ $address->setWeight(0);
46
+ $address->setFreeMethodWeight(0);
47
+ $this->_setAmount(0)
48
+ ->_setBaseAmount(0);
49
+
50
+ $items = $this->_getAddressItems($address);
51
+ if (!count($items)) {
52
+ return $this;
53
+ }
54
+
55
+ $method = $address->getShippingMethod();
56
+ $freeAddress= $address->getFreeShipping();
57
+
58
+ $addressWeight = $address->getWeight();
59
+ $freeMethodWeight = $address->getFreeMethodWeight();
60
+
61
+ $addressQty = 0;
62
+
63
+ foreach ($items as $item) {
64
+ /**
65
+ * Skip if this item is virtual
66
+ */
67
+ if ($item->getProduct()->isVirtual()) {
68
+ continue;
69
+ }
70
+
71
+ /**
72
+ * Children weight we calculate for parent
73
+ */
74
+ if ($item->getParentItem()) {
75
+ continue;
76
+ }
77
+
78
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
79
+ foreach ($item->getChildren() as $child) {
80
+ if ($child->getProduct()->isVirtual()) {
81
+ continue;
82
+ }
83
+ $addressQty += $child->getTotalQty();
84
+
85
+ if (!$item->getProduct()->getWeightType()) {
86
+ $itemWeight = $child->getWeight();
87
+ $itemQty = $child->getTotalQty();
88
+ $rowWeight = $itemWeight*$itemQty;
89
+ $addressWeight += $rowWeight;
90
+ if ($freeAddress || $child->getFreeShipping()===true) {
91
+ $rowWeight = 0;
92
+ } elseif (is_numeric($child->getFreeShipping())) {
93
+ $freeQty = $child->getFreeShipping();
94
+ if ($itemQty>$freeQty) {
95
+ $rowWeight = $itemWeight*($itemQty-$freeQty);
96
+ }
97
+ else {
98
+ $rowWeight = 0;
99
+ }
100
+ }
101
+ $freeMethodWeight += $rowWeight;
102
+ $item->setRowWeight($rowWeight);
103
+ }
104
+ }
105
+ if ($item->getProduct()->getWeightType()) {
106
+ $itemWeight = $item->getWeight();
107
+ $rowWeight = $itemWeight*$item->getQty();
108
+ $addressWeight+= $rowWeight;
109
+ if ($freeAddress || $item->getFreeShipping()===true) {
110
+ $rowWeight = 0;
111
+ } elseif (is_numeric($item->getFreeShipping())) {
112
+ $freeQty = $item->getFreeShipping();
113
+ if ($item->getQty()>$freeQty) {
114
+ $rowWeight = $itemWeight*($item->getQty()-$freeQty);
115
+ }
116
+ else {
117
+ $rowWeight = 0;
118
+ }
119
+ }
120
+ $freeMethodWeight+= $rowWeight;
121
+ $item->setRowWeight($rowWeight);
122
+ }
123
+ }
124
+ else {
125
+ if (!$item->getProduct()->isVirtual()) {
126
+ $addressQty += $item->getQty();
127
+ }
128
+ $itemWeight = $item->getWeight();
129
+ $rowWeight = $itemWeight*$item->getQty();
130
+ $addressWeight+= $rowWeight;
131
+ if ($freeAddress || $item->getFreeShipping()===true) {
132
+ $rowWeight = 0;
133
+ } elseif (is_numeric($item->getFreeShipping())) {
134
+ $freeQty = $item->getFreeShipping();
135
+ if ($item->getQty()>$freeQty) {
136
+ $rowWeight = $itemWeight*($item->getQty()-$freeQty);
137
+ }
138
+ else {
139
+ $rowWeight = 0;
140
+ }
141
+ }
142
+ $freeMethodWeight+= $rowWeight;
143
+ $item->setRowWeight($rowWeight);
144
+ }
145
+ }
146
+
147
+ if (isset($addressQty)) {
148
+ $address->setItemQty($addressQty);
149
+ }
150
+
151
+ $address->setWeight($addressWeight);
152
+ $address->setFreeMethodWeight($freeMethodWeight);
153
+
154
+ $address->collectShippingRates();
155
+
156
+ $this->_setAmount(0)
157
+ ->_setBaseAmount(0);
158
+
159
+ $method = $address->getShippingMethod();
160
+
161
+ if ($method) {
162
+ foreach ($address->getAllShippingRates() as $rate) {
163
+ if ($rate->getCode()==$method) {
164
+ $amountPrice = $address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
165
+ $this->_setAmount($amountPrice);
166
+ $this->_setBaseAmount($rate->getPrice());
167
+ if(!$address->getShippingDescription()) {
168
+ $address->setShippingDescription($rate->getCarrierTitle().' - '.$rate->getMethodTitle());
169
+ }
170
+ break;
171
+ }
172
+ }
173
+ }
174
+
175
+ return $this;
176
+ }
177
+
178
+ /**
179
+ * Add shipping totals information to address object
180
+ *
181
+ * @param Mage_Sales_Model_Quote_Address $address
182
+ * @return Mage_Sales_Model_Quote_Address_Total_Shipping
183
+ */
184
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
185
+ {
186
+ $amount = $address->getShippingAmount();
187
+ if ($amount!=0 || $address->getShippingDescription()) {
188
+ $address->addTotal(array(
189
+ 'code'=>$this->getCode(),
190
+ 'title'=>Mage::helper('sales')->__('Shipping & Handling').' ('.$address->getShippingDescription().')',
191
+ 'value'=>$address->getShippingAmount()
192
+ ));
193
+ }
194
+ return $this;
195
+ }
196
+
197
+ /**
198
+ * Get Shipping label
199
+ *
200
+ * @return string
201
+ */
202
+ public function getLabel()
203
+ {
204
+ return Mage::helper('sales')->__('Shipping');
205
+ }
206
+ }
 
app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/AjaxController.php CHANGED
@@ -1,446 +1,432 @@
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_Adminhtml_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
- }
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_Adminhtml_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
+ }
173
+ if (preg_match('#\)#', $address_filter)) {
174
+ $address_filter_array[] = $concatened;
175
+ $concatened = '';
176
+ $concat = false;
177
+ }
178
+ $i++;
179
+ }
180
+
181
+ foreach ($address_filter_array as $address_filter) {
182
+ $address_filter = trim($address_filter);
183
+ if (trim($address_filter) != '') {
184
+ if (preg_match('# *([^,(]+) *(-)? *(?:\( *(-)? *(.*)\))? *#s', $address_filter, $result)) {
185
+ $country_code = $result[1];
186
+
187
+ $region_codes = array();
188
+ if(isset($result[4])) {
189
+ $region_codes = explode(',', $result[4]);
190
+ for ($i = count($region_codes); --$i >= 0;) {
191
+ $code = trim($region_codes[$i]);
192
+ $region_codes[$i] = $code;
193
+ }
194
+ }
195
+
196
+ $excluding_region = (isset($result[2]) && $result[2] == '-') || (isset($result[3]) && $result[3] == '-');
197
+ $output['countries'][] = array(
198
+ 'excluding' => $excluding_region,
199
+ 'country_code' => $country_code,
200
+ 'region_codes' => implode(',', $region_codes),
201
+ 'original' => $address_filter,
202
+ );
203
+ } else {
204
+ $output['countries'][] = array(
205
+ 'excluding' => null,
206
+ 'country_code' => $address_filter,
207
+ 'region_codes' => null,
208
+ 'original' => $address_filter,
209
+ );
210
+ }
211
+ }
212
+ }
213
+ return $output;
214
+ }
215
+
216
+ private function getRowUI($row, $selected) {
217
+ $row['_ID_']['value'] = isset($row['_ID_']['value']) ? $row['_ID_']['value'] : uniqid('c');
218
+ $row_id = $row['_ID_']['value'];
219
+
220
+ if (isset($row['lines'])) {
221
+ $output = "<div id=\"r-" . $row_id . "-container\" class=\"row-container has-error ignored-lines" . ($selected ? ' selected' : '') . "\">"
222
+ . "<div class=\"row-header\" onclick=\"ocseditor.selectRow('" . $row_id . "');\">"
223
+ . "<div class=\"row-actions\">"
224
+ . $this->button('Apply changes', "ocseditor.applyChanges();")
225
+ . $this->button('Delete', "ocseditor.removeRow(this);", 'delete')
226
+ . "</div>"
227
+ . "<div class=\"row-title\">" . $this->__('Ignored lines') . "</div></div>"
228
+ . "<div class=\"properties-container\"><textarea class=\"field\">" . $row['lines'] . "</textarea></div></div>";
229
+ return $output;
230
+ }
231
+
232
+ if (!isset($row['label'])) {
233
+ $row['label']['value'] = $this->__('New shipping method');
234
+ }
235
+
236
+ $properties = array(
237
+ 'enabled' => 'Enabled',
238
+ 'code' => 'Code',
239
+ 'label' => 'Label',
240
+ 'description' => 'Description',
241
+ 'destination' => 'Destination',
242
+ 'origin' => 'Origin',
243
+ 'conditions' => 'Conditions',
244
+ 'fees' => 'Fees',
245
+ 'customer_groups' => 'Customer groups',
246
+ 'tracking_url' => 'Tracking url',
247
+ '*comment' => 'Comment',
248
+ );
249
+
250
+ $label = $row['label']['value'];
251
+ $output = "<div id=\"r-" . $row_id . "-container\" class=\"row-container" . ($selected ? ' selected' : '') . "\">"
252
+ . "<div class=\"row-header\" onclick=\"ocseditor.selectRow('" . $row_id . "');\">"
253
+ . "<div class=\"row-actions\">" . $this->button('Delete', "ocseditor.removeRow(this);", 'delete') . "</div><div class=\"row-title\">" . $label . "</div></div>"
254
+ . "<div class=\"properties-container\">";
255
+ $list = "<ul class=\"properties-list\">";
256
+ $j = 0;
257
+ foreach ($properties as $property_key => $label) {
258
+ $cleaned_property = $this->cleanKey($property_key);
259
+ $value = isset($row[$property_key]) ? trim($row[$property_key]['value']) : '';
260
+ $property = isset($row[$property_key]) ? $row[$property_key] : '';
261
+
262
+ $list .= "<li id=\"r-" . $row_id . "-p-" . $cleaned_property . "-item\" class=\"property-item" . ($j == 0 ? ' selected' : '')
263
+ . (empty($value) ? ' empty' : '')
264
+ . "\" onclick=\"ocseditor.selectProperty('" . $row_id . "','" . $cleaned_property . "');\">" . $this->__($label) . "</li>";
265
+ $output .= "<div id=\"r-" . $row_id . "-p-" . $cleaned_property . "-container\" class=\"property-container"
266
+ . ($j == 0 ? ' selected' : '') . "\" property-name=\"" . $property_key . "\">"
267
+ . "<div class=\"buttons-set\" style=\"text-align:right;\">" . $this->button('Help', "ocseditor.help('property." . $property_key . "');", 'help') . "</div>"
268
+ . $this->getPropertyHelper($row_id, $property_key, $property) . "</div>";
269
+ $j++;
270
+ }
271
+ foreach ($row as $property_key => $property) {
272
+ if (!isset($properties[$property_key]) && substr($property_key, 0, 1) != '*') {
273
+ $label = $property_key;
274
+ $cleaned_property = $this->cleanKey($property_key);
275
+ $value = isset($row[$property_key]) ? trim($row[$property_key]['value']) : '';
276
+ $list .= "<li id=\"r-" . $row_id . "-p-" . $cleaned_property . "-item\" class=\"property-item" . ($j == 0 ? ' selected' : '')
277
+ . (empty($value) ? ' empty' : '') . ($cleaned_property == '_ID_' ? ' hide' : '')
278
+ . "\" onclick=\"ocseditor.selectProperty('" . $row_id . "','" . $cleaned_property . "');\">" . $this->__($label) . "</li>";
279
+ $output .= "<div id=\"r-" . $row_id . "-p-" . $cleaned_property . "-container\" class=\"property-container"
280
+ . ($j == 0 ? ' selected' : '') . "\" property-name=\"" . $property_key . "\">"
281
+ . "<div class=\"buttons-set\" style=\"text-align:right;\">" . $this->button('Help', "ocseditor.help('property." . $property_key . "');", 'help') . "</div>"
282
+ . $this->getPropertyHelper($row_id, $property_key, $property) . "</div>";
283
+ $j++;
284
+ }
285
+ }
286
+ $output .= $list . "</div></div>";
287
+ return $output;
288
+ }
289
+
290
+ private function getConfigErrors($config) {
291
+ $script = "ocseditor.resetErrors();";
292
+ foreach ($config as $row) {
293
+ if (isset($row['*messages'])) {
294
+ $error = '';
295
+ foreach ($row['*messages'] as $message) {
296
+ $error .= "<p>" . $this->__($message) . "</p>";
297
+ }
298
+ if ($error != '') {
299
+ $script .= "ocseditor.setError('" . $row['_ID_']['value'] . "','','" . $this->jsEscape($error) . "');";
300
+ }
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
+ return $script;
321
+ }
322
+
323
+ private function loadConfig($input) {
324
+ include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
325
+
326
+ $helper = new ChronorelaisShippingHelper($input);
327
+ $helper->checkConfig();
328
+ $config = $helper->getConfig();
329
+
330
+ $output = "<div class=\"buttons-set\">"
331
+ . $this->button('Add a shipping method', "ocseditor.addRow();", 'add')
332
+ . "</div><div class=\"config-container\">";
333
+ $i = 0;
334
+ foreach ($config as &$row) {
335
+ $output .= $this->getRowUI($row, $i == 0);
336
+ $i++;
337
+ }
338
+ $output .= "</div><script type=\"text/javascript\">" . $this->getConfigErrors($config) . "</script>";
339
+ return $output;
340
+ }
341
+
342
+ public function indexAction() {
343
+ header('Content-Type: text/html; charset=UTF-8');
344
+
345
+ include_once $this->getIncludingPath('countries.inc.php');
346
+
347
+ switch ($_POST['what']) {
348
+ case 'open':
349
+ $output = ""
350
+ // Help page
351
+ . $this->page('help', "Chronorelais Shipping extension help", '')
352
+ // Main page
353
+ . $this->pageHeader("Chronorelais Shipping configuration editor", $this->button('Save', "ocseditor.save();", 'save')
354
+ . $this->button('Export', "ocseditor.saveToFile();", '')
355
+ . $this->button('Load', "ocseditor.showConfigLoader();", '')
356
+ . $this->button('Close', "ocseditor.close();", 'cancel')
357
+ )
358
+ . "<div id=\"ocs-editor-config-loader\">"
359
+ . "<textarea></textarea>"
360
+ . "<div class=\"buttons-set\">"
361
+ . $this->button('Load', "ocseditor.loadConfig();", '')
362
+ . $this->button('Cancel', "ocseditor.hideConfigLoader();", 'cancel')
363
+ . "</div>"
364
+ . "</div>"
365
+ . "<div id=\"ocs-editor-config-container\">" . $this->loadConfig($_POST['input']) . "</div>";
366
+ echo $output;
367
+ exit;
368
+ case 'help':
369
+ echo $this->__('{ocseditor.help.' . $_POST['input'] . '}');
370
+ exit;
371
+ case 'add-row':
372
+ echo $this->getRowUI(array(), true);
373
+ exit;
374
+ case 'load-config':
375
+ echo $this->loadConfig($_POST['config']);
376
+ exit;
377
+ case 'check-config':
378
+ include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
379
+
380
+ $helper = new ChronorelaisShippingHelper(urldecode($_POST['config']));
381
+ $helper->checkConfig();
382
+ print_r($helper->getConfig(), $out);
383
+ $script = $this->getConfigErrors($helper->getConfig());
384
+ break;
385
+ case 'save-to-file':
386
+ include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
387
+
388
+ $helper = new ChronorelaisShippingHelper(urldecode($_POST['config']));
389
+ $formatted_config = $helper->formatConfig(false);
390
+ $this->forceDownload('chronorelais-shipping-config.txt', $formatted_config);
391
+ exit;
392
+ case 'get-address-filters':
393
+ $result = $this->parseAddressFilter($_POST['input']);
394
+ echo $this->getAddressFilters($result);
395
+ exit;
396
+ default:
397
+ break;
398
+ }
399
+
400
+ echo "<script type=\"text/javascript\">" . $script . "</script>";
401
+ exit;
402
+ }
403
+
404
+ public function checkloginAction() {
405
+ $params = $this->getRequest()->getParams();
406
+ $account_number = $params['account_number'];
407
+ $account_pass = $params['account_pass'];
408
+ $helper = Mage::helper('chronorelais');
409
+
410
+ $WSParams = array(
411
+ 'accountNumber' => $account_number,
412
+ 'password' => $account_pass,
413
+ 'depCountryCode' => $helper->getConfigurationShipperInfo('country'),
414
+ 'depZipCode' => $helper->getConfigurationShipperInfo('zipcode'),
415
+ 'arrCountryCode' => $helper->getConfigurationShipperInfo('country'),
416
+ 'arrZipCode' => $helper->getConfigurationShipperInfo('zipcode'),
417
+ 'arrCity' => $helper->getConfigurationShipperInfo('city'),
418
+ 'type' => 'M',
419
+ 'weight' => 1
420
+ );
421
+
422
+ $helperWS = Mage::helper('chronorelais/webservice');
423
+ $webservbt = (array)$helperWS->checkLogin($WSParams);
424
+
425
+ echo json_encode($webservbt);
426
+ }
427
+
428
+ public function checkConflictsAction() {
429
+ // Vérification
430
+ 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>';
431
+ }
432
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/ExportController.php CHANGED
@@ -1,448 +1,635 @@
1
- <?php
2
-
3
- class Chronopost_Chronorelais_Adminhtml_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_Adminhtml_Chronorelais_ExportController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ /**
6
+ * Constructor
7
+ */
8
+ protected function _construct() {
9
+ $this->setUsedModuleName('Chronopost_Chronorelais');
10
+ }
11
+
12
+ protected function _isAllowed(){
13
+ return true;
14
+ }
15
+
16
+ /**
17
+ * Main action : show orders list
18
+ */
19
+ public function indexAction() {
20
+ $this->loadLayout()
21
+ ->_setActiveMenu('sales/chronorelais/export')
22
+ ->_addContent($this->getLayout()->createBlock('chronorelais/export_orders'))
23
+ ->renderLayout();
24
+ }
25
+
26
+ public function getValue($value) {
27
+ return ($value != '' ? $value : '');
28
+ }
29
+
30
+ public function removeSpclChars($text) {
31
+ return preg_replace("/[^0-9a-zA-Z]/", "", $text);
32
+ }
33
+
34
+ public function massLivraisonSamediStatusAction() {
35
+ if ($this->getRequest()->getPost('status')) {
36
+ $this->saveLivraisonSamediStatusAction();
37
+ }
38
+ }
39
+
40
+ public function massExportAction() {
41
+ if ($this->getRequest()->getPost('format') == 'css') {
42
+ $this->exportcssAction();
43
+ } elseif ($this->getRequest()->getPost('format') == 'cso') {
44
+ $this->exportcsoAction();
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Export CSS Action
50
+ * Generates a CSV file to download (CSS format)
51
+ */
52
+ public function exportcssAction() {
53
+ /* get the orders */
54
+ $orderIds = $this->getRequest()->getPost('order_ids');
55
+
56
+ /**
57
+ * Get configuration
58
+ */
59
+ $separator = Mage::helper('chronorelais')->getConfigurationFieldSeparator('css');
60
+ $delimiter = Mage::helper('chronorelais')->getConfigurationFieldDelimiter('css');
61
+
62
+ if ($delimiter == 'simple_quote') {
63
+ $delimiter = "'";
64
+ } else if ($delimiter == 'double_quotes') {
65
+ $delimiter = '"';
66
+ } else {
67
+ $delimiter = '';
68
+ }
69
+ $lineBreak = Mage::helper('chronorelais')->getConfigurationEndOfLineCharacter('css');
70
+ if ($lineBreak == 'lf') {
71
+ $lineBreak = "\n";
72
+ } else if ($lineBreak == 'cr') {
73
+ $lineBreak = "\r";
74
+ } else if ($lineBreak == 'crlf') {
75
+ $lineBreak = "\r\n";
76
+ }
77
+ $fileExtension = Mage::helper('chronorelais')->getConfigurationFileExtension('css');
78
+ $fileCharset = Mage::helper('chronorelais')->getConfigurationFileCharset('css');
79
+
80
+ /* set the filename */
81
+ $filename = 'orders_exportcss_' . Mage::getSingleton('core/date')->date('Ymd_His') . $fileExtension;
82
+
83
+ /* initialize the content variable */
84
+ $content = '';
85
+ $helper = Mage::helper('chronorelais');
86
+ $weightUnit = $helper->getConfigWeightUnit();
87
+ if (!empty($orderIds)) {
88
+ foreach ($orderIds as $orderId) {
89
+
90
+ /* get the order */
91
+ $order = Mage::getModel('sales/order')->load($orderId);
92
+ $address = $order->getShippingAddress();
93
+ $billingAddress = $order->getBillingAddress();
94
+
95
+ $_shippingMethod = explode('_', $order->getShippingMethod());
96
+
97
+ /* customer id */
98
+ $content = $this->_addFieldToCsv($content, $delimiter, ($order->getCustomerId() ? $order->getCustomerId() : $address->getLastname()));
99
+ $content .= $separator;
100
+ /* Nom du point relais OU société si livraison à domicile */
101
+ $content = $this->_addFieldToCsv($content, $delimiter, $address->getCompany());
102
+ $content .= $separator;
103
+ /* customer name */
104
+ $content = $this->_addFieldToCsv($content, $delimiter, ($address->getFirstname() ? $address->getFirstname() : $billingAddress->getFirstname()));
105
+ $content .= $separator;
106
+ $content = $this->_addFieldToCsv($content, $delimiter, ($address->getLastname() ? $address->getLastname() : $billingAddress->getLastname()));
107
+ $content .= $separator;
108
+ /* street address */
109
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(1)));
110
+ $content .= $separator;
111
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(2)));
112
+ $content .= $separator;
113
+
114
+ /* digicode (vide)*/
115
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
116
+ $content .= $separator;
117
+
118
+ /* postal code */
119
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getPostcode()));
120
+ $content .= $separator;
121
+ /* city */
122
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCity()));
123
+ $content .= $separator;
124
+ /* country code */
125
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCountry()));
126
+ $content .= $separator;
127
+ /* telephone */
128
+ $telephone = trim(ereg_replace("[^0-9.-]", " ", $address->getTelephone()));
129
+ $telephone = (strlen($telephone) >= 10 ? $telephone : '');
130
+ $content = $this->_addFieldToCsv($content, $delimiter, $telephone);
131
+ $content .= $separator;
132
+ /* email */
133
+ $customer_email = ($address->getEmail()) ? $address->getEmail() : ($billingAddress->getEmail() ? $billingAddress->getEmail() : $order->getCustomerEmail());
134
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($customer_email));
135
+ $content .= $separator;
136
+ /* real order id */
137
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($order->getRealOrderId()));
138
+ $content .= $separator;
139
+
140
+ /* code barre client (vide) */
141
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
142
+ $content .= $separator;
143
+
144
+ /* productCode */
145
+ $productCode = Mage::helper('chronorelais')->getChronoProductCodeString($_shippingMethod[0]);
146
+ $content = $this->_addFieldToCsv($content, $delimiter, $productCode);
147
+ $content .= $separator;
148
+
149
+ /* compte (vide) */
150
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
151
+ $content .= $separator;
152
+
153
+ /* sous compte (vide) */
154
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
155
+ $content .= $separator;
156
+
157
+ /* empty fields */
158
+ $content = $this->_addFieldToCsv($content, $delimiter, 0);
159
+ $content .= $separator;
160
+ $content = $this->_addFieldToCsv($content, $delimiter, 0);
161
+ $content .= $separator;
162
+
163
+ /* document / marchandise (vide) */
164
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
165
+ $content .= $separator;
166
+
167
+ /* description contenu (vide) */
168
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
169
+ $content .= $separator;
170
+
171
+ /* Livraison Samedi */
172
+ $SaturdayShipping = 'L'; //default value for the saturday shipping
173
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
174
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($orderId)) {
175
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
176
+ } else {
177
+ if ($_deliver_on_saturday == 'Yes') {
178
+ $_deliver_on_saturday = 1;
179
+ } else {
180
+ $_deliver_on_saturday = 0;
181
+ }
182
+ }
183
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
184
+ if ($_deliver_on_saturday && $is_sending_day == true) {
185
+ $SaturdayShipping = 'S';
186
+ } elseif (!$_deliver_on_saturday && $is_sending_day == true) {
187
+ $SaturdayShipping = 'L';
188
+ }
189
+ }
190
+ $content = $this->_addFieldToCsv($content, $delimiter, $SaturdayShipping);
191
+ $content .= $separator;
192
+
193
+ /* chronorelay point */
194
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getWRelayPointCode()));
195
+ $content .= $separator;
196
+
197
+ /* total weight (in kg) */
198
+ $order_weight = number_format($order->getWeight(), 2, '.', '');
199
+ if($weightUnit == 'g') {
200
+ $order_weight = $order_weight / 1000;
201
+ }
202
+ $content = $this->_addFieldToCsv($content, $delimiter, $order_weight);
203
+ $content .= $separator;
204
+
205
+
206
+ /* largeur (vide) */
207
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
208
+ $content .= $separator;
209
+
210
+ /* longueur (vide) */
211
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
212
+ $content .= $separator;
213
+
214
+ /* hauteur (vide) */
215
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
216
+ $content .= $separator;
217
+
218
+ /* avertir destinataire (vide) */
219
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
220
+ $content .= $separator;
221
+
222
+ /* nb colis (vide) */
223
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
224
+ $content .= $separator;
225
+
226
+ /* date envoi */
227
+ $content = $this->_addFieldToCsv($content, $delimiter, date('d/m/Y'));
228
+ $content .= $separator;
229
+
230
+ /* a intégrer (vide) */
231
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
232
+ $content .= $separator;
233
+
234
+ /* avertir expéditeur (vide) */
235
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
236
+ $content .= $separator;
237
+
238
+ /* DLC (vide) */
239
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
240
+ $content .= $separator;
241
+
242
+ /* champ specifique rdv */
243
+ $chronopostsrdv_creneaux_info = $address->getData('chronopostsrdv_creneaux_info');
244
+ if($chronopostsrdv_creneaux_info) {
245
+ $chronopostsrdv_creneaux_info = json_decode($chronopostsrdv_creneaux_info,true);
246
+ $_dateRdvStart = new DateTime($chronopostsrdv_creneaux_info['deliveryDate']);
247
+ $_dateRdvStart->setTime($chronopostsrdv_creneaux_info['startHour'],$chronopostsrdv_creneaux_info['startMinutes']);
248
+
249
+ $_dateRdvEnd = new DateTime($chronopostsrdv_creneaux_info['deliveryDate']);
250
+ $_dateRdvEnd->setTime($chronopostsrdv_creneaux_info['endHour'],$chronopostsrdv_creneaux_info['endMinutes']);
251
+
252
+ /* date debut rdv */
253
+ //$content = $this->_addFieldToCsv($content, $delimiter, $_dateRdvStart->format("Y-m-d")."T".$_dateRdvStart->format("H:i:s"));
254
+ $content = $this->_addFieldToCsv($content, $delimiter, $_dateRdvStart->format("dmyHi"));
255
+ $content .= $separator;
256
+
257
+ /* date fin rdv */
258
+ //$content = $this->_addFieldToCsv($content, $delimiter, $_dateRdvEnd->format("Y-m-d")."T".$_dateRdvEnd->format("H:i:s"));
259
+ $content = $this->_addFieldToCsv($content, $delimiter, $_dateRdvEnd->format("dmyHi"));
260
+ $content .= $separator;
261
+
262
+ /* Niveau tarifaire */
263
+ $content = $this->_addFieldToCsv($content, $delimiter, $chronopostsrdv_creneaux_info['tariffLevel']);
264
+ $content .= $separator;
265
+
266
+ /* code service */
267
+ $content = $this->_addFieldToCsv($content, $delimiter, $chronopostsrdv_creneaux_info['serviceCode']);
268
+ $content .= $separator;
269
+
270
+ } else {
271
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
272
+ $content .= $separator;
273
+
274
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
275
+ $content .= $separator;
276
+
277
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
278
+ $content .= $separator;
279
+
280
+ /* code service */
281
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
282
+ $content .= $separator;
283
+ }
284
+
285
+
286
+
287
+ $content .= $lineBreak;
288
+
289
+ }
290
+
291
+ /* decode the content, depending on the charset */
292
+ if ($fileCharset == 'ISO-8859-1') {
293
+ $content = utf8_decode($content);
294
+ }
295
+
296
+ /* pick file mime type, depending on the extension */
297
+ switch ($fileExtension) {
298
+ case '.csv':
299
+ $fileMimeType = 'application/csv';
300
+ break;
301
+ case '.chr':
302
+ $fileMimeType = 'application/chr';
303
+ break;
304
+ default:
305
+ $fileMimeType = 'text/plain';
306
+ break;
307
+ }
308
+ /* download the file */
309
+ return $this->_prepareDownloadResponse($filename, $content, $fileMimeType . '; charset="' . $fileCharset . '"');
310
+ } else {
311
+ $this->_getSession()->addError($this->__('No Order has been selected'));
312
+ }
313
+ }
314
+
315
+ /**
316
+ * Export CSO Action
317
+ * Generates a CSV file to download (CSO format)
318
+ */
319
+ public function exportcsoAction() {
320
+ /* get the orders */
321
+ $orderIds = $this->getRequest()->getPost('order_ids');
322
+
323
+ /**
324
+ * Get configuration
325
+ */
326
+ $separator = Mage::helper('chronorelais')->getConfigurationFieldSeparator('cso');
327
+ $delimiter = Mage::helper('chronorelais')->getConfigurationFieldDelimiter('cso');
328
+ if ($delimiter == 'simple_quote') {
329
+ $delimiter = "'";
330
+ } else if ($delimiter == 'double_quotes') {
331
+ $delimiter = '"';
332
+ } else {
333
+ $delimiter = '';
334
+ }
335
+ $lineBreak = Mage::helper('chronorelais')->getConfigurationEndOfLineCharacter('cso');
336
+ if ($lineBreak == 'lf') {
337
+ $lineBreak = "\n";
338
+ } else if ($lineBreak == 'cr') {
339
+ $lineBreak = "\r";
340
+ } else if ($lineBreak == 'crlf') {
341
+ $lineBreak = "\r\n";
342
+ }
343
+ $fileExtension = Mage::helper('chronorelais')->getConfigurationFileExtension('cso');
344
+ $fileCharset = Mage::helper('chronorelais')->getConfigurationFileCharset('cso');
345
+
346
+ /* set the filename */
347
+ $filename = 'orders_exportcso_' . Mage::getSingleton('core/date')->date('Ymd_His') . $fileExtension;
348
+
349
+ /* initialize the content variable */
350
+ $content = '';
351
+ $helper = Mage::helper('chronorelais');
352
+ $weightUnit = $helper->getConfigWeightUnit();
353
+ if (!empty($orderIds)) {
354
+ foreach ($orderIds as $orderId) {
355
+
356
+ /* get the order */
357
+ $order = Mage::getModel('sales/order')->load($orderId);
358
+ $address = $order->getShippingAddress();
359
+ $billingAddress = $order->getBillingAddress();
360
+
361
+ $_shippingMethod = explode('_', $order->getShippingMethod());
362
+
363
+ /* customer id */
364
+ $content = $this->_addFieldToCsv($content, $delimiter, ($order->getCustomerId() ? $order->getCustomerId() : $address->getLastname()));
365
+ $content .= $separator;
366
+ /* Nom du point relais OU société si livraison à domicile */
367
+ $content = $this->_addFieldToCsv($content, $delimiter, $address->getCompany());
368
+ $content .= $separator;
369
+ /* customer name */
370
+ $content = $this->_addFieldToCsv($content, $delimiter, ($address->getFirstname() ? $address->getFirstname() : $billingAddress->getFirstname()));
371
+ $content .= $separator;
372
+ $content = $this->_addFieldToCsv($content, $delimiter, ($address->getLastname() ? $address->getLastname() : $billingAddress->getLastname()));
373
+ $content .= $separator;
374
+ /* street address */
375
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(1)));
376
+ $content .= $separator;
377
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(2)));
378
+ $content .= $separator;
379
+
380
+ /* digicode (vide)*/
381
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
382
+ $content .= $separator;
383
+
384
+ /* postal code */
385
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getPostcode()));
386
+ $content .= $separator;
387
+ /* city */
388
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCity()));
389
+ $content .= $separator;
390
+ /* country code */
391
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCountry()));
392
+ $content .= $separator;
393
+ /* telephone */
394
+ $telephone = trim(ereg_replace("[^0-9.-]", " ", $address->getTelephone()));
395
+ $telephone = (strlen($telephone) >= 10 ? $telephone : '');
396
+ $content = $this->_addFieldToCsv($content, $delimiter, $telephone);
397
+ $content .= $separator;
398
+ /* email */
399
+ $customer_email = ($address->getEmail()) ? $address->getEmail() : ($billingAddress->getEmail() ? $billingAddress->getEmail() : $order->getCustomerEmail());
400
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($customer_email));
401
+ $content .= $separator;
402
+ /* real order id */
403
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($order->getRealOrderId()));
404
+ $content .= $separator;
405
+
406
+ /* code barre client (vide) */
407
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
408
+ $content .= $separator;
409
+
410
+ /* productCode */
411
+ $productCode = Mage::helper('chronorelais')->getChronoProductCodeString($_shippingMethod[0]);
412
+ $content = $this->_addFieldToCsv($content, $delimiter, $productCode);
413
+ $content .= $separator;
414
+
415
+ /* compte (vide) */
416
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
417
+ $content .= $separator;
418
+
419
+ /* sous compte (vide) */
420
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
421
+ $content .= $separator;
422
+
423
+ /* empty fields */
424
+ $content = $this->_addFieldToCsv($content, $delimiter, 0);
425
+ $content .= $separator;
426
+ $content = $this->_addFieldToCsv($content, $delimiter, 0);
427
+ $content .= $separator;
428
+
429
+ /* document / marchandise (vide) */
430
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
431
+ $content .= $separator;
432
+
433
+ /* description contenu (vide) */
434
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
435
+ $content .= $separator;
436
+
437
+ /* Livraison Samedi */
438
+ $SaturdayShipping = 'L'; //default value for the saturday shipping
439
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
440
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($orderId)) {
441
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
442
+ } else {
443
+ if ($_deliver_on_saturday == 'Yes') {
444
+ $_deliver_on_saturday = 1;
445
+ } else {
446
+ $_deliver_on_saturday = 0;
447
+ }
448
+ }
449
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
450
+ if ($_deliver_on_saturday && $is_sending_day == true) {
451
+ $SaturdayShipping = 'S';
452
+ } elseif (!$_deliver_on_saturday && $is_sending_day == true) {
453
+ $SaturdayShipping = 'L';
454
+ }
455
+ }
456
+ $content = $this->_addFieldToCsv($content, $delimiter, $SaturdayShipping);
457
+ $content .= $separator;
458
+
459
+ /* chronorelay point */
460
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getWRelayPointCode()));
461
+ $content .= $separator;
462
+
463
+ /* total weight (in kg) */
464
+ $order_weight = number_format($order->getWeight(), 2, '.', '');
465
+ if($weightUnit == 'g') {
466
+ $order_weight = $order_weight / 1000;
467
+ }
468
+ $content = $this->_addFieldToCsv($content, $delimiter, $order_weight);
469
+ $content .= $separator;
470
+
471
+
472
+ /* largeur (vide) */
473
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
474
+ $content .= $separator;
475
+
476
+ /* longueur (vide) */
477
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
478
+ $content .= $separator;
479
+
480
+ /* hauteur (vide) */
481
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
482
+ $content .= $separator;
483
+
484
+ /* avertir destinataire (vide) */
485
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
486
+ $content .= $separator;
487
+
488
+ /* nb colis (vide) */
489
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
490
+ $content .= $separator;
491
+
492
+ /* date envoi */
493
+ $content = $this->_addFieldToCsv($content, $delimiter, date('d/m/Y'));
494
+ $content .= $separator;
495
+
496
+ /* a intégrer (vide) */
497
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
498
+ $content .= $separator;
499
+
500
+ /* avertir expéditeur (vide) */
501
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
502
+ $content .= $separator;
503
+
504
+ /* DLC (vide) */
505
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
506
+ $content .= $separator;
507
+
508
+ /* champ specifique rdv */
509
+ $chronopostsrdv_creneaux_info = $address->getData('chronopostsrdv_creneaux_info');
510
+ if($chronopostsrdv_creneaux_info) {
511
+ $chronopostsrdv_creneaux_info = json_decode($chronopostsrdv_creneaux_info,true);
512
+ $_dateRdvStart = new DateTime($chronopostsrdv_creneaux_info['deliveryDate']);
513
+ $_dateRdvStart->setTime($chronopostsrdv_creneaux_info['startHour'],$chronopostsrdv_creneaux_info['startMinutes']);
514
+
515
+ $_dateRdvEnd = new DateTime($chronopostsrdv_creneaux_info['deliveryDate']);
516
+ $_dateRdvEnd->setTime($chronopostsrdv_creneaux_info['endHour'],$chronopostsrdv_creneaux_info['endMinutes']);
517
+
518
+ /* date debut rdv */
519
+ //$content = $this->_addFieldToCsv($content, $delimiter, $_dateRdvStart->format("Y-m-d")."T".$_dateRdvStart->format("H:i:s"));
520
+ $content = $this->_addFieldToCsv($content, $delimiter, $_dateRdvStart->format("dmyHi"));
521
+ $content .= $separator;
522
+
523
+ /* date fin rdv */
524
+ //$content = $this->_addFieldToCsv($content, $delimiter, $_dateRdvEnd->format("Y-m-d")."T".$_dateRdvEnd->format("H:i:s"));
525
+ $content = $this->_addFieldToCsv($content, $delimiter, $_dateRdvEnd->format("dmyHi"));
526
+ $content .= $separator;
527
+
528
+ /* Niveau tarifaire */
529
+ $content = $this->_addFieldToCsv($content, $delimiter, $chronopostsrdv_creneaux_info['tariffLevel']);
530
+ $content .= $separator;
531
+
532
+ /* code service */
533
+ $content = $this->_addFieldToCsv($content, $delimiter, $chronopostsrdv_creneaux_info['serviceCode']);
534
+ $content .= $separator;
535
+
536
+ } else {
537
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
538
+ $content .= $separator;
539
+
540
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
541
+ $content .= $separator;
542
+
543
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
544
+ $content .= $separator;
545
+
546
+ /* code service */
547
+ $content = $this->_addFieldToCsv($content, $delimiter, '');
548
+ $content .= $separator;
549
+ }
550
+
551
+
552
+
553
+ $content .= $lineBreak;
554
+
555
+ }
556
+
557
+ /* decode the content, depending on the charset */
558
+ if ($fileCharset == 'ISO-8859-1') {
559
+ $content = utf8_decode($content);
560
+ }
561
+
562
+ /* pick file mime type, depending on the extension */
563
+ switch ($fileExtension) {
564
+ case '.csv':
565
+ $fileMimeType = 'application/csv';
566
+ break;
567
+ case '.chr':
568
+ $fileMimeType = 'application/chr';
569
+ break;
570
+ default:
571
+ $fileMimeType = 'text/plain';
572
+ break;
573
+ }
574
+ /* download the file */
575
+ return $this->_prepareDownloadResponse($filename, $content, $fileMimeType . '; charset="' . $fileCharset . '"');
576
+ } else {
577
+ $this->_getSession()->addError($this->__('No Order has been selected'));
578
+ }
579
+ }
580
+
581
+ /* Save the Livraison le Samedi status to orders */
582
+
583
+ public function saveLivraisonSamediStatusAction() {
584
+ /* get the orders */
585
+ $orderIds = $this->getRequest()->getPost('order_ids');
586
+ $status = $this->getRequest()->getPost('status');
587
+ $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
588
+ $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
589
+ $exceptions = array();
590
+
591
+ foreach ($orderIds as $orderId) {
592
+ $order_details = Mage::getModel('sales/order')->load($orderId);
593
+ $shipping_method = '';
594
+ $livraison_le_samedi = $status;
595
+ if ($shipping_method = $order_details->getShippingMethod()) {
596
+ $shipping_method = explode('_', $shipping_method);
597
+ if ($shipping_method[0] == 'chronoexpress') {
598
+ $livraison_le_samedi = '--';
599
+ }
600
+ }
601
+ $condition = array(
602
+ $_connection->quoteInto('order_id = ?', $orderId),
603
+ );
604
+ $_connection->delete($_table, $condition);
605
+
606
+ $dataLine = array(
607
+ 'order_id' => $orderId,
608
+ 'livraison_le_samedi' => $livraison_le_samedi
609
+ );
610
+ try {
611
+ $_connection->insert($_table, $dataLine);
612
+ } catch (Exception $e) {
613
+ $exceptions[] = Mage::helper('chronorelais')->__('Order assigning error: ' . $e->getMessage());
614
+ }
615
+ }
616
+ if ($exceptions) {
617
+ $this->_getSession()->addError($exceptions);
618
+ } else {
619
+ $this->_getSession()->addSuccess($this->__('Livraison le Samedi statut a &eacute;t&eacute; ajout&eacute;'));
620
+ }
621
+ $this->_redirect('*/*/index');
622
+ }
623
+
624
+ /**
625
+ * Add a new field to the csv file
626
+ * @param csvContent : the current csv content
627
+ * @param fieldDelimiter : the delimiter character
628
+ * @param fieldContent : the content to add
629
+ * @return : the concatenation of current content and content to add
630
+ */
631
+ private function _addFieldToCsv($csvContent, $fieldDelimiter, $fieldContent) {
632
+ return $csvContent . $fieldDelimiter . $fieldContent . $fieldDelimiter;
633
+ }
634
+
635
  }
app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/ImportController.php CHANGED
@@ -74,9 +74,6 @@ class Chronopost_Chronorelais_Adminhtml_Chronorelais_ImportController extends Ma
74
  $comment = Mage::helper('chronorelais')->getConfigurationShippingComment();
75
  $includeComment = Mage::helper('chronorelais')->getConfigurationIncludeComment();
76
 
77
- /* debug */
78
- //$this->_getSession()->addSuccess($this->__('%s - %s - %s - %s', $sendEmail, $comment, $includeComment, $trackingTitle));
79
-
80
  /**
81
  * $k is line number
82
  * $v is line content array
@@ -104,9 +101,6 @@ class Chronopost_Chronorelais_Adminhtml_Chronorelais_ImportController extends Ma
104
  $orderId = $v[0];
105
  $trackingNumber = $v[1];
106
 
107
- /* for debug */
108
- //$this->_getSession()->addSuccess($this->__('Lecture ligne %s: %s - %s', $k, $orderId, $trackingNumber));
109
-
110
  /**
111
  * Try to load the order
112
  */
@@ -188,8 +182,6 @@ class Chronopost_Chronorelais_Adminhtml_Chronorelais_ImportController extends Ma
188
  case "chronoexpress":
189
  $carrier_code = $_shippingMethod[0];
190
  $popup = 1;
191
- /*$hash = Mage::helper('core')->urlEncode("order_id:{$order->getId()}:{$order->getProtectCode()}");
192
- $tracking_url = Mage::getBaseUrl().'chronorelais/relais/tracking/hash/'.$hash.'/';*/
193
  $tracking_url = str_replace('{tracking_number}', $trackingNumber, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
194
  $tracking_title = $this->__('Track Your Order');
195
  $tracking_order = '<p><a title="'.$tracking_title.'" href="'.$tracking_url.'"><b>'.$tracking_title.'</b></a></p>';
74
  $comment = Mage::helper('chronorelais')->getConfigurationShippingComment();
75
  $includeComment = Mage::helper('chronorelais')->getConfigurationIncludeComment();
76
 
 
 
 
77
  /**
78
  * $k is line number
79
  * $v is line content array
101
  $orderId = $v[0];
102
  $trackingNumber = $v[1];
103
 
 
 
 
104
  /**
105
  * Try to load the order
106
  */
182
  case "chronoexpress":
183
  $carrier_code = $_shippingMethod[0];
184
  $popup = 1;
 
 
185
  $tracking_url = str_replace('{tracking_number}', $trackingNumber, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
186
  $tracking_title = $this->__('Track Your Order');
187
  $tracking_order = '<p><a title="'.$tracking_title.'" href="'.$tracking_url.'"><b>'.$tracking_title.'</b></a></p>';
app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/Sales/BordereauController.php CHANGED
@@ -64,7 +64,6 @@ class Chronopost_Chronorelais_Adminhtml_Chronorelais_Sales_BordereauController e
64
  /* items */
65
  $items = $shipment->getAllItems();
66
  $weightTotal = 0;
67
- $nbTotal = 0;
68
 
69
  $maxAmount = $helper->getMaxAdValoremAmount();
70
  $adValoremAmount = $helper->assuranceAdValoremAmount();
@@ -74,17 +73,15 @@ class Chronopost_Chronorelais_Adminhtml_Chronorelais_Sales_BordereauController e
74
  foreach($items as $item) {
75
  $weightTotal += $item->getWeight() * $item->getQty();
76
  $totalAdValorem += $item->getPrice() * $item->getQty();
77
- /*$price = min($item->getPrice(),$maxAmount);
78
- if($price <= $maxAmount) {
79
- $totalAdValorem += $price * $item->getQty();
80
- }*/
81
  }
82
  /* Si montant < au montant minimum ad valorem => pas d'assurance */
83
  $totalAdValorem = 0;
84
  if($adValoremEnabled)
85
  {
86
  $totalAdValorem = min($totalAdValorem,$maxAmount);
87
- if($totalAdValorem < $adValoremAmount) $totalAdValorem = 0;
 
 
88
  }
89
 
90
  /* Shipping address */
64
  /* items */
65
  $items = $shipment->getAllItems();
66
  $weightTotal = 0;
 
67
 
68
  $maxAmount = $helper->getMaxAdValoremAmount();
69
  $adValoremAmount = $helper->assuranceAdValoremAmount();
73
  foreach($items as $item) {
74
  $weightTotal += $item->getWeight() * $item->getQty();
75
  $totalAdValorem += $item->getPrice() * $item->getQty();
 
 
 
 
76
  }
77
  /* Si montant < au montant minimum ad valorem => pas d'assurance */
78
  $totalAdValorem = 0;
79
  if($adValoremEnabled)
80
  {
81
  $totalAdValorem = min($totalAdValorem,$maxAmount);
82
+ if($totalAdValorem < $adValoremAmount) {
83
+ $totalAdValorem = 0;
84
+ }
85
  }
86
 
87
  /* Shipping address */
app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/Sales/ImpressionController.php CHANGED
@@ -1,1050 +1,1136 @@
1
- <?php
2
-
3
- require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
4
-
5
- class Chronopost_Chronorelais_Adminhtml_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
  }
1
+ <?php
2
+
3
+ require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
4
+
5
+ class Chronopost_Chronorelais_Adminhtml_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($fileName,$content,$contentType = 'application/octet-stream',$contentLength = null)
60
+ {
61
+ $session = Mage::getSingleton('admin/session');
62
+ if ($session->isFirstPageAfterLogin()) {
63
+ $this->_redirect($session->getUser()->getStartupPageUrl());
64
+ return $this;
65
+ }
66
+
67
+ $isFile = false;
68
+ $file = null;
69
+ if (is_array($content)) {
70
+ if (!isset($content['type']) || !isset($content['value'])) {
71
+ return $this;
72
+ }
73
+ if ($content['type'] == 'filename') {
74
+ $isFile = true;
75
+ $file = $content['value'];
76
+ $contentLength = filesize($file);
77
+ }
78
+ }
79
+
80
+ $this->getResponse()
81
+ ->setHttpResponseCode(200)
82
+ ->setHeader('Pragma', 'public', true)
83
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
84
+ ->setHeader('Content-type', $contentType, true)
85
+ ->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength, true)
86
+ ->setHeader('Content-Disposition', 'attachment; filename="'.$fileName.'"', true)
87
+ ->setHeader('Last-Modified', date('r'), true);
88
+
89
+ if (!is_null($content)) {
90
+ if ($isFile) {
91
+ $this->getResponse()->clearBody();
92
+ $this->getResponse()->sendHeaders();
93
+
94
+ $ioAdapter = new Varien_Io_File();
95
+ $ioAdapter->open(array('path' => $ioAdapter->dirname($file)));
96
+ $ioAdapter->streamOpen($file, 'r');
97
+ while ($buffer = $ioAdapter->streamRead()) {
98
+ print $buffer;
99
+ }
100
+ $ioAdapter->streamClose();
101
+ if (!empty($content['rm'])) {
102
+ $ioAdapter->rm($file);
103
+ }
104
+
105
+ exit(0);
106
+ } else {
107
+ $this->getResponse()->setBody($content);
108
+ }
109
+ }
110
+ return $this;
111
+ }
112
+
113
+ protected function _processDownloadMass($pdf_contents) {
114
+
115
+ $paths = array();
116
+ $this->createMediaChronopostFolder();
117
+ foreach ($pdf_contents as $pdf_content) {
118
+ $fileName = 'tmp-etiquette-'.date('H-i-s');
119
+ /* save pdf file */
120
+ $path = Mage::getBaseDir('media').'/chronopost/' . $fileName . '.pdf';
121
+ file_put_contents($path, $pdf_content);
122
+ $paths[] = $path;
123
+ }
124
+
125
+ /* creation d'un pdf unique */
126
+ $pdfMergeFileName = "merged-".date('YmdHis').".pdf";
127
+ $pathMerge = Mage::getBaseDir('media')."/chronopost/".$pdfMergeFileName;
128
+ $cmd = Mage::helper('chronorelais')->getConfigData('chronorelais/shipping/gs_path').' -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="'.$pathMerge.'" -dBATCH '. implode(' ', $paths);
129
+ $res_shell = shell_exec($cmd);
130
+
131
+ /* suppression des pdf temp */
132
+ foreach ($paths as $path) {
133
+ if(is_file($path)) {
134
+ unlink($path);
135
+ }
136
+ }
137
+
138
+ if ($res_shell === null) {
139
+ return $this->_redirectReferer();
140
+ }
141
+ else {
142
+ $this->_prepareDownloadResponse($pdfMergeFileName,array(
143
+ 'type' => 'filename',
144
+ 'value' => $pathMerge
145
+ ));
146
+ unlink($pathMerge);
147
+ }
148
+ }
149
+
150
+ protected function getTrackingNumber($shipmentId) {
151
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
152
+
153
+ //On récupère le numéro de tracking
154
+ $tracks = $shipment->getTracksCollection();
155
+ foreach ($tracks as $track) {
156
+ if ($track->getParentId() == $shipmentId) {
157
+ $this->_trackingNumbers .= $track->getnumber();
158
+ }
159
+ }
160
+
161
+ return $this->_trackingNumbers;
162
+ }
163
+
164
+ protected function getFilledValue($value) {
165
+ if ($value) {
166
+ return $this->removeaccents(trim($value));
167
+ } else {
168
+ return '';
169
+ }
170
+ }
171
+
172
+ protected function checkMobileNumber($value) {
173
+ if ($reqvalue = trim($value)) {
174
+ $_number = substr($reqvalue, 0, 2);
175
+ $fixed_array = array('01', '02', '03', '04', '05', '06', '06');
176
+ if (in_array($_number, $fixed_array)) {
177
+ return $reqvalue;
178
+ } else {
179
+ return '';
180
+ }
181
+ }
182
+ }
183
+
184
+ protected function getExpeditionParams($shipment, $_shippingMethod) {
185
+ $_order = $shipment->getOrder();
186
+ $_shippingAddress = $shipment->getShippingAddress();
187
+ $_billingAddress = $shipment->getBillingAddress();
188
+ $_helper = Mage::helper('chronorelais');
189
+
190
+ $shippingMethodAllow = array('chronorelais','chronopost','chronoexpress','chronopostc10','chronopostc18','chronopostcclassic','chronorelaiseurope','chronorelaisdom','chronopostsrdv','chronopostsameday');
191
+ if (in_array($_shippingMethod[0],$shippingMethodAllow)) {
192
+ $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
193
+
194
+ //header parameters
195
+ $header = array(
196
+ 'idEmit' => 'MAG',
197
+ 'accountNumber' => $_helper->getConfigurationAccountNumber(),
198
+ 'subAccount' => $_helper->getConfigurationSubAccountNumber()
199
+ );
200
+
201
+ //shipper parameters
202
+ $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
203
+ $shipper = array(
204
+ 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
205
+ 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
206
+ 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
207
+ 'shipperCivility' => $_helper->getConfigurationShipperInfo('civility'),
208
+ 'shipperContactName' => $_helper->getConfigurationShipperInfo('contactname'),
209
+ 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
210
+ 'shipperEmail' => $_helper->getConfigurationShipperInfo('email'),
211
+ 'shipperMobilePhone' => $shipperMobilePhone,
212
+ 'shipperName' => $_helper->getConfigurationShipperInfo('name'),
213
+ 'shipperName2' => $_helper->getConfigurationShipperInfo('name2'),
214
+ 'shipperPhone' => $_helper->getConfigurationShipperInfo('phone'),
215
+ 'shipperPreAlert' => '',
216
+ 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
217
+ );
218
+
219
+ //customer parameters
220
+ $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
221
+ $customer = array(
222
+ 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
223
+ 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
224
+ 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
225
+ 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
226
+ 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
227
+ 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
228
+ 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
229
+ 'customerMobilePhone' => $customerMobilePhone,
230
+ 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
231
+ 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
232
+ 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
233
+ 'customerPreAlert' => '',
234
+ 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
235
+ );
236
+
237
+ //recipient parameters
238
+ $recipient_address = $_shippingAddress->getStreet();
239
+ if (!isset($recipient_address[1])) {
240
+ $recipient_address[1] = '';
241
+ }
242
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
243
+ $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
244
+ $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
245
+ $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
246
+ //remove any alphabets in phone number
247
+
248
+ $recipientPhone = trim(preg_replace("/[^0-9\.\-]/", " ", $_shippingAddress->getTelephone()));
249
+
250
+ $recipient = array(
251
+ 'recipientAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
252
+ 'recipientAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
253
+ 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
254
+ 'recipientContactName' => $recipientName2,
255
+ 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
256
+ 'recipientEmail' => $customer_email,
257
+ 'recipientMobilePhone' => $recipientMobilePhone,
258
+ 'recipientName' => $recipientName,
259
+ 'recipientName2' => $recipientName2,
260
+ 'recipientPhone' => $recipientPhone,
261
+ 'recipientPreAlert' => '',
262
+ 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
263
+ );
264
+
265
+ //ref parameters
266
+ $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
267
+ if (!$recipientRef) {
268
+ $recipientRef = $_order->getCustomerId();
269
+ }
270
+ $shipperRef = $_order->getRealOrderId();
271
+
272
+ $ref = array(
273
+ 'recipientRef' => $recipientRef,
274
+ 'shipperRef' => $shipperRef
275
+ );
276
+
277
+ //skybill parameters
278
+ /* Livraison Samedi (Delivery Saturday) field */
279
+ $SaturdayShipping = 0; //default value for the saturday shipping
280
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais" || $_shippingMethod[0] == "chronorelaisdom") {
281
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
282
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
283
+ } else {
284
+ if ($_deliver_on_saturday == 'Yes') {
285
+ $_deliver_on_saturday = 1;
286
+ } else {
287
+ $_deliver_on_saturday = 0;
288
+ }
289
+ }
290
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
291
+
292
+ if($_shippingMethod[0] == "chronorelaisdom") {
293
+ if ($_deliver_on_saturday && $is_sending_day) {
294
+ $SaturdayShipping = 369;
295
+ } else {
296
+ $SaturdayShipping = 368;
297
+ }
298
+ } else {
299
+ if ($_deliver_on_saturday && $is_sending_day) {
300
+ $SaturdayShipping = 6;
301
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
302
+ $SaturdayShipping = 1;
303
+ }
304
+ }
305
+
306
+ }
307
+
308
+ $weight = 0;
309
+ foreach ($shipment->getItemsCollection() as $item) {
310
+ $weight += $item->weight * $item->qty;
311
+ }
312
+ if ($_helper->getConfigWeightUnit() == 'g') {
313
+ $weight = $weight / 1000; /* conversion g => kg */
314
+ }
315
+
316
+ /* si chronorelaiseurope : service : 337 si poids < 3kg ou 338 si > 3kg */
317
+ if($_shippingMethod[0] == "chronorelaiseurope") {
318
+ $weight <= 3 ? $SaturdayShipping = '337' : $SaturdayShipping = '338';
319
+ }
320
+
321
+
322
+ $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
323
+
324
+ $skybill = array(
325
+ 'codCurrency' => 'EUR',
326
+ 'codValue' => '',
327
+ 'content1' => '',
328
+ 'content2' => '',
329
+ 'content3' => '',
330
+ 'content4' => '',
331
+ 'content5' => '',
332
+ 'customsCurrency' => 'EUR',
333
+ 'customsValue' => '',
334
+ 'evtCode' => 'DC',
335
+ 'insuredCurrency' => 'EUR',
336
+ 'insuredValue' => '',
337
+ 'objectType' => 'MAR',
338
+ 'productCode' => $_helper->getChronoProductCodeToShipment($_shippingMethod[0]),
339
+ 'service' => $SaturdayShipping,
340
+ 'shipDate' => date('c'),
341
+ 'shipHour' => date('H'),
342
+ 'weight' => $weight,
343
+ 'weightUnit' => 'KGM'
344
+ );
345
+
346
+ $skybillParams = array(
347
+ 'mode' => $_helper->getConfigurationSkybillParam()
348
+ );
349
+
350
+ $expeditionArray = array(
351
+ 'headerValue' => $header,
352
+ 'shipperValue' => $shipper,
353
+ 'customerValue' => $customer,
354
+ 'recipientValue' => $recipient,
355
+ 'refValue' => $ref,
356
+ 'skybillValue' => $skybill,
357
+ 'skybillParamsValue' => $skybillParams,
358
+ 'password' => $_helper->getConfigurationAccountPass()
359
+ );
360
+
361
+ /* si chronopostsrdv : ajout parametres supplementaires */
362
+ if($_shippingMethod[0] == "chronopostsrdv") {
363
+
364
+ $chronopostsrdv_creneaux_info = $_shippingAddress->getData('chronopostsrdv_creneaux_info');
365
+ $chronopostsrdv_creneaux_info = json_decode($chronopostsrdv_creneaux_info,true);
366
+
367
+ $_dateRdvStart = new DateTime($chronopostsrdv_creneaux_info['deliveryDate']);
368
+ $_dateRdvStart->setTime($chronopostsrdv_creneaux_info['startHour'],$chronopostsrdv_creneaux_info['startMinutes']);
369
+
370
+ $_dateRdvEnd = new DateTime($chronopostsrdv_creneaux_info['deliveryDate']);
371
+ $_dateRdvEnd->setTime($chronopostsrdv_creneaux_info['endHour'],$chronopostsrdv_creneaux_info['endMinutes']);
372
+
373
+
374
+ $scheduledValue = array(
375
+ 'appointmentValue' => array(
376
+ 'timeSlotStartDate' => $_dateRdvStart->format("Y-m-d")."T".$_dateRdvStart->format("H:i:s"),
377
+ 'timeSlotEndDate' => $_dateRdvEnd->format("Y-m-d")."T".$_dateRdvEnd->format("H:i:s"),
378
+ 'timeSlotTariffLevel' => $chronopostsrdv_creneaux_info['tariffLevel']
379
+ )
380
+ );
381
+ $expeditionArray['scheduledValue'] = $scheduledValue;
382
+
383
+ /* modification productCode et service car dynamique pour ce mode de livraison */
384
+
385
+ $expeditionArray['skybillValue']['productCode'] = $chronopostsrdv_creneaux_info['productCode'];
386
+ $expeditionArray['skybillValue']['service'] = $chronopostsrdv_creneaux_info['serviceCode'];
387
+
388
+ }
389
+
390
+ return $expeditionArray;
391
+ }
392
+ }
393
+
394
+ protected function getEtiquetteUrl($shipmentId) {
395
+ //On récupère les infos d'expédition
396
+ $_helper = Mage::helper('chronorelais');
397
+
398
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
399
+ if ($_shipTracks = $shipment->getAllTracks()) {
400
+ foreach ($_shipTracks as $_shipTrack) {
401
+ if ($_shipTrack->getNumber() && $_shipTrack->getChronoReservationNumber()) {
402
+ $skybill = base64_decode($_shipTrack->getChronoReservationNumber());
403
+ break;
404
+ }
405
+ }
406
+ if ($skybill) {
407
+ return $skybill;
408
+ }
409
+ }
410
+
411
+ $_order = $shipment->getOrder();
412
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
413
+
414
+ $expeditionArray = $this->getExpeditionParams($shipment, $_shippingMethod);
415
+ $tracking_number = '';
416
+ if ($expeditionArray) {
417
+ $client = new SoapClient("https://www.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl", array('trace' => true));
418
+ try {
419
+ $webservbt = $client->shippingV3($expeditionArray);
420
+ if (!$webservbt->return->errorCode && $webservbt->return->skybill) {
421
+ $tracking_number = $webservbt->return->skybillNumber;
422
+ // Add tracking number for the shipment if not already exists.
423
+ if (!$this->_trackingNumbers && $webservbt->return->skybillNumber) {
424
+ $track = Mage::getModel('sales/order_shipment_track')
425
+ ->setNumber($webservbt->return->skybillNumber)
426
+ ->setChronoReservationNumber(base64_encode($webservbt->return->skybill))
427
+ ->setCarrier(ucwords($_shippingMethod[0]))
428
+ ->setCarrierCode($_shippingMethod[0])
429
+ ->setTitle(ucwords($_shippingMethod[0]))
430
+ ->setPopup(1);
431
+ $shipment->addTrack($track);
432
+
433
+ $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
434
+ $tracking_title = $this->__('Track Your Order');
435
+ $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
436
+
437
+ $comment = '';
438
+ $shipment->setEmailSent(true);
439
+ $this->_saveShipment($shipment);
440
+ $shipment->sendEmail(1, $tracking_order . $comment);
441
+ }
442
+ return $webservbt->return->skybill; // pdf base64
443
+ } else {
444
+ $this->_getSession()->addError($_helper->__($webservbt->return->errorMessage));
445
+ }
446
+ } catch (SoapFault $fault) {
447
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
448
+ }
449
+ }
450
+ }
451
+
452
+ public function getShipmentByOrderId($orderId) {
453
+ $_shipment = Mage::getResourceModel('sales/order_shipment_grid_collection')
454
+ ->addAttributeToFilter('order_id', $orderId)
455
+ ->getAllIds();
456
+ return $_shipment;
457
+ }
458
+
459
+ public function getShipmentByIncrementId($incrementId) {
460
+ $_shipment = Mage::getResourceModel('sales/order_shipment_grid_collection')
461
+ ->addAttributeToFilter('increment_id', $incrementId)
462
+ ->getAllIds();
463
+ return $_shipment;
464
+ }
465
+
466
+ public function initShipment($orderId,$savedQtys = '') {
467
+ $order = Mage::getModel('sales/order')->load($orderId);
468
+
469
+ /**
470
+ * Check order existing
471
+ */
472
+ if (!$order->getId()) {
473
+ $this->_getSession()->addError($this->__('The order no longer exists.'));
474
+ return false;
475
+ }
476
+ /**
477
+ * Check shipment is available to create separate from invoice
478
+ */
479
+ if ($order->getForcedDoShipmentWithInvoice()) {
480
+ $this->_getSession()->addError($this->__('Cannot do shipment for the order separately from invoice.'));
481
+ return false;
482
+ }
483
+ /**
484
+ * Check shipment create availability
485
+ */
486
+ if(empty($savedQtys)) {
487
+ $savedQtys = $this->_getItemQtys();
488
+ }
489
+ $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($savedQtys);
490
+ if(Mage::registry('current_shipment')) {
491
+ Mage::unregister ('current_shipment');
492
+ }
493
+ Mage::register('current_shipment', $shipment);
494
+ return $shipment;
495
+ }
496
+
497
+ public function createNewShipment($orderId,$savedQtys = '') {
498
+ $_helper = Mage::helper('chronorelais');
499
+ $skybill = '';
500
+ try {
501
+ if ($shipment = $this->initShipment($orderId,$savedQtys)) {
502
+ $shipment->register();
503
+
504
+ $_order = $shipment->getOrder();
505
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
506
+
507
+ $expeditionArray = $this->getExpeditionParams($shipment, $_shippingMethod);
508
+ $tracking_number = '';
509
+ if ($expeditionArray) {
510
+
511
+ $client = new SoapClient("https://www.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl", array('trace' => true));
512
+ try {
513
+ $expedition = $client->shippingV3($expeditionArray);
514
+ if (!$expedition->return->errorCode && $expedition->return->skybillNumber) {
515
+ $tracking_number = $expedition->return->skybillNumber;
516
+ $track = Mage::getModel('sales/order_shipment_track')
517
+ ->setNumber($expedition->return->skybillNumber)
518
+ ->setChronoReservationNumber(base64_encode($expedition->return->skybill))
519
+ ->setCarrier(ucwords($_shippingMethod[0]))
520
+ ->setCarrierCode($_shippingMethod[0])
521
+ ->setTitle(ucwords($_shippingMethod[0]))
522
+ ->setPopup(1);
523
+ $shipment->addTrack($track);
524
+ $skybill = $expedition->return->skybill;
525
+ } else {
526
+ $this->_getSession()->addError($_helper->__($expedition->return->errorMessage));
527
+ return;
528
+ }
529
+ } catch (SoapFault $fault) {
530
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
531
+ return;
532
+ }
533
+ }
534
+
535
+ $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
536
+ $tracking_title = $this->__('Track Your Order');
537
+ $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
538
+
539
+ $comment = '';
540
+ $shipment->setEmailSent(true);
541
+ $this->_saveShipment($shipment);
542
+ $shipment->sendEmail(1, $tracking_order . $comment);
543
+ $this->_getSession()->addSuccess($this->__('Shipment was successfully created.'));
544
+ return $skybill;
545
+ } else {
546
+ $this->_forward('noRoute');
547
+ return;
548
+ }
549
+ } catch (Mage_Core_Exception $e) {
550
+ $this->_getSession()->addError($e->getMessage());
551
+ return;
552
+ } catch (Exception $e) {
553
+ $this->_getSession()->addError($this->__('Can not save shipment: ' . $e->getMessage()));
554
+ return;
555
+ }
556
+ }
557
+
558
+ public function printMassAction() {
559
+ $orderIds = $this->getRequest()->getParam('order_ids');
560
+ $skybillArr = array();
561
+ $helper = Mage::helper('chronorelais');
562
+ foreach ($orderIds as $orderId) {
563
+ if ($_shipments = $this->getShipmentByOrderId($orderId)) {
564
+ if (count($_shipments) == 1) {
565
+ $shipmentId = $_shipments[0];
566
+ $skybill = $this->getEtiquetteUrl($shipmentId);
567
+ if ($skybill) {
568
+ $skybillArr[] = $skybill;
569
+ }
570
+ } else {
571
+ foreach ($_shipments as $_shipment) {
572
+ $skybill = $this->getEtiquetteUrl($_shipment);
573
+ if ($skybill) {
574
+ $skybillArr[] = $skybill;
575
+ }
576
+ }
577
+ }
578
+ } else {
579
+
580
+ $order = Mage::getModel('sales/order')->load($orderId);
581
+
582
+ /* If shipping method is Chronopost => check if shipping weight isn't over limit */
583
+ $chronopostMethods = array('chronorelais','chronopost','chronoexpress','chronopostc10','chronopostc18','chronopostcclassic','chronorelaiseurope','chronorelaisdom','chronopostsrdv','chronopostsameday');
584
+ $shippingMethod = $order->getShippingMethod();
585
+ $shippingMethod = explode("_", $shippingMethod);
586
+ $shippingMethod = $shippingMethod[0];
587
+ if(in_array($shippingMethod, $chronopostMethods)) {
588
+ $weightShipping = 0;
589
+ $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
590
+ foreach ($order->getItemsCollection() as $item) {
591
+ $weightShipping += $item->getWeight()*$item->getQtyOrdered();
592
+ }
593
+ if($helper->getConfigWeightUnit() == 'g')
594
+ {
595
+ $weightShipping = $weightShipping / 1000; // conversion g => kg
596
+ }
597
+ if($weightShipping > $weight_limit) {
598
+ /* multi shipping. 1 shipment by product */
599
+ foreach ($order->getItemsCollection() as $item) {
600
+ $qty = $item->getQtyOrdered();
601
+ for($i = 1; $i <= $qty; $i++) {
602
+ $skybill = $this->createNewShipment($orderId,array($item->getId() => '1'));
603
+ if ($skybill)
604
+ $skybillArr[] = $skybill;
605
+ }
606
+ }
607
+ }
608
+ else {
609
+ $skybill = $this->createNewShipment($orderId);
610
+ if ($skybill) {
611
+ $skybillArr[] = $skybill;
612
+ }
613
+ }
614
+ }
615
+ else {
616
+ $skybill = $this->createNewShipment($orderId);
617
+ if ($skybill) {
618
+ $skybillArr[] = $skybill;
619
+ }
620
+ }
621
+ }
622
+ }
623
+ if (count($skybillArr)) {
624
+ $this->_processDownloadMass($skybillArr);
625
+ }
626
+ else {
627
+ return $this->_redirectReferer();
628
+ }
629
+ }
630
+
631
+ public function printAction() {
632
+ // Appel via order_id
633
+ $orderId = $this->getRequest()->getParam('order_id');
634
+ $helper = Mage::helper('chronorelais');
635
+ if ($orderId) {
636
+ if ($_shipments = $this->getShipmentByOrderId($orderId)) {
637
+ if (count($_shipments) == 1) {
638
+ $shipmentId = $_shipments[0];
639
+ $skybillArr = $this->getEtiquetteUrl($shipmentId);
640
+ } else {
641
+ $track = "Cette commande contient plusieurs expéditions, cliquez sur chaque lien pour obtenir les étiquettes :<br>";
642
+ /*foreach ($_shipments as $_shipment) {
643
+ $url = str_replace('{trackingNumber}', $this->getEtiquetteUrl($_shipment), $helper->getConfigurationTrackingUrl());
644
+ $track .= '<a target="_blank" href="' . $url . '">' . $url . '</a><br />';
645
+ }*/
646
+ echo $track;
647
+ return;
648
+ }
649
+ } else {
650
+ $order = Mage::getModel('sales/order')->load($orderId);
651
+
652
+ /* If shipping method is Chronopost => check if shipping weight isn't over limit */
653
+ $chronopostMethods = array('chronorelais','chronopost','chronoexpress','chronopostc10','chronopostc18','chronopostcclassic','chronorelaiseurope','chronorelaisdom','chronopostsrdv','chronopostsameday');
654
+ $shippingMethod = $order->getShippingMethod();
655
+ $shippingMethod = explode("_", $shippingMethod);
656
+ $shippingMethod = $shippingMethod[0];
657
+ if(in_array($shippingMethod, $chronopostMethods)) {
658
+ $weightShipping = 0;
659
+ $shippingMethod = explode("_", $shippingMethod);
660
+ $shippingMethod = $shippingMethod[0];
661
+ $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
662
+ foreach ($order->getItemsCollection() as $item) {
663
+ $weightShipping += $item->getWeight()*$item->getQtyOrdered();
664
+ }
665
+ if($helper->getConfigWeightUnit() == 'g')
666
+ {
667
+ $weightShipping = $weightShipping / 1000; // conversion g => kg
668
+ }
669
+ if($weightShipping > $weight_limit) {
670
+ /* multi shipping. 1 shipment by product */
671
+ $skybillArr = array();
672
+ foreach ($order->getItemsCollection() as $item) {
673
+ $qty = $item->getQtyOrdered();
674
+ for($i = 1; $i <= $qty; $i++) {
675
+ $skybillArr[] = $this->createNewShipment($orderId,array($item->getId() => '1'));
676
+ }
677
+ }
678
+ }
679
+ else {
680
+ $skybillArr = $this->createNewShipment($orderId);
681
+ }
682
+ }
683
+ else {
684
+ $skybillArr = $this->createNewShipment($orderId);
685
+ }
686
+ }
687
+ } else {
688
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
689
+ if ($shipmentId) {
690
+ $skybillArr = $this->getEtiquetteUrl($shipmentId);
691
+ } else {
692
+ $shipmentIncrementId = $this->getRequest()->getParam('shipment_increment_id');
693
+ $shipmentId = $this->getShipmentByIncrementId($shipmentIncrementId);
694
+ $skybillArr = $this->getEtiquetteUrl($shipmentId[0]);
695
+ }
696
+ }
697
+
698
+
699
+ if ($skybillArr) {
700
+ try {
701
+ if(is_array($skybillArr)) {
702
+ $this->_processDownloadMass($skybillArr);
703
+ }
704
+ else {
705
+ $this->_prepareDownloadResponse('Etiquette_chronopost.pdf', $skybillArr);
706
+
707
+ }
708
+ } catch (Mage_Core_Exception $e) {
709
+ $this->_getSession()->addError($helper->__('Désolé, une erreur est survenu lors de la récupération de l\'étiquettes. Merci de contacter Chronopost ou de réessayer plus tard'));
710
+ }
711
+ }
712
+ else {
713
+ return $this->_redirectReferer();
714
+ }
715
+ }
716
+
717
+ public function massLivraisonSamediStatusAction() {
718
+ if ($this->getRequest()->getPost('status')) {
719
+ $this->saveLivraisonSamediStatusAction();
720
+ }
721
+ }
722
+
723
+ /* Save the Livraison le Samedi status to orders */
724
+
725
+ public function saveLivraisonSamediStatusAction() {
726
+ /* get the orders */
727
+ $orderIds = $this->getRequest()->getPost('order_ids');
728
+ $status = $this->getRequest()->getPost('status');
729
+ $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
730
+ $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
731
+ $exceptions = array();
732
+
733
+ foreach ($orderIds as $orderId) {
734
+ $order_details = Mage::getModel('sales/order')->load($orderId);
735
+ $shipping_method = '';
736
+ $livraison_le_samedi = $status;
737
+ if ($shipping_method = $order_details->getShippingMethod()) {
738
+ $shipping_method = explode('_', $shipping_method);
739
+ if ($shipping_method[0] == 'chronoexpress') {
740
+ $livraison_le_samedi = '--';
741
+ }
742
+ }
743
+ $condition = array(
744
+ $_connection->quoteInto('order_id = ?', $orderId),
745
+ );
746
+ $_connection->delete($_table, $condition);
747
+
748
+ $dataLine = array(
749
+ 'order_id' => $orderId,
750
+ 'livraison_le_samedi' => $livraison_le_samedi
751
+ );
752
+ try {
753
+ $_connection->insert($_table, $dataLine);
754
+ } catch (Exception $e) {
755
+ $exceptions[] = Mage::helper('chronorelais')->__('Order assigning error: ' . $e->getMessage());
756
+ }
757
+ }
758
+ if ($exceptions) {
759
+ $this->_getSession()->addError($exceptions);
760
+ } else {
761
+ $this->_getSession()->addSuccess($this->__('Livraison le Samedi statut a &eacute;t&eacute; ajout&eacute;'));
762
+ }
763
+ $this->_redirect('*/*/index');
764
+ }
765
+
766
+ /* Remove accents characters */
767
+
768
+ public function removeaccents($string) {
769
+ $stringToReturn = str_replace(
770
+ 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);
771
+ // Remove all remaining other unknown characters
772
+ $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
773
+ $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
774
+ $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
775
+ $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
776
+ return $stringToReturn;
777
+ }
778
+
779
+ /*
780
+ * *******************************************************************
781
+ * ******************** ETIQUETTE DE RETOUR **************************
782
+ * *******************************************************************
783
+ */
784
+
785
+ public function printEtiquetteRetourAction() {
786
+ $shipmentIncrementId = $this->getRequest()->getParam('shipment_increment_id');
787
+ $shipmentId = $this->getShipmentByIncrementId($shipmentIncrementId);
788
+ $shipmentId = $shipmentId[0];
789
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
790
+ $_order = $shipment->getOrder();
791
+ $_shippingAddress = $shipment->getShippingAddress();
792
+ $_billingAddress = $shipment->getBillingAddress();
793
+ $skillbill = $this->getEtiquetteRetourUrl($shipment); /* skillbill pdf encode base64*/
794
+
795
+ if ($skillbill) {
796
+ try {
797
+ $path = $this->savePdfWithContent($skillbill, $shipmentId);
798
+
799
+ $message_email = 'Bonjour,
800
+ <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.
801
+ <br />Cordialement,';
802
+
803
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
804
+
805
+ $mail = new Zend_Mail('utf-8');
806
+ $mail->setBodyHtml($message_email);
807
+ $mail->setFrom(Mage::getStoreConfig('contacts/email/recipient_email'));
808
+ $mail->setSubject($_order->getStoreName(1) . ' : Etiquette de retour chronopost');
809
+ $mail->createAttachment(file_get_contents($path), Zend_Mime::TYPE_OCTETSTREAM, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'etiquette_retour.pdf');
810
+
811
+ $mail->addTo($customer_email);
812
+ $mail->send();
813
+
814
+ $mail->clearRecipients();
815
+ $mail->addTo(Mage::getStoreConfig('contacts/email/recipient_email'));
816
+ $mail->send();
817
+
818
+ $this->_getSession()->addSuccess(Mage::helper('chronorelais')->__('L\'etiquette de retour à bien été envoyée au client.'));
819
+ } catch (Mage_Core_Exception $e) {
820
+ $this->_getSession()->addError(Mage::helper('chronorelais')->__('Désolé, une erreure est survenu lors de la récupération de l\'étiquettes. Merci de contacter Chronopost ou de réessayer plus tard'));
821
+ }
822
+ }
823
+ return $this->_redirectReferer();
824
+ }
825
+
826
+ protected function getEtiquetteRetourParams($shipment, $_shippingMethod) {
827
+ $_order = $shipment->getOrder();
828
+ $_shippingAddress = $shipment->getShippingAddress();
829
+ $_billingAddress = $shipment->getBillingAddress();
830
+ $_helper = Mage::helper('chronorelais');
831
+
832
+ if ($_shippingAddress->getCountryId() != 'FR'
833
+ && strpos($_shippingMethod[0], 'chronorelaiseurope') === false
834
+ && strpos($_shippingMethod[0], 'chronorelaisdom') === false
835
+ && strpos($_shippingMethod[0], 'chronopostsrdv') === false
836
+ ) {
837
+ $this->_getSession()->addError($_helper->__('Les retours sont disponibles uniquement pour la France'));
838
+ return;
839
+ }
840
+ $shippingMethodAllow = array('chronorelaiseurope','chronorelais','chronopost','chronopostc10','chronopostc18','chronopostsrdv');
841
+ if (!in_array($_shippingMethod[0], $shippingMethodAllow)) {
842
+ $this->_getSession()->addError($_helper->__('Les retours ne sont pas disponibles pour le mode de livraison ' . $_shippingMethod[0]));
843
+ return;
844
+ }
845
+
846
+ if (in_array($_shippingMethod[0], $shippingMethodAllow)) {
847
+ $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
848
+
849
+ //header parameters
850
+ $header = array(
851
+ 'idEmit' => 'MAG',
852
+ 'accountNumber' => $_helper->getConfigurationAccountNumber(),
853
+ 'subAccount' => $_helper->getConfigurationSubAccountNumber()
854
+ );
855
+
856
+ //shipper parameters
857
+ $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
858
+ $recipient = array(
859
+ 'recipientAdress1' => $_helper->getConfigurationShipperInfo('address1'),
860
+ 'recipientAdress2' => $_helper->getConfigurationShipperInfo('address2'),
861
+ 'recipientCity' => $_helper->getConfigurationShipperInfo('city'),
862
+ 'recipientCivility' => $_helper->getConfigurationShipperInfo('civility'),
863
+ 'recipientContactName' => $_helper->getConfigurationShipperInfo('contactname'),
864
+ 'recipientCountry' => $_helper->getConfigurationShipperInfo('country'),
865
+ 'recipientEmail' => $_helper->getConfigurationShipperInfo('email'),
866
+ 'recipientMobilePhone' => $shipperMobilePhone,
867
+ 'recipientName' => $_helper->getConfigurationShipperInfo('name'),
868
+ 'recipientName2' => $_helper->getConfigurationShipperInfo('name2'),
869
+ 'recipientPhone' => $_helper->getConfigurationShipperInfo('phone'),
870
+ 'recipientPreAlert' => '',
871
+ 'recipientZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
872
+ );
873
+
874
+ //customer parameters
875
+ $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
876
+ $customer = array(
877
+ 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
878
+ 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
879
+ 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
880
+ 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
881
+ 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
882
+ 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
883
+ 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
884
+ 'customerMobilePhone' => $customerMobilePhone,
885
+ 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
886
+ 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
887
+ 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
888
+ 'customerPreAlert' => '',
889
+ 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
890
+ );
891
+
892
+ //recipient parameters
893
+ $_recipientAddress = $_shippingAddress;
894
+ if(strpos($_shippingMethod[0],'chronorelais') !== false) {
895
+ // Nicolas, le 27/11/2014 : si Chronorelais, on doit utiliser l'adresse de facturation, non de livraison (qui est celle du relais)
896
+ $_recipientAddress = $_billingAddress;
897
+ }
898
+ $recipient_address = $_recipientAddress->getStreet();
899
+
900
+ // Champs forcément basés sur l'adresse de livraison
901
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
902
+ $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
903
+ $recipientName = $this->getFilledValue($_recipientAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
904
+ $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
905
+ //remove any alphabets in phone number
906
+
907
+ $recipientPhone = trim(preg_replace("/[^0-9\.\-]/", " ", $_shippingAddress->getTelephone()));
908
+ if (!isset($recipient_address[1])) {
909
+ $recipient_address[1] = '';
910
+ }
911
+
912
+ $shipper = array(
913
+ 'shipperAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
914
+ 'shipperAdress2' => $recipient_address[1] ? substr($this->getFilledValue($recipient_address[1]), 0, 38) : '',
915
+ 'shipperCity' => $this->getFilledValue($_recipientAddress->getCity()),
916
+ 'shipperCivility' => 'M',
917
+ 'shipperContactName' => $recipientName2,
918
+ 'shipperCountry' => $this->getFilledValue($_recipientAddress->getCountryId()),
919
+ 'shipperEmail' => $customer_email,
920
+ 'shipperMobilePhone' => $recipientMobilePhone,
921
+ 'shipperName' => $recipientName,
922
+ 'shipperName2' => $recipientName2,
923
+ 'shipperPhone' => $recipientPhone,
924
+ 'shipperPreAlert' => '',
925
+ 'shipperZipCode' => $this->getFilledValue($_recipientAddress->getPostcode()),
926
+ );
927
+
928
+ //ref parameters
929
+ $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
930
+ if (!$recipientRef) {
931
+ $recipientRef = $_order->getCustomerId();
932
+ }
933
+ $shipperRef = $_order->getRealOrderId();
934
+
935
+ $ref = array(
936
+ 'recipientRef' => $recipientRef,
937
+ 'shipperRef' => $shipperRef
938
+ );
939
+
940
+ //skybill parameters
941
+ /* Livraison Samedi (Delivery Saturday) field */
942
+ $SaturdayShipping = 0; //default value for the saturday shipping
943
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
944
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
945
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
946
+ } else {
947
+ if ($_deliver_on_saturday == 'Yes') {
948
+ $_deliver_on_saturday = 1;
949
+ } else {
950
+ $_deliver_on_saturday = 0;
951
+ }
952
+ }
953
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
954
+ if ($_deliver_on_saturday && $is_sending_day) {
955
+ $SaturdayShipping = 6;
956
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
957
+ $SaturdayShipping = 1;
958
+ }
959
+ }
960
+
961
+ $weight = 0;
962
+ foreach ($shipment->getItemsCollection() as $item) {
963
+ $weight += $item->weight * $item->qty;
964
+ }
965
+ if ($_helper->getConfigWeightUnit() == 'g') {
966
+ $weight = $weight / 1000; /* conversion g => kg */
967
+ }
968
+
969
+ $productCode = Chronopost_Chronorelais_Helper_Data::CHRONO_POST;
970
+ if($_shippingMethod[0] == 'chronorelaiseurope') {
971
+ $productCode = '3T';
972
+ //$weight <= 3 ? $SaturdayShipping = '337' : $SaturdayShipping = '338';
973
+ $SaturdayShipping = '332';
974
+ }
975
+
976
+ $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
977
+
978
+ $skybill = array(
979
+ 'codCurrency' => 'EUR',
980
+ 'codValue' => '',
981
+ 'content1' => '',
982
+ 'content2' => '',
983
+ 'content3' => '',
984
+ 'content4' => '',
985
+ 'content5' => '',
986
+ 'customsCurrency' => 'EUR',
987
+ 'customsValue' => '',
988
+ 'evtCode' => 'DC',
989
+ 'insuredCurrency' => 'EUR',
990
+ 'insuredValue' => '',
991
+ 'objectType' => 'MAR',
992
+ 'productCode' => $productCode,
993
+ 'service' => $SaturdayShipping,
994
+ 'shipDate' => date('c'),
995
+ 'shipHour' => date('H'),
996
+ 'weight' => $weight,
997
+ 'weightUnit' => 'KGM'
998
+ );
999
+
1000
+ $mode = $_helper->getConfigurationSkybillParam();
1001
+ if($_shippingMethod[0] == 'chronorelaiseurope') {
1002
+ $mode = 'PPR';
1003
+ }
1004
+ $skybillParams = array(
1005
+ 'mode' => $mode
1006
+ );
1007
+
1008
+ $expeditionArray = array(
1009
+ 'headerValue' => $header,
1010
+ 'shipperValue' => $shipper,
1011
+ 'customerValue' => $customer,
1012
+ 'recipientValue' => $recipient,
1013
+ 'refValue' => $ref,
1014
+ 'skybillValue' => $skybill,
1015
+ 'skybillParamsValue' => $skybillParams,
1016
+ 'password' => $_helper->getConfigurationAccountPass()
1017
+ );
1018
+ return $expeditionArray;
1019
+ }
1020
+ }
1021
+
1022
+ protected function getEtiquetteRetourUrl($shipment) {
1023
+ //On récupère les infos d'expédition
1024
+ $_helper = Mage::helper('chronorelais');
1025
+
1026
+ $_order = $shipment->getOrder();
1027
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
1028
+
1029
+ $expeditionArray = $this->getEtiquetteRetourParams($shipment, $_shippingMethod);
1030
+ if ($expeditionArray) {
1031
+ $client = new SoapClient("https://www.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl", array('trace' => true));
1032
+ try {
1033
+ $webservbt = $client->shippingV3($expeditionArray);
1034
+
1035
+ if (!$webservbt->return->errorCode && $webservbt->return->skybill) {
1036
+ return $webservbt->return->skybill;
1037
+ } else {
1038
+ $this->_getSession()->addError($_helper->__($webservbt->return->errorMessage));
1039
+ }
1040
+ } catch (SoapFault $fault) {
1041
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
1042
+ }
1043
+ }
1044
+ }
1045
+
1046
+ protected function savePdf($url, $shipmentId) {
1047
+ $this->createMediaChronopostFolder();
1048
+ $path = 'media/chronopost/etiquetteRetour-' . $shipmentId . '.pdf';
1049
+ file_put_contents($path, file_get_contents($url));
1050
+ return $path;
1051
+ }
1052
+
1053
+ protected function savePdfWithContent($content_base64, $shipmentId) {
1054
+ $this->createMediaChronopostFolder();
1055
+ $path = 'media/chronopost/etiquetteRetour-' . $shipmentId . '.pdf';
1056
+ file_put_contents($path, $content_base64);
1057
+ return $path;
1058
+ }
1059
+
1060
+ /* create folder media/chronopost if not exist */
1061
+ protected function createMediaChronopostFolder() {
1062
+ $path = 'media/chronopost';
1063
+ if(!is_dir($path)) {
1064
+ mkdir($path,0777);
1065
+ }
1066
+ }
1067
+
1068
+ protected function getShipmentObjectByOrderId($orderId) {
1069
+ $_shipment = Mage::getResourceModel('sales/order_shipment_collection')
1070
+ ->addAttributeToFilter('order_id', $orderId);
1071
+ return $_shipment;
1072
+ }
1073
+
1074
+ public function cancelMassAction() {
1075
+ $orderIds = $this->getRequest()->getParam('order_ids');
1076
+
1077
+ if($orderIds) {
1078
+ $nbEtiquettesDelete = 0;
1079
+ foreach($orderIds as $orderId) {
1080
+ $shipments = $this->getShipmentObjectByOrderId($orderId);
1081
+ if($shipments) {
1082
+ foreach($shipments as $shipment) {
1083
+
1084
+ $tracks = $shipment->getTracksCollection();
1085
+ foreach ($tracks as $track) {
1086
+
1087
+ /* numero chrono si getChronoReservationNumber non null */
1088
+ if($track->getChronoReservationNumber()) {
1089
+
1090
+ /* appel WS pour annuler LT */
1091
+ $webservbt = Mage::helper('chronorelais/webservice')->cancelSkybill($track->getNumber());
1092
+ if($webservbt) {
1093
+ /* suppression du numéro de tracking */
1094
+ if($webservbt->return->errorCode == 0) {
1095
+ $nbEtiquettesDelete++;
1096
+ $track->delete();
1097
+ } else {
1098
+ switch($webservbt->return->errorCode) {
1099
+ case "1" :
1100
+ $errorMessage = $this->__("Une erreur système est survenue");
1101
+ break;
1102
+ case "2" :
1103
+ $errorMessage = $this->__("le colis n'appartient pas au contrat passé en paramètre ou n'a pas encore été enregistré dans le système de tracking Chronopost");
1104
+ break;
1105
+ case "3" :
1106
+ $errorMessage = $this->__("Le colis ne peut être pas annulé car il a été pris en charge par Chronopost");
1107
+ break;
1108
+ default :
1109
+ $errorMessage = '';
1110
+ break;
1111
+ }
1112
+ $this->_getSession()->addError($this->__("Erreur lors de la suppression de l'étiquettes %s : %s.",$track->getNumber(),$errorMessage));
1113
+ }
1114
+ } else {
1115
+ $this->_getSession()->addError($this->__('Désolé, une erreur est survenu lors de la suppression de l\'étiquette %s. Merci de contacter Chronopost ou de réessayer plus tard',$track->getNumber()));
1116
+ }
1117
+ }
1118
+ }
1119
+ }
1120
+ }
1121
+ }
1122
+ if($nbEtiquettesDelete > 0) {
1123
+ if($nbEtiquettesDelete > 1) {
1124
+ $this->_getSession()->addSuccess($this->__('%s étiquettes de transport ont bien été annulées.',$nbEtiquettesDelete));
1125
+ } else {
1126
+ $this->_getSession()->addSuccess($this->__('%s étiquette de transport a bien été annulée.',$nbEtiquettesDelete));
1127
+ }
1128
+
1129
+ }
1130
+ } else {
1131
+ $this->_getSession()->addError($this->__("Veuillez sélectionner au moins une lettre de transport."));
1132
+ }
1133
+ $this->_redirect('*/*/index');
1134
+ }
1135
+
1136
  }
app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/Sales/Order/ShipmentController.php CHANGED
@@ -1,386 +1,429 @@
1
- <?php
2
-
3
- require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
4
-
5
- class Chronopost_Chronorelais_Adminhtml_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,$data) {
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,$data);
355
- }
356
- }
357
- else
358
- {
359
- $this->saveAndCreateEtiquette($shipment,$data);
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_Adminhtml_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,$data) {
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','chronorelaiseurope','chronorelaisdom','chronopostsrdv','chronopostsameday');
44
+ if (in_array($_shippingMethod[0],$shippingMethodAllow)) {
45
+
46
+ $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
47
+
48
+ //header parameters
49
+ $header = array(
50
+ 'idEmit' => 'MAG',
51
+ 'accountNumber' => $_helper->getConfigurationAccountNumber(),
52
+ 'subAccount' => $_helper->getConfigurationSubAccountNumber()
53
+ );
54
+
55
+ //shipper parameters
56
+ $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
57
+ $shipper = array(
58
+ 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
59
+ 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
60
+ 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
61
+ 'shipperCivility' => $_helper->getConfigurationShipperInfo('civility'),
62
+ 'shipperContactName' => $_helper->getConfigurationShipperInfo('contactname'),
63
+ 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
64
+ 'shipperEmail' => $_helper->getConfigurationShipperInfo('email'),
65
+ 'shipperMobilePhone' => $shipperMobilePhone,
66
+ 'shipperName' => $_helper->getConfigurationShipperInfo('name'),
67
+ 'shipperName2' => $_helper->getConfigurationShipperInfo('name2'),
68
+ 'shipperPhone' => $_helper->getConfigurationShipperInfo('phone'),
69
+ 'shipperPreAlert' => '',
70
+ 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
71
+ );
72
+
73
+ //customer parameters
74
+ $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
75
+ $customer = array(
76
+ 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
77
+ 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
78
+ 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
79
+ 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
80
+ 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
81
+ 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
82
+ 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
83
+ 'customerMobilePhone' => $customerMobilePhone,
84
+ 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
85
+ 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
86
+ 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
87
+ 'customerPreAlert' => '',
88
+ 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
89
+ );
90
+
91
+ //recipient parameters
92
+ $recipient_address = $_shippingAddress->getStreet();
93
+ if (!isset($recipient_address[1])) {
94
+ $recipient_address[1] = '';
95
+ }
96
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
97
+ $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
98
+ $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
99
+ $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
100
+
101
+ //remove any alphabets in phone number
102
+ $recipientPhone = trim(preg_replace("/[^0-9\.\-]/", " ", $_shippingAddress->getTelephone()));
103
+
104
+ $recipient = array(
105
+ 'recipientAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
106
+ 'recipientAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
107
+ 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
108
+ 'recipientContactName' => $recipientName2,
109
+ 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
110
+ 'recipientEmail' => $customer_email,
111
+ 'recipientMobilePhone' => $recipientMobilePhone,
112
+ 'recipientName' => $recipientName,
113
+ 'recipientName2' => $recipientName2,
114
+ 'recipientPhone' => $recipientPhone,
115
+ 'recipientPreAlert' => '',
116
+ 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
117
+ );
118
+
119
+ //ref parameters
120
+ $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
121
+ if (!$recipientRef) {
122
+ $recipientRef = $_order->getCustomerId();
123
+ }
124
+ $shipperRef = $_order->getRealOrderId();
125
+
126
+ $ref = array(
127
+ 'recipientRef' => $recipientRef,
128
+ 'shipperRef' => $shipperRef
129
+ );
130
+
131
+ //skybill parameters
132
+ /* Livraison Samedi (Delivery Saturday) field */
133
+ $SaturdayShipping = 0; //default value for the saturday shipping
134
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais" || $_shippingMethod[0] == "chronorelaisdom") {
135
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
136
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
137
+ } else {
138
+ if ($_deliver_on_saturday == 'Yes') {
139
+ $_deliver_on_saturday = 1;
140
+ } else {
141
+ $_deliver_on_saturday = 0;
142
+ }
143
+ }
144
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
145
+
146
+ if($_shippingMethod[0] == "chronorelaisdom") {
147
+ if ($_deliver_on_saturday && $is_sending_day) {
148
+ $SaturdayShipping = 369;
149
+ } else {
150
+ $SaturdayShipping = 368;
151
+ }
152
+ } else {
153
+ if ($_deliver_on_saturday && $is_sending_day) {
154
+ $SaturdayShipping = 6;
155
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
156
+ $SaturdayShipping = 1;
157
+ }
158
+ }
159
+
160
+ }
161
+
162
+ $weight = 0;
163
+ foreach ($shipment->getItemsCollection() as $item) {
164
+ $weight += $item->weight * $item->qty;
165
+ }
166
+ if ($_helper->getConfigWeightUnit() == 'g') {
167
+ $weight = $weight / 1000; /* conversion g => kg */
168
+ }
169
+
170
+ /* si chronorelaiseurope : service : 337 si poids < 3kg ou 338 si > 3kg */
171
+ if($_shippingMethod[0] == "chronorelaiseurope") {
172
+ $weight <= 3 ? $SaturdayShipping = '337' : $SaturdayShipping = '338';
173
+ }
174
+
175
+
176
+ $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
177
+
178
+ $skybill = array(
179
+ 'codCurrency' => 'EUR',
180
+ 'codValue' => '',
181
+ 'content1' => '',
182
+ 'content2' => '',
183
+ 'content3' => '',
184
+ 'content4' => '',
185
+ 'content5' => '',
186
+ 'customsCurrency' => 'EUR',
187
+ 'customsValue' => '',
188
+ 'evtCode' => 'DC',
189
+ 'insuredCurrency' => 'EUR',
190
+ 'insuredValue' => '',
191
+ 'objectType' => 'MAR',
192
+ 'productCode' => $_helper->getChronoProductCodeToShipment($_shippingMethod[0]),
193
+ 'service' => $SaturdayShipping,
194
+ 'shipDate' => date('c'),
195
+ 'shipHour' => date('H'),
196
+ 'weight' => $weight,
197
+ 'weightUnit' => 'KGM'
198
+ );
199
+
200
+ $skybillParams = array(
201
+ 'mode' => $_helper->getConfigurationSkybillParam()
202
+ );
203
+
204
+ $expeditionArray = array(
205
+ 'headerValue' => $header,
206
+ 'shipperValue' => $shipper,
207
+ 'customerValue' => $customer,
208
+ 'recipientValue' => $recipient,
209
+ 'refValue' => $ref,
210
+ 'skybillValue' => $skybill,
211
+ 'skybillParamsValue' => $skybillParams,
212
+ 'password' => $_helper->getConfigurationAccountPass()
213
+ );
214
+
215
+ /* si chronopostsrdv : ajout parametres supplementaires */
216
+ if($_shippingMethod[0] == "chronopostsrdv") {
217
+
218
+ $chronopostsrdv_creneaux_info = $_shippingAddress->getData('chronopostsrdv_creneaux_info');
219
+ $chronopostsrdv_creneaux_info = json_decode($chronopostsrdv_creneaux_info,true);
220
+
221
+ $_dateRdvStart = new DateTime($chronopostsrdv_creneaux_info['deliveryDate']);
222
+ $_dateRdvStart->setTime($chronopostsrdv_creneaux_info['startHour'],$chronopostsrdv_creneaux_info['startMinutes']);
223
+
224
+ $_dateRdvEnd = new DateTime($chronopostsrdv_creneaux_info['deliveryDate']);
225
+ $_dateRdvEnd->setTime($chronopostsrdv_creneaux_info['endHour'],$chronopostsrdv_creneaux_info['endMinutes']);
226
+
227
+
228
+ $scheduledValue = array(
229
+ 'appointmentValue' => array(
230
+ 'timeSlotStartDate' => $_dateRdvStart->format("Y-m-d")."T".$_dateRdvStart->format("H:i:s"),
231
+ 'timeSlotEndDate' => $_dateRdvEnd->format("Y-m-d")."T".$_dateRdvEnd->format("H:i:s"),
232
+ 'timeSlotTariffLevel' => $chronopostsrdv_creneaux_info['tariffLevel']
233
+ )
234
+ );
235
+ $expeditionArray['scheduledValue'] = $scheduledValue;
236
+
237
+ /* modification productCode et service car dynamique pour ce mode de livraison */
238
+
239
+ $expeditionArray['skybillValue']['productCode'] = $chronopostsrdv_creneaux_info['productCode'];
240
+ $expeditionArray['skybillValue']['service'] = $chronopostsrdv_creneaux_info['serviceCode'];
241
+
242
+ }
243
+
244
+ $tracking_order = '';
245
+
246
+ $client = new SoapClient("https://www.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl", array('trace' => true));
247
+ try {
248
+ $expedition = $client->shippingV3($expeditionArray);
249
+
250
+ if (!$expedition->return->errorCode && $expedition->return->skybillNumber) {
251
+ $track = Mage::getModel('sales/order_shipment_track')
252
+ ->setNumber($expedition->return->skybillNumber)
253
+ ->setChronoReservationNumber(base64_encode($expedition->return->skybill))
254
+ ->setCarrier(ucwords($_shippingMethod[0]))
255
+ ->setCarrierCode($_shippingMethod[0])
256
+ ->setTitle(ucwords($_shippingMethod[0]))
257
+ ->setPopup(1);
258
+ $shipment->addTrack($track);
259
+
260
+ $tracking_number = $expedition->return->skybillNumber;
261
+
262
+ $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
263
+ $tracking_title = $this->__('Track Your Order');
264
+ $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
265
+
266
+ } else {
267
+ $this->_getSession()->addError($_helper->__($expedition->return->errorMessage));
268
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
269
+ return;
270
+ }
271
+ } catch (SoapFault $fault) {
272
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
273
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
274
+ return;
275
+ }
276
+ }
277
+
278
+ $comment = '';
279
+ if (!empty($data['comment_text'])) {
280
+ $shipment->addComment($data['comment_text'], isset($data['comment_customer_notify']));
281
+ $comment = $data['comment_text'];
282
+ }
283
+
284
+ if (!empty($data['send_email'])) {
285
+ $shipment->setEmailSent(true);
286
+ }
287
+
288
+ $this->_saveShipment($shipment);
289
+ $shipment->sendEmail(!empty($data['send_email']), $tracking_order . $comment);
290
+ $this->_getSession()->addSuccess($this->__('Shipment was successfully created.'));
291
+ $this->_redirect('adminhtml/sales_order/view', array('order_id' => $shipment->getOrderId()));
292
+ return;
293
+ }
294
+
295
+ /**
296
+ * Initialize shipment model instance
297
+ *
298
+ * @return Mage_Sales_Model_Order_Shipment|bool
299
+ */
300
+ protected function _initShipment()
301
+ {
302
+ $this->_title($this->__('Sales'))->_title($this->__('Shipments'));
303
+ $helper = Mage::helper('chronorelais');
304
+ $shipment = false;
305
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
306
+ $orderId = $this->getRequest()->getParam('order_id');
307
+ if ($shipmentId) {
308
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
309
+ } elseif ($orderId) {
310
+ $order = Mage::getModel('sales/order')->load($orderId);
311
+
312
+ /**
313
+ * Check order existing
314
+ */
315
+ if (!$order->getId()) {
316
+ $this->_getSession()->addError($this->__('The order no longer exists.'));
317
+ return false;
318
+ }
319
+ /**
320
+ * Check shipment is available to create separate from invoice
321
+ */
322
+ if ($order->getForcedDoShipmentWithInvoice()) {
323
+ $this->_getSession()->addError($this->__('Cannot do shipment for the order separately from invoice.'));
324
+ return false;
325
+ }
326
+ /**
327
+ * Check shipment create availability
328
+ */
329
+ if (!$order->canShip()) {
330
+ $this->_getSession()->addError($this->__('Cannot do shipment for the order.'));
331
+ return false;
332
+ }
333
+ $savedQtys = $this->_getItemQtys();
334
+
335
+ /* If shipping method is Chronopost => check if shipping weight isn't over limit */
336
+ $chronopostMethods = array('chronopost_chronopost','chronoexpress_chronoexpress','chronorelais_chronorelais','chronopostc10_chronopostC10','chronopostc18_chronopostC18','chronopostcclassic_chronopostCClassic','chronopostsrdv_chronopostsrdv','chronopostsameday_chronopostsameday');
337
+ $shippingMethod = $order->getShippingMethod();
338
+ if(in_array($shippingMethod, $chronopostMethods)) {
339
+ $weightShipping = 0;
340
+ $shippingMethod = explode("_", $shippingMethod);
341
+ $shippingMethod = $shippingMethod[0];
342
+ $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
343
+ foreach($savedQtys as $iditem => $qty) {
344
+ $item = $order->getItemById($iditem);
345
+ $weightShipping += $item->getWeight()*$qty;
346
+ }
347
+ if($helper->getConfigWeightUnit() == 'g')
348
+ {
349
+ $weightShipping = $weightShipping / 1000; // conversion g => kg
350
+ }
351
+ if($weightShipping > $weight_limit) {
352
+
353
+ /* Create one shipment by product ordered */
354
+ foreach($savedQtys as $iditem => $qty) {
355
+ $item = $order->getItemById($iditem);
356
+ $weightShipping += $item->getWeight()*$qty;
357
+ for($i = 1; $i <= $qty; $i++) {
358
+ $shipment[] = Mage::getModel('sales/service_order', $order)->prepareShipment(array($item->getId() => '1'));
359
+
360
+ }
361
+ }
362
+ }
363
+ }
364
+
365
+
366
+ if(!$shipment)
367
+ {
368
+ $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($savedQtys);
369
+
370
+ $tracks = $this->getRequest()->getPost('tracking');
371
+ if ($tracks) {
372
+ foreach ($tracks as $data) {
373
+ if (empty($data['number'])) {
374
+ Mage::throwException($this->__('Tracking number cannot be empty.'));
375
+ }
376
+ $track = Mage::getModel('sales/order_shipment_track')
377
+ ->addData($data);
378
+ $shipment->addTrack($track);
379
+ }
380
+ }
381
+ }
382
+ }
383
+
384
+ Mage::register('current_shipment', $shipment);
385
+ return $shipment;
386
+ }
387
+
388
+ public function saveAction() {
389
+ $data = $this->getRequest()->getPost('shipment');
390
+ $orderId = $this->getRequest()->getParam('order_id');
391
+
392
+ try {
393
+
394
+ if ($shipment = $this->_initShipment()) {
395
+ if(is_array($shipment))
396
+ {
397
+ foreach($shipment as $ship) {
398
+ $this->saveAndCreateEtiquette($ship,$data);
399
+ }
400
+ }
401
+ else
402
+ {
403
+ $this->saveAndCreateEtiquette($shipment,$data);
404
+ }
405
+ } else {
406
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
407
+ return;
408
+ }
409
+
410
+ } catch (Mage_Core_Exception $e) {
411
+ $this->_getSession()->addError($e->getMessage());
412
+ } catch (Exception $e) {
413
+ $this->_getSession()->addError($this->__('Can not save shipment: ' . $e->getMessage()));
414
+ }
415
+ $this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
416
+ }
417
+
418
+ public function removeaccents($string) {
419
+ $stringToReturn = str_replace(
420
+ 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);
421
+ // Remove all remaining other unknown characters
422
+ $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
423
+ $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
424
+ $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
425
+ $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
426
+ return $stringToReturn;
427
+ }
428
+
429
+ }
app/code/community/Chronopost/Chronorelais/controllers/Checkout/MultishippingController.php CHANGED
@@ -25,24 +25,21 @@ class Chronopost_Chronorelais_Checkout_MultishippingController extends Mage_Chec
25
  $addresses = $this->_getCheckout()->getQuote()->getAllShippingAddresses();
26
  $relays = $this->getRequest()->getParam('shipping_method_chronorelais');
27
  foreach ($addresses as $address) {
28
- if (isset($shippingMethods[$address->getId()])) {
29
- if (substr($shippingMethods[$address->getId()], 0, 12) == "chronorelais") {
 
30
 
31
- $relaisId = $relays[$address->getId()];
32
- if ($relaisId != "") {
33
 
34
- $helper = Mage::helper('chronorelais/webservice');
35
- $relais = $helper->getDetailRelaisPoint($relaisId);
36
-
37
- if ($relais) {
38
- $address->setCity($relais->localite)
39
- ->setPostcode($relais->codePostal)
40
- ->setStreet(trim($relais->adresse1 . "\n" . $relais->adresse2 . " " . $relais->adresse3))
41
- ->setCompany($relais->nomEnseigne)
42
- ->setWRelayPointCode($relais->identifiantChronopostPointA2PAS)
43
- ->save()
44
- ->setCollectShippingRates(true);
45
- }
46
  }
47
  }
48
  }
@@ -73,9 +70,6 @@ class Chronopost_Chronorelais_Checkout_MultishippingController extends Mage_Chec
73
  $addresses = $this->_getCheckout()->getQuote()->getAllShippingAddresses();
74
  foreach ($addresses as $address) {
75
  if ($address->getId() == $this->getRequest()->get('index')) {
76
- /* $address->setPostcode($postcode)
77
- ->save()
78
- ->setCollectShippingRates(true); */
79
 
80
  $helper = Mage::helper('chronorelais/webservice');
81
  $webservbt = $helper->getPointsRelaisByCp($postcode);
25
  $addresses = $this->_getCheckout()->getQuote()->getAllShippingAddresses();
26
  $relays = $this->getRequest()->getParam('shipping_method_chronorelais');
27
  foreach ($addresses as $address) {
28
+ if (isset($shippingMethods[$address->getId()]) && substr($shippingMethods[$address->getId()], 0, 12) == "chronorelais" ) {
29
+ $relaisId = $relays[$address->getId()];
30
+ if ($relaisId != "") {
31
 
32
+ $helper = Mage::helper('chronorelais/webservice');
33
+ $relais = $helper->getDetailRelaisPoint($relaisId);
34
 
35
+ if ($relais) {
36
+ $address->setCity($relais->localite)
37
+ ->setPostcode($relais->codePostal)
38
+ ->setStreet(trim($relais->adresse1 . "\n" . $relais->adresse2 . " " . $relais->adresse3))
39
+ ->setCompany($relais->nomEnseigne)
40
+ ->setWRelayPointCode($relais->identifiantChronopostPointA2PAS)
41
+ ->save()
42
+ ->setCollectShippingRates(true);
 
 
 
 
43
  }
44
  }
45
  }
70
  $addresses = $this->_getCheckout()->getQuote()->getAllShippingAddresses();
71
  foreach ($addresses as $address) {
72
  if ($address->getId() == $this->getRequest()->get('index')) {
 
 
 
73
 
74
  $helper = Mage::helper('chronorelais/webservice');
75
  $webservbt = $helper->getPointsRelaisByCp($postcode);
app/code/community/Chronopost/Chronorelais/controllers/Checkout/OnepageController.php DELETED
@@ -1,249 +0,0 @@
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
- $shippingMethod = $this->getRequest()->getPost('shipping_method');
187
-
188
- if (extension_loaded('soap')) {
189
-
190
- $helper = Mage::helper('chronorelais/webservice');
191
- $webservbt = $helper->getPointRelaisByAddress();
192
-
193
- if ($webservbt) {
194
- $this->loadLayout('checkout_onepage_shippingchronorelais');
195
- $result['goto_section'] = 'shipping-method';
196
- $result['update_section'] = array(
197
- 'name' => 'shipping-method-'.$shippingMethod,
198
- 'html' => $this->_getChronoRelaisHtml()
199
- );
200
- $result['relaypoints'] = $webservbt;
201
- } else {
202
- $result['error'] = true;
203
- $result['message'] = $this->__('No point relay is associated with this postcode');
204
- }
205
- } else {
206
- $result['error'] = true;
207
- $result['message'] = $this->__('Sorry for inconvenience, The SOAP extension is not installed in the server. Please contact the site administrator.');
208
- }
209
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
210
- }
211
-
212
- /**
213
- * Change shipping postal code
214
- */
215
- public function changePostalCodeAction() {
216
- if ($this->_expireAjax()) {
217
- return;
218
- }
219
- $result = array();
220
- $webservbt = array();
221
- $postcode = $this->getRequest()->getPost('mappostalcode');
222
- $shippingMethod = $this->getRequest()->getPost('shipping_method');
223
- if ($postcode) {
224
- $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
225
- $address = $quote->getShippingAddress();
226
- $address->setPostcode($postcode)
227
- ->save()
228
- ->setCollectShippingRates(true);
229
-
230
- $helper = Mage::helper('chronorelais/webservice');
231
- $webservbt = $helper->getPointsRelaisByCp($postcode);
232
-
233
- }
234
- if ($webservbt) {
235
- $this->loadLayout('checkout_onepage_shippingchronorelais');
236
- $result['goto_section'] = 'shipping-method';
237
- $result['update_section'] = array(
238
- 'name' => 'shipping-method-'.$shippingMethod,
239
- 'html' => $this->_getChronoRelaisHtml()
240
- );
241
- $result['relaypoints'] = $webservbt;
242
- } else {
243
- $result['error'] = true;
244
- $result['message'] = $this->__('No point relay is associated with this postcode');
245
- }
246
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
247
- }
248
-
249
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Chronopost/Chronorelais/controllers/IndexController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_IndexController extends Mage_Core_Controller_Front_Action {
3
+
4
+ public function shippingmethodimageAction() {
5
+ $this->loadLayout();
6
+ echo $this->getLayout()
7
+ ->createBlock("checkout/onepage_shipping_method_available")
8
+ ->setTemplate("chronorelais/checkout/onepage/shipping_method_images.phtml")
9
+ ->toHtml();
10
+ }
11
+ }
app/code/community/Chronopost/Chronorelais/controllers/RelaisController.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
  class Chronopost_Chronorelais_RelaisController extends Mage_Core_Controller_Front_Action {
3
-
4
  public function filterAction() {
5
- $this->loadLayout();
6
  $this->renderLayout();
7
  }
8
-
9
  public function detailAction() {
10
- $this->loadLayout();
11
  $this->renderLayout();
12
  }
13
 
@@ -23,10 +23,99 @@ class Chronopost_Chronorelais_RelaisController extends Mage_Core_Controller_Fron
23
  if($req_values) {
24
  $order = Mage::getModel('sales/order')->load($req_values['id']);
25
  $popup_url = Mage::helper('shipping')->getTrackingPopupUrlBySalesModel($order);
26
- header('location: '.$popup_url); exit();
 
27
  }
28
  }
29
- }
30
- }
31
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
1
  <?php
2
  class Chronopost_Chronorelais_RelaisController extends Mage_Core_Controller_Front_Action {
3
+
4
  public function filterAction() {
5
+ $this->loadLayout();
6
  $this->renderLayout();
7
  }
8
+
9
  public function detailAction() {
10
+ $this->loadLayout();
11
  $this->renderLayout();
12
  }
13
 
23
  if($req_values) {
24
  $order = Mage::getModel('sales/order')->load($req_values['id']);
25
  $popup_url = Mage::helper('shipping')->getTrackingPopupUrlBySalesModel($order);
26
+ header('location: '.$popup_url);
27
+ exit();
28
  }
29
  }
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Get payment method step html
35
+ *
36
+ * @return string
37
+ */
38
+ protected function _getChronoRelaisHtml($shippingMethodCode = 'chronorelais') {
39
+ return $this->getLayout()->getBlock('root')->setMethodCode($shippingMethodCode)->toHtml();
40
+ }
41
+
42
+ /**
43
+ * Get relais
44
+ */
45
+ public function getRelaisAction() {
46
+ $result = array();
47
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
48
+ $address = $quote->getShippingAddress();
49
+ $shippingMethod = $this->getRequest()->getPost('shipping_method');
50
+
51
+ if (extension_loaded('soap')) {
52
+
53
+ $shippingMethodCode = explode("_", $shippingMethod);
54
+ $shippingMethodCode = $shippingMethodCode[0];
55
+
56
+ $helper = Mage::helper('chronorelais/webservice');
57
+ $webservbt = $helper->getPointRelaisByAddress($shippingMethodCode);
58
+
59
+ if ($webservbt) {
60
+ $this->loadLayout('checkout_onepage_shippingchronorelais');
61
+ $result['goto_section'] = 'shipping-method';
62
+ $result['update_section'] = array(
63
+ 'name' => 'shipping-method-'.$shippingMethod,
64
+ 'html' => $this->_getChronoRelaisHtml($shippingMethodCode)
65
+ );
66
+ $result['relaypoints'] = $webservbt;
67
+ } else {
68
+ $result['error'] = true;
69
+ $result['message'] = $this->__('No point relay is associated with this postcode');
70
+ }
71
+ } else {
72
+ $result['error'] = true;
73
+ $result['message'] = $this->__('Sorry for inconvenience, The SOAP extension is not installed in the server. Please contact the site administrator.');
74
+ }
75
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
76
+ }
77
+
78
+ /**
79
+ * Change shipping postal code
80
+ */
81
+ public function changePostalCodeAction() {
82
+
83
+ $result = array();
84
+ $webservbt = array();
85
+ $postcode = $this->getRequest()->getPost('mappostalcode');
86
+ $shippingMethod = $this->getRequest()->getPost('shipping_method');
87
+
88
+ $shippingMethodCode = explode("_", $shippingMethod);
89
+ $shippingMethodCode = $shippingMethodCode[0];
90
+
91
+ if ($postcode) {
92
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
93
+ $address = $quote->getShippingAddress();
94
+ $address->setPostcode($postcode)
95
+ ->save()
96
+ ->setCollectShippingRates(true);
97
+
98
+ $helper = Mage::helper('chronorelais/webservice');
99
+ $webservbt = $helper->getPointsRelaisByCp($postcode);
100
+
101
+ }
102
+ if ($webservbt) {
103
+ $this->loadLayout('checkout_onepage_shippingchronorelais');
104
+ $result['goto_section'] = 'shipping-method';
105
+ $result['update_section'] = array(
106
+ 'name' => 'shipping-method-'.$shippingMethod,
107
+ 'html' => $this->_getChronoRelaisHtml($shippingMethodCode)
108
+ );
109
+ $result['relaypoints'] = $webservbt;
110
+ } else {
111
+ $result['error'] = true;
112
+ $result['message'] = $this->__('No point relay is associated with this postcode');
113
+ }
114
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
115
+ }
116
+
117
+ public function resetSessionRelaiAction() {
118
+ unset($_SESSION['chronopost_relais_id']);
119
+ }
120
+
121
  }
app/code/community/Chronopost/Chronorelais/controllers/SrdvController.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_SrdvController extends Mage_Core_Controller_Front_Action {
3
+
4
+ /**
5
+ * Get payment method step html
6
+ *
7
+ * @return string
8
+ */
9
+ protected function _getChronopostSrdvHtml() {
10
+ return $this->getLayout()->getBlock('root')->toHtml();
11
+ }
12
+
13
+ /**
14
+ * Get planning
15
+ */
16
+ public function getPlanningAction() {
17
+ $result = array();
18
+ $shippingMethod = $this->getRequest()->getPost('shipping_method');
19
+
20
+ if (extension_loaded('soap')) {
21
+
22
+ $shippingMethodCode = explode("_", $shippingMethod);
23
+ $shippingMethodCode = $shippingMethodCode[0];
24
+
25
+ $this->loadLayout('checkout_onepage_shippingchronopostsrdv');
26
+ $result['goto_section'] = 'shipping-method';
27
+ $result['update_section'] = array(
28
+ 'name' => 'shipping-method-'.$shippingMethod,
29
+ 'html' => $this->_getChronopostSrdvHtml()
30
+ );
31
+ $result['planning'] = true;
32
+ } else {
33
+ $result['error'] = true;
34
+ $result['message'] = $this->__('Sorry for inconvenience, The SOAP extension is not installed in the server. Please contact the site administrator.');
35
+ }
36
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
37
+ }
38
+ }
app/code/community/Chronopost/Chronorelais/etc/config.xml CHANGED
@@ -1,465 +1,673 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Chronopost_Chronorelais>
5
- <version>1.0.6</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>/admin/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>adminhtml/chronorelais_export</action>
187
- <sort_order>10</sort_order>
188
- </export>
189
- <import translate="title">
190
- <title>Import</title>
191
- <action>adminhtml/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>adminhtml/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>adminhtml/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
- <admin>
265
- <routers>
266
- <adminhtml>
267
- <args>
268
- <modules>
269
- <Chronopost_Chronorelais before="Mage_Adminhtml">Chronopost_Chronorelais_Adminhtml</Chronopost_Chronorelais>
270
- </modules>
271
- </args>
272
- </adminhtml>
273
- </routers>
274
- </admin>
275
-
276
- <default>
277
- <chronorelais>
278
- <shipping>
279
- <google_map_api></google_map_api>
280
- <tracking_view_url><![CDATA[http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?lang=fr_FR&listeNumeros={tracking_number}]]>
281
- </tracking_view_url>
282
- <gs_path>/usr/bin/gs</gs_path>
283
- </shipping>
284
- <export_css>
285
- <file_extension>.chr</file_extension>
286
- <file_charset>ASCII-7</file_charset>
287
- <endofline_character>crlf</endofline_character>
288
- <field_delimiter>none</field_delimiter>
289
- <field_separator>;</field_separator>
290
- </export_css>
291
- <export_cso>
292
- <file_extension>.txt</file_extension>
293
- <file_charset>ISO-8859-1</file_charset>
294
- <endofline_character>crlf</endofline_character>
295
- <field_delimiter>none</field_delimiter>
296
- <field_separator>;</field_separator>
297
- </export_cso>
298
- <import>
299
- <default_tracking_title>Chronopost - Chronopost livraison express à domicile</default_tracking_title>
300
- <send_email>1</send_email>
301
- <shipping_comment></shipping_comment>
302
- <include_comment>0</include_comment>
303
- </import>
304
- </chronorelais>
305
- <carriers>
306
- <chronopost>
307
- <active>0</active>
308
- <title>Chronopost-Livraison express à domicile avant 13H</title>
309
- <model>Chronopost_Chronorelais_Model_Carrier_Chronopost</model>
310
- <tracking_view_url></tracking_view_url>
311
- <config>
312
- # Chronopost
313
- {
314
- label: "Chronopost-Livraison express à domicile avant 13H",
315
- code: "chronopost",
316
- description: "Colis livré le lendemain matin avant 13h à votre domicile. La veille de la livraison, vous êtes averti par e-mail et SMS.
317
- Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
318
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
319
- destination: "FR,MC",
320
- 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}",
321
- }
322
-
323
- # Chronopost Corse
324
- {
325
- label: "Chronopost livraison express à domicile en Corse",
326
- code: "chronopost_corse",
327
- description: "Colis livré le lendemain avant 13h, à l’adresse de votre choix.
328
- Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.
329
- En cas d’absence, le colis est mis en instance dans le bureau de Poste le plus proche.",
330
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
331
- destination: "FR(20*)",
332
- 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}",
333
- }
334
- </config>
335
- <weight_limit>30</weight_limit>
336
- <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
337
- <logo_url>chronopost.png</logo_url>
338
- <debug>0</debug>
339
- <stop_to_first_match>0</stop_to_first_match>
340
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
341
- <sort_order>1</sort_order>
342
- </chronopost>
343
- <chronoexpress>
344
- <active>0</active>
345
- <title>Chronopost Livraison express partout dans le monde</title>
346
- <model>Chronopost_Chronorelais_Model_Carrier_Chronoexpress</model>
347
- <tracking_view_url></tracking_view_url>
348
- <config>
349
- # Chronoexpress
350
- {
351
- label: "Chronopost Livraison express partout dans le monde",
352
- code: "chronoexpress",
353
- 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.
354
- Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
355
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
356
- 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",
357
- 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}",
358
- }
359
- </config>
360
- <weight_limit>30</weight_limit>
361
- <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
362
- <logo_url>Logo-Chronopost.jpg</logo_url>
363
- <debug>0</debug>
364
- <stop_to_first_match>0</stop_to_first_match>
365
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
366
- <sort_order>1</sort_order>
367
- </chronoexpress>
368
- <chronorelais>
369
- <active>0</active>
370
- <title>Chrono Relais</title>
371
- <model>Chronopost_Chronorelais_Model_Carrier_Chronorelais</model>
372
- <tracking_view_url></tracking_view_url>
373
- <config>
374
- # Chronorelais
375
- {
376
- label: "Chrono Relais : livraison express en relais Pickup",
377
- code: "chronorelais",
378
- description: "Colis livré en Chronopost le lendemain avant 13 h dans le relais Pickup de votre choix.
379
- Vous êtes averti par email ou SMS de l’arrivée du colis dans le point.
380
- Délai à compter de la prise en charge du colis par Chronopost.",
381
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
382
- destination: "FR",
383
- 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}",
384
- }
385
-
386
- # Voir exemple sur mode "Chronopost" pour un tarif spécifique pour la Corse
387
- </config>
388
- <weight_limit>20</weight_limit>
389
- <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
390
- <show_google_map>1</show_google_map>
391
- <logo_url>chronorelais.png</logo_url>
392
- <debug>0</debug>
393
- <stop_to_first_match>0</stop_to_first_match>
394
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
395
- <sort_order>2</sort_order>
396
- </chronorelais>
397
- <chronopostc10>
398
- <active>0</active>
399
- <title>Chronopost-Livraison express à domicile avant 10H</title>
400
- <model>Chronopost_Chronorelais_Model_Carrier_ChronopostC10</model>
401
- <tracking_view_url></tracking_view_url>
402
- <config>
403
- # ChronopostC10
404
- {
405
- label: "Chronopost-Livraison express à domicile avant 10H",
406
- code: "chronopostC10",
407
- description: "Colis livré le lendemain matin avant 10h à votre domicile. La veille de la livraison, vous êtes averti par e-mail et SMS.
408
- Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
409
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
410
- destination: "FR,MC",
411
- 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}",
412
- }
413
- </config>
414
- <weight_limit>30</weight_limit>
415
- <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
416
- <logo_url>chronopost.png</logo_url>
417
- <debug>0</debug>
418
- <stop_to_first_match>0</stop_to_first_match>
419
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
420
- <sort_order>3</sort_order>
421
- </chronopostc10>
422
- <chronopostc18>
423
- <active>0</active>
424
- <title>Chronopost-Livraison express à domicile avant 18H</title>
425
- <model>Chronopost_Chronorelais_Model_Carrier_ChronopostC18</model>
426
- <tracking_view_url></tracking_view_url>
427
- <config>
428
- # ChronopostC18
429
- {
430
- label: "Chronopost-Livraison express à domicile avant 18H",
431
- code: "chronopostC18",
432
- description: "Colis livré le lendemain matin avant 18h à votre domicile. La veille de la livraison, vous êtes averti par e-mail et SMS.
433
- Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
434
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
435
- destination: "FR,MC",
436
- 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}",
437
- }
438
- </config>
439
- <weight_limit>30</weight_limit>
440
- <quickcost>0</quickcost>
441
- <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
442
- <logo_url>chronopost.png</logo_url>
443
- <debug>0</debug>
444
- <stop_to_first_match>0</stop_to_first_match>
445
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
446
- <sort_order>4</sort_order>
447
- </chronopostc18>
448
- <chronopostcclassic>
449
- <active>0</active>
450
- <title>Chronopost Livraison dans certaines villes Européennes</title>
451
- <model>Chronopost_Chronorelais_Model_Carrier_ChronopostCClassic</model>
452
- <tracking_view_url></tracking_view_url>
453
- <config></config>
454
- <weight_limit>30</weight_limit>
455
- <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
456
- <logo_url>chronopost.png</logo_url>
457
- <debug>0</debug>
458
- <stop_to_first_match>0</stop_to_first_match>
459
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
460
- <sort_order>5</sort_order>
461
- </chronopostcclassic>
462
- </carriers>
463
- </default>
464
-
465
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Chronopost_Chronorelais>
5
+ <version>1.3.0</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
+ </models>
20
+ <blocks>
21
+ <chronorelais>
22
+ <class>Chronopost_Chronorelais_Block</class>
23
+ </chronorelais>
24
+ <adminhtml>
25
+ <rewrite>
26
+ <sales_order_shipment_view>Chronopost_Chronorelais_Block_Sales_Order_Shipment_View</sales_order_shipment_view>
27
+ </rewrite>
28
+ </adminhtml>
29
+ </blocks>
30
+ <helpers>
31
+ <chronorelais>
32
+ <class>Chronopost_Chronorelais_Helper</class>
33
+ </chronorelais>
34
+ </helpers>
35
+
36
+ <resources>
37
+ <sales>
38
+ <shipping>
39
+ <carriers>
40
+ <chronorelais>
41
+ <class>Chronopost_Chronorelais_Model_Carrier_Chronorelais</class>
42
+ </chronorelais>
43
+ <chronopost>
44
+ <class>Chronopost_Chronorelais_Model_Carrier_Chronopost</class>
45
+ </chronopost>
46
+ <chronoexpress>
47
+ <class>Chronopost_Chronorelais_Model_Carrier_Chronoexpress</class>
48
+ </chronoexpress>
49
+ </carriers>
50
+ </shipping>
51
+ </sales>
52
+ <chronorelais_setup>
53
+ <setup>
54
+ <module>Chronopost_Chronorelais</module>
55
+ <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
56
+ </setup>
57
+ <connection>
58
+ <use>core_setup</use>
59
+ </connection>
60
+ </chronorelais_setup>
61
+ <chronorelais_write>
62
+ <connection>
63
+ <use>core_write</use>
64
+ </connection>
65
+ </chronorelais_write>
66
+
67
+ <chronorelais_read>
68
+ <connection>
69
+ <use>core_read</use>
70
+ </connection>
71
+ </chronorelais_read>
72
+ </resources>
73
+
74
+ <rewrite>
75
+ <chronopost_chronorelais_checkout_multishipping>
76
+ <from><![CDATA[#^/checkout/multishipping/#]]>
77
+ </from>
78
+ <to>/chronorelais/checkout_multishipping/</to>
79
+ </chronopost_chronorelais_checkout_multishipping>
80
+ <chronopost_chronorelais_sales_order_shipment>
81
+ <from><![CDATA[#^/(.*)sales_order_shipment/save/#]]>
82
+ </from>
83
+ <to><![CDATA[/$1chronorelais_sales_order_shipment/save/]]></to>
84
+ </chronopost_chronorelais_sales_order_shipment>
85
+ </rewrite>
86
+
87
+ <fieldsets>
88
+ <sales_copy_order_billing_address>
89
+ <w_relay_point_code>
90
+ <to_order>*</to_order>
91
+ </w_relay_point_code>
92
+ </sales_copy_order_billing_address>
93
+ <sales_copy_order_shipping_address>
94
+ <w_relay_point_code>
95
+ <to_order>*</to_order>
96
+ </w_relay_point_code>
97
+ </sales_copy_order_shipping_address>
98
+ <sales_convert_quote_address>
99
+ <w_relay_point_code>
100
+ <to_order_address>*</to_order_address>
101
+ <to_customer_address>*</to_customer_address>
102
+ </w_relay_point_code>
103
+ <chronopostsrdv_creneaux_info>
104
+ <to_order_address>*</to_order_address>
105
+ <to_customer_address>*</to_customer_address>
106
+ <to_order>*</to_order>
107
+ </chronopostsrdv_creneaux_info>
108
+ </sales_convert_quote_address>
109
+ <sales_convert_order_address>
110
+ <w_relay_point_code>
111
+ <to_quote_address>*</to_quote_address>
112
+ </w_relay_point_code>
113
+ </sales_convert_order_address>
114
+ <customer_address>
115
+ <w_relay_point_code>
116
+ <to_quote_address>*</to_quote_address>
117
+ </w_relay_point_code>
118
+ </customer_address>
119
+ </fieldsets>
120
+
121
+ </global>
122
+
123
+ <frontend>
124
+ <routers>
125
+ <chronorelais>
126
+ <use>standard</use>
127
+ <args>
128
+ <module>Chronopost_Chronorelais</module>
129
+ <frontName>chronorelais</frontName>
130
+ </args>
131
+ </chronorelais>
132
+ </routers>
133
+
134
+ <layout>
135
+ <updates>
136
+ <chronorelais>
137
+ <file>chronorelais.xml</file>
138
+ </chronorelais>
139
+ </updates>
140
+ </layout>
141
+ <translate>
142
+ <modules>
143
+ <Chronopost_Chronorelais>
144
+ <files>
145
+ <default>Chronopost_Chronorelais.csv</default>
146
+ </files>
147
+ </Chronopost_Chronorelais>
148
+ </modules>
149
+ </translate>
150
+
151
+ <events>
152
+ <controller_action_predispatch_checkout_onepage_index>
153
+ <observers>
154
+ <check_soap_exists>
155
+ <class>chronorelais/observer</class>
156
+ <method>checkSoapExists</method>
157
+ </check_soap_exists>
158
+ </observers>
159
+ </controller_action_predispatch_checkout_onepage_index>
160
+
161
+ <controller_action_predispatch_checkout_onepage_saveBilling>
162
+ <observers>
163
+ <savebilling_before>
164
+ <class>chronorelais/observer</class>
165
+ <method>saveBillingBefore</method>
166
+ </savebilling_before>
167
+ </observers>
168
+ </controller_action_predispatch_checkout_onepage_saveBilling>
169
+
170
+ <controller_action_predispatch_checkout_onepage_saveShipping>
171
+ <observers>
172
+ <saveshipping_before>
173
+ <class>chronorelais/observer</class>
174
+ <method>saveShippingBefore</method>
175
+ </saveshipping_before>
176
+ </observers>
177
+ </controller_action_predispatch_checkout_onepage_saveShipping>
178
+
179
+ <controller_action_predispatch_checkout_onepage_saveShippingMethod>
180
+ <observers>
181
+ <saveshippingmethod_before>
182
+ <class>chronorelais/observer</class>
183
+ <method>saveShippingMethodBefore</method>
184
+ </saveshippingmethod_before>
185
+ </observers>
186
+ </controller_action_predispatch_checkout_onepage_saveShippingMethod>
187
+
188
+ <controller_action_predispatch_onestepcheckout_ajax_set_methods_separate>
189
+ <observers>
190
+ <saveshippingmethod_idev_onestepcheckout_before>
191
+ <class>chronorelais/observer</class>
192
+ <method>saveShippingMethodBefore</method>
193
+ </saveshippingmethod_idev_onestepcheckout_before>
194
+ </observers>
195
+ </controller_action_predispatch_onestepcheckout_ajax_set_methods_separate>
196
+
197
+ <sales_order_place_before>
198
+ <observers>
199
+ <check_relay_point>
200
+ <type>singleton</type>
201
+ <class>chronorelais/observer</class>
202
+ <method>checkRelayPoint</method>
203
+ </check_relay_point>
204
+ </observers>
205
+ </sales_order_place_before>
206
+
207
+ <sales_convert_quote_address_to_order>
208
+ <observers>
209
+ <update_order_with_relay_address>
210
+ <type>singleton</type>
211
+ <class>chronorelais/observer</class>
212
+ <method>updateShippingAddress</method>
213
+ </update_order_with_relay_address>
214
+ </observers>
215
+ </sales_convert_quote_address_to_order>
216
+
217
+ </events>
218
+ </frontend>
219
+
220
+ <!-- <admin>
221
+ <routers>
222
+ <chronorelais>
223
+ <use>admin</use>
224
+ <args>
225
+ <module>Chronopost_Chronorelais</module>
226
+ <frontName>chronorelais</frontName>
227
+ </args>
228
+ </chronorelais>
229
+ </routers>
230
+ </admin> -->
231
+ <adminhtml>
232
+ <layout>
233
+ <updates>
234
+ <chronorelais>
235
+ <file>chronorelais.xml</file>
236
+ </chronorelais>
237
+ </updates>
238
+ </layout>
239
+ <menu>
240
+ <sales>
241
+ <children>
242
+ <chronorelais translate="title"> <!-- TODO faire marcher : module="chronorelais" (aussi dans les children) -->
243
+ <title>Chronopost</title>
244
+ <sort_order>15</sort_order>
245
+ <children>
246
+ <export translate="title">
247
+ <title>Export</title>
248
+ <action>adminhtml/chronorelais_export</action>
249
+ <sort_order>10</sort_order>
250
+ </export>
251
+ <import translate="title">
252
+ <title>Import</title>
253
+ <action>adminhtml/chronorelais_import</action>
254
+ <sort_order>20</sort_order>
255
+ </import>
256
+ <impression translate="title" module="sales">
257
+ <title>Impression des étiquettes</title>
258
+ <action>adminhtml/chronorelais_sales_impression</action>
259
+ <sort_order>30</sort_order>
260
+ </impression>
261
+ <bordereau translate="title" module="sales">
262
+ <title>Bordereau de fin de journée</title>
263
+ <action>adminhtml/chronorelais_sales_bordereau</action>
264
+ <sort_order>40</sort_order>
265
+ </bordereau>
266
+ </children>
267
+ </chronorelais>
268
+ </children>
269
+ </sales>
270
+ </menu>
271
+ <acl>
272
+ <resources>
273
+ <admin>
274
+ <children>
275
+ <sales>
276
+ <children>
277
+ <chronorelais translate="title">
278
+ <title>Chronopost</title>
279
+ <sort_order>15</sort_order>
280
+ <children>
281
+ <export translate="title">
282
+ <title>Export</title>
283
+ <sort_order>10</sort_order>
284
+ </export>
285
+ <import translate="title">
286
+ <title>Import</title>
287
+ <sort_order>20</sort_order>
288
+ </import>
289
+ <impression translate="title" module="sales">
290
+ <title>Impression des étiquettes</title>
291
+ <sort_order>30</sort_order>
292
+ </impression>
293
+ </children>
294
+ </chronorelais>
295
+ </children>
296
+ </sales>
297
+ <system>
298
+ <children>
299
+ <config>
300
+ <children>
301
+ <chronorelais translate="title" module="chronorelais">
302
+ <title>Chronopost</title>
303
+ <sort_order>100</sort_order>
304
+ </chronorelais>
305
+ </children>
306
+ </config>
307
+ </children>
308
+ </system>
309
+ </children>
310
+ </admin>
311
+ </resources>
312
+ </acl>
313
+
314
+ <translate>
315
+ <modules>
316
+ <Chronopost_Chronorelais>
317
+ <files>
318
+ <default>Chronopost_Chronorelais.csv</default>
319
+ </files>
320
+ </Chronopost_Chronorelais>
321
+ </modules>
322
+ </translate>
323
+
324
+ </adminhtml>
325
+
326
+ <admin>
327
+ <routers>
328
+ <adminhtml>
329
+ <args>
330
+ <modules>
331
+ <Chronopost_Chronorelais before="Mage_Adminhtml">Chronopost_Chronorelais_Adminhtml</Chronopost_Chronorelais>
332
+ </modules>
333
+ </args>
334
+ </adminhtml>
335
+ </routers>
336
+ </admin>
337
+
338
+ <default>
339
+ <chronorelais>
340
+ <shipping>
341
+ <google_map_api></google_map_api>
342
+ <tracking_view_url><![CDATA[http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?lang=fr_FR&listeNumeros={tracking_number}]]>
343
+ </tracking_view_url>
344
+ <gs_path>/usr/bin/gs</gs_path>
345
+ </shipping>
346
+ <export_css>
347
+ <file_extension>.chr</file_extension>
348
+ <file_charset>ASCII-7</file_charset>
349
+ <endofline_character>crlf</endofline_character>
350
+ <field_delimiter>none</field_delimiter>
351
+ <field_separator>;</field_separator>
352
+ </export_css>
353
+ <export_cso>
354
+ <file_extension>.txt</file_extension>
355
+ <file_charset>ISO-8859-1</file_charset>
356
+ <endofline_character>crlf</endofline_character>
357
+ <field_delimiter>none</field_delimiter>
358
+ <field_separator>;</field_separator>
359
+ </export_cso>
360
+ <import>
361
+ <default_tracking_title>Chronopost - Chronopost livraison express à domicile</default_tracking_title>
362
+ <send_email>1</send_email>
363
+ <shipping_comment></shipping_comment>
364
+ <include_comment>0</include_comment>
365
+ </import>
366
+ <saturday>
367
+ <startday>thursday:18:00</startday>
368
+ <endday>friday:15:00</endday>
369
+ </saturday>
370
+ </chronorelais>
371
+ <carriers>
372
+ <chronopost>
373
+ <active>0</active>
374
+ <title>Chronopost-Livraison express à domicile avant 13H</title>
375
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronopost</model>
376
+ <tracking_view_url></tracking_view_url>
377
+ <config>
378
+ # Chronopost
379
+ {
380
+ label: "Chronopost-Livraison express à domicile avant 13H",
381
+ code: "chronopost",
382
+ description: "En 24h à votre domicile! Commande livrée le lendemain matin avant 13h.
383
+ Vous pouvez reprogrammer votre livraison en cas d'absence.",
384
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
385
+ destination: "FR,MC",
386
+ 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}",
387
+ }
388
+
389
+ # Chronopost Corse
390
+ {
391
+ label: "Chronopost livraison express à domicile en Corse",
392
+ code: "chronopost_corse",
393
+ description: "Colis livré le lendemain avant 13h, à l’adresse de votre choix.
394
+ Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.
395
+ En cas d’absence, le colis est mis en instance dans le bureau de Poste le plus proche.",
396
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
397
+ destination: "FR(20*)",
398
+ 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}",
399
+ }
400
+ </config>
401
+ <weight_limit>30</weight_limit>
402
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?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>1</sort_order>
408
+ </chronopost>
409
+ <chronoexpress>
410
+ <active>0</active>
411
+ <title>Chronopost Livraison express partout dans le monde</title>
412
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronoexpress</model>
413
+ <tracking_view_url></tracking_view_url>
414
+ <config>
415
+ # Chronoexpress
416
+ {
417
+ label: "Chronopost Livraison express partout dans le monde",
418
+ code: "chronoexpress",
419
+ description: "En express à votre domicile! Commande livrée en Express à l'adresse de votre choix.",
420
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
421
+ 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",
422
+ 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}",
423
+ }
424
+ </config>
425
+ <weight_limit>30</weight_limit>
426
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
427
+ <logo_url>Logo-Chronopost.jpg</logo_url>
428
+ <debug>0</debug>
429
+ <stop_to_first_match>0</stop_to_first_match>
430
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
431
+ <sort_order>2</sort_order>
432
+ </chronoexpress>
433
+ <chronorelais>
434
+ <active>0</active>
435
+ <title>Chrono Relais</title>
436
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronorelais</model>
437
+ <tracking_view_url></tracking_view_url>
438
+ <config>
439
+ # Chronorelais
440
+ {
441
+ label: "Chrono Relais : livraison express en relais Pickup",
442
+ code: "chronorelais",
443
+ description: "En 24h en relais Pickup! Commande livrée le lendemain dans le relais
444
+ Pickup de votre choix, parmi 7500 points répartis sur toute la France.",
445
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
446
+ destination: "FR",
447
+ 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}",
448
+ }
449
+
450
+ # Voir exemple sur mode "Chronopost" pour un tarif spécifique pour la Corse
451
+ </config>
452
+ <weight_limit>20</weight_limit>
453
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
454
+ <show_google_map>1</show_google_map>
455
+ <logo_url>chronorelais.png</logo_url>
456
+ <debug>0</debug>
457
+ <stop_to_first_match>0</stop_to_first_match>
458
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
459
+ <sort_order>3</sort_order>
460
+ <max_distance_search>15</max_distance_search>
461
+ <max_point_chronopost>5</max_point_chronopost>
462
+ <point_relai_ws_method>recherchePointChronopost</point_relai_ws_method>
463
+ <add_address_to_ws>1</add_address_to_ws>
464
+ <can_change_postcode>1</can_change_postcode>
465
+ </chronorelais>
466
+ <chronopostc10>
467
+ <active>0</active>
468
+ <title>Chronopost-Livraison express à domicile avant 10H</title>
469
+ <model>Chronopost_Chronorelais_Model_Carrier_ChronopostC10</model>
470
+ <tracking_view_url></tracking_view_url>
471
+ <config>
472
+ # ChronopostC10
473
+ {
474
+ label: "Chronopost-Livraison express à domicile avant 10H",
475
+ code: "chronopostC10",
476
+ description: "En 24h à votre domicile! Commande livrée le lendemain matin avant 10h.
477
+ Vous pouvez reprogrammer votre livraison en cas d'absence.",
478
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
479
+ destination: "FR,MC",
480
+ 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}",
481
+ }
482
+ </config>
483
+ <weight_limit>30</weight_limit>
484
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
485
+ <logo_url>chronopost.png</logo_url>
486
+ <debug>0</debug>
487
+ <stop_to_first_match>0</stop_to_first_match>
488
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
489
+ <sort_order>4</sort_order>
490
+ </chronopostc10>
491
+ <chronopostc18>
492
+ <active>0</active>
493
+ <title>Chronopost-Livraison express à domicile avant 18H</title>
494
+ <model>Chronopost_Chronorelais_Model_Carrier_ChronopostC18</model>
495
+ <tracking_view_url></tracking_view_url>
496
+ <config>
497
+ # ChronopostC18
498
+ {
499
+ label: "Chronopost-Livraison express à domicile avant 18H",
500
+ code: "chronopostC18",
501
+ description: "En 24h à votre domicile! Commande livrée le lendemain matin avant 18h.
502
+ Vous pouvez reprogrammer votre livraison en cas d'absence.",
503
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
504
+ destination: "FR,MC",
505
+ 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}",
506
+ }
507
+ </config>
508
+ <weight_limit>30</weight_limit>
509
+ <quickcost>0</quickcost>
510
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
511
+ <logo_url>chronopost.png</logo_url>
512
+ <debug>0</debug>
513
+ <stop_to_first_match>0</stop_to_first_match>
514
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
515
+ <sort_order>5</sort_order>
516
+ </chronopostc18>
517
+ <chronopostcclassic>
518
+ <active>0</active>
519
+ <title>Chronopost Livraison dans certaines villes Européennes</title>
520
+ <model>Chronopost_Chronorelais_Model_Carrier_ChronopostCClassic</model>
521
+ <tracking_view_url></tracking_view_url>
522
+ <config>
523
+ # CClassic
524
+ {
525
+ label: "Chronopost Livraison dans certaines villes Européennes",
526
+ code: "chronopostcclassic",
527
+ description: "A domicile! Commande livrée à l'adresse de votre choix. Vous pouvez reprogrammer votre livraison en cas d’absence.",
528
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
529
+ 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",
530
+ 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}",
531
+ }
532
+ </config>
533
+ <weight_limit>30</weight_limit>
534
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
535
+ <logo_url>chronopost.png</logo_url>
536
+ <debug>0</debug>
537
+ <stop_to_first_match>0</stop_to_first_match>
538
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
539
+ <sort_order>6</sort_order>
540
+ </chronopostcclassic>
541
+ <chronorelaiseurope>
542
+ <active>0</active>
543
+ <title>Chrono Relais Europe</title>
544
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronorelaiseurope</model>
545
+ <tracking_view_url></tracking_view_url>
546
+ <config>
547
+ # ChronorelaisEurope
548
+ {
549
+ label: "Chronopost Livraison en point relais",
550
+ description: "En relais Pickup! Commande livrée dans le relais Pickup de votre choix.",
551
+ code: "chronorelaiseurope",
552
+ description: "Colis livré en Chronopost",
553
+ tracking_url: "http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?lang=fr_FR&amp;listeNumeros=@",
554
+ destination: "DE,AT,BE,BG,CY,DK,ES,EE,FI,GR,HU,IE,IT,LV,LT,LU,MT,NL,PL,PT,CZ,RO,GB,SK,SI,SE",
555
+ 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}",
556
+ }
557
+ </config>
558
+ <weight_limit>20</weight_limit>
559
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
560
+ <show_google_map>1</show_google_map>
561
+ <logo_url>chronorelais.png</logo_url>
562
+ <debug>0</debug>
563
+ <stop_to_first_match>0</stop_to_first_match>
564
+ <deliver_on_saturday>0</deliver_on_saturday>
565
+ <sort_order>7</sort_order>
566
+ <max_distance_search>15</max_distance_search>
567
+ <max_point_chronopost>10</max_point_chronopost>
568
+ <point_relai_ws_method>recherchePointChronopostInter</point_relai_ws_method>
569
+ <add_address_to_ws>0</add_address_to_ws>
570
+ <can_change_postcode>0</can_change_postcode>
571
+ </chronorelaiseurope>
572
+ <!--<chronorelaisdom>
573
+ <active>0</active>
574
+ <title>Chrono Relais DOM</title>
575
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronorelaisdom</model>
576
+ <tracking_view_url></tracking_view_url>
577
+ <config>
578
+ # ChronorelaisDom
579
+ {
580
+ label: "Chronopost - Livraison en point relais",
581
+ description: "En relais Pickup! Commande livrée dans le relais Pickup de votre choix.",
582
+ code: "chronorelaisdom",
583
+ description: "Colis livré en Chronopost",
584
+ tracking_url: "http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?lang=fr_FR&amp;listeNumeros=@",
585
+ destination: "GP,MQ,GF,RE",
586
+ 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}",
587
+ }
588
+ </config>
589
+ <weight_limit>20</weight_limit>
590
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
591
+ <show_google_map>1</show_google_map>
592
+ <logo_url>chronorelais.png</logo_url>
593
+ <debug>0</debug>
594
+ <stop_to_first_match>0</stop_to_first_match>
595
+ <deliver_on_saturday>0</deliver_on_saturday>
596
+ <sort_order>8</sort_order>
597
+ <max_distance_search>15</max_distance_search>
598
+ <max_point_chronopost>10</max_point_chronopost>
599
+ <point_relai_ws_method>recherchePointChronopostInter</point_relai_ws_method>
600
+ <add_address_to_ws>1</add_address_to_ws>
601
+ <can_change_postcode>0</can_change_postcode>
602
+ </chronorelaisdom>-->
603
+ <chronopostsameday>
604
+ <active>0</active>
605
+ <title>Chronopost-Livraison express à domicile le même jour</title>
606
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronopostsameday</model>
607
+ <tracking_view_url></tracking_view_url>
608
+ <config>
609
+ # Chronopost
610
+ {
611
+ label: "Chronopost-Livraison express à domicile le même jour",
612
+ code: "chronopostsameday",
613
+ description: "Ce soir à votre domicile! Commande livrée ce soir entre 19h et 22h.
614
+ Vous pouvez reprogrammer votre livraison en cas d'absence.",
615
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
616
+ destination: "FR,MC",
617
+ 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}",
618
+ }
619
+ </config>
620
+ <weight_limit>30</weight_limit>
621
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
622
+ <logo_url>chronopost.png</logo_url>
623
+ <debug>0</debug>
624
+ <stop_to_first_match>0</stop_to_first_match>
625
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
626
+ <sort_order>9</sort_order>
627
+ </chronopostsameday>
628
+ <chronopostsrdv>
629
+ <active>0</active>
630
+ <title>Chronopost-Livraison sur Rendez-vous</title>
631
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronopostsrdv</model>
632
+ <tracking_view_url></tracking_view_url>
633
+ <config>
634
+ # Chronopost
635
+ {
636
+ label: "Chronopost-Livraison sur Rendez-vous",
637
+ code: "chronopostsrdv",
638
+ description: "Sur RDV à votre domicile! Commande livrée au jour de votre choix dans un créneau horaire de 2h.
639
+ Vous pouvez reprogrammer votre livraison en cas d'absence.",
640
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
641
+ destination: "FR",
642
+ fees: "0",
643
+ }
644
+ </config>
645
+ <weight_limit>30</weight_limit>
646
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
647
+ <logo_url>chronopost.png</logo_url>
648
+ <debug>0</debug>
649
+ <stop_to_first_match>0</stop_to_first_match>
650
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
651
+ <rdv_config>
652
+ {
653
+ "dateRemiseColis_nbJour": "1",
654
+ "dateRemiseColis_jour": "0",
655
+ "dateRemiseColis_heures": "0",
656
+ "dateRemiseColis_minutes": "0",
657
+ "niveauTarifaire_show": 1,
658
+ "N1_status": "1",
659
+ "N2_status": "1",
660
+ "N3_status": "1",
661
+ "N4_status": "1",
662
+ "N1_price": "0",
663
+ "N2_price": "0",
664
+ "N3_price": "0",
665
+ "N4_price": "0"
666
+ }
667
+ </rdv_config>
668
+ <sort_order>10</sort_order>
669
+ </chronopostsrdv>
670
+ </carriers>
671
+ </default>
672
+
673
+ </config>
app/code/community/Chronopost/Chronorelais/etc/system.xml CHANGED
@@ -1,1583 +1,2433 @@
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>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_marge translate="label">
68
+ <label>Value to add to quickcost</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>1</show_in_store>
74
+ <validate>validate-number</validate>
75
+ </quickcost_marge>
76
+ <quickcost_marge_type translate="label">
77
+ <label>Type value to add</label>
78
+ <frontend_type>select</frontend_type>
79
+ <source_model>chronorelais/config_source_margetype</source_model>
80
+ <sort_order>12</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
+ </quickcost_marge_type>
85
+ <quickcost_url>
86
+ <label>Quickcost Url</label>
87
+ <frontend_type>text</frontend_type>
88
+ <sort_order>13</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>0</show_in_store>
92
+ </quickcost_url>
93
+ <free_shipping_enable translate="label">
94
+ <label>Free Shipping on the Amount</label>
95
+ <frontend_type>select</frontend_type>
96
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
97
+ <sort_order>20</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>1</show_in_store>
101
+ </free_shipping_enable>
102
+ <free_shipping_subtotal translate="label">
103
+ <label>Minimum Amount for Free Shipping</label>
104
+ <frontend_type>text</frontend_type>
105
+ <sort_order>30</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>0</show_in_store>
109
+ </free_shipping_subtotal>
110
+ <application_fee translate="label">
111
+ <label>Application Fee</label>
112
+ <frontend_type>text</frontend_type>
113
+ <sort_order>40</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ </application_fee>
118
+ <handling_fee translate="label">
119
+ <label>Handling Fee</label>
120
+ <frontend_type>text</frontend_type>
121
+ <sort_order>50</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
+ </handling_fee>
126
+ <logo_url>
127
+ <label>Logo Url</label>
128
+ <frontend_type>text</frontend_type>
129
+ <comment>{logo_ulr_help}</comment>
130
+ <sort_order>60</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
+ </logo_url>
135
+ <debug>
136
+ <label>Debug</label>
137
+ <comment>{debug_help}</comment>
138
+ <frontend_type>text</frontend_type>
139
+ <sort_order>70</sort_order>
140
+ <show_in_default>1</show_in_default>
141
+ <show_in_website>1</show_in_website>
142
+ <show_in_store>1</show_in_store>
143
+ </debug>
144
+ <!--<stop_to_first_match translate="label">
145
+ <label>Stop to first match</label>
146
+ <frontend_type>select</frontend_type>
147
+ <source_model>adminhtml/system_config_source_yesno</source_model>
148
+ <sort_order>80</sort_order>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_website>1</show_in_website>
151
+ <show_in_store>1</show_in_store>
152
+ </stop_to_first_match>-->
153
+ <deliver_on_saturday translate="label comment">
154
+ <label>Livraison le Samedi</label>
155
+ <frontend_type>select</frontend_type>
156
+ <source_model>adminhtml/system_config_source_yesno</source_model>
157
+ <sort_order>90</sort_order>
158
+ <show_in_default>1</show_in_default>
159
+ <show_in_website>1</show_in_website>
160
+ <show_in_store>1</show_in_store>
161
+ </deliver_on_saturday>
162
+ <!--<showmethod translate="label">
163
+ <label>Show Method if Not Applicable</label>
164
+ <frontend_type>select</frontend_type>
165
+ <sort_order>100</sort_order>
166
+ <frontend_class>shipping-skip-hide</frontend_class>
167
+ <source_model>adminhtml/system_config_source_yesno</source_model>
168
+ <show_in_default>1</show_in_default>
169
+ <show_in_website>1</show_in_website>
170
+ <show_in_store>0</show_in_store>
171
+ </showmethod>
172
+ <specificerrmsg translate="label">
173
+ <label>Displayed Error Message</label>
174
+ <frontend_type>textarea</frontend_type>
175
+ <sort_order>110</sort_order>
176
+ <show_in_default>1</show_in_default>
177
+ <show_in_website>1</show_in_website>
178
+ <show_in_store>1</show_in_store>
179
+ </specificerrmsg>-->
180
+ <sort_order translate="label">
181
+ <label>Sort order</label>
182
+ <frontend_type>text</frontend_type>
183
+ <sort_order>120</sort_order>
184
+ <show_in_default>1</show_in_default>
185
+ <show_in_website>1</show_in_website>
186
+ <show_in_store>1</show_in_store>
187
+ </sort_order>
188
+ </fields>
189
+ </chronopost>
190
+
191
+ <chronoexpress translate="label">
192
+ <label>Chrono Express</label>
193
+ <frontend_type>text</frontend_type>
194
+ <sort_order>21</sort_order>
195
+ <show_in_default>1</show_in_default>
196
+ <show_in_website>1</show_in_website>
197
+ <show_in_store>1</show_in_store>
198
+ <fields>
199
+ <active translate="label">
200
+ <label>Enabled</label>
201
+ <frontend_type>select</frontend_type>
202
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
203
+ <source_model>adminhtml/system_config_source_yesno</source_model>
204
+ <sort_order>1</sort_order>
205
+ <show_in_default>1</show_in_default>
206
+ <show_in_website>1</show_in_website>
207
+ <show_in_store>1</show_in_store>
208
+ </active>
209
+ <title translate="label">
210
+ <label>Title</label>
211
+ <frontend_type>text</frontend_type>
212
+ <sort_order>2</sort_order>
213
+ <show_in_default>1</show_in_default>
214
+ <show_in_website>1</show_in_website>
215
+ <show_in_store>1</show_in_store>
216
+ </title>
217
+ <config translate="label">
218
+ <label>Configuration</label>
219
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
220
+ <comment>{configuration_syntax_help}</comment>
221
+ <frontend_type>textarea</frontend_type>
222
+ <sort_order>3</sort_order>
223
+ <show_in_default>1</show_in_default>
224
+ <show_in_website>1</show_in_website>
225
+ <show_in_store>1</show_in_store>
226
+ </config>
227
+ <weight_limit translate="label">
228
+ <label>Weight Limit</label>
229
+ <frontend_type>text</frontend_type>
230
+ <comment>in Kg</comment>
231
+ <sort_order>7</sort_order>
232
+ <show_in_default>1</show_in_default>
233
+ <show_in_website>1</show_in_website>
234
+ <show_in_store>1</show_in_store>
235
+ </weight_limit>
236
+ <quickcost translate="label">
237
+ <label>Quickcost</label>
238
+ <frontend_type>select</frontend_type>
239
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
240
+ <source_model>adminhtml/system_config_source_yesno</source_model>
241
+ <sort_order>10</sort_order>
242
+ <show_in_default>1</show_in_default>
243
+ <show_in_website>1</show_in_website>
244
+ <show_in_store>0</show_in_store>
245
+ </quickcost>
246
+ <quickcost_marge translate="label">
247
+ <label>Value to add to quickcost</label>
248
+ <frontend_type>text</frontend_type>
249
+ <sort_order>11</sort_order>
250
+ <show_in_default>1</show_in_default>
251
+ <show_in_website>1</show_in_website>
252
+ <show_in_store>1</show_in_store>
253
+ <validate>validate-number</validate>
254
+ </quickcost_marge>
255
+ <quickcost_marge_type translate="label">
256
+ <label>Type value to add</label>
257
+ <frontend_type>select</frontend_type>
258
+ <source_model>chronorelais/config_source_margetype</source_model>
259
+ <sort_order>12</sort_order>
260
+ <show_in_default>1</show_in_default>
261
+ <show_in_website>1</show_in_website>
262
+ <show_in_store>1</show_in_store>
263
+ </quickcost_marge_type>
264
+ <quickcost_url>
265
+ <label>Quickcost Url</label>
266
+ <frontend_type>text</frontend_type>
267
+ <sort_order>13</sort_order>
268
+ <show_in_default>1</show_in_default>
269
+ <show_in_website>1</show_in_website>
270
+ <show_in_store>0</show_in_store>
271
+ </quickcost_url>
272
+ <free_shipping_enable translate="label">
273
+ <label>Free Shipping on the Amount</label>
274
+ <frontend_type>select</frontend_type>
275
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
276
+ <sort_order>20</sort_order>
277
+ <show_in_default>1</show_in_default>
278
+ <show_in_website>1</show_in_website>
279
+ <show_in_store>1</show_in_store>
280
+ </free_shipping_enable>
281
+ <free_shipping_subtotal translate="label">
282
+ <label>Minimum Amount for Free Shipping</label>
283
+ <frontend_type>text</frontend_type>
284
+ <sort_order>30</sort_order>
285
+ <show_in_default>1</show_in_default>
286
+ <show_in_website>1</show_in_website>
287
+ <show_in_store>0</show_in_store>
288
+ </free_shipping_subtotal>
289
+ <application_fee translate="label">
290
+ <label>Application Fee</label>
291
+ <frontend_type>text</frontend_type>
292
+ <sort_order>40</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
+ </application_fee>
297
+ <handling_fee translate="label">
298
+ <label>Handling Fee</label>
299
+ <frontend_type>text</frontend_type>
300
+ <sort_order>50</sort_order>
301
+ <show_in_default>1</show_in_default>
302
+ <show_in_website>1</show_in_website>
303
+ <show_in_store>1</show_in_store>
304
+ </handling_fee>
305
+ <logo_url>
306
+ <label>Logo Url</label>
307
+ <frontend_type>text</frontend_type>
308
+ <comment>{logo_ulr_help}</comment>
309
+ <sort_order>60</sort_order>
310
+ <show_in_default>1</show_in_default>
311
+ <show_in_website>1</show_in_website>
312
+ <show_in_store>1</show_in_store>
313
+ </logo_url>
314
+ <debug>
315
+ <label>Debug</label>
316
+ <comment>{debug_help}</comment>
317
+ <frontend_type>text</frontend_type>
318
+ <sort_order>70</sort_order>
319
+ <show_in_default>1</show_in_default>
320
+ <show_in_website>1</show_in_website>
321
+ <show_in_store>1</show_in_store>
322
+ </debug>
323
+ <!--<stop_to_first_match translate="label">
324
+ <label>Stop to first match</label>
325
+ <frontend_type>select</frontend_type>
326
+ <source_model>adminhtml/system_config_source_yesno</source_model>
327
+ <sort_order>80</sort_order>
328
+ <show_in_default>1</show_in_default>
329
+ <show_in_website>1</show_in_website>
330
+ <show_in_store>1</show_in_store>
331
+ </stop_to_first_match>-->
332
+ <!-- deliver_on_saturday not included in chronoexpress only -->
333
+ <!--<showmethod translate="label">
334
+ <label>Show Method if Not Applicable</label>
335
+ <frontend_type>select</frontend_type>
336
+ <sort_order>90</sort_order>
337
+ <frontend_class>shipping-skip-hide</frontend_class>
338
+ <source_model>adminhtml/system_config_source_yesno</source_model>
339
+ <show_in_default>1</show_in_default>
340
+ <show_in_website>1</show_in_website>
341
+ <show_in_store>0</show_in_store>
342
+ </showmethod>
343
+ <specificerrmsg translate="label">
344
+ <label>Displayed Error Message</label>
345
+ <frontend_type>textarea</frontend_type>
346
+ <sort_order>100</sort_order>
347
+ <show_in_default>1</show_in_default>
348
+ <show_in_website>1</show_in_website>
349
+ <show_in_store>1</show_in_store>
350
+ </specificerrmsg>-->
351
+ <sort_order translate="label">
352
+ <label>Sort order</label>
353
+ <frontend_type>text</frontend_type>
354
+ <sort_order>120</sort_order>
355
+ <show_in_default>1</show_in_default>
356
+ <show_in_website>1</show_in_website>
357
+ <show_in_store>1</show_in_store>
358
+ </sort_order>
359
+ </fields>
360
+ </chronoexpress>
361
+
362
+ <chronorelais translate="label">
363
+ <label>Chrono Relais</label>
364
+ <frontend_type>text</frontend_type>
365
+ <sort_order>22</sort_order>
366
+ <show_in_default>1</show_in_default>
367
+ <show_in_website>1</show_in_website>
368
+ <show_in_store>1</show_in_store>
369
+ <fields>
370
+ <active translate="label">
371
+ <label>Enabled</label>
372
+ <frontend_type>select</frontend_type>
373
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
374
+ <source_model>adminhtml/system_config_source_yesno</source_model>
375
+ <sort_order>1</sort_order>
376
+ <show_in_default>1</show_in_default>
377
+ <show_in_website>1</show_in_website>
378
+ <show_in_store>1</show_in_store>
379
+ </active>
380
+ <title translate="label">
381
+ <label>Title</label>
382
+ <frontend_type>text</frontend_type>
383
+ <sort_order>2</sort_order>
384
+ <show_in_default>1</show_in_default>
385
+ <show_in_website>1</show_in_website>
386
+ <show_in_store>1</show_in_store>
387
+ </title>
388
+ <config translate="label">
389
+ <label>Configuration</label>
390
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
391
+ <comment>{configuration_syntax_help}</comment>
392
+ <frontend_type>textarea</frontend_type>
393
+ <sort_order>3</sort_order>
394
+ <show_in_default>1</show_in_default>
395
+ <show_in_website>1</show_in_website>
396
+ <show_in_store>1</show_in_store>
397
+ </config>
398
+ <weight_limit translate="label">
399
+ <label>Weight Limit</label>
400
+ <frontend_type>text</frontend_type>
401
+ <comment>in Kg</comment>
402
+ <sort_order>7</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
+ </weight_limit>
407
+ <quickcost translate="label">
408
+ <label>Quickcost</label>
409
+ <frontend_type>select</frontend_type>
410
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
411
+ <source_model>adminhtml/system_config_source_yesno</source_model>
412
+ <sort_order>10</sort_order>
413
+ <show_in_default>1</show_in_default>
414
+ <show_in_website>1</show_in_website>
415
+ <show_in_store>0</show_in_store>
416
+ </quickcost>
417
+ <quickcost_marge translate="label">
418
+ <label>Value to add to quickcost</label>
419
+ <frontend_type>text</frontend_type>
420
+ <sort_order>11</sort_order>
421
+ <show_in_default>1</show_in_default>
422
+ <show_in_website>1</show_in_website>
423
+ <show_in_store>1</show_in_store>
424
+ <validate>validate-number</validate>
425
+ </quickcost_marge>
426
+ <quickcost_marge_type translate="label">
427
+ <label>Type value to add</label>
428
+ <frontend_type>select</frontend_type>
429
+ <source_model>chronorelais/config_source_margetype</source_model>
430
+ <sort_order>12</sort_order>
431
+ <show_in_default>1</show_in_default>
432
+ <show_in_website>1</show_in_website>
433
+ <show_in_store>1</show_in_store>
434
+ </quickcost_marge_type>
435
+ <quickcost_url>
436
+ <label>Quickcost Url</label>
437
+ <frontend_type>text</frontend_type>
438
+ <sort_order>13</sort_order>
439
+ <show_in_default>1</show_in_default>
440
+ <show_in_website>1</show_in_website>
441
+ <show_in_store>0</show_in_store>
442
+ </quickcost_url>
443
+ <show_google_map translate="label">
444
+ <label>Show Google Map</label>
445
+ <frontend_type>select</frontend_type>
446
+ <source_model>adminhtml/system_config_source_yesno</source_model>
447
+ <sort_order>20</sort_order>
448
+ <show_in_default>1</show_in_default>
449
+ <show_in_website>1</show_in_website>
450
+ <show_in_store>1</show_in_store>
451
+ </show_google_map>
452
+ <max_distance_search translate="label">
453
+ <label>Max distance search</label>
454
+ <frontend_type>text</frontend_type>
455
+ <sort_order>30</sort_order>
456
+ <show_in_default>1</show_in_default>
457
+ <show_in_website>1</show_in_website>
458
+ <show_in_store>0</show_in_store>
459
+ </max_distance_search>
460
+ <free_shipping_enable translate="label">
461
+ <label>Free Shipping with Minimum Order Amount</label>
462
+ <frontend_type>select</frontend_type>
463
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
464
+ <sort_order>40</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
+ </free_shipping_enable>
469
+ <free_shipping_subtotal translate="label">
470
+ <label>Minimum Order Amount for Free Shipping</label>
471
+ <frontend_type>text</frontend_type>
472
+ <sort_order>50</sort_order>
473
+ <show_in_default>1</show_in_default>
474
+ <show_in_website>1</show_in_website>
475
+ <show_in_store>1</show_in_store>
476
+ </free_shipping_subtotal>
477
+ <application_fee translate="label">
478
+ <label>Application Fee</label>
479
+ <frontend_type>text</frontend_type>
480
+ <sort_order>60</sort_order>
481
+ <show_in_default>1</show_in_default>
482
+ <show_in_website>1</show_in_website>
483
+ <show_in_store>1</show_in_store>
484
+ </application_fee>
485
+ <handling_fee translate="label">
486
+ <label>Handling Fee</label>
487
+ <frontend_type>text</frontend_type>
488
+ <sort_order>70</sort_order>
489
+ <show_in_default>1</show_in_default>
490
+ <show_in_website>1</show_in_website>
491
+ <show_in_store>1</show_in_store>
492
+ </handling_fee>
493
+ <logo_url>
494
+ <label>Logo Url</label>
495
+ <frontend_type>text</frontend_type>
496
+ <comment>{logo_ulr_help}</comment>
497
+ <sort_order>80</sort_order>
498
+ <show_in_default>1</show_in_default>
499
+ <show_in_website>1</show_in_website>
500
+ <show_in_store>1</show_in_store>
501
+ </logo_url>
502
+ <debug>
503
+ <label>Debug</label>
504
+ <comment>{debug_help}</comment>
505
+ <frontend_type>text</frontend_type>
506
+ <sort_order>90</sort_order>
507
+ <show_in_default>1</show_in_default>
508
+ <show_in_website>1</show_in_website>
509
+ <show_in_store>1</show_in_store>
510
+ </debug>
511
+ <!--<stop_to_first_match translate="label">
512
+ <label>Stop to first match</label>
513
+ <frontend_type>select</frontend_type>
514
+ <source_model>adminhtml/system_config_source_yesno</source_model>
515
+ <sort_order>100</sort_order>
516
+ <show_in_default>1</show_in_default>
517
+ <show_in_website>1</show_in_website>
518
+ <show_in_store>1</show_in_store>
519
+ </stop_to_first_match>-->
520
+ <deliver_on_saturday translate="label comment">
521
+ <label>Livraison le Samedi</label>
522
+ <frontend_type>select</frontend_type>
523
+ <source_model>adminhtml/system_config_source_yesno</source_model>
524
+ <sort_order>110</sort_order>
525
+ <show_in_default>1</show_in_default>
526
+ <show_in_website>1</show_in_website>
527
+ <show_in_store>1</show_in_store>
528
+ </deliver_on_saturday>
529
+ <!--<showmethod translate="label">
530
+ <label>Show Method if Not Applicable</label>
531
+ <frontend_type>select</frontend_type>
532
+ <sort_order>120</sort_order>
533
+ <frontend_class>shipping-skip-hide</frontend_class>
534
+ <source_model>adminhtml/system_config_source_yesno</source_model>
535
+ <show_in_default>1</show_in_default>
536
+ <show_in_website>1</show_in_website>
537
+ <show_in_store>0</show_in_store>
538
+ </showmethod>
539
+ <specificerrmsg translate="label">
540
+ <label>Displayed Error Message</label>
541
+ <frontend_type>textarea</frontend_type>
542
+ <sort_order>130</sort_order>
543
+ <show_in_default>1</show_in_default>
544
+ <show_in_website>1</show_in_website>
545
+ <show_in_store>1</show_in_store>
546
+ </specificerrmsg>-->
547
+ <sort_order translate="label">
548
+ <label>Sort order</label>
549
+ <frontend_type>text</frontend_type>
550
+ <sort_order>140</sort_order>
551
+ <show_in_default>1</show_in_default>
552
+ <show_in_website>1</show_in_website>
553
+ <show_in_store>1</show_in_store>
554
+ </sort_order>
555
+ </fields>
556
+ </chronorelais>
557
+
558
+ <!-- C10 Livraison avant 10H -->
559
+ <chronopostc10 translate="label">
560
+ <label>Chronopost C10</label>
561
+ <frontend_type>text</frontend_type>
562
+ <sort_order>23</sort_order>
563
+ <show_in_default>1</show_in_default>
564
+ <show_in_website>1</show_in_website>
565
+ <show_in_store>1</show_in_store>
566
+ <fields>
567
+ <active translate="label">
568
+ <label>Enabled</label>
569
+ <frontend_type>select</frontend_type>
570
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
571
+ <source_model>adminhtml/system_config_source_yesno</source_model>
572
+ <sort_order>1</sort_order>
573
+ <show_in_default>1</show_in_default>
574
+ <show_in_website>1</show_in_website>
575
+ <show_in_store>1</show_in_store>
576
+ </active>
577
+ <title translate="label">
578
+ <label>Title</label>
579
+ <frontend_type>text</frontend_type>
580
+ <sort_order>2</sort_order>
581
+ <show_in_default>1</show_in_default>
582
+ <show_in_website>1</show_in_website>
583
+ <show_in_store>1</show_in_store>
584
+ </title>
585
+ <config translate="label">
586
+ <label>Configuration</label>
587
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
588
+ <comment>{configuration_syntax_help}</comment>
589
+ <frontend_type>textarea</frontend_type>
590
+ <sort_order>3</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
+ </config>
595
+ <weight_limit translate="label">
596
+ <label>Weight Limit</label>
597
+ <frontend_type>text</frontend_type>
598
+ <comment>in Kg</comment>
599
+ <sort_order>7</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
+ </weight_limit>
604
+ <quickcost translate="label">
605
+ <label>Quickcost</label>
606
+ <frontend_type>select</frontend_type>
607
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
608
+ <source_model>adminhtml/system_config_source_yesno</source_model>
609
+ <sort_order>10</sort_order>
610
+ <show_in_default>1</show_in_default>
611
+ <show_in_website>1</show_in_website>
612
+ <show_in_store>0</show_in_store>
613
+ </quickcost>
614
+ <quickcost_marge translate="label">
615
+ <label>Value to add to quickcost</label>
616
+ <frontend_type>text</frontend_type>
617
+ <sort_order>11</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
+ <validate>validate-number</validate>
622
+ </quickcost_marge>
623
+ <quickcost_marge_type translate="label">
624
+ <label>Type value to add</label>
625
+ <frontend_type>select</frontend_type>
626
+ <source_model>chronorelais/config_source_margetype</source_model>
627
+ <sort_order>12</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
+ </quickcost_marge_type>
632
+ <quickcost_url>
633
+ <label>Quickcost Url</label>
634
+ <frontend_type>text</frontend_type>
635
+ <sort_order>13</sort_order>
636
+ <show_in_default>1</show_in_default>
637
+ <show_in_website>1</show_in_website>
638
+ <show_in_store>0</show_in_store>
639
+ </quickcost_url>
640
+ <free_shipping_enable translate="label">
641
+ <label>Free Shipping on the Amount</label>
642
+ <frontend_type>select</frontend_type>
643
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
644
+ <sort_order>20</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
+ </free_shipping_enable>
649
+ <free_shipping_subtotal translate="label">
650
+ <label>Minimum Amount for Free Shipping</label>
651
+ <frontend_type>text</frontend_type>
652
+ <sort_order>30</sort_order>
653
+ <show_in_default>1</show_in_default>
654
+ <show_in_website>1</show_in_website>
655
+ <show_in_store>0</show_in_store>
656
+ </free_shipping_subtotal>
657
+ <application_fee translate="label">
658
+ <label>Application Fee</label>
659
+ <frontend_type>text</frontend_type>
660
+ <sort_order>40</sort_order>
661
+ <show_in_default>1</show_in_default>
662
+ <show_in_website>1</show_in_website>
663
+ <show_in_store>1</show_in_store>
664
+ </application_fee>
665
+ <handling_fee translate="label">
666
+ <label>Handling Fee</label>
667
+ <frontend_type>text</frontend_type>
668
+ <sort_order>50</sort_order>
669
+ <show_in_default>1</show_in_default>
670
+ <show_in_website>1</show_in_website>
671
+ <show_in_store>1</show_in_store>
672
+ </handling_fee>
673
+ <logo_url>
674
+ <label>Logo Url</label>
675
+ <frontend_type>text</frontend_type>
676
+ <comment>{logo_ulr_help}</comment>
677
+ <sort_order>60</sort_order>
678
+ <show_in_default>1</show_in_default>
679
+ <show_in_website>1</show_in_website>
680
+ <show_in_store>1</show_in_store>
681
+ </logo_url>
682
+ <debug>
683
+ <label>Debug</label>
684
+ <comment>{debug_help}</comment>
685
+ <frontend_type>text</frontend_type>
686
+ <sort_order>70</sort_order>
687
+ <show_in_default>1</show_in_default>
688
+ <show_in_website>1</show_in_website>
689
+ <show_in_store>1</show_in_store>
690
+ </debug>
691
+ <!--<stop_to_first_match translate="label">
692
+ <label>Stop to first match</label>
693
+ <frontend_type>select</frontend_type>
694
+ <source_model>adminhtml/system_config_source_yesno</source_model>
695
+ <sort_order>80</sort_order>
696
+ <show_in_default>1</show_in_default>
697
+ <show_in_website>1</show_in_website>
698
+ <show_in_store>1</show_in_store>
699
+ </stop_to_first_match>-->
700
+ <deliver_on_saturday translate="label comment">
701
+ <label>Livraison le Samedi</label>
702
+ <frontend_type>select</frontend_type>
703
+ <source_model>adminhtml/system_config_source_yesno</source_model>
704
+ <sort_order>90</sort_order>
705
+ <show_in_default>1</show_in_default>
706
+ <show_in_website>1</show_in_website>
707
+ <show_in_store>1</show_in_store>
708
+ </deliver_on_saturday>
709
+ <!--<showmethod translate="label">
710
+ <label>Show Method if Not Applicable</label>
711
+ <frontend_type>select</frontend_type>
712
+ <sort_order>100</sort_order>
713
+ <frontend_class>shipping-skip-hide</frontend_class>
714
+ <source_model>adminhtml/system_config_source_yesno</source_model>
715
+ <show_in_default>1</show_in_default>
716
+ <show_in_website>1</show_in_website>
717
+ <show_in_store>0</show_in_store>
718
+ </showmethod>
719
+ <specificerrmsg translate="label">
720
+ <label>Displayed Error Message</label>
721
+ <frontend_type>textarea</frontend_type>
722
+ <sort_order>110</sort_order>
723
+ <show_in_default>1</show_in_default>
724
+ <show_in_website>1</show_in_website>
725
+ <show_in_store>1</show_in_store>
726
+ </specificerrmsg>-->
727
+ <sort_order translate="label">
728
+ <label>Sort order</label>
729
+ <frontend_type>text</frontend_type>
730
+ <sort_order>120</sort_order>
731
+ <show_in_default>1</show_in_default>
732
+ <show_in_website>1</show_in_website>
733
+ <show_in_store>1</show_in_store>
734
+ </sort_order>
735
+ </fields>
736
+ </chronopostc10>
737
+
738
+ <!-- C18 Livraison avant 18H -->
739
+ <chronopostc18 translate="label">
740
+ <label>Chronopost C18</label>
741
+ <frontend_type>text</frontend_type>
742
+ <sort_order>24</sort_order>
743
+ <show_in_default>1</show_in_default>
744
+ <show_in_website>1</show_in_website>
745
+ <show_in_store>1</show_in_store>
746
+ <fields>
747
+ <active translate="label">
748
+ <label>Enabled</label>
749
+ <frontend_type>select</frontend_type>
750
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
751
+ <source_model>adminhtml/system_config_source_yesno</source_model>
752
+ <sort_order>1</sort_order>
753
+ <show_in_default>1</show_in_default>
754
+ <show_in_website>1</show_in_website>
755
+ <show_in_store>1</show_in_store>
756
+ </active>
757
+ <title translate="label">
758
+ <label>Title</label>
759
+ <frontend_type>text</frontend_type>
760
+ <sort_order>2</sort_order>
761
+ <show_in_default>1</show_in_default>
762
+ <show_in_website>1</show_in_website>
763
+ <show_in_store>1</show_in_store>
764
+ </title>
765
+ <config translate="label">
766
+ <label>Configuration</label>
767
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
768
+ <comment>{configuration_syntax_help}</comment>
769
+ <frontend_type>textarea</frontend_type>
770
+ <sort_order>3</sort_order>
771
+ <show_in_default>1</show_in_default>
772
+ <show_in_website>1</show_in_website>
773
+ <show_in_store>1</show_in_store>
774
+ </config>
775
+ <weight_limit translate="label">
776
+ <label>Weight Limit</label>
777
+ <frontend_type>text</frontend_type>
778
+ <comment>in Kg</comment>
779
+ <sort_order>7</sort_order>
780
+ <show_in_default>1</show_in_default>
781
+ <show_in_website>1</show_in_website>
782
+ <show_in_store>1</show_in_store>
783
+ </weight_limit>
784
+ <quickcost translate="label">
785
+ <label>Quickcost</label>
786
+ <frontend_type>select</frontend_type>
787
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
788
+ <source_model>adminhtml/system_config_source_yesno</source_model>
789
+ <sort_order>10</sort_order>
790
+ <show_in_default>0</show_in_default>
791
+ <show_in_website>0</show_in_website>
792
+ <show_in_store>0</show_in_store>
793
+ </quickcost>
794
+ <quickcost_marge translate="label">
795
+ <label>Value to add to quickcost</label>
796
+ <frontend_type>text</frontend_type>
797
+ <sort_order>11</sort_order>
798
+ <show_in_default>1</show_in_default>
799
+ <show_in_website>1</show_in_website>
800
+ <show_in_store>1</show_in_store>
801
+ <validate>validate-number</validate>
802
+ </quickcost_marge>
803
+ <quickcost_marge_type translate="label">
804
+ <label>Type value to add</label>
805
+ <frontend_type>select</frontend_type>
806
+ <source_model>chronorelais/config_source_margetype</source_model>
807
+ <sort_order>12</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
+ </quickcost_marge_type>
812
+ <quickcost_url>
813
+ <label>Quickcost Url</label>
814
+ <frontend_type>text</frontend_type>
815
+ <sort_order>13</sort_order>
816
+ <show_in_default>0</show_in_default>
817
+ <show_in_website>0</show_in_website>
818
+ <show_in_store>0</show_in_store>
819
+ </quickcost_url>
820
+ <free_shipping_enable translate="label">
821
+ <label>Free Shipping on the Amount</label>
822
+ <frontend_type>select</frontend_type>
823
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
824
+ <sort_order>20</sort_order>
825
+ <show_in_default>1</show_in_default>
826
+ <show_in_website>1</show_in_website>
827
+ <show_in_store>1</show_in_store>
828
+ </free_shipping_enable>
829
+ <free_shipping_subtotal translate="label">
830
+ <label>Minimum Amount for Free Shipping</label>
831
+ <frontend_type>text</frontend_type>
832
+ <sort_order>30</sort_order>
833
+ <show_in_default>1</show_in_default>
834
+ <show_in_website>1</show_in_website>
835
+ <show_in_store>0</show_in_store>
836
+ </free_shipping_subtotal>
837
+ <application_fee translate="label">
838
+ <label>Application Fee</label>
839
+ <frontend_type>text</frontend_type>
840
+ <sort_order>40</sort_order>
841
+ <show_in_default>1</show_in_default>
842
+ <show_in_website>1</show_in_website>
843
+ <show_in_store>1</show_in_store>
844
+ </application_fee>
845
+ <handling_fee translate="label">
846
+ <label>Handling Fee</label>
847
+ <frontend_type>text</frontend_type>
848
+ <sort_order>50</sort_order>
849
+ <show_in_default>1</show_in_default>
850
+ <show_in_website>1</show_in_website>
851
+ <show_in_store>1</show_in_store>
852
+ </handling_fee>
853
+ <logo_url>
854
+ <label>Logo Url</label>
855
+ <frontend_type>text</frontend_type>
856
+ <comment>{logo_ulr_help}</comment>
857
+ <sort_order>60</sort_order>
858
+ <show_in_default>1</show_in_default>
859
+ <show_in_website>1</show_in_website>
860
+ <show_in_store>1</show_in_store>
861
+ </logo_url>
862
+ <debug>
863
+ <label>Debug</label>
864
+ <comment>{debug_help}</comment>
865
+ <frontend_type>text</frontend_type>
866
+ <sort_order>70</sort_order>
867
+ <show_in_default>1</show_in_default>
868
+ <show_in_website>1</show_in_website>
869
+ <show_in_store>1</show_in_store>
870
+ </debug>
871
+ <!--<stop_to_first_match translate="label">
872
+ <label>Stop to first match</label>
873
+ <frontend_type>select</frontend_type>
874
+ <source_model>adminhtml/system_config_source_yesno</source_model>
875
+ <sort_order>80</sort_order>
876
+ <show_in_default>1</show_in_default>
877
+ <show_in_website>1</show_in_website>
878
+ <show_in_store>1</show_in_store>
879
+ </stop_to_first_match>-->
880
+ <deliver_on_saturday translate="label comment">
881
+ <label>Livraison le Samedi</label>
882
+ <frontend_type>select</frontend_type>
883
+ <source_model>adminhtml/system_config_source_yesno</source_model>
884
+ <sort_order>90</sort_order>
885
+ <show_in_default>1</show_in_default>
886
+ <show_in_website>1</show_in_website>
887
+ <show_in_store>1</show_in_store>
888
+ </deliver_on_saturday>
889
+ <!--<showmethod translate="label">
890
+ <label>Show Method if Not Applicable</label>
891
+ <frontend_type>select</frontend_type>
892
+ <sort_order>100</sort_order>
893
+ <frontend_class>shipping-skip-hide</frontend_class>
894
+ <source_model>adminhtml/system_config_source_yesno</source_model>
895
+ <show_in_default>1</show_in_default>
896
+ <show_in_website>1</show_in_website>
897
+ <show_in_store>0</show_in_store>
898
+ </showmethod>
899
+ <specificerrmsg translate="label">
900
+ <label>Displayed Error Message</label>
901
+ <frontend_type>textarea</frontend_type>
902
+ <sort_order>110</sort_order>
903
+ <show_in_default>1</show_in_default>
904
+ <show_in_website>1</show_in_website>
905
+ <show_in_store>1</show_in_store>
906
+ </specificerrmsg>-->
907
+ <sort_order translate="label">
908
+ <label>Sort order</label>
909
+ <frontend_type>text</frontend_type>
910
+ <sort_order>120</sort_order>
911
+ <show_in_default>1</show_in_default>
912
+ <show_in_website>1</show_in_website>
913
+ <show_in_store>1</show_in_store>
914
+ </sort_order>
915
+ </fields>
916
+ </chronopostc18>
917
+
918
+ <!-- CClassic Livraison dans certaines villes Européennes -->
919
+ <chronopostcclassic translate="label">
920
+ <label>Chronopost CClassic</label>
921
+ <frontend_type>text</frontend_type>
922
+ <sort_order>25</sort_order>
923
+ <show_in_default>1</show_in_default>
924
+ <show_in_website>1</show_in_website>
925
+ <show_in_store>1</show_in_store>
926
+ <fields>
927
+ <active translate="label">
928
+ <label>Enabled</label>
929
+ <frontend_type>select</frontend_type>
930
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
931
+ <source_model>adminhtml/system_config_source_yesno</source_model>
932
+ <sort_order>1</sort_order>
933
+ <show_in_default>1</show_in_default>
934
+ <show_in_website>1</show_in_website>
935
+ <show_in_store>1</show_in_store>
936
+ </active>
937
+ <title translate="label">
938
+ <label>Title</label>
939
+ <frontend_type>text</frontend_type>
940
+ <sort_order>2</sort_order>
941
+ <show_in_default>1</show_in_default>
942
+ <show_in_website>1</show_in_website>
943
+ <show_in_store>1</show_in_store>
944
+ </title>
945
+ <config translate="label">
946
+ <label>Configuration</label>
947
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
948
+ <comment>{configuration_syntax_help}</comment>
949
+ <frontend_type>textarea</frontend_type>
950
+ <sort_order>3</sort_order>
951
+ <show_in_default>1</show_in_default>
952
+ <show_in_website>1</show_in_website>
953
+ <show_in_store>1</show_in_store>
954
+ </config>
955
+ <weight_limit translate="label">
956
+ <label>Weight Limit</label>
957
+ <frontend_type>text</frontend_type>
958
+ <comment>in Kg</comment>
959
+ <sort_order>7</sort_order>
960
+ <show_in_default>1</show_in_default>
961
+ <show_in_website>1</show_in_website>
962
+ <show_in_store>1</show_in_store>
963
+ </weight_limit>
964
+ <quickcost translate="label">
965
+ <label>Quickcost</label>
966
+ <frontend_type>select</frontend_type>
967
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
968
+ <source_model>adminhtml/system_config_source_yesno</source_model>
969
+ <sort_order>10</sort_order>
970
+ <show_in_default>1</show_in_default>
971
+ <show_in_website>1</show_in_website>
972
+ <show_in_store>0</show_in_store>
973
+ </quickcost>
974
+ <quickcost_marge translate="label">
975
+ <label>Value to add to quickcost</label>
976
+ <frontend_type>text</frontend_type>
977
+ <sort_order>11</sort_order>
978
+ <show_in_default>1</show_in_default>
979
+ <show_in_website>1</show_in_website>
980
+ <show_in_store>1</show_in_store>
981
+ <validate>validate-number</validate>
982
+ </quickcost_marge>
983
+ <quickcost_marge_type translate="label">
984
+ <label>Type value to add</label>
985
+ <frontend_type>select</frontend_type>
986
+ <source_model>chronorelais/config_source_margetype</source_model>
987
+ <sort_order>12</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
+ </quickcost_marge_type>
992
+ <quickcost_url>
993
+ <label>Quickcost Url</label>
994
+ <frontend_type>text</frontend_type>
995
+ <sort_order>13</sort_order>
996
+ <show_in_default>1</show_in_default>
997
+ <show_in_website>1</show_in_website>
998
+ <show_in_store>0</show_in_store>
999
+ </quickcost_url>
1000
+ <free_shipping_enable translate="label">
1001
+ <label>Free Shipping on the Amount</label>
1002
+ <frontend_type>select</frontend_type>
1003
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
1004
+ <sort_order>20</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
+ </free_shipping_enable>
1009
+ <free_shipping_subtotal translate="label">
1010
+ <label>Minimum Amount for Free Shipping</label>
1011
+ <frontend_type>text</frontend_type>
1012
+ <sort_order>30</sort_order>
1013
+ <show_in_default>1</show_in_default>
1014
+ <show_in_website>1</show_in_website>
1015
+ <show_in_store>0</show_in_store>
1016
+ </free_shipping_subtotal>
1017
+ <application_fee translate="label">
1018
+ <label>Application Fee</label>
1019
+ <frontend_type>text</frontend_type>
1020
+ <sort_order>40</sort_order>
1021
+ <show_in_default>1</show_in_default>
1022
+ <show_in_website>1</show_in_website>
1023
+ <show_in_store>1</show_in_store>
1024
+ </application_fee>
1025
+ <handling_fee translate="label">
1026
+ <label>Handling Fee</label>
1027
+ <frontend_type>text</frontend_type>
1028
+ <sort_order>50</sort_order>
1029
+ <show_in_default>1</show_in_default>
1030
+ <show_in_website>1</show_in_website>
1031
+ <show_in_store>1</show_in_store>
1032
+ </handling_fee>
1033
+ <logo_url>
1034
+ <label>Logo Url</label>
1035
+ <frontend_type>text</frontend_type>
1036
+ <comment>{logo_ulr_help}</comment>
1037
+ <sort_order>60</sort_order>
1038
+ <show_in_default>1</show_in_default>
1039
+ <show_in_website>1</show_in_website>
1040
+ <show_in_store>1</show_in_store>
1041
+ </logo_url>
1042
+ <debug>
1043
+ <label>Debug</label>
1044
+ <comment>{debug_help}</comment>
1045
+ <frontend_type>text</frontend_type>
1046
+ <sort_order>70</sort_order>
1047
+ <show_in_default>1</show_in_default>
1048
+ <show_in_website>1</show_in_website>
1049
+ <show_in_store>1</show_in_store>
1050
+ </debug>
1051
+ <!--<stop_to_first_match translate="label">
1052
+ <label>Stop to first match</label>
1053
+ <frontend_type>select</frontend_type>
1054
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1055
+ <sort_order>80</sort_order>
1056
+ <show_in_default>1</show_in_default>
1057
+ <show_in_website>1</show_in_website>
1058
+ <show_in_store>1</show_in_store>
1059
+ </stop_to_first_match>-->
1060
+ <deliver_on_saturday translate="label comment">
1061
+ <label>Livraison le Samedi</label>
1062
+ <frontend_type>select</frontend_type>
1063
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1064
+ <sort_order>90</sort_order>
1065
+ <show_in_default>1</show_in_default>
1066
+ <show_in_website>1</show_in_website>
1067
+ <show_in_store>1</show_in_store>
1068
+ </deliver_on_saturday>
1069
+ <!--<showmethod translate="label">
1070
+ <label>Show Method if Not Applicable</label>
1071
+ <frontend_type>select</frontend_type>
1072
+ <sort_order>100</sort_order>
1073
+ <frontend_class>shipping-skip-hide</frontend_class>
1074
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1075
+ <show_in_default>1</show_in_default>
1076
+ <show_in_website>1</show_in_website>
1077
+ <show_in_store>0</show_in_store>
1078
+ </showmethod>
1079
+ <specificerrmsg translate="label">
1080
+ <label>Displayed Error Message</label>
1081
+ <frontend_type>textarea</frontend_type>
1082
+ <sort_order>110</sort_order>
1083
+ <show_in_default>1</show_in_default>
1084
+ <show_in_website>1</show_in_website>
1085
+ <show_in_store>1</show_in_store>
1086
+ </specificerrmsg>-->
1087
+ <sort_order translate="label">
1088
+ <label>Sort order</label>
1089
+ <frontend_type>text</frontend_type>
1090
+ <sort_order>120</sort_order>
1091
+ <show_in_default>1</show_in_default>
1092
+ <show_in_website>1</show_in_website>
1093
+ <show_in_store>1</show_in_store>
1094
+ </sort_order>
1095
+ </fields>
1096
+ </chronopostcclassic>
1097
+
1098
+ <chronorelaiseurope translate="label">
1099
+ <label>Chrono Relais Europe</label>
1100
+ <frontend_type>text</frontend_type>
1101
+ <sort_order>26</sort_order>
1102
+ <show_in_default>1</show_in_default>
1103
+ <show_in_website>1</show_in_website>
1104
+ <show_in_store>1</show_in_store>
1105
+ <fields>
1106
+ <active translate="label">
1107
+ <label>Enabled</label>
1108
+ <frontend_type>select</frontend_type>
1109
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
1110
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1111
+ <sort_order>1</sort_order>
1112
+ <show_in_default>1</show_in_default>
1113
+ <show_in_website>1</show_in_website>
1114
+ <show_in_store>1</show_in_store>
1115
+ </active>
1116
+ <title translate="label">
1117
+ <label>Title</label>
1118
+ <frontend_type>text</frontend_type>
1119
+ <sort_order>2</sort_order>
1120
+ <show_in_default>1</show_in_default>
1121
+ <show_in_website>1</show_in_website>
1122
+ <show_in_store>1</show_in_store>
1123
+ </title>
1124
+ <config translate="label">
1125
+ <label>Configuration</label>
1126
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
1127
+ <comment>{configuration_syntax_help}</comment>
1128
+ <frontend_type>textarea</frontend_type>
1129
+ <sort_order>3</sort_order>
1130
+ <show_in_default>1</show_in_default>
1131
+ <show_in_website>1</show_in_website>
1132
+ <show_in_store>1</show_in_store>
1133
+ </config>
1134
+ <weight_limit translate="label">
1135
+ <label>Weight Limit</label>
1136
+ <frontend_type>text</frontend_type>
1137
+ <comment>in Kg</comment>
1138
+ <sort_order>7</sort_order>
1139
+ <show_in_default>1</show_in_default>
1140
+ <show_in_website>1</show_in_website>
1141
+ <show_in_store>1</show_in_store>
1142
+ </weight_limit>
1143
+ <quickcost translate="label">
1144
+ <label>Quickcost</label>
1145
+ <frontend_type>select</frontend_type>
1146
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
1147
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1148
+ <sort_order>10</sort_order>
1149
+ <show_in_default>1</show_in_default>
1150
+ <show_in_website>1</show_in_website>
1151
+ <show_in_store>0</show_in_store>
1152
+ </quickcost>
1153
+ <quickcost_marge translate="label">
1154
+ <label>Value to add to quickcost</label>
1155
+ <frontend_type>text</frontend_type>
1156
+ <sort_order>11</sort_order>
1157
+ <show_in_default>1</show_in_default>
1158
+ <show_in_website>1</show_in_website>
1159
+ <show_in_store>1</show_in_store>
1160
+ <validate>validate-number</validate>
1161
+ </quickcost_marge>
1162
+ <quickcost_marge_type translate="label">
1163
+ <label>Type value to add</label>
1164
+ <frontend_type>select</frontend_type>
1165
+ <source_model>chronorelais/config_source_margetype</source_model>
1166
+ <sort_order>12</sort_order>
1167
+ <show_in_default>1</show_in_default>
1168
+ <show_in_website>1</show_in_website>
1169
+ <show_in_store>1</show_in_store>
1170
+ </quickcost_marge_type>
1171
+ <quickcost_url>
1172
+ <label>Quickcost Url</label>
1173
+ <frontend_type>text</frontend_type>
1174
+ <sort_order>13</sort_order>
1175
+ <show_in_default>1</show_in_default>
1176
+ <show_in_website>1</show_in_website>
1177
+ <show_in_store>0</show_in_store>
1178
+ </quickcost_url>
1179
+ <show_google_map translate="label">
1180
+ <label>Show Google Map</label>
1181
+ <frontend_type>select</frontend_type>
1182
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1183
+ <sort_order>20</sort_order>
1184
+ <show_in_default>1</show_in_default>
1185
+ <show_in_website>1</show_in_website>
1186
+ <show_in_store>1</show_in_store>
1187
+ </show_google_map>
1188
+ <max_distance_search translate="label">
1189
+ <label>Max distance search</label>
1190
+ <frontend_type>text</frontend_type>
1191
+ <sort_order>30</sort_order>
1192
+ <show_in_default>1</show_in_default>
1193
+ <show_in_website>1</show_in_website>
1194
+ <show_in_store>0</show_in_store>
1195
+ </max_distance_search>
1196
+ <free_shipping_enable translate="label">
1197
+ <label>Free Shipping with Minimum Order Amount</label>
1198
+ <frontend_type>select</frontend_type>
1199
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
1200
+ <sort_order>40</sort_order>
1201
+ <show_in_default>1</show_in_default>
1202
+ <show_in_website>1</show_in_website>
1203
+ <show_in_store>1</show_in_store>
1204
+ </free_shipping_enable>
1205
+ <free_shipping_subtotal translate="label">
1206
+ <label>Minimum Order Amount for Free Shipping</label>
1207
+ <frontend_type>text</frontend_type>
1208
+ <sort_order>50</sort_order>
1209
+ <show_in_default>1</show_in_default>
1210
+ <show_in_website>1</show_in_website>
1211
+ <show_in_store>1</show_in_store>
1212
+ </free_shipping_subtotal>
1213
+ <application_fee translate="label">
1214
+ <label>Application Fee</label>
1215
+ <frontend_type>text</frontend_type>
1216
+ <sort_order>60</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
+ </application_fee>
1221
+ <handling_fee translate="label">
1222
+ <label>Handling Fee</label>
1223
+ <frontend_type>text</frontend_type>
1224
+ <sort_order>70</sort_order>
1225
+ <show_in_default>1</show_in_default>
1226
+ <show_in_website>1</show_in_website>
1227
+ <show_in_store>1</show_in_store>
1228
+ </handling_fee>
1229
+ <logo_url>
1230
+ <label>Logo Url</label>
1231
+ <frontend_type>text</frontend_type>
1232
+ <comment>{logo_ulr_help}</comment>
1233
+ <sort_order>80</sort_order>
1234
+ <show_in_default>1</show_in_default>
1235
+ <show_in_website>1</show_in_website>
1236
+ <show_in_store>1</show_in_store>
1237
+ </logo_url>
1238
+ <debug>
1239
+ <label>Debug</label>
1240
+ <comment>{debug_help}</comment>
1241
+ <frontend_type>text</frontend_type>
1242
+ <sort_order>90</sort_order>
1243
+ <show_in_default>1</show_in_default>
1244
+ <show_in_website>1</show_in_website>
1245
+ <show_in_store>1</show_in_store>
1246
+ </debug>
1247
+ <sort_order translate="label">
1248
+ <label>Sort order</label>
1249
+ <frontend_type>text</frontend_type>
1250
+ <sort_order>100</sort_order>
1251
+ <show_in_default>1</show_in_default>
1252
+ <show_in_website>1</show_in_website>
1253
+ <show_in_store>1</show_in_store>
1254
+ </sort_order>
1255
+ </fields>
1256
+ </chronorelaiseurope>
1257
+
1258
+ <!--<chronorelaisdom translate="label">
1259
+ <label>Chrono Relais DOM</label>
1260
+ <frontend_type>text</frontend_type>
1261
+ <sort_order>27</sort_order>
1262
+ <show_in_default>1</show_in_default>
1263
+ <show_in_website>1</show_in_website>
1264
+ <show_in_store>1</show_in_store>
1265
+ <fields>
1266
+ <active translate="label">
1267
+ <label>Enabled</label>
1268
+ <frontend_type>select</frontend_type>
1269
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
1270
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1271
+ <sort_order>1</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
+ </active>
1276
+ <title translate="label">
1277
+ <label>Title</label>
1278
+ <frontend_type>text</frontend_type>
1279
+ <sort_order>2</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
+ </title>
1284
+ <config translate="label">
1285
+ <label>Configuration</label>
1286
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
1287
+ <comment>{configuration_syntax_help}</comment>
1288
+ <frontend_type>textarea</frontend_type>
1289
+ <sort_order>3</sort_order>
1290
+ <show_in_default>1</show_in_default>
1291
+ <show_in_website>1</show_in_website>
1292
+ <show_in_store>1</show_in_store>
1293
+ </config>
1294
+ <weight_limit translate="label">
1295
+ <label>Weight Limit</label>
1296
+ <frontend_type>text</frontend_type>
1297
+ <comment>in Kg</comment>
1298
+ <sort_order>7</sort_order>
1299
+ <show_in_default>1</show_in_default>
1300
+ <show_in_website>1</show_in_website>
1301
+ <show_in_store>1</show_in_store>
1302
+ </weight_limit>
1303
+ <quickcost translate="label">
1304
+ <label>Quickcost</label>
1305
+ <frontend_type>select</frontend_type>
1306
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
1307
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1308
+ <sort_order>10</sort_order>
1309
+ <show_in_default>1</show_in_default>
1310
+ <show_in_website>1</show_in_website>
1311
+ <show_in_store>0</show_in_store>
1312
+ </quickcost>
1313
+ <quickcost_marge translate="label">
1314
+ <label>Value to add to quickcost</label>
1315
+ <frontend_type>text</frontend_type>
1316
+ <sort_order>11</sort_order>
1317
+ <show_in_default>1</show_in_default>
1318
+ <show_in_website>1</show_in_website>
1319
+ <show_in_store>1</show_in_store>
1320
+ <validate>validate-number</validate>
1321
+ </quickcost_marge>
1322
+ <quickcost_marge_type translate="label">
1323
+ <label>Type value to add</label>
1324
+ <frontend_type>select</frontend_type>
1325
+ <source_model>chronorelais/config_source_margetype</source_model>
1326
+ <sort_order>12</sort_order>
1327
+ <show_in_default>1</show_in_default>
1328
+ <show_in_website>1</show_in_website>
1329
+ <show_in_store>1</show_in_store>
1330
+ </quickcost_marge_type>
1331
+ <quickcost_url>
1332
+ <label>Quickcost Url</label>
1333
+ <frontend_type>text</frontend_type>
1334
+ <sort_order>13</sort_order>
1335
+ <show_in_default>1</show_in_default>
1336
+ <show_in_website>1</show_in_website>
1337
+ <show_in_store>0</show_in_store>
1338
+ </quickcost_url>
1339
+ <show_google_map translate="label">
1340
+ <label>Show Google Map</label>
1341
+ <frontend_type>select</frontend_type>
1342
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1343
+ <sort_order>20</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
+ </show_google_map>
1348
+ <max_distance_search translate="label">
1349
+ <label>Max distance search</label>
1350
+ <frontend_type>text</frontend_type>
1351
+ <sort_order>30</sort_order>
1352
+ <show_in_default>1</show_in_default>
1353
+ <show_in_website>1</show_in_website>
1354
+ <show_in_store>0</show_in_store>
1355
+ </max_distance_search>
1356
+ <free_shipping_enable translate="label">
1357
+ <label>Free Shipping with Minimum Order Amount</label>
1358
+ <frontend_type>select</frontend_type>
1359
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
1360
+ <sort_order>40</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
+ </free_shipping_enable>
1365
+ <free_shipping_subtotal translate="label">
1366
+ <label>Minimum Order Amount for Free Shipping</label>
1367
+ <frontend_type>text</frontend_type>
1368
+ <sort_order>50</sort_order>
1369
+ <show_in_default>1</show_in_default>
1370
+ <show_in_website>1</show_in_website>
1371
+ <show_in_store>1</show_in_store>
1372
+ </free_shipping_subtotal>
1373
+ <application_fee translate="label">
1374
+ <label>Application Fee</label>
1375
+ <frontend_type>text</frontend_type>
1376
+ <sort_order>60</sort_order>
1377
+ <show_in_default>1</show_in_default>
1378
+ <show_in_website>1</show_in_website>
1379
+ <show_in_store>1</show_in_store>
1380
+ </application_fee>
1381
+ <handling_fee translate="label">
1382
+ <label>Handling Fee</label>
1383
+ <frontend_type>text</frontend_type>
1384
+ <sort_order>70</sort_order>
1385
+ <show_in_default>1</show_in_default>
1386
+ <show_in_website>1</show_in_website>
1387
+ <show_in_store>1</show_in_store>
1388
+ </handling_fee>
1389
+ <logo_url>
1390
+ <label>Logo Url</label>
1391
+ <frontend_type>text</frontend_type>
1392
+ <comment>{logo_ulr_help}</comment>
1393
+ <sort_order>80</sort_order>
1394
+ <show_in_default>1</show_in_default>
1395
+ <show_in_website>1</show_in_website>
1396
+ <show_in_store>1</show_in_store>
1397
+ </logo_url>
1398
+ <debug>
1399
+ <label>Debug</label>
1400
+ <comment>{debug_help}</comment>
1401
+ <frontend_type>text</frontend_type>
1402
+ <sort_order>90</sort_order>
1403
+ <show_in_default>1</show_in_default>
1404
+ <show_in_website>1</show_in_website>
1405
+ <show_in_store>1</show_in_store>
1406
+ </debug>
1407
+ <deliver_on_saturday translate="label comment">
1408
+ <label>Livraison le Samedi</label>
1409
+ <frontend_type>select</frontend_type>
1410
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1411
+ <sort_order>100</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
+ </deliver_on_saturday>
1416
+ <sort_order translate="label">
1417
+ <label>Sort order</label>
1418
+ <frontend_type>text</frontend_type>
1419
+ <sort_order>110</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
+ </sort_order>
1424
+ </fields>
1425
+ </chronorelaisdom>-->
1426
+
1427
+ <chronopostsameday translate="label">
1428
+ <label>Chronopost SAMEDAY</label>
1429
+ <frontend_type>text</frontend_type>
1430
+ <sort_order>28</sort_order>
1431
+ <show_in_default>1</show_in_default>
1432
+ <show_in_website>1</show_in_website>
1433
+ <show_in_store>1</show_in_store>
1434
+ <fields>
1435
+ <active translate="label">
1436
+ <label>Enabled</label>
1437
+ <frontend_type>select</frontend_type>
1438
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
1439
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1440
+ <sort_order>1</sort_order>
1441
+ <show_in_default>1</show_in_default>
1442
+ <show_in_website>1</show_in_website>
1443
+ <show_in_store>1</show_in_store>
1444
+ </active>
1445
+ <title translate="label">
1446
+ <label>Title</label>
1447
+ <frontend_type>text</frontend_type>
1448
+ <sort_order>2</sort_order>
1449
+ <show_in_default>1</show_in_default>
1450
+ <show_in_website>1</show_in_website>
1451
+ <show_in_store>1</show_in_store>
1452
+ </title>
1453
+ <config translate="label">
1454
+ <label>Configuration</label>
1455
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
1456
+ <comment>{configuration_syntax_help}</comment>
1457
+ <frontend_type>textarea</frontend_type>
1458
+ <sort_order>3</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
+ </config>
1463
+ <weight_limit translate="label">
1464
+ <label>Weight Limit</label>
1465
+ <frontend_type>text</frontend_type>
1466
+ <comment>in Kg</comment>
1467
+ <sort_order>7</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
+ </weight_limit>
1472
+ <quickcost translate="label">
1473
+ <label>Quickcost</label>
1474
+ <frontend_type>select</frontend_type>
1475
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
1476
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1477
+ <sort_order>10</sort_order>
1478
+ <show_in_default>1</show_in_default>
1479
+ <show_in_website>1</show_in_website>
1480
+ <show_in_store>0</show_in_store>
1481
+ </quickcost>
1482
+ <quickcost_marge translate="label">
1483
+ <label>Value to add to quickcost</label>
1484
+ <frontend_type>text</frontend_type>
1485
+ <sort_order>11</sort_order>
1486
+ <show_in_default>1</show_in_default>
1487
+ <show_in_website>1</show_in_website>
1488
+ <show_in_store>1</show_in_store>
1489
+ <validate>validate-number</validate>
1490
+ </quickcost_marge>
1491
+ <quickcost_marge_type translate="label">
1492
+ <label>Type value to add</label>
1493
+ <frontend_type>select</frontend_type>
1494
+ <source_model>chronorelais/config_source_margetype</source_model>
1495
+ <sort_order>12</sort_order>
1496
+ <show_in_default>1</show_in_default>
1497
+ <show_in_website>1</show_in_website>
1498
+ <show_in_store>1</show_in_store>
1499
+ </quickcost_marge_type>
1500
+ <quickcost_url>
1501
+ <label>Quickcost Url</label>
1502
+ <frontend_type>text</frontend_type>
1503
+ <sort_order>13</sort_order>
1504
+ <show_in_default>1</show_in_default>
1505
+ <show_in_website>1</show_in_website>
1506
+ <show_in_store>0</show_in_store>
1507
+ </quickcost_url>
1508
+ <free_shipping_enable translate="label">
1509
+ <label>Free Shipping on the Amount</label>
1510
+ <frontend_type>select</frontend_type>
1511
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
1512
+ <sort_order>20</sort_order>
1513
+ <show_in_default>1</show_in_default>
1514
+ <show_in_website>1</show_in_website>
1515
+ <show_in_store>1</show_in_store>
1516
+ </free_shipping_enable>
1517
+ <free_shipping_subtotal translate="label">
1518
+ <label>Minimum Amount for Free Shipping</label>
1519
+ <frontend_type>text</frontend_type>
1520
+ <sort_order>30</sort_order>
1521
+ <show_in_default>1</show_in_default>
1522
+ <show_in_website>1</show_in_website>
1523
+ <show_in_store>0</show_in_store>
1524
+ </free_shipping_subtotal>
1525
+ <application_fee translate="label">
1526
+ <label>Application Fee</label>
1527
+ <frontend_type>text</frontend_type>
1528
+ <sort_order>40</sort_order>
1529
+ <show_in_default>1</show_in_default>
1530
+ <show_in_website>1</show_in_website>
1531
+ <show_in_store>1</show_in_store>
1532
+ </application_fee>
1533
+ <handling_fee translate="label">
1534
+ <label>Handling Fee</label>
1535
+ <frontend_type>text</frontend_type>
1536
+ <sort_order>50</sort_order>
1537
+ <show_in_default>1</show_in_default>
1538
+ <show_in_website>1</show_in_website>
1539
+ <show_in_store>1</show_in_store>
1540
+ </handling_fee>
1541
+ <logo_url>
1542
+ <label>Logo Url</label>
1543
+ <frontend_type>text</frontend_type>
1544
+ <comment>{logo_ulr_help}</comment>
1545
+ <sort_order>60</sort_order>
1546
+ <show_in_default>1</show_in_default>
1547
+ <show_in_website>1</show_in_website>
1548
+ <show_in_store>1</show_in_store>
1549
+ </logo_url>
1550
+ <debug>
1551
+ <label>Debug</label>
1552
+ <comment>{debug_help}</comment>
1553
+ <frontend_type>text</frontend_type>
1554
+ <sort_order>70</sort_order>
1555
+ <show_in_default>1</show_in_default>
1556
+ <show_in_website>1</show_in_website>
1557
+ <show_in_store>1</show_in_store>
1558
+ </debug>
1559
+ <!--<stop_to_first_match translate="label">
1560
+ <label>Stop to first match</label>
1561
+ <frontend_type>select</frontend_type>
1562
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1563
+ <sort_order>80</sort_order>
1564
+ <show_in_default>1</show_in_default>
1565
+ <show_in_website>1</show_in_website>
1566
+ <show_in_store>1</show_in_store>
1567
+ </stop_to_first_match>-->
1568
+ <deliver_on_saturday translate="label comment">
1569
+ <label>Livraison le Samedi</label>
1570
+ <frontend_type>select</frontend_type>
1571
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1572
+ <sort_order>90</sort_order>
1573
+ <show_in_default>1</show_in_default>
1574
+ <show_in_website>1</show_in_website>
1575
+ <show_in_store>1</show_in_store>
1576
+ </deliver_on_saturday>
1577
+ <delivery_time_limit>
1578
+ <label>Disable after</label>
1579
+ <comment>The module will be disabled after the selected hour. If it is not working, check your timezone settings in General config.</comment>
1580
+ <frontend_type>select</frontend_type>
1581
+ <source_model>chronorelais/config_source_time</source_model>
1582
+ <sort_order>100</sort_order>
1583
+ <show_in_default>1</show_in_default>
1584
+ <show_in_website>1</show_in_website>
1585
+ <show_in_store>1</show_in_store>
1586
+ </delivery_time_limit>
1587
+ <!--<showmethod translate="label">
1588
+ <label>Show Method if Not Applicable</label>
1589
+ <frontend_type>select</frontend_type>
1590
+ <sort_order>100</sort_order>
1591
+ <frontend_class>shipping-skip-hide</frontend_class>
1592
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1593
+ <show_in_default>1</show_in_default>
1594
+ <show_in_website>1</show_in_website>
1595
+ <show_in_store>0</show_in_store>
1596
+ </showmethod>
1597
+ <specificerrmsg translate="label">
1598
+ <label>Displayed Error Message</label>
1599
+ <frontend_type>textarea</frontend_type>
1600
+ <sort_order>110</sort_order>
1601
+ <show_in_default>1</show_in_default>
1602
+ <show_in_website>1</show_in_website>
1603
+ <show_in_store>1</show_in_store>
1604
+ </specificerrmsg>-->
1605
+ <sort_order translate="label">
1606
+ <label>Sort order</label>
1607
+ <frontend_type>text</frontend_type>
1608
+ <sort_order>120</sort_order>
1609
+ <show_in_default>1</show_in_default>
1610
+ <show_in_website>1</show_in_website>
1611
+ <show_in_store>1</show_in_store>
1612
+ </sort_order>
1613
+ </fields>
1614
+ </chronopostsameday>
1615
+
1616
+ <chronopostsrdv translate="label">
1617
+ <label>Chronopost Sur Rendez-vous</label>
1618
+ <frontend_type>text</frontend_type>
1619
+ <sort_order>30</sort_order>
1620
+ <show_in_default>1</show_in_default>
1621
+ <show_in_website>1</show_in_website>
1622
+ <show_in_store>1</show_in_store>
1623
+ <fields>
1624
+ <active translate="label">
1625
+ <label>Enabled</label>
1626
+ <frontend_type>select</frontend_type>
1627
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
1628
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1629
+ <sort_order>1</sort_order>
1630
+ <show_in_default>1</show_in_default>
1631
+ <show_in_website>1</show_in_website>
1632
+ <show_in_store>1</show_in_store>
1633
+ </active>
1634
+ <title translate="label">
1635
+ <label>Title</label>
1636
+ <frontend_type>text</frontend_type>
1637
+ <sort_order>2</sort_order>
1638
+ <show_in_default>1</show_in_default>
1639
+ <show_in_website>1</show_in_website>
1640
+ <show_in_store>1</show_in_store>
1641
+ </title>
1642
+ <config translate="label">
1643
+ <label>Configuration</label>
1644
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
1645
+ <comment>{configuration_syntax_help}</comment>
1646
+ <frontend_type>textarea</frontend_type>
1647
+ <sort_order>3</sort_order>
1648
+ <show_in_default>1</show_in_default>
1649
+ <show_in_website>1</show_in_website>
1650
+ <show_in_store>1</show_in_store>
1651
+ </config>
1652
+ <weight_limit translate="label">
1653
+ <label>Weight Limit</label>
1654
+ <frontend_type>text</frontend_type>
1655
+ <comment>in Kg</comment>
1656
+ <sort_order>7</sort_order>
1657
+ <show_in_default>1</show_in_default>
1658
+ <show_in_website>1</show_in_website>
1659
+ <show_in_store>1</show_in_store>
1660
+ </weight_limit>
1661
+ <quickcost translate="label">
1662
+ <label>Quickcost</label>
1663
+ <frontend_type>select</frontend_type>
1664
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
1665
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1666
+ <sort_order>10</sort_order>
1667
+ <show_in_default>1</show_in_default>
1668
+ <show_in_website>1</show_in_website>
1669
+ <show_in_store>0</show_in_store>
1670
+ </quickcost>
1671
+ <quickcost_marge translate="label">
1672
+ <label>Value to add to quickcost</label>
1673
+ <frontend_type>text</frontend_type>
1674
+ <sort_order>11</sort_order>
1675
+ <show_in_default>1</show_in_default>
1676
+ <show_in_website>1</show_in_website>
1677
+ <show_in_store>1</show_in_store>
1678
+ <validate>validate-number</validate>
1679
+ </quickcost_marge>
1680
+ <quickcost_marge_type translate="label">
1681
+ <label>Type value to add</label>
1682
+ <frontend_type>select</frontend_type>
1683
+ <source_model>chronorelais/config_source_margetype</source_model>
1684
+ <sort_order>12</sort_order>
1685
+ <show_in_default>1</show_in_default>
1686
+ <show_in_website>1</show_in_website>
1687
+ <show_in_store>1</show_in_store>
1688
+ </quickcost_marge_type>
1689
+ <quickcost_url>
1690
+ <label>Quickcost Url</label>
1691
+ <frontend_type>text</frontend_type>
1692
+ <sort_order>13</sort_order>
1693
+ <show_in_default>1</show_in_default>
1694
+ <show_in_website>1</show_in_website>
1695
+ <show_in_store>0</show_in_store>
1696
+ </quickcost_url>
1697
+ <free_shipping_enable translate="label">
1698
+ <label>Free Shipping on the Amount</label>
1699
+ <frontend_type>select</frontend_type>
1700
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
1701
+ <sort_order>20</sort_order>
1702
+ <show_in_default>1</show_in_default>
1703
+ <show_in_website>1</show_in_website>
1704
+ <show_in_store>1</show_in_store>
1705
+ </free_shipping_enable>
1706
+ <free_shipping_subtotal translate="label">
1707
+ <label>Minimum Amount for Free Shipping</label>
1708
+ <frontend_type>text</frontend_type>
1709
+ <sort_order>30</sort_order>
1710
+ <show_in_default>1</show_in_default>
1711
+ <show_in_website>1</show_in_website>
1712
+ <show_in_store>0</show_in_store>
1713
+ </free_shipping_subtotal>
1714
+ <application_fee translate="label">
1715
+ <label>Application Fee</label>
1716
+ <frontend_type>text</frontend_type>
1717
+ <sort_order>40</sort_order>
1718
+ <show_in_default>1</show_in_default>
1719
+ <show_in_website>1</show_in_website>
1720
+ <show_in_store>1</show_in_store>
1721
+ </application_fee>
1722
+ <handling_fee translate="label">
1723
+ <label>Handling Fee</label>
1724
+ <frontend_type>text</frontend_type>
1725
+ <sort_order>50</sort_order>
1726
+ <show_in_default>1</show_in_default>
1727
+ <show_in_website>1</show_in_website>
1728
+ <show_in_store>1</show_in_store>
1729
+ </handling_fee>
1730
+ <rdv_config translate="label">
1731
+ <label>Configuration RDV</label>
1732
+ <frontend_type>text</frontend_type>
1733
+ <frontend_model>chronorelais/adminhtml_system_config_rdvconfig</frontend_model>
1734
+ <sort_order>55</sort_order>
1735
+ <show_in_default>1</show_in_default>
1736
+ <show_in_website>1</show_in_website>
1737
+ <show_in_store>1</show_in_store>
1738
+ </rdv_config>
1739
+ <logo_url>
1740
+ <label>Logo Url</label>
1741
+ <frontend_type>text</frontend_type>
1742
+ <comment>{logo_ulr_help}</comment>
1743
+ <sort_order>60</sort_order>
1744
+ <show_in_default>1</show_in_default>
1745
+ <show_in_website>1</show_in_website>
1746
+ <show_in_store>1</show_in_store>
1747
+ </logo_url>
1748
+ <debug>
1749
+ <label>Debug</label>
1750
+ <comment>{debug_help}</comment>
1751
+ <frontend_type>text</frontend_type>
1752
+ <sort_order>70</sort_order>
1753
+ <show_in_default>1</show_in_default>
1754
+ <show_in_website>1</show_in_website>
1755
+ <show_in_store>1</show_in_store>
1756
+ </debug>
1757
+ <!--<stop_to_first_match translate="label">
1758
+ <label>Stop to first match</label>
1759
+ <frontend_type>select</frontend_type>
1760
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1761
+ <sort_order>80</sort_order>
1762
+ <show_in_default>1</show_in_default>
1763
+ <show_in_website>1</show_in_website>
1764
+ <show_in_store>1</show_in_store>
1765
+ </stop_to_first_match>-->
1766
+ <deliver_on_saturday translate="label comment">
1767
+ <label>Livraison le Samedi</label>
1768
+ <frontend_type>select</frontend_type>
1769
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1770
+ <sort_order>90</sort_order>
1771
+ <show_in_default>1</show_in_default>
1772
+ <show_in_website>1</show_in_website>
1773
+ <show_in_store>1</show_in_store>
1774
+ </deliver_on_saturday>
1775
+ <!--<showmethod translate="label">
1776
+ <label>Show Method if Not Applicable</label>
1777
+ <frontend_type>select</frontend_type>
1778
+ <sort_order>100</sort_order>
1779
+ <frontend_class>shipping-skip-hide</frontend_class>
1780
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1781
+ <show_in_default>1</show_in_default>
1782
+ <show_in_website>1</show_in_website>
1783
+ <show_in_store>0</show_in_store>
1784
+ </showmethod>
1785
+ <specificerrmsg translate="label">
1786
+ <label>Displayed Error Message</label>
1787
+ <frontend_type>textarea</frontend_type>
1788
+ <sort_order>110</sort_order>
1789
+ <show_in_default>1</show_in_default>
1790
+ <show_in_website>1</show_in_website>
1791
+ <show_in_store>1</show_in_store>
1792
+ </specificerrmsg>-->
1793
+ <sort_order translate="label">
1794
+ <label>Sort order</label>
1795
+ <frontend_type>text</frontend_type>
1796
+ <sort_order>120</sort_order>
1797
+ <show_in_default>1</show_in_default>
1798
+ <show_in_website>1</show_in_website>
1799
+ <show_in_store>1</show_in_store>
1800
+ </sort_order>
1801
+ </fields>
1802
+ </chronopostsrdv>
1803
+
1804
+ </groups>
1805
+ </carriers>
1806
+ </sections>
1807
+
1808
+ <sections>
1809
+ <chronorelais>
1810
+ <label>Configuration</label>
1811
+ <tab>chronopost</tab>
1812
+ <frontend_type>text</frontend_type>
1813
+ <sort_order>2000</sort_order>
1814
+ <show_in_default>1</show_in_default>
1815
+ <show_in_website>1</show_in_website>
1816
+ <show_in_store>1</show_in_store>
1817
+ <groups>
1818
+ <shipping translate="label">
1819
+ <label>General</label>
1820
+ <frontend_type>text</frontend_type>
1821
+ <sort_order>10</sort_order>
1822
+ <show_in_default>1</show_in_default>
1823
+ <show_in_website>1</show_in_website>
1824
+ <show_in_store>1</show_in_store>
1825
+ <fields>
1826
+ <account_number translate="label">
1827
+ <label>N° de compte Chronopost</label>
1828
+ <frontend_type>text</frontend_type>
1829
+ <sort_order>7</sort_order>
1830
+ <show_in_default>1</show_in_default>
1831
+ <show_in_website>1</show_in_website>
1832
+ <show_in_store>1</show_in_store>
1833
+ </account_number>
1834
+ <sub_account_number translate="label">
1835
+ <label>N° de sous-compte</label>
1836
+ <comment>must be 3 digits or empty</comment>
1837
+ <frontend_type>text</frontend_type>
1838
+ <sort_order>8</sort_order>
1839
+ <show_in_default>1</show_in_default>
1840
+ <show_in_website>1</show_in_website>
1841
+ <show_in_store>1</show_in_store>
1842
+ </sub_account_number>
1843
+ <account_pass translate="label">
1844
+ <label>Mot de passe Chronopost</label>
1845
+ <frontend_type>text</frontend_type>
1846
+ <button_label>Vérifier mes identifiants</button_label>
1847
+ <frontend_model>chronorelais/adminhtml_system_config_checklogin</frontend_model>
1848
+ <sort_order>9</sort_order>
1849
+ <show_in_default>1</show_in_default>
1850
+ <show_in_website>1</show_in_website>
1851
+ <show_in_store>1</show_in_store>
1852
+ </account_pass>
1853
+ <google_map_api translate="label">
1854
+ <label>Google Map v3 API Key</label>
1855
+ <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>
1856
+ <frontend_type>text</frontend_type>
1857
+ <sort_order>10</sort_order>
1858
+ <show_in_default>1</show_in_default>
1859
+ <show_in_website>1</show_in_website>
1860
+ <show_in_store>1</show_in_store>
1861
+ </google_map_api>
1862
+ <tracking_view_url translate="label">
1863
+ <label>Tracking URL</label>
1864
+ <comment>For English language, replace fr_FR with en_GB in the above url</comment>
1865
+ <frontend_type>text</frontend_type>
1866
+ <sort_order>20</sort_order>
1867
+ <show_in_default>1</show_in_default>
1868
+ <show_in_website>1</show_in_website>
1869
+ <show_in_store>1</show_in_store>
1870
+ </tracking_view_url>
1871
+ <gs_path translate="label">
1872
+ <label>Chemin GS</label>
1873
+ <comment>Chemin d'accès à la commande gs (Ghostscript)</comment>
1874
+ <frontend_type>text</frontend_type>
1875
+ <sort_order>21</sort_order>
1876
+ <show_in_default>1</show_in_default>
1877
+ <show_in_website>0</show_in_website>
1878
+ <show_in_store>0</show_in_store>
1879
+ </gs_path>
1880
+
1881
+ </fields>
1882
+ </shipping>
1883
+ <export_css translate="label">
1884
+ <label>Export Configuration CSS</label>
1885
+ <frontend_type>text</frontend_type>
1886
+ <sort_order>20</sort_order>
1887
+ <show_in_default>1</show_in_default>
1888
+ <show_in_website>1</show_in_website>
1889
+ <show_in_store>1</show_in_store>
1890
+ <fields>
1891
+ <file_extension translate="label">
1892
+ <label>File Extension</label>
1893
+ <frontend_type>select</frontend_type>
1894
+ <source_model>chronorelais/config_source_fileExtension</source_model>
1895
+ <sort_order>10</sort_order>
1896
+ <show_in_default>1</show_in_default>
1897
+ <show_in_website>1</show_in_website>
1898
+ <show_in_store>1</show_in_store>
1899
+ </file_extension>
1900
+ <file_charset translate="label">
1901
+ <label>File Charset</label>
1902
+ <frontend_type>select</frontend_type>
1903
+ <source_model>chronorelais/config_source_fileCharset</source_model>
1904
+ <sort_order>20</sort_order>
1905
+ <show_in_default>1</show_in_default>
1906
+ <show_in_website>1</show_in_website>
1907
+ <show_in_store>1</show_in_store>
1908
+ </file_charset>
1909
+ <endofline_character translate="label">
1910
+ <label>End Of Line Character</label>
1911
+ <frontend_type>select</frontend_type>
1912
+ <source_model>chronorelais/config_source_endOfLineCharacter</source_model>
1913
+ <sort_order>30</sort_order>
1914
+ <show_in_default>1</show_in_default>
1915
+ <show_in_website>1</show_in_website>
1916
+ <show_in_store>1</show_in_store>
1917
+ </endofline_character>
1918
+ <field_delimiter translate="label">
1919
+ <label>Field Delimiter</label>
1920
+ <frontend_type>select</frontend_type>
1921
+ <source_model>chronorelais/config_source_fieldDelimiter</source_model>
1922
+ <sort_order>40</sort_order>
1923
+ <show_in_default>1</show_in_default>
1924
+ <show_in_website>1</show_in_website>
1925
+ <show_in_store>1</show_in_store>
1926
+ </field_delimiter>
1927
+ <field_separator translate="label">
1928
+ <label>Field Separator</label>
1929
+ <frontend_type>select</frontend_type>
1930
+ <source_model>chronorelais/config_source_fieldSeparator</source_model>
1931
+ <sort_order>50</sort_order>
1932
+ <show_in_default>1</show_in_default>
1933
+ <show_in_website>1</show_in_website>
1934
+ <show_in_store>1</show_in_store>
1935
+ </field_separator>
1936
+ </fields>
1937
+ </export_css>
1938
+ <export_cso translate="label">
1939
+ <label>Export Configuration CSO</label>
1940
+ <frontend_type>text</frontend_type>
1941
+ <sort_order>21</sort_order>
1942
+ <show_in_default>1</show_in_default>
1943
+ <show_in_website>1</show_in_website>
1944
+ <show_in_store>1</show_in_store>
1945
+ <fields>
1946
+ <file_extension translate="label">
1947
+ <label>File Extension</label>
1948
+ <frontend_type>select</frontend_type>
1949
+ <source_model>chronorelais/config_source_fileExtension</source_model>
1950
+ <sort_order>10</sort_order>
1951
+ <show_in_default>1</show_in_default>
1952
+ <show_in_website>1</show_in_website>
1953
+ <show_in_store>1</show_in_store>
1954
+ </file_extension>
1955
+ <file_charset translate="label">
1956
+ <label>File Charset</label>
1957
+ <frontend_type>select</frontend_type>
1958
+ <source_model>chronorelais/config_source_fileCharset</source_model>
1959
+ <sort_order>20</sort_order>
1960
+ <show_in_default>1</show_in_default>
1961
+ <show_in_website>1</show_in_website>
1962
+ <show_in_store>1</show_in_store>
1963
+ </file_charset>
1964
+ <endofline_character translate="label">
1965
+ <label>End Of Line Character</label>
1966
+ <frontend_type>select</frontend_type>
1967
+ <source_model>chronorelais/config_source_endOfLineCharacter</source_model>
1968
+ <sort_order>30</sort_order>
1969
+ <show_in_default>1</show_in_default>
1970
+ <show_in_website>1</show_in_website>
1971
+ <show_in_store>1</show_in_store>
1972
+ </endofline_character>
1973
+ <field_delimiter translate="label">
1974
+ <label>Field Delimiter</label>
1975
+ <frontend_type>select</frontend_type>
1976
+ <source_model>chronorelais/config_source_fieldDelimiter</source_model>
1977
+ <sort_order>40</sort_order>
1978
+ <show_in_default>1</show_in_default>
1979
+ <show_in_website>1</show_in_website>
1980
+ <show_in_store>1</show_in_store>
1981
+ </field_delimiter>
1982
+ <field_separator translate="label">
1983
+ <label>Field Separator</label>
1984
+ <frontend_type>select</frontend_type>
1985
+ <source_model>chronorelais/config_source_fieldSeparator</source_model>
1986
+ <sort_order>50</sort_order>
1987
+ <show_in_default>1</show_in_default>
1988
+ <show_in_website>1</show_in_website>
1989
+ <show_in_store>1</show_in_store>
1990
+ </field_separator>
1991
+ </fields>
1992
+ </export_cso>
1993
+ <import translate="label">
1994
+ <label>Import Configuration</label>
1995
+ <frontend_type>text</frontend_type>
1996
+ <sort_order>30</sort_order>
1997
+ <show_in_default>1</show_in_default>
1998
+ <show_in_website>1</show_in_website>
1999
+ <show_in_store>1</show_in_store>
2000
+ <fields>
2001
+ <default_tracking_title translate="label comment">
2002
+ <label>Default Tracking Title</label>
2003
+ <frontend_type>text</frontend_type>
2004
+ <sort_order>10</sort_order>
2005
+ <show_in_default>1</show_in_default>
2006
+ <show_in_website>1</show_in_website>
2007
+ <show_in_store>1</show_in_store>
2008
+ <comment>This value can be changed in the import form</comment>
2009
+ </default_tracking_title>
2010
+ <send_email translate="label comment">
2011
+ <label>Send an e-mail</label>
2012
+ <frontend_type>select</frontend_type>
2013
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2014
+ <sort_order>20</sort_order>
2015
+ <show_in_default>1</show_in_default>
2016
+ <show_in_website>1</show_in_website>
2017
+ <show_in_store>1</show_in_store>
2018
+ <comment>Send shipping confirmation to the customer</comment>
2019
+ </send_email>
2020
+ <shipping_comment translate="label comment">
2021
+ <label>Shipping Comment</label>
2022
+ <frontend_type>text</frontend_type>
2023
+ <sort_order>30</sort_order>
2024
+ <show_in_default>1</show_in_default>
2025
+ <show_in_website>1</show_in_website>
2026
+ <show_in_store>1</show_in_store>
2027
+ <comment>Internal comment, can be left empty</comment>
2028
+ </shipping_comment>
2029
+ <include_comment translate="label comment">
2030
+ <label>Include comment into e-mail</label>
2031
+ <frontend_type>select</frontend_type>
2032
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2033
+ <sort_order>40</sort_order>
2034
+ <show_in_default>1</show_in_default>
2035
+ <show_in_website>1</show_in_website>
2036
+ <show_in_store>1</show_in_store>
2037
+ <comment>Only applies if the shipping comment is set</comment>
2038
+ </include_comment>
2039
+ </fields>
2040
+ </import>
2041
+
2042
+ <shipperinformation translate="label">
2043
+ <label>Shipper Information for Labels printing</label>
2044
+ <frontend_type>text</frontend_type>
2045
+ <sort_order>40</sort_order>
2046
+ <show_in_default>1</show_in_default>
2047
+ <show_in_website>1</show_in_website>
2048
+ <show_in_store>1</show_in_store>
2049
+ <fields>
2050
+ <civility translate="label">
2051
+ <label>Shipper Civility</label>
2052
+ <frontend_type>select</frontend_type>
2053
+ <source_model>chronorelais/config_source_civility</source_model>
2054
+ <sort_order>10</sort_order>
2055
+ <show_in_default>1</show_in_default>
2056
+ <show_in_website>1</show_in_website>
2057
+ <show_in_store>1</show_in_store>
2058
+ </civility>
2059
+ <name translate="label comment">
2060
+ <label>Shipper Name</label>
2061
+ <frontend_type>text</frontend_type>
2062
+ <sort_order>20</sort_order>
2063
+ <show_in_default>1</show_in_default>
2064
+ <show_in_website>1</show_in_website>
2065
+ <show_in_store>1</show_in_store>
2066
+ <comment>Company name</comment>
2067
+ </name>
2068
+ <name2 translate="label comment">
2069
+ <label>Shipper Name2</label>
2070
+ <frontend_type>text</frontend_type>
2071
+ <sort_order>30</sort_order>
2072
+ <show_in_default>1</show_in_default>
2073
+ <show_in_website>1</show_in_website>
2074
+ <show_in_store>1</show_in_store>
2075
+ <comment>[Optional]</comment>
2076
+ </name2>
2077
+ <address1 translate="label">
2078
+ <label>Shipper Address1</label>
2079
+ <frontend_type>text</frontend_type>
2080
+ <sort_order>40</sort_order>
2081
+ <show_in_default>1</show_in_default>
2082
+ <show_in_website>1</show_in_website>
2083
+ <show_in_store>1</show_in_store>
2084
+ </address1>
2085
+ <address2 translate="label comment">
2086
+ <label>Shipper Address2</label>
2087
+ <frontend_type>text</frontend_type>
2088
+ <sort_order>50</sort_order>
2089
+ <show_in_default>1</show_in_default>
2090
+ <show_in_website>1</show_in_website>
2091
+ <show_in_store>1</show_in_store>
2092
+ <comment>[Optional]</comment>
2093
+ </address2>
2094
+ <zipcode translate="label">
2095
+ <label>Shipper Zipcode</label>
2096
+ <frontend_type>text</frontend_type>
2097
+ <sort_order>60</sort_order>
2098
+ <show_in_default>1</show_in_default>
2099
+ <show_in_website>1</show_in_website>
2100
+ <show_in_store>1</show_in_store>
2101
+ </zipcode>
2102
+ <city translate="label">
2103
+ <label>Shipper City</label>
2104
+ <frontend_type>text</frontend_type>
2105
+ <sort_order>70</sort_order>
2106
+ <show_in_default>1</show_in_default>
2107
+ <show_in_website>1</show_in_website>
2108
+ <show_in_store>1</show_in_store>
2109
+ </city>
2110
+ <country translate="label">
2111
+ <label>Shipper Country</label>
2112
+ <frontend_type>select</frontend_type>
2113
+ <sort_order>80</sort_order>
2114
+ <source_model>adminhtml/system_config_source_country</source_model>
2115
+ <show_in_default>1</show_in_default>
2116
+ <show_in_website>1</show_in_website>
2117
+ <show_in_store>1</show_in_store>
2118
+ </country>
2119
+ <contactname translate="label">
2120
+ <label>Shipper Contact Name</label>
2121
+ <frontend_type>text</frontend_type>
2122
+ <sort_order>90</sort_order>
2123
+ <show_in_default>1</show_in_default>
2124
+ <show_in_website>1</show_in_website>
2125
+ <show_in_store>1</show_in_store>
2126
+ </contactname>
2127
+ <email translate="label">
2128
+ <label>Shipper Email</label>
2129
+ <frontend_type>text</frontend_type>
2130
+ <sort_order>100</sort_order>
2131
+ <show_in_default>1</show_in_default>
2132
+ <show_in_website>1</show_in_website>
2133
+ <show_in_store>1</show_in_store>
2134
+ <comment>[Optional]</comment>
2135
+ </email>
2136
+ <phone translate="label comment">
2137
+ <label>Shipper Telephone</label>
2138
+ <frontend_type>text</frontend_type>
2139
+ <sort_order>110</sort_order>
2140
+ <show_in_default>1</show_in_default>
2141
+ <show_in_website>1</show_in_website>
2142
+ <show_in_store>1</show_in_store>
2143
+ <comment>[Optional]</comment>
2144
+ </phone>
2145
+ <mobilephone translate="label comment">
2146
+ <label>Shipper Mobile</label>
2147
+ <frontend_type>text</frontend_type>
2148
+ <sort_order>120</sort_order>
2149
+ <show_in_default>1</show_in_default>
2150
+ <show_in_website>1</show_in_website>
2151
+ <show_in_store>1</show_in_store>
2152
+ <comment>[Optional]</comment>
2153
+ </mobilephone>
2154
+ </fields>
2155
+ </shipperinformation>
2156
+
2157
+ <customerinformation translate="label">
2158
+ <label>Chronopost Customer Account Information for Labels printing</label>
2159
+ <frontend_type>text</frontend_type>
2160
+ <sort_order>50</sort_order>
2161
+ <show_in_default>1</show_in_default>
2162
+ <show_in_website>1</show_in_website>
2163
+ <show_in_store>1</show_in_store>
2164
+ <fields>
2165
+ <civility translate="label">
2166
+ <label>Customer Civility</label>
2167
+ <frontend_type>select</frontend_type>
2168
+ <source_model>chronorelais/config_source_civility</source_model>
2169
+ <sort_order>10</sort_order>
2170
+ <show_in_default>1</show_in_default>
2171
+ <show_in_website>1</show_in_website>
2172
+ <show_in_store>1</show_in_store>
2173
+ </civility>
2174
+ <name translate="label comment">
2175
+ <label>Customer Name </label>
2176
+ <frontend_type>text</frontend_type>
2177
+ <sort_order>20</sort_order>
2178
+ <show_in_default>1</show_in_default>
2179
+ <show_in_website>1</show_in_website>
2180
+ <show_in_store>1</show_in_store>
2181
+ <comment>Company name</comment>
2182
+ </name>
2183
+ <name2 translate="label comment">
2184
+ <label>Customer Name2</label>
2185
+ <frontend_type>text</frontend_type>
2186
+ <sort_order>30</sort_order>
2187
+ <show_in_default>1</show_in_default>
2188
+ <show_in_website>1</show_in_website>
2189
+ <show_in_store>1</show_in_store>
2190
+ <comment>[Optional]</comment>
2191
+ </name2>
2192
+ <address1 translate="label">
2193
+ <label>Customer Address1</label>
2194
+ <frontend_type>text</frontend_type>
2195
+ <sort_order>40</sort_order>
2196
+ <show_in_default>1</show_in_default>
2197
+ <show_in_website>1</show_in_website>
2198
+ <show_in_store>1</show_in_store>
2199
+ </address1>
2200
+ <address2 translate="label comment">
2201
+ <label>Customer Address2</label>
2202
+ <frontend_type>text</frontend_type>
2203
+ <sort_order>50</sort_order>
2204
+ <show_in_default>1</show_in_default>
2205
+ <show_in_website>1</show_in_website>
2206
+ <show_in_store>1</show_in_store>
2207
+ <comment>[Optional]</comment>
2208
+ </address2>
2209
+ <zipcode translate="label">
2210
+ <label>Customer Zipcode</label>
2211
+ <frontend_type>text</frontend_type>
2212
+ <sort_order>60</sort_order>
2213
+ <show_in_default>1</show_in_default>
2214
+ <show_in_website>1</show_in_website>
2215
+ <show_in_store>1</show_in_store>
2216
+ </zipcode>
2217
+ <city translate="label">
2218
+ <label>Customer City</label>
2219
+ <frontend_type>text</frontend_type>
2220
+ <sort_order>70</sort_order>
2221
+ <show_in_default>1</show_in_default>
2222
+ <show_in_website>1</show_in_website>
2223
+ <show_in_store>1</show_in_store>
2224
+ </city>
2225
+ <country translate="label">
2226
+ <label>Customer Country</label>
2227
+ <frontend_type>select</frontend_type>
2228
+ <sort_order>80</sort_order>
2229
+ <source_model>adminhtml/system_config_source_country</source_model>
2230
+ <show_in_default>1</show_in_default>
2231
+ <show_in_website>1</show_in_website>
2232
+ <show_in_store>1</show_in_store>
2233
+ </country>
2234
+ <contactname translate="label">
2235
+ <label>Customer Contact Name</label>
2236
+ <frontend_type>text</frontend_type>
2237
+ <sort_order>90</sort_order>
2238
+ <show_in_default>1</show_in_default>
2239
+ <show_in_website>1</show_in_website>
2240
+ <show_in_store>1</show_in_store>
2241
+ </contactname>
2242
+ <email translate="label">
2243
+ <label>Customer Email</label>
2244
+ <frontend_type>text</frontend_type>
2245
+ <sort_order>100</sort_order>
2246
+ <show_in_default>1</show_in_default>
2247
+ <show_in_website>1</show_in_website>
2248
+ <show_in_store>1</show_in_store>
2249
+ <comment>[Optional]</comment>
2250
+ </email>
2251
+ <phone translate="label comment">
2252
+ <label>Customer Telephone</label>
2253
+ <frontend_type>text</frontend_type>
2254
+ <sort_order>110</sort_order>
2255
+ <show_in_default>1</show_in_default>
2256
+ <show_in_website>1</show_in_website>
2257
+ <show_in_store>1</show_in_store>
2258
+ <comment>[Optional]</comment>
2259
+ </phone>
2260
+ <mobilephone translate="label comment">
2261
+ <label>Customer Mobile</label>
2262
+ <frontend_type>text</frontend_type>
2263
+ <sort_order>120</sort_order>
2264
+ <show_in_default>1</show_in_default>
2265
+ <show_in_website>1</show_in_website>
2266
+ <show_in_store>1</show_in_store>
2267
+ <comment>[Optional]</comment>
2268
+ </mobilephone>
2269
+ </fields>
2270
+ </customerinformation>
2271
+
2272
+ <skybillparam translate="label">
2273
+ <label>Skybill Parameters for Labels printing</label>
2274
+ <frontend_type>text</frontend_type>
2275
+ <sort_order>60</sort_order>
2276
+ <show_in_default>1</show_in_default>
2277
+ <show_in_website>1</show_in_website>
2278
+ <show_in_store>1</show_in_store>
2279
+ <fields>
2280
+ <mode translate="label">
2281
+ <label>Print Mode</label>
2282
+ <frontend_type>select</frontend_type>
2283
+ <source_model>chronorelais/config_source_printMode</source_model>
2284
+ <sort_order>10</sort_order>
2285
+ <show_in_default>1</show_in_default>
2286
+ <show_in_website>1</show_in_website>
2287
+ <show_in_store>1</show_in_store>
2288
+ <required>1</required>
2289
+ </mode>
2290
+ </fields>
2291
+ </skybillparam>
2292
+
2293
+ <weightunit translate="label">
2294
+ <label>Weight unit for the store</label>
2295
+ <frontend_type>text</frontend_type>
2296
+ <sort_order>70</sort_order>
2297
+ <show_in_default>1</show_in_default>
2298
+ <show_in_website>1</show_in_website>
2299
+ <show_in_store>1</show_in_store>
2300
+ <fields>
2301
+ <unit translate="label">
2302
+ <label>Weight unit</label>
2303
+ <frontend_type>select</frontend_type>
2304
+ <source_model>chronorelais/config_source_weightUnit</source_model>
2305
+ <sort_order>10</sort_order>
2306
+ <show_in_default>1</show_in_default>
2307
+ <show_in_website>1</show_in_website>
2308
+ <show_in_store>1</show_in_store>
2309
+ <required>1</required>
2310
+ </unit>
2311
+ </fields>
2312
+ </weightunit>
2313
+
2314
+ <optionbal translate="label">
2315
+ <label>Option BAL</label>
2316
+ <frontend_type>text</frontend_type>
2317
+ <sort_order>80</sort_order>
2318
+ <show_in_default>1</show_in_default>
2319
+ <show_in_website>1</show_in_website>
2320
+ <show_in_store>1</show_in_store>
2321
+ <fields>
2322
+ <enabled translate="label">
2323
+ <label>Activer l'option BAL de Chronopost</label>
2324
+ <frontend_type>select</frontend_type>
2325
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2326
+ <comment>Vérifiez que cette option figure dans votre contrat</comment>
2327
+ <sort_order>10</sort_order>
2328
+ <show_in_default>1</show_in_default>
2329
+ <show_in_website>1</show_in_website>
2330
+ <show_in_store>1</show_in_store>
2331
+ <required>1</required>
2332
+ </enabled>
2333
+ </fields>
2334
+ </optionbal>
2335
+
2336
+ <assurance translate="label">
2337
+ <label>Assurance Ad Valorem</label>
2338
+ <frontend_type>text</frontend_type>
2339
+ <frontend_model>chronorelais/adminhtml_system_config_form_fieldsetassurance</frontend_model>
2340
+ <sort_order>90</sort_order>
2341
+ <show_in_default>1</show_in_default>
2342
+ <show_in_website>1</show_in_website>
2343
+ <show_in_store>1</show_in_store>
2344
+ <fields>
2345
+ <enabled translate="label">
2346
+ <label>Activer l'Ad Valorem</label>
2347
+ <frontend_type>select</frontend_type>
2348
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2349
+ <sort_order>1</sort_order>
2350
+ <show_in_default>1</show_in_default>
2351
+ <show_in_website>1</show_in_website>
2352
+ <show_in_store>1</show_in_store>
2353
+ <required>1</required>
2354
+ </enabled>
2355
+ <amount translate="label">
2356
+ <label>Montant minimum à assurer</label>
2357
+ <frontend_type>text</frontend_type>
2358
+ <sort_order>2</sort_order>
2359
+ <show_in_default>1</show_in_default>
2360
+ <show_in_website>1</show_in_website>
2361
+ <show_in_store>1</show_in_store>
2362
+ <required>0</required>
2363
+ <validate>validate-number</validate>
2364
+ </amount>
2365
+ </fields>
2366
+ </assurance>
2367
+
2368
+ <conflicts translate="label">
2369
+ <label>Vérificateur de conflits</label>
2370
+ <frontend_type>text</frontend_type>
2371
+ <frontend_model>chronorelais/adminhtml_system_config_form_fieldsetconflicts</frontend_model>
2372
+ <sort_order>100</sort_order>
2373
+ <show_in_default>1</show_in_default>
2374
+ <show_in_website>1</show_in_website>
2375
+ <show_in_store>1</show_in_store>
2376
+ <comment>
2377
+ <![CDATA[
2378
+ 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 />
2379
+ 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).
2380
+ ]]>
2381
+ </comment>
2382
+ <!--<fields>
2383
+ <conflicts translate="label">
2384
+ <label>Mot de passe Chronopost</label>
2385
+ <frontend_type>text</frontend_type>
2386
+ <button_label>Vérifier mes identifiants</button_label>
2387
+ <frontend_model>chronorelais/adminhtml_system_config_checklogin</frontend_model>
2388
+ <sort_order>9</sort_order>
2389
+ <show_in_default>1</show_in_default>
2390
+ <show_in_website>1</show_in_website>
2391
+ <show_in_store>1</show_in_store>
2392
+ </conflicts>
2393
+ </fields>-->
2394
+ </conflicts>
2395
+
2396
+ <saturday translate="label">
2397
+ <label>Option samedi</label>
2398
+ <frontend_type>text</frontend_type>
2399
+ <sort_order>110</sort_order>
2400
+ <show_in_default>1</show_in_default>
2401
+ <show_in_website>0</show_in_website>
2402
+ <show_in_store>0</show_in_store>
2403
+ <fields>
2404
+ <startday translate="label">
2405
+ <label>Option samedi activé du</label>
2406
+ <frontend_type>select</frontend_type>
2407
+ <frontend_model>chronorelais/adminhtml_form_renderer_config_date</frontend_model>
2408
+ <backend_model>chronorelais/config_backend_date</backend_model>
2409
+ <sort_order>1</sort_order>
2410
+ <show_in_default>1</show_in_default>
2411
+ <show_in_website>0</show_in_website>
2412
+ <show_in_store>0</show_in_store>
2413
+ <required>0</required>
2414
+ </startday>
2415
+ <endday translate="label">
2416
+ <label>Au</label>
2417
+ <frontend_type>select</frontend_type>
2418
+ <frontend_model>chronorelais/adminhtml_form_renderer_config_date</frontend_model>
2419
+ <backend_model>chronorelais/config_backend_date</backend_model>
2420
+ <sort_order>2</sort_order>
2421
+ <show_in_default>1</show_in_default>
2422
+ <show_in_website>0</show_in_website>
2423
+ <show_in_store>0</show_in_store>
2424
+ <required>0</required>
2425
+ </endday>
2426
+ </fields>
2427
+ </saturday>
2428
+
2429
+ </groups>
2430
+ </chronorelais>
2431
+ </sections>
2432
+
2433
+ </config>
app/code/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php CHANGED
@@ -1,1368 +1,1465 @@
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
+
95
+ public function printDebug() {
96
+ if ($this->debug > 0) {
97
+ $index = static::$DEBUG_INDEX_COUNTER;
98
+ static::$DEBUG_INDEX_COUNTER++;
99
+ echo "<style rel=\"stylesheet\" type=\"text/css\">"
100
+ . ".osh-formula{color:#f90;} .osh-key{color:#0099f7;}"
101
+ . ".osh-error{color:#f00;} .osh-warning{color:#ff0;} .osh-info{color:#7bf700;}"
102
+ . ".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;}"
103
+ . ".osh-debug-content{padding:10px;}"
104
+ . ".osh-replacement{color:#ff3000;}"
105
+ . "</style>"
106
+ . "<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>"
107
+ . "<p>" . $this->debug_header . "</p>" . $this->debug_output . "</pre></div>";
108
+ }
109
+ }
110
+
111
+ public function setDebugHeader($process) {
112
+ $header = 'DEBUG app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronorelaisShippingHelper.php<br/>';
113
+ foreach ($process['data'] as $key => $data) {
114
+ $header .= ' <span class="osh-key">' . $key . '</span> = <span class="osh-formula">' . $this->_toString($data) . '</span><br/>';
115
+ }
116
+ $this->debug_header = $header;
117
+ }
118
+
119
+ public function getConfig() {
120
+ return $this->_config;
121
+ }
122
+
123
+ public function getMessages() {
124
+ $messages = $this->_messages;
125
+ $this->_messages = array();
126
+ return $messages;
127
+ }
128
+
129
+ public function formatConfig($compress) {
130
+ $output = '';
131
+ foreach ($this->_config as $row) {
132
+ if (!isset($row['lines'])) {
133
+ if (isset($row['*comment']['value'])) {
134
+ $output .= trim($row['*comment']['value']) . "\n";
135
+ }
136
+ $output .= '{' . ($compress ? '' : "\n");
137
+ foreach ($row as $key => $property) {
138
+ if (substr($key, 0, 1) != '*') {
139
+ $value = $property['value'];
140
+ if (isset($property['comment'])) {
141
+ $output .= ($compress ? '' : "\t") . '/* ' . $property['comment'] . ' */' . ($compress ? '' : "\n");
142
+ }
143
+ $output .= ($compress ? '' : "\t") . $key . ':' . ($compress ? '' : ' ');
144
+ if (is_bool($value)) {
145
+ $output .= $value ? 'true' : 'false';
146
+ } else if (is_int($value)) {
147
+ $output .= $value;
148
+ } else if ((string) ((float) $value) == $value) {
149
+ $output .= $value;
150
+ } else {
151
+ $output .= '"' . str_replace('"', '\\"', $value) . '"';
152
+ }
153
+ $output .= ',' . ($compress ? '' : "\n");
154
+ }
155
+ }
156
+ if ($compress) {
157
+ $output = preg_replace('/,$/', '', $output);
158
+ }
159
+ $output .= "}\n" . ($compress ? '' : "\n");
160
+ } else {
161
+ $output .= $row['lines'] . "\n";
162
+ }
163
+ }
164
+ return $compress ? $this->compress($output) : $this->uncompress($output);
165
+ }
166
+
167
+ public function checkConfig() {
168
+ $process = array(
169
+ 'result' => null,
170
+ 'data' => array(
171
+ 'cart.price_excluding_tax' => 0,
172
+ 'cart.price_including_tax' => 0,
173
+ 'destination.country.code' => '',
174
+ 'destination.country.name' => '',
175
+ 'destination.region.code' => '',
176
+ 'destination.postcode' => '',
177
+ 'origin.country.code' => '',
178
+ 'origin.country.name' => '',
179
+ 'origin.region.code' => '',
180
+ 'origin.postcode' => '',
181
+ 'free_shipping' => false,
182
+ 'customer.group.id' => '',
183
+ 'customer.group.code' => '',
184
+ 'cart.weight' => 0,
185
+ 'cart.weight.unit' => 'kg',
186
+ 'cart.quantity' => 0,
187
+ ),
188
+ 'cart.items' => array(),
189
+ 'products' => array(),
190
+ 'config' => $this->_config,
191
+ );
192
+ foreach ($this->_config as &$row) {
193
+ $this->processRow($process, $row, $check_all_conditions = true);
194
+ foreach ($row as $property_key => $property_value) {
195
+ if (substr($property_key, 0, 1) != '*') {
196
+ $this->getRowProperty($row, $property_key);
197
+ }
198
+ }
199
+ }
200
+ }
201
+
202
+ public function processRow($process, &$row, $is_checking = false) {
203
+ if (!isset($row['*code']) || !isset($process['data']['carrier.code'])) {
204
+ return;
205
+ }
206
+
207
+ self::debug('process row <span class="osh-key">' . $row['*code'] . '</span>', 1);
208
+ if (!isset($row['label']['value'])) {
209
+ $row['label']['value'] = '***';
210
+ }
211
+
212
+ $enabled = $this->getRowProperty($row, 'enabled');
213
+ if (isset($enabled) && !$is_checking && !$enabled) {
214
+ $this->addMessage('info', $row, 'enabled', 'Configuration disabled');
215
+ return new OCS_Result(false);
216
+ }
217
+
218
+ $conditions = $this->getRowProperty($row, 'conditions');
219
+ if (isset($conditions)) {
220
+ $result = $this->_processFormula($process, $row, 'conditions', $conditions, $is_checking);
221
+ if (!$is_checking) {
222
+ if (!$result->success) {
223
+ return $result;
224
+ }
225
+ if (!$result->result) {
226
+ $this->addMessage('info', $row, 'conditions', "The cart doesn't match conditions");
227
+ return new OCS_Result(false);
228
+ }
229
+ }
230
+ }
231
+
232
+ $destination = $this->getRowProperty($row, 'destination');
233
+ if (isset($destination)) {
234
+ $destination_match = $this->_addressMatch($destination, array(
235
+ 'country_code' => $process['data']['destination.country.code'],
236
+ 'region_code' => $process['data']['destination.region.code'],
237
+ 'postcode' => $process['data']['destination.postcode']
238
+ ));
239
+ if (!$is_checking && !$destination_match) {
240
+ $this->addMessage('info', $row, 'destination', "The shipping method doesn't cover the zone");
241
+ return new OCS_Result(false);
242
+ }
243
+ }
244
+
245
+ $origin = $this->getRowProperty($row, 'origin');
246
+ if (isset($origin)) {
247
+ $origin_match = $this->_addressMatch($origin, array(
248
+ 'country_code' => $process['data']['origin.country.code'],
249
+ 'region_code' => $process['data']['origin.region.code'],
250
+ 'postcode' => $process['data']['origin.postcode']
251
+ ));
252
+ if (!$is_checking && !$origin_match) {
253
+ $this->addMessage('info', $row, 'origin', "The shipping method doesn't match to shipping origin");
254
+ return new OCS_Result(false);
255
+ }
256
+ }
257
+
258
+ $customer_groups = $this->getRowProperty($row, 'customer_groups');
259
+ if (isset($customer_groups)) {
260
+ $groups = explode(',', $customer_groups);
261
+ $group_match = false;
262
+ foreach ($groups as $group) {
263
+ $group = trim($group);
264
+ if ($group == $process['data']['customer.group.code'] || is_int($group) && $group == $process['data']['customer.group.id'] || $group == '*') {
265
+ $group_match = true;
266
+ break;
267
+ }
268
+ }
269
+ if (!$is_checking && !$group_match) {
270
+ $this->addMessage('info', $row, 'customer_groups', "The shipping method doesn't match to customer group (%s)", $process['data']['customer.group.code']);
271
+ return new OCS_Result(false);
272
+ }
273
+ }
274
+
275
+ $quickcost_val = false;
276
+ //Chronopost quickcost method for dynamic price if it is set enabled
277
+ $quickcost = Mage::getStoreConfig('carriers/' . $process['data']['carrier.code'] . '/quickcost');
278
+ if ($quickcost) {
279
+ if ($quickCostValues = $this->getQuickCostValue($process['data'])) {
280
+ if ($quickCostValues->errorCode == 0) {
281
+ $quickcost_val = (float) $quickCostValues->amountTTC;
282
+
283
+ /* Ajout marge au quickcost */
284
+ if($quickcost_val !== false) {
285
+ $quickcost_val = Mage::helper('chronorelais')->addMargeToQuickcost($quickcost_val,$process['data']['carrier.code']);
286
+ return new OCS_Result(true, (float) $quickcost_val);
287
+ }
288
+
289
+ } else {
290
+ $this->addMessage('error', $row, 'chronopost', $quickCostValues->errorMessage);
291
+ }
292
+ } else { /* if false => WS inaccessible donc on prend les prix de la grille */
293
+
294
+ }
295
+ }
296
+
297
+ /* Prix via la grille du BO */
298
+ if($quickcost_val === false) {
299
+ $fees = $this->getRowProperty($row, 'fees');
300
+ if (isset($fees)) {
301
+ $result = $this->_processFormula($process, $row, 'fees', $fees, $is_checking);
302
+ if (!$result->success) {
303
+ return $result;
304
+ }
305
+ self::debug(' => <span class="osh-info">result = <span class="osh-formula">' . $this->_toString($result->result) . '</span>', 1);
306
+ $quickcost_val = (float) $result->result;
307
+ return new OCS_Result(true, (float) $quickcost_val);
308
+ }
309
+ }
310
+
311
+
312
+
313
+ return new OCS_Result(false);
314
+ }
315
+
316
+ public function getQuickCostValue($processData) {
317
+ $quickCost = array();
318
+ $_helper = Mage::helper('chronorelais');
319
+ $account_number = $_helper->getConfigurationAccountNumber();
320
+ $password = $_helper->getConfigurationAccountPass();
321
+ $productCode = $_helper->getChronoProductCode($processData['destination.country.code'], $processData['carrier.code']);
322
+ $origin_postcode = $_helper->getConfigurationShipperInfo('zipcode');
323
+
324
+ //to get arrival code
325
+ $arrCode = $processData['destination.postcode'];
326
+ if ($processData['carrier.code'] == 'chronoexpress' || $processData['carrier.code'] == 'chronopostcclassic') {
327
+ $arrCode = $processData['destination.country.code'];
328
+ }
329
+
330
+ $cartWeight = $processData['cart.weight'];
331
+ if ($_helper->getConfigWeightUnit() == 'g') {
332
+ $cartWeight = $cartWeight / 1000; /* conversion g => kg */
333
+ }
334
+ $quickCost = array(
335
+ 'accountNumber' => $account_number,
336
+ 'password' => $password,
337
+ 'depCode' => $origin_postcode,
338
+ 'arrCode' => $arrCode,
339
+ 'weight' => $cartWeight,
340
+ 'productCode' => $productCode,
341
+ 'type' => 'M'
342
+ );
343
+
344
+ $quickcost_url = Mage::helper('chronorelais')->getConfigData('carriers/' . $processData['carrier.code'] . '/quickcost_url');
345
+
346
+ $helperWS = Mage::helper('chronorelais/webservice');
347
+ return $helperWS->getQuickcost($quickCost,$quickcost_url);
348
+ }
349
+
350
+ public function getRowProperty(&$row, $key, $original_row = null, $original_key = null) {
351
+ $property = null;
352
+ $output = null;
353
+ if (isset($original_row) && isset($original_key) && $original_row['*code'] == $row['*code'] && $original_key == $key) {
354
+ $this->addMessage('error', $row, $key, 'Infinite loop %s', "<span class=\"code\">{" . $row['*code'] . '.' . $key . "}</span>");
355
+ return array('error' => 'Infinite loop');
356
+ }
357
+ if (isset($row[$key]['value'])) {
358
+ $property = $row[$key]['value'];
359
+ $output = $property;
360
+ 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);
361
+ preg_match_all('/{([a-z0-9_]+)\.([a-z0-9_]+)}/i', $output, $result_set, PREG_SET_ORDER);
362
+ foreach ($result_set as $result) {
363
+ list($original, $ref_code, $ref_key) = $result;
364
+ if (!in_array($ref_code, array('module', 'date', 'store', 'cart', 'product', 'selection', 'customvar'))) {
365
+ if ($ref_code == $row['code']['value'] && $ref_key == $key) {
366
+ $this->addMessage('error', $row, $key, 'Infinite loop %s', "<span class=\"code\">" . $original . "</span>");
367
+ return null;
368
+ }
369
+ if (isset($this->_config[$ref_code][$ref_key]['value'])) {
370
+ $replacement = $this->getRowProperty($this->_config[$ref_code], $ref_key, isset($original_row) ? $original_row : $row, isset($original_key) ? $original_key : $key);
371
+ if (is_array($replacement) && isset($replacement['error'])) {
372
+ return isset($original_row) ? $replacement : 'false';
373
+ }
374
+ } else {
375
+ $this->addMessage('error', $row, $key, 'Non-existent property %s', "<span class=\"code\">" . $original . "</span>");
376
+ $replacement = 'null';
377
+ }
378
+ $output = $this->replace($original, $replacement, $output);
379
+ }
380
+ }
381
+ } else {
382
+ self::debug(' get <span class="osh-key">' . $row['*code'] . '</span>.<span class="osh-key">' . $key . '</span> = <span class="osh-formula">null</span>', 5);
383
+ }
384
+ return $output;
385
+ }
386
+
387
+ protected function _toString($value) {
388
+ if (!isset($value)) {
389
+ return 'null';
390
+ } else if (is_bool($value)) {
391
+ return $value ? 'true' : 'false';
392
+ }
393
+ return $value;
394
+ }
395
+
396
+ protected function replace($from, $to, $input) {
397
+ if ($from === $to) {
398
+ return $input;
399
+ }
400
+ if (strpos($input, $from) === false) {
401
+ return $input;
402
+ }
403
+ $to = $this->_toString($to);
404
+ 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);
405
+ return str_replace($from, $to, $input);
406
+ }
407
+
408
+ protected function _min() {
409
+ $args = func_get_args();
410
+ $min = null;
411
+ foreach ($args as $arg) {
412
+ if (isset($arg) && (!isset($min) || $min > $arg)) {
413
+ $min = $arg;
414
+ }
415
+ }
416
+ return $min;
417
+ }
418
+
419
+ protected function _max() {
420
+ $args = func_get_args();
421
+ $max = null;
422
+ foreach ($args as $arg) {
423
+ if (isset($arg) && (!isset($max) || $max < $arg)) {
424
+ $max = $arg;
425
+ }
426
+ }
427
+ return $max;
428
+ }
429
+
430
+ protected function _processFormula($process, &$row, $property_key, $formula_string, $is_checking, $use_cache = true) {
431
+ $result = $this->_prepareFormula($process, $row, $property_key, $formula_string, $is_checking, $use_cache);
432
+ if (!$result->success) {
433
+ return $result;
434
+ }
435
+
436
+ $eval_result = $this->_evalFormula($result->result);
437
+ if (!isset($eval_result)) {
438
+ $this->addMessage('error', $row, $property_key, 'Invalid formula');
439
+ $result = new OCS_Result(false);
440
+ if ($use_cache) {
441
+ $this->setCache($formula_string, $result);
442
+ }
443
+ return $result;
444
+ }
445
+ self::debug(' formula evaluation = <span class="osh-formula">' . $this->_toString($eval_result) . '</span>', 10);
446
+ $result = new OCS_Result(true, $eval_result);
447
+ if ($use_cache) {
448
+ $this->setCache($formula_string, $result);
449
+ }
450
+ return $result;
451
+ }
452
+
453
+ public function evalInput($process, $row, $property_key, $input) {
454
+ $result = $this->_prepareFormula($process, $row, $property_key, $input, $is_checking = false, $use_cache = true);
455
+ return $result->success ? $result->result : $input;
456
+ }
457
+
458
+ protected function setCache($expression, $value) {
459
+ if ($value instanceof OCS_Result) {
460
+ $this->_formula_cache[$expression] = $value;
461
+ self::debug(' cache <span class="osh-replacement">' . $expression . '</span> = <span class="osh-formula">' . $this->_toString($this->_formula_cache[$expression]) . '</span>', 10);
462
+ } else {
463
+ $value = $this->_toString($value);
464
+ $this->_expression_cache[$expression] = $value;
465
+ self::debug(' cache <span class="osh-replacement">' . $expression . '</span> = <span class="osh-formula">' . $value . '</span>', 10);
466
+ }
467
+ }
468
+
469
+ protected function _prepareFormula($process, $row, $property_key, $formula_string, $is_checking, $use_cache = true) {
470
+ if ($use_cache && isset($this->_formula_cache[$formula_string])) {
471
+ $result = $this->_formula_cache[$formula_string];
472
+ self::debug(' get cached formula <span class="osh-replacement">' . $formula_string . '</span> = <span class="osh-formula">' . $this->_toString($result->result) . '</span>', 10);
473
+ return $result;
474
+ }
475
+
476
+ $formula = $formula_string;
477
+
478
+ while (preg_match("#{foreach product\.((?:attribute|option)\.(?:[a-z0-9_]+))}(.*){/foreach}#i", $formula, $result)) {
479
+ $original = $result[0];
480
+ if ($use_cache && isset($this->_expression_cache[$original])) {
481
+ $replacement = $this->_expression_cache[$original];
482
+ self::debug(' get cached expression <span class="osh-replacement">' . $original . '</span> = <span class="osh-formula">' . $replacement . '</span>', 10);
483
+ } else {
484
+ $replacement = 0;
485
+ list($filter_property_type, $filter_property_name) = explode('.', $result[1]);
486
+ $selections = array();
487
+ self::debug(' :: foreach <span class="osh-key">' . $filter_property_type . '</span>.<span class="osh-key">' . $filter_property_name . '</span>', 10);
488
+ foreach ($process['products'] as $product) {
489
+ $tmp_value = $this->_getProductProperty($product, $filter_property_type, $filter_property_name, $get_by_id = false);
490
+ 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);
491
+ $key = 'val_' . $tmp_value;
492
+ $sel = isset($selections[$key]) ? $selections[$key] : null;
493
+ $selections[$key]['products'][] = $product;
494
+ $selections[$key]['weight'] = (isset($sel['weight']) ? $sel['weight'] : 0) + $product->getAttribute('weight') * $product->getQuantity();
495
+ $selections[$key]['quantity'] = (isset($sel['quantity']) ? $sel['quantity'] : 0) + $product->getQuantity();
496
+ }
497
+ self::debug(' :: start foreach', 10);
498
+ foreach ($selections as $selection) {
499
+ $process2 = $process;
500
+ $process2['products'] = $selection['products'];
501
+ $process2['data']['selection.quantity'] = $selection['quantity'];
502
+ $process2['data']['selection.weight'] = $selection['weight'];
503
+ $process_result = $this->_processFormula($process2, $row, $property_key, $result[2], $is_checking, $tmp_use_cache = false);
504
+ $replacement += $process_result->result;
505
+ }
506
+ self::debug(' :: end foreach <span class="osh-key">' . $filter_property_type . '</span>.<span class="osh-key">' . $filter_property_name . '</span>', 10);
507
+ if ($use_cache) {
508
+ $this->setCache($original, $replacement);
509
+ }
510
+ }
511
+ $formula = $this->replace($original, $replacement, $formula);
512
+ }
513
+
514
+ $formula = str_replace(array("\n", "\t"), array('', ''), $formula);
515
+
516
+ while (preg_match("#{customvar\.([a-z0-9_]+)}#i", $formula, $result)) {
517
+ $original = $result[0];
518
+ $replacement = Mage::getModel('core/variable')->loadByCode($result[1])->getValue('plain');
519
+ $formula = $this->replace($original, $replacement, $formula);
520
+ }
521
+
522
+ $first_product = isset($process['products'][0]) ? $process['products'][0] : null;
523
+ if (!isset($process['data']['selection.weight'])) {
524
+ $process['data']['selection.weight'] = $process['data']['cart.weight'];
525
+ }
526
+ if (!isset($process['data']['selection.quantity'])) {
527
+ $process['data']['selection.quantity'] = $process['data']['cart.quantity'];
528
+ }
529
+ $process['data']['product.weight'] = isset($first_product) ? $first_product->getAttribute('weight') : 0;
530
+ $process['data']['product.quantity'] = isset($first_product) ? $first_product->getQuantity() : 0;
531
+
532
+ foreach ($process['data'] as $original => $replacement) {
533
+ $formula = $this->replace('{' . $original . '}', $replacement, $formula);
534
+ }
535
+
536
+ if (isset($first_product)) {
537
+ while (preg_match("#{product\.(attribute|option|stock)\.([a-z0-9_]+)}#i", $formula, $result)) {
538
+ $original = $result[0];
539
+ switch ($result[1]) {
540
+ case 'attribute': $replacement = $first_product->getAttribute($result[2]);
541
+ break;
542
+ case 'option': $replacement = $first_product->getOption($result[2]);
543
+ break;
544
+ case 'stock': $replacement = $first_product->getStockData($result[2]);
545
+ break;
546
+ }
547
+ $formula = $this->replace($original, $replacement, $formula);
548
+ }
549
+ }
550
+
551
+ while (preg_match("/{(count) products(?: where ([^}]+))?}/i", $formula, $result) || preg_match("/{(sum|count distinct) product\.(attribute|option)\.([a-z0-9_]+)(?: where ([^}]+))?}/i", $formula, $result)) {
552
+ $original = $result[0];
553
+ if ($use_cache && isset($this->_expression_cache[$original])) {
554
+ $replacement = $this->_expression_cache[$original];
555
+ self::debug(' get cached expression <span class="osh-replacement">' . $original . '</span> = <span class="osh-formula">' . $replacement . '</span>', 10);
556
+ } else {
557
+ $replacement = $this->_processProductProperty($process['products'], $result);
558
+ if ($use_cache) {
559
+ $this->setCache($result[0], $replacement);
560
+ }
561
+ }
562
+ $formula = $this->replace($original, $replacement, $formula);
563
+ }
564
+
565
+ while (preg_match("/{table ([^}]+) in ([0-9\.:,\*\[\] ]+)}/i", $formula, $result)) {
566
+ $original = $result[0];
567
+ if ($use_cache && isset($this->_expression_cache[$original])) {
568
+ $replacement = $this->_expression_cache[$original];
569
+ self::debug(' get cached expression <span class="osh-replacement">' . $original . '</span> = <span class="osh-formula">' . $replacement . '</span>', 10);
570
+ } else {
571
+ $reference_value = $this->_evalFormula($result[1]);
572
+ if (isset($reference_value)) {
573
+ $fees_table_string = $result[2];
574
+
575
+ if (!preg_match('#^' . self::$COUPLE_REGEX . '(?:, *' . self::$COUPLE_REGEX . ')*$#', $fees_table_string)) {
576
+ $this->addMessage('error', $row, $property_key, 'Error in table %s', '<span class="osh-formula">' . htmlentities($result[0]) . '</span>');
577
+ $result = new OCS_Result(false);
578
+ if ($use_cache) {
579
+ $this->setCache($formula_string, $result);
580
+ }
581
+ return $result;
582
+ }
583
+ $fees_table = explode(',', $fees_table_string);
584
+
585
+ $replacement = null;
586
+ foreach ($fees_table as $item) {
587
+ $fee_data = explode(':', $item);
588
+
589
+ $fee = trim($fee_data[1]);
590
+ $max_value = trim($fee_data[0]);
591
+
592
+ $last_char = $max_value{strlen($max_value) - 1};
593
+ if ($last_char == '[') {
594
+ $including_max_value = false;
595
+ } else if ($last_char == ']') {
596
+ $including_max_value = true;
597
+ } else {
598
+ $including_max_value = true;
599
+ }
600
+
601
+ $max_value = str_replace(array('[', ']'), '', $max_value);
602
+
603
+ if ($max_value == '*' || $including_max_value && $reference_value <= $max_value || !$including_max_value && $reference_value < $max_value) {
604
+ $replacement = $fee;
605
+ break;
606
+ }
607
+ }
608
+ }
609
+ $replacement = $this->_toString($replacement);
610
+ if ($use_cache) {
611
+ $this->setCache($original, $replacement);
612
+ }
613
+ }
614
+ $formula = $this->replace($original, $replacement, $formula);
615
+ }
616
+ $result = new OCS_Result(true, $formula);
617
+ return $result;
618
+ }
619
+
620
+ protected function _evalFormula($formula) {
621
+ if (is_bool($formula)) {
622
+ return $formula;
623
+ }
624
+ 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'
625
+ . '|in_array\(\'(?:[^\']*)\', *array\( *(?:\'(?:[^\']+)\') *(?: *, *\'(?:[^\']+)\')* *\) *\)'
626
+ . '|\'[^\']*\'|[0-9,\'\.\-\(\)\*\/\?\:\+\<\>\=\&\|%! ])*$/', $formula)) {
627
+ $errors = array(
628
+ PREG_NO_ERROR => 'PREG_NO_ERROR',
629
+ PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR',
630
+ PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR',
631
+ PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR',
632
+ PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR',
633
+ PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR',
634
+ );
635
+ $error = preg_last_error();
636
+ if (isset($errors[$error])) {
637
+ $error = $errors[$error];
638
+ }
639
+ self::debug(' doesn\'t match (' . $error . ')', 10);
640
+ return null;
641
+ }
642
+ $formula = str_replace(
643
+ array('min', 'max'), array('$this->_min', '$this->_max'), $formula
644
+ );
645
+ $eval_result = null;
646
+ @eval('$eval_result = (' . $formula . ');');
647
+ return $eval_result;
648
+ }
649
+
650
+ protected function _getOptionsAndData($string) {
651
+ if (preg_match('/^(\\s*\(\\s*([^\] ]*)\\s*\)\\s*)/', $string, $result)) {
652
+ $options = $result[2];
653
+ $data = str_replace($result[1], '', $string);
654
+ } else {
655
+ $options = '';
656
+ $data = $string;
657
+ }
658
+ return array(
659
+ 'options' => $options,
660
+ 'data' => $data,
661
+ );
662
+ }
663
+
664
+ public function compress($input) {
665
+ if (preg_match_all("/{table (.*) in (" . self::$COUPLE_REGEX . "(?:, *" . self::$COUPLE_REGEX . ")*)}/imsU", $input, $result, PREG_SET_ORDER)) {
666
+ foreach ($result as $result_i) {
667
+ $fees_table = explode(',', $result_i[2]);
668
+ foreach ($fees_table as $index => $item) {
669
+ list($max_value, $fee) = explode(':', $item);
670
+ $last_char = $max_value{strlen($max_value) - 1};
671
+ if (in_array($last_char, array('[', ']'))) {
672
+ $including_char = $last_char;
673
+ $max_value = str_replace(array('[', ']'), '', $max_value);
674
+ }
675
+ else {
676
+ $including_char = '';
677
+ }
678
+ $fees_table[$index] = ((float) $max_value) . $including_char . ':' . ((float) $fee);
679
+ }
680
+ $input = str_replace($result_i[2], implode(',', $fees_table), $input);
681
+ $input = str_replace($result_i[1], trim($result_i[1]), $input);
682
+ }
683
+ }
684
+ if (preg_match_all("#{foreach ([^}]*)}(.*){/foreach}#imsU", $input, $result, PREG_SET_ORDER)) {
685
+ foreach ($result as $result_i) {
686
+ $input = str_replace($result_i[1], trim($result_i[1]), $input);
687
+ $input = str_replace($result_i[2], trim($result_i[2]), $input);
688
+ }
689
+ }
690
+ return '$$' . str_replace(
691
+ self::$UNCOMPRESSED_STRINGS, self::$COMPRESSED_STRINGS, $input
692
+ );
693
+ }
694
+
695
+ public function uncompress($input) {
696
+ if (preg_match_all("/{table (.*) in (" . self::$COUPLE_REGEX . "(?:, *" . self::$COUPLE_REGEX . ")*)}/iU", $input, $result, PREG_SET_ORDER)) {
697
+ foreach ($result as $result_i) {
698
+ $fees_table = explode(',', $result_i[2]);
699
+ foreach ($fees_table as $index => $item) {
700
+ list($max_value, $fee) = explode(':', $item);
701
+ $last_char = $max_value{strlen($max_value) - 1};
702
+ if (in_array($last_char, array('[', ']'))) {
703
+ $including_char = $last_char;
704
+ $max_value = str_replace(array('[', ']'), '', $max_value);
705
+ }
706
+ else {
707
+ $including_char = '';
708
+ }
709
+ $max_value = (float) $max_value;
710
+ $fee = (float) $fee;
711
+ $new_max_value = number_format($max_value, 2, '.', '');
712
+ $new_fee = number_format($fee, 2, '.', '');
713
+ $fees_table[$index] = (((float) $new_max_value) == $max_value ? $new_max_value : $max_value) . $including_char . ':'
714
+ . (((float) $new_fee) == $fee ? $new_fee : $fee);
715
+ }
716
+ $input = str_replace($result_i[2], implode(', ', $fees_table), $input);
717
+ $input = str_replace($result_i[1], trim($result_i[1]), $input);
718
+ }
719
+ }
720
+ if (preg_match_all("#{foreach ([^}]*)}(.*){/foreach}#iU", $input, $result, PREG_SET_ORDER)) {
721
+ foreach ($result as $result_i) {
722
+ $input = str_replace($result_i[1], trim($result_i[1]), $input);
723
+ $input = str_replace($result_i[2], trim($result_i[2]), $input);
724
+ }
725
+ }
726
+ return str_replace(
727
+ self::$COMPRESSED_STRINGS, self::$UNCOMPRESSED_STRINGS, $input
728
+ );
729
+ }
730
+
731
+ public function parseProperty($input) {
732
+ $value = $input === 'false' || $input === 'true' ? $input == 'true' : str_replace('\"', '"', preg_replace('/^(?:"|\')(.*)(?:"|\')$/s', '$1', $input));
733
+ return $value === '' ? null : $value;
734
+ }
735
+
736
+ public function cleanProperty(&$row, $key) {
737
+ $input = $row[$key]['value'];
738
+ if (is_string($input)) {
739
+ $input = str_replace(array("\n"), array(''), $input);
740
+ while (preg_match('/({TABLE |{SUM |{COUNT | DISTINCT | IN )/', $input, $resi)) {
741
+ $input = str_replace($resi[0], strtolower($resi[0]), $input);
742
+ }
743
+
744
+ while (preg_match('/{{customVar code=([a-zA-Z0-9_-]+)}}/', $input, $resi)) {
745
+ $input = str_replace($resi[0], '{customvar.' . $resi[1] . '}', $input);
746
+ }
747
+
748
+ $regex = "{(weight|products_quantity|price_including_tax|price_excluding_tax|country)}";
749
+ if (preg_match('/' . $regex . '/', $input, $resi)) {
750
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
751
+ while (preg_match('/' . $regex . '/', $input, $resi)) {
752
+ switch ($resi[1]) {
753
+ case 'price_including_tax':
754
+ case 'price_excluding_tax':
755
+ case 'weight':
756
+ $input = str_replace($resi[0], "{cart." . $resi[1] . "}", $input);
757
+ break;
758
+ case 'products_quantity': $input = str_replace($resi[0], "{cart.quantity}", $input);
759
+ break;
760
+ case 'country': $input = str_replace($resi[0], "{destination.country.name}", $input);
761
+ break;
762
+ default:
763
+ break;
764
+ }
765
+ }
766
+ }
767
+
768
+ $regex1 = "{copy '([a-zA-Z0-9_]+)'\.'([a-zA-Z0-9_]+)'}";
769
+ if (preg_match('/' . $regex1 . '/', $input, $resi)) {
770
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
771
+ while (preg_match('/' . $regex1 . '/', $input, $resi)) {
772
+ $input = str_replace($resi[0], '{' . $resi[1] . '.' . $resi[2] . '}', $input);
773
+ }
774
+ }
775
+
776
+ $regex1 = "{(count|all|any) (attribute|option) '([^'\)]+)' ?((?:==|<=|>=|<|>|!=) ?(?:" . self::$FLOAT_REGEX . "|true|false|'[^'\)]*'))}";
777
+ $regex2 = "{(sum) (attribute|option) '([^'\)]+)'}";
778
+ if (preg_match('/' . $regex1 . '/', $input, $resi) || preg_match('/' . $regex2 . '/', $input, $resi)) {
779
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
780
+ while (preg_match('/' . $regex1 . '/', $input, $resi) || preg_match('/' . $regex2 . '/', $input, $resi)) {
781
+ switch ($resi[1]) {
782
+ case 'count': $input = str_replace($resi[0], "{count products where product." . $resi[2] . "s." . $resi[3] . $resi[4] . "}", $input);
783
+ break;
784
+ case 'all': $input = str_replace($resi[0], "{count products where product." . $resi[2] . "s." . $resi[3] . $resi[4] . "}=={products_quantity}", $input);
785
+ break;
786
+ case 'any': $input = str_replace($resi[0], "{count products where product." . $resi[2] . "s." . $resi[3] . $resi[4] . "}>0", $input);
787
+ break;
788
+ case 'sum': $input = str_replace($resi[0], "{sum product." . $resi[2] . "." . $resi[3] . "}", $input);
789
+ break;
790
+ default :
791
+ break;
792
+ }
793
+ }
794
+ }
795
+
796
+ $regex = "((?:{| )product.(?:attribute|option))s.";
797
+ if (preg_match('/' . $regex . '/', $input, $resi)) {
798
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
799
+ while (preg_match('/' . $regex . '/', $input, $resi)) {
800
+ $input = str_replace($resi[0], $resi[1] . '.', $input);
801
+ }
802
+ }
803
+
804
+ $regex = "{table '([^']+)' (" . self::$COUPLE_REGEX . "(?:, *" . self::$COUPLE_REGEX . ")*)}";
805
+ if (preg_match('/' . $regex . '/', $input, $resi)) {
806
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
807
+ while (preg_match('/' . $regex . '/', $input, $resi)) {
808
+ switch ($resi[1]) {
809
+ case 'products_quantity':
810
+ $input = str_replace($resi[0], "{table {cart.weight} in " . $resi[2] . "}*{cart.quantity}", $input);
811
+ break;
812
+ default:
813
+ $input = str_replace($resi[0], "{table {cart." . $resi[1] . "} in " . $resi[2] . "}", $input);
814
+ break;
815
+ }
816
+ }
817
+ }
818
+ }
819
+ $row[$key]['value'] = $input;
820
+ }
821
+
822
+ protected function _parseInput() {
823
+ $config_string = str_replace(
824
+ array('&gt;', '&lt;', '“', '”', utf8_encode(chr(147)), utf8_encode(chr(148)), '&laquo;', '&raquo;', "\r\n", "\t"), array('>', '<', '"', '"', '"', '"', '"', '"', "\n", ' '), $this->_input
825
+ );
826
+
827
+ if (substr($config_string, 0, 2) == '$$') {
828
+ $config_string = $this->uncompress(substr($config_string, 2, strlen($config_string)));
829
+ }
830
+
831
+ $row_regex = ' *([a-z0-9_]+)\\s*:\\s*("(?:(?:[^"]|\\\\")*[^\\\\])?"|' . self::$FLOAT_REGEX . '|false|true)\\s*(,)? *(?:\\n)?';
832
+ if (!preg_match_all('/((?:#+[^{\\n]*\\s+)*)\\s*(#)?{\\s*(' . $row_regex . ')+\\s*}/i', $config_string, $result, PREG_SET_ORDER)) {
833
+ $errors = array(
834
+ PREG_NO_ERROR => 'PREG_NO_ERROR',
835
+ PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR',
836
+ PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR',
837
+ PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR',
838
+ PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR',
839
+ PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR',
840
+ );
841
+ $error = preg_last_error();
842
+ if (isset($errors[$error])) {
843
+ $error = $errors[$error];
844
+ }
845
+ self::debug(' preg_match_all error (' . $error . ')', 10);
846
+ }
847
+
848
+ $this->_config = array();
849
+ $available_keys = array(
850
+ 'code', 'label', 'enabled', 'description', 'fees', 'conditions', 'destination', 'origin', 'customer_groups', 'tracking_url',
851
+ 'fees_table', 'fees_formula', 'fixed_fees', 'reference_value',
852
+ 'prices_range', 'weights_range', 'product_properties',
853
+ 'free_shipping__fees_table', 'free_shipping__fees_formula', 'free_shipping__fixed_fees', 'free_shipping__label',
854
+ );
855
+
856
+ foreach ($result as $block) {
857
+ $deprecated_properties = array();
858
+ $unknown_properties = array();
859
+ $missing_semicolon = array();
860
+ $obsolete_disabling_method = array();
861
+
862
+ //$before = strstr($config_string,$block[0],true); // Seulement compatible avec PHP 5.3.0
863
+ list($before) = explode($block[0], $config_string, 2);
864
+ if ($before !== false && trim($before) != '') {
865
+ $config_string = substr($config_string, strlen($before));
866
+ $this->_addIgnoredLines(trim($before));
867
+ $this->addMessage('info', $row = null, null, 'Ignored lines %s', '<div class="code">' . trim($before) . '</div>');
868
+ }
869
+
870
+ $config_string = str_replace($block[0], '', $config_string);
871
+ preg_match_all('/' . $row_regex . '/i', $block[0], $result2, PREG_SET_ORDER);
872
+ $block_string = $block[0];
873
+
874
+ $row = array();
875
+ $i = 1;
876
+ foreach ($result2 as $data) {
877
+ $key = $data[1];
878
+ if (in_array($key, $available_keys) || substr($key, 0, 1) == '_') {
879
+ $property = $this->parseProperty($data[2]);
880
+ if (isset($property)) {
881
+ $row[$key] = array('value' => $property, 'original_value' => $property);
882
+ $this->cleanProperty($row, $key);
883
+ }
884
+ if ($i > 2) {
885
+ $block_string = str_replace($data[0], $i == 3 ? "...\n" : '', $block_string);
886
+ }
887
+ if ($i != count($result2) && !isset($data[3]) || isset($data[3]) && $data[3] != ',') {
888
+ if (preg_match('/^("|\')(.{40})(.*)("|\')$/s', $data[2], $resultx)) {
889
+ $missing_semicolon[] = trim(str_replace($data[2], $resultx[1] . $resultx[2] . ' ...' . $resultx[4], $data[0]));
890
+ } else {
891
+ $missing_semicolon[] = trim($data[0]);
892
+ }
893
+ }
894
+ } else {
895
+ if (!in_array($key, $unknown_properties)) {
896
+ $unknown_properties[] = $key;
897
+ }
898
+ }
899
+ $i++;
900
+ }
901
+ if ($block[1] != '') {
902
+ $row['*comment']['value'] = $block[1];
903
+ }
904
+ if ($block[2] == '#' && !isset($row['enabled'])) {
905
+ $row['enabled'] = array('value' => false);
906
+ $obsolete_disabling_method[] = $block_string;
907
+ }
908
+
909
+ $formula_fields_to_check = array();
910
+ if (isset($row['conditions'])) {
911
+ $formula_fields_to_check[] = 'conditions';
912
+ }
913
+ if (isset($row['fees'])) {
914
+ $formula_fields_to_check[] = 'fees';
915
+ }
916
+
917
+ if (count($formula_fields_to_check) > 0) {
918
+ foreach ($formula_fields_to_check as $property) {
919
+ $property_value = $row[$property]['value'];
920
+ if (preg_match('/{ +/', $property_value)) {
921
+ $this->addMessage('warning', $row, $property, 'There are unwanted spaces after char `%s`', '{');
922
+ $property_value = preg_replace('/{ +/', '{', $property_value);
923
+ }
924
+ if (preg_match('/ +}/', $property_value)) {
925
+ $this->addMessage('warning', $row, $property, 'There are unwanted spaces before char `%s`', '}');
926
+ $property_value = preg_replace('/ +}/', '}', $property_value);
927
+ }
928
+ if (preg_match('/ +/', $property_value)) {
929
+ $this->addMessage('warning', $row, $property, 'There are unwanted multiples spaces `%s`', preg_replace('/( +)/', '<span class="osh-formula">*$1*</span>', $property_value));
930
+ $property_value = preg_replace('/ +/', ' ', $property_value);
931
+ }
932
+ $row[$property]['value'] = trim($property_value);
933
+ }
934
+ }
935
+
936
+ $float_value_regex = '\\s*(' . self::$POSITIVE_FLOAT_REGEX . '|\*)\\s*';
937
+ $conditions = array();
938
+ if (isset($row['prices_range'])) {
939
+ if (!in_array('prices_range', $deprecated_properties)) {
940
+ $deprecated_properties[] = 'prices_range';
941
+ }
942
+
943
+ $result = $this->_getOptionsAndData($row['prices_range']['value']);
944
+ $options = $result['options'];
945
+ $prices_range = $result['data'];
946
+
947
+ if (($options == '' || in_array($options, array('incl.tax', 'ttc'))) && preg_match('/^\\s*(\[|\])?' . $float_value_regex . '=>' . $float_value_regex . '(\[|\])?\\s*$/', $prices_range, $result)) {
948
+ $min_price_included = $result[1] == '[';
949
+ $min_price = $result[2] == '*' ? -1 : (float) $result[2];
950
+ $max_price = $result[3] == '*' ? -1 : (float) $result[3];
951
+ $max_price_included = !isset($result[4]) || $result[4] == ']' || $result[4] == '';
952
+
953
+ $tax_included = $options != '' && in_array($options, array('incl.tax', 'ttc')) || isset($row['reference_value']) && $row['reference_value']['value'] == 'price_including_tax';
954
+ $price = $tax_included ? '{cart.price_including_tax}' : '{cart.price_excluding_tax}';
955
+
956
+ if ($min_price != -1) {
957
+ $conditions[] = $price . '>' . ($min_price_included ? '=' : '') . $min_price;
958
+ }
959
+ if ($max_price != -1) {
960
+ $conditions[] = $price . '<' . ($max_price_included ? '=' : '') . $max_price;
961
+ }
962
+ }
963
+ else {
964
+ $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>');
965
+ }
966
+ unset($row['prices_range']);
967
+ }
968
+ if (isset($row['weights_range'])) {
969
+ if (!in_array('weights_range', $deprecated_properties)) {
970
+ $deprecated_properties[] = 'weights_range';
971
+ }
972
+ if (preg_match('/^\\s*(\[|\])?' . $float_value_regex . '=>' . $float_value_regex . '(\[|\])?\\s*$/', $row['weights_range']['value'], $result)) {
973
+ $min_weight_included = $result[1] == '[';
974
+ $min_weight = $result[2] == '*' ? -1 : (float) $result[2];
975
+ $max_weight = $result[3] == '*' ? -1 : (float) $result[3];
976
+ $max_weight_included = !isset($result[4]) || $result[4] == ']' || $result[4] == '';
977
+
978
+ if ($min_weight != -1) {
979
+ $conditions[] = '{cart.weight}>' . ($min_weight_included ? '=' : '') . $min_weight;
980
+ }
981
+ if ($max_weight != -1) {
982
+ $conditions[] = '{cart.weight}<' . ($max_weight_included ? '=' : '') . $max_weight;
983
+ }
984
+ }
985
+ else {
986
+ $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>');
987
+ }
988
+ unset($row['weights_range']);
989
+ }
990
+ if (isset($row['product_properties'])) {
991
+ if (!in_array('product_properties', $deprecated_properties)) {
992
+ $deprecated_properties[] = 'product_properties';
993
+ }
994
+ $product_property_regex = "\\s*(and|or)? *\((?:(all|any|sum) )?(attribute|option) '([^'\)]+)' ?(==|=|<=|>=|<|>|!=) ?(" . self::$FLOAT_REGEX . "|true|false|'[^'\)]*')\)\\s*";
995
+ if (preg_match('/^(' . $product_property_regex . ')+$/', $row['product_properties']['value'], $result)) {
996
+ preg_match_all('/' . $product_property_regex . '/', $row['product_properties']['value'], $results, PREG_SET_ORDER);
997
+ $product_properties_condition = '';
998
+ foreach ($results as $result) {
999
+ $and_or = $result[1];
1000
+ if ($and_or == '') {
1001
+ $and_or = 'and';
1002
+ }
1003
+ $any_all_sum = $result[2];
1004
+ if ($any_all_sum == '') {
1005
+ $any_all_sum = 'any';
1006
+ }
1007
+ $property_type = $result[3];
1008
+ $property_name = $result[4];
1009
+ $cmp_symbol = $result[5];
1010
+ if ($cmp_symbol == '=') {
1011
+ $cmp_symbol = '==';
1012
+ }
1013
+ $cmp_value = $result[6];
1014
+
1015
+ $product_properties_condition .= $product_properties_condition == '' ? '' : ' ' . $and_or . ' ';
1016
+ switch ($any_all_sum) {
1017
+ case 'sum':
1018
+ $product_properties_condition .= "{sum product." . $property_type . "." . $property_name . "}" . $cmp_symbol . $cmp_value;
1019
+ break;
1020
+ case 'all':
1021
+ $product_properties_condition .= "{count products where product." . $property_type . "." . $property_name . $cmp_symbol . $cmp_value . "}=={products_quantity}";
1022
+ break;
1023
+ case 'any':
1024
+ $product_properties_condition .= "{count products where product." . $property_type . "." . $property_name . $cmp_symbol . $cmp_value . "}>0";
1025
+ break;
1026
+ default :
1027
+ break;
1028
+ }
1029
+ }
1030
+ if ($product_properties_condition != '') {
1031
+ $conditions[] = $product_properties_condition;
1032
+ }
1033
+ }
1034
+ else {
1035
+ $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>');
1036
+ }
1037
+ unset($row['product_properties']);
1038
+ }
1039
+ if (count($conditions) > 0) {
1040
+ $row['conditions'] = array('value' => count($conditions) == 1 ? $conditions[0] : '(' . implode(') && (', $conditions) . ')');
1041
+ }
1042
+
1043
+ $fees = array();
1044
+ if (isset($row['fees_table'])) {
1045
+ if (!in_array('fees_table', $deprecated_properties)) {
1046
+ $deprecated_properties[] = 'fees_table';
1047
+ }
1048
+ $options_and_data = $this->_getOptionsAndData($row['fees_table']['value']);
1049
+ $options = $options_and_data['options'];
1050
+ $fees_table_string = $options_and_data['data'];
1051
+
1052
+ $var = null;
1053
+ if ($options == '') {
1054
+ $var = (isset($row['reference_value']) ? $row['reference_value']['value'] : 'weight');
1055
+ } else if (in_array($options, array('incl.tax', 'ttc'))) {
1056
+ $var = 'price_including_tax';
1057
+ } else if (in_array($options, array('excl.tax', 'ht'))) {
1058
+ $var = 'price_excluding_tax';
1059
+ }
1060
+
1061
+ if (isset($var)) {
1062
+ if ($var == 'price') {
1063
+ $var = 'price_excluding_tax';
1064
+ }
1065
+ if ($var == 'products_quantity') {
1066
+ $var = 'quantity';
1067
+ }
1068
+ if (preg_match('/^[[:space:]]*\*[[:space:]]*:[[:space:]]*(' . $float_value_regex . ')[[:space:]]*$/s', $fees_table_string, $result)) {
1069
+ $fees[] = $result[1];
1070
+ }
1071
+ else {
1072
+ $fees[] = "{table {cart." . $var . "} in " . str_replace(' ', '', $fees_table_string) . "}" . ($var == 'quantity' ? '*{cart.quantity}' : '');
1073
+ }
1074
+ }
1075
+ else {
1076
+ $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>');
1077
+ }
1078
+ unset($row['fees_table']);
1079
+ }
1080
+ if (isset($row['fees_formula'])) {
1081
+ if (!in_array('fees_formula', $deprecated_properties)) {
1082
+ $deprecated_properties[] = 'fees_formula';
1083
+ }
1084
+ $fees[] = str_replace(' ', '', $row['fees_formula']['value']);
1085
+ unset($row['fees_formula']);
1086
+ }
1087
+ if (isset($row['fixed_fees'])) {
1088
+ if (!in_array('fixed_fees', $deprecated_properties)) {
1089
+ $deprecated_properties[] = 'fixed_fees';
1090
+ }
1091
+ if ($row['fixed_fees']['value'] != 0 || count($fees) == 0) {
1092
+ $fees[] = str_replace(' ', '', $row['fixed_fees']['value']);
1093
+ }
1094
+ unset($row['fixed_fees']);
1095
+ }
1096
+ if (!isset($row['fees']) && count($fees) > 0) {
1097
+ $row['fees'] = array('value' => implode('+', $fees));
1098
+ }
1099
+
1100
+ $fs_fees = array();
1101
+ if (isset($row['free_shipping__fees_table'])) {
1102
+ if (!in_array('free_shipping__fees_table', $deprecated_properties)) {
1103
+ $deprecated_properties[] = 'free_shipping__fees_table';
1104
+ }
1105
+ $options_and_data = $this->_getOptionsAndData($row['free_shipping__fees_table']['value']);
1106
+ $options = $options_and_data['options'];
1107
+ $fees_table_string = $options_and_data['data'];
1108
+
1109
+ $var = null;
1110
+ if ($options == '') {
1111
+ $var = isset($row['reference_value']) ? $row['reference_value']['value'] : 'weight';
1112
+ } else if (in_array($options, array('incl.tax', 'ttc'))) {
1113
+ $var = 'price_including_tax';
1114
+ } else if (in_array($options, array('excl.tax', 'ht'))) {
1115
+ $var = 'price_excluding_tax';
1116
+ }
1117
+ if ($var == 'price') {
1118
+ $var = 'price_excluding_tax';
1119
+ }
1120
+
1121
+ if (isset($var)) {
1122
+ if ($var == 'price') {
1123
+ $var = 'price_excluding_tax';
1124
+ }
1125
+ if ($var == 'products_quantity') {
1126
+ $var = 'quantity';
1127
+ }
1128
+ if (preg_match('/^[[:space:]]*\*[[:space:]]*:[[:space:]]*(' . $float_value_regex . ')[[:space:]]*$/s', $fees_table_string, $result)) {
1129
+ $fs_fees[] = $result[1];
1130
+ }
1131
+ else {
1132
+ $fs_fees[] = "{table {cart." . $var . "} in " . str_replace(' ', '', $fees_table_string) . "}" . ($var == 'quantity' ? '*{cart.quantity}' : '');
1133
+ }
1134
+ }
1135
+ else {
1136
+ $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>');
1137
+ }
1138
+ unset($row['free_shipping__fees_table']);
1139
+ }
1140
+ if (isset($row['free_shipping__fees_formula'])) {
1141
+ if (!in_array('free_shipping__fees_formula', $deprecated_properties)) {
1142
+ $deprecated_properties[] = 'free_shipping__fees_formula';
1143
+ }
1144
+ $fs_fees[] = str_replace(' ', '', $row['free_shipping__fees_formula']['value']);
1145
+ unset($row['free_shipping__fees_formula']);
1146
+ }
1147
+ if (isset($row['free_shipping__fixed_fees'])) {
1148
+ if (!in_array('free_shipping__fixed_fees', $deprecated_properties)) {
1149
+ $deprecated_properties[] = 'free_shipping__fixed_fees';
1150
+ }
1151
+ if ($row['free_shipping__fixed_fees']['value'] != 0 || count($fees) == 0) {
1152
+ $fs_fees[] = str_replace(' ', '', $row['free_shipping__fixed_fees']['value']);
1153
+ }
1154
+ unset($row['free_shipping__fixed_fees']);
1155
+ }
1156
+
1157
+ if (isset($row['reference_value'])) {
1158
+ if (!in_array('reference_value', $deprecated_properties)) {
1159
+ $deprecated_properties[] = 'reference_value';
1160
+ }
1161
+ unset($row['reference_value']);
1162
+ }
1163
+
1164
+ if (count($fs_fees) > 0) {
1165
+ $row2 = $row;
1166
+ if (isset($row['code'])) {
1167
+ $row2['code']['value'] = $row['code']['value'] . '__free_shipping';
1168
+ }
1169
+ $row2['fees']['value'] = implode('+', $fs_fees);
1170
+ $row2['conditions']['value'] = isset($row2['conditions']) ? '(' . $row2['conditions'] + ') and {free_shipping}' : '{free_shipping}';
1171
+ $row['conditions']['value'] = isset($row['conditions']) ? '(' . $row['conditions'] + ') and !{free_shipping}' : '!{free_shipping}';
1172
+ if (isset($row['free_shipping__label'])) {
1173
+ if (!in_array('free_shipping__label', $deprecated_properties)) {
1174
+ $deprecated_properties[] = 'free_shipping__label';
1175
+ }
1176
+ $row2['label']['value'] = $row['free_shipping__label']['value'];
1177
+ unset($row['free_shipping__label']);
1178
+ unset($row2['free_shipping__label']);
1179
+ }
1180
+ $this->_addRow($row2);
1181
+ }
1182
+ if (count($unknown_properties) > 0) {
1183
+ $this->addMessage('error', $row, null, 'Usage of unknown properties %s', ': <span class="osh-key">' . implode('</span>, <span class="osh-key">', $unknown_properties) . '</span>');
1184
+ }
1185
+ if (count($deprecated_properties) > 0) {
1186
+ $this->addMessage('warning', $row, null, 'Usage of deprecated properties %s', ': <span class="osh-key">' . implode('</span>, <span class="osh-key">', $deprecated_properties) . '</span>');
1187
+ }
1188
+ if (count($obsolete_disabling_method) > 0) {
1189
+ $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>');
1190
+ }
1191
+ if (count($missing_semicolon) > 0) {
1192
+ $this->addMessage('warning', $row, null, 'A semicolon is missing at the end of following lines %s', '<div class="code">' . implode('<br />', $missing_semicolon) . '</div>');
1193
+ }
1194
+ $this->_addRow($row);
1195
+ }
1196
+ if (trim($config_string) != '') {
1197
+ $this->_addIgnoredLines(trim($config_string));
1198
+ $row = null;
1199
+ $this->addMessage('info', $row, null, 'Ignored lines %s', '<div class="code">' . trim($config_string) . '</div>');
1200
+ }
1201
+ }
1202
+
1203
+ public function addMessage($type, &$row, $property) {
1204
+ $args = func_get_args();
1205
+ array_shift($args);
1206
+ array_shift($args);
1207
+ array_shift($args);
1208
+ $message = new OCS_Message($type, $args);
1209
+ if (isset($row)) {
1210
+ if (isset($property)) {
1211
+ $row[$property]['messages'][] = $message;
1212
+ } else {
1213
+ $row['*messages'][] = $message;
1214
+ }
1215
+ }
1216
+ $this->_messages[] = $message;
1217
+ self::debug(' => <span class="osh-' . $message->type . '">' . $message->toString() . '</span>', 1);
1218
+ }
1219
+
1220
+ protected function _addRow(&$row) {
1221
+ if (isset($row['code'])) {
1222
+ $key = $row['code']['value'];
1223
+ if (isset($this->_config[$key])) {
1224
+ $this->addMessage('error', $row, 'code', 'The property `code` must be unique, `%s` has been found twice', $key);
1225
+ }
1226
+ while (isset($this->_config[$key])) {
1227
+ $key .= rand(0, 9);
1228
+ }
1229
+ } else {
1230
+ $i = 1;
1231
+ do {
1232
+ $key = 'code_auto' . sprintf('%03d', $i);
1233
+ $i++;
1234
+ } while (isset($this->_config[$key]));
1235
+ }
1236
+ $row['*code'] = $key;
1237
+ $this->_config[$key] = $row;
1238
+ }
1239
+
1240
+ protected function _addIgnoredLines($lines) {
1241
+ $this->_config[] = array('lines' => $lines);
1242
+ }
1243
+
1244
+ protected function _addressMatch($address_filter, $address) {
1245
+ $excluding = false;
1246
+ if (preg_match('# *\* *- *\((.*)\) *#s', $address_filter, $result)) {
1247
+ $address_filter = $result[1];
1248
+ $excluding = true;
1249
+ }
1250
+
1251
+ $tmp_address_filter_array = explode(',', trim($address_filter));
1252
+
1253
+ $concat = false;
1254
+ $concatened = '';
1255
+ $address_filter_array = array();
1256
+ $i = 0;
1257
+
1258
+ foreach ($tmp_address_filter_array as $address_filter) {
1259
+ if ($concat) {
1260
+ $concatened .= ',' . $address_filter;
1261
+ } else {
1262
+ if ($i < count($tmp_address_filter_array) - 1 && preg_match('#\(#', $address_filter)) {
1263
+ $concat = true;
1264
+ $concatened .= $address_filter;
1265
+ }
1266
+ else {
1267
+ $address_filter_array[] = $address_filter;
1268
+ }
1269
+ }
1270
+ if (preg_match('#\)#', $address_filter)) {
1271
+ $address_filter_array[] = $concatened;
1272
+ $concatened = '';
1273
+ $concat = false;
1274
+ }
1275
+ $i++;
1276
+ }
1277
+
1278
+ foreach ($address_filter_array as $address_filter) {
1279
+ if (preg_match('# *([A-Z]{2}) *(-)? *(?:\( *(-)? *(.*)\))? *#s', $address_filter, $result)) {
1280
+ $country_code = $result[1];
1281
+ if ($address['country_code'] == $country_code) {
1282
+ self::debug(' country code <span class="osh-replacement">' . $address['country_code'] . '</span> matches', 5);
1283
+ if (!isset($result[4]) || $result[4] == '') {
1284
+ return !$excluding;
1285
+ }
1286
+ else {
1287
+ $region_codes = explode(',', $result[4]);
1288
+ $in_array = false;
1289
+ for ($i = count($region_codes); --$i >= 0;) {
1290
+ $code = trim($region_codes[$i]);
1291
+ $region_codes[$i] = $code;
1292
+ if ($address['region_code'] === $code) {
1293
+ self::debug(' region code <span class="osh-replacement">' . $address['region_code'] . '</span> matches', 5);
1294
+ $in_array = true;
1295
+ } else if ($address['postcode'] === $code) {
1296
+ self::debug(' postcode <span class="osh-replacement">' . $address['postcode'] . '</span> matches', 5);
1297
+ $in_array = true;
1298
+ } else if (strpos($code, '*') !== false && preg_match('/^' . str_replace('*', '(?:.*)', $code) . '$/', $address['postcode'])) {
1299
+ self::debug(' postcode <span class="osh-replacement">' . $address['postcode'] . '</span> matches <span class="osh-formula">' . $code . '</span>', 5);
1300
+ $in_array = true;
1301
+ }
1302
+ if ($in_array) {
1303
+ break;
1304
+ }
1305
+ }
1306
+ if (!$in_array) {
1307
+ 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);
1308
+ }
1309
+ // Vérification stricte
1310
+ $excluding_region = $result[2] == '-' || $result[3] == '-';
1311
+ if ($excluding_region && !$in_array || !$excluding_region && $in_array) {
1312
+ return !$excluding;
1313
+ }
1314
+ }
1315
+ }
1316
+ }
1317
+ }
1318
+ return $excluding;
1319
+ }
1320
+
1321
+ protected function _getProductProperty($product, $property_type, $property_name, $get_by_id = false) {
1322
+ switch ($property_type) {
1323
+ case 'attribute':
1324
+ case 'attributes': return $product->getAttribute($property_name, $get_by_id);
1325
+ case 'option':
1326
+ case 'options': return $product->getOption($property_name, $get_by_id);
1327
+ case 'stock': return $product->getStockData($property_name);
1328
+ default: return null;
1329
+ }
1330
+ return null;
1331
+ }
1332
+
1333
+ protected function _processProductProperty($products, $regex_result) {
1334
+ // COUNT, SUM or COUNT DISTINCT
1335
+ $operation = strtolower($regex_result[1]);
1336
+ switch ($operation) {
1337
+ case 'sum':
1338
+ case 'count distinct':
1339
+ $property_type = $regex_result[2];
1340
+ $property_name = $regex_result[3];
1341
+ $conditions = isset($regex_result[4]) ? $regex_result[4] : null;
1342
+ break;
1343
+ case 'count':
1344
+ $conditions = isset($regex_result[2]) ? $regex_result[2] : null;
1345
+ break;
1346
+ default:
1347
+ $conditions = null;
1348
+ break;
1349
+ }
1350
+
1351
+ self::debug(' :: start <span class="osh-replacement">' . $regex_result[0] . '</span>', 10);
1352
+
1353
+ $return_value = 0;
1354
+
1355
+ preg_match_all('/product\.(attribute(?:s)?|option(?:s)?|stock)\.([a-z0-9_]+)(?:\.(id))?/i', $conditions, $properties_regex_result, PREG_SET_ORDER);
1356
+ $properties = array();
1357
+ foreach ($properties_regex_result as $property_regex_result) {
1358
+ $key = $property_regex_result[0];
1359
+ if (!isset($properties[$key])) {
1360
+ $properties[$key] = $property_regex_result;
1361
+ }
1362
+ }
1363
+
1364
+ foreach ($products as $product) {
1365
+ if (isset($conditions) && $conditions != '') {
1366
+ $formula = $conditions;
1367
+ foreach ($properties as $property) {
1368
+ $value = $this->_getProductProperty(
1369
+ $product, $tmp_property_type = $property[1], $tmp_property_name = $property[2], $get_by_id = isset($property[3]) && $property[3] == 'id'
1370
+ );
1371
+ $from = $property[0];
1372
+ $to = is_string($value) || empty($value) ? "'" . $value . "'" : $value;
1373
+ $formula = str_replace($from, $to, $formula);
1374
+ 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);
1375
+ }
1376
+ $eval_result = $this->_evalFormula($formula);
1377
+ if (!isset($eval_result)) {
1378
+ return 'null';
1379
+ }
1380
+ } else {
1381
+ $eval_result = true;
1382
+ }
1383
+
1384
+ if ($eval_result == true) {
1385
+ switch ($operation) {
1386
+ case 'sum':
1387
+ $value = $this->_getProductProperty($product, $property_type, $property_name);
1388
+ $return_value += $value * $product->getQuantity();
1389
+ break;
1390
+ case 'count distinct':
1391
+ if (!isset($distinct_values)) {
1392
+ $distinct_values = array();
1393
+ }
1394
+ $value = $this->_getProductProperty($product, $property_type, $property_name);
1395
+ if (!in_array($value, $distinct_values)) {
1396
+ $distinct_values[] = $value;
1397
+ $return_value++;
1398
+ }
1399
+ break;
1400
+ case 'count':
1401
+ $return_value += $product->getQuantity();
1402
+ break;
1403
+ default:
1404
+ break;
1405
+ }
1406
+ }
1407
+ }
1408
+
1409
+ self::debug(' :: end <span class="osh-replacement">' . $regex_result[0] . '</span>', 10);
1410
+
1411
+ return $return_value;
1412
+ }
1413
+
1414
+ }
1415
+
1416
+ interface OCS_Product {
1417
+
1418
+ public function getOption($option);
1419
+
1420
+ public function getAttribute($attribute);
1421
+
1422
+ public function getName();
1423
+
1424
+ public function getSku();
1425
+
1426
+ public function getQuantity();
1427
+
1428
+ public function getStockData($key);
1429
+ }
1430
+
1431
+ class OCS_Message {
1432
+
1433
+ public $type;
1434
+ public $message;
1435
+ public $args;
1436
+
1437
+ public function OCS_Message($type, $args) {
1438
+ $this->type = $type;
1439
+ $this->message = array_shift($args);
1440
+ $this->args = $args;
1441
+ }
1442
+
1443
+ public function toString() {
1444
+ return vsprintf($this->message, $this->args);
1445
+ }
1446
+
1447
+ }
1448
+
1449
+ class OCS_Result {
1450
+
1451
+ public $success;
1452
+ public $result;
1453
+
1454
+ public function OCS_Result($success, $result = null) {
1455
+ $this->success = $success;
1456
+ $this->result = $result;
1457
+ }
1458
+
1459
+ public function __toString() {
1460
+ return is_bool($this->result) ? ($this->result ? 'true' : 'false') : (string) $this->result;
1461
+ }
1462
+
1463
+ }
1464
+
1465
+ ?>
app/code/community/Chronopost/Chronorelais/includes/countries.inc.php CHANGED
@@ -1,525 +1,529 @@
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
-
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
+