Moving 2.0 development version to main trunk.
[fa-stable.git] / purchasing / inquiry / supplier_allocation_inquiry.php
index e80201393fb07ba5b6c9f770db4cbb91b6c19b1c..2c3a6fae4702500f3cab0d3a9f5764c7dfb824b6 100644 (file)
@@ -37,14 +37,14 @@ start_row();
 
 supplier_list_cells(_("Select a supplier: "), 'supplier_id', $_POST['supplier_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);
 
-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']);
 
@@ -76,27 +76,27 @@ function get_transactions()
                $sql .= " AND ".TB_PREF."supp_trans.supplier_id = '" . $_POST['supplier_id'] . "'";
        if (isset($_POST['filterType']) && $_POST['filterType'] != reserved_words::get_all())
        {
-               if (($_POST['filterType'] == '1') || ($_POST['filterType'] == '2')) 
+               if (($_POST['filterType'] == '1') || ($_POST['filterType'] == '2'))
                {
                        $sql .= " AND ".TB_PREF."supp_trans.type = 20 ";
-               } 
-               elseif ($_POST['filterType'] == '3') 
+               }
+               elseif ($_POST['filterType'] == '3')
                {
                        $sql .= " AND ".TB_PREF."supp_trans.type = 22 ";
-               } 
-               elseif (($_POST['filterType'] == '4') || ($_POST['filterType'] == '5')) 
+               }
+               elseif (($_POST['filterType'] == '4') || ($_POST['filterType'] == '5'))
                {
                        $sql .= " AND ".TB_PREF."supp_trans.type = 21 ";
                }
 
-               if (($_POST['filterType'] == '2') || ($_POST['filterType'] == '5')) 
+               if (($_POST['filterType'] == '2') || ($_POST['filterType'] == '5'))
                {
                        $today =  date2sql(Today());
                        $sql .= " AND ".TB_PREF."supp_trans.due_date < '$today' ";
                }
        }
 
-       if (!check_value('showSettled')) 
+       if (!check_value('showSettled'))
        {
                $sql .= " AND (round(abs(ov_amount + ov_gst + ov_discount) - alloc,6) != 0) ";
        }
@@ -109,40 +109,44 @@ 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=80%");
-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           
+               _("Debit"), _("Credit"), _("Allocated"), _("Balance"), "");
+  else
        $th = array(_("Type"), _("Number"), _("Reference"),     _("Supp Reference"), _("Date"), _("Due Date"),
-               _("Debit"), _("Credit"), _("Allocated"), _("Balance"));
-table_header($th);
+               _("Debit"), _("Credit"), _("Allocated"), _("Balance"), "");
+  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)
        {
                start_row("class='overduebg'");
                $over_due = true;
-       } 
-       else 
+       }
+       else
        {
                alt_table_row_color($k);
        }
@@ -170,7 +174,7 @@ while ($myrow = db_fetch($result))
        amount_cell($myrow["Allocated"]);
        if ($myrow["type"] == 1 || $myrow["type"] == 21 || $myrow["type"] == 22)
                $balance = -$myrow["TotalAmount"] - $myrow["Allocated"];
-       else    
+       else
                $balance = $myrow["TotalAmount"] - $myrow["Allocated"];
        amount_cell($balance);
 
@@ -179,9 +183,11 @@ while ($myrow = db_fetch($result))
        if (($myrow["type"] == 1 || $myrow["type"] == 21 || $myrow["type"] == 22) &&
                $balance > 0)
        {
-               label_cell("<a href='$path_to_root/purchasing/allocations/supplier_allocate.php?trans_no=" .    
+               label_cell("<a href='$path_to_root/purchasing/allocations/supplier_allocate.php?trans_no=" .
                        $myrow["trans_no"]. "&trans_type=" . $myrow["type"] . "'>" . _("Allocations") . "</a>");
        }
+       else
+               label_cell("");
 
        end_row();
 
@@ -191,13 +197,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();
 ?>