ClientController.php 85 KB

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