ProjectController.php 38 KB

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