ProjectController.php 52 KB

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