ClientController.php 75 KB

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