diff --git a/Application/Admin/Controller/AggregateFinanceStatementController.class.php b/Application/Admin/Controller/AggregateFinanceStatementController.class.php
index a6d58e48b..cce8f5e11 100644
--- a/Application/Admin/Controller/AggregateFinanceStatementController.class.php
+++ b/Application/Admin/Controller/AggregateFinanceStatementController.class.php
@@ -195,43 +195,175 @@ class AggregateFinanceStatementController extends ThinkController
}
public function editStatement(){
- if(!isset($_REQUEST['id'])) $this->error("参数错误");
- $id = $_REQUEST['id'];
- $dbres = M("aggregate_statement","tab_")->where("id = '{$id}'")->find();
- $first_party_info = json_decode($dbres['first_party_info'],true);
- $second_party_info = json_decode($dbres['second_party_info'],true);
- $statement_info = json_decode($dbres['statement_info'],true);
-
- // if($dbres['company_name'] == $first_party_info['partner']){
- // $first_partner_type=0;
- // }else{
- // $first_partner_type=1;
- // }
- // $fine = array_pop($statement_info);
- $senddata = array(
- // "first_partner_type"=>1,
- "statement_id"=>$dbres['id'],
- "first_part_company"=>$first_party_info['partner'],
- "second_part_company"=>$second_party_info['partner'],
- "statement_type"=>$dbres['pay_type'] == 0 ? 1 :0,
- "first_party_info"=>$first_party_info,
- "second_party_info"=>$second_party_info,
- "statement_info"=>$statement_info,
- "statement_count"=>array("pay_money"=>$dbres['pay_money'],"ratio_money"=>$dbres['ratio_money'])
- );
-
- $this->assign("data",$senddata);
- if($dbres['pay_type'] == 0){
- $this->assign("company",$second_party_info['partner']);
- }else{
- $this->assign("company",$first_party_info['partner']);
+ if(!isset($_REQUEST['id'])) $this->error("参数错误");
+ $id = $_REQUEST['id'];
+ $dbres = M("aggregate_statement","tab_")->where("id = '{$id}'")->find();
+ $first_party_info = json_decode($dbres['first_party_info'],true);
+ $second_party_info = json_decode($dbres['second_party_info'],true);
+ $statement_info = json_decode($dbres['statement_info'],true);
+
+ // if($dbres['company_name'] == $first_party_info['partner']){
+ // $first_partner_type=0;
+ // }else{
+ // $first_partner_type=1;
+ // }
+ // $fine = array_pop($statement_info);
+ $senddata = array(
+ // "first_partner_type"=>1,
+ "statement_id"=>$dbres['id'],
+ "first_part_company"=>$first_party_info['partner'],
+ "second_part_company"=>$second_party_info['partner'],
+ "statement_type"=>$dbres['pay_type'] == 0 ? 1 :0,
+ "first_party_info"=>$first_party_info,
+ "second_party_info"=>$second_party_info,
+ "statement_info"=>$statement_info,
+ "statement_count"=>array("pay_money"=>$dbres['pay_money'],"ratio_money"=>$dbres['ratio_money'])
+ );
+
+ $this->assign("data",$senddata);
+ if($dbres['pay_type'] == 0){
+ $this->assign("company",$second_party_info['partner']);
+ }else{
+ $this->assign("company",$first_party_info['partner']);
+ }
+ $this->assign("company_id",$dbres['company_id']);
+ $this->assign("company_name",$dbres['company_name']);
+ $this->assign("id",$dbres['id']);
+ $this->display();
}
- $this->assign("company_id",$dbres['company_id']);
- $this->assign("company_name",$dbres['company_name']);
- $this->assign("id",$dbres['id']);
- $this->display();
+ //查看发票信息
+ public function viewStatement(){
+ if(!isset($_REQUEST['id'])) $this->error("参数错误");
+ $id = $_REQUEST['id'];
+ $dbres = M("aggregate_statement","tab_")->where("id = '{$id}'")->find();
+ $first_party_info = json_decode($dbres['first_party_info'],true);
+ $second_party_info = json_decode($dbres['second_party_info'],true);
+ $statement_info = json_decode($dbres['statement_info'],true);
+
+ if($dbres['pay_type'] == 0){
+ $company = $second_party_info['partner'];
+ $pyinfo = $second_party_info;
+ }else{
+ $company = $first_party_info['partner'];
+ $pyinfo = $first_party_info;
+ }
+ $senddata = array(
+ "company"=>$company,
+ "payinfo"=>$pyinfo,
+ "first_part_company"=>$first_party_info['partner'],
+ "second_part_company"=>$second_party_info['partner'],
+ "statement_type"=>$dbres['pay_type'],
+ "first_party_info"=>$first_party_info,
+ "second_party_info"=>$second_party_info,
+ "statement_info"=>$statement_info,
+ "statement_count"=>array("pay_money"=>$dbres['pay_money'],"ratio_money"=>$dbres['ratio_money'],"big_ratio_money"=>convertAmountToCn($dbres['ratio_money']))
+ );
+ $this->assign("data",$senddata);
+ $this->display();
+ }
+ //导出
+ public function export(){
+ if(!isset($_REQUEST['ids'])) $this->error("参数错误");
+ $ids = explode(",",$_REQUEST['ids']);
+ foreach ($ids as $k => $v) {
+ $this->doexport($v);
+ }
+ }
+ private function doexport($id)
+ {
+ $data = M("aggregate_statement","tab_")->where("id = '{$id}'")->find();
+
+ $data['first_party_info'] = json_decode($data['first_party_info'], 1);//甲方
+ $data['second_party_info'] = json_decode($data['second_party_info'], 1);//乙方
+ $data['statement_info'] = json_decode($data['statement_info'], 1);//结算记录
+ //收款方
+ $big_pay_money = convertAmountToCn($data['pay_money']);//大写
+
+ $data['receive_company'] = $data['pay_type'] ? $data['first_party_info'] : $data['second_party_info'];
+ $data['pay_company'] = $data['pay_type'] ? $data['second_party_info'] : $data['first_party_info'];
+ $this->excelDownStreamTemplate($data,$big_pay_money);
+ }
+ public function excelDownStreamTemplate($data,$big_all_sum_money) {
+
+ header("Content-type: text/html; charset=utf-8");
+ error_reporting(E_ALL);
+ ini_set('display_errors', TRUE);
+ ini_set('display_startup_errors', TRUE);
-}
+ define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
');
+
+ date_default_timezone_set('Europe/London');
+ Vendor("PHPExcel.PHPExcel");
+ $objPHPExcel = new \PHPExcel();
+ $objReader = \PHPExcel_IOFactory::createReader('Excel5');
+
+ //设置模板文件
+ $objPHPExcel = $objReader->load("Public/Admin/excel/down_stream.xls");
+
+ $statement_begin_time = date('Y.m.d', $data['begintime']);//对账开始时间
+ $statement_end_time = date('Y.m.d',$data['endtime']);//对账截止时间
+ $objPHPExcel->getActiveSheet()->setCellValue('A1', "《 {$data['channel_name']} 》结算单
+ ({$statement_begin_time}-{$statement_end_time}");
+
+ if ($data['withdraw_type'] == '2') {
+ $objPHPExcel->getActiveSheet()->setCellValue('D2','补点比例');
+ }
+
+ $line = 3;
+
+ foreach ($data['statement_info'] as $key => $value) {
+ $objPHPExcel->getActiveSheet()->insertNewRowBefore($line,1);
+ $objPHPExcel->getActiveSheet()->removeConditionalStyles();
+
+ $objPHPExcel->getActiveSheet()->setCellValue('A'.$line, $value['begintime'] . '-' . $value['endtime']);
+ $product_name = $value['game_name'];
+ $objPHPExcel->getActiveSheet()->setCellValue('D'.$line, $value['ratio'] . '%');
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.$line, $value['fax_ratio'] . '%');
+ $objPHPExcel->getActiveSheet()->setCellValue('C'.$line, $value['money']);
+
+ $objPHPExcel->getActiveSheet()->setCellValue('B'.$line, $product_name);
+ $objPHPExcel->getActiveSheet()->setCellValue('F'.$line, $value['ratio_money']);
+ $line++;
+ }
+
+ $objPHPExcel->getActiveSheet()->setCellValue('C'.($line), $data['pay_money']);//合计-平台总额
+ $objPHPExcel->getActiveSheet()->setCellValue('F'.($line), $data['ratio_money']);//合计-结算金额
+
+
+ $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+1), $big_all_sum_money);//大写支付结算金额
+ //甲方信息
+ $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+3), $data['first_party_info']['partner']);//甲方
+ $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+4), $data['first_party_info']['link_man']);//联系人
+ $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+5), $data['first_party_info']['link_phone']);//联系电话
+ $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+6), $data['second_party_info']['invoice_item']);//开票项目
+ $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+7), $data['second_party_info']['invoice_type']);//发票类型
+
+ //乙方信息
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+3), $data['second_party_info']['partner']);//乙方
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+4), $data['second_party_info']['link_man']);//联系人
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+5), $data['second_party_info']['link_phone']);//联系电话
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+6), $data['second_party_info']['address']);//邮寄地址
+ // $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+8), $value['pay_amount']);//请汇入此账号
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+8), $data['second_party_info']['payee_name']);//户名
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+9), $data['second_party_info']['bank_account']);//银行账号
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+10), $data['second_party_info']['opening_bank']);//开户行
+ if($data['withdraw_type'] == 1){
+ $m = date('Y.m', $data['begintime']);
+ $fileName = "{$data['second_party_info']['partner']}&{$data['first_party_info']['partner']}-对账单{$m}";
+ }else{
+ $fileName = "{$data['second_party_info']['partner']}&{$data['first_party_info']['partner']}-对账单{$statement_begin_time}-{$statement_end_time}";
+ }
+
+ // dd($fileName);
+ ob_end_clean();//清除缓冲区,避免乱码
+ header('pragma:public');
+ header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $fileName .'".xls');
+ header("Content-Disposition:attachment;filename={$fileName}.xls");//attachment新窗口打印inline本窗口打印
+ $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
+ $objWriter->save('php://output');
+ exit;
+
+ }
}
diff --git a/Application/Admin/View/AggregateFinanceStatement/lists.html b/Application/Admin/View/AggregateFinanceStatement/lists.html
index a8121bd25..cbdf3cf55 100644
--- a/Application/Admin/View/AggregateFinanceStatement/lists.html
+++ b/Application/Admin/View/AggregateFinanceStatement/lists.html
@@ -126,7 +126,7 @@
已开票
已到账
重算对账金额
- 批量导出
+ 批量导出
@@ -247,6 +247,22 @@
}
$(function(){
+ $("#export").click(function () {
+ var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
+ return $(elem).val();
+ }).get();
+ if(text.length > 2){
+ layer.msg("" + '暂不支持超过20条的批量导出' + "");
+ return;
+ }
+ if(text.length < 1){
+ layer.msg("" + '请先选择要导出的结算单' + "");
+ return;
+ }
+ text = text.join(",");
+ window.location.href = "{:U('export')}"+"&ids="+text;
+
+ })
$("#shenhe").click(function () {
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
@@ -320,13 +336,25 @@
})
- //搜索功能
+ //查看开票信息
+
+ $(".viewStatement").click(function () {
+ var id = $(this).data("id");
+ layer.open({
+ type: 2,
+ title: "查看开票信息",
+ shadeClose: true,
+ shade: 0.8,
+ area: ['70%', '80%'],
+ content:'/admin.php?s=/AggregateFinanceStatement/viewStatement/id/'+id
+ });
+ });
//申请开票
$(".createStatement").click(function () {
var id = $(this).data("id");
layer.open({
type: 2,
- title: "海南万盟天下科技有限公司",
+ title: "申请开票",
shadeClose: true,
shade: 0.8,
area: ['70%', '80%'],
@@ -338,7 +366,7 @@
var id = $(this).data("id");
layer.open({
type: 2,
- title: "海南万盟天下科技有限公司",
+ title: "开票编辑",
shadeClose: true,
shade: 0.8,
area: ['70%', '80%'],
diff --git a/Application/Admin/View/AggregateFinanceStatement/viewStatement.html b/Application/Admin/View/AggregateFinanceStatement/viewStatement.html
new file mode 100644
index 000000000..9d7bf0bb3
--- /dev/null
+++ b/Application/Admin/View/AggregateFinanceStatement/viewStatement.html
@@ -0,0 +1,277 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+