RProjectController.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  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('measureauditact');
  9. Doo::loadClass('numofperact');
  10. Doo::loadModelAt('aconfig', 'admin');
  11. Doo::loadClass('sms');
  12. Doo::loadClass('itemmeasurenum');
  13. Doo::loadClass('itemfile');
  14. Doo::loadClass('attachment');
  15. Doo::loadHelper('DooPager');
  16. /**
  17. * MainController
  18. * Feel free to delete the methods and replace them with your own code.
  19. *
  20. * @author darkredz
  21. */
  22. class RProjectController extends DooController
  23. {
  24. private $data, $auth, $attfile, $profile, $project, $contractact, $actmeasure, $measureauditact, $numofperact, $statusArray = array('uncheck' => '未审批', 'checking' => '审批中', 'checked' => '已审批', 'checkno' => '未通过'), $aconfig, $sms, $itemfile, $itemmeasurenum, $itemfle, $att;
  25. public function __construct()
  26. {
  27. $this->auth = new Auth();
  28. $this->attfile = new attFile();
  29. $this->profile = new Profile();
  30. $this->project = new Project();
  31. $this->contractact = new Contractact();
  32. $this->actmeasure = new actMeasure();
  33. $this->measureauditact = new MeasureauditAct();
  34. $this->numofperact = new NumofperAct();
  35. $this->itemfile = new ItemFile();
  36. $this->itemmeasurenum = new ItemMeasureNumpofper();
  37. $this->aconfig = new AConfig();
  38. $this->itemfle = new ItemFile();
  39. $this->att = new attachment();
  40. $this->sms = new Sms(Doo::conf()->SMS_URL, Doo::conf()->SMS_AUTHKEY);
  41. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  42. $this->data['currChannle'] = 'r';
  43. $this->data['user'] = $this->profile->getProWithUid($this->auth->getUid());
  44. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  45. if (isset($mpidArray[0]['pid'])) {
  46. $this->data['numofchecking'] = 0;
  47. foreach ($mpidArray as $key => $value) {
  48. // 审批操作按照时间排序多标段
  49. $this->data['numofchecking'] += $this->measureauditact->getCountMyChecking($value['pid'], $this->auth->getUid());
  50. }
  51. }
  52. if ($this->data['numofchecking'] == 0) {
  53. $this->data['numofchecking'] = null;
  54. }
  55. }
  56. public function beforeRun($resource, $action)
  57. {
  58. // $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  59. // $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  60. // if (!$falg)
  61. // return Doo::acl()->defaultFailedRoute;
  62. if ($this->auth->getUid()) {
  63. $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  64. $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  65. if (!$falg)
  66. return Doo::acl()->defaultFailedRoute;
  67. } else {
  68. return Doo::acl()->defaultFailedRoute;
  69. }
  70. }
  71. public function index()
  72. {
  73. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  74. if (isset($mpidArray[0]['pid'])) {
  75. foreach ($mpidArray as $key => $value) {
  76. // 审批操作按照时间排序多标段
  77. $numOfChecking = $this->measureauditact->getCountMyChecking($value['pid'], $this->auth->getUid());
  78. // end
  79. $this->data['proArray'][$key] = $this->project->getRowByPid($value['pid']);
  80. $this->data['proArray'][$key]['numofchecking'] = $numOfChecking;
  81. $this->data['proArray'][$key]['contracttotal'] = $this->actmeasure->getTotalWithPid($value['pid']);
  82. $this->data['proArray'][$key]['changTotal'] = $this->numofperact->getChangTotal($value['pid']);
  83. // $this->data['proArray'][$key]['contracttotal'] += $this->data['proArray'][$key]['changTotal'];
  84. $this->data['proArray'][$key]['currdone'] = $this->numofperact->getCurrDoneNow($value['pid']);
  85. if (($this->data['proArray'][$key]['contracttotal'] > 0) && ($this->data['proArray'][$key]['currdone'] > 0)) {
  86. $this->data['proArray'][$key]['pcurrdone'] = round(($this->data['proArray'][$key]['currdone'] / $this->data['proArray'][$key]['contracttotal']) * 100) . '%';
  87. } else {
  88. $this->data['proArray'][$key]['pcurrdone'] = '0%';
  89. }
  90. $this->data['proArray'][$key]['bcontracttotal'] = number_format($this->data['proArray'][$key]['contracttotal'], 2, '.', ',');
  91. $this->data['proArray'][$key]['bchangTotal'] = number_format($this->data['proArray'][$key]['changTotal'], 2, '.', ',');
  92. }
  93. } else {
  94. $this->data['proArray'] = array();
  95. }
  96. $this->render('r-project', $this->data);
  97. }
  98. public function proOverview()
  99. {
  100. // $this->data['pros'] = $this->project->getAll();
  101. // if (isset($_POST['pname']) && $_POST['pname']) {
  102. // $this->project->insertProject($_POST['pname']);
  103. // return Doo::conf()->APP_URL . 'project/index';
  104. // }
  105. $this->data['pid'] = $this->params['pid'];
  106. $this->render('w-project-detail', $this->data);
  107. }
  108. public function proSection()
  109. {
  110. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  111. foreach ($mpidArray as $k1 => $v1) {
  112. if ($v1['pid'] != $this->params['pid'])
  113. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  114. }
  115. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  116. $this->data['conArray'] = $this->contractact->getRowByPid($this->params['pid']);
  117. $auditArray = $this->measureauditact->getUserPmid($this->auth->getUid());
  118. foreach ($auditArray as $key => $value) {
  119. $pmidArray[] = $value['pmid'];
  120. }
  121. foreach ($this->data['conArray'] as $key => $value) {
  122. $html = null;
  123. $hetongTotal = $dispstopnowtotal = $dispnowtotal = $countNum = 0;
  124. $nstopnowtotal = $ncurrdone = $nnowtotal = number_format(0, 2, '.', ',');
  125. $pstopnowtotal = '0%';
  126. $pcurrdone = '0%';
  127. $ncurrdone = number_format(0, 2, '.', ',');
  128. $pnowtotal = '0%';
  129. $dispcurrdone = '0%';
  130. // $numStatusArray['currstatus'] = 'uncheck';
  131. $StidArray = $this->actmeasure->getAllbyStid($value['stid']);
  132. $currdoneInt = $this->numofperact->getCurrdoneSTID($value['stid'])['totalplus'];
  133. if (isset($StidArray))
  134. foreach ($StidArray as $k => $v) {
  135. if (in_array($v['pmid'], $pmidArray)) {
  136. $snTotal = $this->numofperact->getStopNowTotal($v['pmid']); //根据标段ID获取最新一期(包括不通过)
  137. $currcomTotal = $this->numofperact->getCurrdoneNew($v['pmid']); //截止目前
  138. $ncurrdone = number_format($currcomTotal['currtotal'], 2, '.', ',');
  139. $nstopnowtotal = number_format($snTotal['sntotal'], 2, '.', ',');
  140. if ($v['contracttotal'] > 0) {
  141. $nnowtotal = number_format($v['contracttotal'] - $currcomTotal['currtotal'] - $snTotal['sntotal'], 2, '.', ',');
  142. $pstopnowtotal = round(($snTotal['sntotal'] / $v['contracttotal']) * 100);
  143. $pcurrdone = round(($currcomTotal['currtotal'] / $v['contracttotal']) * 100);
  144. }
  145. $dispcurrdone = $pcurrdone . '%';
  146. $dispstopnowtotal = $pstopnowtotal . '%';
  147. $pnowtotal = 100 - $pcurrdone - $pstopnowtotal;
  148. $dispnowtotal = $pnowtotal . '%';
  149. $countNum = $this->numofperact->getLastNew2($v['pmid'])['numpname'];
  150. if (!isset($countNum)) {
  151. $countNum = 0;
  152. }
  153. $numStatusArray = $this->numofperact->getLastStatus3($this->params['pid'], $v['pmid']);
  154. if (!isset($numStatusArray['currstatus'])) {
  155. $numStatusArray['currstatus'] = 'uncheck';
  156. }
  157. $datatmp = $this->measureauditact->getMyAuditStatus2($numStatusArray['pmid'], $numStatusArray['numpname'], $numStatusArray['times'], $this->auth->getUid());
  158. if ($datatmp && ($datatmp['mastatus'] == 'checking')) {
  159. $buttonhtml = '<a class="btn btn-warning btn-small" href="/rproject/' . $this->params['pid'] . '/section/' . $v['pmid'] . '/report/' . $numStatusArray['mpid'] . '">开始审批</a>';
  160. } else {
  161. $buttonhtml = '(<span class="colOrange">' . $this->statusArray[$numStatusArray['currstatus']] . '</span>)';
  162. }
  163. $html .= '<tr>
  164. <td><a href="/rproject/' . $this->params['pid'] . '/section/' . $v['pmid'] . '/detail">' . $v['pmname'] . '</a></td>
  165. <td class="">第 ' . $countNum . ' 期 ' . $buttonhtml . '</td>
  166. <td class="taR">¥' . number_format($v['contracttotal'], 2, '.', ',') . '</td>
  167. <td>
  168. <div class="progress">
  169. <div class="bar bar-success" style="width: ' . $dispstopnowtotal . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成:¥' . $nstopnowtotal . '">' . $dispstopnowtotal . '</div>
  170. <div class="bar" style="width:' . $dispcurrdone . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' . $ncurrdone . '">' . $dispcurrdone . '</div>
  171. <div class="bar bar-gary" style="width:' . $dispnowtotal . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $nnowtotal . '">' . $dispnowtotal . '</div>
  172. </div>
  173. </td>
  174. </tr>';
  175. $hetongTotal += $v['contracttotal'];
  176. }
  177. }
  178. $this->data['conArray'][$key]['htmlstr'] = $html;
  179. $this->data['conArray'][$key]['hetongTotal'] = number_format($hetongTotal, 2, '.', ',');
  180. $this->data['conArray'][$key]['phetongTotal'] = 0;
  181. $this->data['conArray'][$key]['nhetongTotal'] = 0;
  182. $this->data['conArray'][$key]['phetongTotal2'] = 0;
  183. $this->data['conArray'][$key]['ncurrdoneInt'] = 0;
  184. $this->data['conArray'][$key]['phetongTotal'] = round(($currdoneInt / $hetongTotal) * 100) . '%';
  185. $this->data['conArray'][$key]['nhetongTotal'] = number_format($currdoneInt, 2, '.', ',');
  186. $this->data['conArray'][$key]['phetongTotal2'] = round((($hetongTotal - $currdoneInt) / $hetongTotal) * 100) . '%';
  187. $this->data['conArray'][$key]['ncurrdoneInt'] = number_format($hetongTotal - $currdoneInt, 2, '.', ',');
  188. }
  189. $this->render('r-project-section', $this->data, TRUE);
  190. }
  191. function proSectionMeasure()
  192. {
  193. $mpidArray = $this->measureauditact->getAuditProject($this->auth->getUid());
  194. foreach ($mpidArray as $k1 => $v1) {
  195. if ($v1['pid'] != $this->params['pid'])
  196. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  197. }
  198. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  199. $this->data['pid'] = $this->params['pid'];
  200. $this->data['mpid'] = $this->params['mpid'];
  201. $this->data['mastatus'] = $this->measureauditact->getStatusByMpid($this->params['mpid'])['mastatus'];
  202. if (isset($_POST['submit'])) {
  203. if ($_POST['submit'] == 'ok') {
  204. $this->measureauditact->setStatusTrue($this->params['mpid']);
  205. return Doo::conf()->APP_URL . 'rproject/' . $this->params['pid'] . '/section/' . $this->params['mpid'] . '/measure';
  206. }
  207. if ($_POST['submit'] == 'no') {
  208. $this->measureauditact->setStatusFalse($this->params['mpid']);
  209. return Doo::conf()->APP_URL . 'rproject/' . $this->params['pid'] . '/section/' . $this->params['mpid'] . '/measure';
  210. }
  211. }
  212. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  213. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  214. // if ($handle = opendir($extPathdir)) {
  215. // while (false !== ($file = readdir($handle))) {
  216. // $filename = pathinfo($file);
  217. // if ($filename['extension'] == 'json')
  218. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  219. // }
  220. // closedir($handle);
  221. // }
  222. // $this->data['proArray'] = $proArray;
  223. $this->render('r-project-section-measure', $this->data, TRUE);
  224. }
  225. function proSectionFiles()
  226. {
  227. if (isset($_POST['optype']) && ($_POST['optype'] == 'replace') && ($_POST['imnid'])) {
  228. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  229. if ($imnidArray['iaid'] > 0) {
  230. $fileArray = $this->upItemFile('file')[0];
  231. if (isset($fileArray['filepath'])) {
  232. $itemArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  233. if (isset($itemArray)) {
  234. if ($itemArray['oldiaid'] > 0) {
  235. $oldiaid = $itemArray['oldiaid'];
  236. } else {
  237. $oldiaid = $imnidArray['iaid'];
  238. }
  239. $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);
  240. $iaid = $this->itemfle->insertItemFileRecord($postArray);
  241. if ($iaid > 1) {
  242. $this->itemmeasurenum->updateIAID($imnidArray['iaid'], $iaid);
  243. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  244. die();
  245. }
  246. }
  247. }
  248. }
  249. }
  250. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  251. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  252. if ($imnidArray['iaid'] > 0) {
  253. $this->itemmeasurenum->updateDeltag($_POST['imnid'], $this->auth->getUid());
  254. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  255. die();
  256. }
  257. }
  258. if (isset($_POST['filename']) && isset($_POST['filedesc']) && isset($_POST['upimnid'])) {
  259. $filename = $_POST['filename'];
  260. $filedesc = $_POST['filedesc'];
  261. $imnidArray = $this->itemmeasurenum->getRowData($_POST['upimnid']);
  262. if ($imnidArray['iaid'] > 0) {
  263. $this->itemmeasurenum->updateItemFields($_POST['upimnid'], $filedesc);
  264. $this->itemfle->updateItemFields($imnidArray['iaid'], $filename);
  265. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  266. die();
  267. }
  268. }
  269. // 面包屑导航项目
  270. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  271. $this->data['pmid'] = $this->params['pmid'];
  272. $allproArray = $this->project->getAll();
  273. foreach ($allproArray as $kk => $vv) {
  274. if ($vv['pid'] == $this->params['pid']) {
  275. $this->data['currproArray'] = $vv;
  276. } else {
  277. $this->data['allproArray'][] = $vv;
  278. }
  279. }
  280. // 面包屑导航合同
  281. $conArray = $this->contractact->getAll();
  282. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  283. if (isset($measureArray['stid'])) {
  284. foreach ($conArray as $kkk => $vvv) {
  285. if ($vvv['stid'] == $measureArray['stid']) {
  286. $this->data['currconArray'] = $vvv;
  287. } else {
  288. if ($vvv['pid'] == $this->params['pid'])
  289. $this->data['allconArray'][] = $vvv;
  290. }
  291. }
  292. } else {
  293. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  294. }
  295. // 面包屑导航标段
  296. $this->data['curractmeasureArray'] = NULL;
  297. $this->data['allactmeasureArray'] = [];
  298. $actmeasureArray = $this->actmeasure->getAll();
  299. foreach ($actmeasureArray as $kkkk => $vvvv) {
  300. if ($vvvv['stid'] == $measureArray['stid']) {
  301. if (($vvvv['pmid'] == $this->params['pmid'])) {
  302. $this->data['curractmeasureArray'] = $vvvv;
  303. } else {
  304. $this->data['allactmeasureArray'][] = $vvvv;
  305. }
  306. }
  307. }
  308. // 选取查询
  309. $groupArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  310. $this->data['groupArray'] = $groupArray;
  311. $owneridArray = $this->itemfle->getGroupOwnerid($this->params['pmid']);
  312. foreach ($owneridArray as $k => $v) {
  313. $this->data['owneridArray'][$k]['name'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  314. $this->data['owneridArray'][$k]['iaid'] = $v['iaid'];
  315. $this->data['owneridArray'][$k]['ownerid'] = $v['ownerid'];
  316. }
  317. // 分页
  318. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid'], 0, $this->params['numpname'], $this->params['userid']);
  319. if ($totalArchive) {
  320. if ($this->params['numpname'] && $this->params['userid']) {
  321. $pager = new DooPager(Doo::conf()->APP_URL . 'rproject/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/num/' . $this->params['numpname'] . '/user/' . $this->params['userid'] . '/page', $totalArchive, 20, 100);
  322. } elseif ($this->params['numpname']) {
  323. $pager = new DooPager(Doo::conf()->APP_URL . 'rproject/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/num/' . $this->params['numpname'] . '/page', $totalArchive, 20, 100);
  324. } elseif ($this->params['userid']) {
  325. $pager = new DooPager(Doo::conf()->APP_URL . 'rproject/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/user/' . $this->params['userid'] . '/page', $totalArchive, 20, 100);
  326. } else {
  327. $pager = new DooPager(Doo::conf()->APP_URL . 'rproject/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/page', $totalArchive, 20, 100);
  328. }
  329. $pager->setCss('', 'disabled', 'active');
  330. if (isset($this->params['pindex']))
  331. $pager->paginate(intval($this->params['pindex']));
  332. else
  333. $pager->paginate(1);
  334. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNum($this->params['pmid'], $pager->limit, $this->params['numpname'], $this->params['userid']);
  335. }
  336. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  337. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  338. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  339. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  340. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  341. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  342. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  343. }
  344. $this->data['pid'] = $this->params['pid'];
  345. $this->data['pmid'] = $this->params['pmid'];
  346. $this->data['mpid'] = $this->params['mpid'];
  347. $this->data['user'] = $this->params['userid'];
  348. $this->data['num'] = $this->params['numpname'];
  349. $this->data['pager'] = $pager->output;
  350. $this->render('r-project-section-files', $this->data, TRUE);
  351. }
  352. function proSectionFilesRecover()
  353. {
  354. if (isset($_POST['optype']) && ($_POST['optype'] == 'reconvery') && isset($_POST['imnid'])) {
  355. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  356. if ($imnidArray['iaid'] > 0) {
  357. $this->itemmeasurenum->recoveryDel($_POST['imnid']);
  358. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  359. die();
  360. }
  361. }
  362. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  363. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  364. if ($imnidArray['iaid'] > 0) {
  365. $iaidArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  366. if ($iaidArray['ownerid'] == $this->auth->getUid()) {
  367. $this->itemfle->delItem($imnidArray['iaid']);
  368. $this->itemmeasurenum->delItemIAID($imnidArray['iaid']);
  369. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  370. die();
  371. } else {
  372. echo json_encode(array('status' => 2), JSON_UNESCAPED_UNICODE);
  373. die();
  374. }
  375. }
  376. }
  377. // 面包屑导航项目
  378. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  379. $this->data['pmid'] = $this->params['pmid'];
  380. $allproArray = $this->project->getAll();
  381. foreach ($allproArray as $kk => $vv) {
  382. if ($vv['pid'] == $this->params['pid']) {
  383. $this->data['currproArray'] = $vv;
  384. } else {
  385. $this->data['allproArray'][] = $vv;
  386. }
  387. }
  388. // 面包屑导航合同
  389. $conArray = $this->contractact->getAll();
  390. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  391. if (isset($measureArray['stid'])) {
  392. foreach ($conArray as $kkk => $vvv) {
  393. if ($vvv['stid'] == $measureArray['stid']) {
  394. $this->data['currconArray'] = $vvv;
  395. } else {
  396. if ($vvv['pid'] == $this->params['pid'])
  397. $this->data['allconArray'][] = $vvv;
  398. }
  399. }
  400. } else {
  401. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  402. }
  403. // 面包屑导航标段
  404. $this->data['curractmeasureArray'] = NULL;
  405. $this->data['allactmeasureArray'] = [];
  406. $actmeasureArray = $this->actmeasure->getAll();
  407. foreach ($actmeasureArray as $kkkk => $vvvv) {
  408. if ($vvvv['stid'] == $measureArray['stid']) {
  409. if (($vvvv['pmid'] == $this->params['pmid'])) {
  410. $this->data['curractmeasureArray'] = $vvvv;
  411. } else {
  412. $this->data['allactmeasureArray'][] = $vvvv;
  413. }
  414. }
  415. }
  416. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid']);
  417. if ($totalArchive) {
  418. $pager = new DooPager(Doo::conf()->APP_URL . 'rproject/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/recover/page', $totalArchive, 20, 100);
  419. $pager->setCss('', 'disabled', 'active');
  420. if (isset($this->params['pindex']))
  421. $pager->paginate(intval($this->params['pindex']));
  422. else
  423. $pager->paginate(1);
  424. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNumDel($pager->limit, $this->params['pmid']);
  425. }
  426. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  427. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  428. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  429. $this->data['itemMeasureArray'][$k]['delname'] = $this->profile->getProWithUid($v['deluid'])['name'];
  430. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  431. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  432. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  433. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  434. $this->data['itemMeasureArray'][$k]['filepath'] = $fileArray['filepath'];
  435. }
  436. $this->data['pid'] = $this->params['pid'];
  437. $this->data['pmid'] = $this->params['pmid'];
  438. $this->data['mpid'] = $this->params['mpid'];
  439. $this->data['pager'] = $pager->output;
  440. $this->render('r-project-section-files-recover', $this->data, TRUE);
  441. }
  442. /**
  443. * @return actMeasure
  444. */
  445. public function proSectionGetFiles()
  446. {
  447. $attaArray = $this->itemfile->getItemFile($this->params['iaid']);
  448. $this->file_down($attaArray['filepath'], $attaArray['filesize'], $attaArray['filename'] . '.' . $attaArray['fileext']);
  449. return;
  450. }
  451. /**
  452. * 文件下载
  453. * @param $filepath 文件路径
  454. * @param $filename 文件名称
  455. */
  456. function file_down($filepath, $filesize, $filename = '')
  457. {
  458. if (!$filename)
  459. $filename = basename($filepath);
  460. if ($this->is_ie())
  461. $filename = rawurlencode($filename);
  462. $filetype = $this->fileext($filename);
  463. // $filesize = sprintf("%u", filesize($filepath));
  464. if (ob_get_length() !== false)
  465. @ob_end_clean();
  466. header('Pragma: public');
  467. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  468. header('Cache-Control: no-store, no-cache, must-revalidate');
  469. header('Cache-Control: pre-check=0, post-check=0, max-age=0');
  470. header('Content-Transfer-Encoding: binary');
  471. header('Content-Encoding: none');
  472. header('Content-type: ' . $filetype);
  473. header('Content-Disposition: attachment; filename="' . $filename . '"');
  474. header('Content-length: ' . $filesize);
  475. @readfile($filepath);
  476. exit;
  477. }
  478. /**
  479. * IE浏览器判断
  480. */
  481. function is_ie()
  482. {
  483. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  484. if ((strpos($useragent, 'opera') !== false) || (strpos($useragent, 'konqueror') !== false))
  485. return false;
  486. if (strpos($useragent, 'msie ') !== false)
  487. return true;
  488. return false;
  489. }
  490. /**
  491. * 取得文件扩展
  492. *
  493. * @param $filename 文件名
  494. * @return 扩展名
  495. */
  496. function fileext($filename)
  497. {
  498. return strtolower(trim(substr(strrchr($filename, '.'), 1, 10)));
  499. }
  500. Function fNumber($number)
  501. {
  502. if ($number == '')
  503. Return "-";
  504. $nlen = strlen($number);
  505. while ($nlen > 3) {
  506. $fNumber = "," . substr($number, $nlen - 3, 3);
  507. $number = substr($number, 0, -3);
  508. $nlen = strlen($number);
  509. }
  510. if ($nlen <= 3) {
  511. $fNumber = $number . $fNumber;
  512. }
  513. Return $fNumber;
  514. }
  515. public function welcome()
  516. {
  517. // if (!$this->auth->isLoggedIn())
  518. // return Doo::conf()->APP_URL;
  519. if ($this->profile->getProWithUid($_SESSION['uid'])['userid'])
  520. return Doo::conf()->APP_URL . 'project/list';
  521. if (isset($_POST['welform'])) {
  522. $profileUserArray = $_POST;
  523. $profileUserArray['userid'] = $_SESSION['uid'];
  524. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  525. return Doo::conf()->APP_URL . 'project/list';
  526. }
  527. $this->render('welcome', $this->data);
  528. }
  529. public function prolist()
  530. {
  531. // if (!$this->auth->isLoggedIn())
  532. // return Doo::conf()->APP_URL;
  533. // $proArray = new stdClass();
  534. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  535. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  536. // if ($handle = opendir($extPathdir)) {
  537. // while (false !== ($file = readdir($handle))) {
  538. // $filename = pathinfo($file);
  539. // if ($filename['extension'] == 'json')
  540. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  541. // }
  542. // closedir($handle);
  543. // }
  544. // $this->data['proArray'] = null;
  545. $this->render('s-project', $this->data);
  546. }
  547. public function proDetail()
  548. {
  549. $numStatusArray = $this->numofperact->getLastRow($this->params['pid'], $this->params['pmid']);
  550. // 项目名称
  551. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  552. foreach ($mpidArray as $k1 => $v1) {
  553. if ($v1['pid'] != $this->params['pid'])
  554. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  555. }
  556. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  557. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  558. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  559. foreach ($this->data['MeasureArray'] as $key => $value) {
  560. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  561. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  562. } else {
  563. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  564. }
  565. }
  566. $this->data['pmid'] = $this->params['pmid'];
  567. $this->data['pid'] = $this->params['pid'];
  568. $this->data['mpid'] = $numStatusArray['mpid'];
  569. $this->render('r-project-section-detail', $this->data, TRUE);
  570. }
  571. public function proReport()
  572. {
  573. // 面包屑导航
  574. // 期数列表
  575. $tmpArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  576. foreach ($tmpArray as $k => $v) {
  577. $intTime = $this->numofperact->getMaxTimes($v['pmid'], $v['numpname'])['times'];
  578. $nfArray[] = $this->numofperact->getRow($v['pmid'], $v['numpname'], $intTime);
  579. }
  580. foreach ($nfArray as $k => $v) {
  581. if ($v['mpid'] == $this->params['mpid']) {
  582. $this->data['mpid'] = $v['mpid'];
  583. $this->data['MeasureArray2'][] = $v;
  584. $this->data['currnum'] = $v['numpname'];
  585. } else {
  586. $this->data['numArray'][] = $v;
  587. }
  588. }
  589. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  590. foreach ($this->data['MeasureArray2'] as $key => $value) {
  591. if ($value['mpid'] == $this->params['mpid']) {
  592. $this->data['MeasureArray2'][$key]['currstatus'] = $this->statusArray[$value['currstatus']];
  593. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  594. $this->data['MeasureArray2'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  595. } else {
  596. $this->data['MeasureArray2'][$key]['lessTotal'] = 0;
  597. }
  598. }
  599. }
  600. //
  601. $lastRowArray = $this->numofperact->getLastNew2($this->params['pmid']);
  602. $maxTimes = $this->numofperact->getMaxTimes($lastRowArray['pmid'], $lastRowArray['numpname']);
  603. // $auditUserArray = $this->measureauditact->getAllAudit($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  604. $maxtimez = $this->measureauditact->getRowGroupByTimes($this->params['mpid']);
  605. $auditUserArray = $this->measureauditact->getRowByMpidTimes($this->params['mpid'], $maxtimez['times']);
  606. $auditArray = $this->measureauditact->getLastNewRowInfo($lastRowArray['pmid'], $lastRowArray['numpname'], $this->auth->getUid());
  607. if (isset($_POST['act'])) {
  608. $auditStatusArray = array('checkno', 'checked');
  609. $myAuditStatus = $this->measureauditact->getMyAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times'], $this->auth->getUid());
  610. if (in_array($myAuditStatus['mastatus'], $auditStatusArray)) {
  611. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  612. die();
  613. }
  614. }
  615. if ($_POST['act'] == 'p') {
  616. if ($this->measureauditact->setMyAuditPass($auditArray['maid'], $_POST['content'], 1, $this->auth->getUid())) {
  617. $countAudit = count($auditUserArray);
  618. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  619. if ($auditArray['last'] == 1) {
  620. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checked', $maxTimes['times']);
  621. // SMS Start
  622. $TenderArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  623. $userProArray = $this->profile->getProWithUid($TenderArray['uid']);
  624. if (isset($userProArray) && ($userProArray['mobile'])) {
  625. $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR3"]);
  626. }
  627. // SMS End
  628. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  629. die();
  630. } else {
  631. if (($countAudit == 2) && ($auditUserArray[1]['last'] == 1) && ($auditUserArray[0]['maid'] == $auditArray['maid'])) {
  632. $this->measureauditact->updateMastatus($auditUserArray[1]['maid']);
  633. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  634. // SMS Start
  635. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[1]['auditoruid']);
  636. $pmnameArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  637. if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// XXXX(标段名),陈特,已审批通过。请您继续审批。
  638. $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  639. }
  640. // SMS End
  641. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  642. die();
  643. }
  644. if (($countAudit > 2)) {
  645. foreach ($auditUserArray as $k => $v) {
  646. if ($v['maid'] == $auditArray['maid']) {
  647. if ($k == ($countAudit - 1)) {//如果是最后一个
  648. $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);
  649. // SMS Start
  650. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[0]['auditoruid']);
  651. // var_dump($verifyUserArray);
  652. $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[0]['pmid']);
  653. // var_dump($pmnameArray);
  654. // SMS End
  655. } else {
  656. $this->measureauditact->updateMastatus($auditUserArray[$k + 1]['maid']);
  657. // SMS Start
  658. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[$k + 1]['auditoruid']);
  659. // var_dump($verifyUserArray);
  660. $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[$k + 1]['pmid']);
  661. // var_dump($pmnameArray);
  662. // SMS End
  663. }
  664. // SMS Start
  665. if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// XXXX(标段名),陈特,已审批通过。请您继续审批。
  666. // $retval = $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  667. $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  668. // var_dump($pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  669. // var_dump($retval);
  670. // var_dump($this->sms->getErrors());
  671. }
  672. // SMS End
  673. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  674. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  675. die();
  676. }
  677. }
  678. }
  679. }
  680. }
  681. }
  682. if ($_POST['act'] == 'np') {
  683. $this->measureauditact->setCheckno($auditArray['maid'], $_POST['content'], 1);
  684. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checkno', $maxTimes['times']);
  685. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  686. // SMS Start
  687. $TenderArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  688. $userProArray = $this->profile->getProWithUid($TenderArray['uid']);
  689. if (isset($userProArray) && ($userProArray['mobile'])) {// // XXXX(标段名),陈特,已审批通过。请您继续审批。
  690. $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR4"]);
  691. // var_dump($retval);
  692. // var_dump($this->sms->getErrors());
  693. // $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR4"]);
  694. }
  695. // SMS End
  696. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  697. die();
  698. }
  699. $this->data['pmid'] = $lastRowArray['pmid'];
  700. $this->data['numpname'] = $lastRowArray['numpname'];
  701. $this->data['times'] = $lastRowArray['times'];
  702. $this->data['pid'] = $this->params['pid'];
  703. foreach ($auditUserArray as $key => $value) {
  704. $strAvatar = $this->auth->getAvatar($value['auditoruid']);
  705. $i = $key + 1;
  706. if ($value['auditoruid'] == $this->auth->getUid()) {
  707. $this->data['mastatus'] = $value['mastatus'];
  708. $this->data['maid'] = $value['maid'];
  709. }
  710. if ($value['mastatus'] == 'uncheck') {
  711. $statuStr = '';
  712. $statucolorStr = '';
  713. $statushtml = '<li title="" class=""><img src="' . $strAvatar . '"></li>';
  714. }
  715. if ($value['mastatus'] == 'checking') {
  716. $statuStr = '<h4 class="colOrange">审批中</h4>';
  717. $statucolorStr = 'colOrange';
  718. $statushtml = '<li title="审批中" class="wait"><span data-icon="k" aria-hidden="true"></span> <img src="' . $strAvatar . '"></li>';
  719. }
  720. if ($value['mastatus'] == 'checked') {
  721. $statuStr = '<h4 class="colGreen">审批完成(' . date('Y-m-d', $value['audittime']) . ')</h4>';
  722. $statucolorStr = 'colGreen';
  723. $statushtml = '<li title="审批通过" class="pass"><span data-icon="d" aria-hidden="true"></span><img src="' . $strAvatar . '"></li>';
  724. }
  725. if ($value['mastatus'] == 'checkno') {
  726. $statuStr = '<h4 class="colRed">审批不通过(' . date('Y-m-d', $value['audittime']) . ')</h4>';
  727. $statucolorStr = 'colRed';
  728. $statushtml = '<li title="审批不通过" class="notpass"><span data-icon="e" aria-hidden="true"></span><img src="' . $strAvatar . '"></li>';
  729. }
  730. $auditUserArray[$key]['statuStr'] = $statuStr;
  731. $auditUserArray[$key]['statucolorStr'] = $statucolorStr;
  732. $auditUserArray[$key]['statushtml'] = $statushtml;
  733. $auditUserArray[$key]['k'] = $i;
  734. $auditUserArray[$key]['name'] = $this->profile->getProWithUid($value['auditoruid'])['name'];
  735. }
  736. $this->data['auditArray'] = $auditUserArray;
  737. $this->data['pmid'] = $this->params['pmid'];
  738. $this->data['pid'] = $this->params['pid'];
  739. $this->data['mpid'] = $this->params['mpid'];
  740. $this->render('r-project-section-report', $this->data, TRUE);
  741. }
  742. /**
  743. * 。
  744. * 标段ID,期号
  745. */
  746. private function __auditNotice($mobile, $text)
  747. {
  748. $smsSwitch = $this->aconfig->getOne(array('select' => 'smsSwitch', 'asArray' => TRUE))['smsSwitch'];
  749. if ($smsSwitch > 0)
  750. return $this->sms->sendSms($mobile, $text);
  751. }
  752. }
  753. ?>