Fix: Affiche message erreur sur creation prelevement

This commit is contained in:
Laurent Destailleur 2005-12-08 23:46:32 +00:00
parent de3b7d3df7
commit 27c1c42eea
3 changed files with 43 additions and 53 deletions

View File

@ -590,9 +590,11 @@ class BonPrelevement
} }
} }
/* /**
* * \brief Renvoi nombre de factures a prélever
* * \param banque bank
* \param agence agence
* \return int <O si erreur, sinon nbre de factures
*/ */
function NbFactureAPrelever($banque=0,$agence=0) function NbFactureAPrelever($banque=0,$agence=0)
{ {
@ -625,21 +627,21 @@ class BonPrelevement
{ {
$row = $this->db->fetch_row($resql); $row = $this->db->fetch_row($resql);
return $row[0];
$this->db->free($resql); $this->db->free($resql);
return $row[0];
} }
else else
{ {
$error = 1; $this->error="BonPrelevement::SommeAPrelever Erreur -1 sql=".$this->db->error();
dolibarr_syslog("BonPrelevement::SommeAPrelever Erreur -1"); dolibarr_syslog($this->error);
dolibarr_syslog($this->db->error()); return -1;
} }
} }
/** /**
* \brief Cree prelevement * \brief Cree prelevement
* * \return int <0 si ko, nbre de facture prélevé sinon
*/ */
function Create($banque=0, $guichet=0) function Create($banque=0, $guichet=0)
{ {
@ -666,8 +668,9 @@ class BonPrelevement
*/ */
$factures = array(); $factures = array();
$factures_prev = array(); $factures_prev = array();
$factures_result = array();
if (!$error) if (! $error)
{ {
$sql = "SELECT f.rowid, pfd.rowid as pfdrowid, f.fk_soc"; $sql = "SELECT f.rowid, pfd.rowid as pfdrowid, f.fk_soc";
@ -742,10 +745,10 @@ class BonPrelevement
{ {
$fact = new Facture($this->db); $fact = new Facture($this->db);
if ($fact->fetch($fac[0]) == 1) if ($fact->fetch($fac[0]) >= 0)
{ {
$soc = new Societe($this->db); $soc = new Societe($this->db);
if ($soc->fetch($fact->socidp) == 1) if ($soc->fetch($fact->socidp) >= 0)
{ {
if ($soc->verif_rib() == 1) if ($soc->verif_rib() == 1)
{ {
@ -757,6 +760,7 @@ class BonPrelevement
else else
{ {
dolibarr_syslog("Erreur de RIB societe $fact->socidp $soc->nom"); dolibarr_syslog("Erreur de RIB societe $fact->socidp $soc->nom");
$facture_errors[$fac[0]]="Erreur de RIB societe $fact->socidp $soc->nom";
} }
} }
else else
@ -776,6 +780,7 @@ class BonPrelevement
} }
} }
/* /*
* *
* *
@ -996,6 +1001,12 @@ class BonPrelevement
$this->db->rollback(); $this->db->rollback();
dolibarr_syslog("ROLLBACK"); dolibarr_syslog("ROLLBACK");
} }
return sizeof($factures_prev);
}
else
{
return 0;
} }
} }

View File

@ -29,6 +29,8 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php');
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
$user->getrights('facture'); $user->getrights('facture');
if (!$user->rights->facture->lire) if (!$user->rights->facture->lire)
@ -38,8 +40,6 @@ $langs->load("bills");
$langs->load("banks"); $langs->load("banks");
$langs->load("withdrawals"); $langs->load("withdrawals");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
// Sécurité accés client // Sécurité accés client
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
@ -61,6 +61,7 @@ if ($_GET["action"] == "new")
if ($result > 0) if ($result > 0)
{ {
Header("Location: prelevement.php?facid=".$fact->id); Header("Location: prelevement.php?facid=".$fact->id);
exit;
} }
else else
{ {
@ -99,56 +100,34 @@ if ($_GET["facid"] > 0)
$fac = New Facture($db); $fac = New Facture($db);
if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0) if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0)
{ {
if ($mesg) print $mesg.'<br>'; if ($mesg) print $mesg.'<br>';
$soc = new Societe($db, $fac->socidp); $soc = new Societe($db, $fac->socidp);
$soc->fetch($fac->socidp); $soc->fetch($fac->socidp);
$author = new User($db); $author = new User($db);
if ($fac->user_author)
{
$author->id = $fac->user_author; $author->id = $fac->user_author;
$author->fetch(); $author->fetch();
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id;
$head[$h][1] = $langs->trans("CardBill");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('Contact');
$h++;
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/apercu.php?facid='.$fac->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
} }
if ($fac->mode_reglement_code == 'PRE') $head = facture_prepare_head($fac);
{
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$fac->id;
$head[$h][1] = $langs->trans("StandingOrders");
$hselected = $h;
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$fac->id; dolibarr_fiche_head($head, 2, $langs->trans('Bill').' : '.$fac->ref);
$head[$h][1] = $langs->trans("Note");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$fac->id;
$head[$h][1] = $langs->trans("Info");
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Bill")." : $fac->ref");
/* /*
* Facture * Facture
*/ */
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Reference du facture
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $fac->ref;
print "</td></tr>";
// Societe // Societe
print '<tr><td>'.$langs->trans("Company").'</td>'; print '<tr><td width="20%">'.$langs->trans("Company").'</td>';
print '<td colspan="5">'; print '<td colspan="5">';
print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>'; print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';
print '</tr>'; print '</tr>';

View File

@ -1530,7 +1530,7 @@ class Facture
*/ */
function demande_prelevement($user) function demande_prelevement($user)
{ {
dolibarr_syslog("Facture::demande_prelevement"); dolibarr_syslog("Facture::demande_prelevement $this->statut $this->paye $this->mode_reglement_id");
$soc = new Societe($this->db); $soc = new Societe($this->db);
$soc->id = $this->socidp; $soc->id = $this->socidp;