RProjectController.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  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. }
  316. // 分页
  317. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid'], 0, $this->params['numpname'], $this->params['userid']);
  318. if ($totalArchive) {
  319. if ($this->params['numpname'] && $this->params['userid']) {
  320. $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, 30, 100);
  321. } elseif ($this->params['numpname']) {
  322. $pager = new DooPager(Doo::conf()->APP_URL . 'rproject/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/num/' . $this->params['numpname'] . '/page', $totalArchive, 30, 100);
  323. } elseif ($this->params['userid']) {
  324. $pager = new DooPager(Doo::conf()->APP_URL . 'rproject/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/user/' . $this->params['userid'] . '/page', $totalArchive, 30, 100);
  325. } else {
  326. $pager = new DooPager(Doo::conf()->APP_URL . 'rproject/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/page', $totalArchive, 30, 100);
  327. }
  328. $pager->setCss('', 'disabled', 'active');
  329. if (isset($this->params['pindex']))
  330. $pager->paginate(intval($this->params['pindex']));
  331. else
  332. $pager->paginate(1);
  333. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNum($this->params['pmid'], $pager->limit, $this->params['numpname'], $this->params['userid']);
  334. }
  335. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  336. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  337. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  338. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  339. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  340. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  341. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  342. }
  343. $this->data['pid'] = $this->params['pid'];
  344. $this->data['pmid'] = $this->params['pmid'];
  345. $this->data['mpid'] = $this->params['mpid'];
  346. $this->data['user'] = $this->params['userid'];
  347. $this->data['num'] = $this->params['numpname'];
  348. $this->data['pager'] = $pager->output;
  349. $this->render('r-project-section-files', $this->data, TRUE);
  350. }
  351. function proSectionFilesRecover()
  352. {
  353. if (isset($_POST['optype']) && ($_POST['optype'] == 'reconvery') && isset($_POST['imnid'])) {
  354. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  355. if ($imnidArray['iaid'] > 0) {
  356. $this->itemmeasurenum->recoveryDel($_POST['imnid']);
  357. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  358. die();
  359. }
  360. }
  361. if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
  362. $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
  363. if ($imnidArray['iaid'] > 0) {
  364. $iaidArray = $this->itemfle->getItemFile($imnidArray['iaid']);
  365. if ($iaidArray['ownerid'] == $this->auth->getUid()) {
  366. $this->itemfle->delItem($imnidArray['iaid']);
  367. $this->itemmeasurenum->delItemIAID($imnidArray['iaid']);
  368. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  369. die();
  370. } else {
  371. echo json_encode(array('status' => 2), JSON_UNESCAPED_UNICODE);
  372. die();
  373. }
  374. }
  375. }
  376. // 面包屑导航项目
  377. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  378. $this->data['pmid'] = $this->params['pmid'];
  379. $allproArray = $this->project->getAll();
  380. foreach ($allproArray as $kk => $vv) {
  381. if ($vv['pid'] == $this->params['pid']) {
  382. $this->data['currproArray'] = $vv;
  383. } else {
  384. $this->data['allproArray'][] = $vv;
  385. }
  386. }
  387. // 面包屑导航合同
  388. $conArray = $this->contractact->getAll();
  389. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  390. if (isset($measureArray['stid'])) {
  391. foreach ($conArray as $kkk => $vvv) {
  392. if ($vvv['stid'] == $measureArray['stid']) {
  393. $this->data['currconArray'] = $vvv;
  394. } else {
  395. if ($vvv['pid'] == $this->params['pid'])
  396. $this->data['allconArray'][] = $vvv;
  397. }
  398. }
  399. } else {
  400. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  401. }
  402. // 面包屑导航标段
  403. $this->data['curractmeasureArray'] = NULL;
  404. $this->data['allactmeasureArray'] = [];
  405. $actmeasureArray = $this->actmeasure->getAll();
  406. foreach ($actmeasureArray as $kkkk => $vvvv) {
  407. if ($vvvv['stid'] == $measureArray['stid']) {
  408. if (($vvvv['pmid'] == $this->params['pmid'])) {
  409. $this->data['curractmeasureArray'] = $vvvv;
  410. } else {
  411. $this->data['allactmeasureArray'][] = $vvvv;
  412. }
  413. }
  414. }
  415. $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid']);
  416. if ($totalArchive) {
  417. $pager = new DooPager(Doo::conf()->APP_URL . 'rproject/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/recover/page', $totalArchive, 1, 1);
  418. $pager->setCss('', 'disabled', 'active');
  419. if (isset($this->params['pindex']))
  420. $pager->paginate(intval($this->params['pindex']));
  421. else
  422. $pager->paginate(1);
  423. $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNumDel($pager->limit, $this->params['pmid']);
  424. }
  425. foreach ($this->data['itemMeasureArray'] as $k => $v) {
  426. $fileArray = $this->itemfle->getItemFile($v['iaid']);
  427. $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
  428. $this->data['itemMeasureArray'][$k]['delname'] = $this->profile->getProWithUid($v['deluid'])['name'];
  429. $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
  430. $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
  431. $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
  432. $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
  433. $this->data['itemMeasureArray'][$k]['filepath'] = $fileArray['filepath'];
  434. }
  435. $this->data['pid'] = $this->params['pid'];
  436. $this->data['pmid'] = $this->params['pmid'];
  437. $this->data['mpid'] = $this->params['mpid'];
  438. $this->data['pager'] = $pager->output;
  439. $this->render('r-project-section-files-recover', $this->data, TRUE);
  440. }
  441. /**
  442. * @return actMeasure
  443. */
  444. public function proSectionGetFiles()
  445. {
  446. $attaArray = $this->itemfile->getItemFile($this->params['iaid']);
  447. $this->file_down($attaArray['filepath'], $attaArray['filesize'], $attaArray['filename'] . '.' . $attaArray['fileext']);
  448. return;
  449. }
  450. /**
  451. * 文件下载
  452. * @param $filepath 文件路径
  453. * @param $filename 文件名称
  454. */
  455. function file_down($filepath, $filesize, $filename = '')
  456. {
  457. if (!$filename)
  458. $filename = basename($filepath);
  459. if ($this->is_ie())
  460. $filename = rawurlencode($filename);
  461. $filetype = $this->fileext($filename);
  462. // $filesize = sprintf("%u", filesize($filepath));
  463. if (ob_get_length() !== false)
  464. @ob_end_clean();
  465. header('Pragma: public');
  466. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  467. header('Cache-Control: no-store, no-cache, must-revalidate');
  468. header('Cache-Control: pre-check=0, post-check=0, max-age=0');
  469. header('Content-Transfer-Encoding: binary');
  470. header('Content-Encoding: none');
  471. header('Content-type: ' . $filetype);
  472. header('Content-Disposition: attachment; filename="' . $filename . '"');
  473. header('Content-length: ' . $filesize);
  474. @readfile($filepath);
  475. exit;
  476. }
  477. /**
  478. * IE浏览器判断
  479. */
  480. function is_ie()
  481. {
  482. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  483. if ((strpos($useragent, 'opera') !== false) || (strpos($useragent, 'konqueror') !== false))
  484. return false;
  485. if (strpos($useragent, 'msie ') !== false)
  486. return true;
  487. return false;
  488. }
  489. /**
  490. * 取得文件扩展
  491. *
  492. * @param $filename 文件名
  493. * @return 扩展名
  494. */
  495. function fileext($filename)
  496. {
  497. return strtolower(trim(substr(strrchr($filename, '.'), 1, 10)));
  498. }
  499. Function fNumber($number)
  500. {
  501. if ($number == '')
  502. Return "-";
  503. $nlen = strlen($number);
  504. while ($nlen > 3) {
  505. $fNumber = "," . substr($number, $nlen - 3, 3);
  506. $number = substr($number, 0, -3);
  507. $nlen = strlen($number);
  508. }
  509. if ($nlen <= 3) {
  510. $fNumber = $number . $fNumber;
  511. }
  512. Return $fNumber;
  513. }
  514. public function welcome()
  515. {
  516. // if (!$this->auth->isLoggedIn())
  517. // return Doo::conf()->APP_URL;
  518. if ($this->profile->getProWithUid($_SESSION['uid'])['userid'])
  519. return Doo::conf()->APP_URL . 'project/list';
  520. if (isset($_POST['welform'])) {
  521. $profileUserArray = $_POST;
  522. $profileUserArray['userid'] = $_SESSION['uid'];
  523. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  524. return Doo::conf()->APP_URL . 'project/list';
  525. }
  526. $this->render('welcome', $this->data);
  527. }
  528. public function prolist()
  529. {
  530. // if (!$this->auth->isLoggedIn())
  531. // return Doo::conf()->APP_URL;
  532. // $proArray = new stdClass();
  533. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  534. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  535. // if ($handle = opendir($extPathdir)) {
  536. // while (false !== ($file = readdir($handle))) {
  537. // $filename = pathinfo($file);
  538. // if ($filename['extension'] == 'json')
  539. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  540. // }
  541. // closedir($handle);
  542. // }
  543. // $this->data['proArray'] = null;
  544. $this->render('s-project', $this->data);
  545. }
  546. public function proDetail()
  547. {
  548. $numStatusArray = $this->numofperact->getLastRow($this->params['pid'], $this->params['pmid']);
  549. // 项目名称
  550. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  551. foreach ($mpidArray as $k1 => $v1) {
  552. if ($v1['pid'] != $this->params['pid'])
  553. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  554. }
  555. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  556. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  557. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  558. foreach ($this->data['MeasureArray'] as $key => $value) {
  559. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  560. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  561. } else {
  562. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  563. }
  564. }
  565. $this->data['pmid'] = $this->params['pmid'];
  566. $this->data['pid'] = $this->params['pid'];
  567. $this->data['mpid'] = $numStatusArray['mpid'];
  568. $this->render('r-project-section-detail', $this->data, TRUE);
  569. }
  570. public function proReport()
  571. {
  572. // 面包屑导航
  573. // 期数列表
  574. $tmpArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  575. foreach ($tmpArray as $k => $v) {
  576. $intTime = $this->numofperact->getMaxTimes($v['pmid'], $v['numpname'])['times'];
  577. $nfArray[] = $this->numofperact->getRow($v['pmid'], $v['numpname'], $intTime);
  578. }
  579. foreach ($nfArray as $k => $v) {
  580. if ($v['mpid'] == $this->params['mpid']) {
  581. $this->data['mpid'] = $v['mpid'];
  582. $this->data['MeasureArray2'][] = $v;
  583. $this->data['currnum'] = $v['numpname'];
  584. } else {
  585. $this->data['numArray'][] = $v;
  586. }
  587. }
  588. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  589. foreach ($this->data['MeasureArray2'] as $key => $value) {
  590. if ($value['mpid'] == $this->params['mpid']) {
  591. $this->data['MeasureArray2'][$key]['currstatus'] = $this->statusArray[$value['currstatus']];
  592. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  593. $this->data['MeasureArray2'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  594. } else {
  595. $this->data['MeasureArray2'][$key]['lessTotal'] = 0;
  596. }
  597. }
  598. }
  599. //
  600. $lastRowArray = $this->numofperact->getLastNew2($this->params['pmid']);
  601. $maxTimes = $this->numofperact->getMaxTimes($lastRowArray['pmid'], $lastRowArray['numpname']);
  602. // $auditUserArray = $this->measureauditact->getAllAudit($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  603. $maxtimez = $this->measureauditact->getRowGroupByTimes($this->params['mpid']);
  604. $auditUserArray = $this->measureauditact->getRowByMpidTimes($this->params['mpid'], $maxtimez['times']);
  605. $auditArray = $this->measureauditact->getLastNewRowInfo($lastRowArray['pmid'], $lastRowArray['numpname'], $this->auth->getUid());
  606. if (isset($_POST['act'])) {
  607. $auditStatusArray = array('checkno', 'checked');
  608. $myAuditStatus = $this->measureauditact->getMyAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times'], $this->auth->getUid());
  609. if (in_array($myAuditStatus['mastatus'], $auditStatusArray)) {
  610. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  611. die();
  612. }
  613. }
  614. if ($_POST['act'] == 'p') {
  615. if ($this->measureauditact->setMyAuditPass($auditArray['maid'], $_POST['content'], 1, $this->auth->getUid())) {
  616. $countAudit = count($auditUserArray);
  617. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  618. if ($auditArray['last'] == 1) {
  619. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checked', $maxTimes['times']);
  620. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  621. die();
  622. } else {
  623. if (($countAudit == 2) && ($auditUserArray[1]['last'] == 1) && ($auditUserArray[0]['maid'] == $auditArray['maid'])) {
  624. $this->measureauditact->updateMastatus($auditUserArray[1]['maid']);
  625. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  626. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  627. die();
  628. }
  629. if (($countAudit > 2)) {
  630. foreach ($auditUserArray as $k => $v) {
  631. if ($v['maid'] == $auditArray['maid']) {
  632. if ($k == ($countAudit - 1)) {//如果是最后一个
  633. $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);
  634. // SMS Start
  635. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[0]['auditoruid']);
  636. // var_dump($verifyUserArray);
  637. $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[0]['pmid']);
  638. // var_dump($pmnameArray);
  639. // SMS End
  640. } else {
  641. $this->measureauditact->updateMastatus($auditUserArray[$k + 1]['maid']);
  642. // SMS Start
  643. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[$k + 1]['auditoruid']);
  644. // var_dump($verifyUserArray);
  645. $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[$k + 1]['pmid']);
  646. // var_dump($pmnameArray);
  647. // SMS End
  648. }
  649. // SMS Start
  650. if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// XXXX(标段名),陈特,已审批通过。请您继续审批。
  651. // $retval = $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  652. $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  653. // var_dump($pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  654. // var_dump($retval);
  655. // var_dump($this->sms->getErrors());
  656. }
  657. // SMS End
  658. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  659. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  660. die();
  661. }
  662. }
  663. }
  664. }
  665. }
  666. }
  667. if ($_POST['act'] == 'np') {
  668. $this->measureauditact->setCheckno($auditArray['maid'], $_POST['content'], 1);
  669. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checkno', $maxTimes['times']);
  670. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  671. // SMS Start
  672. $TenderArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  673. $userProArray = $this->profile->getProWithUid($TenderArray['uid']);
  674. if (isset($userProArray) && ($userProArray['mobile'])) {// // XXXX(标段名),陈特,已审批通过。请您继续审批。
  675. $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR4"]);
  676. }
  677. // SMS End
  678. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  679. die();
  680. }
  681. $this->data['pmid'] = $lastRowArray['pmid'];
  682. $this->data['numpname'] = $lastRowArray['numpname'];
  683. $this->data['times'] = $lastRowArray['times'];
  684. $this->data['pid'] = $this->params['pid'];
  685. foreach ($auditUserArray as $key => $value) {
  686. $strAvatar = $this->auth->getAvatar($value['auditoruid']);
  687. $i = $key + 1;
  688. if ($value['auditoruid'] == $this->auth->getUid()) {
  689. $this->data['mastatus'] = $value['mastatus'];
  690. $this->data['maid'] = $value['maid'];
  691. }
  692. if ($value['mastatus'] == 'uncheck') {
  693. $statuStr = '';
  694. $statucolorStr = '';
  695. $statushtml = '<li title="" class=""><img src="' . $strAvatar . '"></li>';
  696. }
  697. if ($value['mastatus'] == 'checking') {
  698. $statuStr = '<h4 class="colOrange">审批中</h4>';
  699. $statucolorStr = 'colOrange';
  700. $statushtml = '<li title="审批中" class="wait"><span data-icon="k" aria-hidden="true"></span> <img src="' . $strAvatar . '"></li>';
  701. }
  702. if ($value['mastatus'] == 'checked') {
  703. $statuStr = '<h4 class="colGreen">审批完成(' . date('Y-m-d', $value['audittime']) . ')</h4>';
  704. $statucolorStr = 'colGreen';
  705. $statushtml = '<li title="审批通过" class="pass"><span data-icon="d" aria-hidden="true"></span><img src="' . $strAvatar . '"></li>';
  706. }
  707. if ($value['mastatus'] == 'checkno') {
  708. $statuStr = '<h4 class="colRed">审批不通过(' . date('Y-m-d', $value['audittime']) . ')</h4>';
  709. $statucolorStr = 'colRed';
  710. $statushtml = '<li title="审批不通过" class="notpass"><span data-icon="e" aria-hidden="true"></span><img src="' . $strAvatar . '"></li>';
  711. }
  712. $auditUserArray[$key]['statuStr'] = $statuStr;
  713. $auditUserArray[$key]['statucolorStr'] = $statucolorStr;
  714. $auditUserArray[$key]['statushtml'] = $statushtml;
  715. $auditUserArray[$key]['k'] = $i;
  716. $auditUserArray[$key]['name'] = $this->profile->getProWithUid($value['auditoruid'])['name'];
  717. }
  718. $this->data['auditArray'] = $auditUserArray;
  719. $this->data['pmid'] = $this->params['pmid'];
  720. $this->data['pid'] = $this->params['pid'];
  721. $this->data['mpid'] = $this->params['mpid'];
  722. $this->render('r-project-section-report', $this->data, TRUE);
  723. }
  724. /**
  725. * 。
  726. * 标段ID,期号
  727. */
  728. private function __auditNotice($mobile, $text)
  729. {
  730. $smsSwitch = $this->aconfig->getOne(array('select' => 'smsSwitch', 'asArray' => TRUE))['smsSwitch'];
  731. if ($smsSwitch > 0)
  732. return $this->sms->sendSms($mobile, $text);
  733. }
  734. }
  735. ?>