if MySQL is in strict sql mode, a couple of files didn't pass that.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 25 Sep 2008 15:04:31 +0000 (15:04 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 25 Sep 2008 15:04:31 +0000 (15:04 +0000)
CHANGELOG.txt
gl/gl_budget.php
includes/db/comments_db.inc
inventory/cost_update.php
purchasing/includes/db/supp_trans_db.inc
sales/includes/db/cust_trans_db.inc

index 396ceab14a2dbf4a9b3b9ed6891cddaee0cff30d..e80884b8050546538772b92e188d2d48149f1043 100644 (file)
@@ -19,6 +19,19 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+25-Sep-2008 Joe Hunt
+# if MySQL is in strict sql mode, a couple of files didn't pass that. Better not use strict sql mode.
+  This is not necessary, because FA handle this internally. in my.ini(win) or my.cnf(linux) set sql-mode="".
+$ /gl/gl_budget.php
+  /includes/db/comments_db.inc
+  /inventory/cost_update.php
+  /purchasing/includes/db/supp_trans_db.inc
+  /sales/includes/db/cust_trans_db.inc
+# Bug [0000060] table prefix error message and inconsistency at install
+$ /admin/db/maintenance_db.inc
+  /install/index.php
+  /install/save.php
+
 ------------------------------- Release 2.0.2 --------------------------------------------
 23-Sep-2008 Joe Hunt
 ! Release 2.0.2
index b503a61c5f3db15fccafdad1cfa6c7ad81796b9c..d9d4dde927b18fdeddd993c6f4eee1bea8b483df 100644 (file)
@@ -28,14 +28,14 @@ function exists_gl_budget($date_, $account, $dimension, $dimension2)
 function add_update_gl_budget_trans($date_, $account, $dimension, $dimension2, $amount)
 {
        $date = date2sql($date_);
-               
+
        if (exists_gl_budget($date, $account, $dimension, $dimension2))
                $sql = "UPDATE ".TB_PREF."budget_trans SET amount=$amount WHERE account='$account' AND
                        dimension_id=$dimension AND dimension2_id=$dimension2 AND tran_date='$date'";
        else
                $sql = "INSERT INTO ".TB_PREF."budget_trans (tran_date,
-                       account, dimension_id, dimension2_id, amount) VALUES ('$date',
-                       '$account', $dimension, $dimension2, $amount)";
+                       account, dimension_id, dimension2_id, amount, memo_) VALUES ('$date',
+                       '$account', $dimension, $dimension2, $amount, '')";
 
        db_query($sql, "The GL budget transaction could not be saved");
 }
@@ -43,18 +43,18 @@ function add_update_gl_budget_trans($date_, $account, $dimension, $dimension2, $
 function delete_gl_budget_trans($date_, $account, $dimension, $dimension2)
 {
        $date = date2sql($date_);
-               
+
        $sql = "DELETE FROM ".TB_PREF."budget_trans WHERE account='$account' AND
                        dimension_id=$dimension AND dimension2_id=$dimension2 AND tran_date='$date'";
        db_query($sql, "The GL budget transaction could not be deleted");
 }
 
-function get_only_budget_trans_from_to($from_date, $to_date, $account, $dimension=0, $dimension2=0) 
+function get_only_budget_trans_from_to($from_date, $to_date, $account, $dimension=0, $dimension2=0)
 {
 
        $from = date2sql($from_date);
        $to = date2sql($to_date);
-       
+
        $sql = "SELECT SUM(amount) FROM ".TB_PREF."budget_trans
                WHERE account='$account' AND tran_date >= '$from' AND tran_date <= '$to'
                 AND dimension_id = $dimension AND dimension2_id = $dimension2";
@@ -66,28 +66,28 @@ function get_only_budget_trans_from_to($from_date, $to_date, $account, $dimensio
 
 //-------------------------------------------------------------------------------------
 
-if (isset($_POST['add']) || isset($_POST['delete'])) 
+if (isset($_POST['add']) || isset($_POST['delete']))
 {
        begin_transaction();
-       
+
        for ($i = 0, $da = $_POST['begin']; date1_greater_date2($_POST['end'], $da); $i++)
        {
                if (isset($_POST['add']))
                        add_update_gl_budget_trans($da, $_POST['account'], $_POST['dim1'], $_POST['dim2'], input_num('amount'.$i));
-               else    
+               else
                        delete_gl_budget_trans($da, $_POST['account'], $_POST['dim1'], $_POST['dim2']);
                $da = add_months($da, 1);
        }
        commit_transaction();
-       
+
        if (isset($_POST['add']))
                display_notification_centered(_("The Budget has been saved."));
-       else    
+       else
                display_notification_centered(_("The Budget has been deleted."));
-       
-       //meta_forward($_SERVER['PHP_SELF']);           
+
+       //meta_forward($_SERVER['PHP_SELF']);
        $Ajax->activate('budget_tbl');
-}      
+}
 if (isset($_POST['submit']) || isset($_POST['update']))
        $Ajax->activate('budget_tbl');
 
@@ -95,16 +95,16 @@ if (isset($_POST['submit']) || isset($_POST['update']))
 
 start_form();
 
-if (db_has_gl_accounts()) 
+if (db_has_gl_accounts())
 {
        $dim = get_company_pref('use_dimension');
        start_table($table_style2);
        fiscalyears_list_row(_("Fiscal Year:"), 'fyear', null);
        gl_all_accounts_list_row(_("Account Code:"), 'account', null);
-       if (!isset($_POST['dim1']))     
-               $_POST['dim1'] = 0;     
-       if (!isset($_POST['dim2']))     
-               $_POST['dim2'] = 0;     
+       if (!isset($_POST['dim1']))
+               $_POST['dim1'] = 0;
+       if (!isset($_POST['dim2']))
+               $_POST['dim2'] = 0;
     if ($dim == 2)
     {
                dimensions_list_row(_("Dimension")." 1", 'dim1', $_POST['dim1'], true, null, false, 1);
@@ -124,13 +124,13 @@ if (db_has_gl_accounts())
        end_table(1);
        div_start('budget_tbl');
        start_table($table_style2);
-       $showdims = (($dim == 1 && $_POST['dim1'] == 0) || 
+       $showdims = (($dim == 1 && $_POST['dim1'] == 0) ||
                ($dim == 2 && $_POST['dim1'] == 0 && $_POST['dim2'] == 0));
-       if ($showdims)  
+       if ($showdims)
                $th = array(_("Period"), _("Amount"), _("Dim. incl."), _("Last Year"));
-       else    
+       else
                $th = array(_("Period"), _("Amount"), _("Last Year"));
-       table_header($th);      
+       table_header($th);
        $year = $_POST['fyear'];
        if (get_post('update') == '') {
                $sql = "SELECT * FROM ".TB_PREF."fiscal_year WHERE id=$year";
@@ -149,16 +149,16 @@ if (db_has_gl_accounts())
                start_row();
                if (get_post('update') == '')
                        $_POST['amount'.$i] = number_format2(get_only_budget_trans_from_to(
-                               $date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']), 0); 
-               
-               label_cell($date_);     
+                               $date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']), 0);
+
+               label_cell($date_);
                amount_cells(null, 'amount'.$i, null, 15, null, 0);
                if ($showdims)
                {
                        $d = get_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']);
                        label_cell(number_format2($d, 0), "nowrap align=right");
                        $btotal += $d;
-               }       
+               }
                $lamount = get_gl_trans_from_to(add_years($date_, -1), add_years(end_month($date_), -1), $_POST['account'], $_POST['dim1'], $_POST['dim2']);
                $total += input_num('amount'.$i);
                $ltotal += $lamount;
@@ -178,9 +178,9 @@ if (db_has_gl_accounts())
        submit_center_first('update', _("Update"), '', null);
        submit('add', _("Save"), true, '', true);
        submit_center_last('delete', _("Delete"), '', true);
-} 
+}
 end_form();
-       
+
 end_page();
-       
+
 ?>
index fd7af9c5e6991a6da98fd5be2c032628b07447ab..9a484da257b2600d91003ace891072e403396228 100644 (file)
@@ -30,7 +30,7 @@ function update_comments($type, $id, $date_, $memo_)
        if ($date_ == null)
        {
        delete_comments($type, $id);
-       add_comments($type, $id, '', $memo_);
+       add_comments($type, $id, Today(), $memo_);
        }
        else
        {
index 769ac7d679eb8b4cb8f252a1790c88033ceb9d75..48e75ebaa986635ea885ce5815c5f8c06aa5a144 100644 (file)
@@ -51,20 +51,20 @@ if (isset($_POST['UpdateData']))
 
        if ($should_update)
        {
-               $update_no = stock_cost_update($_POST['stock_id'], 
-                   input_num('material_cost'), input_num('labour_cost'), 
+               $update_no = stock_cost_update($_POST['stock_id'],
+                   input_num('material_cost'), input_num('labour_cost'),
                    input_num('overhead_cost'), $old_cost);
 
-        display_note(_("Cost has been updated."));
+        display_notification(_("Cost has been updated."));
 
         if ($update_no > 0)
         {
-               display_note(get_gl_view_str(systypes::cost_update(), $update_no, _("View the GL Journal Entries for this Cost Update")), 1, 0);
+               display_note(get_gl_view_str(systypes::cost_update(), $update_no, _("View the GL Journal Entries for this Cost Update")), 0, 1);
         }
        }
 }
 
-if (list_updated('stock_id')) 
+if (list_updated('stock_id'))
        $Ajax->activate('cost_table');
 //-----------------------------------------------------------------------------------------
 
index b38e787ab03eea1683779edddc0d88cf1ff3cdc6..0ddabcec3d27f4cb36cb8dc431ac437a17b4969a 100644 (file)
@@ -2,86 +2,89 @@
 
 //-------------------------------------------------------------------------------------------------------------
 
-function add_supp_trans($type, $supplier_id, $date_, $due_date, $reference, $supp_reference, 
+function add_supp_trans($type, $supplier_id, $date_, $due_date, $reference, $supp_reference,
        $amount, $amount_tax, $discount, $err_msg="")
 {
        $date = date2sql($date_);
-       $due_date = date2sql($due_date);
-       
-       $trans_no = get_next_trans_no($type);   
+       if ($due_date == "")
+               $due_date = "0000-00-00";
+       else
+               $due_date = date2sql($due_date);
+
+       $trans_no = get_next_trans_no($type);
 
        $curr = get_supplier_currency($supplier_id);
-       $rate = get_exchange_rate_from_home_currency($curr, $date_);    
+       $rate = get_exchange_rate_from_home_currency($curr, $date_);
 
 
-       $sql = "INSERT INTO ".TB_PREF."supp_trans (trans_no, type, supplier_id, tran_date, due_date, 
+       $sql = "INSERT INTO ".TB_PREF."supp_trans (trans_no, type, supplier_id, tran_date, due_date,
                reference, supp_reference, ov_amount, ov_gst, rate, ov_discount) ";
        $sql .= "VALUES ($trans_no, $type, $supplier_id, '$date', '$due_date',
                ".db_escape($reference).", ".db_escape($supp_reference).", $amount, $amount_tax, $rate, $discount)";
-       
+
        if ($err_msg == "")
                $err_msg = "Cannot insert a supplier transaction record";
-               
-       db_query($sql, $err_msg);               
 
-       return $trans_no;       
+       db_query($sql, $err_msg);
+
+       return $trans_no;
 }
 
 //-------------------------------------------------------------------------------------------------------------
 
 function get_supp_trans($trans_no, $trans_type=-1)
 {
-       $sql = "SELECT ".TB_PREF."supp_trans.*, (".TB_PREF."supp_trans.ov_amount+".TB_PREF."supp_trans.ov_gst+".TB_PREF."supp_trans.ov_discount) AS Total, 
+       $sql = "SELECT ".TB_PREF."supp_trans.*, (".TB_PREF."supp_trans.ov_amount+".TB_PREF."supp_trans.ov_gst+".TB_PREF."supp_trans.ov_discount) AS Total,
                ".TB_PREF."suppliers.supp_name AS supplier_name, ".TB_PREF."suppliers.curr_code AS SupplierCurrCode ";
-       
-       if ($trans_type == 22) 
+
+       if ($trans_type == 22)
        {
                // it's a payment so also get the bank account
-               $sql .= ", ".TB_PREF."bank_accounts.bank_name, ".TB_PREF."bank_accounts.bank_account_name, ".TB_PREF."bank_accounts.bank_curr_code, 
+               $sql .= ", ".TB_PREF."bank_accounts.bank_name, ".TB_PREF."bank_accounts.bank_account_name, ".TB_PREF."bank_accounts.bank_curr_code,
                        ".TB_PREF."bank_trans_types.name AS BankTransType, ".TB_PREF."bank_trans.amount AS BankAmount,
-                       ".TB_PREF."bank_trans.ref ";  
-       }  
-       
-       $sql .= " FROM ".TB_PREF."supp_trans, ".TB_PREF."suppliers "; 
+                       ".TB_PREF."bank_trans.ref ";
+       }
 
-       if ($trans_type == 22) 
+       $sql .= " FROM ".TB_PREF."supp_trans, ".TB_PREF."suppliers ";
+
+       if ($trans_type == 22)
        {
                // it's a payment so also get the bank account
-               $sql .= ", ".TB_PREF."bank_trans, ".TB_PREF."bank_accounts, ".TB_PREF."bank_trans_types ";  
-       }       
-       
-       $sql .= " WHERE ".TB_PREF."supp_trans.trans_no=$trans_no 
+               $sql .= ", ".TB_PREF."bank_trans, ".TB_PREF."bank_accounts, ".TB_PREF."bank_trans_types ";
+       }
+
+       $sql .= " WHERE ".TB_PREF."supp_trans.trans_no=$trans_no
                AND ".TB_PREF."supp_trans.supplier_id=".TB_PREF."suppliers.supplier_id";
-                                       
+
        if ($trans_type > 0)
-               $sql .= " AND ".TB_PREF."supp_trans.type=$trans_type ";                                 
-                                       
-       if ($trans_type == 22) 
+               $sql .= " AND ".TB_PREF."supp_trans.type=$trans_type ";
+
+       if ($trans_type == 22)
        {
                // it's a payment so also get the bank account
                $sql .= " AND ".TB_PREF."bank_trans.trans_no =$trans_no
-                       AND ".TB_PREF."bank_trans.type=$trans_type      
+                       AND ".TB_PREF."bank_trans.type=$trans_type
                        AND ".TB_PREF."bank_trans_types.id = ".TB_PREF."bank_trans.bank_trans_type_id
-                       AND ".TB_PREF."bank_accounts.account_code=".TB_PREF."bank_trans.bank_act ";  
-       }                                               
-       
+                       AND ".TB_PREF."bank_accounts.account_code=".TB_PREF."bank_trans.bank_act ";
+       }
+
        $result = db_query($sql, "Cannot retreive a supplier transaction");
-       
-    if (db_num_rows($result) == 0) 
+
+    if (db_num_rows($result) == 0)
     {
        // can't return nothing
        display_db_error("no supplier trans found for given params", $sql, true);
        exit;
     }
-    
-    if (db_num_rows($result) > 1) 
+
+    if (db_num_rows($result) > 1)
     {
        // can't return multiple
        display_db_error("duplicate supplier transactions found for given params", $sql, true);
        exit;
-    }  
-    
-    return db_fetch($result);          
+    }
+
+    return db_fetch($result);
 }
 
 //----------------------------------------------------------------------------------------
@@ -89,24 +92,24 @@ function get_supp_trans($trans_no, $trans_type=-1)
 function get_supplier_transactions($extra_fields=null, $extra_conditions=null, $extra_tables=null)
 {
        $sql = "SELECT ".TB_PREF."supp_trans.*,
-               ov_amount+ov_gst+ov_discount AS Total,   
+               ov_amount+ov_gst+ov_discount AS Total,
                ".TB_PREF."suppliers.supp_name, ".TB_PREF."suppliers.address,
                ".TB_PREF."suppliers.curr_code ";
-                               
+
        if ($extra_fields)
-               $sql .= ", $extra_fields ";                     
-                               
+               $sql .= ", $extra_fields ";
+
        $sql .= " FROM ".TB_PREF."supp_trans, ".TB_PREF."suppliers ";
        if ($extra_tables)
                $sql .= " ,$extra_tables ";
-                               
+
        $sql .= " WHERE ".TB_PREF."supp_trans.supplier_id=".TB_PREF."suppliers.supplier_id";
-                               
+
        if ($extra_conditions)
-               $sql .= " AND $extra_conditions ";      
-               
-       $sql .= " ORDER BY trans_no";   
-       
+               $sql .= " AND $extra_conditions ";
+
+       $sql .= " ORDER BY trans_no";
+
        return db_query($sql, "Cannot retreive supplier transactions");
 }
 
@@ -116,21 +119,21 @@ function exists_supp_trans($type, $type_no)
 {
        if ($type == 25)
                return exists_grn($type_no);
-               
+
        $sql = "SELECT trans_no FROM ".TB_PREF."supp_trans WHERE type=$type
                AND trans_no=$type_no";
-       $result = db_query($sql, "Cannot retreive a supplier transaction");     
-       
-    return (db_num_rows($result) > 0);                         
+       $result = db_query($sql, "Cannot retreive a supplier transaction");
+
+    return (db_num_rows($result) > 0);
 }
 
 //----------------------------------------------------------------------------------------
 
 function void_supp_trans($type, $type_no)
 {
-       $sql = "UPDATE ".TB_PREF."supp_trans SET ov_amount=0, ov_discount=0, ov_gst=0, 
+       $sql = "UPDATE ".TB_PREF."supp_trans SET ov_amount=0, ov_discount=0, ov_gst=0,
                alloc=0 WHERE type=$type AND trans_no=$type_no";
-                       
+
        db_query($sql, "could not void supp transactions for type=$type and trans_no=$type_no");
 }
 
@@ -138,24 +141,24 @@ function void_supp_trans($type, $type_no)
 
 function post_void_supp_trans($type, $type_no)
 {
-       if ($type == 22) 
+       if ($type == 22)
        {
                void_supp_payment($type, $type_no);
                return true;
        }
-       
-       if ($type == 20 || $type == 21) 
+
+       if ($type == 20 || $type == 21)
        {
                void_supp_invoice($type, $type_no);
-               return true;            
+               return true;
        }
-        
-       if ($type == 25) 
+
+       if ($type == 25)
        {
                return void_grn($type_no);
-       }        
-       
-       return false;   
+       }
+
+       return false;
 }
 
 //----------------------------------------------------------------------------------------
index d347dbbfb2903069b45aadfc5e461f95aa274c8e..b91a279558873c141331c55c30c21a5222c9ae57 100644 (file)
@@ -78,7 +78,7 @@ function get_customer_trans_version($type, $trans_no) {
 // date_ is display date (non-sql)
 function write_customer_trans($trans_type, $trans_no, $debtor_no, $BranchNo,
        $date_, $reference, $Total, $discount=0, $Tax=0, $Freight=0, $FreightTax=0,
-       $sales_type=0, $order_no=0, $trans_link=0, $ship_via="", $due_date=null,
+       $sales_type=0, $order_no=0, $trans_link=0, $ship_via=0, $due_date="",
        $AllocAmt=0)
 {
 
@@ -86,7 +86,10 @@ function write_customer_trans($trans_type, $trans_no, $debtor_no, $BranchNo,
        $rate = get_exchange_rate_from_home_currency($curr, $date_);
 
        $SQLDate = date2sql($date_);
-       $SQLDueDate = date2sql($due_date);
+       if ($due_date == "")
+               $SQLDueDate = "000-00-00";
+       else
+               $SQLDueDate = date2sql($due_date);
 
        if ($trans_no==0) {
        $trans_no = get_next_trans_no($trans_type);