ClientController.php 83 KB

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