提交 ea028832 authored 作者: fengzy's avatar fengzy

oa付款单

上级 2e6b5f4d
...@@ -11,8 +11,6 @@ class flow_oafkClassModel extends flowModel ...@@ -11,8 +11,6 @@ class flow_oafkClassModel extends flowModel
//二级 或一级审批同意之后进行预扣款 //二级 或一级审批同意之后进行预扣款
protected function flowcheckbefore($zt, $sm){ protected function flowcheckbefore($zt, $sm){
$id=$this->rs['id']; $id=$this->rs['id'];
$sql = " mid ='$id' and `table`='c_fininfom_oafk' "; $sql = " mid ='$id' and `table`='c_fininfom_oafk' ";
$flow_bill = m('flow_bill')->getone($sql,'allcheckid'); $flow_bill = m('flow_bill')->getone($sql,'allcheckid');
......
...@@ -12,17 +12,30 @@ class flow_oayfkClassModel extends flowModel ...@@ -12,17 +12,30 @@ class flow_oayfkClassModel extends flowModel
//二级 或一级审批同意之后进行预扣款 //二级 或一级审批同意之后进行预扣款
protected function flowcheckbefore($zt, $sm){ protected function flowcheckbefore($zt, $sm){
//zt 1代表同意 $id=$this->rs['id'];
if($zt==1){ $sql = " mid ='$id' and `table`='c_fininfom_oafk' ";
$deptdata = m('admin')->getone('id='.$this->adminid,'deptname'); $flow_bill = m('flow_bill')->getone($sql,'allcheckid');
$option = m('option')->getall('pid = 1497','num,name');//当前部门 $allcheckid=explode(',',$flow_bill['allcheckid']);
foreach ($option as $key => $vo) { $option = m('option')->getall('pid = 1497 and num =1 order by sort desc','num,name,value,sort');
if($vo['name']==$deptdata['deptname']){ foreach ($option as $key => $value) {
$num= $vo['num']; if(in_array($value['value'], $allcheckid)){
$checkid= $value['value'];
break;
}
} }
if(empty($checkid)){
$option = m('option')->getall('pid = 1497 and num =2 order by sort desc','num,name,value,sort');
foreach ($option as $key => $value) {
if(in_array($value['value'], $allcheckid)){
$checkid= $value['value'];
break;
} }
}
}
//zt 1代表同意
if($zt==1){
$flowid=$this->getflow(); $flowid=$this->getflow();
if($flowid['nowcheckname']==$num){ if($flowid['nowcheckid']==$checkid){
$data = m('c_fund_details_fk')->getall('mid='.$this->rs['id'], 'id,cbzx_code,charge_amount'); $data = m('c_fund_details_fk')->getall('mid='.$this->rs['id'], 'id,cbzx_code,charge_amount');
foreach ($data as $key => $vo) { foreach ($data as $key => $vo) {
$cbzx_code=$vo['cbzx_code']; $cbzx_code=$vo['cbzx_code'];
...@@ -39,7 +52,7 @@ class flow_oayfkClassModel extends flowModel ...@@ -39,7 +52,7 @@ class flow_oayfkClassModel extends flowModel
'create_time' => date("Y-m-d H:i:s"), 'create_time' => date("Y-m-d H:i:s"),
'uid' => $this->rs['uid'], 'uid' => $this->rs['uid'],
); );
m('c_withhold')->insert($c_withhold); m('c_withhold_yfk')->insert($c_withhold);
//修改冻结余额 //修改冻结余额
$freeze = array( $freeze = array(
...@@ -53,7 +66,7 @@ class flow_oayfkClassModel extends flowModel ...@@ -53,7 +66,7 @@ class flow_oayfkClassModel extends flowModel
$docnum=$this->rs['docnum']; $docnum=$this->rs['docnum'];
//将单据状态作废余额 //将单据状态作废余额
$withhold_cost = m('c_withhold')->getall("docnum='$docnum' and status =1", 'id,cost_id,amount'); $withhold_cost = m('c_withhold_yfk')->getall("docnum='$docnum' and status =1", 'id,cost_id,amount');
foreach ($withhold_cost as $key => $vo) { foreach ($withhold_cost as $key => $vo) {
//减去冻结金额 //减去冻结金额
...@@ -74,53 +87,48 @@ class flow_oayfkClassModel extends flowModel ...@@ -74,53 +87,48 @@ class flow_oayfkClassModel extends flowModel
$status = array( $status = array(
'status' => 0, 'status' => 0,
); );
m('c_withhold')->update($status, "docnum='$docnum'"); m('c_withhold_yfk')->update($status, "docnum='$docnum'");
} }
} }
//流程全部完成后调用
protected function flowcheckfinsh($zt){
$docnum=$this->rs['docnum'];
$withhold_cost = m('c_withhold')->getall("docnum='$docnum' and status =1", 'id,cost_id,amount');
foreach ($withhold_cost as $key => $vo) { // //流程全部完成后调用
protected function flowcheckfinsh($zt){
$mid= $this->rs['id'];
$datafk = m('c_fund_details_yfk')->getall('mid='.$mid);
foreach ($datafk as $key => $value) {
// 扣除账户余额 c_fund_account account_balance // 扣除账户余额 c_fund_account account_balance
$cbzxid= $vo['cost_id']; $cbzxid= $value['cbzx_code'];
$model = 'c_fund_account'; $model = 'c_fund_account';
$sql = " cost_id ='$cbzxid' and status = 1 and is_default=1"; $sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
$data = m($model)->getone($sql,'id,name,account_balance,freeze_amount'); $data = m($model)->getone($sql,'id,name,account_balance');
$zfarr = array( $zfarr = array(
'account_balance' =>$data['account_balance']-$vo['amount'], 'account_balance' =>$data['account_balance']-$value['charge_amount'],
); );
$id=$data['id']; $id=$data['id'];
m('c_fund_account')->update($zfarr,"`id`='$id'"); m('c_fund_account')->update($zfarr,"`id`='$id'");
$freeze = array(
'freeze_amount' => $data['freeze_amount'] - $vo['amount'],
);
m('c_fund_account')->update($freeze, "`id`='$id'");
// 成本中心 amount 变更 // 成本中心 amount 变更
$cbzx = substr($cbzxid,0,strrpos($cbzxid,"(")); $cbzx = substr($cbzxid,0,strrpos($cbzxid,"("));
$cbzxsql = " code ='$cbzx' and status = 1"; $cbzxsql = " code ='$cbzx' and status = 1";
$cbzxdata = m('c_cbzx')->getone($cbzxsql,'id,amount'); $cbzxdata = m('c_cbzx')->getone($cbzxsql,'id,amount');
$cbarr = array( $cbarr = array(
'amount' =>$cbzxdata['amount']+$vo['amount'], 'amount' =>$cbzxdata['amount']+$value['charge_amount'],
); );
m('c_cbzx')->update($cbarr,"`code`='$cbzx'"); m('c_cbzx')->update($cbarr,"`code`='$cbzx'");
//账户明细 c_account_detail //账户明细 c_account_detail
$account_detail=array( $account_detail=array(
'account' => $data['name'], 'account' => $data['name'],
'opt_type' => 2, 'opt_type' => 2,
'amount' =>$vo['amount'], 'amount' =>$value['charge_amount'],
'trans_numb' => $this->rs['docnum'], 'trans_numb' => $this->rs['docnum'],
'account_balance' => $data['account_balance']-$vo['amount'], 'account_balance' => $data['account_balance']-$value['charge_amount'],
'create_time' =>date("Y-m-d H:i:s"), 'create_time' =>date("Y-m-d H:i:s"),
'uid' =>$this->rs['uid'], 'uid' =>$this->rs['uid'],
); );
...@@ -134,10 +142,10 @@ class flow_oayfkClassModel extends flowModel ...@@ -134,10 +142,10 @@ class flow_oayfkClassModel extends flowModel
'trans_numb' =>$this->rs['docnum'], 'trans_numb' =>$this->rs['docnum'],
'account' => $data['name'], 'account' => $data['name'],
'toaccount' =>$this->rs['payee'], 'toaccount' =>$this->rs['payee'],
'trans_amount' =>$vo['amount'], 'trans_amount' =>$value['charge_amount'],
'business_type' =>8, 'business_type' =>10,
'opt_type' =>2, 'opt_type' =>2,
'account_balance'=>$data['account_balance']-$vo['amount'], 'account_balance'=>$data['account_balance']-$value['charge_amount'],
'create_time' =>date("Y-m-d H:i:s"), 'create_time' =>date("Y-m-d H:i:s"),
'uid' =>$this->rs['uid'], 'uid' =>$this->rs['uid'],
); );
...@@ -145,69 +153,5 @@ class flow_oayfkClassModel extends flowModel ...@@ -145,69 +153,5 @@ class flow_oayfkClassModel extends flowModel
} }
} }
// //流程全部完成后调用
// protected function flowcheckfinsh($zt){
// $mid= $this->rs['id'];
// $datafk = m('c_fund_details_yfk')->getall('mid='.$mid);
// foreach ($datafk as $key => $value) {
// // 扣除账户余额 c_fund_account account_balance
// $cbzxid= $value['cbzx_code'];
// $model = 'c_fund_account';
// $sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
// $data = m($model)->getone($sql,'id,name,account_balance');
// $zfarr = array(
// 'account_balance' =>$data['account_balance']-$value['charge_amount'],
// );
// $id=$data['id'];
// m('c_fund_account')->update($zfarr,"`id`='$id'");
// // 成本中心 amount 变更
// $cbzx = substr($cbzxid,0,strrpos($cbzxid,"("));
// $cbzxsql = " code ='$cbzx' and status = 1";
// $cbzxdata = m('c_cbzx')->getone($cbzxsql,'id,amount');
// $cbarr = array(
// 'amount' =>$cbzxdata['amount']+$value['charge_amount'],
// );
// m('c_cbzx')->update($cbarr,"`code`='$cbzx'");
// //账户明细 c_account_detail
// $account_detail=array(
// 'account' => $data['name'],
// 'opt_type' => 2,
// 'amount' =>$value['charge_amount'],
// 'trans_numb' => $this->rs['docnum'],
// 'account_balance' => $data['account_balance']-$value['charge_amount'],
// 'create_time' =>date("Y-m-d H:i:s"),
// 'uid' =>$this->rs['uid'],
// );
// m('c_account_detail')->insert($account_detail);
// // 业务付款8业务预付款10费用报销11 oa_c_fund_detail
// $fund_detail=array(
// 'trans_numb' =>$this->rs['docnum'],
// 'account' => $data['name'],
// 'toaccount' =>$this->rs['payee'],
// 'trans_amount' =>$value['charge_amount'],
// 'business_type' =>10,
// 'opt_type' =>2,
// 'account_balance'=>$data['account_balance']-$value['charge_amount'],
// 'create_time' =>date("Y-m-d H:i:s"),
// 'uid' =>$this->rs['uid'],
// );
// m('c_fund_detail')->insert($fund_detail);
// }
// }
} }
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论