* Copyright (C) 2004 Éric Seigne * Copyright (C) 2004-2005 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 * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * 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$ */ require("./pre.inc.php"); $user->getrights('facture'); if (!$user->rights->facture->lire) accessforbidden(); $langs->load("bills"); $langs->load("banks"); require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); 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); } } } 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); } } } /* * Sécurité accés client */ if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } llxHeader('',$langs->trans("Bill")); $html = new Form($db); /* *************************************************************************** */ /* */ /* Mode fiche */ /* */ /* *************************************************************************** */ if ($_GET["facid"] > 0) { $fac = New Facture($db); if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0) { $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/apercu.php?facid='.$fac->id; $head[$h][1] = $langs->trans("Preview"); $h++; $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; $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 */ print ''; print ''; print ''; print ""; print ''; print "\n"; print ""; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "
'.$langs->trans("Company").''; print ''.$soc->nom.'Conditions de réglement : " . $fac->cond_reglement ."
'.$langs->trans("Date").'".strftime("%A %d %B %Y",$fac->date)."Date limite de réglement : " . strftime("%d %B %Y",$fac->date_lim_reglement) ."
'.$langs->trans("Author").''.$author->fullname.'
'.$langs->trans("AmountHT").''.price($fac->total_ht).''.$conf->monnaie.' 
'.$langs->trans("AmountTTC").''.price($fac->total_ttc).''.$conf->monnaie.' 
RIB'; print $soc->display_rib(); print '
"; /* * Demande de prélèvement * */ $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.name, u.firstname"; $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"; // Valider if ($fac->statut > 0 && $fac->paye == 0 && $fac->mode_reglement == 3 && $num == 0) { if ($user->rights->facture->creer) { print 'Faire une demande de prélèvement'; } } print "

"; /* * Prélèvement */ print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $var=True; if ($result_sql) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($result_sql); $var=!$var; print ""; print '\n"; print ''; print ''; print ''; print ''; print ''; print "\n"; $i++; } $db->free($result_sql); } else { dolibarr_print_error($db); } $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.name, u.firstname"; $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"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; while ($i < $num) { $obj = $db->fetch_object($result); $var=!$var; print ""; print '\n"; print '\n"; print ''; print '\n"; print ''; print ''; print "\n"; $i++; } $db->free($result); } else { dolibarr_print_error($db); } print "
Date demandeDate traitementMontantBon prélèvement'.$langs->trans("User").'  
'.strftime("%d/%m/%Y",$obj->date_demande)."En attente de traitement'.price($obj->amount).'-'.$obj->firstname." ".$obj->name.''; print ''; print img_delete(); print '
'.strftime("%d/%m/%Y",$obj->date_demande)."'.strftime("%d/%m/%Y",$obj->date_traite)."'.price($obj->amount).''; print ''.$obj->fk_prelevement_bons."'.$obj->firstname." ".$obj->name.'-
"; } else { /* Facture non trouvée */ print $langs->trans("ErrorBillNotFound",$_GET["facid"]); } } print ''; $db->close(); llxFooter('$Date$ - $Revision$'); ?>