ProjectController.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  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. Doo::loadClass('itemmeasurenum');
  11. Doo::loadClass('itemfile');
  12. /* * proDetail
  13. * MainController
  14. * Feel free to delete the methods and replace them with your own code.
  15. *
  16. * @author darkredz
  17. */
  18. class ProjectController extends DooController
  19. {
  20. private $data, $auth, $attfile, $profile, $project, $contractact, $actmeasure, $measureauditact, $numofperact, $statusArray = array('uncheck' => '<span class = "colGray">未审批</span>', 'checking' => '<span class = "colOrange">审批中</span>', 'checked' => '<span class = "colGreen">审批通过</span>', 'checkno' => '<span class = "colRed">审批不通过</span>'), $itemmeasurenum, $itemfle;
  21. public function beforeRun($resource, $action)
  22. {
  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. {
  34. $this->auth = new Auth();
  35. $this->attfile = new attFile();
  36. $this->profile = new Profile();
  37. $this->project = new Project();
  38. $this->contractact = new Contractact();
  39. $this->actmeasure = new actMeasure();
  40. $this->numofperact = new NumofperAct();
  41. $this->measureauditact = new MeasureauditAct();
  42. $this->itemmeasurenum = new ItemMeasureNumpofper();
  43. $this->itemfle = new ItemFile();
  44. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  45. $this->data['currChannle'] = 'p';
  46. $this->data['user'] = $this->profile->getProWithUid($this->auth->getUid());
  47. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  48. if (isset($mpidArray[0]['pid'])) {
  49. foreach ($mpidArray as $key => $value) {
  50. // 审批操作按照时间排序多标段
  51. $this->data['numofchecking'] += $this->measureauditact->getCountMyChecking($value['pid'], $this->auth->getUid());
  52. }
  53. }
  54. if ($this->data['numofchecking'] == 0) {
  55. $this->data['numofchecking'] = null;
  56. }
  57. }
  58. /**
  59. *
  60. * @return type
  61. */
  62. public function index()
  63. {
  64. if (isset($_POST['pname']) && $_POST['pname']) {
  65. $this->project->insertProject($this->auth->getUid(), $_POST['pname']);
  66. return Doo::conf()->APP_URL . 'project/index';
  67. }
  68. if (isset($_POST['target_pname']) && $_POST['target_pname'] && isset($_POST['ppid']) && $_POST['ppid']) {
  69. $this->project->updateProName($_POST['ppid'], $_POST['target_pname']);
  70. return Doo::conf()->APP_URL . 'project/index';
  71. }
  72. $this->data['pros'] = $this->project->getAll($this->auth->getUid());
  73. if (isset($this->data['pros'][0]['pid'])) {
  74. foreach ($this->data['pros'] as $key => $value) {
  75. $this->data['pros'][$key]['numMeasure'] = $this->actmeasure->getMearsureCount($value['pid']);
  76. $this->data['pros'][$key]['contracttotal'] = $this->actmeasure->getTotalWithPid($value['pid']);
  77. $this->data['pros'][$key]['changTotal'] = $this->numofperact->getChangTotal($value['pid']);
  78. // $this->data['pros'][$key]['contracttotal'] += $this->data['pros'][$key]['changTotal'];
  79. $this->data['pros'][$key]['currdone'] = $this->numofperact->getCurrDoneNow($value['pid']);
  80. if ($this->data['pros'][$key]['contracttotal']) {
  81. $this->data['pros'][$key]['pcurrdone'] = round(($this->data['pros'][$key]['currdone'] / $this->data['pros'][$key]['contracttotal']) * 100) . '%';
  82. } else {
  83. $this->data['pros'][$key]['pcurrdone'] = '0%';
  84. }
  85. $this->data['pros'][$key]['bcontracttotal'] = number_format($this->data['pros'][$key]['contracttotal'], 2, '.', ',');
  86. $this->data['pros'][$key]['bchangTotal'] = number_format($this->data['pros'][$key]['changTotal'], 2, '.', ',');
  87. }
  88. } else {
  89. $this->data['pros'] = [];
  90. }
  91. $this->render('w-project', $this->data, TRUE);
  92. }
  93. public function proOverview()
  94. {
  95. $conArray = $this->contractact->getRowByPid($this->params['pid']);
  96. $this->data['projectDate'] = '';
  97. $this->data['conArray'][] = array();
  98. $this->getFav();
  99. // $this->data['measureArray'] = $this->actmeasure->getRowByPids($this->params['pid']);
  100. // foreach ($this->data['measureArray'] as $key => $value) {
  101. // $this->data['measureArray'][$key]['stopNow'] = $this->numofperact->getStopNow($value['pmid'])['sntotal'];
  102. // $this->data['measureArray'][$key]['pstopnow'] = round(($this->data['measureArray'][$key]['stopNow'] / $value['contracttotal']) * 100);
  103. // }
  104. $this->data['pid'] = $this->params['pid'];
  105. $this->data['conArray'] = $conArray;
  106. $contracttotal = 0;
  107. // 不同标段和值
  108. // $list = $this->numofperact->getStopNowStMonth($v['stid']); //print_r($list);
  109. // if (empty($list))
  110. // $startMonth = date("Y-m");
  111. // else
  112. // $startMonth = $list[0]['month'];
  113. // //$list=Array ( 0 => Array ( 'sntotal' => 20000 ,'month' => '2014-09' ),1 => Array ( 'sntotal' => 40000, 'month' => '2016-10' ) );
  114. // $d = 0;
  115. // $mDList = $mList = array();
  116. // $toMD = date("Y-m");
  117. // foreach ($list as $value) {
  118. // $flag = true;
  119. // do {
  120. // $MD = date("Y-m", strtotime($startMonth . " " . $d . " month")); //echo $MD."/".$value['month']."<br/>";
  121. // array_push($mDList, "'" . $MD . "'");
  122. // array_push($mList, $MD);
  123. //
  124. // if ($MD == $toMD)//if(strtotime($MD)>=strtotime($toMD))
  125. // $flag = false;
  126. // if ($d > 0 && ($MD == $value['month'] || $toMD == $value['month']))
  127. // $flag = false;
  128. // $d++;
  129. //// if ($d==10)
  130. //// $flag=false;
  131. // } while ($flag);
  132. // }
  133. // $this->data['projectDate'] = implode(',', $mDList);
  134. //
  135. // $dataList = array();
  136. // $sntotalTA = 0;
  137. // foreach ($mList as $va) {
  138. // $falg = true;
  139. // foreach ($list as $value) {
  140. // if ($va == $value['month']) {
  141. // $sntotalTA+=$value['sntotal'];
  142. // $PER = round($sntotalTA / $contracttotal, 3) * 100;
  143. // array_push($dataList, $PER);
  144. // $falg = false;
  145. // break;
  146. // }
  147. // }
  148. // if ($falg)
  149. // array_push($dataList, 0);
  150. // }
  151. // $this->data['conArray'][$k]['monthStopnow'] = $dataList;
  152. //
  153. // $list = $this->numofperact->getCurrDoneSMontht($v['stid']);
  154. // $dataList = array();
  155. // $currdoneTA = 0;
  156. // foreach ($mList as $va) {
  157. // $falg = true;
  158. // foreach ($list as $value) {
  159. // if ($va == $value['month']) {
  160. // $currdoneTA+=$value['currdone'];
  161. // $PER = round($currdoneTA / $contracttotal, 3) * 100;
  162. // array_push($dataList, $PER);
  163. // $falg = false;
  164. // break;
  165. // }
  166. // }
  167. // if ($falg)
  168. // array_push($dataList, 0);
  169. // }
  170. // $this->data['conArray'][$k]['monthCurrdone'] = $dataList;
  171. //
  172. $totalstid = 0;
  173. $monthArray = [];
  174. foreach ($this->data['conArray'] as $k => $v) {
  175. $this->data['conArray'][$k]['pstopnow'] = $this->data['conArray'][$k]['pscurrdone'] = 0;
  176. $retval = $this->actmeasure->getAllbyStidSum($v['stid']);
  177. $contracttotal += $retval[0]['contracttotal'];
  178. $totalstid += $this->actmeasure->getTotal($v['stid'])['total'];
  179. $total = $this->actmeasure->getTotal($v['stid'])['total'];
  180. if ($total) {
  181. $this->data['conArray'][$k]['total'] = round($total, 2);
  182. } else {
  183. $this->data['conArray'][$k]['total'] = 0;
  184. }
  185. $sntotal = $this->numofperact->getCountTotalSTID2($v['stid'])['totalplus'];
  186. if ($sntotal) {
  187. $this->data['conArray'][$k]['stopnow'] = round($sntotal, 2);
  188. } else {
  189. $this->data['conArray'][$k]['stopnow'] = 0;
  190. }
  191. $this->data['conArray'][$k]['currdone'] = $this->numofperact->getCurrDoneSt($v['stid'])['currdone'];
  192. if ($this->data['conArray'][$k]['total'] > 0) {
  193. $this->data['conArray'][$k]['pstopnow'] = round(($this->data['conArray'][$k]['stopnow'] / $this->data['conArray'][$k]['total']) * 100);
  194. $this->data['conArray'][$k]['pscurrdone'] = round(($this->data['conArray'][$k]['currdone'] / $this->data['conArray'][$k]['total']) * 100);
  195. }
  196. // 分组出年月 每个月份的独立相加
  197. $month = $this->numofperact->getStopNowStMonth($v['stid']);
  198. foreach ($month as $key => $value) {
  199. $allmonth[] = $value;
  200. if (!in_array($value['month'], $monthArray))
  201. $monthArray = $value['month'];
  202. }
  203. // 分组出年月 每个月份的独立相加
  204. $month1 = $this->numofperact->getCurrDoneSMontht($v['stid']);
  205. foreach ($month1 as $key => $value) {
  206. $allmonth1[] = $value;
  207. }
  208. }
  209. // 中文表述年月
  210. foreach ($monthArray as $kk => $vv) {
  211. foreach ($allmonth as $keyk => $valuev) {
  212. if ($valuev['month'] == $vv)
  213. $total[$kk] += $valuev['sntotal'];
  214. }
  215. foreach ($allmonth1 as $k1 => $v1) {
  216. if ($v1['month'] == $vv)
  217. $total1[$kk] += $v1['currdone'];
  218. }
  219. $ymarray = split('-', $vv);
  220. $cnym = '\'' . $ymarray[1] . '月' . '\'';
  221. if ($kk == 0)
  222. $cnym = '\'' . $ymarray[0] . '年' . $ymarray[1] . '月' . '\'';
  223. $cnymArray[] = $cnym;
  224. }
  225. foreach ($total as $value2) {
  226. $total3[] = round(($value2 / $totalstid) * 100);
  227. }
  228. foreach ($total1 as $value11) {
  229. $total4[] = round(($value11 / $totalstid) * 100);
  230. }
  231. $this->data['projectDate'] = implode(',', $cnymArray);
  232. $this->data['t1'] = implode(',', $total3);
  233. $this->data['t2'] = implode(',', $total4);
  234. $this->render('w-project-detail', $this->data, TRUE);
  235. }
  236. public function proSection()
  237. {
  238. if (isset($_POST['stid']) && isset($_POST['proname'])) {
  239. $this->contractact->updateStName($_POST['stid'], $_POST['proname']);
  240. return Doo::conf()->APP_URL . 'project/' . $this->params['pid'] . '/section';
  241. }
  242. $this->getFav();
  243. $contractArray = $this->contractact->getRowByPid($this->params['pid']); // 获取合同段
  244. $htmlstr = NULL;
  245. foreach ($contractArray as $k => $v) {// 获取所有合同段
  246. $retval = $this->actmeasure->getAllbyStid($v['stid']); // 获取标段
  247. $bdhtmlstr = NULL;
  248. $bdhtmlstr = '<thead>
  249. <tr><th class="taC taCble header" width="225">标段名</th><th class="taC" width="140">计量期数</th><th width="115" class="taC">总价</th><th class="taC" width="">截止上期完成/本期完成/未完成</th></tr></thead>
  250. <tbody>';
  251. $biaoduantotalmoney = 0;
  252. $currTotal = 0;
  253. $progress = $otherprogress = '0%';
  254. $currTotal = $this->numofperact->getCountTotalSTID2($v['stid']);
  255. foreach ($retval as $key => $value) {
  256. $displayPercentSnTotalProgress = '0%';
  257. $displayPercentCurrTotalProgress = '0%';
  258. $displayPercentLessTotalProgress = '0%';
  259. $snTotalProgress = $currTotalProgress = $lessTotalProgress = '0%';
  260. $nTotalProgress = $ncurrTotalProgress = $nlessTotalProgress = number_format(0, 2, '.', ',');
  261. $numCount = $this->numofperact->getCountTotalnum2($value['pmid']); // 获取标段已有期数
  262. if (isset($numCount['numpname'])) {
  263. $lastStatusArray = $this->numofperact->getMaxStatusTimes($value['pmid'], $numCount['numpname']);
  264. } else {
  265. $lastStatusArray['currstatus'] = 'uncheck';
  266. $numCount['numpname'] = 0;
  267. }
  268. $totalplus = $this->numofperact->getCountTotalplus($value['pmid']);
  269. $snTotal = $this->numofperact->getStopNowTotal($value['pmid']); //根据标段ID获取最新一期(包括不通过)
  270. $currcomTotal = $this->numofperact->getCurrdoneNew($value['pmid']); //截止目前
  271. $numStatusArray = $this->numofperact->getLastStatus2($this->params['pid'], $value['pmid']);
  272. if ($numCount > 0) {
  273. $nTotalProgress = number_format($snTotal['sntotal'], 2, '.', ',');
  274. $ncurrTotalProgress = number_format($currcomTotal['currtotal'], 2, '.', ',');
  275. $nlessTotalProgress = number_format($value['contracttotal'] - $snTotal['sntotal'] - $currcomTotal['currtotal'], 2, '.', ',');
  276. if (isset($value['contracttotal']) && ($value['contracttotal'] > 0)) {
  277. $snTotalProgress = round(($snTotal['sntotal'] / $value['contracttotal']) * 100);
  278. $currTotalProgress = round(($currcomTotal['currtotal'] / $value['contracttotal']) * 100);
  279. // $lessTotalProgress = round((($value['contracttotal'] - ($currcomTotal['currtotal'] + $snTotal['sntotal'])) / $value['contracttotal']) * 100);
  280. $lessTotalProgress = 100 - $snTotalProgress - $currTotalProgress;
  281. $displayPercentSnTotalProgress = $snTotalProgress . '%';
  282. $displayPercentCurrTotalProgress = $currTotalProgress . '%';
  283. $displayPercentLessTotalProgress = $lessTotalProgress . '%';
  284. }
  285. }
  286. $biaoduantotalmoney += $value['contracttotal'];
  287. $totalmoney = number_format($value['contracttotal'], 2, '.', ',');
  288. if (isset($numStatusArray['currstatus'])) {
  289. $statusStr = '(' . $this->statusArray[$lastStatusArray['currstatus']] . ')';
  290. } else {
  291. $statusStr = '';
  292. }
  293. $bdhtmlstr .= '
  294. <tr>
  295. <td><a href="/project/' . $this->params['pid'] . '/section/' . $value['pmid'] . '/detail">' . $value['pmname'] . '</a></td>
  296. <td class="">第 ' . $numCount['numpname'] . ' 期' . $statusStr . '</td>
  297. <td class="taR">¥' . $totalmoney . '</td>
  298. <td>
  299. <div class="progress">
  300. <div class="bar bar-success" style="width: ' . $displayPercentSnTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成:¥' . $nTotalProgress . '">' . $displayPercentSnTotalProgress . '</div>
  301. <div class="bar" style="width:' . $displayPercentCurrTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' . $ncurrTotalProgress . '">' . $displayPercentCurrTotalProgress . '</div>
  302. <div class="bar bar-gary" style="width:' . $displayPercentLessTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $nlessTotalProgress . '">' . $displayPercentLessTotalProgress . '</div>
  303. </div>
  304. </td>
  305. </tr>';
  306. }
  307. $nprogress = $notherprogress = NULL;
  308. // $currTotal = $this->numofperact->getCurrdoneSTID($v['stid']);
  309. if ($biaoduantotalmoney > 0) {
  310. $nprogress = number_format($currTotal['totalplus'], 2, '.', ',');
  311. $notherprogress = number_format($biaoduantotalmoney - $currTotal['totalplus'], 2, '.', ',');
  312. $progress = round(($currTotal['totalplus'] / $biaoduantotalmoney) * 100) . '%'; // 累计完成计量 所有标段合计
  313. $otherprogress = round((($biaoduantotalmoney - $currTotal['totalplus']) / $biaoduantotalmoney) * 100) . '%';
  314. $biaoduantotalmoney = number_format($biaoduantotalmoney, 2, '.', ',');
  315. }
  316. $htmlstr .= '<div class="project">
  317. <div class="proSection">
  318. <table class="table">
  319. <thead>
  320. <tr>
  321. <td width="150"><span aria-hidden="true" data-icon="u"></span> ' . $v['stname'] . '<a id="idt_' . $v['stid'] . '" href="#secoption" data-toggle="modal" title="编辑/查看KEY" stid="' . $v['stid'] . '" proname="' . $v['stname'] . '" key="' . $v['stkey'] . '"><span data-icon="S" aria-hidden="true" class="closePanel" data-placement="bottom" data-toggle="tooltip" data-original-title="查看KEY" style="font-size:18px"></span></a></td>
  322. <td width="90">总价:</td><td width="165">¥<b style="font-size:16px">' . $biaoduantotalmoney . '</b></td>
  323. <td width="60">完成进度:</td><td><div class="progress">
  324. <div class="bar bar-success" style="width:' . $progress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="累计完成:¥' . $nprogress . '">' . $progress . '</div>
  325. <div class="bar bar-danger" style="width:' . $otherprogress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $notherprogress . '">' . $otherprogress . '</div>
  326. </div></td>
  327. </tr>
  328. </thead>
  329. </table>
  330. <table class="table table-striped table-hover tablelist">
  331. ' . $bdhtmlstr . '
  332. </tbody>
  333. </table>
  334. </div>
  335. </div>';
  336. }
  337. $this->data['htmlstr'] = $htmlstr;
  338. if (isset($_POST['secname']) && $_POST['secname']) {
  339. $this->contractact->insertContract($this->params['pid'], $this->auth->getUid(), $_POST['secname']);
  340. return Doo::conf()->APP_URL . 'project/' . $this->params['pid'] . '/section';
  341. }
  342. $this->data['pid'] = $this->params['pid'];
  343. $this->render('w-project-section', $this->data, TRUE);
  344. }
  345. function proSectionFiles()
  346. {
  347. // 面包屑导航项目
  348. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  349. $this->data['pmid'] = $this->params['pmid'];
  350. $allproArray = $this->project->getAll();
  351. foreach ($allproArray as $kk => $vv) {
  352. if ($vv['pid'] == $this->params['pid']) {
  353. $this->data['currproArray'] = $vv;
  354. } else {
  355. $this->data['allproArray'][] = $vv;
  356. }
  357. }
  358. // 面包屑导航合同
  359. $conArray = $this->contractact->getAll();
  360. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  361. if (isset($measureArray['stid'])) {
  362. foreach ($conArray as $kkk => $vvv) {
  363. if ($vvv['stid'] == $measureArray['stid']) {
  364. $this->data['currconArray'] = $vvv;
  365. } else {
  366. if ($vvv['pid'] == $this->params['pid'])
  367. $this->data['allconArray'][] = $vvv;
  368. }
  369. }
  370. } else {
  371. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  372. }
  373. // 面包屑导航标段
  374. $this->data['curractmeasureArray'] = NULL;
  375. $this->data['allactmeasureArray'] = [];
  376. $actmeasureArray = $this->actmeasure->getAll();
  377. foreach ($actmeasureArray as $kkkk => $vvvv) {
  378. if ($vvvv['stid'] == $measureArray['stid']) {
  379. if (($vvvv['pmid'] == $this->params['pmid'])) {
  380. $this->data['curractmeasureArray'] = $vvvv;
  381. } else {
  382. $this->data['allactmeasureArray'][] = $vvvv;
  383. }
  384. }
  385. }
  386. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNum($this->params['pmid']);
  387. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  388. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  389. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  390. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  391. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  392. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  393. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  394. }
  395. $this->data['pid'] = $this->params['pid'];
  396. $this->data['pmid'] = $this->params['pmid'];
  397. $this->data['mpid'] = $this->params['mpid'];
  398. $this->render('w-project-section-files', $this->data, TRUE);
  399. }
  400. function proSectionFilesRecover()
  401. {
  402. // 面包屑导航项目
  403. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  404. $this->data['pmid'] = $this->params['pmid'];
  405. $allproArray = $this->project->getAll();
  406. foreach ($allproArray as $kk => $vv) {
  407. if ($vv['pid'] == $this->params['pid']) {
  408. $this->data['currproArray'] = $vv;
  409. } else {
  410. $this->data['allproArray'][] = $vv;
  411. }
  412. }
  413. // 面包屑导航合同
  414. $conArray = $this->contractact->getAll();
  415. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  416. if (isset($measureArray['stid'])) {
  417. foreach ($conArray as $kkk => $vvv) {
  418. if ($vvv['stid'] == $measureArray['stid']) {
  419. $this->data['currconArray'] = $vvv;
  420. } else {
  421. if ($vvv['pid'] == $this->params['pid'])
  422. $this->data['allconArray'][] = $vvv;
  423. }
  424. }
  425. } else {
  426. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  427. }
  428. // 面包屑导航标段
  429. $this->data['curractmeasureArray'] = NULL;
  430. $this->data['allactmeasureArray'] = [];
  431. $actmeasureArray = $this->actmeasure->getAll();
  432. foreach ($actmeasureArray as $kkkk => $vvvv) {
  433. if ($vvvv['stid'] == $measureArray['stid']) {
  434. if (($vvvv['pmid'] == $this->params['pmid'])) {
  435. $this->data['curractmeasureArray'] = $vvvv;
  436. } else {
  437. $this->data['allactmeasureArray'][] = $vvvv;
  438. }
  439. }
  440. }
  441. $this->data['itematta'] = $this->itemfle->getFilesAll($this->params['pmid']);
  442. foreach ($this->data['itematta'] as $k => $v) {
  443. $this->data['itematta'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  444. $this->data['itematta'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  445. }
  446. $this->data['pid'] = $this->params['pid'];
  447. $this->data['pmid'] = $this->params['pmid'];
  448. $this->data['mpid'] = $this->params['mpid'];
  449. $this->render('w-project-section-files-recover', $this->data, TRUE);
  450. }
  451. Function fNumber($number)
  452. {
  453. if ($number == '')
  454. Return "-";
  455. $nlen = strlen($number);
  456. while ($nlen > 3) {
  457. $fNumber = "," . substr($number, $nlen - 3, 3);
  458. $number = substr($number, 0, -3);
  459. $nlen = strlen($number);
  460. }
  461. if ($nlen <= 3) {
  462. $fNumber = $number . $fNumber;
  463. }
  464. Return $fNumber;
  465. }
  466. private function getFav()
  467. {
  468. $proArray = $this->project->getAll($this->auth->getUid());
  469. $this->data['othrPro'] = [];
  470. foreach ($proArray as $key => $value) {
  471. if ($value['pid'] == $this->params['pid']) {
  472. $this->data['currProName'] = $value['pname'];
  473. $this->data['currProID'] = $value['pid'];
  474. } else {
  475. $this->data['othrPro'][] = $proArray[$key];
  476. }
  477. }
  478. }
  479. public function proSectionMeasure()
  480. {
  481. //此处未做更改,JSON文件已经固定名称
  482. $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  483. if (isset($jsonpath['dirname'])) {
  484. $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  485. if ($handle = opendir($extPathdir)) {
  486. while (false !== ($file = readdir($handle))) {
  487. $filename = NULL;
  488. $filename = pathinfo($file);
  489. if ($filename['extension'] == 'json')
  490. $proArray = json_decode(file_get_contents($extPathdir . '/' . $file), TRUE, JSON_UNESCAPED_UNICODE);
  491. }
  492. closedir($handle);
  493. }
  494. $this->data['proArray'] = $proArray['Bills'];
  495. } else {
  496. $this->data['proArray'] = [];
  497. }
  498. $this->data['mpid'] = $this->params['mpid'];
  499. $this->data['pid'] = $this->params['pid'];
  500. $this->render('w-project-section-measure', $this->data, TRUE);
  501. }
  502. public function substr_replace_cn($string, $repalce = '*', $start = 0, $len = 0)
  503. {
  504. $count = mb_strlen($string, 'UTF-8'); //此处传入编码,建议使用utf-8。此处编码要与下面mb_substr()所使用的一致
  505. if (!$count) {
  506. return $string;
  507. }
  508. if ($len == 0) {
  509. $end = $count; //传入0则替换到最后
  510. } else {
  511. $end = $start + $len; //传入指定长度则为开始长度+指定长度
  512. }
  513. $i = 0;
  514. $returnString = '';
  515. while ($i < $count) { //循环该字符串
  516. $tmpString = mb_substr($string, $i, 1, 'UTF-8'); // 与mb_strlen编码一致
  517. if ($start <= $i && $i < $end) {
  518. $returnString .= $repalce;
  519. } else {
  520. $returnString .= $tmpString;
  521. }
  522. $i++;
  523. }
  524. return $returnString;
  525. }
  526. function unicode_encode($name)
  527. {//to Unicode
  528. $name = iconv('UTF-8', 'UCS-2', $name);
  529. $len = strlen($name);
  530. $str = '';
  531. for ($i = 0; $i < $len - 1; $i = $i + 2) {
  532. $c = $name[$i];
  533. $c2 = $name[$i + 1];
  534. if (ord($c) > 0) {// 两个字节的字
  535. $str .= '\\' . base_convert(ord($c), 10, 16) . base_convert(ord($c2), 10, 16);
  536. } else {
  537. $str .= $c2;
  538. }
  539. }
  540. $str = strtoupper($str);
  541. return $str;
  542. }
  543. function unicode_decode($name)
  544. {//Unicode to
  545. $pattern = '/([\w]+)|(\\\u([\w]{4}))/i';
  546. preg_match_all($pattern, $name, $matches);
  547. if (!empty($matches)) {
  548. $name = '';
  549. for ($j = 0; $j < count($matches[0]); $j++) {
  550. $str = $matches[0][$j];
  551. if (strpos($str, '\\u') === 0) {
  552. $code = base_convert(substr($str, 2, 2), 16, 10);
  553. $code2 = base_convert(substr($str, 4), 16, 10);
  554. $c = chr($code) . chr($code2);
  555. $c = iconv('UCS-2', 'UTF-8', $c);
  556. $name .= $c;
  557. } else {
  558. $name .= $str;
  559. }
  560. }
  561. }
  562. return $name;
  563. }
  564. public function proDetail()
  565. {
  566. // 面包屑导航项目
  567. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  568. $this->data['pmid'] = $this->params['pmid'];
  569. $allproArray = $this->project->getAll();
  570. foreach ($allproArray as $kk => $vv) {
  571. if ($vv['pid'] == $this->params['pid']) {
  572. $this->data['currproArray'] = $vv;
  573. } else {
  574. $this->data['allproArray'][] = $vv;
  575. }
  576. }
  577. // 面包屑导航合同
  578. $conArray = $this->contractact->getAll();
  579. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  580. if (isset($measureArray['stid'])) {
  581. foreach ($conArray as $kkk => $vvv) {
  582. if ($vvv['stid'] == $measureArray['stid']) {
  583. $this->data['currconArray'] = $vvv;
  584. } else {
  585. if ($vvv['pid'] == $this->params['pid'])
  586. $this->data['allconArray'][] = $vvv;
  587. }
  588. }
  589. } else {
  590. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  591. }
  592. // 面包屑导航标段
  593. $this->data['curractmeasureArray'] = NULL;
  594. $this->data['allactmeasureArray'] = [];
  595. $actmeasureArray = $this->actmeasure->getAll();
  596. foreach ($actmeasureArray as $kkkk => $vvvv) {
  597. if ($vvvv['stid'] == $measureArray['stid']) {
  598. if (($vvvv['pmid'] == $this->params['pmid'])) {
  599. $this->data['curractmeasureArray'] = $vvvv;
  600. } else {
  601. $this->data['allactmeasureArray'][] = $vvvv;
  602. }
  603. }
  604. }
  605. // 图表
  606. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  607. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  608. foreach ($this->data['MeasureArray'] as $key => $value) {
  609. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  610. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  611. } else {
  612. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  613. }
  614. }
  615. $this->data['pmid'] = $this->params['pmid'];
  616. $this->data['pid'] = $this->params['pid'];
  617. $this->render('w-project-section-detail', $this->data, TRUE);
  618. }
  619. public function welcome()
  620. {
  621. // if (!$this->auth->isLoggedIn())
  622. // return Doo::conf()->APP_URL;
  623. if ($this->profile->getProWithUid($this->auth->getUid())['userid'])
  624. return Doo::conf()->APP_URL . 'project/list';
  625. if (isset($_POST['welform'])) {
  626. $profileUserArray = $_POST;
  627. $profileUserArray['userid'] = $this->auth->getUid();
  628. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  629. return Doo::conf()->APP_URL . 'project/list';
  630. }
  631. $this->render('welcome', $this->data);
  632. }
  633. public function prolist()
  634. {
  635. // if (!$this->auth->isLoggedIn())
  636. // return Doo::conf()->APP_URL;
  637. // $proArray = new stdClass();
  638. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  639. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  640. // if ($handle = opendir($extPathdir)) {
  641. // while (false !== ($file = readdir($handle))) {
  642. // $filename = pathinfo($file);
  643. // if ($filename['extension'] == 'json')
  644. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  645. // }
  646. // closedir($handle);
  647. // }
  648. // $this->data['proArray'] = null;
  649. $this->render('s-project
  650. ', $this->data);
  651. }
  652. // ajax提取密码名称
  653. public function getAjaxSection()
  654. {
  655. if (!$this->isAjax())
  656. return;
  657. echo json_encode($_POST);
  658. }
  659. }
  660. ?>