ProjectController.php 53 KB

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