RProjectController.php 27 KB

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