ProjectController.php 50 KB

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