SProjectController.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  45. if (isset($mpidArray[0]['pid'])) {
  46. foreach ($mpidArray as $key => $value) {
  47. // 审批操作按照时间排序多标段
  48. $this->data['numofchecking'] += $this->measureauditact->getCountMyChecking($value['pid'], $this->auth->getUid());
  49. }
  50. }
  51. if ($this->data['numofchecking'] == 0) {
  52. $this->data['numofchecking'] = null;
  53. }
  54. }
  55. public function index() {
  56. $this->data['conArray'] = NULL;
  57. $conArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  58. if (isset($conArray)) {
  59. foreach ($conArray as $k => $v) {
  60. $proArray = $this->project->getRowByPid($v['pid']);
  61. $this->data['conArray'][] = $proArray;
  62. $profileArray = $this->profile->getProWithUid($proArray['uid']);
  63. $this->data['conArray'][$k]['company'] = $profileArray['company'];
  64. $countMeasureInt = $this->actmeasure->getCountMeasure($v['stid']);
  65. $countTotalMeasureInt = $this->actmeasure->getMearsureCount($v['pid']);
  66. $this->data['conArray'][$k]['countmeasure'] = $countMeasureInt;
  67. $this->data['conArray'][$k]['countTotalMeasureInt'] = $countTotalMeasureInt;
  68. $this->data['conArray'][$k]['changTotal'] = $this->numofperact->getChangTotal($v['pid']);
  69. $this->data['conArray'][$k]['currdone'] = $this->numofperact->getCurrDoneNow($v['pid']);
  70. $this->data['conArray'][$k]['contracttotal'] = $this->actmeasure->getTotalWithPid($v['pid']);
  71. if ($this->data['conArray'][$k]['contracttotal']) {
  72. $this->data['conArray'][$k]['pcurrdone'] = round(($this->data['conArray'][$k]['currdone'] / $this->data['conArray'][$k]['contracttotal']) * 100) . '%';
  73. } else {
  74. $this->data['conArray'][$k]['pcurrdone'] = '0%';
  75. }
  76. $this->data['conArray'][$k]['bcontracttotal'] = number_format($this->data['conArray'][$k]['contracttotal'], 2, '.', ',');
  77. $this->data['conArray'][$k]['bchangTotal'] = number_format($this->data['conArray'][$k]['changTotal'], 2, '.', ',');
  78. }
  79. }
  80. $this->render('s-project', $this->data, TRUE);
  81. }
  82. public function proOverview() {
  83. // $this->data['pros'] = $this->project->getAll();
  84. // if (isset($_POST['pname']) && $_POST['pname']) {
  85. // $this->project->insertProject($_POST['pname']);
  86. // return Doo::conf()->APP_URL . 'project/index';
  87. // }
  88. $this->data['pid'] = $this->params['pid'];
  89. $this->render('w-project-detail', $this->data);
  90. }
  91. public function proSection() {
  92. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  93. foreach ($proArray as $v) {
  94. $pidArray[] = $v['pid'];
  95. }
  96. $pidstr = implode(',', $pidArray);
  97. // 项目名称
  98. $this->data['allproArray'] = $this->project->getFewRow($pidstr);
  99. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  100. // 标段按月进度
  101. for ($i = 1; $i <= 7; $i++) {
  102. $monthz[] = date('n月', strtotime('+' . $i . ' months', $this->data['currproArray']['intime']));
  103. if ($i == 1) {
  104. $ii = date('Y年', $this->data['currproArray']['intime']) . date('n月', strtotime('+' . $i . ' months', $this->data['currproArray']['intime']));
  105. } else {
  106. $ii = date('n月', strtotime('+' . $i . ' months', $this->data['currproArray']['intime']));
  107. }
  108. $this->data['months'][$i]['month'] = $ii;
  109. }
  110. // 标段
  111. // 搜索有没有相应的月份,有就把实际赋值,没有就为零
  112. $this->data['MeasureArray'] = $this->actmeasure->getRowsByPid($this->params['pid']);
  113. foreach ($this->data['MeasureArray'] as $key => $value) {
  114. $this->data['MeasureArray'][$key]['pmid'] = $value['pmid'];
  115. $this->data['MeasureArray'][$key]['type'] = $this->contractact->getRowByStid($value['stid'])['stname'];
  116. $numArray = $this->numofperact->getRowByPmid2($value['pmid']);
  117. $num = $num1 = 0;
  118. $this->data['MeasureArray'][$key]['num'] = $this->data['MeasureArray'][$key]['num1'] = NULL;
  119. foreach ($numArray as $k => $v) {
  120. if ($v['currstatus'] == 'checked') {
  121. $monthInt = date('n月', $v['audittime']);
  122. $retval = in_array($monthInt, $monthz);
  123. if ($retval) {
  124. $num = round(($v['currdone'] / $value['contracttotal']) * 100);
  125. $num1 = round(($v['curralltotal'] / $value['contracttotal']) * 100);
  126. }
  127. }
  128. $this->data['MeasureArray'][$key]['num'] .= $num . ',';
  129. $this->data['MeasureArray'][$key]['num1'] .= $num1 . ',';
  130. }
  131. $this->data['MeasureArray'][$key]['totalnum'] = $this->numofperact->getCountTotalnum($value['pmid']);
  132. $this->data['MeasureArray'][$key]['totalplus'] = number_format($this->actmeasure->getRowByPmid($value['pmid'])['contracttotal'], 2, '.', ',');
  133. $this->data['MeasureArray'][$key]['stopnow'] = $this->numofperact->getStopNowTotal($value['pmid'])['sntotal'];
  134. $this->data['MeasureArray'][$key]['nstopnow'] = number_format($this->numofperact->getStopNowTotal($value['pmid'])['sntotal'], 2, '.', ',');
  135. $this->data['MeasureArray'][$key]['currdone'] = $this->numofperact->getCurrdoneNew($value['pmid'])['currtotal'];
  136. $this->data['MeasureArray'][$key]['ncurrdone'] = number_format($this->data['MeasureArray'][$key]['currdone'], 2, '.', ',');
  137. $this->data['MeasureArray'][$key]['pstopnow'] = '0%';
  138. $this->data['MeasureArray'][$key]['pcurrdone'] = '0%';
  139. $this->data['MeasureArray'][$key]['pless'] = '0%';
  140. if ($value['contracttotal'] > 0) {
  141. $this->data['MeasureArray'][$key]['pstopnow'] = round(($this->data['MeasureArray'][$key]['stopnow'] / $value['contracttotal']) * 100);
  142. $this->data['MeasureArray'][$key]['dispstopnow'] = $this->data['MeasureArray'][$key]['pstopnow'] . '%';
  143. $this->data['MeasureArray'][$key]['pcurrdone'] = round(($this->data['MeasureArray'][$key]['currdone'] / $value['contracttotal']) * 100);
  144. $this->data['MeasureArray'][$key]['dispcurrdone'] = $this->data['MeasureArray'][$key]['pcurrdone'] . '%';
  145. $this->data['MeasureArray'][$key]['pless'] = (100 - $this->data['MeasureArray'][$key]['pstopnow'] - $this->data['MeasureArray'][$key]['pcurrdone']) . '%';
  146. }
  147. $this->data['MeasureArray'][$key]['nless'] = number_format($value['contracttotal'] - $this->data['MeasureArray'][$key]['stopnow'] - $this->data['MeasureArray'][$key]['currdone'], 2, '.', ',');
  148. $tenderArray = $this->numofperact->getRowTender2($value['pmid']);
  149. $this->data['MeasureArray'][$key]['ownstatus'] = '审批中';
  150. $ownerStatusArray = $this->measureauditact->getStatusTen($tenderArray['pmid'], $tenderArray['numpname']);
  151. if (isset($ownerStatusArray[0]['last']) && isset($ownerStatusArray[0]['mastatus']))
  152. if (($ownerStatusArray[0]['last'] == 1) && ($ownerStatusArray[0]['mastatus'] == 'checked')) {
  153. $this->data['MeasureArray'][$key]['ownstatus'] = '已审批';
  154. } else {
  155. $this->data['MeasureArray'][$key]['ownstatus'] = '审批中';
  156. }
  157. }
  158. $this->render('s-project-section', $this->data, TRUE);
  159. }
  160. public function proDetail() {
  161. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  162. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  163. foreach ($proArray as $v) {
  164. $pidArray[] = $v['pid'];
  165. }
  166. $pidstr = implode(',', $pidArray);
  167. // 项目名称
  168. $allproArray = $this->project->getFewRow($pidstr);
  169. // 面包屑导航项目
  170. foreach ($allproArray as $kk => $vv) {
  171. if ($vv['pid'] == $this->params['pid']) {
  172. $this->data['currproArray'] = $vv;
  173. } else {
  174. $this->data['allproArray'][] = $vv;
  175. }
  176. }
  177. // 面包屑导航合同
  178. $conArray = $this->contractact->getAll();
  179. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  180. if (isset($measureArray['stid'])) {
  181. foreach ($conArray as $kkk => $vvv) {
  182. if ($vvv['stid'] == $measureArray['stid']) {
  183. $this->data['currconArray'] = $vvv;
  184. } else {
  185. if ($vvv['pid'] == $this->params['pid'])
  186. $this->data['allconArray'][] = $vvv;
  187. }
  188. }
  189. } else {
  190. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  191. }
  192. // 面包屑导航标段
  193. $this->data['curractmeasureArray'] = NULL;
  194. $this->data['allactmeasureArray'] = [];
  195. $actmeasureArray = $this->actmeasure->getAll();
  196. foreach ($actmeasureArray as $kkkk => $vvvv) {
  197. if ($vvvv['stid'] == $measureArray['stid']) {
  198. if (($vvvv['pmid'] == $this->params['pmid'])) {
  199. $this->data['curractmeasureArray'] = $vvvv;
  200. } else {
  201. $this->data['allactmeasureArray'][] = $vvvv;
  202. }
  203. }
  204. }
  205. // 图标
  206. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  207. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  208. foreach ($this->data['MeasureArray'] as $key => $value) {
  209. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  210. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  211. } else {
  212. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  213. }
  214. }
  215. $this->data['pid'] = $this->params['pid'];
  216. // 获取当前合同段的期数
  217. // $this->data['allNumArray'] = $this->numofperact->getNumByStid(1);
  218. $this->render('s-project-section-detail', $this->data, TRUE);
  219. }
  220. public function proMeasure() {
  221. $MpidArray = $this->measureauditact->getRowByMpid(1);
  222. foreach ($MpidArray as $key => $value) {
  223. $uidArray = $value['uid'];
  224. }
  225. $this->data['pid'] = $this->params['pid'];
  226. $this->render('s-project-section-measure', $this->data);
  227. }
  228. Function fNumber($number) {
  229. if ($number == '')
  230. Return "-";
  231. $nlen = strlen($number);
  232. while ($nlen > 3) {
  233. $fNumber = "," . substr($number, $nlen - 3, 3);
  234. $number = substr($number, 0, -3);
  235. $nlen = strlen($number);
  236. }
  237. if ($nlen <= 3) {
  238. $fNumber = $number . $fNumber;
  239. }
  240. Return $fNumber;
  241. }
  242. public function welcome() {
  243. // if (!$this->auth->isLoggedIn())
  244. // return Doo::conf()->APP_URL;
  245. if ($this->profile->getProWithUid($_SESSION['uid'])['userid'])
  246. return Doo::conf()->APP_URL . 'project/list';
  247. if (isset($_POST['welform'])) {
  248. $profileUserArray = $_POST;
  249. $profileUserArray['userid'] = $_SESSION['uid'];
  250. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  251. return Doo::conf()->APP_URL . 'project/list';
  252. }
  253. $this->render('welcome', $this->data);
  254. }
  255. public function prolist() {
  256. // if (!$this->auth->isLoggedIn())
  257. // return Doo::conf()->APP_URL;
  258. // $proArray = new stdClass();
  259. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  260. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  261. // if ($handle = opendir($extPathdir)) {
  262. // while (false !== ($file = readdir($handle))) {
  263. // $filename = pathinfo($file);
  264. // if ($filename['extension'] == 'json')
  265. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  266. // }
  267. // closedir($handle);
  268. // }
  269. // $this->data['proArray'] = null;
  270. $this->render('s-project', $this->data);
  271. }
  272. }
  273. ?>