knowtraimModel.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /**
  3. * 考试培训
  4. */
  5. class flow_knowtraimClassModel extends flowModel
  6. {
  7. public function initModel()
  8. {
  9. $this->statearr = explode(',','<font color=#ff6600>还未开始</font>,<font color=green>进行中</font>,<font color=#888888>已结束</font>');
  10. }
  11. public function getstatestr($zt)
  12. {
  13. return arrvalue($this->statearr, $zt);
  14. }
  15. protected function flowsubmit($na, $sm)
  16. {
  17. if($this->rs['status']==1)$this->sendtodo();
  18. }
  19. //审核完成后发通知
  20. protected function flowcheckfinsh($zt)
  21. {
  22. if($zt==1)$this->sendtodo();
  23. }
  24. //发通知给对应人员
  25. public function sendtodo()
  26. {
  27. $rows = m('knowtrais')->getall('mid='.$this->id.' and `isks`=0','uid');
  28. $ids = '';
  29. foreach($rows as $k=>$rs)$ids.=','.$rs['uid'].'';
  30. if($ids=='')return;
  31. $ids = substr($ids, 1);
  32. $cont = ''.$this->adminname.'发布培训考试,主题:{title},时间{startdt}至{enddt}。';
  33. $this->push($ids,'', $cont);
  34. }
  35. public function flowisreadqx()
  36. {
  37. $to = m('knowtrais')->rows('`mid`='.$this->id.' and `uid`='.$this->adminid.'');
  38. return $to>0;
  39. }
  40. public function flowrsreplace($rs,$lx=0)
  41. {
  42. $zt = $rs['state'];
  43. $rs['state'] = $this->getstatestr($zt);
  44. if($lx==1 && $zt==1){
  45. //我当前状态
  46. $ors = m('knowtrais')->getone('`mid`='.$rs['id'].' and `uid`='.$this->adminid.'');
  47. if($ors){
  48. if($ors['isks']=='0'){
  49. $rs['state'] .= '&nbsp;<a class="zhu" href="index.php?m=hr&a=kaoshi&d=main&id='.$this->id.'">去考试</a>';
  50. }else{
  51. $rs['state'] .= '&nbsp;&nbsp;已考试分数:'.$ors['fenshu'].'';
  52. }
  53. }
  54. }
  55. return $rs;
  56. }
  57. //更新题库状态
  58. public function reloadstate($id='')
  59. {
  60. $where = '1=1';
  61. if($id!='')$where='id in('.$id.')';
  62. $rows = $this->getall($where);
  63. $now = $this->rock->now;
  64. foreach($rows as $k=>$rs){
  65. $zt = 0;
  66. if($rs['enddt']<$now){
  67. $zt = 2;
  68. }else if($rs['startdt']<$now){
  69. $zt = 1;
  70. }
  71. if($zt!=$rs['state'])$this->update('`state`='.$zt.'', $rs['id']);
  72. }
  73. $rows = $this->db->getall('SELECT mid,count(1)stotal FROM `[q]knowtrais` where isks=1 GROUP BY mid');
  74. foreach($rows as $k=>$rs)$this->update('`ydshu`='.$rs['stotal'].'', $rs['mid']);
  75. }
  76. protected function flowbillwhere($uid, $lx)
  77. {
  78. $this->reloadstate();
  79. }
  80. //每天通知未考试培训人员
  81. public function todaytodo()
  82. {
  83. }
  84. //选取选择题库的条件
  85. public function gettikuwhere($tiid, $dwid=0)
  86. {
  87. $str1 = '';
  88. if($dwid==0)$dwid = $this->adminmodel->getcompanyid();
  89. if(ISMORECOM)$str1 = " and `comid`=".$dwid."";
  90. if(isempt($tiid))return $str1;
  91. $sid = '';
  92. $tarr = explode(',', $tiid);
  93. $dbs = m('option');
  94. foreach($tarr as $sid1){
  95. $ssid = $dbs->getalldownid($sid1);
  96. $sid.=','.$ssid.'';
  97. }
  98. if($sid!=''){
  99. $sid = substr($sid, 1);
  100. return ' and `typeid` in('.$sid.')';
  101. }else{
  102. return $str1;
  103. }
  104. }
  105. //删除单据时调用
  106. protected function flowdeletebill($sm)
  107. {
  108. m('knowtrais')->delete("`mid`='".$this->id."'");
  109. }
  110. }
粤ICP备19079148号