From b86223bc906b5d99b0c671506430886f6bd82b18 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Nov 2008 22:34:14 +0000 Subject: [PATCH] Maxi debug of withdraw module --- htdocs/adherents/fiche.php | 2 +- htdocs/compta/facture.php | 11 +- htdocs/compta/facture/prelevement.php | 397 +++++++++--------- .../prelevement/bon-prelevement.class.php | 142 ++++--- htdocs/compta/prelevement/bon.php | 8 +- htdocs/compta/prelevement/bons.php | 11 +- htdocs/compta/prelevement/config.php | 160 +++---- htdocs/compta/prelevement/create.php | 177 ++++---- htdocs/compta/prelevement/demandes.php | 143 ++++--- htdocs/compta/prelevement/factures.php | 21 +- htdocs/compta/prelevement/facturesrejets.php | 10 +- htdocs/compta/prelevement/fiche-rejet.php | 25 +- htdocs/compta/prelevement/fiche-stat.php | 29 +- htdocs/compta/prelevement/fiche.php | 32 +- htdocs/compta/prelevement/index.php | 185 ++++---- htdocs/compta/prelevement/lignes.php | 171 ++++---- htdocs/compta/prelevement/liste.php | 8 +- htdocs/facture.class.php | 132 +++--- htdocs/html.form.class.php | 14 +- .../modules/modNotification.class.php | 3 +- htdocs/langs/en_US/banks.lang | 1 + htdocs/langs/en_US/withdrawals.lang | 11 +- htdocs/langs/fr_FR/banks.lang | 1 + htdocs/langs/fr_FR/withdrawals.lang | 11 +- htdocs/societe/rib.php | 27 +- 25 files changed, 921 insertions(+), 811 deletions(-) diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index c62ee03cf73..b4ca599226e 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -507,7 +507,7 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_add_spip' && /* - * + * View */ llxHeader(); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 02cb41e2225..63cb21922d4 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1820,7 +1820,8 @@ if ($_GET['action'] == 'create') else { $id = $_GET['facid']; - if ($id > 0) + $ref= $_GET['ref']; + if ($id > 0 || ! empty($ref)) { /* *************************************************************************** */ /* */ @@ -1832,7 +1833,7 @@ else $facstatic = new Facture($db); $fac = new Facture($db); - $result=$fac->fetch($_GET['facid']); + $result=$fac->fetch($_GET['facid'],$_GET['ref']); if ($result > 0) { if ($user->societe_id>0 && $user->societe_id!=$fac->socid) accessforbidden('',0); @@ -2026,17 +2027,19 @@ else // Reference print ''.$langs->trans('Ref').''; - print ''.$fac->ref; + print ''; + $morehtmlref=''; $discount=new DiscountAbsolute($db); $result=$discount->fetch(0,$fac->id); if ($result > 0) { - print ' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')'; + $morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')'; } if ($result < 0) { dolibarr_print_error('',$discount->error); } + print $html->showrefnav($fac,'ref','',1,'facnumber','ref',$morehtmlref); print ''; // Ref client diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index b2bf9f545d0..3f50379d568 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Éric Seigne - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * * 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 @@ -16,73 +16,74 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ */ /** - \file htdocs/compta/facture/prelevement.php - \ingroup facture - \brief Gestion des prelevement d'une facture - \version $Revision$ -*/ + * \file htdocs/compta/facture/prelevement.php + * \ingroup facture + * \brief Gestion des prelevement d'une facture + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php'); require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); if (!$user->rights->facture->lire) - accessforbidden(); +accessforbidden(); $langs->load("bills"); $langs->load("banks"); $langs->load("withdrawals"); // Sécurité accés client -if ($user->societe_id > 0) +if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } /* * Actions */ - + if ($_GET["action"] == "new") { - $fact = new Facture($db); - if ($fact->fetch($_GET["facid"])) - { - $result = $fact->demande_prelevement($user); - if ($result > 0) - { - Header("Location: prelevement.php?facid=".$fact->id); - exit; - } - else - { - $mesg='
'.$fact->error.'
'; - } - } + $fact = new Facture($db); + if ($fact->fetch($_GET["facid"])) + { + $result = $fact->demande_prelevement($user); + if ($result > 0) + { + Header("Location: prelevement.php?facid=".$fact->id); + exit; + } + else + { + $mesg='
'.$fact->error.'
'; + } + } } if ($_GET["action"] == "delete") { - $fact = new Facture($db); - if ($fact->fetch($_GET["facid"])) - { - $result = $fact->demande_prelevement_delete($user,$_GET["did"]); - if ($result == 0) - { - Header("Location: prelevement.php?facid=".$fact->id); - } - } + $fact = new Facture($db); + if ($fact->fetch($_GET["facid"])) + { + $result = $fact->demande_prelevement_delete($user,$_GET["did"]); + if ($result == 0) + { + Header("Location: prelevement.php?facid=".$fact->id); + exit; + } + } } +/* + * View + */ llxHeader('',$langs->trans("Bill")); @@ -96,210 +97,210 @@ $html = new Form($db); if ($_GET["facid"] > 0) { - $fac = New Facture($db); - if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0) - { - if ($mesg) print $mesg.'
'; + $fac = New Facture($db); + if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0) + { + if ($mesg) print $mesg.'
'; - $soc = new Societe($db, $fac->socid); - $soc->fetch($fac->socid); + $soc = new Societe($db, $fac->socid); + $soc->fetch($fac->socid); - $author = new User($db); - if ($fac->user_author) - { - $author->id = $fac->user_author; - $author->fetch(); - } + $author = new User($db); + if ($fac->user_author) + { + $author->id = $fac->user_author; + $author->fetch(); + } $head = facture_prepare_head($fac); dolibarr_fiche_head($head, 'standingorders', $langs->trans('InvoiceCustomer')); - /* - * Facture - */ - print ''; + /* + * Facture + */ + print '
'; // Reference du facture print '"; - // Societe - print ''; - print ''; - print ''; + // Societe + print ''; + print ''; + print ''; - // Dates - print ''; - print ''; - print '"; + // Dates + print ''; + print ''; + print '"; - // Conditions et modes de réglement - print ''; - print ''; + // Conditions et modes de réglement + print ''; + print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; + print ''; - print '
'.$langs->trans("Ref").''; print $fac->ref; print "
'.$langs->trans("Company").''; - print ''.$soc->nom.'
'.$langs->trans("Company").''; + print ''.$soc->nom.'
'.$langs->trans("Date").''.dolibarr_print_date($fac->date,"daytext").''.$langs->trans("DateMaxPayment").'' . dolibarr_print_date($fac->date_lim_reglement,"daytext"); - if ($fac->date_lim_reglement < (time() - $conf->facture->client->warning_delay) && ! $fac->paye && $fac->statut == 1 && ! $fac->am) print img_warning($langs->trans("Late")); - print "
'.$langs->trans("Date").''.dolibarr_print_date($fac->date,"daytext").''.$langs->trans("DateMaxPayment").'' . dolibarr_print_date($fac->date_lim_reglement,"daytext"); + if ($fac->date_lim_reglement < (time() - $conf->facture->client->warning_delay) && ! $fac->paye && $fac->statut == 1 && ! $fac->am) print img_warning($langs->trans("Late")); + print "
'.$langs->trans("PaymentConditions").''; - $html->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->cond_reglement_id,"none"); - print ''.$langs->trans("PaymentMode").''; - $html->form_modes_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->mode_reglement_id,"none"); - print '
'.$langs->trans("PaymentConditions").''; + $html->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->cond_reglement_id,"none"); + print ''.$langs->trans("PaymentMode").''; + $html->form_modes_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->mode_reglement_id,"none"); + print '
'.$langs->trans("AmountHT").''.price($fac->total_ht).''.$langs->trans("Currency".$conf->monnaie).' 
'.$langs->trans("AmountHT").''.price($fac->total_ht).''.$langs->trans("Currency".$conf->monnaie).' 
'.$langs->trans("AmountTTC").''.price($fac->total_ttc).''.$langs->trans("Currency".$conf->monnaie).' 
'.$langs->trans("AmountTTC").''.price($fac->total_ttc).''.$langs->trans("Currency".$conf->monnaie).' 
RIB'; - print $soc->display_rib(); - print '
'.$langs->trans("RIB").''; + print $soc->display_rib(); + print '
'; - print ''; - - /* - * Demande de prélèvement - * - */ + print ''; + print ''; - $sql = "SELECT pfd.rowid, pfd.traite,".$db->pdate("pfd.date_demande")." as date_demande"; - $sql .= " ,".$db->pdate("pfd.date_traite")." as date_traite"; - $sql .= " , pfd.amount"; - $sql .= " , u.rowid as user_id, u.name, u.firstname, u.login"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql .= " , ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE fk_facture = ".$fac->id; - $sql .= " AND pfd.fk_user_demande = u.rowid"; - $sql .= " AND pfd.traite = 0"; - $sql .= " ORDER BY pfd.date_demande DESC"; + /* + * Demande de prélèvement + * + */ - $result_sql = $db->query($sql); - if ($result_sql) - { - $num = $db->num_rows($result_sql); - } + $sql = "SELECT pfd.rowid, pfd.traite,".$db->pdate("pfd.date_demande")." as date_demande"; + $sql .= " ,".$db->pdate("pfd.date_traite")." as date_traite"; + $sql .= " , pfd.amount"; + $sql .= " , u.rowid as user_id, u.name, u.firstname, u.login"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " , ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE fk_facture = ".$fac->id; + $sql .= " AND pfd.fk_user_demande = u.rowid"; + $sql .= " AND pfd.traite = 0"; + $sql .= " ORDER BY pfd.date_demande DESC"; + + $result_sql = $db->query($sql); + if ($result_sql) + { + $num = $db->num_rows($result_sql); + } - print "
\n"; + print "
\n"; - // Valider - if ($fac->statut > 0 && $fac->paye == 0 && $fac->mode_reglement_code == 'PRE' && $num == 0) - { - if ($user->rights->facture->creer) - { - print 'Faire une demande de prélèvement'; - } - } - print "

"; + // Add a withdraw request + if ($fac->statut > 0 && $fac->paye == 0 && $fac->mode_reglement_code == 'PRE' && $num == 0) + { + if ($user->rights->facture->creer) + { + print ''.$langs->trans("MakeWithdrawRequest").''; + } + } + print "

"; - - /* - * Prélèvement - */ - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $var=True; + /* + * Prélèvement + */ + print '
'.$langs->trans("DateRequest").''.$langs->trans("DateProcess").''.$langs->trans("Amount").''.$langs->trans("WithdrawalReceipt").''.$langs->trans("User").'  
'; - if ($result_sql) - { - $i = 0; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=True; - while ($i < $num) - { - $obj = $db->fetch_object($result_sql); - $var=!$var; + if ($result_sql) + { + $i = 0; - print ""; - print '\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $i++; - } + while ($i < $num) + { + $obj = $db->fetch_object($result_sql); + $var=!$var; - $db->free($result_sql); - } - else - { - dolibarr_print_error($db); - } + print ""; + print '\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $i++; + } - $sql = "SELECT pfd.rowid, pfd.traite,".$db->pdate("pfd.date_demande")." as date_demande"; - $sql .= " ,".$db->pdate("pfd.date_traite")." as date_traite"; - $sql .= " , pfd.fk_prelevement_bons, pfd.amount"; - $sql .= " , u.rowid as user_id, u.name, u.firstname, u.login"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql .= " , ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE fk_facture = ".$fac->id; - $sql .= " AND pfd.fk_user_demande = u.rowid"; - $sql .= " AND pfd.traite = 1"; - $sql .= " ORDER BY pfd.date_demande DESC"; + $db->free($result_sql); + } + else + { + dolibarr_print_error($db); + } - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; + $sql = "SELECT pfd.rowid, pfd.traite,".$db->pdate("pfd.date_demande")." as date_demande"; + $sql .= " ,".$db->pdate("pfd.date_traite")." as date_traite"; + $sql .= " , pfd.fk_prelevement_bons, pfd.amount"; + $sql .= " , u.rowid as user_id, u.name, u.firstname, u.login"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " , ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE fk_facture = ".$fac->id; + $sql .= " AND pfd.fk_user_demande = u.rowid"; + $sql .= " AND pfd.traite = 1"; + $sql .= " ORDER BY pfd.date_demande DESC"; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $var=!$var; + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; - print ""; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $var=!$var; - print '\n"; + print ""; - print '\n"; + print '\n"; - print ''; + print '\n"; - print '\n"; + print ''; - print ''; + print '\n"; - print ''; - print ''; + print ''; - print "\n"; - $i++; - } + print ''; + print ''; - $db->free($result); - } - else - { - dolibarr_print_error($db); - } + print "\n"; + $i++; + } - print "
'.$langs->trans("DateRequest").''.$langs->trans("DateProcess").''.$langs->trans("Amount").''.$langs->trans("WithdrawalReceipt").''.$langs->trans("User").'  
'.dolibarr_print_date($obj->date_demande)."En attente de traitement'.price($obj->amount).'-'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.' '; - print ''; - print img_delete(); - print '
'.dolibarr_print_date($obj->date_demande,'day')."En attente de traitement'.price($obj->amount).'-'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.' '; + print ''; + print img_delete(); + print '
'.dolibarr_print_date($obj->date_demande)."
'.dolibarr_print_date($obj->date_traite)."'.dolibarr_print_date($obj->date_demande)."'.price($obj->amount).''.dolibarr_print_date($obj->date_traite)."'; - print ''.$obj->fk_prelevement_bons."'.price($obj->amount).''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.''; + print ''.$obj->fk_prelevement_bons."  '.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'
  
"; + $db->free($result); + } + else + { + dolibarr_print_error($db); + } - } - else - { - /* Facture non trouvée */ - print $langs->trans("ErrorBillNotFound",$_GET["facid"]); - } -} + print ""; + + } + else + { + /* Facture non trouvée */ + print $langs->trans("ErrorBillNotFound",$_GET["facid"]); + } +} print ''; diff --git a/htdocs/compta/prelevement/bon-prelevement.class.php b/htdocs/compta/prelevement/bon-prelevement.class.php index 0998e361e23..3940a0035de 100644 --- a/htdocs/compta/prelevement/bon-prelevement.class.php +++ b/htdocs/compta/prelevement/bon-prelevement.class.php @@ -26,11 +26,16 @@ \version $Revision$ */ +require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php"); +require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); +require_once(DOL_DOCUMENT_ROOT."/societe.class.php"); -require_once (DOL_DOCUMENT_ROOT."/facture.class.php"); -require_once (DOL_DOCUMENT_ROOT."/societe.class.php"); -class BonPrelevement +/** + * \class BonPrelevement + * \brief Classe permettant la gestion des bons de prelevements + */ +class BonPrelevement extends CommonObject { var $db; @@ -43,6 +48,7 @@ class BonPrelevement var $total; var $_fetched; + function BonPrelevement($DB, $filename='') { $error = 0; @@ -195,7 +201,7 @@ class BonPrelevement * * */ - function Fetch($rowid) + function fetch($rowid) { $sql = "SELECT p.rowid, p.ref, p.amount, p.note, p.credite"; $sql .= ",".$this->db->pdate("p.datec")." as dc"; @@ -205,9 +211,9 @@ class BonPrelevement $sql .= " , fk_user_credit"; $sql .= " , statut"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; - $sql .= " WHERE p.rowid=".$rowid; + dolibarr_syslog("Bon-prelevement::fetch sql=".$sql, LOG_DEBUG); $result=$this->db->query($sql); if ($result) { @@ -595,26 +601,23 @@ class BonPrelevement } /** - * \brief Renvoi nombre de factures a pr�lever + * \brief Renvoi nombre de factures a prelever * \param banque bank * \param agence agence * \return int db, PRELEVEMENT_USER); + $user = new User($this->db, $conf->global->PRELEVEMENT_USER); /** * Lectures des factures @@ -676,7 +680,6 @@ class BonPrelevement if (! $error) { - $sql = "SELECT f.rowid, pfd.rowid as pfdrowid, f.fk_soc"; $sql .= ", pfd.code_banque, pfd.code_guichet, pfd.number, pfd.cle_rib"; $sql .= ", pfd.amount"; @@ -684,17 +687,14 @@ class BonPrelevement $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " , ".MAIN_DB_PREFIX."societe as s"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql .= " , ".MAIN_DB_PREFIX."societe_rib as sr"; - + if ($banque == 1 || $agence ==1) $sql .= " , ".MAIN_DB_PREFIX."societe_rib as sr"; $sql .= " WHERE f.rowid = pfd.fk_facture"; $sql .= " AND s.rowid = f.fk_soc"; - $sql .= " AND s.rowid = sr.fk_soc"; + if ($banque == 1 || $agence ==1) $sql .= " AND s.rowid = sr.fk_soc"; $sql .= " AND f.fk_statut = 1"; $sql .= " AND f.paye = 0"; $sql .= " AND pfd.traite = 0"; $sql .= " AND f.total_ttc > 0"; - $sql .= " AND f.fk_mode_reglement = 3"; // Mode pr�l�vement - if ($banque == 1) { $sql .= " AND sr.code_banque = '".PRELEVEMENT_CODE_BANQUE."'"; @@ -704,8 +704,8 @@ class BonPrelevement $sql .= " AND sr.code_guichet = '".PRELEVEMENT_CODE_GUICHET."'"; } + dolibarr_syslog("Bon-Prelevement::Create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) { $num = $this->db->num_rows($resql); @@ -718,7 +718,7 @@ class BonPrelevement $i++; } $this->db->free($resql); - dolibarr_syslog("$i factures � pr�lever"); + dolibarr_syslog($i." invoices to withdraw"); } else { @@ -728,20 +728,11 @@ class BonPrelevement } } - /* - * - * Verif des clients - * - */ - if (! $error) { - /* - * V�rification des RIB - * - */ - $i = 0; - dolibarr_syslog("D�but v�rification des RIB"); + // Check RIB + $i = 0; + dolibarr_syslog("Start RIB check"); if (sizeof($factures) > 0) { @@ -763,18 +754,18 @@ class BonPrelevement } else { - dolibarr_syslog("Erreur de RIB societe $fact->socid $soc->nom"); + dolibarr_syslog("Erreur de RIB societe $fact->socid $soc->nom", LOG_ERROR); $facture_errors[$fac[0]]="Erreur de RIB societe $fact->socid $soc->nom"; } } else { - dolibarr_syslog("Impossible de lire la soci�t�"); + dolibarr_syslog("Failed to read company", LOG_ERROR); } } else { - dolibarr_syslog("Impossible de lire la facture"); + dolibarr_syslog("Impossible de lire la facture", LOG_ERROR); } } } @@ -785,12 +776,8 @@ class BonPrelevement } - /* - * - * - */ - - dolibarr_syslog(sizeof($factures_prev)." factures seront pr�lev�es"); + // Withdraw invoices in factures_prev array + dolibarr_syslog(sizeof($factures_prev)." invoices will be withdrawed"); if (sizeof($factures_prev) > 0) { @@ -815,6 +802,7 @@ class BonPrelevement $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."prelevement_bons"; $sql .= " WHERE ref LIKE '$ref%'"; + dolibarr_syslog("Bon-Prelevement::Create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -831,14 +819,11 @@ class BonPrelevement $filebonprev = $ref; - /* - * Creation du bon de prelevement - * - */ - + // Create withdraw receipt in database $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons (ref,datec)"; $sql .= " VALUES ('".$ref."',".$this->db->idate(mktime()).")"; + dolibarr_syslog("Bon-Prelevement::Create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -855,7 +840,7 @@ class BonPrelevement else { $error++; - dolibarr_syslog("Erreur cr�ation du bon de prelevement"); + dolibarr_syslog("Erreur creation du bon de prelevement"); } } @@ -865,25 +850,26 @@ class BonPrelevement */ if (!$error) { - dolibarr_syslog("D�but g�n�ration des paiements"); - dolibarr_syslog("Nombre de factures ".sizeof($factures_prev)); + dolibarr_syslog("Start generation payments for the ".sizeof($factures_prev)." invoices"); if (sizeof($factures_prev) > 0) { foreach ($factures_prev as $fac) { + // Fetch invoice $fact = new Facture($this->db); $fact->fetch($fac[0]); + // Create payment $pai = new Paiement($this->db); $pai->amounts = array(); $pai->amounts[$fac[0]] = $fact->total_ttc; - $pai->datepaye = $this->db->idate($datetimeprev); + $pai->datepaye = $datetimeprev; $pai->paiementid = 3; // pr�l�vement $pai->num_paiement = $ref; - if ($pai->create($user, 1) == -1) // on appelle en no_commit + if ($pai->create($user, 1) < 0) // on appelle en no_commit { $error++; dolibarr_syslog("Erreur creation paiement facture ".$fac[0]); @@ -925,6 +911,7 @@ class BonPrelevement $sql .= ", fk_prelevement_bons = ".$prev_id; $sql .= " WHERE rowid=".$fac[1]; + dolibarr_syslog("Bon-Prelevement::Create sql=".$sql, LOG_DEBUG); if ($this->db->query($sql)) { @@ -984,11 +971,12 @@ class BonPrelevement $sql .= " SET amount = ".price2num($bonprev->total); $sql .= " WHERE rowid = ".$prev_id; + dolibarr_syslog("Bon-Prelevement::Create sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { $error++; - dolibarr_syslog("Erreur mise � jour du total - $sql"); + dolibarr_syslog("Erreur mise a jour du total - $sql"); } /* @@ -998,12 +986,10 @@ class BonPrelevement if (!$error) { $this->db->commit(); - dolibarr_syslog("COMMIT"); } else { $this->db->rollback(); - dolibarr_syslog("ROLLBACK"); } return sizeof($factures_prev); @@ -1014,6 +1000,34 @@ class BonPrelevement } } + + /** + * \brief Renvoie nom clicable (avec eventuellement le picto) + * \param withpicto Inclut le picto dans le lien + * \param option Sur quoi pointe le lien + * \return string Chaine avec URL + */ + function getNomUrl($withpicto=0,$option='') + { + global $langs; + + $result=''; + + $lien = ''; + $lienfin=''; + + if ($option == 'xxx') + { + $lien = ''; + $lienfin=''; + } + + if ($withpicto) $result.=($lien.img_object($langs->trans("ShowWithdraw"),'payment').$lienfin.' '); + $result.=$lien.$this->ref.$lienfin; + return $result; + } + + /** * * @@ -1023,7 +1037,7 @@ class BonPrelevement $result = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_notifications "; - $sql .= " WHERE rowid = '".$rowid."';"; + $sql .= " WHERE rowid = '".$rowid."'"; if ($this->db->query($sql)) { @@ -1044,7 +1058,7 @@ class BonPrelevement $result = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_notifications "; - $sql .= " WHERE fk_user = '".$user."' AND action = '".$action."';"; + $sql .= " WHERE fk_user = '".$user."' AND action = '".$action."'"; if ($this->db->query($sql)) { @@ -1086,7 +1100,7 @@ class BonPrelevement } /** - * G�n�ration d'un bon de pr�l�vement + * Generation d'un bon de pr�l�vement * */ function Generate() diff --git a/htdocs/compta/prelevement/bon.php b/htdocs/compta/prelevement/bon.php index aa0b03a9127..116eb352a2e 100644 --- a/htdocs/compta/prelevement/bon.php +++ b/htdocs/compta/prelevement/bon.php @@ -15,17 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ - * */ /** \file htdocs/compta/prelevement/bon.php \ingroup prelevement \brief Fiche aperçu du bon de prelevement - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -146,5 +142,5 @@ if ($_GET["id"]) print ""; -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 7cb809ce404..ccbb017af17 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005 Laurent Destailleur +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2005-2008 Laurent Destailleur * * 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 @@ -15,16 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ */ /** \file htdocs/compta/prelevement/bons.php \ingroup prelevement \brief Page liste des bons de prelevements - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -108,7 +105,7 @@ if ($result) print ''.dolibarr_print_date($obj->datec,'day')."\n"; - print ''.price($obj->amount).' '.$langs->trans("Currency".$conf->monnaie)."\n"; + print ''.price($obj->amount)."\n"; print "\n"; $i++; diff --git a/htdocs/compta/prelevement/config.php b/htdocs/compta/prelevement/config.php index 3578b26c730..70fae9feb00 100644 --- a/htdocs/compta/prelevement/config.php +++ b/htdocs/compta/prelevement/config.php @@ -184,94 +184,98 @@ print '
'; * TODO Use notification module instead */ -print_titre($langs->trans("Notifications")); - -if ($user->rights->prelevement->bons->configurer) -print '
'; - -print ''; -print ''; -print ''; -print ''; -if ($user->rights->prelevement->bons->configurer) -print ''; -print "\n"; - -if ($user->rights->prelevement->bons->configurer) +if ($conf->global->MAIN_MODULE_NOTIFICATION) { - print '"; - - print ''; - print ''; - - if ($user->rights->prelevement->bons->configurer) - { - print ''; - } - else - { - print ''; - } - $i++; - } - $db->free($resql); -} -print '
NomValeurAction
'; - print ''; - print ''; + print ''; + print ''; + print ''; + if ($user->rights->prelevement->bons->configurer) + print ''; + print "\n"; + + if ($user->rights->prelevement->bons->configurer) { - $num = $db->num_rows(); + print ''; + + print ''; + + print ''; + } + + + $sql = "SELECT u.name, u.firstname, pn.action, pn.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " , ".MAIN_DB_PREFIX."prelevement_notifications as pn"; + $sql .= " WHERE u.rowid = pn.fk_user"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); $i = 0; + $var = True; while ($i < $num) { - $obj = $db->fetch_object(); - print '"; + + print ''; + print ''; + + if ($user->rights->prelevement->bons->configurer) + { + print ''; + } + else + { + print ''; + } + $i++; } - $db->free(); + $db->free($resql); } - - print ''; - - print ''; - - print ''; + print '
NomValeurAction
'; + print ''; + print ''; + print '
'.$obj->firstname." ".$obj->name.''.$obj->action.'rowid.'">'.img_delete().'
'; - print '
'; + + if ($user->rights->prelevement->bons->configurer) + print ''; } -$sql = "SELECT u.name, u.firstname, pn.action, pn.rowid"; -$sql .= " FROM ".MAIN_DB_PREFIX."user as u"; -$sql .= " , ".MAIN_DB_PREFIX."prelevement_notifications as pn"; -$sql .= " WHERE u.rowid = pn.fk_user"; - -$resql = $db->query($sql); -if ($resql) -{ - $num = $db->num_rows($resql); - $i = 0; - $var = True; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - - $var=!$var; - print "
'.$obj->firstname." ".$obj->name.''.$obj->action.'rowid.'">'.img_delete().'
'; - -if ($user->rights->prelevement->bons->configurer) -print ''; - - $db->close(); llxFooter('$Date$ - $Revision$'); diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 22717407c74..78ad053da0e 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -17,13 +17,15 @@ */ /** - \file htdocs/compta/prelevement/create.php - \brief Prelevement - \version $Id$ -*/ + \file htdocs/compta/prelevement/create.php + \brief Prelevement + \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/modPrelevement.class.php"); +require_once DOL_DOCUMENT_ROOT."/facture.class.php"; +require_once DOL_DOCUMENT_ROOT."/societe.class.php"; $langs->load("widthdrawals"); $langs->load("companies"); @@ -32,7 +34,7 @@ $langs->load("bills"); if (!$user->rights->prelevement->bons->creer) - accessforbidden(); +accessforbidden(); /* @@ -41,16 +43,16 @@ if (!$user->rights->prelevement->bons->creer) if ($_GET["action"] == 'create') { - $bprev = new BonPrelevement($db); - $result=$bprev->create($_GET["banque"],$_GET["guichet"]); - if ($result < 0) - { - $mesg='
'.$bprev->error.'
'; - } - if ($result == 0) - { - $mesg='
Aucune facture prélevable, prélevé avec succès
'; - } + $bprev = new BonPrelevement($db); + $result=$bprev->create($_GET["banque"],$_GET["guichet"]); + if ($result < 0) + { + $mesg='
'.$bprev->error.'
'; + } + if ($result == 0) + { + $mesg='
'.$langs->trans("NoInvoiceCouldBeWithdrawed").'
'; + } } @@ -58,6 +60,10 @@ if ($_GET["action"] == 'create') * View */ +$thirdpartystatic=new Societe($db); +$invoicestatic=new Facture($db); +$bprev = new BonPrelevement($db); + llxHeader(); $h=0; @@ -67,22 +73,24 @@ $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("StandingOrders")); -$bprev = new BonPrelevement($db); $nb=$bprev->NbFactureAPrelever(); $nb1=$bprev->NbFactureAPrelever(1); $nb11=$bprev->NbFactureAPrelever(1,1); if ($nb < 0 || $nb1 < 0 || $nb11 < 0) { - dolibarr_print_error($bprev->error); + dolibarr_print_error($bprev->error); } print ''; + print ''; print ''; +print ''; +print ''; @@ -90,9 +98,9 @@ print ''; print ''; -print ''; - -print '
'.$langs->trans("NbOfInvoiceToWithdraw").''; print $nb; -print ''.$langs->trans("BankCode").''; +print '
'.$langs->trans("NbOfInvoiceToWithdraw").' '.$langs->trans("ThirdPartyBankCode").'='.PRELEVEMENT_CODE_BANQUE.''; print $nb1; -print ''.$langs->trans("DeskCode").''; +print '
'.$langs->trans("NbOfInvoiceToWithdraw").' '.$langs->trans("ThirdPartyDeskCode").'='.PRELEVEMENT_CODE_GUICHET.''; print $nb11; print '
'.$langs->trans("AmountToWithdraw").''; print price($bprev->SommeAPrelever()); print ' 
'; +print ''; + +print ''; print ''; @@ -100,17 +108,17 @@ if ($mesg) print $mesg; if ($nb) { - print "
\n"; - - if ($nb) print ''.$langs->trans("Create")."\n"; - if ($nb1) print ''.$langs->trans("CreateGuichet")."\n"; - if ($nb11) print ''.$langs->trans("CreateBanque")."\n"; - - print "
\n"; + print "
\n"; + + if ($nb) print ''.$langs->trans("Create")."\n"; + if ($nb1) print ''.$langs->trans("CreateGuichet")."\n"; + if ($nb11) print ''.$langs->trans("CreateBanque")."\n"; + + print "
\n"; } else { - print $langs->trans("NoInvoiceToWithdraw").'
'; + print $langs->trans("NoInvoiceToWithdraw").'
'; } print '
'; @@ -126,42 +134,44 @@ $sql.= ", p.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql.= " ORDER BY datec DESC"; $sql.=$db->plimit($limit); - + $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; + $num = $db->num_rows($result); + $i = 0; - print"\n\n"; - print ''; - print ''; - print ''; - print ''; + print"\n\n"; + print '
'.$langs->trans("LastWithdrawalReceipts",$limit).''.$langs->trans("Amount").'
'; + print ''; + print ''; + print ''; - $var=True; + $var=True; - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($result); - $var=!$var; + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($result); + $var=!$var; - print "\n"; - print '\n"; + print "\n"; + print '\n"; - print '\n"; + print '\n"; - print "\n"; - $i++; - } - print "
'.$langs->trans("LastWithdrawalReceipts",$limit).''.$langs->trans("Amount").'
"; - print ' '; - print ''.$obj->ref."'.dolibarr_print_date($obj->datec,'day')."
"; + $bprev->id=$obj->rowid; + $bprev->ref=$obj->ref; + print $bprev->getNomUrl(1); + print "'.dolibarr_print_date($obj->datec,'day')."'.price($obj->amount).' '.$langs->trans("Currency".$conf->monnaie)."'.price($obj->amount).' '.$langs->trans("Currency".$conf->monnaie)."

"; - $db->free($result); + print "\n"; + $i++; + } + print "
"; + $db->free($result); } -else +else { - dolibarr_print_error($db); + dolibarr_print_error($db); } @@ -178,39 +188,46 @@ $sql .= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid"; if ($socid) { - $sql .= " AND f.fk_soc = $socid"; + $sql .= " AND f.fk_soc = $socid"; } if ( $db->query($sql) ) { - $num = $db->num_rows(); - $i = 0; - - if ($num) - { - print ''; - print ''; - print ''; - $var = True; - while ($i < $num && $i < 20) - { - $obj = $db->fetch_object(); - $var=!$var; - print ''; - print ''; - print ''; - $i++; - } - - print "
Factures en attente de prélèvement ('.$num.')
'; - print ''.img_file().' '.$obj->facnumber.''.img_object($langs->trans("ShowCompany"),'company').' '.$obj->nom.'

"; + $num = $db->num_rows(); + $i = 0; - } + if ($num) + { + print ''; + print ''; + print ''; + $var = True; + while ($i < $num && $i < 20) + { + $obj = $db->fetch_object(); + $var=!$var; + print ''; + print ''; + print ''; + $i++; + } + + print "
'.$langs->trans("InvoiceWaitingWithdraw").' ('.$num.')
'; + $invoicestatic->id=$obj->rowid; + $invoicestatic->ref=$obj->facnumber; + print $invoicestatic->getNomUrl(1,'withdraw'); + print ''; + $thirdpartystatic->id=$obj->socid; + $thirdpartystatic->nom=$obj->nom; + print $thirdpartystatic->getNomUrl(1,'customer'); + print '

"; + + } } else { - dolibarr_print_error($db); -} + dolibarr_print_error($db); +} llxFooter('$Date$ - $Revision$'); diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 71a411ed949..8c367ae7a5a 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005 Laurent Destailleur + * Copyright (C) 2005-2008 Laurent Destailleur * Copyright (C) 2005-2006 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -19,13 +19,15 @@ */ /** - \file htdocs/compta/prelevement/demandes.php - \brief Page de la liste des demandes de prélèvements - \version $Id$ -*/ + \file htdocs/compta/prelevement/demandes.php + \brief Page de la liste des demandes de prélèvements + \version $Id$ + */ require("./pre.inc.php"); require_once DOL_DOCUMENT_ROOT."/includes/modules/modPrelevement.class.php"; +require_once DOL_DOCUMENT_ROOT."/facture.class.php"; +require_once DOL_DOCUMENT_ROOT."/societe.class.php"; $langs->load("widthdrawals"); $langs->load("companies"); @@ -36,11 +38,14 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement','',''); +/* + * View + */ + llxHeader(); -/* - * - */ +$thirdpartystatic=new Societe($db); +$invoicestatic=new Facture($db); $page = $_GET["page"]; $sortorder = $_GET["sortorder"]; @@ -73,79 +78,89 @@ if ($statut) $sql.= " AND pfd.traite = ".$statut; $sql.= " AND pfd.fk_facture = f.rowid"; if (strlen(trim($_GET["search_societe"]))) { - $sql .= " AND s.nom LIKE '%".$_GET["search_societe"]."%'"; + $sql .= " AND s.nom LIKE '%".$_GET["search_societe"]."%'"; } if ($socid) { - $sql .= " AND f.fk_soc = $socid"; + $sql .= " AND f.fk_soc = $socid"; } $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); if ( $db->query($sql) ) { - $num = $db->num_rows(); - $i = 0; - -if (! $statut) -{ - print_barre_liste($langs->trans("RequestStandingOrderToTreat"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num); -} -else -{ - print_barre_liste($langs->trans("RequestStandingOrderTreated"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num); -} - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $num = $db->num_rows(); + $i = 0; - $var = True; - - $users = array(); - - while ($i < min($num,$conf->liste_limit)) - { - $obj = $db->fetch_object(); - $var=!$var; - print ''; - - // Ref facture - print ''; - - print ''; - - print ''; - - if (!array_key_exists($obj->fk_user_demande,$users)) + if (! $statut) { - $users[$obj->fk_user_demande] = new User($db, $obj->fk_user_demande); - $users[$obj->fk_user_demande]->fetch(); + print_barre_liste($langs->trans("RequestStandingOrderToTreat"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num); + } + else + { + print_barre_liste($langs->trans("RequestStandingOrderTreated"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num); } - // User - print ''; + print '
'.$langs->trans("Bill").''.$langs->trans("Company").''.$langs->trans("Date").''.$langs->trans("Author").'
'.img_file().' '.$obj->facnumber.''.img_object($langs->trans("ShowCompany"),'company').' '.$obj->nom.''.dolibarr_print_date($obj->date_demande).''.img_object($langs->trans("ShowUser"),'user').' '.$users[$obj->fk_user_demande]->code.'
'; + print ''; + print ''; + print ''; + print ''; + print ''; - print ''; - $i++; - } - - print "
'.$langs->trans("Bill").''.$langs->trans("Company").''.$langs->trans("DateRequest").''.$langs->trans("Author").'

"; + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + + $var = True; + + $users = array(); + + while ($i < min($num,$conf->liste_limit)) + { + $obj = $db->fetch_object(); + $var=!$var; + print ''; + + // Ref facture + print ''; + $invoicestatic->id=$obj->rowid; + $invoicestatic->ref=$obj->facnumber; + print $invoicestatic->getNomUrl(1,'withdraw'); + print ''; + + print ''; + $thirdpartystatic->id=$obj->socid; + $thirdpartystatic->nom=$obj->nom; + print $thirdpartystatic->getNomUrl(1,'customer'); + print ''; + + print ''.dolibarr_print_date($obj->date_demande,'day').''; + + if (!array_key_exists($obj->fk_user_demande,$users)) + { + $users[$obj->fk_user_demande] = new User($db, $obj->fk_user_demande); + $users[$obj->fk_user_demande]->fetch(); + } + + // User + print ''; + print $users[$obj->fk_user_demande]->getNomUrl(1); + print ''; + + print ''; + $i++; + } + + print "
"; } else { - dolibarr_print_error($db); -} + dolibarr_print_error($db); +} llxFooter('$Date$ - $Revision$'); diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 26e12a68f85..eb2eee31ddf 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -15,26 +15,25 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ */ /** \file htdocs/compta/prelevement/factures.php \ingroup prelevement \brief Page liste des factures prélevées - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/rejet-prelevement.class.php"); require_once(DOL_DOCUMENT_ROOT."/paiement.class.php"); +$langs->load("companies"); + // Sécurité accés client if ($user->societe_id > 0) accessforbidden(); -llxHeader('','Bon de prélèvement'); +llxHeader('',$langs->trans("WithdrawalReceipt")); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche.php?id='.$_GET["id"]; @@ -74,11 +73,13 @@ if ($_GET["id"]) if ($bon->fetch($_GET["id"]) == 0) { - dolibarr_fiche_head($head, $hselected, 'Prélèvement : '. $bon->ref); + dolibarr_fiche_head($head, $hselected, $langs->trans("WithdrawalReceipt")); print ''; - print ''; - print '
'.$langs->trans("Ref").''.$bon->ref.'

'; + print ''.$langs->trans("Ref").''.$bon->getNomUrl(1).''; + print ''; + + print ''; } else { @@ -128,7 +129,7 @@ if ($result) $urladd = "&id=".$_GET["id"]; - print_barre_liste($langs->trans("Bills"), $page, "factures.php", $urladd, $sortfield, $sortorder, '', $num); + print_barre_liste("", $page, "factures.php", $urladd, $sortfield, $sortorder, '', $num); print"\n\n"; print ''; @@ -138,7 +139,7 @@ if ($result) print_liste_field_titre($langs->trans("Amount"),"factures.php","f.total_ttc","",$urladd,'class="liste_titre" align="center"',$sortfield,$sortorder); print ''; - $var=True; + $var=false; $total = 0; diff --git a/htdocs/compta/prelevement/facturesrejets.php b/htdocs/compta/prelevement/facturesrejets.php index a854c2ff512..bed1df54fd9 100644 --- a/htdocs/compta/prelevement/facturesrejets.php +++ b/htdocs/compta/prelevement/facturesrejets.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT."/paiement.class.php"; */ if ($user->societe_id > 0) accessforbidden(); -llxHeader('','Bon de prélèvement - Rejet'); +llxHeader('',$langs->trans("WithdrawalReceipt")); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche.php?id='.$_GET["id"]; @@ -105,9 +105,9 @@ if ($result) print '
 
'; print ''; print_liste_field_titre("Bon N°","rejets.php","p.ref",'',$urladd); - print_liste_field_titre("Facture","rejets.php","p.facnumber",'',$urladd); - print_liste_field_titre("Société","rejets.php","s.nom",'',$urladd); - print_liste_field_titre("Montant","rejets.php","f.total_ttc","",$urladd,'align="center"'); + print_liste_field_titre($langs->trans("Invoice"),"rejets.php","p.facnumber",'',$urladd); + print_liste_field_titre($langs->trans("ThirdParty"),"rejets.php","s.nom",'',$urladd); + print_liste_field_titre($langs->trans("Amount"),"rejets.php","f.total_ttc","",$urladd,'align="center"'); print ''; $var=True; @@ -156,5 +156,5 @@ else $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index ed098b1374f..4b05e8c28c4 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -15,9 +15,10 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ + */ + +/* + * \version $Id$ */ require("./pre.inc.php"); @@ -27,7 +28,7 @@ require_once(DOL_DOCUMENT_ROOT."/paiement.class.php"); // Sécurité accés client if ($user->societe_id > 0) accessforbidden(); -llxHeader('','Bon de prélèvement - Rejet'); +llxHeader('',$langs->trans("WithdrawalReceipt")); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche.php?id='.$_GET["id"]; @@ -66,11 +67,13 @@ if ($_GET["id"]) if ($bon->fetch($_GET["id"]) == 0) { - dolibarr_fiche_head($head, $hselected, 'Prélèvement : '. $bon->ref); + dolibarr_fiche_head($head, $hselected, $langs->trans("WithdrawalReceipt")); print '
 
'; - print ''; - print '
Référence'.$bon->ref.'

'; + print ''.$langs->trans("Ref").''.$bon->getNomUrl(1).''; + print ''; + + print ''; } else { @@ -111,11 +114,11 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - print_barre_liste("Lignes de prélèvement rejetées", $page, "fiche-rejet.php", $urladd, $sortfield, $sortorder, '', $num); print"\n\n"; print ''; print ''; - print ''; + print ''; + print ''; $var=True; $total = 0; @@ -144,8 +147,8 @@ if ($resql) $i++; } - print ""; - print "\n"; + print ''; + print ''; print '\n"; print ''; print "\n
LigneSociétéMontantMotifA FacturerFacture
'.$langs->trans("Line").''.$langs->trans("ThirdParty").''.$langs->trans("Amount").''.$langs->trans("Reason").''.$langs->trans("ToBill").''.$langs->trans("Invoice").'
 Total
 '.$langs->trans("Total").''.price($total)." 
\n"; diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 56e6e033fd5..df2eee839cd 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -15,9 +15,10 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ + */ + +/* + * \version $Id$ */ require("./pre.inc.php"); @@ -25,7 +26,12 @@ require("./pre.inc.php"); // Sécurité accés client if ($user->societe_id > 0) accessforbidden(); -llxHeader('','Statistique Bon de prélèvement'); + +/* + * View + */ + +llxHeader('',$langs->trans("WithdrawalReceipt")); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche.php?id='.$_GET["id"]; @@ -64,13 +70,15 @@ if ($prev_id) if ($bon->fetch($_GET["id"]) == 0) { - dolibarr_fiche_head($head, $hselected, 'Prélèvement : '. $bon->ref); + dolibarr_fiche_head($head, $hselected, $langs->trans("WithdrawalReceipt")); print ''; - print ''; + print ''; - print '
Référence'.$bon->ref.'
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'

'; + print ''; + + print ''; } else { @@ -97,7 +105,7 @@ if ($prev_id) print ''; print 'StatutMontant%'; - $var=True; + $var=false; while ($i < $num) { @@ -116,7 +124,8 @@ if ($prev_id) elseif ($row[1] == 1) { print 'En attente'; - } + } + else print 'Unknown'; print ''; print price($row[0]); @@ -142,5 +151,5 @@ if ($prev_id) $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/compta/prelevement/fiche.php b/htdocs/compta/prelevement/fiche.php index 0185382395d..17b64506956 100644 --- a/htdocs/compta/prelevement/fiche.php +++ b/htdocs/compta/prelevement/fiche.php @@ -15,16 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ */ /** \file htdocs/compta/prelevement/fiche.php \ingroup prelevement \brief Fiche prelevement - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -33,12 +30,19 @@ if (!$user->rights->prelevement->bons->lire) accessforbidden(); $langs->load("bills"); +$langs->load("withdrawals"); + /* * Sécurité accés client */ if ($user->societe_id > 0) accessforbidden(); + +/* + * Actions + */ + if ($_POST["action"] == 'confirm_credite' && $_POST["confirm"] == yes) { $bon = new BonPrelevement($db,""); @@ -57,7 +61,7 @@ if ($_POST["action"] == 'infotrans') { $dir = $conf->prelevement->dir_output.'/bon/'; - if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . $_FILES['userfile']['name'],1)) + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . $_FILES['userfile']['name'],1) > 0) { $dt = dolibarr_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); @@ -91,7 +95,7 @@ if ($_POST["action"] == 'infocredit') } } -llxHeader('','Bon de prélèvement'); +llxHeader('',$langs->trans("WithdrawalReceipt")); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche.php?id='.$_GET["id"]; @@ -132,7 +136,7 @@ if ($_GET["id"]) if ($bon->fetch($_GET["id"]) == 0) { - dolibarr_fiche_head($head, $hselected, 'Prélèvement : '. $bon->ref); + dolibarr_fiche_head($head, $hselected, $langs->trans("WithdrawalReceipt")); if (isset($_GET["error"])) { @@ -149,7 +153,7 @@ if ($_GET["id"]) print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; } if($bon->date_credit <> 0) { - print ''; } @@ -193,10 +197,10 @@ if ($_GET["id"]) print ''; - print ''; - print ''; @@ -240,7 +244,7 @@ if ($_GET["action"] == '') if ($bon->credite == 0) { - print "id\">".$langs->trans("Classer crédité").""; + print "id\">".$langs->trans("ClassCredited").""; } @@ -250,5 +254,5 @@ if ($_GET["action"] == '') print ""; -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 8bcc226ef6f..c93d9367538 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005 Laurent Destailleur + * Copyright (C) 2005-2008 Laurent Destailleur * Copyright (C) 2005-2006 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -19,13 +19,15 @@ */ /** - \file htdocs/compta/prelevement/index.php - \brief Prelevement - \version $Id$ -*/ + * \file htdocs/compta/prelevement/index.php + * \brief Prelevement + * \version $Id$ + */ require("./pre.inc.php"); require_once DOL_DOCUMENT_ROOT."/includes/modules/modPrelevement.class.php"; +require_once DOL_DOCUMENT_ROOT."/facture.class.php"; +require_once DOL_DOCUMENT_ROOT."/societe.class.php"; $langs->load("withdrawals"); @@ -38,8 +40,7 @@ $result = restrictedArea($user, 'prelevement','',''); /* - * Affichage page - * + * View */ llxHeader(); @@ -51,7 +52,8 @@ print '
'.$langs->trans("Ref").''.$bon->ref.'
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'.$langs->trans("Date").''.dolibarr_print_date($bon->datec,'dayhour').'
'.$langs->trans("Amount").''.price($bon->amount).'
'.$langs->trans("File").''; @@ -172,13 +176,13 @@ if ($_GET["id"]) print '
Date Transmission / Par'; print dolibarr_print_date($bon->date_trans,'dayhour'); print ' par '.$muser->fullname.'
Méthode Transmission'; + print '
Methode Transmission'; print $bon->methodes_trans[$bon->method_trans]; print '
Crédité le'; + print '
Credit on'; print dolibarr_print_date($bon->date_credit,'dayhour'); print '
Date Transmission'; print $html->select_date('','','','','',"userfile"); print '
Méthode Transmission'; + print '
Methode Transmission'; print $html->select_array("methode",$bon->methodes_trans); print '
Fichier'; + print '
'.$langs->trans("File").''; print ''; print '
'; print '
'; print '
'; - +$thirdpartystatic=new Societe($db); +$invoicestatic=new Facture($db); $bprev = new BonPrelevement($db); $var=true; @@ -68,60 +70,10 @@ print ''; print price($bprev->SommeAPrelever()); print '

'; - -/* - * Bon de prélèvement - * - */ -$sql = "SELECT p.rowid, p.ref, p.amount,".$db->pdate("p.datec")." as datec"; -$sql .= " ,p.statut "; -$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; -$sql .= " ORDER BY datec DESC LIMIT 5"; - -$result = $db->query($sql); -if ($result) -{ - $num = $db->num_rows($result); - $i = 0; - $var=True; - - print"\n\n"; - print ''; - print ''; - print ''; - print ''; - - while ($i < $num) - { - $obj = $db->fetch_object($result); - $var=!$var; - - print "\n"; - - print '\n"; - - print '\n"; - - print "\n"; - $i++; - } - print "
'.$langs->trans("WithdrawalReceiptShort").''.$langs->trans("Date").''.$langs->trans("Amount").'
"; - - print ' '; - - print ''.$obj->ref."'.dolibarr_print_date($obj->datec,"dayhour")."'.price($obj->amount)."
"; - $db->free($result); -} -else -{ - dolibarr_print_error($db); -} - print ''; /* * Factures - * */ $sql = "SELECT f.facnumber, f.rowid, s.nom, s.rowid as socid"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; @@ -130,47 +82,102 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFI $sql .= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " WHERE s.rowid = f.fk_soc"; $sql .= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - -if ($socid) +if ($socid) $sql .= " AND f.fk_soc = $socid"; +$resql=$db->query($sql); +if ($resql) { - $sql .= " AND f.fk_soc = $socid"; -} + $num = $db->num_rows($resql); + $i = 0; -if ( $db->query($sql) ) -{ - $num = $db->num_rows(); - $i = 0; - - if ($num) - { - print ''; - print ''; - print ''; - $var = True; - while ($i < $num && $i < 20) + print '
Factures en attente de prélèvement ('.$num.')
'; + print ''; + print ''; + if ($num) { - $obj = $db->fetch_object(); - $var=!$var; - print ''; - print ''; - print ''; - $i++; + $var = True; + while ($i < $num && $i < 20) + { + $obj = $db->fetch_object($resql); + $var=!$var; + print ''; + print ''; + print ''; + $i++; + } } - - print "
'.$langs->trans("InvoiceWaitingWithdraw").' ('.$num.')
'; - print ''.img_file().' '.$obj->facnumber.''.img_object($langs->trans("ShowCompany"),'company').' '.$obj->nom.'
'; + $invoicestatic->id=$obj->rowid; + $invoicestatic->ref=$obj->facnumber; + print $invoicestatic->getNomUrl(1,'withdraw'); + print ''; + $thirdpartystatic->id=$obj->socid; + $thirdpartystatic->nom=$obj->nom; + print $thirdpartystatic->getNomUrl(1,'customer'); + print '

"; - - } + else + { + print ''.$langs->trans("NoInvoiceToWithdraw").''; + } + print "
"; } else { - dolibarr_print_error($db); -} + dolibarr_print_error($db); +} + + + +/* + * Bon de prélèvement + * + */ +$limit=5; +$sql = "SELECT p.rowid, p.ref, p.amount,".$db->pdate("p.datec")." as datec"; +$sql .= " ,p.statut "; +$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; +$sql .= " ORDER BY datec DESC LIMIT ".$limit; + +$result = $db->query($sql); +if ($result) +{ + $num = $db->num_rows($result); + $i = 0; + $var=True; + + print"\n\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($result); + $var=!$var; + + print "\n"; + + print '\n"; + + print '\n"; + + print "\n"; + $i++; + } + print "
'.$langs->trans("LastWithdrawalReceipt",$limit).''.$langs->trans("Date").''.$langs->trans("Amount").'
"; + + print ' '; + + print ''.$obj->ref."'.dolibarr_print_date($obj->datec,"dayhour")."'.price($obj->amount)."
"; + $db->free($result); +} +else +{ + dolibarr_print_error($db); +} print ''; llxFooter('$Date$ - $Revision$'); - ?> diff --git a/htdocs/compta/prelevement/lignes.php b/htdocs/compta/prelevement/lignes.php index 5942c163858..090f8668a50 100644 --- a/htdocs/compta/prelevement/lignes.php +++ b/htdocs/compta/prelevement/lignes.php @@ -15,11 +15,11 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ */ +/* + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/rejet-prelevement.class.php"); require_once(DOL_DOCUMENT_ROOT."/paiement.class.php"); @@ -27,59 +27,66 @@ require_once(DOL_DOCUMENT_ROOT."/paiement.class.php"); // Sécurité accés client if ($user->societe_id > 0) accessforbidden(); -llxHeader('','Bon de prélèvement'); + +/* + * View + */ + +llxHeader('',$langs->trans("WithdrawalReceipt")); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("Card"); -$h++; +$h++; if ($conf->use_preview_tabs) { - $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/bon.php?id='.$_GET["id"]; - $head[$h][1] = $langs->trans("Preview"); - $h++; + $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/bon.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans("Preview"); + $h++; } $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/lignes.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("Lines"); $hselected = $h; -$h++; +$h++; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/factures.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("Bills"); -$h++; +$h++; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-rejet.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("Rejects"); -$h++; +$h++; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-stat.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("Statistics"); -$h++; +$h++; $prev_id = $_GET["id"]; if ($_GET["id"]) { - $bon = new BonPrelevement($db,""); + $bon = new BonPrelevement($db,""); - if ($bon->fetch($_GET["id"]) == 0) - { + if ($bon->fetch($_GET["id"]) == 0) + { - dolibarr_fiche_head($head, $hselected, 'Prélèvement : '. $bon->ref); + dolibarr_fiche_head($head, $hselected, $langs->trans("WithdrawalReceipt")); - print ''; + print '
'; - print ''; + print ''; - print '
Référence'.$bon->ref.'
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'

'; - } - else - { - print "Erreur"; - } + print ''; + + print ''; + } + else + { + print "Erreur"; + } } $page = $_GET["page"]; @@ -93,10 +100,10 @@ $pageprev = $page - 1; $pagenext = $page + 1; if ($sortorder == "") { - $sortorder="DESC"; + $sortorder="DESC"; } if ($sortfield == "") { - $sortfield="pl.fk_soc"; + $sortfield="pl.fk_soc"; } /* @@ -113,7 +120,7 @@ $sql .= " AND pl.fk_soc = s.rowid"; if ($_GET["socid"]) { - $sql .= " AND s.rowid = ".$_GET["socid"]; + $sql .= " AND s.rowid = ".$_GET["socid"]; } $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); @@ -122,76 +129,76 @@ $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - - $urladd = "&id=".$_GET["id"]; + $num = $db->num_rows($result); + $i = 0; - print_barre_liste("Lignes de prélèvement", $page, "lignes.php", $urladd, $sortfield, $sortorder, '', $num); - print"\n\n"; - print ''; - print ''; - print_liste_field_titre("Lignes","lignes.php","pl.rowid",'',$urladd); - print_liste_field_titre("Société","lignes.php","s.nom",'',$urladd); - print_liste_field_titre("Montant","lignes.php","f.total_ttc","",$urladd,'align="center"'); - print ''; + $urladd = "&id=".$_GET["id"]; - $var=True; + print_barre_liste("", $page, "lignes.php", $urladd, $sortfield, $sortorder, '', $num); + print"\n\n"; + print '
 
'; + print ''; + print_liste_field_titre($langs->trans("Lines"),"lignes.php","pl.rowid",'',$urladd); + print_liste_field_titre($langs->trans("ThirdParty"),"lignes.php","s.nom",'',$urladd); + print_liste_field_titre($langs->trans("Amount"),"lignes.php","f.total_ttc","",$urladd,'align="center"'); + print ''; - $total = 0; + $var=false; - while ($i < min($num,$conf->liste_limit)) - { - $obj = $db->fetch_object($result); + $total = 0; - print "'; - - print '\n"; - - print '\n"; - - print ''; + + print '\n"; + + print '\n"; + + print ''; + + $total += $obj->total_ttc; + $var=!$var; + $i++; } - print ''; + if($_GET["socid"]) + { + print "'; - if($_GET["socid"]) - { - print "\n"; - print ''; + print ''; - print '\n"; + print "\n"; + } - print ''; - - print "\n"; - } - - print "
 
"; - - print ' '; - print ''; - print substr('000000'.$obj->rowid, -6); - print ''.stripslashes($obj->nom)."'.price($obj->amount)."'; - - if ($obj->statut == 3) + while ($i < min($num,$conf->liste_limit)) { - print 'Rejeté'; - } - else - { - print " "; + $obj = $db->fetch_object($result); + + print "
"; + + print ' '; + print ''; + print substr('000000'.$obj->rowid, -6); + print ''.stripslashes($obj->nom)."'.price($obj->amount)."'; + + if ($obj->statut == 3) + { + print 'Rejeté'; + } + else + { + print " "; + } + + print '
"; - $total += $obj->total_ttc; - $var=!$var; - $i++; - } + print 'Total
"; + print ''.price($total)."Total '.price($total)."
 
"; - $db->free($result); + print ""; + $db->free($result); } -else +else { - dolibarr_print_error($db); + dolibarr_print_error($db); } $db->close(); diff --git a/htdocs/compta/prelevement/liste.php b/htdocs/compta/prelevement/liste.php index d9ba3b70563..ddc4c17980e 100644 --- a/htdocs/compta/prelevement/liste.php +++ b/htdocs/compta/prelevement/liste.php @@ -105,7 +105,7 @@ if ($result) print_liste_field_titre($langs->trans("WithdrawalReceipt"),"liste.php","p.ref"); print_liste_field_titre($langs->trans("Company"),"liste.php","s.nom"); print_liste_field_titre($langs->trans("Date"),"liste.php","p.datec","","",'align="center"'); - print_liste_field_titre($langs->trans("Amount"),"liste.php","pl.amount"); + print_liste_field_titre($langs->trans("Amount"),"liste.php","pl.amount","","",'align="right"'); print_liste_field_titre($langs->trans("CustomerCode"),"liste.php","s.code_client",'','','align="center"'); print ' '; print ''; @@ -140,9 +140,9 @@ if ($result) print ' '; print ''.$obj->ref."\n"; - print ''.stripslashes($obj->nom)."\n"; - print ''.dolibarr_print_date($obj->datec)."\n"; - print ''.price($obj->amount).' '.$langs->trans("Currency".$conf->monnaie)."\n"; + print ''.$obj->nom."\n"; + print ''.dolibarr_print_date($obj->datec,'day')."\n"; + print ''.price($obj->amount)."\n"; print ''.$obj->code_client."\n"; print ' '; diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 3cd1ced27cf..57db196ae2d 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -337,10 +337,10 @@ class Facture extends CommonObject /** - \brief Create a new invoice in database from current invoice - \param user Object user that ask creation - \param invertdetail Reverse sign of amounts for lines - \return int <0 si ko, >0 si ok + \brief Create a new invoice in database from current invoice + \param user Object user that ask creation + \param invertdetail Reverse sign of amounts for lines + \return int <0 si ko, >0 si ok */ function create_clone($user,$invertdetail=0) { @@ -388,7 +388,7 @@ class Facture extends CommonObject /** * \brief Renvoie nom clicable (avec eventuellement le picto) * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul - * \param option Sur quoi pointe le lien + * \param option Sur quoi pointe le lien ('', 'withdraw') * \return string Chaine avec URL */ function getNomUrl($withpicto=0,$option='') @@ -397,8 +397,16 @@ class Facture extends CommonObject $result=''; - $lien = ''; - $lienfin=''; + if ($option == 'withdraw') + { + $lien = ''; + $lienfin=''; + } + else + { + $lien = ''; + $lienfin=''; + } $picto='bill'; if ($this->type == 1) $picto.='r'; @@ -416,16 +424,14 @@ class Facture extends CommonObject /** - \brief Recupére l'objet facture et ses lignes de factures - \param rowid id de la facture a récupérer - \param societe_id id de societe - \return int >0 si ok, <0 si ko - */ - function fetch($rowid, $societe_id=0) + * \brief Recupére l'objet facture et ses lignes de factures + * \param rowid id de la facture a récupérer + * \param ref Ref of invoice + * \return int >0 si ok, <0 si ko + */ + function fetch($rowid,$ref='') { - dolibarr_syslog("Facture::Fetch rowid=".$rowid.", societe_id=".$societe_id, LOG_DEBUG); - - $sql = 'SELECT f.facnumber,f.ref_client,f.type,f.fk_soc,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise'; + $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.type,f.fk_soc,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise'; $sql.= ','.$this->db->pdate('f.datef').' as df'; $sql.= ','.$this->db->pdate('f.date_lim_reglement').' as dlr'; $sql.= ','.$this->db->pdate('f.datec').' as datec'; @@ -440,20 +446,18 @@ class Facture extends CommonObject $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'cond_reglement as c ON f.fk_cond_reglement = c.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'co_fa as cf ON cf.fk_facture = f.rowid'; - $sql.= ' WHERE f.rowid='.$rowid; - if ($societe_id > 0) - { - $sql.= ' AND f.fk_soc = '.$societe_id; - } - $result = $this->db->query($sql); + if ($ref) $sql.= " WHERE f.facnumber='".$ref."'"; + else $sql.= " WHERE f.rowid=".$rowid; + dolibarr_syslog("Facture::Fetch sql=".$sql, LOG_DEBUG); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); - $this->id = $rowid; + $this->id = $obj->rowid; $this->ref = $obj->facnumber; $this->ref_client = $obj->ref_client; $this->type = $obj->type; @@ -927,7 +931,7 @@ class Facture extends CommonObject $sql.= ' SET paye=0, fk_statut=1, close_code=null, close_note=null'; $sql.= ' WHERE rowid = '.$this->id; $resql = $this->db->query($sql); - + dolibarr_syslog("Facture::set_unpayed sql=".$sql); if ($resql) { @@ -1094,7 +1098,7 @@ class Facture extends CommonObject $sql.= ', date_lim_reglement='.$this->db->idate($datelim); } $sql.= ' WHERE rowid = '.$this->id; - + dolibarr_syslog("Facture::set_valid() sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -1171,7 +1175,7 @@ class Facture extends CommonObject $result=$interface->run_triggers('BILL_VALIDATE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers - + $this->db->commit(); return 1; } @@ -1180,7 +1184,7 @@ class Facture extends CommonObject $this->db->rollback(); return -1; } - + } else { @@ -1303,7 +1307,7 @@ class Facture extends CommonObject $pu_ht=price2num($pu_ht); $pu_ttc=price2num($pu_ttc); $txtva=price2num($txtva); - + if ($price_base_type=='HT') { $pu=$pu_ht; @@ -2229,42 +2233,42 @@ class Facture extends CommonObject $sql .= ' WHERE fk_facture='.$this->id; $sql .= ' AND traite = 0'; if ( $this->db->query( $sql) ) - { - $row = $this->db->fetch_row(); - if ($row[0] == 0) - { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande'; - $sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)'; - $sql .= ' VALUES ('.$this->id; - $sql .= ",'".price2num($this->total_ttc)."'"; - $sql .= ",".$this->db->idate(mktime()).",".$user->id; - $sql .= ",'".$soc->bank_account->code_banque."'"; - $sql .= ",'".$soc->bank_account->code_guichet."'"; - $sql .= ",'".$soc->bank_account->number."'"; - $sql .= ",'".$soc->bank_account->cle_rib."')"; - if ( $this->db->query( $sql) ) - { - return 1; - } - else - { - $this->error=$this->db->error(); - dolibarr_syslog('Facture::DemandePrelevement Erreur'); - return -1; - } - } - else - { - $this->error="Une demande existe déjà"; - dolibarr_syslog('Facture::DemandePrelevement Impossible de créer une demande, demande déja en cours'); - } - } - else - { - $this->error=$this->db->error(); - dolibarr_syslog('Facture::DemandePrelevement Erreur -2'); - return -2; - } + { + $row = $this->db->fetch_row(); + if ($row[0] == 0) + { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande'; + $sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)'; + $sql .= ' VALUES ('.$this->id; + $sql .= ",'".price2num($this->total_ttc)."'"; + $sql .= ",".$this->db->idate(mktime()).",".$user->id; + $sql .= ",'".$soc->bank_account->code_banque."'"; + $sql .= ",'".$soc->bank_account->code_guichet."'"; + $sql .= ",'".$soc->bank_account->number."'"; + $sql .= ",'".$soc->bank_account->cle_rib."')"; + if ( $this->db->query( $sql) ) + { + return 1; + } + else + { + $this->error=$this->db->error(); + dolibarr_syslog('Facture::DemandePrelevement Erreur'); + return -1; + } + } + else + { + $this->error="Une demande existe déjà"; + dolibarr_syslog('Facture::DemandePrelevement Impossible de créer une demande, demande déja en cours'); + } + } + else + { + $this->error=$this->db->error(); + dolibarr_syslog('Facture::DemandePrelevement Erreur -2'); + return -2; + } } else { diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 9f63f9db581..29d74cae950 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -2990,12 +2990,13 @@ class Form * \param object Object to show * \param paramid Nom du parametre a utiliser pour nommer id dans liens URL * \param morehtml Code html supplementaire a afficher avant barre nav - * \param shownav Show Condition - * \param fieldid Nom du champ id a utiliser pour select next et previous - * \param fieldref Nom du champ ref a utiliser pour select next et previous + * \param shownav Show Condition + * \param fieldid Nom du champ en base a utiliser pour select next et previous + * \param fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous + * \param morehtmlref Code html supplementaire a afficher apres ref * \return string Portion HTML avec ref + boutons nav */ - function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref') + function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='') { $ret=''; @@ -3009,7 +3010,10 @@ class Form } $ret.=$object->$fieldref; - + if ($morehtmlref) { + $ret.=' '.$morehtmlref; + } + if ($morehtml) { $ret.=''.$morehtml; } diff --git a/htdocs/includes/modules/modNotification.class.php b/htdocs/includes/modules/modNotification.class.php index 1370724f2e3..9822dd208f9 100644 --- a/htdocs/includes/modules/modNotification.class.php +++ b/htdocs/includes/modules/modNotification.class.php @@ -15,13 +15,12 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ */ /** \defgroup notification Module notification \brief Module pour g�rer les notifications (par mail ou autre) + \version $Id$ */ /** diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 1029f268f0b..cea31119d2e 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -43,6 +43,7 @@ IOMonthlyReporting=Monthly reporting BankAccountDomiciliation=Account address BankAccountOwner=Account owner name BankAccountOwnerAddress=Account owner address +RIBControlError=Control of key says informations for this account number are not complete or wrong. CreateAccount=Create account StandingOrderToProcess=To process StandingOrderProcessed=Processed diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index ef5e38e2563..7b9a2afe7ea 100755 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -16,11 +16,18 @@ RequestStandingOrderToTreat=Request for standing orders to treat RequestStandingOrderTreated=Request for standing orders treated CustomersStandingOrders=Customer standing orders CustomerStandingOrder=Customer standing order -NbOfInvoiceToWithdraw=Nb of invoice to withdraw +NbOfInvoiceToWithdraw=Nb of invoice with withdraw request +InvoiceWaitingWithdraw=Invoice waiting for withdraw AmountToWithdraw=Amount to withdraw WithdrawsRefused=Withdraws refused -NoInvoiceToWithdraw=No invoice in payment mode "withdraw" is waiting +NoInvoiceToWithdraw=No customer invoice in payment mode "withdraw" is waiting. Go on 'Withdraw' tab on invoice card to make a request. ResponsibleUser=Responsible user WithdrawalsSetup=Withdrawal setup WithdrawStatistics=Withdraws' statistics WithdrawRejectStatistics=Withdraw rejects' statistics +LastWithdrawalReceipt=Last %s withdrawing receipts +MakeWithdrawRequest=Make a withdraw request +ThirdPartyBankCode=Third party bank code +ThirdPartyDeskCode=Third party desk code +NoInvoiceCouldBeWithdrawed=No invoice withdrawed with success. Check that invoice are on companies with a valid RIB. +ClassCredited=Classer crédité \ No newline at end of file diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index 95083dd5261..926e19fa135 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -43,6 +43,7 @@ IOMonthlyReporting=Rapport mensuel E/S BankAccountDomiciliation=Domiciliation du compte BankAccountOwner=Nom du propriétaire du compte BankAccountOwnerAddress=Adresse du propriétaire du compte +RIBControlError=Le contrôle de la clé indique que les informations de ce compte bancaire sont incomplètes ou incorrectes. CreateAccount=Créer compte StandingOrderToProcess=À traiter StandingOrderProcessed=Traités diff --git a/htdocs/langs/fr_FR/withdrawals.lang b/htdocs/langs/fr_FR/withdrawals.lang index f9a8af6201b..a4b12aea10c 100755 --- a/htdocs/langs/fr_FR/withdrawals.lang +++ b/htdocs/langs/fr_FR/withdrawals.lang @@ -16,11 +16,18 @@ RequestStandingOrderToTreat=Demandes de pr RequestStandingOrderTreated=Demandes de prélèvements traitées CustomersStandingOrders=Prélèvements clients CustomerStandingOrder=Prélèvement client -NbOfInvoiceToWithdraw=Nb de facture à prélever +NbOfInvoiceToWithdraw=Nb de facture en attente de prélevement +InvoiceWaitingWithdraw=Factures en attente de prélèvement AmountToWithdraw=Somme à prélever WithdrawsRefused=Prélèvements rejetés -NoInvoiceToWithdraw=Aucune facture en mode de paiement 'Prélevement' n'a de demande de prélèvements en attente +NoInvoiceToWithdraw=Aucune facture client en mode de paiement 'Prélevement' n'a de demande de prélèvements en attente. Aller sur l'onglet 'Prélèvement' de la fiche facture pour faire une demande. ResponsibleUser=Utilisateur responsable des prélèvements WithdrawalsSetup=Configuration des prélèvements WithdrawStatistics=Statistiques des prélèvements WithdrawRejectStatistics=Statistiques des rejets de prélèvements +LastWithdrawalReceipt=Les %s derniers bons de prélèvements +MakeWithdrawRequest=Faire une demande de prélèvement +ThirdPartyBankCode=Code banque du tiers +ThirdPartyDeskCode=Code guichet du tiers +NoInvoiceCouldBeWithdrawed=Aucune facture prélevable, prélevé avec succès. Vérifiez que les factures sont sur des sociétés dont le RIB est correctement renseigné. +ClassCredited=Classer crédité \ No newline at end of file diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 787901152b2..b0f9aec24fd 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -101,7 +101,7 @@ if ($_GET["socid"] && $_GET["action"] != 'edit') { if (!$account->verif()) { - print '
Le contrôle de la clé indique que les informations de ce compte bancaire sont incomplètes ou incorrectes.

'; + print '
'.$langs->trans("RIBControlError").'

'; } print ''; @@ -109,7 +109,13 @@ if ($_GET["socid"] && $_GET["action"] != 'edit') print ''; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; @@ -121,15 +127,15 @@ if ($_GET["socid"] && $_GET["action"] != 'edit') print ''; print ''; - print '\n"; - print '\n"; - print '\n"; @@ -176,7 +182,10 @@ if ($_GET["socid"] && $_GET["action"] == 'edit' && $user->rights->societe->creer print ''; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -188,16 +197,16 @@ if ($_GET["socid"] && $_GET["action"] == 'edit' && $user->rights->societe->creer print ''; print ''; - print '"; - print ''; + print ''; print ''; print "\n"; - print '";
'.$langs->trans("Bank").''.$account->bank.'
'.$langs->trans("RIB").'Code BanqueCode GuichetNuméroClé RIB
'.$langs->trans("RIB").''.$langs->trans("BankCode").''.$langs->trans("DeskCode").''.$langs->trans("BankAccountNumber").''.$langs->trans("BankAccountNumberKey").'
 '.$account->code_banque.''.$account->code_guichet.''.$account->number.'
'.$langs->trans("BIC").''.$account->bic.'
Domiciliation'; + print '
'.$langs->trans("BankAccountDomiciliation").''; print $account->domiciliation; print "
Nom propriétaire du compte'; + print '
'.$langs->trans("BankAccountOwner").''; print $account->proprio; print "
Adresse propriétaire du compte'; + print '
'.$langs->trans("BankAccountOwnerAddress").''; print $account->adresse_proprio; print "
'.$langs->trans("Bank").'
'.$langs->trans("RIB").'Code BanqueCode GuichetNuméroClé RIB
'.$langs->trans("RIB").''.$langs->trans("BankCode").''.$langs->trans("DeskCode").''.$langs->trans("BankAccountNumber").''.$langs->trans("BankAccountNumberKey").'
 
'.$langs->trans("BIC").'
Domiciliation'; + print '
'.$langs->trans("BankAccountDomiciliation").''; print "
Nom propriétaire du compte
'.$langs->trans("BankAccountOwner").'
Adresse propriétaire du compte'; + print '
'.$langs->trans("BankAccountOwnerAddress").''; print "