load->helper('array'); $this->load->model('Orders_query', 'Orders_model'); } public function index() { // echo "string"; // return; $this->operation_detail(); } public function operation_detail($find=null) { header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Methods:POST, GET'); header('Access-Control-Max-Age:0'); header('Access-Control-Allow-Headers:x-requested-with, Content-Type'); header('Access-Control-Allow-Credentials:true'); ($find===null) ? $find = $this->input->get_post('q') : null; $find = (mb_strlen($find)<9) ? null : $this->input->get_post('q'); $order_project = $this->Orders_model->get_package_order($find); if ($find===null || $order_project == null) { $ret['status'] = 0; $ret['msg'] = "Not Found."; return $this->output->set_content_type('application/json')->set_output(json_encode($ret)); } $ret['status'] = 1; $ret['msg'] = ""; $group_number_info = analysis_groupCode($order_project[0]->COLI_GroupCode); $ret['group_number'] = $group_number_info["cut"]; $all_combine_no = array_unique(array_map(function($ele) { return $ele->GCI_combineNo; }, $order_project)); $ret['operation'] = array(); $operation = $this->Orders_model->get_operation($all_combine_no); // 司机, 导游 if ( ! empty($operation)) { // 按照实际安排的日期分组 foreach ($operation as $key => $value) { if ($value->GCOD_operationType === 'touristCarOperations') { $tmp_car = array(); $tmp_car['car_type'] = $value->GCOD_subType; $tmp_car['car_company'] = $value->GCOD_title; $tmp_car['car_license'] = $value->GCOD_carLicense; $tmp_car['driver_name'] = $value->GCOD_dutyName; $tmp_car['driver_tel'] = $value->GCOD_dutyTel; $tmp_car['driver_pic'] = $value->GCOD_dutyPhoto; $tmp_car['car_remark'] = $value->GCOD_remark; $tmp_car['using_startdate'] = $value->GCOD_startDate; $tmp_car['using_enddate'] = $value->GCOD_endDate; $ret['operation'][$value->GCOD_startDate]['cardriver'][] = $tmp_car; // 出团时间 $ret['operation'][$value->GCOD_startDate]['start_date'] = $value->GCOD_startDate; } else if ($value->GCOD_operationType === 'guiderOperations') { $tmp_g = array(); $tmp_g['guide_name'] = $value->GCOD_dutyName; $tmp_g['guide_tel'] = $value->GCOD_dutyTel; $tmp_g['guide_pic'] = $value->GCOD_dutyPhoto; $tmp_g['guide_remark'] = $value->GCOD_remark; $tmp_g['using_startdate'] = $value->GCOD_startDate; $tmp_g['using_enddate'] = $value->GCOD_endDate; $ret['operation'][$value->GCOD_startDate]['tourguide'][] = $tmp_g; // 出团时间 $ret['operation'][$value->GCOD_startDate]['start_date'] = $value->GCOD_startDate; } } // 加上行程 $num_index = 0; foreach ($ret['operation'] as $kro => &$vro) { $out_datetime = strtotime($vro['start_date']); $vro['dateWeek_text'] = date('D', $out_datetime); $vro['dateDay_text'] = date('d', $out_datetime); $vro['dateMonth_text'] = date('M', $out_datetime); $vro['dateYear_text'] = date('Y', $out_datetime); $poi = new stdclass(); foreach ($order_project as $kd => $poi_info) { if (strcmp($vro['start_date'], substr($poi_info->COLD_StartDate, 0, 10) ) === 0) { if (count((array)$poi)===0) { $poi = $poi_info; } else if ($poi->POI_Hotel == "") { $poi->POI_Hotel = $poi_info->POI_Hotel; $poi->POI_HotelAddress = $poi_info->POI_HotelAddress; $poi->POI_HotelPhone = $poi_info->POI_HotelPhone; // } else if ($poi->POI_FlightsNo == "") { } else if ($poi_info->POI_FlightsNo != "" && $poi_info->COLD_SN != $poi->COLD_SN) { $poi->POI_FlightsNo .= "; " . $poi_info->POI_FlightsNo; // $poi->POI_AirPort .= "; " . $poi_info->POI_AirPort; } } } if (count((array)$poi)===0) { $poi = $order_project[0]; } $vro['cold_date'] = $poi->COLD_StartDate; $vro['cold_enddate'] = $poi->COLD_EndDate; $vro['tour_name'] = $poi->PAG2_Name; // 领队名字 $vro['leader_name'] = trim($poi->GUT_FirstName . " " . $poi->GUT_LastName); // 行程人数 $vro['personNum_text'] = $poi->COLD_PersonNum + $poi->COLD_ChildNum; $vro['personNum_text'] .= " (" . $poi->COLD_PersonNum . " Adult(s)"; if ($poi->COLD_ChildNum > 0) { $vro['personNum_text'] .= " " . $poi->COLD_ChildNum . " Child(ren)"; } $vro['personNum_text'] .= ")" ; // 人数 $vro['adult_number'] = $order_project[0]->COLD_PersonNum; $vro['kid_number'] = $order_project[0]->COLD_ChildNum; // 酒店 $vro['hotel_name'] = $poi->POI_Hotel; $vro['hotel_address'] = $poi->POI_HotelAddress; $vro['hotel_tel'] = $poi->POI_HotelPhone; // 航班/车次 $vro['flights_no'] = $poi->POI_FlightsNo; $vro['flights_airport'] = $poi->POI_AirPort; // 接送信息 $vro['pick_up'] = ""; $vro['drop_off'] = ""; $decode_MemoText = $memo_text_tmp = ""; if ($vro['pick_up'] === "" && $poi->COLD_MemoText != null && json_decode($poi->COLD_MemoText) != null) { $decode_MemoText = json_decode($poi->COLD_MemoText, true); $vro['pick_up'] = $decode_MemoText['Pick up']; $vro['drop_off'] = $decode_MemoText['Drop off']; } if ($vro['pick_up'] === "" && $num_index == 0) { $vro['pick_up'] = trim(substr(strstr(strstr($poi->COLI_OrderDetailText, "Pick Up From:"), "\n", true), 13)); $vro['drop_off'] = trim(substr(strstr(strstr($poi->COLI_OrderDetailText, "Drop Off:"), "\n" , true), 9)); } if ($vro['pick_up'] === "") { if (strval($poi->PAGS_Direction) === '0') { $vro['pick_up'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort; $vro['drop_off'] .= $poi->POI_Hotel; } else if (strval($poi->PAGS_Direction) === '1') { $vro['pick_up'] .= $poi->POI_Hotel; $vro['drop_off'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort; } else { // if ($poi->POI_FlightsNo != "") $vro['pick_up'] .= $poi->POI_Hotel; // $vro['drop_off'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort; // 结束后送机 } } $num_index++; } unset($vro); } $ret['operation'] = array_values($ret['operation']); $ret_operation = array(); foreach ($ret['operation'] as $ko => $vo) { if (strtotime($vo['start_date']) >= strtotime($vo['cold_date']) && strtotime($vo['start_date']) <= strtotime($vo['cold_enddate'])) { unset($vo['cold_date']); unset($vo['cold_enddate']); $ret_operation[] = $vo; continue; } } $ret['operation'] = $ret_operation; /** 外联信息 */ $raw_opi_id = 0; if (intval($order_project[0]->COLI_OPI_ID) === 435) { $real_code_info = analysis_groupCode($ret['group_number']); $raw_opi_id = $this->Orders_model->get_gri_opi_id($real_code_info['cut']); } else { $raw_opi_id = $order_project[0]->COLI_OPI_ID; } $operator = $this->Orders_model->get_operator($raw_opi_id); if ( ! empty($operator)) { $ret['operator']['chinese_name'] = $operator->OPI_Name; $ret['operator']['mobile'] = $operator->OPI_MoveTelephone; $ret['operator']['email'] = $operator->OPI_Email; $ret['operator']['english_name'] = $operator->OPI2_Name; // 英文名没有 if ($operator->OPI_FirstName == null || $operator->OPI2_Name == null ) { $ret['operator']['english_name'] = ucfirst(strstr($operator->OPI_Email, "@", true)); } } return $this->output->set_content_type('application/json')->set_output(json_encode($ret)); } } /* End of file api.php */ /* Location: ./third_party/trippestOrderSync/controllers/api.php */