RProjectController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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. /**
  11. * MainController
  12. * Feel free to delete the methods and replace them with your own code.
  13. *
  14. * @author darkredz
  15. */
  16. class RProjectController extends DooController
  17. {
  18. private $data, $auth, $attfile, $profile, $project, $contractact, $actmeasure, $measureauditact, $numofperact, $statusArray = array('uncheck' => '未审核', 'checking' => '审核中', 'checked' => '已审核', 'checkno' => '未通过');
  19. public function __construct()
  20. {
  21. $this->auth = new Auth();
  22. $this->attfile = new attFile();
  23. $this->profile = new Profile();
  24. $this->project = new Project();
  25. $this->contractact = new Contractact();
  26. $this->actmeasure = new actMeasure();
  27. $this->measureauditact = new MeasureauditAct();
  28. $this->numofperact = new NumofperAct();
  29. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  30. $this->data['currChannle'] = 'r';
  31. $this->data['user'] = $this->profile->getProWithUid($this->auth->getUid());
  32. }
  33. public function beforeRun($resource, $action)
  34. {
  35. // $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  36. // $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  37. // if (!$falg)
  38. // return Doo::acl()->defaultFailedRoute;
  39. if ($this->auth->getUid()) {
  40. $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  41. $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  42. if (!$falg)
  43. return Doo::acl()->defaultFailedRoute;
  44. } else {
  45. return Doo::acl()->defaultFailedRoute;
  46. }
  47. }
  48. public function index()
  49. {
  50. $mpidArray = $this->measureauditact->getAuditProject($this->auth->getUid());
  51. if (isset($mpidArray[0]['pid'])) {
  52. foreach ($mpidArray as $key => $value) {
  53. // 审批操作按照时间排序多标段
  54. $numOfChecking = $this->measureauditact->getCountMyChecking($value['pid'], $this->auth->getUid());
  55. // end
  56. $this->data['proArray'][$key] = $this->project->getRowByPid($value['pid']);
  57. $this->data['proArray'][$key]['numofchecking'] = $numOfChecking;
  58. $this->data['proArray'][$key]['contracttotal'] = $this->actmeasure->getTotalWithPid($value['pid']);
  59. $this->data['proArray'][$key]['changTotal'] = $this->numofperact->getChangTotal($value['pid']);
  60. // $this->data['proArray'][$key]['contracttotal'] += $this->data['proArray'][$key]['changTotal'];
  61. $this->data['proArray'][$key]['currdone'] = $this->numofperact->getCurrDoneNow($value['pid']);
  62. if (($this->data['proArray'][$key]['contracttotal'] > 0) && ($this->data['proArray'][$key]['currdone'] > 0)) {
  63. $this->data['proArray'][$key]['pcurrdone'] = round(($this->data['proArray'][$key]['currdone'] / $this->data['proArray'][$key]['contracttotal']) * 100) . '%';
  64. } else {
  65. $this->data['proArray'][$key]['pcurrdone'] = '0%';
  66. }
  67. $this->data['proArray'][$key]['bcontracttotal'] = number_format($this->data['proArray'][$key]['contracttotal'], 2, '.', ',');
  68. $this->data['proArray'][$key]['bchangTotal'] = number_format($this->data['proArray'][$key]['changTotal'], 2, '.', ',');
  69. }
  70. } else {
  71. $this->data['proArray'] = array();
  72. }
  73. $this->render('r-project', $this->data);
  74. }
  75. public function proOverview()
  76. {
  77. // $this->data['pros'] = $this->project->getAll();
  78. // if (isset($_POST['pname']) && $_POST['pname']) {
  79. // $this->project->insertProject($_POST['pname']);
  80. // return Doo::conf()->APP_URL . 'project/index';
  81. // }
  82. $this->data['pid'] = $this->params['pid'];
  83. $this->render('w-project-detail', $this->data);
  84. }
  85. public function proSection()
  86. {
  87. $mpidArray = $this->measureauditact->getAuditProject($this->auth->getUid());
  88. foreach ($mpidArray as $k1 => $v1) {
  89. if ($v1['pid'] != $this->params['pid'])
  90. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  91. }
  92. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  93. $this->data['conArray'] = $this->contractact->getRowByPid($this->params['pid']);
  94. $auditArray = $this->measureauditact->getUserPmid($this->auth->getUid());
  95. foreach ($auditArray as $key => $value) {
  96. $pmidArray[] = $value['pmid'];
  97. }
  98. foreach ($this->data['conArray'] as $key => $value) {
  99. $html = null;
  100. $hetongTotal = $dispstopnowtotal = $dispnowtotal = $countNum = 0;
  101. $nstopnowtotal = $ncurrdone = $nnowtotal = number_format(0, 2, '.', ',');
  102. $pstopnowtotal = '0%';
  103. $pcurrdone = '0%';
  104. $ncurrdone = number_format(0, 2, '.', ',');
  105. $pnowtotal = '0%';
  106. $dispcurrdone = '0%';
  107. $numStatusArray['currstatus'] = 'uncheck';
  108. $StidArray = $this->actmeasure->getAllbyStid($value['stid']);
  109. $currdoneInt = $this->numofperact->getCurrdoneSTID($value['stid'])['totalplus'];
  110. if (isset($StidArray))
  111. foreach ($StidArray as $k => $v) {
  112. if (in_array($v['pmid'], $pmidArray)) {
  113. $snTotal = $this->numofperact->getStopNowTotal($v['pmid']); //根据标段ID获取最新一期(包括不通过)
  114. $currcomTotal = $this->numofperact->getCurrdoneNew($v['pmid']); //截止目前
  115. $ncurrdone = number_format($currcomTotal['currtotal'], 2, '.', ',');
  116. $nstopnowtotal = number_format($snTotal['sntotal'], 2, '.', ',');
  117. if ($v['contracttotal'] > 0) {
  118. $nnowtotal = number_format($v['contracttotal'] - $currcomTotal['currtotal'] - $snTotal['sntotal'], 2, '.', ',');
  119. $pstopnowtotal = round(($snTotal['sntotal'] / $v['contracttotal']) * 100);
  120. $pcurrdone = round(($currcomTotal['currtotal'] / $v['contracttotal']) * 100);
  121. }
  122. $dispcurrdone = $pcurrdone . '%';
  123. $dispstopnowtotal = $pstopnowtotal . '%';
  124. $pnowtotal = 100 - $pcurrdone - $pstopnowtotal;
  125. $dispnowtotal = $pnowtotal . '%';
  126. $countNum = $this->numofperact->getCountTotalnum($v['pmid']);
  127. $numStatusArray = $this->numofperact->getLastStatus($this->params['pid'], $v['pmid']);
  128. if (!isset($numStatusArray['currstatus'])) {
  129. $numStatusArray['currstatus'] = 'uncheck';
  130. }
  131. $datatmp = $this->measureauditact->getMyAuditStatus($numStatusArray['pmid'], $numStatusArray['numpname'], $numStatusArray['times'], $this->auth->getUid());
  132. if ($datatmp && ($datatmp['mastatus'] == 'checking')) {
  133. $buttonhtml = '<a class="btn btn-warning btn-small" href="/rproject/' . $this->params['pid'] . '/section/' . $v['pmid'] . '/report/' . $numStatusArray['mpid'] . '">开始审批</a>';
  134. } else {
  135. $buttonhtml = '(<span class="colOrange">' . $this->statusArray[$numStatusArray['currstatus']] . '</span>)';
  136. }
  137. $html .= '<tr>
  138. <td><a href="/rproject/' . $this->params['pid'] . '/section/' . $v['pmid'] . '/detail/' . $numStatusArray['mpid'] . '">' . $v['pmname'] . '</a></td>
  139. <td class="">第 ' . $countNum . ' 期 ' . $buttonhtml . '</td>
  140. <td class="taR">¥' . number_format($v['contracttotal'], 2, '.', ',') . '</td>
  141. <td>
  142. <div class="progress">
  143. <div class="bar bar-success" style="width: ' . $dispstopnowtotal . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成:¥' . $nstopnowtotal . '">' . $dispstopnowtotal . '</div>
  144. <div class="bar" style="width:' . $dispcurrdone . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' . $ncurrdone . '">' . $dispcurrdone . '</div>
  145. <div class="bar bar-gary" style="width:' . $dispnowtotal . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $nnowtotal . '">' . $dispnowtotal . '</div>
  146. </div>
  147. </td>
  148. </tr>';
  149. $hetongTotal += $v['contracttotal'];
  150. }
  151. }
  152. $this->data['conArray'][$key]['htmlstr'] = $html;
  153. $this->data['conArray'][$key]['hetongTotal'] = number_format($hetongTotal, 2, '.', ',');
  154. $this->data['conArray'][$key]['phetongTotal'] = 0;
  155. $this->data['conArray'][$key]['nhetongTotal'] = 0;
  156. $this->data['conArray'][$key]['phetongTotal2'] = 0;
  157. $this->data['conArray'][$key]['ncurrdoneInt'] = 0;
  158. $this->data['conArray'][$key]['phetongTotal'] = round(($currdoneInt / $hetongTotal) * 100) . '%';
  159. $this->data['conArray'][$key]['nhetongTotal'] = number_format($currdoneInt, 2, '.', ',');
  160. $this->data['conArray'][$key]['phetongTotal2'] = round((($hetongTotal - $currdoneInt) / $hetongTotal) * 100) . '%';
  161. $this->data['conArray'][$key]['ncurrdoneInt'] = number_format($hetongTotal - $currdoneInt, 2, '.', ',');
  162. }
  163. $this->render('r-project-section', $this->data, TRUE);
  164. }
  165. function proSectionMeasure()
  166. {
  167. $mpidArray = $this->measureauditact->getAuditProject($this->auth->getUid());
  168. foreach ($mpidArray as $k1 => $v1) {
  169. if ($v1['pid'] != $this->params['pid'])
  170. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  171. }
  172. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  173. $this->data['pid'] = $this->params['pid'];
  174. $this->data['mpid'] = $this->params['mpid'];
  175. $this->data['mastatus'] = $this->measureauditact->getStatusByMpid($this->params['mpid'])['mastatus'];
  176. if (isset($_POST['submit'])) {
  177. if ($_POST['submit'] == 'ok') {
  178. $this->measureauditact->setStatusTrue($this->params['mpid']);
  179. return Doo::conf()->APP_URL . 'rproject/' . $this->params['pid'] . '/section/' . $this->params['mpid'] . '/measure';
  180. }
  181. if ($_POST['submit'] == 'no') {
  182. $this->measureauditact->setStatusFalse($this->params['mpid']);
  183. return Doo::conf()->APP_URL . 'rproject/' . $this->params['pid'] . '/section/' . $this->params['mpid'] . '/measure';
  184. }
  185. }
  186. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  187. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  188. // if ($handle = opendir($extPathdir)) {
  189. // while (false !== ($file = readdir($handle))) {
  190. // $filename = pathinfo($file);
  191. // if ($filename['extension'] == 'json')
  192. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  193. // }
  194. // closedir($handle);
  195. // }
  196. // $this->data['proArray'] = $proArray;
  197. $this->render('r-project-section-measure', $this->data, TRUE);
  198. }
  199. Function fNumber($number)
  200. {
  201. if ($number == '')
  202. Return "-";
  203. $nlen = strlen($number);
  204. while ($nlen > 3) {
  205. $fNumber = "," . substr($number, $nlen - 3, 3);
  206. $number = substr($number, 0, -3);
  207. $nlen = strlen($number);
  208. }
  209. if ($nlen <= 3) {
  210. $fNumber = $number . $fNumber;
  211. }
  212. Return $fNumber;
  213. }
  214. public function welcome()
  215. {
  216. // if (!$this->auth->isLoggedIn())
  217. // return Doo::conf()->APP_URL;
  218. if ($this->profile->getProWithUid($_SESSION['uid'])['userid'])
  219. return Doo::conf()->APP_URL . 'project/list';
  220. if (isset($_POST['welform'])) {
  221. $profileUserArray = $_POST;
  222. $profileUserArray['userid'] = $_SESSION['uid'];
  223. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  224. return Doo::conf()->APP_URL . 'project/list';
  225. }
  226. $this->render('welcome', $this->data);
  227. }
  228. public function prolist()
  229. {
  230. // if (!$this->auth->isLoggedIn())
  231. // return Doo::conf()->APP_URL;
  232. // $proArray = new stdClass();
  233. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  234. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  235. // if ($handle = opendir($extPathdir)) {
  236. // while (false !== ($file = readdir($handle))) {
  237. // $filename = pathinfo($file);
  238. // if ($filename['extension'] == 'json')
  239. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  240. // }
  241. // closedir($handle);
  242. // }
  243. // $this->data['proArray'] = null;
  244. $this->render('s-project', $this->data);
  245. }
  246. public function proDetail()
  247. {
  248. // 项目名称
  249. $mpidArray = $this->measureauditact->getAuditProject($this->auth->getUid());
  250. foreach ($mpidArray as $k1 => $v1) {
  251. if ($v1['pid'] != $this->params['pid'])
  252. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  253. }
  254. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  255. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  256. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  257. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  258. foreach ($this->data['MeasureArray'] as $key => $value) {
  259. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  260. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  261. } else {
  262. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  263. }
  264. }
  265. $this->data['pmid'] = $this->params['pmid'];
  266. $this->data['pid'] = $this->params['pid'];
  267. $this->data['mpid'] = $this->params['mpid'];
  268. $this->render('r-project-section-detail', $this->data, TRUE);
  269. }
  270. public function proReport()
  271. {
  272. // 面包屑导航
  273. // 期数列表
  274. $tmpArray = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  275. foreach ($tmpArray as $k => $v) {
  276. if ($v['mpid'] == $this->params['mpid']) {
  277. $this->data['currnum'] = $v['numpname'];
  278. $this->data['mpid'] = $v['mpid'];
  279. $this->data['MeasureArray2'][] = $v;
  280. } else {
  281. $this->data['numArray'][] = $v;
  282. }
  283. }
  284. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  285. foreach ($this->data['MeasureArray2'] as $key => $value) {
  286. if ($value['mpid'] == $this->params['mpid']) {
  287. $this->data['MeasureArray2'][$key]['currstatus'] = $this->statusArray[$value['currstatus']];
  288. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  289. $this->data['MeasureArray2'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  290. } else {
  291. $this->data['MeasureArray2'][$key]['lessTotal'] = 0;
  292. }
  293. }
  294. }
  295. //
  296. $lastRowArray = $this->numofperact->getLastNew2($this->params['pmid']);
  297. $maxTimes = $this->numofperact->getMaxTimes($lastRowArray['pmid'], $lastRowArray['numpname']);
  298. $auditUserArray = $this->measureauditact->getAllAudit($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  299. $auditArray = $this->measureauditact->getLastNewRowInfo($lastRowArray['pmid'], $lastRowArray['numpname'], $this->auth->getUid());
  300. if (isset($_POST['act'])) {
  301. $auditStatusArray = array('checkno', 'checked');
  302. $myAuditStatus = $this->measureauditact->getMyAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times'], $this->auth->getUid());
  303. if (in_array($myAuditStatus['mastatus'], $auditStatusArray)) {
  304. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  305. die();
  306. }
  307. }
  308. if ($_POST['act'] == 'p') {
  309. if ($this->measureauditact->setStatusTo($auditArray['maid'], 3, $_POST['content'], 1)) {
  310. $countAudit = count($auditUserArray);
  311. if ($auditArray['last'] == 1) {
  312. $this->measureauditact->setStatusTo($auditUserArray[0]['maid'], 3);
  313. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checked', $maxTimes['times']);
  314. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  315. die();
  316. } else {
  317. if (($countAudit == 2) && ($auditUserArray[1]['last'] == 1) && ($auditUserArray[0]['maid'] == $auditArray['maid'])) {
  318. $this->measureauditact->updateMastatus($auditUserArray[1]['maid']);
  319. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  320. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  321. die();
  322. }
  323. if (($countAudit > 2)) {
  324. foreach ($auditUserArray as $k => $v) {
  325. if ($v['maid'] == $auditArray['maid']) {
  326. if ($k == ($countAudit - 1)) {//如果是最后一个
  327. $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);
  328. } else {
  329. $this->measureauditact->updateMastatus($auditUserArray[$k + 1]['maid']);
  330. }
  331. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  332. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  333. die();
  334. }
  335. }
  336. }
  337. }
  338. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  339. }
  340. }
  341. if ($_POST['act'] == 'np') {
  342. $this->measureauditact->setCheckno($auditArray['maid'], $_POST['content'], 1);
  343. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checkno', $maxTimes['times']);
  344. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  345. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  346. die();
  347. }
  348. $this->data['pmid'] = $lastRowArray['pmid'];
  349. $this->data['numpname'] = $lastRowArray['numpname'];
  350. $this->data['times'] = $lastRowArray['times'];
  351. $this->data['pid'] = $this->params['pid'];
  352. foreach ($auditUserArray as $key => $value) {
  353. $i = $key + 1;
  354. if ($value['auditoruid'] == $this->auth->getUid()) {
  355. $this->data['mastatus'] = $value['mastatus'];
  356. $this->data['maid'] = $value['maid'];
  357. }
  358. if ($value['mastatus'] == 'uncheck') {
  359. $statuStr = '';
  360. $statucolorStr = '';
  361. $statushtml = '<li title="" class=""><img src="' . Doo::conf()->APP_URL . 'global/images/avtra.png"></li>';
  362. }
  363. if ($value['mastatus'] == 'checking') {
  364. $statuStr = '<h4 class="colOrange">审核中</h4>';
  365. $statucolorStr = 'colOrange';
  366. $statushtml = '<li title="审批中" class="wait"><span data-icon="k" aria-hidden="true"></span> <img src="' . Doo::conf()->APP_URL . 'global/images/avtra.png"></li>';
  367. }
  368. if ($value['mastatus'] == 'checked') {
  369. $statuStr = '<h4 class="colGreen">审批完成(' . date('Y-m-d', $value['audittime']) . ')</h4>';
  370. $statucolorStr = 'colGreen';
  371. $statushtml = '<li title="审批通过" class="pass"><span data-icon="d" aria-hidden="true"></span><img src="' . Doo::conf()->APP_URL . 'global/images/avtra.png"></li>';
  372. }
  373. if ($value['mastatus'] == 'checkno') {
  374. $statuStr = '<h4 class="colRed">审批不通过(' . date('Y-m-d', $value['audittime']) . ')</h4>';
  375. $statucolorStr = 'colRed';
  376. $statushtml = '<li title="审批不通过" class="notpass"><span data-icon="e" aria-hidden="true"></span><img src="' . Doo::conf()->APP_URL . 'global/images/avtra.png"></li>';
  377. }
  378. $auditUserArray[$key]['statuStr'] = $statuStr;
  379. $auditUserArray[$key]['statucolorStr'] = $statucolorStr;
  380. $auditUserArray[$key]['statushtml'] = $statushtml;
  381. $auditUserArray[$key]['k'] = $i;
  382. $auditUserArray[$key]['name'] = $this->profile->getProWithUid($value['auditoruid'])['name'];
  383. }
  384. $this->data['auditArray'] = $auditUserArray;
  385. $this->data['pmid'] = $this->params['pmid'];
  386. $this->data['pid'] = $this->params['pid'];
  387. $this->data['mpid'] = $this->params['mpid'];
  388. $this->render('r-project-section-report', $this->data, TRUE);
  389. }
  390. }
  391. ?>