ProjectController.php 34 KB

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