Chronopost_Chronorelais - Version 0.1.4

Version Notes

New shipping module

Download this release

Release Info

Developer Magento Core Team
Extension Chronopost_Chronorelais
Version 0.1.4
Comparing to
See all releases


Version 0.1.4

Files changed (65) hide show
  1. app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Field/Config.php +43 -0
  2. app/code/community/Chronopost/Chronorelais/Block/Checkout/Onepage/Shipping/Method/Chronorelais.php +54 -0
  3. app/code/community/Chronopost/Chronorelais/Block/Detail.php +29 -0
  4. app/code/community/Chronopost/Chronorelais/Block/Export/Orders.php +21 -0
  5. app/code/community/Chronopost/Chronorelais/Block/Export/Orders/Grid.php +236 -0
  6. app/code/community/Chronopost/Chronorelais/Block/Filter.php +53 -0
  7. app/code/community/Chronopost/Chronorelais/Block/Import/Form.php +11 -0
  8. app/code/community/Chronopost/Chronorelais/Block/Sales/Impression.php +16 -0
  9. app/code/community/Chronopost/Chronorelais/Block/Sales/Order/Shipment/View.php +99 -0
  10. app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Copy of Grid.php +139 -0
  11. app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid-bkp-03-02-11.php +143 -0
  12. app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid.php +185 -0
  13. app/code/community/Chronopost/Chronorelais/Controller/Abstract.php +126 -0
  14. app/code/community/Chronopost/Chronorelais/Helper/Data.php +177 -0
  15. app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelais.php +32 -0
  16. app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelaisShipping.php +468 -0
  17. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronoexpress.php +6 -0
  18. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronopost.php +6 -0
  19. app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronorelais.php +6 -0
  20. app/code/community/Chronopost/Chronorelais/Model/Config/Source/Civility.php +12 -0
  21. app/code/community/Chronopost/Chronorelais/Model/Config/Source/EndOfLineCharacter.php +12 -0
  22. app/code/community/Chronopost/Chronorelais/Model/Config/Source/FieldDelimiter.php +12 -0
  23. app/code/community/Chronopost/Chronorelais/Model/Config/Source/FieldSeparator.php +11 -0
  24. app/code/community/Chronopost/Chronorelais/Model/Config/Source/FileCharset.php +12 -0
  25. app/code/community/Chronopost/Chronorelais/Model/Config/Source/FileExtension.php +12 -0
  26. app/code/community/Chronopost/Chronorelais/Model/Config/Source/PrintMode.php +12 -0
  27. app/code/community/Chronopost/Chronorelais/Model/Sales/Quote/Address/Total/Shipping.php +207 -0
  28. app/code/community/Chronopost/Chronorelais/controllers/AjaxController.php +409 -0
  29. app/code/community/Chronopost/Chronorelais/controllers/Checkout/OnepageController.php +657 -0
  30. app/code/community/Chronopost/Chronorelais/controllers/ExportController.php +446 -0
  31. app/code/community/Chronopost/Chronorelais/controllers/ImportController.php +249 -0
  32. app/code/community/Chronopost/Chronorelais/controllers/RelaisController.php +32 -0
  33. app/code/community/Chronopost/Chronorelais/controllers/Sales/ImpressionController.php +556 -0
  34. app/code/community/Chronopost/Chronorelais/controllers/Sales/Order/ShipmentController.php +268 -0
  35. app/code/community/Chronopost/Chronorelais/etc/config.xml +340 -0
  36. app/code/community/Chronopost/Chronorelais/etc/system.xml +965 -0
  37. app/code/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php +1245 -0
  38. app/code/community/Chronopost/Chronorelais/includes/countries.inc.php +523 -0
  39. app/code/community/Chronopost/Chronorelais/sql/chronorelais_setup/mysql4-install-0.1.0.php +15 -0
  40. app/code/community/Chronopost/Chronorelais/sql/chronorelais_setup/mysql4-upgrade-0.1.0-0.1.1.php +8 -0
  41. app/code/community/Chronopost/Chronorelais/sql/chronorelais_setup/mysql4-upgrade-0.1.1-0.1.2.php +8 -0
  42. app/code/community/Chronopost/Chronorelais/sql/chronorelais_setup/mysql4-upgrade-0.1.2-0.1.3.php +8 -0
  43. app/code/community/Chronopost/Chronorelais/sql/chronorelais_setup/mysql4-upgrade-0.1.3-0.1.4.php +14 -0
  44. app/design/adminhtml/default/default/template/chronorelais/import/form.phtml +65 -0
  45. app/design/frontend/default/default/layout/chronorelais.xml +44 -0
  46. app/design/frontend/default/default/template/chronorelais/checkout/onepage/shipping_method.phtml +93 -0
  47. app/design/frontend/default/default/template/chronorelais/checkout/onepage/shipping_method/available.phtml +94 -0
  48. app/design/frontend/default/default/template/chronorelais/checkout/onepage/shipping_method/chronorelais.phtml +29 -0
  49. app/design/frontend/default/default/template/chronorelais/sales/order/history.phtml +79 -0
  50. app/design/frontend/default/default/template/chronorelais/sales/order/recent.phtml +78 -0
  51. app/etc/modules/WSChronopost_Chronorelais.xml +31 -0
  52. app/locale/en_US/Chronopost_Chronorelais.csv +1034 -0
  53. app/locale/fr_FR/Chronopost_Chronorelais.csv +1034 -0
  54. js/chronopost/chronorelais/ocseditor.css +465 -0
  55. js/chronopost/chronorelais/ocseditor.js +674 -0
  56. package.xml +20 -0
  57. skin/frontend/default/default/chronorelais/Picto_Chrono_Relais.png +0 -0
  58. skin/frontend/default/default/chronorelais/Thumbs.db +0 -0
  59. skin/frontend/default/default/chronorelais/ac.png +0 -0
  60. skin/frontend/default/default/chronorelais/chronopost.png +0 -0
  61. skin/frontend/default/default/chronorelais/chronorelais.css +46 -0
  62. skin/frontend/default/default/chronorelais/chronorelais.png +0 -0
  63. skin/frontend/default/default/chronorelais/chronorelaismap.js +463 -0
  64. skin/frontend/default/default/chronorelais/home.png +0 -0
  65. skin/frontend/default/default/chronorelais/ico_ac_shaded.gif +0 -0
app/code/community/Chronopost/Chronorelais/Block/Adminhtml/System/Config/Form/Field/Config.php ADDED
@@ -0,0 +1,43 @@
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Block_Adminhtml_System_Config_Form_Field_Config extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ private static $JS_INCLUDED = false;
6
+
7
+ private function label($input) {
8
+ return str_replace(array("\r\n","\r","\n","'"),array("\\n","\\n","\\n","\\'"),$this->__($input));
9
+ }
10
+
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
+ $output = '';
14
+ if (!self::$JS_INCLUDED) {
15
+ $include_path = Mage::getBaseUrl('js').'chronopost/chronorelais';
16
+ $output = "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js\"></script>\n"
17
+ ."<script type=\"text/javascript\" src=\"".$include_path."/ocseditor.js?t=".time()."\"></script>\n"
18
+ ."<script type=\"text/javascript\">\n"
19
+ ."//<![CDATA[\n"
20
+ ."jQuery.noConflict();\n"
21
+ ."var ocseditor = new OCSEditor({\n"
22
+ ."ajax_url: '".$this->getUrl('chronorelais/ajax')."?isAjax=true',\n"
23
+ ."form_key: FORM_KEY,\n"
24
+ ."menu_item_dissociate_label: '".$this->label('Dissociate')."',\n"
25
+ ."menu_item_remove_label: '".$this->label('Remove')."',\n"
26
+ ."menu_item_edit_label: '".$this->label('Edit')."',\n"
27
+ ."prompt_new_value_label: '".$this->label('Enter the new value:')."',\n"
28
+ ."default_row_label: '".$this->label('[No label]')."',\n"
29
+ ."loading_label: '".$this->label('Loading...')."'\n"
30
+ ."});\n"
31
+ ."//]]>\n"
32
+ ."</script>\n"
33
+ ."<link type=\"text/css\" href=\"".$include_path."/ocseditor.css?t=".time()."\" rel=\"stylesheet\" media=\"all\"/>\n"
34
+ ;
35
+ self::$JS_INCLUDED = true;
36
+ }
37
+
38
+ return $output
39
+ .'<div style="margin-bottom:1px;"><button type="button" class="scalable" onclick="ocseditor.open(this);"><span>'.$this->__("Open editor").'</span></button></div>'
40
+ .$element->getElementHtml().'<br/>'
41
+ ;
42
+ }
43
+ }
app/code/community/Chronopost/Chronorelais/Block/Checkout/Onepage/Shipping/Method/Chronorelais.php ADDED
@@ -0,0 +1,54 @@
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_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
+
54
+ }
app/code/community/Chronopost/Chronorelais/Block/Detail.php ADDED
@@ -0,0 +1,29 @@
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Detail extends Mage_Core_Block_Template
3
+ {
4
+
5
+ public function _prepareLayout()
6
+ {
7
+ return parent::_prepareLayout();
8
+ }
9
+
10
+ public function getRelaisPoint(){
11
+
12
+
13
+ $btcode = $this->getRequest()->getParam ( 'btcode' );
14
+
15
+ if($btcode){
16
+ $result = Mage::getModel('shipping/rate_result');
17
+ ini_set("soap.wsdl_cache_enabled", "0");
18
+ $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;
25
+ }
26
+ }
27
+
28
+ }
29
+ ?>
app/code/community/Chronopost/Chronorelais/Block/Export/Orders.php ADDED
@@ -0,0 +1,21 @@
1
+ <?php
2
+ /**
3
+ * Chronopost Chronorelais module
4
+ *
5
+ * @category Chronopost
6
+ * @package Chronopost_Chronorelais
7
+ * @license http://www.opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
8
+ */
9
+ class Chronopost_Chronorelais_Block_Export_Orders extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+
12
+ public function __construct()
13
+ {
14
+ $this->_blockGroup = 'chronorelais';
15
+ $this->_controller = 'export_orders';
16
+ $this->_headerText = Mage::helper('chronorelais')->__('Exporter vers ChronoShip Office ou ChronoShip Station');
17
+ parent::__construct();
18
+ $this->_removeButton('add');
19
+ }
20
+
21
+ }
app/code/community/Chronopost/Chronorelais/Block/Export/Orders/Grid.php ADDED
@@ -0,0 +1,236 @@
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->setDefaultSort('created_at');
10
+ $this->setDefaultDir('DESC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ /**
15
+ * Retrieve collection class
16
+ *
17
+ * @return string
18
+ */
19
+ protected function _getCollectionClass()
20
+ {
21
+ return 'sales/order_grid_collection';
22
+ }
23
+
24
+ protected function _prepareCollection()
25
+ {
26
+ $_chronopost_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronopost/deliver_on_saturday');
27
+ $_chronorelais_deliver_saturday = Mage::helper('chronorelais')->getConfigData('carriers/chronorelais/deliver_on_saturday');
28
+ if($_chronopost_deliver_saturday==1) { $_chronopost_deliver_saturday = 'Yes'; } else { $_chronopost_deliver_saturday = 'No';}
29
+ if($_chronorelais_deliver_saturday==1) { $_chronorelais_deliver_saturday = 'Yes'; } else { $_chronorelais_deliver_saturday = 'No'; }
30
+
31
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
32
+ $collection->join('order', 'main_table.entity_id = order.entity_id', 'shipping_description');
33
+ $collection->join('order_payment', 'main_table.entity_id = order_payment.parent_id', 'method');
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(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"));
35
+ $collection->getSelect()->where('order.shipping_method LIKE "chronorelais%" OR order.shipping_method LIKE "chronopost%" OR order.shipping_method LIKE "chronoexpress%"');
36
+
37
+ $this->setCollection($collection);
38
+ return parent::_prepareCollection();
39
+ }
40
+
41
+ protected function _prepareColumns()
42
+ {
43
+
44
+ $this->addColumn('real_order_id', array(
45
+ 'header'=> Mage::helper('sales')->__('Order #'),
46
+ 'width' => '80px',
47
+ 'type' => 'text',
48
+ 'index' => 'increment_id',
49
+ 'filter' => false,
50
+ ));
51
+
52
+ if (!Mage::app()->isSingleStoreMode()) {
53
+ $this->addColumn('store_id', array(
54
+ 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
55
+ 'index' => 'store_id',
56
+ 'type' => 'store',
57
+ 'store_view'=> true,
58
+ 'display_deleted' => true,
59
+ 'filter' => false,
60
+ ));
61
+ }
62
+
63
+ $this->addColumn('created_at', array(
64
+ 'header' => Mage::helper('sales')->__('Purchased On'),
65
+ 'index' => 'created_at',
66
+ 'type' => 'datetime',
67
+ 'width' => '100px',
68
+ 'filter' => false,
69
+ ));
70
+
71
+ $this->addColumn('billing_name', array(
72
+ 'header' => Mage::helper('sales')->__('Bill to Name'),
73
+ 'index' => 'billing_name',
74
+ 'filter' => false,
75
+ ));
76
+
77
+ $this->addColumn('shipping_name', array(
78
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
79
+ 'index' => 'shipping_name',
80
+ 'filter' => false,
81
+ ));
82
+
83
+ $this->addColumn('base_grand_total', array(
84
+ 'header' => Mage::helper('sales')->__('G.T. (Base)'),
85
+ 'index' => 'base_grand_total',
86
+ 'type' => 'currency',
87
+ 'currency' => 'base_currency_code',
88
+ 'filter' => false,
89
+ ));
90
+
91
+ $this->addColumn('grand_total', array(
92
+ 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
93
+ 'index' => 'grand_total',
94
+ 'type' => 'currency',
95
+ 'currency' => 'order_currency_code',
96
+ 'filter' => false,
97
+ ));
98
+
99
+ $this->addColumn('shipping_description', array(
100
+ 'header'=> Mage::helper('sales')->__('Shipping Method'),
101
+ 'width' => '80px',
102
+ 'type' => 'text',
103
+ 'index' => 'shipping_description',
104
+ 'filter' => false,
105
+ 'truncate' => 30,
106
+ 'escape' => true,
107
+ ));
108
+
109
+ $this->addColumn('payment', array(
110
+ 'header' => Mage::helper('sales')->__('Mode de Paiement'),
111
+ 'index' => 'method',
112
+ 'width' => '100px',
113
+ 'type' => 'text',
114
+ 'filter' => false,
115
+ ));
116
+
117
+ if($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
118
+ $this->addColumn('livraison_le_samedi', array(
119
+ 'header' => Mage::helper('sales')->__('Livraison le Samedi'),
120
+ 'index' => 'livraison_le_samedi',
121
+ 'width' => '100px',
122
+ 'class' => 'a-center',
123
+ 'filter' => false,
124
+ ));
125
+ }
126
+
127
+ $this->addColumn('main_table.status', array(
128
+ 'header' => Mage::helper('sales')->__('Status'),
129
+ 'index' => 'status',
130
+ 'type' => 'options',
131
+ 'width' => '70px',
132
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
133
+ ));
134
+
135
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
136
+ $this->addColumn('action',
137
+ array(
138
+ 'header' => Mage::helper('sales')->__('Action'),
139
+ 'width' => '50px',
140
+ 'type' => 'action',
141
+ 'getter' => 'getId',
142
+ 'actions' => array(
143
+ array(
144
+ 'caption' => Mage::helper('sales')->__('View'),
145
+ 'url' => array('base'=>'adminhtml/sales_order/view'),
146
+ 'field' => 'order_id'
147
+ )
148
+ ),
149
+ 'filter' => false,
150
+ 'sortable' => false,
151
+ 'index' => 'stores',
152
+ 'is_system' => true,
153
+ ));
154
+ }
155
+
156
+ return parent::_prepareColumns();
157
+ }
158
+
159
+ protected function _prepareMassaction111()
160
+ {
161
+ $this->setMassactionIdField('entity_id');
162
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
163
+ $this->getMassactionBlock()->setUseSelectAll(false);
164
+
165
+ $this->getMassactionBlock()->addItem('export_css', array(
166
+ 'label'=> Mage::helper('chronorelais')->__('Export CSS'),
167
+ 'url' => $this->getUrl('*/*/exportcss'),
168
+ ));
169
+ $this->getMassactionBlock()->addItem('export_cso', array(
170
+ 'label'=> Mage::helper('chronorelais')->__('Export CSO'),
171
+ 'url' => $this->getUrl('*/*/exportcso'),
172
+ ));
173
+
174
+ return $this;
175
+ }
176
+
177
+ protected function _prepareMassaction()
178
+ {
179
+ $this->setMassactionIdField('entity_id');
180
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
181
+ $this->getMassactionBlock()->setUseSelectAll(false);
182
+
183
+ if($is_sending_day = Mage::helper('chronorelais')->isSendingDay()) {
184
+ $shipping = array(
185
+ 'Yes' => Mage::helper('chronorelais')->__('Yes'),
186
+ 'No' => Mage::helper('chronorelais')->__('No'));
187
+ $this->getMassactionBlock()->addItem('shipping', array(
188
+ 'label' => Mage::helper('chronorelais')->__('Livraison le Samedi'),
189
+ 'url' => $this->getUrl('*/*/massLivraisonSamediStatus', array('_current'=>true)),
190
+ 'additional' => array(
191
+ 'visibility' => array(
192
+ 'name' => 'status',
193
+ 'type' => 'select',
194
+ 'class' => 'required-entry',
195
+ 'style' => 'width:80px',
196
+ 'label' => Mage::helper('chronorelais')->__('Status'),
197
+ 'values' => $shipping
198
+ )
199
+ )
200
+ ));
201
+ }
202
+
203
+ $export = array(
204
+ 'css' => Mage::helper('chronorelais')->__('CSS Format'),
205
+ 'cso' => Mage::helper('chronorelais')->__('CSO Format'));
206
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
207
+ $this->getMassactionBlock()->addItem('export', array(
208
+ 'label'=> Mage::helper('chronorelais')->__('Export'),
209
+ 'url' => $this->getUrl('*/*/massExport', array('_current'=>true)),
210
+ 'additional' => array(
211
+ 'visibility' => array(
212
+ 'name' => 'format',
213
+ 'type' => 'select',
214
+ 'class' => 'required-entry',
215
+ 'label' => Mage::helper('chronorelais')->__('Format'),
216
+ 'values' => $export
217
+ )
218
+ )
219
+ ));
220
+ return $this;
221
+ }
222
+
223
+ public function getRowUrl($row)
224
+ {
225
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
226
+ return $this->getUrl('adminhtml/sales_order/view', array('order_id' => $row->getId()));
227
+ }
228
+ return false;
229
+ }
230
+
231
+ public function getGridUrl()
232
+ {
233
+ return $this->getUrl('*/*/*', array('_current'=>true));
234
+ }
235
+
236
+ }
app/code/community/Chronopost/Chronorelais/Block/Filter.php ADDED
@@ -0,0 +1,53 @@
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Filter extends Mage_Core_Block_Template
3
+ {
4
+
5
+ public function _prepareLayout()
6
+ {
7
+ return parent::_prepareLayout();
8
+ }
9
+
10
+
11
+ public function getRelaisPoints(){
12
+
13
+ $zipcode = $this->getRequest()->getParam ( 'zipcode' );
14
+
15
+ if( $zipcode && $zipcode!="" ){
16
+ $result = Mage::getModel('shipping/rate_result');
17
+
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{
32
+ return false;
33
+ }
34
+ }
35
+
36
+ public function getmethodeCode(){
37
+
38
+ $zipcode = $this->getRequest()->getParam ( 'methodecode' );
39
+
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{
48
+ return false;
49
+ }
50
+ }
51
+
52
+ }
53
+ ?>
app/code/community/Chronopost/Chronorelais/Block/Import/Form.php ADDED
@@ -0,0 +1,11 @@
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Import_Form extends Mage_Adminhtml_Block_Widget
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setTemplate('chronorelais/import/form.phtml');
9
+ }
10
+
11
+ }
app/code/community/Chronopost/Chronorelais/Block/Sales/Impression.php ADDED
@@ -0,0 +1,16 @@
1
+ <?php
2
+
3
+ class Chronopost_Chronorelais_Block_Sales_Impression extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+
6
+
7
+ public function __construct()
8
+ {
9
+ $this->_blockGroup = 'chronorelais';
10
+ $this->_controller = 'sales_shipment';
11
+ $this->_headerText = Mage::helper('chronorelais')->__('Impressions des étiquettes Chronopost');
12
+ parent::__construct();
13
+ $this->_removeButton('add');
14
+ }
15
+
16
+ }
app/code/community/Chronopost/Chronorelais/Block/Sales/Order/Shipment/View.php ADDED
@@ -0,0 +1,99 @@
1
+ <?php
2
+ class Chronopost_Chronorelais_Block_Sales_Order_Shipment_View extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ $this->_objectId = 'shipment_id';
8
+ $this->_controller = 'sales_order_shipment';
9
+ $this->_mode = 'view';
10
+
11
+ parent::__construct();
12
+
13
+ $this->_removeButton('reset');
14
+ $this->_removeButton('delete');
15
+ $this->_updateButton('save', 'label', Mage::helper('sales')->__('Send Tracking Information'));
16
+ $this->_updateButton('save', 'onclick', "setLocation('".$this->getEmailUrl()."')");
17
+
18
+ //Ajout de l'impression de l'étiquette
19
+ $_order = $this->getShipment()->getOrder();
20
+ $_shippingMethod = explode("_",$_order->getShippingMethod());
21
+ if (($_shippingMethod[0] == 'chronorelais' || $_shippingMethod[0] == 'chronopost' || $_shippingMethod[0] == 'chronoexpress')) {
22
+ $this->_addButton('etiquette', array(
23
+ 'label' => Mage::helper('chronorelais')->__('Etiquette Chronopost'),
24
+ 'class' => 'save',
25
+ 'onclick' => 'setLocation(\'' . $this->getPrintMondialRelayUrl() . '\')'
26
+ )
27
+ );
28
+ }
29
+
30
+ if ($this->getShipment()->getId()) {
31
+ $this->_addButton('print', array(
32
+ 'label' => Mage::helper('sales')->__('Print'),
33
+ 'class' => 'save',
34
+ 'onclick' => 'setLocation(\''.$this->getPrintUrl().'\')'
35
+ )
36
+ );
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Retrieve shipment model instance
42
+ *
43
+ * @return Mage_Sales_Model_Order_Shipment
44
+ */
45
+ public function getShipment()
46
+ {
47
+ return Mage::registry('current_shipment');
48
+ }
49
+
50
+ public function getHeaderText()
51
+ {
52
+ if ($this->getShipment()->getEmailSent()) {
53
+ $emailSent = Mage::helper('sales')->__('Shipment email sent');
54
+ }
55
+ else {
56
+ $emailSent = Mage::helper('sales')->__('Shipment email not sent');
57
+ }
58
+
59
+ $header = Mage::helper('sales')->__('Shipment #%s (%s)', $this->getShipment()->getIncrementId(), $emailSent);
60
+ return $header;
61
+ }
62
+
63
+ public function getBackUrl()
64
+ {
65
+ return $this->getUrl(
66
+ '*/sales_order/view',
67
+ array(
68
+ 'order_id' => $this->getShipment()->getOrderId(),
69
+ 'active_tab'=> 'order_shipments'
70
+ ));
71
+ }
72
+
73
+ public function getEmailUrl()
74
+ {
75
+ return $this->getUrl('*/sales_order_shipment/email', array('shipment_id' => $this->getShipment()->getId()));
76
+ }
77
+
78
+ public function getPrintUrl()
79
+ {
80
+ return $this->getUrl('*/*/print', array(
81
+ 'invoice_id' => $this->getShipment()->getId()
82
+ ));
83
+ }
84
+
85
+ public function getPrintMondialRelayUrl()
86
+ {
87
+ return $this->getUrl('chronorelais/sales_impression/print', array(
88
+ 'shipment_id' => $this->getShipment()->getId()
89
+ ));
90
+ }
91
+
92
+ public function updateBackButtonUrl($flag)
93
+ {
94
+ if ($flag) {
95
+ return $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/sales_shipment/') . '\')');
96
+ }
97
+ return $this;
98
+ }
99
+ }
app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Copy of Grid.php ADDED
@@ -0,0 +1,139 @@
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_shipment_grid');
9
+ $this->setDefaultSort('order_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_shipment_grid_collection';
21
+ }
22
+
23
+ protected function _prepareCollection()
24
+ {
25
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
26
+ $collection->getSelect()->columns(array('shipment_created_at' => 'main_table.created_at'));
27
+ $collection->getSelect()->columns(array('shipment_increment_id' => 'main_table.increment_id'));
28
+
29
+ $collection->getSelect()->joinLeft(array('ot' => $collection->getTable('sales/order')), 'main_table.order_id = ot.entity_id');
30
+ $collection->getSelect()->joinLeft(array('ost' => $collection->getTable('sales/shipment_track')), 'ot.entity_id = ost.order_id');
31
+
32
+ $collection->getSelect()->where('ot.shipping_method LIKE "chronorelais%" OR ot.shipping_method LIKE "chronopost%"');
33
+ $this->setCollection($collection);
34
+ return parent::_prepareCollection();
35
+ }
36
+
37
+ protected function _prepareColumns()
38
+ {
39
+ $this->addColumn('increment_id', array(
40
+ 'header' => Mage::helper('sales')->__('Shipment #'),
41
+ 'index' => 'shipment_increment_id',
42
+ 'type' => 'text',
43
+ ));
44
+
45
+ $this->addColumn('shipment_created_at', array(
46
+ 'header' => Mage::helper('sales')->__('Date Shipped'),
47
+ 'index' => 'shipment_created_at',
48
+ 'type' => 'datetime',
49
+ ));
50
+
51
+ $this->addColumn('order_increment_id', array(
52
+ 'header' => Mage::helper('sales')->__('Order #'),
53
+ 'index' => 'order_increment_id',
54
+ 'type' => 'number',
55
+ ));
56
+
57
+ $this->addColumn('order_created_at', array(
58
+ 'header' => Mage::helper('sales')->__('Order Date'),
59
+ 'index' => 'order_created_at',
60
+ 'type' => 'datetime',
61
+ ));
62
+
63
+ $this->addColumn('shipping_name', array(
64
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
65
+ 'index' => 'shipping_name',
66
+ ));
67
+
68
+ $this->addColumn('total_qty', array(
69
+ 'header' => Mage::helper('sales')->__('Total Qty'),
70
+ 'index' => 'total_qty',
71
+ 'type' => 'number',
72
+ ));
73
+
74
+ $this->addColumn('number', array(
75
+ 'header' => Mage::helper('sales')->__('Tracking'),
76
+ 'index' => 'number',
77
+ ));
78
+
79
+ $this->addColumn('title', array(
80
+ 'header' => Mage::helper('sales')->__('Mode de transport'),
81
+ 'index' => 'title',
82
+ 'type' => 'text',
83
+ ));
84
+
85
+ $this->addColumn('download', array(
86
+ 'header' => Mage::helper('chronorelais')->__('Etiquettes'),
87
+ 'type' => 'action',
88
+ 'getter' => 'getParentId',
89
+ 'actions' => array(
90
+ array(
91
+ 'caption' => Mage::helper('chronorelais')->__('Imprimer'),
92
+ 'url' => array(
93
+ 'base'=>'chronorelais/sales_impression/print'
94
+ ),
95
+ 'field' => 'shipment_id'
96
+ )
97
+ ),
98
+ 'filter' => false,
99
+ 'sortable' => false,
100
+ 'index' => 'stores'
101
+ ));
102
+
103
+ return parent::_prepareColumns();
104
+ }
105
+
106
+ public function getRowUrl($row)
107
+ {
108
+ if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/shipment')) {
109
+ return false;
110
+ }
111
+
112
+ return $this->getUrl('adminhtml/sales_shipment/view',
113
+ array(
114
+ 'shipment_id'=> $row->getParentId(),
115
+ )
116
+ );
117
+ }
118
+
119
+ protected function _prepareMassaction()
120
+ {
121
+ $this->setMassactionIdField('entity_id');
122
+ $this->getMassactionBlock()->setFormFieldName('shipment_ids');
123
+ $this->getMassactionBlock()->setUseSelectAll(false);
124
+
125
+ // Impression des étiquettes
126
+ /*$this->getMassactionBlock()->addItem('pdfshipments_order', array(
127
+ 'label'=> Mage::helper('sales')->__('Imprimer les étiquettes'),
128
+ 'url' => $this->getUrl('chronorelais/sales_impression/printMass'),
129
+ ));*/
130
+
131
+ return $this;
132
+ }
133
+
134
+ public function getGridUrl()
135
+ {
136
+ return $this->getUrl('*/*/*', array('_current' => true));
137
+ }
138
+
139
+ }
app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid-bkp-03-02-11.php ADDED
@@ -0,0 +1,143 @@
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_shipment_grid');
9
+ $this->setDefaultSort('shipment_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_collection';
21
+ }
22
+
23
+ protected function _prepareCollection()
24
+ {
25
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
26
+ $collection->getSelect()->columns(array('shipment_created_at' => 'osg.created_at'));
27
+ $collection->getSelect()->columns(array('shipment_increment_id' => 'osg.increment_id'));
28
+ $collection->getSelect()->columns(array('shipping_method' => 'main_table.shipping_method'));
29
+
30
+ $collection->getSelect()->joinLeft(array('ost' => $collection->getTable('sales/shipment_track')), 'main_table.entity_id = ost.order_id', array('if(isNull(ost.number) , "--" , ost.number) as number', 'if(isNull(ost.title) , "--" , ost.title) as title'));
31
+ $collection->getSelect()->joinRight(array('osg' => $collection->getTable('sales/shipment_grid')), 'osg.order_id = main_table.entity_id');
32
+ $collection->getSelect()->where('shipping_method LIKE "chronorelais%" OR shipping_method LIKE "chronopost%"');
33
+ $collection->getSelect()->group('osg.entity_id');
34
+
35
+
36
+ $this->setCollection($collection);
37
+
38
+ return parent::_prepareCollection();
39
+ }
40
+
41
+ protected function _prepareColumns()
42
+ {
43
+ $this->addColumn('increment_id', array(
44
+ 'header' => Mage::helper('sales')->__('Shipment #'),
45
+ 'index' => 'shipment_increment_id',
46
+ 'type' => 'text',
47
+ ));
48
+
49
+ $this->addColumn('shipment_created_at', array(
50
+ 'header' => Mage::helper('sales')->__('Date Shipped'),
51
+ 'index' => 'shipment_created_at',
52
+ 'type' => 'datetime',
53
+ ));
54
+
55
+ $this->addColumn('order_increment_id', array(
56
+ 'header' => Mage::helper('sales')->__('Order #'),
57
+ 'index' => 'order_increment_id',
58
+ 'type' => 'number',
59
+ ));
60
+
61
+ $this->addColumn('order_created_at', array(
62
+ 'header' => Mage::helper('sales')->__('Order Date'),
63
+ 'index' => 'order_created_at',
64
+ 'type' => 'datetime',
65
+ ));
66
+
67
+ $this->addColumn('shipping_name', array(
68
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
69
+ 'index' => 'shipping_name',
70
+ ));
71
+
72
+ $this->addColumn('total_qty', array(
73
+ 'header' => Mage::helper('sales')->__('Total Qty'),
74
+ 'index' => 'total_qty',
75
+ 'type' => 'number',
76
+ ));
77
+
78
+ $this->addColumn('number', array(
79
+ 'header' => Mage::helper('sales')->__('Tracking'),
80
+ 'index' => 'number',
81
+ ));
82
+
83
+ $this->addColumn('title', array(
84
+ 'header' => Mage::helper('sales')->__('Mode de transport'),
85
+ 'index' => 'title',
86
+ 'type' => 'text',
87
+ ));
88
+
89
+ $this->addColumn('download', array(
90
+ 'header' => Mage::helper('chronorelais')->__('Etiquettes'),
91
+ 'type' => 'action',
92
+ 'getter' => 'getId',
93
+ 'actions' => array(
94
+ array(
95
+ 'caption' => Mage::helper('chronorelais')->__('Imprimer'),
96
+ 'url' => array(
97
+ 'base'=>'chronorelais/sales_impression/print'
98
+ ),
99
+ 'field' => 'shipment_id'
100
+ )
101
+ ),
102
+ 'filter' => false,
103
+ 'sortable' => false,
104
+ 'index' => 'stores'
105
+ ));
106
+
107
+ return parent::_prepareColumns();
108
+ }
109
+
110
+ public function getRowUrl($row)
111
+ {
112
+ if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/shipment')) {
113
+ return false;
114
+ }
115
+
116
+ return $this->getUrl('adminhtml/sales_shipment/view',
117
+ array(
118
+ 'shipment_id'=> $row->getId(),
119
+ )
120
+ );
121
+ }
122
+
123
+ protected function _prepareMassaction()
124
+ {
125
+ $this->setMassactionIdField('entity_id');
126
+ $this->getMassactionBlock()->setFormFieldName('shipment_ids');
127
+ $this->getMassactionBlock()->setUseSelectAll(false);
128
+
129
+ // Impression des étiquettes
130
+ /*$this->getMassactionBlock()->addItem('pdfshipments_order', array(
131
+ 'label'=> Mage::helper('sales')->__('Imprimer les étiquettes'),
132
+ 'url' => $this->getUrl('chronorelais/sales_impression/printMass'),
133
+ ));*/
134
+
135
+ return $this;
136
+ }
137
+
138
+ public function getGridUrl()
139
+ {
140
+ return $this->getUrl('*/*/*', array('_current' => true));
141
+ }
142
+
143
+ }
app/code/community/Chronopost/Chronorelais/Block/Sales/Shipment/Grid.php ADDED
@@ -0,0 +1,185 @@
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) , "--" , osg.increment_id) as shipment_increment_id', 'osg.created_at 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.number) , "--" , ost.number) as number', 'if(isNull(ost.title) , "--" , ost.title) 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('number', array(
94
+ 'header' => Mage::helper('sales')->__('Tracking'),
95
+ 'index' => '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
+ }
app/code/community/Chronopost/Chronorelais/Controller/Abstract.php ADDED
@@ -0,0 +1,126 @@
1
+ <?php
2
+
3
+ /**
4
+ * Magento Chronopost Chronorelais Module
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Chronopost
17
+ * @package Chronopost_Chronorelais
18
+ * @copyright Copyright (c) 2008-10
19
+ * @author Sundar
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class Chronopost_Chronorelais_Controller_Abstract extends Mage_Adminhtml_Controller_Action
24
+ {
25
+ public function __() {
26
+ $args = func_get_args();
27
+ $message = array_shift($args);
28
+ if ($message instanceof OS_Message) {
29
+ $args = $message->args;
30
+ $message = $message->message;
31
+ }
32
+
33
+ $output = Mage::helper('shipping')->__($message);
34
+ if (count($args)==0) return $output;
35
+
36
+ if (!isset($this->_translate_inline)) $this->_translate_inline = Mage::getSingleton('core/translate')->getTranslateInline();
37
+ if ($this->_translate_inline) {
38
+ $parts = explode('}}{{',$output);
39
+ $parts[0] = vsprintf($parts[0],$args);
40
+ return implode('}}{{',$parts);
41
+ }
42
+ else return vsprintf($output,$args);
43
+ }
44
+
45
+ protected function getIncludingPath($path) {
46
+ if (file_exists(dirname(__FILE__).'/Chronopost_Chronorelais_includes_'.$path)) {
47
+ return 'Chronopost_Chronorelais_includes_'.$path;
48
+ } else {
49
+ return Mage::getBaseDir('code').'/community/Chronopost/Chronorelais/includes/'.$path;
50
+ }
51
+ }
52
+
53
+ protected function getMimeType($extension) {
54
+ $mime_type_array = array(
55
+ '.gz' => 'application/x-gzip',
56
+ '.tgz' => 'application/x-gzip',
57
+ '.zip' => 'application/zip',
58
+ '.pdf' => 'application/pdf',
59
+ '.png' => 'image/png',
60
+ '.gif' => 'image/gif',
61
+ '.jpg' => 'image/jpeg',
62
+ '.jpeg' => 'image/jpeg',
63
+ '.txt' => 'text/plain',
64
+ '.htm' => 'text/html',
65
+ '.html' => 'text/html',
66
+ '.mpg' => 'video/mpeg',
67
+ '.avi' => 'video/x-msvideo',
68
+ );
69
+ return isset($mime_type_array[$extension]) ? $mime_type_array[$extension] : 'application/octet-stream';
70
+ }
71
+
72
+ protected function forceDownload($filename, $content) {
73
+ if (headers_sent()) {
74
+ trigger_error('forceDownload($filename) - Headers have already been sent',E_USER_ERROR);
75
+ return false;
76
+ }
77
+
78
+ $extension = strrchr($filename,'.');
79
+ $mime_type = $this->getMimeType($extension);
80
+
81
+ header('Content-disposition: attachment; filename="'.$filename.'"');
82
+ header('Content-Type: application/force-download');
83
+ header('Content-Transfer-Encoding: '.$mime_type."\n"); // Surtout ne pas enlever le \n
84
+ //header('Content-Length: '.filesize($filename));
85
+ header('Pragma: no-cache');
86
+ header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
87
+ header('Expires: 0');
88
+ echo $content;
89
+ return true;
90
+ }
91
+
92
+ protected function jsEscape($input) {
93
+ return str_replace(array("\r\n","\r","\n","'"),array("\\n","\\n","\\n","\\'"),$input);
94
+ }
95
+
96
+ protected function cleanKey($key) {
97
+ return preg_replace('/[^a-z0-9-_]/i','_-_',$key);
98
+ }
99
+
100
+ protected function page($id, $title, $content) {
101
+ return "<div id=\"ocseditor-".$id."-page\" class=\"ocseditor-page\">"
102
+ .$this->pageHeader($title,$this->button('Close',"ocseditor.closePage(this);",'cancel'))
103
+ ."<div class=\"page-content\">".$content."</div>"
104
+ ."</div>"
105
+ ;
106
+ }
107
+
108
+ protected function pageHeader($title, $buttons) {
109
+ return "<div class=\"content-header\">"
110
+ ."<table cellspacing=\"0\"><tr>"
111
+ ."<td><h3>".$this->__($title)."</h3></td>"
112
+ ."<td class=\"form-buttons\">"
113
+ .$buttons
114
+ ."</td>"
115
+ ."</tr></table>"
116
+ ."</div>"
117
+ ;
118
+ }
119
+
120
+ protected function button($label, $onclick, $class_name='') {
121
+ $class_name = 'scalable'.($class_name!='' ? ' '.$class_name : '');
122
+ return "<button type=\"button\" class=\"".$class_name."\" onclick=\"".$onclick."\"><span>".$this->__($label)."</span></button>";
123
+ }
124
+ }
125
+
126
+ ?>
app/code/community/Chronopost/Chronorelais/Helper/Data.php ADDED
@@ -0,0 +1,177 @@
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
+ /**
117
+ * Import configuration
118
+ */
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
+ }
131
+
132
+ /**
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
+ /**
159
+ * Import configuration
160
+ */
161
+ public function getConfigurationSkybillParam() {
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
+ }
app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelais.php ADDED
@@ -0,0 +1,32 @@
1
+ <?php
2
+ abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelais extends Varien_Object
3
+ {
4
+ protected $_code;
5
+ protected $_rates = null;
6
+ protected $_numBoxes = 1;
7
+
8
+ /**
9
+ * Whether this carrier has fixed rates calculation
10
+ *
11
+ * @var bool
12
+ */
13
+ protected $_isFixed = false;
14
+
15
+ const HANDLING_TYPE_PERCENT = 'P';
16
+ const HANDLING_TYPE_FIXED = 'F';
17
+
18
+ const HANDLING_ACTION_PERPACKAGE = 'P';
19
+ const HANDLING_ACTION_PERORDER = 'O';
20
+
21
+ /**
22
+ * Fields that should be replaced in debug with '***'
23
+ *
24
+ * @var array
25
+ */
26
+ protected $_debugReplacePrivateDataKeys = array();
27
+
28
+ public function __construct()
29
+ {
30
+ }
31
+ }
32
+ ?>
app/code/community/Chronopost/Chronorelais/Model/Carrier/AbstractChronorelaisShipping.php ADDED
@@ -0,0 +1,468 @@
1
+ <?php
2
+
3
+ // Pour g�rer les cas o� il y a eu compilation
4
+ if (file_exists(dirname(__FILE__).'/Chronopost_Chronorelais_includes_ChronorelaisShippingHelper.php')) include_once 'Chronopost_Chronorelais_includes_ChronorelaisShippingHelper.php';
5
+ else include_once Mage::getBaseDir('code').'/community/Chronopost/Chronorelais/includes/ChronorelaisShippingHelper.php';
6
+
7
+
8
+
9
+ class OCS_Magento_Product implements OCS_Product {
10
+ private $parent_cart_item;
11
+ private $cart_item;
12
+ private $cart_product;
13
+ private $loaded_product;
14
+ private $quantity;
15
+
16
+ public function OCS_Magento_Product($cart_item, $parent_cart_item) {
17
+ $this->cart_item = $cart_item;
18
+ $this->cart_product = $cart_item->getProduct();
19
+ $this->parent_cart_item = $parent_cart_item;
20
+ $this->quantity = isset($parent_cart_item) ? $parent_cart_item->getQty() : $cart_item->getQty();
21
+ }
22
+
23
+ public function getOption($option_name, $get_by_id=false) {
24
+ $value = null;
25
+ $product = $this->cart_product;
26
+ foreach ($product->getOptions() as $option) {
27
+ if ($option->getTitle()==$option_name) {
28
+ $custom_option = $product->getCustomOption('option_'.$option->getId());
29
+ if ($custom_option) {
30
+ $value = $custom_option->getValue();
31
+ if ($option->getType()=='drop_down' && !$get_by_id) {
32
+ $option_value = $option->getValueById($value);
33
+ if ($option_value) $value = $option_value->getTitle();
34
+ }
35
+ }
36
+ break;
37
+ }
38
+ }
39
+ return $value;
40
+ }
41
+
42
+ public function getAttribute($attribute_name, $get_by_id=false) {
43
+ $value = null;
44
+ $product = $this->_getLoadedProduct();
45
+ $attribute = $product->getResource()->getAttribute($attribute_name);
46
+ if ($attribute) {
47
+ $input_type = $attribute->getFrontend()->getInputType();
48
+ switch ($input_type) {
49
+ case 'select' :
50
+ $value = $get_by_id ? $product->getData($attribute_name) : $product->getAttributeText($attribute_name);
51
+ break;
52
+ default :
53
+ $value = $product->getData($attribute_name);
54
+ break;
55
+ }
56
+ }
57
+ return $value;
58
+ }
59
+
60
+ private function _getLoadedProduct() {
61
+ if (!isset($this->loaded_product)) $this->loaded_product = Mage::getModel('catalog/product')->load($this->cart_product->getId());
62
+ return $this->loaded_product;
63
+ }
64
+
65
+ public function getQuantity() {
66
+ return $this->quantity;
67
+ }
68
+
69
+ public function getName() {
70
+ return $this->cart_product->getName();
71
+ }
72
+
73
+ public function getSku() {
74
+ return $this->cart_product->getSku();
75
+ }
76
+
77
+ public function getStockData($key) {
78
+ $stock = $this->cart_product->getStockItem();
79
+ switch ($key) {
80
+ case 'is_in_stock':
81
+ return (bool)$stock->getIsInStock();
82
+ case 'quantity':
83
+ $quantity = $stock->getQty();
84
+ return $stock->getIsQtyDecimal() ? (float)$quantity : (int)$quantity;
85
+ }
86
+ return null;
87
+ }
88
+ }
89
+
90
+ abstract class Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
91
+ extends Mage_Shipping_Model_Carrier_Abstract
92
+ {
93
+ protected $_translate_inline;
94
+ protected $_result;
95
+ protected $_config;
96
+ protected $_countries;
97
+ protected $_helper;
98
+ protected $_messages;
99
+
100
+ /**
101
+ * Collect rates for this shipping method based on information in $request
102
+ *
103
+ * @param Mage_Shipping_Model_Rate_Request $data
104
+ * @return Mage_Shipping_Model_Rate_Result
105
+ */
106
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
107
+ // skip if not enabled
108
+ if (!$this->__getConfigData('active')) return false;
109
+
110
+ /*foreach ($request->_data as $key => $data) {
111
+ echo $key.' => '.$data.'<br/>';
112
+ }*/
113
+
114
+ $process = array(
115
+ 'request' => $request,
116
+ 'result' => Mage::getModel('shipping/rate_result'),
117
+ 'cart.items' => array(),
118
+ 'products' => array(),
119
+ 'data' => array(
120
+ 'module.version' => null,
121
+ 'carrier.code' => $this->_code,
122
+ 'cart.price_excluding_tax' => $request->_data['package_value_with_discount'],
123
+ 'cart.price_including_tax' => null,
124
+ 'cart.weight' => $request->_data['package_weight'],
125
+ 'cart.weight.unit' => null,
126
+ 'cart.quantity' => $request->_data['package_qty'],
127
+ 'destination.country.code' => $request->_data['dest_country_id'],
128
+ 'destination.country.name' => null,
129
+ 'destination.region.code' => $request->_data['dest_region_code'],
130
+ 'destination.postcode' => $request->_data['dest_postcode'],
131
+ 'origin.country.code' => $request->_data['country_id'],
132
+ 'origin.country.name' => null,
133
+ 'origin.region.code' => $request->_data['region_id'],
134
+ 'origin.postcode' => $request->_data['postcode'],
135
+ 'customer.group.id' => null,
136
+ 'customer.group.code' => null,
137
+ 'free_shipping' => $request->getFreeShipping(),
138
+ 'store.id' => $request->_data['store_id'],
139
+ 'store.code' => null,
140
+ 'store.name' => null,
141
+ 'store.address' => null,
142
+ 'store.phone' => null,
143
+ 'date.timestamp' => null,
144
+ 'date.year' => null,
145
+ 'date.month' => null,
146
+ 'date.day' => null,
147
+ 'date.hour' => null,
148
+ 'date.minute' => null,
149
+ 'date.second' => null,
150
+ ),
151
+ 'stop_to_first_match' => null,
152
+ 'config' => null,
153
+ );
154
+
155
+ $items = $request->getAllItems();
156
+ for ($i=0, $n=count($items); $i<$n; $i++) {
157
+ $item = $items[$i];
158
+ if ($item->getProduct() instanceof Mage_Catalog_Model_Product) $process['cart.items'][$item->getId()] = $item;
159
+ }
160
+
161
+ $process_result = $this->_process($process);
162
+
163
+ return $process['result'];
164
+ }
165
+
166
+
167
+ public function getAllowedMethods() {
168
+ $process = array();
169
+ $config = $this->_getConfig();
170
+ $allowed_methods = array();
171
+ if (count($config)>0) {
172
+ foreach ($config as $row) $allowed_methods[$row['*code']] = isset($row['label']) ? $row['label']['value'] : 'No label';
173
+ }
174
+ return $allowed_methods;
175
+ }
176
+
177
+ public function isTrackingAvailable() {
178
+ return true;
179
+ }
180
+
181
+ public function getTrackingInfo($tracking_number) {
182
+ $tracking_url = Mage::helper('chronorelais')->getConfigurationTrackingViewUrl();
183
+ $parts = explode(':',$tracking_number);
184
+ if (count($parts)>=2) {
185
+ $tracking_number = $parts[1];
186
+
187
+ $process = array();
188
+ $config = $this->_getConfig();
189
+
190
+ if (isset($config[$parts[0]]['tracking_url'])) {
191
+ $row = $config[$parts[0]];
192
+ $tmp_tracking_url = $this->_helper->getRowProperty($row,'tracking_url');
193
+ if (isset($tmp_tracking_url)) $tracking_url = $tmp_tracking_url;
194
+ }
195
+ }
196
+
197
+ $tracking_status = Mage::getModel('shipping/tracking_result_status')
198
+ ->setCarrier($this->_code)
199
+ ->setCarrierTitle($this->__getConfigData('title'))
200
+ ->setTracking($tracking_number)
201
+ ->addData(
202
+ array(
203
+ 'status'=>'<a target="_blank" href="'.str_replace('{tracking_number}',$tracking_number,$tracking_url).'">'.__('track the package').'</a>'
204
+ )
205
+ )
206
+ ;
207
+ $tracking_result = Mage::getModel('shipping/tracking_result')
208
+ ->append($tracking_status)
209
+ ;
210
+
211
+ if ($trackings = $tracking_result->getAllTrackings()) return $trackings[0];
212
+ return false;
213
+ }
214
+
215
+
216
+ /***************************************************************************************************************************/
217
+
218
+ protected function _process(&$process) {
219
+ $store = Mage::app()->getStore($process['data']['store.id']);
220
+ $mage_config = Mage::getConfig();
221
+ $timestamp = time();
222
+ $customer_group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();
223
+ // Pour les commandes depuis Adminhtml
224
+ if ($customer_group_id==0) {
225
+ $customer_group_id2 = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getCustomerGroupId();
226
+ if (isset($customer_group_id2)) $customer_group_id = $customer_group_id2;
227
+ }
228
+
229
+ $customer_group_code = Mage::getSingleton('customer/group')->load($customer_group_id)->getData('customer_group_code');
230
+ $process['data'] = array_merge($process['data'],array(
231
+ 'customer.group.id' => $customer_group_id,
232
+ 'customer.group.code' => $customer_group_code,
233
+ 'destination.country.name' => $this->__getCountryName($process['data']['destination.country.code']),
234
+ 'origin.country.name' => $this->__getCountryName($process['data']['origin.country.code']),
235
+ 'cart.weight.unit' => Mage::getStoreConfig('chronorelais/shipping/weight_unit'),
236
+ 'store.code' => $store->getCode(),
237
+ 'store.name' => $store->getConfig('general/store_information/name'),
238
+ 'store.address' => $store->getConfig('general/store_information/address'),
239
+ 'store.phone' => $store->getConfig('general/store_information/phone'),
240
+ 'date.timestamp' => $timestamp,
241
+ 'date.year' => (int)date('Y',$timestamp),
242
+ 'date.month' => (int)date('m',$timestamp),
243
+ 'date.day' => (int)date('d',$timestamp),
244
+ 'date.hour' => (int)date('H',$timestamp),
245
+ 'date.minute' => (int)date('i',$timestamp),
246
+ 'date.second' => (int)date('s',$timestamp),
247
+ 'module.version' => (string)$mage_config->getNode('modules/Chronopost_Chronorelais/version'),
248
+ ));
249
+
250
+ foreach ($process['cart.items'] as $id => $item) {
251
+ if ($item->getProduct()->getTypeId()!='configurable') {
252
+ $parent_item_id = $item->getParentItemId();
253
+ $process['products'][] = new OCS_Magento_Product($item, isset($process['cart.items'][$parent_item_id]) ? $process['cart.items'][$parent_item_id] : null);
254
+ }
255
+ }
256
+
257
+ if (!$process['data']['free_shipping']) {
258
+ foreach ($process['cart.items'] as $item) {
259
+ if ($item->getProduct() instanceof Mage_Catalog_Model_Product) {
260
+ if ($item->getFreeShipping()) $process['data']['free_shipping'] = true;
261
+ else {
262
+ $process['data']['free_shipping'] = false;
263
+ break;
264
+ }
265
+ }
266
+ }
267
+ }
268
+
269
+ $process['data']['cart.price_including_tax'] = $this->__getCartTaxAmount($process)+$process['data']['cart.price_excluding_tax'];
270
+ $process['stop_to_first_match'] = $this->__getConfigData('stop_to_first_match');
271
+ $process['config'] = $this->_getConfig();
272
+ $compression = $this->__getConfigData('auto_compression');
273
+ if ($compression=='compress') {
274
+ Mage::getConfig()->saveConfig('carriers/'.$this->_code.'/config',$this->_helper->formatConfig(true));
275
+ } else if ($compression=='uncompress') {
276
+ Mage::getConfig()->saveConfig('carriers/'.$this->_code.'/config',$this->_helper->formatConfig(false));
277
+ }
278
+
279
+ $this->_helper->debug = (int)(isset($_GET['debug']) ? $_GET['debug'] : $this->__getConfigData('debug'));
280
+ $http_request = Mage::app()->getFrontController()->getRequest();
281
+ $this->_helper->debug = $this->_helper->debug && $http_request->getRouteName()=='checkout' && $http_request->getControllerName()=='cart';
282
+ if ($this->_helper->debug) $this->_helper->setDebugHeader($process);
283
+
284
+ $value_found = false;
285
+ $process_continue = true;
286
+
287
+ //Set error messages if not any matching
288
+ $errorMsg = '';
289
+ $defaultErrorMsg = Mage::helper('shipping')->__('The shipping module is not available.');
290
+ $configErrorMsg = $this->__getConfigData('specificerrmsg');
291
+ $configErrorMsg = ($configErrorMsg ? $configErrorMsg : $defaultErrorMsg);
292
+ $freeShippingEnable = $this->__getConfigData('free_shipping_enable');
293
+ $freeShippingSubtotal = $this->__getConfigData('free_shipping_subtotal');
294
+ $applicationFee = $this->__getConfigData('application_fee');
295
+ $handlingFee = $this->__getConfigData('handling_fee');
296
+
297
+ /* Check weight limit with cart weight*/
298
+ $weight_limit = $this->__getConfigData('weight_limit');
299
+ if($process['data']['cart.weight']>$weight_limit) {
300
+ $value_found = false;
301
+ $process_continue = false;
302
+ }
303
+
304
+ if($process_continue) {
305
+ foreach ($process['config'] as $row) {
306
+ $result = $this->_helper->processRow($process,$row);
307
+ $this->_addMessages($this->_helper->getMessages());
308
+ if ($result->success) {
309
+ $value_found = true;
310
+ $fees = $result->result;
311
+ if($applicationFee) { $fees += $applicationFee; }
312
+ if($handlingFee) { $fees += $handlingFee; }
313
+ if($freeShippingEnable && ($freeShippingSubtotal<=$process['data']['cart.price_excluding_tax'])) {
314
+ $fees = 0;
315
+ }
316
+ $this->__appendMethod($process,$row,$fees);
317
+ if ($process['stop_to_first_match']) break;
318
+ }
319
+ }
320
+ }
321
+ $this->_helper->printDebug();
322
+
323
+ $this->_appendErrors($process,$this->_messages);
324
+ if (!$value_found) $this->__appendError($process,$this->__($configErrorMsg));
325
+ }
326
+
327
+ protected function _getConfig() {
328
+ if (!isset($this->_config)) {
329
+ $this->_helper = new ChronorelaisShippingHelper($this->__getConfigData('config'));
330
+ $this->_config = $this->_helper->getConfig();
331
+ $this->_addMessages($this->_helper->getMessages());
332
+ }
333
+ return $this->_config;
334
+ }
335
+
336
+ protected function _getMethodText($process, $row, $property) {
337
+ if (!isset($row[$property])) return '';
338
+
339
+ $output = '';
340
+ /*$i = 0;
341
+ foreach ($process['request']->_data as $key => $data) {
342
+ if ($i>12) $output .= $key.' => '.$data.'<br/>';
343
+ $i++;
344
+ }*/
345
+
346
+ return $output . ' '.$this->_helper->evalInput($process,$row,$property,str_replace(
347
+ array('{cart.weight}','{cart.price_including_tax}','{cart.price_excluding_tax}'),
348
+ array(
349
+ $process['data']['cart.weight'].$process['data']['cart.weight.unit'],
350
+ $this->__formatPrice($process['data']['cart.price_including_tax']),
351
+ $this->__formatPrice($process['data']['cart.price_excluding_tax'])
352
+ ),
353
+ $this->_helper->getRowProperty($row,$property)
354
+ ));
355
+ }
356
+
357
+ protected function _addMessages($messages) {
358
+ if (!is_array($messages)) $messages = array($messages);
359
+ if (!is_array($this->_messages)) $this->_messages = $messages;
360
+ else $this->_messages = array_merge($this->_messages,$messages);
361
+ }
362
+
363
+ protected function _appendErrors(&$process, $messages) {
364
+ if (is_array($messages)) {
365
+ foreach ($messages as $message) {
366
+ $this->__appendError($process,$this->__($message));
367
+ }
368
+ }
369
+ }
370
+
371
+ /***************************************************************************************************************************/
372
+
373
+ protected function __getConfigData($key) {
374
+ return $this->getConfigData($key);
375
+ }
376
+
377
+ protected function __appendMethod(&$process, $row, $fees) {
378
+ $method = Mage::getModel('shipping/rate_result_method')
379
+ ->setCarrier($this->_code)
380
+ ->setCarrierTitle($this->__getConfigData('title'))
381
+ ->setMethod($row['*code'])
382
+ ->setMethodTitle($this->_getMethodText($process,$row,'label'))
383
+ ->setMethodDescription($this->_getMethodText($process,$row,'description'))
384
+ ->setMethodLogo($this->__getConfigData('logo_url'))
385
+ ->setPrice($fees)
386
+ ->setCost($fees)
387
+ ;
388
+ $process['result']->append($method);
389
+ }
390
+
391
+ protected function __appendError(&$process, $message) {
392
+ if (isset($process['result'])) {
393
+ $error = Mage::getModel('shipping/rate_result_error')
394
+ ->setCarrier($this->_code)
395
+ ->setCarrierTitle($this->__getConfigData('title'))
396
+ ->setErrorMessage($message)
397
+ ;
398
+ $process['result']->append($error);
399
+ }
400
+ }
401
+
402
+ protected function __formatPrice($price) {
403
+ if (!isset($this->_core_helper)) $this->_core_helper = Mage::helper('core');
404
+ return $this->_core_helper->currency($price);
405
+ }
406
+
407
+ protected function __($message) {
408
+ $args = func_get_args();
409
+ $message = array_shift($args);
410
+ if ($message instanceof OCS_Message) {
411
+ $args = $message->args;
412
+ $message = $message->message;
413
+ }
414
+
415
+ $output = Mage::helper('shipping')->__($message);
416
+ if (count($args)==0) return $output;
417
+
418
+ if (!isset($this->_translate_inline)) $this->_translate_inline = Mage::getSingleton('core/translate')->getTranslateInline();
419
+ if ($this->_translate_inline) {
420
+ $parts = explode('}}{{',$output);
421
+ $parts[0] = vsprintf($parts[0],$args);
422
+ return implode('}}{{',$parts);
423
+ }
424
+ else return vsprintf($output,$args);
425
+ }
426
+
427
+ protected function __getCountryName($country_code) {
428
+ return Mage::getModel('directory/country')->load($country_code)->getName();
429
+ //return Mage::app()->getLocale()->getCountryTranslation($country_code);
430
+ /*if (!isset($this->_countries)) {
431
+ // deprecated
432
+ //$this->_countries = Mage::getModel('core/locale')->getLocale()->getCountryTranslationList();
433
+ $this->_countries = Mage::getModel('core/locale')->getLocale()->getTranslationList('territory',null,2);
434
+ }
435
+ return isset($this->_countries[$country_code]) ? $this->_countries[$country_code] : $country_code;*/
436
+ }
437
+
438
+ /*
439
+ protected function __getCartTaxAmount($process) {
440
+ $tax_amount = 0;
441
+
442
+ foreach ($process['cart.items'] as $item) {
443
+ $tax_class_id = $item->getProduct()->getTaxClassId();
444
+ $request = Mage::getSingleton('tax/calculation')->getRateRequest();
445
+ $request->setProductClassId($tax_class_id);
446
+ $vat_rate = Mage::getSingleton('tax/calculation')->getRate($request);
447
+ $vat_rate = isset($rates[$tax_class_id]) ? $rates[$tax_class_id] : 0;
448
+
449
+ if ($vat_rate > 0) $vat_to_add = $item->getData('row_total_with_discount')*$vat_rate/100;
450
+ else $vat_to_add = $item->getData('tax_amount');
451
+ //echo $item->getProduct()->getName().', '.$item->getData('row_total_with_discount').', '.$vat_rate.', '.$vat_to_add.'<br />';
452
+ $tax_amount += $vat_to_add;
453
+ }
454
+ //echo 'tax:'.$tax_amount.'<br />';
455
+ return $tax_amount;
456
+ }
457
+ */
458
+
459
+ protected function __getCartTaxAmount($process) {
460
+ $tax_amount = 0;
461
+ foreach ($process['cart.items'] as $item) {
462
+ $tax_amount += $item->getData('tax_amount');
463
+ }
464
+ return $tax_amount;
465
+ }
466
+ }
467
+
468
+ ?>
app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronoexpress.php ADDED
@@ -0,0 +1,6 @@
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Carrier_Chronoexpress extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
+ {
4
+ protected $_code = 'chronoexpress';
5
+
6
+ }
app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronopost.php ADDED
@@ -0,0 +1,6 @@
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Carrier_Chronopost extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
+ {
4
+ protected $_code = 'chronopost';
5
+
6
+ }
app/code/community/Chronopost/Chronorelais/Model/Carrier/Chronorelais.php ADDED
@@ -0,0 +1,6 @@
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Carrier_Chronorelais extends Chronopost_Chronorelais_Model_Carrier_AbstractChronorelaisShipping
3
+ {
4
+ protected $_code = 'chronorelais';
5
+
6
+ }
app/code/community/Chronopost/Chronorelais/Model/Config/Source/Civility.php ADDED
@@ -0,0 +1,12 @@
1
+ <?php
2
+ class Chronopost_Chronorelais_Model_Config_Source_Civility
3
+ {
4
+ public function toOptionArray()
5