ShareController.php 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. <?php
  2. Doo::loadClass('shareact');
  3. Doo::loadClass('contractact');
  4. Doo::loadClass('actmeasure');
  5. Doo::loadClass('project');
  6. Doo::loadClass('numofperact');
  7. /**
  8. * MainController
  9. * Feel free to delete the methods and replace them with your own code.
  10. *
  11. * @author darkredz
  12. */
  13. class ShareController extends DooController
  14. {
  15. private $__shareact, $__contractact, $__actMeasure, $__pro, $__numofperact, $statusArray = array('uncheck' => '<span class = "colGray">未上报</span>', 'checking' => '<span class = "colOrange">审核中</span>', 'checked' => '<span class = "colGreen">已完成</span>', 'checkno' => '<span class = "colRed">不通过</span>');
  16. // public function beforeRun($resource, $action) {
  17. // if ($this->auth->getUid()) {
  18. // $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  19. // $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  20. // if (!$falg)
  21. // return Doo::acl()->defaultFailedRoute;
  22. // }else {
  23. // return Doo::acl()->defaultFailedRoute;
  24. // }
  25. // }
  26. public function __construct()
  27. {
  28. $this->__shareact = new Shareact();
  29. $this->__contractact = new Contractact();
  30. $this->__actMeasure = new actMeasure();
  31. $this->__pro = new Project();
  32. $this->__numofperact = new NumofperAct();
  33. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  34. // $this->data['user'] = $this->profile->getProWithUid($this->auth->getUid());
  35. }
  36. public function error()
  37. {
  38. $this->render('w-share-erro', $this->data, TRUE);
  39. }
  40. public function project()
  41. {
  42. $shareRowArray = $this->__shareact->getOne($this->params['hashcode']);
  43. if (!isset($shareRowArray['ids']) || !isset($shareRowArray['idtype']) || $shareRowArray['idtype'] != 1) {
  44. return Doo::conf()->APP_URL . 'share/error';
  45. }
  46. $this->data['hashcode'] = $this->params['hashcode'];
  47. if ($shareRowArray['ids'] > 0) {
  48. $proArray = $this->__pro->getRowByPid($shareRowArray['ids']);
  49. }
  50. // 总价
  51. if ($shareRowArray['ids']) {
  52. $this->data['pros']['numMeasure'] = $this->__actMeasure->getMearsureCount($shareRowArray['ids']);
  53. $this->data['pros']['contracttotal'] = $this->__actMeasure->getTotalWithPid($shareRowArray['ids']);
  54. $this->data['pros']['changTotal'] = $this->__numofperact->getChangTotal($shareRowArray['ids']);
  55. $this->data['pros']['currdone'] = $this->__numofperact->getCurrDoneNow($shareRowArray['ids']);
  56. if ($this->data['pros']['contracttotal']) {
  57. $this->data['pros']['pcurrdone'] = round(($this->data['pros']['currdone'] / $this->data['pros']['contracttotal']) * 100) . '%';
  58. } else {
  59. $this->data['pros']['pcurrdone'] = '0%';
  60. }
  61. $this->data['pros']['bcontracttotal'] = number_format($this->data['pros']['contracttotal'], 2, '.', ',');
  62. $this->data['pros']['bchangTotal'] = number_format($this->data['pros']['changTotal'], 2, '.', ',');
  63. } else {
  64. $this->data['pros'] = [];
  65. }
  66. // 标段计量分布
  67. $conArray = $this->__contractact->getRowByPid($shareRowArray['ids']);
  68. $this->data['projectDate'] = '';
  69. $this->data['conArray'][] = array();
  70. $this->data['pid'] = $shareRowArray['ids'];
  71. $this->data['conArray'] = $conArray;
  72. $contracttotal = 0;
  73. $totalstid = 0;
  74. $monthArray = [];
  75. $allmonth = [];
  76. $allmonth1 = [];
  77. foreach ($this->data['conArray'] as $k => $v) {
  78. $this->data['conArray'][$k]['pstopnow'] = $this->data['conArray'][$k]['pscurrdone'] = 0;
  79. $retval = $this->__actMeasure->getAllbyStidSum($v['stid']);
  80. $contracttotal += $retval[0]['contracttotal'];
  81. $totalstid += $this->__actMeasure->getTotal($v['stid'])['total'];
  82. $total = $this->__actMeasure->getTotal($v['stid'])['total'];
  83. if ($total) {
  84. $this->data['conArray'][$k]['total'] = round($total, 2);
  85. } else {
  86. $this->data['conArray'][$k]['total'] = 0;
  87. }
  88. $sntotal = $this->__numofperact->getCountTotalSTID2($v['stid'])['totalplus'];
  89. if ($sntotal) {
  90. $this->data['conArray'][$k]['stopnow'] = round($sntotal, 2);
  91. } else {
  92. $this->data['conArray'][$k]['stopnow'] = 0;
  93. }
  94. $this->data['conArray'][$k]['currdone'] = $this->__numofperact->getCurrDoneSt($v['stid'])['currdone'];
  95. if ($this->data['conArray'][$k]['total'] > 0) {
  96. $this->data['conArray'][$k]['pstopnow'] = round(($this->data['conArray'][$k]['stopnow'] / $this->data['conArray'][$k]['total']) * 100);
  97. $this->data['conArray'][$k]['pscurrdone'] = round(($this->data['conArray'][$k]['currdone'] / $this->data['conArray'][$k]['total']) * 100);
  98. }
  99. // 分组出年月 每个月份的独立相加
  100. $month = $this->__numofperact->getCurrTotalStMonthNoCheckno($v['stid']);
  101. foreach ($month as $key => $value) {
  102. $allmonth[] = $value;
  103. if (!in_array($value['month'], $monthArray))
  104. $monthArray[] = $value['month'];
  105. }
  106. // 分组出年月 每个月份的独立相加
  107. $month1 = $this->__numofperact->getCurrDoneStMonthNoCheckno($v['stid']);
  108. foreach ($month1 as $key => $value) {
  109. $allmonth1[] = $value;
  110. }
  111. }
  112. // 中文表述年月
  113. $total = $total1 = array();
  114. $startyear = $cnymArray = array();
  115. foreach ($monthArray as $kk => $vv) {
  116. // foreach ($allmonth as $keyk => $valuev) {
  117. // if ($valuev['month'] == $vv)
  118. // $total[$kk] += $valuev['currtotal'];
  119. // }
  120. // foreach ($allmonth1 as $k1 => $v1) {
  121. // if ($v1['month'] == $vv)
  122. // $total1[$kk] += $v1['currdone'];
  123. // }
  124. // $ymarray = split('-', $vv);
  125. $ymarray = explode('-', $vv);
  126. if (!in_array($ymarray[0], $startyear))
  127. $startyear[] = $ymarray[0];
  128. // $cnym = '\'' . $ymarray[1] . '月' . '\'';
  129. // if ($kk == 0)
  130. // $cnym = '\'' . $ymarray[0] . '年' . $ymarray[1] . '月' . '\'';
  131. // $cnymArray[] = $cnym;
  132. }
  133. $thismonth = 0;
  134. foreach($startyear as $sk => $sv){
  135. for($i = 1; $i <= 12; $i++){
  136. $j = $i < 10 ? '0'.$i : $i;
  137. $month = $sv.'-'.$j;
  138. $thismonth1 = 0;
  139. foreach ($allmonth as $keyk => $valuev) {
  140. if ($valuev['month'] == $month)
  141. $thismonth += $valuev['currtotal'];
  142. }
  143. $total[] = $thismonth != 0 ? $thismonth : 0;
  144. foreach ($allmonth1 as $k1 => $v1) {
  145. if ($v1['month'] == $month)
  146. $thismonth1 += $v1['currdone'];
  147. }
  148. $total1[] = $thismonth1 != 0 ? $thismonth1 : 0;
  149. $cnymArray[] = $i == 1 ? '\'' .$sv.'年'.$i.'月'. '\'' : '\'' .$i.'月'. '\'';
  150. }
  151. }
  152. foreach ($total as $value2) {
  153. $total3[] = round(($value2 / $totalstid) * 100);
  154. }
  155. foreach ($total1 as $value11) {
  156. $total4[] = round(($value11 / $totalstid) * 100);
  157. }
  158. $this->data['projectDate'] = implode(',', $cnymArray);
  159. $this->data['t1'] = implode(',', $total3);
  160. $this->data['t2'] = implode(',', $total4);
  161. // 标段计量进度
  162. // 项目按月进度
  163. // 标段列表
  164. $contractArray = $this->__contractact->getRowByPid($shareRowArray['ids']); // 获取合同段
  165. $htmlstr = NULL;
  166. foreach ($contractArray as $k => $v) {// 获取所有合同段
  167. $retval = $this->__actMeasure->getAllbyStid($v['stid']); // 获取标段
  168. $bdhtmlstr = NULL;
  169. $bdhtmlstr = '<thead>
  170. <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>
  171. <tbody>';
  172. $biaoduantotalmoney = 0;
  173. $currTotal = 0;
  174. $progress = $otherprogress = '0%';
  175. $currTotal = $this->__numofperact->getCountTotalSTID2($v['stid']);
  176. foreach ($retval as $key => $value) {
  177. $displayPercentSnTotalProgress = '0%';
  178. $displayPercentCurrTotalProgress = '0%';
  179. $displayPercentLessTotalProgress = '0%';
  180. $snTotalProgress = $currTotalProgress = $lessTotalProgress = '0%';
  181. $nTotalProgress = $ncurrTotalProgress = $nlessTotalProgress = number_format(0, 2, '.', ',');
  182. $numCount = $this->__numofperact->getCountTotalnum2($value['pmid']); // 获取标段已有期数
  183. if (isset($numCount['numpname'])) {
  184. $lastStatusArray = $this->__numofperact->getMaxStatusTimes($value['pmid'], $numCount['numpname']);
  185. } else {
  186. $lastStatusArray['currstatus'] = 'uncheck';
  187. $numCount['numpname'] = 0;
  188. }
  189. $totalplus = $this->__numofperact->getCountTotalplus($value['pmid']);
  190. $snTotal = $this->__numofperact->getStopNowTotal($value['pmid']); //根据标段ID获取最新一期(包括不通过)
  191. $currcomTotal = $this->__numofperact->getCurrdoneNew($value['pmid']); //截止目前
  192. $numStatusArray = $this->__numofperact->getLastStatus2($shareRowArray['ids'], $value['pmid']);
  193. if ($numCount > 0) {
  194. $nTotalProgress = number_format($snTotal['sntotal'], 2, '.', ',');
  195. $ncurrTotalProgress = number_format($currcomTotal['currtotal'], 2, '.', ',');
  196. $nlessTotalProgress = number_format($value['contracttotal'] - $snTotal['sntotal'] - $currcomTotal['currtotal'], 2, '.', ',');
  197. if (isset($value['contracttotal']) && ($value['contracttotal'] > 0)) {
  198. $snTotalProgress = round(($snTotal['sntotal'] / $value['contracttotal']) * 100);
  199. $currTotalProgress = round(($currcomTotal['currtotal'] / $value['contracttotal']) * 100);
  200. // $lessTotalProgress = round((($value['contracttotal'] - ($currcomTotal['currtotal'] + $snTotal['sntotal'])) / $value['contracttotal']) * 100);
  201. $lessTotalProgress = 100 - $snTotalProgress - $currTotalProgress;
  202. $displayPercentSnTotalProgress = $snTotalProgress . '%';
  203. $displayPercentCurrTotalProgress = $currTotalProgress . '%';
  204. $displayPercentLessTotalProgress = $lessTotalProgress . '%';
  205. }
  206. }
  207. $biaoduantotalmoney += $value['contracttotal'];
  208. $totalmoney = number_format($value['contracttotal'], 2, '.', ',');
  209. if (isset($numStatusArray['currstatus'])) {
  210. $statusStr = $this->statusArray[$lastStatusArray['currstatus']];
  211. } else {
  212. $statusStr = '';
  213. }
  214. $bdhtmlstr .= '
  215. <tr>
  216. <td><a href="/share/project/tender/' . $value['pmid'] . '/' . $this->params['hashcode'] . '">' . $value['pmname'] . '</a></td>
  217. <td class="">共 ' . $numCount['numpname'] . ' 期(本期 ' . $statusStr . ')</td>
  218. <td class="taR">¥' . $totalmoney . '</td>
  219. <td>
  220. <div class="progress">
  221. <div class="bar bar-success" style="width: ' . $displayPercentSnTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成:¥' . $nTotalProgress . '">' . $displayPercentSnTotalProgress . '</div>
  222. <div class="bar" style="width:' . $displayPercentCurrTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' . $ncurrTotalProgress . '">' . $displayPercentCurrTotalProgress . '</div>
  223. <div class="bar bar-gary" style="width:' . $displayPercentLessTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $nlessTotalProgress . '">' . $displayPercentLessTotalProgress . '</div>
  224. </div>
  225. </td>
  226. </tr>';
  227. }
  228. $nprogress = $notherprogress = NULL;
  229. // $currTotal = $this->numofperact->getCurrdoneSTID($v['stid']);
  230. if ($biaoduantotalmoney > 0) {
  231. $nprogress = number_format($currTotal['totalplus'], 2, '.', ',');
  232. $notherprogress = number_format($biaoduantotalmoney - $currTotal['totalplus'], 2, '.', ',');
  233. $progress = round(($currTotal['totalplus'] / $biaoduantotalmoney) * 100) . '%'; // 累计完成计量 所有标段合计
  234. $otherprogress = round((($biaoduantotalmoney - $currTotal['totalplus']) / $biaoduantotalmoney) * 100) . '%';
  235. $biaoduantotalmoney = number_format($biaoduantotalmoney, 2, '.', ',');
  236. }
  237. $htmlstr .= '<div class="project">
  238. <div class="proSection">
  239. <table class="table">
  240. <thead>
  241. <tr>
  242. <td width="150"><span aria-hidden="true" data-icon="u"></span> ' . $v['stname'] . '<a id="idt_' . $v['stid'] . '" href="#secoption" data-toggle="modal" title="编辑/查看KEY" stid="' . $v['stid'] . '" proname="' . $v['stname'] . '" key="' . $v['stkey'] . '"><span data-icon="S" aria-hidden="true" class="closePanel" data-placement="bottom" data-toggle="tooltip" data-original-title="查看KEY" style="font-size:18px"></span></a></td>
  243. <td width="90">总价:</td><td width="165">¥<b style="font-size:16px">' . $biaoduantotalmoney . '</b></td>
  244. <td width="60">完成进度:</td><td><div class="progress">
  245. <div class="bar bar-success" style="width:' . $progress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="累计完成:¥' . $nprogress . '">' . $progress . '</div>
  246. <div class="bar bar-danger" style="width:' . $otherprogress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $notherprogress . '">' . $otherprogress . '</div>
  247. </div></td>
  248. </tr>
  249. </thead>
  250. </table>
  251. <table class="table table-striped table-hover tablelist">
  252. ' . $bdhtmlstr . '
  253. </tbody>
  254. </table>
  255. </div>
  256. </div>';
  257. }
  258. $this->data['htmlstr'] = $htmlstr;
  259. $this->data['pname'] = $proArray['pname'];
  260. $this->render('w-share-project', $this->data);
  261. }
  262. public function proTender()
  263. {
  264. $shareRowArray = $this->__shareact->getOne($this->params['hashcode']);
  265. if (!isset($shareRowArray['ids']) || !isset($shareRowArray['idtype']) || $shareRowArray['idtype'] != 1) {
  266. return Doo::conf()->APP_URL . 'share/error';
  267. }
  268. // 判断有效性
  269. // 判断hashcode有效性
  270. // 判断标段ID是否属于当前分享父类ID
  271. // 总价
  272. $mArray = $this->__actMeasure->getRowByPmid($this->params['tenderid']);
  273. if(empty($mArray)){
  274. return Doo::conf()->APP_URL . 'share/error';
  275. }
  276. $proArray = $mArray;
  277. //来源url
  278. $this->data['comefromurl'] = Doo::conf()->APP_URL.'share/project/'.$this->params['hashcode'];
  279. $this->data['pmname'] = $mArray['pmname'];
  280. if ($proArray['pid']) {
  281. $this->data['pros']['numMeasure'] = $this->__actMeasure->getMearsureCount($proArray['pid']);
  282. $this->data['pros']['contracttotal'] = $this->__actMeasure->getTotalWithPid($proArray['pid']);
  283. $this->data['pros']['changTotal'] = $this->__numofperact->getChangTotal($proArray['pid']);
  284. $this->data['pros']['currdone'] = $this->__numofperact->getCurrDoneNow($proArray['pid']);
  285. if ($this->data['pros']['contracttotal']) {
  286. $this->data['pros']['pcurrdone'] = round(($this->data['pros']['currdone'] / $this->data['pros']['contracttotal']) * 100) . '%';
  287. } else {
  288. $this->data['pros']['pcurrdone'] = '0%';
  289. }
  290. $this->data['pros']['bcontracttotal'] = number_format($this->data['pros']['contracttotal'], 2, '.', ',');
  291. $this->data['pros']['bchangTotal'] = number_format($this->data['pros']['changTotal'], 2, '.', ',');
  292. } else {
  293. $this->data['pros'] = [];
  294. }
  295. // 图表
  296. $this->data['MeasureArray'] = $this->__numofperact->getGroupByLastOne($this->params['tenderid']);
  297. $this->data['totalnum'] = count($this->data['MeasureArray']);
  298. $measureArray = $this->__actMeasure->getRowByPmid($this->params['tenderid']);
  299. foreach ($this->data['MeasureArray'] as $key => $value) {
  300. $lastStatusArray = $this->__numofperact->getMaxStatusTimes($value['pmid'], $value['numpname']);
  301. $this->data['status'] = $this->statusArray[$lastStatusArray['currstatus']];
  302. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  303. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  304. } else {
  305. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  306. }
  307. }
  308. $this->render('w-share-project-section-detail', $this->data, TRUE);
  309. }
  310. public function section()
  311. {
  312. $shareRowArray = $this->__shareact->getOne($this->params['hashcode']);
  313. if (!isset($shareRowArray['ids']) || !isset($shareRowArray['idtype']) || $shareRowArray['idtype'] != 2) {
  314. return Doo::conf()->APP_URL . 'share/error';
  315. }
  316. $this->data['hashcode'] = $this->params['hashcode'];
  317. $conArray = $this->__contractact->getRowByStid($shareRowArray['ids']);
  318. if(empty($conArray)){
  319. return Doo::conf()->APP_URL . 'share/error';
  320. }
  321. $this->data['secname'] = $conArray['stname'];
  322. $biaoduantotalmoney = 0;
  323. $retval = $this->__actMeasure->getAllbyStid($shareRowArray['ids']); // 获取标段
  324. $totalretval = $this->__actMeasure->getTotal($shareRowArray['ids']); //获取标段总价格
  325. $currTotal = $this->__numofperact->getCountTotalSTID2($shareRowArray['ids']);
  326. $this->data['stidArray'] = $retval;
  327. $totalstid = $totalretval['total'];
  328. $contracttotal = 0;
  329. $monthArray = [];
  330. foreach ($this->data['stidArray'] as $k => $v) {
  331. //获取标段类型总价
  332. $biaoduantotalmoney += $v['contracttotal'];
  333. // 分组出年月 每个月份的独立相加
  334. $month = $this->__numofperact->getCurrTotalPmMonth($v['pmid']);
  335. foreach ($month as $key => $value) {
  336. $allmonth[] = $value;
  337. if (!in_array($value['month'], $monthArray))
  338. $monthArray[] = $value['month'];
  339. }
  340. // 分组出年月 每个月份的独立相加
  341. $month1 = $this->__numofperact->getCurrDonePmMonth($v['pmid']);
  342. foreach ($month1 as $key => $value) {
  343. $allmonth1[] = $value;
  344. }
  345. $displayPercentSnTotalProgress = '0%';
  346. $displayPercentCurrTotalProgress = '0%';
  347. $displayPercentLessTotalProgress = '0%';
  348. $snTotalProgress = $currTotalProgress = $lessTotalProgress = '0%';
  349. $nTotalProgress = $ncurrTotalProgress = $nlessTotalProgress = number_format(0, 2, '.', ',');
  350. $numCount = $this->__numofperact->getCountTotalnum2($v['pmid']); // 获取标段已有期数
  351. if (isset($numCount['numpname'])) {
  352. $lastStatusArray = $this->__numofperact->getMaxStatusTimes($v['pmid'], $numCount['numpname']);
  353. } else {
  354. $lastStatusArray['currstatus'] = 'uncheck';
  355. $numCount['numpname'] = 0;
  356. }
  357. $this->data['stidArray'][$k]['qi'] = $numCount['numpname'];
  358. $numStatusArray = $this->__numofperact->getLastStatus2($v['pid'], $v['pmid']);
  359. if (isset($numStatusArray['currstatus'])) {
  360. $statusStr = $this->statusArray[$lastStatusArray['currstatus']];
  361. } else {
  362. $statusStr = '';
  363. }
  364. $this->data['stidArray'][$k]['statusStr'] = $statusStr;
  365. $this->data['stidArray'][$k]['totalmoney'] = number_format($v['contracttotal'], 2, '.', ',');
  366. $totalplus = $this->__numofperact->getCountTotalplus($v['pmid']);
  367. $snTotal = $this->__numofperact->getStopNowTotal($v['pmid']); //根据标段ID获取最新一期(包括不通过)
  368. $currcomTotal = $this->__numofperact->getCurrdoneNew($v['pmid']); //截止目前
  369. $numStatusArray = $this->__numofperact->getLastStatus2($v['pid'], $v['pmid']);
  370. if ($numCount > 0) {
  371. $this->data['stidArray'][$k]['nTotalProgress'] = number_format($snTotal['sntotal'], 2, '.', ',');
  372. $this->data['stidArray'][$k]['ncurrTotalProgress'] = number_format($currcomTotal['currtotal'], 2, '.', ',');
  373. $this->data['stidArray'][$k]['nlessTotalProgress'] = number_format($v['contracttotal'] - $snTotal['sntotal'] - $currcomTotal['currtotal'], 2, '.', ',');
  374. if (isset($v['contracttotal']) && ($v['contracttotal'] > 0)) {
  375. $snTotalProgress = round(($snTotal['sntotal'] / $v['contracttotal']) * 100);
  376. $currTotalProgress = round(($currcomTotal['currtotal'] / $v['contracttotal']) * 100);
  377. // $lessTotalProgress = round((($value['contracttotal'] - ($currcomTotal['currtotal'] + $snTotal['sntotal'])) / $value['contracttotal']) * 100);
  378. $lessTotalProgress = 100 - $snTotalProgress - $currTotalProgress;
  379. $this->data['stidArray'][$k]['displayPercentSnTotalProgress'] = $snTotalProgress . '%';
  380. $this->data['stidArray'][$k]['displayPercentCurrTotalProgress'] = $currTotalProgress . '%';
  381. $this->data['stidArray'][$k]['displayPercentLessTotalProgress'] = $lessTotalProgress . '%';
  382. }
  383. }
  384. }
  385. if ($biaoduantotalmoney > 0) {
  386. $this->data['st']['nprogress'] = number_format($currTotal['totalplus'], 2, '.', ',');
  387. $this->data['st']['notherprogress'] = number_format($biaoduantotalmoney - $currTotal['totalplus'], 2, '.', ',');
  388. $this->data['st']['progress'] = round(($currTotal['totalplus'] / $biaoduantotalmoney) * 100) . '%'; // 累计完成计量 所有标段合计
  389. $this->data['st']['otherprogress'] = round((($biaoduantotalmoney - $currTotal['totalplus']) / $biaoduantotalmoney) * 100) . '%';
  390. $this->data['st']['bcontracttotal'] = number_format($biaoduantotalmoney, 2, '.', ',');
  391. }
  392. // 中文表述年月
  393. $total = $total1 = array();
  394. foreach ($monthArray as $kk => $vv) {
  395. foreach ($allmonth as $keyk => $valuev) {
  396. if ($valuev['month'] == $vv)
  397. $total[$kk] += $valuev['currtotal'];
  398. }
  399. foreach ($allmonth1 as $k1 => $v1) {
  400. if ($v1['month'] == $vv)
  401. $total1[$kk] += $v1['currdone'];
  402. }
  403. $ymarray = explode('-', $vv);
  404. $cnym = '\'' . $ymarray[1] . '月' . '\'';
  405. if ($kk == 0)
  406. $cnym = '\'' . $ymarray[0] . '年' . $ymarray[1] . '月' . '\'';
  407. $cnymArray[] = $cnym;
  408. }
  409. foreach ($total as $value2) {
  410. $total3[] = round(($value2 / $totalstid) * 100);
  411. }
  412. foreach ($total1 as $value11) {
  413. $total4[] = round(($value11 / $totalstid) * 100);
  414. }
  415. $this->data['projectDate'] = implode(',', $cnymArray);
  416. $this->data['t1'] = implode(',', $total3);
  417. $this->data['t2'] = implode(',', $total4);
  418. $this->render('w-share-project-section', $this->data);
  419. }
  420. public function secTender()
  421. {
  422. $shareRowArray = $this->__shareact->getOne($this->params['hashcode']);
  423. if (!isset($shareRowArray['ids']) || !isset($shareRowArray['idtype']) || $shareRowArray['idtype'] != 2) {
  424. return Doo::conf()->APP_URL . 'share/error';
  425. }
  426. // 判断hashcode有效性
  427. // 总价
  428. $mArray = $this->__actMeasure->getRowByPmid($this->params['tenderid']);
  429. if(empty($mArray)){
  430. return Doo::conf()->APP_URL . 'share/error';
  431. }
  432. $proArray = $mArray;
  433. //来源url
  434. $this->data['comefromurl'] = Doo::conf()->APP_URL.'share/section/'.$this->params['hashcode'];
  435. $this->data['pmname'] = $mArray['pmname'];
  436. if ($proArray['pid']) {
  437. $this->data['pros']['numMeasure'] = $this->__actMeasure->getMearsureCount($proArray['pid']);
  438. $this->data['pros']['contracttotal'] = $this->__actMeasure->getTotalWithPid($proArray['pid']);
  439. $this->data['pros']['changTotal'] = $this->__numofperact->getChangTotal($proArray['pid']);
  440. $this->data['pros']['currdone'] = $this->__numofperact->getCurrDoneNow($proArray['pid']);
  441. if ($this->data['pros']['contracttotal']) {
  442. $this->data['pros']['pcurrdone'] = round(($this->data['pros']['currdone'] / $this->data['pros']['contracttotal']) * 100) . '%';
  443. } else {
  444. $this->data['pros']['pcurrdone'] = '0%';
  445. }
  446. $this->data['pros']['bcontracttotal'] = number_format($this->data['pros']['contracttotal'], 2, '.', ',');
  447. $this->data['pros']['bchangTotal'] = number_format($this->data['pros']['changTotal'], 2, '.', ',');
  448. } else {
  449. $this->data['pros'] = [];
  450. }
  451. // 图表
  452. $this->data['MeasureArray'] = $this->__numofperact->getGroupByLastOne($this->params['tenderid']);
  453. $this->data['totalnum'] = count($this->data['MeasureArray']);
  454. $measureArray = $this->__actMeasure->getRowByPmid($this->params['tenderid']);
  455. foreach ($this->data['MeasureArray'] as $key => $value) {
  456. $lastStatusArray = $this->__numofperact->getMaxStatusTimes($value['pmid'], $value['numpname']);
  457. $this->data['status'] = $this->statusArray[$lastStatusArray['currstatus']];
  458. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  459. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  460. } else {
  461. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  462. }
  463. }
  464. $this->render('w-share-project-section-detail', $this->data, TRUE);
  465. }
  466. public function tender()
  467. {
  468. $shareRowArray = $this->__shareact->getOne($this->params['hashcode']);
  469. if (!isset($shareRowArray['ids']) || !isset($shareRowArray['idtype']) || $shareRowArray['idtype'] != 3) {
  470. return Doo::conf()->APP_URL . 'share/error';
  471. }
  472. $this->data['hashcode'] = $this->params['hashcode'];
  473. // 总价
  474. if ($shareRowArray['ids'] > 0) {
  475. $mArray = $this->__actMeasure->getRowByPmid($shareRowArray['ids']);
  476. if(empty($mArray)){
  477. return Doo::conf()->APP_URL . 'share/error';
  478. }
  479. $proArray = $mArray;
  480. }
  481. //来源url
  482. $this->data['comefromurl'] = Doo::conf()->APP_URL.'share/tender/'.$this->params['hashcode'];
  483. $this->data['pmname'] = $mArray['pmname'];
  484. if ($proArray['pid']) {
  485. $this->data['pros']['numMeasure'] = $this->__actMeasure->getMearsureCount($proArray['pid']);
  486. $this->data['pros']['contracttotal'] = $this->__actMeasure->getTotalWithPid($proArray['pid']);
  487. $this->data['pros']['changTotal'] = $this->__numofperact->getChangTotal($proArray['pid']);
  488. $this->data['pros']['currdone'] = $this->__numofperact->getCurrDoneNow($proArray['pid']);
  489. if ($this->data['pros']['contracttotal']) {
  490. $this->data['pros']['pcurrdone'] = round(($this->data['pros']['currdone'] / $this->data['pros']['contracttotal']) * 100) . '%';
  491. } else {
  492. $this->data['pros']['pcurrdone'] = '0%';
  493. }
  494. $this->data['pros']['bcontracttotal'] = number_format($this->data['pros']['contracttotal'], 2, '.', ',');
  495. $this->data['pros']['bchangTotal'] = number_format($this->data['pros']['changTotal'], 2, '.', ',');
  496. } else {
  497. $this->data['pros'] = [];
  498. }
  499. // 图表
  500. $this->data['MeasureArray'] = $this->__numofperact->getGroupByLastOne($shareRowArray['ids']);
  501. $this->data['totalnum'] = count($this->data['MeasureArray']);
  502. $measureArray = $this->__actMeasure->getRowByPmid($shareRowArray['ids']);
  503. foreach ($this->data['MeasureArray'] as $key => $value) {
  504. $lastStatusArray = $this->__numofperact->getMaxStatusTimes($value['pmid'], $value['numpname']);
  505. $this->data['status'] = $this->statusArray[$lastStatusArray['currstatus']];
  506. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  507. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  508. } else {
  509. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  510. }
  511. }
  512. $this->render('w-share-project-section-detail', $this->data, true);
  513. }
  514. public function getShare()
  515. {
  516. $page = null;
  517. $fildArray = null;
  518. $proArray = $this->__shareact->getHashCode($_POST['pid'],1);
  519. if(!empty($proArray)){
  520. $proname = $this->__pro->getRowByPid($_POST['pid']);
  521. $page = 1;
  522. $fildArray[] = array('id' => $proArray['ids'], 'name' => $proname['pname'], 'ischeckd' => '1', 'hashcode' => $proArray['hashcode']);
  523. }else{
  524. $fildArray = null;
  525. $tmpArray = $this->__contractact->getRowByPid($_POST['pid']);
  526. foreach ($tmpArray as $key => $value) {
  527. $secArray = $this->__shareact->getSectionCount($value['stid']);
  528. if (!empty($secArray)) {
  529. $page = 2;
  530. $fildArray[] = array('id' => $value['stid'], 'name' => $value['stname'], 'ischeckd' => '1', 'hashcode' => $secArray['hashcode']);
  531. } else {
  532. $fildArray[] = array('id' => $value['stid'], 'name' => $value['stname'], 'ischeckd' => '0', 'hashcode' => $secArray['hashcode']);
  533. }
  534. }
  535. if($page != 2 && $page != 1){
  536. $fildArray = null;
  537. $tmp = $this->__actMeasure->getRowsByPid($_POST['pid']);
  538. foreach ($tmp as $key => $value) {
  539. $tenArray = $this->__shareact->getHashCode($value['pmid'],3);
  540. if(!empty($tenArray)){
  541. $page = 3;
  542. $fildArray[] = array('id' => $value['pmid'], 'name' => $value['pmname'],'ischeckd' => '1', 'hashcode' => $tenArray['hashcode']);
  543. }else{
  544. $fildArray[] = array('id' => $value['pmid'], 'name' => $value['pmname'],'ischeckd' => '0', 'hashcode' => $tenArray['hashcode']);
  545. }
  546. }
  547. }
  548. }
  549. if($page == null){
  550. $page = null;
  551. $fildArray = null;
  552. }
  553. die(json_encode(array('page' => $page, 'filearray' => $fildArray)));
  554. }
  555. public function setShare()
  556. {
  557. if($_POST['check'] == "true"){
  558. if ($this->__shareact->getCount($_POST['id'], $_POST['type']) > 0) {
  559. $returnVal = $this->__shareact->updateHashcode($_POST['id'], $_POST['type']);
  560. } else {
  561. $returnVal = $this->__shareact->insertHashcode($_POST['id'], $_POST['type']);
  562. }
  563. }else{
  564. $returnVal = $this->__shareact->deleteHashcode($_POST['id'], $_POST['type']);
  565. $returnVal['hashcode'] = '';
  566. }
  567. die(json_encode(array('sharecode' => $returnVal['hashcode'])));
  568. // if (isset($_POST['stid'])) {
  569. // if ($this->__shareact->getCount($_POST['stid'], 2) > 0) {
  570. // $returnVal = $this->__shareact->updateHashcode($_POST['stid'], 2);
  571. // } else {
  572. // $returnVal = $this->__shareact->insertHashcode($_POST['stid'], 2);
  573. // }
  574. // die(json_encode(array('sharecode' => $returnVal['hashcode'])));
  575. // }
  576. // if(isset($_POST['pmid'])) {
  577. // if ($this->__shareact->getCount($_POST['pmid'], 3) > 0) {
  578. // $returnVal = $this->__shareact->updateHashcode($_POST['pmid'], 3);
  579. // } else {
  580. // $returnVal = $this->__shareact->insertHashcode($_POST['pmid'], 3);
  581. // }
  582. // die(json_encode(array('sharecode' => $returnVal['hashcode'])));
  583. // }
  584. }
  585. public function ajaxGetProject()
  586. {
  587. $proArray = $this->__shareact->getHashCode($_POST['pid'],1);
  588. $proname = $this->__pro->getRowByPid($_POST['pid']);
  589. if(!empty($proArray)){
  590. $fildArray[] = array('id' => $proArray['ids'], 'name' => $proname['pname'], 'ischeckd' => '1', 'hashcode' => $proArray['hashcode']);
  591. }else{
  592. $fildArray[] = array('id' => $_POST['pid'], 'name' => $proname['pname'], 'ischeckd' => '0', 'hashcode' => $proArray['hashcode']);
  593. }
  594. die(json_encode($fildArray));
  595. }
  596. public function ajaxGetSection()
  597. {
  598. $fildArray = null;
  599. $tmpArray = $this->__contractact->getRowByPid($_POST['pid']);
  600. foreach ($tmpArray as $key => $value) {
  601. $secArray = $this->__shareact->getSectionCount($value['stid']);
  602. if (!empty($secArray)) {
  603. $fildArray[] = array('id' => $value['stid'], 'name' => $value['stname'], 'ischeckd' => '1', 'hashcode' => $secArray['hashcode']);
  604. } else {
  605. $fildArray[] = array('id' => $value['stid'], 'name' => $value['stname'], 'ischeckd' => '0', 'hashcode' => $secArray['hashcode']);
  606. }
  607. }
  608. die(json_encode($fildArray));
  609. }
  610. public function ajaxGetTender()
  611. {
  612. $fildArray = array();
  613. $tmp = $this->__actMeasure->getRowsByPid($_POST['pid']);
  614. foreach ($tmp as $key => $value) {
  615. $tenArray = $this->__shareact->getHashCode($value['pmid'],3);
  616. if(!empty($tenArray)){
  617. $fildArray[] = array('id' => $value['pmid'], 'name' => $value['pmname'],'ischeckd' => '1', 'hashcode' => $tenArray['hashcode']);
  618. }else{
  619. $fildArray[] = array('id' => $value['pmid'], 'name' => $value['pmname'],'ischeckd' => '0', 'hashcode' => $tenArray['hashcode']);
  620. }
  621. }
  622. die(json_encode($fildArray));
  623. }
  624. }
  625. ?>