Trippest结算:导出明细

feature/trippest
lyt 6 years ago
parent d3b36fccdf
commit d76d23f84a

@ -23,7 +23,7 @@ class Vendor_money extends CI_Controller {
public function index($download_vendor=null)
{
// $this->permission->is_admin(true); // test:
$this->permission->is_admin(true);
$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])) {
@ -39,8 +39,10 @@ class Vendor_money extends CI_Controller {
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));
return $this->output->set_content_type('application/json')->set_output(json_encode($vendor_data, JSON_UNESCAPED_UNICODE));
$file_name = str_replace(" ", "_", $date_range) . "_" . $vendor_name;
return $this->download_output($vendor_data, $file_name);
}
$result = array(
"default_date1" => $start_date
@ -219,6 +221,59 @@ class Vendor_money extends CI_Controller {
}
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 */

@ -264,7 +264,7 @@ class Vendor_money_model extends CI_Model {
and GAI_Type in (" . PAY_OTHER . ")
) as vendor_income
,coli.COLI_OPI_ID
, gri.GRI_Name
, 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
@ -298,7 +298,7 @@ class Vendor_money_model extends CI_Model {
-- and COLI_sourcetype=$sourcetype
) as cgi_group";
$query = $this->HT->query($sql);
return $query->result();
return $query->result_array();
}

@ -29,6 +29,7 @@
.text-right {text-align: right;}
.text-bold {font-weight: bold;}
.cell-right {float: right;}
td a {cursor: pointer;}
</style>
</head>
<body>
@ -50,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="">
@ -96,7 +97,7 @@
?>
<tr>
<td class="text-left"><?php echo $trippest['vendor_name'] ?>
<a href="index/<?php echo $trippest['vendor_code'] ?>" class="cell-right">导出账单明细&nbsp;&dArr;</a>
<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>
@ -274,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