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

费用报销脚本

上级 b4c239a6
...@@ -14,6 +14,25 @@ class flow_emfkClassModel extends flowModel ...@@ -14,6 +14,25 @@ class flow_emfkClassModel extends flowModel
9 => '审核失败', 9 => '审核失败',
]; ];
protected function flowzuofeibill($sm){
$this->updatestatus(5);
$this->sendMess(0,9);
}
//删除单据时调用
protected function flowdeletebill($sm){
$this->updatestatus(5);
$this->sendMess(0,9);
}
//流程全部完成后调用
protected function flowcheckfinsh($zt){
$this->sendMess(1,3);
}
/** /**
* 审核时触发 * 审核时触发
...@@ -40,11 +59,11 @@ class flow_emfkClassModel extends flowModel ...@@ -40,11 +59,11 @@ class flow_emfkClassModel extends flowModel
foreach ($oa_fininfos as $k=> $value) { foreach ($oa_fininfos as $k=> $value) {
foreach ($value as $key => $val) { foreach ($value as $key => $val) {
switch ($key) { switch ($key) {
// case 'charge_type': case 'charge_type':
//
// $arr['FPAYBILLENTRY'][$k]['FCOSTID']['FNUMBER']=self::getbxlx($val); $arr['FPAYBILLENTRY'][$k]['F_KXType']['FNUMBER']=self::getkxlx($val);
//
// break; break;
case 'cbzxid': case 'cbzxid':
...@@ -83,7 +102,7 @@ class flow_emfkClassModel extends flowModel ...@@ -83,7 +102,7 @@ class flow_emfkClassModel extends flowModel
} }
$cloudUrl = "http://36.110.39.211/k3cloud/"; $cloudUrl = "http://192.168.1.211/k3cloud/";
//登陆参数 //登陆参数
$data = array( $data = array(
'5e64f6ff0bd47f',//帐套Id '5e64f6ff0bd47f',//帐套Id
...@@ -172,7 +191,8 @@ class flow_emfkClassModel extends flowModel ...@@ -172,7 +191,8 @@ class flow_emfkClassModel extends flowModel
$model['Model']['FRECTUNIT']['FNumber']=$supplier['number']; $model['Model']['FRECTUNIT']['FNumber']=$supplier['number'];
$model['Model']['FPAYBILLENTRY']=$arr['FPAYBILLENTRY']; $model['Model']['FPAYBILLENTRY']=$arr['FPAYBILLENTRY'];
$model['Model']['FDepartment']['FNumber']=self::deptname($applicationdpt); $model['Model']['FDepartment']['FNumber']=self::deptname($applicationdpt);
$model['Model']['FSETTLEORGID']['FNumber']=self::getorg($this->rs['org']);
$model['Model']['FPAYORGID']['FNumber']=self::getorg($this->rs['org']);
$data_model=json_encode($model); $data_model=json_encode($model);
$data = array( $data = array(
'AP_PAYBILL',//业务对象标识FormId 'AP_PAYBILL',//业务对象标识FormId
...@@ -183,24 +203,13 @@ class flow_emfkClassModel extends flowModel ...@@ -183,24 +203,13 @@ class flow_emfkClassModel extends flowModel
$result = self::invoke_add($cloudUrl,$post_content,$cookie_jar); $result = self::invoke_add($cloudUrl,$post_content,$cookie_jar);
$array = json_decode($result,true); $array = json_decode($result,true);
if($array['Result']['ResponseStatus']['IsSuccess']){
$num=$array['Result']['Number']; $num=$array['Result']['Number'];
if($array['Result']['ResponseStatus']['IsSuccess']){
$this->update("`fbillno`='$num'", $this->rs['id']); $this->update("`fbillno`='$num'", $this->rs['id']);
$this->erplog($this->rs['docnum'],'c_emfk','保存成功',json_encode($array),date("Y-m-d H:i:s"),2,$num,$array['Result']['Id'],1); $this->erplog($this->rs['docnum'],'c_emfk','保存成功',json_encode($array),date("Y-m-d H:i:s"),2,$num,$array['Result']['Id'],1);
if($this->emfk_submit($cloudUrl,$cookie_jar,$array['Result']['Id'],$array['Result']['Number'])){
$this->erplog($this->rs['docnum'],'c_emfk','提交成功',json_encode($array),date("Y-m-d H:i:s"),2,$num,$array['Result']['Id'],2);
}else{
$this->erplog($this->rs['docnum'],'c_emfk','提交失败',json_encode($array),date("Y-m-d H:i:s"),1,$num,$array['Result']['Id'],2);
}
}else{ }else{
$this->erplog($this->rs['docnum'],'c_emfk','保存失败',json_encode($array),date("Y-m-d H:i:s"),1,$num,$array['Result']['Id'],1); $this->erplog($this->rs['docnum'],'c_emfk','保存失败',json_encode($array),date("Y-m-d H:i:s"),1,$num,$array['Result']['Id'],1);
...@@ -253,6 +262,20 @@ class flow_emfkClassModel extends flowModel ...@@ -253,6 +262,20 @@ class flow_emfkClassModel extends flowModel
m('log')->addlog('电费付款','接口返回信息:' .$res); m('log')->addlog('电费付款','接口返回信息:' .$res);
} }
static function getorg($name)
{
$data = m('option')->getone("num='organization'", 'id,name');
$orglist = m('option')->getone("pid='".$data['id']."' and name='".$name."'", 'name,num');
return $orglist['num'];
}
static function getkxlx($name)
{
$data = m('option')->getone("num='kxtype'", 'id,name');
$kxlxlist = m('option')->getone("pid='".$data['id']."' and name='".$name."'", 'name,num');
return $kxlxlist['num'];
}
public static function dept($data) public static function dept($data)
{ {
$sql=" id= '$data'"; $sql=" id= '$data'";
...@@ -309,25 +332,43 @@ class flow_emfkClassModel extends flowModel ...@@ -309,25 +332,43 @@ class flow_emfkClassModel extends flowModel
if($flowid['nowcheckid']==$checkid){ if($flowid['nowcheckid']==$checkid){
$data = m('c_emfk_details')->getall('mid='.$this->rs['id'], 'id,cbzxid,amount'); $data = m('c_emfk_details')->getall('mid='.$this->rs['id'], 'id,cbzxid,amount');
foreach ($data as $key => $vo) {
$project=self::project($vo['cbzxid']);
foreach($data as $v){
if(!isset($ret[$v['cbzxid']])){
$ret[$v['cbzxid']] = $v;
}else{
$ret[$v['cbzxid']]['amount'] += $v['amount'];
}
}
$ret = array_values($ret);
foreach ($ret as $key => $vo) {
$project=self::project($vo['cbzxid']);
$cbzx_code= self::dept($project['data'][0]['jz_cur_dept']); $cbzx_code= self::dept($project['data'][0]['jz_cur_dept']);
$sql = " cost_id='$cbzx_code' and status = 1 and is_default=1"; $sql = " cost_id='$cbzx_code' and status = 1 and is_default=1";
$cost = m('c_fund_account')->getone($sql, 'id,type,name,freeze_amount,account_balance');//查询账户表成本中心id $cost = m('c_fund_account')->getone($sql, 'id,type,name,freeze_amount,account_balance');//查询账户表成本中心id
if($cost['type']=='1'){
if(($cost['account_balance']-$cost['freeze_amount'])<$vo['amount']){ if(($cost['account_balance']-$cost['freeze_amount'])<$vo['amount']){
return $cost['name']."余额不足";die; return $cost['name']."余额不足";die;
} }
} }
$id=$cost['id'];
foreach ($data as $ke => $value) {
$project=self::project($value['cbzxid']);
$cbzx_code= self::dept($project['data'][0]['jz_cur_dept']);
$sql = " cost_id='$cbzx_code' and status = 1 and is_default=1";
$cost = m('c_fund_account')->getone($sql, 'id,type,name,freeze_amount,account_balance');//查询账户表成本中心id
$id=$cost['id'];
$c_withhold = array( $c_withhold = array(
'fund_account_id' => $id, 'fund_account_id' => $id,
'docnum' => $this->rs['docnum'], 'docnum' => $this->rs['docnum'],
'cost_id' => $vo['cbzxid'], 'cost_id' => $value['cbzxid'],
'amount' => $vo['amount'], 'amount' => $value['amount'],
'status' => 1, 'status' => 1,
'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'],
...@@ -336,7 +377,7 @@ class flow_emfkClassModel extends flowModel ...@@ -336,7 +377,7 @@ class flow_emfkClassModel extends flowModel
//修改冻结余额 //修改冻结余额
$freeze = array( $freeze = array(
'freeze_amount' => $cost['freeze_amount'] + $vo['amount'], 'freeze_amount' => $cost['freeze_amount'] + $value['amount'],
); );
m('c_fund_account')->update($freeze, "`id`='$id'"); m('c_fund_account')->update($freeze, "`id`='$id'");
......
...@@ -248,7 +248,7 @@ class flow_projectfkClassModel extends flowModel ...@@ -248,7 +248,7 @@ class flow_projectfkClassModel extends flowModel
$sql = " mid ='$id' and `table`='c_projectfk' "; $sql = " mid ='$id' and `table`='c_projectfk' ";
$flow_bill = m('flow_bill')->getone($sql,'allcheckid'); $flow_bill = m('flow_bill')->getone($sql,'allcheckid');
$allcheckid=explode(',',$flow_bill['allcheckid']); $allcheckid=explode(',',$flow_bill['allcheckid']);
$optionid = m('option')->getone("num = 'oafk_manager' ",'id'); $optionid = m('option')->getone("num = 'project_manager' ",'id');
$optionid=$optionid['id']; $optionid=$optionid['id'];
$option = m('option')->getall("pid = '$optionid' and num =1 order by sort desc",'num,name,value,sort'); $option = m('option')->getall("pid = '$optionid' and num =1 order by sort desc",'num,name,value,sort');
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论