SProjectController.php 48 KB

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