SProjectController.php 50 KB

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