ProjectController.php 41 KB

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