RProjectController.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. $html .= '<tr>
  124. <td><a href="/rproject/' . $this->params['pid'] . '/section/' . $v['pmid'] . '/detail">' . $v['pmname'] . '</a></td>
  125. <td class="">第 ' . $countNum . ' 期(<span class="colOrange">' . $this->statusArray[$numStatusArray['currstatus']] . '</span>)</td>
  126. <td class="taR">¥' . number_format($v['contracttotal'], 2, '.', ',') . '</td>
  127. <td>
  128. <div class="progress">
  129. <div class="bar bar-success" style="width: ' . $dispstopnowtotal . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成:¥' . $nstopnowtotal . '">' . $dispstopnowtotal . '</div>
  130. <div class="bar" style="width:' . $dispcurrdone . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' . $ncurrdone . '">' . $dispcurrdone . '</div>
  131. <div class="bar bar-gary" style="width:' . $dispnowtotal . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $nnowtotal . '">' . $dispnowtotal . '</div>
  132. </div>
  133. </td>
  134. </tr>';
  135. $hetongTotal += $v['contracttotal'];
  136. }
  137. }
  138. $this->data['conArray'][$key]['htmlstr'] = $html;
  139. $this->data['conArray'][$key]['hetongTotal'] = number_format($hetongTotal, 2, '.', ',');
  140. $this->data['conArray'][$key]['phetongTotal'] = 0;
  141. $this->data['conArray'][$key]['nhetongTotal'] = 0;
  142. $this->data['conArray'][$key]['phetongTotal2'] = 0;
  143. $this->data['conArray'][$key]['ncurrdoneInt'] = 0;
  144. $this->data['conArray'][$key]['phetongTotal'] = round(($currdoneInt / $hetongTotal) * 100) . '%';
  145. $this->data['conArray'][$key]['nhetongTotal'] = number_format($currdoneInt, 2, '.', ',');
  146. $this->data['conArray'][$key]['phetongTotal2'] = round((($hetongTotal - $currdoneInt) / $hetongTotal) * 100) . '%';
  147. $this->data['conArray'][$key]['ncurrdoneInt'] = number_format($hetongTotal - $currdoneInt, 2, '.', ',');
  148. }
  149. $this->render('r-project-section', $this->data, TRUE);
  150. }
  151. function proSectionMeasure()
  152. {
  153. $this->data['allproArray'] = $this->project->getAll();
  154. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  155. $this->data['pid'] = $this->params['pid'];
  156. $this->data['mpid'] = $this->params['mpid'];
  157. $this->data['mastatus'] = $this->measureauditact->getStatusByMpid($this->params['mpid'])['mastatus'];
  158. if (isset($_POST['submit'])) {
  159. if ($_POST['submit'] == 'ok') {
  160. $this->measureauditact->setStatusTrue($this->params['mpid']);
  161. return Doo::conf()->APP_URL . 'rproject/' . $this->params['pid'] . '/section/' . $this->params['mpid'] . '/measure';
  162. }
  163. if ($_POST['submit'] == 'no') {
  164. $this->measureauditact->setStatusFalse($this->params['mpid']);
  165. return Doo::conf()->APP_URL . 'rproject/' . $this->params['pid'] . '/section/' . $this->params['mpid'] . '/measure';
  166. }
  167. }
  168. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  169. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  170. // if ($handle = opendir($extPathdir)) {
  171. // while (false !== ($file = readdir($handle))) {
  172. // $filename = pathinfo($file);
  173. // if ($filename['extension'] == 'json')
  174. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  175. // }
  176. // closedir($handle);
  177. // }
  178. // $this->data['proArray'] = $proArray;
  179. $this->render('r-project-section-measure', $this->data, TRUE);
  180. }
  181. Function fNumber($number)
  182. {
  183. if ($number == '')
  184. Return "-";
  185. $nlen = strlen($number);
  186. while ($nlen > 3) {
  187. $fNumber = "," . substr($number, $nlen - 3, 3);
  188. $number = substr($number, 0, -3);
  189. $nlen = strlen($number);
  190. }
  191. if ($nlen <= 3) {
  192. $fNumber = $number . $fNumber;
  193. }
  194. Return $fNumber;
  195. }
  196. public function welcome()
  197. {
  198. // if (!$this->auth->isLoggedIn())
  199. // return Doo::conf()->APP_URL;
  200. if ($this->profile->getProWithUid($_SESSION['uid'])['userid'])
  201. return Doo::conf()->APP_URL . 'project/list';
  202. if (isset($_POST['welform'])) {
  203. $profileUserArray = $_POST;
  204. $profileUserArray['userid'] = $_SESSION['uid'];
  205. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  206. return Doo::conf()->APP_URL . 'project/list';
  207. }
  208. $this->render('welcome', $this->data);
  209. }
  210. public function prolist()
  211. {
  212. // if (!$this->auth->isLoggedIn())
  213. // return Doo::conf()->APP_URL;
  214. // $proArray = new stdClass();
  215. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  216. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  217. // if ($handle = opendir($extPathdir)) {
  218. // while (false !== ($file = readdir($handle))) {
  219. // $filename = pathinfo($file);
  220. // if ($filename['extension'] == 'json')
  221. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  222. // }
  223. // closedir($handle);
  224. // }
  225. // $this->data['proArray'] = null;
  226. $this->render('s-project', $this->data);
  227. }
  228. public function proDetail()
  229. {
  230. // 项目名称
  231. $this->data['allproArray'] = $this->project->getAll();
  232. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  233. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  234. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  235. foreach ($this->data['MeasureArray'] as $key => $value) {
  236. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  237. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  238. } else {
  239. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  240. }
  241. }
  242. $this->data['pmid'] = $this->params['pmid'];
  243. $this->data['pid'] = $this->params['pid'];
  244. $this->render('r-project-section-detail', $this->data, TRUE);
  245. }
  246. }
  247. ?>