ProController.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <?php
  2. ini_set('display_errors', 1);
  3. session_start(); // starts new or resumes existing session
  4. Doo::loadModelAt('auser', 'admin');
  5. Doo::loadModelAt('ausers', 'admin');
  6. Doo::loadModelAt('ameasure', 'admin');
  7. Doo::loadModelAt('fileup', 'admin');
  8. Doo::loadModelAt('measureaudit', 'admin');
  9. Doo::loadModelAt('numofper', 'admin');
  10. Doo::loadModel('users');
  11. Doo::loadClass('profile');
  12. Doo::loadClass('contractact');
  13. Doo::loadClass('PasswordHash');
  14. Doo::loadClass('mailer');
  15. Doo::loadClass('project');
  16. Doo::loadClass('attfile');
  17. /*
  18. * To change this license header, choose License Headers in Project Properties.
  19. * To change this template file, choose Tools | Templates
  20. * and open the template in the editor.
  21. */
  22. // 列表停用 编辑 重置密码
  23. // 管理员权限管理
  24. // 管理员修改密码
  25. class ProController extends DooController
  26. {
  27. private $data, $users, $user, $profile, $ph, $userz, $mailer, $project, $am, $cc, $an, $attfile, $ama, $statusArray = array('uncheck' => '<span class = "colGray">未上报</span>', 'checking' => '<span class = "colOrange">审核中</span>', 'checked' => '<span class = "colGreen">完成</span>', 'checkno' => '<span class = "colRed">不通过</span>'), $statusArray2 = array('uncheck' => '', 'checking' => '<span class = "colOrange">审批中</span>', 'checked' => '<span class = "colGreen">审批通过</span>', 'checkno' => '<span class = "colRed">审批不通过</span>');
  28. public function beforeRun($resource, $action)
  29. {
  30. if (!isset($_SESSION['auid'])) {
  31. return Doo::conf()->APP_URL . 'manage';
  32. }
  33. }
  34. public function __construct()
  35. {
  36. $this->users = new AUsers();
  37. $this->user = new AUser();
  38. $this->userz = new Users();
  39. $this->profile = new Profile();
  40. $this->mailer = new Mailer();
  41. $this->ph = new PasswordHash(8, FALSE);
  42. $this->am = new Ameasure();
  43. $this->ama = new AmeasureAudit();
  44. $this->af = new Afileup();
  45. $this->an = new Anumofper();
  46. $this->project = new Project();
  47. $this->cc = new Contractact();
  48. $this->attfile = new attFile();
  49. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  50. }
  51. public function index()
  52. {
  53. if(isset($_POST['type']) && isset($_POST['pid'])){
  54. if($_POST['type'] == 'del'){
  55. $num = $this->cc->getNumRow($_POST['pid']);
  56. if($num > 0){
  57. die(json_encode(array('status' => 1)));
  58. }else{
  59. die(json_encode(array('status' => 2)));
  60. }
  61. }
  62. if($_POST['type'] == "delpro"){
  63. $this->project->del($_POST['pid']);
  64. die(json_encode(array('status' => 'ok')));
  65. }
  66. }
  67. $pArray = $this->project->getAll();
  68. if(!empty($pArray)){
  69. foreach($pArray as $k => $v){
  70. $pArray[$k]['mnum'] = $this->cc->getNumRow($v['pid']);
  71. $userfile = $this->profile->getProWithUid($v['uid']);
  72. $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';
  73. $pArray[$k]['uname'] = $userfile['name'].$company;
  74. }
  75. }
  76. $this->data['pArray'] = $pArray;
  77. $this->data['menu'] = 5;
  78. $this->render('admin-project', $this->data, TRUE);
  79. }
  80. public function section()
  81. {
  82. if(isset($_POST['type'])){
  83. if($_POST['type'] == 'del' && isset($_POST['stid'])){
  84. $num = $this->am->getRowNum($_POST['stid']);
  85. if($num > 0){
  86. die(json_encode(array('status' => 1)));
  87. }else{
  88. die(json_encode(array('status' => 2)));
  89. }
  90. }
  91. if($_POST['type'] == 'delpro' && isset($_POST['stid'])){
  92. $this->cc->del($_POST['stid']);
  93. die(json_encode(array('status' => 'ok')));
  94. }
  95. if($_POST['type'] == 'delmcheck' && isset($_POST['pmid'])){
  96. $num = $this->an->getLastNew2($_POST['pmid']);
  97. if(isset($num['numpname']) && !empty($num['numpname']) && $num['numpname'] != 1 && $num['times'] != 1){
  98. die(json_encode(array('status' => 1)));
  99. }else{
  100. die(json_encode(array('status' => 2)));
  101. }
  102. }
  103. if($_POST['type'] == 'delmpro' && isset($_POST['pmid'])){
  104. $this->am->del($_POST['pmid']);
  105. //删除该标段下第1期#1所有审批人列表
  106. $anmsg = $this->an->getLastNew2($_POST['pmid']);
  107. if(!empty($anmsg)){
  108. $muaudits = $this->ama->getAuditsByMpid($anmsg['mpid']);
  109. if(!empty($muaudits)){
  110. foreach($muaudits as $k => $v){
  111. $this->ama->del($v['maid']);
  112. }
  113. }
  114. $this->an->del($anmsg['mpid']);
  115. //文件列也要删除,不然软件报错
  116. $this->attfile->delAllTimesFile2($anmsg['mpid']);
  117. }
  118. die(json_encode(array('status' => 'ok')));
  119. }
  120. }
  121. $typeArray = $this->cc->getRowByPid($this->params['pid']);
  122. if(!empty($typeArray)){
  123. foreach($typeArray as $k => $v){
  124. $datarows = $this->am->getRowswith($v['stid']);
  125. if(!empty($datarows)){
  126. foreach($datarows as $dk => $dv){
  127. $userfile = $this->profile->getProWithUid($dv['uid']);
  128. $datarows[$dk]['name'] = $userfile['name'];
  129. $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';
  130. $datarows[$dk]['company'] = $company;
  131. //获取第几期和审核状态
  132. $countNum = $this->an->getLastNew2($dv['pmid'])['numpname'];
  133. if (!isset($countNum)) {
  134. $countNum = 0;
  135. }
  136. $lastStatusArray = $this->an->getMaxStatusTimes($dv['pmid'], $countNum);
  137. $datarows[$dk]['num'] = $countNum;
  138. $datarows[$dk]['status'] = $countNum != 0 ? $this->statusArray[$lastStatusArray['currstatus']] : '';
  139. }
  140. }
  141. $typeArray[$k]['datarows'] = $datarows;
  142. }
  143. }
  144. $this->data['pid'] = $this->params['pid'];
  145. $this->data['typeArray'] = $typeArray;
  146. $this->data['menu'] = 5;
  147. $this->render('admin-section', $this->data, TRUE);
  148. }
  149. public function period(){
  150. if(isset($_POST['op'])){
  151. if($_POST['op'] == 'pass' && isset($_POST['maid'])){
  152. $mamsg = $this->ama->getRowData($_POST['maid']);
  153. if(!empty($mamsg)){
  154. $mumsg = $this->an->getRowByMpid($mamsg['mpid']);
  155. //修改期数状态
  156. if(!empty($mumsg)){
  157. $nextmumsg = $this->ama->getAuditByMpidStatus($mamsg['mpid'],'uncheck');
  158. if(!empty($nextmumsg)){
  159. $this->ama->updateStatus($nextmumsg['maid'],'checking',2,0);
  160. }else{
  161. $this->an->updateAuditStatus($mamsg['mpid'],'checked');
  162. }
  163. }
  164. //修改状态为checked
  165. $this->ama->updateStatus($_POST['maid'],'checked');
  166. $this->attfile->updateHash($mumsg['pmid'], $mumsg['numpname'], $mumsg['times']);
  167. }
  168. die(json_encode(array('status' => 'ok')));
  169. }
  170. if($_POST['op'] == 'unpass' && isset($_POST['maid'])){
  171. $mamsg = $this->ama->getRowData($_POST['maid']);
  172. if(!empty($mamsg)){
  173. $mumsg = $this->an->getRowByMpid($mamsg['mpid']);
  174. //修改期数状态
  175. if(!empty($mumsg)){
  176. $this->an->updateAuditStatus($mamsg['mpid'],'checkno');
  177. }
  178. //修改状态为checkno
  179. $this->ama->updateStatus($_POST['maid'],'checkno');
  180. $this->attfile->updateHash($mumsg['pmid'], $mumsg['numpname'], $mumsg['times']);
  181. }
  182. die(json_encode(array('status' => 'ok')));
  183. }
  184. if($_POST['op'] == 'checking' && isset($_POST['maid'])){
  185. $mamsg = $this->ama->getRowData($_POST['maid']);
  186. if(!empty($mamsg)){
  187. $mumsg = $this->an->getRowByMpid($mamsg['mpid']);
  188. //修改期数状态
  189. if(!empty($mumsg) && $mumsg['currstatus'] != 'checking'){
  190. $this->an->updateAuditStatus($mamsg['mpid'],'checking');
  191. }
  192. //修改上一审状态为uncheck,下一审状态为checking
  193. $lastmamsg = $this->ama->getAuditByMpidStatus($mamsg['mpid'],'checking');
  194. $this->ama->updateStatus($lastmamsg['maid'],'uncheck',2,0);
  195. $this->ama->updateStatus($_POST['maid'],'checking',2,0);
  196. //查看当前审批人附件是否存在,存在则删除
  197. $attfile = $this->attfile->getMyAttFile($mumsg['pmid'], $mumsg['numpname'], $mumsg['times'],$mamsg['auditoruid']);
  198. if(!empty($attfile)){
  199. $this->attfile->delMyAttFile($mumsg['pmid'], $mumsg['numpname'], $mumsg['times'],$mamsg['auditoruid']);
  200. //更新最后一个附件为最新 isnew=2
  201. $lastaid = $this->attfile->getLastFileAid($mumsg['pmid'], $mumsg['numpname'], $mumsg['times']);
  202. if(!empty($lastaid)){
  203. $this->attfile->updateIsNew2($lastaid);
  204. }
  205. }
  206. // $this->attfile->updateHash($mumsg['pmid'], $mumsg['numpname'], $mumsg['times']);
  207. }
  208. die(json_encode(array('status' => 'ok')));
  209. }
  210. if($_POST['op'] == 'delete' && isset($_POST['numpname']) && isset($_POST['times'])){
  211. //删除该期审批人列表
  212. $muaudits = $this->ama->getAuditsByPmidNumTimes($this->params['pmid'],$_POST['numpname'],$_POST['times']);
  213. if(!empty($muaudits)){
  214. foreach($muaudits as $k => $v){
  215. $this->ama->del($v['maid']);
  216. }
  217. }
  218. $mumsg = $this->an->getMsgByPmidNumTimes($this->params['pmid'],$_POST['numpname'],$_POST['times']);
  219. if(!empty($mumsg)){
  220. $this->an->del($mumsg['mpid']);
  221. //文件列也要删除,不然软件报错
  222. $this->attfile->delAllTimesFile2($mumsg['mpid']);
  223. }
  224. die(json_encode(array('status' => 'ok')));
  225. }
  226. }
  227. $pmArray = $this->an->getGroupByLastOne2($this->params['pmid']);
  228. //判断是否有获取未上报的数据,如果有则置顶;
  229. $nopm = $this->ama->getLastAuditMsgByPmid($this->params['pmid']);
  230. $this->data['pmid'] = $this->params['pmid'];
  231. if(!empty($pmArray)){
  232. $this->data['pid'] = $pmArray[0]['pid'];
  233. $this->data['keymax'] = $pmArray[0]['numpname'];
  234. if($nopm['numpname'] == $pmArray[0]['numpname'] && $nopm['times'] != $pmArray[0]['times']){
  235. $nopmArray = array();
  236. $nopmArray['mpid'] = $nopm['mpid'];
  237. $nopmArray['numpname'] = $nopm['numpname'];
  238. $nopmArray['times'] = $nopm['times']+1;
  239. $audits2 = $this->ama->getAuditsByPmidNumTimes($nopm['pmid'],$nopm['numpname'],$nopm['times']);
  240. $numaudits2 = $this->ama->getNumAuditsByPmidNumTimes($nopm['pmid'],$nopm['numpname'],$nopm['times']);
  241. if(!empty($audits2)){
  242. foreach($audits2 as $ak => $av){
  243. $audits2[$ak]['numaudit'] = $numaudits2-$ak;
  244. $audits2[$ak]['status'] = $this->statusArray2[$av['mastatus']];
  245. $audits2[$ak]['auditcontent'] = !empty($av['auditcontent']) ? $av['auditcontent'] : '';
  246. $userfile = $this->profile->getProWithUid($av['auditoruid']);
  247. $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';
  248. $audits2[$ak]['name'] = $userfile['name'];
  249. $audits2[$ak]['company'] = $company;
  250. $audits2[$ak]['enable'] = 3;
  251. }
  252. }
  253. $nopmArray['audits'] = $audits2;
  254. $this->data['nopmArray'] = $nopmArray;
  255. }
  256. foreach($pmArray as $k => $v){
  257. $pmArray[$k]['times'] = $v['times']+1;
  258. $audits = $this->ama->getAuditsByPmidNumTimes($v['pmid'],$v['numpname'],$v['times']);
  259. $numaudits = $this->ama->getNumAuditsByPmidNumTimes($v['pmid'],$v['numpname'],$v['times']);
  260. if(!empty($audits)){
  261. foreach($audits as $ak => $av){
  262. $audits[$ak]['numaudit'] = $numaudits-$ak;
  263. $audits[$ak]['status'] = $this->statusArray2[$av['mastatus']];
  264. $audits[$ak]['auditcontent'] = !empty($av['auditcontent']) ? $av['auditcontent'] : '';
  265. $userfile = $this->profile->getProWithUid($av['auditoruid']);
  266. $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';
  267. $audits[$ak]['name'] = $userfile['name'];
  268. $audits[$ak]['company'] = $company;
  269. $audits[$ak]['enable'] = 3;
  270. if($audits[0]['mastatus'] == 'checked'){
  271. $audits[0]['enable'] = 2;
  272. }else{
  273. if($av['mastatus'] == "checking"){
  274. $audits[$ak]['enable'] = 1;
  275. }
  276. if(($ak > 0 && $audits[$ak-1]['mastatus'] == "checking") || $av['mastatus'] == "checkno"){
  277. $audits[$ak]['enable'] = 2;
  278. }
  279. }
  280. }
  281. }
  282. $pmArray[$k]['audits'] = $audits;
  283. }
  284. }
  285. $this->data['isnopm'] = isset($nopmArray) && !empty($nopmArray) ? 1 : 0;
  286. $this->data['pmArray'] = $pmArray;
  287. $this->data['menu'] = 5;
  288. $this->render('admin-period', $this->data, TRUE);
  289. }
  290. }