RProjectController.php 43 KB

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