SProjectController.php 31 KB

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