flow.php 130 KB

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