|
|
|
|
<?php
|
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
|
|
class Group_model extends CI_Model {
|
|
|
|
|
|
|
|
|
|
function __construct() {
|
|
|
|
|
parent::__construct();
|
|
|
|
|
$this->HT = $this->load->database('HT', TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get_plan_not_received($top=1, $gri_sn=0, $start_date=null, $end_date=null)
|
|
|
|
|
{
|
|
|
|
|
$top_sql = $top>0 ? " TOP $top " : "";
|
|
|
|
|
$gri_sql = $gri_sn===0 ? "" : " and GRI_SN=$gri_sn ";
|
|
|
|
|
$sql = "SELECT $top_sql VAS_IsConfirm, VAS_SendVary,
|
|
|
|
|
GRI_OrderType, GRI_SN, GRI_No, GRI_operator,GRI_Name,
|
|
|
|
|
(select OPI_DEI_SN from OperatorInfo where OPI_SN=GRI_operator) as department,
|
|
|
|
|
(select OPI2_Name from OperatorInfo2 where OPI2_OPI_SN=GRI_operator and OPI2_LGC=2) as operator,
|
|
|
|
|
vas.*
|
|
|
|
|
from VendorArrangeState vas
|
|
|
|
|
inner join Eva_ObjectInfo eoi on EOI_GRI_SN=VAS_GRI_SN and EOI_Type=1 and EOI_ObjSN=VAS_VEI_SN
|
|
|
|
|
inner join GRoupInfo gri on GRI_SN=VAS_GRI_SN
|
|
|
|
|
where 1=1 ";
|
|
|
|
|
$sql .= $gri_sn!==0 ? $gri_sql : "
|
|
|
|
|
and VAS_IsCancel=0 and VAS_Delete=0 and vas.DeleteFlag=0
|
|
|
|
|
and VAS_IsSendSucceed=1
|
|
|
|
|
and VAS_IsConfirm=0
|
|
|
|
|
and EOI_GetDate between '$start_date' and '$end_date'
|
|
|
|
|
-- and VAS_VEI_SN in (29188, 1343, 30548) -- test
|
|
|
|
|
-- and GRI_OrderType=227002 -- test
|
|
|
|
|
and (VAS_IsReceive=0 or (VAS_SendTime > ISNULL(VAS_ReceiveTime,0))) ";
|
|
|
|
|
$sql .= " order by EOI_GetDate asc, vas.VAS_IsConfirm asc";
|
|
|
|
|
return $this->HT->query($sql)->result();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get_plan_eva($vas)
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT
|
|
|
|
|
isnull(eoi_v.EOI_SendEvaluation,0) as need_tourguide,
|
|
|
|
|
isnull(eoi_g.EOI_SN,0) as has_tourguide,
|
|
|
|
|
vas.*,eoi_v.*
|
|
|
|
|
from VendorArrangeState vas
|
|
|
|
|
inner join Eva_ObjectInfo eoi_v on EOI_GRI_SN=VAS_GRI_SN
|
|
|
|
|
and EOI_Type=1 and EOI_ObjSN=VAS_VEI_SN
|
|
|
|
|
left join Eva_ObjectInfo eoi_g on eoi_g.EOI_GRI_SN=VAS_GRI_SN
|
|
|
|
|
and eoi_g.EOI_Type=3 and eoi_g.EOI_VEI_SN=eoi_v.EOI_ObjSN
|
|
|
|
|
where VAS_SN=?
|
|
|
|
|
order by has_tourguide desc ";
|
|
|
|
|
return $this->HT->query($sql, array($vas))->result();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get_vendor_plan_info($gri_sn, $vendor_id)
|
|
|
|
|
{
|
|
|
|
|
// SET NOCOUNT ON 才能这样调用, 否则需要遍历结果集
|
|
|
|
|
// $sql = " Tourmanager.dbo.SP_VendorPlan_GetPlanInfo ?, ?, 0 ";
|
|
|
|
|
// $grd_info = $this->HT->query($sql, array($gri_sn, $vendor_id))->result();
|
|
|
|
|
include('c:/database_conn.php');
|
|
|
|
|
$connection = array(
|
|
|
|
|
'UID' => $db['HT']['username'],
|
|
|
|
|
'PWD' => $db['HT']['password'],
|
|
|
|
|
'Database' => 'tourmanager',
|
|
|
|
|
'ConnectionPooling' => 1,
|
|
|
|
|
'CharacterSet' => 'utf-8',
|
|
|
|
|
'ReturnDatesAsStrings' => 1
|
|
|
|
|
);
|
|
|
|
|
$conn = sqlsrv_connect($db['HT']['hostname'], $connection);
|
|
|
|
|
$stmt = sqlsrv_query($conn, "EXEC Tourmanager.dbo.SP_VendorPlan_GetPlanInfo $gri_sn, $vendor_id, 0 ");
|
|
|
|
|
//存储过程中每一个select都会产生一个结果集,取某个结果集就需要从第一个移动到需要的那个结果集
|
|
|
|
|
//如果结果集为空就移到下一个
|
|
|
|
|
while (sqlsrv_has_rows($stmt) !== TRUE) {
|
|
|
|
|
sqlsrv_next_result($stmt);
|
|
|
|
|
}
|
|
|
|
|
$result_object = array();
|
|
|
|
|
while ($row = sqlsrv_fetch_object($stmt)) {
|
|
|
|
|
$result_object[] = $row;
|
|
|
|
|
}
|
|
|
|
|
sqlsrv_free_stmt($stmt);
|
|
|
|
|
sqlsrv_close($conn);
|
|
|
|
|
$grd_info = $result_object;
|
|
|
|
|
$all_day_no = array_map(function($ele){return $ele->GRD_DayNo;}, $grd_info);
|
|
|
|
|
$day_no_str = implode(",", $all_day_no);
|
|
|
|
|
$all_aci = $this->get_arrange_info($gri_sn, 0, $day_no_str);
|
|
|
|
|
foreach ($grd_info as $kgrd => &$vgrd) {
|
|
|
|
|
foreach ($all_aci as $kaci => $vaci) {
|
|
|
|
|
if ($vgrd->GRD_DayNo == $vaci->ACI_DayNo) {
|
|
|
|
|
$vgrd->day_no_raw = strstr($vaci->ACI_OrderDate, " ", true);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $grd_info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get_plan_request($gri_sn)
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT * from GroupChangeInfo
|
|
|
|
|
where GCI_GRI_SN=?
|
|
|
|
|
order by LastEditTime desc
|
|
|
|
|
,case when GCI_Order IS null then 999 else GCI_Order end desc";
|
|
|
|
|
return $this->HT->query($sql, array($gri_sn))->row();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get_arrange_info($gri_sn, $vendor_id=0, $day_no="")
|
|
|
|
|
{
|
|
|
|
|
$param_arr = array($gri_sn);
|
|
|
|
|
$vendor_sql = "";
|
|
|
|
|
if ($vendor_id !== 0) {
|
|
|
|
|
$vendor_sql = " AND aci.ACI_VEI_SN=? ";
|
|
|
|
|
$param_arr[] = $vendor_id;
|
|
|
|
|
}
|
|
|
|
|
$day_no_sql = ($day_no !== "") ? " AND aci.ACI_DayNo IN ($day_no) " : "";
|
|
|
|
|
$sql = "SELECT
|
|
|
|
|
(select CII2_Name from CItyInfo2
|
|
|
|
|
where CII2_CII_SN=ACI_FromCity and CII2_LGC=2) as fromcity,
|
|
|
|
|
(select CII2_Name from CItyInfo2
|
|
|
|
|
where CII2_CII_SN=ACI_ToCity and CII2_LGC=2) as tocity,
|
|
|
|
|
(select CII_PKCode from CItyInfo
|
|
|
|
|
where CII_SN=ACI_ToCity ) as citycode,
|
|
|
|
|
*
|
|
|
|
|
from ArrangeConfirmInfo aci
|
|
|
|
|
where 1=1
|
|
|
|
|
and aci.ACI_GRI_SN=?
|
|
|
|
|
$vendor_sql
|
|
|
|
|
$day_no_sql
|
|
|
|
|
order by ACI_DayNo,ACI_SNInOneDay ";
|
|
|
|
|
return $this->HT->query($sql, $param_arr)->result();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get_sync_info($vas, $tour_code="")
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT *
|
|
|
|
|
from VendorPlanSendout
|
|
|
|
|
where VPS_VAS_SN=? ";
|
|
|
|
|
$param_arr = array($vas);
|
|
|
|
|
if ($tour_code !== "") {
|
|
|
|
|
$sql .= " AND VPS_tourCode=? ";
|
|
|
|
|
$param_arr[] = $tour_code;
|
|
|
|
|
}
|
|
|
|
|
return $this->HT->query($sql, $param_arr)->row();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get_sync_info_by_vendororder($vendor_order_id)
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT
|
|
|
|
|
opi.OPI_DEI_SN as department,
|
|
|
|
|
*
|
|
|
|
|
from VendorPlanSendout vps
|
|
|
|
|
inner join VendorArrangeState vas on vas.VAS_SN=vps.VPS_VAS_SN
|
|
|
|
|
inner join GRoupInfo gri on GRI_SN=vas.VAS_GRI_SN
|
|
|
|
|
left join OperatorInfo opi on opi.OPI_SN=GRI_operator
|
|
|
|
|
where VPS_externalId=? ";
|
|
|
|
|
$param_arr = array($vendor_order_id);
|
|
|
|
|
return $this->HT->query($sql, $param_arr)->row();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* 获取地接社接受计划的人员信息
|
|
|
|
|
* @param $vendorID 地接社ID
|
|
|
|
|
*/
|
|
|
|
|
public function get_vendorContact($vendorID)
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT top 1 lmi2.LMI2_Name,
|
|
|
|
|
lmi.LMI_SN,
|
|
|
|
|
lmi.LMI_AutoFax,
|
|
|
|
|
lmi.LMI_Telephone,
|
|
|
|
|
lmi.LMI_Mobile,
|
|
|
|
|
lmi.LMI_ListMail
|
|
|
|
|
,vei2.VEI2_CompanyBN
|
|
|
|
|
FROM LinkmanInfo lmi
|
|
|
|
|
INNER JOIN LinkManInfo2 lmi2 ON lmi2.LMI2_LMI_SN=lmi.LMI_SN AND lmi2.LMI2_LGC=2
|
|
|
|
|
INNER JOIN VEndorInfo2 vei2 ON vei2.VEI2_VEI_SN=LMI_VEI_SN AND VEI2_LGC=2
|
|
|
|
|
WHERE LMI_Receiver='Yes' AND LMI_VEI_SN=$vendorID";
|
|
|
|
|
$query = $this->HT->query($sql);
|
|
|
|
|
return $query->row();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function search_tourguide($vendor, $cn_name, $en_name=null, $mobile=null)
|
|
|
|
|
{
|
|
|
|
|
$param_arr = array($cn_name);
|
|
|
|
|
$en_sql = " ";
|
|
|
|
|
if (strval($en_name)!=="") {
|
|
|
|
|
$en_sql = " and tgi_en.TGI2_Name =? ";
|
|
|
|
|
$param_arr[] = $en_name;
|
|
|
|
|
}
|
|
|
|
|
$mobile_sql = " ";
|
|
|
|
|
if (strval($mobile)!=="") {
|
|
|
|
|
$mobile_sql = " or TGI_Mobile=? ";
|
|
|
|
|
$param_arr[] = $mobile;
|
|
|
|
|
}
|
|
|
|
|
$sql = "SELECT TGI_VEI_SN,TGI_Mobile,
|
|
|
|
|
tgi_cn.TGI2_Name cn_name,
|
|
|
|
|
tgi_en.TGI2_Name en_name,
|
|
|
|
|
TGI_SN
|
|
|
|
|
from TouristGuideInfo2 tgi_en
|
|
|
|
|
join TouristGuideInfo on TGI_SN=tgi_en.TGI2_TGI_SN and tgi_en.TGI2_LGC=1
|
|
|
|
|
join TouristGuideInfo2 tgi_cn on TGI_SN=tgi_cn.TGI2_TGI_SN and tgi_cn.TGI2_LGC=2
|
|
|
|
|
where (
|
|
|
|
|
( 1=1
|
|
|
|
|
and tgi_cn.TGI2_Name like '%" . $this->HT->escape_like_str($cn_name) . "%'
|
|
|
|
|
$en_sql
|
|
|
|
|
)
|
|
|
|
|
$mobile_sql
|
|
|
|
|
)
|
|
|
|
|
and TGI_VEI_SN in ($vendor)";
|
|
|
|
|
return $this->HT->query($sql, $param_arr)->row();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function set_plan_tourguide($eva_g_sn=0, $column=array())
|
|
|
|
|
{
|
|
|
|
|
if ($eva_g_sn===0) {
|
|
|
|
|
// 第一次设置导游
|
|
|
|
|
$this->HT->insert("Eva_ObjectInfo", $column);
|
|
|
|
|
$eva_g_sn = $this->HT->query("SELECT MAX(EOI_SN) EOI_SN from Eva_ObjectInfo
|
|
|
|
|
where EOI_GRI_SN=?
|
|
|
|
|
and EOI_VEI_SN=?
|
|
|
|
|
and EOI_Type=3
|
|
|
|
|
", array($column['EOI_GRI_SN'], $column['EOI_VEI_SN']))
|
|
|
|
|
->row()->EOI_SN;
|
|
|
|
|
} else {
|
|
|
|
|
// 变更导游设置
|
|
|
|
|
$update_where = " EOI_SN=".$eva_g_sn;
|
|
|
|
|
$update_sql = $this->HT->update_string("Eva_ObjectInfo", $column, $update_where);
|
|
|
|
|
$this->HT->query($update_sql);
|
|
|
|
|
}
|
|
|
|
|
return $eva_g_sn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function set_plan_received($vas_sn=0)
|
|
|
|
|
{
|
|
|
|
|
$sql = "UPDATE VendorArrangeState set VAS_IsReceive=1,VAS_ReceiveTime=GETDATE() where VAS_SN=? ";
|
|
|
|
|
return $this->HT->query($sql, array($vas_sn));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* 地接计划状态变更
|
|
|
|
|
* @param [type] $vas_sn [description]
|
|
|
|
|
* @param string $confirminfo [description]
|
|
|
|
|
*/
|
|
|
|
|
public function set_plan_confirm($vas_sn, $lmi_sn, $confirminfo="")
|
|
|
|
|
{
|
|
|
|
|
$sql = "UPDATE VendorArrangeState
|
|
|
|
|
SET VAS_IsConfirm=1
|
|
|
|
|
,VAS_ConfirmInfo=?
|
|
|
|
|
,VAS_ConfirmTime=GETDATE()
|
|
|
|
|
,VAS_ConfirmSN=?
|
|
|
|
|
WHERE VAS_SN=?";
|
|
|
|
|
$query = $this->HT->query($sql, array($confirminfo, $lmi_sn, $vas_sn));
|
|
|
|
|
// affected_rows() doesn't work with the 'sqlsrv' driver in CI2
|
|
|
|
|
// The solution: Upgrade to the latest CodeIgniter 3.0.x version
|
|
|
|
|
$ssql = "SELECT 1 as 'exist' from VendorArrangeState where VAS_IsConfirm=1 and VAS_SN=? ";
|
|
|
|
|
$squery = $this->HT->query($ssql, array($vas_sn));
|
|
|
|
|
$ret = $squery->result();
|
|
|
|
|
return !empty($ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function insert_VendorPlanSync($sync_arr=array())
|
|
|
|
|
{
|
|
|
|
|
$this->HT->insert('VendorPlanSendout', $sync_arr);
|
|
|
|
|
return $this->HT->query("SELECT MAX(VPS_SN) VPS_SN from VendorPlanSendout")
|
|
|
|
|
->row()->VPS_SN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function update_VendorPlanSync($vps, $sync_arr=array())
|
|
|
|
|
{
|
|
|
|
|
$where = " VPS_SN=" . $vps;
|
|
|
|
|
$update_sql = $this->HT->update_string('VendorPlanSendout', $sync_arr, $where);
|
|
|
|
|
return $this->HT->query($update_sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 发送邮件
|
|
|
|
|
*/
|
|
|
|
|
public function save_automail($M_SenderName, $M_SenderEmail, $fromName, $fromEmail, $toName, $toEmail, $subject, $body, $frominfo = 'vendorConfirm msg', $M_RelatedInfo = '', $M_State = 0, $M_AddTime = '', $M_Web = 'vendorConfirm msg') {
|
|
|
|
|
$sql = "INSERT INTO
|
|
|
|
|
Email_AutomaticSend (
|
|
|
|
|
M_SenderName,
|
|
|
|
|
M_SenderEmail,
|
|
|
|
|
M_ReplyToName,
|
|
|
|
|
M_ReplyToEmail,
|
|
|
|
|
M_ToName,
|
|
|
|
|
M_ToEmail,
|
|
|
|
|
M_Title,
|
|
|
|
|
M_Body,
|
|
|
|
|
M_Web,
|
|
|
|
|
M_FromName,
|
|
|
|
|
M_ServiceSN,
|
|
|
|
|
M_State,
|
|
|
|
|
M_AddTime
|
|
|
|
|
) VALUES (N?, N?, N?, N?, N?, N?, N?, N?, ?, N?, ?,?,getdate()) ";
|
|
|
|
|
$query = $this->HT->query($sql, array($M_SenderName, $M_SenderEmail, $fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_Web, $frominfo, $M_RelatedInfo, $M_State));
|
|
|
|
|
return $query;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* End of file Group_model.php */
|
|
|
|
|
/* Location: ./third_party/vendorPlanSync/models/Group_model.php */
|