RProjectController.php 19 KB

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