ClientController.php 118 KB

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