Trippest汇总:下载明细:查询数据

feature/trippest
lyt 6 years ago
parent 718b396938
commit d3b36fccdf

@ -21,9 +21,9 @@ class Vendor_money extends CI_Controller {
$this->load->view('vendor_money_sum', $data);
}
public function index()
public function index($download_vendor=null)
{
$this->permission->is_admin(true);
// $this->permission->is_admin(true); // test:
$date_range = $this->input->post("date_range");
preg_match_all('/\d{4}\-\d{2}\-\d{2}/', $date_range, $date_range_arr);
if (empty($date_range_arr[0])) {
@ -36,6 +36,12 @@ class Vendor_money extends CI_Controller {
}
$vendors = $this->input->post("vendors");
$vendor_sourcetype = $this->trippest->vendor_sourcetype();
if ($download_vendor !== null) {
$vendors = array($download_vendor);
$sourcetype = $vendor_sourcetype[strval($download_vendor)]["sourcetype"];
$vendor_data = $this->money_model->group_detail_list($download_vendor, $sourcetype, $start_date, $end_date, implode(',', $vendors));
return $this->output->set_content_type('application/json')->set_output(json_encode($vendor_data, JSON_UNESCAPED_UNICODE));
}
$result = array(
"default_date1" => $start_date
,"default_date2" => $end_date
@ -185,11 +191,34 @@ class Vendor_money extends CI_Controller {
$result['col_sum']['trippest']['sum_payout'] = bcadd($result['col_sum']['trippest']['sum_payout'], $vmi['trippest']['payout']);
$result['col_sum']['vendor']['sum_payout'] = bcadd($result['col_sum']['vendor']['sum_payout'], $vmi['vendor']['payout']);
}
// return $this->output->set_content_type('application/json')->set_output(json_encode($result));
$this->load->view('vendor_money_sum', $result);
return ;
}
public function detail($download_vendor=null)
{
// $this->permission->is_admin(true); // test:
$date_range = $this->input->post("date_range");
preg_match_all('/\d{4}\-\d{2}\-\d{2}/', $date_range, $date_range_arr);
if (empty($date_range_arr[0])) {
return $this->settlement();
}
$start_date = $date_range_arr[0][0];
$end_date =$date_range_arr[0][1] . " 23:59:59";
if ($end_date == null) {
$end_date = date("Y-m-d H:i:s", strtotime("+1 month", strtotime($start_date))-1);
}
$vendors = $this->input->post("vendors");
if ($download_vendor !== null) {
$vendors = array($download_vendor);
}
$vendor_sourcetype = $this->trippest->vendor_sourcetype();
$sourcetype = $vendor_sourcetype[strval($download_vendor)]["sourcetype"];
$vendor_data = $this->money_model->group_detail_list($download_vendor, $sourcetype, $start_date, $end_date, implode(',', $vendors));
return $this->output->set_content_type('application/json')->set_output(json_encode($vendor_data));
}
}
/* End of file vendor_money.php */

@ -224,6 +224,83 @@ class Vendor_money_model extends CI_Model {
return $query->result_array();
}
public function group_detail_list($vendor, $sourcetype, $start_date, $end_date, $all_vendor)
{
$sql = "SELECT
(dbo.ConvertToRMB('USD',other_vendor_price)) as other_vendorprice_RMB,
case when other_vendor_price > 0 then
(total_income-dbo.ConvertToRMB('USD',other_vendor_price))
else haina_income_origin end
as haina_income,
*
from (
select
COLI_SN,
(select isnull(SUM(COLD_TotalPrice),0) from BIZ_ConfirmLineDetail
where COLD_COLI_SN=COLI_SN
--and COLD_ServiceType='D'
and DeleteFlag=0
and COLD_PlanVEI_SN<>$vendor
and COLD_PlanVEI_SN not in ($all_vendor)
) as other_vendor_price,
COLI.COLI_sourcetype,
COLI.COLI_Price,
coli.COLI_Currency,
case when coli.COLI_Price <> 0 then
convert(decimal(10,2),round((select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
)/isnull(COLI.COLI_Price,1),2))
else 0 end as exchange_rate,
(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
) as total_income,
(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
and GAI_Type not in (" . PAY_OTHER . ")
) as haina_income_origin,
(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
and GAI_VEI_SN=$vendor
and GAI_Type in (" . PAY_OTHER . ")
) as vendor_income
,coli.COLI_OPI_ID
, gri.GRI_Name
,(select SUM(isnull(tourcost,0)) from report_tour where ordernumber=COLI_ID and exists (
select 1 from BIZ_ConfirmLineDetail where COLD_SN=RPT_COLD_SN
and COLD_PlanVEI_SN=$vendor
)
) as group_vendor_cost
,(select sum(RPT_Total )
from report_tour
where ordernumber=COLI_ID and exists (
select 1 from BIZ_ConfirmLineDetail where COLD_SN=RPT_COLD_SN
and COLD_PlanVEI_SN=$vendor
)
) as gcod_total
,(select SUM(isnull(basemoney,0)) from report_order where gri_sn=RO_GRI_SN
) as order_cost
,(select top 1 GCI_combineNo from GroupCombineInfo where GRI_SN=GCI_GRI_SN) as gci_no
from CK_GroupInfo cgi
inner join GRoupInfo gri on CGI_GRI_SN=GRI_SN
inner join BIZ_ConfirmLineInfo coli on COLI_GRI_SN=GRI_SN
where 1=1
and CGI_ArriveDate between '$start_date' and '$end_date'
and exists (
select 1 from OperatorInfo where OPI_DEI_SN=30 and OPI_SN=CGI_OPI_SN
)
and CGI_Checked=1
and GRI_OrderType=227002
and exists (
select 1 from BIZ_ConfirmLineDetail where COLD_COLI_SN=coli.COLI_SN
and DeleteFlag=0
and COLD_PlanVEI_SN=$vendor
)
-- and COLI_sourcetype=$sourcetype
) as cgi_group";
$query = $this->HT->query($sql);
return $query->result();
}
}

@ -28,6 +28,7 @@
.text-left {text-align: left;}
.text-right {text-align: right;}
.text-bold {font-weight: bold;}
.cell-right {float: right;}
</style>
</head>
<body>
@ -94,7 +95,9 @@
foreach ($money as $kt => $trippest) {
?>
<tr>
<td class="text-left"><?php echo $trippest['vendor_name'] ?></td>
<td class="text-left"><?php echo $trippest['vendor_name'] ?>
<a href="index/<?php echo $trippest['vendor_code'] ?>" class="cell-right">导出账单明细&nbsp;&dArr;</a>
</td>
<td><?php echo $trippest['trippest']['trippest_sum'] ?></td>
<td><?php echo $trippest['trippest']['vendor_sum'] ?></td>
<td><?php echo $trippest['trippest_cost'] ?></td>

Loading…
Cancel
Save