Changed the Running Balance column in Customer Transaction to only show when the...
[fa-stable.git] / sales / inquiry / customer_inquiry.php
index b2764d465595a2be828cda60e3f59921c316d165..de745b5a1a86ff07ee19777f18da28b01af050ae 100644 (file)
@@ -216,10 +216,16 @@ function check_overdue($row)
                debtor.name, 
                branch.br_name,
                debtor.curr_code,
-               @bal := @bal+trans.ov_amount,
                (trans.ov_amount + trans.ov_gst + trans.ov_freight 
-                       + trans.ov_freight_tax + trans.ov_discount)     AS TotalAmount, 
-               trans.alloc AS Allocated,
+                       + trans.ov_freight_tax + trans.ov_discount)     AS TotalAmount, "; 
+       if ($_POST['filterType'] != ALL_TEXT)
+               $sql .= "@bal := @bal+(trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount), ";
+
+//     else
+//             $sql .= "IF(trans.type=".ST_CUSTDELIVERY.",'', IF(trans.type=".ST_SALESINVOICE." OR trans.type=".ST_BANKPAYMENT.",@bal := @bal+
+//                     (trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount), @bal := @bal-
+//                     (trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount))) , ";
+               $sql .= "trans.alloc AS Allocated,
                ((trans.type = ".ST_SALESINVOICE.")
                        AND trans.due_date < '" . date2sql(Today()) . "') AS OverDue
                FROM "
@@ -280,20 +286,22 @@ $cols = array(
        _("Customer") => array('ord'=>''), 
        _("Branch") => array('ord'=>''), 
        _("Currency") => array('align'=>'center'),
-       _("RB"),
        _("Debit") => array('align'=>'right', 'fun'=>'fmt_debit'), 
        _("Credit") => array('align'=>'right','insert'=>true, 'fun'=>'fmt_credit'), 
+       _("RB") => array('align'=>'right', 'type'=>'amount'),
                array('insert'=>true, 'fun'=>'gl_view'),
                array('insert'=>true, 'fun'=>'credit_link'),
                array('insert'=>true, 'fun'=>'edit_link'),
                array('insert'=>true, 'fun'=>'prt_link')
        );
 
+
 if ($_POST['customer_id'] != ALL_TEXT) {
        $cols[_("Customer")] = 'skip';
        $cols[_("Currency")] = 'skip';
 }
-
+if ($_POST['filterType'] == ALL_TEXT)
+       $cols[_("RB")] = 'skip';
 
 $table =& new_db_pager('trans_tbl', $sql, $cols);
 $table->set_marker('check_overdue', _("Marked items are overdue."));