carmsModel.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. //车辆信息登记
  3. class flow_carmsClassModel extends flowModel
  4. {
  5. public function flowrsreplace($rs)
  6. {
  7. $ztname = '';
  8. if(!isempt($rs['enddt'])){
  9. $jg = c('date')->datediff('d', $this->rock->date, $rs['enddt']);
  10. if($jg<0){
  11. $ztname='<font color="#888888">已到期</font>';
  12. $rs['ishui'] = 1;
  13. }
  14. if($jg==0)$ztname='<font color="blue">今日到期</font>';
  15. if($jg>0 && $jg<30)$ztname='<font color="#ff6600">'.$jg.'天后到期</font>';
  16. if($jg>=30)$ztname='<font color="green">生效中</font>';
  17. }
  18. if(isset($rs['carnum'])){
  19. $ors = $rs;
  20. }else{
  21. $ors = m('carm')->getone($rs['carid']);
  22. }
  23. if($ors)$rs['carid'] = ''.$ors['carbrand'].','.$ors['carmode'].'('.$ors['carnum'].')';
  24. $rs['ztname'] = $ztname;
  25. return $rs;
  26. }
  27. public function flowbillwhere($uid, $lx)
  28. {
  29. $where = '';
  30. $carid = (int)$this->rock->get('carid',0);
  31. if($carid>0)$where='and a.`carid`='.$carid.'';
  32. return array(
  33. 'table' => '`[Q]'.$this->mtable.'` a left join `[Q]carm` b on a.`carid`=b.id',
  34. 'fields' => 'a.*,b.carnum,b.carbrand,b.carmode,cartype',
  35. 'orlikefields' => 'b.carnum,b.carbrand,b.carmode,b.`cartype`,a.`otype`@1',
  36. 'asqom' => 'a.',
  37. 'where' => $where,
  38. );
  39. }
  40. //每天信息提醒
  41. public function todocarms($toid)
  42. {
  43. if(isempt($toid))return '没设置提醒人员';
  44. $dt = $this->rock->date;
  45. $dt30 = c('date')->adddate($dt,'d', 30);
  46. $rows = $this->db->getall('select a.`enddt`,a.`otype`,b.`carnum` from `[Q]carms` a left join `[Q]carm` b on a.carid=b.id where b.id is not null and a.`enddt` is not null and a.`enddt`>=\''.$dt.'\'');
  47. $txlist = m('option')->getval('cartodo','0,3,7,15,30');
  48. $txarr = explode(',', $txlist);
  49. $dtobj = c('date');
  50. $cars = array();
  51. $str = '';
  52. foreach($rows as $k=>$rs){
  53. $jg = $dtobj->datediff('d', $dt, $rs['enddt']);
  54. if(in_array($jg, $txarr)){
  55. $strs = ''.$jg.'天后('.$rs['enddt'].')';
  56. if($jg==1)$strs='明天';
  57. if($jg==0)$strs='今天';
  58. $str .= ''.$rs['carnum'].'的['.$rs['otype'].']将在'.$strs.'到期;';
  59. }
  60. }
  61. //下次保养提醒
  62. $rows = $this->db->getall('select a.`nextdt`,b.`carnum`,a.`jiaid`,a.`uid` from `[Q]carmang` a left join `[Q]carm` b on a.carid=b.id where b.id is not null and a.`type`=1 and a.`status`=1 and a.`nextdt` is not null and a.`nextdt`>=\''.$dt.'\'');
  63. foreach($rows as $k=>$rs){
  64. $jg = $dtobj->datediff('d', $dt, $rs['nextdt']);
  65. if(in_array($jg, $txarr)){
  66. $strs = ''.$jg.'后('.$rs['nextdt'].')';
  67. if($jg==1)$strs='明天';
  68. if($jg==0)$strs='今天';
  69. $str .= ''.$rs['carnum'].'在'.$strs.'后需保养了;';
  70. }
  71. }
  72. if($str!=''){
  73. $this->push($toid, '车辆', $str, '车辆信息提醒');
  74. }
  75. return 'success';
  76. }
  77. }
粤ICP备19079148号