コード例 #1
0
ファイル: mta_pds.php プロジェクト: pedrocones/store
 public function product_commission()
 {
     $_REQUEST['format'] = $_GET['format'] = 'raw';
     //+mod by yp mijoshop
     $product_id = $this->request->request['product_id'];
     $this->language->load('catalog/product');
     $data['entry_product'] = $this->language->get('entry_product');
     $data['entry_coupons'] = $this->language->get('entry_coupons');
     $data['column_coupon'] = $this->language->get('column_coupon');
     $data['column_mta_scheme'] = $this->language->get('column_mta_scheme');
     $data['link_commission_tab'] = mta_jsstr($this->url->link('mta/mta_pds/product_commission', 'token=' . $this->session->data['token'] . '&product_id=' . $product_id, 'SSL'));
     $this->load->model('mta/mta_product');
     $data['schemes'] = $this->_get_schemes();
     $data['schemes0'] = array('0' => $this->language->get('text_default'));
     foreach ($data['schemes'] as $_k => $_v) {
         $data['schemes0'][strval($_k)] = $_v;
     }
     $data['text_aff_schemes'] = $this->language->get('text_aff_schemes');
     $_psch = $this->model_mta_mta_product->getProductScheme($product_id);
     $data['product_scheme_id'] = $_psch && isset($_psch['id']) ? $_psch['id'] : 0;
     $all_sub_schemes = $this->model_mta_mta_product->getAllProductSubSchemes($product_id);
     $per_page = $this->config->get('config_admin_limit');
     $this->load->model('marketing/coupon');
     $coupon_total = $this->model_marketing_coupon->getTotalCoupons();
     if ($coupon_total <= $per_page) {
         $data['pagination'] = false;
         $coupons = $this->_get_coupons();
     } else {
         $page = isset($this->request->request['coupon_page']) ? intval($this->request->request['coupon_page']) : 1;
         $coupons = $this->_get_coupons(($page - 1) * $per_page, $per_page);
         $pagination = new Pagination();
         $pagination->total = $coupon_total;
         $pagination->page = $page;
         $pagination->limit = $per_page;
         $pagination->text = $this->language->get('text_pagination');
         $pagination->url = '{page}';
         $data['pagination'] = str_replace('a href=', 'a class="coupon-page-link" href="javascript:;" rel=', $pagination->render());
     }
     $data['coupons'] = array();
     foreach ($coupons as $_coupon) {
         $data['coupons'][] = array('id' => $_coupon['coupon_id'], 'description' => $_coupon['name'] . '<br />(%' . intval($_coupon['discount']) . ')<br />' . date('d/m/Y', strtotime($_coupon['date_start'])) . ' - ' . date('d/m/Y', strtotime($_coupon['date_end'])), 'scheme_id' => isset($all_sub_schemes['coupon'][strval($_coupon['coupon_id'])]) ? $all_sub_schemes['coupon'][strval($_coupon['coupon_id'])] : '0');
     }
     $this->response->setOutput($this->load->view('mta/product_commission.tpl', $data));
 }
コード例 #2
0
ファイル: category.php プロジェクト: pedrocones/store
 protected function getForm()
 {
     //+mod by yp start
     $__cl = strtolower(get_class($this));
     preg_match("/^controller(?:(?:catalog)|(?:marketing))(.+)\$/", $__cl, $__ar);
     $data['page_type'] = $__ar[1];
     $etype = $data['page_type'] === 'coupon' ? $data['page_type'] : substr($data['page_type'], 0, 1);
     if (isset($this->request->get[$data['page_type'] . '_id']) && $this->request->get[$data['page_type'] . '_id']) {
         $this->language->load('mta/mta_pds');
         $data['tab_commission'] = mta_jsstr($this->language->get('tab_commission'));
         $data['tab_general_added'] = mta_jsstr($this->language->get('tab_general_added'));
         $data['mta_do_edit'] = true;
         $data['mta_pds_url'] = mta_jsstr($this->url->link('mta/mta_pds', 'token=' . $this->session->data['token'] . '&type=' . $etype . '&id=' . intval($this->request->get[$data['page_type'] . '_id']), 'SSL'));
     }
     //+mod by yp end
     $data['heading_title'] = $this->language->get('heading_title');
     $data['text_form'] = !isset($this->request->get['category_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
     $data['text_none'] = $this->language->get('text_none');
     $data['text_default'] = $this->language->get('text_default');
     $data['text_enabled'] = $this->language->get('text_enabled');
     $data['text_disabled'] = $this->language->get('text_disabled');
     $data['entry_name'] = $this->language->get('entry_name');
     $data['entry_description'] = $this->language->get('entry_description');
     $data['entry_meta_title'] = $this->language->get('entry_meta_title');
     $data['entry_meta_description'] = $this->language->get('entry_meta_description');
     $data['entry_meta_keyword'] = $this->language->get('entry_meta_keyword');
     $data['entry_keyword'] = $this->language->get('entry_keyword');
     $data['entry_parent'] = $this->language->get('entry_parent');
     $data['entry_filter'] = $this->language->get('entry_filter');
     $data['entry_store'] = $this->language->get('entry_store');
     $data['entry_image'] = $this->language->get('entry_image');
     $data['entry_top'] = $this->language->get('entry_top');
     $data['entry_column'] = $this->language->get('entry_column');
     $data['entry_sort_order'] = $this->language->get('entry_sort_order');
     $data['entry_status'] = $this->language->get('entry_status');
     $data['entry_layout'] = $this->language->get('entry_layout');
     $data['help_filter'] = $this->language->get('help_filter');
     $data['help_keyword'] = $this->language->get('help_keyword');
     $data['help_top'] = $this->language->get('help_top');
     $data['help_column'] = $this->language->get('help_column');
     $data['button_save'] = $this->language->get('button_save');
     $data['button_cancel'] = $this->language->get('button_cancel');
     $data['tab_general'] = $this->language->get('tab_general');
     $data['tab_data'] = $this->language->get('tab_data');
     $data['tab_design'] = $this->language->get('tab_design');
     if (isset($this->error['warning'])) {
         $data['error_warning'] = $this->error['warning'];
     } else {
         $data['error_warning'] = '';
     }
     if (isset($this->error['name'])) {
         $data['error_name'] = $this->error['name'];
     } else {
         $data['error_name'] = array();
     }
     if (isset($this->error['meta_title'])) {
         $data['error_meta_title'] = $this->error['meta_title'];
     } else {
         $data['error_meta_title'] = array();
     }
     if (isset($this->error['keyword'])) {
         $data['error_keyword'] = $this->error['keyword'];
     } else {
         $data['error_keyword'] = '';
     }
     $url = '';
     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'];
     }
     $data['breadcrumbs'] = array();
     $data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL'));
     $data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('catalog/category', 'token=' . $this->session->data['token'] . $url, 'SSL'));
     if (!isset($this->request->get['category_id'])) {
         $data['action'] = $this->url->link('catalog/category/add', 'token=' . $this->session->data['token'] . $url, 'SSL');
     } else {
         $data['action'] = $this->url->link('catalog/category/edit', 'token=' . $this->session->data['token'] . '&category_id=' . $this->request->get['category_id'] . $url, 'SSL');
     }
     $data['cancel'] = $this->url->link('catalog/category', 'token=' . $this->session->data['token'] . $url, 'SSL');
     if (isset($this->request->get['category_id']) && $this->request->server['REQUEST_METHOD'] != 'POST') {
         $category_info = $this->model_catalog_category->getCategory($this->request->get['category_id']);
     }
     $data['token'] = $this->session->data['token'];
     $this->load->model('localisation/language');
     $data['languages'] = $this->model_localisation_language->getLanguages();
     if (isset($this->request->post['category_description'])) {
         $data['category_description'] = $this->request->post['category_description'];
     } elseif (isset($this->request->get['category_id'])) {
         $data['category_description'] = $this->model_catalog_category->getCategoryDescriptions($this->request->get['category_id']);
     } else {
         $data['category_description'] = array();
     }
     if (isset($this->request->post['path'])) {
         $data['path'] = $this->request->post['path'];
     } elseif (!empty($category_info)) {
         $data['path'] = $category_info['path'];
     } else {
         $data['path'] = '';
     }
     if (isset($this->request->post['parent_id'])) {
         $data['parent_id'] = $this->request->post['parent_id'];
     } elseif (!empty($category_info)) {
         $data['parent_id'] = $category_info['parent_id'];
     } else {
         $data['parent_id'] = 0;
     }
     $this->load->model('catalog/filter');
     if (isset($this->request->post['category_filter'])) {
         $filters = $this->request->post['category_filter'];
     } elseif (isset($this->request->get['category_id'])) {
         $filters = $this->model_catalog_category->getCategoryFilters($this->request->get['category_id']);
     } else {
         $filters = array();
     }
     $data['category_filters'] = array();
     foreach ($filters as $filter_id) {
         $filter_info = $this->model_catalog_filter->getFilter($filter_id);
         if ($filter_info) {
             $data['category_filters'][] = array('filter_id' => $filter_info['filter_id'], 'name' => $filter_info['group'] . ' &gt; ' . $filter_info['name']);
         }
     }
     $this->load->model('setting/store');
     $data['stores'] = $this->model_setting_store->getStores();
     if (isset($this->request->post['category_store'])) {
         $data['category_store'] = $this->request->post['category_store'];
     } elseif (isset($this->request->get['category_id'])) {
         $data['category_store'] = $this->model_catalog_category->getCategoryStores($this->request->get['category_id']);
     } else {
         $data['category_store'] = array(0);
     }
     if (isset($this->request->post['keyword'])) {
         $data['keyword'] = $this->request->post['keyword'];
     } elseif (!empty($category_info)) {
         $data['keyword'] = $category_info['keyword'];
     } else {
         $data['keyword'] = '';
     }
     if (isset($this->request->post['image'])) {
         $data['image'] = $this->request->post['image'];
     } elseif (!empty($category_info)) {
         $data['image'] = $category_info['image'];
     } else {
         $data['image'] = '';
     }
     $this->load->model('tool/image');
     if (isset($this->request->post['image']) && is_file(DIR_IMAGE . $this->request->post['image'])) {
         $data['thumb'] = $this->model_tool_image->resize($this->request->post['image'], 100, 100);
     } elseif (!empty($category_info) && is_file(DIR_IMAGE . $category_info['image'])) {
         $data['thumb'] = $this->model_tool_image->resize($category_info['image'], 100, 100);
     } else {
         $data['thumb'] = $this->model_tool_image->resize('no_image.png', 100, 100);
     }
     $data['placeholder'] = $this->model_tool_image->resize('no_image.png', 100, 100);
     if (isset($this->request->post['top'])) {
         $data['top'] = $this->request->post['top'];
     } elseif (!empty($category_info)) {
         $data['top'] = $category_info['top'];
     } else {
         $data['top'] = 0;
     }
     if (isset($this->request->post['column'])) {
         $data['column'] = $this->request->post['column'];
     } elseif (!empty($category_info)) {
         $data['column'] = $category_info['column'];
     } else {
         $data['column'] = 1;
     }
     if (isset($this->request->post['sort_order'])) {
         $data['sort_order'] = $this->request->post['sort_order'];
     } elseif (!empty($category_info)) {
         $data['sort_order'] = $category_info['sort_order'];
     } else {
         $data['sort_order'] = 0;
     }
     if (isset($this->request->post['status'])) {
         $data['status'] = $this->request->post['status'];
     } elseif (!empty($category_info)) {
         $data['status'] = $category_info['status'];
     } else {
         $data['status'] = true;
     }
     if (isset($this->request->post['category_layout'])) {
         $data['category_layout'] = $this->request->post['category_layout'];
     } elseif (isset($this->request->get['category_id'])) {
         $data['category_layout'] = $this->model_catalog_category->getCategoryLayouts($this->request->get['category_id']);
     } else {
         $data['category_layout'] = array();
     }
     $this->load->model('design/layout');
     $data['layouts'] = $this->model_design_layout->getLayouts();
     $data['header'] = $this->load->controller('common/header');
     $data['column_left'] = $this->load->controller('common/column_left');
     $data['footer'] = $this->load->controller('common/footer');
     $this->response->setOutput($this->load->view('catalog/category_form.tpl', $data));
 }
コード例 #3
0
ファイル: product.php プロジェクト: pedrocones/store
 protected function getForm()
 {
     //+mod by yp start
     $this->load->model('mta/mta_product');
     $data['schemes'] = $this->_get_schemes();
     $data['schemes0'] = array('0' => $this->language->get('text_default'));
     foreach ($data['schemes'] as $_k => $_v) {
         $data['schemes0'][strval($_k)] = $_v;
     }
     //+mod by yp end
     $data['heading_title'] = $this->language->get('heading_title');
     $data['text_form'] = !isset($this->request->get['product_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
     $data['text_enabled'] = $this->language->get('text_enabled');
     $data['text_disabled'] = $this->language->get('text_disabled');
     $data['text_none'] = $this->language->get('text_none');
     $data['text_yes'] = $this->language->get('text_yes');
     $data['text_no'] = $this->language->get('text_no');
     $data['text_plus'] = $this->language->get('text_plus');
     $data['text_minus'] = $this->language->get('text_minus');
     $data['text_default'] = $this->language->get('text_default');
     $data['text_option'] = $this->language->get('text_option');
     $data['text_option_value'] = $this->language->get('text_option_value');
     $data['text_select'] = $this->language->get('text_select');
     $data['text_percent'] = $this->language->get('text_percent');
     $data['text_amount'] = $this->language->get('text_amount');
     $data['entry_name'] = $this->language->get('entry_name');
     $data['entry_description'] = $this->language->get('entry_description');
     $data['entry_meta_title'] = $this->language->get('entry_meta_title');
     $data['entry_meta_description'] = $this->language->get('entry_meta_description');
     $data['entry_meta_keyword'] = $this->language->get('entry_meta_keyword');
     $data['entry_keyword'] = $this->language->get('entry_keyword');
     $data['entry_model'] = $this->language->get('entry_model');
     $data['entry_sku'] = $this->language->get('entry_sku');
     $data['entry_upc'] = $this->language->get('entry_upc');
     $data['entry_ean'] = $this->language->get('entry_ean');
     $data['entry_jan'] = $this->language->get('entry_jan');
     $data['entry_isbn'] = $this->language->get('entry_isbn');
     $data['entry_mpn'] = $this->language->get('entry_mpn');
     $data['entry_location'] = $this->language->get('entry_location');
     $data['entry_minimum'] = $this->language->get('entry_minimum');
     $data['entry_shipping'] = $this->language->get('entry_shipping');
     $data['entry_date_available'] = $this->language->get('entry_date_available');
     $data['entry_quantity'] = $this->language->get('entry_quantity');
     $data['entry_stock_status'] = $this->language->get('entry_stock_status');
     $data['entry_price'] = $this->language->get('entry_price');
     $data['entry_tax_class'] = $this->language->get('entry_tax_class');
     $data['entry_points'] = $this->language->get('entry_points');
     $data['entry_option_points'] = $this->language->get('entry_option_points');
     $data['entry_subtract'] = $this->language->get('entry_subtract');
     $data['entry_weight_class'] = $this->language->get('entry_weight_class');
     $data['entry_weight'] = $this->language->get('entry_weight');
     $data['entry_dimension'] = $this->language->get('entry_dimension');
     $data['entry_length_class'] = $this->language->get('entry_length_class');
     $data['entry_length'] = $this->language->get('entry_length');
     $data['entry_width'] = $this->language->get('entry_width');
     $data['entry_height'] = $this->language->get('entry_height');
     $data['entry_image'] = $this->language->get('entry_image');
     $data['entry_store'] = $this->language->get('entry_store');
     $data['entry_manufacturer'] = $this->language->get('entry_manufacturer');
     $data['entry_download'] = $this->language->get('entry_download');
     $data['entry_category'] = $this->language->get('entry_category');
     $data['entry_filter'] = $this->language->get('entry_filter');
     $data['entry_related'] = $this->language->get('entry_related');
     $data['entry_attribute'] = $this->language->get('entry_attribute');
     $data['entry_text'] = $this->language->get('entry_text');
     $data['entry_option'] = $this->language->get('entry_option');
     $data['entry_option_value'] = $this->language->get('entry_option_value');
     $data['entry_required'] = $this->language->get('entry_required');
     $data['entry_sort_order'] = $this->language->get('entry_sort_order');
     $data['entry_status'] = $this->language->get('entry_status');
     $data['entry_date_start'] = $this->language->get('entry_date_start');
     $data['entry_date_end'] = $this->language->get('entry_date_end');
     $data['entry_priority'] = $this->language->get('entry_priority');
     $data['entry_tag'] = $this->language->get('entry_tag');
     $data['entry_customer_group'] = $this->language->get('entry_customer_group');
     $data['entry_reward'] = $this->language->get('entry_reward');
     $data['entry_layout'] = $this->language->get('entry_layout');
     $data['entry_recurring'] = $this->language->get('entry_recurring');
     $data['help_keyword'] = $this->language->get('help_keyword');
     $data['help_sku'] = $this->language->get('help_sku');
     $data['help_upc'] = $this->language->get('help_upc');
     $data['help_ean'] = $this->language->get('help_ean');
     $data['help_jan'] = $this->language->get('help_jan');
     $data['help_isbn'] = $this->language->get('help_isbn');
     $data['help_mpn'] = $this->language->get('help_mpn');
     $data['help_minimum'] = $this->language->get('help_minimum');
     $data['help_manufacturer'] = $this->language->get('help_manufacturer');
     $data['help_stock_status'] = $this->language->get('help_stock_status');
     $data['help_points'] = $this->language->get('help_points');
     $data['help_category'] = $this->language->get('help_category');
     $data['help_filter'] = $this->language->get('help_filter');
     $data['help_download'] = $this->language->get('help_download');
     $data['help_related'] = $this->language->get('help_related');
     $data['help_tag'] = $this->language->get('help_tag');
     $data['button_save'] = $this->language->get('button_save');
     $data['button_cancel'] = $this->language->get('button_cancel');
     $data['button_attribute_add'] = $this->language->get('button_attribute_add');
     $data['button_option_add'] = $this->language->get('button_option_add');
     $data['button_option_value_add'] = $this->language->get('button_option_value_add');
     $data['button_discount_add'] = $this->language->get('button_discount_add');
     $data['button_special_add'] = $this->language->get('button_special_add');
     $data['button_image_add'] = $this->language->get('button_image_add');
     $data['button_remove'] = $this->language->get('button_remove');
     $data['button_recurring_add'] = $this->language->get('button_recurring_add');
     $data['tab_general'] = $this->language->get('tab_general');
     $data['tab_data'] = $this->language->get('tab_data');
     $data['tab_attribute'] = $this->language->get('tab_attribute');
     $data['tab_option'] = $this->language->get('tab_option');
     $data['tab_recurring'] = $this->language->get('tab_recurring');
     $data['tab_discount'] = $this->language->get('tab_discount');
     $data['tab_special'] = $this->language->get('tab_special');
     $data['tab_image'] = $this->language->get('tab_image');
     $data['tab_links'] = $this->language->get('tab_links');
     $data['tab_reward'] = $this->language->get('tab_reward');
     $data['tab_design'] = $this->language->get('tab_design');
     //+mod by yp start
     $data['text_aff_schemes'] = $this->language->get('text_aff_schemes');
     $data['text_edit'] = $this->language->get('text_edit');
     $data['text_add'] = $this->language->get('text_add');
     $data['entry_product'] = $this->language->get('entry_product');
     $data['entry_coupons'] = $this->language->get('entry_coupons');
     $data['tab_scheme'] = $this->language->get('tab_scheme');
     $data['column_affiliates'] = $this->language->get('column_affiliates');
     $data['column_mta_scheme'] = $this->language->get('column_mta_scheme');
     $data['button_add_selected'] = $this->language->get('button_add_selected');
     $data['button_remove_selected'] = $this->language->get('button_remove_selected');
     $data['column_coupon'] = $this->language->get('column_coupon');
     if (isset($this->request->get['product_id']) && (!mta_check_int($this->request->get['product_id']) || $this->request->get['product_id'] < 1)) {
         unset($this->request->get['product_id']);
     }
     $_do_edit = isset($this->request->get['product_id']);
     if ($_do_edit) {
         $data['product_id'] = $product_id = $this->request->get['product_id'];
         $_psch = $this->model_mta_mta_product->getProductScheme($product_id);
         $data['product_scheme_id'] = $_psch && isset($_psch['id']) ? $_psch['id'] : 0;
         $all_sub_schemes = $this->model_mta_mta_product->getAllProductSubSchemes($product_id);
         $coupons = $this->_get_coupons();
         $data['coupons'] = array();
         foreach ($coupons as $_coupon) {
             $data['coupons'][] = array('id' => $_coupon['coupon_id'], 'description' => $_coupon['name'] . '<br />(%' . intval($_coupon['discount']) . ')<br />' . date('d/m/Y', strtotime($_coupon['date_start'])) . ' - ' . date('d/m/Y', strtotime($_coupon['date_end'])), 'scheme_id' => isset($all_sub_schemes['coupon'][strval($_coupon['coupon_id'])]) ? $all_sub_schemes['coupon'][strval($_coupon['coupon_id'])] : '0');
         }
     }
     //+mod by yp end
     $data['tab_openbay'] = $this->language->get('tab_openbay');
     if (isset($this->error['warning'])) {
         $data['error_warning'] = $this->error['warning'];
     } else {
         $data['error_warning'] = '';
     }
     if (isset($this->error['name'])) {
         $data['error_name'] = $this->error['name'];
     } else {
         $data['error_name'] = array();
     }
     if (isset($this->error['meta_title'])) {
         $data['error_meta_title'] = $this->error['meta_title'];
     } else {
         $data['error_meta_title'] = array();
     }
     if (isset($this->error['model'])) {
         $data['error_model'] = $this->error['model'];
     } else {
         $data['error_model'] = '';
     }
     if (isset($this->error['keyword'])) {
         $data['error_keyword'] = $this->error['keyword'];
     } else {
         $data['error_keyword'] = '';
     }
     $url = '';
     if (isset($this->request->get['filter_name'])) {
         $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
     }
     if (isset($this->request->get['filter_model'])) {
         $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
     }
     if (isset($this->request->get['filter_price'])) {
         $url .= '&filter_price=' . $this->request->get['filter_price'];
     }
     if (isset($this->request->get['filter_quantity'])) {
         $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
     }
     if (isset($this->request->get['filter_status'])) {
         $url .= '&filter_status=' . $this->request->get['filter_status'];
     }
     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'];
     }
     $data['breadcrumbs'] = array();
     $data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL'));
     $data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'));
     if (!isset($this->request->get['product_id'])) {
         $data['action'] = $this->url->link('catalog/product/add', 'token=' . $this->session->data['token'] . $url, 'SSL');
     } else {
         $data['action'] = $this->url->link('catalog/product/edit', 'token=' . $this->session->data['token'] . '&product_id=' . $this->request->get['product_id'] . $url, 'SSL');
     }
     $data['cancel'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL');
     if (isset($this->request->get['product_id']) && $this->request->server['REQUEST_METHOD'] != 'POST') {
         $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']);
     }
     $data['token'] = $this->session->data['token'];
     $this->load->model('localisation/language');
     $data['languages'] = $this->model_localisation_language->getLanguages();
     if (isset($this->request->post['product_description'])) {
         $data['product_description'] = $this->request->post['product_description'];
     } elseif (isset($this->request->get['product_id'])) {
         $data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']);
     } else {
         $data['product_description'] = array();
     }
     if (isset($this->request->post['image'])) {
         $data['image'] = $this->request->post['image'];
     } elseif (!empty($product_info)) {
         $data['image'] = $product_info['image'];
     } else {
         $data['image'] = '';
     }
     $this->load->model('tool/image');
     if (isset($this->request->post['image']) && is_file(DIR_IMAGE . $this->request->post['image'])) {
         $data['thumb'] = $this->model_tool_image->resize($this->request->post['image'], 100, 100);
     } elseif (!empty($product_info) && is_file(DIR_IMAGE . $product_info['image'])) {
         $data['thumb'] = $this->model_tool_image->resize($product_info['image'], 100, 100);
     } else {
         $data['thumb'] = $this->model_tool_image->resize('no_image.png', 100, 100);
     }
     $data['placeholder'] = $this->model_tool_image->resize('no_image.png', 100, 100);
     if (isset($this->request->post['model'])) {
         $data['model'] = $this->request->post['model'];
     } elseif (!empty($product_info)) {
         $data['model'] = $product_info['model'];
     } else {
         $data['model'] = '';
     }
     if (isset($this->request->post['sku'])) {
         $data['sku'] = $this->request->post['sku'];
     } elseif (!empty($product_info)) {
         $data['sku'] = $product_info['sku'];
     } else {
         $data['sku'] = '';
     }
     if (isset($this->request->post['upc'])) {
         $data['upc'] = $this->request->post['upc'];
     } elseif (!empty($product_info)) {
         $data['upc'] = $product_info['upc'];
     } else {
         $data['upc'] = '';
     }
     if (isset($this->request->post['ean'])) {
         $data['ean'] = $this->request->post['ean'];
     } elseif (!empty($product_info)) {
         $data['ean'] = $product_info['ean'];
     } else {
         $data['ean'] = '';
     }
     if (isset($this->request->post['jan'])) {
         $data['jan'] = $this->request->post['jan'];
     } elseif (!empty($product_info)) {
         $data['jan'] = $product_info['jan'];
     } else {
         $data['jan'] = '';
     }
     if (isset($this->request->post['isbn'])) {
         $data['isbn'] = $this->request->post['isbn'];
     } elseif (!empty($product_info)) {
         $data['isbn'] = $product_info['isbn'];
     } else {
         $data['isbn'] = '';
     }
     if (isset($this->request->post['mpn'])) {
         $data['mpn'] = $this->request->post['mpn'];
     } elseif (!empty($product_info)) {
         $data['mpn'] = $product_info['mpn'];
     } else {
         $data['mpn'] = '';
     }
     if (isset($this->request->post['location'])) {
         $data['location'] = $this->request->post['location'];
     } elseif (!empty($product_info)) {
         $data['location'] = $product_info['location'];
     } else {
         $data['location'] = '';
     }
     $this->load->model('setting/store');
     $data['stores'] = $this->model_setting_store->getStores();
     if (isset($this->request->post['product_store'])) {
         $data['product_store'] = $this->request->post['product_store'];
     } elseif (isset($this->request->get['product_id'])) {
         $data['product_store'] = $this->model_catalog_product->getProductStores($this->request->get['product_id']);
     } else {
         $data['product_store'] = array(0);
     }
     if (isset($this->request->post['keyword'])) {
         $data['keyword'] = $this->request->post['keyword'];
     } elseif (!empty($product_info)) {
         $data['keyword'] = $product_info['keyword'];
     } else {
         $data['keyword'] = '';
     }
     if (isset($this->request->post['shipping'])) {
         $data['shipping'] = $this->request->post['shipping'];
     } elseif (!empty($product_info)) {
         $data['shipping'] = $product_info['shipping'];
     } else {
         $data['shipping'] = 1;
     }
     if (isset($this->request->post['price'])) {
         $data['price'] = $this->request->post['price'];
     } elseif (!empty($product_info)) {
         $data['price'] = $product_info['price'];
     } else {
         $data['price'] = '';
     }
     $this->load->model('catalog/recurring');
     $data['recurrings'] = $this->model_catalog_recurring->getRecurrings();
     if (isset($this->request->post['product_recurrings'])) {
         $data['product_recurrings'] = $this->request->post['product_recurrings'];
     } elseif (!empty($product_info)) {
         $data['product_recurrings'] = $this->model_catalog_product->getRecurrings($product_info['product_id']);
     } else {
         $data['product_recurrings'] = array();
     }
     $this->load->model('localisation/tax_class');
     $data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();
     if (isset($this->request->post['tax_class_id'])) {
         $data['tax_class_id'] = $this->request->post['tax_class_id'];
     } elseif (!empty($product_info)) {
         $data['tax_class_id'] = $product_info['tax_class_id'];
     } else {
         $data['tax_class_id'] = 0;
     }
     if (isset($this->request->post['date_available'])) {
         $data['date_available'] = $this->request->post['date_available'];
     } elseif (!empty($product_info)) {
         $data['date_available'] = $product_info['date_available'] != '0000-00-00' ? $product_info['date_available'] : '';
     } else {
         $data['date_available'] = date('Y-m-d');
     }
     if (isset($this->request->post['quantity'])) {
         $data['quantity'] = $this->request->post['quantity'];
     } elseif (!empty($product_info)) {
         $data['quantity'] = $product_info['quantity'];
     } else {
         $data['quantity'] = 1;
     }
     if (isset($this->request->post['minimum'])) {
         $data['minimum'] = $this->request->post['minimum'];
     } elseif (!empty($product_info)) {
         $data['minimum'] = $product_info['minimum'];
     } else {
         $data['minimum'] = 1;
     }
     if (isset($this->request->post['subtract'])) {
         $data['subtract'] = $this->request->post['subtract'];
     } elseif (!empty($product_info)) {
         $data['subtract'] = $product_info['subtract'];
     } else {
         $data['subtract'] = 1;
     }
     if (isset($this->request->post['sort_order'])) {
         $data['sort_order'] = $this->request->post['sort_order'];
     } elseif (!empty($product_info)) {
         $data['sort_order'] = $product_info['sort_order'];
     } else {
         $data['sort_order'] = 1;
     }
     $this->load->model('localisation/stock_status');
     $data['stock_statuses'] = $this->model_localisation_stock_status->getStockStatuses();
     if (isset($this->request->post['stock_status_id'])) {
         $data['stock_status_id'] = $this->request->post['stock_status_id'];
     } elseif (!empty($product_info)) {
         $data['stock_status_id'] = $product_info['stock_status_id'];
     } else {
         $data['stock_status_id'] = 0;
     }
     if (isset($this->request->post['status'])) {
         $data['status'] = $this->request->post['status'];
     } elseif (!empty($product_info)) {
         $data['status'] = $product_info['status'];
     } else {
         $data['status'] = true;
     }
     if (isset($this->request->post['weight'])) {
         $data['weight'] = $this->request->post['weight'];
     } elseif (!empty($product_info)) {
         $data['weight'] = $product_info['weight'];
     } else {
         $data['weight'] = '';
     }
     $this->load->model('localisation/weight_class');
     $data['weight_classes'] = $this->model_localisation_weight_class->getWeightClasses();
     if (isset($this->request->post['weight_class_id'])) {
         $data['weight_class_id'] = $this->request->post['weight_class_id'];
     } elseif (!empty($product_info)) {
         $data['weight_class_id'] = $product_info['weight_class_id'];
     } else {
         $data['weight_class_id'] = $this->config->get('config_weight_class_id');
     }
     if (isset($this->request->post['length'])) {
         $data['length'] = $this->request->post['length'];
     } elseif (!empty($product_info)) {
         $data['length'] = $product_info['length'];
     } else {
         $data['length'] = '';
     }
     if (isset($this->request->post['width'])) {
         $data['width'] = $this->request->post['width'];
     } elseif (!empty($product_info)) {
         $data['width'] = $product_info['width'];
     } else {
         $data['width'] = '';
     }
     if (isset($this->request->post['height'])) {
         $data['height'] = $this->request->post['height'];
     } elseif (!empty($product_info)) {
         $data['height'] = $product_info['height'];
     } else {
         $data['height'] = '';
     }
     $this->load->model('localisation/length_class');
     $data['length_classes'] = $this->model_localisation_length_class->getLengthClasses();
     if (isset($this->request->post['length_class_id'])) {
         $data['length_class_id'] = $this->request->post['length_class_id'];
     } elseif (!empty($product_info)) {
         $data['length_class_id'] = $product_info['length_class_id'];
     } else {
         $data['length_class_id'] = $this->config->get('config_length_class_id');
     }
     $this->load->model('catalog/manufacturer');
     if (isset($this->request->post['manufacturer_id'])) {
         $data['manufacturer_id'] = $this->request->post['manufacturer_id'];
     } elseif (!empty($product_info)) {
         $data['manufacturer_id'] = $product_info['manufacturer_id'];
     } else {
         $data['manufacturer_id'] = 0;
     }
     if (isset($this->request->post['manufacturer'])) {
         $data['manufacturer'] = $this->request->post['manufacturer'];
     } elseif (!empty($product_info)) {
         $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($product_info['manufacturer_id']);
         if ($manufacturer_info) {
             $data['manufacturer'] = $manufacturer_info['name'];
         } else {
             $data['manufacturer'] = '';
         }
     } else {
         $data['manufacturer'] = '';
     }
     // Categories
     $this->load->model('catalog/category');
     if (isset($this->request->post['product_category'])) {
         $categories = $this->request->post['product_category'];
     } elseif (isset($this->request->get['product_id'])) {
         $categories = $this->model_catalog_product->getProductCategories($this->request->get['product_id']);
     } else {
         $categories = array();
     }
     $data['product_categories'] = array();
     foreach ($categories as $category_id) {
         $category_info = $this->model_catalog_category->getCategory($category_id);
         if ($category_info) {
             $data['product_categories'][] = array('category_id' => $category_info['category_id'], 'name' => $category_info['path'] ? $category_info['path'] . ' &gt; ' . $category_info['name'] : $category_info['name']);
         }
     }
     // Filters
     $this->load->model('catalog/filter');
     if (isset($this->request->post['product_filter'])) {
         $filters = $this->request->post['product_filter'];
     } elseif (isset($this->request->get['product_id'])) {
         $filters = $this->model_catalog_product->getProductFilters($this->request->get['product_id']);
     } else {
         $filters = array();
     }
     $data['product_filters'] = array();
     foreach ($filters as $filter_id) {
         $filter_info = $this->model_catalog_filter->getFilter($filter_id);
         if ($filter_info) {
             $data['product_filters'][] = array('filter_id' => $filter_info['filter_id'], 'name' => $filter_info['group'] . ' &gt; ' . $filter_info['name']);
         }
     }
     // Attributes
     $this->load->model('catalog/attribute');
     if (isset($this->request->post['product_attribute'])) {
         $product_attributes = $this->request->post['product_attribute'];
     } elseif (isset($this->request->get['product_id'])) {
         $product_attributes = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);
     } else {
         $product_attributes = array();
     }
     $data['product_attributes'] = array();
     foreach ($product_attributes as $product_attribute) {
         $attribute_info = $this->model_catalog_attribute->getAttribute($product_attribute['attribute_id']);
         if ($attribute_info) {
             $data['product_attributes'][] = array('attribute_id' => $product_attribute['attribute_id'], 'name' => $attribute_info['name'], 'product_attribute_description' => $product_attribute['product_attribute_description']);
         }
     }
     // Options
     $this->load->model('catalog/option');
     if (isset($this->request->post['product_option'])) {
         $product_options = $this->request->post['product_option'];
     } elseif (isset($this->request->get['product_id'])) {
         $product_options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']);
     } else {
         $product_options = array();
     }
     $data['product_options'] = array();
     foreach ($product_options as $product_option) {
         $product_option_value_data = array();
         if (isset($product_option['product_option_value'])) {
             foreach ($product_option['product_option_value'] as $product_option_value) {
                 $product_option_value_data[] = array('product_option_value_id' => $product_option_value['product_option_value_id'], 'option_value_id' => $product_option_value['option_value_id'], 'quantity' => $product_option_value['quantity'], 'subtract' => $product_option_value['subtract'], 'price' => $product_option_value['price'], 'price_prefix' => $product_option_value['price_prefix'], 'points' => $product_option_value['points'], 'points_prefix' => $product_option_value['points_prefix'], 'weight' => $product_option_value['weight'], 'weight_prefix' => $product_option_value['weight_prefix']);
             }
         }
         $data['product_options'][] = array('product_option_id' => $product_option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $product_option['option_id'], 'name' => $product_option['name'], 'type' => $product_option['type'], 'value' => isset($product_option['value']) ? $product_option['value'] : '', 'required' => $product_option['required']);
     }
     $data['option_values'] = array();
     foreach ($data['product_options'] as $product_option) {
         if ($product_option['type'] == 'select' || $product_option['type'] == 'radio' || $product_option['type'] == 'checkbox' || $product_option['type'] == 'image') {
             if (!isset($data['option_values'][$product_option['option_id']])) {
                 $data['option_values'][$product_option['option_id']] = $this->model_catalog_option->getOptionValues($product_option['option_id']);
             }
         }
     }
     $this->load->model('customer/customer_group');
     $data['customer_groups'] = $this->model_customer_customer_group->getCustomerGroups();
     if (isset($this->request->post['product_discount'])) {
         $product_discounts = $this->request->post['product_discount'];
     } elseif (isset($this->request->get['product_id'])) {
         $product_discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);
         //+mod by yp start
         foreach ($product_discounts as $_did => $_d) {
             $product_discounts[$_did]['scheme_id'] = isset($all_sub_schemes['discount'][$_d['product_discount_id']]) && $all_sub_schemes['discount'][$_d['product_discount_id']] ? $all_sub_schemes['discount'][$_d['product_discount_id']] : '0';
         }
         //+mod by yp end
     } else {
         $product_discounts = array();
     }
     $data['product_discounts'] = array();
     foreach ($product_discounts as $product_discount) {
         $data['product_discounts'][] = array('product_discount_id' => isset($product_discount['product_discount_id']) ? $product_discount['product_discount_id'] : '', 'scheme_id' => isset($product_discount['scheme_id']) ? $product_discount['scheme_id'] : '0', 'customer_group_id' => $product_discount['customer_group_id'], 'quantity' => $product_discount['quantity'], 'priority' => $product_discount['priority'], 'price' => $product_discount['price'], 'date_start' => $product_discount['date_start'] != '0000-00-00' ? $product_discount['date_start'] : '', 'date_end' => $product_discount['date_end'] != '0000-00-00' ? $product_discount['date_end'] : '');
     }
     if (isset($this->request->post['product_special'])) {
         $product_specials = $this->request->post['product_special'];
     } elseif (isset($this->request->get['product_id'])) {
         $product_specials = $this->model_catalog_product->getProductSpecials($this->request->get['product_id']);
         //+mod by yp start
         foreach ($product_specials as $_did => $_d) {
             $product_specials[$_did]['scheme_id'] = isset($all_sub_schemes['special'][$_d['product_special_id']]) && $all_sub_schemes['special'][$_d['product_special_id']] ? $all_sub_schemes['special'][$_d['product_special_id']] : '0';
         }
         //+mod by yp end
     } else {
         $product_specials = array();
     }
     $data['product_specials'] = array();
     foreach ($product_specials as $product_special) {
         $data['product_specials'][] = array('product_special_id' => isset($product_special['product_special_id']) ? $product_special['product_special_id'] : '', 'scheme_id' => isset($product_special['scheme_id']) ? $product_special['scheme_id'] : '0', 'customer_group_id' => $product_special['customer_group_id'], 'priority' => $product_special['priority'], 'price' => $product_special['price'], 'date_start' => $product_special['date_start'] != '0000-00-00' ? $product_special['date_start'] : '', 'date_end' => $product_special['date_end'] != '0000-00-00' ? $product_special['date_end'] : '');
     }
     // Images
     if (isset($this->request->post['product_image'])) {
         $product_images = $this->request->post['product_image'];
     } elseif (isset($this->request->get['product_id'])) {
         $product_images = $this->model_catalog_product->getProductImages($this->request->get['product_id']);
     } else {
         $product_images = array();
     }
     $data['product_images'] = array();
     foreach ($product_images as $product_image) {
         if (is_file(DIR_IMAGE . $product_image['image'])) {
             $image = $product_image['image'];
             $thumb = $product_image['image'];
         } else {
             $image = '';
             $thumb = 'no_image.png';
         }
         $data['product_images'][] = array('image' => $image, 'thumb' => $this->model_tool_image->resize($thumb, 100, 100), 'sort_order' => $product_image['sort_order']);
     }
     // Downloads
     $this->load->model('catalog/download');
     if (isset($this->request->post['product_download'])) {
         $product_downloads = $this->request->post['product_download'];
     } elseif (isset($this->request->get['product_id'])) {
         $product_downloads = $this->model_catalog_product->getProductDownloads($this->request->get['product_id']);
     } else {
         $product_downloads = array();
     }
     $data['product_downloads'] = array();
     foreach ($product_downloads as $download_id) {
         $download_info = $this->model_catalog_download->getDownload($download_id);
         if ($download_info) {
             $data['product_downloads'][] = array('download_id' => $download_info['download_id'], 'name' => $download_info['name']);
         }
     }
     if (isset($this->request->post['product_related'])) {
         $products = $this->request->post['product_related'];
     } elseif (isset($this->request->get['product_id'])) {
         $products = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
     } else {
         $products = array();
     }
     $data['product_relateds'] = array();
     foreach ($products as $product_id) {
         $related_info = $this->model_catalog_product->getProduct($product_id);
         if ($related_info) {
             $data['product_relateds'][] = array('product_id' => $related_info['product_id'], 'name' => $related_info['name']);
         }
     }
     if (isset($this->request->post['points'])) {
         $data['points'] = $this->request->post['points'];
     } elseif (!empty($product_info)) {
         $data['points'] = $product_info['points'];
     } else {
         $data['points'] = '';
     }
     if (isset($this->request->post['product_reward'])) {
         $data['product_reward'] = $this->request->post['product_reward'];
     } elseif (isset($this->request->get['product_id'])) {
         $data['product_reward'] = $this->model_catalog_product->getProductRewards($this->request->get['product_id']);
     } else {
         $data['product_reward'] = array();
     }
     if (isset($this->request->post['product_layout'])) {
         $data['product_layout'] = $this->request->post['product_layout'];
     } elseif (isset($this->request->get['product_id'])) {
         $data['product_layout'] = $this->model_catalog_product->getProductLayouts($this->request->get['product_id']);
     } else {
         $data['product_layout'] = array();
     }
     $this->load->model('design/layout');
     $data['layouts'] = $this->model_design_layout->getLayouts();
     //+mod by yp start
     $data['do_edit'] = $_do_edit;
     if ($_do_edit) {
         $data['link_commission_tab'] = mta_jsstr($this->url->link('mta/mta_pds/product_commission', 'token=' . $this->session->data['token'] . '&product_id=' . $data['product_id'], 'SSL'));
     }
     //+mod by yp end
     $data['header'] = $this->load->controller('common/header');
     $data['column_left'] = $this->load->controller('common/column_left');
     $data['footer'] = $this->load->controller('common/footer');
     $this->response->setOutput($this->load->view('catalog/product_form.tpl', $data));
 }
コード例 #4
0
ファイル: manufacturer.php プロジェクト: pedrocones/store
 protected function getForm()
 {
     //+mod by yp start
     $__cl = strtolower(get_class($this));
     preg_match("/^controller(?:(?:catalog)|(?:marketing))(.+)\$/", $__cl, $__ar);
     $data['page_type'] = $__ar[1];
     $etype = $data['page_type'] === 'coupon' ? $data['page_type'] : substr($data['page_type'], 0, 1);
     if (isset($this->request->get[$data['page_type'] . '_id']) && $this->request->get[$data['page_type'] . '_id']) {
         $this->language->load('mta/mta_pds');
         $data['tab_commission'] = mta_jsstr($this->language->get('tab_commission'));
         $data['tab_general_added'] = mta_jsstr($this->language->get('tab_general_added'));
         $data['mta_do_edit'] = true;
         $data['mta_pds_url'] = mta_jsstr($this->url->link('mta/mta_pds', 'token=' . $this->session->data['token'] . '&type=' . $etype . '&id=' . intval($this->request->get[$data['page_type'] . '_id']), 'SSL'));
     }
     //+mod by yp end
     $data['heading_title'] = $this->language->get('heading_title');
     $data['text_form'] = !isset($this->request->get['manufacturer_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
     $data['text_enabled'] = $this->language->get('text_enabled');
     $data['text_disabled'] = $this->language->get('text_disabled');
     $data['text_default'] = $this->language->get('text_default');
     $data['text_percent'] = $this->language->get('text_percent');
     $data['text_amount'] = $this->language->get('text_amount');
     $data['entry_name'] = $this->language->get('entry_name');
     $data['entry_store'] = $this->language->get('entry_store');
     $data['entry_keyword'] = $this->language->get('entry_keyword');
     $data['entry_image'] = $this->language->get('entry_image');
     $data['entry_sort_order'] = $this->language->get('entry_sort_order');
     $data['entry_customer_group'] = $this->language->get('entry_customer_group');
     $data['help_keyword'] = $this->language->get('help_keyword');
     $data['button_save'] = $this->language->get('button_save');
     $data['button_cancel'] = $this->language->get('button_cancel');
     if (isset($this->error['warning'])) {
         $data['error_warning'] = $this->error['warning'];
     } else {
         $data['error_warning'] = '';
     }
     if (isset($this->error['name'])) {
         $data['error_name'] = $this->error['name'];
     } else {
         $data['error_name'] = '';
     }
     if (isset($this->error['keyword'])) {
         $data['error_keyword'] = $this->error['keyword'];
     } else {
         $data['error_keyword'] = '';
     }
     $url = '';
     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'];
     }
     $data['breadcrumbs'] = array();
     $data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL'));
     $data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('catalog/manufacturer', 'token=' . $this->session->data['token'] . $url, 'SSL'));
     if (!isset($this->request->get['manufacturer_id'])) {
         $data['action'] = $this->url->link('catalog/manufacturer/add', 'token=' . $this->session->data['token'] . $url, 'SSL');
     } else {
         $data['action'] = $this->url->link('catalog/manufacturer/edit', 'token=' . $this->session->data['token'] . '&manufacturer_id=' . $this->request->get['manufacturer_id'] . $url, 'SSL');
     }
     $data['cancel'] = $this->url->link('catalog/manufacturer', 'token=' . $this->session->data['token'] . $url, 'SSL');
     if (isset($this->request->get['manufacturer_id']) && $this->request->server['REQUEST_METHOD'] != 'POST') {
         $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
     }
     $data['token'] = $this->session->data['token'];
     if (isset($this->request->post['name'])) {
         $data['name'] = $this->request->post['name'];
     } elseif (!empty($manufacturer_info)) {
         $data['name'] = $manufacturer_info['name'];
     } else {
         $data['name'] = '';
     }
     $this->load->model('setting/store');
     $data['stores'] = $this->model_setting_store->getStores();
     if (isset($this->request->post['manufacturer_store'])) {
         $data['manufacturer_store'] = $this->request->post['manufacturer_store'];
     } elseif (isset($this->request->get['manufacturer_id'])) {
         $data['manufacturer_store'] = $this->model_catalog_manufacturer->getManufacturerStores($this->request->get['manufacturer_id']);
     } else {
         $data['manufacturer_store'] = array(0);
     }
     if (isset($this->request->post['keyword'])) {
         $data['keyword'] = $this->request->post['keyword'];
     } elseif (!empty($manufacturer_info)) {
         $data['keyword'] = $manufacturer_info['keyword'];
     } else {
         $data['keyword'] = '';
     }
     if (isset($this->request->post['image'])) {
         $data['image'] = $this->request->post['image'];
     } elseif (!empty($manufacturer_info)) {
         $data['image'] = $manufacturer_info['image'];
     } else {
         $data['image'] = '';
     }
     $this->load->model('tool/image');
     if (isset($this->request->post['image']) && is_file(DIR_IMAGE . $this->request->post['image'])) {
         $data['thumb'] = $this->model_tool_image->resize($this->request->post['image'], 100, 100);
     } elseif (!empty($manufacturer_info) && is_file(DIR_IMAGE . $manufacturer_info['image'])) {
         $data['thumb'] = $this->model_tool_image->resize($manufacturer_info['image'], 100, 100);
     } else {
         $data['thumb'] = $this->model_tool_image->resize('no_image.png', 100, 100);
     }
     $data['placeholder'] = $this->model_tool_image->resize('no_image.png', 100, 100);
     if (isset($this->request->post['sort_order'])) {
         $data['sort_order'] = $this->request->post['sort_order'];
     } elseif (!empty($manufacturer_info)) {
         $data['sort_order'] = $manufacturer_info['sort_order'];
     } else {
         $data['sort_order'] = '';
     }
     $data['header'] = $this->load->controller('common/header');
     $data['column_left'] = $this->load->controller('common/column_left');
     $data['footer'] = $this->load->controller('common/footer');
     $this->response->setOutput($this->load->view('catalog/manufacturer_form.tpl', $data));
 }
コード例 #5
0
ファイル: coupon.php プロジェクト: pedrocones/store
 protected function getForm()
 {
     //+mod by yp start
     $__cl = strtolower(get_class($this));
     preg_match("/^controller(?:(?:catalog)|(?:marketing))(.+)\$/", $__cl, $__ar);
     $data['page_type'] = $__ar[1];
     $etype = $data['page_type'] === 'coupon' ? $data['page_type'] : substr($data['page_type'], 0, 1);
     if (isset($this->request->get[$data['page_type'] . '_id']) && $this->request->get[$data['page_type'] . '_id']) {
         $this->language->load('mta/mta_pds');
         $data['tab_commission'] = mta_jsstr($this->language->get('tab_commission'));
         $data['tab_general_added'] = mta_jsstr($this->language->get('tab_general_added'));
         $data['mta_do_edit'] = true;
         $data['mta_pds_url'] = mta_jsstr($this->url->link('mta/mta_pds', 'token=' . $this->session->data['token'] . '&type=' . $etype . '&id=' . intval($this->request->get[$data['page_type'] . '_id']), 'SSL'));
     }
     //+mod by yp end
     //+mod by yp cft start
     if ($this->config->get('cftyp_status')) {
         $data['cftyp_status'] = true;
         $data['text_none'] = $this->language->get('text_none');
         $data['entry_affiliate'] = $this->language->get('entry_affiliate');
         $data['help_affiliate'] = $this->language->get('help_affiliate');
         $data['text_clear'] = $this->language->get('text_clear');
         $this->load->model('marketing/cftyp');
     } else {
         $data['cftyp_status'] = false;
     }
     //+mod by yp cft end
     $data['heading_title'] = $this->language->get('heading_title');
     $data['text_form'] = !isset($this->request->get['coupon_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
     $data['text_enabled'] = $this->language->get('text_enabled');
     $data['text_disabled'] = $this->language->get('text_disabled');
     $data['text_yes'] = $this->language->get('text_yes');
     $data['text_no'] = $this->language->get('text_no');
     $data['text_percent'] = $this->language->get('text_percent');
     $data['text_amount'] = $this->language->get('text_amount');
     $data['entry_name'] = $this->language->get('entry_name');
     $data['entry_description'] = $this->language->get('entry_description');
     $data['entry_code'] = $this->language->get('entry_code');
     $data['entry_discount'] = $this->language->get('entry_discount');
     $data['entry_logged'] = $this->language->get('entry_logged');
     $data['entry_shipping'] = $this->language->get('entry_shipping');
     $data['entry_type'] = $this->language->get('entry_type');
     $data['entry_total'] = $this->language->get('entry_total');
     $data['entry_category'] = $this->language->get('entry_category');
     $data['entry_product'] = $this->language->get('entry_product');
     $data['entry_date_start'] = $this->language->get('entry_date_start');
     $data['entry_date_end'] = $this->language->get('entry_date_end');
     $data['entry_uses_total'] = $this->language->get('entry_uses_total');
     $data['entry_uses_customer'] = $this->language->get('entry_uses_customer');
     $data['entry_status'] = $this->language->get('entry_status');
     $data['help_code'] = $this->language->get('help_code');
     $data['help_type'] = $this->language->get('help_type');
     $data['help_logged'] = $this->language->get('help_logged');
     $data['help_total'] = $this->language->get('help_total');
     $data['help_category'] = $this->language->get('help_category');
     $data['help_product'] = $this->language->get('help_product');
     $data['help_uses_total'] = $this->language->get('help_uses_total');
     $data['help_uses_customer'] = $this->language->get('help_uses_customer');
     $data['button_save'] = $this->language->get('button_save');
     $data['button_cancel'] = $this->language->get('button_cancel');
     $data['tab_general'] = $this->language->get('tab_general');
     $data['tab_history'] = $this->language->get('tab_history');
     $data['token'] = $this->session->data['token'];
     if (isset($this->request->get['coupon_id'])) {
         $data['coupon_id'] = $this->request->get['coupon_id'];
     } else {
         $data['coupon_id'] = 0;
     }
     if (isset($this->error['warning'])) {
         $data['error_warning'] = $this->error['warning'];
     } else {
         $data['error_warning'] = '';
     }
     if (isset($this->error['name'])) {
         $data['error_name'] = $this->error['name'];
     } else {
         $data['error_name'] = '';
     }
     if (isset($this->error['code'])) {
         $data['error_code'] = $this->error['code'];
     } else {
         $data['error_code'] = '';
     }
     if (isset($this->error['date_start'])) {
         $data['error_date_start'] = $this->error['date_start'];
     } else {
         $data['error_date_start'] = '';
     }
     if (isset($this->error['date_end'])) {
         $data['error_date_end'] = $this->error['date_end'];
     } else {
         $data['error_date_end'] = '';
     }
     $url = '';
     if (isset($this->request->get['page'])) {
         $url .= '&page=' . $this->request->get['page'];
     }
     if (isset($this->request->get['sort'])) {
         $url .= '&sort=' . $this->request->get['sort'];
     }
     if (isset($this->request->get['order'])) {
         $url .= '&order=' . $this->request->get['order'];
     }
     $data['breadcrumbs'] = array();
     $data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL'));
     $data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('marketing/coupon', 'token=' . $this->session->data['token'] . $url, 'SSL'));
     if (!isset($this->request->get['coupon_id'])) {
         $data['action'] = $this->url->link('marketing/coupon/add', 'token=' . $this->session->data['token'] . $url, 'SSL');
     } else {
         $data['action'] = $this->url->link('marketing/coupon/edit', 'token=' . $this->session->data['token'] . '&coupon_id=' . $this->request->get['coupon_id'] . $url, 'SSL');
     }
     $data['cancel'] = $this->url->link('marketing/coupon', 'token=' . $this->session->data['token'] . $url, 'SSL');
     if (isset($this->request->get['coupon_id']) && !$this->request->server['REQUEST_METHOD'] != 'POST') {
         $coupon_info = $this->model_marketing_coupon->getCoupon($this->request->get['coupon_id']);
     }
     if (isset($this->request->post['name'])) {
         $data['name'] = $this->request->post['name'];
     } elseif (!empty($coupon_info)) {
         $data['name'] = $coupon_info['name'];
     } else {
         $data['name'] = '';
     }
     if (isset($this->request->post['code'])) {
         $data['code'] = $this->request->post['code'];
     } elseif (!empty($coupon_info)) {
         $data['code'] = $coupon_info['code'];
     } else {
         $data['code'] = '';
     }
     if (isset($this->request->post['type'])) {
         $data['type'] = $this->request->post['type'];
     } elseif (!empty($coupon_info)) {
         $data['type'] = $coupon_info['type'];
     } else {
         $data['type'] = '';
     }
     if (isset($this->request->post['discount'])) {
         $data['discount'] = $this->request->post['discount'];
     } elseif (!empty($coupon_info)) {
         $data['discount'] = $coupon_info['discount'];
     } else {
         $data['discount'] = '';
     }
     if (isset($this->request->post['logged'])) {
         $data['logged'] = $this->request->post['logged'];
     } elseif (!empty($coupon_info)) {
         $data['logged'] = $coupon_info['logged'];
     } else {
         $data['logged'] = '';
     }
     if (isset($this->request->post['shipping'])) {
         $data['shipping'] = $this->request->post['shipping'];
     } elseif (!empty($coupon_info)) {
         $data['shipping'] = $coupon_info['shipping'];
     } else {
         $data['shipping'] = '';
     }
     if (isset($this->request->post['total'])) {
         $data['total'] = $this->request->post['total'];
     } elseif (!empty($coupon_info)) {
         $data['total'] = $coupon_info['total'];
     } else {
         $data['total'] = '';
     }
     if (isset($this->request->post['coupon_product'])) {
         $products = $this->request->post['coupon_product'];
     } elseif (isset($this->request->get['coupon_id'])) {
         $products = $this->model_marketing_coupon->getCouponProducts($this->request->get['coupon_id']);
     } else {
         $products = array();
     }
     $this->load->model('catalog/product');
     $data['coupon_product'] = array();
     foreach ($products as $product_id) {
         $product_info = $this->model_catalog_product->getProduct($product_id);
         if ($product_info) {
             $data['coupon_product'][] = array('product_id' => $product_info['product_id'], 'name' => $product_info['name']);
         }
     }
     if (isset($this->request->post['coupon_category'])) {
         $categories = $this->request->post['coupon_category'];
     } elseif (isset($this->request->get['coupon_id'])) {
         $categories = $this->model_marketing_coupon->getCouponCategories($this->request->get['coupon_id']);
     } else {
         $categories = array();
     }
     $this->load->model('catalog/category');
     $data['coupon_category'] = array();
     foreach ($categories as $category_id) {
         $category_info = $this->model_catalog_category->getCategory($category_id);
         if ($category_info) {
             $data['coupon_category'][] = array('category_id' => $category_info['category_id'], 'name' => ($category_info['path'] ? $category_info['path'] . ' &gt; ' : '') . $category_info['name']);
         }
     }
     if (isset($this->request->post['date_start'])) {
         $data['date_start'] = $this->request->post['date_start'];
     } elseif (!empty($coupon_info)) {
         $data['date_start'] = $coupon_info['date_start'] != '0000-00-00' ? $coupon_info['date_start'] : '';
     } else {
         $data['date_start'] = date('Y-m-d', time());
     }
     if (isset($this->request->post['date_end'])) {
         $data['date_end'] = $this->request->post['date_end'];
     } elseif (!empty($coupon_info)) {
         $data['date_end'] = $coupon_info['date_end'] != '0000-00-00' ? $coupon_info['date_end'] : '';
     } else {
         $data['date_end'] = date('Y-m-d', strtotime('+1 month'));
     }
     if (isset($this->request->post['uses_total'])) {
         $data['uses_total'] = $this->request->post['uses_total'];
     } elseif (!empty($coupon_info)) {
         $data['uses_total'] = $coupon_info['uses_total'];
     } else {
         $data['uses_total'] = 1;
     }
     if (isset($this->request->post['uses_customer'])) {
         $data['uses_customer'] = $this->request->post['uses_customer'];
     } elseif (!empty($coupon_info)) {
         $data['uses_customer'] = $coupon_info['uses_customer'];
     } else {
         $data['uses_customer'] = 1;
     }
     if (isset($this->request->post['status'])) {
         $data['status'] = $this->request->post['status'];
     } elseif (!empty($coupon_info)) {
         $data['status'] = $coupon_info['status'];
     } else {
         $data['status'] = true;
     }
     $data['header'] = $this->load->controller('common/header');
     $data['column_left'] = $this->load->controller('common/column_left');
     $data['footer'] = $this->load->controller('common/footer');
     //+mod by yp cft start
     if ($this->config->get('cftyp_status')) {
         if (isset($this->request->post['cftyp_affiliate'])) {
             $data['cftyp_affiliate'] = $this->request->post['cftyp_affiliate'];
         } elseif (!empty($coupon_info)) {
             $data['cftyp_affiliate'] = $coupon_info['cftyp_affiliate'];
         } else {
             $data['cftyp_affiliate'] = '0';
         }
         if ($data['cftyp_affiliate']) {
             $_c = explode('_', $data['cftyp_affiliate']);
             if (sizeof($_c) < 2) {
                 array_unshift($_c, 'a');
             }
             if ($_c[0] == 'a') {
                 $this->load->model('marketing/affiliate');
                 $_aff = $this->model_marketing_affiliate->getAffiliate($_c[1]);
                 $data['cftyp_affiliate_name'] = $_aff['firstname'] . ' ' . $_aff['lastname'] . '(' . $_aff['email'] . ')';
             } else {
                 $_res = $this->db->query("SELECT `name` FROM " . DB_PREFIX . "marketing WHERE marketing_id = '" . (int) $_c[1] . "'");
                 $data['cftyp_affiliate_name'] = $_res->row['name'];
             }
         } else {
             $data['cftyp_affiliate_name'] = '';
         }
     }
     //+mod by yp cft end
     $this->response->setOutput($this->load->view('marketing/coupon_form.tpl', $data));
 }