ClientController.php 76 KB

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