Fixed allocation date for customer payments entry, additional fixes for strict sql...
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Thu, 10 Jan 2019 15:29:01 +0000 (16:29 +0100)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Thu, 10 Jan 2019 15:30:24 +0000 (16:30 +0100)
includes/db/audit_trail_db.inc
sales/customer_payments.php

index 6aa91d9833689c0fdfd4db3a70f2f653f747ab08..feb85a991f744b6ed3facf54fd4fffaff18d7964 100644 (file)
@@ -16,17 +16,17 @@ function add_audit_trail($trans_type, $trans_no, $trans_date, $descr='')
 
        $date = date2sql($trans_date);
        $sql = "INSERT INTO ".TB_PREF."audit_trail"
 
        $date = date2sql($trans_date);
        $sql = "INSERT INTO ".TB_PREF."audit_trail"
-               . " (type, trans_no, user, gl_date, description)
+               . " (type, trans_no, user, gl_date, description, stamp)
                        VALUES(".db_escape($trans_type).", ".db_escape($trans_no).","
                        . $_SESSION["wa_current_user"]->user . ","
                        VALUES(".db_escape($trans_type).", ".db_escape($trans_no).","
                        . $_SESSION["wa_current_user"]->user . ","
-                       . "'$date',". db_escape($descr). ")";
+                       . "'$date',". db_escape($descr). ", CURRENT_TIMESTAMP)";
 
        db_query($sql, "Cannot add audit info");
        // all audit records beside just inserted one should have gl_seq set to NULL
        // to avoid need for subqueries (not existing in MySQL 3) all over the code
        $sql = "UPDATE ".TB_PREF."audit_trail audit LEFT JOIN ".TB_PREF."fiscal_year year ON year.begin<='$date' AND year.end>='$date'
                SET audit.gl_seq = IF(audit.id=".db_insert_id().", 0, NULL),"
 
        db_query($sql, "Cannot add audit info");
        // all audit records beside just inserted one should have gl_seq set to NULL
        // to avoid need for subqueries (not existing in MySQL 3) all over the code
        $sql = "UPDATE ".TB_PREF."audit_trail audit LEFT JOIN ".TB_PREF."fiscal_year year ON year.begin<='$date' AND year.end>='$date'
                SET audit.gl_seq = IF(audit.id=".db_insert_id().", 0, NULL),"
-               ."audit.fiscal_year=year.id"
+               ."audit.fiscal_year=year.id, stamp=CURRENT_TIMESTAMP"
                . " WHERE type=".db_escape($trans_type)." AND trans_no="
                . db_escape($trans_no);
 
                . " WHERE type=".db_escape($trans_type)." AND trans_no="
                . db_escape($trans_no);
 
index 592d0e7f903c95986eb607f7aa71b29aa82d4893..f314b9889b250f05289022009bdeaa913de51644 100644 (file)
@@ -243,6 +243,7 @@ if (get_post('AddPaymentItem') && can_process()) {
                input_num('amount'), input_num('discount'), $_POST['memo_'], 0, input_num('charge'), input_num('bank_amount', input_num('amount')));
 
        $_SESSION['alloc']->trans_no = $payment_no;
                input_num('amount'), input_num('discount'), $_POST['memo_'], 0, input_num('charge'), input_num('bank_amount', input_num('amount')));
 
        $_SESSION['alloc']->trans_no = $payment_no;
+       $_SESSION['alloc']->date_ = $_POST['DateBanked'];
        $_SESSION['alloc']->write();
 
        unset($_SESSION['alloc']);
        $_SESSION['alloc']->write();
 
        unset($_SESSION['alloc']);