* 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.php \ingroup facture \brief Page de création d'une facture \version $Revision$ */ require("./pre.inc.php"); require_once DOL_DOCUMENT_ROOT."/facture.class.php"; require_once DOL_DOCUMENT_ROOT."/paiement.class.php"; $user->getrights('facture'); $user->getrights('banque'); if (!$user->rights->facture->lire) accessforbidden(); $langs->load("main"); // BUG De chargement de traduction ne pas modifier cette ligne $langs->load("bills"); $warning_delay=31*24*60*60; // Delai affichage warning retard (si retard paiement facture > delai) if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; } // Sécurité accés client if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } llxHeader('',$langs->trans("UnpayedBills")); /*************************************************************************** * * * Mode Liste * * * ***************************************************************************/ $page = $_GET["page"]; $sortfield=$_GET["sortfield"]; $sortorder=$_GET["sortorder"]; if (! $sortfield) $sortfield="f.date_lim_reglement"; if (! $sortorder) $sortorder="ASC"; if ($page == -1) $page = 0; if ($user->rights->facture->lire) { $limit = $conf->liste_limit; $offset = $limit * $page ; $sql = "SELECT s.nom,s.idp,f.facnumber,f.increment,f.total,f.total_ttc,"; $sql.= $db->pdate("f.datef")." as df, ".$db->pdate("f.date_lim_reglement")." as datelimite, "; $sql.= " f.paye as paye, f.rowid as facid, f.fk_statut, sum(pf.amount) as am"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ",".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; $sql.= " WHERE f.fk_soc = s.idp"; $sql.= " AND f.paye = 0 AND f.fk_statut = 1"; if ($socidp) $sql .= " AND s.idp = $socidp"; if ($_GET["filtre"]) { $filtrearr = split(",", $_GET["filtre"]); foreach ($filtrearr as $fil) { $filt = split(":", $fil); $sql .= " AND " . $filt[0] . " = " . $filt[1]; } } if ($_GET["search_ref"]) { $sql .= " AND f.facnumber like '%".$_GET["search_ref"]."%'"; } if ($_GET["search_societe"]) { $sql .= " AND s.nom like '%".$_GET["search_societe"]."%'"; } if ($_GET["search_montant_ht"]) { $sql .= " AND f.total = '".$_GET["search_montant_ht"]."'"; } if ($_GET["search_montant_ttc"]) { $sql .= " AND f.total_ttc = '".$_GET["search_montant_ttc"]."'"; } if (strlen($_POST["sf_ref"]) > 0) { $sql .= " AND f.facnumber like '%".$_POST["sf_ref"] . "%'"; } $sql .= " GROUP BY f.facnumber"; $sql .= " ORDER BY "; $listfield=split(',',$sortfield); foreach ($listfield as $key => $value) $sql.=$listfield[$key]." ".$sortorder.","; $sql .= " f.fk_soc ASC"; //$sql .= $db->plimit($limit+1,$offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); if ($socidp) { $soc = new Societe($db); $soc->fetch($socidp); } print_barre_liste($langs->trans("BillsCustomersUnpayed")." ".($socidp?" $soc->nom":""),$page,"impayees.php","&socidp=$socidp",$sortfield,$sortorder,'',$num); $i = 0; print ''; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","","&socidp=$socidp","",$sortfield); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","","&socidp=$socidp",'align="center"',$sortfield); print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","","&socidp=$socidp",'align="center"',$sortfield); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&socidp=$socidp","",$sortfield); print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total","","&socidp=$socidp",'align="right"',$sortfield); print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","","&socidp=$socidp",'align="right"',$sortfield); print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","","&socidp=$socidp",'align="right"',$sortfield); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye","","&socidp=$socidp",'align="right"',$sortfield); print "\n"; // Lignes des champs de filtre print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; print ''; if ($num > 0) { $var=True; $total=0; $totalrecu=0; while ($i < $num) { $objp = $db->fetch_object($result); $var=!$var; print ""; $class = "impayee"; print '\n"; print "\n"; print "\n"; print ''; print ""; print ""; print ""; // Affiche statut de la facture if (! $objp->paye) { if ($objp->fk_statut == 0) { print ''; } elseif ($objp->fk_statut == 3) { print ''; } else { print ''; } } else { print ''; } print "\n"; $total+=$objp->total; $total_ttc+=$objp->total_ttc; $totalrecu+=$objp->am; $i++; } print ''; print ""; print ""; print ""; print ""; print ''; print "\n"; } print "
'; print '  '; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.img_object($langs->trans("ShowBill"),"bill")." "; print ''.$objp->facnumber.''.$objp->increment; if ($objp->datelimite < (time() - $warning_delay) && ! $objp->paye && $objp->fk_statut == 1 && ! $objp->am) print img_warning($langs->trans("Late")); print "".dolibarr_print_date($objp->df)."".dolibarr_print_date($objp->datelimite)."'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).'".price($objp->total)."".price($objp->total_ttc)."".price($objp->am)."'.$langs->trans("BillShortStatusDraft").''.$langs->trans("BillShortStatusCanceled").''.($objp->am?$langs->trans("BillShortStatusStarted"):$langs->trans("BillShortStatusNotPayed")).''.$langs->trans("BillShortStatusPayed").'
".$langs->trans("Total").": ".price($total)."".price($total_ttc)."".price($totalrecu)." 
"; $db->free(); } else { dolibarr_print_error($db); } } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>