RProjectController.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <?php
  2. Doo::loadClass('auth');
  3. Doo::loadClass('attfile');
  4. Doo::loadClass('profile');
  5. Doo::loadClass('project');
  6. Doo::loadClass('contractact');
  7. Doo::loadClass('actmeasure');
  8. Doo::loadClass('measureauditact');
  9. Doo::loadClass('numofperact');
  10. Doo::loadClass('itemmeasurenum');
  11. Doo::loadClass('itemfile');
  12. /**
  13. * MainController
  14. * Feel free to delete the methods and replace them with your own code.
  15. *
  16. * @author darkredz
  17. */
  18. class RProjectController extends DooController
  19. {
  20. private $data, $auth, $attfile, $profile, $project, $contractact, $actmeasure, $measureauditact, $numofperact, $statusArray = array('uncheck' => '未审批', 'checking' => '审批中', 'checked' => '已审批', 'checkno' => '未通过'), $itemfile, $itemmeasurenum;
  21. public function __construct()
  22. {
  23. $this->auth = new Auth();
  24. $this->attfile = new attFile();
  25. $this->profile = new Profile();
  26. $this->project = new Project();
  27. $this->contractact = new Contractact();
  28. $this->actmeasure = new actMeasure();
  29. $this->measureauditact = new MeasureauditAct();
  30. $this->numofperact = new NumofperAct();
  31. $this->itemfile = new ItemFile();
  32. $this->itemmeasurenum = new ItemMeasureNumpofper();
  33. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  34. $this->data['currChannle'] = 'r';
  35. $this->data['user'] = $this->profile->getProWithUid($this->auth->getUid());
  36. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  37. if (isset($mpidArray[0]['pid'])) {
  38. $this->data['numofchecking'] = 0;
  39. foreach ($mpidArray as $key => $value) {
  40. // 审批操作按照时间排序多标段
  41. $this->data['numofchecking'] += $this->measureauditact->getCountMyChecking($value['pid'], $this->auth->getUid());
  42. }
  43. }
  44. if ($this->data['numofchecking'] == 0) {
  45. $this->data['numofchecking'] = null;
  46. }
  47. }
  48. public function beforeRun($resource, $action)
  49. {
  50. // $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  51. // $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  52. // if (!$falg)
  53. // return Doo::acl()->defaultFailedRoute;
  54. if ($this->auth->getUid()) {
  55. $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  56. $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  57. if (!$falg)
  58. return Doo::acl()->defaultFailedRoute;
  59. } else {
  60. return Doo::acl()->defaultFailedRoute;
  61. }
  62. }
  63. public function index()
  64. {
  65. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  66. if (isset($mpidArray[0]['pid'])) {
  67. foreach ($mpidArray as $key => $value) {
  68. // 审批操作按照时间排序多标段
  69. $numOfChecking = $this->measureauditact->getCountMyChecking($value['pid'], $this->auth->getUid());
  70. // end
  71. $this->data['proArray'][$key] = $this->project->getRowByPid($value['pid']);
  72. $this->data['proArray'][$key]['numofchecking'] = $numOfChecking;
  73. $this->data['proArray'][$key]['contracttotal'] = $this->actmeasure->getTotalWithPid($value['pid']);
  74. $this->data['proArray'][$key]['changTotal'] = $this->numofperact->getChangTotal($value['pid']);
  75. // $this->data['proArray'][$key]['contracttotal'] += $this->data['proArray'][$key]['changTotal'];
  76. $this->data['proArray'][$key]['currdone'] = $this->numofperact->getCurrDoneNow($value['pid']);
  77. if (($this->data['proArray'][$key]['contracttotal'] > 0) && ($this->data['proArray'][$key]['currdone'] > 0)) {
  78. $this->data['proArray'][$key]['pcurrdone'] = round(($this->data['proArray'][$key]['currdone'] / $this->data['proArray'][$key]['contracttotal']) * 100) . '%';
  79. } else {
  80. $this->data['proArray'][$key]['pcurrdone'] = '0%';
  81. }
  82. $this->data['proArray'][$key]['bcontracttotal'] = number_format($this->data['proArray'][$key]['contracttotal'], 2, '.', ',');
  83. $this->data['proArray'][$key]['bchangTotal'] = number_format($this->data['proArray'][$key]['changTotal'], 2, '.', ',');
  84. }
  85. } else {
  86. $this->data['proArray'] = array();
  87. }
  88. $this->render('r-project', $this->data);
  89. }
  90. public function proOverview()
  91. {
  92. // $this->data['pros'] = $this->project->getAll();
  93. // if (isset($_POST['pname']) && $_POST['pname']) {
  94. // $this->project->insertProject($_POST['pname']);
  95. // return Doo::conf()->APP_URL . 'project/index';
  96. // }
  97. $this->data['pid'] = $this->params['pid'];
  98. $this->render('w-project-detail', $this->data);
  99. }
  100. public function proSection()
  101. {
  102. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  103. foreach ($mpidArray as $k1 => $v1) {
  104. if ($v1['pid'] != $this->params['pid'])
  105. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  106. }
  107. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  108. $this->data['conArray'] = $this->contractact->getRowByPid($this->params['pid']);
  109. $auditArray = $this->measureauditact->getUserPmid($this->auth->getUid());
  110. foreach ($auditArray as $key => $value) {
  111. $pmidArray[] = $value['pmid'];
  112. }
  113. foreach ($this->data['conArray'] as $key => $value) {
  114. $html = null;
  115. $hetongTotal = $dispstopnowtotal = $dispnowtotal = $countNum = 0;
  116. $nstopnowtotal = $ncurrdone = $nnowtotal = number_format(0, 2, '.', ',');
  117. $pstopnowtotal = '0%';
  118. $pcurrdone = '0%';
  119. $ncurrdone = number_format(0, 2, '.', ',');
  120. $pnowtotal = '0%';
  121. $dispcurrdone = '0%';
  122. // $numStatusArray['currstatus'] = 'uncheck';
  123. $StidArray = $this->actmeasure->getAllbyStid($value['stid']);
  124. $currdoneInt = $this->numofperact->getCurrdoneSTID($value['stid'])['totalplus'];
  125. if (isset($StidArray))
  126. foreach ($StidArray as $k => $v) {
  127. if (in_array($v['pmid'], $pmidArray)) {
  128. $snTotal = $this->numofperact->getStopNowTotal($v['pmid']); //根据标段ID获取最新一期(包括不通过)
  129. $currcomTotal = $this->numofperact->getCurrdoneNew($v['pmid']); //截止目前
  130. $ncurrdone = number_format($currcomTotal['currtotal'], 2, '.', ',');
  131. $nstopnowtotal = number_format($snTotal['sntotal'], 2, '.', ',');
  132. if ($v['contracttotal'] > 0) {
  133. $nnowtotal = number_format($v['contracttotal'] - $currcomTotal['currtotal'] - $snTotal['sntotal'], 2, '.', ',');
  134. $pstopnowtotal = round(($snTotal['sntotal'] / $v['contracttotal']) * 100);
  135. $pcurrdone = round(($currcomTotal['currtotal'] / $v['contracttotal']) * 100);
  136. }
  137. $dispcurrdone = $pcurrdone . '%';
  138. $dispstopnowtotal = $pstopnowtotal . '%';
  139. $pnowtotal = 100 - $pcurrdone - $pstopnowtotal;
  140. $dispnowtotal = $pnowtotal . '%';
  141. $countNum = $this->numofperact->getLastNew2($v['pmid'])['numpname'];
  142. if (!isset($countNum)) {
  143. $countNum = 0;
  144. }
  145. $numStatusArray = $this->numofperact->getLastStatus3($this->params['pid'], $v['pmid']);
  146. if (!isset($numStatusArray['currstatus'])) {
  147. $numStatusArray['currstatus'] = 'uncheck';
  148. }
  149. $datatmp = $this->measureauditact->getMyAuditStatus2($numStatusArray['pmid'], $numStatusArray['numpname'], $numStatusArray['times'], $this->auth->getUid());
  150. if ($datatmp && ($datatmp['mastatus'] == 'checking')) {
  151. $buttonhtml = '<a class="btn btn-warning btn-small" href="/rproject/' . $this->params['pid'] . '/section/' . $v['pmid'] . '/report/' . $numStatusArray['mpid'] . '">开始审批</a>';
  152. } else {
  153. $buttonhtml = '(<span class="colOrange">' . $this->statusArray[$numStatusArray['currstatus']] . '</span>)';
  154. }
  155. $html .= '<tr>
  156. <td><a href="/rproject/' . $this->params['pid'] . '/section/' . $v['pmid'] . '/detail">' . $v['pmname'] . '</a></td>
  157. <td class="">第 ' . $countNum . ' 期 ' . $buttonhtml . '</td>
  158. <td class="taR">¥' . number_format($v['contracttotal'], 2, '.', ',') . '</td>
  159. <td>
  160. <div class="progress">
  161. <div class="bar bar-success" style="width: ' . $dispstopnowtotal . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成:¥' . $nstopnowtotal . '">' . $dispstopnowtotal . '</div>
  162. <div class="bar" style="width:' . $dispcurrdone . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' . $ncurrdone . '">' . $dispcurrdone . '</div>
  163. <div class="bar bar-gary" style="width:' . $dispnowtotal . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $nnowtotal . '">' . $dispnowtotal . '</div>
  164. </div>
  165. </td>
  166. </tr>';
  167. $hetongTotal += $v['contracttotal'];
  168. }
  169. }
  170. $this->data['conArray'][$key]['htmlstr'] = $html;
  171. $this->data['conArray'][$key]['hetongTotal'] = number_format($hetongTotal, 2, '.', ',');
  172. $this->data['conArray'][$key]['phetongTotal'] = 0;
  173. $this->data['conArray'][$key]['nhetongTotal'] = 0;
  174. $this->data['conArray'][$key]['phetongTotal2'] = 0;
  175. $this->data['conArray'][$key]['ncurrdoneInt'] = 0;
  176. $this->data['conArray'][$key]['phetongTotal'] = round(($currdoneInt / $hetongTotal) * 100) . '%';
  177. $this->data['conArray'][$key]['nhetongTotal'] = number_format($currdoneInt, 2, '.', ',');
  178. $this->data['conArray'][$key]['phetongTotal2'] = round((($hetongTotal - $currdoneInt) / $hetongTotal) * 100) . '%';
  179. $this->data['conArray'][$key]['ncurrdoneInt'] = number_format($hetongTotal - $currdoneInt, 2, '.', ',');
  180. }
  181. $this->render('r-project-section', $this->data, TRUE);
  182. }
  183. function proSectionMeasure()
  184. {
  185. $mpidArray = $this->measureauditact->getAuditProject($this->auth->getUid());
  186. foreach ($mpidArray as $k1 => $v1) {
  187. if ($v1['pid'] != $this->params['pid'])
  188. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  189. }
  190. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  191. $this->data['pid'] = $this->params['pid'];
  192. $this->data['mpid'] = $this->params['mpid'];
  193. $this->data['mastatus'] = $this->measureauditact->getStatusByMpid($this->params['mpid'])['mastatus'];
  194. if (isset($_POST['submit'])) {
  195. if ($_POST['submit'] == 'ok') {
  196. $this->measureauditact->setStatusTrue($this->params['mpid']);
  197. return Doo::conf()->APP_URL . 'rproject/' . $this->params['pid'] . '/section/' . $this->params['mpid'] . '/measure';
  198. }
  199. if ($_POST['submit'] == 'no') {
  200. $this->measureauditact->setStatusFalse($this->params['mpid']);
  201. return Doo::conf()->APP_URL . 'rproject/' . $this->params['pid'] . '/section/' . $this->params['mpid'] . '/measure';
  202. }
  203. }
  204. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  205. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  206. // if ($handle = opendir($extPathdir)) {
  207. // while (false !== ($file = readdir($handle))) {
  208. // $filename = pathinfo($file);
  209. // if ($filename['extension'] == 'json')
  210. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  211. // }
  212. // closedir($handle);
  213. // }
  214. // $this->data['proArray'] = $proArray;
  215. $this->render('r-project-section-measure', $this->data, TRUE);
  216. }
  217. function proSectionFiles()
  218. {
  219. $mpidArray = $this->measureauditact->getAuditProject($this->auth->getUid());
  220. foreach ($mpidArray as $k1 => $v1) {
  221. if ($v1['pid'] != $this->params['pid'])
  222. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  223. }
  224. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  225. $this->data['itematta'] = $this->itemmeasurenum->getItemMeasureNum($this->params['pmid']);
  226. foreach ($this->data['itematta'] as $k => $v) {
  227. $fileArray = $this->itemfile->getItemFile($v['iaid']);
  228. $this->data['itematta'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  229. $this->data['itematta'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  230. $this->data['itematta'][$k]['filename'] = $fileArray['filename'];
  231. $this->data['itematta'][$k]['fileext'] = $fileArray['fileext'];
  232. $this->data['itematta'][$k]['iaid'] = $fileArray['iaid'];
  233. $this->data['itematta'][$k]['tips'] = $v['tips'];
  234. }
  235. $this->data['pid'] = $this->params['pid'];
  236. $this->data['pmid'] = $this->params['pmid'];
  237. $this->data['mpid'] = $this->params['mpid'];
  238. $this->render('r-project-section-files', $this->data, TRUE);
  239. }
  240. /**
  241. * @return actMeasure
  242. */
  243. public function proSectionGetFiles()
  244. {
  245. $attaArray = $this->itemfile->getItemFile($this->params['iaid']);
  246. $this->file_down($attaArray['filepath'], $attaArray['filesize'], $attaArray['filename']);
  247. return;
  248. }
  249. /**
  250. * 文件下载
  251. * @param $filepath 文件路径
  252. * @param $filename 文件名称
  253. */
  254. function file_down($filepath, $filesize, $filename = '')
  255. {
  256. if (!$filename)
  257. $filename = basename($filepath);
  258. if ($this->is_ie())
  259. $filename = rawurlencode($filename);
  260. $filetype = $this->fileext($filename);
  261. // $filesize = sprintf("%u", filesize($filepath));
  262. if (ob_get_length() !== false)
  263. @ob_end_clean();
  264. header('Pragma: public');
  265. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  266. header('Cache-Control: no-store, no-cache, must-revalidate');
  267. header('Cache-Control: pre-check=0, post-check=0, max-age=0');
  268. header('Content-Transfer-Encoding: binary');
  269. header('Content-Encoding: none');
  270. header('Content-type: ' . $filetype);
  271. header('Content-Disposition: attachment; filename="' . $filename . '"');
  272. header('Content-length: ' . $filesize);
  273. @readfile($filepath);
  274. exit;
  275. }
  276. /**
  277. * IE浏览器判断
  278. */
  279. function is_ie()
  280. {
  281. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  282. if ((strpos($useragent, 'opera') !== false) || (strpos($useragent, 'konqueror') !== false))
  283. return false;
  284. if (strpos($useragent, 'msie ') !== false)
  285. return true;
  286. return false;
  287. }
  288. /**
  289. * 取得文件扩展
  290. *
  291. * @param $filename 文件名
  292. * @return 扩展名
  293. */
  294. function fileext($filename)
  295. {
  296. return strtolower(trim(substr(strrchr($filename, '.'), 1, 10)));
  297. }
  298. Function fNumber($number)
  299. {
  300. if ($number == '')
  301. Return "-";
  302. $nlen = strlen($number);
  303. while ($nlen > 3) {
  304. $fNumber = "," . substr($number, $nlen - 3, 3);
  305. $number = substr($number, 0, -3);
  306. $nlen = strlen($number);
  307. }
  308. if ($nlen <= 3) {
  309. $fNumber = $number . $fNumber;
  310. }
  311. Return $fNumber;
  312. }
  313. public function welcome()
  314. {
  315. // if (!$this->auth->isLoggedIn())
  316. // return Doo::conf()->APP_URL;
  317. if ($this->profile->getProWithUid($_SESSION['uid'])['userid'])
  318. return Doo::conf()->APP_URL . 'project/list';
  319. if (isset($_POST['welform'])) {
  320. $profileUserArray = $_POST;
  321. $profileUserArray['userid'] = $_SESSION['uid'];
  322. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  323. return Doo::conf()->APP_URL . 'project/list';
  324. }
  325. $this->render('welcome', $this->data);
  326. }
  327. public function prolist()
  328. {
  329. // if (!$this->auth->isLoggedIn())
  330. // return Doo::conf()->APP_URL;
  331. // $proArray = new stdClass();
  332. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  333. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  334. // if ($handle = opendir($extPathdir)) {
  335. // while (false !== ($file = readdir($handle))) {
  336. // $filename = pathinfo($file);
  337. // if ($filename['extension'] == 'json')
  338. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  339. // }
  340. // closedir($handle);
  341. // }
  342. // $this->data['proArray'] = null;
  343. $this->render('s-project', $this->data);
  344. }
  345. public function proDetail()
  346. {
  347. $numStatusArray = $this->numofperact->getLastRow($this->params['pid'], $this->params['pmid']);
  348. // 项目名称
  349. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  350. foreach ($mpidArray as $k1 => $v1) {
  351. if ($v1['pid'] != $this->params['pid'])
  352. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  353. }
  354. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  355. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  356. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  357. foreach ($this->data['MeasureArray'] as $key => $value) {
  358. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  359. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  360. } else {
  361. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  362. }
  363. }
  364. $this->data['pmid'] = $this->params['pmid'];
  365. $this->data['pid'] = $this->params['pid'];
  366. $this->data['mpid'] = $numStatusArray['mpid'];
  367. $this->render('r-project-section-detail', $this->data, TRUE);
  368. }
  369. public function proReport()
  370. {
  371. // 面包屑导航
  372. // 期数列表
  373. $tmpArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  374. foreach ($tmpArray as $k => $v) {
  375. $intTime = $this->numofperact->getMaxTimes($v['pmid'], $v['numpname'])['times'];
  376. $nfArray[] = $this->numofperact->getRow($v['pmid'], $v['numpname'], $intTime);
  377. }
  378. foreach ($nfArray as $k => $v) {
  379. if ($v['mpid'] == $this->params['mpid']) {
  380. $this->data['mpid'] = $v['mpid'];
  381. $this->data['MeasureArray2'][] = $v;
  382. $this->data['currnum'] = $v['numpname'];
  383. } else {
  384. $this->data['numArray'][] = $v;
  385. }
  386. }
  387. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  388. foreach ($this->data['MeasureArray2'] as $key => $value) {
  389. if ($value['mpid'] == $this->params['mpid']) {
  390. $this->data['MeasureArray2'][$key]['currstatus'] = $this->statusArray[$value['currstatus']];
  391. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  392. $this->data['MeasureArray2'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  393. } else {
  394. $this->data['MeasureArray2'][$key]['lessTotal'] = 0;
  395. }
  396. }
  397. }
  398. //
  399. $lastRowArray = $this->numofperact->getLastNew2($this->params['pmid']);
  400. $maxTimes = $this->numofperact->getMaxTimes($lastRowArray['pmid'], $lastRowArray['numpname']);
  401. // $auditUserArray = $this->measureauditact->getAllAudit($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  402. $maxtimez = $this->measureauditact->getRowGroupByTimes($this->params['mpid']);
  403. $auditUserArray = $this->measureauditact->getRowByMpidTimes($this->params['mpid'], $maxtimez['times']);
  404. $auditArray = $this->measureauditact->getLastNewRowInfo($lastRowArray['pmid'], $lastRowArray['numpname'], $this->auth->getUid());
  405. if (isset($_POST['act'])) {
  406. $auditStatusArray = array('checkno', 'checked');
  407. $myAuditStatus = $this->measureauditact->getMyAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times'], $this->auth->getUid());
  408. if (in_array($myAuditStatus['mastatus'], $auditStatusArray)) {
  409. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  410. die();
  411. }
  412. }
  413. if ($_POST['act'] == 'p') {
  414. if ($this->measureauditact->setMyAuditPass($auditArray['maid'], $_POST['content'], 1, $this->auth->getUid())) {
  415. $countAudit = count($auditUserArray);
  416. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  417. if ($auditArray['last'] == 1) {
  418. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checked', $maxTimes['times']);
  419. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  420. die();
  421. } else {
  422. if (($countAudit == 2) && ($auditUserArray[1]['last'] == 1) && ($auditUserArray[0]['maid'] == $auditArray['maid'])) {
  423. $this->measureauditact->updateMastatus($auditUserArray[1]['maid']);
  424. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  425. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  426. die();
  427. }
  428. if (($countAudit > 2)) {
  429. foreach ($auditUserArray as $k => $v) {
  430. if ($v['maid'] == $auditArray['maid']) {
  431. if ($k == ($countAudit - 1)) {//如果是最后一个
  432. $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);
  433. } else {
  434. $this->measureauditact->updateMastatus($auditUserArray[$k + 1]['maid']);
  435. }
  436. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  437. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  438. die();
  439. }
  440. }
  441. }
  442. }
  443. }
  444. }
  445. if ($_POST['act'] == 'np') {
  446. $this->measureauditact->setCheckno($auditArray['maid'], $_POST['content'], 1);
  447. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checkno', $maxTimes['times']);
  448. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  449. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  450. die();
  451. }
  452. $this->data['pmid'] = $lastRowArray['pmid'];
  453. $this->data['numpname'] = $lastRowArray['numpname'];
  454. $this->data['times'] = $lastRowArray['times'];
  455. $this->data['pid'] = $this->params['pid'];
  456. foreach ($auditUserArray as $key => $value) {
  457. $strAvatar = $this->auth->getAvatar($value['auditoruid']);
  458. $i = $key + 1;
  459. if ($value['auditoruid'] == $this->auth->getUid()) {
  460. $this->data['mastatus'] = $value['mastatus'];
  461. $this->data['maid'] = $value['maid'];
  462. }
  463. if ($value['mastatus'] == 'uncheck') {
  464. $statuStr = '';
  465. $statucolorStr = '';
  466. $statushtml = '<li title="" class=""><img src="' . $strAvatar . '"></li>';
  467. }
  468. if ($value['mastatus'] == 'checking') {
  469. $statuStr = '<h4 class="colOrange">审批中</h4>';
  470. $statucolorStr = 'colOrange';
  471. $statushtml = '<li title="审批中" class="wait"><span data-icon="k" aria-hidden="true"></span> <img src="' . $strAvatar . '"></li>';
  472. }
  473. if ($value['mastatus'] == 'checked') {
  474. $statuStr = '<h4 class="colGreen">审批完成(' . date('Y-m-d', $value['audittime']) . ')</h4>';
  475. $statucolorStr = 'colGreen';
  476. $statushtml = '<li title="审批通过" class="pass"><span data-icon="d" aria-hidden="true"></span><img src="' . $strAvatar . '"></li>';
  477. }
  478. if ($value['mastatus'] == 'checkno') {
  479. $statuStr = '<h4 class="colRed">审批不通过(' . date('Y-m-d', $value['audittime']) . ')</h4>';
  480. $statucolorStr = 'colRed';
  481. $statushtml = '<li title="审批不通过" class="notpass"><span data-icon="e" aria-hidden="true"></span><img src="' . $strAvatar . '"></li>';
  482. }
  483. $auditUserArray[$key]['statuStr'] = $statuStr;
  484. $auditUserArray[$key]['statucolorStr'] = $statucolorStr;
  485. $auditUserArray[$key]['statushtml'] = $statushtml;
  486. $auditUserArray[$key]['k'] = $i;
  487. $auditUserArray[$key]['name'] = $this->profile->getProWithUid($value['auditoruid'])['name'];
  488. }
  489. $this->data['auditArray'] = $auditUserArray;
  490. $this->data['pmid'] = $this->params['pmid'];
  491. $this->data['pid'] = $this->params['pid'];
  492. $this->data['mpid'] = $this->params['mpid'];
  493. $this->render('r-project-section-report', $this->data, TRUE);
  494. }
  495. }
  496. ?>