Merge branch 'feature/trippest'

hotfix/远程访问多媒体中心
lyt 6 years ago
commit f47521a410

@ -21,7 +21,7 @@ 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);
$date_range = $this->input->post("date_range");
@ -36,6 +36,14 @@ 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_name = $vendor_sourcetype[strval($download_vendor)]["vendor_name"];
$vendor_data = $this->money_model->group_detail_list($download_vendor, $sourcetype, $start_date, $end_date, implode(',', $vendors));
$file_name = str_replace(" ", "_", $date_range) . "_" . $vendor_name;
return $this->download_output($vendor_data, $file_name);
}
$result = array(
"default_date1" => $start_date
,"default_date2" => $end_date
@ -185,11 +193,87 @@ 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));
}
public function download_output($export_list, $file_name)
{
if (empty($export_list)) {
return false;
}
$this->load->library('PHPExcel');
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
//set width
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(20);
// 对齐
$objPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$objPHPExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
// 表标题行
$objPHPExcel->getActiveSheet()
->SetCellValue('A1', '#')
->SetCellValue('B1', '团号')
->SetCellValue('C1', '①海纳代收')
->SetCellValue('D1', '②地接代收')
->SetCellValue('E1', '③海纳成本')
->SetCellValue('F1', '④地接成本')
->SetCellValue('G1', '⑤利润');
bcscale(2);
$rowCount = 2;
foreach ($export_list as $key => $row) {
$objPHPExcel->getActiveSheet()
->SetCellValue('A'.$rowCount, ($rowCount-1))
// ->SetCellValue('A'.$rowCount, $row->pn_sn)
->setCellValueExplicit('B'.$rowCount, $row['GRI_No'],PHPExcel_Cell_DataType::TYPE_STRING)
->setCellValue('C'.$rowCount, number_format($row['haina_income'], 2, ".", ""))
->setCellValue('D'.$rowCount, number_format($row['vendor_income'], 2, ".", ""))
->SetCellValue('E'.$rowCount, 0)
->SetCellValue('F'.$rowCount, $row['group_vendor_cost'])
->setCellValue('G'.$rowCount, bcsub(bcadd($row['vendor_income'],$row['haina_income']),$row['group_vendor_cost']))
;
$rowCount++;
}
$rowCount++; // 隔一行
$filename = $file_name . "_" . date('Y-m-d');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $filename . '.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
}
}
/* 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_No
,(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_array();
}
}

@ -28,6 +28,8 @@
.text-left {text-align: left;}
.text-right {text-align: right;}
.text-bold {font-weight: bold;}
.cell-right {float: right;}
td a {cursor: pointer;}
</style>
</head>
<body>
@ -49,7 +51,7 @@
</div>
<div class="container-fluid">
<p></p>
<form action="/webht.php/apps/trippestordersync/vendor_money/index" method="POST" role="form">
<form action="/webht.php/apps/trippestordersync/vendor_money/index" method="POST" role="form" id="request_form" name="request_form">
<div class="form-group row">
<label for="" class="col-md-2">地接社</label>
<div class="">
@ -94,7 +96,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 onclick="detail_download(<?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>
@ -271,6 +275,12 @@
,allowInput: true
,defaultDate:['<?php echo $default_date1 ?>', '<?php echo $default_date2 ?>']
});
})
function detail_download(vendor) {
document.request_form.action = "/webht.php/apps/trippestordersync/vendor_money/index" + "/" + vendor;
document.querySelector('#request_form').submit();
document.request_form.action = "/webht.php/apps/trippestordersync/vendor_money/index";
}
</script>
</html>

Loading…
Cancel
Save