SProjectController.php 31 KB

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