示例#1
0
 public function editCustomer($customer_id, $data)
 {
     if (!isset($data['custom_field'])) {
         $data['custom_field'] = array();
     }
     $this->db->query("UPDATE " . DB_PREFIX . "customer SET customer_group_id = '" . (int) $data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : '') . "', newsletter = '" . (int) $data['newsletter'] . "', status = '" . (int) $data['status'] . "', approved = '" . (int) $data['approved'] . "', safe = '" . (int) $data['safe'] . "' WHERE customer_id = '" . (int) $customer_id . "'");
     //+mod by yp start
     if (isset($data['affiliate_id']) && mta_check_int($data['affiliate_id'])) {
         $this->db->query("UPDATE " . DB_PREFIX . "customer SET affiliate_id='" . (int) $data['affiliate_id'] . "' where customer_id='" . (int) $customer_id . "'");
     }
     //+mod by yp end
     if ($data['password']) {
         $this->db->query("UPDATE " . DB_PREFIX . "customer SET salt = '" . $this->db->escape($salt = token(9)) . "', password = '******'password'])))) . "' WHERE customer_id = '" . (int) $customer_id . "'");
     }
     $this->db->query("DELETE FROM " . DB_PREFIX . "address WHERE customer_id = '" . (int) $customer_id . "'");
     if (isset($data['address'])) {
         foreach ($data['address'] as $address) {
             if (!isset($address['custom_field'])) {
                 $address['custom_field'] = array();
             }
             $this->db->query("INSERT INTO " . DB_PREFIX . "address SET address_id = '" . (int) $address['address_id'] . "', customer_id = '" . (int) $customer_id . "', firstname = '" . $this->db->escape($address['firstname']) . "', lastname = '" . $this->db->escape($address['lastname']) . "', company = '" . $this->db->escape($address['company']) . "', address_1 = '" . $this->db->escape($address['address_1']) . "', address_2 = '" . $this->db->escape($address['address_2']) . "', city = '" . $this->db->escape($address['city']) . "', postcode = '" . $this->db->escape($address['postcode']) . "', country_id = '" . (int) $address['country_id'] . "', zone_id = '" . (int) $address['zone_id'] . "', custom_field = '" . $this->db->escape(isset($address['custom_field']) ? json_encode($address['custom_field']) : '') . "'");
             if (isset($address['default'])) {
                 $address_id = $this->db->getLastId();
                 $this->db->query("UPDATE " . DB_PREFIX . "customer SET address_id = '" . (int) $address_id . "' WHERE customer_id = '" . (int) $customer_id . "'");
             }
         }
     }
 }
示例#2
0
 public function moveFromScheme($from, $to, $mods = array("''"), $parent = false)
 {
     if (!mta_check_int($from) || !mta_check_int($to)) {
         return false;
     }
     if ($from && !$this->_checkId($from) || $to && !$this->_checkId($to)) {
         return false;
     }
     $tbl = DB_PREFIX . 'mta_product' . ($parent === true ? '' : '_affiliate');
     $query = "update {$tbl} set mta_scheme_id=" . ($to ? "'{$to}'" : "null") . " where mta_scheme_id" . ($from ? "='{$from}'" : " is null") . " and price_mod_type in (" . implode(',', $mods) . ")";
     $this->db->query($query);
     return $this->db->countAffected();
 }
示例#3
0
 public function getAffiliate($affiliate_id, $get_parent_name = false)
 {
     if (!mta_check_int($affiliate_id) || $affiliate_id < 1) {
         return false;
     }
     $res = $this->db->query("select affiliate_id as id, mta_scheme_id as scheme_id, parent_affiliate_id, all_parent_ids, level_original from " . DB_PREFIX . self::$table . " where affiliate_id='{$affiliate_id}'");
     if ($res->num_rows < 1) {
         return false;
     }
     $out = $res->row;
     if ($get_parent_name && $out['parent_affiliate_id']) {
         $res = $this->db->query("select concat(firstname, ' ', lastname) as n from " . DB_PREFIX . "affiliate where affiliate_id='" . $out['parent_affiliate_id'] . "'");
         $out['parent_affiliate_name'] = $res->row['n'];
     }
     $out['parents'] = $out['all_parent_ids'] ? explode(',', $out['all_parent_ids']) : array();
     return $out;
 }
示例#4
0
 protected function &setScheme($s)
 {
     $this->scheme = array();
     if (!isset($s['id']) || !mta_check_int($s['id']) || $s['id'] < 1) {
         $this->scheme['error'] = 'Invalid ID';
         return $this->scheme;
     }
     $this->scheme_id = $s['id'];
     foreach (array('is_default', 'before_shipping') as $_k) {
         $this->scheme[$_k] = (bool) $s[$_k];
     }
     foreach (array('max_levels', 'eternal') as $_k) {
         $this->scheme[$_k] = (int) $s[$_k];
     }
     foreach ($s['_autoapprove'] as $i => $v) {
         $s['_autoapprove'][$i] = (bool) $v;
     }
     foreach ($s['_autoadd'] as $i => $v) {
         foreach ($v as $i2 => $v2) {
             $v[$i2] = (bool) $v2;
         }
         $s['_autoadd'][$i] = $v;
     }
     foreach ($s['_commissions'] as $i => $v) {
         foreach ($v as $i2 => $v2) {
             $v[$i2] = mta_float4($v2);
         }
         $s['_commissions'][$i] = $v;
     }
     foreach ($s as $k => $v) {
         if (!isset($this->scheme[$k])) {
             $this->scheme[$k] = $v;
         }
     }
     $dsid = $this->getDefaultSchemeId();
     if (!$dsid && !$this->scheme['is_default']) {
         $this->scheme['is_default'] = true;
     }
     //if($this->scheme['commission_type'] != 'percentage') $this->scheme['is_default'] = false;
     return $this->scheme;
 }
示例#5
0
文件: mta.php 项目: pedrocones/store
 private function _post_to_scheme(&$p)
 {
     foreach (array('name', 'max_levels') as $_v) {
         if (!isset($p[$_v])) {
             return false;
         }
     }
     if (utf8_strlen($p['name']) < 1 || utf8_strlen($p['name']) > 100 || !mta_check_int($p['max_levels'])) {
         return false;
     }
     if (!isset($p['description'])) {
         $p['description'] = '';
     }
     if (!isset($p['is_default']) || !mta_check_bool($p['is_default'])) {
         $p['is_default'] = 0;
     }
     if (!isset($p['commission_type']) || !in_array($p['commission_type'], array('fixed', 'percentage'))) {
         $p['commission_type'] = 'percentage';
     }
     if (!isset($p['before_shipping']) || !mta_check_bool($p['before_shipping'])) {
         $p['before_shipping'] = 1;
     }
     if (!isset($p['eternal']) || !mta_check_int($p['eternal'])) {
         $p['eternal'] = 0;
     }
     $scheme = array();
     $_levels = array('autoadd' => array(), 'commission' => array());
     $autoapprove = array();
     foreach ($p as $k => $v) {
         if (preg_match("/^((?:tiers)|(?:level))(\\d+)_(.+)\$/", $k, $_lAr)) {
             if ($_lAr[1] == 'tiers') {
                 if (!preg_match("/^\\d+(\\.\\d+)?\$/s", $v)) {
                     return false;
                 }
                 $tier = $_lAr[2];
                 $_lAr = explode('_', $_lAr[3]);
                 $_type = $_lAr[1];
                 preg_match("/\\d+\$/", $_lAr[0], $_lAr);
                 $level = $_lAr[0];
                 if (!isset($_levels[$_type][$tier])) {
                     $_levels[$_type][$tier] = array();
                 }
                 $_levels[$_type][$tier][$level] = $v;
             } else {
                 $autoapprove[$_lAr[2]] = $v;
             }
         } else {
             $scheme[$k] = $v;
         }
     }
     //if($scheme['commission_type'] == 'fixed') $scheme['is_default'] = 0;
     if ($scheme['eternal'] > $scheme['max_levels']) {
         $scheme['eternal'] = 0;
     }
     $scheme['_autoapprove'] = mta_array_a2n($autoapprove);
     if (sizeof($scheme['_autoapprove']) != $scheme['max_levels']) {
         return false;
     }
     foreach ($scheme['_autoapprove'] as $_i => $_v) {
         if (!mta_check_bool($_v)) {
             $scheme['_autoapprove'][$_i] = 1;
         }
     }
     foreach ($_levels as $k => $v) {
         $v = mta_array_a2n($v);
         if (sizeof($v) != $scheme['max_levels']) {
             return false;
         }
         foreach ($v as $i => $v2) {
             $v[$i] = mta_array_a2n($v2);
             if (sizeof($v[$i]) != $i + 1) {
                 return false;
             }
             foreach ($v[$i] as $_i => $_v) {
                 if ($k == 'autoadd') {
                     if (!mta_check_bool($_v)) {
                         $v[$i][$_i] = 1;
                     }
                 } else {
                     if ($k == 'commission') {
                         if (!mta_check_float($_v)) {
                             return false;
                         }
                     } else {
                         return false;
                     }
                 }
             }
         }
         $_levels[$k] = $v;
     }
     $scheme['_commissions'] = $_levels['commission'];
     $scheme['_autoadd'] = $_levels['autoadd'];
     $this->scheme =& $this->model_mta_mta_scheme->setScheme($scheme);
     return isset($this->scheme['error']) ? false : true;
 }
示例#6
0
 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));
 }
示例#7
0
 public function index()
 {
     $this->load->language('report/affiliate');
     $filter_balance = isset($this->request->get['filter_balance']) && mta_check_int($this->request->get['filter_balance']) ? $this->request->get['filter_balance'] : 0;
     //+mod by yp
     $this->document->setTitle($this->language->get('heading_title'));
     if (isset($this->request->get['filter_date_start'])) {
         $filter_date_start = $this->request->get['filter_date_start'];
     } else {
         $filter_date_start = '';
     }
     if (isset($this->request->get['filter_date_end'])) {
         $filter_date_end = $this->request->get['filter_date_end'];
     } else {
         $filter_date_end = '';
     }
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     $url = '';
     if (isset($this->request->get['filter_date_start'])) {
         $url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
     }
     if (isset($this->request->get['filter_date_end'])) {
         $url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
     }
     if (isset($this->request->get['page'])) {
         $url .= '&page=' . $this->request->get['page'];
     }
     if (isset($this->request->get['filter_balance'])) {
         $url .= '&filter_balance=' . $this->request->get['filter_balance'];
     }
     //+mod by yp
     $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('report/affiliate', 'token=' . $this->session->data['token'] . $url, 'SSL'));
     $this->load->model('report/affiliate');
     $data['affiliates'] = array();
     $filter_data = array('filter_balance' => $filter_balance, 'filter_date_start' => $filter_date_start, 'filter_date_end' => $filter_date_end, 'start' => ($page - 1) * $this->config->get('config_limit_admin'), 'limit' => $this->config->get('config_limit_admin'));
     $affiliate_total = $this->model_report_affiliate->getTotalCommission($filter_data);
     $results = $this->model_report_affiliate->getCommission($filter_data);
     $affiliate_ids = array();
     //+mod by yp
     foreach ($results as $result) {
         $affiliate_ids[] = intval($result['affiliate_id']);
         //+mod by yp
         $data['affiliates'][] = array('affiliate_id' => intval($result['affiliate_id']), 'commission' => $this->currency->format($result['commission'], $this->config->get('config_currency')), 'total_earnings' => $this->currency->format(isset($result['total_earnings']) ? $result['total_earnings'] : 0, $this->config->get('config_currency')), 'affiliate' => $result['affiliate'], 'email' => $result['email'], 'status' => $result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled'), 'commission' => $this->currency->format($result['commission'], $this->config->get('config_currency')), 'orders' => $result['orders'], 'total' => $this->currency->format($result['total'], $this->config->get('config_currency')), 'edit' => $this->url->link('marketing/affiliate/edit', 'token=' . $this->session->data['token'] . '&affiliate_id=' . $result['affiliate_id'] . $url, 'SSL'));
     }
     //+mod by yp start
     $this->load->model('mta/mta_affiliate');
     $data['payout_accounts'] = $this->model_mta_mta_affiliate->getPayoutAccounts($affiliate_ids);
     foreach (array('column_current_balance', 'text_no_payout_account', 'entry_current_balance', 'column_total_sales') as $_v) {
         $data[$_v] = $this->language->get($_v);
     }
     //+mod by yp end
     $data['heading_title'] = $this->language->get('heading_title');
     $data['text_list'] = $this->language->get('text_list');
     $data['text_no_results'] = $this->language->get('text_no_results');
     $data['text_confirm'] = $this->language->get('text_confirm');
     $data['column_affiliate'] = $this->language->get('column_affiliate');
     $data['column_email'] = $this->language->get('column_email');
     $data['column_status'] = $this->language->get('column_status');
     $data['column_commission'] = $this->language->get('column_commission');
     $data['column_orders'] = $this->language->get('column_orders');
     $data['column_total'] = $this->language->get('column_total');
     $data['column_action'] = $this->language->get('column_action');
     $data['entry_date_start'] = $this->language->get('entry_date_start');
     $data['entry_date_end'] = $this->language->get('entry_date_end');
     $data['button_edit'] = $this->language->get('button_edit');
     $data['button_filter'] = $this->language->get('button_filter');
     $data['token'] = $this->session->data['token'];
     $url = '';
     if (isset($this->request->get['filter_date_start'])) {
         $url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
     }
     if (isset($this->request->get['filter_date_end'])) {
         $url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
     }
     if (isset($this->request->get['filter_balance'])) {
         $url .= '&filter_balance=' . $this->request->get['filter_balance'];
     }
     //+mod by yp
     $pagination = new Pagination();
     $pagination->total = $affiliate_total;
     $pagination->page = $page;
     $pagination->limit = $this->config->get('config_limit_admin');
     $pagination->url = $this->url->link('report/affiliate', 'token=' . $this->session->data['token'] . $url . '&page={page}', 'SSL');
     $data['pagination'] = $pagination->render();
     $data['results'] = sprintf($this->language->get('text_pagination'), $affiliate_total ? ($page - 1) * $this->config->get('config_limit_admin') + 1 : 0, ($page - 1) * $this->config->get('config_limit_admin') > $affiliate_total - $this->config->get('config_limit_admin') ? $affiliate_total : ($page - 1) * $this->config->get('config_limit_admin') + $this->config->get('config_limit_admin'), $affiliate_total, ceil($affiliate_total / $this->config->get('config_limit_admin')));
     $data['filter_date_start'] = $filter_date_start;
     $data['filter_date_end'] = $filter_date_end;
     $data['filter_balance'] = $filter_balance;
     //+mod by yp
     $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('report/affiliate.tpl', $data));
 }
示例#8
0
 public function setCustomerAffiliateId($customer_id, $affiliate_id, $force = false)
 {
     if (!mta_check_int($customer_id) || $customer_id < 1 || !mta_check_int($affiliate_id) || $affiliate_id < 1 || $force === false && $this->config->get('mta_ypx_db_perm')) {
         return false;
     }
     $affiliate_id = $this->getAcccAffiliateId($customer_id, $affiliate_id);
     if (!$affiliate_id) {
         return false;
     }
     $this->db->query("update " . DB_PREFIX . "customer set affiliate_id='{$affiliate_id}' where customer_id='{$customer_id}'");
     return intval($affiliate_id);
 }
示例#9
0
 public function move()
 {
     $_REQUEST['format'] = $_GET['format'] = 'raw';
     //+mod by yp mijoshop
     //from, to (id or 0), types=(all, p, a, pa, p_c, p_d, p_s)
     $this->language->load('mta/mta');
     if (!$this->user->hasPermission('modify', 'mta/mta')) {
         return $this->_jerror('permission');
     }
     foreach (array('from', 'to', 'types') as $_k) {
         if (!isset($this->request->request[$_k])) {
             return $this->_jerror('invalid_request');
         }
         ${$_k} = $this->request->request[$_k];
     }
     if (!mta_check_int($from) || !mta_check_int($to)) {
         return $this->_jerror('validation');
     }
     $_types = array('p', 'a', 'pa', 'p_c', 'p_d', 'p_s', 'pa_c', 'pa_d', 'pa_s');
     $types = preg_split("/\\s*,\\s*/", $types);
     foreach ($types as $i => $v) {
         if (!in_array($v, $_types)) {
             unset($types[$i]);
         }
     }
     $types = array_values(array_unique($types));
     $sz = sizeof($types);
     if (!$sz) {
         return $this->_jerror('validation');
     }
     if (in_array('a', $types)) {
         $this->load->model('mta/mta_affiliate');
         $_ret = $this->model_mta_mta_affiliate->moveFromScheme($from, $to);
         if ($sz < 2) {
             $this->response->setOutput($_ret !== false ? '1' : '0');
             return;
         }
     }
     $this->load->model('mta/mta_product_affiliate');
     $mod_types = array('c' => 'coupon', 's' => 'special', 'd' => 'discount');
     $mods_p = array();
     $mods_pa = array();
     foreach ($types as $type) {
         if (strlen($type) > 1 && substr($type, 0, 2) == 'pa') {
             $_mods =& $mods_pa;
         } else {
             $_mods =& $mods_p;
         }
         $_expl = explode('_', $type);
         if (sizeof($_expl) < 2) {
             $_mods[] = "''";
         } else {
             $_mods[] = "'" . $mod_types[$_expl[1]] . "'";
         }
     }
     if (sizeof($mods_p) > 0) {
         $_ret1 = $this->model_mta_mta_product_affiliate->moveFromScheme($from, $to, $mods_p, true);
     } else {
         $_ret1 = true;
     }
     if (sizeof($mods_pa) > 0) {
         $_ret2 = $this->model_mta_mta_product_affiliate->moveFromScheme($from, $to, $mods_pa);
     } else {
         $_ret2 = true;
     }
     $this->response->setOutput($_ret1 && $_ret2 ? '1' : '0');
 }
示例#10
0
 public function index()
 {
     $_REQUEST['format'] = $_GET['format'] = 'raw';
     //+mod by yp mijoshop
     $this->load->model('marketing/affiliate');
     $this->load->model('mta/mta_scheme');
     $r =& $this->request->request;
     if (isset($r['sSearch']) && utf8_strlen($r['sSearch']) > 0) {
         if (strpos($r['sSearch'], '@') === false) {
             $filter_name = $r['sSearch'];
         } else {
             $filter_email = $r['sSearch'];
         }
     }
     if (!isset($filter_name)) {
         $filter_name = null;
     }
     if (!isset($filter_email)) {
         $filter_email = null;
     }
     $filter_status = null;
     $filter_approved = null;
     $filter_date_added = null;
     if (isset($r['iSortCol_0']) && mta_check_int($r['iSortCol_0'])) {
         $ckey = $r['mDataProp_' . $r['iSortCol_0']];
         $sorts = array('name', 'email', 'status', 'approved', 'date_added', 'level');
         if (in_array($ckey, $sorts)) {
             $sort = $ckey;
             if ($sort == 'level') {
                 $sort = 'mta_a.level_original';
             } else {
                 if ($sort != 'name') {
                     $sort = 'a.' . $sort;
                 }
             }
         }
     }
     if (!isset($sort)) {
         $sort = 'name';
     }
     $order = isset($r['sSortDir_0']) && $r['sSortDir_0'] && strtolower($r['sSortDir_0']) != 'asc' ? 'DESC' : 'ASC';
     $dta = array('filter_name' => $filter_name, 'filter_email' => $filter_email, 'filter_status' => $filter_status, 'filter_approved' => $filter_approved, 'filter_date_added' => $filter_date_added, 'sort' => $sort, 'order' => $order, 'start' => isset($r['iDisplayStart']) && mta_check_int($r['iDisplayStart']) ? $r['iDisplayStart'] : 0, 'limit' => isset($r['iDisplayLength']) && mta_check_int($r['iDisplayLength']) ? $r['iDisplayLength'] : 25);
     if (isset($r['filter_ids'])) {
         $dta['filter_ids'] = $r['filter_ids'];
     }
     if (isset($r['ids'])) {
         $dta['ids'] = $r['ids'];
     }
     $out = array('sEcho' => (int) $r['sEcho'], 'aaData' => array());
     $out['iTotalRecords'] = (int) $this->model_marketing_affiliate->getTotalAffiliates();
     $out['iTotalDisplayRecords'] = (int) $this->model_marketing_affiliate->getTotalAffiliates($dta);
     $_s = $this->model_mta_mta_scheme->getSchemes(array('fields' => array('mta_scheme_id as id', 'scheme_name as n')));
     $schemes = array();
     foreach ($_s as $_s2) {
         $schemes[$_s2['id']] = $_s2['n'];
     }
     $results = $this->model_marketing_affiliate->getAffiliates($dta);
     foreach ($results as $result) {
         $out['aaData'][] = array('DT_RowId' => 'affiliate_dt-' . $result['affiliate_id'], 'DT_RowClass' => 'affiliate_dt_row', 'id' => $result['affiliate_id'], 'name' => $result['name'], 'email' => $result['email'], 'scheme' => $result['scheme_id'] && isset($schemes[$result['scheme_id']]) ? $schemes[$result['scheme_id']] : $this->language->get('text_default'), 'level' => $result['level'], 'balance' => $this->currency->format($result['balance'], $this->config->get('config_currency')), 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])));
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($out));
 }
示例#11
0
 public function eventEditProductPost($product_id)
 {
     $data = $this->config->get('_mta_product_data_');
     if (!$data) {
         return;
     }
     $this->config->set('_mta_product_data_', 0);
     foreach (array('discount', 'special') as $t) {
         $this->db->query("DELETE FROM " . DB_PREFIX . "mta_product WHERE product_id = '" . (int) $product_id . "' and price_mod_type='" . $t . "'");
         if (isset($data['product_' . $t])) {
             foreach ($data['product_' . $t] as $_i => $product_t) {
                 $t_set = isset($product_t['scheme_id']) && $product_t['scheme_id'];
                 $ta_set = isset($data['product_' . $t . '_affiliates'][$_i]) && is_array($data['product_' . $t . '_affiliates'][$_i]) && sizeof($data['product_' . $t . '_affiliates'][$_i]) > 0;
                 if (!$t_set && !$ta_set) {
                     continue;
                 }
                 $_res = $this->db->query("select product_" . $t . "_id AS tid from " . DB_PREFIX . "product_" . $t . " WHERE product_id = '" . (int) $product_id . "' AND customer_group_id = '" . (int) $product_t['customer_group_id'] . "' AND priority = '" . (int) $product_t['priority'] . "' AND price = '" . (double) $product_t['price'] . "'");
                 if ($_res->num_rows < 1) {
                     continue;
                 }
                 $t_id = intval($_res->row['tid']);
                 if ($t_set) {
                     $this->db->query("insert " . DB_PREFIX . "mta_product set product_id='" . (int) $product_id . "', mta_scheme_id='" . (int) $product_t['scheme_id'] . "', price_mod_type='" . $t . "', price_mod_id='" . $t_id . "'");
                 }
                 if ($ta_set) {
                     if (isset($product_t['product_' . $t . '_id'])) {
                         $this->db->query("DELETE FROM " . DB_PREFIX . "mta_product_affiliate WHERE product_id = '" . (int) $product_id . "' and price_mod_type='" . $t . "' and price_mod_id='" . (int) $product_t['product_' . $t . '_id'] . "'");
                     }
                     $_insert = array();
                     foreach ($data['product_' . $t . '_affiliates'][$_i] as $_scheme_id => $_affs) {
                         if (!$_affs) {
                             continue;
                         }
                         $_affs = explode(',', $_affs);
                         foreach ($_affs as $_aff) {
                             $_insert[] = "('" . (int) $product_id . "','" . (int) $_scheme_id . "','" . $t . "','" . $t_id . "','" . (int) $_aff . "')";
                         }
                     }
                     if (sizeof($_insert) > 0) {
                         $this->db->query("insert into " . DB_PREFIX . "mta_product_affiliate (product_id, mta_scheme_id,price_mod_type,price_mod_id,affiliate_id) values " . implode(',', $_insert));
                     }
                 } else {
                     if (isset($product_t['product_' . $t . '_id'])) {
                         $this->db->query("update " . DB_PREFIX . "mta_product_affiliate set price_mod_id='" . $t_id . "' where product_id = '" . (int) $product_id . "' and price_mod_type='" . $t . "' and price_mod_id='" . (int) $product_t['product_' . $t . '_id'] . "'");
                     }
                 }
             }
         }
     }
     $this->db->query("delete from " . DB_PREFIX . "mta_product where product_id='" . (int) $product_id . "' and price_mod_type=''");
     if (isset($data['product_scheme_id']) && $data['product_scheme_id']) {
         $this->db->query("insert into " . DB_PREFIX . "mta_product set product_id='" . (int) $product_id . "', mta_scheme_id='" . (int) $data['product_scheme_id'] . "', price_mod_type=''");
     }
     //product / affiliate
     if (isset($data['product_affiliates']) && is_array($data['product_affiliates']) && sizeof($data['product_affiliates']) > 0) {
         $this->db->query("delete from " . DB_PREFIX . "mta_product_affiliate where product_id='" . (int) $product_id . "' and price_mod_type=''");
         $_insert = array();
         foreach ($data['product_affiliates'] as $_scheme_id => $_aff_ids) {
             if (!$_aff_ids) {
                 continue;
             }
             $_aff_ids = explode(',', $_aff_ids);
             foreach ($_aff_ids as $_aff_id) {
                 if (mta_check_int($_aff_id) && $_aff_id > 0) {
                     $_insert[] = "('" . (int) $product_id . "','" . (int) $_scheme_id . "','" . (int) $_aff_id . "')";
                 }
             }
         }
         if (sizeof($_insert) > 0) {
             $this->db->query("insert into " . DB_PREFIX . "mta_product_affiliate (product_id, mta_scheme_id, affiliate_id) values " . implode(',', $_insert));
         }
     }
     //coupons
     if (isset($data['product_coupon_scheme_id'])) {
         //$this->db->query("delete from " . DB_PREFIX . "mta_product where product_id='" . (int)$product_id . "' and price_mod_type='coupon'");
         $_insert = array();
         foreach ($data['product_coupon_scheme_id'] as $_coupon_id => $_scheme_id) {
             $this->db->query("delete from " . DB_PREFIX . "mta_product where product_id='" . (int) $product_id . "' and price_mod_type='coupon' and price_mod_id='" . (int) $_coupon_id . "'");
             $this->db->query("delete from " . DB_PREFIX . "mta_product_affiliate where product_id='" . (int) $product_id . "' and price_mod_type='coupon' and price_mod_id='" . (int) $_coupon_id . "'");
             if ($_scheme_id) {
                 $_insert[] = "('" . (int) $product_id . "','" . (int) $_scheme_id . "','coupon','" . (int) $_coupon_id . "')";
             }
         }
         if (sizeof($_insert) > 0) {
             $this->db->query("insert into " . DB_PREFIX . "mta_product (product_id, mta_scheme_id, price_mod_type, price_mod_id) values " . implode(',', $_insert));
         }
     }
     //coupons / affiliate
     if (isset($data['product_coupon_affiliates']) && is_array($data['product_coupon_affiliates']) && sizeof($data['product_coupon_affiliates']) > 0) {
         //$this->db->query("delete from " . DB_PREFIX . "mta_product_affiliate where product_id='" . (int)$product_id . "' and price_mod_type='coupon'");
         $_insert = array();
         foreach ($data['product_coupon_affiliates'] as $_coupon_id => $_sAr) {
             foreach ($_sAr as $_scheme_id => $_aff_ids) {
                 if (!$_aff_ids) {
                     continue;
                 }
                 $_aff_ids = explode(',', $_aff_ids);
                 foreach ($_aff_ids as $_aff_id) {
                     if (mta_check_int($_aff_id) && $_aff_id > 0) {
                         $_insert[] = "('" . (int) $product_id . "','" . (int) $_scheme_id . "','coupon','" . (int) $_coupon_id . "','" . (int) $_aff_id . "')";
                     }
                 }
             }
         }
         if (sizeof($_insert) > 0) {
             $this->db->query("insert into " . DB_PREFIX . "mta_product_affiliate (product_id, mta_scheme_id, price_mod_type, price_mod_id, affiliate_id) values " . implode(',', $_insert));
         }
     }
 }
示例#12
0
 protected function _checkId($id)
 {
     if (!mta_check_int($id) || $id < 1) {
         return false;
     }
     $r = $this->db->query("select scheme_name from " . DB_PREFIX . "mta_scheme where mta_scheme_id='{$id}'");
     return $r->num_rows > 0 ? true : false;
 }