ClientController.php 82 KB

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