ProjectController.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  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->getCurrTotalStMonthNoCheckno($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->getCurrDoneStMonthNoCheckno($v['stid']);
  208. foreach ($month1 as $key => $value) {
  209. $allmonth1[] = $value;
  210. }
  211. }
  212. // 中文表述年月
  213. $total = $total1 = array();
  214. $startyear = $cnymArray = array();
  215. foreach ($monthArray as $kk => $vv) {
  216. $ymarray = explode('-', $vv);
  217. if (!in_array($ymarray[0], $startyear))
  218. $startyear[] = $ymarray[0];
  219. // $cnym = '\'' . $ymarray[1] . '月' . '\'';
  220. // if ($kk == 0)
  221. // $cnym = '\'' . $ymarray[0] . '年' . $ymarray[1] . '月' . '\'';
  222. // $cnymArray[] = $cnym;
  223. }
  224. $thismonth = 0;
  225. foreach($startyear as $sk => $sv){
  226. for($i = 1; $i <= 12; $i++){
  227. $j = $i < 10 ? '0'.$i : $i;
  228. $month = $sv.'-'.$j;
  229. $thismonth1 = 0;
  230. foreach ($allmonth as $keyk => $valuev) {
  231. if ($valuev['month'] == $month)
  232. $thismonth += $valuev['currtotal'];
  233. }
  234. $total[] = $thismonth != 0 ? $thismonth : 0;
  235. foreach ($allmonth1 as $k1 => $v1) {
  236. if ($v1['month'] == $month)
  237. $thismonth1 += $v1['currdone'];
  238. }
  239. $total1[] = $thismonth1 != 0 ? $thismonth1 : 0;
  240. $cnymArray[] = $i == 1 ? '\'' .$sv.'年'.$i.'月'. '\'' : '\'' .$i.'月'. '\'';
  241. }
  242. }
  243. foreach ($total as $value2) {
  244. $total3[] = round(($value2 / $totalstid) * 100);
  245. }
  246. foreach ($total1 as $value11) {
  247. $total4[] = round(($value11 / $totalstid) * 100);
  248. }
  249. $this->data['projectDate'] = implode(',', $cnymArray);
  250. $this->data['t1'] = implode(',', $total3);
  251. $this->data['t2'] = implode(',', $total4);
  252. $this->render('w-project-detail', $this->data, TRUE);
  253. }
  254. public function proSection()
  255. {
  256. if (isset($_POST['stid']) && isset($_POST['proname'])) {
  257. $this->contractact->updateStName($_POST['stid'], $_POST['proname']);
  258. return Doo::conf()->APP_URL . 'project/' . $this->params['pid'] . '/section';
  259. }
  260. $this->getFav();
  261. $contractArray = $this->contractact->getRowByPid($this->params['pid']); // 获取合同段
  262. $htmlstr = NULL;
  263. foreach ($contractArray as $k => $v) {// 获取所有合同段
  264. $retval = $this->actmeasure->getAllbyStid($v['stid']); // 获取标段
  265. $bdhtmlstr = NULL;
  266. $bdhtmlstr = '<thead>
  267. <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>
  268. <tbody>';
  269. $biaoduantotalmoney = 0;
  270. $currTotal = 0;
  271. $progress = $otherprogress = '0%';
  272. $currTotal = $this->numofperact->getCountTotalSTID2($v['stid']);
  273. foreach ($retval as $key => $value) {
  274. $displayPercentSnTotalProgress = '0%';
  275. $displayPercentCurrTotalProgress = '0%';
  276. $displayPercentLessTotalProgress = '0%';
  277. $snTotalProgress = $currTotalProgress = $lessTotalProgress = '0%';
  278. $nTotalProgress = $ncurrTotalProgress = $nlessTotalProgress = number_format(0, 2, '.', ',');
  279. $numCount = $this->numofperact->getCountTotalnum2($value['pmid']); // 获取标段已有期数
  280. if (isset($numCount['numpname'])) {
  281. $lastStatusArray = $this->numofperact->getMaxStatusTimes($value['pmid'], $numCount['numpname']);
  282. } else {
  283. $lastStatusArray['currstatus'] = 'uncheck';
  284. $numCount['numpname'] = 0;
  285. }
  286. $totalplus = $this->numofperact->getCountTotalplus($value['pmid']);
  287. $snTotal = $this->numofperact->getStopNowTotal($value['pmid']); //根据标段ID获取最新一期(包括不通过)
  288. $currcomTotal = $this->numofperact->getCurrdoneNew($value['pmid']); //截止目前
  289. $numStatusArray = $this->numofperact->getLastStatus2($this->params['pid'], $value['pmid']);
  290. if ($numCount > 0) {
  291. $nTotalProgress = number_format($snTotal['sntotal'], 2, '.', ',');
  292. $ncurrTotalProgress = number_format($currcomTotal['currtotal'], 2, '.', ',');
  293. $nlessTotalProgress = number_format($value['contracttotal'] - $snTotal['sntotal'] - $currcomTotal['currtotal'], 2, '.', ',');
  294. if (isset($value['contracttotal']) && ($value['contracttotal'] > 0)) {
  295. $snTotalProgress = round(($snTotal['sntotal'] / $value['contracttotal']) * 100);
  296. $currTotalProgress = round(($currcomTotal['currtotal'] / $value['contracttotal']) * 100);
  297. // $lessTotalProgress = round((($value['contracttotal'] - ($currcomTotal['currtotal'] + $snTotal['sntotal'])) / $value['contracttotal']) * 100);
  298. $lessTotalProgress = 100 - $snTotalProgress - $currTotalProgress;
  299. $displayPercentSnTotalProgress = $snTotalProgress . '%';
  300. $displayPercentCurrTotalProgress = $currTotalProgress . '%';
  301. $displayPercentLessTotalProgress = $lessTotalProgress . '%';
  302. }
  303. }
  304. $biaoduantotalmoney += $value['contracttotal'];
  305. $totalmoney = number_format($value['contracttotal'], 2, '.', ',');
  306. if (isset($numStatusArray['currstatus'])) {
  307. $statusStr = '(' . $this->statusArray[$lastStatusArray['currstatus']] . ')';
  308. } else {
  309. $statusStr = '';
  310. }
  311. $bdhtmlstr .= '
  312. <tr>
  313. <td><a href="/project/' . $this->params['pid'] . '/section/' . $value['pmid'] . '/detail">' . $value['pmname'] . '</a></td>
  314. <td class="">第 ' . $numCount['numpname'] . ' 期' . $statusStr . '</td>
  315. <td class="taR">¥' . $totalmoney . '</td>
  316. <td>
  317. <div class="progress">
  318. <div class="bar bar-success" style="width: ' . $displayPercentSnTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成:¥' . $nTotalProgress . '">' . $displayPercentSnTotalProgress . '</div>
  319. <div class="bar" style="width:' . $displayPercentCurrTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' . $ncurrTotalProgress . '">' . $displayPercentCurrTotalProgress . '</div>
  320. <div class="bar bar-gary" style="width:' . $displayPercentLessTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $nlessTotalProgress . '">' . $displayPercentLessTotalProgress . '</div>
  321. </div>
  322. </td>
  323. </tr>';
  324. }
  325. $nprogress = $notherprogress = NULL;
  326. // $currTotal = $this->numofperact->getCurrdoneSTID($v['stid']);
  327. if ($biaoduantotalmoney > 0) {
  328. $nprogress = number_format($currTotal['totalplus'], 2, '.', ',');
  329. $notherprogress = number_format($biaoduantotalmoney - $currTotal['totalplus'], 2, '.', ',');
  330. $progress = round(($currTotal['totalplus'] / $biaoduantotalmoney) * 100) . '%'; // 累计完成计量 所有标段合计
  331. $otherprogress = round((($biaoduantotalmoney - $currTotal['totalplus']) / $biaoduantotalmoney) * 100) . '%';
  332. $biaoduantotalmoney = number_format($biaoduantotalmoney, 2, '.', ',');
  333. }
  334. $htmlstr .= '<div class="project">
  335. <div class="proSection">
  336. <table class="table">
  337. <thead>
  338. <tr>
  339. <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>
  340. <td width="90">总价:</td><td width="165">¥<b style="font-size:16px">' . $biaoduantotalmoney . '</b></td>
  341. <td width="60">完成进度:</td><td><div class="progress">
  342. <div class="bar bar-success" style="width:' . $progress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="累计完成:¥' . $nprogress . '">' . $progress . '</div>
  343. <div class="bar bar-danger" style="width:' . $otherprogress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $notherprogress . '">' . $otherprogress . '</div>
  344. </div></td>
  345. </tr>
  346. </thead>
  347. </table>
  348. <table class="table table-striped table-hover tablelist">
  349. ' . $bdhtmlstr . '
  350. </tbody>
  351. </table>
  352. </div>
  353. </div>';
  354. }
  355. $this->data['htmlstr'] = $htmlstr;
  356. if (isset($_POST['secname']) && $_POST['secname']) {
  357. $this->contractact->insertContract($this->params['pid'], $this->auth->getUid(), $_POST['secname']);
  358. return Doo::conf()->APP_URL . 'project/' . $this->params['pid'] . '/section';
  359. }
  360. $this->data['pid'] = $this->params['pid'];
  361. $this->render('w-project-section', $this->data, TRUE);
  362. }
  363. function proSectionFiles()
  364. {
  365. if (isset($_POST['optype']) && ($_POST['optype'] == 'replace') && ($_POST['imnid'])) {
  366. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  367. if ($imnidArray['iaid'] > 0) {
  368. $fileArray = $this->upItemFile('file')[0];
  369. if (isset($fileArray['filepath'])) {
  370. $itemArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  371. if (isset($itemArray)) {
  372. if ($itemArray['oldiaid'] > 0) {
  373. $oldiaid = $itemArray['oldiaid'];
  374. } else {
  375. $oldiaid = $imnidArray['iaid'];
  376. }
  377. $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);
  378. $iaid = $this->itemfle->insertItemFileRecord($postArray);
  379. if ($iaid > 1) {
  380. $this->itemmeasurenum->updateIAID($imnidArray['iaid'], $iaid);
  381. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  382. die();
  383. }
  384. }
  385. }
  386. }
  387. }
  388. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  389. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  390. if ($imnidArray['iaid'] > 0) {
  391. $this->itemmeasurenum->updateDeltag($_POST['imnid'], $this->auth->getUid());
  392. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  393. die();
  394. }
  395. }
  396. if (isset($_POST['filename']) && isset($_POST['filedesc']) && isset($_POST['upimnid'])) {
  397. $filename = $_POST['filename'];
  398. $filedesc = $_POST['filedesc'];
  399. $imnidArray = $this->itemmeasurenum->getRowData($_POST['upimnid']);
  400. if ($imnidArray['iaid'] > 0) {
  401. if (isset($filedesc))
  402. $this->itemmeasurenum->updateItemFields($_POST['upimnid'], $filedesc, 0);
  403. if (isset($filename))
  404. $this->itemfle->updateItemFields($imnidArray['iaid'], $filename, 0);
  405. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  406. die();
  407. }
  408. }
  409. // 面包屑导航项目
  410. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  411. $this->data['pmid'] = $this->params['pmid'];
  412. $allproArray = $this->project->getAll();
  413. foreach ($allproArray as $kk => $vv) {
  414. if ($vv['pid'] == $this->params['pid']) {
  415. $this->data['currproArray'] = $vv;
  416. } else {
  417. $this->data['allproArray'][] = $vv;
  418. }
  419. }
  420. // 面包屑导航合同
  421. $conArray = $this->contractact->getAll();
  422. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  423. if (isset($measureArray['stid'])) {
  424. foreach ($conArray as $kkk => $vvv) {
  425. if ($vvv['stid'] == $measureArray['stid']) {
  426. $this->data['currconArray'] = $vvv;
  427. } else {
  428. if ($vvv['pid'] == $this->params['pid'])
  429. $this->data['allconArray'][] = $vvv;
  430. }
  431. }
  432. } else {
  433. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  434. }
  435. // 面包屑导航标段
  436. $this->data['curractmeasureArray'] = NULL;
  437. $this->data['allactmeasureArray'] = [];
  438. $actmeasureArray = $this->actmeasure->getAll();
  439. foreach ($actmeasureArray as $kkkk => $vvvv) {
  440. if ($vvvv['stid'] == $measureArray['stid']) {
  441. if (($vvvv['pmid'] == $this->params['pmid'])) {
  442. $this->data['curractmeasureArray'] = $vvvv;
  443. } else {
  444. $this->data['allactmeasureArray'][] = $vvvv;
  445. }
  446. }
  447. }
  448. // 选取查询
  449. $groupArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  450. $this->data['groupArray'] = $groupArray;
  451. $owneridArray = $this->itemfle->getGroupOwnerid($this->params['pmid']);
  452. foreach ($owneridArray as $k => $v) {
  453. $this->data['owneridArray'][$k]['name'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  454. $this->data['owneridArray'][$k]['iaid'] = $v['iaid'];
  455. $this->data['owneridArray'][$k]['ownerid'] = $v['ownerid'];
  456. }
  457. // 分页
  458. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid'], 0, $this->params['numpname'], $this->params['userid']);
  459. if ($totalArchive) {
  460. if ($this->params['numpname'] && $this->params['userid']) {
  461. $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);
  462. } elseif ($this->params['numpname']) {
  463. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/num/' . $this->params['numpname'] . '/page', $totalArchive, 20, 100);
  464. } elseif ($this->params['userid']) {
  465. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/user/' . $this->params['userid'] . '/page', $totalArchive, 20, 100);
  466. } else {
  467. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/page', $totalArchive, 20, 100);
  468. }
  469. $pager->setCss('', 'disabled', 'active');
  470. if (isset($this->params['pindex']))
  471. $pager->paginate(intval($this->params['pindex']));
  472. else
  473. $pager->paginate(1);
  474. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNum($this->params['pmid'], $pager->limit, $this->params['numpname'], $this->params['userid']);
  475. }
  476. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  477. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  478. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  479. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  480. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  481. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  482. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  483. }
  484. $this->data['pid'] = $this->params['pid'];
  485. $this->data['pmid'] = $this->params['pmid'];
  486. $this->data['mpid'] = $this->params['mpid'];
  487. $this->data['userid'] = $this->params['userid'];
  488. $this->data['num'] = $this->params['numpname'];
  489. $this->data['pager'] = $pager->output;
  490. $this->render('w-project-section-files', $this->data, TRUE);
  491. }
  492. function proSectionFilesRecover()
  493. {
  494. if (isset($_POST['optype']) && ($_POST['optype'] == 'reconvery') && isset($_POST['imnid'])) {
  495. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  496. if ($imnidArray['iaid'] > 0) {
  497. $this->itemmeasurenum->recoveryDel($_POST['imnid']);
  498. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  499. die();
  500. }
  501. }
  502. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  503. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  504. if ($imnidArray['iaid'] > 0) {
  505. $iaidArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  506. if ($iaidArray['ownerid'] == $this->auth->getUid()) {
  507. $this->itemfle->delItem($imnidArray['iaid']);
  508. $this->itemmeasurenum->delItemIAID($imnidArray['iaid']);
  509. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  510. die();
  511. } else {
  512. echo json_encode(array('status' => 2), JSON_UNESCAPED_UNICODE);
  513. die();
  514. }
  515. }
  516. }
  517. // 面包屑导航项目
  518. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  519. $this->data['pmid'] = $this->params['pmid'];
  520. $allproArray = $this->project->getAll();
  521. foreach ($allproArray as $kk => $vv) {
  522. if ($vv['pid'] == $this->params['pid']) {
  523. $this->data['currproArray'] = $vv;
  524. } else {
  525. $this->data['allproArray'][] = $vv;
  526. }
  527. }
  528. // 面包屑导航合同
  529. $conArray = $this->contractact->getAll();
  530. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  531. if (isset($measureArray['stid'])) {
  532. foreach ($conArray as $kkk => $vvv) {
  533. if ($vvv['stid'] == $measureArray['stid']) {
  534. $this->data['currconArray'] = $vvv;
  535. } else {
  536. if ($vvv['pid'] == $this->params['pid'])
  537. $this->data['allconArray'][] = $vvv;
  538. }
  539. }
  540. } else {
  541. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  542. }
  543. // 面包屑导航标段
  544. $this->data['curractmeasureArray'] = NULL;
  545. $this->data['allactmeasureArray'] = [];
  546. $actmeasureArray = $this->actmeasure->getAll();
  547. foreach ($actmeasureArray as $kkkk => $vvvv) {
  548. if ($vvvv['stid'] == $measureArray['stid']) {
  549. if (($vvvv['pmid'] == $this->params['pmid'])) {
  550. $this->data['curractmeasureArray'] = $vvvv;
  551. } else {
  552. $this->data['allactmeasureArray'][] = $vvvv;
  553. }
  554. }
  555. }
  556. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid']);
  557. if ($totalArchive) {
  558. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/recover/page', $totalArchive, 20, 100);
  559. $pager->setCss('', 'disabled', 'active');
  560. if (isset($this->params['pindex']))
  561. $pager->paginate(intval($this->params['pindex']));
  562. else
  563. $pager->paginate(1);
  564. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNumDel($pager->limit, $this->params['pmid']);
  565. }
  566. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  567. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  568. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  569. $this->data['itemMeasureArray'][$k]['delname'] = $this->profile->getProWithUid($v['deluid'])['name'];
  570. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  571. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  572. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  573. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  574. $this->data['itemMeasureArray'][$k]['filepath'] = $fileArray['filepath'];
  575. }
  576. $this->data['pid'] = $this->params['pid'];
  577. $this->data['pmid'] = $this->params['pmid'];
  578. $this->data['mpid'] = $this->params['mpid'];
  579. $this->data['pager'] = $pager->output;
  580. $this->render('w-project-section-files-recover', $this->data, TRUE);
  581. }
  582. /**
  583. * @return actMeasure
  584. */
  585. public function proSectionGetFiles()
  586. {
  587. $attaArray = $this->itemfle->getItemFile($this->params['iaid']);
  588. $this->file_down($attaArray['filepath'], $attaArray['filesize'], $attaArray['filename'] . '.' . $attaArray['fileext']);
  589. return;
  590. }
  591. function getItemFileHistory()
  592. {
  593. if ($this->params['iaid']) {
  594. $iaidArray = $this->itemfle->getItemFile($this->params['iaid']);
  595. if ($iaidArray['oldiaid'] > 0) {
  596. $oldiaidArray = $this->itemfle->getFileHistory($iaidArray['oldiaid']);
  597. $htmlstr = '';
  598. foreach ($oldiaidArray as $k => $v) {
  599. $countInt = $k + 1;
  600. $formatDate = date('Y-m-d H:i:s', $v['intime']);
  601. $profileArray = $this->profile->getProWithUid($v['ownerid']);
  602. $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>';
  603. }
  604. echo json_encode(array('html' => $htmlstr), JSON_UNESCAPED_UNICODE);
  605. die();
  606. }
  607. }
  608. }
  609. Function fNumber($number)
  610. {
  611. if ($number == '')
  612. Return "-";
  613. $nlen = strlen($number);
  614. while ($nlen > 3) {
  615. $fNumber = "," . substr($number, $nlen - 3, 3);
  616. $number = substr($number, 0, -3);
  617. $nlen = strlen($number);
  618. }
  619. if ($nlen <= 3) {
  620. $fNumber = $number . $fNumber;
  621. }
  622. Return $fNumber;
  623. }
  624. private function getFav()
  625. {
  626. $proArray = $this->project->getAll($this->auth->getUid());
  627. $this->data['othrPro'] = [];
  628. foreach ($proArray as $key => $value) {
  629. if ($value['pid'] == $this->params['pid']) {
  630. $this->data['currProName'] = $value['pname'];
  631. $this->data['currProID'] = $value['pid'];
  632. } else {
  633. $this->data['othrPro'][] = $proArray[$key];
  634. }
  635. }
  636. }
  637. public function proSectionMeasure()
  638. {
  639. //此处未做更改,JSON文件已经固定名称
  640. $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  641. if (isset($jsonpath['dirname'])) {
  642. $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  643. if ($handle = opendir($extPathdir)) {
  644. while (false !== ($file = readdir($handle))) {
  645. $filename = NULL;
  646. $filename = pathinfo($file);
  647. if ($filename['extension'] == 'json')
  648. $proArray = json_decode(file_get_contents($extPathdir . '/' . $file), TRUE, JSON_UNESCAPED_UNICODE);
  649. }
  650. closedir($handle);
  651. }
  652. $this->data['proArray'] = $proArray['Bills'];
  653. } else {
  654. $this->data['proArray'] = [];
  655. }
  656. $this->data['mpid'] = $this->params['mpid'];
  657. $this->data['pid'] = $this->params['pid'];
  658. $this->render('w-project-section-measure', $this->data, TRUE);
  659. }
  660. public function substr_replace_cn($string, $repalce = '*', $start = 0, $len = 0)
  661. {
  662. $count = mb_strlen($string, 'UTF-8'); //此处传入编码,建议使用utf-8。此处编码要与下面mb_substr()所使用的一致
  663. if (!$count) {
  664. return $string;
  665. }
  666. if ($len == 0) {
  667. $end = $count; //传入0则替换到最后
  668. } else {
  669. $end = $start + $len; //传入指定长度则为开始长度+指定长度
  670. }
  671. $i = 0;
  672. $returnString = '';
  673. while ($i < $count) { //循环该字符串
  674. $tmpString = mb_substr($string, $i, 1, 'UTF-8'); // 与mb_strlen编码一致
  675. if ($start <= $i && $i < $end) {
  676. $returnString .= $repalce;
  677. } else {
  678. $returnString .= $tmpString;
  679. }
  680. $i++;
  681. }
  682. return $returnString;
  683. }
  684. function unicode_encode($name)
  685. {//to Unicode
  686. $name = iconv('UTF-8', 'UCS-2', $name);
  687. $len = strlen($name);
  688. $str = '';
  689. for ($i = 0; $i < $len - 1; $i = $i + 2) {
  690. $c = $name[$i];
  691. $c2 = $name[$i + 1];
  692. if (ord($c) > 0) {// 两个字节的字
  693. $str .= '\\' . base_convert(ord($c), 10, 16) . base_convert(ord($c2), 10, 16);
  694. } else {
  695. $str .= $c2;
  696. }
  697. }
  698. $str = strtoupper($str);
  699. return $str;
  700. }
  701. function unicode_decode($name)
  702. {//Unicode to
  703. $pattern = '/([\w]+)|(\\\u([\w]{4}))/i';
  704. preg_match_all($pattern, $name, $matches);
  705. if (!empty($matches)) {
  706. $name = '';
  707. for ($j = 0; $j < count($matches[0]); $j++) {
  708. $str = $matches[0][$j];
  709. if (strpos($str, '\\u') === 0) {
  710. $code = base_convert(substr($str, 2, 2), 16, 10);
  711. $code2 = base_convert(substr($str, 4), 16, 10);
  712. $c = chr($code) . chr($code2);
  713. $c = iconv('UCS-2', 'UTF-8', $c);
  714. $name .= $c;
  715. } else {
  716. $name .= $str;
  717. }
  718. }
  719. }
  720. return $name;
  721. }
  722. public function proDetail()
  723. {
  724. // 面包屑导航项目
  725. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  726. $this->data['pmid'] = $this->params['pmid'];
  727. $allproArray = $this->project->getAll();
  728. foreach ($allproArray as $kk => $vv) {
  729. if ($vv['pid'] == $this->params['pid']) {
  730. $this->data['currproArray'] = $vv;
  731. } else {
  732. $this->data['allproArray'][] = $vv;
  733. }
  734. }
  735. // 面包屑导航合同
  736. $conArray = $this->contractact->getAll();
  737. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  738. if (isset($measureArray['stid'])) {
  739. foreach ($conArray as $kkk => $vvv) {
  740. if ($vvv['stid'] == $measureArray['stid']) {
  741. $this->data['currconArray'] = $vvv;
  742. } else {
  743. if ($vvv['pid'] == $this->params['pid'])
  744. $this->data['allconArray'][] = $vvv;
  745. }
  746. }
  747. } else {
  748. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  749. }
  750. // 面包屑导航标段
  751. $this->data['curractmeasureArray'] = NULL;
  752. $this->data['allactmeasureArray'] = [];
  753. $actmeasureArray = $this->actmeasure->getAll();
  754. foreach ($actmeasureArray as $kkkk => $vvvv) {
  755. if ($vvvv['stid'] == $measureArray['stid']) {
  756. if (($vvvv['pmid'] == $this->params['pmid'])) {
  757. $this->data['curractmeasureArray'] = $vvvv;
  758. } else {
  759. $this->data['allactmeasureArray'][] = $vvvv;
  760. }
  761. }
  762. }
  763. // 图表
  764. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  765. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  766. foreach ($this->data['MeasureArray'] as $key => $value) {
  767. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  768. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  769. } else {
  770. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  771. }
  772. }
  773. $this->data['pmid'] = $this->params['pmid'];
  774. $this->data['pid'] = $this->params['pid'];
  775. $this->render('w-project-section-detail', $this->data, TRUE);
  776. }
  777. public function welcome()
  778. {
  779. // if (!$this->auth->isLoggedIn())
  780. // return Doo::conf()->APP_URL;
  781. if ($this->profile->getProWithUid($this->auth->getUid())['userid'])
  782. return Doo::conf()->APP_URL . 'project/list';
  783. if (isset($_POST['welform'])) {
  784. $profileUserArray = $_POST;
  785. $profileUserArray['userid'] = $this->auth->getUid();
  786. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  787. return Doo::conf()->APP_URL . 'project/list';
  788. }
  789. $this->render('welcome', $this->data);
  790. }
  791. // ajax提取密码名称
  792. public function getAjaxSection()
  793. {
  794. if (!$this->isAjax())
  795. return;
  796. echo json_encode($_POST);
  797. }
  798. function upItemFile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  799. {
  800. $this->att->setUploadDir();
  801. return $this->att->uploadMut($fildname, $param);
  802. }
  803. /**
  804. * 文件下载
  805. * @param $filepath 文件路径
  806. * @param $filename 文件名称
  807. */
  808. function file_down($filepath, $filesize, $filename = '')
  809. {
  810. if (!$filename)
  811. $filename = basename($filepath);
  812. if ($this->is_ie())
  813. $filename = rawurlencode($filename);
  814. $filetype = $this->fileext($filename);
  815. // $filesize = sprintf("%u", filesize($filepath));
  816. if (ob_get_length() !== false)
  817. @ob_end_clean();
  818. header('Pragma: public');
  819. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  820. header('Cache-Control: no-store, no-cache, must-revalidate');
  821. header('Cache-Control: pre-check=0, post-check=0, max-age=0');
  822. header('Content-Transfer-Encoding: binary');
  823. header('Content-Encoding: none');
  824. header('Content-type: ' . $filetype);
  825. header('Content-Disposition: attachment; filename="' . $filename . '"');
  826. header('Content-length: ' . $filesize);
  827. @readfile($filepath);
  828. exit;
  829. }
  830. /**
  831. * IE浏览器判断
  832. */
  833. function is_ie()
  834. {
  835. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  836. if ((strpos($useragent, 'opera') !== false) || (strpos($useragent, 'konqueror') !== false))
  837. return false;
  838. if (strpos($useragent, 'msie ') !== false)
  839. return true;
  840. return false;
  841. }
  842. /**
  843. * 取得文件扩展
  844. *
  845. * @param $filename 文件名
  846. * @return 扩展名
  847. */
  848. function fileext($filename)
  849. {
  850. return strtolower(trim(substr(strrchr($filename, '.'), 1, 10)));
  851. }
  852. }
  853. ?>