Fixed focus after error display.
[fa-stable.git] / purchasing / inquiry / supplier_allocation_inquiry.php
index 8d306f1c2e36613488c225e3aebc88c2579a7a62..cc15d580da095e771b02f18ad5df46e4af23c200 100644 (file)
@@ -40,11 +40,11 @@ supplier_list_cells(_("Select a supplier: "), 'supplier_id', $_POST['supplier_id
 date_cells(_("From:"), 'TransAfterDate', '', null, -30);
 date_cells(_("To:"), 'TransToDate', '', null, 1);
 
-supp_allocations_list_cells("filterType", null);
+supp_allocations_list_cell("filterType", null);
 
 check_cells(_("show settled:"), 'showSettled', null);
 
-submit_cells('Refresh Inquiry', _("Search"));
+submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true);
 
 set_global_supplier($_POST['supplier_id']);
 
@@ -109,35 +109,39 @@ function get_transactions()
 //------------------------------------------------------------------------------------------------
 
 $result = get_transactions();
-
-if (db_num_rows($result) == 0)
+//------------------------------------------------------------------------------------------------
+if(get_post('RefreshInquiry')) 
 {
-       display_note(_("There are no transactions to display for the given dates."), 1, 1);
-       end_page();
-       exit;
+       $Ajax->activate('doc_tbl');
 }
 
 //------------------------------------------------------------------------------------------------
 
 /*show a table of the transactions returned by the sql */
 
-start_table("$table_style width=90%");
-if ($_POST['supplier_id'] == reserved_words::get_all())
+div_start('doc_tbl');
+if (db_num_rows($result) == 0)
+{
+       display_note(_("There are no transactions to display for the given dates."), 1, 1);
+} else
+{
+  start_table("$table_style width=90%");
+  if ($_POST['supplier_id'] == reserved_words::get_all())
        $th = array(_("Type"), _("Number"), _("Reference"), _("Supplier"),
                _("Supp Reference"), _("Date"), _("Due Date"), _("Currency"),
                _("Debit"), _("Credit"), _("Allocated"), _("Balance"), "");
-else
+  else
        $th = array(_("Type"), _("Number"), _("Reference"),     _("Supp Reference"), _("Date"), _("Due Date"),
                _("Debit"), _("Credit"), _("Allocated"), _("Balance"), "");
-table_header($th);
+  table_header($th);
 
-$j = 1;
-$k = 0; //row colour counter
-$over_due = false;
-while ($myrow = db_fetch($result))
-{
+  $j = 1;
+  $k = 0; //row colour counter
+  $over_due = false;
+  while ($myrow = db_fetch($result))
+  {
 
-       if ($myrow['OverDue'] == 1)
+       if (($myrow['TotalAmount']>$myrow['Allocated']) && $myrow['OverDue'] == 1)
        {
                start_row("class='overduebg'");
                $over_due = true;
@@ -174,8 +178,6 @@ while ($myrow = db_fetch($result))
                $balance = $myrow["TotalAmount"] - $myrow["Allocated"];
        amount_cell($balance);
 
-       //if (($myrow["type"] == 1 || $myrow["type"] == 21 || $myrow["type"] == 22) &&
-       //      $myrow["Void"] == 0)
        if (($myrow["type"] == 1 || $myrow["type"] == 21 || $myrow["type"] == 22) &&
                $balance > 0)
        {
@@ -193,13 +195,14 @@ while ($myrow = db_fetch($result))
                $j = 1;
                table_header($th);
        }
-//end of page full new headings if
-}
-//end of while loop
+  //end of page full new headings if
+  }
+  //end of while loop
 
-end_table(1);
-if ($over_due)
+  end_table(1);
+  if ($over_due)
        display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'");
-
+}
+div_end();
 end_page();
 ?>