AppController.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  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. Doo::loadClass('Hashids/Hashids');
  20. /**
  21. * MainController
  22. * Feel free to delete the methods and replace them with your own code.
  23. *
  24. * @author EllisRan
  25. */
  26. class AppController extends DooController {
  27. private $data, $client, $auth, $att, $file, $zip, $actmeasure, $contractact, $project, $profile, $numofperact, $measureauditact, $attfile, $users, $itemfile, $modelconfig, $aconfig, $sms, $itemMeasureNum, $__hashids;
  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. $this->__hashids = new Hashids\Hashids('jlzfuserid', 8);
  51. }
  52. public function ServerLogin() {
  53. if(isset($_POST['sname']) && !empty($_POST['sname'])){
  54. $allserver = array($_SERVER['HTTP_HOST']);
  55. if(in_array(trim($_POST['sname']), $allserver)){
  56. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  57. die;
  58. }else{
  59. echo json_encode(array('status' => FALSE, 'msg' => '服务器不存在。'), JSON_UNESCAPED_UNICODE);
  60. die;
  61. }
  62. }else{
  63. echo json_encode(array('status' => FALSE, 'msg' => '请输入服务器名称。'), JSON_UNESCAPED_UNICODE);
  64. die;
  65. }
  66. }
  67. public function AppSignin() {
  68. if(!isset($_POST['username']) || empty($_POST['username'])){
  69. echo json_encode(array('status' => FALSE, 'msg' => '请输入邮箱'), JSON_UNESCAPED_UNICODE);
  70. die;
  71. }
  72. if(!isset($_POST['userpwd']) || empty($_POST['userpwd'])){
  73. echo json_encode(array('status' => FALSE, 'msg' => '请输入密码'), JSON_UNESCAPED_UNICODE);
  74. die;
  75. }
  76. if ($this->auth->login($_POST['username'], $_POST['userpwd'])) {
  77. $uinfo = $this->auth->getUinfo();
  78. if (isset($uinfo['isstop']) && $uinfo['isstop'] > 0) {
  79. echo json_encode(array('status' => FALSE, 'msg' => '邮箱不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
  80. die;
  81. }
  82. if (isset($uinfo['uid'])) {
  83. $userArray = $this->profile->getProWithUid($uinfo['uid']);
  84. $avatarStr = $userArray['avatar'];
  85. if (isset($userArray['userid'])) {
  86. // $this->auth->setUid($uinfo['uid']);
  87. $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr);
  88. echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
  89. die;
  90. }
  91. }
  92. } else {
  93. echo json_encode(array('status' => FALSE, 'msg' => '邮箱不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
  94. die;
  95. }
  96. }
  97. // 获取待审批标段名
  98. public function UnSectionList(){
  99. if(isset($_POST['uid']) && !empty($_POST['uid']) && is_numeric($_POST['uid'])){
  100. $unsectionlist = $this->measureauditact->getCheckedRowbyUID6($_POST['uid']);
  101. $unslist = array();
  102. if(!empty($unsectionlist)){
  103. foreach($unsectionlist as $k => $v){
  104. $unslist[$k]['pname'] = $this->project->getRowByPid($v['pid'])['pname'];
  105. $unslist[$k]['sectionlist'] = array();
  106. $sectionlist = $this->measureauditact->getCheckedRowbyUID7($_POST['uid'],$v['pid']);
  107. if(!empty($sectionlist)){
  108. foreach($sectionlist as $sk => $sv){
  109. $name = $this->actmeasure->getRowByPmid($sv['pmid']);
  110. $unslist[$k]['sectionlist'][$sk]['pmname'] = !empty($name) ? $name['pmname'] : '';
  111. $countNum = $this->numofperact->getLastNew2($sv['pmid'])['numpname'];
  112. $unslist[$k]['sectionlist'][$sk]['countNum'] = !empty($countNum) ? $countNum : 0;
  113. $unslist[$k]['sectionlist'][$sk]['audittime'] = !empty($sv['audittime']) ? date('Y-m-d',$sv['audittime']) : '';
  114. $unslist[$k]['sectionlist'][$sk]['url'] = '/app/rproject/' . $sv['pid'] . '/section/' . $sv['pmid'] . '/detail';
  115. $stname = $this->contractact->getRowByStid($sv['stid']);
  116. $unslist[$k]['sectionlist'][$sk]['stname'] = !empty($stname) ? $stname['stname'] : '';
  117. }
  118. }
  119. }
  120. }
  121. echo json_encode(array('status' => TRUE, 'msg' => '', 'unsectionlist' => $unslist), JSON_UNESCAPED_UNICODE);
  122. die();
  123. }else{
  124. $status = array('status' => FALSE, 'msg' => '获取待审批标段列表出错');
  125. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  126. die();
  127. }
  128. }
  129. //获取已审核项目名
  130. public function ItemCkeckedList(){
  131. if(isset($_POST['uid']) && !empty($_POST['uid']) && is_numeric($_POST['uid'])){
  132. $Itemlist = $this->measureauditact->getCheckedRowbyUID3($_POST['uid']);
  133. $Itemcheckedlist = array();
  134. if(!empty($Itemlist)){
  135. foreach($Itemlist as $k => $v){
  136. $name = $this->project->getRowByPid($v['pid']);
  137. $Itemcheckedlist[$k]['pid'] = $v['pid'];
  138. $Itemcheckedlist[$k]['pname'] = $name['pname'];
  139. }
  140. }
  141. echo json_encode(array('status' => TRUE, 'msg' => '', 'Itemlist' => $Itemcheckedlist), JSON_UNESCAPED_UNICODE);
  142. die();
  143. }else{
  144. $status = array('status' => FALSE, 'msg' => '获取已审核项目列表出错');
  145. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  146. die();
  147. }
  148. }
  149. //获取已审核项目中已审核标段的信息
  150. public function SectionCheckedList(){
  151. if(isset($_POST['uid']) && is_numeric($_POST['uid']) && isset($this->params['pid']) && is_numeric($this->params['pid'])){
  152. //先获取标段类型列表
  153. $stlist = $this->measureauditact->getCheckedRowbyUID4($_POST['uid'], $this->params['pid']);
  154. $sectioncheckedlist = array();
  155. if(!empty($stlist)){
  156. $i = 0;
  157. foreach($stlist as $k => $v){
  158. //再获取标段名信息
  159. $sectionlist = $this->measureauditact->getCheckedRowbyUID5($_POST['uid'], $this->params['pid'],$v['stid']);
  160. $sectioncheckedlistarray = array();
  161. if(!empty($sectionlist)){
  162. $j = 0;
  163. foreach($sectionlist as $key => $value){
  164. $numStatusArray = $this->numofperact->getLastStatus3($this->params['pid'], $value['pmid']);
  165. if (!isset($numStatusArray['currstatus'])) {
  166. $numStatusArray['currstatus'] = 'uncheck';
  167. }
  168. $datatmp = $this->measureauditact->getMyAuditStatus2($numStatusArray['pmid'], $numStatusArray['numpname'], $numStatusArray['times'], $_POST['uid']);
  169. if ($datatmp && ($datatmp['mastatus'] == 'checked' || $datatmp['mastatus'] == 'checkno') ) {
  170. $pmname = $this->actmeasure->getRowByPmid($value['pmid']);
  171. $sectioncheckedlistarray[$j]['pmname'] = !empty($pmname) ? $pmname['pmname'] : '';
  172. $sectioncheckedlistarray[$j]['countNum'] = !empty($datatmp['numpname']) ? $datatmp['numpname'] : 0;
  173. $sectioncheckedlistarray[$j]['audittime'] = !empty($datatmp['audittime']) ? date('Y-m-d',$datatmp['audittime']) : '';
  174. $sectioncheckedlistarray[$j]['url'] = '/app/rproject/' . $this->params['pid'] . '/section/' . $value['pmid'] . '/detail';
  175. $j++;
  176. }
  177. }
  178. }
  179. if(!empty($sectioncheckedlistarray)){
  180. $stname = $this->contractact->getRowByStid($v['stid']);
  181. $sectioncheckedlist[$i]['stname'] = !empty($stname['stname']) ? $stname['stname'] : '';
  182. $sectioncheckedlist[$i]['stlist'] = $sectioncheckedlistarray;
  183. }
  184. $i++;
  185. }
  186. }
  187. echo json_encode(array('status' => TRUE, 'msg' => '', 'sectionlist' => $sectioncheckedlist), JSON_UNESCAPED_UNICODE);
  188. die();
  189. }else{
  190. $status = array('status' => FALSE, 'msg' => '获取已审核标段列表出错');
  191. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  192. die();
  193. }
  194. }
  195. //内嵌app页
  196. public function proDetail() {
  197. if(isset($_GET['uid']) && is_numeric($_GET['uid'])) {
  198. if(isset($_GET['approval'])){
  199. $this->data['approval'] = 1;
  200. }
  201. $numStatusArray = $this->numofperact->getLastStatus3($this->params['pid'], $this->params['pmid']);
  202. if (!isset($numStatusArray['currstatus'])) {
  203. $numStatusArray['currstatus'] = 'uncheck';
  204. }
  205. // 项目名称
  206. $mpidArray = $this->measureauditact->getAuditProject2($_GET['uid']);
  207. foreach ($mpidArray as $k1 => $v1) {
  208. if ($v1['pid'] != $this->params['pid'])
  209. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  210. }
  211. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  212. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  213. $this->data['MeasureArray3'] = array_reverse($this->data['MeasureArray']);
  214. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  215. foreach ($this->data['MeasureArray'] as $key => $value) {
  216. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  217. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  218. } else {
  219. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  220. }
  221. }
  222. // 期数列表
  223. $tmpArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  224. foreach ($tmpArray as $k => $v) {
  225. $intTime = $this->numofperact->getMaxTimes($v['pmid'], $v['numpname'])['times'];
  226. $nfArray[] = $this->numofperact->getRow($v['pmid'], $v['numpname'], $intTime);
  227. }
  228. foreach ($nfArray as $k => $v) {
  229. if ($v['mpid'] == $numStatusArray['mpid']) {
  230. $this->data['mpid'] = $v['mpid'];
  231. $this->data['MeasureArray2'][] = $v;
  232. $this->data['currnum'] = $v['numpname'];
  233. } else {
  234. $this->data['numArray'][] = $v;
  235. }
  236. }
  237. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  238. foreach ($this->data['MeasureArray2'] as $key => $value) {
  239. if ($value['mpid'] == $numStatusArray['mpid']) {
  240. $this->data['MeasureArray2'][$key]['currstatus'] = $this->statusArray[$value['currstatus']];
  241. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  242. $this->data['MeasureArray2'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  243. } else {
  244. $this->data['MeasureArray2'][$key]['lessTotal'] = 0;
  245. }
  246. }
  247. }
  248. $lastRowArray = $this->numofperact->getLastNew2($this->params['pmid']);
  249. $maxTimes = $this->numofperact->getMaxTimes($lastRowArray['pmid'], $lastRowArray['numpname']);
  250. // $auditUserArray = $this->measureauditact->getAllAudit($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  251. // $maxtimez = $this->measureauditact->getRowGroupByTimes($numStatusArray['mpid']);
  252. $maxtimez = $this->numofperact->getRowByMpid($numStatusArray['mpid']);
  253. $auditUserArray = $this->measureauditact->getRowByMpidTimes($numStatusArray['mpid'], $maxtimez['numpname'], $maxtimez['times']);
  254. $auditArray = $this->measureauditact->getLastNewRowInfo($lastRowArray['pmid'], $lastRowArray['numpname'], $_GET['uid']);
  255. if (isset($_POST['act'])) {
  256. $auditStatusArray = array('checkno', 'checked');
  257. $myAuditStatus = $this->measureauditact->getMyAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times'], $_GET['uid']);
  258. if (in_array($myAuditStatus['mastatus'], $auditStatusArray)) {
  259. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  260. die();
  261. }
  262. }
  263. if ($_POST['act'] == 'p') {
  264. if ($this->measureauditact->setMyAuditPass($auditArray['maid'], $_POST['content'], 1, $_GET['uid'])) {
  265. $countAudit = count($auditUserArray);
  266. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  267. if ($auditArray['last'] == 1) {
  268. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checked', $maxTimes['times']);
  269. // SMS Start
  270. $TenderArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  271. $userProArray = $this->profile->getProWithUid($TenderArray['uid']);
  272. if (isset($userProArray) && ($userProArray['mobile'])) {
  273. $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR3"]);
  274. }
  275. // SMS End
  276. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  277. die();
  278. } else {
  279. if (($countAudit == 2) && ($auditUserArray[1]['last'] == 1) && ($auditUserArray[0]['maid'] == $auditArray['maid'])) {
  280. $this->measureauditact->updateMastatus($auditUserArray[1]['maid']);
  281. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  282. // SMS Start
  283. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[1]['auditoruid']);
  284. $pmnameArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  285. if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// XXXX(标段名),陈特,已审批通过。请您继续审批。
  286. $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  287. }
  288. // SMS End
  289. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  290. die();
  291. }
  292. if (($countAudit > 2)) {
  293. foreach ($auditUserArray as $k => $v) {
  294. if ($v['maid'] == $auditArray['maid']) {
  295. if ($k == ($countAudit - 1)) {//如果是最后一个
  296. $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);
  297. // SMS Start
  298. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[0]['auditoruid']);
  299. // var_dump($verifyUserArray);
  300. $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[0]['pmid']);
  301. // var_dump($pmnameArray);
  302. // SMS End
  303. } else {
  304. $this->measureauditact->updateMastatus($auditUserArray[$k + 1]['maid']);
  305. // SMS Start
  306. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[$k + 1]['auditoruid']);
  307. // var_dump($verifyUserArray);
  308. $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[$k + 1]['pmid']);
  309. // var_dump($pmnameArray);
  310. // SMS End
  311. }
  312. // SMS Start
  313. if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// XXXX(标段名),陈特,已审批通过。请您继续审批。
  314. // $retval = $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  315. $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  316. // var_dump($pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  317. // var_dump($retval);
  318. // var_dump($this->sms->getErrors());
  319. }
  320. // SMS End
  321. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  322. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  323. die();
  324. }
  325. }
  326. }
  327. }
  328. }
  329. }
  330. if ($_POST['act'] == 'np') {
  331. $this->measureauditact->setCheckno($auditArray['maid'], $_POST['content'], 1);
  332. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checkno', $maxTimes['times']);
  333. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  334. // SMS Start
  335. $TenderArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  336. $userProArray = $this->profile->getProWithUid($TenderArray['uid']);
  337. if (isset($userProArray) && ($userProArray['mobile'])) {// // XXXX(标段名),陈特,已审批通过。请您继续审批。
  338. $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR4"]);
  339. // var_dump($retval);
  340. // var_dump($this->sms->getErrors());
  341. // $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR4"]);
  342. }
  343. // SMS End
  344. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  345. die();
  346. }
  347. if($_POST['act'] == 'back') {
  348. $measureauditact = new MeasureauditAct();
  349. $measureauditact->setUncheck($auditArray['maid']);
  350. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  351. //获取并改变上一个审批人为审批中状态
  352. $lastmeasureauditact = $this->measureauditact->getMyAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times'], $_POST['last']);
  353. $this->measureauditact->updateMastatus2($lastmeasureauditact['maid']);
  354. //退回必须删除上一个上报人的文件数据并更改前一个文件为最新2
  355. $this->attfile->delMyAttFile($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times'], $_POST['last']);
  356. $lastaid = $this->attfile->getLastFileAid($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  357. if(!empty($lastaid)){
  358. $this->attfile->updateIsNew2($lastaid);
  359. }
  360. // SMS Start
  361. $TenderArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  362. $userProArray = $this->profile->getProWithUid($_POST['last']);
  363. if (isset($userProArray) && ($userProArray['mobile'])) {// // XXXX(标段名),陈特,已审批通过。请您继续审批。
  364. $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR8"]);
  365. }
  366. // SMS End
  367. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  368. die();
  369. }
  370. $this->data['pmid'] = $lastRowArray['pmid'];
  371. $this->data['numpname'] = $lastRowArray['numpname'];
  372. $this->data['times'] = $lastRowArray['times'];
  373. $firstUser = 0;
  374. foreach ($auditUserArray as $key => $value) {
  375. $strAvatar = $this->auth->getAvatar($value['auditoruid']);
  376. if ($value['auditoruid'] == $_GET['uid']) {
  377. $this->data['mastatus'] = $value['mastatus'];
  378. $this->data['maid'] = $value['maid'];
  379. $name = $this->profile->getProWithUid($value['auditoruid'])['name'].'(我)';
  380. if($key == 0){
  381. $firstUser = 1;
  382. }else{
  383. $this->data['lastUserID'] = $auditUserArray[$key-1]['auditoruid'];
  384. $this->data['lastUsername'] = $this->profile->getProWithUid($auditUserArray[$key-1]['auditoruid'])['name'];
  385. $this->data['lastUserCompany'] = $this->profile->getProWithUid($auditUserArray[$key-1]['auditoruid'])['company'];
  386. }
  387. }else{
  388. $name = $this->profile->getProWithUid($value['auditoruid'])['name'];
  389. }
  390. if ($value['mastatus'] == 'uncheck') {
  391. $statushtml = '<div class="approvalImg"><img class="pa2ss" src="'. $strAvatar .'">'.$name.'<b class="colGray fR">待审</b></div>';
  392. }
  393. if ($value['mastatus'] == 'checking') {
  394. $statushtml = '<div class="approvalImg"><img class="wait" src="'. $strAvatar .'">'.$name.'<b class="colOrange fR">审批中</b></div>';
  395. }
  396. if ($value['mastatus'] == 'checked') {
  397. $statushtml = '<div class="approvalImg"><img class="pass" src="'. $strAvatar .'">'.$name.'<b class="colGreen fR">审批完成(' . date('Y-m-d', $value['audittime']) . ')</b></div>';
  398. }
  399. if ($value['mastatus'] == 'checkno') {
  400. $statushtml = '<div class="approvalImg"><img class="unpass" src="'. $strAvatar .'">'.$name.'<b class="colRed fR">审批不通过(' . date('Y-m-d', $value['audittime']) . ')</b></div>';
  401. }
  402. $auditUserArray[$key]['statushtml'] = $statushtml;
  403. }
  404. $strAvatar = $this->auth->getAvatar($measureArray['uid']);
  405. $orginArrayname = $this->profile->getProWithUid($measureArray['uid'])['name'];
  406. $attfileArray = $this->attfile->getFirstFile($lastRowArray['pmid'], $lastRowArray['numpname'], $lastRowArray['times']);
  407. $orginArray['time'] = date('Y-m-d', $attfileArray['intime']);
  408. $orginArray['statushtml'] = '<div class="approvalImg"><img class="pass" src="'. $strAvatar .'">'.$orginArrayname.'<b class="colGreen fR">原报上报(' . $orginArray['time'] . ')</b></div>';
  409. $this->data['auditArray'] = $auditUserArray;
  410. $this->data['orginArray'] = $orginArray;
  411. $this->data['uid'] = $_GET['uid'];
  412. $this->data['pmid'] = $this->params['pmid'];
  413. $this->data['pid'] = $this->params['pid'];
  414. $this->data['mpid'] = $numStatusArray['mpid'];
  415. $this->data['firstUser'] = $firstUser;
  416. $this->render('r-project-section-detail-APP', $this->data, TRUE);
  417. }else{
  418. exit('error:无参数无法访问本页');
  419. }
  420. }
  421. public function getSignPic(){
  422. if(isset($_POST['uid']) && is_numeric($_POST['uid'])){
  423. $userArray = $this->profile->getProWithUid($_POST['uid']);
  424. if(!empty($userArray)){
  425. $signPic = $userArray['signpath'];
  426. $status = array('status' => TRUE, 'msg' => '', 'signpic' => Doo::conf()->APP_URL . $signPic);
  427. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  428. die();
  429. }
  430. }
  431. $status = array('status' => FALSE, 'msg' => '参数有误');
  432. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  433. die();
  434. }
  435. public function uploadSignPic(){
  436. if(isset($_POST['uid']) && is_numeric($_POST['uid']) && isset($_POST['signbase64'])){
  437. $userArray = $this->profile->getProWithUid($_POST['uid']);
  438. if(!empty($userArray)){
  439. $img = base64_decode($_POST['signbase64']);
  440. $dir = 'global/signpath';
  441. $fileName = date("YmdHis") . '_' . floor(microtime() * 1000) . '_' . self::createRandomCode(8);
  442. $virtualPath = "$dir/php_sign_$fileName.jpg";
  443. $a = file_put_contents(Doo::conf()->SITE_PATH .$virtualPath,$img);
  444. // move_uploaded_file($_FILES['sign']["tmp_name"], Doo::conf()->SITE_PATH .$virtualPath);
  445. if($a){
  446. $this->profile->setSignPath($_POST['uid'], $virtualPath);
  447. $status = array('status' => TRUE, 'msg' => '');
  448. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  449. die();
  450. }else{
  451. $status = array('status' => FALSE, 'msg' => '上传签名照失败');
  452. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  453. die();
  454. }
  455. }
  456. }
  457. $status = array('status' => FALSE, 'msg' => '参数有误');
  458. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  459. die();
  460. }
  461. //二维数组去掉重复值 并保留键值
  462. function array_unique_fb($array2D)
  463. {
  464. $key = array();
  465. foreach ($array2D as $k => $v) {
  466. if (empty($key))
  467. $key = array_keys($v); //记录数组的KEY
  468. $v = join(",", $v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
  469. $temp[$k] = $v;
  470. }
  471. $temp = array_unique($temp); //去掉重复的字符串,也就是重复的一维数组
  472. foreach ($temp as $k => $v) {
  473. $array = explode(",", $v); //再将拆开的数组重新组装
  474. foreach ($array as $i => $t) {
  475. $temp2[$k] = !empty($temp2[$k]) ? array_merge($temp2[$k], array("{
  476. $key[$i]}" => $t)) : array("{
  477. $key[$i]}" => $t); //依次添加到新的数组中去
  478. }
  479. }
  480. return $temp2;
  481. }
  482. function unique_arr($array2D, $stkeep = false, $ndformat = true)
  483. {
  484. // 判断是否保留一级数组键 (一级数组键可以为非数字)
  485. if ($stkeep)
  486. $stArr = array_keys($array2D);
  487. // 判断是否保留二级数组键 (所有二级数组键必须相同)
  488. if ($ndformat)
  489. $ndArr = array_keys(end($array2D));
  490. //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
  491. foreach ($array2D as $v) {
  492. $v = join(",", $v);
  493. $temp[] = $v;
  494. }
  495. //去掉重复的字符串,也就是重复的一维数组
  496. $temp = array_unique($temp);
  497. //再将拆开的数组重新组装
  498. foreach ($temp as $k => $v) {
  499. if ($stkeep)
  500. $k = $stArr[$k];
  501. if ($ndformat) {
  502. $tempArr = explode(",", $v);
  503. foreach ($tempArr as $ndkey => $ndval) {
  504. $output[$k][$ndArr[$ndkey]] = $ndval;
  505. }
  506. } else {
  507. $output[$k] = explode(",", $v);
  508. }
  509. }
  510. return $output;
  511. }
  512. /**
  513. * 。
  514. * 标段ID,期号
  515. */
  516. private function __auditNotice($mobile, $text)
  517. {
  518. $smsSwitch = $this->aconfig->getOne(array('select' => 'smsSwitch', 'asArray' => TRUE))['smsSwitch'];
  519. if ($smsSwitch > 0)
  520. return $this->sms->sendSms($mobile, $text);
  521. }
  522. function upfile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  523. {
  524. return $this->att->uploadMut($fildname, $param);
  525. }
  526. function upItemFile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  527. {
  528. $this->att->setUploadDir();
  529. return $this->att->uploadMut($fildname, $param);
  530. }
  531. /**
  532. * 根据标段ID获取标段是否已经被删除的提示
  533. * 标段ID
  534. */
  535. public function getCountPmid()
  536. {
  537. if (isset($this->params['tenderid'])) {
  538. $isexist = $this->actmeasure->getCountPmid($this->params['tenderid']);
  539. if ($isexist > 0) {
  540. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => null), JSON_UNESCAPED_UNICODE);
  541. die();
  542. } else {
  543. echo json_encode(array('status' => 'FALSE', 'msg' => '该项目[XXX]在云端已被删除,点击“确定”后,可手动删除该项目'), JSON_UNESCAPED_UNICODE);
  544. die();
  545. }
  546. } else {
  547. $this->msg(0, '获取标段是否存在参数错误');
  548. }
  549. }
  550. function getFileupErrorNo()
  551. {
  552. return $this->att->error();
  553. }
  554. function Signout()
  555. {
  556. session_destroy();
  557. }
  558. function isLoggedIn()
  559. {
  560. return isset($_SESSION['user_id']);
  561. }
  562. function generateFormHash($salt)
  563. {
  564. $hash = md5(mt_rand(1, 1000000) . $salt);
  565. $_SESSION['csrf_hash'] = $hash;
  566. return $hash;
  567. }
  568. function isValidFormHash($hash)
  569. {
  570. return $_SESSION['csrf_hash'] === $hash;
  571. }
  572. /**
  573. * 随机字符串函数
  574. * @param $password 密码
  575. * @param $random 随机数
  576. */
  577. function random($length, $chars = '0123456789')
  578. {
  579. $hash = '';
  580. $max = strlen($chars) - 1;
  581. for ($i = 0; $i < $length; $i++) {
  582. $hash .= $chars[mt_rand(0, $max)];
  583. }
  584. return $hash;
  585. }
  586. /**
  587. * 生成随机字符串
  588. * @param string $lenth 长度
  589. * @return string 字符串
  590. */
  591. function create_randomstr($lenth = 6)
  592. {
  593. return $this->random($lenth, '123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ');
  594. }
  595. function dir_create($path, $mode = 0777)
  596. {
  597. if (is_dir($path))
  598. return TRUE;
  599. $path = $this->dir_path($path);
  600. $parent = dirname($path);
  601. if (!is_dir($parent))
  602. @mkdir($parent, 0777, true);
  603. @mkdir($path, 0777, true);
  604. return is_dir($path);
  605. }
  606. function dir_path($path)
  607. {
  608. $path = str_replace('\\', '/', $path);
  609. if (substr($path, -1) != '/')
  610. $path = $path . '/';
  611. return $path;
  612. }
  613. function msg($isTrue = 0, $msg = null, $retmsg = null)
  614. {
  615. if ($isTrue > 0) {
  616. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  617. die();
  618. } else {
  619. echo json_encode(array('status' => 'FALSE', 'msg' => $msg), JSON_UNESCAPED_UNICODE);
  620. die();
  621. }
  622. }
  623. /* * ************************************************************
  624. * 生成指定长度的随机码。
  625. * @param int $length 随机码的长度。
  626. * @access public
  627. * ************************************************************ */
  628. function createRandomCode($length)
  629. {
  630. $randomCode = "";
  631. $randomChars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  632. for ($i = 0; $i < $length; $i++) {
  633. $randomCode .= $randomChars{mt_rand(0, 35)};
  634. }
  635. return $randomCode;
  636. }
  637. public function scanValidate(){
  638. if(isset($_POST['app']) && $_POST['app'] == 'jlzfAppScanValidate'){
  639. $uid = $this->__hashids->decode($_POST['user'])[0];
  640. if(!empty($uid) && is_numeric($uid)){
  641. if($this->auth->getWebToken($uid) == $_POST['token']){
  642. $userArray = $this->profile->getProWithUid($uid);
  643. $avatarStr = $userArray['avatar'];
  644. if (isset($userArray['userid'])) {
  645. $msgArray = array('uid' => $uid, 'name' => $userArray['name'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr, 'server' => $_SERVER['HTTP_HOST'], 'token' => $_POST['token']);
  646. echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
  647. exit;
  648. }else{
  649. echo json_encode(array('status' => FALSE, 'msg' => '不存在该用户,请联系我们'), JSON_UNESCAPED_UNICODE);
  650. exit;
  651. }
  652. }else{
  653. echo json_encode(array('status' => FALSE, 'msg' => '请检查二维码是否正确或过期,重新登录web端获取最新二维码或使用账号密码登录'), JSON_UNESCAPED_UNICODE);
  654. exit;
  655. }
  656. }
  657. }
  658. return 'http://a.app.qq.com/o/simple.jsp?pkgname=cn.com.smartcost.jlzf';
  659. }
  660. public function ScanLogin(){
  661. if(isset($_POST['app']) && $_POST['app'] == 'jlzfAppScanLogin'){
  662. $status = $this->auth->checkLoginByScan($_POST['uid'],$_POST['token']);
  663. if($status){
  664. $uinfo = $this->auth->getUinfo();
  665. $userArray = $this->profile->getProWithUid($uinfo['uid']);
  666. $avatarStr = $userArray['avatar'];
  667. if (isset($userArray['userid'])) {
  668. $apptoken = sha1($this->create_randomstr() . $uinfo['uid']);
  669. $this->auth->AppLoginToken($uinfo['uid'],$apptoken);
  670. $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr, 'token' => $apptoken);
  671. echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
  672. die;
  673. }
  674. }else{
  675. echo json_encode(array('status' => FALSE, 'msg' => '请检查二维码是否正确或过期,重新登录web端获取最新二维码或使用账号密码登录'), JSON_UNESCAPED_UNICODE);
  676. exit;
  677. }
  678. }
  679. return 'http://a.app.qq.com/o/simple.jsp?pkgname=cn.com.smartcost.jlzf';
  680. }
  681. public function autoScanLogin(){
  682. if ($this->auth->CheckAppLoginToken($_POST['uid'], $_POST['token'])) {
  683. $uinfo = $this->auth->getUinfo();
  684. if (isset($uinfo['isstop']) && $uinfo['isstop'] > 0) {
  685. echo json_encode(array('status' => FALSE, 'msg' => '账号未启用'), JSON_UNESCAPED_UNICODE);
  686. die;
  687. }
  688. if (isset($uinfo['uid'])) {
  689. $userArray = $this->profile->getProWithUid($uinfo['uid']);
  690. $avatarStr = $userArray['avatar'];
  691. if (isset($userArray['userid'])) {
  692. // $this->auth->setUid($uinfo['uid']);
  693. $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr);
  694. echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
  695. die;
  696. }
  697. }
  698. } else {
  699. echo json_encode(array('status' => FALSE, 'msg' => '您的登录信息已过期,请重新登录'), JSON_UNESCAPED_UNICODE);
  700. die;
  701. }
  702. }
  703. // function checkVersion($version)
  704. // {
  705. // preg_match();
  706. // }
  707. }
  708. ?>