groupgoods.inc.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. global $_GPC, $_W;
  3. $GLOBALS['frames'] = $this->getMainMenu();
  4. $types=pdo_getall('zhtc_grouptype',array('uniacid'=>$_W['uniacid']),array('name','id'),'','num asc');
  5. $where=" WHERE a.uniacid=:uniacid ";
  6. $data[':uniacid']=$_W['uniacid'];
  7. if($_GPC['keywords']){
  8. $where.=" and (a.name LIKE concat('%', :name,'%') || c.store_name LIKE concat('%', :name,'%'))";
  9. $op=$_GPC['keywords'];
  10. $data[':name']="%$op%";
  11. }
  12. if($_GPC['type_id']){
  13. $where .=" and a.type_id=:type_id";
  14. $data[':type_id']=$_GPC['type_id'];
  15. }
  16. if($_GPC['is_shelves2']){
  17. $where .=" and a.is_shelves=:cid";
  18. $data[':cid']=$_GPC['is_shelves2'];
  19. }
  20. if($_GPC['state']){
  21. $where.=" and a.state={$_GPC['state']} ";
  22. }
  23. $pageindex = max(1, intval($_GPC['page']));
  24. $pagesize=10;
  25. $type=isset($_GPC['type'])?$_GPC['type']:'all';
  26. $sql="select a.* ,b.name as type_name,c.store_name from " . tablename("zhtc_groupgoods") . " a" . " left join " . tablename("zhtc_grouptype") . " b on b.id=a.type_id left join " . tablename("zhtc_store") . " c on c.id=a.store_id".$where." order by num asc";
  27. $select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
  28. $list = pdo_fetchall($select_sql,$data);
  29. $total=pdo_fetchcolumn("select count(*) from " . tablename("zhtc_groupgoods") . " a" . " left join " . tablename("zhtc_grouptype") . " b on b.id=a.type_id left join " . tablename("zhtc_store") . " c on c.id=a.store_id".$where,$data);
  30. $pager = pagination($total, $pageindex, $pagesize);
  31. if($_GPC['id']){
  32. $data2['is_shelves']=$_GPC['is_shelves'];
  33. $res=pdo_update('zhtc_groupgoods',$data2,array('id'=>$_GPC['id']));
  34. if($res){
  35. message('设置成功',$this->createWebUrl('groupgoods',array('page'=>$_GPC['page'],'keywords'=>$_GPC['keywords'],'dishes_type'=>$_GPC['dishes_type'],'type_id'=>$_GPC['type_id'],'is_show2'=>$_GPC['is_show2'])),'success');
  36. }else{
  37. message('设置失败','','error');
  38. }
  39. }
  40. if($_GPC['op']=='delete'){
  41. $result = pdo_delete('zhtc_groupgoods', array('id'=>$_GPC['delid']));
  42. if($result){
  43. message('删除成功',$this->createWebUrl('groupgoods',array()),'success');
  44. }else{
  45. message('删除失败','','error');
  46. }
  47. }
  48. if($_GPC['op']=='play'){
  49. $data2['display']=$_GPC['display'];
  50. $res=pdo_update('zhtc_groupgoods',$data2,array('id'=>$_GPC['did']));
  51. if($res){
  52. message('设置成功',$this->createWebUrl('groupgoods',array('page'=>$_GPC['page'],'keywords'=>$_GPC['keywords'],'dishes_type'=>$_GPC['dishes_type'],'type_id'=>$_GPC['type_id'])),'success');
  53. }else{
  54. message('设置失败','','error');
  55. }
  56. }
  57. if($_GPC['op']=='tg'){
  58. $res=pdo_update('zhtc_groupgoods',array('state'=>2),array('id'=>$_GPC['cid']));
  59. if($res){
  60. message('通过成功!', $this->createWebUrl('groupgoods'), 'success');
  61. }else{
  62. message('通过失败!','','error');
  63. }
  64. }
  65. if($_GPC['op']=='jj'){
  66. $res=pdo_update('zhtc_groupgoods',array('state'=>3),array('id'=>$_GPC['cid']));
  67. if($res){
  68. message('拒绝成功!', $this->createWebUrl('groupgoods'), 'success');
  69. }else{
  70. message('拒绝失败!','','error');
  71. }
  72. }
  73. include $this->template('web/groupgoods');