You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
information-system/webht/third_party/trippestOrderSync/controllers/api.php

165 lines
7.8 KiB
PHTML

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Api extends CI_Controller {
public function __construct(){
parent::__construct();
mb_regex_encoding("UTF-8");
$this->load->helper('array');
$this->load->model('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'] = "";
$ret['group_number'] = $order_project[0]->COLI_GroupCode;
$all_combine_no = array_unique(array_map(function($ele)
{
return $ele->GCI_combineNo;
}, $order_project));
$ret['operation'] = null;
$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;
}
}
// 加上行程
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 = $order_project[0];
foreach ($order_project as $kd => $poi_info) {
if (strcmp($vro['start_date'], substr($poi_info->COLD_StartDate, 0, 10) ) === 0) {
$poi = $poi_info;
break;
}
}
$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 ($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'];
} else {
$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));
}
}
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 = analysis_groupCode($ret['group_number']);
$raw_opi_id = $this->Orders_model->get_gri_opi_id($real_code);
} 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 */