Magebuzz_RocketUncle - Version 0.1.0

Version Notes

Rocket Uncle 0.1.0

Download this release

Release Info

Developer Magebuzz
Extension Magebuzz_RocketUncle
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (20) hide show
  1. app/code/community/Magebuzz/Rocketuncle/Block/Adminhtml/Order/Grid/Renderer/Rocketstatus.php +26 -0
  2. app/code/community/Magebuzz/Rocketuncle/Block/Adminhtml/Order/Grid/Renderer/Shipment/Rocketstatus.php +22 -0
  3. app/code/community/Magebuzz/Rocketuncle/Block/Adminhtml/System/Config/Button.php +34 -0
  4. app/code/community/Magebuzz/Rocketuncle/Helper/Data.php +331 -0
  5. app/code/community/Magebuzz/Rocketuncle/Model/Observer.php +103 -0
  6. app/code/community/Magebuzz/Rocketuncle/Model/System/Config/Scope.php +12 -0
  7. app/code/community/Magebuzz/Rocketuncle/Model/System/Config/Weightunit.php +12 -0
  8. app/code/community/Magebuzz/Rocketuncle/controllers/Adminhtml/RocketuncleController.php +55 -0
  9. app/code/community/Magebuzz/Rocketuncle/controllers/IndexController.php +245 -0
  10. app/code/community/Magebuzz/Rocketuncle/etc/adminhtml.xml +25 -0
  11. app/code/community/Magebuzz/Rocketuncle/etc/config.xml +184 -0
  12. app/code/community/Magebuzz/Rocketuncle/etc/system.xml +188 -0
  13. app/code/community/Magebuzz/Rocketuncle/sql/rocketuncle_setup/mysql4-install-0.1.0.php +9 -0
  14. app/design/adminhtml/default/default/layout/rocketuncle.xml +40 -0
  15. app/design/adminhtml/default/default/template/rocketuncle/sales/order/invoice/create/tracking.phtml +115 -0
  16. app/design/adminhtml/default/default/template/rocketuncle/sales/order/shipment/create/items.phtml +137 -0
  17. app/design/adminhtml/default/default/template/rocketuncle/sales/order/view/tab/info.phtml +197 -0
  18. app/design/adminhtml/default/default/template/rocketuncle/system/config/button.phtml +22 -0
  19. app/etc/modules/Magebuzz_Rocketuncle.xml +9 -0
  20. package.xml +18 -0
app/code/community/Magebuzz/Rocketuncle/Block/Adminhtml/Order/Grid/Renderer/Rocketstatus.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @copyright Copyright (c) 2014 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Rocketuncle_Block_Adminhtml_Order_Grid_Renderer_Rocketstatus extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
7
+ {
8
+ public function render(Varien_Object $row)
9
+ {
10
+
11
+ $order = Mage::getModel('sales/order')->load($row->getId());
12
+ $rocketStatus = $order->getRocketuncleStatus() ;
13
+ Zend_Debug::dump($rocketStatus) ;die();
14
+ $message = $order->getRocketuncleInformation() ;
15
+ $information = json_decode($message);
16
+ if($rocketStatus == 1){
17
+ $name = "<p>Success</p>";
18
+ }else if($rocketStatus== 2){
19
+ $name = "<p>Fail : ".$information->errorMessage." </p>";
20
+ }else{
21
+ $name = "Pending";
22
+ }
23
+
24
+ return $name;
25
+ }
26
+ }
app/code/community/Magebuzz/Rocketuncle/Block/Adminhtml/Order/Grid/Renderer/Shipment/Rocketstatus.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @copyright Copyright (c) 2014 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Rocketuncle_Block_Adminhtml_Order_Grid_Renderer_Shipment_Rocketstatus extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
7
+ public function render(Varien_Object $row) {
8
+ $order = Mage::getModel('sales/order')->load($row->getOrderIncrementId(), 'increment_id');
9
+ $rocketStatus = $order->getRocketuncleStatus() ;
10
+ $message = $order->getRocketuncleInformation() ;
11
+ $information = json_decode($message);
12
+ if ($rocketStatus == 1) {
13
+ $name = "<p>Success</p>";
14
+ } else if($rocketStatus== 2) {
15
+ $name = "<p>Fail : ".$information->message." </p>";
16
+ } else {
17
+ $name = "Pending";
18
+ }
19
+
20
+ return $name;
21
+ }
22
+ }
app/code/community/Magebuzz/Rocketuncle/Block/Adminhtml/System/Config/Button.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright (c) 2014 www.magebuzz.com
4
+ */
5
+ class Magebuzz_Rocketuncle_Block_Adminhtml_System_Config_Button extends Mage_Adminhtml_Block_System_Config_Form_Field{
6
+ protected function _construct() {
7
+ parent::_construct();
8
+ $this->setTemplate('rocketuncle/system/config/button.phtml');
9
+ }
10
+
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
12
+ return $this->_toHtml();
13
+ }
14
+
15
+ public function getAjaxCheckUrl() {
16
+ return Mage::helper('adminhtml')->getUrl('rocketuncle/adminhtml_rocketuncle/get_access_token');
17
+ }
18
+
19
+ /**
20
+ * Generate button html
21
+ *
22
+ * @return string
23
+ */
24
+ public function getButtonHtml() {
25
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
26
+ ->setData(array(
27
+ 'id' => 'rocketuncle_button',
28
+ 'label' => $this->helper('adminhtml')->__('Get Access Token'),
29
+ 'onclick' => 'javascript:check(); return false;'
30
+ ));
31
+
32
+ return $button->toHtml();
33
+ }
34
+ }
app/code/community/Magebuzz/Rocketuncle/Helper/Data.php ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright (c) 2014 www.magebuzz.com
4
+ */
5
+ class Magebuzz_Rocketuncle_Helper_Data extends Mage_Core_Helper_Abstract {
6
+ const ACCESS_TOKEN_URL = 'https://go.rocketuncle.com/oauth/Token';
7
+ const CREATE_ORDER_URL = 'http://api.rocketuncle.com/api/v2/Deliveries/Create';
8
+
9
+ public function getDbAccessToken() {
10
+ $storeId = Mage::app()->getStore()->getId();
11
+ return (string) Mage::getStoreConfig('rocketuncle/general/access_token', $storeId);
12
+ }
13
+
14
+ public function getClientId() {
15
+ $storeId = Mage::app()->getStore()->getId();
16
+ return (string) Mage::getStoreConfig('rocketuncle/general/client_id', $storeId);
17
+ }
18
+
19
+ public function getClientSecret() {
20
+ $storeId = Mage::app()->getStore()->getId();
21
+ return (string) Mage::getStoreConfig('rocketuncle/general/client_secret', $storeId);
22
+ }
23
+
24
+ public function enableRocketUncle() {
25
+ $storeId = Mage::app()->getStore()->getId();
26
+ return (bool) Mage::getStoreConfig('rocketuncle/general/active', $storeId);
27
+ }
28
+
29
+ public function getScope() {
30
+ return 'order';
31
+ // $storeId = Mage::app()->getStore()->getId();
32
+ // return (string) Mage::getStoreConfig('rocketuncle/general/scope', $storeId);
33
+ }
34
+
35
+ public function getService() {
36
+ $storeId = Mage::app()->getStore()->getId();
37
+ return (string) Mage::getStoreConfig('rocketuncle/general/service', $storeId);
38
+ }
39
+
40
+ public function getPickupTime() {
41
+ $storeId = Mage::app()->getStore()->getId();
42
+ return (string) Mage::getStoreConfig('rocketuncle/general/pickup_time', $storeId);
43
+ }
44
+
45
+ public function getWeightUnit() {
46
+ $storeId = Mage::app()->getStore()->getId();
47
+ return (string) Mage::getStoreConfig('rocketuncle/general/weight_unit', $storeId);
48
+ }
49
+
50
+ public function isTestMode() {
51
+ $storeId = Mage::app()->getStore()->getId();
52
+ return (string) Mage::getStoreConfig('rocketuncle/general/test_mode', $storeId);
53
+ }
54
+
55
+
56
+ public function getSender() {
57
+
58
+ $localtion = array(
59
+ "countryCode"=>Mage::getStoreConfig('rocketuncle/sender/country_code'),
60
+ "address"=>Mage::getStoreConfig('rocketuncle/sender/address_sender'),
61
+ "address2"=>Mage::getStoreConfig('rocketuncle/sender/address_sender2'),
62
+ "postalCode"=>Mage::getStoreConfig('rocketuncle/sender/postal_code'),
63
+ );
64
+
65
+ $senderData = array(
66
+ "companyName"=>Mage::getStoreConfig('rocketuncle/sender/company_name'),
67
+ "contactName"=>Mage::getStoreConfig('rocketuncle/sender/contact_name'),
68
+ "contactNumber"=>Mage::getStoreConfig('rocketuncle/sender/contact_number'),
69
+ "location"=> $localtion,
70
+ );
71
+
72
+ return $senderData;
73
+
74
+ }
75
+
76
+
77
+ public function call($method, $url, $data = null ,$accessTocken) {
78
+ $ch = curl_init($url);
79
+ $scope = Mage::helper('rocketuncle')->getScope();
80
+ $header = array(
81
+ 'Content-Type: application/json',
82
+ 'Authorization : Bearer '.$accessTocken,
83
+ 'scope: '.$scope,
84
+ 'grant_type: client_credentials'
85
+ );
86
+ curl_setopt_array($ch, array(
87
+ CURLOPT_RETURNTRANSFER => true,
88
+ CURLOPT_POSTFIELDS => $data,
89
+ CURLOPT_HTTPHEADER => $header,
90
+ ));
91
+ $res = curl_exec($ch);
92
+ $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
93
+ return json_decode($res, true);
94
+ }
95
+
96
+
97
+ function getAccessToken($method, $curl_data) {
98
+ $options = array(
99
+ CURLOPT_RETURNTRANSFER => true,
100
+ CURLOPT_HEADER => false,
101
+ CURLOPT_FOLLOWLOCATION => true,
102
+ CURLOPT_ENCODING => "",
103
+ CURLOPT_USERAGENT => "spider",
104
+ CURLOPT_AUTOREFERER => true,
105
+ CURLOPT_CONNECTTIMEOUT => 120,
106
+ CURLOPT_TIMEOUT => 120,
107
+ CURLOPT_MAXREDIRS => 10,
108
+ CURLOPT_POST => 1,
109
+ CURLOPT_POSTFIELDS => $curl_data,
110
+ CURLOPT_SSL_VERIFYHOST => 0,
111
+ CURLOPT_SSL_VERIFYPEER => false,
112
+ CURLOPT_VERBOSE => 1 ,
113
+ CURLOPT_CUSTOMREQUEST => strtoupper($method),
114
+ );
115
+
116
+ $accessTokenUrl = 'https://go.rocketuncle.com/oauth/Token';
117
+ if ($this->isTestMode()) {
118
+ $accessTokenUrl = 'https://go.rocketuncle.net/oauth/Token';
119
+ }
120
+
121
+ $ch = curl_init($accessTokenUrl);
122
+ curl_setopt_array($ch,$options);
123
+ $content = curl_exec($ch);
124
+ $err = curl_errno($ch);
125
+ $errmsg = curl_error($ch) ;
126
+ $header = curl_getinfo($ch);
127
+ curl_close($ch);
128
+ $header['errno'] = $err;
129
+ $header['errmsg'] = $errmsg;
130
+ $header['content'] = $content;
131
+ return $header;
132
+ }
133
+
134
+ public function postRocketShipmentToAPI($order) {
135
+ Mage::log('start creating shipment', null, 'rocketuncle.log');
136
+ $shippingAddress = $order->getShippingAddress()->getData();
137
+ $shipName = $shippingAddress['firstname']. ' '. $shippingAddress['lastname'];
138
+ $companyName = $shippingAddress['company'];
139
+ if ($companyName =='') {
140
+ $companyName = 'N/A';
141
+ }
142
+ $countryId = $shippingAddress['country_id'];
143
+ $postcode = $shippingAddress['postcode'];
144
+ $address = $shippingAddress['street']. ',' .$shippingAddress['city'].',' .$shippingAddress['region'];
145
+ $phoneNumber = $shippingAddress['telephone'];
146
+ $location = array (
147
+ 'countryCode' => $countryId,
148
+ 'address' => $address,
149
+ 'address2' => '',
150
+ 'postalCode' => $postcode
151
+ );
152
+
153
+ // receiver
154
+ $receiver = array (
155
+ 'companyName' => $companyName,
156
+ 'contactName' => $shipName,
157
+ 'contactNumber' => $phoneNumber,
158
+ 'location' => $location
159
+ );
160
+ // sender
161
+ $sender = $this->getSender();
162
+
163
+ // services
164
+ //$service = $this->getService() ;
165
+ $service = $this->getService();
166
+
167
+ $time = '10:00' ;
168
+ $weightUnit = $this->getWeightUnit() ;
169
+ // comment
170
+ $comments = '';
171
+ //pickupTime
172
+ $date = new DateTime();
173
+ $pickupTime = $date->format('Y-m-d') . 'T' . $this->getPickupTime() . ':00+08:00';
174
+ // get deliverydate_date
175
+
176
+ // get delivery date -- integrated with Amasty deliverydate extension
177
+ if ($this->isModuleInstalled('Amasty_Deliverydate')) {
178
+ $orderDate = Mage::getModel('amdeliverydate/deliverydate');
179
+ $orderDate->load($order->getId(), 'order_id');
180
+ if ($orderDate->getDate()) {
181
+ $deliveryDate = $orderDate->getDate();
182
+ $deliveryTime = $orderDate->getTime();
183
+ if ($deliveryTime == '14 00 - 19 00') {
184
+ $service = 'AFTERNOON';
185
+ }
186
+ else {
187
+ $service = 'MORNING';
188
+ }
189
+ $pickupTime = $deliveryDate . 'T' . $pickupTime . ':00+08:00';
190
+ $comments = $orderDate->getComment();
191
+ }
192
+ }
193
+
194
+ // get weight total of order
195
+ $weight = 0;
196
+ $items = $order->getAllItems();
197
+ foreach ($items as $item) {
198
+ $weight += ($item->getWeight() * $item->getQtyOrdered());
199
+ }
200
+
201
+ $dataPost = array(
202
+ 'sender' => $sender,
203
+ 'receiver' => $receiver,
204
+ 'service' => $service,
205
+ 'pickupTime' => $pickupTime,
206
+ 'parcels' => array (
207
+ array(
208
+ 'description' => 'parcel1',
209
+ 'dimension' => array('unit' => 'cm', 'width' => 0, 'height' => 0, 'length' => 0),
210
+ 'weight'=>array("unit" => $weightUnit, "value" => $weight)
211
+ ),
212
+ ),
213
+ 'comments' => $comments
214
+ );
215
+
216
+ if ($order->getPayment()->getMethod() == 'cashondelivery') {
217
+ $dataPost['cod'] = array(
218
+ 'symbol' => $order->getOrderCurrencyCode(),
219
+ 'value' => $order->getGrandTotal()
220
+ );
221
+ }
222
+
223
+ //$url = 'https://gofuture.rocketuncle.com/oauth/Token';
224
+ //$url = 'https://go.rocketuncle.com/oauth/Token';
225
+
226
+ $accessToken = $this->getDbAccessToken();
227
+ if (!$accessToken) {
228
+ $clientId = $this->getClientId();
229
+ $secretKey = $this->getClientSecret();
230
+ $scope = $this->getScope();
231
+ $method = "POST";
232
+ $data = array(
233
+ 'grant_type' => 'client_credentials',
234
+ 'scope' => $scope,
235
+ 'client_id' => $clientId,
236
+ 'client_secret' => $secretKey
237
+ );
238
+ $responseToken = $this->getAccessToken($method, $data);
239
+ if (isset($responseToken['http_code']) && $responseToken['http_code'] == 200) {
240
+ $contentResponce = $responseToken['content'];
241
+ $decodeData = json_decode($contentResponce);
242
+ $accessToken = $decodeData->access_token;
243
+ }
244
+ }
245
+
246
+ if ($accessToken) {
247
+ $jsonData = json_encode($dataPost);
248
+ // send request Create Order on Rocket
249
+ //$urlCreateOrder = 'http://apifuture.rocketuncle.com/api/v2/Deliveries/Create';
250
+ $urlCreateOrder = 'http://api.rocketuncle.com/api/v2/Deliveries/Create';
251
+ if ($this->isTestMode()) {
252
+ $urlCreateOrder = 'http://api.rocketuncle.net/api/v2/Deliveries/Create';
253
+ }
254
+ $sendRequestCreateOrder = $this->call("POST", $urlCreateOrder, $jsonData, $accessToken);
255
+
256
+ if (isset($sendRequestCreateOrder['status']) && $sendRequestCreateOrder['status'] == 'Success') {
257
+ //--------------------------------
258
+ $order->setRocketuncleStatus(1);
259
+ $order->setRocketuncleInformation(json_encode($sendRequestCreateOrder['delivery']));
260
+ } else {
261
+ $order->setRocketuncleStatus(2);
262
+ if (isset($sendRequestCreateOrder['error'])) {
263
+ $error = $sendRequestCreateOrder['error'];
264
+ $message= '';
265
+ foreach ($error as $er) {
266
+ $message .=$er['errorMessage'].',';
267
+ }
268
+ $errorMessage = array('status'=>'error', 'message'=>$message) ;
269
+ }
270
+ $order->setRocketuncleInformation(json_encode($errorMessage));
271
+ }
272
+ } else {
273
+ $order->setRocketuncleStatus(2);
274
+ $errorMessage = array('status' => 'error','message' => "Cannot get access token.") ;
275
+ $order->setRocketuncleInformation(json_encode($errorMessage));
276
+ }
277
+
278
+ $order->save();
279
+ return $this;
280
+ }
281
+
282
+ public function getAvailableServices() {
283
+ $url = 'http://api.rocketuncle.net/api/v2/Services';
284
+ $data = array();
285
+ $data['senderLocation'] = array(
286
+ 'countryCode' => 'SG',
287
+ 'postalCode' => '469025'
288
+ );
289
+ $data['receiverLocation'] = array(
290
+ 'countryCode' => 'SG',
291
+ 'postalCode' => '610118'
292
+ );
293
+
294
+ $data['parcels'] = array(
295
+ array(
296
+ 'description' => 'Parcel 1',
297
+ 'weight' => array(
298
+ 'unit' => 'kg',
299
+ 'value' => '0.14'
300
+ )
301
+ )
302
+ );
303
+
304
+ // 'parcels' => array (
305
+ // array(
306
+ // 'description' => 'parcel1',
307
+ // 'dimension' => array('unit' => 'cm', 'width' => 0, 'height' => 0, 'length' => 0),
308
+ // 'weight'=>array("unit" => $weightUnit, "value" => $weight)
309
+ // ),
310
+ // )
311
+
312
+ $jsonData = json_encode($data);
313
+ $accessToken = $this->getDbAccessToken();
314
+
315
+ // echo $accessToken; die('fff');
316
+ //$scope = $this->getScope();
317
+ //$method = "POST";
318
+ $response = $this->call("POST", $url, $jsonData, $accessToken);
319
+ Zend_Debug::dump($response);
320
+ die('aaaa');
321
+ }
322
+
323
+ public function isModuleInstalled($moduleName) {
324
+ $isActive = Mage::getConfig()->getNode('modules/' . $moduleName . '/active');
325
+ if ($isActive && in_array((string)$isActive, array('true', '1'))) {
326
+ return true;
327
+ }
328
+ return false;
329
+ }
330
+
331
+ }
app/code/community/Magebuzz/Rocketuncle/Model/Observer.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright (c) 2014 www.magebuzz.com
4
+ */
5
+ class Magebuzz_Rocketuncle_Model_Observer {
6
+
7
+ public function sendOrderJson(Varien_Event_Observer $observer) {
8
+
9
+ $_helper = Mage::helper('rocketuncle');
10
+
11
+ if (!$_helper->enableRocketUncle()) {
12
+ return $this;
13
+ }
14
+ $rocketStatus = Mage::getSingleton('adminhtml/session')->getCreateDelivery();
15
+ $event = $observer->getEvent();
16
+ $shipment = $event->getShipment();
17
+ $order = $shipment->getOrder();
18
+ if($rocketStatus){
19
+ $_helper->postRocketShipmentToAPI($order);
20
+ }
21
+
22
+ Mage::getSingleton('adminhtml/session')->setCreateDelivery(false);
23
+ }
24
+
25
+ // add field Rocket information in Order Grid
26
+ public function addFieldRocketForOrderGrid($observer){
27
+ $block = $observer->getEvent()->getBlock();
28
+ $allowPendingCustomer = Mage::helper('rocketuncle')->enableRocketUncle();
29
+ if($allowPendingCustomer ==1){
30
+ //if($block->getType() == 'adminhtml/sales_order_view_tab_shipments'){
31
+ // $block->addColumnAfter('rocketuncle_status', array(
32
+ // 'header' => 'Rocket Uncle Shipment Status',
33
+ // 'type' => 'text',
34
+ // 'width' => '50px',
35
+ // 'index' => 'rocketuncle_status',
36
+ // 'renderer' => 'rocketuncle/adminhtml_order_grid_renderer_rocketstatus',
37
+ // 'filter' => false,
38
+ // 'sort' => false
39
+ // ),'grand_total');
40
+ // }
41
+
42
+
43
+ if($block->getType() == 'adminhtml/sales_shipment_grid'){
44
+
45
+ $block->addColumnAfter('rocketuncle_status', array(
46
+ 'header' => 'Rocket Uncle Shipment Status',
47
+ 'type' => 'text',
48
+ 'width' => '50px',
49
+ 'index' => 'rocketuncle_status',
50
+ 'renderer' => 'rocketuncle/adminhtml_order_grid_renderer_shipment_rocketstatus',
51
+ 'filter' => false,
52
+ 'sort' => false
53
+ ),'increment_id');
54
+ }
55
+ }
56
+ }
57
+
58
+ public function controllerPredispatchAction($observer){
59
+ $fullActionName = $observer->getEvent()->getControllerAction()->getFullActionName();
60
+ if($observer->getEvent()->getControllerAction()->getFullActionName() == 'adminhtml_sales_order_shipment_save') {
61
+ $event = $observer->getEvent();
62
+ $postAction = $event->getControllerAction();
63
+ $params = $postAction->getRequest()->getParams();
64
+ if(isset($params['shipment']['create_delivery_rocket']) && $params['shipment']['create_delivery_rocket']==1){
65
+ Mage::getSingleton('adminhtml/session')->setCreateDelivery(true);
66
+ }else{
67
+ Mage::getSingleton('adminhtml/session')->setCreateDelivery(false);
68
+ }
69
+ }
70
+ }
71
+
72
+ public function predispatchInvoiceSaveAction($observer){
73
+ $fullActionName = $observer->getEvent()->getControllerAction()->getFullActionName();
74
+ if($observer->getEvent()->getControllerAction()->getFullActionName() == 'adminhtml_sales_order_invoice_save') {
75
+ $event = $observer->getEvent();
76
+ $postAction = $event->getControllerAction();
77
+ $params = $postAction->getRequest()->getParams();
78
+ if(isset($params['invoice']['do_shipment']) && $params['invoice']['do_shipment']==1){
79
+ if(isset($params['invoice']['rocket_shipment']) && $params['invoice']['rocket_shipment']==1){
80
+ Mage::getSingleton('adminhtml/session')->setCreateDelivery(true);
81
+ return;
82
+ }
83
+ }
84
+ }
85
+ Mage::getSingleton('adminhtml/session')->setCreateDelivery(false);
86
+ }
87
+
88
+ public function setTemplateInvoiceTracking($observer){
89
+ if ($observer->getBlock() instanceof Mage_Adminhtml_Block_Sales_Order_Invoice_Create_Tracking) {
90
+ $observer->getBlock()->setTemplate('rocketuncle/sales/order/invoice/create/tracking.phtml');
91
+ }
92
+ }
93
+ public function addMassActionPostShipment($observer){
94
+ $block = $observer->getBlock();
95
+ if ($block instanceof Mage_Adminhtml_Block_Sales_Shipment_Grid) {
96
+
97
+ $block->getMassactionBlock()->addItem('post_to_rocketuncle', array(
98
+ 'label'=> Mage::helper('sales')->__('Post job to Rocket Uncle'),
99
+ 'url' => Mage::getUrl('rocketuncle/adminhtml_rocketuncle/post'),
100
+ ));
101
+ }
102
+ }
103
+ }
app/code/community/Magebuzz/Rocketuncle/Model/System/Config/Scope.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright (c) 2014 www.magebuzz.com
4
+ */
5
+ class Magebuzz_Rocketuncle_Model_System_Config_Scope {
6
+ public function toOptionArray() {
7
+ return array(
8
+ 'print' => Mage::helper('rocketuncle')->__('Print Labels'),
9
+ 'order' => Mage::helper('rocketuncle')->__('Orders')
10
+ );
11
+ }
12
+ }
app/code/community/Magebuzz/Rocketuncle/Model/System/Config/Weightunit.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright (c) 2014 www.magebuzz.com
4
+ */
5
+ class Magebuzz_Rocketuncle_Model_System_Config_Weightunit {
6
+ public function toOptionArray() {
7
+ return array(
8
+ 'kg' => Mage::helper('rocketuncle')->__('Kg'),
9
+ 'lb' => Mage::helper('rocketuncle')->__('Lb')
10
+ );
11
+ }
12
+ }
app/code/community/Magebuzz/Rocketuncle/controllers/Adminhtml/RocketuncleController.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright (c) 2014 www.magebuzz.com
4
+ */
5
+ class Magebuzz_Rocketuncle_Adminhtml_RocketuncleController extends Mage_Adminhtml_Controller_Action {
6
+ public function postAction() {
7
+ $post = $this->getRequest()->getPost();
8
+ $_helper = Mage::helper('rocketuncle');
9
+ if (!$_helper->enableRocketUncle()) {
10
+ return $this;
11
+ }
12
+
13
+ if(isset($post['shipment_ids']) && count($post['shipment_ids'])>0){
14
+
15
+ $shipmentIds = $post['shipment_ids'];
16
+ foreach($shipmentIds as $shipmentId){
17
+ $shipment = Mage::getModel('sales/order_shipment');
18
+ $shipment->load($shipmentId);
19
+ $order = $shipment->getOrder();
20
+ $_helper->postRocketShipmentToAPI($order);
21
+ }
22
+ }
23
+
24
+ $this->_redirect('adminhtml/sales_shipment/index') ;
25
+ }
26
+
27
+ public function get_access_tokenAction() {
28
+ $scope = Mage::helper('rocketuncle')->getScope();
29
+ $clientId = Mage::helper('rocketuncle')->getClientId();
30
+ $secretKey = Mage::helper('rocketuncle')->getClientSecret();
31
+ $method = "POST";
32
+ $data = array(
33
+ 'grant_type' => 'client_credentials',
34
+ 'scope' => $scope,
35
+ 'client_id' => $clientId,
36
+ 'client_secret' => $secretKey
37
+ );
38
+ $responseToken = Mage::helper('rocketuncle')->getAccessToken($method, $data);
39
+ if (isset($responseToken['http_code']) && $responseToken['http_code'] == 200) {
40
+ $content = $responseToken['content'];
41
+ $decodeData = json_decode($content);
42
+ $accessToken = $decodeData->access_token;
43
+ $result = array(
44
+ 'success' => true,
45
+ 'access_token' => $accessToken
46
+ );
47
+ }
48
+ else {
49
+ $result = array(
50
+ 'success' => false
51
+ );
52
+ }
53
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
54
+ }
55
+ }
app/code/community/Magebuzz/Rocketuncle/controllers/IndexController.php ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright (c) 2014 www.magebuzz.com
4
+ */
5
+ class Magebuzz_Rocketuncle_IndexController extends Mage_Core_Controller_Front_Action {
6
+ public function testAction() {
7
+ $order = Mage::getModel('sales/order')->load(2876);
8
+ echo $order->getPayment()->getMethod();
9
+ //Mage::helper('rocketuncle')->postRocketShipmentToAPI($order);
10
+ die('1111');
11
+ $shippingAddress = $order->getShippingAddress()->getData();
12
+ $shipName = $shippingAddress['firstname']. ' '. $shippingAddress['lastname'];
13
+ $companyName = $shippingAddress['company'];
14
+ if ($companyName =='') {
15
+ $companyName = 'N/A';
16
+ }
17
+ $countryId = $shippingAddress['country_id'];
18
+ $postcode = $shippingAddress['postcode'];
19
+ $address = $shippingAddress['street']. ',' .$shippingAddress['city'].',' .$shippingAddress['region'];
20
+ $phoneNumber = $shippingAddress['telephone'];
21
+ $location = array (
22
+ 'countryCode' => $countryId,
23
+ 'address' => $address,
24
+ 'address2' => '',
25
+ 'postalCode' => $postcode
26
+ );
27
+
28
+ // receiver
29
+ $receiver = array(
30
+ 'companyName' => $companyName,
31
+ 'contactName' => $shipName,
32
+ 'contactNumber' => $phoneNumber,
33
+ 'location' => $location
34
+ );
35
+ // sender
36
+ $sender = Mage::helper('rocketuncle')->getSender();
37
+
38
+ die('xxx');
39
+
40
+ // services
41
+ //$service = $this->getService() ;
42
+ $service = 'OFFICE_HOURS_6PM'; //hardcode for expatfoodhall.
43
+
44
+ $time = '10:00' ;
45
+ $weightUnit = Mage::helper('rocketuncle')->getWeightUnit() ;
46
+ // comment
47
+ $comments = '';
48
+ //pickupTime
49
+ $pickupTime = '';
50
+ // get deliverydate_date
51
+ $row_saleorderid = Mage::getModel('onestepcheckout/onestepcheckout')->getCollection()
52
+ ->addFieldToFilter('sales_order_id',$order->getId());
53
+
54
+ if ($row_saleorderid->getSize()) {
55
+ $orderonestep = $row_saleorderid->getFirstItem();
56
+ $deliveryDate = $orderonestep->getMwDeliverydateDate();
57
+ $deliveryDate = ereg_replace('/','-',$deliveryDate);
58
+ $timestampDelivery = strtotime($deliveryDate);
59
+ $deliveryDate = date('Y-m-d',$timestampDelivery);
60
+ $deliveryTime = $orderonestep->getMwDeliverydateTime();
61
+
62
+ if ($deliveryTime !="") {
63
+ $deliveryTime = explode('-', $deliveryTime) ;
64
+ $time = $deliveryTime[0];
65
+ $end_time = $deliveryTime[1];
66
+ }
67
+
68
+ if ($time == 'All' || $end_time == '18:00') {
69
+ $service = 'OFFICE_HOURS_6PM';
70
+ }
71
+ else {
72
+ $service = 'OFFICE_HOURS_2PM';
73
+ }
74
+
75
+ if ($time == 'All') {
76
+ $time = '10:00';
77
+ }
78
+
79
+ $time = '10:00';
80
+ $dateTime = $deliveryDate;
81
+ $date = new DateTime($dateTime);
82
+ //$pickupTime = $date->format('Y-m-d H:i:sA');
83
+ $pickupTime = $date->format('Y-m-d');
84
+ $pickupTime .= 'T10:00:00+08:00';
85
+ $comments = $orderonestep->getMwCustomercommentInfo();
86
+ }
87
+
88
+ // get weight total of order
89
+ $weight = 0;
90
+ $items = $order->getAllItems();
91
+ foreach ($items as $item) {
92
+ $weight += ($item->getWeight() * $item->getQtyOrdered());
93
+ }
94
+
95
+ $dataPost = array(
96
+ 'sender' => $sender,
97
+ 'receiver' => $receiver,
98
+ 'service' => $service,
99
+ 'pickupTime' => $pickupTime,
100
+ 'parcels' => array (
101
+ array(
102
+ 'description' => 'parcel1',
103
+ 'dimension' => array('unit' => 'cm', 'width' => 0, 'height' => 0, 'length' => 0),
104
+ 'weight'=>array("unit" => $weightUnit, "value" => $weight)
105
+ ),
106
+ ),
107
+ 'comments' => $comments
108
+ );
109
+ $jsonData = json_encode($dataPost);
110
+
111
+ $clientId = Mage::helper('rocketuncle')->getClientId();
112
+ $secretKey = Mage::helper('rocketuncle')->getClientSecret();
113
+ $scope = Mage::helper('rocketuncle')->getScope();
114
+ $method = "POST";
115
+ $data = array('grant_type'=>'client_credentials','scope'=>$scope,'client_id'=>$clientId,'client_secret'=>$secretKey);
116
+ $responceToken = $this->getAccessToken($method, $url, $data);
117
+ if (isset($responceToken['http_code']) && $responceToken['http_code'] == 200) {
118
+ $contentResponce = $responceToken['content'];
119
+ $decodeData = json_decode($contentResponce);
120
+ $accessToken = $decodeData->access_token;
121
+ $jsonData = json_encode($dataPost);
122
+
123
+
124
+ // send request Create Order on Rocket
125
+ $urlCreateOrder = 'http://apifuture.rocketuncle.com/api/v2/Deliveries/Create';
126
+ $sendRequestCreateOrder = $this->call("POST",$urlCreateOrder,$jsonData,$accessToken) ;
127
+
128
+ //if(isset($sendRequestCreateOrder['status']) && $sendRequestCreateOrder['status'] == 'Success'){
129
+ //--------------------------------
130
+ //$order->setRocketuncleStatus(1);
131
+ //$order->setRocketuncleInformation(json_encode($sendRequestCreateOrder['delivery']));
132
+ // }else{
133
+ $order->setRocketuncleStatus(2);
134
+ if(isset($sendRequestCreateOrder['error'])){
135
+ $error = $sendRequestCreateOrder['error'];
136
+ $message= '';
137
+ foreach($error as $er){
138
+ $message .=$er['errorMessage'].',';
139
+ }
140
+ $errorMessage = array('status'=>'error','message'=>$message) ;
141
+ }
142
+ $order->setRocketuncleInformation(json_encode($errorMessage));
143
+ // }
144
+ }else{
145
+ // $order->setRocketuncleStatus(2);
146
+ // $errorMessage = array('status'=>'error','message'=>"Not connect to server") ;
147
+ // $order->setRocketuncleInformation(json_encode($errorMessage));
148
+ }
149
+ }
150
+
151
+ public function call($method, $url, $data = null ,$accessTocken) {
152
+ //echo $accessTocken;die();
153
+ $ch = curl_init($url);
154
+ $header = array(
155
+ 'Content-Type: application/json',
156
+ // 'Accept: application/json',
157
+ // 'Connection: close',
158
+ 'Authorization : Bearer '.$accessTocken,
159
+ 'scope: order',
160
+ 'grant_type: client_credentials'
161
+ );
162
+ curl_setopt_array($ch, array(
163
+ CURLOPT_RETURNTRANSFER => true,
164
+ //CURLOPT_CUSTOMREQUEST => strtoupper($method),
165
+ CURLOPT_POSTFIELDS => $data,
166
+ CURLOPT_HTTPHEADER => $header,
167
+ // CURLOPT_SSL_VERIFYHOST => 0, // don't verify ssl
168
+ // CURLOPT_SSL_VERIFYPEER => false,
169
+ ));
170
+ $res = curl_exec($ch);
171
+
172
+ $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
173
+ // $content = curl_exec($ch);
174
+ // $err = curl_errno($ch);
175
+ // $errmsg = curl_error($ch) ;
176
+ // $header = curl_getinfo($ch);
177
+ // curl_close($ch);
178
+ // $header['errno'] = $err;
179
+ // $header['errmsg'] = $errmsg;
180
+ // $header['content'] = $res;
181
+ Zend_Debug::dump($res);die();
182
+
183
+
184
+
185
+ if ($status == 400) {
186
+ //throw new SiteBizApiClientException($status, json_decode($res, true));
187
+ } elseif ($status > 400) {
188
+ // throw new SiteBizApiClientException($status);
189
+ }
190
+ return json_decode($res, true);
191
+ }
192
+
193
+
194
+ function getAccessToken($method,$url,$curl_data )
195
+ {
196
+ $options = array(
197
+ CURLOPT_RETURNTRANSFER => true,
198
+ CURLOPT_HEADER => false,
199
+ CURLOPT_FOLLOWLOCATION => true,
200
+ CURLOPT_ENCODING => "",
201
+ CURLOPT_USERAGENT => "spider",
202
+ CURLOPT_AUTOREFERER => true,
203
+ CURLOPT_CONNECTTIMEOUT => 120,
204
+ CURLOPT_TIMEOUT => 120,
205
+ CURLOPT_MAXREDIRS => 10,
206
+ CURLOPT_POST => 1,
207
+ CURLOPT_POSTFIELDS => $curl_data,
208
+ CURLOPT_SSL_VERIFYHOST => 0,
209
+ CURLOPT_SSL_VERIFYPEER => false,
210
+ CURLOPT_VERBOSE => 1 ,
211
+ CURLOPT_CUSTOMREQUEST => strtoupper($method),
212
+ );
213
+
214
+ $ch = curl_init($url);
215
+ curl_setopt_array($ch,$options);
216
+ $content = curl_exec($ch);
217
+ $err = curl_errno($ch);
218
+ $errmsg = curl_error($ch) ;
219
+ $header = curl_getinfo($ch);
220
+ curl_close($ch);
221
+ $header['errno'] = $err;
222
+ $header['errmsg'] = $errmsg;
223
+ $header['content'] = $content;
224
+ return $header;
225
+ }
226
+
227
+
228
+ public function testconnectAction(){
229
+ $url = 'https://gofuture.rocketuncle.com/oauth/Token';
230
+ $clientId = Mage::helper('rocketuncle')->getClientId();
231
+ $secretKey = Mage::helper('rocketuncle')->getClientSecret();
232
+ $method = "POST";
233
+ $data = array('grant_type'=>'client_credentials','scope'=>'order','client_id'=>$clientId,'client_secret'=>$secretKey);
234
+ $responceToken = $this->getAccessToken($method, $url, $data);
235
+ $accessToken = $responceToken['content'];
236
+ $jsonDecode = json_decode($accessToken);
237
+ //echo $jsonDecode->access_token; die('bbb');
238
+ $content = $this->test($jsonDecode->access_token) ;
239
+ }
240
+
241
+ public function servicesAction() {
242
+ Mage::helper('rocketuncle')->getServices();
243
+ die('ssson');
244
+ }
245
+ }
app/code/community/Magebuzz/Rocketuncle/etc/adminhtml.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <acl>
3
+ <resources>
4
+ <all>
5
+ <title>Allow Everything</title>
6
+ </all>
7
+ <admin>
8
+ <children>
9
+ <system>
10
+ <children>
11
+ <config>
12
+ <children>
13
+ <rocketuncle module="rocketuncle" translate="title">
14
+ <title>RocketUncle</title>
15
+ <sort_order>100</sort_order>
16
+ </rocketuncle>
17
+ </children>
18
+ </config>
19
+ </children>
20
+ </system>
21
+ </children>
22
+ </admin>
23
+ </resources>
24
+ </acl>
25
+ </config>
app/code/community/Magebuzz/Rocketuncle/etc/config.xml ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <!-- <stores>
4
+ <admin>
5
+ <dev>
6
+ <debug>
7
+ <template_hints>1</template_hints>
8
+ <template_hints_blocks>1</template_hints_blocks>
9
+ </debug>
10
+ </dev>
11
+ </admin>
12
+ </stores> -->
13
+ <modules>
14
+ <Magebuzz_Rocketuncle>
15
+ <version>0.1.0</version>
16
+ </Magebuzz_Rocketuncle>
17
+ </modules>
18
+ <frontend>
19
+ <routers>
20
+ <rocketuncle>
21
+ <use>standard</use>
22
+ <args>
23
+ <module>Magebuzz_Rocketuncle</module>
24
+ <frontName>rocketuncle</frontName>
25
+ </args>
26
+ </rocketuncle>
27
+ </routers>
28
+ <layout>
29
+ <updates>
30
+ <rocketuncle>
31
+ <file>rocketuncle.xml</file>
32
+ </rocketuncle>
33
+ </updates>
34
+ </layout>
35
+ <translate>
36
+ <modules>
37
+ <Magebuzz_Rocketuncle>
38
+ <files>
39
+ <default>Magebuzz_Rocketuncle.csv</default>
40
+ </files>
41
+ </Magebuzz_Rocketuncle>
42
+ </modules>
43
+ </translate>
44
+ </frontend>
45
+ <admin>
46
+ <routers>
47
+ <rocketuncle>
48
+ <use>admin</use>
49
+ <args>
50
+ <module>Magebuzz_Rocketuncle</module>
51
+ <frontName>rocketuncle</frontName>
52
+ </args>
53
+ </rocketuncle>
54
+ </routers>
55
+ </admin>
56
+ <adminhtml>
57
+ <events>
58
+ <controller_action_predispatch_adminhtml_sales_order_shipment_save>
59
+ <observers>
60
+ <magebuzz_set_status_delivery>
61
+ <class>rocketuncle/observer</class>
62
+ <method>controllerPredispatchAction</method>
63
+ </magebuzz_set_status_delivery>
64
+ </observers>
65
+ </controller_action_predispatch_adminhtml_sales_order_shipment_save>
66
+ <controller_action_predispatch_adminhtml_sales_order_invoice_save>
67
+ <observers>
68
+ <magebuzz_predispatch_invoice_save>
69
+ <class>rocketuncle/observer</class>
70
+ <method>predispatchInvoiceSaveAction</method>
71
+ </magebuzz_predispatch_invoice_save>
72
+ </observers>
73
+ </controller_action_predispatch_adminhtml_sales_order_invoice_save>
74
+ <core_block_abstract_to_html_before>
75
+ <observers>
76
+ <magebuzz_set_template_invoice_tracking>
77
+ <class>rocketuncle/observer</class>
78
+ <method>setTemplateInvoiceTracking</method>
79
+ </magebuzz_set_template_invoice_tracking>
80
+ </observers>
81
+ </core_block_abstract_to_html_before>
82
+ <adminhtml_block_html_before>
83
+ <observers>
84
+ <magebuzz_addmassaction_post_rocketshipment>
85
+ <class>rocketuncle/observer</class>
86
+ <method>addMassActionPostShipment</method>
87
+ </magebuzz_addmassaction_post_rocketshipment>
88
+ </observers>
89
+ </adminhtml_block_html_before>
90
+ </events>
91
+ <layout>
92
+ <updates>
93
+ <rocketuncle>
94
+ <file>rocketuncle.xml</file>
95
+ </rocketuncle>
96
+ </updates>
97
+ </layout>
98
+ <translate>
99
+ <modules>
100
+ <Magebuzz_Rocketuncle>
101
+ <files>
102
+ <default>Magebuzz_Rocketuncle.csv</default>
103
+ </files>
104
+ </Magebuzz_Rocketuncle>
105
+ </modules>
106
+ </translate>
107
+ </adminhtml>
108
+ <global>
109
+ <events>
110
+ <sales_order_shipment_save_after>
111
+ <observers>
112
+ <rocketuncle_sales_order_shipment_save_after>
113
+ <type>singleton</type>
114
+ <class>rocketuncle/observer</class>
115
+ <method>sendOrderJson</method>
116
+ </rocketuncle_sales_order_shipment_save_after>
117
+ </observers>
118
+ </sales_order_shipment_save_after>
119
+ <core_block_abstract_prepare_layout_before>
120
+ <observers>
121
+ <magebuzz_core_block_prepare_layout_before>
122
+ <type>model</type>
123
+ <class>rocketuncle/observer</class>
124
+ <method>addFieldRocketForOrderGrid</method>
125
+ </magebuzz_core_block_prepare_layout_before>
126
+ </observers>
127
+ </core_block_abstract_prepare_layout_before>
128
+ </events>
129
+ <models>
130
+ <rocketuncle>
131
+ <class>Magebuzz_Rocketuncle_Model</class>
132
+ <resourceModel>rocketuncle_mysql4</resourceModel>
133
+ </rocketuncle>
134
+ <rocketuncle_mysql4>
135
+ <class>Magebuzz_Rocketuncle_Model_Mysql4</class>
136
+ <entities>
137
+ <rocketuncle>
138
+ <table>rocketuncle</table>
139
+ </rocketuncle>
140
+ </entities>
141
+ </rocketuncle_mysql4>
142
+ </models>
143
+ <resources>
144
+ <rocketuncle_setup>
145
+ <setup>
146
+ <module>Magebuzz_Rocketuncle</module>
147
+ </setup>
148
+ <connection>
149
+ <use>core_setup</use>
150
+ </connection>
151
+ </rocketuncle_setup>
152
+ <rocketuncle_write>
153
+ <connection>
154
+ <use>core_write</use>
155
+ </connection>
156
+ </rocketuncle_write>
157
+ <rocketuncle_read>
158
+ <connection>
159
+ <use>core_read</use>
160
+ </connection>
161
+ </rocketuncle_read>
162
+ </resources>
163
+ <blocks>
164
+ <rocketuncle>
165
+ <class>Magebuzz_Rocketuncle_Block</class>
166
+ </rocketuncle>
167
+ </blocks>
168
+ <helpers>
169
+ <rocketuncle>
170
+ <class>Magebuzz_Rocketuncle_Helper</class>
171
+ </rocketuncle>
172
+ </helpers>
173
+ </global>
174
+ <default>
175
+ <rocketuncle>
176
+ <general>
177
+ <active>1</active>
178
+ <scope>order</scope>
179
+ <service>AFTERNOON</service>
180
+ <pickup_time>09:00</pickup_time>
181
+ </general>
182
+ </rocketuncle>
183
+ </default>
184
+ </config>
app/code/community/Magebuzz/Rocketuncle/etc/system.xml ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <magebuzz translate="label">
5
+ <label>MageBuzz Add-Ons</label>
6
+ <sort_order>200</sort_order>
7
+ </magebuzz>
8
+ </tabs>
9
+ <sections>
10
+ <rocketuncle translate="label" module="catalog">
11
+ <class>separator-top</class>
12
+ <label>RocketUncle</label>
13
+ <tab>magebuzz</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>100</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>0</show_in_store>
19
+ <groups>
20
+ <general translate="label">
21
+ <label>RocketUncle API</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>0</show_in_store>
27
+ <fields>
28
+ <active translate="label">
29
+ <label>Enable</label>
30
+ <frontend_type>select</frontend_type>
31
+ <sort_order>1</sort_order>
32
+ <source_model>adminhtml/system_config_source_yesno</source_model>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>0</show_in_store>
36
+ </active>
37
+ <client_id translate="label">
38
+ <label>Client ID</label>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>2</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>0</show_in_store>
44
+ </client_id>
45
+ <client_secret translate="label">
46
+ <label>Client Secret</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>3</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>0</show_in_store>
52
+ </client_secret>
53
+ <!--<scope translate="label">
54
+ <label>Scope</label>
55
+ <frontend_type>select</frontend_type>
56
+ <sort_order>4</sort_order>
57
+ <source_model>rocketuncle/system_config_scope</source_model>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>0</show_in_store>
61
+ </scope>-->
62
+
63
+ <service translate="label comment">
64
+ <label>Service Name</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>5</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>0</show_in_store>
70
+ <comment><![CDATA[2_HOURS | 3_HOURS | OFFICE_HOURS | EVENING | 2_WAY_OFFICE_HOURS. <a target="_blank" href="https://gofuture.rocketuncle.com/Bulk/AddBatch">Get your service name</a>]]></comment>
71
+ </service>
72
+
73
+ <pickup_time translate="label comment">
74
+ <label>Pickup Time</label>
75
+ <frontend_type>text</frontend_type>
76
+ <sort_order>6</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>0</show_in_store>
80
+ <comment><![CDATA[Format of Pickup Time is 24h <b>Example :</b> 09:00, 18:30 ]]></comment>
81
+ </pickup_time>
82
+
83
+ <access_token translate="label">
84
+ <label>Access Token</label>
85
+ <frontend_type>text</frontend_type>
86
+ <sort_order>4</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>0</show_in_store>
90
+ </access_token>
91
+ <get_access_token>
92
+ <frontend_type>button</frontend_type>
93
+ <frontend_model>rocketuncle/adminhtml_system_config_button</frontend_model>
94
+ <sort_order>5</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>0</show_in_store>
98
+ </get_access_token>
99
+ <weight_unit translate="label">
100
+ <label>Weight Unit</label>
101
+ <frontend_type>select</frontend_type>
102
+ <sort_order>7</sort_order>
103
+ <source_model>rocketuncle/system_config_weightunit</source_model>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>0</show_in_store>
107
+ </weight_unit>
108
+ <test_mode translate="label">
109
+ <label>Test Mode</label>
110
+ <frontend_type>select</frontend_type>
111
+ <sort_order>8</sort_order>
112
+ <source_model>adminhtml/system_config_source_yesno</source_model>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>0</show_in_store>
116
+ </test_mode>
117
+ </fields>
118
+ </general>
119
+ <sender translate="label">
120
+ <label>Sender Information</label>
121
+ <frontend_type>text</frontend_type>
122
+ <sort_order>1</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>0</show_in_store>
126
+ <fields>
127
+ <company_name translate="label">
128
+ <label>Company Name</label>
129
+ <frontend_type>text</frontend_type>
130
+ <sort_order>1</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>0</show_in_store>
134
+ </company_name>
135
+ <contact_name translate="label">
136
+ <label>Contact Name</label>
137
+ <frontend_type>text</frontend_type>
138
+ <sort_order>2</sort_order>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_website>1</show_in_website>
141
+ <show_in_store>0</show_in_store>
142
+ </contact_name>
143
+ <contact_number translate="label">
144
+ <label>Contact Number</label>
145
+ <frontend_type>text</frontend_type>
146
+ <sort_order>3</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
+ </contact_number>
151
+ <country_code translate="label">
152
+ <label>Country Code </label>
153
+ <frontend_type>text</frontend_type>
154
+ <sort_order>4</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
+ </country_code>
159
+ <postal_code translate="label">
160
+ <label>Postal Code </label>
161
+ <frontend_type>text</frontend_type>
162
+ <sort_order>5</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>1</show_in_website>
165
+ <show_in_store>0</show_in_store>
166
+ </postal_code>
167
+ <address_sender translate="label comment">
168
+ <label>Address</label>
169
+ <frontend_type>text</frontend_type>
170
+ <sort_order>6</sort_order>
171
+ <show_in_default>1</show_in_default>
172
+ <show_in_website>1</show_in_website>
173
+ <show_in_store>0</show_in_store>
174
+ </address_sender>
175
+ <address_sender2 translate="label comment">
176
+ <label>Address 2</label>
177
+ <frontend_type>text</frontend_type>
178
+ <sort_order>7</sort_order>
179
+ <show_in_default>1</show_in_default>
180
+ <show_in_website>1</show_in_website>
181
+ <show_in_store>0</show_in_store>
182
+ </address_sender2>
183
+ </fields>
184
+ </sender>
185
+ </groups>
186
+ </rocketuncle>
187
+ </sections>
188
+ </config>
app/code/community/Magebuzz/Rocketuncle/sql/rocketuncle_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $installer->run("
5
+ ALTER TABLE {$this->getTable('sales_flat_order')} ADD `rocketuncle_status` INT(11) NOT NULL DEFAULT '0';
6
+ ALTER TABLE {$this->getTable('sales_flat_order')} ADD `rocketuncle_information` TEXT NULL;
7
+ ");
8
+
9
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/rocketuncle.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category design
23
+ * @package default_default
24
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+
29
+ <layout>
30
+ <adminhtml_sales_order_view>
31
+ <reference name="order_tab_info">
32
+ <action method="setTemplate"><template>rocketuncle/sales/order/view/tab/info.phtml</template></action>
33
+ </reference>
34
+ </adminhtml_sales_order_view>
35
+ <adminhtml_sales_order_shipment_new>
36
+ <reference name="order_items">
37
+ <action method="setTemplate"><template>rocketuncle/sales/order/shipment/create/items.phtml</template></action>
38
+ </reference>
39
+ </adminhtml_sales_order_shipment_new>
40
+ </layout>
app/design/adminhtml/default/default/template/rocketuncle/sales/order/invoice/create/tracking.phtml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php /** @var $this Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Tracking */ ?>
28
+ <script type="text/javascript">
29
+ //<![CDATA[
30
+ var trackingControl;
31
+ trackingControl = {
32
+ index : 0,
33
+ add : function () {
34
+ this.index++;
35
+ var data = {index:this.index};
36
+ Element.insert($('track_row_container'), {bottom: this.template.evaluate(data)});
37
+ $('trackingC' + this.index).disabled = false;
38
+ $('trackingT' + this.index).disabled = false;
39
+ $('trackingN' + this.index).disabled = false;
40
+ this.bindCurrierOnchange();
41
+ },
42
+ deleteRow : function(event) {
43
+ var row = Event.findElement(event, 'tr');
44
+ if (row) {
45
+ row.parentNode.removeChild(row)
46
+ }
47
+ },
48
+ bindCurrierOnchange : function() {
49
+ var elems = $('tracking_numbers_table').select('.select');
50
+ elems.each(function (elem) {
51
+ if (!elem.onchangeBound) {
52
+ elem.onchangeBound = true;
53
+ elem.valueInput = $(elem.parentNode.parentNode).select('.number-title')[0];
54
+ elem.observe('change', this.currierOnchange);
55
+ }
56
+ }.bind(this));
57
+ },
58
+ currierOnchange : function(event) {
59
+ var elem = Event.element(event);
60
+ var option = elem.options[elem.selectedIndex];
61
+ if (option.value && option.value != 'custom') {
62
+ elem.valueInput.value = option.text;
63
+ }
64
+ else {
65
+ elem.valueInput.value = '';
66
+ }
67
+ }
68
+ }
69
+ //]]>
70
+ </script>
71
+ <div class="grid">
72
+ <p class="nm">
73
+ <label class="normal">Create delivery job in Rocket Uncle</label>
74
+ <input type="checkbox" value="1" id="rocket_shipment" name="invoice[rocket_shipment]">
75
+ </p>
76
+ <br/>
77
+ <table cellspacing="0" class="data" id="tracking_numbers_table">
78
+ <col width="100" />
79
+ <col />
80
+ <col />
81
+ <col width="80" />
82
+ <thead>
83
+ <tr class="headings">
84
+ <th><?php echo Mage::helper('sales')->__('Carrier') ?></th>
85
+ <th><?php echo Mage::helper('sales')->__('Title') ?></th>
86
+ <th><?php echo Mage::helper('sales')->__('Number') ?> <span class="required">*</span></th>
87
+ <th class="last"><?php echo Mage::helper('sales')->__('Action') ?></th>
88
+ </tr>
89
+ </thead>
90
+ <tfoot>
91
+ <tr>
92
+ <td colspan="4" class="a-center last" style="padding:8px;"><?php echo $this->getChildHtml('add_button') ?></td>
93
+ </tr>
94
+ </tfoot>
95
+ <tbody id="track_row_container">
96
+ <tr id="track_row_template" class="template no-display">
97
+ <td>
98
+ <select name="tracking[__index__][carrier_code]" id="trackingC__index__" class="select carrier" style="width:110px;" disabled="disabled">
99
+ <?php foreach ($this->getCarriers() as $_code=>$_name): ?>
100
+ <option value="<?php echo $_code ?>"><?php echo $this->escapeHtml($_name) ?></option>
101
+ <?php endforeach; ?>
102
+ </select>
103
+ </td>
104
+ <td><input class="input-text number-title" type="text" name="tracking[__index__][title]" id="trackingT__index__" value="" disabled="disabled" /></td>
105
+ <td><input class="input-text required-entry" type="text" name="tracking[__index__][number]" id="trackingN__index__" value="" disabled="disabled" /></td>
106
+ <td class="last"><a href="#" onclick="trackingControl.deleteRow(event);return false"><?php echo $this->__('Delete') ?></a></td>
107
+ </tr>
108
+ </tbody>
109
+ </table>
110
+ </div>
111
+ <script type="text/javascript">
112
+ //<![CDATA[
113
+ trackingControl.template = new Template('<tr>' + $('track_row_template').innerHTML.replace(/__index__/g, '#{index}') + '<\/tr>');
114
+ //]]>
115
+ </script>
app/design/adminhtml/default/default/template/rocketuncle/sales/order/shipment/create/items.phtml ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ ?>
4
+ <div class="grid np">
5
+ <div class="hor-scroll">
6
+ <table cellspacing="0" class="data order-tables">
7
+ <col />
8
+ <col width="1" />
9
+ <col width="1" />
10
+ <?php if (!$this->canShipPartiallyItem()): ?>
11
+ <col width="20" />
12
+ <?php endif; ?>
13
+ <thead>
14
+ <tr class="headings">
15
+ <th><?php echo $this->helper('sales')->__('Product') ?></th>
16
+ <th class="a-center"><?php echo $this->helper('sales')->__('Qty') ?></th>
17
+ <th<?php if ($this->isShipmentRegular()): ?> class="last"<?php endif; ?>><span class="nobr"><?php echo $this->helper('sales')->__('Qty to Ship') ?></span></th>
18
+
19
+ <?php if (!$this->canShipPartiallyItem()): ?>
20
+ <th class="a-center last"><span class="nobr"><?php echo $this->helper('sales')->__('Ship') ?></span></th>
21
+ <?php endif; ?>
22
+
23
+ </tr>
24
+ </thead>
25
+ <?php $_items = $this->getShipment()->getAllItems() ?>
26
+ <?php $_i=0;foreach ($_items as $_item): if ($_item->getOrderItem()->getIsVirtual() || $_item->getOrderItem()->getParentItem()): continue; endif; $_i++ ?>
27
+ <tbody class="<?php echo $_i%2?'odd':'even' ?>">
28
+ <?php echo $this->getItemHtml($_item) ?>
29
+ <?php echo $this->getItemExtraInfoHtml($_item->getOrderItem()) ?>
30
+ </tbody>
31
+ <?php endforeach; ?>
32
+ </table>
33
+ </div>
34
+ </div>
35
+ <br />
36
+ <div class="box-left entry-edit">
37
+ <div class="entry-edit-head"><h4><?php echo $this->__('Shipment Comments') ?></h4></div>
38
+ <fieldset>
39
+ <div id="order-history_form">
40
+ <span class="field-row">
41
+ <label class="normal" for="shipment_comment_text"><?php echo Mage::helper('sales')->__('Shipment Comments') ?></label>
42
+ <textarea id="shipment_comment_text" name="shipment[comment_text]" rows="3" cols="5" style="height:6em; width:99%;"><?php echo $this->getShipment()->getCommentText(); ?></textarea>
43
+ </span>
44
+ <div class="clear"></div>
45
+ </div>
46
+ </fieldset>
47
+ </div>
48
+
49
+ <div class="box-right entry-edit">
50
+ <div class="order-totals">
51
+ <div class="order-totals-bottom">
52
+ <?php if ($this->canCreateShippingLabel()): ?>
53
+ <p>
54
+ <label class="normal" for="create_shipping_label"><?php echo Mage::helper('sales')->__('Create Shipping Label') ?></label>
55
+ <input id="create_shipping_label" name="shipment[create_shipping_label]" value="1" type="checkbox" onclick="toggleCreateLabelCheckbox();" />
56
+ </p>
57
+ <?php endif ?>
58
+ <p>
59
+ <label class="normal" for="notify_customer"><?php echo Mage::helper('sales')->__('Append Comments') ?></label>
60
+ <input id="notify_customer" name="shipment[comment_customer_notify]" value="1" type="checkbox" />
61
+ </p>
62
+ <?php if ($this->canSendShipmentEmail()): ?>
63
+ <p>
64
+ <label class="normal" for="send_email"><?php echo Mage::helper('sales')->__('Email Copy of Shipment') ?></label>
65
+ <input id="send_email" name="shipment[send_email]" value="1" type="checkbox" />
66
+ </p>
67
+ <?php endif; ?>
68
+
69
+ <p>
70
+ <label class="normal" for="send_email"><?php echo Mage::helper('sales')->__('Create Delivery In RocketUncle') ?></label>
71
+ <input id="send_email" name="shipment[create_delivery_rocket]" value="1" type="checkbox" />
72
+ </p>
73
+
74
+ <div class="a-right">
75
+ <?php echo $this->getChildHtml('submit_button') ?>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ <div class="clear"></div>
81
+ <script type="text/javascript">
82
+ //<![CDATA[
83
+ var sendEmailCheckbox = $('send_email');
84
+ if (sendEmailCheckbox) {
85
+ var notifyCustomerCheckbox = $('notify_customer');
86
+ var shipmentCommentText = $('shipment_comment_text');
87
+ Event.observe(sendEmailCheckbox, 'change', bindSendEmail);
88
+ bindSendEmail();
89
+ }
90
+ function bindSendEmail() {
91
+ if (sendEmailCheckbox.checked == true) {
92
+ notifyCustomerCheckbox.disabled = false;
93
+ //shipmentCommentText.disabled = false;
94
+ }
95
+ else {
96
+ notifyCustomerCheckbox.disabled = true;
97
+ //shipmentCommentText.disabled = true;
98
+ }
99
+ }
100
+ function toggleCreateLabelCheckbox() {
101
+ var checkbox = $('create_shipping_label');
102
+ var submitButton = checkbox.up('.order-totals').select('.submit-button span')[0];
103
+ if (checkbox.checked) {
104
+ submitButton.innerText += '...';
105
+ } else {
106
+ submitButton.innerText = submitButton.innerText.replace(/\.\.\.$/, '');
107
+ }
108
+ }
109
+ function submitShipment(btn) {
110
+ var checkbox = $(btn).up('.order-totals').select('#create_shipping_label')[0];
111
+
112
+ if (!validQtyItems()) {
113
+ return;
114
+ }
115
+
116
+ if (checkbox && checkbox.checked) {
117
+ packaging.showWindow();
118
+ } else if(editForm.submit()) {
119
+ disableElements('submit-button');
120
+ }
121
+ }
122
+
123
+ function validQtyItems() {
124
+ var valid = true;
125
+ var errorMessage = '<?php echo $this->helper('sales')->__('Invalid value(s) for Qty to Ship') ?>';
126
+ $$('.qty-item').each(function(item) {
127
+ var val = parseFloat(item.value);
128
+ if (isNaN(val) || val < 0) {
129
+ valid = false;
130
+ alert(errorMessage);
131
+ throw $break;
132
+ }
133
+ });
134
+ return valid;
135
+ }
136
+ //]]>
137
+ </script>
app/design/adminhtml/default/default/template/rocketuncle/sales/order/view/tab/info.phtml ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php /** @var $this Mage_Adminhtml_Block_Sales_Order_View_Tab_Info */ ?>
28
+ <?php $_order = $this->getOrder() ?>
29
+ <div>
30
+ <div id="order-messages">
31
+ <?php echo $this->getChildHtml('order_messages') ?>
32
+ </div>
33
+ <?php echo $this->getChildHtml('order_info') ?>
34
+ <input type="hidden" name="order_id" value="<?php echo $_order->getId() ?>"/>
35
+ <?php if ($_order->getIsVirtual()): ?>
36
+ <div class="box-right">
37
+ <?php else: ?>
38
+ <div class="box-left">
39
+ <?php endif; ?>
40
+ <!--Payment Method-->
41
+ <div class="entry-edit">
42
+ <div class="entry-edit-head">
43
+ <h4 class="icon-head head-payment-method"><?php echo Mage::helper('sales')->__('Payment Information') ?></h4>
44
+ </div>
45
+ <fieldset>
46
+ <?php echo $this->getPaymentHtml() ?>
47
+ <div><?php echo Mage::helper('sales')->__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?></div>
48
+ </fieldset>
49
+ </div>
50
+ </div>
51
+
52
+ <?php if (!$_order->getIsVirtual()): ?>
53
+ <div class="box-right">
54
+ <!--Shipping Method-->
55
+ <div class="entry-edit">
56
+ <div class="entry-edit-head">
57
+ <h4 class="icon-head head-shipping-method"><?php echo Mage::helper('sales')->__('Shipping &amp; Handling Information') ?></h4>
58
+ </div>
59
+ <fieldset>
60
+ <?php if ($_order->getTracksCollection()->count()) : ?>
61
+ <a href="#" id="linkId" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')" title="<?php echo $this->__('Track Order') ?>"><?php echo $this->__('Track Order') ?></a>
62
+ <br/>
63
+ <?php endif; ?>
64
+ <?php if ($_order->getShippingDescription()): ?>
65
+ <strong><?php echo $this->escapeHtml($_order->getShippingDescription()) ?></strong>
66
+
67
+ <?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?>
68
+ <?php $_excl = $this->displayShippingPriceInclTax($_order); ?>
69
+ <?php else: ?>
70
+ <?php $_excl = $this->displayPriceAttribute('shipping_amount', false, ' '); ?>
71
+ <?php endif; ?>
72
+ <?php $_incl = $this->displayShippingPriceInclTax($_order); ?>
73
+
74
+ <?php echo $_excl; ?>
75
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
76
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
77
+ <?php endif; ?>
78
+ <?php else: ?>
79
+ <?php echo $this->helper('sales')->__('No shipping information available'); ?>
80
+ <?php endif; ?>
81
+ </fieldset>
82
+ </div>
83
+ </div>
84
+ <?php endif; ?>
85
+
86
+ <?php
87
+ /**
88
+ * START ADDITIONAL HTML for Community-Extension Biebersdorf_CustomerOrderComment.
89
+ * (Show the Customer-Comment for the Order)
90
+ */
91
+ ?>
92
+ <?php
93
+ echo $this->getChildHtml('customer_messages');
94
+ ?>
95
+ <?php
96
+ echo $this->getChildHtml('deliverydate');
97
+ ?>
98
+ <?php
99
+ /**
100
+ * END ADDITIONAL HTML for Community-Extension Biebersdorf_CustomerOrderComment.
101
+ * (Show the Customer-Comment for the Order)
102
+ */
103
+ ?>
104
+
105
+ <?php if(Mage::helper('rocketuncle')->enableRocketUncle() && $_order->getRocketuncleStatus() ==1):?>
106
+ <?php $uncle = json_decode($_order->getRocketuncleInformation());
107
+ $cost = $uncle->cost;
108
+ $receiver = $uncle->receiver;
109
+ $receiverLocation = $receiver->location;
110
+ ?>
111
+ <div class="clear"></div>
112
+ <div class="box-left">
113
+ <div class="entry-edit">
114
+ <div class="entry-edit-head">
115
+ <h4 class="icon-head head-payment-method"><?php echo Mage::helper('sales')->__('Rocket Uncle Information') ?></h4>
116
+ </div>
117
+ <fieldset>
118
+ Status :Success <br/>
119
+ TrackingNumber : <?php echo $uncle->trackingNumber;?> <br/>
120
+ Cost : <?php echo $cost->value.' '.$cost->currency;?> <br/>
121
+ Created At : <?php echo $uncle->pickupTime;?> <br/>
122
+ Services : <?php echo $uncle->service;?><br/>
123
+ </fieldset>
124
+ </div>
125
+ </div>
126
+ <div class="box-right">
127
+ <div class="entry-edit">
128
+ <div class="entry-edit-head">
129
+ <h4 class="icon-head head-shipping-method"><?php echo Mage::helper('sales')->__('Delivery Information') ?></h4>
130
+ </div>
131
+ <fieldset>
132
+ Deliver To : <?php echo $receiver-> contactName;?><br/>
133
+ <?php if ($receiver->companyName !=""):?>
134
+ Company : <?php echo $receiver->companyName;?> <br/>
135
+ <?php endif;?>
136
+ Phone Number : <?php echo $receiver->contactNumber;?><br/>
137
+ Location : <?php echo $receiverLocation->address;?><br/>
138
+ <?php echo $receiverLocation->postalCode .' '. $receiverLocation->countryCode;?> <br/>
139
+ Comment : <?php echo $uncle->comments;?><br/>
140
+ </fieldset>
141
+ </div>
142
+ </div>
143
+ <?php endif;?>
144
+
145
+
146
+ <div class="clear"></div>
147
+ <?php echo $this->getGiftOptionsHtml() ?>
148
+ <div class="clear"></div>
149
+ <div class="entry-edit">
150
+ <div class="entry-edit-head">
151
+ <h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('Items Ordered') ?></h4>
152
+ </div>
153
+ </div>
154
+ <?php echo $this->getItemsHtml() ?>
155
+ <div class="clear"></div>
156
+
157
+ <div class="box-left">
158
+ <div class="entry-edit">
159
+ <div class="entry-edit-head">
160
+ <h4><?php echo Mage::helper('sales')->__('Comments History') ?></h4>
161
+ </div>
162
+ <fieldset><?php echo $this->getChildHtml('order_history') ?></fieldset>
163
+ </div>
164
+ </div>
165
+ <div class="box-right entry-edit">
166
+ <div class="entry-edit-head"><h4><?php echo Mage::helper('sales')->__('Order Totals') ?></h4></div>
167
+ <div class="order-totals"><?php echo $this->getChildHtml('order_totals') ?></div>
168
+ </div>
169
+ <div class="clear"></div>
170
+ </div>
171
+
172
+ <?php echo $this->getChildHtml('popup_window');?>
173
+ <script type="text/javascript">
174
+ //<![CDATA[
175
+ /**
176
+ * Retrieve gift options tooltip content
177
+ */
178
+ function getGiftOptionsTooltipContent(itemId) {
179
+ var contentLines = [];
180
+ var headerLine = null;
181
+ var contentLine = null;
182
+
183
+ $$('#gift_options_data_' + itemId + ' .gift-options-tooltip-content').each(function (element) {
184
+ if (element.down(0)) {
185
+ headerLine = element.down(0).innerHTML;
186
+ contentLine = element.down(0).next().innerHTML;
187
+ if (contentLine.length > 30) {
188
+ contentLine = contentLine.slice(0,30) + '...';
189
+ }
190
+ contentLines.push(headerLine + ' ' + contentLine);
191
+ }
192
+ });
193
+ return contentLines.join('<br/>');
194
+ }
195
+ giftOptionsTooltip.setTooltipContentLoaderFunction(getGiftOptionsTooltipContent);
196
+ //]]>
197
+ </script>
app/design/adminhtml/default/default/template/rocketuncle/system/config/button.phtml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ //<![CDATA[
3
+ function check() {
4
+ new Ajax.Request('<?php echo $this->getAjaxCheckUrl() ?>', {
5
+ method: 'get',
6
+ onSuccess: function(transport){
7
+ if (transport.responseText){
8
+ var data = transport.responseText.evalJSON();
9
+ if (data.success) {
10
+ $('rocketuncle_general_access_token').value = data.access_token;
11
+ }
12
+ else {
13
+ alert('Cannot get access token, please check your info and try again!');
14
+ }
15
+ }
16
+ }
17
+ });
18
+ }
19
+ //]]>
20
+ </script>
21
+
22
+ <?php echo $this->getButtonHtml() ?>
app/etc/modules/Magebuzz_Rocketuncle.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magebuzz_Rocketuncle>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Magebuzz_Rocketuncle>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Magebuzz_RocketUncle</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Magento and Rocket Uncle Integration</summary>
10
+ <description>Connect Magento &amp; Rocket Uncle via API. Submit shipment from Magento to Rocket Uncle automatically. </description>
11
+ <notes>Rocket Uncle 0.1.0</notes>
12
+ <authors><author><name>Magebuzz</name><user>magebuzz</user><email>magebuzz@gmail.com</email></author></authors>
13
+ <date>2015-01-13</date>
14
+ <time>10:01:10</time>
15
+ <contents><target name="magecommunity"><dir name="Magebuzz"><dir name="Rocketuncle"><dir name="Block"><dir name="Adminhtml"><dir name="Order"><dir name="Grid"><dir name="Renderer"><file name="Rocketstatus.php" hash="09adf39e974dcaf6b3d52cda53b4ac46"/><dir name="Shipment"><file name="Rocketstatus.php" hash="9f92a97a202a4c43719ac97c19d053d6"/></dir></dir></dir></dir><dir name="System"><dir name="Config"><file name="Button.php" hash="0cfe8ba2359b711b4fc2ded38306270e"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="e1c0e0f3b8389ff967a47488ea8e3edf"/></dir><dir name="Model"><file name="Observer.php" hash="dc8eb8a48be86a5f49363f38f98a1ca0"/><dir name="System"><dir name="Config"><file name="Scope.php" hash="57e933fde62ddcb1abdd5fa99e16e6a8"/><file name="Weightunit.php" hash="2dfe23ba53834cf141a002aac55a14c0"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="RocketuncleController.php" hash="0538bcdc93637d5560b5dbcdb52b0d1a"/></dir><file name="IndexController.php" hash="5d51e90c6fa4d80a92a65919b44c9273"/></dir><dir name="etc"><file name="adminhtml.xml" hash="695906254593b405dacfe716b0184c8f"/><file name="config.xml" hash="7531b4d9e64e8d819b0e059888976a66"/><file name="system.xml" hash="b6cbf72bf7cea3b4110d01c3fedf513f"/></dir><dir name="sql"><dir name="rocketuncle_setup"><file name="mysql4-install-0.1.0.php" hash="f7047bcc5e1d2a602950a332d1d90055"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="rocketuncle.xml" hash="425ad6c3ca864c1dd42da8ed614ee7b0"/></dir><dir name="template"><dir name="rocketuncle"><dir name="sales"><dir name="order"><dir name="invoice"><dir name="create"><file name="tracking.phtml" hash="c6a09d974acdb57a19b4b46292169cf6"/></dir></dir><dir name="shipment"><dir name="create"><file name="items.phtml" hash="43918b4fd23bdb3021c674bd8637df7e"/></dir></dir><dir name="view"><dir name="tab"><file name="info.phtml" hash="7c8945fbcbe5bb09181a643401c6e164"/></dir></dir></dir></dir><dir name="system"><dir name="config"><file name="button.phtml" hash="1bcc3d760173d5f2dc01c680d2bf5789"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magebuzz_Rocketuncle.xml" hash="faf34a510f1918f2291b8e7a860af660"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>