ClientController.php 69 KB

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