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

Qual: Uniformize code. Errors

parent dbb2d464
No related branches found
No related tags found
No related merge requests found
<?php <?php
/* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> /* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -279,6 +280,8 @@ class PaymentSalary extends CommonObject ...@@ -279,6 +280,8 @@ class PaymentSalary extends CommonObject
{ {
global $conf,$langs; global $conf,$langs;
$error=0;
// Clean parameters // Clean parameters
$this->amount=price2num(trim($this->amount)); $this->amount=price2num(trim($this->amount));
$this->label=trim($this->label); $this->label=trim($this->label);
...@@ -351,7 +354,6 @@ class PaymentSalary extends CommonObject ...@@ -351,7 +354,6 @@ class PaymentSalary extends CommonObject
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$ok=1;
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary");
...@@ -387,10 +389,10 @@ class PaymentSalary extends CommonObject ...@@ -387,10 +389,10 @@ class PaymentSalary extends CommonObject
else else
{ {
$this->error=$acc->error; $this->error=$acc->error;
$ok=0; $error++;
} }
if ($ok) if (! $error)
{ {
// Add link 'payment_salary' in bank_url between payment and bank transaction // Add link 'payment_salary' in bank_url between payment and bank transaction
$url=DOL_URL_ROOT.'/compta/salaries/fiche.php?id='; $url=DOL_URL_ROOT.'/compta/salaries/fiche.php?id=';
...@@ -399,7 +401,7 @@ class PaymentSalary extends CommonObject ...@@ -399,7 +401,7 @@ class PaymentSalary extends CommonObject
if ($result <= 0) if ($result <= 0)
{ {
$this->error=$acc->error; $this->error=$acc->error;
$ok=0; $error++;
} }
} }
...@@ -419,19 +421,19 @@ class PaymentSalary extends CommonObject ...@@ -419,19 +421,19 @@ class PaymentSalary extends CommonObject
if ($result <= 0) if ($result <= 0)
{ {
$this->error=$acc->error; $this->error=$acc->error;
$ok=0; $error++;
} }
} }
// Call trigger // Call trigger
$result=$this->call_trigger('PAYMENT_SALARY_CREATE',$user); $result=$this->call_trigger('PAYMENT_SALARY_CREATE',$user);
if ($result < 0) $ok=0; if ($result < 0) $error++;
// End call triggers // End call triggers
} }
else $ok=0; else $error++;
if ($ok) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment