Preparing for Graphic Links final.Optimized.
[fa-stable.git] / sales / inquiry / customer_inquiry.php
index c9d64bdc00548033f60f05fbe14699c26ff10a60..b8e555bbc3389464550f2f4ab8bb81eee990b208 100644 (file)
@@ -1,5 +1,14 @@
 <?php
-
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU Affero General Public License,
+       AGPL, as published by the Free Software Foundation, either version 
+       3 of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/agpl-3.0.html>.
+***********************************************************************/
 $page_security = 1;
 $path_to_root="../..";
 include($path_to_root . "/includes/db_pager.inc");
@@ -45,9 +54,7 @@ cust_allocations_list_cells(null, 'filterType', $_POST['filterType'], true);
 submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true);
 end_row();
 end_table();
-
 end_form();
-
 set_global_customer($_POST['customer_id']);
 
 //------------------------------------------------------------------------------------------------
@@ -82,7 +89,7 @@ function display_customer_summary($customer_record)
        amount_cell($customer_record["Balance"]);
        end_row();
 
-       end_table();;
+       end_table();
 }
 //------------------------------------------------------------------------------------------------
 
@@ -95,8 +102,12 @@ if ($_POST['customer_id'] != "" && $_POST['customer_id'] != reserved_words::get_
 }
 div_end();
 
-
+if(get_post('RefreshInquiry'))
+{
+       $Ajax->activate('totals_tbl');
+}
 //------------------------------------------------------------------------------------------------
+
 function systype_name($dummy, $type)
 {
        return systypes::name($type);
@@ -142,23 +153,12 @@ function fmt_credit($row)
        return $value>0 ? price_format($value) : '';
 }
 
-function alloc_link($row)
-{
-       if ($row['type'] == 10)
-               if ($row["TotalAmount"] - $row["Allocated"] > 0)
-                       return pager_link(_("Allocation"),
-                               "/sales/allocations/customer_allocate.php"
-                               ."?trans_no={$row['trans_no']}&trans_type="
-                               .$row['type']);
-       return '';
-}
-
 function credit_link($row)
 {
        return $row['type'] == 10 ?
                pager_link(_("Credit This"),
                        "/sales/customer_credit_invoice.php?InvoiceNumber=".
-                       $row['trans_no'])
+                       $row['trans_no'], ICON_CREDIT)
                        : '';
 }
 
@@ -180,13 +180,13 @@ function edit_link($row)
                $str = "/sales/customer_delivery.php?ModifyDelivery=".$row['trans_no'];
                break;
        }
-       return pager_link(_('Edit'), $str);
+       return pager_link(_('Edit'), $str, ICON_EDIT);
 }
 
 function prt_link($row)
 {
        if ($row['type'] != 12) // customer payment printout not defined yet.
-               return print_document_link($row['trans_no'], _("Print"), true, $row['type']);
+               return print_document_link($row['trans_no'], _("Print"), true, $row['type'], ICON_PRINT);
 }
 
 function check_overdue($row)
@@ -219,7 +219,8 @@ function check_overdue($row)
                        .TB_PREF."cust_branch as branch
                WHERE debtor.debtor_no = trans.debtor_no
                        AND trans.tran_date >= '$date_after'
-                       AND trans.tran_date <= '$date_to'";
+                       AND trans.tran_date <= '$date_to'
+                       AND trans.branch_code = branch.branch_code";
 
        if ($_POST['customer_id'] != reserved_words::get_all())
                $sql .= " AND trans.debtor_no = '" . $_POST['customer_id'] . "'";
@@ -272,7 +273,6 @@ $cols = array(
        _("Debit") => array('align'=>'right', 'fun'=>'fmt_debit'), 
        _("Credit") => array('align'=>'right','insert'=>true, 'fun'=>'fmt_credit'), 
                array('insert'=>true, 'fun'=>'gl_view'),
-               array('insert'=>true, 'fun'=>'alloc_link'),
                array('insert'=>true, 'fun'=>'credit_link'),
                array('insert'=>true, 'fun'=>'edit_link'),
                array('insert'=>true, 'fun'=>'prt_link')
@@ -287,19 +287,14 @@ if ($_POST['customer_id'] != reserved_words::get_all()) {
 $table =& new_db_pager('trans_tbl', $sql, $cols);
 $table->set_marker('check_overdue', _("Marked items are overdue."));
 
-
-if(get_post('RefreshInquiry'))
-{
+if (get_post('RefreshInquiry')) {
        $table->set_sql($sql);
        $table->set_columns($cols);
-       $Ajax->activate('trans_tbl');
-       $Ajax->activate('totals_tbl');
 }
+start_form();
+display_db_pager($table);
 
-       start_form();
-       display_db_pager($table);
-       end_form();
+end_form();
 end_page();
 
-
 ?>