新增导出

master
chenzhi 4 years ago
parent 3b8d6eb128
commit d05d6e2159

@ -110,10 +110,13 @@ class CompanyStatementLackController extends ThinkController
}
//获取基本信息
$dbres = $this->DBModel->where("id='{$id}'")->select();
$title = $dbres[0]['company_name'];
$this->assign("title",$title);
if($dbres[0]['company_type'] == 3){
//上游
A("CompanyStatementPool")->viewCpPool($dbres,$is_export);
}elseif($infolist[0]['company_type'] == 1){
}elseif($dbres[0]['company_type'] == 1){
//下游公司
A("CompanyStatementPool")->viewPcPool($dbres,$is_export);
}else{

@ -181,6 +181,9 @@ class CompanyStatementPoolController extends ThinkController
}
//获取基本信息
$infolist = M("company_statement_info","tab_")->where("pool_id = '{$id}'")->select();
//获取母单
$statement_num = M("company_statement_pool","tab_")->field('statement_num')->where("id={$id}")->find()['statement_num'];
$this->assign("title",$statement_num);
if($infolist[0]['company_type'] == 3){
//上游
@ -501,88 +504,60 @@ class CompanyStatementPoolController extends ThinkController
}
//撤销汇总
public function cancelPool()
{
//开启事务
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids'];
$dbres = $this->DBModel->field("id,statement_ids,verify_status")->where("id in ({$ids})")->select();
$sids = [];
foreach($dbres as $k=>$v){
if(in_array($v['verify_status'],[3,4])) continue; //有打款就不允许回退
$statement_ids = explode(",",$v['statement_ids']);
$sids = array_merge($sids,$statement_ids);
}
$sids = implode(",",$sids);
M()->startTrans();//事务
//删除info
$infores = M("company_statement_info","tab_")->where("pool_id in ($ids)")->delete();
if($infores === false){
M()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
}
//删除自己
$poolres = $this->DBModel->where("id in ({$ids})")->delete();
if($poolres === false){
M()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
}
//修改结算单信息
$st_res = M("company_statement","tab_")->field("id,verify_status,verify_log")->where("id in ({$sids})")->select();
foreach($st_res as $k=>&$v){
$v['verify_log'] = json_decode($v['verify_log'],true);
$v['verify_log'][$op_pre.'_user']=$this->admininfo["username"];
$v['verify_log'][$op_pre.'_time']=date("Y-m-d H:i:s");
$v['verify_log'] = json_encode($v['verify_log']);
$v['verify_status']=-2;
$stres = M("company_statement","tab_")->save($v);
if($stres === false){
M()->rollback();
$this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
}
}
M()->commit();
$this->ajaxReturn(array(
'status' => 1,
"info"=>"重算金额成功"
));
}
//导出
public function export()
{
public function cancelPool(){
if(!isset($_REQUEST['id'])) $this->error("参数错误");
$id = $_REQUEST['id'];
//获取基础信息
}
// public function cancelPool()
// {
// //开启事务
// if(!isset($_REQUEST['ids'])) $this->error("参数错误");
// $ids = $_REQUEST['ids'];
// $dbres = $this->DBModel->field("id,statement_ids,verify_status")->where("id in ({$ids})")->select();
// $sids = [];
// foreach($dbres as $k=>$v){
// if(in_array($v['verify_status'],[3,4])) continue; //有打款就不允许回退
// $statement_ids = explode(",",$v['statement_ids']);
// $sids = array_merge($sids,$statement_ids);
// }
// $sids = implode(",",$sids);
// M()->startTrans();//事务
// //删除info
// $infores = M("company_statement_info","tab_")->where("pool_id in ($ids)")->delete();
// if($infores === false){
// M()->rollback();
// $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
// }
// //删除自己
// $poolres = $this->DBModel->where("id in ({$ids})")->delete();
// if($poolres === false){
// M()->rollback();
// $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
// }
// //修改结算单信息
// $st_res = M("company_statement","tab_")->field("id,verify_status,verify_log")->where("id in ({$sids})")->select();
// foreach($st_res as $k=>&$v){
// $v['verify_log'] = json_decode($v['verify_log'],true);
// $v['verify_log'][$op_pre.'_user']=$this->admininfo["username"];
// $v['verify_log'][$op_pre.'_time']=date("Y-m-d H:i:s");
// $v['verify_log'] = json_encode($v['verify_log']);
// $v['verify_status']=-2;
// $stres = M("company_statement","tab_")->save($v);
// if($stres === false){
// M()->rollback();
// $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败"));
// }
// }
// M()->commit();
// $this->ajaxReturn(array(
// 'status' => 1,
// "info"=>"重算金额成功"
// ));
// }
$data = M("CompanyStatement","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);//结算记录
//收款方
$all_sum_money = $data['pay_amount'];//合计平台总额
$all_pay_amount = $data['statement_money'];//合计结算金额
$big_all_sum_money = convertAmountToCn($data['statement_money']);//大写
if($data['pay_type'] == 2){
$data['receive_company'] = $data['second_party_info'];//收款方
$data['pay_company'] = $data['first_party_info'];
}else{
$data['receive_company'] = $data['first_party_info'];
$data['pay_company'] = $data['second_party_info'];
}
if($data['receive_company']['invoice_type'] == 1){
$data['receive_company']['invoice_type']="专票";
}else{
$data['receive_company']['invoice_type']="普票";
}
if ($data['company_belong'] == 9) {//上游
excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money);
} else {//下游
excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money);
}
}
public function OpAuth($info)
{

@ -344,7 +344,7 @@
}
for (var index = 0; index < text.length; index++) {
var id = text[index];
var url ="{:U('export')}"+"&id="+id;
var url ="{:U('viewStatement')}"+"&id="+id+"&export=1";
var iframeExcel = "<iframe src='"+url+"' width='0px' height='0px' style='z-index:-1;position: absolute;top: -999999px;'></iframe>"//添加下载的地址到iframe这里是公司信息我用**表示了。
$("body").append(iframeExcel)
}

@ -396,6 +396,35 @@
}
}
})
//撤销汇总
$(".cancelPool").on("click",function(){
var id = $(this).data('id');
var url = "{:U('cancelPool')}";
cancelPoolAjax(url,{id:id});
})
function cancelPoolAjax(opurl,senddata){
//执行
$.ajax({
type: "POST",
url: opurl,
dataType: 'json',
async: false,
data: senddata,
success:function(data){
if(data.status==1){
layer.msg("<font style='color:white'>" + data.info + "</font>");
setTimeout(function(){
window.location.reload();
},1500);
}else{
layer.msg("<font style='color:white'>" + data.info + "</font>");
return false;
}
}
});
}
//新增批注
$(".addRemark").click(function(){
var id = $(this).data("id");

@ -185,7 +185,7 @@
<if condition="$is_export">
$(function(){
$("#exporttable").table2excel({
filename: "上游结算汇总.xls", // do include extension
filename: "{$title}.xls", // do include extension
preserveColors: false // set to true if you want background colors and font colors preserved
});
});

@ -168,7 +168,7 @@
<if condition="$is_export">
$(function(){
$("#exporttable").table2excel({
filename: "下游公司汇总.xls", // do include extension
filename: "{$title}.xls", // do include extension
preserveColors: false // set to true if you want background colors and font colors preserved
});
});

@ -189,7 +189,7 @@
<if condition="$is_export">
$(function(){
$("#exporttable").table2excel({
filename: "下游公司汇总.xls", // do include extension
filename: "{$title}.xls", // do include extension
preserveColors: false // set to true if you want background colors and font colors preserved
});
});

Loading…
Cancel
Save