Voided Documents Still Exist In Drop-down when printing. Fixed.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 13 Oct 2019 23:15:54 +0000 (01:15 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 13 Oct 2019 23:15:54 +0000 (01:15 +0200)
reporting/includes/reports_classes.inc

index 0d150930760c79f8c096e1599f1561f73c161a5a..276d988ea8fe4db56f9ee603201eae31cd580452 100644 (file)
@@ -317,8 +317,9 @@ class BoxReports
                                        $sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO,
                                                                concat('$IV ', debtor_trans.$ref,' ', debtor.name) as IName
                                                FROM ".TB_PREF."debtors_master debtor,"
-                                                       .TB_PREF."debtor_trans debtor_trans
-                                               WHERE type=".ST_SALESINVOICE." AND debtor.debtor_no=debtor_trans.debtor_no
+                                                       .TB_PREF."debtor_trans debtor_trans LEFT JOIN ".TB_PREF."voided AS vd ON debtor_trans.type=vd.type AND
+                                                       debtor_trans.trans_no=vd.id
+                                               WHERE debtor_trans.type=".ST_SALESINVOICE." AND debtor.debtor_no=debtor_trans.debtor_no AND ISNULL(vd.id)
                                                ORDER BY debtor_trans.trans_no DESC";
                                        return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
 
@@ -328,18 +329,20 @@ class BoxReports
                                        $sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO,
                                                                concat('$CN ', debtor_trans.$ref,' ', debtor.name) as IName
                                                FROM ".TB_PREF."debtors_master debtor,"
-                                                       .TB_PREF."debtor_trans debtor_trans
-                                               WHERE type=".ST_CUSTCREDIT." AND debtor.debtor_no=debtor_trans.debtor_no
+                                                       .TB_PREF."debtor_trans debtor_trans LEFT JOIN ".TB_PREF."voided AS vd ON debtor_trans.type=vd.type AND
+                                                       debtor_trans.trans_no=vd.id
+                                               WHERE debtor_trans.type=".ST_CUSTCREDIT." AND debtor.debtor_no=debtor_trans.debtor_no AND ISNULL(vd.id)
                                                ORDER BY debtor_trans.trans_no DESC";
                                        return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
 
                                case 'DELIVERY':
                                        $DN = $type_shortcuts[ST_CUSTDELIVERY];
-                                       $sql = "SELECT  concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO,
+                                       $sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO,
                                                                concat(debtor_trans.trans_no, ' $DN ', debtor.name) as IName
                                                FROM ".TB_PREF."debtors_master debtor,"
-                                                       .TB_PREF."debtor_trans debtor_trans
-                                               WHERE type=".ST_CUSTDELIVERY." AND debtor.debtor_no=debtor_trans.debtor_no
+                                                       .TB_PREF."debtor_trans debtor_trans LEFT JOIN ".TB_PREF."voided AS vd ON debtor_trans.type=vd.type AND
+                                                       debtor_trans.trans_no=vd.id
+                                               WHERE debtor_trans.type=".ST_CUSTDELIVERY." AND debtor.debtor_no=debtor_trans.debtor_no AND ISNULL(vd.id)
                                                ORDER BY debtor_trans.trans_no DESC";
                                        return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
 
@@ -358,7 +361,7 @@ class BoxReports
                                                FROM ".TB_PREF."debtors_master debtor,"
                                                        .TB_PREF."sales_orders sorder
                                                WHERE debtor.debtor_no=sorder.debtor_no AND sorder.trans_type=".ST_SALESQUOTE
-                                                       ." ORDER BY sorder.order_no DESC";
+                                               ." ORDER BY sorder.order_no DESC";
                                        return combo_input($name, '', $sql, 'order_no', 'IName',array('order'=>false));
 
                                case 'PO':
@@ -376,12 +379,14 @@ class BoxReports
                                        $CN = $type_shortcuts[ST_SUPPCREDIT];
                                        $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
                                        $sql = "SELECT concat(trans.trans_no, '-',trans.type) AS TNO,
-                                                               concat(trans.$ref, IF(type=".ST_BANKPAYMENT.", ' $BP ', IF(type=".ST_SUPPAYMENT.", ' $SP ', ' $CN ')), supplier.supp_name) as IName
-                                                       FROM ".TB_PREF."suppliers supplier, "
-                                                               .TB_PREF."supp_trans trans
-                                                       WHERE type IN(".ST_BANKPAYMENT.",".ST_SUPPAYMENT.",".ST_SUPPCREDIT.")
-                                                               AND supplier.supplier_id=trans.supplier_id
-                                                       ORDER BY trans.trans_no DESC";
+                                                               concat(trans.$ref, IF(trans.type=".ST_BANKPAYMENT.", ' $BP ', IF(trans.type=".ST_SUPPAYMENT.", ' $SP ', 
+                                                               ' $CN ')),
+                                                               supplier.supp_name) as IName
+                                               FROM ".TB_PREF."suppliers supplier, "
+                                                       .TB_PREF."supp_trans trans  LEFT JOIN ".TB_PREF."voided AS vd ON trans.type=vd.type AND trans.trans_no=vd.id
+                                               WHERE trans.type IN(".ST_BANKPAYMENT.",".ST_SUPPAYMENT.",".ST_SUPPCREDIT.") AND
+                                                       supplier.supplier_id=trans.supplier_id AND ISNULL(vd.id)
+                                               ORDER BY trans.trans_no DESC";
                                        return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
 
                                case 'RECEIPT':
@@ -389,10 +394,11 @@ class BoxReports
                                        $CP = $type_shortcuts[ST_CUSTPAYMENT];
                                        $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
                                        $sql = "SELECT concat(trans.trans_no, '-', trans.type) AS TNO,
-                                                               concat(trans.$ref, IF(type=".ST_BANKDEPOSIT.", ' $BD ', ' $CP '), debtor.name) as IName
+                                                               concat(trans.$ref, IF(trans.type=".ST_BANKDEPOSIT.", ' $BD ', ' $CP '), debtor.name) as IName
                                                FROM ".TB_PREF."debtors_master debtor,"
-                                                       .TB_PREF."debtor_trans trans
-                                               WHERE type IN(".ST_BANKDEPOSIT.",".ST_CUSTPAYMENT.",".ST_CUSTCREDIT.") AND debtor.debtor_no=trans.debtor_no
+                                                       .TB_PREF."debtor_trans trans LEFT JOIN ".TB_PREF."voided AS vd ON trans.type=vd.type AND trans.trans_no=vd.id
+                                               WHERE trans.type IN(".ST_BANKDEPOSIT.",".ST_CUSTPAYMENT.",".ST_CUSTCREDIT.") AND
+                                                       debtor.debtor_no=trans.debtor_no AND ISNULL(vd.id)
                                                ORDER BY trans.trans_no DESC";
                                        return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));