ProjectController.php 41 KB

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