fedex.php (13606B)
1 <?php 2 class ControllerExtensionShippingFedex extends Controller { 3 private $error = array(); 4 5 public function index() { 6 $this->load->language('extension/shipping/fedex'); 7 8 $this->document->setTitle($this->language->get('heading_title')); 9 10 $this->load->model('setting/setting'); 11 12 if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { 13 $this->model_setting_setting->editSetting('shipping_fedex', $this->request->post); 14 15 $this->session->data['success'] = $this->language->get('text_success'); 16 17 $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true)); 18 } 19 20 if (isset($this->error['warning'])) { 21 $data['error_warning'] = $this->error['warning']; 22 } else { 23 $data['error_warning'] = ''; 24 } 25 26 if (isset($this->error['key'])) { 27 $data['error_key'] = $this->error['key']; 28 } else { 29 $data['error_key'] = ''; 30 } 31 32 if (isset($this->error['password'])) { 33 $data['error_password'] = $this->error['password']; 34 } else { 35 $data['error_password'] = ''; 36 } 37 38 if (isset($this->error['account'])) { 39 $data['error_account'] = $this->error['account']; 40 } else { 41 $data['error_account'] = ''; 42 } 43 44 if (isset($this->error['meter'])) { 45 $data['error_meter'] = $this->error['meter']; 46 } else { 47 $data['error_meter'] = ''; 48 } 49 50 if (isset($this->error['postcode'])) { 51 $data['error_postcode'] = $this->error['postcode']; 52 } else { 53 $data['error_postcode'] = ''; 54 } 55 56 if (isset($this->error['dimension'])) { 57 $data['error_dimension'] = $this->error['dimension']; 58 } else { 59 $data['error_dimension'] = ''; 60 } 61 62 $data['breadcrumbs'] = array(); 63 64 $data['breadcrumbs'][] = array( 65 'text' => $this->language->get('text_home'), 66 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) 67 ); 68 69 $data['breadcrumbs'][] = array( 70 'text' => $this->language->get('text_extension'), 71 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true) 72 ); 73 74 $data['breadcrumbs'][] = array( 75 'text' => $this->language->get('heading_title'), 76 'href' => $this->url->link('extension/shipping/fedex', 'user_token=' . $this->session->data['user_token'], true) 77 ); 78 79 $data['action'] = $this->url->link('extension/shipping/fedex', 'user_token=' . $this->session->data['user_token'], true); 80 81 $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=shipping', true); 82 83 if (isset($this->request->post['shipping_fedex_key'])) { 84 $data['shipping_fedex_key'] = $this->request->post['shipping_fedex_key']; 85 } else { 86 $data['shipping_fedex_key'] = $this->config->get('shipping_fedex_key'); 87 } 88 89 if (isset($this->request->post['shipping_fedex_password'])) { 90 $data['shipping_fedex_password'] = $this->request->post['shipping_fedex_password']; 91 } else { 92 $data['shipping_fedex_password'] = $this->config->get('shipping_fedex_password'); 93 } 94 95 if (isset($this->request->post['shipping_fedex_account'])) { 96 $data['shipping_fedex_account'] = $this->request->post['shipping_fedex_account']; 97 } else { 98 $data['shipping_fedex_account'] = $this->config->get('shipping_fedex_account'); 99 } 100 101 if (isset($this->request->post['shipping_fedex_meter'])) { 102 $data['shipping_fedex_meter'] = $this->request->post['shipping_fedex_meter']; 103 } else { 104 $data['shipping_fedex_meter'] = $this->config->get('shipping_fedex_meter'); 105 } 106 107 if (isset($this->request->post['shipping_fedex_postcode'])) { 108 $data['shipping_fedex_postcode'] = $this->request->post['shipping_fedex_postcode']; 109 } else { 110 $data['shipping_fedex_postcode'] = $this->config->get('shipping_fedex_postcode'); 111 } 112 113 if (isset($this->request->post['shipping_fedex_test'])) { 114 $data['shipping_fedex_test'] = $this->request->post['shipping_fedex_test']; 115 } else { 116 $data['shipping_fedex_test'] = $this->config->get('shipping_fedex_test'); 117 } 118 119 if (isset($this->request->post['shipping_fedex_service'])) { 120 $data['shipping_fedex_service'] = $this->request->post['shipping_fedex_service']; 121 } elseif ($this->config->has('shipping_fedex_service')) { 122 $data['shipping_fedex_service'] = $this->config->get('shipping_fedex_service'); 123 } else { 124 $data['shipping_fedex_service'] = array(); 125 } 126 127 $data['services'] = array(); 128 129 $data['services'][] = array( 130 'text' => $this->language->get('text_europe_first_international_priority'), 131 'value' => 'EUROPE_FIRST_INTERNATIONAL_PRIORITY' 132 ); 133 134 $data['services'][] = array( 135 'text' => $this->language->get('text_fedex_1_day_freight'), 136 'value' => 'FEDEX_1_DAY_FREIGHT' 137 ); 138 139 $data['services'][] = array( 140 'text' => $this->language->get('text_fedex_2_day'), 141 'value' => 'FEDEX_2_DAY' 142 ); 143 144 $data['services'][] = array( 145 'text' => $this->language->get('text_fedex_2_day_am'), 146 'value' => 'FEDEX_2_DAY_AM' 147 ); 148 149 $data['services'][] = array( 150 'text' => $this->language->get('text_fedex_2_day_freight'), 151 'value' => 'FEDEX_2_DAY_FREIGHT' 152 ); 153 154 $data['services'][] = array( 155 'text' => $this->language->get('text_fedex_3_day_freight'), 156 'value' => 'FEDEX_3_DAY_FREIGHT' 157 ); 158 159 $data['services'][] = array( 160 'text' => $this->language->get('text_fedex_express_saver'), 161 'value' => 'FEDEX_EXPRESS_SAVER' 162 ); 163 164 $data['services'][] = array( 165 'text' => $this->language->get('text_fedex_first_freight'), 166 'value' => 'FEDEX_FIRST_FREIGHT' 167 ); 168 169 $data['services'][] = array( 170 'text' => $this->language->get('text_fedex_freight_economy'), 171 'value' => 'FEDEX_FREIGHT_ECONOMY' 172 ); 173 174 $data['services'][] = array( 175 'text' => $this->language->get('text_fedex_freight_priority'), 176 'value' => 'FEDEX_FREIGHT_PRIORITY' 177 ); 178 179 $data['services'][] = array( 180 'text' => $this->language->get('text_fedex_ground'), 181 'value' => 'FEDEX_GROUND' 182 ); 183 184 $data['services'][] = array( 185 'text' => $this->language->get('text_first_overnight'), 186 'value' => 'FIRST_OVERNIGHT' 187 ); 188 189 $data['services'][] = array( 190 'text' => $this->language->get('text_ground_home_delivery'), 191 'value' => 'GROUND_HOME_DELIVERY' 192 ); 193 194 $data['services'][] = array( 195 'text' => $this->language->get('text_international_economy'), 196 'value' => 'INTERNATIONAL_ECONOMY' 197 ); 198 199 $data['services'][] = array( 200 'text' => $this->language->get('text_international_economy_freight'), 201 'value' => 'INTERNATIONAL_ECONOMY_FREIGHT' 202 ); 203 204 $data['services'][] = array( 205 'text' => $this->language->get('text_international_first'), 206 'value' => 'INTERNATIONAL_FIRST' 207 ); 208 209 $data['services'][] = array( 210 'text' => $this->language->get('text_international_priority'), 211 'value' => 'INTERNATIONAL_PRIORITY' 212 ); 213 214 $data['services'][] = array( 215 'text' => $this->language->get('text_international_priority_freight'), 216 'value' => 'INTERNATIONAL_PRIORITY_FREIGHT' 217 ); 218 219 $data['services'][] = array( 220 'text' => $this->language->get('text_priority_overnight'), 221 'value' => 'PRIORITY_OVERNIGHT' 222 ); 223 224 $data['services'][] = array( 225 'text' => $this->language->get('text_smart_post'), 226 'value' => 'SMART_POST' 227 ); 228 229 $data['services'][] = array( 230 'text' => $this->language->get('text_standard_overnight'), 231 'value' => 'STANDARD_OVERNIGHT' 232 ); 233 234 if (isset($this->request->post['shipping_fedex_length'])) { 235 $data['shipping_fedex_length'] = $this->request->post['shipping_fedex_length']; 236 } else { 237 $data['shipping_fedex_length'] = $this->config->get('shipping_fedex_length'); 238 } 239 240 if (isset($this->request->post['shipping_fedex_width'])) { 241 $data['shipping_fedex_width'] = $this->request->post['shipping_fedex_width']; 242 } else { 243 $data['shipping_fedex_width'] = $this->config->get('shipping_fedex_width'); 244 } 245 246 if (isset($this->request->post['shipping_fedex_height'])) { 247 $data['shipping_fedex_height'] = $this->request->post['shipping_fedex_height']; 248 } else { 249 $data['shipping_fedex_height'] = $this->config->get('shipping_fedex_height'); 250 } 251 252 if (isset($this->request->post['shipping_fedex_length_class_id'])) { 253 $data['shipping_fedex_length_class_id'] = $this->request->post['shipping_fedex_length_class_id']; 254 } else { 255 $data['shipping_fedex_length_class_id'] = $this->config->get('shipping_fedex_length_class_id'); 256 } 257 258 $this->load->model('localisation/length_class'); 259 260 $data['length_classes'] = $this->model_localisation_length_class->getLengthClasses(); 261 262 if (isset($this->request->post['shipping_fedex_dropoff_type'])) { 263 $data['shipping_fedex_dropoff_type'] = $this->request->post['shipping_fedex_dropoff_type']; 264 } else { 265 $data['shipping_fedex_dropoff_type'] = $this->config->get('shipping_fedex_dropoff_type'); 266 } 267 268 if (isset($this->request->post['shipping_fedex_packaging_type'])) { 269 $data['shipping_fedex_packaging_type'] = $this->request->post['shipping_fedex_packaging_type']; 270 } else { 271 $data['shipping_fedex_packaging_type'] = $this->config->get('shipping_fedex_packaging_type'); 272 } 273 274 if (isset($this->request->post['shipping_fedex_rate_type'])) { 275 $data['shipping_fedex_rate_type'] = $this->request->post['shipping_fedex_rate_type']; 276 } else { 277 $data['shipping_fedex_rate_type'] = $this->config->get('shipping_fedex_rate_type'); 278 } 279 280 if (isset($this->request->post['shipping_fedex_destination_type'])) { 281 $data['shipping_fedex_destination_type'] = $this->request->post['shipping_fedex_destination_type']; 282 } else { 283 $data['shipping_fedex_destination_type'] = $this->config->get('shipping_fedex_destination_type'); 284 } 285 286 if (isset($this->request->post['shipping_fedex_display_time'])) { 287 $data['shipping_fedex_display_time'] = $this->request->post['shipping_fedex_display_time']; 288 } else { 289 $data['shipping_fedex_display_time'] = $this->config->get('shipping_fedex_display_time'); 290 } 291 292 if (isset($this->request->post['shipping_fedex_display_weight'])) { 293 $data['shipping_fedex_display_weight'] = $this->request->post['shipping_fedex_display_weight']; 294 } else { 295 $data['shipping_fedex_display_weight'] = $this->config->get('shipping_fedex_display_weight'); 296 } 297 298 if (isset($this->request->post['shipping_fedex_weight_class_id'])) { 299 $data['shipping_fedex_weight_class_id'] = $this->request->post['shipping_fedex_weight_class_id']; 300 } else { 301 $data['shipping_fedex_weight_class_id'] = $this->config->get('shipping_fedex_weight_class_id'); 302 } 303 304 $this->load->model('localisation/weight_class'); 305 306 $data['weight_classes'] = $this->model_localisation_weight_class->getWeightClasses(); 307 308 if (isset($this->request->post['shipping_fedex_tax_class_id'])) { 309 $data['shipping_fedex_tax_class_id'] = $this->request->post['shipping_fedex_tax_class_id']; 310 } else { 311 $data['shipping_fedex_tax_class_id'] = $this->config->get('shipping_fedex_tax_class_id'); 312 } 313 314 $this->load->model('localisation/tax_class'); 315 316 $data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses(); 317 318 if (isset($this->request->post['shipping_fedex_geo_zone_id'])) { 319 $data['shipping_fedex_geo_zone_id'] = $this->request->post['shipping_fedex_geo_zone_id']; 320 } else { 321 $data['shipping_fedex_geo_zone_id'] = $this->config->get('shipping_fedex_geo_zone_id'); 322 } 323 324 $this->load->model('localisation/geo_zone'); 325 326 $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); 327 328 if (isset($this->request->post['shipping_fedex_status'])) { 329 $data['shipping_fedex_status'] = $this->request->post['shipping_fedex_status']; 330 } else { 331 $data['shipping_fedex_status'] = $this->config->get('shipping_fedex_status'); 332 } 333 334 if (isset($this->request->post['shipping_fedex_sort_order'])) { 335 $data['shipping_fedex_sort_order'] = $this->request->post['shipping_fedex_sort_order']; 336 } else { 337 $data['shipping_fedex_sort_order'] = $this->config->get('shipping_fedex_sort_order'); 338 } 339 340 $data['header'] = $this->load->controller('common/header'); 341 $data['column_left'] = $this->load->controller('common/column_left'); 342 $data['footer'] = $this->load->controller('common/footer'); 343 344 $this->response->setOutput($this->load->view('extension/shipping/fedex', $data)); 345 } 346 347 protected function validate() { 348 if (!$this->user->hasPermission('modify', 'extension/shipping/fedex')) { 349 $this->error['warning'] = $this->language->get('error_permission'); 350 } 351 352 if (!$this->request->post['shipping_fedex_key']) { 353 $this->error['key'] = $this->language->get('error_key'); 354 } 355 356 if (!$this->request->post['shipping_fedex_password']) { 357 $this->error['password'] = $this->language->get('error_password'); 358 } 359 360 if (!$this->request->post['shipping_fedex_account']) { 361 $this->error['account'] = $this->language->get('error_account'); 362 } 363 364 if (!$this->request->post['shipping_fedex_meter']) { 365 $this->error['meter'] = $this->language->get('error_meter'); 366 } 367 368 if (!$this->request->post['shipping_fedex_postcode']) { 369 $this->error['postcode'] = $this->language->get('error_postcode'); 370 } 371 372 if (!$this->request->post['shipping_fedex_length'] || !$this->request->post['shipping_fedex_width'] || !$this->request->post['shipping_fedex_height']) { 373 $this->error['dimension'] = $this->language->get('error_dimension'); 374 } 375 376 return !$this->error; 377 } 378 }