<?php
$response = new stdClass();
$total = array();
//var_dump($_POST);exit();
if (isset($_POST["add_i"]) && isset($_POST["AA_ACNO"]) && is_numeric($_POST["add_i"]) && $_POST["add_i"] > 0) {
    $conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
    if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
    if ($conn->query("UPDATE  `" . $GLOBALS['arif_ac'] . "` SET  `AA_BAL` =  `AA_BAL`+" . $_POST["add_i"] . " , `AA_NO_OF_PAYPAID` =  `AA_NO_OF_PAYPAID`+1 WHERE  `AA_ACNO` = '" . $_POST["AA_ACNO"] . "'"));
    //Add entry to Transaction
    {
        $AT_USER = $_SESSION['EMAIL'];
        if ($conn->query("INSERT INTO `" . $GLOBALS['arif_tran'] . "` (`AT_ID`, `AT_TIMESTAMP`, `AT_ADMIN`, `AT_ACID`, `AT_AMOUNT`) VALUES (NULL, CURRENT_TIMESTAMP, '" . $AT_USER . "', '" . $_POST["AA_ACNO"] . "', '" . $_POST["add_i"] . "')")){
            $total['status'] = 'Success';
            $total['statusmsg'] = 'Transaction Successful!';
        }
        else {
            $total['status'] = 'Error';
            $total['statusmsg'] = 'Error in Config';
        }
    }
    $conn->close();
} else  {
    $total['status'] = 'Error';
    $total['statusmsg'] = 'Error!! Check Input Details'.$_POST["add_i"].$_POST["AA_ACNO"];
    }

$response = $total;
echo json_encode($response);
?>