ProController.php 16 KB

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