Ajax additions
[fa-stable.git] / sales / inquiry / customer_allocation_inquiry.php
index 5606cbf83df1f5c45328f87fa5787170d9f272f5..2770fb22bf5357f21be8a18d323b5656fce5441c 100644 (file)
@@ -31,14 +31,14 @@ start_row();
 
 customer_list_cells(_("Select a customer: "), 'customer_id', $_POST['customer_id'], true);
 
-date_cells(_("from:"), 'TransAfterDate', null, -30);
-date_cells(_("to:"), 'TransToDate', null, 1);
+date_cells(_("from:"), 'TransAfterDate', '', null, -30);
+date_cells(_("to:"), 'TransToDate', '', null, 1);
 
 cust_allocations_list_cells(_("Type:"), 'filterType', null);
 
 check_cells(" " . _("show settled:"), 'showSettled', null);
 
-submit_cells('Refresh Inquiry', _("Search"));
+submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true);
 
 set_global_customer($_POST['customer_id']);
 
@@ -116,16 +116,19 @@ function get_transactions()
 
 $result = get_transactions();
 
-if (db_num_rows($result) == 0)
+//------------------------------------------------------------------------------------------------
+if(get_post('RefreshInquiry')) 
 {
-       display_note(_("The selected customer has no transactions for the given dates."), 1, 1);
-       end_page();
-       exit;
+       $Ajax->activate('doc_tbl');
 }
-
 //------------------------------------------------------------------------------------------------
+div_start('doc_tbl');
+if (db_num_rows($result) == 0)
+{
+       display_note(_("The selected customer has no transactions for the given dates."), 1, 1);
+} else {
 
-start_table("$table_style width='80%'");
+       start_table("$table_style width='80%'");
 
 if ($_POST['customer_id'] == reserved_words::get_all())
        $th = array(_("Type"), _("Number"), _("Reference"), _("Order"), _("Date"), _("Due Date"),
@@ -172,8 +175,8 @@ while ($myrow = db_fetch($result))
                $allocations_str = $allocations;
 
        }
-       elseif ($myrow["type"] == systypes::cust_payment() &&
-               ($myrow['TotalAmount'] + $myrow['Allocated']) > 0)
+       elseif (($myrow["type"] == systypes::cust_payment() || $myrow["type"] == systypes::bank_deposit()) &&
+               ($myrow['TotalAmount'] - $myrow['Allocated']) > 0)
        {
                /*its a receipt  which could have an allocation*/
                $allocations_str = $allocations;
@@ -185,8 +188,7 @@ while ($myrow = db_fetch($result))
        }
 
        label_cell(systypes::name($myrow["type"]));
-
-       label_cell(get_customer_trans_view_str($myrow["type"], $myrow["trans_no"]));
+       label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"]));
        label_cell($myrow["reference"]);
        label_cell($preview_order_str);
        label_cell(sql2date($myrow["tran_date"]), "nowrap");
@@ -196,7 +198,9 @@ while ($myrow = db_fetch($result))
                label_cell($myrow["CustName"]);
                label_cell($myrow["CustCurrCode"]);
        }
-       display_debit_or_credit_cells($myrow["TotalAmount"]);
+       display_debit_or_credit_cells(
+           $myrow['type']==11 || $myrow['type']==12 || $myrow['type']==2 ?
+               -$myrow["TotalAmount"] : $myrow["TotalAmount"]);
        amount_cell(abs($myrow["Allocated"]));
        amount_cell(abs($myrow["TotalAmount"]) - $myrow["Allocated"]);
        label_cell($allocations_str);
@@ -213,11 +217,11 @@ while ($myrow = db_fetch($result))
 //end of page full new headings if
 }
 //end of while loop
-
 end_table(1);
 if ($over_due)
        display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'");
-
+}
+div_end();
 end_page();
 
 ?>