SProjectController.php 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  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. $this->data['numofchecking'] = 0;
  61. foreach ($mpidArray as $key => $value) {
  62. // 审批操作按照时间排序多标段
  63. $this->data['numofchecking'] += $this->measureauditact->getCountMyChecking($value['pid'], $this->auth->getUid());
  64. }
  65. }
  66. if (!isset($this->data['numofchecking']) || $this->data['numofchecking'] == 0) {
  67. $this->data['numofchecking'] = null;
  68. }
  69. $this->data['signSwitch'] = $this->aconfig->getOne(array('select' => 'signswitch', 'asArray' => TRUE))['signswitch'];
  70. //获取需要您签署的数目
  71. if($this->data['signSwitch'] > 0)
  72. $this->data['needSignNum'] = $this->sign->getNeedSignNumbyUid($this->auth->getUid()) != 0 ? $this->sign->getNeedSignNumbyUid($this->auth->getUid()) : '';
  73. //获取桌面版本
  74. $this->getsoftware();
  75. //草图入口
  76. $this->data['imediateSwitch'] = $this->aconfig->getOne(array('select' => 'imediateswitch', 'asArray' => TRUE))['imediateswitch'];
  77. }
  78. function getsoftware(){
  79. $StrJson = ($this->aconfig->getOne(array('select' => 'upgradeinfo', 'asArray' => TRUE))['upgradeinfo']);
  80. $upgradeinfo = json_decode($StrJson, true);
  81. if ($upgradeinfo) {
  82. $this->data['version'] = $upgradeinfo['version'];
  83. $this->data['download'] = $upgradeinfo['download'];
  84. }
  85. }
  86. public function index()
  87. {
  88. $this->data['conArray'] = NULL;
  89. $conArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  90. if (isset($conArray)) {
  91. foreach ($conArray as $k => $v) {
  92. $proArray = $this->project->getRowByPid($v['pid']);
  93. $this->data['conArray'][] = $proArray;
  94. $profileArray = $this->profile->getProWithUid($proArray['uid']);
  95. $this->data['conArray'][$k]['company'] = $profileArray['company'];
  96. $countMeasureInt = $this->actmeasure->getCountMeasure($v['stid']);
  97. $countTotalMeasureInt = $this->actmeasure->getMearsureCount($v['pid']);
  98. $this->data['conArray'][$k]['countmeasure'] = $countMeasureInt;
  99. $this->data['conArray'][$k]['countTotalMeasureInt'] = $countTotalMeasureInt;
  100. $this->data['conArray'][$k]['changTotal'] = $this->numofperact->getChangTotal($v['pid']);
  101. $this->data['conArray'][$k]['currdone'] = $this->numofperact->getCurrDoneNow($v['pid']);
  102. $this->data['conArray'][$k]['contracttotal'] = $this->actmeasure->getTotalWithPid($v['pid']);
  103. if ($this->data['conArray'][$k]['contracttotal']) {
  104. $this->data['conArray'][$k]['pcurrdone'] = round(($this->data['conArray'][$k]['currdone'] / $this->data['conArray'][$k]['contracttotal']) * 100) . '%';
  105. } else {
  106. $this->data['conArray'][$k]['pcurrdone'] = '0%';
  107. }
  108. $this->data['conArray'][$k]['bcontracttotal'] = number_format($this->data['conArray'][$k]['contracttotal'], 2, '.', ',');
  109. $this->data['conArray'][$k]['bchangTotal'] = number_format($this->data['conArray'][$k]['changTotal'], 2, '.', ',');
  110. $this->data['conArray'][$k]['index'] = $k%8+1;
  111. }
  112. }
  113. $this->render('s-project', $this->data, TRUE);
  114. }
  115. public function proOverview()
  116. {
  117. // $this->data['pros'] = $this->project->getAll();
  118. // if (isset($_POST['pname']) && $_POST['pname']) {
  119. // $this->project->insertProject($_POST['pname']);
  120. // return Doo::conf()->APP_URL . 'project/index';
  121. // }
  122. $this->data['pid'] = $this->params['pid'];
  123. $this->render('w-project-detail', $this->data);
  124. }
  125. public function proSection()
  126. {
  127. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  128. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  129. foreach ($proArray as $v) {
  130. $pidArray[] = $v['pid'];
  131. }
  132. $pidstr = implode(',', $pidArray);
  133. // 项目名称
  134. $allproArray = $this->project->getFewRow($pidstr);
  135. // 面包屑导航项目
  136. foreach ($allproArray as $kk => $vv) {
  137. if ($vv['pid'] == $this->params['pid']) {
  138. $this->data['currproArray'] = $vv;
  139. } else {
  140. $this->data['allproArray'][] = $vv;
  141. }
  142. }
  143. // 标段按月进度
  144. // for ($i = 1; $i <= 7; $i++) {
  145. // $monthz[] = date('n月', strtotime('+' . $i . ' months', $this->data['currproArray']['intime']));
  146. // if ($i == 1) {
  147. // $ii = date('Y年', $this->data['currproArray']['intime']) . date('n月', strtotime('+' . $i . ' months', $this->data['currproArray']['intime']));
  148. // } else {
  149. // $ii = date('n月', strtotime('+' . $i . ' months', $this->data['currproArray']['intime']));
  150. // }
  151. // $this->data['months'][$i]['month'] = $ii;
  152. // }
  153. // 标段
  154. // 搜索有没有相应的月份,有就把实际赋值,没有就为零
  155. $this->data['MeasureArray'] = $this->actmeasure->getRowsByPid($this->params['pid']);
  156. $totalstid = 0;
  157. $monthArray = [];
  158. foreach ($this->data['MeasureArray'] as $key => $value) {
  159. $this->data['MeasureArray'][$key]['pmid'] = $value['pmid'];
  160. $this->data['MeasureArray'][$key]['type'] = $this->contractact->getRowByStid($value['stid'])['stname'];
  161. $totalstid += $this->actmeasure->getTotal($value['stid'])['total'];
  162. // $numArray = $this->numofperact->getRowByPmid2($value['pmid']);
  163. // $num = $num1 = 0;
  164. // $this->data['MeasureArray'][$key]['num'] = $this->data['MeasureArray'][$key]['num1'] = NULL;
  165. // foreach ($numArray as $k => $v) {
  166. // if ($v['currstatus'] == 'checked') {
  167. // $monthInt = date('n月', $v['audittime']);
  168. // $retval = in_array($monthInt, $monthz);
  169. // if ($retval) {
  170. // $num = round(($v['currdone'] / $value['contracttotal']) * 100);
  171. // $num1 = round(($v['curralltotal'] / $value['contracttotal']) * 100);
  172. // }
  173. // }
  174. // $this->data['MeasureArray'][$key]['num'] .= $num . ',';
  175. // $this->data['MeasureArray'][$key]['num1'] .= $num1 . ',';
  176. // }
  177. $this->data['MeasureArray'][$key]['totalnum'] = $this->numofperact->getCountTotalnum($value['pmid']);
  178. $this->data['MeasureArray'][$key]['totalplus'] = number_format($this->actmeasure->getRowByPmid($value['pmid'])['contracttotal'], 2, '.', ',');
  179. $this->data['MeasureArray'][$key]['stopnow'] = $this->numofperact->getStopNowTotal($value['pmid'])['sntotal'];
  180. $this->data['MeasureArray'][$key]['nstopnow'] = number_format($this->numofperact->getStopNowTotal($value['pmid'])['sntotal'], 2, '.', ',');
  181. $this->data['MeasureArray'][$key]['currdone'] = $this->numofperact->getCurrdoneNew($value['pmid'])['currtotal'];
  182. $this->data['MeasureArray'][$key]['ncurrdone'] = number_format($this->data['MeasureArray'][$key]['currdone'], 2, '.', ',');
  183. $this->data['MeasureArray'][$key]['pstopnow'] = '0%';
  184. $this->data['MeasureArray'][$key]['pcurrdone'] = '0%';
  185. $this->data['MeasureArray'][$key]['pless'] = '0%';
  186. if ($value['contracttotal'] > 0) {
  187. $this->data['MeasureArray'][$key]['pstopnow'] = round(($this->data['MeasureArray'][$key]['stopnow'] / $value['contracttotal']) * 100);
  188. $this->data['MeasureArray'][$key]['dispstopnow'] = $this->data['MeasureArray'][$key]['pstopnow'] . '%';
  189. $this->data['MeasureArray'][$key]['pcurrdone'] = round(($this->data['MeasureArray'][$key]['currdone'] / $value['contracttotal']) * 100);
  190. $this->data['MeasureArray'][$key]['dispcurrdone'] = $this->data['MeasureArray'][$key]['pcurrdone'] . '%';
  191. $this->data['MeasureArray'][$key]['pless'] = (100 - $this->data['MeasureArray'][$key]['pstopnow'] - $this->data['MeasureArray'][$key]['pcurrdone']) . '%';
  192. }
  193. $this->data['MeasureArray'][$key]['nless'] = number_format($value['contracttotal'] - $this->data['MeasureArray'][$key]['stopnow'] - $this->data['MeasureArray'][$key]['currdone'], 2, '.', ',');
  194. $tenderArray = $this->numofperact->getRowTender2($value['pmid']);
  195. $this->data['MeasureArray'][$key]['ownstatus'] = '审批中';
  196. $ownerStatusArray = $this->measureauditact->getStatusTen($tenderArray['pmid'], $tenderArray['numpname']);
  197. if (isset($ownerStatusArray[0]['last']) && isset($ownerStatusArray[0]['mastatus']))
  198. if (($ownerStatusArray[0]['last'] == 1) && ($ownerStatusArray[0]['mastatus'] == 'checked')) {
  199. $this->data['MeasureArray'][$key]['ownstatus'] = '已审批';
  200. } else {
  201. $this->data['MeasureArray'][$key]['ownstatus'] = '审批中';
  202. }
  203. // 分组出年月 每个月份的独立相加 累计完成总量
  204. $month = $this->numofperact->getCurrTotalStMonthNoCheckno($value['stid']);
  205. foreach ($month as $k => $v) {
  206. $allmonth[] = $v;
  207. if (!in_array($v['month'], $monthArray))
  208. $monthArray[] = $v['month'];
  209. }
  210. // 分组出年月 每个月份的独立相加 本月完成总量
  211. $month1 = $this->numofperact->getCurrDoneStMonthNoCheckno($value['stid']);
  212. foreach ($month1 as $k => $v) {
  213. $allmonth1[] = $v;
  214. }
  215. }
  216. // 中文表述年月
  217. $total = $total1 = array();
  218. $startyear = $cnymArray = array();
  219. foreach ($monthArray as $kk => $vv) {
  220. $ymarray = explode('-', $vv);
  221. if (!in_array($ymarray[0], $startyear))
  222. $startyear[] = $ymarray[0];
  223. }
  224. $thismonth = 0;
  225. foreach($startyear as $sk => $sv){
  226. for($i = 1; $i <= 12; $i++){
  227. $j = $i < 10 ? '0'.$i : $i;
  228. $month = $sv.'-'.$j;
  229. $thismonth1 = 0;
  230. foreach ($allmonth1 as $k1 => $v1) {
  231. if ($v1['month'] == $month)
  232. $thismonth1 += $v1['currdone'];
  233. }
  234. $total1[] = $thismonth1 != 0 ? $thismonth1 : 0;
  235. foreach ($allmonth as $keyk => $valuev) {
  236. if ($valuev['month'] == $month)
  237. $thismonth += $valuev['currtotal'];
  238. }
  239. $total[] = ($thismonth != 0 && $thismonth1 != 0) ? $thismonth : 0;
  240. $cnymArray[] = $i == 1 ? '\'' .$sv.'年'.$i.'月'. '\'' : '\'' .$i.'月'. '\'';
  241. }
  242. }
  243. foreach ($total as $value2) {
  244. $total3[] = round(($value2 / $totalstid) * 100);
  245. }
  246. foreach ($total1 as $value11) {
  247. $total4[] = round(($value11 / $totalstid) * 100);
  248. }
  249. $this->data['projectDate'] = implode(',', $cnymArray);
  250. $this->data['t1'] = implode(',', $total3);
  251. $this->data['t2'] = implode(',', $total4);
  252. $this->render('s-project-section', $this->data, TRUE);
  253. }
  254. public function proDetail()
  255. {
  256. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  257. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  258. foreach ($proArray as $v) {
  259. $pidArray[] = $v['pid'];
  260. }
  261. $pidstr = implode(',', $pidArray);
  262. // 项目名称
  263. $allproArray = $this->project->getFewRow($pidstr);
  264. // 面包屑导航项目
  265. foreach ($allproArray as $kk => $vv) {
  266. if ($vv['pid'] == $this->params['pid']) {
  267. $this->data['currproArray'] = $vv;
  268. } else {
  269. $this->data['allproArray'][] = $vv;
  270. }
  271. }
  272. // 面包屑导航合同
  273. $conArray = $this->contractact->getAll();
  274. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  275. if (isset($measureArray['stid'])) {
  276. foreach ($conArray as $kkk => $vvv) {
  277. if ($vvv['stid'] == $measureArray['stid']) {
  278. $this->data['currconArray'] = $vvv;
  279. } else {
  280. if ($vvv['pid'] == $this->params['pid'])
  281. $this->data['allconArray'][] = $vvv;
  282. }
  283. }
  284. } else {
  285. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  286. }
  287. // 面包屑导航标段
  288. $this->data['curractmeasureArray'] = NULL;
  289. $this->data['allactmeasureArray'] = [];
  290. $actmeasureArray = $this->actmeasure->getAll();
  291. foreach ($actmeasureArray as $kkkk => $vvvv) {
  292. if ($vvvv['stid'] == $measureArray['stid']) {
  293. if (($vvvv['pmid'] == $this->params['pmid'])) {
  294. $this->data['curractmeasureArray'] = $vvvv;
  295. } else {
  296. $this->data['allactmeasureArray'][] = $vvvv;
  297. }
  298. }
  299. }
  300. // 图标
  301. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  302. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  303. foreach ($this->data['MeasureArray'] as $key => $value) {
  304. if ($value['currdone'] > 0 && $measureArray['contracttotal'] > $value['currdone']) {
  305. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  306. } else {
  307. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  308. }
  309. }
  310. $this->data['pid'] = $this->params['pid'];
  311. $this->data['pmid'] = $this->params['pmid'];
  312. // 获取当前合同段的期数
  313. // $this->data['allNumArray'] = $this->numofperact->getNumByStid(1);
  314. $this->render('s-project-section-detail', $this->data, TRUE);
  315. }
  316. public function proMeasure()
  317. {
  318. $MpidArray = $this->measureauditact->getRowByMpid(1);
  319. foreach ($MpidArray as $key => $value) {
  320. $uidArray = $value['uid'];
  321. }
  322. $this->data['pid'] = $this->params['pid'];
  323. $this->render('s-project-section-measure', $this->data);
  324. }
  325. Function fNumber($number)
  326. {
  327. if ($number == '')
  328. Return "-";
  329. $nlen = strlen($number);
  330. while ($nlen > 3) {
  331. $fNumber = "," . substr($number, $nlen - 3, 3);
  332. $number = substr($number, 0, -3);
  333. $nlen = strlen($number);
  334. }
  335. if ($nlen <= 3) {
  336. $fNumber = $number . $fNumber;
  337. }
  338. Return $fNumber;
  339. }
  340. public function welcome()
  341. {
  342. // if (!$this->auth->isLoggedIn())
  343. // return Doo::conf()->APP_URL;
  344. if ($this->profile->getProWithUid($_SESSION['uid'])['userid'])
  345. return Doo::conf()->APP_URL . 'project/list';
  346. if (isset($_POST['welform'])) {
  347. $profileUserArray = $_POST;
  348. $profileUserArray['userid'] = $_SESSION['uid'];
  349. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  350. return Doo::conf()->APP_URL . 'project/list';
  351. }
  352. $this->render('welcome', $this->data);
  353. }
  354. public function prolist()
  355. {
  356. // if (!$this->auth->isLoggedIn())
  357. // return Doo::conf()->APP_URL;
  358. // $proArray = new stdClass();
  359. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  360. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  361. // if ($handle = opendir($extPathdir)) {
  362. // while (false !== ($file = readdir($handle))) {
  363. // $filename = pathinfo($file);
  364. // if ($filename['extension'] == 'json')
  365. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  366. // }
  367. // closedir($handle);
  368. // }
  369. // $this->data['proArray'] = null;
  370. $this->render('s-project', $this->data);
  371. }
  372. function proSectionFiles()
  373. {
  374. if (isset($_POST['optype']) && ($_POST['optype'] == 'replace') && ($_POST['imnid'])) {
  375. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  376. if ($imnidArray['iaid'] > 0) {
  377. $fileArray = $this->upItemFile('file')[0];
  378. if (isset($fileArray['filepath'])) {
  379. $itemArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  380. if (isset($itemArray)) {
  381. if ($itemArray['oldiaid'] > 0) {
  382. $oldiaid = $itemArray['oldiaid'];
  383. } else {
  384. $oldiaid = $imnidArray['iaid'];
  385. }
  386. $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);
  387. $iaid = $this->itemfle->insertItemFileRecord($postArray);
  388. if ($iaid > 1) {
  389. $this->itemmeasurenum->updateIAID($imnidArray['iaid'], $iaid);
  390. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  391. die();
  392. }
  393. }
  394. }
  395. }
  396. }
  397. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  398. ini_set('display_errors', 1);
  399. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  400. if ($imnidArray['iaid'] > 0) {
  401. $this->itemmeasurenum->updateDeltag($_POST['imnid'], $this->auth->getUid());
  402. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  403. die();
  404. }
  405. }
  406. if (isset($_POST['filename']) && isset($_POST['filedesc']) && isset($_POST['upimnid'])) {
  407. $filename = $_POST['filename'];
  408. $filedesc = $_POST['filedesc'];
  409. $imnidArray = $this->itemmeasurenum->getRowData($_POST['upimnid']);
  410. if ($imnidArray['iaid'] > 0) {
  411. if (isset($filedesc))
  412. $this->itemmeasurenum->updateItemFields($_POST['upimnid'], $filedesc, 0);
  413. if (isset($filename))
  414. $this->itemfle->updateItemFields($imnidArray['iaid'], $filename, 0);
  415. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  416. die();
  417. }
  418. }
  419. // 面包屑导航项目
  420. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  421. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  422. foreach ($proArray as $v) {
  423. $pidArray[] = $v['pid'];
  424. }
  425. $pidstr = implode(',', $pidArray);
  426. // 项目名称
  427. $allproArray = $this->project->getFewRow($pidstr);
  428. // 面包屑导航项目
  429. foreach ($allproArray as $kk => $vv) {
  430. if ($vv['pid'] == $this->params['pid']) {
  431. $this->data['currproArray'] = $vv;
  432. } else {
  433. $this->data['allproArray'][] = $vv;
  434. }
  435. }
  436. // 面包屑导航合同
  437. $conArray = $this->contractact->getAll();
  438. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  439. if (isset($measureArray['stid'])) {
  440. foreach ($conArray as $kkk => $vvv) {
  441. if ($vvv['stid'] == $measureArray['stid']) {
  442. $this->data['currconArray'] = $vvv;
  443. } else {
  444. if ($vvv['pid'] == $this->params['pid'])
  445. $this->data['allconArray'][] = $vvv;
  446. }
  447. }
  448. } else {
  449. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  450. }
  451. // 面包屑导航标段
  452. $this->data['curractmeasureArray'] = NULL;
  453. $this->data['allactmeasureArray'] = [];
  454. $actmeasureArray = $this->actmeasure->getAll();
  455. foreach ($actmeasureArray as $kkkk => $vvvv) {
  456. if ($vvvv['stid'] == $measureArray['stid']) {
  457. if (($vvvv['pmid'] == $this->params['pmid'])) {
  458. $this->data['curractmeasureArray'] = $vvvv;
  459. } else {
  460. $this->data['allactmeasureArray'][] = $vvvv;
  461. }
  462. }
  463. }
  464. // 选取查询
  465. $groupArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  466. $this->data['groupArray'] = $groupArray;
  467. $owneridArray = $this->itemfle->getGroupOwnerid($this->params['pmid']);
  468. foreach ($owneridArray as $k => $v) {
  469. $this->data['owneridArray'][$k]['name'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  470. $this->data['owneridArray'][$k]['iaid'] = $v['iaid'];
  471. $this->data['owneridArray'][$k]['ownerid'] = $v['ownerid'];
  472. }
  473. // 分页
  474. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid'], 0, $this->params['numpname'], $this->params['userid']);
  475. if ($totalArchive) {
  476. if ($this->params['numpname'] && $this->params['userid']) {
  477. $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);
  478. } elseif ($this->params['numpname']) {
  479. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/num/' . $this->params['numpname'] . '/page', $totalArchive, 20, 100);
  480. } elseif ($this->params['userid']) {
  481. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/user/' . $this->params['userid'] . '/page', $totalArchive, 20, 100);
  482. } else {
  483. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/page', $totalArchive, 20, 100);
  484. }
  485. $pager->setCss('', 'disabled', 'active');
  486. if (isset($this->params['pindex']))
  487. $pager->paginate(intval($this->params['pindex']));
  488. else
  489. $pager->paginate(1);
  490. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNum($this->params['pmid'], $pager->limit, $this->params['numpname'], $this->params['userid']);
  491. }
  492. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  493. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  494. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  495. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  496. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  497. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  498. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  499. }
  500. $this->data['pid'] = $this->params['pid'];
  501. $this->data['pmid'] = $this->params['pmid'];
  502. $this->data['mpid'] = $this->params['mpid'];
  503. $this->data['userid'] = $this->params['userid'];
  504. $this->data['num'] = $this->params['numpname'];
  505. $this->data['pager'] = $pager->output;
  506. $this->render('s-project-section-files', $this->data, TRUE);
  507. }
  508. function proSectionFilesRecover()
  509. {
  510. if (isset($_POST['optype']) && ($_POST['optype'] == 'reconvery') && isset($_POST['imnid'])) {
  511. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  512. if ($imnidArray['iaid'] > 0) {
  513. $this->itemmeasurenum->recoveryDel($_POST['imnid']);
  514. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  515. die();
  516. }
  517. }
  518. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  519. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  520. if ($imnidArray['iaid'] > 0) {
  521. $iaidArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  522. if ($iaidArray['ownerid'] == $this->auth->getUid()) {
  523. $this->itemfle->delItem($imnidArray['iaid']);
  524. $this->itemmeasurenum->delItemIAID($imnidArray['iaid']);
  525. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  526. die();
  527. } else {
  528. echo json_encode(array('status' => 2), JSON_UNESCAPED_UNICODE);
  529. die();
  530. }
  531. }
  532. }
  533. // 面包屑导航项目
  534. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  535. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  536. foreach ($proArray as $v) {
  537. $pidArray[] = $v['pid'];
  538. }
  539. $pidstr = implode(',', $pidArray);
  540. // 项目名称
  541. $allproArray = $this->project->getFewRow($pidstr);
  542. // 面包屑导航项目
  543. foreach ($allproArray as $kk => $vv) {
  544. if ($vv['pid'] == $this->params['pid']) {
  545. $this->data['currproArray'] = $vv;
  546. } else {
  547. $this->data['allproArray'][] = $vv;
  548. }
  549. }
  550. // 面包屑导航合同
  551. $conArray = $this->contractact->getAll();
  552. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  553. if (isset($measureArray['stid'])) {
  554. foreach ($conArray as $kkk => $vvv) {
  555. if ($vvv['stid'] == $measureArray['stid']) {
  556. $this->data['currconArray'] = $vvv;
  557. } else {
  558. if ($vvv['pid'] == $this->params['pid'])
  559. $this->data['allconArray'][] = $vvv;
  560. }
  561. }
  562. } else {
  563. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  564. }
  565. // 面包屑导航标段
  566. $this->data['curractmeasureArray'] = NULL;
  567. $this->data['allactmeasureArray'] = [];
  568. $actmeasureArray = $this->actmeasure->getAll();
  569. foreach ($actmeasureArray as $kkkk => $vvvv) {
  570. if ($vvvv['stid'] == $measureArray['stid']) {
  571. if (($vvvv['pmid'] == $this->params['pmid'])) {
  572. $this->data['curractmeasureArray'] = $vvvv;
  573. } else {
  574. $this->data['allactmeasureArray'][] = $vvvv;
  575. }
  576. }
  577. }
  578. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid']);
  579. if ($totalArchive) {
  580. $pager = new DooPager(Doo::conf()->APP_URL . 'sproject/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/recover/page', $totalArchive, 20, 100);
  581. $pager->setCss('', 'disabled', 'active');
  582. if (isset($this->params['pindex']))
  583. $pager->paginate(intval($this->params['pindex']));
  584. else
  585. $pager->paginate(1);
  586. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNumDel($pager->limit, $this->params['pmid']);
  587. }
  588. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  589. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  590. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  591. $this->data['itemMeasureArray'][$k]['delname'] = $this->profile->getProWithUid($v['deluid'])['name'];
  592. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  593. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  594. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  595. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  596. $this->data['itemMeasureArray'][$k]['filepath'] = $fileArray['filepath'];
  597. }
  598. $this->data['pid'] = $this->params['pid'];
  599. $this->data['pmid'] = $this->params['pmid'];
  600. $this->data['mpid'] = $this->params['mpid'];
  601. $this->data['pager'] = $pager->output;
  602. $this->render('s-project-section-files-recover', $this->data, TRUE);
  603. }
  604. /**
  605. * @return actMeasure
  606. */
  607. public function proSectionGetFiles()
  608. {
  609. $attaArray = $this->itemfile->getItemFile($this->params['iaid']);
  610. $this->file_down($attaArray['filepath'], $attaArray['filesize'], $attaArray['filename'] . '.' . $attaArray['fileext']);
  611. return;
  612. }
  613. public function proSectionInterMediate(){
  614. //草图功能开关控制
  615. if($this->data['imediateSwitch'] == 0){
  616. exit('中间计量表草图添加功能未启用...');
  617. }
  618. if(isset($_POST['delid']) && is_numeric($_POST['delid'])){
  619. //删除未签署报表数据和文件
  620. $signmsg = $this->sign->getOneSignbysid($_POST['delid']);
  621. if(empty($signmsg) && $signmsg['status'] == "checked" && $signmsg['ownuid'] != $this->auth->getUid()){
  622. exit(json_encode(array('code' => 400),JSON_UNESCAPED_UNICODE));
  623. }
  624. $this->sign->delSignbysid($_POST['delid'],$signmsg['status']);
  625. include (DOO::conf()->SITE_PATH . 'protected/plugin/io.han.php');
  626. $this->IoHandler = new IoHandler();
  627. $path = DOO::conf()->SITE_PATH."signs/".$_POST['delid'];
  628. $this->IoHandler->RemoveDir($path);
  629. exit(json_encode(array('code' => 200),JSON_UNESCAPED_UNICODE));
  630. }
  631. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  632. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  633. foreach ($proArray as $v) {
  634. $pidArray[] = $v['pid'];
  635. }
  636. $pidstr = implode(',', $pidArray);
  637. // 项目名称
  638. $allproArray = $this->project->getFewRow($pidstr);
  639. // 面包屑导航项目
  640. foreach ($allproArray as $kk => $vv) {
  641. if ($vv['pid'] == $this->params['pid']) {
  642. $this->data['currproArray'] = $vv;
  643. } else {
  644. $this->data['allproArray'][] = $vv;
  645. }
  646. }
  647. // 面包屑导航合同
  648. $conArray = $this->contractact->getAll();
  649. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  650. if (isset($measureArray['stid'])) {
  651. foreach ($conArray as $kkk => $vvv) {
  652. if ($vvv['stid'] == $measureArray['stid']) {
  653. $this->data['currconArray'] = $vvv;
  654. } else {
  655. if ($vvv['pid'] == $this->params['pid'])
  656. $this->data['allconArray'][] = $vvv;
  657. }
  658. }
  659. } else {
  660. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  661. }
  662. // 面包屑导航标段
  663. $this->data['curractmeasureArray'] = NULL;
  664. $this->data['allactmeasureArray'] = [];
  665. // $actmeasureArray = $this->actmeasure->getAll();
  666. $actmeasureArray = $this->actmeasure->getRowUser($this->auth->getUid());
  667. foreach ($actmeasureArray as $kkkk => $vvvv) {
  668. if ($vvvv['stid'] == $measureArray['stid']) {
  669. if (($vvvv['pmid'] == $this->params['pmid'])) {
  670. $this->data['curractmeasureArray'] = $vvvv;
  671. } else {
  672. $this->data['allactmeasureArray'][] = $vvvv;
  673. }
  674. }
  675. }
  676. Doo::loadHelper('DooPager');
  677. $pagestr = '';
  678. $sqlstr = ' 1';
  679. // $this->data['project'] = '';
  680. // $this->data['tender'] = '';
  681. $this->data['phaseno'] = '';
  682. $this->data['nosign'] = '';
  683. //获取项目信息
  684. $searchsql = 'isinter!=0 and (`ownuid`='.$this->auth->getUid().' OR `audituid`='.$this->auth->getUid().' OR sid IN (SELECT sid FROM jl_sign_audit WHERE jl_sign_audit.audituid='.$this->auth->getUid().'))';
  685. // $itemlist = $this->sign->getSignGroupByProject($searchsql);
  686. // if(!empty($itemlist)){
  687. // foreach($itemlist as $ik => $iv){
  688. // $itemmsg = $this->project->getRowByPid($iv['project']);
  689. // $itemlist[$ik]['pname'] = $itemmsg['pname'];
  690. // }
  691. // }
  692. if(isset($this->params['pid']) && is_numeric($this->params['pid'])){
  693. $pagestr .= '/'.$this->params['pid'];
  694. $sqlstr .= ' and project='.$this->params['pid'];
  695. //获取标段信息
  696. // $tenderlist = $this->sign->getSignGroupByTender($this->params['pid'],$searchsql);
  697. // if(!empty($tenderlist)){
  698. // foreach($tenderlist as $tk => $tv){
  699. // $tendermsg = $this->actmeasure->getRowByPmid($tv['tender']);
  700. // $tenderlist[$tk]['pmname'] = $tendermsg['pmname'];
  701. // }
  702. // }
  703. if(isset($this->params['pmid']) && is_numeric($this->params['pmid'])){
  704. $pagestr .= '/section/'.$this->params['pmid'];
  705. $sqlstr .= ' and tender='.$this->params['pmid'];
  706. //获取期数信息
  707. $phasenolist = $this->sign->getSignGroupByPhaseno($this->params['pmid'],$searchsql);
  708. if(!empty($phasenolist)){
  709. foreach($phasenolist as $pk => $pv){
  710. $phasenolist[$pk]['numpname'] = $pv['phaseno'];
  711. }
  712. }
  713. if(isset($this->params['mpid']) && is_numeric($this->params['mpid'])){
  714. $this->data['phaseno'] = $this->params['mpid'];
  715. $pagestr .= '/phaseno/'.$this->params['mpid'];
  716. $sqlstr .= ' and phaseno='.$this->params['mpid'];
  717. }
  718. }
  719. }
  720. $totalArchive = $this->sign->getSignNum($sqlstr.' and '.$searchsql);
  721. $pager = new DooPager(Doo::conf()->APP_URL . 'sproject'.$pagestr.'/intermediate/page', $totalArchive, 10, 100);
  722. $pager->setCss('', 'disabled', 'active');
  723. if (isset($this->params['pindex']))
  724. $pager->paginate(intval($this->params['pindex']));
  725. else
  726. $pager->paginate(1);
  727. if ($pager->limit != ' -10,10')
  728. $list = $this->sign->getSignList($sqlstr.' and '.$searchsql,$pager->limit);
  729. if(isset($list) && !empty($list)){
  730. foreach($list as $k => $v){
  731. //获取项目名,标段名,标段期数
  732. $project = $this->project->getRowByPid($v['project']);
  733. $tender = $this->actmeasure->getRowByPmid($v['tender']);
  734. // $phaseno = $this->numofperact->getCurrStatus($v['phaseno']);
  735. $list[$k]['project'] = $project['pname'];
  736. $list[$k]['tender'] = $tender['pmname'];
  737. // $list[$k]['phaseno'] = $phaseno['numpname'];
  738. $list[$k]['ownname'] = $this->auth->getName($v['ownuid']);
  739. $list[$k]['auditname'] = $this->auth->getName($v['audituid']);
  740. $list[$k]['delstatus'] = $this->auth->getUid() == $v['ownuid'] && $v['status'] != 'checked' ? 1 : 0;
  741. }
  742. }
  743. $this->data['list'] = isset($list) ? $list : '';
  744. // $this->data['itemlist'] = $itemlist;
  745. // $this->data['tenderlist'] = isset($tenderlist) ? $tenderlist : '';
  746. $this->data['phasenolist'] = isset($phasenolist) ? $phasenolist : '';
  747. $this->data['pager'] = $pager->output;
  748. $this->data['pid'] = $this->params['pid'];
  749. $this->data['pmid'] = $this->params['pmid'];
  750. $this->render('s-project-section-intermediate', $this->data, TRUE);
  751. }
  752. public function interMediateMake(){
  753. //草图功能开关控制
  754. if($this->data['imediateSwitch'] == 0){
  755. exit('中间计量表草图添加功能未启用...');die;
  756. }
  757. if(isset($this->params['sid']) && is_numeric($this->params['sid'])){
  758. //获取报表信息
  759. $signmsg = $this->sign->getOneSignbysid($this->params['sid']);
  760. if(!empty($signmsg) && ($signmsg['isinter'] == 1 || $signmsg['isinter'] == 2)){
  761. if($signmsg['pagenum'] == 0){
  762. exit('当前中间计量表还没上传图片~');die;
  763. }
  764. $this->data['sid'] = $signmsg['sid'];
  765. $this->data['pid'] = $signmsg['project'];
  766. $this->data['pmid'] = $signmsg['tender'];
  767. $this->data['name'] = $signmsg['name'];
  768. $this->data['totalnum'] = $signmsg['pagenum'];
  769. if(isset($this->params['page']) && is_numeric($this->params['page'])){
  770. $this->data['currnum'] = $this->params['page'];
  771. $this->data['lastnum'] = $this->params['page'] - 1 > 0 ? ($this->params['page'] - 1) : '';
  772. $this->data['nextnum'] = $this->params['page'] + 1 > $signmsg['pagenum'] ? '' : ($this->params['page'] + 1);
  773. $signattmsg = $this->sign->getOneSignAtt($this->params['sid'],$this->params['page']);
  774. }else{
  775. $this->data['currnum'] = 1;
  776. $this->data['lastnum'] = '';
  777. $this->data['nextnum'] = 1 + 1 > $signmsg['pagenum'] ? '' : 2;
  778. $signattmsg = $this->sign->getOneSignAtt($this->params['sid'],1);
  779. }
  780. //获取报表图片
  781. $maxwidth = 794; //默认图片最大宽度 a4
  782. $maxheight = 1123; //默认图片最大高度 a4
  783. $imgmsg = getimagesize(Doo::conf()->APP_URL.$signattmsg['filepath']);
  784. $maxwidth = $imgmsg[0];
  785. $maxheight = $imgmsg[1];
  786. $this->data['maxwidth'] = $maxwidth;
  787. $this->data['maxheight'] = $maxheight;
  788. if($this->is_pjax()){
  789. echo '<div class="page" style="width:'.$maxwidth.'px" id="intermediatePage'.$this->data['currnum'].'"><input type="hidden" value="'.$this->data['currnum'].'" id="pagecurrnum"><img src="'.Doo::conf()->APP_URL.$signattmsg['filepath'].'"></div>';exit;
  790. }
  791. $this->data['attmsg'] = $signattmsg;
  792. $this->render('s-project-section-intermediate-detail', $this->data, TRUE);die;
  793. }
  794. }
  795. exit('没有中间计量表参数');
  796. }
  797. public function interMediateUpload(){
  798. if(isset($this->params['sid']) && is_numeric($this->params['sid']) && isset($_POST['num']) && isset($_POST['data'])){
  799. $signmsg = $this->sign->getOneSignbysid($this->params['sid']);
  800. if(!empty($signmsg) && ($signmsg['isinter'] == 1 || $signmsg['isinter'] == 2)){
  801. if(empty($_POST['data']) && $_POST['num'] == $signmsg['pagenum']){
  802. $this->sign->updateInterMediateStatus($this->params['sid'],3);
  803. $status = array('code' => 202, 'msg' => '最后一张已上传完毕');
  804. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  805. die();
  806. }
  807. preg_match('/^(data:\s*image\/(\w+);base64,)/', $_POST['data'], $result);
  808. $img = base64_decode(str_replace($result[1], '', $_POST['data']));
  809. //path
  810. $dir = 'signs/'.$this->params['sid'].'/intermediate';
  811. if (!$this->dir_create2(Doo::conf()->SITE_PATH . $dir)) {
  812. $status = array('status' => 400, 'msg' => '文件夹创建失败');
  813. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  814. die();
  815. }
  816. $virtualPath = $dir.'/'.$_POST['num'].'.jpg';
  817. $a = file_put_contents(Doo::conf()->SITE_PATH .$virtualPath,$img);
  818. if($a){
  819. //更新signatt表信息
  820. $result = $this->sign->updateSignAtt($this->params['sid'],$_POST['num'],$virtualPath);
  821. if($result){
  822. if($_POST['num'] == $signmsg['pagenum']){
  823. $this->sign->updateInterMediateStatus($this->params['sid'],3);
  824. $status = array('code' => 202, 'msg' => '最后一张已上传完毕');
  825. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  826. die();
  827. }else{
  828. $status = array('code' => 200, 'msg' => '');
  829. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  830. die();
  831. }
  832. }
  833. }
  834. $status = array('code' => 400, 'msg' => '上传中间计量表失败');
  835. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  836. die();
  837. }
  838. }
  839. $status = array('code' => 400, 'msg' => '参数有误,不存在此中间计量表或此中间计量表已合成');
  840. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  841. die();
  842. }
  843. /**
  844. *
  845. * @return type
  846. */
  847. public function signView()
  848. {
  849. //草图功能开关控制
  850. if($this->data['imediateSwitch'] == 0){
  851. exit('中间计量表草图添加功能未启用...');die;
  852. }
  853. if(!isset($this->params['sid']) || !is_numeric($this->params['sid'])){
  854. exit('没有报表参数');
  855. }
  856. //获取报表信息
  857. $signmsg = $this->sign->getOneSignbysid($this->params['sid']);
  858. if(empty($signmsg) || $signmsg['isinter'] != 3){
  859. exit('不存在此中间计量表');
  860. }
  861. $backurl = '/sproject/'.$signmsg['project'].'/section/'.$signmsg['tender'].'/intermediate';
  862. //获取项目名,标段名,标段期数
  863. $project = $this->project->getRowByPid($signmsg['project']);
  864. $tender = $this->actmeasure->getRowByPmid($signmsg['tender']);
  865. // $phaseno = $this->numofperact->getCurrStatus($signmsg['phaseno']);
  866. $signmsg['project'] = $project['pname'];
  867. $signmsg['tender'] = $tender['pmname'];
  868. // $signmsg['phaseno'] = $phaseno['numpname'];
  869. //获取签署人列表
  870. $signauditlist = $this->sign->getSignAuditList($this->params['sid']);
  871. if(!empty($signauditlist)){
  872. foreach($signauditlist as $k => $v){
  873. //获取签署人头像
  874. $signauditlist[$k]['index'] = $k+1;
  875. $signauditlist[$k]['avatar'] = $this->auth->getAvatar($v['audituid']);
  876. }
  877. }
  878. //获取报表图片
  879. $maxwidth = 794; //默认图片最大宽度 a4
  880. $maxheight = 1123; //默认图片最大高度 a4
  881. if(!empty($signmsg['widhei'])){
  882. $widhei = explode('_', $signmsg['widhei']);
  883. $style = $widhei[0].'mm '.$widhei[1].'mm';
  884. }else{
  885. $style = '210mm 297mm';
  886. }
  887. $signattlist = $this->sign->getSignAttList($this->params['sid']);
  888. if(!empty($signattlist)){
  889. foreach($signattlist as $sak => $sav){
  890. $signattlist[$sak]['auditatt'] = $this->sign->getSignAuditAttList($sav['said']);
  891. if($sak == 0){
  892. $imgmsg = getimagesize(Doo::conf()->APP_URL.$sav['filepath']);
  893. $maxwidth = $imgmsg[0];
  894. $maxheight = $imgmsg[1];
  895. }
  896. }
  897. }
  898. $this->data['signmsg'] = $signmsg;
  899. $this->data['auditlist'] = $signauditlist;
  900. $this->data['attlist'] = $signattlist;
  901. $this->data['backurl'] = $backurl;
  902. $this->data['maxwidth'] = $maxwidth;
  903. $this->data['maxheight'] = $maxheight;
  904. $this->data['style'] = $style;
  905. $this->render('sign-view-page', $this->data, TRUE);
  906. }
  907. function is_pjax(){
  908. return array_key_exists('HTTP_X_PJAX', $_SERVER) && $_SERVER['HTTP_X_PJAX'] === 'true';
  909. }
  910. /**
  911. * 文件下载
  912. * @param $filepath 文件路径
  913. * @param $filename 文件名称
  914. */
  915. function file_down($filepath, $filesize, $filename = '')
  916. {
  917. if (!$filename)
  918. $filename = basename($filepath);
  919. if ($this->is_ie())
  920. $filename = rawurlencode($filename);
  921. $filetype = $this->fileext($filename);
  922. // $filesize = sprintf("%u", filesize($filepath));
  923. if (ob_get_length() !== false)
  924. @ob_end_clean();
  925. header('Pragma: public');
  926. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  927. header('Cache-Control: no-store, no-cache, must-revalidate');
  928. header('Cache-Control: pre-check=0, post-check=0, max-age=0');
  929. header('Content-Transfer-Encoding: binary');
  930. header('Content-Encoding: none');
  931. header('Content-type: ' . $filetype);
  932. header('Content-Disposition: attachment; filename="' . $filename . '"');
  933. header('Content-length: ' . $filesize);
  934. @readfile($filepath);
  935. exit;
  936. }
  937. /**
  938. * IE浏览器判断
  939. */
  940. function is_ie()
  941. {
  942. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  943. if ((strpos($useragent, 'opera') !== false) || (strpos($useragent, 'konqueror') !== false))
  944. return false;
  945. if (strpos($useragent, 'msie ') !== false)
  946. return true;
  947. return false;
  948. }
  949. /**
  950. * 取得文件扩展
  951. *
  952. * @param $filename 文件名
  953. * @return 扩展名
  954. */
  955. function fileext($filename)
  956. {
  957. return strtolower(trim(substr(strrchr($filename, '.'), 1, 10)));
  958. }
  959. function dir_create2($path, $mode = 0777)
  960. {
  961. if (is_dir($path))
  962. return TRUE;
  963. $path = $this->dir_path($path);
  964. $parent = dirname($path);
  965. if (!is_dir($parent)){
  966. @mkdir($parent, 0777);
  967. @chmod($parent, 0777);
  968. }
  969. @mkdir($path, 0777);
  970. @chmod($path, 0777);
  971. return is_dir($path);
  972. }
  973. function dir_path($path)
  974. {
  975. $path = str_replace('\\', '/', $path);
  976. if (substr($path, -1) != '/')
  977. $path = $path . '/';
  978. return $path;
  979. }
  980. }
  981. ?>