diff --git a/htdocs/bon-prelevement.class.php b/htdocs/bon-prelevement.class.php index eb8e3a0aa9b..1ada712cb1a 100644 --- a/htdocs/bon-prelevement.class.php +++ b/htdocs/bon-prelevement.class.php @@ -590,9 +590,11 @@ class BonPrelevement } } - /* - * - * + /** + * \brief Renvoi nombre de factures a prélever + * \param banque bank + * \param agence agence + * \return int db->fetch_row($resql); - return $row[0]; - $this->db->free($resql); + + return $row[0]; } else { - $error = 1; - dolibarr_syslog("BonPrelevement::SommeAPrelever Erreur -1"); - dolibarr_syslog($this->db->error()); + $this->error="BonPrelevement::SommeAPrelever Erreur -1 sql=".$this->db->error(); + dolibarr_syslog($this->error); + return -1; } } /** * \brief Cree prelevement - * + * \return int <0 si ko, nbre de facture prélevé sinon */ function Create($banque=0, $guichet=0) { @@ -666,8 +668,9 @@ class BonPrelevement */ $factures = array(); $factures_prev = array(); + $factures_result = array(); - if (!$error) + if (! $error) { $sql = "SELECT f.rowid, pfd.rowid as pfdrowid, f.fk_soc"; @@ -742,10 +745,10 @@ class BonPrelevement { $fact = new Facture($this->db); - if ($fact->fetch($fac[0]) == 1) + if ($fact->fetch($fac[0]) >= 0) { $soc = new Societe($this->db); - if ($soc->fetch($fact->socidp) == 1) + if ($soc->fetch($fact->socidp) >= 0) { if ($soc->verif_rib() == 1) { @@ -757,6 +760,7 @@ class BonPrelevement else { dolibarr_syslog("Erreur de RIB societe $fact->socidp $soc->nom"); + $facture_errors[$fac[0]]="Erreur de RIB societe $fact->socidp $soc->nom"; } } else @@ -776,6 +780,7 @@ class BonPrelevement } } + /* * * @@ -996,6 +1001,12 @@ class BonPrelevement $this->db->rollback(); dolibarr_syslog("ROLLBACK"); } + + return sizeof($factures_prev); + } + else + { + return 0; } } diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 72eb81cc951..3a7a57483c2 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -29,6 +29,8 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php'); +require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); $user->getrights('facture'); if (!$user->rights->facture->lire) @@ -38,8 +40,6 @@ $langs->load("bills"); $langs->load("banks"); $langs->load("withdrawals"); -require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); - // Sécurité accés client if ($user->societe_id > 0) { @@ -61,6 +61,7 @@ if ($_GET["action"] == "new") if ($result > 0) { Header("Location: prelevement.php?facid=".$fact->id); + exit; } else { @@ -99,56 +100,34 @@ if ($_GET["facid"] > 0) $fac = New Facture($db); if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0) { - if ($mesg) print $mesg.'
'; $soc = new Societe($db, $fac->socidp); $soc->fetch($fac->socidp); + $author = new User($db); - $author->id = $fac->user_author; - $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) + if ($fac->user_author) { - $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[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$fac->id; - $head[$h][1] = $langs->trans("StandingOrders"); - $hselected = $h; - $h++; + $author->id = $fac->user_author; + $author->fetch(); } - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$fac->id; - $head[$h][1] = $langs->trans("Note"); - $h++; + $head = facture_prepare_head($fac); - $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"); + dolibarr_fiche_head($head, 2, $langs->trans('Bill').' : '.$fac->ref); /* - * Facture - */ + * Facture + */ print ''; + // Reference du facture + print '"; + // Societe - print ''; + print ''; print ''; print ''; diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index fd1b37c8600..7f979f7b081 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -1524,18 +1524,18 @@ class Facture /** - * \brief Créé une demande de prélèvement + * \brief Créé une demande de prélèvement * \param user Utilisateur créant la demande * \return int <0 si ko, >0 si ok */ 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->id = $this->socidp; $soc->rib(); - if ($this->statut > 0 && $this->paye == 0 && $this->mode_reglement_id == 3) + if ($this->statut > 0 && $this->paye == 0 && $this->mode_reglement_id == 3) { $sql = 'SELECT count(*) FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; $sql .= ' WHERE fk_facture='.$this->id;
'.$langs->trans("Ref").''; + print $fac->ref; + print "
'.$langs->trans("Company").'
'.$langs->trans("Company").''; print ''.$soc->nom.'