Skip to content
Snippets Groups Projects
Commit d4466a65 authored by Juanjo Menent's avatar Juanjo Menent
Browse files

Merge pull request #4288 from marcosgdf/bug-4182

FIX #4182 SQL error when deleting an unexisting bank entry
parents c9e8c362 8b633aee
No related branches found
No related tags found
No related merge requests found
...@@ -1277,12 +1277,12 @@ class AccountLine extends CommonObject ...@@ -1277,12 +1277,12 @@ class AccountLine extends CommonObject
$nbko++; $nbko++;
} }
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".$this->rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".(int) $this->rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) $nbko++; if (! $result) $nbko++;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".$this->rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".(int) $this->rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) $nbko++; if (! $result) $nbko++;
...@@ -1319,7 +1319,7 @@ class AccountLine extends CommonObject ...@@ -1319,7 +1319,7 @@ class AccountLine extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".$this->rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".(int) $this->rowid;
dol_syslog(get_class($this)."::delete_urls", LOG_DEBUG); dol_syslog(get_class($this)."::delete_urls", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) $nbko++; if (! $result) $nbko++;
......
...@@ -99,11 +99,14 @@ if ($action == 'rappro' && $user->rights->banque->consolidate) ...@@ -99,11 +99,14 @@ if ($action == 'rappro' && $user->rights->banque->consolidate)
if ($action == 'del') if ($action == 'del')
{ {
$bankline=new AccountLine($db); $bankline=new AccountLine($db);
$bankline->fetch($_GET["rowid"]);
$result=$bankline->delete($user); if ($bankline->fetch($_GET["rowid"]) > 1) {
if ($result < 0) $result = $bankline->delete($user);
{ if ($result < 0) {
dol_print_error($db,$bankline->error); dol_print_error($db, $bankline->error);
}
} else {
setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors');
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment