flow.php 121 KB

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