|
|
|
@ -209,8 +209,14 @@ class OrderFinance_model extends CI_Model {
|
|
|
|
|
/** 判断各种项目的报表是否已存在 */
|
|
|
|
|
public function report_tour_exists($coli_id=null, $tourCode=null, $tourBz=null)
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT top 1 ordernumber from report_tour where ordernumber=? and tourCode=? and tourBz=? ";
|
|
|
|
|
$num_rows = $this->HT->query($sql, array($coli_id, $tourCode, $tourBz))->num_rows();
|
|
|
|
|
$sql = "SELECT top 10 ordernumber from report_tour where ordernumber=? and tourCode=? ";
|
|
|
|
|
if ($tourBz) {
|
|
|
|
|
$tourBz = mb_ereg_replace('[^a-zA-Z0-9\-\[\]]', '', strstr($tourBz, ",", true));
|
|
|
|
|
$tourBz = str_replace("[", "[[]", $tourBz);
|
|
|
|
|
$sql .= " and (tourBz like '%" . $this->HT->escape_like_str($tourBz) . "%'
|
|
|
|
|
OR tourBz='') ";
|
|
|
|
|
}
|
|
|
|
|
$num_rows = $this->HT->query($sql, array($coli_id, $tourCode))->num_rows();
|
|
|
|
|
return $num_rows>0;
|
|
|
|
|
}
|
|
|
|
|
public function report_train_exists($coli_id=null, $TrainNo=null)
|
|
|
|
@ -236,14 +242,20 @@ class OrderFinance_model extends CI_Model {
|
|
|
|
|
public function insert_report_tour_tulanduo($report_tour_arr=array())
|
|
|
|
|
{
|
|
|
|
|
foreach ($report_tour_arr as $krt => $vrt) {
|
|
|
|
|
$tourBz_tmp = "";
|
|
|
|
|
if ($this->report_tour_exists($vrt['ordernumber'], $vrt['tourCode'], $vrt['tourBZ']) === TRUE) {
|
|
|
|
|
$where = " ordernumber='" . $vrt['ordernumber'] . "' AND tourCode='" . $vrt['tourCode'] . "' ";
|
|
|
|
|
$where .= " AND tourBZ='" . $vrt['tourBZ'] . "' ";
|
|
|
|
|
$update_sql = $this->HT->update_string('tourmanager.dbo.Report_Tour', $vrt, $where);
|
|
|
|
|
$this->HT->query($update_sql);
|
|
|
|
|
} else {
|
|
|
|
|
$this->HT->insert('tourmanager.dbo.Report_Tour', $vrt);
|
|
|
|
|
$tourBz_tmp = mb_ereg_replace('[^a-zA-Z0-9\-\[\]]', '', strstr($vrt['tourBZ'], ",", true));
|
|
|
|
|
$tourBz_tmp = str_replace("[", "[[]", $tourBz_tmp);
|
|
|
|
|
$where .= " AND (tourBZ like '%" . $this->HT->escape_like_str($tourBz_tmp) . "%'
|
|
|
|
|
OR tourBZ='') ";
|
|
|
|
|
$delete_sql = "DELETE FROM tourmanager.dbo.Report_Tour where " . $where;
|
|
|
|
|
// $update_sql = $this->HT->update_string('tourmanager.dbo.Report_Tour', $vrt, $where);
|
|
|
|
|
$this->HT->query($delete_sql);
|
|
|
|
|
}
|
|
|
|
|
// else {
|
|
|
|
|
$this->HT->insert('tourmanager.dbo.Report_Tour', $vrt);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|