ProjectController.php 52 KB

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