| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814 |
- <?php
- /**
- * 来自:信呼开发团队
- * 作者:磐石(rainrock)
- * 网址:http://www.rockoa.com/
- * 系统的核心文件之一,处理工作流程模块的。
- */
- class flowModel extends Model
- {
- public $modenum; //当前模块编号
- public $editcont= ''; //修改的记录
- public $id = 0; //当前单据ID
- public $moders; //当前模块数组
- public $modeid; //当前模块Id
- public $modename; //当前模块名称
- public $sericnum; //当前单据单号
- public $billrs = array(); //当前单据流程信息
- public $rs = array(); //当前单据记录信息
- public $urs = array(); //当前单据对应用户
- public $drs = array(); //当前单据对应用户
- public $fieldsarr = array(); //主表元素字段数组
- public $fieldsarra = array(); //元素数组
- public $mwhere;
- public $mtable; //当前模块对应表
- public $uname; //当前单据对应用户姓名
- public $uid = 0; //当前单据对应用户Id
- public $optid = 0; //当前当街对应操作用Id,如提交人Id
- public $isflow = 0; //当前模块是否有流程审核步骤
- public $ismobile= 0; //是否移动的页面请求的
- public $minwidth= 100; //录入页面子表最小宽度
- public $inputwidth= 0; //录入页面宽度
- public $atype = '';
- public $daochubo= false; //是否导出操作
- public $companyid= 1; //默认单位Id
-
- //当初始化模块后调用
- protected function flowinit(){}
-
- //当初始化单据调用
- protected function flowchangedata(){}
-
- //当触发通知时处理
- protected function flowchangetodo(){}
-
- //删除单据时调用,$sm删除说明
- protected function flowdeletebill($sm){}
-
- //作废单据时调用,$sm作废说明
- protected function flowzuofeibill($sm){}
-
- //提交时调用
- protected function flowsubmit($na, $sm){}
-
- //添加日志记录调用$arr 添加数组
- protected function flowaddlog($arr){}
-
- protected function flowdatalog($arr){}
-
- //审核之前调用$zt 状态, $sm说明
- protected function flowcheckbefore($zt, $sm, $ufied){}
-
- //审核完成后调用
- protected function flowcheckafter($zt, $sm){}
-
- //流程全部完成后调用
- protected function flowcheckfinsh($zt){}
-
-
- protected function flowgetfields($lx){}
- protected function flowgetoptmenu($opt){}
-
- //自定义审核人重新的方法$num 步骤单号
- protected function flowcheckname($num){}
-
- //审核步骤根据$num 编号判断是否需要审核
- protected function flowcoursejudge($num){}
-
- //操作单据
- protected function flowoptmenu($ors, $crs){}
-
- //自定义是否可查看本单据
- protected function flowisreadqx(){return false;}
-
- //自定义是否可以删除权限,如返回0不能删除,1可删除,其他值无效
- protected function flowisdeleteqx(){return false;}
-
- //已弃用
- protected function flowprintrows($r){return $r;}
-
- //子表数据替换处理$lx=0编辑时,1展示时
- protected function flowsubdata($r, $lx=0){return $r;}
-
- //默认推送格式从写
- protected function flownexttodo($type){return false;}
-
- //单据判断条件从写$lx类型,$uid用户Id
- protected function flowbillwhere($lx, $uid){return '';}
-
- protected $flowweixinarr = array();
- protected $flowviewufieds = 'uid';
-
- //关联单位id字段默认是comid
- protected $flowcompanyidfieds = 'comid';
-
- protected $flowfieldstype = 0; //获取字段类型0默认*,1根据字段元素设置得到字段
-
- //初始化单据可替换其他属性,$lx,0默认,1详情展示,2列表显示,3打印页,4外部详情页
- public function flowrsreplace($rs){return $rs;}
-
- //这个是移动端列表中使用
- public function flowrsreplace_we($row, $rs){return $row;}
-
- //通用移动端列表搜索
- public function flowwesearchdata($lx){return array();}
-
- //编辑的时候替换
- protected function flowrsreplaceedit($rs){return $rs;}
-
- //默认状态1时可以就算审核通过,默认是1
- protected $flowstatusarr = array(1);
-
- //子表样式,可以改成print打印
- protected $subsubdatastyle = '';
-
- //关联其他模块
- protected $wherejoin = array();
-
- //默认排序如:id,desc
- public $defaultorder = '';
-
- //是否可编辑别人单据
- public $floweditother = false;
-
- //详情边框元素
- public $xiangbordercolor = '';
-
-
- //php8需要定义
- public $viewmodel,$chaomodel,$billmodel,$todomodel,$todosmodel,$flogmodel,$checksmodel,$cnamemodel,$wheremodel,$adminmodel,$remindmodel,$option,$rssust,$flowarr,$nowcourse,$nextcourse,$flowisend,$pipeiCoursearrc,$pipeiCoursearrs,$pipeiCoursearr,$_tempauoe;
-
- public function echomsg($msg)
- {
- if(!isajax())exit($msg);
- showreturn('', $msg, 201);
- exit();
- }
-
- //字段处理$farr字段,$lx=0pc,1移动
- public function flowfieldarr($farr, $lx){return $farr;}
-
- //自定义录入模版$lx=0pc,1移动
- public function flowinputtpl($cont, $lx){return $cont;}
- public function flowviewtpl($cont, $lx){return $cont;}
-
- //在线编辑单据下附件
- public function floweditoffice($frs, $ofrs){}
-
- /**
- * 初始化流程信息
- */
- public function initdata($num, $id=null)
- {
- $this->initbase($num);
- $this->viewmodel = m('view');
- $this->chaomodel = m('flow_chao');
- $this->billmodel = m('flow_bill');
- $this->todomodel = m('flow_todo');
- $this->todosmodel = m('flowtodo');
- $this->flogmodel = m('flow_log');
- $this->checksmodel = m('flow_checks');
- $this->cnamemodel = m('flowcname');
- $this->wheremodel = m('where');
- $this->adminmodel = m('admin');
- $this->remindmodel = m('remind'); //单据提醒表
- $this->option = m('option');
- $this->companyid = $this->adminmodel->getcompanyid();
- $this->tfieldsarra(); //初始化录入的表单元素
- $this->mwhere = "`table`='$this->mtable' and `mid`=-1";
- if(!$this->defaultorder){
- $sortdir = arrvalue($this->moders, 'sortdir');
- if(!isempt($sortdir))$this->defaultorder = str_replace(' ',',', $sortdir);
- }
- $this->flowinit();
- if($id==null)return $this;
- $this->loaddata($id, true);
- return $this;
- }
-
- public function initbase($num)
- {
- if(is_array($num)){
- $this->moders= $num;
- }else{
- $this->moders = m('flow_set')->getone(is_numeric($num) ? $num : "`num`='$num'");
- if(!$this->moders)$this->echomsg('模块['.$num.']不存在,请到[流程模块列表]下添加');
- }
- $this->daochubo = ($this->rock->post('execldown')=='true') ? true :false;
- $table = $this->moders['table'];
- $this->modeid = $this->moders['id'];
- $this->modenum = $this->moders['num'];
-
- $this->moders['name'] = $this->lang($this->moders['name']);
- $this->modename = $this->moders['name'];
- $this->isflow = (int)$this->moders['isflow'];
- $this->settable($table);
- $this->mtable = $table;
- return $this;
- }
-
- private function tfieldsarra()
- {
- $rows = m('flow_element')->getrows("`mid`='$this->modeid' and `iszb`=0",'`name`,`fields`,`isbt`,`iszs`,`fieldstype`,`savewhere`,`data`,`isdr`,`iszb`,`issou`,`islu`,`islb`,`isonly`,`attr`','`sort`');
- $this->fieldsarr = array();
- if($rows)foreach($rows as $k=>$rs){
- if($rs['islu']==1)$this->fieldsarr[] = $rs;
- }
- $this->fieldsarra = $rows;
- }
-
- //录入页上的标题
- public function inputtitle()
- {
- return $this->moders['name'];
- }
-
- /**
- * 列表上要搜索的的,此方法仅用到在:webmain/flow/input/inputAction.php 行607上返回,模块接口可重写这个方法
- */
- public function flowsearchfields()
- {
- $arr = array();
- if($this->isflow>0){
- $arr[] = array('name'=>''.lang('申请人').'...','fields'=>'uid');
- $arr[] = array('name'=>''.lang('提交人').'...','fields'=>'optid');
- }
- return $arr;
- }
-
- /**
- * 初始化单据数据
- * id 单据Id $ispd 是否判断有查看权限
- */
- public function loaddata($id, $ispd=true)
- {
- $this->id = (int)$id;
- $this->mwhere = "`table`='$this->mtable' and `mid`='$id'";
-
- //防止同主表模块串数据
- $swhere = "`id`='$id'";
- $wherestr = $this->moders['where'];
- if(!isempt($wherestr)){
- $wherestr = $this->rock->covexec($wherestr);
- $swhere .= ' and '.$wherestr;
- }
-
- $this->rs = $this->getone($swhere);
- $this->uname = '';
- if(!$this->rs)$this->echomsg('数据记录不存在了');
- $this->rs['base_name'] = '';
- $this->rs['base_deptname'] = '';
- if(isset($this->rs['uid']))$this->uid = $this->rs['uid'];
- if(isset($this->rs['comid']))$this->companyid = $this->rs['comid'];
- if(!isset($this->rs['applydt']))$this->rs['applydt'] = '';
- if(!isset($this->rs['status']))$this->rs['status'] = 1;
- $uisfield = property_exists($this, 'uidfields') ? $this->uidfields : 'optid';
- if($this->uid==0 && isset($this->rs[$uisfield]))$this->uid = $this->rs[$uisfield];
- $this->optid = isset($this->rs['optid']) ? $this->rs['optid'] : $this->uid;
- $this->urs = $this->adminmodel->getone($this->uid,'id,name,user,deptid,deptids,deptname,deptallname,face,ranking,superid,superpath,superman,deptpath');
- if($this->isempt($this->rs['applydt'])&&isset($this->rs['optdt']))$this->rs['applydt']=substr($this->rs['optdt'],0,10);
- if($this->urs){
- $this->drs = $this->db->getone('[Q]dept',"`id`='".$this->urs['deptid']."'");
- $this->uname = $this->urs['name'];
- $this->rs['base_name'] = $this->uname;
- if($this->drs){
- $this->rs['base_deptname'] = $this->drs['name'];
- }
- }
- $this->sericnum = '';
- $this->billrs = $this->billmodel->getone($this->mwhere);
- if($this->billrs){
- $this->sericnum = $this->billrs['sericnum'];
- if(isempt(arrvalue($this->billrs,'uname'))){
- $this->savebill();
- }
- if($this->billrs['status']!=$this->rs['status'])$this->billmodel->update('`status`='.$this->rs['status'].'', $this->billrs['id']);//状态不一样更新一下
- if($this->billrs['isturn']!=$this->rs['isturn'])$this->billmodel->update('`isturn`='.$this->rs['isturn'].'', $this->billrs['id']);
- if(isempt($this->rs['base_name']))$this->rs['base_name'] = $this->billrs['uname'];
- if(isempt($this->rs['base_deptname']))$this->rs['base_deptname'] = $this->billrs['udeptname'];
- }else{
- if($this->isflow>0)$this->savebill();
- }
- if($this->isflow>0){
- if($this->rs['status']==1 && $this->rs['isturn']=='0'){
- $this->update(array('isturn' => 1), $this->id);
- $this->rs['isturn'] = 1;
- if($this->billrs)$this->billmodel->update('`isturn`=1', $this->billrs['id']);
- }
- }
- $this->getlogrows = array();
- if($ispd)$this->isreadqx();
- $this->rssust = $this->rs;
- $this->flowchangedata();
-
- $this->rs['base_systitle'] = TITLE;//系统名称
- $this->rs['base_modename'] = $this->modename;
- $this->rs['base_sericnum'] = $this->sericnum;
- $this->rs['base_summary'] = $this->getsummary();
- }
-
- /**
- * 当前模块我待办数量
- */
- public function getdaiban()
- {
- $s = $this->rock->dbinstr('nowcheckid', $this->adminid);
- $to = $this->billmodel->rows('`modeid`='.$this->modeid.' and `isdel`=0 and `status` not in(1,2) and '.$s.'');
- return $to;
- }
-
- /**
- * 判断单据是否可以查看
- */
- public function isreadqx($glx=0)
- {
- $bo = false;
- if($this->adminid==1)$bo=true;//为1的超级管理员可查看
- if($this->uid==$this->adminid && $this->adminid>0)$bo=true;
- if(!$bo && $this->isflow>0){
- if($this->billrs){
- $allcheckid = $this->billrs['allcheckid'];
- if(contain(','.$allcheckid.',',','.$this->adminid.','))$bo = true;
- }
- }
- //可以查看下属人员的
- if(!$bo){
- if($this->urs && contain($this->urs['superpath'],'['.$this->adminid.']'))$bo = true;
- }
- //通知表上的权限
- if(!$bo){
- $tos = $this->todosmodel->rows("".$this->mwhere." and `uid`='$this->adminid'");
- if($tos>0)$bo=true;
- }
- //抄送表上的
- if(!$bo){
- $tos = $this->chaomodel->rows($this->mwhere.' and '.$this->rock->dbinstr('csnameid', $this->adminid).'');
- if($tos>0)$bo=true;
- }
- //todo表里
- if(!$bo){
- $tos = $this->db->rows('[Q]todo', "`uid`='$this->adminid' and ".$this->mwhere."");
- if($tos>0)$bo=true;
- }
-
- if(!$bo)$bo = $this->flowisreadqx(); //自定义查看权限
- //权限设置上的
- if(!$bo){
- $bo = $this->isreadqxs();
- }
- //监控流程也是可以查看
- if(!$bo){
- $tos = $this->isjiankongqx();
- if($tos>0)$bo=true;
- }
-
- if($glx==1)return $bo;
- if(!$bo)$this->echomsg('无权限查看模块['.$this->modenum.'.'.$this->modename.']'.$this->uname.'的数据,请联系管理员到[流程模块→流程模块权限]下设置');
- }
-
- /**
- * 从权限上看是否有查看权限
- */
- public function isreadqxs()
- {
- $bo = false;
- $where = $this->viewmodel->viewwhere($this->moders, $this->adminid, $this->flowviewufieds);
- $where = str_replace('{asqom}','', $where);
- $tos = $this->rows("`id`='$this->id' $where ");
- if($tos>0)$bo=true;
- return $bo;
- }
-
- /**
- * 判断单据是否可以编辑
- */
- public function iseditqx()
- {
- $bo = 0;
- if($bo==0 && $this->isflow>0){
- if($this->billrs && ($this->uid == $this->adminid || $this->optid==$this->adminid)){
- if($this->billrs['nstatus']==0 || $this->billrs['nstatus']==2){
- $bo = 1;
- }
- }
- if($this->rs['status']==1)$bo=0;
- }
- if($bo==0){
- $where = $this->viewmodel->editwhere($this->moders, $this->adminid, $this->flowviewufieds);
- $where = str_replace('{asqom}','', $where);
- $tos = $this->rows("`id`='$this->id' $where ");
- if($tos>0)$bo=1;
- }
- return $bo;
- }
-
- /**
- * 判断当前单据是否可以删除
- */
- public function isdeleteqx()
- {
- $bo = 0;
- if($bo==0 && $this->isflow>0){
- if($this->billrs && ($this->uid == $this->adminid || $this->optid==$this->adminid)){
- if($this->billrs['nstatus']==0 || $this->billrs['nstatus']==2){
- $bo = 1;
- }
- }
- if($this->rs['status']==1)$bo=0;
- }
- if($bo==0){
- $where = $this->viewmodel->deletewhere($this->moders, $this->adminid, $this->flowviewufieds);
- $where = str_replace('{asqom}','', $where);
- $tos = $this->rows("`id`='$this->id' $where ");
- if($tos>0)$bo=1;
- }
-
- $isd = $this->flowisdeleteqx();
- if(is_numeric($isd) && $isd <= 1)$bo = $isd;
-
- return $bo;
- }
-
- /**
- * 判断是否监控权限
- */
- public function isjiankongqx()
- {
- $bo = 0;
- if($bo==0){
- $where = $this->viewmodel->jiankongwhere($this->moders, $this->adminid, $this->flowviewufieds);
- $where = str_replace('{asqom}','', $where);
- $tos = $this->rows("`id`='$this->id' $where ");
- if($tos>0)$bo=1;
- }
- return $bo;
- }
-
- /**
- * 获取详情展示字段
- */
- public function getfields($lx=0)
- {
- $fields = array();
- if(!$this->fieldsarra)$this->tfieldsarra();
- $farr = $this->fieldsarra;
- foreach($farr as $k=>$rs)if($rs['iszs']=='1')$fields[$rs['fields']] = $rs['name'];
- $fters = $this->flowgetfields($lx);
- if(is_array($fters))$fields = array_merge($fields, $fters);
- return $fields;
- }
-
- /**
- * 获取录入页面地址
- */
- public function getinputurl($num='',$mid=0,$can=array())
- {
- if($num=='')$num = $this->modenum;
- $xa = 'lu';
- if($this->ismobile==1)$xa = 'lum';
- $url = 'index.php?a='.$xa.'&m=input&d=flow&num='.$num.'&mid='.$mid.'';
- if(is_array($can)){
- foreach($can as $k=>$v)$url.='&'.$k.'='.$v.'';
- }else{
- $url .= '&'.$can.'';
- }
- return $url;
- }
-
- public function replacepbr(&$arr, $k)
- {
- $val = arrvalue($arr, $k);
- if(!c('html')->ishtml($val))$arr[$k] = str_replace("\n",'<br>', $val);
- return $arr;
- }
-
- /**
- * 读取展示数据
- * $lx 0pc, 1移动,$isdy=2就是打印读取
- */
- public function getdatalog($lx=0, $isdy=0)
- {
- m('log')->addread($this->mtable, $this->id);
- $this->todosmodel->biaoyidu($this->adminid, $this->modenum, $this->id);
- $fobj = m('file');
- $this->ismobile = $lx;
- $arr['modename'] = $this->modename;
- $arr['title'] = $this->modename;
- $arr['modeid'] = $this->modeid;
- $arr['modenum'] = $this->modenum;
- $arr['mid'] = $this->id;
- $arr['status'] = arrvalue($this->rs,'status');
- $arr['logarr'] = $this->getlog(1);
- $arr['isplview'] = arrvalue($this->moders,'ispl','0');
- $arr['isys'] = arrvalue($this->moders,'isys','0');
- $contview = '';
- $lsds = ($isdy==2) ? $isdy: $lx;
- $path = ''.P.'/flow/page/view_'.$this->modenum.'_'.$lsds.'.html';
- if(COMPANYNUM){
- $path1 = ''.P.'/flow/page/view_'.$this->modenum.'_'.COMPANYNUM.'_'.$lsds.'.html';
- if(file_exists($path1))$path = $path1;
- }
- $fstr = $fobj->getstr($this->mtable, $this->id, 3);//3说明是详情也读
- $issubtabs = 0;
- if($fstr != ''){
- $this->rs['file_content'] = $fstr;
- }
- $subdata = $this->getsuballdata(1);
- $this->rs['subdatarows'] = $subdata;
-
- $data = $this->flowrsreplace($this->rs, ($isdy==2) ? 3 : 1);
- $dataa = $this->viewjinfields(array($data));
- $data = $dataa[0];
-
- //读取多行子表
- if($subdata){
- $zbzd = m('flow_element')->getrows("`mid`='$this->modeid' and `iszb`>0 and `iszs`=1 and `fieldstype` in('uploadimg','uploadfile','textarea')",'`name`,`fields`,`fieldstype`,`iszb`','`iszb`,`sort`');
- foreach($subdata as $zb=>$da){
- $sub = $da['fields'];
- //--autharstart--
- foreach($zbzd as $k1=>$rs1){
- if($rs1['iszb']==$zb+1){
- $fty = $rs1['fieldstype'];
- $fid = $rs1['fields'];
- foreach($da['data'] as $k2=>$rs2){
- $fval = arrvalue($rs2, $fid);
- if($fty=='uploadimg'){
- if(!isempt($fval) && substr($fval,0,4)!='<img'){
- $fval = $this->rock->gethttppath($fval);
- $da['data'][$k2][$fid] = '<img src="'.$fval.'" onclick="c.showviews(this)" height="70">';
- }
- }
- if($fty=='uploadfile'){
- if(isempt($fval))$fval='0';
- if($fval!='0'){
- $da['data'][$k2][$fid] = $fobj->getstr('', '', 3, "`id` in($fval)");
- }
- }
- if($fty=='textarea'){
- $this->replacepbr($da['data'][$k2], $fid);
- }
- }
- }
- }
- //--autharend--
- $data[$sub] = $this->getsubdata($zb,$da['data'],arrvalue($data,'subdatays'.$zb.'',$lx));
- $data[''.$sub.'_style'] = 'padding:0';
- }
- }
-
- //文件字段替换上传和上传图片的
- $farrobj = $chufarr= array();
- if(method_exists($this, 'flowxiangfields'))$chufarr = $this->flowxiangfields($chufarr);
- $farrobj['base_sericnum'] = array('name'=>arrvalue($chufarr,'base_sericnum','单号'));
- $farrobj['base_name'] = array('name'=>arrvalue($chufarr,'base_name','申请人'));
- $farrobj['base_deptname'] = array('name'=>arrvalue($chufarr,'base_deptname','申请人部门'));
- $farrobj['base_status'] = array('name'=>arrvalue($chufarr,'base_status','流程状态'));
- $farrobj['file_content'] = array('name'=>arrvalue($chufarr,'file_content','相关文件'));
-
- foreach($this->fieldsarra as $k=>$rs){
- $fid = $rs['fields'];
- $fty = $rs['fieldstype'];
- if($fty=='uploadfile'){
- $fval = arrvalue($data, $fid);
- if(isempt($fval))$fval='0';
- $data[$fid] = '';
- if($fval!='0'){
- $data[$fid] = $fobj->getstr('', '', 3, "`id` in($fval)");
- }
- }
- if($fty=='uploadimg' || $fty=='graph'){
- $fval = arrvalue($data, $fid);
- if(!isempt($fval) && substr($fval,0,4)!='<img'){
- $fval = $this->rock->gethttppath($fval);
- $fwei = ($fty=='graph') ? 50 : 100;
- $data[$fid] = '<img src="'.$fval.'" onclick="c.showviews(this)" height="'.$fwei.'">';
- }
- }
- //文本域自动换行
- if($fty=='textarea'){
- $this->replacepbr($data, $fid);
- }
- if($fty=='ditumap' && !isempt($rs['data'])){
- $wzhi = arrvalue($data, $rs['data']);
- if(!isempt($wzhi))$data[$fid].='<a href="javascript:;" onclick="js.showmap(\''.$wzhi.','.$data[$fid].'\')">[查看地图]</a>';
- }
-
- $farrobj[$fid] = $rs;
- }
-
-
- $_logarr = $qfields = array();
- foreach($arr['logarr'] as $k1=>$rs1)$_logarr[$rs1['id']] = $rs1;
- //读取流程审核步骤信息,只显示同意的
- $logrows = $this->flogmodel->getrows($this->mwhere.' and `modeid`='.$this->modeid.' and `courseid`>0 and `status`>0 and `valid`=1','*','id desc');
- $togdar = array();
- foreach($logrows as $k2=>$rs2){
- $sie1 = $rs2['courseid'].'_'.$rs2['checkid'];
- if(isset($togdar[$sie1])){
- $logrows[$k2]['show'] = false;
- }else{
- $togdar[$sie1] = true;
- $logrows[$k2]['show'] = true;
- }
- }
- foreach($logrows as $k2=>$rs2){
- if(!$rs2['show'])continue;
- $rs3 = $_logarr[$rs2['id']];
- $_coid = $rs2['courseid'];
- if(!isempt($rs3['qmimg']))$rs3['name'] = '<img height="30" onclick="c.showviews(this)" width="70" src="'.$rs3['qmimg'].'">';
- $key1 = 'course'.$_coid.'';
- //if(isempt($rs3['sm']))$rs3['sm']= $rs3['statusname'];
- if(!isset($data[''.$key1.'_name'])){
- $data[''.$key1.'_name'] = $rs3['name'];
- $data[''.$key1.'_zt'] = '<font color="'.$rs3['color'].'">'.$rs3['statusname'].'</font>';
- $data[''.$key1.'_sm'] = $rs3['sm'];
- $data[''.$key1.'_dt'] = $rs3['checkdt'];
- }else{
- $data[''.$key1.'_name'] .= ','.$rs3['name'];
- $data[''.$key1.'_sm'] .= ','.$rs3['sm'];
- $data[''.$key1.'_dt'] = $rs3['checkdt'];
- }
-
- //全部处理意见
- $key2 = ''.$key1.'_all';
- if(!isset($data[$key2])){
- $qfields[$key2] = $rs2['name'];
- $data[$key2]='';
- }
-
- $str1 = $rs3['name'].' <font color="'.$rs3['color'].'">'.$rs3['statusname'].'</font> '.$rs3['checkdt'].'';
- if(!isempt($rs3['sm']))$str1.=','.$rs3['sm'].'';
-
- if($data[$key2]!='')$data[$key2].='<hr size="1">';
- $data[$key2].= $str1;
- }
- $ztass = $this->getnowstatus();
- $data['base_status'] = $ztass[3];
- //使用了自定的展示模板
- if(file_exists($path)){
- $contview = $this->flowviewtpl(file_get_contents($path), $lx);
- preg_match_all('/\^(.*?)\^/', $contview, $list);
- foreach($list[1] as $k=>$nrs){
- $fzdrs = arrvalue($farrobj, $nrs);
- if($fzdrs)$contview = str_replace('^'.$nrs.'^', $fzdrs['name'], $contview);
- }
- $contview = $this->rock->reparr($contview, $data);
- }
-
- $arr['isdefaultview'] = 0;
-
- foreach($chufarr as $f1=>$v1)$qfields[$f1] = $v1;//额外字段添加
-
- if($this->isempt($contview) || contain($contview, '$contview$')){
- $arr['isdefaultview'] = 1;
- $_fields = array();
- if($this->isflow>0){
- $_fields['base_sericnum'] = $farrobj['base_sericnum']['name'];
- $_fields['base_name'] = $farrobj['base_name']['name'];
- $_fields['base_deptname'] = $farrobj['base_deptname']['name'];
- $_fields['base_status'] = $farrobj['base_status']['name'];
- }
- $fields = array_merge($_fields, $this->getfields($lx));
- if($fstr!='')$fields['file_content'] = $farrobj['file_content']['name'];
- foreach($subdata as $zb=>$da){
- $fields[$da['fields']] = $da['name'];
- }
- if($qfields)$fields = array_merge($fields,$qfields);//审核的字段显示到详情里
-
- if($lx==0)foreach($fields as $k=>$rs){$data[''.$k.'_style'] = 'width:75%';break;}
- $_colsr = $this->xiangbordercolor;
- if($_colsr=='')$_colsr = getconfig('bcolorxiang');
- $contvimr = c('html')->xiangtable($fields, $data, $_colsr);
- $contvimr = '<div align="center">'.$contvimr.'</div>';
-
- //移动默认展示
- if($lx==1){
- $contvimr = '';
- if($this->isflow>0 && $this->urs){
- // $contvimr.='<div class="r-border-b">
- // <div class="blank5"></div>
- // <table><tr>
- // <td width="50" align="left"><img style="height:40px;width:40px;border-radius:50%" src="'.$this->urs['face'].'"></td>
- // <td><div>'.$this->urs['name'].'<font color="#888888">('.$this->urs['ranking'].')</font></div><div style="padding-top:5px">'.$this->urs['deptallname'].'</div></td>
- // </tr></table>
- // <div style="margin:5px 0px" class="blank10"></div>
- // </div>';
- // 顶部头像、申请信息
- $contvimr .='<div class="" style="background-color: #fff; border-radius: 30px; padding: 10px;">
- <div style="display: flex; align-items: center;">
- <div style="width: 50px; height: 50px; border-radius: 50%; overflow: hidden;">
- <img style="height:40px;width:40px;border-radius:50%;background-color:#fff;padding:5px;" src="'.$this->urs['face'].'">
- </div>
- <div style="margin-left: 10px;">
- <div>'.$this->urs['name'].'<font color="#888888">('.$this->urs['ranking'].')</font></div>
- <div style="padding-top:5px">'.$this->urs['deptallname'].'</div>
- </div>
- </div></div>
- <div style="margin:5px 0px" class="blank10"></div>
- ';
- unset($fields['base_name']);
- unset($fields['base_deptname']);
- }
- // $contvimr .= '<div><table width="100%" id="mobile_info_table">';
- // foreach($fields as $f=>$n){
- // $vs = arrvalue($data, $f);
- // if(!isempt($vs)){
- // //子表
- // if(substr($f,0,7)=='subdata'){
- // $contvimr .= '<tr><td colspan="3"><div style="padding:5px" align="left"><div><b>'.$n.'</b></div>'.$vs.'</div></td></tr>';
- //
- // }else{
- // $contvimr .= '<tr><td nowrap><div align="right" style="color:#888888;padding:3px 0px">'.str_replace(' ','<br>',$n).'</div></td><td style="color:#888888">:</td><td width="95%"><div style="padding:3px" align="left">'.$vs.'</div></td></tr>';
- //
- // }
- // }
- // }
- // $contvimr .= '</table></div>';
- $contvimr .= '<div style=""><div id="mobile_info_table" style="width: 100%;">';
- $contvimr .= '<div style="">';
- $i=0;
- // $bkcl = ["#fff", "#f7fff4"];
- $bkcl = ["#fff", "#fff"];
- foreach($fields as $f=>$n){
- $vs = arrvalue($data, $f);
- if(!isempt($vs)){
- //子表
- if(substr($f,0,7)=='subdata'){
- $contvimr .= '<div style="padding:5px"><div><b>'.$n.'</b></div>'.$vs.'</div>';
- // } else if(substr($f,0,4)=='base'){
- } else {
- $contvimr .='
- <div style="margin-bottom: 10px; padding: 10px; background-color:'.$bkcl[$i++ % 2].'">
- <div style="font-weight: bold; color: #333; margin-bottom: 5px;">'.str_replace(' ','<br>',$n).'</div>
- <div style="color: #666; ">'.$vs.'</div>
- </div>';
- // $contvimr .= '<div style="color:#888888;padding:3px 0px">'.str_replace(' ','<br>',$n).':</div>';
- // $contvimr .= '<div style="padding:3px" align="left">'.$vs.'</div>';
- }
- }
- }
- $contvimr .= '</div></div></div>';
- }
- if(isempt($contview))$contview = $contvimr;
- $contview = str_replace('$contview$',$contvimr, $contview);
- }
- unset($farrobj);
-
- $arr['contview'] = $contview;
- $arr['readarr'] = m('log')->getreadarr($this->mtable, $this->id); //已读人员
-
- $arr['isedit'] = $this->iseditqx();
- $arr['isdel'] = $this->isdeleteqx();
- $arr['isflow'] = $this->isflow;
- $arr['modename'] = $this->modename;
- $arr['ischehui'] = $this->ischehui();
-
-
- $arr['statustext'] = $ztass[4];
- $arr['statuscolor'] = $ztass[1];
- $arr['optmenu'] = $this->getoptmenu(1); //获取在详情上展示菜单
-
- $arr['isgbjl'] = (int)$this->rock->arrvalue($this->moders,'isgbjl','0'); //是否关闭操作记录
- $arr['isgbcy'] = (int)$this->rock->arrvalue($this->moders,'isgbcy','0'); //是否不显示查阅记录
-
- //判断是否需要回执(2018-07-06)新增
- $receiptrs = false;
- $receiptrow = m('receipt')->getall("`modenum`='$this->modenum' and `mid`='$this->id' and `status`=1");
- foreach($receiptrow as $k=>$hrs){
- $uid1 = ','.$this->adminid.',';
- if(!contain(','.$hrs['receid'].',', $uid1))continue;
- if(!contain(','.$hrs['receids'].',', $uid1)){
- $receiptrs = array(
- 'id' => $hrs['id'],
- 'optname' => $hrs['optname'],
- );
- break;
- }
- }
-
-
- $arr['flowinfor'] = array(); //流程信息
- $arr['readunarr'] = array(); //未读人员
- $arr['receiptrs'] = $receiptrs; //回执确认
-
- if($this->isflow>0){
- $arr['flowinfor']= $this->getflowinfor();
- if($arr['flowinfor']['ischeck']==1){
- $arr['isplview']='0';//需要审核就不要评论框了
- }
- }
- if(isset($data['title']))$arr['title'] = $data['title'];
- $_oarr = $this->flowdatalog($arr);
- if(is_array($_oarr))foreach($_oarr as $k=>$v)$arr[$k]=$v;
-
- $conta = $this->rock->matcharr($contview,2);
- $edbof = false;
-
-
- foreach($conta as $fids){
- $thnr = '';
-
- $contview = str_replace('`'.$fids.'`', $thnr, $contview);
- }
- $arr['contview'] = $contview;
-
- return $arr;
- }
- //$lx=0PC,1移动
- private function getsubdata($xu, $rows, $lx=0)
- {
- $iscz = 0;
- $iszb = $xu+1;
- $fields = 'subdata'.$xu.'';
- $subrows = $this->db->getrows('[Q]flow_element','`mid`='.$this->modeid.' and `iszb`='.$iszb.' and `iszs`=1','`fields`,`name`,`isalign`','`sort`');
- $cont = '';
- if($this->db->count > 0){
- $iscz = 1;
- $headstr = '@xuhaos,,center'; $colorbb = getconfig('bcolorxiang', '#cccccc');
- //if($lx==1){$headstr = '';$colorbb = 'black';}
- foreach($subrows as $k=>$rs){
- $headstr.='@'.$rs['fields'].','.$rs['name'].'';
- if($rs['isalign']=='1')$headstr.=',left';
- if($rs['isalign']=='2')$headstr.=',right';
- }
- foreach($rows as $k=>$rs)$rows[$k]['xuhaos'] = $k+1;
- $slex = ($lx==0) ? 'noborder':'';
- if($this->subsubdatastyle!='')$slex = $this->subsubdatastyle;
- $cont = c('html')->createrows($rows, substr($headstr,1), $colorbb, $slex);
- }
- return $cont;
- }
-
- /**
- * 判断当前是否可以撤回
- * 撤回条件,审核未同意,最后一步是当前人审核的而为同意,2小时之内
- */
- public function ischehui()
- {
- $is = 0;
- if($this->rs['status']==1 || $this->isflow==3)return $is;//自由流程不允许撤回
- $where = "".$this->mwhere." and `valid`=1 order by `id` desc";
- $rs = $this->flogmodel->getone($where);
- $sj = (int)getconfig('flowchehuitime','2');
- $time = time()-$sj*3600;
- if($rs && $rs['status']=='1' && $rs['checkid']==$this->adminid && strtotime($rs['optdt'])>$time &&
- ($rs['courseid']>0 || $rs['iszb']=='1' ))
- $is = $rs['id'];
- return $is;
- }
-
- /**
- * 撤回操作
- */
- public function chehui($sm='')
- {
- //--autharstart--
- $id = $this->ischehui();
- if($id==0)return '当前不允许撤回操作';
- $this->flogmodel->update('courseid=0', "`id`='$id'");
- $this->addlog(array(
- 'explain' => $sm,
- 'name' => '撤回'
- ));
- $this->checksmodel->delete($this->mwhere.' and `optid`='.$this->adminid.'');//删除我指定的人
- $barr = $this->getflow(false);
- //当前审核人空
- if(isempt($barr['nowcheckid'])){
- $courseid = $barr['nowcourseid'];
- $this->addcheckname($courseid, $this->adminid, $this->adminname, false,2);
- $barr = $this->getflow(false);
- }
- $this->getflowsave($barr);
- return 'ok';
- //--autharend--
- return $this->bd6('5peg5L!h5ZG8562!5o6I5peg5q2k5Yqf6IO9');
- }
-
- public function bd6($str)
- {
- return $this->rock->jm->base64dencode($str);
- }
-
- /**
- * 读取编辑数据
- */
- public function getdataedit()
- {
- $fobj = m('file');
- $arr['data'] = $this->flowrsreplaceedit($this->rssust);
- $arr['table'] = $this->mtable;
- $arr['tables'] = $this->moders['tables'];
- $arr['modeid'] = $this->modeid;
- $arr['isedit'] = $this->iseditqx();
- $arr['isflow'] = $this->isflow;
- $arr['user'] = $this->urs;
- $arr['status'] = $this->rs['status'];
-
- $filers = $fobj->getfile($this->mtable,$this->id);
- foreach($filers as $fk=>$frs1)$filers[$fk]['thumbpath']=$fobj->getthumbpath($frs1);//缩略图显示
- $arr['filers'] = $filers;
-
- $arr['subdata'] = $this->getsuballdata();
- $filearr = array();
- $fileids = '';
- foreach($this->fieldsarr as $k=>$rs){
- $fid = $rs['fields'];
- $flx = $rs['fieldstype'];
- if($flx=='uploadfile'){
- $fval = arrvalue($this->rssust, $fid);
- if(!isempt($fval))$fileids.=','.$fval.'';
- }
- if($flx=='uploadimg'){
- $arr['data'][''.$fid.'_view'] = $this->rock->gethttppath($arr['data'][$fid]);
- }
- }
- //--autharstart--
- //读取子表中上传文件的id
- if($arr['subdata']){
- $zbzd = m('flow_element')->getrows("`mid`='$this->modeid' and `iszb`>0 and `fieldstype`='uploadfile'",'`name`,`fields`,`fieldstype`,`iszb`','`iszb`,`sort`');
- foreach($zbzd as $k1=>$rs1){
- $zbda = arrvalue($arr['subdata'], 'subdata'.(floatval($rs1['iszb'])-1).'');
- if($zbda)foreach($zbda as $k2=>$rs2){
- $fval = arrvalue($rs2, $rs1['fields']);
- if(!isempt($fval))$fileids.=','.$fval.'';
- }
- }
- }
- $arr['flow5str'] = arrvalue($this->billrs, 'flow5str');
- //--autharend--
- //读取文件详情
- if($fileids!=''){
- $frows = $fobj->getall('`id` in('.substr($fileids, 1).')','filename,id,filesizecn,fileext,optname,thumbpath,thumbplat');
- foreach($frows as $k1=>$rs1){
- $rs1['thumbpath'] = $fobj->getthumbpath($rs1);
- $filearr['f'.$rs1['id'].''] = $rs1;
- }
- }
-
- $arr['filearr'] = $filearr;
- $ztarr = $this->getnowstatus();
- $arr['statustext'] = $ztarr[0];
- $arr['statuscolor'] = $ztarr[1];
- return $arr;
- }
-
- /*
- * 读取流程信息
- */
- public function getflowinfor()
- {
- $ischeck = 0;
- $ischange= 0;
- $str = '';
- $arr = $this->getflow();
- if($arr['nowcheckid'] != $this->billrs['nowcheckid'])$this->getflowsave($arr, true);
- $nstatus = $this->rs['status'];
- $isturn = $this->rs['isturn'];
- $nowcheckid = ','.$arr['nowcheckid'].',';
- if($isturn==1 && $nstatus !=1 && contain($nowcheckid, ','.$this->adminid.',') && !in_array($nstatus, array(2,5))){
- $ischeck = 1;
- }
- $logarr = $this->getlog();
- $nowcur = $this->nowcourse;
- if(arrvalue($this->nextcourse,'checktype')=='change'){
- $ischange = 1; //需要自己选择下一步处理人
- }
- $sarr['ischeck'] = $ischeck;
- $sarr['ischange'] = $ischange;
- $sarr['nowcourse'] = $nowcur;
- $sarr['iszhuanban'] = 0;
- $sarr['ischao'] = 0;
- $sarr['nextcourse'] = $this->nextcourse;
- $sarr['nstatustext'] = $arr['nstatustext'];
- //--autharstart--
- $sarr['iszhuanban'] = (int)arrvalue($nowcur,'iszf',0);
- if($sarr['iszhuanban']>0){
- $sarr['zbrangeid'] = $this->rock->repempt(arrvalue($nowcur,'zbrangeid'));
- $sarr['zbrangelx'] = 'check';
- if($sarr['iszhuanban']==2)$sarr['zbrangelx']='';//转办单选
- }
- $sarr['ischao'] = (int)arrvalue($nowcur,'cslx',0);
- $sarr['ischaofwid'] = arrvalue($nowcur,'csfwid');
- //--autharend--
-
- if($isturn==0)$sarr['nstatustext'] = '<font color="#ff6600">待提交</font>';
-
- //读取当前审核表单,必填字段|选填字段
- $_checkfields = arrvalue($nowcur,'checkfields');
- $checkfields = array();
- if($ischeck == 1 && !isempt($_checkfields)){
- $_checkfieldsa = explode('|', $_checkfields);
- $_checkfields = join(',',$_checkfieldsa);
- $_checkxuant = arrvalue($_checkfieldsa, 1);
- $inputobj = c('input');
- $inputobj->flow = $this;
- $inputobj->mid = $this->id;
- $inputobj->urs = $this->urs;
- $elwswhere = "`mid`='$this->modeid' and `iszb`=0 and instr(',$_checkfields,', concat(',',`fields`,','))>0";
- $infeidss = $inputobj->initFields($elwswhere);
- foreach($infeidss as $_fs=>$fsva){
- $_sfes = $fsva['fields'];
- $_type = $fsva['fieldstype'];
- $showinpus = 1;
- $isbt = 1;
- if($_checkxuant && contain(','.$_checkxuant.',',','.$_sfes.','))$isbt=0;
- if($_type=='hidden' || $_type=='fixed')$showinpus=2;
- $_val = arrvalue($this->rssust, $_sfes);
- $cheo = (substr($_type,0,6)=='change' && !isempt($fsva['data']));
- if($cheo)$_val.='|'.arrvalue($this->rssust, $fsva['data']).''; //默认值
-
- $checkfields[$_sfes] = array(
- 'inputstr' => $inputobj->getfieldcontval($_sfes, $_val),
- 'name' => $fsva['name'],
- 'isbt' => $isbt,
- 'fieldstype'=> $_type,
- 'fieldsarr' => $fsva,
- 'showinpus' => $showinpus
- );
- if($cheo){
- $_sfes = $fsva['data'];
- $checkfields[$_sfes] = array(
- 'inputstr' => '',
- 'isbt' => $isbt,
- 'name' => $fsva['name'].'id',
- 'fieldstype'=> $_type,
- 'fieldsarr' => false,
- 'showinpus' => 2
- );
- }
- }
- }
- $sarr['checkfields'] = $checkfields;
- if($nstatus==2)$sarr['nstatustext'] ='<font color="#AB47F7">待提交人处理('.$this->urs['name'].')</font>';
- $loglen = count($logarr);
- //<img align="absmiddle" class="face" src="'.$rs['face'].'">
- foreach($logarr as $k=>$rs){
- if($rs['courseid']>0){
- $sty = '';
- $col = $rs['color'];
- if($str!='')$str.=' → ';
- $str.='<span style="'.$sty.'">'.$rs['actname'].'('.$rs['name'].'<font color="'.$col.'">'.$rs['statusname'].'</font>)</span>';
- }
- }
- //未同意
- if($nstatus=='2'){
- if($str!='')$str.=' → ';
- $str.= $sarr['nstatustext'];
- }else if($nstatus=='5'){
- if($str!='')$str.=' → ';
- $sarr['nstatustext'] = '<font color="#888888">已作废</font>';
- $str.= '<font color="#888888">已作废</font>';
- }else{
- foreach($this->flowarr as $k=>$rs){
- if($rs['ischeck']==0){
- $sty = 'color:#888888';
- if($rs['isnow']==1)$sty='font-weight:bold;color:#800000';
- if($str!='')$str.=' <font color=#888888>→</font> ';
- $str.='<span style="'.$sty.'" step=1>'.$rs['name'].'';
- if(!isempt($rs['nowcheckname']))$str.='('.$rs['nowcheckname'].')';
- $str.='</span>';
- }
- }
- }
-
- $sarr['flowcoursestr'] = $str;
- if($nstatus==1)$sarr['nstatustext'] = $this->getnowstatus(1); //完成后状态
-
- $actstr = ',同意|green,不同意|red';
- if(isset($nowcur['courseact']) ){
- $actstrt = $nowcur['courseact'];
- if(!isempt($actstrt))$actstr = ','.$actstrt;
- }
- $act = c('array')->strtoarray($actstr);
- foreach($act as $k=>$as1)if($k>0 && $as1[0]==$as1[1])$act[$k][1]='';
- if(arrvalue($this->moders,'isys')=='1' && (int)arrvalue($nowcur,'mid','0')>=0){
- $act[25]= array('前加签','','');
- $act[26]= array('后加签','','');
- }
- $sarr['courseact'] = $act;
- $nowstatus = $this->rs['status'];
- if($this->isflow>0 && $this->rs['isturn']==0)$nowstatus=3;
- $sarr['nowstatus'] = $nowstatus;
-
- //不同意退回可选择人员
- $step = $this->rock->arrvalue($nowcur, 'step','0');
- $tuicourse = $this->flogmodel->getall($this->mwhere.' and `courseid`>0 and `valid`=1 and `status`=1 and `step`<'.$step.'','`id`,`checkname`,`name`','`step` desc');
- $sarr['tuicourse'] = $tuicourse;
-
-
-
- return $sarr;
- }
-
- /**
- * 更新单据状态
- */
- public function updatestatus($zt)
- {
- $this->update('`status`='.$zt.'', $this->id);
- $this->billmodel->update('`status`='.$zt.'', $this->mwhere);
- }
-
- /**
- * 获取状态列表数组
- */
- public function getstatusarr()
- {
- return $this->getstatus(null, '','',2);
- }
-
- /**
- * 获取某单据当前状态
- * $rs 单据数据,$statusstr设置的状态,$other 当前审核人
- */
- public function getstatus($rs, $statusstr='',$other='', $glx=0)
- {
- $statustext = $statuscolor = '';
- if($statusstr=='')$statusstr=$this->rock->arrvalue($this->moders,'statusstr');
- $statusara = array();
- $colorsa = array('blue','green','red','#ff6600','#526D08','#888888','','','','','','','','','','','','','');
- if(isempt($statusstr)){
- $statussst = '不同意';
-
- $statusstr = '待?处理|blue,已审核|green,'.$statussst.'|red';
- }
- $nowcheckname= arrvalue($rs,'nowcheckname', arrvalue($this->billrs,'nowcheckname'));
- if(isempt($other))$other = $nowcheckname;
- $statusar = c('array')->strtoarray($statusstr);
- foreach($statusar as $k=>$v){
- if($v[0]==$v[1])$v[1]= arrvalue($colorsa, $k);
- $statusara[$k] = $v;
- }
- $statusara[5] = array('已作废','#888888');
- $statusara[23] = array('退回','#17B2B7');
- if($glx==2)return $statusara;
-
- $isturn = -1;
- if(isset($rs['isturn']))$isturn = (int)$rs['isturn'];
- $zt = $this->rock->arrvalue($rs, 'status');
- if($isturn==0){
- $statustext = '待提交';
- $statuscolor= '#ff6600';
- }elseif(!isempt($zt)){
- if(isset($statusara[$zt])){
- $statustext = $statusara[$zt][0];
- $statuscolor = $statusara[$zt][1];
- }
- }
-
- if(contain($statustext,'?')){
- $statusstr = str_replace('?', '<font color="'.$statuscolor.'">'.$other.'</font>', $statustext);
- }else{
- $statusstr = '<font color="'.$statuscolor.'">'.$statustext.'</font>';
- }
- if($glx==1){
- return $statusstr;
- }
- return array(str_replace('?', $other, $statustext), $statuscolor, $zt, $statusstr, str_replace('?', '', $statustext));
- }
-
- public function getstatusstr($rs)
- {
- return $this->getstatus($rs, '','', 1);
- }
-
- /**
- * 当前单击状态
- */
- public function getnowstatus($glx=0)
- {
- return $this->getstatus($this->rs, '','', $glx);
- }
-
- //$lx=0默认,1详情
- private $getlogrows = array();
- public function getlog($lx=0)
- {
- if(isset($this->getlogrows[$lx]))return $this->getlogrows[$lx];
- $rows = $this->flogmodel->getrows($this->mwhere, '`checkname` as `name`,`checkid`,`name` as actname,`optdt`,`status`,`explain`,`statusname`,`valid`,`courseid`,`color`,`id`,`qmimg`','`id` asc');
- $uids = $idss = '';
- $dts = c('date');
- $fo = m('file');
- $editarrs = array();
- //--autharstart--
- if($lx==1){
- $editarr = $this->db->getall('SELECT `optid`,`optdt` FROM `[Q]editrecord` where '.$this->mwhere.' order by `optid`,`optdt`');
- foreach($editarr as $k1=>$rs1)$editarrs[$rs1['optid'].$rs1['optdt']]=1;
- }
- //--autharend--
- foreach($rows as $k=>$rs){
- $uids.=','.$rs['checkid'].'';
- $idss.=','.$rs['id'].'';
- $col = $rs['color'];
- if(isempt($col))$col='green';
- if(contain($rs['statusname'],'不') || $rs['status']=='2')$col='red';
- $rows[$k]['color'] = $col;
- $rows[$k]['checkdt'] = $rs['optdt'];
- $rows[$k]['sm'] = str_replace("\n",'<br>', (string)$rs['explain']);
- $rows[$k]['explain'] = $rows[$k]['sm'];
- if(!isempt($rs['qmimg'])){
- //签名是手写的
- if(!contain($rs['qmimg'],'.')){
- $qmimg = ''.UPDIR.'/'.date('Y-m').'/qmimg'.$rs['id'].'.png';
- $bo = true;
- if(!file_exists($qmimg)){
- $bar= explode(',', $rs['qmimg']);
- $bo = $this->rock->createtxt($qmimg, base64_decode($bar[1]));
- }
- if(!$bo){
- $qmimg = $rs['qmimg'];
- }else{
- $qmimg = ''.URL.''.$qmimg.'';
- }
- }else{
- $qmimg = $rs['qmimg'];
- if(!file_exists($qmimg)){
- $qmimg = '';
- }else{
- $qmimg = ''.URL.''.$qmimg.'';
- }
- }
- $rows[$k]['qmimg'] = $qmimg;
- if(!isempt($qmimg))$rows[$k]['explain']= '<img height="30" width="70" src="'.$qmimg.'">'.$rs['explain'].'';
-
- }
- //--autharstart--
- if($lx==1 && $rs['actname']=='编辑'){
- if(isset($editarrs[$rs['checkid'].$rs['optdt']]))$rows[$k]['explain'] = $this->strappend($rows[$k]['explain'], '<a class="zhu" href="javascript:;" onclick="c.showeditcont(\''.strtotime($rs['optdt']).'\','.$rs['checkid'].')">修改记录</a>');
- }
- //--autharend--
- }
- //读取相关文件
- if($idss!=''){
- $farr = $fo->getfile('flow_log', substr($idss, 1));
- if($farr)foreach($rows as $k=>$rs){
- $fstr = $fo->getallstr($farr, $rs['id'],2);
- $rows[$k]['explain']= $this->strappend($rs['explain'], $fstr, '<br>');
- }
- }
- //读取对应人员头像
- if($uids!=''){
- $rows = m('admin')->getadmininfor($rows, substr($uids, 1), 'checkid');
- }
- $this->getlogrows[$lx] = $rows;
- return $rows;
- }
-
- public function addlog($arr=array())
- {
- $addarr = array(
- 'table' => $this->mtable,
- 'mid' => $this->id,
- 'checkname' => $this->adminname,
- 'checkid' => $this->adminid,
- 'optdt' => $this->rock->now,
- 'courseid' => '0',
- 'status' => '1',
- 'ip' => $this->rock->ip,
- 'web' => $this->rock->web,
- 'modeid' => $this->modeid
- );
- foreach($arr as $k=>$v)$addarr[$k]=$v;
- if(isset($addarr['explain']))$addarr['explain']= htmlspecialchars($addarr['explain']);
- $this->flogmodel->insert($addarr);
- $ssid = $this->db->insert_id();
- $fileid = $this->rock->post('fileid'); //这个是审批处理时下的上传文件
- if($fileid!='')m('file')->addfile($fileid, 'flow_log', $ssid, $this->modenum.'|'.$this->id);
- $logfileid = $this->rock->post('logfileid'); //这个是从单据操作菜单添加追加时
- if($logfileid!='')m('file')->addfile($logfileid, 'flow_log', $ssid, $this->modenum.'|'.$this->id);
- $addarr['id'] = $ssid;
- $this->flowaddlog($addarr);
- $this->getlogrows = array();
- return $ssid;
- }
-
- public function submit($na='', $sm='')
- {
- if($na=='')$na='提交';
- $isturn = 1;
- if($na=='保存')$isturn = 0;
- $this->addlog(array(
- 'name' => $na,
- 'explain' => $sm
- ));
- if($this->isflow>0){
- $marr['isturn'] = $isturn;
- $marr['status'] = 0;
- $this->rs['status'] = 0;
- $this->update($marr, $this->id);
-
- //每次编辑判断是否重新开始走审批。
- if(arrvalue($this->moders,'isflowlx')=='1' || $this->isflow>=3){
- $this->checksmodel->delete($this->mwhere);
- $this->flogmodel->update('`valid`=0', ''.$this->mwhere.' and `courseid`>0 and `valid`=1');
- }
-
-
-
-
- $farr = $this->getflow();
- //第一步自定义审核人
- if($farr['nowcourseid']>0){
- $sysnextoptid = $this->rock->post('sysnextoptid'); $sysnextopt = $this->rock->post('sysnextopt'); $sysnextcustidid = (int)$this->rock->post('sysnextcustidid');
- if($sysnextcustidid == $farr['nowcourseid'] && !isempt($sysnextoptid) && !isempt($sysnextopt)){
- $this->addcheckname($sysnextcustidid, $sysnextoptid, $sysnextopt, true, 1);
- $farr = $this->getflow(); //重新在读取匹配流程
- }
- }
- $farr['status'] = 0;
- $this->savebill($farr);
- if($isturn == 1){
- $this->nexttodo($farr['nowcheckid'],'submit');
- }
- }
- $this->flowsubmit($na, $sm);
-
- //抄送保存
- $this->savecsname(
- $this->rock->post('syschaosongid'),
- $this->rock->post('syschaosong'),
- $this->adminid,0,$isturn,$na);
-
- if($na=='编辑'){
- $this->gettodosend('boedit');
- }else{
- $this->gettodosend('boturn');//提交
- }
- }
-
- private function savecsname($csnameid,$csname,$uid,$type,$isturn, $na)
- {
- if(!isempt($csnameid)){
- $where = $this->mwhere.' and `type`='.$type.'';
- if($type>0)$where.=' and `uid`='.$uid.'';
- $csid = (int)$this->chaomodel->getmou('id', $where);
- if($csid==0)$where = '';
- $this->chaomodel->record(array(
- 'modeid' => $this->modeid,
- 'table' => $this->mtable,
- 'mid' => $this->id,
- 'uid' => $uid,
- 'type' => $type,
- 'csname' => $csname,
- 'csnameid' => $csnameid,
- ),$where);
- if($isturn==1)$this->nexttodo($csnameid,'chao', $na);//发送通知
- }
- }
-
- /**
- * 获取抄送人姓名
- */
- public function getcsname($id=0)
- {
- if($id>0){
- $where= "`table`='$this->mtable' and `mid`='$id' and `type`=0";
- }else{
- $where= "`modeid`={$this->modeid} and `uid`={$this->adminid} and `type`=0";
- $iscs = (int)$this->moders['iscs'];
- //if($iscs<=2)$where='1=2';//默认不读取
- }
- $ors = $this->chaomodel->getone($where,'*','`id` desc');
- $csname = $csnameid = '';
- if($ors){
- $csname = $ors['csname'];
- $csnameid = $ors['csnameid'];
- }
- return array(
- 'csname' => $csname,
- 'csnameid' => $csnameid,
- 'id' => $id,
- );
- }
-
- /**
- * 追加说明
- */
- public function zhuijiaexplain($sm='')
- {
- $this->addlog(array(
- 'explain' => $sm,
- 'name' => '追加说明',
- 'status' => 1,
- ));
- $zt = $this->rs['status'];
- if($zt==2 && $this->isflow>0 && $this->adminid==$this->uid){
- $marr['status'] = 0;
- $this->rs['status'] = 0;
- $this->update($marr, $this->id);
- $farr = $this->getflow();
- $farr['status'] = 0;
- $this->savebill($farr);
- $this->nexttodo($farr['nowcheckid'],'zhui', $sm);
- }
- $this->gettodosend('bozhui','', $sm);
- }
-
- /**
- * 催办
- */
- public function chuiban($sm='')
- {
- $this->addlog(array(
- 'explain' => $sm,
- 'name' => '催办',
- 'status' => 1,
- ));
- $farr = $this->getflow(true);
- $this->nexttodo($farr['nowcheckid'],'cuiban', $sm);
- $this->gettodosend('cuiban','', $sm);
- }
-
- //提请预算读取
- public function getyushen($rows)
- {
-
- return $rows;
- }
- private function getyushenss($id, $rows, $xu, $isq)
- {
- if($xu==0)$this->_tempauoe = array();
- if(isset($rows[$id])){
- $_tars = $rows[$id];
- if($isq==1)$this->getyushenss($_tars['id'], $rows, $xu+1, $isq);
- $this->_tempauoe[] = $_tars;
- if($isq==0)$this->getyushenss($_tars['id'], $rows, $xu+1, $isq);
- }
- return $this->_tempauoe;
- }
-
-
- /**
- * 匹配流程读取
- */
- public function getflowpipei($uid=0)
- {
- $urs = $this->urs;
- if(!$urs)$urs = $uid;
- if(!is_array($urs))$urs = $this->db->getone('[Q]admin', "`id`='$urs'", '`deptid`,`deptpath`,`id`');
- $coursedb = m('flowcourse');
-
-
-
- $barr = $coursedb->pipeiCourse($this->modeid);
- $rows = $barr['rows'];
- $this->pipeiCoursearrc = $barr['rowd'];
- $this->pipeiCoursearrs = array();
- $this->pipeiCoursearr = array();
- $kqobj = m('kaoqin');
- $this->getflowpipeis($rows, $urs, $kqobj);
- unset($this->pipeiCoursearrs);
- unset($this->pipeiCoursearrc);
- return $this->getyushen($this->pipeiCoursearr);
- }
- private function getflowpipeis($rows,$urs, $kqobj)
- {
- $shiyong = array();
- $defix = $xuhao = 0; //默认是0的
- $uid = arrvalue($urs,'id',0);
- $zshu = count($rows);
-
-
-
- foreach($rows as $k=>$rs){
- $whereid = (int)$rs['whereid'];
- $receid = $rs['receid'];
- $wherestr= arrvalue($rs, 'where');
-
- //停用了
- if($rs['status']=='0')continue;
-
- //where条件字段
- if(!isempt($wherestr)){
- $wherestr = m('base')->strreplace($this->rock->jm->base64decode($wherestr), $uid);
- $to = $this->rows("`id`='$this->id' and $wherestr ");
- if($to==0)continue;//条件不成立
- }
-
- //有条件的【流程模块条件】下的ID
- if($whereid > 0){
- $bo = $this->wheremanzhu($whereid);
- if(!$bo)continue;
- }
-
- //特殊判断过滤
- if(!isempt($rs['num'])){
- $bo = $this->flowcoursejudge($rs['num'], $rs);
- if(is_bool($bo) && !$bo)continue;
- }
-
- $xuhao++;
-
- if($defix==0 && (isempt($receid) || contain($receid,'all'))){
- $defix = $xuhao;
- }
-
- //当有设置审核条件满足时就用这个做默认,2018-07-10 新增,如果是多个满足就取最后一个
- if(isempt($receid) && (!isempt($wherestr) || $whereid > 0)){
- $defix = $xuhao;
- }
-
- $rs['xuhao'] = $xuhao;
- $shiyong[] = $rs;
- }
-
- //在根据receid匹配到哪个流程
- $pboss = false;//是否有匹配到
- if($shiyong){
- $gxuha = $kqobj->getpipeimid($urs, $shiyong, 'xuhao', $defix); //这个匹配出来是大于0的
- if($gxuha>0){
- $pboss = true;//有匹配到
- $gxuha = $gxuha-1;
- $prs = $shiyong[$gxuha];
- $this->getflowpipeisss($prs, $urs, $kqobj);
- }
- }
- //没匹配到,可能是跳过,而且有下级需要审批
- if(!$pboss && $zshu==1 && $rows[0]['childshu']>0){
- $this->getflowpipeis($rows[0]['children'], $urs, $kqobj);
- }
- }
- private function getflowpipeisss($prsnrs, $urs, $kqobj)
- {
- $prs = $prsnrs;
- unset($prs['children']);
- $this->pipeiCoursearrs[]= $prs['id'];
- $this->pipeiCoursearr[] = $prs;
-
- if($prs['childshu']>0){
- $this->getflowpipeis($prsnrs['children'], $urs, $kqobj);
- }else{
- //有nid下级就读取
- $nid = arrvalue($prs,'nid','0');
- if($nid>0 && !in_array($nid, $this->pipeiCoursearrs) && isset($this->pipeiCoursearrc, $nid)){
- $this->getflowpipeis(array($this->pipeiCoursearrc[$nid]), $urs, $kqobj);
- }
- }
- }
-
- /*
- * 获取流程
- */
- public function getflow($sbo=false)
- {
- $this->flowarr = array();
- $allcheckid = $nowcheckid = $nowcheckname = $nstatustext = '';
- $allcheckids = array();
- $nowcourseid = 0;
- $nstatus = $this->rs['status'];
- $this->nowcourse = array();
- $this->nextcourse = array();
- $this->flowisend = 0;
-
- $curs = $this->flogmodel->getrows($this->mwhere,'checkid,checkname,courseid,`valid`,`status`,`statusname`,`name`,`iszb`','id desc');
- $cufss = $ztnas = $chesarr = array();
- foreach($curs as $k=>$rs){
-
- if($rs['iszb']=='1' && !in_array($rs['checkid'], $allcheckids))$allcheckids[] = $rs['checkid']; //转办也记录到经我处理的
-
- if($rs['courseid']=='0')continue;
- $_su = ''.$rs['courseid'].'';
- $_su1 = ''.$rs['courseid'].'_'.$rs['checkid'].'';
- //$rs['status']为1就一走下一步
- if($rs['valid']==1 && in_array($rs['status'], $this->flowstatusarr)){
- if(!isset($cufss[$_su]))$cufss[$_su]=0;
- $cufss[$_su]++;
- $chesarr[$_su1] = 1; //标识已审核
- }
- if(!in_array($rs['checkid'], $allcheckids))$allcheckids[] = $rs['checkid'];
- if($nstatustext=='' && $rs['courseid']>0){
- $nstatustext = ''.$rs['checkname'].'处理'.$rs['statusname'].'';
- $nstatus = $rs['status'];
- }
- $ztnas[$rs['courseid']] = ''.$rs['checkname'].''.$rs['statusname'].'';
- }
- $nowstep = $zongsetp = -1;
- $isend = 0;
- $czt = $this->rs['status'];
- $coutye = 0; //判断是否需要前后审批处理
- $rows = ($czt==1 || $czt==5)? array() : $this->getflowpipei($this->uid);
- if($rows){
- //读取flow_checks是否比审核状态(退回的)
- $checksa = $this->checksmodel->getrows($this->mwhere.' and `addlx`=3');
- $coursea = $nrows = array();
- foreach($checksa as $k=>$rs)$coursea[$rs['courseid']]='1';
- $nrows = array();
-
- //获取审核人
- $allcheckid = '';
- $isoptsuperbo = false;
- foreach($rows as $k=>$rs){
- $uarr = $this->getcheckname($rs);
- $rows[$k]['checkid'] = $uarr[0];
- $rows[$k]['checkname'] = $uarr[1];
- $allcheckid .= ','.$uarr[0].'';
- if($rs['checktype']=='optsuper' && isempt($uarr[0]))$isoptsuperbo=true;//有操作人上级
- }
-
- //有需要读取上一步
- if($isoptsuperbo)foreach($rows as $k=>$rs){
- if($rs['checktype']=='optsuper'){
- //读取上一步处理人
- $_k1 = $k-1;
- $_uid = $this->optid;
- if($_k1>=0){
- $ours = $this->flogmodel->getone($this->mwhere.' and `courseid`='.$rows[$_k1]['id'].' and `valid`=1 ','`checkid`','`id` desc');
- if(!$ours){
- $_uid = (int)$rows[$_k1]['checkid'];
- }else{
- $_uid = $ours['checkid'];
- }
- }
- $uarr = $this->adminmodel->getsuperman($_uid);
- if($uarr){
- $rows[$k]['checkid'] = $uarr[0];
- $rows[$k]['checkname'] = $uarr[1];
- }
- }
- }
- //print_r($rows);
-
- foreach($rows as $k=>$rs){
- $nrows[] = $rs;
-
- //全部直属上级
- if($rs['checktype']=='superall'){
- $ids1 = $rs['id'];
- $suparr = $this->adminmodel->getsuperarr($this->uid);
- if($suparr){
- $logdsar = $this->getlog();
- foreach($logdsar as $k1=>$rs1){
- if($rs1['courseid']>0 && $rs1['status']=='1' && $rs1['valid']=='1')$allcheckid .= ','.$rs1['checkid'].'';
- }
- foreach($suparr as $k1=>$surs){
- if(!contain(','.$allcheckid.',', ','.$surs['id'].',')){
- $rs['oldid'] = $ids1;
- $rs['id'] = $ids1 * 99999 + $surs['id'];
- $rs['checkid'] = $surs['id'];
- $rs['checkname'] = $surs['name'];
- $rs['iszf'] = 0;
- $nrows[] = $rs;
- $allcheckid .= ','.$surs['id'].'';
- }
- }
- }
- }
- }
-
- $yisheh = '';
- if($this->isflow==2){
- $logdsar = $this->getlog();
- foreach($logdsar as $k1=>$rs1)
- if($rs1['courseid']>0 && $rs1['status']==1 && $rs1['valid']==1)$yisheh .= ','.$rs1['checkid'].'';
- }
-
- foreach($nrows as $k=>$rs){
- $whereid = (int)$rs['whereid'];
- $checkshu = $rs['checkshu'];
-
- $checkid = $rs['checkid'];
- $checkname = $rs['checkname'];
- $checktype = $rs['checktype'];
-
- //顺序前缀审批,申请人提交人不参与审批
- if($this->isflow==2 && !isempt($checkid) && isempt($rs['checkfields'])){
- if(($checkid==$this->uid || $checkid==$this->optid) )continue; //申请人
- $k2 = $k+1;
- $ntype = 'yes';
- if(isset($nrows[$k2])){
- if($nrows[$k2]['checktype']=='change')$ntype='no';//下步上步指定
- }
- //已经处理就不处理
- if($ntype=='yes' && contain(','.$yisheh.',',','.$checkid.','))continue;
- }
-
- if(!isempt($checkid))$yisheh .= ','.$checkid.'';
-
- $zongsetp++;
- $ischeck = 0;
- $checkids = $checknames = '';
-
- $_su = ''.$rs['id'].'';
- $nowshu = 0;
- if(isset($cufss[$_su]))$nowshu = $cufss[$_su];
-
- if(!$this->isempt($checkid)){
- $checkida = explode(',', $checkid);
- $checkidna = explode(',', $checkname);
- $_chid = $_chna = '';
-
- foreach($checkida as $k1=>$chkid){
- $_su1 = ''.$rs['id'].'_'.$chkid.'';
- if(!in_array($chkid, $allcheckids))$allcheckids[] = $chkid;
- if(!isset($chesarr[$_su1])){
- $_chid.=','.$chkid.'';
- $_chna.=','.arrvalue($checkidna, $k1).'';
- }
- }
- if($_chid!='')$_chid = substr($_chid, 1);
- if($_chna!='')$_chna = substr($_chna, 1);
-
- if($_chid==''){
- $ischeck = 1;
- }else{
- if($checkshu>0&&$nowshu>=$checkshu)$ischeck = 1;
- }
- $checkids = $_chid;
- $checknames = $_chna;
- }else{
- if($checkshu>0&&$nowshu>=$checkshu)$ischeck = 1;
- //需要全部审核时 同时已有审核过了 也没有审核人了
- if($checkshu == 0 && $nowshu>0)$ischeck = 1;
- }
-
- if($ischeck==0 && $coutye==0){
- if((int)arrvalue($rs,'coursetype','0')>0)$coutye = 1;
- }
-
- $rs['ischeck'] = $ischeck;
- $rs['islast'] = 0;
- $rs['checkid'] = $checkid;
- $rs['checkname'] = $checkname;
- $rs['nowcheckid'] = $checkids;
- $rs['nowcheckname'] = $checknames;
- $rs['isnow'] = 0;
- $rs['nowstep'] = $zongsetp;
- $rs['step'] = $k+1;
-
- if($ischeck==0 && $nowstep==-1){
- $rs['isnow']= 1;
- $nowstep = $zongsetp;
- $this->nowcourse = $rs; //当前审核步骤信息
- $nowcourseid = $rs['id'];
- $nowcheckid = $checkids;
- $nowcheckname = $checknames;
- }
-
- if($nowstep>-1 && $zongsetp==$nowstep+1)$this->nextcourse = $rs; //下一步信息
- $this->flowarr[]= $rs;
- }
- }
-
-
- if($zongsetp>-1)$this->flowarr[$zongsetp]['islast']=1;
- if($nowstep == -1){
- $isend = 1;
- }else{
- $nstatustext = '待'.$nowcheckname.'处理';
- }
- $this->flowisend = $isend;
- $allcheckid = join(',', $allcheckids);
- $arrbill['allcheckid'] = $allcheckid;
- $arrbill['nowcourseid'] = $nowcourseid;
- $arrbill['nowcheckid'] = $nowcheckid;
- $arrbill['nowcheckname'] = $nowcheckname;
- $arrbill['nstatustext'] = $nstatustext;
- $arrbill['nstatus'] = $nstatus;
- $arrbill['status'] = $this->rs['status'];
- $arrbill['isturn'] = $this->rs['isturn'];
- if($sbo)$this->getflowsave($arrbill);
- return $arrbill;
- }
- public function wheremanzhu($id)
- {
- $uid = $this->uid;
- $ser = $this->wheremodel->getflowwhere($id, $uid);
- if(!$ser)return true;
- $str = $ser['ntr'];
- if(!isempt($str)){
- $to = $this->db->rows('[Q]admin',"`id`='$uid' and ($str)");
- if($to>0)return false;
- }
- $str = $ser['str'];
- if(!isempt($str)){
- $str= str_replace('{asqom}','', $str);
- $to = $this->rows("`id`='$this->id' and $str");
- if($to==0)return false;
- }
- $str = $ser['utr'];
- if(!isempt($str)){
- $to = $this->db->rows('[Q]admin',"`id`='$uid' and $str");
- if($to==0)return false;
- }
- return true;
- }
-
- public function getflowsave($sarr, $suvu=false)
- {
- if(!$sarr)return;
- if($suvu)$sarr['updt'] = $this->rock->now;
- $this->billmodel->update($sarr, $this->mwhere);
- }
-
- //获取审核人
- private function getcheckname($crs)
- {
- $type = $crs['checktype'];
- $cuid = $name = '';
- $courseid= $crs['id'];
-
- $cheorws = $this->checksmodel->getall($this->mwhere.' and `courseid`='.$courseid.'','checkid,checkname');
- if($cheorws){
- foreach($cheorws as $k=>$rs){
- $lxss = $rs['checkid'];
- if(isempt($lxss) || $lxss=='0')continue;
- $cuid.=','.$lxss.'';
- $name.=','.$rs['checkname'].'';
- }
- if($cuid != ''){
- $cuid = substr($cuid, 1);
- $name = substr($name, 1);
- return array($cuid, $name);
- }
- }
-
- //自定义审核人读取
- if(!$this->isempt($crs['num'])){
- $uarr = $this->flowcheckname($crs['num']);
- if(is_array($uarr)){
- if(!$this->isempt($uarr[0]))return $uarr;
- }
- }
-
- if($type=='super' || $type=='superall'){
- $cuid = $this->urs['superid'];
- $name = $this->urs['superman'];
- }
- if($type=='dept' || $type=='super' || $type=='superall'){
- if($this->isempt($cuid) && $this->drs){
- $cuid = $this->drs['headid'];
- $name = $this->drs['headman'];
- }
- }
- if($type=='apply'){
- $cuid = $this->urs['id'];
- $name = $this->urs['name'];
- }
- if($type=='opt'){
- $cuid = $this->rs['optid'];
- $name = $this->rs['optname'];
- if(isempt($cuid)){
- $cuid = $this->urs['id'];
- $name = $this->urs['name'];
- }
- }
- if($type=='user'){
- $cuid = $crs['checktypeid'];
- $name = $crs['checktypename'];
- }
- if($type=='rank'){
- $rank = $crs['checktypename'];
- if(!$this->isempt($rank)){
- $wheer1 = $this->adminmodel->getcompanywhere(5,'',$this->companyid);
- $rnurs = $this->db->getrows('[Q]admin',"`status`=1 and `ranking`='$rank' ".$wheer1."",'id,name','sort');
- foreach($rnurs as $k=>$rns){
- $cuid.=','.$rns['id'].'';
- $name.=','.$rns['name'].'';
- }
- if($cuid != ''){
- $cuid = substr($cuid, 1);
- $name = substr($name, 1);
- }
- }
- }
- if($type=='cname'){
- $cnbar = $this->cnamemodel->getcheckname($crs['checktypeid'], $this->uid);
- $cuid = arrvalue($cnbar, 0);
- $name = arrvalue($cnbar, 1);
- }
-
- //主表上字段,一般都是ID字段
- if($type=='field'){
- $fids = $crs['checktypeid'];
- if(!isempt($fids)){
- $vals = '';
- $farrs= explode(',', $fids);
- foreach($farrs as $fid){
- $vid = arrvalue($this->rs, $fid);
- if(!isempt($vid))$vals.=','.$vid.'';
- }
- if($vals!=''){
- $vals = substr($vals, 1);
- $uarr = $this->adminmodel->getrows('`status`=1 and `id` in('.$vals.')','id,name','FIELD(`id`,'.$vals.')');
- foreach($uarr as $k=>$rs){
- $cuid.=','.$rs['id'].'';
- $name.=','.$rs['name'].'';
- }
- if($cuid != ''){
- $cuid = substr($cuid, 1);
- $name = substr($name, 1);
- }
- }
- }
- }
-
- $cuid = $this->rock->repempt($cuid);
- $name = $this->rock->repempt($name);
- return array($cuid, $name);
- }
-
-
- /**
- * 创建编号
- */
- public function createbianhao($num, $fid, $wshu=3)
- {
- if(isempt($num))$num=''.$this->modenum.'-';
- @$appdt = $this->rs['applydt'];
- if(isempt($appdt))$appdt = $this->rock->date;
- $apdt = str_replace('-','', substr($appdt,0,10));
- $num = str_replace('Ymd',$apdt,$num);
- return $this->db->sericnum($num,'[Q]'.$this->mtable.'', $fid, $wshu);
- }
-
- /**
- * 录入页上编号
- */
- public function createinputnum($num, $fid)
- {
- $acta = '';
- if(method_exists($this, $num)){
- $acta = $num;
- }else{
- if(contain($num, ',')){
- $arra = explode(',', $num);
- $acta = $arra[0];
- $num = $arra[1];
- }
- }
- if($acta && method_exists($this, $acta)){
- $barr = $this->$acta($num);
- if(is_array($barr)){
- $qom = arrvalue($barr, 'qom', $num);//前缀
- $wshu= arrvalue($barr, 'wshu', 3);//位数
- $bom = arrvalue($barr, 'bom');//后缀
- $fields = arrvalue($barr, 'fields', $fid);
- return $this->createbianhao($qom, $fields, $wshu).$bom;
- }else{
- if(isempt($barr))$barr = $num;
- return $this->createbianhao($barr, $fid);
- }
- }else{
- return $this->createbianhao($num, $fid);
- }
- }
-
- /**
- * 创建流程单号
- */
- public function createnum()
- {
- $num = $this->moders['sericnum'];
- if($num=='无'||$this->isempt($num))$num='TM-Ymd-';
- @$appdt = $this->rs['applydt'];
- if(isempt($appdt))$appdt = $this->rock->date;
- $apdt = str_replace('-','', $appdt);
- $num = str_replace('Ymd',$apdt,$num);
- return $this->db->sericnum($num,'[Q]flow_bill', 'sericnum', 3);
- }
- public function savebill($oarr=array())
- {
- $dbs = $this->billmodel;
- $whes= $this->mwhere;
- $birs= $dbs->getone($whes);
- $arr = array(
- 'table' => $this->mtable,
- 'mid' => $this->id,
- 'optdt' => isset($this->rs['optdt']) ? $this->rs['optdt'] : $this->rock->now,
- 'optname' => arrvalue($this->rs,'optname', $this->adminname),
- 'optid' => arrvalue($this->rs,'optid', $this->adminid),
- 'modeid' => $this->modeid,
- 'updt' => $this->rock->now,
- 'isturn' => $this->rs['isturn'],
- 'nstatus' => $this->rs['status'],
- 'applydt' => $this->rs['applydt'],
- 'modename' => $this->modename,
- 'uname' => $this->rs['base_name'],
- 'udeptname' => $this->rs['base_deptname'],
- 'uid' => $this->uid,
- 'isdel' => '0',
- );
- foreach($oarr as $k=>$v)$arr[$k]=$v;
- if(!$birs){
- $arr['status'] = $arr['nstatus'];
- $arr['createdt']= $arr['optdt'];
- $arr['sericnum']= $this->createnum();
- $arr['udeptid'] = $this->rock->post('sysudeptid', arrvalue($this->urs,'deptid'));
- $whes = '';
- $this->sericnum = $arr['sericnum'];
- }else{
- $udeptid = $birs['udeptid'];
- if($udeptid==0)$arr['udeptid']= arrvalue($this->urs,'deptid');
- }
- $fstr = $this->rock->post('sysflow5str');
- if($fstr)$arr['flow5str'] = $fstr;
-
- $dbs->record($arr, $whes);
- return $arr;
- }
-
- /**
- * 获取摘要
- */
- public function getsummary()
- {
- return $this->rock->reparr($this->moders['summary'], $this->rs);
- }
-
- public function addcheckname($courseid, $uid, $uname, $onbo=false, $addlx=0)
- {
- if(isempt($uid)){$uid = '0';$uname= 'auto';}
- $uida = explode(',', ''.$uid.'');
- $uidan = explode(',', $uname);
- if($onbo)$this->checksmodel->delete($this->mwhere.' and `courseid`='.$courseid.'');
- if($uida)foreach($uida as $k=>$uid){
- $uname = $this->rock->arrvalue($uidan, $k);
- $zyarr = array(
- 'table' => $this->mtable,
- 'mid' => $this->id,
- 'modeid' => $this->modeid,
- 'courseid' => $courseid,
- 'optid' => $this->adminid,
- 'optname' => $this->adminname,
- 'addlx' => $addlx, //添加类型:1自定义,2撤回添加,3退回添加,4转移添加,5自由流程,6选择流程,7监控转办
- 'optdt' => $this->rock->now,
- 'status' => 0
- );
- $this->checksmodel->delete($this->mwhere.' and `checkid`='.$uid.' and `courseid`='.$courseid.'');
- $zyarr['checkid'] = $uid;
- $zyarr['checkname'] = $uname;
- $this->checksmodel->insert($zyarr);
- }
- if($addlx==4)$this->checksmodel->delete($this->mwhere.' and `checkid`='.$this->adminid.' and `courseid`='.$courseid.'');//删除别人转给我的
- }
-
-
- /**
- * 判断保存的数据是否
- */
- public function savedatastr($fval, $farr, $data=array())
- {
- $str = '';
- if(!$farr)return $str;
- $savewhere = $farr['savewhere'];
- $name = $farr['name'];
- $types = $farr['fieldstype'];
- if(isempt($savewhere) || isempt($fval))return $str;
- $savewhere = str_replace(array('{0}','{date}','{now}'), array($name, $this->rock->date,$this->rock->now), $savewhere);
- $savewhere = $this->rock->reparr($savewhere, $data);
- $saees = explode(',', $savewhere);
- if($types=='date' || $types=='datetime')$fval = strtotime($fval);
- if($types=='number')$fval = floatval($fval);
- foreach($saees as $saeess){
- $fsaed = explode('|', $saeess);
- $msg = isset($fsaed[2]) ? $fsaed[2] : ''.$name.'数据不符号';
- $val = isset($fsaed[1]) ? $fsaed[1] : '';
- $lfs = $fsaed[0];
- if($val != ''){
- if($types=='date' || $types=='datetime')$val = strtotime($val);
- if($types=='number')$val = floatval($val);
- if($lfs=='gt'){$bo = $fval>$val;if(!$bo)return $msg;}
- if($lfs=='egt'){$bo = $fval>=$val;if(!$bo)return $msg;}
- if($lfs=='lt'){$bo = $fval<$val;if(!$bo)return $msg;}
- if($lfs=='elt'){$bo = $fval<=$val;if(!$bo)return $msg;}
- if($lfs=='eg'){$bo = $fval==$val;if(!$bo)return $msg;}
- if($lfs=='neg'){$bo = $fval!=$val;if(!$bo)return $msg;}
- }
- }
- return $str;
- }
-
- /**
- * 重写更新一下方法
- */
- public function update($arr, $where)
- {
- if(is_array($arr)){
- foreach($arr as $k=>$v)$this->rs[$k]=$v;
- }
- return parent::update($arr,$where);
- }
-
- /**
- * 将操作记录标识无效状态
- */
- public function updatelogvalid($whe)
- {
- $this->flogmodel->update('valid=0', $this->mwhere.' '.$whe);
- }
-
- /**
- * 说明追加
- */
- public function strappend($sm, $str, $fh=',')
- {
- if(isempt($str))return $sm;
- if(!isempt($sm))$sm.=$fh;
- $sm.=$str;
- return $sm;
- }
-
- /**
- * 异常直接标识已完成
- */
- public function checkerror($lx=1,$sm='')
- {
- if($sm=='')$sm='单据异常管理员处理';
- $msg = $this->check($lx, $sm, 1);
- return $msg;
- }
- /**
- * 提交审核处理
- * $zt 状态 $sm 说明 $lx=0默认1异常标识
- */
- public function check($zt, $sm='', $lx=0)
- {
- if($this->rs['status']==1)return '流程已处理完成,无需操作';
- $arr = $this->getflow();
- $flowinfor = $this->getflowinfor();
-
- if($flowinfor['ischeck']==0 && $lx==0)return '当前是['.$arr['nowcheckname'].']处理';
-
- $nowcourse = $this->nowcourse; //当前步骤信息
-
- //异常的审核
- if($lx==1){
- if($arr['nowcourseid']!=0)return '当前有审核步骤ID是存在的不能直接标识已完成';
- $to = $this->flogmodel->rows($this->mwhere.' and `courseid`>0 and `status`=1');
- if($to==0)return '该单据没有任何通过审核处理不能直接标识已完成或已审核';
- $nowcourse = array('id'=>66666,'name'=>'异常处理','step'=>0);
- }
-
- $nextcourse = $this->nextcourse;
- $zynameid = $this->rock->post('zynameid');
- $zyname = $this->rock->post('zyname');
- $csnameid = '';
- $csname = '';
- $nextname = $this->rock->post('nextname');
- $nextnameid = $this->rock->post('nextnameid');
- $qmimgstr = $this->rock->post('qmimgstr'); //签名图片
- $tuiid = (int)$this->rock->post('tuiid'); //退回到哪个flowlog.id上
- $iszhuanyi = $ischangenext = 0;
- if($zt==1 && $this->isflow!=3 && isempt($zynameid) && arrvalue($nextcourse,'checktype')=='change'){
- $ischangenext = 1;//需要选下步处理人
- }
- if($zt!=2)$tuiid = 0;//只有2的状态才能退回
-
- $istongyi = in_array($zt, $this->flowstatusarr); //是否审核本步骤同意
-
- //判断是否转办
- if($zynameid!='' && $istongyi){
- if($zynameid==$this->adminid)return '不能转给自己';
- $sm = $this->strappend($sm, '转给:'.$zyname.'');
- $iszhuanyi = 1;
- $this->rs['syszb_name'] = $zyname;
- $this->rs['syszb_nameid'] = $zynameid;
- }
- //--autharstart--
- $csnameid = $this->rock->post('csnameid');
- $csname = $this->rock->post('csname');
- if(arrvalue($nowcourse,'cslx')=='2' && $csnameid=='' && $istongyi)return '必须选择抄送对应人';
- if(arrvalue($nowcourse,'cslx')=='3' && $istongyi){
- $csfwid = arrvalue($nowcourse,'csfwid');
- $csfwname = arrvalue($nowcourse,'csfwname');
- if(!isempt($csfwid)){
- if(contain($csfwid,'super')){
- $_super = $this->adminmodel->getsuperman($this->adminid);
- $csfwid = str_replace('super', $_super[0], $csfwid);
- $csfwname = str_replace('审批人直属上级', $_super[1], $csfwname);
- if(substr($csfwid,0,1)==','){$csfwid = substr($csfwid, 1);$csfwname = substr($csfwname, 1);}
- }
- $csnameid = $this->adminmodel->gjoins($csfwid);
- $csname = $csfwname;
- }
- }
- $this->rs['syscs_name'] = $csname;
- $this->rs['syscs_nameid'] = $csnameid;
- //--autharend--
-
-
- if($nextnameid=='' && $ischangenext==1)return '请选择下一步处理人';
-
-
-
- $ufied = array();
- if($iszhuanyi == 0 && $zt!=2){
- foreach($flowinfor['checkfields'] as $chef=>$chefv){
- $ufied[$chef] = $_val = $this->rock->post('cfields_'.$chef.'');
- if(isempt($_val) && $chefv['isbt']=='1')$this->echomsg(''.$chefv['name'].'不能为空');
- $_stype = arrvalue($chefv, 'fieldstype');
- if($_stype=='graph')$ufied[$chef] = c('input')->createqianming($_val);
- $_str = $this->savedatastr($_val, $chefv['fieldsarr'], $this->rs);
- if($_str!='')$this->echomsg($_str);
- }
- }
-
- $this->checkiszhuanyi = $iszhuanyi;//是否为转办
-
- $barr = $this->flowcheckbefore($zt, $sm, $ufied);
- $msg = '';
- if(is_array($barr) && isset($barr['msg']))$msg = $barr['msg'];
-
- //更新字段
- if(is_array($barr) && isset($barr['update'])){
- foreach($barr['update'] as $_k=>$_v)$ufied[$_k] = $_v;
- }
- if(is_string($barr))$msg = $barr;
- if(!isempt($msg))return $msg;
-
- if($ufied){
- $bo = $this->update($ufied, $this->id);
- if(!$bo)return 'dberr:'.$this->db->error();
- }
-
- $courseact = $flowinfor['courseact'];
- $act = $courseact[$zt];
- $statusname = $act[0];//状态名称
- $statuscolor= $act[1];//状态颜色
- $nzt = $act[2];//处理后对应状态
- $courseid = $nowcourse['id'];
-
- $this->checksmodel->update('`status`='.$zt.'', $this->mwhere.' and `checkid`='.$this->adminid.' and `courseid`='.$courseid.'');
- if($iszhuanyi == 1){
- $this->addcheckname($courseid, $zynameid, $zyname, false, 4);
- $nowcourse['id'] = 0;
- }
-
- //指定下步审核
- if($ischangenext==1){
- $this->addcheckname($nextcourse['id'], $nextnameid, $nextname, true, 1);
- }
-
- //读取退回记录
- $tuirs = array();
- if($tuiid > 0)$tuirs = $this->flogmodel->getone($tuiid);
- if(!$tuirs)$tuiid = 0;
- if($tuiid>0){
- $sm = $this->strappend($sm, '退回到['.$tuirs['name'].'('.$tuirs['checkname'].')]');
- $statusname = '退回';
- $statuscolor = '#17B2B7';
- }
- $this->checkistui = $tuiid;//是否为退回的
- $logsm = $sm;
- if($iszhuanyi==0 && $csname)$logsm = $this->strappend($logsm,'抄送给:'.$csname.'');
- $this->lastlogid = $this->addlog(array(
- 'courseid' => $nowcourse['id'],
- 'name' => $nowcourse['name'],
- 'step' => $nowcourse['step'],
- 'status' => $zt,
- 'statusname'=> $statusname,
- 'color' => $statuscolor,
- 'explain' => $logsm,
- 'iszb' => $iszhuanyi,
- 'qmimg' => $qmimgstr
- ));
-
-
-
- //退回处理
- if($tuiid > 0){
- $this->addcheckname($tuirs['courseid'], $tuirs['checkid'], $tuirs['checkname'], true, 3);
- $this->updatelogvalid('and `courseid`>0 and `status`=1 and `step`>='.$tuirs['step'].'');
- }
-
- $lzt = $this->rock->repempt($nzt, $zt);//最后状态
-
- $uparr = $nexttodoarr = $nexttodoarc = array();
- $bsarr = $this->getflow();
- $bsarr['tuiid'] = $tuiid;
- $nextcheckid = $bsarr['nowcheckid']; //下一步审核人
-
- if($istongyi){//同意
- if($iszhuanyi==0){
- $uparr['status']= $this->rock->repempt($nzt,'0');
- }
- $nexttodoarr = array($nextcheckid, 'next', $sm, $statusname);//通知下一步处理人
- }else{
- if($tuiid>0){
- $lzt = 23; //退回固定状态23
- $nexttodoarr = array($nextcheckid, 'tui', $sm, $statusname); //通知到退回的人员
- }elseif($zt==2){//2固定不同意
- $nexttodoarr = array($this->optid, 'nothrough', $sm, $statusname);
- }
- $uparr['status'] = $lzt;
- }
- $this->flowcheckafter($zt, $sm, $nowcourse);
-
- $bsarr['nstatus'] = $lzt;
- $bsarr['checksm'] = $sm;
-
- //没有当前步骤就是结束完成了
- if(!$this->nowcourse){
- $uparr['status'] = $lzt;
- $nexttodoarc = array($this->optid, 'finish', $sm, '');
- }
-
- //最后状态更新
- if($uparr){
- $this->update($uparr, $this->id);
- }
-
- //审核完成了调用对应函数接口
- if(!$this->nowcourse){
- $this->flowcheckfinsh($zt);
- if($istongyi){
- $this->checksmodel->delete($this->mwhere);//完成了删除设置审核人
- }
- }
- $bsarr['status'] = $this->rs['status'];//状态
- $this->getflowsave($bsarr, true);
-
- //通知给相应人员
- if($this->db->backsql()){
- $bos = ($courseid == arrvalue($this->nowcourse, 'id') && $istongyi);
- if($nexttodoarr && (!$bos || $iszhuanyi==1))$this->nexttodo($nexttodoarr[0],$nexttodoarr[1],$nexttodoarr[2],$nexttodoarr[3]);
- if($nexttodoarc)$this->nexttodo($nexttodoarc[0],$nexttodoarc[1],$nexttodoarc[2],$nexttodoarc[3]);
- }
-
- //通知发送的
- if($iszhuanyi == 1){
- $this->gettodosend('bozhuan','', $sm, 0, ''.$this->adminname.'将['.$nowcourse['name'].']转给:'.$zyname.'');
- }else{
- if($istongyi)$this->gettodosend('botong', $statusname, $sm, $nowcourse['id']);
- if($zt==2)$this->gettodosend('bobutong',$statusname, $sm, $nowcourse['id']);
- if(!$this->nowcourse && $istongyi)$this->gettodosend('bofinish', '', $sm); //全部完成了
- }
-
- //通知给抄送人,转办不需要抄送
- if($iszhuanyi==0){
- $sm1 = '在“'.$nowcourse['name'].'”处理'.$statusname.'';
- $this->savecsname($csnameid,$csname,$this->adminid,$nowcourse['id'],1, $sm1);
- }
-
- return 'ok';
- }
-
- public function pushs($receid, $cont, $title='', $params=array())
- {
- return $this->push($receid,'', $cont, $title, 0, $params);
- }
-
- /**
- * 详情的URL
- */
- public function getxiangurl($num='', $id=0, $lx='x')
- {
- if($num=='')$num = $this->modenum;
- if($id==0)$id = $this->id;
- $url = URL;
- if($lx=='auto')$lx = ($this->ismobile==1)?'x':'p';
- if($lx=='x' || $lx=='a')$url = $this->rock->getouturl();//移动端
- $url = ''.$url.'task.php?a='.$lx.'&num='.$num.'&mid='.$id.'';
- if(COMPANYNUM)$url.='&dwnum='.COMPANYNUM.'';
- return $url;
- }
- public function getxiangurlx($num='',$id=0){return $this->getxiangurl($num,$id,'x');}
-
-
- /**
- * 推送提醒
- */
- public function push($receid, $gname='', $cont='', $title='', $wkal=0, $params=array())
- {
- if(isempt($receid) && $wkal==1)$receid='all';
- if(isempt($receid))return false;
- if(contain(','.$receid.',', ',d1,'))$receid='all'; //如果选顶级d1就是全员
- $modenum = arrvalue($params, 'modenum', $this->modenum);
- $modename = arrvalue($params, 'modename', $this->modename);
- $id = (int)arrvalue($params, 'id', $this->id);
- $moders = arrvalue($params, 'moders');
- if(!is_array($moders))$moders = $this->moders;
- if($gname=='')$gname = $modename;
- $reim = m('reim');
- $url = $this->getxiangurl($modenum, $id, 'p');
- $wxurl = $this->getxiangurl($modenum, $id, 'x');
- $emurl = $this->getxiangurl($modenum, $id, 'a');
- if($id==0){
- $url = '';$wxurl = '';$emurl='';
- }
- $url = arrvalue($params, 'url', $url); //PC上URL
- $wxurl = arrvalue($params, 'wxurl', $wxurl); //移动端URL
- $emurl = arrvalue($params, 'emurl', $emurl); //邮件上URL
-
- $slx = 0;
- $pctx = $moders['pctx'];
- $mctx = $moders['mctx'];
- $wxtx = $moders['wxtx'];
- $ddtx = $moders['ddtx'];
- $emtx = $moders['emtx'];
- if($pctx==0 && $mctx==1)$slx=2;
- if($pctx==1 && $mctx==0)$slx=1;
- if($pctx==0 && $mctx==0)$slx=3;
- $this->rs['now_adminname'] = $this->adminname;
- $this->rs['now_modename'] = $modename;
- $cont = $this->rock->reparr($cont, $this->rs);
- $receido= $receid;
- $receid = $this->adminmodel->gjoins($receid);//已经返回对应人id了
- $uids = m('todo')->addtodo($receid, $modename, $cont, $modenum, $id);
- if($uids!='' && $moders['type'] != '系统' && $id > 0)$this->todosmodel->addtotouids($uids, array(
- 'table' => $moders['table'],
- 'mid' => $id,
- 'modename' => $modename,
- 'modenum' => $modenum,
- ));
-
- $title = $this->rock->reparr($title, $this->rs);
- $reim->pushagent($uids, $gname, $cont, $title, $url, $wxurl, $slx, ''.$modenum.'|'.$id.'');
- $this->flowchangetodo($uids, $gname);
-
- if(isempt($title))$title = $modename;
-
- //--autharstart--
- //邮件提醒发送不发送全体人员的,太多了
- if($emtx == 1 && $receido != 'all'){
- $emcont = '您好:<br>'.$cont.'(邮件由系统自动发送)';
- if($emurl!=''){
- $emcont.='<br><a href="'.$emurl.'" target="_blank" style="color:blue"><u>详情>></u></a>';
- }
- $msg = m('email')->sendmail($title, $emcont, $receid);
- if($msg!='ok')m('log')->addlogs('邮件', $msg , 2);
- }
- $drecied = ($receido=='all') ? $receido : $receid;
-
- //微信提醒发送
- $isptbo = $reim->installwx(5);
- if($wxtx==1 || $isptbo){
- $wxarra = $this->flowweixinarr;
- $wxarr = array(
- 'title' => $title,
- 'description' => $cont,
- 'url' => $wxurl
- );
- $picurl = arrvalue($this->rs, 'fengmian');
- if($picurl != ''){
- if(substr($picurl,0,4) != 'http')$picurl = URL.$picurl;
- $wxarr['picurl'] = $picurl;
- }
- foreach($wxarra as $k=>$v)$wxarr[$k]=$v;
-
- //REIM即时通讯平台
- if($isptbo){
- $sarr = $wxarr;
- $sarr['url'] = $emurl;
- m('reimplat:agent')->sendxiao($receid, $gname, $sarr);
- }
-
- //企业微信提醒
- if($wxtx==1){
- if($this->option->getval('qywxplat_tixi')=='1'){
- c('rockqywx')->sendmess($drecied, $wxarr['title'], $wxarr['description'], $wxarr['url'], arrvalue($wxarr, 'picurl'));
- }else{
- if($reim->installwx(1)){
- $gnames = $gname;
- if($gname != $modename)$gnames =''.$modename.','.$gname.'';
- $devagent = $this->option->getval('weixinqy_devagent');
- if(isempt($devagent))$devagent = '办公助手';
- $barr = m('weixinqy:index')->sendxiao($drecied, ''.$gnames.','.$devagent.'', $wxarr);
- m('log')->todolog('企业微信提醒', $barr);
- }
- }
- }
-
- //微信公众号
- if(($gname=='流程待办' || $gname=='流程申请') && $wxtx==1 && $reim->installwx(4)){
- $this->billrs = $this->billmodel->getone($this->mwhere);
- $zta = $this->getnowstatus();
- $barr = m('wxgzh:index')->send($receid, '流程待办', array(
- 'url' => $wxurl,
- 'applyname' => $this->rs['base_name'],
- 'deptname' => $this->rs['base_deptname'],
- 'sericnum' => $this->sericnum,
- 'title' => $title,
- 'explain' => $cont,
- 'modename' => $this->modename,
- 'optname' => $this->adminname,
- 'optdt' => $this->rock->now,
- 'statustext' => $zta[0],
- 'statustext_color' => $zta[1],
- 'applydt' => arrvalue($this->billrs, 'applydt', $this->rock->date),
- 'summary' => $this->getsummary(),
- ));
- m('log')->todolog('微信模版消息', $barr);
- }
- }
- //钉钉提醒发送
- if($ddtx==1 && $reim->installwx(2)){
- $barr = m('dingding:index')->sendoa($drecied, $gname, array(
- 'title' => $title,
- 'content' => $cont,
- 'wxurl' => arrvalue($this->flowweixinarr, 'url', $wxurl),
- 'modename' => $modename
- ));
- m('log')->todolog('钉钉提醒', $barr);
- }
- //--autharend--
- $this->flowweixinarr=array();
- return $receid;
- }
-
- /**
- * 下一步发通知
- */
- public function nexttodo($nuid, $type, $sm='', $act='')
- {
- $cont = '';
- $tit = '';
- $gname = '流程待办';
- $summary= $this->getsummary();
- if($type=='submit' || $type=='next' || $type == 'cuiban'){
- $cont = '你有['.$this->uname.']的['.$this->modename.',单号:'.$this->sericnum.']需要处理';
- if($sm!='')$cont.=',说明:'.$sm.'';
- $tit = ''.$this->uname.'的'.$this->modename.'';
- //短信提醒
- if($type != 'cuiban'){
- $txnum = $this->option->getval('sms_txnum');
- if(!isempt($txnum)){
- $mknum = $this->option->getval('sms_mknum');
- if($mknum=='all' || contain(','.$mknum.',',','.$this->modenum.',')){
- $wxurl = $this->getxiangurlx();
- $barr = c('xinhuapi')->sendsms($nuid, '', $txnum, array(
- 'modename' => $this->modename,
- 'sericnum' => $this->sericnum,
- 'applyname'=> $this->uname,
- 'deptname' => $this->rs['base_deptname'],
- ),$wxurl);
- }
- }
- }
- $type = 'daiban';
- }
-
-
-
- //审核不同意
- if($type == 'nothrough'){
- $cont = '你提交['.$this->modename.',单号:'.$this->sericnum.']'.$this->adminname.'处理['.$act.'],原因:['.$sm.']';
- $gname= '流程申请';
- $tit = ''.$this->modename.'处理'.$act.'';
- }
- if($type == 'finish'){
- $cont = '你提交的['.$this->modename.',单号:'.$this->sericnum.']已全部处理完成';
- $gname= '流程申请';
- $tit = ''.$this->modename.'全部处理完成';
- }
- if($type == 'zhui'){
- $cont = ''.$this->adminname.'追加单据说明['.$this->modename.',单号:'.$this->sericnum.'],说明:['.$sm.']';
- }
- //退回
- if($type == 'tui'){
- $cont = '['.$this->adminname.']退回单据['.$this->modename.',单号:'.$this->sericnum.']到你这请及时处理,说明:'.$sm.'';
- }
- //提交抄送
- if($type == 'chao'){
- $cont = ''.$this->adminname.''.$sm.'了“'.$this->modename.'”';
- if(!isempt($summary))$cont.=',摘要“'.$summary.'”';
- if($this->isflow>0)$cont.=',单号“'.$this->sericnum.'”';
- $gname= '';
- $tit = ''.$this->modename.'的单据抄送';
- }
- //评论
- if($type=='pinglun'){
- $cont = ''.$this->adminname.''.$act.'你的['.$this->modename.']单据,说明:'.$sm.'';
- $gname = '';
- $tit = ''.$this->modename.'评论';
- }
-
- //回执确认
- if($type=='receipt'){
- $cont = ''.$this->adminname.''.$act.'['.$this->modename.']的单据';
- if($sm!='')$cont.=',说明:'.$sm.'';
- $gname = '回执确认';
- $tit = ''.$this->modename.'回执确认';
- }
-
- $nbis = $this->flownexttodo($type); //自定义推送内容
- if($nbis){
- if(is_string($nbis))$cont = $nbis;
- if(is_array($nbis)){
- $tit = arrvalue($nbis, 'title', $tit);
- $gname = arrvalue($nbis, 'gname', $gname);
- $cont = arrvalue($nbis, 'cont', $cont);
- }
- }
- if($cont!='')$this->push($nuid, $gname, $cont, $tit);
- }
-
-
- public function getwxurl($num='')
- {
- if($num=='')$num = $this->modenum;
- $url = $this->rock->getouturl();
- $str = ''.$url.'?m=ying&d=we&num='.$num.'';
- return $str;
- }
-
- /**
- * 模块移动端url
- */
- public function getweurl($num='')
- {
- if($num=='')$num = $this->modenum;
- $url = $this->rock->getouturl();
- $str = ''.$url.'?m=ying&d=we&mnum='.$num.'';
- return $str;
- }
-
- /**
- * 删除单据
- */
- public function deletebill($sm='', $qxpd=true)
- {
- if(getconfig('systype')=='demo')return '演示请勿删除';
- if($qxpd){
- $is = $this->isdeleteqx();
- if($is==0)return '无权删除';
- }
-
- //删除前判断
- if(method_exists($this,'flowdeletebillbefore')){
- $bstr = $this->flowdeletebillbefore($sm);
- if(!isempt($bstr))return $bstr;
- }
- $modewhere = "`modenum`='".$this->modenum."' and `mid`=".$this->id."";
- $this->flogmodel->delete($this->mwhere);
- m('reads')->delete($this->mwhere);
- m('file')->delfile('', "`mtype`='".$this->mtable."' and `mid`=".$this->id." and `id` not in(select `fileid` from `[Q]files` where `type`=3)");
- $tables = $this->moders['tables'];
- if(!isempt($tables)){
- $arrse = explode(',', $tables);
- foreach($arrse as $arrses)m($arrses)->delete('mid='.$this->id.'');
- }
- $this->billmodel->delete($this->mwhere);
- $this->todosmodel->delete($this->mwhere);
- $this->checksmodel->delete($this->mwhere);
- $this->chaomodel->delete($this->mwhere);
- m('remind')->delete($this->mwhere); //单据提醒的
- m('todo')->delete($this->mwhere);
- m('todo')->delete($modewhere);
- m('receipt')->delete($this->mwhere); //回执
- m('im_history')->delete("`xgurl`='".$this->modenum."|".$this->id."'");
- m('files')->delete("`ip`='".$this->modenum."|".$this->id."'");
- $this->delete($this->id);
- $this->flowdeletebill($sm);
- $this->flowzuofeibill($sm);
- $this->gettodosend('bodel','', $sm);
-
- $dels = '删除模块['.$this->modename.']id为'.$this->id.'的单据';
- $ztss = arrvalue($this->rs,'base_summary');
- if(!isempt($ztss))$dels.=',摘要['.$ztss.']';
- if(!isempt($sm))$dels.=',说明:'.$sm.'';
-
- m('log')->addlogs('删除单据', $dels, 3);
-
- foreach($this->wherejoin as $num=>$fields){
- $this->deletebilljoin($num, "`$fields`='$this->id'", $sm);
- }
- return 'ok';
- }
-
- /**
- * 关联删除
- */
- public function deletebilljoin($num, $where, $sm='')
- {
- $flow = m('flow')->initflow($num);
- $rows = $flow->getall($where);
- foreach($rows as $k1=>$rs1){
- $mid = $rs1['id'];
- $flow->loaddata($mid, false);
- $flow->deletebill($sm, false);
- }
- }
-
- /**
- * 关联作废
- */
- public function zuofeibilljoin($num, $where, $sm='')
- {
- $flow = m('flow')->initflow($num);
- $rows = $flow->getall($where);
- foreach($rows as $k1=>$rs1){
- $mid = $rs1['id'];
- $flow->loaddata($mid, false);
- $flow->zuofeibill($sm);
- }
- }
-
- /**
- * 单据作废处理
- */
- public function zuofeibill($sm='')
- {
- $this->addlog(array(
- 'explain' => $sm,
- 'name' => '作废',
- 'status' => 1,
- ));
- $this->update('`status`=5', $this->id);
- $zfarr = array(
- 'status' => 5,
- 'nstatus' => 5,
- 'checksm' => '作废:'.$sm.'',
- 'nowcheckid' => '',
- 'nowcheckname' => '',
- 'nstatustext' => '作废',
- 'updt' => $this->rock->now,
- );
- $this->billmodel->update($zfarr, $this->mwhere);
- $tables = $this->moders['tables'];
- if(!isempt($tables)){
- $arrse = explode(',', $tables);
- foreach($arrse as $arrses)m($arrses)->delete('mid='.$this->id.'');
- }
- $this->flowzuofeibill($sm);
- $this->gettodosend('bozuofei','', $sm);
-
- foreach($this->wherejoin as $num=>$fields){
- $this->zuofeibilljoin($num, "`$fields`='$this->id'", $sm);
- }
- return 'ok';
- }
-
- /**
- * 对外接口详情页加载数据
- */
- public function openxiang()
- {
- $xiangdata = $btndata = array();
- $data = $this->flowrsreplace($this->rs,4);
- foreach($this->fieldsarra as $k=>$rs){
- if($rs['iszs']=='1'){
- $xiangdata[] = array(
- 'name' => $rs['name'],
- 'fields'=> $rs['fields'],
- 'value' => $this->rock->repempt(arrvalue($data,$rs['fields']))
- );
- }
- }
- $barr['xiangdata'] = $xiangdata;
- $btnrows = $this->db->getrows('[Q]flow_menu',"`setid`='$this->modeid' and `status`=1 and `num` like 'open%'",'id,wherestr,name,num,issm,type','`sort`');
- foreach($btnrows as $k=>$rs){
- $wherestr = $rs['wherestr'];
- $bo = false;
- if(isempt($wherestr)){
- $bo = true;
- }else{
- $ewet = $this->wheremodel->getstrwhere($this->rock->jm->base64decode($wherestr));
- $ewet = str_replace(array('{asqom}','1=2 and'),'', $ewet);
- $tos = $this->rows("`id`='$this->id' and $ewet");
- if($tos>0)$bo = true;
- }
- if($bo)$btndata[] = array(
- 'id' => $rs['id'],
- 'name' => $rs['name'],
- 'issm' => $rs['issm'],
- );
- }
- $barr['btndata'] = $btndata;
- if(method_exists($this,'flowopenxiang')){
- $lbarr = $this->flowopenxiang($data,$xiangdata,$btndata);
- if(is_array($lbarr))foreach($lbarr as $k=>$v)$barr[$k]=$v;
- }
- return $barr;
- }
-
- /**
- * 短信催办,需要有短信功能
- */
- public function smschuiban($sm='')
- {
- //有流程和是我催办
- if($this->isflow>0 && $this->adminid==$this->uid){
- $farr = $this->getflow(true);
- $nowcheckid = $farr['nowcheckid']; //当前处理人
- $tplnum = $this->option->getval('sms_cbnum','defnum');//短信模版
- $wxurl = $this->getxiangurlx();
- $barr = c('xinhuapi')->sendsms($nowcheckid, '', $tplnum, array(
- 'modename' => $this->modename,
- 'sericnum' => $this->sericnum,
- 'applyname'=> $this->uname,
- 'deptname' => $this->rs['base_deptname'],
- ),$wxurl, false, false);//短信催办不需要日志和异步
- if(!$barr['success'])return $barr['msg'];
- $this->addlog(array(
- 'explain' => $sm,
- 'name' => '短信催办',
- 'status' => 1,
- ));
- }
- return 'ok';
- }
-
- /**
- * 让它可以重新走审批
- */
- public function reloadflow($sm='')
- {
- $this->update(array('status'=>0), $this->id);
- $this->flogmodel->update('`valid`=0', ''.$this->mwhere.' and `courseid`>0');
- $this->addlog(array(
- 'explain' => $sm,
- 'name' => '重新审批',
- 'status' => 1,
- ));
- $this->getflow(true);
- $this->billmodel->update('`status`=0,`nstatus`=0',$this->mwhere);
- return 'ok';
- }
-
- /**
- * 加入日程提醒
- */
- public function addschedule($sm='')
- {
- $txdt = $this->rock->post('txdt');
- if(isempt($sm))return '说明不能为空';
- if(isempt($txdt))return '提醒时间不能为空';
- $barr['title'] = $sm;
- $barr['startdt'] = $txdt;
- $barr['uid'] = $this->adminid;
- $barr['optdt'] = $this->rock->now;
- $barr['optname']= $this->adminname;
- $barr['txsj'] = 1;
- m('schedule')->insert($barr);
- return 'ok';
- }
-
- /*
- * 获取操作菜单 $flx=0 从操作上点出来 1详情上展示的
- */
- public function getoptmenu($flx=0)
- {
- $where = '';
- if($flx==1)$where='and `iszs`=1';
- $rows = $this->db->getrows('[Q]flow_menu',"`setid`='$this->modeid' ".$where." and `status`=1",'id,wherestr,name,statuscolor,statusvalue,num,islog,issm,type,upgcont','`sort`');
- $arr = array();
- $bfrom = $this->rock->post('bfrom');
- if($flx==0)$arr[] = array('lx'=>0,'name'=>$this->rock->jm->base64decode('5pyq562!5o6I5peg5rOV5pi!56S66I!c5Y2V5aaC5bey562!5o6I5Y675Y2H57qn'),'optmenuid'=>0,'color'=>'red');
- //--autharstart--
- $arr = array();
- foreach($rows as $k=>$rs){
- $wherestr = $rs['wherestr'];
- $bo = false;
- if(isempt($wherestr)){
- $bo = true;
- }else{
- $ewet = $this->wheremodel->getstrwhere($this->rock->jm->base64decode($wherestr));
- $ewet = str_replace('{asqom}','', $ewet);
- $tos = $this->rows("`id`='$this->id' and $ewet");
- if($tos>0)$bo = true;
- }
- $rs['lx'] = $rs['type'];
- $rs['optnum'] = $rs['num'];
- if(!isempt($rs['num'])){
- $glx = $this->flowgetoptmenu($rs['num'], $bo);
- if(is_bool($glx))$bo = $glx;
- if(is_array($glx))foreach($glx as $k1=>$v1)$rs[$k1]=$v1;
- }
- $rs['optmenuid'] = $rs['id'];$rs['color']='';
- if(!isempt($rs['statuscolor']))$rs['color'] = $rs['statuscolor'];
- unset($rs['id']);unset($rs['num']);unset($rs['wherestr']);unset($rs['type']);unset($rs['statuscolor']);
- if($rs['lx']==5 || $rs['lx']==7){
- $upgcont = $this->rock->jm->base64decode($rs['upgcont']);
- $rs['upgcont'] = $this->rock->reparr($upgcont, $this->rs);
- }else{
- unset($rs['upgcont']);
- }
- if($bo)$arr[] = $rs;
- }
- //--autharend--
- if($flx==1)return $arr;
-
-
- $status = (int)arrvalue($this->rs,'status','0');
- $isturn = (int)arrvalue($this->rs, 'isturn','0');
- $ismy = ($this->uid == $this->adminid or $this->optid == $this->adminid);
-
- $isreadbo = $this->isreadqx(1);
- //菜单上参数说明lx 标识类型,nup是否不显示上传框,optmenuid菜单Id负数,issm是否需要说明
- if($this->isflow>0 && $isturn==1){
-
- //--autharstart--
- if(!in_array($status, array(1,5)) && $isreadbo){
- $arr[] = array('name'=>'追加说明...','lx'=>1,'issm'=>1,'optmenuid'=>-12);
- }
-
- $isjk = $this->isjiankongqx();//监控权限
-
- if(!in_array($status, array(1,5)) && ($ismy || $isjk)){
- $arr[] = array('name'=>'作废申请...','lx'=>16,'issm'=>1,'nup'=>1,'optmenuid'=>-16); //可直接作废
- if($isjk){
- $arr[] = array('name'=>'监控转办...','color'=>'blue','lx'=>3,'issm'=>1,'nup'=>1,'optmenuid'=>-18);
- //$arr[] = array('name'=>'撤回上一步处理','color'=>'#ff6600','lx'=>1,'issm'=>1,'nup'=>1,'optmenuid'=>-19);
- }
- }
-
- if(!in_array($status, array(1,2,5)) && ($ismy || $isjk)){
- $arr[] = array('name'=>'催办...','lx'=>13,'issm'=>1,'nup'=>1,'optmenuid'=>-13);
- if($this->option->getval('sms_iscb')=='1')$arr[] = array('name'=>'短信催办...','lx'=>17,'issm'=>1,'nup'=>1,'optmenuid'=>-17);
- }
- $chearr = $this->getflowinfor();
- if($chearr['ischeck']==1){
- $arr[] = array('name'=>'<b>去处理单据...</b>','color'=>getconfig('apptheme','#1389D3'),'lx'=>996);
- }
-
- $sdtv= $this->option->getval('sysreflowcheck');
- if($sdtv && ($ismy || $this->adminid==1) && $status==1 && (time()-strtotime($this->rs['applydt'])) < floatval($sdtv)*3600*24 ){
- $arr[] = array('name'=>'重新编辑在走审批','lx'=>19,'issm'=>1,'nup'=>1,'optmenuid'=>-19);
- }
-
- //--autharend--
- }
-
- if($status != 5 && arrvalue($this->moders,'ispl','1')=='1' && $isreadbo){
- $arr[] = array('name'=>lang('评论'),'lx'=>15,'nup'=>1,'issm'=>1,'optmenuid'=>-15);
- }
-
- //回执确认
- if($ismy && arrvalue($this->moders,'ishz')=='1' && $status==1){
- $smcont = $this->getsummary();
- $mid = (int)m('receipt')->getmou('id',"`uid`='$this->adminid' and `modenum`='$this->modenum' and `mid`='$this->id'");
- $namess = '回执确认设置';
- if($mid>0)$namess = '回执确认编辑';
- $arr[] = array('name'=>$namess,'djmid'=>$mid,'optnum'=>'receipt','lx'=>'18','optmenuid'=>-18,'modename'=>$this->modename,'smcont'=>$smcont);
- }
-
- //定时提醒设置
- if($isreadbo && arrvalue($this->moders,'istxset','1')=='1' && $this->modenum != 'remind' && !in_array($status, array(2,5))){
- $smcont = ''.$this->modename.':'.$this->getsummary();
- $mid = (int)m('remind')->getmou('id',"`uid`='$this->adminid' and `modenum`='$this->modenum' and `mid`='$this->id'");
- $namess = '+添加提醒设置';
- if($mid>0)$namess = '提醒设置编辑';
- $arr[] = array('name'=>$namess,'djmid'=>$mid,'smcont'=>$smcont,'issm'=>1,'optnum'=>'tixing','lx'=>'14','optmenuid'=>-14);
- }
-
-
-
- if($this->iseditqx()==1 && $isreadbo){
- $arr[] = array('name'=>lang('编辑'),'optnum'=>'edit','lx'=>'11','optmenuid'=>-11);
- }
-
- if($this->isdeleteqx()==1){
- $arr[] = array('name'=>lang('删除'),'color'=>'red','optnum'=>'del','nup'=>1,'issm'=>0,'islog'=>0,'statusvalue'=>9,'lx'=>'9','optmenuid'=>-9);
- }
-
- if(method_exists($this,'flowgetoptmenuarr')){
- $lbarr = $this->flowgetoptmenuarr($flx);
- if(is_array($lbarr))foreach($lbarr as $k=>$v)$arr[]=$v;
- }
-
- return $arr;
- }
-
- /**
- * 操作菜单操作
- */
- public function optmenu($czid, $zt, $sm='')
- {
- $msg = '';
- $cname = $this->rock->post('changename');
- $cnameid = $this->rock->post('changenameid');
- $cdate = $this->rock->post('changedate');
- $darr = array(
- 'cname' => $cname,
- 'cnameid' => $cnameid,
- 'cdate' => $cdate,
- 'sm' => $sm,
- );
- if($czid==-9){
- $msg = $this->deletebill($sm);
- }else if($czid==-10){
- $msg = $this->check($zt, $sm);
- if(contain($msg,'成功'))$msg = 'ok';
- }else if($czid==-12){
- $this->zhuijiaexplain($sm);
- }else if($czid==-13){
- $this->chuiban($sm);
- }else if($czid==-14){
- $msg = $this->addschedule($sm);
- }else if($czid==-15){
- $actname = $this->rock->post('name');
- $this->addlog(array(
- 'explain' => $sm,
- 'name' => $actname,
- ));
- //评论时提醒给相关人员
- $uids = '';
- if(isset($this->rs['uid'])){
- $uids= $this->rs['uid'];
- }else if(isset($this->rs['optid'])){
- $uids= $this->rs['optid'];
- }
- if($uids)$this->nexttodo($uids, 'pinglun', $sm, $actname);
- $this->gettodosend('boping','', $sm);
- }else if($czid==-16){
- $this->zuofeibill($sm); //撤销申请也就是作废了
- }else if($czid==-17){
- $msg = $this->smschuiban($sm); //短信催办
- }else if($czid==-18){
- $msg = $this->jiankongzb($darr);
- }else if($czid==-19){
- $msg = $this->reloadflow($sm); //重新编辑让可以审批
- }else{
- //--autharstart--
- $ors = m('flow_menu')->getone("`id`='$czid' and `setid`='$this->modeid' and `status`=1");
- if(!$ors)return '菜单不存在';
- $name = str_replace('.', '', $ors['name']);
- $actname = $ors['actname'];if(isempt($actname))$actname=$name;
- if($ors['islog']==1){
- if(!isempt($cname)){
- if(!isempt($sm))$sm.=',';
- $sm.=''.$name.':'.$cname.'';
- }
- $this->addlog(array(
- 'explain' => $sm,
- 'name' => $actname,
- 'statusname'=> $ors['statusname'],
- 'status' => $ors['statusvalue'],
- 'color' => $ors['statuscolor']
- ));
- }
- $barrs = array(
- 'cname' => $cname,
- 'sm' => $sm,
- 'cnameid' => $cnameid,
- 'cdate' => $cdate
- );
- if(method_exists($this,'flowoptmenubefore')){
- $msg = $this->flowoptmenubefore($ors, $barrs);
- if($msg)return $msg;
- }
- if($ors['type']==4 && !isempt($ors['fields'])){
- $fielsa = explode(',', $ors['fields']);
- $uarrs = array();
- foreach($fielsa as $fielsas){
- $fsdiwe = 'fields_'.$fielsas.'';
- if(isset($_REQUEST[$fsdiwe])){
- $uarrs[$fielsas]=$this->rock->post($fsdiwe);
- $barrs[$fsdiwe] = $uarrs[$fielsas];
- }
- }
- if($uarrs)$this->update($uarrs, $this->id);
- }
- $upgcont = $ors['upgcont'];
- //需要判断当前用户有没有编辑权限
- if(!isempt($upgcont)){
- $upgcont = $this->rock->jm->base64decode($upgcont);
- $upgcont = str_replace(array('{now}','{date}','{uid}','{adminid}','{admin}','{sm}','{cname}','{cnameid}'),array($this->rock->now,$this->rock->date, $this->adminid, $this->adminid, $this->adminname, $sm, $cname, $cnameid), $upgcont);
- $this->update($upgcont, $this->id);
- }
- $this->flowoptmenu($ors, $barrs);
- //--autharend--
- }
- if($msg=='')$msg='ok';
- return $msg;
- }
-
- /**
- * 监控人操作转办
- */
- public function jiankongzb($darr)
- {
- //--autharstart--
- $cnameid = $darr['cnameid'];
- $cname = $darr['cname'];
- if(isempt($cnameid))return '没有选择人员';
- $barr = $this->getflow();
- $nowcourseid = arrvalue($barr, 'nowcourseid');
- if(isempt($nowcourseid))return '此单据当前没审核步骤';
-
- $sm = '将['.$this->nowcourse['name'].']转办给:'.$cname.'';
- $this->addlog(array(
- 'explain' => $sm,
- 'name' => '监控转办',
- ));
-
- $this->addcheckname($nowcourseid, $cnameid, $cname, true, 7);
- $barr = $this->getflow();
- $this->getflowsave($barr, true);
- $this->nexttodo($barr['nowcheckid'], 'next', $sm);
-
- return 'ok';
- //--autharend--
- return $this->bd6('5peg5L!h5ZG8562!5o6I5peg5q2k5Yqf6IO9');
- }
-
- /**
- * 单据展示条件搜索
- */
- public function billwhere($uid, $lx)
- {
- $arr['table'] = $this->mtable;
- $arr['tableleft'] = ''; //左关联table
- $arr['fields'] = '';
- $arr['order'] = '';
- $arr['group'] = '';
- $arr['keywhere']= '';
- $arr['asqom'] = ''; //主表别名
- $arr['onlywhere'] = ''; //只要我的一个搜索
- $arr['companywhere']= ''; //多单位显示搜索
- $this->atype = $lx;
- $nas = $this->flowbillwhere($uid, $lx);
- $inwhere = '';
- if(substr($lx,0,5)=='grant'){
- $inwhere = $this->viewmodel->viewwhere($this->moders, $this->adminid, $this->flowviewufieds, 1);
- }
- //抄送的
- if($lx=='chaos'){
- $inwhere = "and {asqom}`id` in(select `mid` from `[Q]flow_chao` where `table`='{$this->mtable}' and ".$this->rock->dbinstr('csnameid', $this->adminid).")";
- }
- //经我处理
- if($lx=='mychuli'){
- $inwhere = "and {asqom}`id` in(select bill.`mid` from `[Q]flow_bill` as `bill` where bill.`modeid`='{$this->modeid}' and ".$this->rock->dbinstr('bill.`allcheckid`', $this->adminid).")";
- }
- //待办
- if($lx=='daib'){
- $inwhere = "and {asqom}`id` in(select bill.`mid` from `[Q]flow_bill` as `bill` where bill.`modeid`='{$this->modeid}' and `status` = 0 and ".$this->rock->dbinstr('bill.`nowcheckid`', $this->adminid).")";
- }
- $_wehs = '';
- if(is_array($nas)){
- if(isset($nas['where']))$_wehs = $nas['where'];
- $ftears = explode(',','asqom,order,fields,fieldsleft,table,group,companywhere,onlywhere,keywhere,tableleft');
- foreach($ftears as $fid)if(isset($nas[$fid]))$arr[$fid] = $nas[$fid];
- }else{
- $_wehs = $nas;
- }
- $fwhere = $this->getflowwhere($uid, $lx);//流程模块上条件
- $path = ''.P.'/flow/page/rock_page_'.$this->modenum.'.php';
-
- $table = $arr['table'];
- $temsao = 0;
- if(!contain($table, ' ') && $this->isflow>0){
- $arr['table'] = '`[Q]'.$this->mtable.'` a left join `[Q]flow_bill` b on a.`id`=b.`mid` and b.`table`=\''.$this->mtable.'\'';
- if(!isempt($arr['tableleft']))$arr['table'].=' left join '.$arr['tableleft'].'';
- $arr['asqom'] = 'a.';
- $arr['fields']= 'a.*,b.`uname` as base_name,b.`udeptname` as base_deptname,b.`sericnum`,b.`nowcheckname`';
- if(isset($arr['fieldsleft']) && $arr['fieldsleft'])$arr['fields'].=','.$arr['fieldsleft'].'';
- if($arr['order']=='')$arr['order'] = 'a.`optdt` desc'; //默认操作时间倒序
- $temsao = 1;
- if($this->defaultorder){
- $defa = explode(',', $this->defaultorder);
- $desc = arrvalue($defa, 1, 'desc');
- $arr['order'] = 'a.`'.$defa[0].'` '.$desc.'';
- }
- }
-
- if(isempt($arr['order'])){
- $arr['order'] = '{asqom}`id` desc';//没有流程默认id倒序
- if($this->defaultorder){
- $defa = explode(',', $this->defaultorder);
- $desc = arrvalue($defa, 1, 'desc');
- $arr['order'] = '{asqom}`'.$defa[0].'` '.$desc.'';
- }
- }
-
- if(isempt($fwhere) && isempt($inwhere) && $this->moders['isscl']>0){
- $fwhere = 'and 1=2';
- }
- $where = $inwhere;
- $wherestr = $this->moders['where'];
- if(!isempt($wherestr)){
- $wherestr = $this->rock->covexec($wherestr);
- $where .= ' and {asqom}'.$wherestr;
- }
-
- if($fwhere!='')$where .= ' '.$fwhere;
- if($_wehs!='')$where .= ' '.$_wehs;
- $highwhere = $this->gethighwhere();//高级搜索
- $allfields = array();
- //关键词搜索
- $key = $this->rock->post('key');
- $pnum = $this->rock->post('pnum');
- $status = $this->rock->post('keystatus');
- $ztfields = arrvalue($nas, 'ztfields', 'status');
-
- //新加搜索2021-06-07,支持子表搜索
- $xhlikea = array('like','=','>=','<=', 'not like');
- $xhfields = $this->rock->post('xhfields');
- $xhlike = (int)$this->rock->post('xhlike','0');
- $xhkeygj = $this->rock->jm->base64decode($this->rock->post('xhkeygj'));
- if(!isempt($xhkeygj) && $xhfields){
- if(substr($xhfields,0,2)=='zb'){
- $xu = substr($xhfields,2,1);
- $zbasr = explode(',', $this->moders['tables']);
- $zbts = arrvalue($zbasr,$xu);
- $xhfields = substr($xhfields,4);
- $wher1 = "`$xhfields` ".$xhlikea[$xhlike]."";
- if($xhlike==0 || $xhlike==4)$wher1.=" '%".$xhkeygj."%'";
- if($xhlike==1 || $xhlike==2 || $xhlike==3)$wher1.=" '$xhkeygj'";
- $wher1 = " and {asqom}`id` in(select `mid` from `[Q]".$zbts."` where ".$wher1.")";
- $where.= $wher1;
- }else{
- $wher1 = " and {asqom}`$xhfields` ".$xhlikea[$xhlike]."";
- if($xhlike==0 || $xhlike==4)$wher1.=" '%".$xhkeygj."%'";
- if($xhlike==1 || $xhlike==2 || $xhlike==3)$wher1.=" '$xhkeygj'";
- $where.= $wher1;
- }
- }
-
- if(!isempt($status))$where .= ' and {asqom}`'.$ztfields.'`='.$status.'';
- if(!isempt($key) && isempt($arr['keywhere'])){
- $check = c('check');
- $allfields = $this->db->getallfields('[Q]'.$this->mtable.'');
- $_kearr = array();
-
- //关键词是日期
- if($check->isdate($key) || $check->ismonth($key)){
- $skeay = array('date','datetime','month');
- foreach($this->fieldsarra as $k=>$rs){
- $flx = $rs['fieldstype'];
- $fid = $rs['fields'];
- if($rs['issou']==1 && in_array($flx, $skeay) && in_array($fid, $allfields)){
- if($check->isdate($key)){
- if($flx=='date')$_kearr[] = "{asqom}`".$fid."`='$key'";
- if($flx=='datetime')$_kearr[] = "{asqom}`".$fid."` like '$key%'";
- if($flx=='month')$_kearr[] = "{asqom}`".$fid."`='".substr($key,0,7)."'";
- if($temsao==1){
- $_kearr[] = "b.`applydt`='$key'";
- }
- }
- if($check->ismonth($key)){
- if($flx=='month'){
- $_kearr[] = "{asqom}`".$fid."`='$key'";
- }else{
- $_kearr[] = "{asqom}`".$fid."` like '$key%'";
- }
- if($temsao==1){
- $_kearr[] = "b.`applydt` like '$key%'";
- }
- }
- }
- }
- }
- if(!$_kearr){
- $skeay = array('text','textarea','htmlediter','changeuser','changeusercheck','changedept','changedeptusercheck','selectdatafalse','selectdatatrue','num');
- $xiakk = array('rockcombo','select');
- foreach($this->fieldsarra as $k=>$rs){
- if($rs['issou']==1 && in_array($rs['fields'], $allfields) && substr($rs['fields'],-2) != 'dt'){
- if(in_array($rs['fieldstype'], $skeay))$_kearr[] = "{asqom}`".$rs['fields']."` like '%".$key."%'";
- //if(in_array($rs['fieldstype'], $xiakk))$_kearr[] = "{asqom}`".$rs['fields']."` = '".$key."'";
- }
- }
-
- if($temsao==1){
- $_kearr[] = "b.`uname` like '%".$key."%'";
- $_kearr[] = "b.`udeptname` like '%".$key."%'";
- $_kearr[] = "b.`sericnum` = '$key'";
- $_kearr[] = "b.`nowcheckname` = '$key'"; //搜索当前处理人
- }
-
- //其他or字段条件格式:name@1,title
- if(isset($nas['orlikefields'])){
- $owhee = explode(',', $nas['orlikefields']);
- foreach($owhee as $owhees){
- $_owhees = explode('@', $owhees);
- $sle = arrvalue($_owhees, 1);
- if($sle=='1'){
- $_kearr[] = "".$_owhees[0]." ='$key'";
- }else{
- $_kearr[] = "".$_owhees[0]." like '%".$key."%'";
- }
- }
- }
- }
- if($_kearr && $arr['onlywhere']=='')$arr['keywhere'] = "and (".join(' or ',$_kearr).")";
- }
-
- if(!isempt($arr['companywhere']) && getconfig('companymode'))$where .= ' '.$arr['companywhere'];
- if(!isempt($arr['onlywhere']))$where .= ' '.$arr['onlywhere'];
- if(!isempt($arr['keywhere']))$where .= ' '.$arr['keywhere'];
-
- if($highwhere!='')$where .= ' '.$highwhere;
-
-
-
- $where = str_replace('{asqom}', $arr['asqom'], $where);
- $arr['order'] = str_replace('{asqom}', $arr['asqom'], $arr['order']);
- $where = str_replace('[A]', $arr['asqom'], $where);
-
-
- //字段显示
- $fields = $arr['fields'];
- if($this->flowfieldstype==1 && (isempt($fields) || $fields=='*') && $this->moders['isscl']>0){
- if(!$allfields)$allfields = $this->db->getallfields('[Q]'.$this->mtable.'');
- $fields = '{asqom}`id`';
- $odlvs = $this->option->getval('columns_'.$this->modenum.'_'.$pnum.'');
- if(isempt($odlvs)){
- foreach($this->fieldsarra as $k=>$rs){
- if($rs['islb']==1 && in_array($rs['fields'],$allfields)){
- $fields.=',{asqom}`'.$rs['fields'].'`';
- }
- }
- }else{
- $odlvsa = explode(',', $odlvs);
- foreach($odlvsa as $odlvs1){
- if(in_array($odlvs1, $allfields)){
- $fields.=',{asqom}`'.$odlvs1.'`';
- }
- }
- }
- if($this->isflow>0){
- if(!contain($fields,'`status`'))$fields.=',{asqom}`status`';
- }
- $fields = str_replace('{asqom}', $arr['asqom'], $fields);
- $arr['fields'] = $fields;
- }
-
- //字段添加上``
- $fields = $arr['fields'];
- if(!isempt($fields) && $fields!='*'){
- $fieldsa = explode(',', $fields);
- $fieldss = '';
- foreach($fieldsa as $fieldsas){
- if(contain($fieldsas,'`') || contain($fieldsas,'.') || contain($fieldsas,' ') || contain($fieldsas,'(')){
- $fieldss.=','.$fieldsas.'';
- }else{
- $fieldss.=',`'.$fieldsas.'`';
- }
- }
- $arr['fields'] = substr($fieldss, 1);
- }
- $arr['where'] = str_replace('{asqom}','', $where);//替换一下
- return $arr;
- }
-
- /**
- * 获取高级搜索条件
- */
- public function gethighwhere()
- {
- $s = '';
- //--autharstart--
- foreach($this->fieldsarra as $k=>$rs){
- if($rs['issou']!=1)continue;
- $type = $rs['fieldstype'];
- $fields = $rs['fields'];
- $val = $this->rock->post('soufields_'.$fields.'');
- if($type=='date' || $type=='datetime' || $type=='number' || substr($fields,-2)=='dt'){
- $val1 = $this->rock->post('soufields_'.$fields.'_start');
- $val2 = $this->rock->post('soufields_'.$fields.'_end');
- $val3 = $this->rock->post('soufields_'.$fields.'_equal');
- if($type!='number'){
- if(!isempt($val1))$val1 = "'$val1'";
- if(!isempt($val3))$val3 = "'$val3'";
- if(!isempt($val2)){
- if($type=='datetime')$val2 = "$val2 23:59:59";
- $val2 = "'$val2'";
- }
- }
- if(!isempt($val1))$s.=" and {asqom}`$fields`>=".$val1."";
- if(!isempt($val2))$s.=" and {asqom}`$fields`<=".$val2."";
- if(!isempt($val3))$s.=" and {asqom}`$fields`=".$val3."";
- }else{
- if(isempt($val))continue;
- if($type=='select' || $type=='radio' || $type=='rockcombo'){
- $s.=" and {asqom}`$fields`='$val'";
- }else if($type=='month'){
- $s.=" and {asqom}`$fields` like '$val%'";
- }else{
- $s.=" and {asqom}`$fields` like '%$val%'";
- }
- }
- }
- $ofied = $this->rock->post('search_fields');
- $ofval = $this->rock->post('search_value');
- if(!isempt($ofied) && !isempt($ofval)){
- $ofval = $this->adminmodel->gjoin($ofval,'', 'all');
- $s = " and {asqom}`$ofied` in($ofval)";
- }
- //--autharend--
- return $s;
- }
-
- /**
- * 根据编号获取对应条件flow_where
- */
- public function getflowwhere($uid, $num)
- {
- $where = '';
- $rs = $this->wheremodel->getone("`setid`='$this->modeid' and `num`='$num'");
- if(!$rs)return $where;
- $where = $this->wheremodel->getwherestr($rs, $uid, $this->flowviewufieds);
- return $where;
- }
-
- /**
- * 根据流程模块条件读取记录和统计
- */
- public function getflowrows($uid, $lx, $limit=5, $swher='')
- {
- $nas = $this->billwhere($uid, $lx);
- $table = $nas['table'];
- if(!contain($table,' '))$table='[Q]'.$table.'';
- if(isempt($nas['fields']))$nas['fields'] = '*';
- $swher = str_replace('{asqom}',$nas['asqom'], $swher);
- $where = '1=1 '.$nas['where'].' '.$swher.'';
- if($limit==0)return $this->db->rows($table, $where );
- $rows = $this->db->getrows($table, $where , $nas['fields'], $nas['order'], $limit);
- foreach($rows as $k=>$rs){
- $rows[$k] = $this->flowrsreplace($rs, 2);
- }
- return $rows;
- }
-
- /**
- * 读取要提醒的单据
- */
- public function gettodorows($whereid)
- {
- $where = $this->wheremodel->getwherestr($whereid, $this->adminid, $this->flowviewufieds);
- $wherestr = $this->moders['where'];
- if(!isempt($wherestr)){
- $wherestr = $this->rock->covexec($wherestr);
- $where .= ' and '.$wherestr;
- }
- $where = str_replace('{asqom}','', $where);
- $rows = $this->getall('2=2 '.$where.'');
- foreach($rows as $k=>$rs){
- $rows[$k] = $this->flowrsreplace($rs, 1);
- }
- return $rows;
- }
-
-
-
- /**
- * 打印导出
- */
- public function printexecl($event)
- {
- $arr['moders'] = $this->moders;
- $arr['fields'] = $this->getfields();
- $cell = 1;
- foreach($arr['fields'] as $k=>$v)$cell++;
- $arr['cell'] = $cell;
-
- $where = '1=1';
- $str1 = $this->moders['where'];
- if(!isempt($str1)){
- $str1 = $this->rock->covexec($str1);
- $where = $str1;
- }
-
- $vwhere = $this->viewmodel->viewwhere($this->moders, $this->adminid);
- $rows = $this->getrows(''.$where.' '.$vwhere.'', '*', 'id desc', 100);
- $arr['rows'] = $this->flowprintrows($rows);
- $arr['count'] = $this->db->count;
- return $arr;
- }
-
- /**
- * 获取所有多行子表数据
- * $lx=0编辑时读取,1展示时读取
- */
- public function getsuballdata($lx=0, $mid=0)
- {
- $tabless = $this->moders['tables'];
- $subdata = array();
- if($mid==0)$mid = $this->id;
- if(!isempt($tabless)){
- $tablessa = explode(',', $tabless);
- $namessa = explode(',', $this->moders['names']);
- $tabless1 = '['.str_replace(',','],[', $tabless).']';
- foreach($tablessa as $zbx=>$tables){
- $cis = substr_count($tabless1, '['.$tables.']');
- $whes = '';
- if($cis>1)$whes=' and `sslx`='.$zbx.'';
- $data = m($tables)->getall('mid='.$mid.''.$whes.'','*','`sort`');
- $data = $this->flowsubdata($data, $lx, $zbx);
- if($lx == 0){
- $subdata['subdata'.$zbx.''] = $data;
- }else{
- $subdata[$zbx] = array(
- 'data' => $data,
- 'fields'=> 'subdata'.$zbx.'',
- 'name' => $this->rock->arrvalue($namessa, $zbx)
- );
- }
- }
- }
- return $subdata;
- }
-
-
- /**
- * 读取通知
- * $act 当前动作有(boturn,boedit,bochang,bodel)
- */
- private $gettodolistarr = null;
- public function gettodolist($act)
- {
- if(is_array($act))return $act;
- if($this->gettodolistarr === null){
- $rows = $this->todomodel->getrows("`setid`='".$this->modeid."' and `status`=1");
- $barr = array();
- foreach($rows as $k=>$rs){
- $whereid = (int)$rs['whereid'];
- if($whereid > 0){
- $bo = $this->wheremanzhu($whereid);
- if(!$bo)continue;
- }
- $barr[] = $rs;
- }
- $this->gettodolistarr = $barr;
- }else{
- $barr = $this->gettodolistarr;
- }
- $garr = array();
- if($barr)foreach($barr as $k=>$rs){
- if(arrvalue($rs,$act)=='1')$garr[] = $rs;
- }
- return $garr;
- }
-
- /**
- * 发送设置的通知
- */
- public function gettodosend($act, $actname='',$sm='', $courseid=0, $conts='')
- {
- $barr = $this->gettodolist($act);
- if(!$barr)return;
- $changearr = array('boturn'=>'提交','boedit'=>'编辑','bozhuan'=>'转办','bochang'=>'修改字段','bodel'=>'删除','bozuofei'=>'作废','botong'=>'处理同意','bobutong'=>'处理不同意','bofinish'=>'全部处理完成','bozhui'=>'追加说明','boping'=>'评论','bohuiz'=>'回执确认');
- if($actname=='' && is_string($act))$actname = arrvalue($changearr, $act);
- if(isempt($actname))return;
- $cheo = c('check');
- foreach($barr as $k=>$rs){
- $receid = $rs['receid'];
-
- if($act=='botong' || $act=='bobutong'){
- $changewe = $rs['changecourse'];
- if(!isempt($changewe) && !contain(','.$changewe.',',','.$courseid.','))continue;
- }
-
- if($rs['toturn']==1)$receid.=','.$this->uid.''; //通知给提交人
- if(arrvalue($rs,'tosuper')=='1'){
- $supar = $this->adminmodel->getsuperman($this->uid);
- $shnej = arrvalue($supar, 0);
- if(!isempt($shnej))$receid.=','.$shnej.''; //通知给直属上级,没有就读取部门负责人
- }
- if($rs['tocourse']==1 && $this->billrs){
- $allcheckid = $this->billrs['allcheckid'];
- if(!isempt($allcheckid))$receid.=','.$allcheckid.''; //通知流程所有参与人
- }
- //其他字段
- $todofields = $rs['todofields'];
- if(!isempt($todofields)){
- $toad = explode(',', $todofields);
- foreach($toad as $toads){
- $ttv = arrvalue($this->rs, $toads);
- if(!isempt($ttv) && $cheo->isinnumber($ttv))$receid.=','.$ttv.'';
- }
- }
- if(isempt($receid))continue;
- if(substr($receid,0,1)==',')$receid = substr($receid, 1);
- $cont = $rs['summary'];
- if(isempt($cont))$cont = $conts;
- if(isempt($cont)){
- $cont = ''.$this->adminname.''.$actname.'['.$this->modename.',单号:'.$this->sericnum.']';
- if($sm!='')$cont.=',说明:'.$sm.'';
- }
- $this->push($receid, '', $cont, $this->rock->repempt($rs['name']));
- }
- }
-
- /**
- * 根据编号发送通知
- */
- public function numtodosend($num, $actname='',$sm='')
- {
- $rows = $this->todomodel->getrows("`setid`='".$this->modeid."' and `num`='$num' and `status`=1");
- if(!$rows)return;
- $this->gettodosend($rows, $actname, $sm);
- }
-
-
- /**
- * 统计报表
- */
- public function flowtotal($fields='', $type='')
- {
- if($fields=='')$fields = $this->rock->post('total_fields');
- if($type=='')$type = $this->rock->post('total_type','jls');
- $typea = explode('|', $type);
- $typefields = '';
- $type = $typea[0]; $typefields = arrvalue($typea, 1);
- $rowa = array();
- $rowa[] = array(
- 'name' => '暂无数据',
- 'value' => 0,
- 'bili' => ''
- );
- $tofiels= 'count(1)';
- if($type=='sum')$tofiels = 'sum([A]`'.$typefields.'`)';
- if($type=='avg')$tofiels = 'avg([A]`'.$typefields.'`)';
- $atype = $this->rock->post('atype');
- $table = '[Q]'.$this->mtable.'';
-
- $narr = $this->billwhere($this->adminid, $atype);
- $where = $narr['where'];
- $table = $narr['table'];
- if(!contain($table,' '))$table = '[Q]'.$table.'';
-
- $gwhere = $this->rock->post('where');
- if(!isempt($gwhere)){
- $gwhere = $this->rock->jm->uncrypt($this->rock->iconvsql($gwhere));
- $where .= ' '.$gwhere.'';
- }
-
- $sql = 'select '.$fields.' as `name`,'.$tofiels.' as value from '.$table.' where 1=1 '.$where.' group by '.$fields.'';
- $sql = str_replace('[A]', $narr['asqom'], $sql);
-
-
- $rows = $this->db->getall($sql);
- $total = 0;
- if($rows){
- foreach($rows as $k=>$rs)$total+=floatval($rs['value']);
- if($total>0)foreach($rows as $k=>$rs){
- $rows[$k]['bili'] = $this->rock->number($rs['value']*100/$total).'%';
- }
- if($type!='avg' && count($rows)>1)$rows[] = array('name' => '合计','value' => $total,'bili' => '');
- }else{
- $rows = $rowa;
- }
- return $rows;
- }
-
-
-
- /**
- * 回执确认
- */
- public function receiptcheck($hid, $sm)
- {
- //--autharstart--
- $hrs = m('receipt')->getone("`id`='$hid' and `modenum`='$this->modenum' and `mid`='$this->id'");
- if(!$hrs)return;
- $receid = $hrs['receid'];
- $receids = $hrs['receids'];
- if(isempt($receids))$receids = '';
- $uid = $this->adminid;
- if(!contain(','.$receid.',', ','.$uid .','))return;
-
- $reaa = explode(',', $receids);
- if(!$reaa)$reaa = array();
-
- if(!in_array($uid, $reaa)){
- if($receids!='')$receids.=',';
- $receids.=''.$uid.'';
- }
-
- $reaa = explode(',', $receids);
- $ushuy = count($reaa);
- $receids= join(',', $reaa);
-
- m('receipt')->update(array(
- 'receids' => $receids,
- 'ushuy' => $ushuy,
- ), $hid);
-
- $this->addlog(array(
- 'explain' => $sm,
- 'name' => '回执确认'
- ));
-
- //通知给提交人
- $this->rs = $hrs;
- $this->nexttodo($hrs['uid'],'receipt', $sm, '回执确认');
- //--autharend--
- return 'ok';
- }
-
-
- /**
- * 获取简单列表数据,返回table表格
- */
- public function getrowstable($atype, $where, $limit=100,$fields='')
- {
- $rows = $this->getflowrows($this->adminid,$atype,$limit,$where);
- $headstr = '@xuhaos,,center';
- foreach($this->fieldsarra as $k=>$rs){
- $bo = false;
- if(!$fields && $rs['islb']==1 && $rs['iszb']=='0')$bo = true;
- if($fields && contain(','.$fields.',',','.$rs['fields'].','))$bo = true;
- if($bo)$headstr.='@'.$rs['fields'].','.$rs['name'].'';
- }
- if($this->isflow>0){
- $headstr.='@statustext,状态';
- if(is_array($rows))foreach($rows as $k=>$rs){
- $rows[$k]['statustext'] = $this->getstatusstr($rs);
- }
- }
- $cont = c('html')->createrows($rows, substr($headstr, 1),'#cccccc','noborder');
- return $cont;
- }
-
- /**
- * 翻译用
- */
- public function lang($ky)
- {
- return lang($ky,'mode_'.$this->modenum.'');
- }
-
- /**
- * 禁看处理
- */
- public function viewjinfields($rows)
- {
- if(!$rows)return $rows;
- //--autharstart--
- $jinkfarr = $this->viewmodel->viewjinfields($this->moders, $this->adminid, $this->flowviewufieds);
- if($jinkfarr && is_array($jinkfarr)){
- $wherear= array();
- $ids = '';
- foreach($rows as $k=>$rs){
- if(!isset($rs['id']))return $rows;//没有id字段是无法判断
- $ids.=','.$rs['id'].'';
- }
- $ids = substr($ids, 1);
- foreach($jinkfarr as $k1=>$rs1){
- $wherestr = arrvalue($rs1,'wherestr');
- $wherestr2 = arrvalue($rs1,'wherestr2');
- $fieldstr = arrvalue($rs1,'fieldstr');
- if(isempt($fieldstr))continue;
- if($wherestr=='' && $wherestr2=='')continue;
- if($wherestr2!=''){
- if($wherestr!='')$wherestr.=' and ';
- $wherestr.=$wherestr2;
- }
- $wherestr= str_replace('{asqom}','', $wherestr);
- $jinrows = $this->getall('`id` in('.$ids.') and '.$wherestr.'','id');
- if(!$jinrows)continue;
- $jinrow = array();
- foreach($jinrows as $k2=>$rs2)$jinrow[]=$rs2['id'];
- $jinkfarr[$k1]['jinrows'] = $jinrow;
- }
-
- //隐藏字段设置
- foreach($rows as $k=>$rs){
- $id = $rs['id'];
- if(arrvalue($rs, $this->flowviewufieds)==$this->adminid)continue;//我自己都可以看
- foreach($jinkfarr as $k1=>$rs1){
- $fieldstr = arrvalue($rs1,'fieldstr');
- $jinrows = arrvalue($rs1,'jinrows');
- if($jinrows){
- $farr = explode(',', $fieldstr);
- if(in_array($id, $jinrows)){
- foreach($farr as $fid){
- if(isset($rs[$fid]))$rows[$k][$fid]='';//清空
- }
- }
- }
- }
- }
- }
- //--autharend--
- return $rows;
- }
-
- /**
- * 判断是否导出子表处理
- */
- public function daochusubtable($rows)
- {
- //--autharstart--
- if(!$this->daochubo || !$rows)return $rows;
- $excelsubtab = $this->rock->post('excelsubtab');
- if(isempt($excelsubtab) || isempt($this->moders['tables']))return $rows;
- $suba = explode(',', $excelsubtab);
-
- foreach($rows as $k=>$rs){
- if(!isset($rs['id']))return $rows;
- $subdata = $this->getsuballdata(1, $rs['id']);
- foreach($suba as $zb){
- $shuju = $subdata[$zb]['data'];
- if($shuju){
- $this->subsubdatastyle = 'print';
- $rows[$k]['sub_table_'.$zb.''] = $this->getsubdata($zb, $shuju);
- }else{
- $rows[$k]['sub_table_'.$zb.''] = '';
- }
- }
- }
- //--autharend--
- return $rows;
- }
-
-
- }
|