account.inc.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. global $_GPC, $_W;
  3. $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
  4. $where=" where a.weid = :weid AND a.role=1 $strwhere";
  5. $data[':weid']=$_W['uniacid'];
  6. if($_W['role']=='operator'){
  7. //查找商家ID;
  8. $account=pdo_get('zhtc_account',array('weid'=>$_W['uniacid'],'uid'=>$_W['user']['uid']));
  9. /*$cityname=$account['cityname'];
  10. $where.=" and a.cityname =:cityname";
  11. $data[':cityname']=$cityname;*/
  12. $id=$account['id'];
  13. $where.=" and a.id =:id";
  14. $data[':id']=$id;
  15. }
  16. $GLOBALS['frames'] = $this->getMainMenu();
  17. if ($operation == 'display') {
  18. $strwhere = '';
  19. $pindex = max(1, intval($_GPC['page']));
  20. $psize = 10;
  21. $list = pdo_fetchall("SELECT a.*,b.username AS username,b.status AS status FROM " . tablename('zhtc_account') . " a LEFT JOIN
  22. " . tablename('users') . " b ON a.uid=b.uid ".$where." ORDER BY id DESC LIMIT
  23. " . ($pindex - 1) * $psize . ',' . $psize, $data);
  24. if (!empty($list)) {
  25. $total = pdo_fetchcolumn('SELECT COUNT(1) FROM ' . tablename('zhtc_account') . " WHERE weid = :weid $strwhere", array(':weid' =>$_W['uniacid']));
  26. $pager = pagination($total, $pindex, $psize);
  27. }
  28. } else if ($operation == 'delete') {
  29. $id = intval($_GPC['id']);
  30. $item = pdo_fetch("SELECT id FROM " . tablename('zhtc_account') . " WHERE id = '$id'");
  31. if (empty($item)) {
  32. message('抱歉,不存在或是已经被删除!', $this->createWebUrl('account', array('op' => 'display')), 'error');
  33. }
  34. pdo_delete('users', array('uid' => $item['uid']));
  35. pdo_delete('zhtc_account', array('id' => $id, 'weid' => $_W['uniacid']));
  36. message('删除成功!', $this->createWebUrl('account', array('op' => 'display')), 'success');
  37. }
  38. include $this->template('web/account');