Chronopost - Version 1.4.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.4.0
Comparing to
See all releases


Code changes from version 1.2.0 to 1.4.0

Files changed (67) hide show
  1. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/Form/Renderer/Config/Date.php +23 -23
  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/Field/Config.php +43 -43
  5. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Field/Enabled.php +19 -19
  6. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Fieldsetassurance.php +43 -43
  7. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Fieldsetconflicts.php +47 -47
  8. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Rdvconfig.php +29 -29
  9. app/code/community/Chronopost/Chronorelais/Block/Checkout/Multishipping/Shipping/Method/Chronorelais.php +53 -53
  10. app/code/community/Chronopost/Chronorelais/Block/Checkout/Onepage/Shipping/Method/Chronopostsrdv.php +18 -18
  11. app/code/community/Chronopost/Chronorelais/Block/Checkout/Onepage/Shipping/Method/Chronorelais.php +62 -62
  12. app/code/community/Chronopost/Chronorelais/Block/Detail.php +17 -17
  13. app/code/community/Chronopost/Chronorelais/Block/Export/Orders.php +21 -21
  14. app/code/community/Chronopost/Chronorelais/Block/Export/Orders/Grid.php +278 -278
  15. app/code/community/Chronopost/Chronorelais/Block/Filter.php +28 -28
  16. app/code/community/Chronopost/Chronorelais/Block/Import/Form.php +11 -11
  17. app/code/community/Chronopost/Chronorelais/Block/Sales/Bordereau.php +13 -13
  18. app/code/community/Chronopost/Chronorelais/Block/Sales/Bordereau/Grid.php +161 -161
  19. app/code/community/Chronopost/Chronorelais/Block/Sales/Impression.php +15 -15
  20. app/code/community/Chronopost/Chronorelais/Block/Sales/Order/Shipment/View.php +27 -27
  21. app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid.php +259 -259
  22. app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid/Renderer/Retoursav.php +31 -31
  23. app/code/community/Chronopost/Chronorelais/Controller/Abstract.php +129 -129
  24. app/code/community/Chronopost/Chronorelais/Helper/Conflicts.php +159 -159
  25. app/code/community/Chronopost/Chronorelais/Helper/Data.php +463 -463
  26. app/code/community/Chronopost/Chronorelais/Helper/Webservice.php +733 -727
  27. app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelais.php +31 -31
  28. app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelaisShipping.php +517 -517
  29. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronoexpress.php +4 -4
  30. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronopost.php +4 -4
  31. app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostC10.php +5 -5
  32. app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostC18.php +5 -5
  33. app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostCClassic.php +5 -5
  34. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronopostsameday.php +33 -33
  35. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronopostsrdv.php +85 -85
  36. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronorelais.php +5 -5
  37. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronorelaisdom.php +7 -7
  38. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronorelaiseurope.php +6 -6
  39. app/code/community/Chronopost/Chronorelais/Model/Config/Backend/Date.php +17 -17
  40. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Civility.php +11 -11
  41. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Day.php +16 -16
  42. app/code/community/Chronopost/Chronorelais/Model/Config/Source/EndOfLineCharacter.php +12 -12
  43. app/code/community/Chronopost/Chronorelais/Model/Config/Source/FieldDelimiter.php +11 -11
  44. app/code/community/Chronopost/Chronorelais/Model/Config/Source/FieldSeparator.php +11 -11
  45. app/code/community/Chronopost/Chronorelais/Model/Config/Source/FileCharset.php +11 -11
  46. app/code/community/Chronopost/Chronorelais/Model/Config/Source/FileExtension.php +12 -12
  47. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Hour.php +13 -13
  48. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Margetype.php +11 -11
  49. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Minute.php +13 -13
  50. app/code/community/Chronopost/Chronorelais/Model/Config/Source/PrintMode.php +12 -12
  51. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Time.php +31 -31
  52. app/code/community/Chronopost/Chronorelais/Model/Config/Source/WeightUnit.php +11 -11
  53. app/code/community/Chronopost/Chronorelais/Model/Observer.php +270 -270
  54. app/code/community/Chronopost/Chronorelais/Model/Sales/Quote/Address/Total/Shipping.php +206 -206
  55. app/code/community/Chronopost/Chronorelais/Model/Sales/Quote/Address/Total/Shipping.toDel.php +206 -206
  56. app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/AjaxController.php +432 -432
  57. app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/ExportController.php +634 -634
  58. app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/ImportController.php +240 -240
  59. app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/Sales/BordereauController.php +328 -328
  60. app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/Sales/ImpressionController.php +1138 -1136
  61. app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/Sales/Order/ShipmentController.php +429 -429
  62. app/code/community/Chronopost/Chronorelais/controllers/Checkout/MultishippingController.php +104 -104
  63. app/code/community/Chronopost/Chronorelais/controllers/IndexController.php +10 -10
  64. app/code/community/Chronopost/Chronorelais/controllers/RelaisController.php +120 -120
  65. app/code/community/Chronopost/Chronorelais/controllers/SrdvController.php +37 -37
  66. app/code/community/Chronopost/Chronorelais/etc/config.xml +673 -673
  67. app/code/community/Chronopost/Chronorelais/etc/system.xml +1955 -2433
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/Form/Renderer/Config/Date.php CHANGED
@@ -1,23 +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
- }
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[0];
73
- if(version_compare($lastRelease->v, $currentVersion, '>')) {
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/Field/Config.php CHANGED
@@ -1,43 +1,43 @@
1
- <?php
2
-
3
- class Chronopost_Chronorelais_Block_Adminhtml_System_Config_Form_Field_Config extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- private static $JS_INCLUDED = false;
6
-
7
- private function label($input) {
8
- return str_replace(array("\r\n","\r","\n","'"),array("\\n","\\n","\\n","\\'"),$this->__($input));
9
- }
10
-
11
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
- {
13
- $output = '';
14
- if (!self::$JS_INCLUDED) {
15
- $include_path = Mage::getBaseUrl('js').'chronopost/chronorelais';
16
- $output = "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js\"></script>\n"
17
- ."<script type=\"text/javascript\" src=\"".$include_path."/ocseditor.js?t=".time()."\"></script>\n"
18
- ."<script type=\"text/javascript\">\n"
19
- ."//<![CDATA[\n"
20
- ."jQuery.noConflict();\n"
21
- ."var ocseditor = new OCSEditor({\n"
22
- ."ajax_url: '".$this->getUrl('adminhtml/chronorelais_ajax')."?isAjax=true',\n"
23
- ."form_key: FORM_KEY,\n"
24
- ."menu_item_dissociate_label: '".$this->label('Dissociate')."',\n"
25
- ."menu_item_remove_label: '".$this->label('Remove')."',\n"
26
- ."menu_item_edit_label: '".$this->label('Edit')."',\n"
27
- ."prompt_new_value_label: '".$this->label('Enter the new value:')."',\n"
28
- ."default_row_label: '".$this->label('[No label]')."',\n"
29
- ."loading_label: '".$this->label('Loading...')."'\n"
30
- ."});\n"
31
- ."//]]>\n"
32
- ."</script>\n"
33
- ."<link type=\"text/css\" href=\"".$include_path."/ocseditor.css?t=".time()."\" rel=\"stylesheet\" media=\"all\"/>\n"
34
- ;
35
- self::$JS_INCLUDED = true;
36
- }
37
-
38
- return $output
39
- .'<div style="margin-bottom:1px;"><button type="button" class="scalable" onclick="ocseditor.open(this);"><span>'.$this->__("Open editor").'</span></button></div>'
40
- .$element->getElementHtml().'<br/>'
41
- ;
42
- }
43
- }
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Block_Adminhtml_System_Config_Form_Field_Config extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ private static $JS_INCLUDED = false;
6
+
7
+ private function label($input) {
8
+ return str_replace(array("\r\n","\r","\n","'"),array("\\n","\\n","\\n","\\'"),$this->__($input));
9
+ }
10
+
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
+ $output = '';
14
+ if (!self::$JS_INCLUDED) {
15
+ $include_path = Mage::getBaseUrl('js').'chronopost/chronorelais';
16
+ $output = "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js\"></script>\n"
17
+ ."<script type=\"text/javascript\" src=\"".$include_path."/ocseditor.js?t=".time()."\"></script>\n"
18
+ ."<script type=\"text/javascript\">\n"
19
+ ."//<![CDATA[\n"
20
+ ."jQuery.noConflict();\n"
21
+ ."var ocseditor = new OCSEditor({\n"
22
+ ."ajax_url: '".$this->getUrl('adminhtml/chronorelais_ajax')."?isAjax=true',\n"
23
+ ."form_key: FORM_KEY,\n"
24
+ ."menu_item_dissociate_label: '".$this->label('Dissociate')."',\n"
25
+ ."menu_item_remove_label: '".$this->label('Remove')."',\n"
26
+ ."menu_item_edit_label: '".$this->label('Edit')."',\n"
27
+ ."prompt_new_value_label: '".$this->label('Enter the new value:')."',\n"
28
+ ."default_row_label: '".$this->label('[No label]')."',\n"
29
+ ."loading_label: '".$this->label('Loading...')."'\n"
30
+ ."});\n"
31
+ ."//]]>\n"
32
+ ."</script>\n"
33
+ ."<link type=\"text/css\" href=\"".$include_path."/ocseditor.css?t=".time()."\" rel=\"stylesheet\" media=\"all\"/>\n"
34
+ ;
35
+ self::$JS_INCLUDED = true;
36
+ }
37
+
38
+ return $output
39
+ .'<div style="margin-bottom:1px;"><button type="button" class="scalable" onclick="ocseditor.open(this);"><span>'.$this->__("Open editor").'</span></button></div>'
40
+ .$element->getElementHtml().'<br/>'
41
+ ;
42
+ }
43
+ }
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Field/Enabled.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
-
3
- class Chronopost_Chronorelais_Block_Adminhtml_System_Config_Form_Field_Enabled extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- /* si mode de livraison pas dans son contrat => on le désactive */
8
- $id = $element->getId();
9
- $carrier = explode('_', $id);
10
- $carrier = $carrier[1];
11
- if(!Mage::helper('chronorelais')->shippingMethodEnabled($carrier))
12
- {
13
- $element->setDisabled('disabled');
14
- $element->setValue(0);
15
- }
16
-
17
- return $element->getElementHtml();
18
- }
19
- }
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Block_Adminhtml_System_Config_Form_Field_Enabled extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ /* si mode de livraison pas dans son contrat => on le désactive */
8
+ $id = $element->getId();
9
+ $carrier = explode('_', $id);
10
+ $carrier = $carrier[1];
11
+ if(!Mage::helper('chronorelais')->shippingMethodEnabled($carrier))
12
+ {
13
+ $element->setDisabled('disabled');
14
+ $element->setValue(0);
15
+ }
16
+
17
+ return $element->getElementHtml();
18
+ }
19
+ }
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Fieldsetassurance.php CHANGED
@@ -1,43 +1,43 @@
1
- <?php
2
- class Chronopost_Chronorelais_Block_Adminhtml_System_Config_Form_Fieldsetassurance
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_assurance">';
19
- $html .= '<div class="chronorelais_assurance_picto">';
20
- $html .= '<img src="'.Mage::getDesign()->getSkinUrl('chronorelais/picto.gif').'" id="chronorelais_assurance_picto_img"/>';
21
- $html .= '</div>';
22
- $html .= '<div class="chronorelais_assurance_infobulle" id="chronorelais_assurance_infobulle" style="display:none;">';
23
- $html .= '<div class="chronorelais_assurance_infobulle_header">';
24
- $html .= '<div class="chronorelais_assurance_infobulle_header_title">POP-UP INFORMATION</div>';
25
- $html .= '<div class="chronorelais_assurance_infobulle_header_close" id="chronorelais_assurance_infobulle_header_close"><button class="scalable close" type="button"><span>Close</span></button></div>';
26
- $html .= '<div class="clear"></div>';
27
- $html .= '</div>';
28
- $html .= '<div class="chronorelais_assurance_infobulle_content">';
29
- $html .= 'En activant cette option, pour chaque colis dépassant le montant que vous renseignez, votre envoi sera assuré à hauteur du montant des articles de ce dernier (maximum 20 000€).';
30
- $html .= '</div>';
31
- $html .= '</div>';
32
- $html .= '</div>';
33
-
34
- $html .= '</fieldset>' . $this->_getExtraJs($element, $tooltipsExist);
35
-
36
- if ($element->getIsNested()) {
37
- $html .= '</div></td></tr>';
38
- } else {
39
- $html .= '</div>';
40
- }
41
- return $html;
42
- }
43
- }
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Adminhtml_System_Config_Form_Fieldsetassurance
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_assurance">';
19
+ $html .= '<div class="chronorelais_assurance_picto">';
20
+ $html .= '<img src="'.Mage::getDesign()->getSkinUrl('chronorelais/picto.gif').'" id="chronorelais_assurance_picto_img"/>';
21
+ $html .= '</div>';
22
+ $html .= '<div class="chronorelais_assurance_infobulle" id="chronorelais_assurance_infobulle" style="display:none;">';
23
+ $html .= '<div class="chronorelais_assurance_infobulle_header">';
24
+ $html .= '<div class="chronorelais_assurance_infobulle_header_title">POP-UP INFORMATION</div>';
25
+ $html .= '<div class="chronorelais_assurance_infobulle_header_close" id="chronorelais_assurance_infobulle_header_close"><button class="scalable close" type="button"><span>Close</span></button></div>';
26
+ $html .= '<div class="clear"></div>';
27
+ $html .= '</div>';
28
+ $html .= '<div class="chronorelais_assurance_infobulle_content">';
29
+ $html .= 'En activant cette option, pour chaque colis dépassant le montant que vous renseignez, votre envoi sera assuré à hauteur du montant des articles de ce dernier (maximum 20 000€).';
30
+ $html .= '</div>';
31
+ $html .= '</div>';
32
+ $html .= '</div>';
33
+
34
+ $html .= '</fieldset>' . $this->_getExtraJs($element, $tooltipsExist);
35
+
36
+ if ($element->getIsNested()) {
37
+ $html .= '</div></td></tr>';
38
+ } else {
39
+ $html .= '</div>';
40
+ }
41
+ return $html;
42
+ }
43
+ }
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Fieldsetconflicts.php CHANGED
@@ -1,47 +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
- $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
- }
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 CHANGED
@@ -1,29 +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
- }
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/Multishipping/Shipping/Method/Chronorelais.php CHANGED
@@ -1,53 +1,53 @@
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_Checkout
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
- * One page checkout status
29
- *
30
- * @category Mage
31
- * @category Mage
32
- * @package Mage_Checkout
33
- * @author Magento Core Team <core@magentocommerce.com>
34
- */
35
- class Chronopost_Chronorelais_Block_Checkout_Multishipping_Shipping_Method_Chronorelais extends Mage_Checkout_Block_Onepage_Abstract
36
- {
37
- protected $_chronorelais;
38
-
39
- public function getChronorelais()
40
- {
41
- if (empty($this->_chronorelais)) {
42
- $postcode = Mage::getSingleton('core/session')->getMultiPostcode();
43
-
44
- $helper = Mage::helper('chronorelais/webservice');
45
- $webservbt = $helper->getPointsRelaisByCp($postcode);
46
-
47
- $this->_chronorelais = $webservbt;
48
- }
49
-
50
- return $this->_chronorelais;
51
- }
52
-
53
- }
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_Checkout
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
+ * One page checkout status
29
+ *
30
+ * @category Mage
31
+ * @category Mage
32
+ * @package Mage_Checkout
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Chronopost_Chronorelais_Block_Checkout_Multishipping_Shipping_Method_Chronorelais extends Mage_Checkout_Block_Onepage_Abstract
36
+ {
37
+ protected $_chronorelais;
38
+
39
+ public function getChronorelais()
40
+ {
41
+ if (empty($this->_chronorelais)) {
42
+ $postcode = Mage::getSingleton('core/session')->getMultiPostcode();
43
+
44
+ $helper = Mage::helper('chronorelais/webservice');
45
+ $webservbt = $helper->getPointsRelaisByCp($postcode);
46
+
47
+ $this->_chronorelais = $webservbt;
48
+ }
49
+
50
+ return $this->_chronorelais;
51
+ }
52
+
53
+ }
app/code/community/Chronopost/Chronorelais/Block/Checkout/Onepage/Shipping/Method/Chronopostsrdv.php CHANGED
@@ -1,18 +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
- }
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
@@ -1,62 +1,62 @@
1
- <?php
2
-
3
- /**
4
- * Magento
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
- * DISCLAIMER
17
- *
18
- * Do not edit or add to this file if you wish to upgrade Magento to newer
19
- * versions in the future. If you wish to customize Magento for your
20
- * needs please refer to http://www.magentocommerce.com for more information.
21
- *
22
- * @category Mage
23
- * @package Mage_Checkout
24
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
25
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
- */
27
-
28
- /**
29
- * One page checkout status
30
- *
31
- * @category Mage
32
- * @category Mage
33
- * @package Mage_Checkout
34
- * @author Magento Core Team <core@magentocommerce.com>
35
- */
36
- class Chronopost_Chronorelais_Block_Checkout_Onepage_Shipping_Method_Chronorelais extends Mage_Checkout_Block_Onepage_Abstract {
37
-
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
- }
61
-
62
- }
1
+ <?php
2
+
3
+ /**
4
+ * Magento
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
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Checkout
24
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ /**
29
+ * One page checkout status
30
+ *
31
+ * @category Mage
32
+ * @category Mage
33
+ * @package Mage_Checkout
34
+ * @author Magento Core Team <core@magentocommerce.com>
35
+ */
36
+ class Chronopost_Chronorelais_Block_Checkout_Onepage_Shipping_Method_Chronorelais extends Mage_Checkout_Block_Onepage_Abstract {
37
+
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
+ }
61
+
62
+ }
app/code/community/Chronopost/Chronorelais/Block/Detail.php CHANGED
@@ -1,18 +1,18 @@
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
  ?>
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.php CHANGED
@@ -1,21 +1,21 @@
1
- <?php
2
- /**
3
- * Chronopost Chronorelais module
4
- *
5
- * @category Chronopost
6
- * @package Chronopost_Chronorelais
7
- * @license http://www.opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
8
- */
9
- class Chronopost_Chronorelais_Block_Export_Orders extends Mage_Adminhtml_Block_Widget_Grid_Container
10
- {
11
-
12
- public function __construct()
13
- {
14
- $this->_blockGroup = 'chronorelais';
15
- $this->_controller = 'export_orders';
16
- $this->_headerText = Mage::helper('chronorelais')->__('Exporter vers ChronoShip Office ou ChronoShip Station');
17
- parent::__construct();
18
- $this->_removeButton('add');
19
- }
20
-
21
- }
1
+ <?php
2
+ /**
3
+ * Chronopost Chronorelais module
4
+ *
5
+ * @category Chronopost
6
+ * @package Chronopost_Chronorelais
7
+ * @license http://www.opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
8
+ */
9
+ class Chronopost_Chronorelais_Block_Export_Orders extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+
12
+ public function __construct()
13
+ {
14
+ $this->_blockGroup = 'chronorelais';
15
+ $this->_controller = 'export_orders';
16
+ $this->_headerText = Mage::helper('chronorelais')->__('Exporter vers ChronoShip Office ou ChronoShip Station');
17
+ parent::__construct();
18
+ $this->_removeButton('add');
19
+ }
20
+
21
+ }
app/code/community/Chronopost/Chronorelais/Block/Export/Orders/Grid.php CHANGED
@@ -1,278 +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) {
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
- }
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,29 +1,29 @@
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
  ?>
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/Import/Form.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
- class Chronopost_Chronorelais_Block_Import_Form extends Mage_Adminhtml_Block_Widget
3
- {
4
-
5
- public function __construct()
6
- {
7
- parent::__construct();
8
- $this->setTemplate('chronorelais/import/form.phtml');
9
- }
10
-
11
- }
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Import_Form extends Mage_Adminhtml_Block_Widget
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setTemplate('chronorelais/import/form.phtml');
9
+ }
10
+
11
+ }
app/code/community/Chronopost/Chronorelais/Block/Sales/Bordereau.php CHANGED
@@ -1,14 +1,14 @@
1
- <?php
2
-
3
- class Chronopost_Chronorelais_Block_Sales_Bordereau extends Mage_Adminhtml_Block_Widget_Grid_Container
4
- {
5
- public function __construct()
6
- {
7
- $this->_blockGroup = 'chronorelais';
8
- $this->_controller = 'sales_bordereau';
9
- $this->_headerText = Mage::helper('chronorelais')->__('Bordereau de fin de journée');
10
- parent::__construct();
11
- $this->_removeButton('add');
12
- }
13
-
14
  }
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Block_Sales_Bordereau extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_blockGroup = 'chronorelais';
8
+ $this->_controller = 'sales_bordereau';
9
+ $this->_headerText = Mage::helper('chronorelais')->__('Bordereau de fin de journée');
10
+ parent::__construct();
11
+ $this->_removeButton('add');
12
+ }
13
+
14
  }
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 (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/Impression.php CHANGED
@@ -1,16 +1,16 @@
1
- <?php
2
-
3
- class Chronopost_Chronorelais_Block_Sales_Impression extends Mage_Adminhtml_Block_Widget_Grid_Container
4
- {
5
-
6
-
7
- public function __construct()
8
- {
9
- $this->_blockGroup = 'chronorelais';
10
- $this->_controller = 'sales_shipment';
11
- $this->_headerText = Mage::helper('chronorelais')->__('Impressions des étiquettes Chronopost');
12
- parent::__construct();
13
- $this->_removeButton('add');
14
- }
15
-
16
  }
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Block_Sales_Impression extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+
6
+
7
+ public function __construct()
8
+ {
9
+ $this->_blockGroup = 'chronorelais';
10
+ $this->_controller = 'sales_shipment';
11
+ $this->_headerText = Mage::helper('chronorelais')->__('Impressions des étiquettes Chronopost');
12
+ parent::__construct();
13
+ $this->_removeButton('add');
14
+ }
15
+
16
  }
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,259 +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 (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
- }
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,31 +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
- $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
- }
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
@@ -1,130 +1,130 @@
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
- class Chronopost_Chronorelais_Controller_Abstract extends Mage_Adminhtml_Controller_Action
24
- {
25
- public function __() {
26
- $args = func_get_args();
27
- $message = array_shift($args);
28
- if ($message instanceof OS_Message) {
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) {
51
- if (file_exists(dirname(__FILE__).'/Chronopost_Chronorelais_includes_'.$path)) {
52
- return 'Chronopost_Chronorelais_includes_'.$path;
53
- } else {
54
- return Mage::getBaseDir('code').'/community/Chronopost/Chronorelais/includes/'.$path;
55
- }
56
- }
57
-
58
- protected function getMimeType($extension) {
59
- $mime_type_array = array(
60
- '.gz' => 'application/x-gzip',
61
- '.tgz' => 'application/x-gzip',
62
- '.zip' => 'application/zip',
63
- '.pdf' => 'application/pdf',
64
- '.png' => 'image/png',
65
- '.gif' => 'image/gif',
66
- '.jpg' => 'image/jpeg',
67
- '.jpeg' => 'image/jpeg',
68
- '.txt' => 'text/plain',
69
- '.htm' => 'text/html',
70
- '.html' => 'text/html',
71
- '.mpg' => 'video/mpeg',
72
- '.avi' => 'video/x-msvideo',
73
- );
74
- return isset($mime_type_array[$extension]) ? $mime_type_array[$extension] : 'application/octet-stream';
75
- }
76
-
77
- protected function forceDownload($filename, $content) {
78
- if (headers_sent()) {
79
- trigger_error('forceDownload($filename) - Headers have already been sent',E_USER_ERROR);
80
- return false;
81
- }
82
-
83
- $extension = strrchr($filename,'.');
84
- $mime_type = $this->getMimeType($extension);
85
-
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');
92
- echo $content;
93
- return true;
94
- }
95
-
96
- protected function jsEscape($input) {
97
- return str_replace(array("\r\n","\r","\n","'"),array("\\n","\\n","\\n","\\'"),$input);
98
- }
99
-
100
- protected function cleanKey($key) {
101
- return preg_replace('/[^a-z0-9-_]/i','_-_',$key);
102
- }
103
-
104
- protected function page($id, $title, $content) {
105
- return "<div id=\"ocseditor-".$id."-page\" class=\"ocseditor-page\">"
106
- .$this->pageHeader($title,$this->button('Close',"ocseditor.closePage(this);",'cancel'))
107
- ."<div class=\"page-content\">".$content."</div>"
108
- ."</div>"
109
- ;
110
- }
111
-
112
- protected function pageHeader($title, $buttons) {
113
- return "<div class=\"content-header\">"
114
- ."<table cellspacing=\"0\"><tr>"
115
- ."<td><h3>".$this->__($title)."</h3></td>"
116
- ."<td class=\"form-buttons\">"
117
- .$buttons
118
- ."</td>"
119
- ."</tr></table>"
120
- ."</div>"
121
- ;
122
- }
123
-
124
- protected function button($label, $onclick, $class_name='') {
125
- $class_name = 'scalable'.($class_name!='' ? ' '.$class_name : '');
126
- return "<button type=\"button\" class=\"".$class_name."\" onclick=\"".$onclick."\"><span>".$this->__($label)."</span></button>";
127
- }
128
- }
129
-
130
  ?>
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
+ class Chronopost_Chronorelais_Controller_Abstract extends Mage_Adminhtml_Controller_Action
24
+ {
25
+ public function __() {
26
+ $args = func_get_args();
27
+ $message = array_shift($args);
28
+ if ($message instanceof OS_Message) {
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) {
51
+ if (file_exists(dirname(__FILE__).'/Chronopost_Chronorelais_includes_'.$path)) {
52
+ return 'Chronopost_Chronorelais_includes_'.$path;
53
+ } else {
54
+ return Mage::getBaseDir('code').'/community/Chronopost/Chronorelais/includes/'.$path;
55
+ }
56
+ }
57
+
58
+ protected function getMimeType($extension) {
59
+ $mime_type_array = array(
60
+ '.gz' => 'application/x-gzip',
61
+ '.tgz' => 'application/x-gzip',
62
+ '.zip' => 'application/zip',
63
+ '.pdf' => 'application/pdf',
64
+ '.png' => 'image/png',
65
+ '.gif' => 'image/gif',
66
+ '.jpg' => 'image/jpeg',
67
+ '.jpeg' => 'image/jpeg',
68
+ '.txt' => 'text/plain',
69
+ '.htm' => 'text/html',
70
+ '.html' => 'text/html',
71
+ '.mpg' => 'video/mpeg',
72
+ '.avi' => 'video/x-msvideo',
73
+ );
74
+ return isset($mime_type_array[$extension]) ? $mime_type_array[$extension] : 'application/octet-stream';
75
+ }
76
+
77
+ protected function forceDownload($filename, $content) {
78
+ if (headers_sent()) {
79
+ trigger_error('forceDownload($filename) - Headers have already been sent',E_USER_ERROR);
80
+ return false;
81
+ }
82
+
83
+ $extension = strrchr($filename,'.');
84
+ $mime_type = $this->getMimeType($extension);
85
+
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');
92
+ echo $content;
93
+ return true;
94
+ }
95
+
96
+ protected function jsEscape($input) {
97
+ return str_replace(array("\r\n","\r","\n","'"),array("\\n","\\n","\\n","\\'"),$input);
98
+ }
99
+
100
+ protected function cleanKey($key) {
101
+ return preg_replace('/[^a-z0-9-_]/i','_-_',$key);
102
+ }
103
+
104
+ protected function page($id, $title, $content) {
105
+ return "<div id=\"ocseditor-".$id."-page\" class=\"ocseditor-page\">"
106
+ .$this->pageHeader($title,$this->button('Close',"ocseditor.closePage(this);",'cancel'))
107
+ ."<div class=\"page-content\">".$content."</div>"
108
+ ."</div>"
109
+ ;
110
+ }
111
+
112
+ protected function pageHeader($title, $buttons) {
113
+ return "<div class=\"content-header\">"
114
+ ."<table cellspacing=\"0\"><tr>"
115
+ ."<td><h3>".$this->__($title)."</h3></td>"
116
+ ."<td class=\"form-buttons\">"
117
+ .$buttons
118
+ ."</td>"
119
+ ."</tr></table>"
120
+ ."</div>"
121
+ ;
122
+ }
123
+
124
+ protected function button($label, $onclick, $class_name='') {
125
+ $class_name = 'scalable'.($class_name!='' ? ' '.$class_name : '');
126
+ return "<button type=\"button\" class=\"".$class_name."\" onclick=\"".$onclick."\"><span>".$this->__($label)."</span></button>";
127
+ }
128
+ }
129
+
130
  ?>
app/code/community/Chronopost/Chronorelais/Helper/Conflicts.php CHANGED
@@ -1,159 +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)) {
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
- }
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,463 +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
-
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
- }
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,727 +1,733 @@
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
- }
 
 
 
 
 
 
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?wsdl");
210
+ $webservbt = $client->rechercheDetailPointChronopost($params);
211
+
212
+ if($webservbt->return->errorCode == 0)
213
+ {
214
+ return $webservbt->return->listePointRelais;
215
+ } else {
216
+ return $this->getDetailRelaisPointByPudo($btcode);
217
+ }
218
+
219
+ } catch (Exception $e) {
220
+ return $this->getDetailRelaisPointByPudo($btcode);
221
+ }
222
+ }
223
+
224
+
225
+ /*
226
+ *
227
+ * WS de secours
228
+ */
229
+
230
+ public function getDetailRelaisPointByPudo($btcode) {
231
+ $params = array(
232
+ 'carrier' => 'CHR',
233
+ 'key' => '75f6fe195dc88ceecbc0f8a2f70a8f3a',
234
+ 'pudo_id' => $btcode,
235
+ );
236
+
237
+ try {
238
+ $client = new SoapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?wsdl", array('trace' => 0, 'connection_timeout' => 10));
239
+ $webservbt = $client->GetPudoDetails($params);
240
+ $webservbt = json_decode(json_encode((object) simplexml_load_string($webservbt->GetPudoDetailsResult->any)), 1);
241
+ if(!isset($webservbt['ERROR'])) {
242
+ $pr = $webservbt['PUDO_ITEMS']['PUDO_ITEM'];
243
+ if($pr && $pr['@attributes']['active'] == 'true') {
244
+ $newPr = (object)array();
245
+ $newPr->adresse1 = $pr['ADDRESS1'];
246
+ $newPr->adresse2 = is_array($pr['ADDRESS2']) ? implode(' ', $pr['ADDRESS2']) : $pr['ADDRESS2'];
247
+ $newPr->adresse3 = is_array($pr['ADDRESS3']) ? implode(' ', $pr['ADDRESS3']) : $pr['ADDRESS3'];
248
+ $newPr->codePostal = $pr['ZIPCODE'];
249
+ $newPr->identifiantChronopostPointA2PAS = $pr['PUDO_ID'];
250
+ $newPr->localite = $pr['CITY'];
251
+ $newPr->nomEnseigne = $pr['NAME'];
252
+ $time = new DateTime;
253
+ $newPr->dateArriveColis = $time->format(DateTime::ATOM);
254
+ $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
255
+
256
+ if(isset($pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'])) {
257
+ $listeHoraires = $pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'];
258
+ foreach($listeHoraires as $horaire) {
259
+ switch($horaire['DAY_ID']) {
260
+ case '1' :
261
+ if(!empty($newPr->horairesOuvertureLundi)) {
262
+ $newPr->horairesOuvertureLundi .= ' ';
263
+ }
264
+ $newPr->horairesOuvertureLundi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
265
+ break;
266
+ case '2' :
267
+ if(!empty($newPr->horairesOuvertureMardi)) {
268
+ $newPr->horairesOuvertureMardi .= ' ';
269
+ }
270
+ $newPr->horairesOuvertureMardi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
271
+ break;
272
+ case '3' :
273
+ if(!empty($newPr->horairesOuvertureMercredi)) {
274
+ $newPr->horairesOuvertureMercredi .= ' ';
275
+ }
276
+ $newPr->horairesOuvertureMercredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
277
+ break;
278
+ case '4' :
279
+ if(!empty($newPr->horairesOuvertureJeudi)) {
280
+ $newPr->horairesOuvertureJeudi .= ' ';
281
+ }
282
+ $newPr->horairesOuvertureJeudi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
283
+ break;
284
+ case '5' :
285
+ if(!empty($newPr->horairesOuvertureVendredi)) {
286
+ $newPr->horairesOuvertureVendredi .= ' ';
287
+ }
288
+ $newPr->horairesOuvertureVendredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
289
+ break;
290
+ case '6' :
291
+ if(!empty($newPr->horairesOuvertureSamedi)) {
292
+ $newPr->horairesOuvertureSamedi .= ' ';
293
+ }
294
+ $newPr->horairesOuvertureSamedi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
295
+ break;
296
+ case '7' :
297
+ if(!empty($newPr->horairesOuvertureDimanche)) {
298
+ $newPr->horairesOuvertureDimanche .= ' ';
299
+ }
300
+ $newPr->horairesOuvertureDimanche .= $horaire['START_TM'].'-'.$horaire['END_TM'];
301
+ break;
302
+ default :
303
+ break;
304
+ }
305
+ }
306
+ }
307
+ if(empty($newPr->horairesOuvertureLundi)) {
308
+ $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
309
+ }
310
+ if(empty($newPr->horairesOuvertureMardi)) {
311
+ $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
312
+ }
313
+ if(empty($newPr->horairesOuvertureMercredi)) {
314
+ $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
315
+ }
316
+ if(empty($newPr->horairesOuvertureJeudi)) {
317
+ $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
318
+ }
319
+ if(empty($newPr->horairesOuvertureVendredi)) {
320
+ $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
321
+ }
322
+ if(empty($newPr->horairesOuvertureSamedi)) {
323
+ $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
324
+ }
325
+ if(empty($newPr->horairesOuvertureDimanche)) {
326
+ $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
327
+ }
328
+
329
+ return $newPr;
330
+ }
331
+ }
332
+ }
333
+ catch (Exception $e) {
334
+ return false;
335
+ }
336
+ return false;
337
+ }
338
+
339
+ public function getPointsRelaisByPudo($address = '', $cp = '') {
340
+
341
+ $params = array(
342
+ 'carrier' => 'CHR',
343
+ 'key' => '75f6fe195dc88ceecbc0f8a2f70a8f3a',
344
+ 'address' => $address ? $this->getFilledValue($address->getStreet(1)) : '',
345
+ 'zipCode' => $address ? $this->getFilledValue($address->getPostcode()) : $cp,
346
+ 'city' => $address ? $this->getFilledValue($address->getCity()) : 'Lille',
347
+ 'countrycode' => $address ? $this->getFilledValue($address->getCountryId()) : '',
348
+ 'requestID' => '1',
349
+ 'date_from' => date('d/m/Y'),
350
+ 'max_pudo_number' => 5,
351
+ 'max_distance_search' => 10,
352
+ 'weight' => 1,
353
+ 'category' => '',
354
+ 'holiday_tolerant' => 1,
355
+ );
356
+ try {
357
+ $client = new SoapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?wsdl", array('trace' => 0, 'connection_timeout' => 10));
358
+ $webservbt = $client->GetPudoList($params);
359
+ $webservbt = json_decode(json_encode((object) simplexml_load_string($webservbt->GetPudoListResult->any)), 1);
360
+ if(!isset($webservbt['ERROR'])) {
361
+ $return = array();
362
+
363
+ $listePr = $webservbt['PUDO_ITEMS']['PUDO_ITEM'];
364
+ if($listePr) {
365
+ foreach($listePr as $pr)
366
+ {
367
+ if($pr['@attributes']['active'] == 'true')
368
+ {
369
+ $newPr = (object)array();
370
+ $newPr->adresse1 = $pr['ADDRESS1'];
371
+ $newPr->adresse2 = is_array($pr['ADDRESS2']) ? implode(' ', $pr['ADDRESS2']) : $pr['ADDRESS2'];
372
+ $newPr->adresse3 = is_array($pr['ADDRESS3']) ? implode(' ', $pr['ADDRESS3']) : $pr['ADDRESS3'];
373
+ $newPr->codePostal = $pr['ZIPCODE'];
374
+ $newPr->identifiantChronopostPointA2PAS = $pr['PUDO_ID'];
375
+ $newPr->localite = $pr['CITY'];
376
+ $newPr->nomEnseigne = $pr['NAME'];
377
+ $time = new DateTime;
378
+ $newPr->dateArriveColis = $time->format(DateTime::ATOM);
379
+ $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
380
+
381
+ if(isset($pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'])) {
382
+ $listeHoraires = $pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'];
383
+ foreach($listeHoraires as $horaire) {
384
+ switch($horaire['DAY_ID']) {
385
+ case '1' :
386
+ if(!empty($newPr->horairesOuvertureLundi)) {
387
+ $newPr->horairesOuvertureLundi .= ' ';
388
+ }
389
+ $newPr->horairesOuvertureLundi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
390
+ break;
391
+ case '2' :
392
+ if(!empty($newPr->horairesOuvertureMardi)) {
393
+ $newPr->horairesOuvertureMardi .= ' ';
394
+ }
395
+ $newPr->horairesOuvertureMardi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
396
+ break;
397
+ case '3' :
398
+ if(!empty($newPr->horairesOuvertureMercredi)) {
399
+ $newPr->horairesOuvertureMercredi .= ' ';
400
+ }
401
+ $newPr->horairesOuvertureMercredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
402
+ break;
403
+ case '4' :
404
+ if(!empty($newPr->horairesOuvertureJeudi)) {
405
+ $newPr->horairesOuvertureJeudi .= ' ';
406
+ }
407
+ $newPr->horairesOuvertureJeudi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
408
+ break;
409
+ case '5' :
410
+ if(!empty($newPr->horairesOuvertureVendredi)) {
411
+ $newPr->horairesOuvertureVendredi .= ' ';
412
+ }
413
+ $newPr->horairesOuvertureVendredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
414
+ break;
415
+ case '6' :
416
+ if(!empty($newPr->horairesOuvertureSamedi)) {
417
+ $newPr->horairesOuvertureSamedi .= ' ';
418
+ }
419
+ $newPr->horairesOuvertureSamedi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
420
+ break;
421
+ case '7' :
422
+ if(!empty($newPr->horairesOuvertureDimanche)) {
423
+ $newPr->horairesOuvertureDimanche .= ' ';
424
+ }
425
+ $newPr->horairesOuvertureDimanche .= $horaire['START_TM'].'-'.$horaire['END_TM'];
426
+ break;
427
+ }
428
+ }
429
+ }
430
+ if(empty($newPr->horairesOuvertureLundi)) {
431
+ $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
432
+ }
433
+ if(empty($newPr->horairesOuvertureMardi)) {
434
+ $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
435
+ }
436
+ if(empty($newPr->horairesOuvertureMercredi)) {
437
+ $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
438
+ }
439
+ if(empty($newPr->horairesOuvertureJeudi)) {
440
+ $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
441
+ }
442
+ if(empty($newPr->horairesOuvertureVendredi)) {
443
+ $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
444
+ }
445
+ if(empty($newPr->horairesOuvertureSamedi)) {
446
+ $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
447
+ }
448
+ if(empty($newPr->horairesOuvertureDimanche)) {
449
+ $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
450
+ }
451
+
452
+ $return[] = $newPr;
453
+ }
454
+ }
455
+ return $return;
456
+ }
457
+ }
458
+ }
459
+ catch (Exception $e) {
460
+ return false;
461
+ }
462
+ return false;
463
+ }
464
+
465
+
466
+ public function getQuickcost($quickCost,$quickcost_url = '') {
467
+ if (!$quickcost_url) {
468
+ $quickcost_url = "https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl";
469
+ }
470
+ try {
471
+ $client = new SoapClient($quickcost_url);
472
+ $webservbt = $client->quickCost($quickCost);
473
+
474
+ return $webservbt->return;
475
+ } catch (Exception $e) {
476
+ return false;
477
+ }
478
+ }
479
+
480
+ public function checkLogin($quickCost,$quickcost_url = '') {
481
+ if (!$quickcost_url) {
482
+ $quickcost_url = "https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl";
483
+ }
484
+ try {
485
+ $client = new SoapClient($quickcost_url);
486
+ $webservbt = $client->calculateProducts($quickCost);
487
+ return $webservbt;
488
+ } catch (Exception $e) {
489
+ return false;
490
+ }
491
+ }
492
+
493
+ /*
494
+ * Return true si la méthode de livraison fait partie du contrat
495
+ */
496
+ public function getMethodIsAllowed($code,$quote = '') {
497
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
498
+ $address = $quote->getShippingAddress();
499
+ $helperData = Mage::helper('chronorelais');
500
+ $code = $helperData->getChronoProductCode('',$code);
501
+ try {
502
+ if($this->methodsAllowed === false) {
503
+ $this->methodsAllowed = array();
504
+ $client = new SoapClient("https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl", array('trace' => 0, 'connection_timeout' => 10));
505
+ $params = array(
506
+ 'accountNumber' => $helperData->getConfigurationAccountNumber(),
507
+ 'password' => $helperData->getConfigurationAccountPass(),
508
+ 'depCountryCode' => $helperData->getConfigurationShipperInfo('country'),
509
+ 'depZipCode' => $helperData->getConfigurationShipperInfo('zipcode'),
510
+ 'arrCountryCode' => $this->getFilledValue($address->getCountryId()),
511
+ 'arrZipCode' => $this->getFilledValue($address->getPostcode()),
512
+ 'arrCity' => $address->getCity() ? $this->getFilledValue($address->getCity()) : '-',
513
+ 'type' => 'M',
514
+ 'weight' => 1
515
+ );
516
+ $webservbt = $client->calculateProducts($params);
517
+ if($webservbt->return->errorCode == 0 && $webservbt->return->productList)
518
+ {
519
+ if(is_array($webservbt->return->productList)) {
520
+ foreach($webservbt->return->productList as $product) {
521
+ $this->methodsAllowed[] = $product->productCode;
522
+ }
523
+ } else { /* cas ou il y a un seul résultat */
524
+ $product = $webservbt->return->productList;
525
+ $this->methodsAllowed[] = $product->productCode;
526
+ }
527
+ }
528
+ }
529
+ if(!empty($this->methodsAllowed) && in_array($code, $this->methodsAllowed)) {
530
+ return true;
531
+ }
532
+ return false;
533
+ }catch(Exception $e) {
534
+ return false;
535
+ }
536
+ }
537
+
538
+
539
+ public function getFilledValue($value) {
540
+ if ($value) {
541
+ return $this->removeaccents(trim($value));
542
+ } else {
543
+ return '';
544
+ }
545
+ }
546
+
547
+ public function removeaccents($string) {
548
+ $stringToReturn = str_replace(
549
+ 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);
550
+ // Remove all remaining other unknown characters
551
+ $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
552
+ $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
553
+ $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
554
+ $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
555
+ return $stringToReturn;
556
+ }
557
+
558
+ public function cancelSkybill($skybillNumber = '') {
559
+ if($skybillNumber) {
560
+ try {
561
+
562
+ $client = new SoapClient("https://www.chronopost.fr/tracking-cxf/TrackingServiceWS?wsdl",array('trace'=> 0,'connection_timeout'=>10));
563
+
564
+ $helperData = Mage::helper('chronorelais');
565
+ $params = array(
566
+ 'accountNumber' => $helperData->getConfigurationAccountNumber(),
567
+ 'password' => $helperData->getConfigurationAccountPass(),
568
+ 'skybillNumber' => $skybillNumber,
569
+ 'language' => Mage::app()->getLocale()->getLocaleCode()
570
+ );
571
+
572
+ return $client->cancelSkybill($params);
573
+ } catch (Exception $e) {
574
+ return false;
575
+ }
576
+ }
577
+ return false;
578
+ }
579
+
580
+ /* Livraison sur rendez-vous */
581
+ public function getSearchDeliverySlot($_srdvConfig = '') {
582
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
583
+
584
+ $_shippingAddress = $quote->getShippingAddress();
585
+ $recipient_address = $_shippingAddress->getStreet();
586
+ if (!isset($recipient_address[1])) {
587
+ $recipient_address[1] = '';
588
+ }
589
+
590
+ $_helper = Mage::helper('chronorelais');
591
+ try {
592
+
593
+ $soapHeaders = array();
594
+ $namespace = 'http://cxf.soap.ws.creneau.chronopost.fr/';
595
+ $soapHeaders[] = new SoapHeader($namespace, 'password', $_helper->getConfigurationAccountPass());
596
+ $soapHeaders[] = new SoapHeader($namespace, 'accountNumber', $_helper->getConfigurationAccountNumber());
597
+
598
+ $client = new SoapClient("https://www.chronopost.fr/rdv-cxf/services/CreneauServiceWS?wsdl", array('trace' => 1, 'connection_timeout' => 10));
599
+ $client->__setSoapHeaders($soapHeaders);
600
+
601
+ $_srdvConfig = json_decode($_srdvConfig,true);
602
+
603
+ /* definition date de debut */
604
+ $dateBegin = date('Y-m-d H:i:s');
605
+ if(isset($_srdvConfig['dateRemiseColis_nbJour']) && $_srdvConfig['dateRemiseColis_nbJour'] > 0) {
606
+ $dateBegin = date('Y-m-d', strtotime('+'.(int)$_srdvConfig['dateRemiseColis_nbJour'].' day'));
607
+ } elseif(isset($_srdvConfig['dateRemiseColis_jour']) && isset($_srdvConfig['dateRemiseColis_heures'])) {
608
+ $jour_text = date('l', strtotime("Sunday +".$_srdvConfig['dateRemiseColis_jour']." days"));
609
+ $dateBegin = date('Y-m-d', strtotime('next '.$jour_text)).' '.$_srdvConfig['dateRemiseColis_heures'].':'.$_srdvConfig['dateRemiseColis_minutes'].':00';
610
+ }
611
+ $dateBegin = date('Y-m-d',strtotime($dateBegin)).'T'.date('H:i:s',strtotime($dateBegin));
612
+
613
+ $params = array(
614
+
615
+ 'callerTool' => 'RDVWS',
616
+ 'productType' => 'RDV',
617
+
618
+ 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
619
+ 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
620
+ 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode'),
621
+ 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
622
+ 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
623
+
624
+ 'recipientAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
625
+ 'recipientAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
626
+ 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
627
+ 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
628
+ 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
629
+
630
+ 'weight' => 1,
631
+ 'dateBegin' => $dateBegin,
632
+ 'shipperDeliverySlotClosed' => '',
633
+ 'currency' => 'EUR',
634
+ 'isDeliveryDate' => 0,
635
+ 'slotType' => 'J'
636
+ );
637
+
638
+
639
+ for($i = 1; $i <= 4; $i++) {
640
+
641
+ /* tarif des niveaux tarifaires */
642
+ if(isset($_srdvConfig['N'.$i.'_price'])) {
643
+ $params['rateN'.$i] = $_srdvConfig['N'.$i.'_price'];
644
+ }
645
+
646
+ /* niveaux tarifaires fermés */
647
+ if(isset($_srdvConfig['N'.$i.'_status']) && $_srdvConfig['N'.$i.'_status'] == 0) {
648
+ if(!isset($params['rateLevelsNotShow'])) {
649
+ $params['rateLevelsNotShow'] = array();
650
+ }
651
+ $params['rateLevelsNotShow'][]= 'N'.$i;
652
+ }
653
+ }
654
+
655
+ /* creneaux à fermer */
656
+ if(isset($_srdvConfig['creneaux'])) {
657
+ foreach($_srdvConfig['creneaux'] as $_creneau) {
658
+
659
+ $jour_debut_text = date('l', Mage::getModel('core/date')->timestamp(strtotime("Sunday +".$_creneau['creneaux_debut_jour']." days")));
660
+ $jour_fin_text = date('l', Mage::getModel('core/date')->timestamp(strtotime("Sunday +".$_creneau['creneaux_fin_jour']." days")));
661
+
662
+ $dateDebut = '';
663
+ $dateFin = '';
664
+
665
+ /* creation de creneaux aux bons formats, pour 6 semaines consécutives */
666
+ for($indiceWeek = 0; $indiceWeek < 6; $indiceWeek++) {
667
+
668
+ if(empty($dateDebut)) {
669
+ $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';
670
+ $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';
671
+ if(date('N') >= $_creneau['creneaux_debut_jour']) {
672
+ $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';
673
+ }
674
+ if(date('N') >= $_creneau['creneaux_fin_jour']) {
675
+ $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';
676
+ }
677
+
678
+ } else {
679
+ $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';
680
+ $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';
681
+ }
682
+
683
+ $dateDebutStr = date('Y-m-d',Mage::getModel('core/date')->timestamp(strtotime($dateDebut))).'T'.date('H:i:s',Mage::getModel('core/date')->timestamp(strtotime($dateDebut)));
684
+ $dateFinStr = date('Y-m-d',Mage::getModel('core/date')->timestamp(strtotime($dateFin))).'T'.date('H:i:s',Mage::getModel('core/date')->timestamp(strtotime($dateFin)));
685
+
686
+ if(!isset($params['shipperDeliverySlotClosed'])) {
687
+ $params['shipperDeliverySlotClosed'] = array();
688
+ }
689
+ $params['shipperDeliverySlotClosed'][] = $dateDebutStr."/".$dateFinStr;
690
+ }
691
+ }
692
+ }
693
+
694
+ $webservbt = $client->searchDeliverySlot($params);
695
+ if($webservbt->return->code == 0) {
696
+ return $webservbt;
697
+ }
698
+ return false;
699
+ }catch(Exception $e) {
700
+ return false;
701
+ }
702
+ }
703
+
704
+ public function confirmDeliverySlot($rdvInfo = '') {
705
+ $_helper = Mage::helper('chronorelais');
706
+ try {
707
+
708
+ $soapHeaders = array();
709
+ $namespace = 'http://cxf.soap.ws.creneau.chronopost.fr/';
710
+ $soapHeaders[] = new SoapHeader($namespace, 'password', $_helper->getConfigurationAccountPass());
711
+ $soapHeaders[] = new SoapHeader($namespace, 'accountNumber', $_helper->getConfigurationAccountNumber());
712
+
713
+ $client = new SoapClient("https://www.chronopost.fr/rdv-cxf/services/CreneauServiceWS?wsdl", array('trace' => 1, 'connection_timeout' => 10));
714
+ $client->__setSoapHeaders($soapHeaders);
715
+
716
+ $params = array(
717
+ 'callerTool' => 'RDVWS',
718
+ 'productType' => 'RDV',
719
+
720
+ 'codeSlot' => $rdvInfo['deliverySlotCode'],
721
+ 'meshCode' => $rdvInfo['meshCode'],
722
+ 'transactionID' => $rdvInfo['transactionID'],
723
+ 'rank' => $rdvInfo['rank'],
724
+ 'position' => $rdvInfo['rank'],
725
+ 'dateSelected' => $rdvInfo['deliveryDate']
726
+ );
727
+
728
+ return $client->confirmDeliverySlot($params);
729
+ }catch(Exception $e) {
730
+ return false;
731
+ }
732
+ }
733
+ }
app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelais.php CHANGED
@@ -1,32 +1,32 @@
1
- <?php
2
- abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelais extends Varien_Object
3
- {
4
- protected $_code;
5
- protected $_rates = null;
6
- protected $_numBoxes = 1;
7
-
8
- /**
9
- * Whether this carrier has fixed rates calculation
10
- *
11
- * @var bool
12
- */
13
- protected $_isFixed = false;
14
-
15
- const HANDLING_TYPE_PERCENT = 'P';
16
- const HANDLING_TYPE_FIXED = 'F';
17
-
18
- const HANDLING_ACTION_PERPACKAGE = 'P';
19
- const HANDLING_ACTION_PERORDER = 'O';
20
-
21
- /**
22
- * Fields that should be replaced in debug with '***'
23
- *
24
- * @var array
25
- */
26
- protected $_debugReplacePrivateDataKeys = array();
27
-
28
- public function __construct()
29
- {
30
- }
31
- }
32
  ?>
1
+ <?php
2
+ abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelais extends Varien_Object
3
+ {
4
+ protected $_code;
5
+ protected $_rates = null;
6
+ protected $_numBoxes = 1;
7
+
8
+ /**
9
+ * Whether this carrier has fixed rates calculation
10
+ *
11
+ * @var bool
12
+ */
13
+ protected $_isFixed = false;
14
+
15
+ const HANDLING_TYPE_PERCENT = 'P';
16
+ const HANDLING_TYPE_FIXED = 'F';
17
+
18
+ const HANDLING_ACTION_PERPACKAGE = 'P';
19
+ const HANDLING_ACTION_PERORDER = 'O';
20
+
21
+ /**
22
+ * Fields that should be replaced in debug with '***'
23
+ *
24
+ * @var array
25
+ */
26
+ protected $_debugReplacePrivateDataKeys = array();
27
+
28
+ public function __construct()
29
+ {
30
+ }
31
+ }
32
  ?>
app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelaisShipping.php CHANGED
@@ -1,518 +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')) {
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
  ?>
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')) {
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,5 +1,5 @@
1
- <?php
2
- class Chronopost_Chronorelais_Model_Carrier_Chronoexpress extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
- {
4
- protected $_code = 'chronoexpress';
5
  }
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,5 +1,5 @@
1
- <?php
2
- class Chronopost_Chronorelais_Model_Carrier_Chronopost extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
- {
4
- protected $_code = 'chronopost';
5
  }
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
- protected $_checkContract = true;
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
- protected $_checkContract = true;
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
- protected $_checkContract = true;
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 CHANGED
@@ -1,33 +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
- }
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 CHANGED
@@ -1,85 +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
- }
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
- protected $_checkRelaiWs = true;
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 CHANGED
@@ -1,7 +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
- }
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 CHANGED
@@ -1,7 +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
  }
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 CHANGED
@@ -1,17 +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
- }
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
@@ -1,12 +1,12 @@
1
- <?php
2
- class Chronopost_Chronorelais_Model_Config_Source_Civility
3
- {
4
- public function toOptionArray()
5
- {
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
  }
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_Civility
3
+ {
4
+ public function toOptionArray()
5
+ {
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 CHANGED
@@ -1,16 +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
- }
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/EndOfLineCharacter.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
- class Chronopost_Chronorelais_Model_Config_Source_EndOfLineCharacter
3
- {
4
- public function toOptionArray()
5
- {
6
- return array(
7
- array('value'=>'lf', 'label'=>Mage::helper('chronorelais')->__('LF')),
8
- array('value'=>'cr', 'label'=>Mage::helper('chronorelais')->__('CR')),
9
- array('value'=>'crlf', 'label'=>Mage::helper('chronorelais')->__('CR+LF'))
10
- );
11
- }
12
- }
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_EndOfLineCharacter
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>'lf', 'label'=>Mage::helper('chronorelais')->__('LF')),
8
+ array('value'=>'cr', 'label'=>Mage::helper('chronorelais')->__('CR')),
9
+ array('value'=>'crlf', 'label'=>Mage::helper('chronorelais')->__('CR+LF'))
10
+ );
11
+ }
12
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/FieldDelimiter.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
- class Chronopost_Chronorelais_Model_Config_Source_FieldDelimiter
3
- {
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
  }
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_FieldDelimiter
3
+ {
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/FieldSeparator.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
- class Chronopost_Chronorelais_Model_Config_Source_FieldSeparator
3
- {
4
- public function toOptionArray()
5
- {
6
- return array(
7
- array('value'=>';', 'label'=>Mage::helper('chronorelais')->__('Semicolon')),
8
- array('value'=>',', 'label'=>Mage::helper('chronorelais')->__('Comma'))
9
- );
10
- }
11
- }
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_FieldSeparator
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>';', 'label'=>Mage::helper('chronorelais')->__('Semicolon')),
8
+ array('value'=>',', 'label'=>Mage::helper('chronorelais')->__('Comma'))
9
+ );
10
+ }
11
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/FileCharset.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
- class Chronopost_Chronorelais_Model_Config_Source_FileCharset
3
- {
4
- public function toOptionArray()
5
- {
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
  }
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_FileCharset
3
+ {
4
+ public function toOptionArray()
5
+ {
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
@@ -1,12 +1,12 @@
1
- <?php
2
- class Chronopost_Chronorelais_Model_Config_Source_FileExtension
3
- {
4
- public function toOptionArray()
5
- {
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
- }
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_FileExtension
3
+ {
4
+ public function toOptionArray()
5
+ {
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 CHANGED
@@ -1,13 +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
- }
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 CHANGED
@@ -1,11 +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
- }
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 CHANGED
@@ -1,13 +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
- }
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
@@ -1,12 +1,12 @@
1
- <?php
2
- class Chronopost_Chronorelais_Model_Config_Source_PrintMode
3
- {
4
- public function toOptionArray()
5
- {
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
- }
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_PrintMode
3
+ {
4
+ public function toOptionArray()
5
+ {
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 CHANGED
@@ -1,31 +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
- }
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/Config/Source/WeightUnit.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
- class Chronopost_Chronorelais_Model_Config_Source_WeightUnit
3
- {
4
- public function toOptionArray()
5
- {
6
- return array(
7
- array('value'=>'kg', 'label'=>Mage::helper('chronorelais')->__('Kilogramme')),
8
- array('value'=>'g', 'label'=>Mage::helper('chronorelais')->__('gramme')),
9
- );
10
- }
11
- }
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_WeightUnit
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>'kg', 'label'=>Mage::helper('chronorelais')->__('Kilogramme')),
8
+ array('value'=>'g', 'label'=>Mage::helper('chronorelais')->__('gramme')),
9
+ );
10
+ }
11
+ }
app/code/community/Chronopost/Chronorelais/Model/Observer.php CHANGED
@@ -1,271 +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
  }
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,206 +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
- $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
- }
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,206 +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
- $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
- }
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,432 +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
- }
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
- }
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,635 +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
- 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
  }
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
@@ -1,241 +1,241 @@
1
- <?php
2
- class Chronopost_Chronorelais_Adminhtml_Chronorelais_ImportController extends Mage_Adminhtml_Controller_Action
3
- {
4
-
5
- /**
6
- * Constructor
7
- */
8
- protected function _construct()
9
- {
10
- $this->setUsedModuleName('Chronopost_Chronorelais');
11
- }
12
-
13
- /**
14
- * Main action : show import form
15
- */
16
- public function indexAction()
17
- {
18
- $this->loadLayout()
19
- ->_setActiveMenu('sales/chronorelais/import')
20
- ->_addContent($this->getLayout()->createBlock('chronorelais/import_form'))
21
- ->renderLayout();
22
- }
23
-
24
- /**
25
- * Import Action
26
- */
27
- public function importAction()
28
- {
29
- if ($this->getRequest()->isPost() && !empty($_FILES['import_chronorelais_file']['tmp_name'])) {
30
- try {
31
- $trackingTitle = $_POST['import_chronorelais_tracking_title'];
32
- $this->_importChronorelaisFile($_FILES['import_chronorelais_file']['tmp_name'], $trackingTitle);
33
- }
34
- catch (Mage_Core_Exception $e) {
35
- $this->_getSession()->addError($e->getMessage());
36
- }
37
- catch (Exception $e) {
38
- $this->_getSession()->addError($e->getMessage());
39
- $this->_getSession()->addError($this->__('Invalid file upload attempt'));
40
- }
41
- }
42
- else {
43
- $this->_getSession()->addError($this->__('Invalid file upload attempt'));
44
- }
45
- $this->_redirect('*/*/index');
46
- }
47
-
48
- /**
49
- * Importation logic
50
- * @param string $fileName
51
- * @param string $trackingTitle
52
- */
53
- protected function _importChronorelaisFile($fileName, $trackingTitle)
54
- {
55
- /**
56
- * File handling
57
- **/
58
- ini_set('auto_detect_line_endings', true);
59
- $csvObject = new Varien_File_Csv();
60
- $csvData = $csvObject->getData($fileName);
61
-
62
- /**
63
- * File expected fields
64
- */
65
- $expectedCsvFields = array(
66
- 0 => $this->__('Order Id'),
67
- 1 => $this->__('Tracking Number')
68
- );
69
-
70
- /**
71
- * Get configuration
72
- */
73
- $sendEmail = Mage::helper('chronorelais')->getConfigurationSendEmail();
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
80
- */
81
- foreach ($csvData as $k => $v) {
82
-
83
- /**
84
- * End of file has more than one empty lines
85
- */
86
- if (count($v) <= 1 && !strlen($v[0])) {
87
- continue;
88
- }
89
-
90
- /**
91
- * Check that the number of fields is not lower than expected
92
- */
93
- if (count($v) < count($expectedCsvFields)) {
94
- $this->_getSession()->addError($this->__('Line %s format is invalid and has been ignored', $k));
95
- continue;
96
- }
97
-
98
- /**
99
- * Get fields content
100
- */
101
- $orderId = $v[0];
102
- $trackingNumber = $v[1];
103
-
104
- /**
105
- * Try to load the order
106
- */
107
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
108
- if (!$order->getId()) {
109
- $this->_getSession()->addError($this->__('Order %s does not exist', $orderId));
110
- continue;
111
- }
112
-
113
- /**
114
- * Try to create a shipment
115
- */
116
- $shipmentId = $this->_createShipment($order, $trackingNumber, $trackingTitle, $sendEmail, $comment, $includeComment);
117
-
118
- if ($shipmentId != 0) {
119
- $this->_getSession()->addSuccess($this->__('Shipment %s created for order %s, with tracking number %s', $shipmentId, $orderId, $trackingNumber));
120
- }
121
-
122
- }//foreach
123
-
124
- }
125
-
126
- /**
127
- * Create new shipment for order
128
- * Inspired by Mage_Sales_Model_Order_Shipment_Api methods
129
- *
130
- * @param Mage_Sales_Model_Order $order (it should exist, no control is done into the method)
131
- * @param string $trackingNumber
132
- * @param string $trackingTitle
133
- * @param booleam $email
134
- * @param string $comment
135
- * @param boolean $includeComment
136
- * @return int : shipment real id if creation was ok, else 0
137
- */
138
- public function _createShipment($order, $trackingNumber, $trackingTitle, $email, $comment, $includeComment)
139
- {
140
- /**
141
- * Check shipment creation availability
142
- */
143
- if (!$order->canShip()) {
144
- $this->_getSession()->addError($this->__('Order %s can not be shipped or has already been shipped', $order->getRealOrderId()));
145
- return 0;
146
- }
147
-
148
- /**
149
- * Initialize the Mage_Sales_Model_Order_Shipment object
150
- */
151
- $convertor = Mage::getModel('sales/convert_order');
152
- $shipment = $convertor->toShipment($order);
153
-
154
- /**
155
- * Add the items to send
156
- */
157
- foreach ($order->getAllItems() as $orderItem) {
158
- if (!$orderItem->getQtyToShip()) {
159
- continue;
160
- }
161
- if ($orderItem->getIsVirtual()) {
162
- continue;
163
- }
164
-
165
- $item = $convertor->itemToShipmentItem($orderItem);
166
- $qty = $orderItem->getQtyToShip();
167
- $item->setQty($qty);
168
-
169
- $shipment->addItem($item);
170
- }//foreach
171
-
172
- $shipment->register();
173
-
174
- /**
175
- * Tracking number instanciation
176
- */
177
-
178
- $_shippingMethod = explode("_",$order->getShippingMethod());
179
- switch($_shippingMethod[0]) {
180
- case "chronopost":
181
- case "chronorelais":
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>';
188
- break;
189
- default:
190
- $carrier_code = 'custom';
191
- $popup = 0;
192
- $tracking_order = '';
193
- break;
194
- }
195
-
196
- $track = Mage::getModel('sales/order_shipment_track')
197
- ->setNumber($trackingNumber) //setTrackingNumber ?
198
- ->setCarrierCode($carrier_code)
199
- ->setTitle($trackingTitle)
200
- ->setPopup($popup);
201
- $shipment->addTrack($track);
202
-
203
- /**
204
- * Comment handling
205
- */
206
- $shipment->addComment($comment, $email && $includeComment);
207
-
208
- /**
209
- * Change order status to Processing
210
- */
211
- $shipment->getOrder()->setIsInProcess(true);
212
-
213
- /**
214
- * If e-mail, set as sent (must be done before shipment object saving)
215
- */
216
- if ($email) {
217
- $shipment->setEmailSent(true);
218
- }
219
-
220
- try {
221
- /**
222
- * Save the created shipment and the updated order
223
- */
224
- $shipment->save();
225
- $shipment->getOrder()->save();
226
-
227
- /**
228
- * Email sending
229
- */
230
- $shipment->sendEmail($email, ($includeComment ? $tracking_order.$comment : $tracking_order));
231
- } catch (Mage_Core_Exception $e) {
232
- $this->_getSession()->addError($this->__('Shipment creation error for Order %s : %s', $orderId, $e->getMessage()));
233
- return 0;
234
- }
235
-
236
- /**
237
- * Everything was ok : return Shipment real id
238
- */
239
- return $shipment->getIncrementId();
240
- }
241
  }
1
+ <?php
2
+ class Chronopost_Chronorelais_Adminhtml_Chronorelais_ImportController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+
5
+ /**
6
+ * Constructor
7
+ */
8
+ protected function _construct()
9
+ {
10
+ $this->setUsedModuleName('Chronopost_Chronorelais');
11
+ }
12
+
13
+ /**
14
+ * Main action : show import form
15
+ */
16
+ public function indexAction()
17
+ {
18
+ $this->loadLayout()
19
+ ->_setActiveMenu('sales/chronorelais/import')
20
+ ->_addContent($this->getLayout()->createBlock('chronorelais/import_form'))
21
+ ->renderLayout();
22
+ }
23
+
24
+ /**
25
+ * Import Action
26
+ */
27
+ public function importAction()
28
+ {
29
+ if ($this->getRequest()->isPost() && !empty($_FILES['import_chronorelais_file']['tmp_name'])) {
30
+ try {
31
+ $trackingTitle = $_POST['import_chronorelais_tracking_title'];
32
+ $this->_importChronorelaisFile($_FILES['import_chronorelais_file']['tmp_name'], $trackingTitle);
33
+ }
34
+ catch (Mage_Core_Exception $e) {
35
+ $this->_getSession()->addError($e->getMessage());
36
+ }
37
+ catch (Exception $e) {
38
+ $this->_getSession()->addError($e->getMessage());
39
+ $this->_getSession()->addError($this->__('Invalid file upload attempt'));
40
+ }
41
+ }
42
+ else {
43
+ $this->_getSession()->addError($this->__('Invalid file upload attempt'));
44
+ }
45
+ $this->_redirect('*/*/index');
46
+ }
47
+
48
+ /**
49
+ * Importation logic
50
+ * @param string $fileName
51
+ * @param string $trackingTitle
52
+ */
53
+ protected function _importChronorelaisFile($fileName, $trackingTitle)
54
+ {
55
+ /**
56
+ * File handling
57
+ **/
58
+ ini_set('auto_detect_line_endings', true);
59
+ $csvObject = new Varien_File_Csv();
60
+ $csvData = $csvObject->getData($fileName);
61
+
62
+ /**
63
+ * File expected fields
64
+ */
65
+ $expectedCsvFields = array(
66
+ 0 => $this->__('Order Id'),
67
+ 1 => $this->__('Tracking Number')
68
+ );
69
+
70
+ /**
71
+ * Get configuration
72
+ */
73
+ $sendEmail = Mage::helper('chronorelais')->getConfigurationSendEmail();
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
80
+ */
81
+ foreach ($csvData as $k => $v) {
82
+
83
+ /**
84
+ * End of file has more than one empty lines
85
+ */
86
+ if (count($v) <= 1 && !strlen($v[0])) {
87
+ continue;
88
+ }
89
+
90
+ /**
91
+ * Check that the number of fields is not lower than expected
92
+ */
93
+ if (count($v) < count($expectedCsvFields)) {
94
+ $this->_getSession()->addError($this->__('Line %s format is invalid and has been ignored', $k));
95
+ continue;
96
+ }
97
+
98
+ /**
99
+ * Get fields content
100
+ */
101
+ $orderId = $v[0];
102
+ $trackingNumber = $v[1];
103
+
104
+ /**
105
+ * Try to load the order
106
+ */
107
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
108
+ if (!$order->getId()) {
109
+ $this->_getSession()->addError($this->__('Order %s does not exist', $orderId));
110
+ continue;
111
+ }
112
+
113
+ /**
114
+ * Try to create a shipment
115
+ */
116
+ $shipmentId = $this->_createShipment($order, $trackingNumber, $trackingTitle, $sendEmail, $comment, $includeComment);
117
+
118
+ if ($shipmentId != 0) {
119
+ $this->_getSession()->addSuccess($this->__('Shipment %s created for order %s, with tracking number %s', $shipmentId, $orderId, $trackingNumber));
120
+ }
121
+
122
+ }//foreach
123
+
124
+ }
125
+
126
+ /**
127
+ * Create new shipment for order
128
+ * Inspired by Mage_Sales_Model_Order_Shipment_Api methods
129
+ *
130
+ * @param Mage_Sales_Model_Order $order (it should exist, no control is done into the method)
131
+ * @param string $trackingNumber
132
+ * @param string $trackingTitle
133
+ * @param booleam $email
134
+ * @param string $comment
135
+ * @param boolean $includeComment
136
+ * @return int : shipment real id if creation was ok, else 0
137
+ */
138
+ public function _createShipment($order, $trackingNumber, $trackingTitle, $email, $comment, $includeComment)
139
+ {
140
+ /**
141
+ * Check shipment creation availability
142
+ */
143
+ if (!$order->canShip()) {
144
+ $this->_getSession()->addError($this->__('Order %s can not be shipped or has already been shipped', $order->getRealOrderId()));
145
+ return 0;
146
+ }
147
+
148
+ /**
149
+ * Initialize the Mage_Sales_Model_Order_Shipment object
150
+ */
151
+ $convertor = Mage::getModel('sales/convert_order');
152
+ $shipment = $convertor->toShipment($order);
153
+
154
+ /**
155
+ * Add the items to send
156
+ */
157
+ foreach ($order->getAllItems() as $orderItem) {
158
+ if (!$orderItem->getQtyToShip()) {
159
+ continue;
160
+ }
161
+ if ($orderItem->getIsVirtual()) {
162
+ continue;
163
+ }
164
+
165
+ $item = $convertor->itemToShipmentItem($orderItem);
166
+ $qty = $orderItem->getQtyToShip();
167
+ $item->setQty($qty);
168
+
169
+ $shipment->addItem($item);
170
+ }//foreach
171
+
172
+ $shipment->register();
173
+
174
+ /**
175
+ * Tracking number instanciation
176
+ */
177
+
178
+ $_shippingMethod = explode("_",$order->getShippingMethod());
179
+ switch($_shippingMethod[0]) {
180
+ case "chronopost":
181
+ case "chronorelais":
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>';
188
+ break;
189
+ default:
190
+ $carrier_code = 'custom';
191
+ $popup = 0;
192
+ $tracking_order = '';
193
+ break;
194
+ }
195
+
196
+ $track = Mage::getModel('sales/order_shipment_track')
197
+ ->setNumber($trackingNumber) //setTrackingNumber ?
198
+ ->setCarrierCode($carrier_code)
199
+ ->setTitle($trackingTitle)
200
+ ->setPopup($popup);
201
+ $shipment->addTrack($track);
202
+
203
+ /**
204
+ * Comment handling
205
+ */
206
+ $shipment->addComment($comment, $email && $includeComment);
207
+
208
+ /**
209
+ * Change order status to Processing
210
+ */
211
+ $shipment->getOrder()->setIsInProcess(true);
212
+
213
+ /**
214
+ * If e-mail, set as sent (must be done before shipment object saving)
215
+ */
216
+ if ($email) {
217
+ $shipment->setEmailSent(true);
218
+ }
219
+
220
+ try {
221
+ /**
222
+ * Save the created shipment and the updated order
223
+ */
224
+ $shipment->save();
225
+ $shipment->getOrder()->save();
226
+
227
+ /**
228
+ * Email sending
229
+ */
230
+ $shipment->sendEmail($email, ($includeComment ? $tracking_order.$comment : $tracking_order));
231
+ } catch (Mage_Core_Exception $e) {
232
+ $this->_getSession()->addError($this->__('Shipment creation error for Order %s : %s', $orderId, $e->getMessage()));
233
+ return 0;
234
+ }
235
+
236
+ /**
237
+ * Everything was ok : return Shipment real id
238
+ */
239
+ return $shipment->getIncrementId();
240
+ }
241
  }
app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/Sales/BordereauController.php CHANGED
@@ -1,329 +1,329 @@
1
- <?php
2
-
3
- require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';
4
-
5
- class Chronopost_Chronorelais_Adminhtml_Chronorelais_Sales_BordereauController extends Mage_Adminhtml_Sales_OrderController {
6
-
7
- /**
8
- * Additional initialization
9
- *
10
- */
11
- protected function _construct() {
12
- $this->setUsedModuleName('Chronopost_Chronorelais');
13
- }
14
-
15
- /**
16
- * Order grid
17
- */
18
- public function indexAction() {
19
- if (!extension_loaded('soap')) {
20
- $this->_getSession()->addError($this->__('The SOAP extension is not installed in the server. Please contact the site administrator. Sorry for inconvenience.'));
21
- return $this->_redirectReferer();
22
- }
23
- $this->loadLayout()
24
- ->_setActiveMenu('sales/chronorelais')
25
- ->_addContent($this->getLayout()->createBlock('chronorelais/sales_bordereau'))
26
- ->renderLayout();
27
- }
28
-
29
- public function massPrintBordereauAction() {
30
- $orderIds = $this->getRequest()->getPost('order_ids');
31
- try {
32
-
33
- $weightNational = 0;
34
- $nbNational = 0;
35
- $weightInternational = 0;
36
- $nbInternational = 0;
37
-
38
- $helper = Mage::helper('chronorelais');
39
-
40
- /* Shipper */
41
- $shipper = array(
42
- 'accountNumber' => $helper->getConfigurationAccountNumber(),
43
- 'name' => $helper->getConfigurationShipperInfo('name'),
44
- 'address1' => $helper->getConfigurationShipperInfo('address1'),
45
- 'address2' => $helper->getConfigurationShipperInfo('address2'),
46
- 'city' => $helper->getConfigurationShipperInfo('city'),
47
- 'postcode' => $helper->getConfigurationShipperInfo('zipcode'),
48
- 'country' => $helper->getConfigurationShipperInfo('country'),
49
- 'phone' => $helper->getConfigurationShipperInfo('phone'),
50
- );
51
-
52
- $detail = '';
53
- $resume = '';
54
- foreach($orderIds as $orderId) {
55
- $order = Mage::getModel('sales/order')->load($orderId);
56
- $_shippingMethod = explode("_", $order->getShippingMethod());
57
- $productCode = 'Chrono '.$helper->getChronoProductCodeStringWithBAL($_shippingMethod[0]);
58
- $shipments = $order->getShipmentsCollection();
59
- foreach($shipments as $shipment) {
60
-
61
- /* Tracking Number */
62
- $trackNumber = $this->getTrackingNumber($shipment->getId());
63
-
64
- /* items */
65
- $items = $shipment->getAllItems();
66
- $weightTotal = 0;
67
-
68
- $maxAmount = $helper->getMaxAdValoremAmount();
69
- $adValoremAmount = $helper->assuranceAdValoremAmount();
70
- $adValoremEnabled = $helper->assuranceAdValoremEnabled();
71
- $totalAdValorem = 0;
72
-
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 */
88
- $address = Mage::getModel('sales/order_address')->load($shipment->getShippingAddressId());
89
- if($address->getCountryId() == 'FR') {
90
- $weightNational += $weightTotal;
91
- $nbNational++;
92
- }
93
- else {
94
- $weightInternational += $weightTotal;
95
- $nbInternational++;
96
- }
97
-
98
- $detail[] = array(
99
- 'trackNumber' => $trackNumber,
100
- 'weight' => $weightTotal,
101
- 'product_code' => $productCode,
102
- 'postcode' => $address->getPostcode(),
103
- 'country' => $address->getCountryId(),
104
- 'assurance' => $totalAdValorem,
105
- 'city' => Mage::helper('core/string')->truncate($address->getCity(),17),
106
- );
107
- }
108
- }
109
- $resume = array(
110
- 'NATIONAL' => array('unite' => $nbNational, 'poids' => $weightNational),
111
- 'INTERNATIONAL' => array('unite' => $nbInternational, 'poids' => $weightInternational),
112
- 'TOTAL' => array('unite' => ($nbNational+$nbInternational), 'poids' => ($weightNational+$weightInternational)),
113
- );
114
-
115
- /* Create pdf */
116
- $fileName = 'bordereau.pdf';
117
- $content = $this->getPdfFile($shipper,$detail,$resume);
118
- $this->_prepareDownloadResponse($fileName, $content);
119
-
120
- } catch (Mage_Core_Exception $e) {
121
- $this->_getSession()->addError(Mage::helper('chronorelais')->__('Désolé, une erreur est survenu lors de la génération des bordereau. Merci de contacter Chronopost ou de réessayer plus tard'));
122
- }
123
- }
124
-
125
- protected function getPdfFile($shipper,$detail,$resume) {
126
- $pdf = new Zend_Pdf();
127
- $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
128
-
129
- $helper = Mage::helper('chronorelais');
130
- $weightUnit = $helper->getConfigWeightUnit();
131
-
132
- $minYPosToChangePage = 60;
133
- $xPos = 20;
134
- $yPos = $page->getHeight()-20;
135
- $lineHeight = 15;
136
-
137
- $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
138
- $fontBold = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
139
-
140
- /* DATE */
141
- $page->setFont($font, 11);
142
- $page->drawText('date : '.date('d/m/Y'), $page->getWidth()-100, $yPos);
143
- $yPos -= ($lineHeight);
144
- $page->setFont($font, 12);
145
-
146
- /* TITRE */
147
- $page->setFont($fontBold, 12);
148
- $page->drawText('BORDEREAU RECAPITULATIF', $xPos, $yPos);
149
- $yPos -= ($lineHeight+20);
150
- $page->setFont($font, 12);
151
-
152
-
153
- /* EMETTEUR */
154
- $page->setFont($fontBold, 12);
155
- $page->drawText('EMETTEUR: ', $xPos, $yPos);
156
- $yPos -= ($lineHeight+5);
157
- $page->setFont($font, 12);
158
-
159
- $page->drawText('NUMERO DE COMPTE', $xPos, $yPos);
160
- $page->drawText($shipper['accountNumber'], $xPos+150, $yPos);
161
- $yPos -= $lineHeight;
162
-
163
- $page->drawText('NOM', $xPos, $yPos);
164
- $page->drawText($shipper['name'], $xPos+150, $yPos);
165
- $yPos -= $lineHeight;
166
-
167
- $page->drawText('ADRESSE', $xPos, $yPos);
168
- $page->drawText($shipper['address1'], $xPos+150, $yPos);
169
- $yPos -= $lineHeight;
170
-
171
- $page->drawText('ADRESSE (SUITE)', $xPos, $yPos);
172
- $page->drawText($shipper['address2'], $xPos+150, $yPos);
173
- $yPos -= $lineHeight;
174
-
175
- $page->drawText('VILLE', $xPos, $yPos);
176
- $page->drawText($shipper['city'], $xPos+150, $yPos);
177
- $yPos -= $lineHeight;
178
-
179
- $page->drawText('CODE POSTAL', $xPos, $yPos);
180
- $page->drawText($shipper['postcode'], $xPos+150, $yPos);
181
- $yPos -= $lineHeight;
182
-
183
- $page->drawText('PAYS', $xPos, $yPos);
184
- $page->drawText($shipper['country'], $xPos+150, $yPos);
185
- $yPos -= $lineHeight;
186
-
187
- $page->drawText('TELEPHONE', $xPos, $yPos);
188
- $page->drawText($shipper['phone'], $xPos+150, $yPos);
189
- $yPos -= $lineHeight;
190
-
191
- $page->drawText('POSTE COMPTABLE', $xPos, $yPos);
192
- $page->drawText(substr($shipper['postcode'],0,2).'999', $xPos+150, $yPos);
193
- $yPos -= $lineHeight;
194
-
195
- /* DETAIL DES ENVOIS */
196
- $yPos -= 50;
197
- $page->setFont($fontBold, 12);
198
- $page->drawText('DETAIL DES ENVOIS ', $xPos, $yPos);
199
- $yPos -= ($lineHeight+5);
200
- $page->setFont($font, 12);
201
-
202
- $page->setFillColor(new Zend_Pdf_Color_Rgb(0.85, 0.85, 0.85));
203
- $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
204
- $page->setLineWidth(0.5);
205
- $page->drawRectangle($xPos, $yPos, 570, $yPos -20);
206
- $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
207
- $yPos -= 15;
208
-
209
- $page->drawText("Numéro de LT", $xPos+5, $yPos,'UTF-8');
210
- $page->drawText('Poids (kg)', $xPos+110, $yPos);
211
- $page->drawText('Code produit', $xPos+170, $yPos);
212
- $page->drawText('Code postal', $xPos+270, $yPos);
213
- $page->drawText('Pays', $xPos+340, $yPos);
214
- $page->drawText('Assurance', $xPos+380, $yPos);
215
- $page->drawText('Ville', $xPos+440, $yPos);
216
- $yPos -= 5;
217
-
218
- foreach($detail as $line) {
219
-
220
- $page->setFillColor(new Zend_Pdf_Color_Rgb(255, 255, 255));
221
- $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
222
- $page->setLineWidth(0.5);
223
- $page->drawRectangle($xPos, $yPos, 570, $yPos -20);
224
- $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
225
- $yPos -= 15;
226
-
227
- $lineWeight = $line['weight'];
228
- if($weightUnit == 'g') {
229
- $lineWeight = $lineWeight / 1000;
230
- }
231
-
232
- $page->drawText($line['trackNumber'], $xPos+5, $yPos,'UTF-8');
233
- $page->drawText($lineWeight, $xPos+110, $yPos);
234
- $page->drawText($line['product_code'], $xPos+170, $yPos);
235
- $page->drawText($line['postcode'], $xPos+270, $yPos);
236
- $page->drawText($line['country'], $xPos+340, $yPos);
237
- $page->drawText($line['assurance'], $xPos+380, $yPos);
238
- $page->drawText($line['city'], $xPos+440, $yPos,'UTF-8');
239
- $yPos -= 5;
240
-
241
- if($yPos <= $minYPosToChangePage) {
242
- $pdf->pages[] = $page;
243
- $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
244
- $yPos = $page->getHeight()-20;
245
- }
246
- }
247
-
248
- /* RESUME */
249
- $yPos -= 50;
250
- $page->setFont($fontBold, 12);
251
- $page->drawText('RESUME ', $xPos, $yPos);
252
- $yPos -= ($lineHeight+5);
253
- $page->setFont($font, 12);
254
-
255
- $page->setFillColor(new Zend_Pdf_Color_Rgb(0.85, 0.85, 0.85));
256
- $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
257
- $page->setLineWidth(0.5);
258
- $page->drawRectangle($xPos, $yPos, 570, $yPos -20);
259
- $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
260
- $yPos -= 15;
261
-
262
- $page->drawText("DESTINATION", $xPos+5, $yPos,'UTF-8');
263
- $page->drawText('UNITE', $xPos+170, $yPos);
264
- $page->drawText('POIDS TOTAL (kg)', $xPos+320, $yPos);
265
- $yPos -= 5;
266
-
267
- foreach($resume as $destination => $line) {
268
-
269
- $page->setFillColor(new Zend_Pdf_Color_Rgb(255, 255, 255));
270
- $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
271
- $page->setLineWidth(0.5);
272
- $page->drawRectangle($xPos, $yPos, 570, $yPos -20);
273
- $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
274
- $yPos -= 15;
275
-
276
- $lineWeight = $line['poids'];
277
- if($weightUnit == 'g') {
278
- $lineWeight = $lineWeight / 1000;
279
- }
280
-
281
- $page->drawText($destination, $xPos+5, $yPos,'UTF-8');
282
- $page->drawText($line['unite'], $xPos+180, $yPos);
283
- $page->drawText($lineWeight, $xPos+340, $yPos);
284
- $yPos -= 5;
285
- }
286
-
287
- if($yPos <= $minYPosToChangePage) {
288
- $pdf->pages[] = $page;
289
- $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
290
- $yPos = $page->getHeight()-20;
291
- }
292
-
293
- $yPos -= 50;
294
- $page->setFont($fontBold, 12);
295
- $page->drawText('Bien pris en charge '.$resume['TOTAL']['unite'].' colis', $xPos, $yPos);
296
-
297
- if($yPos <= $minYPosToChangePage) {
298
- $pdf->pages[] = $page;
299
- $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
300
- $yPos = $page->getHeight()-20;
301
- }
302
-
303
- /* signatures */
304
- $yPos -= 60;
305
- $page->setFont($font, 12);
306
- $page->drawText('Signature du client', $xPos, $yPos);
307
- $page->drawText('Signature du Messager Chronopost', 400, $yPos);
308
-
309
-
310
-
311
- $pdf->pages[] = $page;
312
- return $pdf->render();
313
- }
314
-
315
-
316
- protected function getTrackingNumber($shipmentId) {
317
- $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
318
- $trackNumber = '';
319
- //On récupère le numéro de tracking
320
- $tracks = $shipment->getTracksCollection();
321
- foreach ($tracks as $track) {
322
- if ($track->getParentId() == $shipmentId) {
323
- $trackNumber = $track->getnumber();
324
- }
325
- }
326
-
327
- return $trackNumber;
328
- }
329
  }
1
+ <?php
2
+
3
+ require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';
4
+
5
+ class Chronopost_Chronorelais_Adminhtml_Chronorelais_Sales_BordereauController extends Mage_Adminhtml_Sales_OrderController {
6
+
7
+ /**
8
+ * Additional initialization
9
+ *
10
+ */
11
+ protected function _construct() {
12
+ $this->setUsedModuleName('Chronopost_Chronorelais');
13
+ }
14
+
15
+ /**
16
+ * Order grid
17
+ */
18
+ public function indexAction() {
19
+ if (!extension_loaded('soap')) {
20
+ $this->_getSession()->addError($this->__('The SOAP extension is not installed in the server. Please contact the site administrator. Sorry for inconvenience.'));
21
+ return $this->_redirectReferer();
22
+ }
23
+ $this->loadLayout()
24
+ ->_setActiveMenu('sales/chronorelais')
25
+ ->_addContent($this->getLayout()->createBlock('chronorelais/sales_bordereau'))
26
+ ->renderLayout();
27
+ }
28
+
29
+ public function massPrintBordereauAction() {
30
+ $orderIds = $this->getRequest()->getPost('order_ids');
31
+ try {
32
+
33
+ $weightNational = 0;
34
+ $nbNational = 0;
35
+ $weightInternational = 0;
36
+ $nbInternational = 0;
37
+
38
+ $helper = Mage::helper('chronorelais');
39
+
40
+ /* Shipper */
41
+ $shipper = array(
42
+ 'accountNumber' => $helper->getConfigurationAccountNumber(),
43
+ 'name' => $helper->getConfigurationShipperInfo('name'),
44
+ 'address1' => $helper->getConfigurationShipperInfo('address1'),
45
+ 'address2' => $helper->getConfigurationShipperInfo('address2'),
46
+ 'city' => $helper->getConfigurationShipperInfo('city'),
47
+ 'postcode' => $helper->getConfigurationShipperInfo('zipcode'),
48
+ 'country' => $helper->getConfigurationShipperInfo('country'),
49
+ 'phone' => $helper->getConfigurationShipperInfo('phone'),
50
+ );
51
+
52
+ $detail = '';
53
+ $resume = '';
54
+ foreach($orderIds as $orderId) {
55
+ $order = Mage::getModel('sales/order')->load($orderId);
56
+ $_shippingMethod = explode("_", $order->getShippingMethod());
57
+ $productCode = 'Chrono '.$helper->getChronoProductCodeStringWithBAL($_shippingMethod[0]);
58
+ $shipments = $order->getShipmentsCollection();
59
+ foreach($shipments as $shipment) {
60
+
61
+ /* Tracking Number */
62
+ $trackNumber = $this->getTrackingNumber($shipment->getId());
63
+
64
+ /* items */
65
+ $items = $shipment->getAllItems();
66
+ $weightTotal = 0;
67
+
68
+ $maxAmount = $helper->getMaxAdValoremAmount();
69
+ $adValoremAmount = $helper->assuranceAdValoremAmount();
70
+ $adValoremEnabled = $helper->assuranceAdValoremEnabled();
71
+ $totalAdValorem = 0;
72
+
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 */
88
+ $address = Mage::getModel('sales/order_address')->load($shipment->getShippingAddressId());
89
+ if($address->getCountryId() == 'FR') {
90
+ $weightNational += $weightTotal;
91
+ $nbNational++;
92
+ }
93
+ else {
94
+ $weightInternational += $weightTotal;
95
+ $nbInternational++;
96
+ }
97
+
98
+ $detail[] = array(
99
+ 'trackNumber' => $trackNumber,
100
+ 'weight' => $weightTotal,
101
+ 'product_code' => $productCode,
102
+ 'postcode' => $address->getPostcode(),
103
+ 'country' => $address->getCountryId(),
104
+ 'assurance' => $totalAdValorem,
105
+ 'city' => Mage::helper('core/string')->truncate($address->getCity(),17),
106
+ );
107
+ }
108
+ }
109
+ $resume = array(
110
+ 'NATIONAL' => array('unite' => $nbNational, 'poids' => $weightNational),
111
+ 'INTERNATIONAL' => array('unite' => $nbInternational, 'poids' => $weightInternational),
112
+ 'TOTAL' => array('unite' => ($nbNational+$nbInternational), 'poids' => ($weightNational+$weightInternational)),
113
+ );
114
+
115
+ /* Create pdf */
116
+ $fileName = 'bordereau.pdf';
117
+ $content = $this->getPdfFile($shipper,$detail,$resume);
118
+ $this->_prepareDownloadResponse($fileName, $content);
119
+
120
+ } catch (Mage_Core_Exception $e) {
121
+ $this->_getSession()->addError(Mage::helper('chronorelais')->__('Désolé, une erreur est survenu lors de la génération des bordereau. Merci de contacter Chronopost ou de réessayer plus tard'));
122
+ }
123
+ }
124
+
125
+ protected function getPdfFile($shipper,$detail,$resume) {
126
+ $pdf = new Zend_Pdf();
127
+ $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
128
+
129
+ $helper = Mage::helper('chronorelais');
130
+ $weightUnit = $helper->getConfigWeightUnit();
131
+
132
+ $minYPosToChangePage = 60;
133
+ $xPos = 20;
134
+ $yPos = $page->getHeight()-20;
135
+ $lineHeight = 15;
136
+
137
+ $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
138
+ $fontBold = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
139
+
140
+ /* DATE */
141
+ $page->setFont($font, 11);
142
+ $page->drawText('date : '.date('d/m/Y'), $page->getWidth()-100, $yPos);
143
+ $yPos -= ($lineHeight);
144
+ $page->setFont($font, 12);
145
+
146
+ /* TITRE */
147
+ $page->setFont($fontBold, 12);
148
+ $page->drawText('BORDEREAU RECAPITULATIF', $xPos, $yPos);
149
+ $yPos -= ($lineHeight+20);
150
+ $page->setFont($font, 12);
151
+
152
+
153
+ /* EMETTEUR */
154
+ $page->setFont($fontBold, 12);
155
+ $page->drawText('EMETTEUR: ', $xPos, $yPos);
156
+ $yPos -= ($lineHeight+5);
157
+ $page->setFont($font, 12);
158
+
159
+ $page->drawText('NUMERO DE COMPTE', $xPos, $yPos);
160
+ $page->drawText($shipper['accountNumber'], $xPos+150, $yPos);
161
+ $yPos -= $lineHeight;
162
+
163
+ $page->drawText('NOM', $xPos, $yPos);
164
+ $page->drawText($shipper['name'], $xPos+150, $yPos);
165
+ $yPos -= $lineHeight;
166
+
167
+ $page->drawText('ADRESSE', $xPos, $yPos);
168
+ $page->drawText($shipper['address1'], $xPos+150, $yPos);
169
+ $yPos -= $lineHeight;
170
+
171
+ $page->drawText('ADRESSE (SUITE)', $xPos, $yPos);
172
+ $page->drawText($shipper['address2'], $xPos+150, $yPos);
173
+ $yPos -= $lineHeight;
174
+
175
+ $page->drawText('VILLE', $xPos, $yPos);
176
+ $page->drawText($shipper['city'], $xPos+150, $yPos);
177
+ $yPos -= $lineHeight;
178
+
179
+ $page->drawText('CODE POSTAL', $xPos, $yPos);
180
+ $page->drawText($shipper['postcode'], $xPos+150, $yPos);
181
+ $yPos -= $lineHeight;
182
+
183
+ $page->drawText('PAYS', $xPos, $yPos);
184
+ $page->drawText($shipper['country'], $xPos+150, $yPos);
185
+ $yPos -= $lineHeight;
186
+
187
+ $page->drawText('TELEPHONE', $xPos, $yPos);
188
+ $page->drawText($shipper['phone'], $xPos+150, $yPos);
189
+ $yPos -= $lineHeight;
190
+
191
+ $page->drawText('POSTE COMPTABLE', $xPos, $yPos);
192
+ $page->drawText(substr($shipper['postcode'],0,2).'999', $xPos+150, $yPos);
193
+ $yPos -= $lineHeight;
194
+
195
+ /* DETAIL DES ENVOIS */
196
+ $yPos -= 50;
197
+ $page->setFont($fontBold, 12);
198
+ $page->drawText('DETAIL DES ENVOIS ', $xPos, $yPos);
199
+ $yPos -= ($lineHeight+5);
200
+ $page->setFont($font, 12);
201
+
202
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(0.85, 0.85, 0.85));
203
+ $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
204
+ $page->setLineWidth(0.5);
205
+ $page->drawRectangle($xPos, $yPos, 570, $yPos -20);
206
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
207
+ $yPos -= 15;
208
+
209
+ $page->drawText("Numéro de LT", $xPos+5, $yPos,'UTF-8');
210
+ $page->drawText('Poids (kg)', $xPos+110, $yPos);
211
+ $page->drawText('Code produit', $xPos+170, $yPos);
212
+ $page->drawText('Code postal', $xPos+270, $yPos);
213
+ $page->drawText('Pays', $xPos+340, $yPos);
214
+ $page->drawText('Assurance', $xPos+380, $yPos);
215
+ $page->drawText('Ville', $xPos+440, $yPos);
216
+ $yPos -= 5;
217
+
218
+ foreach($detail as $line) {
219
+
220
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(255, 255, 255));
221
+ $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
222
+ $page->setLineWidth(0.5);
223
+ $page->drawRectangle($xPos, $yPos, 570, $yPos -20);
224
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
225
+ $yPos -= 15;
226
+
227
+ $lineWeight = $line['weight'];
228
+ if($weightUnit == 'g') {
229
+ $lineWeight = $lineWeight / 1000;
230
+ }
231
+
232
+ $page->drawText($line['trackNumber'], $xPos+5, $yPos,'UTF-8');
233
+ $page->drawText($lineWeight, $xPos+110, $yPos);
234
+ $page->drawText($line['product_code'], $xPos+170, $yPos);
235
+ $page->drawText($line['postcode'], $xPos+270, $yPos);
236
+ $page->drawText($line['country'], $xPos+340, $yPos);
237
+ $page->drawText($line['assurance'], $xPos+380, $yPos);
238
+ $page->drawText($line['city'], $xPos+440, $yPos,'UTF-8');
239
+ $yPos -= 5;
240
+
241
+ if($yPos <= $minYPosToChangePage) {
242
+ $pdf->pages[] = $page;
243
+ $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
244
+ $yPos = $page->getHeight()-20;
245
+ }
246
+ }
247
+
248
+ /* RESUME */
249
+ $yPos -= 50;
250
+ $page->setFont($fontBold, 12);
251
+ $page->drawText('RESUME ', $xPos, $yPos);
252
+ $yPos -= ($lineHeight+5);
253
+ $page->setFont($font, 12);
254
+
255
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(0.85, 0.85, 0.85));
256
+ $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
257
+ $page->setLineWidth(0.5);
258
+ $page->drawRectangle($xPos, $yPos, 570, $yPos -20);
259
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
260
+ $yPos -= 15;
261
+
262
+ $page->drawText("DESTINATION", $xPos+5, $yPos,'UTF-8');
263
+ $page->drawText('UNITE', $xPos+170, $yPos);
264
+ $page->drawText('POIDS TOTAL (kg)', $xPos+320, $yPos);
265
+ $yPos -= 5;
266
+
267
+ foreach($resume as $destination => $line) {
268
+
269
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(255, 255, 255));
270
+ $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
271
+ $page->setLineWidth(0.5);
272
+ $page->drawRectangle($xPos, $yPos, 570, $yPos -20);
273
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
274
+ $yPos -= 15;
275
+
276
+ $lineWeight = $line['poids'];
277
+ if($weightUnit == 'g') {
278
+ $lineWeight = $lineWeight / 1000;
279
+ }
280
+
281
+ $page->drawText($destination, $xPos+5, $yPos,'UTF-8');
282
+ $page->drawText($line['unite'], $xPos+180, $yPos);
283
+ $page->drawText($lineWeight, $xPos+340, $yPos);
284
+ $yPos -= 5;
285
+ }
286
+
287
+ if($yPos <= $minYPosToChangePage) {
288
+ $pdf->pages[] = $page;
289
+ $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
290
+ $yPos = $page->getHeight()-20;
291
+ }
292
+
293
+ $yPos -= 50;
294
+ $page->setFont($fontBold, 12);
295
+ $page->drawText('Bien pris en charge '.$resume['TOTAL']['unite'].' colis', $xPos, $yPos);
296
+
297
+ if($yPos <= $minYPosToChangePage) {
298
+ $pdf->pages[] = $page;
299
+ $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
300
+ $yPos = $page->getHeight()-20;
301
+ }
302
+
303
+ /* signatures */
304
+ $yPos -= 60;
305
+ $page->setFont($font, 12);
306
+ $page->drawText('Signature du client', $xPos, $yPos);
307
+ $page->drawText('Signature du Messager Chronopost', 400, $yPos);
308
+
309
+
310
+
311
+ $pdf->pages[] = $page;
312
+ return $pdf->render();
313
+ }
314
+
315
+
316
+ protected function getTrackingNumber($shipmentId) {
317
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
318
+ $trackNumber = '';
319
+ //On récupère le numéro de tracking
320
+ $tracks = $shipment->getTracksCollection();
321
+ foreach ($tracks as $track) {
322
+ if ($track->getParentId() == $shipmentId) {
323
+ $trackNumber = $track->getnumber();
324
+ }
325
+ }
326
+
327
+ return $trackNumber;
328
+ }
329
  }
app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/Sales/ImpressionController.php CHANGED
@@ -1,1136 +1,1138 @@
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
- }
 
 
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
+ $indiceFile = 0;
118
+ foreach ($pdf_contents as $pdf_content) {
119
+ $fileName = 'tmp-etiquette-'.date('H-i-s-'.$indiceFile);
120
+ /* save pdf file */
121
+ $path = Mage::getBaseDir('media').'/chronopost/' . $fileName . '.pdf';
122
+ file_put_contents($path, $pdf_content);
123
+ $paths[] = $path;
124
+ $indiceFile++;
125
+ }
126
+
127
+ /* creation d'un pdf unique */
128
+ $pdfMergeFileName = "merged-".date('YmdHis').".pdf";
129
+ $pathMerge = Mage::getBaseDir('media')."/chronopost/".$pdfMergeFileName;
130
+ $cmd = Mage::helper('chronorelais')->getConfigData('chronorelais/shipping/gs_path').' -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="'.$pathMerge.'" -dBATCH '. implode(' ', $paths);
131
+ $res_shell = shell_exec($cmd);
132
+
133
+ /* suppression des pdf temp */
134
+ foreach ($paths as $path) {
135
+ if(is_file($path)) {
136
+ unlink($path);
137
+ }
138
+ }
139
+
140
+ if ($res_shell === null) {
141
+ return $this->_redirectReferer();
142
+ }
143
+ else {
144
+ $this->_prepareDownloadResponse($pdfMergeFileName,array(
145
+ 'type' => 'filename',
146
+ 'value' => $pathMerge
147
+ ));
148
+ unlink($pathMerge);
149
+ }
150
+ }
151
+
152
+ protected function getTrackingNumber($shipmentId) {
153
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
154
+
155
+ //On récupère le numéro de tracking
156
+ $tracks = $shipment->getTracksCollection();
157
+ foreach ($tracks as $track) {
158
+ if ($track->getParentId() == $shipmentId) {
159
+ $this->_trackingNumbers .= $track->getnumber();
160
+ }
161
+ }
162
+
163
+ return $this->_trackingNumbers;
164
+ }
165
+
166
+ protected function getFilledValue($value) {
167
+ if ($value) {
168
+ return $this->removeaccents(trim($value));
169
+ } else {
170
+ return '';
171
+ }
172
+ }
173
+
174
+ protected function checkMobileNumber($value) {
175
+ if ($reqvalue = trim($value)) {
176
+ $_number = substr($reqvalue, 0, 2);
177
+ $fixed_array = array('01', '02', '03', '04', '05', '06', '06');
178
+ if (in_array($_number, $fixed_array)) {
179
+ return $reqvalue;
180
+ } else {
181
+ return '';
182
+ }
183
+ }
184
+ }
185
+
186
+ protected function getExpeditionParams($shipment, $_shippingMethod) {
187
+ $_order = $shipment->getOrder();
188
+ $_shippingAddress = $shipment->getShippingAddress();
189
+ $_billingAddress = $shipment->getBillingAddress();
190
+ $_helper = Mage::helper('chronorelais');
191
+
192
+ $shippingMethodAllow = array('chronorelais','chronopost','chronoexpress','chronopostc10','chronopostc18','chronopostcclassic','chronorelaiseurope','chronorelaisdom','chronopostsrdv','chronopostsameday');
193
+ if (in_array($_shippingMethod[0],$shippingMethodAllow)) {
194
+ $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
195
+
196
+ //header parameters
197
+ $header = array(
198
+ 'idEmit' => 'MAG',
199
+ 'accountNumber' => $_helper->getConfigurationAccountNumber(),
200
+ 'subAccount' => $_helper->getConfigurationSubAccountNumber()
201
+ );
202
+
203
+ //shipper parameters
204
+ $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
205
+ $shipper = array(
206
+ 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
207
+ 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
208
+ 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
209
+ 'shipperCivility' => $_helper->getConfigurationShipperInfo('civility'),
210
+ 'shipperContactName' => $_helper->getConfigurationShipperInfo('contactname'),
211
+ 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
212
+ 'shipperEmail' => $_helper->getConfigurationShipperInfo('email'),
213
+ 'shipperMobilePhone' => $shipperMobilePhone,
214
+ 'shipperName' => $_helper->getConfigurationShipperInfo('name'),
215
+ 'shipperName2' => $_helper->getConfigurationShipperInfo('name2'),
216
+ 'shipperPhone' => $_helper->getConfigurationShipperInfo('phone'),
217
+ 'shipperPreAlert' => '',
218
+ 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
219
+ );
220
+
221
+ //customer parameters
222
+ $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
223
+ $customer = array(
224
+ 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
225
+ 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
226
+ 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
227
+ 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
228
+ 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
229
+ 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
230
+ 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
231
+ 'customerMobilePhone' => $customerMobilePhone,
232
+ 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
233
+ 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
234
+ 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
235
+ 'customerPreAlert' => '',
236
+ 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
237
+ );
238
+
239
+ //recipient parameters
240
+ $recipient_address = $_shippingAddress->getStreet();
241
+ if (!isset($recipient_address[1])) {
242
+ $recipient_address[1] = '';
243
+ }
244
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
245
+ $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
246
+ $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
247
+ $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
248
+ //remove any alphabets in phone number
249
+
250
+ $recipientPhone = trim(preg_replace("/[^0-9\.\-]/", " ", $_shippingAddress->getTelephone()));
251
+
252
+ $recipient = array(
253
+ 'recipientAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
254
+ 'recipientAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
255
+ 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
256
+ 'recipientContactName' => $recipientName2,
257
+ 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
258
+ 'recipientEmail' => $customer_email,
259
+ 'recipientMobilePhone' => $recipientMobilePhone,
260
+ 'recipientName' => $recipientName,
261
+ 'recipientName2' => $recipientName2,
262
+ 'recipientPhone' => $recipientPhone,
263
+ 'recipientPreAlert' => '',
264
+ 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
265
+ );
266
+
267
+ //ref parameters
268
+ $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
269
+ if (!$recipientRef) {
270
+ $recipientRef = $_order->getCustomerId();
271
+ }
272
+ $shipperRef = $_order->getRealOrderId();
273
+
274
+ $ref = array(
275
+ 'recipientRef' => $recipientRef,
276
+ 'shipperRef' => $shipperRef
277
+ );
278
+
279
+ //skybill parameters
280
+ /* Livraison Samedi (Delivery Saturday) field */
281
+ $SaturdayShipping = 0; //default value for the saturday shipping
282
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais" || $_shippingMethod[0] == "chronorelaisdom") {
283
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
284
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
285
+ } else {
286
+ if ($_deliver_on_saturday == 'Yes') {
287
+ $_deliver_on_saturday = 1;
288
+ } else {
289
+ $_deliver_on_saturday = 0;
290
+ }
291
+ }
292
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
293
+
294
+ if($_shippingMethod[0] == "chronorelaisdom") {
295
+ if ($_deliver_on_saturday && $is_sending_day) {
296
+ $SaturdayShipping = 369;
297
+ } else {
298
+ $SaturdayShipping = 368;
299
+ }
300
+ } else {
301
+ if ($_deliver_on_saturday && $is_sending_day) {
302
+ $SaturdayShipping = 6;
303
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
304
+ $SaturdayShipping = 1;
305
+ }
306
+ }
307
+
308
+ }
309
+
310
+ $weight = 0;
311
+ foreach ($shipment->getItemsCollection() as $item) {
312
+ $weight += $item->weight * $item->qty;
313
+ }
314
+ if ($_helper->getConfigWeightUnit() == 'g') {
315
+ $weight = $weight / 1000; /* conversion g => kg */
316
+ }
317
+
318
+ /* si chronorelaiseurope : service : 337 si poids < 3kg ou 338 si > 3kg */
319
+ if($_shippingMethod[0] == "chronorelaiseurope") {
320
+ $weight <= 3 ? $SaturdayShipping = '337' : $SaturdayShipping = '338';
321
+ }
322
+
323
+
324
+ $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
325
+
326
+ $skybill = array(
327
+ 'codCurrency' => 'EUR',
328
+ 'codValue' => '',
329
+ 'content1' => '',
330
+ 'content2' => '',
331
+ 'content3' => '',
332
+ 'content4' => '',
333
+ 'content5' => '',
334
+ 'customsCurrency' => 'EUR',
335
+ 'customsValue' => '',
336
+ 'evtCode' => 'DC',
337
+ 'insuredCurrency' => 'EUR',
338
+ 'insuredValue' => '',
339
+ 'objectType' => 'MAR',
340
+ 'productCode' => $_helper->getChronoProductCodeToShipment($_shippingMethod[0]),
341
+ 'service' => $SaturdayShipping,
342
+ 'shipDate' => date('c'),
343
+ 'shipHour' => date('H'),
344
+ 'weight' => $weight,
345
+ 'weightUnit' => 'KGM'
346
+ );
347
+
348
+ $skybillParams = array(
349
+ 'mode' => $_helper->getConfigurationSkybillParam()
350
+ );
351
+
352
+ $expeditionArray = array(
353
+ 'headerValue' => $header,
354
+ 'shipperValue' => $shipper,
355
+ 'customerValue' => $customer,
356
+ 'recipientValue' => $recipient,
357
+ 'refValue' => $ref,
358
+ 'skybillValue' => $skybill,
359
+ 'skybillParamsValue' => $skybillParams,
360
+ 'password' => $_helper->getConfigurationAccountPass()
361
+ );
362
+
363
+ /* si chronopostsrdv : ajout parametres supplementaires */
364
+ if($_shippingMethod[0] == "chronopostsrdv") {
365
+
366
+ $chronopostsrdv_creneaux_info = $_shippingAddress->getData('chronopostsrdv_creneaux_info');
367
+ $chronopostsrdv_creneaux_info = json_decode($chronopostsrdv_creneaux_info,true);
368
+
369
+ $_dateRdvStart = new DateTime($chronopostsrdv_creneaux_info['deliveryDate']);
370
+ $_dateRdvStart->setTime($chronopostsrdv_creneaux_info['startHour'],$chronopostsrdv_creneaux_info['startMinutes']);
371
+
372
+ $_dateRdvEnd = new DateTime($chronopostsrdv_creneaux_info['deliveryDate']);
373
+ $_dateRdvEnd->setTime($chronopostsrdv_creneaux_info['endHour'],$chronopostsrdv_creneaux_info['endMinutes']);
374
+
375
+
376
+ $scheduledValue = array(
377
+ 'appointmentValue' => array(
378
+ 'timeSlotStartDate' => $_dateRdvStart->format("Y-m-d")."T".$_dateRdvStart->format("H:i:s"),
379
+ 'timeSlotEndDate' => $_dateRdvEnd->format("Y-m-d")."T".$_dateRdvEnd->format("H:i:s"),
380
+ 'timeSlotTariffLevel' => $chronopostsrdv_creneaux_info['tariffLevel']
381
+ )
382
+ );
383
+ $expeditionArray['scheduledValue'] = $scheduledValue;
384
+
385
+ /* modification productCode et service car dynamique pour ce mode de livraison */
386
+
387
+ $expeditionArray['skybillValue']['productCode'] = $chronopostsrdv_creneaux_info['productCode'];
388
+ $expeditionArray['skybillValue']['service'] = $chronopostsrdv_creneaux_info['serviceCode'];
389
+
390
+ }
391
+
392
+ return $expeditionArray;
393
+ }
394
+ }
395
+
396
+ protected function getEtiquetteUrl($shipmentId) {
397
+ //On récupère les infos d'expédition
398
+ $_helper = Mage::helper('chronorelais');
399
+
400
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
401
+ if ($_shipTracks = $shipment->getAllTracks()) {
402
+ foreach ($_shipTracks as $_shipTrack) {
403
+ if ($_shipTrack->getNumber() && $_shipTrack->getChronoReservationNumber()) {
404
+ $skybill = base64_decode($_shipTrack->getChronoReservationNumber());
405
+ break;
406
+ }
407
+ }
408
+ if ($skybill) {
409
+ return $skybill;
410
+ }
411
+ }
412
+
413
+ $_order = $shipment->getOrder();
414
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
415
+
416
+ $expeditionArray = $this->getExpeditionParams($shipment, $_shippingMethod);
417
+ $tracking_number = '';
418
+ if ($expeditionArray) {
419
+ $client = new SoapClient("https://www.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl", array('trace' => true));
420
+ try {
421
+ $webservbt = $client->shippingV3($expeditionArray);
422
+ if (!$webservbt->return->errorCode && $webservbt->return->skybill) {
423
+ $tracking_number = $webservbt->return->skybillNumber;
424
+ // Add tracking number for the shipment if not already exists.
425
+ if (!$this->_trackingNumbers && $webservbt->return->skybillNumber) {
426
+ $track = Mage::getModel('sales/order_shipment_track')
427
+ ->setNumber($webservbt->return->skybillNumber)
428
+ ->setChronoReservationNumber(base64_encode($webservbt->return->skybill))
429
+ ->setCarrier(ucwords($_shippingMethod[0]))
430
+ ->setCarrierCode($_shippingMethod[0])
431
+ ->setTitle(ucwords($_shippingMethod[0]))
432
+ ->setPopup(1);
433
+ $shipment->addTrack($track);
434
+
435
+ $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
436
+ $tracking_title = $this->__('Track Your Order');
437
+ $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
438
+
439
+ $comment = '';
440
+ $shipment->setEmailSent(true);
441
+ $this->_saveShipment($shipment);
442
+ $shipment->sendEmail(1, $tracking_order . $comment);
443
+ }
444
+ return $webservbt->return->skybill; // pdf base64
445
+ } else {
446
+ $this->_getSession()->addError($_helper->__($webservbt->return->errorMessage));
447
+ }
448
+ } catch (SoapFault $fault) {
449
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
450
+ }
451
+ }
452
+ }
453
+
454
+ public function getShipmentByOrderId($orderId) {
455
+ $_shipment = Mage::getResourceModel('sales/order_shipment_grid_collection')
456
+ ->addAttributeToFilter('order_id', $orderId)
457
+ ->getAllIds();
458
+ return $_shipment;
459
+ }
460
+
461
+ public function getShipmentByIncrementId($incrementId) {
462
+ $_shipment = Mage::getResourceModel('sales/order_shipment_grid_collection')
463
+ ->addAttributeToFilter('increment_id', $incrementId)
464
+ ->getAllIds();
465
+ return $_shipment;
466
+ }
467
+
468
+ public function initShipment($orderId,$savedQtys = '') {
469
+ $order = Mage::getModel('sales/order')->load($orderId);
470
+
471
+ /**
472
+ * Check order existing
473
+ */
474
+ if (!$order->getId()) {
475
+ $this->_getSession()->addError($this->__('The order no longer exists.'));
476
+ return false;
477
+ }
478
+ /**
479
+ * Check shipment is available to create separate from invoice
480
+ */
481
+ if ($order->getForcedDoShipmentWithInvoice()) {
482
+ $this->_getSession()->addError($this->__('Cannot do shipment for the order separately from invoice.'));
483
+ return false;
484
+ }
485
+ /**
486
+ * Check shipment create availability
487
+ */
488
+ if(empty($savedQtys)) {
489
+ $savedQtys = $this->_getItemQtys();
490
+ }
491
+ $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($savedQtys);
492
+ if(Mage::registry('current_shipment')) {
493
+ Mage::unregister ('current_shipment');
494
+ }
495
+ Mage::register('current_shipment', $shipment);
496
+ return $shipment;
497
+ }
498
+
499
+ public function createNewShipment($orderId,$savedQtys = '') {
500
+ $_helper = Mage::helper('chronorelais');
501
+ $skybill = '';
502
+ try {
503
+ if ($shipment = $this->initShipment($orderId,$savedQtys)) {
504
+ $shipment->register();
505
+
506
+ $_order = $shipment->getOrder();
507
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
508
+
509
+ $expeditionArray = $this->getExpeditionParams($shipment, $_shippingMethod);
510
+ $tracking_number = '';
511
+ if ($expeditionArray) {
512
+
513
+ $client = new SoapClient("https://www.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl", array('trace' => true));
514
+ try {
515
+ $expedition = $client->shippingV3($expeditionArray);
516
+ if (!$expedition->return->errorCode && $expedition->return->skybillNumber) {
517
+ $tracking_number = $expedition->return->skybillNumber;
518
+ $track = Mage::getModel('sales/order_shipment_track')
519
+ ->setNumber($expedition->return->skybillNumber)
520
+ ->setChronoReservationNumber(base64_encode($expedition->return->skybill))
521
+ ->setCarrier(ucwords($_shippingMethod[0]))
522
+ ->setCarrierCode($_shippingMethod[0])
523
+ ->setTitle(ucwords($_shippingMethod[0]))
524
+ ->setPopup(1);
525
+ $shipment->addTrack($track);
526
+ $skybill = $expedition->return->skybill;
527
+ } else {
528
+ $this->_getSession()->addError($_helper->__($expedition->return->errorMessage));
529
+ return;
530
+ }
531
+ } catch (SoapFault $fault) {
532
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
533
+ return;
534
+ }
535
+ }
536
+
537
+ $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
538
+ $tracking_title = $this->__('Track Your Order');
539
+ $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
540
+
541
+ $comment = '';
542
+ $shipment->setEmailSent(true);
543
+ $this->_saveShipment($shipment);
544
+ $shipment->sendEmail(1, $tracking_order . $comment);
545
+ $this->_getSession()->addSuccess($this->__('Shipment was successfully created.'));
546
+ return $skybill;
547
+ } else {
548
+ $this->_forward('noRoute');
549
+ return;
550
+ }
551
+ } catch (Mage_Core_Exception $e) {
552
+ $this->_getSession()->addError($e->getMessage());
553
+ return;
554
+ } catch (Exception $e) {
555
+ $this->_getSession()->addError($this->__('Can not save shipment: ' . $e->getMessage()));
556
+ return;
557
+ }
558
+ }
559
+
560
+ public function printMassAction() {
561
+ $orderIds = $this->getRequest()->getParam('order_ids');
562
+ $skybillArr = array();
563
+ $helper = Mage::helper('chronorelais');
564
+ foreach ($orderIds as $orderId) {
565
+ if ($_shipments = $this->getShipmentByOrderId($orderId)) {
566
+ if (count($_shipments) == 1) {
567
+ $shipmentId = $_shipments[0];
568
+ $skybill = $this->getEtiquetteUrl($shipmentId);
569
+ if ($skybill) {
570
+ $skybillArr[] = $skybill;
571
+ }
572
+ } else {
573
+ foreach ($_shipments as $_shipment) {
574
+ $skybill = $this->getEtiquetteUrl($_shipment);
575
+ if ($skybill) {
576
+ $skybillArr[] = $skybill;
577
+ }
578
+ }
579
+ }
580
+ } else {
581
+
582
+ $order = Mage::getModel('sales/order')->load($orderId);
583
+
584
+ /* If shipping method is Chronopost => check if shipping weight isn't over limit */
585
+ $chronopostMethods = array('chronorelais','chronopost','chronoexpress','chronopostc10','chronopostc18','chronopostcclassic','chronorelaiseurope','chronorelaisdom','chronopostsrdv','chronopostsameday');
586
+ $shippingMethod = $order->getShippingMethod();
587
+ $shippingMethod = explode("_", $shippingMethod);
588
+ $shippingMethod = $shippingMethod[0];
589
+ if(in_array($shippingMethod, $chronopostMethods)) {
590
+ $weightShipping = 0;
591
+ $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
592
+ foreach ($order->getItemsCollection() as $item) {
593
+ $weightShipping += $item->getWeight()*$item->getQtyOrdered();
594
+ }
595
+ if($helper->getConfigWeightUnit() == 'g')
596
+ {
597
+ $weightShipping = $weightShipping / 1000; // conversion g => kg
598
+ }
599
+ if($weightShipping > $weight_limit) {
600
+ /* multi shipping. 1 shipment by product */
601
+ foreach ($order->getItemsCollection() as $item) {
602
+ $qty = $item->getQtyOrdered();
603
+ for($i = 1; $i <= $qty; $i++) {
604
+ $skybill = $this->createNewShipment($orderId,array($item->getId() => '1'));
605
+ if ($skybill)
606
+ $skybillArr[] = $skybill;
607
+ }
608
+ }
609
+ }
610
+ else {
611
+ $skybill = $this->createNewShipment($orderId);
612
+ if ($skybill) {
613
+ $skybillArr[] = $skybill;
614
+ }
615
+ }
616
+ }
617
+ else {
618
+ $skybill = $this->createNewShipment($orderId);
619
+ if ($skybill) {
620
+ $skybillArr[] = $skybill;
621
+ }
622
+ }
623
+ }
624
+ }
625
+ if (count($skybillArr)) {
626
+ $this->_processDownloadMass($skybillArr);
627
+ }
628
+ else {
629
+ return $this->_redirectReferer();
630
+ }
631
+ }
632
+
633
+ public function printAction() {
634
+ // Appel via order_id
635
+ $orderId = $this->getRequest()->getParam('order_id');
636
+ $helper = Mage::helper('chronorelais');
637
+ if ($orderId) {
638
+ if ($_shipments = $this->getShipmentByOrderId($orderId)) {
639
+ if (count($_shipments) == 1) {
640
+ $shipmentId = $_shipments[0];
641
+ $skybillArr = $this->getEtiquetteUrl($shipmentId);
642
+ } else {
643
+ $track = "Cette commande contient plusieurs expéditions, cliquez sur chaque lien pour obtenir les étiquettes :<br>";
644
+ /*foreach ($_shipments as $_shipment) {
645
+ $url = str_replace('{trackingNumber}', $this->getEtiquetteUrl($_shipment), $helper->getConfigurationTrackingUrl());
646
+ $track .= '<a target="_blank" href="' . $url . '">' . $url . '</a><br />';
647
+ }*/
648
+ echo $track;
649
+ return;
650
+ }
651
+ } else {
652
+ $order = Mage::getModel('sales/order')->load($orderId);
653
+
654
+ /* If shipping method is Chronopost => check if shipping weight isn't over limit */
655
+ $chronopostMethods = array('chronorelais','chronopost','chronoexpress','chronopostc10','chronopostc18','chronopostcclassic','chronorelaiseurope','chronorelaisdom','chronopostsrdv','chronopostsameday');
656
+ $shippingMethod = $order->getShippingMethod();
657
+ $shippingMethod = explode("_", $shippingMethod);
658
+ $shippingMethod = $shippingMethod[0];
659
+ if(in_array($shippingMethod, $chronopostMethods)) {
660
+ $weightShipping = 0;
661
+ $shippingMethod = explode("_", $shippingMethod);
662
+ $shippingMethod = $shippingMethod[0];
663
+ $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
664
+ foreach ($order->getItemsCollection() as $item) {
665
+ $weightShipping += $item->getWeight()*$item->getQtyOrdered();
666
+ }
667
+ if($helper->getConfigWeightUnit() == 'g')
668
+ {
669
+ $weightShipping = $weightShipping / 1000; // conversion g => kg
670
+ }
671
+ if($weightShipping > $weight_limit) {
672
+ /* multi shipping. 1 shipment by product */
673
+ $skybillArr = array();
674
+ foreach ($order->getItemsCollection() as $item) {
675
+ $qty = $item->getQtyOrdered();
676
+ for($i = 1; $i <= $qty; $i++) {
677
+ $skybillArr[] = $this->createNewShipment($orderId,array($item->getId() => '1'));
678
+ }
679
+ }
680
+ }
681
+ else {
682
+ $skybillArr = $this->createNewShipment($orderId);
683
+ }
684
+ }
685
+ else {
686
+ $skybillArr = $this->createNewShipment($orderId);
687
+ }
688
+ }
689
+ } else {
690
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
691
+ if ($shipmentId) {
692
+ $skybillArr = $this->getEtiquetteUrl($shipmentId);
693
+ } else {
694
+ $shipmentIncrementId = $this->getRequest()->getParam('shipment_increment_id');
695
+ $shipmentId = $this->getShipmentByIncrementId($shipmentIncrementId);
696
+ $skybillArr = $this->getEtiquetteUrl($shipmentId[0]);
697
+ }
698
+ }
699
+
700
+
701
+ if ($skybillArr) {
702
+ try {
703
+ if(is_array($skybillArr)) {
704
+ $this->_processDownloadMass($skybillArr);
705
+ }
706
+ else {
707
+ $this->_prepareDownloadResponse('Etiquette_chronopost.pdf', $skybillArr);
708
+
709
+ }
710
+ } catch (Mage_Core_Exception $e) {
711
+ $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'));
712
+ }
713
+ }
714
+ else {
715
+ return $this->_redirectReferer();
716
+ }
717
+ }
718
+
719
+ public function massLivraisonSamediStatusAction() {
720
+ if ($this->getRequest()->getPost('status')) {
721
+ $this->saveLivraisonSamediStatusAction();
722
+ }
723
+ }
724
+
725
+ /* Save the Livraison le Samedi status to orders */
726
+
727
+ public function saveLivraisonSamediStatusAction() {
728
+ /* get the orders */
729
+ $orderIds = $this->getRequest()->getPost('order_ids');
730
+ $status = $this->getRequest()->getPost('status');
731
+ $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
732
+ $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
733
+ $exceptions = array();
734
+
735
+ foreach ($orderIds as $orderId) {
736
+ $order_details = Mage::getModel('sales/order')->load($orderId);
737
+ $shipping_method = '';
738
+ $livraison_le_samedi = $status;
739
+ if ($shipping_method = $order_details->getShippingMethod()) {
740
+ $shipping_method = explode('_', $shipping_method);
741
+ if ($shipping_method[0] == 'chronoexpress') {
742
+ $livraison_le_samedi = '--';
743
+ }
744
+ }
745
+ $condition = array(
746
+ $_connection->quoteInto('order_id = ?', $orderId),
747
+ );
748
+ $_connection->delete($_table, $condition);
749
+
750
+ $dataLine = array(
751
+ 'order_id' => $orderId,
752
+ 'livraison_le_samedi' => $livraison_le_samedi
753
+ );
754
+ try {
755
+ $_connection->insert($_table, $dataLine);
756
+ } catch (Exception $e) {
757
+ $exceptions[] = Mage::helper('chronorelais')->__('Order assigning error: ' . $e->getMessage());
758
+ }
759
+ }
760
+ if ($exceptions) {
761
+ $this->_getSession()->addError($exceptions);
762
+ } else {
763
+ $this->_getSession()->addSuccess($this->__('Livraison le Samedi statut a &eacute;t&eacute; ajout&eacute;'));
764
+ }
765
+ $this->_redirect('*/*/index');
766
+ }
767
+
768
+ /* Remove accents characters */
769
+
770
+ public function removeaccents($string) {
771
+ $stringToReturn = str_replace(
772
+ 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);
773
+ // Remove all remaining other unknown characters
774
+ $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
775
+ $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
776
+ $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
777
+ $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
778
+ return $stringToReturn;
779
+ }
780
+
781
+ /*
782
+ * *******************************************************************
783
+ * ******************** ETIQUETTE DE RETOUR **************************
784
+ * *******************************************************************
785
+ */
786
+
787
+ public function printEtiquetteRetourAction() {
788
+ $shipmentIncrementId = $this->getRequest()->getParam('shipment_increment_id');
789
+ $shipmentId = $this->getShipmentByIncrementId($shipmentIncrementId);
790
+ $shipmentId = $shipmentId[0];
791
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
792
+ $_order = $shipment->getOrder();
793
+ $_shippingAddress = $shipment->getShippingAddress();
794
+ $_billingAddress = $shipment->getBillingAddress();
795
+ $skillbill = $this->getEtiquetteRetourUrl($shipment); /* skillbill pdf encode base64*/
796
+
797
+ if ($skillbill) {
798
+ try {
799
+ $path = $this->savePdfWithContent($skillbill, $shipmentId);
800
+
801
+ $message_email = 'Bonjour,
802
+ <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.
803
+ <br />Cordialement,';
804
+
805
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
806
+
807
+ $mail = new Zend_Mail('utf-8');
808
+ $mail->setBodyHtml($message_email);
809
+ $mail->setFrom(Mage::getStoreConfig('contacts/email/recipient_email'));
810
+ $mail->setSubject($_order->getStoreName(1) . ' : Etiquette de retour chronopost');
811
+ $mail->createAttachment(file_get_contents($path), Zend_Mime::TYPE_OCTETSTREAM, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'etiquette_retour.pdf');
812
+
813
+ $mail->addTo($customer_email);
814
+ $mail->send();
815
+
816
+ $mail->clearRecipients();
817
+ $mail->addTo(Mage::getStoreConfig('contacts/email/recipient_email'));
818
+ $mail->send();
819
+
820
+ $this->_getSession()->addSuccess(Mage::helper('chronorelais')->__('L\'etiquette de retour à bien été envoyée au client.'));
821
+ } catch (Mage_Core_Exception $e) {
822
+ $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'));
823
+ }
824
+ }
825
+ return $this->_redirectReferer();
826
+ }
827
+
828
+ protected function getEtiquetteRetourParams($shipment, $_shippingMethod) {
829
+ $_order = $shipment->getOrder();
830
+ $_shippingAddress = $shipment->getShippingAddress();
831
+ $_billingAddress = $shipment->getBillingAddress();
832
+ $_helper = Mage::helper('chronorelais');
833
+
834
+ if ($_shippingAddress->getCountryId() != 'FR'
835
+ && strpos($_shippingMethod[0], 'chronorelaiseurope') === false
836
+ && strpos($_shippingMethod[0], 'chronorelaisdom') === false
837
+ && strpos($_shippingMethod[0], 'chronopostsrdv') === false
838
+ ) {
839
+ $this->_getSession()->addError($_helper->__('Les retours sont disponibles uniquement pour la France'));
840
+ return;
841
+ }
842
+ $shippingMethodAllow = array('chronorelaiseurope','chronorelais','chronopost','chronopostc10','chronopostc18','chronopostsrdv');
843
+ if (!in_array($_shippingMethod[0], $shippingMethodAllow)) {
844
+ $this->_getSession()->addError($_helper->__('Les retours ne sont pas disponibles pour le mode de livraison ' . $_shippingMethod[0]));
845
+ return;
846
+ }
847
+
848
+ if (in_array($_shippingMethod[0], $shippingMethodAllow)) {
849
+ $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
850
+
851
+ //header parameters
852
+ $header = array(
853
+ 'idEmit' => 'MAG',
854
+ 'accountNumber' => $_helper->getConfigurationAccountNumber(),
855
+ 'subAccount' => $_helper->getConfigurationSubAccountNumber()
856
+ );
857
+
858
+ //shipper parameters
859
+ $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
860
+ $recipient = array(
861
+ 'recipientAdress1' => $_helper->getConfigurationShipperInfo('address1'),
862
+ 'recipientAdress2' => $_helper->getConfigurationShipperInfo('address2'),
863
+ 'recipientCity' => $_helper->getConfigurationShipperInfo('city'),
864
+ 'recipientCivility' => $_helper->getConfigurationShipperInfo('civility'),
865
+ 'recipientContactName' => $_helper->getConfigurationShipperInfo('contactname'),
866
+ 'recipientCountry' => $_helper->getConfigurationShipperInfo('country'),
867
+ 'recipientEmail' => $_helper->getConfigurationShipperInfo('email'),
868
+ 'recipientMobilePhone' => $shipperMobilePhone,
869
+ 'recipientName' => $_helper->getConfigurationShipperInfo('name'),
870
+ 'recipientName2' => $_helper->getConfigurationShipperInfo('name2'),
871
+ 'recipientPhone' => $_helper->getConfigurationShipperInfo('phone'),
872
+ 'recipientPreAlert' => '',
873
+ 'recipientZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
874
+ );
875
+
876
+ //customer parameters
877
+ $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
878
+ $customer = array(
879
+ 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
880
+ 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
881
+ 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
882
+ 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
883
+ 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
884
+ 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
885
+ 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
886
+ 'customerMobilePhone' => $customerMobilePhone,
887
+ 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
888
+ 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
889
+ 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
890
+ 'customerPreAlert' => '',
891
+ 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
892
+ );
893
+
894
+ //recipient parameters
895
+ $_recipientAddress = $_shippingAddress;
896
+ if(strpos($_shippingMethod[0],'chronorelais') !== false) {
897
+ // Nicolas, le 27/11/2014 : si Chronorelais, on doit utiliser l'adresse de facturation, non de livraison (qui est celle du relais)
898
+ $_recipientAddress = $_billingAddress;
899
+ }
900
+ $recipient_address = $_recipientAddress->getStreet();
901
+
902
+ // Champs forcément basés sur l'adresse de livraison
903
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
904
+ $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
905
+ $recipientName = $this->getFilledValue($_recipientAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
906
+ $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
907
+ //remove any alphabets in phone number
908
+
909
+ $recipientPhone = trim(preg_replace("/[^0-9\.\-]/", " ", $_shippingAddress->getTelephone()));
910
+ if (!isset($recipient_address[1])) {
911
+ $recipient_address[1] = '';
912
+ }
913
+
914
+ $shipper = array(
915
+ 'shipperAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
916
+ 'shipperAdress2' => $recipient_address[1] ? substr($this->getFilledValue($recipient_address[1]), 0, 38) : '',
917
+ 'shipperCity' => $this->getFilledValue($_recipientAddress->getCity()),
918
+ 'shipperCivility' => 'M',
919
+ 'shipperContactName' => $recipientName2,
920
+ 'shipperCountry' => $this->getFilledValue($_recipientAddress->getCountryId()),
921
+ 'shipperEmail' => $customer_email,
922
+ 'shipperMobilePhone' => $recipientMobilePhone,
923
+ 'shipperName' => $recipientName,
924
+ 'shipperName2' => $recipientName2,
925
+ 'shipperPhone' => $recipientPhone,
926
+ 'shipperPreAlert' => '',
927
+ 'shipperZipCode' => $this->getFilledValue($_recipientAddress->getPostcode()),
928
+ );
929
+
930
+ //ref parameters
931
+ $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
932
+ if (!$recipientRef) {
933
+ $recipientRef = $_order->getCustomerId();
934
+ }
935
+ $shipperRef = $_order->getRealOrderId();
936
+
937
+ $ref = array(
938
+ 'recipientRef' => $recipientRef,
939
+ 'shipperRef' => $shipperRef
940
+ );
941
+
942
+ //skybill parameters
943
+ /* Livraison Samedi (Delivery Saturday) field */
944
+ $SaturdayShipping = 0; //default value for the saturday shipping
945
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
946
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
947
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
948
+ } else {
949
+ if ($_deliver_on_saturday == 'Yes') {
950
+ $_deliver_on_saturday = 1;
951
+ } else {
952
+ $_deliver_on_saturday = 0;
953
+ }
954
+ }
955
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
956
+ if ($_deliver_on_saturday && $is_sending_day) {
957
+ $SaturdayShipping = 6;
958
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
959
+ $SaturdayShipping = 1;
960
+ }
961
+ }
962
+
963
+ $weight = 0;
964
+ foreach ($shipment->getItemsCollection() as $item) {
965
+ $weight += $item->weight * $item->qty;
966
+ }
967
+ if ($_helper->getConfigWeightUnit() == 'g') {
968
+ $weight = $weight / 1000; /* conversion g => kg */
969
+ }
970
+
971
+ $productCode = Chronopost_Chronorelais_Helper_Data::CHRONO_POST;
972
+ if($_shippingMethod[0] == 'chronorelaiseurope') {
973
+ $productCode = '3T';
974
+ //$weight <= 3 ? $SaturdayShipping = '337' : $SaturdayShipping = '338';
975
+ $SaturdayShipping = '332';
976
+ }
977
+
978
+ $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
979
+
980
+ $skybill = array(
981
+ 'codCurrency' => 'EUR',
982
+ 'codValue' => '',
983
+ 'content1' => '',
984
+ 'content2' => '',
985
+ 'content3' => '',
986
+ 'content4' => '',
987
+ 'content5' => '',
988
+ 'customsCurrency' => 'EUR',
989
+ 'customsValue' => '',
990
+ 'evtCode' => 'DC',
991
+ 'insuredCurrency' => 'EUR',
992
+ 'insuredValue' => '',
993
+ 'objectType' => 'MAR',
994
+ 'productCode' => $productCode,
995
+ 'service' => $SaturdayShipping,
996
+ 'shipDate' => date('c'),
997
+ 'shipHour' => date('H'),
998
+ 'weight' => $weight,
999
+ 'weightUnit' => 'KGM'
1000
+ );
1001
+
1002
+ $mode = $_helper->getConfigurationSkybillParam();
1003
+ if($_shippingMethod[0] == 'chronorelaiseurope') {
1004
+ $mode = 'PPR';
1005
+ }
1006
+ $skybillParams = array(
1007
+ 'mode' => $mode
1008
+ );
1009
+
1010
+ $expeditionArray = array(
1011
+ 'headerValue' => $header,
1012
+ 'shipperValue' => $shipper,
1013
+ 'customerValue' => $customer,
1014
+ 'recipientValue' => $recipient,
1015
+ 'refValue' => $ref,
1016
+ 'skybillValue' => $skybill,
1017
+ 'skybillParamsValue' => $skybillParams,
1018
+ 'password' => $_helper->getConfigurationAccountPass()
1019
+ );
1020
+ return $expeditionArray;
1021
+ }
1022
+ }
1023
+
1024
+ protected function getEtiquetteRetourUrl($shipment) {
1025
+ //On récupère les infos d'expédition
1026
+ $_helper = Mage::helper('chronorelais');
1027
+
1028
+ $_order = $shipment->getOrder();
1029
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
1030
+
1031
+ $expeditionArray = $this->getEtiquetteRetourParams($shipment, $_shippingMethod);
1032
+ if ($expeditionArray) {
1033
+ $client = new SoapClient("https://www.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl", array('trace' => true));
1034
+ try {
1035
+ $webservbt = $client->shippingV3($expeditionArray);
1036
+
1037
+ if (!$webservbt->return->errorCode && $webservbt->return->skybill) {
1038
+ return $webservbt->return->skybill;
1039
+ } else {
1040
+ $this->_getSession()->addError($_helper->__($webservbt->return->errorMessage));
1041
+ }
1042
+ } catch (SoapFault $fault) {
1043
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
1044
+ }
1045
+ }
1046
+ }
1047
+
1048
+ protected function savePdf($url, $shipmentId) {
1049
+ $this->createMediaChronopostFolder();
1050
+ $path = 'media/chronopost/etiquetteRetour-' . $shipmentId . '.pdf';
1051
+ file_put_contents($path, file_get_contents($url));
1052
+ return $path;
1053
+ }
1054
+
1055
+ protected function savePdfWithContent($content_base64, $shipmentId) {
1056
+ $this->createMediaChronopostFolder();
1057
+ $path = 'media/chronopost/etiquetteRetour-' . $shipmentId . '.pdf';
1058
+ file_put_contents($path, $content_base64);
1059
+ return $path;
1060
+ }
1061
+
1062
+ /* create folder media/chronopost if not exist */
1063
+ protected function createMediaChronopostFolder() {
1064
+ $path = 'media/chronopost';
1065
+ if(!is_dir($path)) {
1066
+ mkdir($path,0777);
1067
+ }
1068
+ }
1069
+
1070
+ protected function getShipmentObjectByOrderId($orderId) {
1071
+ $_shipment = Mage::getResourceModel('sales/order_shipment_collection')
1072
+ ->addAttributeToFilter('order_id', $orderId);
1073
+ return $_shipment;
1074
+ }
1075
+
1076
+ public function cancelMassAction() {
1077
+ $orderIds = $this->getRequest()->getParam('order_ids');
1078
+
1079
+ if($orderIds) {
1080
+ $nbEtiquettesDelete = 0;
1081
+ foreach($orderIds as $orderId) {
1082
+ $shipments = $this->getShipmentObjectByOrderId($orderId);
1083
+ if($shipments) {
1084
+ foreach($shipments as $shipment) {
1085
+
1086
+ $tracks = $shipment->getTracksCollection();
1087
+ foreach ($tracks as $track) {
1088
+
1089
+ /* numero chrono si getChronoReservationNumber non null */
1090
+ if($track->getChronoReservationNumber()) {
1091
+
1092
+ /* appel WS pour annuler LT */
1093
+ $webservbt = Mage::helper('chronorelais/webservice')->cancelSkybill($track->getNumber());
1094
+ if($webservbt) {
1095
+ /* suppression du numéro de tracking */
1096
+ if($webservbt->return->errorCode == 0) {
1097
+ $nbEtiquettesDelete++;
1098
+ $track->delete();
1099
+ } else {
1100
+ switch($webservbt->return->errorCode) {
1101
+ case "1" :
1102
+ $errorMessage = $this->__("Une erreur système est survenue");
1103
+ break;
1104
+ case "2" :
1105
+ $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");
1106
+ break;
1107
+ case "3" :
1108
+ $errorMessage = $this->__("Le colis ne peut être pas annulé car il a été pris en charge par Chronopost");
1109
+ break;
1110
+ default :
1111
+ $errorMessage = '';
1112
+ break;
1113
+ }
1114
+ $this->_getSession()->addError($this->__("Erreur lors de la suppression de l'étiquettes %s : %s.",$track->getNumber(),$errorMessage));
1115
+ }
1116
+ } else {
1117
+ $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()));
1118
+ }
1119
+ }
1120
+ }
1121
+ }
1122
+ }
1123
+ }
1124
+ if($nbEtiquettesDelete > 0) {
1125
+ if($nbEtiquettesDelete > 1) {
1126
+ $this->_getSession()->addSuccess($this->__('%s étiquettes de transport ont bien été annulées.',$nbEtiquettesDelete));
1127
+ } else {
1128
+ $this->_getSession()->addSuccess($this->__('%s étiquette de transport a bien été annulée.',$nbEtiquettesDelete));
1129
+ }
1130
+
1131
+ }
1132
+ } else {
1133
+ $this->_getSession()->addError($this->__("Veuillez sélectionner au moins une lettre de transport."));
1134
+ }
1135
+ $this->_redirect('*/*/index');
1136
+ }
1137
+
1138
+ }
app/code/community/Chronopost/Chronorelais/controllers/Adminhtml/Chronorelais/Sales/Order/ShipmentController.php CHANGED
@@ -1,429 +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','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
- }
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
@@ -1,104 +1,104 @@
1
- <?php
2
-
3
- require_once 'Mage/Checkout/controllers/MultishippingController.php';
4
-
5
- class Chronopost_Chronorelais_Checkout_MultishippingController extends Mage_Checkout_MultishippingController {
6
-
7
- /**
8
- * Get payment method step html
9
- *
10
- * @return string
11
- */
12
- protected function _getChronoRelaisHtml() {
13
- return $this->getLayout()->getBlock('root')->toHtml();
14
- }
15
-
16
- public function shippingPostAction() {
17
- $shippingMethods = $this->getRequest()->getPost('shipping_method');
18
- try {
19
- Mage::dispatchEvent(
20
- 'checkout_controller_multishipping_shipping_post', array('request' => $this->getRequest(), 'quote' => $this->_getCheckout()->getQuote())
21
- );
22
- $this->_getCheckout()->setShippingMethods($shippingMethods);
23
-
24
- //WEC chronorelais
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
- }
46
- }
47
- //ENDWEC chronorelais
48
-
49
- $this->_getState()->setActiveStep(
50
- Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING
51
- );
52
- $this->_getState()->setCompleteStep(
53
- Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING
54
- );
55
- $this->_redirect('*/*/billing');
56
- } catch (Exception $e) {
57
- $this->_getCheckoutSession()->addError($e->getMessage());
58
- $this->_redirect('*/*/shipping');
59
- }
60
- }
61
-
62
- /**
63
- * Get relais
64
- */
65
- public function getMultiRelaisAction() {
66
- $result = array();
67
- $postcode = $this->getRequest()->get('zip', '');
68
-
69
- if (extension_loaded('soap')) {
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);
76
-
77
- if ($webservbt) {
78
- Mage::getSingleton('core/session')->setMultiPostcode($postcode);
79
- $this->loadLayout('checkout_multishipping_shippingchronorelais');
80
- $result['update_section'] = array(
81
- 'name' => 'checkout-shipping-method-chronorelais-load_' . $this->getRequest()->get('index'),
82
- 'html' => str_replace("%%id%%", $this->getRequest()->get('index'), $this->_getChronoRelaisHtml())
83
- );
84
- $result['relaypoints'] = $webservbt;
85
- } else {
86
- $result['error'] = true;
87
- $result['message'] = $this->__('No point relay is associated with this postcode');
88
- }
89
-
90
- break;
91
- }
92
- }
93
- if (count($result) == 0) {
94
- $result['error'] = true;
95
- $result['message'] = $this->__('Issue with addresses');
96
- }
97
- } else {
98
- $result['error'] = true;
99
- $result['message'] = $this->__('Sorry for inconvenience, The SOAP extension is not installed in the server. Please contact the site administrator.');
100
- }
101
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
102
- }
103
-
104
- }
1
+ <?php
2
+
3
+ require_once 'Mage/Checkout/controllers/MultishippingController.php';
4
+
5
+ class Chronopost_Chronorelais_Checkout_MultishippingController extends Mage_Checkout_MultishippingController {
6
+
7
+ /**
8
+ * Get payment method step html
9
+ *
10
+ * @return string
11
+ */
12
+ protected function _getChronoRelaisHtml() {
13
+ return $this->getLayout()->getBlock('root')->toHtml();
14
+ }
15
+
16
+ public function shippingPostAction() {
17
+ $shippingMethods = $this->getRequest()->getPost('shipping_method');
18
+ try {
19
+ Mage::dispatchEvent(
20
+ 'checkout_controller_multishipping_shipping_post', array('request' => $this->getRequest(), 'quote' => $this->_getCheckout()->getQuote())
21
+ );
22
+ $this->_getCheckout()->setShippingMethods($shippingMethods);
23
+
24
+ //WEC chronorelais
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
+ }
46
+ }
47
+ //ENDWEC chronorelais
48
+
49
+ $this->_getState()->setActiveStep(
50
+ Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING
51
+ );
52
+ $this->_getState()->setCompleteStep(
53
+ Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING
54
+ );
55
+ $this->_redirect('*/*/billing');
56
+ } catch (Exception $e) {
57
+ $this->_getCheckoutSession()->addError($e->getMessage());
58
+ $this->_redirect('*/*/shipping');
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Get relais
64
+ */
65
+ public function getMultiRelaisAction() {
66
+ $result = array();
67
+ $postcode = $this->getRequest()->get('zip', '');
68
+
69
+ if (extension_loaded('soap')) {
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);
76
+
77
+ if ($webservbt) {
78
+ Mage::getSingleton('core/session')->setMultiPostcode($postcode);
79
+ $this->loadLayout('checkout_multishipping_shippingchronorelais');
80
+ $result['update_section'] = array(
81
+ 'name' => 'checkout-shipping-method-chronorelais-load_' . $this->getRequest()->get('index'),
82
+ 'html' => str_replace("%%id%%", $this->getRequest()->get('index'), $this->_getChronoRelaisHtml())
83
+ );
84
+ $result['relaypoints'] = $webservbt;
85
+ } else {
86
+ $result['error'] = true;
87
+ $result['message'] = $this->__('No point relay is associated with this postcode');
88
+ }
89
+
90
+ break;
91
+ }
92
+ }
93
+ if (count($result) == 0) {
94
+ $result['error'] = true;
95
+ $result['message'] = $this->__('Issue with addresses');
96
+ }
97
+ } else {
98
+ $result['error'] = true;
99
+ $result['message'] = $this->__('Sorry for inconvenience, The SOAP extension is not installed in the server. Please contact the site administrator.');
100
+ }
101
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
102
+ }
103
+
104
+ }
app/code/community/Chronopost/Chronorelais/controllers/IndexController.php CHANGED
@@ -1,11 +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
  }
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,121 +1,121 @@
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
-
14
- /**
15
- * Go to the tacking page
16
- * external function for mail link "Track Your Order" in shipment mail
17
- */
18
- public function trackingAction()
19
- {
20
- if($this->getRequest()->isGet()) {
21
- if($hash = $this->getRequest()->getParam('hash')) {
22
- $req_values = Mage::helper('shipping')->decodeTrackingHash($hash);
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
  }
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
+
14
+ /**
15
+ * Go to the tacking page
16
+ * external function for mail link "Track Your Order" in shipment mail
17
+ */
18
+ public function trackingAction()
19
+ {
20
+ if($this->getRequest()->isGet()) {
21
+ if($hash = $this->getRequest()->getParam('hash')) {
22
+ $req_values = Mage::helper('shipping')->decodeTrackingHash($hash);
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 CHANGED
@@ -1,38 +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
  }
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,673 +1,673 @@
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>
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,2433 +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_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>
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 tran