ProjectController.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916
  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. function getsoftware(){
  73. $StrJson = ($this->aconfig->getOne(array('select' => 'upgradeinfo', 'asArray' => TRUE))['upgradeinfo']);
  74. $upgradeinfo = json_decode($StrJson, true);
  75. if ($upgradeinfo) {
  76. $this->data['version'] = $upgradeinfo['version'];
  77. $this->data['download'] = $upgradeinfo['download'];
  78. }
  79. }
  80. /**
  81. *
  82. * @return type
  83. */
  84. public function index()
  85. {
  86. if (isset($_POST['pname']) && $_POST['pname']) {
  87. $this->project->insertProject($this->auth->getUid(), $_POST['pname']);
  88. return Doo::conf()->APP_URL . 'project/index';
  89. }
  90. if (isset($_POST['target_pname']) && $_POST['target_pname'] && isset($_POST['ppid']) && $_POST['ppid']) {
  91. $this->project->updateProName($_POST['ppid'], $_POST['target_pname']);
  92. return Doo::conf()->APP_URL . 'project/index';
  93. }
  94. $this->data['pros'] = $this->project->getAll($this->auth->getUid());
  95. if (isset($this->data['pros'][0]['pid'])) {
  96. foreach ($this->data['pros'] as $key => $value) {
  97. $this->data['pros'][$key]['index'] = $key%8+1;
  98. $this->data['pros'][$key]['numMeasure'] = $this->actmeasure->getMearsureCount($value['pid']);
  99. $this->data['pros'][$key]['contracttotal'] = $this->actmeasure->getTotalWithPid($value['pid']);
  100. $this->data['pros'][$key]['changTotal'] = $this->numofperact->getChangTotal($value['pid']);
  101. // $this->data['pros'][$key]['contracttotal'] += $this->data['pros'][$key]['changTotal'];
  102. $this->data['pros'][$key]['currdone'] = $this->numofperact->getCurrDoneNow($value['pid']);
  103. if ($this->data['pros'][$key]['contracttotal']) {
  104. $this->data['pros'][$key]['pcurrdone'] = round(($this->data['pros'][$key]['currdone'] / $this->data['pros'][$key]['contracttotal']) * 100) . '%';
  105. } else {
  106. $this->data['pros'][$key]['pcurrdone'] = '0%';
  107. }
  108. $this->data['pros'][$key]['bcontracttotal'] = number_format($this->data['pros'][$key]['contracttotal'], 2, '.', ',');
  109. $this->data['pros'][$key]['bchangTotal'] = number_format($this->data['pros'][$key]['changTotal'], 2, '.', ',');
  110. }
  111. } else {
  112. $this->data['pros'] = [];
  113. }
  114. $this->render('w-project', $this->data, TRUE);
  115. }
  116. public function proOverview()
  117. {
  118. $conArray = $this->contractact->getRowByPid($this->params['pid']);
  119. $this->data['projectDate'] = '';
  120. $this->data['conArray'][] = array();
  121. $this->getFav();
  122. // $this->data['measureArray'] = $this->actmeasure->getRowByPids($this->params['pid']);
  123. // foreach ($this->data['measureArray'] as $key => $value) {
  124. // $this->data['measureArray'][$key]['stopNow'] = $this->numofperact->getStopNow($value['pmid'])['sntotal'];
  125. // $this->data['measureArray'][$key]['pstopnow'] = round(($this->data['measureArray'][$key]['stopNow'] / $value['contracttotal']) * 100);
  126. // }
  127. $this->data['pid'] = $this->params['pid'];
  128. $this->data['conArray'] = $conArray;
  129. $contracttotal = 0;
  130. // 不同标段和值
  131. // $list = $this->numofperact->getStopNowStMonth($v['stid']); //print_r($list);
  132. // if (empty($list))
  133. // $startMonth = date("Y-m");
  134. // else
  135. // $startMonth = $list[0]['month'];
  136. // //$list=Array ( 0 => Array ( 'sntotal' => 20000 ,'month' => '2014-09' ),1 => Array ( 'sntotal' => 40000, 'month' => '2016-10' ) );
  137. // $d = 0;
  138. // $mDList = $mList = array();
  139. // $toMD = date("Y-m");
  140. // foreach ($list as $value) {
  141. // $flag = true;
  142. // do {
  143. // $MD = date("Y-m", strtotime($startMonth . " " . $d . " month")); //echo $MD."/".$value['month']."<br/>";
  144. // array_push($mDList, "'" . $MD . "'");
  145. // array_push($mList, $MD);
  146. //
  147. // if ($MD == $toMD)//if(strtotime($MD)>=strtotime($toMD))
  148. // $flag = false;
  149. // if ($d > 0 && ($MD == $value['month'] || $toMD == $value['month']))
  150. // $flag = false;
  151. // $d++;
  152. //// if ($d==10)
  153. //// $flag=false;
  154. // } while ($flag);
  155. // }
  156. // $this->data['projectDate'] = implode(',', $mDList);
  157. //
  158. // $dataList = array();
  159. // $sntotalTA = 0;
  160. // foreach ($mList as $va) {
  161. // $falg = true;
  162. // foreach ($list as $value) {
  163. // if ($va == $value['month']) {
  164. // $sntotalTA+=$value['sntotal'];
  165. // $PER = round($sntotalTA / $contracttotal, 3) * 100;
  166. // array_push($dataList, $PER);
  167. // $falg = false;
  168. // break;
  169. // }
  170. // }
  171. // if ($falg)
  172. // array_push($dataList, 0);
  173. // }
  174. // $this->data['conArray'][$k]['monthStopnow'] = $dataList;
  175. //
  176. // $list = $this->numofperact->getCurrDoneSMontht($v['stid']);
  177. // $dataList = array();
  178. // $currdoneTA = 0;
  179. // foreach ($mList as $va) {
  180. // $falg = true;
  181. // foreach ($list as $value) {
  182. // if ($va == $value['month']) {
  183. // $currdoneTA+=$value['currdone'];
  184. // $PER = round($currdoneTA / $contracttotal, 3) * 100;
  185. // array_push($dataList, $PER);
  186. // $falg = false;
  187. // break;
  188. // }
  189. // }
  190. // if ($falg)
  191. // array_push($dataList, 0);
  192. // }
  193. // $this->data['conArray'][$k]['monthCurrdone'] = $dataList;
  194. //
  195. $totalstid = 0;
  196. $monthArray = [];
  197. foreach ($this->data['conArray'] as $k => $v) {
  198. $this->data['conArray'][$k]['pstopnow'] = $this->data['conArray'][$k]['pscurrdone'] = 0;
  199. $retval = $this->actmeasure->getAllbyStidSum($v['stid']);
  200. $contracttotal += $retval[0]['contracttotal'];
  201. $totalstid += $this->actmeasure->getTotal($v['stid'])['total'];
  202. $total = $this->actmeasure->getTotal($v['stid'])['total'];
  203. if ($total) {
  204. $this->data['conArray'][$k]['total'] = round($total, 2);
  205. } else {
  206. $this->data['conArray'][$k]['total'] = 0;
  207. }
  208. $sntotal = $this->numofperact->getCountTotalSTID2($v['stid'])['totalplus'];
  209. if ($sntotal) {
  210. $this->data['conArray'][$k]['stopnow'] = round($sntotal, 2);
  211. } else {
  212. $this->data['conArray'][$k]['stopnow'] = 0;
  213. }
  214. $this->data['conArray'][$k]['currdone'] = $this->numofperact->getCurrDoneSt($v['stid'])['currdone'];
  215. if ($this->data['conArray'][$k]['total'] > 0) {
  216. $this->data['conArray'][$k]['pstopnow'] = round(($this->data['conArray'][$k]['stopnow'] / $this->data['conArray'][$k]['total']) * 100);
  217. $this->data['conArray'][$k]['pscurrdone'] = round(($this->data['conArray'][$k]['currdone'] / $this->data['conArray'][$k]['total']) * 100);
  218. }
  219. // 分组出年月 每个月份的独立相加 累计完成总量
  220. $month = $this->numofperact->getCurrTotalStMonthNoCheckno($v['stid']);
  221. foreach ($month as $key => $value) {
  222. $allmonth[] = $value;
  223. if (!in_array($value['month'], $monthArray))
  224. $monthArray[] = $value['month'];
  225. }
  226. // 分组出年月 每个月份的独立相加 本月完成总量
  227. $month1 = $this->numofperact->getCurrDoneStMonthNoCheckno($v['stid']);
  228. foreach ($month1 as $key => $value) {
  229. $allmonth1[] = $value;
  230. }
  231. }
  232. // 中文表述年月
  233. $total = $total1 = array();
  234. $startyear = $cnymArray = array();
  235. foreach ($monthArray as $kk => $vv) {
  236. $ymarray = explode('-', $vv);
  237. if (!in_array($ymarray[0], $startyear))
  238. $startyear[] = $ymarray[0];
  239. // $cnym = '\'' . $ymarray[1] . '月' . '\'';
  240. // if ($kk == 0)
  241. // $cnym = '\'' . $ymarray[0] . '年' . $ymarray[1] . '月' . '\'';
  242. // $cnymArray[] = $cnym;
  243. }
  244. $thismonth = 0;
  245. foreach($startyear as $sk => $sv){
  246. for($i = 1; $i <= 12; $i++){
  247. $j = $i < 10 ? '0'.$i : $i;
  248. $month = $sv.'-'.$j;
  249. $thismonth1 = 0;
  250. foreach ($allmonth1 as $k1 => $v1) {
  251. if ($v1['month'] == $month)
  252. $thismonth1 += $v1['currdone'];
  253. }
  254. $total1[] = $thismonth1 != 0 ? $thismonth1 : 0;
  255. foreach ($allmonth as $keyk => $valuev) {
  256. if ($valuev['month'] == $month)
  257. $thismonth += $valuev['currtotal'];
  258. }
  259. $total[] = ($thismonth != 0 && $thismonth1 != 0) ? $thismonth : 0;
  260. $cnymArray[] = $i == 1 ? '\'' .$sv.'年'.$i.'月'. '\'' : '\'' .$i.'月'. '\'';
  261. }
  262. }
  263. foreach ($total as $value2) {
  264. $total3[] = round(($value2 / $totalstid) * 100);
  265. }
  266. foreach ($total1 as $value11) {
  267. $total4[] = round(($value11 / $totalstid) * 100);
  268. }
  269. $this->data['projectDate'] = implode(',', $cnymArray);
  270. $this->data['t1'] = implode(',', $total3);
  271. $this->data['t2'] = implode(',', $total4);
  272. $this->render('w-project-detail', $this->data, TRUE);
  273. }
  274. public function proSection()
  275. {
  276. if (isset($_POST['stid']) && isset($_POST['proname'])) {
  277. $this->contractact->updateStName($_POST['stid'], $_POST['proname']);
  278. return Doo::conf()->APP_URL . 'project/' . $this->params['pid'] . '/section';
  279. }
  280. $this->getFav();
  281. $contractArray = $this->contractact->getRowByPid($this->params['pid']); // 获取合同段
  282. $htmlstr = NULL;
  283. foreach ($contractArray as $k => $v) {// 获取所有合同段
  284. $retval = $this->actmeasure->getAllbyStid($v['stid']); // 获取标段
  285. $bdhtmlstr = NULL;
  286. $bdhtmlstr = '<thead>
  287. <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>
  288. <tbody>';
  289. $biaoduantotalmoney = 0;
  290. $currTotal = 0;
  291. $progress = $otherprogress = '0%';
  292. $currTotal = $this->numofperact->getCountTotalSTID2($v['stid']);
  293. foreach ($retval as $key => $value) {
  294. $displayPercentSnTotalProgress = '0%';
  295. $displayPercentCurrTotalProgress = '0%';
  296. $displayPercentLessTotalProgress = '0%';
  297. $snTotalProgress = $currTotalProgress = $lessTotalProgress = '0%';
  298. $nTotalProgress = $ncurrTotalProgress = $nlessTotalProgress = number_format(0, 2, '.', ',');
  299. $numCount = $this->numofperact->getCountTotalnum2($value['pmid']); // 获取标段已有期数
  300. if (isset($numCount['numpname'])) {
  301. $lastStatusArray = $this->numofperact->getMaxStatusTimes($value['pmid'], $numCount['numpname']);
  302. } else {
  303. $lastStatusArray['currstatus'] = 'uncheck';
  304. $numCount['numpname'] = 0;
  305. }
  306. $totalplus = $this->numofperact->getCountTotalplus($value['pmid']);
  307. $snTotal = $this->numofperact->getStopNowTotal($value['pmid']); //根据标段ID获取最新一期(包括不通过)
  308. $currcomTotal = $this->numofperact->getCurrdoneNew($value['pmid']); //截止目前
  309. $numStatusArray = $this->numofperact->getLastStatus2($this->params['pid'], $value['pmid']);
  310. if ($numCount > 0) {
  311. $nTotalProgress = number_format($snTotal['sntotal'], 2, '.', ',');
  312. $ncurrTotalProgress = number_format($currcomTotal['currtotal'], 2, '.', ',');
  313. $nlessTotalProgress = number_format($value['contracttotal'] - $snTotal['sntotal'] - $currcomTotal['currtotal'], 2, '.', ',');
  314. if (isset($value['contracttotal']) && ($value['contracttotal'] > 0)) {
  315. $snTotalProgress = round(($snTotal['sntotal'] / $value['contracttotal']) * 100);
  316. $currTotalProgress = round(($currcomTotal['currtotal'] / $value['contracttotal']) * 100);
  317. // $lessTotalProgress = round((($value['contracttotal'] - ($currcomTotal['currtotal'] + $snTotal['sntotal'])) / $value['contracttotal']) * 100);
  318. $lessTotalProgress = 100 - $snTotalProgress - $currTotalProgress;
  319. $displayPercentSnTotalProgress = $snTotalProgress . '%';
  320. $displayPercentCurrTotalProgress = $currTotalProgress . '%';
  321. $displayPercentLessTotalProgress = $lessTotalProgress . '%';
  322. }
  323. }
  324. $biaoduantotalmoney += $value['contracttotal'];
  325. $totalmoney = number_format($value['contracttotal'], 2, '.', ',');
  326. if (isset($numStatusArray['currstatus'])) {
  327. $statusStr = '(' . $this->statusArray[$lastStatusArray['currstatus']] . ')';
  328. } else {
  329. $statusStr = '';
  330. }
  331. $bdhtmlstr .= '
  332. <tr>
  333. <td><a href="/project/' . $this->params['pid'] . '/section/' . $value['pmid'] . '/detail">' . $value['pmname'] . '</a></td>
  334. <td class="">第 ' . $numCount['numpname'] . ' 期' . $statusStr . '</td>
  335. <td class="taR">¥' . $totalmoney . '</td>
  336. <td>
  337. <div class="progress">
  338. <div class="progress-bar progress-bar-success" style="width: ' . $displayPercentSnTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成:¥' . $nTotalProgress . '">' . $displayPercentSnTotalProgress . '</div>
  339. <div class="progress-bar" style="width:' . $displayPercentCurrTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' . $ncurrTotalProgress . '">' . $displayPercentCurrTotalProgress . '</div>
  340. <div class="progress-bar progress-bar-gary" style="width:' . $displayPercentLessTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $nlessTotalProgress . '">' . $displayPercentLessTotalProgress . '</div>
  341. </div>
  342. </td>
  343. </tr>';
  344. }
  345. $nprogress = $notherprogress = NULL;
  346. // $currTotal = $this->numofperact->getCurrdoneSTID($v['stid']);
  347. if ($biaoduantotalmoney > 0) {
  348. $nprogress = number_format($currTotal['totalplus'], 2, '.', ',');
  349. $notherprogress = number_format($biaoduantotalmoney - $currTotal['totalplus'], 2, '.', ',');
  350. $progress = round(($currTotal['totalplus'] / $biaoduantotalmoney) * 100) . '%'; // 累计完成计量 所有标段合计
  351. $otherprogress = round((($biaoduantotalmoney - $currTotal['totalplus']) / $biaoduantotalmoney) * 100) . '%';
  352. $biaoduantotalmoney = number_format($biaoduantotalmoney, 2, '.', ',');
  353. }
  354. $htmlstr .= '<div class="project">
  355. <div class="proSection">
  356. <table class="table">
  357. <thead>
  358. <tr>
  359. <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>
  360. <td width="90">总价:</td><td width="165">¥<b style="font-size:16px">' . $biaoduantotalmoney . '</b></td>
  361. <td width="60">完成进度:</td><td><div class="progress">
  362. <div class="progress-bar progress-bar-success" style="width:' . $progress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="累计完成:¥' . $nprogress . '">' . $progress . '</div>
  363. <div class="progress-bar progress-bar-danger" style="width:' . $otherprogress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $notherprogress . '">' . $otherprogress . '</div>
  364. </div></td>
  365. </tr>
  366. </thead>
  367. </table>
  368. <table class="table table-striped table-hover tablelist">
  369. ' . $bdhtmlstr . '
  370. </tbody>
  371. </table>
  372. </div>
  373. </div>';
  374. }
  375. $this->data['htmlstr'] = $htmlstr;
  376. if (isset($_POST['secname']) && $_POST['secname']) {
  377. $this->contractact->insertContract($this->params['pid'], $this->auth->getUid(), $_POST['secname']);
  378. return Doo::conf()->APP_URL . 'project/' . $this->params['pid'] . '/section';
  379. }
  380. $this->data['pid'] = $this->params['pid'];
  381. $this->render('w-project-section', $this->data, TRUE);
  382. }
  383. function proSectionFiles()
  384. {
  385. if (isset($_POST['optype']) && ($_POST['optype'] == 'replace') && ($_POST['imnid'])) {
  386. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  387. if ($imnidArray['iaid'] > 0) {
  388. $fileArray = $this->upItemFile('file')[0];
  389. if (isset($fileArray['filepath'])) {
  390. $itemArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  391. if (isset($itemArray)) {
  392. if ($itemArray['oldiaid'] > 0) {
  393. $oldiaid = $itemArray['oldiaid'];
  394. } else {
  395. $oldiaid = $imnidArray['iaid'];
  396. }
  397. $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);
  398. $iaid = $this->itemfle->insertItemFileRecord($postArray);
  399. if ($iaid > 1) {
  400. $this->itemmeasurenum->updateIAID($imnidArray['iaid'], $iaid);
  401. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  402. die();
  403. }
  404. }
  405. }
  406. }
  407. }
  408. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  409. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  410. if ($imnidArray['iaid'] > 0) {
  411. $this->itemmeasurenum->updateDeltag($_POST['imnid'], $this->auth->getUid());
  412. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  413. die();
  414. }
  415. }
  416. if (isset($_POST['filename']) && isset($_POST['filedesc']) && isset($_POST['upimnid'])) {
  417. $filename = $_POST['filename'];
  418. $filedesc = $_POST['filedesc'];
  419. $imnidArray = $this->itemmeasurenum->getRowData($_POST['upimnid']);
  420. if ($imnidArray['iaid'] > 0) {
  421. if (isset($filedesc))
  422. $this->itemmeasurenum->updateItemFields($_POST['upimnid'], $filedesc, 0);
  423. if (isset($filename))
  424. $this->itemfle->updateItemFields($imnidArray['iaid'], $filename, 0);
  425. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  426. die();
  427. }
  428. }
  429. // 面包屑导航项目
  430. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  431. $this->data['pmid'] = $this->params['pmid'];
  432. $allproArray = $this->project->getAll();
  433. foreach ($allproArray as $kk => $vv) {
  434. if ($vv['pid'] == $this->params['pid']) {
  435. $this->data['currproArray'] = $vv;
  436. } else {
  437. $this->data['allproArray'][] = $vv;
  438. }
  439. }
  440. // 面包屑导航合同
  441. $conArray = $this->contractact->getAll();
  442. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  443. if (isset($measureArray['stid'])) {
  444. foreach ($conArray as $kkk => $vvv) {
  445. if ($vvv['stid'] == $measureArray['stid']) {
  446. $this->data['currconArray'] = $vvv;
  447. } else {
  448. if ($vvv['pid'] == $this->params['pid'])
  449. $this->data['allconArray'][] = $vvv;
  450. }
  451. }
  452. } else {
  453. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  454. }
  455. // 面包屑导航标段
  456. $this->data['curractmeasureArray'] = NULL;
  457. $this->data['allactmeasureArray'] = [];
  458. $actmeasureArray = $this->actmeasure->getAll();
  459. foreach ($actmeasureArray as $kkkk => $vvvv) {
  460. if ($vvvv['stid'] == $measureArray['stid']) {
  461. if (($vvvv['pmid'] == $this->params['pmid'])) {
  462. $this->data['curractmeasureArray'] = $vvvv;
  463. } else {
  464. $this->data['allactmeasureArray'][] = $vvvv;
  465. }
  466. }
  467. }
  468. // 选取查询
  469. $groupArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  470. $this->data['groupArray'] = $groupArray;
  471. $owneridArray = $this->itemfle->getGroupOwnerid($this->params['pmid']);
  472. foreach ($owneridArray as $k => $v) {
  473. $this->data['owneridArray'][$k]['name'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  474. $this->data['owneridArray'][$k]['iaid'] = $v['iaid'];
  475. $this->data['owneridArray'][$k]['ownerid'] = $v['ownerid'];
  476. }
  477. // 分页
  478. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid'], 0, $this->params['numpname'], $this->params['userid']);
  479. if ($totalArchive) {
  480. if ($this->params['numpname'] && $this->params['userid']) {
  481. $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);
  482. } elseif ($this->params['numpname']) {
  483. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/num/' . $this->params['numpname'] . '/page', $totalArchive, 20, 100);
  484. } elseif ($this->params['userid']) {
  485. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/user/' . $this->params['userid'] . '/page', $totalArchive, 20, 100);
  486. } else {
  487. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/page', $totalArchive, 20, 100);
  488. }
  489. $pager->setCss('', 'disabled', 'active');
  490. if (isset($this->params['pindex']))
  491. $pager->paginate(intval($this->params['pindex']));
  492. else
  493. $pager->paginate(1);
  494. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNum($this->params['pmid'], $pager->limit, $this->params['numpname'], $this->params['userid']);
  495. }
  496. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  497. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  498. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  499. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  500. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  501. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  502. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  503. }
  504. $this->data['pid'] = $this->params['pid'];
  505. $this->data['pmid'] = $this->params['pmid'];
  506. $this->data['mpid'] = $this->params['mpid'];
  507. $this->data['userid'] = $this->params['userid'];
  508. $this->data['num'] = $this->params['numpname'];
  509. $this->data['pager'] = $pager->output;
  510. $this->render('w-project-section-files', $this->data, TRUE);
  511. }
  512. function proSectionFilesRecover()
  513. {
  514. if (isset($_POST['optype']) && ($_POST['optype'] == 'reconvery') && isset($_POST['imnid'])) {
  515. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  516. if ($imnidArray['iaid'] > 0) {
  517. $this->itemmeasurenum->recoveryDel($_POST['imnid']);
  518. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  519. die();
  520. }
  521. }
  522. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  523. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  524. if ($imnidArray['iaid'] > 0) {
  525. $iaidArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  526. if ($iaidArray['ownerid'] == $this->auth->getUid()) {
  527. $this->itemfle->delItem($imnidArray['iaid']);
  528. $this->itemmeasurenum->delItemIAID($imnidArray['iaid']);
  529. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  530. die();
  531. } else {
  532. echo json_encode(array('status' => 2), JSON_UNESCAPED_UNICODE);
  533. die();
  534. }
  535. }
  536. }
  537. // 面包屑导航项目
  538. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  539. $this->data['pmid'] = $this->params['pmid'];
  540. $allproArray = $this->project->getAll();
  541. foreach ($allproArray as $kk => $vv) {
  542. if ($vv['pid'] == $this->params['pid']) {
  543. $this->data['currproArray'] = $vv;
  544. } else {
  545. $this->data['allproArray'][] = $vv;
  546. }
  547. }
  548. // 面包屑导航合同
  549. $conArray = $this->contractact->getAll();
  550. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  551. if (isset($measureArray['stid'])) {
  552. foreach ($conArray as $kkk => $vvv) {
  553. if ($vvv['stid'] == $measureArray['stid']) {
  554. $this->data['currconArray'] = $vvv;
  555. } else {
  556. if ($vvv['pid'] == $this->params['pid'])
  557. $this->data['allconArray'][] = $vvv;
  558. }
  559. }
  560. } else {
  561. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  562. }
  563. // 面包屑导航标段
  564. $this->data['curractmeasureArray'] = NULL;
  565. $this->data['allactmeasureArray'] = [];
  566. $actmeasureArray = $this->actmeasure->getAll();
  567. foreach ($actmeasureArray as $kkkk => $vvvv) {
  568. if ($vvvv['stid'] == $measureArray['stid']) {
  569. if (($vvvv['pmid'] == $this->params['pmid'])) {
  570. $this->data['curractmeasureArray'] = $vvvv;
  571. } else {
  572. $this->data['allactmeasureArray'][] = $vvvv;
  573. }
  574. }
  575. }
  576. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid']);
  577. if ($totalArchive) {
  578. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/recover/page', $totalArchive, 20, 100);
  579. $pager->setCss('', 'disabled', 'active');
  580. if (isset($this->params['pindex']))
  581. $pager->paginate(intval($this->params['pindex']));
  582. else
  583. $pager->paginate(1);
  584. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNumDel($pager->limit, $this->params['pmid']);
  585. }
  586. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  587. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  588. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  589. $this->data['itemMeasureArray'][$k]['delname'] = $this->profile->getProWithUid($v['deluid'])['name'];
  590. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  591. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  592. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  593. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  594. $this->data['itemMeasureArray'][$k]['filepath'] = $fileArray['filepath'];
  595. }
  596. $this->data['pid'] = $this->params['pid'];
  597. $this->data['pmid'] = $this->params['pmid'];
  598. $this->data['mpid'] = $this->params['mpid'];
  599. $this->data['pager'] = $pager->output;
  600. $this->render('w-project-section-files-recover', $this->data, TRUE);
  601. }
  602. /**
  603. * @return actMeasure
  604. */
  605. public function proSectionGetFiles()
  606. {
  607. $attaArray = $this->itemfle->getItemFile($this->params['iaid']);
  608. $this->file_down($attaArray['filepath'], $attaArray['filesize'], $attaArray['filename'] . '.' . $attaArray['fileext']);
  609. return;
  610. }
  611. function getItemFileHistory()
  612. {
  613. if ($this->params['iaid']) {
  614. $iaidArray = $this->itemfle->getItemFile($this->params['iaid']);
  615. if ($iaidArray['oldiaid'] > 0) {
  616. $oldiaidArray = $this->itemfle->getFileHistory($iaidArray['oldiaid']);
  617. $htmlstr = '';
  618. foreach ($oldiaidArray as $k => $v) {
  619. $countInt = $k + 1;
  620. $formatDate = date('Y-m-d H:i:s', $v['intime']);
  621. $profileArray = $this->profile->getProWithUid($v['ownerid']);
  622. $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>';
  623. }
  624. echo json_encode(array('html' => $htmlstr), JSON_UNESCAPED_UNICODE);
  625. die();
  626. }
  627. }
  628. }
  629. Function fNumber($number)
  630. {
  631. if ($number == '')
  632. Return "-";
  633. $nlen = strlen($number);
  634. while ($nlen > 3) {
  635. $fNumber = "," . substr($number, $nlen - 3, 3);
  636. $number = substr($number, 0, -3);
  637. $nlen = strlen($number);
  638. }
  639. if ($nlen <= 3) {
  640. $fNumber = $number . $fNumber;
  641. }
  642. Return $fNumber;
  643. }
  644. private function getFav()
  645. {
  646. $proArray = $this->project->getAll($this->auth->getUid());
  647. $this->data['othrPro'] = [];
  648. foreach ($proArray as $key => $value) {
  649. if ($value['pid'] == $this->params['pid']) {
  650. $this->data['currProName'] = $value['pname'];
  651. $this->data['currProID'] = $value['pid'];
  652. } else {
  653. $this->data['othrPro'][] = $proArray[$key];
  654. }
  655. }
  656. }
  657. public function proSectionMeasure()
  658. {
  659. //此处未做更改,JSON文件已经固定名称
  660. $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  661. if (isset($jsonpath['dirname'])) {
  662. $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  663. if ($handle = opendir($extPathdir)) {
  664. while (false !== ($file = readdir($handle))) {
  665. $filename = NULL;
  666. $filename = pathinfo($file);
  667. if ($filename['extension'] == 'json')
  668. $proArray = json_decode(file_get_contents($extPathdir . '/' . $file), TRUE, JSON_UNESCAPED_UNICODE);
  669. }
  670. closedir($handle);
  671. }
  672. $this->data['proArray'] = $proArray['Bills'];
  673. } else {
  674. $this->data['proArray'] = [];
  675. }
  676. $this->data['mpid'] = $this->params['mpid'];
  677. $this->data['pid'] = $this->params['pid'];
  678. $this->render('w-project-section-measure', $this->data, TRUE);
  679. }
  680. public function substr_replace_cn($string, $repalce = '*', $start = 0, $len = 0)
  681. {
  682. $count = mb_strlen($string, 'UTF-8'); //此处传入编码,建议使用utf-8。此处编码要与下面mb_substr()所使用的一致
  683. if (!$count) {
  684. return $string;
  685. }
  686. if ($len == 0) {
  687. $end = $count; //传入0则替换到最后
  688. } else {
  689. $end = $start + $len; //传入指定长度则为开始长度+指定长度
  690. }
  691. $i = 0;
  692. $returnString = '';
  693. while ($i < $count) { //循环该字符串
  694. $tmpString = mb_substr($string, $i, 1, 'UTF-8'); // 与mb_strlen编码一致
  695. if ($start <= $i && $i < $end) {
  696. $returnString .= $repalce;
  697. } else {
  698. $returnString .= $tmpString;
  699. }
  700. $i++;
  701. }
  702. return $returnString;
  703. }
  704. function unicode_encode($name)
  705. {//to Unicode
  706. $name = iconv('UTF-8', 'UCS-2', $name);
  707. $len = strlen($name);
  708. $str = '';
  709. for ($i = 0; $i < $len - 1; $i = $i + 2) {
  710. $c = $name[$i];
  711. $c2 = $name[$i + 1];
  712. if (ord($c) > 0) {// 两个字节的字
  713. $str .= '\\' . base_convert(ord($c), 10, 16) . base_convert(ord($c2), 10, 16);
  714. } else {
  715. $str .= $c2;
  716. }
  717. }
  718. $str = strtoupper($str);
  719. return $str;
  720. }
  721. function unicode_decode($name)
  722. {//Unicode to
  723. $pattern = '/([\w]+)|(\\\u([\w]{4}))/i';
  724. preg_match_all($pattern, $name, $matches);
  725. if (!empty($matches)) {
  726. $name = '';
  727. for ($j = 0; $j < count($matches[0]); $j++) {
  728. $str = $matches[0][$j];
  729. if (strpos($str, '\\u') === 0) {
  730. $code = base_convert(substr($str, 2, 2), 16, 10);
  731. $code2 = base_convert(substr($str, 4), 16, 10);
  732. $c = chr($code) . chr($code2);
  733. $c = iconv('UCS-2', 'UTF-8', $c);
  734. $name .= $c;
  735. } else {
  736. $name .= $str;
  737. }
  738. }
  739. }
  740. return $name;
  741. }
  742. public function proDetail()
  743. {
  744. // 面包屑导航项目
  745. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  746. $this->data['pmid'] = $this->params['pmid'];
  747. $allproArray = $this->project->getAll();
  748. foreach ($allproArray as $kk => $vv) {
  749. if ($vv['pid'] == $this->params['pid']) {
  750. $this->data['currproArray'] = $vv;
  751. } else {
  752. $this->data['allproArray'][] = $vv;
  753. }
  754. }
  755. // 面包屑导航合同
  756. $conArray = $this->contractact->getAll();
  757. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  758. if (isset($measureArray['stid'])) {
  759. foreach ($conArray as $kkk => $vvv) {
  760. if ($vvv['stid'] == $measureArray['stid']) {
  761. $this->data['currconArray'] = $vvv;
  762. } else {
  763. if ($vvv['pid'] == $this->params['pid'])
  764. $this->data['allconArray'][] = $vvv;
  765. }
  766. }
  767. } else {
  768. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  769. }
  770. // 面包屑导航标段
  771. $this->data['curractmeasureArray'] = NULL;
  772. $this->data['allactmeasureArray'] = [];
  773. $actmeasureArray = $this->actmeasure->getAll();
  774. foreach ($actmeasureArray as $kkkk => $vvvv) {
  775. if ($vvvv['stid'] == $measureArray['stid']) {
  776. if (($vvvv['pmid'] == $this->params['pmid'])) {
  777. $this->data['curractmeasureArray'] = $vvvv;
  778. } else {
  779. $this->data['allactmeasureArray'][] = $vvvv;
  780. }
  781. }
  782. }
  783. // 图表
  784. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  785. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  786. foreach ($this->data['MeasureArray'] as $key => $value) {
  787. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  788. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  789. } else {
  790. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  791. }
  792. }
  793. $this->data['pmid'] = $this->params['pmid'];
  794. $this->data['pid'] = $this->params['pid'];
  795. $this->render('w-project-section-detail', $this->data, TRUE);
  796. }
  797. public function welcome()
  798. {
  799. // if (!$this->auth->isLoggedIn())
  800. // return Doo::conf()->APP_URL;
  801. if ($this->profile->getProWithUid($this->auth->getUid())['userid'])
  802. return Doo::conf()->APP_URL . 'project/list';
  803. if (isset($_POST['welform'])) {
  804. $profileUserArray = $_POST;
  805. $profileUserArray['userid'] = $this->auth->getUid();
  806. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  807. return Doo::conf()->APP_URL . 'project/list';
  808. }
  809. $this->render('welcome', $this->data);
  810. }
  811. // ajax提取密码名称
  812. public function getAjaxSection()
  813. {
  814. if (!$this->isAjax())
  815. return;
  816. echo json_encode($_POST);
  817. }
  818. function upItemFile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  819. {
  820. $this->att->setUploadDir();
  821. return $this->att->uploadMut($fildname, $param);
  822. }
  823. /**
  824. * 文件下载
  825. * @param $filepath 文件路径
  826. * @param $filename 文件名称
  827. */
  828. function file_down($filepath, $filesize, $filename = '')
  829. {
  830. if (!$filename)
  831. $filename = basename($filepath);
  832. if ($this->is_ie())
  833. $filename = rawurlencode($filename);
  834. $filetype = $this->fileext($filename);
  835. // $filesize = sprintf("%u", filesize($filepath));
  836. if (ob_get_length() !== false)
  837. @ob_end_clean();
  838. header('Pragma: public');
  839. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  840. header('Cache-Control: no-store, no-cache, must-revalidate');
  841. header('Cache-Control: pre-check=0, post-check=0, max-age=0');
  842. header('Content-Transfer-Encoding: binary');
  843. header('Content-Encoding: none');
  844. header('Content-type: ' . $filetype);
  845. header('Content-Disposition: attachment; filename="' . $filename . '"');
  846. header('Content-length: ' . $filesize);
  847. @readfile($filepath);
  848. exit;
  849. }
  850. /**
  851. * IE浏览器判断
  852. */
  853. function is_ie()
  854. {
  855. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  856. if ((strpos($useragent, 'opera') !== false) || (strpos($useragent, 'konqueror') !== false))
  857. return false;
  858. if (strpos($useragent, 'msie ') !== false)
  859. return true;
  860. return false;
  861. }
  862. /**
  863. * 取得文件扩展
  864. *
  865. * @param $filename 文件名
  866. * @return 扩展名
  867. */
  868. function fileext($filename)
  869. {
  870. return strtolower(trim(substr(strrchr($filename, '.'), 1, 10)));
  871. }
  872. }
  873. ?>