123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857 |
- <?php
- namespace app\common\model;
- use app\hander\HelpHander;
- use think\Db;
- use think\Exception;
- use think\Model;
- class ApplyRecord extends Model
- {
- public function add($data,$orgId,$title){
- try{
- $recordId = Db::name('apply_record')->insertGetId($data);
- if(!$recordId){
- \exception('数据保存失败');
- }
- // 生成消息及推送提醒
- if($data['type'] == 3){
- $context = $title.',抄送给您,请知晓。';
- } else if($data['type'] == 9){
- $context = $title.',需要您去执行,请知晓。';
- } else {
- $context = $title.'需要您审批。';
- }
- $res = model('Message')->add(2,$recordId,2,$data['user_id'],$orgId,$context);
- if(!$res){
- \exception('消息生成失败');
- }
- return true;
- }catch (Exception $e){
- $this->error = $e->getMessage();
- return false;
- }
- }
- // 审批单生成时审批记录生成
- public function createRecord($applyId,$data){
- // flowJson排序
- $flowJson = sort_flow_json(json_decode($data['flow_json'],true));
- $curTime = date('Y-m-d H:i:s');
- $nodeid = '';
- $status = 1;
- $users = [];
- foreach ($flowJson as $k=>$v){
- $nodeid = $v['id'];
- if($v['type'] == 9||$v['type'] == 3){ // 节点是执行人或审批人时
- foreach ($v['userList'] as $kk=>$vv){
- $users[] = [
- 'user_id' => $vv['userId'],
- 'nodeid' => $v['id'],
- 'type' => $v['type']
- ];
- }
- } else if($v['type'] == 2||$v['type'] == 8){ // 审批人
- foreach ($v['userList'] as $kk=>$vv){
- $users[] = [
- 'user_id' => $vv['userId'],
- 'nodeid' => $v['id'],
- 'type' => $v['type']
- ];
- }
- break;
- } else if($v['type'] == 5){ // 流程结束
- $status = 2;
- }
- }
- try{
- if($status == 2){ // 流程结束
- $ret = Db::name('apply')->where('id',$applyId)->update([
- 'status' => 2,
- 'finish_time' => $curTime,
- 'update_time' => $curTime,
- 'nodeid' => $nodeid
- ]);
- if(!$ret){
- \exception('流程状态修改失败1');
- }
- // 生成消息记录
- $context = "温馨提醒,".$data['title']."(编号:".$data['apply_sn'].")已通过。";
- $mres = model('Message')->add(3,$applyId,4,$data['user_id'],$data['org_id'],$context);
- if(!$mres){
- \exception('消息生成失败');
- }
- if($data['advanced'] > 0){ // 流程结束高级组件执行逻辑
- $aret = $this->advancedEndAction($applyId,$data['org_id'],$data['user_id'],$data['form_json'],$data['advanced']);
- if(!$aret){
- \exception('操作失败');
- }
- }
- } else { // 审批中
- $ret = Db::name('apply')->where('id',$applyId)->update([
- 'status' => 1,
- 'update_time' => $curTime,
- 'nodeid' => $nodeid
- ]);
- if(!$ret){
- \exception('流程状态修改失败2'.$ret);
- }
- }
- if($users){
- foreach ($users as $k=>$v){
- $v['apply_id'] = $applyId;
- $v['status'] = 0;
- $v['create_time'] = $curTime;
- $res = model('ApplyRecord')->add($v,$data['org_id'],$data['title']);
- if(!$res){
- \exception('流程记录生成失败');
- }
- }
- }
- return true;
- }catch (Exception $e){
- $this->error = $e->getMessage();
- return false;
- }
- }
- // 记录修改为已阅
- public function updateStatus($id,$userId){
- $info = Db::name('apply_record')->where('id',$id)->where('user_id',$userId)->find();
- if($info && $info['status'] == 0){
- Db::name('apply_record')
- ->where('id',$id)
- ->update(['status' => 1,'finish_time' => date('Y-m-d H:i:s')]);
- }
- }
- // 转交
- public function transferApply($id,$userId,$transferUserId){
- if($userId == $transferUserId){
- HelpHander::error('被转交人不能是自己');
- }
- $info = Db::name('apply_record')
- ->alias('ar')
- ->join('apply a','a.id = ar.apply_id')
- ->where('ar.id',$id)
- ->where('ar.del',0)
- ->where('ar.user_id',$userId)
- ->field('ar.*,a.title,a.org_id')
- ->find();
- if(!$info){
- HelpHander::error('数据不存在');
- }
- if($info['type'] == 3||$info['type'] == 9){
- HelpHander::error('无法转交');
- }
- if($info['status'] != 0){
- HelpHander::error('已处理,无法转交');
- }
- $transfer = Db::name('apply_record')->where('del',0)->where('apply_id',$info['apply_id'])->where('user_id',$transferUserId)->find();
- if($transfer){
- HelpHander::error('被转交人已参与审批,无法再次转交');
- }
- Db::startTrans();
- try{
- $ret = Db::name('apply_record')->where('id',$id)->setField('status',3);
- if(!$ret){
- \exception('转交失败');
- }
- $data = [
- 'user_id' => $transferUserId,
- 'apply_id' => $info['apply_id'],
- 'status' => 0,
- 'nodeid' => $info['nodeid'],
- 'type' => 2,
- 'transfer' => 1,
- 'create_time' => date('Y-m-d H:i:s')
- ];
- $res = $this->add($data,$info['org_id'],$info['title']);
- if(!$res){
- \exception('转交失败');
- }
- Db::commit();
- }catch (Exception $e){
- Db::rollback();
- HelpHander::error('转交失败');
- }
- return true;
- }
- // 会签
- public function aggregationApproval($id,$userId,$userIds){
- $userIds = explode(',',$userIds);
- $info = Db::name('apply_record')
- ->alias('ar')
- ->join('apply a','a.id = ar.apply_id')
- ->where('ar.id',$id)
- ->where('ar.del',0)
- ->where('ar.user_id',$userId)
- ->field('ar.*,a.title,a.org_id,a.flow_json')
- ->find();
- if(!$info){
- HelpHander::error('数据不存在');
- }
- if($info['type'] == 3||$info['type'] == 9){
- HelpHander::error('无法会签');
- }
- if($info['status'] != 0){
- HelpHander::error('已处理,无法会签');
- }
- // 检查当前节点是会签还是或签,或签无法加人会签
- $flowJson = json_decode($info['flow_json'],true);
- foreach ($flowJson as $k=>$v){
- if($v['id'] == $info['nodeid'] && $v['mode'] == 2){
- HelpHander::error('该节点为或签,无法添加会签');
- }
- }
- $oldusers = Db::name('apply_record')
- ->where('nodeid',$info['nodeid'])
- ->where('apply_id',$id)
- ->where('del',0)
- ->column('user_id');
- $jjuser = array_intersect($userIds, $oldusers);
- if($jjuser){
- HelpHander::error('存在用户已是会签人员');
- }
- Db::startTrans();
- try{
- foreach ($userIds as $k=>$v){
- $data = [
- 'user_id' => $v,
- 'apply_id' => $info['apply_id'],
- 'status' => 0,
- 'nodeid' => $info['nodeid'],
- 'type' => 2,
- 'countersign' => 1,
- 'create_time' => date('Y-m-d H:i:s')
- ];
- $res = $this->add($data,$info['org_id'],$info['title']);
- if(!$res){
- \exception('会签失败');
- }
- }
- Db::commit();
- }catch (Exception $e){
- Db::rollback();
- HelpHander::error('会签失败');
- }
- return true;
- }
- // 加签
- public function addSign($id,$userId,$addUserId,$type=0){
- $info = Db::name('apply_record')
- ->alias('ar')
- ->join('apply a','a.id = ar.apply_id')
- ->where('ar.id',$id)
- ->where('ar.del',0)
- ->where('ar.user_id',$userId)
- ->field('ar.*,a.title,a.org_id,a.flow_json')
- ->find();
- if(!$info){
- HelpHander::error('数据不存在');
- }
- if($info['type'] == 3||$info['type'] == 9){
- HelpHander::error('无法加签');
- }
- if($info['status'] != 0){
- HelpHander::error('已处理,无法加签');
- }
- $lastNode = ''; // 最后一个审批节点
- $node = [];
- // 检查当前节点是会签还是或签,或签无法加签
- $flowJson = sort_flow_json(json_decode($info['flow_json'],true));
- foreach ($flowJson as $k=>$v){
- if($v['id'] == $info['nodeid'] && $v['mode'] == 2){
- HelpHander::error('该节点为或签,无法加签');
- }
- if($v['type'] == 2||$v['type'] == 8){
- $lastNode = $v['id'];
- }
- if($v['id'] == $info['nodeid']){
- $node = $v;
- }
- }
- // 检查是否多人会签,多人会签无法加签
- $oldusers = Db::name('apply_record')
- ->where('nodeid',$info['nodeid'])
- ->where('apply_id',$id)
- ->where('del',0)
- ->column('user_id');
- if(count($oldusers) > 1 || in_array($addUserId,$oldusers)){
- HelpHander::error('无权限加签');
- }
- if($type == 1 && $lastNode != $info['nodeid']){ // 往后加签,检查是否是最后一个审批节点
- HelpHander::error('无权限加签');
- }
- $user = Db::name('user_info')
- ->where('user_id',$addUserId)
- ->field('user_id,name')
- ->find();
- Db::startTrans();
- try{
- $node = [];
- foreach ($flowJson as $k=>$v){
- if($v['id'] == $info['nodeid']){
- $node = $v;
- }
- }
- $addnode = $node;
- $addnode['id'] = 'addnode'.time().rand(1000,9999);
- $addnode['nextId'] = $node['id'];
- $addnode['type'] = 8;
- $addnode['name'] = '加签';
- $addnode['userList'] = [[
- "userName" => $user['name'],
- "shortName" => mb_strlen($user['name']) > 2?mb_substr($user['name'], 0, -2):$user['name'],
- "userId" => $user['user_id']
- ]];
- foreach ($flowJson as $k=>$v){
- if($v['nextId'] == $info['nodeid']){
- $flowJson[$k]['nextId'] = $addnode['id'];
- }
- }
- $flowJson[] = $addnode;
- // 修改审批单信息
- $ret = Db::name('apply')->where('id',$info['apply_id'])->update([
- 'nodeid' => $addnode['id'],
- 'flow_json' => json_encode($flowJson,JSON_UNESCAPED_UNICODE),
- 'update_time' => date('Y-m-d H:i:s')
- ]);
- if(!$ret){
- \exception('加签失败');
- }
- // 删除原来节点记录及消息
- $ids = Db::name('apply_record')
- ->where('apply_id',$info['apply_id'])
- ->where('nodeid',$info['nodeid'])
- ->where('del',0)
- ->column('id');
- Db::name('apply_record')->where('id','in',$ids)->setField('del',1);
- Db::name('message')
- ->where('type',2)
- ->where('bus_type',2)
- ->where('org_id',$info['org_id'])
- ->where('bus_id','in',$ids)
- ->delete();
- $data = [
- 'user_id' => $addUserId,
- 'apply_id' => $info['apply_id'],
- 'status' => 0,
- 'nodeid' => $addnode['id'],
- 'type' => 8,
- 'create_time' => date('Y-m-d H:i:s')
- ];
- $res = $this->add($data,$info['org_id'],$info['title']);
- if(!$res){
- \exception('加签失败');
- }
- Db::commit();
- }catch (Exception $e){
- Db::rollback();
- HelpHander::error('加签失败'.$e->getMessage());
- }
- return true;
- }
- // 同意
- public function audit($id,$userId,$content,$formJson,$userList){
- $info = Db::name('apply_record')
- ->where('id',$id)
- ->where('user_id',$userId)
- ->find();
- if(!$info){
- HelpHander::error('数据不存在');
- }
- if($info['type'] == 3||$info['type'] == 9){
- HelpHander::error('无法执行此操作');
- }
- if($info['status'] != 0){
- HelpHander::error('已处理');
- }
- $apply = Db::name('apply')->where('id',$info['apply_id'])->find();
- $flowJson = sort_flow_json(json_decode($apply['flow_json'],true));
- $curNode = $this->getNodeFlowJson($flowJson,$info['nodeid']);
- $next = 0; // 是否走到下一流程
- if($curNode['mode'] == '1'){ // 会签
- // 检查是否该到下一流程
- $count = Db::name('apply_record')
- ->where('apply_id',$info['apply_id'])
- ->where('nodeid',$info['nodeid'])
- ->where('status',0)
- ->count();
- if($count == 1){ // 下一流程
- $next = 1;
- }
- } else { // 或签
- $next = 1;
- }
- $isexecutor = 0;
- foreach ($flowJson as $k=>$v){
- if($v['type'] == 9){
- $isexecutor = 1;
- break;
- }
- }
- $curTime = date('Y-m-d H:i:s');
- $duration = round((strtotime($curTime) - strtotime($info['create_time']))/3600,2); // 时长
- $applyduration = round((strtotime($curTime) - strtotime($apply['create_time']))/3600,2); // 时长
- Db::startTrans();
- try{
- $ret = Db::name('apply_record')
- ->where('id',$id)
- ->update([
- 'status' => 1,
- 'finish_time'=>$curTime,
- 'content' => $content,
- 'duration' => $duration
- ]);
- if(!$ret){
- \exception('操作失败');
- }
- if($formJson || $userList){ // formJson或$userList有变化
- if($formJson){
- $ad['form_json'] = $formJson;
- // formJson日志记录
- $res = Db::name('apply_form_log')->insert([
- 'apply_id' => $info['apply_id'],
- 'user_id' => $userId,
- 'form_json' => $formJson,
- 'create_time' => $curTime
- ]);
- if(!$res){
- \exception('数据保存失败');
- }
- }
- if($isexecutor == 1){
- foreach ($flowJson as $k=>$v){
- if($v['type'] == 9){
- $flowJson[$k]['userList'] = json_decode($userList,true);
- break;
- }
- }
- $ad['flow_json'] = json_encode($flowJson,JSON_UNESCAPED_UNICODE);
- }
- $ad['update_time'] = $curTime;
- $ret = Db::name('apply')->where('id',$info['apply_id'])->update($ad);
- if(!$ret){
- \exception('数据修改失败');
- }
- }
- if($next == 1){ // 流转到下一节点
- Db::name('apply_record')
- ->where('id','<>',$id)
- ->where('apply_id',$info['apply_id'])
- ->where('status',0)
- ->where('nodeid',$info['nodeid'])
- ->setField('status',4);
- $nodeid = $curNode['nextId'];
- $status = 1;
- $users = [];
- while (true){
- $nextNode = $this->getNodeFlowJson($flowJson,$nodeid);
- if($nextNode['type'] == 9||$nextNode['type'] == 3){ // 节点是执行人或审批人时
- foreach ($nextNode['userList'] as $kk=>$vv){
- $users[] = [
- 'user_id' => $vv['userId'],
- 'nodeid' => $nextNode['id'],
- 'type' => $nextNode['type']
- ];
- }
- $nodeid = $nextNode['nextId'];
- } else if($nextNode['type'] == 2||$nextNode['type'] == 8){ // 审批人
- foreach ($nextNode['userList'] as $kk=>$vv){
- $users[] = [
- 'user_id' => $vv['userId'],
- 'nodeid' => $nextNode['id'],
- 'type' => $nextNode['type']
- ];
- }
- break;
- } else if($nextNode['type'] == 5){ // 流程结束
- $status = 2;
- break;
- }
- }
- if($status == 2){ // 流程结束
- $ret = Db::name('apply')->where('id',$info['apply_id'])->update([
- 'status' => 2,
- 'finish_time' => $curTime,
- 'update_time' => $curTime,
- 'nodeid' => $nodeid,
- 'duration' => $applyduration
- ]);
- if(!$ret){
- \exception('信息修改失败');
- }
- // 生成消息记录
- $context = "温馨提醒,".$apply['title']."(编号:".$apply['apply_sn'].")已通过。";
- $mres = model('Message')->add(3,$info['apply_id'],4,$apply['user_id'],$apply['org_id'],$context);
- if(!$mres){
- \exception('消息生成失败');
- }
- if($apply['advanced'] > 0){ // 流程结束高级组件执行逻辑
- $aret = $this->advancedEndAction($apply['id'],$apply['org_id'],$apply['user_id'],$apply['form_json'],$apply['advanced']);
- if(!$aret){
- \exception('操作失败');
- }
- }
- } else { // 审批中
- $ret = Db::name('apply')->where('id',$info['apply_id'])->update([
- 'status' => 1,
- 'update_time' => $curTime,
- 'nodeid' => $nodeid
- ]);
- if(!$ret){
- \exception('信息修改失败');
- }
- }
- if($users){
- foreach ($users as $k=>$v){
- $v['apply_id'] = $info['apply_id'];
- $v['status'] = 0;
- $v['create_time'] = $curTime;
- $res = $this->add($v,$apply['org_id'],$apply['title']);
- if(!$res){
- \exception('流程记录生成失败');
- }
- }
- }
- }
- Db::commit();
- }catch (Exception $e){
- Db::rollback();
- HelpHander::error('操作失败'.$e->getMessage());
- }
- return true;
- }
- // 打回/拒绝
- public function toBack($applyId,$userId,$content){
- $info = Db::name('apply_record')
- ->alias('ar')
- ->join('apply a','a.id = ar.apply_id')
- ->where('a.id',$applyId)
- ->where('ar.user_id',$userId)
- ->where('ar.status',0)
- ->field('ar.*')
- ->find();
- if(!$info){
- HelpHander::error('数据不存在');
- }
- if($info['type'] == 3||$info['type'] == 9){
- HelpHander::error('无法操作');
- }
- if($info['status'] != 0){
- HelpHander::error('已处理');
- }
- $apply = Db::name('apply')->where('id',$info['apply_id'])->find();
- $curTime = date('Y-m-d H:i:s');
- $duration = round((strtotime($curTime) - strtotime($info['create_time']))/3600,2); // 时长
- $applyduration = round((strtotime($curTime) - strtotime($apply['create_time']))/3600,2); // 时长
- Db::startTrans();
- try{
- $ret = Db::name('apply_record')->where('id',$info['id'])->update([
- 'status' => 2,
- 'content' => $content,
- 'finish_time' => $curTime,
- 'duration' => $duration
- ]);
- if(!$ret){
- \exception('操作失败');
- }
- Db::name('apply_record')
- ->where('id','<>',$info['id'])
- ->where('status',0)
- ->where('apply_id',$info['apply_id'])
- ->where('nodeid',$info['nodeid'])
- ->setField('status',4);
- $res = Db::name('apply')->where('id',$applyId)->update([
- 'status' => 5,
- 'finish_time' => $curTime,
- 'duration' => $applyduration
- ]);
- if(!$res){
- \exception('操作失败');
- }
- $result = $this->advancedDisagreeAction($applyId,$apply['advanced']);
- if(!$result){
- \exception('操作失败');
- }
- Db::commit();
- }catch (Exception $e){
- Db::rollback();
- HelpHander::error('会签失败');
- }
- return true;
- }
- // 获取node信息
- public function getNodeFlowJson($flowJson,$nodeId){
- $curNode = [];
- foreach ($flowJson as $k=>$v){
- if($v['id'] == $nodeId){
- $curNode = $v;
- break;
- }
- }
- return $curNode;
- }
- // 高级组件执行操作 -- 流程申请时
- public function advancedStartAction($id,$orgId,$userId,$formJson,$advanced,$extra=[]){
- switch ($advanced){
- case '1': // 请假
- $ret = model('AttendanceLeave')->advancedStartLeave($id,$orgId,$userId,$formJson);
- break;
- case '3': // 合同
- $ret = model('Contract')->advancedStartContract($id,$orgId,$userId,$formJson);
- break;
- case '4': // 追加合同
- $ret = model('Contract')->advancedStartAddContract($id,$orgId,$userId,$formJson);
- break;
- case '5': // 合同付款
- $ret = model('ContractPay')->advancedStartContractPay($id,$orgId,$userId,$formJson);
- break;
- case '6': // 会议室预定
- $ret = model('MeetingRoom')->advancedStartMeetingRoom($id,$orgId,$userId,$formJson,$extra);
- break;
- case '7': // 合同收款
- $ret = model('ContractPay')->advancedStartContractGet($id,$orgId,$userId,$formJson);
- break;
- case '8': // 销假
- $ret = model('AttendanceLeaveTerminate')->advancedStartLeaveTerminate($id,$orgId,$userId,$formJson);
- break;
- case '9': // 离京报告
- $ret = model('LeaveBj')->advancedStartLeaveBj($id,$orgId,$userId,$formJson);
- break;
- case '10': // 办公物品
- $ret = model('OfficeReceive')->advancedStartOfficeReceive($id,$orgId,$userId,$formJson,$extra);
- break;
- case '11': // 用车
- $ret = model('CarRecord')->advancedStartCarRecord($id,$orgId,$userId,$formJson,$extra);
- break;
- case '13': // 资产领取
- $ret = model('AssetReceive')->advancedStartAssetReceive($id,$orgId,$userId,$formJson,$extra);
- break;
- case '14': // 资产退库
- $ret = model('AssetWithdraw')->advancedStartAssetWithdraw($id,$orgId,$userId,$formJson,$extra);
- break;
- case '15': // 资产维修
- $ret = model('AssetRepair')->advancedStartAssetRepair($id,$orgId,$userId,$formJson,$extra);
- break;
- case '16': // 资产处置
- $ret = model('AssetDisposal')->advancedStartAssetDisposal($id,$orgId,$userId,$formJson,$extra);
- break;
- case '17': // 预算
- $ret = model('BudgetApply')->advancedStartBudgetApply($id,$orgId,$userId,$formJson,$extra);
- break;
- case '18': // 用印
- $ret = model('OfficialSealApply')->advancedStartSealApply($id,$orgId,$userId,$formJson,$extra);
- break;
- case '19': // 中心发文
- $ret = model('PostApply')->advancedStartPostApply($id,$orgId,$userId,$formJson,$extra);
- break;
- default:
- $ret = true;
- break;
- }
- return $ret;
- }
- // 高级组件执行操作 -- 流程结束时
- public function advancedEndAction($id,$orgId,$userId,$formJson,$advanced){
- switch ($advanced){
- case '1': // 请假
- $ret = model('AttendanceLeave')->advancedEndLeave($id,$orgId,$userId,$formJson);
- break;
- case '3': // 合同
- $ret = model('Contract')->advancedEndContract($id,$orgId,$userId,$formJson);
- break;
- case '4': // 追加合同
- $ret = model('Contract')->advancedEndAddContract($id,$orgId,$userId,$formJson);
- break;
- case '5': // 合同支付
- $ret = model('ContractPay')->advancedEndContractPay($id,$orgId,$userId,$formJson);
- break;
- case '6': // 会议室预定
- $ret = model('MeetingRoom')->advancedEndMeetingRoom($id,$orgId,$userId,$formJson);
- break;
- case '7': // 合同收款
- $ret = model('ContractPay')->advancedEndContractGet($id,$orgId,$userId,$formJson);
- break;
- case '8': // 销假
- $ret = model('AttendanceLeaveTerminate')->advancedEndLeaveTerminate($id,$orgId,$userId,$formJson);
- break;
- case '9': // 离京报告
- $ret = model('LeaveBj')->advancedEndLeaveBj($id,$orgId,$userId,$formJson);
- break;
- case '10': // 办公物品
- $ret = model('OfficeReceive')->advancedEndOfficeReceive($id,$orgId,$userId,$formJson);
- break;
- case '11': // 用车
- $ret = model('CarRecord')->advancedEndCarRecord($id,$orgId,$userId,$formJson);
- break;
- case '12': // 离职或退休
- $ret = model('UserInfo')->advancedEndUserInfo($id,$orgId,$userId,$formJson);
- break;
- case '13': // 资产领取
- $ret = model('AssetReceive')->advancedEndAssetReceive($id,$orgId,$userId,$formJson);
- break;
- case '14': // 资产退库
- $ret = model('AssetWithdraw')->advancedEndAssetWithdraw($id,$orgId,$userId,$formJson);
- break;
- case '15': // 资产维修
- $ret = model('AssetRepair')->advancedEndAssetRepair($id,$orgId,$userId,$formJson);
- break;
- case '16': // 资产处置
- $ret = model('AssetDisposal')->advancedEndAssetDisposal($id,$orgId,$userId,$formJson);
- break;
- case '17': // 预算
- $ret = model('BudgetApply')->advancedEndBudgetApply($id,$orgId,$userId,$formJson);
- break;
- case '18': // 用印
- $ret = model('OfficialSealApply')->advancedEndSealApply($id,$orgId,$userId,$formJson);
- break;
- case '19': // 中心发文
- $ret = model('PostApply')->advancedEndPostApply($id,$orgId,$userId,$formJson);
- break;
- default:
- $ret = true;
- break;
- }
- return $ret;
- }
- public function advancedDisagreeAction($applyId,$advanced){
- switch ($advanced){
- case '1': // 请假
- $ret = model('AttendanceLeave')->advancedDisagreeLeave($applyId);
- break;
- case '3': // 合同
- $ret = model('Contract')->advancedDisagreeContract($applyId);
- break;
- case '4': // 追加合同
- $ret = model('Contract')->advancedDisagreeAddContract($applyId);
- break;
- case '5': // 合同支付
- $ret = model('ContractPay')->advancedDisagreeContractPay($applyId);
- break;
- case '6': // 会议室预定
- $ret = model('MeetingRoom')->advancedDisagreeMeetingRoom($applyId);
- break;
- case '7': // 合同收款
- $ret = model('ContractPay')->advancedDisagreeContractGet($applyId);
- break;
- case '8': // 销假
- $ret = model('AttendanceLeaveTerminate')->advancedDisagreeLeaveTerminate($applyId);
- break;
- case '9': // 离京报告
- $ret = model('LeaveBj')->advancedDisagreeLeaveBj($applyId);
- break;
- case '10': // 办公物品
- $ret = model('OfficeReceive')->advancedDisagreeOfficeReceive($applyId);
- break;
- case '11': // 用车
- $ret = model('CarRecord')->advancedDisagreeCarRecord($applyId);
- break;
- case '13': // 资产领取
- $ret = model('AssetReceive')->advancedDisagreeAssetReceive($applyId);
- break;
- case '14': // 资产退库
- $ret = model('AssetWithdraw')->advancedDisagreeAssetWithdraw($applyId);
- break;
- case '15': // 资产维修
- $ret = model('AssetRepair')->advancedDisagreeAssetRepair($applyId);
- break;
- case '16': // 资产处置
- $ret = model('AssetDisposal')->advancedDisagreeAssetDisposal($applyId);
- break;
- case '17': // 预算
- $ret = model('BudgetApply')->advancedDisagreeBudgetApply($applyId);
- break;
- case '18': // 用印
- $ret = model('OfficialSealApply')->advancedDisagreeSealApply($applyId);
- break;
- case '19': // 中心发文
- $ret = model('PostApply')->advancedDisagreePostApply($applyId);
- break;
- default:
- $ret = true;
- break;
- }
- return $ret;
- }
- // 获取未审批数量
- public function unApplyNums($userId,$orgId){
- $count = Db::name('apply_record')
- ->alias('ar')
- ->join('apply a','a.id = ar.apply_id')
- ->where('ar.status',0)
- ->where('ar.type','in',[2,8])
- ->where('ar.user_id',$userId)
- ->where('a.org_id',$orgId)
- ->count();
- return $count;
- }
- }
|