wenjuanModel.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. //问卷调查模块接口问卷
  3. class flow_wenjuanClassModel extends flowModel
  4. {
  5. public $inputwidth = 950;
  6. private $readunarr = array();//未读人员
  7. //替换读取统计
  8. public function flowrsreplace($rs, $lx=0)
  9. {
  10. if($lx==2 && $this->adminid==$rs['uid']){
  11. $where = $this->adminmodel->gjoin($rs['receid'],'','where');
  12. $where.= " and `workdate`<='".$rs['startdt']."' and `status`=1";
  13. $yito = $this->adminmodel->rows($where);
  14. $yato = 0;
  15. if(!isempt($rs['dauserids']))$yato = count(explode(',', $rs['dauserids']));
  16. $temp_total = ''.$yato.'/'.$yito.'';
  17. $rs['temp_total'] = $temp_total;
  18. }
  19. if($rs['enddt']<$this->rock->date)$rs['ishui']=1;
  20. //未查阅人
  21. if($lx==1){
  22. $barr = m('log')->getreadshu($this->mtable, $rs['id'],$rs['receid'] , $rs['startdt'], $this->adminmodel);
  23. foreach($barr as $k=>$v)$rs[$k]=$v;
  24. $this->readunarr = $barr['wduarr'];
  25. }
  26. return $rs;
  27. }
  28. //作废或删除时
  29. protected function flowzuofeibill($sm)
  30. {
  31. m('wenjuau')->delete("`mid`='$this->id'");
  32. }
  33. protected function flowdatalog($arr)
  34. {
  35. $arr['title'] = '';
  36. $itemarr = m('wenjuat')->getall("`mid`='$this->id'",'*','sort asc');
  37. $suid = (int)$this->rock->get('suid','0');
  38. if($suid==0)$suid = $this->adminid;
  39. //读取我提交的结果
  40. $tjrows = m('wenjuau')->getall("`mid`='$this->id' and `optid`='$suid'");
  41. $arr['tjcount'] = count($tjrows);//是否提交过
  42. $hlx = $this->rock->get('hlx');
  43. foreach($itemarr as $k=>$rs)$itemarr[$k]['daan']='';
  44. //显示汇总
  45. if($hlx=='true'){
  46. $xuan= explode(',','a,b,c,d,e,f,g,h,i,k');
  47. $zongtiarr = m('wenjuau')->getall("`mid`='$this->id'");
  48. foreach($itemarr as $k=>$rs){
  49. $showcont = '';
  50. $piaoshu = 0;
  51. foreach($xuan as $xua)$itemarr[$k]['daan'.$xua.'']=0;
  52. $itemarr[$k]['zong'] = 0;
  53. foreach($zongtiarr as $k1=>$rs1){
  54. if($rs['id']==$rs1['sid']){
  55. if($rs['itemtype']=='2'){
  56. $showcont.='<div>'.$rs1['optname'].':'.$rs1['conts'].' <span style="font-size:12px;color:#888888">('.$rs1['optdt'].')</font></div>';
  57. }else{
  58. $conts = ','.$rs1['conts'].',';
  59. foreach($xuan as $xua){
  60. if(contain($conts,','.$xua.',')){
  61. $itemarr[$k]['daan'.$xua.'']++;
  62. $itemarr[$k]['zong']++;
  63. }
  64. }
  65. }
  66. }
  67. }
  68. $itemarr[$k]['showcont'] = $showcont;
  69. }
  70. }else if($arr['tjcount']>0){
  71. $rand = $tjrows[0]['rand'];
  72. foreach($itemarr as $k=>$rs){
  73. foreach($tjrows as $k1=>$rs1){
  74. if($rs1['rand']==$rand && $rs1['sid']==$rs['id']){
  75. $itemarr[$k]['daan'] = $rs1['conts'];
  76. }
  77. }
  78. }
  79. }
  80. $arr['readunarr'] = $this->readunarr;//读取未查阅
  81. $arr['itemarr'] = $itemarr;
  82. $arr['showname'] = $this->adminmodel->getmou('name', $suid);
  83. $arr['hlx'] = $hlx;
  84. return $arr;
  85. }
  86. //显示调查内容
  87. public function showitem()
  88. {
  89. }
  90. /**
  91. * 提交问卷了
  92. */
  93. public function submitwenjuan()
  94. {
  95. if(isset($this->rs['status']) && $this->rs['status']!='1')return '记录审核未完成';
  96. if($this->rs['startdt']>$this->rock->date)return '还没开始呢';
  97. if($this->rs['enddt']<$this->rock->date)return '已经结束了哦';
  98. $itemarr = m('wenjuat')->getall("`mid`='$this->id'",'*','sort asc');
  99. $rand = rand(100000,999999);
  100. $dbs = m('wenjuau');
  101. if($dbs->rows("`mid`='$this->id' and `optid`='$this->adminid'")>0)return '已经提交过了哦';
  102. if(!isempt($this->rs['dauserids'])){
  103. $dauserids = explode(',', $this->rs['dauserids']);
  104. if(!in_array($this->adminid, $dauserids))$dauserids[] = $this->adminid;
  105. }else{
  106. $dauserids = array($this->adminid);
  107. }
  108. foreach($itemarr as $k1=>$rs1){
  109. $tyname = 'itemname_'.$rs1['id'].'';
  110. $tyvale = $this->rock->post($tyname);
  111. if(isempt($tyvale))return '选项'.($k1+1).'你还没选呢';
  112. $itemarr[$k1]['tyvale'] = $tyvale;
  113. }
  114. foreach($itemarr as $k1=>$rs1){
  115. $uarr = array('mid'=>$this->id);
  116. $uarr['sid'] = $rs1['id'];
  117. $uarr['comid'] = $this->rs['comid'];
  118. $uarr['conts'] = $rs1['tyvale'];
  119. $uarr['optid'] = $this->adminid;
  120. $uarr['optname'] = $this->adminname;
  121. $uarr['optdt'] = $this->rock->now;
  122. $uarr['rand'] = $rand;
  123. $dbs->insert($uarr);
  124. }
  125. $this->update(array(
  126. 'dauserids' => join(',', $dauserids)
  127. ), $this->id);
  128. $this->numtodosend('wmsubmit','提交问卷');
  129. return 'ok';
  130. }
  131. }
粤ICP备19079148号