ClientController.php 78 KB

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