Qual: Uniformize code. Errors

This commit is contained in:
Juanjo Menent 2014-07-12 09:48:10 +02:00
parent dbb2d464db
commit 893240ce21

View File

@ -1,19 +1,20 @@
<?php
/* 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
* 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 <http://www.gnu.org/licenses/>.
*/
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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;