<?php

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

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

$std = new stdClass();

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

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

if (is_null($id)) {
    $error = 'Token missing in request body';
    $std->error = $error;
    echo (json_encode($std));
    die();
} else {
    $paid = PAID;
    mysqli_query($link, "update withdrawals set status = '$paid' where `date` = $id and `user` = '$user'");
    if (mysqli_affected_rows($link) == 1) {
        $std->msg = PAID;
       // User::sendNotice1($email, $link, $amount);
        echo (json_encode($std));
        die();
    } else {
        $error = 'Already updated';
        $std->error = $error;
        echo (json_encode($std));
        die();
    }
}

