goods.inc.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. global $_GPC, $_W;
  3. $GLOBALS['frames'] = $this->getMainMenu();
  4. $where=" WHERE a.uniacid=:uniacid ";
  5. if($_GPC['keywords']){
  6. $op=$_GPC['keywords'];
  7. $where.=" and a.goods_name LIKE concat('%', :name,'%') ";
  8. $data[':name']=$op;
  9. }
  10. if($_GPC['state']){
  11. $where.=" and a.state={$_GPC['state']} ";
  12. }
  13. if(!empty($_GPC['time'])){
  14. $start=strtotime($_GPC['time']['start']);
  15. $end=strtotime($_GPC['time']['end']);
  16. $where.=" and a.time >={$start} and a.time<={$end}";
  17. }
  18. $state=$_GPC['state'];
  19. $pageindex = max(1, intval($_GPC['page']));
  20. $pagesize=10;
  21. $type=isset($_GPC['type'])?$_GPC['type']:'all';
  22. $data[':uniacid']=$_W['uniacid'];
  23. $sql="select a.*,b.store_name from " . tablename("zhtc_goods") . " a" . " left join " . tablename("zhtc_store") . " b on a.store_id=b.id" .$where." order by a.time desc ";
  24. $total=pdo_fetchcolumn("select count(*) as wname from " . tablename("zhtc_goods") . " a" . " left join " . tablename("zhtc_store") . " b on a.store_id=b.id".$where." order by a.time desc ",$data);
  25. $select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
  26. $list=pdo_fetchall($select_sql,$data);
  27. $pager = pagination($total, $pageindex, $pagesize);
  28. if($_GPC['op']=='delete'){
  29. $res=pdo_delete('zhtc_goods',array('id'=>$_GPC['id']));
  30. if($res){
  31. message('删除成功!', $this->createWebUrl('goods'), 'success');
  32. }else{
  33. message('删除失败!','','error');
  34. }
  35. }
  36. if($_GPC['op']=='tg'){
  37. $res=pdo_update('zhtc_goods',array('state'=>2),array('id'=>$_GPC['id']));
  38. if($res){
  39. message('通过成功!', $this->createWebUrl('goods'), 'success');
  40. }else{
  41. message('通过失败!','','error');
  42. }
  43. }
  44. if($_GPC['op']=='jj'){
  45. $res=pdo_update('zhtc_goods',array('state'=>3),array('id'=>$_GPC['id']));
  46. if($res){
  47. message('拒绝成功!', $this->createWebUrl('goods'), 'success');
  48. }else{
  49. message('拒绝失败!','','error');
  50. }
  51. }
  52. include $this->template('web/goods');