check_user($investor_id);
if($validate_user == "" || empty($validate_user)) {
redirect_to("rm_root.php?msg=Invalid User!");
return false;
}
$update_bal = null;
if ($assetType == "RMT") {
$assetType = "btc";
} elseif ($assetType == "Cash") {
$assetType = "traditional";
} else {
redirect_to("rm_root.php?msg=Invalid balance type!");
return false;
}
/*Restrict decimal places while updating balance*/
if ($assetType == "traditional") {
if (!validate_decimal_place($balance, 2)) {
redirect_to("rm_root.php?msg=Max 2 decimal places allowed in Fiat balance.!");
return false;
}
} else if ($assetType == "btc") {
if (!validate_decimal_place($balance, 10)) {
redirect_to("rm_root.php?msg=Max 10 decimal places allowed in RMT balance.!");
return false;
}
}
//Prev balance of user
$bal_prev = (float) $OrderClass->check_customer_balance($assetType, $investor_id)->Balance;
$update_bal = $OrderClass->update_user_balance($assetType, $balance, $investor_id);
if (!$update_bal) {
redirect_to("rm_root.php?msg=Failed to update balance!");
return false;
} else if($update_bal) {
// Record this change
$OrderClass->record_root_bal_update($investor_id, $bal_prev, $balance, $assetType);
redirect_to("rm_root.php?msg=Successfully updated balance!&type=info");
} else {
redirect_to("rm_root.php?msg= Something went wrong. Failed to update balance!");
return false;
}
} else {
redirect_to("rm_root.php?msg= Please fill all fields!");
return false;
}
}
$traders = $OrderClass->UserBalanceList(1);
?>