コード例 #1
0
ファイル: order.php プロジェクト: ralfeus/moomi-daeri.com
 public function getForm()
 {
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_default'] = $this->language->get('text_default');
     $this->data['text_select'] = $this->language->get('text_select');
     $this->data['text_none'] = $this->language->get('text_none');
     $this->data['text_wait'] = $this->language->get('text_wait');
     $this->data['entry_store'] = $this->language->get('entry_store');
     $this->data['entry_customer'] = $this->language->get('entry_customer');
     $this->data['entry_customer_group'] = $this->language->get('entry_customer_group');
     $this->data['entry_firstname'] = $this->language->get('entry_firstname');
     $this->data['entry_lastname'] = $this->language->get('entry_lastname');
     $this->data['entry_email'] = $this->language->get('entry_email');
     $this->data['entry_telephone'] = $this->language->get('entry_telephone');
     $this->data['entry_fax'] = $this->language->get('entry_fax');
     $this->data['entry_order_status'] = $this->language->get('entry_order_status');
     $this->data['entry_comment'] = $this->language->get('entry_comment');
     $this->data['entry_affiliate'] = $this->language->get('entry_affiliate');
     $this->data['entry_address'] = $this->language->get('entry_address');
     $this->data['entry_company'] = $this->language->get('entry_company');
     $this->data['entry_address_1'] = $this->language->get('entry_address_1');
     $this->data['entry_address_2'] = $this->language->get('entry_address_2');
     $this->data['entry_city'] = $this->language->get('entry_city');
     $this->data['entry_postcode'] = $this->language->get('entry_postcode');
     $this->data['entry_zone'] = $this->language->get('entry_zone');
     $this->data['entry_zone_code'] = $this->language->get('entry_zone_code');
     $this->data['entry_country'] = $this->language->get('entry_country');
     $this->data['entry_product'] = $this->language->get('entry_product');
     $this->data['entry_option'] = $this->language->get('entry_option');
     $this->data['entry_quantity'] = $this->language->get('entry_quantity');
     $this->data['entry_shipping'] = $this->language->get('entry_shipping');
     $this->data['entry_payment'] = $this->language->get('entry_payment');
     $this->data['entry_voucher'] = $this->language->get('entry_voucher');
     $this->data['entry_reward'] = $this->language->get('entry_reward');
     $this->data['column_product'] = $this->language->get('column_product');
     $this->data['column_model'] = $this->language->get('column_model');
     $this->data['column_quantity'] = $this->language->get('column_quantity');
     $this->data['column_price'] = $this->language->get('column_price');
     $this->data['column_total'] = $this->language->get('column_total');
     $this->data['button_save'] = $this->language->get('button_save');
     $this->data['button_cancel'] = $this->language->get('button_cancel');
     $this->data['button_add_product'] = $this->language->get('button_add_product');
     $this->data['button_remove'] = $this->language->get('button_remove');
     $this->data['button_upload'] = $this->language->get('button_upload');
     $this->data['tab_order'] = $this->language->get('tab_order');
     $this->data['tab_payment'] = $this->language->get('tab_payment');
     $this->data['tab_shipping'] = $this->language->get('tab_shipping');
     $this->data['tab_product'] = $this->language->get('tab_product');
     $this->data['tab_total'] = $this->language->get('tab_total');
     $this->data['token'] = $this->session->data['token'];
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     if (isset($this->error['firstname'])) {
         $this->data['error_firstname'] = $this->error['firstname'];
     } else {
         $this->data['error_firstname'] = '';
     }
     if (isset($this->error['lastname'])) {
         $this->data['error_lastname'] = $this->error['lastname'];
     } else {
         $this->data['error_lastname'] = '';
     }
     if (isset($this->error['email'])) {
         $this->data['error_email'] = $this->error['email'];
     } else {
         $this->data['error_email'] = '';
     }
     if (isset($this->error['telephone'])) {
         $this->data['error_telephone'] = $this->error['telephone'];
     } else {
         $this->data['error_telephone'] = '';
     }
     if (isset($this->error['shipping_firstname'])) {
         $this->data['error_shipping_firstname'] = $this->error['shipping_firstname'];
     } else {
         $this->data['error_shipping_firstname'] = '';
     }
     if (isset($this->error['shipping_lastname'])) {
         $this->data['error_shipping_lastname'] = $this->error['shipping_lastname'];
     } else {
         $this->data['error_shipping_lastname'] = '';
     }
     if (isset($this->error['shipping_address_1'])) {
         $this->data['error_shipping_address_1'] = $this->error['shipping_address_1'];
     } else {
         $this->data['error_shipping_address_1'] = '';
     }
     if (isset($this->error['shipping_city'])) {
         $this->data['error_shipping_city'] = $this->error['shipping_city'];
     } else {
         $this->data['error_shipping_city'] = '';
     }
     if (isset($this->error['shipping_postcode'])) {
         $this->data['error_shipping_postcode'] = $this->error['shipping_postcode'];
     } else {
         $this->data['error_shipping_postcode'] = '';
     }
     if (isset($this->error['shipping_country'])) {
         $this->data['error_shipping_country'] = $this->error['shipping_country'];
     } else {
         $this->data['error_shipping_country'] = '';
     }
     if (isset($this->error['shipping_zone'])) {
         $this->data['error_shipping_zone'] = $this->error['shipping_zone'];
     } else {
         $this->data['error_shipping_zone'] = '';
     }
     if (isset($this->error['payment_firstname'])) {
         $this->data['error_payment_firstname'] = $this->error['payment_firstname'];
     } else {
         $this->data['error_payment_firstname'] = '';
     }
     if (isset($this->error['payment_lastname'])) {
         $this->data['error_payment_lastname'] = $this->error['payment_lastname'];
     } else {
         $this->data['error_payment_lastname'] = '';
     }
     if (isset($this->error['payment_address_1'])) {
         $this->data['error_payment_address_1'] = $this->error['payment_address_1'];
     } else {
         $this->data['error_payment_address_1'] = '';
     }
     if (isset($this->error['payment_city'])) {
         $this->data['error_payment_city'] = $this->error['payment_city'];
     } else {
         $this->data['error_payment_city'] = '';
     }
     if (isset($this->error['payment_postcode'])) {
         $this->data['error_payment_postcode'] = $this->error['payment_postcode'];
     } else {
         $this->data['error_payment_postcode'] = '';
     }
     if (isset($this->error['payment_country'])) {
         $this->data['error_payment_country'] = $this->error['payment_country'];
     } else {
         $this->data['error_payment_country'] = '';
     }
     if (isset($this->error['payment_zone'])) {
         $this->data['error_payment_zone'] = $this->error['payment_zone'];
     } else {
         $this->data['error_payment_zone'] = '';
     }
     $url = '';
     if (isset($this->request->get['filter_order_id'])) {
         $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
     }
     if (isset($this->request->get['filter_customer'])) {
         $url .= '&filter_customer=' . $this->request->get['filter_customer'];
     }
     if (isset($this->request->get['filter_order_status_id'])) {
         $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
     }
     if (isset($this->request->get['filter_total'])) {
         $url .= '&filter_total=' . $this->request->get['filter_total'];
     }
     if (isset($this->request->get['filter_date_added'])) {
         $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
     }
     if (isset($this->request->get['filter_date_modified'])) {
         $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
     }
     if (isset($this->request->get['sort'])) {
         $url .= '&sort=' . $this->request->get['sort'];
     }
     if (isset($this->request->get['order'])) {
         $url .= '&order=' . $this->request->get['order'];
     }
     if (isset($this->request->get['page'])) {
         $url .= '&page=' . $this->request->get['page'];
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => false);
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('sale/order', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ');
     if (!isset($this->request->get['order_id'])) {
         $this->data['action'] = $this->url->link('sale/order/insert', 'token=' . $this->session->data['token'] . $url, 'SSL');
     } else {
         $this->data['action'] = $this->url->link('sale/order/update', 'token=' . $this->session->data['token'] . '&order_id=' . $this->request->get['order_id'] . $url, 'SSL');
     }
     $this->data['cancel'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL');
     if (isset($this->request->get['order_id']) && $this->request->server['REQUEST_METHOD'] != 'POST') {
         $order_info = $this->model_sale_order->getOrder($this->request->get['order_id']);
     }
     if (isset($this->request->post['store_id'])) {
         $this->data['store_id'] = $this->request->post['store_id'];
     } elseif (!empty($order_info)) {
         $this->data['store_id'] = $order_info['store_id'];
     } else {
         $this->data['store_id'] = '';
     }
     $this->load->model('setting/store');
     $this->data['stores'] = $this->model_setting_store->getStores();
     $this->data['store_url'] = HTTP_CATALOG;
     if (isset($this->request->post['customer_id'])) {
         $this->data['customer_id'] = $this->request->post['customer_id'];
     } elseif (!empty($order_info)) {
         $this->data['customer_id'] = $order_info['customer_id'];
     } else {
         $this->data['customer_id'] = '';
     }
     if (isset($this->request->post['customer'])) {
         $this->data['customer'] = $this->request->post['customer'];
     } elseif (!empty($order_info)) {
         $this->data['customer'] = $order_info['customer'];
     } else {
         $this->data['customer'] = '';
     }
     if (isset($this->request->post['firstname'])) {
         $this->data['firstname'] = $this->request->post['firstname'];
     } elseif (!empty($order_info)) {
         $this->data['firstname'] = $order_info['firstname'];
     } else {
         $this->data['firstname'] = '';
     }
     if (isset($this->request->post['lastname'])) {
         $this->data['lastname'] = $this->request->post['lastname'];
     } elseif (!empty($order_info)) {
         $this->data['lastname'] = $order_info['lastname'];
     } else {
         $this->data['lastname'] = '';
     }
     if (isset($this->request->post['email'])) {
         $this->data['email'] = $this->request->post['email'];
     } elseif (!empty($order_info)) {
         $this->data['email'] = $order_info['email'];
     } else {
         $this->data['email'] = '';
     }
     if (isset($this->request->post['telephone'])) {
         $this->data['telephone'] = $this->request->post['telephone'];
     } elseif (!empty($order_info)) {
         $this->data['telephone'] = $order_info['telephone'];
     } else {
         $this->data['telephone'] = '';
     }
     if (isset($this->request->post['fax'])) {
         $this->data['fax'] = $this->request->post['fax'];
     } elseif (!empty($order_info)) {
         $this->data['fax'] = $order_info['fax'];
     } else {
         $this->data['fax'] = '';
     }
     if (isset($this->request->post['customer_id'])) {
         $this->data['addresses'] = CustomerDAO::getInstance()->getAddresses($this->request->post['customer_id']);
     } elseif (!empty($order_info)) {
         $this->data['addresses'] = CustomerDAO::getInstance()->getAddresses($order_info['customer_id']);
     } else {
         $this->data['addresses'] = array();
     }
     if (isset($this->request->post['shipping_firstname'])) {
         $this->data['shipping_firstname'] = $this->request->post['shipping_firstname'];
     } elseif (!empty($order_info)) {
         $this->data['shipping_firstname'] = $order_info['shipping_firstname'];
     } else {
         $this->data['shipping_firstname'] = '';
     }
     if (isset($this->request->post['shipping_lastname'])) {
         $this->data['shipping_lastname'] = $this->request->post['shipping_lastname'];
     } elseif (!empty($order_info)) {
         $this->data['shipping_lastname'] = $order_info['shipping_lastname'];
     } else {
         $this->data['shipping_lastname'] = '';
     }
     if (isset($this->request->post['shipping_company'])) {
         $this->data['shipping_company'] = $this->request->post['shipping_company'];
     } elseif (!empty($order_info)) {
         $this->data['shipping_company'] = $order_info['shipping_company'];
     } else {
         $this->data['shipping_company'] = '';
     }
     if (isset($this->request->post['shipping_address_1'])) {
         $this->data['shipping_address_1'] = $this->request->post['shipping_address_1'];
     } elseif (!empty($order_info)) {
         $this->data['shipping_address_1'] = $order_info['shipping_address_1'];
     } else {
         $this->data['shipping_address_1'] = '';
     }
     if (isset($this->request->post['shipping_address_2'])) {
         $this->data['shipping_address_2'] = $this->request->post['shipping_address_2'];
     } elseif (!empty($order_info)) {
         $this->data['shipping_address_2'] = $order_info['shipping_address_2'];
     } else {
         $this->data['shipping_address_2'] = '';
     }
     if (isset($this->request->post['shipping_city'])) {
         $this->data['shipping_city'] = $this->request->post['shipping_city'];
     } elseif (!empty($order_info)) {
         $this->data['shipping_city'] = $order_info['shipping_city'];
     } else {
         $this->data['shipping_city'] = '';
     }
     if (isset($this->request->post['shipping_postcode'])) {
         $this->data['shipping_postcode'] = $this->request->post['shipping_postcode'];
     } elseif (!empty($order_info)) {
         $this->data['shipping_postcode'] = $order_info['shipping_postcode'];
     } else {
         $this->data['shipping_postcode'] = '';
     }
     if (isset($this->request->post['shipping_country_id'])) {
         $this->data['shipping_country_id'] = $this->request->post['shipping_country_id'];
     } elseif (!empty($order_info)) {
         $this->data['shipping_country_id'] = $order_info['shipping_country_id'];
     } else {
         $this->data['shipping_country_id'] = '';
     }
     if (isset($this->request->post['shipping_zone_id'])) {
         $this->data['shipping_zone_id'] = $this->request->post['shipping_zone_id'];
     } elseif (!empty($order_info)) {
         $this->data['shipping_zone_id'] = $order_info['shipping_zone_id'];
     } else {
         $this->data['shipping_zone_id'] = '';
     }
     if (isset($this->request->post['shipping_method'])) {
         $this->data['shipping_method'] = $this->request->post['shipping_method'];
     } elseif (!empty($order_info)) {
         $this->data['shipping_method'] = $order_info['shipping_method'];
     } else {
         $this->data['shipping_method'] = '';
     }
     if (isset($this->request->post['payment_firstname'])) {
         $this->data['payment_firstname'] = $this->request->post['payment_firstname'];
     } elseif (!empty($order_info)) {
         $this->data['payment_firstname'] = $order_info['payment_firstname'];
     } else {
         $this->data['payment_firstname'] = '';
     }
     if (isset($this->request->post['payment_lastname'])) {
         $this->data['payment_lastname'] = $this->request->post['payment_lastname'];
     } elseif (!empty($order_info)) {
         $this->data['payment_lastname'] = $order_info['payment_lastname'];
     } else {
         $this->data['payment_lastname'] = '';
     }
     if (isset($this->request->post['payment_company'])) {
         $this->data['payment_company'] = $this->request->post['payment_company'];
     } elseif (!empty($order_info)) {
         $this->data['payment_company'] = $order_info['payment_company'];
     } else {
         $this->data['payment_company'] = '';
     }
     if (isset($this->request->post['payment_address_1'])) {
         $this->data['payment_address_1'] = $this->request->post['payment_address_1'];
     } elseif (!empty($order_info)) {
         $this->data['payment_address_1'] = $order_info['payment_address_1'];
     } else {
         $this->data['payment_address_1'] = '';
     }
     if (isset($this->request->post['payment_address_2'])) {
         $this->data['payment_address_2'] = $this->request->post['payment_address_2'];
     } elseif (!empty($order_info)) {
         $this->data['payment_address_2'] = $order_info['payment_address_2'];
     } else {
         $this->data['payment_address_2'] = '';
     }
     if (isset($this->request->post['payment_city'])) {
         $this->data['payment_city'] = $this->request->post['payment_city'];
     } elseif (!empty($order_info)) {
         $this->data['payment_city'] = $order_info['payment_city'];
     } else {
         $this->data['payment_city'] = '';
     }
     if (isset($this->request->post['payment_postcode'])) {
         $this->data['payment_postcode'] = $this->request->post['payment_postcode'];
     } elseif (!empty($order_info)) {
         $this->data['payment_postcode'] = $order_info['payment_postcode'];
     } else {
         $this->data['payment_postcode'] = '';
     }
     if (isset($this->request->post['payment_country_id'])) {
         $this->data['payment_country_id'] = $this->request->post['payment_country_id'];
     } elseif (!empty($order_info)) {
         $this->data['payment_country_id'] = $order_info['payment_country_id'];
     } else {
         $this->data['payment_country_id'] = '';
     }
     if (isset($this->request->post['payment_zone_id'])) {
         $this->data['payment_zone_id'] = $this->request->post['payment_zone_id'];
     } elseif (!empty($order_info)) {
         $this->data['payment_zone_id'] = $order_info['payment_zone_id'];
     } else {
         $this->data['payment_zone_id'] = '';
     }
     $this->load->model('localisation/country');
     $this->data['countries'] = $this->model_localisation_country->getCountries();
     if (isset($this->request->post['payment_method'])) {
         $this->data['payment_method'] = $this->request->post['payment_method'];
     } elseif (!empty($order_info)) {
         $this->data['payment_method'] = $order_info['payment_method'];
     } else {
         $this->data['payment_method'] = '';
     }
     if (isset($this->request->post['affiliate_id'])) {
         $this->data['affiliate_id'] = $this->request->post['affiliate_id'];
     } elseif (!empty($order_info)) {
         $this->data['affiliate_id'] = $order_info['affiliate_id'];
     } else {
         $this->data['affiliate_id'] = '';
     }
     if (isset($this->request->post['affiliate'])) {
         $this->data['affiliate'] = $this->request->post['affiliate'];
     } elseif (!empty($order_info)) {
         $this->data['affiliate'] = $order_info['affiliate_firstname'] . ' ' . $order_info['affiliate_lastname'];
     } else {
         $this->data['affiliate'] = '';
     }
     if (isset($this->request->post['order_status_id'])) {
         $this->data['order_status_id'] = $this->request->post['order_status_id'];
     } elseif (!empty($order_info)) {
         $this->data['order_status_id'] = $order_info['order_status_id'];
     } else {
         $this->data['order_status_id'] = '';
     }
     $this->load->model('localisation/order_status');
     $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
     if (isset($this->request->post['comment'])) {
         $this->data['comment'] = $this->request->post['comment'];
     } elseif (!empty($order_info)) {
         $this->data['comment'] = $order_info['comment'];
     } else {
         $this->data['comment'] = '';
     }
     if (isset($this->request->post['order_product'])) {
         $order_products = $this->request->post['order_product'];
     } elseif (isset($this->request->get['order_id'])) {
         $order_products = $this->modelSaleOrder->getOrderProducts($this->request->get['order_id']);
     } else {
         $order_products = array();
     }
     $this->load->model('catalog/product');
     $this->document->addScript('view/javascript/jquery/ajaxupload.js');
     $this->data['order_products'] = array();
     foreach ($order_products as $order_product) {
         $product_info = $this->model_catalog_product->getProduct($order_product['product_id']);
         if ($product_info) {
             if (isset($this->request->post['order_product'])) {
                 $order_option = $order_product['order_option'];
             } else {
                 $order_option = $this->modelSaleOrder->getOrderOptions($this->request->get['order_id'], $order_product['order_product_id']);
             }
             $this->data['order_products'][] = array('order_product_id' => $order_product['order_product_id'], 'order_id' => $order_product['order_id'], 'product_id' => $product_info['product_id'], 'name' => $product_info['name'], 'model' => $product_info['model'], 'option' => $order_option, 'quantity' => $order_product['quantity'], 'price' => $order_product['price'], 'total' => $order_product['total'], 'tax' => $order_product['tax']);
         }
     }
     if (isset($this->request->post['order_total'])) {
         $this->data['order_totals'] = $this->request->post['order_total'];
     } elseif (isset($this->request->get['order_id'])) {
         $this->data['order_totals'] = $this->modelSaleOrder->getOrderTotals($this->request->get['order_id']);
     } else {
         $this->data['order_totals'] = array();
     }
     $this->template = 'sale/order_form.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->getResponse()->setOutput($this->render());
 }