ClientController.php 117 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149
  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->getUserAudit($_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. $postArray = array('ownerid' => $this->params['uid'], 'pid' => $pidArray['pid'], 'pmid' => $this->params['tenderid'], 'filename' => $filenameStr, 'filesize' => $fileArray['filesize'], 'fileext' => $fileArray['fileext'], 'filepath' => $fileArray['filepath']);
  1233. $iaid = $this->itemfile->insertItemFileRecord($postArray);
  1234. if ($iaid > 1) {
  1235. $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);
  1236. if (($imnid = $this->itemMeasureNum->insert($itemMeasureNumArray)) > 0) {
  1237. $extPath = pathinfo($fileArray['filepath']);
  1238. $itemArray = array('onlineFileName' => $extPath['filename'] . '.' . $extPath['extension'], 'imnid' => $imnid, 'fileurl' => Doo::conf()->APP_URL . $fileArray['filepath']);
  1239. $status = array('status' => TRUE, 'msg' => '', 'iteminfo' => $itemArray);
  1240. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1241. die();
  1242. } else {
  1243. $this->msg(0, '附件上传失败,请重新上传.');
  1244. }
  1245. }
  1246. } else {
  1247. $this->msg(0, '附件上传失败,请重新上传');
  1248. }
  1249. } else {
  1250. $this->msg(0, '上传参数错误');
  1251. }
  1252. }
  1253. /**
  1254. * 获得清单附件列表
  1255. */
  1256. public function getItemFileList()
  1257. {
  1258. if (isset($this->params['tenderid'])) {
  1259. $itemfileArray = $this->itemMeasureNum->getItemMeasureNum($this->params['tenderid']);
  1260. foreach ($itemfileArray as $value) {
  1261. $profileArray = $this->profile->getProWithUid($value['ownerid']);
  1262. $attFileArray = $this->itemfile->getItemFile($value['iaid']);
  1263. if (isset($attFileArray) && $attFileArray && isset($profileArray) && $profileArray)
  1264. $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']);
  1265. }
  1266. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downArray), JSON_UNESCAPED_UNICODE);
  1267. die();
  1268. } else {
  1269. $this->msg(0, '获取附件列表参数错误');
  1270. }
  1271. }
  1272. /**
  1273. * 编辑清单附件描述 文件名?
  1274. */
  1275. public function updateItemFileDesc()
  1276. {
  1277. if (isset($this->params['fileid']) && isset($_POST['FileName']) && isset($_POST['Memo'])) {
  1278. // $memoStr = iconv('GB18030', 'UTF-8', $_POST['Memo']);
  1279. $memoStr = $_POST['Memo'];
  1280. // $filenameStr = iconv('GB18030', 'UTF-8', $_POST['FileName']);
  1281. $filenameStr = $_POST['FileName'];
  1282. $imnidArray = $this->itemMeasureNum->getRowData($this->params['fileid']);
  1283. // if ($this->itemMeasureNum->updateItemFields($this->params['fileid'], $memoStr) > 0) {
  1284. $this->itemMeasureNum->updateItemFields($this->params['fileid'], $memoStr);
  1285. $this->itemfile->updateItemFields($imnidArray['iaid'], $filenameStr);
  1286. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  1287. die();
  1288. // } else {
  1289. // echo json_encode(array('status' => 'FALSE', 'msg' => '附件更新接口参数错误'), JSON_UNESCAPED_UNICODE);
  1290. // die();
  1291. // }
  1292. } else {
  1293. $this->msg(0, '附件更新接口参数错误');
  1294. }
  1295. }
  1296. /**
  1297. * 删除清单附件
  1298. */
  1299. public function delItemFile()
  1300. {
  1301. if (isset($this->params['fileid'])) {
  1302. $this->itemMeasureNum->delItemFields($this->params['fileid']);
  1303. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  1304. die();
  1305. } else {
  1306. $this->msg(0, '关联删除接口参数错误');
  1307. }
  1308. }
  1309. /**
  1310. * @return attachment
  1311. */
  1312. public function getAttaFilesAll()
  1313. {
  1314. if (isset($this->params['tenderid'])) {
  1315. $itemfileArray = $this->itemfile->getFilesAll($this->params['tenderid']);
  1316. foreach ($itemfileArray as $value) {
  1317. // $profileArray = $this->profile->getProWithUid($value['ownerid']);
  1318. // $attFileArray = $this->itemfile->getItemFile($value['iaid']);
  1319. // if (isset($attFileArray) && $attFileArray && isset($profileArray) && $profileArray)
  1320. $filesArray[] = array('downurl' => Doo::conf()->APP_URL . $value['filepath'], 'filename' => $value['filename'] . '.' . $value['fileext'], 'fileext' => $value['fileext'], 'fileid' => $value['iaid']);
  1321. }
  1322. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $filesArray), JSON_UNESCAPED_UNICODE);
  1323. die();
  1324. } else {
  1325. $this->msg(0, '获取附件列表参数错误');
  1326. }
  1327. }
  1328. /**
  1329. * @return attachment
  1330. */
  1331. public function createAttWithTender()
  1332. {
  1333. if (isset($this->params['tenderid'])) {
  1334. $itemfileArray = $this->itemfile->getFilesAll($this->params['tenderid']);
  1335. foreach ($itemfileArray as $value) {
  1336. // $profileArray = $this->profile->getProWithUid($value['ownerid']);
  1337. // $attFileArray = $this->itemfile->getItemFile($value['iaid']);
  1338. // if (isset($attFileArray) && $attFileArray && isset($profileArray) && $profileArray)
  1339. $filesArray[] = array('downurl' => Doo::conf()->APP_URL . $value['filepath'], 'filename' => $value['filename'] . '.' . $value['fileext'], 'fileext' => $value['fileext'], 'fileid' => $value['iaid']);
  1340. }
  1341. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $filesArray), JSON_UNESCAPED_UNICODE);
  1342. die();
  1343. } else {
  1344. $this->msg(0, '获取附件列表参数错误');
  1345. }
  1346. }
  1347. /**
  1348. * 查询指定项目的指定期的全部审批意见。
  1349. * 标段ID,期号
  1350. */
  1351. public function getAuditOpinion()
  1352. {
  1353. if (isset($this->params['tenderid']) && isset($this->params['phaseno'])) {
  1354. $retval = $this->measureauditact->getAuditOpinion($this->params['tenderid'], $this->params['phaseno']);
  1355. $iterator = new ArrayIterator($retval);
  1356. if (iterator_count($iterator) > 0) {
  1357. foreach ($retval as $value) {
  1358. $proArray = $this->profile->getProWithUid($value['auditoruid']);
  1359. $auditcontent = !empty($value['auditcontent']) ? $value['auditcontent'] : '';
  1360. $uArray[] = array('realname' => $proArray['name'], 'jobs' => $proArray['jobs'], 'acontent' => $auditcontent);
  1361. }
  1362. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $uArray), JSON_UNESCAPED_UNICODE);
  1363. die();
  1364. } else {
  1365. echo json_encode(array('status' => 'FALSE', 'msg' => '查询指定项目的指定期的全部审批意见参数错误'), JSON_UNESCAPED_UNICODE);
  1366. die();
  1367. }
  1368. } else {
  1369. $this->msg(0, '查询指定项目的指定期的全部审批意见接口参数错误');
  1370. }
  1371. }
  1372. /**
  1373. * 。
  1374. * 标段ID,期号
  1375. */
  1376. private function __auditNotice($mobile, $text)
  1377. {
  1378. $smsSwitch = $this->aconfig->getOne(array('select' => 'smsSwitch', 'asArray' => TRUE))['smsSwitch'];
  1379. if ($smsSwitch > 0)
  1380. return $this->sms->sendSms($mobile, $text);
  1381. }
  1382. function upfile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  1383. {
  1384. return $this->att->uploadMut($fildname, $param);
  1385. }
  1386. function upItemFile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  1387. {
  1388. $this->att->setUploadDir();
  1389. return $this->att->uploadMut($fildname, $param);
  1390. }
  1391. /**
  1392. * 根据标段ID获取标段是否已经被删除的提示
  1393. * 标段ID
  1394. */
  1395. public function getCountPmid()
  1396. {
  1397. if (isset($this->params['tenderid'])) {
  1398. $isexist = $this->actmeasure->getCountPmid($this->params['tenderid']);
  1399. if ($isexist > 0) {
  1400. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => null), JSON_UNESCAPED_UNICODE);
  1401. die();
  1402. } else {
  1403. echo json_encode(array('status' => 'FALSE', 'msg' => '该项目[XXX]在云端已被删除,点击“确定”后,可手动删除该项目'), JSON_UNESCAPED_UNICODE);
  1404. die();
  1405. }
  1406. } else {
  1407. $this->msg(0, '获取标段是否存在参数错误');
  1408. }
  1409. }
  1410. function getFileupErrorNo()
  1411. {
  1412. return $this->att->error();
  1413. }
  1414. function Signout()
  1415. {
  1416. session_destroy();
  1417. }
  1418. function isLoggedIn()
  1419. {
  1420. return isset($_SESSION['user_id']);
  1421. }
  1422. function generateFormHash($salt)
  1423. {
  1424. $hash = md5(mt_rand(1, 1000000) . $salt);
  1425. $_SESSION['csrf_hash'] = $hash;
  1426. return $hash;
  1427. }
  1428. function isValidFormHash($hash)
  1429. {
  1430. return $_SESSION['csrf_hash'] === $hash;
  1431. }
  1432. /**
  1433. * 随机字符串函数
  1434. * @param $password 密码
  1435. * @param $random 随机数
  1436. */
  1437. function random($length, $chars = '0123456789')
  1438. {
  1439. $hash = '';
  1440. $max = strlen($chars) - 1;
  1441. for ($i = 0; $i < $length; $i++) {
  1442. $hash .= $chars[mt_rand(0, $max)];
  1443. }
  1444. return $hash;
  1445. }
  1446. /**
  1447. * 生成随机字符串
  1448. * @param string $lenth 长度
  1449. * @return string 字符串
  1450. */
  1451. function create_randomstr($lenth = 6)
  1452. {
  1453. return $this->random($lenth, '123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ');
  1454. }
  1455. function dir_create($path, $mode = 0777)
  1456. {
  1457. if (is_dir($path))
  1458. return TRUE;
  1459. $path = $this->dir_path($path);
  1460. $parent = dirname($path);
  1461. if (!is_dir($parent))
  1462. @mkdir($parent, 0777, true);
  1463. @mkdir($path, 0777, true);
  1464. return is_dir($path);
  1465. }
  1466. function dir_create2($path, $mode = 0777)
  1467. {
  1468. if (is_dir($path))
  1469. return TRUE;
  1470. $path = $this->dir_path($path);
  1471. $parent = dirname($path);
  1472. if (!is_dir($parent)){
  1473. @mkdir($parent, 0777);
  1474. @chmod($parent, 0777);
  1475. }
  1476. @mkdir($path, 0777);
  1477. @chmod($path, 0777);
  1478. return is_dir($path);
  1479. }
  1480. function dir_path($path)
  1481. {
  1482. $path = str_replace('\\', '/', $path);
  1483. if (substr($path, -1) != '/')
  1484. $path = $path . '/';
  1485. return $path;
  1486. }
  1487. function msg($isTrue = 0, $msg = null, $retmsg = null)
  1488. {
  1489. if ($isTrue > 0) {
  1490. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  1491. die();
  1492. } else {
  1493. echo json_encode(array('status' => 'FALSE', 'msg' => $msg), JSON_UNESCAPED_UNICODE);
  1494. die();
  1495. }
  1496. }
  1497. // function checkVersion($version)
  1498. // {
  1499. // preg_match();
  1500. // }
  1501. //在线签署的接口
  1502. public function getSignCreate(){
  1503. // TODO:上报数据
  1504. 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'])) {
  1505. //解压压缩包并把图片存到文件夹中
  1506. @$_POST['name'] = iconv('GBK', 'UTF-8', $_POST['name']);
  1507. $upfilename = pathinfo($_FILES['upfile']['name']);
  1508. if($upfilename['extension'] != 'zip'){
  1509. $status = array('status' => 'FALSE', 'msg' => '上传的文件格式有误');
  1510. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1511. die();
  1512. }
  1513. $res = $this->zip->open($_FILES['upfile']['tmp_name']);
  1514. if ($res === TRUE) {
  1515. $samesignname = $this->sign->getSignbyName($_POST['name']);
  1516. if(!empty($samesignname)){
  1517. $status = array('status' => 'FALSE', 'msg' => '存在同名报表');
  1518. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1519. die();
  1520. }
  1521. //添加到签署报表中
  1522. $intime = time();
  1523. $signid = $this->sign->insertSign($_POST['project'], $_POST['tender'], $_POST['phaseno'], $_POST['name'], $_POST['ownuid'],$intime,$_POST['widhei']);
  1524. $extPathdir = Doo::conf()->SITE_PATH . 'signs/' . $signid;
  1525. if ($res === TRUE) {
  1526. if (!$this->dir_create2($extPathdir)) {
  1527. $status = array('status' => 'FALSE', 'msg' => '期数数据上传失败');
  1528. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1529. die();
  1530. }
  1531. $this->zip->extractTo($extPathdir);
  1532. $this->zip->close();
  1533. $fileanddir = $this->deepScanDir($extPathdir);
  1534. sort($fileanddir['file2']);
  1535. $sum = 0;
  1536. foreach($fileanddir['file2'] as $k =>$v){
  1537. $sum++;
  1538. $signatt = new signn();
  1539. $path = 'signs/'.$signid.'/' . $v . '.jpg';
  1540. @chmod(Doo::conf()->SITE_PATH.$path,0777);
  1541. $signatt->insertSignAtt($signid,$v,$path);
  1542. // $this->compressed_image(Doo::conf()->SITE_PATH.$path,Doo::conf()->SITE_PATH.$path);
  1543. }
  1544. $sign2 = new signn();
  1545. $sign2->updateSignPageNum($signid,$sum);
  1546. $upspdfname = pathinfo($_FILES['upspdf']['name']);
  1547. if($upspdfname['extension'] != 'pdf'){
  1548. $status = array('status' => 'FALSE', 'msg' => '上传的文件格式有误');
  1549. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1550. die();
  1551. }
  1552. //上传pdf文件
  1553. if(!empty($_FILES["upspdf"]['name'])){
  1554. $pdf_name = $intime.'.pdf';
  1555. $upload_pdf = $extPathdir.'/'.$pdf_name;
  1556. $k = move_uploaded_file($_FILES["upspdf"]["tmp_name"], $upload_pdf);
  1557. if($k){
  1558. $status = array('status' => 'TRUE');
  1559. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1560. die();
  1561. }
  1562. }
  1563. }
  1564. }
  1565. $status = array('status' => 'FALSE', 'msg' => '文件上传失败,请重试');
  1566. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1567. die();
  1568. } else {
  1569. $status = array('status' => 'FALSE', 'msg' => '上传参数错误');
  1570. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1571. die();
  1572. }
  1573. }
  1574. public function getSignList(){
  1575. $wheresql = ' 1';
  1576. if(isset($_POST['project']) && is_numeric($_POST['project'])){
  1577. $wheresql .= ' and project='.$_POST['project'];
  1578. }
  1579. if(isset($_POST['tender']) && is_numeric($_POST['tender'])) {
  1580. $wheresql .= ' and tender='.$_POST['tender'];
  1581. }
  1582. if(isset($_POST['phaseno']) && is_numeric($_POST['phaseno'])){
  1583. $wheresql .= ' and phaseno='.$_POST['phaseno'];
  1584. }
  1585. $signlist = $this->sign->getSignListbyClient($wheresql);
  1586. if(!empty($signlist)){
  1587. $interMediatelist = array();
  1588. foreach($signlist as $k => $v){
  1589. $interMediatelist[$k]['signid'] = $v['sid'];
  1590. $interMediatelist[$k]['md5_sign'] = md5(Doo::conf()->SITE_PATH . 'signs/' . $v['sid']);
  1591. $interMediatelist[$k]['project'] = $v['project'];
  1592. $interMediatelist[$k]['tender'] = $v['tender'];
  1593. $interMediatelist[$k]['phaseno'] = $v['phaseno'];
  1594. $interMediatelist[$k]['name'] = $v['name'];
  1595. $interMediatelist[$k]['ownuid'] = $v['ownuid'];
  1596. $interMediatelist[$k]['status'] = $v['isinter'];
  1597. $interMediatelist[$k]['currnum'] = $v['pagenum'];
  1598. $interMediatelist[$k]['totalnum'] = $v['internum'];
  1599. }
  1600. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $interMediatelist), JSON_UNESCAPED_UNICODE);
  1601. die();
  1602. }else{
  1603. $status = array('status' => TRUE, 'msg' => '当前没有签署报表','info' => '');
  1604. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1605. die();
  1606. }
  1607. }
  1608. //中间计量表的接口
  1609. public function getInterMediateCreate(){
  1610. // TODO:上报数据
  1611. if (isset($_POST['project']) && isset($_POST['tender']) && isset($_POST['phaseno']) && isset($_POST['name']) && isset($_POST['ownuid']) && isset($_POST['widhei']) && isset($_POST['totalnum'])) {
  1612. //解压压缩包并把图片存到文件夹中
  1613. @$_POST['name'] = iconv('GBK', 'UTF-8', $_POST['name']);
  1614. $samesignname = $this->sign->getSignbyName($_POST['tender'], $_POST['phaseno'], $_POST['name']);
  1615. if(!empty($samesignname)){
  1616. $status = array('status' => 'FALSE', 'msg' => '存在同名中间计量表');
  1617. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1618. die();
  1619. }
  1620. //添加到签署报表中
  1621. $intime = time();
  1622. $signid = $this->sign->insertSign($_POST['project'], $_POST['tender'], $_POST['phaseno'], $_POST['name'], $_POST['ownuid'],$intime,$_POST['widhei'],1,$_POST['totalnum']);
  1623. $extPathdir = Doo::conf()->SITE_PATH . 'signs/' . $signid;
  1624. if (!$this->dir_create2($extPathdir)) {
  1625. $status = array('status' => 'FALSE', 'msg' => '文件夹创建失败');
  1626. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1627. die();
  1628. }
  1629. $status = array('status' => 'TRUE','msg' => '', 'info' => array('signid' => $signid, 'md5_sign' => md5($extPathdir)));
  1630. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1631. die();
  1632. } else {
  1633. $status = array('status' => 'FALSE', 'msg' => '上传参数错误');
  1634. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1635. die();
  1636. }
  1637. }
  1638. public function getInterMediateUpload(){
  1639. if(isset($_POST['signid']) && isset($_POST['md5_sign']) && !empty($_FILES['imediate']['name'])){
  1640. $extPathdir = Doo::conf()->SITE_PATH . 'signs/' . $_POST['signid'];
  1641. if($_POST['md5_sign'] != md5($extPathdir)){
  1642. $status = array('status' => 'FALSE', 'msg' => '上传的图表不对应');
  1643. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1644. die();
  1645. }
  1646. $path = $extPathdir .'/' . $_FILES['imediate']['name'];
  1647. @chmod(Doo::conf()->SITE_PATH.$path,0777);
  1648. $k = move_uploaded_file($_FILES['imediate']["tmp_name"], $path);
  1649. if($k){
  1650. $signatt = new signn();
  1651. $result = $signatt->insertSignAtt($_POST['signid'],basename($_FILES['imediate']['name'],".jpg"),'signs/' . $_POST['signid'].'/'.$_FILES['imediate']['name']);
  1652. if(!empty($result)){
  1653. $sign2 = new signn();
  1654. $signArray = $sign2->getOneSignbysid($_POST['signid']);
  1655. $sign2->updateSignPageNum($_POST['signid'],$signArray['pagenum']+1);
  1656. if($signArray['pagenum']+1 == $signArray['internum']){
  1657. $sign2->updateInterMediateStatus($_POST['signid'],2);
  1658. }
  1659. $status = array('status' => 'TRUE');
  1660. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1661. die();
  1662. }else{
  1663. $status = array('status' => 'FALSE', 'msg' => '图片保存出错');
  1664. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1665. die();
  1666. }
  1667. }else{
  1668. $status = array('status' => 'FALSE', 'msg' => '上传图片失败');
  1669. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1670. die();
  1671. }
  1672. }else{
  1673. $status = array('status' => 'FALSE', 'msg' => '上传参数错误');
  1674. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1675. die();
  1676. }
  1677. }
  1678. public function getInterMediateList(){
  1679. $wheresql = 'isinter!=0';
  1680. if(isset($_POST['project']) && is_numeric($_POST['project'])){
  1681. $wheresql .= ' and project='.$_POST['project'];
  1682. }
  1683. if(isset($_POST['tender']) && is_numeric($_POST['tender'])) {
  1684. $wheresql .= ' and tender='.$_POST['tender'];
  1685. }
  1686. if(isset($_POST['phaseno']) && is_numeric($_POST['phaseno'])){
  1687. $wheresql .= ' and phaseno='.$_POST['phaseno'];
  1688. }
  1689. $signlist = $this->sign->getSignListbyClient($wheresql);
  1690. if(!empty($signlist)){
  1691. $interMediatelist = array();
  1692. foreach($signlist as $k => $v){
  1693. $interMediatelist[$k]['signid'] = $v['sid'];
  1694. $interMediatelist[$k]['md5_sign'] = md5(Doo::conf()->SITE_PATH . 'signs/' . $v['sid']);
  1695. $interMediatelist[$k]['phaseno'] = $v['phaseno'];
  1696. $interMediatelist[$k]['name'] = $v['name'];
  1697. $interMediatelist[$k]['ownuid'] = $v['ownuid'];
  1698. $interMediatelist[$k]['status'] = $v['isinter'];
  1699. $interMediatelist[$k]['currnum'] = $v['pagenum'];
  1700. $interMediatelist[$k]['totalnum'] = $v['internum'];
  1701. }
  1702. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $interMediatelist), JSON_UNESCAPED_UNICODE);
  1703. die();
  1704. }else{
  1705. $status = array('status' => TRUE, 'msg' => '当前没有中间计量表','info' => '');
  1706. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  1707. die();
  1708. }
  1709. }
  1710. // public function testzip(){
  1711. // $this->render('testzip', $this->data);
  1712. // }
  1713. function deepScanDir($dir) {
  1714. $fileArr = array ();
  1715. $fileArr2 = array ();
  1716. $dirArr = array ();
  1717. $dir = rtrim($dir, '//');
  1718. if (is_dir($dir)) {
  1719. $dirHandle = opendir($dir);
  1720. while (false !== ($fileName = readdir($dirHandle))) {
  1721. $subFile = $dir . DIRECTORY_SEPARATOR . $fileName;
  1722. if (is_file($subFile)) {
  1723. $fileArr[] = $subFile;
  1724. $fileArr2[] = basename($subFile,'.jpg');
  1725. }
  1726. elseif (is_dir($subFile) && str_replace('.', '', $fileName) != '') {
  1727. $dirArr[] = $subFile;
  1728. $arr = $this->deepScanDir($subFile);
  1729. $dirArr = array_merge($dirArr, $arr['dir']);
  1730. $fileArr = array_merge($fileArr, $arr['file']);
  1731. $fileArr2 = array_merge($fileArr2, $arr['file2']);
  1732. }
  1733. }
  1734. closedir($dirHandle);
  1735. }
  1736. return array (
  1737. 'dir' => $dirArr,
  1738. 'file' => $fileArr,
  1739. 'file2' => $fileArr2
  1740. );
  1741. }
  1742. /**
  1743. * desription 判断是否gif动画
  1744. * @param sting $image_file图片路径
  1745. * @return boolean t 是 f 否
  1746. */
  1747. function check_gifcartoon($image_file){
  1748. $fp = fopen($image_file,'rb');
  1749. $image_head = fread($fp,1024);
  1750. fclose($fp);
  1751. return preg_match("/".chr(0x21).chr(0xff).chr(0x0b).'NETSCAPE2.0'."/",$image_head)?false:true;
  1752. }
  1753. /**
  1754. * desription 压缩图片
  1755. * @param sting $imgsrc 图片路径
  1756. * @param string $imgdst 压缩后保存路径
  1757. */
  1758. function compressed_image($imgsrc,$imgdst){
  1759. list($width,$height,$type)=getimagesize($imgsrc);
  1760. $new_width = $width;
  1761. $new_height = $height;
  1762. switch($type){
  1763. case 1:
  1764. $giftype=$this->check_gifcartoon($imgsrc);
  1765. if($giftype){
  1766. // header('Content-Type:image/gif');
  1767. $image_wp=imagecreatetruecolor($new_width, $new_height);
  1768. $image = imagecreatefromgif($imgsrc);
  1769. imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  1770. //75代表的是质量、压缩图片容量大小
  1771. imagejpeg($image_wp, $imgdst,100);
  1772. imagedestroy($image_wp);
  1773. }
  1774. break;
  1775. case 2:
  1776. // header('Content-Type:image/jpeg');
  1777. $image_wp=imagecreatetruecolor($new_width, $new_height);
  1778. $image = imagecreatefromjpeg($imgsrc);
  1779. imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  1780. //75代表的是质量、压缩图片容量大小
  1781. imagejpeg($image_wp, $imgdst,100);
  1782. imagedestroy($image_wp);
  1783. break;
  1784. case 3:
  1785. // header('Content-Type:image/png');
  1786. $image_wp=imagecreatetruecolor($new_width, $new_height);
  1787. $image = imagecreatefrompng($imgsrc);
  1788. imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  1789. //75代表的是质量、压缩图片容量大小
  1790. imagejpeg($image_wp, $imgdst,100);
  1791. imagedestroy($image_wp);
  1792. break;
  1793. case 6:
  1794. // header('Content-Type:image/x-ms-bmp');
  1795. $image_wp=imagecreatetruecolor($new_width, $new_height);
  1796. $image = $this->imagecreatefrombmp($imgsrc);
  1797. imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  1798. //75代表的是质量、压缩图片容量大小
  1799. imagejpeg($image_wp, $imgdst,100);
  1800. imagedestroy($image_wp);
  1801. break;
  1802. }
  1803. }
  1804. //bmp 转jpg
  1805. function imagecreatefrombmp( $filename ){
  1806. if ( !$f1 = fopen( $filename, "rb" ) )
  1807. return FALSE;
  1808. $FILE = unpack( "vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread( $f1, 14 ) );
  1809. if ( $FILE['file_type'] != 19778 )
  1810. return FALSE;
  1811. $BMP = unpack( 'Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel' . '/Vcompression/Vsize_bitmap/Vhoriz_resolution' . '/Vvert_resolution/Vcolors_used/Vcolors_important', fread( $f1, 40 ) );
  1812. $BMP['colors'] = pow( 2, $BMP['bits_per_pixel'] );
  1813. if ( $BMP['size_bitmap'] == 0 )
  1814. $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset'];
  1815. $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel'] / 8;
  1816. $BMP['bytes_per_pixel2'] = ceil( $BMP['bytes_per_pixel'] );
  1817. $BMP['decal'] = ($BMP['width'] * $BMP['bytes_per_pixel'] / 4);
  1818. $BMP['decal'] -= floor( $BMP['width'] * $BMP['bytes_per_pixel'] / 4 );
  1819. $BMP['decal'] = 4 - (4 * $BMP['decal']);
  1820. if ( $BMP['decal'] == 4 )
  1821. $BMP['decal'] = 0;
  1822. $PALETTE = array();
  1823. if ( $BMP['colors'] < 16777216 ){
  1824. $PALETTE = unpack( 'V' . $BMP['colors'], fread( $f1, $BMP['colors'] * 4 ) );
  1825. }
  1826. $IMG = fread( $f1, $BMP['size_bitmap'] );
  1827. $VIDE = chr( 0 );
  1828. $res = imagecreatetruecolor( $BMP['width'], $BMP['height'] );
  1829. $P = 0;
  1830. $Y = $BMP['height'] - 1;
  1831. while( $Y >= 0 ){
  1832. $X = 0;
  1833. while( $X < $BMP['width'] ){
  1834. if ( $BMP['bits_per_pixel'] == 32 ){
  1835. $COLOR = unpack( "V", substr( $IMG, $P, 4 ) );
  1836. $B = ord(substr($IMG, $P,1));
  1837. $G = ord(substr($IMG, $P+1,1));
  1838. $R = ord(substr($IMG, $P+2,1));
  1839. $color = imagecolorexact( $res, $R, $G, $B );
  1840. if ( $color == -1 )
  1841. $color = imagecolorallocate( $res, $R, $G, $B );
  1842. $COLOR[0] = $R*256*256+$G*256+$B;
  1843. $COLOR[1] = $color;
  1844. }elseif ( $BMP['bits_per_pixel'] == 24 )
  1845. $COLOR = unpack( "V", substr( $IMG, $P, 3 ) . $VIDE );
  1846. elseif ( $BMP['bits_per_pixel'] == 16 ){
  1847. $COLOR = unpack( "n", substr( $IMG, $P, 2 ) );
  1848. $COLOR[1] = $PALETTE[$COLOR[1] + 1];
  1849. }elseif ( $BMP['bits_per_pixel'] == 8 ){
  1850. $COLOR = unpack( "n", $VIDE . substr( $IMG, $P, 1 ) );
  1851. $COLOR[1] = $PALETTE[$COLOR[1] + 1];
  1852. }elseif ( $BMP['bits_per_pixel'] == 4 ){
  1853. $COLOR = unpack( "n", $VIDE . substr( $IMG, floor( $P ), 1 ) );
  1854. if ( ($P * 2) % 2 == 0 )
  1855. $COLOR[1] = ($COLOR[1] >> 4);
  1856. else
  1857. $COLOR[1] = ($COLOR[1] & 0x0F);
  1858. $COLOR[1] = $PALETTE[$COLOR[1] + 1];
  1859. }elseif ( $BMP['bits_per_pixel'] == 1 ){
  1860. $COLOR = unpack( "n", $VIDE . substr( $IMG, floor( $P ), 1 ) );
  1861. if ( ($P * 8) % 8 == 0 )
  1862. $COLOR[1] = $COLOR[1] >> 7;
  1863. elseif ( ($P * 8) % 8 == 1 )
  1864. $COLOR[1] = ($COLOR[1] & 0x40) >> 6;
  1865. elseif ( ($P * 8) % 8 == 2 )
  1866. $COLOR[1] = ($COLOR[1] & 0x20) >> 5;
  1867. elseif ( ($P * 8) % 8 == 3 )
  1868. $COLOR[1] = ($COLOR[1] & 0x10) >> 4;
  1869. elseif ( ($P * 8) % 8 == 4 )
  1870. $COLOR[1] = ($COLOR[1] & 0x8) >> 3;
  1871. elseif ( ($P * 8) % 8 == 5 )
  1872. $COLOR[1] = ($COLOR[1] & 0x4) >> 2;
  1873. elseif ( ($P * 8) % 8 == 6 )
  1874. $COLOR[1] = ($COLOR[1] & 0x2) >> 1;
  1875. elseif ( ($P * 8) % 8 == 7 )
  1876. $COLOR[1] = ($COLOR[1] & 0x1);
  1877. $COLOR[1] = $PALETTE[$COLOR[1] + 1];
  1878. }else
  1879. return FALSE;
  1880. imagesetpixel( $res, $X, $Y, $COLOR[1] );
  1881. $X++;
  1882. $P += $BMP['bytes_per_pixel'];
  1883. }
  1884. $Y--;
  1885. $P += $BMP['decal'];
  1886. }
  1887. fclose( $f1 );
  1888. return $res;
  1889. }
  1890. /**
  1891. * 查询标段关注人信息列表
  1892. */
  1893. public function getConcernAuditList(){
  1894. if(isset($this->params['tenderid']) && is_numeric($this->params['tenderid'])){
  1895. $concernArray = $this->concern->getMeasureConcernList($this->params['tenderid']);
  1896. if(!empty($concernArray)){
  1897. $userArray = array();
  1898. foreach($concernArray as $k => $v){
  1899. $userArray[$k]['uid'] = $v['uid'];
  1900. $userArray[$k]['name'] = $this->auth->getName($v['uid']);
  1901. $userArray[$k]['uemail'] = $this->auth->getEmail($v['uid']);
  1902. }
  1903. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $userArray), JSON_UNESCAPED_UNICODE);
  1904. die();
  1905. }else{
  1906. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => null), JSON_UNESCAPED_UNICODE);
  1907. die();
  1908. }
  1909. } else {
  1910. echo json_encode(array('status' => 'FALSE', 'msg' => '标段参数无效'), JSON_UNESCAPED_UNICODE);
  1911. die();
  1912. }
  1913. }
  1914. /**
  1915. * 添加关注标段
  1916. */
  1917. public function addConcernAudit(){
  1918. if(isset($_POST['tenderid']) && is_numeric($_POST['tenderid']) && isset($_POST['uid']) && is_numeric($_POST['uid'])){
  1919. $tendermsg = $this->actmeasure->getRowByPmid($_POST['tenderid']);
  1920. if(!empty($tendermsg)){
  1921. $result = $this->concern->insertMeasureConcern($tendermsg['pid'], $tendermsg['stid'], $tendermsg['pmid'], $_POST['uid']);
  1922. if($result){
  1923. echo json_encode(array('status' => TRUE, 'msg' => '成功添加关注'), JSON_UNESCAPED_UNICODE);
  1924. die();
  1925. }else{
  1926. echo json_encode(array('status' => 'FALSE', 'msg' => '添加标段关注人失败'), JSON_UNESCAPED_UNICODE);
  1927. die();
  1928. }
  1929. }else{
  1930. echo json_encode(array('status' => 'FALSE', 'msg' => '标段不存在'), JSON_UNESCAPED_UNICODE);
  1931. die();
  1932. }
  1933. }else{
  1934. echo json_encode(array('status' => 'FALSE', 'msg' => '标段或关注人参数无效'), JSON_UNESCAPED_UNICODE);
  1935. die();
  1936. }
  1937. }
  1938. /**
  1939. * 取消关注标段
  1940. */
  1941. public function delConcernAudit(){
  1942. if(isset($_POST['tenderid']) && is_numeric($_POST['tenderid']) && isset($_POST['uid']) && is_numeric($_POST['uid'])){
  1943. $tendermsg = $this->actmeasure->getRowByPmid($_POST['tenderid']);
  1944. if(!empty($tendermsg)){
  1945. $result = $this->concern->delMeasureConcern($tendermsg['pmid'], $_POST['uid']);
  1946. echo json_encode(array('status' => TRUE, 'msg' => '成功取消关注'), JSON_UNESCAPED_UNICODE);
  1947. die();
  1948. }else{
  1949. echo json_encode(array('status' => 'FALSE', 'msg' => '标段不存在'), JSON_UNESCAPED_UNICODE);
  1950. die();
  1951. }
  1952. }else{
  1953. echo json_encode(array('status' => 'FALSE', 'msg' => '标段或关注人参数无效'), JSON_UNESCAPED_UNICODE);
  1954. die();
  1955. }
  1956. }
  1957. /**
  1958. * 软件生成报表开关
  1959. */
  1960. public function signSwitch(){
  1961. $reportSwitch = $this->aconfig->getOne(array('select' => 'reportswitch', 'asArray' => TRUE))['reportswitch'];
  1962. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $reportSwitch), JSON_UNESCAPED_UNICODE);
  1963. die();
  1964. }
  1965. /**
  1966. * 中间计量表添加草图功能开关
  1967. */
  1968. public function interMediateSwitch(){
  1969. $imediateswitch = $this->aconfig->getOne(array('select' => 'imediateswitch', 'asArray' => TRUE))['imediateswitch'];
  1970. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $imediateswitch), JSON_UNESCAPED_UNICODE);
  1971. die();
  1972. }
  1973. /**
  1974. * 变更令签约清单列表添加
  1975. */
  1976. public function changeListAdd(){
  1977. if(isset($_POST['pmid']) && is_numeric($_POST['pmid']) && isset($_POST['listjson']) && !empty($_POST['listjson'])){
  1978. $pmArray = $this->actmeasure->getRowByPmid($_POST['pmid']);
  1979. if(!empty($pmArray)){
  1980. $listjson = json_decode($_POST['listjson'],true);
  1981. //先删除原有的清单列表再重新添加
  1982. $this->change->delChangeListbyPmid($_POST['pmid']);
  1983. Doo::loadModel('changelist');
  1984. foreach($listjson as $k => $v){
  1985. $changelist = new ChangeList();
  1986. $changelist->insertChangelist($pmArray,$v);
  1987. }
  1988. echo json_encode(array('status' => TRUE, 'info' => ''), JSON_UNESCAPED_UNICODE);
  1989. die();
  1990. }else{
  1991. echo json_encode(array('status' => 'FALSE', 'msg' => '不存在此标段'), JSON_UNESCAPED_UNICODE);
  1992. die();
  1993. }
  1994. }else{
  1995. echo json_encode(array('status' => 'FALSE', 'msg' => '参数有误'), JSON_UNESCAPED_UNICODE);
  1996. die();
  1997. }
  1998. }
  1999. /*
  2000. * 标段的变更令内容导出
  2001. */
  2002. public function changeList()
  2003. {
  2004. if(isset($this->params['pmid']) && is_numeric($this->params['pmid'])){
  2005. $pmArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  2006. if(!empty($pmArray)){
  2007. $idlist = array();
  2008. $list = array();
  2009. $newcidlist = array();
  2010. //获取所有通过的变更令内容
  2011. $cidlist = $this->change->getPassChangeListID($this->params['pmid']);
  2012. if(empty($cidlist)){
  2013. echo json_encode(array('status' => 'TRUE', 'msg' => '当前标段不存在变更令内容', 'info' => ''), JSON_UNESCAPED_UNICODE);
  2014. die();
  2015. }
  2016. foreach($cidlist as $ck => $cv){
  2017. array_push($newcidlist,$cv['cid']);
  2018. }
  2019. //过滤掉已上传完的list
  2020. if(isset($_POST['filter']) && !empty($_POST['filter'])){
  2021. $filter = explode(',',$_POST['filter']);
  2022. $idlist = array_diff($newcidlist,$filter);
  2023. }else{
  2024. $idlist = $newcidlist;
  2025. }
  2026. if(empty($idlist)){
  2027. echo json_encode(array('status' => 'TRUE', 'msg' => '当前标段不存在需要更新的变更令', 'info' => ''), JSON_UNESCAPED_UNICODE);
  2028. die();
  2029. }else{
  2030. $index = 0;
  2031. foreach($idlist as $k => $v){
  2032. $changeArray = $this->change->getChangebyid($v);
  2033. $list[$index] = $changeArray;
  2034. $list[$index]['changeCategory'] = $this->changeCategory[$changeArray['category']];
  2035. $list[$index]['changeNature'] = $this->changeNature[$changeArray['cnature']];
  2036. $list[$index]['company'] = $this->change->getCompanybyid($changeArray['companyid'])['name'];
  2037. $list[$index]['changeBills'] = $this->change->getChangeAuditListbycid($v);
  2038. $index++;
  2039. }
  2040. echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => $list), JSON_UNESCAPED_UNICODE);
  2041. die();
  2042. }
  2043. }else{
  2044. echo json_encode(array('status' => 'FALSE', 'msg' => '不存在此标段'), JSON_UNESCAPED_UNICODE);
  2045. die();
  2046. }
  2047. }else{
  2048. echo json_encode(array('status' => 'FALSE', 'msg' => '参数有误'), JSON_UNESCAPED_UNICODE);
  2049. die();
  2050. }
  2051. }
  2052. }
  2053. ?>