Version Notes
Modification des URLs du module pour compatibilité avec patch SUPEE-6788
Download this release
Release Info
Developer | Berlioz |
Extension | ColiPoste_La_Poste_Expeditor_Inet_So_Colissimo |
Version | 1.0.8 |
Comparing to | |
See all releases |
Code changes from version 1.0.7 to 1.0.8
- app/code/community/LaPoste/ExpeditorINet/controllers/Adminhtml/Expeditorinet/ExportController.php +256 -0
- app/code/community/LaPoste/ExpeditorINet/controllers/Adminhtml/Expeditorinet/ImportController.php +208 -0
- app/code/community/LaPoste/ExpeditorINet/controllers/{ExportController.php → Adminhtml/ExportController.php} +1 -1
- app/code/community/LaPoste/ExpeditorINet/controllers/{ImportController.php → Adminhtml/ImportController.php} +1 -1
- app/code/community/LaPoste/ExpeditorINet/etc/adminhtml.xml +4 -4
- app/code/community/LaPoste/ExpeditorINet/etc/config.xml +6 -6
- package.xml +5 -5
app/code/community/LaPoste/ExpeditorINet/controllers/Adminhtml/Expeditorinet/ExportController.php
ADDED
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LaPoste_ExpeditorINet
|
4 |
+
*
|
5 |
+
* @category LaPoste
|
6 |
+
* @package LaPoste_ExpeditorINet
|
7 |
+
* @copyright Copyright (c) 2010 La Poste
|
8 |
+
* @author Smile (http://www.smile.fr) & Jibé
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class LaPoste_ExpeditorINet_Adminhtml_Expeditorinet_ExportController extends Mage_Adminhtml_Controller_Action
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Constructor
|
15 |
+
*
|
16 |
+
* @return void
|
17 |
+
*/
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
$this->setUsedModuleName('LaPoste_ExpeditorINet');
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Check whether the admin user has access to this controller.
|
25 |
+
*
|
26 |
+
* @return bool
|
27 |
+
*/
|
28 |
+
protected function _isAllowed()
|
29 |
+
{
|
30 |
+
return Mage::getSingleton('admin/session')->isAllowed('sales/expeditorinet/export');
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Main action : show orders list
|
35 |
+
*
|
36 |
+
* @return void
|
37 |
+
*/
|
38 |
+
public function indexAction()
|
39 |
+
{
|
40 |
+
$this->loadLayout()
|
41 |
+
->_setActiveMenu('sales/expeditorinet/export')
|
42 |
+
->_addContent($this->getLayout()->createBlock('expeditorinet/export_orders'))
|
43 |
+
->renderLayout();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Convert civility in letters to a code for Expeditor
|
48 |
+
*
|
49 |
+
* @param string $civility a civility
|
50 |
+
* @return int
|
51 |
+
*/
|
52 |
+
protected function _getExpeditorCodeForCivility($civility)
|
53 |
+
{
|
54 |
+
if ($civility === 'MR') {
|
55 |
+
return 2;
|
56 |
+
} elseif ($civility === 'MME') {
|
57 |
+
return 3;
|
58 |
+
} elseif ($civility === 'MLE') {
|
59 |
+
return 4;
|
60 |
+
} else {
|
61 |
+
return 1;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Export Action
|
67 |
+
* Generates a CSV file to download
|
68 |
+
*
|
69 |
+
* @return void
|
70 |
+
*/
|
71 |
+
public function exportAction()
|
72 |
+
{
|
73 |
+
// get the orders
|
74 |
+
$orderIds = $this->getRequest()->getPost('order_ids');
|
75 |
+
|
76 |
+
// get configuration
|
77 |
+
$separator = Mage::helper('expeditorinet')->getConfigurationFieldSeparator();
|
78 |
+
$delimiter = Mage::helper('expeditorinet')->getConfigurationFieldDelimiter();
|
79 |
+
if ($delimiter === 'simple_quote') {
|
80 |
+
$delimiter = "'";
|
81 |
+
} elseif ($delimiter === 'double_quotes') {
|
82 |
+
$delimiter = '"';
|
83 |
+
}
|
84 |
+
$lineBreak = Mage::helper('expeditorinet')->getConfigurationEndOfLineCharacter();
|
85 |
+
if ($lineBreak === 'lf') {
|
86 |
+
$lineBreak = "\n";
|
87 |
+
} elseif ($lineBreak === 'cr') {
|
88 |
+
$lineBreak = "\r";
|
89 |
+
} elseif ($lineBreak === 'crlf') {
|
90 |
+
$lineBreak = "\r\n";
|
91 |
+
}
|
92 |
+
$fileExtension = Mage::helper('expeditorinet')->getConfigurationFileExtension();
|
93 |
+
$fileCharset = Mage::helper('expeditorinet')->getConfigurationFileCharset();
|
94 |
+
|
95 |
+
// So Colissimo product codes for Hors Domicile
|
96 |
+
$hdProductCodes = Mage::helper('expeditorinet')->getPickupPointCodes();
|
97 |
+
|
98 |
+
// set the filename
|
99 |
+
$filename = 'orders_export_'.Mage::getSingleton('core/date')->date('Ymd_His') . $fileExtension;
|
100 |
+
|
101 |
+
// get company commercial name
|
102 |
+
$commercialName = Mage::helper('expeditorinet')->getCompanyCommercialName();
|
103 |
+
|
104 |
+
// initialize the content variable
|
105 |
+
$content = '';
|
106 |
+
|
107 |
+
if (!empty($orderIds)) {
|
108 |
+
foreach ($orderIds as $orderId) {
|
109 |
+
// get the order
|
110 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
111 |
+
|
112 |
+
// if the product code is for Hors Domicile we should take the billing address
|
113 |
+
if (in_array($order->getSocoProductCode(), $hdProductCodes)) {
|
114 |
+
// get the shipping address
|
115 |
+
$address = $order->getBillingAddress();
|
116 |
+
} else {
|
117 |
+
// get the billing address
|
118 |
+
$address = $order->getShippingAddress();
|
119 |
+
}
|
120 |
+
|
121 |
+
// real order id
|
122 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $order->getRealOrderId());
|
123 |
+
$content .= $separator;
|
124 |
+
// customer first name
|
125 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $address->getFirstname());
|
126 |
+
$content .= $separator;
|
127 |
+
// customer last name
|
128 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $address->getLastname());
|
129 |
+
$content .= $separator;
|
130 |
+
// customer company
|
131 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $address->getCompany());
|
132 |
+
$content .= $separator;
|
133 |
+
// street address, on 4 fields
|
134 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $address->getStreet(1));
|
135 |
+
$content .= $separator;
|
136 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $address->getStreet(2));
|
137 |
+
$content .= $separator;
|
138 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $address->getStreet(3));
|
139 |
+
$content .= $separator;
|
140 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $address->getStreet(4));
|
141 |
+
$content .= $separator;
|
142 |
+
// postal code
|
143 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $address->getPostcode());
|
144 |
+
$content .= $separator;
|
145 |
+
// city
|
146 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $address->getCity());
|
147 |
+
$content .= $separator;
|
148 |
+
// country code
|
149 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $address->getCountry());
|
150 |
+
$content .= $separator;
|
151 |
+
// portable phone number
|
152 |
+
$telephone = '';
|
153 |
+
if ($order->getSocoPhoneNumber() != '' && $order->getSocoPhoneNumber() != null) {
|
154 |
+
$telephone = $order->getSocoPhoneNumber();
|
155 |
+
} elseif ($address->getTelephone() != '' && $address->getTelephone() != null) {
|
156 |
+
$telephone = $address->getTelephone();
|
157 |
+
}
|
158 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $telephone);
|
159 |
+
$content .= $separator;
|
160 |
+
// product code
|
161 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $this->_getProductCode($order));
|
162 |
+
$content .= $separator;
|
163 |
+
// shipping instruction
|
164 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $order->getSocoShippingInstruction());
|
165 |
+
$content .= $separator;
|
166 |
+
// civility
|
167 |
+
$civility = $this->_getExpeditorCodeForCivility($order->getSocoCivility());
|
168 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $civility);
|
169 |
+
$content .= $separator;
|
170 |
+
// door code 1
|
171 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $order->getSocoDoorCode1());
|
172 |
+
$content .= $separator;
|
173 |
+
// door code 2
|
174 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $order->getSocoDoorCode2());
|
175 |
+
$content .= $separator;
|
176 |
+
// interphone
|
177 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $order->getSocoInterphone());
|
178 |
+
$content .= $separator;
|
179 |
+
// relay point code
|
180 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $order->getSocoRelayPointCode());
|
181 |
+
$content .= $separator;
|
182 |
+
// network code
|
183 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $order->getSocoNetworkCode());
|
184 |
+
$content .= $separator;
|
185 |
+
// email
|
186 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $order->getSocoEmail());
|
187 |
+
$content .= $separator;
|
188 |
+
|
189 |
+
// total weight
|
190 |
+
$total_weight = 0;
|
191 |
+
$items = $order->getAllItems();
|
192 |
+
foreach ($items as $item) {
|
193 |
+
$total_weight += $item['row_weight'];
|
194 |
+
}
|
195 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $total_weight);
|
196 |
+
$content .= $separator;
|
197 |
+
|
198 |
+
// company commercial name
|
199 |
+
$content = $this->_addFieldToCsv($content, $delimiter, $commercialName);
|
200 |
+
|
201 |
+
$content .= $lineBreak;
|
202 |
+
}
|
203 |
+
|
204 |
+
// decode the content, depending on the charset
|
205 |
+
if ($fileCharset == 'ISO-8859-1') {
|
206 |
+
$content = utf8_decode($content);
|
207 |
+
}
|
208 |
+
|
209 |
+
// pick file mime type, depending on the extension
|
210 |
+
if ($fileExtension == '.txt') {
|
211 |
+
$fileMimeType = 'text/plain';
|
212 |
+
} elseif ($fileExtension == '.csv') {
|
213 |
+
$fileMimeType = 'application/csv';
|
214 |
+
} else {
|
215 |
+
// default
|
216 |
+
$fileMimeType = 'text/plain';
|
217 |
+
}
|
218 |
+
|
219 |
+
// download the file
|
220 |
+
return $this->_prepareDownloadResponse($filename, $content, $fileMimeType .'; charset="'. $fileCharset .'"');
|
221 |
+
} else {
|
222 |
+
$this->_getSession()->addError($this->__('No Order has been selected'));
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Add a new field to the csv file
|
228 |
+
*
|
229 |
+
* @param csvContent the current csv content
|
230 |
+
* @param fieldDelimiter the delimiter character
|
231 |
+
* @param fieldContent the content to add
|
232 |
+
* @return string
|
233 |
+
*/
|
234 |
+
protected function _addFieldToCsv($csvContent, $fieldDelimiter, $fieldContent)
|
235 |
+
{
|
236 |
+
return $csvContent . $fieldDelimiter . $fieldContent . $fieldDelimiter;
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Get the So Colissimo product code stored in the order data.
|
241 |
+
*
|
242 |
+
* @param Mage_Sales_Model_Order $order the order
|
243 |
+
* @return string
|
244 |
+
*/
|
245 |
+
protected function _getProductCode($order)
|
246 |
+
{
|
247 |
+
$value = $order->getSocoProductCode();
|
248 |
+
|
249 |
+
// request a signature for home delivery
|
250 |
+
if ($value === 'DOM' && Mage::helper('expeditorinet')->getConfigurationSignatureRequired()) {
|
251 |
+
$value = 'DOS';
|
252 |
+
}
|
253 |
+
|
254 |
+
return $value;
|
255 |
+
}
|
256 |
+
}
|
app/code/community/LaPoste/ExpeditorINet/controllers/Adminhtml/Expeditorinet/ImportController.php
ADDED
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LaPoste_ExpeditorINet
|
4 |
+
*
|
5 |
+
* @category LaPoste
|
6 |
+
* @package LaPoste_ExpeditorINet
|
7 |
+
* @copyright Copyright (c) 2010 La Poste
|
8 |
+
* @author Smile (http://www.smile.fr) & Jibé
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class LaPoste_ExpeditorINet_Adminhtml_Expeditorinet_ImportController extends Mage_Adminhtml_Controller_Action
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Constructor
|
15 |
+
*
|
16 |
+
* @return void
|
17 |
+
*/
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
$this->setUsedModuleName('LaPoste_ExpeditorINet');
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Check whether the admin user has access to this controller.
|
25 |
+
*
|
26 |
+
* @return bool
|
27 |
+
*/
|
28 |
+
protected function _isAllowed()
|
29 |
+
{
|
30 |
+
return Mage::getSingleton('admin/session')->isAllowed('sales/expeditorinet/import');
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Main action : show import form
|
35 |
+
*
|
36 |
+
* @return void
|
37 |
+
*/
|
38 |
+
public function indexAction()
|
39 |
+
{
|
40 |
+
$this->loadLayout()
|
41 |
+
->_setActiveMenu('sales/expeditorinet/import')
|
42 |
+
->_addContent($this->getLayout()->createBlock('expeditorinet/import_form'))
|
43 |
+
->renderLayout();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Import Action
|
48 |
+
*
|
49 |
+
* @return void
|
50 |
+
*/
|
51 |
+
public function importAction()
|
52 |
+
{
|
53 |
+
if ($this->getRequest()->isPost() && !empty($_FILES['import_expeditor_inet_file']['tmp_name'])) {
|
54 |
+
try {
|
55 |
+
$trackingTitle = $_POST['import_expeditor_inet_tracking_title'];
|
56 |
+
$this->_importExpeditorInetFile($_FILES['import_expeditor_inet_file']['tmp_name'], $trackingTitle);
|
57 |
+
} catch (Mage_Core_Exception $e) {
|
58 |
+
$this->_getSession()->addError($e->getMessage());
|
59 |
+
} catch (Exception $e) {
|
60 |
+
$this->_getSession()->addError($e->getMessage());
|
61 |
+
$this->_getSession()->addError($this->__('Invalid file upload attempt'));
|
62 |
+
}
|
63 |
+
} else {
|
64 |
+
$this->_getSession()->addError($this->__('Invalid file upload attempt'));
|
65 |
+
}
|
66 |
+
$this->_redirect('*/*/index');
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Importation logic
|
71 |
+
*
|
72 |
+
* @param string $fileName
|
73 |
+
* @param string $trackingTitle
|
74 |
+
* @return void
|
75 |
+
*/
|
76 |
+
protected function _importExpeditorInetFile($fileName, $trackingTitle)
|
77 |
+
{
|
78 |
+
// file handling
|
79 |
+
ini_set('auto_detect_line_endings', true);
|
80 |
+
$csvObject = new Varien_File_Csv();
|
81 |
+
$csvData = $csvObject->getData($fileName);
|
82 |
+
|
83 |
+
// file expected fields
|
84 |
+
$expectedCsvFields = array(
|
85 |
+
0 => $this->__('Order Id'),
|
86 |
+
1 => $this->__('Tracking Number'),
|
87 |
+
);
|
88 |
+
|
89 |
+
// get configuration
|
90 |
+
$sendEmail = Mage::helper('expeditorinet')->getConfigurationSendEmail();
|
91 |
+
$comment = Mage::helper('expeditorinet')->getConfigurationShippingComment();
|
92 |
+
$includeComment = Mage::helper('expeditorinet')->getConfigurationIncludeComment();
|
93 |
+
|
94 |
+
// $k is line number, $v is line content array
|
95 |
+
foreach ($csvData as $k => $v) {
|
96 |
+
// end of file has more than one empty lines
|
97 |
+
if (count($v) <= 1 && !strlen($v[0])) {
|
98 |
+
continue;
|
99 |
+
}
|
100 |
+
|
101 |
+
// check that the number of fields is not lower than expected
|
102 |
+
if (count($v) < count($expectedCsvFields)) {
|
103 |
+
$this->_getSession()->addError($this->__('Line %s format is invalid and has been ignored', $k));
|
104 |
+
continue;
|
105 |
+
}
|
106 |
+
|
107 |
+
// get fields content
|
108 |
+
$orderId = $v[0];
|
109 |
+
$trackingNumber = $v[1];
|
110 |
+
|
111 |
+
// try to load the order
|
112 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
113 |
+
if (!$order->getId()) {
|
114 |
+
$this->_getSession()->addError($this->__('Order %s does not exist', $orderId));
|
115 |
+
continue;
|
116 |
+
}
|
117 |
+
|
118 |
+
// try to create a shipment
|
119 |
+
$shipmentId = $this->_createShipment($order, $trackingNumber, $trackingTitle, $sendEmail, $comment, $includeComment);
|
120 |
+
|
121 |
+
if ($shipmentId != 0) {
|
122 |
+
$this->_getSession()->addSuccess($this->__('Shipment %s created for order %s, with tracking number %s', $shipmentId, $orderId, $trackingNumber));
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Create new shipment for order
|
129 |
+
* Inspired by Mage_Sales_Model_Order_Shipment_Api methods
|
130 |
+
*
|
131 |
+
* @param Mage_Sales_Model_Order $order (it should exist, no control is done into the method)
|
132 |
+
* @param string $trackingNumber
|
133 |
+
* @param string $trackingTitle
|
134 |
+
* @param booleam $email
|
135 |
+
* @param string $comment
|
136 |
+
* @param boolean $includeComment
|
137 |
+
* @return int : shipment real id if creation was ok, else 0
|
138 |
+
*/
|
139 |
+
public function _createShipment($order, $trackingNumber, $trackingTitle, $email, $comment, $includeComment)
|
140 |
+
{
|
141 |
+
// check shipment creation availability
|
142 |
+
if (!$order->canShip()) {
|
143 |
+
$this->_getSession()->addError($this->__('Order %s can not be shipped or has already been shipped', $order->getRealOrderId()));
|
144 |
+
return 0;
|
145 |
+
}
|
146 |
+
|
147 |
+
// initialize the Mage_Sales_Model_Order_Shipment object
|
148 |
+
$convertor = Mage::getModel('sales/convert_order');
|
149 |
+
$shipment = $convertor->toShipment($order);
|
150 |
+
|
151 |
+
// add the items to send
|
152 |
+
foreach ($order->getAllItems() as $orderItem) {
|
153 |
+
if (!$orderItem->getQtyToShip()) {
|
154 |
+
continue;
|
155 |
+
}
|
156 |
+
|
157 |
+
if ($orderItem->getIsVirtual()) {
|
158 |
+
continue;
|
159 |
+
}
|
160 |
+
|
161 |
+
$item = $convertor->itemToShipmentItem($orderItem);
|
162 |
+
$qty = $orderItem->getQtyToShip();
|
163 |
+
$item->setQty($qty);
|
164 |
+
|
165 |
+
$shipment->addItem($item);
|
166 |
+
}
|
167 |
+
|
168 |
+
$shipment->register();
|
169 |
+
|
170 |
+
// tracking number instanciation
|
171 |
+
$carrierCode = Mage::helper('expeditorinet')->getConfigurationCarrierCode();
|
172 |
+
if (!$carrierCode) {
|
173 |
+
$carrierCode = 'custom';
|
174 |
+
}
|
175 |
+
|
176 |
+
$track = Mage::getModel('sales/order_shipment_track')
|
177 |
+
->setNumber($trackingNumber)
|
178 |
+
->setCarrierCode($carrierCode)
|
179 |
+
->setTitle($trackingTitle);
|
180 |
+
$shipment->addTrack($track);
|
181 |
+
|
182 |
+
// comment handling
|
183 |
+
$shipment->addComment($comment, $email && $includeComment);
|
184 |
+
|
185 |
+
// change order status to Processing
|
186 |
+
$shipment->getOrder()->setIsInProcess(true);
|
187 |
+
|
188 |
+
// if e-mail, set as sent (must be done before shipment object saving)
|
189 |
+
if ($email) {
|
190 |
+
$shipment->setEmailSent(true);
|
191 |
+
}
|
192 |
+
|
193 |
+
try {
|
194 |
+
// save the created shipment and the updated order
|
195 |
+
$shipment->save();
|
196 |
+
$shipment->getOrder()->save();
|
197 |
+
|
198 |
+
// email sending
|
199 |
+
$shipment->sendEmail($email, ($includeComment ? $comment : ''));
|
200 |
+
} catch (Mage_Core_Exception $e) {
|
201 |
+
$this->_getSession()->addError($this->__('Shipment creation error for Order %s : %s', $orderId, $e->getMessage()));
|
202 |
+
return 0;
|
203 |
+
}
|
204 |
+
|
205 |
+
// everything was ok : return Shipment real id
|
206 |
+
return $shipment->getIncrementId();
|
207 |
+
}
|
208 |
+
}
|
app/code/community/LaPoste/ExpeditorINet/controllers/{ExportController.php → Adminhtml/ExportController.php}
RENAMED
@@ -8,7 +8,7 @@
|
|
8 |
* @author Smile (http://www.smile.fr) & Jibé
|
9 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
/**
|
14 |
* Constructor
|
8 |
* @author Smile (http://www.smile.fr) & Jibé
|
9 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
*/
|
11 |
+
class LaPoste_ExpeditorINet_Adminhtml_ExportController extends Mage_Adminhtml_Controller_Action
|
12 |
{
|
13 |
/**
|
14 |
* Constructor
|
app/code/community/LaPoste/ExpeditorINet/controllers/{ImportController.php → Adminhtml/ImportController.php}
RENAMED
@@ -8,7 +8,7 @@
|
|
8 |
* @author Smile (http://www.smile.fr) & Jibé
|
9 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
/**
|
14 |
* Constructor
|
8 |
* @author Smile (http://www.smile.fr) & Jibé
|
9 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
*/
|
11 |
+
class LaPoste_ExpeditorINet_Adminhtml_ImportController extends Mage_Adminhtml_Controller_Action
|
12 |
{
|
13 |
/**
|
14 |
* Constructor
|
app/code/community/LaPoste/ExpeditorINet/etc/adminhtml.xml
CHANGED
@@ -14,18 +14,18 @@
|
|
14 |
<menu>
|
15 |
<sales>
|
16 |
<children>
|
17 |
-
<expeditorinet translate="title"
|
18 |
<title>La Poste Expeditor INet</title>
|
19 |
<sort_order>15</sort_order>
|
20 |
<children>
|
21 |
<export translate="title">
|
22 |
<title>Export orders</title>
|
23 |
-
<action>
|
24 |
<sort_order>10</sort_order>
|
25 |
</export>
|
26 |
<import translate="title">
|
27 |
<title>Import shipping</title>
|
28 |
-
<action>
|
29 |
<sort_order>20</sort_order>
|
30 |
</import>
|
31 |
</children>
|
@@ -39,7 +39,7 @@
|
|
39 |
<children>
|
40 |
<sales>
|
41 |
<children>
|
42 |
-
<expeditorinet translate="title">
|
43 |
<title>La Poste Expeditor INet</title>
|
44 |
<children>
|
45 |
<export translate="title">
|
14 |
<menu>
|
15 |
<sales>
|
16 |
<children>
|
17 |
+
<expeditorinet translate="title" module="expeditorinet">
|
18 |
<title>La Poste Expeditor INet</title>
|
19 |
<sort_order>15</sort_order>
|
20 |
<children>
|
21 |
<export translate="title">
|
22 |
<title>Export orders</title>
|
23 |
+
<action>adminhtml/expeditorinet_export</action>
|
24 |
<sort_order>10</sort_order>
|
25 |
</export>
|
26 |
<import translate="title">
|
27 |
<title>Import shipping</title>
|
28 |
+
<action>adminhtml/expeditorinet_import</action>
|
29 |
<sort_order>20</sort_order>
|
30 |
</import>
|
31 |
</children>
|
39 |
<children>
|
40 |
<sales>
|
41 |
<children>
|
42 |
+
<expeditorinet translate="title" module="expeditorinet">
|
43 |
<title>La Poste Expeditor INet</title>
|
44 |
<children>
|
45 |
<export translate="title">
|
app/code/community/LaPoste/ExpeditorINet/etc/config.xml
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
<config>
|
14 |
<modules>
|
15 |
<LaPoste_ExpeditorINet>
|
16 |
-
<version>1.0.
|
17 |
<depends>
|
18 |
<Mage_Sales />
|
19 |
<Mage_Adminhtml />
|
@@ -43,13 +43,13 @@
|
|
43 |
|
44 |
<admin>
|
45 |
<routers>
|
46 |
-
<
|
47 |
-
<use>admin</use>
|
48 |
<args>
|
49 |
-
<
|
50 |
-
|
|
|
51 |
</args>
|
52 |
-
</
|
53 |
</routers>
|
54 |
</admin>
|
55 |
|
13 |
<config>
|
14 |
<modules>
|
15 |
<LaPoste_ExpeditorINet>
|
16 |
+
<version>1.0.8</version>
|
17 |
<depends>
|
18 |
<Mage_Sales />
|
19 |
<Mage_Adminhtml />
|
43 |
|
44 |
<admin>
|
45 |
<routers>
|
46 |
+
<adminhtml>
|
|
|
47 |
<args>
|
48 |
+
<modules>
|
49 |
+
<expeditorinet after="Mage_Adminhtml">LaPoste_ExpeditorINet_Adminhtml</expeditorinet>
|
50 |
+
</modules>
|
51 |
</args>
|
52 |
+
</adminhtml>
|
53 |
</routers>
|
54 |
</admin>
|
55 |
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>ColiPoste_La_Poste_Expeditor_Inet_So_Colissimo</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
@@ -16,11 +16,11 @@ Testé et validé sur Magento :
|
|
16 |
- Enterprise : 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14
|
17 |

|
18 |
Réalisé par Smile sur la base du module créé par Jibé.</description>
|
19 |
-
<notes>
|
20 |
<authors><author><name>Berlioz</name><user>Aline</user><email>Aline.BERLIOZ@laposte.fr</email></author></authors>
|
21 |
-
<date>2015-
|
22 |
-
<time>
|
23 |
-
<contents><target name="mageetc"><dir name="modules"><file name="LaPoste_ExpeditorINet.xml" hash="f2198321021ba493d81d064eb99e6aec"/></dir></target><target name="magecommunity"><dir name="LaPoste"><dir name="ExpeditorINet"><dir name="Block"><dir name="Export"><dir name="Orders"><file name="Grid.php" hash="768bc842442e022eb3b39706d0606279"/></dir><file name="Orders.php" hash="eddae8e734c4b12a36343ef330cdcb32"/></dir><dir name="Import"><file name="Form.php" hash="375c120395760e50ce8eb6e6edf2cdca"/></dir></dir><dir name="Helper"><file name="Data.php" hash="026ea878ecf24e84711b27ad8b10edaf"/></dir><dir name="Model"><dir name="Config"><dir name="Source"><file name="EndOfLineCharacter.php" hash="b8c600ab0371995b790bbb9f9ce43185"/><file name="FieldDelimiter.php" hash="d82eacb4771e2db3168bc360dbd9586b"/><file name="FieldSeparator.php" hash="30c60175102f0c138798d6ce095e1439"/><file name="FileCharset.php" hash="67ae7384d6c71a535e1d93fd683a4d80"/><file name="FileExtension.php" hash="b5d4b7b193e63270f30c5624ff7e9921"/></dir></dir></dir><dir name="controllers"><file name="ExportController.php" hash="
|
24 |
<compatible/>
|
25 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
26 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>ColiPoste_La_Poste_Expeditor_Inet_So_Colissimo</name>
|
4 |
+
<version>1.0.8</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
16 |
- Enterprise : 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14
|
17 |

|
18 |
Réalisé par Smile sur la base du module créé par Jibé.</description>
|
19 |
+
<notes>Modification des URLs du module pour compatibilité avec patch SUPEE-6788</notes>
|
20 |
<authors><author><name>Berlioz</name><user>Aline</user><email>Aline.BERLIOZ@laposte.fr</email></author></authors>
|
21 |
+
<date>2015-11-03</date>
|
22 |
+
<time>10:41:09</time>
|
23 |
+
<contents><target name="mageetc"><dir name="modules"><file name="LaPoste_ExpeditorINet.xml" hash="f2198321021ba493d81d064eb99e6aec"/></dir></target><target name="magecommunity"><dir name="LaPoste"><dir name="ExpeditorINet"><dir name="Block"><dir name="Export"><dir name="Orders"><file name="Grid.php" hash="768bc842442e022eb3b39706d0606279"/></dir><file name="Orders.php" hash="eddae8e734c4b12a36343ef330cdcb32"/></dir><dir name="Import"><file name="Form.php" hash="375c120395760e50ce8eb6e6edf2cdca"/></dir></dir><dir name="Helper"><file name="Data.php" hash="026ea878ecf24e84711b27ad8b10edaf"/></dir><dir name="Model"><dir name="Config"><dir name="Source"><file name="EndOfLineCharacter.php" hash="b8c600ab0371995b790bbb9f9ce43185"/><file name="FieldDelimiter.php" hash="d82eacb4771e2db3168bc360dbd9586b"/><file name="FieldSeparator.php" hash="30c60175102f0c138798d6ce095e1439"/><file name="FileCharset.php" hash="67ae7384d6c71a535e1d93fd683a4d80"/><file name="FileExtension.php" hash="b5d4b7b193e63270f30c5624ff7e9921"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Expeditorinet"><file name="ExportController.php" hash="1aaf3281106695a60c0fa4119e53ac76"/><file name="ImportController.php" hash="2593b2730395d485a37cc50bbe37dbdc"/></dir><file name="ExportController.php" hash="8beb35dcf706e2fae91d25b801a93106"/><file name="ImportController.php" hash="5da784bd33ed72d25567cfdb7f908700"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="75bd5e2fe327161da315b8ca8e2a57af"/><file name="config.xml" hash="b4a53809d7b3199249ecf5c0b8cf4fd1"/><file name="system.xml" hash="7c7a4a4c1e4e5db4ac1d020de0d16bca"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="expeditorinet"><dir name="import"><file name="form.phtml" hash="0afef5bb21747ce26466f7367b3f6d19"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="fr_FR"><file name="LaPoste_ExpeditorINet.csv" hash="b519614a28683786e3d60293bdc551f6"/></dir></dir></target></contents>
|
24 |
<compatible/>
|
25 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
26 |
</package>
|