load->model('Order_model'); $this->load->model('Import_model'); // 查看加载时间 //$this->output->enable_profiler(TRUE); $this->data['nav'] = 'index'; $this->data['nav_header'] = $this->load->view('index/order_header', '', true); } // 电子台历lzq public function show_calendar($year = false, $mounth = false) { /* * */ $prefs = array( 'show_next_prev' => TRUE, 'next_prev_url' => site_url('/index/show_calendar') ); $prefs['template'] = '
{table_open}{/table_open} {heading_row_start}{/heading_row_start} {heading_previous_cell}{/heading_previous_cell} {heading_title_cell}{/heading_title_cell} {heading_next_cell}{/heading_next_cell} {heading_row_end}{/heading_row_end} {week_row_start}{/week_row_start} {week_day_cell}{/week_day_cell} {week_row_end}{/week_row_end} {cal_row_start}{/cal_row_start} {cal_cell_start}{/cal_cell_end} {cal_cell_end_today}{/cal_cell_end_today} {cal_cell_end_other}{/cal_cell_end_other} {cal_row_end}{/cal_row_end} {table_close}
<<
{heading}      订单号/(第几天)-大人/小孩/婴儿 产品代号/酒店信息
>>
{week_day}
{/cal_cell_start} {cal_cell_start_today}{/cal_cell_start_today} {cal_cell_start_other}{/cal_cell_start_other} {cal_cell_content}
{day}
{content}
{/cal_cell_content} {cal_cell_content_today}
{day}
{content}
{/cal_cell_content_today} {cal_cell_no_content}
{day}

{/cal_cell_no_content} {cal_cell_no_content_today}
{day}
{/cal_cell_no_content_today} {cal_cell_blank} {/cal_cell_blank} {cal_cell_other}{day}{/cal_cel_other} {cal_cell_end}
{/table_close} '; $this->load->library('calendar', $prefs); $year = $year == false ? date("Y") : $year; $mounth = $mounth == false ? date("m") : $mounth; $after_mounth = $mounth == 12 ? 1 : $mounth + 1; $after_year = $mounth == 12 ? $year + 1 : $year; // 当月总天数 $mounth_days = $this->calendar->get_total_days($mounth, $year); // 得到上月的处理日期,和这个月月底日期 $start_date = $year . '-' . $mounth . '-1'; $start_date = date('Y-m-d H:i:s', strtotime($start_date)); $end_date = $after_year . '-' . $after_mounth . '-1'; $end_date = date('Y-m-d H:i:s', strtotime("$end_date-1 minute")); // 获取结果集 $mounth_results = $this->Order_model->get_date_info($start_date, $end_date); foreach ($mounth_results as $k => $v) { // 出发日 $first_day = date('d', strtotime($v->COLD_StartDate)); $first_day = intval($first_day, 10); // 处理酒店字符串 $pol_hotel = str_replace(array("HotelName:"), "", $v->POI_Hotel); if (strpos($pol_hotel, ",")) { $pol_hotel = substr($pol_hotel, 0, strpos($pol_hotel, ',')); } if (strpos($pol_hotel, "(")) { $pol_hotel = substr($pol_hotel, 0, strpos($pol_hotel, '(')); } //拼接html语句处理 $start_href = 'COLI_ID . '-' . $v->COLD_PersonNum . '/' . $v->COLD_ChildNum . '/' . $v->COLD_BabyNum . '
' . $v->PAG_Code . '/' . $pol_hotel . '
'; // 当天新增标红色 if (date('Y-m-d', strtotime($v->COLI_ApplyDate)) == date("Y-m-d")) { $strtemp = $start_href . $red_html . $next_href . $strtemp . $end_href; } else { $strtemp = $start_href . $black_html . $next_href . $strtemp . $end_href; } $data_content[$first_day] .= '
' . $strtemp . '
'; } $this->data['ele_calendar'] = $this->calendar->generate($year, $mounth, $data_content); $this->load->view('header', $this->data); $this->load->view('index/show_calendar'); $this->load->view('footer'); } //订单列表页 public function index($page = 1) { $page_flag = true; $this->data['order_type'] = $this->lang->line('order_type'); $this->data['order_status'] = $this->lang->line('order_status'); $this->data['conditions'] = $this->input->post(); if ($this->input->post('search_order') == 1) { $this->data['o_orderno'] = $this->input->post('o_orderno'); $status = $this->input->post('status') == 'all' ? false : $this->input->post('status'); $ordertype = $this->input->post('ordertype') == 'all' ? false : $this->input->post('ordertype'); $ordercolno = $this->input->post('ordercolno'); $startdate = $this->input->post('startdate'); $startdate2 = $this->input->post('startdate2') ? $this->input->post('startdate2') : date('Y-m-d'); $applydate = $this->input->post('applydate'); $applydate2 = $this->input->post('applydate2') ? $this->input->post('applydate2') : date('Y-m-d'); $source = $this->input->post('source'); $list = $this->Order_model->get_order_list_ids($this->data['o_orderno'], $status, $ordertype, $ordercolno, $startdate, $startdate2, $applydate, $applydate2, $source); } else { $list = $this->Order_model->get_order_list_ids(); } $pages['total'] = count($list); //数据总条数 $pages['pageSize'] = 20; //每页展示数量 $pages['url'] = site_url("index/index/"); //页码链接 $pages['current'] = $page; //当前页码 $this->data['pageinfo'] = show_page($pages); $order_id_str = 0; $list = array_slice($list, $pages['pageSize'] * ($page - 1), $pages['pageSize']); foreach ($list as $v) { $order_id_str.=',' . $v->o_sn; } $this->data['order_list'] = $this->Order_model->get_order_list_by_idstr($order_id_str); //用于判断订单是否已付款 $pay_list = $this->Order_model->get_payments($order_id_str); $pay_array = array(); foreach ($pay_list as $pay) { $pay_array[$pay->pm_o_sn] = $pay; } $this->data['payrecord'] = $pay_array; $this->load->view('header', $this->data); $this->load->view('index/index'); $this->load->view('footer'); } //新订单详细页 public function new_detail($o_orderno = false) { $this->data['order_type'] = $this->lang->line('order_type'); $this->data['order_status'] = $this->lang->line('order_status'); $this->data['sex'] = $this->lang->line('sex'); $this->data['country'] = $this->lang->line('country'); $this->data['order_step'] = $this->lang->line('order_step'); $this->data['order_sourcetypes'] = $this->lang->line('order_sourcetypes'); $this->data['order_devices'] = $this->lang->line('order_devices'); //获取产品信息 if ($o_orderno != false) { $product_info = $this->Order_model->get_product_by_coli_id($o_orderno); } $this->data['product_info'] = $product_info; //获取付款记录 if ($o_orderno != false) { $payments_info = $this->Order_model->get_pay_by_coli_id($o_orderno); } foreach ($payments_info as $k => $v) { $v->pm_money_type = $this->Import_model->get_payment_type($v->GAI_Type); } $this->data['payments'] = $payments_info; //获取订单及联系人信息 if ($o_orderno != false) { $orderinfo = $this->Order_model->get_order_by_coli_id($o_orderno); } $orderinfo->sourcetype = $this->Import_model->get_source_type($orderinfo->COLI_sourcetype); $orderinfo->o_device = $this->Import_model->get_source_device($orderinfo->COLI_OrderSource); $orderinfo->cus_sex = ($orderinfo->GUT_SEX == 1) ? '男' : '女'; $this->data['orderinfo'] = $orderinfo; $this->load->view('header', $this->data); $this->load->view('index/new_detail'); $this->load->view('footer'); } //订单详细页 public function detail($o_sn, $o_orderno = false) { $this->data['order_type'] = $this->lang->line('order_type'); $this->data['order_status'] = $this->lang->line('order_status'); $this->data['sex'] = $this->lang->line('sex'); $this->data['country'] = $this->lang->line('country'); $this->data['order_step'] = $this->lang->line('order_step'); $this->data['order_sourcetypes'] = $this->lang->line('order_sourcetypes'); $this->data['order_devices'] = $this->lang->line('order_devices'); $this->load->model('Templates_model'); $this->data['template_list'] = $this->Templates_model->get_list(); //根据主表ID或者订单号查询订单信息 if ($o_orderno != false) { $this->data['orderinfo'] = $this->Order_model->get_detail_by_orderno($o_orderno); } else { $this->data['orderinfo'] = $this->Order_model->get_order_list($o_sn); } $this->data['sub_order_list'] = $this->data['orderinfo']; $this->data['orderinfo'] = $this->data['orderinfo'][0]; $o_sn = $this->data['orderinfo']->o_sn; //获取联系人信息 $this->data['linkuser'] = $this->Order_model->get_link_user($o_sn); //获取客人列表信息 $this->data['guest_list'] = $this->Order_model->get_guest_list($o_sn); $customers = array(); foreach ($this->data['guest_list'] as $key => $u) { if (!isset($customers[$u->occ_sn])) { $customers[$u->occ_sn] = array(); } $customers[$u->occ_sn][] = $u; } $this->data['customers'] = $customers; $current_step = array_search($this->data['orderinfo']->o_status, $this->data['order_step']); $this->data['current_step'] = $current_step ? $current_step : 0; //获取来往邮件 $this->load->model('Mails_model'); $this->data['mails'] = $this->Mails_model->get_search_mails($this->data['orderinfo']->o_orderno); //付款记录 $this->data['payments'] = array(); $this->data['payments'] = $this->Order_model->get_payments($o_sn); //标记是否显示信息 $this->data['targer_info'] = 1; $this->load->view('header', $this->data); $this->load->view('index/detail'); $this->load->view('footer'); } public function edit_payment($o_sn, $pm_sn = false, $price = '') { $this->data['price'] = $price; $this->data['payments'] = ''; if ($pm_sn != false || !empty($pm_sn) || $pm_sn != 0) { $this->data['pm_sn'] = $pm_sn; $this->data['payments'] = $this->Order_model->get_payments(false, $pm_sn); } $this->data['o_sn'] = $o_sn; $this->data['payment_types'] = $this->lang->line('payment_types'); $this->data['currency_type'] = $this->lang->line('currency_rate'); $this->data['pm_company'] = $this->lang->line('pm_company'); $this->load->view('index/edit_payment', $this->data); } public function edit_payment_save() { $pm_o_sn = $this->input->post('pm_o_sn'); $pm_money = $this->input->post('pm_money'); $pm_money_currency = $this->input->post('pm_money_currency'); $pm_money_type = $this->input->post('pm_money_type'); $pm_money_date = $this->input->post('pm_money_date'); $pm_rmb = $this->input->post('pm_rmb'); $pm_rmb_date = $this->input->post('pm_rmb_date'); $pm_customer = $this->input->post('pm_customer'); $pm_customer_email = $this->input->post('pm_customer_email'); $pm_company = $this->input->post('pm_company'); $pm_memo = $this->input->post('pm_memo'); $pm_delete = 0; $payment_types = $this->lang->line('payment_types'); $pm_money_type = $payment_types[$pm_money_type]; if ($this->input->post('pm_sn')) { $pm_sn = $this->input->post('pm_sn'); $result = $this->Order_model->update_payments($pm_sn, $pm_o_sn, $pm_money, $pm_money_currency, $pm_money_type, $pm_money_date, $pm_rmb, $pm_rmb_date, $pm_customer, $pm_customer_email, $pm_company, $pm_memo, $pm_delete); } else { $result = $this->Order_model->save_payments($pm_o_sn, $pm_money, $pm_money_currency, $pm_money_type, $pm_money_date, $pm_rmb, $pm_rmb_date, $pm_customer, $pm_customer_email, $pm_company, $pm_memo, $pm_delete); $pm_sn = $result; } if ($result) { $html = ' ' . $pm_money_type . ' ' . $pm_money_currency . ' ' . $pm_money . ' ' . date("Y-m-d", strtotime($pm_money_date)) . ' ' . $pm_rmb . ' ' . date("Y-m-d", strtotime($pm_rmb_date)) . ' ' . $pm_customer . ' ' . $pm_customer_email . ' ' . $pm_company . ' ' . $pm_memo . '
修改 '; $output = array('status' => 'ok', 'msg' => '保存成功!', 'insert_box' => '.payment-table', 'inserthtml' => $html, 'remove_elem' => '#payment_list_' . $pm_sn); echo json_encode($output); } else { echo json_encode(array('status' => 'no', 'msg' => '保存失败!')); } } //添加订单 public function add_order() { $o_orderno = MakeOrderNumber(); $o_ordertype = ''; $o_status = '新订单'; $o_source = ''; $o_memo = ''; $o_contractors = 1; $o_deleteflag = 0; $o_sn = $this->Order_model->save_orders($o_orderno, $o_ordertype, $o_status, $o_source, $o_contractors, $o_deleteflag, $o_memo); //联系人信息 $cus_firstname = ''; $cus_middlename = ''; $cus_lastname = ''; $cus_nationality = 0; $cus_passport = ''; $cus_passport_validdate = ''; $cus_phone = ''; $cus_email = ''; $cus_sex = '男'; $cus_backup_email = ''; $cus_deleteflag = 0; $oc_type = 'orders'; $cus_sn = $this->Order_model->save_customer($cus_firstname, $cus_middlename, $cus_lastname, $cus_nationality, $cus_passport, $cus_passportvaliddate, $cus_phone, $cus_email, $cus_sex, $cus_deleteflag, $cus_backup_email); $this->Order_model->save_ordercus($o_sn, $cus_sn, $oc_type); redirect(site_url('index/detail/' . $o_sn)); } public function do_add_order() { //主表信息 $o_orderno = $this->input->post('orderNO'); $o_ordertype = $this->input->post('ordertype'); $o_status = $this->input->post('status'); $o_source = $this->input->post('source'); $o_memo = $this->input->post('o_memo'); $o_device = $this->input->post('o_device'); $o_contractors = 1; $o_deleteflag = 0; if ($this->input->post('o_sn')) { $url_o_sn = $this->input->post('o_sn'); $this->Order_model->update_orders($this->input->post('o_sn'), $o_orderno, $o_ordertype, $o_status, $o_source, $o_contractors, $o_memo, $o_device); $occ_o_sn = $this->input->post('o_sn'); } else { $occ_o_sn = $this->Order_model->save_orders($o_orderno, $o_ordertype, $o_status, $o_source, $o_contractors, $o_deleteflag, $o_memo, $o_device); $url_o_sn = $occ_o_sn; } //联系人信息 $cus_firstname = $this->input->post('linkname'); $cus_middlename = ''; $cus_lastname = ''; $cus_nationality = $this->input->post('linkcountry'); $cus_passport = $this->input->post('linkpassport'); $cus_passportvaliddate = $this->input->post('linkpassportpaliddate'); // 日期返回待告 则返回空 $cus_passportvaliddate = $cus_passportvaliddate == '待告' ? NULL : $cus_passportvaliddate; $cus_phone = $this->input->post('linkphone'); $cus_email = $this->input->post('linkemail'); $cus_sex = $this->input->post('linksex'); $cus_backup_email = $this->input->post('backup_email'); $cus_deleteflag = 0; $oc_type = 'orders'; if ($this->input->post('cus_sn')) { $cus_sn = $this->Order_model->update_customer($this->input->post('cus_sn'), $cus_firstname, $cus_middlename, $cus_lastname, $cus_nationality, $cus_passport, $cus_passportvaliddate, $cus_phone, $cus_email, $cus_sex, $cus_backup_email); } else { $cus_sn = $this->Order_model->save_customer($cus_firstname, $cus_middlename, $cus_lastname, $cus_nationality, $cus_passport, $cus_passportvaliddate, $cus_phone, $cus_email, $cus_sex, $cus_deleteflag, $cus_backup_email); //订单客人关联表 $this->Order_model->save_ordercus($this->input->post('o_sn'), $cus_sn, $oc_type); } //保存子表产品信息 $sub_order_count = $this->input->post('sub_order_count'); $oc_type = 'order_circuit'; for ($i = 0; $i < $sub_order_count; $i++) { //子表信息 $occ_circuitcode = $this->input->post('ordercolno_' . $i); $occ_adultcount = $this->input->post('adultcount_' . $i); $occ_childrencount = $this->input->post('childrencount_' . $i); $occ_babycount = $this->input->post('babycount_' . $i); $occ_days = $this->input->post('orderdays_' . $i); $occ_startdate = $this->input->post('startdate_' . $i); $occ_startdate = $occ_startdate == '待告' ? NULL : $occ_startdate; $occ_detailtext = $this->input->post('DetailText_' . $i); $occ_totalprice = $this->input->post('orderprice_' . $i); $occ_totalprice = trim($occ_totalprice, '$'); $occ_totalprice = $occ_totalprice == '' ? 0 : $occ_totalprice; $occ_edited_price = $this->input->post('old_occ_edited_price_' . $i); $sub_order_sn = $this->input->post('sub_order_sn_' . $i); if (!empty($sub_order_sn)) { $suborderID = $this->input->post('sub_order_sn_' . $i); $old_price = $this->input->post('old_price_' . $i); if ($old_price != $this->input->post('orderprice_' . $i)) { $occ_edited_price = 1; } $this->Order_model->update_order_circuit($suborderID, $occ_circuitcode, $occ_adultcount, $occ_childrencount, $occ_babycount, $occ_days, $occ_startdate, $occ_detailtext, $occ_totalprice, $occ_edited_price); } else { $suborderID = $this->Order_model->save_order_circuit($occ_o_sn, $occ_circuitcode, $occ_adultcount, $occ_childrencount, $occ_babycount, $occ_days, $occ_startdate, $occ_detailtext, $occ_totalprice, $occ_edited_price); } //产品客人列表信息 $FirstName_List = $this->input->post('FirstName_' . $i); $MiddleName = $this->input->post('MiddleName_' . $i); $LastName = $this->input->post('LastName_' . $i); $sex = $this->input->post('sex_' . $i); $passport = $this->input->post('passport_' . $i); $PassportValidDate = $this->input->post('PassportValidDate_' . $i); $Nationality = $this->input->post('Nationality_' . $i); $Email = $this->input->post('Email_' . $i); $guest_cus_sn = $this->input->post('guest_cus_sn_' . $i); foreach ($FirstName_List as $key => $value) { $cus_firstname = $FirstName_List["$key"]; $cus_middlename = $MiddleName["$key"]; $cus_lastname = $LastName["$key"]; $cus_nationality = $Nationality["$key"]; $cus_passport = $passport["$key"]; $cus_passportvaliddate = $PassportValidDate["$key"]; $cus_phone = ''; $cus_email = $Email["$key"]; $cus_sex = $sex["$key"]; if (empty($cus_firstname) && empty($cus_middlename) && empty($cus_lastname)) { continue; } if (isset($guest_cus_sn["$key"]) && !empty($guest_cus_sn["$key"])) { $cus_sn = $this->Order_model->update_customer($guest_cus_sn["$key"], $cus_firstname, $cus_middlename, $cus_lastname, $cus_nationality, $cus_passport, $cus_passportvaliddate, $cus_phone, $cus_email, $cus_sex); } else { $cus_sn = $this->Order_model->save_customer($cus_firstname, $cus_middlename, $cus_lastname, $cus_nationality, $cus_passport, $cus_passportvaliddate, $cus_phone, $cus_email, $cus_sex, $cus_deleteflag); $this->Order_model->save_ordercus($suborderID, $cus_sn, $oc_type); } } } if ($this->input->post('o_sn')) { echo json_encode(array('status' => 'ok', 'msg' => '添加成功!')); } else { echo json_encode(array('status' => 'ok_go', 'msg' => '添加成功!', 'url' => site_url('index/detail/' . $url_o_sn))); } } public function add_suborder_item($o_sn, $k) { $this->data['order_type'] = $this->lang->line('order_type'); $this->data['order_status'] = $this->lang->line('order_status'); $this->data['sex'] = $this->lang->line('sex'); $this->data['country'] = $this->lang->line('country'); //子表信息 $occ_circuitcode = ''; $occ_adultcount = 0; $occ_childrencount = 0; $occ_babycount = 0; $occ_days = -1; $occ_startdate = ''; $occ_detailtext = ''; $occ_totalprice = 0; $occ_edited_price = 1; $suborderID = $this->Order_model->save_order_circuit($o_sn, $occ_circuitcode, $occ_adultcount, $occ_childrencount, $occ_babycount, $occ_days, $occ_startdate, $occ_detailtext, $occ_totalprice, $occ_edited_price); $this->data['k'] = $k; $this->data['o_sn'] = $o_sn; $this->data['occ_sn'] = $suborderID; $this->load->view('index/add_suborder_item', $this->data); } public function delete($o_sn) { $result = $this->Order_model->delete_orders($o_sn); if ($result) { echo json_encode(array('status' => 'ok_go', 'msg' => '删除成功!', 'url' => site_url('index/index'))); } else { echo json_encode(array('status' => 'no', 'msg' => '删除失败!')); } } public function delete_guest($cus_sn) { $result = $this->Order_model->delete_guest($cus_sn); if ($result) { echo json_encode(array('status' => 'ok', 'msg' => '删除成功!')); } else { echo json_encode(array('status' => 'no', 'msg' => '删除失败!')); } } public function delete_payments($pm_sn) { $result = $this->Order_model->delete_payments($pm_sn); if ($result) { echo json_encode(array('status' => 'ok', 'msg' => '删除成功!', 'remove_elem' => '#payment_list_' . $pm_sn)); } else { echo json_encode(array('status' => 'no', 'msg' => '删除失败!')); } } public function get_pm_rmb($money, $chars, $pay_type) { $card_rate = $this->lang->line('card_rate'); $rmb = convert_to_rmb_by_char($money, $chars); $CardRate = $card_rate['1021001']; $CreditCardOnlineRate = $card_rate['1021003']; $pay_type = trim($pay_type); //15002 PayPal, 15003 信用卡, 15010 PayPal即时支付 if ($pay_type == '15002' || $pay_type == '15003' || $pay_type == '15010') { $pay_rmb = $rmb * (1 - $CardRate); } //信用卡在线支付 elseif ($pay_type == '15011') { $pay_rmb = $rmb * (1 - $CreditCardOnlineRate); } else { $pay_rmb = $rmb; } echo json_encode(array('pay_rmb' => $pay_rmb)); return true; } //根据产品号和人数天数计算产品价格201605091106 public function order_to_rmb($ordercolno, $orderdays, $adultcount, $childrencount, $babycount) { $adultcount_rmb = $orderdays * $adultcount * 100; $childrencount_rmb = $orderdays * $childrencount * 60; $babycount_rmb = $orderdays * $babycount * 30; $order_rmb = $adultcount_rmb + $childrencount_rmb + $babycount_rmb; echo json_encode(array('order_rmb' => $order_rmb)); return true; } //设置订单指定字段内容 public function set_orders($filed = 'o_status') { $o_sn = $this->input->post('o_sn'); $value = $this->input->post('value'); $result = $this->Order_model->set_orders($o_sn, $filed, $value); if ($result) { echo json_encode(array('status' => 'ok', 'msg' => '设置成功!')); } else { echo json_encode(array('status' => 'no', 'msg' => '设置失败!')); } } //返回订单上一个状态 public function goto_pre_step($o_sn) { $orderinfo = $this->Order_model->get_order_list($o_sn); $orderinfo = $orderinfo[0]; $order_step = $this->lang->line('order_step'); $current_step = array_search($orderinfo->o_status, $order_step); $value = $current_step ? ($current_step - 1 == 0 ? "新订单" : $order_step[$current_step - 1]) : "新订单"; $result = $this->Order_model->set_orders($o_sn, 'o_status', $value); redirect(site_url('index/detail/' . $o_sn)); } }