SProjectController.php 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  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, $statusArray = array('uncheck' => '未审批', 'checking' => '审批中', 'checked' => '已审批', 'checkno' => '未通过');
  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. $numStatusArray = $this->numofperact->getLastStatus3($this->params['pid'], $this->params['pmid']);
  338. $this->data['mpid'] = $numStatusArray['mpid'];
  339. $this->data['pid'] = $this->params['pid'];
  340. $this->data['pmid'] = $this->params['pmid'];
  341. // 获取当前合同段的期数
  342. // $this->data['allNumArray'] = $this->numofperact->getNumByStid(1);
  343. $this->render('s-project-section-detail', $this->data, TRUE);
  344. }
  345. public function proMeasure()
  346. {
  347. $MpidArray = $this->measureauditact->getRowByMpid(1);
  348. foreach ($MpidArray as $key => $value) {
  349. $uidArray = $value['uid'];
  350. }
  351. $this->data['pid'] = $this->params['pid'];
  352. $this->render('s-project-section-measure', $this->data);
  353. }
  354. Function fNumber($number)
  355. {
  356. if ($number == '')
  357. Return "-";
  358. $nlen = strlen($number);
  359. while ($nlen > 3) {
  360. $fNumber = "," . substr($number, $nlen - 3, 3);
  361. $number = substr($number, 0, -3);
  362. $nlen = strlen($number);
  363. }
  364. if ($nlen <= 3) {
  365. $fNumber = $number . $fNumber;
  366. }
  367. Return $fNumber;
  368. }
  369. public function welcome()
  370. {
  371. // if (!$this->auth->isLoggedIn())
  372. // return Doo::conf()->APP_URL;
  373. if ($this->profile->getProWithUid($_SESSION['uid'])['userid'])
  374. return Doo::conf()->APP_URL . 'project/list';
  375. if (isset($_POST['welform'])) {
  376. $profileUserArray = $_POST;
  377. $profileUserArray['userid'] = $_SESSION['uid'];
  378. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  379. return Doo::conf()->APP_URL . 'project/list';
  380. }
  381. $this->render('welcome', $this->data);
  382. }
  383. public function prolist()
  384. {
  385. // if (!$this->auth->isLoggedIn())
  386. // return Doo::conf()->APP_URL;
  387. // $proArray = new stdClass();
  388. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  389. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  390. // if ($handle = opendir($extPathdir)) {
  391. // while (false !== ($file = readdir($handle))) {
  392. // $filename = pathinfo($file);
  393. // if ($filename['extension'] == 'json')
  394. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  395. // }
  396. // closedir($handle);
  397. // }
  398. // $this->data['proArray'] = null;
  399. $this->render('s-project', $this->data);
  400. }
  401. function proSectionFiles()
  402. {
  403. if (isset($_POST['optype']) && ($_POST['optype'] == 'replace') && ($_POST['imnid'])) {
  404. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  405. if ($imnidArray['iaid'] > 0) {
  406. $fileArray = $this->upItemFile('file')[0];
  407. if (isset($fileArray['filepath'])) {
  408. $itemArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  409. if (isset($itemArray)) {
  410. if ($itemArray['oldiaid'] > 0) {
  411. $oldiaid = $itemArray['oldiaid'];
  412. } else {
  413. $oldiaid = $imnidArray['iaid'];
  414. }
  415. $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);
  416. $iaid = $this->itemfle->insertItemFileRecord($postArray);
  417. if ($iaid > 1) {
  418. $this->itemmeasurenum->updateIAID($imnidArray['iaid'], $iaid);
  419. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  420. die();
  421. }
  422. }
  423. }
  424. }
  425. }
  426. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  427. ini_set('display_errors', 1);
  428. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  429. if ($imnidArray['iaid'] > 0) {
  430. $this->itemmeasurenum->updateDeltag($_POST['imnid'], $this->auth->getUid());
  431. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  432. die();
  433. }
  434. }
  435. if (isset($_POST['filename']) && isset($_POST['filedesc']) && isset($_POST['upimnid'])) {
  436. $filename = $_POST['filename'];
  437. $filedesc = $_POST['filedesc'];
  438. $imnidArray = $this->itemmeasurenum->getRowData($_POST['upimnid']);
  439. if ($imnidArray['iaid'] > 0) {
  440. if (isset($filedesc))
  441. $this->itemmeasurenum->updateItemFields($_POST['upimnid'], $filedesc, 0);
  442. if (isset($filename))
  443. $this->itemfle->updateItemFields($imnidArray['iaid'], $filename, 0);
  444. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  445. die();
  446. }
  447. }
  448. // 面包屑导航项目
  449. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  450. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  451. foreach ($proArray as $v) {
  452. $pidArray[] = $v['pid'];
  453. }
  454. $pidstr = implode(',', $pidArray);
  455. // 项目名称
  456. $allproArray = $this->project->getFewRow($pidstr);
  457. // 面包屑导航项目
  458. foreach ($allproArray as $kk => $vv) {
  459. if ($vv['pid'] == $this->params['pid']) {
  460. $this->data['currproArray'] = $vv;
  461. } else {
  462. $this->data['allproArray'][] = $vv;
  463. }
  464. }
  465. // 面包屑导航合同
  466. $conArray = $this->contractact->getAll();
  467. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  468. if (isset($measureArray['stid'])) {
  469. foreach ($conArray as $kkk => $vvv) {
  470. if ($vvv['stid'] == $measureArray['stid']) {
  471. $this->data['currconArray'] = $vvv;
  472. } else {
  473. if ($vvv['pid'] == $this->params['pid'])
  474. $this->data['allconArray'][] = $vvv;
  475. }
  476. }
  477. } else {
  478. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  479. }
  480. // 面包屑导航标段
  481. $this->data['curractmeasureArray'] = NULL;
  482. $this->data['allactmeasureArray'] = [];
  483. $actmeasureArray = $this->actmeasure->getRowUser($this->auth->getUid());
  484. foreach ($actmeasureArray as $kkkk => $vvvv) {
  485. if ($vvvv['stid'] == $measureArray['stid']) {
  486. if (($vvvv['pmid'] == $this->params['pmid'])) {
  487. $this->data['curractmeasureArray'] = $vvvv;
  488. } else {
  489. $this->data['allactmeasureArray'][] = $vvvv;
  490. }
  491. }
  492. }
  493. // 选取查询
  494. $groupArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  495. $this->data['groupArray'] = $groupArray;
  496. $owneridArray = $this->itemfle->getGroupOwnerid($this->params['pmid']);
  497. foreach ($owneridArray as $k => $v) {
  498. $this->data['owneridArray'][$k]['name'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  499. $this->data['owneridArray'][$k]['iaid'] = $v['iaid'];
  500. $this->data['owneridArray'][$k]['ownerid'] = $v['ownerid'];
  501. }
  502. // 分页
  503. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid'], 0, $this->params['numpname'], $this->params['userid']);
  504. if ($totalArchive) {
  505. if ($this->params['numpname'] && $this->params['userid']) {
  506. $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);
  507. } elseif ($this->params['numpname']) {
  508. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/num/' . $this->params['numpname'] . '/page', $totalArchive, 20, 100);
  509. } elseif ($this->params['userid']) {
  510. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/user/' . $this->params['userid'] . '/page', $totalArchive, 20, 100);
  511. } else {
  512. $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/page', $totalArchive, 20, 100);
  513. }
  514. $pager->setCss('', 'disabled', 'active');
  515. if (isset($this->params['pindex']))
  516. $pager->paginate(intval($this->params['pindex']));
  517. else
  518. $pager->paginate(1);
  519. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNum($this->params['pmid'], $pager->limit, $this->params['numpname'], $this->params['userid']);
  520. }
  521. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  522. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  523. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  524. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  525. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  526. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  527. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  528. }
  529. $this->data['pid'] = $this->params['pid'];
  530. $this->data['pmid'] = $this->params['pmid'];
  531. $numStatusArray = $this->numofperact->getLastStatus3($this->params['pid'], $this->params['pmid']);
  532. $this->data['mpid'] = $numStatusArray['mpid'];
  533. $this->data['userid'] = $this->params['userid'];
  534. $this->data['num'] = $this->params['numpname'];
  535. $this->data['pager'] = $pager->output;
  536. $this->render('s-project-section-files', $this->data, TRUE);
  537. }
  538. function proSectionFilesRecover()
  539. {
  540. if (isset($_POST['optype']) && ($_POST['optype'] == 'reconvery') && isset($_POST['imnid'])) {
  541. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  542. if ($imnidArray['iaid'] > 0) {
  543. $this->itemmeasurenum->recoveryDel($_POST['imnid']);
  544. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  545. die();
  546. }
  547. }
  548. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  549. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  550. if ($imnidArray['iaid'] > 0) {
  551. $iaidArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  552. if ($iaidArray['ownerid'] == $this->auth->getUid()) {
  553. $this->itemfle->delItem($imnidArray['iaid']);
  554. $this->itemmeasurenum->delItemIAID($imnidArray['iaid']);
  555. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  556. die();
  557. } else {
  558. echo json_encode(array('status' => 2), JSON_UNESCAPED_UNICODE);
  559. die();
  560. }
  561. }
  562. }
  563. // 面包屑导航项目
  564. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  565. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  566. foreach ($proArray as $v) {
  567. $pidArray[] = $v['pid'];
  568. }
  569. $pidstr = implode(',', $pidArray);
  570. // 项目名称
  571. $allproArray = $this->project->getFewRow($pidstr);
  572. // 面包屑导航项目
  573. foreach ($allproArray as $kk => $vv) {
  574. if ($vv['pid'] == $this->params['pid']) {
  575. $this->data['currproArray'] = $vv;
  576. } else {
  577. $this->data['allproArray'][] = $vv;
  578. }
  579. }
  580. // 面包屑导航合同
  581. $conArray = $this->contractact->getAll();
  582. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  583. if (isset($measureArray['stid'])) {
  584. foreach ($conArray as $kkk => $vvv) {
  585. if ($vvv['stid'] == $measureArray['stid']) {
  586. $this->data['currconArray'] = $vvv;
  587. } else {
  588. if ($vvv['pid'] == $this->params['pid'])
  589. $this->data['allconArray'][] = $vvv;
  590. }
  591. }
  592. } else {
  593. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  594. }
  595. // 面包屑导航标段
  596. $this->data['curractmeasureArray'] = NULL;
  597. $this->data['allactmeasureArray'] = [];
  598. $actmeasureArray = $this->actmeasure->getRowUser($this->auth->getUid());
  599. foreach ($actmeasureArray as $kkkk => $vvvv) {
  600. if ($vvvv['stid'] == $measureArray['stid']) {
  601. if (($vvvv['pmid'] == $this->params['pmid'])) {
  602. $this->data['curractmeasureArray'] = $vvvv;
  603. } else {
  604. $this->data['allactmeasureArray'][] = $vvvv;
  605. }
  606. }
  607. }
  608. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid']);
  609. if ($totalArchive) {
  610. $pager = new DooPager(Doo::conf()->APP_URL . 'sproject/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/recover/page', $totalArchive, 20, 100);
  611. $pager->setCss('', 'disabled', 'active');
  612. if (isset($this->params['pindex']))
  613. $pager->paginate(intval($this->params['pindex']));
  614. else
  615. $pager->paginate(1);
  616. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNumDel($pager->limit, $this->params['pmid']);
  617. }
  618. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  619. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  620. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  621. $this->data['itemMeasureArray'][$k]['delname'] = $this->profile->getProWithUid($v['deluid'])['name'];
  622. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  623. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  624. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  625. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  626. $this->data['itemMeasureArray'][$k]['filepath'] = $fileArray['filepath'];
  627. }
  628. $this->data['pid'] = $this->params['pid'];
  629. $this->data['pmid'] = $this->params['pmid'];
  630. $numStatusArray = $this->numofperact->getLastStatus3($this->params['pid'], $this->params['pmid']);
  631. $this->data['mpid'] = $numStatusArray['mpid'];
  632. $this->data['pager'] = $pager->output;
  633. $this->render('s-project-section-files-recover', $this->data, TRUE);
  634. }
  635. /**
  636. * @return actMeasure
  637. */
  638. public function proSectionGetFiles()
  639. {
  640. $attaArray = $this->itemfle->getItemFile($this->params['iaid']);
  641. $this->file_down($attaArray['filepath'], $attaArray['filesize'], $attaArray['filename'] . '.' . $attaArray['fileext']);
  642. return;
  643. }
  644. public function proSectionInterMediate(){
  645. //草图功能开关控制
  646. if($this->data['imediateSwitch'] == 0){
  647. exit('中间计量表草图添加功能未启用...');
  648. }
  649. if(isset($_POST['delid']) && is_numeric($_POST['delid'])){
  650. //删除未签署报表数据和文件
  651. $signmsg = $this->sign->getOneSignbysid($_POST['delid']);
  652. if(empty($signmsg) && $signmsg['status'] == "checked" && $signmsg['ownuid'] != $this->auth->getUid()){
  653. exit(json_encode(array('code' => 400),JSON_UNESCAPED_UNICODE));
  654. }
  655. $this->sign->delSignbysid($_POST['delid'],$signmsg['status']);
  656. include (DOO::conf()->SITE_PATH . 'protected/plugin/io.han.php');
  657. $this->IoHandler = new IoHandler();
  658. $path = DOO::conf()->SITE_PATH."signs/".$_POST['delid'];
  659. $this->IoHandler->RemoveDir($path);
  660. exit(json_encode(array('code' => 200),JSON_UNESCAPED_UNICODE));
  661. }
  662. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  663. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  664. foreach ($proArray as $v) {
  665. $pidArray[] = $v['pid'];
  666. }
  667. $pidstr = implode(',', $pidArray);
  668. // 项目名称
  669. $allproArray = $this->project->getFewRow($pidstr);
  670. // 面包屑导航项目
  671. foreach ($allproArray as $kk => $vv) {
  672. if ($vv['pid'] == $this->params['pid']) {
  673. $this->data['currproArray'] = $vv;
  674. } else {
  675. $this->data['allproArray'][] = $vv;
  676. }
  677. }
  678. // 面包屑导航合同
  679. $conArray = $this->contractact->getAll();
  680. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  681. if (isset($measureArray['stid'])) {
  682. foreach ($conArray as $kkk => $vvv) {
  683. if ($vvv['stid'] == $measureArray['stid']) {
  684. $this->data['currconArray'] = $vvv;
  685. } else {
  686. if ($vvv['pid'] == $this->params['pid'])
  687. $this->data['allconArray'][] = $vvv;
  688. }
  689. }
  690. } else {
  691. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  692. }
  693. // 面包屑导航标段
  694. $this->data['curractmeasureArray'] = NULL;
  695. $this->data['allactmeasureArray'] = [];
  696. $actmeasureArray = $this->actmeasure->getRowUser($this->auth->getUid());
  697. foreach ($actmeasureArray as $kkkk => $vvvv) {
  698. if ($vvvv['stid'] == $measureArray['stid']) {
  699. if (($vvvv['pmid'] == $this->params['pmid'])) {
  700. $this->data['curractmeasureArray'] = $vvvv;
  701. } else {
  702. $this->data['allactmeasureArray'][] = $vvvv;
  703. }
  704. }
  705. }
  706. Doo::loadHelper('DooPager');
  707. $pagestr = '';
  708. $sqlstr = ' 1';
  709. // $this->data['project'] = '';
  710. // $this->data['tender'] = '';
  711. $this->data['phaseno'] = '';
  712. $this->data['nosign'] = '';
  713. //获取项目信息
  714. $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().'))';
  715. // $itemlist = $this->sign->getSignGroupByProject($searchsql);
  716. // if(!empty($itemlist)){
  717. // foreach($itemlist as $ik => $iv){
  718. // $itemmsg = $this->project->getRowByPid($iv['project']);
  719. // $itemlist[$ik]['pname'] = $itemmsg['pname'];
  720. // }
  721. // }
  722. if(isset($this->params['pid']) && is_numeric($this->params['pid'])){
  723. $pagestr .= '/'.$this->params['pid'];
  724. $sqlstr .= ' and project='.$this->params['pid'];
  725. //获取标段信息
  726. // $tenderlist = $this->sign->getSignGroupByTender($this->params['pid'],$searchsql);
  727. // if(!empty($tenderlist)){
  728. // foreach($tenderlist as $tk => $tv){
  729. // $tendermsg = $this->actmeasure->getRowByPmid($tv['tender']);
  730. // $tenderlist[$tk]['pmname'] = $tendermsg['pmname'];
  731. // }
  732. // }
  733. if(isset($this->params['pmid']) && is_numeric($this->params['pmid'])){
  734. $pagestr .= '/section/'.$this->params['pmid'];
  735. $sqlstr .= ' and tender='.$this->params['pmid'];
  736. //获取期数信息
  737. $phasenolist = $this->sign->getSignGroupByPhaseno($this->params['pmid'],$searchsql);
  738. if(!empty($phasenolist)){
  739. foreach($phasenolist as $pk => $pv){
  740. $phasenolist[$pk]['numpname'] = $pv['phaseno'];
  741. }
  742. }
  743. if(isset($this->params['mpid']) && is_numeric($this->params['mpid'])){
  744. $this->data['phaseno'] = $this->params['mpid'];
  745. $pagestr .= '/phaseno/'.$this->params['mpid'];
  746. $sqlstr .= ' and phaseno='.$this->params['mpid'];
  747. }
  748. }
  749. }
  750. $totalArchive = $this->sign->getSignNum($sqlstr.' and '.$searchsql);
  751. $pager = new DooPager(Doo::conf()->APP_URL . 'sproject'.$pagestr.'/intermediate/page', $totalArchive, 10, 100);
  752. $pager->setCss('', 'disabled', 'active');
  753. if (isset($this->params['pindex']))
  754. $pager->paginate(intval($this->params['pindex']));
  755. else
  756. $pager->paginate(1);
  757. if ($pager->limit != ' -10,10')
  758. $list = $this->sign->getSignList($sqlstr.' and '.$searchsql,$pager->limit);
  759. if(isset($list) && !empty($list)){
  760. foreach($list as $k => $v){
  761. //获取项目名,标段名,标段期数
  762. $project = $this->project->getRowByPid($v['project']);
  763. $tender = $this->actmeasure->getRowByPmid($v['tender']);
  764. // $phaseno = $this->numofperact->getCurrStatus($v['phaseno']);
  765. $list[$k]['project'] = $project['pname'];
  766. $list[$k]['tender'] = $tender['pmname'];
  767. // $list[$k]['phaseno'] = $phaseno['numpname'];
  768. $list[$k]['ownname'] = $this->auth->getName($v['ownuid']);
  769. $list[$k]['auditname'] = $this->auth->getName($v['audituid']);
  770. $list[$k]['delstatus'] = $this->auth->getUid() == $v['ownuid'] && $v['status'] != 'checked' ? 1 : 0;
  771. }
  772. }
  773. $this->data['list'] = isset($list) ? $list : '';
  774. // $this->data['itemlist'] = $itemlist;
  775. // $this->data['tenderlist'] = isset($tenderlist) ? $tenderlist : '';
  776. $this->data['phasenolist'] = isset($phasenolist) ? $phasenolist : '';
  777. $this->data['pager'] = $pager->output;
  778. $numStatusArray = $this->numofperact->getLastStatus3($this->params['pid'], $this->params['pmid']);
  779. $this->data['mpid'] = $numStatusArray['mpid'];
  780. $this->data['pid'] = $this->params['pid'];
  781. $this->data['pmid'] = $this->params['pmid'];
  782. $this->render('s-project-section-intermediate', $this->data, TRUE);
  783. }
  784. public function interMediateMake(){
  785. //草图功能开关控制
  786. if($this->data['imediateSwitch'] == 0){
  787. exit('中间计量表草图添加功能未启用...');die;
  788. }
  789. if(isset($this->params['sid']) && is_numeric($this->params['sid'])){
  790. //获取报表信息
  791. $signmsg = $this->sign->getOneSignbysid($this->params['sid']);
  792. if(!empty($signmsg) && ($signmsg['isinter'] == 1 || $signmsg['isinter'] == 2)){
  793. if($signmsg['pagenum'] == 0){
  794. exit('当前中间计量表还没上传图片~');die;
  795. }
  796. if(isset($_POST['clear']) && isset($_POST['clearnum']) && is_numeric($_POST['clearnum'])){
  797. $dir = 'signs/'.$this->params['sid'];
  798. $virtualPath = $dir.'/'.$_POST['clearnum'].'.jpg';
  799. $result = $this->sign->updateSignAtt($this->params['sid'],$_POST['clearnum'],$virtualPath);
  800. if($result){
  801. include (DOO::conf()->SITE_PATH . 'protected/plugin/io.han.php');
  802. $this->IoHandler = new IoHandler();
  803. $path = DOO::conf()->SITE_PATH."signs/".$this->params['sid'].'/intermediate/'.$_POST['clearnum'].'.jpg';
  804. $this->IoHandler->DeleteFile($path);
  805. }
  806. }
  807. $this->data['sid'] = $signmsg['sid'];
  808. $this->data['pid'] = $signmsg['project'];
  809. $this->data['pmid'] = $signmsg['tender'];
  810. $this->data['name'] = $signmsg['name'];
  811. $this->data['totalnum'] = $signmsg['pagenum'];
  812. if(isset($this->params['page']) && is_numeric($this->params['page'])){
  813. $this->data['currnum'] = $this->params['page'];
  814. $this->data['lastnum'] = $this->params['page'] - 1 > 0 ? ($this->params['page'] - 1) : '';
  815. $this->data['nextnum'] = $this->params['page'] + 1 > $signmsg['pagenum'] ? '' : ($this->params['page'] + 1);
  816. $signattmsg = $this->sign->getOneSignAtt($this->params['sid'],$this->params['page']);
  817. }else{
  818. $this->data['currnum'] = 1;
  819. $this->data['lastnum'] = '';
  820. $this->data['nextnum'] = 1 + 1 > $signmsg['pagenum'] ? '' : 2;
  821. $signattmsg = $this->sign->getOneSignAtt($this->params['sid'],1);
  822. }
  823. //获取报表图片
  824. $maxwidth = 794; //默认图片最大宽度 a4
  825. $maxheight = 1123; //默认图片最大高度 a4
  826. $imgmsg = getimagesize(Doo::conf()->APP_URL.$signattmsg['filepath']);
  827. $maxwidth = $imgmsg[0];
  828. $maxheight = $imgmsg[1];
  829. $this->data['maxwidth'] = $maxwidth;
  830. $this->data['maxheight'] = $maxheight;
  831. // $this->data['hadupload'] = strpos($signattmsg['filepath'], 'intermediate') !== false ? 1 : 0;
  832. $this->data['hadupload'] = 1;
  833. $time = date('YmdHis',time());
  834. $this->data['time'] = $time;
  835. if($this->is_pjax()){
  836. 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;
  837. }
  838. $this->data['attmsg'] = $signattmsg;
  839. $this->render('s-project-section-intermediate-detail', $this->data, TRUE);die;
  840. }
  841. }
  842. exit('没有中间计量表参数');
  843. }
  844. public function interMediateUpload(){
  845. if(isset($this->params['sid']) && is_numeric($this->params['sid']) && isset($_POST['num']) && isset($_POST['data'])){
  846. $signmsg = $this->sign->getOneSignbysid($this->params['sid']);
  847. if(!empty($signmsg) && ($signmsg['isinter'] == 1 || $signmsg['isinter'] == 2)){
  848. if(empty($_POST['data']) && isset($_POST['succ'])){
  849. if($_POST['succ'] == 1){
  850. $this->sign->updateInterMediateStatus($this->params['sid'],3);
  851. $status = array('code' => 202, 'msg' => '最后一张已上传完毕');
  852. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  853. die();
  854. }
  855. }
  856. preg_match('/^(data:\s*image\/(\w+);base64,)/', $_POST['data'], $result);
  857. $img = base64_decode(str_replace($result[1], '', $_POST['data']));
  858. //path
  859. $dir = 'signs/'.$this->params['sid'].'/intermediate';
  860. if (!$this->dir_create2(Doo::conf()->SITE_PATH . $dir)) {
  861. $status = array('status' => 400, 'msg' => '文件夹创建失败');
  862. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  863. die();
  864. }
  865. $virtualPath = $dir.'/'.$_POST['num'].'.jpg';
  866. $a = file_put_contents(Doo::conf()->SITE_PATH .$virtualPath,$img);
  867. if($a){
  868. //更新signatt表信息
  869. $result = $this->sign->updateSignAtt($this->params['sid'],$_POST['num'],$virtualPath);
  870. if($result){
  871. // if($_POST['num'] == $signmsg['pagenum']){
  872. // $this->sign->updateInterMediateStatus($this->params['sid'],3);
  873. // $status = array('code' => 202, 'msg' => '最后一张已上传完毕');
  874. // echo json_encode($status, JSON_UNESCAPED_UNICODE);
  875. // die();
  876. // }
  877. // else{
  878. $status = array('code' => 200, 'msg' => '');
  879. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  880. die();
  881. // }
  882. }
  883. }
  884. $status = array('code' => 400, 'msg' => '上传中间计量表失败');
  885. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  886. die();
  887. }
  888. }
  889. $status = array('code' => 400, 'msg' => '参数有误,不存在此中间计量表或此中间计量表已合成');
  890. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  891. die();
  892. }
  893. /**
  894. *
  895. * @return type
  896. */
  897. public function signView()
  898. {
  899. //草图功能开关控制
  900. if($this->data['imediateSwitch'] == 0){
  901. exit('中间计量表草图添加功能未启用...');die;
  902. }
  903. if(!isset($this->params['sid']) || !is_numeric($this->params['sid'])){
  904. exit('没有报表参数');
  905. }
  906. //获取报表信息
  907. $signmsg = $this->sign->getOneSignbysid($this->params['sid']);
  908. if(empty($signmsg) || $signmsg['isinter'] != 3){
  909. exit('不存在此中间计量表');
  910. }
  911. $backurl = '/sproject/'.$signmsg['project'].'/section/'.$signmsg['tender'].'/intermediate';
  912. //获取项目名,标段名,标段期数
  913. $project = $this->project->getRowByPid($signmsg['project']);
  914. $tender = $this->actmeasure->getRowByPmid($signmsg['tender']);
  915. // $phaseno = $this->numofperact->getCurrStatus($signmsg['phaseno']);
  916. $signmsg['project'] = $project['pname'];
  917. $signmsg['tender'] = $tender['pmname'];
  918. // $signmsg['phaseno'] = $phaseno['numpname'];
  919. //获取签署人列表
  920. $signauditlist = $this->sign->getSignAuditList($this->params['sid']);
  921. if(!empty($signauditlist)){
  922. foreach($signauditlist as $k => $v){
  923. //获取签署人头像
  924. $signauditlist[$k]['index'] = $k+1;
  925. $signauditlist[$k]['avatar'] = $this->auth->getAvatar($v['audituid']);
  926. }
  927. }
  928. //获取报表图片
  929. $maxwidth = 794; //默认图片最大宽度 a4
  930. $maxheight = 1123; //默认图片最大高度 a4
  931. if(!empty($signmsg['widhei'])){
  932. $widhei = explode('_', $signmsg['widhei']);
  933. $style = $widhei[0].'mm '.$widhei[1].'mm';
  934. }else{
  935. $style = '210mm 297mm';
  936. }
  937. $signattlist = $this->sign->getSignAttList($this->params['sid']);
  938. if(!empty($signattlist)){
  939. foreach($signattlist as $sak => $sav){
  940. $signattlist[$sak]['auditatt'] = $this->sign->getSignAuditAttList($sav['said']);
  941. if($sak == 0){
  942. $imgmsg = getimagesize(Doo::conf()->APP_URL.$sav['filepath']);
  943. $maxwidth = $imgmsg[0];
  944. $maxheight = $imgmsg[1];
  945. }
  946. }
  947. }
  948. $this->data['signmsg'] = $signmsg;
  949. $this->data['auditlist'] = $signauditlist;
  950. $this->data['attlist'] = $signattlist;
  951. $this->data['backurl'] = $backurl;
  952. $this->data['maxwidth'] = $maxwidth;
  953. $this->data['maxheight'] = $maxheight;
  954. $this->data['style'] = $style;
  955. $this->render('sign-view-page', $this->data, TRUE);
  956. }
  957. // 审批流程页
  958. public function proReport() {
  959. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  960. $proArray = $this->actmeasure->getGroupProject($this->auth->getUid());
  961. foreach ($proArray as $v) {
  962. $pidArray[] = $v['pid'];
  963. }
  964. $pidstr = implode(',', $pidArray);
  965. // 项目名称
  966. $allproArray = $this->project->getFewRow($pidstr);
  967. // 面包屑导航项目
  968. foreach ($allproArray as $kk => $vv) {
  969. if ($vv['pid'] == $this->params['pid']) {
  970. $this->data['currproArray'] = $vv;
  971. } else {
  972. $this->data['allproArray'][] = $vv;
  973. }
  974. }
  975. // 面包屑导航合同
  976. $conArray = $this->contractact->getAll();
  977. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  978. if (isset($measureArray['stid'])) {
  979. foreach ($conArray as $kkk => $vvv) {
  980. if ($vvv['stid'] == $measureArray['stid']) {
  981. $this->data['currconArray'] = $vvv;
  982. } else {
  983. if ($vvv['pid'] == $this->params['pid'])
  984. $this->data['allconArray'][] = $vvv;
  985. }
  986. }
  987. } else {
  988. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  989. }
  990. // 面包屑导航标段
  991. $this->data['curractmeasureArray'] = NULL;
  992. $this->data['allactmeasureArray'] = [];
  993. $actmeasureArray = $this->actmeasure->getRowUser($this->auth->getUid());
  994. foreach ($actmeasureArray as $kkkk => $vvvv) {
  995. if ($vvvv['stid'] == $measureArray['stid']) {
  996. if (($vvvv['pmid'] == $this->params['pmid'])) {
  997. $this->data['curractmeasureArray'] = $vvvv;
  998. } else {
  999. $this->data['allactmeasureArray'][] = $vvvv;
  1000. }
  1001. }
  1002. }
  1003. // 期数列表
  1004. $tmpArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  1005. foreach ($tmpArray as $k => $v) {
  1006. $intTime = $this->numofperact->getMaxTimes($v['pmid'], $v['numpname'])['times'];
  1007. $nfArray[] = $this->numofperact->getRow($v['pmid'], $v['numpname'], $intTime);
  1008. }
  1009. foreach ($nfArray as $k => $v) {
  1010. if ($v['mpid'] == $this->params['mpid']) {
  1011. $this->data['mpid'] = $v['mpid'];
  1012. $this->data['MeasureArray2'][] = $v;
  1013. $this->data['currnum'] = $v['numpname'];
  1014. } else {
  1015. $this->data['numArray'][] = $v;
  1016. }
  1017. }
  1018. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  1019. foreach ($this->data['MeasureArray2'] as $key => $value) {
  1020. if ($value['mpid'] == $this->params['mpid']) {
  1021. $this->data['MeasureArray2'][$key]['currstatus'] = $this->statusArray[$value['currstatus']];
  1022. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  1023. $this->data['MeasureArray2'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  1024. } else {
  1025. $this->data['MeasureArray2'][$key]['lessTotal'] = 0;
  1026. }
  1027. }
  1028. }
  1029. //
  1030. $lastRowArray = $this->numofperact->getLastNew2($this->params['pmid']);
  1031. $maxTimes = $this->numofperact->getMaxTimes($lastRowArray['pmid'], $lastRowArray['numpname']);
  1032. // $auditUserArray = $this->measureauditact->getAllAudit($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  1033. // $maxtimez = $this->measureauditact->getRowGroupByTimes($this->params['mpid']);
  1034. $maxtimez = $this->numofperact->getRowByMpid($this->params['mpid']);
  1035. $auditUserArray = $this->measureauditact->getRowByMpidTimes($this->params['mpid'], $maxtimez['numpname'], $maxtimez['times']);
  1036. $auditArray = $this->measureauditact->getLastNewRowInfo($lastRowArray['pmid'], $lastRowArray['numpname'], $this->auth->getUid());
  1037. $this->data['pmid'] = $lastRowArray['pmid'];
  1038. $this->data['numpname'] = $lastRowArray['numpname'];
  1039. $this->data['times'] = $lastRowArray['times'];
  1040. $this->data['pid'] = $this->params['pid'];
  1041. $firstUser = 0;
  1042. foreach ($auditUserArray as $key => $value) {
  1043. $strAvatar = $this->auth->getAvatar($value['auditoruid']);
  1044. $i = $key + 1;
  1045. if ($value['auditoruid'] == $this->auth->getUid()) {
  1046. $this->data['mastatus'] = $value['mastatus'];
  1047. $this->data['maid'] = $value['maid'];
  1048. if($key == 0){
  1049. $firstUser = 1;
  1050. }else{
  1051. $this->data['lastUserID'] = $auditUserArray[$key-1]['auditoruid'];
  1052. $this->data['lastUsername'] = $this->profile->getProWithUid($auditUserArray[$key-1]['auditoruid'])['name'];
  1053. $this->data['lastUserCompany'] = $this->profile->getProWithUid($auditUserArray[$key-1]['auditoruid'])['company'];
  1054. }
  1055. }
  1056. if ($value['mastatus'] == 'uncheck') {
  1057. $statuStr = '';
  1058. $statucolorStr = '';
  1059. $statushtml = '<li title="" class=""><img src="' . $strAvatar . '"></li>';
  1060. }
  1061. if ($value['mastatus'] == 'checking') {
  1062. $statuStr = '<h4 class="colOrange">审批中</h4>';
  1063. $statucolorStr = 'colOrange';
  1064. $statushtml = '<li title="审批中" class="wait"><span data-icon="k" aria-hidden="true"></span> <img src="' . $strAvatar . '"></li>';
  1065. }
  1066. if ($value['mastatus'] == 'checked') {
  1067. $statuStr = '<h4 class="colGreen">审批完成(' . date('Y-m-d', $value['audittime']) . ')</h4>';
  1068. $statucolorStr = 'colGreen';
  1069. $statushtml = '<li title="审批通过" class="pass"><span data-icon="d" aria-hidden="true"></span><img src="' . $strAvatar . '"></li>';
  1070. }
  1071. if ($value['mastatus'] == 'checkno') {
  1072. $statuStr = '<h4 class="colRed">审批不通过(' . date('Y-m-d', $value['audittime']) . ')</h4>';
  1073. $statucolorStr = 'colRed';
  1074. $statushtml = '<li title="审批不通过" class="notpass"><span data-icon="e" aria-hidden="true"></span><img src="' . $strAvatar . '"></li>';
  1075. }
  1076. $auditUserArray[$key]['statuStr'] = $statuStr;
  1077. $auditUserArray[$key]['statucolorStr'] = $statucolorStr;
  1078. $auditUserArray[$key]['statushtml'] = $statushtml;
  1079. $auditUserArray[$key]['k'] = $i;
  1080. $auditUserArray[$key]['name'] = $this->profile->getProWithUid($value['auditoruid'])['name'];
  1081. }
  1082. $strAvatar = $this->auth->getAvatar($measureArray['uid']);
  1083. $orginArray['avatar'] = '<img src="' . $strAvatar . '"></li>';
  1084. $orginArray['name'] = $this->profile->getProWithUid($measureArray['uid'])['name'];
  1085. // 获取原报时间
  1086. // 利用mpid和uid获取原报人当前期数下上传的第一份文件时间,即为原报时间
  1087. // $attfileArray = $this->attfile->getFirstFile($lastRowArray['pmid'], $lastRowArray['numpname'], $lastRowArray['times']);
  1088. $attfileArray = $this->attfile->getFirstFile($lastRowArray['pmid'], $maxtimez['numpname'], $maxtimez['times']);
  1089. $orginArray['time'] = date('Y-m-d', $attfileArray['intime']);
  1090. $this->data['auditArray'] = $auditUserArray;
  1091. $this->data['orginArray'] = $orginArray;
  1092. $this->data['pmid'] = $this->params['pmid'];
  1093. $this->data['pid'] = $this->params['pid'];
  1094. $this->data['mpid'] = $this->params['mpid'];
  1095. $this->data['firstUser'] = $firstUser;
  1096. // var_dump($this->data);
  1097. // exit;
  1098. $this->render('s-project-section-report', $this->data, TRUE);
  1099. }
  1100. function is_pjax(){
  1101. return array_key_exists('HTTP_X_PJAX', $_SERVER) && $_SERVER['HTTP_X_PJAX'] === 'true';
  1102. }
  1103. /**
  1104. * 文件下载
  1105. * @param $filepath 文件路径
  1106. * @param $filename 文件名称
  1107. */
  1108. function file_down($filepath, $filesize, $filename = '')
  1109. {
  1110. if (!$filename)
  1111. $filename = basename($filepath);
  1112. if ($this->is_ie())
  1113. $filename = rawurlencode($filename);
  1114. $filetype = $this->fileext($filename);
  1115. // $filesize = sprintf("%u", filesize($filepath));
  1116. if (ob_get_length() !== false)
  1117. @ob_end_clean();
  1118. header('Pragma: public');
  1119. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  1120. header('Cache-Control: no-store, no-cache, must-revalidate');
  1121. header('Cache-Control: pre-check=0, post-check=0, max-age=0');
  1122. header('Content-Transfer-Encoding: binary');
  1123. header('Content-Encoding: none');
  1124. header('Content-type: ' . $filetype);
  1125. header('Content-Disposition: attachment; filename="' . $filename . '"');
  1126. header('Content-length: ' . $filesize);
  1127. @readfile($filepath);
  1128. exit;
  1129. }
  1130. /**
  1131. * IE浏览器判断
  1132. */
  1133. function is_ie()
  1134. {
  1135. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  1136. if ((strpos($useragent, 'opera') !== false) || (strpos($useragent, 'konqueror') !== false))
  1137. return false;
  1138. if (strpos($useragent, 'msie ') !== false)
  1139. return true;
  1140. return false;
  1141. }
  1142. /**
  1143. * 取得文件扩展
  1144. *
  1145. * @param $filename 文件名
  1146. * @return 扩展名
  1147. */
  1148. function fileext($filename)
  1149. {
  1150. return strtolower(trim(substr(strrchr($filename, '.'), 1, 10)));
  1151. }
  1152. function dir_create2($path, $mode = 0777)
  1153. {
  1154. if (is_dir($path))
  1155. return TRUE;
  1156. $path = $this->dir_path($path);
  1157. $parent = dirname($path);
  1158. if (!is_dir($parent)){
  1159. @mkdir($parent, 0777);
  1160. @chmod($parent, 0777);
  1161. }
  1162. @mkdir($path, 0777);
  1163. @chmod($path, 0777);
  1164. return is_dir($path);
  1165. }
  1166. function dir_path($path)
  1167. {
  1168. $path = str_replace('\\', '/', $path);
  1169. if (substr($path, -1) != '/')
  1170. $path = $path . '/';
  1171. return $path;
  1172. }
  1173. }
  1174. ?>