public function move_save() { if ($this->input->is_post()) { $ship_order_no = $this->input->post('ship_order_no'); $log_type = $this->input->post('log_type'); $storage_code = $this->input->post('storage_code'); $ship_confirm_date = $this->input->post('ship_confirm_date'); $locale = $this->input->post('locale'); $collect_address = $this->input->post('collect_address'); $ship_confirm_user = $this->input->post('ship_confirm_user'); $transaction_number = $this->input->post('transaction_number'); $abroad_stock_remark = $this->input->post('abroad_stock_remark'); $sku_arr = $this->input->post('sku'); $qty_arr = $this->input->post('qty'); } $sku_str = ''; $qty_str = ''; foreach ($sku_arr as $val => $sku) { if (!$this->product_model->check_exists('product_basic', array('sku' => $sku))) { echo $this->create_json(0, lang('product_sku_nonentity')); return; } else { $sku_str = $sku_str . $sku . ','; } } foreach ($qty_arr as $qty) { if (!is_positive($qty)) { echo $this->create_json(0, lang('qty_not_natural')); return; } else { $qty_str = $qty_str . $qty . ','; } } $sku_str = substr($sku_str, 0, strlen($sku_str) - 1); $qty_str = substr($qty_str, 0, strlen($qty_str) - 1); $creator = $this->get_current_login_name(); $created_date = get_current_time(); $data = array('ship_order_no' => $ship_order_no, 'log_type' => $log_type, 'storage_code' => $storage_code, 'ship_confirm_date' => $ship_confirm_date, 'locale' => $locale, 'remark' => $abroad_stock_remark, 'collect_address' => $collect_address, 'ship_confirm_user' => $ship_confirm_user, 'transaction_number' => $transaction_number, 'sku_str' => $sku_str, 'qty_str' => $qty_str, 'creator' => $creator, 'created_date' => $created_date); $this->product_model->save_move_stock($data); foreach ($sku_arr as $val => $sku) { $count = $qty_arr[$val]; $this->change_stock_count($sku, $storage_code, $count); } echo $this->create_json(1, lang('purchase_apply_saved')); }
public function update_group() { $id = $this->input->post('id'); $type = $this->input->post('type'); $value = trim($this->input->post('value')); try { switch ($type) { case 'code': if ($this->group_model->check_exists('group', array('code' => $value))) { echo $this->create_json(0, lang('group_code_in_use'), $value); return; } break; case 'name': if ($this->group_model->check_exists('group', array('name' => $value))) { echo $this->create_json(0, lang('group_name_in_use'), $value); return; } break; case 'priority': if (!is_positive($value)) { echo $this->create_json(0, lang('your_input_is_not_positive_numeric'), $value); return; } break; case 'bind': $groups = $this->fetch_all_enable_subsys(); $bind = $value; $value = isset($groups[$bind]) ? lang($groups[$bind]) : ''; if ($this->group_model->check_exists('group_system_map', array('bind' => $bind, 'group_id' => $this->input->post('group_id')))) { echo $this->create_json(0, lang('system_exists'), $value); return; } $this->group_model->update_group($id, $type, $bind); echo $this->create_json(1, lang('ok'), $value); return; } $this->group_model->update_group($id, $type, $value); echo $this->create_json(1, lang('ok'), $value); } catch (Exception $e) { $this->ajax_failed(); echo lang('error_msg'); } }
public function save_again() { $rules = array(array('field' => 'item_id_str', 'label' => lang('item_id_str'), 'rules' => 'trim|required'), array('field' => 'name', 'label' => 'name', 'rules' => 'trim|required'), array('field' => 'is_register', 'label' => 'is_register', 'rules' => 'trim|required'), array('field' => 'address_line_1', 'label' => 'address_line_1', 'rules' => 'trim|required|'), array('field' => 'town_city', 'label' => 'town_city', 'rules' => 'trim|required'), array('field' => 'country', 'label' => 'country', 'rules' => 'trim|required'), array('field' => 'state_province', 'label' => 'state_province', 'rules' => 'trim'), array('field' => 'net', 'label' => 'net', 'rules' => 'trim|required|numeric'), array('field' => 'transaction_id', 'label' => 'transaction_id', 'rules' => 'trim|required'), array('field' => 'item_id_str', 'label' => 'item_id_str', 'rules' => 'trim|required'), array('field' => 'qty[]', 'label' => 'qty', 'rules' => 'trim|required'), array('field' => 'sku[]', 'label' => 'sku', 'rules' => 'trim|required'), array('field' => 'from_email', 'label' => 'from_email', 'rules' => 'trim|required|valid_email'), array('field' => 'to_email', 'label' => 'to_email', 'rules' => 'trim|required|valid_email')); $this->form_validation->set_rules($rules); if ($this->form_validation->run() == FALSE) { $error = validation_errors(); echo $this->create_json(0, $error); return; } $transaction_id = $this->input->post('transaction_id'); $sku_arr = $this->input->post('sku'); $qty_arr = $this->input->post('qty'); $sku_str = ''; $qty_str = ''; foreach ($sku_arr as $sku) { if (!$this->product_model->check_exists('product_basic', array('sku' => $sku))) { echo $this->create_json(0, lang('product_sku_nonentity')); return; } else { $sku_str = $sku_str . $sku . ','; } } foreach ($qty_arr as $qty) { if (!is_positive($qty)) { echo $this->create_json(0, lang('qty_not_natural')); return; } else { $qty_str = $qty_str . $qty . ','; } } $sku_str = substr($sku_str, 0, strlen($sku_str) - 1); $qty_str = substr($qty_str, 0, strlen($qty_str) - 1); $input_user = $this->get_current_login_name(); $input_date = get_current_time(); $item_id = $this->input->post('item_id_str'); $register = $this->input->post('is_register'); if (trim($register) == 'H') { echo $this->create_json(0, lang('return_order_is_register_may_not_use_h')); return; } $income_type = $this->input->post('income_type'); $order_status_finance = $this->order_model->fetch_status_id('order_status', 'wait_for_finance_confirmation'); $order_status = $this->order_model->fetch_status_id('order_status', 'wait_for_confirmation'); $order_status_ship = $this->order_model->fetch_status_id('order_status', 'wait_for_shipping_label'); $old_order_id = $this->input->post('order_id'); $old_order = $this->order_model->get_order_with_id($old_order_id); $new_item_no = $this->order_model->create_item_no($input_user, date('ymd'), substr($item_id, -5), $transaction_id, $register); $to_old_order_sys_remark_string = $old_order->sys_remark; $to_old_order_sys_remark_string .= sprintf(lang('reutrn_to'), get_current_time(), get_current_user_name(), $new_item_no); $to_new_order_sys_remark_string = sprintf(lang('by_old_order_sys_remark'), get_current_time(), $old_order->item_no); $status_id = $old_order->order_status; $order_status_name = $this->order_model->fetch_status_name('order_status', $status_id); if ($order_status_name == 'not_received_approved_resending') { $order_status_old = $this->order_model->fetch_status_id('order_status', 'not_received_resended'); } elseif ($order_status_name == 'received_approved_resending') { $order_status_old = $this->order_model->fetch_status_id('order_status', 'received_resended'); } else { echo $this->create_json(0, lang('order_agained')); return; } $phone = $this->input->post('contact_phone_number'); $phone_requred = $this->order_model->fetch_contact_phone_requred($register); if ($phone_requred) { if (!$phone) { echo $this->create_json(0, lang('shipping_and_phone_is_not_null')); return; } } $update_data = array('sys_remark' => $to_old_order_sys_remark_string, 'order_status' => $order_status_old); $return_remark = $this->input->post('return_remark'); $data = array('item_no' => $new_item_no, 'name' => $this->input->post('name'), 'buyer_id' => $this->input->post('buyer_id'), 'address_line_1' => $this->input->post('address_line_1'), 'address_line_2' => $this->input->post('address_line_2'), 'town_city' => $this->input->post('town_city'), 'country' => $this->input->post('country'), 'state_province' => $this->input->post('state_province'), 'zip_code' => $this->input->post('zip_code'), 'contact_phone_number' => $this->input->post('contact_phone_number'), 'is_register' => $register, 'item_id_str' => $item_id, 'qty_str' => $qty_str, 'sku_str' => $sku_str, 'net' => $this->input->post('net'), 'currency' => $this->input->post('currency'), 'transaction_id' => $transaction_id, 'input_user' => $input_user, 'input_date' => $input_date, 'check_user' => $input_user, 'check_date' => $input_date, 'order_status' => $order_status, 'income_type' => $income_type, 'auction_site' => $this->input->post('auction_site'), 'auction_site_type' => 'mallerp', 'sys_remark' => $to_new_order_sys_remark_string, 'descript' => $return_remark, 'note' => $return_remark, 'to_email' => $this->input->post('to_email'), 'from_email' => $this->input->post('from_email')); $income_type_str = substr($income_type, 0, 2); if ($this->input->post('tag') == 1) { $data['order_status'] = $order_status_finance; /* if ($income_type_str == 'PP') { $data['order_status'] = $order_status_ship; } else { $data['order_status'] = $order_status_finance; }*/ } try { $order_id = $this->order_model->add_order($data); $update_tag = $this->order_model->update_order_information($old_order_id, $update_data); if ($this->input->post('tag') == 1) { /*发送财务审核消息*/ $message = $this->messages->load('apply_for_refund_notify'); $this->events->trigger('apply_for_refund_after', array('type' => 'apply_for_refund_notify', 'click_url' => site_url('finance/finance_order/confirm_order'), 'content' => lang($message['message'] . '_notify'), 'owner_id' => $this->get_current_user_id())); } echo $this->create_json(1, lang('return_order_saved') . ' ( ' . lang('new_item_no') . " : {$new_item_no} )"); } catch (Exception $e) { echo lang('error_msg'); $this->ajax_failed(); } }
public function seccuss_or_failure() { $rules = array(array('field' => 'case_id', 'label' => lang('case_id'), 'rules' => 'trim|required'), array('field' => 'case_no', 'label' => lang('case_no'), 'rules' => 'trim|required|is_natural'), array('field' => 'declared_name[]', 'label' => lang('declared_name'), 'rules' => 'trim|required'), array('field' => 'declared_price[]', 'label' => lang('declared_price'), '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; } $sku_arr = $this->input->post('sku'); $qty_arr = $this->input->post('qty'); $declared_name_arr = $this->input->post('declared_name'); $declared_price_arr = $this->input->post('declared_price'); if (count($sku_arr) == count($qty_arr) && count($qty_arr) == count($declared_name_arr) && count($declared_name_arr) == count($declared_price_arr)) { foreach ($sku_arr as $sku) { if (!$this->abroad_stock_model->check_exists('product_basic', array('sku' => $sku))) { echo $this->create_json(0, lang('product_sku_nonentity')); return; } } foreach ($qty_arr as $qty) { if (!is_positive($qty)) { echo $this->create_json(0, lang('qty_not_natural')); return; } } $case_no = trim($this->input->post('case_no')); $case_id = trim($this->input->post('case_id')); // $order_sign = $this->abroad_stock_model->get_order_sign_by_case_id($case_id); $sku_count = count($sku_arr); $this->abroad_stock_model->delete('cky_in_store_product', array('case_id' => $case_id)); for ($i = 0; $i < $sku_count; $i++) { $data_to_database = array('case_id' => $case_id, 'case_no' => $case_no, 'title' => $sku_arr[$i], 'quantity' => $qty_arr[$i], 'declared_name' => $declared_name_arr[$i], 'declared_price' => $declared_price_arr[$i], 'creator' => get_current_login_name()); try { $this->abroad_stock_model->save_in_store_product($data_to_database); } catch (Exception $e) { echo lang('error_msg'); $this->ajax_failed(); } } } else { echo $this->create_json(0, lang('product_info_not_matching')); return; } $list_id = trim($this->input->post('list_id')); list($list_info, $boxes_info, $products_info) = $this->in_store_list_all_detail($list_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); $this->load->view('stock/abroad_stock/seccuss_or_failure_page', $data_for_view); return; }
public function save() { $rules = array(array('field' => 'email_time', 'label' => lang('email_time'), '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 (!$this->input->post('recommend_no')) { echo $this->create_json(0, lang('recommend_no_is_null')); return; } $recommend_no = trim($this->input->post('recommend_no')); if ($this->quality_testing_model->check_exists('order_recommend_list', array('recommend_no' => $recommend_no))) { echo $this->create_json(0, lang('recommend_no_exists')); return; } // $skus = $this->input->post('sku'); // $qtys = $this->input->post('qty'); // $sku_str = ''; // $qty_str = ''; // if($skus && $qtys) // { // $sku_str = implode(',', $skus); // $qty_str = implode(',', $qtys); // } // else // { // echo $this->create_json(0, lang('order_is_not_product')); // return; // } $sku_arr = $this->input->post('sku'); $qty_arr = $this->input->post('qty'); $sku_str = ''; $qty_str = ''; foreach ($sku_arr as $sku) { if (!$this->product_model->check_exists('product_basic', array('sku' => $sku))) { echo $this->create_json(0, lang('product_sku_nonentity')); return; } else { $sku_str = $sku_str . $sku . ','; } } foreach ($qty_arr as $qty) { if (!is_positive($qty)) { echo $this->create_json(0, lang('qty_not_natural')); return; } else { $qty_str = $qty_str . $qty . ','; } } $sku_str = substr($sku_str, 0, strlen($sku_str) - 1); $qty_str = substr($qty_str, 0, strlen($qty_str) - 1); $data = array('recommend_id' => -1, 'order_id' => -1, 'qty_str' => $qty_str, 'sku_str' => $sku_str, 'recommend_no' => $recommend_no, 'status' => trim($this->input->post('recommend_status')), 'cause' => trim($this->input->post('recommend_cause')), 'email_time' => trim($this->input->post('email_time')), 'remark' => trim($this->input->post('recommend_remark')), 'creator' => $this->get_current_login_name(), 'created_date' => date('Y-m-d h:m:s')); try { $recommend_id = $this->quality_testing_model->save_recommend($data); echo $this->create_json(1, lang('save_recommend_successed')); } catch (Exception $e) { echo lang('error_msg'); $this->ajax_failed(); } }
public function save_split_order() { if ($this->input->is_post()) { $old_item_title_str = $this->input->post('old_item_title_str'); $old_item_id_str = $this->input->post('old_item_id_str'); $old_gross = $this->input->post('old_gross'); $old_net = $this->input->post('old_net'); $old_shipping_cost = $this->input->post('old_shipping_cost'); $old_shipping_way = $this->input->post('old_shipping_way'); $old_sku_arr = $this->input->post('old_sku'); $old_qty_arr = $this->input->post('old_qty'); $old_price_arr = $this->input->post('old_price'); $item_title_str = $this->input->post('item_title_str'); $item_id_str = $this->input->post('item_id_str'); $gross = $this->input->post('gross'); $net = $this->input->post('net'); $shipping_cost = $this->input->post('shipping_cost'); $shipping_way = $this->input->post('shipping_way'); $sku_arr = $this->input->post('sku'); $qty_arr = $this->input->post('qty'); $price_arr = $this->input->post('price'); $old_order_id = $this->input->post('order_id'); } $old_sku_str = ''; $old_qty_str = ''; $old_price_str = ''; $sku_str = ''; $qty_str = ''; $price_str = ''; foreach ($old_sku_arr as $old_sku) { if (!$this->product_model->check_exists('product_basic', array('sku' => $old_sku))) { echo $this->create_json(0, lang('product_sku_nonentity')); return; } else { $old_sku_str = $old_sku_str . $old_sku . ','; } } foreach ($old_qty_arr as $old_qty) { if (!is_positive($old_qty)) { echo $this->create_json(0, lang('qty_not_natural')); return; } else { $old_qty_str = $old_qty_str . $old_qty . ','; } } foreach ($old_price_arr as $old_price) { $old_price_str = $old_price_str . $old_price . ','; } foreach ($sku_arr as $sku) { if (!$this->product_model->check_exists('product_basic', array('sku' => $sku))) { echo $this->create_json(0, lang('product_sku_nonentity')); return; } else { $sku_str = $sku_str . $sku . ','; } } foreach ($qty_arr as $qty) { if (!is_positive($qty)) { echo $this->create_json(0, lang('qty_not_natural')); return; } else { $qty_str = $qty_str . $qty . ','; } } foreach ($price_arr as $price) { $price_str = $price_str . $price . ','; } $old_sku_str = substr($old_sku_str, 0, strlen($old_sku_str) - 1); $old_qty_str = substr($old_qty_str, 0, strlen($old_qty_str) - 1); $old_price_str = substr($old_price_str, 0, strlen($old_price_str) - 1); $sku_str = substr($sku_str, 0, strlen($sku_str) - 1); $qty_str = substr($qty_str, 0, strlen($qty_str) - 1); $price_str = substr($price_str, 0, strlen($price_str) - 1); $input_user = $this->get_current_login_name(); $input_date = get_current_time(); $register = $shipping_way; $item_id_arr = explode(',', $item_id_str); $order_status = fetch_status_id('order_status', 'wait_for_confirmation'); $data = $this->order_model->get_order_with_id($old_order_id); $transaction_id = $data->transaction_id; $ebay_id = $data->ebay_id; if ($ebay_id == '') { //$ebay_id= $this->ebay_model->get_ebay_id_by_item_id($item_id_arr[0]); } $item_no = $this->order_model->create_item_no($input_user, date('ymd'), $item_id_arr[0] . 'C', $transaction_id, $register); $item_id = $data->item_id_str; $old_item_no = $data->item_no; $old_sys_remark = $data->sys_remark; /*替换新订单的参数*/ $data->id = ''; $data->item_no = $item_no; $data->sku_str = $sku_str; $data->qty_str = $qty_str; $data->item_price_str = $price_str; $data->item_id_str = $item_id_str; $data->item_title_str = $item_title_str; $data->gross = $gross; $data->net = $net; $data->shipping_cost = $shipping_cost; $data->sys_remark = sprintf(lang('split_order_remark'), get_current_time(), $input_user, $transaction_id, $item_id) . ',' . lang('order_number') . ':' . $old_item_no; $data->is_register = $shipping_way; $data->transaction_id = $transaction_id . '-' . date('is'); $data->is_splited = 1; $data->track_number = ''; //print_r($data); $old_data = array('item_title_str' => $old_item_title_str, 'item_id_str' => $old_item_id_str, 'gross' => $old_gross, 'net' => $old_net, 'shipping_cost' => $old_shipping_cost, 'item_title_str' => $old_price_str, 'is_register' => $old_shipping_way, 'sku_str' => $old_sku_str, 'qty_str' => $old_qty_str, 'sys_remark' => $old_sys_remark . ';' . sprintf(lang('split_by_label_remark'), get_current_time(), $input_user)); //print_r($old_data); try { $new_order_id = $this->order_model->add_split_order($data); $this->order_model->update_order_information($old_order_id, $old_data); echo $this->create_json(1, lang('order_saved')); } catch (Exception $e) { echo lang('error_msg'); $this->ajax_failed(); } }