ClientController.php 110 KB

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