AJAX File not working

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
uchhavi
Veteran Member
Posts: 66
Joined: 2018-05-15 14:07

AJAX File not working

Post by uchhavi » 2019-05-29 09:52

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
Best regards,

Chhavi Jain

User avatar
a.gneady
Site Admin
Posts: 1033
Joined: 2012-09-27 14:46
Contact:

Re: AJAX File not working

Post by a.gneady » 2019-06-02 11:10

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
));
:idea: Learn all the tips and tricks of customizing AppGini apps through our online course.
:arrow: Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
:arrow: Summary Reports plugin: Build powerful reports and charts for your AppGini apps.
:arrow: Search Page Maker: Compose user-friendly yet powerful search pages for your AppGini apps.

Post Reply