SProjectController.php 31 KB

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