collectsModel.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. class flow_collectsClassModel extends flowModel
  3. {
  4. public $subtable = 'plans';
  5. public function flowfieldarr($farr, $lx)
  6. {
  7. $mid = (int)$this->rock->post('mid','0');
  8. //if($mid==0)$mid = (int)$this->rock->post('id','0');
  9. $this->newfarr = array();
  10. if($mid){
  11. $mrs = $this->getone($mid);
  12. $sid = $mrs['leixing'];
  13. $zrows = m($this->subtable)->getall('mid='.$sid.'','*','`sort`');
  14. foreach($zrows as $k=>$rs){
  15. $frs = $farr[0];
  16. $frs['name'] = $rs['pitem'];
  17. $frs['fieldstype'] = $rs['zxren'];
  18. $frs['data'] = $rs['zxrenid'];
  19. $frs['attr'] = '';
  20. $frs['lens'] = '0';
  21. $frs['isbt'] = ($rs['itemid']=='1')?'1':'0';
  22. $frs['islu'] = '1';
  23. $frs['id'] = '0';
  24. $frs['fields'] = 'sitemid_'.$rs['id'].'';
  25. $farr[] = $frs;
  26. $this->newfarr[] = $frs;
  27. }
  28. }
  29. return $farr;
  30. }
  31. //在运行这个,模版处理
  32. public function flowinputtpl($cont, $lx)
  33. {
  34. //pc
  35. if($lx==0){
  36. $str = '';
  37. foreach($this->newfarr as $k=>$rs){
  38. $str.='<tr><td class="ys1" align="right">'.(($rs['isbt']=='1')?'*':'').''.$rs['name'].'</td><td colspan="3" class="ys2">{'.$rs['fields'].'}</td></tr>';
  39. }
  40. $cont = str_replace('{autotpl}', $str, $cont);
  41. }
  42. return $cont;
  43. }
  44. //报错子表信息
  45. protected function flowsubmit($na, $sm)
  46. {
  47. $sid = $this->rs['leixing'];
  48. $dbs = m($this->subtable);
  49. $zrows = $dbs->getall('mid='.$sid.'','*','`sort`');
  50. foreach($zrows as $k=>$rs){
  51. $fields = 'sitemid_'.$rs['id'].'';
  52. $where = '`mid`='.$this->id.' and `itemid`='.$rs['id'].'';
  53. $uarr = array(
  54. 'pitem' => $rs['pitem'],
  55. 'zxren' => $this->rock->post($fields),
  56. 'zxrenid' => $this->rock->post($fields.'id'),
  57. 'itemid'=> $rs['id'],
  58. 'mid' => $this->id,
  59. 'comid' => $this->rs['comid'],
  60. 'sort' => $rs['sort'],
  61. );
  62. if($dbs->rows($where)==0)$where='';
  63. $dbs->record($uarr, $where);
  64. }
  65. $this->updaterenshu($sid);
  66. }
  67. public function updaterenshu($sid)
  68. {
  69. $zrshu = $this->rows('`leixing`='.$sid.' and `type`=3 and `status`<>5');
  70. $this->update('`leixing`='.$zrshu.'', $sid);
  71. }
  72. protected function flowrsreplaceedit($rs)
  73. {
  74. $this->addotherfield();
  75. $zrows = m($this->subtable)->getall('mid='.$rs['id'].'','*','`sort`');
  76. foreach($zrows as $k=>$rs1){
  77. $rs['sitemid_'.$rs1['itemid'].''] = $rs1['zxren'];
  78. $this->rssust['sitemid_'.$rs1['itemid'].''] = $rs1['zxren'];
  79. }
  80. return $rs;
  81. }
  82. /*
  83. protected function flowgetfields($lx)
  84. {
  85. $zrows = m($this->subtable)->getall('mid='.$this->id.'','*','`sort`');
  86. $arr = array();
  87. foreach($zrows as $k=>$rs1){
  88. $arr['sitemid_'.$rs1['itemid'].''] = $rs1['pitem'];
  89. }
  90. return $arr;
  91. }*/
  92. private function addotherfield()
  93. {
  94. $frs = $this->fieldsarra[0];
  95. $sid = $this->rs['leixing'];
  96. $zrows = m($this->subtable)->getall('mid='.$sid.'','*','`sort`');
  97. foreach($zrows as $k=>$rs1){
  98. $frs['name'] = $rs1['pitem'];
  99. $frs['fieldstype'] = $rs1['zxren'];
  100. $frs['islu'] = '1';
  101. $frs['fields'] = 'sitemid_'.$rs1['id'];
  102. $this->fieldsarra[] = $frs;
  103. $this->fieldsarr[] = $frs;
  104. }
  105. }
  106. public function flowrsreplace($rs, $lx=0)
  107. {
  108. if($lx==1 || $lx==3){
  109. $rs = $this->flowrsreplaceedit($rs);
  110. }
  111. return $rs;
  112. }
  113. protected function flowzuofeibill($sm)
  114. {
  115. //$this->update('`leixing`=`leixing`-1', $this->rs['leixing']);
  116. $this->updaterenshu($this->rs['leixing']);
  117. m($this->subtable)->delete('`mid`='.$this->id.'');
  118. }
  119. public function flowxiangfields(&$fields)
  120. {
  121. $fields['base_name'] = '填写人';
  122. $fields['base_deptname'] = '填写人部门';
  123. return $fields;
  124. }
  125. protected function flowbillwhere($uid, $lx)
  126. {
  127. $where = '';
  128. $leixingid = (int)$this->rock->post('leixingid');
  129. if($leixingid>0)$where='and `leixing`='.$leixingid.'';
  130. return array(
  131. 'keywhere' => $where,
  132. );
  133. }
  134. }
粤ICP备19079148号