SProjectController.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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('numofperact');
  9. Doo::loadClass('measureauditact');
  10. /**
  11. * MainController
  12. * Feel free to delete the methods and replace them with your own code.
  13. *
  14. * @author darkredz
  15. */
  16. class SProjectController extends DooController {
  17. private $data, $auth, $attfile, $profile, $project, $contractact, $actmeasure, $numofperact, $measureauditact;
  18. public function beforeRun($resource, $action) {
  19. // $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  20. // $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  21. // if (!$falg)
  22. // return Doo::acl()->defaultFailedRoute;
  23. if ($this->auth->getUid()) {
  24. $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  25. $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  26. if (!$falg)
  27. return Doo::acl()->defaultFailedRoute;
  28. }else {
  29. return Doo::acl()->defaultFailedRoute;
  30. }
  31. }
  32. public function __construct() {
  33. $this->auth = new Auth();
  34. $this->attfile = new attFile();
  35. $this->profile = new Profile();
  36. $this->project = new Project();
  37. $this->contractact = new Contractact();
  38. $this->actmeasure = new actMeasure();
  39. $this->numofperact = new NumofperAct();
  40. $this->measureauditact = new MeasureauditAct();
  41. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  42. $this->data['currChannle'] = 's';
  43. $this->data['user'] = $this->profile->getProWithUid($this->auth->getUid());
  44. }
  45. public function index() {
  46. $this->data['conArray'] = NULL;
  47. $conArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  48. if (isset($conArray)) {
  49. foreach ($conArray as $k => $v) {
  50. $proArray = $this->project->getRowByPid($v['pid']);
  51. $this->data['conArray'][] = $proArray;
  52. $profileArray = $this->profile->getProWithUid($proArray['uid']);
  53. $this->data['conArray'][$k]['company'] = $profileArray['company'];
  54. $countMeasureInt = $this->actmeasure->getCountMeasure($v['stid']);
  55. $countTotalMeasureInt = $this->actmeasure->getMearsureCount($v['pid']);
  56. $this->data['conArray'][$k]['countmeasure'] = $countMeasureInt;
  57. $this->data['conArray'][$k]['countTotalMeasureInt'] = $countTotalMeasureInt;
  58. $this->data['conArray'][$k]['changTotal'] = $this->numofperact->getChangTotal($v['pid']);
  59. $this->data['conArray'][$k]['currdone'] = $this->numofperact->getCurrDoneNow($v['pid']);
  60. $this->data['conArray'][$k]['contracttotal'] = $this->actmeasure->getTotalWithPid($v['pid']);
  61. if ($this->data['conArray'][$k]['contracttotal']) {
  62. $this->data['conArray'][$k]['pcurrdone'] = round(($this->data['conArray'][$k]['currdone'] / $this->data['conArray'][$k]['contracttotal']) * 100) . '%';
  63. } else {
  64. $this->data['conArray'][$k]['pcurrdone'] = '0%';
  65. }
  66. $this->data['conArray'][$k]['bcontracttotal'] = number_format($this->data['conArray'][$k]['contracttotal'], 2, '.', ',');
  67. $this->data['conArray'][$k]['bchangTotal'] = number_format($this->data['conArray'][$k]['changTotal'], 2, '.', ',');
  68. }
  69. }
  70. $this->render('s-project', $this->data, TRUE);
  71. }
  72. public function proOverview() {
  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. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  83. foreach ($proArray as $v) {
  84. $pidArray[] = $v['pid'];
  85. }
  86. $pidstr = implode(',', $pidArray);
  87. // 项目名称
  88. $this->data['allproArray'] = $this->project->getFewRow($pidstr);
  89. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  90. // 标段按月进度
  91. for ($i = 1; $i <= 7; $i++) {
  92. $monthz[] = date('n月', strtotime('+' . $i . ' months', $this->data['currproArray']['intime']));
  93. if ($i == 1) {
  94. $ii = date('Y年', $this->data['currproArray']['intime']) . date('n月', strtotime('+' . $i . ' months', $this->data['currproArray']['intime']));
  95. } else {
  96. $ii = date('n月', strtotime('+' . $i . ' months', $this->data['currproArray']['intime']));
  97. }
  98. $this->data['months'][$i]['month'] = $ii;
  99. }
  100. // 标段
  101. // 搜索有没有相应的月份,有就把实际赋值,没有就为零
  102. $this->data['MeasureArray'] = $this->actmeasure->getRowsByPid($this->params['pid']);
  103. foreach ($this->data['MeasureArray'] as $key => $value) {
  104. $this->data['MeasureArray'][$key]['pmid'] = $value['pmid'];
  105. $this->data['MeasureArray'][$key]['type'] = $this->contractact->getRowByStid($value['stid'])['stname'];
  106. $numArray = $this->numofperact->getRowByPmid2($value['pmid']);
  107. $num = $num1 = 0;
  108. $this->data['MeasureArray'][$key]['num'] = $this->data['MeasureArray'][$key]['num1'] = NULL;
  109. foreach ($numArray as $k => $v) {
  110. if ($v['currstatus'] == 'checked') {
  111. $monthInt = date('n月', $v['audittime']);
  112. $retval = in_array($monthInt, $monthz);
  113. if ($retval) {
  114. $num = round(($v['currdone'] / $value['contracttotal']) * 100);
  115. $num1 = round(($v['curralltotal'] / $value['contracttotal']) * 100);
  116. }
  117. }
  118. $this->data['MeasureArray'][$key]['num'] .= $num . ',';
  119. $this->data['MeasureArray'][$key]['num1'] .= $num1 . ',';
  120. }
  121. $this->data['MeasureArray'][$key]['totalnum'] = $this->numofperact->getCountTotalnum($value['pmid']);
  122. $this->data['MeasureArray'][$key]['totalplus'] = number_format($this->actmeasure->getRowByPmid($value['pmid'])['contracttotal'], 2, '.', ',');
  123. $this->data['MeasureArray'][$key]['stopnow'] = $this->numofperact->getStopNowTotal($value['pmid'])['sntotal'];
  124. $this->data['MeasureArray'][$key]['nstopnow'] = number_format($this->numofperact->getStopNowTotal($value['pmid'])['sntotal'], 2, '.', ',');
  125. $this->data['MeasureArray'][$key]['currdone'] = $this->numofperact->getCurrdoneNew($value['pmid'])['currtotal'];
  126. $this->data['MeasureArray'][$key]['ncurrdone'] = number_format($this->data['MeasureArray'][$key]['currdone'], 2, '.', ',');
  127. $this->data['MeasureArray'][$key]['pstopnow'] = '0%';
  128. $this->data['MeasureArray'][$key]['pcurrdone'] = '0%';
  129. $this->data['MeasureArray'][$key]['pless'] = '0%';
  130. if ($value['contracttotal'] > 0) {
  131. $this->data['MeasureArray'][$key]['pstopnow'] = round(($this->data['MeasureArray'][$key]['stopnow'] / $value['contracttotal']) * 100);
  132. $this->data['MeasureArray'][$key]['dispstopnow'] = $this->data['MeasureArray'][$key]['pstopnow'] . '%';
  133. $this->data['MeasureArray'][$key]['pcurrdone'] = round(($this->data['MeasureArray'][$key]['currdone'] / $value['contracttotal']) * 100);
  134. $this->data['MeasureArray'][$key]['dispcurrdone'] = $this->data['MeasureArray'][$key]['pcurrdone'] . '%';
  135. $this->data['MeasureArray'][$key]['pless'] = (100 - $this->data['MeasureArray'][$key]['pstopnow'] - $this->data['MeasureArray'][$key]['pcurrdone']) . '%';
  136. }
  137. $this->data['MeasureArray'][$key]['nless'] = number_format($value['contracttotal'] - $this->data['MeasureArray'][$key]['stopnow'] - $this->data['MeasureArray'][$key]['currdone'], 2, '.', ',');
  138. $tenderArray = $this->numofperact->getRowTender2($value['pmid']);
  139. $this->data['MeasureArray'][$key]['ownstatus'] = '审核中';
  140. $ownerStatusArray = $this->measureauditact->getStatusTen($tenderArray['pmid'], $tenderArray['numpname']);
  141. if (isset($ownerStatusArray[0]['last']) && isset($ownerStatusArray[0]['mastatus']))
  142. if (($ownerStatusArray[0]['last'] == 1) && ($ownerStatusArray[0]['mastatus'] == 'checked')) {
  143. $this->data['MeasureArray'][$key]['ownstatus'] = '已审核';
  144. } else {
  145. $this->data['MeasureArray'][$key]['ownstatus'] = '审核中';
  146. }
  147. }
  148. $this->render('s-project-section', $this->data, TRUE);
  149. }
  150. public function proDetail() {
  151. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  152. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  153. foreach ($proArray as $v) {
  154. $pidArray[] = $v['pid'];
  155. }
  156. $pidstr = implode(',', $pidArray);
  157. // 项目名称
  158. $allproArray = $this->project->getFewRow($pidstr);
  159. // 面包屑导航项目
  160. foreach ($allproArray as $kk => $vv) {
  161. if ($vv['pid'] == $this->params['pid']) {
  162. $this->data['currproArray'] = $vv;
  163. } else {
  164. $this->data['allproArray'][] = $vv;
  165. }
  166. }
  167. // 面包屑导航合同
  168. $conArray = $this->contractact->getAll();
  169. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  170. if (isset($measureArray['stid'])) {
  171. foreach ($conArray as $kkk => $vvv) {
  172. if ($vvv['stid'] == $measureArray['stid']) {
  173. $this->data['currconArray'] = $vvv;
  174. } else {
  175. if ($vvv['pid'] == $this->params['pid'])
  176. $this->data['allconArray'][] = $vvv;
  177. }
  178. }
  179. } else {
  180. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  181. }
  182. // 面包屑导航标段
  183. $this->data['curractmeasureArray'] = NULL;
  184. $this->data['allactmeasureArray'] = [];
  185. $actmeasureArray = $this->actmeasure->getAll();
  186. foreach ($actmeasureArray as $kkkk => $vvvv) {
  187. if ($vvvv['stid'] == $measureArray['stid']) {
  188. if (($vvvv['pmid'] == $this->params['pmid'])) {
  189. $this->data['curractmeasureArray'] = $vvvv;
  190. } else {
  191. $this->data['allactmeasureArray'][] = $vvvv;
  192. }
  193. }
  194. }
  195. // 图标
  196. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  197. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  198. foreach ($this->data['MeasureArray'] as $key => $value) {
  199. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  200. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  201. } else {
  202. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  203. }
  204. }
  205. $this->data['pid'] = $this->params['pid'];
  206. // 获取当前合同段的期数
  207. // $this->data['allNumArray'] = $this->numofperact->getNumByStid(1);
  208. $this->render('s-project-section-detail', $this->data, TRUE);
  209. }
  210. public function proMeasure() {
  211. $MpidArray = $this->measureauditact->getRowByMpid(1);
  212. foreach ($MpidArray as $key => $value) {
  213. $uidArray = $value['uid'];
  214. }
  215. $this->data['pid'] = $this->params['pid'];
  216. $this->render('s-project-section-measure', $this->data);
  217. }
  218. Function fNumber($number) {
  219. if ($number == '')
  220. Return "-";
  221. $nlen = strlen($number);
  222. while ($nlen > 3) {
  223. $fNumber = "," . substr($number, $nlen - 3, 3);
  224. $number = substr($number, 0, -3);
  225. $nlen = strlen($number);
  226. }
  227. if ($nlen <= 3) {
  228. $fNumber = $number . $fNumber;
  229. }
  230. Return $fNumber;
  231. }
  232. public function welcome() {
  233. // if (!$this->auth->isLoggedIn())
  234. // return Doo::conf()->APP_URL;
  235. if ($this->profile->getProWithUid($_SESSION['uid'])['userid'])
  236. return Doo::conf()->APP_URL . 'project/list';
  237. if (isset($_POST['welform'])) {
  238. $profileUserArray = $_POST;
  239. $profileUserArray['userid'] = $_SESSION['uid'];
  240. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  241. return Doo::conf()->APP_URL . 'project/list';
  242. }
  243. $this->render('welcome', $this->data);
  244. }
  245. public function prolist() {
  246. // if (!$this->auth->isLoggedIn())
  247. // return Doo::conf()->APP_URL;
  248. // $proArray = new stdClass();
  249. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  250. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  251. // if ($handle = opendir($extPathdir)) {
  252. // while (false !== ($file = readdir($handle))) {
  253. // $filename = pathinfo($file);
  254. // if ($filename['extension'] == 'json')
  255. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  256. // }
  257. // closedir($handle);
  258. // }
  259. // $this->data['proArray'] = null;
  260. $this->render('s-project', $this->data);
  261. }
  262. }
  263. ?>