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

85 lines
4.1 KiB
PHTML

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Api extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->helper('array');
$this->load->model('Orders_model');
mb_regex_encoding("UTF-8");
}
public function index()
{
$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;
$order_obj = $this->Orders_model->get_operation_detail_for_client($find);
if ($order_obj['order_info'] == null) {
$order_obj['status'] = 0;
$order_obj['msg'] = "Not Found.";
return $this->output->set_content_type('application/json')->set_output(json_encode($order_obj));
}
$order_obj['status'] = 1;
$order_obj['msg'] = "";
// 英文名没有
if ($order_obj['operator_info']->OPI_FirstName == null
|| $order_obj['operator_info']->OPI2_Name == null ) {
$order_obj['operator_info']->OPI_FirstName = $order_obj['operator_info']->OPI2_Name
= ucfirst(strstr($order_obj['operator_info']->OPI_Email, "@", true));
}
// 领队名字
$order_obj['order_info']->leader_name = trim($order_obj['order_info']->GUT_FirstName . " " . $order_obj['order_info']->GUT_LastName);
// 团人数
$order_obj['order_info']->personNum_text = $order_obj['order_info']->COLD_PersonNum + $order_obj['order_info']->COLD_ChildNum;
$order_obj['order_info']->personNum_text .= " (" . $order_obj['order_info']->COLD_PersonNum . " Adult(s)";
if ($order_obj['order_info']->COLD_ChildNum > 0) {
$order_obj['order_info']->personNum_text .= " " . $order_obj['order_info']->COLD_ChildNum . " Child(ren)";
}
$order_obj['order_info']->personNum_text .= ")" ;
// 出团时间
$out_datetime = strtotime($order_obj['order_info']->COLD_StartDate);
$order_obj['order_info']->dateWeek_text = date('D', $out_datetime);
$order_obj['order_info']->dateDay_text = date('d', $out_datetime);
$order_obj['order_info']->dateMonth_text = date('M', $out_datetime);
$order_obj['order_info']->dateYear_text = date('Y', $out_datetime);
// 接送信息
$order_obj['order_info']->pick_up = "";
$order_obj['order_info']->drop_off = "";
if ($order_obj['order_info']->COLD_MemoText != null && json_decode($order_obj['order_info']->COLD_MemoText) != null) {
$decode_MemoText = json_decode($order_obj['order_info']->COLD_MemoText, true);
$order_obj['order_info']->pick_up = $decode_MemoText['Pick up'];
$order_obj['order_info']->drop_off = $decode_MemoText['Drop off'];
} else {
$memo_text_tmp = trim(strstr($order_obj['order_info']->COLD_MemoText, "Pick Up From:"));
$order_obj['order_info']->pick_up = trim(strstr($memo_text_tmp, "Drop Off:", true));
$order_obj['order_info']->drop_off = trim(strstr($memo_text_tmp, "Drop Off:"));
}
// 司机, 导游
if ( ! empty($order_obj['operation_info'])) {
foreach ($order_obj['operation_info'] as $key => $value) {
$order_obj['operation_info'][$value->GCOD_operationType] = $value;
}
unset($order_obj['operation_info'][0]);
unset($order_obj['operation_info'][1]);
}
// unset($order_obj['order_info']->COLD_MemoText);
unset($order_obj['order_info']->GUT_FirstName);
unset($order_obj['order_info']->GUT_LastName);
return $this->output->set_content_type('application/json')->set_output(json_encode($order_obj));
}
}
/* End of file api.php */
/* Location: ./third_party/trippestOrderSync/controllers/api.php */