ClientController.php 80 KB

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