|
|
|
@ -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 */
|
|
|
|
|