ClientController.php 113 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057
  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. Doo::loadClass('sign');
  20. Doo::loadClass('measureconcerner');
  21. //
  22. // _oo0oo_
  23. // o8888888o
  24. // 88" . "88
  25. // (| -_- |)
  26. // 0\ = /0
  27. // ___/`---'\___
  28. // .' \| |// '.
  29. // / \||| : |||// \
  30. // / _||||| -:- |||||- \
  31. // | | \ - /// | |
  32. // | \_| ''\---/'' |_/ |
  33. // \ .-\__ '-' ___/-. /
  34. // ___'. .' /--.--\ `. .'___
  35. // ."" '< `.___\_<|>_/___.' >' "".
  36. // | | : `- \`.;`\ _ /`;.`/ - ` : | |
  37. // \ \ `_. \_ __\ /__ _/ .-` / /
  38. // =====`-.____`.___ \_____/___.-`___.-'=====
  39. // `=---='
  40. //
  41. //
  42. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  43. //
  44. // 佛祖保佑 永无BUG
  45. //
  46. /**
  47. * MainController
  48. * Feel free to delete the methods and replace them with your own code.
  49. *
  50. * @author NoNZero
  51. */
  52. class ClientController extends DooController
  53. {
  54. private $data, $sign, $concern, $client, $auth, $att, $file, $zip, $actmeasure, $contractact, $project, $profile, $numofperact, $measureauditact, $attfile, $users, $itemfile, $modelconfig, $aconfig, $sms, $itemMeasureNum;
  55. private $statusArray = array('uncheck' => '1', 'checking' => '2', 'checked' => '3', 'checkno' => '4');
  56. private $fileTypeArray = array('台帐附件');
  57. public function __construct()
  58. {
  59. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  60. $this->client = new client();
  61. $this->auth = new Auth();
  62. $this->att = new attachment();
  63. $this->attfile = new attFile();
  64. $this->zip = new ZipArchive();
  65. $this->actmeasure = new actMeasure();
  66. $this->contractact = new Contractact();
  67. $this->project = new Project();
  68. $this->profile = new Profile();
  69. $this->numofperact = new NumofperAct();
  70. $this->measureauditact = new MeasureauditAct();
  71. $this->users = new Users();
  72. $this->itemfile = new ItemFile();
  73. $this->modelconfig = new AConfig();
  74. $this->itemMeasureNum = new ItemMeasureNumpofper();
  75. $this->aconfig = new AConfig();
  76. $this->sign = new signn();
  77. $this->concern = new MeasureConcerner();
  78. $this->sms = new Sms(Doo::conf()->SMS_URL, Doo::conf()->SMS_AUTHKEY);
  79. }
  80. public function ClientSignin()
  81. {
  82. if (isset($_POST['zhname']) && isset($_POST['zhpass'])) {
  83. echo json_encode(array('status' => FALSE, 'msg' => '登录失败,请更新软件。'), JSON_UNESCAPED_UNICODE);
  84. die;
  85. }
  86. if (isset($_POST['uname']) && isset($_POST['upass'])) {
  87. echo json_encode(array('status' => FALSE, 'msg' => '登录失败,请更新软件。'), JSON_UNESCAPED_UNICODE);
  88. die;
  89. }
  90. if (isset($_POST['v3name']) && isset($_POST['v3name'])) {
  91. echo json_encode(array('status' => FALSE, 'msg' => '登录失败,请更新软件。'), JSON_UNESCAPED_UNICODE);
  92. die;
  93. }
  94. if (!empty($_POST['version'])) {
  95. try {
  96. if ($this->modelconfig->getOne(array('select' => 'onoff', 'asArray' => TRUE))['onoff'] != 1) {
  97. $versionTotal = implode("",explode('.', $_POST['version']));
  98. $StrJson = ($this->modelconfig->getOne(array('select' => 'upgradeinfo', 'asArray' => TRUE))['upgradeinfo']);
  99. $jsonObj = json_decode($StrJson, true);
  100. if ($jsonObj) {
  101. $versionTotalUp = implode("",explode('.', $jsonObj['version']));
  102. $strJson = json_encode(array('status' => 'upgrade', 'msg' => '您的客户端需要升级,请点击确定按钮,下载新版本,并且覆盖安装。', 'url' => $jsonObj['download']), JSON_UNESCAPED_UNICODE);
  103. if ($jsonObj['condition'] == 1) {
  104. if ($versionTotalUp != $versionTotal) {
  105. echo $strJson;
  106. die;
  107. }
  108. }
  109. if ($jsonObj['condition'] == 2) {
  110. if ($versionTotalUp > $versionTotal) {
  111. echo $strJson;
  112. die;
  113. }
  114. }
  115. }
  116. if (isset($_POST['logintype']) && $_POST['logintype'] == 2) {
  117. if ($this->auth->loginWithUserName($_POST['v4name'])) {
  118. $uinfo = $this->auth->getUinfo();
  119. if (isset($uinfo['isstop']) && $uinfo['isstop'] > 0) {
  120. echo json_encode(array('status' => FALSE, 'msg' => '帐号不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
  121. die;
  122. }
  123. if (isset($uinfo['uid'])) {
  124. $userArray = $this->profile->getProWithUid($uinfo['uid']);
  125. $avatarStr = $userArray['avatar'];
  126. if (isset($userArray['userid'])) {
  127. $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr);
  128. echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
  129. die;
  130. }
  131. }
  132. } else {
  133. echo json_encode(array('status' => FALSE, 'msg' => '帐号不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
  134. die;
  135. }
  136. } else {
  137. if(isset($_POST['v4name']) && isset($_POST['v4pass'])) {
  138. if ($this->auth->login($_POST['v4name'], $_POST['v4pass'])) {
  139. $uinfo = $this->auth->getUinfo();
  140. if (isset($uinfo['isstop']) && $uinfo['isstop'] > 0) {
  141. echo json_encode(array('status' => 'false', 'msg' => '帐号不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
  142. die;
  143. }
  144. if (isset($uinfo['uid'])) {
  145. $userArray = $this->profile->getProWithUid($uinfo['uid']);
  146. $avatarStr = $userArray['avatar'];
  147. if (isset($userArray['userid'])) {
  148. $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr);
  149. echo json_encode(array('status' => 'true', 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
  150. die;
  151. }
  152. }
  153. } else {
  154. echo json_encode(array('status' => 'false', 'msg' => '帐号不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
  155. die;
  156. }
  157. }else{
  158. echo json_encode(array('status' => 'false', 'msg' => '参数错误'), JSON_UNESCAPED_UNICODE);
  159. die;
  160. }
  161. }
  162. } else {
  163. echo json_encode(array('status' => 'false', 'msg' => '该计量支付已关闭,请联系相关管理人员。'), JSON_UNESCAPED_UNICODE);
  164. die;
  165. }
  166. } catch (Exception $exc) {
  167. }
  168. } else {
  169. echo json_encode(array('status' => 'false', 'msg' => '参数错误'), JSON_UNESCAPED_UNICODE);
  170. die;
  171. }
  172. }
  173. // 创建标段
  174. // 参数:用户ID,创建名称,KEY
  175. function ClientCreatmeasure()
  176. {
  177. if (isset($this->params['uid']) && $this->params['uid'] && isset($this->params['bname']) && $this->params['bname'] && $this->params['ckey'] && isset($this->params['ckey'])) {
  178. $retval = $this->contractact->getPidWithKey($this->params['ckey']);
  179. if (isset($retval['pid'])) {
  180. $pArray = $this->project->getRowByPid($retval['pid']);
  181. if (isset($this->params['uid']) && ($this->params['uid'] == $pArray['uid'])) {
  182. $status = array('status' => FALSE, 'msg' => '业主不能作为编制人新建标段!');
  183. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  184. die();
  185. }
  186. $id = $this->actmeasure->insertMeasure(intval($this->params['uid']), $retval['pid'], $retval['stid'], iconv('GBK', 'UTF-8', $this->params['bname']));
  187. $this->measureauditact->insertMeasureAudit($pArray['pid'], 0, $pArray['uid'], 0, $id, $retval['stid'], 1, 'uncheck', 1); //加入业主
  188. $uArray = $this->profile->getProWithUid($retval['uid']);
  189. $strAvatar = $this->auth->getAvatar($uArray['userid']);
  190. $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']);
  191. $status = array('status' => TRUE, 'msg' => '', 'createinfo' => $createArray);
  192. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  193. die();
  194. } else {
  195. $status = array('status' => FALSE, 'msg' => 'The key is error');
  196. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  197. die();
  198. }
  199. } else {
  200. $status = array('status' => FALSE, 'msg' => 'error_create');
  201. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  202. die();
  203. }
  204. }
  205. // 编制人审批第一期时 开始审批第一期时候调用ll
  206. public function ClientPeriod()
  207. {
  208. // TODO:上报数据
  209. // TODO:每期更新数据时候和上传时候要查询当前进行期数的第几次一并写入数据库
  210. if (isset($this->params['userid']) && isset($this->params['tenderid']) && isset($this->params['phaseno']) && isset($_POST['MD5_JL']) && isset($_POST['MD5_Zip'])) {
  211. $fp = $this->upfile('upfile');
  212. if (isset($fp[0]['filepath'])) {
  213. /**
  214. * 增加上传压缩包md5检测机制
  215. */
  216. $localmd5HashString = hash_file("md5", Doo::conf()->SITE_PATH . $fp[0]['filepath']);
  217. if ($localmd5HashString != trim($_POST['MD5_Zip'])) {
  218. $status = array('status' => 'FALSE', 'msg' => '期数数据上传失败,请重新上传');
  219. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  220. die();
  221. }
  222. $res = $this->zip->open(Doo::conf()->SITE_PATH . $fp[0]['filepath']);
  223. $extPath = pathinfo($fp[0]['filepath']);
  224. $extPathdir = Doo::conf()->SITE_PATH . $extPath['dirname'] . '/' . $extPath['filename'];
  225. if ($res === TRUE) {
  226. if (!$this->dir_create($extPathdir)) {
  227. $status = array('status' => 'FALSE', 'msg' => '期数数据上传失败');
  228. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  229. die();
  230. }
  231. $this->zip->extractTo($extPathdir);
  232. $this->zip->close();
  233. }
  234. $countArray = json_decode(file_get_contents($extPathdir . '/' . 'JsonFile_Common.json'), TRUE, JSON_UNESCAPED_UNICODE);
  235. if (!isset($countArray)) {
  236. $status = array('status' => 'FALSE', 'msg' => '期数汇总数据上传失败');
  237. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  238. die();
  239. }
  240. $this->actmeasure->updateCon($this->params['tenderid'], $countArray['TotalPrice']);
  241. $pmArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);
  242. if (isset($pmArray['pmid'])) {
  243. // 由于不通过功能数据表记录重复写入时要考虑当前是第几次审批
  244. $intMaxTimes = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno']);
  245. if (isset($intMaxTimes['times']) && ($intMaxTimes['times'] >= 0)) {
  246. $iniTimes = $intMaxTimes['times'] + 1;
  247. } else {
  248. $iniTimes = 0;
  249. }
  250. // 写入第一期
  251. $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);
  252. // 更新审批人MPID
  253. $this->measureauditact->updateAuditorMPID($mpid, $this->params['tenderid'], $this->params['phaseno'], $iniTimes);
  254. // 设置审批人状态
  255. $firstAuditor = $this->measureauditact->getFirstAuditor($this->params['tenderid'], $this->params['phaseno'], $iniTimes);
  256. if (isset($firstAuditor)) {
  257. if ($firstAuditor['mastatus'] == 'uncheck') {
  258. $retVal = $this->measureauditact->updateMastatus($firstAuditor['maid']);
  259. if ($retVal > 0) {
  260. // SMS Start
  261. $verifyUserArray = $this->profile->getVerifiedMobile($firstAuditor['auditoruid']);
  262. $pmnameArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);
  263. if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// // XXXX(标段名),陈特,已审批通过。请您继续审批。
  264. $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  265. }
  266. // SMS End
  267. }
  268. }
  269. }
  270. }
  271. if ($mpid > 0) {
  272. 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, 2)) {
  273. $infostatus = 0;
  274. $pmArray = $this->numofperact->getRowTender($this->params['tenderid']);
  275. if ($pmArray) {
  276. $countTotal = count($pmArray);
  277. $ownerStatusArray = $this->measureauditact->getStatusTender($pmArray[0]['pmid'], $pmArray[0]['numpname']);
  278. if ($ownerStatusArray) {
  279. $infostatus = $this->statusArray[$ownerStatusArray['mastatus']];
  280. }
  281. echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('curr' => $pmArray[0]['numpname'], 'infostatus' => $infostatus, 'total' => $countTotal)), JSON_UNESCAPED_UNICODE);
  282. die();
  283. } else {
  284. echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('curr' => 1, 'infostatus' => 1, 'total' => 1)), JSON_UNESCAPED_UNICODE);
  285. die();
  286. }
  287. } else {
  288. $status = array('status' => 'FALSE', 'msg' => '期数上传失败');
  289. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  290. die();
  291. }
  292. } else {
  293. $status = array('status' => 'FALSE', 'msg' => '期数上传失败');
  294. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  295. die();
  296. }
  297. } else {
  298. $status = array('status' => 'FALSE', 'msg' => '文件上传失败,请重试');
  299. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  300. die();
  301. }
  302. } else {
  303. $status = array('status' => 'FALSE', 'msg' => '上传参数错误');
  304. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  305. die();
  306. }
  307. }
  308. /**
  309. * 获取标段状态信息(由于加入了)
  310. * 每个标段只有一期在进行中 group by?
  311. *
  312. * 查询标段的审批状态可以根据业主的审批依据来查询
  313. * 如果除业主意外的人审批状态为未通过怎么处理
  314. */
  315. public function getMAStatus()
  316. {
  317. // curr:当前期数,status:当前状态,total:总期数
  318. // 参数catid
  319. if (isset($this->params['tenderid'])) {
  320. $pmArray = $this->numofperact->getRowTenderCurr($this->params['tenderid']);
  321. $countTotal = count($pmArray);
  322. $ownerStatus = NULL;
  323. $isUnCheck = TRUE;
  324. $ownerStatusArray = $this->measureauditact->getStatusTen($pmArray[0]['pmid'], $pmArray[0]['numpname']);
  325. // if (isset($ownerStatusArray))
  326. // if (($ownerStatusArray[0]['last'] == 1) && ($ownerStatusArray[0]['mastatus'] == 'checked')) {
  327. // $ownerStatus = 'checked';
  328. // } else {
  329. // $ownerStatus = 'checking';
  330. // }
  331. $statusArray = $this->numofperact->getMaxRowStatus($pmArray[0]['pmid'], $pmArray[0]['numpname']);
  332. $ownerStatus = $statusArray['currstatus'];
  333. // foreach ($ownerStatusArray as $kk => $vv) {
  334. // if (($vv['last'] == 1) && ($vv['mastatus'] == 'checked')) {
  335. // $ownerStatus = 'checked';
  336. // } else {
  337. // $ownerStatus = 'checking';
  338. // }
  339. // }
  340. $projectArray = $this->project->getRowByPid($ownerStatusArray[0]['pid']);
  341. $stArray = $this->contractact->getRowByStid($ownerStatusArray[0]['stid']);
  342. $profileArray = $this->profile->getProWithUid($projectArray['uid']);
  343. $auditArray = $this->measureauditact->getAuditUserRedo($pmArray[0]['pmid'], $pmArray[0]['numpname']);
  344. if (isset($auditArray[0]['auditoruid'])) {
  345. foreach ($auditArray as $key => $value) {
  346. $userArray = $this->profile->getProWithUid($value['auditoruid']);
  347. $auditcontent = !empty($value['auditcontent']) ? $value['auditcontent'] : '';
  348. // $finalStatus = $value['mastatus'];
  349. if ($value['mastatus'] != 'uncheck') {
  350. $isUnCheck = FALSE;
  351. }
  352. if ($value['audittime'] > 0) {
  353. $value['audittime'] = date('Y-m-d', $value['audittime']);
  354. }
  355. $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' => $auditcontent, 'onlineaudit' => $value['onlineaudit'], 'audittime' => $value['audittime']);
  356. }
  357. }
  358. if ($ownerStatusArray) {
  359. if ($isUnCheck) {
  360. 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);
  361. } else {
  362. 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);
  363. }
  364. die();
  365. } else {
  366. echo json_encode(array('status' => 'FALSE', 'msg' => '标段状态查询不存在'), JSON_UNESCAPED_UNICODE);
  367. die();
  368. }
  369. } else {
  370. echo json_encode(array('status' => 'FALSE', 'msg' => '标段状态查询参数错误'), JSON_UNESCAPED_UNICODE);
  371. die();
  372. }
  373. }
  374. public function getUserSearch()
  375. {
  376. if (isset($_POST['uemail'])) {
  377. $retval = $this->users->getOne(array('where' => 'uemail=?', 'param' => array($_POST['uemail']), 'asArray' => TRUE));
  378. if (isset($retval['uid'])) {
  379. $proArray = $this->profile->getProWithUid($retval['uid']);
  380. if (isset($proArray['userid'])) {
  381. $strAvatar = $this->auth->getAvatar($proArray['userid']);
  382. 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);
  383. die();
  384. } else {
  385. echo json_encode(array('status' => 'FALSE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  386. die();
  387. }
  388. } else {
  389. echo json_encode(array('status' => 'FALSE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  390. die();
  391. }
  392. } else {
  393. echo json_encode(array('status' => 'FALSE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  394. die();
  395. }
  396. }
  397. /**
  398. * 获取指定标段指定期数{默认提取重做后最新一期的}
  399. * 单击获取项目相关审批人员和状态
  400. * sectionid:标段ID periodid:期数
  401. * TODO:如果审批人的期数或者次数与标段期数或者次数存在不对应情况的处理
  402. */
  403. public function getAlluserMeasure()
  404. {
  405. if (isset($this->params['tenderid']) && isset($this->params['phaseno'])) {
  406. // error_log(var_export($this->params, TRUE), 3, '/opt/html/jlzftest/data/' . time());
  407. // 先判断是否存在期数问题
  408. // 然后再判断是否存在次数不匹配
  409. // $intNum = $this->numofperact->getCountNumpname($this->params['tenderid'], $this->params['phaseno']);
  410. // // 如果期数是第一期期数必须大于一,否则减一为无效数据 ,为0表示这期为做上报没有产生记录
  411. // if (( $this->params['phaseno'] > 1) && ($intNum == 0)) {// 提取上一期的数据
  412. // // 提取期数减一
  413. // $intLastTimes = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno'] - 1)['times'];
  414. // $uinfoTmpArray = $this->measureauditact->getAllAudit($this->params['tenderid'], $this->params['phaseno'] - 1, $intLastTimes);
  415. // } else {
  416. // $IntMaxRedoTimes = $this->measureauditact->getMaxTimes($this->params['tenderid'], $this->params['phaseno'])['maxtimes'];
  417. // $intTimes = $this->numofperact->getCountTimes($this->params['tenderid'], $this->params['phaseno'], $IntMaxRedoTimes);
  418. // if (($intTimes == 0) && ($IntMaxRedoTimes > 0)) {
  419. // $lastTimes = $IntMaxRedoTimes - 1;
  420. // $uinfoTmpArray = $this->measureauditact->getAllAudit($this->params['tenderid'], $this->params['phaseno'], $lastTimes);
  421. // } else {
  422. // $uinfoTmpArray = $this->measureauditact->getAllAudit($this->params['tenderid'], $this->params['phaseno'], $IntMaxRedoTimes);
  423. // }
  424. // }
  425. $uinfoTmpArray = $this->measureauditact->getAlluserMeasureAudit($this->params['tenderid'], $this->params['phaseno']);
  426. if ($uinfoTmpArray) {
  427. foreach ($uinfoTmpArray as $key => $value) {
  428. $uArray = $this->profile->getProWithUid($value['auditoruid']);
  429. $uinfoArray[$key]['name'] = $uArray['name'];
  430. $uinfoArray[$key]['company'] = $uArray['company'];
  431. $uinfoArray[$key]['jobs'] = $uArray['jobs'];
  432. $uinfoArray[$key]['mastatus'] = $this->statusArray[$value['mastatus']];
  433. $uinfoArray[$key]['uid'] = $value['auditoruid'];
  434. $uinfoArray[$key]['avatar'] = $this->auth->getAvatar($value['auditoruid']);
  435. $uinfoArray[$key]['CheckerMemo'] = !empty($value['auditcontent']) ? $value['auditcontent'] : '';
  436. $uinfoArray[$key]['onlineaudit'] = $value['onlineaudit'];
  437. if ($value['audittime'] > 0) {
  438. $uinfoArray[$key]['audittime'] = date('Y-m-d', $value['audittime']);
  439. } else {
  440. $uinfoArray[$key]['audittime'] = '0';
  441. }
  442. }
  443. } else {
  444. echo json_encode(array('status' => FALSE, 'msg' => '用户列表不存在'), JSON_UNESCAPED_UNICODE);
  445. die();
  446. }
  447. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $uinfoArray), JSON_UNESCAPED_UNICODE);
  448. die();
  449. } else {
  450. echo json_encode(array('status' => FALSE, 'msg' => '错误'), JSON_UNESCAPED_UNICODE);
  451. die();
  452. }
  453. }
  454. //
  455. //
  456. // 配置审批人时候还没有创建标段所以没有MPID存在
  457. function addAuditMeasure()
  458. {
  459. // 必须检查期数是否存在
  460. // 标段ID 当前登录 审批人ID
  461. // 检测是否重复写入 && ($_POST['creatoruid'] > 0)
  462. // TODO: 增加多次审批人变更需求,调整审批人增加、删除接口
  463. // 当前操作的是否为最新一期还是最新一期加一(项目进行中时,不能编辑审批人,所以直接加一)
  464. // 大于一次重做的时候,自动复制编制人和所有审批人次数加一
  465. if (isset($_POST['pmid']) && isset($_POST['creatoruid']) && isset($_POST['auditoruid']) && isset($_POST['numpname'])) {
  466. $IntMaxTimes = $this->measureauditact->getMaxTimesInt($_POST['pmid'], $_POST['numpname']); // 根据标段PMID,期数numpname,获取目前重做次数
  467. if ($IntMaxTimes > 0) {
  468. $inTimes = $IntMaxTimes;
  469. } else {
  470. $inTimes = 0;
  471. }
  472. $pmArray = $this->actmeasure->getRowByPmid($_POST['pmid']);
  473. try {
  474. if ($this->measureauditact->insertMeasureAudit($pmArray['pid'], $_POST['creatoruid'], $_POST['auditoruid'], 0, $_POST['pmid'], $pmArray['stid'], $_POST['numpname'], 'uncheck', 2, $inTimes) > 0) {
  475. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => ''), JSON_UNESCAPED_UNICODE);
  476. die();
  477. }
  478. } catch (PDOException $e) {// 判断异常类型,提示不同错误信息
  479. echo json_encode(array('status' => FALSE, 'msg' => '配置审批人错误'), JSON_UNESCAPED_UNICODE);
  480. }
  481. } else {
  482. echo json_encode(array('status' => FALSE, 'msg' => '配置审批人参数错误'), JSON_UNESCAPED_UNICODE);
  483. die();
  484. }
  485. }
  486. /**
  487. * 删除审批用户
  488. */
  489. function delAuditMeasure()
  490. {
  491. if (isset($this->params['userid']) && isset($this->params['tenderid']) && isset($this->params['phaseno'])) {
  492. // 判断当前标段期数审批状态,决定是否继续执行
  493. $IntMaxTimes = $this->measureauditact->getMaxTimesInt($this->params['tenderid'], $this->params['phaseno']); // 根据标段PMID,期数numpname,获取目前重做次数
  494. if ($IntMaxTimes > 0) {
  495. $inTimes = $IntMaxTimes;
  496. $intHasCount = $this->numofperact->hasTheTimesRow($this->params['tenderid'], $this->params['phaseno'], $inTimes);
  497. if (isset($intHasCount) && ($intHasCount > 0)) {
  498. echo json_encode(array('status' => FALSE, 'msg' => '此标段状态,禁止删除审批人员'), JSON_UNESCAPED_UNICODE);
  499. die();
  500. }
  501. } else {
  502. $inTimes = 0;
  503. }
  504. try {
  505. $this->measureauditact->delAuditUserTimes($this->params['tenderid'], $this->params['phaseno'], $this->params['userid'], $inTimes);
  506. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  507. die();
  508. } catch (PDOException $e) {// 判断异常类型,提示不同错误信息
  509. echo json_encode(array('status' => FALSE, 'msg' => '删除审批人错误'), JSON_UNESCAPED_UNICODE);
  510. }
  511. } else {
  512. echo json_encode(array('status' => FALSE, 'msg' => '删除审批人员参数错误'), JSON_UNESCAPED_UNICODE);
  513. die();
  514. }
  515. }
  516. // 查询状态变更为审批中,已审批中为查询依据
  517. function checkMeasureStatus()
  518. {
  519. if (isset($_POST['sectionid']) && isset($_POST['periodid'])) {
  520. $mpArray = $this->numofperact->getRow($_POST['sectionid'], $_POST['periodid']);
  521. $maArray = $this->measureauditact->getAlluserMeasureAudit($_POST['sectionid'], $_POST['periodid']);
  522. foreach ($maArray as $key => $value) {
  523. if ($value['mastatus'] == 'uncheck') {
  524. $mastatus = $this->statusArray[$value['mastatus']];
  525. }
  526. }
  527. if (isset($mpArray['mpid'])) {
  528. echo json_encode(array('status' => TRUE, 'msg' => '', 'isexist' => TRUE, 'checkstatus' => $mastatus), JSON_UNESCAPED_UNICODE);
  529. die();
  530. } else {
  531. echo json_encode(array('status' => TRUE, 'msg' => '', 'isexist' => FALSE), JSON_UNESCAPED_UNICODE);
  532. die();
  533. }
  534. } else {
  535. echo json_encode(array('status' => FALSE, 'msg' => '标段信息不正确'), JSON_UNESCAPED_UNICODE);
  536. die();
  537. }
  538. }
  539. // 根据用户查询参与的标段信息
  540. // 参数为1时,当提交的附件中有重做记录时,提取记录未经过排重处理,出现重复结果。
  541. // api/client/user/get/15/allproject 此接口也有同样问题
  542. function getAuditProject()
  543. {
  544. // TODO:可以通过SQL直接查询出来
  545. if (isset($_POST['audituid']) && isset($_POST['RequestType'])) {
  546. $downfileurl = NULL;
  547. /**
  548. * 只查询审批中状态的记录
  549. * 然后根据每天记录所在的标段、期数、创建人查询所有此次所有审批人记录、为了判断
  550. * 判断此用户是第几个审批的人
  551. * 直接提取状态为未审批、审批中的
  552. * 未审批(没有到该审批人)
  553. * 审批中(出现在第一个)
  554. * 上传审批时候先遍历所有审批提交文件的状态并设置为旧文件状态
  555. * 然后写入新审批的文件路径等信息
  556. * 审批同时上传审批文件并设置审批表的状态做更改
  557. *
  558. */
  559. if ($_POST['RequestType'] == 1) {
  560. /**
  561. * 功能描述:
  562. * 参数1功能为,取得与当前用户相关的待审批状态的所有进行中的标段期数、最新一次的记录
  563. * 根据用户ID查询编制人和审批人参与的正在进行中的项目,进行中的项目状态为uncheck,checking
  564. * 由于·uncheck状态不能准确反映出其他用户操作对所属标段操作产生的的状态{比如:其他用户操作标段状态为(未通过【打回重做】)}、要排除这种情况
  565. * 还有一种情况为编制人编制项目时,审批人列表已经添加审批人,但是项目没有提交,没有项目文件,此时应根据有没有项目文件进行过滤。
  566. *
  567. * ??此ID为编制人或者为审批人时
  568. */
  569. // 第一步:根据用户ID,查询此用户参与的所有标段{根据最大期数【由于期数是递进关系只获取最大值】、最大次数【由于次数是递进关系只获取最大值】作为条件参数进行查询记录}
  570. $mpArray = $this->measureauditact->getCheckedRowbyUID2($_POST['audituid']); // 通过pmid,numpname分组获取参与的记录
  571. if (isset($mpArray)) {
  572. $statusArray = array('uncheck', 'checking');
  573. foreach ($mpArray as $key => $value) {
  574. /**
  575. * 根据审批ID查询所在标段期数
  576. * 然后去附件表根据标段ID 期数 是否新标志字段去查询最新的文件
  577. * 项目名称 项目类型
  578. *
  579. *
  580. * 此处现在是以创建者ID和审批人ID做关联来做判断
  581. * 判断上一个人的审批状态来提取记录
  582. *
  583. * 变更为一个用户添加所有人
  584. *
  585. */
  586. // $maxtimes = $this->attfile->getMaxTimes2($value['pmid'], $value['numpname']);
  587. $numStatusArray = $this->numofperact->getRow($value['pmid'], $value['numpname'], $value['times']);
  588. if (in_array($numStatusArray['currstatus'], $statusArray)) {
  589. $newfileArray = $this->attfile->getNewLast($value['pmid'], $value['numpname'], $value['times']);
  590. if (isset($newfileArray['filepath'])) {
  591. $projectArray = $this->project->getRowByPid($newfileArray['pid']);
  592. $pmidArray = $this->actmeasure->getRowByPmid($value['pmid']);
  593. $stArray = $this->contractact->getRowByStid($newfileArray['stid']);
  594. // $auditArray = $this->measureauditact->getLastNewRowInfo($value['pmid'], $value['numpname'], $_POST['audituid']);
  595. $pathinfo = pathinfo($newfileArray['filepath']);
  596. $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']);
  597. }
  598. }
  599. }
  600. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downfileurl), JSON_UNESCAPED_UNICODE);
  601. die();
  602. } else {
  603. echo json_encode(array('status' => FALSE, 'msg' => '暂时无审批信息'), JSON_UNESCAPED_UNICODE);
  604. die();
  605. }
  606. }
  607. if ($_POST['RequestType'] == 2) {
  608. /**
  609. * {
  610. * "downurl": "http://d.jl.smartcost.com.cn/data/2015/0608/20150608043245691/ProjectFile.rmf", 最新一期最新一次的文件
  611. * "proName": "巫溪县前进桥", 项目名称
  612. * "stName": "巫溪县 前进桥(终)", 合同段名称
  613. * "MD5_Jl": "7cf05dccc6ad45b2d78f476a3388c3b2", 最新一期最新一次的文件hash code
  614. * "tenderstatus": "2", 标段状态
  615. * "tenderid": "234", 标段ID
  616. * "pnameid": "79", 项目ID
  617. * "ptypeid": "96", 合同段ID
  618. * "audituidstatus": "2", 当前用户审批状态
  619. * "bianzhirenuid": "59", 编制人UID
  620. * "tenderName": "巫溪县 前进桥 终" 标段名称
  621. * }
  622. */
  623. // TODO::不同角色提取条件不同是否使用audituid 作为当前用户提取条件,容易产生冲突
  624. if (!isset($_POST['audituid']) || !($_POST['audituid'] > 0)) {
  625. echo json_encode(array('status' => FALSE, 'msg' => '返回指定用户参与的所有项目参数错误'), JSON_UNESCAPED_UNICODE);
  626. die();
  627. }
  628. // 三个角色数据合并返回
  629. // 返回最新一期的项目文件
  630. // 业主
  631. // 业主查询参与的项目时
  632. // TODO::业主是否参与审批?如果参与提取哪个参与者的审批状态?
  633. $userproArray = $this->project->getRowUid($_POST['audituid']);
  634. $newattArray = $retArray = $hashArray = NULL;
  635. foreach ($userproArray as $upk => $upv) {
  636. $attArray = $this->attfile->getPmidGroup($upv['pid']);
  637. $attaArray = NULL;
  638. foreach ($attArray as $akey => $avalue) {
  639. $attaArray[] = $this->attfile->getLastNumTimes($avalue['pmid']);
  640. }
  641. foreach ($attaArray as $attk => $attv) {
  642. $attfileArray = $this->contractact->getRowByStid($attv['stid']);
  643. $pmidArray = $this->actmeasure->getRowByPmid($attv['pmid']);
  644. $numArray = $this->numofperact->getRow($attv['pmid'], $attv['numpname'], $attv['times']);
  645. $auditArray = $this->measureauditact->getLastNewRowInfo($attv['pmid'], $attv['numpname'], $_POST['audituid']);
  646. $pathinfo = pathinfo($attv['filepath']);
  647. if (isset($pathinfo['dirname'])) {
  648. $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']);
  649. $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']);
  650. }
  651. }
  652. }
  653. // 施工
  654. $measureArray = $this->actmeasure->getPmidRow($_POST['audituid']);
  655. if (isset($measureArray) && $measureArray) {
  656. $attfileArray = $stidArray = NULL;
  657. foreach ($measureArray as $key => $value) {
  658. $proArray = $this->project->getRowByPid($value['pid']);
  659. $conArray = $this->contractact->getRowByStid($value['stid']);
  660. $attfileArray = $this->attfile->getLastNewProfile2($value['pmid']);
  661. $pmidArray = $this->actmeasure->getRowByPmid($value['pmid']);
  662. $statusArray = $this->numofperact->getMaxRowStatus($attfileArray['pmid'], $attfileArray['numpname']);
  663. $auditArray = $this->measureauditact->getLastNewRowInfo($attfileArray['pmid'], $attfileArray['numpname'], $_POST['audituid']);
  664. $pathinfo = pathinfo($attfileArray['filepath']);
  665. if (!$auditArray['mastatus'])
  666. $auditStr = 'uncheck';
  667. else
  668. $auditStr = $auditArray['mastatus'];
  669. if (isset($pathinfo['dirname'])) {
  670. $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']);
  671. if (!in_array($hashstr, $hashArray)) {
  672. $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']);
  673. $hashArray[] = $hashstr;
  674. }
  675. }
  676. }
  677. }
  678. // 审批 是否只提取最新一期?
  679. $pmidGroupArray = $this->measureauditact->getPmidGroup($_POST['audituid']);
  680. /**
  681. * 从审批人列表中提取记录时,如果项目进行到新开一次或者一期数据,但是上报人并未上报数据,(犹豫逻辑上机制导致,先创建审批人再通过上报人上报数据才能产生新一期)
  682. * 这时,上报人查询到的数据就为空。
  683. * 如果没有最新一次上报数据(可否提取2期上报数据?即便是能下载也不能打开,因为上一期数据的审批人数或者状态,可能与最新一期的审批人状态不同,然后软件报错)
  684. */
  685. $retval = null;
  686. foreach ($pmidGroupArray as $gkey => $gvalue) {
  687. $retval[] = $this->measureauditact->getLastNumTimes($gvalue['pmid'], $_POST['audituid']);
  688. }
  689. foreach ($retval as $spkey => $spvalue) {
  690. $pathinfo = null;
  691. $proArray = $this->project->getRowByPid($spvalue['pid']);
  692. $conArray = $this->contractact->getRowByStid($spvalue['stid']);
  693. $pmidArray = $this->actmeasure->getRowByPmid($spvalue['pmid']);
  694. /**
  695. * 两种情况 一种情况是 新建一期 还有一种是审批未通过重做 这两种未提交
  696. */
  697. $intNum = $this->numofperact->getCountNumpname($spvalue['pmid'], $spvalue['numpname']);
  698. // 如果期数是第一期期数必须大于一,否则减一为无效数据 ,为0表示这期为做上报没有产生记录
  699. if (($spvalue['numpname'] > 1) && ($intNum == 0)) {// 提取上一期的数据
  700. // 提取期数减一
  701. $intLastTimes = $this->numofperact->getMaxTimes($spvalue['pmid'], $spvalue['numpname'] - 1)['times'];
  702. $numstatusArray = $this->numofperact->getRow($spvalue['pmid'], $spvalue['numpname'] - 1, $intLastTimes); //获取上一期最新一次的状态
  703. } else {
  704. $intTimes = $this->numofperact->getCountTimes($spvalue['pmid'], $spvalue['numpname'], $spvalue['times']);
  705. if (($intTimes == '0') && $spvalue['times'] > 0) {
  706. $numstatusArray = $this->numofperact->getRow($spvalue['pmid'], $spvalue['numpname'], $spvalue['times'] - 1);
  707. } else {// 当创建第一次的时候也会为空,所以下方加了判断
  708. $numstatusArray = $this->numofperact->getRow($spvalue['pmid'], $spvalue['numpname'], $spvalue['times']);
  709. }
  710. }
  711. $afArray = $this->attfile->getLastNewProfile2($spvalue['pmid']); // 由于始终提取最新一期所以不用放入判断情况中
  712. $auditArray = $this->measureauditact->getLastNewRowInfo($spvalue['pmid'], $spvalue['numpname'], $_POST['audituid']);
  713. $pathinfo = pathinfo($afArray['filepath']);
  714. if ($numstatusArray && $auditArray) { // 如果重做审批人有变更,根据审批状态判断是否存在该审批人,不存在则不显示此条记录
  715. $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']);
  716. if (!in_array($hashstr, $hashArray)) {
  717. $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']);
  718. $hashArray[] = $hashstr;
  719. }
  720. }
  721. }
  722. //标段关注人
  723. $concernArray = $this->concern->getRowbyUid($_POST['audituid']);
  724. if (isset($concernArray) && !empty($concernArray)) {
  725. $attfileArray = $stidArray = NULL;
  726. foreach ($concernArray as $key => $value) {
  727. $proArray = $this->project->getRowByPid($value['pid']);
  728. $conArray = $this->contractact->getRowByStid($value['stid']);
  729. $attfileArray = $this->attfile->getLastNewProfile2($value['pmid']);
  730. $pmidArray = $this->actmeasure->getRowByPmid($value['pmid']);
  731. $statusArray = $this->numofperact->getMaxRowStatus($attfileArray['pmid'], $attfileArray['numpname']);
  732. $auditArray = $this->measureauditact->getLastNewRowInfo($attfileArray['pmid'], $attfileArray['numpname'], $_POST['audituid']);
  733. $pathinfo = pathinfo($attfileArray['filepath']);
  734. if (!$auditArray['mastatus'])
  735. $auditStr = 'uncheck';
  736. else
  737. $auditStr = $auditArray['mastatus'];
  738. if (isset($pathinfo['dirname'])) {
  739. $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']);
  740. if (!in_array($hashstr, $hashArray)) {
  741. $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']);
  742. $hashArray[] = $hashstr;
  743. }
  744. }
  745. }
  746. }
  747. // $dd = NULL;
  748. // if (isset($retArray))
  749. // $dd = $this->array_unique_fb($retArray);
  750. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $retArray), JSON_UNESCAPED_UNICODE);
  751. }
  752. }
  753. }
  754. //二维数组去掉重复值 并保留键值
  755. function array_unique_fb($array2D)
  756. {
  757. $key = array();
  758. foreach ($array2D as $k => $v) {
  759. if (empty($key))
  760. $key = array_keys($v); //记录数组的KEY
  761. $v = join(",", $v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
  762. $temp[$k] = $v;
  763. }
  764. $temp = array_unique($temp); //去掉重复的字符串,也就是重复的一维数组
  765. foreach ($temp as $k => $v) {
  766. $array = explode(",", $v); //再将拆开的数组重新组装
  767. foreach ($array as $i => $t) {
  768. $temp2[$k] = !empty($temp2[$k]) ? array_merge($temp2[$k], array("{
  769. $key[$i]}" => $t)) : array("{
  770. $key[$i]}" => $t); //依次添加到新的数组中去
  771. }
  772. }
  773. return $temp2;
  774. }
  775. function unique_arr($array2D, $stkeep = false, $ndformat = true)
  776. {
  777. // 判断是否保留一级数组键 (一级数组键可以为非数字)
  778. if ($stkeep)
  779. $stArr = array_keys($array2D);
  780. // 判断是否保留二级数组键 (所有二级数组键必须相同)
  781. if ($ndformat)
  782. $ndArr = array_keys(end($array2D));
  783. //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
  784. foreach ($array2D as $v) {
  785. $v = join(",", $v);
  786. $temp[] = $v;
  787. }
  788. //去掉重复的字符串,也就是重复的一维数组
  789. $temp = array_unique($temp);
  790. //再将拆开的数组重新组装
  791. foreach ($temp as $k => $v) {
  792. if ($stkeep)
  793. $k = $stArr[$k];
  794. if ($ndformat) {
  795. $tempArr = explode(",", $v);
  796. foreach ($tempArr as $ndkey => $ndval) {
  797. $output[$k][$ndArr[$ndkey]] = $ndval;
  798. }
  799. } else {
  800. $output[$k] = explode(",", $v);
  801. }
  802. }
  803. return $output;
  804. }
  805. // 标段期审批接口
  806. function auditMeasure()
  807. {
  808. if (isset($_POST['userid']) && isset($_POST['tenderid']) && isset($_POST['phaseno']) && isset($_POST['MD5_JL']) && isset($_POST['MD5_Zip'])) {
  809. $auditcontent = iconv('GBK', 'UTF-8', $_POST['CheckerMemo']);
  810. $auditArray = $this->measureauditact->getLastNewRowInfo($_POST['tenderid'], $_POST['phaseno'], $_POST['userid']);
  811. if (isset($auditArray ['mastatus']) && (($auditArray ['mastatus'] == 'checked') || ($auditArray ['mastatus'] == 'checkno'))) {
  812. echo json_encode(array('status' => FALSE, 'msg' => '该标段已审批完毕。'), JSON_UNESCAPED_UNICODE);
  813. die();
  814. }
  815. $auditUserArray = $this->measureauditact->getUserAuditLast($_POST['tenderid'], $_POST['phaseno']);
  816. $fp = $this->upfile('upfile');
  817. if (isset($fp[0]['filepath'])) {
  818. $localmd5HashString = hash_file("md5", Doo::conf()->SITE_PATH . $fp[0]['filepath']);
  819. if ($localmd5HashString != trim($_POST['MD5_Zip'])) {
  820. $status = array('status' => 'FALSE', 'msg' => '审批期数数据上传失败,请重新上传');
  821. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  822. die();
  823. }
  824. $res = $this->zip->open(Doo::conf()->SITE_PATH . $fp[0]['filepath']);
  825. $extPath = pathinfo($fp[0]['filepath']);
  826. $extPathdir = Doo::conf()->SITE_PATH . $extPath ['dirname'] . '/' . $extPath['filename'];
  827. if ($res === TRUE) {
  828. if (!$this->dir_create($extPathdir)) {
  829. return FALSE;
  830. }
  831. $this->zip->extractTo($extPathdir);
  832. $this->zip->close();
  833. }
  834. // 更新五项最新数据
  835. $countArray = json_decode(file_get_contents($extPathdir . '/' . 'JsonFile_Common.json'), TRUE, JSON_UNESCAPED_UNICODE);
  836. if (!isset($countArray)) {
  837. $status = array('status' => FALSE, 'msg' => '期数汇总数据上传失败');
  838. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  839. die();
  840. }
  841. $iniTimes = 0;
  842. $intMaxTimes = $this->numofperact->getMaxTimes($_POST['tenderid'], $_POST['phaseno']);
  843. if (isset($intMaxTimes['times']) && ($intMaxTimes['times'] > 0)) {
  844. $iniTimes = $intMaxTimes['times'];
  845. }
  846. $this->actmeasure->updateCon($_POST['tenderid'], $countArray['TotalPrice']);
  847. $this->numofperact->updateNumofper($_POST['tenderid'], $_POST['phaseno'], $countArray, $iniTimes);
  848. $numArray = $this->numofperact->getRow($_POST['tenderid'], $_POST['phaseno'], $iniTimes);
  849. if (isset($auditArray['pid'])) {
  850. // 插入附件表之前要更新所有次标段期数的提交的数据状态为旧标志
  851. $this->attfile->setOldfileFlag($_POST['tenderid'], $_POST['phaseno'], $iniTimes);
  852. // 插入此次提交的文件路径数据并设置为新状态
  853. // 写入此时是第几次重做
  854. $this->attfile->insertFile($auditArray['pid'], $auditArray['stid'], $numArray['mpid'], $_POST['tenderid'], $_POST['phaseno'], $_POST['userid'], $fp[0]['filepath'], 0, $_POST['MD5_JL'], $iniTimes);
  855. // 更新审批表审批人的标段期数审批状态
  856. if ($this->measureauditact->setStatusTo($auditArray['maid'], 3, $auditcontent)) {
  857. // 更新下一个人的状态
  858. $countAudit = count($auditUserArray);
  859. if ($auditArray['last'] == '1') {// 根据标志位判断是否为最后一个审核人{ 判断当前审核人是什么角色 } 利用post发送的UID 与 当前期数参与的所有人比较
  860. $this->measureauditact->setStatusTo($auditUserArray[0]['maid'], 3);
  861. $this->numofperact->updateAuditStatus($_POST['tenderid'], $_POST['phaseno'], 'checked', $iniTimes);
  862. // SMS Start
  863. $TenderArray = $this->actmeasure->getRowByPmid($_POST['tenderid']);
  864. $userProArray = $this->profile->getProWithUid($TenderArray['uid']);
  865. if (isset($userProArray) && ($userProArray['mobile'])) {
  866. $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR3"]);
  867. }
  868. // SMS End
  869. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  870. die();
  871. } else {// 不是最后一个审核人根据不同审核人数量变更状态 {当前用户不是最后一个审核人}
  872. if (($countAudit == 2) && ($auditUserArray[0]['last'] == 1) && ($auditUserArray[1]['maid'] == $auditArray['maid'])) {// 如果审核人为两个,第一个是最后审核人角色,第二个为当前审核人,设置审核中状态 {就是当前用户POST UID}
  873. $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);
  874. $this->numofperact->updateAuditStatus($_POST['tenderid'], $_POST['phaseno'], 'checking', $iniTimes);
  875. // SMS Start
  876. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[0]['auditoruid']);
  877. $pmnameArray = $this->actmeasure->getRowByPmid($_POST['tenderid']);
  878. if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// XXXX(标段名),陈特,已审批通过。请您继续审批。
  879. $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  880. }
  881. // SMS End
  882. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  883. die();
  884. }
  885. if (($countAudit > 2)) {// 审核人总数大于2时,
  886. foreach ($auditUserArray as $k => $v) {
  887. if ($v['maid'] == $auditArray['maid']) {// 找到当前用户
  888. if ($k == ($countAudit - 1)) {//如果是最后一个
  889. $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);
  890. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[0]['auditoruid']);
  891. $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[0]['pmid']);
  892. } else {
  893. $this->measureauditact->updateMastatus($auditUserArray[$k + 1]['maid']);//变更下一个状态
  894. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[$k + 1]['auditoruid']);
  895. $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[$k]['pmid']);
  896. }
  897. // SMS Start
  898. if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// // XXXX(标段名),陈特,已审批通过。请您继续审批。
  899. $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  900. }
  901. // SMS End
  902. $this->numofperact->updateAuditStatus($_POST['tenderid'], $_POST['phaseno'], 'checking', $iniTimes);
  903. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  904. die();
  905. }
  906. }
  907. // 我是第几个审批的
  908. // 如果是最后一个就把业主审批状态更改为审批中
  909. // 如果是第一个就把后一个设置为审批中
  910. }
  911. }
  912. } else {
  913. echo json_encode(array('status' => FALSE, 'msg' => '审批文件提交失败1'), JSON_UNESCAPED_UNICODE);
  914. die();
  915. }
  916. }
  917. } else {
  918. echo json_encode(array('status' => FALSE, 'msg' => '审批文件提交失败'), JSON_UNESCAPED_UNICODE);
  919. die();
  920. }
  921. } else {
  922. echo json_encode(array('status' => FALSE, 'msg' => '审批参数错误'), JSON_UNESCAPED_UNICODE);
  923. die();
  924. }
  925. }
  926. /**
  927. * 根据标段ID查询是否需要更新
  928. */
  929. function checkTenderUpdate()
  930. {
  931. if (isset($this->params ['tenderid']) && $this->params['tenderid']) {
  932. $updateArray = $this->attfile->getFileUpdate($this->params['tenderid']);
  933. $projectArray = $this->project->getRowByPid($updateArray['pid']);
  934. $stArray = $this->contractact->getRowByStid($updateArray['stid']);
  935. $MeasureArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);
  936. if (isset($updateArray['filepath'])) {
  937. $pathinfo = pathinfo($updateArray['filepath']);
  938. $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']);
  939. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downfileurl), JSON_UNESCAPED_UNICODE);
  940. die();
  941. } else {
  942. echo json_encode(array('status' => TRUE, 'msg' => '暂无更新数据'), JSON_UNESCAPED_UNICODE);
  943. die();
  944. }
  945. } else {
  946. echo json_encode(array('status' => FALSE, 'msg' => '更新查询参数错误'), JSON_UNESCAPED_UNICODE);
  947. die();
  948. }
  949. }
  950. /**
  951. * 手动创建第二期的审批人
  952. */
  953. function creatTenderNumPnameUser()
  954. {
  955. if (isset($_POST['tenderid']) && isset($_POST['phaseno']) && ($_POST['phaseno'] > 1)) {
  956. $allMeasureUser = $this->measureauditact->getUserAudit($_POST['tenderid'], $_POST['phaseno'] - 1);
  957. if (isset($allMeasureUser)) {
  958. foreach ($allMeasureUser as $key => $value) {
  959. // if ($key == 1) {
  960. // $status = 'checking';
  961. // } else {
  962. $status = 'uncheck';
  963. // }
  964. try {
  965. $this->measureauditact->insertMeasureAudit($value['pid'], $value['creatoruid'], $value['auditoruid'], $value['mpid'], $value['pmid'], $value['stid'], $_POST['phaseno'], $status, $value['last']);
  966. } catch (Exception $exc) {
  967. }
  968. }
  969. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  970. die();
  971. } else {
  972. echo json_encode(array('status' => FALSE, 'msg' => '审批人员列表不存在'), JSON_UNESCAPED_UNICODE);
  973. die();
  974. }
  975. } else {
  976. echo json_encode(array('status' => FALSE, 'msg' => '创建审批人员列表参数错误'), JSON_UNESCAPED_UNICODE);
  977. die();
  978. }
  979. }
  980. /**
  981. * 返回指定用户参与的所有项目
  982. */
  983. function getUserALLProject()
  984. {
  985. if (!isset($this->params['userid']) || !($this->params['userid'] > 0)) {
  986. echo json_encode(array('status' => FALSE, 'msg' => '返回指定用户参与的所有项目参数错误'), JSON_UNESCAPED_UNICODE);
  987. die();
  988. }
  989. $conArray = $this->contractact->getUserRow($this->params['userid']);
  990. if (isset($conArray) && $conArray) {
  991. foreach ($conArray as $key => $value) {
  992. $proArray = $this->project->getRowByPid($value['pid']);
  993. $attfileArray = $this->attfile->getLastData($value['stid']);
  994. foreach ($attfileArray as $k => $v) {
  995. $pathinfo = pathinfo($v['filepath']);
  996. $retArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $proArray['pname'], 'stName' => $value['stname'], 'MD5_Jl' => $v['filehashcode']);
  997. }
  998. }
  999. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $retArray), JSON_UNESCAPED_UNICODE);
  1000. die();
  1001. } else {
  1002. $userproArray = $this->measureauditact->getProject($this->params['userid']);
  1003. if (isset($userproArray) && $userproArray) {
  1004. foreach ($userproArray as $upk => $upv) {
  1005. $attArray = $this->attfile->getMeasureLastNew($upv['pmid'], $upv['numpname']);
  1006. $proArray = $this->project->getRowByPid($attArray['pid']);
  1007. $attfileArray = $this->contractact->getRowByStid($attArray['stid']);
  1008. $pathinfo = pathinfo($attArray['filepath']);
  1009. if (isset($pathinfo['dirname']))
  1010. $newattArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $proArray['pname'], 'stName' => $attfileArray['stname'], 'MD5_Jl' => $attArray['filehashcode']);
  1011. }
  1012. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $newattArray), JSON_UNESCAPED_UNICODE);
  1013. die();
  1014. }
  1015. }
  1016. }
  1017. /**
  1018. * 设置审批未通过操作
  1019. * 第一步设置未通过操作,操作相关期数。 同步状态。
  1020. * 第二步设置项目查询接口未通过审批的查询返回未锁定的
  1021. * 第三步前台相关状态更新
  1022. *
  1023. * TODO: 更新附件标志位未加入次数标志做更新 ok
  1024. * TODO: 不通过两次未通过时候操作期数状态为错误位同步状态位 ok
  1025. * TODO: MPID未通过操作不争取 ok
  1026. */
  1027. function setCheckno()
  1028. {
  1029. if (isset($this->params['userid']) && isset($this->params['tenderid']) && isset($this->params['phaseno']) && isset($_POST['MD5_JL']) && isset($_POST['MD5_Zip'])) {
  1030. $auditcontent = iconv('GBK', 'UTF - 8', $_POST['CheckerMemo']);
  1031. $auditArrayStatus = $this->measureauditact->getLastNewRowInfo($this->params['tenderid'], $this->params['phaseno'], $this->params['userid']);
  1032. if (isset($auditArrayStatus ['mastatus']) && (($auditArrayStatus ['mastatus'] == 'checked') || ($auditArrayStatus ['mastatus'] == 'checkno'))) {
  1033. echo json_encode(array('status' => FALSE, 'msg' => '该标段已审批完毕。'), JSON_UNESCAPED_UNICODE);
  1034. die();
  1035. }
  1036. $auditArray = $this->measureauditact->getRowInfo($this->params['tenderid'], $this->params['phaseno'], $this->params['userid']);
  1037. if (isset($auditArray['maid'])) {
  1038. $intMaxTimes = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno']);
  1039. if (isset($intMaxTimes['times'])) {
  1040. $iniTimes = $intMaxTimes['times'];
  1041. }
  1042. $this->measureauditact->setCheckno($auditArray['maid'], $auditcontent);
  1043. $this->numofperact->updateAuditStatus($this->params['tenderid'], $this->params['phaseno'], 'checkno', $iniTimes);
  1044. $fp = $this->upfile('upfile');
  1045. if (isset($fp[0]['filepath'])) {
  1046. // 解压缩文件等待以后直接使用
  1047. // TODO:根据校验码校验包的完整性
  1048. $localmd5HashString = hash_file("md5", Doo::conf()->SITE_PATH . $fp[0]['filepath']);
  1049. if ($localmd5HashString != trim($_POST['MD5_Zip'])) {
  1050. $status = array('status' => 'FALSE', 'msg' => '未通过期数数据上传失败,请重新上传');
  1051. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1052. die();
  1053. }
  1054. $res = $this->zip->open(Doo::conf()->SITE_PATH . $fp[0]['filepath']);
  1055. $extPath = pathinfo($fp[0]['filepath']);
  1056. $extPathdir = Doo::conf()->SITE_PATH . $extPath ['dirname'] . '/' . $extPath['filename'];
  1057. if ($res === TRUE) {
  1058. if (!$this->dir_create($extPathdir)) {
  1059. return FALSE;
  1060. }
  1061. $this->zip->extractTo($extPathdir);
  1062. $this->zip->close();
  1063. }
  1064. $numArray = $this->numofperact->getRow($this->params['tenderid'], $this->params['phaseno'], $iniTimes);
  1065. // 插入附件表之前要更新所有次标段期数的提交的数据状态为旧标志
  1066. $this->attfile->setOldfileFlag($this->params['tenderid'], $this->params['phaseno'], $iniTimes);
  1067. // 插入此次提交的文件路径数据并设置为新状态
  1068. $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);
  1069. // SMS Start
  1070. $TenderArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);
  1071. $userProArray = $this->profile->getProWithUid($TenderArray['uid']);
  1072. if (isset($userProArray) && ($userProArray['mobile'])) {
  1073. $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR4"]);
  1074. }
  1075. // SMS End
  1076. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  1077. die();
  1078. } else {
  1079. echo json_encode(array('status' => FALSE, 'msg' => '文件上传故障'), JSON_UNESCAPED_UNICODE);
  1080. die();
  1081. }
  1082. } else {
  1083. echo json_encode(array('status' => FALSE, 'msg' => '审批期数不存在'), JSON_UNESCAPED_UNICODE);
  1084. die();
  1085. }
  1086. } else {
  1087. echo json_encode(array('status' => FALSE, 'msg' => '审批未通过参数错误'), JSON_UNESCAPED_UNICODE);
  1088. die();
  1089. }
  1090. }
  1091. /**
  1092. * 创建未通过的新一期
  1093. *
  1094. */
  1095. function createNewAudit()
  1096. {
  1097. // 插入上次期数相关审批人员
  1098. // TODO:
  1099. // error_log(var_export($this->params, TRUE), 3, ' / opt / html / jiliang_customedProduct / data / ' . time());
  1100. // die;
  1101. if (isset($this->params['tenderid']) && isset($this->params['phaseno'])) {
  1102. $auditArray = $this->numofperact->getChecknoRow($this->params['tenderid'], $this->params['phaseno']);
  1103. if (isset($auditArray['currstatus']) && ($auditArray['currstatus'] == 'checkno')) {
  1104. $isCreate = false;
  1105. $auditUserArray = $this->measureauditact->getUserAuditLast($this->params['tenderid'], $this->params['phaseno']);
  1106. foreach ($auditUserArray as $key => $value) {
  1107. if ($value['mastatus'] != 'uncheck') {
  1108. $isCreate = true;
  1109. }
  1110. }
  1111. if ($auditUserArray && $isCreate) {
  1112. foreach ($auditUserArray as $key => $value) {
  1113. $this->measureauditact->insertMeasureAudit($value['pid'], $value['creatoruid'], $value['auditoruid'], $value['mpid'], $value['pmid'], $value['stid'], $value['numpname'], $status = 'uncheck', $value['last'], $auditArray['times'] + 1);
  1114. }
  1115. } else {
  1116. echo json_encode(array('status' => FALSE, 'msg' => '无效操作重复创建审批人'), JSON_UNESCAPED_UNICODE);
  1117. die();
  1118. }
  1119. //// $timesArray = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno']);
  1120. // $urlinfoArray = $this->attfile->getLastNewProfileUnlock2($this->params['tenderid'], $this->params['phaseno']);
  1121. // $proArray = $this->project->getRowByPid($urlinfoArray['pid']);
  1122. // $stArray = $this->contractact->getRowByStid($urlinfoArray['stid']);
  1123. // $MeasureArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);
  1124. // $downArray = NULL;
  1125. // $pathinfo = pathinfo($urlinfoArray['filepath']);
  1126. // if (isset($pathinfo['dirname']))
  1127. // $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']);
  1128. // echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downArray), JSON_UNESCAPED_UNICODE);
  1129. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  1130. die();
  1131. } else {
  1132. echo json_encode(array('status' => FALSE, 'msg' => '审批状态无效'), JSON_UNESCAPED_UNICODE);
  1133. die();
  1134. }
  1135. } else {
  1136. echo json_encode(array('status' => FALSE, 'msg' => '创建未通过的新一期参数错误'), JSON_UNESCAPED_UNICODE);
  1137. die();
  1138. }
  1139. }
  1140. /**
  1141. * 重做新一期获取原报上报文件
  1142. *
  1143. */
  1144. function getReportFile()
  1145. {
  1146. if (isset($this->params['tenderid']) && isset($this->params['phaseno'])) {
  1147. $auditArray = $this->numofperact->getChecknoRow($this->params['tenderid'], $this->params['phaseno']);
  1148. if (isset($auditArray['currstatus']) && ($auditArray['currstatus'] == 'checkno')) {
  1149. $timesArray = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno']);
  1150. $urlinfoArray = $this->attfile->getReportFile($this->params['tenderid'], $this->params['phaseno'], $timesArray['times']);
  1151. $proArray = $this->project->getRowByPid($urlinfoArray['pid']);
  1152. $stArray = $this->contractact->getRowByStid($urlinfoArray['stid']);
  1153. $MeasureArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);
  1154. $downArray = NULL;
  1155. $pathinfo = pathinfo($urlinfoArray['filepath']);
  1156. if (isset($pathinfo['dirname'])) {
  1157. $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']);
  1158. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downArray), JSON_UNESCAPED_UNICODE);
  1159. die();
  1160. } else {
  1161. echo json_encode(array('status' => FALSE, 'msg' => '上报文件不存在'), JSON_UNESCAPED_UNICODE);
  1162. die();
  1163. }
  1164. } else {
  1165. echo json_encode(array('status' => FALSE, 'msg' => '审批状态无效'), JSON_UNESCAPED_UNICODE);
  1166. die();
  1167. }
  1168. } else {
  1169. echo json_encode(array('status' => FALSE, 'msg' => '创建未通过的新一期参数错误'), JSON_UNESCAPED_UNICODE);
  1170. die();
  1171. }
  1172. }
  1173. public function getUserInfo()
  1174. {
  1175. if (isset($this->params['userid']) && ($this->params['userid'] > 0)) {
  1176. $proArray = $this->profile->getProWithUid($this->params['userid']);
  1177. if (isset($proArray['userid'])) {
  1178. $strAvatar = $this->auth->getAvatar($proArray['userid']);
  1179. echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('avatar' => $strAvatar, 'name' => $proArray['name'], 'jobs' => $proArray['jobs'], 'company' => $proArray['company'])), JSON_UNESCAPED_UNICODE);
  1180. die();
  1181. } else {
  1182. echo json_encode(array('status' => 'FALSE', 'msg' => '此用户不存在'), JSON_UNESCAPED_UNICODE);
  1183. die();
  1184. }
  1185. } else {
  1186. echo json_encode(array('status' => 'FALSE', 'msg' => '用户查询参数无效'), JSON_UNESCAPED_UNICODE);
  1187. die();
  1188. }
  1189. }
  1190. public function updateTenderName()
  1191. {
  1192. if (isset($this->params['BidID']) && isset($this->params['BidNewName'])) {
  1193. if ($this->actmeasure->updateName($this->params['BidID'], iconv('GBK', 'UTF - 8', $this->params['BidNewName']))) {
  1194. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  1195. die();
  1196. } else {
  1197. echo json_encode(array('status' => 'FALSE', 'msg' => '标段名称更新错误'), JSON_UNESCAPED_UNICODE);
  1198. die();
  1199. }
  1200. } else {
  1201. echo json_encode(array('status' => 'FALSE', 'msg' => '标段名称更新参数无效'), JSON_UNESCAPED_UNICODE);
  1202. die();
  1203. }
  1204. }
  1205. /**
  1206. * 清单附件上传,单文件上传
  1207. * @param int $tenderid 标段ID
  1208. * @param int $uid 上传人ID
  1209. * @param int $itemid 本地清单ID
  1210. */
  1211. public function uploadItemFile()
  1212. {
  1213. if (isset($this->params['tenderid']) && isset($this->params['uid'])) {
  1214. if (!isset($_FILES['upitem']) && !isset($_POST['itemid']) && !isset($_POST['category']) && !isset($_POST['phase'])) {
  1215. $this->msg(0, '上传参数错误');
  1216. }
  1217. $fileArray = $this->upItemFile('upitem')[0];
  1218. if (isset($fileArray['filepath'])) {
  1219. $pidArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);
  1220. $memoStr = iconv('GBK', 'UTF-8', $_POST['Memo']);
  1221. $pathinfo_dirname = pathinfo($fileArray['filepath'], PATHINFO_DIRNAME);
  1222. $filenameStr2 = iconv('GBK', 'UTF-8', $fileArray['filename']);
  1223. $url = $pathinfo_dirname . '/' . $filenameStr2;
  1224. setlocale(LC_ALL, 'zh_CN.UTF-8');
  1225. $fname = pathinfo($url);
  1226. $filenameStr = $fname['filename'];
  1227. $postArray = array('ownerid' => $this->params['uid'], 'pid' => $pidArray['pid'], 'pmid' => $this->params['tenderid'], 'filename' => $filenameStr, 'filesize' => $fileArray['filesize'], 'fileext' => $fileArray['fileext'], 'filepath' => $fileArray['filepath']);
  1228. $iaid = $this->itemfile->insertItemFileRecord($postArray);
  1229. if ($iaid > 1) {
  1230. $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);
  1231. if (($imnid = $this->itemMeasureNum->insert($itemMeasureNumArray)) > 0) {
  1232. $extPath = pathinfo($fileArray['filepath']);
  1233. $itemArray = array('onlineFileName' => $extPath['filename'] . '.' . $extPath['extension'], 'imnid' => $imnid, 'fileurl' => Doo::conf()->APP_URL . $fileArray['filepath']);
  1234. $status = array('status' => TRUE, 'msg' => '', 'iteminfo' => $itemArray);
  1235. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1236. die();
  1237. } else {
  1238. $this->msg(0, '附件上传失败,请重新上传.');
  1239. }
  1240. }
  1241. } else {
  1242. $this->msg(0, '附件上传失败,请重新上传');
  1243. }
  1244. } else {
  1245. $this->msg(0, '上传参数错误');
  1246. }
  1247. }
  1248. /**
  1249. * 获得清单附件列表
  1250. */
  1251. public function getItemFileList()
  1252. {
  1253. if (isset($this->params['tenderid'])) {
  1254. $itemfileArray = $this->itemMeasureNum->getItemMeasureNum($this->params['tenderid']);
  1255. foreach ($itemfileArray as $value) {
  1256. $profileArray = $this->profile->getProWithUid($value['ownerid']);
  1257. $attFileArray = $this->itemfile->getItemFile($value['iaid']);
  1258. if (isset($attFileArray) && $attFileArray && isset($profileArray) && $profileArray)
  1259. $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']);
  1260. }
  1261. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downArray), JSON_UNESCAPED_UNICODE);
  1262. die();
  1263. } else {
  1264. $this->msg(0, '获取附件列表参数错误');
  1265. }
  1266. }
  1267. /**
  1268. * 编辑清单附件描述 文件名?
  1269. */
  1270. public function updateItemFileDesc()
  1271. {
  1272. if (isset($this->params['fileid']) && isset($_POST['FileName']) && isset($_POST['Memo'])) {
  1273. // $memoStr = iconv('GB18030', 'UTF-8', $_POST['Memo']);
  1274. $memoStr = $_POST['Memo'];
  1275. // $filenameStr = iconv('GB18030', 'UTF-8', $_POST['FileName']);
  1276. $filenameStr = $_POST['FileName'];
  1277. $imnidArray = $this->itemMeasureNum->getRowData($this->params['fileid']);
  1278. // if ($this->itemMeasureNum->updateItemFields($this->params['fileid'], $memoStr) > 0) {
  1279. $this->itemMeasureNum->updateItemFields($this->params['fileid'], $memoStr);
  1280. $this->itemfile->updateItemFields($imnidArray['iaid'], $filenameStr);
  1281. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  1282. die();
  1283. // } else {
  1284. // echo json_encode(array('status' => 'FALSE', 'msg' => '附件更新接口参数错误'), JSON_UNESCAPED_UNICODE);
  1285. // die();
  1286. // }
  1287. } else {
  1288. $this->msg(0, '附件更新接口参数错误');
  1289. }
  1290. }
  1291. /**
  1292. * 删除清单附件
  1293. */
  1294. public function delItemFile()
  1295. {
  1296. if (isset($this->params['fileid'])) {
  1297. $this->itemMeasureNum->delItemFields($this->params['fileid']);
  1298. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  1299. die();
  1300. } else {
  1301. $this->msg(0, '关联删除接口参数错误');
  1302. }
  1303. }
  1304. /**
  1305. * @return attachment
  1306. */
  1307. public function getAttaFilesAll()
  1308. {
  1309. if (isset($this->params['tenderid'])) {
  1310. $itemfileArray = $this->itemfile->getFilesAll($this->params['tenderid']);
  1311. foreach ($itemfileArray as $value) {
  1312. // $profileArray = $this->profile->getProWithUid($value['ownerid']);
  1313. // $attFileArray = $this->itemfile->getItemFile($value['iaid']);
  1314. // if (isset($attFileArray) && $attFileArray && isset($profileArray) && $profileArray)
  1315. $filesArray[] = array('downurl' => Doo::conf()->APP_URL . $value['filepath'], 'filename' => $value['filename'] . '.' . $value['fileext'], 'fileext' => $value['fileext'], 'fileid' => $value['iaid']);
  1316. }
  1317. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $filesArray), JSON_UNESCAPED_UNICODE);
  1318. die();
  1319. } else {
  1320. $this->msg(0, '获取附件列表参数错误');
  1321. }
  1322. }
  1323. /**
  1324. * @return attachment
  1325. */
  1326. public function createAttWithTender()
  1327. {
  1328. if (isset($this->params['tenderid'])) {
  1329. $itemfileArray = $this->itemfile->getFilesAll($this->params['tenderid']);
  1330. foreach ($itemfileArray as $value) {
  1331. // $profileArray = $this->profile->getProWithUid($value['ownerid']);
  1332. // $attFileArray = $this->itemfile->getItemFile($value['iaid']);
  1333. // if (isset($attFileArray) && $attFileArray && isset($profileArray) && $profileArray)
  1334. $filesArray[] = array('downurl' => Doo::conf()->APP_URL . $value['filepath'], 'filename' => $value['filename'] . '.' . $value['fileext'], 'fileext' => $value['fileext'], 'fileid' => $value['iaid']);
  1335. }
  1336. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $filesArray), JSON_UNESCAPED_UNICODE);
  1337. die();
  1338. } else {
  1339. $this->msg(0, '获取附件列表参数错误');
  1340. }
  1341. }
  1342. /**
  1343. * 查询指定项目的指定期的全部审批意见。
  1344. * 标段ID,期号
  1345. */
  1346. public function getAuditOpinion()
  1347. {
  1348. if (isset($this->params['tenderid']) && isset($this->params['phaseno'])) {
  1349. $retval = $this->measureauditact->getAuditOpinion($this->params['tenderid'], $this->params['phaseno']);
  1350. $iterator = new ArrayIterator($retval);
  1351. if (iterator_count($iterator) > 0) {
  1352. foreach ($retval as $value) {
  1353. $proArray = $this->profile->getProWithUid($value['auditoruid']);
  1354. $auditcontent = !empty($value['auditcontent']) ? $value['auditcontent'] : '';
  1355. $uArray[] = array('realname' => $proArray['name'], 'jobs' => $proArray['jobs'], 'acontent' => $auditcontent);
  1356. }
  1357. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $uArray), JSON_UNESCAPED_UNICODE);
  1358. die();
  1359. } else {
  1360. echo json_encode(array('status' => 'FALSE', 'msg' => '查询指定项目的指定期的全部审批意见参数错误'), JSON_UNESCAPED_UNICODE);
  1361. die();
  1362. }
  1363. } else {
  1364. $this->msg(0, '查询指定项目的指定期的全部审批意见接口参数错误');
  1365. }
  1366. }
  1367. /**
  1368. * 。
  1369. * 标段ID,期号
  1370. */
  1371. private function __auditNotice($mobile, $text)
  1372. {
  1373. $smsSwitch = $this->aconfig->getOne(array('select' => 'smsSwitch', 'asArray' => TRUE))['smsSwitch'];
  1374. if ($smsSwitch > 0)
  1375. return $this->sms->sendSms($mobile, $text);
  1376. }
  1377. function upfile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  1378. {
  1379. return $this->att->uploadMut($fildname, $param);
  1380. }
  1381. function upItemFile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  1382. {
  1383. $this->att->setUploadDir();
  1384. return $this->att->uploadMut($fildname, $param);
  1385. }
  1386. /**
  1387. * 根据标段ID获取标段是否已经被删除的提示
  1388. * 标段ID
  1389. */
  1390. public function getCountPmid()
  1391. {
  1392. if (isset($this->params['tenderid'])) {
  1393. $isexist = $this->actmeasure->getCountPmid($this->params['tenderid']);
  1394. if ($isexist > 0) {
  1395. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => null), JSON_UNESCAPED_UNICODE);
  1396. die();
  1397. } else {
  1398. echo json_encode(array('status' => 'FALSE', 'msg' => '该项目[XXX]在云端已被删除,点击“确定”后,可手动删除该项目'), JSON_UNESCAPED_UNICODE);
  1399. die();
  1400. }
  1401. } else {
  1402. $this->msg(0, '获取标段是否存在参数错误');
  1403. }
  1404. }
  1405. function getFileupErrorNo()
  1406. {
  1407. return $this->att->error();
  1408. }
  1409. function Signout()
  1410. {
  1411. session_destroy();
  1412. }
  1413. function isLoggedIn()
  1414. {
  1415. return isset($_SESSION['user_id']);
  1416. }
  1417. function generateFormHash($salt)
  1418. {
  1419. $hash = md5(mt_rand(1, 1000000) . $salt);
  1420. $_SESSION['csrf_hash'] = $hash;
  1421. return $hash;
  1422. }
  1423. function isValidFormHash($hash)
  1424. {
  1425. return $_SESSION['csrf_hash'] === $hash;
  1426. }
  1427. /**
  1428. * 随机字符串函数
  1429. * @param $password 密码
  1430. * @param $random 随机数
  1431. */
  1432. function random($length, $chars = '0123456789')
  1433. {
  1434. $hash = '';
  1435. $max = strlen($chars) - 1;
  1436. for ($i = 0; $i < $length; $i++) {
  1437. $hash .= $chars[mt_rand(0, $max)];
  1438. }
  1439. return $hash;
  1440. }
  1441. /**
  1442. * 生成随机字符串
  1443. * @param string $lenth 长度
  1444. * @return string 字符串
  1445. */
  1446. function create_randomstr($lenth = 6)
  1447. {
  1448. return $this->random($lenth, '123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ');
  1449. }
  1450. function dir_create($path, $mode = 0777)
  1451. {
  1452. if (is_dir($path))
  1453. return TRUE;
  1454. $path = $this->dir_path($path);
  1455. $parent = dirname($path);
  1456. if (!is_dir($parent))
  1457. @mkdir($parent, 0777, true);
  1458. @mkdir($path, 0777, true);
  1459. return is_dir($path);
  1460. }
  1461. function dir_create2($path, $mode = 0777)
  1462. {
  1463. if (is_dir($path))
  1464. return TRUE;
  1465. $path = $this->dir_path($path);
  1466. $parent = dirname($path);
  1467. if (!is_dir($parent)){
  1468. @mkdir($parent, 0777);
  1469. @chmod($parent, 0777);
  1470. }
  1471. @mkdir($path, 0777);
  1472. @chmod($path, 0777);
  1473. return is_dir($path);
  1474. }
  1475. function dir_path($path)
  1476. {
  1477. $path = str_replace('\\', '/', $path);
  1478. if (substr($path, -1) != '/')
  1479. $path = $path . '/';
  1480. return $path;
  1481. }
  1482. function msg($isTrue = 0, $msg = null, $retmsg = null)
  1483. {
  1484. if ($isTrue > 0) {
  1485. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  1486. die();
  1487. } else {
  1488. echo json_encode(array('status' => 'FALSE', 'msg' => $msg), JSON_UNESCAPED_UNICODE);
  1489. die();
  1490. }
  1491. }
  1492. // function checkVersion($version)
  1493. // {
  1494. // preg_match();
  1495. // }
  1496. //在线签署的接口
  1497. public function getSignCreate(){
  1498. // TODO:上报数据
  1499. if (!empty($_FILES['upspdf']['name']) && !empty($_FILES['upfile']['name']) && isset($_POST['project']) && isset($_POST['tender']) && isset($_POST['phaseno']) && isset($_POST['name']) && isset($_POST['ownuid']) && isset($_POST['widhei'])) {
  1500. //解压压缩包并把图片存到文件夹中
  1501. @$_POST['name'] = iconv('GBK', 'UTF-8', $_POST['name']);
  1502. $upfilename = pathinfo($_FILES['upfile']['name']);
  1503. if($upfilename['extension'] != 'zip'){
  1504. $status = array('status' => 'FALSE', 'msg' => '上传的文件格式有误');
  1505. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1506. die();
  1507. }
  1508. $res = $this->zip->open($_FILES['upfile']['tmp_name']);
  1509. if ($res === TRUE) {
  1510. $samesignname = $this->sign->getSignbyName($_POST['name']);
  1511. if(!empty($samesignname)){
  1512. $status = array('status' => 'FALSE', 'msg' => '存在同名报表');
  1513. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1514. die();
  1515. }
  1516. //添加到签署报表中
  1517. $intime = time();
  1518. $signid = $this->sign->insertSign($_POST['project'], $_POST['tender'], $_POST['phaseno'], $_POST['name'], $_POST['ownuid'],$intime,$_POST['widhei']);
  1519. $extPathdir = Doo::conf()->SITE_PATH . 'signs/' . $signid;
  1520. if ($res === TRUE) {
  1521. if (!$this->dir_create2($extPathdir)) {
  1522. $status = array('status' => 'FALSE', 'msg' => '期数数据上传失败');
  1523. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1524. die();
  1525. }
  1526. $this->zip->extractTo($extPathdir);
  1527. $this->zip->close();
  1528. $fileanddir = $this->deepScanDir($extPathdir);
  1529. sort($fileanddir['file2']);
  1530. $sum = 0;
  1531. foreach($fileanddir['file2'] as $k =>$v){
  1532. $sum++;
  1533. $signatt = new signn();
  1534. $path = 'signs/'.$signid.'/' . $v . '.jpg';
  1535. @chmod(Doo::conf()->SITE_PATH.$path,0777);
  1536. $signatt->insertSignAtt($signid,$v,$path);
  1537. // $this->compressed_image(Doo::conf()->SITE_PATH.$path,Doo::conf()->SITE_PATH.$path);
  1538. }
  1539. $sign2 = new signn();
  1540. $sign2->updateSignPageNum($signid,$sum);
  1541. $upspdfname = pathinfo($_FILES['upspdf']['name']);
  1542. if($upspdfname['extension'] != 'pdf'){
  1543. $status = array('status' => 'FALSE', 'msg' => '上传的文件格式有误');
  1544. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1545. die();
  1546. }
  1547. //上传pdf文件
  1548. if(!empty($_FILES["upspdf"]['name'])){
  1549. $pdf_name = $intime.'.pdf';
  1550. $upload_pdf = $extPathdir.'/'.$pdf_name;
  1551. $k = move_uploaded_file($_FILES["upspdf"]["tmp_name"], $upload_pdf);
  1552. if($k){
  1553. $status = array('status' => 'TRUE');
  1554. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1555. die();
  1556. }
  1557. }
  1558. }
  1559. }
  1560. $status = array('status' => 'FALSE', 'msg' => '文件上传失败,请重试');
  1561. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1562. die();
  1563. } else {
  1564. $status = array('status' => 'FALSE', 'msg' => '上传参数错误');
  1565. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1566. die();
  1567. }
  1568. }
  1569. public function getSignList(){
  1570. $wheresql = ' 1';
  1571. if(isset($_POST['project']) && is_numeric($_POST['project'])){
  1572. $wheresql .= ' and project='.$_POST['project'];
  1573. }
  1574. if(isset($_POST['tender']) && is_numeric($_POST['tender'])) {
  1575. $wheresql .= ' and tender='.$_POST['tender'];
  1576. }
  1577. if(isset($_POST['phaseno']) && is_numeric($_POST['phaseno'])){
  1578. $wheresql .= ' and phaseno='.$_POST['phaseno'];
  1579. }
  1580. $signlist = $this->sign->getSignListbyClient($wheresql);
  1581. if(!empty($signlist)){
  1582. $interMediatelist = array();
  1583. foreach($signlist as $k => $v){
  1584. $interMediatelist[$k]['signid'] = $v['sid'];
  1585. $interMediatelist[$k]['md5_sign'] = md5(Doo::conf()->SITE_PATH . 'signs/' . $v['sid']);
  1586. $interMediatelist[$k]['project'] = $v['project'];
  1587. $interMediatelist[$k]['tender'] = $v['tender'];
  1588. $interMediatelist[$k]['phaseno'] = $v['phaseno'];
  1589. $interMediatelist[$k]['name'] = $v['name'];
  1590. $interMediatelist[$k]['ownuid'] = $v['ownuid'];
  1591. $interMediatelist[$k]['status'] = $v['isinter'];
  1592. $interMediatelist[$k]['currnum'] = $v['pagenum'];
  1593. $interMediatelist[$k]['totalnum'] = $v['internum'];
  1594. }
  1595. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $interMediatelist), JSON_UNESCAPED_UNICODE);
  1596. die();
  1597. }else{
  1598. $status = array('status' => TRUE, 'msg' => '当前没有签署报表','info' => '');
  1599. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1600. die();
  1601. }
  1602. }
  1603. //中间计量表的接口
  1604. public function getInterMediateCreate(){
  1605. // TODO:上报数据
  1606. if (isset($_POST['project']) && isset($_POST['tender']) && isset($_POST['phaseno']) && isset($_POST['name']) && isset($_POST['ownuid']) && isset($_POST['widhei']) && isset($_POST['totalnum'])) {
  1607. //解压压缩包并把图片存到文件夹中
  1608. @$_POST['name'] = iconv('GBK', 'UTF-8', $_POST['name']);
  1609. $samesignname = $this->sign->getSignbyName($_POST['tender'], $_POST['phaseno'], $_POST['name']);
  1610. if(!empty($samesignname)){
  1611. $status = array('status' => 'FALSE', 'msg' => '存在同名中间计量表');
  1612. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1613. die();
  1614. }
  1615. //添加到签署报表中
  1616. $intime = time();
  1617. $signid = $this->sign->insertSign($_POST['project'], $_POST['tender'], $_POST['phaseno'], $_POST['name'], $_POST['ownuid'],$intime,$_POST['widhei'],1,$_POST['totalnum']);
  1618. $extPathdir = Doo::conf()->SITE_PATH . 'signs/' . $signid;
  1619. if (!$this->dir_create2($extPathdir)) {
  1620. $status = array('status' => 'FALSE', 'msg' => '文件夹创建失败');
  1621. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1622. die();
  1623. }
  1624. $status = array('status' => 'TRUE','msg' => '', 'info' => array('signid' => $signid, 'md5_sign' => md5($extPathdir)));
  1625. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1626. die();
  1627. } else {
  1628. $status = array('status' => 'FALSE', 'msg' => '上传参数错误');
  1629. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1630. die();
  1631. }
  1632. }
  1633. public function getInterMediateUpload(){
  1634. if(isset($_POST['signid']) && isset($_POST['md5_sign']) && !empty($_FILES['imediate']['name'])){
  1635. $extPathdir = Doo::conf()->SITE_PATH . 'signs/' . $_POST['signid'];
  1636. if($_POST['md5_sign'] != md5($extPathdir)){
  1637. $status = array('status' => 'FALSE', 'msg' => '上传的图表不对应');
  1638. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1639. die();
  1640. }
  1641. $path = $extPathdir .'/' . $_FILES['imediate']['name'];
  1642. @chmod(Doo::conf()->SITE_PATH.$path,0777);
  1643. $k = move_uploaded_file($_FILES['imediate']["tmp_name"], $path);
  1644. if($k){
  1645. $signatt = new signn();
  1646. $result = $signatt->insertSignAtt($_POST['signid'],basename($_FILES['imediate']['name'],".jpg"),'signs/' . $_POST['signid'].'/'.$_FILES['imediate']['name']);
  1647. if(!empty($result)){
  1648. $sign2 = new signn();
  1649. $signArray = $sign2->getOneSignbysid($_POST['signid']);
  1650. $sign2->updateSignPageNum($_POST['signid'],$signArray['pagenum']+1);
  1651. if($signArray['pagenum']+1 == $signArray['internum']){
  1652. $sign2->updateInterMediateStatus($_POST['signid'],2);
  1653. }
  1654. $status = array('status' => 'TRUE');
  1655. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1656. die();
  1657. }else{
  1658. $status = array('status' => 'FALSE', 'msg' => '图片保存出错');
  1659. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1660. die();
  1661. }
  1662. }else{
  1663. $status = array('status' => 'FALSE', 'msg' => '上传图片失败');
  1664. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1665. die();
  1666. }
  1667. }else{
  1668. $status = array('status' => 'FALSE', 'msg' => '上传参数错误');
  1669. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1670. die();
  1671. }
  1672. }
  1673. public function getInterMediateList(){
  1674. $wheresql = 'isinter!=0';
  1675. if(isset($_POST['project']) && is_numeric($_POST['project'])){
  1676. $wheresql .= ' and project='.$_POST['project'];
  1677. }
  1678. if(isset($_POST['tender']) && is_numeric($_POST['tender'])) {
  1679. $wheresql .= ' and tender='.$_POST['tender'];
  1680. }
  1681. if(isset($_POST['phaseno']) && is_numeric($_POST['phaseno'])){
  1682. $wheresql .= ' and phaseno='.$_POST['phaseno'];
  1683. }
  1684. $signlist = $this->sign->getSignListbyClient($wheresql);
  1685. if(!empty($signlist)){
  1686. $interMediatelist = array();
  1687. foreach($signlist as $k => $v){
  1688. $interMediatelist[$k]['signid'] = $v['sid'];
  1689. $interMediatelist[$k]['md5_sign'] = md5(Doo::conf()->SITE_PATH . 'signs/' . $v['sid']);
  1690. $interMediatelist[$k]['phaseno'] = $v['phaseno'];
  1691. $interMediatelist[$k]['name'] = $v['name'];
  1692. $interMediatelist[$k]['ownuid'] = $v['ownuid'];
  1693. $interMediatelist[$k]['status'] = $v['isinter'];
  1694. $interMediatelist[$k]['currnum'] = $v['pagenum'];
  1695. $interMediatelist[$k]['totalnum'] = $v['internum'];
  1696. }
  1697. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $interMediatelist), JSON_UNESCAPED_UNICODE);
  1698. die();
  1699. }else{
  1700. $status = array('status' => TRUE, 'msg' => '当前没有中间计量表','info' => '');
  1701. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1702. die();
  1703. }
  1704. }
  1705. // public function testzip(){
  1706. // $this->render('testzip', $this->data);
  1707. // }
  1708. function deepScanDir($dir) {
  1709. $fileArr = array ();
  1710. $fileArr2 = array ();
  1711. $dirArr = array ();
  1712. $dir = rtrim($dir, '//');
  1713. if (is_dir($dir)) {
  1714. $dirHandle = opendir($dir);
  1715. while (false !== ($fileName = readdir($dirHandle))) {
  1716. $subFile = $dir . DIRECTORY_SEPARATOR . $fileName;
  1717. if (is_file($subFile)) {
  1718. $fileArr[] = $subFile;
  1719. $fileArr2[] = basename($subFile,'.jpg');
  1720. }
  1721. elseif (is_dir($subFile) && str_replace('.', '', $fileName) != '') {
  1722. $dirArr[] = $subFile;
  1723. $arr = $this->deepScanDir($subFile);
  1724. $dirArr = array_merge($dirArr, $arr['dir']);
  1725. $fileArr = array_merge($fileArr, $arr['file']);
  1726. $fileArr2 = array_merge($fileArr2, $arr['file2']);
  1727. }
  1728. }
  1729. closedir($dirHandle);
  1730. }
  1731. return array (
  1732. 'dir' => $dirArr,
  1733. 'file' => $fileArr,
  1734. 'file2' => $fileArr2
  1735. );
  1736. }
  1737. /**
  1738. * desription 判断是否gif动画
  1739. * @param sting $image_file图片路径
  1740. * @return boolean t 是 f 否
  1741. */
  1742. function check_gifcartoon($image_file){
  1743. $fp = fopen($image_file,'rb');
  1744. $image_head = fread($fp,1024);
  1745. fclose($fp);
  1746. return preg_match("/".chr(0x21).chr(0xff).chr(0x0b).'NETSCAPE2.0'."/",$image_head)?false:true;
  1747. }
  1748. /**
  1749. * desription 压缩图片
  1750. * @param sting $imgsrc 图片路径
  1751. * @param string $imgdst 压缩后保存路径
  1752. */
  1753. function compressed_image($imgsrc,$imgdst){
  1754. list($width,$height,$type)=getimagesize($imgsrc);
  1755. $new_width = $width;
  1756. $new_height = $height;
  1757. switch($type){
  1758. case 1:
  1759. $giftype=$this->check_gifcartoon($imgsrc);
  1760. if($giftype){
  1761. // header('Content-Type:image/gif');
  1762. $image_wp=imagecreatetruecolor($new_width, $new_height);
  1763. $image = imagecreatefromgif($imgsrc);
  1764. imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  1765. //75代表的是质量、压缩图片容量大小
  1766. imagejpeg($image_wp, $imgdst,100);
  1767. imagedestroy($image_wp);
  1768. }
  1769. break;
  1770. case 2:
  1771. // header('Content-Type:image/jpeg');
  1772. $image_wp=imagecreatetruecolor($new_width, $new_height);
  1773. $image = imagecreatefromjpeg($imgsrc);
  1774. imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  1775. //75代表的是质量、压缩图片容量大小
  1776. imagejpeg($image_wp, $imgdst,100);
  1777. imagedestroy($image_wp);
  1778. break;
  1779. case 3:
  1780. // header('Content-Type:image/png');
  1781. $image_wp=imagecreatetruecolor($new_width, $new_height);
  1782. $image = imagecreatefrompng($imgsrc);
  1783. imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  1784. //75代表的是质量、压缩图片容量大小
  1785. imagejpeg($image_wp, $imgdst,100);
  1786. imagedestroy($image_wp);
  1787. break;
  1788. case 6:
  1789. // header('Content-Type:image/x-ms-bmp');
  1790. $image_wp=imagecreatetruecolor($new_width, $new_height);
  1791. $image = $this->imagecreatefrombmp($imgsrc);
  1792. imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  1793. //75代表的是质量、压缩图片容量大小
  1794. imagejpeg($image_wp, $imgdst,100);
  1795. imagedestroy($image_wp);
  1796. break;
  1797. }
  1798. }
  1799. //bmp 转jpg
  1800. function imagecreatefrombmp( $filename ){
  1801. if ( !$f1 = fopen( $filename, "rb" ) )
  1802. return FALSE;
  1803. $FILE = unpack( "vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread( $f1, 14 ) );
  1804. if ( $FILE['file_type'] != 19778 )
  1805. return FALSE;
  1806. $BMP = unpack( 'Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel' . '/Vcompression/Vsize_bitmap/Vhoriz_resolution' . '/Vvert_resolution/Vcolors_used/Vcolors_important', fread( $f1, 40 ) );
  1807. $BMP['colors'] = pow( 2, $BMP['bits_per_pixel'] );
  1808. if ( $BMP['size_bitmap'] == 0 )
  1809. $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset'];
  1810. $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel'] / 8;
  1811. $BMP['bytes_per_pixel2'] = ceil( $BMP['bytes_per_pixel'] );
  1812. $BMP['decal'] = ($BMP['width'] * $BMP['bytes_per_pixel'] / 4);
  1813. $BMP['decal'] -= floor( $BMP['width'] * $BMP['bytes_per_pixel'] / 4 );
  1814. $BMP['decal'] = 4 - (4 * $BMP['decal']);
  1815. if ( $BMP['decal'] == 4 )
  1816. $BMP['decal'] = 0;
  1817. $PALETTE = array();
  1818. if ( $BMP['colors'] < 16777216 ){
  1819. $PALETTE = unpack( 'V' . $BMP['colors'], fread( $f1, $BMP['colors'] * 4 ) );
  1820. }
  1821. $IMG = fread( $f1, $BMP['size_bitmap'] );
  1822. $VIDE = chr( 0 );
  1823. $res = imagecreatetruecolor( $BMP['width'], $BMP['height'] );
  1824. $P = 0;
  1825. $Y = $BMP['height'] - 1;
  1826. while( $Y >= 0 ){
  1827. $X = 0;
  1828. while( $X < $BMP['width'] ){
  1829. if ( $BMP['bits_per_pixel'] == 32 ){
  1830. $COLOR = unpack( "V", substr( $IMG, $P, 4 ) );
  1831. $B = ord(substr($IMG, $P,1));
  1832. $G = ord(substr($IMG, $P+1,1));
  1833. $R = ord(substr($IMG, $P+2,1));
  1834. $color = imagecolorexact( $res, $R, $G, $B );
  1835. if ( $color == -1 )
  1836. $color = imagecolorallocate( $res, $R, $G, $B );
  1837. $COLOR[0] = $R*256*256+$G*256+$B;
  1838. $COLOR[1] = $color;
  1839. }elseif ( $BMP['bits_per_pixel'] == 24 )
  1840. $COLOR = unpack( "V", substr( $IMG, $P, 3 ) . $VIDE );
  1841. elseif ( $BMP['bits_per_pixel'] == 16 ){
  1842. $COLOR = unpack( "n", substr( $IMG, $P, 2 ) );
  1843. $COLOR[1] = $PALETTE[$COLOR[1] + 1];
  1844. }elseif ( $BMP['bits_per_pixel'] == 8 ){
  1845. $COLOR = unpack( "n", $VIDE . substr( $IMG, $P, 1 ) );
  1846. $COLOR[1] = $PALETTE[$COLOR[1] + 1];
  1847. }elseif ( $BMP['bits_per_pixel'] == 4 ){
  1848. $COLOR = unpack( "n", $VIDE . substr( $IMG, floor( $P ), 1 ) );
  1849. if ( ($P * 2) % 2 == 0 )
  1850. $COLOR[1] = ($COLOR[1] >> 4);
  1851. else
  1852. $COLOR[1] = ($COLOR[1] & 0x0F);
  1853. $COLOR[1] = $PALETTE[$COLOR[1] + 1];
  1854. }elseif ( $BMP['bits_per_pixel'] == 1 ){
  1855. $COLOR = unpack( "n", $VIDE . substr( $IMG, floor( $P ), 1 ) );
  1856. if ( ($P * 8) % 8 == 0 )
  1857. $COLOR[1] = $COLOR[1] >> 7;
  1858. elseif ( ($P * 8) % 8 == 1 )
  1859. $COLOR[1] = ($COLOR[1] & 0x40) >> 6;
  1860. elseif ( ($P * 8) % 8 == 2 )
  1861. $COLOR[1] = ($COLOR[1] & 0x20) >> 5;
  1862. elseif ( ($P * 8) % 8 == 3 )
  1863. $COLOR[1] = ($COLOR[1] & 0x10) >> 4;
  1864. elseif ( ($P * 8) % 8 == 4 )
  1865. $COLOR[1] = ($COLOR[1] & 0x8) >> 3;
  1866. elseif ( ($P * 8) % 8 == 5 )
  1867. $COLOR[1] = ($COLOR[1] & 0x4) >> 2;
  1868. elseif ( ($P * 8) % 8 == 6 )
  1869. $COLOR[1] = ($COLOR[1] & 0x2) >> 1;
  1870. elseif ( ($P * 8) % 8 == 7 )
  1871. $COLOR[1] = ($COLOR[1] & 0x1);
  1872. $COLOR[1] = $PALETTE[$COLOR[1] + 1];
  1873. }else
  1874. return FALSE;
  1875. imagesetpixel( $res, $X, $Y, $COLOR[1] );
  1876. $X++;
  1877. $P += $BMP['bytes_per_pixel'];
  1878. }
  1879. $Y--;
  1880. $P += $BMP['decal'];
  1881. }
  1882. fclose( $f1 );
  1883. return $res;
  1884. }
  1885. /**
  1886. * 查询标段关注人信息列表
  1887. */
  1888. public function getConcernAuditList(){
  1889. if(isset($this->params['tenderid']) && is_numeric($this->params['tenderid'])){
  1890. $concernArray = $this->concern->getMeasureConcernList($this->params['tenderid']);
  1891. if(!empty($concernArray)){
  1892. $userArray = array();
  1893. foreach($concernArray as $k => $v){
  1894. $userArray[$k]['uid'] = $v['uid'];
  1895. $userArray[$k]['name'] = $this->auth->getName($v['uid']);
  1896. $userArray[$k]['uemail'] = $this->auth->getEmail($v['uid']);
  1897. }
  1898. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $userArray), JSON_UNESCAPED_UNICODE);
  1899. die();
  1900. }else{
  1901. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => null), JSON_UNESCAPED_UNICODE);
  1902. die();
  1903. }
  1904. } else {
  1905. echo json_encode(array('status' => 'FALSE', 'msg' => '标段参数无效'), JSON_UNESCAPED_UNICODE);
  1906. die();
  1907. }
  1908. }
  1909. /**
  1910. * 添加关注标段
  1911. */
  1912. public function addConcernAudit(){
  1913. if(isset($_POST['tenderid']) && is_numeric($_POST['tenderid']) && isset($_POST['uid']) && is_numeric($_POST['uid'])){
  1914. $tendermsg = $this->actmeasure->getRowByPmid($_POST['tenderid']);
  1915. if(!empty($tendermsg)){
  1916. $result = $this->concern->insertMeasureConcern($tendermsg['pid'], $tendermsg['stid'], $tendermsg['pmid'], $_POST['uid']);
  1917. if($result){
  1918. echo json_encode(array('status' => TRUE, 'msg' => '成功添加关注'), JSON_UNESCAPED_UNICODE);
  1919. die();
  1920. }else{
  1921. echo json_encode(array('status' => 'FALSE', 'msg' => '添加标段关注人失败'), JSON_UNESCAPED_UNICODE);
  1922. die();
  1923. }
  1924. }else{
  1925. echo json_encode(array('status' => 'FALSE', 'msg' => '标段不存在'), JSON_UNESCAPED_UNICODE);
  1926. die();
  1927. }
  1928. }else{
  1929. echo json_encode(array('status' => 'FALSE', 'msg' => '标段或关注人参数无效'), JSON_UNESCAPED_UNICODE);
  1930. die();
  1931. }
  1932. }
  1933. /**
  1934. * 取消关注标段
  1935. */
  1936. public function delConcernAudit(){
  1937. if(isset($_POST['tenderid']) && is_numeric($_POST['tenderid']) && isset($_POST['uid']) && is_numeric($_POST['uid'])){
  1938. $tendermsg = $this->actmeasure->getRowByPmid($_POST['tenderid']);
  1939. if(!empty($tendermsg)){
  1940. $result = $this->concern->delMeasureConcern($tendermsg['pmid'], $_POST['uid']);
  1941. echo json_encode(array('status' => TRUE, 'msg' => '成功取消关注'), JSON_UNESCAPED_UNICODE);
  1942. die();
  1943. }else{
  1944. echo json_encode(array('status' => 'FALSE', 'msg' => '标段不存在'), JSON_UNESCAPED_UNICODE);
  1945. die();
  1946. }
  1947. }else{
  1948. echo json_encode(array('status' => 'FALSE', 'msg' => '标段或关注人参数无效'), JSON_UNESCAPED_UNICODE);
  1949. die();
  1950. }
  1951. }
  1952. /**
  1953. * 软件生成报表开关
  1954. */
  1955. public function signSwitch(){
  1956. $reportSwitch = $this->aconfig->getOne(array('select' => 'reportswitch', 'asArray' => TRUE))['reportswitch'];
  1957. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $reportSwitch), JSON_UNESCAPED_UNICODE);
  1958. die();
  1959. }
  1960. /**
  1961. * 中间计量表添加草图功能开关
  1962. */
  1963. public function interMediateSwitch(){
  1964. $imediateswitch = $this->aconfig->getOne(array('select' => 'imediateswitch', 'asArray' => TRUE))['imediateswitch'];
  1965. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $imediateswitch), JSON_UNESCAPED_UNICODE);
  1966. die();
  1967. }
  1968. }
  1969. ?>