<?php 

require 'db.php';

if(isset($_GET['sid']) && isset($_GET['token']))
{
    $shop_id = $_GET['sid'];
    $shop_code = $_GET['token'];

    include 'token_check.php';
    
    if($token_check)
    {
        $sels = $con->query("select * from coupon_code where shop_id='$shop_id' and shop_code='$shop_code'");
        while($rows = $sels->fetch_assoc())
        {
                $p['id'] = $rows['id'];
        		$p['name'] = $rows['name'];
        		$p['discount'] = $rows['discount'];
        		$p['code'] = $rows['code'];
        		$p['max_order_amount'] = $rows['max_order_amount'];
        		$p['max_discount_amount'] = $rows['max_discount_amount'];
        		$p['max_use_limit'] = $rows['max_use_limit'];
        		$p['status'] = $rows['status'];
        		$cp[] = $p;
        }
        
        echo json_encode($cp);
    }
    else
    {
        $rows = array('status'=>"",'message' => 'Data Error');
        echo json_encode($rows);
    }
}

?>