RProjectController.php 43 KB

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