ProjectController.php 41 KB

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