SProjectController.php 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
  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->getAll();
  688. $actmeasureArray = $this->actmeasure->getRowUser($this->auth->getUid());
  689. foreach ($actmeasureArray as $kkkk => $vvvv) {
  690. if ($vvvv['stid'] == $measureArray['stid']) {
  691. if (($vvvv['pmid'] == $this->params['pmid'])) {
  692. $this->data['curractmeasureArray'] = $vvvv;
  693. } else {
  694. $this->data['allactmeasureArray'][] = $vvvv;
  695. }
  696. }
  697. }
  698. Doo::loadHelper('DooPager');
  699. $pagestr = '';
  700. $sqlstr = ' 1';
  701. // $this->data['project'] = '';
  702. // $this->data['tender'] = '';
  703. $this->data['phaseno'] = '';
  704. $this->data['nosign'] = '';
  705. //获取项目信息
  706. $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().'))';
  707. // $itemlist = $this->sign->getSignGroupByProject($searchsql);
  708. // if(!empty($itemlist)){
  709. // foreach($itemlist as $ik => $iv){
  710. // $itemmsg = $this->project->getRowByPid($iv['project']);
  711. // $itemlist[$ik]['pname'] = $itemmsg['pname'];
  712. // }
  713. // }
  714. if(isset($this->params['pid']) && is_numeric($this->params['pid'])){
  715. $pagestr .= '/'.$this->params['pid'];
  716. $sqlstr .= ' and project='.$this->params['pid'];
  717. //获取标段信息
  718. // $tenderlist = $this->sign->getSignGroupByTender($this->params['pid'],$searchsql);
  719. // if(!empty($tenderlist)){
  720. // foreach($tenderlist as $tk => $tv){
  721. // $tendermsg = $this->actmeasure->getRowByPmid($tv['tender']);
  722. // $tenderlist[$tk]['pmname'] = $tendermsg['pmname'];
  723. // }
  724. // }
  725. if(isset($this->params['pmid']) && is_numeric($this->params['pmid'])){
  726. $pagestr .= '/section/'.$this->params['pmid'];
  727. $sqlstr .= ' and tender='.$this->params['pmid'];
  728. //获取期数信息
  729. $phasenolist = $this->sign->getSignGroupByPhaseno($this->params['pmid'],$searchsql);
  730. if(!empty($phasenolist)){
  731. foreach($phasenolist as $pk => $pv){
  732. $phasenolist[$pk]['numpname'] = $pv['phaseno'];
  733. }
  734. }
  735. if(isset($this->params['mpid']) && is_numeric($this->params['mpid'])){
  736. $this->data['phaseno'] = $this->params['mpid'];
  737. $pagestr .= '/phaseno/'.$this->params['mpid'];
  738. $sqlstr .= ' and phaseno='.$this->params['mpid'];
  739. }
  740. }
  741. }
  742. $totalArchive = $this->sign->getSignNum($sqlstr.' and '.$searchsql);
  743. $pager = new DooPager(Doo::conf()->APP_URL . 'sproject'.$pagestr.'/intermediate/page', $totalArchive, 10, 100);
  744. $pager->setCss('', 'disabled', 'active');
  745. if (isset($this->params['pindex']))
  746. $pager->paginate(intval($this->params['pindex']));
  747. else
  748. $pager->paginate(1);
  749. if ($pager->limit != ' -10,10')
  750. $list = $this->sign->getSignList($sqlstr.' and '.$searchsql,$pager->limit);
  751. if(isset($list) && !empty($list)){
  752. foreach($list as $k => $v){
  753. //获取项目名,标段名,标段期数
  754. $project = $this->project->getRowByPid($v['project']);
  755. $tender = $this->actmeasure->getRowByPmid($v['tender']);
  756. // $phaseno = $this->numofperact->getCurrStatus($v['phaseno']);
  757. $list[$k]['project'] = $project['pname'];
  758. $list[$k]['tender'] = $tender['pmname'];
  759. // $list[$k]['phaseno'] = $phaseno['numpname'];
  760. $list[$k]['ownname'] = $this->auth->getName($v['ownuid']);
  761. $list[$k]['auditname'] = $this->auth->getName($v['audituid']);
  762. $list[$k]['delstatus'] = $this->auth->getUid() == $v['ownuid'] && $v['status'] != 'checked' ? 1 : 0;
  763. }
  764. }
  765. $this->data['list'] = isset($list) ? $list : '';
  766. // $this->data['itemlist'] = $itemlist;
  767. // $this->data['tenderlist'] = isset($tenderlist) ? $tenderlist : '';
  768. $this->data['phasenolist'] = isset($phasenolist) ? $phasenolist : '';
  769. $this->data['pager'] = $pager->output;
  770. $this->data['pid'] = $this->params['pid'];
  771. $this->data['pmid'] = $this->params['pmid'];
  772. $this->render('s-project-section-intermediate', $this->data, TRUE);
  773. }
  774. public function interMediateMake(){
  775. //草图功能开关控制
  776. if($this->data['imediateSwitch'] == 0){
  777. exit('中间计量表草图添加功能未启用...');die;
  778. }
  779. if(isset($this->params['sid']) && is_numeric($this->params['sid'])){
  780. //获取报表信息
  781. $signmsg = $this->sign->getOneSignbysid($this->params['sid']);
  782. if(!empty($signmsg) && ($signmsg['isinter'] == 1 || $signmsg['isinter'] == 2)){
  783. if($signmsg['pagenum'] == 0){
  784. exit('当前中间计量表还没上传图片~');die;
  785. }
  786. $this->data['sid'] = $signmsg['sid'];
  787. $this->data['pid'] = $signmsg['project'];
  788. $this->data['pmid'] = $signmsg['tender'];
  789. $this->data['name'] = $signmsg['name'];
  790. $this->data['totalnum'] = $signmsg['pagenum'];
  791. if(isset($this->params['page']) && is_numeric($this->params['page'])){
  792. $this->data['currnum'] = $this->params['page'];
  793. $this->data['lastnum'] = $this->params['page'] - 1 > 0 ? ($this->params['page'] - 1) : '';
  794. $this->data['nextnum'] = $this->params['page'] + 1 > $signmsg['pagenum'] ? '' : ($this->params['page'] + 1);
  795. $signattmsg = $this->sign->getOneSignAtt($this->params['sid'],$this->params['page']);
  796. }else{
  797. $this->data['currnum'] = 1;
  798. $this->data['lastnum'] = '';
  799. $this->data['nextnum'] = 1 + 1 > $signmsg['pagenum'] ? '' : 2;
  800. $signattmsg = $this->sign->getOneSignAtt($this->params['sid'],1);
  801. }
  802. //获取报表图片
  803. $maxwidth = 794; //默认图片最大宽度 a4
  804. $maxheight = 1123; //默认图片最大高度 a4
  805. $imgmsg = getimagesize(Doo::conf()->APP_URL.$signattmsg['filepath']);
  806. $maxwidth = $imgmsg[0];
  807. $maxheight = $imgmsg[1];
  808. $this->data['maxwidth'] = $maxwidth;
  809. $this->data['maxheight'] = $maxheight;
  810. if($this->is_pjax()){
  811. echo '<div class="page" style="width:'.$maxwidth.'px" id="intermediatePage'.$this->data['currnum'].'"><input type="hidden" value="'.$this->data['currnum'].'" id="pagecurrnum"><img src="'.Doo::conf()->APP_URL.$signattmsg['filepath'].'"></div>';exit;
  812. }
  813. $this->data['attmsg'] = $signattmsg;
  814. $this->render('s-project-section-intermediate-detail', $this->data, TRUE);die;
  815. }
  816. }
  817. exit('没有中间计量表参数');
  818. }
  819. public function interMediateUpload(){
  820. if(isset($this->params['sid']) && is_numeric($this->params['sid']) && isset($_POST['num']) && isset($_POST['data'])){
  821. $signmsg = $this->sign->getOneSignbysid($this->params['sid']);
  822. if(!empty($signmsg) && ($signmsg['isinter'] == 1 || $signmsg['isinter'] == 2)){
  823. if(empty($_POST['data']) && $_POST['num'] == $signmsg['pagenum']){
  824. $this->sign->updateInterMediateStatus($this->params['sid'],3);
  825. $status = array('code' => 202, 'msg' => '最后一张已上传完毕');
  826. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  827. die();
  828. }
  829. preg_match('/^(data:\s*image\/(\w+);base64,)/', $_POST['data'], $result);
  830. $img = base64_decode(str_replace($result[1], '', $_POST['data']));
  831. //path
  832. $dir = 'signs/'.$this->params['sid'].'/intermediate';
  833. if (!$this->dir_create2(Doo::conf()->SITE_PATH . $dir)) {
  834. $status = array('status' => 400, 'msg' => '文件夹创建失败');
  835. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  836. die();
  837. }
  838. $virtualPath = $dir.'/'.$_POST['num'].'.jpg';
  839. $a = file_put_contents(Doo::conf()->SITE_PATH .$virtualPath,$img);
  840. if($a){
  841. //更新signatt表信息
  842. $result = $this->sign->updateSignAtt($this->params['sid'],$_POST['num'],$virtualPath);
  843. if($result){
  844. if($_POST['num'] == $signmsg['pagenum']){
  845. $this->sign->updateInterMediateStatus($this->params['sid'],3);
  846. $status = array('code' => 202, 'msg' => '最后一张已上传完毕');
  847. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  848. die();
  849. }else{
  850. $status = array('code' => 200, 'msg' => '');
  851. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  852. die();
  853. }
  854. }
  855. }
  856. $status = array('code' => 400, 'msg' => '上传中间计量表失败');
  857. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  858. die();
  859. }
  860. }
  861. $status = array('code' => 400, 'msg' => '参数有误,不存在此中间计量表或此中间计量表已合成');
  862. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  863. die();
  864. }
  865. /**
  866. *
  867. * @return type
  868. */
  869. public function signView()
  870. {
  871. //草图功能开关控制
  872. if($this->data['imediateSwitch'] == 0){
  873. exit('中间计量表草图添加功能未启用...');die;
  874. }
  875. if(!isset($this->params['sid']) || !is_numeric($this->params['sid'])){
  876. exit('没有报表参数');
  877. }
  878. //获取报表信息
  879. $signmsg = $this->sign->getOneSignbysid($this->params['sid']);
  880. if(empty($signmsg) || $signmsg['isinter'] != 3){
  881. exit('不存在此中间计量表');
  882. }
  883. $backurl = '/sproject/'.$signmsg['project'].'/section/'.$signmsg['tender'].'/intermediate';
  884. //获取项目名,标段名,标段期数
  885. $project = $this->project->getRowByPid($signmsg['project']);
  886. $tender = $this->actmeasure->getRowByPmid($signmsg['tender']);
  887. // $phaseno = $this->numofperact->getCurrStatus($signmsg['phaseno']);
  888. $signmsg['project'] = $project['pname'];
  889. $signmsg['tender'] = $tender['pmname'];
  890. // $signmsg['phaseno'] = $phaseno['numpname'];
  891. //获取签署人列表
  892. $signauditlist = $this->sign->getSignAuditList($this->params['sid']);
  893. if(!empty($signauditlist)){
  894. foreach($signauditlist as $k => $v){
  895. //获取签署人头像
  896. $signauditlist[$k]['index'] = $k+1;
  897. $signauditlist[$k]['avatar'] = $this->auth->getAvatar($v['audituid']);
  898. }
  899. }
  900. //获取报表图片
  901. $maxwidth = 794; //默认图片最大宽度 a4
  902. $maxheight = 1123; //默认图片最大高度 a4
  903. if(!empty($signmsg['widhei'])){
  904. $widhei = explode('_', $signmsg['widhei']);
  905. $style = $widhei[0].'mm '.$widhei[1].'mm';
  906. }else{
  907. $style = '210mm 297mm';
  908. }
  909. $signattlist = $this->sign->getSignAttList($this->params['sid']);
  910. if(!empty($signattlist)){
  911. foreach($signattlist as $sak => $sav){
  912. $signattlist[$sak]['auditatt'] = $this->sign->getSignAuditAttList($sav['said']);
  913. if($sak == 0){
  914. $imgmsg = getimagesize(Doo::conf()->APP_URL.$sav['filepath']);
  915. $maxwidth = $imgmsg[0];
  916. $maxheight = $imgmsg[1];
  917. }
  918. }
  919. }
  920. $this->data['signmsg'] = $signmsg;
  921. $this->data['auditlist'] = $signauditlist;
  922. $this->data['attlist'] = $signattlist;
  923. $this->data['backurl'] = $backurl;
  924. $this->data['maxwidth'] = $maxwidth;
  925. $this->data['maxheight'] = $maxheight;
  926. $this->data['style'] = $style;
  927. $this->render('sign-view-page', $this->data, TRUE);
  928. }
  929. function is_pjax(){
  930. return array_key_exists('HTTP_X_PJAX', $_SERVER) && $_SERVER['HTTP_X_PJAX'] === 'true';
  931. }
  932. /**
  933. * 文件下载
  934. * @param $filepath 文件路径
  935. * @param $filename 文件名称
  936. */
  937. function file_down($filepath, $filesize, $filename = '')
  938. {
  939. if (!$filename)
  940. $filename = basename($filepath);
  941. if ($this->is_ie())
  942. $filename = rawurlencode($filename);
  943. $filetype = $this->fileext($filename);
  944. // $filesize = sprintf("%u", filesize($filepath));
  945. if (ob_get_length() !== false)
  946. @ob_end_clean();
  947. header('Pragma: public');
  948. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  949. header('Cache-Control: no-store, no-cache, must-revalidate');
  950. header('Cache-Control: pre-check=0, post-check=0, max-age=0');
  951. header('Content-Transfer-Encoding: binary');
  952. header('Content-Encoding: none');
  953. header('Content-type: ' . $filetype);
  954. header('Content-Disposition: attachment; filename="' . $filename . '"');
  955. header('Content-length: ' . $filesize);
  956. @readfile($filepath);
  957. exit;
  958. }
  959. /**
  960. * IE浏览器判断
  961. */
  962. function is_ie()
  963. {
  964. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  965. if ((strpos($useragent, 'opera') !== false) || (strpos($useragent, 'konqueror') !== false))
  966. return false;
  967. if (strpos($useragent, 'msie ') !== false)
  968. return true;
  969. return false;
  970. }
  971. /**
  972. * 取得文件扩展
  973. *
  974. * @param $filename 文件名
  975. * @return 扩展名
  976. */
  977. function fileext($filename)
  978. {
  979. return strtolower(trim(substr(strrchr($filename, '.'), 1, 10)));
  980. }
  981. function dir_create2($path, $mode = 0777)
  982. {
  983. if (is_dir($path))
  984. return TRUE;
  985. $path = $this->dir_path($path);
  986. $parent = dirname($path);
  987. if (!is_dir($parent)){
  988. @mkdir($parent, 0777);
  989. @chmod($parent, 0777);
  990. }
  991. @mkdir($path, 0777);
  992. @chmod($path, 0777);
  993. return is_dir($path);
  994. }
  995. function dir_path($path)
  996. {
  997. $path = str_replace('\\', '/', $path);
  998. if (substr($path, -1) != '/')
  999. $path = $path . '/';
  1000. return $path;
  1001. }
  1002. }
  1003. ?>