<?php

require_once '../../vendor/autoload.php';
require_once '../../include/DatabaseConn.php';
require_once '../../include/Constants.php';
require_once '../../models/User.php';

$db = new DatabaseConn();
$link = $db->connect();

$std = new stdClass();


$user = filter_input(INPUT_GET, "user");

header("content-type: application/json");

if (is_null($user)) {
    $error = 'Token missing in request body';
    $std->error = $error;
    echo (json_encode($std));
    die();
} else {
    mysqli_query($link, "update users set box = true where `email` = '$user'");
    if (mysqli_affected_rows($link) == 1) {
        $std->msg = PAID;
        $str = "Your weekly ROI will be compounded for 360 days. During this period, you may: <br /> 1.	Make a deposit to extend and continue receiving weekly ROI, or <br/>
	            2.	Initiate a new weekly ROI plan.";
          User::notify11($user, $str, "Compounding Wallet Activated");
        echo (json_encode($std));
        die();
    } else {
        $error = 'Already updated';
        $std->error = $error;
        echo (json_encode($std));
        die();
    }
}

