TNTFrance - Version 1.0

Version Notes

Extension officielle vous permettant de proposer les services TNT à vos clients.

Download this release

Release Info

Developer Magento Core Team
Extension TNTFrance
Version 1.0
Comparing to
See all releases


Version 1.0

Files changed (39) hide show
  1. app/code/community/Infostrates/Tnt/Block/Onepage/Shipping/Method/Available.php +69 -0
  2. app/code/community/Infostrates/Tnt/Block/Onepage/Shipping/Method/Available/Item.php +6 -0
  3. app/code/community/Infostrates/Tnt/Block/Sales/Impression.php +16 -0
  4. app/code/community/Infostrates/Tnt/Block/Sales/Order/Shipment/View.php +100 -0
  5. app/code/community/Infostrates/Tnt/Block/Sales/Shipment/Grid.php +103 -0
  6. app/code/community/Infostrates/Tnt/Helper/Data.php +5 -0
  7. app/code/community/Infostrates/Tnt/Model/Shipping/Carrier/Tnt.php +427 -0
  8. app/code/community/Infostrates/Tnt/Model/Shipping/Carrier/Tnt/Source/Labelformat.php +16 -0
  9. app/code/community/Infostrates/Tnt/Model/Shipping/Carrier/Tnt/Source/Method.php +38 -0
  10. app/code/community/Infostrates/Tnt/controllers/Sales/ImpressionController.php +135 -0
  11. app/code/community/Infostrates/Tnt/controllers/Sales/Order/ShipmentController.php +193 -0
  12. app/code/community/Infostrates/Tnt/controllers/TntController.php +170 -0
  13. app/code/community/Infostrates/Tnt/etc/config.xml +196 -0
  14. app/code/community/Infostrates/Tnt/etc/system.xml +272 -0
  15. app/code/community/Infostrates/Tnt/sql/tnt_setup/mysql4-uninstall-1.0.0.php +11 -0
  16. app/design/adminhtml/default/tnt/template/sales/order/invoice/create/form.phtml +85 -0
  17. app/design/adminhtml/default/tnt/template/sales/order/invoice/create/tracking.phtml +90 -0
  18. app/design/adminhtml/default/tnt/template/sales/order/shipment/create/form.phtml +113 -0
  19. app/design/frontend/default/default/layout/tnt.xml +25 -0
  20. app/design/frontend/default/default/template/tnt/form/failure.phtml +14 -0
  21. app/design/frontend/default/default/template/tnt/onepage/shipping_method.phtml +21 -0
  22. app/design/frontend/default/default/template/tnt/onepage/shipping_method/available.phtml +134 -0
  23. app/etc/modules/Infostrates_Tnt.xml +24 -0
  24. js/tnt/jquery_162.js +19 -0
  25. media/pdf_bt/100000053.pdf +0 -0
  26. media/pdf_bt/100000054.pdf +0 -0
  27. media/pdf_bt/100000055.pdf +0 -0
  28. media/pdf_bt/index.html +0 -0
  29. package.xml +18 -0
  30. skin/adminhtml/default/tnt/images/calendar.gif +0 -0
  31. skin/frontend/default/default/css/tnt/jquery.superbox.css +26 -0
  32. skin/frontend/default/default/css/tnt/tnt.css +20 -0
  33. skin/frontend/default/default/images/tnt/tnt_j.png +0 -0
  34. skin/frontend/default/default/images/tnt/tnt_jd.png +0 -0
  35. skin/frontend/default/default/images/tnt/tnt_jz.png +0 -0
  36. skin/frontend/default/default/images/tnt/tnt_sure_we_can.png +0 -0
  37. skin/frontend/default/default/images/tnt/tnt_t.png +0 -0
  38. skin/frontend/default/default/js/tnt/jquery.superbox.js +585 -0
  39. skin/frontend/default/default/js/tnt/tnt.js +141 -0
app/code/community/Infostrates/Tnt/Block/Onepage/Shipping/Method/Available.php ADDED
@@ -0,0 +1,69 @@
1
+ <?php
2
+ class Infostrates_Tnt_Block_Onepage_Shipping_Method_Available extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
3
+ {
4
+ protected $_itemRenders = array();
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+
10
+ //Rendu par défaut
11
+ $this->addItemRender(
12
+ 'default',
13
+ 'tnt/onepage_shipping_method_available',
14
+ 'tnt/onepage/shipping_method/available/default.phtml'
15
+ );
16
+ }
17
+
18
+ /**
19
+ * Ajoute une correspondance dans la table des rendus des modes de livraison.
20
+ * Cela permet de personnaliser l'affichage d'un mode de livraison parmi la
21
+ * liste des modes proposés lors du passage d'une commande.
22
+ * @param string $type
23
+ * @param string $block
24
+ * @param string $template
25
+ * @return LaPoste_SoColissimoSimplicite_Block_Onepage_Shipping_Method_Available
26
+ */
27
+ public function addItemRender($type, $block, $template)
28
+ {
29
+ $this->_itemRenders[$type] = array(
30
+ 'block' => $block,
31
+ 'template' => $template,
32
+ 'blockInstance' => null
33
+ );
34
+ return $this;
35
+ }
36
+
37
+ /**
38
+ * Retourne le renderer approprié selon le mode de livraison.
39
+ * Le renderer par défaut est "default".
40
+ * @param string $type exemples : default|socolissimosimplicite
41
+ * @return array
42
+ */
43
+ public function getItemRenderer($type)
44
+ {
45
+ if (!isset($this->_itemRenders[$type])) {
46
+ $type = 'default';
47
+ }
48
+ if (is_null($this->_itemRenders[$type]['blockInstance'])) {
49
+ $this->_itemRenders[$type]['blockInstance'] = $this->getLayout()
50
+ ->createBlock($this->_itemRenders[$type]['block'])
51
+ ->setTemplate($this->_itemRenders[$type]['template'])
52
+ ->setRenderedBlock($this);
53
+ }
54
+
55
+ return $this->_itemRenders[$type]['blockInstance'];
56
+ }
57
+
58
+ /**
59
+ * Retourne le code html du mode de livraison donné.
60
+ * @param Mage_Shipping_Model_Carrier_Abstract $item
61
+ * @return string
62
+ */
63
+ public function getItemHtml($item)
64
+ {
65
+ //le code html retourné dépend du mode de livraison
66
+ $renderer = $this->getItemRenderer($item->getMethod())->setRate($item);
67
+ return $renderer->toHtml();
68
+ }
69
+ }
app/code/community/Infostrates/Tnt/Block/Onepage/Shipping/Method/Available/Item.php ADDED
@@ -0,0 +1,6 @@
1
+ <?php
2
+ class Infostrates_Tnt_Block_Onepage_Shipping_Method_Available_Item
3
+ extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
4
+ {
5
+
6
+ }
app/code/community/Infostrates/Tnt/Block/Sales/Impression.php ADDED
@@ -0,0 +1,16 @@
1
+ <?php
2
+
3
+ class Infostrates_Tnt_Block_Sales_Impression extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+
6
+
7
+ public function __construct()
8
+ {
9
+ $this->_blockGroup = 'tnt';
10
+ $this->_controller = 'sales_shipment';
11
+ $this->_headerText = Mage::helper('tnt')->__('Suivi des expéditions TNT');
12
+ parent::__construct();
13
+ $this->_removeButton('add');
14
+ }
15
+
16
+ }
app/code/community/Infostrates/Tnt/Block/Sales/Order/Shipment/View.php ADDED
@@ -0,0 +1,100 @@
1
+ <?php
2
+ class Infostrates_Tnt_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
+
21
+ $_shippingMethod = explode("_",$_order->getShippingMethod());
22
+ if ($_shippingMethod[0] == 'tnt') {
23
+ $this->_addButton('etiquette', array(
24
+ 'label' => Mage::helper('tnt')->__('Etiquette TNT'),
25
+ 'class' => 'save',
26
+ 'onclick' => 'window.open(\'' . $this->getPrintTntUrl() . '\')'
27
+ )
28
+ );
29
+ }
30
+
31
+ if ($this->getShipment()->getId()) {
32
+ $this->_addButton('print', array(
33
+ 'label' => Mage::helper('sales')->__('Print'),
34
+ 'class' => 'save',
35
+ 'onclick' => 'setLocation(\''.$this->getPrintUrl().'\')'
36
+ )
37
+ );
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Retrieve shipment model instance
43
+ *
44
+ * @return Mage_Sales_Model_Order_Shipment
45
+ */
46
+ public function getShipment()
47
+ {
48
+ return Mage::registry('current_shipment');
49
+ }
50
+
51
+ public function getHeaderText()
52
+ {
53
+ if ($this->getShipment()->getEmailSent()) {
54
+ $emailSent = Mage::helper('sales')->__('Shipment email sent');
55
+ }
56
+ else {
57
+ $emailSent = Mage::helper('sales')->__('Shipment email not sent');
58
+ }
59
+
60
+ $header = Mage::helper('sales')->__('Shipment #%s (%s)', $this->getShipment()->getIncrementId(), $emailSent);
61
+ return $header;
62
+ }
63
+
64
+ public function getBackUrl()
65
+ {
66
+ return $this->getUrl(
67
+ '*/sales_order/view',
68
+ array(
69
+ 'order_id' => $this->getShipment()->getOrderId(),
70
+ 'active_tab'=> 'order_shipments'
71
+ ));
72
+ }
73
+
74
+ public function getEmailUrl()
75
+ {
76
+ return $this->getUrl('*/sales_order_shipment/email', array('shipment_id' => $this->getShipment()->getId()));
77
+ }
78
+
79
+ public function getPrintUrl()
80
+ {
81
+ return $this->getUrl('*/*/print', array(
82
+ 'invoice_id' => $this->getShipment()->getId()
83
+ ));
84
+ }
85
+
86
+ public function getPrintTntUrl()
87
+ {
88
+ return $this->getUrl('tnt/sales_impression/print', array(
89
+ 'shipment_id' => $this->getShipment()->getId()
90
+ ));
91
+ }
92
+
93
+ public function updateBackButtonUrl($flag)
94
+ {
95
+ if ($flag) {
96
+ return $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/sales_shipment/') . '\')');
97
+ }
98
+ return $this;
99
+ }
100
+ }
app/code/community/Infostrates/Tnt/Block/Sales/Shipment/Grid.php ADDED
@@ -0,0 +1,103 @@
1
+ <?php
2
+
3
+ class Infostrates_Tnt_Block_Sales_Shipment_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('sales_shipment_grid');
10
+ $this->setDefaultSort('order_created_at');
11
+ $this->setDefaultDir('DESC');
12
+ }
13
+
14
+ /**
15
+ * Retrieve collection class
16
+ *
17
+ * @return string
18
+ */
19
+ protected function _getCollectionClass()
20
+ {
21
+ return 'sales/order_shipment_grid_collection';
22
+ }
23
+
24
+ protected function _prepareCollection()
25
+ {
26
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
27
+ $collection->distinct(true);
28
+ $collection->getSelect()->columns(array('shipment_created_at' => 'main_table.created_at'));
29
+ $collection->getSelect()->join(array('ost' => $collection->getTable('sales/shipment_track')), 'main_table.entity_id = ost.parent_id');
30
+ $collection->addFieldToFilter('ost.carrier_code', array('like' => 'tnt%'));
31
+ $collection->getSelect()->group('main_table.entity_id');
32
+ $this->setCollection($collection);
33
+ return parent::_prepareCollection();
34
+ }
35
+
36
+ protected function _prepareColumns()
37
+ {
38
+ $this->addColumn('increment_id', array(
39
+ 'header' => Mage::helper('sales')->__('Shipment #'),
40
+ 'index' => 'increment_id',
41
+ 'type' => 'text',
42
+ ));
43
+
44
+ $this->addColumn('shipment_created_at', array(
45
+ 'header' => Mage::helper('sales')->__('Date Shipped'),
46
+ 'index' => 'shipment_created_at',
47
+ 'type' => 'datetime',
48
+ ));
49
+
50
+ $this->addColumn('order_increment_id', array(
51
+ 'header' => Mage::helper('sales')->__('Order #'),
52
+ 'index' => 'order_increment_id',
53
+ 'type' => 'number',
54
+ ));
55
+
56
+ $this->addColumn('order_created_at', array(
57
+ 'header' => Mage::helper('sales')->__('Order Date'),
58
+ 'index' => 'order_created_at',
59
+ 'type' => 'datetime',
60
+ ));
61
+
62
+ $this->addColumn('shipping_name', array(
63
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
64
+ 'index' => 'shipping_name',
65
+ ));
66
+
67
+ $this->addColumn('total_qty', array(
68
+ 'header' => Mage::helper('sales')->__('Total Qty'),
69
+ 'index' => 'total_qty',
70
+ 'type' => 'number',
71
+ ));
72
+
73
+ return parent::_prepareColumns();
74
+ }
75
+
76
+ public function getRowUrl($row)
77
+ {
78
+ if (!Mage::getSingleton('admin/session')->isAllowed('sales/order/shipment')) {
79
+ return false;
80
+ }
81
+ }
82
+
83
+ protected function _prepareMassaction()
84
+ {
85
+ $this->setMassactionIdField('entity_id');
86
+ $this->getMassactionBlock()->setFormFieldName('shipment_ids');
87
+ $this->getMassactionBlock()->setUseSelectAll(false);
88
+
89
+ // Impression des étiquettes
90
+ $this->getMassactionBlock()->addItem('pdfshipments_order', array(
91
+ 'label'=> Mage::helper('sales')->__('Imprimer les étiquettes'),
92
+ 'url' => $this->getUrl('tnt/sales_impression/printMass'),
93
+ ));
94
+
95
+ return $this;
96
+ }
97
+
98
+ public function getGridUrl()
99
+ {
100
+ return $this->getUrl('*/*/*', array('_current' => true));
101
+ }
102
+
103
+ }
app/code/community/Infostrates/Tnt/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
1
+ <?php
2
+ class Infostrates_Tnt_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ }
app/code/community/Infostrates/Tnt/Model/Shipping/Carrier/Tnt.php ADDED
@@ -0,0 +1,427 @@
1
+ <?php
2
+
3
+ class Infostrates_Tnt_Model_Shipping_Carrier_Tnt extends Mage_Usa_Model_Shipping_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
4
+ {
5
+
6
+ protected $_code = 'tnt';
7
+ protected $_request = null;
8
+ protected $_result = null;
9
+ protected $_gatewayUrl = 'http://www.tnt.fr/service/?wsdl';
10
+
11
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
12
+ {
13
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
14
+
15
+ if (!$this->getConfigFlag('active') || $quote->getShippingAddress()->getCountryId() != 'FR') {
16
+ return false;
17
+ }
18
+
19
+ if( date('D') == 'Sat' ) {
20
+ $date = date('Y-m-d', mktime(0, 0, 0, date("m") , date("d")+2, date("Y")));
21
+
22
+ } elseif( date('D') == 'Sun' ) {
23
+ $date = date('Y-m-d', mktime(0, 0, 0, date("m") , date("d")+1, date("Y")));
24
+ } else {
25
+ $date = date('Y-m-d');
26
+ }
27
+ //vérification des informations du compte saisies dans l'admin
28
+ $sender = array('zipCode' => $this->getConfigData('code_postal'), 'city' => $this->getConfigData('ville'));
29
+ $receiver = array('zipCode' => $this->getConfigData('code_postal'), 'city' => $this->getConfigData('ville'));
30
+ $feasi_params = array('shippingDate' => $date, 'accountNumber' => $this->getConfigData('account'), 'sender' => $sender, 'receiver' => $receiver );
31
+ $feasi_result = Mage::getModel('tnt/shipping_carrier_tnt')->_tnt_feasibility( $feasi_params );
32
+
33
+ if( is_string($feasi_result) ) {
34
+ return false;
35
+ }
36
+
37
+ $this->setRequest($request);
38
+
39
+ //checker la feasibility des services choisis par les commercant via le webservice
40
+ $r = $this->_rawRequest;
41
+
42
+ $allMethods = Mage::getModel('tnt/shipping_carrier_tnt_source_method')->toOptionArray();
43
+
44
+ //version Lite
45
+ $allowedMethods = explode(",", "JZ,J,JD");
46
+ //version Full
47
+ //$allowedMethods = explode(",", $this->getConfigData('allowed_methods'));
48
+
49
+ $servicesDispos = array();
50
+
51
+ foreach ($allMethods as $oneMethod) {
52
+ //si la methode est choisie par le commercant
53
+ if( in_array($oneMethod['value'], $allowedMethods) ) {
54
+ if( $oneMethod['value'] == 'JD' ||
55
+ (!preg_match("/Z/", $oneMethod['value']) && $quote->getShippingAddress()->getCompany() != '') ||
56
+ (preg_match("/Z/", $oneMethod['value']) && $quote->getShippingAddress()->getCompany() == '') ) {
57
+ $servicesDispos[] = array("serviceCode" => $oneMethod['value'], "serviceLabel" => $oneMethod['label'], "serviceDescription" => $oneMethod['description'], "serviceLien" => $oneMethod['lien'], "serviceLogo" => $oneMethod['logo']);
58
+ }
59
+ }
60
+ }
61
+ $this->_result = $this->_parseTntFeasibilityResponse($servicesDispos);
62
+
63
+ return $this->getResult();
64
+ }
65
+
66
+ public function setRequest(Mage_Shipping_Model_Rate_Request $request)
67
+ {
68
+ $this->_request = $request;
69
+
70
+ $r = new Varien_Object();
71
+
72
+ if ($request->getLimitMethod()) {
73
+ $r->setService($request->getLimitMethod());
74
+ }
75
+
76
+ if ($request->getTntAccount()) {
77
+ $r->setTntAccount($request->getTntAccount());
78
+ } else {
79
+ $r->setTntAccount($this->getConfigData('account'));
80
+ }
81
+
82
+ if ($request->getExpZipCode()) {
83
+ $r->setExpZipCode($request->getExpZipCode());
84
+ } else {
85
+ $r->setExpZipCode(Mage::getStoreConfig('carriers/tnt/code_postal', $this->getStore()));
86
+ }
87
+
88
+ if ($request->getExpCity()) {
89
+ $r->setExpCity($request->getExpCity());
90
+ } else {
91
+ $r->setExpCity(Mage::getStoreConfig('carriers/tnt/ville', $this->getStore()));
92
+ }
93
+
94
+ if ($request->getDestPostcode()) {
95
+ $r->setDestPostcode($request->getDestPostcode());
96
+ } else {
97
+ }
98
+
99
+ if ($request->getDestCity()) {
100
+ $r->setDestCity($request->getDestCity());
101
+ } else {
102
+ }
103
+
104
+ $this->_rawRequest = $r;
105
+
106
+ return $this;
107
+ }
108
+
109
+ public function getResult()
110
+ {
111
+ return $this->_result;
112
+ }
113
+
114
+ //permet de requeter le WS
115
+ protected function ws_tnt_communication($fonction, $parametres) {
116
+ $url = $this->getConfigData('gateway_url');
117
+ $username = $this->getConfigData('identifiant');
118
+ $password = $this->getConfigData('mdp');
119
+
120
+ $authheader = sprintf('
121
+ <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
122
+ <wsse:UsernameToken>
123
+ <wsse:Username>%s</wsse:Username>
124
+ <wsse:Password>%s</wsse:Password>
125
+ </wsse:UsernameToken>
126
+ </wsse:Security>', htmlspecialchars($username), htmlspecialchars( $password ));
127
+
128
+ $authvars = new SoapVar($authheader, XSD_ANYXML);
129
+ $header = new SoapHeader("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security", $authvars);
130
+
131
+ $soap = new SoapClient($url, array('trace'=>1));
132
+ $soap->__setSOAPHeaders(array($header));
133
+
134
+ try {
135
+ if($fonction == 'feasibility') {
136
+ $result = $soap->feasibility( array('parameters' => $parametres) );
137
+ }
138
+ if($fonction == 'dropOffPoints') {
139
+ $result = $soap->dropOffPoints($parametres);
140
+ }
141
+ if($fonction == 'citiesGuide') {
142
+ $result = $soap->citiesGuide($parametres);
143
+ }
144
+ if($fonction == 'expeditionCreation') {
145
+ $result = $soap->expeditionCreation( $parametres );
146
+ }
147
+ } catch (Exception $e) {
148
+ $result = $e->getMessage();
149
+ }
150
+
151
+ return $result;
152
+ }
153
+
154
+ /*
155
+ * Test de feasibility via le WS
156
+ * $params = array(params,array sender,array receiver)
157
+ */
158
+ public function _tnt_feasibility($params)
159
+ {
160
+ $debugData = array();
161
+ $fonction = 'feasibility';
162
+ $results = array();
163
+
164
+ $result = $this->ws_tnt_communication($fonction, $params);
165
+
166
+ if( is_string($result) ) {
167
+ $debugData['result'] = array('error' => $result);
168
+ $results = $result;
169
+ } else {
170
+ $nb = count($result->Service);
171
+
172
+ if ($nb > 1) {
173
+ // Cas où une liste de services est renvoyée
174
+ foreach ($result->Service as $Service) {
175
+ $results[] = array("serviceCode" => $Service->serviceCode, "serviceLabel" => $Service->serviceLabel." (".$Service->dueDate.")");
176
+ }
177
+ } elseif($nb == 1) {
178
+ $Service = $result->Service;
179
+ $results[] = array("serviceCode" => $Service->serviceCode, "serviceLabel" => $Service->serviceLabel." (".$Service->dueDate.")");
180
+ } else {
181
+ // Cas où aucun service n'est renvoyé
182
+ }
183
+ }
184
+
185
+ $this->_debug($debugData);
186
+
187
+ return $results;
188
+ }
189
+
190
+ //Retourne les services choisis par le commercant
191
+ protected function _parseTntFeasibilityResponse($servicesDispos)
192
+ {
193
+ $already_showed = array();
194
+
195
+ $result = Mage::getModel('shipping/rate_result');
196
+ $rate = Mage::getModel('shipping/rate_result_method');
197
+ $totalCart = Mage::getModel('checkout/session')->getQuote()->getGrandTotal();
198
+
199
+ $items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
200
+ $shipping_weight = 0;
201
+ foreach($items as $item) {
202
+ $shipping_weight += ($item->getWeight() * $item->getQty()) ;
203
+ }
204
+
205
+ if (empty($servicesDispos)) {
206
+ $error = Mage::getModel('shipping/rate_result_error');
207
+ $error->setCarrier($this->_code);
208
+ $error->setCarrierTitle($this->getConfigData('title'));
209
+ $error->setErrorMessage($this->getConfigData('specificerrmsg'));
210
+ $result->append($error);
211
+ } else {
212
+ foreach ($servicesDispos as $m) {
213
+ if(in_array($m['serviceLabel'],$already_showed)) { continue; } else { $already_showed[] = $m['serviceLabel']; }
214
+
215
+ $rate = Mage::getModel('shipping/rate_result_method');
216
+ $rate->setCarrier($this->_code);
217
+ $rate->setCarrierTitle($this->getConfigData('title'));
218
+ $rate->setMethod( $m['serviceCode'] );
219
+ $rate->setMethodTitle( $m['serviceLabel'] );
220
+ $rate->setMethodDescription( $m['serviceDescription']."|||".$m['serviceLien']."|||".$m['serviceLogo'] );
221
+
222
+ if( $this->getConfigData($m['serviceCode'].'_free') != 0 && $this->getConfigData($m['serviceCode'].'_free') <= $totalCart ) {
223
+ $rate->setPrice( '0' );
224
+ } else {
225
+ $table = split("[:,]" , $this->getConfigData($m['serviceCode'].'_amount'));
226
+ $tarifTrouve=true;
227
+ //si le commercant choisi un forfait plutot qu'une table de correspondance poids:prix
228
+ if(count($table) == 1) {
229
+ $tarif = $table[0];
230
+ } else {
231
+ for ($i = 0; $i < sizeof($table); $i+=2) {
232
+ if ($shipping_weight > $table[$i])
233
+ continue;
234
+ if (($shipping_weight <= $table[$i]) AND $tarifTrouve) {
235
+ $tarif=$table[$i+1];
236
+ $tarifTrouve=false;
237
+ }
238
+ }
239
+ }
240
+
241
+ $rate->setPrice( $tarif );
242
+ }
243
+
244
+ $result->append($rate);
245
+ }
246
+ }
247
+
248
+ return $result;
249
+ }
250
+
251
+ //Récupération des villes en fonction du CP via le WS
252
+ public function _tnt_citiesGuide($cp)
253
+ {
254
+ $debugData = array();
255
+ $fonction = 'citiesGuide';
256
+ $city = '';
257
+
258
+ $parametres = array('zipCode' => $cp);
259
+
260
+ $result = $this->ws_tnt_communication($fonction, $parametres);
261
+
262
+ if( is_string($result) ) {
263
+ $debugData['result'] = array('error' => $result);
264
+ $city = $result;
265
+ } else {
266
+ if( isset($result->City) && count($result->City) > 1 ) {
267
+ foreach ($result->City as $City) {
268
+ $city[] = array("name" => $City->name, "zipCode" => $City->zipCode);
269
+ }
270
+ } elseif( isset($result->City) && count($result->City) > 0 ) {
271
+ $City = $result->City;
272
+ $city[] = array("name" => $City->name, "zipCode" => $City->zipCode);
273
+ } else {
274
+ // Cas où aucune ville n'est renvoyée
275
+ $city = "Le code postal de votre adresse de livraison n'est pas correct.";
276
+ }
277
+ }
278
+
279
+ $this->_debug($debugData);
280
+
281
+ return $city;
282
+ }
283
+
284
+ //Récupération des points relais pour l'CP/ville par defaut via le WS
285
+ public function _tnt_dropOffPoints($cp,$ville)
286
+ {
287
+ $debugData = array();
288
+ $fonction = 'dropOffPoints';
289
+ $pointsDispos = array();
290
+
291
+ $parametres = array('zipCode' => $cp, 'city' => $ville);
292
+
293
+ $result = $this->ws_tnt_communication($fonction, $parametres);
294
+
295
+ if( is_string($result) ) {
296
+ $debugData['result'] = array('error' => $result);
297
+ $pointsDispos = $result;
298
+ } else {
299
+ if (isset($result->DropOffPoint) && count($result->DropOffPoint) > 1) {
300
+ foreach ($result->DropOffPoint as $Point) {
301
+ $pointsDispos[] = array("xETTCode" => $Point->xETTCode,
302
+ "name" => $Point->name,
303
+ "address1" => $Point->address1,
304
+ "zipCode" => $Point->zipCode,
305
+ "city" => $Point->city,
306
+ "geolocalisationUrl" => $Point->geolocalisationUrl,
307
+ "openingHours" => array( "monday" => $Point->openingHours->monday,
308
+ "tuesday" => $Point->openingHours->tuesday,
309
+ "wednesday" => $Point->openingHours->wednesday,
310
+ "thursday" => $Point->openingHours->thursday,
311
+ "friday" => $Point->openingHours->friday,
312
+ "saturday" => $Point->openingHours->saturday,
313
+ "sunday" => $Point->openingHours->sunday
314
+ ));
315
+ }
316
+ } elseif(isset($result->DropOffPoint) && count($result->DropOffPoint) == 1) {
317
+ $Point = $result->DropOffPoint;
318
+ $pointsDispos[] = array("xETTCode" => $Point->xETTCode,
319
+ "name" => $Point->name,
320
+ "address1" => $Point->address1,
321
+ "zipCode" => $Point->zipCode,
322
+ "city" => $Point->city,
323
+ "geolocalisationUrl" => $Point->geolocalisationUrl,
324
+ "openingHours" => array( "monday" => $Point->openingHours->monday,
325
+ "tuesday" => $Point->openingHours->tuesday,
326
+ "wednesday" => $Point->openingHours->wednesday,
327
+ "thursday" => $Point->openingHours->thursday,
328
+ "friday" => $Point->openingHours->friday,
329
+ "saturday" => $Point->openingHours->saturday,
330
+ "sunday" => $Point->openingHours->sunday
331
+ ));
332
+ } else {
333
+ // Cas où aucun PR n'est renvoyé
334
+ }
335
+ }
336
+
337
+ $this->_debug($debugData);
338
+
339
+ return $pointsDispos;
340
+ }
341
+
342
+ //Création d'une expé via le WS
343
+ public function _tnt_exp_crea($params)
344
+ {
345
+ $debugData = array();
346
+ $fonction = 'expeditionCreation';
347
+ $parcels = array();
348
+
349
+ $result = $this->ws_tnt_communication($fonction, $params);
350
+
351
+ if( is_string($result) ) {
352
+ $debugData['result'] = array('error' => $result);
353
+ $parcels = $result;
354
+ } else {
355
+ $parcels['pdfLabels'] = $result->Expedition->PDFLabels;
356
+
357
+ if( count($result->Expedition->parcelResponses) > 1 ) {
358
+ foreach ($result->Expedition->parcelResponses as $parcelResponses) {
359
+ $parcels[] = array("sequenceNumber" => $parcelResponses->sequenceNumber,
360
+ "parcelNumber" => $parcelResponses->parcelNumber,
361
+ "trackingURL" => $parcelResponses->trackingURL);
362
+ }
363
+ } elseif( count($result->Expedition->parcelResponses) > 0 ) {
364
+ $parcelResponses = $result->Expedition->parcelResponses;
365
+ $parcels[] = array("sequenceNumber" => $parcelResponses->sequenceNumber,
366
+ "parcelNumber" => $parcelResponses->parcelNumber,
367
+ "trackingURL" => $parcelResponses->trackingURL);
368
+ } else {
369
+ // Cas où aucune expé n'est renvoyée
370
+ }
371
+ }
372
+
373
+ $this->_debug($debugData);
374
+
375
+ return $parcels;
376
+ }
377
+
378
+ public function getAllowedMethods() {
379
+ $allowed = explode(',', $this->getConfigData('allowed_methods'));
380
+ $arr = array();
381
+ foreach ($allowed as $k) {
382
+ $arr[$k] = $this->getCode('method', $k);
383
+ }
384
+ return $arr;
385
+ }
386
+
387
+
388
+ public function isTrackingAvailable()
389
+ {
390
+ return true;
391
+ }
392
+
393
+ public function getTrackingInfo($tracking_number)
394
+ {
395
+ $tracking_result = $this->getTracking($tracking_number);
396
+
397
+ if ($tracking_result instanceof Mage_Shipping_Model_Tracking_Result)
398
+ {
399
+ if ($trackings = $tracking_result->getAllTrackings())
400
+ {
401
+ return $trackings[0];
402
+ }
403
+ }
404
+ elseif (is_string($tracking_result) && !empty($tracking_result))
405
+ {
406
+ return $tracking_result;
407
+ }
408
+
409
+ return false;
410
+ }
411
+
412
+ protected function getTracking($tracking_number)
413
+ {
414
+ $tracking_url = $this->getConfigData('tracking_url').$tracking_number;
415
+
416
+ $tracking_result = Mage::getModel('shipping/tracking_result');
417
+
418
+ $tracking_status = Mage::getModel('shipping/tracking_result_status');
419
+ $tracking_status->setCarrier($this->_code)
420
+ ->setCarrierTitle($this->getConfigData('title'))
421
+ ->setTracking($tracking_number)
422
+ ->setUrl($tracking_url);
423
+ $tracking_result->append($tracking_status);
424
+
425
+ return $tracking_result;
426
+ }
427
+ }
app/code/community/Infostrates/Tnt/Model/Shipping/Carrier/Tnt/Source/Labelformat.php ADDED
@@ -0,0 +1,16 @@
1
+ <?php
2
+
3
+ class Infostrates_Tnt_Model_Shipping_Carrier_Tnt_Source_Labelformat
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array(
9
+ 'value'=>'STDA4',
10
+ 'label'=>Mage::helper('tnt')->__('Impression A4 standard')),
11
+ array(
12
+ 'value'=>'THERMAL',
13
+ 'label'=>Mage::helper('tnt')->__('Impression pour imprimante thermique'))
14
+ );
15
+ }
16
+ }
app/code/community/Infostrates/Tnt/Model/Shipping/Carrier/Tnt/Source/Method.php ADDED
@@ -0,0 +1,38 @@
1
+ <?php
2
+
3
+ class Infostrates_Tnt_Model_Shipping_Carrier_Tnt_Source_Method
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array(
9
+ 'value'=>'JZ',
10
+ 'label'=>Mage::helper('tnt')->__('TNT 24h à Domicile : Votre colis livré demain matin chez vous.'),
11
+ 'description'=>Mage::helper('tnt')->__("Livraison en main propre contre signature, en 24h après expédition de votre commande, et avant 13h*, du lundi au samedi* de 8H à 13H**. En cas d'absence ou d'impossibilité de livraison, le colis est déposé dans le Relais Colis® le plus proche, et vous pouvez le retirer le jour même dès 14h.<br />
12
+ <span class='rem1'>* Livraison le samedi uniquement dans les principales agglomérations. Pas de livraison les dimanches et jours fériés.** ou en début d'après-midi dans les zones rurales.</span>"),
13
+ 'lien'=> 'http://www.tnt.fr/BtoC/page_domicile.html',
14
+ 'logo'=> 'tnt_jz.png'),
15
+ /*array(
16
+ 'value'=>'T',
17
+ 'label'=>Mage::helper('tnt')->__('10:00 Express au bureau'),
18
+ 'description'=>Mage::helper('tnt')->__("Colis livré avant 10 heures (ou en fin de matinée dans les zones rurales), le lendemain de sa prise en charge par TNT, en France métropolitaine.
19
+ En cas d'impossibilité de livrer le destinataire, livraison automatique le jour même dans le Relais Colis® le plus proche."),
20
+ 'lien'=> "",
21
+ 'logo'=> 'tnt_t.png'),*/
22
+ array(
23
+ 'value'=>'J',
24
+ 'label'=>Mage::helper('tnt')->__("TNT 24h Entreprise : Votre colis livré demain matin à l'adresse indiquée."),
25
+ 'description'=>Mage::helper('tnt')->__("Livraison en main propre contre signature, en 24h après expédition de votre commande, et avant 13h*, du lundi au vendredi de 8H à 13H**. En cas d'absence ou d'impossibilité de livraison, le colis est retourné à l'agence TNT de distribution en attente de vos instructions.<br />
26
+ <span class='rem1'>*Pas de livraison les samedis, dimanches et jours fériés.** ou en début d'après-midi dans les zones rurales.</span>"),
27
+ 'lien'=> "",
28
+ 'logo'=> 'tnt_j.png'),
29
+ array(
30
+ 'value'=>'JD',
31
+ 'label'=>Mage::helper('tnt')->__('TNT 24h en Relais Colis® : Votre colis livré demain matin dans le Relais Colis® de votre choix.'),
32
+ 'description'=>Mage::helper('tnt')->__("Livraison en 24h, après expédition de votre commande, dans l'un des 4000 Relais Colis® partout en France métropolitaine. Retrait possible dés 14h et distribution après vérification d’une pièce d'identité et contre signature.<br />
33
+ <span class='rem1'>* Livraison le samedi uniquement dans les principales agglomérations. Pas de livraison les dimanches et jours fériés.** ou en début d'après-midi dans les zones rurales.</span>"),
34
+ 'lien'=> "http://www.tnt.fr/BtoC/page_relais-colis.html",
35
+ 'logo'=> 'tnt_jd.png'),
36
+ );
37
+ }
38
+ }
app/code/community/Infostrates/Tnt/controllers/Sales/ImpressionController.php ADDED
@@ -0,0 +1,135 @@
1
+ <?php
2
+
3
+ class Infostrates_Tnt_Sales_ImpressionController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ /**
6
+ * Additional initialization
7
+ *
8
+ */
9
+ protected function _construct()
10
+ {
11
+ $this->setUsedModuleName('Infostrates_Tnt');
12
+ }
13
+
14
+
15
+ /**
16
+ * Shipping grid
17
+ */
18
+ public function indexAction()
19
+ {
20
+ $this->loadLayout()
21
+ ->_setActiveMenu('sales/tnt')
22
+ ->_addContent($this->getLayout()->createBlock('tnt/sales_impression'))
23
+ ->renderLayout();
24
+ }
25
+
26
+ public function getConfigData($field)
27
+ {
28
+ $path = 'carriers/tnt/'.$field;
29
+ return Mage::getStoreConfig($path, Mage::app()->getStore());
30
+ }
31
+
32
+ protected function _processDownload($resource, $resourceType)
33
+ {
34
+ $helper = Mage::helper('downloadable/download');
35
+
36
+ $helper->setResource($resource, $resourceType);
37
+
38
+ $fileName = $helper->getFilename();
39
+ $contentType = $helper->getContentType();
40
+
41
+ $this->getResponse()
42
+ ->setHttpResponseCode(200)
43
+ ->setHeader('Pragma', 'public', true)
44
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
45
+ ->setHeader('Content-type', $contentType, true);
46
+
47
+ if ($fileSize = $helper->getFilesize()) {
48
+ $this->getResponse()
49
+ ->setHeader('Content-Length', $fileSize);
50
+ }
51
+
52
+ if ($contentDisposition = $helper->getContentDisposition()) {
53
+ $this->getResponse()
54
+ ->setHeader('Content-Disposition', $contentDisposition . '; filename='.$fileName);
55
+ }
56
+
57
+ $this->getResponse()
58
+ ->clearBody();
59
+ $this->getResponse()
60
+ ->sendHeaders();
61
+
62
+ $helper->output();
63
+ }
64
+
65
+ protected function getEtiquetteUrl($shipmentsIds)
66
+ {
67
+ //On récupère les infos d'expédition
68
+ if (is_array($shipmentsIds))
69
+ {
70
+ $path = Mage::getBaseDir('media').'/pdf_bt/';
71
+ $pdfDocs = array();
72
+
73
+ for ($i = 0; $i < count($shipmentsIds); $i++)
74
+ {
75
+ $shipmentId = Mage::getModel('sales/order_shipment_track')->load($shipmentsIds[$i])->getParentId();
76
+ $orderNum = Mage::getModel('sales/order_shipment')->load($shipmentId)->getOrder()->getRealOrderId();
77
+
78
+ // Array of the pdf files need to be merged
79
+ $pdfDocs[] = $path.$orderNum.'.pdf';
80
+ }
81
+
82
+ $filename = $path."tnt_pdf.pdf";
83
+
84
+ $cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$filename ";
85
+ //Add each pdf file to the end of the command
86
+ for($i=0; $i<count($pdfDocs);$i++) {
87
+ $cmd .= $pdfDocs[$i]." ";
88
+ }
89
+ $result = shell_exec($cmd);
90
+ $filename = "tnt_pdf.pdf";
91
+ }
92
+ else
93
+ {
94
+ $shipmentId = $shipmentsIds;
95
+
96
+ $orderNum = Mage::getModel('sales/order_shipment')->load($shipmentId)->getOrder()->getRealOrderId();
97
+
98
+ $filename = $orderNum.'.pdf';
99
+ };
100
+ return $filename;
101
+ }
102
+
103
+ public function printMassAction()
104
+ {
105
+ $path = Mage::getBaseUrl('media').'pdf_bt/';
106
+ $shipmentsIds = $this->getRequest()->getPost('shipment_ids');
107
+
108
+ try {
109
+ $filename = $this->getEtiquetteUrl($shipmentsIds);
110
+
111
+ $this->_processDownload($path.$filename, 'url');
112
+ exit(0);
113
+ } catch (Mage_Core_Exception $e) {
114
+ $this->_getSession()->addError(Mage::helper('tnt')->__('Impossible de récupérer les BT : '.$filename));
115
+ }
116
+ return $this->_redirectReferer();
117
+ }
118
+
119
+ public function printAction()
120
+ {
121
+ $path = Mage::getBaseUrl('media').'pdf_bt/';
122
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
123
+
124
+ try {
125
+ $filename = $this->getEtiquetteUrl($shipmentId);
126
+
127
+ $this->_processDownload($path.$filename, 'url');
128
+ exit(0);
129
+ } catch (Mage_Core_Exception $e) {
130
+ $this->_getSession()->addError(Mage::helper('tnt')->__('Impossible de récupérer le BT : '.$filename));
131
+ }
132
+ return $this->_redirectReferer();
133
+ }
134
+
135
+ }
app/code/community/Infostrates/Tnt/controllers/Sales/Order/ShipmentController.php ADDED
@@ -0,0 +1,193 @@
1
+ <?php
2
+ require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
3
+ class Infostrates_Tnt_Sales_Order_ShipmentController extends Mage_Adminhtml_Sales_Order_ShipmentController
4
+ {
5
+
6
+ /**
7
+ * Save shipment
8
+ * We can save only new shipment. Existing shipments are not editable
9
+ */
10
+
11
+ public function getConfigData($field)
12
+ {
13
+ $path = 'carriers/tnt/'.$field;
14
+ return Mage::getStoreConfig($path, Mage::app()->getStore());
15
+ }
16
+
17
+ public function dateFR( $dateUS ) {
18
+ $tmp = explode('-',$dateUS);
19
+
20
+ $dateFR = $tmp[2].'-'.$tmp[1].'-'.$tmp[0];
21
+
22
+ return $dateFR;
23
+ }
24
+
25
+ public function saveAction()
26
+ {
27
+ $data = $this->getRequest()->getPost('shipment');
28
+
29
+ try {
30
+
31
+ if ($shipment = $this->_initShipment()) {
32
+
33
+ $_order = $shipment->getOrder();
34
+
35
+ $_shippingMethod = explode("_",$_order->getShippingMethod());
36
+
37
+ //Expédition via TNT on créé une expé. et on récupère le tracking num via le WS.
38
+ if ($_shippingMethod[0] == 'tnt') {
39
+
40
+ // On met en place les paramètres de la requète pour l'expédition
41
+ $send_city = $this->getConfigData('ville');
42
+
43
+ $rec_typeid = '';
44
+ $rec_name = '';
45
+
46
+ if($_shippingMethod['1'] == "A" || $_shippingMethod['1'] == "T" || $_shippingMethod['1'] == "M" || $_shippingMethod['1'] == "J") {
47
+ $rec_type = 'ENTERPRISE';
48
+ $rec_name = trim($_order->getShippingAddress()->getCompany());
49
+ } elseif($_shippingMethod['1'] == "AZ" || $_shippingMethod['1'] == "TZ" || $_shippingMethod['1'] == "MZ" || $_shippingMethod['1'] == "JZ") {
50
+ $rec_type = 'INDIVIDUAL';
51
+ } else {
52
+ $rec_type = 'DROPOFFPOINT';
53
+ $extt = explode(' ',trim($_order->getShippingAddress()->getCompany()));
54
+ $rec_typeid = end($extt);
55
+ $rec_name = str_replace($rec_typeid, '', $_order->getShippingAddress()->getCompany());
56
+ }
57
+
58
+ $rec_address = $_order->getShippingAddress()->getStreet();
59
+ if (!isset($rec_address[1]))
60
+ {
61
+ $rec_address[1] = '';
62
+ }
63
+
64
+ $nb_colis = $this->getRequest()->getPost('nb_colis');
65
+ $date_expe = $this->dateFR( $this->getRequest()->getPost('shippingDate') );
66
+
67
+ $parcelsRequest = array();
68
+
69
+ $poids_restant = $_order->getWeight();
70
+ for($i=1;$i<=$nb_colis;$i++) {
71
+ if($i == $nb_colis) {
72
+ if( $poids_restant > $this->getConfigData('max_package_weight') ) {
73
+ $parcelWeight = $this->getConfigData('max_package_weight');
74
+ } else {
75
+ $parcelWeight = $poids_restant;
76
+ }
77
+ } else {
78
+ $parcelWeight = $this->getConfigData('max_package_weight');
79
+ $poids_restant = $poids_restant - $parcelWeight;
80
+ }
81
+
82
+ if($parcelWeight < 0) {
83
+ $parcelWeight = 1;
84
+ }
85
+
86
+ $parcelsRequest[] = array('sequenceNumber'=>$i,'customerReference' => $_order->getRealOrderId(), 'weight' => $parcelWeight);
87
+ }
88
+
89
+ $rec_city = $_order->getShippingAddress()->getCity();
90
+
91
+ $sender = array('zipCode' => $this->getConfigData('code_postal'), 'city' => $send_city);
92
+ $receiver = array('zipCode' => $_order->getShippingAddress()->getPostcode(), 'city' => $rec_city, 'type' => $rec_type);
93
+ $feasi_params = array('shippingDate' => $date_expe, 'accountNumber' => $this->getConfigData('account'), 'sender' => $sender, 'receiver' => $receiver );
94
+ $feasi_result = Mage::getModel('tnt/shipping_carrier_tnt')->_tnt_feasibility( $feasi_params );
95
+
96
+ if( is_string($feasi_result) ) {
97
+ Throw new Exception( $feasi_result );
98
+ }
99
+
100
+ $params = array('parameters' => array( 'shippingDate' => $date_expe,
101
+ 'accountNumber' => $this->getConfigData('account'),
102
+ 'sender' => array( 'name' => $this->getConfigData('raison_sociale'),
103
+ 'address1' => $this->getConfigData('adresse'),
104
+ 'address2' => $this->getConfigData('adresse2'),
105
+ 'zipCode' => $this->getConfigData('code_postal'),
106
+ 'city' => $send_city
107
+ ),
108
+ 'receiver' => array( 'type' => $rec_type,
109
+ 'typeId' => $rec_typeid,
110
+ 'name' => $rec_name,
111
+ 'address1' => $rec_address[0],
112
+ 'address2' => $rec_address[1],
113
+ 'zipCode' => $_order->getShippingAddress()->getPostcode(),
114
+ 'city' => $rec_city,
115
+ 'contactLastName' => substr($_order->getShippingAddress()->getLastname(),0,12),
116
+ 'contactFirstName' => substr($_order->getShippingAddress()->getFirstname(),0,19),
117
+ 'emailAddress' => $_order->getShippingAddress()->getEmail(),
118
+ 'phoneNumber' => $_order->getShippingAddress()->getTelephone()
119
+ ),
120
+ 'serviceCode' => $_shippingMethod[1],
121
+ 'quantity' => $nb_colis,
122
+ 'parcelsRequest' => $parcelsRequest,
123
+ 'labelFormat' => $this->getConfigData('label_format')
124
+ )
125
+ );
126
+
127
+
128
+ $parcels = Mage::getModel('tnt/shipping_carrier_tnt')->_tnt_exp_crea($params);
129
+
130
+ if( is_string($parcels) ) {
131
+ Throw new Exception( $this->__($parcels) );
132
+ }
133
+
134
+ //on créé le fichier PDF
135
+ $path = Mage::getBaseDir('media').'/pdf_bt/';
136
+ $filename = $_order->getRealOrderId().".pdf";
137
+
138
+ if($parcels['pdfLabels'] && !file_exists($path.$filename)) {
139
+ if( $handle = fopen($path.$filename, 'x+') ) {
140
+ fwrite($handle, $parcels['pdfLabels']);
141
+ fclose($handle);
142
+ } else {
143
+ Throw new Exception( $this->__("Impossible de créer le BT. Vérifiez que le repertoire /media/pdf_bt/ à les droits en écriture.") );
144
+ }
145
+ }
146
+
147
+ foreach($parcels as $parcel) {
148
+ if(is_array($parcel)) {
149
+ $track = Mage::getModel('sales/order_shipment_track')
150
+ ->setNumber($parcel['parcelNumber'])
151
+ ->setCarrier('TNT')
152
+ ->setCarrierCode($_shippingMethod[0])
153
+ ->setTitle('TNT')
154
+ ->setPopup(1);
155
+ $shipment->addTrack($track);
156
+ }
157
+ }
158
+ }
159
+
160
+ $shipment->register();
161
+ $comment = '';
162
+ if (!empty($data['comment_text'])) {
163
+ $shipment->addComment($data['comment_text'], isset($data['comment_customer_notify']));
164
+ $comment = $data['comment_text'];
165
+ }
166
+
167
+ if (!empty($data['send_email'])) {
168
+ $shipment->setEmailSent(true);
169
+ }
170
+
171
+ $shipment->getCreatedAt($date_expe);
172
+ $shipment->getUpdatedAt($date_expe);
173
+
174
+ $this->_saveShipment($shipment);
175
+ $shipment->sendEmail(!empty($data['send_email']), $comment);
176
+ $this->_getSession()->addSuccess($this->__('Shipment was successfully created.'));
177
+ $this->_redirect('adminhtml/sales_order/view', array('order_id' => $shipment->getOrderId()));
178
+ return;
179
+
180
+ }else {
181
+ $this->_forward('noRoute');
182
+ return;
183
+ }
184
+ }
185
+ catch (Mage_Core_Exception $e) {
186
+ $this->_getSession()->addError($e->getMessage());
187
+ }
188
+ catch (Exception $e) {
189
+ $this->_getSession()->addError($this->__('Can not save shipment: '.$e->getMessage()));
190
+ }
191
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
192
+ }
193
+ }
app/code/community/Infostrates/Tnt/controllers/TntController.php ADDED
@@ -0,0 +1,170 @@
1
+ <?php
2
+ require_once ('app/code/core/Mage/Core/Controller/Front/Action.php');
3
+
4
+ class Infostrates_Tnt_TntController extends Mage_Core_Controller_Front_Action {
5
+
6
+ public function indexAction() {
7
+ $zipcode = $this->getRequest ()->getParam ( 'zipcode' );
8
+ $zipcode = trim(urldecode($zipcode));
9
+ $zipcode = mb_convert_encoding($zipcode,'UTF-8');
10
+
11
+ if (empty ( $zipcode )) {
12
+ Mage::log ( 'TNTRelais: No zip code - error message' );
13
+ echo '<ul class="messages"><li class="error-msg"><ul><li>' . Mage::helper ( 'tnt' )->__ ( 'Le code postal est obligatoire !' ) . '</li></ul></li></ul>';
14
+ } else {
15
+
16
+ $results = Mage::getModel('tnt/shipping_carrier_tnt')->_tnt_citiesGuide($zipcode);
17
+
18
+ if ( !is_array($results) ) {
19
+ echo '<ul class="messages"><li class="error-msg"><ul><li>' . Mage::helper ( 'tnt' )->__ ( $results ) . '</li></ul></li></ul>';
20
+ } else {
21
+
22
+ $points = array();
23
+
24
+ foreach ($results as $result) {
25
+ $points[] = Mage::getModel('tnt/shipping_carrier_tnt')->_tnt_dropOffPoints($result['zipCode'], $result['name']);
26
+ }
27
+
28
+ if ( !is_array($points) ) {
29
+ echo '<ul class="messages"><li class="error-msg"><ul><li>' . Mage::helper ( 'tnt' )->__ ( $points ) . '</li></ul></li></ul>';
30
+ } else {
31
+ $this->filterPoints ( $points );
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+ /**
38
+ * liste les PR retournés par le WS
39
+ * @param Array $tnt_items
40
+ * @return string
41
+ */
42
+ private function filterPoints($tnt_items) {
43
+
44
+ toFirePHP($tnt_items);
45
+
46
+ $offset = 1;
47
+ $allReadyIn = array();
48
+ $html = '<label>' . Mage::helper ( 'tnt' )->__ ( 'Choisissez votre point relais pour la livraison' ) . ': </label><ul>';
49
+ foreach ( $tnt_items as $tmp_items ) {
50
+ foreach( $tmp_items as $item ) {
51
+ if( !in_array($item['xETTCode'], $allReadyIn) ) {
52
+ $allReadyIn[] = $item['xETTCode'];
53
+ if ($offset <= 15) {
54
+ $html.= '<li>
55
+ <input name="tnt_relais" type="radio" id="tnt_relais'.$offset.'" class="radio" value="'.$item['address1'].'&&&'.$item['name'].' '.$item['xETTCode'].'&&&'.$item['zipCode'].'&&&'.$item['city'].'" />
56
+ <label for="tnt_relais'.$offset.'">
57
+ <span class="s1">'.$item['name'].' : '.$item['address1'].' - '.$item['zipCode'].' - '.$item['city'].'</span>
58
+ <span class="s2"> <a href="'.$item['geolocalisationUrl'].'" target="_blank">voir</a></span>
59
+ </label>
60
+ </li>';
61
+ }
62
+ ++ $offset;
63
+ }
64
+ }
65
+ }
66
+ $html.='</ul>';
67
+ echo $html;
68
+ }
69
+
70
+ /**
71
+ * Update les données d'expédition du client par celles du PR
72
+ *
73
+ * @return string
74
+ */
75
+ public function changeshippingaddressAction() {
76
+ if ($shipping = $this->getRequest()->getParams( array ('street', 'description', 'postcode', 'city') )) {
77
+
78
+ $current = Mage::getSingleton ( 'checkout/session' )->getQuote ();
79
+ Mage::register ( 'current_quote', $current );
80
+ $address = $current->getShippingAddress ();
81
+
82
+ ( string ) $postcode = $shipping ['postcode'];
83
+ if (substr ( $postcode, 0, 2 ) == 20) {
84
+ $regioncode = substr ( $postcode, 0, 3 );
85
+ switch ($regioncode) {
86
+ case 202 :
87
+ $regioncode = '2B';
88
+ break;
89
+ default:
90
+ $regioncode = '2A';
91
+ break;
92
+ }
93
+
94
+ } else {
95
+
96
+ $regioncode = substr ( $postcode, 0, 2 );
97
+ }
98
+ Mage::app ()->getLocale ()->setLocaleCode ( 'en_US' );
99
+ $region = Mage::getModel ( 'directory/region' )->loadByCode ( $regioncode, $address->getCountryId () );
100
+ $regionname = $region->getDefaultName ();
101
+ $regionid = $region->getRegionId ();
102
+ $address->setRegion ( $regionname );
103
+ $address->setRegionId ( $regionid );
104
+ $address->setPostcode ( $postcode );
105
+ $address->setStreet ( urldecode ( $shipping ['street'] ) );
106
+ $address->setCity ( urldecode ( $shipping ['city'] ) );
107
+ $address->setCompany ( trim(urldecode ( $shipping ['description'] )) );
108
+ $address->save ();
109
+ $current->setShippingAddress ( $address );
110
+ $current->save ();
111
+ }
112
+ }
113
+
114
+ public function villeAction() {
115
+ $zipcode = $this->getRequest ()->getParam ( 'zipcode' );
116
+ $zipcode = trim(urldecode($zipcode));
117
+ $zipcode = mb_convert_encoding($zipcode,'UTF-8');
118
+
119
+ //je stock les infos de l'adresse de livraison au cas ou
120
+ $street = $this->getRequest ()->getParam ( 'address' );
121
+ $street = trim(urldecode($street));
122
+ $street = mb_convert_encoding($street,'UTF-8');
123
+
124
+ $city = $this->getRequest ()->getParam ( 'city' );
125
+ $city = trim(urldecode($city));
126
+ $city = mb_convert_encoding($city,'UTF-8');
127
+
128
+ $company = $this->getRequest ()->getParam ( 'company' );
129
+ $company = trim(urldecode($company));
130
+ $company = mb_convert_encoding($company,'UTF-8');
131
+
132
+ if (empty ( $zipcode )) {
133
+ Mage::log ( 'TNTCheck CP/Villes: No zip code - error message' );
134
+ echo '<ul class="messages"><li class="error-msg"><ul><li>' . Mage::helper ( 'tnt' )->__ ( 'Le code postal est obligatoire !' ) . '</li></ul></li></ul>';
135
+ } else {
136
+ $allVilles = Mage::getModel('tnt/shipping_carrier_tnt')->_tnt_citiesGuide($zipcode);
137
+
138
+ if ( !is_array($allVilles) ) {
139
+ echo '<ul class="messages"><li class="error-msg"><ul><li>' . Mage::helper ( 'tnt' )->__ ( $allVilles ) . '</li></ul></li></ul>';
140
+ } else {
141
+ $this->filterVilles ( $allVilles, $street, $zipcode, $city, $company );
142
+ }
143
+ }
144
+ }
145
+
146
+ private function filterVilles($allVilles, $street, $zipcode, $city, $company) {
147
+ $offset = 0;
148
+ $html = '';
149
+
150
+ if(count($allVilles) > 1) {
151
+ $html.= '<label>' . Mage::helper ( 'tnt' )->__ ( 'Choisissez précisemment la ville de livraison' ) . ': </label><ul>';
152
+ foreach ( $allVilles as $ville ) {
153
+ ++ $offset;
154
+ if ($offset <= 10) {
155
+ $html.= '<li>
156
+ <input name="tnt_ville" type="radio" id="tnt_ville'.$offset.'" class="radio" value="'.$street.'&&&'.$company.'&&&'.$zipcode.'&&&'.$ville['name'].'" />
157
+ <label for="tnt_ville'.$offset.'">
158
+ <span class="s1">'.$ville['name'].'</span>
159
+ </label>
160
+ </li>';
161
+ }
162
+ }
163
+ $html.='</ul>';
164
+ } else {
165
+ $html.= '<input name="tnt_ville" type="radio" id="tnt_ville1" class="radio" value="'.$street.'&&&'.$company.'&&&'.$zipcode.'&&&'.$allVilles[0]['name'].'" checked="checked" style="display:none;" />';
166
+ }
167
+ echo $html;
168
+ }
169
+ }
170
+ ?>
app/code/community/Infostrates/Tnt/etc/config.xml ADDED
@@ -0,0 +1,196 @@
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Infostrates_Tnt>
6
+ <version>1.0</version>
7
+ <depends>
8
+ <Mage_Adminhtml />
9
+ <Mage_Shipping />
10
+ </depends>
11
+ </Infostrates_Tnt>
12
+ </modules>
13
+ <global>
14
+ <resources>
15
+ <tnt_setup>
16
+ <setup>
17
+ <module>Infostrates_Tnt</module>
18
+ </setup>
19
+ <connection>
20
+ <use>core_setup</use>
21
+ </connection>
22
+ </tnt_setup>
23
+ <tnt_write>
24
+ <connection>
25
+ <use>core_write</use>
26
+ </connection>
27
+ </tnt_write>
28
+ <tnt_read>
29
+ <connection>
30
+ <use>core_read</use>
31
+ </connection>
32
+ </tnt_read>
33
+ </resources>
34
+ <blocks>
35
+ <tnt>
36
+ <class>Infostrates_Tnt_Block</class>
37
+ </tnt>
38
+ <adminhtml>
39
+ <rewrite>
40
+ <sales_order_shipment_view>Infostrates_Tnt_Block_Sales_Order_Shipment_View</sales_order_shipment_view>
41
+ </rewrite>
42
+ </adminhtml>
43
+ </blocks>
44
+ <helpers>
45
+ <tnt>
46
+ <class>Infostrates_Tnt_Helper</class>
47
+ </tnt>
48
+ </helpers>
49
+ <models>
50
+ <tnt>
51
+ <class>Infostrates_Tnt_Model</class>
52
+ </tnt>
53
+ </models>
54
+ <sales>
55
+ <shipping>
56
+ <carriers>
57
+ <tnt>
58
+ <class>Infostrates_Tnt_Model_Shipping_Carrier_Tnt</class>
59
+ </tnt>
60
+ </carriers>
61
+ </shipping>
62
+ <tax>
63
+ <methods>
64
+ <tntzipcode>
65
+ <class>Infostrates_Tnt_Model_Tax_Tntzipcode</class>
66
+ </tntzipcode>
67
+ </methods>
68
+ </tax>
69
+ </sales>
70
+ <rewrite>
71
+ <infostrates_tnt_sales_order_shipment>
72
+ <from><![CDATA[#^/.*sales_order_shipment/save/#]]></from>
73
+ <to>/tnt/sales_order_shipment/save/</to>
74
+ </infostrates_tnt_sales_order_shipment>
75
+ </rewrite>
76
+ </global>
77
+ <adminhtml>
78
+ <menu>
79
+ <sales translate="title" module="tnt">
80
+ <title>Sales</title>
81
+ <sort_order>20</sort_order>
82
+ <depends><module>Mage_Sales</module></depends>
83
+ <children>
84
+ <tnt translate="title" module="sales">
85
+ <title>TNT</title>
86
+ <sort_order>31</sort_order>
87
+ <children>
88
+ <impression translate="title" module="sales">
89
+ <title>Suivi des expéditions TNT</title>
90
+ <action>tnt/sales_impression</action>
91
+ <sort_order>10</sort_order>
92
+ </impression>
93
+ </children>
94
+ </tnt>
95
+ </children>
96
+ </sales>
97
+ </menu>
98
+ <acl>
99
+ <resources>
100
+ <admin>
101
+ <children>
102
+ <sales translate="title" module="sales">
103
+ <title>Sales</title>
104
+ <sort_order>20</sort_order>
105
+ <children>
106
+ <tnt translate="title" module="sales">
107
+ <title>TNT</title>
108
+ <sort_order>31</sort_order>
109
+ <children>
110
+ <impression translate="title" module="sales">
111
+ <title>Suivi des expéditions TNT</title>
112
+ <sort_order>10</sort_order>
113
+ </impression>
114
+ </children>
115
+ </tnt>
116
+ </children>
117
+ </sales>
118
+ </children>
119
+ </admin>
120
+ </resources>
121
+ </acl>
122
+ </adminhtml>
123
+ <stores>
124
+ <admin>
125
+ <design>
126
+ <theme>
127
+ <default>tnt</default>
128
+ </theme>
129
+ </design>
130
+ </admin>
131
+ </stores>
132
+ <admin>
133
+ <routers>
134
+ <tnt>
135
+ <use>admin</use>
136
+ <args>
137
+ <module>Infostrates_Tnt</module>
138
+ <frontName>tnt</frontName>
139
+ </args>
140
+ </tnt>
141
+ </routers>
142
+ </admin>
143
+ <frontend>
144
+ <layout>
145
+ <updates>
146
+ <tnt module="Infostrates_Tnt">
147
+ <file>tnt.xml</file>
148
+ </tnt>
149
+ </updates>
150
+ </layout>
151
+ <routers>
152
+ <tnt>
153
+ <use>standard</use>
154
+ <args>
155
+ <module>Infostrates_Tnt</module>
156
+ <frontName>tnt</frontName>
157
+ </args>
158
+ </tnt>
159
+ </routers>
160
+ <translate>
161
+ <modules>
162
+ <Infostrates_Tnt>
163
+ <files>
164
+ <default>Infostrates_Tnt.csv</default>
165
+ </files>
166
+ </Infostrates_Tnt>
167
+ </modules>
168
+ </translate>
169
+ </frontend>
170
+
171
+ <default>
172
+ <carriers>
173
+ <tnt>
174
+ <active>0</active>
175
+ <title>TNT</title>
176
+ <gateway_url>http://www.tnt.fr/service/?wsdl</gateway_url>
177
+ <account>06324676</account>
178
+ <identifiant>webservices@tnt.fr</identifiant>
179
+ <mdp>test</mdp>
180
+ <max_package_weight>20</max_package_weight>
181
+ <allowed_methods>T,JZ,JD,J</allowed_methods>
182
+ <label_format>STDA4</label_format>
183
+ <tracking_url>http://www.tnt.fr/public/suivi_colis/recherche/visubontransport.do?bonTransport=</tracking_url>
184
+ <J_amount>10:23.90,20:52.30,1000:99</J_amount>
185
+ <JZ_amount>10:23.90,20:52.30,1000:99</JZ_amount>
186
+ <JD_amount>10:23.90,20:52.30,1000:99</JD_amount>
187
+ <J_free>0</J_free>
188
+ <JZ_free>0</JZ_free>
189
+ <JD_free>0</JD_free>
190
+ <sallowspecific>0</sallowspecific>
191
+ <model>tnt/shipping_carrier_tnt</model>
192
+ <specificerrmsg>Ce mode d'expédition n'est pas disponible. Si vous souhaitez l'utiliser contactez nous.</specificerrmsg>
193
+ </tnt>
194
+ </carriers>
195
+ </default>
196
+ </config>
app/code/community/Infostrates/Tnt/etc/system.xml ADDED
@@ -0,0 +1,272 @@
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <sections>
5
+ <carriers>
6
+ <groups>
7
+ <tnt translate="label" module="usa">
8
+ <label>TNT</label>
9
+ <frontend_type>text</frontend_type>
10
+ <sort_order>12</sort_order>
11
+ <show_in_default>1</show_in_default>
12
+ <show_in_website>1</show_in_website>
13
+ <show_in_store>1</show_in_store>
14
+ <fields>
15
+ <active translate="label">
16
+ <label>Enabled</label>
17
+ <frontend_type>select</frontend_type>
18
+ <source_model>adminhtml/system_config_source_yesno</source_model>
19
+ <sort_order>1</sort_order>
20
+ <show_in_default>1</show_in_default>
21
+ <show_in_website>1</show_in_website>
22
+ <show_in_store>0</show_in_store>
23
+ </active>
24
+ <title translate="label">
25
+ <label>Title</label>
26
+ <frontend_type>text</frontend_type>
27
+ <sort_order>1</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ <validate>required-entry</validate>
32
+ </title>
33
+ <gateway_url translate="label">
34
+ <label>Gateway URL</label>
35
+ <frontend_type>text</frontend_type>
36
+ <sort_order>2</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>0</show_in_store>
40
+ <validate>required-entry</validate>
41
+ </gateway_url>
42
+ <tracking_url translate="label comment">
43
+ <label>URL de tracking TNT</label>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>2</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>0</show_in_store>
49
+ <validate>required-entry</validate>
50
+ </tracking_url>
51
+ <account translate="label comment">
52
+ <label>Numéro de compte client TNT</label>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>3</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>0</show_in_store>
58
+ <validate>required-entry</validate>
59
+ <comment>Uniquement des chiffres</comment>
60
+ </account>
61
+ <identifiant translate="label comment">
62
+ <label>Identifiant MyTNT</label>
63
+ <frontend_type>text</frontend_type>
64
+ <sort_order>4</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>0</show_in_store>
68
+ <validate>required-entry</validate>
69
+ <comment>Adresse email</comment>
70
+ </identifiant>
71
+ <mdp translate="label comment">
72
+ <label>Mot de passe MyTNT</label>
73
+ <frontend_type>text</frontend_type>
74
+ <sort_order>5</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>0</show_in_store>
78
+ <validate>required-entry</validate>
79
+ </mdp>
80
+ <raison_sociale translate="label comment">
81
+ <label>Raison sociale</label>
82
+ <frontend_type>text</frontend_type>
83
+ <sort_order>6</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>0</show_in_store>
87
+ <validate>required-entry</validate>
88
+ </raison_sociale>
89
+ <adresse translate="label comment">
90
+ <label>Adresse d'expédition</label>
91
+ <frontend_type>text</frontend_type>
92
+ <sort_order>7</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>0</show_in_store>
96
+ <validate>required-entry</validate>
97
+ </adresse>
98
+ <adresse2 translate="label comment">
99
+ <label>Complément d'adresse d'expédition</label>
100
+ <frontend_type>text</frontend_type>
101
+ <sort_order>8</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>0</show_in_store>
105
+ </adresse2>
106
+ <code_postal translate="label comment">
107
+ <label>Code postal</label>
108
+ <frontend_type>text</frontend_type>
109
+ <sort_order>9</sort_order>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>0</show_in_store>
113
+ <validate>required-entry</validate>
114
+ </code_postal>
115
+ <ville translate="label comment">
116
+ <label>Ville</label>
117
+ <frontend_type>text</frontend_type>
118
+ <sort_order>10</sort_order>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>0</show_in_store>
122
+ <validate>required-entry</validate>
123
+ </ville>
124
+ <max_package_weight translate="label">
125
+ <label>Poids Maximum par colis (pour les colis plus lourds, contactez TNT Express)</label>
126
+ <frontend_type>text</frontend_type>
127
+ <sort_order>11</sort_order>
128
+ <show_in_default>1</show_in_default>
129
+ <show_in_website>1</show_in_website>
130
+ <show_in_store>0</show_in_store>
131
+ </max_package_weight>
132
+ <allowed_methods translate="label">
133
+ <label>Allowed Methods</label>
134
+ <frontend_type>multiselect</frontend_type>
135
+ <source_model>tnt/shipping_carrier_tnt_source_method</source_model>
136
+ <sort_order>16</sort_order>
137
+ <show_in_default>1</show_in_default>
138
+ <show_in_website>1</show_in_website>
139
+ <show_in_store>0</show_in_store>
140
+ <can_be_empty>1</can_be_empty>
141
+ </allowed_methods>
142
+ <label_format>
143
+ <label>Format d'étiquette</label>
144
+ <frontend_type>select</frontend_type>
145
+ <source_model>tnt/shipping_carrier_tnt_source_labelformat</source_model>
146
+ <sort_order>16</sort_order>
147
+ <show_in_default>1</show_in_default>
148
+ <show_in_website>1</show_in_website>
149
+ <show_in_store>0</show_in_store>
150
+ </label_format>
151
+ <JZ_amount>
152
+ <label>TNT 24h à Domicile</label>
153
+ <frontend_type>text</frontend_type>
154
+ <sort_order>23</sort_order>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>0</show_in_store>
158
+ <validate>required-entry</validate>
159
+ <comment>Soit un montant unique ex : 15.99. Soit au format poids/prix ex : 10:23.90,20:52.30,1000:99</comment>
160
+ </JZ_amount>
161
+ <JZ_free>
162
+ <label>Minimum d'achat pour TNT 24h à Domicile offert</label>
163
+ <frontend_type>text</frontend_type>
164
+ <sort_order>24</sort_order>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>0</show_in_store>
168
+ <validate>required-entry</validate>
169
+ <comment>ex : 150</comment>
170
+ </JZ_free>
171
+ <J_amount>
172
+ <label>TNT 24h Entreprise</label>
173
+ <frontend_type>text</frontend_type>
174
+ <sort_order>31</sort_order>
175
+ <show_in_default>1</show_in_default>
176
+ <show_in_website>1</show_in_website>
177
+ <show_in_store>0</show_in_store>
178
+ <validate>required-entry</validate>
179
+ <comment>Soit un montant unique ex : 15.99. Soit au format poids/prix ex : 10:23.90,20:52.30,1000:99</comment>
180
+ </J_amount>
181
+ <J_free>
182
+ <label>Minimum d'achat pour TNT 24h Entreprise offert</label>
183
+ <frontend_type>text</frontend_type>
184
+ <sort_order>32</sort_order>
185
+ <show_in_default>1</show_in_default>
186
+ <show_in_website>1</show_in_website>
187
+ <show_in_store>0</show_in_store>
188
+ <validate>required-entry</validate>
189
+ <comment>ex : 150</comment>
190
+ </J_free>
191
+ <JD_amount>
192
+ <label>TNT 24h en Relais Colis®</label>
193
+ <frontend_type>text</frontend_type>
194
+ <sort_order>33</sort_order>
195
+ <show_in_default>1</show_in_default>
196
+ <show_in_website>1</show_in_website>
197
+ <show_in_store>0</show_in_store>
198
+ <validate>required-entry</validate>
199
+ <comment>Soit un montant unique ex : 15.99. Soit au format poids/prix ex : 10:23.90,20:52.30,1000:99</comment>
200
+ </JD_amount>
201
+ <JD_free>
202
+ <label>Minimum d'achat pour TNT 24h en Relais Colis® offert</label>
203
+ <frontend_type>text</frontend_type>
204
+ <sort_order>34</sort_order>
205
+ <show_in_default>1</show_in_default>
206
+ <show_in_website>1</show_in_website>
207
+ <show_in_store>0</show_in_store>
208
+ <validate>required-entry</validate>
209
+ <comment>ex : 150</comment>
210
+ </JD_free>
211
+ <specificerrmsg translate="label">
212
+ <label>Displayed Error Message</label>
213
+ <frontend_type>textarea</frontend_type>
214
+ <sort_order>80</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>1</show_in_store>
218
+ <validate>required-entry</validate>
219
+ </specificerrmsg>
220
+ <sallowspecific translate="label">
221
+ <label>Ship to Applicable Countries</label>
222
+ <frontend_type>select</frontend_type>
223
+ <sort_order>90</sort_order>
224
+ <frontend_class>shipping-applicable-country</frontend_class>
225
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
226
+ <show_in_default>1</show_in_default>
227
+ <show_in_website>1</show_in_website>
228
+ <show_in_store>0</show_in_store>
229
+ </sallowspecific>
230
+ <specificcountry translate="label">
231
+ <label>Ship to Specific Countries</label>
232
+ <frontend_type>multiselect</frontend_type>
233
+ <sort_order>91</sort_order>
234
+ <source_model>adminhtml/system_config_source_country</source_model>
235
+ <show_in_default>1</show_in_default>
236
+ <show_in_website>1</show_in_website>
237
+ <show_in_store>0</show_in_store>
238
+ <can_be_empty>1</can_be_empty>
239
+ </specificcountry>
240
+ <showmethod translate="label">
241
+ <label>Show Method if Not Applicable</label>
242
+ <frontend_type>select</frontend_type>
243
+ <sort_order>92</sort_order>
244
+ <frontend_class>shipping-skip-hide</frontend_class>
245
+ <source_model>adminhtml/system_config_source_yesno</source_model>
246
+ <show_in_default>1</show_in_default>
247
+ <show_in_website>1</show_in_website>
248
+ <show_in_store>0</show_in_store>
249
+ </showmethod>
250
+ <debug translate="label">
251
+ <label>Debug</label>
252
+ <frontend_type>select</frontend_type>
253
+ <source_model>adminhtml/system_config_source_yesno</source_model>
254
+ <sort_order>92</sort_order>
255
+ <show_in_default>1</show_in_default>
256
+ <show_in_website>1</show_in_website>
257
+ <show_in_store>0</show_in_store>
258
+ </debug>
259
+ <sort_order translate="label">
260
+ <label>Sort Order</label>
261
+ <frontend_type>text</frontend_type>
262
+ <sort_order>100</sort_order>
263
+ <show_in_default>1</show_in_default>
264
+ <show_in_website>1</show_in_website>
265
+ <show_in_store>0</show_in_store>
266
+ </sort_order>
267
+ </fields>
268
+ </tnt>
269
+ </groups>
270
+ </carriers>
271
+ </sections>
272
+ </config>
app/code/community/Infostrates/Tnt/sql/tnt_setup/mysql4-uninstall-1.0.0.php ADDED
@@ -0,0 +1,11 @@
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+ DELETE FROM {$this->getTable('core/config_data')} WHERE path like 'carriers/tnt/%';
8
+ DELETE FROM {$this->getTable('core/resource')} WHERE code like 'tnt_setup';
9
+ ");
10
+
11
+ $installer->endSetup();
app/design/adminhtml/default/tnt/template/sales/order/invoice/create/form.phtml ADDED
@@ -0,0 +1,85 @@
1
+ <form id="edit_form" method="post" action="<?php echo $this->getSaveUrl() ?>">
2
+ <?php echo $this->getBlockHtml('formkey')?>
3
+ <?php $_order = $this->getInvoice()->getOrder() ?>
4
+ <?php echo $this->getChildHtml('order_info') ?>
5
+ <?php if (!$_order->getIsVirtual()): ?>
6
+ <div class="box-left">
7
+ <?php else: ?>
8
+ <div class="box-right">
9
+ <?php endif; ?>
10
+
11
+ <div class="entry-edit">
12
+ <div class="entry-edit-head">
13
+ <h4 class="icon-head head-payment-method"><?php echo Mage::helper('sales')->__('Payment Information') ?></h4>
14
+ </div>
15
+ <fieldset>
16
+ <div><?php echo $this->getChildHtml('order_payment') ?></div>
17
+ <div><?php echo Mage::helper('sales')->__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?></div>
18
+ </fieldset>
19
+ </div>
20
+ </div>
21
+ <?php if (!$_order->getIsVirtual()): ?>
22
+ <div class="box-right">
23
+ <!--Shipping Address-->
24
+ <div class="entry-edit">
25
+ <div class="entry-edit-head">
26
+ <h4 class="icon-head head-shipping-method"><?php echo Mage::helper('sales')->__('Shipping Information') ?></h4>
27
+ </div>
28
+ <fieldset>
29
+ <div>
30
+ <strong><?php echo $_order->getShippingDescription() ?></strong>
31
+ <?php echo $this->helper('sales')->__('Total Shipping Charges'); ?>:
32
+
33
+ <?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?>
34
+ <?php $_excl = $this->displayShippingPriceInclTax($_order); ?>
35
+ <?php else: ?>
36
+ <?php $_excl = $this->displayPriceAttribute('shipping_amount', false, ' '); ?>
37
+ <?php endif; ?>
38
+ <?php $_incl = $this->displayShippingPriceInclTax($_order); ?>
39
+
40
+ <?php echo $_excl; ?>
41
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
42
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
43
+ <?php endif; ?>
44
+ </div>
45
+ <?php $_order = Mage::registry('current_invoice')->getOrder(); ?>
46
+ <?php $_shippingMethod = $_order->getShippingCarrier()->getCarrierCode(); ?>
47
+ <?php if ($this->canCreateShipment() && $this->canShipPartiallyItem()
48
+ && $_shippingMethod != 'tnt'): ?>
49
+ <p class="nm">
50
+ <label for="invoice_do_shipment" class="normal"><?php echo Mage::helper('sales')->__('Create Shipment') ?></label>
51
+ <input type="checkbox" name="invoice[do_shipment]" id="invoice_do_shipment" value="1" onclick="if ( this.checked==true ) { document.getElementById('tracking').style.display = 'block'} else { document.getElementById('tracking').style.display = 'none' }"<?php echo $this->hasInvoiceShipmentTypeMismatch()?' disabled="disabled"':'' ?> />
52
+ </p>
53
+ <?php if ($this->hasInvoiceShipmentTypeMismatch()): ?>
54
+ <small><?php echo $this->__('Some items in this order have different invoice and shipment types. You can create shipment only after the invoice is created.') ?></small>
55
+ <?php endif; ?>
56
+ <?php endif; ?>
57
+ <div id="tracking" style="display:none;"><?php echo $this->getChildHtml('tracking',false) ?></div>
58
+ </fieldset>
59
+ </div>
60
+ </div>
61
+ <?php endif; ?>
62
+ <div class="clear"></div>
63
+
64
+ <div class="entry-edit">
65
+ <div class="entry-edit-head">
66
+ <?php
67
+ $_itemsGridLabel = $this->getForcedShipmentCreate()?'Items to Invoice and Ship':'Items to Invoice';
68
+ ?>
69
+ <h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('%s', $_itemsGridLabel) ?></h4>
70
+ </div>
71
+ </div>
72
+ <div id="invoice_item_container">
73
+ <?php echo $this->getChildHtml('order_items') ?>
74
+ </div>
75
+ </form>
76
+ <script>
77
+ /*forced creating of shipment*/
78
+ var forcedShipmentCreate = <?php echo $this->getForcedShipmentCreate() ?>;
79
+ var shipmentElement = $('invoice_do_shipment');
80
+ if (forcedShipmentCreate && shipmentElement) {
81
+ shipmentElement.checked = true;
82
+ shipmentElement.disabled = true;
83
+ document.getElementById('tracking').style.display = 'block';
84
+ }
85
+ </script>
app/design/adminhtml/default/tnt/template/sales/order/invoice/create/tracking.phtml ADDED
@@ -0,0 +1,90 @@