<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
include '../../../config/index.php';
$data = file_get_contents('php://input');
$obj = json_decode($data, true);
foreach ($obj as $key => $value) {
    $Active =  $value['Active'] ? 'true' : 'false';
    $sql = "INSERT INTO Coupons VALUES (NULL,
        '" . $value['code'] . "',
        '" . $value['DiscountOption'] . "',
        '" . $value['FixedAmount'] . "',
        '" . $value['PercentageAmount'] . "',
        '" . $value['ExpiryDate'] . "',
        '" . $Active . "',
        'Issued',
          now(),
        'false',
        'false',
    now())";
    // echo  $sql;
    if (mysqli_query($conn, $sql)) {
    }
}


$curl_post_data = array(
    'Success' => 'true',
    'Reason' => 'You Have Succesfully Generated Coupons',
);
echo json_encode($curl_post_data);


// }


// echo json_encode($obj);
