sjcoupon.inc.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. global $_GPC, $_W;
  3. $storeid=$_COOKIE["storeid"];
  4. $cur_store = $this->getStoreById($storeid);
  5. $GLOBALS['frames'] = $this->getNaveMenu2($storeid);
  6. $where=" WHERE b.uniacid=:uniacid and a.store_id=:store_id";
  7. $data[':uniacid']=$_W['uniacid'];
  8. $data[':store_id']=$storeid;
  9. if($_GPC['keywords']){
  10. $op=$_GPC['keywords'];
  11. $where.=" and (a.name LIKE concat('%', :name,'%') || b.store_name LIKE concat('%', :name,'%'))";
  12. $data[':name']=$op;
  13. }
  14. if(!empty($_GPC['time'])){
  15. $start=strtotime($_GPC['time']['start']);
  16. $end=strtotime($_GPC['time']['end']);
  17. $where.=" and UNIX_TIMESTAMP(a.time) >={$start} and UNIX_TIMESTAMP(a.time)<={$end}";
  18. }
  19. if($_GPC['state']){
  20. $where.=" and a.state={$_GPC['state']} ";
  21. }
  22. $state=$_GPC['state'];
  23. $type=isset($_GPC['type'])?$_GPC['type']:'all';
  24. $pageindex = max(1, intval($_GPC['page']));
  25. $pagesize=10;
  26. $sql="select a.*,b.store_name,c.type_name from " . tablename("zhtc_coupons") . " a" . " left join " . tablename("zhtc_store") . " b on a.store_id=b.id left join " . tablename("zhtc_coupontype") . " c on a.type_id=c.id " .$where." order by a.time desc ";
  27. $total=pdo_fetchcolumn("select count(*) as wname from " . tablename("zhtc_coupons") . " a" . " left join " . tablename("zhtc_store") . " b on a.store_id=b.id left join " . tablename("zhtc_coupontype") . " c on a.type_id=c.id ".$where." order by a.time desc ",$data);
  28. $select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
  29. $list=pdo_fetchall($select_sql,$data);
  30. $pager = pagination($total, $pageindex, $pagesize);
  31. if($_GPC['op']=='delete'){
  32. $res=pdo_delete('zhtc_coupons',array('id'=>$_GPC['id']));
  33. if($res){
  34. message('删除成功!', $this->createWebUrl2('sjcoupon'), 'success');
  35. }else{
  36. message('删除失败!','','error');
  37. }
  38. }
  39. if($_GPC['op']=='updshow'){
  40. $res=pdo_update('zhtc_coupons',array('is_show'=>$_GPC['is_show']),array('id'=>$_GPC['id']));
  41. if($res){
  42. message('操作成功!', $this->createWebUrl2('sjcoupon'), 'success');
  43. }else{
  44. message('操作失败!','','error');
  45. }
  46. }
  47. if($_GPC['op']=='updshow2'){
  48. $res=pdo_update('zhtc_coupons',array('is_pt'=>$_GPC['is_pt']),array('id'=>$_GPC['id']));
  49. if($res){
  50. message('操作成功!', $this->createWebUrl2('sjcoupon'), 'success');
  51. }else{
  52. message('操作失败!','','error');
  53. }
  54. }
  55. if($_GPC['op']=='tg'){
  56. $res=pdo_update('zhtc_coupons',array('state'=>2),array('id'=>$_GPC['id']));
  57. if($res){
  58. message('通过成功!', $this->createWebUrl2('sjcoupon'), 'success');
  59. }else{
  60. message('通过失败!','','error');
  61. }
  62. }
  63. if($_GPC['op']=='jj'){
  64. $res=pdo_update('zhtc_coupons',array('state'=>3),array('id'=>$_GPC['id']));
  65. if($res){
  66. message('拒绝成功!', $this->createWebUrl2('sjcoupon'), 'success');
  67. }else{
  68. message('拒绝失败!','','error');
  69. }
  70. }
  71. include $this->template('web/sjcoupon');