Skip to content

Instantly share code, notes, and snippets.

@c3media
Last active December 9, 2019 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c3media/9240d9ff5f5c4eb0ea897aec2454b838 to your computer and use it in GitHub Desktop.
Save c3media/9240d9ff5f5c4eb0ea897aec2454b838 to your computer and use it in GitHub Desktop.
function delete_budget($data)
{
date_default_timezone_set('America/Bogota');
//$data["params"]["date"] = date("Y-m-d H:i:s");
$client_id = $data["params"]["tickets_id"];
$budget_id = $data["params"]["id"];
global $g;
/* Code to show errors
ob_start();
print_r($data);
$str = ob_get_clean();
phpgrid_error($str);
*/
$restic = $g->execute_query("select id, tickets_id, total from ticket_budget WHERE id = '$budget_id'");
#phpgrid_error($h->con->errormsg());
$arrtic = $restic->GetRows();
#phpgrid_error($arr);
$tickets_id = $arrtic[0]["tickets_id"];
$total_delete = $arrtic[0]["total"];
$restica = $g->execute_query("select id, ticket_budget_total from tickets WHERE id = '$client_id'");
#phpgrid_error($h->con->errormsg());
$arrtica = $restica->GetRows();
#phpgrid_error($arr);
$ticket_budget_total = $arrtica[0]["ticket_budget_total"];
$total_budget = $ticket_budget_total - $total_delete;
$g->execute_query("UPDATE tickets SET ticket_budget_total = '$total_budget' WHERE id = '$client_id'");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment