Code cleanup
[fa-stable.git] / sales / inquiry / customer_inquiry.php
index db68dfdd36616e61c97812a895c88715a0e03657..715de08ae6495e2f2a429cfb4c18657f37be6a81 100644 (file)
@@ -29,19 +29,20 @@ if (!isset($_POST['customer_id']))
        $_POST['customer_id'] = get_global_customer();
 
 start_table("class='tablestyle_noborder'");
+start_row();
 
-customer_list_cells(_("Select a customer: "), 'customer_id', $_POST['customer_id'], true);
+customer_list_cells(_("Select a customer: "), 'customer_id', null, 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);
 
 if (!isset($_POST['filterType']))
        $_POST['filterType'] = 0;
 
 cust_allocations_list_cells(null, 'filterType', $_POST['filterType'], true);
 
-submit_cells('Refresh Inquiry', _("Search"));
-
+submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true);
+end_row();
 end_table();
 
 end_form();
@@ -146,44 +147,50 @@ function get_transactions()
 
 //------------------------------------------------------------------------------------------------
 
-if (($_POST['customer_id'] != "") && ($_POST['customer_id'] != reserved_words::get_all()))
+div_start('totals_tbl');
+if ($_POST['customer_id'] != "" && $_POST['customer_id'] != reserved_words::get_all())
 {
-       $customer_record = get_customer_details($_POST['customer_id']);
+       $customer_record = get_customer_details($_POST['customer_id'], $_POST['TransToDate']);
     display_customer_summary($customer_record);
     echo "<br>";
 }
-
+div_end();
 //------------------------------------------------------------------------------------------------
 
 $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."), 0, 2);
-       end_page();
-       exit;
+       $Ajax->activate('trans_tbl');
+       $Ajax->activate('totals_tbl');
 }
-
 //------------------------------------------------------------------------------------------------
-
 print_hidden_script(10);
-start_table("$table_style width='80%'");
+
+div_start('trans_tbl');
+if (db_num_rows($result) == 0)
+{
+       display_note(_("The selected customer has no transactions for the given dates."), 0, 2);
+} else {
+
+       start_table("$table_style width='80%'");
 
        $th = array(_("Type"), _("#"), _("Order"), _("Reference"), _("Date"), _("Due Date"),
                _("Customer"), _("Branch"), _("Currency"), _("Debit"), _("Credit"), "", "","","");
 
-if ($_POST['customer_id'] != reserved_words::get_all()) {
-  unset($th[6], $th[8]);
-}
+       if ($_POST['customer_id'] != reserved_words::get_all()) {
+         unset($th[6], $th[8]);
+       }
 
-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)
        {
@@ -269,19 +276,20 @@ while ($myrow = db_fetch($result))
                label_cell('');
        end_row();
 
-       $j++;
-       if ($j == 12)
-       {
-               $j = 1;
-               table_header($th);
-       } //end of page full new headings if
-} //end of transaction while loop
-
-end_table(1);
+               $j++;
+               if ($j == 12)
+               {
+                       $j = 1;
+                       table_header($th);
+               } //end of page full new headings if
+       } //end of transaction while loop
 
-if ($over_due)
-       display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'");
+       end_table(1);
 
+       if ($over_due)
+               display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'");
+}
+div_end();
 end_page();
 
 ?>