SProjectController.php 51 KB

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