<?php 
require 'db.php';
$data = json_decode(file_get_contents('php://input'), true);

if($data['shop_name'] == '' || $data['owner_name'] == '' || $data['mobile'] == '' || $data['ref_code'] == '' || $data['subscription_plan'] == '' || $data['subscription_amount'] == '' || $data['pay_date'] == '' || $data['pay_time'] == '' )
{
    $returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Something Went Wrong!");    
}
else
{
    $shopname =  $data['shop_name'];
    $ownername = $data['owner_name'];
    $mobile = $data['mobile'];
    $ref_code = $data['ref_code'];
    $sub_plan = $data['subscription_plan'];
    $sub_amount = $data['subscription_amount'];
    $pay_date = $data['pay_date'];
    $pay_time = $data['pay_time'];
    
    if($sub_plan == "1")
    {
      $sub_period = "1 Month";
    }
    else if($sub_plan == "2")
    {
        $sub_period = "3 Months";
    }
    else if($sub_plan == "3")
    {
        $sub_period = "6 Months";
    }
    else if($sub_plan == "4")
    {
        $sub_period = "1 Year";
    }

    $con->query("insert into `subscription_orders`(`shop_name`,`owner_name`,`mobile_no`,`sub_plan`,`sub_period`,`sub_amount`,`pay_date`,`pay_time`,`ref_code`)values('".$shopname."','".$ownername."','".$mobile."','".$sub_plan."','".$sub_period."','".$sub_amount."','".$pay_date."','".$pay_time."','".$ref_code."')");
    
    $returnArr = array("ResponseCode"=>"200","Result"=>"true","ResponseMsg"=>"Order Save Successfully");
}

echo json_encode($returnArr);
?>