ProController.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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. $power = $this->checkPower($_SESSION['auid']);
  59. if($power['itempower'] != 1) {
  60. echo 'No access is allowed for the current page.';
  61. die;
  62. }
  63. }
  64. function checkPower($auid) {
  65. $auserinfo = $this->user->getRowByID($auid);
  66. if($auserinfo['issuper'] == 0){
  67. return $powerArray = json_decode($auserinfo['powerjson'], true);
  68. } else {
  69. return array('itempower' => 1);
  70. }
  71. }
  72. public function index()
  73. {
  74. if(isset($_POST['type']) && isset($_POST['pid'])){
  75. if($_POST['type'] == 'del'){
  76. $num = $this->cc->getNumRow($_POST['pid']);
  77. if($num > 0){
  78. die(json_encode(array('status' => 1)));
  79. }else{
  80. die(json_encode(array('status' => 2)));
  81. }
  82. }
  83. if($_POST['type'] == "delpro"){
  84. $this->project->del($_POST['pid']);
  85. die(json_encode(array('status' => 'ok')));
  86. }
  87. }
  88. $pArray = $this->project->getAll();
  89. if(!empty($pArray)){
  90. foreach($pArray as $k => $v){
  91. $pArray[$k]['mnum'] = $this->cc->getNumRow($v['pid']);
  92. $userfile = $this->profile->getProWithUid($v['uid']);
  93. $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';
  94. $pArray[$k]['uname'] = $userfile['name'].$company;
  95. }
  96. }
  97. $this->data['pArray'] = $pArray;
  98. $this->data['menu'] = 5;
  99. $this->render('admin-project', $this->data, TRUE);
  100. }
  101. public function section()
  102. {
  103. if(isset($_POST['type'])){
  104. if($_POST['type'] == 'del' && isset($_POST['stid'])){
  105. $num = $this->am->getRowNum($_POST['stid']);
  106. if($num > 0){
  107. die(json_encode(array('status' => 1)));
  108. }else{
  109. die(json_encode(array('status' => 2)));
  110. }
  111. }
  112. if($_POST['type'] == 'delpro' && isset($_POST['stid'])){
  113. $this->cc->del($_POST['stid']);
  114. die(json_encode(array('status' => 'ok')));
  115. }
  116. if($_POST['type'] == 'delmcheck' && isset($_POST['pmid'])){
  117. // $num = $this->an->getLastNew2($_POST['pmid']);
  118. $pmArray = $this->an->getGroupByLastOne2($_POST['pmid']);
  119. if(empty($pmArray) || (isset($pmArray[0]['numpname']) && $pmArray[0]['numpname'] == 1 && $pmArray[0]['times'] == 0)){
  120. die(json_encode(array('status' => 2)));
  121. }else{
  122. die(json_encode(array('status' => 1)));
  123. }
  124. }
  125. if($_POST['type'] == 'delmpro' && isset($_POST['pmid'])){
  126. $this->am->del($_POST['pmid']);
  127. //删除该标段下第1期#1所有审批人列表
  128. // $anmsg = $this->an->getLastNew2($_POST['pmid']);
  129. $this->ama->delMeasureAuditListbyPmid($_POST['pmid']);
  130. // if(!empty($anmsg)){
  131. // $muaudits = $this->ama->getAuditsByMpid($anmsg['mpid']);
  132. // if(!empty($muaudits)){
  133. // foreach($muaudits as $k => $v){
  134. // $this->ama->del($v['maid']);
  135. // }
  136. // }
  137. // $this->an->del($anmsg['mpid']);
  138. //文件列也要删除,不然软件报错
  139. $this->attfile->delAllTimesFile3($_POST['pmid']);
  140. //删除标段关注、签署表,中间计量表,附件的内容,变更令的内容
  141. $this->concern->delMeasureConcernListbyPmid($_POST['pmid']);
  142. $this->sign->delSignbyTenderAndPhaseno($_POST['pmid']);
  143. $this->itemmeasurenum->delItembyPmid($_POST['pmid']);
  144. $this->change->delAllChangebyPmid($_POST['pmid']);
  145. die(json_encode(array('status' => 'ok')));
  146. }
  147. }
  148. $typeArray = $this->cc->getRowByPid($this->params['pid']);
  149. if(!empty($typeArray)){
  150. foreach($typeArray as $k => $v){
  151. $datarows = $this->am->getRowswith($v['stid']);
  152. if(!empty($datarows)){
  153. foreach($datarows as $dk => $dv){
  154. $userfile = $this->profile->getProWithUid($dv['uid']);
  155. $datarows[$dk]['name'] = $userfile['name'];
  156. $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';
  157. $datarows[$dk]['company'] = $company;
  158. //获取第几期和审核状态
  159. $countNum = $this->an->getLastNew2($dv['pmid'])['numpname'];
  160. if (!isset($countNum)) {
  161. $countNum = 0;
  162. }
  163. $lastStatusArray = $this->an->getMaxStatusTimes($dv['pmid'], $countNum);
  164. $datarows[$dk]['num'] = $countNum;
  165. $nopm = $this->ama->getLastAuditMsgByPmid($dv['pmid']);
  166. $pmArray = $this->an->getGroupByLastOne2($dv['pmid']);
  167. if(!empty($nopm) && !empty($pmArray) && $nopm['numpname'] == $pmArray[0]['numpname'] && $nopm['times'] != $pmArray[0]['times']){
  168. $datarows[$dk]['status'] = $this->statusArray['uncheck'];
  169. }else{
  170. $datarows[$dk]['status'] = $countNum != 0 ? $this->statusArray[$lastStatusArray['currstatus']] : '';
  171. }
  172. }
  173. }
  174. $typeArray[$k]['datarows'] = $datarows;
  175. }
  176. }
  177. $this->data['pid'] = $this->params['pid'];
  178. $this->data['typeArray'] = $typeArray;
  179. $this->data['menu'] = 5;
  180. $this->render('admin-section', $this->data, TRUE);
  181. }
  182. public function period(){
  183. if(isset($_POST['op'])){
  184. if($_POST['op'] == 'pass' && 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)){
  190. $nextmumsg = $this->ama->getAuditByMpidStatus($mamsg['mpid'],'uncheck');
  191. if(!empty($nextmumsg)){
  192. $this->ama->updateStatus($nextmumsg['maid'],'checking',2,0);
  193. }else{
  194. $this->an->updateAuditStatus($mamsg['mpid'],'checked');
  195. }
  196. }
  197. //修改状态为checked
  198. $this->ama->updateStatus($_POST['maid'],'checked');
  199. $this->attfile->updateHash($mumsg['pmid'], $mumsg['numpname'], $mumsg['times']);
  200. }
  201. die(json_encode(array('status' => 'ok')));
  202. }
  203. if($_POST['op'] == 'unpass' && isset($_POST['maid'])){
  204. $mamsg = $this->ama->getRowData($_POST['maid']);
  205. if(!empty($mamsg)){
  206. $mumsg = $this->an->getRowByMpid($mamsg['mpid']);
  207. //修改期数状态
  208. if(!empty($mumsg)){
  209. $this->an->updateAuditStatus($mamsg['mpid'],'checkno');
  210. }
  211. //修改状态为checkno
  212. $this->ama->updateStatus($_POST['maid'],'checkno');
  213. $this->attfile->updateHash($mumsg['pmid'], $mumsg['numpname'], $mumsg['times']);
  214. }
  215. die(json_encode(array('status' => 'ok')));
  216. }
  217. if($_POST['op'] == 'checking' && isset($_POST['maid'])){
  218. $mamsg = $this->ama->getRowData($_POST['maid']);
  219. if(!empty($mamsg)){
  220. $mumsg = $this->an->getRowByMpid($mamsg['mpid']);
  221. //修改期数状态
  222. if(!empty($mumsg) && $mumsg['currstatus'] != 'checking'){
  223. $this->an->updateAuditStatus($mamsg['mpid'],'checking');
  224. }
  225. //修改上一审状态为uncheck,下一审状态为checking
  226. $lastmamsg = $this->ama->getAuditByMpidStatus($mamsg['mpid'],'checking');
  227. $this->ama->updateStatus($lastmamsg['maid'],'uncheck',2,0);
  228. $this->ama->updateStatus($_POST['maid'],'checking',2,0);
  229. //查看当前审批人附件是否存在,存在则删除
  230. $attfile = $this->attfile->getMyAttFile($mumsg['pmid'], $mumsg['numpname'], $mumsg['times'],$mamsg['auditoruid']);
  231. if(!empty($attfile)){
  232. $this->attfile->delMyAttFile($mumsg['pmid'], $mumsg['numpname'], $mumsg['times'],$mamsg['auditoruid']);
  233. //更新最后一个附件为最新 isnew=2
  234. $lastaid = $this->attfile->getLastFileAid($mumsg['pmid'], $mumsg['numpname'], $mumsg['times']);
  235. if(!empty($lastaid)){
  236. $this->attfile->updateIsNew2($lastaid);
  237. }
  238. }
  239. // $this->attfile->updateHash($mumsg['pmid'], $mumsg['numpname'], $mumsg['times']);
  240. }
  241. die(json_encode(array('status' => 'ok')));
  242. }
  243. if($_POST['op'] == 'delete' && isset($_POST['numpname']) && isset($_POST['times'])){
  244. //删除该期审批人列表
  245. $muaudits = $this->ama->getAuditsByPmidNumTimes($this->params['pmid'],$_POST['numpname'],$_POST['times']);
  246. if(!empty($muaudits)){
  247. foreach($muaudits as $k => $v){
  248. $this->ama->del($v['maid']);
  249. }
  250. }
  251. $mumsg = $this->an->getMsgByPmidNumTimes($this->params['pmid'],$_POST['numpname'],$_POST['times']);
  252. if(!empty($mumsg)){
  253. $this->an->del($mumsg['mpid']);
  254. //文件列也要删除,不然软件报错
  255. $this->attfile->delAllTimesFile2($mumsg['mpid']);
  256. //删除签署或中间计量表内容
  257. if($_POST['times'] == 0){
  258. $this->sign->delSignbyTenderAndPhaseno($this->params['pmid'],$_POST['numpname']);
  259. }
  260. }
  261. die(json_encode(array('status' => 'ok')));
  262. }
  263. }
  264. $pmArray = $this->an->getGroupByLastOne2($this->params['pmid']);
  265. $pmArray2 = $this->am->getOneRow($this->params['pmid']);
  266. $this->data['pid'] = $pmArray2['pid'];
  267. //判断是否有获取未上报的数据,如果有则置顶;
  268. $nopm = $this->ama->getLastAuditMsgByPmid($this->params['pmid']);
  269. $this->data['pmid'] = $this->params['pmid'];
  270. if(!empty($pmArray)){
  271. $this->data['keymax'] = $pmArray[0]['numpname'];
  272. if($nopm['numpname'] == $pmArray[0]['numpname'] && $nopm['times'] != $pmArray[0]['times']){
  273. $nopmArray = array();
  274. $nopmArray['mpid'] = $nopm['mpid'];
  275. $nopmArray['numpname'] = $nopm['numpname'];
  276. $nopmArray['times'] = $nopm['times']+1;
  277. $audits2 = $this->ama->getAuditsByPmidNumTimes($nopm['pmid'],$nopm['numpname'],$nopm['times']);
  278. $numaudits2 = $this->ama->getNumAuditsByPmidNumTimes($nopm['pmid'],$nopm['numpname'],$nopm['times']);
  279. if(!empty($audits2)){
  280. foreach($audits2 as $ak => $av){
  281. $audits2[$ak]['numaudit'] = $numaudits2-$ak;
  282. $audits2[$ak]['status'] = $this->statusArray2[$av['mastatus']];
  283. $audits2[$ak]['auditcontent'] = !empty($av['auditcontent']) ? $av['auditcontent'] : '';
  284. $userfile = $this->profile->getProWithUid($av['auditoruid']);
  285. $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';
  286. $audits2[$ak]['name'] = $userfile['name'];
  287. $audits2[$ak]['company'] = $company;
  288. $audits2[$ak]['enable'] = 3;
  289. }
  290. }
  291. $nopmArray['audits'] = $audits2;
  292. $this->data['nopmArray'] = $nopmArray;
  293. }
  294. foreach($pmArray as $k => $v){
  295. $pmArray[$k]['times'] = $v['times']+1;
  296. $audits = $this->ama->getAuditsByPmidNumTimes($v['pmid'],$v['numpname'],$v['times']);
  297. $numaudits = $this->ama->getNumAuditsByPmidNumTimes($v['pmid'],$v['numpname'],$v['times']);
  298. if(!empty($audits)){
  299. foreach($audits as $ak => $av){
  300. $audits[$ak]['numaudit'] = $numaudits-$ak;
  301. $audits[$ak]['status'] = $this->statusArray2[$av['mastatus']];
  302. $audits[$ak]['auditcontent'] = !empty($av['auditcontent']) ? $av['auditcontent'] : '';
  303. $userfile = $this->profile->getProWithUid($av['auditoruid']);
  304. $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';
  305. $audits[$ak]['name'] = $userfile['name'];
  306. $audits[$ak]['company'] = $company;
  307. $audits[$ak]['enable'] = 3;
  308. if($audits[0]['mastatus'] == 'checked'){
  309. $audits[0]['enable'] = 2;
  310. }else{
  311. if($av['mastatus'] == "checking"){
  312. $audits[$ak]['enable'] = 1;
  313. }
  314. if(($ak > 0 && $audits[$ak-1]['mastatus'] == "checking") || $av['mastatus'] == "checkno"){
  315. $audits[$ak]['enable'] = 2;
  316. }
  317. }
  318. }
  319. }
  320. $pmArray[$k]['audits'] = $audits;
  321. }
  322. }
  323. $this->data['isnopm'] = isset($nopmArray) && !empty($nopmArray) ? 1 : 0;
  324. $this->data['pmArray'] = $pmArray;
  325. $this->data['menu'] = 5;
  326. $this->render('admin-period', $this->data, TRUE);
  327. }
  328. }