flow.php 119 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702
  1. <?php
  2. /**
  3. * 来自:信呼开发团队
  4. * 作者:磐石(rainrock)
  5. * 网址:http://www.rockoa.com/
  6. * 系统的核心文件之一,处理工作流程模块的。
  7. */
  8. class flowModel extends Model
  9. {
  10. public $modenum; //当前模块编号
  11. public $editcont= ''; //修改的记录
  12. public $id = 0; //当前单据ID
  13. public $moders; //当前模块数组
  14. public $modeid; //当前模块Id
  15. public $modename; //当前模块名称
  16. public $sericnum; //当前单据单号
  17. public $billrs = array(); //当前单据流程信息
  18. public $rs = array(); //当前单据记录信息
  19. public $urs = array(); //当前单据对应用户
  20. public $drs = array(); //当前单据对应用户
  21. public $fieldsarr = array(); //主表元素字段数组
  22. public $fieldsarra = array(); //元素数组
  23. public $mwhere;
  24. public $mtable; //当前模块对应表
  25. public $uname; //当前单据对应用户姓名
  26. public $uid = 0; //当前单据对应用户Id
  27. public $optid = 0; //当前当街对应操作用Id,如提交人Id
  28. public $isflow = 0; //当前模块是否有流程审核步骤
  29. public $ismobile= 0; //是否移动的页面请求的
  30. public $minwidth= 100; //录入页面子表最小宽度
  31. public $inputwidth= 0; //录入页面宽度
  32. public $atype = '';
  33. public $daochubo= false; //是否导出操作
  34. public $companyid= 1; //默认单位Id
  35. //当初始化模块后调用
  36. protected function flowinit(){}
  37. //当初始化单据调用
  38. protected function flowchangedata(){}
  39. //当触发通知时处理
  40. protected function flowchangetodo(){}
  41. //删除单据时调用,$sm删除说明
  42. protected function flowdeletebill($sm){}
  43. //作废单据时调用,$sm作废说明
  44. protected function flowzuofeibill($sm){}
  45. //提交时调用
  46. protected function flowsubmit($na, $sm){}
  47. //添加日志记录调用$arr 添加数组
  48. protected function flowaddlog($arr){}
  49. protected function flowdatalog($arr){}
  50. //审核之前调用$zt 状态, $sm说明
  51. protected function flowcheckbefore(){}
  52. //审核完成后调用
  53. protected function flowcheckafter($zt, $sm){}
  54. //流程全部完成后调用
  55. protected function flowcheckfinsh($zt){}
  56. protected function flowgetfields($lx){}
  57. protected function flowgetoptmenu($opt){}
  58. //自定义审核人重新的方法$num 步骤单号
  59. protected function flowcheckname($num){}
  60. //审核步骤根据$num 编号判断是否需要审核
  61. protected function flowcoursejudge($num){}
  62. //操作单据
  63. protected function flowoptmenu($ors, $crs){}
  64. //自定义是否可查看本单据
  65. protected function flowisreadqx(){return false;}
  66. //自定义是否可以删除权限,如返回0不能删除,1可删除,其他值无效
  67. protected function flowisdeleteqx(){return false;}
  68. //已弃用
  69. protected function flowprintrows($r){return $r;}
  70. //子表数据替换处理$lx=0编辑时,1展示时
  71. protected function flowsubdata($r, $lx=0){return $r;}
  72. //默认推送格式从写
  73. protected function flownexttodo($type){return false;}
  74. //单据判断条件从写$lx类型,$uid用户Id
  75. protected function flowbillwhere($lx, $uid){return '';}
  76. protected $flowweixinarr = array();
  77. protected $flowviewufieds = 'uid';
  78. //关联单位id字段默认是comid
  79. protected $flowcompanyidfieds = 'comid';
  80. protected $flowfieldstype = 0; //获取字段类型0默认*,1根据字段元素设置得到字段
  81. //初始化单据可替换其他属性,$lx,0默认,1详情展示,2列表显示,3打印页,4外部详情页
  82. public function flowrsreplace($rs){return $rs;}
  83. //这个是移动端列表中使用
  84. public function flowrsreplace_we($row, $rs){return $row;}
  85. //通用移动端列表搜索
  86. public function flowwesearchdata($lx){return array();}
  87. //编辑的时候替换
  88. protected function flowrsreplaceedit($rs){return $rs;}
  89. //默认状态1时可以就算审核通过,默认是1
  90. protected $flowstatusarr = array(1);
  91. //子表样式,可以改成print打印
  92. protected $subsubdatastyle = '';
  93. //关联其他模块
  94. protected $wherejoin = array();
  95. //默认排序如:id,desc
  96. public $defaultorder = '';
  97. //是否可编辑别人单据
  98. public $floweditother = false;
  99. //详情边框元素
  100. public $xiangbordercolor = '';
  101. public function echomsg($msg)
  102. {
  103. if(!isajax())exit($msg);
  104. showreturn('', $msg, 201);
  105. exit();
  106. }
  107. //字段处理$farr字段,$lx=0pc,1移动
  108. public function flowfieldarr($farr, $lx){return $farr;}
  109. //自定义录入模版$lx=0pc,1移动
  110. public function flowinputtpl($cont, $lx){return $cont;}
  111. public function flowviewtpl($cont, $lx){return $cont;}
  112. //在线编辑单据下附件
  113. public function floweditoffice($frs, $ofrs){}
  114. /**
  115. * 初始化流程信息
  116. */
  117. public function initdata($num, $id=null)
  118. {
  119. if(is_array($num)){
  120. $this->moders= $num;
  121. }else{
  122. $this->moders = m('flow_set')->getone(is_numeric($num) ? $num : "`num`='$num'");
  123. if(!$this->moders)$this->echomsg('模块['.$num.']不存在,请到[流程模块列表]下添加');
  124. }
  125. $this->daochubo = ($this->rock->post('execldown')=='true') ? true :false;
  126. $table = $this->moders['table'];
  127. $this->modeid = $this->moders['id'];
  128. $this->modenum = $this->moders['num'];
  129. $this->modename = $this->moders['name'];
  130. $this->isflow = (int)$this->moders['isflow'];
  131. $this->settable($table);
  132. $this->mtable = $table;
  133. $this->viewmodel = m('view');
  134. $this->chaomodel = m('flow_chao');
  135. $this->billmodel = m('flow_bill');
  136. $this->todomodel = m('flow_todo');
  137. $this->todosmodel = m('flowtodo');
  138. $this->flogmodel = m('flow_log');
  139. $this->checksmodel = m('flow_checks');
  140. $this->cnamemodel = m('flowcname');
  141. $this->wheremodel = m('where');
  142. $this->adminmodel = m('admin');
  143. $this->remindmodel = m('remind'); //单据提醒表
  144. $this->option = m('option');
  145. $this->companyid = $this->adminmodel->getcompanyid();
  146. $this->tfieldsarra(); //初始化录入的表单元素
  147. $this->mwhere = "`table`='$this->mtable' and `mid`=-1";
  148. if(!$this->defaultorder){
  149. $sortdir = arrvalue($this->moders, 'sortdir');
  150. if(!isempt($sortdir))$this->defaultorder = str_replace(' ',',', $sortdir);
  151. }
  152. $this->flowinit();
  153. if($id==null)return $this;
  154. $this->loaddata($id, true);
  155. return $this;
  156. }
  157. private function tfieldsarra()
  158. {
  159. $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`');
  160. $this->fieldsarr = array();
  161. if($rows)foreach($rows as $k=>$rs){
  162. if($rs['islu']==1)$this->fieldsarr[] = $rs;
  163. }
  164. $this->fieldsarra = $rows;
  165. }
  166. //录入页上的标题
  167. public function inputtitle()
  168. {
  169. return $this->moders['name'];
  170. }
  171. /**
  172. * 列表上要搜索的的,此方法仅用到在:webmain/flow/input/inputAction.php 行607上返回,模块接口可重写这个方法
  173. */
  174. public function flowsearchfields()
  175. {
  176. $arr = array();
  177. if($this->isflow>0){
  178. $arr[] = array('name'=>'申请人...','fields'=>'uid');
  179. $arr[] = array('name'=>'提交人...','fields'=>'optid');
  180. }
  181. return $arr;
  182. }
  183. /**
  184. * 初始化单据数据
  185. * id 单据Id $ispd 是否判断有查看权限
  186. */
  187. public function loaddata($id, $ispd=true)
  188. {
  189. $this->id = (int)$id;
  190. $this->mwhere = "`table`='$this->mtable' and `mid`='$id'";
  191. //防止同主表模块串数据
  192. $swhere = "`id`='$id'";
  193. $wherestr = $this->moders['where'];
  194. if(!isempt($wherestr)){
  195. $wherestr = $this->rock->covexec($wherestr);
  196. $swhere .= ' and '.$wherestr;
  197. }
  198. $this->rs = $this->getone($swhere);
  199. $this->uname = '';
  200. if(!$this->rs)$this->echomsg('数据记录不存在了');
  201. $this->rs['base_name'] = '';
  202. $this->rs['base_deptname'] = '';
  203. if(isset($this->rs['uid']))$this->uid = $this->rs['uid'];
  204. if(isset($this->rs['comid']))$this->companyid = $this->rs['comid'];
  205. if(!isset($this->rs['applydt']))$this->rs['applydt'] = '';
  206. if(!isset($this->rs['status']))$this->rs['status'] = 1;
  207. $uisfield = property_exists($this, 'uidfields') ? $this->uidfields : 'optid';
  208. if($this->uid==0 && isset($this->rs[$uisfield]))$this->uid = $this->rs[$uisfield];
  209. $this->optid = isset($this->rs['optid']) ? $this->rs['optid'] : $this->uid;
  210. $this->urs = $this->adminmodel->getone($this->uid,'id,name,user,deptid,deptids,deptname,deptallname,face,ranking,superid,superpath,superman,deptpath');
  211. if($this->isempt($this->rs['applydt'])&&isset($this->rs['optdt']))$this->rs['applydt']=substr($this->rs['optdt'],0,10);
  212. if($this->urs){
  213. $this->drs = $this->db->getone('[Q]dept',"`id`='".$this->urs['deptid']."'");
  214. $this->uname = $this->urs['name'];
  215. $this->rs['base_name'] = $this->uname;
  216. if($this->drs){
  217. $this->rs['base_deptname'] = $this->drs['name'];
  218. }
  219. }
  220. $this->sericnum = '';
  221. $this->billrs = $this->billmodel->getone($this->mwhere);
  222. if($this->billrs){
  223. $this->sericnum = $this->billrs['sericnum'];
  224. if(isempt(arrvalue($this->billrs,'uname'))){
  225. $this->savebill();
  226. }
  227. if($this->billrs['status']!=$this->rs['status'])$this->billmodel->update('`status`='.$this->rs['status'].'', $this->billrs['id']);//状态不一样更新一下
  228. if($this->billrs['isturn']!=$this->rs['isturn'])$this->billmodel->update('`isturn`='.$this->rs['isturn'].'', $this->billrs['id']);
  229. if(isempt($this->rs['base_name']))$this->rs['base_name'] = $this->billrs['uname'];
  230. if(isempt($this->rs['base_deptname']))$this->rs['base_deptname'] = $this->billrs['udeptname'];
  231. }else{
  232. if($this->isflow>0)$this->savebill();
  233. }
  234. if($this->isflow>0){
  235. if($this->rs['status']==1 && $this->rs['isturn']=='0'){
  236. $this->update(array('isturn' => 1), $this->id);
  237. $this->rs['isturn'] = 1;
  238. if($this->billrs)$this->billmodel->update('`isturn`=1', $this->billrs['id']);
  239. }
  240. }
  241. $this->getlogrows = array();
  242. if($ispd)$this->isreadqx();
  243. $this->rssust = $this->rs;
  244. $this->flowchangedata();
  245. $this->rs['base_systitle'] = TITLE;//系统名称
  246. $this->rs['base_modename'] = $this->modename;
  247. $this->rs['base_sericnum'] = $this->sericnum;
  248. $this->rs['base_summary'] = $this->getsummary();
  249. }
  250. /**
  251. * 当前模块我待办数量
  252. */
  253. public function getdaiban()
  254. {
  255. $s = $this->rock->dbinstr('nowcheckid', $this->adminid);
  256. $to = $this->billmodel->rows('`modeid`='.$this->modeid.' and `isdel`=0 and `status` not in(1,2) and '.$s.'');
  257. return $to;
  258. }
  259. /**
  260. * 判断单据是否可以查看
  261. */
  262. public function isreadqx($glx=0)
  263. {
  264. $bo = false;
  265. if($this->adminid==1)$bo=true;//为1的超级管理员可查看
  266. if($this->uid==$this->adminid && $this->adminid>0)$bo=true;
  267. if(!$bo && $this->isflow>0){
  268. if($this->billrs){
  269. $allcheckid = $this->billrs['allcheckid'];
  270. if(contain(','.$allcheckid.',',','.$this->adminid.','))$bo = true;
  271. }
  272. }
  273. //可以查看下属人员的
  274. if(!$bo){
  275. if($this->urs && contain($this->urs['superpath'],'['.$this->adminid.']'))$bo = true;
  276. }
  277. //通知表上的权限
  278. if(!$bo){
  279. $tos = $this->todosmodel->rows("".$this->mwhere." and `uid`='$this->adminid'");
  280. if($tos>0)$bo=true;
  281. }
  282. //抄送表上的
  283. if(!$bo){
  284. $tos = $this->chaomodel->rows($this->mwhere.' and '.$this->rock->dbinstr('csnameid', $this->adminid).'');
  285. if($tos>0)$bo=true;
  286. }
  287. //todo表里
  288. if(!$bo){
  289. $tos = $this->db->rows('[Q]todo', "`uid`='$this->adminid' and ".$this->mwhere."");
  290. if($tos>0)$bo=true;
  291. }
  292. if(!$bo)$bo = $this->flowisreadqx(); //自定义查看权限
  293. //权限设置上的
  294. if(!$bo){
  295. $bo = $this->isreadqxs();
  296. }
  297. //监控流程也是可以查看
  298. if(!$bo){
  299. $tos = $this->isjiankongqx();
  300. if($tos>0)$bo=true;
  301. }
  302. if($glx==1)return $bo;
  303. if(!$bo)$this->echomsg('无权限查看模块['.$this->modenum.'.'.$this->modename.']'.$this->uname.'的数据,请联系管理员到[流程模块→流程模块权限]下设置');
  304. }
  305. /**
  306. * 从权限上看是否有查看权限
  307. */
  308. public function isreadqxs()
  309. {
  310. $bo = false;
  311. $where = $this->viewmodel->viewwhere($this->moders, $this->adminid, $this->flowviewufieds);
  312. $where = str_replace('{asqom}','', $where);
  313. $tos = $this->rows("`id`='$this->id' $where ");
  314. if($tos>0)$bo=true;
  315. return $bo;
  316. }
  317. /**
  318. * 判断单据是否可以编辑
  319. */
  320. public function iseditqx()
  321. {
  322. $bo = 0;
  323. if($bo==0 && $this->isflow>0){
  324. if($this->billrs && ($this->uid == $this->adminid || $this->optid==$this->adminid)){
  325. if($this->billrs['nstatus']==0 || $this->billrs['nstatus']==2){
  326. $bo = 1;
  327. }
  328. }
  329. if($this->rs['status']==1)$bo=0;
  330. }
  331. if($bo==0){
  332. $where = $this->viewmodel->editwhere($this->moders, $this->adminid, $this->flowviewufieds);
  333. $where = str_replace('{asqom}','', $where);
  334. $tos = $this->rows("`id`='$this->id' $where ");
  335. if($tos>0)$bo=1;
  336. }
  337. return $bo;
  338. }
  339. /**
  340. * 判断当前单据是否可以删除
  341. */
  342. public function isdeleteqx()
  343. {
  344. $bo = 0;
  345. if($bo==0 && $this->isflow>0){
  346. if($this->billrs && ($this->uid == $this->adminid || $this->optid==$this->adminid)){
  347. if($this->billrs['nstatus']==0 || $this->billrs['nstatus']==2){
  348. $bo = 1;
  349. }
  350. }
  351. if($this->rs['status']==1)$bo=0;
  352. }
  353. if($bo==0){
  354. $where = $this->viewmodel->deletewhere($this->moders, $this->adminid, $this->flowviewufieds);
  355. $where = str_replace('{asqom}','', $where);
  356. $tos = $this->rows("`id`='$this->id' $where ");
  357. if($tos>0)$bo=1;
  358. }
  359. $isd = $this->flowisdeleteqx();
  360. if(is_numeric($isd) && $isd <= 1)$bo = $isd;
  361. return $bo;
  362. }
  363. /**
  364. * 判断是否监控权限
  365. */
  366. public function isjiankongqx()
  367. {
  368. $bo = 0;
  369. if($bo==0){
  370. $where = $this->viewmodel->jiankongwhere($this->moders, $this->adminid, $this->flowviewufieds);
  371. $where = str_replace('{asqom}','', $where);
  372. $tos = $this->rows("`id`='$this->id' $where ");
  373. if($tos>0)$bo=1;
  374. }
  375. return $bo;
  376. }
  377. /**
  378. * 获取详情展示字段
  379. */
  380. public function getfields($lx=0)
  381. {
  382. $fields = array();
  383. if(!$this->fieldsarra)$this->tfieldsarra();
  384. $farr = $this->fieldsarra;
  385. foreach($farr as $k=>$rs)if($rs['iszs']=='1')$fields[$rs['fields']] = $rs['name'];
  386. $fters = $this->flowgetfields($lx);
  387. if(is_array($fters))$fields = array_merge($fields, $fters);
  388. return $fields;
  389. }
  390. /**
  391. * 获取录入页面地址
  392. */
  393. public function getinputurl($num='',$mid=0,$can=array())
  394. {
  395. if($num=='')$num = $this->modenum;
  396. $xa = 'lu';
  397. if($this->ismobile==1)$xa = 'lum';
  398. $url = 'index.php?a='.$xa.'&m=input&d=flow&num='.$num.'&mid='.$mid.'';
  399. if(is_array($can)){
  400. foreach($can as $k=>$v)$url.='&'.$k.'='.$v.'';
  401. }else{
  402. $url .= '&'.$can.'';
  403. }
  404. return $url;
  405. }
  406. public function replacepbr(&$arr, $k)
  407. {
  408. $val = arrvalue($arr, $k);
  409. if(!c('html')->ishtml($val))$arr[$k] = str_replace("\n",'<br>', $val);
  410. return $arr;
  411. }
  412. /**
  413. * 读取展示数据
  414. * $lx 0pc, 1移动,$isdy=2就是打印读取
  415. */
  416. public function getdatalog($lx=0, $isdy=0)
  417. {
  418. m('log')->addread($this->mtable, $this->id);
  419. $this->todosmodel->biaoyidu($this->adminid, $this->modenum, $this->id);
  420. $fobj = m('file');
  421. $this->ismobile = $lx;
  422. $arr['modename'] = $this->modename;
  423. $arr['title'] = $this->modename;
  424. $arr['modeid'] = $this->modeid;
  425. $arr['modenum'] = $this->modenum;
  426. $arr['mid'] = $this->id;
  427. $arr['status'] = arrvalue($this->rs,'status');
  428. $arr['logarr'] = $this->getlog(1);
  429. $arr['isplview'] = arrvalue($this->moders,'ispl','0');
  430. $arr['isys'] = arrvalue($this->moders,'isys','0');
  431. $contview = '';
  432. $lsds = ($isdy==2) ? $isdy: $lx;
  433. $path = ''.P.'/flow/page/view_'.$this->modenum.'_'.$lsds.'.html';
  434. if(COMPANYNUM){
  435. $path1 = ''.P.'/flow/page/view_'.$this->modenum.'_'.COMPANYNUM.'_'.$lsds.'.html';
  436. if(file_exists($path1))$path = $path1;
  437. }
  438. $fstr = $fobj->getstr($this->mtable, $this->id, 3);//3说明是详情也读
  439. $issubtabs = 0;
  440. //if($fstr != ''){
  441. // $this->rs['file_content'] = $fstr;
  442. //}
  443. $data = $this->flowrsreplace($this->rs, ($isdy==2) ? 3 : 1);
  444. $dataa = $this->viewjinfields(array($data));
  445. $data = $dataa[0];
  446. //读取多行子表
  447. $subdata = $this->getsuballdata(1);
  448. if($subdata){
  449. $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`');
  450. foreach($subdata as $zb=>$da){
  451. $sub = $da['fields'];
  452. //--autharstart--
  453. foreach($zbzd as $k1=>$rs1){
  454. if($rs1['iszb']==$zb+1){
  455. $fty = $rs1['fieldstype'];
  456. $fid = $rs1['fields'];
  457. foreach($da['data'] as $k2=>$rs2){
  458. $fval = arrvalue($rs2, $fid);
  459. if($fty=='uploadimg'){
  460. if(!isempt($fval) && substr($fval,0,4)!='<img'){
  461. $fval = $this->rock->gethttppath($fval);
  462. $da['data'][$k2][$fid] = '<img src="'.$fval.'" onclick="c.showviews(this)" height="70">';
  463. }
  464. }
  465. if($fty=='uploadfile'){
  466. if(isempt($fval))$fval='0';
  467. if($fval!='0'){
  468. $da['data'][$k2][$fid] = $fobj->getstr('', '', 3, "`id` in($fval)");
  469. }
  470. }
  471. if($fty=='textarea'){
  472. $this->replacepbr($da['data'][$k2], $fid);
  473. }
  474. }
  475. }
  476. }
  477. //--autharend--
  478. $data[$sub] = $this->getsubdata($zb,$da['data'],arrvalue($data,'subdatays'.$zb.'',$lx));
  479. $data[''.$sub.'_style'] = 'padding:0';
  480. }
  481. }
  482. //文件字段替换上传和上传图片的
  483. $farrobj = $chufarr= array();
  484. if(method_exists($this, 'flowxiangfields'))$chufarr = $this->flowxiangfields($chufarr);
  485. $farrobj['base_sericnum'] = array('name'=>arrvalue($chufarr,'base_sericnum','单号'));
  486. $farrobj['base_name'] = array('name'=>arrvalue($chufarr,'base_name','申请人'));
  487. $farrobj['base_deptname'] = array('name'=>arrvalue($chufarr,'base_deptname','申请人部门'));
  488. $farrobj['base_status'] = array('name'=>arrvalue($chufarr,'base_status','流程状态'));
  489. $farrobj['file_content'] = array('name'=>arrvalue($chufarr,'file_content','相关文件'));
  490. foreach($this->fieldsarra as $k=>$rs){
  491. $fid = $rs['fields'];
  492. $fty = $rs['fieldstype'];
  493. if($fty=='uploadfile'){
  494. $fval = arrvalue($data, $fid);
  495. if(isempt($fval))$fval='0';
  496. $data[$fid] = '';
  497. if($fval!='0'){
  498. $data[$fid] = $fobj->getstr('', '', 3, "`id` in($fval)");
  499. }
  500. }
  501. if($fty=='uploadimg'){
  502. $fval = arrvalue($data, $fid);
  503. if(!isempt($fval) && substr($fval,0,4)!='<img'){
  504. $fval = $this->rock->gethttppath($fval);
  505. $data[$fid] = '<img src="'.$fval.'" onclick="c.showviews(this)" height="100">';
  506. }
  507. }
  508. //文本域自动换行
  509. if($fty=='textarea'){
  510. $this->replacepbr($data, $fid);
  511. }
  512. if($fty=='ditumap' && !isempt($rs['data'])){
  513. $wzhi = arrvalue($data, $rs['data']);
  514. if(!isempt($wzhi))$data[$fid].='<a href="javascript:;" onclick="js.showmap(\''.$wzhi.','.$data[$fid].'\')">[查看地图]</a>';
  515. }
  516. $farrobj[$fid] = $rs;
  517. }
  518. $_logarr = $qfields = array();
  519. foreach($arr['logarr'] as $k1=>$rs1)$_logarr[$rs1['id']] = $rs1;
  520. //读取流程审核步骤信息,只显示同意的
  521. $logrows = $this->flogmodel->getrows($this->mwhere.' and `modeid`='.$this->modeid.' and `courseid`>0 and `courseid`<88888 and `status`>0 and `valid`=1');
  522. foreach($logrows as $k2=>$rs2){
  523. $rs3 = $_logarr[$rs2['id']];
  524. $_coid = $rs2['courseid'];
  525. if(!isempt($rs3['qmimg']))$rs3['name'] = '<img height="30" onclick="c.showviews(this)" width="70" src="'.$rs3['qmimg'].'">';
  526. $key1 = 'course'.$_coid.'';
  527. //if(isempt($rs3['sm']))$rs3['sm']= $rs3['statusname'];
  528. if(!isset($data[''.$key1.'_name'])){
  529. $data[''.$key1.'_name'] = $rs3['name'];
  530. $data[''.$key1.'_zt'] = '<font color="'.$rs3['color'].'">'.$rs3['statusname'].'</font>';
  531. $data[''.$key1.'_sm'] = $rs3['sm'];
  532. $data[''.$key1.'_dt'] = $rs3['checkdt'];
  533. }else{
  534. $data[''.$key1.'_name'] .= ','.$rs3['name'];
  535. $data[''.$key1.'_sm'] .= ','.$rs3['sm'];
  536. $data[''.$key1.'_dt'] = $rs3['checkdt'];
  537. }
  538. //全部处理意见
  539. $key2 = ''.$key1.'_all';
  540. if(!isset($data[$key2])){
  541. $qfields[$key2] = $rs2['name'];
  542. $data[$key2]='';
  543. }
  544. $str1 = $rs3['name'].' <font color="'.$rs3['color'].'">'.$rs3['statusname'].'</font> '.$rs3['checkdt'].'';
  545. if(!isempt($rs3['sm']))$str1.=','.$rs3['sm'].'';
  546. if($data[$key2]!='')$data[$key2].='<hr size="1">';
  547. $data[$key2].= $str1;
  548. }
  549. $ztass = $this->getnowstatus();
  550. $data['base_status'] = $ztass[3];
  551. //使用了自定的展示模板
  552. if(file_exists($path)){
  553. $contview = $this->flowviewtpl(file_get_contents($path), $lx);
  554. preg_match_all('/\^(.*?)\^/', $contview, $list);
  555. foreach($list[1] as $k=>$nrs){
  556. $fzdrs = arrvalue($farrobj, $nrs);
  557. if($fzdrs)$contview = str_replace('^'.$nrs.'^', $fzdrs['name'], $contview);
  558. }
  559. $contview = $this->rock->reparr($contview, $data);
  560. }
  561. $arr['isdefaultview'] = 0;
  562. if($this->isempt($contview) || contain($contview, '$contview$')){
  563. $arr['isdefaultview'] = 1;
  564. $_fields = array();
  565. if($this->isflow>0){
  566. $_fields['base_sericnum'] = $farrobj['base_sericnum']['name'];
  567. $_fields['base_name'] = $farrobj['base_name']['name'];
  568. $_fields['base_deptname'] = $farrobj['base_deptname']['name'];
  569. $_fields['base_status'] = $farrobj['base_status']['name'];
  570. }
  571. $fields = array_merge($_fields, $this->getfields($lx));
  572. //if($fstr!='')$fields['file_content'] = $farrobj['file_content']['name'];
  573. foreach($subdata as $zb=>$da){
  574. $fields[$da['fields']] = $da['name'];
  575. }
  576. if($qfields)$fields = array_merge($fields,$qfields);//审核的字段显示到详情里
  577. if($lx==0)foreach($fields as $k=>$rs){$data[''.$k.'_style'] = 'width:75%';break;}
  578. $_colsr = $this->xiangbordercolor;
  579. if($_colsr=='')$_colsr = getconfig('bcolorxiang');
  580. $contvimr = c('html')->xiangtable($fields, $data, $_colsr);
  581. $contvimr = '<div align="center">'.$contvimr.'</div>';
  582. //移动默认展示
  583. if($lx==1){
  584. $contvimr = '';
  585. if($this->isflow>0){
  586. $contvimr.='<div class="r-border-b">
  587. <div class="blank5"></div>
  588. <table><tr>
  589. <td width="50" align="left"><img style="height:40px;width:40px;border-radius:50%;" src="'.$this->urs['face'].'"></td>
  590. <td><div>'.$this->urs['name'].'<font color="#888888">('.$this->urs['ranking'].')</font></div><div style="padding-top:5px">'.$this->urs['deptallname'].'</div></td>
  591. </tr></table>
  592. <div style="margin:5px 0px" class="blank10"></div>
  593. </div>';
  594. unset($fields['base_name']);
  595. unset($fields['base_deptname']);
  596. }
  597. $contvimr .= '<div><table width="100%">';
  598. foreach($fields as $f=>$n){
  599. $vs = arrvalue($data, $f);
  600. if(!isempt($vs)){
  601. //子表
  602. if(substr($f,0,7)=='subdata'){
  603. $contvimr .= '<tr><td colspan="3"><div style="padding:5px" align="left"><div><b>'.$n.'</b></div>'.$vs.'</div></td></tr>';
  604. }else{
  605. $contvimr .= '<tr><td style="vertical-align:text-top;"><div align="left" style="color:#000;padding:6px 0px 3px;font-size:16px;font-weight:bold;">'.str_replace(' ','<br>',$n).'</div><div style="padding:8px 10px 8px 10px;color:#3A3A3C;font-size:15px;width:94%;min-height:15px;border:1px solid #dcdcdc;border-radius:5px;" align="left">'.$vs.'</div></td><td></td></tr>';
  606. }
  607. }
  608. }
  609. $contvimr .= '</table></div>';
  610. }
  611. if(isempt($contview))$contview = $contvimr;
  612. $contview = str_replace('$contview$',$contvimr, $contview);
  613. }
  614. unset($farrobj);
  615. $arr['contview'] = $contview;
  616. $arr['readarr'] = m('log')->getreadarr($this->mtable, $this->id); //已读人员
  617. $arr['isedit'] = $this->iseditqx();
  618. $arr['isdel'] = $this->isdeleteqx();
  619. $arr['isflow'] = $this->isflow;
  620. $arr['modename'] = $this->modename;
  621. $arr['ischehui'] = $this->ischehui();
  622. $arr['statustext'] = $ztass[4];
  623. $arr['statuscolor'] = $ztass[1];
  624. $arr['optmenu'] = $this->getoptmenu(1); //获取在详情上展示菜单
  625. $arr['isgbjl'] = (int)$this->rock->arrvalue($this->moders,'isgbjl','0'); //是否关闭操作记录
  626. $arr['isgbcy'] = (int)$this->rock->arrvalue($this->moders,'isgbcy','0'); //是否不显示查阅记录
  627. //判断是否需要回执(2018-07-06)新增
  628. $receiptrs = false;
  629. $receiptrow = m('receipt')->getall("`modenum`='$this->modenum' and `mid`='$this->id' and `status`=1");
  630. foreach($receiptrow as $k=>$hrs){
  631. $uid1 = ','.$this->adminid.',';
  632. if(!contain(','.$hrs['receid'].',', $uid1))continue;
  633. if(!contain(','.$hrs['receids'].',', $uid1)){
  634. $receiptrs = array(
  635. 'id' => $hrs['id'],
  636. 'optname' => $hrs['optname'],
  637. );
  638. break;
  639. }
  640. }
  641. $arr['flowinfor'] = array(); //流程信息
  642. $arr['readunarr'] = array(); //未读人员
  643. $arr['receiptrs'] = $receiptrs; //回执确认
  644. if($this->isflow>0){
  645. $arr['flowinfor']= $this->getflowinfor();
  646. if($arr['flowinfor']['ischeck']==1){
  647. $arr['isplview']='0';//需要审核就不要评论框了
  648. }
  649. }
  650. if(isset($data['title']))$arr['title'] = $data['title'];
  651. $_oarr = $this->flowdatalog($arr);
  652. if(is_array($_oarr))foreach($_oarr as $k=>$v)$arr[$k]=$v;
  653. $conta = $this->rock->matcharr($contview,2);
  654. $edbof = false;
  655. foreach($conta as $fids){
  656. $thnr = '';
  657. $contview = str_replace('`'.$fids.'`', $thnr, $contview);
  658. }
  659. $arr['contview'] = $contview;
  660. return $arr;
  661. }
  662. //$lx=0PC,1移动
  663. private function getsubdata($xu, $rows, $lx=0)
  664. {
  665. $iscz = 0;
  666. $iszb = $xu+1;
  667. $fields = 'subdata'.$xu.'';
  668. $subrows = $this->db->getrows('[Q]flow_element','`mid`='.$this->modeid.' and `iszb`='.$iszb.' and `iszs`=1','`fields`,`name`,`isalign`','`sort`');
  669. $cont = '';
  670. if($this->db->count > 0){
  671. $iscz = 1;
  672. $headstr = '@xuhaos,,center'; $colorbb = getconfig('bcolorxiang', '#cccccc');
  673. //if($lx==1){$headstr = '';$colorbb = 'black';}
  674. foreach($subrows as $k=>$rs){
  675. $headstr.='@'.$rs['fields'].','.$rs['name'].'';
  676. if($rs['isalign']=='1')$headstr.=',left';
  677. if($rs['isalign']=='2')$headstr.=',right';
  678. }
  679. foreach($rows as $k=>$rs)$rows[$k]['xuhaos'] = $k+1;
  680. $slex = ($lx==0) ? 'noborder':'';
  681. if($this->subsubdatastyle!='')$slex = $this->subsubdatastyle;
  682. $cont = c('html')->createrows($rows, substr($headstr,1), $colorbb, $slex);
  683. }
  684. return $cont;
  685. }
  686. /**
  687. * 判断当前是否可以撤回
  688. * 撤回条件,审核未同意,最后一步是当前人审核的而为同意,2小时之内
  689. */
  690. public function ischehui()
  691. {
  692. $is = 0;
  693. if($this->rs['status']==1 || $this->isflow==3)return $is;//自由流程不允许撤回
  694. $where = "".$this->mwhere." and `valid`=1 order by `id` desc";
  695. $rs = $this->flogmodel->getone($where);
  696. $time = time()-2*3600;
  697. if($rs && $rs['status']=='1' && $rs['checkid']==$this->adminid && strtotime($rs['optdt'])>$time &&
  698. ($rs['courseid']>0 || $rs['iszb']=='1' ))
  699. $is = $rs['id'];
  700. return $is;
  701. }
  702. /**
  703. * 撤回操作
  704. */
  705. public function chehui($sm='')
  706. {
  707. //--autharstart--
  708. $id = $this->ischehui();
  709. if($id==0)return '当前不允许撤回操作';
  710. $this->flogmodel->update('courseid=0', "`id`='$id'");
  711. $this->addlog(array(
  712. 'explain' => $sm,
  713. 'name' => '撤回'
  714. ));
  715. $this->checksmodel->delete($this->mwhere.' and `optid`='.$this->adminid.'');//删除我指定的人
  716. $barr = $this->getflow(false);
  717. //当前审核人空
  718. if(isempt($barr['nowcheckid'])){
  719. $courseid = $barr['nowcourseid'];
  720. $this->addcheckname($courseid, $this->adminid, $this->adminname, false,2);
  721. $barr = $this->getflow(false);
  722. }
  723. $this->getflowsave($barr);
  724. return 'ok';
  725. //--autharend--
  726. return $this->bd6('5peg5L!h5ZG8562!5o6I5peg5q2k5Yqf6IO9');
  727. }
  728. public function bd6($str)
  729. {
  730. return $this->rock->jm->base64dencode($str);
  731. }
  732. /**
  733. * 读取编辑数据
  734. */
  735. public function getdataedit()
  736. {
  737. $fobj = m('file');
  738. $arr['data'] = $this->flowrsreplaceedit($this->rssust);
  739. $arr['table'] = $this->mtable;
  740. $arr['tables'] = $this->moders['tables'];
  741. $arr['modeid'] = $this->modeid;
  742. $arr['isedit'] = $this->iseditqx();
  743. $arr['isflow'] = $this->isflow;
  744. $arr['user'] = $this->urs;
  745. $arr['status'] = $this->rs['status'];
  746. $filers = $fobj->getfile($this->mtable,$this->id);
  747. foreach($filers as $fk=>$frs1)$filers[$fk]['thumbpath']=$fobj->getthumbpath($frs1);//缩略图显示
  748. $arr['filers'] = $filers;
  749. $arr['subdata'] = $this->getsuballdata();
  750. $filearr = array();
  751. $fileids = '';
  752. foreach($this->fieldsarr as $k=>$rs){
  753. $fid = $rs['fields'];
  754. $flx = $rs['fieldstype'];
  755. if($flx=='uploadfile'){
  756. $fval = arrvalue($this->rssust, $fid);
  757. if(!isempt($fval))$fileids.=','.$fval.'';
  758. }
  759. if($flx=='uploadimg'){
  760. $arr['data'][''.$fid.'_view'] = $this->rock->gethttppath($arr['data'][$fid]);
  761. }
  762. }
  763. //--autharstart--
  764. //读取子表中上传文件的id
  765. if($arr['subdata']){
  766. $zbzd = m('flow_element')->getrows("`mid`='$this->modeid' and `iszb`>0 and `fieldstype`='uploadfile'",'`name`,`fields`,`fieldstype`,`iszb`','`iszb`,`sort`');
  767. foreach($zbzd as $k1=>$rs1){
  768. $zbda = arrvalue($arr['subdata'], 'subdata'.(floatval($rs1['iszb'])-1).'');
  769. if($zbda)foreach($zbda as $k2=>$rs2){
  770. $fval = arrvalue($rs2, $rs1['fields']);
  771. if(!isempt($fval))$fileids.=','.$fval.'';
  772. }
  773. }
  774. }
  775. //--autharend--
  776. //读取文件详情
  777. if($fileids!=''){
  778. $frows = $fobj->getall('`id` in('.substr($fileids, 1).')','filename,id,filesizecn,fileext,optname,thumbpath,thumbplat');
  779. foreach($frows as $k1=>$rs1){
  780. $rs1['thumbpath'] = $fobj->getthumbpath($rs1);
  781. $filearr['f'.$rs1['id'].''] = $rs1;
  782. }
  783. }
  784. $arr['filearr'] = $filearr;
  785. $ztarr = $this->getnowstatus();
  786. $arr['statustext'] = $ztarr[0];
  787. $arr['statuscolor'] = $ztarr[1];
  788. return $arr;
  789. }
  790. /*
  791. * 读取流程信息
  792. */
  793. public function getflowinfor()
  794. {
  795. $ischeck = 0;
  796. $ischange= 0;
  797. $str = '';
  798. $arr = $this->getflow();
  799. if($arr['nowcheckid'] != $this->billrs['nowcheckid'])$this->getflowsave($arr, true);
  800. $nstatus = $this->rs['status'];
  801. $isturn = $this->rs['isturn'];
  802. $nowcheckid = ','.$arr['nowcheckid'].',';
  803. if($isturn==1 && $nstatus !=1 && contain($nowcheckid, ','.$this->adminid.',') && !in_array($nstatus, array(2,5))){
  804. $ischeck = 1;
  805. }
  806. $logarr = $this->getlog();
  807. $nowcur = $this->nowcourse;
  808. if(arrvalue($this->nextcourse,'checktype')=='change'){
  809. $ischange = 1; //需要自己选择下一步处理人
  810. }
  811. $sarr['ischeck'] = $ischeck;
  812. $sarr['ischange'] = $ischange;
  813. $sarr['nowcourse'] = $nowcur;
  814. $sarr['iszhuanban'] = 0;
  815. $sarr['ischao'] = 0;
  816. $sarr['nextcourse'] = $this->nextcourse;
  817. $sarr['nstatustext'] = $arr['nstatustext'];
  818. //--autharstart--
  819. $sarr['iszhuanban'] = (int)arrvalue($nowcur,'iszf',0);
  820. if($sarr['iszhuanban']>0){
  821. $sarr['zbrangeid'] = $this->rock->repempt(arrvalue($nowcur,'zbrangeid'));
  822. $sarr['zbrangelx'] = 'check';
  823. if($sarr['iszhuanban']==2)$sarr['zbrangelx']='';//转办单选
  824. }
  825. $sarr['ischao'] = (int)arrvalue($nowcur,'cslx',0);
  826. $sarr['ischaofwid'] = arrvalue($nowcur,'csfwid');
  827. //--autharend--
  828. if($isturn==0)$sarr['nstatustext'] = '<font color="#ff6600">待提交</font>';
  829. //读取当前审核表单,必填字段|选填字段
  830. $_checkfields = arrvalue($nowcur,'checkfields');
  831. $checkfields = array();
  832. if($ischeck == 1 && !isempt($_checkfields)){
  833. $_checkfieldsa = explode('|', $_checkfields);
  834. $_checkfields = join(',',$_checkfieldsa);
  835. $_checkxuant = arrvalue($_checkfieldsa, 1);
  836. $inputobj = c('input');
  837. $inputobj->flow = $this;
  838. $inputobj->mid = $this->id;
  839. $inputobj->urs = $this->urs;
  840. $elwswhere = "`mid`='$this->modeid' and `iszb`=0 and instr(',$_checkfields,', concat(',',`fields`,','))>0";
  841. $infeidss = $inputobj->initFields($elwswhere);
  842. foreach($infeidss as $_fs=>$fsva){
  843. $_sfes = $fsva['fields'];
  844. $_type = $fsva['fieldstype'];
  845. $showinpus = 1;
  846. $isbt = 1;
  847. if($_checkxuant && contain(','.$_checkxuant.',',','.$_sfes.','))$isbt=0;
  848. if($_type=='hidden' || $_type=='fixed')$showinpus=2;
  849. $_val = arrvalue($this->rssust, $_sfes);
  850. $cheo = (substr($_type,0,6)=='change' && !isempt($fsva['data']));
  851. if($cheo)$_val.='|'.arrvalue($this->rssust, $fsva['data']).''; //默认值
  852. $checkfields[$_sfes] = array(
  853. 'inputstr' => $inputobj->getfieldcontval($_sfes, $_val),
  854. 'name' => $fsva['name'],
  855. 'isbt' => $isbt,
  856. 'fieldstype'=> $_type,
  857. 'fieldsarr' => $fsva,
  858. 'showinpus' => $showinpus
  859. );
  860. if($cheo){
  861. $_sfes = $fsva['data'];
  862. $checkfields[$_sfes] = array(
  863. 'inputstr' => '',
  864. 'isbt' => $isbt,
  865. 'name' => $fsva['name'].'id',
  866. 'fieldstype'=> $_type,
  867. 'fieldsarr' => false,
  868. 'showinpus' => 2
  869. );
  870. }
  871. }
  872. }
  873. $sarr['checkfields'] = $checkfields;
  874. if($nstatus==2)$sarr['nstatustext'] ='<font color="#AB47F7">待提交人处理('.$this->urs['name'].')</font>';
  875. $loglen = count($logarr);
  876. //<img align="absmiddle" class="face" src="'.$rs['face'].'">
  877. foreach($logarr as $k=>$rs){
  878. if($rs['courseid']>0){
  879. $sty = '';
  880. $col = $rs['color'];
  881. if($str!='')$str.=' → ';
  882. $str.='<span style="'.$sty.'">'.$rs['actname'].'('.$rs['name'].'<font color="'.$col.'">'.$rs['statusname'].'</font>)</span>';
  883. }
  884. }
  885. //未同意
  886. if($nstatus=='2'){
  887. if($str!='')$str.=' → ';
  888. $str.= $sarr['nstatustext'];
  889. }else if($nstatus=='5'){
  890. if($str!='')$str.=' → ';
  891. $sarr['nstatustext'] = '<font color="#888888">已作废</font>';
  892. $str.= '<font color="#888888">已作废</font>';
  893. }else{
  894. foreach($this->flowarr as $k=>$rs){
  895. if($rs['ischeck']==0){
  896. $sty = 'color:#888888';
  897. if($rs['isnow']==1)$sty='font-weight:bold;color:#800000';
  898. if($str!='')$str.=' <font color=#888888>→</font> ';
  899. $str.='<span style="'.$sty.'">'.$rs['name'].'';
  900. if(!isempt($rs['nowcheckname']))$str.='('.$rs['nowcheckname'].')';
  901. $str.='</span>';
  902. }
  903. }
  904. }
  905. $sarr['flowcoursestr'] = $str;
  906. if($nstatus==1)$sarr['nstatustext'] = $this->getnowstatus(1); //完成后状态
  907. $actstr = ',同意|green,不同意|red';
  908. if(isset($nowcur['courseact']) ){
  909. $actstrt = $nowcur['courseact'];
  910. if(!isempt($actstrt))$actstr = ','.$actstrt;
  911. }
  912. $act = c('array')->strtoarray($actstr);
  913. foreach($act as $k=>$as1)if($k>0 && $as1[0]==$as1[1])$act[$k][1]='';
  914. if(arrvalue($this->moders,'isys')=='1' && (int)arrvalue($nowcur,'mid','0')>=0){
  915. $act[25]= array('前加签','','');
  916. $act[26]= array('后加签','','');
  917. }
  918. $sarr['courseact'] = $act;
  919. $nowstatus = $this->rs['status'];
  920. if($this->isflow>0 && $this->rs['isturn']==0)$nowstatus=3;
  921. $sarr['nowstatus'] = $nowstatus;
  922. //不同意退回可选择人员
  923. $step = $this->rock->arrvalue($nowcur, 'step','0');
  924. $tuicourse = $this->flogmodel->getall($this->mwhere.' and `courseid`>0 and `valid`=1 and `status`=1 and `step`<'.$step.'','`id`,`checkname`,`name`','`step` desc');
  925. $sarr['tuicourse'] = $tuicourse;
  926. return $sarr;
  927. }
  928. /**
  929. * 更新单据状态
  930. */
  931. public function updatestatus($zt)
  932. {
  933. $this->update('`status`='.$zt.'', $this->id);
  934. $this->billmodel->update('`status`='.$zt.'', $this->mwhere);
  935. }
  936. /**
  937. * 获取状态列表数组
  938. */
  939. public function getstatusarr()
  940. {
  941. return $this->getstatus(null, '','',2);
  942. }
  943. /**
  944. * 获取某单据当前状态
  945. * $rs 单据数据,$statusstr设置的状态,$other 当前审核人
  946. */
  947. public function getstatus($rs, $statusstr='',$other='', $glx=0)
  948. {
  949. $statustext = $statuscolor = '';
  950. if($statusstr=='')$statusstr=$this->rock->arrvalue($this->moders,'statusstr');
  951. $statusara = array();
  952. $colorsa = array('blue','green','red','#ff6600','#526D08','#888888','','','','','','','','','','','','','');
  953. if(isempt($statusstr)){
  954. $statussst = '不同意';
  955. $statusstr = '待?处理|blue,已审核|green,'.$statussst.'|red';
  956. }
  957. $nowcheckname= arrvalue($rs,'nowcheckname', arrvalue($this->billrs,'nowcheckname'));
  958. if(isempt($other))$other = $nowcheckname;
  959. $statusar = c('array')->strtoarray($statusstr);
  960. foreach($statusar as $k=>$v){
  961. if($v[0]==$v[1])$v[1]= arrvalue($colorsa, $k);
  962. $statusara[$k] = $v;
  963. }
  964. $statusara[5] = array('已作废','#888888');
  965. $statusara[23] = array('退回','#17B2B7');
  966. if($glx==2)return $statusara;
  967. $isturn = -1;
  968. if(isset($rs['isturn']))$isturn = (int)$rs['isturn'];
  969. $zt = $this->rock->arrvalue($rs, 'status');
  970. if($isturn==0){
  971. $statustext = '待提交';
  972. $statuscolor= '#ff6600';
  973. }elseif(!isempt($zt)){
  974. if(isset($statusara[$zt])){
  975. $statustext = $statusara[$zt][0];
  976. $statuscolor = $statusara[$zt][1];
  977. }
  978. }
  979. if(contain($statustext,'?')){
  980. $statusstr = str_replace('?', '<font color="'.$statuscolor.'">'.$other.'</font>', $statustext);
  981. }else{
  982. $statusstr = '<font color="'.$statuscolor.'">'.$statustext.'</font>';
  983. }
  984. if($glx==1){
  985. return $statusstr;
  986. }
  987. return array(str_replace('?', $other, $statustext), $statuscolor, $zt, $statusstr, str_replace('?', '', $statustext));
  988. }
  989. public function getstatusstr($rs)
  990. {
  991. return $this->getstatus($rs, '','', 1);
  992. }
  993. /**
  994. * 当前单击状态
  995. */
  996. public function getnowstatus($glx=0)
  997. {
  998. return $this->getstatus($this->rs, '','', $glx);
  999. }
  1000. //$lx=0默认,1详情
  1001. private $getlogrows = array();
  1002. public function getlog($lx=0)
  1003. {
  1004. if(isset($this->getlogrows[$lx]))return $this->getlogrows[$lx];
  1005. $rows = $this->flogmodel->getrows($this->mwhere, '`checkname` as `name`,`checkid`,`name` as actname,`optdt`,`status`,`explain`,`statusname`,`valid`,`courseid`,`color`,`id`,`qmimg`','`id` asc');
  1006. $uids = $idss = '';
  1007. $dts = c('date');
  1008. $fo = m('file');
  1009. $editarrs = array();
  1010. //--autharstart--
  1011. if($lx==1){
  1012. $editarr = $this->db->getall('SELECT `optid`,`optdt` FROM `[Q]editrecord` where '.$this->mwhere.' order by `optid`,`optdt`');
  1013. foreach($editarr as $k1=>$rs1)$editarrs[$rs1['optid'].$rs1['optdt']]=1;
  1014. }
  1015. //--autharend--
  1016. foreach($rows as $k=>$rs){
  1017. $uids.=','.$rs['checkid'].'';
  1018. $idss.=','.$rs['id'].'';
  1019. $col = $rs['color'];
  1020. if(isempt($col))$col='green';
  1021. if(contain($rs['statusname'],'不') || $rs['status']=='2')$col='red';
  1022. $rows[$k]['color'] = $col;
  1023. $rows[$k]['checkdt'] = $rs['optdt'];
  1024. $rows[$k]['sm'] = $rs['explain'];
  1025. if(!isempt($rs['qmimg'])){
  1026. //签名是手写的
  1027. if(!contain($rs['qmimg'],'.')){
  1028. $qmimg = ''.UPDIR.'/'.date('Y-m').'/qmimg'.$rs['id'].'.png';
  1029. $bo = true;
  1030. if(!file_exists($qmimg)){
  1031. $bar= explode(',', $rs['qmimg']);
  1032. $bo = $this->rock->createtxt($qmimg, base64_decode($bar[1]));
  1033. }
  1034. if(!$bo){
  1035. $qmimg = $rs['qmimg'];
  1036. }else{
  1037. $qmimg = ''.URL.''.$qmimg.'';
  1038. }
  1039. }else{
  1040. $qmimg = $rs['qmimg'];
  1041. if(!file_exists($qmimg)){
  1042. $qmimg = '';
  1043. }else{
  1044. $qmimg = ''.URL.''.$qmimg.'';
  1045. }
  1046. }
  1047. $rows[$k]['qmimg'] = $qmimg;
  1048. if(!isempt($qmimg))$rows[$k]['explain']= '<img height="30" width="70" src="'.$qmimg.'">'.$rs['explain'].'';
  1049. }
  1050. //--autharstart--
  1051. if($lx==1 && $rs['actname']=='编辑'){
  1052. 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>');
  1053. }
  1054. //--autharend--
  1055. }
  1056. //读取相关文件
  1057. if($idss!=''){
  1058. $farr = $fo->getfile('flow_log', substr($idss, 1));
  1059. if($farr)foreach($rows as $k=>$rs){
  1060. $fstr = $fo->getallstr($farr, $rs['id'],2);
  1061. $rows[$k]['explain']= $this->strappend($rs['explain'], $fstr, '<br>');
  1062. }
  1063. }
  1064. //读取对应人员头像
  1065. if($uids!=''){
  1066. $rows = m('admin')->getadmininfor($rows, substr($uids, 1), 'checkid');
  1067. }
  1068. $this->getlogrows[$lx] = $rows;
  1069. return $rows;
  1070. }
  1071. public function addlog($arr=array())
  1072. {
  1073. $addarr = array(
  1074. 'table' => $this->mtable,
  1075. 'mid' => $this->id,
  1076. 'checkname' => $this->adminname,
  1077. 'checkid' => $this->adminid,
  1078. 'optdt' => $this->rock->now,
  1079. 'courseid' => '0',
  1080. 'status' => '1',
  1081. 'ip' => $this->rock->ip,
  1082. 'web' => $this->rock->web,
  1083. 'modeid' => $this->modeid
  1084. );
  1085. foreach($arr as $k=>$v)$addarr[$k]=$v;
  1086. if(isset($addarr['explain']))$addarr['explain']= htmlspecialchars($addarr['explain']);
  1087. $this->flogmodel->insert($addarr);
  1088. $ssid = $this->db->insert_id();
  1089. $fileid = $this->rock->post('fileid'); //这个是审批处理时下的上传文件
  1090. if($fileid!='')m('file')->addfile($fileid, 'flow_log', $ssid, $this->modenum.'|'.$this->id);
  1091. $logfileid = $this->rock->post('logfileid'); //这个是从单据操作菜单添加追加时
  1092. if($logfileid!='')m('file')->addfile($logfileid, 'flow_log', $ssid, $this->modenum.'|'.$this->id);
  1093. $addarr['id'] = $ssid;
  1094. $this->flowaddlog($addarr);
  1095. $this->getlogrows = array();
  1096. return $ssid;
  1097. }
  1098. public function submit($na='', $sm='')
  1099. {
  1100. if($na=='')$na='提交';
  1101. $isturn = 1;
  1102. if($na=='保存')$isturn = 0;
  1103. $this->addlog(array(
  1104. 'name' => $na,
  1105. 'explain' => $sm
  1106. ));
  1107. if($this->isflow>0){
  1108. $marr['isturn'] = $isturn;
  1109. $marr['status'] = 0;
  1110. $this->rs['status'] = 0;
  1111. $this->update($marr, $this->id);
  1112. //每次编辑判断是否重新开始走审批。
  1113. if(arrvalue($this->moders,'isflowlx')=='1' || $this->isflow>=3){
  1114. $this->checksmodel->delete($this->mwhere);
  1115. $this->flogmodel->update('`valid`=0', ''.$this->mwhere.' and `courseid`>0 and `valid`=1');
  1116. }
  1117. $farr = $this->getflow();
  1118. //第一步自定义审核人
  1119. if($farr['nowcourseid']>0){
  1120. $sysnextoptid = $this->rock->post('sysnextoptid'); $sysnextopt = $this->rock->post('sysnextopt'); $sysnextcustidid = (int)$this->rock->post('sysnextcustidid');
  1121. if($sysnextcustidid == $farr['nowcourseid'] && !isempt($sysnextoptid) && !isempt($sysnextopt)){
  1122. $this->addcheckname($sysnextcustidid, $sysnextoptid, $sysnextopt, true, 1);
  1123. $farr = $this->getflow(); //重新在读取匹配流程
  1124. }
  1125. }
  1126. $farr['status'] = 0;
  1127. $this->savebill($farr);
  1128. if($isturn == 1){
  1129. $this->nexttodo($farr['nowcheckid'],'submit');
  1130. }
  1131. }
  1132. $this->flowsubmit($na, $sm);
  1133. //抄送保存
  1134. $this->savecsname(
  1135. $this->rock->post('syschaosongid'),
  1136. $this->rock->post('syschaosong'),
  1137. $this->adminid,0,$isturn,$na);
  1138. if($na=='编辑'){
  1139. $this->gettodosend('boedit');
  1140. }else{
  1141. $this->gettodosend('boturn');//提交
  1142. }
  1143. }
  1144. private function savecsname($csnameid,$csname,$uid,$type,$isturn, $na)
  1145. {
  1146. if(!isempt($csnameid)){
  1147. $where = $this->mwhere.' and `type`='.$type.'';
  1148. if($type>0)$where.=' and `uid`='.$uid.'';
  1149. $csid = (int)$this->chaomodel->getmou('id', $where);
  1150. if($csid==0)$where = '';
  1151. $this->chaomodel->record(array(
  1152. 'modeid' => $this->modeid,
  1153. 'table' => $this->mtable,
  1154. 'mid' => $this->id,
  1155. 'uid' => $uid,
  1156. 'type' => $type,
  1157. 'csname' => $csname,
  1158. 'csnameid' => $csnameid,
  1159. ),$where);
  1160. if($isturn==1)$this->nexttodo($csnameid,'chao', $na);//发送通知
  1161. }
  1162. }
  1163. /**
  1164. * 获取抄送人姓名
  1165. */
  1166. public function getcsname($id=0)
  1167. {
  1168. if($id>0){
  1169. $where= "`table`='$this->mtable' and `mid`='$id' and `type`=0";
  1170. }else{
  1171. $where= "`modeid`={$this->modeid} and `uid`={$this->adminid} and `type`=0";
  1172. $iscs = (int)$this->moders['iscs'];
  1173. //if($iscs<=2)$where='1=2';//默认不读取
  1174. }
  1175. $ors = $this->chaomodel->getone($where,'*','`id` desc');
  1176. $csname = $csnameid = '';
  1177. if($ors){
  1178. $csname = $ors['csname'];
  1179. $csnameid = $ors['csnameid'];
  1180. }
  1181. return array(
  1182. 'csname' => $csname,
  1183. 'csnameid' => $csnameid,
  1184. 'id' => $id,
  1185. );
  1186. }
  1187. /**
  1188. * 追加说明
  1189. */
  1190. public function zhuijiaexplain($sm='')
  1191. {
  1192. $this->addlog(array(
  1193. 'explain' => $sm,
  1194. 'name' => '追加说明',
  1195. 'status' => 1,
  1196. ));
  1197. $zt = $this->rs['status'];
  1198. if($zt==2 && $this->isflow>0 && $this->adminid==$this->uid){
  1199. $marr['status'] = 0;
  1200. $this->rs['status'] = 0;
  1201. $this->update($marr, $this->id);
  1202. $farr = $this->getflow();
  1203. $farr['status'] = 0;
  1204. $this->savebill($farr);
  1205. $this->nexttodo($farr['nowcheckid'],'zhui', $sm);
  1206. }
  1207. $this->gettodosend('bozhui','', $sm);
  1208. }
  1209. /**
  1210. * 催办
  1211. */
  1212. public function chuiban($sm='')
  1213. {
  1214. $this->addlog(array(
  1215. 'explain' => $sm,
  1216. 'name' => '催办',
  1217. 'status' => 1,
  1218. ));
  1219. $farr = $this->getflow(true);
  1220. $this->nexttodo($farr['nowcheckid'],'cuiban', $sm);
  1221. $this->gettodosend('cuiban','', $sm);
  1222. }
  1223. //提请预算读取
  1224. public function getyushen($rows)
  1225. {
  1226. return $rows;
  1227. }
  1228. private function getyushenss($id, $rows, $xu, $isq)
  1229. {
  1230. if($xu==0)$this->_tempauoe = array();
  1231. if(isset($rows[$id])){
  1232. $_tars = $rows[$id];
  1233. if($isq==1)$this->getyushenss($_tars['id'], $rows, $xu+1, $isq);
  1234. $this->_tempauoe[] = $_tars;
  1235. if($isq==0)$this->getyushenss($_tars['id'], $rows, $xu+1, $isq);
  1236. }
  1237. return $this->_tempauoe;
  1238. }
  1239. /**
  1240. * 匹配流程读取
  1241. */
  1242. public function getflowpipei($uid=0)
  1243. {
  1244. $urs = $this->urs;
  1245. if(!$urs)$urs = $uid;
  1246. if(!is_array($urs))$urs = $this->db->getone('[Q]admin', "`id`='$urs'", '`deptid`,`deptpath`,`id`');
  1247. $coursedb = m('flowcourse');
  1248. $barr = $coursedb->pipeiCourse($this->modeid);
  1249. $rows = $barr['rows'];
  1250. $this->pipeiCoursearrc = $barr['rowd'];
  1251. $this->pipeiCoursearrs = array();
  1252. $this->pipeiCoursearr = array();
  1253. $kqobj = m('kaoqin');
  1254. $this->getflowpipeis($rows, $urs, $kqobj);
  1255. unset($this->pipeiCoursearrs);
  1256. unset($this->pipeiCoursearrc);
  1257. return $this->getyushen($this->pipeiCoursearr);
  1258. }
  1259. private function getflowpipeis($rows,$urs, $kqobj)
  1260. {
  1261. $shiyong = array();
  1262. $defix = $xuhao = 0; //默认是0的
  1263. $uid = arrvalue($urs,'id',0);
  1264. $zshu = count($rows);
  1265. foreach($rows as $k=>$rs){
  1266. $whereid = (int)$rs['whereid'];
  1267. $receid = $rs['receid'];
  1268. $wherestr= arrvalue($rs, 'where');
  1269. //停用了
  1270. if($rs['status']=='0')continue;
  1271. //where条件字段
  1272. if(!isempt($wherestr)){
  1273. $wherestr = m('base')->strreplace($this->rock->jm->base64decode($wherestr), $uid);
  1274. $to = $this->rows("`id`='$this->id' and $wherestr ");
  1275. if($to==0)continue;//条件不成立
  1276. }
  1277. //有条件的【流程模块条件】下的ID
  1278. if($whereid > 0){
  1279. $bo = $this->wheremanzhu($whereid);
  1280. if(!$bo)continue;
  1281. }
  1282. //特殊判断过滤
  1283. if(!isempt($rs['num'])){
  1284. $bo = $this->flowcoursejudge($rs['num'], $rs);
  1285. if(is_bool($bo) && !$bo)continue;
  1286. }
  1287. $xuhao++;
  1288. if($defix==0 && (isempt($receid) || contain($receid,'all'))){
  1289. $defix = $xuhao;
  1290. }
  1291. //当有设置审核条件满足时就用这个做默认,2018-07-10 新增,如果是多个满足就取最后一个
  1292. if(isempt($receid) && (!isempt($wherestr) || $whereid > 0)){
  1293. $defix = $xuhao;
  1294. }
  1295. $rs['xuhao'] = $xuhao;
  1296. $shiyong[] = $rs;
  1297. }
  1298. //在根据receid匹配到哪个流程
  1299. $pboss = false;//是否有匹配到
  1300. if($shiyong){
  1301. $gxuha = $kqobj->getpipeimid($urs, $shiyong, 'xuhao', $defix); //这个匹配出来是大于0的
  1302. if($gxuha>0){
  1303. $pboss = true;//有匹配到
  1304. $gxuha = $gxuha-1;
  1305. $prs = $shiyong[$gxuha];
  1306. $this->getflowpipeisss($prs, $urs, $kqobj);
  1307. }
  1308. }
  1309. //没匹配到,可能是跳过,而且有下级需要审批
  1310. if(!$pboss && $zshu==1 && $rows[0]['childshu']>0){
  1311. $this->getflowpipeis($rows[0]['children'], $urs, $kqobj);
  1312. }
  1313. }
  1314. private function getflowpipeisss($prsnrs, $urs, $kqobj)
  1315. {
  1316. $prs = $prsnrs;
  1317. unset($prs['children']);
  1318. $this->pipeiCoursearrs[]= $prs['id'];
  1319. $this->pipeiCoursearr[] = $prs;
  1320. if($prs['childshu']>0){
  1321. $this->getflowpipeis($prsnrs['children'], $urs, $kqobj);
  1322. }else{
  1323. //有nid下级就读取
  1324. $nid = arrvalue($prs,'nid','0');
  1325. if($nid>0 && !in_array($nid, $this->pipeiCoursearrs) && isset($this->pipeiCoursearrc, $nid)){
  1326. $this->getflowpipeis(array($this->pipeiCoursearrc[$nid]), $urs, $kqobj);
  1327. }
  1328. }
  1329. }
  1330. /*
  1331. * 获取流程
  1332. */
  1333. public function getflow($sbo=false)
  1334. {
  1335. $this->flowarr = array();
  1336. $allcheckid = $nowcheckid = $nowcheckname = $nstatustext = '';
  1337. $allcheckids = array();
  1338. $nowcourseid = 0;
  1339. $nstatus = $this->rs['status'];
  1340. $this->nowcourse = array();
  1341. $this->nextcourse = array();
  1342. $this->flowisend = 0;
  1343. $curs = $this->flogmodel->getrows($this->mwhere,'checkid,checkname,courseid,`valid`,`status`,`statusname`,`name`,`iszb`','id desc');
  1344. $cufss = $ztnas = $chesarr = array();
  1345. foreach($curs as $k=>$rs){
  1346. if($rs['iszb']=='1' && !in_array($rs['checkid'], $allcheckids))$allcheckids[] = $rs['checkid']; //转办也记录到经我处理的
  1347. if($rs['courseid']=='0')continue;
  1348. $_su = ''.$rs['courseid'].'';
  1349. $_su1 = ''.$rs['courseid'].'_'.$rs['checkid'].'';
  1350. //$rs['status']为1就一走下一步
  1351. if($rs['valid']==1 && in_array($rs['status'], $this->flowstatusarr)){
  1352. if(!isset($cufss[$_su]))$cufss[$_su]=0;
  1353. $cufss[$_su]++;
  1354. $chesarr[$_su1] = 1; //标识已审核
  1355. }
  1356. if(!in_array($rs['checkid'], $allcheckids))$allcheckids[] = $rs['checkid'];
  1357. if($nstatustext=='' && $rs['courseid']>0){
  1358. $nstatustext = ''.$rs['checkname'].'处理'.$rs['statusname'].'';
  1359. $nstatus = $rs['status'];
  1360. }
  1361. $ztnas[$rs['courseid']] = ''.$rs['checkname'].''.$rs['statusname'].'';
  1362. }
  1363. $nowstep = $zongsetp = -1;
  1364. $isend = 0;
  1365. $czt = $this->rs['status'];
  1366. $coutye = 0; //判断是否需要前后审批处理
  1367. $rows = ($czt==1 || $czt==5)? array() : $this->getflowpipei($this->uid);
  1368. if($rows){
  1369. //读取flow_checks是否比审核状态(退回的)
  1370. $checksa = $this->checksmodel->getrows($this->mwhere.' and `addlx`=3');
  1371. $coursea = $nrows = array();
  1372. foreach($checksa as $k=>$rs)$coursea[$rs['courseid']]='1';
  1373. $nrows = array();
  1374. //获取审核人
  1375. $allcheckid = '';
  1376. $isoptsuperbo = false;
  1377. foreach($rows as $k=>$rs){
  1378. $uarr = $this->getcheckname($rs);
  1379. $rows[$k]['checkid'] = $uarr[0];
  1380. $rows[$k]['checkname'] = $uarr[1];
  1381. $allcheckid .= ','.$uarr[0].'';
  1382. if($rs['checktype']=='optsuper' && isempt($uarr[0]))$isoptsuperbo=true;//有操作人上级
  1383. }
  1384. //有需要读取上一步
  1385. if($isoptsuperbo)foreach($rows as $k=>$rs){
  1386. if($rs['checktype']=='optsuper'){
  1387. //读取上一步处理人
  1388. $_k1 = $k-1;
  1389. $_uid = $this->optid;
  1390. if($_k1>=0){
  1391. $ours = $this->flogmodel->getone($this->mwhere.' and `courseid`='.$rows[$_k1]['id'].' and `valid`=1 ','`checkid`','`id` desc');
  1392. if(!$ours){
  1393. $_uid = (int)$rows[$_k1]['checkid'];
  1394. }else{
  1395. $_uid = $ours['checkid'];
  1396. }
  1397. }
  1398. $uarr = $this->adminmodel->getsuperman($_uid);
  1399. if($uarr){
  1400. $rows[$k]['checkid'] = $uarr[0];
  1401. $rows[$k]['checkname'] = $uarr[1];
  1402. }
  1403. }
  1404. }
  1405. //print_r($rows);
  1406. foreach($rows as $k=>$rs){
  1407. $nrows[] = $rs;
  1408. //全部直属上级
  1409. if($rs['checktype']=='superall'){
  1410. $ids1 = $rs['id'];
  1411. $suparr = $this->adminmodel->getsuperarr($this->uid);
  1412. if($suparr){
  1413. $logdsar = $this->getlog();
  1414. foreach($logdsar as $k1=>$rs1){
  1415. if($rs1['courseid']>0 && $rs1['status']=='1' && $rs1['valid']=='1')$allcheckid .= ','.$rs1['checkid'].'';
  1416. }
  1417. foreach($suparr as $k1=>$surs){
  1418. if(!contain(','.$allcheckid.',', ','.$surs['id'].',')){
  1419. $rs['oldid'] = $ids1;
  1420. $rs['id'] = $ids1 * 99999 + $surs['id'];
  1421. $rs['checkid'] = $surs['id'];
  1422. $rs['checkname'] = $surs['name'];
  1423. $rs['iszf'] = 0;
  1424. $nrows[] = $rs;
  1425. $allcheckid .= ','.$surs['id'].'';
  1426. }
  1427. }
  1428. }
  1429. }
  1430. }
  1431. $yisheh = '';
  1432. if($this->isflow==2){
  1433. $logdsar = $this->getlog();
  1434. foreach($logdsar as $k1=>$rs1)
  1435. if($rs1['courseid']>0 && $rs1['status']==1 && $rs1['valid']==1)$yisheh .= ','.$rs1['checkid'].'';
  1436. }
  1437. foreach($nrows as $k=>$rs){
  1438. $whereid = (int)$rs['whereid'];
  1439. $checkshu = $rs['checkshu'];
  1440. $checkid = $rs['checkid'];
  1441. $checkname = $rs['checkname'];
  1442. $checktype = $rs['checktype'];
  1443. //顺序前缀审批,申请人提交人不参与审批
  1444. if($this->isflow==2 && !isempt($checkid) && isempt($rs['checkfields'])){
  1445. if(($checkid==$this->uid || $checkid==$this->optid) )continue; //申请人
  1446. $k2 = $k+1;
  1447. $ntype = 'yes';
  1448. if(isset($nrows[$k2])){
  1449. if($nrows[$k2]['checktype']=='change')$ntype='no';//下步上步指定
  1450. }
  1451. //已经处理就不处理
  1452. if($ntype=='yes' && contain(','.$yisheh.',',','.$checkid.','))continue;
  1453. }
  1454. if(!isempt($checkid))$yisheh .= ','.$checkid.'';
  1455. $zongsetp++;
  1456. $ischeck = 0;
  1457. $checkids = $checknames = '';
  1458. $_su = ''.$rs['id'].'';
  1459. $nowshu = 0;
  1460. if(isset($cufss[$_su]))$nowshu = $cufss[$_su];
  1461. if(!$this->isempt($checkid)){
  1462. $checkida = explode(',', $checkid);
  1463. $checkidna = explode(',', $checkname);
  1464. $_chid = $_chna = '';
  1465. foreach($checkida as $k1=>$chkid){
  1466. $_su1 = ''.$rs['id'].'_'.$chkid.'';
  1467. if(!in_array($chkid, $allcheckids))$allcheckids[] = $chkid;
  1468. if(!isset($chesarr[$_su1])){
  1469. $_chid.=','.$chkid.'';
  1470. $_chna.=','.arrvalue($checkidna, $k1).'';
  1471. }
  1472. }
  1473. if($_chid!='')$_chid = substr($_chid, 1);
  1474. if($_chna!='')$_chna = substr($_chna, 1);
  1475. if($_chid==''){
  1476. $ischeck = 1;
  1477. }else{
  1478. if($checkshu>0&&$nowshu>=$checkshu)$ischeck = 1;
  1479. }
  1480. $checkids = $_chid;
  1481. $checknames = $_chna;
  1482. }else{
  1483. if($checkshu>0&&$nowshu>=$checkshu)$ischeck = 1;
  1484. //需要全部审核时 同时已有审核过了 也没有审核人了
  1485. if($checkshu == 0 && $nowshu>0)$ischeck = 1;
  1486. }
  1487. if($ischeck==0 && $coutye==0){
  1488. if((int)arrvalue($rs,'coursetype','0')>0)$coutye = 1;
  1489. }
  1490. $rs['ischeck'] = $ischeck;
  1491. $rs['islast'] = 0;
  1492. $rs['checkid'] = $checkid;
  1493. $rs['checkname'] = $checkname;
  1494. $rs['nowcheckid'] = $checkids;
  1495. $rs['nowcheckname'] = $checknames;
  1496. $rs['isnow'] = 0;
  1497. $rs['nowstep'] = $zongsetp;
  1498. $rs['step'] = $k+1;
  1499. if($ischeck==0 && $nowstep==-1){
  1500. $rs['isnow']= 1;
  1501. $nowstep = $zongsetp;
  1502. $this->nowcourse = $rs; //当前审核步骤信息
  1503. $nowcourseid = $rs['id'];
  1504. $nowcheckid = $checkids;
  1505. $nowcheckname = $checknames;
  1506. }
  1507. if($nowstep>-1 && $zongsetp==$nowstep+1)$this->nextcourse = $rs; //下一步信息
  1508. $this->flowarr[]= $rs;
  1509. }
  1510. }
  1511. if($zongsetp>-1)$this->flowarr[$zongsetp]['islast']=1;
  1512. if($nowstep == -1){
  1513. $isend = 1;
  1514. }else{
  1515. $nstatustext = '待'.$nowcheckname.'处理';
  1516. }
  1517. $this->flowisend = $isend;
  1518. $allcheckid = join(',', $allcheckids);
  1519. $arrbill['allcheckid'] = $allcheckid;
  1520. $arrbill['nowcourseid'] = $nowcourseid;
  1521. $arrbill['nowcheckid'] = $nowcheckid;
  1522. $arrbill['nowcheckname'] = $nowcheckname;
  1523. $arrbill['nstatustext'] = $nstatustext;
  1524. $arrbill['nstatus'] = $nstatus;
  1525. $arrbill['status'] = $this->rs['status'];
  1526. $arrbill['isturn'] = $this->rs['isturn'];
  1527. if($sbo)$this->getflowsave($arrbill);
  1528. return $arrbill;
  1529. }
  1530. public function wheremanzhu($id)
  1531. {
  1532. $uid = $this->uid;
  1533. $ser = $this->wheremodel->getflowwhere($id, $uid);
  1534. if(!$ser)return true;
  1535. $str = $ser['ntr'];
  1536. if(!isempt($str)){
  1537. $to = $this->db->rows('[Q]admin',"`id`='$uid' and ($str)");
  1538. if($to>0)return false;
  1539. }
  1540. $str = $ser['str'];
  1541. if(!isempt($str)){
  1542. $str= str_replace('{asqom}','', $str);
  1543. $to = $this->rows("`id`='$this->id' and $str");
  1544. if($to==0)return false;
  1545. }
  1546. $str = $ser['utr'];
  1547. if(!isempt($str)){
  1548. $to = $this->db->rows('[Q]admin',"`id`='$uid' and $str");
  1549. if($to==0)return false;
  1550. }
  1551. return true;
  1552. }
  1553. public function getflowsave($sarr, $suvu=false)
  1554. {
  1555. if(!$sarr)return;
  1556. if($suvu)$sarr['updt'] = $this->rock->now;
  1557. $this->billmodel->update($sarr, $this->mwhere);
  1558. }
  1559. //获取审核人
  1560. private function getcheckname($crs)
  1561. {
  1562. $type = $crs['checktype'];
  1563. $cuid = $name = '';
  1564. $courseid= $crs['id'];
  1565. $cheorws = $this->checksmodel->getall($this->mwhere.' and `courseid`='.$courseid.'','checkid,checkname');
  1566. if($cheorws){
  1567. foreach($cheorws as $k=>$rs){
  1568. $lxss = $rs['checkid'];
  1569. if(isempt($lxss) || $lxss=='0')continue;
  1570. $cuid.=','.$lxss.'';
  1571. $name.=','.$rs['checkname'].'';
  1572. }
  1573. if($cuid != ''){
  1574. $cuid = substr($cuid, 1);
  1575. $name = substr($name, 1);
  1576. return array($cuid, $name);
  1577. }
  1578. }
  1579. //自定义审核人读取
  1580. if(!$this->isempt($crs['num'])){
  1581. $uarr = $this->flowcheckname($crs['num']);
  1582. if(is_array($uarr)){
  1583. if(!$this->isempt($uarr[0]))return $uarr;
  1584. }
  1585. }
  1586. if($type=='super' || $type=='superall'){
  1587. $cuid = $this->urs['superid'];
  1588. $name = $this->urs['superman'];
  1589. }
  1590. if($type=='dept' || $type=='super' || $type=='superall'){
  1591. if($this->isempt($cuid) && $this->drs){
  1592. $cuid = $this->drs['headid'];
  1593. $name = $this->drs['headman'];
  1594. }
  1595. }
  1596. if($type=='apply'){
  1597. $cuid = $this->urs['id'];
  1598. $name = $this->urs['name'];
  1599. }
  1600. if($type=='opt'){
  1601. $cuid = $this->rs['optid'];
  1602. $name = $this->rs['optname'];
  1603. if(isempt($cuid)){
  1604. $cuid = $this->urs['id'];
  1605. $name = $this->urs['name'];
  1606. }
  1607. }
  1608. if($type=='user'){
  1609. $cuid = $crs['checktypeid'];
  1610. $name = $crs['checktypename'];
  1611. }
  1612. if($type=='rank'){
  1613. $rank = $crs['checktypename'];
  1614. if(!$this->isempt($rank)){
  1615. $wheer1 = $this->adminmodel->getcompanywhere(5,'',$this->companyid);
  1616. $rnurs = $this->db->getrows('[Q]admin',"`status`=1 and `ranking`='$rank' ".$wheer1."",'id,name','sort');
  1617. foreach($rnurs as $k=>$rns){
  1618. $cuid.=','.$rns['id'].'';
  1619. $name.=','.$rns['name'].'';
  1620. }
  1621. if($cuid != ''){
  1622. $cuid = substr($cuid, 1);
  1623. $name = substr($name, 1);
  1624. }
  1625. }
  1626. }
  1627. if($type=='cname'){
  1628. $cnbar = $this->cnamemodel->getcheckname($crs['checktypeid'], $this->uid);
  1629. $cuid = arrvalue($cnbar, 0);
  1630. $name = arrvalue($cnbar, 1);
  1631. }
  1632. //主表上字段,一般都是ID字段
  1633. if($type=='field'){
  1634. $fids = $crs['checktypeid'];
  1635. if(!isempt($fids)){
  1636. $vals = '';
  1637. $farrs= explode(',', $fids);
  1638. foreach($farrs as $fid){
  1639. $vid = arrvalue($this->rs, $fid);
  1640. if(!isempt($vid))$vals.=','.$vid.'';
  1641. }
  1642. if($vals!=''){
  1643. $vals = substr($vals, 1);
  1644. $uarr = $this->adminmodel->getrows('`status`=1 and `id` in('.$vals.')','id,name','FIELD(`id`,'.$vals.')');
  1645. foreach($uarr as $k=>$rs){
  1646. $cuid.=','.$rs['id'].'';
  1647. $name.=','.$rs['name'].'';
  1648. }
  1649. if($cuid != ''){
  1650. $cuid = substr($cuid, 1);
  1651. $name = substr($name, 1);
  1652. }
  1653. }
  1654. }
  1655. }
  1656. $cuid = $this->rock->repempt($cuid);
  1657. $name = $this->rock->repempt($name);
  1658. return array($cuid, $name);
  1659. }
  1660. /**
  1661. * 创建编号
  1662. */
  1663. public function createbianhao($num, $fid, $wshu=3)
  1664. {
  1665. if(isempt($num))$num=''.$this->modenum.'-';
  1666. @$appdt = $this->rs['applydt'];
  1667. if(isempt($appdt))$appdt = $this->rock->date;
  1668. $apdt = str_replace('-','', substr($appdt,0,10));
  1669. $num = str_replace('Ymd',$apdt,$num);
  1670. return $this->db->sericnum($num,'[Q]'.$this->mtable.'', $fid, $wshu);
  1671. }
  1672. /**
  1673. * 录入页上编号
  1674. */
  1675. public function createinputnum($num, $fid)
  1676. {
  1677. $acta = '';
  1678. if(method_exists($this, $num)){
  1679. $acta = $num;
  1680. }else{
  1681. if(contain($num, ',')){
  1682. $arra = explode(',', $num);
  1683. $acta = $arra[0];
  1684. $num = $arra[1];
  1685. }
  1686. }
  1687. if($acta && method_exists($this, $acta)){
  1688. $barr = $this->$acta($num);
  1689. if(is_array($barr)){
  1690. $qom = arrvalue($barr, 'qom', $num);//前缀
  1691. $wshu= arrvalue($barr, 'wshu', 3);//位数
  1692. $bom = arrvalue($barr, 'bom');//后缀
  1693. $fields = arrvalue($barr, 'fields', $fid);
  1694. return $this->createbianhao($qom, $fields, $wshu).$bom;
  1695. }else{
  1696. if(isempt($barr))$barr = $num;
  1697. return $this->createbianhao($barr, $fid);
  1698. }
  1699. }else{
  1700. return $this->createbianhao($num, $fid);
  1701. }
  1702. }
  1703. /**
  1704. * 创建流程单号
  1705. */
  1706. public function createnum()
  1707. {
  1708. $num = $this->moders['sericnum'];
  1709. if($num=='无'||$this->isempt($num))$num='TM-Ymd-';
  1710. @$appdt = $this->rs['applydt'];
  1711. if(isempt($appdt))$appdt = $this->rock->date;
  1712. $apdt = str_replace('-','', $appdt);
  1713. $num = str_replace('Ymd',$apdt,$num);
  1714. return $this->db->sericnum($num,'[Q]flow_bill', 'sericnum', 3);
  1715. }
  1716. public function savebill($oarr=array())
  1717. {
  1718. $dbs = $this->billmodel;
  1719. $whes= $this->mwhere;
  1720. $birs= $dbs->getone($whes);
  1721. $arr = array(
  1722. 'table' => $this->mtable,
  1723. 'mid' => $this->id,
  1724. 'optdt' => isset($this->rs['optdt']) ? $this->rs['optdt'] : $this->rock->now,
  1725. 'optname' => $this->adminname,
  1726. 'optid' => $this->adminid,
  1727. 'modeid' => $this->modeid,
  1728. 'updt' => $this->rock->now,
  1729. 'isturn' => $this->rs['isturn'],
  1730. 'nstatus' => $this->rs['status'],
  1731. 'applydt' => $this->rs['applydt'],
  1732. 'modename' => $this->modename,
  1733. 'uname' => $this->rs['base_name'],
  1734. 'udeptname' => $this->rs['base_deptname'],
  1735. 'uid' => $this->uid,
  1736. 'isdel' => '0',
  1737. );
  1738. foreach($oarr as $k=>$v)$arr[$k]=$v;
  1739. if(!$birs){
  1740. $arr['status'] = $arr['nstatus'];
  1741. $arr['createdt']= $arr['optdt'];
  1742. $arr['sericnum']= $this->createnum();
  1743. $arr['udeptid'] = $this->rock->post('sysudeptid', $this->urs['deptid']);
  1744. $whes = '';
  1745. $this->sericnum = $arr['sericnum'];
  1746. }else{
  1747. $udeptid = $birs['udeptid'];
  1748. if($udeptid==0)$arr['udeptid']=$this->urs['deptid'];
  1749. }
  1750. $dbs->record($arr, $whes);
  1751. return $arr;
  1752. }
  1753. /**
  1754. * 获取摘要
  1755. */
  1756. public function getsummary()
  1757. {
  1758. return $this->rock->reparr($this->moders['summary'], $this->rs);
  1759. }
  1760. public function addcheckname($courseid, $uid, $uname, $onbo=false, $addlx=0)
  1761. {
  1762. if(isempt($uid)){$uid = '0';$uname= 'auto';}
  1763. $uida = explode(',', ''.$uid.'');
  1764. $uidan = explode(',', $uname);
  1765. if($onbo)$this->checksmodel->delete($this->mwhere.' and `courseid`='.$courseid.'');
  1766. if($uida)foreach($uida as $k=>$uid){
  1767. $uname = $this->rock->arrvalue($uidan, $k);
  1768. $zyarr = array(
  1769. 'table' => $this->mtable,
  1770. 'mid' => $this->id,
  1771. 'modeid' => $this->modeid,
  1772. 'courseid' => $courseid,
  1773. 'optid' => $this->adminid,
  1774. 'optname' => $this->adminname,
  1775. 'addlx' => $addlx, //添加类型:1自定义,2撤回添加,3退回添加,4转移添加,5自由流程,6选择流程,7监控转办
  1776. 'optdt' => $this->rock->now,
  1777. 'status' => 0
  1778. );
  1779. $this->checksmodel->delete($this->mwhere.' and `checkid`='.$uid.' and `courseid`='.$courseid.'');
  1780. $zyarr['checkid'] = $uid;
  1781. $zyarr['checkname'] = $uname;
  1782. $this->checksmodel->insert($zyarr);
  1783. }
  1784. if($addlx==4)$this->checksmodel->delete($this->mwhere.' and `checkid`='.$this->adminid.' and `courseid`='.$courseid.'');//删除别人转给我的
  1785. }
  1786. /**
  1787. * 判断保存的数据是否
  1788. */
  1789. public function savedatastr($fval, $farr, $data=array())
  1790. {
  1791. $str = '';
  1792. if(!$farr)return $str;
  1793. $savewhere = $farr['savewhere'];
  1794. $name = $farr['name'];
  1795. $types = $farr['fieldstype'];
  1796. if(isempt($savewhere) || isempt($fval))return $str;
  1797. $savewhere = str_replace(array('{0}','{date}','{now}'), array($name, $this->rock->date,$this->rock->now), $savewhere);
  1798. $savewhere = $this->rock->reparr($savewhere, $data);
  1799. $saees = explode(',', $savewhere);
  1800. if($types=='date' || $types=='datetime')$fval = strtotime($fval);
  1801. if($types=='number')$fval = floatval($fval);
  1802. foreach($saees as $saeess){
  1803. $fsaed = explode('|', $saeess);
  1804. $msg = isset($fsaed[2]) ? $fsaed[2] : ''.$name.'数据不符号';
  1805. $val = isset($fsaed[1]) ? $fsaed[1] : '';
  1806. $lfs = $fsaed[0];
  1807. if($val != ''){
  1808. if($types=='date' || $types=='datetime')$val = strtotime($val);
  1809. if($types=='number')$val = floatval($val);
  1810. if($lfs=='gt'){$bo = $fval>$val;if(!$bo)return $msg;}
  1811. if($lfs=='egt'){$bo = $fval>=$val;if(!$bo)return $msg;}
  1812. if($lfs=='lt'){$bo = $fval<$val;if(!$bo)return $msg;}
  1813. if($lfs=='elt'){$bo = $fval<=$val;if(!$bo)return $msg;}
  1814. if($lfs=='eg'){$bo = $fval==$val;if(!$bo)return $msg;}
  1815. if($lfs=='neg'){$bo = $fval!=$val;if(!$bo)return $msg;}
  1816. }
  1817. }
  1818. return $str;
  1819. }
  1820. /**
  1821. * 重写更新一下方法
  1822. */
  1823. public function update($arr, $where)
  1824. {
  1825. if(is_array($arr)){
  1826. foreach($arr as $k=>$v)$this->rs[$k]=$v;
  1827. }
  1828. return parent::update($arr,$where);
  1829. }
  1830. /**
  1831. * 将操作记录标识无效状态
  1832. */
  1833. public function updatelogvalid($whe)
  1834. {
  1835. $this->flogmodel->update('valid=0', $this->mwhere.' '.$whe);
  1836. }
  1837. /**
  1838. * 说明追加
  1839. */
  1840. public function strappend($sm, $str, $fh=',')
  1841. {
  1842. if(isempt($str))return $sm;
  1843. if(!isempt($sm))$sm.=$fh;
  1844. $sm.=$str;
  1845. return $sm;
  1846. }
  1847. /**
  1848. * 异常直接标识已完成
  1849. */
  1850. public function checkerror($lx=1,$sm='')
  1851. {
  1852. if($sm=='')$sm='单据异常管理员处理';
  1853. $msg = $this->check($lx, $sm, 1);
  1854. return $msg;
  1855. }
  1856. /**
  1857. * 提交审核处理
  1858. * $zt 状态 $sm 说明 $lx=0默认1异常标识
  1859. */
  1860. public function check($zt, $sm='', $lx=0)
  1861. {
  1862. if($this->rs['status']==1)return '流程已处理完成,无需操作';
  1863. $arr = $this->getflow();
  1864. $flowinfor = $this->getflowinfor();
  1865. if($flowinfor['ischeck']==0 && $lx==0)return '当前是['.$arr['nowcheckname'].']处理';
  1866. $nowcourse = $this->nowcourse; //当前步骤信息
  1867. //异常的审核
  1868. if($lx==1){
  1869. if($arr['nowcourseid']!=0)return '当前有审核步骤ID是存在的不能直接标识已完成';
  1870. $to = $this->flogmodel->rows($this->mwhere.' and `courseid`>0 and `status`=1');
  1871. if($to==0)return '该单据没有任何通过审核处理不能直接标识已完成或已审核';
  1872. $nowcourse = array('id'=>66666,'name'=>'异常处理','step'=>0);
  1873. }
  1874. $nextcourse = $this->nextcourse;
  1875. $zynameid = $this->rock->post('zynameid');
  1876. $zyname = $this->rock->post('zyname');
  1877. $csnameid = '';
  1878. $csname = '';
  1879. $nextname = $this->rock->post('nextname');
  1880. $nextnameid = $this->rock->post('nextnameid');
  1881. $qmimgstr = $this->rock->post('qmimgstr'); //签名图片
  1882. $tuiid = (int)$this->rock->post('tuiid'); //退回到哪个flowlog.id上
  1883. $iszhuanyi = $ischangenext = 0;
  1884. if($zt==1 && $this->isflow!=3 && isempt($zynameid) && arrvalue($nextcourse,'checktype')=='change'){
  1885. $ischangenext = 1;//需要选下步处理人
  1886. }
  1887. if($zt!=2)$tuiid = 0;//只有2的状态才能退回
  1888. $istongyi = in_array($zt, $this->flowstatusarr); //是否审核本步骤同意
  1889. //判断是否转办
  1890. if($zynameid!='' && $istongyi){
  1891. if($zynameid==$this->adminid)return '不能转给自己';
  1892. $sm = $this->strappend($sm, '转给:'.$zyname.'');
  1893. $iszhuanyi = 1;
  1894. $this->rs['syszb_name'] = $zyname;
  1895. $this->rs['syszb_nameid'] = $zynameid;
  1896. }
  1897. //--autharstart--
  1898. $csnameid = $this->rock->post('csnameid');
  1899. $csname = $this->rock->post('csname');
  1900. if(arrvalue($nowcourse,'cslx')=='2' && $csnameid=='' && $istongyi)return '必须选择抄送对应人';
  1901. if(arrvalue($nowcourse,'cslx')=='3' && $istongyi){
  1902. $csfwid = arrvalue($nowcourse,'csfwid');
  1903. $csfwname = arrvalue($nowcourse,'csfwname');
  1904. if(!isempt($csfwid)){
  1905. if(contain($csfwid,'super')){
  1906. $_super = $this->adminmodel->getsuperman($this->adminid);
  1907. $csfwid = str_replace('super', $_super[0], $csfwid);
  1908. $csfwname = str_replace('审批人直属上级', $_super[1], $csfwname);
  1909. if(substr($csfwid,0,1)==','){$csfwid = substr($csfwid, 1);$csfwname = substr($csfwname, 1);}
  1910. }
  1911. $csnameid = $this->adminmodel->gjoins($csfwid);
  1912. $csname = $csfwname;
  1913. }
  1914. }
  1915. $this->rs['syscs_name'] = $csname;
  1916. $this->rs['syscs_nameid'] = $csnameid;
  1917. //--autharend--
  1918. if($nextnameid=='' && $ischangenext==1)return '请选择下一步处理人';
  1919. $ufied = array();
  1920. if($iszhuanyi == 0 && $zt!=2){
  1921. foreach($flowinfor['checkfields'] as $chef=>$chefv){
  1922. $ufied[$chef] = $this->rock->post('cfields_'.$chef.'');
  1923. if(isempt($ufied[$chef]) && $chefv['isbt']=='1')$this->echomsg(''.$chefv['name'].'不能为空');
  1924. $_str = $this->savedatastr($ufied[$chef], $chefv['fieldsarr'], $this->rs);
  1925. if($_str!='')$this->echomsg($_str);
  1926. }
  1927. }
  1928. $this->checkiszhuanyi = $iszhuanyi;//是否为转办
  1929. $barr = $this->flowcheckbefore($zt, $ufied, $sm);
  1930. $msg = '';
  1931. if(is_array($barr) && isset($barr['msg']))$msg = $barr['msg'];
  1932. //更新字段
  1933. if(is_array($barr) && isset($barr['update'])){
  1934. foreach($barr['update'] as $_k=>$_v)$ufied[$_k] = $_v;
  1935. }
  1936. if(is_string($barr))$msg = $barr;
  1937. if(!isempt($msg))return $msg;
  1938. if($ufied){
  1939. $bo = $this->update($ufied, $this->id);
  1940. if(!$bo)return 'dberr:'.$this->db->error();
  1941. }
  1942. $courseact = $flowinfor['courseact'];
  1943. $act = $courseact[$zt];
  1944. $statusname = $act[0];//状态名称
  1945. $statuscolor= $act[1];//状态颜色
  1946. $nzt = $act[2];//处理后对应状态
  1947. $courseid = $nowcourse['id'];
  1948. $this->checksmodel->update('`status`='.$zt.'', $this->mwhere.' and `checkid`='.$this->adminid.' and `courseid`='.$courseid.'');
  1949. if($iszhuanyi == 1){
  1950. $this->addcheckname($courseid, $zynameid, $zyname, false, 4);
  1951. $nowcourse['id'] = 0;
  1952. }
  1953. //指定下步审核
  1954. if($ischangenext==1){
  1955. $this->addcheckname($nextcourse['id'], $nextnameid, $nextname, true, 1);
  1956. }
  1957. //读取退回记录
  1958. $tuirs = array();
  1959. if($tuiid > 0)$tuirs = $this->flogmodel->getone($tuiid);
  1960. if(!$tuirs)$tuiid = 0;
  1961. if($tuiid>0){
  1962. $sm = $this->strappend($sm, '退回到['.$tuirs['name'].'('.$tuirs['checkname'].')]');
  1963. $statusname = '退回';
  1964. $statuscolor = '#17B2B7';
  1965. }
  1966. $this->checkistui = $tuiid;//是否为退回的
  1967. $logsm = $sm;
  1968. if($iszhuanyi==0 && $csname)$logsm = $this->strappend($logsm,'抄送给:'.$csname.'');
  1969. $this->lastlogid = $this->addlog(array(
  1970. 'courseid' => $nowcourse['id'],
  1971. 'name' => $nowcourse['name'],
  1972. 'step' => $nowcourse['step'],
  1973. 'status' => $zt,
  1974. 'statusname'=> $statusname,
  1975. 'color' => $statuscolor,
  1976. 'explain' => $logsm,
  1977. 'iszb' => $iszhuanyi,
  1978. 'qmimg' => $qmimgstr
  1979. ));
  1980. //退回处理
  1981. if($tuiid > 0){
  1982. $this->addcheckname($tuirs['courseid'], $tuirs['checkid'], $tuirs['checkname'], true, 3);
  1983. $this->updatelogvalid('and `courseid`>0 and `status`=1 and `step`>='.$tuirs['step'].'');
  1984. }
  1985. $lzt = $this->rock->repempt($nzt, $zt);//最后状态
  1986. $uparr = $nexttodoarr = $nexttodoarc = array();
  1987. $bsarr = $this->getflow();
  1988. $bsarr['tuiid'] = $tuiid;
  1989. $nextcheckid = $bsarr['nowcheckid']; //下一步审核人
  1990. if($istongyi){//同意
  1991. if($iszhuanyi==0){
  1992. $uparr['status']= $this->rock->repempt($nzt,'0');
  1993. }
  1994. $nexttodoarr = array($nextcheckid, 'next', $sm, $statusname);//通知下一步处理人
  1995. }else{
  1996. if($tuiid>0){
  1997. $lzt = 23; //退回固定状态23
  1998. $nexttodoarr = array($nextcheckid, 'tui', $sm, $statusname); //通知到退回的人员
  1999. }elseif($zt==2){//2固定不同意
  2000. $nexttodoarr = array($this->optid, 'nothrough', $sm, $statusname);
  2001. }
  2002. $uparr['status'] = $lzt;
  2003. }
  2004. $this->flowcheckafter($zt, $sm, $nowcourse);
  2005. $bsarr['nstatus'] = $lzt;
  2006. $bsarr['checksm'] = $sm;
  2007. //没有当前步骤就是结束完成了
  2008. if(!$this->nowcourse){
  2009. $uparr['status'] = $lzt;
  2010. $nexttodoarc = array($this->optid, 'finish', $sm, '');
  2011. }
  2012. //最后状态更新
  2013. if($uparr){
  2014. $this->update($uparr, $this->id);
  2015. }
  2016. //审核完成了调用对应函数接口
  2017. if(!$this->nowcourse){
  2018. $this->flowcheckfinsh($zt);
  2019. if($istongyi){
  2020. $this->checksmodel->delete($this->mwhere);//完成了删除设置审核人
  2021. }
  2022. }
  2023. $bsarr['status'] = $this->rs['status'];//状态
  2024. $this->getflowsave($bsarr, true);
  2025. //通知给相应人员
  2026. if($this->db->backsql()){
  2027. $bos = ($courseid == arrvalue($this->nowcourse, 'id') && $istongyi);
  2028. if($nexttodoarr && (!$bos || $iszhuanyi==1))$this->nexttodo($nexttodoarr[0],$nexttodoarr[1],$nexttodoarr[2],$nexttodoarr[3]);
  2029. if($nexttodoarc)$this->nexttodo($nexttodoarc[0],$nexttodoarc[1],$nexttodoarc[2],$nexttodoarc[3]);
  2030. }
  2031. //通知发送的
  2032. if($iszhuanyi == 1){
  2033. $this->gettodosend('bozhuan','', $sm, 0, ''.$this->adminname.'将['.$nowcourse['name'].']转给:'.$zyname.'');
  2034. }else{
  2035. if($istongyi)$this->gettodosend('botong', $statusname, $sm, $nowcourse['id']);
  2036. if($zt==2)$this->gettodosend('bobutong',$statusname, $sm, $nowcourse['id']);
  2037. if(!$this->nowcourse && $istongyi)$this->gettodosend('bofinish', '', $sm); //全部完成了
  2038. }
  2039. //通知给抄送人,转办不需要抄送
  2040. if($iszhuanyi==0){
  2041. $sm1 = '在“'.$nowcourse['name'].'”处理'.$statusname.'';
  2042. $this->savecsname($csnameid,$csname,$this->adminid,$nowcourse['id'],1, $sm1);
  2043. }
  2044. return 'ok';
  2045. }
  2046. public function pushs($receid, $cont, $title='', $params=array())
  2047. {
  2048. return $this->push($receid,'', $cont, $title, 0, $params);
  2049. }
  2050. /**
  2051. * 详情的URL
  2052. */
  2053. public function getxiangurl($num='', $id=0, $lx='x')
  2054. {
  2055. if($num=='')$num = $this->modenum;
  2056. if($id==0)$id = $this->id;
  2057. $url = URL;
  2058. if($lx=='auto')$lx = ($this->ismobile==1)?'x':'p';
  2059. if($lx=='x' || $lx=='a')$url = $this->rock->getouturl();//移动端
  2060. $url = ''.$url.'task.php?a='.$lx.'&num='.$num.'&mid='.$id.'';
  2061. if(COMPANYNUM)$url.='&dwnum='.COMPANYNUM.'';
  2062. return $url;
  2063. }
  2064. public function getxiangurlx($num='',$id=0){return $this->getxiangurl($num,$id,'x');}
  2065. /**
  2066. * 推送提醒
  2067. */
  2068. public function push($receid, $gname='', $cont='', $title='', $wkal=0, $params=array())
  2069. {
  2070. if(isempt($receid) && $wkal==1)$receid='all';
  2071. if(isempt($receid))return false;
  2072. if(contain(','.$receid.',', ',d1,'))$receid='all'; //如果选顶级d1就是全员
  2073. $modenum = arrvalue($params, 'modenum', $this->modenum);
  2074. $modename = arrvalue($params, 'modename', $this->modename);
  2075. $id = (int)arrvalue($params, 'id', $this->id);
  2076. $moders = arrvalue($params, 'moders');
  2077. if(!is_array($moders))$moders = $this->moders;
  2078. if($gname=='')$gname = $modename;
  2079. $reim = m('reim');
  2080. $url = $this->getxiangurl($modenum, $id, 'p');
  2081. $wxurl = $this->getxiangurl($modenum, $id, 'x');
  2082. $emurl = $this->getxiangurl($modenum, $id, 'a');
  2083. if($id==0){
  2084. $url = '';$wxurl = '';$emurl='';
  2085. }
  2086. $url = arrvalue($params, 'url', $url); //PC上URL
  2087. $wxurl = arrvalue($params, 'wxurl', $wxurl); //移动端URL
  2088. $emurl = arrvalue($params, 'emurl', $emurl); //邮件上URL
  2089. $slx = 0;
  2090. $pctx = $moders['pctx'];
  2091. $mctx = $moders['mctx'];
  2092. $wxtx = $moders['wxtx'];
  2093. $ddtx = $moders['ddtx'];
  2094. $emtx = $moders['emtx'];
  2095. if($pctx==0 && $mctx==1)$slx=2;
  2096. if($pctx==1 && $mctx==0)$slx=1;
  2097. if($pctx==0 && $mctx==0)$slx=3;
  2098. $this->rs['now_adminname'] = $this->adminname;
  2099. $this->rs['now_modename'] = $modename;
  2100. $cont = $this->rock->reparr($cont, $this->rs);
  2101. $receid = $this->adminmodel->gjoins($receid);//已经返回对应人id了
  2102. $uids = m('todo')->addtodo($receid, $modename, $cont, $modenum, $id);
  2103. if($uids!='' && $moders['type'] != '系统' && $id > 0)$this->todosmodel->addtotouids($uids, array(
  2104. 'table' => $moders['table'],
  2105. 'mid' => $id,
  2106. 'modename' => $modename,
  2107. 'modenum' => $modenum,
  2108. ));
  2109. $title = $this->rock->reparr($title, $this->rs);
  2110. $reim->pushagent($uids, $gname, $cont, $title, $url, $wxurl, $slx, ''.$modenum.'|'.$id.'');
  2111. $this->flowchangetodo($uids, $gname);
  2112. if(isempt($title))$title = $modename;
  2113. //--autharstart--
  2114. //邮件提醒发送不发送全体人员的,太多了
  2115. if($emtx == 1 && $receid != 'all'){
  2116. $emcont = '您好:<br>'.$cont.'(邮件由系统自动发送)';
  2117. if($emurl!=''){
  2118. $emcont.='<br><a href="'.$emurl.'" target="_blank" style="color:blue"><u>详情&gt;&gt;</u></a>';
  2119. }
  2120. $msg = m('email')->sendmail($title, $emcont, $receid);
  2121. if($msg!='ok')m('log')->addlogs('邮件', $msg , 2);
  2122. }
  2123. //微信提醒发送
  2124. $isptbo = $reim->installwx(5);
  2125. if($wxtx==1 || $isptbo){
  2126. $wxarra = $this->flowweixinarr;
  2127. $wxarr = array(
  2128. 'title' => $title,
  2129. 'description' => $cont,
  2130. 'url' => $wxurl
  2131. );
  2132. $picurl = arrvalue($this->rs, 'fengmian');
  2133. if($picurl != ''){
  2134. if(substr($picurl,0,4) != 'http')$picurl = URL.$picurl;
  2135. $wxarr['picurl'] = $picurl;
  2136. }
  2137. foreach($wxarra as $k=>$v)$wxarr[$k]=$v;
  2138. //REIM即时通讯平台
  2139. if($isptbo){
  2140. $sarr = $wxarr;
  2141. $sarr['url'] = $emurl;
  2142. m('reimplat:agent')->sendxiao($receid, $gname, $sarr);
  2143. }
  2144. //企业微信提醒
  2145. if($reim->installwx(1) && $wxtx==1){
  2146. $gnames = $gname;
  2147. if($gname != $modename)$gnames =''.$modename.','.$gname.'';
  2148. $devagent = $this->option->getval('weixinqy_devagent');
  2149. if(isempt($devagent))$devagent = '办公助手';
  2150. $barr = m('weixinqy:index')->sendxiao($receid, ''.$gnames.','.$devagent.'', $wxarr);
  2151. m('log')->todolog('企业微信提醒', $barr);
  2152. }
  2153. //微信公众号
  2154. if(($gname=='流程待办' || $gname=='流程申请') && $wxtx==1 && $reim->installwx(4)){
  2155. $zta = $this->getnowstatus();
  2156. $barr = m('wxgzh:index')->send($receid, '流程待办', array(
  2157. 'url' => $wxurl,
  2158. 'applyname' => $this->rs['base_name'],
  2159. 'deptname' => $this->rs['base_deptname'],
  2160. 'sericnum' => $this->sericnum,
  2161. 'title' => $title,
  2162. 'explain' => $cont,
  2163. 'modename' => $this->modename,
  2164. 'optname' => $this->adminname,
  2165. 'optdt' => $this->rock->now,
  2166. 'statustext' => $zta[0],
  2167. 'statustext_color' => $zta[1],
  2168. 'applydt' => arrvalue($this->billrs, 'applydt', $this->rock->date),
  2169. 'summary' => $this->getsummary(),
  2170. ));
  2171. m('log')->todolog('微信模版消息', $barr);
  2172. }
  2173. }
  2174. //钉钉提醒发送
  2175. if($ddtx==1 && $reim->installwx(2)){
  2176. $barr = m('dingding:index')->sendoa($receid, $gname, array(
  2177. 'title' => $title,
  2178. 'content' => $cont,
  2179. 'wxurl' => arrvalue($this->flowweixinarr, 'url', $wxurl),
  2180. 'modename' => $modename
  2181. ));
  2182. m('log')->todolog('钉钉提醒', $barr);
  2183. }
  2184. //--autharend--
  2185. $this->flowweixinarr=array();
  2186. return $receid;
  2187. }
  2188. /**
  2189. * 下一步发通知
  2190. */
  2191. public function nexttodo($nuid, $type, $sm='', $act='')
  2192. {
  2193. $cont = '';
  2194. $tit = '';
  2195. $gname = '流程待办';
  2196. $summary= $this->getsummary();
  2197. if($type=='submit' || $type=='next' || $type == 'cuiban'){
  2198. $cont = '你有['.$this->uname.']的['.$this->modename.',单号:'.$this->sericnum.']需要处理';
  2199. if($sm!='')$cont.=',说明:'.$sm.'';
  2200. $tit = ''.$this->uname.'的'.$this->modename.'';
  2201. //短信提醒
  2202. if($type != 'cuiban'){
  2203. $txnum = $this->option->getval('sms_txnum');
  2204. if(!isempt($txnum)){
  2205. $mknum = $this->option->getval('sms_mknum');
  2206. if($mknum=='all' || contain(','.$mknum.',',','.$this->modenum.',')){
  2207. $wxurl = $this->getxiangurlx();
  2208. $farr = $this->getflow();
  2209. $barr = c('xinhuapi')->sendsms($nuid, '', $txnum, array(
  2210. 'modename' => $this->modename,
  2211. 'sericnum' => $this->sericnum,
  2212. 'applyname'=> $this->uname,
  2213. 'deptname' => $this->rs['base_deptname'],
  2214. 'name' => $farr['nowcheckname'],
  2215. 'userName' => $this->uname,
  2216. 'orderName'=> $this->modename,
  2217. ),$wxurl);
  2218. }
  2219. }
  2220. }
  2221. $type = 'daiban';
  2222. }
  2223. //审核不同意
  2224. if($type == 'nothrough'){
  2225. $cont = '你提交['.$this->modename.',单号:'.$this->sericnum.']'.$this->adminname.'处理['.$act.'],原因:['.$sm.']';
  2226. $gname= '流程申请';
  2227. $tit = ''.$this->modename.'处理'.$act.'';
  2228. }
  2229. if($type == 'finish'){
  2230. $cont = '你提交的['.$this->modename.',单号:'.$this->sericnum.']已全部处理完成';
  2231. $gname= '流程申请';
  2232. $tit = ''.$this->modename.'全部处理完成';
  2233. }
  2234. if($type == 'zhui'){
  2235. $cont = ''.$this->adminname.'追加单据说明['.$this->modename.',单号:'.$this->sericnum.'],说明:['.$sm.']';
  2236. }
  2237. //退回
  2238. if($type == 'tui'){
  2239. $cont = '['.$this->adminname.']退回单据['.$this->modename.',单号:'.$this->sericnum.']到你这请及时处理,说明:'.$sm.'';
  2240. }
  2241. //提交抄送
  2242. if($type == 'chao'){
  2243. $cont = ''.$this->adminname.''.$sm.'了“'.$this->modename.'”';
  2244. if(!isempt($summary))$cont.=',摘要“'.$summary.'”';
  2245. if($this->isflow>0)$cont.=',单号“'.$this->sericnum.'”';
  2246. $gname= '';
  2247. $tit = ''.$this->modename.'的单据抄送';
  2248. }
  2249. //评论
  2250. if($type=='pinglun'){
  2251. $cont = ''.$this->adminname.''.$act.'你的['.$this->modename.']单据,说明:'.$sm.'';
  2252. $gname = '';
  2253. $tit = ''.$this->modename.'评论';
  2254. }
  2255. //回执确认
  2256. if($type=='receipt'){
  2257. $cont = ''.$this->adminname.''.$act.'['.$this->modename.']的单据';
  2258. if($sm!='')$cont.=',说明:'.$sm.'';
  2259. $gname = '回执确认';
  2260. $tit = ''.$this->modename.'回执确认';
  2261. }
  2262. $nbis = $this->flownexttodo($type); //自定义推送内容
  2263. if($nbis){
  2264. if(is_string($nbis))$cont = $nbis;
  2265. if(is_array($nbis)){
  2266. $tit = arrvalue($nbis, 'title', $tit);
  2267. $gname = arrvalue($nbis, 'gname', $gname);
  2268. $cont = arrvalue($nbis, 'cont', $cont);
  2269. }
  2270. }
  2271. if($cont!='')$this->push($nuid, $gname, $cont, $tit);
  2272. }
  2273. public function getwxurl($num='')
  2274. {
  2275. if($num=='')$num = $this->modenum;
  2276. $url = $this->rock->getouturl();
  2277. $str = ''.$url.'?m=ying&d=we&num='.$num.'';
  2278. return $str;
  2279. }
  2280. /**
  2281. * 模块移动端url
  2282. */
  2283. public function getweurl($num='')
  2284. {
  2285. if($num=='')$num = $this->modenum;
  2286. $url = $this->rock->getouturl();
  2287. $str = ''.$url.'?m=ying&d=we&mnum='.$num.'';
  2288. return $str;
  2289. }
  2290. /**
  2291. * 删除单据
  2292. */
  2293. public function deletebill($sm='', $qxpd=true)
  2294. {
  2295. if(getconfig('systype')=='demo')return '演示请勿删除';
  2296. if($qxpd){
  2297. $is = $this->isdeleteqx();
  2298. if($is==0)return '无权删除';
  2299. }
  2300. //删除前判断
  2301. if(method_exists($this,'flowdeletebillbefore')){
  2302. $bstr = $this->flowdeletebillbefore($sm);
  2303. if(!isempt($bstr))return $bstr;
  2304. }
  2305. $modewhere = "`modenum`='".$this->modenum."' and `mid`=".$this->id."";
  2306. $this->flogmodel->delete($this->mwhere);
  2307. m('reads')->delete($this->mwhere);
  2308. m('file')->delfiles($this->mtable, $this->id);
  2309. $tables = $this->moders['tables'];
  2310. if(!isempt($tables)){
  2311. $arrse = explode(',', $tables);
  2312. foreach($arrse as $arrses)m($arrses)->delete('mid='.$this->id.'');
  2313. }
  2314. $this->billmodel->delete($this->mwhere);
  2315. $this->todosmodel->delete($this->mwhere);
  2316. $this->checksmodel->delete($this->mwhere);
  2317. $this->chaomodel->delete($this->mwhere);
  2318. m('remind')->delete($this->mwhere); //单据提醒的
  2319. m('todo')->delete($this->mwhere);
  2320. m('todo')->delete($modewhere);
  2321. m('receipt')->delete($this->mwhere); //回执
  2322. m('im_history')->delete("`xgurl`='".$this->modenum."|".$this->id."'");
  2323. $this->delete($this->id);
  2324. $this->flowdeletebill($sm);
  2325. $this->flowzuofeibill($sm);
  2326. $this->gettodosend('bodel','', $sm);
  2327. $dels = '删除模块['.$this->modename.']id为'.$this->id.'的单据';
  2328. $ztss = arrvalue($this->rs,'base_summary');
  2329. if(!isempt($ztss))$dels.=',摘要['.$ztss.']';
  2330. if(!isempt($sm))$dels.=',说明:'.$sm.'';
  2331. m('log')->addlogs('删除单据', $dels, 3);
  2332. foreach($this->wherejoin as $num=>$fields){
  2333. $this->deletebilljoin($num, "`$fields`='$this->id'", $sm);
  2334. }
  2335. return 'ok';
  2336. }
  2337. /**
  2338. * 关联删除
  2339. */
  2340. public function deletebilljoin($num, $where, $sm='')
  2341. {
  2342. $flow = m('flow')->initflow($num);
  2343. $rows = $flow->getall($where);
  2344. foreach($rows as $k1=>$rs1){
  2345. $mid = $rs1['id'];
  2346. $flow->loaddata($mid, false);
  2347. $flow->deletebill($sm, false);
  2348. }
  2349. }
  2350. /**
  2351. * 关联作废
  2352. */
  2353. public function zuofeibilljoin($num, $where, $sm='')
  2354. {
  2355. $flow = m('flow')->initflow($num);
  2356. $rows = $flow->getall($where);
  2357. foreach($rows as $k1=>$rs1){
  2358. $mid = $rs1['id'];
  2359. $flow->loaddata($mid, false);
  2360. $flow->zuofeibill($sm);
  2361. }
  2362. }
  2363. /**
  2364. * 单据作废处理
  2365. */
  2366. public function zuofeibill($sm='')
  2367. {
  2368. $this->addlog(array(
  2369. 'explain' => $sm,
  2370. 'name' => '作废',
  2371. 'status' => 1,
  2372. ));
  2373. $this->update('`status`=5', $this->id);
  2374. $zfarr = array(
  2375. 'status' => 5,
  2376. 'nstatus' => 5,
  2377. 'checksm' => '作废:'.$sm.'',
  2378. 'nowcheckid' => '',
  2379. 'nowcheckname' => '',
  2380. 'nstatustext' => '作废',
  2381. 'updt' => $this->rock->now,
  2382. );
  2383. $this->billmodel->update($zfarr, $this->mwhere);
  2384. $tables = $this->moders['tables'];
  2385. if(!isempt($tables)){
  2386. $arrse = explode(',', $tables);
  2387. foreach($arrse as $arrses)m($arrses)->delete('mid='.$this->id.'');
  2388. }
  2389. $this->flowzuofeibill($sm);
  2390. $this->gettodosend('bozuofei','', $sm);
  2391. foreach($this->wherejoin as $num=>$fields){
  2392. $this->zuofeibilljoin($num, "`$fields`='$this->id'", $sm);
  2393. }
  2394. return 'ok';
  2395. }
  2396. /**
  2397. * 对外接口详情页加载数据
  2398. */
  2399. public function openxiang()
  2400. {
  2401. $xiangdata = $btndata = array();
  2402. $data = $this->flowrsreplace($this->rs,4);
  2403. foreach($this->fieldsarra as $k=>$rs){
  2404. if($rs['iszs']=='1'){
  2405. $xiangdata[] = array(
  2406. 'name' => $rs['name'],
  2407. 'fields'=> $rs['fields'],
  2408. 'value' => $this->rock->repempt(arrvalue($data,$rs['fields']))
  2409. );
  2410. }
  2411. }
  2412. $barr['xiangdata'] = $xiangdata;
  2413. $btnrows = $this->db->getrows('[Q]flow_menu',"`setid`='$this->modeid' and `status`=1 and `num` like 'open%'",'id,wherestr,name,num,issm,type','`sort`');
  2414. foreach($btnrows as $k=>$rs){
  2415. $wherestr = $rs['wherestr'];
  2416. $bo = false;
  2417. if(isempt($wherestr)){
  2418. $bo = true;
  2419. }else{
  2420. $ewet = $this->wheremodel->getstrwhere($this->rock->jm->base64decode($wherestr));
  2421. $ewet = str_replace(array('{asqom}','1=2 and'),'', $ewet);
  2422. $tos = $this->rows("`id`='$this->id' and $ewet");
  2423. if($tos>0)$bo = true;
  2424. }
  2425. if($bo)$btndata[] = array(
  2426. 'id' => $rs['id'],
  2427. 'name' => $rs['name'],
  2428. 'issm' => $rs['issm'],
  2429. );
  2430. }
  2431. $barr['btndata'] = $btndata;
  2432. if(method_exists($this,'flowopenxiang')){
  2433. $lbarr = $this->flowopenxiang($data,$xiangdata,$btndata);
  2434. if(is_array($lbarr))foreach($lbarr as $k=>$v)$barr[$k]=$v;
  2435. }
  2436. return $barr;
  2437. }
  2438. /**
  2439. * 短信催办,需要有短信功能
  2440. */
  2441. public function smschuiban($sm='')
  2442. {
  2443. //有流程和是我催办
  2444. if($this->isflow>0 && $this->adminid==$this->uid){
  2445. $farr = $this->getflow(true);
  2446. $nowcheckid = $farr['nowcheckid']; //当前处理人
  2447. $tplnum = $this->option->getval('sms_cbnum','defnum');//短信模版
  2448. $wxurl = $this->getxiangurlx();
  2449. $barr = c('xinhuapi')->sendsms($nowcheckid, '', $tplnum, array(
  2450. 'modename' => $this->modename,
  2451. 'sericnum' => $this->sericnum,
  2452. 'applyname'=> $this->uname,
  2453. 'deptname' => $this->rs['base_deptname'],
  2454. ),$wxurl, false, false);//短信催办不需要日志和异步
  2455. if(!$barr['success'])return $barr['msg'];
  2456. $this->addlog(array(
  2457. 'explain' => $sm,
  2458. 'name' => '短信催办',
  2459. 'status' => 1,
  2460. ));
  2461. }
  2462. return 'ok';
  2463. }
  2464. /**
  2465. * 加入日程提醒
  2466. */
  2467. public function addschedule($sm='')
  2468. {
  2469. $txdt = $this->rock->post('txdt');
  2470. if(isempt($sm))return '说明不能为空';
  2471. if(isempt($txdt))return '提醒时间不能为空';
  2472. $barr['title'] = $sm;
  2473. $barr['startdt'] = $txdt;
  2474. $barr['uid'] = $this->adminid;
  2475. $barr['optdt'] = $this->rock->now;
  2476. $barr['optname']= $this->adminname;
  2477. $barr['txsj'] = 1;
  2478. m('schedule')->insert($barr);
  2479. return 'ok';
  2480. }
  2481. /*
  2482. * 获取操作菜单 $flx=0 从操作上点出来 1详情上展示的
  2483. */
  2484. public function getoptmenu($flx=0)
  2485. {
  2486. $where = '';
  2487. if($flx==1)$where='and `iszs`=1';
  2488. $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`');
  2489. $arr = array();
  2490. $bfrom = $this->rock->post('bfrom');
  2491. $arr[] = array('lx'=>0,'name'=>$this->rock->jm->base64decode('5pyq562!5o6I5peg5rOV5pi!56S66I!c5Y2V'),'optmenuid'=>0,'color'=>'red');
  2492. //--autharstart--
  2493. $arr = array();
  2494. foreach($rows as $k=>$rs){
  2495. $wherestr = $rs['wherestr'];
  2496. $bo = false;
  2497. if(isempt($wherestr)){
  2498. $bo = true;
  2499. }else{
  2500. $ewet = $this->wheremodel->getstrwhere($this->rock->jm->base64decode($wherestr));
  2501. $ewet = str_replace('{asqom}','', $ewet);
  2502. $tos = $this->rows("`id`='$this->id' and $ewet");
  2503. if($tos>0)$bo = true;
  2504. }
  2505. $rs['lx'] = $rs['type'];
  2506. $rs['optnum'] = $rs['num'];
  2507. if(!isempt($rs['num'])){
  2508. $glx = $this->flowgetoptmenu($rs['num']);
  2509. if(is_bool($glx))$bo = $glx;
  2510. if(is_array($glx))foreach($glx as $k1=>$v1)$rs[$k1]=$v1;
  2511. }
  2512. $rs['optmenuid'] = $rs['id'];$rs['color']='';
  2513. if(!isempt($rs['statuscolor']))$rs['color'] = $rs['statuscolor'];
  2514. unset($rs['id']);unset($rs['num']);unset($rs['wherestr']);unset($rs['type']);unset($rs['statuscolor']);
  2515. if($rs['lx']==5 || $rs['lx']==7){
  2516. $upgcont = $this->rock->jm->base64decode($rs['upgcont']);
  2517. $rs['upgcont'] = $this->rock->reparr($upgcont, $this->rs);
  2518. }else{
  2519. unset($rs['upgcont']);
  2520. }
  2521. if($bo)$arr[] = $rs;
  2522. }
  2523. //--autharend--
  2524. if($flx==1)return $arr;
  2525. $status = (int)arrvalue($this->rs,'status','0');
  2526. $isturn = (int)arrvalue($this->rs, 'isturn','0');
  2527. $ismy = ($this->uid == $this->adminid or $this->optid == $this->adminid);
  2528. $isreadbo = $this->isreadqx(1);
  2529. //菜单上参数说明lx 标识类型,nup是否不显示上传框,optmenuid菜单Id负数,issm是否需要说明
  2530. if($this->isflow>0 && $isturn==1){
  2531. //--autharstart--
  2532. if(!in_array($status, array(1,5)) && $isreadbo){
  2533. $arr[] = array('name'=>'追加说明...','lx'=>1,'issm'=>1,'optmenuid'=>-12);
  2534. }
  2535. $isjk = $this->isjiankongqx();//监控权限
  2536. if(!in_array($status, array(1,5)) && ($ismy || $isjk)){
  2537. $arr[] = array('name'=>'作废申请...','lx'=>16,'issm'=>1,'nup'=>1,'optmenuid'=>-16); //可直接作废
  2538. if($isjk){
  2539. $arr[] = array('name'=>'监控转办...','color'=>'blue','lx'=>3,'issm'=>1,'nup'=>1,'optmenuid'=>-18);
  2540. //$arr[] = array('name'=>'撤回上一步处理','color'=>'#ff6600','lx'=>1,'issm'=>1,'nup'=>1,'optmenuid'=>-19);
  2541. }
  2542. }
  2543. if(!in_array($status, array(1,2,5)) && ($ismy || $isjk)){
  2544. $arr[] = array('name'=>'催办...','lx'=>13,'issm'=>1,'nup'=>1,'optmenuid'=>-13);
  2545. if($this->option->getval('sms_iscb')=='1')$arr[] = array('name'=>'短信催办...','lx'=>17,'issm'=>1,'nup'=>1,'optmenuid'=>-17);
  2546. }
  2547. $chearr = $this->getflowinfor();
  2548. if($chearr['ischeck']==1){
  2549. $arr[] = array('name'=>'<b>去处理单据...</b>','color'=>'#1389D3','lx'=>996);
  2550. if(1==2)foreach($chearr['courseact'] as $zv=>$dz){
  2551. if($zv>0){
  2552. $assar = array('name'=>$dz[0],'color'=>$dz[1],'optnum'=>'check','issm'=>1,'islog'=>0,'statusvalue'=>$zv,'lx'=>'10','optmenuid'=>-10);
  2553. if($zv==1)$assar['issm'] = 0;
  2554. $arr[] = $assar;
  2555. }
  2556. }
  2557. }
  2558. //--autharend--
  2559. }
  2560. if($status != 5 && arrvalue($this->moders,'ispl','1')=='1' && $isreadbo){
  2561. $arr[] = array('name'=>'评论','lx'=>15,'nup'=>1,'issm'=>1,'optmenuid'=>-15);
  2562. }
  2563. //回执确认
  2564. if($ismy && arrvalue($this->moders,'ishz')=='1' && $status==1){
  2565. $smcont = $this->getsummary();
  2566. $mid = (int)m('receipt')->getmou('id',"`uid`='$this->adminid' and `modenum`='$this->modenum' and `mid`='$this->id'");
  2567. $namess = '回执确认设置';
  2568. if($mid>0)$namess = '回执确认编辑';
  2569. $arr[] = array('name'=>$namess,'djmid'=>$mid,'optnum'=>'receipt','lx'=>'18','optmenuid'=>-18,'modename'=>$this->modename,'smcont'=>$smcont);
  2570. }
  2571. //定时提醒设置
  2572. if($isreadbo && arrvalue($this->moders,'istxset','1')=='1' && $this->modenum != 'remind' && !in_array($status, array(2,5))){
  2573. $smcont = ''.$this->modename.':'.$this->getsummary();
  2574. $mid = (int)m('remind')->getmou('id',"`uid`='$this->adminid' and `modenum`='$this->modenum' and `mid`='$this->id'");
  2575. $namess = '+添加提醒设置';
  2576. if($mid>0)$namess = '提醒设置编辑';
  2577. $arr[] = array('name'=>$namess,'djmid'=>$mid,'smcont'=>$smcont,'issm'=>1,'optnum'=>'tixing','lx'=>'14','optmenuid'=>-14);
  2578. }
  2579. if($this->iseditqx()==1 && $isreadbo){
  2580. $arr[] = array('name'=>'编辑','optnum'=>'edit','lx'=>'11','optmenuid'=>-11);
  2581. }
  2582. if($this->isdeleteqx()==1){
  2583. $arr[] = array('name'=>'删除','color'=>'red','optnum'=>'del','nup'=>1,'issm'=>0,'islog'=>0,'statusvalue'=>9,'lx'=>'9','optmenuid'=>-9);
  2584. }
  2585. return $arr;
  2586. }
  2587. /**
  2588. * 操作菜单操作
  2589. */
  2590. public function optmenu($czid, $zt, $sm='')
  2591. {
  2592. $msg = '';
  2593. $cname = $this->rock->post('changename');
  2594. $cnameid = $this->rock->post('changenameid');
  2595. $cdate = $this->rock->post('changedate');
  2596. $darr = array(
  2597. 'cname' => $cname,
  2598. 'cnameid' => $cnameid,
  2599. 'cdate' => $cdate,
  2600. 'sm' => $sm,
  2601. );
  2602. if($czid==-9){
  2603. $msg = $this->deletebill($sm);
  2604. }else if($czid==-10){
  2605. $msg = $this->check($zt, $sm);
  2606. if(contain($msg,'成功'))$msg = 'ok';
  2607. }else if($czid==-12){
  2608. $this->zhuijiaexplain($sm);
  2609. }else if($czid==-13){
  2610. $this->chuiban($sm);
  2611. }else if($czid==-14){
  2612. $msg = $this->addschedule($sm);
  2613. }else if($czid==-15){
  2614. $actname = $this->rock->post('name');
  2615. $this->addlog(array(
  2616. 'explain' => $sm,
  2617. 'name' => $actname,
  2618. ));
  2619. //评论时提醒给相关人员
  2620. $uids = arrvalue($this->rs,'uid','0');
  2621. if(isset($this->rs['optid']))$uids.=','.$this->rs['optid'].'';
  2622. $this->nexttodo($uids, 'pinglun', $sm, $actname);
  2623. $this->gettodosend('boping','', $sm);
  2624. }else if($czid==-16){
  2625. $this->zuofeibill($sm); //撤销申请也就是作废了
  2626. }else if($czid==-17){
  2627. $msg = $this->smschuiban($sm); //短信催办
  2628. }else if($czid==-18){
  2629. $msg = $this->jiankongzb($darr);
  2630. }else{
  2631. //--autharstart--
  2632. $ors = m('flow_menu')->getone("`id`='$czid' and `setid`='$this->modeid' and `status`=1");
  2633. if(!$ors)return '菜单不存在';
  2634. $name = str_replace('.', '', $ors['name']);
  2635. $actname = $ors['actname'];if(isempt($actname))$actname=$name;
  2636. if($ors['islog']==1){
  2637. if(!isempt($cname)){
  2638. if(!isempt($sm))$sm.=',';
  2639. $sm.=''.$name.':'.$cname.'';
  2640. }
  2641. $this->addlog(array(
  2642. 'explain' => $sm,
  2643. 'name' => $actname,
  2644. 'statusname'=> $ors['statusname'],
  2645. 'status' => $ors['statusvalue'],
  2646. 'color' => $ors['statuscolor']
  2647. ));
  2648. }
  2649. $barrs = array(
  2650. 'cname' => $cname,
  2651. 'sm' => $sm,
  2652. 'cnameid' => $cnameid,
  2653. 'cdate' => $cdate
  2654. );
  2655. if($ors['type']==4 && !isempt($ors['fields'])){
  2656. $fielsa = explode(',', $ors['fields']);
  2657. $uarrs = array();
  2658. foreach($fielsa as $fielsas){
  2659. $fsdiwe = 'fields_'.$fielsas.'';
  2660. if(isset($_REQUEST[$fsdiwe])){
  2661. $uarrs[$fielsas]=$this->rock->post($fsdiwe);
  2662. $barrs[$fsdiwe] = $uarrs[$fielsas];
  2663. }
  2664. }
  2665. if($uarrs)$this->update($uarrs, $this->id);
  2666. }
  2667. $upgcont = $ors['upgcont'];
  2668. //需要判断当前用户有没有编辑权限
  2669. if(!isempt($upgcont)){
  2670. $upgcont = $this->rock->jm->base64decode($upgcont);
  2671. $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);
  2672. $this->update($upgcont, $this->id);
  2673. }
  2674. $this->flowoptmenu($ors, $barrs);
  2675. //--autharend--
  2676. }
  2677. if($msg=='')$msg='ok';
  2678. return $msg;
  2679. }
  2680. /**
  2681. * 监控人操作转办
  2682. */
  2683. public function jiankongzb($darr)
  2684. {
  2685. //--autharstart--
  2686. $cnameid = $darr['cnameid'];
  2687. $cname = $darr['cname'];
  2688. if(isempt($cnameid))return '没有选择人员';
  2689. $barr = $this->getflow();
  2690. $nowcourseid = arrvalue($barr, 'nowcourseid');
  2691. if(isempt($nowcourseid))return '此单据当前没审核步骤';
  2692. $sm = '将['.$this->nowcourse['name'].']转办给:'.$cname.'';
  2693. $this->addlog(array(
  2694. 'explain' => $sm,
  2695. 'name' => '监控转办',
  2696. ));
  2697. $this->addcheckname($nowcourseid, $cnameid, $cname, true, 7);
  2698. $barr = $this->getflow();
  2699. $this->getflowsave($barr, true);
  2700. $this->nexttodo($barr['nowcheckid'], 'next', $sm);
  2701. return 'ok';
  2702. //--autharend--
  2703. return $this->bd6('5peg5L!h5ZG8562!5o6I5peg5q2k5Yqf6IO9');
  2704. }
  2705. /**
  2706. * 单据展示条件搜索
  2707. */
  2708. public function billwhere($uid, $lx)
  2709. {
  2710. $arr['table'] = $this->mtable;
  2711. $arr['tableleft'] = ''; //左关联table
  2712. $arr['fields'] = '';
  2713. $arr['order'] = '';
  2714. $arr['group'] = '';
  2715. $arr['keywhere']= '';
  2716. $arr['asqom'] = ''; //主表别名
  2717. $arr['onlywhere'] = ''; //只要我的一个搜索
  2718. $arr['companywhere']= ''; //多单位显示搜索
  2719. $this->atype = $lx;
  2720. $nas = $this->flowbillwhere($uid, $lx);
  2721. $inwhere = '';
  2722. if(substr($lx,0,5)=='grant'){
  2723. $inwhere = $this->viewmodel->viewwhere($this->moders, $this->adminid, $this->flowviewufieds, 1);
  2724. }
  2725. //抄送的
  2726. if($lx=='chaos'){
  2727. $inwhere = "and {asqom}`id` in(select `mid` from `[Q]flow_chao` where `table`='{$this->mtable}' and ".$this->rock->dbinstr('csnameid', $this->adminid).")";
  2728. }
  2729. //经我处理
  2730. if($lx=='mychuli'){
  2731. $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).")";
  2732. }
  2733. $_wehs = '';
  2734. if(is_array($nas)){
  2735. if(isset($nas['where']))$_wehs = $nas['where'];
  2736. $ftears = explode(',','asqom,order,fields,fieldsleft,table,group,companywhere,onlywhere,keywhere,tableleft');
  2737. foreach($ftears as $fid)if(isset($nas[$fid]))$arr[$fid] = $nas[$fid];
  2738. }else{
  2739. $_wehs = $nas;
  2740. }
  2741. $fwhere = $this->getflowwhere($uid, $lx);//流程模块上条件
  2742. $path = ''.P.'/flow/page/rock_page_'.$this->modenum.'.php';
  2743. $table = $arr['table'];
  2744. $temsao = 0;
  2745. if(!contain($table, ' ') && $this->isflow>0){
  2746. $arr['table'] = '`[Q]'.$this->mtable.'` a left join `[Q]flow_bill` b on a.`id`=b.`mid` and b.`table`=\''.$this->mtable.'\'';
  2747. if(!isempt($arr['tableleft']))$arr['table'].=' left join '.$arr['tableleft'].'';
  2748. $arr['asqom'] = 'a.';
  2749. $arr['fields']= 'a.*,b.`uname` as base_name,b.`udeptname` as base_deptname,b.`sericnum`,b.`nowcheckname`';
  2750. if(isset($arr['fieldsleft']) && $arr['fieldsleft'])$arr['fields'].=','.$arr['fieldsleft'].'';
  2751. if($arr['order']=='')$arr['order'] = 'a.`optdt` desc'; //默认操作时间倒序
  2752. $temsao = 1;
  2753. if($this->defaultorder){
  2754. $defa = explode(',', $this->defaultorder);
  2755. $desc = arrvalue($defa, 1, 'desc');
  2756. $arr['order'] = 'a.`'.$defa[0].'` '.$desc.'';
  2757. }
  2758. }
  2759. if(isempt($arr['order'])){
  2760. $arr['order'] = '{asqom}`id` desc';//没有流程默认id倒序
  2761. if($this->defaultorder){
  2762. $defa = explode(',', $this->defaultorder);
  2763. $desc = arrvalue($defa, 1, 'desc');
  2764. $arr['order'] = '{asqom}`'.$defa[0].'` '.$desc.'';
  2765. }
  2766. }
  2767. if(isempt($fwhere) && isempt($inwhere) && $this->moders['isscl']==1){
  2768. $fwhere = 'and 1=2';
  2769. }
  2770. $where = $inwhere;
  2771. $wherestr = $this->moders['where'];
  2772. if(!isempt($wherestr)){
  2773. $wherestr = $this->rock->covexec($wherestr);
  2774. $where .= ' and {asqom}'.$wherestr;
  2775. }
  2776. if($fwhere!='')$where .= ' '.$fwhere;
  2777. if($_wehs!='')$where .= ' '.$_wehs;
  2778. $highwhere = $this->gethighwhere();//高级搜索
  2779. $allfields = array();
  2780. //关键词搜索
  2781. $key = $this->rock->post('key');
  2782. $pnum = $this->rock->post('pnum');
  2783. $status = $this->rock->post('keystatus');
  2784. $ztfields = arrvalue($nas, 'ztfields', 'status');
  2785. //新加搜索2021-06-07,支持子表搜索
  2786. $xhlikea = array('like','=','>=','<=', 'not like');
  2787. $xhfields = $this->rock->post('xhfields');
  2788. $xhlike = (int)$this->rock->post('xhlike','0');
  2789. $xhkeygj = $this->rock->jm->base64decode($this->rock->post('xhkeygj'));
  2790. if(!isempt($xhkeygj) && $xhfields){
  2791. if(substr($xhfields,0,2)=='zb'){
  2792. $xu = substr($xhfields,2,1);
  2793. $zbasr = explode(',', $this->moders['tables']);
  2794. $zbts = arrvalue($zbasr,$xu);
  2795. $xhfields = substr($xhfields,4);
  2796. $wher1 = "`$xhfields` ".$xhlikea[$xhlike]."";
  2797. if($xhlike==0 || $xhlike==4)$wher1.=" '%".$xhkeygj."%'";
  2798. if($xhlike==1 || $xhlike==2 || $xhlike==3)$wher1.=" '$xhkeygj'";
  2799. $wher1 = " and {asqom}`id` in(select `mid` from `[Q]".$zbts."` where ".$wher1.")";
  2800. $where.= $wher1;
  2801. }else{
  2802. $wher1 = " and {asqom}`$xhfields` ".$xhlikea[$xhlike]."";
  2803. if($xhlike==0 || $xhlike==4)$wher1.=" '%".$xhkeygj."%'";
  2804. if($xhlike==1 || $xhlike==2 || $xhlike==3)$wher1.=" '$xhkeygj'";
  2805. $where.= $wher1;
  2806. }
  2807. }
  2808. if(!isempt($status))$where .= ' and {asqom}`'.$ztfields.'`='.$status.'';
  2809. if(!isempt($key) && isempt($arr['keywhere'])){
  2810. $check = c('check');
  2811. $allfields = $this->db->getallfields('[Q]'.$this->mtable.'');
  2812. $_kearr = array();
  2813. //关键词是日期
  2814. if($check->isdate($key) || $check->ismonth($key)){
  2815. $skeay = array('date','datetime','month');
  2816. foreach($this->fieldsarra as $k=>$rs){
  2817. $flx = $rs['fieldstype'];
  2818. $fid = $rs['fields'];
  2819. if($rs['issou']==1 && in_array($flx, $skeay) && in_array($fid, $allfields)){
  2820. if($check->isdate($key)){
  2821. if($flx=='date')$_kearr[] = "{asqom}`".$fid."`='$key'";
  2822. if($flx=='datetime')$_kearr[] = "{asqom}`".$fid."` like '$key%'";
  2823. if($flx=='month')$_kearr[] = "{asqom}`".$fid."`='".substr($key,0,7)."'";
  2824. if($temsao==1){
  2825. $_kearr[] = "b.`applydt`='$key'";
  2826. }
  2827. }
  2828. if($check->ismonth($key)){
  2829. if($flx=='month'){
  2830. $_kearr[] = "{asqom}`".$fid."`='$key'";
  2831. }else{
  2832. $_kearr[] = "{asqom}`".$fid."` like '$key%'";
  2833. }
  2834. if($temsao==1){
  2835. $_kearr[] = "b.`applydt` like '$key%'";
  2836. }
  2837. }
  2838. }
  2839. }
  2840. }
  2841. if(!$_kearr){
  2842. $skeay = array('text','textarea','htmlediter','changeuser','changeusercheck','changedept','changedeptusercheck','selectdatafalse','selectdatatrue','num');
  2843. $xiakk = array('rockcombo','select');
  2844. foreach($this->fieldsarra as $k=>$rs){
  2845. if($rs['issou']==1 && in_array($rs['fields'], $allfields) && substr($rs['fields'],-2) != 'dt'){
  2846. if(in_array($rs['fieldstype'], $skeay))$_kearr[] = "{asqom}`".$rs['fields']."` like '%".$key."%'";
  2847. //if(in_array($rs['fieldstype'], $xiakk))$_kearr[] = "{asqom}`".$rs['fields']."` = '".$key."'";
  2848. }
  2849. }
  2850. if($temsao==1){
  2851. $_kearr[] = "b.`uname` like '%".$key."%'";
  2852. $_kearr[] = "b.`udeptname` like '%".$key."%'";
  2853. $_kearr[] = "b.`sericnum` = '$key'";
  2854. $_kearr[] = "b.`nowcheckname` = '$key'"; //搜索当前处理人
  2855. }
  2856. //其他or字段条件格式:name@1,title
  2857. if(isset($nas['orlikefields'])){
  2858. $owhee = explode(',', $nas['orlikefields']);
  2859. foreach($owhee as $owhees){
  2860. $_owhees = explode('@', $owhees);
  2861. $sle = arrvalue($_owhees, 1);
  2862. if($sle=='1'){
  2863. $_kearr[] = "".$_owhees[0]." ='$key'";
  2864. }else{
  2865. $_kearr[] = "".$_owhees[0]." like '%".$key."%'";
  2866. }
  2867. }
  2868. }
  2869. }
  2870. if($_kearr && $arr['onlywhere']=='')$arr['keywhere'] = "and (".join(' or ',$_kearr).")";
  2871. }
  2872. if(!isempt($arr['companywhere']) && getconfig('companymode'))$where .= ' '.$arr['companywhere'];
  2873. if(!isempt($arr['onlywhere']))$where .= ' '.$arr['onlywhere'];
  2874. if(!isempt($arr['keywhere']))$where .= ' '.$arr['keywhere'];
  2875. if($highwhere!='')$where .= ' '.$highwhere;
  2876. $where = str_replace('{asqom}', $arr['asqom'], $where);
  2877. $arr['order'] = str_replace('{asqom}', $arr['asqom'], $arr['order']);
  2878. $where = str_replace('[A]', $arr['asqom'], $where);
  2879. //字段显示
  2880. $fields = $arr['fields'];
  2881. if($this->flowfieldstype==1 && (isempt($fields) || $fields=='*') && $this->moders['isscl']==1){
  2882. if(!$allfields)$allfields = $this->db->getallfields('[Q]'.$this->mtable.'');
  2883. $fields = '{asqom}`id`';
  2884. $odlvs = $this->option->getval('columns_'.$this->modenum.'_'.$pnum.'');
  2885. if(isempt($odlvs)){
  2886. foreach($this->fieldsarra as $k=>$rs){
  2887. if($rs['islb']==1 && in_array($rs['fields'],$allfields)){
  2888. $fields.=',{asqom}`'.$rs['fields'].'`';
  2889. }
  2890. }
  2891. }else{
  2892. $odlvsa = explode(',', $odlvs);
  2893. foreach($odlvsa as $odlvs1){
  2894. if(in_array($odlvs1, $allfields)){
  2895. $fields.=',{asqom}`'.$odlvs1.'`';
  2896. }
  2897. }
  2898. }
  2899. if($this->isflow>0){
  2900. if(!contain($fields,'`status`'))$fields.=',{asqom}`status`';
  2901. }
  2902. $fields = str_replace('{asqom}', $arr['asqom'], $fields);
  2903. $arr['fields'] = $fields;
  2904. }
  2905. //字段添加上``
  2906. $fields = $arr['fields'];
  2907. if(!isempt($fields) && $fields!='*'){
  2908. $fieldsa = explode(',', $fields);
  2909. $fieldss = '';
  2910. foreach($fieldsa as $fieldsas){
  2911. if(contain($fieldsas,'`') || contain($fieldsas,'.') || contain($fieldsas,' ') || contain($fieldsas,'(')){
  2912. $fieldss.=','.$fieldsas.'';
  2913. }else{
  2914. $fieldss.=',`'.$fieldsas.'`';
  2915. }
  2916. }
  2917. $arr['fields'] = substr($fieldss, 1);
  2918. }
  2919. $arr['where'] = str_replace('{asqom}','', $where);//替换一下
  2920. return $arr;
  2921. }
  2922. /**
  2923. * 获取高级搜索条件
  2924. */
  2925. public function gethighwhere()
  2926. {
  2927. $s = '';
  2928. //--autharstart--
  2929. foreach($this->fieldsarra as $k=>$rs){
  2930. if($rs['issou']!=1)continue;
  2931. $type = $rs['fieldstype'];
  2932. $fields = $rs['fields'];
  2933. $val = $this->rock->post('soufields_'.$fields.'');
  2934. if($type=='date' || $type=='datetime' || $type=='number' || substr($fields,-2)=='dt'){
  2935. $val1 = $this->rock->post('soufields_'.$fields.'_start');
  2936. $val2 = $this->rock->post('soufields_'.$fields.'_end');
  2937. $val3 = $this->rock->post('soufields_'.$fields.'_equal');
  2938. if($type!='number'){
  2939. if(!isempt($val1))$val1 = "'$val1'";
  2940. if(!isempt($val3))$val3 = "'$val3'";
  2941. if(!isempt($val2)){
  2942. if($type=='datetime')$val2 = "$val2 23:59:59";
  2943. $val2 = "'$val2'";
  2944. }
  2945. }
  2946. if(!isempt($val1))$s.=" and {asqom}`$fields`>=".$val1."";
  2947. if(!isempt($val2))$s.=" and {asqom}`$fields`<=".$val2."";
  2948. if(!isempt($val3))$s.=" and {asqom}`$fields`=".$val3."";
  2949. }else{
  2950. if(isempt($val))continue;
  2951. if($type=='select' || $type=='radio' || $type=='rockcombo'){
  2952. $s.=" and {asqom}`$fields`='$val'";
  2953. }else if($type=='month'){
  2954. $s.=" and {asqom}`$fields` like '$val%'";
  2955. }else{
  2956. $s.=" and {asqom}`$fields` like '%$val%'";
  2957. }
  2958. }
  2959. }
  2960. $ofied = $this->rock->post('search_fields');
  2961. $ofval = $this->rock->post('search_value');
  2962. if(!isempt($ofied) && !isempt($ofval)){
  2963. $ofval = $this->adminmodel->gjoin($ofval,'', 'all');
  2964. $s = " and {asqom}`$ofied` in($ofval)";
  2965. }
  2966. //--autharend--
  2967. return $s;
  2968. }
  2969. /**
  2970. * 根据编号获取对应条件flow_where
  2971. */
  2972. public function getflowwhere($uid, $num)
  2973. {
  2974. $where = '';
  2975. $rs = $this->wheremodel->getone("`setid`='$this->modeid' and `num`='$num'");
  2976. if(!$rs)return $where;
  2977. $where = $this->wheremodel->getwherestr($rs, $uid, $this->flowviewufieds);
  2978. return $where;
  2979. }
  2980. /**
  2981. * 根据流程模块条件读取记录和统计
  2982. */
  2983. public function getflowrows($uid, $lx, $limit=5, $swher='')
  2984. {
  2985. $nas = $this->billwhere($uid, $lx);
  2986. $table = $nas['table'];
  2987. if(!contain($table,' '))$table='[Q]'.$table.'';
  2988. if(isempt($nas['fields']))$nas['fields'] = '*';
  2989. $swher = str_replace('{asqom}',$nas['asqom'], $swher);
  2990. $where = '1=1 '.$nas['where'].' '.$swher.'';
  2991. if($limit==0)return $this->db->rows($table, $where );
  2992. $rows = $this->db->getrows($table, $where , $nas['fields'], $nas['order'], $limit);
  2993. foreach($rows as $k=>$rs){
  2994. $rows[$k] = $this->flowrsreplace($rs, 2);
  2995. }
  2996. return $rows;
  2997. }
  2998. /**
  2999. * 读取要提醒的单据
  3000. */
  3001. public function gettodorows($whereid)
  3002. {
  3003. $where = $this->wheremodel->getwherestr($whereid, $this->adminid, $this->flowviewufieds);
  3004. $wherestr = $this->moders['where'];
  3005. if(!isempt($wherestr)){
  3006. $wherestr = $this->rock->covexec($wherestr);
  3007. $where .= ' and '.$wherestr;
  3008. }
  3009. $where = str_replace('{asqom}','', $where);
  3010. $rows = $this->getall('2=2 '.$where.'');
  3011. foreach($rows as $k=>$rs){
  3012. $rows[$k] = $this->flowrsreplace($rs, 1);
  3013. }
  3014. return $rows;
  3015. }
  3016. /**
  3017. * 打印导出
  3018. */
  3019. public function printexecl($event)
  3020. {
  3021. $arr['moders'] = $this->moders;
  3022. $arr['fields'] = $this->getfields();
  3023. $cell = 1;
  3024. foreach($arr['fields'] as $k=>$v)$cell++;
  3025. $arr['cell'] = $cell;
  3026. $where = '1=1';
  3027. $str1 = $this->moders['where'];
  3028. if(!isempt($str1)){
  3029. $str1 = $this->rock->covexec($str1);
  3030. $where = $str1;
  3031. }
  3032. $vwhere = $this->viewmodel->viewwhere($this->moders, $this->adminid);
  3033. $rows = $this->getrows(''.$where.' '.$vwhere.'', '*', 'id desc', 100);
  3034. $arr['rows'] = $this->flowprintrows($rows);
  3035. $arr['count'] = $this->db->count;
  3036. return $arr;
  3037. }
  3038. /**
  3039. * 获取所有多行子表数据
  3040. * $lx=0编辑时读取,1展示时读取
  3041. */
  3042. public function getsuballdata($lx=0, $mid=0)
  3043. {
  3044. $tabless = $this->moders['tables'];
  3045. $subdata = array();
  3046. if($mid==0)$mid = $this->id;
  3047. if(!isempt($tabless)){
  3048. $tablessa = explode(',', $tabless);
  3049. $namessa = explode(',', $this->moders['names']);
  3050. $tabless1 = '['.str_replace(',','],[', $tabless).']';
  3051. foreach($tablessa as $zbx=>$tables){
  3052. $cis = substr_count($tabless1, '['.$tables.']');
  3053. $whes = '';
  3054. if($cis>1)$whes=' and `sslx`='.$zbx.'';
  3055. $data = m($tables)->getall('mid='.$mid.''.$whes.'','*','`sort`');
  3056. $data = $this->flowsubdata($data, $lx, $zbx);
  3057. if($lx == 0){
  3058. $subdata['subdata'.$zbx.''] = $data;
  3059. }else{
  3060. $subdata[$zbx] = array(
  3061. 'data' => $data,
  3062. 'fields'=> 'subdata'.$zbx.'',
  3063. 'name' => $this->rock->arrvalue($namessa, $zbx)
  3064. );
  3065. }
  3066. }
  3067. }
  3068. return $subdata;
  3069. }
  3070. /**
  3071. * 读取通知
  3072. * $act 当前动作有(boturn,boedit,bochang,bodel)
  3073. */
  3074. private $gettodolistarr = null;
  3075. public function gettodolist($act)
  3076. {
  3077. if(is_array($act))return $act;
  3078. if($this->gettodolistarr === null){
  3079. $rows = $this->todomodel->getrows("`setid`='".$this->modeid."' and `status`=1");
  3080. $barr = array();
  3081. foreach($rows as $k=>$rs){
  3082. $whereid = (int)$rs['whereid'];
  3083. if($whereid > 0){
  3084. $bo = $this->wheremanzhu($whereid);
  3085. if(!$bo)continue;
  3086. }
  3087. $barr[] = $rs;
  3088. }
  3089. $this->gettodolistarr = $barr;
  3090. }else{
  3091. $barr = $this->gettodolistarr;
  3092. }
  3093. $garr = array();
  3094. if($barr)foreach($barr as $k=>$rs){
  3095. if(arrvalue($rs,$act)=='1')$garr[] = $rs;
  3096. }
  3097. return $garr;
  3098. }
  3099. /**
  3100. * 发送设置的通知
  3101. */
  3102. public function gettodosend($act, $actname='',$sm='', $courseid=0, $conts='')
  3103. {
  3104. $barr = $this->gettodolist($act);
  3105. if(!$barr)return;
  3106. $changearr = array('boturn'=>'提交','boedit'=>'编辑','bozhuan'=>'转办','bochang'=>'修改字段','bodel'=>'删除','bozuofei'=>'作废','botong'=>'处理同意','bobutong'=>'处理不同意','bofinish'=>'全部处理完成','bozhui'=>'追加说明','boping'=>'评论','bohuiz'=>'回执确认');
  3107. if($actname=='' && is_string($act))$actname = arrvalue($changearr, $act);
  3108. if(isempt($actname))return;
  3109. $cheo = c('check');
  3110. foreach($barr as $k=>$rs){
  3111. //提交发送短信通知
  3112. if ($act == 'boturn') {
  3113. $receids = $this->adminmodel->gjoins($rs['receid']);
  3114. $receids = explode(',', $receids);
  3115. $txnum = $this->option->getval('sms_txnum');
  3116. $wxurl = $this->getxiangurlx();
  3117. foreach ($receids as $rk => $rv) {
  3118. $where = "`id`=" . $rv;
  3119. $admin = m('admin')->getone($where, 'name');
  3120. $barr = c('xinhuapi')->sendsms(
  3121. $rv, '', $txnum, [
  3122. 'modename' => $this->modename,
  3123. 'sericnum' => $this->sericnum,
  3124. 'applyname' => $this->uname,
  3125. 'deptname' => $this->rs['base_deptname'],
  3126. 'name' => $admin['name'],
  3127. 'userName' => $this->uname,
  3128. 'orderName' => $this->modename,
  3129. ], $wxurl
  3130. );
  3131. };
  3132. }
  3133. $receid = $rs['receid'];
  3134. if($act=='botong' || $act=='bobutong'){
  3135. $changewe = $rs['changecourse'];
  3136. if(!isempt($changewe) && !contain(','.$changewe.',',','.$courseid.','))continue;
  3137. }
  3138. if($rs['toturn']==1)$receid.=','.$this->uid.''; //通知给提交人
  3139. if(arrvalue($rs,'tosuper')=='1'){
  3140. $supar = $this->adminmodel->getsuperman($this->uid);
  3141. $shnej = arrvalue($supar, 0);
  3142. if(!isempt($shnej))$receid.=','.$shnej.''; //通知给直属上级,没有就读取部门负责人
  3143. }
  3144. if($rs['tocourse']==1 && $this->billrs){
  3145. $allcheckid = $this->billrs['allcheckid'];
  3146. if(!isempt($allcheckid))$receid.=','.$allcheckid.''; //通知流程所有参与人
  3147. }
  3148. //其他字段
  3149. $todofields = $rs['todofields'];
  3150. if(!isempt($todofields)){
  3151. $toad = explode(',', $todofields);
  3152. foreach($toad as $toads){
  3153. $ttv = arrvalue($this->rs, $toads);
  3154. if(!isempt($ttv) && $cheo->isinnumber($ttv))$receid.=','.$ttv.'';
  3155. }
  3156. }
  3157. if(isempt($receid))continue;
  3158. if(substr($receid,0,1)==',')$receid = substr($receid, 1);
  3159. $cont = $rs['summary'];
  3160. if(isempt($cont))$cont = $conts;
  3161. if(isempt($cont)){
  3162. $cont = ''.$this->adminname.''.$actname.'['.$this->modename.',单号:'.$this->sericnum.']';
  3163. if($sm!='')$cont.=',说明:'.$sm.'';
  3164. }
  3165. $this->push($receid, '', $cont, $this->rock->repempt($rs['name']));
  3166. }
  3167. }
  3168. /**
  3169. * 根据编号发送通知
  3170. */
  3171. public function numtodosend($num, $actname='',$sm='')
  3172. {
  3173. $rows = $this->todomodel->getrows("`setid`='".$this->modeid."' and `num`='$num' and `status`=1");
  3174. if(!$rows)return;
  3175. $this->gettodosend($rows, $actname, $sm);
  3176. }
  3177. /**
  3178. * 统计报表
  3179. */
  3180. public function flowtotal($fields='', $type='')
  3181. {
  3182. if($fields=='')$fields = $this->rock->post('total_fields');
  3183. if($type=='')$type = $this->rock->post('total_type','jls');
  3184. $typea = explode('|', $type);
  3185. $typefields = '';
  3186. $type = $typea[0]; $typefields = arrvalue($typea, 1);
  3187. $rowa = array();
  3188. $rowa[] = array(
  3189. 'name' => '暂无数据',
  3190. 'value' => 0,
  3191. 'bili' => ''
  3192. );
  3193. $tofiels= 'count(1)';
  3194. if($type=='sum')$tofiels = 'sum([A]`'.$typefields.'`)';
  3195. if($type=='avg')$tofiels = 'avg([A]`'.$typefields.'`)';
  3196. $atype = $this->rock->post('atype');
  3197. $table = '[Q]'.$this->mtable.'';
  3198. $narr = $this->billwhere($this->adminid, $atype);
  3199. $where = $narr['where'];
  3200. $table = $narr['table'];
  3201. if(!contain($table,' '))$table = '[Q]'.$table.'';
  3202. $gwhere = $this->rock->post('where');
  3203. if(!isempt($gwhere)){
  3204. $gwhere = $this->rock->jm->uncrypt($this->rock->iconvsql($gwhere));
  3205. $where .= ' '.$gwhere.'';
  3206. }
  3207. $sql = 'select '.$fields.' as `name`,'.$tofiels.' as value from '.$table.' where 1=1 '.$where.' group by '.$fields.'';
  3208. $sql = str_replace('[A]', $narr['asqom'], $sql);
  3209. $rows = $this->db->getall($sql);
  3210. $total = 0;
  3211. if($rows){
  3212. foreach($rows as $k=>$rs)$total+=floatval($rs['value']);
  3213. if($total>0)foreach($rows as $k=>$rs){
  3214. $rows[$k]['bili'] = $this->rock->number($rs['value']*100/$total).'%';
  3215. }
  3216. if($type!='avg' && count($rows)>1)$rows[] = array('name' => '合计','value' => $total,'bili' => '');
  3217. }else{
  3218. $rows = $rowa;
  3219. }
  3220. return $rows;
  3221. }
  3222. /**
  3223. * 回执确认
  3224. */
  3225. public function receiptcheck($hid, $sm)
  3226. {
  3227. //--autharstart--
  3228. $hrs = m('receipt')->getone("`id`='$hid' and `modenum`='$this->modenum' and `mid`='$this->id'");
  3229. if(!$hrs)return;
  3230. $receid = $hrs['receid'];
  3231. $receids = $hrs['receids'];
  3232. if(isempt($receids))$receids = '';
  3233. $uid = $this->adminid;
  3234. if(!contain(','.$receid.',', ','.$uid .','))return;
  3235. $reaa = explode(',', $receids);
  3236. if(!$reaa)$reaa = array();
  3237. if(!in_array($uid, $reaa)){
  3238. if($receids!='')$receids.=',';
  3239. $receids.=''.$uid.'';
  3240. }
  3241. $reaa = explode(',', $receids);
  3242. $ushuy = count($reaa);
  3243. $receids= join(',', $reaa);
  3244. m('receipt')->update(array(
  3245. 'receids' => $receids,
  3246. 'ushuy' => $ushuy,
  3247. ), $hid);
  3248. $this->addlog(array(
  3249. 'explain' => $sm,
  3250. 'name' => '回执确认'
  3251. ));
  3252. //通知给提交人
  3253. $this->rs = $hrs;
  3254. $this->nexttodo($hrs['uid'],'receipt', $sm, '回执确认');
  3255. //--autharend--
  3256. return 'ok';
  3257. }
  3258. /**
  3259. * 获取简单列表数据,返回table表格
  3260. */
  3261. public function getrowstable($atype, $where, $limit=100)
  3262. {
  3263. $rows = $this->getflowrows($this->adminid,$atype,$limit,$where);
  3264. $headstr = '@xuhaos,,center';
  3265. foreach($this->fieldsarra as $k=>$rs){
  3266. if($rs['islb']==1 && $rs['iszb']=='0')
  3267. $headstr.='@'.$rs['fields'].','.$rs['name'].'';
  3268. }
  3269. if($this->isflow>0){
  3270. $headstr.='@statustext,状态';
  3271. if(is_array($rows))foreach($rows as $k=>$rs){
  3272. $rows[$k]['statustext'] = $this->getstatusstr($rs);
  3273. }
  3274. }
  3275. $cont = c('html')->createrows($rows, substr($headstr, 1),'#cccccc','noborder');
  3276. return $cont;
  3277. }
  3278. /**
  3279. * 禁看处理
  3280. */
  3281. public function viewjinfields($rows)
  3282. {
  3283. if(!$rows)return $rows;
  3284. //--autharstart--
  3285. $jinkfarr = $this->viewmodel->viewjinfields($this->moders, $this->adminid, $this->flowviewufieds);
  3286. if($jinkfarr && is_array($jinkfarr)){
  3287. $wherear= array();
  3288. $ids = '';
  3289. foreach($rows as $k=>$rs){
  3290. if(!isset($rs['id']))return $rows;//没有id字段是无法判断
  3291. $ids.=','.$rs['id'].'';
  3292. }
  3293. $ids = substr($ids, 1);
  3294. foreach($jinkfarr as $k1=>$rs1){
  3295. $wherestr = arrvalue($rs1,'wherestr');
  3296. $wherestr2 = arrvalue($rs1,'wherestr2');
  3297. $fieldstr = arrvalue($rs1,'fieldstr');
  3298. if(isempt($fieldstr))continue;
  3299. if($wherestr=='' && $wherestr2=='')continue;
  3300. if($wherestr2!=''){
  3301. if($wherestr!='')$wherestr.=' and ';
  3302. $wherestr.=$wherestr2;
  3303. }
  3304. $wherestr= str_replace('{asqom}','', $wherestr);
  3305. $jinrows = $this->getall('`id` in('.$ids.') and '.$wherestr.'','id');
  3306. if(!$jinrows)continue;
  3307. $jinrow = array();
  3308. foreach($jinrows as $k2=>$rs2)$jinrow[]=$rs2['id'];
  3309. $jinkfarr[$k1]['jinrows'] = $jinrow;
  3310. }
  3311. //隐藏字段设置
  3312. foreach($rows as $k=>$rs){
  3313. $id = $rs['id'];
  3314. if(arrvalue($rs, $this->flowviewufieds)==$this->adminid)continue;//我自己都可以看
  3315. foreach($jinkfarr as $k1=>$rs1){
  3316. $fieldstr = arrvalue($rs1,'fieldstr');
  3317. $jinrows = arrvalue($rs1,'jinrows');
  3318. if($jinrows){
  3319. $farr = explode(',', $fieldstr);
  3320. if(in_array($id, $jinrows)){
  3321. foreach($farr as $fid){
  3322. if(isset($rs[$fid]))$rows[$k][$fid]='';//清空
  3323. }
  3324. }
  3325. }
  3326. }
  3327. }
  3328. }
  3329. //--autharend--
  3330. return $rows;
  3331. }
  3332. /**
  3333. * 判断是否导出子表处理
  3334. */
  3335. public function daochusubtable($rows)
  3336. {
  3337. //--autharstart--
  3338. if(!$this->daochubo || !$rows)return $rows;
  3339. $excelsubtab = $this->rock->post('excelsubtab');
  3340. if(isempt($excelsubtab) || isempt($this->moders['tables']))return $rows;
  3341. $suba = explode(',', $excelsubtab);
  3342. foreach($rows as $k=>$rs){
  3343. if(!isset($rs['id']))return $rows;
  3344. $subdata = $this->getsuballdata(1, $rs['id']);
  3345. foreach($suba as $zb){
  3346. $shuju = $subdata[$zb]['data'];
  3347. if($shuju){
  3348. $this->subsubdatastyle = 'print';
  3349. $rows[$k]['sub_table_'.$zb.''] = $this->getsubdata($zb, $shuju);
  3350. }else{
  3351. $rows[$k]['sub_table_'.$zb.''] = '';
  3352. }
  3353. }
  3354. }
  3355. //--autharend--
  3356. return $rows;
  3357. }
  3358. }