This topic is locked

Dependant Calculations

7/6/2009 5:53:04 AM
PHPRunner General questions
G
Greeham author

Hi All,
Bare with me here:-
I have a tabel with many fields, the ones I namely need to use are:-
select

factpricepart,

factpricelab,

factpricepart+ factpricelab as factpricetot,

markup,

listpricepound,

exchrate,

listpricedollar,

transferprice

FROM instspares
Now I need to do some calculations on these and am not sure where to do it, through the SQL query or through Event processing.
The calculations:-
factpricetot is self explantory

listpricepound i need to be calculated depending on the value of factpricetot. So if factpricetot is <5 I want to multiply by 20 and if <10 multiply by 10 etc
So if factpricetot is 9, then listpricepound would be 9*10=90
The other calculation is for the transferprice, this needs to be the listpricepound less 10%, which is easy to do by the sql query but if the customer is in the US, then I need to factor in a user entered exchange rate and then use that value instead of listpricepound.
All confusing I know, but any help would be much appreciated.
Thanks,
Graham

J
Jane 7/6/2009

Hi,
use Before record added/Before record updated events on the Events tab for this purpose.

Here is a sample:

if ($values["factpricetot"]<5)

$values["listpricepound"] = $values["factpricetot"]*20;

G
Greeham author 7/6/2009

Hi Jane,
I tried the following in BeforeRecord Updated:-
global $conn;
if ($values["factpricetot"]<5)

$values["listpricepound"] = $values["factpricetot"]20;

if ($values["factpricetot"]<10)

$values["listpricepound"] = $values["factpricetot"]
10;

if ($values["factpricetot"]<100)

$values["listpricepound"] = $values["factpricetot"]4;

if ($values["factpricetot"]<500)

$values["listpricepound"] = $values["factpricetot"]
2;

if ($values["factpricetot"]<2500)

$values["listpricepound"] = $values["factpricetot"]1.5;

if ($values["factpricetot"]<15000)

$values["listpricepound"] = $values["factpricetot"]
1.25;

$values["listpricedollar"]=$values["listpricepound"]$values["exchrate"];

$values["transferprice"]=$values["listpricepound"]-(($values["listpricepound"]/100)
10);

return true;
And it doesn't work, have I missed something?
Thanks,
Graham

J
Jane 7/7/2009

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

K
kondur 7/7/2009

Try to use the JavaScript for the calculations. I had the same situation.

G
Greeham author 7/8/2009

Try to use the JavaScript for the calculations. I had the same situation.


Hi,
Have you got a sample?
Thanks,
Graham
P.S Jane, my support has run out, can I still get help by posting to Demo?

J
Jane 7/8/2009

Graham,
I recommend you to contact support@xlinesoft.com directly with this question.

K
kondur 7/8/2009

<script>

var a1 = document.forms.editform.value_order_quantity1;

var b1 = document.forms.editform.value_carton_EA1;

var c1 = document.forms.editform.value_cost_EA1;

var d1 = document.forms.editform.value_extended1;

var e1 = document.forms.editform.value_master1;

a1.onchange = a1.onkeyup = b1.onchange = b1.onkeyup = c1.onchange = c1.onkeyup = d1.onchange = d1.onkeyup = e1.onchange = e1.onkeyup = function()
{

var or1 = document.forms.editform.value_order_quantity1.value;

var crEA1 = document.forms.editform.value_carton_EA1.value;

var coEA1 = document.forms.editform.value_cost_EA1.value;

var ex1 = document.forms.editform.value_extended1.value;

var ma1 = document.forms.editform.value_master1.value;
document.forms.editform.value_carton_EA1.value = Number(or1/ma1);

document.forms.editform.value_extended1.value = Number(or1*coEA1);
document.editform.value_quantity.value =Number(document.editform.value_order_quantity1.value);

document.forms.editform.value_extened_amount.value = Number(document.editform.value_extended1.value);
document.forms.editform.value_cartons.value =Number(document.editform.value_carton_EA1.value);
}
</SCRIPT>