Fixed supplier order reference uniquty, fixed company logo file deletion.
authorJanusz Dobrowolski <janusz@frontaccouting.eu>
Tue, 6 Sep 2011 10:09:59 +0000 (12:09 +0200)
committerJanusz Dobrowolski <janusz@frontaccouting.eu>
Tue, 6 Sep 2011 10:09:59 +0000 (12:09 +0200)
admin/company_preferences.php
purchasing/includes/db/invoice_db.inc
purchasing/po_entry_items.php

index d944fefba2a782c1c005b6371082f026cfebe41d..51881218f4d929261302bc7af841c8008f08a9c7 100644 (file)
@@ -93,9 +93,8 @@ if (isset($_POST['update']) && $_POST['update'] != "")
                                display_error(_('The existing image could not be removed'));
                                $input_error = 1;
                        }
-                       else
-                               $_POST['coy_logo'] = "";
                }
+               $_POST['coy_logo'] = "";
        }
        if ($_POST['add_pct'] == "")
                $_POST['add_pct'] = -1;
index 4f8024a62420a57ee8009b5e8cbeb0d56d047ab1..1482ebcc8804434c1c51fe1a46171e6a46563b0c 100644 (file)
@@ -635,17 +635,18 @@ function get_gl_account_info($acc)
        return db_query($sql,"get account information");
 }
 
-function is_reference_already_there($supplier_id, $supp_reference)
+function is_reference_already_there($supplier_id, $supp_reference, $trans_no=0)
 {
-       $sql = "SELECT Count(*) FROM ".TB_PREF."supp_trans WHERE supplier_id="
+       $sql = "SELECT COUNT(*) FROM ".TB_PREF."supp_trans WHERE supplier_id="
                .db_escape($supplier_id) . " AND supp_reference=" 
                .db_escape($supp_reference) 
                . " AND ov_amount!=0"; // ignore voided invoice references
-
+       if ($trans_no)
+               $sql .= " AND trans_no!=$trans_no";
        $result=db_query($sql,"The sql to check for the previous entry of the same invoice failed");
 
        $myrow = db_fetch_row($result);
-       return ($myrow[0] == 1);
+       return $myrow[0] > 0;
 }
 
 function remove_not_invoice_item($id)
index af5e3ee1c4978b65a78cc92615a83891be066bd2..a23b7a0754b94603dc9e8e1d22931b4d6df3f337 100644 (file)
@@ -373,7 +373,7 @@ function can_commit()
                return false;
        }
        if ($_SESSION['PO']->trans_type==ST_SUPPINVOICE 
-               && is_reference_already_there($_SESSION['PO']->supplier_id, get_post('supp_ref'), $_SESSION['PO']->trans_no))
+               && is_reference_already_there($_SESSION['PO']->supplier_id, get_post('supp_ref'), $_SESSION['PO']->order_no))
        {
                display_error(_("This invoice number has already been entered. It cannot be entered again.") . " (" . get_post('supp_ref') . ")");
                set_focus('supp_ref');