Total Complexity | 209 |
Total Lines | 1818 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like ControllerSaleOrder often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ControllerSaleOrder, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
23 | class ControllerSaleOrder extends \Divine\Engine\Core\Controller |
||
|
|||
24 | { |
||
25 | private $error = array(); |
||
26 | |||
27 | public function index() |
||
28 | { |
||
29 | $this->load->language('sale/order'); |
||
30 | |||
31 | $this->document->setTitle($this->language->get('heading_title')); |
||
32 | |||
33 | $this->load->model('sale/order'); |
||
34 | |||
35 | $this->getList(); |
||
36 | } |
||
37 | |||
38 | public function add() |
||
39 | { |
||
40 | $this->load->language('sale/order'); |
||
41 | |||
42 | $this->document->setTitle($this->language->get('heading_title')); |
||
43 | |||
44 | $this->load->model('sale/order'); |
||
45 | |||
46 | $this->getForm(); |
||
47 | } |
||
48 | |||
49 | public function edit() |
||
50 | { |
||
51 | $this->load->language('sale/order'); |
||
52 | |||
53 | $this->document->setTitle($this->language->get('heading_title')); |
||
54 | |||
55 | $this->load->model('sale/order'); |
||
56 | |||
57 | $this->getForm(); |
||
58 | } |
||
59 | |||
60 | public function delete() |
||
61 | { |
||
62 | $this->load->language('sale/order'); |
||
63 | |||
64 | $this->document->setTitle($this->language->get('heading_title')); |
||
65 | |||
66 | $this->load->model('sale/order'); |
||
67 | |||
68 | if (isset($this->request->post['selected']) && $this->validate()) { |
||
69 | foreach ($this->request->post['selected'] as $order_id) { |
||
70 | $this->model_sale_order->deleteOrder($order_id); |
||
71 | } |
||
72 | |||
73 | $this->session->data['success'] = $this->language->get('text_success'); |
||
74 | |||
75 | $url = ''; |
||
76 | |||
77 | if (isset($this->request->get['filter_order_id'])) { |
||
78 | $url .= '&filter_order_id=' . $this->request->get['filter_order_id']; |
||
79 | } |
||
80 | |||
81 | if (isset($this->request->get['filter_customer'])) { |
||
82 | $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8')); |
||
83 | } |
||
84 | |||
85 | if (isset($this->request->get['filter_order_status'])) { |
||
86 | $url .= '&filter_order_status=' . $this->request->get['filter_order_status']; |
||
87 | } |
||
88 | |||
89 | if (isset($this->request->get['filter_total'])) { |
||
90 | $url .= '&filter_total=' . $this->request->get['filter_total']; |
||
91 | } |
||
92 | |||
93 | if (isset($this->request->get['filter_date_added'])) { |
||
94 | $url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
||
95 | } |
||
96 | |||
97 | if (isset($this->request->get['filter_date_modified'])) { |
||
98 | $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified']; |
||
99 | } |
||
100 | |||
101 | $this->response->redirect($this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, true)); |
||
102 | } |
||
103 | |||
104 | $this->getList(); |
||
105 | } |
||
106 | |||
107 | protected function getList() |
||
417 | } |
||
418 | |||
419 | public function getForm() |
||
420 | { |
||
421 | $data['heading_title'] = $this->language->get('heading_title'); |
||
422 | |||
423 | $data['text_form'] = !isset($this->request->get['order_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
||
424 | $data['text_no_results'] = $this->language->get('text_no_results'); |
||
425 | $data['text_default'] = $this->language->get('text_default'); |
||
426 | $data['text_select'] = $this->language->get('text_select'); |
||
427 | $data['text_none'] = $this->language->get('text_none'); |
||
428 | $data['text_loading'] = $this->language->get('text_loading'); |
||
429 | $data['text_ip_add'] = sprintf($this->language->get('text_ip_add'), $this->request->server['REMOTE_ADDR']); |
||
430 | $data['text_product'] = $this->language->get('text_product'); |
||
431 | $data['text_order_detail'] = $this->language->get('text_order_detail'); |
||
432 | |||
433 | $data['entry_customer'] = $this->language->get('entry_customer'); |
||
434 | $data['entry_customer_group'] = $this->language->get('entry_customer_group'); |
||
435 | $data['entry_firstname'] = $this->language->get('entry_firstname'); |
||
436 | $data['entry_lastname'] = $this->language->get('entry_lastname'); |
||
437 | $data['entry_email'] = $this->language->get('entry_email'); |
||
438 | $data['entry_telephone'] = $this->language->get('entry_telephone'); |
||
439 | $data['entry_fax'] = $this->language->get('entry_fax'); |
||
440 | $data['entry_comment'] = $this->language->get('entry_comment'); |
||
441 | $data['entry_address'] = $this->language->get('entry_address'); |
||
442 | $data['entry_company'] = $this->language->get('entry_company'); |
||
443 | $data['entry_address_1'] = $this->language->get('entry_address_1'); |
||
444 | $data['entry_address_2'] = $this->language->get('entry_address_2'); |
||
445 | $data['entry_city'] = $this->language->get('entry_city'); |
||
446 | $data['entry_postcode'] = $this->language->get('entry_postcode'); |
||
447 | $data['entry_zone'] = $this->language->get('entry_zone'); |
||
448 | $data['entry_zone_code'] = $this->language->get('entry_zone_code'); |
||
449 | $data['entry_country'] = $this->language->get('entry_country'); |
||
450 | $data['entry_product'] = $this->language->get('entry_product'); |
||
451 | $data['entry_option'] = $this->language->get('entry_option'); |
||
452 | $data['entry_quantity'] = $this->language->get('entry_quantity'); |
||
453 | $data['entry_to_name'] = $this->language->get('entry_to_name'); |
||
454 | $data['entry_to_email'] = $this->language->get('entry_to_email'); |
||
455 | $data['entry_from_name'] = $this->language->get('entry_from_name'); |
||
456 | $data['entry_from_email'] = $this->language->get('entry_from_email'); |
||
457 | $data['entry_theme'] = $this->language->get('entry_theme'); |
||
458 | $data['entry_message'] = $this->language->get('entry_message'); |
||
459 | $data['entry_amount'] = $this->language->get('entry_amount'); |
||
460 | $data['entry_currency'] = $this->language->get('entry_currency'); |
||
461 | $data['entry_shipping_method'] = $this->language->get('entry_shipping_method'); |
||
462 | $data['entry_payment_method'] = $this->language->get('entry_payment_method'); |
||
463 | $data['entry_reward'] = $this->language->get('entry_reward'); |
||
464 | $data['entry_order_status'] = $this->language->get('entry_order_status'); |
||
465 | |||
466 | $data['column_product'] = $this->language->get('column_product'); |
||
467 | $data['column_model'] = $this->language->get('column_model'); |
||
468 | $data['column_quantity'] = $this->language->get('column_quantity'); |
||
469 | $data['column_price'] = $this->language->get('column_price'); |
||
470 | $data['column_total'] = $this->language->get('column_total'); |
||
471 | $data['column_action'] = $this->language->get('column_action'); |
||
472 | |||
473 | $data['button_save'] = $this->language->get('button_save'); |
||
474 | $data['button_cancel'] = $this->language->get('button_cancel'); |
||
475 | $data['button_continue'] = $this->language->get('button_continue'); |
||
476 | $data['button_back'] = $this->language->get('button_back'); |
||
477 | $data['button_refresh'] = $this->language->get('button_refresh'); |
||
478 | $data['button_product_add'] = $this->language->get('button_product_add'); |
||
479 | $data['button_apply'] = $this->language->get('button_apply'); |
||
480 | $data['button_upload'] = $this->language->get('button_upload'); |
||
481 | $data['button_remove'] = $this->language->get('button_remove'); |
||
482 | $data['button_ip_add'] = $this->language->get('button_ip_add'); |
||
483 | |||
484 | $data['tab_order'] = $this->language->get('tab_order'); |
||
485 | $data['tab_customer'] = $this->language->get('tab_customer'); |
||
486 | $data['tab_payment'] = $this->language->get('tab_payment'); |
||
487 | $data['tab_shipping'] = $this->language->get('tab_shipping'); |
||
488 | $data['tab_product'] = $this->language->get('tab_product'); |
||
489 | $data['tab_total'] = $this->language->get('tab_total'); |
||
490 | |||
491 | $url = ''; |
||
492 | |||
493 | if (isset($this->request->get['filter_order_id'])) { |
||
494 | $url .= '&filter_order_id=' . $this->request->get['filter_order_id']; |
||
495 | } |
||
496 | |||
497 | if (isset($this->request->get['filter_customer'])) { |
||
498 | $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8')); |
||
499 | } |
||
500 | |||
501 | if (isset($this->request->get['filter_order_status'])) { |
||
502 | $url .= '&filter_order_status=' . $this->request->get['filter_order_status']; |
||
503 | } |
||
504 | |||
505 | if (isset($this->request->get['filter_total'])) { |
||
506 | $url .= '&filter_total=' . $this->request->get['filter_total']; |
||
507 | } |
||
508 | |||
509 | if (isset($this->request->get['filter_date_added'])) { |
||
510 | $url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
||
511 | } |
||
512 | |||
513 | if (isset($this->request->get['filter_date_modified'])) { |
||
514 | $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified']; |
||
515 | } |
||
516 | |||
517 | if (isset($this->request->get['sort'])) { |
||
518 | $url .= '&sort=' . $this->request->get['sort']; |
||
519 | } |
||
520 | |||
521 | if (isset($this->request->get['order'])) { |
||
522 | $url .= '&order=' . $this->request->get['order']; |
||
523 | } |
||
524 | |||
525 | if (isset($this->request->get['page'])) { |
||
526 | $url .= '&page=' . $this->request->get['page']; |
||
527 | } |
||
528 | |||
529 | $data['breadcrumbs'] = array(); |
||
530 | |||
531 | $data['breadcrumbs'][] = array( |
||
532 | 'text' => $this->language->get('text_home'), |
||
533 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
534 | ); |
||
535 | |||
536 | $data['breadcrumbs'][] = array( |
||
537 | 'text' => $this->language->get('heading_title'), |
||
538 | 'href' => $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, true) |
||
539 | ); |
||
540 | |||
541 | $data['cancel'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, true); |
||
542 | |||
543 | $data['token'] = $this->session->data['token']; |
||
544 | |||
545 | if (isset($this->request->get['order_id'])) { |
||
546 | $order_info = $this->model_sale_order->getOrder($this->request->get['order_id']); |
||
547 | } |
||
548 | |||
549 | if (!empty($order_info)) { |
||
550 | $data['order_id'] = $this->request->get['order_id']; |
||
551 | $data['store_url'] = '/'; |
||
552 | |||
553 | $data['customer'] = $order_info['customer']; |
||
554 | $data['customer_id'] = $order_info['customer_id']; |
||
555 | $data['customer_group_id'] = $order_info['customer_group_id']; |
||
556 | $data['firstname'] = $order_info['firstname']; |
||
557 | $data['lastname'] = $order_info['lastname']; |
||
558 | $data['email'] = $order_info['email']; |
||
559 | $data['telephone'] = $order_info['telephone']; |
||
560 | $data['fax'] = $order_info['fax']; |
||
561 | $data['account_custom_field'] = $order_info['custom_field']; |
||
562 | |||
563 | $this->load->model('customer/customer'); |
||
564 | |||
565 | $data['addresses'] = $this->model_customer_customer->getAddresses($order_info['customer_id']); |
||
566 | |||
567 | $data['payment_firstname'] = $order_info['payment_firstname']; |
||
568 | $data['payment_lastname'] = $order_info['payment_lastname']; |
||
569 | $data['payment_company'] = $order_info['payment_company']; |
||
570 | $data['payment_address_1'] = $order_info['payment_address_1']; |
||
571 | $data['payment_address_2'] = $order_info['payment_address_2']; |
||
572 | $data['payment_city'] = $order_info['payment_city']; |
||
573 | $data['payment_postcode'] = $order_info['payment_postcode']; |
||
574 | $data['payment_country_id'] = $order_info['payment_country_id']; |
||
575 | $data['payment_zone_id'] = $order_info['payment_zone_id']; |
||
576 | $data['payment_custom_field'] = $order_info['payment_custom_field']; |
||
577 | $data['payment_method'] = $order_info['payment_method']; |
||
578 | $data['payment_code'] = $order_info['payment_code']; |
||
579 | |||
580 | $data['shipping_firstname'] = $order_info['shipping_firstname']; |
||
581 | $data['shipping_lastname'] = $order_info['shipping_lastname']; |
||
582 | $data['shipping_company'] = $order_info['shipping_company']; |
||
583 | $data['shipping_address_1'] = $order_info['shipping_address_1']; |
||
584 | $data['shipping_address_2'] = $order_info['shipping_address_2']; |
||
585 | $data['shipping_city'] = $order_info['shipping_city']; |
||
586 | $data['shipping_postcode'] = $order_info['shipping_postcode']; |
||
587 | $data['shipping_country_id'] = $order_info['shipping_country_id']; |
||
588 | $data['shipping_zone_id'] = $order_info['shipping_zone_id']; |
||
589 | $data['shipping_custom_field'] = $order_info['shipping_custom_field']; |
||
590 | $data['shipping_method'] = $order_info['shipping_method']; |
||
591 | $data['shipping_code'] = $order_info['shipping_code']; |
||
592 | |||
593 | // Products |
||
594 | $data['order_products'] = array(); |
||
595 | |||
596 | $products = $this->model_sale_order->getOrderProducts($this->request->get['order_id']); |
||
597 | |||
598 | foreach ($products as $product) { |
||
599 | $data['order_products'][] = array( |
||
600 | 'product_id' => $product['product_id'], |
||
601 | 'name' => $product['name'], |
||
602 | 'model' => $product['model'], |
||
603 | 'option' => $this->model_sale_order->getOrderOptions($this->request->get['order_id'], $product['order_product_id']), |
||
604 | 'quantity' => $product['quantity'], |
||
605 | 'price' => $product['price'], |
||
606 | 'total' => $product['total'], |
||
607 | 'reward' => $product['reward'] |
||
608 | ); |
||
609 | } |
||
610 | |||
611 | $data['reward'] = ''; |
||
612 | |||
613 | $data['order_totals'] = array(); |
||
614 | |||
615 | $order_totals = $this->model_sale_order->getOrderTotals($this->request->get['order_id']); |
||
616 | |||
617 | foreach ($order_totals as $order_total) { |
||
618 | // If reward points |
||
619 | $start = strpos($order_total['title'], '(') + 1; |
||
620 | $end = strrpos($order_total['title'], ')'); |
||
621 | |||
622 | if ($start && $end) { |
||
623 | $data[$order_total['code']] = substr($order_total['title'], $start, $end - $start); |
||
624 | } |
||
625 | } |
||
626 | |||
627 | $data['order_status_id'] = $order_info['order_status_id']; |
||
628 | $data['comment'] = $order_info['comment']; |
||
629 | $data['currency_code'] = $order_info['currency_code']; |
||
630 | } else { |
||
631 | $data['order_id'] = 0; |
||
632 | $data['store_url'] = '/'; |
||
633 | |||
634 | $data['customer'] = ''; |
||
635 | $data['customer_id'] = ''; |
||
636 | $data['customer_group_id'] = $this->config->get('config_customer_group_id'); |
||
637 | $data['firstname'] = ''; |
||
638 | $data['lastname'] = ''; |
||
639 | $data['email'] = ''; |
||
640 | $data['telephone'] = ''; |
||
641 | $data['fax'] = ''; |
||
642 | $data['customer_custom_field'] = array(); |
||
643 | |||
644 | $data['addresses'] = array(); |
||
645 | |||
646 | $data['payment_firstname'] = ''; |
||
647 | $data['payment_lastname'] = ''; |
||
648 | $data['payment_company'] = ''; |
||
649 | $data['payment_address_1'] = ''; |
||
650 | $data['payment_address_2'] = ''; |
||
651 | $data['payment_city'] = ''; |
||
652 | $data['payment_postcode'] = ''; |
||
653 | $data['payment_country_id'] = ''; |
||
654 | $data['payment_zone_id'] = ''; |
||
655 | $data['payment_custom_field'] = array(); |
||
656 | $data['payment_method'] = ''; |
||
657 | $data['payment_code'] = ''; |
||
658 | |||
659 | $data['shipping_firstname'] = ''; |
||
660 | $data['shipping_lastname'] = ''; |
||
661 | $data['shipping_company'] = ''; |
||
662 | $data['shipping_address_1'] = ''; |
||
663 | $data['shipping_address_2'] = ''; |
||
664 | $data['shipping_city'] = ''; |
||
665 | $data['shipping_postcode'] = ''; |
||
666 | $data['shipping_country_id'] = ''; |
||
667 | $data['shipping_zone_id'] = ''; |
||
668 | $data['shipping_custom_field'] = array(); |
||
669 | $data['shipping_method'] = ''; |
||
670 | $data['shipping_code'] = ''; |
||
671 | |||
672 | $data['order_products'] = array(); |
||
673 | $data['order_totals'] = array(); |
||
674 | |||
675 | $data['order_status_id'] = $this->config->get('config_order_status_id'); |
||
676 | $data['comment'] = ''; |
||
677 | $data['currency_code'] = $this->config->get('config_currency'); |
||
678 | |||
679 | $data['reward'] = ''; |
||
680 | } |
||
681 | |||
682 | // Customer Groups |
||
683 | $this->load->model('customer/customer_group'); |
||
684 | |||
685 | $data['customer_groups'] = $this->model_customer_customer_group->getCustomerGroups(); |
||
686 | |||
687 | // Custom Fields |
||
688 | $this->load->model('customer/custom_field'); |
||
689 | |||
690 | $data['custom_fields'] = array(); |
||
691 | |||
692 | $filter_data = array( |
||
693 | 'sort' => 'cf.sort_order', |
||
694 | 'order' => 'ASC' |
||
695 | ); |
||
696 | |||
697 | $custom_fields = $this->model_customer_custom_field->getCustomFields($filter_data); |
||
698 | |||
699 | foreach ($custom_fields as $custom_field) { |
||
700 | $data['custom_fields'][] = array( |
||
701 | 'custom_field_id' => $custom_field['custom_field_id'], |
||
702 | 'custom_field_value' => $this->model_customer_custom_field->getCustomFieldValues($custom_field['custom_field_id']), |
||
703 | 'name' => $custom_field['name'], |
||
704 | 'value' => $custom_field['value'], |
||
705 | 'type' => $custom_field['type'], |
||
706 | 'location' => $custom_field['location'], |
||
707 | 'sort_order' => $custom_field['sort_order'] |
||
708 | ); |
||
709 | } |
||
710 | |||
711 | $this->load->model('localisation/order_status'); |
||
712 | |||
713 | $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); |
||
714 | |||
715 | $this->load->model('localisation/country'); |
||
716 | |||
717 | $data['countries'] = $this->model_localisation_country->getCountries(); |
||
718 | |||
719 | $this->load->model('localisation/currency'); |
||
720 | |||
721 | $data['currencies'] = $this->model_localisation_currency->getCurrencies(); |
||
722 | |||
723 | $data['header'] = $this->load->controller('common/header'); |
||
724 | $data['column'] = $this->load->controller('common/column_left'); |
||
725 | $data['footer'] = $this->load->controller('common/footer'); |
||
726 | |||
727 | $this->response->setOutput($this->load->view('sale/order_form', $data)); |
||
728 | } |
||
729 | |||
730 | public function info() |
||
731 | { |
||
732 | $this->load->model('sale/order'); |
||
733 | |||
734 | if (isset($this->request->get['order_id'])) { |
||
735 | $order_id = $this->request->get['order_id']; |
||
736 | } else { |
||
737 | $order_id = 0; |
||
738 | } |
||
739 | |||
740 | $order_info = $this->model_sale_order->getOrder($order_id); |
||
741 | |||
742 | if ($order_info) { |
||
743 | $this->load->language('sale/order'); |
||
744 | |||
745 | $this->document->setTitle($this->language->get('heading_title')); |
||
746 | |||
747 | $data['heading_title'] = $this->language->get('heading_title'); |
||
748 | |||
749 | $data['text_ip_add'] = sprintf($this->language->get('text_ip_add'), $this->request->server['REMOTE_ADDR']); |
||
750 | $data['text_order_detail'] = $this->language->get('text_order_detail'); |
||
751 | $data['text_customer_detail'] = $this->language->get('text_customer_detail'); |
||
752 | $data['text_option'] = $this->language->get('text_option'); |
||
753 | $data['text_store'] = $this->language->get('text_store'); |
||
754 | $data['text_date_added'] = $this->language->get('text_date_added'); |
||
755 | $data['text_payment_method'] = $this->language->get('text_payment_method'); |
||
756 | $data['text_shipping_method'] = $this->language->get('text_shipping_method'); |
||
757 | $data['text_customer'] = $this->language->get('text_customer'); |
||
758 | $data['text_customer_group'] = $this->language->get('text_customer_group'); |
||
759 | $data['text_email'] = $this->language->get('text_email'); |
||
760 | $data['text_telephone'] = $this->language->get('text_telephone'); |
||
761 | $data['text_invoice'] = $this->language->get('text_invoice'); |
||
762 | $data['text_reward'] = $this->language->get('text_reward'); |
||
763 | $data['text_order'] = sprintf($this->language->get('text_order'), $this->request->get['order_id']); |
||
764 | $data['text_payment_address'] = $this->language->get('text_payment_address'); |
||
765 | $data['text_shipping_address'] = $this->language->get('text_shipping_address'); |
||
766 | $data['text_comment'] = $this->language->get('text_comment'); |
||
767 | $data['text_account_custom_field'] = $this->language->get('text_account_custom_field'); |
||
768 | $data['text_payment_custom_field'] = $this->language->get('text_payment_custom_field'); |
||
769 | $data['text_shipping_custom_field'] = $this->language->get('text_shipping_custom_field'); |
||
770 | $data['text_browser'] = $this->language->get('text_browser'); |
||
771 | $data['text_ip'] = $this->language->get('text_ip'); |
||
772 | $data['text_forwarded_ip'] = $this->language->get('text_forwarded_ip'); |
||
773 | $data['text_user_agent'] = $this->language->get('text_user_agent'); |
||
774 | $data['text_accept_language'] = $this->language->get('text_accept_language'); |
||
775 | $data['text_history'] = $this->language->get('text_history'); |
||
776 | $data['text_history_add'] = $this->language->get('text_history_add'); |
||
777 | $data['text_loading'] = $this->language->get('text_loading'); |
||
778 | |||
779 | $data['column_product'] = $this->language->get('column_product'); |
||
780 | $data['column_model'] = $this->language->get('column_model'); |
||
781 | $data['column_quantity'] = $this->language->get('column_quantity'); |
||
782 | $data['column_price'] = $this->language->get('column_price'); |
||
783 | $data['column_total'] = $this->language->get('column_total'); |
||
784 | |||
785 | $data['entry_order_status'] = $this->language->get('entry_order_status'); |
||
786 | $data['entry_notify'] = $this->language->get('entry_notify'); |
||
787 | $data['entry_override'] = $this->language->get('entry_override'); |
||
788 | $data['entry_comment'] = $this->language->get('entry_comment'); |
||
789 | |||
790 | $data['help_override'] = $this->language->get('help_override'); |
||
791 | |||
792 | $data['button_invoice_print'] = $this->language->get('button_invoice_print'); |
||
793 | $data['button_shipping_print'] = $this->language->get('button_shipping_print'); |
||
794 | $data['button_edit'] = $this->language->get('button_edit'); |
||
795 | $data['button_cancel'] = $this->language->get('button_cancel'); |
||
796 | $data['button_generate'] = $this->language->get('button_generate'); |
||
797 | $data['button_reward_add'] = $this->language->get('button_reward_add'); |
||
798 | $data['button_reward_remove'] = $this->language->get('button_reward_remove'); |
||
799 | $data['button_commission_add'] = $this->language->get('button_commission_add'); |
||
800 | $data['button_commission_remove'] = $this->language->get('button_commission_remove'); |
||
801 | $data['button_history_add'] = $this->language->get('button_history_add'); |
||
802 | $data['button_ip_add'] = $this->language->get('button_ip_add'); |
||
803 | |||
804 | $data['tab_history'] = $this->language->get('tab_history'); |
||
805 | $data['tab_additional'] = $this->language->get('tab_additional'); |
||
806 | |||
807 | $url = ''; |
||
808 | |||
809 | if (isset($this->request->get['filter_order_id'])) { |
||
810 | $url .= '&filter_order_id=' . $this->request->get['filter_order_id']; |
||
811 | } |
||
812 | |||
813 | if (isset($this->request->get['filter_customer'])) { |
||
814 | $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8')); |
||
815 | } |
||
816 | |||
817 | if (isset($this->request->get['filter_order_status'])) { |
||
818 | $url .= '&filter_order_status=' . $this->request->get['filter_order_status']; |
||
819 | } |
||
820 | |||
821 | if (isset($this->request->get['filter_total'])) { |
||
822 | $url .= '&filter_total=' . $this->request->get['filter_total']; |
||
823 | } |
||
824 | |||
825 | if (isset($this->request->get['filter_date_added'])) { |
||
826 | $url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
||
827 | } |
||
828 | |||
829 | if (isset($this->request->get['filter_date_modified'])) { |
||
830 | $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified']; |
||
831 | } |
||
832 | |||
833 | if (isset($this->request->get['sort'])) { |
||
834 | $url .= '&sort=' . $this->request->get['sort']; |
||
835 | } |
||
836 | |||
837 | if (isset($this->request->get['order'])) { |
||
838 | $url .= '&order=' . $this->request->get['order']; |
||
839 | } |
||
840 | |||
841 | if (isset($this->request->get['page'])) { |
||
842 | $url .= '&page=' . $this->request->get['page']; |
||
843 | } |
||
844 | |||
845 | $data['breadcrumbs'] = array(); |
||
846 | |||
847 | $data['breadcrumbs'][] = array( |
||
848 | 'text' => $this->language->get('text_home'), |
||
849 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
850 | ); |
||
851 | |||
852 | $data['breadcrumbs'][] = array( |
||
853 | 'text' => $this->language->get('heading_title'), |
||
854 | 'href' => $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, true) |
||
855 | ); |
||
856 | |||
857 | $data['shipping'] = $this->url->link('sale/order/shipping', 'token=' . $this->session->data['token'] . '&order_id=' . (int)$this->request->get['order_id'], true); |
||
858 | $data['invoice'] = $this->url->link('sale/order/invoice', 'token=' . $this->session->data['token'] . '&order_id=' . (int)$this->request->get['order_id'], true); |
||
859 | $data['edit'] = $this->url->link('sale/order/edit', 'token=' . $this->session->data['token'] . '&order_id=' . (int)$this->request->get['order_id'], true); |
||
860 | $data['cancel'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, true); |
||
861 | |||
862 | $data['token'] = $this->session->data['token']; |
||
863 | |||
864 | $data['order_id'] = $this->request->get['order_id']; |
||
865 | |||
866 | $data['store_name'] = $order_info['store_name']; |
||
867 | $data['store_url'] = '/'; |
||
868 | |||
869 | if ($order_info['invoice_no']) { |
||
870 | $data['invoice_no'] = $order_info['invoice_prefix'] . $order_info['invoice_no']; |
||
871 | } else { |
||
872 | $data['invoice_no'] = ''; |
||
873 | } |
||
874 | |||
875 | $data['date_added'] = date($this->language->get('date_format_short'), strtotime($order_info['date_added'])); |
||
876 | |||
877 | $data['firstname'] = $order_info['firstname']; |
||
878 | $data['lastname'] = $order_info['lastname']; |
||
879 | |||
880 | if ($order_info['customer_id']) { |
||
881 | $data['customer'] = $this->url->link('customer/customer/edit', 'token=' . $this->session->data['token'] . '&customer_id=' . $order_info['customer_id'], true); |
||
882 | } else { |
||
883 | $data['customer'] = ''; |
||
884 | } |
||
885 | |||
886 | $this->load->model('customer/customer_group'); |
||
887 | |||
888 | $customer_group_info = $this->model_customer_customer_group->getCustomerGroup($order_info['customer_group_id']); |
||
889 | |||
890 | if ($customer_group_info) { |
||
891 | $data['customer_group'] = $customer_group_info['name']; |
||
892 | } else { |
||
893 | $data['customer_group'] = ''; |
||
894 | } |
||
895 | |||
896 | $data['email'] = $order_info['email']; |
||
897 | $data['telephone'] = $order_info['telephone']; |
||
898 | |||
899 | $data['shipping_method'] = $order_info['shipping_method']; |
||
900 | $data['payment_method'] = $order_info['payment_method']; |
||
901 | |||
902 | // Payment Address |
||
903 | if ($order_info['payment_address_format']) { |
||
904 | $format = $order_info['payment_address_format']; |
||
905 | } else { |
||
906 | $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; |
||
907 | } |
||
908 | |||
909 | $find = array( |
||
910 | '{firstname}', |
||
911 | '{lastname}', |
||
912 | '{company}', |
||
913 | '{address_1}', |
||
914 | '{address_2}', |
||
915 | '{city}', |
||
916 | '{postcode}', |
||
917 | '{zone}', |
||
918 | '{zone_code}', |
||
919 | '{country}' |
||
920 | ); |
||
921 | |||
922 | $replace = array( |
||
923 | 'firstname' => $order_info['payment_firstname'], |
||
924 | 'lastname' => $order_info['payment_lastname'], |
||
925 | 'company' => $order_info['payment_company'], |
||
926 | 'address_1' => $order_info['payment_address_1'], |
||
927 | 'address_2' => $order_info['payment_address_2'], |
||
928 | 'city' => $order_info['payment_city'], |
||
929 | 'postcode' => $order_info['payment_postcode'], |
||
930 | 'zone' => $order_info['payment_zone'], |
||
931 | 'zone_code' => $order_info['payment_zone_code'], |
||
932 | 'country' => $order_info['payment_country'] |
||
933 | ); |
||
934 | |||
935 | $data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); |
||
936 | |||
937 | // Shipping Address |
||
938 | if ($order_info['shipping_address_format']) { |
||
939 | $format = $order_info['shipping_address_format']; |
||
940 | } else { |
||
941 | $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; |
||
942 | } |
||
943 | |||
944 | $find = array( |
||
945 | '{firstname}', |
||
946 | '{lastname}', |
||
947 | '{company}', |
||
948 | '{address_1}', |
||
949 | '{address_2}', |
||
950 | '{city}', |
||
951 | '{postcode}', |
||
952 | '{zone}', |
||
953 | '{zone_code}', |
||
954 | '{country}' |
||
955 | ); |
||
956 | |||
957 | $replace = array( |
||
958 | 'firstname' => $order_info['shipping_firstname'], |
||
959 | 'lastname' => $order_info['shipping_lastname'], |
||
960 | 'company' => $order_info['shipping_company'], |
||
961 | 'address_1' => $order_info['shipping_address_1'], |
||
962 | 'address_2' => $order_info['shipping_address_2'], |
||
963 | 'city' => $order_info['shipping_city'], |
||
964 | 'postcode' => $order_info['shipping_postcode'], |
||
965 | 'zone' => $order_info['shipping_zone'], |
||
966 | 'zone_code' => $order_info['shipping_zone_code'], |
||
967 | 'country' => $order_info['shipping_country'] |
||
968 | ); |
||
969 | |||
970 | $data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); |
||
971 | |||
972 | // Uploaded files |
||
973 | $this->load->model('tool/upload'); |
||
974 | |||
975 | $data['products'] = array(); |
||
976 | |||
977 | $products = $this->model_sale_order->getOrderProducts($this->request->get['order_id']); |
||
978 | |||
979 | foreach ($products as $product) { |
||
980 | $option_data = array(); |
||
981 | |||
982 | $options = $this->model_sale_order->getOrderOptions($this->request->get['order_id'], $product['order_product_id']); |
||
983 | |||
984 | foreach ($options as $option) { |
||
985 | if ($option['type'] != 'file') { |
||
986 | $option_data[] = array( |
||
987 | 'name' => $option['name'], |
||
988 | 'value' => $option['value'], |
||
989 | 'type' => $option['type'] |
||
990 | ); |
||
991 | } else { |
||
992 | $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); |
||
993 | |||
994 | if ($upload_info) { |
||
995 | $option_data[] = array( |
||
996 | 'name' => $option['name'], |
||
997 | 'value' => $upload_info['name'], |
||
998 | 'type' => $option['type'], |
||
999 | 'href' => $this->url->link('tool/upload/download', 'token=' . $this->session->data['token'] . '&code=' . $upload_info['code'], true) |
||
1000 | ); |
||
1001 | } |
||
1002 | } |
||
1003 | } |
||
1004 | |||
1005 | $data['products'][] = array( |
||
1006 | 'order_product_id' => $product['order_product_id'], |
||
1007 | 'product_id' => $product['product_id'], |
||
1008 | 'name' => $product['name'], |
||
1009 | 'model' => $product['model'], |
||
1010 | 'option' => $option_data, |
||
1011 | 'quantity' => $product['quantity'], |
||
1012 | 'price' => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']), |
||
1013 | 'total' => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value']), |
||
1014 | 'href' => $this->url->link('catalog/product/edit', 'token=' . $this->session->data['token'] . '&product_id=' . $product['product_id'], true) |
||
1015 | ); |
||
1016 | } |
||
1017 | |||
1018 | $data['totals'] = array(); |
||
1019 | |||
1020 | $totals = $this->model_sale_order->getOrderTotals($this->request->get['order_id']); |
||
1021 | |||
1022 | foreach ($totals as $total) { |
||
1023 | $data['totals'][] = array( |
||
1024 | 'title' => $total['title'], |
||
1025 | 'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']) |
||
1026 | ); |
||
1027 | } |
||
1028 | |||
1029 | $data['comment'] = nl2br($order_info['comment']); |
||
1030 | |||
1031 | $this->load->model('customer/customer'); |
||
1032 | |||
1033 | $data['reward'] = $order_info['reward']; |
||
1034 | |||
1035 | $data['reward_total'] = $this->model_customer_customer->getTotalCustomerRewardsByOrderId($this->request->get['order_id']); |
||
1036 | |||
1037 | $data['commission'] = $this->currency->format($order_info['commission'], $order_info['currency_code'], $order_info['currency_value']); |
||
1038 | |||
1039 | $this->load->model('localisation/order_status'); |
||
1040 | |||
1041 | $order_status_info = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id']); |
||
1042 | |||
1043 | if ($order_status_info) { |
||
1044 | $data['order_status'] = $order_status_info['name']; |
||
1045 | } else { |
||
1046 | $data['order_status'] = ''; |
||
1047 | } |
||
1048 | |||
1049 | $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); |
||
1050 | |||
1051 | $data['order_status_id'] = $order_info['order_status_id']; |
||
1052 | |||
1053 | $data['account_custom_field'] = $order_info['custom_field']; |
||
1054 | |||
1055 | // Custom Fields |
||
1056 | $this->load->model('customer/custom_field'); |
||
1057 | |||
1058 | $data['account_custom_fields'] = array(); |
||
1059 | |||
1060 | $filter_data = array( |
||
1061 | 'sort' => 'cf.sort_order', |
||
1062 | 'order' => 'ASC' |
||
1063 | ); |
||
1064 | |||
1065 | $custom_fields = $this->model_customer_custom_field->getCustomFields($filter_data); |
||
1066 | |||
1067 | foreach ($custom_fields as $custom_field) { |
||
1068 | if ($custom_field['location'] == 'account' && isset($order_info['custom_field'][$custom_field['custom_field_id']])) { |
||
1069 | if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio') { |
||
1070 | $custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($order_info['custom_field'][$custom_field['custom_field_id']]); |
||
1071 | |||
1072 | if ($custom_field_value_info) { |
||
1073 | $data['account_custom_fields'][] = array( |
||
1074 | 'name' => $custom_field['name'], |
||
1075 | 'value' => $custom_field_value_info['name'] |
||
1076 | ); |
||
1077 | } |
||
1078 | } |
||
1079 | |||
1080 | if ($custom_field['type'] == 'checkbox' && is_array($order_info['custom_field'][$custom_field['custom_field_id']])) { |
||
1081 | foreach ($order_info['custom_field'][$custom_field['custom_field_id']] as $custom_field_value_id) { |
||
1082 | $custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($custom_field_value_id); |
||
1083 | |||
1084 | if ($custom_field_value_info) { |
||
1085 | $data['account_custom_fields'][] = array( |
||
1086 | 'name' => $custom_field['name'], |
||
1087 | 'value' => $custom_field_value_info['name'] |
||
1088 | ); |
||
1089 | } |
||
1090 | } |
||
1091 | } |
||
1092 | |||
1093 | if ($custom_field['type'] == 'text' || $custom_field['type'] == 'textarea' || $custom_field['type'] == 'file' || $custom_field['type'] == 'date' || $custom_field['type'] == 'datetime' || $custom_field['type'] == 'time') { |
||
1094 | $data['account_custom_fields'][] = array( |
||
1095 | 'name' => $custom_field['name'], |
||
1096 | 'value' => $order_info['custom_field'][$custom_field['custom_field_id']] |
||
1097 | ); |
||
1098 | } |
||
1099 | |||
1100 | if ($custom_field['type'] == 'file') { |
||
1101 | $upload_info = $this->model_tool_upload->getUploadByCode($order_info['custom_field'][$custom_field['custom_field_id']]); |
||
1102 | |||
1103 | if ($upload_info) { |
||
1104 | $data['account_custom_fields'][] = array( |
||
1105 | 'name' => $custom_field['name'], |
||
1106 | 'value' => $upload_info['name'] |
||
1107 | ); |
||
1108 | } |
||
1109 | } |
||
1110 | } |
||
1111 | } |
||
1112 | |||
1113 | // Custom fields |
||
1114 | $data['payment_custom_fields'] = array(); |
||
1115 | |||
1116 | foreach ($custom_fields as $custom_field) { |
||
1117 | if ($custom_field['location'] == 'address' && isset($order_info['payment_custom_field'][$custom_field['custom_field_id']])) { |
||
1118 | if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio') { |
||
1119 | $custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($order_info['payment_custom_field'][$custom_field['custom_field_id']]); |
||
1120 | |||
1121 | if ($custom_field_value_info) { |
||
1122 | $data['payment_custom_fields'][] = array( |
||
1123 | 'name' => $custom_field['name'], |
||
1124 | 'value' => $custom_field_value_info['name'], |
||
1125 | 'sort_order' => $custom_field['sort_order'] |
||
1126 | ); |
||
1127 | } |
||
1128 | } |
||
1129 | |||
1130 | if ($custom_field['type'] == 'checkbox' && is_array($order_info['payment_custom_field'][$custom_field['custom_field_id']])) { |
||
1131 | foreach ($order_info['payment_custom_field'][$custom_field['custom_field_id']] as $custom_field_value_id) { |
||
1132 | $custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($custom_field_value_id); |
||
1133 | |||
1134 | if ($custom_field_value_info) { |
||
1135 | $data['payment_custom_fields'][] = array( |
||
1136 | 'name' => $custom_field['name'], |
||
1137 | 'value' => $custom_field_value_info['name'], |
||
1138 | 'sort_order' => $custom_field['sort_order'] |
||
1139 | ); |
||
1140 | } |
||
1141 | } |
||
1142 | } |
||
1143 | |||
1144 | if ($custom_field['type'] == 'text' || $custom_field['type'] == 'textarea' || $custom_field['type'] == 'file' || $custom_field['type'] == 'date' || $custom_field['type'] == 'datetime' || $custom_field['type'] == 'time') { |
||
1145 | $data['payment_custom_fields'][] = array( |
||
1146 | 'name' => $custom_field['name'], |
||
1147 | 'value' => $order_info['payment_custom_field'][$custom_field['custom_field_id']], |
||
1148 | 'sort_order' => $custom_field['sort_order'] |
||
1149 | ); |
||
1150 | } |
||
1151 | |||
1152 | if ($custom_field['type'] == 'file') { |
||
1153 | $upload_info = $this->model_tool_upload->getUploadByCode($order_info['payment_custom_field'][$custom_field['custom_field_id']]); |
||
1154 | |||
1155 | if ($upload_info) { |
||
1156 | $data['payment_custom_fields'][] = array( |
||
1157 | 'name' => $custom_field['name'], |
||
1158 | 'value' => $upload_info['name'], |
||
1159 | 'sort_order' => $custom_field['sort_order'] |
||
1160 | ); |
||
1161 | } |
||
1162 | } |
||
1163 | } |
||
1164 | } |
||
1165 | |||
1166 | // Shipping |
||
1167 | $data['shipping_custom_fields'] = array(); |
||
1168 | |||
1169 | foreach ($custom_fields as $custom_field) { |
||
1170 | if ($custom_field['location'] == 'address' && isset($order_info['shipping_custom_field'][$custom_field['custom_field_id']])) { |
||
1171 | if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio') { |
||
1172 | $custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($order_info['shipping_custom_field'][$custom_field['custom_field_id']]); |
||
1173 | |||
1174 | if ($custom_field_value_info) { |
||
1175 | $data['shipping_custom_fields'][] = array( |
||
1176 | 'name' => $custom_field['name'], |
||
1177 | 'value' => $custom_field_value_info['name'], |
||
1178 | 'sort_order' => $custom_field['sort_order'] |
||
1179 | ); |
||
1180 | } |
||
1181 | } |
||
1182 | |||
1183 | if ($custom_field['type'] == 'checkbox' && is_array($order_info['shipping_custom_field'][$custom_field['custom_field_id']])) { |
||
1184 | foreach ($order_info['shipping_custom_field'][$custom_field['custom_field_id']] as $custom_field_value_id) { |
||
1185 | $custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($custom_field_value_id); |
||
1186 | |||
1187 | if ($custom_field_value_info) { |
||
1188 | $data['shipping_custom_fields'][] = array( |
||
1189 | 'name' => $custom_field['name'], |
||
1190 | 'value' => $custom_field_value_info['name'], |
||
1191 | 'sort_order' => $custom_field['sort_order'] |
||
1192 | ); |
||
1193 | } |
||
1194 | } |
||
1195 | } |
||
1196 | |||
1197 | if ($custom_field['type'] == 'text' || $custom_field['type'] == 'textarea' || $custom_field['type'] == 'file' || $custom_field['type'] == 'date' || $custom_field['type'] == 'datetime' || $custom_field['type'] == 'time') { |
||
1198 | $data['shipping_custom_fields'][] = array( |
||
1199 | 'name' => $custom_field['name'], |
||
1200 | 'value' => $order_info['shipping_custom_field'][$custom_field['custom_field_id']], |
||
1201 | 'sort_order' => $custom_field['sort_order'] |
||
1202 | ); |
||
1203 | } |
||
1204 | |||
1205 | if ($custom_field['type'] == 'file') { |
||
1206 | $upload_info = $this->model_tool_upload->getUploadByCode($order_info['shipping_custom_field'][$custom_field['custom_field_id']]); |
||
1207 | |||
1208 | if ($upload_info) { |
||
1209 | $data['shipping_custom_fields'][] = array( |
||
1210 | 'name' => $custom_field['name'], |
||
1211 | 'value' => $upload_info['name'], |
||
1212 | 'sort_order' => $custom_field['sort_order'] |
||
1213 | ); |
||
1214 | } |
||
1215 | } |
||
1216 | } |
||
1217 | } |
||
1218 | |||
1219 | $data['ip'] = $order_info['ip']; |
||
1220 | $data['forwarded_ip'] = $order_info['forwarded_ip']; |
||
1221 | $data['user_agent'] = $order_info['user_agent']; |
||
1222 | $data['accept_language'] = $order_info['accept_language']; |
||
1223 | |||
1224 | // Additional Tabs |
||
1225 | $data['tabs'] = array(); |
||
1226 | |||
1227 | if ($this->user->hasPermission('access', 'extension/payment/' . $order_info['payment_code'])) { |
||
1228 | if (is_file(DIR_CATALOG . 'controller/extension/payment/' . $order_info['payment_code'] . '.php')) { |
||
1229 | $content = $this->load->controller('extension/payment/' . $order_info['payment_code'] . '/order'); |
||
1230 | } else { |
||
1231 | $content = null; |
||
1232 | } |
||
1233 | |||
1234 | if ($content) { |
||
1235 | $this->load->language('extension/payment/' . $order_info['payment_code']); |
||
1236 | |||
1237 | $data['tabs'][] = array( |
||
1238 | 'code' => $order_info['payment_code'], |
||
1239 | 'title' => $this->language->get('heading_title'), |
||
1240 | 'content' => $content |
||
1241 | ); |
||
1242 | } |
||
1243 | } |
||
1244 | |||
1245 | $data['header'] = $this->load->controller('common/header'); |
||
1246 | $data['column'] = $this->load->controller('common/column_left'); |
||
1247 | $data['footer'] = $this->load->controller('common/footer'); |
||
1248 | |||
1249 | $this->response->setOutput($this->load->view('sale/order_info', $data)); |
||
1250 | } else { |
||
1251 | return new \Divine\Engine\Core\Action('error/not_found'); |
||
1252 | } |
||
1253 | } |
||
1254 | |||
1255 | protected function validate() |
||
1256 | { |
||
1257 | if (!$this->user->hasPermission('modify', 'sale/order')) { |
||
1258 | $this->error['warning'] = $this->language->get('error_permission'); |
||
1259 | } |
||
1260 | |||
1261 | return !$this->error; |
||
1262 | } |
||
1263 | |||
1264 | public function createInvoiceNo() |
||
1292 | } |
||
1293 | |||
1294 | public function addReward() |
||
1295 | { |
||
1296 | $this->load->language('sale/order'); |
||
1297 | |||
1298 | $json = array(); |
||
1299 | |||
1300 | if (!$this->user->hasPermission('modify', 'sale/order')) { |
||
1301 | $json['error'] = $this->language->get('error_permission'); |
||
1302 | } else { |
||
1303 | if (isset($this->request->get['order_id'])) { |
||
1304 | $order_id = $this->request->get['order_id']; |
||
1305 | } else { |
||
1306 | $order_id = 0; |
||
1307 | } |
||
1308 | |||
1309 | $this->load->model('sale/order'); |
||
1310 | |||
1311 | $order_info = $this->model_sale_order->getOrder($order_id); |
||
1312 | |||
1313 | if ($order_info && $order_info['customer_id'] && ($order_info['reward'] > 0)) { |
||
1314 | $this->load->model('customer/customer'); |
||
1315 | |||
1316 | $reward_total = $this->model_customer_customer->getTotalCustomerRewardsByOrderId($order_id); |
||
1317 | |||
1318 | if (!$reward_total) { |
||
1319 | $this->model_customer_customer->addReward($order_info['customer_id'], $this->language->get('text_order_id') . ' #' . $order_id, $order_info['reward'], $order_id); |
||
1320 | } |
||
1321 | } |
||
1322 | |||
1323 | $json['success'] = $this->language->get('text_reward_added'); |
||
1324 | } |
||
1325 | |||
1326 | $this->response->addHeader('Content-Type: application/json'); |
||
1327 | $this->response->setOutput(json_encode($json)); |
||
1328 | } |
||
1329 | |||
1330 | public function removeReward() |
||
1360 | } |
||
1361 | |||
1362 | public function addCommission() |
||
1386 | } |
||
1387 | |||
1388 | public function removeCommission() |
||
1412 | } |
||
1413 | |||
1414 | public function history() |
||
1459 | } |
||
1460 | |||
1461 | public function invoice() |
||
1462 | { |
||
1664 | } |
||
1665 | |||
1666 | public function shipping() |
||
1667 | { |
||
1668 | $this->load->language('sale/order'); |
||
1843 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.