RProjectController.php 42 KB

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