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/application/third_party/order/controllers/confirm.php

144 lines
6.2 KiB
PHTML

<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Confirm extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('Order_model');
}
public function index($COLI_SN = false, $visitor_link = false, $token = false) {
$data = array();
if (empty($COLI_SN) || strtoupper(md5($visitor_link)) != strtoupper($token)) {
echo '<div class="hidden">校验不对</div>';
$this->load->view('link_tips', $data);
return false;
}
$data['visitor_link'] = $visitor_link;
$data['userinfo'] = $this->Order_model->get_customer_info($COLI_SN);
$data['username'] = '';
if (!empty($data['userinfo'])) {
foreach ($data['userinfo'] as $v) {
if ($v->CUL_IsLinkMan == 1) {
$data['username'] = $v->MEI_FirstName;
$data['usermail'] = $v->MEI_MailList;
}
}
} else {
$this->load->view('link_tips', $data);
return false;
}
$visitor_link_arr = $this->Order_model->get_visitor_link($COLI_SN);
foreach ($visitor_link_arr as $l) {
if ($visitor_link == $l->visitor_link) {
$this->load->view('link_tips', $data);
return false;
}
}
$this->load->view('confirm_order', $data);
}
public function save_confirm_info() {
//客人信息
$gender = $this->input->post('gender');
$given_name = $this->input->post('given_name');
$birthday = $this->input->post('birthday');
$passport = $this->input->post('passport');
$expiration_date = $this->input->post('passport_expiration_date');
$nationality = $this->input->post('nationality');
$contact_phone = '座机:' . $this->input->post('landline') . '/手机:' . $this->input->post('mobile');
$COLI_SN = $this->input->post('COLI_SN');
$visitor_link = $this->input->post('visitor_link');
$COLI_ID = $this->input->post('COLI_ID');
//已经确认过
$had_save = $this->Order_model->get_visitor_link($COLI_SN, $visitor_link);
if (!empty($had_save)) {
echo json_encode(array('status' => 'ok'));
return;
}
$MEI_SN = false;
foreach ($this->input->post('sur_name') as $key => $name) {
if (!empty($name)) {
if ($this->input->post('home_address') != '') {
$MEI_Street = $this->input->post('home_address');
} elseif ($this->input->post('address_street')) {
$MEI_Street = $this->input->post('address_street') . ',' . $this->input->post('address_city') . ',' . $this->input->post('address_state') . ',' . $this->input->post('address_country');
} else {
$MEI_Street = '';
}
$data['MEI_Street'] = $MEI_Street;
if (isset($given_name[$key]) && $given_name[$key] != 'None') {
$MEI_FirstName = $given_name[$key];
} else {
$MEI_FirstName = '';
}
$MEI_LastName = $name;
if ($this->input->post('arrive_flight')) {
$CUL_Memo = 'Arrival China Flight No : '
. $this->input->post('arrive_flight')
. ' & Arrival time : '
. $this->input->post('arrive_time')
. ' & Departure China Flight no : '
. $this->input->post('departure_flight')
. ' & Departure time : '
. $this->input->post('depart_time');
} else {
$CUL_Memo = '';
}
$CUL_Memo .= $this->input->post('insurance_information');
$MEI_Memo = $this->input->post('special_request') . ' ' . $CUL_Memo;
//$birthday[$key] = date('Y-m-d H:i:s', strtotime($birthday[$key]));
$birthday_tmp = date('Y-m-d H:i:s', strtotime($birthday[$key]));
//$expiration_date[$key] = date('Y-m-d H:i:s', strtotime($expiration_date[$key]));
$expiration_date_tmp = date('Y-m-d H:i:s', strtotime($expiration_date[$key]));
$MEI_SN = $this->Order_model->add_customer_info($gender[$key], $nationality[$key], $MEI_FirstName, $MEI_LastName, $passport[$key], $expiration_date_tmp, $birthday_tmp, $MEI_Memo, $MEI_Street, '', $contact_phone, 0, $COLI_SN, $visitor_link);
}
}
if ($MEI_SN && $this->input->post('emergency_person_name') != '') {
$add_emergency_res = $this->Order_model->add_customer_info(
'', '', $this->input->post('emergency_person_name'), '', '', '', '', $this->input->post('emergency_relationship'), '', $this->input->post('emergency_email'), $this->input->post('emergency_telephone'), 1, $COLI_SN, $visitor_link
);
}
if ($MEI_SN) {
$customer_usermail = $this->input->post('customer_usermail');
$customer_username = $this->input->post('customer_username');
$toname = $this->input->post('toname');
$tomail = $this->input->post('tomail');
$data['postdata'] = $this->input->post();
$mail_text = $this->load->view('mailtext', $data, true);
$this->Order_model->send_mail('chinahighlights', 'service@chinahighlights.com', $toname, $tomail, $COLI_ID . ' 团个人信息导入HT', $COLI_ID . ' 团个人信息导入HT<br>' . $mail_text, 'China Highlights', $M_Web = 'CHT_USERINFO');
//发送信息给客人
//$this->Order_model->send_mail($toname, $tomail, $customer_username, $customer_usermail, 'Passenger Information', $mail_text, 'China Highlights', $M_Web = 'CHT_USERINFO');
echo json_encode(array('status' => 'ok'));
} else {
echo json_encode(array('status' => 'no'));
}
}
function review() {
$data = array();
$data['postdata'] = $this->input->post();
$mail_text = $this->load->view('mailtext', $data, true);
echo json_encode($mail_text);
}
}