RProjectController.php 42 KB

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