flow.php 132 KB

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