<?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 = array();
$data = json_decode(file_get_contents('php://input'), true);
$sql = "SELECT * FROM global_settings ";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {

        $sql_two = "UPDATE global_settings SET
                maximum_advance='" . $_GET["maximum_advance"] . "',
                currency='" . $_GET["currency"] . "',
                maximum_no_kids='" . $_GET["maximum_no_kids"] . "',
                parent_discount='" . $_GET["parent_discount"] . "'
                WHERE global_settings_id='" . $row["global_settings_id"] . "'
                ";
        if (mysqli_query($conn, $sql_two)) {

            $new_array = array(
                'Success' => "true",
                'Reason' => "You have succesfully Updated settings",


            );
            echo json_encode($new_array);
        } else {
            $new_array = array(
                'Success' => "false",
                'Reason' => "You were unable to succesfully Update settings",

            );
            echo json_encode($new_array);
        }
    }
} else {

    $sql_two = "INSERT INTO global_settings VALUES(NULL,
         '0', '0', '0', '0', '0', '0', '0',
         '" . $_GET["maximum_advance"] . "',
         '" . $_GET["currency"] . "',
         '0', '" . $_GET["maximum_no_kids"] . "', '0',
         '" . $_GET["parent_discount"] . "',  '0',  '0', '0', '0', '0', 'false', 'false', 'false', 'false',  now() )";
    if (mysqli_query($conn, $sql_two)) {
        $new_array = array(
            'Success' => "true",
            'Reason' => "You have succesfully Updated settings",
        );
        echo json_encode($new_array);
    } else {
        $new_array = array(
            'Success' => "false",
            'Reason' => "You were unable to succesfully Update settings",
        );
        echo json_encode($new_array);
    }
}
