RProjectController.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. private $data, $auth, $attfile, $profile, $project, $contractact, $actmeasure, $measureauditact, $numofperact, $statusArray = array('uncheck' => '未审核', 'checking' => '审核中', 'checked' => '已审核', 'checkno' => '未通过');
  18. public function __construct() {
  19. $this->auth = new Auth();
  20. $this->attfile = new attFile();
  21. $this->profile = new Profile();
  22. $this->project = new Project();
  23. $this->contractact = new Contractact();
  24. $this->actmeasure = new actMeasure();
  25. $this->measureauditact = new MeasureauditAct();
  26. $this->numofperact = new NumofperAct();
  27. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  28. $this->data['currChannle'] = 'r';
  29. $this->data['user'] = $this->profile->getProWithUid($this->auth->getUid());
  30. }
  31. public function beforeRun($resource, $action) {
  32. // $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  33. // $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  34. // if (!$falg)
  35. // return Doo::acl()->defaultFailedRoute;
  36. if ($this->auth->getUid()) {
  37. $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  38. $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  39. if (!$falg)
  40. return Doo::acl()->defaultFailedRoute;
  41. }else {
  42. return Doo::acl()->defaultFailedRoute;
  43. }
  44. }
  45. public function index() {
  46. $mpidArray = $this->measureauditact->getAuditProject($this->auth->getUid());
  47. if (isset($mpidArray[0]['pid'])) {
  48. foreach ($mpidArray as $key => $value) {
  49. $this->data['proArray'][$key] = $this->project->getRowByPid($value['pid']);
  50. $this->data['proArray'][$key]['contracttotal'] = $this->actmeasure->getTotalWithPid($value['pid']);
  51. $this->data['proArray'][$key]['changTotal'] = $this->numofperact->getChangTotal($value['pid']);
  52. // $this->data['proArray'][$key]['contracttotal'] += $this->data['proArray'][$key]['changTotal'];
  53. $this->data['proArray'][$key]['currdone'] = $this->numofperact->getCurrDoneNow($value['pid']);
  54. if (($this->data['proArray'][$key]['contracttotal'] > 0) && ($this->data['proArray'][$key]['currdone'] > 0)) {
  55. $this->data['proArray'][$key]['pcurrdone'] = round(($this->data['proArray'][$key]['currdone'] / $this->data['proArray'][$key]['contracttotal']) * 100) . '%';
  56. } else {
  57. $this->data['proArray'][$key]['pcurrdone'] = '0%';
  58. }
  59. $this->data['proArray'][$key]['bcontracttotal'] = number_format($this->data['proArray'][$key]['contracttotal'], 2, '.', ',');
  60. $this->data['proArray'][$key]['bchangTotal'] = number_format($this->data['proArray'][$key]['changTotal'], 2, '.', ',');
  61. }
  62. } else {
  63. $this->data['proArray'] = array();
  64. }
  65. $this->render('r-project', $this->data);
  66. }
  67. public function proOverview() {
  68. // $this->data['pros'] = $this->project->getAll();
  69. // if (isset($_POST['pname']) && $_POST['pname']) {
  70. // $this->project->insertProject($_POST['pname']);
  71. // return Doo::conf()->APP_URL . 'project/index';
  72. // }
  73. $this->data['pid'] = $this->params['pid'];
  74. $this->render('w-project-detail', $this->data);
  75. }
  76. public function proSection() {
  77. $this->data['allproArray'] = $this->project->getAll();
  78. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  79. $this->data['conArray'] = $this->contractact->getRowByPid($this->params['pid']);
  80. $auditArray = $this->measureauditact->getUserPmid($this->auth->getUid());
  81. foreach ($auditArray as $key => $value) {
  82. $pmidArray[] = $value['pmid'];
  83. }
  84. foreach ($this->data['conArray'] as $key => $value) {
  85. $html = null;
  86. $hetongTotal = $dispstopnowtotal = $dispnowtotal = $countNum = 0;
  87. $nstopnowtotal = $ncurrdone = $nnowtotal = number_format(0, 2, '.', ',');
  88. $pstopnowtotal = '0%';
  89. $pcurrdone = '0%';
  90. $ncurrdone = number_format(0, 2, '.', ',');
  91. $pnowtotal = '0%';
  92. $dispcurrdone = '0%';
  93. $numStatusArray['currstatus'] = 'uncheck';
  94. $StidArray = $this->actmeasure->getAllbyStid($value['stid']);
  95. $currdoneInt = $this->numofperact->getCurrdoneSTID($value['stid'])['totalplus'];
  96. if (isset($StidArray))
  97. foreach ($StidArray as $k => $v) {
  98. if (in_array($v['pmid'], $pmidArray)) {
  99. $snTotal = $this->numofperact->getStopNowTotal($v['pmid']); //根据标段ID获取最新一期(包括不通过)
  100. $currcomTotal = $this->numofperact->getCurrdoneNew($v['pmid']); //截止目前
  101. $ncurrdone = number_format($currcomTotal['currtotal'], 2, '.', ',');
  102. $nstopnowtotal = number_format($snTotal['sntotal'], 2, '.', ',');
  103. if ($v['contracttotal'] > 0) {
  104. $nnowtotal = number_format($v['contracttotal'] - $currcomTotal['currtotal'] - $snTotal['sntotal'], 2, '.', ',');
  105. $pstopnowtotal = round(($snTotal['sntotal'] / $v['contracttotal']) * 100);
  106. $pcurrdone = round(($currcomTotal['currtotal'] / $v['contracttotal']) * 100);
  107. }
  108. $dispcurrdone = $pcurrdone . '%';
  109. $dispstopnowtotal = $pstopnowtotal . '%';
  110. $pnowtotal = 100 - $pcurrdone - $pstopnowtotal;
  111. $dispnowtotal = $pnowtotal . '%';
  112. $countNum = $this->numofperact->getCountTotalnum($v['pmid']);
  113. $numStatusArray = $this->numofperact->getLastStatus($this->params['pid'], $v['pmid']);
  114. if (!isset($numStatusArray['currstatus'])) {
  115. $numStatusArray['currstatus'] = 'uncheck';
  116. }
  117. $html .= '<tr>
  118. <td><a href="/rproject/' . $this->params['pid'] . '/section/' . $v['pmid'] . '/detail">' . $v['pmname'] . '</a></td>
  119. <td class="">第 ' . $countNum . ' 期(<span class="colOrange">' . $this->statusArray[$numStatusArray['currstatus']] . '</span>)</td>
  120. <td class="taR">¥' . number_format($v['contracttotal'], 2, '.', ',') . '</td>
  121. <td>
  122. <div class="progress">
  123. <div class="bar bar-success" style="width: ' . $dispstopnowtotal . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成:¥' . $nstopnowtotal . '">' . $dispstopnowtotal . '</div>
  124. <div class="bar" style="width:' . $dispcurrdone . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' . $ncurrdone . '">' . $dispcurrdone . '</div>
  125. <div class="bar bar-gary" style="width:' . $dispnowtotal . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $nnowtotal . '">' . $dispnowtotal . '</div>
  126. </div>
  127. </td>
  128. </tr>';
  129. $hetongTotal+=$v['contracttotal'];
  130. }
  131. }
  132. $this->data['conArray'][$key]['htmlstr'] = $html;
  133. $this->data['conArray'][$key]['hetongTotal'] = number_format($hetongTotal, 2, '.', ',');
  134. $this->data['conArray'][$key]['phetongTotal'] = 0;
  135. $this->data['conArray'][$key]['nhetongTotal'] = 0;
  136. $this->data['conArray'][$key]['phetongTotal2'] = 0;
  137. $this->data['conArray'][$key]['ncurrdoneInt'] = 0;
  138. $this->data['conArray'][$key]['phetongTotal'] = round(($currdoneInt / $hetongTotal) * 100) . '%';
  139. $this->data['conArray'][$key]['nhetongTotal'] = number_format($currdoneInt, 2, '.', ',');
  140. $this->data['conArray'][$key]['phetongTotal2'] = round((($hetongTotal - $currdoneInt) / $hetongTotal) * 100) . '%';
  141. $this->data['conArray'][$key]['ncurrdoneInt'] = number_format($hetongTotal - $currdoneInt, 2, '.', ',');
  142. }
  143. $this->render('r-project-section', $this->data, TRUE);
  144. }
  145. function proSectionMeasure() {
  146. $this->data['allproArray'] = $this->project->getAll();
  147. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  148. $this->data['pid'] = $this->params['pid'];
  149. $this->data['mpid'] = $this->params['mpid'];
  150. $this->data['mastatus'] = $this->measureauditact->getStatusByMpid($this->params['mpid'])['mastatus'];
  151. if (isset($_POST['submit'])) {
  152. if ($_POST['submit'] == 'ok') {
  153. $this->measureauditact->setStatusTrue($this->params['mpid']);
  154. return Doo::conf()->APP_URL . 'rproject/' . $this->params['pid'] . '/section/' . $this->params['mpid'] . '/measure';
  155. }
  156. if ($_POST['submit'] == 'no') {
  157. $this->measureauditact->setStatusFalse($this->params['mpid']);
  158. return Doo::conf()->APP_URL . 'rproject/' . $this->params['pid'] . '/section/' . $this->params['mpid'] . '/measure';
  159. }
  160. }
  161. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  162. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  163. // if ($handle = opendir($extPathdir)) {
  164. // while (false !== ($file = readdir($handle))) {
  165. // $filename = pathinfo($file);
  166. // if ($filename['extension'] == 'json')
  167. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  168. // }
  169. // closedir($handle);
  170. // }
  171. // $this->data['proArray'] = $proArray;
  172. $this->render('r-project-section-measure', $this->data, TRUE);
  173. }
  174. Function fNumber($number) {
  175. if ($number == '')
  176. Return "-";
  177. $nlen = strlen($number);
  178. while ($nlen > 3) {
  179. $fNumber = "," . substr($number, $nlen - 3, 3);
  180. $number = substr($number, 0, -3);
  181. $nlen = strlen($number);
  182. }
  183. if ($nlen <= 3) {
  184. $fNumber = $number . $fNumber;
  185. }
  186. Return $fNumber;
  187. }
  188. public function welcome() {
  189. // if (!$this->auth->isLoggedIn())
  190. // return Doo::conf()->APP_URL;
  191. if ($this->profile->getProWithUid($_SESSION['uid'])['userid'])
  192. return Doo::conf()->APP_URL . 'project/list';
  193. if (isset($_POST['welform'])) {
  194. $profileUserArray = $_POST;
  195. $profileUserArray['userid'] = $_SESSION['uid'];
  196. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  197. return Doo::conf()->APP_URL . 'project/list';
  198. }
  199. $this->render('welcome', $this->data);
  200. }
  201. public function prolist() {
  202. // if (!$this->auth->isLoggedIn())
  203. // return Doo::conf()->APP_URL;
  204. // $proArray = new stdClass();
  205. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  206. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  207. // if ($handle = opendir($extPathdir)) {
  208. // while (false !== ($file = readdir($handle))) {
  209. // $filename = pathinfo($file);
  210. // if ($filename['extension'] == 'json')
  211. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  212. // }
  213. // closedir($handle);
  214. // }
  215. // $this->data['proArray'] = null;
  216. $this->render('s-project', $this->data);
  217. }
  218. public function proDetail() {
  219. // 项目名称
  220. $this->data['allproArray'] = $this->project->getAll();
  221. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  222. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  223. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  224. foreach ($this->data['MeasureArray'] as $key => $value) {
  225. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  226. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  227. } else {
  228. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  229. }
  230. }
  231. $this->data['pmid'] = $this->params['pmid'];
  232. $this->data['pid'] = $this->params['pid'];
  233. $this->render('r-project-section-detail', $this->data, TRUE);
  234. }
  235. }
  236. ?>