ClientController.php 86 KB

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