ProjectController.php 42 KB

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