planmModel.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. class flow_planmClassModel extends flowModel
  3. {
  4. public function leixingdata()
  5. {
  6. $arr[] = array('value'=>'1','name'=>'年度');
  7. $arr[] = array('value'=>'2','name'=>'季度');
  8. $arr[] = array('value'=>'3','name'=>'月度');
  9. $arr[] = array('value'=>'4','name'=>'周');
  10. $arr[] = array('value'=>'5','name'=>'项目');
  11. $arr[] = array('value'=>'0','name'=>'其他');
  12. return $arr;
  13. }
  14. private function leixingval($lx)
  15. {
  16. $data = $this->leixingdata();
  17. $str = $lx;
  18. foreach($data as $kv=>$rv){
  19. if($rv['value']==$lx){
  20. $str = $rv['name'].'计划';
  21. break;
  22. }
  23. }
  24. return $str;
  25. }
  26. public function flowrsreplace($rs, $lx=0){
  27. $rs['leixing'] = $this->leixingval($rs['leixing']);
  28. $str = '';
  29. if($rs['startdt']>$this->rock->now){
  30. $str = '未开始';
  31. }else if($rs['enddt']<$this->rock->now){
  32. }else{
  33. $str = '执行中';
  34. }
  35. if($rs['state']==1)$str='已完成';
  36. if($rs['state']==2)$str='执行中';
  37. if($rs['state']==0)$str='待执行';
  38. if($rs['enddt']<$this->rock->now)$str.=',<font color=gray>已截止</font>';
  39. if($rs['startdt']>$this->rock->now)$str='未开始';
  40. $rs['state'] = $str;
  41. return $rs;
  42. }
  43. //自定义审核人读取
  44. protected function flowcheckname($num){
  45. $sid = '';
  46. $sna = '';
  47. if($num=='zhixi'){
  48. $ssid = '';
  49. $runrenid = $this->rs['runrenid'];
  50. if(!isempt($runrenid)){
  51. $dbs = m('dept');
  52. $runa = explode(',', $runrenid);
  53. foreach($runa as $id1){
  54. $id1d = str_replace(array('d','u'),'', $id1);
  55. if(contain($id1,'d')){
  56. $drs = $dbs->getone($id1d);
  57. if($drs && !isempt($drs['headid']))$ssid.=','.$drs['headid'].'';
  58. }else{
  59. $ssid.=','.$id1d.'';
  60. }
  61. }
  62. }
  63. if($ssid){
  64. $ssid = substr($ssid, 1);
  65. $rows = $this->adminmodel->getall('id in('.$ssid.') and `status`=1');
  66. if($rows){
  67. foreach($rows as $k=>$rs){
  68. $sid.=','.$rs['id'].'';
  69. $sna.=','.$rs['name'].'';
  70. }
  71. $sid = substr($sid, 1);
  72. $sna = substr($sna, 1);
  73. }
  74. }
  75. }
  76. return array($sid, $sna);
  77. }
  78. protected function flowbillwhere($uid, $lx)
  79. {
  80. $where = '';
  81. if($lx=='bumen'){
  82. $dbs = m('dept');
  83. $detpids= '';
  84. $drows = $dbs->getall($this->rock->dbinstr('headid', $uid)); //读取我负责的部门
  85. foreach($drows as $k=>$rs)$detpids.=','.$rs['id'].'';
  86. if($detpids!=''){
  87. $detpids = substr($detpids,1);
  88. for($i=1;$i<=2;$i++){
  89. $drows = $dbs->getall('`pid` in('.$detpids.')');
  90. foreach($drows as $k=>$rs)$detpids.=','.$rs['id'].'';
  91. if(!$drows)break;
  92. }
  93. }
  94. if(!$detpids){
  95. $where='and 1=2';
  96. }else{
  97. $drows = $dbs->getall('`id` in('.$detpids.')');
  98. $whewea = array();
  99. foreach($drows as $k=>$rs){
  100. $whewea[] = $this->rock->dbinstr('runrenid', 'd'.$rs['id'].'');
  101. }
  102. $where = 'and ('.join(' or ', $whewea).')';
  103. }
  104. }
  105. return $where;
  106. }
  107. //判断是不是再执行人里面。
  108. private $runboolpdid = 0;
  109. public function runboolpd()
  110. {
  111. if($this->rs['status']!=1
  112. || ($this->rs['enddt']<$this->rock->now && $this->rs['state']==1)
  113. || $this->rs['startdt']>$this->rock->now)return false;
  114. if($this->runboolpdid>0){
  115. if($this->runboolpdid==1)return true;
  116. if($this->runboolpdid==2)return false;
  117. }
  118. $bo = $this->adminmodel->containjoin($this->rs['runrenid'], $this->adminid);
  119. $this->runboolpdid = $bo ? 1: 2;
  120. return $bo;
  121. }
  122. //是否可执行
  123. protected function flowdatalog($arr)
  124. {
  125. $runbool = $this->runboolpd();
  126. return array(
  127. 'modelujs' => $runbool,
  128. );
  129. }
  130. //子表数据替换处理
  131. protected function flowsubdata($rows, $lx=0){
  132. if($lx!=1 || !$rows || !$this->runboolpd())return $rows;
  133. $inputobj = c('input');
  134. foreach($rows as $k=>$rs){
  135. $rows[$k]['zxren'] = $inputobj->inputchangeuser(array(
  136. 'type' => 'changedeptusercheck',
  137. 'changerange' => $this->rs['runrenid'],
  138. 'name' => 'zhixing_zxren_'.$rs['id'].'',
  139. 'id' => 'zhixing_zxrenid_'.$rs['id'].'',
  140. 'value' => $rs['zxren'],
  141. 'valueid' => $rs['zxrenid'],
  142. 'title' => '执行人'
  143. ));
  144. $rows[$k]['zxtime'] = '<input name="zhixing_zxtime_'.$rs['id'].'" onclick="js.datechange(this,\'datetime\')" readonly value="'.$rs['zxtime'].'" class="inputs datesss">';
  145. }
  146. $zt = $this->rs['state'];
  147. $rows[] = array(
  148. 'pitem'=>'执行状态',
  149. 'zxren'=>'<select id="ztstate" class="inputs"><option value="0">待执行</option><option value="2"'.(($zt==2)?' selected':'').'>执行中</option><option value="1"'.(($zt==1)?' selected':'').'>已完成</option></select>',
  150. 'zxtime'=>'<div align="left"><button type="button" onclick="submittijiao(this)" class="webbtn">保存</button></div>'
  151. );
  152. return $rows;
  153. }
  154. //统计未完成
  155. public function getwwctotals($uid)
  156. {
  157. $where = m('admin')->getjoinstr('runrenid', $uid,0,1);
  158. $where = "`status`=1 and `state`<>1 and `startdt`<'{$this->rock->now}' and `type`=0 $where";
  159. return m('planm')->rows($where);
  160. }
  161. }
粤ICP备19079148号