ShareController.php 36 KB

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