SProjectController.php 49 KB

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