ProjectController.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  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. if (isset($filedesc))
  387. $this->itemmeasurenum->updateItemFields($_POST['upimnid'], $filedesc, 0);
  388. if (isset($filename))
  389. $this->itemfle->updateItemFields($imnidArray['iaid'], $filename, 0);
  390. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  391. die();
  392. }
  393. }
  394. // 面包屑导航项目
  395. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  396. $this->data['pmid'] = $this->params['pmid'];
  397. $allproArray = $this->project->getAll();
  398. foreach ($allproArray as $kk => $vv) {
  399. if ($vv['pid'] == $this->params['pid']) {
  400. $this->data['currproArray'] = $vv;
  401. } else {
  402. $this->data['allproArray'][] = $vv;
  403. }
  404. }
  405. // 面包屑导航合同
  406. $conArray = $this->contractact->getAll();
  407. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  408. if (isset($measureArray['stid'])) {
  409. foreach ($conArray as $kkk => $vvv) {
  410. if ($vvv['stid'] == $measureArray['stid']) {
  411. $this->data['currconArray'] = $vvv;
  412. } else {
  413. if ($vvv['pid'] == $this->params['pid'])
  414. $this->data['allconArray'][] = $vvv;
  415. }
  416. }
  417. } else {
  418. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  419. }
  420. // 面包屑导航标段
  421. $this->data['curractmeasureArray'] = NULL;
  422. $this->data['allactmeasureArray'] = [];
  423. $actmeasureArray = $this->actmeasure->getAll();
  424. foreach ($actmeasureArray as $kkkk => $vvvv) {
  425. if ($vvvv['stid'] == $measureArray['stid']) {
  426. if (($vvvv['pmid'] == $this->params['pmid'])) {
  427. $this->data['curractmeasureArray'] = $vvvv;
  428. } else {
  429. $this->data['allactmeasureArray'][] = $vvvv;
  430. }
  431. }
  432. }
  433. // 选取查询
  434. $groupArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  435. $this->data['groupArray'] = $groupArray;
  436. $owneridArray = $this->itemfle->getGroupOwnerid($this->params['pmid']);
  437. foreach ($owneridArray as $k => $v) {
  438. $this->data['owneridArray'][$k]['name'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  439. $this->data['owneridArray'][$k]['iaid'] = $v['iaid'];
  440. $this->data['owneridArray'][$k]['ownerid'] = $v['ownerid'];
  441. }
  442. // 分页
  443. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid'], 0, $this->params['numpname'], $this->params['userid']);
  444. if ($totalArchive) {
  445. if ($this->params['numpname'] && $this->params['userid']) {
  446. $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);
  447. } elseif ($this->params['numpname']) {
  448. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/num/' . $this->params['numpname'] . '/page', $totalArchive, 20, 100);
  449. } elseif ($this->params['userid']) {
  450. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/user/' . $this->params['userid'] . '/page', $totalArchive, 20, 100);
  451. } else {
  452. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/page', $totalArchive, 20, 100);
  453. }
  454. $pager->setCss('', 'disabled', 'active');
  455. if (isset($this->params['pindex']))
  456. $pager->paginate(intval($this->params['pindex']));
  457. else
  458. $pager->paginate(1);
  459. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNum($this->params['pmid'], $pager->limit, $this->params['numpname'], $this->params['userid']);
  460. }
  461. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  462. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  463. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  464. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  465. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  466. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  467. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  468. }
  469. $this->data['pid'] = $this->params['pid'];
  470. $this->data['pmid'] = $this->params['pmid'];
  471. $this->data['mpid'] = $this->params['mpid'];
  472. $this->data['user'] = $this->params['userid'];
  473. $this->data['num'] = $this->params['numpname'];
  474. $this->data['pager'] = $pager->output;
  475. $this->render('w-project-section-files', $this->data, TRUE);
  476. }
  477. function proSectionFilesRecover()
  478. {
  479. if (isset($_POST['optype']) && ($_POST['optype'] == 'reconvery') && isset($_POST['imnid'])) {
  480. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  481. if ($imnidArray['iaid'] > 0) {
  482. $this->itemmeasurenum->recoveryDel($_POST['imnid']);
  483. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  484. die();
  485. }
  486. }
  487. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  488. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  489. if ($imnidArray['iaid'] > 0) {
  490. $iaidArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  491. if ($iaidArray['ownerid'] == $this->auth->getUid()) {
  492. $this->itemfle->delItem($imnidArray['iaid']);
  493. $this->itemmeasurenum->delItemIAID($imnidArray['iaid']);
  494. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  495. die();
  496. } else {
  497. echo json_encode(array('status' => 2), JSON_UNESCAPED_UNICODE);
  498. die();
  499. }
  500. }
  501. }
  502. // 面包屑导航项目
  503. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  504. $this->data['pmid'] = $this->params['pmid'];
  505. $allproArray = $this->project->getAll();
  506. foreach ($allproArray as $kk => $vv) {
  507. if ($vv['pid'] == $this->params['pid']) {
  508. $this->data['currproArray'] = $vv;
  509. } else {
  510. $this->data['allproArray'][] = $vv;
  511. }
  512. }
  513. // 面包屑导航合同
  514. $conArray = $this->contractact->getAll();
  515. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  516. if (isset($measureArray['stid'])) {
  517. foreach ($conArray as $kkk => $vvv) {
  518. if ($vvv['stid'] == $measureArray['stid']) {
  519. $this->data['currconArray'] = $vvv;
  520. } else {
  521. if ($vvv['pid'] == $this->params['pid'])
  522. $this->data['allconArray'][] = $vvv;
  523. }
  524. }
  525. } else {
  526. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  527. }
  528. // 面包屑导航标段
  529. $this->data['curractmeasureArray'] = NULL;
  530. $this->data['allactmeasureArray'] = [];
  531. $actmeasureArray = $this->actmeasure->getAll();
  532. foreach ($actmeasureArray as $kkkk => $vvvv) {
  533. if ($vvvv['stid'] == $measureArray['stid']) {
  534. if (($vvvv['pmid'] == $this->params['pmid'])) {
  535. $this->data['curractmeasureArray'] = $vvvv;
  536. } else {
  537. $this->data['allactmeasureArray'][] = $vvvv;
  538. }
  539. }
  540. }
  541. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid']);
  542. if ($totalArchive) {
  543. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/recover/page', $totalArchive, 20, 100);
  544. $pager->setCss('', 'disabled', 'active');
  545. if (isset($this->params['pindex']))
  546. $pager->paginate(intval($this->params['pindex']));
  547. else
  548. $pager->paginate(1);
  549. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNumDel($pager->limit, $this->params['pmid']);
  550. }
  551. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  552. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  553. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  554. $this->data['itemMeasureArray'][$k]['delname'] = $this->profile->getProWithUid($v['deluid'])['name'];
  555. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  556. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  557. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  558. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  559. $this->data['itemMeasureArray'][$k]['filepath'] = $fileArray['filepath'];
  560. }
  561. $this->data['pid'] = $this->params['pid'];
  562. $this->data['pmid'] = $this->params['pmid'];
  563. $this->data['mpid'] = $this->params['mpid'];
  564. $this->data['pager'] = $pager->output;
  565. $this->render('w-project-section-files-recover', $this->data, TRUE);
  566. }
  567. function getItemFileHistory()
  568. {
  569. if ($this->params['iaid']) {
  570. $iaidArray = $this->itemfle->getItemFile($this->params['iaid']);
  571. if ($iaidArray['oldiaid'] > 0) {
  572. $oldiaidArray = $this->itemfle->getFileHistory($iaidArray['oldiaid']);
  573. $htmlstr = '';
  574. foreach ($oldiaidArray as $k => $v) {
  575. $countInt = $k + 1;
  576. $formatDate = date('Y-m-d H:i:s', $v['intime']);
  577. $profileArray = $this->profile->getProWithUid($v['ownerid']);
  578. $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>';
  579. }
  580. echo json_encode(array('html' => $htmlstr), JSON_UNESCAPED_UNICODE);
  581. die();
  582. }
  583. }
  584. }
  585. Function fNumber($number)
  586. {
  587. if ($number == '')
  588. Return "-";
  589. $nlen = strlen($number);
  590. while ($nlen > 3) {
  591. $fNumber = "," . substr($number, $nlen - 3, 3);
  592. $number = substr($number, 0, -3);
  593. $nlen = strlen($number);
  594. }
  595. if ($nlen <= 3) {
  596. $fNumber = $number . $fNumber;
  597. }
  598. Return $fNumber;
  599. }
  600. private function getFav()
  601. {
  602. $proArray = $this->project->getAll($this->auth->getUid());
  603. $this->data['othrPro'] = [];
  604. foreach ($proArray as $key => $value) {
  605. if ($value['pid'] == $this->params['pid']) {
  606. $this->data['currProName'] = $value['pname'];
  607. $this->data['currProID'] = $value['pid'];
  608. } else {
  609. $this->data['othrPro'][] = $proArray[$key];
  610. }
  611. }
  612. }
  613. public function proSectionMeasure()
  614. {
  615. //此处未做更改,JSON文件已经固定名称
  616. $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  617. if (isset($jsonpath['dirname'])) {
  618. $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  619. if ($handle = opendir($extPathdir)) {
  620. while (false !== ($file = readdir($handle))) {
  621. $filename = NULL;
  622. $filename = pathinfo($file);
  623. if ($filename['extension'] == 'json')
  624. $proArray = json_decode(file_get_contents($extPathdir . '/' . $file), TRUE, JSON_UNESCAPED_UNICODE);
  625. }
  626. closedir($handle);
  627. }
  628. $this->data['proArray'] = $proArray['Bills'];
  629. } else {
  630. $this->data['proArray'] = [];
  631. }
  632. $this->data['mpid'] = $this->params['mpid'];
  633. $this->data['pid'] = $this->params['pid'];
  634. $this->render('w-project-section-measure', $this->data, TRUE);
  635. }
  636. public function substr_replace_cn($string, $repalce = '*', $start = 0, $len = 0)
  637. {
  638. $count = mb_strlen($string, 'UTF-8'); //此处传入编码,建议使用utf-8。此处编码要与下面mb_substr()所使用的一致
  639. if (!$count) {
  640. return $string;
  641. }
  642. if ($len == 0) {
  643. $end = $count; //传入0则替换到最后
  644. } else {
  645. $end = $start + $len; //传入指定长度则为开始长度+指定长度
  646. }
  647. $i = 0;
  648. $returnString = '';
  649. while ($i < $count) { //循环该字符串
  650. $tmpString = mb_substr($string, $i, 1, 'UTF-8'); // 与mb_strlen编码一致
  651. if ($start <= $i && $i < $end) {
  652. $returnString .= $repalce;
  653. } else {
  654. $returnString .= $tmpString;
  655. }
  656. $i++;
  657. }
  658. return $returnString;
  659. }
  660. function unicode_encode($name)
  661. {//to Unicode
  662. $name = iconv('UTF-8', 'UCS-2', $name);
  663. $len = strlen($name);
  664. $str = '';
  665. for ($i = 0; $i < $len - 1; $i = $i + 2) {
  666. $c = $name[$i];
  667. $c2 = $name[$i + 1];
  668. if (ord($c) > 0) {// 两个字节的字
  669. $str .= '\\' . base_convert(ord($c), 10, 16) . base_convert(ord($c2), 10, 16);
  670. } else {
  671. $str .= $c2;
  672. }
  673. }
  674. $str = strtoupper($str);
  675. return $str;
  676. }
  677. function unicode_decode($name)
  678. {//Unicode to
  679. $pattern = '/([\w]+)|(\\\u([\w]{4}))/i';
  680. preg_match_all($pattern, $name, $matches);
  681. if (!empty($matches)) {
  682. $name = '';
  683. for ($j = 0; $j < count($matches[0]); $j++) {
  684. $str = $matches[0][$j];
  685. if (strpos($str, '\\u') === 0) {
  686. $code = base_convert(substr($str, 2, 2), 16, 10);
  687. $code2 = base_convert(substr($str, 4), 16, 10);
  688. $c = chr($code) . chr($code2);
  689. $c = iconv('UCS-2', 'UTF-8', $c);
  690. $name .= $c;
  691. } else {
  692. $name .= $str;
  693. }
  694. }
  695. }
  696. return $name;
  697. }
  698. public function proDetail()
  699. {
  700. // 面包屑导航项目
  701. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  702. $this->data['pmid'] = $this->params['pmid'];
  703. $allproArray = $this->project->getAll();
  704. foreach ($allproArray as $kk => $vv) {
  705. if ($vv['pid'] == $this->params['pid']) {
  706. $this->data['currproArray'] = $vv;
  707. } else {
  708. $this->data['allproArray'][] = $vv;
  709. }
  710. }
  711. // 面包屑导航合同
  712. $conArray = $this->contractact->getAll();
  713. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  714. if (isset($measureArray['stid'])) {
  715. foreach ($conArray as $kkk => $vvv) {
  716. if ($vvv['stid'] == $measureArray['stid']) {
  717. $this->data['currconArray'] = $vvv;
  718. } else {
  719. if ($vvv['pid'] == $this->params['pid'])
  720. $this->data['allconArray'][] = $vvv;
  721. }
  722. }
  723. } else {
  724. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  725. }
  726. // 面包屑导航标段
  727. $this->data['curractmeasureArray'] = NULL;
  728. $this->data['allactmeasureArray'] = [];
  729. $actmeasureArray = $this->actmeasure->getAll();
  730. foreach ($actmeasureArray as $kkkk => $vvvv) {
  731. if ($vvvv['stid'] == $measureArray['stid']) {
  732. if (($vvvv['pmid'] == $this->params['pmid'])) {
  733. $this->data['curractmeasureArray'] = $vvvv;
  734. } else {
  735. $this->data['allactmeasureArray'][] = $vvvv;
  736. }
  737. }
  738. }
  739. // 图表
  740. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  741. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  742. foreach ($this->data['MeasureArray'] as $key => $value) {
  743. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  744. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  745. } else {
  746. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  747. }
  748. }
  749. $this->data['pmid'] = $this->params['pmid'];
  750. $this->data['pid'] = $this->params['pid'];
  751. $this->render('w-project-section-detail', $this->data, TRUE);
  752. }
  753. public function welcome()
  754. {
  755. // if (!$this->auth->isLoggedIn())
  756. // return Doo::conf()->APP_URL;
  757. if ($this->profile->getProWithUid($this->auth->getUid())['userid'])
  758. return Doo::conf()->APP_URL . 'project/list';
  759. if (isset($_POST['welform'])) {
  760. $profileUserArray = $_POST;
  761. $profileUserArray['userid'] = $this->auth->getUid();
  762. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  763. return Doo::conf()->APP_URL . 'project/list';
  764. }
  765. $this->render('welcome', $this->data);
  766. }
  767. // ajax提取密码名称
  768. public function getAjaxSection()
  769. {
  770. if (!$this->isAjax())
  771. return;
  772. echo json_encode($_POST);
  773. }
  774. function upItemFile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  775. {
  776. $this->att->setUploadDir();
  777. return $this->att->uploadMut($fildname, $param);
  778. }
  779. }
  780. ?>