ClientController.php 73 KB

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