Пример #1
0
 public function save()
 {
     $rules = array(array('field' => 'keyword', 'label' => lang('keyword'), 'rules' => 'trim|required'), array('field' => 'link_url', 'label' => lang('link_url'), 'rules' => 'trim|required'), array('field' => 'global_search_monthly', 'label' => lang('global_search_monthly'), 'rules' => 'trim'), array('field' => 'usa_search', 'label' => lang('usa_search'), 'rules' => 'trim'), array('field' => 'search_result', 'label' => lang('search_result'), 'rules' => 'trim'), array('field' => 'search_intitle', 'label' => lang('search_intitle'), 'rules' => 'trim'), array('field' => 'compete_index', 'label' => lang('compete_index'), 'rules' => 'trim|is_natural'), array('field' => 'intitle', 'label' => lang('intitle'), 'rules' => 'trim|is_natural'), array('field' => 'price_per_click', 'label' => lang('price_per_click'), 'rules' => 'trim'), array('field' => 'page_first_ten', 'label' => lang('page_first_ten'), 'rules' => 'trim|is_natural'), array('field' => 'com_ranking', 'label' => lang('com_ranking'), 'rules' => 'trim'), array('field' => 'compete_price', 'label' => lang('compete_price'), 'rules' => 'trim|is_natural'));
     $this->form_validation->set_rules($rules);
     if ($this->form_validation->run() == FALSE) {
         $error = validation_errors();
         echo $this->create_json(0, $error);
         return;
     }
     if ($this->input->post('keyword_id') < 0) {
         if ($this->seo_keyword_model->check_exists('seo_keyword', array('keyword' => $this->input->post('keyword')))) {
             echo $this->create_json(0, lang('keyword_exists'));
             return;
         }
     } else {
         if (trim($this->input->post('keyword')) !== $this->seo_keyword_model->get_one('seo_keyword', 'keyword', array('id' => $this->input->post('keyword_id')))) {
             if ($this->seo_keyword_model->check_exists('seo_keyword', array('keyword' => $this->input->post('keyword')))) {
                 echo $this->create_json(0, lang('keyword_exists'));
                 return;
             }
         }
     }
     $search_monthly = trim($this->input->post('global_search_monthly'));
     $global_search_monthly = formate_to_number($search_monthly);
     if (positive_numeric($global_search_monthly) === FALSE && $global_search_monthly != 0) {
         echo $this->create_json(0, lang('a_number_greater_than_zero'));
         return;
     }
     $usa_search = trim($this->input->post('usa_search'));
     $usa_search = formate_to_number($usa_search);
     if (positive_numeric($usa_search) === FALSE && $usa_search != 0) {
         echo $this->create_json(0, lang('a_number_greater_than_zero'));
         return;
     }
     $search_result = trim($this->input->post('search_result'));
     $search_result = formate_to_number($search_result);
     if (positive_numeric($search_result) === FALSE && $search_result != 0) {
         echo $this->create_json(0, lang('a_number_greater_than_zero'));
         return;
     }
     $search_intitle = trim($this->input->post('search_intitle'));
     $search_intitle = formate_to_number($search_intitle);
     if (positive_numeric($search_intitle) === FALSE && $search_intitle != 0) {
         echo $this->create_json(0, lang('a_number_greater_than_zero'));
         return;
     }
     $data = array('keyword_id' => $this->input->post('keyword_id'), 'keyword' => trim($this->input->post('keyword')), 'link_url' => trim($this->input->post('link_url')), 'global_search_monthly' => $global_search_monthly, 'usa_search' => $usa_search, 'search_result' => $search_result, 'search_intitle' => $search_intitle, 'intitle' => trim($this->input->post('intitle')), 'compete_index' => trim($this->input->post('compete_index')), 'compete_price' => trim($this->input->post('compete_price')), 'price_per_click' => trim($this->input->post('price_per_click')), 'page_first_ten' => trim($this->input->post('page_first_ten')), 'level' => $this->input->post('level'), 'com_ranking' => trim($this->input->post('com_ranking')), 'note' => trim($this->input->post('note')), 'creator' => get_current_user_id());
     try {
         $keyword_id = $this->seo_keyword_model->save_keyword($data);
         $user_ids = $this->input->post('permissions');
         $catalog_ids = $this->input->post('catalogs');
         if (empty($user_ids) || empty($catalog_ids)) {
             $user_ids = array();
             $catalog_ids = array();
         }
         $this->seo_keyword_model->save_keyword_permissions($keyword_id, $user_ids);
         $this->seo_keyword_model->save_keyword_catalogs($keyword_id, $catalog_ids);
         $company_ids = $this->input->post('company_permissions');
         if (empty($company_ids)) {
             $company_ids = array();
         }
         $this->seo_service_company_model->save_keyword_company_permissions($keyword_id, $company_ids);
         echo $this->create_json(1, lang('save_keyword_successed'));
     } catch (Exception $e) {
         echo lang('error_msg');
         $this->ajax_failed();
     }
 }
Пример #2
0
 public function in_store_product($case_id = NULL, $tag = NULL, $key = NULL)
 {
     if ($case_id && $tag == 'product_back') {
         $products = $this->abroad_stock_model->fetch_product_info_by_case_id($case_id);
         $case_obj = $this->abroad_stock_model->fetch_case_info_by_id($case_id);
         list($list_info, $boxes_info, $products_info) = $this->in_store_list_all_detail($case_obj->list_id);
         $data_for_view = array('products' => $products, 'list_id' => $case_obj->list_id, 'case_id' => $case_id, 'case_no' => $case_obj->case_no, 'list_info' => $list_info, 'boxes_info' => $boxes_info, 'products_info' => $products_info);
         $this->load->view('stock/abroad_stock/in_store_product_page', $data_for_view);
         return;
     }
     $list_id = trim($this->input->post('list_id'));
     $case_id = trim($this->input->post('case_id'));
     $case_no = trim($this->input->post('case_no'));
     $tag = trim($this->input->post('tag'));
     $weight = trim($this->input->post('in_store_weight'));
     $packing = trim($this->input->post('packing'));
     $rules = array(array('field' => 'case_no', 'label' => lang('case_no'), 'rules' => 'trim|required|is_natural'), array('field' => 'in_store_weight', 'label' => lang('in_store_weight'), 'rules' => 'trim|required'), array('field' => 'packing', 'label' => lang('packing'), 'rules' => 'trim|required'));
     $this->form_validation->set_rules($rules);
     if ($this->form_validation->run() == FALSE) {
         $error = validation_errors();
         echo $this->create_json(0, $error);
         return;
     }
     if (!positive_numeric($weight)) {
         echo $this->create_json(0, lang('weight_not_natural'));
         return;
     }
     $packing_arr = explode('*', $packing);
     if (count($packing_arr) != 3) {
         echo $this->create_json(0, lang('packing_format_is_error'));
         return;
     }
     $data_to_database = array('case_no' => $case_no, 'list_id' => $list_id, 'weight' => $weight, 'packing' => $packing, 'creator' => get_current_login_name());
     try {
         if ($case_id > 0) {
             $case_obj = $this->abroad_stock_model->fetch_case_info_by_id($case_id);
             if ($this->abroad_stock_model->check_exists('cky_in_store_case', array('list_id' => $list_id, 'case_no' => $case_no)) && $case_obj->case_no != $case_no) {
                 echo $this->create_json(0, lang('case_no_nonentity'));
                 return;
             }
             $this->abroad_stock_model->update('cky_in_store_case', array('id' => $case_id), $data_to_database);
         } else {
             if ($this->abroad_stock_model->check_exists('cky_in_store_case', array('list_id' => $list_id, 'case_no' => $case_no))) {
                 echo $this->create_json(0, lang('case_no_nonentity'));
                 return;
             }
             $case_id = $this->abroad_stock_model->save_in_store_case($data_to_database);
         }
         list($list_info, $boxes_info, $products_info) = $this->in_store_list_all_detail($list_id);
         $products = $this->abroad_stock_model->fetch_product_info_by_case_id($case_id);
         $data_for_view = array('list_id' => $list_id, 'case_id' => $case_id, 'case_no' => $case_no, 'list_info' => $list_info, 'boxes_info' => $boxes_info, 'products_info' => $products_info, 'products' => $products);
         $this->load->view('stock/abroad_stock/in_store_product_page', $data_for_view);
         return;
     } catch (Exception $e) {
         echo lang('error_msg');
         $this->ajax_failed();
     }
 }
Пример #3
0
 public function save_quick_out_stock()
 {
     $qty = $this->input->post('qty');
     $sku = $this->input->post('sku');
     $note = $this->input->post('note');
     $user_id = get_current_user_id();
     if (!positive_numeric($qty)) {
         echo $this->create_json(0, lang('qty_not_natural'));
         return;
     }
     if (!$this->product_model->fetch_product_id(strtoupper($sku))) {
         echo $this->create_json(0, lang('product_sku_doesnot_exists') . "({$sku})");
         return;
     }
     $this->product_model->update_product_stock_count_by_sku($sku, $qty, true, lang('quick_out_stock'), $note, 'SZ', $user_id);
     echo $this->create_json(1, lang('configuration_accepted'));
 }