AppController.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <?php
  2. Doo::loadCore('auth/DooAuth');
  3. Doo::loadClass('PasswordHash');
  4. Doo::loadClass('client');
  5. Doo::loadClass('auth');
  6. Doo::loadClass('attachment');
  7. Doo::loadClass('attfile');
  8. Doo::loadClass('actmeasure');
  9. Doo::loadClass('contractact');
  10. Doo::loadClass('project');
  11. Doo::loadClass('profile');
  12. Doo::loadClass('numofperact');
  13. Doo::loadClass('measureauditact');
  14. Doo::loadClass('itemfile');
  15. Doo::loadModel('users');
  16. Doo::loadClass('itemmeasurenum');
  17. Doo::loadModelAt('aconfig', 'admin');
  18. Doo::loadClass('sms');
  19. Doo::loadClass('Hashids/Hashids');
  20. /**
  21. * MainController
  22. * Feel free to delete the methods and replace them with your own code.
  23. *
  24. * @author EllisRan
  25. */
  26. class AppController extends DooController {
  27. private $data, $client, $auth, $att, $file, $zip, $actmeasure, $contractact, $project, $profile, $numofperact, $measureauditact, $attfile, $users, $itemfile, $modelconfig, $aconfig, $sms, $itemMeasureNum, $__hashids;
  28. private $statusArray = array('uncheck' => '1', 'checking' => '2', 'checked' => '3', 'checkno' => '4');
  29. private $fileTypeArray = array('台帐附件');
  30. public function __construct()
  31. {
  32. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  33. $this->client = new client();
  34. $this->auth = new Auth();
  35. $this->att = new attachment();
  36. $this->attfile = new attFile();
  37. // $this->zip = new ZipArchive();
  38. $this->actmeasure = new actMeasure();
  39. $this->contractact = new Contractact();
  40. $this->project = new Project();
  41. $this->profile = new Profile();
  42. $this->numofperact = new NumofperAct();
  43. $this->measureauditact = new MeasureauditAct();
  44. $this->users = new Users();
  45. $this->itemfile = new ItemFile();
  46. $this->modelconfig = new AConfig();
  47. $this->itemMeasureNum = new ItemMeasureNumpofper();
  48. $this->aconfig = new AConfig();
  49. $this->sms = new Sms(Doo::conf()->SMS_URL, Doo::conf()->SMS_AUTHKEY);
  50. $this->__hashids = new Hashids\Hashids('jlzfuserid', 8);
  51. }
  52. public function ServerLogin() {
  53. if(isset($_POST['sname']) && !empty($_POST['sname'])){
  54. $allserver = array($_SERVER['HTTP_HOST']);
  55. if(in_array(trim($_POST['sname']), $allserver)){
  56. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  57. die;
  58. }else{
  59. echo json_encode(array('status' => FALSE, 'msg' => '服务器不存在。'), JSON_UNESCAPED_UNICODE);
  60. die;
  61. }
  62. }else{
  63. echo json_encode(array('status' => FALSE, 'msg' => '请输入服务器名称。'), JSON_UNESCAPED_UNICODE);
  64. die;
  65. }
  66. }
  67. public function AppSignin() {
  68. if(!isset($_POST['username']) || empty($_POST['username'])){
  69. echo json_encode(array('status' => FALSE, 'msg' => '请输入邮箱'), JSON_UNESCAPED_UNICODE);
  70. die;
  71. }
  72. if(!isset($_POST['userpwd']) || empty($_POST['userpwd'])){
  73. echo json_encode(array('status' => FALSE, 'msg' => '请输入密码'), JSON_UNESCAPED_UNICODE);
  74. die;
  75. }
  76. if ($this->auth->login($_POST['username'], $_POST['userpwd'])) {
  77. $uinfo = $this->auth->getUinfo();
  78. if (isset($uinfo['isstop']) && $uinfo['isstop'] > 0) {
  79. echo json_encode(array('status' => FALSE, 'msg' => '邮箱不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
  80. die;
  81. }
  82. if (isset($uinfo['uid'])) {
  83. $userArray = $this->profile->getProWithUid($uinfo['uid']);
  84. $avatarStr = $userArray['avatar'];
  85. if (isset($userArray['userid'])) {
  86. // $this->auth->setUid($uinfo['uid']);
  87. $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr);
  88. echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
  89. die;
  90. }
  91. }
  92. } else {
  93. echo json_encode(array('status' => FALSE, 'msg' => '邮箱不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
  94. die;
  95. }
  96. }
  97. // 获取待审批标段名
  98. public function UnSectionList(){
  99. if(isset($_POST['uid']) && !empty($_POST['uid']) && is_numeric($_POST['uid'])){
  100. $unsectionlist = $this->measureauditact->getCheckedRowbyUID6($_POST['uid']);
  101. $unslist = array();
  102. if(!empty($unsectionlist)){
  103. foreach($unsectionlist as $k => $v){
  104. $unslist[$k]['pname'] = $this->project->getRowByPid($v['pid'])['pname'];
  105. $unslist[$k]['sectionlist'] = array();
  106. $sectionlist = $this->measureauditact->getCheckedRowbyUID7($_POST['uid'],$v['pid']);
  107. if(!empty($sectionlist)){
  108. foreach($sectionlist as $sk => $sv){
  109. $name = $this->actmeasure->getRowByPmid($sv['pmid']);
  110. $unslist[$k]['sectionlist'][$sk]['pmname'] = !empty($name) ? $name['pmname'] : '';
  111. $countNum = $this->numofperact->getLastNew2($sv['pmid'])['numpname'];
  112. $unslist[$k]['sectionlist'][$sk]['countNum'] = !empty($countNum) ? $countNum : 0;
  113. $unslist[$k]['sectionlist'][$sk]['audittime'] = !empty($sv['audittime']) ? date('Y-m-d',$sv['audittime']) : '';
  114. $unslist[$k]['sectionlist'][$sk]['url'] = '/app/rproject/' . $sv['pid'] . '/section/' . $sv['pmid'] . '/detail';
  115. $stname = $this->contractact->getRowByStid($sv['stid']);
  116. $unslist[$k]['sectionlist'][$sk]['stname'] = !empty($stname) ? $stname['stname'] : '';
  117. }
  118. }
  119. }
  120. }
  121. echo json_encode(array('status' => TRUE, 'msg' => '', 'unsectionlist' => $unslist), JSON_UNESCAPED_UNICODE);
  122. die();
  123. }else{
  124. $status = array('status' => FALSE, 'msg' => '获取待审批标段列表出错');
  125. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  126. die();
  127. }
  128. }
  129. //获取已审核项目名
  130. public function ItemCkeckedList(){
  131. if(isset($_POST['uid']) && !empty($_POST['uid']) && is_numeric($_POST['uid'])){
  132. $Itemlist = $this->measureauditact->getCheckedRowbyUID3($_POST['uid']);
  133. $Itemcheckedlist = array();
  134. if(!empty($Itemlist)){
  135. foreach($Itemlist as $k => $v){
  136. $name = $this->project->getRowByPid($v['pid']);
  137. $Itemcheckedlist[$k]['pid'] = $v['pid'];
  138. $Itemcheckedlist[$k]['pname'] = $name['pname'];
  139. }
  140. }
  141. echo json_encode(array('status' => TRUE, 'msg' => '', 'Itemlist' => $Itemcheckedlist), JSON_UNESCAPED_UNICODE);
  142. die();
  143. }else{
  144. $status = array('status' => FALSE, 'msg' => '获取已审核项目列表出错');
  145. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  146. die();
  147. }
  148. }
  149. //获取已审核项目中已审核标段的信息
  150. public function SectionCheckedList(){
  151. if(isset($_POST['uid']) && is_numeric($_POST['uid']) && isset($this->params['pid']) && is_numeric($this->params['pid'])){
  152. //先获取标段类型列表
  153. $stlist = $this->measureauditact->getCheckedRowbyUID4($_POST['uid'], $this->params['pid']);
  154. $sectioncheckedlist = array();
  155. if(!empty($stlist)){
  156. $i = 0;
  157. foreach($stlist as $k => $v){
  158. //再获取标段名信息
  159. $sectionlist = $this->measureauditact->getCheckedRowbyUID5($_POST['uid'], $this->params['pid'],$v['stid']);
  160. $sectioncheckedlistarray = array();
  161. if(!empty($sectionlist)){
  162. $j = 0;
  163. foreach($sectionlist as $key => $value){
  164. $numStatusArray = $this->numofperact->getLastStatus3($this->params['pid'], $value['pmid']);
  165. if (!isset($numStatusArray['currstatus'])) {
  166. $numStatusArray['currstatus'] = 'uncheck';
  167. }
  168. $datatmp = $this->measureauditact->getMyAuditStatus2($numStatusArray['pmid'], $numStatusArray['numpname'], $numStatusArray['times'], $_POST['uid']);
  169. if ($datatmp && ($datatmp['mastatus'] == 'checked' || $datatmp['mastatus'] == 'checkno') ) {
  170. $pmname = $this->actmeasure->getRowByPmid($value['pmid']);
  171. $sectioncheckedlistarray[$j]['pmname'] = !empty($pmname) ? $pmname['pmname'] : '';
  172. $sectioncheckedlistarray[$j]['countNum'] = !empty($datatmp['numpname']) ? $datatmp['numpname'] : 0;
  173. $sectioncheckedlistarray[$j]['audittime'] = !empty($datatmp['audittime']) ? date('Y-m-d',$datatmp['audittime']) : '';
  174. $sectioncheckedlistarray[$j]['url'] = '/app/rproject/' . $this->params['pid'] . '/section/' . $value['pmid'] . '/detail';
  175. $j++;
  176. }
  177. }
  178. }
  179. if(!empty($sectioncheckedlistarray)){
  180. $stname = $this->contractact->getRowByStid($v['stid']);
  181. $sectioncheckedlist[$i]['stname'] = !empty($stname['stname']) ? $stname['stname'] : '';
  182. $sectioncheckedlist[$i]['stlist'] = $sectioncheckedlistarray;
  183. }
  184. $i++;
  185. }
  186. }
  187. echo json_encode(array('status' => TRUE, 'msg' => '', 'sectionlist' => $sectioncheckedlist), JSON_UNESCAPED_UNICODE);
  188. die();
  189. }else{
  190. $status = array('status' => FALSE, 'msg' => '获取已审核标段列表出错');
  191. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  192. die();
  193. }
  194. }
  195. //内嵌app页
  196. public function proDetail() {
  197. if(isset($_GET['uid']) && is_numeric($_GET['uid'])) {
  198. if(isset($_GET['approval'])){
  199. $this->data['approval'] = 1;
  200. }
  201. $numStatusArray = $this->numofperact->getLastStatus3($this->params['pid'], $this->params['pmid']);
  202. if (!isset($numStatusArray['currstatus'])) {
  203. $numStatusArray['currstatus'] = 'uncheck';
  204. }
  205. // 项目名称
  206. $mpidArray = $this->measureauditact->getAuditProject2($_GET['uid']);
  207. foreach ($mpidArray as $k1 => $v1) {
  208. if ($v1['pid'] != $this->params['pid'])
  209. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  210. }
  211. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  212. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  213. $this->data['MeasureArray3'] = array_reverse($this->data['MeasureArray']);
  214. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  215. foreach ($this->data['MeasureArray'] as $key => $value) {
  216. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  217. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  218. } else {
  219. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  220. }
  221. }
  222. // 期数列表
  223. $tmpArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  224. foreach ($tmpArray as $k => $v) {
  225. $intTime = $this->numofperact->getMaxTimes($v['pmid'], $v['numpname'])['times'];
  226. $nfArray[] = $this->numofperact->getRow($v['pmid'], $v['numpname'], $intTime);
  227. }
  228. foreach ($nfArray as $k => $v) {
  229. if ($v['mpid'] == $numStatusArray['mpid']) {
  230. $this->data['mpid'] = $v['mpid'];
  231. $this->data['MeasureArray2'][] = $v;
  232. $this->data['currnum'] = $v['numpname'];
  233. } else {
  234. $this->data['numArray'][] = $v;
  235. }
  236. }
  237. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  238. foreach ($this->data['MeasureArray2'] as $key => $value) {
  239. if ($value['mpid'] == $numStatusArray['mpid']) {
  240. $this->data['MeasureArray2'][$key]['currstatus'] = $this->statusArray[$value['currstatus']];
  241. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  242. $this->data['MeasureArray2'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  243. } else {
  244. $this->data['MeasureArray2'][$key]['lessTotal'] = 0;
  245. }
  246. }
  247. }
  248. $lastRowArray = $this->numofperact->getLastNew2($this->params['pmid']);
  249. $maxTimes = $this->numofperact->getMaxTimes($lastRowArray['pmid'], $lastRowArray['numpname']);
  250. // $auditUserArray = $this->measureauditact->getAllAudit($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  251. // $maxtimez = $this->measureauditact->getRowGroupByTimes($numStatusArray['mpid']);
  252. $maxtimez = $this->numofperact->getRowByMpid($numStatusArray['mpid']);
  253. $auditUserArray = $this->measureauditact->getRowByMpidTimes($numStatusArray['mpid'], $maxtimez['numpname'], $maxtimez['times']);
  254. $auditArray = $this->measureauditact->getLastNewRowInfo($lastRowArray['pmid'], $lastRowArray['numpname'], $_GET['uid']);
  255. if (isset($_POST['act'])) {
  256. $auditStatusArray = array('checkno', 'checked');
  257. $myAuditStatus = $this->measureauditact->getMyAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times'], $_GET['uid']);
  258. if (in_array($myAuditStatus['mastatus'], $auditStatusArray)) {
  259. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  260. die();
  261. }
  262. }
  263. if ($_POST['act'] == 'p') {
  264. if ($this->measureauditact->setMyAuditPass($auditArray['maid'], $_POST['content'], 1, $_GET['uid'])) {
  265. $countAudit = count($auditUserArray);
  266. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  267. if ($auditArray['last'] == 1) {
  268. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checked', $maxTimes['times']);
  269. // SMS Start
  270. $TenderArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  271. $userProArray = $this->profile->getProWithUid($TenderArray['uid']);
  272. if (isset($userProArray) && ($userProArray['mobile'])) {
  273. $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR3"]);
  274. }
  275. // SMS End
  276. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  277. die();
  278. } else {
  279. if (($countAudit == 2) && ($auditUserArray[1]['last'] == 1) && ($auditUserArray[0]['maid'] == $auditArray['maid'])) {
  280. $this->measureauditact->updateMastatus($auditUserArray[1]['maid']);
  281. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  282. // SMS Start
  283. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[1]['auditoruid']);
  284. $pmnameArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  285. if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// XXXX(标段名),陈特,已审批通过。请您继续审批。
  286. $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  287. }
  288. // SMS End
  289. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  290. die();
  291. }
  292. if (($countAudit > 2)) {
  293. foreach ($auditUserArray as $k => $v) {
  294. if ($v['maid'] == $auditArray['maid']) {
  295. if ($k == ($countAudit - 1)) {//如果是最后一个
  296. $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);
  297. // SMS Start
  298. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[0]['auditoruid']);
  299. // var_dump($verifyUserArray);
  300. $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[0]['pmid']);
  301. // var_dump($pmnameArray);
  302. // SMS End
  303. } else {
  304. $this->measureauditact->updateMastatus($auditUserArray[$k + 1]['maid']);
  305. // SMS Start
  306. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[$k + 1]['auditoruid']);
  307. // var_dump($verifyUserArray);
  308. $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[$k + 1]['pmid']);
  309. // var_dump($pmnameArray);
  310. // SMS End
  311. }
  312. // SMS Start
  313. if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// XXXX(标段名),陈特,已审批通过。请您继续审批。
  314. // $retval = $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  315. $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  316. // var_dump($pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  317. // var_dump($retval);
  318. // var_dump($this->sms->getErrors());
  319. }
  320. // SMS End
  321. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  322. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  323. die();
  324. }
  325. }
  326. }
  327. }
  328. }
  329. }
  330. if ($_POST['act'] == 'np') {
  331. $this->measureauditact->setCheckno($auditArray['maid'], $_POST['content'], 1);
  332. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checkno', $maxTimes['times']);
  333. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  334. // SMS Start
  335. $TenderArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  336. $userProArray = $this->profile->getProWithUid($TenderArray['uid']);
  337. if (isset($userProArray) && ($userProArray['mobile'])) {// // XXXX(标段名),陈特,已审批通过。请您继续审批。
  338. $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR4"]);
  339. // var_dump($retval);
  340. // var_dump($this->sms->getErrors());
  341. // $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR4"]);
  342. }
  343. // SMS End
  344. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  345. die();
  346. }
  347. $this->data['pmid'] = $lastRowArray['pmid'];
  348. $this->data['numpname'] = $lastRowArray['numpname'];
  349. $this->data['times'] = $lastRowArray['times'];
  350. foreach ($auditUserArray as $key => $value) {
  351. $strAvatar = $this->auth->getAvatar($value['auditoruid']);
  352. if ($value['auditoruid'] == $_GET['uid']) {
  353. $this->data['mastatus'] = $value['mastatus'];
  354. $this->data['maid'] = $value['maid'];
  355. $name = $this->profile->getProWithUid($value['auditoruid'])['name'].'(我)';
  356. }else{
  357. $name = $this->profile->getProWithUid($value['auditoruid'])['name'];
  358. }
  359. if ($value['mastatus'] == 'uncheck') {
  360. $statushtml = '<div class="approvalImg"><img class="pa2ss" src="'. $strAvatar .'">'.$name.'<b class="colGray fR">待审</b></div>';
  361. }
  362. if ($value['mastatus'] == 'checking') {
  363. $statushtml = '<div class="approvalImg"><img class="wait" src="'. $strAvatar .'">'.$name.'<b class="colOrange fR">审批中</b></div>';
  364. }
  365. if ($value['mastatus'] == 'checked') {
  366. $statushtml = '<div class="approvalImg"><img class="pass" src="'. $strAvatar .'">'.$name.'<b class="colGreen fR">审批完成(' . date('Y-m-d', $value['audittime']) . ')</b></div>';
  367. }
  368. if ($value['mastatus'] == 'checkno') {
  369. $statushtml = '<div class="approvalImg"><img class="unpass" src="'. $strAvatar .'">'.$name.'<b class="colRed fR">审批不通过(' . date('Y-m-d', $value['audittime']) . ')</b></div>';
  370. }
  371. $auditUserArray[$key]['statushtml'] = $statushtml;
  372. }
  373. $strAvatar = $this->auth->getAvatar($measureArray['uid']);
  374. $orginArrayname = $this->profile->getProWithUid($measureArray['uid'])['name'];
  375. $attfileArray = $this->attfile->getFirstFile($lastRowArray['pmid'], $lastRowArray['numpname'], $lastRowArray['times']);
  376. $orginArray['time'] = date('Y-m-d', $attfileArray['intime']);
  377. $orginArray['statushtml'] = '<div class="approvalImg"><img class="pass" src="'. $strAvatar .'">'.$orginArrayname.'<b class="colGreen fR">原报上报(' . $orginArray['time'] . ')</b></div>';
  378. $this->data['auditArray'] = $auditUserArray;
  379. $this->data['orginArray'] = $orginArray;
  380. $this->data['uid'] = $_GET['uid'];
  381. $this->data['pmid'] = $this->params['pmid'];
  382. $this->data['pid'] = $this->params['pid'];
  383. $this->data['mpid'] = $numStatusArray['mpid'];
  384. $this->render('r-project-section-detail-APP', $this->data, TRUE);
  385. }else{
  386. exit('error:无参数无法访问本页');
  387. }
  388. }
  389. //二维数组去掉重复值 并保留键值
  390. function array_unique_fb($array2D)
  391. {
  392. $key = array();
  393. foreach ($array2D as $k => $v) {
  394. if (empty($key))
  395. $key = array_keys($v); //记录数组的KEY
  396. $v = join(",", $v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
  397. $temp[$k] = $v;
  398. }
  399. $temp = array_unique($temp); //去掉重复的字符串,也就是重复的一维数组
  400. foreach ($temp as $k => $v) {
  401. $array = explode(",", $v); //再将拆开的数组重新组装
  402. foreach ($array as $i => $t) {
  403. $temp2[$k] = !empty($temp2[$k]) ? array_merge($temp2[$k], array("{
  404. $key[$i]}" => $t)) : array("{
  405. $key[$i]}" => $t); //依次添加到新的数组中去
  406. }
  407. }
  408. return $temp2;
  409. }
  410. function unique_arr($array2D, $stkeep = false, $ndformat = true)
  411. {
  412. // 判断是否保留一级数组键 (一级数组键可以为非数字)
  413. if ($stkeep)
  414. $stArr = array_keys($array2D);
  415. // 判断是否保留二级数组键 (所有二级数组键必须相同)
  416. if ($ndformat)
  417. $ndArr = array_keys(end($array2D));
  418. //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
  419. foreach ($array2D as $v) {
  420. $v = join(",", $v);
  421. $temp[] = $v;
  422. }
  423. //去掉重复的字符串,也就是重复的一维数组
  424. $temp = array_unique($temp);
  425. //再将拆开的数组重新组装
  426. foreach ($temp as $k => $v) {
  427. if ($stkeep)
  428. $k = $stArr[$k];
  429. if ($ndformat) {
  430. $tempArr = explode(",", $v);
  431. foreach ($tempArr as $ndkey => $ndval) {
  432. $output[$k][$ndArr[$ndkey]] = $ndval;
  433. }
  434. } else {
  435. $output[$k] = explode(",", $v);
  436. }
  437. }
  438. return $output;
  439. }
  440. /**
  441. * 。
  442. * 标段ID,期号
  443. */
  444. private function __auditNotice($mobile, $text)
  445. {
  446. $smsSwitch = $this->aconfig->getOne(array('select' => 'smsSwitch', 'asArray' => TRUE))['smsSwitch'];
  447. if ($smsSwitch > 0)
  448. return $this->sms->sendSms($mobile, $text);
  449. }
  450. function upfile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  451. {
  452. return $this->att->uploadMut($fildname, $param);
  453. }
  454. function upItemFile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  455. {
  456. $this->att->setUploadDir();
  457. return $this->att->uploadMut($fildname, $param);
  458. }
  459. /**
  460. * 根据标段ID获取标段是否已经被删除的提示
  461. * 标段ID
  462. */
  463. public function getCountPmid()
  464. {
  465. if (isset($this->params['tenderid'])) {
  466. $isexist = $this->actmeasure->getCountPmid($this->params['tenderid']);
  467. if ($isexist > 0) {
  468. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => null), JSON_UNESCAPED_UNICODE);
  469. die();
  470. } else {
  471. echo json_encode(array('status' => 'FALSE', 'msg' => '该项目[XXX]在云端已被删除,点击“确定”后,可手动删除该项目'), JSON_UNESCAPED_UNICODE);
  472. die();
  473. }
  474. } else {
  475. $this->msg(0, '获取标段是否存在参数错误');
  476. }
  477. }
  478. function getFileupErrorNo()
  479. {
  480. return $this->att->error();
  481. }
  482. function Signout()
  483. {
  484. session_destroy();
  485. }
  486. function isLoggedIn()
  487. {
  488. return isset($_SESSION['user_id']);
  489. }
  490. function generateFormHash($salt)
  491. {
  492. $hash = md5(mt_rand(1, 1000000) . $salt);
  493. $_SESSION['csrf_hash'] = $hash;
  494. return $hash;
  495. }
  496. function isValidFormHash($hash)
  497. {
  498. return $_SESSION['csrf_hash'] === $hash;
  499. }
  500. /**
  501. * 随机字符串函数
  502. * @param $password 密码
  503. * @param $random 随机数
  504. */
  505. function random($length, $chars = '0123456789')
  506. {
  507. $hash = '';
  508. $max = strlen($chars) - 1;
  509. for ($i = 0; $i < $length; $i++) {
  510. $hash .= $chars[mt_rand(0, $max)];
  511. }
  512. return $hash;
  513. }
  514. /**
  515. * 生成随机字符串
  516. * @param string $lenth 长度
  517. * @return string 字符串
  518. */
  519. function create_randomstr($lenth = 6)
  520. {
  521. return $this->random($lenth, '123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ');
  522. }
  523. function dir_create($path, $mode = 0777)
  524. {
  525. if (is_dir($path))
  526. return TRUE;
  527. $path = $this->dir_path($path);
  528. $parent = dirname($path);
  529. if (!is_dir($parent))
  530. @mkdir($parent, 0777, true);
  531. @mkdir($path, 0777, true);
  532. return is_dir($path);
  533. }
  534. function dir_path($path)
  535. {
  536. $path = str_replace('\\', '/', $path);
  537. if (substr($path, -1) != '/')
  538. $path = $path . '/';
  539. return $path;
  540. }
  541. function msg($isTrue = 0, $msg = null, $retmsg = null)
  542. {
  543. if ($isTrue > 0) {
  544. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  545. die();
  546. } else {
  547. echo json_encode(array('status' => 'FALSE', 'msg' => $msg), JSON_UNESCAPED_UNICODE);
  548. die();
  549. }
  550. }
  551. public function scanValidate(){
  552. if(isset($_POST['app']) && $_POST['app'] == 'jlzfAppScanValidate'){
  553. $uid = $this->__hashids->decode($_POST['user'])[0];
  554. if(!empty($uid) && is_numeric($uid)){
  555. if($this->auth->getWebToken($uid) == $_POST['token']){
  556. $userArray = $this->profile->getProWithUid($uid);
  557. $avatarStr = $userArray['avatar'];
  558. if (isset($userArray['userid'])) {
  559. $msgArray = array('uid' => $uid, 'name' => $userArray['name'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr, 'server' => $_SERVER['HTTP_HOST'], 'token' => $_POST['token']);
  560. echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
  561. exit;
  562. }else{
  563. echo json_encode(array('status' => FALSE, 'msg' => '不存在该用户,请联系我们'), JSON_UNESCAPED_UNICODE);
  564. exit;
  565. }
  566. }else{
  567. echo json_encode(array('status' => FALSE, 'msg' => '请检查二维码是否正确或过期,重新登录web端获取最新二维码或使用账号密码登录'), JSON_UNESCAPED_UNICODE);
  568. exit;
  569. }
  570. }
  571. }
  572. return 'http://a.app.qq.com/o/simple.jsp?pkgname=cn.com.smartcost.jlzf';
  573. }
  574. public function ScanLogin(){
  575. if(isset($_POST['app']) && $_POST['app'] == 'jlzfAppScanLogin'){
  576. $status = $this->auth->checkLoginByScan($_POST['uid'],$_POST['token']);
  577. if($status){
  578. $uinfo = $this->auth->getUinfo();
  579. $userArray = $this->profile->getProWithUid($uinfo['uid']);
  580. $avatarStr = $userArray['avatar'];
  581. if (isset($userArray['userid'])) {
  582. $apptoken = sha1($this->create_randomstr() . $uinfo['uid']);
  583. $this->auth->AppLoginToken($uinfo['uid'],$apptoken);
  584. $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr, 'token' => $apptoken);
  585. echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
  586. die;
  587. }
  588. }else{
  589. echo json_encode(array('status' => FALSE, 'msg' => '请检查二维码是否正确或过期,重新登录web端获取最新二维码或使用账号密码登录'), JSON_UNESCAPED_UNICODE);
  590. exit;
  591. }
  592. }
  593. return 'http://a.app.qq.com/o/simple.jsp?pkgname=cn.com.smartcost.jlzf';
  594. }
  595. public function autoScanLogin(){
  596. if ($this->auth->CheckAppLoginToken($_POST['uid'], $_POST['token'])) {
  597. $uinfo = $this->auth->getUinfo();
  598. if (isset($uinfo['isstop']) && $uinfo['isstop'] > 0) {
  599. echo json_encode(array('status' => FALSE, 'msg' => '账号未启用'), JSON_UNESCAPED_UNICODE);
  600. die;
  601. }
  602. if (isset($uinfo['uid'])) {
  603. $userArray = $this->profile->getProWithUid($uinfo['uid']);
  604. $avatarStr = $userArray['avatar'];
  605. if (isset($userArray['userid'])) {
  606. // $this->auth->setUid($uinfo['uid']);
  607. $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr);
  608. echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
  609. die;
  610. }
  611. }
  612. } else {
  613. echo json_encode(array('status' => FALSE, 'msg' => '您的登录信息已过期,请重新登录'), JSON_UNESCAPED_UNICODE);
  614. die;
  615. }
  616. }
  617. // function checkVersion($version)
  618. // {
  619. // preg_match();
  620. // }
  621. }
  622. ?>