coupon.inc.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. global $_GPC, $_W;
  3. $GLOBALS['frames'] = $this->getMainMenu();
  4. $where=" WHERE b.uniacid=:uniacid ";
  5. if($_GPC['keywords']){
  6. $op=$_GPC['keywords'];
  7. $where.=" and (a.name LIKE concat('%', :name,'%') || b.store_name LIKE concat('%', :name,'%'))";
  8. $data[':name']=$op;
  9. }
  10. if(!empty($_GPC['time'])){
  11. $start=strtotime($_GPC['time']['start']);
  12. $end=strtotime($_GPC['time']['end']);
  13. $where.=" and UNIX_TIMESTAMP(a.time) >={$start} and UNIX_TIMESTAMP(a.time)<={$end}";
  14. }
  15. if($_GPC['state']){
  16. $where.=" and a.state={$_GPC['state']} ";
  17. }
  18. $state=$_GPC['state'];
  19. $type=isset($_GPC['type'])?$_GPC['type']:'all';
  20. $pageindex = max(1, intval($_GPC['page']));
  21. $pagesize=10;
  22. $data[':uniacid']=$_W['uniacid'];
  23. $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 ";
  24. $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);
  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_coupons',array('id'=>$_GPC['id']));
  30. if($res){
  31. message('删除成功!', $this->createWebUrl('coupon'), 'success');
  32. }else{
  33. message('删除失败!','','error');
  34. }
  35. }
  36. if($_GPC['op']=='updshow'){
  37. $res=pdo_update('zhtc_coupons',array('is_show'=>$_GPC['is_show']),array('id'=>$_GPC['id']));
  38. if($res){
  39. message('操作成功!', $this->createWebUrl('coupon'), 'success');
  40. }else{
  41. message('操作失败!','','error');
  42. }
  43. }
  44. if($_GPC['op']=='updshow2'){
  45. $res=pdo_update('zhtc_coupons',array('is_pt'=>$_GPC['is_pt']),array('id'=>$_GPC['id']));
  46. if($res){
  47. message('操作成功!', $this->createWebUrl('coupon'), 'success');
  48. }else{
  49. message('操作失败!','','error');
  50. }
  51. }
  52. if($_GPC['op']=='tg'){
  53. $res=pdo_update('zhtc_coupons',array('state'=>2),array('id'=>$_GPC['id']));
  54. if($res){
  55. message('通过成功!', $this->createWebUrl('coupon'), 'success');
  56. }else{
  57. message('通过失败!','','error');
  58. }
  59. }
  60. if($_GPC['op']=='jj'){
  61. $res=pdo_update('zhtc_coupons',array('state'=>3),array('id'=>$_GPC['id']));
  62. if($res){
  63. message('拒绝成功!', $this->createWebUrl('coupon'), 'success');
  64. }else{
  65. message('拒绝失败!','','error');
  66. }
  67. }
  68. include $this->template('web/coupon');