diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index 19b0c99ca87..91e5fd0314c 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -2,7 +2,7 @@ /* Copyright (C) 2002-2005 Rodolphe Quiedeville * Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * 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 @@ -183,7 +183,7 @@ if (! $sortorder) $sortorder="ASC"; $limit = $conf->liste_limit; $sql = "SELECT s.nom, s.rowid as socid"; -$sql.= ", f.facnumber,f.increment,f.total as total_ht,f.total_ttc"; +$sql.= ", f.facnumber, f.increment, f.total as total_ht, f.tva as total_tva, f.total_ttc"; $sql.= ", f.datef as df, f.date_lim_reglement as datelimite"; $sql.= ", f.paye as paye, f.rowid as facid, f.fk_statut, f.type"; $sql.= ", sum(pf.amount) as am"; @@ -198,10 +198,10 @@ $sql.= " AND f.type IN (0,1,3) AND f.fk_statut = 1"; $sql.= " AND f.paye = 0"; if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($socid) $sql .= " AND s.rowid = ".$socid; -if ($_GET["filtre"]) +if (! empty($socid)) $sql .= " AND s.rowid = ".$socid; +if (GETPOST('filtre')) { - $filtrearr = explode(",", $_GET["filtre"]); + $filtrearr = explode(",", GETPOST('filtre')); foreach ($filtrearr as $fil) { $filt = explode(":", $fil); @@ -212,7 +212,7 @@ if ($search_ref) $sql .= " AND f.facnumber LIKE '%".$search_ref."%'"; if ($search_societe) $sql .= " AND s.nom LIKE '%".$search_societe."%'"; if ($search_montant_ht) $sql .= " AND f.total = '".$search_montant_ht."'"; if ($search_montant_ttc) $sql .= " AND f.total_ttc = '".$search_montant_ttc."'"; -if (dol_strlen($_POST["sf_ref"]) > 0) $sql .= " AND f.facnumber LIKE '%".$_POST["sf_ref"] . "%'"; +if (GETPOST('sf_ref')) $sql .= " AND f.facnumber LIKE '%".GETPOST('sf_ref') . "%'"; $sql.= " GROUP BY f.facnumber,f.increment,f.total,f.total_ttc,f.datef, f.date_lim_reglement,f.paye, f.rowid, f.fk_statut, f.type,s.nom, s.rowid"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; $sql.= " ORDER BY "; @@ -227,15 +227,15 @@ if ($resql) { $num = $db->num_rows($resql); - if ($socid) + if (! empty($socid)) { $soc = new Societe($db); $soc->fetch($socid); } $param=""; - $param.=($socid?"&socid=".$socid:""); - $param.=($option?"&option=".$option:""); + $param.=(! empty($socid)?"&socid=".$socid:""); + $param.=(! empty($option)?"&option=".$option:""); if ($search_ref) $param.='&search_ref='.urlencode($search_ref); if ($search_societe) $param.='&search_societe='.urlencode($search_societe); if ($search_montant_ht) $param.='&search_montant_ht='.urlencode($search_montant_ht); @@ -245,7 +245,7 @@ if ($resql) $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource.=str_replace('&','&',$param); - $titre=($socid?$langs->trans("BillsCustomersUnpaidForCompany",$soc->nom):$langs->trans("BillsCustomersUnpaid")); + $titre=(! empty($socid)?$langs->trans("BillsCustomersUnpaidForCompany",$soc->nom):$langs->trans("BillsCustomersUnpaid")); if ($option == 'late') $titre.=' ('.$langs->trans("Late").')'; else $titre.=' ('.$langs->trans("All").')'; @@ -266,6 +266,7 @@ if ($resql) print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountVAT"),$_SERVER["PHP_SELF"],"f.tva","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder); @@ -281,13 +282,11 @@ if ($resql) print ''; print ' '; print ' '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ' '; + print ''; + print ''; print ''; print ''; print ''; @@ -300,6 +299,7 @@ if ($resql) { $var=True; $total_ht=0; + $total_tva=0; $total_ttc=0; $total_paid=0; @@ -352,8 +352,9 @@ if ($resql) print ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,28).''; - print ''.price($objp->total_ht).''; - print ''.price($objp->total_ttc).''; + print ''.price($objp->total_ht).' '.getCurrencySymbol($conf->currency).''; + print ''.price($objp->total_tva).' '.getCurrencySymbol($conf->currency).''; + print ''.price($objp->total_ttc).' '.getCurrencySymbol($conf->currency).''; print ''.price($objp->am).''; if ($objp->am==0) { print ''; } @@ -373,6 +374,7 @@ if ($resql) print "\n"; $total_ht+=$objp->total_ht; + $total_tva+=$objp->total_tva; $total_ttc+=$objp->total_ttc; $total_paid+=$objp->am; @@ -381,9 +383,10 @@ if ($resql) print ''; print ''.$langs->trans("Total").''; - print ''.price($total_ht).''; - print ''.price($total_ttc).''; - print ''.price($total_paid).''; + print ''.price($total_ht).' '.getCurrencySymbol($conf->currency).''; + print ''.price($total_tva).' '.getCurrencySymbol($conf->currency).''; + print ''.price($total_ttc).' '.getCurrencySymbol($conf->currency).''; + print ''.price($total_paid).' '.getCurrencySymbol($conf->currency).''; print ' '; print ' '; print ' '; @@ -415,6 +418,5 @@ else dol_print_error($db,''); llxFooter(); - -if (is_object($db)) $db->close(); +$db->close(); ?> diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 86a70f28e28..feef15fdfe4 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -140,7 +140,7 @@ $facturestatic=new Facture($db); if (! $sall) $sql = 'SELECT'; else $sql = 'SELECT DISTINCT'; -$sql.= ' f.rowid as facid, f.facnumber, f.type, f.increment, f.total, f.total_ttc,'; +$sql.= ' f.rowid as facid, f.facnumber, f.type, f.increment, f.total as total_ht, f.tva as total_tva, f.total_ttc,'; $sql.= ' f.datef as df, f.date_lim_reglement as datelimite,'; $sql.= ' f.paye as paye, f.fk_statut, f.note,'; $sql.= ' s.nom, s.rowid as socid'; @@ -280,6 +280,7 @@ if ($resql) print_liste_field_titre($langs->trans("DateDue"),$_SERVER['PHP_SELF'],"f.date_lim_reglement",'',$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Company'),$_SERVER['PHP_SELF'],'s.nom','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans('AmountHT'),$_SERVER['PHP_SELF'],'f.total','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('AmountVAT'),$_SERVER['PHP_SELF'],'f.tva','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('AmountTTC'),$_SERVER['PHP_SELF'],'f.total_ttc','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Received'),$_SERVER['PHP_SELF'],'am','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'fk_statut,paye,am','',$param,'align="right"',$sortfield,$sortorder); @@ -297,23 +298,19 @@ if ($resql) $formother->select_year($year?$year:-1,'year',1, 20, 5); print ''; print ' '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ' '; - print ''; + print ''; + print ''; + print ' '; + print ''; + print ' '; print ''; print "\n"; if ($num > 0) { $var=True; - $total=0; + $total_ht=0; + $total_tva=0; $total_ttc=0; $totalrecu=0; @@ -343,7 +340,7 @@ if ($resql) print ''; $filename=dol_sanitizeFileName($objp->facnumber); $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($objp->facnumber); - $urlsource=$_SERVER['PHP_SELF'].'?facid='.$objp->facid; + $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->facid; $formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; print ''; @@ -371,11 +368,13 @@ if ($resql) print $thirdparty->getNomUrl(1,'customer'); print ''; - print ''.price($objp->total).''; + print ''.price($objp->total_ht).' '.getCurrencySymbol($conf->currency).''; - print ''.price($objp->total_ttc).''; + print ''.price($objp->total_tva).' '.getCurrencySymbol($conf->currency).''; - print ''.price($paiement).''; + print ''.price($objp->total_ttc).' '.getCurrencySymbol($conf->currency).''; + + print ''.price($paiement).' '.getCurrencySymbol($conf->currency).''; // Affiche statut de la facture print ''; @@ -383,7 +382,8 @@ if ($resql) print ""; //print " "; print "\n"; - $total+=$objp->total; + $total_ht+=$objp->total_ht; + $total_tva+=$objp->total_tva; $total_ttc+=$objp->total_ttc; $totalrecu+=$paiement; $i++; @@ -394,9 +394,10 @@ if ($resql) // Print total print ''; print ''.$langs->trans('Total').''; - print ''.price($total).''; - print ''.price($total_ttc).''; - print ''.price($totalrecu).''; + print ''.price($total_ht).' '.getCurrencySymbol($conf->currency).''; + print ''.price($total_tva).' '.getCurrencySymbol($conf->currency).''; + print ''.price($total_ttc).' '.getCurrencySymbol($conf->currency).''; + print ''.price($totalrecu).' '.getCurrencySymbol($conf->currency).''; print ' '; print ''; }