From 893240ce213272dd06bb891514ed43a8c4416970 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Sat, 12 Jul 2014 09:48:10 +0200 Subject: [PATCH] Qual: Uniformize code. Errors --- .../salaries/class/paymentsalary.class.php | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 234b70d84b9..5e728b0cc64 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -1,19 +1,20 @@ + * Copyright (C) 2014 Juanjo Menent * -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ /** * \file htdocs/compta/salaries/class/paymentsalary.class.php @@ -278,6 +279,8 @@ class PaymentSalary extends CommonObject function create($user) { global $conf,$langs; + + $error=0; // Clean parameters $this->amount=price2num(trim($this->amount)); @@ -351,7 +354,6 @@ class PaymentSalary extends CommonObject $result = $this->db->query($sql); if ($result) { - $ok=1; $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); @@ -387,10 +389,10 @@ class PaymentSalary extends CommonObject else { $this->error=$acc->error; - $ok=0; + $error++; } - if ($ok) + if (! $error) { // Add link 'payment_salary' in bank_url between payment and bank transaction $url=DOL_URL_ROOT.'/compta/salaries/fiche.php?id='; @@ -399,7 +401,7 @@ class PaymentSalary extends CommonObject if ($result <= 0) { $this->error=$acc->error; - $ok=0; + $error++; } } @@ -419,19 +421,19 @@ class PaymentSalary extends CommonObject if ($result <= 0) { $this->error=$acc->error; - $ok=0; + $error++; } } // Call trigger $result=$this->call_trigger('PAYMENT_SALARY_CREATE',$user); - if ($result < 0) $ok=0; + if ($result < 0) $error++; // End call triggers } - else $ok=0; + else $error++; - if ($ok) + if (! $error) { $this->db->commit(); return $this->id;