userractModel.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. class flow_userractClassModel extends flowModel
  3. {
  4. protected $flowcompanyidfieds = 'companyid';
  5. public $statearr,$dtobj;
  6. public function initModel()
  7. {
  8. $this->statearr = explode(',','<font color=blue>待执行</font>,<font color=green>生效中</font>,<font color=#888888>已终止</font>,<font color=red>已过期</font>');
  9. $this->dtobj = c('date');
  10. }
  11. public function flowrsreplace($rs, $lx=0)
  12. {
  13. $rs['state'] = $this->statearr[$rs['state']];
  14. if(isset($rs['newname']) && !isempt($rs['newname']) && $rs['newname']!=$rs['uname'])$this->update("`uname`='".$rs['newname']."'",$rs['id']);
  15. if($lx==1){
  16. $rs['deptname'] = $this->adminmodel->getmou('deptname', $rs['uid']);
  17. }
  18. if(!isempt($rs['enddt'])){
  19. $jg = $this->dtobj->datediff('d', $this->rock->date, $rs['enddt']);
  20. if($jg==0)$jg='今';
  21. if($jg==1)$jg='明';
  22. $rs['jg'] = $jg;
  23. }
  24. return $rs;
  25. }
  26. public function updatestate()
  27. {
  28. $dt = $this->rock->date;
  29. $this->update("`state`=2", "`tqenddt` is not null and `tqenddt`<`enddt` and `tqenddt`<'$dt'");
  30. $this->update("`state`=1", "`startdt`<='$dt' and `enddt`>='$dt' and `tqenddt` is null");
  31. $this->update("`state`=3", "`enddt`<'$dt' and `tqenddt` is null");
  32. $this->update("`state`=0", "`startdt`>'$dt'");
  33. }
  34. protected function flowbillwhere($uid, $lx)
  35. {
  36. $this->updatestate();
  37. $table = '`[Q]userract` a left join `[Q]admin` b on a.uid=b.id';
  38. return array(
  39. 'where' => '',
  40. 'table' => $table,
  41. 'fields'=> 'a.*,b.deptname,b.`name` as newname',
  42. 'orlikefields'=>'b.deptname',
  43. 'order' => 'a.`optdt` desc',
  44. 'asqom' => 'a.'
  45. );
  46. }
  47. }
粤ICP备19079148号