SProjectController.php 51 KB

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