ProController.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. /*
  17. * To change this license header, choose License Headers in Project Properties.
  18. * To change this template file, choose Tools | Templates
  19. * and open the template in the editor.
  20. */
  21. // 列表停用 编辑 重置密码
  22. // 管理员权限管理
  23. // 管理员修改密码
  24. class ProController extends DooController
  25. {
  26. private $data, $users, $user, $profile, $ph, $userz, $mailer, $project, $am, $cc, $an, $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>');
  27. public function beforeRun($resource, $action)
  28. {
  29. if (!isset($_SESSION['auid'])) {
  30. return Doo::conf()->APP_URL . 'manage';
  31. }
  32. }
  33. public function __construct()
  34. {
  35. $this->users = new AUsers();
  36. $this->user = new AUser();
  37. $this->userz = new Users();
  38. $this->profile = new Profile();
  39. $this->mailer = new Mailer();
  40. $this->ph = new PasswordHash(8, FALSE);
  41. $this->am = new Ameasure();
  42. $this->ama = new AmeasureAudit();
  43. $this->af = new Afileup();
  44. $this->an = new Anumofper();
  45. $this->project = new Project();
  46. $this->cc = new Contractact();
  47. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  48. }
  49. public function index()
  50. {
  51. if(isset($_POST['type']) && isset($_POST['pid'])){
  52. if($_POST['type'] == 'del'){
  53. $num = $this->cc->getNumRow($_POST['pid']);
  54. if($num > 0){
  55. die(json_encode(array('status' => 1)));
  56. }else{
  57. die(json_encode(array('status' => 2)));
  58. }
  59. }
  60. if($_POST['type'] == "delpro"){
  61. $this->project->del($_POST['pid']);
  62. die(json_encode(array('status' => 'ok')));
  63. }
  64. }
  65. $pArray = $this->project->getAll();
  66. if(!empty($pArray)){
  67. foreach($pArray as $k => $v){
  68. $pArray[$k]['mnum'] = $this->cc->getNumRow($v['pid']);
  69. $userfile = $this->profile->getProWithUid($v['uid']);
  70. $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';
  71. $pArray[$k]['uname'] = $userfile['name'].$company;
  72. }
  73. }
  74. $this->data['pArray'] = $pArray;
  75. $this->data['menu'] = 5;
  76. $this->render('admin-project', $this->data, TRUE);
  77. }
  78. public function section()
  79. {
  80. if(isset($_POST['type'])){
  81. if($_POST['type'] == 'del' && isset($_POST['stid'])){
  82. $num = $this->am->getRowNum($_POST['stid']);
  83. if($num > 0){
  84. die(json_encode(array('status' => 1)));
  85. }else{
  86. die(json_encode(array('status' => 2)));
  87. }
  88. }
  89. if($_POST['type'] == 'delpro' && isset($_POST['stid'])){
  90. $this->cc->del($_POST['stid']);
  91. die(json_encode(array('status' => 'ok')));
  92. }
  93. if($_POST['type'] == 'delmcheck' && isset($_POST['pmid'])){
  94. $num = $this->an->getLastNew2($_POST['pmid'])['numpname'];
  95. if(!empty($num)){
  96. die(json_encode(array('status' => 1)));
  97. }else{
  98. die(json_encode(array('status' => 2)));
  99. }
  100. }
  101. if($_POST['type'] == 'delmpro' && isset($_POST['pmid'])){
  102. $this->am->del($_POST['pmid']);
  103. die(json_encode(array('status' => 'ok')));
  104. }
  105. }
  106. $typeArray = $this->cc->getRowByPid($this->params['pid']);
  107. if(!empty($typeArray)){
  108. foreach($typeArray as $k => $v){
  109. $datarows = $this->am->getRowswith($v['stid']);
  110. if(!empty($datarows)){
  111. foreach($datarows as $dk => $dv){
  112. $userfile = $this->profile->getProWithUid($dv['uid']);
  113. $datarows[$dk]['name'] = $userfile['name'];
  114. $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';
  115. $datarows[$dk]['company'] = $company;
  116. //获取第几期和审核状态
  117. $countNum = $this->an->getLastNew2($dv['pmid'])['numpname'];
  118. if (!isset($countNum)) {
  119. $countNum = 0;
  120. }
  121. $lastStatusArray = $this->an->getMaxStatusTimes($dv['pmid'], $countNum);
  122. $datarows[$dk]['num'] = $countNum;
  123. $datarows[$dk]['status'] = $countNum != 0 ? $this->statusArray[$lastStatusArray['currstatus']] : '';
  124. }
  125. }
  126. $typeArray[$k]['datarows'] = $datarows;
  127. }
  128. }
  129. $this->data['pid'] = $this->params['pid'];
  130. $this->data['typeArray'] = $typeArray;
  131. $this->data['menu'] = 5;
  132. $this->render('admin-section', $this->data, TRUE);
  133. }
  134. public function period(){
  135. if(isset($_POST['op'])){
  136. if($_POST['op'] == 'pass' && isset($_POST['maid'])){
  137. $mamsg = $this->ama->getRowData($_POST['maid']);
  138. if(!empty($mamsg)){
  139. $mumsg = $this->an->getRowByMpid($mamsg['mpid']);
  140. //修改期数状态
  141. if(!empty($mumsg)){
  142. $nextmumsg = $this->ama->getAuditByMpidStatus($mamsg['mpid'],'uncheck');
  143. if(!empty($nextmumsg)){
  144. $this->ama->updateStatus($nextmumsg['maid'],'checking');
  145. }else{
  146. $this->an->updateAuditStatus($mamsg['mpid'],'checked');
  147. }
  148. }
  149. //修改状态为checked
  150. $this->ama->updateStatus($_POST['maid'],'checked');
  151. }
  152. die(json_encode(array('status' => 'ok')));
  153. }
  154. if($_POST['op'] == 'unpass' && isset($_POST['maid'])){
  155. $mamsg = $this->ama->getRowData($_POST['maid']);
  156. if(!empty($mamsg)){
  157. $mumsg = $this->an->getRowByMpid($mamsg['mpid']);
  158. //修改期数状态
  159. if(!empty($mumsg)){
  160. $this->an->updateAuditStatus($mamsg['mpid'],'checkno');
  161. }
  162. //修改状态为checkno
  163. $this->ama->updateStatus($_POST['maid'],'checkno');
  164. }
  165. die(json_encode(array('status' => 'ok')));
  166. }
  167. if($_POST['op'] == 'checking' && isset($_POST['maid'])){
  168. $mamsg = $this->ama->getRowData($_POST['maid']);
  169. if(!empty($mamsg)){
  170. $mumsg = $this->an->getRowByMpid($mamsg['mpid']);
  171. //修改期数状态
  172. if(!empty($mumsg) && $mumsg['currstatus'] != 'checking'){
  173. $this->an->updateAuditStatus($mamsg['mpid'],'checking');
  174. }
  175. //修改上一审状态为uncheck,下一审状态为checking
  176. $lastmamsg = $this->ama->getAuditByMpidStatus($mamsg['mpid'],'checking');
  177. $this->ama->updateStatus($lastmamsg['maid'],'uncheck');
  178. $this->ama->updateStatus($_POST['maid'],'checking');
  179. }
  180. die(json_encode(array('status' => 'ok')));
  181. }
  182. if($_POST['op'] == 'delete' && isset($_POST['mpid'])){
  183. //删除该期审批人列表
  184. $muaudits = $this->ama->getAuditsByMpid($_POST['mpid']);
  185. if(!empty($muaudits)){
  186. foreach($muaudits as $k => $v){
  187. $this->ama->del($v['maid']);
  188. }
  189. }
  190. $this->an->del($_POST['mpid']);
  191. die(json_encode(array('status' => 'ok')));
  192. }
  193. }
  194. $pmArray = $this->an->getGroupByLastOne2($this->params['pmid']);
  195. $this->data['pmid'] = $this->params['pmid'];
  196. if(!empty($pmArray)){
  197. $this->data['pid'] = $pmArray[0]['pid'];
  198. $this->data['keymax'] = $pmArray[0]['numpname'];
  199. foreach($pmArray as $k => $v){
  200. $pmArray[$k]['times'] = $v['times']+1;
  201. $audits = $this->ama->getAuditsByMpid($v['mpid']);
  202. $numaudits = $this->ama->getNumAuditsByMpid($v['mpid']);
  203. if(!empty($audits)){
  204. foreach($audits as $ak => $av){
  205. $audits[$ak]['numaudit'] = $numaudits-$ak;
  206. $audits[$ak]['status'] = $this->statusArray2[$av['mastatus']];
  207. $audits[$ak]['auditcontent'] = !empty($av['auditcontent']) ? $av['auditcontent'] : '';
  208. $userfile = $this->profile->getProWithUid($av['auditoruid']);
  209. $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';
  210. $audits[$ak]['name'] = $userfile['name'];
  211. $audits[$ak]['company'] = $company;
  212. $audits[$ak]['enable'] = 3;
  213. if($audits[0]['mastatus'] == 'checked'){
  214. $audits[0]['enable'] = 2;
  215. }else{
  216. if($av['mastatus'] == "checking"){
  217. $audits[$ak]['enable'] = 1;
  218. }
  219. if(($ak > 0 && $audits[$ak-1]['mastatus'] == "checking") || $av['mastatus'] == "checkno"){
  220. $audits[$ak]['enable'] = 2;
  221. }
  222. }
  223. }
  224. }
  225. $pmArray[$k]['audits'] = $audits;
  226. }
  227. }
  228. $this->data['pmArray'] = $pmArray;
  229. $this->data['menu'] = 5;
  230. $this->render('admin-period', $this->data, TRUE);
  231. }
  232. }