SProjectController.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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. /**
  15. * MainController
  16. * Feel free to delete the methods and replace them with your own code.
  17. *
  18. * @author darkredz
  19. */
  20. class SProjectController extends DooController
  21. {
  22. private $data, $auth, $attfile, $profile, $project, $contractact, $actmeasure, $numofperact, $measureauditact, $itemmeasurenum, $itemfle, $att;
  23. public function beforeRun($resource, $action)
  24. {
  25. // $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  26. // $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  27. // if (!$falg)
  28. // return Doo::acl()->defaultFailedRoute;
  29. if ($this->auth->getUid()) {
  30. $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  31. $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  32. if (!$falg)
  33. return Doo::acl()->defaultFailedRoute;
  34. } else {
  35. return Doo::acl()->defaultFailedRoute;
  36. }
  37. }
  38. public function __construct()
  39. {
  40. $this->auth = new Auth();
  41. $this->attfile = new attFile();
  42. $this->profile = new Profile();
  43. $this->project = new Project();
  44. $this->contractact = new Contractact();
  45. $this->actmeasure = new actMeasure();
  46. $this->numofperact = new NumofperAct();
  47. $this->measureauditact = new MeasureauditAct();
  48. $this->itemmeasurenum = new ItemMeasureNumpofper();
  49. $this->itemfle = new ItemFile();
  50. $this->att = new attachment();
  51. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  52. $this->data['currChannle'] = 's';
  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. foreach ($mpidArray as $key => $value) {
  57. // 审批操作按照时间排序多标段
  58. $this->data['numofchecking'] += $this->measureauditact->getCountMyChecking($value['pid'], $this->auth->getUid());
  59. }
  60. }
  61. if ($this->data['numofchecking'] == 0) {
  62. $this->data['numofchecking'] = null;
  63. }
  64. }
  65. public function index()
  66. {
  67. $this->data['conArray'] = NULL;
  68. $conArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  69. if (isset($conArray)) {
  70. foreach ($conArray as $k => $v) {
  71. $proArray = $this->project->getRowByPid($v['pid']);
  72. $this->data['conArray'][] = $proArray;
  73. $profileArray = $this->profile->getProWithUid($proArray['uid']);
  74. $this->data['conArray'][$k]['company'] = $profileArray['company'];
  75. $countMeasureInt = $this->actmeasure->getCountMeasure($v['stid']);
  76. $countTotalMeasureInt = $this->actmeasure->getMearsureCount($v['pid']);
  77. $this->data['conArray'][$k]['countmeasure'] = $countMeasureInt;
  78. $this->data['conArray'][$k]['countTotalMeasureInt'] = $countTotalMeasureInt;
  79. $this->data['conArray'][$k]['changTotal'] = $this->numofperact->getChangTotal($v['pid']);
  80. $this->data['conArray'][$k]['currdone'] = $this->numofperact->getCurrDoneNow($v['pid']);
  81. $this->data['conArray'][$k]['contracttotal'] = $this->actmeasure->getTotalWithPid($v['pid']);
  82. if ($this->data['conArray'][$k]['contracttotal']) {
  83. $this->data['conArray'][$k]['pcurrdone'] = round(($this->data['conArray'][$k]['currdone'] / $this->data['conArray'][$k]['contracttotal']) * 100) . '%';
  84. } else {
  85. $this->data['conArray'][$k]['pcurrdone'] = '0%';
  86. }
  87. $this->data['conArray'][$k]['bcontracttotal'] = number_format($this->data['conArray'][$k]['contracttotal'], 2, '.', ',');
  88. $this->data['conArray'][$k]['bchangTotal'] = number_format($this->data['conArray'][$k]['changTotal'], 2, '.', ',');
  89. }
  90. }
  91. $this->render('s-project', $this->data, TRUE);
  92. }
  93. public function proOverview()
  94. {
  95. // $this->data['pros'] = $this->project->getAll();
  96. // if (isset($_POST['pname']) && $_POST['pname']) {
  97. // $this->project->insertProject($_POST['pname']);
  98. // return Doo::conf()->APP_URL . 'project/index';
  99. // }
  100. $this->data['pid'] = $this->params['pid'];
  101. $this->render('w-project-detail', $this->data);
  102. }
  103. public function proSection()
  104. {
  105. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  106. foreach ($proArray as $v) {
  107. $pidArray[] = $v['pid'];
  108. }
  109. $pidstr = implode(',', $pidArray);
  110. // 项目名称
  111. $this->data['allproArray'] = $this->project->getFewRow($pidstr);
  112. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  113. // 标段按月进度
  114. // for ($i = 1; $i <= 7; $i++) {
  115. // $monthz[] = date('n月', strtotime('+' . $i . ' months', $this->data['currproArray']['intime']));
  116. // if ($i == 1) {
  117. // $ii = date('Y年', $this->data['currproArray']['intime']) . date('n月', strtotime('+' . $i . ' months', $this->data['currproArray']['intime']));
  118. // } else {
  119. // $ii = date('n月', strtotime('+' . $i . ' months', $this->data['currproArray']['intime']));
  120. // }
  121. // $this->data['months'][$i]['month'] = $ii;
  122. // }
  123. // 标段
  124. // 搜索有没有相应的月份,有就把实际赋值,没有就为零
  125. $this->data['MeasureArray'] = $this->actmeasure->getRowsByPid($this->params['pid']);
  126. $totalstid = 0;
  127. $monthArray = [];
  128. foreach ($this->data['MeasureArray'] as $key => $value) {
  129. $this->data['MeasureArray'][$key]['pmid'] = $value['pmid'];
  130. $this->data['MeasureArray'][$key]['type'] = $this->contractact->getRowByStid($value['stid'])['stname'];
  131. $totalstid += $this->actmeasure->getTotal($value['stid'])['total'];
  132. // $numArray = $this->numofperact->getRowByPmid2($value['pmid']);
  133. // $num = $num1 = 0;
  134. // $this->data['MeasureArray'][$key]['num'] = $this->data['MeasureArray'][$key]['num1'] = NULL;
  135. // foreach ($numArray as $k => $v) {
  136. // if ($v['currstatus'] == 'checked') {
  137. // $monthInt = date('n月', $v['audittime']);
  138. // $retval = in_array($monthInt, $monthz);
  139. // if ($retval) {
  140. // $num = round(($v['currdone'] / $value['contracttotal']) * 100);
  141. // $num1 = round(($v['curralltotal'] / $value['contracttotal']) * 100);
  142. // }
  143. // }
  144. // $this->data['MeasureArray'][$key]['num'] .= $num . ',';
  145. // $this->data['MeasureArray'][$key]['num1'] .= $num1 . ',';
  146. // }
  147. $this->data['MeasureArray'][$key]['totalnum'] = $this->numofperact->getCountTotalnum($value['pmid']);
  148. $this->data['MeasureArray'][$key]['totalplus'] = number_format($this->actmeasure->getRowByPmid($value['pmid'])['contracttotal'], 2, '.', ',');
  149. $this->data['MeasureArray'][$key]['stopnow'] = $this->numofperact->getStopNowTotal($value['pmid'])['sntotal'];
  150. $this->data['MeasureArray'][$key]['nstopnow'] = number_format($this->numofperact->getStopNowTotal($value['pmid'])['sntotal'], 2, '.', ',');
  151. $this->data['MeasureArray'][$key]['currdone'] = $this->numofperact->getCurrdoneNew($value['pmid'])['currtotal'];
  152. $this->data['MeasureArray'][$key]['ncurrdone'] = number_format($this->data['MeasureArray'][$key]['currdone'], 2, '.', ',');
  153. $this->data['MeasureArray'][$key]['pstopnow'] = '0%';
  154. $this->data['MeasureArray'][$key]['pcurrdone'] = '0%';
  155. $this->data['MeasureArray'][$key]['pless'] = '0%';
  156. if ($value['contracttotal'] > 0) {
  157. $this->data['MeasureArray'][$key]['pstopnow'] = round(($this->data['MeasureArray'][$key]['stopnow'] / $value['contracttotal']) * 100);
  158. $this->data['MeasureArray'][$key]['dispstopnow'] = $this->data['MeasureArray'][$key]['pstopnow'] . '%';
  159. $this->data['MeasureArray'][$key]['pcurrdone'] = round(($this->data['MeasureArray'][$key]['currdone'] / $value['contracttotal']) * 100);
  160. $this->data['MeasureArray'][$key]['dispcurrdone'] = $this->data['MeasureArray'][$key]['pcurrdone'] . '%';
  161. $this->data['MeasureArray'][$key]['pless'] = (100 - $this->data['MeasureArray'][$key]['pstopnow'] - $this->data['MeasureArray'][$key]['pcurrdone']) . '%';
  162. }
  163. $this->data['MeasureArray'][$key]['nless'] = number_format($value['contracttotal'] - $this->data['MeasureArray'][$key]['stopnow'] - $this->data['MeasureArray'][$key]['currdone'], 2, '.', ',');
  164. $tenderArray = $this->numofperact->getRowTender2($value['pmid']);
  165. $this->data['MeasureArray'][$key]['ownstatus'] = '审批中';
  166. $ownerStatusArray = $this->measureauditact->getStatusTen($tenderArray['pmid'], $tenderArray['numpname']);
  167. if (isset($ownerStatusArray[0]['last']) && isset($ownerStatusArray[0]['mastatus']))
  168. if (($ownerStatusArray[0]['last'] == 1) && ($ownerStatusArray[0]['mastatus'] == 'checked')) {
  169. $this->data['MeasureArray'][$key]['ownstatus'] = '已审批';
  170. } else {
  171. $this->data['MeasureArray'][$key]['ownstatus'] = '审批中';
  172. }
  173. // 分组出年月 每个月份的独立相加 累计完成总量
  174. $month = $this->numofperact->getCurrTotalStMonthNoCheckno($value['stid']);
  175. foreach ($month as $k => $v) {
  176. $allmonth[] = $v;
  177. if (!in_array($v['month'], $monthArray))
  178. $monthArray[] = $v['month'];
  179. }
  180. // 分组出年月 每个月份的独立相加 本月完成总量
  181. $month1 = $this->numofperact->getCurrDoneStMonthNoCheckno($value['stid']);
  182. foreach ($month1 as $k => $v) {
  183. $allmonth1[] = $v;
  184. }
  185. }
  186. // 中文表述年月
  187. $total = $total1 = array();
  188. $startyear = $cnymArray = array();
  189. foreach ($monthArray as $kk => $vv) {
  190. $ymarray = explode('-', $vv);
  191. if (!in_array($ymarray[0], $startyear))
  192. $startyear[] = $ymarray[0];
  193. }
  194. $thismonth = 0;
  195. foreach($startyear as $sk => $sv){
  196. for($i = 1; $i <= 12; $i++){
  197. $j = $i < 10 ? '0'.$i : $i;
  198. $month = $sv.'-'.$j;
  199. $thismonth1 = 0;
  200. foreach ($allmonth as $keyk => $valuev) {
  201. if ($valuev['month'] == $month)
  202. $thismonth += $valuev['currtotal'];
  203. }
  204. $total[] = $thismonth != 0 ? $thismonth : 0;
  205. foreach ($allmonth1 as $k1 => $v1) {
  206. if ($v1['month'] == $month)
  207. $thismonth1 += $v1['currdone'];
  208. }
  209. $total1[] = $thismonth1 != 0 ? $thismonth1 : 0;
  210. $cnymArray[] = $i == 1 ? '\'' .$sv.'年'.$i.'月'. '\'' : '\'' .$i.'月'. '\'';
  211. }
  212. }
  213. foreach ($total as $value2) {
  214. $total3[] = round(($value2 / $totalstid) * 100);
  215. }
  216. foreach ($total1 as $value11) {
  217. $total4[] = round(($value11 / $totalstid) * 100);
  218. }
  219. $this->data['projectDate'] = implode(',', $cnymArray);
  220. $this->data['t1'] = implode(',', $total3);
  221. $this->data['t2'] = implode(',', $total4);
  222. $this->render('s-project-section', $this->data, TRUE);
  223. }
  224. public function proDetail()
  225. {
  226. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  227. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  228. foreach ($proArray as $v) {
  229. $pidArray[] = $v['pid'];
  230. }
  231. $pidstr = implode(',', $pidArray);
  232. // 项目名称
  233. $allproArray = $this->project->getFewRow($pidstr);
  234. // 面包屑导航项目
  235. foreach ($allproArray as $kk => $vv) {
  236. if ($vv['pid'] == $this->params['pid']) {
  237. $this->data['currproArray'] = $vv;
  238. } else {
  239. $this->data['allproArray'][] = $vv;
  240. }
  241. }
  242. // 面包屑导航合同
  243. $conArray = $this->contractact->getAll();
  244. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  245. if (isset($measureArray['stid'])) {
  246. foreach ($conArray as $kkk => $vvv) {
  247. if ($vvv['stid'] == $measureArray['stid']) {
  248. $this->data['currconArray'] = $vvv;
  249. } else {
  250. if ($vvv['pid'] == $this->params['pid'])
  251. $this->data['allconArray'][] = $vvv;
  252. }
  253. }
  254. } else {
  255. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  256. }
  257. // 面包屑导航标段
  258. $this->data['curractmeasureArray'] = NULL;
  259. $this->data['allactmeasureArray'] = [];
  260. $actmeasureArray = $this->actmeasure->getAll();
  261. foreach ($actmeasureArray as $kkkk => $vvvv) {
  262. if ($vvvv['stid'] == $measureArray['stid']) {
  263. if (($vvvv['pmid'] == $this->params['pmid'])) {
  264. $this->data['curractmeasureArray'] = $vvvv;
  265. } else {
  266. $this->data['allactmeasureArray'][] = $vvvv;
  267. }
  268. }
  269. }
  270. // 图标
  271. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  272. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  273. foreach ($this->data['MeasureArray'] as $key => $value) {
  274. if ($value['currdone'] > 0 && $measureArray['contracttotal'] > $value['currdone']) {
  275. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  276. } else {
  277. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  278. }
  279. }
  280. $this->data['pid'] = $this->params['pid'];
  281. $this->data['pmid'] = $this->params['pmid'];
  282. // 获取当前合同段的期数
  283. // $this->data['allNumArray'] = $this->numofperact->getNumByStid(1);
  284. $this->render('s-project-section-detail', $this->data, TRUE);
  285. }
  286. public function proMeasure()
  287. {
  288. $MpidArray = $this->measureauditact->getRowByMpid(1);
  289. foreach ($MpidArray as $key => $value) {
  290. $uidArray = $value['uid'];
  291. }
  292. $this->data['pid'] = $this->params['pid'];
  293. $this->render('s-project-section-measure', $this->data);
  294. }
  295. Function fNumber($number)
  296. {
  297. if ($number == '')
  298. Return "-";
  299. $nlen = strlen($number);
  300. while ($nlen > 3) {
  301. $fNumber = "," . substr($number, $nlen - 3, 3);
  302. $number = substr($number, 0, -3);
  303. $nlen = strlen($number);
  304. }
  305. if ($nlen <= 3) {
  306. $fNumber = $number . $fNumber;
  307. }
  308. Return $fNumber;
  309. }
  310. public function welcome()
  311. {
  312. // if (!$this->auth->isLoggedIn())
  313. // return Doo::conf()->APP_URL;
  314. if ($this->profile->getProWithUid($_SESSION['uid'])['userid'])
  315. return Doo::conf()->APP_URL . 'project/list';
  316. if (isset($_POST['welform'])) {
  317. $profileUserArray = $_POST;
  318. $profileUserArray['userid'] = $_SESSION['uid'];
  319. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  320. return Doo::conf()->APP_URL . 'project/list';
  321. }
  322. $this->render('welcome', $this->data);
  323. }
  324. public function prolist()
  325. {
  326. // if (!$this->auth->isLoggedIn())
  327. // return Doo::conf()->APP_URL;
  328. // $proArray = new stdClass();
  329. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  330. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  331. // if ($handle = opendir($extPathdir)) {
  332. // while (false !== ($file = readdir($handle))) {
  333. // $filename = pathinfo($file);
  334. // if ($filename['extension'] == 'json')
  335. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  336. // }
  337. // closedir($handle);
  338. // }
  339. // $this->data['proArray'] = null;
  340. $this->render('s-project', $this->data);
  341. }
  342. function proSectionFiles()
  343. {
  344. if (isset($_POST['optype']) && ($_POST['optype'] == 'replace') && ($_POST['imnid'])) {
  345. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  346. if ($imnidArray['iaid'] > 0) {
  347. $fileArray = $this->upItemFile('file')[0];
  348. if (isset($fileArray['filepath'])) {
  349. $itemArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  350. if (isset($itemArray)) {
  351. if ($itemArray['oldiaid'] > 0) {
  352. $oldiaid = $itemArray['oldiaid'];
  353. } else {
  354. $oldiaid = $imnidArray['iaid'];
  355. }
  356. $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);
  357. $iaid = $this->itemfle->insertItemFileRecord($postArray);
  358. if ($iaid > 1) {
  359. $this->itemmeasurenum->updateIAID($imnidArray['iaid'], $iaid);
  360. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  361. die();
  362. }
  363. }
  364. }
  365. }
  366. }
  367. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  368. ini_set('display_errors', 1);
  369. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  370. if ($imnidArray['iaid'] > 0) {
  371. $this->itemmeasurenum->updateDeltag($_POST['imnid'], $this->auth->getUid());
  372. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  373. die();
  374. }
  375. }
  376. if (isset($_POST['filename']) && isset($_POST['filedesc']) && isset($_POST['upimnid'])) {
  377. $filename = $_POST['filename'];
  378. $filedesc = $_POST['filedesc'];
  379. $imnidArray = $this->itemmeasurenum->getRowData($_POST['upimnid']);
  380. if ($imnidArray['iaid'] > 0) {
  381. if (isset($filedesc))
  382. $this->itemmeasurenum->updateItemFields($_POST['upimnid'], $filedesc, 0);
  383. if (isset($filename))
  384. $this->itemfle->updateItemFields($imnidArray['iaid'], $filename, 0);
  385. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  386. die();
  387. }
  388. }
  389. // 面包屑导航项目
  390. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  391. $this->data['pmid'] = $this->params['pmid'];
  392. $allproArray = $this->project->getAll();
  393. foreach ($allproArray as $kk => $vv) {
  394. if ($vv['pid'] == $this->params['pid']) {
  395. $this->data['currproArray'] = $vv;
  396. } else {
  397. $this->data['allproArray'][] = $vv;
  398. }
  399. }
  400. // 面包屑导航合同
  401. $conArray = $this->contractact->getAll();
  402. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  403. if (isset($measureArray['stid'])) {
  404. foreach ($conArray as $kkk => $vvv) {
  405. if ($vvv['stid'] == $measureArray['stid']) {
  406. $this->data['currconArray'] = $vvv;
  407. } else {
  408. if ($vvv['pid'] == $this->params['pid'])
  409. $this->data['allconArray'][] = $vvv;
  410. }
  411. }
  412. } else {
  413. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  414. }
  415. // 面包屑导航标段
  416. $this->data['curractmeasureArray'] = NULL;
  417. $this->data['allactmeasureArray'] = [];
  418. $actmeasureArray = $this->actmeasure->getAll();
  419. foreach ($actmeasureArray as $kkkk => $vvvv) {
  420. if ($vvvv['stid'] == $measureArray['stid']) {
  421. if (($vvvv['pmid'] == $this->params['pmid'])) {
  422. $this->data['curractmeasureArray'] = $vvvv;
  423. } else {
  424. $this->data['allactmeasureArray'][] = $vvvv;
  425. }
  426. }
  427. }
  428. // 选取查询
  429. $groupArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  430. $this->data['groupArray'] = $groupArray;
  431. $owneridArray = $this->itemfle->getGroupOwnerid($this->params['pmid']);
  432. foreach ($owneridArray as $k => $v) {
  433. $this->data['owneridArray'][$k]['name'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  434. $this->data['owneridArray'][$k]['iaid'] = $v['iaid'];
  435. $this->data['owneridArray'][$k]['ownerid'] = $v['ownerid'];
  436. }
  437. // 分页
  438. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid'], 0, $this->params['numpname'], $this->params['userid']);
  439. if ($totalArchive) {
  440. if ($this->params['numpname'] && $this->params['userid']) {
  441. $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);
  442. } elseif ($this->params['numpname']) {
  443. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/num/' . $this->params['numpname'] . '/page', $totalArchive, 20, 100);
  444. } elseif ($this->params['userid']) {
  445. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/user/' . $this->params['userid'] . '/page', $totalArchive, 20, 100);
  446. } else {
  447. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/page', $totalArchive, 20, 100);
  448. }
  449. $pager->setCss('', 'disabled', 'active');
  450. if (isset($this->params['pindex']))
  451. $pager->paginate(intval($this->params['pindex']));
  452. else
  453. $pager->paginate(1);
  454. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNum($this->params['pmid'], $pager->limit, $this->params['numpname'], $this->params['userid']);
  455. }
  456. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  457. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  458. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  459. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  460. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  461. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  462. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  463. }
  464. $this->data['pid'] = $this->params['pid'];
  465. $this->data['pmid'] = $this->params['pmid'];
  466. $this->data['mpid'] = $this->params['mpid'];
  467. $this->data['userid'] = $this->params['userid'];
  468. $this->data['num'] = $this->params['numpname'];
  469. $this->data['pager'] = $pager->output;
  470. $this->render('s-project-section-files', $this->data, TRUE);
  471. }
  472. function proSectionFilesRecover()
  473. {
  474. if (isset($_POST['optype']) && ($_POST['optype'] == 'reconvery') && isset($_POST['imnid'])) {
  475. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  476. if ($imnidArray['iaid'] > 0) {
  477. $this->itemmeasurenum->recoveryDel($_POST['imnid']);
  478. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  479. die();
  480. }
  481. }
  482. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  483. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  484. if ($imnidArray['iaid'] > 0) {
  485. $iaidArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  486. if ($iaidArray['ownerid'] == $this->auth->getUid()) {
  487. $this->itemfle->delItem($imnidArray['iaid']);
  488. $this->itemmeasurenum->delItemIAID($imnidArray['iaid']);
  489. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  490. die();
  491. } else {
  492. echo json_encode(array('status' => 2), JSON_UNESCAPED_UNICODE);
  493. die();
  494. }
  495. }
  496. }
  497. // 面包屑导航项目
  498. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  499. $this->data['pmid'] = $this->params['pmid'];
  500. $allproArray = $this->project->getAll();
  501. foreach ($allproArray as $kk => $vv) {
  502. if ($vv['pid'] == $this->params['pid']) {
  503. $this->data['currproArray'] = $vv;
  504. } else {
  505. $this->data['allproArray'][] = $vv;
  506. }
  507. }
  508. // 面包屑导航合同
  509. $conArray = $this->contractact->getAll();
  510. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  511. if (isset($measureArray['stid'])) {
  512. foreach ($conArray as $kkk => $vvv) {
  513. if ($vvv['stid'] == $measureArray['stid']) {
  514. $this->data['currconArray'] = $vvv;
  515. } else {
  516. if ($vvv['pid'] == $this->params['pid'])
  517. $this->data['allconArray'][] = $vvv;
  518. }
  519. }
  520. } else {
  521. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  522. }
  523. // 面包屑导航标段
  524. $this->data['curractmeasureArray'] = NULL;
  525. $this->data['allactmeasureArray'] = [];
  526. $actmeasureArray = $this->actmeasure->getAll();
  527. foreach ($actmeasureArray as $kkkk => $vvvv) {
  528. if ($vvvv['stid'] == $measureArray['stid']) {
  529. if (($vvvv['pmid'] == $this->params['pmid'])) {
  530. $this->data['curractmeasureArray'] = $vvvv;
  531. } else {
  532. $this->data['allactmeasureArray'][] = $vvvv;
  533. }
  534. }
  535. }
  536. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid']);
  537. if ($totalArchive) {
  538. $pager = new DooPager(Doo::conf()->APP_URL . 'sproject/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/recover/page', $totalArchive, 20, 100);
  539. $pager->setCss('', 'disabled', 'active');
  540. if (isset($this->params['pindex']))
  541. $pager->paginate(intval($this->params['pindex']));
  542. else
  543. $pager->paginate(1);
  544. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNumDel($pager->limit, $this->params['pmid']);
  545. }
  546. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  547. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  548. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  549. $this->data['itemMeasureArray'][$k]['delname'] = $this->profile->getProWithUid($v['deluid'])['name'];
  550. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  551. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  552. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  553. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  554. $this->data['itemMeasureArray'][$k]['filepath'] = $fileArray['filepath'];
  555. }
  556. $this->data['pid'] = $this->params['pid'];
  557. $this->data['pmid'] = $this->params['pmid'];
  558. $this->data['mpid'] = $this->params['mpid'];
  559. $this->data['pager'] = $pager->output;
  560. $this->render('s-project-section-files-recover', $this->data, TRUE);
  561. }
  562. /**
  563. * @return actMeasure
  564. */
  565. public function proSectionGetFiles()
  566. {
  567. $attaArray = $this->itemfile->getItemFile($this->params['iaid']);
  568. $this->file_down($attaArray['filepath'], $attaArray['filesize'], $attaArray['filename'] . '.' . $attaArray['fileext']);
  569. return;
  570. }
  571. /**
  572. * 文件下载
  573. * @param $filepath 文件路径
  574. * @param $filename 文件名称
  575. */
  576. function file_down($filepath, $filesize, $filename = '')
  577. {
  578. if (!$filename)
  579. $filename = basename($filepath);
  580. if ($this->is_ie())
  581. $filename = rawurlencode($filename);
  582. $filetype = $this->fileext($filename);
  583. // $filesize = sprintf("%u", filesize($filepath));
  584. if (ob_get_length() !== false)
  585. @ob_end_clean();
  586. header('Pragma: public');
  587. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  588. header('Cache-Control: no-store, no-cache, must-revalidate');
  589. header('Cache-Control: pre-check=0, post-check=0, max-age=0');
  590. header('Content-Transfer-Encoding: binary');
  591. header('Content-Encoding: none');
  592. header('Content-type: ' . $filetype);
  593. header('Content-Disposition: attachment; filename="' . $filename . '"');
  594. header('Content-length: ' . $filesize);
  595. @readfile($filepath);
  596. exit;
  597. }
  598. /**
  599. * IE浏览器判断
  600. */
  601. function is_ie()
  602. {
  603. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  604. if ((strpos($useragent, 'opera') !== false) || (strpos($useragent, 'konqueror') !== false))
  605. return false;
  606. if (strpos($useragent, 'msie ') !== false)
  607. return true;
  608. return false;
  609. }
  610. /**
  611. * 取得文件扩展
  612. *
  613. * @param $filename 文件名
  614. * @return 扩展名
  615. */
  616. function fileext($filename)
  617. {
  618. return strtolower(trim(substr(strrchr($filename, '.'), 1, 10)));
  619. }
  620. }
  621. ?>