ClientController.php 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229
  1. <?php
  2. ini_set('display_errors',on);
  3. Doo::loadCore('auth/DooAuth');
  4. Doo::loadClass('PasswordHash');
  5. Doo::loadClass('client');
  6. Doo::loadClass('auth');
  7. Doo::loadClass('attachment');
  8. Doo::loadClass('attfile');
  9. Doo::loadClass('actmeasure');
  10. Doo::loadClass('contractact');
  11. Doo::loadClass('project');
  12. Doo::loadClass('profile');
  13. Doo::loadClass('numofperact');
  14. Doo::loadClass('measureauditact');
  15. Doo::loadClass('itemfile');
  16. Doo::loadModel('users');
  17. /**
  18. * MainController
  19. * Feel free to delete the methods and replace them with your own code.
  20. *
  21. * @author NoNZero
  22. */
  23. class ClientController extends DooController
  24. {
  25. private $data, $client, $auth, $att, $file, $zip, $actmeasure, $contractact, $project, $profile, $numofperact, $measureauditact, $attfile, $users, $itemfile;
  26. private $statusArray = array('uncheck' => '1', 'checking' => '2', 'checked' => '3', 'checkno' => '4');
  27. private $fileTypeArray = array('台帐附件');
  28. public function __construct()
  29. {
  30. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  31. $this->client = new client();
  32. $this->auth = new Auth();
  33. $this->att = new attachment();
  34. $this->attfile = new attFile();
  35. $this->zip = new ZipArchive();
  36. $this->actmeasure = new actMeasure();
  37. $this->contractact = new Contractact();
  38. $this->project = new Project();
  39. $this->profile = new Profile();
  40. $this->numofperact = new NumofperAct();
  41. $this->measureauditact = new MeasureauditAct();
  42. $this->users = new Users();
  43. $this->itemfile = new ItemFile();
  44. }
  45. public function ClientSignin()
  46. {
  47. if (isset($_POST['zhname']) && isset($_POST['zhpass'])) {
  48. echo json_encode(array('status' => FALSE, 'msg' => '登录失败,请更新软件。'), JSON_UNESCAPED_UNICODE);
  49. die;
  50. }
  51. if (isset($_POST['uname']) && isset($_POST['upass'])) {
  52. echo json_encode(array('status' => FALSE, 'msg' => '登录失败,请更新软件。'), JSON_UNESCAPED_UNICODE);
  53. die;
  54. }
  55. if (isset($_POST['v3name']) && isset($_POST['v3pass']))
  56. try {
  57. if ($this->auth->login($_POST['v3name'], $_POST['v3pass'])) {
  58. $uinfo = $this->auth->getUinfo();
  59. if (isset($uinfo['isstop']) && $uinfo['isstop'] > 0) {
  60. echo json_encode(array('status' => FALSE, 'msg' => '用户名或密码错误'), JSON_UNESCAPED_UNICODE);
  61. die;
  62. }
  63. if (isset($uinfo['uid'])) {
  64. $userArray = $this->profile->getProWithUid($uinfo['uid']);
  65. $avatarStr = $userArray['avatar'];
  66. if (isset($userArray['userid'])) {
  67. $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr);
  68. echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
  69. die;
  70. }
  71. }
  72. } else {
  73. echo json_encode(array('status' => FALSE, 'msg' => '用户名或密码错误'), JSON_UNESCAPED_UNICODE);
  74. die;
  75. }
  76. } catch (Exception $exc) {
  77. }
  78. }
  79. // 创建标段
  80. // 参数:用户ID,创建名称,KEY
  81. function ClientCreatmeasure()
  82. {
  83. if (isset($this->params['uid']) && $this->params['uid'] && isset($this->params['bname']) && $this->params['bname'] && $this->params['ckey'] && isset($this->params['ckey'])) {
  84. $retval = $this->contractact->getPidWithKey($this->params['ckey']);
  85. if (isset($retval['pid'])) {
  86. $pArray = $this->project->getRowByPid($retval['pid']);
  87. if (isset($this->params['uid']) && ($this->params['uid'] == $pArray['uid'])) {
  88. $status = array('status' => FALSE, 'msg' => '业主不能作为编制人新建标段!');
  89. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  90. die();
  91. }
  92. $id = $this->actmeasure->insertMeasure(intval($this->params['uid']), $retval['pid'], $retval['stid'], iconv('GBK', 'UTF-8', $this->params['bname']));
  93. $this->measureauditact->insertMeasureAudit($pArray['pid'], 0, $pArray['uid'], 0, $id, $retval['stid'], 1, 'uncheck', 1); //加入业主
  94. $uArray = $this->profile->getProWithUid($retval['uid']);
  95. $strAvatar = $this->auth->getAvatar($uArray['userid']);
  96. $createArray = array('catid' => $id, 'name' => $uArray['name'], 'avatar' => $strAvatar, 'jobs' => $uArray['jobs'], 'company' => $uArray['company'], 'coninfo' => array('phone' => $uArray['phone'], 'mobile' => $uArray['mobile'], 'qq' => $uArray['qq']), 'pname' => $pArray['pname'], 'ptype' => $retval['stname'], 'ownuid' => $pArray['uid'], 'pnameid' => $pArray['pid'], 'ptypeid' => $retval['stid']);
  97. $status = array('status' => TRUE, 'msg' => '', 'createinfo' => $createArray);
  98. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  99. die();
  100. } else {
  101. $status = array('status' => FALSE, 'msg' => 'The key is error');
  102. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  103. die();
  104. }
  105. } else {
  106. $status = array('status' => FALSE, 'msg' => 'error_create');
  107. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  108. die();
  109. }
  110. }
  111. // 编制人审核第一期时 开始审核第一期时候调用ll
  112. public function ClientPeriod()
  113. {
  114. // TODO:上报数据
  115. // TODO:每期更新数据时候和上传时候要查询当前进行期数的第几次一并写入数据库
  116. if (isset($this->params['userid']) && isset($this->params['tenderid']) && isset($this->params['phaseno']) && isset($_POST['MD5_JL']) && isset($_POST['MD5_Zip'])) {
  117. $fp = $this->upfile('upfile');
  118. if (isset($fp[0]['filepath'])) {
  119. /**
  120. * 增加上传压缩包md5检测机制
  121. */
  122. $localmd5HashString = hash_file("md5",Doo::conf()->SITE_PATH . $fp[0]['filepath']);
  123. if($localmd5HashString!=trim($_POST['MD5_Zip'])){
  124. $status = array('status' => 'FALSE', 'msg' => '期数数据上传失败,请重新上传');
  125. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  126. die();
  127. }
  128. $res = $this->zip->open(Doo::conf()->SITE_PATH . $fp[0]['filepath']);
  129. $extPath = pathinfo($fp[0]['filepath']);
  130. $extPathdir = Doo::conf()->SITE_PATH . $extPath['dirname'] . '/' . $extPath['filename'];
  131. if ($res === TRUE) {
  132. if (!$this->dir_create($extPathdir)) {
  133. $status = array('status' => 'FALSE', 'msg' => '期数数据上传失败');
  134. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  135. die();
  136. }
  137. $this->zip->extractTo($extPathdir);
  138. $this->zip->close();
  139. }
  140. $countArray = json_decode(file_get_contents($extPathdir . '/' . 'JsonFile_Common.json'), TRUE, JSON_UNESCAPED_UNICODE);
  141. if (!isset($countArray)) {
  142. $status = array('status' => 'FALSE', 'msg' => '期数汇总数据上传失败');
  143. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  144. die();
  145. }
  146. $this->actmeasure->updateCon($this->params['tenderid'], $countArray['TotalPrice']);
  147. $pmArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);
  148. if (isset($pmArray['pmid'])) {
  149. // 由于不通过功能数据表记录重复写入时要考虑当前是第几次审核
  150. $intMaxTimes = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno']);
  151. if (isset($intMaxTimes['times']) && ($intMaxTimes['times'] >= 0)) {
  152. $iniTimes = $intMaxTimes['times'] + 1;
  153. } else {
  154. $iniTimes = 0;
  155. }
  156. // 写入第一期
  157. $mpid = $this->numofperact->insert($pmArray['pid'], $this->params['userid'], $this->params['tenderid'], $pmArray['stid'], $this->params['phaseno'], $countArray['BQHTJL'], $countArray['BQSLBGJL'], $countArray['JZSQLJWC'], $countArray['BQWCJL'], $countArray['LJWCJL'], $iniTimes);
  158. // 更新审核人MPID
  159. $this->measureauditact->updateAuditorMPID($mpid, $this->params['tenderid'], $this->params['phaseno'], $iniTimes);
  160. // 设置审核人状态
  161. $firstAuditor = $this->measureauditact->getFirstAuditor($this->params['tenderid'], $this->params['phaseno'], $iniTimes);
  162. if (isset($firstAuditor)) {
  163. if ($firstAuditor['mastatus'] == 'uncheck') {
  164. $this->measureauditact->updateMastatus($firstAuditor['maid']);
  165. }
  166. }
  167. }
  168. if ($mpid > 0) {
  169. if ($this->attfile->insertFile($pmArray['pid'], $pmArray['stid'], $mpid, $this->params['tenderid'], $this->params['phaseno'], $this->params['userid'], $fp[0]['filepath'], 0, $_POST['MD5_JL'], $iniTimes)) {
  170. $infostatus = 0;
  171. $pmArray = $this->numofperact->getRowTender($this->params['tenderid']);
  172. if ($pmArray) {
  173. $countTotal = count($pmArray);
  174. $ownerStatusArray = $this->measureauditact->getStatusTender($pmArray[0]['pmid'], $pmArray[0]['numpname']);
  175. if ($ownerStatusArray) {
  176. $infostatus = $this->statusArray[$ownerStatusArray['mastatus']];
  177. }
  178. echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('curr' => $pmArray[0]['numpname'], 'infostatus' => $infostatus, 'total' => $countTotal)), JSON_UNESCAPED_UNICODE);
  179. die();
  180. } else {
  181. echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('curr' => 1, 'infostatus' => 1, 'total' => 1)), JSON_UNESCAPED_UNICODE);
  182. die();
  183. }
  184. } else {
  185. $status = array('status' => 'FALSE', 'msg' => '期数上传失败');
  186. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  187. die();
  188. }
  189. } else {
  190. $status = array('status' => 'FALSE', 'msg' => '期数上传失败');
  191. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  192. die();
  193. }
  194. } else {
  195. $status = array('status' => 'FALSE', 'msg' => '文件上传失败,请重试');
  196. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  197. die();
  198. }
  199. } else {
  200. $status = array('status' => 'FALSE', 'msg' => '上传参数错误');
  201. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  202. die();
  203. }
  204. }
  205. /**
  206. * 获取标段状态信息(由于加入了)
  207. * 每个标段只有一期在进行中 group by?
  208. *
  209. * 查询标段的审核状态可以根据业主的审核依据来查询
  210. * 如果除业主意外的人审核状态为未通过怎么处理
  211. */
  212. public function getMAStatus()
  213. {
  214. // curr:当前期数,status:当前状态,total:总期数
  215. // 参数catid
  216. if (isset($this->params['tenderid'])) {
  217. $pmArray = $this->numofperact->getRowTenderCurr($this->params['tenderid']);
  218. $countTotal = count($pmArray);
  219. $ownerStatus = NULL;
  220. $isUnCheck = TRUE;
  221. $ownerStatusArray = $this->measureauditact->getStatusTen($pmArray[0]['pmid'], $pmArray[0]['numpname']);
  222. // if (isset($ownerStatusArray))
  223. // if (($ownerStatusArray[0]['last'] == 1) && ($ownerStatusArray[0]['mastatus'] == 'checked')) {
  224. // $ownerStatus = 'checked';
  225. // } else {
  226. // $ownerStatus = 'checking';
  227. // }
  228. $statusArray = $this->numofperact->getMaxRowStatus($pmArray[0]['pmid'], $pmArray[0]['numpname']);
  229. $ownerStatus = $statusArray['currstatus'];
  230. // foreach ($ownerStatusArray as $kk => $vv) {
  231. // if (($vv['last'] == 1) && ($vv['mastatus'] == 'checked')) {
  232. // $ownerStatus = 'checked';
  233. // } else {
  234. // $ownerStatus = 'checking';
  235. // }
  236. // }
  237. $projectArray = $this->project->getRowByPid($ownerStatusArray[0]['pid']);
  238. $stArray = $this->contractact->getRowByStid($ownerStatusArray[0]['stid']);
  239. $profileArray = $this->profile->getProWithUid($projectArray['uid']);
  240. $auditArray = $this->measureauditact->getAuditUserRedo($pmArray[0]['pmid'], $pmArray[0]['numpname']);
  241. if (isset($auditArray[0]['auditoruid'])) {
  242. foreach ($auditArray as $key => $value) {
  243. $userArray = $this->profile->getProWithUid($value['auditoruid']);
  244. // $finalStatus = $value['mastatus'];
  245. if ($value['mastatus'] != 'uncheck') {
  246. $isUnCheck = FALSE;
  247. }
  248. if($value['audittime']>0){
  249. $value['audittime'] = date('Y-m-d',$value['audittime']);
  250. }
  251. $auditInfo[] = array('uid' => $userArray['userid'], 'name' => $userArray['name'], 'company' => $userArray['company'], 'jobs' => $userArray['jobs'], 'avatar' => $this->auth->getAvatar($value['auditoruid']), 'mastatus' => $this->statusArray[$value['mastatus']], 'CheckerMemo' => $value['auditcontent'],'onlineaudit' => $value['onlineaudit'],'audittime'=>$value['audittime']);
  252. }
  253. }
  254. if ($ownerStatusArray) {
  255. if ($isUnCheck) {
  256. echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('curr' => $pmArray[0]['numpname'], 'infostatus' => $this->statusArray['uncheck'], 'total' => "$countTotal", 'proName' => $projectArray['pname'], 'stName' => $stArray['stname'], 'name' => $profileArray['name'], 'company' => $profileArray['company'], 'jobs' => $profileArray['jobs']), 'auditinfo' => $auditInfo), JSON_UNESCAPED_UNICODE);
  257. } else {
  258. echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('curr' => $pmArray[0]['numpname'], 'infostatus' => $this->statusArray[$ownerStatus], 'total' => "$countTotal", 'proName' => $projectArray['pname'], 'stName' => $stArray['stname'], 'name' => $profileArray['name'], 'company' => $profileArray['company'], 'jobs' => $profileArray['jobs']), 'auditinfo' => $auditInfo), JSON_UNESCAPED_UNICODE);
  259. }
  260. die();
  261. } else {
  262. echo json_encode(array('status' => 'FALSE', 'msg' => '标段状态查询不存在'), JSON_UNESCAPED_UNICODE);
  263. die();
  264. }
  265. } else {
  266. echo json_encode(array('status' => 'FALSE', 'msg' => '标段状态查询参数错误'), JSON_UNESCAPED_UNICODE);
  267. die();
  268. }
  269. }
  270. public function getUserSearch()
  271. {
  272. if (isset($_POST['uemail']) && filter_var($_POST['uemail'], FILTER_VALIDATE_EMAIL)) {
  273. $retval = $this->users->getOne(array('where' => 'uemail=?', 'param' => array($_POST['uemail']), 'asArray' => TRUE));
  274. if (isset($retval['uid'])) {
  275. $proArray = $this->profile->getProWithUid($retval['uid']);
  276. if (isset($proArray['userid'])) {
  277. $strAvatar = $this->auth->getAvatar($proArray['userid']);
  278. echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('uid' => $proArray['userid'], 'avatar' => $strAvatar, 'name' => $proArray['name'], 'jobs' => $proArray['jobs'], 'company' => $proArray['company'])), JSON_UNESCAPED_UNICODE);
  279. die();
  280. } else {
  281. echo json_encode(array('status' => 'FALSE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  282. die();
  283. }
  284. } else {
  285. echo json_encode(array('status' => 'FALSE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  286. die();
  287. }
  288. } else {
  289. echo json_encode(array('status' => 'FALSE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  290. die();
  291. }
  292. }
  293. /**
  294. * 获取指定标段指定期数{默认提取重做后最新一期的}
  295. * 单击获取项目相关审核人员和状态
  296. * sectionid:标段ID periodid:期数
  297. * TODO:如果审核人的期数或者次数与标段期数或者次数存在不对应情况的处理
  298. */
  299. public function getAlluserMeasure()
  300. {
  301. if (isset($this->params['tenderid']) && isset($this->params['phaseno'])) {
  302. // error_log(var_export($this->params, TRUE), 3, '/opt/html/jlzftest/data/' . time());
  303. // 先判断是否存在期数问题
  304. // 然后再判断是否存在次数不匹配
  305. // $intNum = $this->numofperact->getCountNumpname($this->params['tenderid'], $this->params['phaseno']);
  306. // // 如果期数是第一期期数必须大于一,否则减一为无效数据 ,为0表示这期为做上报没有产生记录
  307. // if (( $this->params['phaseno'] > 1) && ($intNum == 0)) {// 提取上一期的数据
  308. // // 提取期数减一
  309. // $intLastTimes = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno'] - 1)['times'];
  310. // $uinfoTmpArray = $this->measureauditact->getAllAudit($this->params['tenderid'], $this->params['phaseno'] - 1, $intLastTimes);
  311. // } else {
  312. // $IntMaxRedoTimes = $this->measureauditact->getMaxTimes($this->params['tenderid'], $this->params['phaseno'])['maxtimes'];
  313. // $intTimes = $this->numofperact->getCountTimes($this->params['tenderid'], $this->params['phaseno'], $IntMaxRedoTimes);
  314. // if (($intTimes == 0) && ($IntMaxRedoTimes > 0)) {
  315. // $lastTimes = $IntMaxRedoTimes - 1;
  316. // $uinfoTmpArray = $this->measureauditact->getAllAudit($this->params['tenderid'], $this->params['phaseno'], $lastTimes);
  317. // } else {
  318. // $uinfoTmpArray = $this->measureauditact->getAllAudit($this->params['tenderid'], $this->params['phaseno'], $IntMaxRedoTimes);
  319. // }
  320. // }
  321. $uinfoTmpArray = $this->measureauditact->getAlluserMeasureAudit($this->params['tenderid'], $this->params['phaseno']);
  322. if ($uinfoTmpArray) {
  323. foreach ($uinfoTmpArray as $key => $value) {
  324. $uArray = $this->profile->getProWithUid($value['auditoruid']);
  325. $uinfoArray[$key]['name'] = $uArray['name'];
  326. $uinfoArray[$key]['company'] = $uArray['company'];
  327. $uinfoArray[$key]['jobs'] = $uArray['jobs'];
  328. $uinfoArray[$key]['mastatus'] = $this->statusArray[$value['mastatus']];
  329. $uinfoArray[$key]['uid'] = $value['auditoruid'];
  330. $uinfoArray[$key]['avatar'] = $this->auth->getAvatar($value['auditoruid']);
  331. $uinfoArray[$key]['CheckerMemo'] = $value['auditcontent'];
  332. $uinfoArray[$key]['onlineaudit'] = $value['onlineaudit'];
  333. if($value['audittime']>0){
  334. $uinfoArray[$key]['audittime'] = date('Y-m-d',$value['audittime']);
  335. }else{
  336. $uinfoArray[$key]['audittime'] = 0;
  337. }
  338. }
  339. } else {
  340. echo json_encode(array('status' => FALSE, 'msg' => '用户列表不存在'), JSON_UNESCAPED_UNICODE);
  341. die();
  342. }
  343. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $uinfoArray), JSON_UNESCAPED_UNICODE);
  344. die();
  345. } else {
  346. echo json_encode(array('status' => FALSE, 'msg' => '错误'), JSON_UNESCAPED_UNICODE);
  347. die();
  348. }
  349. }
  350. //
  351. //
  352. // 配置审核人时候还没有创建标段所以没有MPID存在
  353. function addAuditMeasure()
  354. {
  355. // 必须检查期数是否存在
  356. // 标段ID 当前登录 审核人ID
  357. // 检测是否重复写入 && ($_POST['creatoruid'] > 0)
  358. // TODO: 增加多次审核人变更需求,调整审核人增加、删除接口
  359. // 当前操作的是否为最新一期还是最新一期加一(项目进行中时,不能编辑审核人,所以直接加一)
  360. // 大于一次重做的时候,自动复制编制人和所有审核人次数加一
  361. if (isset($_POST['pmid']) && isset($_POST['creatoruid']) && isset($_POST['auditoruid']) && isset($_POST['numpname'])) {
  362. $IntMaxTimes = $this->measureauditact->getMaxTimesInt($_POST['pmid'], $_POST['numpname']); // 根据标段PMID,期数numpname,获取目前重做次数
  363. if ($IntMaxTimes > 0) {
  364. $inTimes = $IntMaxTimes;
  365. } else {
  366. $inTimes = 0;
  367. }
  368. $pmArray = $this->actmeasure->getRowByPmid($_POST['pmid']);
  369. try {
  370. if ($this->measureauditact->insertMeasureAudit($pmArray['pid'], $_POST['creatoruid'], $_POST['auditoruid'], 0, $_POST['pmid'], $pmArray['stid'], $_POST['numpname'], 'uncheck', 2, $inTimes) > 0) {
  371. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => ''), JSON_UNESCAPED_UNICODE);
  372. die();
  373. }
  374. } catch (PDOException $e) {// 判断异常类型,提示不同错误信息
  375. echo json_encode(array('status' => FALSE, 'msg' => '配置审核人错误'), JSON_UNESCAPED_UNICODE);
  376. }
  377. } else {
  378. echo json_encode(array('status' => FALSE, 'msg' => '配置审核人参数错误'), JSON_UNESCAPED_UNICODE);
  379. die();
  380. }
  381. }
  382. /**
  383. * 删除审核用户
  384. */
  385. function delAuditMeasure()
  386. {
  387. if (isset($this->params['userid']) && isset($this->params['tenderid']) && isset($this->params['phaseno'])) {
  388. // 判断当前标段期数审核状态,决定是否继续执行
  389. $IntMaxTimes = $this->measureauditact->getMaxTimesInt($this->params['tenderid'], $this->params['phaseno']); // 根据标段PMID,期数numpname,获取目前重做次数
  390. if ($IntMaxTimes > 0) {
  391. $inTimes = $IntMaxTimes;
  392. $intHasCount = $this->numofperact->hasTheTimesRow($this->params['tenderid'], $this->params['phaseno'], $inTimes);
  393. if (isset($intHasCount) && ($intHasCount > 0)) {
  394. echo json_encode(array('status' => FALSE, 'msg' => '此标段状态,禁止删除审核人员'), JSON_UNESCAPED_UNICODE);
  395. die();
  396. }
  397. } else {
  398. $inTimes = 0;
  399. }
  400. try {
  401. $this->measureauditact->delAuditUserTimes($this->params['tenderid'], $this->params['phaseno'], $this->params['userid'], $inTimes);
  402. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  403. die();
  404. } catch (PDOException $e) {// 判断异常类型,提示不同错误信息
  405. echo json_encode(array('status' => FALSE, 'msg' => '删除审核人错误'), JSON_UNESCAPED_UNICODE);
  406. }
  407. } else {
  408. echo json_encode(array('status' => FALSE, 'msg' => '删除审核人员参数错误'), JSON_UNESCAPED_UNICODE);
  409. die();
  410. }
  411. }
  412. // 查询状态变更为审核中,已审核中为查询依据
  413. function checkMeasureStatus()
  414. {
  415. if (isset($_POST['sectionid']) && isset($_POST['periodid'])) {
  416. $mpArray = $this->numofperact->getRow($_POST['sectionid'], $_POST['periodid']);
  417. $maArray = $this->measureauditact->getAlluserMeasureAudit($_POST['sectionid'], $_POST['periodid']);
  418. foreach ($maArray as $key => $value) {
  419. if ($value['mastatus'] == 'uncheck') {
  420. $mastatus = $this->statusArray[$value['mastatus']];
  421. }
  422. }
  423. if (isset($mpArray['mpid'])) {
  424. echo json_encode(array('status' => TRUE, 'msg' => '', 'isexist' => TRUE, 'checkstatus' => $mastatus), JSON_UNESCAPED_UNICODE);
  425. die();
  426. } else {
  427. echo json_encode(array('status' => TRUE, 'msg' => '', 'isexist' => FALSE), JSON_UNESCAPED_UNICODE);
  428. die();
  429. }
  430. } else {
  431. echo json_encode(array('status' => FALSE, 'msg' => '标段信息不正确'), JSON_UNESCAPED_UNICODE);
  432. die();
  433. }
  434. }
  435. // 根据用户查询参与的标段信息
  436. // 参数为1时,当提交的附件中有重做记录时,提取记录未经过排重处理,出现重复结果。
  437. // api/client/user/get/15/allproject 此接口也有同样问题
  438. function getAuditProject()
  439. {
  440. // TODO:可以通过SQL直接查询出来
  441. if (isset($_POST['audituid']) && isset($_POST['RequestType'])) {
  442. $downfileurl = NULL;
  443. /**
  444. * 只查询审核中状态的记录
  445. * 然后根据每天记录所在的标段、期数、创建人查询所有此次所有审核人记录、为了判断
  446. * 判断此用户是第几个审核的人
  447. * 直接提取状态为未审核、审核中的
  448. * 未审核(没有到该审核人)
  449. * 审核中(出现在第一个)
  450. * 上传审核时候先遍历所有审核提交文件的状态并设置为旧文件状态
  451. * 然后写入新审核的文件路径等信息
  452. * 审核同时上传审核文件并设置审核表的状态做更改
  453. *
  454. */
  455. if ($_POST['RequestType'] == 1) {
  456. /**
  457. * 功能描述:
  458. * 参数1功能为,取得与当前用户相关的待审核状态的所有进行中的标段期数、最新一次的记录
  459. * 根据用户ID查询编制人和审核人参与的正在进行中的项目,进行中的项目状态为uncheck,checking
  460. * 由于·uncheck状态不能准确反映出其他用户操作对所属标段操作产生的的状态{比如:其他用户操作标段状态为(未通过【打回重做】)}、要排除这种情况
  461. * 还有一种情况为编制人编制项目时,审核人列表已经添加审核人,但是项目没有提交,没有项目文件,此时应根据有没有项目文件进行过滤。
  462. *
  463. * ??此ID为编制人或者为审核人时
  464. */
  465. // 第一步:根据用户ID,查询此用户参与的所有标段{根据最大期数【由于期数是递进关系只获取最大值】、最大次数【由于次数是递进关系只获取最大值】作为条件参数进行查询记录}
  466. $mpArray = $this->measureauditact->getCheckedRowbyUID2($_POST['audituid']); // 通过pmid,numpname分组获取参与的记录
  467. if (isset($mpArray)) {
  468. $statusArray = array('uncheck', 'checking');
  469. foreach ($mpArray as $key => $value) {
  470. /**
  471. * 根据审核ID查询所在标段期数
  472. * 然后去附件表根据标段ID 期数 是否新标志字段去查询最新的文件
  473. * 项目名称 项目类型
  474. *
  475. *
  476. * 此处现在是以创建者ID和审核人ID做关联来做判断
  477. * 判断上一个人的审核状态来提取记录
  478. *
  479. * 变更为一个用户添加所有人
  480. *
  481. */
  482. // $maxtimes = $this->attfile->getMaxTimes2($value['pmid'], $value['numpname']);
  483. $numStatusArray = $this->numofperact->getRow($value['pmid'], $value['numpname'], $value['times']);
  484. if (in_array($numStatusArray['currstatus'], $statusArray)) {
  485. $newfileArray = $this->attfile->getNewLast($value['pmid'], $value['numpname'], $value['times']);
  486. if (isset($newfileArray['filepath'])) {
  487. $projectArray = $this->project->getRowByPid($newfileArray['pid']);
  488. $pmidArray = $this->actmeasure->getRowByPmid($value['pmid']);
  489. $stArray = $this->contractact->getRowByStid($newfileArray['stid']);
  490. // $auditArray = $this->measureauditact->getLastNewRowInfo($value['pmid'], $value['numpname'], $_POST['audituid']);
  491. $pathinfo = pathinfo($newfileArray['filepath']);
  492. $downfileurl[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $projectArray['pname'], 'stName' => $stArray['stname'], 'MD5_Jl' => $newfileArray['filehashcode'], 'tenderstatus' => $this->statusArray[$value['mastatus']], 'tenderid' => $value['pmid'], 'pnameid' => $projectArray['pid'], 'ptypeid' => $stArray['stid'], 'audituidstatus' => $this->statusArray[$value['mastatus']], 'bianzhirenuid' => $pmidArray['uid'], 'tenderName' => $pmidArray['pmname']);
  493. }
  494. }
  495. }
  496. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downfileurl), JSON_UNESCAPED_UNICODE);
  497. die();
  498. } else {
  499. echo json_encode(array('status' => FALSE, 'msg' => '暂时无审核信息'), JSON_UNESCAPED_UNICODE);
  500. die();
  501. }
  502. }
  503. if ($_POST['RequestType'] == 2) {
  504. /**
  505. * {
  506. * "downurl": "http://d.jl.smartcost.com.cn/data/2015/0608/20150608043245691/ProjectFile.rmf", 最新一期最新一次的文件
  507. * "proName": "巫溪县前进桥", 项目名称
  508. * "stName": "巫溪县 前进桥(终)", 合同段名称
  509. * "MD5_Jl": "7cf05dccc6ad45b2d78f476a3388c3b2", 最新一期最新一次的文件hash code
  510. * "tenderstatus": "2", 标段状态
  511. * "tenderid": "234", 标段ID
  512. * "pnameid": "79", 项目ID
  513. * "ptypeid": "96", 合同段ID
  514. * "audituidstatus": "2", 当前用户审核状态
  515. * "bianzhirenuid": "59", 编制人UID
  516. * "tenderName": "巫溪县 前进桥 终" 标段名称
  517. * }
  518. */
  519. // TODO::不同角色提取条件不同是否使用audituid 作为当前用户提取条件,容易产生冲突
  520. if (!isset($_POST['audituid']) || !($_POST['audituid'] > 0)) {
  521. echo json_encode(array('status' => FALSE, 'msg' => '返回指定用户参与的所有项目参数错误'), JSON_UNESCAPED_UNICODE);
  522. die();
  523. }
  524. // 三个角色数据合并返回
  525. // 返回最新一期的项目文件
  526. // 业主
  527. // 业主查询参与的项目时
  528. // TODO::业主是否参与审核?如果参与提取哪个参与者的审核状态?
  529. $userproArray = $this->project->getRowUid($_POST['audituid']);
  530. $newattArray = $retArray = $hashArray = NULL;
  531. foreach ($userproArray as $upk => $upv) {
  532. $attArray = $this->attfile->getPmidGroup($upv['pid']);
  533. $attaArray = NULL;
  534. foreach ($attArray as $akey => $avalue) {
  535. $attaArray[] = $this->attfile->getLastNumTimes($avalue['pmid']);
  536. }
  537. foreach ($attaArray as $attk => $attv) {
  538. $attfileArray = $this->contractact->getRowByStid($attv['stid']);
  539. $pmidArray = $this->actmeasure->getRowByPmid($attv['pmid']);
  540. $numArray = $this->numofperact->getRow($attv['pmid'], $attv['numpname'], $attv['times']);
  541. $auditArray = $this->measureauditact->getLastNewRowInfo($attv['pmid'], $attv['numpname'], $_POST['audituid']);
  542. $pathinfo = pathinfo($attv['filepath']);
  543. if (isset($pathinfo['dirname'])) {
  544. $retArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $upv['pname'], 'stName' => $attfileArray['stname'], 'MD5_Jl' => $attv['filehashcode'], 'tenderstatus' => $this->statusArray[$numArray['currstatus']], 'tenderid' => $attv['pmid'], 'pnameid' => $upv['pid'], 'ptypeid' => $attfileArray['stid'], 'audituidstatus' => $this->statusArray[$auditArray['mastatus']], 'bianzhirenuid' => $pmidArray['uid'], 'tenderName' => $pmidArray['pmname']);
  545. $hashArray[] = md5(Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf' . $upv['pname'] . $attfileArray['stname'] . $attv['filehashcode'] . $this->statusArray[$numArray['currstatus']] . $attv['pmid'] . $upv['pid'] . $attfileArray['stid'] . $this->statusArray[$auditArray['mastatus']] . $pmidArray['uid'] . $pmidArray['pmname']);
  546. }
  547. }
  548. }
  549. // 施工
  550. $measureArray = $this->actmeasure->getPmidRow($_POST['audituid']);
  551. if (isset($measureArray) && $measureArray) {
  552. $attfileArray = $stidArray = NULL;
  553. foreach ($measureArray as $key => $value) {
  554. $proArray = $this->project->getRowByPid($value['pid']);
  555. $conArray = $this->contractact->getRowByStid($value['stid']);
  556. $attfileArray = $this->attfile->getLastNewProfile2($value['pmid']);
  557. $pmidArray = $this->actmeasure->getRowByPmid($value['pmid']);
  558. $statusArray = $this->numofperact->getMaxRowStatus($attfileArray['pmid'], $attfileArray['numpname']);
  559. $auditArray = $this->measureauditact->getLastNewRowInfo($attfileArray['pmid'], $attfileArray['numpname'], $_POST['audituid']);
  560. $pathinfo = pathinfo($attfileArray['filepath']);
  561. if (!$auditArray['mastatus'])
  562. $auditStr = 'uncheck';
  563. if (isset($pathinfo['dirname'])) {
  564. $hashstr = md5(Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf' . $proArray['pname'] . $conArray['stname'] . $attfileArray['filehashcode'] . $this->statusArray[$statusArray['currstatus']] . $value['pmid'] . $proArray['pid'] . $conArray['stid'] . $this->statusArray[$auditStr] . $pmidArray['uid'] . $pmidArray['pmname']);
  565. if (!in_array($hashstr, $hashArray)) {
  566. $retArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $proArray['pname'], 'stName' => $conArray['stname'], 'MD5_Jl' => $attfileArray['filehashcode'], 'tenderstatus' => $this->statusArray[$statusArray['currstatus']], 'tenderid' => $value['pmid'], 'pnameid' => $proArray['pid'], 'ptypeid' => $conArray['stid'], 'audituidstatus' => $this->statusArray[$auditStr], 'bianzhirenuid' => $pmidArray['uid'], 'tenderName' => $pmidArray['pmname']);
  567. $hashArray[] = $hashstr;
  568. }
  569. }
  570. }
  571. }
  572. // 审批 是否只提取最新一期?
  573. $pmidGroupArray = $this->measureauditact->getPmidGroup($_POST['audituid']);
  574. /**
  575. * 从审核人列表中提取记录时,如果项目进行到新开一次或者一期数据,但是上报人并未上报数据,(犹豫逻辑上机制导致,先创建审批人再通过上报人上报数据才能产生新一期)
  576. * 这时,上报人查询到的数据就为空。
  577. * 如果没有最新一次上报数据(可否提取2期上报数据?即便是能下载也不能打开,因为上一期数据的审批人数或者状态,可能与最新一期的审批人状态不同,然后软件报错)
  578. */
  579. $retval = null;
  580. foreach ($pmidGroupArray as $gkey => $gvalue) {
  581. $retval[] = $this->measureauditact->getLastNumTimes($gvalue['pmid'], $_POST['audituid']);
  582. }
  583. foreach ($retval as $spkey => $spvalue) {
  584. $pathinfo = null;
  585. $proArray = $this->project->getRowByPid($spvalue['pid']);
  586. $conArray = $this->contractact->getRowByStid($spvalue['stid']);
  587. $pmidArray = $this->actmeasure->getRowByPmid($spvalue['pmid']);
  588. /**
  589. * 两种情况 一种情况是 新建一期 还有一种是审核未通过重做 这两种未提交
  590. */
  591. $intNum = $this->numofperact->getCountNumpname($spvalue['pmid'], $spvalue['numpname']);
  592. // 如果期数是第一期期数必须大于一,否则减一为无效数据 ,为0表示这期为做上报没有产生记录
  593. if (($spvalue['numpname'] > 1) && ($intNum == 0)) {// 提取上一期的数据
  594. // 提取期数减一
  595. $intLastTimes = $this->numofperact->getMaxTimes($spvalue['pmid'], $spvalue['numpname'] - 1)['times'];
  596. $numstatusArray = $this->numofperact->getRow($spvalue['pmid'], $spvalue['numpname'] - 1, $intLastTimes); //获取上一期最新一次的状态
  597. } else {
  598. $intTimes = $this->numofperact->getCountTimes($spvalue['pmid'], $spvalue['numpname'], $spvalue['times']);
  599. if (($intTimes == '0') && $spvalue['times'] > 0) {
  600. $numstatusArray = $this->numofperact->getRow($spvalue['pmid'], $spvalue['numpname'], $spvalue['times'] - 1);
  601. } else {// 当创建第一次的时候也会为空,所以下方加了判断
  602. $numstatusArray = $this->numofperact->getRow($spvalue['pmid'], $spvalue['numpname'], $spvalue['times']);
  603. }
  604. }
  605. $afArray = $this->attfile->getLastNewProfile2($spvalue['pmid']); // 由于始终提取最新一期所以不用放入判断情况中
  606. $auditArray = $this->measureauditact->getLastNewRowInfo($spvalue['pmid'], $spvalue['numpname'], $_POST['audituid']);
  607. $pathinfo = pathinfo($afArray['filepath']);
  608. if ($numstatusArray && $auditArray) { // 如果重做审核人有变更,根据审核状态判断是否存在该审核人,不存在则不显示此条记录
  609. $hashstr = md5(Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf' . $proArray['pname'] . $conArray['stname'] . $afArray['filehashcode'] . $this->statusArray[$numstatusArray['currstatus']] . $spvalue['pmid'] . $proArray['pid'] . $conArray['stid'] . $this->statusArray[$auditArray['mastatus']] . $pmidArray['uid'] . $pmidArray['pmname']);
  610. if (!in_array($hashstr, $hashArray)) {
  611. $retArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $proArray['pname'], 'stName' => $conArray['stname'], 'MD5_Jl' => $afArray['filehashcode'], 'tenderstatus' => $this->statusArray[$numstatusArray['currstatus']], 'tenderid' => $spvalue['pmid'], 'pnameid' => $proArray['pid'], 'ptypeid' => $conArray['stid'], 'audituidstatus' => $this->statusArray[$auditArray['mastatus']], 'bianzhirenuid' => $pmidArray['uid'], 'tenderName' => $pmidArray['pmname']);
  612. $hashArray[] = $hashstr;
  613. }
  614. }
  615. }
  616. // $dd = NULL;
  617. // if (isset($retArray))
  618. // $dd = $this->array_unique_fb($retArray);
  619. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $retArray), JSON_UNESCAPED_UNICODE);
  620. }
  621. }
  622. }
  623. //二维数组去掉重复值 并保留键值
  624. function array_unique_fb($array2D)
  625. {
  626. $key = array();
  627. foreach ($array2D as $k => $v) {
  628. if (empty($key))
  629. $key = array_keys($v); //记录数组的KEY
  630. $v = join(",", $v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
  631. $temp[$k] = $v;
  632. }
  633. $temp = array_unique($temp); //去掉重复的字符串,也就是重复的一维数组
  634. foreach ($temp as $k => $v) {
  635. $array = explode(",", $v); //再将拆开的数组重新组装
  636. foreach ($array as $i => $t) {
  637. $temp2[$k] = !empty($temp2[$k]) ? array_merge($temp2[$k], array("{$key[$i]}" => $t)) : array("{$key[$i]}" => $t); //依次添加到新的数组中去
  638. }
  639. }
  640. return $temp2;
  641. }
  642. function unique_arr($array2D, $stkeep = false, $ndformat = true)
  643. {
  644. // 判断是否保留一级数组键 (一级数组键可以为非数字)
  645. if ($stkeep)
  646. $stArr = array_keys($array2D);
  647. // 判断是否保留二级数组键 (所有二级数组键必须相同)
  648. if ($ndformat)
  649. $ndArr = array_keys(end($array2D));
  650. //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
  651. foreach ($array2D as $v) {
  652. $v = join(",", $v);
  653. $temp[] = $v;
  654. }
  655. //去掉重复的字符串,也就是重复的一维数组
  656. $temp = array_unique($temp);
  657. //再将拆开的数组重新组装
  658. foreach ($temp as $k => $v) {
  659. if ($stkeep)
  660. $k = $stArr[$k];
  661. if ($ndformat) {
  662. $tempArr = explode(",", $v);
  663. foreach ($tempArr as $ndkey => $ndval) {
  664. $output[$k][$ndArr[$ndkey]] = $ndval;
  665. }
  666. } else {
  667. $output[$k] = explode(",", $v);
  668. }
  669. }
  670. return $output;
  671. }
  672. // 标段期审核接口
  673. function auditMeasure()
  674. {
  675. if (isset($_POST['userid']) && isset($_POST['tenderid']) && isset($_POST['phaseno']) && isset($_POST['MD5_JL']) && isset($_POST['MD5_Zip'])) {
  676. $auditcontent = iconv('GBK', 'UTF-8', $_POST['CheckerMemo']);
  677. $auditArray = $this->measureauditact->getLastNewRowInfo($_POST['tenderid'], $_POST['phaseno'], $_POST['userid']);
  678. if (isset($auditArray ['mastatus']) && ($auditArray ['mastatus'] == 'checked') || ($auditArray ['mastatus'] == 'checkno')) {
  679. echo json_encode(array('status' => FALSE, 'msg' => '已审核完毕,请勿重复提交'), JSON_UNESCAPED_UNICODE);
  680. die();
  681. }
  682. $auditUserArray = $this->measureauditact->getUserAuditLast($_POST['tenderid'], $_POST['phaseno']);
  683. $fp = $this->upfile('upfile');
  684. if (isset($fp[0]['filepath'])) {
  685. $localmd5HashString = hash_file("md5",Doo::conf()->SITE_PATH . $fp[0]['filepath']);
  686. if($localmd5HashString!=trim($_POST['MD5_Zip'])){
  687. $status = array('status' => 'FALSE', 'msg' => '审核期数数据上传失败,请重新上传');
  688. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  689. die();
  690. }
  691. $res = $this->zip->open(Doo::conf()->SITE_PATH . $fp[0]['filepath']);
  692. $extPath = pathinfo($fp[0]['filepath']);
  693. $extPathdir = Doo::conf()->SITE_PATH . $extPath ['dirname'] . '/' . $extPath['filename'];
  694. if ($res === TRUE) {
  695. if (!$this->dir_create($extPathdir)) {
  696. return FALSE;
  697. }
  698. $this->zip->extractTo($extPathdir);
  699. $this->zip->close();
  700. }
  701. // 更新五项最新数据
  702. $countArray = json_decode(file_get_contents($extPathdir . '/' . 'JsonFile_Common.json'), TRUE, JSON_UNESCAPED_UNICODE);
  703. if (!isset($countArray)) {
  704. $status = array('status' => FALSE, 'msg' => '期数汇总数据上传失败');
  705. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  706. die();
  707. }
  708. $iniTimes = 0;
  709. $intMaxTimes = $this->numofperact->getMaxTimes($_POST['tenderid'], $_POST['phaseno']);
  710. if (isset($intMaxTimes['times']) && ($intMaxTimes['times'] > 0)) {
  711. $iniTimes = $intMaxTimes['times'];
  712. }
  713. $this->actmeasure->updateCon($_POST['tenderid'], $countArray['TotalPrice']);
  714. $this->numofperact->updateNumofper($_POST['tenderid'], $_POST['phaseno'], $countArray, $iniTimes);
  715. $numArray = $this->numofperact->getRow($_POST['tenderid'], $_POST['phaseno'], $iniTimes);
  716. if (isset($auditArray['pid'])) {
  717. // 插入附件表之前要更新所有次标段期数的提交的数据状态为旧标志
  718. $this->attfile->setOldfileFlag($_POST['tenderid'], $_POST['phaseno'], $iniTimes);
  719. // 插入此次提交的文件路径数据并设置为新状态
  720. // 写入此时是第几次重做
  721. $this->attfile->insertFile($auditArray['pid'], $auditArray['stid'], $numArray['mpid'], $_POST['tenderid'], $_POST['phaseno'], $_POST['userid'], $fp[0]['filepath'], 0, $_POST['MD5_JL'], $iniTimes);
  722. // 更新审核表审核人的标段期数审核状态
  723. if ($this->measureauditact->setStatusTo($auditArray['maid'], 3, $auditcontent)) {
  724. // 更新下一个人的状态
  725. $countAudit = count($auditUserArray);
  726. if ($auditArray['last'] == '1') {
  727. $this->measureauditact->setStatusTo($auditUserArray[0]['maid'], 3);
  728. $this->numofperact->updateAuditStatus($_POST['tenderid'], $_POST['phaseno'], 'checked', $iniTimes);
  729. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  730. die();
  731. } else {
  732. if (($countAudit == 2) && ($auditUserArray[0]['last'] == 1) && ($auditUserArray[1]['maid'] == $auditArray['maid'])) {
  733. $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);
  734. $this->numofperact->updateAuditStatus($_POST['tenderid'], $_POST['phaseno'], 'checking', $iniTimes);
  735. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  736. die();
  737. }
  738. if (($countAudit > 2)) {
  739. foreach ($auditUserArray as $k => $v) {
  740. if ($v['maid'] == $auditArray['maid']) {
  741. if ($k == ($countAudit - 1)) {//如果是最后一个
  742. $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);
  743. } else {
  744. $this->measureauditact->updateMastatus($auditUserArray[$k + 1]['maid']);
  745. }
  746. $this->numofperact->updateAuditStatus($_POST['tenderid'], $_POST['phaseno'], 'checking', $iniTimes);
  747. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  748. die();
  749. }
  750. }
  751. // 我是第几个审核的
  752. // 如果是最后一个就把业主审核状态更改为审核中
  753. // 如果是第一个就把后一个设置为审核中
  754. }
  755. }
  756. } else {
  757. echo json_encode(array('status' => FALSE, 'msg' => '审核文件提交失败1'), JSON_UNESCAPED_UNICODE);
  758. die();
  759. }
  760. }
  761. } else {
  762. echo json_encode(array('status' => FALSE, 'msg' => '审核文件提交失败'), JSON_UNESCAPED_UNICODE);
  763. die();
  764. }
  765. } else {
  766. echo json_encode(array('status' => FALSE, 'msg' => '审核参数错误'), JSON_UNESCAPED_UNICODE);
  767. die();
  768. }
  769. }
  770. /**
  771. * 根据标段ID查询是否需要更新
  772. */
  773. function checkTenderUpdate()
  774. {
  775. if (isset($this->params ['tenderid']) && $this->params['tenderid']) {
  776. $updateArray = $this->attfile->getFileUpdate($this->params['tenderid']);
  777. $projectArray = $this->project->getRowByPid($updateArray['pid']);
  778. $stArray = $this->contractact->getRowByStid($updateArray['stid']);
  779. $MeasureArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);
  780. if (isset($updateArray['filepath'])) {
  781. $pathinfo = pathinfo($updateArray['filepath']);
  782. $downfileurl[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'MD5_Jl' => $updateArray['filehashcode'], 'proName' => $projectArray['pname'], 'stName' => $stArray['stname'], 'pnameid' => $projectArray['pid'], 'ptypeid' => $stArray['stid'], 'BidName' => $MeasureArray['pmname']);
  783. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downfileurl), JSON_UNESCAPED_UNICODE);
  784. die();
  785. } else {
  786. echo json_encode(array('status' => TRUE, 'msg' => '暂无更新数据'), JSON_UNESCAPED_UNICODE);
  787. die();
  788. }
  789. } else {
  790. echo json_encode(array('status' => FALSE, 'msg' => '更新查询参数错误'), JSON_UNESCAPED_UNICODE);
  791. die();
  792. }
  793. }
  794. /**
  795. * 手动创建第二期的审核人
  796. */
  797. function creatTenderNumPnameUser()
  798. {
  799. if (isset($_POST['tenderid']) && isset($_POST['phaseno']) && ($_POST['phaseno'] > 1)) {
  800. $allMeasureUser = $this->measureauditact->getUserAudit($_POST['tenderid'], $_POST['phaseno'] - 1);
  801. if (isset($allMeasureUser)) {
  802. foreach ($allMeasureUser as $key => $value) {
  803. // if ($key == 1) {
  804. // $status = 'checking';
  805. // } else {
  806. $status = 'uncheck';
  807. // }
  808. try {
  809. $this->measureauditact->insertMeasureAudit($value['pid'], $value['creatoruid'], $value['auditoruid'], $value['mpid'], $value['pmid'], $value['stid'], $_POST['phaseno'], $status, $value['last']);
  810. } catch (Exception $exc) {
  811. }
  812. }
  813. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  814. die();
  815. } else {
  816. echo json_encode(array('status' => FALSE, 'msg' => '审核人员列表不存在'), JSON_UNESCAPED_UNICODE);
  817. die();
  818. }
  819. } else {
  820. echo json_encode(array('status' => FALSE, 'msg' => '创建审核人员列表参数错误'), JSON_UNESCAPED_UNICODE);
  821. die();
  822. }
  823. }
  824. /**
  825. * 返回指定用户参与的所有项目
  826. */
  827. function getUserALLProject()
  828. {
  829. if (!isset($this->params['userid']) || !($this->params['userid'] > 0)) {
  830. echo json_encode(array('status' => FALSE, 'msg' => '返回指定用户参与的所有项目参数错误'), JSON_UNESCAPED_UNICODE);
  831. die();
  832. }
  833. $conArray = $this->contractact->getUserRow($this->params['userid']);
  834. if (isset($conArray) && $conArray) {
  835. foreach ($conArray as $key => $value) {
  836. $proArray = $this->project->getRowByPid($value['pid']);
  837. $attfileArray = $this->attfile->getLastData($value['stid']);
  838. foreach ($attfileArray as $k => $v) {
  839. $pathinfo = pathinfo($v['filepath']);
  840. $retArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $proArray['pname'], 'stName' => $value['stname'], 'MD5_Jl' => $v['filehashcode']);
  841. }
  842. }
  843. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $retArray), JSON_UNESCAPED_UNICODE);
  844. die();
  845. } else {
  846. $userproArray = $this->measureauditact->getProject($this->params['userid']);
  847. if (isset($userproArray) && $userproArray) {
  848. foreach ($userproArray as $upk => $upv) {
  849. $attArray = $this->attfile->getMeasureLastNew($upv['pmid'], $upv['numpname']);
  850. $proArray = $this->project->getRowByPid($attArray['pid']);
  851. $attfileArray = $this->contractact->getRowByStid($attArray['stid']);
  852. $pathinfo = pathinfo($attArray['filepath']);
  853. if (isset($pathinfo['dirname']))
  854. $newattArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $proArray['pname'], 'stName' => $attfileArray['stname'], 'MD5_Jl' => $attArray['filehashcode']);
  855. }
  856. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $newattArray), JSON_UNESCAPED_UNICODE);
  857. die();
  858. }
  859. }
  860. }
  861. /**
  862. * 设置审核未通过操作
  863. * 第一步设置未通过操作,操作相关期数。 同步状态。
  864. * 第二步设置项目查询接口未通过审核的查询返回未锁定的
  865. * 第三步前台相关状态更新
  866. *
  867. * TODO: 更新附件标志位未加入次数标志做更新 ok
  868. * TODO: 不通过两次未通过时候操作期数状态为错误位同步状态位 ok
  869. * TODO: MPID未通过操作不争取 ok
  870. */
  871. function setCheckno()
  872. {
  873. if (isset($this->params['userid']) && isset($this->params['tenderid']) && isset($this->params['phaseno']) && isset($_POST['MD5_JL']) && isset($_POST['MD5_Zip'])) {
  874. $auditcontent = iconv('GBK', 'UTF-8', $_POST['CheckerMemo']);
  875. $auditArray = $this->measureauditact->getRowInfo($this->params['tenderid'], $this->params['phaseno'], $this->params['userid']);
  876. if (isset($auditArray['maid'])) {
  877. $intMaxTimes = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno']);
  878. if (isset($intMaxTimes['times'])) {
  879. $iniTimes = $intMaxTimes['times'];
  880. }
  881. $this->measureauditact->setCheckno($auditArray['maid'], $auditcontent);
  882. $this->numofperact->updateAuditStatus($this->params['tenderid'], $this->params['phaseno'], 'checkno', $iniTimes);
  883. $fp = $this->upfile('upfile');
  884. if (isset($fp[0]['filepath'])) {
  885. // 解压缩文件等待以后直接使用
  886. // TODO:根据校验码校验包的完整性
  887. $localmd5HashString = hash_file("md5",Doo::conf()->SITE_PATH . $fp[0]['filepath']);
  888. if($localmd5HashString!=trim($_POST['MD5_Zip'])){
  889. $status = array('status' => 'FALSE', 'msg' => '未通过期数数据上传失败,请重新上传');
  890. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  891. die();
  892. }
  893. $res = $this->zip->open(Doo::conf()->SITE_PATH . $fp[0]['filepath']);
  894. $extPath = pathinfo($fp[0]['filepath']);
  895. $extPathdir = Doo::conf()->SITE_PATH . $extPath ['dirname'] . '/' . $extPath['filename'];
  896. if ($res === TRUE) {
  897. if (!$this->dir_create($extPathdir)) {
  898. return FALSE;
  899. }
  900. $this->zip->extractTo($extPathdir);
  901. $this->zip->close();
  902. }
  903. $numArray = $this->numofperact->getRow($this->params['tenderid'], $this->params['phaseno'], $iniTimes);
  904. // 插入附件表之前要更新所有次标段期数的提交的数据状态为旧标志
  905. $this->attfile->setOldfileFlag($this->params['tenderid'], $this->params['phaseno'], $iniTimes);
  906. // 插入此次提交的文件路径数据并设置为新状态
  907. $this->attfile->insertFile($auditArray['pid'], $auditArray['stid'], $auditArray['mpid'], $this->params['tenderid'], $this->params['phaseno'], $this->params['userid'], $fp[0]['filepath'], 0, $_POST['MD5_JL'], $iniTimes);
  908. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  909. die();
  910. } else {
  911. echo json_encode(array('status' => FALSE, 'msg' => '文件上传故障'), JSON_UNESCAPED_UNICODE);
  912. die();
  913. }
  914. } else {
  915. echo json_encode(array('status' => FALSE, 'msg' => '审核期数不存在'), JSON_UNESCAPED_UNICODE);
  916. die();
  917. }
  918. } else {
  919. echo json_encode(array('status' => FALSE, 'msg' => '审核未通过参数错误'), JSON_UNESCAPED_UNICODE);
  920. die();
  921. }
  922. }
  923. /**
  924. * 创建未通过的新一期
  925. *
  926. */
  927. function createNewAudit()
  928. {
  929. // 插入上次期数相关审核人员
  930. // TODO:
  931. // error_log(var_export($this->params, TRUE), 3, '/opt/html/jiliang_customedProduct/data/' . time());
  932. // die;
  933. if (isset($this->params['tenderid']) && isset($this->params['phaseno'])) {
  934. $auditArray = $this->numofperact->getChecknoRow($this->params['tenderid'], $this->params['phaseno']);
  935. if (isset($auditArray['currstatus']) && ($auditArray['currstatus'] == 'checkno')) {
  936. $auditUserArray = $this->measureauditact->getUserAudit($this->params['tenderid'], $this->params['phaseno'], $auditArray['times']);
  937. if ($auditUserArray) {
  938. foreach ($auditUserArray as $key => $value) {
  939. $auditUserArray = $this->measureauditact->insertMeasureAudit($value['pid'], $value['creatoruid'], $value['auditoruid'], $value['mpid'], $value['pmid'], $value['stid'], $value['numpname'], $status = 'uncheck', $value['last'], $auditArray['times'] + 1);
  940. }
  941. }
  942. $timesArray = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno']);
  943. $urlinfoArray = $this->attfile->getLastNewProfileUnlock($this->params['tenderid'], $this->params['phaseno'], $timesArray['times']);
  944. $proArray = $this->project->getRowByPid($urlinfoArray['pid']);
  945. $stArray = $this->contractact->getRowByStid($urlinfoArray['stid']);
  946. $MeasureArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);
  947. $downArray = NULL;
  948. $pathinfo = pathinfo($urlinfoArray['filepath']);
  949. if (isset($pathinfo['dirname']))
  950. $downArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '/ProjectFile.rmf', 'MD5_Jl' => $urlinfoArray['filehashcode'], 'proName' => $proArray['pname'], 'stName' => $stArray['stname'], 'pnameid' => $proArray['pid'], 'ptypeid' => $stArray['stid'], 'BidName' => $MeasureArray['pmname']);
  951. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downArray), JSON_UNESCAPED_UNICODE);
  952. die();
  953. } else {
  954. echo json_encode(array('status' => FALSE, 'msg' => '审核状态无效'), JSON_UNESCAPED_UNICODE);
  955. die();
  956. }
  957. } else {
  958. echo json_encode(array('status' => FALSE, 'msg' => '创建未通过的新一期参数错误'), JSON_UNESCAPED_UNICODE);
  959. die();
  960. }
  961. }
  962. public function getUserInfo()
  963. {
  964. if (isset($this->params['userid']) && ($this->params['userid'] > 0)) {
  965. $proArray = $this->profile->getProWithUid($this->params['userid']);
  966. if (isset($proArray['userid'])) {
  967. $strAvatar = $this->auth->getAvatar($proArray['userid']);
  968. echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('avatar' => $strAvatar, 'name' => $proArray['name'], 'jobs' => $proArray['jobs'], 'company' => $proArray['company'])), JSON_UNESCAPED_UNICODE);
  969. die();
  970. } else {
  971. echo json_encode(array('status' => 'FALSE', 'msg' => '此用户不存在'), JSON_UNESCAPED_UNICODE);
  972. die();
  973. }
  974. } else {
  975. echo json_encode(array('status' => 'FALSE', 'msg' => '用户查询参数无效'), JSON_UNESCAPED_UNICODE);
  976. die();
  977. }
  978. }
  979. public function updateTenderName()
  980. {
  981. if (isset($this->params['BidID']) && isset($this->params['BidNewName'])) {
  982. if ($this->actmeasure->updateName($this->params['BidID'], iconv('GBK', 'UTF-8', $this->params['BidNewName']))) {
  983. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  984. die();
  985. } else {
  986. echo json_encode(array('status' => 'FALSE', 'msg' => '标段名称更新错误'), JSON_UNESCAPED_UNICODE);
  987. die();
  988. }
  989. } else {
  990. echo json_encode(array('status' => 'FALSE', 'msg' => '标段名称更新参数无效'), JSON_UNESCAPED_UNICODE);
  991. die();
  992. }
  993. }
  994. /**
  995. * 清单附件上传,单文件上传
  996. * @param int $tenderid 标段ID
  997. * @param int $uid 上传人ID
  998. * @param int $itemid 本地清单ID
  999. */
  1000. public function uploadItemFile()
  1001. {
  1002. if (isset($this->params['tenderid']) && isset($this->params['uid'])) {
  1003. if (!isset($_FILES['upitem']) && !isset($_POST['itemid']) && !isset($_POST['Category'])) {
  1004. $this->msg(0, '上传参数错误');
  1005. }
  1006. $fileArray = $this->upItemFile('upitem')[0];
  1007. if (isset($fileArray['filepath'])) {
  1008. $memoStr = iconv('GBK', 'UTF-8', $_POST['Memo']);
  1009. $fnArray = explode('.', $fileArray['filename']);
  1010. $filenameStr = iconv('GBK', 'UTF-8', $fnArray[0]);
  1011. $postArray = array('mpid' => $this->params['tenderid'], 'ownerid' => $this->params['uid'], 'itemid' => $_POST['itemid'], 'filename' => $filenameStr, 'filesize' => $fileArray['filesize'], 'fileext' => $fileArray['fileext'], 'filepath' => $fileArray['filepath'], 'categoryid' => array_search($_POST['Category'], $this->fileTypeArray), 'tips' => $memoStr);
  1012. if ($this->itemfile->insertItemFileRecord($postArray) > 1) {
  1013. $extPath = pathinfo($fileArray['filepath']);
  1014. $itemArray = array('onlineFileName' => $extPath['filename'] . '.' . $extPath['extension']);
  1015. $status = array('status' => TRUE, 'msg' => '', 'iteminfo' => $itemArray);
  1016. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1017. die();
  1018. }
  1019. } else {
  1020. $this->msg(0, '附件上传失败,请重新上传');
  1021. }
  1022. } else {
  1023. $this->msg(0, '上传参数错误');
  1024. }
  1025. }
  1026. /**
  1027. * 获得清单附件列表
  1028. */
  1029. public function getItemFileList()
  1030. {
  1031. if (isset($this->params['tenderid'])) {
  1032. $itemfileArray = $this->itemfile->getItemFileList($this->params['tenderid']);
  1033. $key = array_search(max($itemfileArray), $itemfileArray);
  1034. if ($key >= 0) {
  1035. foreach ($itemfileArray as $value) {
  1036. $profileArray = $this->profile->getProWithUid($value['ownerid']);
  1037. $downArray[] = array('downurl' => Doo::conf()->APP_URL . $value['filepath'], 'filename' => $value['filename'] . '.' . $value['fileext'], 'fileext' => $value['fileext'], 'ownerName' => $profileArray['name'], 'itemid' => $value['itemid'], 'Category' => $this->fileTypeArray[$value['categoryid']], 'Memo' => $value['tips'], 'ownerid' => $value['ownerid'], 'uptime' => date('Y-m-d H:i', $value['intime']), 'fileid' => $value['iaid']);
  1038. }
  1039. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downArray), JSON_UNESCAPED_UNICODE);
  1040. die();
  1041. }
  1042. } else {
  1043. $this->msg(0, '获取附件列表参数错误');
  1044. }
  1045. }
  1046. /**
  1047. * 编辑清单附件描述 文件名?
  1048. */
  1049. public function updateItemFileDesc()
  1050. {
  1051. if (isset($this->params['fileid']) && isset($_POST['FileName']) && isset($_POST['Memo'])) {
  1052. if ($this->itemfile->updateItemFields($this->params['fileid'], $_POST['FileName'], $_POST['Memo']) > 0) {
  1053. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  1054. die();
  1055. } else {
  1056. echo json_encode(array('status' => 'FALSE', 'msg' => '附件更新接口参数错误'), JSON_UNESCAPED_UNICODE);
  1057. die();
  1058. }
  1059. } else {
  1060. $this->msg(0, '附件更新接口参数错误');
  1061. }
  1062. }
  1063. /**
  1064. * 查询指定项目的指定期的全部审核意见。
  1065. * 标段ID,期号
  1066. */
  1067. public function getAuditOpinion()
  1068. {
  1069. if (isset($this->params['tenderid']) && isset($this->params['phaseno'])) {
  1070. $retval = $this->measureauditact->getAuditOpinion($this->params['tenderid'], $this->params['phaseno']);
  1071. $iterator = new ArrayIterator($retval);
  1072. if (iterator_count($iterator) > 0) {
  1073. foreach ($retval as $value) {
  1074. $proArray = $this->profile->getProWithUid($value['auditoruid']);
  1075. $uArray[] = array('realname' => $proArray['name'], 'jobs' => $proArray['jobs'], 'acontent' => $value['auditcontent']);
  1076. }
  1077. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $uArray), JSON_UNESCAPED_UNICODE);
  1078. die();
  1079. } else {
  1080. echo json_encode(array('status' => 'FALSE', 'msg' => '查询指定项目的指定期的全部审核意见参数错误'), JSON_UNESCAPED_UNICODE);
  1081. die();
  1082. }
  1083. } else {
  1084. $this->msg(0, '查询指定项目的指定期的全部审核意见接口参数错误');
  1085. }
  1086. }
  1087. function upfile($fildname, $param = 'doc, docx, xls, xlsx, png, zip') {
  1088. return $this->att->uploadMut($fildname, $param);
  1089. }
  1090. function upItemFile($fildname, $param = 'doc, docx, xls, xlsx, png, zip') {
  1091. $this->att->setUploadDir();
  1092. return $this->att->uploadMut($fildname, $param);
  1093. }
  1094. /**
  1095. * 根据标段ID获取标段是否已经被删除的提示
  1096. * 标段ID
  1097. */
  1098. public function getCountPmid() {
  1099. if (isset($this->params['tenderid'])) {
  1100. $isexist = $this->actmeasure->getCountPmid($this->params['tenderid']);
  1101. if ($isexist > 0) {
  1102. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => null), JSON_UNESCAPED_UNICODE);
  1103. die();
  1104. } else {
  1105. echo json_encode(array('status' => 'FALSE', 'msg' => '该项目[XXX]在云端已被删除,点击“确定”后,可手动删除该项目'), JSON_UNESCAPED_UNICODE);
  1106. die();
  1107. }
  1108. } else {
  1109. $this->msg(0, '获取标段是否存在参数错误');
  1110. }
  1111. }
  1112. function getFileupErrorNo() {
  1113. return $this->att->error();
  1114. }
  1115. function Signout()
  1116. {
  1117. session_destroy();
  1118. }
  1119. function isLoggedIn()
  1120. {
  1121. return isset($_SESSION['user_id']);
  1122. }
  1123. function generateFormHash($salt)
  1124. {
  1125. $hash = md5(mt_rand(1, 1000000) . $salt);
  1126. $_SESSION['csrf_hash'] = $hash;
  1127. return $hash;
  1128. }
  1129. function isValidFormHash($hash)
  1130. {
  1131. return $_SESSION['csrf_hash'] === $hash;
  1132. }
  1133. /**
  1134. * 随机字符串函数
  1135. * @param $password 密码
  1136. * @param $random 随机数
  1137. */
  1138. function random($length, $chars = '0123456789')
  1139. {
  1140. $hash = '';
  1141. $max = strlen($chars) - 1;
  1142. for ($i = 0; $i < $length; $i++) {
  1143. $hash .= $chars[mt_rand(0, $max)];
  1144. }
  1145. return $hash;
  1146. }
  1147. /**
  1148. * 生成随机字符串
  1149. * @param string $lenth 长度
  1150. * @return string 字符串
  1151. */
  1152. function create_randomstr($lenth = 6)
  1153. {
  1154. return $this->random($lenth, '123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ');
  1155. }
  1156. function dir_create($path, $mode = 0777)
  1157. {
  1158. if (is_dir($path))
  1159. return TRUE;
  1160. $path = $this->dir_path($path);
  1161. $parent = dirname($path);
  1162. if (!is_dir($parent))
  1163. @mkdir($parent, 0777, true);
  1164. @mkdir($path, 0777, true);
  1165. return is_dir($path);
  1166. }
  1167. function dir_path($path)
  1168. {
  1169. $path = str_replace('\\', '/', $path);
  1170. if (substr($path, -1) != '/')
  1171. $path = $path . '/';
  1172. return $path;
  1173. }
  1174. function msg($isTrue = 0, $msg = null, $retmsg = null)
  1175. {
  1176. if ($isTrue > 0) {
  1177. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  1178. die();
  1179. } else {
  1180. echo json_encode(array('status' => 'FALSE', 'msg' => $msg), JSON_UNESCAPED_UNICODE);
  1181. die();
  1182. }
  1183. }
  1184. }
  1185. ?>