ProjectController.php 25 KB

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