Page 1 of 1

AJAX File not working

Posted: 2019-05-29 09:52
by uchhavi
Hello,

Please help me.

I followed the appgini video tuitorial but somehow this is not working.

SO i have 2 tables Sales Order and Items Ordered.

In the Items ordered table there is Unit Price and Quantity and then there is subtotal of each item ordered.
The subtotal bit I was able to go following the tuitorial.

Now I need to copy the grand total of all the subtotals to the sales order table in the order_value field and add the currency_conversion to this and then put the total in another field names order_value_myr.

I follow your tuitorial and made the ajax file. Below is the code for the same:

Code: Select all

	<?php
	$currDir = dirname(__FILE__) . '/..';
	include("$currDir/defaultLang.php");
	include("$currDir/language.php");
	include("$currDir/lib.php");

	/* grant access to all users who have access to the sales orders table */
	$od_from = get_sql_from('sales_orders');
	if(!$od_from){
		header('HTTP/1.0 401 Unauthorized');
		exit;
	}

	$id = intval($_REQUEST['id']);
	if(!$id) exit;

	$grand_total = sqlValue("select sum(total_price) from item_orders where sale_order_id='{$id}'");
	$currency_conv = sqlValue("select currency_conversion from sales_orders where sale_order_id='{$id}'");
	
	$order_value_myr = $grand_total * $currency_conv;

	sql("UPDATE sales_orders SET order_value_myr='{$order_value_myr}' WHERE sale_order_id='{$id}'", $eo);

	echo number_format($order_value_myr, 2);
	
[/b]

Firstly when i try to directly execute this code from the taskbar by typing "http://localhost/crm_mp1/hooks/ajax-ord ... hp?id=1000"

The value is not coming...

Please can you advise me what is the issue with the code....

I am really stuck here .. and i really need help here please

Re: AJAX File not working

Posted: 2019-06-02 11:10
by a.gneady
I don't seem to find any issues in your code ... could you try doing some debugging? Try adding this code at the end:

Code: Select all

var_dump(array(
    'id' => $id,
    'grand_total' => $grand_total,
    'currency_conv' => $currency_conv,
    'order_value_myr' => $order_value_myr
));