ProController.php 16 KB

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