Chronopost - Version 1.0.1

Version Notes

Version destinée à Magento 1.6.X et supérieures. Testée sur Magento 1.7.0.
------------
Intégration de l'API Google Maps v3.
Ajout d'un exemple de configuration de tarifs spécifiques pour la Corse.
Correction d'un bug qui passait les commandes en invité au lieu de créer le compte pour un nouveau client.
Divers correctifs mineurs.

Download this release

Release Info

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


Code changes from version 0.4.0 to 1.0.1

Files changed (52) hide show
  1. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/Notification.php +55 -0
  2. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Checklogin.php +44 -0
  3. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Field/Enabled.php +19 -0
  4. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Fieldsetassurance.php +43 -0
  5. app/code/community/Chronopost/Chronorelais/Block/Checkout/Multishipping/Shipping/Method/Chronorelais.php +53 -52
  6. app/code/community/Chronopost/Chronorelais/Block/Checkout/Onepage/Shipping/Method/Chronorelais.php +21 -14
  7. app/code/community/Chronopost/Chronorelais/Block/Detail.php +4 -4
  8. app/code/community/Chronopost/Chronorelais/Block/Export/Orders/Grid.php +270 -270
  9. app/code/community/Chronopost/Chronorelais/Block/Filter.php +4 -13
  10. app/code/community/Chronopost/Chronorelais/Block/Sales/Bordereau.php +14 -0
  11. app/code/community/Chronopost/Chronorelais/Block/Sales/Bordereau/Grid.php +160 -0
  12. app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid.php +249 -203
  13. app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid/Renderer/Retoursav.php +28 -0
  14. app/code/community/Chronopost/Chronorelais/Helper/Data.php +252 -98
  15. app/code/community/Chronopost/Chronorelais/Helper/Webservice.php +436 -0
  16. app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelaisShipping.php +40 -6
  17. app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostC10.php +6 -0
  18. app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostC18.php +6 -0
  19. app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostCClassic.php +6 -0
  20. app/code/community/Chronopost/Chronorelais/Model/Config/Source/WeightUnit.php +11 -0
  21. app/code/community/Chronopost/Chronorelais/controllers/AjaxController.php +392 -366
  22. app/code/community/Chronopost/Chronorelais/controllers/Checkout/MultishippingController.php +110 -114
  23. app/code/community/Chronopost/Chronorelais/controllers/Checkout/OnepageController.php +281 -280
  24. app/code/community/Chronopost/Chronorelais/controllers/ExportController.php +444 -444
  25. app/code/community/Chronopost/Chronorelais/controllers/ImportController.php +248 -248
  26. app/code/community/Chronopost/Chronorelais/controllers/Sales/BordereauController.php +332 -0
  27. app/code/community/Chronopost/Chronorelais/controllers/Sales/ImpressionController.php +1026 -566
  28. app/code/community/Chronopost/Chronorelais/controllers/Sales/Order/ShipmentController.php +383 -274
  29. app/code/community/Chronopost/Chronorelais/etc/config.xml +451 -358
  30. app/code/community/Chronopost/Chronorelais/etc/system.xml +1545 -965
  31. app/code/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php +1331 -1230
  32. app/code/community/Chronopost/Chronorelais/includes/countries.inc.php +522 -522
  33. app/design/adminhtml/default/default/template/chronorelais/bordereau/grid.phtml +229 -0
  34. app/design/adminhtml/default/default/template/chronorelais/config/checklogin.phtml +40 -0
  35. app/design/adminhtml/default/default/template/chronorelais/notification.phtml +54 -0
  36. app/design/adminhtml/default/default/template/chronorelais/sales/order/view/tab/info.phtml +165 -0
  37. app/design/frontend/default/default/layout/chronorelais.xml +59 -59
  38. app/design/frontend/default/default/template/chronorelais/checkout/multishipping/shipping.phtml +152 -152
  39. app/design/frontend/default/default/template/chronorelais/checkout/multishipping/shipping_method/chronorelais.phtml +29 -29
  40. app/design/frontend/default/default/template/chronorelais/checkout/onepage/shipping_method.phtml +92 -92
  41. app/design/frontend/default/default/template/chronorelais/checkout/onepage/shipping_method/available.phtml +123 -123
  42. app/design/frontend/default/default/template/chronorelais/checkout/onepage/shipping_method/chronorelais.phtml +29 -29
  43. app/design/frontend/default/default/template/chronorelais/sales/order/history.phtml +80 -80
  44. app/design/frontend/default/default/template/chronorelais/sales/order/recent.phtml +79 -79
  45. app/etc/modules/WSChronopost_Chronorelais.xml +27 -27
  46. app/locale/fr_FR/Chronopost_Chronorelais.csv +2 -0
  47. js/chronopost/chronorelais/chronorelais.js +38 -0
  48. package.xml +4 -4
  49. skin/frontend/default/default/chronorelais/chronopost.png +0 -0
  50. skin/frontend/default/default/chronorelais/chronorelais.css +46 -46
  51. skin/frontend/default/default/chronorelais/chronorelais.png +0 -0
  52. skin/frontend/default/default/chronorelais/chronorelaismap.js +567 -567
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/Notification.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ protected function _prepareLayout()
6
+ {
7
+ parent::_prepareLayout();
8
+ if (!$this->getTemplate()) {
9
+ $this->setTemplate('chronorelais/notification.phtml');
10
+ }
11
+ return $this;
12
+ }
13
+
14
+ public function getSeverityIconsUrl()
15
+ {
16
+ return (Mage::app()->getFrontController()->getRequest()->isSecure() ? 'https://' : 'http://')
17
+ . sprintf(Mage::getStoreConfig(self::XML_SEVERITY_ICONS_URL_PATH), Mage::getVersion(),
18
+ 'SEVERITY_NOTICE');
19
+ }
20
+
21
+ public function canShow()
22
+ {
23
+ if (!Mage::getSingleton('admin/session')->isFirstPageAfterLogin()) {
24
+ return false;
25
+ }
26
+
27
+ $_helper = Mage::helper('chronorelais');
28
+ $account_number = $_helper->getConfigurationAccountNumber();
29
+ $password = $_helper->getConfigurationAccountPass();
30
+ $origin_postcode = $_helper->getConfigurationShipperInfo('zipcode');
31
+
32
+ $WSParams = array(
33
+ 'accountNumber' => $account_number,
34
+ 'password' => $password,
35
+ 'depCountryCode' => $_helper->getConfigurationShipperInfo('country'),
36
+ 'depZipCode' => $origin_postcode,
37
+ 'arrCountryCode' => $_helper->getConfigurationShipperInfo('country'),
38
+ 'arrZipCode' => $origin_postcode,
39
+ 'arrCity' => $_helper->getConfigurationShipperInfo('city'),
40
+ 'type' => 'M',
41
+ 'weight' => 1
42
+ );
43
+
44
+ $helperWS = Mage::helper('chronorelais/webservice');
45
+ $webservbt = $helperWS->checkLogin($WSParams);
46
+
47
+ if(!$webservbt) return true;
48
+
49
+ $webservbt = (array)$webservbt;
50
+ if($webservbt['errorCode'] != 0) { return true; }
51
+
52
+ return false;
53
+ }
54
+
55
+ }
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Checklogin.php ADDED
@@ -0,0 +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('chronorelais/ajax/checklogin')
39
+ ));
40
+
41
+
42
+ return $html.$this->_toHtml();
43
+ }
44
+ }
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Field/Enabled.php ADDED
@@ -0,0 +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
+ }
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Fieldsetassurance.php ADDED
@@ -0,0 +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
+ }
app/code/community/Chronopost/Chronorelais/Block/Checkout/Multishipping/Shipping/Method/Chronorelais.php CHANGED
@@ -1,52 +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
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl",array('trace'=> 0,'connection_timeout'=>10));
45
- $webservbt = $client->__call("rechercheBtParCodeproduitEtCodepostalEtDate",array(0,$postcode,0));
46
- $this->_chronorelais = $webservbt;
47
- }
48
-
49
- return $this->_chronorelais;
50
- }
51
-
52
- }
 
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/Chronorelais.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -32,22 +33,28 @@
32
  * @package Mage_Checkout
33
  * @author Magento Core Team <core@magentocommerce.com>
34
  */
35
- class Chronopost_Chronorelais_Block_Checkout_Onepage_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
- $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
43
- $address = $quote->getShippingAddress();
44
- $postcode = $address->getPostcode();
45
-
46
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl",array('trace'=> 0,'connection_timeout'=>10));
47
- $webservbt = $client->__call("rechercheBtParCodeproduitEtCodepostalEtDate",array(0,$postcode,0));
48
- $this->_chronorelais = $webservbt;
49
- }
50
-
 
 
 
 
 
 
51
  return $this->_chronorelais;
52
  }
53
 
1
  <?php
2
+
3
  /**
4
  * Magento
5
  *
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
+ if (empty($this->_chronorelais)) {
42
+ $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
43
+ $address = $quote->getShippingAddress();
44
+ $postcode = $address->getPostcode();
45
+ $helper = Mage::helper('chronorelais/webservice');
46
+ $params = $this->getRequest()->getParams();
47
+ if(isset($params['mappostalcode']))
48
+ {
49
+ $webservbt = $helper->getPointsRelaisByCp($params['mappostalcode']);
50
+ }
51
+ else
52
+ {
53
+ $webservbt = $helper->getPointRelaisByAddress();
54
+ }
55
+ $this->_chronorelais = $webservbt;
56
+ }
57
+
58
  return $this->_chronorelais;
59
  }
60
 
app/code/community/Chronopost/Chronorelais/Block/Detail.php CHANGED
@@ -14,11 +14,11 @@ class Chronopost_Chronorelais_Block_Detail extends Mage_Core_Block_Template
14
 
15
  if($btcode){
16
  $result = Mage::getModel('shipping/rate_result');
17
- ini_set("soap.wsdl_cache_enabled", "0");
18
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl");
19
- $webservbt = $client->__call("rechercheBtParIdChronopostA2Pas",array($btcode));
20
 
21
- return $webservbt[0];
22
  }
23
  else{
24
  return false;
14
 
15
  if($btcode){
16
  $result = Mage::getModel('shipping/rate_result');
17
+ ini_set("soap.wsdl_cache_enabled", "0");
18
+ $helper = Mage::helper('chronorelais/webservice');
19
+ $webservbt = $helper->getDetailRelaisPoint($btcode);
20
 
21
+ return $webservbt;
22
  }
23
  else{
24
  return false;
app/code/community/Chronopost/Chronorelais/Block/Export/Orders/Grid.php CHANGED
@@ -1,270 +1,270 @@
1
- <?php
2
- class Chronopost_Chronorelais_Block_Export_Orders_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
- {
4
-
5
- public function __construct()
6
- {
7
- parent::__construct();
8
- $this->setId('chronorelais_export_order_grid');
9
- $this->setUseAjax(false);
10
- $this->setDefaultSort('created_at');
11
- $this->setDefaultDir('DESC');
12
- $this->setSaveParametersInSession(true);
13
- }
14
-
15
- /**
16
- * Retrieve collection class
17
- *
18
- * @return string
19
- */
20
- protected function _getCollectionClass()
21
- {
22
- return 'sales/order_grid_collection';
23
- }
24
-
25
- protected function _prepareCollection()
26
- {
27
- $_chronopost_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronopost/deliver_on_saturday');
28
- $_chronorelais_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/deliver_on_saturday');
29
- if($_chronopost_deliver_saturday==1) { $_chronopost_deliver_saturday = 'Yes'; } else { $_chronopost_deliver_saturday = 'No';}
30
- if($_chronorelais_deliver_saturday==1) { $_chronorelais_deliver_saturday = 'Yes'; } else { $_chronorelais_deliver_saturday = 'No'; }
31
-
32
- $collection = Mage::getResourceModel($this->_getCollectionClass());
33
- $collection->join('order', 'main_table.entity_id = order.entity_id', 'shipping_description');
34
- $collection->join('order_payment', 'main_table.entity_id = order_payment.parent_id', 'method');
35
- $collection->getSelect()->joinLeft(array('oes' => Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status')), 'main_table.entity_id = oes.order_id', array("if(isNull(oes.livraison_le_samedi), CASE LOWER(SUBSTRING_INDEX(order.shipping_method,'_','1')) WHEN 'chronopost' THEN '$_chronopost_deliver_saturday' WHEN 'chronorelais' THEN '$_chronorelais_deliver_saturday' WHEN 'chronoexpress' THEN '--' ELSE 'No' END, oes.livraison_le_samedi) as livraison_le_samedi"));
36
- $collection->getSelect()->where('order.shipping_method LIKE "chronorelais%" OR order.shipping_method LIKE "chronopost%" OR order.shipping_method LIKE "chronoexpress%"');
37
-
38
- $this->setCollection($collection);
39
- return parent::_prepareCollection();
40
- }
41
-
42
- protected function _addColumnFilterToCollection($column)
43
- {
44
- if ($this->getCollection()) {
45
- $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
46
- if ($column->getFilterConditionCallback()) {
47
- call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
48
- } else {
49
- $cond = $column->getFilter()->getCondition();
50
- if ($field && isset($cond)) {
51
- // Le champ status est ambigu, il faut donc sp�cifier sa table lors de l'ajout pour filtrage
52
- $this->getCollection()->addFieldToFilter($field == "status" ? "main_table.status" : $field, $cond);
53
- }
54
- }
55
- }
56
- return $this;
57
- }
58
-
59
- protected function _prepareColumns()
60
- {
61
-
62
- $this->addColumn('real_order_id', array(
63
- 'header'=> Mage::helper('sales')->__('Order #'),
64
- 'width' => '80px',
65
- 'type' => 'text',
66
- 'index' => 'increment_id',
67
- 'filter' => false,
68
- ));
69
-
70
- if (!Mage::app()->isSingleStoreMode()) {
71
- $this->addColumn('store_id', array(
72
- 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
73
- 'index' => 'store_id',
74
- 'type' => 'store',
75
- 'store_view'=> true,
76
- 'display_deleted' => true,
77
- 'filter' => false,
78
- ));
79
- }
80
-
81
- $this->addColumn('created_at', array(
82
- 'header' => Mage::helper('sales')->__('Purchased On'),
83
- 'index' => 'created_at',
84
- 'type' => 'datetime',
85
- 'width' => '100px',
86
- 'filter' => false,
87
- ));
88
-
89
- $this->addColumn('billing_name', array(
90
- 'header' => Mage::helper('sales')->__('Bill to Name'),
91
- 'index' => 'billing_name',
92
- 'filter' => false,
93
- ));
94
-
95
- $this->addColumn('shipping_name', array(
96
- 'header' => Mage::helper('sales')->__('Ship to Name'),
97
- 'index' => 'shipping_name',
98
- 'filter' => false,
99
- ));
100
-
101
- $this->addColumn('base_grand_total', array(
102
- 'header' => Mage::helper('sales')->__('G.T. (Base)'),
103
- 'index' => 'base_grand_total',
104
- 'type' => 'currency',
105
- 'currency' => 'base_currency_code',
106
- 'filter' => false,
107
- ));
108
-
109
- $this->addColumn('grand_total', array(
110
- 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
111
- 'index' => 'grand_total',
112
- 'type' => 'currency',
113
- 'currency' => 'order_currency_code',
114
- 'filter' => false,
115
- ));
116
-
117
- $this->addColumn('shipping_description', array(
118
- 'header'=> Mage::helper('sales')->__('Shipping Method'),
119
- 'width' => '80px',
120
- 'type' => 'text',
121
- 'index' => 'shipping_description',
122
- 'filter' => false,
123
- 'truncate' => 30,
124
- 'escape' => true,
125
- ));
126
-
127
- $this->addColumn('payment', array(
128
- 'header' => Mage::helper('sales')->__('Mode de Paiement'),
129
- 'index' => 'method',
130
- 'width' => '100px',
131
- 'type' => 'text',
132
- 'filter' => false,
133
- ));
134
-
135
- if($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
136
- $this->addColumn('livraison_le_samedi', array(
137
- 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
138
- 'index' => 'livraison_le_samedi',
139
- 'width' => '100px',
140
- 'class' => 'a-center',
141
- 'filter' => false,
142
- ));
143
- }
144
-
145
- $this->addColumn('status', array(
146
- 'header' => Mage::helper('sales')->__('Status'),
147
- 'index' => 'status',
148
- 'type' => 'options',
149
- 'width' => '70px',
150
- 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
151
- ));
152
-
153
- if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
154
- $this->addColumn('action',
155
- array(
156
- 'header' => Mage::helper('sales')->__('Action'),
157
- 'width' => '50px',
158
- 'type' => 'action',
159
- 'getter' => 'getId',
160
- 'actions' => array(
161
- array(
162
- 'caption' => Mage::helper('sales')->__('View'),
163
- 'url' => array('base'=>'adminhtml/sales_order/view'),
164
- 'field' => 'order_id'
165
- )
166
- ),
167
- 'filter' => false,
168
- 'sortable' => false,
169
- 'index' => 'stores',
170
- 'is_system' => true,
171
- ));
172
- }
173
-
174
- return parent::_prepareColumns();
175
- }
176
-
177
- protected function _prepareMassaction111()
178
- {
179
- $this->setMassactionIdField('entity_id');
180
- $this->getMassactionBlock()->setFormFieldName('order_ids');
181
- $this->getMassactionBlock()->setUseSelectAll(false);
182
-
183
- $this->getMassactionBlock()->addItem('export_css', array(
184
- 'label'=> Mage::helper('chronorelais')->__('Export CSS'),
185
- 'url' => $this->getUrl('*/*/exportcss'),
186
- ));
187
- $this->getMassactionBlock()->addItem('export_cso', array(
188
- 'label'=> Mage::helper('chronorelais')->__('Export CSO'),
189
- 'url' => $this->getUrl('*/*/exportcso'),
190
- ));
191
-
192
- return $this;
193
- }
194
-
195
- protected function _prepareMassaction()
196
- {
197
- $this->setMassactionIdField('entity_id');
198
- $this->getMassactionBlock()->setFormFieldName('order_ids');
199
- $this->getMassactionBlock()->setUseSelectAll(false);
200
-
201
- if($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
202
- $shipping = array(
203
- 'Yes' => Mage::helper('chronorelais')->__('Yes'),
204
- 'No' => Mage::helper('chronorelais')->__('No'));
205
- $this->getMassactionBlock()->addItem('shipping', array(
206
- 'label' => Mage::helper('chronorelais')->__('Livraison le Samedi'),
207
- 'url' => $this->getUrl('*/*/massLivraisonSamediStatus', array('_current'=>true)),
208
- 'additional' => array(
209
- 'visibility' => array(
210
- 'name' => 'status',
211
- 'type' => 'select',
212
- 'class' => 'required-entry',
213
- 'style' => 'width:80px',
214
- 'label' => Mage::helper('chronorelais')->__('Status'),
215
- 'values' => $shipping
216
- )
217
- )
218
- ));
219
- }
220
-
221
- $export = array(
222
- 'css' => Mage::helper('chronorelais')->__('CSS Format'),
223
- 'cso' => Mage::helper('chronorelais')->__('CSO Format'));
224
- array_unshift($statuses, array('label'=>'', 'value'=>''));
225
- $this->getMassactionBlock()->addItem('export', array(
226
- 'label'=> Mage::helper('chronorelais')->__('Export'),
227
- 'url' => $this->getUrl('*/*/massExport', array('_current'=>true)),
228
- 'additional' => array(
229
- 'visibility' => array(
230
- 'name' => 'format',
231
- 'type' => 'select',
232
- 'class' => 'required-entry',
233
- 'label' => Mage::helper('chronorelais')->__('Format'),
234
- 'values' => $export
235
- )
236
- )
237
- ));
238
- return $this;
239
- }
240
-
241
- public function getRowUrl($row)
242
- {
243
- if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
244
- return $this->getUrl('adminhtml/sales_order/view', array('order_id' => $row->getId()));
245
- }
246
- return false;
247
- }
248
-
249
- public function getGridUrl()
250
- {
251
- return $this->getUrl('*/*/*', array('_current'=>true));
252
- }
253
-
254
- public function getAdditionalJavaScript()
255
- {
256
- echo "
257
- var element = document.getElementById('chronorelais_export_order_grid_massaction-select');
258
- element.selectedIndex = 1;
259
- if ('fireEvent' in element)
260
- element.fireEvent('onchange');
261
- else
262
- {
263
- var evt = document.createEvent('HTMLEvents');
264
- evt.initEvent('change', false, true);
265
- element.dispatchEvent(evt);
266
- }
267
- ";
268
- }
269
-
270
- }
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Export_Orders_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('chronorelais_export_order_grid');
9
+ $this->setUseAjax(false);
10
+ $this->setDefaultSort('created_at');
11
+ $this->setDefaultDir('DESC');
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ /**
16
+ * Retrieve collection class
17
+ *
18
+ * @return string
19
+ */
20
+ protected function _getCollectionClass()
21
+ {
22
+ return 'sales/order_grid_collection';
23
+ }
24
+
25
+ protected function _prepareCollection()
26
+ {
27
+ $_chronopost_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronopost/deliver_on_saturday');
28
+ $_chronorelais_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/deliver_on_saturday');
29
+ if($_chronopost_deliver_saturday==1) { $_chronopost_deliver_saturday = 'Yes'; } else { $_chronopost_deliver_saturday = 'No';}
30
+ if($_chronorelais_deliver_saturday==1) { $_chronorelais_deliver_saturday = 'Yes'; } else { $_chronorelais_deliver_saturday = 'No'; }
31
+
32
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
33
+ $collection->join('order', 'main_table.entity_id = order.entity_id', 'shipping_description');
34
+ $collection->join('order_payment', 'main_table.entity_id = order_payment.parent_id', 'method');
35
+ $collection->getSelect()->joinLeft(array('oes' => Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status')), 'main_table.entity_id = oes.order_id', array("if(isNull(oes.livraison_le_samedi), CASE LOWER(SUBSTRING_INDEX(order.shipping_method,'_','1')) WHEN 'chronopost' THEN '$_chronopost_deliver_saturday' WHEN 'chronorelais' THEN '$_chronorelais_deliver_saturday' WHEN 'chronoexpress' THEN '--' ELSE 'No' END, oes.livraison_le_samedi) as livraison_le_samedi"));
36
+ $collection->getSelect()->where('order.shipping_method LIKE "chronorelais%" OR order.shipping_method LIKE "chronopost%" OR order.shipping_method LIKE "chronoexpress%"');
37
+
38
+ $this->setCollection($collection);
39
+ return parent::_prepareCollection();
40
+ }
41
+
42
+ protected function _addColumnFilterToCollection($column)
43
+ {
44
+ if ($this->getCollection()) {
45
+ $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
46
+ if ($column->getFilterConditionCallback()) {
47
+ call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
48
+ } else {
49
+ $cond = $column->getFilter()->getCondition();
50
+ if ($field && isset($cond)) {
51
+ // Le champ status est ambigu, il faut donc sp�cifier sa table lors de l'ajout pour filtrage
52
+ $this->getCollection()->addFieldToFilter($field == "status" ? "main_table.status" : $field, $cond);
53
+ }
54
+ }
55
+ }
56
+ return $this;
57
+ }
58
+
59
+ protected function _prepareColumns()
60
+ {
61
+
62
+ $this->addColumn('real_order_id', array(
63
+ 'header'=> Mage::helper('sales')->__('Order #'),
64
+ 'width' => '80px',
65
+ 'type' => 'text',
66
+ 'index' => 'increment_id',
67
+ 'filter' => false,
68
+ ));
69
+
70
+ if (!Mage::app()->isSingleStoreMode()) {
71
+ $this->addColumn('store_id', array(
72
+ 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
73
+ 'index' => 'store_id',
74
+ 'type' => 'store',
75
+ 'store_view'=> true,
76
+ 'display_deleted' => true,
77
+ 'filter' => false,
78
+ ));
79
+ }
80
+
81
+ $this->addColumn('created_at', array(
82
+ 'header' => Mage::helper('sales')->__('Purchased On'),
83
+ 'index' => 'created_at',
84
+ 'type' => 'datetime',
85
+ 'width' => '100px',
86
+ 'filter' => false,
87
+ ));
88
+
89
+ $this->addColumn('billing_name', array(
90
+ 'header' => Mage::helper('sales')->__('Bill to Name'),
91
+ 'index' => 'billing_name',
92
+ 'filter' => false,
93
+ ));
94
+
95
+ $this->addColumn('shipping_name', array(
96
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
97
+ 'index' => 'shipping_name',
98
+ 'filter' => false,
99
+ ));
100
+
101
+ $this->addColumn('base_grand_total', array(
102
+ 'header' => Mage::helper('sales')->__('G.T. (Base)'),
103
+ 'index' => 'base_grand_total',
104
+ 'type' => 'currency',
105
+ 'currency' => 'base_currency_code',
106
+ 'filter' => false,
107
+ ));
108
+
109
+ $this->addColumn('grand_total', array(
110
+ 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
111
+ 'index' => 'grand_total',
112
+ 'type' => 'currency',
113
+ 'currency' => 'order_currency_code',
114
+ 'filter' => false,
115
+ ));
116
+
117
+ $this->addColumn('shipping_description', array(
118
+ 'header'=> Mage::helper('sales')->__('Shipping Method'),
119
+ 'width' => '80px',
120
+ 'type' => 'text',
121
+ 'index' => 'shipping_description',
122
+ 'filter' => false,
123
+ 'truncate' => 30,
124
+ 'escape' => true,
125
+ ));
126
+
127
+ $this->addColumn('payment', array(
128
+ 'header' => Mage::helper('sales')->__('Mode de Paiement'),
129
+ 'index' => 'method',
130
+ 'width' => '100px',
131
+ 'type' => 'text',
132
+ 'filter' => false,
133
+ ));
134
+
135
+ if($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
136
+ $this->addColumn('livraison_le_samedi', array(
137
+ 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
138
+ 'index' => 'livraison_le_samedi',
139
+ 'width' => '100px',
140
+ 'class' => 'a-center',
141
+ 'filter' => false,
142
+ ));
143
+ }
144
+
145
+ $this->addColumn('status', array(
146
+ 'header' => Mage::helper('sales')->__('Status'),
147
+ 'index' => 'status',
148
+ 'type' => 'options',
149
+ 'width' => '70px',
150
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
151
+ ));
152
+
153
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
154
+ $this->addColumn('action',
155
+ array(
156
+ 'header' => Mage::helper('sales')->__('Action'),
157
+ 'width' => '50px',
158
+ 'type' => 'action',
159
+ 'getter' => 'getId',
160
+ 'actions' => array(
161
+ array(
162
+ 'caption' => Mage::helper('sales')->__('View'),
163
+ 'url' => array('base'=>'adminhtml/sales_order/view'),
164
+ 'field' => 'order_id'
165
+ )
166
+ ),
167
+ 'filter' => false,
168
+ 'sortable' => false,
169
+ 'index' => 'stores',
170
+ 'is_system' => true,
171
+ ));
172
+ }
173
+
174
+ return parent::_prepareColumns();
175
+ }
176
+
177
+ protected function _prepareMassaction111()
178
+ {
179
+ $this->setMassactionIdField('entity_id');
180
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
181
+ $this->getMassactionBlock()->setUseSelectAll(false);
182
+
183
+ $this->getMassactionBlock()->addItem('export_css', array(
184
+ 'label'=> Mage::helper('chronorelais')->__('Export CSS'),
185
+ 'url' => $this->getUrl('*/*/exportcss'),
186
+ ));
187
+ $this->getMassactionBlock()->addItem('export_cso', array(
188
+ 'label'=> Mage::helper('chronorelais')->__('Export CSO'),
189
+ 'url' => $this->getUrl('*/*/exportcso'),
190
+ ));
191
+
192
+ return $this;
193
+ }
194
+
195
+ protected function _prepareMassaction()
196
+ {
197
+ $this->setMassactionIdField('entity_id');
198
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
199
+ $this->getMassactionBlock()->setUseSelectAll(false);
200
+
201
+ if($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
202
+ $shipping = array(
203
+ 'Yes' => Mage::helper('chronorelais')->__('Yes'),
204
+ 'No' => Mage::helper('chronorelais')->__('No'));
205
+ $this->getMassactionBlock()->addItem('shipping', array(
206
+ 'label' => Mage::helper('chronorelais')->__('Livraison le Samedi'),
207
+ 'url' => $this->getUrl('*/*/massLivraisonSamediStatus', array('_current'=>true)),
208
+ 'additional' => array(
209
+ 'visibility' => array(
210
+ 'name' => 'status',
211
+ 'type' => 'select',
212
+ 'class' => 'required-entry',
213
+ 'style' => 'width:80px',
214
+ 'label' => Mage::helper('chronorelais')->__('Status'),
215
+ 'values' => $shipping
216
+ )
217
+ )
218
+ ));
219
+ }
220
+
221
+ $export = array(
222
+ 'css' => Mage::helper('chronorelais')->__('CSS Format'),
223
+ 'cso' => Mage::helper('chronorelais')->__('CSO Format'));
224
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
225
+ $this->getMassactionBlock()->addItem('export', array(
226
+ 'label'=> Mage::helper('chronorelais')->__('Export'),
227
+ 'url' => $this->getUrl('*/*/massExport', array('_current'=>true)),
228
+ 'additional' => array(
229
+ 'visibility' => array(
230
+ 'name' => 'format',
231
+ 'type' => 'select',
232
+ 'class' => 'required-entry',
233
+ 'label' => Mage::helper('chronorelais')->__('Format'),
234
+ 'values' => $export
235
+ )
236
+ )
237
+ ));
238
+ return $this;
239
+ }
240
+
241
+ public function getRowUrl($row)
242
+ {
243
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
244
+ return $this->getUrl('adminhtml/sales_order/view', array('order_id' => $row->getId()));
245
+ }
246
+ return false;
247
+ }
248
+
249
+ public function getGridUrl()
250
+ {
251
+ return $this->getUrl('*/*/*', array('_current'=>true));
252
+ }
253
+
254
+ public function getAdditionalJavaScript()
255
+ {
256
+ echo "
257
+ var element = document.getElementById('chronorelais_export_order_grid_massaction-select');
258
+ element.selectedIndex = 1;
259
+ if ('fireEvent' in element)
260
+ element.fireEvent('onchange');
261
+ else
262
+ {
263
+ var evt = document.createEvent('HTMLEvents');
264
+ evt.initEvent('change', false, true);
265
+ element.dispatchEvent(evt);
266
+ }
267
+ ";
268
+ }
269
+
270
+ }
app/code/community/Chronopost/Chronorelais/Block/Filter.php CHANGED
@@ -14,18 +14,9 @@ class Chronopost_Chronorelais_Block_Filter extends Mage_Core_Block_Template
14
 
15
  if( $zipcode && $zipcode!="" ){
16
  $result = Mage::getModel('shipping/rate_result');
17
-
18
- try {
19
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl",array('trace'=> 0,'connection_timeout'=>10));
20
-
21
- $webservbt = $client->__call("rechercheBtParCodeproduitEtCodepostalEtDate",array(0,$zipcode,0));
22
-
23
- } catch(SoapFault $fault){
24
-
25
- return false;
26
- }
27
 
28
-
29
  return $webservbt;
30
  }
31
  else{
@@ -40,8 +31,8 @@ class Chronopost_Chronorelais_Block_Filter extends Mage_Core_Block_Template
40
  if($zipcode){
41
  $result = Mage::getModel('shipping/rate_result');
42
  ini_set("soap.wsdl_cache_enabled", "0");
43
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl");
44
- $webservbt = $client->__call("rechercheBtParCodeproduitEtCodepostalEtDate",array(0,$zipcode,0));
45
  return $webservbt;
46
  }
47
  else{
14
 
15
  if( $zipcode && $zipcode!="" ){
16
  $result = Mage::getModel('shipping/rate_result');
17
+ $helper = Mage::helper('chronorelais/webservice');
18
+ $webservbt = $helper->getPointsRelaisByCp($zipcode);
 
 
 
 
 
 
 
 
19
 
 
20
  return $webservbt;
21
  }
22
  else{
31
  if($zipcode){
32
  $result = Mage::getModel('shipping/rate_result');
33
  ini_set("soap.wsdl_cache_enabled", "0");
34
+ $helper = Mage::helper('chronorelais/webservice');
35
+ $webservbt = $helper->getPointsRelaisByCp($zipcode);
36
  return $webservbt;
37
  }
38
  else{
app/code/community/Chronopost/Chronorelais/Block/Sales/Bordereau.php ADDED
@@ -0,0 +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
+ }
app/code/community/Chronopost/Chronorelais/Block/Sales/Bordereau/Grid.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Block_Sales_Bordereau_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setTemplate('chronorelais/bordereau/grid.phtml'); /* Pour ajouter la phrase d'impression des bordereaux enxemplaires */
8
+ $this->setId('sales_order_grid');
9
+ $this->setDefaultSort('created_at');
10
+ $this->setDefaultDir('DESC');
11
+ }
12
+
13
+ /**
14
+ * Retrieve collection class
15
+ *
16
+ * @return string
17
+ */
18
+ protected function _getCollectionClass() {
19
+ return 'sales/order_grid_collection';
20
+ }
21
+
22
+ protected function _prepareCollection() {
23
+ $_chronopost_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronopost/deliver_on_saturday');
24
+ $_chronorelais_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/deliver_on_saturday');
25
+ if ($_chronopost_deliver_saturday == 1) {
26
+ $_chronopost_deliver_saturday = 'Yes';
27
+ } else {
28
+ $_chronopost_deliver_saturday = 'No';
29
+ }
30
+ if ($_chronorelais_deliver_saturday == 1) {
31
+ $_chronorelais_deliver_saturday = 'Yes';
32
+ } else {
33
+ $_chronorelais_deliver_saturday = 'No';
34
+ }
35
+
36
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
37
+ $collection->getSelect()->joinLeft(array('og' => $collection->getTable('sales/order')), 'main_table.entity_id = og.entity_id', array('CASE LOWER(SUBSTRING_INDEX(og.shipping_method,"_","1")) WHEN "chronoexpress" THEN "Chrono Express" WHEN "chronorelais" THEN "Chrono Relais" ELSE CONCAT(UCASE(SUBSTRING(SUBSTRING_INDEX(og.shipping_method,"_","1"),1,1)),LOWER(SUBSTRING(SUBSTRING_INDEX(og.shipping_method,"_","1"), 2))) END as chrono_shipping_method', 'og.total_qty_ordered'));
38
+ $collection->getSelect()->joinLeft(array('osg' => $collection->getTable('sales/shipment_grid')), 'main_table.entity_id = osg.order_id', array('if(isNull(osg.increment_id) , "--" , GROUP_CONCAT(DISTINCT osg.increment_id SEPARATOR \', \')) as shipment_increment_id', 'GROUP_CONCAT(DISTINCT osg.created_at SEPARATOR \', \') as shipment_created_at'));
39
+ $collection->getSelect()->joinLeft(array('ost' => $collection->getTable('sales/shipment_track')), 'main_table.entity_id = ost.order_id', array('if(isNull(ost.track_number) , "--" , GROUP_CONCAT(DISTINCT ost.track_number SEPARATOR \', \')) as track_number', 'if(isNull(ost.title) , "--" , GROUP_CONCAT(DISTINCT ost.title SEPARATOR \', \')) as title'));
40
+ $collection->getSelect()->joinLeft(array('oes' => Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status')), 'main_table.entity_id = oes.order_id', array("if(isNull(oes.livraison_le_samedi), CASE LOWER(SUBSTRING_INDEX(og.shipping_method,'_','1')) WHEN 'chronopost' THEN '$_chronopost_deliver_saturday' WHEN 'chronorelais' THEN '$_chronorelais_deliver_saturday' WHEN 'chronoexpress' THEN '--' ELSE 'No' END, oes.livraison_le_samedi) as livraison_le_samedi"));
41
+ $collection->getSelect()->where('og.shipping_method LIKE "chronorelais%" OR og.shipping_method LIKE "chronopost%" OR og.shipping_method LIKE "chronoexpress%"');
42
+ $collection->getSelect()->group('main_table.entity_id');
43
+ $sql = $collection->getSelectSql(true);
44
+ $collection->getSelect()->reset()->from(
45
+ array('e' => new Zend_Db_Expr("({$sql})")), array('e' => "*")
46
+ );
47
+
48
+ $this->setCollection($collection);
49
+ return parent::_prepareCollection();
50
+ }
51
+
52
+ protected function _prepareColumns() {
53
+
54
+ $this->addColumn('real_order_id', array(
55
+ 'header' => Mage::helper('sales')->__('Order #'),
56
+ 'width' => '100px',
57
+ 'type' => 'text',
58
+ 'index' => 'increment_id',
59
+ 'filter' => false,
60
+ ));
61
+
62
+ $this->addColumn('created_at', array(
63
+ 'header' => Mage::helper('sales')->__('Order Date'),
64
+ 'index' => 'created_at',
65
+ 'type' => 'datetime',
66
+ 'filter' => false,
67
+ ));
68
+
69
+ $this->addColumn('shipment_increment_id', array(
70
+ 'header' => Mage::helper('sales')->__('Shipment #'),
71
+ 'index' => 'shipment_increment_id',
72
+ 'type' => 'text',
73
+ 'width' => '100px',
74
+ 'filter' => false,
75
+ ));
76
+
77
+ $this->addColumn('shipment_created_at', array(
78
+ 'header' => Mage::helper('sales')->__('Date Shipped'),
79
+ 'index' => 'shipment_created_at',
80
+ 'type' => 'datetime',
81
+ 'filter' => false,
82
+ ));
83
+
84
+ $this->addColumn('shipping_name', array(
85
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
86
+ 'index' => 'shipping_name',
87
+ 'filter' => false,
88
+ ));
89
+
90
+ $this->addColumn('total_qty_ordered', array(
91
+ 'header' => Mage::helper('sales')->__('Total Qty'),
92
+ 'index' => 'total_qty_ordered',
93
+ 'type' => 'number',
94
+ 'filter' => false,
95
+ ));
96
+
97
+ $this->addColumn('track_number', array(
98
+ 'header' => Mage::helper('sales')->__('Tracking'),
99
+ 'index' => 'track_number',
100
+ 'filter' => false,
101
+ ));
102
+
103
+ $this->addColumn('chrono_shipping_method', array(
104
+ 'header' => Mage::helper('sales')->__('Mode de transport'),
105
+ 'index' => 'chrono_shipping_method',
106
+ 'type' => 'text',
107
+ 'filter' => false,
108
+ ));
109
+
110
+ $this->addColumn('status', array(
111
+ 'header' => Mage::helper('sales')->__('Status'),
112
+ 'index' => 'status',
113
+ 'type' => 'options',
114
+ 'width' => '90px',
115
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
116
+ ));
117
+
118
+ if ($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
119
+ $this->addColumn('livraison_le_samedi', array(
120
+ 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
121
+ 'index' => 'livraison_le_samedi',
122
+ 'width' => '100px',
123
+ 'class' => 'a-center',
124
+ 'filter' => false,
125
+ ));
126
+ }
127
+
128
+ return parent::_prepareColumns();
129
+ }
130
+
131
+ public function getRowUrl($row) {
132
+ if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/shipment')) {
133
+ return false;
134
+ }
135
+
136
+ return $this->getUrl('adminhtml/sales_order/view', array(
137
+ 'order_id' => $row->getId(),
138
+ )
139
+ );
140
+ }
141
+
142
+ protected function _prepareMassaction() {
143
+
144
+ $this->setMassactionIdField('entity_id');
145
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
146
+ $this->getMassactionBlock()->setUseSelectAll(false);
147
+
148
+ $this->getMassactionBlock()->addItem('print_bordereau', array(
149
+ 'label' => Mage::helper('chronorelais')->__('Imprimer le bordereau'),
150
+ 'url' => $this->getUrl('*/*/massPrintBordereau', array('_current' => true)),
151
+ 'selected' => true,
152
+ ));
153
+
154
+ return $this;
155
+ }
156
+
157
+ public function getGridUrl() {
158
+ return $this->getUrl('*/*/*', array('_current' => true));
159
+ }
160
+ }
app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid.php CHANGED
@@ -1,203 +1,249 @@
1
- <?php
2
- class Chronopost_Chronorelais_Block_Sales_Shipment_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
- {
4
-
5
- public function __construct()
6
- {
7
- parent::__construct();
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
- {
20
- return 'sales/order_grid_collection';
21
- }
22
-
23
- protected function _prepareCollection()
24
- {
25
- $_chronopost_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronopost/deliver_on_saturday');
26
- $_chronorelais_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/deliver_on_saturday');
27
- if($_chronopost_deliver_saturday==1) { $_chronopost_deliver_saturday = 'Yes'; } else { $_chronopost_deliver_saturday = 'No';}
28
- if($_chronorelais_deliver_saturday==1) { $_chronorelais_deliver_saturday = 'Yes'; } else { $_chronorelais_deliver_saturday = 'No'; }
29
-
30
- $collection = Mage::getResourceModel($this->_getCollectionClass());
31
- $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 shipping_method', 'og.total_qty_ordered'));
32
- $collection->getSelect()->joinLeft(array('osg' => $collection->getTable('sales/shipment_grid')), 'main_table.entity_id = osg.order_id', array('if(isNull(osg.increment_id) , "--" , GROUP_CONCAT(DISTINCT osg.increment_id SEPARATOR \', \')) as shipment_increment_id', 'GROUP_CONCAT(DISTINCT osg.created_at SEPARATOR \', \') as shipment_created_at'));
33
- $collection->getSelect()->joinLeft(array('ost' => $collection->getTable('sales/shipment_track')), 'main_table.entity_id = ost.order_id', array('if(isNull(ost.track_number) , "--" , GROUP_CONCAT(DISTINCT ost.track_number SEPARATOR \', \')) as track_number', 'if(isNull(ost.title) , "--" , GROUP_CONCAT(DISTINCT ost.title SEPARATOR \', \')) as title'));
34
- $collection->getSelect()->joinLeft(array('oes' => Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status')), 'main_table.entity_id = oes.order_id', array("if(isNull(oes.livraison_le_samedi), CASE LOWER(SUBSTRING_INDEX(og.shipping_method,'_','1')) WHEN 'chronopost' THEN '$_chronopost_deliver_saturday' WHEN 'chronorelais' THEN '$_chronorelais_deliver_saturday' WHEN 'chronoexpress' THEN '--' ELSE 'No' END, oes.livraison_le_samedi) as livraison_le_samedi"));
35
- $collection->getSelect()->where('og.shipping_method LIKE "chronorelais%" OR og.shipping_method LIKE "chronopost%" OR og.shipping_method LIKE "chronoexpress%"');
36
- $collection->getSelect()->group('main_table.entity_id');
37
- $sql = $collection->getSelectSql(true);
38
- $collection->getSelect()->reset()->from(
39
- array('e' =>new Zend_Db_Expr("({$sql})")),
40
- array('e' => "*")
41
- );
42
-
43
- $this->setCollection($collection);
44
- return parent::_prepareCollection();
45
- }
46
-
47
- protected function _prepareColumns()
48
- {
49
-
50
- $this->addColumn('real_order_id', array(
51
- 'header'=> Mage::helper('sales')->__('Order #'),
52
- 'width' => '100px',
53
- 'type' => 'text',
54
- 'index' => 'increment_id',
55
- 'filter' => false,
56
- ));
57
-
58
- $this->addColumn('created_at', array(
59
- 'header' => Mage::helper('sales')->__('Order Date'),
60
- 'index' => 'created_at',
61
- 'type' => 'datetime',
62
- 'filter' => false,
63
- ));
64
-
65
- $this->addColumn('shipment_increment_id', array(
66
- 'header' => Mage::helper('sales')->__('Shipment #'),
67
- 'index' => 'shipment_increment_id',
68
- 'type' => 'text',
69
- 'width' => '100px',
70
- 'filter' => false,
71
- ));
72
-
73
- $this->addColumn('shipment_created_at', array(
74
- 'header' => Mage::helper('sales')->__('Date Shipped'),
75
- 'index' => 'shipment_created_at',
76
- 'type' => 'datetime',
77
- 'filter' => false,
78
- ));
79
-
80
- $this->addColumn('shipping_name', array(
81
- 'header' => Mage::helper('sales')->__('Ship to Name'),
82
- 'index' => 'shipping_name',
83
- 'filter' => false,
84
- ));
85
-
86
- $this->addColumn('total_qty_ordered', array(
87
- 'header' => Mage::helper('sales')->__('Total Qty'),
88
- 'index' => 'total_qty_ordered',
89
- 'type' => 'number',
90
- 'filter' => false,
91
- ));
92
-
93
- $this->addColumn('track_number', array(
94
- 'header' => Mage::helper('sales')->__('Tracking'),
95
- 'index' => 'track_number',
96
- 'filter' => false,
97
- ));
98
-
99
- $this->addColumn('shipping_method', array(
100
- 'header' => Mage::helper('sales')->__('Mode de transport'),
101
- 'index' => 'shipping_method',
102
- 'type' => 'text',
103
- 'filter' => false,
104
- ));
105
-
106
- if($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
107
- $this->addColumn('livraison_le_samedi', array(
108
- 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
109
- 'index' => 'livraison_le_samedi',
110
- 'width' => '100px',
111
- 'class' => 'a-center',
112
- 'filter' => false,
113
- ));
114
- }
115
-
116
- $this->addColumn('download', array(
117
- 'header' => Mage::helper('chronorelais')->__('Etiquettes'),
118
- 'type' => 'action',
119
- 'getter' => 'getId',
120
- 'actions' => array(
121
- array(
122
- 'caption' => Mage::helper('chronorelais')->__('Imprimer'),
123
- 'url' => array(
124
- 'base'=>'chronorelais/sales_impression/print'
125
- ),
126
- 'target' => '_blank',
127
- 'field' => 'order_id'
128
- )
129
- ),
130
- 'filter' => false,
131
- 'sortable' => false,
132
- 'index' => 'stores'
133
- ));
134
-
135
- return parent::_prepareColumns();
136
- }
137
-
138
- public function getRowUrl($row)
139
- {
140
- if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/shipment')) {
141
- return false;
142
- }
143
-
144
- return $this->getUrl('adminhtml/sales_order/view',
145
- array(
146
- 'order_id'=> $row->getId(),
147
- )
148
- );
149
- }
150
-
151
- protected function _prepareMassaction()
152
- {
153
- if($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
154
- $this->setMassactionIdField('entity_id');
155
- $this->getMassactionBlock()->setFormFieldName('order_ids');
156
- $this->getMassactionBlock()->setUseSelectAll(false);
157
-
158
- $shipping = array(
159
- 'Yes' => Mage::helper('chronorelais')->__('Yes'),
160
- 'No' => Mage::helper('chronorelais')->__('No'));
161
- $this->getMassactionBlock()->addItem('shipping', array(
162
- 'label' => Mage::helper('chronorelais')->__('Livraison le Samedi'),
163
- 'url' => $this->getUrl('*/*/massLivraisonSamediStatus', array('_current'=>true)),
164
- 'additional' => array(
165
- 'visibility' => array(
166
- 'name' => 'status',
167
- 'type' => 'select',
168
- 'class' => 'required-entry',
169
- 'style' => 'width:80px',
170
- 'label' => Mage::helper('chronorelais')->__('Status'),
171
- 'values' => $shipping
172
- )
173
- )
174
- ));
175
-
176
- return $this;
177
- }
178
- }
179
-
180
- public function getGridUrl()
181
- {
182
- return $this->getUrl('*/*/*', array('_current' => true));
183
- }
184
-
185
- public function getAdditionalJavaScript()
186
- {
187
- echo "$$('#sales_order_grid_table tr td:nth-child(3)').each(function(item) {
188
- var chaine = item.innerHTML.replace(/^\s+/g,'').replace(/\s+$/g,'');
189
- if (chaine.split(', ').length > 1) {
190
- var content = '';
191
- var numbers = chaine.split(', ');
192
- var lien = $(item).next('.last').down('a');
193
- for (var i=0; i<numbers.length; i++) {
194
- content += '<a href=\"' + lien.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + numbers[i] + '/') + '\" target=\"_blank\">Exp&eacute;dition ' + numbers[i] + '</a><br />';
195
- }
196
- content += '';
197
- lien.up().innerHTML = content;
198
- //lien.writeAttribute('onclick', \"$(this).up().down('div').show(); return false;\");
199
- }
200
- });";
201
- }
202
-
203
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Block_Sales_Shipment_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('sales_order_grid');
8
+ $this->setDefaultSort('created_at');
9
+ $this->setDefaultDir('DESC');
10
+ }
11
+
12
+ /**
13
+ * Retrieve collection class
14
+ *
15
+ * @return string
16
+ */
17
+ protected function _getCollectionClass() {
18
+ return 'sales/order_grid_collection';
19
+ }
20
+
21
+ protected function _prepareCollection() {
22
+ $_chronopost_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronopost/deliver_on_saturday');
23
+ $_chronorelais_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/deliver_on_saturday');
24
+ if ($_chronopost_deliver_saturday == 1) {
25
+ $_chronopost_deliver_saturday = 'Yes';
26
+ } else {
27
+ $_chronopost_deliver_saturday = 'No';
28
+ }
29
+ if ($_chronorelais_deliver_saturday == 1) {
30
+ $_chronorelais_deliver_saturday = 'Yes';
31
+ } else {
32
+ $_chronorelais_deliver_saturday = 'No';
33
+ }
34
+
35
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
36
+ $collection->getSelect()->joinLeft(array('og' => $collection->getTable('sales/order')), 'main_table.entity_id = og.entity_id', array('CASE LOWER(SUBSTRING_INDEX(og.shipping_method,"_","1")) WHEN "chronoexpress" THEN "Chrono Express" WHEN "chronorelais" THEN "Chrono Relais" ELSE CONCAT(UCASE(SUBSTRING(SUBSTRING_INDEX(og.shipping_method,"_","1"),1,1)),LOWER(SUBSTRING(SUBSTRING_INDEX(og.shipping_method,"_","1"), 2))) END as chrono_shipping_method', 'og.total_qty_ordered'));
37
+ $collection->getSelect()->joinLeft(array('osg' => $collection->getTable('sales/shipment_grid')), 'main_table.entity_id = osg.order_id', array('if(isNull(osg.increment_id) , "--" , GROUP_CONCAT(DISTINCT osg.increment_id SEPARATOR \', \')) as shipment_increment_id', 'GROUP_CONCAT(DISTINCT osg.created_at SEPARATOR \', \') as shipment_created_at'));
38
+ $collection->getSelect()->joinLeft(array('ost' => $collection->getTable('sales/shipment_track')), 'main_table.entity_id = ost.order_id', array('if(isNull(ost.track_number) , "--" , GROUP_CONCAT(DISTINCT ost.track_number SEPARATOR \', \')) as track_number', 'if(isNull(ost.title) , "--" , GROUP_CONCAT(DISTINCT ost.title SEPARATOR \', \')) as title'));
39
+ $collection->getSelect()->joinLeft(array('oes' => Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status')), 'main_table.entity_id = oes.order_id', array("if(isNull(oes.livraison_le_samedi), CASE LOWER(SUBSTRING_INDEX(og.shipping_method,'_','1')) WHEN 'chronopost' THEN '$_chronopost_deliver_saturday' WHEN 'chronorelais' THEN '$_chronorelais_deliver_saturday' WHEN 'chronoexpress' THEN '--' ELSE 'No' END, oes.livraison_le_samedi) as livraison_le_samedi"));
40
+ $collection->getSelect()->where('og.shipping_method LIKE "chronorelais%" OR og.shipping_method LIKE "chronopost%" OR og.shipping_method LIKE "chronoexpress%"');
41
+ $collection->getSelect()->group('main_table.entity_id');
42
+ $sql = $collection->getSelectSql(true);
43
+ $collection->getSelect()->reset()->from(
44
+ array('e' => new Zend_Db_Expr("({$sql})")), array('e' => "*")
45
+ );
46
+
47
+ $this->setCollection($collection);
48
+ return parent::_prepareCollection();
49
+ }
50
+
51
+ protected function _prepareColumns() {
52
+
53
+ $this->addColumn('real_order_id', array(
54
+ 'header' => Mage::helper('sales')->__('Order #'),
55
+ 'width' => '100px',
56
+ 'type' => 'text',
57
+ 'index' => 'increment_id',
58
+ 'filter' => false,
59
+ ));
60
+
61
+ $this->addColumn('created_at', array(
62
+ 'header' => Mage::helper('sales')->__('Order Date'),
63
+ 'index' => 'created_at',
64
+ 'type' => 'datetime',
65
+ 'filter' => false,
66
+ ));
67
+
68
+ $this->addColumn('shipment_increment_id', array(
69
+ 'header' => Mage::helper('sales')->__('Shipment #'),
70
+ 'index' => 'shipment_increment_id',
71
+ 'type' => 'text',
72
+ 'width' => '100px',
73
+ 'filter' => false,
74
+ ));
75
+
76
+ $this->addColumn('shipment_created_at', array(
77
+ 'header' => Mage::helper('sales')->__('Date Shipped'),
78
+ 'index' => 'shipment_created_at',
79
+ 'type' => 'datetime',
80
+ 'filter' => false,
81
+ ));
82
+
83
+ $this->addColumn('shipping_name', array(
84
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
85
+ 'index' => 'shipping_name',
86
+ 'filter' => false,
87
+ ));
88
+
89
+ $this->addColumn('total_qty_ordered', array(
90
+ 'header' => Mage::helper('sales')->__('Total Qty'),
91
+ 'index' => 'total_qty_ordered',
92
+ 'type' => 'number',
93
+ 'filter' => false,
94
+ ));
95
+
96
+ $this->addColumn('track_number', array(
97
+ 'header' => Mage::helper('sales')->__('Tracking'),
98
+ 'index' => 'track_number',
99
+ 'filter' => false,
100
+ ));
101
+
102
+ $this->addColumn('chrono_shipping_method', array(
103
+ 'header' => Mage::helper('sales')->__('Mode de transport'),
104
+ 'index' => 'chrono_shipping_method',
105
+ 'type' => 'text',
106
+ 'filter' => false,
107
+ ));
108
+
109
+ if ($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
110
+ $this->addColumn('livraison_le_samedi', array(
111
+ 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
112
+ 'index' => 'livraison_le_samedi',
113
+ 'width' => '100px',
114
+ 'class' => 'a-center',
115
+ 'filter' => false,
116
+ ));
117
+ }
118
+
119
+ $this->addColumn('etiquette_expedition', array(
120
+ 'header' => Mage::helper('chronorelais')->__('Impression étiquette expédition'),
121
+ 'type' => 'action',
122
+ 'getter' => 'getId',
123
+ 'column_css_class' => 'etiquette_expedition',
124
+ 'actions' => array(
125
+ array(
126
+ 'caption' => Mage::helper('chronorelais')->__('Expédition'),
127
+ 'url' => array(
128
+ 'base' => 'chronorelais/sales_impression/print'
129
+ ),
130
+ 'field' => 'order_id'
131
+ )
132
+ ),
133
+ 'filter' => false,
134
+ 'sortable' => false,
135
+ 'index' => 'stores'
136
+ ));
137
+
138
+ $this->addColumn('etiquette_retour', array(
139
+ 'header' => Mage::helper('chronorelais')->__('Impression étiquette retour'),
140
+ 'type' => 'action',
141
+ 'getter' => 'getId',
142
+ 'column_css_class' => 'etiquette_retour',
143
+ 'actions' => array(
144
+ array(
145
+ 'caption' => Mage::helper('chronorelais')->__('Retour SAV'),
146
+ 'url' => array(
147
+ 'base' => 'chronorelais/sales_impression/printEtiquetteRetour'
148
+ ),
149
+ 'field' => 'order_id'
150
+ )
151
+ ),
152
+ 'filter' => false,
153
+ 'renderer' => 'Chronopost_Chronorelais_Block_Sales_Shipment_Grid_Renderer_Retoursav',
154
+ 'sortable' => false,
155
+ 'index' => 'stores'
156
+ ));
157
+
158
+ return parent::_prepareColumns();
159
+ }
160
+
161
+ public function getRowUrl($row) {
162
+ if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/shipment')) {
163
+ return false;
164
+ }
165
+
166
+ return $this->getUrl('adminhtml/sales_order/view', array(
167
+ 'order_id' => $row->getId(),
168
+ )
169
+ );
170
+ }
171
+
172
+ protected function _prepareMassaction() {
173
+
174
+ $this->setMassactionIdField('entity_id');
175
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
176
+ $this->getMassactionBlock()->setUseSelectAll(false);
177
+
178
+ $cmd = Mage::helper('chronorelais')->getConfigData('chronorelais/shipping/gs_path');
179
+ $res_shell = shell_exec($cmd);
180
+ if($res_shell !== null) {
181
+ $this->getMassactionBlock()->addItem('print', array(
182
+ 'label' => Mage::helper('chronorelais')->__('Imprimer les étiquettes'),
183
+ 'url' => $this->getUrl('*/*/printMass', array('_current' => true)),
184
+ ));
185
+ }
186
+
187
+ if ($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
188
+
189
+ $shipping = array(
190
+ 'Yes' => Mage::helper('chronorelais')->__('Yes'),
191
+ 'No' => Mage::helper('chronorelais')->__('No'));
192
+ $this->getMassactionBlock()->addItem('shipping', array(
193
+ 'label' => Mage::helper('chronorelais')->__('Livraison le Samedi'),
194
+ 'url' => $this->getUrl('*/*/massLivraisonSamediStatus', array('_current' => true)),
195
+ 'additional' => array(
196
+ 'visibility' => array(
197
+ 'name' => 'status',
198
+ 'type' => 'select',
199
+ 'class' => 'required-entry',
200
+ 'style' => 'width:80px',
201
+ 'label' => Mage::helper('chronorelais')->__('Status'),
202
+ 'values' => $shipping
203
+ )
204
+ )
205
+ ));
206
+ }
207
+ return $this;
208
+ }
209
+
210
+ public function getGridUrl() {
211
+ return $this->getUrl('*/*/*', array('_current' => true));
212
+ }
213
+
214
+ public function getAdditionalJavaScript() {
215
+ echo "$$('#sales_order_grid_table tr td:nth-child(4)').each(function(item) {
216
+ var chaine = item.innerHTML.replace(/^\s+/g,'').replace(/\s+$/g,'');
217
+ var lienExpedition = $(item).next('.etiquette_expedition').down('a');
218
+ var lienRetour = $(item).next('.etiquette_retour').down('a');
219
+ if (chaine.split(', ').length > 1) {
220
+ var contentExpedition = '';
221
+ var contentRetour = '';
222
+ var numbers = chaine.split(', ');
223
+ for (var i=0; i<numbers.length; i++) {
224
+ contentExpedition += '<a href=\"' + lienExpedition.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + numbers[i] + '/') + '\">Exp&eacute;dition ' + numbers[i] + '</a><br />';
225
+ contentRetour += '<a href=\"' + lienRetour.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + numbers[i] + '/') + '\" >Retour SAV ' + numbers[i] + '</a><br />';
226
+ }
227
+ lienExpedition.up().innerHTML = contentExpedition;
228
+ if(typeof lienRetour !== 'undefined')
229
+ {
230
+ lienRetour.up().innerHTML = contentRetour;
231
+ }
232
+ }
233
+ else if(chaine.length > 2) {
234
+ lienExpedition.up().innerHTML = '<a href=\"' + lienExpedition.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + chaine + '/') + '\">Exp&eacute;dition</a><br />';
235
+ if(typeof lienRetour !== 'undefined')
236
+ {
237
+ lienRetour.up().innerHTML = '<a href=\"' + lienRetour.href.replace(/\/order_id\/\d+\//, '/shipment_increment_id/' + chaine + '/') + '\" >Retour SAV</a><br />';
238
+ }
239
+ }
240
+ else {
241
+ if(typeof lienRetour !== 'undefined')
242
+ {
243
+ lienRetour.up().innerHTML = '';
244
+ }
245
+ }
246
+ });";
247
+ }
248
+
249
+ }
app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid/Renderer/Retoursav.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Sales_Shipment_Grid_Renderer_Retoursav
3
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
4
+ {
5
+
6
+ public function render(Varien_Object $row)
7
+ {
8
+ $actions = $this->getColumn()->getActions();
9
+ if ( empty($actions) || !is_array($actions) ) {
10
+ return '&nbsp;';
11
+ }
12
+ $countryId = $row->getShippingAddress()->getCountryId();
13
+
14
+ if($countryId != 'FR')
15
+ return '';
16
+ $out = '';
17
+ $i = 0;
18
+ foreach ($actions as $action){
19
+ if (is_array($action) ) {
20
+ if($i > 0)
21
+ $out .= '<br />';
22
+ $out .= $this->_toLinkHtml($action, $row);
23
+ $i++;
24
+ }
25
+ }
26
+ return $out;
27
+ }
28
+ }
app/code/community/Chronopost/Chronorelais/Helper/Data.php CHANGED
@@ -1,116 +1,222 @@
1
  <?php
2
- class Chronopost_Chronorelais_Helper_Data extends Mage_Core_Helper_Abstract
3
- {
4
- //Choronorelais settings for productCode
5
- const CHRONO_POST = '01'; // for France
6
- const CHRONO_EXPRESS = '17'; // for Interantional
7
- const CHRONORELAIS = '86'; // for Chronorelais
8
- const CHRONOPOST_13H = '13H'; // for France
9
- const CHRONOEXPRESS_EI = 'EI'; // for Interantional
10
- const CHRONORELAIS_PR = 'PR'; // for Chronorelais
11
- const CHRONOPOST_DEFAULT_COUNTRY = 'FR';
12
- const CHRONOPOST_TRACKING_URL = 'http://wsshipping.chronopost.fr/shipping/services/getReservedSkybill?reservationNumber={trackingNumber}';
13
- // if you are in a period outside thursday 18:00 to friday 15:00, there is no shipping on saturday
14
- var $SaturdayShippingDays = array(
15
- 'startday' => 'thursday',
16
- 'endday' => 'friday',
17
- 'starttime' => '18:00:00',
18
- 'endtime' => '15:00:00'
19
- );
20
-
21
- public function getConfigData($path) {
 
 
 
 
 
 
 
 
 
 
22
  return Mage::getStoreConfig($path, Mage::app()->getStore());
23
- }
24
- public function getSaturdayShippingDays() {
 
25
  return $this->SaturdayShippingDays;
26
- }
27
- public function getCurrentTimeByZone($timezone="Europe/Paris", $format="l H:i") {
28
- $d = new DateTime("now", new DateTimeZone($timezone));
 
29
  return $d->format($format);
30
- }
31
- public function isSendingDay() {
32
- $shipping_days = $this->getSaturdayShippingDays();
33
- $current_day = strtolower($this->getCurrentTimeByZone("Europe/Paris", "l"));
34
- $current_date = $this->getCurrentTimeByZone("Europe/Paris", "Y-m-d H:i:s");
35
- $current_datetime = explode(' ',$current_date);
36
-
37
- //get timestamps
38
- $start_timestamp = strtotime($current_datetime[0]." ".$shipping_days['starttime']);
39
- $end_timestamp = strtotime($current_datetime[0]." ".$shipping_days['endtime']);
40
- $current_timestamp = strtotime($current_date);
41
-
42
- $sending_day = false;
43
- if($shipping_days['startday']==$current_day && $current_timestamp>=$start_timestamp) {
44
- $sending_day = true;
45
- } elseif($shipping_days['endday']==$current_day && $current_timestamp<=$end_timestamp) {
46
- $sending_day = true;
47
- }
48
- return $sending_day;
49
- }
50
-
51
- /**
52
- * General Shipping configuration
53
- */
 
54
  public function getConfigurationAccountNumber() {
55
  return $this->getConfigData('chronorelais/shipping/account_number');
56
  }
 
57
  public function getConfigurationSubAccountNumber() {
58
  return $this->getConfigData('chronorelais/shipping/sub_account_number');
59
  }
 
60
  public function getConfigurationAccountPass() {
61
  return $this->getConfigData('chronorelais/shipping/account_pass');
62
  }
 
63
  public function getConfigurationTrackingViewUrl() {
64
  return $this->getConfigData('chronorelais/shipping/tracking_view_url');
65
  }
 
66
  public function getConfigurationGoogleMapAPIKey() {
67
  return $this->getConfigData('chronorelais/shipping/google_map_api');
68
  }
 
69
  public function getChronoProductCode($country, $code='') {
70
- $productcode = '';
71
- $code = strtolower($code);
72
- if($code=='chronorelais') {
73
- $productcode = self::CHRONORELAIS;
74
- } elseif($code=='chronopost') {
75
- $productcode = self::CHRONO_POST;
76
- } else {
77
- $productcode = self::CHRONO_EXPRESS;
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  return $productcode;
80
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  public function getChronoProductCodeString($code='') {
82
- $productcode = '';
83
- $code = strtolower($code);
84
- if($code=='chronorelais') {
85
- $productcode = self::CHRONORELAIS_PR;
86
- } elseif($code=='chronopost') {
87
- $productcode = self::CHRONOPOST_13H;
88
- } else {
89
- $productcode = self::CHRONOEXPRESS_EI;
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  return $productcode;
92
  }
 
93
  public function getConfigurationTrackingUrl() {
94
  return self::CHRONOPOST_TRACKING_URL;
95
  }
96
-
97
- /**
98
  * Export configuration
99
  */
100
  public function getConfigurationFileExtension($export_type='css') {
101
- return $this->getConfigData('chronorelais/export_'.$export_type.'/file_extension');
102
  }
 
103
  public function getConfigurationFileCharset($export_type='css') {
104
- return $this->getConfigData('chronorelais/export_'.$export_type.'/file_charset');
105
  }
 
106
  public function getConfigurationEndOfLineCharacter($export_type='css') {
107
- return $this->getConfigData('chronorelais/export_'.$export_type.'/endofline_character');
108
  }
 
109
  public function getConfigurationFieldDelimiter($export_type='css') {
110
- return $this->getConfigData('chronorelais/export_'.$export_type.'/field_delimiter');
111
  }
 
112
  public function getConfigurationFieldSeparator($export_type='css') {
113
- return $this->getConfigData('chronorelais/export_'.$export_type.'/field_separator');
114
  }
115
 
116
  /**
@@ -119,12 +225,15 @@ class Chronopost_Chronorelais_Helper_Data extends Mage_Core_Helper_Abstract
119
  public function getConfigurationSendEmail() {
120
  return $this->getConfigData('chronorelais/import/send_email');
121
  }
 
122
  public function getConfigurationIncludeComment() {
123
  return $this->getConfigData('chronorelais/import/include_comment');
124
  }
 
125
  public function getConfigurationDefaultTrackingTitle() {
126
  return $this->getConfigData('chronorelais/import/default_tracking_title');
127
  }
 
128
  public function getConfigurationShippingComment() {
129
  return $this->getConfigData('chronorelais/import/shipping_comment');
130
  }
@@ -133,26 +242,26 @@ class Chronopost_Chronorelais_Helper_Data extends Mage_Core_Helper_Abstract
133
  * Shipper Information
134
  */
135
  public function getConfigurationShipperInfo($field) {
136
- $fieldValue = '';
137
- if($field) {
138
- if($this->getConfigData('chronorelais/shipperinformation/'.$field)) {
139
- $fieldValue = $this->getConfigData('chronorelais/shipperinformation/'.$field);
140
- }
141
- }
142
- return $fieldValue;
143
  }
144
 
145
  /**
146
  * Chronopost Customer Information
147
  */
148
  public function getConfigurationCustomerInfo($field) {
149
- $fieldValue = '';
150
- if($field) {
151
- if($this->getConfigData('chronorelais/customerinformation/'.$field)) {
152
- $fieldValue = $this->getConfigData('chronorelais/customerinformation/'.$field);
153
- }
154
- }
155
- return $fieldValue;
156
  }
157
 
158
  /**
@@ -162,16 +271,61 @@ class Chronopost_Chronorelais_Helper_Data extends Mage_Core_Helper_Abstract
162
  return $this->getConfigData('chronorelais/skybillparam/mode');
163
  }
164
 
165
- /* Get Livraison le Samedi status by orderid */
166
- public function getLivraisonSamediStatus($order_id)
167
- {
168
- $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
169
- $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
170
- $select = $_connection->select()
171
- ->from($_table, 'livraison_le_samedi')
172
- ->where('order_id=?', $order_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  $status = $_connection->fetchOne($select);
174
- return $status;
175
- }
 
 
 
 
 
 
 
 
176
 
177
  }
1
  <?php
2
+
3
+ class Chronopost_Chronorelais_Helper_Data extends Mage_Core_Helper_Abstract {
4
+ //Choronorelais settings for productCode
5
+ const CHRONO_POST = '01'; // for France
6
+ const CHRONO_POST_BAL = '58'; // For france avec option BAL
7
+ const CHRONO_EXPRESS = '17'; // for Interantional
8
+ const CHRONORELAIS = '86'; // for Chronorelais
9
+ const CHRONOPOST_C10 = '02'; // for Chronopost C10
10
+ const CHRONOPOST_C18 = '16'; // for Chronopost C18
11
+ const CHRONOPOST_C18_BAL = '2M'; // for Chronopost C18 avec option BAL
12
+ const CHRONOPOST_CClassic = '44'; // for Chronopost CClassic
13
+ const CHRONOPOST_13H = '13H'; // for France
14
+ const CHRONOPOST_13H_BAL = '13H BAL'; // for France BAL
15
+ const CHRONOPOST_C10_STR = '10H'; // for Chronopost C10
16
+ const CHRONOPOST_C18_STR = '18H'; // for Chronopost C18
17
+ const CHRONOPOST_C18_BAL_STR = '18H BAL'; // for Chronopost C18 BAL
18
+ const CHRONOPOST_CClassic_STR = 'CClassic'; // for Chronopost CClassic
19
+ const CHRONOEXPRESS_EI = 'EI'; // for Interantional
20
+ const CHRONORELAIS_PR = 'PR'; // for Chronorelais
21
+ const CHRONOPOST_DEFAULT_COUNTRY = 'FR';
22
+ const CHRONOPOST_TRACKING_URL = 'http://wsshipping.chronopost.fr/shipping/services/getReservedSkybill?reservationNumber={trackingNumber}';
23
+ // if you are in a period outside thursday 18:00 to friday 15:00, there is no shipping on saturday
24
+ var $SaturdayShippingDays = array(
25
+ 'startday' => 'thursday',
26
+ 'endday' => 'friday',
27
+ 'starttime' => '18:00:00',
28
+ 'endtime' => '15:00:00'
29
+ );
30
+
31
+ public function getConfigData($path) {
32
  return Mage::getStoreConfig($path, Mage::app()->getStore());
33
+ }
34
+
35
+ public function getSaturdayShippingDays() {
36
  return $this->SaturdayShippingDays;
37
+ }
38
+
39
+ public function getCurrentTimeByZone($timezone="Europe/Paris", $format="l H:i") {
40
+ $d = new DateTime("now", new DateTimeZone($timezone));
41
  return $d->format($format);
42
+ }
43
+
44
+ public function isSendingDay() {
45
+ $shipping_days = $this->getSaturdayShippingDays();
46
+ $current_day = strtolower($this->getCurrentTimeByZone("Europe/Paris", "l"));
47
+ $current_date = $this->getCurrentTimeByZone("Europe/Paris", "Y-m-d H:i:s");
48
+ $current_datetime = explode(' ', $current_date);
49
+
50
+ //get timestamps
51
+ $start_timestamp = strtotime($current_datetime[0] . " " . $shipping_days['starttime']);
52
+ $end_timestamp = strtotime($current_datetime[0] . " " . $shipping_days['endtime']);
53
+ $current_timestamp = strtotime($current_date);
54
+
55
+ $sending_day = false;
56
+ if ($shipping_days['startday'] == $current_day && $current_timestamp >= $start_timestamp) {
57
+ $sending_day = true;
58
+ } elseif ($shipping_days['endday'] == $current_day && $current_timestamp <= $end_timestamp) {
59
+ $sending_day = true;
60
+ }
61
+ return $sending_day;
62
+ }
63
+
64
+ /**
65
+ * General Shipping configuration
66
+ */
67
  public function getConfigurationAccountNumber() {
68
  return $this->getConfigData('chronorelais/shipping/account_number');
69
  }
70
+
71
  public function getConfigurationSubAccountNumber() {
72
  return $this->getConfigData('chronorelais/shipping/sub_account_number');
73
  }
74
+
75
  public function getConfigurationAccountPass() {
76
  return $this->getConfigData('chronorelais/shipping/account_pass');
77
  }
78
+
79
  public function getConfigurationTrackingViewUrl() {
80
  return $this->getConfigData('chronorelais/shipping/tracking_view_url');
81
  }
82
+
83
  public function getConfigurationGoogleMapAPIKey() {
84
  return $this->getConfigData('chronorelais/shipping/google_map_api');
85
  }
86
+
87
  public function getChronoProductCode($country, $code='') {
88
+ $productcode = '';
89
+ $code = strtolower($code);
90
+
91
+ switch($code) {
92
+ case 'chronorelais' :
93
+ $productcode = self::CHRONORELAIS;
94
+ break;
95
+ case 'chronopost' :
96
+ $productcode = self::CHRONO_POST;
97
+ break;
98
+ case 'chronoexpress' :
99
+ $productcode = self::CHRONO_EXPRESS;
100
+ break;
101
+ case 'chronopostc10' :
102
+ $productcode = self::CHRONOPOST_C10;
103
+ break;
104
+ case 'chronopostc18' :
105
+ $productcode = self::CHRONOPOST_C18;
106
+ break;
107
+ case 'chronopostcclassic' :
108
+ $productcode = self::CHRONOPOST_CClassic;
109
+ break;
110
+ }
111
  return $productcode;
112
  }
113
+
114
+ public function getChronoProductCodeToShipment($code='') {
115
+ $productcode = '';
116
+ $code = strtolower($code);
117
+
118
+ switch($code) {
119
+ case 'chronorelais' :
120
+ $productcode = self::CHRONORELAIS;
121
+ break;
122
+ case 'chronopost' :
123
+ if($this->getConfigOptionBAL()) {
124
+ $productcode = self::CHRONO_POST_BAL;
125
+ }
126
+ else {
127
+ $productcode = self::CHRONO_POST;
128
+ }
129
+ break;
130
+ case 'chronoexpress' :
131
+ $productcode = self::CHRONO_EXPRESS;
132
+ break;
133
+ case 'chronopostc10' :
134
+ $productcode = self::CHRONOPOST_C10;
135
+ break;
136
+ case 'chronopostc18' :
137
+ if($this->getConfigOptionBAL()) {
138
+ $productcode = self::CHRONOPOST_C18_BAL;
139
+ }
140
+ else {
141
+ $productcode = self::CHRONOPOST_C18;
142
+ }
143
+ break;
144
+ case 'chronopostcclassic' :
145
+ $productcode = self::CHRONOPOST_CClassic;
146
+ break;
147
+ }
148
+ return $productcode;
149
+ }
150
+
151
  public function getChronoProductCodeString($code='') {
152
+ $productcode = '';
153
+ $code = strtolower($code);
154
+
155
+ switch($code) {
156
+ case 'chronorelais' : $productcode = self::CHRONORELAIS_PR; break;
157
+ case 'chronopost' : $productcode = self::CHRONOPOST_13H; break;
158
+ case 'chronoexpress' : $productcode = self::CHRONOEXPRESS_EI; break;
159
+ case 'chronopostc10' : $productcode = self::CHRONOPOST_C10_STR; break;
160
+ case 'chronopostc18' : $productcode = self::CHRONOPOST_C18_STR; break;
161
+ case 'chronopostcclassic' : $productcode = self::CHRONOPOST_CClassic_STR; break;
162
+ }
163
+ return $productcode;
164
+ }
165
+
166
+ public function getChronoProductCodeStringWithBAL($code='') {
167
+ $productcode = '';
168
+ $code = strtolower($code);
169
+
170
+ switch($code) {
171
+ case 'chronorelais' : $productcode = self::CHRONORELAIS_PR; break;
172
+ case 'chronopost' :
173
+ if($this->getConfigOptionBAL()) {
174
+ $productcode = self::CHRONOPOST_13H_BAL;
175
+ }
176
+ else {
177
+ $productcode = self::CHRONOPOST_13H;
178
+ }
179
+ break;
180
+ case 'chronoexpress' : $productcode = self::CHRONOEXPRESS_EI; break;
181
+ case 'chronopostc10' : $productcode = self::CHRONOPOST_C10_STR; break;
182
+ case 'chronopostc18' :
183
+ if($this->getConfigOptionBAL()) {
184
+ $productcode = self::CHRONOPOST_C18_BAL_STR;
185
+ }
186
+ else {
187
+ $productcode = self::CHRONOPOST_C18_STR;
188
+ }
189
+ break;
190
+ case 'chronopostcclassic' : $productcode = self::CHRONOPOST_CClassic_STR; break;
191
+ }
192
  return $productcode;
193
  }
194
+
195
  public function getConfigurationTrackingUrl() {
196
  return self::CHRONOPOST_TRACKING_URL;
197
  }
198
+
199
+ /**
200
  * Export configuration
201
  */
202
  public function getConfigurationFileExtension($export_type='css') {
203
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/file_extension');
204
  }
205
+
206
  public function getConfigurationFileCharset($export_type='css') {
207
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/file_charset');
208
  }
209
+
210
  public function getConfigurationEndOfLineCharacter($export_type='css') {
211
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/endofline_character');
212
  }
213
+
214
  public function getConfigurationFieldDelimiter($export_type='css') {
215
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/field_delimiter');
216
  }
217
+
218
  public function getConfigurationFieldSeparator($export_type='css') {
219
+ return $this->getConfigData('chronorelais/export_' . $export_type . '/field_separator');
220
  }
221
 
222
  /**
225
  public function getConfigurationSendEmail() {
226
  return $this->getConfigData('chronorelais/import/send_email');
227
  }
228
+
229
  public function getConfigurationIncludeComment() {
230
  return $this->getConfigData('chronorelais/import/include_comment');
231
  }
232
+
233
  public function getConfigurationDefaultTrackingTitle() {
234
  return $this->getConfigData('chronorelais/import/default_tracking_title');
235
  }
236
+
237
  public function getConfigurationShippingComment() {
238
  return $this->getConfigData('chronorelais/import/shipping_comment');
239
  }
242
  * Shipper Information
243
  */
244
  public function getConfigurationShipperInfo($field) {
245
+ $fieldValue = '';
246
+ if ($field) {
247
+ if ($this->getConfigData('chronorelais/shipperinformation/' . $field)) {
248
+ $fieldValue = $this->getConfigData('chronorelais/shipperinformation/' . $field);
249
+ }
250
+ }
251
+ return $fieldValue;
252
  }
253
 
254
  /**
255
  * Chronopost Customer Information
256
  */
257
  public function getConfigurationCustomerInfo($field) {
258
+ $fieldValue = '';
259
+ if ($field) {
260
+ if ($this->getConfigData('chronorelais/customerinformation/' . $field)) {
261
+ $fieldValue = $this->getConfigData('chronorelais/customerinformation/' . $field);
262
+ }
263
+ }
264
+ return $fieldValue;
265
  }
266
 
267
  /**
271
  return $this->getConfigData('chronorelais/skybillparam/mode');
272
  }
273
 
274
+ /*
275
+ * Weight unit
276
+ */
277
+ public function getConfigWeightUnit() {
278
+ return $this->getConfigData('chronorelais/weightunit/unit');
279
+ }
280
+
281
+ /*
282
+ * Option BAL
283
+ */
284
+ public function getConfigOptionBAL() {
285
+ return $this->getConfigData('chronorelais/optionbal/enabled');
286
+ }
287
+
288
+ public function hasOptionBAL($order) {
289
+ $shippingMethod = explode('_',$order->getShippingMethod());
290
+ $shippingMethod = $shippingMethod[1];
291
+ $shippingMethodAllowBAL = array('chronopost','chronopostc18');
292
+ if(in_array(strtolower($shippingMethod), $shippingMethodAllowBAL) && $this->getConfigOptionBAL()) {
293
+ return true;
294
+ }
295
+ return false;
296
+ }
297
+
298
+ /*
299
+ * Assurance Ad Valorem
300
+ */
301
+ public function assuranceAdValoremEnabled() {
302
+ return $this->getConfigData('chronorelais/assurance/enabled');
303
+ }
304
+ public function assuranceAdValoremAmount() {
305
+ return $this->getConfigData('chronorelais/assurance/amount');
306
+ }
307
+ public function getMaxAdValoremAmount() {
308
+ return 20000;
309
+ }
310
+
311
+ /* Get Livraison le Samedi status by orderid */
312
+
313
+ public function getLivraisonSamediStatus($order_id) {
314
+ $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
315
+ $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
316
+ $select = $_connection->select()
317
+ ->from($_table, 'livraison_le_samedi')
318
+ ->where('order_id=?', $order_id);
319
  $status = $_connection->fetchOne($select);
320
+ return $status;
321
+ }
322
+
323
+
324
+ /*
325
+ * Return true si la méthode de livraison fait partie du contrat du marchant
326
+ */
327
+ public function shippingMethodEnabled($shippingMethod) {
328
+ return true;
329
+ }
330
 
331
  }
app/code/community/Chronopost/Chronorelais/Helper/Webservice.php ADDED
@@ -0,0 +1,436 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Helper_Webservice extends Mage_Core_Helper_Abstract {
4
+
5
+ var $methodsAllowed = false;
6
+
7
+ public function getPointsRelaisByCp($cp) {
8
+
9
+ try {
10
+ $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl",array('trace'=> 0,'connection_timeout'=>10));
11
+ $webservbt = $client->__call("rechercheBtParCodeproduitEtCodepostalEtDate",array(0,$cp,0));
12
+ return $webservbt;
13
+ } catch (Exception $e) {
14
+ $webservbt = $this->getPointsRelaisByPudo('',$cp);
15
+ return $webservbt;
16
+ }
17
+ }
18
+
19
+ /* get point relais by address */
20
+ public function getPointRelaisByAddress() {
21
+
22
+ $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
23
+ $address = $quote->getShippingAddress();
24
+ $helperData = Mage::helper('chronorelais');
25
+
26
+ try {
27
+ $client = new SoapClient("https://www.chronopost.fr/recherchebt-ws-cxf/PointRelaisServiceWS?wsdl", array('trace' => 0, 'connection_timeout' => 10));
28
+
29
+ $params = array(
30
+ 'accountNumber' => $helperData->getConfigurationAccountNumber(),
31
+ 'password' => $helperData->getConfigurationAccountPass(),
32
+ 'address' => $this->getFilledValue($address->getStreet(1)),
33
+ 'zipCode' => $this->getFilledValue($address->getPostcode()),
34
+ 'city' => $this->getFilledValue($address->getCity()),
35
+ 'countryCode' => $this->getFilledValue($address->getCountryId()),
36
+ 'type' => 'P',
37
+ 'productCode' => '1',
38
+ 'service' => 'T',
39
+ 'weight' => 2000,
40
+ 'shippingDate' => date('d/m/Y'),
41
+ 'maxPointChronopost' => 5,
42
+ 'maxDistanceSearch' => 10,
43
+ 'holidayTolerant' => 1
44
+ );
45
+ $webservbt = $client->recherchePointChronopost($params);
46
+
47
+ /* format $webservbt pour avoir le meme format que lors de l'appel du WS par code postal */
48
+ if($webservbt->return->errorCode == 0)
49
+ {
50
+ /*
51
+ * Format entrée
52
+ *
53
+ * accesPersonneMobiliteReduite
54
+ actif
55
+ adresse1
56
+ adresse2
57
+ adresse3
58
+ codePays
59
+ codePostal
60
+ coordGeolocalisationLatitude
61
+ coordGeolocalisationLongitude
62
+ distanceEnMetre
63
+ identifiant
64
+ indiceDeLocalisation
65
+ listeHoraireOuverture
66
+ localite
67
+ nom
68
+ poidsMaxi
69
+ typeDePoint
70
+ urlGoogleMaps
71
+ *
72
+ * Format sortie
73
+ * adresse1
74
+ adresse2
75
+ adresse3
76
+ codePostal
77
+ dateArriveColis
78
+ horairesOuvertureDimanche ("10:00-12:30 14:30-19:00")
79
+ horairesOuvertureJeudi
80
+ horairesOuvertureLundi
81
+ horairesOuvertureMardi
82
+ horairesOuvertureMercredi
83
+ horairesOuvertureSamedi
84
+ horairesOuvertureVendredi
85
+ identifiantChronopostPointA2PAS
86
+ localite
87
+ nomEnseigne
88
+ *
89
+ *
90
+ *
91
+ * 2013-02-19T10:42:40.196Z
92
+ *
93
+ */
94
+ $listePr = $webservbt->return->listePointRelais;
95
+ $return = array();
96
+ foreach($listePr as $pr)
97
+ {
98
+ //$newPr = new object();
99
+ $newPr = (object)array();
100
+ $newPr->adresse1 = $pr->adresse1;
101
+ $newPr->adresse2 = $pr->adresse2;
102
+ $newPr->adresse3 = $pr->adresse3;
103
+ $newPr->codePostal = $pr->codePostal;
104
+ $newPr->identifiantChronopostPointA2PAS = $pr->identifiant;
105
+ $newPr->localite = $pr->localite;
106
+ $newPr->nomEnseigne = $pr->nom;
107
+ $time = new DateTime;
108
+ $newPr->dateArriveColis = $time->format(DateTime::ATOM);
109
+ $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
110
+ foreach($pr->listeHoraireOuverture as $horaire) {
111
+ switch($horaire->jour) {
112
+ case '1' : $newPr->horairesOuvertureLundi = $horaire->horairesAsString; break;
113
+ case '2' : $newPr->horairesOuvertureMardi = $horaire->horairesAsString; break;
114
+ case '3' : $newPr->horairesOuvertureMercredi = $horaire->horairesAsString; break;
115
+ case '4' : $newPr->horairesOuvertureJeudi = $horaire->horairesAsString; break;
116
+ case '5' : $newPr->horairesOuvertureVendredi = $horaire->horairesAsString; break;
117
+ case '6' : $newPr->horairesOuvertureSamedi = $horaire->horairesAsString; break;
118
+ case '7' : $newPr->horairesOuvertureDimanche = $horaire->horairesAsString; break;
119
+ }
120
+ }
121
+ if(empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
122
+ if(empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
123
+ if(empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
124
+ if(empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
125
+ if(empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
126
+ if(empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
127
+ if(empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
128
+
129
+ $return[] = $newPr;
130
+ }
131
+ return $return;
132
+ }
133
+ } catch (Exception $e) {
134
+ return $this->getPointsRelaisByPudo($address);
135
+ }
136
+ }
137
+
138
+ public function getDetailRelaisPoint($btcode) {
139
+ try {
140
+ $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl");
141
+ $webservbt = $client->__call("rechercheBtParIdChronopostA2Pas",array($btcode));
142
+ return $webservbt[0];
143
+ } catch (Exception $e) {
144
+ return $this->getDetailRelaisPointByPudo($btcode);
145
+ }
146
+ }
147
+
148
+
149
+ /*
150
+ *
151
+ * WS de secours
152
+ */
153
+
154
+ public function getDetailRelaisPointByPudo($btcode) {
155
+ $params = array(
156
+ 'carrier' => 'CHR',
157
+ 'key' => '75f6fe195dc88ceecbc0f8a2f70a8f3a',
158
+ 'pudo_id' => $btcode,
159
+ );
160
+
161
+ try {
162
+ $client = new SoapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?wsdl", array('trace' => 0, 'connection_timeout' => 10));
163
+ $webservbt = $client->GetPudoDetails($params);
164
+ $webservbt = json_decode(json_encode((object) simplexml_load_string($webservbt->GetPudoDetailsResult->any)), 1);
165
+ if(!isset($webservbt['ERROR'])) {
166
+ $return = array();
167
+ $pr = $webservbt['PUDO_ITEMS']['PUDO_ITEM'];
168
+ if($pr) {
169
+ if($pr['@attributes']['active'] == 'true')
170
+ {
171
+ $newPr = (object)array();
172
+ $newPr->adresse1 = $pr['ADDRESS1'];
173
+ $newPr->adresse2 = is_array($pr['ADDRESS2']) ? implode(' ', $pr['ADDRESS2']) : $pr['ADDRESS2'];
174
+ $newPr->adresse3 = is_array($pr['ADDRESS3']) ? implode(' ', $pr['ADDRESS3']) : $pr['ADDRESS3'];
175
+ $newPr->codePostal = $pr['ZIPCODE'];
176
+ $newPr->identifiantChronopostPointA2PAS = $pr['PUDO_ID'];
177
+ $newPr->localite = $pr['CITY'];
178
+ $newPr->nomEnseigne = $pr['NAME'];
179
+ $time = new DateTime;
180
+ $newPr->dateArriveColis = $time->format(DateTime::ATOM);
181
+ $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
182
+
183
+ if(isset($pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'])) {
184
+ $listeHoraires = $pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'];
185
+ foreach($listeHoraires as $horaire) {
186
+ switch($horaire['DAY_ID']) {
187
+ case '1' :
188
+ if(!empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi .= ' ';
189
+ $newPr->horairesOuvertureLundi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
190
+ break;
191
+ case '2' :
192
+ if(!empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi .= ' ';
193
+ $newPr->horairesOuvertureMardi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
194
+ break;
195
+ case '3' :
196
+ if(!empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi .= ' ';
197
+ $newPr->horairesOuvertureMercredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
198
+ break;
199
+ case '4' :
200
+ if(!empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi .= ' ';
201
+ $newPr->horairesOuvertureJeudi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
202
+ break;
203
+ case '5' :
204
+ if(!empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi .= ' ';
205
+ $newPr->horairesOuvertureVendredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
206
+ break;
207
+ case '6' :
208
+ if(!empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi .= ' ';
209
+ $newPr->horairesOuvertureSamedi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
210
+ break;
211
+ case '7' :
212
+ if(!empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche .= ' ';
213
+ $newPr->horairesOuvertureDimanche .= $horaire['START_TM'].'-'.$horaire['END_TM'];
214
+ break;
215
+ }
216
+ }
217
+ }
218
+ if(empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
219
+ if(empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
220
+ if(empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
221
+ if(empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
222
+ if(empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
223
+ if(empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
224
+ if(empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
225
+
226
+ return $newPr;
227
+ }
228
+ }
229
+ }
230
+ }
231
+ catch (Exception $e) {
232
+ return false;
233
+ }
234
+ return false;
235
+ }
236
+
237
+ public function getPointsRelaisByPudo($address = '', $cp = '') {
238
+
239
+ $params = array(
240
+ 'carrier' => 'CHR',
241
+ 'key' => '75f6fe195dc88ceecbc0f8a2f70a8f3a',
242
+ 'address' => $address ? $this->getFilledValue($address->getStreet(1)) : '',
243
+ 'zipCode' => $address ? $this->getFilledValue($address->getPostcode()) : $cp,
244
+ 'city' => $address ? $this->getFilledValue($address->getCity()) : 'Lille',
245
+ 'countrycode' => $address ? $this->getFilledValue($address->getCountryId()) : '',
246
+ 'requestID' => '1',
247
+ 'date_from' => date('d/m/Y'),
248
+ 'max_pudo_number' => 5,
249
+ 'max_distance_search' => 10,
250
+ 'weight' => 1,
251
+ 'category' => '',
252
+ 'holiday_tolerant' => 1,
253
+ );
254
+ try {
255
+ $client = new SoapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?wsdl", array('trace' => 0, 'connection_timeout' => 10));
256
+ $webservbt = $client->GetPudoList($params);
257
+ $webservbt = json_decode(json_encode((object) simplexml_load_string($webservbt->GetPudoListResult->any)), 1);
258
+ if(!isset($webservbt['ERROR'])) {
259
+ $return = array();
260
+
261
+ $listePr = $webservbt['PUDO_ITEMS']['PUDO_ITEM'];
262
+ if($listePr) {
263
+ foreach($listePr as $pr)
264
+ {
265
+ if($pr['@attributes']['active'] == 'true')
266
+ {
267
+ $newPr = (object)array();
268
+ $newPr->adresse1 = $pr['ADDRESS1'];
269
+ $newPr->adresse2 = is_array($pr['ADDRESS2']) ? implode(' ', $pr['ADDRESS2']) : $pr['ADDRESS2'];
270
+ $newPr->adresse3 = is_array($pr['ADDRESS3']) ? implode(' ', $pr['ADDRESS3']) : $pr['ADDRESS3'];
271
+ $newPr->codePostal = $pr['ZIPCODE'];
272
+ $newPr->identifiantChronopostPointA2PAS = $pr['PUDO_ID'];
273
+ $newPr->localite = $pr['CITY'];
274
+ $newPr->nomEnseigne = $pr['NAME'];
275
+ $time = new DateTime;
276
+ $newPr->dateArriveColis = $time->format(DateTime::ATOM);
277
+ $newPr->horairesOuvertureLundi = $newPr->horairesOuvertureMardi = $newPr->horairesOuvertureMercredi = $newPr->horairesOuvertureJeudi = $newPr->horairesOuvertureVendredi = $newPr->horairesOuvertureSamedi = $newPr->horairesOuvertureDimanche = '';
278
+
279
+ if(isset($pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'])) {
280
+ $listeHoraires = $pr['OPENING_HOURS_ITEMS']['OPENING_HOURS_ITEM'];
281
+ foreach($listeHoraires as $horaire) {
282
+ switch($horaire['DAY_ID']) {
283
+ case '1' :
284
+ if(!empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi .= ' ';
285
+ $newPr->horairesOuvertureLundi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
286
+ break;
287
+ case '2' :
288
+ if(!empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi .= ' ';
289
+ $newPr->horairesOuvertureMardi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
290
+ break;
291
+ case '3' :
292
+ if(!empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi .= ' ';
293
+ $newPr->horairesOuvertureMercredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
294
+ break;
295
+ case '4' :
296
+ if(!empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi .= ' ';
297
+ $newPr->horairesOuvertureJeudi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
298
+ break;
299
+ case '5' :
300
+ if(!empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi .= ' ';
301
+ $newPr->horairesOuvertureVendredi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
302
+ break;
303
+ case '6' :
304
+ if(!empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi .= ' ';
305
+ $newPr->horairesOuvertureSamedi .= $horaire['START_TM'].'-'.$horaire['END_TM'];
306
+ break;
307
+ case '7' :
308
+ if(!empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche .= ' ';
309
+ $newPr->horairesOuvertureDimanche .= $horaire['START_TM'].'-'.$horaire['END_TM'];
310
+ break;
311
+ }
312
+ }
313
+ }
314
+ if(empty($newPr->horairesOuvertureLundi)) $newPr->horairesOuvertureLundi = "00:00-00:00 00:00-00:00";
315
+ if(empty($newPr->horairesOuvertureMardi)) $newPr->horairesOuvertureMardi = "00:00-00:00 00:00-00:00";
316
+ if(empty($newPr->horairesOuvertureMercredi)) $newPr->horairesOuvertureMercredi = "00:00-00:00 00:00-00:00";
317
+ if(empty($newPr->horairesOuvertureJeudi)) $newPr->horairesOuvertureJeudi = "00:00-00:00 00:00-00:00";
318
+ if(empty($newPr->horairesOuvertureVendredi)) $newPr->horairesOuvertureVendredi = "00:00-00:00 00:00-00:00";
319
+ if(empty($newPr->horairesOuvertureSamedi)) $newPr->horairesOuvertureSamedi = "00:00-00:00 00:00-00:00";
320
+ if(empty($newPr->horairesOuvertureDimanche)) $newPr->horairesOuvertureDimanche = "00:00-00:00 00:00-00:00";
321
+
322
+ $return[] = $newPr;
323
+ }
324
+ }
325
+ return $return;
326
+ }
327
+ }
328
+ }
329
+ catch (Exception $e) {
330
+ return false;
331
+ }
332
+ return false;
333
+ }
334
+
335
+
336
+ public function getQuickcost($quickCost,$quickcost_url = '') {
337
+ if (!$quickcost_url) {
338
+ //$quickcost_url = "http://wsshipping.chronopost.fr/wsQuickcost/services/ServiceQuickCost?wsdl";
339
+ $quickcost_url = "https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl";
340
+ }
341
+ try {
342
+ $client = new SoapClient($quickcost_url);
343
+ $webservbt = $client->quickCost($quickCost);
344
+
345
+ return $webservbt->return;
346
+ } catch (Exception $e) {
347
+ return false;
348
+ }
349
+ }
350
+
351
+ public function checkLogin($quickCost,$quickcost_url = '') {
352
+ if (!$quickcost_url) {
353
+ $quickcost_url = "https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl";
354
+ }
355
+ try {
356
+ $client = new SoapClient($quickcost_url);
357
+ $webservbt = $client->calculateProducts($quickCost);
358
+ return $webservbt;
359
+ } catch (Exception $e) {
360
+ return false;
361
+ }
362
+ }
363
+
364
+ /*
365
+ * Return true si la méthode de livraison fait partie du contrat
366
+ */
367
+ public function getMethodIsAllowed($code,$quote) {
368
+ $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
369
+ $address = $quote->getShippingAddress();
370
+ $helperData = Mage::helper('chronorelais');
371
+ $code = $helperData->getChronoProductCode('',$code);
372
+ try {
373
+ if($this->methodsAllowed === false) {
374
+ $this->methodsAllowed = array();
375
+ $client = new SoapClient("https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl", array('trace' => 0, 'connection_timeout' => 10));
376
+ $params = array(
377
+ 'accountNumber' => $helperData->getConfigurationAccountNumber(),
378
+ 'password' => $helperData->getConfigurationAccountPass(),
379
+ 'depCountryCode' => $helperData->getConfigurationShipperInfo('country'),
380
+ 'depZipCode' => $helperData->getConfigurationShipperInfo('zipcode'),
381
+ 'arrCountryCode' => $this->getFilledValue($address->getCountryId()),
382
+ 'arrZipCode' => $this->getFilledValue($address->getPostcode()),
383
+ 'arrCity' => $this->getFilledValue($address->getCity()),
384
+ 'type' => 'M',
385
+ 'weight' => 1
386
+ );
387
+ //print_r($params);
388
+ $webservbt = $client->calculateProducts($params);
389
+ //print_r($webservbt);
390
+ if($webservbt->return->errorCode == 0)
391
+ {
392
+ if($webservbt->return->productList) {
393
+ foreach($webservbt->return->productList as $product) {
394
+ //echo $product->productCode.' ---- ';
395
+ $this->methodsAllowed[] = $product->productCode;
396
+ }
397
+ }
398
+ }
399
+ }
400
+ //print_r($this->methodsAllowed);
401
+ if(!empty($this->methodsAllowed) && in_array($code, $this->methodsAllowed)) {
402
+ return true;
403
+ }
404
+ return false;
405
+ }catch(Exception $e) {
406
+ return false;
407
+ }
408
+ }
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+ public function getFilledValue($value) {
419
+ if ($value) {
420
+ return $this->removeaccents(trim($value));
421
+ } else {
422
+ return '';
423
+ }
424
+ }
425
+
426
+ public function removeaccents($string) {
427
+ $stringToReturn = str_replace(
428
+ array('à', 'á', 'â', 'ã', 'ä', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', '/', '\xa8'), array('a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', ' ', 'e'), $string);
429
+ // Remove all remaining other unknown characters
430
+ $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
431
+ $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
432
+ $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
433
+ $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
434
+ return $stringToReturn;
435
+ }
436
+ }
app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelaisShipping.php CHANGED
@@ -20,7 +20,7 @@
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
- // Pour g�rer les cas o� il y a eu compilation
24
  if (file_exists(dirname(__FILE__).'/Chronopost_Chronorelais_includes_ChronorelaisShippingHelper.php')) include_once 'Chronopost_Chronorelais_includes_ChronorelaisShippingHelper.php';
25
  else include_once Mage::getBaseDir('code').'/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php';
26
 
@@ -130,6 +130,7 @@ abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShippin
130
  /*foreach ($request->_data as $key => $data) {
131
  echo $key.' => '.$data.'<br/>';
132
  }*/
 
133
 
134
  $process = array(
135
  'request' => $request,
@@ -142,7 +143,7 @@ abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShippin
142
  'cart.price_excluding_tax' => $request->_data['package_value_with_discount'],
143
  'cart.price_including_tax' => null,
144
  'cart.weight' => $request->_data['package_weight'],
145
- 'cart.weight.unit' => null,
146
  'cart.quantity' => $request->_data['package_qty'],
147
  'destination.country.code' => $request->_data['dest_country_id'],
148
  'destination.country.name' => null,
@@ -240,6 +241,7 @@ abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShippin
240
  $mage_config = Mage::getConfig();
241
  $timestamp = time();
242
  $customer_group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();
 
243
  // Pour les commandes depuis Adminhtml
244
  if ($customer_group_id==0) {
245
  $customer_group_id2 = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getCustomerGroupId();
@@ -252,7 +254,7 @@ abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShippin
252
  'customer.group.code' => $customer_group_code,
253
  'destination.country.name' => $this->__getCountryName($process['data']['destination.country.code']),
254
  'origin.country.name' => $this->__getCountryName($process['data']['origin.country.code']),
255
- 'cart.weight.unit' => Mage::getStoreConfig('chronorelais/shipping/weight_unit'),
256
  'store.code' => $store->getCode(),
257
  'store.name' => $store->getConfig('general/store_information/name'),
258
  'store.address' => $store->getConfig('general/store_information/address'),
@@ -267,9 +269,20 @@ abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShippin
267
  'module.version' => (string)$mage_config->getNode('modules/Chronopost_Chronorelais/version'),
268
  ));
269
 
 
 
 
270
  foreach ($process['cart.items'] as $id => $item) {
271
  if ($item->getProduct()->getTypeId()!='configurable') {
272
  $parent_item_id = $item->getParentItemId();
 
 
 
 
 
 
 
 
273
  $process['products'][] = new OCS_Magento_Product($item, isset($process['cart.items'][$parent_item_id]) ? $process['cart.items'][$parent_item_id] : null);
274
  }
275
  }
@@ -314,12 +327,33 @@ abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShippin
314
  $applicationFee = $this->__getConfigData('application_fee');
315
  $handlingFee = $this->__getConfigData('handling_fee');
316
 
317
- /* Check weight limit with cart weight*/
318
- $weight_limit = $this->__getConfigData('weight_limit');
319
- if($process['data']['cart.weight']>$weight_limit) {
320
  $value_found = false;
321
  $process_continue = false;
322
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
 
324
  if($process_continue) {
325
  foreach ($process['config'] as $row) {
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
+ // Pour g�rer les cas o� il y a eu compilation
24
  if (file_exists(dirname(__FILE__).'/Chronopost_Chronorelais_includes_ChronorelaisShippingHelper.php')) include_once 'Chronopost_Chronorelais_includes_ChronorelaisShippingHelper.php';
25
  else include_once Mage::getBaseDir('code').'/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php';
26
 
130
  /*foreach ($request->_data as $key => $data) {
131
  echo $key.' => '.$data.'<br/>';
132
  }*/
133
+ $helper = Mage::helper('chronorelais');
134
 
135
  $process = array(
136
  'request' => $request,
143
  'cart.price_excluding_tax' => $request->_data['package_value_with_discount'],
144
  'cart.price_including_tax' => null,
145
  'cart.weight' => $request->_data['package_weight'],
146
+ 'cart.weight.unit' => $helper->getConfigWeightUnit(),
147
  'cart.quantity' => $request->_data['package_qty'],
148
  'destination.country.code' => $request->_data['dest_country_id'],
149
  'destination.country.name' => null,
241
  $mage_config = Mage::getConfig();
242
  $timestamp = time();
243
  $customer_group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();
244
+ $helper = Mage::helper('chronorelais');
245
  // Pour les commandes depuis Adminhtml
246
  if ($customer_group_id==0) {
247
  $customer_group_id2 = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getCustomerGroupId();
254
  'customer.group.code' => $customer_group_code,
255
  'destination.country.name' => $this->__getCountryName($process['data']['destination.country.code']),
256
  'origin.country.name' => $this->__getCountryName($process['data']['origin.country.code']),
257
+ 'cart.weight.unit' => $helper->getConfigWeightUnit(),/*Mage::getStoreConfig('chronorelais/shipping/weight_unit')*/
258
  'store.code' => $store->getCode(),
259
  'store.name' => $store->getConfig('general/store_information/name'),
260
  'store.address' => $store->getConfig('general/store_information/address'),
269
  'module.version' => (string)$mage_config->getNode('modules/Chronopost_Chronorelais/version'),
270
  ));
271
 
272
+ $weight_limit = $this->__getConfigData('weight_limit'); /* weight_limit in kg */
273
+ $productWeightOverLimit = false;
274
+
275
  foreach ($process['cart.items'] as $id => $item) {
276
  if ($item->getProduct()->getTypeId()!='configurable') {
277
  $parent_item_id = $item->getParentItemId();
278
+ $itemWeight = $item->getWeight();
279
+ if($helper->getConfigWeightUnit() == 'g')
280
+ {
281
+ $itemWeight = $itemWeight / 1000; // conversion g => kg
282
+ }
283
+ if($itemWeight > $weight_limit) {
284
+ $productWeightOverLimit = true;
285
+ }
286
  $process['products'][] = new OCS_Magento_Product($item, isset($process['cart.items'][$parent_item_id]) ? $process['cart.items'][$parent_item_id] : null);
287
  }
288
  }
327
  $applicationFee = $this->__getConfigData('application_fee');
328
  $handlingFee = $this->__getConfigData('handling_fee');
329
 
330
+ /* On autorise chronopost > 30 Kg si tous les produits sont <= 30 Kg */
331
+ if($productWeightOverLimit) {
 
332
  $value_found = false;
333
  $process_continue = false;
334
  }
335
+
336
+ $helperWS = Mage::helper('chronorelais/webservice');
337
+ /* Si Chronorelais => test Si WS fonctionne */
338
+ if($this->_code == 'chronorelais') {
339
+ $shippingAddress = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getShippingAddress();
340
+ $webservice = $helperWS->getPointsRelaisByCp($shippingAddress->getPostcode());
341
+ if($webservice === false) {
342
+ $value_found = false;
343
+ $process_continue = false;
344
+ }
345
+ }
346
+
347
+ /* Si C10, CClassic ou Express => On vérifie si la méthode fait partie du contrat */
348
+ $methodsToCheck = array('chronoexpress','chronopostc10','chronopostcclassic');
349
+ if(in_array($this->_code, $methodsToCheck))
350
+ {
351
+ $isAllowed = $helperWS->getMethodIsAllowed($this->_code);
352
+ if($isAllowed === false) {
353
+ $value_found = false;
354
+ $process_continue = false;
355
+ }
356
+ }
357
 
358
  if($process_continue) {
359
  foreach ($process['config'] as $row) {
app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostC10.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Carrier_ChronopostC10 extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
+ {
4
+ protected $_code = 'chronopostc10';
5
+
6
+ }
app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostC18.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Carrier_ChronopostC18 extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
+ {
4
+ protected $_code = 'chronopostc18';
5
+
6
+ }
app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronopostCClassic.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Carrier_ChronopostCClassic extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
+ {
4
+ protected $_code = 'chronopostcclassic';
5
+
6
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/WeightUnit.php ADDED
@@ -0,0 +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
+ }
app/code/community/Chronopost/Chronorelais/controllers/AjaxController.php CHANGED
@@ -19,391 +19,417 @@
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_AjaxController extends Chronopost_Chronorelais_Controller_Abstract
24
- {
25
- private function getPropertyHelper($row_id, $property_key, $property) {
26
- $cleaned_property = $this->cleanKey($property_key);
27
- $prefix = "r-".$row_id."-p-".$cleaned_property;
28
- $value = isset($property['original_value']) ? $property['original_value'] : (isset($property['value']) ? $property['value'] : '');
29
-
30
- switch ($property_key) {
31
- case 'enabled':
32
- $enabled = $value!==false;
33
- return "<p><select id=\"".$prefix."\" class=\"field\">"
34
- ."<option value=\"0\"".($enabled ? '' : ' selected="selected"').">".$this->__('Disabled')."</option>"
35
- ."<option value=\"1\"".($enabled ? ' selected="selected"' : '').">".$this->__('Enabled')."</option>"
36
- ."</select><p>";
37
- break;
38
- case 'label':
39
- case 'description':
40
- return "<textarea id=\"".$prefix."\" class=\"field\">".$value."</textarea>"
41
- ."<fieldset class=\"buttons-set\"><legend>".$this->__('Insert')."</legend>"
42
- ."<p>"
43
- .$this->button('Destination country',"ocseditor.insertAtCaret(this,'{destination.country.name}');")
44
- .$this->button('Cart weight',"ocseditor.insertAtCaret(this,'{cart.weight}');")
45
- .$this->button('Cart quantity',"ocseditor.insertAtCaret(this,'{cart.quantity}');")
46
- .$this->button('Price including tax',"ocseditor.insertAtCaret(this,'{cart.price_including_tax}');")
47
- .$this->button('Price excluding tax',"ocseditor.insertAtCaret(this,'{cart.price_excluding_tax}');")
48
- ."</p>"
49
- ."</fieldset>";
50
- break;
51
- case 'fees':
52
- return "<textarea id=\"".$prefix."\" class=\"field\">".$value."</textarea>"
53
- ."<fieldset class=\"buttons-set\"><legend>".$this->__('Insert')."</legend>"
54
- ."<p><span class=\"buttons-set-label\">".$this->__('Cart')."</span>"
55
- .$this->button('Weight',"ocseditor.insertAtCaret(this,'{cart.weight}');")
56
- .$this->button('Products quantity',"ocseditor.insertAtCaret(this,'{cart.quantity}');")
57
- .$this->button('Price including tax',"ocseditor.insertAtCaret(this,'{cart.price_including_tax}');")
58
- .$this->button('Price excluding tax',"ocseditor.insertAtCaret(this,'{cart.price_excluding_tax}');")
59
- ."</p>"
60
- ."<p><span class=\"buttons-set-label\">".$this->__('Selection')."</span>"
61
- .$this->button('Weight',"ocseditor.insertAtCaret(this,'{selection.weight}');")
62
- .$this->button('Products quantity',"ocseditor.insertAtCaret(this,'{selection.quantity}');")
63
- ."</p>"
64
- ."<p><span class=\"buttons-set-label\">".$this->__('Product')."</span>"
65
- .$this->button('Weight',"ocseditor.insertAtCaret(this,'{product.weight}');")
66
- .$this->button('Quantity',"ocseditor.insertAtCaret(this,'{product.quantity}');")
67
- ."</p>"
68
- ."</fieldset>";
69
- break;
70
- case 'conditions':
71
- return "<textarea id=\"".$prefix."\" class=\"field\">".$value."</textarea>"
72
- ."<fieldset class=\"buttons-set\"><legend>".$this->__('Insert')."</legend>"
73
- ."<p><span class=\"buttons-set-label\">".$this->__('Cart')."</span>"
74
- .$this->button('Weight',"ocseditor.insertAtCaret(this,'{cart.weight}');")
75
- .$this->button('Products quantity',"ocseditor.insertAtCaret(this,'{cart.quantity}');")
76
- .$this->button('Price including tax',"ocseditor.insertAtCaret(this,'{cart.price_including_tax}');")
77
- .$this->button('Price excluding tax',"ocseditor.insertAtCaret(this,'{cart.price_excluding_tax}');")
78
- ."</p>"
79
- ."</fieldset>";
80
- break;
81
- case 'customer_groups':
82
- return "<textarea id=\"".$prefix."\" class=\"field\">".$value."</textarea>"
83
- ."<fieldset class=\"buttons-set\"><legend>".$this->__('Insert')."</legend>"
84
- ."<p>"
85
- .$this->button('Not logged in',"ocseditor.insertAtCaret(this,'NOT LOGGED IN');")
86
- ."</p>"
87
- ."</fieldset>";
88
- break;
89
- case 'tracking_url':
90
- return "<textarea id=\"".$prefix."\" class=\"field\">".$value."</textarea>"
91
- ."<fieldset class=\"buttons-set\"><legend>".$this->__('Insert')."</legend>"
92
- ."<p>"
93
- .$this->button('Tracking number',"ocseditor.insertAtCaret(this,'{tracking_number}');")
94
- ."</p>"
95
- ."</fieldset>";
96
- break;
97
- case 'destination':
98
- case 'origin':
99
- $parsed_value = $this->parseAddressFilter($value);
100
- $excluding = $parsed_value['excluding'];
101
- return "<div class=\"address-filters-property\"><p>"
102
- ."<input type=\"radio\" class=\"excluding\" id=\"".$prefix."-exluding-0\" name=\"".$prefix."-exluding\""
103
- ." value=\"0\"".(!$excluding ? " checked=\"checked\"" : '')." onclick=\"ocseditor.updateCountries(this);\"/>"
104
- ."<label for=\"".$prefix."-exluding-0\"> ".$this->__('Limit to')."</label> &nbsp; "
105
- ."<input type=\"radio\" class=\"excluding\" id=\"".$prefix."-exluding-1\" name=\"".$prefix."-exluding\""
106
- ." value=\"1\"".($excluding ? " checked=\"checked\"" : '')." onclick=\"ocseditor.updateCountries(this);\"/>"
107
- ."<label for=\"".$prefix."-exluding-1\"> ".$this->__('Exclude')."</label></p>"
108
- ."<textarea id=\"".$prefix."\" class=\"field\">".$value."</textarea>"
109
- ."<fieldset class=\"buttons-set\"><legend>".$this->__('Display')."</legend>"
110
- ."<p>"
111
- .$this->button('Display original input',"ocseditor.displayCountry('original-value',this,false);")
112
- .$this->button('Display corrected names',"ocseditor.displayCountry('full-value',this,false);")
113
- .$this->button('Display codes',"ocseditor.displayCountry('compact-value',this,true);")
114
- ."</p>"
115
- ."</fieldset>"
116
- ."<fieldset class=\"buttons-set\"><legend>".$this->__('Preview')."</legend>"
117
- ."<div class=\"address-filter-list\">".$this->getAddressFilters($parsed_value)."</div>"
118
- ."</fieldset>"
119
- ."</div>"
120
- ;
121
- break;
122
- case '*comment' :
123
- $lines = explode("\n",trim($value));
124
- for ($i=0; $i<count($lines); $i++) {
125
- $lines[$i] = preg_replace('/^# ?/','',$lines[$i]);
126
- }
127
- $value = implode("\n",$lines);
128
- return "<textarea id=\"".$prefix."\" class=\"field\">".$value."</textarea>";
129
- default :
130
- return "<textarea id=\"".$prefix."\" class=\"field\">".$value."</textarea>";
131
- }
132
- }
133
 
134
- private function getAddressFilters($data) {
135
- $address_filters = array();
136
- foreach ($data['countries'] as $country) {
137
- $address_filters[] = new AddressFilter($country);
138
- }
139
- return implode('',$address_filters);
140
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
- private function parseAddressFilter($address_filter) {
143
- $output = array(
144
- 'excluding' => false,
145
- 'countries' => array(),
146
- 'original' => $address_filter,
147
- );
 
148
 
149
- $address_filter = str_replace(array("\r\n","\r","\n"),array(',',',',','),$address_filter);
 
 
 
 
 
150
 
151
- if (preg_match('# *\* *- *\((.*)\) *#s',$address_filter,$result)) {
152
- $address_filter = $result[1];
153
- $output['excluding'] = true;
154
- }
155
 
156
- $tmp_address_filter_array = explode(',',trim($address_filter));
157
-
158
- $concat = false;
159
- $concatened = '';
160
- $address_filter_array = array();
161
- $i = 0;
162
-
163
- foreach ($tmp_address_filter_array as $address_filter) {
164
- if ($concat) $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 $address_filter_array[] = $address_filter;
170
- }
171
- if (preg_match('#\)#',$address_filter)) {
172
- $address_filter_array[] = $concatened;
173
- $concatened = '';
174
- $concat = false;
175
- }
176
- $i++;
177
- }
178
-
179
- foreach ($address_filter_array as $address_filter) {
180
- $address_filter = trim($address_filter);
181
- if (trim($address_filter)!='') {
182
- if (preg_match('# *([^,(]+) *(-)? *(?:\( *(-)? *(.*)\))? *#s',$address_filter,$result)) {
183
- $country_code = $result[1];
184
 
185
- $region_codes = explode(',',$result[4]);
186
- $in_array = false;
187
- for ($i=count($region_codes); --$i>=0;) {
188
- $code = trim($region_codes[$i]);
189
- $region_codes[$i] = $code;
190
- }
191
- /*$in_array = in_array($address['region_code'],$region_codes,true) || in_array($address['postcode'],$region_codes,true);*/
192
- $excluding_region = $result[2]=='-' || $result[3]=='-';
193
- $output['countries'][] = array(
194
- 'excluding' => $excluding_region,
195
- 'country_code' => $country_code,
196
- 'region_codes' => implode(',',$region_codes),
197
- 'original' => $address_filter,
198
- );
199
- } else {
200
- $output['countries'][] = array(
201
- 'excluding' => null,
202
- 'country_code' => $address_filter,
203
- 'region_codes' => null,
204
- 'original' => $address_filter,
205
- );
206
- }
207
- }
208
- }
209
- return $output;
210
- }
211
 
212
- private function getRowUI($row, $selected) {
213
- $row['_ID_']['value'] = isset($row['_ID_']['value']) ? $row['_ID_']['value'] : uniqid('c');
214
- $row_id = $row['_ID_']['value'];
 
215
 
216
- if (isset($row['lines'])) {
217
- $output = "<div id=\"r-".$row_id."-container\" class=\"row-container has-error ignored-lines".($selected ? ' selected' : '')."\">"
218
- ."<div class=\"row-header\" onclick=\"ocseditor.selectRow('".$row_id."');\">"
219
- ."<div class=\"row-actions\">"
220
- .$this->button('Apply changes',"ocseditor.applyChanges();")
221
- .$this->button('Delete',"ocseditor.removeRow(this);",'delete')
222
- ."</div>"
223
- ."<div class=\"row-title\">".$this->__('Ignored lines')."</div></div>"
224
- ."<div class=\"properties-container\"><textarea class=\"field\">".$row['lines']."</textarea></div></div>";
225
- return $output;
226
- }
 
 
 
 
 
 
227
 
228
- if (!isset($row['label'])) {
229
- $row['label']['value'] = $this->__('New shipping method');
230
- }
 
 
231
 
232
- $properties = array(
233
- 'enabled' => 'Enabled',
234
- 'code' => 'Code',
235
- 'label' => 'Label',
236
- 'description' => 'Description',
237
- 'destination' => 'Destination',
238
- 'origin' => 'Origin',
239
- 'conditions' => 'Conditions',
240
- 'fees' => 'Fees',
241
- 'customer_groups' => 'Customer groups',
242
- 'tracking_url' => 'Tracking url',
243
- '*comment' => 'Comment',
244
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
245
 
246
- $label = $row['label']['value'];
247
- $output = "<div id=\"r-".$row_id."-container\" class=\"row-container".($selected ? ' selected' : '')."\">"
248
- ."<div class=\"row-header\" onclick=\"ocseditor.selectRow('".$row_id."');\">"
249
- ."<div class=\"row-actions\">".$this->button('Delete',"ocseditor.removeRow(this);",'delete')."</div><div class=\"row-title\">".$label."</div></div>"
250
- ."<div class=\"properties-container\">";
251
- $list = "<ul class=\"properties-list\">";
252
- $j = 0;
253
- foreach ($properties as $property_key => $label) {
254
- $cleaned_property = $this->cleanKey($property_key);
255
- $value = isset($row[$property_key]) ? trim($row[$property_key]['value']) : '';
256
- $list .= "<li id=\"r-".$row_id."-p-".$cleaned_property."-item\" class=\"property-item".($j==0 ? ' selected' : '')
257
- .(empty($value) ? ' empty' : '')
258
- ."\" onclick=\"ocseditor.selectProperty('".$row_id."','".$cleaned_property."');\">".$this->__($label)."</li>";
259
- $output .= "<div id=\"r-".$row_id."-p-".$cleaned_property."-container\" class=\"property-container"
260
- .($j==0 ? ' selected' : '')."\" property-name=\"".$property_key."\">"
261
- ."<div class=\"buttons-set\" style=\"text-align:right;\">".$this->button('Help',"ocseditor.help('property.".$property_key."');",'help')."</div>"
262
- .$this->getPropertyHelper($row_id,$property_key,$row[$property_key])."</div>";
263
- $j++;
264
- }
265
- foreach ($row as $property_key => $property) {
266
- if (!isset($properties[$property_key]) && substr($property_key,0,1)!='*') {
267
- $label = $property_key;
268
- $cleaned_property = $this->cleanKey($property_key);
269
- $value = isset($row[$property_key]) ? trim($row[$property_key]['value']) : '';
270
- $list .= "<li id=\"r-".$row_id."-p-".$cleaned_property."-item\" class=\"property-item".($j==0 ? ' selected' : '')
271
- .(empty($value) ? ' empty' : '').($cleaned_property=='_ID_' ? ' hide' : '')
272
- ."\" onclick=\"ocseditor.selectProperty('".$row_id."','".$cleaned_property."');\">".$this->__($label)."</li>";
273
- $output .= "<div id=\"r-".$row_id."-p-".$cleaned_property."-container\" class=\"property-container"
274
- .($j==0 ? ' selected' : '')."\" property-name=\"".$property_key."\">"
275
- ."<div class=\"buttons-set\" style=\"text-align:right;\">".$this->button('Help',"ocseditor.help('property.".$property_key."');",'help')."</div>"
276
- .$this->getPropertyHelper($row_id,$property_key,$property)."</div>";
277
- $j++;
278
- }
279
- }
280
- $output .= $list."</div></div>";
281
- return $output;
282
- }
283
 
284
- private function getConfigErrors($config) {
285
- $script = "ocseditor.resetErrors();";
286
- foreach ($config as $row_code => $row) {
287
- if (isset($row['*messages'])) {
288
- $error = '';
289
- foreach ($row['*messages'] as $message) {
290
- $error .= "<p>".$this->__($message)."</p>";
291
- }
292
- if ($error!='') $script .= "ocseditor.setError('".$row['_ID_']['value']."','','".$this->jsEscape($error)."');";
293
- }
294
- foreach ($row as $property_key => $property) {
295
- if (isset($property['messages'])) {
296
- $error = '';
297
- foreach ($property['messages'] as $message) {
298
- $error .= "<p>".$this->__($message)."</p>";
299
- }
300
- if ($error!='') {
301
- $script .= "ocseditor.setError('".$row['_ID_']['value']."','".$property_key."','"
302
- .$this->jsEscape($error
303
- .($property['value']!=$property['original_value'] ?
304
- "<p>"
305
- .$this->button('Correct',"ocseditor.correct('".$row['_ID_']['value']."','".$property_key."','".$this->jsEscape($property['value'])."');")
306
- ."</p>" : '')
307
- )."');";
308
- }
309
- }
310
- }
311
- }
312
- //$script .= "alert('".str_replace(array("\r\n","\n","\'","'"),array(" "," ","\\\'","\'"),$script)."');";
313
- return $script;
314
- }
315
 
316
- private function loadConfig($input) {
317
- include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
 
318
 
319
- $helper = new ChronorelaisShippingHelper($input);
320
- $helper->checkConfig();
321
- $config = $helper->getConfig();
322
- //print_r($config);
323
-
324
- $output = "<div class=\"buttons-set\">"
325
- .$this->button('Add a shipping method',"ocseditor.addRow();",'add')
326
- ."</div><div class=\"config-container\">";
327
- $i = 0;
328
- foreach ($config as &$row) {
329
- $output .= $this->getRowUI($row,$i==0);
330
- $i++;
331
- }
332
- $output .= "</div><script type=\"text/javascript\">".$this->getConfigErrors($config)."</script>";
333
- return $output;
334
- }
335
 
336
- public function indexAction() {
337
- header('Content-Type: text/html; charset=UTF-8');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
 
339
- include_once $this->getIncludingPath('countries.inc.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
 
341
- switch ($_POST['what']) {
342
- case 'open':
343
- $output = ""
344
- // Donate page
345
- //.$this->page('donate',"Support the development of Chronorelais Shipping extension",$this->__('{ocseditor.donate-page.content}'))
346
- // Help page
347
- .$this->page('help',"Chronorelais Shipping extension help",'')
348
- // Main page
349
- .$this->pageHeader("Chronorelais Shipping configuration editor",
350
- $this->button('Save',"ocseditor.save();",'save')
351
- .$this->button('Export',"ocseditor.saveToFile();",'')
352
- .$this->button('Load',"ocseditor.showConfigLoader();",'')
353
- .$this->button('Close',"ocseditor.close();",'cancel')
354
- )
355
- ."<div id=\"ocs-editor-config-loader\">"
356
- ."<textarea></textarea>"
357
- ."<div class=\"buttons-set\">"
358
- .$this->button('Load',"ocseditor.loadConfig();",'')
359
- .$this->button('Cancel',"ocseditor.hideConfigLoader();",'cancel')
360
- ."</div>"
361
- ."</div>"
362
- ."<div id=\"ocs-editor-config-container\">".$this->loadConfig($_POST['input'])."</div>"
363
- /*."<div class=\"donate-container\">"
364
- ."<table cellspacing=\"0\"><tr>"
365
- ."<td>".$this->__('You appreciate this extension and would like to help?')."</td>"
366
- ."<td class=\"form-buttons\">"
367
- .$this->button('Donate',"ocseditor.openPage('donate');",'donate')
368
- ."</td>"
369
- ."</tr></table>"
370
- ."</div>"*/
371
- ;
372
- echo $output;
373
- exit;
374
- case 'help':
375
- echo $this->__('{ocseditor.help.'.$_POST['input'].'}');
376
- exit;
377
- case 'add-row':
378
- echo $this->getRowUI(array(),true);
379
- exit;
380
- case 'load-config':
381
- echo $this->loadConfig($_POST['config']);
382
- exit;
383
- case 'check-config':
384
- include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
385
 
386
- $helper = new ChronorelaisShippingHelper(urldecode($_POST['config']));
387
- $helper->checkConfig();
388
- print_r($helper->getConfig(),$out);
389
- //$script = "alert('".$this->jsEscape(urldecode($_POST['config']))."');";
390
- $script = $this->getConfigErrors($helper->getConfig());
391
- //$script = "alert('".$this->jsEscape($this->getConfigErrors($helper->getConfig()))."');";
392
- break;
393
- case 'save-to-file':
394
- include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
395
 
396
- $helper = new ChronorelaisShippingHelper(urldecode($_POST['config']));
397
- $formatted_config = $helper->formatConfig(false);
398
- $this->forceDownload('chronorelais-shipping-config.txt',$formatted_config);
399
- exit;
400
- case 'get-address-filters':
401
- $result = $this->parseAddressFilter($_POST['input']);
402
- echo $this->getAddressFilters($result);
403
- exit;
404
- }
 
 
405
 
406
- echo "<script type=\"text/javascript\">".$script."</script>";
407
- exit;
408
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  }
19
  * @author Antoine Lemoine
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
+ class Chronopost_Chronorelais_AjaxController extends Chronopost_Chronorelais_Controller_Abstract {
23
 
24
+ private function getPropertyHelper($row_id, $property_key, $property) {
25
+ $cleaned_property = $this->cleanKey($property_key);
26
+ $prefix = "r-" . $row_id . "-p-" . $cleaned_property;
27
+ $value = isset($property['original_value']) ? $property['original_value'] : (isset($property['value']) ? $property['value'] : '');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
+ switch ($property_key) {
30
+ case 'enabled':
31
+ $enabled = $value !== false;
32
+ return "<p><select id=\"" . $prefix . "\" class=\"field\">"
33
+ . "<option value=\"0\"" . ($enabled ? '' : ' selected="selected"') . ">" . $this->__('Disabled') . "</option>"
34
+ . "<option value=\"1\"" . ($enabled ? ' selected="selected"' : '') . ">" . $this->__('Enabled') . "</option>"
35
+ . "</select><p>";
36
+ break;
37
+ case 'label':
38
+ case 'description':
39
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
40
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
41
+ . "<p>"
42
+ . $this->button('Destination country', "ocseditor.insertAtCaret(this,'{destination.country.name}');")
43
+ . $this->button('Cart weight', "ocseditor.insertAtCaret(this,'{cart.weight}');")
44
+ . $this->button('Cart quantity', "ocseditor.insertAtCaret(this,'{cart.quantity}');")
45
+ . $this->button('Price including tax', "ocseditor.insertAtCaret(this,'{cart.price_including_tax}');")
46
+ . $this->button('Price excluding tax', "ocseditor.insertAtCaret(this,'{cart.price_excluding_tax}');")
47
+ . "</p>"
48
+ . "</fieldset>";
49
+ break;
50
+ case 'fees':
51
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
52
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
53
+ . "<p><span class=\"buttons-set-label\">" . $this->__('Cart') . "</span>"
54
+ . $this->button('Weight', "ocseditor.insertAtCaret(this,'{cart.weight}');")
55
+ . $this->button('Products quantity', "ocseditor.insertAtCaret(this,'{cart.quantity}');")
56
+ . $this->button('Price including tax', "ocseditor.insertAtCaret(this,'{cart.price_including_tax}');")
57
+ . $this->button('Price excluding tax', "ocseditor.insertAtCaret(this,'{cart.price_excluding_tax}');")
58
+ . "</p>"
59
+ . "<p><span class=\"buttons-set-label\">" . $this->__('Selection') . "</span>"
60
+ . $this->button('Weight', "ocseditor.insertAtCaret(this,'{selection.weight}');")
61
+ . $this->button('Products quantity', "ocseditor.insertAtCaret(this,'{selection.quantity}');")
62
+ . "</p>"
63
+ . "<p><span class=\"buttons-set-label\">" . $this->__('Product') . "</span>"
64
+ . $this->button('Weight', "ocseditor.insertAtCaret(this,'{product.weight}');")
65
+ . $this->button('Quantity', "ocseditor.insertAtCaret(this,'{product.quantity}');")
66
+ . "</p>"
67
+ . "</fieldset>";
68
+ break;
69
+ case 'conditions':
70
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
71
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
72
+ . "<p><span class=\"buttons-set-label\">" . $this->__('Cart') . "</span>"
73
+ . $this->button('Weight', "ocseditor.insertAtCaret(this,'{cart.weight}');")
74
+ . $this->button('Products quantity', "ocseditor.insertAtCaret(this,'{cart.quantity}');")
75
+ . $this->button('Price including tax', "ocseditor.insertAtCaret(this,'{cart.price_including_tax}');")
76
+ . $this->button('Price excluding tax', "ocseditor.insertAtCaret(this,'{cart.price_excluding_tax}');")
77
+ . "</p>"
78
+ . "</fieldset>";
79
+ break;
80
+ case 'customer_groups':
81
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
82
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
83
+ . "<p>"
84
+ . $this->button('Not logged in', "ocseditor.insertAtCaret(this,'NOT LOGGED IN');")
85
+ . "</p>"
86
+ . "</fieldset>";
87
+ break;
88
+ case 'tracking_url':
89
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
90
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Insert') . "</legend>"
91
+ . "<p>"
92
+ . $this->button('Tracking number', "ocseditor.insertAtCaret(this,'{tracking_number}');")
93
+ . "</p>"
94
+ . "</fieldset>";
95
+ break;
96
+ case 'destination':
97
+ case 'origin':
98
+ $parsed_value = $this->parseAddressFilter($value);
99
+ $excluding = $parsed_value['excluding'];
100
+ return "<div class=\"address-filters-property\"><p>"
101
+ . "<input type=\"radio\" class=\"excluding\" id=\"" . $prefix . "-exluding-0\" name=\"" . $prefix . "-exluding\""
102
+ . " value=\"0\"" . (!$excluding ? " checked=\"checked\"" : '') . " onclick=\"ocseditor.updateCountries(this);\"/>"
103
+ . "<label for=\"" . $prefix . "-exluding-0\"> " . $this->__('Limit to') . "</label> &nbsp; "
104
+ . "<input type=\"radio\" class=\"excluding\" id=\"" . $prefix . "-exluding-1\" name=\"" . $prefix . "-exluding\""
105
+ . " value=\"1\"" . ($excluding ? " checked=\"checked\"" : '') . " onclick=\"ocseditor.updateCountries(this);\"/>"
106
+ . "<label for=\"" . $prefix . "-exluding-1\"> " . $this->__('Exclude') . "</label></p>"
107
+ . "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>"
108
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Display') . "</legend>"
109
+ . "<p>"
110
+ . $this->button('Display original input', "ocseditor.displayCountry('original-value',this,false);")
111
+ . $this->button('Display corrected names', "ocseditor.displayCountry('full-value',this,false);")
112
+ . $this->button('Display codes', "ocseditor.displayCountry('compact-value',this,true);")
113
+ . "</p>"
114
+ . "</fieldset>"
115
+ . "<fieldset class=\"buttons-set\"><legend>" . $this->__('Preview') . "</legend>"
116
+ . "<div class=\"address-filter-list\">" . $this->getAddressFilters($parsed_value) . "</div>"
117
+ . "</fieldset>"
118
+ . "</div>"
119
+ ;
120
+ break;
121
+ case '*comment' :
122
+ $lines = explode("\n", trim($value));
123
+ for ($i = 0; $i < count($lines); $i++) {
124
+ $lines[$i] = preg_replace('/^# ?/', '', $lines[$i]);
125
+ }
126
+ $value = implode("\n", $lines);
127
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>";
128
+ default :
129
+ return "<textarea id=\"" . $prefix . "\" class=\"field\">" . $value . "</textarea>";
130
+ }
131
+ }
132
 
133
+ private function getAddressFilters($data) {
134
+ $address_filters = array();
135
+ foreach ($data['countries'] as $country) {
136
+ $address_filters[] = new AddressFilter($country);
137
+ }
138
+ return implode('', $address_filters);
139
+ }
140
 
141
+ private function parseAddressFilter($address_filter) {
142
+ $output = array(
143
+ 'excluding' => false,
144
+ 'countries' => array(),
145
+ 'original' => $address_filter,
146
+ );
147
 
148
+ $address_filter = str_replace(array("\r\n", "\r", "\n"), array(',', ',', ','), $address_filter);
 
 
 
149
 
150
+ if (preg_match('# *\* *- *\((.*)\) *#s', $address_filter, $result)) {
151
+ $address_filter = $result[1];
152
+ $output['excluding'] = true;
153
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
+ $tmp_address_filter_array = explode(',', trim($address_filter));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
 
157
+ $concat = false;
158
+ $concatened = '';
159
+ $address_filter_array = array();
160
+ $i = 0;
161
 
162
+ foreach ($tmp_address_filter_array as $address_filter) {
163
+ if ($concat)
164
+ $concatened .= ',' . $address_filter;
165
+ else {
166
+ if ($i < count($tmp_address_filter_array) - 1 && preg_match('#\(#', $address_filter)) {
167
+ $concat = true;
168
+ $concatened .= $address_filter;
169
+ } else
170
+ $address_filter_array[] = $address_filter;
171
+ }
172
+ if (preg_match('#\)#', $address_filter)) {
173
+ $address_filter_array[] = $concatened;
174
+ $concatened = '';
175
+ $concat = false;
176
+ }
177
+ $i++;
178
+ }
179
 
180
+ foreach ($address_filter_array as $address_filter) {
181
+ $address_filter = trim($address_filter);
182
+ if (trim($address_filter) != '') {
183
+ if (preg_match('# *([^,(]+) *(-)? *(?:\( *(-)? *(.*)\))? *#s', $address_filter, $result)) {
184
+ $country_code = $result[1];
185
 
186
+ $region_codes = explode(',', $result[4]);
187
+ $in_array = false;
188
+ for ($i = count($region_codes); --$i >= 0;) {
189
+ $code = trim($region_codes[$i]);
190
+ $region_codes[$i] = $code;
191
+ }
192
+ /* $in_array = in_array($address['region_code'],$region_codes,true) || in_array($address['postcode'],$region_codes,true); */
193
+ $excluding_region = $result[2] == '-' || $result[3] == '-';
194
+ $output['countries'][] = array(
195
+ 'excluding' => $excluding_region,
196
+ 'country_code' => $country_code,
197
+ 'region_codes' => implode(',', $region_codes),
198
+ 'original' => $address_filter,
199
+ );
200
+ } else {
201
+ $output['countries'][] = array(
202
+ 'excluding' => null,
203
+ 'country_code' => $address_filter,
204
+ 'region_codes' => null,
205
+ 'original' => $address_filter,
206
+ );
207
+ }
208
+ }
209
+ }
210
+ return $output;
211
+ }
212
 
213
+ private function getRowUI($row, $selected) {
214
+ $row['_ID_']['value'] = isset($row['_ID_']['value']) ? $row['_ID_']['value'] : uniqid('c');
215
+ $row_id = $row['_ID_']['value'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
 
217
+ if (isset($row['lines'])) {
218
+ $output = "<div id=\"r-" . $row_id . "-container\" class=\"row-container has-error ignored-lines" . ($selected ? ' selected' : '') . "\">"
219
+ . "<div class=\"row-header\" onclick=\"ocseditor.selectRow('" . $row_id . "');\">"
220
+ . "<div class=\"row-actions\">"
221
+ . $this->button('Apply changes', "ocseditor.applyChanges();")
222
+ . $this->button('Delete', "ocseditor.removeRow(this);", 'delete')
223
+ . "</div>"
224
+ . "<div class=\"row-title\">" . $this->__('Ignored lines') . "</div></div>"
225
+ . "<div class=\"properties-container\"><textarea class=\"field\">" . $row['lines'] . "</textarea></div></div>";
226
+ return $output;
227
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
 
229
+ if (!isset($row['label'])) {
230
+ $row['label']['value'] = $this->__('New shipping method');
231
+ }
232
 
233
+ $properties = array(
234
+ 'enabled' => 'Enabled',
235
+ 'code' => 'Code',
236
+ 'label' => 'Label',
237
+ 'description' => 'Description',
238
+ 'destination' => 'Destination',
239
+ 'origin' => 'Origin',
240
+ 'conditions' => 'Conditions',
241
+ 'fees' => 'Fees',
242
+ 'customer_groups' => 'Customer groups',
243
+ 'tracking_url' => 'Tracking url',
244
+ '*comment' => 'Comment',
245
+ );
 
 
 
246
 
247
+ $label = $row['label']['value'];
248
+ $output = "<div id=\"r-" . $row_id . "-container\" class=\"row-container" . ($selected ? ' selected' : '') . "\">"
249
+ . "<div class=\"row-header\" onclick=\"ocseditor.selectRow('" . $row_id . "');\">"
250
+ . "<div class=\"row-actions\">" . $this->button('Delete', "ocseditor.removeRow(this);", 'delete') . "</div><div class=\"row-title\">" . $label . "</div></div>"
251
+ . "<div class=\"properties-container\">";
252
+ $list = "<ul class=\"properties-list\">";
253
+ $j = 0;
254
+ foreach ($properties as $property_key => $label) {
255
+ $cleaned_property = $this->cleanKey($property_key);
256
+ $value = isset($row[$property_key]) ? trim($row[$property_key]['value']) : '';
257
+ $list .= "<li id=\"r-" . $row_id . "-p-" . $cleaned_property . "-item\" class=\"property-item" . ($j == 0 ? ' selected' : '')
258
+ . (empty($value) ? ' empty' : '')
259
+ . "\" onclick=\"ocseditor.selectProperty('" . $row_id . "','" . $cleaned_property . "');\">" . $this->__($label) . "</li>";
260
+ $output .= "<div id=\"r-" . $row_id . "-p-" . $cleaned_property . "-container\" class=\"property-container"
261
+ . ($j == 0 ? ' selected' : '') . "\" property-name=\"" . $property_key . "\">"
262
+ . "<div class=\"buttons-set\" style=\"text-align:right;\">" . $this->button('Help', "ocseditor.help('property." . $property_key . "');", 'help') . "</div>"
263
+ . $this->getPropertyHelper($row_id, $property_key, $row[$property_key]) . "</div>";
264
+ $j++;
265
+ }
266
+ foreach ($row as $property_key => $property) {
267
+ if (!isset($properties[$property_key]) && substr($property_key, 0, 1) != '*') {
268
+ $label = $property_key;
269
+ $cleaned_property = $this->cleanKey($property_key);
270
+ $value = isset($row[$property_key]) ? trim($row[$property_key]['value']) : '';
271
+ $list .= "<li id=\"r-" . $row_id . "-p-" . $cleaned_property . "-item\" class=\"property-item" . ($j == 0 ? ' selected' : '')
272
+ . (empty($value) ? ' empty' : '') . ($cleaned_property == '_ID_' ? ' hide' : '')
273
+ . "\" onclick=\"ocseditor.selectProperty('" . $row_id . "','" . $cleaned_property . "');\">" . $this->__($label) . "</li>";
274
+ $output .= "<div id=\"r-" . $row_id . "-p-" . $cleaned_property . "-container\" class=\"property-container"
275
+ . ($j == 0 ? ' selected' : '') . "\" property-name=\"" . $property_key . "\">"
276
+ . "<div class=\"buttons-set\" style=\"text-align:right;\">" . $this->button('Help', "ocseditor.help('property." . $property_key . "');", 'help') . "</div>"
277
+ . $this->getPropertyHelper($row_id, $property_key, $property) . "</div>";
278
+ $j++;
279
+ }
280
+ }
281
+ $output .= $list . "</div></div>";
282
+ return $output;
283
+ }
284
 
285
+ private function getConfigErrors($config) {
286
+ $script = "ocseditor.resetErrors();";
287
+ foreach ($config as $row_code => $row) {
288
+ if (isset($row['*messages'])) {
289
+ $error = '';
290
+ foreach ($row['*messages'] as $message) {
291
+ $error .= "<p>" . $this->__($message) . "</p>";
292
+ }
293
+ if ($error != '')
294
+ $script .= "ocseditor.setError('" . $row['_ID_']['value'] . "','','" . $this->jsEscape($error) . "');";
295
+ }
296
+ foreach ($row as $property_key => $property) {
297
+ if (isset($property['messages'])) {
298
+ $error = '';
299
+ foreach ($property['messages'] as $message) {
300
+ $error .= "<p>" . $this->__($message) . "</p>";
301
+ }
302
+ if ($error != '') {
303
+ $script .= "ocseditor.setError('" . $row['_ID_']['value'] . "','" . $property_key . "','"
304
+ . $this->jsEscape($error
305
+ . ($property['value'] != $property['original_value'] ?
306
+ "<p>"
307
+ . $this->button('Correct', "ocseditor.correct('" . $row['_ID_']['value'] . "','" . $property_key . "','" . $this->jsEscape($property['value']) . "');")
308
+ . "</p>" : '')
309
+ ) . "');";
310
+ }
311
+ }
312
+ }
313
+ }
314
+ //$script .= "alert('".str_replace(array("\r\n","\n","\'","'"),array(" "," ","\\\'","\'"),$script)."');";
315
+ return $script;
316
+ }
317
 
318
+ private function loadConfig($input) {
319
+ include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
 
321
+ $helper = new ChronorelaisShippingHelper($input);
322
+ $helper->checkConfig();
323
+ $config = $helper->getConfig();
324
+ //print_r($config);
 
 
 
 
 
325
 
326
+ $output = "<div class=\"buttons-set\">"
327
+ . $this->button('Add a shipping method', "ocseditor.addRow();", 'add')
328
+ . "</div><div class=\"config-container\">";
329
+ $i = 0;
330
+ foreach ($config as &$row) {
331
+ $output .= $this->getRowUI($row, $i == 0);
332
+ $i++;
333
+ }
334
+ $output .= "</div><script type=\"text/javascript\">" . $this->getConfigErrors($config) . "</script>";
335
+ return $output;
336
+ }
337
 
338
+ public function indexAction() {
339
+ header('Content-Type: text/html; charset=UTF-8');
340
+
341
+ include_once $this->getIncludingPath('countries.inc.php');
342
+
343
+ switch ($_POST['what']) {
344
+ case 'open':
345
+ $output = ""
346
+ // Donate page
347
+ //.$this->page('donate',"Support the development of Chronorelais Shipping extension",$this->__('{ocseditor.donate-page.content}'))
348
+ // Help page
349
+ . $this->page('help', "Chronorelais Shipping extension help", '')
350
+ // Main page
351
+ . $this->pageHeader("Chronorelais Shipping configuration editor", $this->button('Save', "ocseditor.save();", 'save')
352
+ . $this->button('Export', "ocseditor.saveToFile();", '')
353
+ . $this->button('Load', "ocseditor.showConfigLoader();", '')
354
+ . $this->button('Close', "ocseditor.close();", 'cancel')
355
+ )
356
+ . "<div id=\"ocs-editor-config-loader\">"
357
+ . "<textarea></textarea>"
358
+ . "<div class=\"buttons-set\">"
359
+ . $this->button('Load', "ocseditor.loadConfig();", '')
360
+ . $this->button('Cancel', "ocseditor.hideConfigLoader();", 'cancel')
361
+ . "</div>"
362
+ . "</div>"
363
+ . "<div id=\"ocs-editor-config-container\">" . $this->loadConfig($_POST['input']) . "</div>"
364
+ /* ."<div class=\"donate-container\">"
365
+ ."<table cellspacing=\"0\"><tr>"
366
+ ."<td>".$this->__('You appreciate this extension and would like to help?')."</td>"
367
+ ."<td class=\"form-buttons\">"
368
+ .$this->button('Donate',"ocseditor.openPage('donate');",'donate')
369
+ ."</td>"
370
+ ."</tr></table>"
371
+ ."</div>" */
372
+ ;
373
+ echo $output;
374
+ exit;
375
+ case 'help':
376
+ echo $this->__('{ocseditor.help.' . $_POST['input'] . '}');
377
+ exit;
378
+ case 'add-row':
379
+ echo $this->getRowUI(array(), true);
380
+ exit;
381
+ case 'load-config':
382
+ echo $this->loadConfig($_POST['config']);
383
+ exit;
384
+ case 'check-config':
385
+ include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
386
+
387
+ $helper = new ChronorelaisShippingHelper(urldecode($_POST['config']));
388
+ $helper->checkConfig();
389
+ print_r($helper->getConfig(), $out);
390
+ //$script = "alert('".$this->jsEscape(urldecode($_POST['config']))."');";
391
+ $script = $this->getConfigErrors($helper->getConfig());
392
+ //$script = "alert('".$this->jsEscape($this->getConfigErrors($helper->getConfig()))."');";
393
+ break;
394
+ case 'save-to-file':
395
+ include_once $this->getIncludingPath('ChronorelaisShippingHelper.php');
396
+
397
+ $helper = new ChronorelaisShippingHelper(urldecode($_POST['config']));
398
+ $formatted_config = $helper->formatConfig(false);
399
+ $this->forceDownload('chronorelais-shipping-config.txt', $formatted_config);
400
+ exit;
401
+ case 'get-address-filters':
402
+ $result = $this->parseAddressFilter($_POST['input']);
403
+ echo $this->getAddressFilters($result);
404
+ exit;
405
+ }
406
+
407
+ echo "<script type=\"text/javascript\">" . $script . "</script>";
408
+ exit;
409
+ }
410
+
411
+ public function checkloginAction() {
412
+ $params = $this->getRequest()->getParams();
413
+ $account_number = $params['account_number'];
414
+ $sub_account_number = $params['sub_account_number'];
415
+ $account_pass = $params['account_pass'];
416
+ $helper = Mage::helper('chronorelais');
417
+
418
+ $WSParams = array(
419
+ 'accountNumber' => $account_number,
420
+ 'password' => $account_pass,
421
+ 'depCountryCode' => $helper->getConfigurationShipperInfo('country'),
422
+ 'depZipCode' => $helper->getConfigurationShipperInfo('zipcode'),
423
+ 'arrCountryCode' => $helper->getConfigurationShipperInfo('country'),
424
+ 'arrZipCode' => $helper->getConfigurationShipperInfo('zipcode'),
425
+ 'arrCity' => $helper->getConfigurationShipperInfo('city'),
426
+ 'type' => 'M',
427
+ 'weight' => 1
428
+ );
429
+
430
+ $helperWS = Mage::helper('chronorelais/webservice');
431
+ $webservbt = (array)$helperWS->checkLogin($WSParams);
432
+
433
+ echo json_encode($webservbt);
434
+ }
435
  }
app/code/community/Chronopost/Chronorelais/controllers/Checkout/MultishippingController.php CHANGED
@@ -1,114 +1,110 @@
1
- <?php
2
-
3
- require_once 'Mage/Checkout/controllers/MultishippingController.php';
4
- class Chronopost_Chronorelais_Checkout_MultishippingController extends Mage_Checkout_MultishippingController
5
- {
6
- /**
7
- * Get payment method step html
8
- *
9
- * @return string
10
- */
11
- protected function _getChronoRelaisHtml()
12
- {
13
- return $this->getLayout()->getBlock('root')->toHtml();
14
- }
15
-
16
- public function shippingPostAction()
17
- {
18
- $shippingMethods = $this->getRequest()->getPost('shipping_method');
19
- try {
20
- Mage::dispatchEvent(
21
- 'checkout_controller_multishipping_shipping_post',
22
- array('request'=>$this->getRequest(), 'quote'=>$this->_getCheckout()->getQuote())
23
- );
24
- $this->_getCheckout()->setShippingMethods($shippingMethods);
25
-
26
- //WEC chronorelais
27
- $addresses = $this->_getCheckout()->getQuote()->getAllShippingAddresses();
28
- $relays = $this->getRequest()->getParam('shipping_method_chronorelais');
29
- foreach ($addresses as $address) {
30
- if (isset($shippingMethods[$address->getId()])) {
31
- if( substr($shippingMethods[$address->getId()],0,12) == "chronorelais" ){
32
-
33
- $relaisId = $relays[$address->getId()];
34
- if($relaisId!=""){
35
-
36
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl");
37
- $webservbt = $client->__call("rechercheBtParIdChronopostA2Pas",array($relaisId));
38
- $relais = $webservbt[0] ;
39
-
40
- if($relais) {
41
- $address->setCity($relais->localite)
42
- ->setPostcode($relais->codePostal)
43
- ->setStreet ( trim( $relais->adresse1." ".$relais->adresse2." ".$relais->adresse3 ) )
44
- ->setCompany ( $relais->nomEnseigne )
45
- ->setWRelayPointCode( $relais->identifiantChronopostPointA2PAS )
46
- ->save()
47
- ->setCollectShippingRates(true);
48
- }
49
- }
50
- }
51
- }
52
- }
53
- //ENDWEC chronorelais
54
-
55
- $this->_getState()->setActiveStep(
56
- Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING
57
- );
58
- $this->_getState()->setCompleteStep(
59
- Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING
60
- );
61
- $this->_redirect('*/*/billing');
62
- }
63
- catch (Exception $e){
64
- $this->_getCheckoutSession()->addError($e->getMessage());
65
- $this->_redirect('*/*/shipping');
66
- }
67
- }
68
-
69
- /**
70
- * Get relais
71
- */
72
- public function getMultiRelaisAction()
73
- {
74
- $result = array();
75
- $postcode = $this->getRequest()->get('zip', '');
76
-
77
- if (extension_loaded('soap')) {
78
- $addresses = $this->_getCheckout()->getQuote()->getAllShippingAddresses();
79
- foreach ($addresses as $address) {
80
- if ($address->getId() == $this->getRequest()->get('index')) {
81
- /*$address->setPostcode($postcode)
82
- ->save()
83
- ->setCollectShippingRates(true);*/
84
-
85
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl",array('trace'=> 0,'connection_timeout'=>10));
86
- $webservbt = $client->__call("rechercheBtParCodeproduitEtCodepostalEtDate",array(0,$postcode,0));
87
-
88
- if ($webservbt) {
89
- Mage::getSingleton('core/session')->setMultiPostcode($postcode);
90
- $this->loadLayout('checkout_multishipping_shippingchronorelais');
91
- $result['update_section'] = array(
92
- 'name' => 'checkout-shipping-method-chronorelais-load_'.$this->getRequest()->get('index'),
93
- 'html' => str_replace("%%id%%", $this->getRequest()->get('index'), $this->_getChronoRelaisHtml())
94
- );
95
- $result['relaypoints'] = $webservbt;
96
- } else {
97
- $result['error'] = true;
98
- $result['message'] = $this->__('No point relay is associated with this postcode');
99
- }
100
-
101
- break;
102
- }
103
- }
104
- if (count($result) == 0) {
105
- $result['error'] = true;
106
- $result['message'] = $this->__('Issue with addresses');
107
- }
108
- } else {
109
- $result['error'] = true;
110
- $result['message'] = $this->__('Sorry for inconvenience, The SOAP extension is not installed in the server. Please contact the site administrator.');
111
- }
112
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
113
- }
114
- }
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()])) {
29
+ if (substr($shippingMethods[$address->getId()], 0, 12) == "chronorelais") {
30
+
31
+ $relaisId = $relays[$address->getId()];
32
+ if ($relaisId != "") {
33
+
34
+ $helper = Mage::helper('chronorelais/webservice');
35
+ $relais = $helper->getDetailRelaisPoint($relaisId);
36
+
37
+ if ($relais) {
38
+ $address->setCity($relais->localite)
39
+ ->setPostcode($relais->codePostal)
40
+ ->setStreet(trim($relais->adresse1 . "\n" . $relais->adresse2 . " " . $relais->adresse3))
41
+ ->setCompany($relais->nomEnseigne)
42
+ ->setWRelayPointCode($relais->identifiantChronopostPointA2PAS)
43
+ ->save()
44
+ ->setCollectShippingRates(true);
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
50
+ //ENDWEC chronorelais
51
+
52
+ $this->_getState()->setActiveStep(
53
+ Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING
54
+ );
55
+ $this->_getState()->setCompleteStep(
56
+ Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING
57
+ );
58
+ $this->_redirect('*/*/billing');
59
+ } catch (Exception $e) {
60
+ $this->_getCheckoutSession()->addError($e->getMessage());
61
+ $this->_redirect('*/*/shipping');
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Get relais
67
+ */
68
+ public function getMultiRelaisAction() {
69
+ $result = array();
70
+ $postcode = $this->getRequest()->get('zip', '');
71
+
72
+ if (extension_loaded('soap')) {
73
+ $addresses = $this->_getCheckout()->getQuote()->getAllShippingAddresses();
74
+ foreach ($addresses as $address) {
75
+ if ($address->getId() == $this->getRequest()->get('index')) {
76
+ /* $address->setPostcode($postcode)
77
+ ->save()
78
+ ->setCollectShippingRates(true); */
79
+
80
+ $helper = Mage::helper('chronorelais/webservice');
81
+ $webservbt = $helper->getPointsRelaisByCp($postcode);
82
+
83
+ if ($webservbt) {
84
+ Mage::getSingleton('core/session')->setMultiPostcode($postcode);
85
+ $this->loadLayout('checkout_multishipping_shippingchronorelais');
86
+ $result['update_section'] = array(
87
+ 'name' => 'checkout-shipping-method-chronorelais-load_' . $this->getRequest()->get('index'),
88
+ 'html' => str_replace("%%id%%", $this->getRequest()->get('index'), $this->_getChronoRelaisHtml())
89
+ );
90
+ $result['relaypoints'] = $webservbt;
91
+ } else {
92
+ $result['error'] = true;
93
+ $result['message'] = $this->__('No point relay is associated with this postcode');
94
+ }
95
+
96
+ break;
97
+ }
98
+ }
99
+ if (count($result) == 0) {
100
+ $result['error'] = true;
101
+ $result['message'] = $this->__('Issue with addresses');
102
+ }
103
+ } else {
104
+ $result['error'] = true;
105
+ $result['message'] = $this->__('Sorry for inconvenience, The SOAP extension is not installed in the server. Please contact the site administrator.');
106
+ }
107
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
108
+ }
109
+
110
+ }
 
 
 
 
app/code/community/Chronopost/Chronorelais/controllers/Checkout/OnepageController.php CHANGED
@@ -1,281 +1,282 @@
1
- <?php
2
-
3
- require_once 'Mage/Checkout/controllers/OnepageController.php';
4
-
5
- class Chronopost_Chronorelais_Checkout_OnepageController extends Mage_Checkout_OnepageController {
6
-
7
- protected $_sectionUpdateFunctions = array(
8
- 'payment-method' => '_getPaymentMethodsHtml',
9
- 'shipping-method' => '_getShippingMethodsHtml',
10
- 'review' => '_getReviewHtml',
11
- 'shipping-method-chronorelais' => '_getReviewHtml',
12
- );
13
-
14
- /**
15
- * Get payment method step html
16
- *
17
- * @return string
18
- */
19
- protected function _getChronoRelaisHtml() {
20
- return $this->getLayout()->getBlock('root')->toHtml();
21
- }
22
-
23
- /**
24
- * Checkout page
25
- */
26
- public function indexAction() {
27
- if (!extension_loaded('soap')) {
28
- if (Mage::helper('chronorelais')->getConfigData('carriers/chronopost/active') || Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/active') || Mage::helper('chronorelais')->getConfigData('carriers/chronoexpress/active')) {
29
- Mage::getSingleton('checkout/session')->addError($this->__('The SOAP extension is not installed in the server. Please contact the site administrator. Sorry for inconvenience.'));
30
- $this->_redirect('checkout/cart');
31
- return;
32
- }
33
- }
34
- parent::indexAction();
35
- }
36
-
37
- /**
38
- * save checkout billing address
39
- */
40
- public function saveBillingAction() {
41
- if ($this->_expireAjax()) {
42
- return;
43
- }
44
- if ($this->getRequest()->isPost()) {
45
- // $postData = $this->getRequest()->getPost('billing', array());
46
- // $data = $this->_filterPostData($postData);
47
- $data = $this->getRequest()->getPost('billing', array());
48
- $customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
49
-
50
- if (isset($data['email'])) {
51
- $data['email'] = trim($data['email']);
52
- }
53
- $result = $this->getOnepage()->saveBilling($data, $customerAddressId);
54
-
55
- if (!isset($result['error'])) {
56
- /* check quote for virtual */
57
- if ($this->getOnepage()->getQuote()->isVirtual()) {
58
- $result['goto_section'] = 'payment';
59
- $result['update_section'] = array(
60
- 'name' => 'payment-method',
61
- 'html' => $this->_getPaymentMethodsHtml()
62
- );
63
- } elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
64
- $result['goto_section'] = 'shipping_method';
65
- $result['update_section'] = array(
66
- 'name' => 'shipping-method',
67
- 'html' => $this->_getShippingMethodsHtml()
68
- );
69
-
70
- $result['allow_sections'] = array('shipping');
71
- $result['duplicateBillingInfo'] = 'true';
72
-
73
- //WEC chronorelais
74
- if (isset($_SESSION["customer_shipping_address_reference"])) {
75
- unset($_SESSION["customer_shipping_address_reference"]);
76
- }
77
-
78
- if (!array_key_exists("company", $data)) {
79
- $data["company"] = "";
80
- }
81
-
82
- $_SESSION["customer_shipping_address_reference"]["data"] = $data;
83
- $_SESSION["customer_shipping_address_reference"]["customerAddressId"] = $customerAddressId;
84
- $_SESSION["customer_shipping_address_reference"]["available"] = false;
85
- //ENDWEC
86
- } else {
87
- $result['goto_section'] = 'shipping';
88
- }
89
- }
90
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
91
- }
92
- }
93
-
94
- /**
95
- * Shipping address save action
96
- */
97
- public function saveShippingAction() {
98
- if ($this->_expireAjax()) {
99
- return;
100
- }
101
- if ($this->getRequest()->isPost()) {
102
- $data = $this->getRequest()->getPost('shipping', array());
103
- $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
104
- $result = $this->getOnepage()->saveShipping($data, $customerAddressId);
105
-
106
- if (!isset($result['error'])) {
107
- $result['goto_section'] = 'shipping_method';
108
- $result['update_section'] = array(
109
- 'name' => 'shipping-method',
110
- 'html' => $this->_getShippingMethodsHtml()
111
- );
112
- }
113
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
114
- }
115
-
116
- //WEC chronorelais
117
- if (isset($_SESSION["customer_shipping_address_reference"])) {
118
- unset($_SESSION["customer_shipping_address_reference"]);
119
- }
120
- if (!array_key_exists("company", $data)) {
121
- $data["company"] = "";
122
- }
123
- $_SESSION["customer_shipping_address_reference"]["data"] = $data;
124
- $_SESSION["customer_shipping_address_reference"]["customerAddressId"] = $customerAddressId;
125
- $_SESSION["customer_shipping_address_reference"]["available"] = false;
126
-
127
- //ENDWEC
128
- }
129
-
130
- /**
131
- * Shipping method save action
132
- */
133
- public function saveShippingMethodAction() {
134
- if ($this->_expireAjax()) {
135
- return;
136
- }
137
- if ($this->getRequest()->isPost()) {
138
-
139
- //WEC chronorelais
140
- if ($_SESSION["customer_shipping_address_reference"]["available"]) {
141
- $data = $_SESSION["customer_shipping_address_reference"]["data"];
142
- $customerAddressId = $_SESSION["customer_shipping_address_reference"]["customerAddressId"];
143
- $_SESSION["customer_shipping_address_reference"]["available"] = false;
144
-
145
- $result = $this->getOnepage()->saveShipping($data, $customerAddressId);
146
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
147
- }
148
-
149
- $method = $this->getRequest()->getParam('shipping_method');
150
- $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
151
- $address = $quote->getShippingAddress();
152
-
153
- if (substr($this->getRequest()->getParam('shipping_method'), 0, 12) == "chronorelais") {
154
- $relaisId = $this->getRequest()->getParam('shipping_method_chronorelais');
155
- if ($relaisId != "") {
156
-
157
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl");
158
- $webservbt = $client->__call("rechercheBtParIdChronopostA2Pas", array($relaisId));
159
- $relais = $webservbt[0];
160
-
161
- if ($relais) {
162
- $address->setCity($relais->localite)
163
- ->setPostcode($relais->codePostal)
164
- ->setStreet(trim($relais->adresse1 . " " . $relais->adresse2 . " " . $relais->adresse3))
165
- ->setCompany($relais->nomEnseigne)
166
- ->setWRelayPointCode($relais->identifiantChronopostPointA2PAS)
167
- ->save()
168
- ->setCollectShippingRates(true);
169
-
170
- $_SESSION["customer_shipping_address_reference"]["available"] = true;
171
- }
172
- }
173
- }
174
-
175
- $methodTitle = "";
176
- if (isset($relais->localite)) {
177
- $methodTitle = ' - ' . $relais->nomEnseigne . ' - ' . trim($relais->adresse1 . " " . $relais->adresse2 . " " . $relais->adresse3) . ' - ' . $relais->codePostal . ' - ' . $relais->localite;
178
- }
179
- if ($method) {
180
- foreach ($address->getAllShippingRates() as $rate) {
181
- if ($rate->getCode() == $method) {
182
- $address->setShippingDescription($rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle() . $methodTitle);
183
- break;
184
- }
185
- }
186
- }
187
- //ENDWEC chronorelais
188
-
189
- $data = $this->getRequest()->getPost('shipping_method', '');
190
- $result = $this->getOnepage()->saveShippingMethod($data);
191
- /*
192
- $result will have erro data if shipping method is empty
193
- */
194
- if (!$result) {
195
- Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method', array('request' => $this->getRequest(),
196
- 'quote' => $this->getOnepage()->getQuote()));
197
- $this->getOnepage()->getQuote()->collectTotals();
198
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
199
-
200
- $result['goto_section'] = 'payment';
201
- $result['update_section'] = array(
202
- 'name' => 'payment-method',
203
- 'html' => $this->_getPaymentMethodsHtml()
204
- );
205
- }
206
- $this->getOnepage()->getQuote()->collectTotals()->save();
207
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
208
- }
209
- }
210
-
211
- /**
212
- * Get relais
213
- */
214
- public function getRelaisAction() {
215
- if ($this->_expireAjax()) {
216
- return;
217
- }
218
- $result = array();
219
- $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
220
- $address = $quote->getShippingAddress();
221
- $postcode = $address->getPostcode();
222
-
223
- if (extension_loaded('soap')) {
224
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl", array('trace' => 0, 'connection_timeout' => 10));
225
- $webservbt = $client->__call("rechercheBtParCodeproduitEtCodepostalEtDate", array(0, $postcode, 0));
226
-
227
- if ($webservbt) {
228
- $this->loadLayout('checkout_onepage_shippingchronorelais');
229
- $result['goto_section'] = 'shipping-method';
230
- $result['update_section'] = array(
231
- 'name' => 'shipping-method-chronorelais',
232
- 'html' => $this->_getChronoRelaisHtml()
233
- );
234
- $result['relaypoints'] = $webservbt;
235
- } else {
236
- $result['error'] = true;
237
- $result['message'] = $this->__('No point relay is associated with this postcode');
238
- }
239
- } else {
240
- $result['error'] = true;
241
- $result['message'] = $this->__('Sorry for inconvenience, The SOAP extension is not installed in the server. Please contact the site administrator.');
242
- }
243
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
244
- }
245
-
246
- /**
247
- * Change shipping postal code
248
- */
249
- public function changePostalCodeAction() {
250
- if ($this->_expireAjax()) {
251
- return;
252
- }
253
- $result = array();
254
- $webservbt = array();
255
- $postcode = $this->getRequest()->getPost('mappostalcode');
256
- if ($postcode) {
257
- $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
258
- $address = $quote->getShippingAddress();
259
- $address->setPostcode($postcode)
260
- ->save()
261
- ->setCollectShippingRates(true);
262
-
263
- $client = new SoapClient("http://wsshipping.chronopost.fr/soap.point.relais/services/ServiceRechercheBt?wsdl", array('trace' => 0, 'connection_timeout' => 10));
264
- $webservbt = $client->__call("rechercheBtParCodeproduitEtCodepostalEtDate", array(0, $postcode, 0));
265
- }
266
- if ($webservbt) {
267
- $this->loadLayout('checkout_onepage_shippingchronorelais');
268
- $result['goto_section'] = 'shipping-method';
269
- $result['update_section'] = array(
270
- 'name' => 'shipping-method-chronorelais',
271
- 'html' => $this->_getChronoRelaisHtml()
272
- );
273
- $result['relaypoints'] = $webservbt;
274
- } else {
275
- $result['error'] = true;
276
- $result['message'] = $this->__('No point relay is associated with this postcode');
277
- }
278
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
279
- }
280
-
 
281
  }
1
+ <?php
2
+
3
+ require_once 'Mage/Checkout/controllers/OnepageController.php';
4
+
5
+ class Chronopost_Chronorelais_Checkout_OnepageController extends Mage_Checkout_OnepageController {
6
+
7
+ protected $_sectionUpdateFunctions = array(
8
+ 'payment-method' => '_getPaymentMethodsHtml',
9
+ 'shipping-method' => '_getShippingMethodsHtml',
10
+ 'review' => '_getReviewHtml',
11
+ 'shipping-method-chronorelais' => '_getReviewHtml',
12
+ );
13
+
14
+ /**
15
+ * Get payment method step html
16
+ *
17
+ * @return string
18
+ */
19
+ protected function _getChronoRelaisHtml() {
20
+ return $this->getLayout()->getBlock('root')->toHtml();
21
+ }
22
+
23
+ /**
24
+ * Checkout page
25
+ */
26
+ public function indexAction() {
27
+ if (!extension_loaded('soap')) {
28
+ if (Mage::helper('chronorelais')->getConfigData('carriers/chronopost/active') || Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/active') || Mage::helper('chronorelais')->getConfigData('carriers/chronoexpress/active')) {
29
+ Mage::getSingleton('checkout/session')->addError($this->__('The SOAP extension is not installed in the server. Please contact the site administrator. Sorry for inconvenience.'));
30
+ $this->_redirect('checkout/cart');
31
+ return;
32
+ }
33
+ }
34
+ parent::indexAction();
35
+ }
36
+
37
+ /**
38
+ * save checkout billing address
39
+ */
40
+ public function saveBillingAction() {
41
+ if ($this->_expireAjax()) {
42
+ return;
43
+ }
44
+ if ($this->getRequest()->isPost()) {
45
+ // $postData = $this->getRequest()->getPost('billing', array());
46
+ // $data = $this->_filterPostData($postData);
47
+ $data = $this->getRequest()->getPost('billing', array());
48
+ $customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
49
+
50
+ if (isset($data['email'])) {
51
+ $data['email'] = trim($data['email']);
52
+ }
53
+ $result = $this->getOnepage()->saveBilling($data, $customerAddressId);
54
+
55
+ if (!isset($result['error'])) {
56
+ /* check quote for virtual */
57
+ if ($this->getOnepage()->getQuote()->isVirtual()) {
58
+ $result['goto_section'] = 'payment';
59
+ $result['update_section'] = array(
60
+ 'name' => 'payment-method',
61
+ 'html' => $this->_getPaymentMethodsHtml()
62
+ );
63
+ } elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
64
+ $result['goto_section'] = 'shipping_method';
65
+ $result['update_section'] = array(
66
+ 'name' => 'shipping-method',
67
+ 'html' => $this->_getShippingMethodsHtml()
68
+ );
69
+
70
+ $result['allow_sections'] = array('shipping');
71
+ $result['duplicateBillingInfo'] = 'true';
72
+
73
+ //WEC chronorelais
74
+ if (isset($_SESSION["customer_shipping_address_reference"])) {
75
+ unset($_SESSION["customer_shipping_address_reference"]);
76
+ }
77
+
78
+ if (!array_key_exists("company", $data)) {
79
+ $data["company"] = "";
80
+ }
81
+
82
+ $_SESSION["customer_shipping_address_reference"]["data"] = $data;
83
+ $_SESSION["customer_shipping_address_reference"]["customerAddressId"] = $customerAddressId;
84
+ $_SESSION["customer_shipping_address_reference"]["available"] = false;
85
+ //ENDWEC
86
+ } else {
87
+ $result['goto_section'] = 'shipping';
88
+ }
89
+ }
90
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Shipping address save action
96
+ */
97
+ public function saveShippingAction() {
98
+ if ($this->_expireAjax()) {
99
+ return;
100
+ }
101
+ if ($this->getRequest()->isPost()) {
102
+ $data = $this->getRequest()->getPost('shipping', array());
103
+ $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
104
+ $result = $this->getOnepage()->saveShipping($data, $customerAddressId);
105
+
106
+ if (!isset($result['error'])) {
107
+ $result['goto_section'] = 'shipping_method';
108
+ $result['update_section'] = array(
109
+ 'name' => 'shipping-method',
110
+ 'html' => $this->_getShippingMethodsHtml()
111
+ );
112
+ }
113
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
114
+ }
115
+
116
+ //WEC chronorelais
117
+ if (isset($_SESSION["customer_shipping_address_reference"])) {
118
+ unset($_SESSION["customer_shipping_address_reference"]);
119
+ }
120
+ if (!array_key_exists("company", $data)) {
121
+ $data["company"] = "";
122
+ }
123
+ $_SESSION["customer_shipping_address_reference"]["data"] = $data;
124
+ $_SESSION["customer_shipping_address_reference"]["customerAddressId"] = $customerAddressId;
125
+ $_SESSION["customer_shipping_address_reference"]["available"] = false;
126
+
127
+ //ENDWEC
128
+ }
129
+
130
+ /**
131
+ * Shipping method save action
132
+ */
133
+ public function saveShippingMethodAction() {
134
+ if ($this->_expireAjax()) {
135
+ return;
136
+ }
137
+ if ($this->getRequest()->isPost()) {
138
+
139
+ //WEC chronorelais
140
+ if ($_SESSION["customer_shipping_address_reference"]["available"]) {
141
+ $data = $_SESSION["customer_shipping_address_reference"]["data"];
142
+ $customerAddressId = $_SESSION["customer_shipping_address_reference"]["customerAddressId"];
143
+ $_SESSION["customer_shipping_address_reference"]["available"] = false;
144
+
145
+ $result = $this->getOnepage()->saveShipping($data, $customerAddressId);
146
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
147
+ }
148
+
149
+ $method = $this->getRequest()->getParam('shipping_method');
150
+ $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
151
+ $address = $quote->getShippingAddress();
152
+
153
+ if (substr($this->getRequest()->getParam('shipping_method'), 0, 12) == "chronorelais") {
154
+ $relaisId = $this->getRequest()->getParam('shipping_method_chronorelais');
155
+ if ($relaisId != "") {
156
+
157
+ $helper = Mage::helper('chronorelais/webservice');
158
+ $relais = $helper->getDetailRelaisPoint($relaisId);
159
+
160
+ if ($relais) {
161
+ $address->setCity($relais->localite)
162
+ ->setPostcode($relais->codePostal)
163
+ ->setStreet(trim($relais->adresse1 . "\n" . $relais->adresse2 . " " . $relais->adresse3))
164
+ ->setCompany($relais->nomEnseigne)
165
+ ->setWRelayPointCode($relais->identifiantChronopostPointA2PAS)
166
+ ->save()
167
+ ->setCollectShippingRates(true);
168
+
169
+ $_SESSION["customer_shipping_address_reference"]["available"] = true;
170
+ }
171
+ }
172
+ }
173
+
174
+ $methodTitle = "";
175
+ if (isset($relais->localite)) {
176
+ $methodTitle = ' - ' . $relais->nomEnseigne . ' - ' . trim($relais->adresse1 . " " . $relais->adresse2 . " " . $relais->adresse3) . ' - ' . $relais->codePostal . ' - ' . $relais->localite;
177
+ }
178
+ if ($method) {
179
+ foreach ($address->getAllShippingRates() as $rate) {
180
+ if ($rate->getCode() == $method) {
181
+ $address->setShippingDescription($rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle() . $methodTitle);
182
+ break;
183
+ }
184
+ }
185
+ }
186
+ //ENDWEC chronorelais
187
+
188
+ $data = $this->getRequest()->getPost('shipping_method', '');
189
+ $result = $this->getOnepage()->saveShippingMethod($data);
190
+ /*
191
+ $result will have erro data if shipping method is empty
192
+ */
193
+ if (!$result) {
194
+ Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method', array('request' => $this->getRequest(),
195
+ 'quote' => $this->getOnepage()->getQuote()));
196
+ $this->getOnepage()->getQuote()->collectTotals();
197
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
198
+
199
+ $result['goto_section'] = 'payment';
200
+ $result['update_section'] = array(
201
+ 'name' => 'payment-method',
202
+ 'html' => $this->_getPaymentMethodsHtml()
203
+ );
204
+ }
205
+ $this->getOnepage()->getQuote()->collectTotals()->save();
206
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Get relais
212
+ */
213
+ public function getRelaisAction() {
214
+ if ($this->_expireAjax()) {
215
+ return;
216
+ }
217
+ $result = array();
218
+ $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
219
+ $address = $quote->getShippingAddress();
220
+ $postcode = $address->getPostcode();
221
+
222
+ if (extension_loaded('soap')) {
223
+
224
+ $helper = Mage::helper('chronorelais/webservice');
225
+ $webservbt = $helper->getPointRelaisByAddress();
226
+
227
+ if ($webservbt) {
228
+ $this->loadLayout('checkout_onepage_shippingchronorelais');
229
+ $result['goto_section'] = 'shipping-method';
230
+ $result['update_section'] = array(
231
+ 'name' => 'shipping-method-chronorelais',
232
+ 'html' => $this->_getChronoRelaisHtml()
233
+ );
234
+ $result['relaypoints'] = $webservbt;
235
+ } else {
236
+ $result['error'] = true;
237
+ $result['message'] = $this->__('No point relay is associated with this postcode');
238
+ }
239
+ } else {
240
+ $result['error'] = true;
241
+ $result['message'] = $this->__('Sorry for inconvenience, The SOAP extension is not installed in the server. Please contact the site administrator.');
242
+ }
243
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
244
+ }
245
+
246
+ /**
247
+ * Change shipping postal code
248
+ */
249
+ public function changePostalCodeAction() {
250
+ if ($this->_expireAjax()) {
251
+ return;
252
+ }
253
+ $result = array();
254
+ $webservbt = array();
255
+ $postcode = $this->getRequest()->getPost('mappostalcode');
256
+ if ($postcode) {
257
+ $quote = $this->getOnepage()->getQuote(); //Mage::getSingleton('checkout/cart')->init()->getQuote();
258
+ $address = $quote->getShippingAddress();
259
+ $address->setPostcode($postcode)
260
+ ->save()
261
+ ->setCollectShippingRates(true);
262
+
263
+ $helper = Mage::helper('chronorelais/webservice');
264
+ $webservbt = $helper->getPointsRelaisByCp($postcode);
265
+
266
+ }
267
+ if ($webservbt) {
268
+ $this->loadLayout('checkout_onepage_shippingchronorelais');
269
+ $result['goto_section'] = 'shipping-method';
270
+ $result['update_section'] = array(
271
+ 'name' => 'shipping-method-chronorelais',
272
+ 'html' => $this->_getChronoRelaisHtml()
273
+ );
274
+ $result['relaypoints'] = $webservbt;
275
+ } else {
276
+ $result['error'] = true;
277
+ $result['message'] = $this->__('No point relay is associated with this postcode');
278
+ }
279
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
280
+ }
281
+
282
  }
app/code/community/Chronopost/Chronorelais/controllers/ExportController.php CHANGED
@@ -1,445 +1,445 @@
1
- <?php
2
- class Chronopost_Chronorelais_ExportController 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 orders list
15
- */
16
- public function indexAction()
17
- {
18
- $this->loadLayout()
19
- ->_setActiveMenu('sales/chronorelais/export')
20
- ->_addContent($this->getLayout()->createBlock('chronorelais/export_orders'))
21
- ->renderLayout();
22
- }
23
-
24
- public function getValue($value)
25
- {
26
- return ($value!='' ? $value : '');
27
- }
28
-
29
- public function removeSpclChars($text)
30
- {
31
- return ereg_replace("[^0-9a-zA-Z]", "", $text);
32
- }
33
-
34
- public function massLivraisonSamediStatusAction()
35
- {
36
- if($this->getRequest()->getPost('status')) {
37
- $this->saveLivraisonSamediStatusAction();
38
- }
39
- }
40
-
41
- public function massExportAction()
42
- {
43
- if($this->getRequest()->getPost('format')=='css') {
44
- $this->exportcssAction();
45
- } elseif($this->getRequest()->getPost('format')=='cso') {
46
- $this->exportcsoAction();
47
- }
48
- }
49
-
50
- /**
51
- * Export CSS Action
52
- * Generates a CSV file to download (CSS format)
53
- */
54
- public function exportcssAction()
55
- {
56
- /* get the orders */
57
- $orderIds = $this->getRequest()->getPost('order_ids');
58
-
59
- /**
60
- * Get configuration
61
- */
62
- $separator = Mage::helper('chronorelais')->getConfigurationFieldSeparator('css');
63
- $delimiter = Mage::helper('chronorelais')->getConfigurationFieldDelimiter('css');
64
-
65
- if ($delimiter == 'simple_quote') {
66
- $delimiter = "'";
67
- } else if ($delimiter == 'double_quotes') {
68
- $delimiter = '"';
69
- } else {
70
- $delimiter = '';
71
- }
72
- $lineBreak = Mage::helper('chronorelais')->getConfigurationEndOfLineCharacter('css');
73
- if ($lineBreak == 'lf') {
74
- $lineBreak = "\n";
75
- } else if ($lineBreak == 'cr') {
76
- $lineBreak = "\r";
77
- } else if ($lineBreak == 'crlf') {
78
- $lineBreak = "\r\n";
79
- }
80
- $fileExtension = Mage::helper('chronorelais')->getConfigurationFileExtension('css');
81
- $fileCharset = Mage::helper('chronorelais')->getConfigurationFileCharset('css');
82
-
83
- /* set the filename */
84
- $filename = 'orders_exportcss_'.Mage::getSingleton('core/date')->date('Ymd_His').$fileExtension;
85
-
86
- /* initialize the content variable */
87
- $content = '';
88
-
89
- if (!empty($orderIds)) {
90
- foreach ($orderIds as $orderId) {
91
-
92
- /* get the order */
93
- $order = Mage::getModel('sales/order')->load($orderId);
94
- $address = $order->getShippingAddress();
95
- $billingAddress = $order->getBillingAddress();
96
-
97
- $_shippingMethod = explode('_',$order->getShippingMethod());
98
-
99
- /* customer id */
100
- $content = $this->_addFieldToCsv($content, $delimiter, ($order->getCustomerId() ? $order->getCustomerId() : $address->getLastname()));
101
- $content .= $separator;
102
- /* Nom du point relais OU soci�t� si livraison � domicile */
103
- //$content = $this->_addFieldToCsv($content, $delimiter, $_shippingMethod[0] == "chronorelais" ? $address->getCompany() : "");
104
- $content = $this->_addFieldToCsv($content, $delimiter, $address->getCompany());
105
- $content .= $separator;
106
- /* customer name */
107
- $content = $this->_addFieldToCsv($content, $delimiter, ($address->getName() ? $address->getName() : $billingAddress->getName()));
108
- $content .= $separator;
109
- /* street address */
110
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(1)));
111
- $content .= $separator;
112
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(2)));
113
- $content .= $separator;
114
- /* postal code */
115
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getPostcode()));
116
- $content .= $separator;
117
- /* city */
118
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCity()));
119
- $content .= $separator;
120
- /* country code */
121
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCountry()));
122
- $content .= $separator;
123
- /* telephone */
124
- $telephone = trim(ereg_replace("[^0-9.-]", " ", $address->getTelephone()));
125
- $telephone = (strlen($telephone)>=10 ? $telephone : '');
126
- $content = $this->_addFieldToCsv($content, $delimiter, $telephone);
127
- $content .= $separator;
128
- /* email */
129
- $customer_email = ($address->getEmail()) ? $address->getEmail() : ($billingAddress->getEmail() ? $billingAddress->getEmail() : $order->getCustomerEmail());
130
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($customer_email));
131
- $content .= $separator;
132
- /* chronorelay point */
133
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getWRelayPointCode()));
134
- $content .= $separator;
135
- /* real order id */
136
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($order->getRealOrderId()));
137
- $content .= $separator;
138
- /* total weight */
139
- $order_weight = number_format($order->getWeight(), 2 , '.' , '');
140
- //$order_weight = $order_weight * 1000;
141
- $content = $this->_addFieldToCsv($content, $delimiter, $order_weight);
142
- $content .= $separator;
143
-
144
- /* productCode*/
145
- $productCode = ''; //Default code for chronorelais
146
- $productCode = Mage::helper('chronorelais')->getChronoProductCodeString($_shippingMethod[0]);
147
- $content = $this->_addFieldToCsv($content, $delimiter, $productCode);
148
- $content .= $separator;
149
-
150
- /* Livraison Samedi*/
151
- $SaturdayShipping = 'L'; //default value for the saturday shipping
152
- $send_day = strtolower(date('l'));
153
- if($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
154
- if(!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($orderId)) {
155
- $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/'.$_shippingMethod[0].'/deliver_on_saturday');
156
- } else {
157
- if($_deliver_on_saturday=='Yes') {
158
- $_deliver_on_saturday = 1;
159
- } else {
160
- $_deliver_on_saturday = 0;
161
- }
162
- }
163
- $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
164
- if($_deliver_on_saturday && $is_sending_day==true) {
165
- $SaturdayShipping = 'S';
166
- } elseif(!$_deliver_on_saturday && $is_sending_day==true) {
167
- $SaturdayShipping = 'L';
168
- }
169
- }
170
- $content = $this->_addFieldToCsv($content, $delimiter, $SaturdayShipping);
171
- $content .= $separator;
172
-
173
- /* empty fields */
174
- $content = $this->_addFieldToCsv($content, $delimiter, 0);
175
- $content .= $separator;
176
- $content = $this->_addFieldToCsv($content, $delimiter, 0);
177
- $content .= $lineBreak;
178
- }
179
-
180
- /* decode the content, depending on the charset */
181
- if ($fileCharset == 'ISO-8859-1') {
182
- $content = utf8_decode($content);
183
- }
184
-
185
- /* pick file mime type, depending on the extension */
186
- if ($fileExtension == '.txt') {
187
- $fileMimeType = 'text/plain';
188
- } else if ($fileExtension == '.csv') {
189
- $fileMimeType = 'application/csv';
190
- } else if ($fileExtension == '.chr') {
191
- $fileMimeType = 'application/chr';
192
- } else {
193
- // default
194
- $fileMimeType = 'text/plain';
195
- }
196
-
197
- /* download the file */
198
- return $this->_prepareDownloadResponse($filename, $content, $fileMimeType .'; charset="'. $fileCharset .'"');
199
- }
200
- else {
201
- $this->_getSession()->addError($this->__('No Order has been selected'));
202
- }
203
- }
204
-
205
- /**
206
- * Export CSO Action
207
- * Generates a CSV file to download (CSO format)
208
- */
209
- public function exportcsoAction()
210
- {
211
- /* get the orders */
212
- $orderIds = $this->getRequest()->getPost('order_ids');
213
-
214
- /**
215
- * Get configuration
216
- */
217
- $separator = Mage::helper('chronorelais')->getConfigurationFieldSeparator('cso');
218
- $delimiter = Mage::helper('chronorelais')->getConfigurationFieldDelimiter('cso');
219
- if ($delimiter == 'simple_quote') {
220
- $delimiter = "'";
221
- } else if ($delimiter == 'double_quotes') {
222
- $delimiter = '"';
223
- } else {
224
- $delimiter = '';
225
- }
226
- $lineBreak = Mage::helper('chronorelais')->getConfigurationEndOfLineCharacter('cso');
227
- if ($lineBreak == 'lf') {
228
- $lineBreak = "\n";
229
- } else if ($lineBreak == 'cr') {
230
- $lineBreak = "\r";
231
- } else if ($lineBreak == 'crlf') {
232
- $lineBreak = "\r\n";
233
- }
234
- $fileExtension = Mage::helper('chronorelais')->getConfigurationFileExtension('cso');
235
- $fileCharset = Mage::helper('chronorelais')->getConfigurationFileCharset('cso');
236
-
237
- /* set the filename */
238
- $filename = 'orders_exportcso_'.Mage::getSingleton('core/date')->date('Ymd_His').$fileExtension;
239
-
240
- /* initialize the content variable */
241
- $content = '';
242
-
243
- if (!empty($orderIds)) {
244
- foreach ($orderIds as $orderId) {
245
-
246
- /* get the order */
247
- $order = Mage::getModel('sales/order')->load($orderId);
248
- $address = $order->getShippingAddress();
249
- $billingAddress = $order->getBillingAddress();
250
-
251
- /* customer id */
252
- $content = $this->_addFieldToCsv($content, $delimiter, ($order->getCustomerId() ? $order->getCustomerId() : $address->getLastname()));
253
- $content .= $separator;
254
- /* Nom du point relais OU soci�t� si livraison � domicile */
255
- //$content = $this->_addFieldToCsv($content, $delimiter, $_shippingMethod[0] == "chronorelais" ? $address->getCompany() : "");
256
- $content = $this->_addFieldToCsv($content, $delimiter, $address->getCompany());
257
- $content .= $separator;
258
- /* empty */
259
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
260
- $content .= $separator;
261
- /* street address */
262
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(1)));
263
- $content .= $separator;
264
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(2)));
265
- $content .= $separator;
266
- /* Code Porte */
267
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
268
- $content .= $separator;
269
- /* country code */
270
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCountry()));
271
- $content .= $separator;
272
- /* postal code */
273
- $content = $this->_addFieldToCsv($content, $delimiter, $this->removeSpclChars($this->getValue($address->getPostcode())));
274
- $content .= $separator;
275
- /* city */
276
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(strtoupper($address->getCity())));
277
- $content .= $separator;
278
- /* lastname */
279
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getLastname()));
280
- $content .= $separator;
281
- /* firstname */
282
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getFirstname()));
283
- $content .= $separator;
284
- /* telephone */
285
- $telephone = trim(ereg_replace("[^0-9.-]", " ", $address->getTelephone()));
286
- $telephone = (strlen($telephone)>=10 ? $telephone : '');
287
- $content = $this->_addFieldToCsv($content, $delimiter, $telephone);
288
- $content .= $separator;
289
- /* email */
290
- $customer_email = ($address->getEmail()) ? $address->getEmail() : ($billingAddress->getEmail() ? $billingAddress->getEmail() : $order->getCustomerEmail());
291
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($customer_email));
292
- $content .= $separator;
293
- /* VAT number*/
294
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
295
- $content .= $separator;
296
- /* productCode*/
297
- $productCode = ''; //Default code for chronorelais
298
- $_shippingMethod = explode('_',$order->getShippingMethod());
299
- if($_shippingMethod[0] == "chronopost") { // Conditions for chronorelais code
300
- $productCode = 1;
301
- } elseif($_shippingMethod[0] == "chronorelais") {
302
- //$productCode = 6; //for chronorelais
303
- } else {
304
- $productCode = 4; //for chronoexpress
305
- }
306
- $content = $this->_addFieldToCsv($content, $delimiter, $productCode);
307
- $content .= $separator;
308
- /* real order id */
309
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($order->getRealOrderId()));
310
- $content .= $separator;
311
- /* total weight */
312
- $order_weight = number_format($order->getWeight(), 2 , '.' , '');
313
- $order_weight = $order_weight * 1000;
314
- $content = $this->_addFieldToCsv($content, $delimiter, $order_weight);
315
- $content .= $separator;
316
- /* Valeur Assur�e field*/
317
- $content = $this->_addFieldToCsv($content, $delimiter, 0);
318
- $content .= $separator;
319
- /* Inform the recipient by e-mail field*/
320
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue("N"));
321
- $content .= $separator;
322
- /* Print Waybill field*/
323
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue("O"));
324
- $content .= $separator;
325
- /* sub-account field*/
326
- $sub_account = Mage::helper('chronorelais')->getConfigurationSubAccountNumber();
327
- $content = $this->_addFieldToCsv($content, $delimiter, (strlen($sub_account)==3 ? $sub_account : ""));
328
- $content .= $separator;
329
- /* Nature of item field*/
330
- $content = $this->_addFieldToCsv($content, $delimiter, 2);
331
- $content .= $separator;
332
- /* Description of Consignment field*/
333
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
334
- $content .= $separator;
335
- /* Print pro-forma (customs) field*/
336
- $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue("N"));
337
- $content .= $separator;
338
- /* Declared value (customs) field*/
339
- $content = $this->_addFieldToCsv($content, $delimiter, 0);
340
- $content .= $separator;
341
- /* Livraison Samedi (Delivery Saturday) field*/
342
- $SaturdayShipping = 0; //default value for the saturday shipping
343
- $send_day = strtolower(date('l'));
344
- if($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
345
- if(!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($orderId)) {
346
- $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/'.$_shippingMethod[0].'/deliver_on_saturday');
347
- } else {
348
- if($_deliver_on_saturday=='Yes') {
349
- $_deliver_on_saturday = 1;
350
- } else {
351
- $_deliver_on_saturday = 0;
352
- }
353
- }
354
- $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
355
- if($_deliver_on_saturday && $is_sending_day) {
356
- $SaturdayShipping = 1;
357
- } elseif(!$_deliver_on_saturday && $is_sending_day) {
358
- $SaturdayShipping = 2;
359
- }
360
- }
361
- $content = $this->_addFieldToCsv($content, $delimiter, $SaturdayShipping);
362
- $content .= $lineBreak;
363
- }
364
-
365
- /* decode the content, depending on the charset */
366
- if ($fileCharset == 'ISO-8859-1') {
367
- $content = utf8_decode($content);
368
- }
369
-
370
- /* pick file mime type, depending on the extension */
371
- if ($fileExtension == '.txt') {
372
- $fileMimeType = 'text/plain';
373
- } else if ($fileExtension == '.csv') {
374
- $fileMimeType = 'application/csv';
375
- } else if ($fileExtension == '.chr') {
376
- $fileMimeType = 'application/chr';
377
- } else {
378
- // default
379
- $fileMimeType = 'text/plain';
380
- }
381
-
382
- /* download the file */
383
- return $this->_prepareDownloadResponse($filename, $content, $fileMimeType .'; charset="'. $fileCharset .'"');
384
- }
385
- else {
386
- $this->_getSession()->addError($this->__('No Order has been selected'));
387
- }
388
- }
389
-
390
- /* Save the Livraison le Samedi status to orders */
391
- public function saveLivraisonSamediStatusAction()
392
- {
393
- /* get the orders */
394
- $orderIds = $this->getRequest()->getPost('order_ids');
395
- $status = $this->getRequest()->getPost('status');
396
- $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
397
- $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
398
- $exceptions = array();
399
-
400
- foreach($orderIds as $orderId) {
401
- $order_details = Mage::getModel('sales/order')->load($orderId);
402
- $shipping_method = '';
403
- $livraison_le_samedi = $status;
404
- if($shipping_method = $order_details->getShippingMethod()) {
405
- $shipping_method = explode('_',$shipping_method);
406
- if($shipping_method[0]=='chronoexpress') {
407
- $livraison_le_samedi = '--';
408
- }
409
- }
410
- $condition = array(
411
- $_connection->quoteInto('order_id = ?', $orderId),
412
- );
413
- $_connection->delete($_table, $condition);
414
-
415
- $dataLine = array(
416
- 'order_id' => $orderId,
417
- 'livraison_le_samedi' => $livraison_le_samedi
418
- );
419
- try {
420
- $_connection->insert($_table, $dataLine);
421
- }
422
- catch (Exception $e) {
423
- $exceptions[] = Mage::helper('chronorelais')->__('Order assigning error: ' . $e->getMessage());
424
- }
425
- }
426
- if($exceptions) {
427
- $this->_getSession()->addError($exceptions);
428
- } else {
429
- $this->_getSession()->addSuccess($this->__('Livraison le Samedi statut a &eacute;t&eacute; ajout&eacute;'));
430
- }
431
- $this->_redirect('*/*/index');
432
- }
433
-
434
- /**
435
- * Add a new field to the csv file
436
- * @param csvContent : the current csv content
437
- * @param fieldDelimiter : the delimiter character
438
- * @param fieldContent : the content to add
439
- * @return : the concatenation of current content and content to add
440
- */
441
- private function _addFieldToCsv($csvContent, $fieldDelimiter, $fieldContent) {
442
- return $csvContent . $fieldDelimiter . $fieldContent . $fieldDelimiter;
443
- }
444
-
445
  }
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_ExportController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ /**
6
+ * Constructor
7
+ */
8
+ protected function _construct() {
9
+ $this->setUsedModuleName('Chronopost_Chronorelais');
10
+ }
11
+
12
+ /**
13
+ * Main action : show orders list
14
+ */
15
+ public function indexAction() {
16
+ $this->loadLayout()
17
+ ->_setActiveMenu('sales/chronorelais/export')
18
+ ->_addContent($this->getLayout()->createBlock('chronorelais/export_orders'))
19
+ ->renderLayout();
20
+ }
21
+
22
+ public function getValue($value) {
23
+ return ($value != '' ? $value : '');
24
+ }
25
+
26
+ public function removeSpclChars($text) {
27
+ return ereg_replace("[^0-9a-zA-Z]", "", $text);
28
+ }
29
+
30
+ public function massLivraisonSamediStatusAction() {
31
+ if ($this->getRequest()->getPost('status')) {
32
+ $this->saveLivraisonSamediStatusAction();
33
+ }
34
+ }
35
+
36
+ public function massExportAction() {
37
+ if ($this->getRequest()->getPost('format') == 'css') {
38
+ $this->exportcssAction();
39
+ } elseif ($this->getRequest()->getPost('format') == 'cso') {
40
+ $this->exportcsoAction();
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Export CSS Action
46
+ * Generates a CSV file to download (CSS format)
47
+ */
48
+ public function exportcssAction() {
49
+ /* get the orders */
50
+ $orderIds = $this->getRequest()->getPost('order_ids');
51
+
52
+ /**
53
+ * Get configuration
54
+ */
55
+ $separator = Mage::helper('chronorelais')->getConfigurationFieldSeparator('css');
56
+ $delimiter = Mage::helper('chronorelais')->getConfigurationFieldDelimiter('css');
57
+
58
+ if ($delimiter == 'simple_quote') {
59
+ $delimiter = "'";
60
+ } else if ($delimiter == 'double_quotes') {
61
+ $delimiter = '"';
62
+ } else {
63
+ $delimiter = '';
64
+ }
65
+ $lineBreak = Mage::helper('chronorelais')->getConfigurationEndOfLineCharacter('css');
66
+ if ($lineBreak == 'lf') {
67
+ $lineBreak = "\n";
68
+ } else if ($lineBreak == 'cr') {
69
+ $lineBreak = "\r";
70
+ } else if ($lineBreak == 'crlf') {
71
+ $lineBreak = "\r\n";
72
+ }
73
+ $fileExtension = Mage::helper('chronorelais')->getConfigurationFileExtension('css');
74
+ $fileCharset = Mage::helper('chronorelais')->getConfigurationFileCharset('css');
75
+
76
+ /* set the filename */
77
+ $filename = 'orders_exportcss_' . Mage::getSingleton('core/date')->date('Ymd_His') . $fileExtension;
78
+
79
+ /* initialize the content variable */
80
+ $content = '';
81
+ $helper = Mage::helper('chronorelais');
82
+ $weightUnit = $helper->getConfigWeightUnit();
83
+ if (!empty($orderIds)) {
84
+ foreach ($orderIds as $orderId) {
85
+
86
+ /* get the order */
87
+ $order = Mage::getModel('sales/order')->load($orderId);
88
+ $address = $order->getShippingAddress();
89
+ $billingAddress = $order->getBillingAddress();
90
+
91
+ $_shippingMethod = explode('_', $order->getShippingMethod());
92
+
93
+ /* customer id */
94
+ $content = $this->_addFieldToCsv($content, $delimiter, ($order->getCustomerId() ? $order->getCustomerId() : $address->getLastname()));
95
+ $content .= $separator;
96
+ /* Nom du point relais OU soci�t� si livraison � domicile */
97
+ //$content = $this->_addFieldToCsv($content, $delimiter, $_shippingMethod[0] == "chronorelais" ? $address->getCompany() : "");
98
+ $content = $this->_addFieldToCsv($content, $delimiter, $address->getCompany());
99
+ $content .= $separator;
100
+ /* customer name */
101
+ $content = $this->_addFieldToCsv($content, $delimiter, ($address->getName() ? $address->getName() : $billingAddress->getName()));
102
+ $content .= $separator;
103
+ /* street address */
104
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(1)));
105
+ $content .= $separator;
106
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(2)));
107
+ $content .= $separator;
108
+ /* postal code */
109
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getPostcode()));
110
+ $content .= $separator;
111
+ /* city */
112
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCity()));
113
+ $content .= $separator;
114
+ /* country code */
115
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCountry()));
116
+ $content .= $separator;
117
+ /* telephone */
118
+ $telephone = trim(ereg_replace("[^0-9.-]", " ", $address->getTelephone()));
119
+ $telephone = (strlen($telephone) >= 10 ? $telephone : '');
120
+ $content = $this->_addFieldToCsv($content, $delimiter, $telephone);
121
+ $content .= $separator;
122
+ /* email */
123
+ $customer_email = ($address->getEmail()) ? $address->getEmail() : ($billingAddress->getEmail() ? $billingAddress->getEmail() : $order->getCustomerEmail());
124
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($customer_email));
125
+ $content .= $separator;
126
+ /* chronorelay point */
127
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getWRelayPointCode()));
128
+ $content .= $separator;
129
+ /* real order id */
130
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($order->getRealOrderId()));
131
+ $content .= $separator;
132
+
133
+
134
+ /* total weight (in kg) */
135
+ $order_weight = number_format($order->getWeight(), 2, '.', '');
136
+ if($weightUnit == 'g') {
137
+ $order_weight = $order_weight / 1000;
138
+ }
139
+ //$order_weight = $order_weight * 1000;
140
+ $content = $this->_addFieldToCsv($content, $delimiter, $order_weight);
141
+ $content .= $separator;
142
+
143
+ /* productCode */
144
+ $productCode = ''; //Default code for chronorelais
145
+ $productCode = Mage::helper('chronorelais')->getChronoProductCodeString($_shippingMethod[0]);
146
+ $content = $this->_addFieldToCsv($content, $delimiter, $productCode);
147
+ $content .= $separator;
148
+
149
+ /* Livraison Samedi */
150
+ $SaturdayShipping = 'L'; //default value for the saturday shipping
151
+ $send_day = strtolower(date('l'));
152
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
153
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($orderId)) {
154
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
155
+ } else {
156
+ if ($_deliver_on_saturday == 'Yes') {
157
+ $_deliver_on_saturday = 1;
158
+ } else {
159
+ $_deliver_on_saturday = 0;
160
+ }
161
+ }
162
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
163
+ if ($_deliver_on_saturday && $is_sending_day == true) {
164
+ $SaturdayShipping = 'S';
165
+ } elseif (!$_deliver_on_saturday && $is_sending_day == true) {
166
+ $SaturdayShipping = 'L';
167
+ }
168
+ }
169
+ $content = $this->_addFieldToCsv($content, $delimiter, $SaturdayShipping);
170
+ $content .= $separator;
171
+
172
+ /* empty fields */
173
+ $content = $this->_addFieldToCsv($content, $delimiter, 0);
174
+ $content .= $separator;
175
+ $content = $this->_addFieldToCsv($content, $delimiter, 0);
176
+ $content .= $lineBreak;
177
+ }
178
+
179
+ /* decode the content, depending on the charset */
180
+ if ($fileCharset == 'ISO-8859-1') {
181
+ $content = utf8_decode($content);
182
+ }
183
+
184
+ /* pick file mime type, depending on the extension */
185
+ if ($fileExtension == '.txt') {
186
+ $fileMimeType = 'text/plain';
187
+ } else if ($fileExtension == '.csv') {
188
+ $fileMimeType = 'application/csv';
189
+ } else if ($fileExtension == '.chr') {
190
+ $fileMimeType = 'application/chr';
191
+ } else {
192
+ // default
193
+ $fileMimeType = 'text/plain';
194
+ }
195
+
196
+ /* download the file */
197
+ return $this->_prepareDownloadResponse($filename, $content, $fileMimeType . '; charset="' . $fileCharset . '"');
198
+ } else {
199
+ $this->_getSession()->addError($this->__('No Order has been selected'));
200
+ }
201
+ }
202
+
203
+ /**
204
+ * Export CSO Action
205
+ * Generates a CSV file to download (CSO format)
206
+ */
207
+ public function exportcsoAction() {
208
+ /* get the orders */
209
+ $orderIds = $this->getRequest()->getPost('order_ids');
210
+
211
+ /**
212
+ * Get configuration
213
+ */
214
+ $separator = Mage::helper('chronorelais')->getConfigurationFieldSeparator('cso');
215
+ $delimiter = Mage::helper('chronorelais')->getConfigurationFieldDelimiter('cso');
216
+ if ($delimiter == 'simple_quote') {
217
+ $delimiter = "'";
218
+ } else if ($delimiter == 'double_quotes') {
219
+ $delimiter = '"';
220
+ } else {
221
+ $delimiter = '';
222
+ }
223
+ $lineBreak = Mage::helper('chronorelais')->getConfigurationEndOfLineCharacter('cso');
224
+ if ($lineBreak == 'lf') {
225
+ $lineBreak = "\n";
226
+ } else if ($lineBreak == 'cr') {
227
+ $lineBreak = "\r";
228
+ } else if ($lineBreak == 'crlf') {
229
+ $lineBreak = "\r\n";
230
+ }
231
+ $fileExtension = Mage::helper('chronorelais')->getConfigurationFileExtension('cso');
232
+ $fileCharset = Mage::helper('chronorelais')->getConfigurationFileCharset('cso');
233
+
234
+ /* set the filename */
235
+ $filename = 'orders_exportcso_' . Mage::getSingleton('core/date')->date('Ymd_His') . $fileExtension;
236
+
237
+ /* initialize the content variable */
238
+ $content = '';
239
+ $helper = Mage::helper('chronorelais');
240
+ $weightUnit = $helper->getConfigWeightUnit();
241
+ if (!empty($orderIds)) {
242
+ foreach ($orderIds as $orderId) {
243
+
244
+ /* get the order */
245
+ $order = Mage::getModel('sales/order')->load($orderId);
246
+ $address = $order->getShippingAddress();
247
+ $billingAddress = $order->getBillingAddress();
248
+
249
+ /* customer id */
250
+ $content = $this->_addFieldToCsv($content, $delimiter, ($order->getCustomerId() ? $order->getCustomerId() : $address->getLastname()));
251
+ $content .= $separator;
252
+ /* Nom du point relais OU soci�t� si livraison � domicile */
253
+ //$content = $this->_addFieldToCsv($content, $delimiter, $_shippingMethod[0] == "chronorelais" ? $address->getCompany() : "");
254
+ $content = $this->_addFieldToCsv($content, $delimiter, $address->getCompany());
255
+ $content .= $separator;
256
+ /* empty */
257
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
258
+ $content .= $separator;
259
+ /* street address */
260
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(1)));
261
+ $content .= $separator;
262
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getStreet(2)));
263
+ $content .= $separator;
264
+ /* Code Porte */
265
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
266
+ $content .= $separator;
267
+ /* country code */
268
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getCountry()));
269
+ $content .= $separator;
270
+ /* postal code */
271
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->removeSpclChars($this->getValue($address->getPostcode())));
272
+ $content .= $separator;
273
+ /* city */
274
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(strtoupper($address->getCity())));
275
+ $content .= $separator;
276
+ /* lastname */
277
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getLastname()));
278
+ $content .= $separator;
279
+ /* firstname */
280
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($address->getFirstname()));
281
+ $content .= $separator;
282
+ /* telephone */
283
+ $telephone = trim(ereg_replace("[^0-9.-]", " ", $address->getTelephone()));
284
+ $telephone = (strlen($telephone) >= 10 ? $telephone : '');
285
+ $content = $this->_addFieldToCsv($content, $delimiter, $telephone);
286
+ $content .= $separator;
287
+ /* email */
288
+ $customer_email = ($address->getEmail()) ? $address->getEmail() : ($billingAddress->getEmail() ? $billingAddress->getEmail() : $order->getCustomerEmail());
289
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($customer_email));
290
+ $content .= $separator;
291
+ /* VAT number */
292
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
293
+ $content .= $separator;
294
+ /* productCode */
295
+ $productCode = ''; //Default code for chronorelais
296
+ $_shippingMethod = explode('_', $order->getShippingMethod());
297
+ if ($_shippingMethod[0] == "chronopost") { // Conditions for chronorelais code
298
+ $productCode = 1;
299
+ } elseif ($_shippingMethod[0] == "chronorelais") {
300
+ //$productCode = 6; //for chronorelais
301
+ } else {
302
+ $productCode = 4; //for chronoexpress
303
+ }
304
+ $content = $this->_addFieldToCsv($content, $delimiter, $productCode);
305
+ $content .= $separator;
306
+ /* real order id */
307
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue($order->getRealOrderId()));
308
+ $content .= $separator;
309
+
310
+ /* total weight (in g)*/
311
+ $order_weight = number_format($order->getWeight(), 2, '.', '');
312
+ if($weightUnit == 'kg') {
313
+ $order_weight = $order_weight * 1000;
314
+ }
315
+ $content = $this->_addFieldToCsv($content, $delimiter, $order_weight);
316
+ $content .= $separator;
317
+
318
+ /* Valeur Assur�e field */
319
+ $content = $this->_addFieldToCsv($content, $delimiter, 0);
320
+ $content .= $separator;
321
+ /* Inform the recipient by e-mail field */
322
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue("N"));
323
+ $content .= $separator;
324
+ /* Print Waybill field */
325
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue("O"));
326
+ $content .= $separator;
327
+ /* sub-account field */
328
+ $sub_account = Mage::helper('chronorelais')->getConfigurationSubAccountNumber();
329
+ $content = $this->_addFieldToCsv($content, $delimiter, (strlen($sub_account) == 3 ? $sub_account : ""));
330
+ $content .= $separator;
331
+ /* Nature of item field */
332
+ $content = $this->_addFieldToCsv($content, $delimiter, 2);
333
+ $content .= $separator;
334
+ /* Description of Consignment field */
335
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue(""));
336
+ $content .= $separator;
337
+ /* Print pro-forma (customs) field */
338
+ $content = $this->_addFieldToCsv($content, $delimiter, $this->getValue("N"));
339
+ $content .= $separator;
340
+ /* Declared value (customs) field */
341
+ $content = $this->_addFieldToCsv($content, $delimiter, 0);
342
+ $content .= $separator;
343
+ /* Livraison Samedi (Delivery Saturday) field */
344
+ $SaturdayShipping = 0; //default value for the saturday shipping
345
+ $send_day = strtolower(date('l'));
346
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
347
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($orderId)) {
348
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
349
+ } else {
350
+ if ($_deliver_on_saturday == 'Yes') {
351
+ $_deliver_on_saturday = 1;
352
+ } else {
353
+ $_deliver_on_saturday = 0;
354
+ }
355
+ }
356
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
357
+ if ($_deliver_on_saturday && $is_sending_day) {
358
+ $SaturdayShipping = 1;
359
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
360
+ $SaturdayShipping = 2;
361
+ }
362
+ }
363
+ $content = $this->_addFieldToCsv($content, $delimiter, $SaturdayShipping);
364
+ $content .= $lineBreak;
365
+ }
366
+
367
+ /* decode the content, depending on the charset */
368
+ if ($fileCharset == 'ISO-8859-1') {
369
+ $content = utf8_decode($content);
370
+ }
371
+
372
+ /* pick file mime type, depending on the extension */
373
+ if ($fileExtension == '.txt') {
374
+ $fileMimeType = 'text/plain';
375
+ } else if ($fileExtension == '.csv') {
376
+ $fileMimeType = 'application/csv';
377
+ } else if ($fileExtension == '.chr') {
378
+ $fileMimeType = 'application/chr';
379
+ } else {
380
+ // default
381
+ $fileMimeType = 'text/plain';
382
+ }
383
+
384
+ /* download the file */
385
+ return $this->_prepareDownloadResponse($filename, $content, $fileMimeType . '; charset="' . $fileCharset . '"');
386
+ } else {
387
+ $this->_getSession()->addError($this->__('No Order has been selected'));
388
+ }
389
+ }
390
+
391
+ /* Save the Livraison le Samedi status to orders */
392
+
393
+ public function saveLivraisonSamediStatusAction() {
394
+ /* get the orders */
395
+ $orderIds = $this->getRequest()->getPost('order_ids');
396
+ $status = $this->getRequest()->getPost('status');
397
+ $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
398
+ $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
399
+ $exceptions = array();
400
+
401
+ foreach ($orderIds as $orderId) {
402
+ $order_details = Mage::getModel('sales/order')->load($orderId);
403
+ $shipping_method = '';
404
+ $livraison_le_samedi = $status;
405
+ if ($shipping_method = $order_details->getShippingMethod()) {
406
+ $shipping_method = explode('_', $shipping_method);
407
+ if ($shipping_method[0] == 'chronoexpress') {
408
+ $livraison_le_samedi = '--';
409
+ }
410
+ }
411
+ $condition = array(
412
+ $_connection->quoteInto('order_id = ?', $orderId),
413
+ );
414
+ $_connection->delete($_table, $condition);
415
+
416
+ $dataLine = array(
417
+ 'order_id' => $orderId,
418
+ 'livraison_le_samedi' => $livraison_le_samedi
419
+ );
420
+ try {
421
+ $_connection->insert($_table, $dataLine);
422
+ } catch (Exception $e) {
423
+ $exceptions[] = Mage::helper('chronorelais')->__('Order assigning error: ' . $e->getMessage());
424
+ }
425
+ }
426
+ if ($exceptions) {
427
+ $this->_getSession()->addError($exceptions);
428
+ } else {
429
+ $this->_getSession()->addSuccess($this->__('Livraison le Samedi statut a &eacute;t&eacute; ajout&eacute;'));
430
+ }
431
+ $this->_redirect('*/*/index');
432
+ }
433
+
434
+ /**
435
+ * Add a new field to the csv file
436
+ * @param csvContent : the current csv content
437
+ * @param fieldDelimiter : the delimiter character
438
+ * @param fieldContent : the content to add
439
+ * @return : the concatenation of current content and content to add
440
+ */
441
+ private function _addFieldToCsv($csvContent, $fieldDelimiter, $fieldContent) {
442
+ return $csvContent . $fieldDelimiter . $fieldContent . $fieldDelimiter;
443
+ }
444
+
445
  }
app/code/community/Chronopost/Chronorelais/controllers/ImportController.php CHANGED
@@ -1,249 +1,249 @@
1
- <?php
2
- class Chronopost_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
- /* debug */
78
- //$this->_getSession()->addSuccess($this->__('%s - %s - %s - %s', $sendEmail, $comment, $includeComment, $trackingTitle));
79
-
80
- /**
81
- * $k is line number
82
- * $v is line content array
83
- */
84
- foreach ($csvData as $k => $v) {
85
-
86
- /**
87
- * End of file has more than one empty lines
88
- */
89
- if (count($v) <= 1 && !strlen($v[0])) {
90
- continue;
91
- }
92
-
93
- /**
94
- * Check that the number of fields is not lower than expected
95
- */
96
- if (count($v) < count($expectedCsvFields)) {
97
- $this->_getSession()->addError($this->__('Line %s format is invalid and has been ignored', $k));
98
- continue;
99
- }
100
-
101
- /**
102
- * Get fields content
103
- */
104
- $orderId = $v[0];
105
- $trackingNumber = $v[1];
106
-
107
- /* for debug */
108
- //$this->_getSession()->addSuccess($this->__('Lecture ligne %s: %s - %s', $k, $orderId, $trackingNumber));
109
-
110
- /**
111
- * Try to load the order
112
- */
113
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
114
- if (!$order->getId()) {
115
- $this->_getSession()->addError($this->__('Order %s does not exist', $orderId));
116
- continue;
117
- }
118
-
119
- /**
120
- * Try to create a shipment
121
- */
122
- $shipmentId = $this->_createShipment($order, $trackingNumber, $trackingTitle, $sendEmail, $comment, $includeComment);
123
-
124
- if ($shipmentId != 0) {
125
- $this->_getSession()->addSuccess($this->__('Shipment %s created for order %s, with tracking number %s', $shipmentId, $orderId, $trackingNumber));
126
- }
127
-
128
- }//foreach
129
-
130
- }
131
-
132
- /**
133
- * Create new shipment for order
134
- * Inspired by Mage_Sales_Model_Order_Shipment_Api methods
135
- *
136
- * @param Mage_Sales_Model_Order $order (it should exist, no control is done into the method)
137
- * @param string $trackingNumber
138
- * @param string $trackingTitle
139
- * @param booleam $email
140
- * @param string $comment
141
- * @param boolean $includeComment
142
- * @return int : shipment real id if creation was ok, else 0
143
- */
144
- public function _createShipment($order, $trackingNumber, $trackingTitle, $email, $comment, $includeComment)
145
- {
146
- /**
147
- * Check shipment creation availability
148
- */
149
- if (!$order->canShip()) {
150
- $this->_getSession()->addError($this->__('Order %s can not be shipped or has already been shipped', $order->getRealOrderId()));
151
- return 0;
152
- }
153
-
154
- /**
155
- * Initialize the Mage_Sales_Model_Order_Shipment object
156
- */
157
- $convertor = Mage::getModel('sales/convert_order');
158
- $shipment = $convertor->toShipment($order);
159
-
160
- /**
161
- * Add the items to send
162
- */
163
- foreach ($order->getAllItems() as $orderItem) {
164
- if (!$orderItem->getQtyToShip()) {
165
- continue;
166
- }
167
- if ($orderItem->getIsVirtual()) {
168
- continue;
169
- }
170
-
171
- $item = $convertor->itemToShipmentItem($orderItem);
172
- $qty = $orderItem->getQtyToShip();
173
- $item->setQty($qty);
174
-
175
- $shipment->addItem($item);
176
- }//foreach
177
-
178
- $shipment->register();
179
-
180
- /**
181
- * Tracking number instanciation
182
- */
183
-
184
- $_shippingMethod = explode("_",$order->getShippingMethod());
185
- switch($_shippingMethod[0]) {
186
- case "chronopost":
187
- case "chronorelais":
188
- case "chronoexpress":
189
- $carrier_code = $_shippingMethod[0];
190
- $popup = 1;
191
- /*$hash = Mage::helper('core')->urlEncode("order_id:{$order->getId()}:{$order->getProtectCode()}");
192
- $tracking_url = Mage::getBaseUrl().'chronorelais/relais/tracking/hash/'.$hash.'/';*/
193
- $tracking_url = str_replace('{tracking_number}', $trackingNumber, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
194
- $tracking_title = $this->__('Track Your Order');
195
- $tracking_order = '<p><a title="'.$tracking_title.'" href="'.$tracking_url.'"><b>'.$tracking_title.'</b></a></p>';
196
- break;
197
- default:
198
- $carrier_code = 'custom';
199
- $popup = 0;
200
- $tracking_order = '';
201
- break;
202
- }
203
-
204
- $track = Mage::getModel('sales/order_shipment_track')
205
- ->setNumber($trackingNumber) //setTrackingNumber ?
206
- ->setCarrierCode($carrier_code)
207
- ->setTitle($trackingTitle)
208
- ->setPopup($popup);
209
- $shipment->addTrack($track);
210
-
211
- /**
212
- * Comment handling
213
- */
214
- $shipment->addComment($comment, $email && $includeComment);
215
-
216
- /**
217
- * Change order status to Processing
218
- */
219
- $shipment->getOrder()->setIsInProcess(true);
220
-
221
- /**
222
- * If e-mail, set as sent (must be done before shipment object saving)
223
- */
224
- if ($email) {
225
- $shipment->setEmailSent(true);
226
- }
227
-
228
- try {
229
- /**
230
- * Save the created shipment and the updated order
231
- */
232
- $shipment->save();
233
- $shipment->getOrder()->save();
234
-
235
- /**
236
- * Email sending
237
- */
238
- $shipment->sendEmail($email, ($includeComment ? $tracking_order.$comment : $tracking_order));
239
- } catch (Mage_Core_Exception $e) {
240
- $this->_getSession()->addError($this->__('Shipment creation error for Order %s : %s', $orderId, $e->getMessage()));
241
- return 0;
242
- }
243
-
244
- /**
245
- * Everything was ok : return Shipment real id
246
- */
247
- return $shipment->getIncrementId();
248
- }
249
  }
1
+ <?php
2
+ class Chronopost_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
+ /* debug */
78
+ //$this->_getSession()->addSuccess($this->__('%s - %s - %s - %s', $sendEmail, $comment, $includeComment, $trackingTitle));
79
+
80
+ /**
81
+ * $k is line number
82
+ * $v is line content array
83
+ */
84
+ foreach ($csvData as $k => $v) {
85
+
86
+ /**
87
+ * End of file has more than one empty lines
88
+ */
89
+ if (count($v) <= 1 && !strlen($v[0])) {
90
+ continue;
91
+ }
92
+
93
+ /**
94
+ * Check that the number of fields is not lower than expected
95
+ */
96
+ if (count($v) < count($expectedCsvFields)) {
97
+ $this->_getSession()->addError($this->__('Line %s format is invalid and has been ignored', $k));
98
+ continue;
99
+ }
100
+
101
+ /**
102
+ * Get fields content
103
+ */
104
+ $orderId = $v[0];
105
+ $trackingNumber = $v[1];
106
+
107
+ /* for debug */
108
+ //$this->_getSession()->addSuccess($this->__('Lecture ligne %s: %s - %s', $k, $orderId, $trackingNumber));
109
+
110
+ /**
111
+ * Try to load the order
112
+ */
113
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
114
+ if (!$order->getId()) {
115
+ $this->_getSession()->addError($this->__('Order %s does not exist', $orderId));
116
+ continue;
117
+ }
118
+
119
+ /**
120
+ * Try to create a shipment
121
+ */
122
+ $shipmentId = $this->_createShipment($order, $trackingNumber, $trackingTitle, $sendEmail, $comment, $includeComment);
123
+
124
+ if ($shipmentId != 0) {
125
+ $this->_getSession()->addSuccess($this->__('Shipment %s created for order %s, with tracking number %s', $shipmentId, $orderId, $trackingNumber));
126
+ }
127
+
128
+ }//foreach
129
+
130
+ }
131
+
132
+ /**
133
+ * Create new shipment for order
134
+ * Inspired by Mage_Sales_Model_Order_Shipment_Api methods
135
+ *
136
+ * @param Mage_Sales_Model_Order $order (it should exist, no control is done into the method)
137
+ * @param string $trackingNumber
138
+ * @param string $trackingTitle
139
+ * @param booleam $email
140
+ * @param string $comment
141
+ * @param boolean $includeComment
142
+ * @return int : shipment real id if creation was ok, else 0
143
+ */
144
+ public function _createShipment($order, $trackingNumber, $trackingTitle, $email, $comment, $includeComment)
145
+ {
146
+ /**
147
+ * Check shipment creation availability
148
+ */
149
+ if (!$order->canShip()) {
150
+ $this->_getSession()->addError($this->__('Order %s can not be shipped or has already been shipped', $order->getRealOrderId()));
151
+ return 0;
152
+ }
153
+
154
+ /**
155
+ * Initialize the Mage_Sales_Model_Order_Shipment object
156
+ */
157
+ $convertor = Mage::getModel('sales/convert_order');
158
+ $shipment = $convertor->toShipment($order);
159
+
160
+ /**
161
+ * Add the items to send
162
+ */
163
+ foreach ($order->getAllItems() as $orderItem) {
164
+ if (!$orderItem->getQtyToShip()) {
165
+ continue;
166
+ }
167
+ if ($orderItem->getIsVirtual()) {
168
+ continue;
169
+ }
170
+
171
+ $item = $convertor->itemToShipmentItem($orderItem);
172
+ $qty = $orderItem->getQtyToShip();
173
+ $item->setQty($qty);
174
+
175
+ $shipment->addItem($item);
176
+ }//foreach
177
+
178
+ $shipment->register();
179
+
180
+ /**
181
+ * Tracking number instanciation
182
+ */
183
+
184
+ $_shippingMethod = explode("_",$order->getShippingMethod());
185
+ switch($_shippingMethod[0]) {
186
+ case "chronopost":
187
+ case "chronorelais":
188
+ case "chronoexpress":
189
+ $carrier_code = $_shippingMethod[0];
190
+ $popup = 1;
191
+ /*$hash = Mage::helper('core')->urlEncode("order_id:{$order->getId()}:{$order->getProtectCode()}");
192
+ $tracking_url = Mage::getBaseUrl().'chronorelais/relais/tracking/hash/'.$hash.'/';*/
193
+ $tracking_url = str_replace('{tracking_number}', $trackingNumber, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
194
+ $tracking_title = $this->__('Track Your Order');
195
+ $tracking_order = '<p><a title="'.$tracking_title.'" href="'.$tracking_url.'"><b>'.$tracking_title.'</b></a></p>';
196
+ break;
197
+ default:
198
+ $carrier_code = 'custom';
199
+ $popup = 0;
200
+ $tracking_order = '';
201
+ break;
202
+ }
203
+
204
+ $track = Mage::getModel('sales/order_shipment_track')
205
+ ->setNumber($trackingNumber) //setTrackingNumber ?
206
+ ->setCarrierCode($carrier_code)
207
+ ->setTitle($trackingTitle)
208
+ ->setPopup($popup);
209
+ $shipment->addTrack($track);
210
+
211
+ /**
212
+ * Comment handling
213
+ */
214
+ $shipment->addComment($comment, $email && $includeComment);
215
+
216
+ /**
217
+ * Change order status to Processing
218
+ */
219
+ $shipment->getOrder()->setIsInProcess(true);
220
+
221
+ /**
222
+ * If e-mail, set as sent (must be done before shipment object saving)
223
+ */
224
+ if ($email) {
225
+ $shipment->setEmailSent(true);
226
+ }
227
+
228
+ try {
229
+ /**
230
+ * Save the created shipment and the updated order
231
+ */
232
+ $shipment->save();
233
+ $shipment->getOrder()->save();
234
+
235
+ /**
236
+ * Email sending
237
+ */
238
+ $shipment->sendEmail($email, ($includeComment ? $tracking_order.$comment : $tracking_order));
239
+ } catch (Mage_Core_Exception $e) {
240
+ $this->_getSession()->addError($this->__('Shipment creation error for Order %s : %s', $orderId, $e->getMessage()));
241
+ return 0;
242
+ }
243
+
244
+ /**
245
+ * Everything was ok : return Shipment real id
246
+ */
247
+ return $shipment->getIncrementId();
248
+ }
249
  }
app/code/community/Chronopost/Chronorelais/controllers/Sales/BordereauController.php ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';
4
+
5
+ class Chronopost_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
+ $nbTotal = 0;
68
+
69
+ $maxAmount = $helper->getMaxAdValoremAmount();
70
+ $adValoremAmount = $helper->assuranceAdValoremAmount();
71
+ $adValoremEnabled = $helper->assuranceAdValoremEnabled();
72
+ $totalAdValorem = 0;
73
+
74
+ foreach($items as $item) {
75
+ $weightTotal += $item->getWeight() * $item->getQty();
76
+ $totalAdValorem += $item->getPrice() * $item->getQty();
77
+ /*$price = min($item->getPrice(),$maxAmount);
78
+ if($price <= $maxAmount) {
79
+ $totalAdValorem += $price * $item->getQty();
80
+ }*/
81
+ }
82
+ /* Si montant < au montant minimum ad valorem => pas d'assurance */
83
+ $totalAdValorem = 0;
84
+ if($adValoremEnabled)
85
+ {
86
+ $totalAdValorem = min($totalAdValorem,$maxAmount);
87
+ if($totalAdValorem < $adValoremAmount) $totalAdValorem = 0;
88
+ }
89
+
90
+ /* Shipping address */
91
+ $address = Mage::getModel('sales/order_address')->load($shipment->getShippingAddressId());
92
+ if($address->getCountryId() == 'FR') {
93
+ $weightNational += $weightTotal;
94
+ $nbNational++;
95
+ }
96
+ else {
97
+ $weightInternational += $weightTotal;
98
+ $nbInternational++;
99
+ }
100
+
101
+ $detail[] = array(
102
+ 'trackNumber' => $trackNumber,
103
+ 'weight' => $weightTotal,
104
+ 'product_code' => $productCode,
105
+ 'postcode' => $address->getPostcode(),
106
+ 'country' => $address->getCountryId(),
107
+ 'assurance' => $totalAdValorem,
108
+ 'city' => Mage::helper('core/string')->truncate($address->getCity(),17),
109
+ );
110
+ }
111
+ }
112
+ $resume = array(
113
+ 'NATIONAL' => array('unite' => $nbNational, 'poids' => $weightNational),
114
+ 'INTERNATIONAL' => array('unite' => $nbInternational, 'poids' => $weightInternational),
115
+ 'TOTAL' => array('unite' => ($nbNational+$nbInternational), 'poids' => ($weightNational+$weightInternational)),
116
+ );
117
+
118
+ /* Create pdf */
119
+ $fileName = 'bordereau.pdf';
120
+ $content = $this->getPdfFile($shipper,$detail,$resume);
121
+ $this->_prepareDownloadResponse($fileName, $content);
122
+
123
+ } catch (Mage_Core_Exception $e) {
124
+ $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'));
125
+ }
126
+ }
127
+
128
+ protected function getPdfFile($shipper,$detail,$resume) {
129
+ $pdf = new Zend_Pdf();
130
+ $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
131
+
132
+ $helper = Mage::helper('chronorelais');
133
+ $weightUnit = $helper->getConfigWeightUnit();
134
+
135
+ $minYPosToChangePage = 60;
136
+ $xPos = 20;
137
+ $yPos = $page->getHeight()-20;
138
+ $lineHeight = 15;
139
+
140
+ $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
141
+ $fontBold = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
142
+
143
+ /* DATE */
144
+ $page->setFont($font, 11);
145
+ $page->drawText('date : '.date('d/m/Y'), $page->getWidth()-100, $yPos);
146
+ $yPos -= ($lineHeight);
147
+ $page->setFont($font, 12);
148
+
149
+ /* TITRE */
150
+ $page->setFont($fontBold, 12);
151
+ $page->drawText('BORDEREAU RECAPITULATIF', $xPos, $yPos);
152
+ $yPos -= ($lineHeight+20);
153
+ $page->setFont($font, 12);
154
+
155
+
156
+ /* EMETTEUR */
157
+ $page->setFont($fontBold, 12);
158
+ $page->drawText('EMETTEUR: ', $xPos, $yPos);
159
+ $yPos -= ($lineHeight+5);
160
+ $page->setFont($font, 12);
161
+
162
+ $page->drawText('NUMERO DE COMPTE', $xPos, $yPos);
163
+ $page->drawText($shipper['accountNumber'], $xPos+150, $yPos);
164
+ $yPos -= $lineHeight;
165
+
166
+ $page->drawText('NOM', $xPos, $yPos);
167
+ $page->drawText($shipper['name'], $xPos+150, $yPos);
168
+ $yPos -= $lineHeight;
169
+
170
+ $page->drawText('ADRESSE', $xPos, $yPos);
171
+ $page->drawText($shipper['address1'], $xPos+150, $yPos);
172
+ $yPos -= $lineHeight;
173
+
174
+ $page->drawText('ADRESSE (SUITE)', $xPos, $yPos);
175
+ $page->drawText($shipper['address2'], $xPos+150, $yPos);
176
+ $yPos -= $lineHeight;
177
+
178
+ $page->drawText('VILLE', $xPos, $yPos);
179
+ $page->drawText($shipper['city'], $xPos+150, $yPos);
180
+ $yPos -= $lineHeight;
181
+
182
+ $page->drawText('CODE POSTAL', $xPos, $yPos);
183
+ $page->drawText($shipper['postcode'], $xPos+150, $yPos);
184
+ $yPos -= $lineHeight;
185
+
186
+ $page->drawText('PAYS', $xPos, $yPos);
187
+ $page->drawText($shipper['country'], $xPos+150, $yPos);
188
+ $yPos -= $lineHeight;
189
+
190
+ $page->drawText('TELEPHONE', $xPos, $yPos);
191
+ $page->drawText($shipper['phone'], $xPos+150, $yPos);
192
+ $yPos -= $lineHeight;
193
+
194
+ $page->drawText('POSTE COMPTABLE', $xPos, $yPos);
195
+ $page->drawText(substr($shipper['postcode'],0,2).'999', $xPos+150, $yPos);
196
+ $yPos -= $lineHeight;
197
+
198
+ /* DETAIL DES ENVOIS */
199
+ $yPos -= 50;
200
+ $page->setFont($fontBold, 12);
201
+ $page->drawText('DETAIL DES ENVOIS ', $xPos, $yPos);
202
+ $yPos -= ($lineHeight+5);
203
+ $page->setFont($font, 12);
204
+
205
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(0.85, 0.85, 0.85));
206
+ $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
207
+ $page->setLineWidth(0.5);
208
+ $page->drawRectangle($xPos, $yPos, 570, $yPos -20);
209
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
210
+ $yPos -= 15;
211
+
212
+ $page->drawText("Numéro de LT", $xPos+5, $yPos,'UTF-8');
213
+ $page->drawText('Poids (kg)', $xPos+110, $yPos);
214
+ $page->drawText('Code produit', $xPos+170, $yPos);
215
+ $page->drawText('Code postal', $xPos+270, $yPos);
216
+ $page->drawText('Pays', $xPos+340, $yPos);
217
+ $page->drawText('Assurance', $xPos+380, $yPos);
218
+ $page->drawText('Ville', $xPos+440, $yPos);
219
+ $yPos -= 5;
220
+
221
+ foreach($detail as $line) {
222
+
223
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(255, 255, 255));
224
+ $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
225
+ $page->setLineWidth(0.5);
226
+ $page->drawRectangle($xPos, $yPos, 570, $yPos -20);
227
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
228
+ $yPos -= 15;
229
+
230
+ $lineWeight = $line['weight'];
231
+ if($weightUnit == 'g') {
232
+ $lineWeight = $lineWeight / 1000;
233
+ }
234
+
235
+ $page->drawText($line['trackNumber'], $xPos+5, $yPos,'UTF-8');
236
+ $page->drawText($lineWeight, $xPos+110, $yPos);
237
+ $page->drawText($line['product_code'], $xPos+170, $yPos);
238
+ $page->drawText($line['postcode'], $xPos+270, $yPos);
239
+ $page->drawText($line['country'], $xPos+340, $yPos);
240
+ $page->drawText($line['assurance'], $xPos+380, $yPos);
241
+ $page->drawText($line['city'], $xPos+440, $yPos,'UTF-8');
242
+ $yPos -= 5;
243
+
244
+ if($yPos <= $minYPosToChangePage) {
245
+ $pdf->pages[] = $page;
246
+ $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
247
+ $yPos = $page->getHeight()-20;
248
+ }
249
+ }
250
+
251
+ /* RESUME */
252
+ $yPos -= 50;
253
+ $page->setFont($fontBold, 12);
254
+ $page->drawText('RESUME ', $xPos, $yPos);
255
+ $yPos -= ($lineHeight+5);
256
+ $page->setFont($font, 12);
257
+
258
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(0.85, 0.85, 0.85));
259
+ $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
260
+ $page->setLineWidth(0.5);
261
+ $page->drawRectangle($xPos, $yPos, 570, $yPos -20);
262
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
263
+ $yPos -= 15;
264
+
265
+ $page->drawText("DESTINATION", $xPos+5, $yPos,'UTF-8');
266
+ $page->drawText('UNITE', $xPos+170, $yPos);
267
+ $page->drawText('POIDS TOTAL (kg)', $xPos+320, $yPos);
268
+ $yPos -= 5;
269
+
270
+ foreach($resume as $destination => $line) {
271
+
272
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(255, 255, 255));
273
+ $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
274
+ $page->setLineWidth(0.5);
275
+ $page->drawRectangle($xPos, $yPos, 570, $yPos -20);
276
+ $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
277
+ $yPos -= 15;
278
+
279
+ $lineWeight = $line['poids'];
280
+ if($weightUnit == 'g') {
281
+ $lineWeight = $lineWeight / 1000;
282
+ }
283
+
284
+ $page->drawText($destination, $xPos+5, $yPos,'UTF-8');
285
+ $page->drawText($line['unite'], $xPos+180, $yPos);
286
+ $page->drawText($lineWeight, $xPos+340, $yPos);
287
+ $yPos -= 5;
288
+ }
289
+
290
+ if($yPos <= $minYPosToChangePage) {
291
+ $pdf->pages[] = $page;
292
+ $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
293
+ $yPos = $page->getHeight()-20;
294
+ }
295
+
296
+ $yPos -= 50;
297
+ $page->setFont($fontBold, 12);
298
+ $page->drawText('Bien pris en charge '.$resume['TOTAL']['unite'].' colis', $xPos, $yPos);
299
+
300
+ if($yPos <= $minYPosToChangePage) {
301
+ $pdf->pages[] = $page;
302
+ $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
303
+ $yPos = $page->getHeight()-20;
304
+ }
305
+
306
+ /* signatures */
307
+ $yPos -= 60;
308
+ $page->setFont($font, 12);
309
+ $page->drawText('Signature du client', $xPos, $yPos);
310
+ $page->drawText('Signature du Messager Chronopost', 400, $yPos);
311
+
312
+
313
+
314
+ $pdf->pages[] = $page;
315
+ return $pdf->render();
316
+ }
317
+
318
+
319
+ protected function getTrackingNumber($shipmentId) {
320
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
321
+ $trackNumber = '';
322
+ //On récupère le numéro de tracking
323
+ $tracks = $shipment->getTracksCollection();
324
+ foreach ($tracks as $track) {
325
+ if ($track->getParentId() == $shipmentId) {
326
+ $trackNumber = $track->getnumber();
327
+ }
328
+ }
329
+
330
+ return $trackNumber;
331
+ }
332
+ }
app/code/community/Chronopost/Chronorelais/controllers/Sales/ImpressionController.php CHANGED
@@ -1,567 +1,1027 @@
1
- <?php
2
-
3
- require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
4
-
5
- class Chronopost_Chronorelais_Sales_ImpressionController extends Mage_Adminhtml_Sales_Order_ShipmentController {
6
-
7
- protected $_trackingNumbers = '';
8
-
9
- /**
10
- * Additional initialization
11
- *
12
- */
13
- protected function _construct() {
14
- $this->setUsedModuleName('Chronopost_Chronorelais');
15
- }
16
-
17
- /**
18
- * Shipping grid
19
- */
20
- public function indexAction() {
21
- if (!extension_loaded('soap')) {
22
- $this->_getSession()->addError($this->__('The SOAP extension is not installed in the server. Please contact the site administrator. Sorry for inconvenience.'));
23
- return $this->_redirectReferer();
24
- }
25
- $this->loadLayout()
26
- ->_setActiveMenu('sales/chronorelais')
27
- ->_addContent($this->getLayout()->createBlock('chronorelais/sales_impression'))
28
- ->renderLayout();
29
- }
30
-
31
- /**
32
- * Save shipment and order in one transaction
33
- * @param Mage_Sales_Model_Order_Shipment $shipment
34
- */
35
- protected function _saveShipment($shipment) {
36
- $shipment->getOrder()->setIsInProcess(true);
37
- $transactionSave = Mage::getModel('core/resource_transaction')
38
- ->addObject($shipment)
39
- ->addObject($shipment->getOrder())
40
- ->save();
41
-
42
- return $this;
43
- }
44
-
45
- protected function _processDownload($resource, $resourceType) {
46
- $helper = Mage::helper('downloadable/download');
47
- /* @var $helper Mage_Downloadable_Helper_Download */
48
-
49
- $helper->setResource($resource, $resourceType);
50
-
51
- $fileName = $helper->getFilename();
52
- $contentType = $helper->getContentType();
53
-
54
- $this->getResponse()
55
- ->setHttpResponseCode(200)
56
- ->setHeader('Pragma', 'public', true)
57
- ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
58
- ->setHeader('Content-type', $contentType, true);
59
-
60
- if ($fileSize = $helper->getFilesize()) {
61
- $this->getResponse()
62
- ->setHeader('Content-Length', $fileSize);
63
- }
64
-
65
- if ($contentDisposition = $helper->getContentDisposition()) {
66
- $this->getResponse()
67
- ->setHeader('Content-Disposition', $contentDisposition . '; filename=' . $fileName);
68
- }
69
-
70
- $this->getResponse()
71
- ->clearBody();
72
- $this->getResponse()
73
- ->sendHeaders();
74
-
75
- $helper->output();
76
- }
77
-
78
- protected function getTrackingNumber($shipmentId) {
79
- $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
80
-
81
- //On récupère le numéro de tracking
82
- $tracks = $shipment->getTracksCollection();
83
- foreach ($tracks as $track) {
84
- if ($track->getParentId() == $shipmentId) {
85
- $this->_trackingNumbers .= $track->getnumber();
86
- }
87
- }
88
-
89
- return $this->_trackingNumbers;
90
- }
91
-
92
- protected function getFilledValue($value) {
93
- if ($value) {
94
- return $this->removeaccents(trim($value));
95
- } else {
96
- return '';
97
- }
98
- }
99
-
100
- protected function checkMobileNumber($value) {
101
- if ($reqvalue = trim($value)) {
102
- $_number = substr($reqvalue, 0, 2);
103
- $fixed_array = array('01', '02', '03', '04', '05', '06', '06');
104
- if (in_array($_number, $fixed_array)) {
105
- return $reqvalue;
106
- } else {
107
- return '';
108
- }
109
- }
110
- }
111
-
112
- protected function getExpeditionParams($shipment, $_shippingMethod) {
113
- $_order = $shipment->getOrder();
114
- $_shippingAddress = $shipment->getShippingAddress();
115
- $_billingAddress = $shipment->getBillingAddress();
116
- $_helper = Mage::helper('chronorelais');
117
-
118
- if ($_shippingMethod[0] == 'chronorelais' || $_shippingMethod[0] == 'chronopost' || $_shippingMethod[0] == 'chronoexpress') {
119
- $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
120
-
121
- //esdParams parameters
122
- $esdParams = array(
123
- 'height' => '',
124
- 'width' => '',
125
- 'length' => ''
126
- );
127
-
128
- //header parameters
129
- $header = array(
130
- 'idEmit' => 'CHRFR',
131
- 'accountNumber' => $_helper->getConfigurationAccountNumber(),
132
- 'subAccount' => $_helper->getConfigurationSubAccountNumber()
133
- );
134
-
135
- //shipper parameters
136
- $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
137
- $shipper = array(
138
- 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
139
- 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
140
- 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
141
- 'shipperCivility' => $_helper->getConfigurationShipperInfo('civility'),
142
- 'shipperContactName' => $_helper->getConfigurationShipperInfo('contactname'),
143
- 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
144
- 'shipperEmail' => $_helper->getConfigurationShipperInfo('email'),
145
- 'shipperMobilePhone' => $shipperMobilePhone,
146
- 'shipperName' => $_helper->getConfigurationShipperInfo('name'),
147
- 'shipperName2' => $_helper->getConfigurationShipperInfo('name2'),
148
- 'shipperPhone' => $_helper->getConfigurationShipperInfo('phone'),
149
- 'shipperPreAlert' => '',
150
- 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
151
- );
152
-
153
- //customer parameters
154
- $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
155
- $customer = array(
156
- 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
157
- 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
158
- 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
159
- 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
160
- 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
161
- 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
162
- 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
163
- 'customerMobilePhone' => $customerMobilePhone,
164
- 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
165
- 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
166
- 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
167
- 'customerPreAlert' => '',
168
- 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
169
- );
170
-
171
- //recipient parameters
172
- $recipient_address = $_shippingAddress->getStreet();
173
- if (!isset($recipient_address[1])) {
174
- $recipient_address[1] = '';
175
- }
176
- $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
177
- $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
178
- $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
179
- $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
180
- //remove any alphabets in phone number
181
- $recipientPhone = trim(ereg_replace("[^0-9.-]", " ", $_shippingAddress->getTelephone()));
182
-
183
- $recipient = array(
184
- 'recipientAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
185
- 'recipientAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
186
- 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
187
- 'recipientContactName' => $recipientName2,
188
- 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
189
- 'recipientEmail' => $customer_email,
190
- 'recipientMobilePhone' => $recipientMobilePhone,
191
- 'recipientName' => $recipientName,
192
- 'recipientName2' => $recipientName2,
193
- 'recipientPhone' => $recipientPhone,
194
- 'recipientPreAlert' => '',
195
- 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
196
- );
197
-
198
- //ref parameters
199
- $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
200
- if (!$recipientRef) {
201
- $recipientRef = $_order->getCustomerId();
202
- }
203
- $shipperRef = $_order->getRealOrderId();
204
-
205
- $ref = array(
206
- 'recipientRef' => $recipientRef,
207
- 'shipperRef' => $shipperRef
208
- );
209
-
210
- //skybill parameters
211
- /* Livraison Samedi (Delivery Saturday) field */
212
- $SaturdayShipping = 0; //default value for the saturday shipping
213
- $send_day = strtolower(date('l'));
214
- if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
215
- if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
216
- $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
217
- } else {
218
- if ($_deliver_on_saturday == 'Yes') {
219
- $_deliver_on_saturday = 1;
220
- } else {
221
- $_deliver_on_saturday = 0;
222
- }
223
- }
224
- $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
225
- if ($_deliver_on_saturday && $is_sending_day) {
226
- $SaturdayShipping = 6;
227
- } elseif (!$_deliver_on_saturday && $is_sending_day) {
228
- $SaturdayShipping = 1;
229
- }
230
- }
231
-
232
- $weight = 0;
233
- foreach ($shipment->getItemsCollection() as $item) {
234
- $weight += $item->weight * $item->qty;
235
- }
236
-
237
- $skybill = array(
238
- 'codCurrency' => 'EUR',
239
- 'codValue' => '',
240
- 'content1' => '',
241
- 'content2' => '',
242
- 'content3' => '',
243
- 'content4' => '',
244
- 'content5' => '',
245
- 'customsCurrency' => 'EUR',
246
- 'customsValue' => '',
247
- 'evtCode' => 'DC',
248
- 'insuredCurrency' => 'EUR',
249
- 'insuredValue' => '',
250
- 'objectType' => 'MAR',
251
- 'productCode' => $_helper->getChronoProductCode($_shippingAddress->getCountryId(), $_shippingMethod[0]),
252
- 'service' => $SaturdayShipping,
253
- 'shipDate' => date('c'),
254
- 'shipHour' => date('H'),
255
- 'weight' => $weight,
256
- 'weightUnit' => 'KGM'
257
- );
258
-
259
- $skybillParams = array(
260
- 'mode' => $_helper->getConfigurationSkybillParam()
261
- );
262
-
263
- $expeditionArray = array(
264
- 'esdParams' => $esdParams,
265
- 'header' => $header,
266
- 'shipper' => $shipper,
267
- 'customer' => $customer,
268
- 'recipient' => $recipient,
269
- 'ref' => $ref,
270
- 'skybill' => $skybill,
271
- 'skybillParams' => $skybillParams,
272
- 'password' => $_helper->getConfigurationAccountPass(),
273
- 'option' => '0'
274
- );
275
- //printArray($expeditionArray); exit;
276
- return $expeditionArray;
277
- }
278
- }
279
-
280
- protected function getEtiquetteUrl($shipmentId) {
281
- //On récupère les infos d'expédition
282
- $reservationNumber = '';
283
- $_helper = Mage::helper('chronorelais');
284
-
285
- $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
286
- if ($_shipTracks = $shipment->getAllTracks()) {
287
- foreach ($_shipTracks as $_shipTrack) {
288
- if ($_shipTrack->getNumber() && $_shipTrack->getChronoReservationNumber()) {
289
- $reservationNumber = $_shipTrack->getChronoReservationNumber();
290
- break;
291
- }
292
- }
293
- if ($reservationNumber) {
294
- return $reservationNumber;
295
- }
296
- }
297
-
298
- $_order = $shipment->getOrder();
299
- $_shippingMethod = explode("_", $_order->getShippingMethod());
300
-
301
- $expeditionArray = $this->getExpeditionParams($shipment, $_shippingMethod);
302
- $tracking_number = '';
303
- if ($expeditionArray) {
304
- $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
305
- try {
306
- $webservbt = $client->__call("reservationExpeditionV2", $expeditionArray);
307
- if (!$webservbt->errorCode && $webservbt->reservationNumber) {
308
- $tracking_number = $webservbt->skybillNumber;
309
- // Add tracking number for the shipment if not already exists.
310
- if (!$this->_trackingNumbers && $webservbt->skybillNumber) {
311
- $track = Mage::getModel('sales/order_shipment_track')
312
- ->setNumber($webservbt->skybillNumber)
313
- ->setCarrier(ucwords($_shippingMethod[0]))
314
- ->setCarrierCode($_shippingMethod[0])
315
- ->setTitle(ucwords($_shippingMethod[0]))
316
- ->setChronoReservationNumber($webservbt->reservationNumber)
317
- ->setPopup(1);
318
- $shipment->addTrack($track);
319
-
320
- $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
321
- $tracking_title = $this->__('Track Your Order');
322
- $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
323
-
324
- //$shipment->register();
325
- $comment = '';
326
- $shipment->setEmailSent(true);
327
- $this->_saveShipment($shipment);
328
- $shipment->sendEmail(1, $tracking_order . $comment);
329
- }
330
- return $webservbt->reservationNumber;
331
- } else {
332
- $this->_getSession()->addError($_helper->__($webservbt->errorMessage));
333
- }
334
- } catch (SoapFault $fault) {
335
- $this->_getSession()->addError($_helper->__($fault->faultstring));
336
- }
337
- }
338
- }
339
-
340
- public function getShipmentByOrderId($orderId) {
341
- $_shipment = Mage::getResourceModel('sales/order_shipment_grid_collection')
342
- ->addAttributeToFilter('order_id', $orderId)
343
- ->getAllIds();
344
- return $_shipment;
345
- }
346
-
347
- public function getShipmentByIncrementId($incrementId) {
348
- $_shipment = Mage::getResourceModel('sales/order_shipment_grid_collection')
349
- ->addAttributeToFilter('increment_id', $incrementId)
350
- ->getAllIds();
351
- return $_shipment;
352
- }
353
-
354
- public function initShipment($orderId) {
355
- $order = Mage::getModel('sales/order')->load($orderId);
356
-
357
- /**
358
- * Check order existing
359
- */
360
- if (!$order->getId()) {
361
- $this->_getSession()->addError($this->__('The order no longer exists.'));
362
- return false;
363
- }
364
- /**
365
- * Check shipment is available to create separate from invoice
366
- */
367
- if ($order->getForcedDoShipmentWithInvoice()) {
368
- $this->_getSession()->addError($this->__('Cannot do shipment for the order separately from invoice.'));
369
- return false;
370
- }
371
- /**
372
- * Check shipment create availability
373
- */
374
- /* if (!$order->canShip()) {
375
- $this->_getSession()->addError($this->__('Cannot do shipment for the order.'));
376
- return false;
377
- } */
378
- $savedQtys = $this->_getItemQtys();
379
- $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($savedQtys);
380
-
381
- Mage::register('current_shipment', $shipment);
382
- return $shipment;
383
- }
384
-
385
- public function createNewShipment($orderId) {
386
- $_helper = Mage::helper('chronorelais');
387
- $reservationNumber = '';
388
- try {
389
- if ($shipment = $this->initShipment($orderId)) {
390
- $shipment->register();
391
-
392
- $_order = $shipment->getOrder();
393
- $_shippingMethod = explode("_", $_order->getShippingMethod());
394
-
395
- $expeditionArray = $this->getExpeditionParams($shipment, $_shippingMethod);
396
- $tracking_number = '';
397
- if ($expeditionArray) {
398
-
399
- $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
400
- try {
401
- $expedition = $client->__call("reservationExpeditionV2", $expeditionArray);
402
- if (!$expedition->errorCode && $expedition->skybillNumber) {
403
- $tracking_number = $expedition->skybillNumber;
404
- $track = Mage::getModel('sales/order_shipment_track')
405
- ->setNumber($expedition->skybillNumber)
406
- ->setCarrier(ucwords($_shippingMethod[0]))
407
- ->setCarrierCode($_shippingMethod[0])
408
- ->setTitle(ucwords($_shippingMethod[0]))
409
- ->setChronoReservationNumber($expedition->reservationNumber)
410
- ->setPopup(1);
411
- $shipment->addTrack($track);
412
- $reservationNumber = $expedition->reservationNumber;
413
- } else {
414
- $this->_getSession()->addError($_helper->__($expedition->errorMessage));
415
- return;
416
- }
417
- } catch (SoapFault $fault) {
418
- $this->_getSession()->addError($_helper->__($fault->faultstring));
419
- return;
420
- }
421
- }
422
-
423
- $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
424
- $tracking_title = $this->__('Track Your Order');
425
- $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
426
-
427
- $comment = '';
428
- $shipment->setEmailSent(true);
429
- $this->_saveShipment($shipment);
430
- $shipment->sendEmail(1, $tracking_order . $comment);
431
- $this->_getSession()->addSuccess($this->__('Shipment was successfully created.'));
432
- return $reservationNumber;
433
- } else {
434
- $this->_forward('noRoute');
435
- return;
436
- }
437
- } catch (Mage_Core_Exception $e) {
438
- $this->_getSession()->addError($e->getMessage());
439
- return;
440
- } catch (Exception $e) {
441
- $this->_getSession()->addError($this->__('Can not save shipment: ' . $e->getMessage()));
442
- return;
443
- }
444
- }
445
-
446
- public function printMassAction() {
447
- $shipmentsIds = $this->getRequest()->getPost('shipment_ids');
448
- try {
449
- $trackingNumber = $this->getEtiquetteUrl($shipmentsIds);
450
- if ($trackingNumber) {
451
- $tracking_url = str_replace('{trackingNumber}', $trackingNumber, Mage::helper('chronorelais')->getConfigurationTrackingUrl());
452
- $this->_processDownload($tracking_url, 'url');
453
- exit(0);
454
- }
455
- } catch (Mage_Core_Exception $e) {
456
- $this->_getSession()->addError(Mage::helper('chronorelais')->__('Désolé, une erreure est survenu lors de la récupération de l\'étiquetes. Merci de contacter Chronopost ou de réessayer plus tard'));
457
- }
458
- return $this->_redirectReferer();
459
- }
460
-
461
- public function printAction() {
462
- // Appel via order_id
463
- $orderId = $this->getRequest()->getParam('order_id');
464
- if ($orderId) {
465
- if ($_shipments = $this->getShipmentByOrderId($orderId)) {
466
- if (count($_shipments) == 1) {
467
- $shipmentId = $_shipments[0];
468
- $trackingNumber = $this->getEtiquetteUrl($shipmentId);
469
- } else {
470
- $track = "Cette commande contient plusieurs expéditions, cliquez sur chaque lien pour obtenir les étiquettes :<br>";
471
- foreach ($_shipments as $_shipment) {
472
- $url = str_replace('{trackingNumber}', $this->getEtiquetteUrl($_shipment), Mage::helper('chronorelais')->getConfigurationTrackingUrl());
473
- $track .= '<a target="_blank" href="'.$url.'">'.$url.'</a><br />';
474
- }
475
- echo $track;
476
- return;
477
- }
478
- } else {
479
- $trackingNumber = $this->createNewShipment($orderId);
480
- }
481
- } else {
482
- $shipmentId = $this->getRequest()->getParam('shipment_id');
483
- if ($shipmentId) {
484
- $trackingNumber = $this->getEtiquetteUrl($shipmentId);
485
- } else {
486
- $shipmentIncrementId = $this->getRequest()->getParam('shipment_increment_id');
487
- $shipmentId = $this->getShipmentByIncrementId($shipmentIncrementId);
488
- $trackingNumber = $this->getEtiquetteUrl($shipmentId[0]);
489
- }
490
- }
491
-
492
-
493
- if ($trackingNumber) {
494
- try {
495
- $tracking_url = str_replace('{trackingNumber}', $trackingNumber, Mage::helper('chronorelais')->getConfigurationTrackingUrl());
496
- $this->_processDownload($tracking_url, 'url');
497
- exit(0);
498
- } catch (Mage_Core_Exception $e) {
499
- $this->_getSession()->addError(Mage::helper('chronorelais')->__('Désolé, une erreure est survenu lors de la récupération de l\'étiquetes. Merci de contacter Chronopost ou de réessayer plus tard'));
500
- }
501
- }
502
- return $this->_redirectReferer();
503
- }
504
-
505
- public function massLivraisonSamediStatusAction() {
506
- if ($this->getRequest()->getPost('status')) {
507
- $this->saveLivraisonSamediStatusAction();
508
- }
509
- }
510
-
511
- /* Save the Livraison le Samedi status to orders */
512
-
513
- public function saveLivraisonSamediStatusAction() {
514
- /* get the orders */
515
- $orderIds = $this->getRequest()->getPost('order_ids');
516
- $status = $this->getRequest()->getPost('status');
517
- $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
518
- $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
519
- $exceptions = array();
520
-
521
- foreach ($orderIds as $orderId) {
522
- $order_details = Mage::getModel('sales/order')->load($orderId);
523
- $shipping_method = '';
524
- $livraison_le_samedi = $status;
525
- if ($shipping_method = $order_details->getShippingMethod()) {
526
- $shipping_method = explode('_', $shipping_method);
527
- if ($shipping_method[0] == 'chronoexpress') {
528
- $livraison_le_samedi = '--';
529
- }
530
- }
531
- $condition = array(
532
- $_connection->quoteInto('order_id = ?', $orderId),
533
- );
534
- $_connection->delete($_table, $condition);
535
-
536
- $dataLine = array(
537
- 'order_id' => $orderId,
538
- 'livraison_le_samedi' => $livraison_le_samedi
539
- );
540
- try {
541
- $_connection->insert($_table, $dataLine);
542
- } catch (Exception $e) {
543
- $exceptions[] = Mage::helper('chronorelais')->__('Order assigning error: ' . $e->getMessage());
544
- }
545
- }
546
- if ($exceptions) {
547
- $this->_getSession()->addError($exceptions);
548
- } else {
549
- $this->_getSession()->addSuccess($this->__('Livraison le Samedi statut a &eacute;t&eacute; ajout&eacute;'));
550
- }
551
- $this->_redirect('*/*/index');
552
- }
553
-
554
- /* Remove accents characters */
555
-
556
- public function removeaccents($string) {
557
- $stringToReturn = str_replace(
558
- 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);
559
- // Remove all remaining other unknown characters
560
- $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
561
- $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
562
- $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
563
- $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
564
- return $stringToReturn;
565
- }
566
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
567
  }
1
+ <?php
2
+
3
+ require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
4
+
5
+ class Chronopost_Chronorelais_Sales_ImpressionController extends Mage_Adminhtml_Sales_Order_ShipmentController {
6
+
7
+ protected $_trackingNumbers = '';
8
+
9
+ /**
10
+ * Additional initialization
11
+ *
12
+ */
13
+ protected function _construct() {
14
+ $this->setUsedModuleName('Chronopost_Chronorelais');
15
+ }
16
+
17
+ /**
18
+ * Shipping grid
19
+ */
20
+ public function indexAction() {
21
+ if (!extension_loaded('soap')) {
22
+ $this->_getSession()->addError($this->__('The SOAP extension is not installed in the server. Please contact the site administrator. Sorry for inconvenience.'));
23
+ return $this->_redirectReferer();
24
+ }
25
+ $cmdTestGs = Mage::helper('chronorelais')->getConfigData('chronorelais/shipping/gs_path');
26
+ if(shell_exec($cmdTestGs) === null) {
27
+ $this->_getSession()->addNotice($this->__('Please install %s on your server to print mass','<a href="http://www.ghostscript.com/download/" target="_blank">Ghostscript</a>'));
28
+ }
29
+ $this->loadLayout()
30
+ ->_setActiveMenu('sales/chronorelais')
31
+ ->_addContent($this->getLayout()->createBlock('chronorelais/sales_impression'))
32
+ ->renderLayout();
33
+ }
34
+
35
+ /**
36
+ * Save shipment and order in one transaction
37
+ * @param Mage_Sales_Model_Order_Shipment $shipment
38
+ */
39
+ protected function _saveShipment($shipment) {
40
+ $shipment->getOrder()->setIsInProcess(true);
41
+ $transactionSave = Mage::getModel('core/resource_transaction')
42
+ ->addObject($shipment)
43
+ ->addObject($shipment->getOrder())
44
+ ->save();
45
+
46
+ return $this;
47
+ }
48
+
49
+ /**
50
+ * Declare headers and content file in response for file download
51
+ *
52
+ * @param string $fileName
53
+ * @param string|array $content set to null to avoid starting output, $contentLength should be set explicitly in
54
+ * that case
55
+ * @param string $contentType
56
+ * @param int $contentLength explicit content length, if strlen($content) isn't applicable
57
+ * @return Mage_Core_Controller_Varien_Action
58
+ */
59
+ protected function _prepareDownloadResponse(
60
+ $fileName,
61
+ $content,
62
+ $contentType = 'application/octet-stream',
63
+ $contentLength = null)
64
+ {
65
+ $session = Mage::getSingleton('admin/session');
66
+ if ($session->isFirstPageAfterLogin()) {
67
+ $this->_redirect($session->getUser()->getStartupPageUrl());
68
+ return $this;
69
+ }
70
+
71
+ $isFile = false;
72
+ $file = null;
73
+ if (is_array($content)) {
74
+ if (!isset($content['type']) || !isset($content['value'])) {
75
+ return $this;
76
+ }
77
+ if ($content['type'] == 'filename') {
78
+ $isFile = true;
79
+ $file = $content['value'];
80
+ $contentLength = filesize($file);
81
+ }
82
+ }
83
+
84
+ $this->getResponse()
85
+ ->setHttpResponseCode(200)
86
+ ->setHeader('Pragma', 'public', true)
87
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
88
+ ->setHeader('Content-type', $contentType, true)
89
+ ->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength, true)
90
+ ->setHeader('Content-Disposition', 'attachment; filename="'.$fileName.'"', true)
91
+ ->setHeader('Last-Modified', date('r'), true);
92
+
93
+ if (!is_null($content)) {
94
+ if ($isFile) {
95
+ $this->getResponse()->clearBody();
96
+ $this->getResponse()->sendHeaders();
97
+
98
+ $ioAdapter = new Varien_Io_File();
99
+ $ioAdapter->open(array('path' => $ioAdapter->dirname($file)));
100
+ $ioAdapter->streamOpen($file, 'r');
101
+ while ($buffer = $ioAdapter->streamRead()) {
102
+ print $buffer;
103
+ }
104
+ $ioAdapter->streamClose();
105
+ if (!empty($content['rm'])) {
106
+ $ioAdapter->rm($file);
107
+ }
108
+
109
+ exit(0);
110
+ } else {
111
+ $this->getResponse()->setBody($content);
112
+ }
113
+ }
114
+ return $this;
115
+ }
116
+
117
+ protected function _processDownloadMass($urls) {
118
+
119
+ $helper = Mage::helper('downloadable/download');
120
+ $countUrl = count($urls);
121
+ $indice = 1;
122
+ $filesSize = 0;
123
+ $content = '';
124
+
125
+ $paths = array();
126
+
127
+ foreach ($urls as $url) {
128
+ $helper->setResource($url, 'url');
129
+ $fileName = $helper->getFilename();
130
+ $fileName = explode('reservationNumber=', $fileName);
131
+ $fileName = $fileName[1];
132
+ $filesSize = $helper->getFilesize();
133
+ $contentType = $helper->getContentType();
134
+
135
+ /* save pdf file */
136
+ $path = Mage::getBaseDir('media').'/chronopost/' . $fileName . '.pdf';
137
+ file_put_contents($path, file_get_contents($url));
138
+ $paths[] = $path;
139
+ }
140
+
141
+ /* creation d'un pdf unique */
142
+ $pdfMergeFileName = "merged-".date('YmdHis').".pdf";
143
+ $pathMerge = Mage::getBaseDir('media')."/chronopost/".$pdfMergeFileName;
144
+ $cmd = Mage::helper('chronorelais')->getConfigData('chronorelais/shipping/gs_path').' -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="'.$pathMerge.'" -dBATCH '. implode(' ', $paths);
145
+ $res_shell = shell_exec($cmd);
146
+
147
+ /* suppression des pdf temp */
148
+ foreach ($paths as $path) {
149
+ if(is_file($path)) {
150
+ unlink($path);
151
+ }
152
+ }
153
+
154
+ if ($res_shell === null) {
155
+ return $this->_redirectReferer();
156
+ }
157
+ else {
158
+ $this->_prepareDownloadResponse($pdfMergeFileName,array(
159
+ 'type' => 'filename',
160
+ 'value' => $pathMerge
161
+ ));
162
+ unlink($pathMerge);
163
+ }
164
+ }
165
+
166
+ protected function getTrackingNumber($shipmentId) {
167
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
168
+
169
+ //On récupère le numéro de tracking
170
+ $tracks = $shipment->getTracksCollection();
171
+ foreach ($tracks as $track) {
172
+ if ($track->getParentId() == $shipmentId) {
173
+ $this->_trackingNumbers .= $track->getnumber();
174
+ }
175
+ }
176
+
177
+ return $this->_trackingNumbers;
178
+ }
179
+
180
+ protected function getFilledValue($value) {
181
+ if ($value) {
182
+ return $this->removeaccents(trim($value));
183
+ } else {
184
+ return '';
185
+ }
186
+ }
187
+
188
+ protected function checkMobileNumber($value) {
189
+ if ($reqvalue = trim($value)) {
190
+ $_number = substr($reqvalue, 0, 2);
191
+ $fixed_array = array('01', '02', '03', '04', '05', '06', '06');
192
+ if (in_array($_number, $fixed_array)) {
193
+ return $reqvalue;
194
+ } else {
195
+ return '';
196
+ }
197
+ }
198
+ }
199
+
200
+ protected function getExpeditionParams($shipment, $_shippingMethod) {
201
+ $_order = $shipment->getOrder();
202
+ $_shippingAddress = $shipment->getShippingAddress();
203
+ $_billingAddress = $shipment->getBillingAddress();
204
+ $_helper = Mage::helper('chronorelais');
205
+
206
+ $shippingMethodAllow = array('chronorelais','chronopost','chronoexpress','chronopostc10','chronopostc18','chronopostcclassic');
207
+ if (in_array($_shippingMethod[0],$shippingMethodAllow)) {
208
+ $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
209
+
210
+ //esdParams parameters
211
+ $esdParams = array(
212
+ 'height' => '',
213
+ 'width' => '',
214
+ 'length' => ''
215
+ );
216
+
217
+ //header parameters
218
+ $header = array(
219
+ 'idEmit' => 'CHRFR',
220
+ 'accountNumber' => $_helper->getConfigurationAccountNumber(),
221
+ 'subAccount' => $_helper->getConfigurationSubAccountNumber()
222
+ );
223
+
224
+ //shipper parameters
225
+ $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
226
+ $shipper = array(
227
+ 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
228
+ 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
229
+ 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
230
+ 'shipperCivility' => $_helper->getConfigurationShipperInfo('civility'),
231
+ 'shipperContactName' => $_helper->getConfigurationShipperInfo('contactname'),
232
+ 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
233
+ 'shipperEmail' => $_helper->getConfigurationShipperInfo('email'),
234
+ 'shipperMobilePhone' => $shipperMobilePhone,
235
+ 'shipperName' => $_helper->getConfigurationShipperInfo('name'),
236
+ 'shipperName2' => $_helper->getConfigurationShipperInfo('name2'),
237
+ 'shipperPhone' => $_helper->getConfigurationShipperInfo('phone'),
238
+ 'shipperPreAlert' => '',
239
+ 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
240
+ );
241
+
242
+ //customer parameters
243
+ $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
244
+ $customer = array(
245
+ 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
246
+ 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
247
+ 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
248
+ 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
249
+ 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
250
+ 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
251
+ 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
252
+ 'customerMobilePhone' => $customerMobilePhone,
253
+ 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
254
+ 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
255
+ 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
256
+ 'customerPreAlert' => '',
257
+ 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
258
+ );
259
+
260
+ //recipient parameters
261
+ $recipient_address = $_shippingAddress->getStreet();
262
+ if (!isset($recipient_address[1])) {
263
+ $recipient_address[1] = '';
264
+ }
265
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
266
+ $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
267
+ $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
268
+ $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
269
+ //remove any alphabets in phone number
270
+ $recipientPhone = trim(ereg_replace("[^0-9.-]", " ", $_shippingAddress->getTelephone()));
271
+
272
+ $recipient = array(
273
+ 'recipientAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
274
+ 'recipientAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
275
+ 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
276
+ 'recipientContactName' => $recipientName2,
277
+ 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
278
+ 'recipientEmail' => $customer_email,
279
+ 'recipientMobilePhone' => $recipientMobilePhone,
280
+ 'recipientName' => $recipientName,
281
+ 'recipientName2' => $recipientName2,
282
+ 'recipientPhone' => $recipientPhone,
283
+ 'recipientPreAlert' => '',
284
+ 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
285
+ );
286
+
287
+ //ref parameters
288
+ $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
289
+ if (!$recipientRef) {
290
+ $recipientRef = $_order->getCustomerId();
291
+ }
292
+ $shipperRef = $_order->getRealOrderId();
293
+
294
+ $ref = array(
295
+ 'recipientRef' => $recipientRef,
296
+ 'shipperRef' => $shipperRef
297
+ );
298
+
299
+ //skybill parameters
300
+ /* Livraison Samedi (Delivery Saturday) field */
301
+ $SaturdayShipping = 0; //default value for the saturday shipping
302
+ $send_day = strtolower(date('l'));
303
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
304
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
305
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
306
+ } else {
307
+ if ($_deliver_on_saturday == 'Yes') {
308
+ $_deliver_on_saturday = 1;
309
+ } else {
310
+ $_deliver_on_saturday = 0;
311
+ }
312
+ }
313
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
314
+ if ($_deliver_on_saturday && $is_sending_day) {
315
+ $SaturdayShipping = 6;
316
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
317
+ $SaturdayShipping = 1;
318
+ }
319
+ }
320
+
321
+ $weight = 0;
322
+ foreach ($shipment->getItemsCollection() as $item) {
323
+ $weight += $item->weight * $item->qty;
324
+ }
325
+ if ($_helper->getConfigWeightUnit() == 'g') {
326
+ $weight = $weight / 1000; /* conversion g => kg */
327
+ }
328
+ $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
329
+
330
+ $skybill = array(
331
+ 'codCurrency' => 'EUR',
332
+ 'codValue' => '',
333
+ 'content1' => '',
334
+ 'content2' => '',
335
+ 'content3' => '',
336
+ 'content4' => '',
337
+ 'content5' => '',
338
+ 'customsCurrency' => 'EUR',
339
+ 'customsValue' => '',
340
+ 'evtCode' => 'DC',
341
+ 'insuredCurrency' => 'EUR',
342
+ 'insuredValue' => '',
343
+ 'objectType' => 'MAR',
344
+ 'productCode' => $_helper->getChronoProductCodeToShipment($_shippingMethod[0]),
345
+ 'service' => $SaturdayShipping,
346
+ 'shipDate' => date('c'),
347
+ 'shipHour' => date('H'),
348
+ 'weight' => $weight,
349
+ 'weightUnit' => 'KGM'
350
+ );
351
+
352
+ $skybillParams = array(
353
+ 'mode' => $_helper->getConfigurationSkybillParam()
354
+ );
355
+
356
+ $expeditionArray = array(
357
+ 'esdParams' => $esdParams,
358
+ 'header' => $header,
359
+ 'shipper' => $shipper,
360
+ 'customer' => $customer,
361
+ 'recipient' => $recipient,
362
+ 'ref' => $ref,
363
+ 'skybill' => $skybill,
364
+ 'skybillParams' => $skybillParams,
365
+ 'password' => $_helper->getConfigurationAccountPass(),
366
+ 'option' => '0'
367
+ );
368
+ //printArray($expeditionArray); exit;
369
+ return $expeditionArray;
370
+ }
371
+ }
372
+
373
+ protected function getEtiquetteUrl($shipmentId) {
374
+ //On récupère les infos d'expédition
375
+ $reservationNumber = '';
376
+ $_helper = Mage::helper('chronorelais');
377
+
378
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
379
+ if ($_shipTracks = $shipment->getAllTracks()) {
380
+ foreach ($_shipTracks as $_shipTrack) {
381
+ if ($_shipTrack->getNumber() && $_shipTrack->getChronoReservationNumber()) {
382
+ $reservationNumber = $_shipTrack->getChronoReservationNumber();
383
+ break;
384
+ }
385
+ }
386
+ if ($reservationNumber) {
387
+ return $reservationNumber;
388
+ }
389
+ }
390
+
391
+ $_order = $shipment->getOrder();
392
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
393
+
394
+ $expeditionArray = $this->getExpeditionParams($shipment, $_shippingMethod);
395
+ $tracking_number = '';
396
+ if ($expeditionArray) {
397
+ $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
398
+ try {
399
+ $webservbt = $client->__call("reservationExpeditionV2", $expeditionArray);
400
+ if (!$webservbt->errorCode && $webservbt->reservationNumber) {
401
+ $tracking_number = $webservbt->skybillNumber;
402
+ // Add tracking number for the shipment if not already exists.
403
+ if (!$this->_trackingNumbers && $webservbt->skybillNumber) {
404
+ $track = Mage::getModel('sales/order_shipment_track')
405
+ ->setNumber($webservbt->skybillNumber)
406
+ ->setCarrier(ucwords($_shippingMethod[0]))
407
+ ->setCarrierCode($_shippingMethod[0])
408
+ ->setTitle(ucwords($_shippingMethod[0]))
409
+ ->setChronoReservationNumber($webservbt->reservationNumber)
410
+ ->setPopup(1);
411
+ $shipment->addTrack($track);
412
+
413
+ $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
414
+ $tracking_title = $this->__('Track Your Order');
415
+ $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
416
+
417
+ //$shipment->register();
418
+ $comment = '';
419
+ $shipment->setEmailSent(true);
420
+ $this->_saveShipment($shipment);
421
+ $shipment->sendEmail(1, $tracking_order . $comment);
422
+ }
423
+ return $webservbt->reservationNumber;
424
+ } else {
425
+ $this->_getSession()->addError($_helper->__($webservbt->errorMessage));
426
+ }
427
+ } catch (SoapFault $fault) {
428
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
429
+ }
430
+ }
431
+ }
432
+
433
+ public function getShipmentByOrderId($orderId) {
434
+ $_shipment = Mage::getResourceModel('sales/order_shipment_grid_collection')
435
+ ->addAttributeToFilter('order_id', $orderId)
436
+ ->getAllIds();
437
+ return $_shipment;
438
+ }
439
+
440
+ public function getShipmentByIncrementId($incrementId) {
441
+ $_shipment = Mage::getResourceModel('sales/order_shipment_grid_collection')
442
+ ->addAttributeToFilter('increment_id', $incrementId)
443
+ ->getAllIds();
444
+ return $_shipment;
445
+ }
446
+
447
+ public function initShipment($orderId,$savedQtys = '') {
448
+ $order = Mage::getModel('sales/order')->load($orderId);
449
+
450
+ /**
451
+ * Check order existing
452
+ */
453
+ if (!$order->getId()) {
454
+ $this->_getSession()->addError($this->__('The order no longer exists.'));
455
+ return false;
456
+ }
457
+ /**
458
+ * Check shipment is available to create separate from invoice
459
+ */
460
+ if ($order->getForcedDoShipmentWithInvoice()) {
461
+ $this->_getSession()->addError($this->__('Cannot do shipment for the order separately from invoice.'));
462
+ return false;
463
+ }
464
+ /**
465
+ * Check shipment create availability
466
+ */
467
+ /* if (!$order->canShip()) {
468
+ $this->_getSession()->addError($this->__('Cannot do shipment for the order.'));
469
+ return false;
470
+ } */
471
+ if(empty($savedQtys))
472
+ $savedQtys = $this->_getItemQtys();
473
+ $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($savedQtys);
474
+ if(Mage::registry('current_shipment')) Mage::unregister ('current_shipment');
475
+ Mage::register('current_shipment', $shipment);
476
+ return $shipment;
477
+ }
478
+
479
+ public function createNewShipment($orderId,$savedQtys = '') {
480
+ $_helper = Mage::helper('chronorelais');
481
+ $reservationNumber = '';
482
+ try {
483
+ if ($shipment = $this->initShipment($orderId,$savedQtys)) {
484
+ $shipment->register();
485
+
486
+ $_order = $shipment->getOrder();
487
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
488
+
489
+ $expeditionArray = $this->getExpeditionParams($shipment, $_shippingMethod);
490
+ $tracking_number = '';
491
+ if ($expeditionArray) {
492
+
493
+ $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
494
+ try {
495
+ $expedition = $client->__call("reservationExpeditionV2", $expeditionArray);
496
+ if (!$expedition->errorCode && $expedition->skybillNumber) {
497
+ $tracking_number = $expedition->skybillNumber;
498
+ $track = Mage::getModel('sales/order_shipment_track')
499
+ ->setNumber($expedition->skybillNumber)
500
+ ->setCarrier(ucwords($_shippingMethod[0]))
501
+ ->setCarrierCode($_shippingMethod[0])
502
+ ->setTitle(ucwords($_shippingMethod[0]))
503
+ ->setChronoReservationNumber($expedition->reservationNumber)
504
+ ->setPopup(1);
505
+ $shipment->addTrack($track);
506
+ $reservationNumber = $expedition->reservationNumber;
507
+ } else {
508
+ $this->_getSession()->addError($_helper->__($expedition->errorMessage));
509
+ return;
510
+ }
511
+ } catch (SoapFault $fault) {
512
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
513
+ return;
514
+ }
515
+ }
516
+
517
+ $tracking_url = str_replace('{tracking_number}', $tracking_number, Mage::helper('chronorelais')->getConfigurationTrackingViewUrl());
518
+ $tracking_title = $this->__('Track Your Order');
519
+ $tracking_order = '<p><a title="' . $tracking_title . '" href="' . $tracking_url . '"><b>' . $tracking_title . '</b></a></p>';
520
+
521
+ $comment = '';
522
+ $shipment->setEmailSent(true);
523
+ $this->_saveShipment($shipment);
524
+ $shipment->sendEmail(1, $tracking_order . $comment);
525
+ $this->_getSession()->addSuccess($this->__('Shipment was successfully created.'));
526
+ return $reservationNumber;
527
+ } else {
528
+ $this->_forward('noRoute');
529
+ return;
530
+ }
531
+ } catch (Mage_Core_Exception $e) {
532
+ $this->_getSession()->addError($e->getMessage());
533
+ return;
534
+ } catch (Exception $e) {
535
+ $this->_getSession()->addError($this->__('Can not save shipment: ' . $e->getMessage()));
536
+ return;
537
+ }
538
+ }
539
+
540
+ public function printMassAction() {
541
+ $orderIds = $this->getRequest()->getParam('order_ids');
542
+ $trackNumberUrls = array();
543
+ $helper = Mage::helper('chronorelais');
544
+ foreach ($orderIds as $orderId) {
545
+ if ($_shipments = $this->getShipmentByOrderId($orderId)) {
546
+ if (count($_shipments) == 1) {
547
+ $shipmentId = $_shipments[0];
548
+ $trackNumber = $this->getEtiquetteUrl($shipmentId);
549
+ if ($trackNumber)
550
+ $trackNumberUrls[] = str_replace('{trackingNumber}', $trackNumber, $helper->getConfigurationTrackingUrl());
551
+ } else {
552
+ foreach ($_shipments as $_shipment) {
553
+ $trackNumber = $this->getEtiquetteUrl($_shipment);
554
+ if ($trackNumber)
555
+ $trackNumberUrls[] = str_replace('{trackingNumber}', $trackNumber, $helper->getConfigurationTrackingUrl());
556
+ }
557
+ }
558
+ } else {
559
+
560
+ $order = Mage::getModel('sales/order')->load($orderId);
561
+
562
+ /* If shipping method is Chronopost => check if shipping weight isn't over limit */
563
+ $chronopostMethods = array('chronopost_chronopost','chronoexpress_chronoexpress','chronorelais_chronorelais','chronopostc10_chronopostC10','chronopostc18_chronopostC18','chronopostcclassic_chronopostCClassic');
564
+ $shippingMethod = $order->getShippingMethod();
565
+ if(in_array($shippingMethod, $chronopostMethods)) {
566
+ $weightShipping = 0;
567
+ $shippingMethod = explode("_", $shippingMethod);
568
+ $shippingMethod = $shippingMethod[0];
569
+ $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
570
+ foreach ($order->getItemsCollection() as $item) {
571
+ $weightShipping += $item->getWeight()*$item->getQtyOrdered();
572
+ }
573
+ if($helper->getConfigWeightUnit() == 'g')
574
+ {
575
+ $weightShipping = $weightShipping / 1000; // conversion g => kg
576
+ }
577
+ if($weightShipping > $weight_limit) {
578
+ /* multi shipping. 1 shipment by product */
579
+ $trackingNumber = array();
580
+ foreach ($order->getItemsCollection() as $item) {
581
+ $qty = $item->getQtyOrdered();
582
+ for($i = 1; $i <= $qty; $i++) {
583
+ $trackingNumber = $this->createNewShipment($orderId,array($item->getId() => '1'));
584
+ if ($trackingNumber)
585
+ $trackNumberUrls[] = str_replace('{trackingNumber}', $trackingNumber, $helper->getConfigurationTrackingUrl());
586
+ }
587
+ }
588
+ }
589
+ else {
590
+ $trackingNumber = $this->createNewShipment($orderId);
591
+ if ($trackingNumber)
592
+ $trackNumberUrls[] = str_replace('{trackingNumber}', $trackingNumber, $helper->getConfigurationTrackingUrl());
593
+ }
594
+ }
595
+ else {
596
+ $trackingNumber = $this->createNewShipment($orderId);
597
+ if ($trackingNumber)
598
+ $trackNumberUrls[] = str_replace('{trackingNumber}', $trackingNumber, $helper->getConfigurationTrackingUrl());
599
+ }
600
+ }
601
+ }
602
+ if (count($trackNumberUrls)) {
603
+ $this->_processDownloadMass($trackNumberUrls);
604
+ //exit(0);
605
+ }
606
+ else
607
+ return $this->_redirectReferer();
608
+ }
609
+
610
+ public function printAction() {
611
+ // Appel via order_id
612
+ $orderId = $this->getRequest()->getParam('order_id');
613
+ $helper = Mage::helper('chronorelais');
614
+ if ($orderId) {
615
+ if ($_shipments = $this->getShipmentByOrderId($orderId)) {
616
+ if (count($_shipments) == 1) {
617
+ $shipmentId = $_shipments[0];
618
+ $trackingNumber = $this->getEtiquetteUrl($shipmentId);
619
+ } else {
620
+ $track = "Cette commande contient plusieurs expéditions, cliquez sur chaque lien pour obtenir les étiquettes :<br>";
621
+ foreach ($_shipments as $_shipment) {
622
+ $url = str_replace('{trackingNumber}', $this->getEtiquetteUrl($_shipment), $helper->getConfigurationTrackingUrl());
623
+ $track .= '<a target="_blank" href="' . $url . '">' . $url . '</a><br />';
624
+ }
625
+ echo $track;
626
+ return;
627
+ }
628
+ } else {
629
+ $order = Mage::getModel('sales/order')->load($orderId);
630
+
631
+ /* If shipping method is Chronopost => check if shipping weight isn't over limit */
632
+ $chronopostMethods = array('chronopost_chronopost','chronoexpress_chronoexpress','chronorelais_chronorelais','chronopostc10_chronopostC10','chronopostc18_chronopostC18','chronopostcclassic_chronopostCClassic');
633
+ $shippingMethod = $order->getShippingMethod();
634
+ if(in_array($shippingMethod, $chronopostMethods)) {
635
+ $weightShipping = 0;
636
+ $shippingMethod = explode("_", $shippingMethod);
637
+ $shippingMethod = $shippingMethod[0];
638
+ $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
639
+ foreach ($order->getItemsCollection() as $item) {
640
+ $weightShipping += $item->getWeight()*$item->getQtyOrdered();
641
+ }
642
+ if($helper->getConfigWeightUnit() == 'g')
643
+ {
644
+ $weightShipping = $weightShipping / 1000; // conversion g => kg
645
+ }
646
+ if($weightShipping > $weight_limit) {
647
+ /* multi shipping. 1 shipment by product */
648
+ $trackingNumber = array();
649
+ foreach ($order->getItemsCollection() as $item) {
650
+ $qty = $item->getQtyOrdered();
651
+ for($i = 1; $i <= $qty; $i++) {
652
+ $trackingNumber[] = $this->createNewShipment($orderId,array($item->getId() => '1'));
653
+ }
654
+ }
655
+ }
656
+ else {
657
+ $trackingNumber = $this->createNewShipment($orderId);
658
+ }
659
+ }
660
+ else {
661
+ $trackingNumber = $this->createNewShipment($orderId);
662
+ }
663
+ }
664
+ } else {
665
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
666
+ if ($shipmentId) {
667
+ $trackingNumber = $this->getEtiquetteUrl($shipmentId);
668
+ } else {
669
+ $shipmentIncrementId = $this->getRequest()->getParam('shipment_increment_id');
670
+ $shipmentId = $this->getShipmentByIncrementId($shipmentIncrementId);
671
+ $trackingNumber = $this->getEtiquetteUrl($shipmentId[0]);
672
+ }
673
+ }
674
+
675
+
676
+ if ($trackingNumber) {
677
+ try {
678
+ if(is_array($trackingNumber)) {
679
+ $trackNumberUrls = array();
680
+ foreach($trackingNumber as $track) {
681
+ $trackNumberUrls[] = str_replace('{trackingNumber}', $track, $helper->getConfigurationTrackingUrl());
682
+ }
683
+ $this->_processDownloadMass($trackNumberUrls);
684
+ //exit(0);
685
+ }
686
+ else {
687
+ $tracking_url = str_replace('{trackingNumber}', $trackingNumber, $helper->getConfigurationTrackingUrl());
688
+ $this->_prepareDownloadResponse('Etiquette_chronopost.pdf', file_get_contents($tracking_url));
689
+ //$this->_processDownload($tracking_url, 'url');
690
+ //exit(0);
691
+ }
692
+ } catch (Mage_Core_Exception $e) {
693
+ $this->_getSession()->addError($helper->__('Désolé, une erreur est survenu lors de la récupération de l\'étiquetes. Merci de contacter Chronopost ou de réessayer plus tard'));
694
+ }
695
+ }
696
+ else
697
+ return $this->_redirectReferer();
698
+ }
699
+
700
+ public function massLivraisonSamediStatusAction() {
701
+ if ($this->getRequest()->getPost('status')) {
702
+ $this->saveLivraisonSamediStatusAction();
703
+ }
704
+ }
705
+
706
+ /* Save the Livraison le Samedi status to orders */
707
+
708
+ public function saveLivraisonSamediStatusAction() {
709
+ /* get the orders */
710
+ $orderIds = $this->getRequest()->getPost('order_ids');
711
+ $status = $this->getRequest()->getPost('status');
712
+ $_connection = Mage::getSingleton('core/resource')->getConnection('core_write');
713
+ $_table = Mage::getSingleton('core/resource')->getTableName('sales_chronopost_order_export_status');
714
+ $exceptions = array();
715
+
716
+ foreach ($orderIds as $orderId) {
717
+ $order_details = Mage::getModel('sales/order')->load($orderId);
718
+ $shipping_method = '';
719
+ $livraison_le_samedi = $status;
720
+ if ($shipping_method = $order_details->getShippingMethod()) {
721
+ $shipping_method = explode('_', $shipping_method);
722
+ if ($shipping_method[0] == 'chronoexpress') {
723
+ $livraison_le_samedi = '--';
724
+ }
725
+ }
726
+ $condition = array(
727
+ $_connection->quoteInto('order_id = ?', $orderId),
728
+ );
729
+ $_connection->delete($_table, $condition);
730
+
731
+ $dataLine = array(
732
+ 'order_id' => $orderId,
733
+ 'livraison_le_samedi' => $livraison_le_samedi
734
+ );
735
+ try {
736
+ $_connection->insert($_table, $dataLine);
737
+ } catch (Exception $e) {
738
+ $exceptions[] = Mage::helper('chronorelais')->__('Order assigning error: ' . $e->getMessage());
739
+ }
740
+ }
741
+ if ($exceptions) {
742
+ $this->_getSession()->addError($exceptions);
743
+ } else {
744
+ $this->_getSession()->addSuccess($this->__('Livraison le Samedi statut a &eacute;t&eacute; ajout&eacute;'));
745
+ }
746
+ $this->_redirect('*/*/index');
747
+ }
748
+
749
+ /* Remove accents characters */
750
+
751
+ public function removeaccents($string) {
752
+ $stringToReturn = str_replace(
753
+ 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);
754
+ // Remove all remaining other unknown characters
755
+ $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
756
+ $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
757
+ $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
758
+ $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
759
+ return $stringToReturn;
760
+ }
761
+
762
+ /*
763
+ * *******************************************************************
764
+ * ******************** ETIQUETTE DE RETOUR **************************
765
+ * *******************************************************************
766
+ */
767
+
768
+ public function printEtiquetteRetourAction() {
769
+ $shipmentIncrementId = $this->getRequest()->getParam('shipment_increment_id');
770
+ $shipmentId = $this->getShipmentByIncrementId($shipmentIncrementId);
771
+ $shipmentId = $shipmentId[0];
772
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
773
+ $_order = $shipment->getOrder();
774
+ $_shippingAddress = $shipment->getShippingAddress();
775
+ $_billingAddress = $shipment->getBillingAddress();
776
+ $trackingNumber = $this->getEtiquetteRetourUrl($shipment);
777
+
778
+ if ($trackingNumber) {
779
+ try {
780
+ $tracking_url = str_replace('{trackingNumber}', $trackingNumber, Mage::helper('chronorelais')->getConfigurationTrackingUrl());
781
+ $path = $this->savePdf($tracking_url, $shipmentId);
782
+
783
+ /*
784
+ * TODO adexos : Send mail with pdf to customer
785
+ */
786
+ $message_email .= 'Bonjour,
787
+ <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.
788
+ <br />Cordialement,';
789
+
790
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
791
+
792
+ $mail = new Zend_Mail('utf-8');
793
+ $mail->setBodyHtml($message_email);
794
+ $mail->setFrom(Mage::getStoreConfig('contacts/email/recipient_email'));
795
+ $mail->setSubject($_order->getStoreName(1) . ' : Etiquette de retour chronopost');
796
+ $mail->createAttachment(file_get_contents($path), Zend_Mime::TYPE_OCTETSTREAM, Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'etiquette_retour.pdf');
797
+
798
+ $mail->addTo($customer_email);
799
+ $mail->send();
800
+
801
+ $mail->clearRecipients();
802
+ $mail->addTo(Mage::getStoreConfig('contacts/email/recipient_email'));
803
+ $mail->send();
804
+
805
+ $this->_getSession()->addSuccess(Mage::helper('chronorelais')->__('L\'etiquette de retour à bien été envoyée au client.'));
806
+ } catch (Mage_Core_Exception $e) {
807
+ $this->_getSession()->addError(Mage::helper('chronorelais')->__('Désolé, une erreure est survenu lors de la récupération de l\'étiquetes. Merci de contacter Chronopost ou de réessayer plus tard'));
808
+ }
809
+ }
810
+ return $this->_redirectReferer();
811
+ }
812
+
813
+ protected function getEtiquetteRetourParams($shipment, $_shippingMethod) {
814
+ $_order = $shipment->getOrder();
815
+ $_shippingAddress = $shipment->getShippingAddress();
816
+ $_billingAddress = $shipment->getBillingAddress();
817
+ $_helper = Mage::helper('chronorelais');
818
+
819
+ if ($_shippingAddress->getCountryId() != 'FR') {
820
+ $this->_getSession()->addError($_helper->__('Les retours sont disponibles uniquement pour la France'));
821
+ return;
822
+ }
823
+ $shippingMethodAllow = array('chronorelais','chronopost','chronopostc10','chronopostc18');
824
+ if (!in_array($_shippingMethod[0], $shippingMethodAllow)) {
825
+ $this->_getSession()->addError($_helper->__('Les retours ne sont pas disponibles pour le mode de livraison ' . $_shippingMethod[0]));
826
+ return;
827
+ }
828
+
829
+ if (in_array($_shippingMethod[0], $shippingMethodAllow)) {
830
+ $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
831
+
832
+ //esdParams parameters
833
+ $esdParams = array(
834
+ 'height' => '',
835
+ 'width' => '',
836
+ 'length' => ''
837
+ );
838
+
839
+ //header parameters
840
+ $header = array(
841
+ 'idEmit' => 'CHRFR',
842
+ 'accountNumber' => $_helper->getConfigurationAccountNumber(),
843
+ 'subAccount' => $_helper->getConfigurationSubAccountNumber()
844
+ );
845
+
846
+ //shipper parameters
847
+ $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
848
+ $recipient = array(
849
+ 'recipientAdress1' => $_helper->getConfigurationShipperInfo('address1'),
850
+ 'recipientAdress2' => $_helper->getConfigurationShipperInfo('address2'),
851
+ 'recipientCity' => $_helper->getConfigurationShipperInfo('city'),
852
+ 'recipientCivility' => $_helper->getConfigurationShipperInfo('civility'),
853
+ 'recipientContactName' => $_helper->getConfigurationShipperInfo('contactname'),
854
+ 'recipientCountry' => $_helper->getConfigurationShipperInfo('country'),
855
+ 'recipientEmail' => $_helper->getConfigurationShipperInfo('email'),
856
+ 'recipientMobilePhone' => $shipperMobilePhone,
857
+ 'recipientName' => $_helper->getConfigurationShipperInfo('name'),
858
+ 'recipientName2' => $_helper->getConfigurationShipperInfo('name2'),
859
+ 'recipientPhone' => $_helper->getConfigurationShipperInfo('phone'),
860
+ 'recipientPreAlert' => '',
861
+ 'recipientZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
862
+ );
863
+
864
+ //customer parameters
865
+ $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
866
+ $customer = array(
867
+ 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
868
+ 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
869
+ 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
870
+ 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
871
+ 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
872
+ 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
873
+ 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
874
+ 'customerMobilePhone' => $customerMobilePhone,
875
+ 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
876
+ 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
877
+ 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
878
+ 'customerPreAlert' => '',
879
+ 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
880
+ );
881
+
882
+ //recipient parameters
883
+ $recipient_address = $_shippingAddress->getStreet();
884
+ if (!isset($recipient_address[1])) {
885
+ $recipient_address[1] = '';
886
+ }
887
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
888
+ $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
889
+ $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
890
+ $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
891
+ //remove any alphabets in phone number
892
+ $recipientPhone = trim(ereg_replace("[^0-9.-]", " ", $_shippingAddress->getTelephone()));
893
+ $shipper = array(
894
+ 'shipperAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
895
+ 'shipperAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
896
+ 'shipperCity' => $this->getFilledValue($_shippingAddress->getCity()),
897
+ 'shipperCivility' => 'M',
898
+ 'shipperContactName' => $recipientName2,
899
+ 'shipperCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
900
+ 'shipperEmail' => $customer_email,
901
+ 'shipperMobilePhone' => $recipientMobilePhone,
902
+ 'shipperName' => $recipientName,
903
+ 'shipperName2' => $recipientName2,
904
+ 'shipperPhone' => $recipientPhone,
905
+ 'shipperPreAlert' => '',
906
+ 'shipperZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
907
+ );
908
+
909
+ //ref parameters
910
+ $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
911
+ if (!$recipientRef) {
912
+ $recipientRef = $_order->getCustomerId();
913
+ }
914
+ $shipperRef = $_order->getRealOrderId();
915
+
916
+ $ref = array(
917
+ 'recipientRef' => $recipientRef,
918
+ 'shipperRef' => $shipperRef
919
+ );
920
+
921
+ //skybill parameters
922
+ /* Livraison Samedi (Delivery Saturday) field */
923
+ $SaturdayShipping = 0; //default value for the saturday shipping
924
+ $send_day = strtolower(date('l'));
925
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
926
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
927
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
928
+ } else {
929
+ if ($_deliver_on_saturday == 'Yes') {
930
+ $_deliver_on_saturday = 1;
931
+ } else {
932
+ $_deliver_on_saturday = 0;
933
+ }
934
+ }
935
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
936
+ if ($_deliver_on_saturday && $is_sending_day) {
937
+ $SaturdayShipping = 6;
938
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
939
+ $SaturdayShipping = 1;
940
+ }
941
+ }
942
+
943
+ $weight = 0;
944
+ foreach ($shipment->getItemsCollection() as $item) {
945
+ $weight += $item->weight * $item->qty;
946
+ }
947
+ if ($_helper->getConfigWeightUnit() == 'g') {
948
+ $weight = $weight / 1000; /* conversion g => kg */
949
+ }
950
+ $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
951
+
952
+ $skybill = array(
953
+ 'codCurrency' => 'EUR',
954
+ 'codValue' => '',
955
+ 'content1' => '',
956
+ 'content2' => '',
957
+ 'content3' => '',
958
+ 'content4' => '',
959
+ 'content5' => '',
960
+ 'customsCurrency' => 'EUR',
961
+ 'customsValue' => '',
962
+ 'evtCode' => 'DC',
963
+ 'insuredCurrency' => 'EUR',
964
+ 'insuredValue' => '',
965
+ 'objectType' => 'MAR',
966
+ 'productCode' => $_helper::CHRONO_POST,
967
+ 'service' => $SaturdayShipping,
968
+ 'shipDate' => date('c'),
969
+ 'shipHour' => date('H'),
970
+ 'weight' => $weight,
971
+ 'weightUnit' => 'KGM'
972
+ );
973
+
974
+ $skybillParams = array(
975
+ 'mode' => $_helper->getConfigurationSkybillParam()
976
+ );
977
+
978
+ $expeditionArray = array(
979
+ 'esdParams' => $esdParams,
980
+ 'header' => $header,
981
+ 'shipper' => $shipper,
982
+ 'customer' => $customer,
983
+ 'recipient' => $recipient,
984
+ 'ref' => $ref,
985
+ 'skybill' => $skybill,
986
+ 'skybillParams' => $skybillParams,
987
+ 'password' => $_helper->getConfigurationAccountPass(),
988
+ 'option' => '0'
989
+ );
990
+ //printArray($expeditionArray); exit;
991
+ return $expeditionArray;
992
+ }
993
+ }
994
+
995
+ protected function getEtiquetteRetourUrl($shipment) {
996
+ //On récupère les infos d'expédition
997
+ $reservationNumber = '';
998
+ $_helper = Mage::helper('chronorelais');
999
+
1000
+ $_order = $shipment->getOrder();
1001
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
1002
+
1003
+ $expeditionArray = $this->getEtiquetteRetourParams($shipment, $_shippingMethod);
1004
+ $tracking_number = '';
1005
+ if ($expeditionArray) {
1006
+ $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
1007
+ try {
1008
+ $webservbt = $client->__call("reservationExpeditionV2", $expeditionArray);
1009
+ if (!$webservbt->errorCode && $webservbt->reservationNumber) {
1010
+ $tracking_number = $webservbt->skybillNumber;
1011
+ return $webservbt->reservationNumber;
1012
+ } else {
1013
+ $this->_getSession()->addError($_helper->__($webservbt->errorMessage));
1014
+ }
1015
+ } catch (SoapFault $fault) {
1016
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
1017
+ }
1018
+ }
1019
+ }
1020
+
1021
+ protected function savePdf($url, $shipmentId) {
1022
+ $path = 'media/chronopost/etiquetteRetour-' . $shipmentId . '.pdf';
1023
+ file_put_contents($path, file_get_contents($url));
1024
+ return $path;
1025
+ }
1026
+
1027
  }
app/code/community/Chronopost/Chronorelais/controllers/Sales/Order/ShipmentController.php CHANGED
@@ -1,274 +1,383 @@
1
- <?php
2
- require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
3
- class Chronopost_Chronorelais_Sales_Order_ShipmentController extends Mage_Adminhtml_Sales_Order_ShipmentController
4
- {
5
-
6
- /**
7
- * Save shipment
8
- * We can save only new shipment. Existing shipments are not editable
9
- */
10
-
11
- public function getFilledValue($value)
12
- {
13
- if($value) {
14
- return $this->removeaccents(trim($value));
15
- } else {
16
- return '';
17
- }
18
- }
19
-
20
- public function checkMobileNumber($value)
21
- {
22
- if($reqvalue = trim($value)) {
23
- $_number = substr($reqvalue, 0, 2);
24
- $fixed_array = array('01','02','03','04','05','06','06');
25
- if(in_array($_number, $fixed_array)) {
26
- return $reqvalue;
27
- } else {
28
- return '';
29
- }
30
- }
31
- }
32
-
33
- public function saveAction()
34
- {
35
- $data = $this->getRequest()->getPost('shipment');
36
-
37
- try {
38
- if ($shipment = $this->_initShipment()) {
39
- $shipment->register();
40
-
41
- //Si l'expedition est réalisé par Mondial Relay, on créé le tracking automatiquement.
42
-
43
- $_order = $shipment->getOrder();
44
- $_shippingMethod = explode("_",$_order->getShippingMethod());
45
-
46
- $_shippingAddress = $shipment->getShippingAddress();
47
- $_billingAddress = $shipment->getBillingAddress();
48
- $_helper = Mage::helper('chronorelais');
49
-
50
- if ($_shippingMethod[0] == 'chronorelais' || $_shippingMethod[0] == 'chronopost' || $_shippingMethod[0] == 'chronoexpress') {
51
-
52
- $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
53
-
54
- //esdParams parameters
55
- $esdParams = array(
56
- 'height' => '',
57
- 'width' => '',
58
- 'length' => ''
59
- );
60
-
61
- //header parameters
62
- $header = array(
63
- 'idEmit' => 'CHRFR',
64
- 'accountNumber' => $_helper->getConfigurationAccountNumber(),
65
- 'subAccount' => $_helper->getConfigurationSubAccountNumber()
66
- );
67
-
68
- //shipper parameters
69
- $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
70
- $shipper = array(
71
- 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
72
- 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
73
- 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
74
- 'shipperCivility' => $_helper->getConfigurationShipperInfo('civility'),
75
- 'shipperContactName'=> $_helper->getConfigurationShipperInfo('contactname'),
76
- 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
77
- 'shipperEmail' => $_helper->getConfigurationShipperInfo('email'),
78
- 'shipperMobilePhone'=> $shipperMobilePhone,
79
- 'shipperName' => $_helper->getConfigurationShipperInfo('name'),
80
- 'shipperName2' => $_helper->getConfigurationShipperInfo('name2'),
81
- 'shipperPhone' => $_helper->getConfigurationShipperInfo('phone'),
82
- 'shipperPreAlert' => '',
83
- 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
84
- );
85
-
86
- //customer parameters
87
- $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
88
- $customer = array(
89
- 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
90
- 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
91
- 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
92
- 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
93
- 'customerContactName'=> $_helper->getConfigurationCustomerInfo('contactname'),
94
- 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
95
- 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
96
- 'customerMobilePhone'=> $customerMobilePhone,
97
- 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
98
- 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
99
- 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
100
- 'customerPreAlert' => '',
101
- 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
102
- );
103
-
104
- //recipient parameters
105
- $recipient_address = $_shippingAddress->getStreet();
106
- if (!isset($recipient_address[1])) {
107
- $recipient_address[1] = '';
108
- }
109
- $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
110
- $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
111
- $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
112
- $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
113
- //remove any alphabets in phone number
114
- $recipientPhone = trim(ereg_replace("[^0-9.-]", " ", $_shippingAddress->getTelephone()));
115
-
116
- $recipient = array(
117
- 'recipientAdress1' => $this->getFilledValue($recipient_address[0]),
118
- 'recipientAdress2' => $this->getFilledValue($recipient_address[1]),
119
- 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
120
- 'recipientContactName' => $recipientName2,
121
- 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
122
- 'recipientEmail' => $customer_email,
123
- 'recipientMobilePhone' => $recipientMobilePhone,
124
- 'recipientName' => $recipientName,
125
- 'recipientName2' => $recipientName2,
126
- 'recipientPhone' => $recipientPhone,
127
- 'recipientPreAlert' => '',
128
- 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
129
- );
130
-
131
- //ref parameters
132
- $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
133
- if(!$recipientRef) {
134
- $recipientRef = $_order->getCustomerId();
135
- }
136
- $shipperRef = $_order->getRealOrderId();
137
-
138
- $ref = array(
139
- 'recipientRef' => $recipientRef,
140
- 'shipperRef' => $shipperRef
141
- );
142
-
143
- //skybill parameters
144
- /* Livraison Samedi (Delivery Saturday) field*/
145
- $SaturdayShipping = 0; //default value for the saturday shipping
146
- $send_day = strtolower(date('l'));
147
- if($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
148
- if(!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
149
- $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/'.$_shippingMethod[0].'/deliver_on_saturday');
150
- } else {
151
- if($_deliver_on_saturday=='Yes') {
152
- $_deliver_on_saturday = 1;
153
- } else {
154
- $_deliver_on_saturday = 0;
155
- }
156
- }
157
- $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
158
- if($_deliver_on_saturday && $is_sending_day) {
159
- $SaturdayShipping = 1;
160
- } elseif(!$_deliver_on_saturday && $is_sending_day) {
161
- $SaturdayShipping = 6;
162
- }
163
- }
164
-
165
- $weight = 0;
166
- foreach ($shipment->getItemsCollection() as $item) {
167
- $weight += $item->weight * $item->qty;
168
- }
169
-
170
- $skybill = array(
171
- 'codCurrency' => 'EUR',
172
- 'codValue' => '',
173
- 'content1' => '',
174
- 'content2' => '',
175
- 'content3' => '',
176
- 'content4' => '',
177
- 'content5' => '',
178
- 'customsCurrency' => 'EUR',
179
- 'customsValue' => '',
180
- 'evtCode' => 'DC',
181
- 'insuredCurrency' => 'EUR',
182
- 'insuredValue' => '',
183
- 'objectType' => 'MAR',
184
- 'productCode' => $_helper->getChronoProductCode($_shippingAddress->getCountryId(),$_shippingMethod[0]),
185
- 'service' => $SaturdayShipping,
186
- 'shipDate' => date('c'),
187
- 'shipHour' => date('H'),
188
- 'weight' => $weight,
189
- 'weightUnit' => 'KGM'
190
- );
191
-
192
- $expeditionArray = array(
193
- 'esdParams' => $esdParams,
194
- 'header' => $header,
195
- 'shipper' => $shipper,
196
- 'customer' => $customer,
197
- 'recipient' => $recipient,
198
- 'ref' => $ref,
199
- 'skybill' => $skybill,
200
- 'skybillParams' => $_helper->getConfigurationSkybillParam(),
201
- 'password' => $_helper->getConfigurationAccountPass(),
202
- 'option' => '0'
203
- );
204
-
205
- $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
206
- try
207
- {
208
- $expedition = $client->__call("reservationExpeditionV2",$expeditionArray);
209
- if(!$expedition->errorCode && $expedition->skybillNumber) {
210
- $track = Mage::getModel('sales/order_shipment_track')
211
- ->setNumber($expedition->skybillNumber)
212
- ->setCarrier(ucwords($_shippingMethod[0]))
213
- ->setCarrierCode($_shippingMethod[0])
214
- ->setTitle(ucwords($_shippingMethod[0]))
215
- ->setChronoReservationNumber($expedition->reservationNumber)
216
- ->setPopup(1);
217
- $shipment->addTrack($track);
218
- } else {
219
- $this->_getSession()->addError($_helper->__($expedition->errorMessage));
220
- $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
221
- return;
222
- }
223
- }
224
- catch(SoapFault $fault)
225
- {
226
- $this->_getSession()->addError($_helper->__($fault->faultstring));
227
- $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
228
- return;
229
- }
230
- }
231
-
232
- $comment = '';
233
- if (!empty($data['comment_text'])) {
234
- $shipment->addComment($data['comment_text'], isset($data['comment_customer_notify']));
235
- $comment = $data['comment_text'];
236
- }
237
-
238
- if (!empty($data['send_email'])) {
239
- $shipment->setEmailSent(true);
240
- }
241
-
242
- $this->_saveShipment($shipment);
243
- $shipment->sendEmail(!empty($data['send_email']), $comment);
244
- $this->_getSession()->addSuccess($this->__('Shipment was successfully created.'));
245
- $this->_redirect('adminhtml/sales_order/view', array('order_id' => $shipment->getOrderId()));
246
- return;
247
-
248
- }else {
249
- $this->_forward('noRoute');
250
- return;
251
- }
252
- }
253
- catch (Mage_Core_Exception $e) {
254
- $this->_getSession()->addError($e->getMessage());
255
- }
256
- catch (Exception $e) {
257
- $this->_getSession()->addError($this->__('Can not save shipment: '.$e->getMessage()));
258
- }
259
- $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
260
- }
261
-
262
- public function removeaccents($string){
263
- $stringToReturn = str_replace(
264
- array('�','�','�','�','�', '�', '�','�','�','�', '�','�','�','�', '�', '�','�','�','�','�', '�','�','�','�', '�','�', '�','�','�','�','�', '�', '�','�','�','�', '�','�','�','�', '�', '�','�','�','�','�', '�','�','�','�', '�','/','\xa8'),
265
- 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);
266
- // Remove all remaining other unknown characters
267
- $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
268
- $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
269
- $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
270
- $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
271
- return $stringToReturn;
272
- }
273
-
274
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
4
+
5
+ class Chronopost_Chronorelais_Sales_Order_ShipmentController extends Mage_Adminhtml_Sales_Order_ShipmentController {
6
+
7
+ /**
8
+ * Save shipment
9
+ * We can save only new shipment. Existing shipments are not editable
10
+ */
11
+ public function getFilledValue($value) {
12
+ if ($value) {
13
+ return $this->removeaccents(trim($value));
14
+ } else {
15
+ return '';
16
+ }
17
+ }
18
+
19
+ public function checkMobileNumber($value) {
20
+ if ($reqvalue = trim($value)) {
21
+ $_number = substr($reqvalue, 0, 2);
22
+ $fixed_array = array('01', '02', '03', '04', '05', '06', '06');
23
+ if (in_array($_number, $fixed_array)) {
24
+ return $reqvalue;
25
+ } else {
26
+ return '';
27
+ }
28
+ }
29
+ }
30
+
31
+ protected function saveAndCreateEtiquette($shipment) {
32
+ $shipment->register();
33
+
34
+ //Si l'expedition est réalisé par Mondial Relay, on créé le tracking automatiquement.
35
+
36
+ $_order = $shipment->getOrder();
37
+ $_shippingMethod = explode("_", $_order->getShippingMethod());
38
+
39
+ $_shippingAddress = $shipment->getShippingAddress();
40
+ $_billingAddress = $shipment->getBillingAddress();
41
+ $_helper = Mage::helper('chronorelais');
42
+
43
+ $shippingMethodAllow = array('chronorelais','chronopost','chronoexpress','chronopostc10','chronopostc18','chronopostcclassic');
44
+ if (in_array($_shippingMethod[0],$shippingMethodAllow)) {
45
+
46
+ $esdParams = $header = $shipper = $customer = $recipient = $ref = $skybill = $skybillParams = $password = array();
47
+
48
+ //esdParams parameters
49
+ $esdParams = array(
50
+ 'height' => '',
51
+ 'width' => '',
52
+ 'length' => ''
53
+ );
54
+
55
+ //header parameters
56
+ $header = array(
57
+ 'idEmit' => 'CHRFR',
58
+ 'accountNumber' => $_helper->getConfigurationAccountNumber(),
59
+ 'subAccount' => $_helper->getConfigurationSubAccountNumber()
60
+ );
61
+
62
+ //shipper parameters
63
+ $shipperMobilePhone = $this->checkMobileNumber($_helper->getConfigurationShipperInfo('mobilephone'));
64
+ $shipper = array(
65
+ 'shipperAdress1' => $_helper->getConfigurationShipperInfo('address1'),
66
+ 'shipperAdress2' => $_helper->getConfigurationShipperInfo('address2'),
67
+ 'shipperCity' => $_helper->getConfigurationShipperInfo('city'),
68
+ 'shipperCivility' => $_helper->getConfigurationShipperInfo('civility'),
69
+ 'shipperContactName' => $_helper->getConfigurationShipperInfo('contactname'),
70
+ 'shipperCountry' => $_helper->getConfigurationShipperInfo('country'),
71
+ 'shipperEmail' => $_helper->getConfigurationShipperInfo('email'),
72
+ 'shipperMobilePhone' => $shipperMobilePhone,
73
+ 'shipperName' => $_helper->getConfigurationShipperInfo('name'),
74
+ 'shipperName2' => $_helper->getConfigurationShipperInfo('name2'),
75
+ 'shipperPhone' => $_helper->getConfigurationShipperInfo('phone'),
76
+ 'shipperPreAlert' => '',
77
+ 'shipperZipCode' => $_helper->getConfigurationShipperInfo('zipcode')
78
+ );
79
+
80
+ //customer parameters
81
+ $customerMobilePhone = $this->checkMobileNumber($_helper->getConfigurationCustomerInfo('mobilephone'));
82
+ $customer = array(
83
+ 'customerAdress1' => $_helper->getConfigurationCustomerInfo('address1'),
84
+ 'customerAdress2' => $_helper->getConfigurationCustomerInfo('address2'),
85
+ 'customerCity' => $_helper->getConfigurationCustomerInfo('city'),
86
+ 'customerCivility' => $_helper->getConfigurationCustomerInfo('civility'),
87
+ 'customerContactName' => $_helper->getConfigurationCustomerInfo('contactname'),
88
+ 'customerCountry' => $_helper->getConfigurationCustomerInfo('country'),
89
+ 'customerEmail' => $_helper->getConfigurationCustomerInfo('email'),
90
+ 'customerMobilePhone' => $customerMobilePhone,
91
+ 'customerName' => $_helper->getConfigurationCustomerInfo('name'),
92
+ 'customerName2' => $_helper->getConfigurationCustomerInfo('name2'),
93
+ 'customerPhone' => $_helper->getConfigurationCustomerInfo('phone'),
94
+ 'customerPreAlert' => '',
95
+ 'customerZipCode' => $_helper->getConfigurationCustomerInfo('zipcode')
96
+ );
97
+
98
+ //recipient parameters
99
+ $recipient_address = $_shippingAddress->getStreet();
100
+ if (!isset($recipient_address[1])) {
101
+ $recipient_address[1] = '';
102
+ }
103
+ $customer_email = ($_shippingAddress->getEmail()) ? $_shippingAddress->getEmail() : ($_billingAddress->getEmail() ? $_billingAddress->getEmail() : $_order->getCustomerEmail());
104
+ $recipientMobilePhone = $this->checkMobileNumber($_shippingAddress->getTelephone());
105
+ $recipientName = $this->getFilledValue($_shippingAddress->getCompany()); //RelayPoint Name if chronorelais or Companyname if chronopost and
106
+ $recipientName2 = $this->getFilledValue($_shippingAddress->getFirstname() . ' ' . $_shippingAddress->getLastname());
107
+ //remove any alphabets in phone number
108
+ $recipientPhone = trim(ereg_replace("[^0-9.-]", " ", $_shippingAddress->getTelephone()));
109
+
110
+ $recipient = array(
111
+ 'recipientAdress1' => substr($this->getFilledValue($recipient_address[0]), 0, 38),
112
+ 'recipientAdress2' => substr($this->getFilledValue($recipient_address[1]), 0, 38),
113
+ 'recipientCity' => $this->getFilledValue($_shippingAddress->getCity()),
114
+ 'recipientContactName' => $recipientName2,
115
+ 'recipientCountry' => $this->getFilledValue($_shippingAddress->getCountryId()),
116
+ 'recipientEmail' => $customer_email,
117
+ 'recipientMobilePhone' => $recipientMobilePhone,
118
+ 'recipientName' => $recipientName,
119
+ 'recipientName2' => $recipientName2,
120
+ 'recipientPhone' => $recipientPhone,
121
+ 'recipientPreAlert' => '',
122
+ 'recipientZipCode' => $this->getFilledValue($_shippingAddress->getPostcode()),
123
+ );
124
+
125
+ //ref parameters
126
+ $recipientRef = $this->getFilledValue($_shippingAddress->getWRelayPointCode());
127
+ if (!$recipientRef) {
128
+ $recipientRef = $_order->getCustomerId();
129
+ }
130
+ $shipperRef = $_order->getRealOrderId();
131
+
132
+ $ref = array(
133
+ 'recipientRef' => $recipientRef,
134
+ 'shipperRef' => $shipperRef
135
+ );
136
+
137
+ //skybill parameters
138
+ /* Livraison Samedi (Delivery Saturday) field */
139
+ $SaturdayShipping = 0; //default value for the saturday shipping
140
+ $send_day = strtolower(date('l'));
141
+ if ($_shippingMethod[0] == "chronopost" || $_shippingMethod[0] == "chronorelais") {
142
+ if (!$_deliver_on_saturday = Mage::helper('chronorelais')->getLivraisonSamediStatus($_order->getEntityId())) {
143
+ $_deliver_on_saturday = Mage::helper('chronorelais')->getConfigData('carriers/' . $_shippingMethod[0] . '/deliver_on_saturday');
144
+ } else {
145
+ if ($_deliver_on_saturday == 'Yes') {
146
+ $_deliver_on_saturday = 1;
147
+ } else {
148
+ $_deliver_on_saturday = 0;
149
+ }
150
+ }
151
+ $is_sending_day = Mage::helper('chronorelais')->isSendingDay();
152
+ if ($_deliver_on_saturday && $is_sending_day) {
153
+ $SaturdayShipping = 1;
154
+ } elseif (!$_deliver_on_saturday && $is_sending_day) {
155
+ $SaturdayShipping = 6;
156
+ }
157
+ }
158
+
159
+ $weight = 0;
160
+ foreach ($shipment->getItemsCollection() as $item) {
161
+ $weight += $item->weight * $item->qty;
162
+ }
163
+ if ($_helper->getConfigWeightUnit() == 'g') {
164
+ $weight = $weight / 1000; /* conversion g => kg */
165
+ }
166
+ $weight = 0; /* On met le poids à 0 car les colis sont pesé sur place */
167
+
168
+ $skybill = array(
169
+ 'codCurrency' => 'EUR',
170
+ 'codValue' => '',
171
+ 'content1' => '',
172
+ 'content2' => '',
173
+ 'content3' => '',
174
+ 'content4' => '',
175
+ 'content5' => '',
176
+ 'customsCurrency' => 'EUR',
177
+ 'customsValue' => '',
178
+ 'evtCode' => 'DC',
179
+ 'insuredCurrency' => 'EUR',
180
+ 'insuredValue' => '',
181
+ 'objectType' => 'MAR',
182
+ 'productCode' => $_helper->getChronoProductCodeToShipment($_shippingMethod[0]),
183
+ 'service' => $SaturdayShipping,
184
+ 'shipDate' => date('c'),
185
+ 'shipHour' => date('H'),
186
+ 'weight' => $weight,
187
+ 'weightUnit' => 'KGM'
188
+ );
189
+
190
+ $expeditionArray = array(
191
+ 'esdParams' => $esdParams,
192
+ 'header' => $header,
193
+ 'shipper' => $shipper,
194
+ 'customer' => $customer,
195
+ 'recipient' => $recipient,
196
+ 'ref' => $ref,
197
+ 'skybill' => $skybill,
198
+ 'skybillParams' => $_helper->getConfigurationSkybillParam(),
199
+ 'password' => $_helper->getConfigurationAccountPass(),
200
+ 'option' => '0'
201
+ );
202
+
203
+ $client = new SoapClient("http://wsshipping.chronopost.fr/shipping/services/services/ServiceEProcurement?wsdl", array('trace' => true));
204
+ try {
205
+ $expedition = $client->__call("reservationExpeditionV2", $expeditionArray);
206
+ if (!$expedition->errorCode && $expedition->skybillNumber) {
207
+ $track = Mage::getModel('sales/order_shipment_track')
208
+ ->setNumber($expedition->skybillNumber)
209
+ ->setCarrier(ucwords($_shippingMethod[0]))
210
+ ->setCarrierCode($_shippingMethod[0])
211
+ ->setTitle(ucwords($_shippingMethod[0]))
212
+ ->setChronoReservationNumber($expedition->reservationNumber)
213
+ ->setPopup(1);
214
+ $shipment->addTrack($track);
215
+ } else {
216
+ $this->_getSession()->addError($_helper->__($expedition->errorMessage));
217
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
218
+ return;
219
+ }
220
+ } catch (SoapFault $fault) {
221
+ $this->_getSession()->addError($_helper->__($fault->faultstring));
222
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
223
+ return;
224
+ }
225
+ }
226
+
227
+ $comment = '';
228
+ if (!empty($data['comment_text'])) {
229
+ $shipment->addComment($data['comment_text'], isset($data['comment_customer_notify']));
230
+ $comment = $data['comment_text'];
231
+ }
232
+
233
+ if (!empty($data['send_email'])) {
234
+ $shipment->setEmailSent(true);
235
+ }
236
+
237
+ $this->_saveShipment($shipment);
238
+ $shipment->sendEmail(!empty($data['send_email']), $comment);
239
+ $this->_getSession()->addSuccess($this->__('Shipment was successfully created.'));
240
+ $this->_redirect('adminhtml/sales_order/view', array('order_id' => $shipment->getOrderId()));
241
+ return;
242
+ }
243
+
244
+ /**
245
+ * Initialize shipment model instance
246
+ *
247
+ * @return Mage_Sales_Model_Order_Shipment|bool
248
+ */
249
+ protected function _initShipment()
250
+ {
251
+ $this->_title($this->__('Sales'))->_title($this->__('Shipments'));
252
+ $helper = Mage::helper('chronorelais');
253
+ $shipment = false;
254
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
255
+ $orderId = $this->getRequest()->getParam('order_id');
256
+ if ($shipmentId) {
257
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
258
+ } elseif ($orderId) {
259
+ $order = Mage::getModel('sales/order')->load($orderId);
260
+
261
+ /**
262
+ * Check order existing
263
+ */
264
+ if (!$order->getId()) {
265
+ $this->_getSession()->addError($this->__('The order no longer exists.'));
266
+ return false;
267
+ }
268
+ /**
269
+ * Check shipment is available to create separate from invoice
270
+ */
271
+ if ($order->getForcedDoShipmentWithInvoice()) {
272
+ $this->_getSession()->addError($this->__('Cannot do shipment for the order separately from invoice.'));
273
+ return false;
274
+ }
275
+ /**
276
+ * Check shipment create availability
277
+ */
278
+ if (!$order->canShip()) {
279
+ $this->_getSession()->addError($this->__('Cannot do shipment for the order.'));
280
+ return false;
281
+ }
282
+ $savedQtys = $this->_getItemQtys();
283
+
284
+ /* If shipping method is Chronopost => check if shipping weight isn't over limit */
285
+ $chronopostMethods = array('chronopost_chronopost','chronoexpress_chronoexpress','chronorelais_chronorelais','chronopostc10_chronopostC10','chronopostc18_chronopostC18','chronopostcclassic_chronopostCClassic');
286
+ $shippingMethod = $order->getShippingMethod();
287
+ if(in_array($shippingMethod, $chronopostMethods)) {
288
+ $weightShipping = 0;
289
+ $shippingMethod = explode("_", $shippingMethod);
290
+ $shippingMethod = $shippingMethod[0];
291
+ $weight_limit = Mage::getStoreConfig('carriers/'.$shippingMethod.'/weight_limit');
292
+ foreach($savedQtys as $iditem => $qty) {
293
+ $item = $order->getItemById($iditem);
294
+ $weightShipping += $item->getWeight()*$qty;
295
+ }
296
+ if($helper->getConfigWeightUnit() == 'g')
297
+ {
298
+ $weightShipping = $weightShipping / 1000; // conversion g => kg
299
+ }
300
+ if($weightShipping > $weight_limit) {
301
+
302
+ /* Create one shipment by product ordered */
303
+ foreach($savedQtys as $iditem => $qty) {
304
+ $item = $order->getItemById($iditem);
305
+ $weightShipping += $item->getWeight()*$qty;
306
+ for($i = 1; $i <= $qty; $i++) {
307
+ $shipment[] = Mage::getModel('sales/service_order', $order)->prepareShipment(array($item->getId() => '1'));
308
+
309
+ }
310
+ }
311
+
312
+
313
+ //$this->_getSession()->addError($this->__('Le poids total de l\'expédition est supérieur au poids limite pour une livraison '.$shippingMethod));
314
+ //return false;
315
+ }
316
+ }
317
+
318
+
319
+ if(!$shipment)
320
+ {
321
+ $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($savedQtys);
322
+
323
+ $tracks = $this->getRequest()->getPost('tracking');
324
+ if ($tracks) {
325
+ foreach ($tracks as $data) {
326
+ if (empty($data['number'])) {
327
+ Mage::throwException($this->__('Tracking number cannot be empty.'));
328
+ }
329
+ $track = Mage::getModel('sales/order_shipment_track')
330
+ ->addData($data);
331
+ $shipment->addTrack($track);
332
+ }
333
+ }
334
+ }
335
+ }
336
+
337
+ Mage::register('current_shipment', $shipment);
338
+ return $shipment;
339
+ }
340
+
341
+ public function saveAction() {
342
+ $data = $this->getRequest()->getPost('shipment');
343
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
344
+ $orderId = $this->getRequest()->getParam('order_id');
345
+
346
+ try {
347
+
348
+ if ($shipment = $this->_initShipment()) {
349
+ if(is_array($shipment))
350
+ {
351
+ foreach($shipment as $ship) {
352
+ $this->saveAndCreateEtiquette($ship);
353
+ }
354
+ }
355
+ else
356
+ {
357
+ $this->saveAndCreateEtiquette($shipment);
358
+ }
359
+ } else {
360
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
361
+ return;
362
+ }
363
+
364
+ } catch (Mage_Core_Exception $e) {
365
+ $this->_getSession()->addError($e->getMessage());
366
+ } catch (Exception $e) {
367
+ $this->_getSession()->addError($this->__('Can not save shipment: ' . $e->getMessage()));
368
+ }
369
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
370
+ }
371
+
372
+ public function removeaccents($string) {
373
+ $stringToReturn = str_replace(
374
+ 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);
375
+ // Remove all remaining other unknown characters
376
+ $stringToReturn = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $stringToReturn);
377
+ $stringToReturn = preg_replace('/^[\-]+/', '', $stringToReturn);
378
+ $stringToReturn = preg_replace('/[\-]+$/', '', $stringToReturn);
379
+ $stringToReturn = preg_replace('/[\-]{2,}/', ' ', $stringToReturn);
380
+ return $stringToReturn;
381
+ }
382
+
383
+ }
app/code/community/Chronopost/Chronorelais/etc/config.xml CHANGED
@@ -1,359 +1,452 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Chronopost_Chronorelais>
5
- <version>0.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
- <sales>
20
- <rewrite>
21
- <quote_address_total_shipping>Chronopost_Chronorelais_Model_Sales_Quote_Address_Total_Shipping</quote_address_total_shipping>
22
- </rewrite>
23
- </sales>
24
- </models>
25
- <blocks>
26
- <chronorelais>
27
- <class>Chronopost_Chronorelais_Block</class>
28
- </chronorelais>
29
- <adminhtml>
30
- <rewrite>
31
- <sales_order_shipment_view>Chronopost_Chronorelais_Block_Sales_Order_Shipment_View</sales_order_shipment_view>
32
- </rewrite>
33
- </adminhtml>
34
- </blocks>
35
- <helpers>
36
- <chronorelais>
37
- <class>Chronopost_Chronorelais_Helper</class>
38
- </chronorelais>
39
- </helpers>
40
-
41
- <resources>
42
- <sales>
43
- <shipping>
44
- <carriers>
45
- <chronorelais>
46
- <class>Chronopost_Chronorelais_Model_Carrier_Chronorelais</class>
47
- </chronorelais>
48
- <chronopost>
49
- <class>Chronopost_Chronorelais_Model_Carrier_Chronopost</class>
50
- </chronopost>
51
- <chronoexpress>
52
- <class>Chronopost_Chronorelais_Model_Carrier_Chronoexpress</class>
53
- </chronoexpress>
54
- </carriers>
55
- </shipping>
56
- </sales>
57
- <chronorelais_setup>
58
- <setup>
59
- <module>Chronopost_Chronorelais</module>
60
- <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
61
- </setup>
62
- <connection>
63
- <use>core_setup</use>
64
- </connection>
65
- </chronorelais_setup>
66
- <chronorelais_write>
67
- <connection>
68
- <use>core_write</use>
69
- </connection>
70
- </chronorelais_write>
71
-
72
- <chronorelais_read>
73
- <connection>
74
- <use>core_read</use>
75
- </connection>
76
- </chronorelais_read>
77
- </resources>
78
-
79
- <rewrite>
80
- <chronopost_chronorelais_checkout_onepage>
81
- <from><![CDATA[#^/checkout/onepage/#]]></from>
82
- <to>/chronorelais/checkout_onepage/</to>
83
- </chronopost_chronorelais_checkout_onepage>
84
- <chronopost_chronorelais_checkout_multishipping>
85
- <from><![CDATA[#^/checkout/multishipping/#]]></from>
86
- <to>/chronorelais/checkout_multishipping/</to>
87
- </chronopost_chronorelais_checkout_multishipping>
88
- <chronopost_chronorelais_sales_order_shipment>
89
- <from><![CDATA[#^/.*sales_order_shipment/save/#]]></from>
90
- <to>/chronorelais/sales_order_shipment/save/</to>
91
- </chronopost_chronorelais_sales_order_shipment>
92
- </rewrite>
93
-
94
- <fieldsets>
95
- <sales_copy_order_billing_address>
96
- <w_relay_point_code><to_order>*</to_order></w_relay_point_code>
97
- </sales_copy_order_billing_address>
98
- <sales_copy_order_shipping_address>
99
- <w_relay_point_code><to_order>*</to_order></w_relay_point_code>
100
- </sales_copy_order_shipping_address>
101
- <sales_convert_quote_address>
102
- <w_relay_point_code><to_order_address>*</to_order_address><to_customer_address>*</to_customer_address></w_relay_point_code>
103
- </sales_convert_quote_address>
104
- <sales_convert_order_address>
105
- <w_relay_point_code><to_quote_address>*</to_quote_address></w_relay_point_code>
106
- </sales_convert_order_address>
107
- <customer_address>
108
- <w_relay_point_code><to_quote_address>*</to_quote_address></w_relay_point_code>
109
- </customer_address>
110
- </fieldsets>
111
-
112
- </global>
113
-
114
- <frontend>
115
- <routers>
116
- <chronorelais>
117
- <use>standard</use>
118
- <args>
119
- <module>Chronopost_Chronorelais</module>
120
- <frontName>chronorelais</frontName>
121
- </args>
122
- </chronorelais>
123
- </routers>
124
-
125
- <layout>
126
- <updates>
127
- <chronorelais>
128
- <file>chronorelais.xml</file>
129
- </chronorelais>
130
- </updates>
131
- </layout>
132
- <translate>
133
- <modules>
134
- <Chronopost_Chronorelais>
135
- <files>
136
- <default>Chronopost_Chronorelais.csv</default>
137
- </files>
138
- </Chronopost_Chronorelais>
139
- </modules>
140
- </translate>
141
- </frontend>
142
-
143
- <admin>
144
- <routers>
145
- <chronorelais>
146
- <use>admin</use>
147
- <args>
148
- <module>Chronopost_Chronorelais</module>
149
- <frontName>chronorelais</frontName>
150
- </args>
151
- </chronorelais>
152
- </routers>
153
- </admin>
154
-
155
- <adminhtml>
156
- <menu>
157
- <sales>
158
- <children>
159
- <chronorelais translate="title"> <!-- TODO faire marcher : module="chronorelais" (aussi dans les children) -->
160
- <title>Chronopost</title>
161
- <sort_order>15</sort_order>
162
- <children>
163
- <export translate="title">
164
- <title>Export</title>
165
- <action>chronorelais/export</action>
166
- <sort_order>10</sort_order>
167
- </export>
168
- <import translate="title">
169
- <title>Import</title>
170
- <action>chronorelais/import</action>
171
- <sort_order>20</sort_order>
172
- </import>
173
- <impression translate="title" module="sales">
174
- <title>Impression des étiquettes</title>
175
- <action>chronorelais/sales_impression</action>
176
- <sort_order>30</sort_order>
177
- </impression>
178
- </children>
179
- </chronorelais>
180
- </children>
181
- </sales>
182
- </menu>
183
- <acl>
184
- <resources>
185
- <admin>
186
- <children>
187
- <sales>
188
- <children>
189
- <chronorelais translate="title">
190
- <title>Chronopost</title>
191
- <sort_order>15</sort_order>
192
- <children>
193
- <export translate="title">
194
- <title>Export</title>
195
- <sort_order>10</sort_order>
196
- </export>
197
- <import translate="title">
198
- <title>Import</title>
199
- <sort_order>20</sort_order>
200
- </import>
201
- <impression translate="title" module="sales">
202
- <title>Impression des étiquettes</title>
203
- <sort_order>30</sort_order>
204
- </impression>
205
- </children>
206
- </chronorelais>
207
- </children>
208
- </sales>
209
- <system>
210
- <children>
211
- <config>
212
- <children>
213
- <chronorelais translate="title" module="chronorelais">
214
- <title>Chronopost</title>
215
- <sort_order>100</sort_order>
216
- </chronorelais>
217
- </children>
218
- </config>
219
- </children>
220
- </system>
221
- </children>
222
- </admin>
223
- </resources>
224
- </acl>
225
-
226
- <translate>
227
- <modules>
228
- <Chronopost_Chronorelais>
229
- <files>
230
- <default>Chronopost_Chronorelais.csv</default>
231
- </files>
232
- </Chronopost_Chronorelais>
233
- </modules>
234
- </translate>
235
- </adminhtml>
236
-
237
- <default>
238
- <chronorelais>
239
- <shipping>
240
- <google_map_api>ABQIAAAAZvdukOwsytNocL5anZKqZxS51Nc8ngbKeRYi0kVLSLeRaqOKHRSLs6O150txpwWCDcct2mH4X-G6OA</google_map_api>
241
- <tracking_view_url><![CDATA[http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?lang=fr_FR&listeNumeros={tracking_number}]]></tracking_view_url>
242
- </shipping>
243
- <export_css>
244
- <file_extension>.chr</file_extension>
245
- <file_charset>ASCII-7</file_charset>
246
- <endofline_character>crlf</endofline_character>
247
- <field_delimiter>none</field_delimiter>
248
- <field_separator>;</field_separator>
249
- </export_css>
250
- <export_cso>
251
- <file_extension>.txt</file_extension>
252
- <file_charset>ISO-8859-1</file_charset>
253
- <endofline_character>crlf</endofline_character>
254
- <field_delimiter>none</field_delimiter>
255
- <field_separator>;</field_separator>
256
- </export_cso>
257
- <import>
258
- <default_tracking_title>Chronopost - Chronopost livraison express à domicile</default_tracking_title>
259
- <send_email>1</send_email>
260
- <shipping_comment></shipping_comment>
261
- <include_comment>0</include_comment>
262
- </import>
263
- </chronorelais>
264
- <carriers>
265
- <chronopost>
266
- <active>0</active>
267
- <title>Chronopost</title>
268
- <model>Chronopost_Chronorelais_Model_Carrier_Chronopost</model>
269
- <tracking_view_url></tracking_view_url>
270
- <config>
271
- # Chronopost
272
- {
273
- label: "Chronopost livraison express à domicile",
274
- code: "chronopost",
275
- description: "Colis livré le lendemain avant 13h, à l’adresse de votre choix.
276
- Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.
277
- En cas d’absence, le colis est mis en instance dans le bureau de Poste le plus proche.",
278
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
279
- destination: "FR,MC",
280
- 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}",
281
- }
282
-
283
- # Chronopost Corse
284
- {
285
- label: "Chronopost livraison express à domicile en Corse",
286
- code: "chronopost_corse",
287
- description: "Colis livré le lendemain avant 13h, à l’adresse de votre choix.
288
- Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.
289
- En cas d’absence, le colis est mis en instance dans le bureau de Poste le plus proche.",
290
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
291
- destination: "FR(20*)",
292
- 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}",
293
- }
294
- </config>
295
- <weight_limit>30</weight_limit>
296
- <quickcost_url>http://wsshipping.chronopost.fr/wsQuickcost/services/ServiceQuickCost?wsdl</quickcost_url>
297
- <logo_url>chronopost.png</logo_url>
298
- <debug>0</debug>
299
- <stop_to_first_match>0</stop_to_first_match>
300
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
301
- <sort_order>1</sort_order>
302
- </chronopost>
303
- <chronoexpress>
304
- <active>0</active>
305
- <title>Chronopost</title>
306
- <model>Chronopost_Chronorelais_Model_Carrier_Chronoexpress</model>
307
- <tracking_view_url></tracking_view_url>
308
- <config>
309
- # Chronoexpress
310
- {
311
- label: "Chronopost livraison express partout dans le monde",
312
- code: "chronoexpress",
313
- description: "L'Europe livrée en 1 à 3 jours et le reste du monde en 2 à 5 jours.
314
- Délai à compter de la prise en charge du colis par Chronopost.",
315
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
316
- 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",
317
- 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}",
318
- }
319
- </config>
320
- <weight_limit>30</weight_limit>
321
- <quickcost_url>http://wsshipping.chronopost.fr/wsQuickcost/services/ServiceQuickCost?wsdl</quickcost_url>
322
- <logo_url>Logo-Chronopost.jpg</logo_url>
323
- <debug>0</debug>
324
- <stop_to_first_match>0</stop_to_first_match>
325
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
326
- <sort_order>1</sort_order>
327
- </chronoexpress>
328
- <chronorelais>
329
- <active>0</active>
330
- <title>Chrono Relais</title>
331
- <model>Chronopost_Chronorelais_Model_Carrier_Chronorelais</model>
332
- <tracking_view_url></tracking_view_url>
333
- <config>
334
- # Chronorelais
335
- {
336
- label: "Chrono Relais : livraison express en relais Pickup",
337
- code: "chronorelais",
338
- description: "Colis livré en Chronopost le lendemain avant 13 h dans le relais Pickup de votre choix.
339
- Vous êtes averti par email ou SMS de l’arrivée du colis dans le point.
340
- Délai à compter de la prise en charge du colis par Chronopost.",
341
- tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
342
- destination: "FR",
343
- 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}",
344
- }
345
-
346
- # Voir exemple sur mode "Chronopost" pour un tarif spécifique pour la Corse
347
- </config>
348
- <weight_limit>20</weight_limit>
349
- <quickcost_url>http://wsshipping.chronopost.fr/wsQuickcost/services/ServiceQuickCost?wsdl</quickcost_url>
350
- <logo_url>chronorelais.png</logo_url>
351
- <debug>0</debug>
352
- <stop_to_first_match>0</stop_to_first_match>
353
- <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
354
- <sort_order>2</sort_order>
355
- </chronorelais>
356
- </carriers>
357
- </default>
358
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
359
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Chronopost_Chronorelais>
5
+ <version>1.0.1</version>
6
+ <depends>
7
+ <Mage_Shipping />
8
+ <Mage_Sales />
9
+ <Mage_Adminhtml />
10
+ </depends>
11
+ </Chronopost_Chronorelais>
12
+ </modules>
13
+
14
+ <global>
15
+ <models>
16
+ <chronorelais>
17
+ <class>Chronopost_Chronorelais_Model</class>
18
+ </chronorelais>
19
+ <sales>
20
+ <rewrite>
21
+ <quote_address_total_shipping>Chronopost_Chronorelais_Model_Sales_Quote_Address_Total_Shipping</quote_address_total_shipping>
22
+ </rewrite>
23
+ </sales>
24
+ </models>
25
+ <blocks>
26
+ <chronorelais>
27
+ <class>Chronopost_Chronorelais_Block</class>
28
+ </chronorelais>
29
+ <adminhtml>
30
+ <rewrite>
31
+ <sales_order_shipment_view>Chronopost_Chronorelais_Block_Sales_Order_Shipment_View</sales_order_shipment_view>
32
+ </rewrite>
33
+ </adminhtml>
34
+ </blocks>
35
+ <helpers>
36
+ <chronorelais>
37
+ <class>Chronopost_Chronorelais_Helper</class>
38
+ </chronorelais>
39
+ </helpers>
40
+
41
+ <resources>
42
+ <sales>
43
+ <shipping>
44
+ <carriers>
45
+ <chronorelais>
46
+ <class>Chronopost_Chronorelais_Model_Carrier_Chronorelais</class>
47
+ </chronorelais>
48
+ <chronopost>
49
+ <class>Chronopost_Chronorelais_Model_Carrier_Chronopost</class>
50
+ </chronopost>
51
+ <chronoexpress>
52
+ <class>Chronopost_Chronorelais_Model_Carrier_Chronoexpress</class>
53
+ </chronoexpress>
54
+ </carriers>
55
+ </shipping>
56
+ </sales>
57
+ <chronorelais_setup>
58
+ <setup>
59
+ <module>Chronopost_Chronorelais</module>
60
+ <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
61
+ </setup>
62
+ <connection>
63
+ <use>core_setup</use>
64
+ </connection>
65
+ </chronorelais_setup>
66
+ <chronorelais_write>
67
+ <connection>
68
+ <use>core_write</use>
69
+ </connection>
70
+ </chronorelais_write>
71
+
72
+ <chronorelais_read>
73
+ <connection>
74
+ <use>core_read</use>
75
+ </connection>
76
+ </chronorelais_read>
77
+ </resources>
78
+
79
+ <rewrite>
80
+ <chronopost_chronorelais_checkout_onepage>
81
+ <from><![CDATA[#^/checkout/onepage/#]]>
82
+ </from>
83
+ <to>/chronorelais/checkout_onepage/</to>
84
+ </chronopost_chronorelais_checkout_onepage>
85
+ <chronopost_chronorelais_checkout_multishipping>
86
+ <from><![CDATA[#^/checkout/multishipping/#]]>
87
+ </from>
88
+ <to>/chronorelais/checkout_multishipping/</to>
89
+ </chronopost_chronorelais_checkout_multishipping>
90
+ <chronopost_chronorelais_sales_order_shipment>
91
+ <from><![CDATA[#^/.*sales_order_shipment/save/#]]>
92
+ </from>
93
+ <to>/chronorelais/sales_order_shipment/save/</to>
94
+ </chronopost_chronorelais_sales_order_shipment>
95
+ </rewrite>
96
+
97
+ <fieldsets>
98
+ <sales_copy_order_billing_address>
99
+ <w_relay_point_code>
100
+ <to_order>*</to_order>
101
+ </w_relay_point_code>
102
+ </sales_copy_order_billing_address>
103
+ <sales_copy_order_shipping_address>
104
+ <w_relay_point_code>
105
+ <to_order>*</to_order>
106
+ </w_relay_point_code>
107
+ </sales_copy_order_shipping_address>
108
+ <sales_convert_quote_address>
109
+ <w_relay_point_code>
110
+ <to_order_address>*</to_order_address>
111
+ <to_customer_address>*</to_customer_address>
112
+ </w_relay_point_code>
113
+ </sales_convert_quote_address>
114
+ <sales_convert_order_address>
115
+ <w_relay_point_code>
116
+ <to_quote_address>*</to_quote_address>
117
+ </w_relay_point_code>
118
+ </sales_convert_order_address>
119
+ <customer_address>
120
+ <w_relay_point_code>
121
+ <to_quote_address>*</to_quote_address>
122
+ </w_relay_point_code>
123
+ </customer_address>
124
+ </fieldsets>
125
+
126
+ </global>
127
+
128
+ <frontend>
129
+ <routers>
130
+ <chronorelais>
131
+ <use>standard</use>
132
+ <args>
133
+ <module>Chronopost_Chronorelais</module>
134
+ <frontName>chronorelais</frontName>
135
+ </args>
136
+ </chronorelais>
137
+ </routers>
138
+
139
+ <layout>
140
+ <updates>
141
+ <chronorelais>
142
+ <file>chronorelais.xml</file>
143
+ </chronorelais>
144
+ </updates>
145
+ </layout>
146
+ <translate>
147
+ <modules>
148
+ <Chronopost_Chronorelais>
149
+ <files>
150
+ <default>Chronopost_Chronorelais.csv</default>
151
+ </files>
152
+ </Chronopost_Chronorelais>
153
+ </modules>
154
+ </translate>
155
+ </frontend>
156
+
157
+ <admin>
158
+ <routers>
159
+ <chronorelais>
160
+ <use>admin</use>
161
+ <args>
162
+ <module>Chronopost_Chronorelais</module>
163
+ <frontName>chronorelais</frontName>
164
+ </args>
165
+ </chronorelais>
166
+ </routers>
167
+ </admin>
168
+
169
+ <adminhtml>
170
+ <layout>
171
+ <updates>
172
+ <chronorelais>
173
+ <file>chronorelais.xml</file>
174
+ </chronorelais>
175
+ </updates>
176
+ </layout>
177
+ <menu>
178
+ <sales>
179
+ <children>
180
+ <chronorelais translate="title"> <!-- TODO faire marcher : module="chronorelais" (aussi dans les children) -->
181
+ <title>Chronopost</title>
182
+ <sort_order>15</sort_order>
183
+ <children>
184
+ <export translate="title">
185
+ <title>Export</title>
186
+ <action>chronorelais/export</action>
187
+ <sort_order>10</sort_order>
188
+ </export>
189
+ <import translate="title">
190
+ <title>Import</title>
191
+ <action>chronorelais/import</action>
192
+ <sort_order>20</sort_order>
193
+ </import>
194
+ <impression translate="title" module="sales">
195
+ <title>Impression des étiquettes</title>
196
+ <action>chronorelais/sales_impression</action>
197
+ <sort_order>30</sort_order>
198
+ </impression>
199
+ <bordereau translate="title" module="sales">
200
+ <title>Bordereau de fin de journée</title>
201
+ <action>chronorelais/sales_bordereau</action>
202
+ <sort_order>40</sort_order>
203
+ </bordereau>
204
+ </children>
205
+ </chronorelais>
206
+ </children>
207
+ </sales>
208
+ </menu>
209
+ <acl>
210
+ <resources>
211
+ <admin>
212
+ <children>
213
+ <sales>
214
+ <children>
215
+ <chronorelais translate="title">
216
+ <title>Chronopost</title>
217
+ <sort_order>15</sort_order>
218
+ <children>
219
+ <export translate="title">
220
+ <title>Export</title>
221
+ <sort_order>10</sort_order>
222
+ </export>
223
+ <import translate="title">
224
+ <title>Import</title>
225
+ <sort_order>20</sort_order>
226
+ </import>
227
+ <impression translate="title" module="sales">
228
+ <title>Impression des étiquettes</title>
229
+ <sort_order>30</sort_order>
230
+ </impression>
231
+ </children>
232
+ </chronorelais>
233
+ </children>
234
+ </sales>
235
+ <system>
236
+ <children>
237
+ <config>
238
+ <children>
239
+ <chronorelais translate="title" module="chronorelais">
240
+ <title>Chronopost</title>
241
+ <sort_order>100</sort_order>
242
+ </chronorelais>
243
+ </children>
244
+ </config>
245
+ </children>
246
+ </system>
247
+ </children>
248
+ </admin>
249
+ </resources>
250
+ </acl>
251
+
252
+ <translate>
253
+ <modules>
254
+ <Chronopost_Chronorelais>
255
+ <files>
256
+ <default>Chronopost_Chronorelais.csv</default>
257
+ </files>
258
+ </Chronopost_Chronorelais>
259
+ </modules>
260
+ </translate>
261
+
262
+ </adminhtml>
263
+
264
+ <default>
265
+ <chronorelais>
266
+ <shipping>
267
+ <google_map_api>ABQIAAAAZvdukOwsytNocL5anZKqZxS51Nc8ngbKeRYi0kVLSLeRaqOKHRSLs6O150txpwWCDcct2mH4X-G6OA</google_map_api>
268
+ <tracking_view_url><![CDATA[http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?lang=fr_FR&listeNumeros={tracking_number}]]>
269
+ </tracking_view_url>
270
+ <gs_path>/usr/bin/gs</gs_path>
271
+ </shipping>
272
+ <export_css>
273
+ <file_extension>.chr</file_extension>
274
+ <file_charset>ASCII-7</file_charset>
275
+ <endofline_character>crlf</endofline_character>
276
+ <field_delimiter>none</field_delimiter>
277
+ <field_separator>;</field_separator>
278
+ </export_css>
279
+ <export_cso>
280
+ <file_extension>.txt</file_extension>
281
+ <file_charset>ISO-8859-1</file_charset>
282
+ <endofline_character>crlf</endofline_character>
283
+ <field_delimiter>none</field_delimiter>
284
+ <field_separator>;</field_separator>
285
+ </export_cso>
286
+ <import>
287
+ <default_tracking_title>Chronopost - Chronopost livraison express à domicile</default_tracking_title>
288
+ <send_email>1</send_email>
289
+ <shipping_comment></shipping_comment>
290
+ <include_comment>0</include_comment>
291
+ </import>
292
+ </chronorelais>
293
+ <carriers>
294
+ <chronopost>
295
+ <active>0</active>
296
+ <title>Chronopost-Livraison express à domicile avant 13H</title>
297
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronopost</model>
298
+ <tracking_view_url></tracking_view_url>
299
+ <config>
300
+ # Chronopost
301
+ {
302
+ label: "Chronopost-Livraison express à domicile avant 13H",
303
+ code: "chronopost",
304
+ description: "Colis livré le lendemain matin avant 13h à votre domicile. La veille de la livraison, vous êtes averti par e-mail et SMS.
305
+ Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
306
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
307
+ destination: "FR,MC",
308
+ fees: "{table {cart.weight} in 2.00:17.56, 3.00:18.40, 4.00:19.24, 5.00:20.08, 6.00:20.92, 7.00:21.76, 8.00:22.60, 9.00:23.44, 10.00:24.28, 15.00:28.48, 20.00:32.68, 25.00:36.88, 30.00:41.08}",
309
+ }
310
+
311
+ # Chronopost Corse
312
+ {
313
+ label: "Chronopost livraison express à domicile en Corse",
314
+ code: "chronopost_corse",
315
+ description: "Colis livré le lendemain avant 13h, à l’adresse de votre choix.
316
+ Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.
317
+ En cas d’absence, le colis est mis en instance dans le bureau de Poste le plus proche.",
318
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
319
+ destination: "FR(20*)",
320
+ fees: "{table {cart.weight} in 2.00:19.56, 3.00:20.40, 4.00:21.24, 5.00:22.08, 6.00:22.92, 7.00:23.76, 8.00:24.60, 9.00:25.44, 10.00:26.28, 15.00:30.48, 20.00:34.68, 25.00:38.88, 30.00:43.08}",
321
+ }
322
+ </config>
323
+ <weight_limit>30</weight_limit>
324
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
325
+ <logo_url>chronopost.png</logo_url>
326
+ <debug>0</debug>
327
+ <stop_to_first_match>0</stop_to_first_match>
328
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
329
+ <sort_order>1</sort_order>
330
+ </chronopost>
331
+ <chronoexpress>
332
+ <active>0</active>
333
+ <title>Chronopost Livraison express partout dans le monde</title>
334
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronoexpress</model>
335
+ <tracking_view_url></tracking_view_url>
336
+ <config>
337
+ # Chronoexpress
338
+ {
339
+ label: "Chronopost Livraison express partout dans le monde",
340
+ code: "chronoexpress",
341
+ description: "Colis livré en 1 à 3 jours vers l'Europe, en 48h vers les DOM et en 2 à 5 jours vers le reste du monde.
342
+ Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
343
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
344
+ destination: "DE,BE,BG,CY,DK,ES,EE,FI,GR,IE,IT,LV,LT,MT,NL,PL,PT,CZ,RO,SK,AT,HU,LU,GB,SI,SE,GF,YT,GP,MQ,RE",
345
+ fees: "{table {cart.weight} in 0.50:30.94, 1.00:45.07, 1.50:55.26, 2.00:65.45, 2.50:75.64, 3.00:85.83, 3.50:88.72, 4.00:91.61, 4.50:94.50, 5.00:97.39, 30.00:97.39}",
346
+ }
347
+ </config>
348
+ <weight_limit>30</weight_limit>
349
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
350
+ <logo_url>Logo-Chronopost.jpg</logo_url>
351
+ <debug>0</debug>
352
+ <stop_to_first_match>0</stop_to_first_match>
353
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
354
+ <sort_order>1</sort_order>
355
+ </chronoexpress>
356
+ <chronorelais>
357
+ <active>0</active>
358
+ <title>Chrono Relais</title>
359
+ <model>Chronopost_Chronorelais_Model_Carrier_Chronorelais</model>
360
+ <tracking_view_url></tracking_view_url>
361
+ <config>
362
+ # Chronorelais
363
+ {
364
+ label: "Chrono Relais : livraison express en relais Pickup",
365
+ code: "chronorelais",
366
+ description: "Colis livré en Chronopost le lendemain avant 13 h dans le relais Pickup de votre choix.
367
+ Vous êtes averti par email ou SMS de l’arrivée du colis dans le point.
368
+ Délai à compter de la prise en charge du colis par Chronopost.",
369
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
370
+ destination: "FR",
371
+ fees: "{table {cart.weight} in 2.00:17.56, 3.00:18.40, 4.00:19.24, 5.00:20.08, 6.00:20.92, 7.00:21.76, 8.00:22.60, 9.00:23.44, 10.00:24.28, 15.00:28.48, 20.00:32.68, 25.00:36.88, 30.00:41.08}",
372
+ }
373
+
374
+ # Voir exemple sur mode "Chronopost" pour un tarif spécifique pour la Corse
375
+ </config>
376
+ <weight_limit>20</weight_limit>
377
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
378
+ <logo_url>chronorelais.png</logo_url>
379
+ <debug>0</debug>
380
+ <stop_to_first_match>0</stop_to_first_match>
381
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
382
+ <sort_order>2</sort_order>
383
+ </chronorelais>
384
+ <chronopostc10>
385
+ <active>0</active>
386
+ <title>Chronopost-Livraison express à domicile avant 10H</title>
387
+ <model>Chronopost_Chronorelais_Model_Carrier_ChronopostC10</model>
388
+ <tracking_view_url></tracking_view_url>
389
+ <config>
390
+ # ChronopostC10
391
+ {
392
+ label: "Chronopost-Livraison express à domicile avant 10H",
393
+ code: "chronopostC10",
394
+ description: "Colis livré le lendemain matin avant 10h à votre domicile. La veille de la livraison, vous êtes averti par e-mail et SMS.
395
+ Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
396
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
397
+ destination: "FR,MC",
398
+ fees: "{table {cart.weight} in 2.00:17.56, 3.00:18.40, 4.00:19.24, 5.00:20.08, 6.00:20.92, 7.00:21.76, 8.00:22.60, 9.00:23.44, 10.00:24.28, 15.00:28.48, 20.00:32.68, 25.00:36.88, 30.00:41.08}",
399
+ }
400
+ </config>
401
+ <weight_limit>30</weight_limit>
402
+ <quickcost_url>http://wsshipping.chronopost.fr/wsQuickcost/services/ServiceQuickCost?wsdl</quickcost_url>
403
+ <logo_url>chronopost.png</logo_url>
404
+ <debug>0</debug>
405
+ <stop_to_first_match>0</stop_to_first_match>
406
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
407
+ <sort_order>3</sort_order>
408
+ </chronopostc10>
409
+ <chronopostc18>
410
+ <active>0</active>
411
+ <title>Chronopost-Livraison express à domicile avant 18H</title>
412
+ <model>Chronopost_Chronorelais_Model_Carrier_ChronopostC18</model>
413
+ <tracking_view_url></tracking_view_url>
414
+ <config>
415
+ # ChronopostC18
416
+ {
417
+ label: "Chronopost-Livraison express à domicile avant 18H",
418
+ code: "chronopostC18",
419
+ description: "Colis livré le lendemain matin avant 18h à votre domicile. La veille de la livraison, vous êtes averti par e-mail et SMS.
420
+ Délai à compter de la prise en charge du colis par Chronopost, pour une livraison en France métropolitaine.",
421
+ tracking_url: "http://www.fr.chronopost.com/fr/tracking/result?listeNumeros={tracking_number}",
422
+ destination: "FR,MC",
423
+ fees: "{table {cart.weight} in 2.00:17.56, 3.00:18.40, 4.00:19.24, 5.00:20.08, 6.00:20.92, 7.00:21.76, 8.00:22.60, 9.00:23.44, 10.00:24.28, 15.00:28.48, 20.00:32.68, 25.00:36.88, 30.00:41.08}",
424
+ }
425
+ </config>
426
+ <weight_limit>30</weight_limit>
427
+ <quickcost>0</quickcost>
428
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
429
+ <logo_url>chronopost.png</logo_url>
430
+ <debug>0</debug>
431
+ <stop_to_first_match>0</stop_to_first_match>
432
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
433
+ <sort_order>4</sort_order>
434
+ </chronopostc18>
435
+ <chronopostcclassic>
436
+ <active>0</active>
437
+ <title>Chronopost Livraison dans certaines villes Européennes</title>
438
+ <model>Chronopost_Chronorelais_Model_Carrier_ChronopostCClassic</model>
439
+ <tracking_view_url></tracking_view_url>
440
+ <config></config>
441
+ <weight_limit>30</weight_limit>
442
+ <quickcost_url>https://www.chronopost.fr/quickcost-cxf/QuickcostServiceWS?wsdl</quickcost_url>
443
+ <logo_url>chronopost.png</logo_url>
444
+ <debug>0</debug>
445
+ <stop_to_first_match>0</stop_to_first_match>
446
+ <!--<specificerrmsg>This shipping method is currently unavailable.</specificerrmsg>-->
447
+ <sort_order>5</sort_order>
448
+ </chronopostcclassic>
449
+ </carriers>
450
+ </default>
451
+
452
  </config>
app/code/community/Chronopost/Chronorelais/etc/system.xml CHANGED
@@ -1,966 +1,1546 @@
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
- <source_model>adminhtml/system_config_source_yesno</source_model>
24
- <sort_order>1</sort_order>
25
- <show_in_default>1</show_in_default>
26
- <show_in_website>1</show_in_website>
27
- <show_in_store>1</show_in_store>
28
- </active>
29
- <title translate="label">
30
- <label>Title</label>
31
- <frontend_type>text</frontend_type>
32
- <sort_order>2</sort_order>
33
- <show_in_default>1</show_in_default>
34
- <show_in_website>1</show_in_website>
35
- <show_in_store>1</show_in_store>
36
- </title>
37
- <config translate="label">
38
- <label>Configuration</label>
39
- <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
40
- <comment>{configuration_syntax_help}</comment>
41
- <frontend_type>textarea</frontend_type>
42
- <sort_order>3</sort_order>
43
- <show_in_default>1</show_in_default>
44
- <show_in_website>1</show_in_website>
45
- <show_in_store>1</show_in_store>
46
- </config>
47
- <weight_limit translate="label">
48
- <label>Weight Limit</label>
49
- <frontend_type>text</frontend_type>
50
- <comment>in Kg</comment>
51
- <sort_order>7</sort_order>
52
- <show_in_default>1</show_in_default>
53
- <show_in_website>1</show_in_website>
54
- <show_in_store>1</show_in_store>
55
- </weight_limit>
56
- <quickcost translate="label">
57
- <label>Quickcost</label>
58
- <frontend_type>select</frontend_type>
59
- <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
60
- <source_model>adminhtml/system_config_source_yesno</source_model>
61
- <sort_order>10</sort_order>
62
- <show_in_default>1</show_in_default>
63
- <show_in_website>1</show_in_website>
64
- <show_in_store>0</show_in_store>
65
- </quickcost>
66
- <quickcost_url>
67
- <label>Quickcost Url</label>
68
- <frontend_type>text</frontend_type>
69
- <sort_order>11</sort_order>
70
- <show_in_default>1</show_in_default>
71
- <show_in_website>1</show_in_website>
72
- <show_in_store>0</show_in_store>
73
- </quickcost_url>
74
- <free_shipping_enable translate="label">
75
- <label>Free Shipping on the Amount</label>
76
- <frontend_type>select</frontend_type>
77
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
78
- <sort_order>12</sort_order>
79
- <show_in_default>1</show_in_default>
80
- <show_in_website>1</show_in_website>
81
- <show_in_store>1</show_in_store>
82
- </free_shipping_enable>
83
- <free_shipping_subtotal translate="label">
84
- <label>Minimum Amount for Free Shipping</label>
85
- <frontend_type>text</frontend_type>
86
- <sort_order>13</sort_order>
87
- <show_in_default>1</show_in_default>
88
- <show_in_website>1</show_in_website>
89
- <show_in_store>0</show_in_store>
90
- </free_shipping_subtotal>
91
- <application_fee translate="label">
92
- <label>Application Fee</label>
93
- <frontend_type>text</frontend_type>
94
- <sort_order>14</sort_order>
95
- <show_in_default>1</show_in_default>
96
- <show_in_website>1</show_in_website>
97
- <show_in_store>1</show_in_store>
98
- </application_fee>
99
- <handling_fee translate="label">
100
- <label>Handling Fee</label>
101
- <frontend_type>text</frontend_type>
102
- <sort_order>15</sort_order>
103
- <show_in_default>1</show_in_default>
104
- <show_in_website>1</show_in_website>
105
- <show_in_store>1</show_in_store>
106
- </handling_fee>
107
- <logo_url>
108
- <label>Logo Url</label>
109
- <frontend_type>text</frontend_type>
110
- <comment>{logo_ulr_help}</comment>
111
- <sort_order>18</sort_order>
112
- <show_in_default>1</show_in_default>
113
- <show_in_website>1</show_in_website>
114
- <show_in_store>1</show_in_store>
115
- </logo_url>
116
- <debug>
117
- <label>Debug</label>
118
- <comment>{debug_help}</comment>
119
- <frontend_type>text</frontend_type>
120
- <sort_order>20</sort_order>
121
- <show_in_default>1</show_in_default>
122
- <show_in_website>1</show_in_website>
123
- <show_in_store>1</show_in_store>
124
- </debug>
125
- <!--<stop_to_first_match translate="label">
126
- <label>Stop to first match</label>
127
- <frontend_type>select</frontend_type>
128
- <source_model>adminhtml/system_config_source_yesno</source_model>
129
- <sort_order>22</sort_order>
130
- <show_in_default>1</show_in_default>
131
- <show_in_website>1</show_in_website>
132
- <show_in_store>1</show_in_store>
133
- </stop_to_first_match>-->
134
- <deliver_on_saturday translate="label comment">
135
- <label>Livraison le Samedi</label>
136
- <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
137
- <frontend_type>select</frontend_type>
138
- <source_model>adminhtml/system_config_source_yesno</source_model>
139
- <sort_order>23</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
- </deliver_on_saturday>
144
- <!--<showmethod translate="label">
145
- <label>Show Method if Not Applicable</label>
146
- <frontend_type>select</frontend_type>
147
- <sort_order>30</sort_order>
148
- <frontend_class>shipping-skip-hide</frontend_class>
149
- <source_model>adminhtml/system_config_source_yesno</source_model>
150
- <show_in_default>1</show_in_default>
151
- <show_in_website>1</show_in_website>
152
- <show_in_store>0</show_in_store>
153
- </showmethod>
154
- <specificerrmsg translate="label">
155
- <label>Displayed Error Message</label>
156
- <frontend_type>textarea</frontend_type>
157
- <sort_order>31</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
- </specificerrmsg>-->
162
- <sort_order translate="label">
163
- <label>Sort order</label>
164
- <frontend_type>text</frontend_type>
165
- <sort_order>100</sort_order>
166
- <show_in_default>1</show_in_default>
167
- <show_in_website>1</show_in_website>
168
- <show_in_store>1</show_in_store>
169
- </sort_order>
170
- </fields>
171
- </chronopost>
172
-
173
- <chronoexpress translate="label">
174
- <label>Chrono Express</label>
175
- <frontend_type>text</frontend_type>
176
- <sort_order>21</sort_order>
177
- <show_in_default>1</show_in_default>
178
- <show_in_website>1</show_in_website>
179
- <show_in_store>1</show_in_store>
180
- <fields>
181
- <active translate="label">
182
- <label>Enabled</label>
183
- <frontend_type>select</frontend_type>
184
- <source_model>adminhtml/system_config_source_yesno</source_model>
185
- <sort_order>1</sort_order>
186
- <show_in_default>1</show_in_default>
187
- <show_in_website>1</show_in_website>
188
- <show_in_store>1</show_in_store>
189
- </active>
190
- <title translate="label">
191
- <label>Title</label>
192
- <frontend_type>text</frontend_type>
193
- <sort_order>2</sort_order>
194
- <show_in_default>1</show_in_default>
195
- <show_in_website>1</show_in_website>
196
- <show_in_store>1</show_in_store>
197
- </title>
198
- <config translate="label">
199
- <label>Configuration</label>
200
- <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
201
- <comment>{configuration_syntax_help}</comment>
202
- <frontend_type>textarea</frontend_type>
203
- <sort_order>3</sort_order>
204
- <show_in_default>1</show_in_default>
205
- <show_in_website>1</show_in_website>
206
- <show_in_store>1</show_in_store>
207
- </config>
208
- <weight_limit translate="label">
209
- <label>Weight Limit</label>
210
- <frontend_type>text</frontend_type>
211
- <comment>in Kg</comment>
212
- <sort_order>7</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
- </weight_limit>
217
- <quickcost translate="label">
218
- <label>Quickcost</label>
219
- <frontend_type>select</frontend_type>
220
- <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
221
- <source_model>adminhtml/system_config_source_yesno</source_model>
222
- <sort_order>10</sort_order>
223
- <show_in_default>1</show_in_default>
224
- <show_in_website>1</show_in_website>
225
- <show_in_store>0</show_in_store>
226
- </quickcost>
227
- <quickcost_url>
228
- <label>Quickcost Url</label>
229
- <frontend_type>text</frontend_type>
230
- <sort_order>11</sort_order>
231
- <show_in_default>1</show_in_default>
232
- <show_in_website>1</show_in_website>
233
- <show_in_store>0</show_in_store>
234
- </quickcost_url>
235
- <free_shipping_enable translate="label">
236
- <label>Free Shipping on the Amount</label>
237
- <frontend_type>select</frontend_type>
238
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
239
- <sort_order>12</sort_order>
240
- <show_in_default>1</show_in_default>
241
- <show_in_website>1</show_in_website>
242
- <show_in_store>1</show_in_store>
243
- </free_shipping_enable>
244
- <free_shipping_subtotal translate="label">
245
- <label>Minimum Amount for Free Shipping</label>
246
- <frontend_type>text</frontend_type>
247
- <sort_order>13</sort_order>
248
- <show_in_default>1</show_in_default>
249
- <show_in_website>1</show_in_website>
250
- <show_in_store>0</show_in_store>
251
- </free_shipping_subtotal>
252
- <application_fee translate="label">
253
- <label>Application Fee</label>
254
- <frontend_type>text</frontend_type>
255
- <sort_order>14</sort_order>
256
- <show_in_default>1</show_in_default>
257
- <show_in_website>1</show_in_website>
258
- <show_in_store>1</show_in_store>
259
- </application_fee>
260
- <handling_fee translate="label">
261
- <label>Handling Fee</label>
262
- <frontend_type>text</frontend_type>
263
- <sort_order>15</sort_order>
264
- <show_in_default>1</show_in_default>
265
- <show_in_website>1</show_in_website>
266
- <show_in_store>1</show_in_store>
267
- </handling_fee>
268
- <logo_url>
269
- <label>Logo Url</label>
270
- <frontend_type>text</frontend_type>
271
- <comment>{logo_ulr_help}</comment>
272
- <sort_order>18</sort_order>
273
- <show_in_default>1</show_in_default>
274
- <show_in_website>1</show_in_website>
275
- <show_in_store>1</show_in_store>
276
- </logo_url>
277
- <debug>
278
- <label>Debug</label>
279
- <comment>{debug_help}</comment>
280
- <frontend_type>text</frontend_type>
281
- <sort_order>20</sort_order>
282
- <show_in_default>1</show_in_default>
283
- <show_in_website>1</show_in_website>
284
- <show_in_store>1</show_in_store>
285
- </debug>
286
- <!--<stop_to_first_match translate="label">
287
- <label>Stop to first match</label>
288
- <frontend_type>select</frontend_type>
289
- <source_model>adminhtml/system_config_source_yesno</source_model>
290
- <sort_order>22</sort_order>
291
- <show_in_default>1</show_in_default>
292
- <show_in_website>1</show_in_website>
293
- <show_in_store>1</show_in_store>
294
- </stop_to_first_match>-->
295
- <!-- deliver_on_saturday not included in chronoexpress only -->
296
- <!--<showmethod translate="label">
297
- <label>Show Method if Not Applicable</label>
298
- <frontend_type>select</frontend_type>
299
- <sort_order>30</sort_order>
300
- <frontend_class>shipping-skip-hide</frontend_class>
301
- <source_model>adminhtml/system_config_source_yesno</source_model>
302
- <show_in_default>1</show_in_default>
303
- <show_in_website>1</show_in_website>
304
- <show_in_store>0</show_in_store>
305
- </showmethod>
306
- <specificerrmsg translate="label">
307
- <label>Displayed Error Message</label>
308
- <frontend_type>textarea</frontend_type>
309
- <sort_order>31</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
- </specificerrmsg>-->
314
- <sort_order translate="label">
315
- <label>Sort order</label>
316
- <frontend_type>text</frontend_type>
317
- <sort_order>100</sort_order>
318
- <show_in_default>1</show_in_default>
319
- <show_in_website>1</show_in_website>
320
- <show_in_store>1</show_in_store>
321
- </sort_order>
322
- </fields>
323
- </chronoexpress>
324
-
325
- <chronorelais translate="label">
326
- <label>Chrono Relais</label>
327
- <frontend_type>text</frontend_type>
328
- <sort_order>22</sort_order>
329
- <show_in_default>1</show_in_default>
330
- <show_in_website>1</show_in_website>
331
- <show_in_store>1</show_in_store>
332
- <fields>
333
- <active translate="label">
334
- <label>Enabled</label>
335
- <frontend_type>select</frontend_type>
336
- <source_model>adminhtml/system_config_source_yesno</source_model>
337
- <sort_order>1</sort_order>
338
- <show_in_default>1</show_in_default>
339
- <show_in_website>1</show_in_website>
340
- <show_in_store>1</show_in_store>
341
- </active>
342
- <title translate="label">
343
- <label>Title</label>
344
- <frontend_type>text</frontend_type>
345
- <sort_order>2</sort_order>
346
- <show_in_default>1</show_in_default>
347
- <show_in_website>1</show_in_website>
348
- <show_in_store>1</show_in_store>
349
- </title>
350
- <config translate="label">
351
- <label>Configuration</label>
352
- <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
353
- <comment>{configuration_syntax_help}</comment>
354
- <frontend_type>textarea</frontend_type>
355
- <sort_order>3</sort_order>
356
- <show_in_default>1</show_in_default>
357
- <show_in_website>1</show_in_website>
358
- <show_in_store>1</show_in_store>
359
- </config>
360
- <weight_limit translate="label">
361
- <label>Weight Limit</label>
362
- <frontend_type>text</frontend_type>
363
- <comment>in Kg</comment>
364
- <sort_order>7</sort_order>
365
- <show_in_default>1</show_in_default>
366
- <show_in_website>1</show_in_website>
367
- <show_in_store>1</show_in_store>
368
- </weight_limit>
369
- <quickcost translate="label">
370
- <label>Quickcost</label>
371
- <frontend_type>select</frontend_type>
372
- <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
373
- <source_model>adminhtml/system_config_source_yesno</source_model>
374
- <sort_order>10</sort_order>
375
- <show_in_default>1</show_in_default>
376
- <show_in_website>1</show_in_website>
377
- <show_in_store>0</show_in_store>
378
- </quickcost>
379
- <quickcost_url>
380
- <label>Quickcost Url</label>
381
- <frontend_type>text</frontend_type>
382
- <sort_order>11</sort_order>
383
- <show_in_default>1</show_in_default>
384
- <show_in_website>1</show_in_website>
385
- <show_in_store>0</show_in_store>
386
- </quickcost_url>
387
- <free_shipping_enable translate="label">
388
- <label>Free Shipping with Minimum Order Amount</label>
389
- <frontend_type>select</frontend_type>
390
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
391
- <sort_order>12</sort_order>
392
- <show_in_default>1</show_in_default>
393
- <show_in_website>1</show_in_website>
394
- <show_in_store>1</show_in_store>
395
- </free_shipping_enable>
396
- <free_shipping_subtotal translate="label">
397
- <label>Minimum Order Amount for Free Shipping</label>
398
- <frontend_type>text</frontend_type>
399
- <sort_order>13</sort_order>
400
- <show_in_default>1</show_in_default>
401
- <show_in_website>1</show_in_website>
402
- <show_in_store>1</show_in_store>
403
- </free_shipping_subtotal>
404
- <application_fee translate="label">
405
- <label>Application Fee</label>
406
- <frontend_type>text</frontend_type>
407
- <sort_order>14</sort_order>
408
- <show_in_default>1</show_in_default>
409
- <show_in_website>1</show_in_website>
410
- <show_in_store>1</show_in_store>
411
- </application_fee>
412
- <handling_fee translate="label">
413
- <label>Handling Fee</label>
414
- <frontend_type>text</frontend_type>
415
- <sort_order>15</sort_order>
416
- <show_in_default>1</show_in_default>
417
- <show_in_website>1</show_in_website>
418
- <show_in_store>1</show_in_store>
419
- </handling_fee>
420
- <logo_url>
421
- <label>Logo Url</label>
422
- <frontend_type>text</frontend_type>
423
- <comment>{logo_ulr_help}</comment>
424
- <sort_order>18</sort_order>
425
- <show_in_default>1</show_in_default>
426
- <show_in_website>1</show_in_website>
427
- <show_in_store>1</show_in_store>
428
- </logo_url>
429
- <debug>
430
- <label>Debug</label>
431
- <comment>{debug_help}</comment>
432
- <frontend_type>text</frontend_type>
433
- <sort_order>20</sort_order>
434
- <show_in_default>1</show_in_default>
435
- <show_in_website>1</show_in_website>
436
- <show_in_store>1</show_in_store>
437
- </debug>
438
- <!--<stop_to_first_match translate="label">
439
- <label>Stop to first match</label>
440
- <frontend_type>select</frontend_type>
441
- <source_model>adminhtml/system_config_source_yesno</source_model>
442
- <sort_order>22</sort_order>
443
- <show_in_default>1</show_in_default>
444
- <show_in_website>1</show_in_website>
445
- <show_in_store>1</show_in_store>
446
- </stop_to_first_match>-->
447
- <deliver_on_saturday translate="label comment">
448
- <label>Livraison le Samedi</label>
449
- <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
450
- <frontend_type>select</frontend_type>
451
- <source_model>adminhtml/system_config_source_yesno</source_model>
452
- <sort_order>23</sort_order>
453
- <show_in_default>1</show_in_default>
454
- <show_in_website>1</show_in_website>
455
- <show_in_store>1</show_in_store>
456
- </deliver_on_saturday>
457
- <!--<showmethod translate="label">
458
- <label>Show Method if Not Applicable</label>
459
- <frontend_type>select</frontend_type>
460
- <sort_order>30</sort_order>
461
- <frontend_class>shipping-skip-hide</frontend_class>
462
- <source_model>adminhtml/system_config_source_yesno</source_model>
463
- <show_in_default>1</show_in_default>
464
- <show_in_website>1</show_in_website>
465
- <show_in_store>0</show_in_store>
466
- </showmethod>
467
- <specificerrmsg translate="label">
468
- <label>Displayed Error Message</label>
469
- <frontend_type>textarea</frontend_type>
470
- <sort_order>31</sort_order>
471
- <show_in_default>1</show_in_default>
472
- <show_in_website>1</show_in_website>
473
- <show_in_store>1</show_in_store>
474
- </specificerrmsg>-->
475
- <sort_order translate="label">
476
- <label>Sort order</label>
477
- <frontend_type>text</frontend_type>
478
- <sort_order>100</sort_order>
479
- <show_in_default>1</show_in_default>
480
- <show_in_website>1</show_in_website>
481
- <show_in_store>1</show_in_store>
482
- </sort_order>
483
- </fields>
484
- </chronorelais>
485
- </groups>
486
- </carriers>
487
- </sections>
488
-
489
- <sections>
490
- <chronorelais>
491
- <label>Chronopost Settings</label>
492
- <tab>chronopost</tab>
493
- <frontend_type>text</frontend_type>
494
- <sort_order>2000</sort_order>
495
- <show_in_default>1</show_in_default>
496
- <show_in_website>1</show_in_website>
497
- <show_in_store>1</show_in_store>
498
- <groups>
499
- <shipping translate="label">
500
- <label>General</label>
501
- <frontend_type>text</frontend_type>
502
- <sort_order>10</sort_order>
503
- <show_in_default>1</show_in_default>
504
- <show_in_website>1</show_in_website>
505
- <show_in_store>1</show_in_store>
506
- <fields>
507
- <account_number translate="label">
508
- <label>N° de compte Chronopost</label>
509
- <frontend_type>text</frontend_type>
510
- <sort_order>7</sort_order>
511
- <show_in_default>1</show_in_default>
512
- <show_in_website>1</show_in_website>
513
- <show_in_store>1</show_in_store>
514
- </account_number>
515
- <sub_account_number translate="label">
516
- <label>N° de sous-compte</label>
517
- <comment>must be 3 digits or empty</comment>
518
- <frontend_type>text</frontend_type>
519
- <sort_order>8</sort_order>
520
- <show_in_default>1</show_in_default>
521
- <show_in_website>1</show_in_website>
522
- <show_in_store>1</show_in_store>
523
- </sub_account_number>
524
- <account_pass translate="label">
525
- <label>Mot de passe Chronopost</label>
526
- <frontend_type>text</frontend_type>
527
- <sort_order>9</sort_order>
528
- <show_in_default>1</show_in_default>
529
- <show_in_website>1</show_in_website>
530
- <show_in_store>1</show_in_store>
531
- </account_pass>
532
- <google_map_api translate="label">
533
- <label>Google Map v3 API Key</label>
534
- <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>
535
- <frontend_type>text</frontend_type>
536
- <sort_order>10</sort_order>
537
- <show_in_default>1</show_in_default>
538
- <show_in_website>1</show_in_website>
539
- <show_in_store>1</show_in_store>
540
- </google_map_api>
541
- <tracking_view_url translate="label">
542
- <label>Tracking URL</label>
543
- <comment>For English language, replace fr_FR with en_GB in the above url</comment>
544
- <frontend_type>text</frontend_type>
545
- <sort_order>20</sort_order>
546
- <show_in_default>1</show_in_default>
547
- <show_in_website>1</show_in_website>
548
- <show_in_store>1</show_in_store>
549
- </tracking_view_url>
550
-
551
- </fields>
552
- </shipping>
553
- <export_css translate="label">
554
- <label>Export Configuration CSS</label>
555
- <frontend_type>text</frontend_type>
556
- <sort_order>20</sort_order>
557
- <show_in_default>1</show_in_default>
558
- <show_in_website>1</show_in_website>
559
- <show_in_store>1</show_in_store>
560
- <fields>
561
- <file_extension translate="label">
562
- <label>File Extension</label>
563
- <frontend_type>select</frontend_type>
564
- <source_model>chronorelais/config_source_fileExtension</source_model>
565
- <sort_order>10</sort_order>
566
- <show_in_default>1</show_in_default>
567
- <show_in_website>1</show_in_website>
568
- <show_in_store>1</show_in_store>
569
- </file_extension>
570
- <file_charset translate="label">
571
- <label>File Charset</label>
572
- <frontend_type>select</frontend_type>
573
- <source_model>chronorelais/config_source_fileCharset</source_model>
574
- <sort_order>20</sort_order>
575
- <show_in_default>1</show_in_default>
576
- <show_in_website>1</show_in_website>
577
- <show_in_store>1</show_in_store>
578
- </file_charset>
579
- <endofline_character translate="label">
580
- <label>End Of Line Character</label>
581
- <frontend_type>select</frontend_type>
582
- <source_model>chronorelais/config_source_endOfLineCharacter</source_model>
583
- <sort_order>30</sort_order>
584
- <show_in_default>1</show_in_default>
585
- <show_in_website>1</show_in_website>
586
- <show_in_store>1</show_in_store>
587
- </endofline_character>
588
- <field_delimiter translate="label">
589
- <label>Field Delimiter</label>
590
- <frontend_type>select</frontend_type>
591
- <source_model>chronorelais/config_source_fieldDelimiter</source_model>
592
- <sort_order>40</sort_order>
593
- <show_in_default>1</show_in_default>
594
- <show_in_website>1</show_in_website>
595
- <show_in_store>1</show_in_store>
596
- </field_delimiter>
597
- <field_separator translate="label">
598
- <label>Field Separator</label>
599
- <frontend_type>select</frontend_type>
600
- <source_model>chronorelais/config_source_fieldSeparator</source_model>
601
- <sort_order>50</sort_order>
602
- <show_in_default>1</show_in_default>
603
- <show_in_website>1</show_in_website>
604
- <show_in_store>1</show_in_store>
605
- </field_separator>
606
- </fields>
607
- </export_css>
608
- <export_cso translate="label">
609
- <label>Export Configuration CSO</label>
610
- <frontend_type>text</frontend_type>
611
- <sort_order>21</sort_order>
612
- <show_in_default>1</show_in_default>
613
- <show_in_website>1</show_in_website>
614
- <show_in_store>1</show_in_store>
615
- <fields>
616
- <file_extension translate="label">
617
- <label>File Extension</label>
618
- <frontend_type>select</frontend_type>
619
- <source_model>chronorelais/config_source_fileExtension</source_model>
620
- <sort_order>10</sort_order>
621
- <show_in_default>1</show_in_default>
622
- <show_in_website>1</show_in_website>
623
- <show_in_store>1</show_in_store>
624
- </file_extension>
625
- <file_charset translate="label">
626
- <label>File Charset</label>
627
- <frontend_type>select</frontend_type>
628
- <source_model>chronorelais/config_source_fileCharset</source_model>
629
- <sort_order>20</sort_order>
630
- <show_in_default>1</show_in_default>
631
- <show_in_website>1</show_in_website>
632
- <show_in_store>1</show_in_store>
633
- </file_charset>
634
- <endofline_character translate="label">
635
- <label>End Of Line Character</label>
636
- <frontend_type>select</frontend_type>
637
- <source_model>chronorelais/config_source_endOfLineCharacter</source_model>
638
- <sort_order>30</sort_order>
639
- <show_in_default>1</show_in_default>
640
- <show_in_website>1</show_in_website>
641
- <show_in_store>1</show_in_store>
642
- </endofline_character>
643
- <field_delimiter translate="label">
644
- <label>Field Delimiter</label>
645
- <frontend_type>select</frontend_type>
646
- <source_model>chronorelais/config_source_fieldDelimiter</source_model>
647
- <sort_order>40</sort_order>
648
- <show_in_default>1</show_in_default>
649
- <show_in_website>1</show_in_website>
650
- <show_in_store>1</show_in_store>
651
- </field_delimiter>
652
- <field_separator translate="label">
653
- <label>Field Separator</label>
654
- <frontend_type>select</frontend_type>
655
- <source_model>chronorelais/config_source_fieldSeparator</source_model>
656
- <sort_order>50</sort_order>
657
- <show_in_default>1</show_in_default>
658
- <show_in_website>1</show_in_website>
659
- <show_in_store>1</show_in_store>
660
- </field_separator>
661
- </fields>
662
- </export_cso>
663
- <import translate="label">
664
- <label>Import Configuration</label>
665
- <frontend_type>text</frontend_type>
666
- <sort_order>30</sort_order>
667
- <show_in_default>1</show_in_default>
668
- <show_in_website>1</show_in_website>
669
- <show_in_store>1</show_in_store>
670
- <fields>
671
- <default_tracking_title translate="label comment">
672
- <label>Default Tracking Title</label>
673
- <frontend_type>text</frontend_type>
674
- <sort_order>10</sort_order>
675
- <show_in_default>1</show_in_default>
676
- <show_in_website>1</show_in_website>
677
- <show_in_store>1</show_in_store>
678
- <comment>This value can be changed in the import form</comment>
679
- </default_tracking_title>
680
- <send_email translate="label comment">
681
- <label>Send an e-mail</label>
682
- <frontend_type>select</frontend_type>
683
- <source_model>adminhtml/system_config_source_yesno</source_model>
684
- <sort_order>20</sort_order>
685
- <show_in_default>1</show_in_default>
686
- <show_in_website>1</show_in_website>
687
- <show_in_store>1</show_in_store>
688
- <comment>Send shipping confirmation to the customer</comment>
689
- </send_email>
690
- <shipping_comment translate="label comment">
691
- <label>Shipping Comment</label>
692
- <frontend_type>text</frontend_type>
693
- <sort_order>30</sort_order>
694
- <show_in_default>1</show_in_default>
695
- <show_in_website>1</show_in_website>
696
- <show_in_store>1</show_in_store>
697
- <comment>Internal comment, can be left empty</comment>
698
- </shipping_comment>
699
- <include_comment translate="label comment">
700
- <label>Include comment into e-mail</label>
701
- <frontend_type>select</frontend_type>
702
- <source_model>adminhtml/system_config_source_yesno</source_model>
703
- <sort_order>40</sort_order>
704
- <show_in_default>1</show_in_default>
705
- <show_in_website>1</show_in_website>
706
- <show_in_store>1</show_in_store>
707
- <comment>Only applies if the shipping comment is set</comment>
708
- </include_comment>
709
- </fields>
710
- </import>
711
-
712
- <shipperinformation translate="label">
713
- <label>Shipper Information for Labels printing</label>
714
- <frontend_type>text</frontend_type>
715
- <sort_order>40</sort_order>
716
- <show_in_default>1</show_in_default>
717
- <show_in_website>1</show_in_website>
718
- <show_in_store>1</show_in_store>
719
- <fields>
720
- <civility translate="label">
721
- <label>Shipper Civility</label>
722
- <frontend_type>select</frontend_type>
723
- <source_model>chronorelais/config_source_civility</source_model>
724
- <sort_order>10</sort_order>
725
- <show_in_default>1</show_in_default>
726
- <show_in_website>1</show_in_website>
727
- <show_in_store>1</show_in_store>
728
- </civility>
729
- <name translate="label comment">
730
- <label>Shipper Name</label>
731
- <frontend_type>text</frontend_type>
732
- <sort_order>20</sort_order>
733
- <show_in_default>1</show_in_default>
734
- <show_in_website>1</show_in_website>
735
- <show_in_store>1</show_in_store>
736
- <comment>Company name</comment>
737
- </name>
738
- <name2 translate="label comment">
739
- <label>Shipper Name2</label>
740
- <frontend_type>text</frontend_type>
741
- <sort_order>30</sort_order>
742
- <show_in_default>1</show_in_default>
743
- <show_in_website>1</show_in_website>
744
- <show_in_store>1</show_in_store>
745
- <comment>[Optional]</comment>
746
- </name2>
747
- <address1 translate="label">
748
- <label>Shipper Address1</label>
749
- <frontend_type>text</frontend_type>
750
- <sort_order>40</sort_order>
751
- <show_in_default>1</show_in_default>
752
- <show_in_website>1</show_in_website>
753
- <show_in_store>1</show_in_store>
754
- </address1>
755
- <address2 translate="label comment">
756
- <label>Shipper Address2</label>
757
- <frontend_type>text</frontend_type>
758
- <sort_order>50</sort_order>
759
- <show_in_default>1</show_in_default>
760
- <show_in_website>1</show_in_website>
761
- <show_in_store>1</show_in_store>
762
- <comment>[Optional]</comment>
763
- </address2>
764
- <zipcode translate="label">
765
- <label>Shipper Zipcode</label>
766
- <frontend_type>text</frontend_type>
767
- <sort_order>60</sort_order>
768
- <show_in_default>1</show_in_default>
769
- <show_in_website>1</show_in_website>
770
- <show_in_store>1</show_in_store>
771
- </zipcode>
772
- <city translate="label">
773
- <label>Shipper City</label>
774
- <frontend_type>text</frontend_type>
775
- <sort_order>70</sort_order>
776
- <show_in_default>1</show_in_default>
777
- <show_in_website>1</show_in_website>
778
- <show_in_store>1</show_in_store>
779
- </city>
780
- <country translate="label">
781
- <label>Shipper Country</label>
782
- <frontend_type>select</frontend_type>
783
- <sort_order>80</sort_order>
784
- <source_model>adminhtml/system_config_source_country</source_model>
785
- <show_in_default>1</show_in_default>
786
- <show_in_website>1</show_in_website>
787
- <show_in_store>1</show_in_store>
788
- </country>
789
- <contactname translate="label">
790
- <label>Shipper Contact Name</label>
791
- <frontend_type>text</frontend_type>
792
- <sort_order>90</sort_order>
793
- <show_in_default>1</show_in_default>
794
- <show_in_website>1</show_in_website>
795
- <show_in_store>1</show_in_store>
796
- </contactname>
797
- <email translate="label">
798
- <label>Shipper Email</label>
799
- <frontend_type>text</frontend_type>
800
- <sort_order>100</sort_order>
801
- <show_in_default>1</show_in_default>
802
- <show_in_website>1</show_in_website>
803
- <show_in_store>1</show_in_store>
804
- <comment>[Optional]</comment>
805
- </email>
806
- <phone translate="label comment">
807
- <label>Shipper Telephone</label>
808
- <frontend_type>text</frontend_type>
809
- <sort_order>110</sort_order>
810
- <show_in_default>1</show_in_default>
811
- <show_in_website>1</show_in_website>
812
- <show_in_store>1</show_in_store>
813
- <comment>[Optional]</comment>
814
- </phone>
815
- <mobilephone translate="label comment">
816
- <label>Shipper Mobile</label>
817
- <frontend_type>text</frontend_type>
818
- <sort_order>120</sort_order>
819
- <show_in_default>1</show_in_default>
820
- <show_in_website>1</show_in_website>
821
- <show_in_store>1</show_in_store>
822
- <comment>[Optional]</comment>
823
- </mobilephone>
824
- </fields>
825
- </shipperinformation>
826
-
827
- <customerinformation translate="label">
828
- <label>Chronopost Customer Account Information for Labels printing</label>
829
- <frontend_type>text</frontend_type>
830
- <sort_order>50</sort_order>
831
- <show_in_default>1</show_in_default>
832
- <show_in_website>1</show_in_website>
833
- <show_in_store>1</show_in_store>
834
- <fields>
835
- <civility translate="label">
836
- <label>Customer Civility</label>
837
- <frontend_type>select</frontend_type>
838
- <source_model>chronorelais/config_source_civility</source_model>
839
- <sort_order>10</sort_order>
840
- <show_in_default>1</show_in_default>
841
- <show_in_website>1</show_in_website>
842
- <show_in_store>1</show_in_store>
843
- </civility>
844
- <name translate="label comment">
845
- <label>Customer Name </label>
846
- <frontend_type>text</frontend_type>
847
- <sort_order>20</sort_order>
848
- <show_in_default>1</show_in_default>
849
- <show_in_website>1</show_in_website>
850
- <show_in_store>1</show_in_store>
851
- <comment>Company name</comment>
852
- </name>
853
- <name2 translate="label comment">
854
- <label>Customer Name2</label>
855
- <frontend_type>text</frontend_type>
856
- <sort_order>30</sort_order>
857
- <show_in_default>1</show_in_default>
858
- <show_in_website>1</show_in_website>
859
- <show_in_store>1</show_in_store>
860
- <comment>[Optional]</comment>
861
- </name2>
862
- <address1 translate="label">
863
- <label>Customer Address1</label>
864
- <frontend_type>text</frontend_type>
865
- <sort_order>40</sort_order>
866
- <show_in_default>1</show_in_default>
867
- <show_in_website>1</show_in_website>
868
- <show_in_store>1</show_in_store>
869
- </address1>
870
- <address2 translate="label comment">
871
- <label>Customer Address2</label>
872
- <frontend_type>text</frontend_type>
873
- <sort_order>50</sort_order>
874
- <show_in_default>1</show_in_default>
875
- <show_in_website>1</show_in_website>
876
- <show_in_store>1</show_in_store>
877
- <comment>[Optional]</comment>
878
- </address2>
879
- <zipcode translate="label">
880
- <label>Customer Zipcode</label>
881
- <frontend_type>text</frontend_type>
882
- <sort_order>60</sort_order>
883
- <show_in_default>1</show_in_default>
884
- <show_in_website>1</show_in_website>
885
- <show_in_store>1</show_in_store>
886
- </zipcode>
887
- <city translate="label">
888
- <label>Customer City</label>
889
- <frontend_type>text</frontend_type>
890
- <sort_order>70</sort_order>
891
- <show_in_default>1</show_in_default>
892
- <show_in_website>1</show_in_website>
893
- <show_in_store>1</show_in_store>
894
- </city>
895
- <country translate="label">
896
- <label>Customer Country</label>
897
- <frontend_type>select</frontend_type>
898
- <sort_order>80</sort_order>
899
- <source_model>adminhtml/system_config_source_country</source_model>
900
- <show_in_default>1</show_in_default>
901
- <show_in_website>1</show_in_website>
902
- <show_in_store>1</show_in_store>
903
- </country>
904
- <contactname translate="label">
905
- <label>Customer Contact Name</label>
906
- <frontend_type>text</frontend_type>
907
- <sort_order>90</sort_order>
908
- <show_in_default>1</show_in_default>
909
- <show_in_website>1</show_in_website>
910
- <show_in_store>1</show_in_store>
911
- </contactname>
912
- <email translate="label">
913
- <label>Customer Email</label>
914
- <frontend_type>text</frontend_type>
915
- <sort_order>100</sort_order>
916
- <show_in_default>1</show_in_default>
917
- <show_in_website>1</show_in_website>
918
- <show_in_store>1</show_in_store>
919
- <comment>[Optional]</comment>
920
- </email>
921
- <phone translate="label comment">
922
- <label>Customer Telephone</label>
923
- <frontend_type>text</frontend_type>
924
- <sort_order>110</sort_order>
925
- <show_in_default>1</show_in_default>
926
- <show_in_website>1</show_in_website>
927
- <show_in_store>1</show_in_store>
928
- <comment>[Optional]</comment>
929
- </phone>
930
- <mobilephone translate="label comment">
931
- <label>Customer Mobile</label>
932
- <frontend_type>text</frontend_type>
933
- <sort_order>120</sort_order>
934
- <show_in_default>1</show_in_default>
935
- <show_in_website>1</show_in_website>
936
- <show_in_store>1</show_in_store>
937
- <comment>[Optional]</comment>
938
- </mobilephone>
939
- </fields>
940
- </customerinformation>
941
-
942
- <skybillparam translate="label">
943
- <label>Skybill Parameters for Labels printing</label>
944
- <frontend_type>text</frontend_type>
945
- <sort_order>60</sort_order>
946
- <show_in_default>1</show_in_default>
947
- <show_in_website>1</show_in_website>
948
- <show_in_store>1</show_in_store>
949
- <fields>
950
- <mode translate="label">
951
- <label>Print Mode</label>
952
- <frontend_type>select</frontend_type>
953
- <source_model>chronorelais/config_source_printMode</source_model>
954
- <sort_order>10</sort_order>
955
- <show_in_default>1</show_in_default>
956
- <show_in_website>1</show_in_website>
957
- <show_in_store>1</show_in_store>
958
- <required>1</required>
959
- </mode>
960
- </fields>
961
- </skybillparam>
962
- </groups>
963
- </chronorelais>
964
- </sections>
965
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
966
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <chronopost translate="label" module="chronorelais">
5
+ <label>Chronopost</label>
6
+ <sort_order>200</sort_order>
7
+ </chronopost>
8
+ </tabs>
9
+ <sections>
10
+ <carriers>
11
+ <groups>
12
+ <chronopost translate="label">
13
+ <label>Chronopost</label>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>20</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <fields>
20
+ <active translate="label">
21
+ <label>Enabled</label>
22
+ <frontend_type>select</frontend_type>
23
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
24
+ <source_model>adminhtml/system_config_source_yesno</source_model>
25
+ <sort_order>1</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ </active>
30
+ <title translate="label">
31
+ <label>Title</label>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>2</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ </title>
38
+ <config translate="label">
39
+ <label>Configuration</label>
40
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
41
+ <comment>{configuration_syntax_help}</comment>
42
+ <frontend_type>textarea</frontend_type>
43
+ <sort_order>3</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ </config>
48
+ <weight_limit translate="label">
49
+ <label>Weight Limit</label>
50
+ <frontend_type>text</frontend_type>
51
+ <comment>in Kg</comment>
52
+ <sort_order>7</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </weight_limit>
57
+ <quickcost translate="label">
58
+ <label>Quickcost</label>
59
+ <frontend_type>select</frontend_type>
60
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
61
+ <source_model>adminhtml/system_config_source_yesno</source_model>
62
+ <sort_order>10</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>0</show_in_store>
66
+ </quickcost>
67
+ <quickcost_url>
68
+ <label>Quickcost Url</label>
69
+ <frontend_type>text</frontend_type>
70
+ <sort_order>11</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>0</show_in_store>
74
+ </quickcost_url>
75
+ <free_shipping_enable translate="label">
76
+ <label>Free Shipping on the Amount</label>
77
+ <frontend_type>select</frontend_type>
78
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
79
+ <sort_order>12</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ </free_shipping_enable>
84
+ <free_shipping_subtotal translate="label">
85
+ <label>Minimum Amount for Free Shipping</label>
86
+ <frontend_type>text</frontend_type>
87
+ <sort_order>13</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>0</show_in_store>
91
+ </free_shipping_subtotal>
92
+ <application_fee translate="label">
93
+ <label>Application Fee</label>
94
+ <frontend_type>text</frontend_type>
95
+ <sort_order>14</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>1</show_in_store>
99
+ </application_fee>
100
+ <handling_fee translate="label">
101
+ <label>Handling Fee</label>
102
+ <frontend_type>text</frontend_type>
103
+ <sort_order>15</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>1</show_in_store>
107
+ </handling_fee>
108
+ <logo_url>
109
+ <label>Logo Url</label>
110
+ <frontend_type>text</frontend_type>
111
+ <comment>{logo_ulr_help}</comment>
112
+ <sort_order>18</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ </logo_url>
117
+ <debug>
118
+ <label>Debug</label>
119
+ <comment>{debug_help}</comment>
120
+ <frontend_type>text</frontend_type>
121
+ <sort_order>20</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>1</show_in_store>
125
+ </debug>
126
+ <!--<stop_to_first_match translate="label">
127
+ <label>Stop to first match</label>
128
+ <frontend_type>select</frontend_type>
129
+ <source_model>adminhtml/system_config_source_yesno</source_model>
130
+ <sort_order>22</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>1</show_in_store>
134
+ </stop_to_first_match>-->
135
+ <deliver_on_saturday translate="label comment">
136
+ <label>Livraison le Samedi</label>
137
+ <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
138
+ <frontend_type>select</frontend_type>
139
+ <source_model>adminhtml/system_config_source_yesno</source_model>
140
+ <sort_order>23</sort_order>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_website>1</show_in_website>
143
+ <show_in_store>1</show_in_store>
144
+ </deliver_on_saturday>
145
+ <!--<showmethod translate="label">
146
+ <label>Show Method if Not Applicable</label>
147
+ <frontend_type>select</frontend_type>
148
+ <sort_order>30</sort_order>
149
+ <frontend_class>shipping-skip-hide</frontend_class>
150
+ <source_model>adminhtml/system_config_source_yesno</source_model>
151
+ <show_in_default>1</show_in_default>
152
+ <show_in_website>1</show_in_website>
153
+ <show_in_store>0</show_in_store>
154
+ </showmethod>
155
+ <specificerrmsg translate="label">
156
+ <label>Displayed Error Message</label>
157
+ <frontend_type>textarea</frontend_type>
158
+ <sort_order>31</sort_order>
159
+ <show_in_default>1</show_in_default>
160
+ <show_in_website>1</show_in_website>
161
+ <show_in_store>1</show_in_store>
162
+ </specificerrmsg>-->
163
+ <sort_order translate="label">
164
+ <label>Sort order</label>
165
+ <frontend_type>text</frontend_type>
166
+ <sort_order>100</sort_order>
167
+ <show_in_default>1</show_in_default>
168
+ <show_in_website>1</show_in_website>
169
+ <show_in_store>1</show_in_store>
170
+ </sort_order>
171
+ </fields>
172
+ </chronopost>
173
+
174
+ <chronoexpress translate="label">
175
+ <label>Chrono Express</label>
176
+ <frontend_type>text</frontend_type>
177
+ <sort_order>21</sort_order>
178
+ <show_in_default>1</show_in_default>
179
+ <show_in_website>1</show_in_website>
180
+ <show_in_store>1</show_in_store>
181
+ <fields>
182
+ <active translate="label">
183
+ <label>Enabled</label>
184
+ <frontend_type>select</frontend_type>
185
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
186
+ <source_model>adminhtml/system_config_source_yesno</source_model>
187
+ <sort_order>1</sort_order>
188
+ <show_in_default>1</show_in_default>
189
+ <show_in_website>1</show_in_website>
190
+ <show_in_store>1</show_in_store>
191
+ </active>
192
+ <title translate="label">
193
+ <label>Title</label>
194
+ <frontend_type>text</frontend_type>
195
+ <sort_order>2</sort_order>
196
+ <show_in_default>1</show_in_default>
197
+ <show_in_website>1</show_in_website>
198
+ <show_in_store>1</show_in_store>
199
+ </title>
200
+ <config translate="label">
201
+ <label>Configuration</label>
202
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
203
+ <comment>{configuration_syntax_help}</comment>
204
+ <frontend_type>textarea</frontend_type>
205
+ <sort_order>3</sort_order>
206
+ <show_in_default>1</show_in_default>
207
+ <show_in_website>1</show_in_website>
208
+ <show_in_store>1</show_in_store>
209
+ </config>
210
+ <weight_limit translate="label">
211
+ <label>Weight Limit</label>
212
+ <frontend_type>text</frontend_type>
213
+ <comment>in Kg</comment>
214
+ <sort_order>7</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>1</show_in_store>
218
+ </weight_limit>
219
+ <quickcost translate="label">
220
+ <label>Quickcost</label>
221
+ <frontend_type>select</frontend_type>
222
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
223
+ <source_model>adminhtml/system_config_source_yesno</source_model>
224
+ <sort_order>10</sort_order>
225
+ <show_in_default>1</show_in_default>
226
+ <show_in_website>1</show_in_website>
227
+ <show_in_store>0</show_in_store>
228
+ </quickcost>
229
+ <quickcost_url>
230
+ <label>Quickcost Url</label>
231
+ <frontend_type>text</frontend_type>
232
+ <sort_order>11</sort_order>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_website>1</show_in_website>
235
+ <show_in_store>0</show_in_store>
236
+ </quickcost_url>
237
+ <free_shipping_enable translate="label">
238
+ <label>Free Shipping on the Amount</label>
239
+ <frontend_type>select</frontend_type>
240
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
241
+ <sort_order>12</sort_order>
242
+ <show_in_default>1</show_in_default>
243
+ <show_in_website>1</show_in_website>
244
+ <show_in_store>1</show_in_store>
245
+ </free_shipping_enable>
246
+ <free_shipping_subtotal translate="label">
247
+ <label>Minimum Amount for Free Shipping</label>
248
+ <frontend_type>text</frontend_type>
249
+ <sort_order>13</sort_order>
250
+ <show_in_default>1</show_in_default>
251
+ <show_in_website>1</show_in_website>
252
+ <show_in_store>0</show_in_store>
253
+ </free_shipping_subtotal>
254
+ <application_fee translate="label">
255
+ <label>Application Fee</label>
256
+ <frontend_type>text</frontend_type>
257
+ <sort_order>14</sort_order>
258
+ <show_in_default>1</show_in_default>
259
+ <show_in_website>1</show_in_website>
260
+ <show_in_store>1</show_in_store>
261
+ </application_fee>
262
+ <handling_fee translate="label">
263
+ <label>Handling Fee</label>
264
+ <frontend_type>text</frontend_type>
265
+ <sort_order>15</sort_order>
266
+ <show_in_default>1</show_in_default>
267
+ <show_in_website>1</show_in_website>
268
+ <show_in_store>1</show_in_store>
269
+ </handling_fee>
270
+ <logo_url>
271
+ <label>Logo Url</label>
272
+ <frontend_type>text</frontend_type>
273
+ <comment>{logo_ulr_help}</comment>
274
+ <sort_order>18</sort_order>
275
+ <show_in_default>1</show_in_default>
276
+ <show_in_website>1</show_in_website>
277
+ <show_in_store>1</show_in_store>
278
+ </logo_url>
279
+ <debug>
280
+ <label>Debug</label>
281
+ <comment>{debug_help}</comment>
282
+ <frontend_type>text</frontend_type>
283
+ <sort_order>20</sort_order>
284
+ <show_in_default>1</show_in_default>
285
+ <show_in_website>1</show_in_website>
286
+ <show_in_store>1</show_in_store>
287
+ </debug>
288
+ <!--<stop_to_first_match translate="label">
289
+ <label>Stop to first match</label>
290
+ <frontend_type>select</frontend_type>
291
+ <source_model>adminhtml/system_config_source_yesno</source_model>
292
+ <sort_order>22</sort_order>
293
+ <show_in_default>1</show_in_default>
294
+ <show_in_website>1</show_in_website>
295
+ <show_in_store>1</show_in_store>
296
+ </stop_to_first_match>-->
297
+ <!-- deliver_on_saturday not included in chronoexpress only -->
298
+ <!--<showmethod translate="label">
299
+ <label>Show Method if Not Applicable</label>
300
+ <frontend_type>select</frontend_type>
301
+ <sort_order>30</sort_order>
302
+ <frontend_class>shipping-skip-hide</frontend_class>
303
+ <source_model>adminhtml/system_config_source_yesno</source_model>
304
+ <show_in_default>1</show_in_default>
305
+ <show_in_website>1</show_in_website>
306
+ <show_in_store>0</show_in_store>
307
+ </showmethod>
308
+ <specificerrmsg translate="label">
309
+ <label>Displayed Error Message</label>
310
+ <frontend_type>textarea</frontend_type>
311
+ <sort_order>31</sort_order>
312
+ <show_in_default>1</show_in_default>
313
+ <show_in_website>1</show_in_website>
314
+ <show_in_store>1</show_in_store>
315
+ </specificerrmsg>-->
316
+ <sort_order translate="label">
317
+ <label>Sort order</label>
318
+ <frontend_type>text</frontend_type>
319
+ <sort_order>100</sort_order>
320
+ <show_in_default>1</show_in_default>
321
+ <show_in_website>1</show_in_website>
322
+ <show_in_store>1</show_in_store>
323
+ </sort_order>
324
+ </fields>
325
+ </chronoexpress>
326
+
327
+ <chronorelais translate="label">
328
+ <label>Chrono Relais</label>
329
+ <frontend_type>text</frontend_type>
330
+ <sort_order>22</sort_order>
331
+ <show_in_default>1</show_in_default>
332
+ <show_in_website>1</show_in_website>
333
+ <show_in_store>1</show_in_store>
334
+ <fields>
335
+ <active translate="label">
336
+ <label>Enabled</label>
337
+ <frontend_type>select</frontend_type>
338
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
339
+ <source_model>adminhtml/system_config_source_yesno</source_model>
340
+ <sort_order>1</sort_order>
341
+ <show_in_default>1</show_in_default>
342
+ <show_in_website>1</show_in_website>
343
+ <show_in_store>1</show_in_store>
344
+ </active>
345
+ <title translate="label">
346
+ <label>Title</label>
347
+ <frontend_type>text</frontend_type>
348
+ <sort_order>2</sort_order>
349
+ <show_in_default>1</show_in_default>
350
+ <show_in_website>1</show_in_website>
351
+ <show_in_store>1</show_in_store>
352
+ </title>
353
+ <config translate="label">
354
+ <label>Configuration</label>
355
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
356
+ <comment>{configuration_syntax_help}</comment>
357
+ <frontend_type>textarea</frontend_type>
358
+ <sort_order>3</sort_order>
359
+ <show_in_default>1</show_in_default>
360
+ <show_in_website>1</show_in_website>
361
+ <show_in_store>1</show_in_store>
362
+ </config>
363
+ <weight_limit translate="label">
364
+ <label>Weight Limit</label>
365
+ <frontend_type>text</frontend_type>
366
+ <comment>in Kg</comment>
367
+ <sort_order>7</sort_order>
368
+ <show_in_default>1</show_in_default>
369
+ <show_in_website>1</show_in_website>
370
+ <show_in_store>1</show_in_store>
371
+ </weight_limit>
372
+ <quickcost translate="label">
373
+ <label>Quickcost</label>
374
+ <frontend_type>select</frontend_type>
375
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
376
+ <source_model>adminhtml/system_config_source_yesno</source_model>
377
+ <sort_order>10</sort_order>
378
+ <show_in_default>1</show_in_default>
379
+ <show_in_website>1</show_in_website>
380
+ <show_in_store>0</show_in_store>
381
+ </quickcost>
382
+ <quickcost_url>
383
+ <label>Quickcost Url</label>
384
+ <frontend_type>text</frontend_type>
385
+ <sort_order>11</sort_order>
386
+ <show_in_default>1</show_in_default>
387
+ <show_in_website>1</show_in_website>
388
+ <show_in_store>0</show_in_store>
389
+ </quickcost_url>
390
+ <free_shipping_enable translate="label">
391
+ <label>Free Shipping with Minimum Order Amount</label>
392
+ <frontend_type>select</frontend_type>
393
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
394
+ <sort_order>12</sort_order>
395
+ <show_in_default>1</show_in_default>
396
+ <show_in_website>1</show_in_website>
397
+ <show_in_store>1</show_in_store>
398
+ </free_shipping_enable>
399
+ <free_shipping_subtotal translate="label">
400
+ <label>Minimum Order Amount for Free Shipping</label>
401
+ <frontend_type>text</frontend_type>
402
+ <sort_order>13</sort_order>
403
+ <show_in_default>1</show_in_default>
404
+ <show_in_website>1</show_in_website>
405
+ <show_in_store>1</show_in_store>
406
+ </free_shipping_subtotal>
407
+ <application_fee translate="label">
408
+ <label>Application Fee</label>
409
+ <frontend_type>text</frontend_type>
410
+ <sort_order>14</sort_order>
411
+ <show_in_default>1</show_in_default>
412
+ <show_in_website>1</show_in_website>
413
+ <show_in_store>1</show_in_store>
414
+ </application_fee>
415
+ <handling_fee translate="label">
416
+ <label>Handling Fee</label>
417
+ <frontend_type>text</frontend_type>
418
+ <sort_order>15</sort_order>
419
+ <show_in_default>1</show_in_default>
420
+ <show_in_website>1</show_in_website>
421
+ <show_in_store>1</show_in_store>
422
+ </handling_fee>
423
+ <logo_url>
424
+ <label>Logo Url</label>
425
+ <frontend_type>text</frontend_type>
426
+ <comment>{logo_ulr_help}</comment>
427
+ <sort_order>18</sort_order>
428
+ <show_in_default>1</show_in_default>
429
+ <show_in_website>1</show_in_website>
430
+ <show_in_store>1</show_in_store>
431
+ </logo_url>
432
+ <debug>
433
+ <label>Debug</label>
434
+ <comment>{debug_help}</comment>
435
+ <frontend_type>text</frontend_type>
436
+ <sort_order>20</sort_order>
437
+ <show_in_default>1</show_in_default>
438
+ <show_in_website>1</show_in_website>
439
+ <show_in_store>1</show_in_store>
440
+ </debug>
441
+ <!--<stop_to_first_match translate="label">
442
+ <label>Stop to first match</label>
443
+ <frontend_type>select</frontend_type>
444
+ <source_model>adminhtml/system_config_source_yesno</source_model>
445
+ <sort_order>22</sort_order>
446
+ <show_in_default>1</show_in_default>
447
+ <show_in_website>1</show_in_website>
448
+ <show_in_store>1</show_in_store>
449
+ </stop_to_first_match>-->
450
+ <deliver_on_saturday translate="label comment">
451
+ <label>Livraison le Samedi</label>
452
+ <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
453
+ <frontend_type>select</frontend_type>
454
+ <source_model>adminhtml/system_config_source_yesno</source_model>
455
+ <sort_order>23</sort_order>
456
+ <show_in_default>1</show_in_default>
457
+ <show_in_website>1</show_in_website>
458
+ <show_in_store>1</show_in_store>
459
+ </deliver_on_saturday>
460
+ <!--<showmethod translate="label">
461
+ <label>Show Method if Not Applicable</label>
462
+ <frontend_type>select</frontend_type>
463
+ <sort_order>30</sort_order>
464
+ <frontend_class>shipping-skip-hide</frontend_class>
465
+ <source_model>adminhtml/system_config_source_yesno</source_model>
466
+ <show_in_default>1</show_in_default>
467
+ <show_in_website>1</show_in_website>
468
+ <show_in_store>0</show_in_store>
469
+ </showmethod>
470
+ <specificerrmsg translate="label">
471
+ <label>Displayed Error Message</label>
472
+ <frontend_type>textarea</frontend_type>
473
+ <sort_order>31</sort_order>
474
+ <show_in_default>1</show_in_default>
475
+ <show_in_website>1</show_in_website>
476
+ <show_in_store>1</show_in_store>
477
+ </specificerrmsg>-->
478
+ <sort_order translate="label">
479
+ <label>Sort order</label>
480
+ <frontend_type>text</frontend_type>
481
+ <sort_order>100</sort_order>
482
+ <show_in_default>1</show_in_default>
483
+ <show_in_website>1</show_in_website>
484
+ <show_in_store>1</show_in_store>
485
+ </sort_order>
486
+ </fields>
487
+ </chronorelais>
488
+
489
+ <!-- C10 Livraison avant 10H -->
490
+ <chronopostc10 translate="label">
491
+ <label>Chronopost C10</label>
492
+ <frontend_type>text</frontend_type>
493
+ <sort_order>23</sort_order>
494
+ <show_in_default>1</show_in_default>
495
+ <show_in_website>1</show_in_website>
496
+ <show_in_store>1</show_in_store>
497
+ <fields>
498
+ <active translate="label">
499
+ <label>Enabled</label>
500
+ <frontend_type>select</frontend_type>
501
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
502
+ <source_model>adminhtml/system_config_source_yesno</source_model>
503
+ <sort_order>1</sort_order>
504
+ <show_in_default>1</show_in_default>
505
+ <show_in_website>1</show_in_website>
506
+ <show_in_store>1</show_in_store>
507
+ </active>
508
+ <title translate="label">
509
+ <label>Title</label>
510
+ <frontend_type>text</frontend_type>
511
+ <sort_order>2</sort_order>
512
+ <show_in_default>1</show_in_default>
513
+ <show_in_website>1</show_in_website>
514
+ <show_in_store>1</show_in_store>
515
+ </title>
516
+ <config translate="label">
517
+ <label>Configuration</label>
518
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
519
+ <comment>{configuration_syntax_help}</comment>
520
+ <frontend_type>textarea</frontend_type>
521
+ <sort_order>3</sort_order>
522
+ <show_in_default>1</show_in_default>
523
+ <show_in_website>1</show_in_website>
524
+ <show_in_store>1</show_in_store>
525
+ </config>
526
+ <weight_limit translate="label">
527
+ <label>Weight Limit</label>
528
+ <frontend_type>text</frontend_type>
529
+ <comment>in Kg</comment>
530
+ <sort_order>7</sort_order>
531
+ <show_in_default>1</show_in_default>
532
+ <show_in_website>1</show_in_website>
533
+ <show_in_store>1</show_in_store>
534
+ </weight_limit>
535
+ <quickcost translate="label">
536
+ <label>Quickcost</label>
537
+ <frontend_type>select</frontend_type>
538
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
539
+ <source_model>adminhtml/system_config_source_yesno</source_model>
540
+ <sort_order>10</sort_order>
541
+ <show_in_default>1</show_in_default>
542
+ <show_in_website>1</show_in_website>
543
+ <show_in_store>0</show_in_store>
544
+ </quickcost>
545
+ <quickcost_url>
546
+ <label>Quickcost Url</label>
547
+ <frontend_type>text</frontend_type>
548
+ <sort_order>11</sort_order>
549
+ <show_in_default>1</show_in_default>
550
+ <show_in_website>1</show_in_website>
551
+ <show_in_store>0</show_in_store>
552
+ </quickcost_url>
553
+ <free_shipping_enable translate="label">
554
+ <label>Free Shipping on the Amount</label>
555
+ <frontend_type>select</frontend_type>
556
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
557
+ <sort_order>12</sort_order>
558
+ <show_in_default>1</show_in_default>
559
+ <show_in_website>1</show_in_website>
560
+ <show_in_store>1</show_in_store>
561
+ </free_shipping_enable>
562
+ <free_shipping_subtotal translate="label">
563
+ <label>Minimum Amount for Free Shipping</label>
564
+ <frontend_type>text</frontend_type>
565
+ <sort_order>13</sort_order>
566
+ <show_in_default>1</show_in_default>
567
+ <show_in_website>1</show_in_website>
568
+ <show_in_store>0</show_in_store>
569
+ </free_shipping_subtotal>
570
+ <application_fee translate="label">
571
+ <label>Application Fee</label>
572
+ <frontend_type>text</frontend_type>
573
+ <sort_order>14</sort_order>
574
+ <show_in_default>1</show_in_default>
575
+ <show_in_website>1</show_in_website>
576
+ <show_in_store>1</show_in_store>
577
+ </application_fee>
578
+ <handling_fee translate="label">
579
+ <label>Handling Fee</label>
580
+ <frontend_type>text</frontend_type>
581
+ <sort_order>15</sort_order>
582
+ <show_in_default>1</show_in_default>
583
+ <show_in_website>1</show_in_website>
584
+ <show_in_store>1</show_in_store>
585
+ </handling_fee>
586
+ <logo_url>
587
+ <label>Logo Url</label>
588
+ <frontend_type>text</frontend_type>
589
+ <comment>{logo_ulr_help}</comment>
590
+ <sort_order>18</sort_order>
591
+ <show_in_default>1</show_in_default>
592
+ <show_in_website>1</show_in_website>
593
+ <show_in_store>1</show_in_store>
594
+ </logo_url>
595
+ <debug>
596
+ <label>Debug</label>
597
+ <comment>{debug_help}</comment>
598
+ <frontend_type>text</frontend_type>
599
+ <sort_order>20</sort_order>
600
+ <show_in_default>1</show_in_default>
601
+ <show_in_website>1</show_in_website>
602
+ <show_in_store>1</show_in_store>
603
+ </debug>
604
+ <!--<stop_to_first_match translate="label">
605
+ <label>Stop to first match</label>
606
+ <frontend_type>select</frontend_type>
607
+ <source_model>adminhtml/system_config_source_yesno</source_model>
608
+ <sort_order>22</sort_order>
609
+ <show_in_default>1</show_in_default>
610
+ <show_in_website>1</show_in_website>
611
+ <show_in_store>1</show_in_store>
612
+ </stop_to_first_match>-->
613
+ <deliver_on_saturday translate="label comment">
614
+ <label>Livraison le Samedi</label>
615
+ <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
616
+ <frontend_type>select</frontend_type>
617
+ <source_model>adminhtml/system_config_source_yesno</source_model>
618
+ <sort_order>23</sort_order>
619
+ <show_in_default>1</show_in_default>
620
+ <show_in_website>1</show_in_website>
621
+ <show_in_store>1</show_in_store>
622
+ </deliver_on_saturday>
623
+ <!--<showmethod translate="label">
624
+ <label>Show Method if Not Applicable</label>
625
+ <frontend_type>select</frontend_type>
626
+ <sort_order>30</sort_order>
627
+ <frontend_class>shipping-skip-hide</frontend_class>
628
+ <source_model>adminhtml/system_config_source_yesno</source_model>
629
+ <show_in_default>1</show_in_default>
630
+ <show_in_website>1</show_in_website>
631
+ <show_in_store>0</show_in_store>
632
+ </showmethod>
633
+ <specificerrmsg translate="label">
634
+ <label>Displayed Error Message</label>
635
+ <frontend_type>textarea</frontend_type>
636
+ <sort_order>31</sort_order>
637
+ <show_in_default>1</show_in_default>
638
+ <show_in_website>1</show_in_website>
639
+ <show_in_store>1</show_in_store>
640
+ </specificerrmsg>-->
641
+ <sort_order translate="label">
642
+ <label>Sort order</label>
643
+ <frontend_type>text</frontend_type>
644
+ <sort_order>100</sort_order>
645
+ <show_in_default>1</show_in_default>
646
+ <show_in_website>1</show_in_website>
647
+ <show_in_store>1</show_in_store>
648
+ </sort_order>
649
+ </fields>
650
+ </chronopostc10>
651
+
652
+ <!-- C18 Livraison avant 18H -->
653
+ <chronopostc18 translate="label">
654
+ <label>Chronopost C18</label>
655
+ <frontend_type>text</frontend_type>
656
+ <sort_order>24</sort_order>
657
+ <show_in_default>1</show_in_default>
658
+ <show_in_website>1</show_in_website>
659
+ <show_in_store>1</show_in_store>
660
+ <fields>
661
+ <active translate="label">
662
+ <label>Enabled</label>
663
+ <frontend_type>select</frontend_type>
664
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
665
+ <source_model>adminhtml/system_config_source_yesno</source_model>
666
+ <sort_order>1</sort_order>
667
+ <show_in_default>1</show_in_default>
668
+ <show_in_website>1</show_in_website>
669
+ <show_in_store>1</show_in_store>
670
+ </active>
671
+ <title translate="label">
672
+ <label>Title</label>
673
+ <frontend_type>text</frontend_type>
674
+ <sort_order>2</sort_order>
675
+ <show_in_default>1</show_in_default>
676
+ <show_in_website>1</show_in_website>
677
+ <show_in_store>1</show_in_store>
678
+ </title>
679
+ <config translate="label">
680
+ <label>Configuration</label>
681
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
682
+ <comment>{configuration_syntax_help}</comment>
683
+ <frontend_type>textarea</frontend_type>
684
+ <sort_order>3</sort_order>
685
+ <show_in_default>1</show_in_default>
686
+ <show_in_website>1</show_in_website>
687
+ <show_in_store>1</show_in_store>
688
+ </config>
689
+ <weight_limit translate="label">
690
+ <label>Weight Limit</label>
691
+ <frontend_type>text</frontend_type>
692
+ <comment>in Kg</comment>
693
+ <sort_order>7</sort_order>
694
+ <show_in_default>1</show_in_default>
695
+ <show_in_website>1</show_in_website>
696
+ <show_in_store>1</show_in_store>
697
+ </weight_limit>
698
+ <quickcost translate="label">
699
+ <label>Quickcost</label>
700
+ <frontend_type>select</frontend_type>
701
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
702
+ <source_model>adminhtml/system_config_source_yesno</source_model>
703
+ <sort_order>10</sort_order>
704
+ <show_in_default>0</show_in_default>
705
+ <show_in_website>0</show_in_website>
706
+ <show_in_store>0</show_in_store>
707
+ </quickcost>
708
+ <quickcost_url>
709
+ <label>Quickcost Url</label>
710
+ <frontend_type>text</frontend_type>
711
+ <sort_order>11</sort_order>
712
+ <show_in_default>0</show_in_default>
713
+ <show_in_website>0</show_in_website>
714
+ <show_in_store>0</show_in_store>
715
+ </quickcost_url>
716
+ <free_shipping_enable translate="label">
717
+ <label>Free Shipping on the Amount</label>
718
+ <frontend_type>select</frontend_type>
719
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
720
+ <sort_order>12</sort_order>
721
+ <show_in_default>1</show_in_default>
722
+ <show_in_website>1</show_in_website>
723
+ <show_in_store>1</show_in_store>
724
+ </free_shipping_enable>
725
+ <free_shipping_subtotal translate="label">
726
+ <label>Minimum Amount for Free Shipping</label>
727
+ <frontend_type>text</frontend_type>
728
+ <sort_order>13</sort_order>
729
+ <show_in_default>1</show_in_default>
730
+ <show_in_website>1</show_in_website>
731
+ <show_in_store>0</show_in_store>
732
+ </free_shipping_subtotal>
733
+ <application_fee translate="label">
734
+ <label>Application Fee</label>
735
+ <frontend_type>text</frontend_type>
736
+ <sort_order>14</sort_order>
737
+ <show_in_default>1</show_in_default>
738
+ <show_in_website>1</show_in_website>
739
+ <show_in_store>1</show_in_store>
740
+ </application_fee>
741
+ <handling_fee translate="label">
742
+ <label>Handling Fee</label>
743
+ <frontend_type>text</frontend_type>
744
+ <sort_order>15</sort_order>
745
+ <show_in_default>1</show_in_default>
746
+ <show_in_website>1</show_in_website>
747
+ <show_in_store>1</show_in_store>
748
+ </handling_fee>
749
+ <logo_url>
750
+ <label>Logo Url</label>
751
+ <frontend_type>text</frontend_type>
752
+ <comment>{logo_ulr_help}</comment>
753
+ <sort_order>18</sort_order>
754
+ <show_in_default>1</show_in_default>
755
+ <show_in_website>1</show_in_website>
756
+ <show_in_store>1</show_in_store>
757
+ </logo_url>
758
+ <debug>
759
+ <label>Debug</label>
760
+ <comment>{debug_help}</comment>
761
+ <frontend_type>text</frontend_type>
762
+ <sort_order>20</sort_order>
763
+ <show_in_default>1</show_in_default>
764
+ <show_in_website>1</show_in_website>
765
+ <show_in_store>1</show_in_store>
766
+ </debug>
767
+ <!--<stop_to_first_match translate="label">
768
+ <label>Stop to first match</label>
769
+ <frontend_type>select</frontend_type>
770
+ <source_model>adminhtml/system_config_source_yesno</source_model>
771
+ <sort_order>22</sort_order>
772
+ <show_in_default>1</show_in_default>
773
+ <show_in_website>1</show_in_website>
774
+ <show_in_store>1</show_in_store>
775
+ </stop_to_first_match>-->
776
+ <deliver_on_saturday translate="label comment">
777
+ <label>Livraison le Samedi</label>
778
+ <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
779
+ <frontend_type>select</frontend_type>
780
+ <source_model>adminhtml/system_config_source_yesno</source_model>
781
+ <sort_order>23</sort_order>
782
+ <show_in_default>1</show_in_default>
783
+ <show_in_website>1</show_in_website>
784
+ <show_in_store>1</show_in_store>
785
+ </deliver_on_saturday>
786
+ <!--<showmethod translate="label">
787
+ <label>Show Method if Not Applicable</label>
788
+ <frontend_type>select</frontend_type>
789
+ <sort_order>30</sort_order>
790
+ <frontend_class>shipping-skip-hide</frontend_class>
791
+ <source_model>adminhtml/system_config_source_yesno</source_model>
792
+ <show_in_default>1</show_in_default>
793
+ <show_in_website>1</show_in_website>
794
+ <show_in_store>0</show_in_store>
795
+ </showmethod>
796
+ <specificerrmsg translate="label">
797
+ <label>Displayed Error Message</label>
798
+ <frontend_type>textarea</frontend_type>
799
+ <sort_order>31</sort_order>
800
+ <show_in_default>1</show_in_default>
801
+ <show_in_website>1</show_in_website>
802
+ <show_in_store>1</show_in_store>
803
+ </specificerrmsg>-->
804
+ <sort_order translate="label">
805
+ <label>Sort order</label>
806
+ <frontend_type>text</frontend_type>
807
+ <sort_order>100</sort_order>
808
+ <show_in_default>1</show_in_default>
809
+ <show_in_website>1</show_in_website>
810
+ <show_in_store>1</show_in_store>
811
+ </sort_order>
812
+ </fields>
813
+ </chronopostc18>
814
+
815
+ <!-- CClassic Livraison dans certaines villes Européennes -->
816
+ <chronopostcclassic translate="label">
817
+ <label>Chronopost CClassic</label>
818
+ <frontend_type>text</frontend_type>
819
+ <sort_order>25</sort_order>
820
+ <show_in_default>1</show_in_default>
821
+ <show_in_website>1</show_in_website>
822
+ <show_in_store>1</show_in_store>
823
+ <fields>
824
+ <active translate="label">
825
+ <label>Enabled</label>
826
+ <frontend_type>select</frontend_type>
827
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_enabled</frontend_model>
828
+ <source_model>adminhtml/system_config_source_yesno</source_model>
829
+ <sort_order>1</sort_order>
830
+ <show_in_default>1</show_in_default>
831
+ <show_in_website>1</show_in_website>
832
+ <show_in_store>1</show_in_store>
833
+ </active>
834
+ <title translate="label">
835
+ <label>Title</label>
836
+ <frontend_type>text</frontend_type>
837
+ <sort_order>2</sort_order>
838
+ <show_in_default>1</show_in_default>
839
+ <show_in_website>1</show_in_website>
840
+ <show_in_store>1</show_in_store>
841
+ </title>
842
+ <config translate="label">
843
+ <label>Configuration</label>
844
+ <frontend_model>chronorelais/adminhtml_system_config_form_field_config</frontend_model>
845
+ <comment>{configuration_syntax_help}</comment>
846
+ <frontend_type>textarea</frontend_type>
847
+ <sort_order>3</sort_order>
848
+ <show_in_default>1</show_in_default>
849
+ <show_in_website>1</show_in_website>
850
+ <show_in_store>1</show_in_store>
851
+ </config>
852
+ <weight_limit translate="label">
853
+ <label>Weight Limit</label>
854
+ <frontend_type>text</frontend_type>
855
+ <comment>in Kg</comment>
856
+ <sort_order>7</sort_order>
857
+ <show_in_default>1</show_in_default>
858
+ <show_in_website>1</show_in_website>
859
+ <show_in_store>1</show_in_store>
860
+ </weight_limit>
861
+ <quickcost translate="label">
862
+ <label>Quickcost</label>
863
+ <frontend_type>select</frontend_type>
864
+ <comment>No : cost is obtained from your rate grid ; Yes : cost is fetched from URL below</comment>
865
+ <source_model>adminhtml/system_config_source_yesno</source_model>
866
+ <sort_order>10</sort_order>
867
+ <show_in_default>1</show_in_default>
868
+ <show_in_website>1</show_in_website>
869
+ <show_in_store>0</show_in_store>
870
+ </quickcost>
871
+ <quickcost_url>
872
+ <label>Quickcost Url</label>
873
+ <frontend_type>text</frontend_type>
874
+ <sort_order>11</sort_order>
875
+ <show_in_default>1</show_in_default>
876
+ <show_in_website>1</show_in_website>
877
+ <show_in_store>0</show_in_store>
878
+ </quickcost_url>
879
+ <free_shipping_enable translate="label">
880
+ <label>Free Shipping on the Amount</label>
881
+ <frontend_type>select</frontend_type>
882
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
883
+ <sort_order>12</sort_order>
884
+ <show_in_default>1</show_in_default>
885
+ <show_in_website>1</show_in_website>
886
+ <show_in_store>1</show_in_store>
887
+ </free_shipping_enable>
888
+ <free_shipping_subtotal translate="label">
889
+ <label>Minimum Amount for Free Shipping</label>
890
+ <frontend_type>text</frontend_type>
891
+ <sort_order>13</sort_order>
892
+ <show_in_default>1</show_in_default>
893
+ <show_in_website>1</show_in_website>
894
+ <show_in_store>0</show_in_store>
895
+ </free_shipping_subtotal>
896
+ <application_fee translate="label">
897
+ <label>Application Fee</label>
898
+ <frontend_type>text</frontend_type>
899
+ <sort_order>14</sort_order>
900
+ <show_in_default>1</show_in_default>
901
+ <show_in_website>1</show_in_website>
902
+ <show_in_store>1</show_in_store>
903
+ </application_fee>
904
+ <handling_fee translate="label">
905
+ <label>Handling Fee</label>
906
+ <frontend_type>text</frontend_type>
907
+ <sort_order>15</sort_order>
908
+ <show_in_default>1</show_in_default>
909
+ <show_in_website>1</show_in_website>
910
+ <show_in_store>1</show_in_store>
911
+ </handling_fee>
912
+ <logo_url>
913
+ <label>Logo Url</label>
914
+ <frontend_type>text</frontend_type>
915
+ <comment>{logo_ulr_help}</comment>
916
+ <sort_order>18</sort_order>
917
+ <show_in_default>1</show_in_default>
918
+ <show_in_website>1</show_in_website>
919
+ <show_in_store>1</show_in_store>
920
+ </logo_url>
921
+ <debug>
922
+ <label>Debug</label>
923
+ <comment>{debug_help}</comment>
924
+ <frontend_type>text</frontend_type>
925
+ <sort_order>20</sort_order>
926
+ <show_in_default>1</show_in_default>
927
+ <show_in_website>1</show_in_website>
928
+ <show_in_store>1</show_in_store>
929
+ </debug>
930
+ <!--<stop_to_first_match translate="label">
931
+ <label>Stop to first match</label>
932
+ <frontend_type>select</frontend_type>
933
+ <source_model>adminhtml/system_config_source_yesno</source_model>
934
+ <sort_order>22</sort_order>
935
+ <show_in_default>1</show_in_default>
936
+ <show_in_website>1</show_in_website>
937
+ <show_in_store>1</show_in_store>
938
+ </stop_to_first_match>-->
939
+ <deliver_on_saturday translate="label comment">
940
+ <label>Livraison le Samedi</label>
941
+ <comment>If yes has been selected, the option will be available every Thursdays from 6pm to Fridays at 3pm.</comment>
942
+ <frontend_type>select</frontend_type>
943
+ <source_model>adminhtml/system_config_source_yesno</source_model>
944
+ <sort_order>23</sort_order>
945
+ <show_in_default>1</show_in_default>
946
+ <show_in_website>1</show_in_website>
947
+ <show_in_store>1</show_in_store>
948
+ </deliver_on_saturday>
949
+ <!--<showmethod translate="label">
950
+ <label>Show Method if Not Applicable</label>
951
+ <frontend_type>select</frontend_type>
952
+ <sort_order>30</sort_order>
953
+ <frontend_class>shipping-skip-hide</frontend_class>
954
+ <source_model>adminhtml/system_config_source_yesno</source_model>
955
+ <show_in_default>1</show_in_default>
956
+ <show_in_website>1</show_in_website>
957
+ <show_in_store>0</show_in_store>
958
+ </showmethod>
959
+ <specificerrmsg translate="label">
960
+ <label>Displayed Error Message</label>
961
+ <frontend_type>textarea</frontend_type>
962
+ <sort_order>31</sort_order>
963
+ <show_in_default>1</show_in_default>
964
+ <show_in_website>1</show_in_website>
965
+ <show_in_store>1</show_in_store>
966
+ </specificerrmsg>-->
967
+ <sort_order translate="label">
968
+ <label>Sort order</label>
969
+ <frontend_type>text</frontend_type>
970
+ <sort_order>100</sort_order>
971
+ <show_in_default>1</show_in_default>
972
+ <show_in_website>1</show_in_website>
973
+ <show_in_store>1</show_in_store>
974
+ </sort_order>
975
+ </fields>
976
+ </chronopostcclassic>
977
+
978
+ </groups>
979
+ </carriers>
980
+ </sections>
981
+
982
+ <sections>
983
+ <chronorelais>
984
+ <label>Configuration</label>
985
+ <tab>chronopost</tab>
986
+ <frontend_type>text</frontend_type>
987
+ <sort_order>2000</sort_order>
988
+ <show_in_default>1</show_in_default>
989
+ <show_in_website>1</show_in_website>
990
+ <show_in_store>1</show_in_store>
991
+ <groups>
992
+ <shipping translate="label">
993
+ <label>General</label>
994
+ <frontend_type>text</frontend_type>
995
+ <sort_order>10</sort_order>
996
+ <show_in_default>1</show_in_default>
997
+ <show_in_website>1</show_in_website>
998
+ <show_in_store>1</show_in_store>
999
+ <fields>
1000
+ <account_number translate="label">
1001
+ <label>N° de compte Chronopost</label>
1002
+ <frontend_type>text</frontend_type>
1003
+ <sort_order>7</sort_order>
1004
+ <show_in_default>1</show_in_default>
1005
+ <show_in_website>1</show_in_website>
1006
+ <show_in_store>1</show_in_store>
1007
+ </account_number>
1008
+ <sub_account_number translate="label">
1009
+ <label>N° de sous-compte</label>
1010
+ <comment>must be 3 digits or empty</comment>
1011
+ <frontend_type>text</frontend_type>
1012
+ <sort_order>8</sort_order>
1013
+ <show_in_default>1</show_in_default>
1014
+ <show_in_website>1</show_in_website>
1015
+ <show_in_store>1</show_in_store>
1016
+ </sub_account_number>
1017
+ <account_pass translate="label">
1018
+ <label>Mot de passe Chronopost</label>
1019
+ <frontend_type>text</frontend_type>
1020
+ <button_label>Vérifier mes identifiants</button_label>
1021
+ <frontend_model>chronorelais/adminhtml_system_config_checklogin</frontend_model>
1022
+ <sort_order>9</sort_order>
1023
+ <show_in_default>1</show_in_default>
1024
+ <show_in_website>1</show_in_website>
1025
+ <show_in_store>1</show_in_store>
1026
+ </account_pass>
1027
+ <google_map_api translate="label">
1028
+ <label>Google Map v3 API Key</label>
1029
+ <comment>The Google Maps JavaScript API Version 2 has been officially deprecated. Please use v3 API now. Get your key at https://code.google.com/apis/console/.</comment>
1030
+ <frontend_type>text</frontend_type>
1031
+ <sort_order>10</sort_order>
1032
+ <show_in_default>1</show_in_default>
1033
+ <show_in_website>1</show_in_website>
1034
+ <show_in_store>1</show_in_store>
1035
+ </google_map_api>
1036
+ <tracking_view_url translate="label">
1037
+ <label>Tracking URL</label>
1038
+ <comment>For English language, replace fr_FR with en_GB in the above url</comment>
1039
+ <frontend_type>text</frontend_type>
1040
+ <sort_order>20</sort_order>
1041
+ <show_in_default>1</show_in_default>
1042
+ <show_in_website>1</show_in_website>
1043
+ <show_in_store>1</show_in_store>
1044
+ </tracking_view_url>
1045
+ <gs_path translate="label">
1046
+ <label>Chemin GS</label>
1047
+ <comment>Chemin d'accès à la commande gs (Ghostscript)</comment>
1048
+ <frontend_type>text</frontend_type>
1049
+ <sort_order>21</sort_order>
1050
+ <show_in_default>1</show_in_default>
1051
+ <show_in_website>0</show_in_website>
1052
+ <show_in_store>0</show_in_store>
1053
+ </gs_path>
1054
+
1055
+ </fields>
1056
+ </shipping>
1057
+ <export_css translate="label">
1058
+ <label>Export Configuration CSS</label>
1059
+ <frontend_type>text</frontend_type>
1060
+ <sort_order>20</sort_order>
1061
+ <show_in_default>1</show_in_default>
1062
+ <show_in_website>1</show_in_website>
1063
+ <show_in_store>1</show_in_store>
1064
+ <fields>
1065
+ <file_extension translate="label">
1066
+ <label>File Extension</label>
1067
+ <frontend_type>select</frontend_type>
1068
+ <source_model>chronorelais/config_source_fileExtension</source_model>
1069
+ <sort_order>10</sort_order>
1070
+ <show_in_default>1</show_in_default>
1071
+ <show_in_website>1</show_in_website>
1072
+ <show_in_store>1</show_in_store>
1073
+ </file_extension>
1074
+ <file_charset translate="label">
1075
+ <label>File Charset</label>
1076
+ <frontend_type>select</frontend_type>
1077
+ <source_model>chronorelais/config_source_fileCharset</source_model>
1078
+ <sort_order>20</sort_order>
1079
+ <show_in_default>1</show_in_default>
1080
+ <show_in_website>1</show_in_website>
1081
+ <show_in_store>1</show_in_store>
1082
+ </file_charset>
1083
+ <endofline_character translate="label">
1084
+ <label>End Of Line Character</label>
1085
+ <frontend_type>select</frontend_type>
1086
+ <source_model>chronorelais/config_source_endOfLineCharacter</source_model>
1087
+ <sort_order>30</sort_order>
1088
+ <show_in_default>1</show_in_default>
1089
+ <show_in_website>1</show_in_website>
1090
+ <show_in_store>1</show_in_store>
1091
+ </endofline_character>
1092
+ <field_delimiter translate="label">
1093
+ <label>Field Delimiter</label>
1094
+ <frontend_type>select</frontend_type>
1095
+ <source_model>chronorelais/config_source_fieldDelimiter</source_model>
1096
+ <sort_order>40</sort_order>
1097
+ <show_in_default>1</show_in_default>
1098
+ <show_in_website>1</show_in_website>
1099
+ <show_in_store>1</show_in_store>
1100
+ </field_delimiter>
1101
+ <field_separator translate="label">
1102
+ <label>Field Separator</label>
1103
+ <frontend_type>select</frontend_type>
1104
+ <source_model>chronorelais/config_source_fieldSeparator</source_model>
1105
+ <sort_order>50</sort_order>
1106
+ <show_in_default>1</show_in_default>
1107
+ <show_in_website>1</show_in_website>
1108
+ <show_in_store>1</show_in_store>
1109
+ </field_separator>
1110
+ </fields>
1111
+ </export_css>
1112
+ <export_cso translate="label">
1113
+ <label>Export Configuration CSO</label>
1114
+ <frontend_type>text</frontend_type>
1115
+ <sort_order>21</sort_order>
1116
+ <show_in_default>1</show_in_default>
1117
+ <show_in_website>1</show_in_website>
1118
+ <show_in_store>1</show_in_store>
1119
+ <fields>
1120
+ <file_extension translate="label">
1121
+ <label>File Extension</label>
1122
+ <frontend_type>select</frontend_type>
1123
+ <source_model>chronorelais/config_source_fileExtension</source_model>
1124
+ <sort_order>10</sort_order>
1125
+ <show_in_default>1</show_in_default>
1126
+ <show_in_website>1</show_in_website>
1127
+ <show_in_store>1</show_in_store>
1128
+ </file_extension>
1129
+ <file_charset translate="label">
1130
+ <label>File Charset</label>
1131
+ <frontend_type>select</frontend_type>
1132
+ <source_model>chronorelais/config_source_fileCharset</source_model>
1133
+ <sort_order>20</sort_order>
1134
+ <show_in_default>1</show_in_default>
1135
+ <show_in_website>1</show_in_website>
1136
+ <show_in_store>1</show_in_store>
1137
+ </file_charset>
1138
+ <endofline_character translate="label">
1139
+ <label>End Of Line Character</label>
1140
+ <frontend_type>select</frontend_type>
1141
+ <source_model>chronorelais/config_source_endOfLineCharacter</source_model>
1142
+ <sort_order>30</sort_order>
1143
+ <show_in_default>1</show_in_default>
1144
+ <show_in_website>1</show_in_website>
1145
+ <show_in_store>1</show_in_store>
1146
+ </endofline_character>
1147
+ <field_delimiter translate="label">
1148
+ <label>Field Delimiter</label>
1149
+ <frontend_type>select</frontend_type>
1150
+ <source_model>chronorelais/config_source_fieldDelimiter</source_model>
1151
+ <sort_order>40</sort_order>
1152
+ <show_in_default>1</show_in_default>
1153
+ <show_in_website>1</show_in_website>
1154
+ <show_in_store>1</show_in_store>
1155
+ </field_delimiter>
1156
+ <field_separator translate="label">
1157
+ <label>Field Separator</label>
1158
+ <frontend_type>select</frontend_type>
1159
+ <source_model>chronorelais/config_source_fieldSeparator</source_model>
1160
+ <sort_order>50</sort_order>
1161
+ <show_in_default>1</show_in_default>
1162
+ <show_in_website>1</show_in_website>
1163
+ <show_in_store>1</show_in_store>
1164
+ </field_separator>
1165
+ </fields>
1166
+ </export_cso>
1167
+ <import translate="label">
1168
+ <label>Import Configuration</label>
1169
+ <frontend_type>text</frontend_type>
1170
+ <sort_order>30</sort_order>
1171
+ <show_in_default>1</show_in_default>
1172
+ <show_in_website>1</show_in_website>
1173
+ <show_in_store>1</show_in_store>
1174
+ <fields>
1175
+ <default_tracking_title translate="label comment">
1176
+ <label>Default Tracking Title</label>
1177
+ <frontend_type>text</frontend_type>
1178
+ <sort_order>10</sort_order>
1179
+ <show_in_default>1</show_in_default>
1180
+ <show_in_website>1</show_in_website>
1181
+ <show_in_store>1</show_in_store>
1182
+ <comment>This value can be changed in the import form</comment>
1183
+ </default_tracking_title>
1184
+ <send_email translate="label comment">
1185
+ <label>Send an e-mail</label>
1186
+ <frontend_type>select</frontend_type>
1187
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1188
+ <sort_order>20</sort_order>
1189
+ <show_in_default>1</show_in_default>
1190
+ <show_in_website>1</show_in_website>
1191
+ <show_in_store>1</show_in_store>
1192
+ <comment>Send shipping confirmation to the customer</comment>
1193
+ </send_email>
1194
+ <shipping_comment translate="label comment">
1195
+ <label>Shipping Comment</label>
1196
+ <frontend_type>text</frontend_type>
1197
+ <sort_order>30</sort_order>
1198
+ <show_in_default>1</show_in_default>
1199
+ <show_in_website>1</show_in_website>
1200
+ <show_in_store>1</show_in_store>
1201
+ <comment>Internal comment, can be left empty</comment>
1202
+ </shipping_comment>
1203
+ <include_comment translate="label comment">
1204
+ <label>Include comment into e-mail</label>
1205
+ <frontend_type>select</frontend_type>
1206
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1207
+ <sort_order>40</sort_order>
1208
+ <show_in_default>1</show_in_default>
1209
+ <show_in_website>1</show_in_website>
1210
+ <show_in_store>1</show_in_store>
1211
+ <comment>Only applies if the shipping comment is set</comment>
1212
+ </include_comment>
1213
+ </fields>
1214
+ </import>
1215
+
1216
+ <shipperinformation translate="label">
1217
+ <label>Shipper Information for Labels printing</label>
1218
+ <frontend_type>text</frontend_type>
1219
+ <sort_order>40</sort_order>
1220
+ <show_in_default>1</show_in_default>
1221
+ <show_in_website>1</show_in_website>
1222
+ <show_in_store>1</show_in_store>
1223
+ <fields>
1224
+ <civility translate="label">
1225
+ <label>Shipper Civility</label>
1226
+ <frontend_type>select</frontend_type>
1227
+ <source_model>chronorelais/config_source_civility</source_model>
1228
+ <sort_order>10</sort_order>
1229
+ <show_in_default>1</show_in_default>
1230
+ <show_in_website>1</show_in_website>
1231
+ <show_in_store>1</show_in_store>
1232
+ </civility>
1233
+ <name translate="label comment">
1234
+ <label>Shipper Name</label>
1235
+ <frontend_type>text</frontend_type>
1236
+ <sort_order>20</sort_order>
1237
+ <show_in_default>1</show_in_default>
1238
+ <show_in_website>1</show_in_website>
1239
+ <show_in_store>1</show_in_store>
1240
+ <comment>Company name</comment>
1241
+ </name>
1242
+ <name2 translate="label comment">
1243
+ <label>Shipper Name2</label>
1244
+ <frontend_type>text</frontend_type>
1245
+ <sort_order>30</sort_order>
1246
+ <show_in_default>1</show_in_default>
1247
+ <show_in_website>1</show_in_website>
1248
+ <show_in_store>1</show_in_store>
1249
+ <comment>[Optional]</comment>
1250
+ </name2>
1251
+ <address1 translate="label">
1252
+ <label>Shipper Address1</label>
1253
+ <frontend_type>text</frontend_type>
1254
+ <sort_order>40</sort_order>
1255
+ <show_in_default>1</show_in_default>
1256
+ <show_in_website>1</show_in_website>
1257
+ <show_in_store>1</show_in_store>
1258
+ </address1>
1259
+ <address2 translate="label comment">
1260
+ <label>Shipper Address2</label>
1261
+ <frontend_type>text</frontend_type>
1262
+ <sort_order>50</sort_order>
1263
+ <show_in_default>1</show_in_default>
1264
+ <show_in_website>1</show_in_website>
1265
+ <show_in_store>1</show_in_store>
1266
+ <comment>[Optional]</comment>
1267
+ </address2>
1268
+ <zipcode translate="label">
1269
+ <label>Shipper Zipcode</label>
1270
+ <frontend_type>text</frontend_type>
1271
+ <sort_order>60</sort_order>
1272
+ <show_in_default>1</show_in_default>
1273
+ <show_in_website>1</show_in_website>
1274
+ <show_in_store>1</show_in_store>
1275
+ </zipcode>
1276
+ <city translate="label">
1277
+ <label>Shipper City</label>
1278
+ <frontend_type>text</frontend_type>
1279
+ <sort_order>70</sort_order>
1280
+ <show_in_default>1</show_in_default>
1281
+ <show_in_website>1</show_in_website>
1282
+ <show_in_store>1</show_in_store>
1283
+ </city>
1284
+ <country translate="label">
1285
+ <label>Shipper Country</label>
1286
+ <frontend_type>select</frontend_type>
1287
+ <sort_order>80</sort_order>
1288
+ <source_model>adminhtml/system_config_source_country</source_model>
1289
+ <show_in_default>1</show_in_default>
1290
+ <show_in_website>1</show_in_website>
1291
+ <show_in_store>1</show_in_store>
1292
+ </country>
1293
+ <contactname translate="label">
1294
+ <label>Shipper Contact Name</label>
1295
+ <frontend_type>text</frontend_type>
1296
+ <sort_order>90</sort_order>
1297
+ <show_in_default>1</show_in_default>
1298
+ <show_in_website>1</show_in_website>
1299
+ <show_in_store>1</show_in_store>
1300
+ </contactname>
1301
+ <email translate="label">
1302
+ <label>Shipper Email</label>
1303
+ <frontend_type>text</frontend_type>
1304
+ <sort_order>100</sort_order>
1305
+ <show_in_default>1</show_in_default>
1306
+ <show_in_website>1</show_in_website>
1307
+ <show_in_store>1</show_in_store>
1308
+ <comment>[Optional]</comment>
1309
+ </email>
1310
+ <phone translate="label comment">
1311
+ <label>Shipper Telephone</label>
1312
+ <frontend_type>text</frontend_type>
1313
+ <sort_order>110</sort_order>
1314
+ <show_in_default>1</show_in_default>
1315
+ <show_in_website>1</show_in_website>
1316
+ <show_in_store>1</show_in_store>
1317
+ <comment>[Optional]</comment>
1318
+ </phone>
1319
+ <mobilephone translate="label comment">
1320
+ <label>Shipper Mobile</label>
1321
+ <frontend_type>text</frontend_type>
1322
+ <sort_order>120</sort_order>
1323
+ <show_in_default>1</show_in_default>
1324
+ <show_in_website>1</show_in_website>
1325
+ <show_in_store>1</show_in_store>
1326
+ <comment>[Optional]</comment>
1327
+ </mobilephone>
1328
+ </fields>
1329
+ </shipperinformation>
1330
+
1331
+ <customerinformation translate="label">
1332
+ <label>Chronopost Customer Account Information for Labels printing</label>
1333
+ <frontend_type>text</frontend_type>
1334
+ <sort_order>50</sort_order>
1335
+ <show_in_default>1</show_in_default>
1336
+ <show_in_website>1</show_in_website>
1337
+ <show_in_store>1</show_in_store>
1338
+ <fields>
1339
+ <civility translate="label">
1340
+ <label>Customer Civility</label>
1341
+ <frontend_type>select</frontend_type>
1342
+ <source_model>chronorelais/config_source_civility</source_model>
1343
+ <sort_order>10</sort_order>
1344
+ <show_in_default>1</show_in_default>
1345
+ <show_in_website>1</show_in_website>
1346
+ <show_in_store>1</show_in_store>
1347
+ </civility>
1348
+ <name translate="label comment">
1349
+ <label>Customer Name </label>
1350
+ <frontend_type>text</frontend_type>
1351
+ <sort_order>20</sort_order>
1352
+ <show_in_default>1</show_in_default>
1353
+ <show_in_website>1</show_in_website>
1354
+ <show_in_store>1</show_in_store>
1355
+ <comment>Company name</comment>
1356
+ </name>
1357
+ <name2 translate="label comment">
1358
+ <label>Customer Name2</label>
1359
+ <frontend_type>text</frontend_type>
1360
+ <sort_order>30</sort_order>
1361
+ <show_in_default>1</show_in_default>
1362
+ <show_in_website>1</show_in_website>
1363
+ <show_in_store>1</show_in_store>
1364
+ <comment>[Optional]</comment>
1365
+ </name2>
1366
+ <address1 translate="label">
1367
+ <label>Customer Address1</label>
1368
+ <frontend_type>text</frontend_type>
1369
+ <sort_order>40</sort_order>
1370
+ <show_in_default>1</show_in_default>
1371
+ <show_in_website>1</show_in_website>
1372
+ <show_in_store>1</show_in_store>
1373
+ </address1>
1374
+ <address2 translate="label comment">
1375
+ <label>Customer Address2</label>
1376
+ <frontend_type>text</frontend_type>
1377
+ <sort_order>50</sort_order>
1378
+ <show_in_default>1</show_in_default>
1379
+ <show_in_website>1</show_in_website>
1380
+ <show_in_store>1</show_in_store>
1381
+ <comment>[Optional]</comment>
1382
+ </address2>
1383
+ <zipcode translate="label">
1384
+ <label>Customer Zipcode</label>
1385
+ <frontend_type>text</frontend_type>
1386
+ <sort_order>60</sort_order>
1387
+ <show_in_default>1</show_in_default>
1388
+ <show_in_website>1</show_in_website>
1389
+ <show_in_store>1</show_in_store>
1390
+ </zipcode>
1391
+ <city translate="label">
1392
+ <label>Customer City</label>
1393
+ <frontend_type>text</frontend_type>
1394
+ <sort_order>70</sort_order>
1395
+ <show_in_default>1</show_in_default>
1396
+ <show_in_website>1</show_in_website>
1397
+ <show_in_store>1</show_in_store>
1398
+ </city>
1399
+ <country translate="label">
1400
+ <label>Customer Country</label>
1401
+ <frontend_type>select</frontend_type>
1402
+ <sort_order>80</sort_order>
1403
+ <source_model>adminhtml/system_config_source_country</source_model>
1404
+ <show_in_default>1</show_in_default>
1405
+ <show_in_website>1</show_in_website>
1406
+ <show_in_store>1</show_in_store>
1407
+ </country>
1408
+ <contactname translate="label">
1409
+ <label>Customer Contact Name</label>
1410
+ <frontend_type>text</frontend_type>
1411
+ <sort_order>90</sort_order>
1412
+ <show_in_default>1</show_in_default>
1413
+ <show_in_website>1</show_in_website>
1414
+ <show_in_store>1</show_in_store>
1415
+ </contactname>
1416
+ <email translate="label">
1417
+ <label>Customer Email</label>
1418
+ <frontend_type>text</frontend_type>
1419
+ <sort_order>100</sort_order>
1420
+ <show_in_default>1</show_in_default>
1421
+ <show_in_website>1</show_in_website>
1422
+ <show_in_store>1</show_in_store>
1423
+ <comment>[Optional]</comment>
1424
+ </email>
1425
+ <phone translate="label comment">
1426
+ <label>Customer Telephone</label>
1427
+ <frontend_type>text</frontend_type>
1428
+ <sort_order>110</sort_order>
1429
+ <show_in_default>1</show_in_default>
1430
+ <show_in_website>1</show_in_website>
1431
+ <show_in_store>1</show_in_store>
1432
+ <comment>[Optional]</comment>
1433
+ </phone>
1434
+ <mobilephone translate="label comment">
1435
+ <label>Customer Mobile</label>
1436
+ <frontend_type>text</frontend_type>
1437
+ <sort_order>120</sort_order>
1438
+ <show_in_default>1</show_in_default>
1439
+ <show_in_website>1</show_in_website>
1440
+ <show_in_store>1</show_in_store>
1441
+ <comment>[Optional]</comment>
1442
+ </mobilephone>
1443
+ </fields>
1444
+ </customerinformation>
1445
+
1446
+ <skybillparam translate="label">
1447
+ <label>Skybill Parameters for Labels printing</label>
1448
+ <frontend_type>text</frontend_type>
1449
+ <sort_order>60</sort_order>
1450
+ <show_in_default>1</show_in_default>
1451
+ <show_in_website>1</show_in_website>
1452
+ <show_in_store>1</show_in_store>
1453
+ <fields>
1454
+ <mode translate="label">
1455
+ <label>Print Mode</label>
1456
+ <frontend_type>select</frontend_type>
1457
+ <source_model>chronorelais/config_source_printMode</source_model>
1458
+ <sort_order>10</sort_order>
1459
+ <show_in_default>1</show_in_default>
1460
+ <show_in_website>1</show_in_website>
1461
+ <show_in_store>1</show_in_store>
1462
+ <required>1</required>
1463
+ </mode>
1464
+ </fields>
1465
+ </skybillparam>
1466
+
1467
+ <weightunit translate="label">
1468
+ <label>Weight unit for the store</label>
1469
+ <frontend_type>text</frontend_type>
1470
+ <sort_order>70</sort_order>
1471
+ <show_in_default>1</show_in_default>
1472
+ <show_in_website>1</show_in_website>
1473
+ <show_in_store>1</show_in_store>
1474
+ <fields>
1475
+ <unit translate="label">
1476
+ <label>Weight unit</label>
1477
+ <frontend_type>select</frontend_type>
1478
+ <source_model>chronorelais/config_source_weightUnit</source_model>
1479
+ <sort_order>10</sort_order>
1480
+ <show_in_default>1</show_in_default>
1481
+ <show_in_website>1</show_in_website>
1482
+ <show_in_store>1</show_in_store>
1483
+ <required>1</required>
1484
+ </unit>
1485
+ </fields>
1486
+ </weightunit>
1487
+
1488
+ <optionbal translate="label">
1489
+ <label>Option BAL</label>
1490
+ <frontend_type>text</frontend_type>
1491
+ <sort_order>80</sort_order>
1492
+ <show_in_default>1</show_in_default>
1493
+ <show_in_website>1</show_in_website>
1494
+ <show_in_store>1</show_in_store>
1495
+ <fields>
1496
+ <enabled translate="label">
1497
+ <label>Activer l'option BAL de Chronopost</label>
1498
+ <frontend_type>select</frontend_type>
1499
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1500
+ <comment>Vérifiez que cette option figure dans votre contrat</comment>
1501
+ <sort_order>10</sort_order>
1502
+ <show_in_default>1</show_in_default>
1503
+ <show_in_website>1</show_in_website>
1504
+ <show_in_store>1</show_in_store>
1505
+ <required>1</required>
1506
+ </enabled>
1507
+ </fields>
1508
+ </optionbal>
1509
+
1510
+ <assurance translate="label">
1511
+ <label>Assurance Ad Valorem</label>
1512
+ <frontend_type>text</frontend_type>
1513
+ <frontend_model>chronorelais/adminhtml_system_config_form_fieldsetassurance</frontend_model>
1514
+ <sort_order>90</sort_order>
1515
+ <show_in_default>1</show_in_default>
1516
+ <show_in_website>1</show_in_website>
1517
+ <show_in_store>1</show_in_store>
1518
+ <fields>
1519
+ <enabled translate="label">
1520
+ <label>Activer l'Ad Valorem</label>
1521
+ <frontend_type>select</frontend_type>
1522
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1523
+ <sort_order>1</sort_order>
1524
+ <show_in_default>1</show_in_default>
1525
+ <show_in_website>1</show_in_website>
1526
+ <show_in_store>1</show_in_store>
1527
+ <required>1</required>
1528
+ </enabled>
1529
+ <amount translate="label">
1530
+ <label>Montant minimum à assurer</label>
1531
+ <frontend_type>text</frontend_type>
1532
+ <sort_order>2</sort_order>
1533
+ <show_in_default>1</show_in_default>
1534
+ <show_in_website>1</show_in_website>
1535
+ <show_in_store>1</show_in_store>
1536
+ <required>0</required>
1537
+ <validate>validate-number</validate>
1538
+ </amount>
1539
+ </fields>
1540
+ </assurance>
1541
+
1542
+ </groups>
1543
+ </chronorelais>
1544
+ </sections>
1545
+
1546
  </config>
app/code/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php CHANGED
@@ -19,1248 +19,1349 @@
19
  * @author Antoine Lemoine
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
-
23
- class ChronorelaisShippingHelper
24
- {
25
- public static $DEBUG_INDEX_COUNTER = 0;
26
- public static $FLOAT_REGEX = '[-]?\d+(?:[.]\d+)?';
27
- public static $POSITIVE_FLOAT_REGEX = '\d+(?:[.]\d+)?';
28
- //public static $COUPLE_REGEX = '(?:[0-9.]+|\*)(?:\[|\])?\:[0-9.]+(?:\:[0-9.]+%?)*';
29
- public static $COUPLE_REGEX = '(?:[0-9.]+|\*) *(?:\[|\])? *\: *[0-9.]+';
30
- public static $UNCOMPRESSED_STRINGS = array(
31
- ' product.attribute.',
32
- ' product.option.',
33
- ' product.stock.',
34
- '{product.attribute.',
35
- '{product.option.',
36
- '{product.stock.',
37
- '{product.weight}',
38
- '{product.quantity}',
39
- '{cart.weight}',
40
- '{cart.quantity}',
41
- '{cart.price_including_tax}',
42
- '{cart.price_excluding_tax}',
43
- '{cart.',
44
- '{customvar.',
45
- '{selection.weight}',
46
- '{selection.quantity}',
47
- '{selection.',
48
- '{destination.country.',
49
- '{foreach ',
50
- '{/foreach}',
51
- );
52
- public static $COMPRESSED_STRINGS = array(
53
- ' p.a.',
54
- ' p.o.',
55
- ' p.s.',
56
- '{p.a.',
57
- '{p.o.',
58
- '{p.s.',
59
- '{p.w}',
60
- '{p.qty}',
61
- '{c.w}',
62
- '{c.qty}',
63
- '{c.pit}',
64
- '{c.pet}',
65
- '{c.',
66
- '{v.',
67
- '{s.w}',
68
- '{s.qty}',
69
- '{s.',
70
- '{dest.ctry.',
71
- '{each ',
72
- '{/each}',
73
- );
74
-
75
- protected $_input;
76
- protected $_config;
77
- protected $_messages;
78
- protected $_formula_cache;
79
- protected $_expression_cache;
80
- public $debug = 0;
81
- public $debug_output = '';
82
- public $debug_header = null;
83
-
84
- public function ChronorelaisShippingHelper($input) {
85
- $this->_formula_cache = array();
86
- $this->_messages = array();
87
- $this->_input = $input;
88
- $this->_config = array();
89
- $this->_parseInput();
90
- }
91
-
92
- private function debug($text, $level=10) {
93
- if ($this->debug>=$level) $this->debug_output .= "<p>".$text."</p>";
94
- }
95
-
96
- public function printDebug() {
97
- if ($this->debug>0) {
98
- $index = self::$DEBUG_INDEX_COUNTER++;
99
- echo "<style rel=\"stylesheet\" type=\"text/css\">"
100
- .".osh-formula{color:#f90;} .osh-key{color:#0099f7;}"
101
- .".osh-error{color:#f00;} .osh-warning{color:#ff0;} .osh-info{color:#7bf700;}"
102
- .".osh-debug{background:#000;color:#bbb;position:absolute;top:0;left:0;width:100%;z-index:100;-moz-opacity:0.9;opacity:0.9;text-align:left;white-space:pre-wrap;}"
103
- .".osh-debug-content{padding:10px;}"
104
- .".osh-replacement{color:#ff3000;}"
105
- ."</style>"
106
- ."<div id=\"osh-debug-".$index."\" class=\"osh-debug\"><pre class=\"osh-debug-content\"><span style=\"float:right;cursor:pointer;\" onclick=\"document.getElementById('osh-debug-".$index."').style.display = 'none';\">[<span style=\"padding:0 5px;color:#f00;\">X</span>]</span>"
107
- ."<p>".$this->debug_header."</p>".$this->debug_output."</pre></div>";
108
- }
109
- }
110
-
111
- public function setDebugHeader($process) {
112
- $header = 'DEBUG app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronorelaisShippingHelper.php<br/>';
113
- foreach ($process['data'] as $key => $data) {
114
- $header .= ' <span class="osh-key">'.$key.'</span> = <span class="osh-formula">'.$this->_toString($data).'</span><br/>';
115
- }
116
- $this->debug_header = $header;
117
- }
118
-
119
- public function getConfig() {
120
- return $this->_config;
121
- }
122
-
123
- public function getMessages() {
124
- $messages = $this->_messages;
125
- $this->_messages = array();
126
- return $messages;
127
- }
128
-
129
- public function formatConfig($compress) {
130
- $output = '';
131
- foreach ($this->_config as $code => $row) {
132
- if (!isset($row['lines'])) {
133
- if (isset($row['*comment']['value'])) {
134
- $output .= trim($row['*comment']['value'])."\n";
135
- }
136
- $output .= '{'.($compress ? '' : "\n");
137
- foreach ($row as $key => $property) {
138
- if (substr($key,0,1)!='*') {
139
- $value = $property['value'];
140
- if (isset($property['comment'])) $output .= ($compress ? '' : "\t").'/* '.$property['comment'].' */'.($compress ? '' : "\n");
141
- $output .= ($compress ? '' : "\t").$key.':'.($compress ? '' : ' ');
142
- if (is_bool($value)) $output .= $value ? 'true' : 'false';
143
- else if (is_int($value)) $output .= $value;
144
- else if ((string)((float)$value)==$value) $output .= $value;
145
- else $output .= '"'.str_replace('"','\\"',$value).'"';
146
- $output .= ','.($compress ? '' : "\n");
147
- }
148
- }
149
- if ($compress) $output = preg_replace('/,$/','',$output);
150
- $output .= "}\n".($compress ? '' : "\n");
151
- } else {
152
- $output .= $row['lines']."\n";
153
- }
154
- }
155
- return $compress ? $this->compress($output) : $this->uncompress($output);
156
- }
157
-
158
- public function checkConfig() {
159
- $process = array(
160
- 'result' => null,
161
- 'data' => array(
162
- 'cart.price_excluding_tax' => 0,
163
- 'cart.price_including_tax' => 0,
164
- 'destination.country.code' => '',
165
- 'destination.country.name' => '',
166
- 'destination.region.code' => '',
167
- 'destination.postcode' => '',
168
- 'origin.country.code' => '',
169
- 'origin.country.name' => '',
170
- 'origin.region.code' => '',
171
- 'origin.postcode' => '',
172
- 'free_shipping' => false,
173
- 'customer.group.id' => '',
174
- 'customer.group.code' => '',
175
- 'cart.weight' => 0,
176
- 'cart.weight.unit' => 'kg',
177
- 'cart.quantity' => 0,
178
- ),
179
- 'cart.items' => array(),
180
- 'products' => array(),
181
- 'config' => $this->_config,
182
- );
183
- foreach ($this->_config as $code => &$row) {
184
- $this->processRow($process,$row,$check_all_conditions=true);
185
- foreach ($row as $property_key => $property_value) {
186
- if (substr($property_key,0,1)!='*') $this->getRowProperty($row,$property_key);
187
- }
188
- }
189
- }
190
-
191
- public function processRow($process, &$row, $is_checking=false) {
192
- if (!isset($row['*code'])) return;
193
-
194
- self::debug('process row <span class="osh-key">'.$row['*code'].'</span>',1);
195
- if (!isset($row['label']['value'])) $row['label']['value'] = '***';
196
-
197
- $enabled = $this->getRowProperty($row,'enabled');
198
- if (isset($enabled)) {
199
- if (!$is_checking && !$enabled) {
200
- $this->addMessage('info',$row,'enabled','Configuration disabled');
201
- return new OCS_Result(false);
202
- }
203
- }
204
-
205
- $conditions = $this->getRowProperty($row,'conditions');
206
- if (isset($conditions)) {
207
- $result = $this->_processFormula($process,$row,'conditions',$conditions,$is_checking);
208
- if (!$is_checking) {
209
- if (!$result->success) return $result;
210
- if (!$result->result) {
211
- $this->addMessage('info',$row,'conditions',"The cart doesn't match conditions");
212
- return new OCS_Result(false);
213
- }
214
- }
215
- }
216
-
217
- $destination = $this->getRowProperty($row,'destination');
218
- if (isset($destination)) {
219
- $destination_match = $this->_addressMatch($destination,array(
220
- 'country_code' => $process['data']['destination.country.code'],
221
- 'region_code' => $process['data']['destination.region.code'],
222
- 'postcode' => $process['data']['destination.postcode']
223
- ));
224
- if (!$is_checking && !$destination_match) {
225
- $this->addMessage('info',$row,'destination',"The shipping method doesn't cover the zone");
226
- return new OCS_Result(false);
227
- }
228
- }
229
-
230
- $origin = $this->getRowProperty($row,'origin');
231
- if (isset($origin)) {
232
- $origin_match = $this->_addressMatch($origin,array(
233
- 'country_code' => $process['data']['origin.country.code'],
234
- 'region_code' => $process['data']['origin.region.code'],
235
- 'postcode' => $process['data']['origin.postcode']
236
- ));
237
- if (!$is_checking && !$origin_match) {
238
- $this->addMessage('info',$row,'origin',"The shipping method doesn't match to shipping origin");
239
- return new OCS_Result(false);
240
- }
241
- }
242
-
243
- $customer_groups = $this->getRowProperty($row,'customer_groups');
244
- if (isset($customer_groups)) {
245
- $groups = explode(',',$customer_groups);
246
- $group_match = false;
247
- //self::debug('code:'.$process['data']['customer.group.code'].', id:'.$process['data']['customer.group.id']);
248
- foreach ($groups as $group) {
249
- $group = trim($group);
250
- if ($group==$process['data']['customer.group.code'] || is_int($group) && $group==$process['data']['customer.group.id'] || $group=='*') {
251
- $group_match = true;
252
- break;
253
- }
254
- }
255
- if (!$is_checking && !$group_match) {
256
- $this->addMessage('info',$row,'customer_groups',"The shipping method doesn't match to customer group (%s)",$process['data']['customer.group.code']);
257
- return new OCS_Result(false);
258
- }
259
- }
260
-
261
- //Chronopost quickcost method for dynamic price if it is set enabled
262
- $quickcost = Mage::getStoreConfig('carriers/'.$process['data']['carrier.code'].'/quickcost');
263
- if($quickcost) {
264
- if($quickCostValues = $this->getQuickCostValue($process['data'])) {
265
- if($quickCostValues->errorCode==0) {
266
- return new OCS_Result(true,(float)$quickCostValues->amountTTC);
267
- } else {
268
- $this->addMessage('error',$row,'chronopost',$quickCostValues->errorMessage);
269
- return new OCS_Result(false);
270
- }
271
- } else {
272
- return new OCS_Result(false);
273
- }
274
- }
275
-
276
- $fees = $this->getRowProperty($row,'fees');
277
- if (isset($fees)) {
278
- $result = $this->_processFormula($process,$row,'fees',$fees,$is_checking);
279
- if (!$result->success) return $result;
280
- self::debug(' => <span class="osh-info">result = <span class="osh-formula">'.$this->_toString($result->result).'</span>',1);
281
- return new OCS_Result(true,(float)$result->result);
282
- }
283
-
284
- return new OCS_Result(false);
285
- }
286
-
287
- public function getQuickCostValue($processData) {
288
- $quickCost = array();
289
- $_helper = Mage::helper('chronorelais');
290
- $account_number = $_helper->getConfigurationAccountNumber();
291
- $password = $_helper->getConfigurationAccountPass();
292
- $productCode = $_helper->getChronoProductCode($processData['destination.country.code'], $processData['carrier.code']);
293
- $origin_postcode = $_helper->getConfigurationShipperInfo('zipcode');
294
-
295
- //to get arrival code
296
- $arrCode = $processData['destination.postcode'];
297
- if($processData['carrier.code']=='chronoexpress') {
298
- $arrCode = $processData['destination.country.code'];
299
- }
300
-
301
- $quickCost = array(
302
- 'contratNumber' => $account_number,
303
- 'depCode' => $origin_postcode,
304
- 'arrCode' => $arrCode,
305
- 'weight' => $processData['cart.weight'],
306
- 'productCode' => $productCode,
307
- 'type' => 'M',
308
- 'password' => $password
309
- );
310
-
311
- try {
312
- $quickcost_url = Mage::helper('chronorelais')->getConfigData('carriers/'.$processData['carrier.code'].'/quickcost_url');
313
- if(!$quickcost_url) { $quickcost_url = "http://wsshipping.chronopost.fr/wsQuickcost/services/ServiceQuickCost?wsdl"; }
314
- $client = new SoapClient($quickcost_url);
315
- $webservbt = $client->__call("quickCost",$quickCost);
316
- return $webservbt;
317
- } catch(SoapFault $fault) {
318
- $this->addMessage('info',$row,'chronopost',$fault->faultstring);
319
- return false;
320
- }
321
- }
322
-
323
- public function getRowProperty(&$row, $key, $original_row=null, $original_key=null) {
324
- $property = null;
325
- $output = null;
326
- if (isset($original_row) && isset($original_key) && $original_row['*code']==$row['*code'] && $original_key==$key) {
327
- $this->addMessage('error',$row,$key,'Infinite loop %s',"<span class=\"code\">{".$row['*code'].'.'.$key."}</span>");
328
- return array('error' => 'Infinite loop');
329
- }
330
- if (isset($row[$key]['value'])) {
331
- $property = $row[$key]['value'];
332
- $output = $property;
333
- self::debug(' get <span class="osh-key">'.$row['*code'].'</span>.<span class="osh-key">'.$key.'</span> = <span class="osh-formula">'.$this->_toString($property).'</span>',5);
334
- preg_match_all('/{([a-z0-9_]+)\.([a-z0-9_]+)}/i',$output,$result_set,PREG_SET_ORDER);
335
- foreach ($result_set as $result) {
336
- list($original,$ref_code,$ref_key) = $result;
337
- if (!in_array($ref_code,array('module','date','store','cart','product','selection','customvar'))) {
338
- if ($ref_code==$row['code']['value'] && $ref_key==$key) {
339
- $this->addMessage('error',$row,$key,'Infinite loop %s',"<span class=\"code\">".$original."</span>");
340
- return null;
341
- }
342
- if (isset($this->_config[$ref_code][$ref_key]['value'])) {
343
- $replacement = $this->getRowProperty($this->_config[$ref_code],$ref_key,
344
- isset($original_row) ? $original_row : $row,isset($original_key) ? $original_key : $key);
345
- if (is_array($replacement) && isset($replacement['error'])) {
346
- return isset($original_row) ? $replacement : 'false';
347
- }
348
- } else {
349
- $this->addMessage('error',$row,$key,'Non-existent property %s',"<span class=\"code\">".$original."</span>");
350
- $replacement = 'null';
351
- }
352
- $output = $this->replace($original,$replacement,$output);
353
- }
354
- }
355
- } else {
356
- self::debug(' get <span class="osh-key">'.$row['*code'].'</span>.<span class="osh-key">'.$key.'</span> = <span class="osh-formula">null</span>',5);
357
- }
358
- return $output;
359
- }
360
-
361
- protected function _toString($value) {
362
- if (!isset($value)) return 'null';
363
- else if (is_bool($value)) return $value ? 'true' : 'false';
364
- else return $value;
365
- }
366
-
367
- protected function replace($from, $to, $input) {
368
- if ($from===$to) return $input;
369
- if (strpos($input,$from)===false) return $input;
370
- $to = $this->_toString($to);
371
- self::debug(' replace <span class="osh-replacement">'.$this->_toString($from).'</span> by <span class="osh-replacement">'.$to.'</span> =&gt; <span class="osh-formula">'.str_replace($from,'<span class="osh-replacement">'.$to.'</span>',$input).'</span>',5);
372
- return str_replace($from,$to,$input);
373
- }
374
-
375
- protected function _min() {
376
- $args = func_get_args();
377
- $min = null;
378
- foreach ($args as $arg) {
379
- if (isset($arg) && (!isset($min) || $min>$arg)) $min = $arg;
380
- }
381
- return $min;
382
- }
383
-
384
- protected function _max() {
385
- $args = func_get_args();
386
- $max = null;
387
- foreach ($args as $arg) {
388
- if (isset($arg) && (!isset($max) || $max<$arg)) $max = $arg;
389
- }
390
- return $max;
391
- }
392
-
393
- protected function _processFormula($process, &$row, $property_key, $formula_string, $is_checking, $use_cache=true)
394
- {
395
- $result = $this->_prepareFormula($process,$row,$property_key,$formula_string,$is_checking,$use_cache);
396
- if (!$result->success) return $result;
397
-
398
- $eval_result = $this->_evalFormula($result->result);
399
- if (!isset($eval_result)) {
400
- $this->addMessage('error',$row,$property_key,'Invalid formula');
401
- $result = new OCS_Result(false);
402
- if ($use_cache) $this->setCache($formula_string,$result);
403
- return $result;
404
- }
405
- self::debug(' formula evaluation = <span class="osh-formula">'.$this->_toString($eval_result).'</span>',10);
406
- $result = new OCS_Result(true,$eval_result);
407
- if ($use_cache) $this->setCache($formula_string,$result);
408
- return $result;
409
- }
410
-
411
- public function evalInput($process, $row, $property_key, $input) {
412
- $result = $this->_prepareFormula($process,$row,$property_key,$input,$is_checking=false,$use_cache=true);
413
- return $result->success ? $result->result : $input;
414
- }
415
-
416
- protected function setCache($expression, $value) {
417
- if ($value instanceof OCS_Result) {
418
- $this->_formula_cache[$expression] = $value;
419
- self::debug(' cache <span class="osh-replacement">'.$expression.'</span> = <span class="osh-formula">'.$this->_toString($this->_formula_cache[$expression]).'</span>',10);
420
- } else {
421
- $value = $this->_toString($value);
422
- $this->_expression_cache[$expression] = $value;
423
- self::debug(' cache <span class="osh-replacement">'.$expression.'</span> = <span class="osh-formula">'.$value.'</span>',10);
424
- }
425
- }
426
-
427
- protected function _prepareFormula($process, $row, $property_key, $formula_string, $is_checking, $use_cache=true)
428
- {
429
- if ($use_cache && isset($this->_formula_cache[$formula_string])) {
430
- $result = $this->_formula_cache[$formula_string];
431
- self::debug(' get cached formula <span class="osh-replacement">'.$formula_string.'</span> = <span class="osh-formula">'.$this->_toString($result->result).'</span>',10);
432
- return $result;
433
- }
434
-
435
- $formula = $formula_string;
436
- //self::debug(' formula = <span class="osh-formula">'.$formula.'</span>',10);
437
-
438
- while (preg_match("#{foreach product\.((?:attribute|option)\.(?:[a-z0-9_]+))}(.*){/foreach}#i",$formula,$result)) {
439
- $original = $result[0];
440
- if ($use_cache && isset($this->_expression_cache[$original])) {
441
- $replacement = $this->_expression_cache[$original];
442
- self::debug(' get cached expression <span class="osh-replacement">'.$original.'</span> = <span class="osh-formula">'.$replacement.'</span>',10);
443
- }
444
- else {
445
- $replacement = 0;
446
- list($filter_property_type,$filter_property_name) = explode('.',$result[1]);
447
- $selections = array();
448
- self::debug(' :: foreach <span class="osh-key">'.$filter_property_type.'</span>.<span class="osh-key">'.$filter_property_name.'</span>',10);
449
- foreach ($process['products'] as $product) {
450
- $tmp_value = $this->_getProductProperty($product,$filter_property_type,$filter_property_name,$get_by_id=false);
451
- self::debug(' products[<span class="osh-formula">'.$product->getName().'</span>].<span class="osh-key">'.$filter_property_type.'</span>.<span class="osh-key">'.$filter_property_name.'</span> = <span class="osh-formula">'.$this->_toString($tmp_value).'</span>',10);
452
- $key = 'val_'.$tmp_value;
453
- $sel = isset($selections[$key]) ? $selections[$key] : null;
454
- $selections[$key]['products'][] = $product;
455
- $selections[$key]['weight'] = (isset($sel['weight']) ? $sel['weight'] : 0)+$product->getAttribute('weight')*$product->getQuantity();
456
- $selections[$key]['quantity'] = (isset($sel['quantity']) ? $sel['quantity'] : 0)+$product->getQuantity();
457
- }
458
- self::debug(' :: start foreach',10);
459
- foreach ($selections as $selection) {
460
- $process2 = $process;
461
- $process2['products'] = $selection['products'];
462
- $process2['data']['selection.quantity'] = $selection['quantity'];
463
- $process2['data']['selection.weight'] = $selection['weight'];
464
- $process_result = $this->_processFormula($process2,$row,$property_key,$result[2],$is_checking,$tmp_use_cache=false);
465
- $replacement += $process_result->result;
466
- }
467
- self::debug(' :: end foreach <span class="osh-key">'.$filter_property_type.'</span>.<span class="osh-key">'.$filter_property_name.'</span>',10);
468
- if ($use_cache) $this->setCache($original,$replacement);
469
- }
470
- $formula = $this->replace($original,$replacement,$formula);
471
- }
472
-
473
- $formula = str_replace(array("\n","\t"),array('',''),$formula);
474
-
475
- while (preg_match("#{customvar\.([a-z0-9_]+)}#i",$formula,$result)) {
476
- $original = $result[0];
477
- $replacement = Mage::getModel('core/variable')->loadByCode($result[1])->getValue('plain');
478
- $formula = $this->replace($original,$replacement,$formula);
479
- }
480
-
481
- $first_product = isset($process['products'][0]) ? $process['products'][0] : null;
482
- if (!isset($process['data']['selection.weight'])) $process['data']['selection.weight'] = $process['data']['cart.weight'];
483
- if (!isset($process['data']['selection.quantity'])) $process['data']['selection.quantity'] = $process['data']['cart.quantity'];
484
- $process['data']['product.weight'] = isset($first_product) ? $first_product->getAttribute('weight') : 0;
485
- $process['data']['product.quantity'] = isset($first_product) ? $first_product->getQuantity() : 0;
486
-
487
- foreach ($process['data'] as $original => $replacement) {
488
- $formula = $this->replace('{'.$original.'}',$replacement,$formula);
489
- }
490
-
491
- if (isset($first_product)) {
492
- while (preg_match("#{product\.(attribute|option|stock)\.([a-z0-9_]+)}#i",$formula,$result)) {
493
- $original = $result[0];
494
- switch ($result[1]) {
495
- case 'attribute': $replacement = $first_product->getAttribute($result[2]); break;
496
- case 'option': $replacement = $first_product->getOption($result[2]); break;
497
- case 'stock': $replacement = $first_product->getStockData($result[2]); break;
498
- }
499
- $formula = $this->replace($original,$replacement,$formula);
500
- }
501
- }
502
-
503
- //while (preg_match("/{(count|all|any) (attribute|option) '([^'\)]+)' ?(==|<=|>=|<|>|!=) ?(".self::$FLOAT_REGEX."|true|false|'[^'\)]*')}/",$formula,$result)
504
- // || preg_match("/{(sum|count distinct) (attribute|option) '([^'\)]+)'}/",$formula,$result))
505
- while (preg_match("/{(count) products(?: where ([^}]+))?}/i",$formula,$result)
506
- || preg_match("/{(sum|count distinct) product\.(attribute|option)\.([a-z0-9_]+)(?: where ([^}]+))?}/i",$formula,$result)) {
507
- $original = $result[0];
508
- if ($use_cache && isset($this->_expression_cache[$original])) {
509
- $replacement = $this->_expression_cache[$original];
510
- self::debug(' get cached expression <span class="osh-replacement">'.$original.'</span> = <span class="osh-formula">'.$replacement.'</span>',10);
511
- }
512
- else {
513
- $replacement = $this->_processProductProperty($process['products'],$result);
514
- if ($use_cache) $this->setCache($result[0],$replacement);
515
- }
516
- $formula = $this->replace($original,$replacement,$formula);
517
- }
518
-
519
- //while (preg_match("/{table '([^']+)' ([^}]+)}/",$formula,$result))
520
- while (preg_match("/{table ([^}]+) in ([0-9\.:,\*\[\] ]+)}/i",$formula,$result)) {
521
- $original = $result[0];
522
- if ($use_cache && isset($this->_expression_cache[$original])) {
523
- $replacement = $this->_expression_cache[$original];
524
- self::debug(' get cached expression <span class="osh-replacement">'.$original.'</span> = <span class="osh-formula">'.$replacement.'</span>',10);
525
- } else {
526
- $reference_value = $this->_evalFormula($result[1]);
527
- if (isset($reference_value)) {
528
- $fees_table_string = $result[2];
529
-
530
- if (!preg_match('#^'.self::$COUPLE_REGEX.'(?:, *'.self::$COUPLE_REGEX.')*$#',$fees_table_string)) {
531
- $this->addMessage('error',$row,$property_key,'Error in table %s','<span class="osh-formula">'.htmlentities($result[0]).'</span>');
532
- $result = new OCS_Result(false);
533
- if ($use_cache) $this->setCache($formula_string,$result);
534
- return $result;
535
- }
536
- $fees_table = explode(',',$fees_table_string);
537
-
538
- $replacement = null;
539
- foreach ($fees_table as $item) {
540
- $fee_data = explode(':',$item);
541
-
542
- $fee = trim($fee_data[1]);
543
- $max_value = trim($fee_data[0]);
544
-
545
- $last_char = $max_value{strlen($max_value)-1};
546
- if ($last_char=='[') $including_max_value = false;
547
- else if ($last_char==']') $including_max_value = true;
548
- else $including_max_value = true;
549
-
550
- $max_value = str_replace(array('[',']'),'',$max_value);
551
-
552
- if ($max_value=='*' || $including_max_value && $reference_value<=$max_value || !$including_max_value && $reference_value<$max_value) {
553
- $replacement = $fee;//$this->_calculateFee($process,$fee,$var);
554
- break;
555
- }
556
- }
557
- }
558
- $replacement = $this->_toString($replacement);
559
- if ($use_cache) $this->setCache($original,$replacement);
560
- }
561
- $formula = $this->replace($original,$replacement,$formula);
562
- }
563
- $result = new OCS_Result(true,$formula);
564
- return $result;
565
- }
566
-
567
- protected function _evalFormula($formula) {
568
- if (is_bool($formula)) return $formula;
569
- if (!preg_match('/^(?:floor|ceil|round|max|min|rand|pow|pi|sqrt|log|exp|abs|int|float|true|false|null|and|or|in|substr|strtolower'
570
- .'|in_array\(\'(?:[^\']*)\', *array\( *(?:\'(?:[^\']+)\') *(?: *, *\'(?:[^\']+)\')* *\) *\)'
571
- .'|\'[^\']*\'|[0-9,\'\.\-\(\)\*\/\?\:\+\<\>\=\&\|%! ])*$/',$formula)) {
572
- $errors = array(
573
- PREG_NO_ERROR => 'PREG_NO_ERROR',
574
- PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR',
575
- PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR',
576
- PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR',
577
- PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR',
578
- PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR',
579
- );
580
- $error = preg_last_error();
581
- if (isset($errors[$error])) $error = $errors[$error];
582
- self::debug(' doesn\'t match ('.$error.')',10);
583
- return null;
584
- }
585
- $formula = str_replace(
586
- array('min','max'),
587
- array('$this->_min','$this->_max'),
588
- $formula
589
- );
590
- $eval_result = null;
591
- @eval('$eval_result = ('.$formula.');');
592
- return $eval_result;
593
- }
594
-
595
- protected function _getOptionsAndData($string) {
596
- if (preg_match('/^(\\s*\(\\s*([^\] ]*)\\s*\)\\s*)/',$string,$result)) {
597
- $options = $result[2];
598
- $data = str_replace($result[1],'',$string);
599
- } else {
600
- $options = '';
601
- $data = $string;
602
- }
603
- return array(
604
- 'options' => $options,
605
- 'data' => $data,
606
- );
607
- }
608
-
609
- public function compress($input) {
610
- if (preg_match_all("/{table (.*) in (".self::$COUPLE_REGEX."(?:, *".self::$COUPLE_REGEX.")*)}/imsU",$input,$result,PREG_SET_ORDER)) {
611
- foreach ($result as $result_i) {
612
- $fees_table = explode(',',$result_i[2]);
613
- $value = null;
614
- foreach ($fees_table as $index => $item) {
615
- list($max_value,$fee) = explode(':',$item);
616
- $last_char = $max_value{strlen($max_value)-1};
617
- if (in_array($last_char,array('[',']'))) {
618
- $including_char = $last_char;
619
- $max_value = str_replace(array('[',']'),'',$max_value);
620
- } else $including_char = '';
621
- $fees_table[$index] = ((float)$max_value).$including_char.':'.((float)$fee);
622
- }
623
- $input = str_replace($result_i[2],implode(',',$fees_table),$input);
624
- $input = str_replace($result_i[1],trim($result_i[1]),$input);
625
- }
626
- }
627
- if (preg_match_all("#{foreach ([^}]*)}(.*){/foreach}#imsU",$input,$result,PREG_SET_ORDER)) {
628
- foreach ($result as $result_i) {
629
- $input = str_replace($result_i[1],trim($result_i[1]),$input);
630
- $input = str_replace($result_i[2],trim($result_i[2]),$input);
631
- }
632
- }
633
- return '$$'.str_replace(
634
- self::$UNCOMPRESSED_STRINGS,
635
- self::$COMPRESSED_STRINGS,
636
- $input
637
- );
638
- }
639
-
640
- public function uncompress($input) {
641
- if (preg_match_all("/{table (.*) in (".self::$COUPLE_REGEX."(?:, *".self::$COUPLE_REGEX.")*)}/iU",$input,$result,PREG_SET_ORDER)) {
642
- foreach ($result as $result_i) {
643
- $fees_table = explode(',',$result_i[2]);
644
- $value = null;
645
- foreach ($fees_table as $index => $item) {
646
- list($max_value,$fee) = explode(':',$item);
647
- $last_char = $max_value{strlen($max_value)-1};
648
- if (in_array($last_char,array('[',']'))) {
649
- $including_char = $last_char;
650
- $max_value = str_replace(array('[',']'),'',$max_value);
651
- } else $including_char = '';
652
- $max_value = (float)$max_value;
653
- $fee = (float)$fee;
654
- $new_max_value = number_format($max_value,2,'.','');
655
- $new_fee = number_format($fee,2,'.','');
656
- $fees_table[$index] = (((float)$new_max_value)==$max_value ? $new_max_value : $max_value).$including_char.':'
657
- .(((float)$new_fee)==$fee ? $new_fee : $fee);
658
- }
659
- $input = str_replace($result_i[2],implode(', ',$fees_table),$input);
660
- $input = str_replace($result_i[1],trim($result_i[1]),$input);
661
- }
662
- }
663
- if (preg_match_all("#{foreach ([^}]*)}(.*){/foreach}#iU",$input,$result,PREG_SET_ORDER)) {
664
- foreach ($result as $result_i) {
665
- $input = str_replace($result_i[1],trim($result_i[1]),$input);
666
- $input = str_replace($result_i[2],trim($result_i[2]),$input);
667
- }
668
- }
669
- return str_replace(
670
- self::$COMPRESSED_STRINGS,
671
- self::$UNCOMPRESSED_STRINGS,
672
- $input
673
- );
674
- }
675
-
676
- public function parseProperty($input) {
677
- $value = $input==='false' || $input==='true' ? $input=='true' : str_replace('\"','"',preg_replace('/^(?:"|\')(.*)(?:"|\')$/s','$1',$input));
678
- return $value==='' ? null : $value;
679
- }
680
-
681
- public function cleanProperty(&$row, $key) {
682
- $input = $row[$key]['value'];
683
- if (is_string($input)) {
684
- $input = str_replace(array("\n"),array(''),$input);
685
- while (preg_match('/({TABLE |{SUM |{COUNT | DISTINCT | IN )/',$input,$resi)) {
686
- $input = str_replace($resi[0],strtolower($resi[0]),$input);
687
- }
688
-
689
- while (preg_match('/{{customVar code=([a-zA-Z0-9_-]+)}}/',$input,$resi)) {
690
- $input = str_replace($resi[0],'{customvar.'.$resi[1].'}',$input);
691
- }
692
-
693
- $regex = "{(weight|products_quantity|price_including_tax|price_excluding_tax|country)}";
694
- if (preg_match('/'.$regex.'/',$input,$resi)) {
695
- $this->addMessage('warning',$row,$key,'Usage of deprecated syntax %s','<span class="osh-formula">'.$resi[0].'</span>');
696
- while (preg_match('/'.$regex.'/',$input,$resi)) {
697
- switch ($resi[1]) {
698
- case 'price_including_tax':
699
- case 'price_excluding_tax':
700
- case 'weight':
701
- $input = str_replace($resi[0],"{cart.".$resi[1]."}",$input);
702
- break;
703
- case 'products_quantity': $input = str_replace($resi[0],"{cart.quantity}",$input); break;
704
- case 'country': $input = str_replace($resi[0],"{destination.country.name}",$input); break;
705
- }
706
- }
707
- }
708
-
709
- $regex1 = "{copy '([a-zA-Z0-9_]+)'\.'([a-zA-Z0-9_]+)'}";
710
- if (preg_match('/'.$regex1.'/',$input,$resi)) {
711
- $this->addMessage('warning',$row,$key,'Usage of deprecated syntax %s','<span class="osh-formula">'.$resi[0].'</span>');
712
- while (preg_match('/'.$regex1.'/',$input,$resi)) $input = str_replace($resi[0],'{'.$resi[1].'.'.$resi[2].'}',$input);
713
- }
714
-
715
- $regex1 = "{(count|all|any) (attribute|option) '([^'\)]+)' ?((?:==|<=|>=|<|>|!=) ?(?:".self::$FLOAT_REGEX."|true|false|'[^'\)]*'))}";
716
- $regex2 = "{(sum) (attribute|option) '([^'\)]+)'}";
717
- if (preg_match('/'.$regex1.'/',$input,$resi) || preg_match('/'.$regex2.'/',$input,$resi)) {
718
- $this->addMessage('warning',$row,$key,'Usage of deprecated syntax %s','<span class="osh-formula">'.$resi[0].'</span>');
719
- while (preg_match('/'.$regex1.'/',$input,$resi) || preg_match('/'.$regex2.'/',$input,$resi)) {
720
- switch ($resi[1]) {
721
- case 'count': $input = str_replace($resi[0],"{count products where product.".$resi[2]."s.".$resi[3].$resi[4]."}",$input); break;
722
- case 'all': $input = str_replace($resi[0],"{count products where product.".$resi[2]."s.".$resi[3].$resi[4]."}=={products_quantity}",$input); break;
723
- case 'any': $input = str_replace($resi[0],"{count products where product.".$resi[2]."s.".$resi[3].$resi[4]."}>0",$input); break;
724
- case 'sum': $input = str_replace($resi[0],"{sum product.".$resi[2].".".$resi[3]."}",$input); break;
725
- }
726
- }
727
- }
728
-
729
- $regex = "((?:{| )product.(?:attribute|option))s.";
730
- if (preg_match('/'.$regex.'/',$input,$resi)) {
731
- $this->addMessage('warning',$row,$key,'Usage of deprecated syntax %s','<span class="osh-formula">'.$resi[0].'</span>');
732
- while (preg_match('/'.$regex.'/',$input,$resi)) {
733
- $input = str_replace($resi[0],$resi[1].'.',$input);
734
- }
735
- }
736
-
737
- $regex = "{table '([^']+)' (".self::$COUPLE_REGEX."(?:, *".self::$COUPLE_REGEX.")*)}";
738
- if (preg_match('/'.$regex.'/',$input,$resi)) {
739
- $this->addMessage('warning',$row,$key,'Usage of deprecated syntax %s','<span class="osh-formula">'.$resi[0].'</span>');
740
- while (preg_match('/'.$regex.'/',$input,$resi)) {
741
- switch ($resi[1]) {
742
- case 'products_quantity':
743
- $input = str_replace($resi[0],"{table {cart.weight} in ".$resi[2]."}*{cart.quantity}",$input);
744
- break;
745
- default:
746
- $input = str_replace($resi[0],"{table {cart.".$resi[1]."} in ".$resi[2]."}",$input);
747
- break;
748
- }
749
- }
750
- }
751
- }
752
- $row[$key]['value'] = $input;
753
- }
754
-
755
- protected function _parseInput() {
756
- $config_string = str_replace(
757
- array('&gt;','&lt;','“','”',utf8_encode(chr(147)),utf8_encode(chr(148)),'&laquo;','&raquo;',"\r\n","\t"),
758
- array('>','<','"','"','"','"','"','"',"\n",' '),
759
- $this->_input
760
- );
761
-
762
- if (substr($config_string,0,2)=='$$') $config_string = $this->uncompress(substr($config_string,2,strlen($config_string)));
763
-
764
- //echo ini_get('pcre.backtrack_limit');
765
- //exit;
766
-
767
- $row_regex = ' *([a-z0-9_]+)\\s*:\\s*("(?:(?:[^"]|\\\\")*[^\\\\])?"|'.self::$FLOAT_REGEX.'|false|true)\\s*(,)? *(?:\\n)?';
768
- if (!preg_match_all('/((?:#+[^{\\n]*\\s+)*)\\s*(#)?{\\s*('.$row_regex.')+\\s*}/i',$config_string,$result,PREG_SET_ORDER)) {
769
- $errors = array(
770
- PREG_NO_ERROR => 'PREG_NO_ERROR',
771
- PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR',
772
- PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR',
773
- PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR',
774
- PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR',
775
- PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR',
776
- );
777
- $error = preg_last_error();
778
- if (isset($errors[$error])) $error = $errors[$error];
779
- self::debug(' preg_match_all error ('.$error.')',10);
780
- }
781
-
782
- $this->_config = array();
783
- $available_keys = array(
784
- 'code','label','enabled','description','fees','conditions','destination','origin','customer_groups','tracking_url',
785
- 'fees_table','fees_formula','fixed_fees','reference_value',
786
- 'prices_range','weights_range','product_properties',
787
- 'free_shipping__fees_table','free_shipping__fees_formula','free_shipping__fixed_fees','free_shipping__label',
788
- );
789
-
790
- foreach ($result as $block) {
791
- $deprecated_properties = array();
792
- $unknown_properties = array();
793
- $missing_semicolon = array();
794
- $obsolete_disabling_method = array();
795
-
796
- //$before = strstr($config_string,$block[0],true); // Seulement compatible avec PHP 5.3.0
797
- list($before) = explode($block[0],$config_string,2);
798
- if ($before!==false && trim($before)!='') {
799
- $config_string = substr($config_string,strlen($before));
800
- $this->_addIgnoredLines(trim($before));
801
- $this->addMessage('info',$row=null,null,'Ignored lines %s','<div class="code">'.trim($before).'</div>');
802
- }
803
-
804
- $config_string = str_replace($block[0], '', $config_string);
805
- preg_match_all('/'.$row_regex.'/i',$block[0],$result2,PREG_SET_ORDER);
806
- $block_string = $block[0];
807
-
808
- $row = array();
809
- $i = 1;
810
- foreach ($result2 as $data) {
811
- $key = $data[1];
812
- if (in_array($key,$available_keys) || substr($key,0,1)=='_') {
813
- $property = $this->parseProperty($data[2]);
814
- if (isset($property)) {
815
- $row[$key] = array('value' => $property, 'original_value' => $property);
816
- $this->cleanProperty($row,$key);
817
- }
818
- if ($i>2) {
819
- $block_string = str_replace($data[0],$i==3 ? "...\n" : '',$block_string);
820
- }
821
- if ($i!=count($result2) && !isset($data[3]) || isset($data[3]) && $data[3]!=',') {
822
- if (preg_match('/^("|\')(.{40})(.*)("|\')$/s',$data[2],$resultx))
823
- $missing_semicolon[] = trim(str_replace($data[2],$resultx[1].$resultx[2].' ...'.$resultx[4],$data[0]));
824
- else $missing_semicolon[] = trim($data[0]);
825
- }
826
- } else {
827
- if (!in_array($key,$unknown_properties)) $unknown_properties[] = $key;
828
- }
829
- $i++;
830
- }
831
- if ($block[1]!='') $row['*comment']['value'] = $block[1];
832
- if ($block[2]=='#' && !isset($row['enabled'])) {
833
- $row['enabled'] = array('value' => false);
834
- $obsolete_disabling_method[] = $block_string;
835
- }
836
-
837
- $formula_fields_to_check = array();
838
- if (isset($row['conditions'])) $formula_fields_to_check[] = 'conditions';
839
- if (isset($row['fees'])) $formula_fields_to_check[] = 'fees';
840
-
841
- if (count($formula_fields_to_check)>0) {
842
- foreach ($formula_fields_to_check as $property) {
843
- $property_value = $row[$property]['value'];
844
- if (preg_match('/{ +/',$property_value)) {
845
- $this->addMessage('warning',$row,$property,'There are unwanted spaces after char `%s`','{');
846
- $property_value = preg_replace('/{ +/','{',$property_value);
847
- }
848
- if (preg_match('/ +}/',$property_value)) {
849
- $this->addMessage('warning',$row,$property,'There are unwanted spaces before char `%s`','}');
850
- $property_value = preg_replace('/ +}/','}',$property_value);
851
- }
852
- if (preg_match('/ +/',$property_value)) {
853
- $this->addMessage('warning',$row,$property,'There are unwanted multiples spaces `%s`',preg_replace('/( +)/','<span class="osh-formula">*$1*</span>',$property_value));
854
- $property_value = preg_replace('/ +/',' ',$property_value);
855
- }
856
- $row[$property]['value'] = trim($property_value);
857
- }
858
- }
859
-
860
- $float_value_regex = '\\s*('.self::$POSITIVE_FLOAT_REGEX.'|\*)\\s*';
861
- $conditions = array();
862
- if (isset($row['prices_range'])) {
863
- if (!in_array('prices_range',$deprecated_properties)) $deprecated_properties[] = 'prices_range';
864
-
865
- $result = $this->_getOptionsAndData($row['prices_range']['value']);
866
- $options = $result['options'];
867
- $prices_range = $result['data'];
868
-
869
- if (($options=='' || in_array($options,array('incl.tax','ttc')))
870
- && preg_match('/^\\s*(\[|\])?'.$float_value_regex.'=>'.$float_value_regex.'(\[|\])?\\s*$/',$prices_range,$result)) {
871
- $min_price_included = $result[1]=='[';
872
- $min_price = $result[2]=='*' ? -1 : (float)$result[2];
873
- $max_price = $result[3]=='*' ? -1 : (float)$result[3];
874
- $max_price_included = !isset($result[4]) || $result[4]==']' || $result[4]=='';
875
-
876
- $tax_included = $options!='' && in_array($options,array('incl.tax','ttc')) || isset($row['reference_value']) && $row['reference_value']['value']=='price_including_tax';
877
- $price = $tax_included ? '{cart.price_including_tax}' : '{cart.price_excluding_tax}';
878
-
879
- if ($min_price!=-1) $conditions[] = $price.'>'.($min_price_included ? '=' : '').$min_price;
880
- if ($max_price!=-1) $conditions[] = $price.'<'.($max_price_included ? '=' : '').$max_price;
881
- }
882
- else $this->addMessage('error',$row,null,'Unrecognized value of deprecated property %s %s','<span class="osh-key">prices_range</span>','<span class="osh-formula">'.$row['prices_range']['value'].'</span>');
883
- unset($row['prices_range']);
884
- }
885
- if (isset($row['weights_range'])) {
886
- if (!in_array('weights_range',$deprecated_properties)) $deprecated_properties[] = 'weights_range';
887
- if (preg_match('/^\\s*(\[|\])?'.$float_value_regex.'=>'.$float_value_regex.'(\[|\])?\\s*$/',$row['weights_range']['value'],$result)) {
888
- $min_weight_included = $result[1]=='[';
889
- $min_weight = $result[2]=='*' ? -1 : (float)$result[2];
890
- $max_weight = $result[3]=='*' ? -1 : (float)$result[3];
891
- $max_weight_included = !isset($result[4]) || $result[4]==']' || $result[4]=='';
892
-
893
- if ($min_weight!=-1) $conditions[] = '{cart.weight}>'.($min_weight_included ? '=' : '').$min_weight;
894
- if ($max_weight!=-1) $conditions[] = '{cart.weight}<'.($max_weight_included ? '=' : '').$max_weight;
895
- }
896
- else $this->addMessage('error',$row,null,'Unrecognized value of deprecated property %s %s','<span class="osh-key">weights_range</span>','<span class="osh-formula">'.$row['weights_range']['value'].'</span>');
897
- unset($row['weights_range']);
898
- }
899
- if (isset($row['product_properties'])) {
900
- if (!in_array('product_properties',$deprecated_properties)) $deprecated_properties[] = 'product_properties';
901
- $product_property_regex = "\\s*(and|or)? *\((?:(all|any|sum) )?(attribute|option) '([^'\)]+)' ?(==|=|<=|>=|<|>|!=) ?(".self::$FLOAT_REGEX."|true|false|'[^'\)]*')\)\\s*";
902
- if (preg_match('/^('.$product_property_regex.')+$/',$row['product_properties']['value'],$result)) {
903
- preg_match_all('/'.$product_property_regex.'/',$row['product_properties']['value'],$results,PREG_SET_ORDER);
904
- $product_properties_condition = '';
905
- foreach ($results as $result) {
906
- $and_or = $result[1];
907
- if ($and_or=='') $and_or = 'and';
908
- $any_all_sum = $result[2];
909
- if ($any_all_sum=='') $any_all_sum = 'any';
910
- $property_type = $result[3];
911
- $property_name = $result[4];
912
- $cmp_symbol = $result[5];
913
- if ($cmp_symbol=='=') $cmp_symbol = '==';
914
- $cmp_value = $result[6];
915
-
916
- $product_properties_condition .= $product_properties_condition=='' ? '' : ' '.$and_or.' ';
917
- switch ($any_all_sum) {
918
- case 'sum':
919
- $product_properties_condition .= "{sum product.".$property_type.".".$property_name."}".$cmp_symbol.$cmp_value;
920
- break;
921
- case 'all':
922
- $product_properties_condition .= "{count products where product.".$property_type.".".$property_name.$cmp_symbol.$cmp_value."}=={products_quantity}";
923
- break;
924
- case 'any':
925
- $product_properties_condition .= "{count products where product.".$property_type.".".$property_name.$cmp_symbol.$cmp_value."}>0";
926
- break;
927
- }
928
- }
929
- if ($product_properties_condition!='') $conditions[] = $product_properties_condition;
930
- }
931
- else $this->addMessage('error',$row,null,'Unrecognized value of deprecated property %s %s','<span class="osh-key">product_properties</span>','<span class="osh-formula">'.$row['product_properties']['value'].'</span>');
932
- unset($row['product_properties']);
933
- }
934
- if (count($conditions)>0) $row['conditions'] = array('value' => count($conditions)==1 ? $conditions[0] : '('.implode(') && (',$conditions).')');
935
-
936
- $fees = array();
937
- if (isset($row['fees_table'])) {
938
- if (!in_array('fees_table',$deprecated_properties)) $deprecated_properties[] = 'fees_table';
939
- $options_and_data = $this->_getOptionsAndData($row['fees_table']['value']);
940
- $options = $options_and_data['options'];
941
- $fees_table_string = $options_and_data['data'];
942
-
943
- $var = null;
944
- if ($options=='') $var = (isset($row['reference_value']) ? $row['reference_value']['value'] : 'weight');
945
- else if (in_array($options,array('incl.tax','ttc'))) $var = 'price_including_tax';
946
- else if (in_array($options,array('excl.tax','ht'))) $var = 'price_excluding_tax';
947
-
948
- if (isset($var)) {
949
- if ($var=='price') $var = 'price_excluding_tax';
950
- if ($var=='products_quantity') $var = 'quantity';
951
- if (preg_match('/^[[:space:]]*\*[[:space:]]*:[[:space:]]*('.$float_value_regex.')[[:space:]]*$/s',$fees_table_string,$result)) $fees[] = $result[1];
952
- else $fees[] = "{table {cart.".$var."} in ".str_replace(' ','',$fees_table_string)."}".($var=='quantity' ? '*{cart.quantity}' : '');
953
- }
954
- else $this->addMessage('error',$row,null,'Unrecognized value of deprecated property %s %s','<span class="osh-key">fees_table</span>','<span class="osh-formula">'.$row['fees_table']['value'].'</span>');
955
- unset($row['fees_table']);
956
- }
957
- if (isset($row['fees_formula'])) {
958
- if (!in_array('fees_formula',$deprecated_properties)) $deprecated_properties[] = 'fees_formula';
959
- $fees[] = str_replace(' ','',$row['fees_formula']['value']);
960
- unset($row['fees_formula']);
961
- }
962
- if (isset($row['fixed_fees'])) {
963
- if (!in_array('fixed_fees',$deprecated_properties)) $deprecated_properties[] = 'fixed_fees';
964
- if ($row['fixed_fees']['value']!=0 || count($fees)==0) $fees[] = str_replace(' ','',$row['fixed_fees']['value']);
965
- unset($row['fixed_fees']);
966
- }
967
- if (!isset($row['fees']) && count($fees)>0) $row['fees'] = array('value' => implode('+',$fees));
968
-
969
- $fs_fees = array();
970
- if (isset($row['free_shipping__fees_table'])) {
971
- if (!in_array('free_shipping__fees_table',$deprecated_properties)) $deprecated_properties[] = 'free_shipping__fees_table';
972
- $options_and_data = $this->_getOptionsAndData($row['free_shipping__fees_table']['value']);
973
- $options = $options_and_data['options'];
974
- $fees_table_string = $options_and_data['data'];
975
-
976
- $var = null;
977
- if ($options=='') $var = isset($row['reference_value']) ? $row['reference_value']['value'] : 'weight';
978
- else if (in_array($options,array('incl.tax','ttc'))) $var = 'price_including_tax';
979
- else if (in_array($options,array('excl.tax','ht'))) $var = 'price_excluding_tax';
980
- if ($var=='price') $var = 'price_excluding_tax';
981
-
982
- if (isset($var)) {
983
- if ($var=='price') $var = 'price_excluding_tax';
984
- if ($var=='products_quantity') $var = 'quantity';
985
- if (preg_match('/^[[:space:]]*\*[[:space:]]*:[[:space:]]*('.$float_value_regex.')[[:space:]]*$/s',$fees_table_string,$result)) $fs_fees[] = $result[1];
986
- else $fs_fees[] = "{table {cart.".$var."} in ".str_replace(' ','',$fees_table_string)."}".($var=='quantity' ? '*{cart.quantity}' : '');
987
- }
988
- else $this->addMessage('error',$row,null,'Unrecognized value of deprecated property %s %s','<span class="osh-key">free_shipping__fees_table</span>','<span class="osh-formula">'.$row['free_shipping__fees_table']['value'].'</span>');
989
- unset($row['free_shipping__fees_table']);
990
- }
991
- if (isset($row['free_shipping__fees_formula'])) {
992
- if (!in_array('free_shipping__fees_formula',$deprecated_properties)) $deprecated_properties[] = 'free_shipping__fees_formula';
993
- $fs_fees[] = str_replace(' ','',$row['free_shipping__fees_formula']['value']);
994
- unset($row['free_shipping__fees_formula']);
995
- }
996
- if (isset($row['free_shipping__fixed_fees'])) {
997
- if (!in_array('free_shipping__fixed_fees',$deprecated_properties)) $deprecated_properties[] = 'free_shipping__fixed_fees';
998
- if ($row['free_shipping__fixed_fees']['value']!=0 || count($fees)==0) $fs_fees[] = str_replace(' ','',$row['free_shipping__fixed_fees']['value']);
999
- unset($row['free_shipping__fixed_fees']);
1000
- }
1001
-
1002
- if (isset($row['reference_value'])) {
1003
- if (!in_array('reference_value',$deprecated_properties)) $deprecated_properties[] = 'reference_value';
1004
- unset($row['reference_value']);
1005
- }
1006
-
1007
- if (count($fs_fees)>0) {
1008
- $row2 = $row;
1009
- if (isset($row['code'])) $row2['code']['value'] = $row['code']['value'].'__free_shipping';
1010
- $row2['fees']['value'] = implode('+',$fs_fees);
1011
- $row2['conditions']['value'] = isset($row2['conditions']) ? '('.$row2['conditions']+') and {free_shipping}' : '{free_shipping}';
1012
- $row['conditions']['value'] = isset($row['conditions']) ? '('.$row['conditions']+') and !{free_shipping}' : '!{free_shipping}';
1013
- if (isset($row['free_shipping__label'])) {
1014
- if (!in_array('free_shipping__label',$deprecated_properties)) $deprecated_properties[] = 'free_shipping__label';
1015
- $row2['label']['value'] = $row['free_shipping__label']['value'];
1016
- unset($row['free_shipping__label']);
1017
- unset($row2['free_shipping__label']);
1018
- }
1019
- $this->_addRow($row2);
1020
- }
1021
- if (count($unknown_properties)>0) $this->addMessage('error',$row,null,'Usage of unknown properties %s',': <span class="osh-key">'.implode('</span>, <span class="osh-key">',$unknown_properties).'</span>');
1022
- if (count($deprecated_properties)>0) $this->addMessage('warning',$row,null,'Usage of deprecated properties %s',': <span class="osh-key">'.implode('</span>, <span class="osh-key">',$deprecated_properties).'</span>');
1023
- if (count($obsolete_disabling_method)>0) $this->addMessage('warning',$row,null,'Usage of obsolete method to disabling a shipping method (`#` before `{`)%s','<div class="code">'.implode('<br />',$obsolete_disabling_method).'</div>');
1024
- if (count($missing_semicolon)>0) $this->addMessage('warning',$row,null,'A semicolon is missing at the end of following lines %s','<div class="code">'.implode('<br />',$missing_semicolon).'</div>');
1025
- $this->_addRow($row);
1026
- }
1027
- if (trim($config_string)!='') {
1028
- $this->_addIgnoredLines(trim($config_string));
1029
- $this->addMessage('info',$row=null,null,'Ignored lines %s','<div class="code">'.trim($config_string).'</div>');
1030
- }
1031
- }
1032
-
1033
- public function addMessage($type, &$row, $property) {
1034
- $args = func_get_args();
1035
- array_shift($args);
1036
- array_shift($args);
1037
- array_shift($args);
1038
- $message = new OCS_Message($type,$args);
1039
- if (isset($row)) {
1040
- if (isset($property)) {
1041
- $row[$property]['messages'][] = $message;
1042
- } else {
1043
- $row['*messages'][] = $message;
1044
- }
1045
- }
1046
- $this->_messages[] = $message;
1047
- self::debug(' => <span class="osh-'.$message->type.'">'.$message->toString().'</span>',1);
1048
- }
1049
-
1050
- protected function _addRow(&$row) {
1051
- if (isset($row['code'])) {
1052
- $key = $row['code']['value'];
1053
- if (isset($this->_config[$key])) $this->addMessage('error',$row,'code','The property `code` must be unique, `%s` has been found twice',$key);
1054
- while (isset($this->_config[$key])) $key .= rand(0,9);
1055
- //$row['code'] = $key;
1056
- } else {
1057
- $i = 1;
1058
- do {
1059
- $key = 'code_auto'.sprintf('%03d',$i);
1060
- $i++;
1061
- } while (isset($this->_config[$key]));
1062
- }
1063
- $row['*code'] = $key;
1064
- $this->_config[$key] = $row;
1065
- }
1066
-
1067
- protected function _addIgnoredLines($lines) {
1068
- $this->_config[] = array('lines' => $lines);
1069
- }
1070
-
1071
- protected function _addressMatch($address_filter, $address) {
1072
- $excluding = false;
1073
- if (preg_match('# *\* *- *\((.*)\) *#s',$address_filter,$result)) {
1074
- $address_filter = $result[1];
1075
- $excluding = true;
1076
- }
1077
-
1078
- $tmp_address_filter_array = explode(',',trim($address_filter));
1079
-
1080
- $concat = false;
1081
- $concatened = '';
1082
- $address_filter_array = array();
1083
- $i = 0;
1084
-
1085
- foreach ($tmp_address_filter_array as $address_filter) {
1086
- if ($concat) $concatened .= ','.$address_filter;
1087
- else {
1088
- if ($i<count($tmp_address_filter_array)-1 && preg_match('#\(#',$address_filter)) {
1089
- $concat = true;
1090
- $concatened .= $address_filter;
1091
- } else $address_filter_array[] = $address_filter;
1092
- }
1093
- if (preg_match('#\)#',$address_filter)) {
1094
- $address_filter_array[] = $concatened;
1095
- $concatened = '';
1096
- $concat = false;
1097
- }
1098
- $i++;
1099
- }
1100
-
1101
- foreach ($address_filter_array as $address_filter) {
1102
- if (preg_match('# *([A-Z]{2}) *(-)? *(?:\( *(-)? *(.*)\))? *#s',$address_filter,$result)) {
1103
- $country_code = $result[1];
1104
- if ($address['country_code']==$country_code) {
1105
- self::debug(' country code <span class="osh-replacement">'.$address['country_code'].'</span> matches',5);
1106
- if (!isset($result[4]) || $result[4]=='') return !$excluding;
1107
- else {
1108
- $region_codes = explode(',',$result[4]);
1109
- $in_array = false;
1110
- for ($i=count($region_codes); --$i>=0;) {
1111
- $code = trim($region_codes[$i]);
1112
- $region_codes[$i] = $code;
1113
- if ($address['region_code']===$code) {
1114
- self::debug(' region code <span class="osh-replacement">'.$address['region_code'].'</span> matches',5);
1115
- $in_array = true;
1116
- } else if ($address['postcode']===$code) {
1117
- self::debug(' postcode <span class="osh-replacement">'.$address['postcode'].'</span> matches',5);
1118
- $in_array = true;
1119
- } else if (strpos($code,'*')!==false && preg_match('/^'.str_replace('*','(?:.*)',$code).'$/',$address['postcode'])) {
1120
- self::debug(' postcode <span class="osh-replacement">'.$address['postcode'].'</span> matches <span class="osh-formula">'.$code.'</span>',5);
1121
- $in_array = true;
1122
- }
1123
- if ($in_array) break;
1124
- }
1125
- if (!$in_array) {
1126
- self::debug(' region code <span class="osh-replacement">'.$address['region_code'].'</span> and postcode <span class="osh-replacement">'.$address['postcode'].'</span> don\'t match',5);
1127
- }
1128
- // Vérification stricte
1129
- /*$in_array = in_array($address['region_code'],$region_codes,true) || in_array($address['postcode'],$region_codes,true);*/
1130
- $excluding_region = $result[2]=='-' || $result[3]=='-';
1131
- if ($excluding_region && !$in_array || !$excluding_region && $in_array) return !$excluding;
1132
- }
1133
- }
1134
- }
1135
- }
1136
- return $excluding;
1137
- }
1138
-
1139
- protected function _getProductProperty($product, $property_type, $property_name, $get_by_id=false) {
1140
- switch ($property_type) {
1141
- case 'attribute':
1142
- case 'attributes': return $product->getAttribute($property_name,$get_by_id);
1143
- case 'option':
1144
- case 'options': return $product->getOption($property_name,$get_by_id);
1145
- case 'stock': return $product->getStockData($property_name);
1146
- }
1147
- return null;
1148
- }
1149
-
1150
- protected function _processProductProperty($products, $regex_result) {
1151
- // COUNT, SUM or COUNT DISTINCT
1152
- $operation = strtolower($regex_result[1]);
1153
- switch ($operation) {
1154
- case 'sum':
1155
- case 'count distinct':
1156
- $property_type = $regex_result[2];
1157
- $property_name = $regex_result[3];
1158
- $conditions = isset($regex_result[4]) ? $regex_result[4] : null;
1159
- break;
1160
- case 'count':
1161
- $conditions = isset($regex_result[2]) ? $regex_result[2] : null;
1162
- break;
1163
- }
1164
-
1165
- self::debug(' :: start <span class="osh-replacement">'.$regex_result[0].'</span>',10);
1166
-
1167
- $return_value = 0;
1168
-
1169
- preg_match_all('/product\.(attribute(?:s)?|option(?:s)?|stock)\.([a-z0-9_]+)(?:\.(id))?/i',$conditions,$properties_regex_result,PREG_SET_ORDER);
1170
- $properties = array();
1171
- foreach ($properties_regex_result as $property_regex_result) {
1172
- $key = $property_regex_result[0];
1173
- if (!isset($properties[$key])) $properties[$key] = $property_regex_result;
1174
- }
1175
-
1176
- foreach ($products as $product) {
1177
- if (isset($conditions) && $conditions!='') {
1178
- $formula = $conditions;
1179
- foreach ($properties as $property) {
1180
- $value = $this->_getProductProperty(
1181
- $product,
1182
- $tmp_property_type = $property[1],
1183
- $tmp_property_name = $property[2],
1184
- $get_by_id = isset($property[3]) && $property[3]=='id'
1185
- );
1186
- //$formula = $this->replace($property[0],$value,$formula);
1187
- $from = $property[0];
1188
- $to = is_string($value) || empty($value) ? "'".$value."'" : $value;
1189
- $formula = str_replace($from,$to,$formula);
1190
- self::debug(' replace <span class="osh-replacement">'.$from.'</span> by <span class="osh-replacement">'.$to.'</span> =&gt; <span class="osh-formula">'.str_replace($from,'<span class="osh-replacement">'.$to.'</span>',$formula).'</span>',5);
1191
- }
1192
- $eval_result = $this->_evalFormula($formula);
1193
- if (!isset($eval_result)) return 'null';
1194
- }
1195
- else $eval_result = true;
1196
-
1197
- if ($eval_result==true) {
1198
- switch ($operation) {
1199
- case 'sum':
1200
- $value = $this->_getProductProperty($product,$property_type,$property_name);
1201
- //self::debug($product->getSku().'.'.$property_type.'.'.$property_name.' = "'.$value.'" x '.$product->getQuantity(),10);
1202
- $return_value += $value*$product->getQuantity();
1203
- break;
1204
- case 'count distinct':
1205
- if (!isset($distinct_values)) $distinct_values = array();
1206
- $value = $this->_getProductProperty($product,$property_type,$property_name);
1207
- if (!in_array($value,$distinct_values)) {
1208
- $distinct_values[] = $value;
1209
- $return_value++;
1210
- }
1211
- break;
1212
- case 'count':
1213
- $return_value += $product->getQuantity();
1214
- break;
1215
- }
1216
- }
1217
- }
1218
-
1219
- self::debug(' :: end <span class="osh-replacement">'.$regex_result[0].'</span>',10);
1220
-
1221
- return $return_value;
1222
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1223
 
1224
  }
1225
 
1226
  interface OCS_Product {
1227
- public function getOption($option);
1228
- public function getAttribute($attribute);
1229
- public function getName();
1230
- public function getSku();
1231
- public function getQuantity();
1232
- public function getStockData($key);
 
 
 
 
 
 
1233
  }
1234
 
1235
  class OCS_Message {
1236
- public $type;
1237
- public $message;
1238
- public $args;
1239
-
1240
- public function OCS_Message($type, $args) {
1241
- $this->type = $type;
1242
- $this->message = array_shift($args);
1243
- $this->args = $args;
1244
- }
1245
-
1246
- public function toString() {
1247
- return vsprintf($this->message,$this->args);
1248
- }
 
 
1249
  }
1250
 
1251
  class OCS_Result {
1252
- public $success;
1253
- public $result;
1254
 
1255
- public function OCS_Result($success, $result=null) {
1256
- $this->success = $success;
1257
- $this->result = $result;
1258
- }
1259
 
1260
- public function __toString() {
1261
- return is_bool($this->result) ? ($this->result ? 'true' : 'false') : (string)$this->result;
1262
- }
1263
- }
 
 
 
 
1264
 
 
1265
 
1266
  ?>
19
  * @author Antoine Lemoine
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
+ class ChronorelaisShippingHelper {
23
+
24
+ public static $DEBUG_INDEX_COUNTER = 0;
25
+ public static $FLOAT_REGEX = '[-]?\d+(?:[.]\d+)?';
26
+ public static $POSITIVE_FLOAT_REGEX = '\d+(?:[.]\d+)?';
27
+ public static $COUPLE_REGEX = '(?:[0-9.]+|\*) *(?:\[|\])? *\: *[0-9.]+';
28
+ public static $UNCOMPRESSED_STRINGS = array(
29
+ ' product.attribute.',
30
+ ' product.option.',
31
+ ' product.stock.',
32
+ '{product.attribute.',
33
+ '{product.option.',
34
+ '{product.stock.',
35
+ '{product.weight}',
36
+ '{product.quantity}',
37
+ '{cart.weight}',
38
+ '{cart.quantity}',
39
+ '{cart.price_including_tax}',
40
+ '{cart.price_excluding_tax}',
41
+ '{cart.',
42
+ '{customvar.',
43
+ '{selection.weight}',
44
+ '{selection.quantity}',
45
+ '{selection.',
46
+ '{destination.country.',
47
+ '{foreach ',
48
+ '{/foreach}',
49
+ );
50
+ public static $COMPRESSED_STRINGS = array(
51
+ ' p.a.',
52
+ ' p.o.',
53
+ ' p.s.',
54
+ '{p.a.',
55
+ '{p.o.',
56
+ '{p.s.',
57
+ '{p.w}',
58
+ '{p.qty}',
59
+ '{c.w}',
60
+ '{c.qty}',
61
+ '{c.pit}',
62
+ '{c.pet}',
63
+ '{c.',
64
+ '{v.',
65
+ '{s.w}',
66
+ '{s.qty}',
67
+ '{s.',
68
+ '{dest.ctry.',
69
+ '{each ',
70
+ '{/each}',
71
+ );
72
+ protected $_input;
73
+ protected $_config;
74
+ protected $_messages;
75
+ protected $_formula_cache;
76
+ protected $_expression_cache;
77
+ public $debug = 0;
78
+ public $debug_output = '';
79
+ public $debug_header = null;
80
+
81
+ public function ChronorelaisShippingHelper($input) {
82
+ $this->_formula_cache = array();
83
+ $this->_messages = array();
84
+ $this->_input = $input;
85
+ $this->_config = array();
86
+ $this->_parseInput();
87
+ }
88
+
89
+ private function debug($text, $level = 10) {
90
+ if ($this->debug >= $level)
91
+ $this->debug_output .= "<p>" . $text . "</p>";
92
+ }
93
+
94
+ public function printDebug() {
95
+ if ($this->debug > 0) {
96
+ $index = self::$DEBUG_INDEX_COUNTER++;
97
+ echo "<style rel=\"stylesheet\" type=\"text/css\">"
98
+ . ".osh-formula{color:#f90;} .osh-key{color:#0099f7;}"
99
+ . ".osh-error{color:#f00;} .osh-warning{color:#ff0;} .osh-info{color:#7bf700;}"
100
+ . ".osh-debug{background:#000;color:#bbb;position:absolute;top:0;left:0;width:100%;z-index:100;-moz-opacity:0.9;opacity:0.9;text-align:left;white-space:pre-wrap;}"
101
+ . ".osh-debug-content{padding:10px;}"
102
+ . ".osh-replacement{color:#ff3000;}"
103
+ . "</style>"
104
+ . "<div id=\"osh-debug-" . $index . "\" class=\"osh-debug\"><pre class=\"osh-debug-content\"><span style=\"float:right;cursor:pointer;\" onclick=\"document.getElementById('osh-debug-" . $index . "').style.display = 'none';\">[<span style=\"padding:0 5px;color:#f00;\">X</span>]</span>"
105
+ . "<p>" . $this->debug_header . "</p>" . $this->debug_output . "</pre></div>";
106
+ }
107
+ }
108
+
109
+ public function setDebugHeader($process) {
110
+ $header = 'DEBUG app/code/community/Chronopost/Chronorelais/Model/Carrier/ChronorelaisShippingHelper.php<br/>';
111
+ foreach ($process['data'] as $key => $data) {
112
+ $header .= ' <span class="osh-key">' . $key . '</span> = <span class="osh-formula">' . $this->_toString($data) . '</span><br/>';
113
+ }
114
+ $this->debug_header = $header;
115
+ }
116
+
117
+ public function getConfig() {
118
+ return $this->_config;
119
+ }
120
+
121
+ public function getMessages() {
122
+ $messages = $this->_messages;
123
+ $this->_messages = array();
124
+ return $messages;
125
+ }
126
+
127
+ public function formatConfig($compress) {
128
+ $output = '';
129
+ foreach ($this->_config as $code => $row) {
130
+ if (!isset($row['lines'])) {
131
+ if (isset($row['*comment']['value'])) {
132
+ $output .= trim($row['*comment']['value']) . "\n";
133
+ }
134
+ $output .= '{' . ($compress ? '' : "\n");
135
+ foreach ($row as $key => $property) {
136
+ if (substr($key, 0, 1) != '*') {
137
+ $value = $property['value'];
138
+ if (isset($property['comment']))
139
+ $output .= ($compress ? '' : "\t") . '/* ' . $property['comment'] . ' */' . ($compress ? '' : "\n");
140
+ $output .= ($compress ? '' : "\t") . $key . ':' . ($compress ? '' : ' ');
141
+ if (is_bool($value))
142
+ $output .= $value ? 'true' : 'false';
143
+ else if (is_int($value))
144
+ $output .= $value;
145
+ else if ((string) ((float) $value) == $value)
146
+ $output .= $value;
147
+ else
148
+ $output .= '"' . str_replace('"', '\\"', $value) . '"';
149
+ $output .= ',' . ($compress ? '' : "\n");
150
+ }
151
+ }
152
+ if ($compress)
153
+ $output = preg_replace('/,$/', '', $output);
154
+ $output .= "}\n" . ($compress ? '' : "\n");
155
+ } else {
156
+ $output .= $row['lines'] . "\n";
157
+ }
158
+ }
159
+ return $compress ? $this->compress($output) : $this->uncompress($output);
160
+ }
161
+
162
+ public function checkConfig() {
163
+ $process = array(
164
+ 'result' => null,
165
+ 'data' => array(
166
+ 'cart.price_excluding_tax' => 0,
167
+ 'cart.price_including_tax' => 0,
168
+ 'destination.country.code' => '',
169
+ 'destination.country.name' => '',
170
+ 'destination.region.code' => '',
171
+ 'destination.postcode' => '',
172
+ 'origin.country.code' => '',
173
+ 'origin.country.name' => '',
174
+ 'origin.region.code' => '',
175
+ 'origin.postcode' => '',
176
+ 'free_shipping' => false,
177
+ 'customer.group.id' => '',
178
+ 'customer.group.code' => '',
179
+ 'cart.weight' => 0,
180
+ 'cart.weight.unit' => 'kg',
181
+ 'cart.quantity' => 0,
182
+ ),
183
+ 'cart.items' => array(),
184
+ 'products' => array(),
185
+ 'config' => $this->_config,
186
+ );
187
+ foreach ($this->_config as $code => &$row) {
188
+ $this->processRow($process, $row, $check_all_conditions = true);
189
+ foreach ($row as $property_key => $property_value) {
190
+ if (substr($property_key, 0, 1) != '*')
191
+ $this->getRowProperty($row, $property_key);
192
+ }
193
+ }
194
+ }
195
+
196
+ public function processRow($process, &$row, $is_checking = false) {
197
+ if (!isset($row['*code']))
198
+ return;
199
+
200
+ self::debug('process row <span class="osh-key">' . $row['*code'] . '</span>', 1);
201
+ if (!isset($row['label']['value']))
202
+ $row['label']['value'] = '***';
203
+
204
+ $enabled = $this->getRowProperty($row, 'enabled');
205
+ if (isset($enabled)) {
206
+ if (!$is_checking && !$enabled) {
207
+ $this->addMessage('info', $row, 'enabled', 'Configuration disabled');
208
+ return new OCS_Result(false);
209
+ }
210
+ }
211
+
212
+ $conditions = $this->getRowProperty($row, 'conditions');
213
+ if (isset($conditions)) {
214
+ $result = $this->_processFormula($process, $row, 'conditions', $conditions, $is_checking);
215
+ if (!$is_checking) {
216
+ if (!$result->success)
217
+ return $result;
218
+ if (!$result->result) {
219
+ $this->addMessage('info', $row, 'conditions', "The cart doesn't match conditions");
220
+ return new OCS_Result(false);
221
+ }
222
+ }
223
+ }
224
+
225
+ $destination = $this->getRowProperty($row, 'destination');
226
+ if (isset($destination)) {
227
+ $destination_match = $this->_addressMatch($destination, array(
228
+ 'country_code' => $process['data']['destination.country.code'],
229
+ 'region_code' => $process['data']['destination.region.code'],
230
+ 'postcode' => $process['data']['destination.postcode']
231
+ ));
232
+ if (!$is_checking && !$destination_match) {
233
+ $this->addMessage('info', $row, 'destination', "The shipping method doesn't cover the zone");
234
+ return new OCS_Result(false);
235
+ }
236
+ }
237
+
238
+ $origin = $this->getRowProperty($row, 'origin');
239
+ if (isset($origin)) {
240
+ $origin_match = $this->_addressMatch($origin, array(
241
+ 'country_code' => $process['data']['origin.country.code'],
242
+ 'region_code' => $process['data']['origin.region.code'],
243
+ 'postcode' => $process['data']['origin.postcode']
244
+ ));
245
+ if (!$is_checking && !$origin_match) {
246
+ $this->addMessage('info', $row, 'origin', "The shipping method doesn't match to shipping origin");
247
+ return new OCS_Result(false);
248
+ }
249
+ }
250
+
251
+ $customer_groups = $this->getRowProperty($row, 'customer_groups');
252
+ if (isset($customer_groups)) {
253
+ $groups = explode(',', $customer_groups);
254
+ $group_match = false;
255
+ //self::debug('code:'.$process['data']['customer.group.code'].', id:'.$process['data']['customer.group.id']);
256
+ foreach ($groups as $group) {
257
+ $group = trim($group);
258
+ if ($group == $process['data']['customer.group.code'] || is_int($group) && $group == $process['data']['customer.group.id'] || $group == '*') {
259
+ $group_match = true;
260
+ break;
261
+ }
262
+ }
263
+ if (!$is_checking && !$group_match) {
264
+ $this->addMessage('info', $row, 'customer_groups', "The shipping method doesn't match to customer group (%s)", $process['data']['customer.group.code']);
265
+ return new OCS_Result(false);
266
+ }
267
+ }
268
+
269
+ //Chronopost quickcost method for dynamic price if it is set enabled
270
+ $quickcost = Mage::getStoreConfig('carriers/' . $process['data']['carrier.code'] . '/quickcost');
271
+ if ($quickcost) {
272
+ if ($quickCostValues = $this->getQuickCostValue($process['data'])) {
273
+ if ($quickCostValues->errorCode == 0) {
274
+ return new OCS_Result(true, (float) $quickCostValues->amountTTC);
275
+ } else {
276
+ $this->addMessage('error', $row, 'chronopost', $quickCostValues->errorMessage);
277
+ return new OCS_Result(false);
278
+ }
279
+ } else { /* if false => WS inaccessible donc on prend les prix de la grille */
280
+ //return new OCS_Result(false);
281
+ }
282
+ }
283
+
284
+ /* Prix via la grille du BO */
285
+ $fees = $this->getRowProperty($row, 'fees');
286
+ if (isset($fees)) {
287
+ $result = $this->_processFormula($process, $row, 'fees', $fees, $is_checking);
288
+ if (!$result->success)
289
+ return $result;
290
+ self::debug(' => <span class="osh-info">result = <span class="osh-formula">' . $this->_toString($result->result) . '</span>', 1);
291
+ return new OCS_Result(true, (float) $result->result);
292
+ }
293
+
294
+ return new OCS_Result(false);
295
+ }
296
+
297
+ public function getQuickCostValue($processData) {
298
+ $quickCost = array();
299
+ $_helper = Mage::helper('chronorelais');
300
+ $account_number = $_helper->getConfigurationAccountNumber();
301
+ $password = $_helper->getConfigurationAccountPass();
302
+ $productCode = $_helper->getChronoProductCode($processData['destination.country.code'], $processData['carrier.code']);
303
+ $origin_postcode = $_helper->getConfigurationShipperInfo('zipcode');
304
+
305
+ //to get arrival code
306
+ $arrCode = $processData['destination.postcode'];
307
+ if ($processData['carrier.code'] == 'chronoexpress' || $processData['carrier.code'] == 'chronopostcclassic') {
308
+ $arrCode = $processData['destination.country.code'];
309
+ }
310
+
311
+ $cartWeight = $processData['cart.weight'];
312
+ if ($_helper->getConfigWeightUnit() == 'g') {
313
+ $cartWeight = $cartWeight / 1000; /* conversion g => kg */
314
+ }
315
+ $quickCost = array(
316
+ 'accountNumber' => $account_number,
317
+ 'password' => $password,
318
+ 'depCode' => $origin_postcode,
319
+ 'arrCode' => $arrCode,
320
+ 'weight' => $cartWeight,
321
+ 'productCode' => $productCode,
322
+ 'type' => 'M'
323
+ );
324
+
325
+ $quickcost_url = Mage::helper('chronorelais')->getConfigData('carriers/' . $processData['carrier.code'] . '/quickcost_url');
326
+
327
+ $helperWS = Mage::helper('chronorelais/webservice');
328
+ return $helperWS->getQuickcost($quickCost,$quickcost_url);
329
+ }
330
+
331
+ public function getRowProperty(&$row, $key, $original_row = null, $original_key = null) {
332
+ $property = null;
333
+ $output = null;
334
+ if (isset($original_row) && isset($original_key) && $original_row['*code'] == $row['*code'] && $original_key == $key) {
335
+ $this->addMessage('error', $row, $key, 'Infinite loop %s', "<span class=\"code\">{" . $row['*code'] . '.' . $key . "}</span>");
336
+ return array('error' => 'Infinite loop');
337
+ }
338
+ if (isset($row[$key]['value'])) {
339
+ $property = $row[$key]['value'];
340
+ $output = $property;
341
+ self::debug(' get <span class="osh-key">' . $row['*code'] . '</span>.<span class="osh-key">' . $key . '</span> = <span class="osh-formula">' . $this->_toString($property) . '</span>', 5);
342
+ preg_match_all('/{([a-z0-9_]+)\.([a-z0-9_]+)}/i', $output, $result_set, PREG_SET_ORDER);
343
+ foreach ($result_set as $result) {
344
+ list($original, $ref_code, $ref_key) = $result;
345
+ if (!in_array($ref_code, array('module', 'date', 'store', 'cart', 'product', 'selection', 'customvar'))) {
346
+ if ($ref_code == $row['code']['value'] && $ref_key == $key) {
347
+ $this->addMessage('error', $row, $key, 'Infinite loop %s', "<span class=\"code\">" . $original . "</span>");
348
+ return null;
349
+ }
350
+ if (isset($this->_config[$ref_code][$ref_key]['value'])) {
351
+ $replacement = $this->getRowProperty($this->_config[$ref_code], $ref_key, isset($original_row) ? $original_row : $row, isset($original_key) ? $original_key : $key);
352
+ if (is_array($replacement) && isset($replacement['error'])) {
353
+ return isset($original_row) ? $replacement : 'false';
354
+ }
355
+ } else {
356
+ $this->addMessage('error', $row, $key, 'Non-existent property %s', "<span class=\"code\">" . $original . "</span>");
357
+ $replacement = 'null';
358
+ }
359
+ $output = $this->replace($original, $replacement, $output);
360
+ }
361
+ }
362
+ } else {
363
+ self::debug(' get <span class="osh-key">' . $row['*code'] . '</span>.<span class="osh-key">' . $key . '</span> = <span class="osh-formula">null</span>', 5);
364
+ }
365
+ return $output;
366
+ }
367
+
368
+ protected function _toString($value) {
369
+ if (!isset($value))
370
+ return 'null';
371
+ else if (is_bool($value))
372
+ return $value ? 'true' : 'false';
373
+ else
374
+ return $value;
375
+ }
376
+
377
+ protected function replace($from, $to, $input) {
378
+ if ($from === $to)
379
+ return $input;
380
+ if (strpos($input, $from) === false)
381
+ return $input;
382
+ $to = $this->_toString($to);
383
+ self::debug(' replace <span class="osh-replacement">' . $this->_toString($from) . '</span> by <span class="osh-replacement">' . $to . '</span> =&gt; <span class="osh-formula">' . str_replace($from, '<span class="osh-replacement">' . $to . '</span>', $input) . '</span>', 5);
384
+ return str_replace($from, $to, $input);
385
+ }
386
+
387
+ protected function _min() {
388
+ $args = func_get_args();
389
+ $min = null;
390
+ foreach ($args as $arg) {
391
+ if (isset($arg) && (!isset($min) || $min > $arg))
392
+ $min = $arg;
393
+ }
394
+ return $min;
395
+ }
396
+
397
+ protected function _max() {
398
+ $args = func_get_args();
399
+ $max = null;
400
+ foreach ($args as $arg) {
401
+ if (isset($arg) && (!isset($max) || $max < $arg))
402
+ $max = $arg;
403
+ }
404
+ return $max;
405
+ }
406
+
407
+ protected function _processFormula($process, &$row, $property_key, $formula_string, $is_checking, $use_cache = true) {
408
+ $result = $this->_prepareFormula($process, $row, $property_key, $formula_string, $is_checking, $use_cache);
409
+ if (!$result->success)
410
+ return $result;
411
+
412
+ $eval_result = $this->_evalFormula($result->result);
413
+ if (!isset($eval_result)) {
414
+ $this->addMessage('error', $row, $property_key, 'Invalid formula');
415
+ $result = new OCS_Result(false);
416
+ if ($use_cache)
417
+ $this->setCache($formula_string, $result);
418
+ return $result;
419
+ }
420
+ self::debug(' formula evaluation = <span class="osh-formula">' . $this->_toString($eval_result) . '</span>', 10);
421
+ $result = new OCS_Result(true, $eval_result);
422
+ if ($use_cache)
423
+ $this->setCache($formula_string, $result);
424
+ return $result;
425
+ }
426
+
427
+ public function evalInput($process, $row, $property_key, $input) {
428
+ $result = $this->_prepareFormula($process, $row, $property_key, $input, $is_checking = false, $use_cache = true);
429
+ return $result->success ? $result->result : $input;
430
+ }
431
+
432
+ protected function setCache($expression, $value) {
433
+ if ($value instanceof OCS_Result) {
434
+ $this->_formula_cache[$expression] = $value;
435
+ self::debug(' cache <span class="osh-replacement">' . $expression . '</span> = <span class="osh-formula">' . $this->_toString($this->_formula_cache[$expression]) . '</span>', 10);
436
+ } else {
437
+ $value = $this->_toString($value);
438
+ $this->_expression_cache[$expression] = $value;
439
+ self::debug(' cache <span class="osh-replacement">' . $expression . '</span> = <span class="osh-formula">' . $value . '</span>', 10);
440
+ }
441
+ }
442
+
443
+ protected function _prepareFormula($process, $row, $property_key, $formula_string, $is_checking, $use_cache = true) {
444
+ if ($use_cache && isset($this->_formula_cache[$formula_string])) {
445
+ $result = $this->_formula_cache[$formula_string];
446
+ self::debug(' get cached formula <span class="osh-replacement">' . $formula_string . '</span> = <span class="osh-formula">' . $this->_toString($result->result) . '</span>', 10);
447
+ return $result;
448
+ }
449
+
450
+ $formula = $formula_string;
451
+ //self::debug(' formula = <span class="osh-formula">'.$formula.'</span>',10);
452
+
453
+ while (preg_match("#{foreach product\.((?:attribute|option)\.(?:[a-z0-9_]+))}(.*){/foreach}#i", $formula, $result)) {
454
+ $original = $result[0];
455
+ if ($use_cache && isset($this->_expression_cache[$original])) {
456
+ $replacement = $this->_expression_cache[$original];
457
+ self::debug(' get cached expression <span class="osh-replacement">' . $original . '</span> = <span class="osh-formula">' . $replacement . '</span>', 10);
458
+ } else {
459
+ $replacement = 0;
460
+ list($filter_property_type, $filter_property_name) = explode('.', $result[1]);
461
+ $selections = array();
462
+ self::debug(' :: foreach <span class="osh-key">' . $filter_property_type . '</span>.<span class="osh-key">' . $filter_property_name . '</span>', 10);
463
+ foreach ($process['products'] as $product) {
464
+ $tmp_value = $this->_getProductProperty($product, $filter_property_type, $filter_property_name, $get_by_id = false);
465
+ self::debug(' products[<span class="osh-formula">' . $product->getName() . '</span>].<span class="osh-key">' . $filter_property_type . '</span>.<span class="osh-key">' . $filter_property_name . '</span> = <span class="osh-formula">' . $this->_toString($tmp_value) . '</span>', 10);
466
+ $key = 'val_' . $tmp_value;
467
+ $sel = isset($selections[$key]) ? $selections[$key] : null;
468
+ $selections[$key]['products'][] = $product;
469
+ $selections[$key]['weight'] = (isset($sel['weight']) ? $sel['weight'] : 0) + $product->getAttribute('weight') * $product->getQuantity();
470
+ $selections[$key]['quantity'] = (isset($sel['quantity']) ? $sel['quantity'] : 0) + $product->getQuantity();
471
+ }
472
+ self::debug(' :: start foreach', 10);
473
+ foreach ($selections as $selection) {
474
+ $process2 = $process;
475
+ $process2['products'] = $selection['products'];
476
+ $process2['data']['selection.quantity'] = $selection['quantity'];
477
+ $process2['data']['selection.weight'] = $selection['weight'];
478
+ $process_result = $this->_processFormula($process2, $row, $property_key, $result[2], $is_checking, $tmp_use_cache = false);
479
+ $replacement += $process_result->result;
480
+ }
481
+ self::debug(' :: end foreach <span class="osh-key">' . $filter_property_type . '</span>.<span class="osh-key">' . $filter_property_name . '</span>', 10);
482
+ if ($use_cache)
483
+ $this->setCache($original, $replacement);
484
+ }
485
+ $formula = $this->replace($original, $replacement, $formula);
486
+ }
487
+
488
+ $formula = str_replace(array("\n", "\t"), array('', ''), $formula);
489
+
490
+ while (preg_match("#{customvar\.([a-z0-9_]+)}#i", $formula, $result)) {
491
+ $original = $result[0];
492
+ $replacement = Mage::getModel('core/variable')->loadByCode($result[1])->getValue('plain');
493
+ $formula = $this->replace($original, $replacement, $formula);
494
+ }
495
+
496
+ $first_product = isset($process['products'][0]) ? $process['products'][0] : null;
497
+ if (!isset($process['data']['selection.weight']))
498
+ $process['data']['selection.weight'] = $process['data']['cart.weight'];
499
+ if (!isset($process['data']['selection.quantity']))
500
+ $process['data']['selection.quantity'] = $process['data']['cart.quantity'];
501
+ $process['data']['product.weight'] = isset($first_product) ? $first_product->getAttribute('weight') : 0;
502
+ $process['data']['product.quantity'] = isset($first_product) ? $first_product->getQuantity() : 0;
503
+
504
+ foreach ($process['data'] as $original => $replacement) {
505
+ $formula = $this->replace('{' . $original . '}', $replacement, $formula);
506
+ }
507
+
508
+ if (isset($first_product)) {
509
+ while (preg_match("#{product\.(attribute|option|stock)\.([a-z0-9_]+)}#i", $formula, $result)) {
510
+ $original = $result[0];
511
+ switch ($result[1]) {
512
+ case 'attribute': $replacement = $first_product->getAttribute($result[2]);
513
+ break;
514
+ case 'option': $replacement = $first_product->getOption($result[2]);
515
+ break;
516
+ case 'stock': $replacement = $first_product->getStockData($result[2]);
517
+ break;
518
+ }
519
+ $formula = $this->replace($original, $replacement, $formula);
520
+ }
521
+ }
522
+
523
+ //while (preg_match("/{(count|all|any) (attribute|option) '([^'\)]+)' ?(==|<=|>=|<|>|!=) ?(".self::$FLOAT_REGEX."|true|false|'[^'\)]*')}/",$formula,$result)
524
+ // || preg_match("/{(sum|count distinct) (attribute|option) '([^'\)]+)'}/",$formula,$result))
525
+ while (preg_match("/{(count) products(?: where ([^}]+))?}/i", $formula, $result) || preg_match("/{(sum|count distinct) product\.(attribute|option)\.([a-z0-9_]+)(?: where ([^}]+))?}/i", $formula, $result)) {
526
+ $original = $result[0];
527
+ if ($use_cache && isset($this->_expression_cache[$original])) {
528
+ $replacement = $this->_expression_cache[$original];
529
+ self::debug(' get cached expression <span class="osh-replacement">' . $original . '</span> = <span class="osh-formula">' . $replacement . '</span>', 10);
530
+ } else {
531
+ $replacement = $this->_processProductProperty($process['products'], $result);
532
+ if ($use_cache)
533
+ $this->setCache($result[0], $replacement);
534
+ }
535
+ $formula = $this->replace($original, $replacement, $formula);
536
+ }
537
+
538
+ //while (preg_match("/{table '([^']+)' ([^}]+)}/",$formula,$result))
539
+ while (preg_match("/{table ([^}]+) in ([0-9\.:,\*\[\] ]+)}/i", $formula, $result)) {
540
+ $original = $result[0];
541
+ if ($use_cache && isset($this->_expression_cache[$original])) {
542
+ $replacement = $this->_expression_cache[$original];
543
+ self::debug(' get cached expression <span class="osh-replacement">' . $original . '</span> = <span class="osh-formula">' . $replacement . '</span>', 10);
544
+ } else {
545
+ $reference_value = $this->_evalFormula($result[1]);
546
+ if (isset($reference_value)) {
547
+ $fees_table_string = $result[2];
548
+
549
+ if (!preg_match('#^' . self::$COUPLE_REGEX . '(?:, *' . self::$COUPLE_REGEX . ')*$#', $fees_table_string)) {
550
+ $this->addMessage('error', $row, $property_key, 'Error in table %s', '<span class="osh-formula">' . htmlentities($result[0]) . '</span>');
551
+ $result = new OCS_Result(false);
552
+ if ($use_cache)
553
+ $this->setCache($formula_string, $result);
554
+ return $result;
555
+ }
556
+ $fees_table = explode(',', $fees_table_string);
557
+
558
+ $replacement = null;
559
+ foreach ($fees_table as $item) {
560
+ $fee_data = explode(':', $item);
561
+
562
+ $fee = trim($fee_data[1]);
563
+ $max_value = trim($fee_data[0]);
564
+
565
+ $last_char = $max_value{strlen($max_value) - 1};
566
+ if ($last_char == '[')
567
+ $including_max_value = false;
568
+ else if ($last_char == ']')
569
+ $including_max_value = true;
570
+ else
571
+ $including_max_value = true;
572
+
573
+ $max_value = str_replace(array('[', ']'), '', $max_value);
574
+
575
+ if ($max_value == '*' || $including_max_value && $reference_value <= $max_value || !$including_max_value && $reference_value < $max_value) {
576
+ $replacement = $fee; //$this->_calculateFee($process,$fee,$var);
577
+ break;
578
+ }
579
+ }
580
+ }
581
+ $replacement = $this->_toString($replacement);
582
+ if ($use_cache)
583
+ $this->setCache($original, $replacement);
584
+ }
585
+ $formula = $this->replace($original, $replacement, $formula);
586
+ }
587
+ $result = new OCS_Result(true, $formula);
588
+ return $result;
589
+ }
590
+
591
+ protected function _evalFormula($formula) {
592
+ if (is_bool($formula))
593
+ return $formula;
594
+ if (!preg_match('/^(?:floor|ceil|round|max|min|rand|pow|pi|sqrt|log|exp|abs|int|float|true|false|null|and|or|in|substr|strtolower'
595
+ . '|in_array\(\'(?:[^\']*)\', *array\( *(?:\'(?:[^\']+)\') *(?: *, *\'(?:[^\']+)\')* *\) *\)'
596
+ . '|\'[^\']*\'|[0-9,\'\.\-\(\)\*\/\?\:\+\<\>\=\&\|%! ])*$/', $formula)) {
597
+ $errors = array(
598
+ PREG_NO_ERROR => 'PREG_NO_ERROR',
599
+ PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR',
600
+ PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR',
601
+ PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR',
602
+ PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR',
603
+ PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR',
604
+ );
605
+ $error = preg_last_error();
606
+ if (isset($errors[$error]))
607
+ $error = $errors[$error];
608
+ self::debug(' doesn\'t match (' . $error . ')', 10);
609
+ return null;
610
+ }
611
+ $formula = str_replace(
612
+ array('min', 'max'), array('$this->_min', '$this->_max'), $formula
613
+ );
614
+ $eval_result = null;
615
+ @eval('$eval_result = (' . $formula . ');');
616
+ return $eval_result;
617
+ }
618
+
619
+ protected function _getOptionsAndData($string) {
620
+ if (preg_match('/^(\\s*\(\\s*([^\] ]*)\\s*\)\\s*)/', $string, $result)) {
621
+ $options = $result[2];
622
+ $data = str_replace($result[1], '', $string);
623
+ } else {
624
+ $options = '';
625
+ $data = $string;
626
+ }
627
+ return array(
628
+ 'options' => $options,
629
+ 'data' => $data,
630
+ );
631
+ }
632
+
633
+ public function compress($input) {
634
+ if (preg_match_all("/{table (.*) in (" . self::$COUPLE_REGEX . "(?:, *" . self::$COUPLE_REGEX . ")*)}/imsU", $input, $result, PREG_SET_ORDER)) {
635
+ foreach ($result as $result_i) {
636
+ $fees_table = explode(',', $result_i[2]);
637
+ $value = null;
638
+ foreach ($fees_table as $index => $item) {
639
+ list($max_value, $fee) = explode(':', $item);
640
+ $last_char = $max_value{strlen($max_value) - 1};
641
+ if (in_array($last_char, array('[', ']'))) {
642
+ $including_char = $last_char;
643
+ $max_value = str_replace(array('[', ']'), '', $max_value);
644
+ }
645
+ else
646
+ $including_char = '';
647
+ $fees_table[$index] = ((float) $max_value) . $including_char . ':' . ((float) $fee);
648
+ }
649
+ $input = str_replace($result_i[2], implode(',', $fees_table), $input);
650
+ $input = str_replace($result_i[1], trim($result_i[1]), $input);
651
+ }
652
+ }
653
+ if (preg_match_all("#{foreach ([^}]*)}(.*){/foreach}#imsU", $input, $result, PREG_SET_ORDER)) {
654
+ foreach ($result as $result_i) {
655
+ $input = str_replace($result_i[1], trim($result_i[1]), $input);
656
+ $input = str_replace($result_i[2], trim($result_i[2]), $input);
657
+ }
658
+ }
659
+ return '$$' . str_replace(
660
+ self::$UNCOMPRESSED_STRINGS, self::$COMPRESSED_STRINGS, $input
661
+ );
662
+ }
663
+
664
+ public function uncompress($input) {
665
+ if (preg_match_all("/{table (.*) in (" . self::$COUPLE_REGEX . "(?:, *" . self::$COUPLE_REGEX . ")*)}/iU", $input, $result, PREG_SET_ORDER)) {
666
+ foreach ($result as $result_i) {
667
+ $fees_table = explode(',', $result_i[2]);
668
+ $value = null;
669
+ foreach ($fees_table as $index => $item) {
670
+ list($max_value, $fee) = explode(':', $item);
671
+ $last_char = $max_value{strlen($max_value) - 1};
672
+ if (in_array($last_char, array('[', ']'))) {
673
+ $including_char = $last_char;
674
+ $max_value = str_replace(array('[', ']'), '', $max_value);
675
+ }
676
+ else
677
+ $including_char = '';
678
+ $max_value = (float) $max_value;
679
+ $fee = (float) $fee;
680
+ $new_max_value = number_format($max_value, 2, '.', '');
681
+ $new_fee = number_format($fee, 2, '.', '');
682
+ $fees_table[$index] = (((float) $new_max_value) == $max_value ? $new_max_value : $max_value) . $including_char . ':'
683
+ . (((float) $new_fee) == $fee ? $new_fee : $fee);
684
+ }
685
+ $input = str_replace($result_i[2], implode(', ', $fees_table), $input);
686
+ $input = str_replace($result_i[1], trim($result_i[1]), $input);
687
+ }
688
+ }
689
+ if (preg_match_all("#{foreach ([^}]*)}(.*){/foreach}#iU", $input, $result, PREG_SET_ORDER)) {
690
+ foreach ($result as $result_i) {
691
+ $input = str_replace($result_i[1], trim($result_i[1]), $input);
692
+ $input = str_replace($result_i[2], trim($result_i[2]), $input);
693
+ }
694
+ }
695
+ return str_replace(
696
+ self::$COMPRESSED_STRINGS, self::$UNCOMPRESSED_STRINGS, $input
697
+ );
698
+ }
699
+
700
+ public function parseProperty($input) {
701
+ $value = $input === 'false' || $input === 'true' ? $input == 'true' : str_replace('\"', '"', preg_replace('/^(?:"|\')(.*)(?:"|\')$/s', '$1', $input));
702
+ return $value === '' ? null : $value;
703
+ }
704
+
705
+ public function cleanProperty(&$row, $key) {
706
+ $input = $row[$key]['value'];
707
+ if (is_string($input)) {
708
+ $input = str_replace(array("\n"), array(''), $input);
709
+ while (preg_match('/({TABLE |{SUM |{COUNT | DISTINCT | IN )/', $input, $resi)) {
710
+ $input = str_replace($resi[0], strtolower($resi[0]), $input);
711
+ }
712
+
713
+ while (preg_match('/{{customVar code=([a-zA-Z0-9_-]+)}}/', $input, $resi)) {
714
+ $input = str_replace($resi[0], '{customvar.' . $resi[1] . '}', $input);
715
+ }
716
+
717
+ $regex = "{(weight|products_quantity|price_including_tax|price_excluding_tax|country)}";
718
+ if (preg_match('/' . $regex . '/', $input, $resi)) {
719
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
720
+ while (preg_match('/' . $regex . '/', $input, $resi)) {
721
+ switch ($resi[1]) {
722
+ case 'price_including_tax':
723
+ case 'price_excluding_tax':
724
+ case 'weight':
725
+ $input = str_replace($resi[0], "{cart." . $resi[1] . "}", $input);
726
+ break;
727
+ case 'products_quantity': $input = str_replace($resi[0], "{cart.quantity}", $input);
728
+ break;
729
+ case 'country': $input = str_replace($resi[0], "{destination.country.name}", $input);
730
+ break;
731
+ }
732
+ }
733
+ }
734
+
735
+ $regex1 = "{copy '([a-zA-Z0-9_]+)'\.'([a-zA-Z0-9_]+)'}";
736
+ if (preg_match('/' . $regex1 . '/', $input, $resi)) {
737
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
738
+ while (preg_match('/' . $regex1 . '/', $input, $resi))
739
+ $input = str_replace($resi[0], '{' . $resi[1] . '.' . $resi[2] . '}', $input);
740
+ }
741
+
742
+ $regex1 = "{(count|all|any) (attribute|option) '([^'\)]+)' ?((?:==|<=|>=|<|>|!=) ?(?:" . self::$FLOAT_REGEX . "|true|false|'[^'\)]*'))}";
743
+ $regex2 = "{(sum) (attribute|option) '([^'\)]+)'}";
744
+ if (preg_match('/' . $regex1 . '/', $input, $resi) || preg_match('/' . $regex2 . '/', $input, $resi)) {
745
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
746
+ while (preg_match('/' . $regex1 . '/', $input, $resi) || preg_match('/' . $regex2 . '/', $input, $resi)) {
747
+ switch ($resi[1]) {
748
+ case 'count': $input = str_replace($resi[0], "{count products where product." . $resi[2] . "s." . $resi[3] . $resi[4] . "}", $input);
749
+ break;
750
+ case 'all': $input = str_replace($resi[0], "{count products where product." . $resi[2] . "s." . $resi[3] . $resi[4] . "}=={products_quantity}", $input);
751
+ break;
752
+ case 'any': $input = str_replace($resi[0], "{count products where product." . $resi[2] . "s." . $resi[3] . $resi[4] . "}>0", $input);
753
+ break;
754
+ case 'sum': $input = str_replace($resi[0], "{sum product." . $resi[2] . "." . $resi[3] . "}", $input);
755
+ break;
756
+ }
757
+ }
758
+ }
759
+
760
+ $regex = "((?:{| )product.(?:attribute|option))s.";
761
+ if (preg_match('/' . $regex . '/', $input, $resi)) {
762
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
763
+ while (preg_match('/' . $regex . '/', $input, $resi)) {
764
+ $input = str_replace($resi[0], $resi[1] . '.', $input);
765
+ }
766
+ }
767
+
768
+ $regex = "{table '([^']+)' (" . self::$COUPLE_REGEX . "(?:, *" . self::$COUPLE_REGEX . ")*)}";
769
+ if (preg_match('/' . $regex . '/', $input, $resi)) {
770
+ $this->addMessage('warning', $row, $key, 'Usage of deprecated syntax %s', '<span class="osh-formula">' . $resi[0] . '</span>');
771
+ while (preg_match('/' . $regex . '/', $input, $resi)) {
772
+ switch ($resi[1]) {
773
+ case 'products_quantity':
774
+ $input = str_replace($resi[0], "{table {cart.weight} in " . $resi[2] . "}*{cart.quantity}", $input);
775
+ break;
776
+ default:
777
+ $input = str_replace($resi[0], "{table {cart." . $resi[1] . "} in " . $resi[2] . "}", $input);
778
+ break;
779
+ }
780
+ }
781
+ }
782
+ }
783
+ $row[$key]['value'] = $input;
784
+ }
785
+
786
+ protected function _parseInput() {
787
+ $config_string = str_replace(
788
+ array('&gt;', '&lt;', '“', '”', utf8_encode(chr(147)), utf8_encode(chr(148)), '&laquo;', '&raquo;', "\r\n", "\t"), array('>', '<', '"', '"', '"', '"', '"', '"', "\n", ' '), $this->_input
789
+ );
790
+
791
+ if (substr($config_string, 0, 2) == '$$')
792
+ $config_string = $this->uncompress(substr($config_string, 2, strlen($config_string)));
793
+
794
+ //echo ini_get('pcre.backtrack_limit');
795
+ //exit;
796
+
797
+ $row_regex = ' *([a-z0-9_]+)\\s*:\\s*("(?:(?:[^"]|\\\\")*[^\\\\])?"|' . self::$FLOAT_REGEX . '|false|true)\\s*(,)? *(?:\\n)?';
798
+ if (!preg_match_all('/((?:#+[^{\\n]*\\s+)*)\\s*(#)?{\\s*(' . $row_regex . ')+\\s*}/i', $config_string, $result, PREG_SET_ORDER)) {
799
+ $errors = array(
800
+ PREG_NO_ERROR => 'PREG_NO_ERROR',
801
+ PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR',
802
+ PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR',
803
+ PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR',
804
+ PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR',
805
+ PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR',
806
+ );
807
+ $error = preg_last_error();
808
+ if (isset($errors[$error]))
809
+ $error = $errors[$error];
810
+ self::debug(' preg_match_all error (' . $error . ')', 10);
811
+ }
812
+
813
+ $this->_config = array();
814
+ $available_keys = array(
815
+ 'code', 'label', 'enabled', 'description', 'fees', 'conditions', 'destination', 'origin', 'customer_groups', 'tracking_url',
816
+ 'fees_table', 'fees_formula', 'fixed_fees', 'reference_value',
817
+ 'prices_range', 'weights_range', 'product_properties',
818
+ 'free_shipping__fees_table', 'free_shipping__fees_formula', 'free_shipping__fixed_fees', 'free_shipping__label',
819
+ );
820
+
821
+ foreach ($result as $block) {
822
+ $deprecated_properties = array();
823
+ $unknown_properties = array();
824
+ $missing_semicolon = array();
825
+ $obsolete_disabling_method = array();
826
+
827
+ //$before = strstr($config_string,$block[0],true); // Seulement compatible avec PHP 5.3.0
828
+ list($before) = explode($block[0], $config_string, 2);
829
+ if ($before !== false && trim($before) != '') {
830
+ $config_string = substr($config_string, strlen($before));
831
+ $this->_addIgnoredLines(trim($before));
832
+ $this->addMessage('info', $row = null, null, 'Ignored lines %s', '<div class="code">' . trim($before) . '</div>');
833
+ }
834
+
835
+ $config_string = str_replace($block[0], '', $config_string);
836
+ preg_match_all('/' . $row_regex . '/i', $block[0], $result2, PREG_SET_ORDER);
837
+ $block_string = $block[0];
838
+
839
+ $row = array();
840
+ $i = 1;
841
+ foreach ($result2 as $data) {
842
+ $key = $data[1];
843
+ if (in_array($key, $available_keys) || substr($key, 0, 1) == '_') {
844
+ $property = $this->parseProperty($data[2]);
845
+ if (isset($property)) {
846
+ $row[$key] = array('value' => $property, 'original_value' => $property);
847
+ $this->cleanProperty($row, $key);
848
+ }
849
+ if ($i > 2) {
850
+ $block_string = str_replace($data[0], $i == 3 ? "...\n" : '', $block_string);
851
+ }
852
+ if ($i != count($result2) && !isset($data[3]) || isset($data[3]) && $data[3] != ',') {
853
+ if (preg_match('/^("|\')(.{40})(.*)("|\')$/s', $data[2], $resultx))
854
+ $missing_semicolon[] = trim(str_replace($data[2], $resultx[1] . $resultx[2] . ' ...' . $resultx[4], $data[0]));
855
+ else
856
+ $missing_semicolon[] = trim($data[0]);
857
+ }
858
+ } else {
859
+ if (!in_array($key, $unknown_properties))
860
+ $unknown_properties[] = $key;
861
+ }
862
+ $i++;
863
+ }
864
+ if ($block[1] != '')
865
+ $row['*comment']['value'] = $block[1];
866
+ if ($block[2] == '#' && !isset($row['enabled'])) {
867
+ $row['enabled'] = array('value' => false);
868
+ $obsolete_disabling_method[] = $block_string;
869
+ }
870
+
871
+ $formula_fields_to_check = array();
872
+ if (isset($row['conditions']))
873
+ $formula_fields_to_check[] = 'conditions';
874
+ if (isset($row['fees']))
875
+ $formula_fields_to_check[] = 'fees';
876
+
877
+ if (count($formula_fields_to_check) > 0) {
878
+ foreach ($formula_fields_to_check as $property) {
879
+ $property_value = $row[$property]['value'];
880
+ if (preg_match('/{ +/', $property_value)) {
881
+ $this->addMessage('warning', $row, $property, 'There are unwanted spaces after char `%s`', '{');
882
+ $property_value = preg_replace('/{ +/', '{', $property_value);
883
+ }
884
+ if (preg_match('/ +}/', $property_value)) {
885
+ $this->addMessage('warning', $row, $property, 'There are unwanted spaces before char `%s`', '}');
886
+ $property_value = preg_replace('/ +}/', '}', $property_value);
887
+ }
888
+ if (preg_match('/ +/', $property_value)) {
889
+ $this->addMessage('warning', $row, $property, 'There are unwanted multiples spaces `%s`', preg_replace('/( +)/', '<span class="osh-formula">*$1*</span>', $property_value));
890
+ $property_value = preg_replace('/ +/', ' ', $property_value);
891
+ }
892
+ $row[$property]['value'] = trim($property_value);
893
+ }
894
+ }
895
+
896
+ $float_value_regex = '\\s*(' . self::$POSITIVE_FLOAT_REGEX . '|\*)\\s*';
897
+ $conditions = array();
898
+ if (isset($row['prices_range'])) {
899
+ if (!in_array('prices_range', $deprecated_properties))
900
+ $deprecated_properties[] = 'prices_range';
901
+
902
+ $result = $this->_getOptionsAndData($row['prices_range']['value']);
903
+ $options = $result['options'];
904
+ $prices_range = $result['data'];
905
+
906
+ if (($options == '' || in_array($options, array('incl.tax', 'ttc'))) && preg_match('/^\\s*(\[|\])?' . $float_value_regex . '=>' . $float_value_regex . '(\[|\])?\\s*$/', $prices_range, $result)) {
907
+ $min_price_included = $result[1] == '[';
908
+ $min_price = $result[2] == '*' ? -1 : (float) $result[2];
909
+ $max_price = $result[3] == '*' ? -1 : (float) $result[3];
910
+ $max_price_included = !isset($result[4]) || $result[4] == ']' || $result[4] == '';
911
+
912
+ $tax_included = $options != '' && in_array($options, array('incl.tax', 'ttc')) || isset($row['reference_value']) && $row['reference_value']['value'] == 'price_including_tax';
913
+ $price = $tax_included ? '{cart.price_including_tax}' : '{cart.price_excluding_tax}';
914
+
915
+ if ($min_price != -1)
916
+ $conditions[] = $price . '>' . ($min_price_included ? '=' : '') . $min_price;
917
+ if ($max_price != -1)
918
+ $conditions[] = $price . '<' . ($max_price_included ? '=' : '') . $max_price;
919
+ }
920
+ else
921
+ $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">prices_range</span>', '<span class="osh-formula">' . $row['prices_range']['value'] . '</span>');
922
+ unset($row['prices_range']);
923
+ }
924
+ if (isset($row['weights_range'])) {
925
+ if (!in_array('weights_range', $deprecated_properties))
926
+ $deprecated_properties[] = 'weights_range';
927
+ if (preg_match('/^\\s*(\[|\])?' . $float_value_regex . '=>' . $float_value_regex . '(\[|\])?\\s*$/', $row['weights_range']['value'], $result)) {
928
+ $min_weight_included = $result[1] == '[';
929
+ $min_weight = $result[2] == '*' ? -1 : (float) $result[2];
930
+ $max_weight = $result[3] == '*' ? -1 : (float) $result[3];
931
+ $max_weight_included = !isset($result[4]) || $result[4] == ']' || $result[4] == '';
932
+
933
+ if ($min_weight != -1)
934
+ $conditions[] = '{cart.weight}>' . ($min_weight_included ? '=' : '') . $min_weight;
935
+ if ($max_weight != -1)
936
+ $conditions[] = '{cart.weight}<' . ($max_weight_included ? '=' : '') . $max_weight;
937
+ }
938
+ else
939
+ $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">weights_range</span>', '<span class="osh-formula">' . $row['weights_range']['value'] . '</span>');
940
+ unset($row['weights_range']);
941
+ }
942
+ if (isset($row['product_properties'])) {
943
+ if (!in_array('product_properties', $deprecated_properties))
944
+ $deprecated_properties[] = 'product_properties';
945
+ $product_property_regex = "\\s*(and|or)? *\((?:(all|any|sum) )?(attribute|option) '([^'\)]+)' ?(==|=|<=|>=|<|>|!=) ?(" . self::$FLOAT_REGEX . "|true|false|'[^'\)]*')\)\\s*";
946
+ if (preg_match('/^(' . $product_property_regex . ')+$/', $row['product_properties']['value'], $result)) {
947
+ preg_match_all('/' . $product_property_regex . '/', $row['product_properties']['value'], $results, PREG_SET_ORDER);
948
+ $product_properties_condition = '';
949
+ foreach ($results as $result) {
950
+ $and_or = $result[1];
951
+ if ($and_or == '')
952
+ $and_or = 'and';
953
+ $any_all_sum = $result[2];
954
+ if ($any_all_sum == '')
955
+ $any_all_sum = 'any';
956
+ $property_type = $result[3];
957
+ $property_name = $result[4];
958
+ $cmp_symbol = $result[5];
959
+ if ($cmp_symbol == '=')
960
+ $cmp_symbol = '==';
961
+ $cmp_value = $result[6];
962
+
963
+ $product_properties_condition .= $product_properties_condition == '' ? '' : ' ' . $and_or . ' ';
964
+ switch ($any_all_sum) {
965
+ case 'sum':
966
+ $product_properties_condition .= "{sum product." . $property_type . "." . $property_name . "}" . $cmp_symbol . $cmp_value;
967
+ break;
968
+ case 'all':
969
+ $product_properties_condition .= "{count products where product." . $property_type . "." . $property_name . $cmp_symbol . $cmp_value . "}=={products_quantity}";
970
+ break;
971
+ case 'any':
972
+ $product_properties_condition .= "{count products where product." . $property_type . "." . $property_name . $cmp_symbol . $cmp_value . "}>0";
973
+ break;
974
+ }
975
+ }
976
+ if ($product_properties_condition != '')
977
+ $conditions[] = $product_properties_condition;
978
+ }
979
+ else
980
+ $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">product_properties</span>', '<span class="osh-formula">' . $row['product_properties']['value'] . '</span>');
981
+ unset($row['product_properties']);
982
+ }
983
+ if (count($conditions) > 0)
984
+ $row['conditions'] = array('value' => count($conditions) == 1 ? $conditions[0] : '(' . implode(') && (', $conditions) . ')');
985
+
986
+ $fees = array();
987
+ if (isset($row['fees_table'])) {
988
+ if (!in_array('fees_table', $deprecated_properties))
989
+ $deprecated_properties[] = 'fees_table';
990
+ $options_and_data = $this->_getOptionsAndData($row['fees_table']['value']);
991
+ $options = $options_and_data['options'];
992
+ $fees_table_string = $options_and_data['data'];
993
+
994
+ $var = null;
995
+ if ($options == '')
996
+ $var = (isset($row['reference_value']) ? $row['reference_value']['value'] : 'weight');
997
+ else if (in_array($options, array('incl.tax', 'ttc')))
998
+ $var = 'price_including_tax';
999
+ else if (in_array($options, array('excl.tax', 'ht')))
1000
+ $var = 'price_excluding_tax';
1001
+
1002
+ if (isset($var)) {
1003
+ if ($var == 'price')
1004
+ $var = 'price_excluding_tax';
1005
+ if ($var == 'products_quantity')
1006
+ $var = 'quantity';
1007
+ if (preg_match('/^[[:space:]]*\*[[:space:]]*:[[:space:]]*(' . $float_value_regex . ')[[:space:]]*$/s', $fees_table_string, $result))
1008
+ $fees[] = $result[1];
1009
+ else
1010
+ $fees[] = "{table {cart." . $var . "} in " . str_replace(' ', '', $fees_table_string) . "}" . ($var == 'quantity' ? '*{cart.quantity}' : '');
1011
+ }
1012
+ else
1013
+ $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">fees_table</span>', '<span class="osh-formula">' . $row['fees_table']['value'] . '</span>');
1014
+ unset($row['fees_table']);
1015
+ }
1016
+ if (isset($row['fees_formula'])) {
1017
+ if (!in_array('fees_formula', $deprecated_properties))
1018
+ $deprecated_properties[] = 'fees_formula';
1019
+ $fees[] = str_replace(' ', '', $row['fees_formula']['value']);
1020
+ unset($row['fees_formula']);
1021
+ }
1022
+ if (isset($row['fixed_fees'])) {
1023
+ if (!in_array('fixed_fees', $deprecated_properties))
1024
+ $deprecated_properties[] = 'fixed_fees';
1025
+ if ($row['fixed_fees']['value'] != 0 || count($fees) == 0)
1026
+ $fees[] = str_replace(' ', '', $row['fixed_fees']['value']);
1027
+ unset($row['fixed_fees']);
1028
+ }
1029
+ if (!isset($row['fees']) && count($fees) > 0)
1030
+ $row['fees'] = array('value' => implode('+', $fees));
1031
+
1032
+ $fs_fees = array();
1033
+ if (isset($row['free_shipping__fees_table'])) {
1034
+ if (!in_array('free_shipping__fees_table', $deprecated_properties))
1035
+ $deprecated_properties[] = 'free_shipping__fees_table';
1036
+ $options_and_data = $this->_getOptionsAndData($row['free_shipping__fees_table']['value']);
1037
+ $options = $options_and_data['options'];
1038
+ $fees_table_string = $options_and_data['data'];
1039
+
1040
+ $var = null;
1041
+ if ($options == '')
1042
+ $var = isset($row['reference_value']) ? $row['reference_value']['value'] : 'weight';
1043
+ else if (in_array($options, array('incl.tax', 'ttc')))
1044
+ $var = 'price_including_tax';
1045
+ else if (in_array($options, array('excl.tax', 'ht')))
1046
+ $var = 'price_excluding_tax';
1047
+ if ($var == 'price')
1048
+ $var = 'price_excluding_tax';
1049
+
1050
+ if (isset($var)) {
1051
+ if ($var == 'price')
1052
+ $var = 'price_excluding_tax';
1053
+ if ($var == 'products_quantity')
1054
+ $var = 'quantity';
1055
+ if (preg_match('/^[[:space:]]*\*[[:space:]]*:[[:space:]]*(' . $float_value_regex . ')[[:space:]]*$/s', $fees_table_string, $result))
1056
+ $fs_fees[] = $result[1];
1057
+ else
1058
+ $fs_fees[] = "{table {cart." . $var . "} in " . str_replace(' ', '', $fees_table_string) . "}" . ($var == 'quantity' ? '*{cart.quantity}' : '');
1059
+ }
1060
+ else
1061
+ $this->addMessage('error', $row, null, 'Unrecognized value of deprecated property %s %s', '<span class="osh-key">free_shipping__fees_table</span>', '<span class="osh-formula">' . $row['free_shipping__fees_table']['value'] . '</span>');
1062
+ unset($row['free_shipping__fees_table']);
1063
+ }
1064
+ if (isset($row['free_shipping__fees_formula'])) {
1065
+ if (!in_array('free_shipping__fees_formula', $deprecated_properties))
1066
+ $deprecated_properties[] = 'free_shipping__fees_formula';
1067
+ $fs_fees[] = str_replace(' ', '', $row['free_shipping__fees_formula']['value']);
1068
+ unset($row['free_shipping__fees_formula']);
1069
+ }
1070
+ if (isset($row['free_shipping__fixed_fees'])) {
1071
+ if (!in_array('free_shipping__fixed_fees', $deprecated_properties))
1072
+ $deprecated_properties[] = 'free_shipping__fixed_fees';
1073
+ if ($row['free_shipping__fixed_fees']['value'] != 0 || count($fees) == 0)
1074
+ $fs_fees[] = str_replace(' ', '', $row['free_shipping__fixed_fees']['value']);
1075
+ unset($row['free_shipping__fixed_fees']);
1076
+ }
1077
+
1078
+ if (isset($row['reference_value'])) {
1079
+ if (!in_array('reference_value', $deprecated_properties))
1080
+ $deprecated_properties[] = 'reference_value';
1081
+ unset($row['reference_value']);
1082
+ }
1083
+
1084
+ if (count($fs_fees) > 0) {
1085
+ $row2 = $row;
1086
+ if (isset($row['code']))
1087
+ $row2['code']['value'] = $row['code']['value'] . '__free_shipping';
1088
+ $row2['fees']['value'] = implode('+', $fs_fees);
1089
+ $row2['conditions']['value'] = isset($row2['conditions']) ? '(' . $row2['conditions'] + ') and {free_shipping}' : '{free_shipping}';
1090
+ $row['conditions']['value'] = isset($row['conditions']) ? '(' . $row['conditions'] + ') and !{free_shipping}' : '!{free_shipping}';
1091
+ if (isset($row['free_shipping__label'])) {
1092
+ if (!in_array('free_shipping__label', $deprecated_properties))
1093
+ $deprecated_properties[] = 'free_shipping__label';
1094
+ $row2['label']['value'] = $row['free_shipping__label']['value'];
1095
+ unset($row['free_shipping__label']);
1096
+ unset($row2['free_shipping__label']);
1097
+ }
1098
+ $this->_addRow($row2);
1099
+ }
1100
+ if (count($unknown_properties) > 0)
1101
+ $this->addMessage('error', $row, null, 'Usage of unknown properties %s', ': <span class="osh-key">' . implode('</span>, <span class="osh-key">', $unknown_properties) . '</span>');
1102
+ if (count($deprecated_properties) > 0)
1103
+ $this->addMessage('warning', $row, null, 'Usage of deprecated properties %s', ': <span class="osh-key">' . implode('</span>, <span class="osh-key">', $deprecated_properties) . '</span>');
1104
+ if (count($obsolete_disabling_method) > 0)
1105
+ $this->addMessage('warning', $row, null, 'Usage of obsolete method to disabling a shipping method (`#` before `{`)%s', '<div class="code">' . implode('<br />', $obsolete_disabling_method) . '</div>');
1106
+ if (count($missing_semicolon) > 0)
1107
+ $this->addMessage('warning', $row, null, 'A semicolon is missing at the end of following lines %s', '<div class="code">' . implode('<br />', $missing_semicolon) . '</div>');
1108
+ $this->_addRow($row);
1109
+ }
1110
+ if (trim($config_string) != '') {
1111
+ $this->_addIgnoredLines(trim($config_string));
1112
+ $this->addMessage('info', $row = null, null, 'Ignored lines %s', '<div class="code">' . trim($config_string) . '</div>');
1113
+ }
1114
+ }
1115
+
1116
+ public function addMessage($type, &$row, $property) {
1117
+ $args = func_get_args();
1118
+ array_shift($args);
1119
+ array_shift($args);
1120
+ array_shift($args);
1121
+ $message = new OCS_Message($type, $args);
1122
+ if (isset($row)) {
1123
+ if (isset($property)) {
1124
+ $row[$property]['messages'][] = $message;
1125
+ } else {
1126
+ $row['*messages'][] = $message;
1127
+ }
1128
+ }
1129
+ $this->_messages[] = $message;
1130
+ self::debug(' => <span class="osh-' . $message->type . '">' . $message->toString() . '</span>', 1);
1131
+ }
1132
+
1133
+ protected function _addRow(&$row) {
1134
+ if (isset($row['code'])) {
1135
+ $key = $row['code']['value'];
1136
+ if (isset($this->_config[$key]))
1137
+ $this->addMessage('error', $row, 'code', 'The property `code` must be unique, `%s` has been found twice', $key);
1138
+ while (isset($this->_config[$key]))
1139
+ $key .= rand(0, 9);
1140
+ //$row['code'] = $key;
1141
+ } else {
1142
+ $i = 1;
1143
+ do {
1144
+ $key = 'code_auto' . sprintf('%03d', $i);
1145
+ $i++;
1146
+ } while (isset($this->_config[$key]));
1147
+ }
1148
+ $row['*code'] = $key;
1149
+ $this->_config[$key] = $row;
1150
+ }
1151
+
1152
+ protected function _addIgnoredLines($lines) {
1153
+ $this->_config[] = array('lines' => $lines);
1154
+ }
1155
+
1156
+ protected function _addressMatch($address_filter, $address) {
1157
+ $excluding = false;
1158
+ if (preg_match('# *\* *- *\((.*)\) *#s', $address_filter, $result)) {
1159
+ $address_filter = $result[1];
1160
+ $excluding = true;
1161
+ }
1162
+
1163
+ $tmp_address_filter_array = explode(',', trim($address_filter));
1164
+
1165
+ $concat = false;
1166
+ $concatened = '';
1167
+ $address_filter_array = array();
1168
+ $i = 0;
1169
+
1170
+ foreach ($tmp_address_filter_array as $address_filter) {
1171
+ if ($concat)
1172
+ $concatened .= ',' . $address_filter;
1173
+ else {
1174
+ if ($i < count($tmp_address_filter_array) - 1 && preg_match('#\(#', $address_filter)) {
1175
+ $concat = true;
1176
+ $concatened .= $address_filter;
1177
+ }
1178
+ else
1179
+ $address_filter_array[] = $address_filter;
1180
+ }
1181
+ if (preg_match('#\)#', $address_filter)) {
1182
+ $address_filter_array[] = $concatened;
1183
+ $concatened = '';
1184
+ $concat = false;
1185
+ }
1186
+ $i++;
1187
+ }
1188
+
1189
+ foreach ($address_filter_array as $address_filter) {
1190
+ if (preg_match('# *([A-Z]{2}) *(-)? *(?:\( *(-)? *(.*)\))? *#s', $address_filter, $result)) {
1191
+ $country_code = $result[1];
1192
+ if ($address['country_code'] == $country_code) {
1193
+ self::debug(' country code <span class="osh-replacement">' . $address['country_code'] . '</span> matches', 5);
1194
+ if (!isset($result[4]) || $result[4] == '')
1195
+ return !$excluding;
1196
+ else {
1197
+ $region_codes = explode(',', $result[4]);
1198
+ $in_array = false;
1199
+ for ($i = count($region_codes); --$i >= 0;) {
1200
+ $code = trim($region_codes[$i]);
1201
+ $region_codes[$i] = $code;
1202
+ if ($address['region_code'] === $code) {
1203
+ self::debug(' region code <span class="osh-replacement">' . $address['region_code'] . '</span> matches', 5);
1204
+ $in_array = true;
1205
+ } else if ($address['postcode'] === $code) {
1206
+ self::debug(' postcode <span class="osh-replacement">' . $address['postcode'] . '</span> matches', 5);
1207
+ $in_array = true;
1208
+ } else if (strpos($code, '*') !== false && preg_match('/^' . str_replace('*', '(?:.*)', $code) . '$/', $address['postcode'])) {
1209
+ self::debug(' postcode <span class="osh-replacement">' . $address['postcode'] . '</span> matches <span class="osh-formula">' . $code . '</span>', 5);
1210
+ $in_array = true;
1211
+ }
1212
+ if ($in_array)
1213
+ break;
1214
+ }
1215
+ if (!$in_array) {
1216
+ self::debug(' region code <span class="osh-replacement">' . $address['region_code'] . '</span> and postcode <span class="osh-replacement">' . $address['postcode'] . '</span> don\'t match', 5);
1217
+ }
1218
+ // Vérification stricte
1219
+ /* $in_array = in_array($address['region_code'],$region_codes,true) || in_array($address['postcode'],$region_codes,true); */
1220
+ $excluding_region = $result[2] == '-' || $result[3] == '-';
1221
+ if ($excluding_region && !$in_array || !$excluding_region && $in_array)
1222
+ return !$excluding;
1223
+ }
1224
+ }
1225
+ }
1226
+ }
1227
+ return $excluding;
1228
+ }
1229
+
1230
+ protected function _getProductProperty($product, $property_type, $property_name, $get_by_id = false) {
1231
+ switch ($property_type) {
1232
+ case 'attribute':
1233
+ case 'attributes': return $product->getAttribute($property_name, $get_by_id);
1234
+ case 'option':
1235
+ case 'options': return $product->getOption($property_name, $get_by_id);
1236
+ case 'stock': return $product->getStockData($property_name);
1237
+ }
1238
+ return null;
1239
+ }
1240
+
1241
+ protected function _processProductProperty($products, $regex_result) {
1242
+ // COUNT, SUM or COUNT DISTINCT
1243
+ $operation = strtolower($regex_result[1]);
1244
+ switch ($operation) {
1245
+ case 'sum':
1246
+ case 'count distinct':
1247
+ $property_type = $regex_result[2];
1248
+ $property_name = $regex_result[3];
1249
+ $conditions = isset($regex_result[4]) ? $regex_result[4] : null;
1250
+ break;
1251
+ case 'count':
1252
+ $conditions = isset($regex_result[2]) ? $regex_result[2] : null;
1253
+ break;
1254
+ }
1255
+
1256
+ self::debug(' :: start <span class="osh-replacement">' . $regex_result[0] . '</span>', 10);
1257
+
1258
+ $return_value = 0;
1259
+
1260
+ preg_match_all('/product\.(attribute(?:s)?|option(?:s)?|stock)\.([a-z0-9_]+)(?:\.(id))?/i', $conditions, $properties_regex_result, PREG_SET_ORDER);
1261
+ $properties = array();
1262
+ foreach ($properties_regex_result as $property_regex_result) {
1263
+ $key = $property_regex_result[0];
1264
+ if (!isset($properties[$key]))
1265
+ $properties[$key] = $property_regex_result;
1266
+ }
1267
+
1268
+ foreach ($products as $product) {
1269
+ if (isset($conditions) && $conditions != '') {
1270
+ $formula = $conditions;
1271
+ foreach ($properties as $property) {
1272
+ $value = $this->_getProductProperty(
1273
+ $product, $tmp_property_type = $property[1], $tmp_property_name = $property[2], $get_by_id = isset($property[3]) && $property[3] == 'id'
1274
+ );
1275
+ //$formula = $this->replace($property[0],$value,$formula);
1276
+ $from = $property[0];
1277
+ $to = is_string($value) || empty($value) ? "'" . $value . "'" : $value;
1278
+ $formula = str_replace($from, $to, $formula);
1279
+ self::debug(' replace <span class="osh-replacement">' . $from . '</span> by <span class="osh-replacement">' . $to . '</span> =&gt; <span class="osh-formula">' . str_replace($from, '<span class="osh-replacement">' . $to . '</span>', $formula) . '</span>', 5);
1280
+ }
1281
+ $eval_result = $this->_evalFormula($formula);
1282
+ if (!isset($eval_result))
1283
+ return 'null';
1284
+ }
1285
+ else
1286
+ $eval_result = true;
1287
+
1288
+ if ($eval_result == true) {
1289
+ switch ($operation) {
1290
+ case 'sum':
1291
+ $value = $this->_getProductProperty($product, $property_type, $property_name);
1292
+ //self::debug($product->getSku().'.'.$property_type.'.'.$property_name.' = "'.$value.'" x '.$product->getQuantity(),10);
1293
+ $return_value += $value * $product->getQuantity();
1294
+ break;
1295
+ case 'count distinct':
1296
+ if (!isset($distinct_values))
1297
+ $distinct_values = array();
1298
+ $value = $this->_getProductProperty($product, $property_type, $property_name);
1299
+ if (!in_array($value, $distinct_values)) {
1300
+ $distinct_values[] = $value;
1301
+ $return_value++;
1302
+ }
1303
+ break;
1304
+ case 'count':
1305
+ $return_value += $product->getQuantity();
1306
+ break;
1307
+ }
1308
+ }
1309
+ }
1310
+
1311
+ self::debug(' :: end <span class="osh-replacement">' . $regex_result[0] . '</span>', 10);
1312
+
1313
+ return $return_value;
1314
+ }
1315
 
1316
  }
1317
 
1318
  interface OCS_Product {
1319
+
1320
+ public function getOption($option);
1321
+
1322
+ public function getAttribute($attribute);
1323
+
1324
+ public function getName();
1325
+
1326
+ public function getSku();
1327
+
1328
+ public function getQuantity();
1329
+
1330
+ public function getStockData($key);
1331
  }
1332
 
1333
  class OCS_Message {
1334
+
1335
+ public $type;
1336
+ public $message;
1337
+ public $args;
1338
+
1339
+ public function OCS_Message($type, $args) {
1340
+ $this->type = $type;
1341
+ $this->message = array_shift($args);
1342
+ $this->args = $args;
1343
+ }
1344
+
1345
+ public function toString() {
1346
+ return vsprintf($this->message, $this->args);
1347
+ }
1348
+
1349
  }
1350
 
1351
  class OCS_Result {
 
 
1352
 
1353
+ public $success;
1354
+ public $result;
 
 
1355
 
1356
+ public function OCS_Result($success, $result = null) {
1357
+ $this->success = $success;
1358
+ $this->result = $result;
1359
+ }
1360
+
1361
+ public function __toString() {
1362
+ return is_bool($this->result) ? ($this->result ? 'true' : 'false') : (string) $this->result;
1363
+ }
1364
 
1365
+ }
1366
 
1367
  ?>
app/code/community/Chronopost/Chronorelais/includes/countries.inc.php CHANGED
@@ -1,523 +1,523 @@
1
- <?php
2
-
3
-
4
- class Country
5
- {
6
- private static $LOADED = false;
7
- private static $COUNTRIES = array(
8
- 'code2name' => array(
9
- 'AF' => 'Afghanistan',
10
- 'ZA' => 'Afrique du Sud',
11
- 'AX' => 'Åland',
12
- 'AL' => 'Albanie',
13
- 'DZ' => 'Algérie',
14
- 'DE' => 'Allemagne',
15
- 'AD' => 'Andorre',
16
- 'AO' => 'Angola',
17
- 'AI' => 'Anguilla',
18
- 'AQ' => 'Antarctique',
19
- 'AG' => 'Antigua-et-Barbuda',
20
- 'AN' => 'Antilles néerlandaises',
21
- 'SA' => 'Arabie saoudite',
22
- 'AR' => 'Argentine',
23
- 'AM' => 'Arménie',
24
- 'AW' => 'Aruba',
25
- 'AU' => 'Australie',
26
- 'AT' => 'Autriche',
27
- 'AZ' => 'Azerbaïdjan',
28
- 'BS' => 'Bahamas',
29
- 'BH' => 'Bahreïn',
30
- 'BD' => 'Bangladesh',
31
- 'BB' => 'Barbade',
32
- 'BY' => 'Biélorussie',
33
- 'BE' => 'Belgique',
34
- 'BZ' => 'Belize',
35
- 'BJ' => 'Bénin',
36
- 'BM' => 'Bermudes',
37
- 'BT' => 'Bhoutan',
38
- 'BO' => 'Bolivie',
39
- 'BA' => 'Bosnie-Herzégovine',
40
- 'BW' => 'Botswana',
41
- 'BV' => 'Île Bouvet',
42
- 'BR' => 'Brésil',
43
- 'BN' => 'Brunei',
44
- 'BG' => 'Bulgarie',
45
- 'BF' => 'Burkina Faso',
46
- 'BI' => 'Burundi',
47
- 'KY' => 'Îles Caïmans',
48
- 'KH' => 'Cambodge',
49
- 'CM' => 'Cameroun',
50
- 'CA' => 'Canada',
51
- 'CV' => 'Cap-Vert',
52
- 'CF' => 'République centrafricaine',
53
- 'CL' => 'Chili',
54
- 'CN' => 'Chine',
55
- 'CX' => 'Île Christmas',
56
- 'CY' => 'Chypre',
57
- 'CC' => 'Îles Cocos',
58
- 'CO' => 'Colombie',
59
- 'KM' => 'Comores',
60
- 'CG' => 'Congo',
61
- 'CD' => 'République démocratique du Congo',
62
- 'CK' => 'Îles Cook',
63
- 'KR' => 'Corée du Sud',
64
- 'KP' => 'Corée du Nord',
65
- 'CR' => 'Costa Rica',
66
- 'CI' => "Côte d'Ivoire",
67
- 'HR' => 'Croatie',
68
- 'CU' => 'Cuba',
69
- 'DK' => 'Danemark',
70
- 'DJ' => 'Djibouti',
71
- 'DO' => 'République dominicaine',
72
- 'DM' => 'Dominique',
73
- 'EG' => 'Égypte',
74
- 'SV' => 'Salvador',
75
- 'AE' => 'Émirats arabes unis',
76
- 'EC' => 'Équateur',
77
- 'ER' => 'Érythrée',
78
- 'ES' => 'Espagne',
79
- 'EE' => 'Estonie',
80
- 'US' => 'États-Unis',
81
- 'ET' => 'Éthiopie',
82
- 'FK' => 'Îles Malouines',
83
- 'FO' => 'Îles Féroé',
84
- 'FJ' => 'Fidji',
85
- 'FI' => 'Finlande',
86
- 'FR' => 'France',
87
- 'GA' => 'Gabon',
88
- 'GM' => 'Gambie',
89
- 'GE' => 'Géorgie',
90
- 'GS' => 'Géorgie du Sud-et-les Îles Sandwich du Sud',
91
- 'GH' => 'Ghana',
92
- 'GI' => 'Gibraltar',
93
- 'GR' => 'Grèce',
94
- 'GD' => 'Grenade',
95
- 'GL' => 'Groenland',
96
- 'GP' => 'Guadeloupe',
97
- 'GU' => 'Guam',
98
- 'GT' => 'Guatemala',
99
- 'GG' => 'Guernesey',
100
- 'GN' => 'Guinée',
101
- 'GW' => 'Guinée-Bissau',
102
- 'GQ' => 'Guinée équatoriale',
103
- 'GY' => 'Guyana',
104
- 'GF' => 'Guyane Française',
105
- 'HT' => 'Haïti',
106
- 'HM' => 'Îles Heard-et-MacDonald',
107
- 'HN' => 'Honduras',
108
- 'HK' => 'Hong Kong',
109
- 'HU' => 'Hongrie',
110
- 'IM' => 'Île de Man',
111
- 'UM' => 'Îles mineures éloignées des États-Unis',
112
- 'VG' => 'Îles Vierges britanniques',
113
- 'VI' => 'Îles Vierges américaines',
114
- 'IN' => 'Inde',
115
- 'ID' => 'Indonésie',
116
- 'IR' => 'Iran',
117
- 'IQ' => 'Irak',
118
- 'IE' => 'Irlande',
119
- 'IS' => 'Islande',
120
- 'IL' => 'Israël',
121
- 'IT' => 'Italie',
122
- 'JM' => 'Jamaïque',
123
- 'JP' => 'Japon',
124
- 'JE' => 'Jersey',
125
- 'JO' => 'Jordanie',
126
- 'KZ' => 'Kazakhstan',
127
- 'KE' => 'Kenya',
128
- 'KG' => 'Kirghizistan',
129
- 'KI' => 'Kiribati',
130
- 'KW' => 'Koweït',
131
- 'LA' => 'Laos',
132
- 'LS' => 'Lesotho',
133
- 'LV' => 'Lettonie',
134
- 'LB' => 'Liban',
135
- 'LR' => 'Libéria',
136
- 'LY' => 'Libye',
137
- 'LI' => 'Liechtenstein',
138
- 'LT' => 'Lituanie',
139
- 'LU' => 'Luxembourg',
140
- 'MO' => 'Macao',
141
- 'MK' => 'Macédoine',
142
- 'MG' => 'Madagascar',
143
- 'MY' => 'Malaisie',
144
- 'MW' => 'Malawi',
145
- 'MV' => 'Maldives',
146
- 'ML' => 'Mali',
147
- 'MT' => 'Malte',
148
- 'MP' => 'Îles Mariannes du Nord',
149
- 'MA' => 'Maroc',
150
- 'MH' => 'Îles Marshall',
151
- 'MQ' => 'Martinique',
152
- 'MU' => 'Île Maurice',
153
- 'MR' => 'Mauritanie',
154
- 'YT' => 'Mayotte',
155
- 'MX' => 'Mexique',
156
- 'FM' => 'Micronésie',
157
- 'MD' => 'Moldavie',
158
- 'MC' => 'Monaco',
159
- 'MN' => 'Mongolie',
160
- 'ME' => 'Monténégro',
161
- 'MS' => 'Montserrat',
162
- 'MZ' => 'Mozambique',
163
- 'MM' => 'Birmanie',
164
- 'NA' => 'Namibie',
165
- 'NR' => 'Nauru',
166
- 'NP' => 'Népal',
167
- 'NI' => 'Nicaragua',
168
- 'NE' => 'Niger',
169
- 'NG' => 'Nigéria',
170
- 'NU' => 'Niué',
171
- 'NF' => 'Île Norfolk',
172
- 'NO' => 'Norvège',
173
- 'NC' => 'Nouvelle-Calédonie',
174
- 'NZ' => 'Nouvelle-Zélande',
175
- 'IO' => "Territoire britannique de l'océan Indien",
176
- 'OM' => 'Oman',
177
- 'UG' => 'Ouganda',
178
- 'UZ' => 'Ouzbékistan',
179
- 'PK' => 'Pakistan',
180
- 'PW' => 'Palaos',
181
- 'PS' => 'Palestine',
182
- 'PA' => 'Panamá',
183
- 'PG' => 'Papouasie-Nouvelle-Guinée',
184
- 'PY' => 'Paraguay',
185
- 'NL' => 'Pays-Bas',
186
- 'PE' => 'Pérou',
187
- 'PH' => 'Philippines',
188
- 'PN' => 'Îles Pitcairn',
189
- 'PL' => 'Pologne',
190
- 'PF' => 'Polynésie Française',
191
- 'PR' => 'Porto Rico',
192
- 'PT' => 'Portugal',
193
- 'QA' => 'Qatar',
194
- 'RE' => 'La Réunion',
195
- 'RO' => 'Roumanie',
196
- 'GB' => 'Royaume-Uni',
197
- 'RU' => 'Russie',
198
- 'RW' => 'Rwanda',
199
- 'EH' => 'Sahara occidental',
200
- 'BL' => 'Saint-Barthélemy',
201
- 'KN' => 'Saint-Christophe-et-Niévès',
202
- 'SM' => 'Saint-Marin',
203
- 'MF' => 'Saint-Martin',
204
- 'PM' => 'Saint-Pierre-et-Miquelon',
205
- 'VA' => 'Vatican',
206
- 'VC' => 'Saint-Vincent-et-les Grenadines',
207
- 'SH' => 'Sainte-Hélène',
208
- 'LC' => 'Sainte-Lucie',
209
- 'SB' => 'Îles Salomon',
210
- 'WS' => 'Samoa',
211
- 'AS' => 'Samoa américaines',
212
- 'ST' => 'São Tomé-et-Principe',
213
- 'SN' => 'Sénégal',
214
- 'RS' => 'Serbie',
215
- 'SC' => 'Seychelles',
216
- 'SL' => 'Sierra Leone',
217
- 'SG' => 'Singapour',
218
- 'SK' => 'Slovaquie',
219
- 'SI' => 'Slovénie',
220
- 'SO' => 'Somalie',
221
- 'SD' => 'Soudan',
222
- 'LK' => 'Sri Lanka',
223
- 'SE' => 'Suède',
224
- 'CH' => 'Suisse',
225
- 'SR' => 'Suriname',
226
- 'SJ' => 'Svalbard et île Jan Mayen',
227
- 'SZ' => 'Swaziland',
228
- 'SY' => 'Syrie',
229
- 'TJ' => 'Tadjikistan',
230
- 'TW' => 'Taïwan',
231
- 'TZ' => 'Tanzanie',
232
- 'TD' => 'Tchad',
233
- 'CZ' => 'République tchèque',
234
- 'TF' => 'Terres Australes et Antarctiques Françaises',
235
- 'TH' => 'Thaïlande',
236
- 'TL' => 'Timor oriental',
237
- 'TG' => 'Togo',
238
- 'TK' => 'Tokelau',
239
- 'TO' => 'Tonga',
240
- 'TT' => 'Trinité-et-Tobago',
241
- 'TN' => 'Tunisie',
242
- 'TM' => 'Turkménistan',
243
- 'TC' => 'Îles Turques-et-Caïques',
244
- 'TR' => 'Turquie',
245
- 'TV' => 'Tuvalu',
246
- 'UA' => 'Ukraine',
247
- 'UY' => 'Uruguay',
248
- 'VU' => 'Vanuatu',
249
- 'VE' => 'Venezuela',
250
- 'VN' => 'Viêt Nam',
251
- 'WF' => 'Wallis-et-Futuna',
252
- 'YE' => 'Yémen',
253
- 'ZM' => 'Zambie',
254
- 'ZW' => 'Zimbabwe',
255
- ),
256
- 'code2soft-cleaned-name' => null,
257
- 'code2hard-cleaned-name' => null,
258
- 'replacement' => array(
259
- 'reunion' => 'RE',
260
- 'france-metropolitaine' => 'FR',
261
- 'guyane' => 'GF',
262
- 'taaf' => 'TF',
263
- 'terres-australes-francaises' => 'TF',
264
- 'usa' => 'US',
265
- 'hollande' => 'NL',
266
- 'grande-bretagne' => 'GB',
267
- 'vietnam' => 'VN',
268
- 'belarus' => 'BY',
269
- 'brunei-darussalam' => 'BN',
270
- 'cayman' => 'KY',
271
- 'caiman' => 'KY',
272
- 'caimanes' => 'KY',
273
- 'cocos-keeling' => 'CC',
274
- 'keeling' => 'CC',
275
- 'centrafrique' => 'CF',
276
- 'congo-brazzaville' => 'CG',
277
- 'congo-kinshasa' => 'CD',
278
- 'zaire' => 'CD',
279
- 'san-marin' => 'SM',
280
- 'surinam' => 'SR',
281
- 'myanmar' => 'MM',
282
- 'saint-christophe-nevis' => 'KN',
283
- 'saint-kitts-nevis' => 'KN',
284
- 'falkland' => 'FK',
285
- 'el-salvador' => 'SV',
286
- 'lithuanie' => 'LT',
287
- 'turks-caiques' => 'TC',
288
- 'vierges-des-etats-unis' => 'VI',
289
- 'etat-de-la-cite-du-vatican' => 'VA',
290
- 'etats-federes-de-micronesie' => 'FM',
291
- 'r-a-s-chinoise-de-hong-kong' => 'HK',
292
- 'r-a-s-chinoise-de-macao' => 'MO',
293
- ),
294
- );
295
-
296
- public static function loadCache() {
297
- $filename = 'cache/countries';
298
- if (!file_exists($filename)) {
299
- self::$COUNTRIES['code2soft-cleaned-name'] = array();
300
- self::$COUNTRIES['code2hard-cleaned-name'] = array();
301
- foreach (self::$COUNTRIES['code2name'] as $_code => $_name) {
302
- $soft_cleaned = self::softClean($_name);
303
- self::$COUNTRIES['code2soft-cleaned-name'][$_code] = $soft_cleaned;
304
- self::$COUNTRIES['code2hard-cleaned-name'][$_code] = self::hardClean($soft_cleaned);
305
- }
306
- file_put_contents('cache/countries',serialize(self::$COUNTRIES));
307
- } else {
308
- self::$COUNTRIES = unserialize(file_get_contents('cache/countries'));
309
- }
310
- }
311
-
312
- public static function getCountryNameByCode($code) {
313
- return isset(self::$COUNTRIES['code2name'][$code]) ? self::$COUNTRIES['code2name'][$code] : null;
314
- }
315
-
316
- public static function getCountryCodeByName($name, $name_type=null) {
317
- $suffix = isset($name_type) ? $name_type.'-' : '';
318
- if (!self::$LOADED) self::loadCache();
319
- $code = array_search($name, self::$COUNTRIES['code2'.$suffix.'name']);
320
- return $code!==false ? $code : null;
321
- }
322
-
323
- public static function getCountryCodeByReplacedName($cleaned_name) {
324
- if (isset(self::$COUNTRIES['replacement'][$cleaned_name])) return self::$COUNTRIES['replacement'][$cleaned_name];
325
- return null;
326
- }
327
-
328
- public static function softClean($input) {
329
- $input = mb_strtolower($input,'UTF-8');
330
- $input = preg_replace('/[ -\.]+/','-',trim($input));
331
- //echo '"'.$input.'" => ';
332
- $input = str_replace(
333
- array(' ','ç','é','è','ê','ë','à','á','â','ä','ã','å','ô','ö','ù','û','ü','î','ï','ÿ'),
334
- array('-','c','e','e','e','e','a','a','a','a','a','a','o','o','u','u','u','i','i','y'),
335
- $input
336
- );
337
- //echo '"'.$input.'", ';
338
- $input = preg_replace("/^st-/",'saint-',$input);
339
- $input = preg_replace("/^ste-/",'sainte-',$input);
340
- $input = preg_replace("/-&-/",'-et-',$input);
341
- return $input;
342
- }
343
-
344
- public static function hardClean($input) {
345
- //$output = preg_match('/ivoire/',$input);
346
- //if ($output) echo '"'.$input.'" => ';
347
- $input = preg_replace("/^(?:les|le|la|l'|ile|iles)-/",'',$input);
348
- $input = preg_replace("/-(?:ile|iles)$/",'',$input);
349
- $input = preg_replace("/-(?:(?:et|les)-)+/",'-',$input);
350
- $input = preg_replace("/(?:[^a-z0-9]+)/",'-',$input);
351
- //if ($output) echo '"'.$input.'",<br/>';
352
- return $input;
353
- }
354
-
355
- }
356
-
357
- class AddressFilter extends Country
358
- {
359
- private $data;
360
- private $code;
361
- private $name;
362
- private $classes;
363
- private $label;
364
- private $arranged;
365
- private $address_filters_list;
366
-
367
- public function AddressFilter($data) {
368
- $input = trim($input);
369
- $this->data = $data;
370
- $this->classes = array();
371
- $this->address_filters_list = null;
372
- $this->parse();
373
- }
374
-
375
- public function parse($recursive=true) {
376
- if (strlen($this->data['country_code'])==2) {
377
- $code = strtoupper($this->data['country_code']);
378
- $name = Country::getCountryNameByCode($code);
379
-
380
- if (isset($name)) {
381
- $this->code = $code;
382
- $this->name = $name;
383
- $this->classes[] = 'known';
384
- }
385
- }
386
- if (!isset($this->name)) {
387
- $code = Country::getCountryCodeByName($this->data['country_code']);
388
- if (!isset($code)) {
389
- $this->classes[] = 'soft-cleaned';
390
- $cleaned_name = Country::softClean($this->data['country_code']);
391
- $code = Country::getCountryCodeByName($cleaned_name,'soft-cleaned');
392
- }
393
- if (!isset($code)) {
394
- $this->classes[] = 'replaced';
395
- $code = Country::getCountryCodeByReplacedName($cleaned_name);
396
- }
397
- if (!isset($code)) {
398
- $this->classes[] = 'hard-cleaned';
399
- $cleaned_name = Country::hardClean($cleaned_name);
400
- $code = Country::getCountryCodeByName($cleaned_name,'hard-cleaned');
401
- }
402
- if (!isset($code)) {
403
- $this->classes[] = 'replaced';
404
- $code = Country::getCountryCodeByReplacedName($cleaned_name);
405
- }
406
- if (isset($code)) {
407
- $this->code = $code;
408
- $this->name = Country::getCountryNameByCode($code);
409
- $this->classes[] = 'known';
410
- } else {
411
- $this->classes[] = 'unknown';
412
- }
413
- }
414
-
415
- if ($recursive && $this->hasClass('unknown')) {
416
- if (!isset($cleaned_name)) $cleaned_name = Country::hardClean(Country::softClean($this->data['original']));
417
- switch ($cleaned_name) {
418
- case 'corse':
419
- $this->data = array(
420
- 'exclusion' => false,
421
- 'country_code' => 'FR',
422
- 'region_codes' => '2A,2B',
423
- 'original' => $this->data['original'],
424
- );
425
- $this->classes = array('replaced');
426
- $this->parse(false);
427
- break;
428
- case 'uk':
429
- $this->data = array(
430
- 'exclusion' => false,
431
- 'country_code' => 'GB',
432
- 'region_codes' => '',
433
- 'original' => $this->data['original'],
434
- );
435
- $this->classes = array('replaced');
436
- $this->parse(false);
437
- break;
438
- case 'union-europeenne':
439
- case 'ue':
440
- $this->createAddressFilterGroup(
441
- array('DE','AT','BE','BG','CY','DK','ES','EE','FI','FR','GR','HU','IE','IT','LV','LT','LU','MT','NL','PL','PT','CZ','RO','GB','SK','SI','SE'),
442
- $code = 'UE',
443
- $name = 'Union européenne'
444
- );
445
- break;
446
- case 'dom':
447
- $this->createAddressFilterGroup(
448
- array('GP','MQ','GF','RE'),
449
- $code = 'DOM',
450
- $name = "Département d'Outre-Mer"
451
- );
452
- break;
453
- case 'com':
454
- $this->createAddressFilterGroup(
455
- array('PF','PM','WF','YT','MF','BL'),
456
- $code = 'COM',
457
- $name = "Collectivités d'Outre-Mer"
458
- );
459
- break;
460
- case 'outre-mer':
461
- $this->createAddressFilterGroup(
462
- array('DOM','COM','NC','TF'),
463
- $code = "Outre-Mer",
464
- $name = "Outre-Mer"
465
- );
466
- break;
467
- }
468
- }
469
-
470
- if ($this->hasClass('known')) {
471
- if ($this->hasClass('replaced') || $this->hasClass('hard-cleaned')) $this->label = '<span class="bad">'.$this->data['original'].'</span> '.$this->name;
472
- else $this->label = $this->name;
473
- if (isset($this->data['region_codes']) && $this->data['region_codes']!='') {
474
- $this->label .= ' ('.$this->data['region_codes'].')';
475
- }
476
- } else {
477
- $this->label = $this->data['original'];
478
- }
479
- }
480
-
481
- public function createAddressFilterGroup($countries, $code, $name) {
482
- $this->address_filters_list = array();
483
- foreach ($countries as $country_code) {
484
- $this->address_filters_list[] = new AddressFilter(array('country_code' => $country_code, 'original' => $country_code));
485
- }
486
- $this->classes = array('known');
487
- $this->code = $code;
488
- $this->name = $name;
489
- }
490
-
491
- public function hasClass($class) {
492
- return in_array($class,$this->classes);
493
- }
494
-
495
- public function __toString() {
496
- $output = '';
497
- if (isset($this->address_filters_list)) {
498
- $compact_value = $this->code;
499
- $full_value = $this->name;
500
- $output .= '<span class="address-filter address-filter-group"'
501
- .' full-value="'.$full_value.'" compact-value="'.$compact_value.'" original-value="'.$this->data['original'].'"><span class="address-filter-group-label">'.$this->label.'</span>';
502
- foreach ($this->address_filters_list as $address_filter) {
503
- $output .= $address_filter;
504
- }
505
- $output .= '</span>';
506
- } else {
507
- if (isset($this->code)) {
508
- $compact_value = $this->code.(isset($this->data['region_codes']) && $this->data['region_codes']!='' ? '('.$this->data['region_codes'].')' : '');
509
- $full_value = $this->name.(isset($this->data['region_codes']) && $this->data['region_codes']!='' ? ' ('.$this->data['region_codes'].')' : '');
510
- } else {
511
- $compact_value = $this->data['original'];
512
- $full_value = $this->data['original'];
513
- }
514
- $output .= '<span class="address-filter country-'.$this->code.' '.implode(' ',$this->classes)
515
- .'" country-code="'.$this->code.'" full-value="'.$full_value.'" compact-value="'.$compact_value.'" original-value="'.$this->data['original'].'">'
516
- .$this->label.'</span>';
517
- }
518
- return $output;
519
- }
520
- }
521
-
522
-
523
  ?>
1
+ <?php
2
+
3
+
4
+ class Country
5
+ {
6
+ private static $LOADED = false;
7
+ private static $COUNTRIES = array(
8
+ 'code2name' => array(
9
+ 'AF' => 'Afghanistan',
10
+ 'ZA' => 'Afrique du Sud',
11
+ 'AX' => 'Åland',
12
+ 'AL' => 'Albanie',
13
+ 'DZ' => 'Algérie',
14
+ 'DE' => 'Allemagne',
15
+ 'AD' => 'Andorre',
16
+ 'AO' => 'Angola',
17
+ 'AI' => 'Anguilla',
18
+ 'AQ' => 'Antarctique',
19
+ 'AG' => 'Antigua-et-Barbuda',
20
+ 'AN' => 'Antilles néerlandaises',
21
+ 'SA' => 'Arabie saoudite',
22
+ 'AR' => 'Argentine',
23
+ 'AM' => 'Arménie',
24
+ 'AW' => 'Aruba',
25
+ 'AU' => 'Australie',
26
+ 'AT' => 'Autriche',
27
+ 'AZ' => 'Azerbaïdjan',
28
+ 'BS' => 'Bahamas',
29
+ 'BH' => 'Bahreïn',
30
+ 'BD' => 'Bangladesh',
31
+ 'BB' => 'Barbade',
32
+ 'BY' => 'Biélorussie',
33
+ 'BE' => 'Belgique',
34
+ 'BZ' => 'Belize',
35
+ 'BJ' => 'Bénin',
36
+ 'BM' => 'Bermudes',
37
+ 'BT' => 'Bhoutan',
38
+ 'BO' => 'Bolivie',
39
+ 'BA' => 'Bosnie-Herzégovine',
40
+ 'BW' => 'Botswana',
41
+ 'BV' => 'Île Bouvet',
42
+ 'BR' => 'Brésil',
43
+ 'BN' => 'Brunei',
44
+ 'BG' => 'Bulgarie',
45
+ 'BF' => 'Burkina Faso',
46
+ 'BI' => 'Burundi',
47
+ 'KY' => 'Îles Caïmans',
48
+ 'KH' => 'Cambodge',
49
+ 'CM' => 'Cameroun',
50
+ 'CA' => 'Canada',
51
+ 'CV' => 'Cap-Vert',
52
+ 'CF' => 'République centrafricaine',
53
+ 'CL' => 'Chili',
54
+ 'CN' => 'Chine',
55
+ 'CX' => 'Île Christmas',
56
+ 'CY' => 'Chypre',
57
+ 'CC' => 'Îles Cocos',
58
+ 'CO' => 'Colombie',
59
+ 'KM' => 'Comores',
60
+ 'CG' => 'Congo',
61
+ 'CD' => 'République démocratique du Congo',
62
+ 'CK' => 'Îles Cook',
63
+ 'KR' => 'Corée du Sud',
64
+ 'KP' => 'Corée du Nord',
65
+ 'CR' => 'Costa Rica',
66
+ 'CI' => "Côte d'Ivoire",
67
+ 'HR' => 'Croatie',
68
+ 'CU' => 'Cuba',
69
+ 'DK' => 'Danemark',
70
+ 'DJ' => 'Djibouti',
71
+ 'DO' => 'République dominicaine',
72
+ 'DM' => 'Dominique',
73
+ 'EG' => 'Égypte',
74
+ 'SV' => 'Salvador',
75
+ 'AE' => 'Émirats arabes unis',
76
+ 'EC' => 'Équateur',
77
+ 'ER' => 'Érythrée',
78
+ 'ES' => 'Espagne',
79
+ 'EE' => 'Estonie',
80
+ 'US' => 'États-Unis',
81
+ 'ET' => 'Éthiopie',
82
+ 'FK' => 'Îles Malouines',
83
+ 'FO' => 'Îles Féroé',
84
+ 'FJ' => 'Fidji',
85
+ 'FI' => 'Finlande',
86
+ 'FR' => 'France',
87
+ 'GA' => 'Gabon',
88
+ 'GM' => 'Gambie',
89
+ 'GE' => 'Géorgie',
90
+ 'GS' => 'Géorgie du Sud-et-les Îles Sandwich du Sud',
91
+ 'GH' => 'Ghana',
92
+ 'GI' => 'Gibraltar',
93
+ 'GR' => 'Grèce',
94
+ 'GD' => 'Grenade',
95
+ 'GL' => 'Groenland',
96
+ 'GP' => 'Guadeloupe',
97
+ 'GU' => 'Guam',
98
+ 'GT' => 'Guatemala',
99
+ 'GG' => 'Guernesey',
100
+ 'GN' => 'Guinée',
101
+ 'GW' => 'Guinée-Bissau',
102
+ 'GQ' => 'Guinée équatoriale',
103
+ 'GY' => 'Guyana',
104
+ 'GF' => 'Guyane Française',
105
+ 'HT' => 'Haïti',
106
+ 'HM' => 'Îles Heard-et-MacDonald',
107
+ 'HN' => 'Honduras',
108
+ 'HK' => 'Hong Kong',
109
+ 'HU' => 'Hongrie',
110
+ 'IM' => 'Île de Man',
111
+ 'UM' => 'Îles mineures éloignées des États-Unis',
112
+ 'VG' => 'Îles Vierges britanniques',
113
+ 'VI' => 'Îles Vierges américaines',
114
+ 'IN' => 'Inde',
115
+ 'ID' => 'Indonésie',
116
+ 'IR' => 'Iran',
117
+ 'IQ' => 'Irak',
118
+ 'IE' => 'Irlande',
119
+ 'IS' => 'Islande',
120
+ 'IL' => 'Israël',
121
+ 'IT' => 'Italie',
122
+ 'JM' => 'Jamaïque',
123
+ 'JP' => 'Japon',
124
+ 'JE' => 'Jersey',
125
+ 'JO' => 'Jordanie',
126
+ 'KZ' => 'Kazakhstan',
127
+ 'KE' => 'Kenya',
128
+ 'KG' => 'Kirghizistan',
129
+ 'KI' => 'Kiribati',
130
+ 'KW' => 'Koweït',
131
+ 'LA' => 'Laos',
132
+ 'LS' => 'Lesotho',
133
+ 'LV' => 'Lettonie',
134
+ 'LB' => 'Liban',
135
+ 'LR' => 'Libéria',
136
+ 'LY' => 'Libye',
137
+ 'LI' => 'Liechtenstein',
138
+ 'LT' => 'Lituanie',
139
+ 'LU' => 'Luxembourg',
140
+ 'MO' => 'Macao',
141
+ 'MK' => 'Macédoine',
142
+ 'MG' => 'Madagascar',
143
+ 'MY' => 'Malaisie',
144
+ 'MW' => 'Malawi',
145
+ 'MV' => 'Maldives',
146
+ 'ML' => 'Mali',
147
+ 'MT' => 'Malte',
148
+ 'MP' => 'Îles Mariannes du Nord',
149
+ 'MA' => 'Maroc',
150
+ 'MH' => 'Îles Marshall',
151
+ 'MQ' => 'Martinique',
152
+ 'MU' => 'Île Maurice',
153
+ 'MR' => 'Mauritanie',
154
+ 'YT' => 'Mayotte',
155
+ 'MX' => 'Mexique',
156
+ 'FM' => 'Micronésie',
157
+ 'MD' => 'Moldavie',
158
+ 'MC' => 'Monaco',
159
+ 'MN' => 'Mongolie',
160
+ 'ME' => 'Monténégro',
161
+ 'MS' => 'Montserrat',
162
+ 'MZ' => 'Mozambique',
163
+ 'MM' => 'Birmanie',
164
+ 'NA' => 'Namibie',
165
+ 'NR' => 'Nauru',
166
+ 'NP' => 'Népal',
167
+ 'NI' => 'Nicaragua',
168
+ 'NE' => 'Niger',
169
+ 'NG' => 'Nigéria',
170
+ 'NU' => 'Niué',
171
+ 'NF' => 'Île Norfolk',
172
+ 'NO' => 'Norvège',
173
+ 'NC' => 'Nouvelle-Calédonie',
174
+ 'NZ' => 'Nouvelle-Zélande',
175
+ 'IO' => "Territoire britannique de l'océan Indien",
176
+ 'OM' => 'Oman',
177
+ 'UG' => 'Ouganda',
178
+ 'UZ' => 'Ouzbékistan',
179
+ 'PK' => 'Pakistan',
180
+ 'PW' => 'Palaos',
181
+ 'PS' => 'Palestine',
182
+ 'PA' => 'Panamá',
183
+ 'PG' => 'Papouasie-Nouvelle-Guinée',
184
+ 'PY' => 'Paraguay',
185
+ 'NL' => 'Pays-Bas',
186
+ 'PE' => 'Pérou',
187
+ 'PH' => 'Philippines',
188
+ 'PN' => 'Îles Pitcairn',
189
+ 'PL' => 'Pologne',
190
+ 'PF' => 'Polynésie Française',
191
+ 'PR' => 'Porto Rico',
192
+ 'PT' => 'Portugal',
193
+ 'QA' => 'Qatar',
194
+ 'RE' => 'La Réunion',
195
+ 'RO' => 'Roumanie',
196
+ 'GB' => 'Royaume-Uni',
197
+ 'RU' => 'Russie',
198
+ 'RW' => 'Rwanda',
199
+ 'EH' => 'Sahara occidental',
200
+ 'BL' => 'Saint-Barthélemy',
201
+ 'KN' => 'Saint-Christophe-et-Niévès',
202
+ 'SM' => 'Saint-Marin',
203
+ 'MF' => 'Saint-Martin',
204
+ 'PM' => 'Saint-Pierre-et-Miquelon',
205
+ 'VA' => 'Vatican',
206
+ 'VC' => 'Saint-Vincent-et-les Grenadines',
207
+ 'SH' => 'Sainte-Hélène',
208
+ 'LC' => 'Sainte-Lucie',
209
+ 'SB' => 'Îles Salomon',
210
+ 'WS' => 'Samoa',
211
+ 'AS' => 'Samoa américaines',
212
+ 'ST' => 'São Tomé-et-Principe',
213
+ 'SN' => 'Sénégal',
214
+ 'RS' => 'Serbie',
215
+ 'SC' => 'Seychelles',
216
+ 'SL' => 'Sierra Leone',
217
+ 'SG' => 'Singapour',
218
+ 'SK' => 'Slovaquie',
219
+ 'SI' => 'Slovénie',
220
+ 'SO' => 'Somalie',
221
+ 'SD' => 'Soudan',
222
+ 'LK' => 'Sri Lanka',
223
+ 'SE' => 'Suède',
224
+ 'CH' => 'Suisse',
225
+ 'SR' => 'Suriname',
226
+ 'SJ' => 'Svalbard et île Jan Mayen',
227
+ 'SZ' => 'Swaziland',
228
+ 'SY' => 'Syrie',
229
+ 'TJ' => 'Tadjikistan',
230
+ 'TW' => 'Taïwan',
231
+ 'TZ' => 'Tanzanie',
232
+ 'TD' => 'Tchad',
233
+ 'CZ' => 'République tchèque',
234
+ 'TF' => 'Terres Australes et Antarctiques Françaises',
235
+ 'TH' => 'Thaïlande',
236
+ 'TL' => 'Timor oriental',
237
+ 'TG' => 'Togo',
238
+ 'TK' => 'Tokelau',
239
+ 'TO' => 'Tonga',
240
+ 'TT' => 'Trinité-et-Tobago',
241
+ 'TN' => 'Tunisie',
242
+ 'TM' => 'Turkménistan',
243
+ 'TC' => 'Îles Turques-et-Caïques',
244
+ 'TR' => 'Turquie',
245
+ 'TV' => 'Tuvalu',
246
+ 'UA' => 'Ukraine',
247
+ 'UY' => 'Uruguay',
248
+ 'VU' => 'Vanuatu',
249
+ 'VE' => 'Venezuela',
250
+ 'VN' => 'Viêt Nam',
251
+ 'WF' => 'Wallis-et-Futuna',
252
+ 'YE' => 'Yémen',
253
+ 'ZM' => 'Zambie',
254
+ 'ZW' => 'Zimbabwe',
255
+ ),
256
+ 'code2soft-cleaned-name' => null,
257
+ 'code2hard-cleaned-name' => null,
258
+ 'replacement' => array(
259
+ 'reunion' => 'RE',
260
+ 'france-metropolitaine' => 'FR',
261
+ 'guyane' => 'GF',
262
+ 'taaf' => 'TF',
263
+ 'terres-australes-francaises' => 'TF',
264
+ 'usa' => 'US',
265
+ 'hollande' => 'NL',
266
+ 'grande-bretagne' => 'GB',
267
+ 'vietnam' => 'VN',
268
+ 'belarus' => 'BY',
269
+ 'brunei-darussalam' => 'BN',
270
+ 'cayman' => 'KY',
271
+ 'caiman' => 'KY',
272
+ 'caimanes' => 'KY',
273
+ 'cocos-keeling' => 'CC',
274
+ 'keeling' => 'CC',
275
+ 'centrafrique' => 'CF',
276
+ 'congo-brazzaville' => 'CG',
277
+ 'congo-kinshasa' => 'CD',
278
+ 'zaire' => 'CD',
279
+ 'san-marin' => 'SM',
280
+ 'surinam' => 'SR',
281
+ 'myanmar' => 'MM',
282
+ 'saint-christophe-nevis' => 'KN',
283
+ 'saint-kitts-nevis' => 'KN',
284
+ 'falkland' => 'FK',
285
+ 'el-salvador' => 'SV',
286
+ 'lithuanie' => 'LT',
287
+ 'turks-caiques' => 'TC',
288
+ 'vierges-des-etats-unis' => 'VI',
289
+ 'etat-de-la-cite-du-vatican' => 'VA',
290
+ 'etats-federes-de-micronesie' => 'FM',
291
+ 'r-a-s-chinoise-de-hong-kong' => 'HK',
292
+ 'r-a-s-chinoise-de-macao' => 'MO',
293
+ ),
294
+ );
295
+
296
+ public static function loadCache() {
297
+ $filename = 'cache/countries';
298
+ if (!file_exists($filename)) {
299
+ self::$COUNTRIES['code2soft-cleaned-name'] = array();
300
+ self::$COUNTRIES['code2hard-cleaned-name'] = array();
301
+ foreach (self::$COUNTRIES['code2name'] as $_code => $_name) {
302
+ $soft_cleaned = self::softClean($_name);
303
+ self::$COUNTRIES['code2soft-cleaned-name'][$_code] = $soft_cleaned;
304
+ self::$COUNTRIES['code2hard-cleaned-name'][$_code] = self::hardClean($soft_cleaned);
305
+ }
306
+ file_put_contents('cache/countries',serialize(self::$COUNTRIES));
307
+ } else {
308
+ self::$COUNTRIES = unserialize(file_get_contents('cache/countries'));
309
+ }
310
+ }
311
+
312
+ public static function getCountryNameByCode($code) {
313
+ return isset(self::$COUNTRIES['code2name'][$code]) ? self::$COUNTRIES['code2name'][$code] : null;
314
+ }
315
+
316
+ public static function getCountryCodeByName($name, $name_type=null) {
317
+ $suffix = isset($name_type) ? $name_type.'-' : '';
318
+ if (!self::$LOADED) self::loadCache();
319
+ $code = array_search($name, self::$COUNTRIES['code2'.$suffix.'name']);
320
+ return $code!==false ? $code : null;
321
+ }
322
+
323
+ public static function getCountryCodeByReplacedName($cleaned_name) {
324
+ if (isset(self::$COUNTRIES['replacement'][$cleaned_name])) return self::$COUNTRIES['replacement'][$cleaned_name];
325
+ return null;
326
+ }
327
+
328
+ public static function softClean($input) {
329
+ $input = mb_strtolower($input,'UTF-8');
330
+ $input = preg_replace('/[ -\.]+/','-',trim($input));
331
+ //echo '"'.$input.'" => ';
332
+ $input = str_replace(
333
+ array(' ','ç','é','è','ê','ë','à','á','â','ä','ã','å','ô','ö','ù','û','ü','î','ï','ÿ'),
334
+ array('-','c','e','e','e','e','a','a','a','a','a','a','o','o','u','u','u','i','i','y'),
335
+ $input
336
+ );
337
+ //echo '"'.$input.'", ';
338
+ $input = preg_replace("/^st-/",'saint-',$input);
339
+ $input = preg_replace("/^ste-/",'sainte-',$input);
340
+ $input = preg_replace("/-&-/",'-et-',$input);
341
+ return $input;
342
+ }
343
+
344
+ public static function hardClean($input) {
345
+ //$output = preg_match('/ivoire/',$input);
346
+ //if ($output) echo '"'.$input.'" => ';
347
+ $input = preg_replace("/^(?:les|le|la|l'|ile|iles)-/",'',$input);
348
+ $input = preg_replace("/-(?:ile|iles)$/",'',$input);
349
+ $input = preg_replace("/-(?:(?:et|les)-)+/",'-',$input);
350
+ $input = preg_replace("/(?:[^a-z0-9]+)/",'-',$input);
351
+ //if ($output) echo '"'.$input.'",<br/>';
352
+ return $input;
353
+ }
354
+
355
+ }
356
+
357
+ class AddressFilter extends Country
358
+ {
359
+ private $data;
360
+ private $code;
361
+ private $name;
362
+ private $classes;
363
+ private $label;
364
+ private $arranged;
365
+ private $address_filters_list;
366
+
367
+ public function AddressFilter($data) {
368
+ $input = trim($input);
369
+ $this->data = $data;
370
+ $this->classes = array();
371
+ $this->address_filters_list = null;
372
+ $this->parse();
373
+ }
374
+
375
+ public function parse($recursive=true) {
376
+ if (strlen($this->data['country_code'])==2) {
377
+ $code = strtoupper($this->data['country_code']);
378
+ $name = Country::getCountryNameByCode($code);
379
+
380
+ if (isset($name)) {
381
+ $this->code = $code;
382
+ $this->name = $name;
383
+ $this->classes[] = 'known';
384
+ }
385
+ }
386
+ if (!isset($this->name)) {
387
+ $code = Country::getCountryCodeByName($this->data['country_code']);
388
+ if (!isset($code)) {
389
+ $this->classes[] = 'soft-cleaned';
390
+ $cleaned_name = Country::softClean($this->data['country_code']);
391
+ $code = Country::getCountryCodeByName($cleaned_name,'soft-cleaned');
392
+ }
393
+ if (!isset($code)) {
394
+ $this->classes[] = 'replaced';
395
+ $code = Country::getCountryCodeByReplacedName($cleaned_name);
396
+ }
397
+ if (!isset($code)) {
398
+ $this->classes[] = 'hard-cleaned';
399
+ $cleaned_name = Country::hardClean($cleaned_name);
400
+ $code = Country::getCountryCodeByName($cleaned_name,'hard-cleaned');
401
+ }
402
+ if (!isset($code)) {
403
+ $this->classes[] = 'replaced';
404
+ $code = Country::getCountryCodeByReplacedName($cleaned_name);
405
+ }
406
+ if (isset($code)) {
407
+ $this->code = $code;
408
+ $this->name = Country::getCountryNameByCode($code);
409
+ $this->classes[] = 'known';
410
+ } else {
411
+ $this->classes[] = 'unknown';
412
+ }
413
+ }
414
+
415
+ if ($recursive && $this->hasClass('unknown')) {
416
+ if (!isset($cleaned_name)) $cleaned_name = Country::hardClean(Country::softClean($this->data['original']));
417
+ switch ($cleaned_name) {
418
+ case 'corse':
419
+ $this->data = array(
420
+ 'exclusion' => false,
421
+ 'country_code' => 'FR',
422
+ 'region_codes' => '2A,2B',
423
+ 'original' => $this->data['original'],
424
+ );
425
+ $this->classes = array('replaced');
426
+ $this->parse(false);
427
+ break;
428
+ case 'uk':
429
+ $this->data = array(
430
+ 'exclusion' => false,
431
+ 'country_code' => 'GB',
432
+ 'region_codes' => '',
433
+ 'original' => $this->data['original'],
434
+ );
435
+ $this->classes = array('replaced');
436
+ $this->parse(false);
437
+ break;
438
+ case 'union-europeenne':
439
+ case 'ue':
440
+ $this->createAddressFilterGroup(
441
+ array('DE','AT','BE','BG','CY','DK','ES','EE','FI','FR','GR','HU','IE','IT','LV','LT','LU','MT','NL','PL','PT','CZ','RO','GB','SK','SI','SE'),
442
+ $code = 'UE',
443
+ $name = 'Union européenne'
444
+ );
445
+ break;
446
+ case 'dom':
447
+ $this->createAddressFilterGroup(
448
+ array('GP','MQ','GF','RE'),
449
+ $code = 'DOM',
450
+ $name = "Département d'Outre-Mer"
451
+ );
452
+ break;
453
+ case 'com':
454
+ $this->createAddressFilterGroup(
455
+ array('PF','PM','WF','YT','MF','BL'),
456
+ $code = 'COM',
457
+ $name = "Collectivités d'Outre-Mer"
458
+ );
459
+ break;
460
+ case 'outre-mer':
461
+ $this->createAddressFilterGroup(
462
+ array('DOM','COM','NC','TF'),
463
+ $code = "Outre-Mer",
464
+ $name = "Outre-Mer"
465
+ );
466
+ break;
467
+ }
468
+ }
469
+
470
+ if ($this->hasClass('known')) {
471
+ if ($this->hasClass('replaced') || $this->hasClass('hard-cleaned')) $this->label = '<span class="bad">'.$this->data['original'].'</span> '.$this->name;
472
+ else $this->label = $this->name;
473
+ if (isset($this->data['region_codes']) && $this->data['region_codes']!='') {
474
+ $this->label .= ' ('.$this->data['region_codes'].')';
475
+ }
476
+ } else {
477
+ $this->label = $this->data['original'];
478
+ }
479
+ }
480
+
481
+ public function createAddressFilterGroup($countries, $code, $name) {
482
+ $this->address_filters_list = array();
483
+ foreach ($countries as $country_code) {
484
+ $this->address_filters_list[] = new AddressFilter(array('country_code' => $country_code, 'original' => $country_code));
485
+ }
486
+ $this->classes = array('known');
487
+ $this->code = $code;
488
+ $this->name = $name;
489
+ }
490
+
491
+ public function hasClass($class) {
492
+ return in_array($class,$this->classes);
493
+ }
494
+
495
+ public function __toString() {
496
+ $output = '';
497
+ if (isset($this->address_filters_list)) {
498
+ $compact_value = $this->code;
499
+ $full_value = $this->name;
500
+ $output .= '<span class="address-filter address-filter-group"'
501
+ .' full-value="'.$full_value.'" compact-value="'.$compact_value.'" original-value="'.$this->data['original'].'"><span class="address-filter-group-label">'.$this->label.'</span>';
502
+ foreach ($this->address_filters_list as $address_filter) {
503
+ $output .= $address_filter;
504
+ }
505
+ $output .= '</span>';
506
+ } else {
507
+ if (isset($this->code)) {
508
+ $compact_value = $this->code.(isset($this->data['region_codes']) && $this->data['region_codes']!='' ? '('.$this->data['region_codes'].')' : '');
509
+ $full_value = $this->name.(isset($this->data['region_codes']) && $this->data['region_codes']!='' ? ' ('.$this->data['region_codes'].')' : '');
510
+ } else {
511
+ $compact_value = $this->data['original'];
512
+ $full_value = $this->data['original'];
513
+ }
514
+ $output .= '<span class="address-filter country-'.$this->code.' '.implode(' ',$this->classes)
515
+ .'" country-code="'.$this->code.'" full-value="'.$full_value.'" compact-value="'.$compact_value.'" original-value="'.$this->data['original'].'">'
516
+ .$this->label.'</span>';
517
+ }
518
+ return $output;
519
+ }
520
+ }
521
+
522
+
523
  ?>
app/design/adminhtml/default/default/template/chronorelais/bordereau/grid.phtml ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Template for Mage_Adminhtml_Block_Widget_Grid
30
+ *
31
+ * getId()
32
+ * getCollection()
33
+ * getColumns()
34
+ * getPagerVisibility()
35
+ * getVarNamePage()
36
+ */
37
+ $numColumns = sizeof($this->getColumns());
38
+ ?>
39
+ <?php if($this->getCollection()): ?>
40
+ <?php if($this->canDisplayContainer()): ?>
41
+ <?php if($this->getGridHeader()): ?>
42
+ <div class="content-header">
43
+ <table cellspacing="0">
44
+ <tr>
45
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
46
+ </tr>
47
+ </table>
48
+ </div>
49
+ <?php endif ?>
50
+
51
+ <div id="<?php echo $this->getId() ?>">
52
+ <?php else: ?>
53
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
54
+ <?php endif; ?>
55
+ <?php if($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
56
+ <table cellspacing="0" class="actions">
57
+ <tr>
58
+ <?php if($this->getPagerVisibility()): ?>
59
+ <td class="pager">
60
+ <?php echo $this->__('Page') ?>
61
+
62
+ <?php $_curPage = $this->getCollection()->getCurPage() ?>
63
+ <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
64
+ <?php if($_curPage>1): ?>
65
+ <a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage-1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
66
+ <?php else: ?>
67
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
68
+ <?php endif; ?>
69
+
70
+ <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
71
+
72
+ <?php if($_curPage < $_lastPage): ?>
73
+ <a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage+1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
74
+ <?php else: ?>
75
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
76
+ <?php endif; ?>
77
+
78
+ <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
79
+ <span class="separator">|</span>
80
+ <?php echo $this->__('View') ?>
81
+ <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
82
+ <option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
83
+ <option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
84
+ <option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
85
+ <option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
86
+ <option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
87
+ </select>
88
+ <?php echo $this->__('per page') ?><span class="separator">|</span>
89
+ <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
90
+ <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
91
+ <?php if($this->getRssLists()): ?>
92
+ <?php foreach ($this->getRssLists() as $_rss): ?>
93
+ <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
94
+ <?php endforeach ?>
95
+ <?php endif; ?>
96
+ </td>
97
+ <?php endif ?>
98
+ <?php if($this->getExportTypes()): ?>
99
+ <td class="export a-right">
100
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
101
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
102
+ <?php foreach ($this->getExportTypes() as $_type): ?>
103
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
104
+ <?php endforeach; ?>
105
+ </select>
106
+ <?php echo $this->getExportButtonHtml() ?>
107
+ </td>
108
+ <?php endif; ?>
109
+ <td style="width:500px;"><?php echo $this->__('N\'oubliez pas d\'imprimer le bordereau de remise en deux exemplaires, un doit être remis lors de l\'enlèvement ou du dépôt ; l\'autre est à conserver. Les deux doivent être signés.') ?></td>
110
+ <td class="filter-actions a-right">
111
+ <?php echo $this->getMainButtonsHtml() ?>
112
+ </td>
113
+ </tr>
114
+ </table>
115
+ <?php endif; ?>
116
+ <?php if($this->getMassactionBlock()->isAvailable()): ?>
117
+ <?php echo $this->getMassactionBlockHtml() ?>
118
+ <?php endif ?>
119
+ <div class="grid">
120
+ <div class="hor-scroll">
121
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
122
+ <?php foreach ($this->getColumns() as $_column): ?>
123
+ <col <?php echo $_column->getHtmlProperty() ?> />
124
+ <?php endforeach; ?>
125
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
126
+ <thead>
127
+ <?php if ($this->getHeadersVisibility()): ?>
128
+ <tr class="headings">
129
+ <?php foreach ($this->getColumns() as $_column): ?>
130
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
131
+ <?php endforeach; ?>
132
+ </tr>
133
+ <?php endif; ?>
134
+ <?php if ($this->getFilterVisibility()): ?>
135
+ <tr class="filter">
136
+ <?php $i=0;foreach ($this->getColumns() as $_column): ?>
137
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
138
+ <?php endforeach; ?>
139
+ </tr>
140
+ <?php endif ?>
141
+ </thead>
142
+ <?php endif; ?>
143
+ <?php if ($this->getCountTotals()): ?>
144
+ <tfoot>
145
+ <tr class="totals">
146
+ <?php foreach ($this->getColumns() as $_column): ?>
147
+ <th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?>&nbsp;</th>
148
+ <?php endforeach; ?>
149
+ </tr>
150
+ </tfoot>
151
+ <?php endif; ?>
152
+
153
+ <tbody>
154
+ <?php if (($this->getCollection()->getSize()>0) && (!$this->getIsCollapsed())): ?>
155
+ <?php foreach ($this->getCollection() as $_index=>$_item): ?>
156
+ <tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)):?> class="<?php echo $_class; ?>"<?php endif;?> >
157
+ <?php $i=0;foreach ($this->getColumns() as $_column): ?>
158
+
159
+ <?php if ($this->shouldRenderCell($_item, $_column)):?>
160
+ <?php $_rowspan = $this->getRowspan($_item, $_column);?>
161
+ <td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns?'last':'' ?>">
162
+ <?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
163
+ </td>
164
+ <?php if ($this->shouldRenderEmptyCell($_item, $_column)):?>
165
+ <td colspan="<?php echo $this->getEmptyCellColspan($_item)?>" class="last"><?php echo $this->getEmptyCellLabel()?></td>
166
+ <?php endif;?>
167
+ <?php endif;?>
168
+
169
+ <?php endforeach; ?>
170
+ </tr>
171
+ <?php if ($_multipleRows = $this->getMultipleRows($_item)):?>
172
+ <?php foreach ($_multipleRows as $_i):?>
173
+ <tr>
174
+ <?php $i=0;foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
175
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns-1?'last':'' ?>">
176
+ <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
177
+ </td>
178
+ <?php endforeach; ?>
179
+ </tr>
180
+ <?php endforeach;?>
181
+ <?php endif;?>
182
+
183
+ <?php if ($this->shouldRenderSubTotal($_item)): ?>
184
+ <tr class="subtotals">
185
+ <?php $i = 0; foreach ($this->getSubTotalColumns() as $_column): ?>
186
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i == $numColumns ? 'last' : '' ?>">
187
+ <?php echo ($_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel() :
188
+ $_column->getRowField($this->getSubTotalItem($_item))
189
+ );
190
+ ?>
191
+ </td>
192
+ <?php endforeach; ?>
193
+ </tr>
194
+ <?php endif; ?>
195
+ <?php endforeach; ?>
196
+ <?php elseif ($this->getEmptyText()): ?>
197
+ <tr>
198
+ <td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="<?php echo $numColumns ?>"><?php echo $this->getEmptyText() ?></td>
199
+ </tr>
200
+ <?php endif; ?>
201
+ </tbody>
202
+
203
+ </table>
204
+ </div>
205
+ </div>
206
+ <?php if($this->canDisplayContainer()): ?>
207
+ </div>
208
+ <script type="text/javascript">
209
+ //<![CDATA[
210
+ <?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
211
+ <?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
212
+ <?php if($this->getRowClickCallback()): ?>
213
+ <?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
214
+ <?php endif; ?>
215
+ <?php if($this->getCheckboxCheckCallback()): ?>
216
+ <?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
217
+ <?php endif; ?>
218
+ <?php if($this->getRowInitCallback()): ?>
219
+ <?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
220
+ <?php echo $this->getJsObjectName() ?>.initGridRows();
221
+ <?php endif; ?>
222
+ <?php if($this->getMassactionBlock()->isAvailable()): ?>
223
+ <?php echo $this->getMassactionBlock()->getJavaScript() ?>
224
+ <?php endif ?>
225
+ <?php echo $this->getAdditionalJavaScript(); ?>
226
+ //]]>
227
+ </script>
228
+ <?php endif; ?>
229
+ <?php endif ?>
app/design/adminhtml/default/default/template/chronorelais/config/checklogin.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @see Chronopost_Chronorelais_Block_Adminhtml_Config_Checklogin
4
+ */
5
+ ?>
6
+ <script type="text/javascript">
7
+ //<![CDATA[
8
+ function checkLogin() {
9
+ var elem = $('<?php echo $this->getHtmlId() ?>');
10
+
11
+ params = {
12
+ account_number: $('chronorelais_shipping_account_number').value,
13
+ sub_account_number: $('chronorelais_shipping_sub_account_number').value,
14
+ account_pass: $('chronorelais_shipping_account_pass').value
15
+ };
16
+
17
+
18
+ new Ajax.Request('<?php echo $this->getAjaxUrl() ?>', {
19
+ parameters: params,
20
+ onSuccess: function(data) {
21
+ var response = data.responseText.evalJSON();
22
+ response = response.return;
23
+ var msg = '<strong style="color:#007700;">Identification réussie.</strong>';
24
+ if(response.errorCode == undefined) {
25
+ msg = '<strong>Le webservice est momentanément inaccessible. Veuillez réessayer plus tard.</strong>';
26
+ }
27
+ else if(response.errorCode != 0)
28
+ {
29
+ msg = '<strong style="color:#FF0000;">Les identifiants que vous avez renseignés ne sont pas valides.</strong>'
30
+ }
31
+ $('validation_result').update(msg);
32
+ }
33
+ });
34
+ }
35
+ //]]>
36
+ </script>
37
+ <button onclick="javascript:checkLogin(); return false;" class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>">
38
+ <span><?php echo $this->escapeHtml($this->getButtonLabel()) ?></span>
39
+ </button>
40
+ <div id="validation_result"></div>
app/design/adminhtml/default/default/template/chronorelais/notification.phtml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @see Chronopost_Chronorelais_Block_Adminhtml_Notification
4
+ */
5
+ ?>
6
+ <?php if ($this->canShow()): ?>
7
+ <script type="text/javascript">
8
+ //<![CDATA[
9
+ var messagePopupClosed = false;
10
+ function openMessagePopup() {
11
+ var height = $('html-body').getHeight();
12
+ $('message-popup-window-mask').setStyle({'height':height+'px'});
13
+ toggleSelectsUnderBlock($('message-popup-window-mask'), false);
14
+ Element.show('message-popup-window-mask');
15
+ $('message-popup-window').addClassName('show');
16
+ }
17
+
18
+ function closeMessagePopup() {
19
+ toggleSelectsUnderBlock($('message-popup-window-mask'), true);
20
+ Element.hide('message-popup-window-mask');
21
+ $('message-popup-window').removeClassName('show');
22
+ messagePopupClosed = true;
23
+ }
24
+
25
+ Event.observe(window, 'load', openMessagePopup);
26
+ Event.observe(window, 'keyup', function(evt) {
27
+ if(messagePopupClosed) return;
28
+ var code;
29
+ if (evt.keyCode) code = evt.keyCode;
30
+ else if (evt.which) code = evt.which;
31
+ if (code == Event.KEY_ESC) {
32
+ closeMessagePopup();
33
+ }
34
+ });
35
+ //]]>
36
+ </script>
37
+ <div id="message-popup-window-mask" style="display:none;"></div>
38
+ <div id="message-popup-window" class="message-popup">
39
+ <div class="message-popup-head">
40
+ <a href="#" onclick="closeMessagePopup(); return false;" title="Close"><span><?php echo $this->__('close'); ?></span></a>
41
+ <h2>Chronopost vous informe :</h2>
42
+ </div>
43
+ <div class="message-popup-content">
44
+ <div class="message">
45
+ <span class="message-icon message-notice" style="background-image:url(<?php echo $this->getSeverityIconsUrl() ?>);">Notice</span>
46
+ <p class="message-text">
47
+ Le quickcost est momentanément indisponible, les prix renseignés dans la grille tarifaire sont appliqués.
48
+ <br />
49
+ Veuillez les vérifier.
50
+ </p>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ <?php endif; ?>
app/design/adminhtml/default/default/template/chronorelais/sales/order/view/tab/info.phtml ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php /** @var $this Mage_Adminhtml_Block_Sales_Order_View_Tab_Info */ ?>
28
+ <?php $_order = $this->getOrder() ?>
29
+ <div>
30
+ <div id="order-messages">
31
+ <?php echo $this->getChildHtml('order_messages') ?>
32
+ </div>
33
+ <?php echo $this->getChildHtml('order_info') ?>
34
+ <input type="hidden" name="order_id" value="<?php echo $_order->getId() ?>"/>
35
+ <?php if ($_order->getIsVirtual()): ?>
36
+ <div class="box-right">
37
+ <?php else: ?>
38
+ <div class="box-left">
39
+ <?php endif; ?>
40
+ <!--Payment Method-->
41
+ <div class="entry-edit">
42
+ <div class="entry-edit-head">
43
+ <h4 class="icon-head head-payment-method"><?php echo Mage::helper('sales')->__('Payment Information') ?></h4>
44
+ </div>
45
+ <fieldset>
46
+ <?php echo $this->getPaymentHtml() ?>
47
+ <div><?php echo Mage::helper('sales')->__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?></div>
48
+ </fieldset>
49
+ </div>
50
+ </div>
51
+ <?php if (!$_order->getIsVirtual()): ?>
52
+ <div class="box-right">
53
+ <!--Shipping Method-->
54
+ <div class="entry-edit">
55
+ <div class="entry-edit-head">
56
+ <h4 class="icon-head head-shipping-method"><?php echo Mage::helper('sales')->__('Shipping &amp; Handling Information') ?></h4>
57
+ </div>
58
+ <fieldset>
59
+ <?php if ($_order->getTracksCollection()->count()) : ?>
60
+ <a href="#" id="linkId" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')" title="<?php echo $this->__('Track Order') ?>"><?php echo $this->__('Track Order') ?></a>
61
+ <br/>
62
+ <?php endif; ?>
63
+ <?php if ($_order->getShippingDescription()): ?>
64
+ <strong><?php echo $this->escapeHtml($_order->getShippingDescription()) ?></strong>
65
+
66
+ <?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?>
67
+ <?php $_excl = $this->displayShippingPriceInclTax($_order); ?>
68
+ <?php else: ?>
69
+ <?php $_excl = $this->displayPriceAttribute('shipping_amount', false, ' '); ?>
70
+ <?php endif; ?>
71
+ <?php $_incl = $this->displayShippingPriceInclTax($_order); ?>
72
+
73
+ <?php echo $_excl; ?>
74
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
75
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
76
+ <?php endif; ?>
77
+ <?php else: ?>
78
+ <?php echo $this->helper('sales')->__('No shipping information available'); ?>
79
+ <?php endif; ?>
80
+ <?php
81
+ $helper = Mage::helper('chronorelais');
82
+ /* Option BAL */
83
+ if($helper->hasOptionBAL($this->getOrder())) {
84
+ echo '<p><strong>Option BAL</strong></p>';
85
+ }
86
+
87
+ /* Assurance Ad Valorem */
88
+ if($helper->assuranceAdValoremEnabled())
89
+ {
90
+ $minAmount = $helper->assuranceAdValoremAmount();
91
+ $maxAmount = $helper->getMaxAdValoremAmount();
92
+
93
+ $items = $_order->getAllItems();
94
+
95
+ $totalAdValorem = 0;
96
+
97
+ foreach($items as $item) {
98
+ $totalAdValorem += $item->getPrice() * $item->getQtyOrdered();
99
+ }
100
+ $totalAdValorem = min($totalAdValorem,$maxAmount);
101
+ /* Si montant < au montant minimum ad valorem => pas d'assurance */
102
+ if($totalAdValorem < $minAmount) $totalAdValorem = 0;
103
+
104
+ if($totalAdValorem > 0) {
105
+ echo '<p><strong>Assurance Ad Valorem</strong></p>';
106
+ echo $_order->formatPrice($totalAdValorem);
107
+ }
108
+ }
109
+ ?>
110
+ </fieldset>
111
+ </div>
112
+ </div>
113
+ <?php endif; ?>
114
+ <div class="clear"></div>
115
+ <?php echo $this->getGiftOptionsHtml() ?>
116
+ <div class="clear"></div>
117
+ <div class="entry-edit">
118
+ <div class="entry-edit-head">
119
+ <h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('Items Ordered') ?></h4>
120
+ </div>
121
+ </div>
122
+ <?php echo $this->getItemsHtml() ?>
123
+ <div class="clear"></div>
124
+
125
+ <div class="box-left">
126
+ <div class="entry-edit">
127
+ <div class="entry-edit-head">
128
+ <h4><?php echo Mage::helper('sales')->__('Comments History') ?></h4>
129
+ </div>
130
+ <fieldset><?php echo $this->getChildHtml('order_history') ?></fieldset>
131
+ </div>
132
+ </div>
133
+ <div class="box-right entry-edit">
134
+ <div class="entry-edit-head"><h4><?php echo Mage::helper('sales')->__('Order Totals') ?></h4></div>
135
+ <div class="order-totals"><?php echo $this->getChildHtml('order_totals') ?></div>
136
+ </div>
137
+ <div class="clear"></div>
138
+ </div>
139
+
140
+ <?php echo $this->getChildHtml('popup_window');?>
141
+ <script type="text/javascript">
142
+ //<![CDATA[
143
+ /**
144
+ * Retrieve gift options tooltip content
145
+ */
146
+ function getGiftOptionsTooltipContent(itemId) {
147
+ var contentLines = [];
148
+ var headerLine = null;
149
+ var contentLine = null;
150
+
151
+ $$('#gift_options_data_' + itemId + ' .gift-options-tooltip-content').each(function (element) {
152
+ if (element.down(0)) {
153
+ headerLine = element.down(0).innerHTML;
154
+ contentLine = element.down(0).next().innerHTML;
155
+ if (contentLine.length > 30) {
156
+ contentLine = contentLine.slice(0,30) + '...';
157
+ }
158
+ contentLines.push(headerLine + ' ' + contentLine);
159
+ }
160
+ });
161
+ return contentLines.join('<br/>');
162
+ }
163
+ giftOptionsTooltip.setTooltipContentLoaderFunction(getGiftOptionsTooltipContent);
164
+ //]]>
165
+ </script>
app/design/frontend/default/default/layout/chronorelais.xml CHANGED
@@ -1,60 +1,60 @@
1
- <?xml version="1.0"?>
2
- <layout version="0.1.0">
3
- <default>
4
- <reference name="head">
5
- <action method="addItem"><type>skin_css</type><name>chronorelais/chronorelais.css</name></action>
6
- </reference>
7
- </default>
8
-
9
- <checkout_onepage_index>
10
- <reference name="checkout.onepage.shipping_method">
11
- <action method="setTemplate"><template>chronorelais/checkout/onepage/shipping_method.phtml</template></action>
12
- <block type="checkout/onepage_shipping_method_available" name="checkout.onepage.shipping_method.available" as="available" template="chronorelais/checkout/onepage/shipping_method/available.phtml">
13
- <block type="chronorelais/checkout_onepage_shipping_method_chronorelais" name="checkout.onepage.shipping_method.chronorelais" as="relaislist" template="chronorelais/checkout/onepage/shipping_method/chronorelais.phtml"/>
14
- </block>
15
- </reference>
16
- </checkout_onepage_index>
17
-
18
- <!-- -->
19
- <checkout_multishipping_shipping>
20
- <update handle="checkout_multishipping"/>
21
- <reference name="checkout_shipping">
22
- <action method="setTemplate"><template>chronorelais/checkout/multishipping/shipping.phtml</template></action>
23
- <block type="chronorelais/checkout_multishipping_shipping_method_chronorelais" name="checkout.multishipping.shipping_method.chronorelais" as="relaislist" template="chronorelais/checkout/multishipping/shipping_method/chronorelais.phtml"/>
24
- </reference>
25
- </checkout_multishipping_shipping>
26
- <!-- -->
27
-
28
- <checkout_onepage_shippingmethod>
29
- <remove name="right"/>
30
- <remove name="left"/>
31
- <block type="checkout/onepage_shipping_method_available" name="root" output="toHtml" template="chronorelais/checkout/onepage/shipping_method/available.phtml">
32
- <!--<block type="checkout/onepage_shipping_method_chronorelais" name="checkout.onepage.shipping_method.chronorelais" as="relaislist" template="chronorelais/checkout/onepage/shipping_method/chronorelais.phtml"/>-->
33
- </block>
34
- </checkout_onepage_shippingmethod>
35
-
36
- <checkout_onepage_shippingchronorelais>
37
- <remove name="right"/>
38
- <remove name="left"/>
39
- <block type="chronorelais/checkout_onepage_shipping_method_chronorelais" name="root" output="toHtml" template="chronorelais/checkout/onepage/shipping_method/chronorelais.phtml"/>
40
- </checkout_onepage_shippingchronorelais>
41
-
42
- <checkout_multishipping_shippingchronorelais>
43
- <remove name="right"/>
44
- <remove name="left"/>
45
- <block type="chronorelais/checkout_multishipping_shipping_method_chronorelais" name="root" output="toHtml" template="chronorelais/checkout/multishipping/shipping_method/chronorelais.phtml"/>
46
- </checkout_multishipping_shippingchronorelais>
47
-
48
- <customer_account_index>
49
- <reference name="customer_account_dashboard">
50
- <block type="sales/order_recent" name="customer_account_dashboard_top" as="top" template="chronorelais/sales/order/recent.phtml"/>
51
- </reference>
52
- </customer_account_index>
53
-
54
- <sales_order_history>
55
- <reference name="sales.order.history">
56
- <action method="setTemplate"><template>chronorelais/sales/order/history.phtml</template></action>
57
- </reference>
58
- </sales_order_history>
59
-
60
  </layout>
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addItem"><type>skin_css</type><name>chronorelais/chronorelais.css</name></action>
6
+ </reference>
7
+ </default>
8
+
9
+ <checkout_onepage_index>
10
+ <reference name="checkout.onepage.shipping_method">
11
+ <action method="setTemplate"><template>chronorelais/checkout/onepage/shipping_method.phtml</template></action>
12
+ <block type="checkout/onepage_shipping_method_available" name="checkout.onepage.shipping_method.available" as="available" template="chronorelais/checkout/onepage/shipping_method/available.phtml">
13
+ <block type="chronorelais/checkout_onepage_shipping_method_chronorelais" name="checkout.onepage.shipping_method.chronorelais" as="relaislist" template="chronorelais/checkout/onepage/shipping_method/chronorelais.phtml"/>
14
+ </block>
15
+ </reference>
16
+ </checkout_onepage_index>
17
+
18
+ <!-- -->
19
+ <checkout_multishipping_shipping>
20
+ <update handle="checkout_multishipping"/>
21
+ <reference name="checkout_shipping">
22
+ <action method="setTemplate"><template>chronorelais/checkout/multishipping/shipping.phtml</template></action>
23
+ <block type="chronorelais/checkout_multishipping_shipping_method_chronorelais" name="checkout.multishipping.shipping_method.chronorelais" as="relaislist" template="chronorelais/checkout/multishipping/shipping_method/chronorelais.phtml"/>
24
+ </reference>
25
+ </checkout_multishipping_shipping>
26
+ <!-- -->
27
+
28
+ <checkout_onepage_shippingmethod>
29
+ <remove name="right"/>
30
+ <remove name="left"/>
31
+ <block type="checkout/onepage_shipping_method_available" name="root" output="toHtml" template="chronorelais/checkout/onepage/shipping_method/available.phtml">
32
+ <!--<block type="checkout/onepage_shipping_method_chronorelais" name="checkout.onepage.shipping_method.chronorelais" as="relaislist" template="chronorelais/checkout/onepage/shipping_method/chronorelais.phtml"/>-->
33
+ </block>
34
+ </checkout_onepage_shippingmethod>
35
+
36
+ <checkout_onepage_shippingchronorelais>
37
+ <remove name="right"/>
38
+ <remove name="left"/>
39
+ <block type="chronorelais/checkout_onepage_shipping_method_chronorelais" name="root" output="toHtml" template="chronorelais/checkout/onepage/shipping_method/chronorelais.phtml"/>
40
+ </checkout_onepage_shippingchronorelais>
41
+
42
+ <checkout_multishipping_shippingchronorelais>
43
+ <remove name="right"/>
44
+ <remove name="left"/>
45
+ <block type="chronorelais/checkout_multishipping_shipping_method_chronorelais" name="root" output="toHtml" template="chronorelais/checkout/multishipping/shipping_method/chronorelais.phtml"/>
46
+ </checkout_multishipping_shippingchronorelais>
47
+
48
+ <customer_account_index>
49
+ <reference name="customer_account_dashboard">
50
+ <block type="sales/order_recent" name="customer_account_dashboard_top" as="top" template="chronorelais/sales/order/recent.phtml"/>
51
+ </reference>
52
+ </customer_account_index>
53
+
54
+ <sales_order_history>
55
+ <reference name="sales.order.history">
56
+ <action method="setTemplate"><template>chronorelais/sales/order/history.phtml</template></action>
57
+ </reference>
58
+ </sales_order_history>
59
+
60
  </layout>
app/design/frontend/default/default/template/chronorelais/checkout/multishipping/shipping.phtml CHANGED
@@ -1,152 +1,152 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php
28
- /**
29
- * Multishipping checkout shipping template
30
- *
31
- * @see Mage_Checkout_Block_Multishipping_Shipping
32
- */
33
- ?>
34
- <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=<?php echo Mage::helper('chronorelais')->getConfigurationGoogleMapAPIKey()?>" type="text/javascript"></script>
35
- <script type="text/javascript" src="<?php echo $this->getSkinUrl('chronorelais/chronorelaismap.js') ?>"></script>
36
- <script type="text/javascript">
37
- //<![CDATA[
38
- var Picto_Chrono_Relais = '<?php echo $this->getSkinUrl('chronorelais/Picto_Chrono_Relais.png')?>';
39
- var Home_Chrono_Icon = '<?php echo $this->getSkinUrl('chronorelais/home.png')?>';
40
- //]]>
41
- </script>
42
-
43
- <div class="multiple-checkout">
44
- <div class="page-title">
45
- <h1><?php echo $this->__('Select Shipping Method') ?></h1>
46
- </div>
47
- <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
48
- <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="shipping_method_form">
49
- <?php foreach ($this->getAddresses() as $_index => $_address): ?>
50
- <div class="col2-set">
51
- <h2 class="legend"><?php echo $this->__('Address %s of %s', ($_index+1), $this->getAddressCount()) ?></h2>
52
- <div class="col-1 col-narrow">
53
- <div class="box">
54
- <div class="box-title">
55
- <h3><?php echo $this->__('Shipping To') ?> <span class="separator">|</span> <a href="<?php echo $this->getAddressEditUrl($_address) ?>"><?php echo $this->__('Change') ?></a></h3>
56
- </div>
57
- <div class="box-content">
58
- <address><?php echo $_address->format('html') ?></address>
59
- </div>
60
- </div>
61
- <div class="box box-sp-methods">
62
- <div class="pointer"></div>
63
- <div class="box-title">
64
- <h3><?php echo $this->__('Shipping Method') ?></h3>
65
- </div>
66
- <div class="box-content">
67
- <?php if (!($_shippingRateGroups = $this->getShippingRates($_address))): ?>
68
- <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
69
- <?php else: ?>
70
- <dl class="sp-methods">
71
- <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
72
- <dt><?php echo $this->getCarrierName($code) ?></dt>
73
- <dd>
74
- <ul>
75
- <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
76
- <li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"' ?>>
77
- <?php if ($_rate->getErrorMessage()): ?>
78
- <?php echo $_rate->getCarrierTitle() ?>: <?php echo $_rate->getErrorMessage() ?>
79
- <?php else: ?>
80
- <?php /*if ($_sole) : ?>
81
- <span class="no-display"><input type="radio" name="shipping_method[<?php echo $_address->getId() ?>]" value="<?php echo $this->htmlEscape($_rate->getCode()) ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>" checked="checked"/></span>
82
- <?php else:*/ ?>
83
- <input type="radio" name="shipping_method[<?php echo $_address->getId() ?>]" value="<?php echo $this->htmlEscape($_rate->getCode()) ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod($_address)) echo ' checked="checked"' ?> class="radio" onclick="<?php if($code=="chronorelais"): ?>shippingMethod.getrelais('<?php echo $this->getUrl('checkout/multishipping/getMultiRelais')?>?zip=<?php echo $_address->getPostcode() ?>&index=<?php echo $_address->getId() ?>', <?php echo $_address->getId() ?>, '<?php echo $_address->getPostcode() ?> <?php echo $_address->getCity() ?>')<?php else: ?>shippingMethod.hiderelais(<?php echo $_address->getId() ?>)<?php endif; ?>" />
84
- <?php //endif; ?>
85
- <label for="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
86
- <?php $_excl = $this->getShippingPrice($_address, $_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
87
- <?php $_incl = $this->getShippingPrice($_address, $_rate->getPrice(), true); ?>
88
- <?php echo $_excl; ?>
89
- <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
90
- (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
91
- <?php endif; ?>
92
- </label>
93
- <?php endif ?>
94
- </li>
95
- <?php endforeach; ?>
96
- </ul>
97
- </dd>
98
- <?php endforeach; ?>
99
- </dl>
100
- <?php endif; ?>
101
- </div>
102
- </div>
103
- </div>
104
- <div class="col-2 col-wide">
105
- <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress_checkbox', $_address); ?>
106
- <h3><?php echo $this->__('Items') ?> <span class="separator">|</span> <a href="<?php echo $this->getItemsEditUrl($_address) ?>"><?php echo $this->__('Edit Items') ?></a></h3>
107
- <table class="data-table" id="shipping-table-<?php echo $_address->getId() ?>">
108
- <col />
109
- <col width="1" />
110
- <thead>
111
- <tr>
112
- <th><?php echo $this->__('Product Name') ?></th>
113
- <th class="a-center"><?php echo $this->__('Qty') ?></th>
114
- </tr>
115
- </thead>
116
- <tbody>
117
- <?php foreach ($this->getAddressItems($_address) as $_item): ?>
118
- <tr>
119
- <td>
120
- <?php echo $this->getItemHtml($_item->getQuoteItem()) ?>
121
- </td>
122
- <td class="a-center"><?php echo $_item->getQty() ?></td>
123
- </tr>
124
- <?php endforeach; ?>
125
- </tbody>
126
- </table>
127
- <script type="text/javascript">decorateTable('shipping-table-<?php echo $_address->getId() ?>')</script>
128
- <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress', $_address); ?>
129
- </div>
130
-
131
- <span style="display: none;" class="please-wait" id="loading-process"><img class="v-middle" title="<?php echo $this->__('Loading...')?>" alt="<?php echo $this->__('Loading...')?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>"> <?php echo $this->__('Loading...')?></span>
132
- <div id="checkout-shipping-method-chronorelais-load_<?php echo $_address->getId() ?>" class="chronorelais-list" style="clear: both;">
133
- <?php if($this->getAddressShippingMethod($_address)=="chronorelais_chronorelais"): ?>
134
- <?php Mage::getSingleton('core/session')->setMultiPostcode($_address->getPostcode()); ?>
135
- <?php echo $this->getChildHtml('relaislist') ?>
136
- <?php endif; ?>
137
- </div>
138
- </div>
139
- <?php endforeach; ?>
140
- <?php echo $this->getChildHtml('checkout_billing_items') ?>
141
- <div class="buttons-set">
142
- <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back to Select Addresses') ?></a></p>
143
- <button type="submit" title="<?php echo $this->__('Continue to Billing Information') ?>" class="button"><span><span><?php echo $this->__('Continue to Billing Information') ?></span></span></button>
144
- </div>
145
- </form>
146
-
147
- <script type="text/javascript">
148
- //<![CDATA[
149
- var shippingMethod = new MultiShippingMethod();
150
- //]]>
151
- </script>
152
- </div>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Multishipping checkout shipping template
30
+ *
31
+ * @see Mage_Checkout_Block_Multishipping_Shipping
32
+ */
33
+ ?>
34
+ <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=<?php echo Mage::helper('chronorelais')->getConfigurationGoogleMapAPIKey()?>" type="text/javascript"></script>
35
+ <script type="text/javascript" src="<?php echo $this->getSkinUrl('chronorelais/chronorelaismap.js') ?>"></script>
36
+ <script type="text/javascript">
37
+ //<![CDATA[
38
+ var Picto_Chrono_Relais = '<?php echo $this->getSkinUrl('chronorelais/Picto_Chrono_Relais.png')?>';
39
+ var Home_Chrono_Icon = '<?php echo $this->getSkinUrl('chronorelais/home.png')?>';
40
+ //]]>
41
+ </script>
42
+
43
+ <div class="multiple-checkout">
44
+ <div class="page-title">
45
+ <h1><?php echo $this->__('Select Shipping Method') ?></h1>
46
+ </div>
47
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
48
+ <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="shipping_method_form">
49
+ <?php foreach ($this->getAddresses() as $_index => $_address): ?>
50
+ <div class="col2-set">
51
+ <h2 class="legend"><?php echo $this->__('Address %s of %s', ($_index+1), $this->getAddressCount()) ?></h2>
52
+ <div class="col-1 col-narrow">
53
+ <div class="box">
54
+ <div class="box-title">
55
+ <h3><?php echo $this->__('Shipping To') ?> <span class="separator">|</span> <a href="<?php echo $this->getAddressEditUrl($_address) ?>"><?php echo $this->__('Change') ?></a></h3>
56
+ </div>
57
+ <div class="box-content">
58
+ <address><?php echo $_address->format('html') ?></address>
59
+ </div>
60
+ </div>
61
+ <div class="box box-sp-methods">
62
+ <div class="pointer"></div>
63
+ <div class="box-title">
64
+ <h3><?php echo $this->__('Shipping Method') ?></h3>
65
+ </div>
66
+ <div class="box-content">
67
+ <?php if (!($_shippingRateGroups = $this->getShippingRates($_address))): ?>
68
+ <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
69
+ <?php else: ?>
70
+ <dl class="sp-methods">
71
+ <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
72
+ <dt><?php echo $this->getCarrierName($code) ?></dt>
73
+ <dd>
74
+ <ul>
75
+ <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
76
+ <li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"' ?>>
77
+ <?php if ($_rate->getErrorMessage()): ?>
78
+ <?php echo $_rate->getCarrierTitle() ?>: <?php echo $_rate->getErrorMessage() ?>
79
+ <?php else: ?>
80
+ <?php /*if ($_sole) : ?>
81
+ <span class="no-display"><input type="radio" name="shipping_method[<?php echo $_address->getId() ?>]" value="<?php echo $this->htmlEscape($_rate->getCode()) ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>" checked="checked"/></span>
82
+ <?php else:*/ ?>
83
+ <input type="radio" name="shipping_method[<?php echo $_address->getId() ?>]" value="<?php echo $this->htmlEscape($_rate->getCode()) ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod($_address)) echo ' checked="checked"' ?> class="radio" onclick="<?php if($code=="chronorelais"): ?>shippingMethod.getrelais('<?php echo $this->getUrl('checkout/multishipping/getMultiRelais')?>?zip=<?php echo $_address->getPostcode() ?>&index=<?php echo $_address->getId() ?>', <?php echo $_address->getId() ?>, '<?php echo $_address->getPostcode() ?> <?php echo $_address->getCity() ?>')<?php else: ?>shippingMethod.hiderelais(<?php echo $_address->getId() ?>)<?php endif; ?>" />
84
+ <?php //endif; ?>
85
+ <label for="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
86
+ <?php $_excl = $this->getShippingPrice($_address, $_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
87
+ <?php $_incl = $this->getShippingPrice($_address, $_rate->getPrice(), true); ?>
88
+ <?php echo $_excl; ?>
89
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
90
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
91
+ <?php endif; ?>
92
+ </label>
93
+ <?php endif ?>
94
+ </li>
95
+ <?php endforeach; ?>
96
+ </ul>
97
+ </dd>
98
+ <?php endforeach; ?>
99
+ </dl>
100
+ <?php endif; ?>
101
+ </div>
102
+ </div>
103
+ </div>
104
+ <div class="col-2 col-wide">
105
+ <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress_checkbox', $_address); ?>
106
+ <h3><?php echo $this->__('Items') ?> <span class="separator">|</span> <a href="<?php echo $this->getItemsEditUrl($_address) ?>"><?php echo $this->__('Edit Items') ?></a></h3>
107
+ <table class="data-table" id="shipping-table-<?php echo $_address->getId() ?>">
108
+ <col />
109
+ <col width="1" />
110
+ <thead>
111
+ <tr>
112
+ <th><?php echo $this->__('Product Name') ?></th>
113
+ <th class="a-center"><?php echo $this->__('Qty') ?></th>
114
+ </tr>
115
+ </thead>
116
+ <tbody>
117
+ <?php foreach ($this->getAddressItems($_address) as $_item): ?>
118
+ <tr>
119
+ <td>
120
+ <?php echo $this->getItemHtml($_item->getQuoteItem()) ?>
121
+ </td>
122
+ <td class="a-center"><?php echo $_item->getQty() ?></td>
123
+ </tr>
124
+ <?php endforeach; ?>
125
+ </tbody>
126
+ </table>
127
+ <script type="text/javascript">decorateTable('shipping-table-<?php echo $_address->getId() ?>')</script>
128
+ <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress', $_address); ?>
129
+ </div>
130
+
131
+ <span style="display: none;" class="please-wait" id="loading-process"><img class="v-middle" title="<?php echo $this->__('Loading...')?>" alt="<?php echo $this->__('Loading...')?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>"> <?php echo $this->__('Loading...')?></span>
132
+ <div id="checkout-shipping-method-chronorelais-load_<?php echo $_address->getId() ?>" class="chronorelais-list" style="clear: both;">
133
+ <?php if($this->getAddressShippingMethod($_address)=="chronorelais_chronorelais"): ?>
134
+ <?php Mage::getSingleton('core/session')->setMultiPostcode($_address->getPostcode()); ?>
135
+ <?php echo $this->getChildHtml('relaislist') ?>
136
+ <?php endif; ?>
137
+ </div>
138
+ </div>
139
+ <?php endforeach; ?>
140
+ <?php echo $this->getChildHtml('checkout_billing_items') ?>
141
+ <div class="buttons-set">
142
+ <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back to Select Addresses') ?></a></p>
143
+ <button type="submit" title="<?php echo $this->__('Continue to Billing Information') ?>" class="button"><span><span><?php echo $this->__('Continue to Billing Information') ?></span></span></button>
144
+ </div>
145
+ </form>
146
+
147
+ <script type="text/javascript">
148
+ //<![CDATA[
149
+ var shippingMethod = new MultiShippingMethod();
150
+ //]]>
151
+ </script>
152
+ </div>
app/design/frontend/default/default/template/chronorelais/checkout/multishipping/shipping_method/chronorelais.phtml CHANGED
@@ -1,30 +1,30 @@
1
- <?php if(count($this->getChronorelais())>0): ?>
2
- <?php
3
- $postcode = Mage::getSingleton('core/session')->getMultiPostcode();
4
- ?>
5
- <div class="chronorelaismap">
6
- <div class="mappostalcode">
7
- <form id="mappostalcodeform_%%id%%" onsubmit="return false;" action="#">
8
- <input type="text" name="mappostalcode[%%id%%]" id="mappostalcode_%%id%%" value="<?php echo $postcode ?>" class="input-text" onkeyup="if (event.keyCode == 13) shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/multishipping/getMultiRelais')?>?index=%%id%%', %%id%%)" />
9
- <button onclick="shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/multishipping/getMultiRelais')?>?index=%%id%%', %%id%%);" id="mappostalcodebtn_%%id%%" class="button" type="button"><span><span><?php echo $this->__('Changer mon code postal')?></span></span></button>
10
- <span style="display: none;" class="please-wait" id="postalcode-please-wait_%%id%%"><img class="v-middle" title="<?php echo $this->__('Loading map...')?>" alt="<?php echo $this->__('Loading map...')?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>"> <?php echo $this->__('Loading map...')?></span>
11
- </form>
12
- </div>
13
- <div id="chronomap_%%id%%" class="chronomap"></div>
14
- </div>
15
- <p style="margin: 0;"><?php echo $this->__('Veuillez choisir parmi les 5 relais Pickup affich&eacute;s ci-dessous celui qui servira d\'adresse de livraison.')?></p>
16
- <dl class="sp-methods-chronorelais">
17
- <dt><?php echo $this->__('Chronorelay points')?></dt>
18
- <dd>
19
- <ul>
20
- <?php foreach($this->getChronorelais() as $key=>$chronorelais): ?>
21
- <li>
22
- <input name="shipping_method_chronorelais[%%id%%]" type="radio" value="<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" id="s_method_chronorelais_%%id%%_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" class="radio" onclick="loadMyPoint('<?php echo $chronorelais->identifiantChronopostPointA2PAS;//$key?>')" />
23
- <label for="s_method_chronorelais_%%id%%_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>"><?php echo $chronorelais->nomEnseigne.' - '.$chronorelais->adresse1.' - '.$chronorelais->codePostal.' - '.$chronorelais->localite;?></label>
24
- </li>
25
- <?php endforeach; ?>
26
- </ul>
27
- </dd>
28
- </dl>
29
-
30
  <?php endif; ?>
1
+ <?php if(count($this->getChronorelais())>0): ?>
2
+ <?php
3
+ $postcode = Mage::getSingleton('core/session')->getMultiPostcode();
4
+ ?>
5
+ <div class="chronorelaismap">
6
+ <div class="mappostalcode">
7
+ <form id="mappostalcodeform_%%id%%" onsubmit="return false;" action="#">
8
+ <input type="text" name="mappostalcode[%%id%%]" id="mappostalcode_%%id%%" value="<?php echo $postcode ?>" class="input-text" onkeyup="if (event.keyCode == 13) shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/multishipping/getMultiRelais')?>?index=%%id%%', %%id%%)" />
9
+ <button onclick="shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/multishipping/getMultiRelais')?>?index=%%id%%', %%id%%);" id="mappostalcodebtn_%%id%%" class="button" type="button"><span><span><?php echo $this->__('Changer mon code postal')?></span></span></button>
10
+ <span style="display: none;" class="please-wait" id="postalcode-please-wait_%%id%%"><img class="v-middle" title="<?php echo $this->__('Loading map...')?>" alt="<?php echo $this->__('Loading map...')?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>"> <?php echo $this->__('Loading map...')?></span>
11
+ </form>
12
+ </div>
13
+ <div id="chronomap_%%id%%" class="chronomap"></div>
14
+ </div>
15
+ <p style="margin: 0;"><?php echo $this->__('Veuillez choisir parmi les 5 relais Pickup affich&eacute;s ci-dessous celui qui servira d\'adresse de livraison.')?></p>
16
+ <dl class="sp-methods-chronorelais">
17
+ <dt><?php echo $this->__('Chronorelay points')?></dt>
18
+ <dd>
19
+ <ul>
20
+ <?php foreach($this->getChronorelais() as $key=>$chronorelais): ?>
21
+ <li>
22
+ <input name="shipping_method_chronorelais[%%id%%]" type="radio" value="<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" id="s_method_chronorelais_%%id%%_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" class="radio" onclick="loadMyPoint('<?php echo $chronorelais->identifiantChronopostPointA2PAS;//$key?>')" />
23
+ <label for="s_method_chronorelais_%%id%%_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>"><?php echo $chronorelais->nomEnseigne.' - '.$chronorelais->adresse1.' - '.$chronorelais->codePostal.' - '.$chronorelais->localite;?></label>
24
+ </li>
25
+ <?php endforeach; ?>
26
+ </ul>
27
+ </dd>
28
+ </dl>
29
+
30
  <?php endif; ?>
app/design/frontend/default/default/template/chronorelais/checkout/onepage/shipping_method.phtml CHANGED
@@ -1,93 +1,93 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php $isSoColissimoSimplicite = Mage::getConfig()->getModuleConfig('LaPoste_SoColissimoSimplicite')->is('active'); ?>
28
-
29
- <script src="http://maps.googleapis.com/maps/api/js?sensor=false<?php if (Mage::helper('chronorelais')->getConfigurationGoogleMapAPIKey()): ?>&amp;key=<?php echo Mage::helper('chronorelais')->getConfigurationGoogleMapAPIKey() ?><?php endif; ?>" type="text/javascript"></script>
30
- <script type="text/javascript" src="<?php echo $this->getSkinUrl('chronorelais/chronorelaismap.js') ?>"></script>
31
- <script type="text/javascript">
32
- //<![CDATA[
33
- var Picto_Chrono_Relais = '<?php echo $this->getSkinUrl('chronorelais/Picto_Chrono_Relais.png')?>';
34
- var Home_Chrono_Icon = '<?php echo $this->getSkinUrl('chronorelais/home.png')?>';
35
- //]]>
36
- </script>
37
- <form id="co-shipping-method-form" action="">
38
- <div id="checkout-shipping-method-load">
39
- <?php echo $this->getChildHtml('available') ?>
40
- </div>
41
- <?php if(!empty($isSoColissimoSimplicite)) : ?>
42
- <?php $_helper = Mage::helper('socolissimosimplicite'); ?>
43
- <script type="text/javascript">
44
- //<![CDATA[
45
- // update method save to redirect onSuccess to method which deals with colissimo choice
46
- ShippingMethod.prototype.saveWithColissimo = function(){
47
- if (checkout.loadWaiting!=false) return;
48
- if (this.validate()) {
49
- checkout.setLoadWaiting('shipping-method');
50
- var request = new Ajax.Request(
51
- this.saveUrl,
52
- {
53
- method:'post',
54
- onComplete: this.onComplete,
55
- onSuccess: this.redirectToColissimo,
56
- onFailure: checkout.ajaxFailure.bind(checkout),
57
- parameters: Form.serialize(this.form)
58
- }
59
- );
60
- }
61
- };
62
- // check if colissimo is selected, then redirect on form which post data on this platform
63
- ShippingMethod.prototype.redirectToColissimo = function(transport){
64
- var rateCodeSoColissimoSimplicite = '<?php echo $_helper->getRateCode()?>';
65
- var urlFormSoColissimoSimplicite = '<?php echo $_helper->getFormUrl()?>';
66
- var methods = document.getElementsByName('shipping_method');
67
- for (var i=0; i<methods.length; i++) {
68
- if (methods[i].value == rateCodeSoColissimoSimplicite && methods[i].checked) {
69
- window.location = urlFormSoColissimoSimplicite;
70
- }
71
- }
72
- // pass to next step (= default onSave binding
73
- ShippingMethod.prototype.nextStep(transport);
74
- };
75
- //]]>
76
- </script>
77
- <?php endif; ?>
78
- <script type="text/javascript">
79
- //<![CDATA[
80
- var shippingMethod = new ShippingMethod('co-shipping-method-form', "<?php echo $this->getUrl('checkout/onepage/saveShippingMethod') ?>");
81
- //]]>
82
- </script>
83
- <div id="onepage-checkout-shipping-method-additional-load">
84
- <?php echo $this->getChildHtml('additional') ?>
85
- </div>
86
- <div class="buttons-set" id="shipping-method-buttons-container">
87
- <p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
88
- <button type="button" class="button" onclick=" <?php if(!empty($isSoColissimoSimplicite)) : ?>shippingMethod.saveWithColissimo()<?php else: ?>shippingMethod.save()<?php endif;?>"><span><span><?php echo $this->__('Continue') ?></span></span></button>
89
- <span id="shipping-method-please-wait" class="please-wait" style="display:none;">
90
- <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
91
- </span>
92
- </div>
93
  </form>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php $isSoColissimoSimplicite = Mage::getConfig()->getModuleConfig('LaPoste_SoColissimoSimplicite')->is('active'); ?>
28
+
29
+ <script src="http://maps.googleapis.com/maps/api/js?sensor=false<?php if (Mage::helper('chronorelais')->getConfigurationGoogleMapAPIKey()): ?>&amp;key=<?php echo Mage::helper('chronorelais')->getConfigurationGoogleMapAPIKey() ?><?php endif; ?>" type="text/javascript"></script>
30
+ <script type="text/javascript" src="<?php echo $this->getSkinUrl('chronorelais/chronorelaismap.js') ?>"></script>
31
+ <script type="text/javascript">
32
+ //<![CDATA[
33
+ var Picto_Chrono_Relais = '<?php echo $this->getSkinUrl('chronorelais/Picto_Chrono_Relais.png')?>';
34
+ var Home_Chrono_Icon = '<?php echo $this->getSkinUrl('chronorelais/home.png')?>';
35
+ //]]>
36
+ </script>
37
+ <form id="co-shipping-method-form" action="">
38
+ <div id="checkout-shipping-method-load">
39
+ <?php echo $this->getChildHtml('available') ?>
40
+ </div>
41
+ <?php if(!empty($isSoColissimoSimplicite)) : ?>
42
+ <?php $_helper = Mage::helper('socolissimosimplicite'); ?>
43
+ <script type="text/javascript">
44
+ //<![CDATA[
45
+ // update method save to redirect onSuccess to method which deals with colissimo choice
46
+ ShippingMethod.prototype.saveWithColissimo = function(){
47
+ if (checkout.loadWaiting!=false) return;
48
+ if (this.validate()) {
49
+ checkout.setLoadWaiting('shipping-method');
50
+ var request = new Ajax.Request(
51
+ this.saveUrl,
52
+ {
53
+ method:'post',
54
+ onComplete: this.onComplete,
55
+ onSuccess: this.redirectToColissimo,
56
+ onFailure: checkout.ajaxFailure.bind(checkout),
57
+ parameters: Form.serialize(this.form)
58
+ }
59
+ );
60
+ }
61
+ };
62
+ // check if colissimo is selected, then redirect on form which post data on this platform
63
+ ShippingMethod.prototype.redirectToColissimo = function(transport){
64
+ var rateCodeSoColissimoSimplicite = '<?php echo $_helper->getRateCode()?>';
65
+ var urlFormSoColissimoSimplicite = '<?php echo $_helper->getFormUrl()?>';
66
+ var methods = document.getElementsByName('shipping_method');
67
+ for (var i=0; i<methods.length; i++) {
68
+ if (methods[i].value == rateCodeSoColissimoSimplicite && methods[i].checked) {
69
+ window.location = urlFormSoColissimoSimplicite;
70
+ }
71
+ }
72
+ // pass to next step (= default onSave binding
73
+ ShippingMethod.prototype.nextStep(transport);
74
+ };
75
+ //]]>
76
+ </script>
77
+ <?php endif; ?>
78
+ <script type="text/javascript">
79
+ //<![CDATA[
80
+ var shippingMethod = new ShippingMethod('co-shipping-method-form', "<?php echo $this->getUrl('checkout/onepage/saveShippingMethod') ?>");
81
+ //]]>
82
+ </script>
83
+ <div id="onepage-checkout-shipping-method-additional-load">
84
+ <?php echo $this->getChildHtml('additional') ?>
85
+ </div>
86
+ <div class="buttons-set" id="shipping-method-buttons-container">
87
+ <p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
88
+ <button type="button" class="button" onclick=" <?php if(!empty($isSoColissimoSimplicite)) : ?>shippingMethod.saveWithColissimo()<?php else: ?>shippingMethod.save()<?php endif;?>"><span><span><?php echo $this->__('Continue') ?></span></span></button>
89
+ <span id="shipping-method-please-wait" class="please-wait" style="display:none;">
90
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
91
+ </span>
92
+ </div>
93
  </form>
app/design/frontend/default/default/template/chronorelais/checkout/onepage/shipping_method/available.phtml CHANGED
@@ -1,124 +1,124 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
28
- <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
29
- <?php else: ?>
30
- <dl class="sp-methods">
31
- <?php $shippingCodePrice = array(); ?>
32
- <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
33
- <dt><?php echo $this->getCarrierName($code) ?></dt>
34
- <dd>
35
- <ul>
36
- <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
37
- <?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
38
- <li>
39
- <?php if ($_rate->getErrorMessage()): ?>
40
- <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
41
- <?php else: ?>
42
- <table>
43
- <tr><td class="method-radio">
44
- <?php /*if ($_sole) : ?>
45
- <span class="no-display"><input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" onclick="<?php if($code=="chronorelais"): ?>shippingMethod.getrelais('<?php echo $this->getUrl('checkout/onepage/getRelais')?>')<?php else: ?>shippingMethod.hiderelais()<?php endif; ?>" /></span>
46
- <?php else:*/ ?>
47
- <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php /*if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"'*/ ?> class="radio" onclick="<?php if($code=="chronorelais"): ?>shippingMethod.getrelais('<?php echo $this->getUrl('checkout/onepage/getRelais')?>')<?php else: ?>shippingMethod.hiderelais()<?php endif; ?>" />
48
- <?php //endif; ?>
49
- </td>
50
- <?php if(Mage::getStoreConfig('carriers/'.$code.'/logo_url')): ?>
51
- <td class="method-image"><img src="<?php echo $this->getSkinUrl("chronorelais/".Mage::getStoreConfig('carriers/'.$code.'/logo_url')); ?>" alt="" /></td>
52
- <?php endif; ?>
53
- <td class="method-contents">
54
- <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
55
- <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
56
- <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
57
- <?php echo $_excl; ?>
58
- <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
59
- (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
60
- <?php endif; ?>
61
- </label>
62
- <?php if($_rate->getMethodDescription()): ?>
63
- <div class="method-description">
64
- <?php echo $_rate->getMethodDescription()?>
65
- </div>
66
- <?php endif;?>
67
-
68
- <?php // disponibilit� de la plateforme soco ?>
69
- <?php if(Mage::getConfig()->getModuleConfig('LaPoste_SoColissimoSimplicite')->is('active')) : ?>
70
- <?php $helper = Mage::helper('socolissimosimplicite'); ?>
71
- <?php
72
- $serviceIsAvailable = true;
73
- if ($helper->getServiceIsAvailable() and $helper->getServiceIsAvailableUrl() != '') {
74
- $serviceIsAvailable = $helper->checkserviceAvailability();
75
- }
76
- ?>
77
- <?php if ($_rate->getCode() == 'socolissimosimplicite_socolissimosimplicite' and !$serviceIsAvailable): ?>
78
- <ul class="messages"><li class="error-msg"><ul><li><?php echo $helper->getServiceNotAvailableMessage(); ?></li></ul></li></ul>
79
- <?php endif ?>
80
- <?php endif; ?>
81
- </td>
82
- </tr>
83
- </table>
84
- <?php if($code=="chronorelais"): ?>
85
- <div id="checkout-shipping-method-chronorelais-load" class="chronorelais-list">
86
- <?php echo $this->getChildHtml('relaislist') ?>
87
- </div>
88
- <?php endif; ?>
89
- <?php endif ?>
90
- </li>
91
- <?php endforeach; ?>
92
- </ul>
93
- </dd>
94
- <?php endforeach; ?>
95
- </dl>
96
- <script type="text/javascript">
97
- //<![CDATA[
98
- <?php if (!empty($shippingCodePrice)): ?>
99
- var shippingCodePrice = {<?php echo implode(',',$shippingCodePrice); ?>};
100
- <?php endif; ?>
101
-
102
- $$('input[type="radio"][name="shipping_method"]').each(function(el){
103
- Event.observe(el, 'click', function(){
104
- if (el.checked == true) {
105
- var getShippingCode = el.getValue();
106
- <?php if (!empty($shippingCodePrice)): ?>
107
- var newPrice = shippingCodePrice[getShippingCode];
108
- if (!lastPrice) {
109
- lastPrice = newPrice;
110
- quoteBaseGrandTotal += newPrice;
111
- }
112
- if (newPrice != lastPrice) {
113
- quoteBaseGrandTotal += (newPrice-lastPrice);
114
- lastPrice = newPrice;
115
- }
116
- <?php endif; ?>
117
- checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
118
- return false;
119
- }
120
- });
121
- });
122
- //]]>
123
- </script>
124
  <?php endif; ?>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
28
+ <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
29
+ <?php else: ?>
30
+ <dl class="sp-methods">
31
+ <?php $shippingCodePrice = array(); ?>
32
+ <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
33
+ <dt><?php echo $this->getCarrierName($code) ?></dt>
34
+ <dd>
35
+ <ul>
36
+ <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
37
+ <?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
38
+ <li>
39
+ <?php if ($_rate->getErrorMessage()): ?>
40
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
41
+ <?php else: ?>
42
+ <table>
43
+ <tr><td class="method-radio">
44
+ <?php /*if ($_sole) : ?>
45
+ <span class="no-display"><input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" onclick="<?php if($code=="chronorelais"): ?>shippingMethod.getrelais('<?php echo $this->getUrl('checkout/onepage/getRelais')?>')<?php else: ?>shippingMethod.hiderelais()<?php endif; ?>" /></span>
46
+ <?php else:*/ ?>
47
+ <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php /*if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"'*/ ?> class="radio" onclick="<?php if($code=="chronorelais"): ?>shippingMethod.getrelais('<?php echo $this->getUrl('checkout/onepage/getRelais')?>')<?php else: ?>shippingMethod.hiderelais()<?php endif; ?>" />
48
+ <?php //endif; ?>
49
+ </td>
50
+ <?php if(Mage::getStoreConfig('carriers/'.$code.'/logo_url')): ?>
51
+ <td class="method-image"><img src="<?php echo $this->getSkinUrl("chronorelais/".Mage::getStoreConfig('carriers/'.$code.'/logo_url')); ?>" alt="" /></td>
52
+ <?php endif; ?>
53
+ <td class="method-contents">
54
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
55
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
56
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
57
+ <?php echo $_excl; ?>
58
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
59
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
60
+ <?php endif; ?>
61
+ </label>
62
+ <?php if($_rate->getMethodDescription()): ?>
63
+ <div class="method-description">
64
+ <?php echo $_rate->getMethodDescription()?>
65
+ </div>
66
+ <?php endif;?>
67
+
68
+ <?php // disponibilit� de la plateforme soco ?>
69
+ <?php if(Mage::getConfig()->getModuleConfig('LaPoste_SoColissimoSimplicite')->is('active')) : ?>
70
+ <?php $helper = Mage::helper('socolissimosimplicite'); ?>
71
+ <?php
72
+ $serviceIsAvailable = true;
73
+ if ($helper->getServiceIsAvailable() and $helper->getServiceIsAvailableUrl() != '') {
74
+ $serviceIsAvailable = $helper->checkserviceAvailability();
75
+ }
76
+ ?>
77
+ <?php if ($_rate->getCode() == 'socolissimosimplicite_socolissimosimplicite' and !$serviceIsAvailable): ?>
78
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $helper->getServiceNotAvailableMessage(); ?></li></ul></li></ul>
79
+ <?php endif ?>
80
+ <?php endif; ?>
81
+ </td>
82
+ </tr>
83
+ </table>
84
+ <?php if($code=="chronorelais"): ?>
85
+ <div id="checkout-shipping-method-chronorelais-load" class="chronorelais-list">
86
+ <?php echo $this->getChildHtml('relaislist') ?>
87
+ </div>
88
+ <?php endif; ?>
89
+ <?php endif ?>
90
+ </li>
91
+ <?php endforeach; ?>
92
+ </ul>
93
+ </dd>
94
+ <?php endforeach; ?>
95
+ </dl>
96
+ <script type="text/javascript">
97
+ //<![CDATA[
98
+ <?php if (!empty($shippingCodePrice)): ?>
99
+ var shippingCodePrice = {<?php echo implode(',',$shippingCodePrice); ?>};
100
+ <?php endif; ?>
101
+
102
+ $$('input[type="radio"][name="shipping_method"]').each(function(el){
103
+ Event.observe(el, 'click', function(){
104
+ if (el.checked == true) {
105
+ var getShippingCode = el.getValue();
106
+ <?php if (!empty($shippingCodePrice)): ?>
107
+ var newPrice = shippingCodePrice[getShippingCode];
108
+ if (!lastPrice) {
109
+ lastPrice = newPrice;
110
+ quoteBaseGrandTotal += newPrice;
111
+ }
112
+ if (newPrice != lastPrice) {
113
+ quoteBaseGrandTotal += (newPrice-lastPrice);
114
+ lastPrice = newPrice;
115
+ }
116
+ <?php endif; ?>
117
+ checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
118
+ return false;
119
+ }
120
+ });
121
+ });
122
+ //]]>
123
+ </script>
124
  <?php endif; ?>
app/design/frontend/default/default/template/chronorelais/checkout/onepage/shipping_method/chronorelais.phtml CHANGED
@@ -1,30 +1,30 @@
1
- <?php if(count($this->getChronorelais())>0): ?>
2
- <?php
3
- $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
4
- $address = $quote->getShippingAddress();
5
- $postcode = $address->getPostcode();
6
- ?>
7
- <div class="chronorelaismap">
8
- <div class="mappostalcode">
9
- <input type="text" name="mappostalcode" id="mappostalcode" value="<?php echo $postcode ?>" class="input-text" onkeydown="if (event.keyCode == 13) shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/onepage/changePostalCode')?>')" />
10
- <button onclick="shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/onepage/changePostalCode')?>');" id="mappostalcodebtn" class="button" type="button"><span><span><?php echo $this->__('Changer mon code postal')?></span></span></button>
11
- <span style="display: none;" class="please-wait" id="postalcode-please-wait"><img class="v-middle" title="<?php echo $this->__('Loading map...')?>" alt="<?php echo $this->__('Loading map...')?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>"> <?php echo $this->__('Loading map...')?></span>
12
- </div>
13
- <div id="chronomap" class="chronomap"></div>
14
- </div>
15
- <p style="margin: 0;"><?php echo $this->__('Veuillez choisir parmi les 5 relais Pickup affich&eacute;s ci-dessous celui qui servira d\'adresse de livraison.')?></p>
16
- <dl class="sp-methods-chronorelais">
17
- <dt><?php echo $this->__('Chronorelay points')?></dt>
18
- <dd>
19
- <ul>
20
- <?php foreach($this->getChronorelais() as $key=>$chronorelais): ?>
21
- <li>
22
- <input name="shipping_method_chronorelais" type="radio" value="<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" id="s_method_chronorelais_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" class="radio" onclick="loadMyPoint('<?php echo $chronorelais->identifiantChronopostPointA2PAS;//$key?>')" />
23
- <label for="s_method_chronorelais_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>"><?php echo $chronorelais->nomEnseigne.' - '.$chronorelais->adresse1.' - '.$chronorelais->codePostal.' - '.$chronorelais->localite;?></label>
24
- </li>
25
- <?php endforeach; ?>
26
- </ul>
27
- </dd>
28
- </dl>
29
-
30
  <?php endif; ?>
1
+ <?php if(count($this->getChronorelais())>0): ?>
2
+ <?php
3
+ $quote = Mage::getSingleton('checkout/cart')->init()->getQuote();
4
+ $address = $quote->getShippingAddress();
5
+ $postcode = $address->getPostcode();
6
+ ?>
7
+ <div class="chronorelaismap">
8
+ <div class="mappostalcode">
9
+ <input type="text" name="mappostalcode" id="mappostalcode" value="<?php echo $postcode ?>" class="input-text" onkeydown="if (event.keyCode == 13) shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/onepage/changePostalCode')?>')" />
10
+ <button onclick="shippingMethod.changePostalCode('<?php echo $this->getUrl('checkout/onepage/changePostalCode')?>');" id="mappostalcodebtn" class="button" type="button"><span><span><?php echo $this->__('Changer mon code postal')?></span></span></button>
11
+ <span style="display: none;" class="please-wait" id="postalcode-please-wait"><img class="v-middle" title="<?php echo $this->__('Loading map...')?>" alt="<?php echo $this->__('Loading map...')?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>"> <?php echo $this->__('Loading map...')?></span>
12
+ </div>
13
+ <div id="chronomap" class="chronomap"></div>
14
+ </div>
15
+ <p style="margin: 0;"><?php echo $this->__('Veuillez choisir parmi les 5 relais Pickup affich&eacute;s ci-dessous celui qui servira d\'adresse de livraison.')?></p>
16
+ <dl class="sp-methods-chronorelais">
17
+ <dt><?php echo $this->__('Chronorelay points')?></dt>
18
+ <dd>
19
+ <ul>
20
+ <?php foreach($this->getChronorelais() as $key=>$chronorelais): ?>
21
+ <li>
22
+ <input name="shipping_method_chronorelais" type="radio" value="<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" id="s_method_chronorelais_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>" class="radio" onclick="loadMyPoint('<?php echo $chronorelais->identifiantChronopostPointA2PAS;//$key?>')" />
23
+ <label for="s_method_chronorelais_<?php echo $chronorelais->identifiantChronopostPointA2PAS;?>"><?php echo $chronorelais->nomEnseigne.' - '.$chronorelais->adresse1.' - '.$chronorelais->codePostal.' - '.$chronorelais->localite;?></label>
24
+ </li>
25
+ <?php endforeach; ?>
26
+ </ul>
27
+ </dd>
28
+ </dl>
29
+
30
  <?php endif; ?>
app/design/frontend/default/default/template/chronorelais/sales/order/history.phtml CHANGED
@@ -1,80 +1,80 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
28
- <?php $_orders = $this->getOrders(); ?>
29
- <div class="page-title">
30
- <h1><?php echo $this->__('My Orders') ?></h1>
31
- </div>
32
- <?php echo $this->getPagerHtml(); ?>
33
- <?php if($_orders->getSize()): ?>
34
- <table class="data-table" id="my-orders-table">
35
- <col width="1" />
36
- <col width="1" />
37
- <col />
38
- <col width="1" />
39
- <col width="1" />
40
- <col width="1" />
41
- <thead>
42
- <tr>
43
- <th><?php echo $this->__('Order #') ?></th>
44
- <th><?php echo $this->__('Date') ?></th>
45
- <th><?php echo $this->__('Ship To') ?></th>
46
- <th><span class="nobr"><?php echo $this->__('Order Total') ?></span></th>
47
- <th><span class="nobr"><?php echo $this->__('Order Status') ?></span></th>
48
- <th>&nbsp;</th>
49
- </tr>
50
- </thead>
51
- <tbody>
52
- <?php $_odd = ''; ?>
53
- <?php foreach ($_orders as $_order): ?>
54
- <tr>
55
- <td><?php echo $_order->getRealOrderId() ?></td>
56
- <td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
57
- <td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
58
- <td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
59
- <td><em><?php echo $_order->getStatusLabel() ?></em></td>
60
- <td class="a-center">
61
- <span class="nobr"><a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>
62
- <?php /*<span class="separator">|</span><a href="<?php echo $this->getTrackUrl($_order) ?>"><?php echo $this->__('Track Order') ?></a>&nbsp;*/ ?>
63
- <?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
64
- <span class="separator">|</span> <a href="<?php echo $this->getReorderUrl($_order) ?>" class="link-reorder"><?php echo $this->__('Reorder') ?></a>
65
- <?php endif ?>
66
- </span>
67
- <br />
68
- <?php if ($_order->getTracksCollection()->count()) : ?>
69
- <a href="#" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','top=50,left=50,width=800,height=600,resizable=yes,scrollbars=yes'); return false;" title="<?php echo $this->__('Track Your Order') ?>"><?php echo $this->__('Track Your Order') ?></a>
70
- <?php endif; ?>
71
- </td>
72
- </tr>
73
- <?php endforeach; ?>
74
- </tbody>
75
- </table>
76
- <script type="text/javascript">decorateTable('my-orders-table');</script>
77
- <?php echo $this->getPagerHtml(); ?>
78
- <?php else: ?>
79
- <p><?php echo $this->__('You have placed no orders.'); ?></p>
80
- <?php endif ?>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
28
+ <?php $_orders = $this->getOrders(); ?>
29
+ <div class="page-title">
30
+ <h1><?php echo $this->__('My Orders') ?></h1>
31
+ </div>
32
+ <?php echo $this->getPagerHtml(); ?>
33
+ <?php if($_orders->getSize()): ?>
34
+ <table class="data-table" id="my-orders-table">
35
+ <col width="1" />
36
+ <col width="1" />
37
+ <col />
38
+ <col width="1" />
39
+ <col width="1" />
40
+ <col width="1" />
41
+ <thead>
42
+ <tr>
43
+ <th><?php echo $this->__('Order #') ?></th>
44
+ <th><?php echo $this->__('Date') ?></th>
45
+ <th><?php echo $this->__('Ship To') ?></th>
46
+ <th><span class="nobr"><?php echo $this->__('Order Total') ?></span></th>
47
+ <th><span class="nobr"><?php echo $this->__('Order Status') ?></span></th>
48
+ <th>&nbsp;</th>
49
+ </tr>
50
+ </thead>
51
+ <tbody>
52
+ <?php $_odd = ''; ?>
53
+ <?php foreach ($_orders as $_order): ?>
54
+ <tr>
55
+ <td><?php echo $_order->getRealOrderId() ?></td>
56
+ <td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
57
+ <td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
58
+ <td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
59
+ <td><em><?php echo $_order->getStatusLabel() ?></em></td>
60
+ <td class="a-center">
61
+ <span class="nobr"><a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>
62
+ <?php /*<span class="separator">|</span><a href="<?php echo $this->getTrackUrl($_order) ?>"><?php echo $this->__('Track Order') ?></a>&nbsp;*/ ?>
63
+ <?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
64
+ <span class="separator">|</span> <a href="<?php echo $this->getReorderUrl($_order) ?>" class="link-reorder"><?php echo $this->__('Reorder') ?></a>
65
+ <?php endif ?>
66
+ </span>
67
+ <br />
68
+ <?php if ($_order->getTracksCollection()->count()) : ?>
69
+ <a href="#" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','top=50,left=50,width=800,height=600,resizable=yes,scrollbars=yes'); return false;" title="<?php echo $this->__('Track Your Order') ?>"><?php echo $this->__('Track Your Order') ?></a>
70
+ <?php endif; ?>
71
+ </td>
72
+ </tr>
73
+ <?php endforeach; ?>
74
+ </tbody>
75
+ </table>
76
+ <script type="text/javascript">decorateTable('my-orders-table');</script>
77
+ <?php echo $this->getPagerHtml(); ?>
78
+ <?php else: ?>
79
+ <p><?php echo $this->__('You have placed no orders.'); ?></p>
80
+ <?php endif ?>
app/design/frontend/default/default/template/chronorelais/sales/order/recent.phtml CHANGED
@@ -1,79 +1,79 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
- ?>
27
- <div class="box-account box-recent">
28
- <?php $_orders = $this->getOrders(); ?>
29
- <div class="box-head">
30
- <h2><?php echo $this->__('Recent Orders') ?></h2>
31
- <?php if( sizeof($_orders->getItems()) > 0 ): ?><a href="<?php echo $this->getUrl('sales/order/history') ?>"><?php echo $this->__('View All') ?></a><?php endif; ?>
32
- </div>
33
- <?php if( sizeof($_orders->getItems()) > 0 ): ?>
34
- <table class="data-table" id="my-orders-table">
35
- <col width="1" />
36
- <col width="1" />
37
- <col />
38
- <col width="1" />
39
- <col width="1" />
40
- <col width="1" />
41
- <thead>
42
- <tr>
43
- <th><?php echo $this->__('Order #') ?></th>
44
- <th><?php echo $this->__('Date') ?></th>
45
- <th><?php echo $this->__('Ship To') ?></th>
46
- <th><span class="nobr"><?php echo $this->__('Order Total') ?></span></th>
47
- <th><?php echo $this->__('Status') ?></th>
48
- <th>&nbsp;</th>
49
- </tr>
50
- </thead>
51
- <tbody>
52
- <?php foreach ($_orders as $_order): ?>
53
- <tr>
54
- <td><?php echo $_order->getRealOrderId() ?></td>
55
- <td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
56
- <td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
57
- <td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
58
- <td><em><?php echo $_order->getStatusLabel() ?></em></td>
59
- <td class="a-center">
60
- <span class="nobr">
61
- <a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>
62
- <?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
63
- <span class="separator">|</span> <a href="<?php echo $this->getReorderUrl($_order) ?>" class="link-reorder"><?php echo $this->__('Reorder') ?></a>
64
- <?php endif ?>
65
- </span>
66
- <br />
67
- <?php if ($_order->getTracksCollection()->count()) : ?>
68
- <a href="#" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','top=50,left=50,width=800,height=600,resizable=yes,scrollbars=yes'); return false;" title="<?php echo $this->__('Track Your Order') ?>"><?php echo $this->__('Track Your Order') ?></a>
69
- <?php endif; ?>
70
- </td>
71
- </tr>
72
- <?php endforeach; ?>
73
- </tbody>
74
- </table>
75
- <script type="text/javascript">decorateTable('my-orders-table')</script>
76
- <?php else: ?>
77
- <p><?php echo $this->__('You have placed no orders.'); ?></p>
78
- <?php endif; ?>
79
- </div>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div class="box-account box-recent">
28
+ <?php $_orders = $this->getOrders(); ?>
29
+ <div class="box-head">
30
+ <h2><?php echo $this->__('Recent Orders') ?></h2>
31
+ <?php if( sizeof($_orders->getItems()) > 0 ): ?><a href="<?php echo $this->getUrl('sales/order/history') ?>"><?php echo $this->__('View All') ?></a><?php endif; ?>
32
+ </div>
33
+ <?php if( sizeof($_orders->getItems()) > 0 ): ?>
34
+ <table class="data-table" id="my-orders-table">
35
+ <col width="1" />
36
+ <col width="1" />
37
+ <col />
38
+ <col width="1" />
39
+ <col width="1" />
40
+ <col width="1" />
41
+ <thead>
42
+ <tr>
43
+ <th><?php echo $this->__('Order #') ?></th>
44
+ <th><?php echo $this->__('Date') ?></th>
45
+ <th><?php echo $this->__('Ship To') ?></th>
46
+ <th><span class="nobr"><?php echo $this->__('Order Total') ?></span></th>
47
+ <th><?php echo $this->__('Status') ?></th>
48
+ <th>&nbsp;</th>
49
+ </tr>
50
+ </thead>
51
+ <tbody>
52
+ <?php foreach ($_orders as $_order): ?>
53
+ <tr>
54
+ <td><?php echo $_order->getRealOrderId() ?></td>
55
+ <td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
56
+ <td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
57
+ <td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
58
+ <td><em><?php echo $_order->getStatusLabel() ?></em></td>
59
+ <td class="a-center">
60
+ <span class="nobr">
61
+ <a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>
62
+ <?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
63
+ <span class="separator">|</span> <a href="<?php echo $this->getReorderUrl($_order) ?>" class="link-reorder"><?php echo $this->__('Reorder') ?></a>
64
+ <?php endif ?>
65
+ </span>
66
+ <br />
67
+ <?php if ($_order->getTracksCollection()->count()) : ?>
68
+ <a href="#" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','top=50,left=50,width=800,height=600,resizable=yes,scrollbars=yes'); return false;" title="<?php echo $this->__('Track Your Order') ?>"><?php echo $this->__('Track Your Order') ?></a>
69
+ <?php endif; ?>
70
+ </td>
71
+ </tr>
72
+ <?php endforeach; ?>
73
+ </tbody>
74
+ </table>
75
+ <script type="text/javascript">decorateTable('my-orders-table')</script>
76
+ <?php else: ?>
77
+ <p><?php echo $this->__('You have placed no orders.'); ?></p>
78
+ <?php endif; ?>
79
+ </div>
app/etc/modules/WSChronopost_Chronorelais.xml CHANGED
@@ -1,28 +1,28 @@
1
- <?xml version="1.0"?>
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
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
- */
20
- -->
21
- <config>
22
- <modules>
23
- <Chronopost_Chronorelais>
24
- <active>true</active>
25
- <codePool>community</codePool>
26
- </Chronopost_Chronorelais>
27
- </modules>
28
  </config>
1
+ <?xml version="1.0"?>
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
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ -->
21
+ <config>
22
+ <modules>
23
+ <Chronopost_Chronorelais>
24
+ <active>true</active>
25
+ <codePool>community</codePool>
26
+ </Chronopost_Chronorelais>
27
+ </modules>
28
  </config>
app/locale/fr_FR/Chronopost_Chronorelais.csv CHANGED
@@ -1,4 +1,6 @@
1
  # fr-FR
 
 
2
  "No match found","Aucune correspondance trouvée"
3
  "Configuration disabled","Configuration désactivée"
4
  "The cart doesn't match conditions","Le panier ne correspond pas aux conditions"
1
  # fr-FR
2
+ "Weight unit for the store","Unité de poids"
3
+ "Please install %s on your server to print mass","Veuillez installer %s sur votre serveur pour pouvoir imprimer en masse"
4
  "No match found","Aucune correspondance trouvée"
5
  "Configuration disabled","Configuration désactivée"
6
  "The cart doesn't match conditions","Le panier ne correspond pas aux conditions"
js/chronopost/chronorelais/chronorelais.js ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Event.observe(window, 'load', function() {
2
+ if ($('chronorelais_assurance_picto_img'))
3
+ {
4
+ $('chronorelais_assurance_picto_img').observe('click', function() {
5
+ $('chronorelais_assurance_infobulle').show();
6
+ });
7
+ $('chronorelais_assurance_infobulle_header_close').observe('click', function() {
8
+ $('chronorelais_assurance_infobulle').hide();
9
+ });
10
+ }
11
+
12
+
13
+ configForm.submit = function(url){
14
+ if (typeof varienGlobalEvents != undefined) {
15
+ varienGlobalEvents.fireEvent('formSubmit', this.formId);
16
+ }
17
+ this.errorSections = $H({});
18
+ this.canShowError = true;
19
+ this.submitUrl = url;
20
+ if (this.validator && this.validator.validate()) {
21
+ if ($('carriers_chronopost')) {
22
+ if ($('carriers_chronopost_active').value == 1 && $('carriers_chronopostc18_active').value == 1) {
23
+ alert('Vous ne pouvez pas activer Chronopost C13 et Chronopost C18 en même temps');
24
+ return false;
25
+ }
26
+ }
27
+ if (this.validationUrl) {
28
+ this._validate();
29
+ }
30
+ else {
31
+ this._submit();
32
+ }
33
+ return true;
34
+ }
35
+ return false;
36
+ }
37
+
38
+ });
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Chronopost</name>
4
- <version>0.4.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -36,9 +36,9 @@ Correction d'un bug qui passait les commandes en invit&#xE9; au lieu de cr&#xE9;
36
  Divers correctifs mineurs.&#xD;
37
  </notes>
38
  <authors><author><name>Benjamin GOSSELET</name><user>Chronopost</user><email>bgosselet@adexos.fr</email></author></authors>
39
- <date>2012-09-21</date>
40
- <time>20:01:28</time>
41
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="chronorelais"><dir name="import"><file name="form.phtml" hash="356aadf2bb0182b23f7af38888a0cd38"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="chronorelais.xml" hash="a298640a9d7a9d5c9ad90b81801d0584"/></dir><dir name="template"><dir name="chronorelais"><dir name="checkout"><dir name="multishipping"><file name="shipping.phtml" hash="89ac65c42722975ec8b872a1e69b5ae9"/><dir name="shipping_method"><file name="chronorelais.phtml" hash="f184ce28e619c185434810545bc82d9f"/></dir></dir><dir name="onepage"><dir name="shipping_method"><file name="available.phtml" hash="294928839d355bec304699573299a4ee"/><file name="chronorelais.phtml" hash="4d9d318e0add0ff4a70155541180654a"/></dir><file name="shipping_method.phtml" hash="a2b0c989c7191d47eda86ddf94beaca8"/></dir></dir><dir name="sales"><dir name="order"><file name="history.phtml" hash="67bfaad7cff5ab92b5bd1c00581c6a8f"/><file name="recent.phtml" hash="7288560d442eadf3d8c19a40f80a9765"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Chronopost"><dir name="Chronorelais"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Config.php" hash="b38741ddd97fcae5dd276239fb3c6b70"/></dir></dir></dir></dir></dir><dir name="Checkout"><dir name="Multishipping"><dir name="Shipping"><dir name="Method"><file name="Chronorelais.php" hash="a095d54809c9ad04453758635879127e"/></dir></dir></dir><dir name="Onepage"><dir name="Shipping"><dir name="Method"><file name="Chronorelais.php" hash="c4d908310310e4cd90833378df260599"/></dir></dir></dir></dir><file name="Detail.php" hash="005fa3b6e5918c6c9779402fab5713f2"/><dir name="Export"><dir name="Orders"><file name="Grid.php" hash="485a293e051663aac0f67959644e6824"/></dir><file name="Orders.php" hash="9ada10bd85cb58122e722b3e82c71e37"/></dir><file name="Filter.php" hash="28f80e3ab34f6ff03b61f070ccbac697"/><dir name="Import"><file name="Form.php" hash="56c6e3787c05e58d57b48ec4b1421468"/></dir><dir name="Sales"><file name="Impression.php" hash="619599b136b9cc49f01dba5b08ee8428"/><dir name="Order"><dir name="Shipment"><file name="View.php" hash="f5407d7d14aa59acb844479da5046900"/></dir></dir><dir name="Shipment"><file name="Grid.php" hash="06928b811ee8d71e5e1fdcc0814ff9e0"/></dir></dir></dir><dir name="Controller"><file name="Abstract.php" hash="94680cd88c6af59764dedb613b08d5f6"/></dir><dir name="Helper"><file name="Data.php" hash="70531f8f903a63986c063f65553d643d"/></dir><dir name="Model"><dir name="Carrier"><file name="AbstractChronorelais.php" hash="f4957f6d660c4adb0328f9f2d73da1e2"/><file name="AbstractChronorelaisShipping.php" hash="1adab13f3659559803b338ad86205d43"/><file name="Chronoexpress.php" hash="bc867a6b98966ada549a0b81ec334b64"/><file name="Chronopost.php" hash="c4d4525447d2801d28d921eaedc35a9a"/><file name="Chronorelais.php" hash="5cfcb83c23d05585fdc50f8b2747fc40"/></dir><dir name="Config"><dir name="Source"><file name="Civility.php" hash="fe6ec6eebe6faffdd0bb65479d91cd5d"/><file name="EndOfLineCharacter.php" hash="3fe6b6069a9efdc29ad0d3f7d1cf4794"/><file name="FieldDelimiter.php" hash="3e023d40aeca50932e62ff97eed6317e"/><file name="FieldSeparator.php" hash="ce30c5974a893bd5467334d574dd578a"/><file name="FileCharset.php" hash="6cc4ebab95735bd121af16e0eedd90d6"/><file name="FileExtension.php" hash="597c3e78e7584bf7c4b7b2ebad6d2a65"/><file name="PrintMode.php" hash="67e8a6e98e12c7e72624ba5322076c00"/></dir></dir><dir name="Sales"><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Shipping.php" hash="2e69db363011f84ef2cdb5d0e9d4c4df"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AjaxController.php" hash="1905b32a1366d3c27277836364737e98"/><dir name="Checkout"><file name="MultishippingController.php" hash="c44aa875ba9683e1d6311390c4e77080"/><file name="OnepageController.php" hash="7d21a70c64f27ee9a34e2db9265708fb"/></dir><file name="ExportController.php" hash="9a24df876d6d7c48df53d99ff5498d6b"/><file name="ImportController.php" hash="7cce42f41a838e1cb3e220742020eeff"/><file name="RelaisController.php" hash="5d48155ddb7cc2d4effbbfdeb4f3946d"/><dir name="Sales"><file name="ImpressionController.php" hash="7b040384c03fec329f66ec0afb2d4d44"/><dir name="Order"><file name="ShipmentController.php" hash="992c53ee433323ef9fb1c0f101c54ea3"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="28417b8fdd11f66ff100ded62a43a312"/><file name="system.xml" hash="d819211d2c30e6ed340b8f2c5aa77cf8"/></dir><dir name="includes"><file name="ChronorelaisShippingHelper.php" hash="d3ee70e7f3ed2fb822f2e46abed56596"/><file name="countries.inc.php" hash="d21cd393c7c0ebc83beccc99950d6ab1"/></dir><dir name="sql"><dir name="chronorelais_setup"><file name="mysql4-install-0.1.0.php" hash="c307802a7bd10c1ecce06799b04569c2"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="ea3358055a851a96b673c721202045be"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="961f41dc1012d0917504f9bb5f5d106c"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="b85470889421f652c3d01b96072f579c"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="def69d0ae26b0d130d2ce6e0838e5d7f"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Chronopost_Chronorelais.csv" hash="76475aa4fa500c135a666e47bab62ddf"/></dir><dir name="fr_FR"><file name="Chronopost_Chronorelais.csv" hash="774b0e1f1c3157a6eeb37ef2e8f21e16"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="chronorelais"><file name="Logo-Chronopost.jpg" hash="cc1226ebcd7236ce021076657ac22265"/><file name="Picto_Chrono_Relais.png" hash="1ea0f0c410d237adf23d5905cd8431f5"/><file name="Thumbs.db" hash="2e16ed23c37d1aa29a6caf73f513a648"/><file name="ac.png" hash="0c04f70da35d43a2636cfbd6ad2b10d5"/><file name="chronopost.png" hash="93e5b22e2f280923df8d503f5c8e5b92"/><file name="chronorelais.css" hash="a1fef1934a1114be6c8f4eebde2b5263"/><file name="chronorelais.png" hash="87c42de75ddafe495dfc0248c2a688b4"/><file name="chronorelaismap.js" hash="92ed8469ba7bd08fec0683b841bdc860"/><file name="home.png" hash="7904b495e94047eb3406e260bc660cce"/><file name="ico_ac_shaded.gif" hash="e55d9b2071fb976cf5331b6273a40731"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="WSChronopost_Chronorelais.xml" hash="a432624b16f2f25dff3c66937e1d8f5d"/></dir></target><target name="mage"><dir name="js"><dir name="chronopost"><dir name="chronorelais"><file name="ocseditor.css" hash="1bfc847153768d6729cdad7cb1abe443"/><file name="ocseditor.js" hash="8b7f29ddf7faff2fd3a63af18ba666aa"/></dir></dir></dir></target></contents>
42
  <compatible/>
43
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
44
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Chronopost</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
36
  Divers correctifs mineurs.&#xD;
37
  </notes>
38
  <authors><author><name>Benjamin GOSSELET</name><user>Chronopost</user><email>bgosselet@adexos.fr</email></author></authors>
39
+ <date>2013-06-27</date>
40
+ <time>15:46:23</time>
41
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="chronorelais"><dir name="bordereau"><file name="grid.phtml" hash="0eca2119f27219d6bb568c2d1f50dbaf"/></dir><dir name="config"><file name="checklogin.phtml" hash="5455c412136bb8aee5dc7376ec7db2e8"/></dir><dir name="import"><file name="form.phtml" hash="356aadf2bb0182b23f7af38888a0cd38"/></dir><file name="notification.phtml" hash="e706e5d080a768c30e399b0259bdeb6a"/><dir name="sales"><dir name="order"><dir name="view"><dir name="tab"><file name="info.phtml" hash="3c30b03519879b7ef0e5b37f44f4d823"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="chronorelais.xml" hash="940f6bbecfea90954bd6166cde50ad99"/></dir><dir name="template"><dir name="chronorelais"><dir name="checkout"><dir name="multishipping"><file name="shipping.phtml" hash="907963f1564fe4b8e54492d66bc69b4b"/><dir name="shipping_method"><file name="chronorelais.phtml" hash="6b5d24fc6b59bba4a18185e4d5df84a8"/></dir></dir><dir name="onepage"><dir name="shipping_method"><file name="available.phtml" hash="d0596b238d7daf5e858583add7da7b3f"/><file name="chronorelais.phtml" hash="061e1430d504c505ef6845d4435235af"/></dir><file name="shipping_method.phtml" hash="c218579e6c7f82921fd36a9a4d3a39af"/></dir></dir><dir name="sales"><dir name="order"><file name="history.phtml" hash="0fbf2362562fc2ee25d9843d1fc3ab3e"/><file name="recent.phtml" hash="2c9a57fd83862a931956a8e95a2d82bb"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Chronopost"><dir name="Chronorelais"><dir name="Block"><dir name="Adminhtml"><file name="Notification.php" hash="f8496d3e31ae22a567cabd35ad99f320"/><dir name="System"><dir name="Config"><file name="Checklogin.php" hash="163f40010cc47a564a7655ede95d73b0"/><dir name="Form"><dir name="Field"><file name="Config.php" hash="b38741ddd97fcae5dd276239fb3c6b70"/><file name="Enabled.php" hash="c04ab5ade5716bdb3da170961215d7bf"/></dir><file name="Fieldsetassurance.php" hash="b5dbc90058d4d2cd8365965e2a2dc821"/></dir></dir></dir></dir><dir name="Checkout"><dir name="Multishipping"><dir name="Shipping"><dir name="Method"><file name="Chronorelais.php" hash="867238885e2aee05a729ba2e8b6f5d51"/></dir></dir></dir><dir name="Onepage"><dir name="Shipping"><dir name="Method"><file name="Chronorelais.php" hash="2abbc99d42ac0b6d3c97a4de32130cd6"/></dir></dir></dir></dir><file name="Detail.php" hash="42437d3c2c262e10f62e7b83ad73ccad"/><dir name="Export"><dir name="Orders"><file name="Grid.php" hash="ff2868c86da4e6b7eaeb1aa0bf30487b"/></dir><file name="Orders.php" hash="9ada10bd85cb58122e722b3e82c71e37"/></dir><file name="Filter.php" hash="07712e19ee91e331e8e141d075a787a3"/><dir name="Import"><file name="Form.php" hash="56c6e3787c05e58d57b48ec4b1421468"/></dir><dir name="Sales"><dir name="Bordereau"><file name="Grid.php" hash="9448cd1620e69f11c6f21641a90a9902"/></dir><file name="Bordereau.php" hash="699028f61947ea13f6939c2d2e1be01d"/><file name="Impression.php" hash="619599b136b9cc49f01dba5b08ee8428"/><dir name="Order"><dir name="Shipment"><file name="View.php" hash="f5407d7d14aa59acb844479da5046900"/></dir></dir><dir name="Shipment"><dir name="Grid"><dir name="Renderer"><file name="Retoursav.php" hash="c3a1fb0229bc2a4fa4d24d5808f58114"/></dir></dir><file name="Grid.php" hash="990bea932942b104612c45600981fc11"/></dir></dir></dir><dir name="Controller"><file name="Abstract.php" hash="94680cd88c6af59764dedb613b08d5f6"/></dir><dir name="Helper"><file name="Data.php" hash="1d2dee890e665476c4810afc4d0dc98b"/><file name="Webservice.php" hash="1ed2917d19f0f95bc41e02fc43da7f5f"/></dir><dir name="Model"><dir name="Carrier"><file name="AbstractChronorelais.php" hash="f4957f6d660c4adb0328f9f2d73da1e2"/><file name="AbstractChronorelaisShipping.php" hash="300ca74ab4846b1c097e78b7a1085c8f"/><file name="Chronoexpress.php" hash="bc867a6b98966ada549a0b81ec334b64"/><file name="Chronopost.php" hash="c4d4525447d2801d28d921eaedc35a9a"/><file name="ChronopostC10.php" hash="bb642a19103ce9a40ef1725fd5cf22bd"/><file name="ChronopostC18.php" hash="85419f76cf74e93d7385dd98c04587a7"/><file name="ChronopostCClassic.php" hash="2195866755728930b16695d06d06feb1"/><file name="Chronorelais.php" hash="5cfcb83c23d05585fdc50f8b2747fc40"/></dir><dir name="Config"><dir name="Source"><file name="Civility.php" hash="fe6ec6eebe6faffdd0bb65479d91cd5d"/><file name="EndOfLineCharacter.php" hash="3fe6b6069a9efdc29ad0d3f7d1cf4794"/><file name="FieldDelimiter.php" hash="3e023d40aeca50932e62ff97eed6317e"/><file name="FieldSeparator.php" hash="ce30c5974a893bd5467334d574dd578a"/><file name="FileCharset.php" hash="6cc4ebab95735bd121af16e0eedd90d6"/><file name="FileExtension.php" hash="597c3e78e7584bf7c4b7b2ebad6d2a65"/><file name="PrintMode.php" hash="67e8a6e98e12c7e72624ba5322076c00"/><file name="WeightUnit.php" hash="97ed82ddf61e05a094ba1a04982d0010"/></dir></dir><dir name="Sales"><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Shipping.php" hash="2e69db363011f84ef2cdb5d0e9d4c4df"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AjaxController.php" hash="6a50dd7b5e74a9132d6986b7e596147b"/><dir name="Checkout"><file name="MultishippingController.php" hash="5841817a54f05995454e4b0bbc792f4d"/><file name="OnepageController.php" hash="b70eea145708edc145858d7cf5fae091"/></dir><file name="ExportController.php" hash="c9adf4b0f9ed478efc2a5bc75cf0bbef"/><file name="ImportController.php" hash="964bf705b593bede1fc3b93e02fb37f2"/><file name="RelaisController.php" hash="5d48155ddb7cc2d4effbbfdeb4f3946d"/><dir name="Sales"><file name="BordereauController.php" hash="1102091b04b0af8f0d88bb6888f5fffd"/><file name="ImpressionController.php" hash="06d4777f7a51620a1e211c71dfcc7227"/><dir name="Order"><file name="ShipmentController.php" hash="db0aa2ad9e99d4b4e23548a0c5b5a743"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="78a1b10ce676b87a2d9f7be71079765a"/><file name="system.xml" hash="c4cf1c01931456dfa97c87a32ff5ff36"/></dir><dir name="includes"><file name="ChronorelaisShippingHelper.php" hash="47dc5560d25bcd940560c05238b5e913"/><file name="countries.inc.php" hash="ba7f3ed0d1adb87d928a6389fc722906"/></dir><dir name="sql"><dir name="chronorelais_setup"><file name="mysql4-install-0.1.0.php" hash="c307802a7bd10c1ecce06799b04569c2"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="ea3358055a851a96b673c721202045be"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="961f41dc1012d0917504f9bb5f5d106c"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="b85470889421f652c3d01b96072f579c"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="def69d0ae26b0d130d2ce6e0838e5d7f"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Chronopost_Chronorelais.csv" hash="76475aa4fa500c135a666e47bab62ddf"/></dir><dir name="fr_FR"><file name="Chronopost_Chronorelais.csv" hash="3f383558f7019b884d9c01ceab372ce4"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="chronorelais"><file name="Logo-Chronopost.jpg" hash="cc1226ebcd7236ce021076657ac22265"/><file name="Picto_Chrono_Relais.png" hash="1ea0f0c410d237adf23d5905cd8431f5"/><file name="Thumbs.db" hash="2e16ed23c37d1aa29a6caf73f513a648"/><file name="ac.png" hash="0c04f70da35d43a2636cfbd6ad2b10d5"/><file name="chronopost.png" hash="51ec3f1b8f0c970749ff24000bf7c162"/><file name="chronorelais.css" hash="a8d0ec0c82669a100a8951b31e6604ea"/><file name="chronorelais.png" hash="b3a8e94469113e5814c268cc6de66a2e"/><file name="chronorelaismap.js" hash="eee78175275ed0545dcdc710186ddbef"/><file name="home.png" hash="7904b495e94047eb3406e260bc660cce"/><file name="ico_ac_shaded.gif" hash="e55d9b2071fb976cf5331b6273a40731"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="WSChronopost_Chronorelais.xml" hash="e614759d6b46c0c25f6c26d6e9dff45a"/></dir></target><target name="mage"><dir name="js"><dir name="chronopost"><dir name="chronorelais"><file name="chronorelais.js" hash="9c55c7a13327be44a8c4fde0f272fb35"/><file name="ocseditor.css" hash="1bfc847153768d6729cdad7cb1abe443"/><file name="ocseditor.js" hash="8b7f29ddf7faff2fd3a63af18ba666aa"/></dir></dir></dir></target></contents>
42
  <compatible/>
43
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
44
  </package>
skin/frontend/default/default/chronorelais/chronopost.png CHANGED
Binary file
skin/frontend/default/default/chronorelais/chronorelais.css CHANGED
@@ -1,46 +1,46 @@
1
- /* styles for chrono relais */
2
-
3
- .chronorelais-list { }
4
- .sp-methods-chronorelais { padding:5px 20px;}
5
- sp-methods-chronorelais dd li { clear:both;}
6
- .chronorelaismap { margin:20px 0px 10px 0px; }
7
- .chronorelaismap .mappostalcode { margin-bottom:10px; text-align:right;}
8
- .sp-methods .method-description { clear:both; }
9
- .sp-methods .method-radio, .sp-methods .method-image, .sp-methods .method-contents { }
10
- .sp-methods .method-image { padding:0 10px;}
11
-
12
- /*****************************
13
- sw-Gmap
14
- *******************************/
15
- .chronomap { height:450px; width:100%; overflow:hidden!mportant; font:82.5%/1.3 Arial,Helvetica,sans-serif; background-color: #E5E3DF; border: 1px solid #aaa;}
16
- .chronomap *{float:none;overflow:visible;font-family: Arial,sans-serif;}
17
- .chronomap a {color:#0000cc;outline:none;}
18
- .chronomap h4{font-size:14px;margin-bottom:6px;border-bottom:1px solid #ccc;}
19
- .chronomap h2{font-size:16px;margin:2px 10px 6px 0; font-weight:bold;}
20
-
21
- /*****************************
22
- Infowindow
23
- *******************************/
24
- .chronomap .sw-infowindow a{cursor:pointer;}
25
- #sw-infowindow-info{max-height:400px}
26
- #sw-infowindow-hor{height:150px}
27
- .sw-map-adresse-wrp{min-height:90px}
28
- .sw-map-adresse{font-size:1.2em;margin:5px 0 8px 0;line-height:1.45em;}
29
- .sw-map-tools a{font-size:12px;}
30
- .chronomap .sw-desc{display:block;font-weight:bold;line-height:16px;float:none!important;width:auto;}
31
- .chronomap .sw-help{display:block;float:none!important;width:auto;clear:both;}
32
- .sw-map-itin-tools{font-size:11px;padding:8px 0;display:block;}
33
- .sw-back-link{font-size:11px;display:block;text-align:right;margin:0px ;}
34
- #sw-sendbymail-wrap{height:220px;overflow:hidden;}
35
- .chronomap .sw-textarea{height:30px;}
36
- .sw-tool-itineraire{height:220px;}
37
- /*****************************
38
- Tables
39
- *******************************/
40
- .sw-table {border-collapse:collapse; width:100%;}
41
- .sw-table td {font-size:1.2em;border-bottom:1px solid #ccc; padding:1px 0px;}
42
- .sw-table th{background:#eee;font-size:1.3em;border-top:1px solid #555}
43
- #sw-table-horaire-client td ,#sw-table-horaire-depot td{width:50%;}
44
- #sw-table-horaire-client{}
45
- #sw-table-horaire-depot{margin-top:8px;}
46
- /*****************************
1
+ /* styles for chrono relais */
2
+
3
+ .chronorelais-list { }
4
+ .sp-methods-chronorelais { padding:5px 20px;}
5
+ sp-methods-chronorelais dd li { clear:both;}
6
+ .chronorelaismap { margin:20px 0px 10px 0px; }
7
+ .chronorelaismap .mappostalcode { margin-bottom:10px; text-align:right;}
8
+ .sp-methods .method-description { clear:both; }
9
+ .sp-methods .method-radio, .sp-methods .method-image, .sp-methods .method-contents { }
10
+ .sp-methods .method-image { padding:0 10px;}
11
+
12
+ /*****************************
13
+ sw-Gmap
14
+ *******************************/
15
+ .chronomap { height:450px; width:100%; overflow:hidden!mportant; font:82.5%/1.3 Arial,Helvetica,sans-serif; background-color: #E5E3DF; border: 1px solid #aaa;}
16
+ .chronomap *{float:none;overflow:visible;font-family: Arial,sans-serif;}
17
+ .chronomap a {color:#0000cc;outline:none;}
18
+ .chronomap h4{font-size:14px;margin-bottom:6px;border-bottom:1px solid #ccc;}
19
+ .chronomap h2{font-size:16px;margin:2px 10px 6px 0; font-weight:bold;}
20
+
21
+ /*****************************
22
+ Infowindow
23
+ *******************************/
24
+ .chronomap .sw-infowindow a{cursor:pointer;}
25
+ #sw-infowindow-info{max-height:400px}
26
+ #sw-infowindow-hor{height:150px}
27
+ .sw-map-adresse-wrp{min-height:90px}
28
+ .sw-map-adresse{font-size:1.2em;margin:5px 0 8px 0;line-height:1.45em;}
29
+ .sw-map-tools a{font-size:12px;}
30
+ .chronomap .sw-desc{display:block;font-weight:bold;line-height:16px;float:none!important;width:auto;}
31
+ .chronomap .sw-help{display:block;float:none!important;width:auto;clear:both;}
32
+ .sw-map-itin-tools{font-size:11px;padding:8px 0;display:block;}
33
+ .sw-back-link{font-size:11px;display:block;text-align:right;margin:0px ;}
34
+ #sw-sendbymail-wrap{height:220px;overflow:hidden;}
35
+ .chronomap .sw-textarea{height:30px;}
36
+ .sw-tool-itineraire{height:220px;}
37
+ /*****************************
38
+ Tables
39
+ *******************************/
40
+ .sw-table {border-collapse:collapse; width:100%;}
41
+ .sw-table td {font-size:1.2em;border-bottom:1px solid #ccc; padding:1px 0px;}
42
+ .sw-table th{background:#eee;font-size:1.3em;border-top:1px solid #555}
43
+ #sw-table-horaire-client td ,#sw-table-horaire-depot td{width:50%;}
44
+ #sw-table-horaire-client{}
45
+ #sw-table-horaire-depot{margin-top:8px;}
46
+ /*****************************
skin/frontend/default/default/chronorelais/chronorelais.png CHANGED
Binary file
skin/frontend/default/default/chronorelais/chronorelaismap.js CHANGED
@@ -1,567 +1,567 @@
1
- var gmarkers = [];
2
- var map;
3
- var homeaddress = "";
4
- var addressrelais = [];
5
- var relaylatan = [];
6
- var next_pt = 0;
7
- var hidehomeicon = false;
8
- var currentInfoWindow;
9
-
10
- function loadMyPoint(i) {
11
- google.maps.event.trigger(gmarkers[i], "click");
12
- }
13
-
14
- var bounds = new google.maps.LatLngBounds();
15
- function loadRelayMap(address, relaisArray, nextpt, mapid) {
16
- var geo = new google.maps.Geocoder();
17
-
18
- var myOptions = {
19
- zoom: 5,
20
- center: new google.maps.LatLng(47.37285025362682, 2.4172996312499784),
21
- mapTypeId: google.maps.MapTypeId.ROADMAP
22
- }
23
- map = new google.maps.Map(document.getElementById(mapid), myOptions);
24
-
25
- var blueIcon = new google.maps.MarkerImage(Picto_Chrono_Relais);
26
-
27
- var homeIcon = new google.maps.MarkerImage(Home_Chrono_Icon);
28
-
29
- if(!homeaddress && !hidehomeicon) {
30
- var ship_address = getShipAddress(); //get shipping address to set home address
31
- homeaddress = relaisArray.codePostal + " " + relaisArray.localite;
32
- if(ship_address) { homeaddress = ship_address+" "+homeaddress; }
33
-
34
- geo.geocode({'address': homeaddress}, function(results, status) {
35
- if (status == google.maps.GeocoderStatus.OK) {
36
- var point = results[0].geometry.location;
37
- var marker = new google.maps.Marker({
38
- position: point,
39
- map: map,
40
- title: 'home',
41
- icon: homeIcon
42
- });
43
- map.setCenter(point, 11);
44
- }
45
- });
46
- }
47
-
48
- function createTabbedMarker(point, relaisArray) {
49
- addressrelais.push(relaisArray);
50
- var label = nextpt;
51
- var relaypoint_id = relaisArray.identifiantChronopostPointA2PAS;
52
- var marker = new google.maps.Marker({map: map, position: point, title:relaisArray.nomEnseigne, icon:blueIcon});
53
-
54
- var infowindow = new google.maps.InfoWindow({
55
- content: '<div style="width: 400px;"><div style="width: 190px; float: left;"><h2>Infos</h2>'+getMarkerInfoContent(relaisArray) + getActionsForm(addressrelais.length)+'</div><div style="margin-left: 10px; padding-left: 10px; border-left: 1px solid #000; float: left;"><h2>Horaires</h2><div style="width: 189px">'+getHorairesTab(relaisArray, true)+'</div></div></div>'
56
- });
57
-
58
- google.maps.event.addListener(marker, 'click', function() {
59
- if(document.getElementById('s_method_chronorelais_'+relaisArray.identifiantChronopostPointA2PAS))
60
- document.getElementById('s_method_chronorelais_'+relaisArray.identifiantChronopostPointA2PAS).checked = true;
61
-
62
- if (currentInfoWindow) {
63
- currentInfoWindow.close();
64
- }
65
- infowindow.open(map,marker);
66
- currentInfoWindow = infowindow;
67
- });
68
-
69
- gmarkers[relaypoint_id] = marker;
70
- return marker;
71
- }
72
-
73
- function showAddress(address, relaisArray) {
74
- var search = address;
75
- // ====== Perform the Geocoding ======
76
- geo.geocode({'address': search}, function(results, status)
77
- {
78
- // If that was successful
79
- if (status == google.maps.GeocoderStatus.OK) {
80
- // Loop through the results, placing markers
81
- //for (var i=0; i<result.Placemark.length; i++) {
82
- for (var i=0; i<1; i++) {
83
- var p = results[i].geometry.location;
84
- relaylatan.push(p);
85
- var marker = createTabbedMarker(p, relaisArray);
86
- // ==== Each time a point is found, extent the bounds ato include it =====
87
- bounds.extend(p);
88
- }
89
- // centre the map on the first result
90
- //!homeaddress && hidehomeicon &&
91
- if(nextpt==5) {
92
- var p = results[0].geometry.location;
93
- // ===== determine the zoom level from the bounds =====
94
- map.fitBounds(bounds);
95
- // ===== determine the centre from the bounds ======
96
- map.setCenter(bounds.getCenter());
97
- }
98
- }
99
- // ====== Decode the error status ======
100
- else {
101
- var reason = "Code " + status;
102
- /*
103
- if (reasons[status]) {
104
- reason = reasons[status]
105
- }
106
- */
107
- alert('Could not find "' + search + '" ' + reason);
108
- }
109
- });
110
- }
111
- showAddress(address, relaisArray);
112
- } // end of loadRelayMap function
113
-
114
- function addEvent( obj, type, fn ) {
115
- if ( obj.attachEvent ) {
116
- obj["e"+type+fn] = fn;
117
- obj[type+fn] = function() { obj["e"+type+fn]( window.event ) };
118
- obj.attachEvent( "on"+type, obj[type+fn] );
119
- }
120
- else{
121
- obj.addEventListener( type, fn, false );
122
- }
123
- }
124
-
125
- function getMarkerInfoContent(relaisArray){
126
- var icoPath = Picto_Chrono_Relais;
127
- var content="<div class=\"sw-map-adresse-wrp\" style=\"background-image: url("+ icoPath +"); background-repeat: no-repeat;padding-left:50px;\">"
128
- + "<h2>"+relaisArray.nomEnseigne+"</h2>"
129
- + "<div class=\"sw-map-adresse\">"
130
- + parseAdresse(relaisArray)
131
- + relaisArray.codePostal + " " + relaisArray.localite
132
- + "</div></div>";
133
- return content;
134
- }
135
- function getActionsForm(label)
136
- {
137
- var html = '<div class="sw-map-tools"><a href="javascript:printPage('+label+')">Imprimer</a>'
138
- + '</div>';
139
- return html;
140
- }
141
-
142
- function getHorairesTab(anArray, highlight)
143
- {
144
- var userAgent = navigator.userAgent.toLowerCase();
145
- var msie = /msie/.test( userAgent ) && !/opera/.test( userAgent );
146
-
147
- var rs = "" ;
148
- rs = "<table id=\"sw-table-horaire\" class=\"sw-table\"";
149
- if(msie) {
150
- rs += " style=\"width:auto;\"";
151
- }
152
- rs += ">"
153
- + "<tr><td>Lun:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureLundi, 1, highlight) +"</tr>"
154
- + "<tr><td>Mar:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureMardi, 2, highlight) +"</tr>"
155
- + "<tr><td>Mer:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureMercredi, 3, highlight) +"</tr>"
156
- + "<tr><td>Jeu:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureJeudi, 4, highlight) +"</tr>"
157
- + "<tr><td>Ven:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureVendredi, 5, highlight) +"</tr>"
158
- + "<tr><td>Sam:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureSamedi, 6, highlight) +"</tr>"
159
- + "<tr><td>Dim:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureDimanche, 0, highlight) +"</tr>"
160
- + "</table>" ;
161
- return rs ;
162
- }
163
-
164
- function parseAdresse(anArray)
165
- {
166
- var address = anArray.adresse1 + "<br />" ;
167
- if (anArray.adresse2)
168
- address += anArray.adresse2 + "<br />" ;
169
- if (anArray.adresse3)
170
- address += anArray.adresse3 + "<br />" ;
171
- return address ;
172
- }
173
-
174
- function parseHorairesOuverture(value , day, highlight)
175
- {
176
- var rs = "" ;
177
-
178
- var now = new Date() ;
179
- var today = now.getDay() ; // number of day
180
- var attributedCell = "" ;
181
- var reg = new RegExp(" ", "g");
182
-
183
- var horaires = value.split(reg) ;
184
-
185
- for (var i=0; i < horaires.length; i++)
186
- {
187
- // first define the attributes for the current cell
188
- /* Aucun jour n'est mis en exergue car on ne sait pas quel sera le jour de livraison
189
- if ( highlight == true && day == today)
190
- {
191
- attributedCell = "style=\"color:red;\"" ;
192
- }
193
- else
194
- {
195
- */
196
- attributedCell = "" ;
197
- /*
198
- }
199
- */
200
-
201
- // so, re-format time
202
- if (horaires[i] == "00:00-00:00")
203
- {
204
- horaires[i] = "<td "+attributedCell+">Ferm&eacute;</td>" ;
205
- }
206
- else
207
- {
208
- horaires[i] = "<td "+attributedCell+">"+horaires[i]+"</td>" ;
209
- }
210
-
211
- // yeah, concatenates result to the returned value
212
- rs += horaires[i] ;
213
- }
214
-
215
- return rs ;
216
- }
217
-
218
- function printPage(i)
219
- {
220
- var fen=open("","Impression");
221
- fen.focus();
222
- var baseURL = "http://www.chronopost.fr/transport-express/webdav/site/chronov4/groups/administrators/public/Chronomaps/" ;
223
- var latlngpoint = relaylatan[i-1];
224
- if(latlngpoint) {
225
- fen.location.href = baseURL
226
- + "print-result.html?request=print&"
227
- + btQueryString(addressrelais[i-1], true).replace(/00%3A00-00%3A00/gi, 'Ferm%E9')
228
- + "&rtype=chronorelais"
229
- + "&icnname=ac"
230
- + "&lat=" + latlngpoint.lat()
231
- + "&lng=" + latlngpoint.lng()
232
- + "&sw-form-type-point=opt_chrlas"
233
- + "&is_print_direction=" + false
234
- + "&from_addr="
235
- + "&to_addr=";
236
- }
237
- }
238
-
239
- function btQueryString(anArray, needEscape)
240
- {
241
- var rs = "" ;
242
- for (key in anArray)
243
- {
244
- if (needEscape == true)
245
- {
246
- if(anArray[key]) {
247
- if (rs != "")
248
- rs += "&"
249
- rs += key +"=" + escape(anArray[key]) ;
250
- }
251
- }
252
- else
253
- {
254
- if(anArray[key]) {
255
- if (rs != "")
256
- rs += "_-_"
257
- rs += key +"=" + anArray[key] ;
258
- }
259
- }
260
- }
261
- return rs ;
262
- }
263
-
264
- function getShipAddress() {
265
- var ship_address = '';
266
- if($('shipping:same_as_billing').checked) {
267
- if ($('billing-address-select') && $('billing-address-select').value) {
268
- var e = $('billing-address-select');
269
- var address_value = e.options[e.selectedIndex].text;
270
- var shipping_address = address_value.split(',');
271
- if(shipping_address[1]) {
272
- ship_address = shipping_address[1];
273
- }
274
- } else {
275
- if($('billing:street1')) { ship_address = $('billing:street1').value; }
276
- if($('billing:street2')) { ship_address = ship_address+" "+$('billing:street2').value; }
277
- if($('billing:street3')) { ship_address = ship_address+" "+$('billing:street3').value; }
278
- }
279
- } else {
280
- if ($('shipping-address-select') && $('shipping-address-select').value) {
281
- var e = $('shipping-address-select');
282
- var address_value = e.options[e.selectedIndex].text;
283
- var shipping_address = address_value.split(',');
284
- if(shipping_address[1]) {
285
- ship_address = shipping_address[1];
286
- }
287
- } else {
288
- if($('shipping:street1')) { ship_address = $('shipping:street1').value; }
289
- if($('shipping:street2')) { ship_address = ship_address+" "+$('shipping:street2').value; }
290
- if($('shipping:street3')) { ship_address = ship_address+" "+$('shipping:street3').value; }
291
- }
292
- }
293
- return ship_address;
294
- }
295
-
296
- /** Map content end **/
297
-
298
-
299
- // shipping method
300
- var ShippingMethod = Class.create();
301
- ShippingMethod.prototype = {
302
- initialize: function(form, saveUrl){
303
- this.form = form;
304
- if ($(this.form)) {
305
- $(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
306
- }
307
- this.saveUrl = saveUrl;
308
- this.validator = new Validation(this.form);
309
- this.onSave = this.nextStep.bindAsEventListener(this);
310
- this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
311
- },
312
-
313
- validate: function() {
314
- var methods = document.getElementsByName('shipping_method');
315
- if (methods.length==0) {
316
- alert(Translator.translate('Your order cannot be completed at this time as there is no shipping methods available for it. Please make neccessary changes in your shipping address.'));
317
- return false;
318
- }
319
-
320
- if(!this.validator.validate()) {
321
- return false;
322
- }
323
-
324
- for (var i=0; i<methods.length; i++) {
325
- if (methods[i].checked) {
326
- if (methods[i].value == 'chronorelais_chronorelais') {
327
- var submethods = document.getElementsByName('shipping_method_chronorelais');
328
- if (submethods.length==0) {
329
- alert(Translator.translate('Your order cannot be completed at this time as there is no shipping methods available for it. Please make neccessary changes in your shipping address.'));
330
- return false;
331
- }
332
- for (var j=0; j<submethods.length; j++) {
333
- if (submethods[j].checked) {
334
- return true;
335
- }
336
- }
337
- } else {
338
- return true;
339
- }
340
- }
341
- }
342
- alert(Translator.translate('Please specify shipping method.'));
343
- return false;
344
- },
345
-
346
- getrelais: function(url){
347
- if (checkout.loadWaiting!=false) return;
348
- //if (this.validate()) {
349
- checkout.setLoadWaiting('shipping-method');
350
- hidehomeicon = false;
351
- var request = new Ajax.Request(
352
- url,
353
- {
354
- method:'post',
355
- onComplete: this.onComplete,
356
- onSuccess: this.onSave,
357
- onFailure: checkout.ajaxFailure.bind(checkout),
358
- parameters: Form.serialize(this.form)
359
- }
360
- );
361
- //}
362
- },
363
-
364
- changePostalCode: function(url){
365
- if (checkout.loadWaiting!=false) return;
366
- //if (this.validate()) {
367
- if(!$('mappostalcode').value) { return false; }
368
- checkout.setLoadWaiting('shipping-method');
369
- $('mappostalcodebtn').hide();
370
- $('postalcode-please-wait').show();
371
- $('postalcode-please-wait').style.opacity = '0.5';
372
- hidehomeicon = true;
373
- var request = new Ajax.Request(
374
- url,
375
- {
376
- method:'post',
377
- onComplete: this.onComplete,
378
- onSuccess: this.onSave,
379
- onFailure: checkout.ajaxFailure.bind(checkout),
380
- parameters: Form.serialize(this.form)
381
- }
382
- );
383
- //}
384
- },
385
-
386
- hiderelais: function(url){
387
- if($('checkout-shipping-method-chronorelais-load')) {
388
- $('checkout-shipping-method-chronorelais-load').innerHTML = "";
389
- }
390
- },
391
-
392
- save: function(){
393
-
394
- if (checkout.loadWaiting!=false) return;
395
- if (this.validate()) {
396
- checkout.setLoadWaiting('shipping-method');
397
- var request = new Ajax.Request(
398
- this.saveUrl,
399
- {
400
- method:'post',
401
- onComplete: this.onComplete,
402
- onSuccess: this.onSave,
403
- onFailure: checkout.ajaxFailure.bind(checkout),
404
- parameters: Form.serialize(this.form)
405
- }
406
- );
407
- }
408
- },
409
-
410
- resetLoadWaiting: function(transport){
411
- checkout.setLoadWaiting(false);
412
- },
413
-
414
- nextStep: function(transport){
415
- if (transport && transport.responseText){
416
- try{
417
- response = eval('(' + transport.responseText + ')');
418
- }
419
- catch (e) {
420
- response = {};
421
- }
422
- }
423
-
424
- if (response.error) {
425
- alert(response.message);
426
- if($('mappostalcodebtn')) { $('mappostalcodebtn').show(); }
427
- if($('postalcode-please-wait')) { $('postalcode-please-wait').hide(); }
428
- return false;
429
- }
430
-
431
- if (response.update_section) {
432
- $('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
433
- response.update_section.html.evalScripts();
434
-
435
- if(response.relaypoints) {
436
- if(response.relaypoints.length>0) {
437
- var relayaddress = "";
438
- gmarkers = [];
439
- addressrelais = [];
440
- relaylatan = [];
441
- homeaddress = "";
442
- next_pt = 0;
443
- bounds = new google.maps.LatLngBounds();
444
- for(var s=0; s<response.relaypoints.length; s++) {
445
- next_pt = s+1;
446
- relayaddress = response.relaypoints[s].adresse1;
447
- if(response.relaypoints[s].codePostal)
448
- relayaddress += " "+response.relaypoints[s].codePostal;
449
- if(response.relaypoints[s].localite)
450
- relayaddress += " "+response.relaypoints[s].localite;
451
- loadRelayMap(relayaddress, response.relaypoints[s], next_pt, "chronomap");
452
- }
453
- }
454
- }
455
- }
456
-
457
- payment.initWhatIsCvvListeners();
458
-
459
- if (response.goto_section) {
460
- checkout.gotoSection(response.goto_section);
461
- checkout.reloadProgressBlock();
462
- return;
463
- }
464
-
465
- if (response.payment_methods_html) {
466
- $('checkout-payment-method-load').update(response.payment_methods_html);
467
- }
468
-
469
- checkout.setShippingMethod();
470
- }
471
- }
472
-
473
- // shipping method
474
- var multiindex = "";
475
- var MultiShippingMethod = Class.create();
476
- MultiShippingMethod.prototype = {
477
- initialize: function(){
478
- this.loadWaiting = false;
479
- this.onComplete = this.complete.bindAsEventListener(this);
480
- },
481
-
482
- getrelais: function(url, index, home){
483
- if (this.loadWaiting!=false) return;
484
- this.loadWaiting = true;
485
- homeaddress = home;
486
- hidehomeicon = false;
487
- multiindex = "_" + index;
488
- var request = new Ajax.Request(
489
- url,
490
- {
491
- method:'post',
492
- onComplete: this.onComplete
493
- }
494
- );
495
-
496
- },
497
-
498
- changePostalCode: function(url, index){
499
- if (this.loadWaiting!=false) return;
500
- this.loadWaiting = true;
501
- multiindex = "_" + index;
502
- if(!$('mappostalcode' + multiindex).value) { return false; }
503
- homeaddress = $('mappostalcode' + multiindex).value;
504
- $('mappostalcodebtn' + multiindex).hide();
505
- $('postalcode-please-wait' + multiindex).show();
506
- $('postalcode-please-wait' + multiindex).style.opacity = '0.5';
507
- hidehomeicon = true;
508
- var request = new Ajax.Request(
509
- url + '&zip=' + $('mappostalcode' + multiindex).value,
510
- {
511
- method:'post',
512
- onComplete: this.onComplete
513
- }
514
- );
515
- },
516
-
517
- hiderelais: function(url, index){
518
- if($('checkout-shipping-method-chronorelais-load_' + index)) {
519
- $('checkout-shipping-method-chronorelais-load_' + index).innerHTML = "";
520
- }
521
- },
522
-
523
- complete: function(transport){
524
- this.loadWaiting = false;
525
-
526
- if (transport && transport.responseText){
527
- try{
528
- response = eval('(' + transport.responseText + ')');
529
- }
530
- catch (e) {
531
- response = {};
532
- }
533
- }
534
-
535
- if (response.error) {
536
- alert(response.message);
537
- if($('mappostalcodebtn' + multiindex)) { $('mappostalcodebtn' + multiindex).show(); }
538
- if($('postalcode-please-wait' + multiindex)) { $('postalcode-please-wait' + multiindex).hide(); }
539
- return false;
540
- }
541
-
542
- if (response.update_section) {
543
- $(response.update_section.name).update(response.update_section.html);
544
- response.update_section.html.evalScripts();
545
-
546
- if(response.relaypoints) {
547
- if(response.relaypoints.length>0) {
548
- var relayaddress = "";
549
- gmarkers = [];
550
- addressrelais = [];
551
- relaylatan = [];
552
- next_pt = 0;
553
- bounds = new google.maps.LatLngBounds();
554
- for(var s=0; s<response.relaypoints.length; s++) {
555
- next_pt = s+1;
556
- relayaddress = response.relaypoints[s].adresse1;
557
- if(response.relaypoints[s].codePostal)
558
- relayaddress += " "+response.relaypoints[s].codePostal;
559
- if(response.relaypoints[s].localite)
560
- relayaddress += " "+response.relaypoints[s].localite;
561
- loadRelayMap(relayaddress, response.relaypoints[s], next_pt, 'chronomap' + multiindex);
562
- }
563
- }
564
- }
565
- }
566
- }
567
- }
1
+ var gmarkers = [];
2
+ var map;
3
+ var homeaddress = "";
4
+ var addressrelais = [];
5
+ var relaylatan = [];
6
+ var next_pt = 0;
7
+ var hidehomeicon = false;
8
+ var currentInfoWindow;
9
+
10
+ function loadMyPoint(i) {
11
+ google.maps.event.trigger(gmarkers[i], "click");
12
+ }
13
+
14
+ var bounds = new google.maps.LatLngBounds();
15
+ function loadRelayMap(address, relaisArray, nextpt, mapid) {
16
+ var geo = new google.maps.Geocoder();
17
+
18
+ var myOptions = {
19
+ zoom: 5,
20
+ center: new google.maps.LatLng(47.37285025362682, 2.4172996312499784),
21
+ mapTypeId: google.maps.MapTypeId.ROADMAP
22
+ }
23
+ map = new google.maps.Map(document.getElementById(mapid), myOptions);
24
+
25
+ var blueIcon = new google.maps.MarkerImage(Picto_Chrono_Relais);
26
+
27
+ var homeIcon = new google.maps.MarkerImage(Home_Chrono_Icon);
28
+
29
+ if(!homeaddress && !hidehomeicon) {
30
+ var ship_address = getShipAddress(); //get shipping address to set home address
31
+ homeaddress = relaisArray.codePostal + " " + relaisArray.localite;
32
+ if(ship_address) { homeaddress = ship_address+" "+homeaddress; }
33
+
34
+ geo.geocode({'address': homeaddress}, function(results, status) {
35
+ if (status == google.maps.GeocoderStatus.OK) {
36
+ var point = results[0].geometry.location;
37
+ var marker = new google.maps.Marker({
38
+ position: point,
39
+ map: map,
40
+ title: 'home',
41
+ icon: homeIcon
42
+ });
43
+ map.setCenter(point, 11);
44
+ }
45
+ });
46
+ }
47
+
48
+ function createTabbedMarker(point, relaisArray) {
49
+ addressrelais.push(relaisArray);
50
+ var label = nextpt;
51
+ var relaypoint_id = relaisArray.identifiantChronopostPointA2PAS;
52
+ var marker = new google.maps.Marker({map: map, position: point, title:relaisArray.nomEnseigne, icon:blueIcon});
53
+
54
+ var infowindow = new google.maps.InfoWindow({
55
+ content: '<div style="width: 400px;"><div style="width: 190px; float: left;"><h2>Infos</h2>'+getMarkerInfoContent(relaisArray) + getActionsForm(addressrelais.length)+'</div><div style="margin-left: 10px; padding-left: 10px; border-left: 1px solid #000; float: left;"><h2>Horaires</h2><div style="width: 189px">'+getHorairesTab(relaisArray, true)+'</div></div></div>'
56
+ });
57
+
58
+ google.maps.event.addListener(marker, 'click', function() {
59
+ if(document.getElementById('s_method_chronorelais_'+relaisArray.identifiantChronopostPointA2PAS))
60
+ document.getElementById('s_method_chronorelais_'+relaisArray.identifiantChronopostPointA2PAS).checked = true;
61
+
62
+ if (currentInfoWindow) {
63
+ currentInfoWindow.close();
64
+ }
65
+ infowindow.open(map,marker);
66
+ currentInfoWindow = infowindow;
67
+ });
68
+
69
+ gmarkers[relaypoint_id] = marker;
70
+ return marker;
71
+ }
72
+
73
+ function showAddress(address, relaisArray) {
74
+ var search = address;
75
+ // ====== Perform the Geocoding ======
76
+ geo.geocode({'address': search}, function(results, status)
77
+ {
78
+ // If that was successful
79
+ if (status == google.maps.GeocoderStatus.OK) {
80
+ // Loop through the results, placing markers
81
+ //for (var i=0; i<result.Placemark.length; i++) {
82
+ for (var i=0; i<1; i++) {
83
+ var p = results[i].geometry.location;
84
+ relaylatan.push(p);
85
+ var marker = createTabbedMarker(p, relaisArray);
86
+ // ==== Each time a point is found, extent the bounds ato include it =====
87
+ bounds.extend(p);
88
+ }
89
+ // centre the map on the first result
90
+ //!homeaddress && hidehomeicon &&
91
+ if(nextpt==5) {
92
+ var p = results[0].geometry.location;
93
+ // ===== determine the zoom level from the bounds =====
94
+ map.fitBounds(bounds);
95
+ // ===== determine the centre from the bounds ======
96
+ map.setCenter(bounds.getCenter());
97
+ }
98
+ }
99
+ // ====== Decode the error status ======
100
+ else {
101
+ var reason = "Code " + status;
102
+ /*
103
+ if (reasons[status]) {
104
+ reason = reasons[status]
105
+ }
106
+ */
107
+ alert('Could not find "' + search + '" ' + reason);
108
+ }
109
+ });
110
+ }
111
+ showAddress(address, relaisArray);
112
+ } // end of loadRelayMap function
113
+
114
+ function addEvent( obj, type, fn ) {
115
+ if ( obj.attachEvent ) {
116
+ obj["e"+type+fn] = fn;
117
+ obj[type+fn] = function() { obj["e"+type+fn]( window.event ) };
118
+ obj.attachEvent( "on"+type, obj[type+fn] );
119
+ }
120
+ else{
121
+ obj.addEventListener( type, fn, false );
122
+ }
123
+ }
124
+
125
+ function getMarkerInfoContent(relaisArray){
126
+ var icoPath = Picto_Chrono_Relais;
127
+ var content="<div class=\"sw-map-adresse-wrp\" style=\"background-image: url("+ icoPath +"); background-repeat: no-repeat;padding-left:50px;\">"
128
+ + "<h2>"+relaisArray.nomEnseigne+"</h2>"
129
+ + "<div class=\"sw-map-adresse\">"
130
+ + parseAdresse(relaisArray)
131
+ + relaisArray.codePostal + " " + relaisArray.localite
132
+ + "</div></div>";
133
+ return content;
134
+ }
135
+ function getActionsForm(label)
136
+ {
137
+ var html = '<div class="sw-map-tools"><a href="javascript:printPage('+label+')">Imprimer</a>'
138
+ + '</div>';
139
+ return html;
140
+ }
141
+
142
+ function getHorairesTab(anArray, highlight)
143
+ {
144
+ var userAgent = navigator.userAgent.toLowerCase();
145
+ var msie = /msie/.test( userAgent ) && !/opera/.test( userAgent );
146
+
147
+ var rs = "" ;
148
+ rs = "<table id=\"sw-table-horaire\" class=\"sw-table\"";
149
+ if(msie) {
150
+ rs += " style=\"width:auto;\"";
151
+ }
152
+ rs += ">"
153
+ + "<tr><td>Lun:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureLundi, 1, highlight) +"</tr>"
154
+ + "<tr><td>Mar:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureMardi, 2, highlight) +"</tr>"
155
+ + "<tr><td>Mer:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureMercredi, 3, highlight) +"</tr>"
156
+ + "<tr><td>Jeu:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureJeudi, 4, highlight) +"</tr>"
157
+ + "<tr><td>Ven:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureVendredi, 5, highlight) +"</tr>"
158
+ + "<tr><td>Sam:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureSamedi, 6, highlight) +"</tr>"
159
+ + "<tr><td>Dim:</td>"+ parseHorairesOuverture(anArray.horairesOuvertureDimanche, 0, highlight) +"</tr>"
160
+ + "</table>" ;
161
+ return rs ;
162
+ }
163
+
164
+ function parseAdresse(anArray)
165
+ {
166
+ var address = anArray.adresse1 + "<br />" ;
167
+ if (anArray.adresse2)
168
+ address += anArray.adresse2 + "<br />" ;
169
+ if (anArray.adresse3)
170
+ address += anArray.adresse3 + "<br />" ;
171
+ return address ;
172
+ }
173
+
174
+ function parseHorairesOuverture(value , day, highlight)
175
+ {
176
+ var rs = "" ;
177
+
178
+ var now = new Date() ;
179
+ var today = now.getDay() ; // number of day
180
+ var attributedCell = "" ;
181
+ var reg = new RegExp(" ", "g");
182
+
183
+ var horaires = value.split(reg) ;
184
+
185
+ for (var i=0; i < horaires.length; i++)
186
+ {
187
+ // first define the attributes for the current cell
188
+ /* Aucun jour n'est mis en exergue car on ne sait pas quel sera le jour de livraison
189
+ if ( highlight == true && day == today)
190
+ {
191
+ attributedCell = "style=\"color:red;\"" ;
192
+ }
193
+ else
194
+ {
195
+ */
196
+ attributedCell = "" ;
197
+ /*
198
+ }
199
+ */
200
+
201
+ // so, re-format time
202
+ if (horaires[i] == "00:00-00:00")
203
+ {
204
+ horaires[i] = "<td "+attributedCell+">Ferm&eacute;</td>" ;
205
+ }
206
+ else
207
+ {
208
+ horaires[i] = "<td "+attributedCell+">"+horaires[i]+"</td>" ;
209
+ }
210
+
211
+ // yeah, concatenates result to the returned value
212
+ rs += horaires[i] ;
213
+ }
214
+
215
+ return rs ;
216
+ }
217
+
218
+ function printPage(i)
219
+ {
220
+ var fen=open("","Impression");
221
+ fen.focus();
222
+ var baseURL = "http://www.chronopost.fr/transport-express/webdav/site/chronov4/groups/administrators/public/Chronomaps/" ;
223
+ var latlngpoint = relaylatan[i-1];
224
+ if(latlngpoint) {
225
+ fen.location.href = baseURL
226
+ + "print-result.html?request=print&"
227
+ + btQueryString(addressrelais[i-1], true).replace(/00%3A00-00%3A00/gi, 'Ferm%E9')
228
+ + "&rtype=chronorelais"
229
+ + "&icnname=ac"
230
+ + "&lat=" + latlngpoint.lat()
231
+ + "&lng=" + latlngpoint.lng()
232
+ + "&sw-form-type-point=opt_chrlas"
233
+ + "&is_print_direction=" + false
234
+ + "&from_addr="
235
+ + "&to_addr=";
236
+ }
237
+ }
238
+
239
+ function btQueryString(anArray, needEscape)
240
+ {
241
+ var rs = "" ;
242
+ for (key in anArray)
243
+ {
244
+ if (needEscape == true)
245
+ {
246
+ if(anArray[key]) {
247
+ if (rs != "")
248
+ rs += "&"
249
+ rs += key +"=" + escape(anArray[key]) ;
250
+ }
251
+ }
252
+ else
253
+ {
254
+ if(anArray[key]) {
255
+ if (rs != "")
256
+ rs += "_-_"
257
+ rs += key +"=" + anArray[key] ;
258
+ }
259
+ }
260
+ }
261
+ return rs ;
262
+ }
263
+
264
+ function getShipAddress() {
265
+ var ship_address = '';
266
+ if($('shipping:same_as_billing').checked) {
267
+ if ($('billing-address-select') && $('billing-address-select').value) {
268
+ var e = $('billing-address-select');
269
+ var address_value = e.options[e.selectedIndex].text;
270
+ var shipping_address = address_value.split(',');
271
+ if(shipping_address[1]) {
272
+ ship_address = shipping_address[1];
273
+ }
274
+ } else {
275
+ if($('billing:street1')) { ship_address = $('billing:street1').value; }
276
+ if($('billing:street2')) { ship_address = ship_address+" "+$('billing:street2').value; }
277
+ if($('billing:street3')) { ship_address = ship_address+" "+$('billing:street3').value; }
278
+ }
279
+ } else {
280
+ if ($('shipping-address-select') && $('shipping-address-select').value) {
281
+ var e = $('shipping-address-select');
282
+ var address_value = e.options[e.selectedIndex].text;
283
+ var shipping_address = address_value.split(',');
284
+ if(shipping_address[1]) {
285
+ ship_address = shipping_address[1];
286
+ }
287
+ } else {
288
+ if($('shipping:street1')) { ship_address = $('shipping:street1').value; }
289
+ if($('shipping:street2')) { ship_address = ship_address+" "+$('shipping:street2').value; }
290
+ if($('shipping:street3')) { ship_address = ship_address+" "+$('shipping:street3').value; }
291
+ }
292
+ }
293
+ return ship_address;
294
+ }
295
+
296
+ /** Map content end **/
297
+
298
+
299
+ // shipping method
300
+ var ShippingMethod = Class.create();
301
+ ShippingMethod.prototype = {
302
+ initialize: function(form, saveUrl){
303
+ this.form = form;
304
+ if ($(this.form)) {
305
+ $(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
306
+ }
307
+ this.saveUrl = saveUrl;
308
+ this.validator = new Validation(this.form);
309
+ this.onSave = this.nextStep.bindAsEventListener(this);
310
+ this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
311
+ },
312
+
313
+ validate: function() {
314
+ var methods = document.getElementsByName('shipping_method');
315
+ if (methods.length==0) {
316
+ alert(Translator.translate('Your order cannot be completed at this time as there is no shipping methods available for it. Please make neccessary changes in your shipping address.'));
317
+ return false;
318
+ }
319
+
320
+ if(!this.validator.validate()) {
321
+ return false;
322
+ }
323
+
324
+ for (var i=0; i<methods.length; i++) {
325
+ if (methods[i].checked) {
326
+ if (methods[i].value == 'chronorelais_chronorelais') {
327
+ var submethods = document.getElementsByName('shipping_method_chronorelais');
328
+ if (submethods.length==0) {
329
+ alert(Translator.translate('Your order cannot be completed at this time as there is no shipping methods available for it. Please make neccessary changes in your shipping address.'));
330
+ return false;
331
+ }
332
+ for (var j=0; j<submethods.length; j++) {
333
+ if (submethods[j].checked) {
334
+ return true;
335
+ }
336
+ }
337
+ } else {
338
+ return true;
339
+ }
340
+ }
341
+ }
342
+ alert(Translator.translate('Please specify shipping method.'));
343
+ return false;
344
+ },
345
+
346
+ getrelais: function(url){
347
+ if (checkout.loadWaiting!=false) return;
348
+ //if (this.validate()) {
349
+ checkout.setLoadWaiting('shipping-method');
350
+ hidehomeicon = false;
351
+ var request = new Ajax.Request(
352
+ url,
353
+ {
354
+ method:'post',
355
+ onComplete: this.onComplete,
356
+ onSuccess: this.onSave,
357
+ onFailure: checkout.ajaxFailure.bind(checkout),
358
+ parameters: Form.serialize(this.form)
359
+ }
360
+ );
361
+ //}
362
+ },
363
+
364
+ changePostalCode: function(url){
365
+ if (checkout.loadWaiting!=false) return;
366
+ //if (this.validate()) {
367
+ if(!$('mappostalcode').value) { return false; }
368
+ checkout.setLoadWaiting('shipping-method');
369
+ $('mappostalcodebtn').hide();
370
+ $('postalcode-please-wait').show();
371
+ $('postalcode-please-wait').style.opacity = '0.5';
372
+ hidehomeicon = true;
373
+ var request = new Ajax.Request(
374
+ url,
375
+ {
376
+ method:'post',
377
+ onComplete: this.onComplete,
378
+ onSuccess: this.onSave,
379
+ onFailure: checkout.ajaxFailure.bind(checkout),
380
+ parameters: Form.serialize(this.form)
381
+ }
382
+ );
383
+ //}
384
+ },
385
+
386
+ hiderelais: function(url){
387
+ if($('checkout-shipping-method-chronorelais-load')) {
388
+ $('checkout-shipping-method-chronorelais-load').innerHTML = "";
389
+ }
390
+ },
391
+
392
+ save: function(){
393
+
394
+ if (checkout.loadWaiting!=false) return;
395
+ if (this.validate()) {
396
+ checkout.setLoadWaiting('shipping-method');
397
+ var request = new Ajax.Request(
398
+ this.saveUrl,
399
+ {
400
+ method:'post',
401
+ onComplete: this.onComplete,
402
+ onSuccess: this.onSave,
403
+ onFailure: checkout.ajaxFailure.bind(checkout),
404
+ parameters: Form.serialize(this.form)
405
+ }
406
+ );
407
+ }
408
+ },
409
+
410
+ resetLoadWaiting: function(transport){
411
+ checkout.setLoadWaiting(false);
412
+ },
413
+
414
+ nextStep: function(transport){
415
+ if (transport && transport.responseText){
416
+ try{
417
+ response = eval('(' + transport.responseText + ')');
418
+ }
419
+ catch (e) {
420
+ response = {};
421
+ }
422
+ }
423
+
424
+ if (response.error) {
425
+ alert(response.message);
426
+ if($('mappostalcodebtn')) { $('mappostalcodebtn').show(); }
427
+ if($('postalcode-please-wait')) { $('postalcode-please-wait').hide(); }
428
+ return false;
429
+ }
430
+
431
+ if (response.update_section) {
432
+ $('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
433
+ response.update_section.html.evalScripts();
434
+
435
+ if(response.relaypoints) {
436
+ if(response.relaypoints.length>0) {
437
+ var relayaddress = "";
438
+ gmarkers = [];
439
+ addressrelais = [];
440
+ relaylatan = [];
441
+ homeaddress = "";
442
+ next_pt = 0;
443
+ bounds = new google.maps.LatLngBounds();
444
+ for(var s=0; s<response.relaypoints.length; s++) {
445
+ next_pt = s+1;
446
+ relayaddress = response.relaypoints[s].adresse1;
447
+ if(response.relaypoints[s].codePostal)
448
+ relayaddress += " "+response.relaypoints[s].codePostal;
449
+ if(response.relaypoints[s].localite)
450
+ relayaddress += " "+response.relaypoints[s].localite;
451
+ loadRelayMap(relayaddress, response.relaypoints[s], next_pt, "chronomap");
452
+ }
453
+ }
454
+ }
455
+ }
456
+
457
+ payment.initWhatIsCvvListeners();
458
+
459
+ if (response.goto_section) {
460
+ checkout.gotoSection(response.goto_section);
461
+ checkout.reloadProgressBlock();
462
+ return;
463
+ }
464
+
465
+ if (response.payment_methods_html) {
466
+ $('checkout-payment-method-load').update(response.payment_methods_html);
467
+ }
468
+
469
+ checkout.setShippingMethod();
470
+ }
471
+ }
472
+
473
+ // shipping method
474
+ var multiindex = "";
475
+ var MultiShippingMethod = Class.create();
476
+ MultiShippingMethod.prototype = {
477
+ initialize: function(){
478
+ this.loadWaiting = false;
479
+ this.onComplete = this.complete.bindAsEventListener(this);
480
+ },
481
+
482
+ getrelais: function(url, index, home){
483
+ if (this.loadWaiting!=false) return;
484
+ this.loadWaiting = true;
485
+ homeaddress = home;
486
+ hidehomeicon = false;
487
+ multiindex = "_" + index;
488
+ var request = new Ajax.Request(
489
+ url,
490
+ {
491
+ method:'post',
492
+ onComplete: this.onComplete
493
+ }
494
+ );
495
+
496
+ },
497
+
498
+ changePostalCode: function(url, index){
499
+ if (this.loadWaiting!=false) return;
500
+ this.loadWaiting = true;
501
+ multiindex = "_" + index;
502
+ if(!$('mappostalcode' + multiindex).value) { return false; }
503
+ homeaddress = $('mappostalcode' + multiindex).value;
504
+ $('mappostalcodebtn' + multiindex).hide();
505
+ $('postalcode-please-wait' + multiindex).show();
506
+ $('postalcode-please-wait' + multiindex).style.opacity = '0.5';
507
+ hidehomeicon = true;
508
+ var request = new Ajax.Request(
509
+ url + '&zip=' + $('mappostalcode' + multiindex).value,
510
+ {
511
+ method:'post',
512
+ onComplete: this.onComplete
513
+ }
514
+ );
515
+ },
516
+
517
+ hiderelais: function(url, index){
518
+ if($('checkout-shipping-method-chronorelais-load_' + index)) {
519
+ $('checkout-shipping-method-chronorelais-load_' + index).innerHTML = "";
520
+ }
521
+ },
522
+
523
+ complete: function(transport){
524
+ this.loadWaiting = false;
525
+
526
+ if (transport && transport.responseText){
527
+ try{
528
+ response = eval('(' + transport.responseText + ')');
529
+ }
530
+ catch (e) {
531
+ response = {};
532
+ }
533
+ }
534
+
535
+ if (response.error) {
536
+ alert(response.message);
537
+ if($('mappostalcodebtn' + multiindex)) { $('mappostalcodebtn' + multiindex).show(); }
538
+ if($('postalcode-please-wait' + multiindex)) { $('postalcode-please-wait' + multiindex).hide(); }
539
+ return false;
540
+ }
541
+
542
+ if (response.update_section) {
543
+ $(response.update_section.name).update(response.update_section.html);
544
+ response.update_section.html.evalScripts();
545
+
546
+ if(response.relaypoints) {
547
+ if(response.relaypoints.length>0) {
548
+ var relayaddress = "";
549
+ gmarkers = [];
550
+ addressrelais = [];
551
+ relaylatan = [];
552
+ next_pt = 0;
553
+ bounds = new google.maps.LatLngBounds();
554
+ for(var s=0; s<response.relaypoints.length; s++) {
555
+ next_pt = s+1;
556
+ relayaddress = response.relaypoints[s].adresse1;
557
+ if(response.relaypoints[s].codePostal)
558
+ relayaddress += " "+response.relaypoints[s].codePostal;
559
+ if(response.relaypoints[s].localite)
560
+ relayaddress += " "+response.relaypoints[s].localite;
561
+ loadRelayMap(relayaddress, response.relaypoints[s], next_pt, 'chronomap' + multiindex);
562
+ }
563
+ }
564
+ }
565
+ }
566
+ }
567
+ }