This topic is locked

Totals on Invoice Header

8/1/2016 2:53:07 AM
PHPRunner General questions
P
peterp author

Hi All,

I have followed the 'Calculate Order Totals on the fly" and this works fine but now what I want to do is to substitute the manually input unit price with a unit price from an Inventory table and use that price in the total calculation. I have managed to get the individual lines to recognize the inventory item but unfortunately I'm unable to get the calculation to accept the inventories unit price. I'm doing something wrong and have no idea what. Hopefully somebody can help me with what code I have to insert to make this work, any help will be greatly appreciated.

Best Regards,

Peterp

romaldus 8/1/2016



Hi All,

I have followed the 'Calculate Order Totals on the fly" and this works fine but now what I want to do is to substitute the manually input unit price with a unit price from an Inventory table and use that price in the total calculation. I have managed to get the individual lines to recognize the inventory item but unfortunately I'm unable to get the calculation to accept the inventories unit price. I'm doing something wrong and have no idea what. Hopefully somebody can help me with what code I have to insert to make this work, any help will be greatly appreciated.

Best Regards,

Peterp


[size="3"]Why you input unit price manually? Use phprunner autofill feature to fill price field automatically [/size]
[size="3"]btw.. post your question here:[/size]

[size="3"]http://www.asprunner.com/forums/forum/4-phprunner-general-questions/

[/size]

P
peterp author 8/2/2016



[size="3"]Why you input unit price manually? Use phprunner autofill feature to fill price field automatically [/size]
[size="3"]btw.. post your question here:[/size]

[size="3"]http://www.asprunner.com/forums/forum/4-phprunner-general-questions/

[/size]


Hi romaldus,

Thanks so much for this solution and it works just fine however I now have another couple of problems and as I'm very new with JavaScript and SQL I'm hoping you can assist me. The first problem I have is that when ADDing a new order with multiple order lines this is all fine after saving this order I then go into it to edit the quantities and JavaScript that I'm using (see Below) also I have included the javascript call in the ADD and EDIT editor pae at the end and also added this code to the javascript on load event
var ctrlPrice = Runner.getControl(pageid, 'price');

var ctrlQuantity = Runner.getControl(pageid, 'quantity');

var ctrlTotal = Runner.getControl(pageid, 'total')

ctrlPrice.on('change, keyup', function(e){calcTotals();});

ctrlQuantity.on('change, keyup', function(e){calcTotals();});
// JavaScript Document

function calcTotals() {

var total=0;

$("tr[id=gridRow]").each(function() {

var id=$(this).attr('id');

id = id.substring(7);

t=+($("#valueprice"+id).val()
$("#valuequantity"+id).val());

if (t>0) total+= t;

});
$("#value_total_1").val(total);

};
doesn't take into consideration that there are multiple lines within the order details and therefore when you change the order quantity the total in the order header only reflects the line that is currently being edited and not any of the others, hence this new total gets written to the order header which then does not reflect all of the line items. So my question is what do I have to put into the JavaScript so as to prompt the recalculation of the order header total.

The second question is it possible to remove the up and down arrows for each input field and also make the order header total field uneditable.
The project I'm working with is the same as the documented one call "calculating order totals on the fly" which is in the PHPRunner 8.1 tips and tricks forum.
I hope you are able to help me or point me in the right direction your help is greatly appreciated.

Best Regards,

Peterp