Hello I have two Tables:
1. Clients (ID, Name, Points)
2. Sales (ID_Clients, Product (10, for example), …)
After Sales registering, I need it update Points Col in Clients table limit 90, using method on_after_insert based in ID_Clients col and ID in Clients table.
When Points in clients > 90, update to Zero (0) to start cicle again.
I tried using Views in Mysql but It´s with bugs and very bad option…
Thanks by your help!
It should work with on_after_insert.
If you email me code, i can suggest the changes.
Hello Abu,
This is working with basic update on_after_insert method:
function bonus_data($data)
{
$t = $data["params"]["reference_no"];
$client_id = $data["params"]["customer_id"];
global $h;
$h->execute_query("UPDATE sma_companies SET award_points = '$t' WHERE id = '$client_id'");
}
I would like to update award_points using previously If or Case statements, If award_points < 180 then points = award_points + award_points else then set to zero.
Thank you
Hello Abu,
I´m trying with this function:
function bonus_data($data)
{
$t = $data["params"]["reference_no"];
$client_id = $data["params"]["customer_id"];
global $h;
$h->execute_query("select award_points from sma_companies WHERE id = '$client_id'");
$puntos = $h;
if ($puntos < "180") {
$t=$data["params"]["reference_no"];
global $h;
$h->execute_query("UPDATE sma_companies SET award_points = '$t' + '$puntos' WHERE id = '$client_id'");
}
else
if ($puntos > "180")
{
$t=$data["params"]["reference_no"];
global $h;
$h->execute_query("UPDATE sma_companies SET award_points = '$t' WHERE id = '$client_id'");
}
}
This is updating award_points Col, but I need Sum award_points to previous value until award_points > 180.
Thanks by your help!
Abu, I need this to load on_after_insert method, It´s possible right now but just updating previous values. So I need select the Previous Col to update accumulating data.
Thank you by your help!
I understand now, you can change query to:
$res = $h->execute_query("select award_points from sma_companies WHERE id = '$client_id'");
$arr = $res->GetRows();
$puntos = $arr["award_points"];
Ok Abu,
Phpgrid_error is:
<tr id="FormError">
It´s not taking row data, this is the problem!
Thanks by tour help
Show me this:
Uncaught TypeError: Cannot read property 'id' of undefined
Thank you!