Fixed: Bug création facture fournisseur. Correction gestion erreur.

This commit is contained in:
Laurent Destailleur 2005-05-23 16:21:44 +00:00
parent 2251bcbac4
commit eac9d46bfd
2 changed files with 107 additions and 103 deletions

View File

@ -57,6 +57,7 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == yes && $user->ri
$facturefourn->set_valid($user->id); $facturefourn->set_valid($user->id);
Header("Location: fiche.php?facid=".$_GET["facid"]); Header("Location: fiche.php?facid=".$_GET["facid"]);
exit;
} }
@ -99,7 +100,7 @@ if ($_POST["action"] == 'update')
$result = $db->query( $sql); $result = $db->query( $sql);
} }
/* /*
* Création * Action création
*/ */
if ($_POST["action"] == 'add' && $user->rights->fournisseur->facture->creer) if ($_POST["action"] == 'add' && $user->rights->fournisseur->facture->creer)
{ {
@ -152,18 +153,20 @@ if ($_POST["action"] == 'add' && $user->rights->fournisseur->facture->creer)
} }
$db->commit(); $db->commit();
header("Location: fiche.php?facid=$facid");
exit;
} }
else else
{ {
$db->rollback(); $db->rollback();
$mesg='<div class="error">'.$facfou->error.'</div>';
$_GET["action"]='create';
} }
header("Location: fiche.php?facid=$facid");
} }
else else
{ {
$mesg="<div class=\"error\">Erreur: Un numéro de facture fournisseur est obligatoire.</div>"; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Ref")).'</div>';
$_GET["action"]='create';
} }
} }
@ -207,14 +210,16 @@ if ($_GET["action"] == 'create' or $_GET["action"] == 'copy')
{ {
llxHeader(); llxHeader();
if ($mesg) { print "<br>$mesg<br>"; }
print_titre($langs->trans("NewBill"));
if ($mesg) { print "$mesg<br>"; }
if ($_GET["action"] == 'copy') if ($_GET["action"] == 'copy')
{ {
$fac_ori = new FactureFournisseur($db); $fac_ori = new FactureFournisseur($db);
$fac_ori->fetch($_GET["facid"]); $fac_ori->fetch($_GET["facid"]);
} }
print_titre($langs->trans("NewBill"));
print '<form action="fiche.php" method="post">'; print '<form action="fiche.php" method="post">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.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
@ -83,14 +83,12 @@ class FactureFournisseur
/** /**
* \brief Création de la facture en base * \brief Création de la facture en base
* \param user object utilisateur qui crée * \param user object utilisateur qui crée
* * \return int id facture si ok, < 0 si erreur
*/ */
function create($user) function create($user)
{ {
global $langs;
/*
* Insertion dans la base
*/
$socid = $this->socidp; $socid = $this->socidp;
$number = $this->number; $number = $this->number;
$amount = $this->amount; $amount = $this->amount;
@ -142,15 +140,16 @@ class FactureFournisseur
{ {
if ($this->db->errno() == DB_ERROR_RECORD_ALREADY_EXISTS) if ($this->db->errno() == DB_ERROR_RECORD_ALREADY_EXISTS)
{ {
print "Erreur : Une facture possédant cet id existe déjà"; $this->error=$langs->trans("ErrorBillRefAlreadyExists");
return -1;
} }
else else
{ {
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
} return -2;
return 0;
} }
} }
}
/** /**
* \brief Recupére l'objet facture et ses lignes de factures * \brief Recupére l'objet facture et ses lignes de factures