flow.php 120 KB

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