Fix: Amélioration gestion erreur
This commit is contained in:
parent
32a479a834
commit
937113dae9
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -124,12 +124,13 @@ class Account
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank
|
* \brief Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank
|
||||||
* \return int rowid de l'entrée ajoutée
|
* \return int rowid de l'entrée ajoutée, < 0 si erreur
|
||||||
*/
|
*/
|
||||||
function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user='')
|
function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user='')
|
||||||
{
|
{
|
||||||
if ($this->rowid)
|
if ($this->rowid)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch ($oper)
|
switch ($oper)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@ -158,8 +159,7 @@ class Account
|
|||||||
$datev = $date;
|
$datev = $date;
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, dateo, datev, label, amount, fk_user_author, num_chq,fk_account, fk_type)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, dateo, datev, label, amount, fk_user_author, num_chq,fk_account, fk_type)";
|
||||||
$sql .= " VALUES (now(), '$date', '$datev', '$label', '" . ereg_replace(",",".",$amount) . "', '$user->id' ,'$num_chq', '$this->rowid', '$oper')";
|
$sql.= " VALUES (now(), '".$date."', '$datev', '$label', '" . ereg_replace(',','.',$amount) . "', '".$user->id."' ,'$num_chq', '".$this->rowid."', '$oper')";
|
||||||
|
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
@ -168,13 +168,9 @@ class Account
|
|||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES ('$rowid', '$categorie')";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES ('$rowid', '$categorie')";
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if (! $result)
|
||||||
{
|
{
|
||||||
return $rowid;
|
return -2;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//return ''; On ne quitte pas avec erreur car insertion dans bank_class peut echouer alors que insertion dans bank ok
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $rowid;
|
return $rowid;
|
||||||
@ -182,7 +178,7 @@ class Account
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
return '';
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,23 +197,19 @@ class Account
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $pcgnumber) {
|
if (! $pcgnumber) $pcgnumber="51";
|
||||||
// TODO
|
|
||||||
// Prendre comme de numero compte comptable pour le compte bancaire, le numero par defaut pour plan de compte actif
|
|
||||||
$pcgnumber="51";
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account (datec, label, account_number) values (now(),'$this->label','$pcgnumber');";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account (datec, label, account_number) values (now(),'$this->label','$pcgnumber');";
|
||||||
if ($this->db->query($sql))
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
{
|
{
|
||||||
if ($this->db->affected_rows())
|
if ($this->db->affected_rows($resql))
|
||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account");
|
||||||
if ( $this->update() )
|
if ( $this->update() )
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, label, amount, fk_account,datev,dateo,fk_type,rappro) ";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, label, amount, fk_account,datev,dateo,fk_type,rappro) ";
|
||||||
$sql .= " VALUES (now(),'Solde','" . ereg_replace(",",".",$this->solde) . "','$this->id','".$this->db->idate($this->date_solde)."','".$this->db->idate($this->date_solde)."','SOLD',1);";
|
$sql .= " VALUES (now(),'Solde','" . ereg_replace(',','.',$this->solde) . "','$this->id','".$this->db->idate($this->date_solde)."','".$this->db->idate($this->date_solde)."','SOLD',1);";
|
||||||
|
|
||||||
$this->db->query($sql);
|
$this->db->query($sql);
|
||||||
}
|
}
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user