Ajout pages "impayees" pour les factures fournisseurs
This commit is contained in:
parent
ba48db528a
commit
3828073a09
@ -22,10 +22,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/facture/imapyees.php
|
||||
\ingroup facture
|
||||
\brief Page de liste des factures imapyées
|
||||
\version $Revision$
|
||||
\file htdocs/compta/facture/impayees.php
|
||||
\ingroup facture
|
||||
\brief Page de liste des factures clients impayées
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
@ -36,7 +36,7 @@ $user->getrights('facture');
|
||||
$user->getrights('banque');
|
||||
|
||||
if (!$user->rights->facture->lire)
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
|
||||
$langs->load("main"); // BUG De chargement de traduction ne pas modifier cette ligne
|
||||
$langs->load("bills");
|
||||
@ -48,8 +48,8 @@ if ($_GET["socid"]) { $socid=$_GET["socid"]; }
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -69,182 +69,183 @@ if (! $sortorder) $sortorder="ASC";
|
||||
|
||||
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";
|
||||
$sql.= " ,sum(pf.amount) as am";
|
||||
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$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 (! $user->rights->commercial->client->voir && ! $socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql .= " AND s.idp = $socid";
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
|
||||
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 = "SELECT s.nom, s.idp,";
|
||||
$sql.= " f.facnumber,f.increment,f.total as total_ht,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";
|
||||
$sql.= " ,sum(pf.amount) as am";
|
||||
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$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 (! $user->rights->commercial->client->voir && ! $socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql .= " AND s.idp = ".$socid;
|
||||
|
||||
$sql.= " ORDER BY ";
|
||||
$listfield=split(',',$sortfield);
|
||||
foreach ($listfield as $key => $value) $sql.=$listfield[$key]." ".$sortorder.",";
|
||||
$sql.= " f.facnumber DESC";
|
||||
if ($_GET["filtre"])
|
||||
{
|
||||
$filtrearr = split(",", $_GET["filtre"]);
|
||||
foreach ($filtrearr as $fil)
|
||||
{
|
||||
$filt = split(":", $fil);
|
||||
$sql .= " AND " . $filt[0] . " = " . $filt[1];
|
||||
}
|
||||
}
|
||||
|
||||
//$sql .= $db->plimit($limit+1,$offset);
|
||||
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.facnumber DESC";
|
||||
|
||||
//$sql .= $db->plimit($limit+1,$offset);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
if ($socid)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socid);
|
||||
}
|
||||
|
||||
$titre=($socid?$langs->trans("BillsCustomersUnpayedForCompany",$soc->nom):$langs->trans("BillsCustomersUnpayed"));
|
||||
print_barre_liste($titre,$page,"impayees.php","&socid=$socid",$sortfield,$sortorder,'',$num);
|
||||
$i = 0;
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","","&socid=$socid","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","","&socid=$socid",'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","","&socid=$socid",'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&socid=$socid","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total","","&socid=$socid",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","","&socid=$socid",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","","&socid=$socid",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","","&socid=$socid",'align="right"',$sortfield);
|
||||
print "</tr>\n";
|
||||
|
||||
// Lignes des champs de filtre
|
||||
print '<form method="get" action="impayees.php">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre" valign="right">';
|
||||
print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET["search_ref"].'"></td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre" align="left">';
|
||||
print '<input class="flat" type="text" name="search_societe" value="'.$_GET["search_societe"].'">';
|
||||
print '</td><td class="liste_titre" align="right">';
|
||||
print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$_GET["search_montant_ht"].'">';
|
||||
print '</td><td class="liste_titre" align="right">';
|
||||
print '<input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$_GET["search_montant_ttc"].'">';
|
||||
print '</td><td class="liste_titre" colspan="2" align="right">';
|
||||
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
print '</form>';
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
if ($socid)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socid);
|
||||
}
|
||||
|
||||
$titre=($socid?$langs->trans("BillsCustomersUnpayedForCompany",$soc->nom):$langs->trans("BillsCustomersUnpayed"));
|
||||
print_barre_liste($titre,$page,"impayees.php","&socid=$socid",$sortfield,$sortorder,'',$num);
|
||||
$i = 0;
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","","&socid=$socid","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","","&socid=$socid",'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","","&socid=$socid",'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&socid=$socid","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total","","&socid=$socid",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","","&socid=$socid",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","","&socid=$socid",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","","&socid=$socid",'align="right"',$sortfield);
|
||||
print "</tr>\n";
|
||||
|
||||
// Lignes des champs de filtre
|
||||
print '<form method="get" action="impayees.php">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre" valign="right">';
|
||||
print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET["search_ref"].'"></td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre" align="left">';
|
||||
print '<input class="flat" type="text" name="search_societe" value="'.$_GET["search_societe"].'">';
|
||||
print '</td><td class="liste_titre" align="right">';
|
||||
print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$_GET["search_montant_ht"].'">';
|
||||
print '</td><td class="liste_titre" align="right">';
|
||||
print '<input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$_GET["search_montant_ttc"].'">';
|
||||
print '</td><td class="liste_titre" colspan="2" align="right">';
|
||||
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
print '</form>';
|
||||
|
||||
|
||||
$facturestatic=new Facture($db);
|
||||
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
$total=0;
|
||||
$totalrecu=0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
$class = "impayee";
|
||||
|
||||
print '<td nowrap><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill")."</a> ";
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.$objp->facnumber.'</a>'.$objp->increment;
|
||||
if ($objp->datelimite < (time() - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1) print img_warning($langs->trans("Late"));
|
||||
print "</td>\n";
|
||||
|
||||
print "<td nowrap align=\"center\">".dolibarr_print_date($objp->df)."</td>\n";
|
||||
print "<td nowrap align=\"center\">".dolibarr_print_date($objp->datelimite)."</td>\n";
|
||||
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,32).'</a></td>';
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
$total_ht=0;
|
||||
$total_ttc=0;
|
||||
$total_payed=0;
|
||||
|
||||
print "<td align=\"right\">".price($objp->total)."</td>";
|
||||
print "<td align=\"right\">".price($objp->total_ttc)."</td>";
|
||||
print "<td align=\"right\">".price($objp->am)."</td>";
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
// Affiche statut de la facture
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
$class = "impayee";
|
||||
|
||||
print '<td nowrap><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill")."</a> ";
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.$objp->facnumber.'</a>'.$objp->increment;
|
||||
if ($objp->datelimite < (time() - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1) print img_warning($langs->trans("Late"));
|
||||
print "</td>\n";
|
||||
|
||||
print "<td nowrap align=\"center\">".dolibarr_print_date($objp->df)."</td>\n";
|
||||
print "<td nowrap align=\"center\">".dolibarr_print_date($objp->datelimite)."</td>\n";
|
||||
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,32).'</a></td>';
|
||||
|
||||
print "<td align=\"right\">".price($objp->total_ht)."</td>";
|
||||
print "<td align=\"right\">".price($objp->total_ttc)."</td>";
|
||||
print "<td align=\"right\">".price($objp->am)."</td>";
|
||||
|
||||
// Affiche statut de la facture
|
||||
print '<td align="right" nowrap="nowrap">';
|
||||
print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am);
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
$total+=$objp->total;
|
||||
$total_ttc+=$objp->total_ttc;
|
||||
$totalrecu+=$objp->am;
|
||||
print "</tr>\n";
|
||||
$total_ht+=$objp->total_ht;
|
||||
$total_ttc+=$objp->total_ttc;
|
||||
$total_payed+=$objp->am;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
print '<tr class="liste_total">';
|
||||
print "<td colspan=\"4\" align=\"left\">".$langs->trans("Total").": </td>";
|
||||
print "<td align=\"right\"><b>".price($total)."</b></td>";
|
||||
print "<td align=\"right\"><b>".price($total_ttc)."</b></td>";
|
||||
print "<td align=\"right\"><b>".price($totalrecu)."</b></td>";
|
||||
print '<td align="center"> </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
print '<tr class="liste_total">';
|
||||
print "<td colspan=\"4\" align=\"left\">".$langs->trans("Total").": </td>";
|
||||
print "<td align=\"right\"><b>".price($total_ht)."</b></td>";
|
||||
print "<td align=\"right\"><b>".price($total_ttc)."</b></td>";
|
||||
print "<td align=\"right\"><b>".price($total_payed)."</b></td>";
|
||||
print '<td align="center"> </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print "</table>";
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
|
||||
253
htdocs/fourn/facture/impayees.php
Normal file
253
htdocs/fourn/facture/impayees.php
Normal file
@ -0,0 +1,253 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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/fourn/facture/impayees.php
|
||||
\ingroup facture
|
||||
\brief Page de liste des factures fournisseurs impayées
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.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("companies");
|
||||
$langs->load("bills");
|
||||
|
||||
|
||||
|
||||
if ($_GET["socid"]) { $socid=$_GET["socid"]; }
|
||||
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
llxHeader('',$langs->trans("BillsSuppliersUnpayed"));
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* Mode Liste *
|
||||
* *
|
||||
***************************************************************************/
|
||||
$page = $_GET["page"];
|
||||
$sortfield=$_GET["sortfield"];
|
||||
$sortorder=$_GET["sortorder"];
|
||||
if (! $sortfield) $sortfield="f.date_lim_reglement";
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
|
||||
if ($user->rights->fournisseur->facture->lire)
|
||||
{
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
|
||||
$sql = "SELECT s.nom, s.idp,";
|
||||
$sql.= " f.facnumber,f.total_ht,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";
|
||||
$sql.= " ,sum(pf.amount) as am";
|
||||
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= ",".MAIN_DB_PREFIX."facture_fourn as f";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn ";
|
||||
$sql.= " WHERE f.fk_soc = s.idp";
|
||||
$sql.= " AND f.paye = 0 AND f.fk_statut = 1";
|
||||
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql .= " AND s.idp = ".$socid;
|
||||
|
||||
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_ht = '".$_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.facnumber DESC";
|
||||
|
||||
//$sql .= $db->plimit($limit+1,$offset);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
if ($socid)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socid);
|
||||
}
|
||||
|
||||
$titre=($socid?$langs->trans("BillsSuppliersUnpayedForCompany",$soc->nom):$langs->trans("BillsSuppliersUnpayed"));
|
||||
print_barre_liste($titre,$page,"impayees.php","&socid=$socid",$sortfield,$sortorder,'',$num);
|
||||
$i = 0;
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","","&socid=$socid","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","","&socid=$socid",'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","","&socid=$socid",'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&socid=$socid","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total_ht","","&socid=$socid",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","","&socid=$socid",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("AlreadyPayed"),$_SERVER["PHP_SELF"],"am","","&socid=$socid",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","","&socid=$socid",'align="right"',$sortfield);
|
||||
print "</tr>\n";
|
||||
|
||||
// Lignes des champs de filtre
|
||||
print '<form method="get" action="impayees.php">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre" valign="right">';
|
||||
print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET["search_ref"].'"></td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre" align="left">';
|
||||
print '<input class="flat" type="text" name="search_societe" value="'.$_GET["search_societe"].'">';
|
||||
print '</td><td class="liste_titre" align="right">';
|
||||
print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$_GET["search_montant_ht"].'">';
|
||||
print '</td><td class="liste_titre" align="right">';
|
||||
print '<input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$_GET["search_montant_ttc"].'">';
|
||||
print '</td><td class="liste_titre" colspan="2" align="right">';
|
||||
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
print '</form>';
|
||||
|
||||
|
||||
$facturestatic=new FactureFournisseur($db);
|
||||
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
$total_ht=0;
|
||||
$total_ttc=0;
|
||||
$total_payed=0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
$class = "impayee";
|
||||
|
||||
print '<td nowrap><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill")."</a> ";
|
||||
print '<a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$objp->facid.'">'.$objp->facnumber.'</a>';
|
||||
if ($objp->datelimite < (time() - $conf->facture->fournisseur->warning_delay) && ! $objp->paye && $objp->fk_statut == 1) print img_warning($langs->trans("Late"));
|
||||
print "</td>\n";
|
||||
|
||||
print "<td nowrap align=\"center\">".dolibarr_print_date($objp->df)."</td>\n";
|
||||
print "<td nowrap align=\"center\">".dolibarr_print_date($objp->datelimite)."</td>\n";
|
||||
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,32).'</a></td>';
|
||||
|
||||
print "<td align=\"right\">".price($objp->total_ht)."</td>";
|
||||
print "<td align=\"right\">".price($objp->total_ttc)."</td>";
|
||||
print "<td align=\"right\">".price($objp->am)."</td>";
|
||||
|
||||
// Affiche statut de la facture
|
||||
print '<td align="right" nowrap="nowrap">';
|
||||
print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am);
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
$total_ht+=$objp->total_ht;
|
||||
$total_ttc+=$objp->total_ttc;
|
||||
$total_payed+=$objp->am;
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
print '<tr class="liste_total">';
|
||||
print "<td colspan=\"4\" align=\"left\">".$langs->trans("Total").": </td>";
|
||||
print "<td align=\"right\"><b>".price($total_ht)."</b></td>";
|
||||
print "<td align=\"right\"><b>".price($total_ttc)."</b></td>";
|
||||
print "<td align=\"right\"><b>".price($total_payed)."</b></td>";
|
||||
print '<td align="center"> </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
@ -53,7 +53,7 @@ $offset = $limit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
if (! $sortfield) $sortfield="fac.date_lim_reglement";
|
||||
if (! $sortfield) $sortfield="fac.datef";
|
||||
|
||||
|
||||
/*
|
||||
@ -89,12 +89,13 @@ if ($_POST["mode"] == 'search')
|
||||
|
||||
llxHeader();
|
||||
|
||||
$sql = "SELECT s.idp as socid, s.nom, ".$db->pdate("fac.date_lim_reglement")." as date_echeance, fac.total_ht";
|
||||
$sql .= ", fac.total_ttc, fac.paye as paye, fac.fk_statut as fk_statut, fac.libelle, fac.rowid as facid, fac.facnumber";
|
||||
$sql = "SELECT s.idp as socid, s.nom, ";
|
||||
$sql.= " ".$db->pdate("fac.datef")." as datef, ".$db->pdate("fac.date_lim_reglement")." as date_echeance,";
|
||||
$sql.= " fac.total_ht, fac.total_ttc, fac.paye as paye, fac.fk_statut as fk_statut, fac.libelle, fac.rowid as facid, fac.facnumber";
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as fac";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as fac";
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql .= " WHERE fac.fk_soc = s.idp";
|
||||
$sql.= " WHERE fac.fk_soc = s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid)
|
||||
{
|
||||
@ -154,7 +155,7 @@ if ($resql)
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Ref"),"index.php","facnumber","&socid=$socid","","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("DateEcheance"),"index.php","fac.date_lim_reglement","&socid=$socid","","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Date"),"index.php","fac.datef","&socid=$socid","",'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Label"),"index.php","fac.libelle","&socid=$socid","","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","&socid=$socid","","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("AmountHT"),"index.php","fac.total_ht","&socid=$socid","",'align="right"',$sortfield);
|
||||
@ -194,10 +195,10 @@ if ($resql)
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td nowrap><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$obj->facid.'" title="'.$obj->facnumber.'">'.img_object($langs->trans("ShowBill"),"bill").' '.dolibarr_trunc($obj->facnumber,12)."</a></td>\n";
|
||||
print '<td align="center" nowrap>'.dolibarr_print_date($obj->date_echeance);
|
||||
print '<td nowrap><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$obj->facid.'" title="'.$obj->facnumber.'">'.img_object($langs->trans("ShowBill"),"bill").' '.dolibarr_trunc($obj->facnumber,12)."</a>";
|
||||
if (($obj->paye == 0) && ($obj->fk_statut > 0) && $obj->date_echeance < (time() - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning");
|
||||
print '</td>';
|
||||
print "</td>\n";
|
||||
print '<td align="center" nowrap="1">'.dolibarr_print_date($obj->datef).'</td>';
|
||||
print '<td>'.dolibarr_trunc($obj->libelle,36).'</td>';
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.'</a</td>';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -18,13 +18,12 @@
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/fourn/facture/pre.inc.php
|
||||
\ingroup fournisseur,facture
|
||||
\brief Fichier gestionnaire du menu factures fournisseurs
|
||||
\file htdocs/fourn/facture/pre.inc.php
|
||||
\ingroup fournisseur,facture
|
||||
\brief Fichier gestionnaire du menu factures fournisseurs
|
||||
*/
|
||||
|
||||
require("../../main.inc.php");
|
||||
@ -32,78 +31,75 @@ require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.facture.class.php";
|
||||
$user->getrights('fournisseur');
|
||||
|
||||
function llxHeader($head = "", $title = "", $addons='') {
|
||||
global $user, $conf, $langs;
|
||||
function llxHeader($head = "", $title = "", $addons='')
|
||||
{
|
||||
global $user, $conf, $langs;
|
||||
|
||||
$langs->load("suppliers");
|
||||
$langs->load("propal");
|
||||
$langs->load("suppliers");
|
||||
$langs->load("propal");
|
||||
|
||||
top_menu($head, $title);
|
||||
top_menu($head, $title);
|
||||
|
||||
$menu = new Menu();
|
||||
$menu = new Menu();
|
||||
|
||||
|
||||
if (is_array($addons))
|
||||
{
|
||||
//$menu->add($url, $libelle);
|
||||
if (is_array($addons))
|
||||
{
|
||||
//$menu->add($url, $libelle);
|
||||
|
||||
$menu->add($addons[0][0], $addons[0][1]);
|
||||
}
|
||||
$menu->add($addons[0][0], $addons[0][1]);
|
||||
}
|
||||
|
||||
|
||||
if ($conf->fournisseur->enabled)
|
||||
{
|
||||
if ($user->rights->societe->lire)
|
||||
{
|
||||
$menu->add(DOL_URL_ROOT."/fourn/index.php", $langs->trans("Suppliers"));
|
||||
}
|
||||
if ($conf->fournisseur->enabled)
|
||||
{
|
||||
if ($user->rights->societe->lire)
|
||||
{
|
||||
$menu->add(DOL_URL_ROOT."/fourn/index.php", $langs->trans("Suppliers"));
|
||||
}
|
||||
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id == 0 && $user->rights->societe->creer)
|
||||
{
|
||||
$menu->add_submenu(DOL_URL_ROOT."/soc.php?action=create&type=f",$langs->trans("NewSupplier"));
|
||||
}
|
||||
}
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id == 0 && $user->rights->societe->creer)
|
||||
{
|
||||
$menu->add_submenu(DOL_URL_ROOT."/soc.php?action=create&type=f",$langs->trans("NewSupplier"));
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->societe->enabled)
|
||||
{
|
||||
if ($user->rights->societe->lire)
|
||||
{
|
||||
$menu->add_submenu(DOL_URL_ROOT."/fourn/contact.php",$langs->trans("Contacts"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$langs->load("bills");
|
||||
if ($user->rights->fournisseur->facture->lire)
|
||||
{
|
||||
$menu->add(DOL_URL_ROOT."/fourn/facture/index.php", $langs->trans("Bills"));
|
||||
}
|
||||
|
||||
|
||||
if ($user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$menu->add_submenu(DOL_URL_ROOT."/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"));
|
||||
}
|
||||
if ($user->rights->fournisseur->facture->lire)
|
||||
{
|
||||
$menu->add_submenu(DOL_URL_ROOT."/fourn/facture/paiement.php", $langs->trans("Payments"));
|
||||
}
|
||||
|
||||
|
||||
$langs->load("orders");
|
||||
if ($user->rights->fournisseur->commande->lire)
|
||||
{
|
||||
$menu->add(DOL_URL_ROOT."/fourn/commande/",$langs->trans("Orders"));
|
||||
}
|
||||
if ($conf->societe->enabled)
|
||||
{
|
||||
if ($user->rights->societe->lire)
|
||||
{
|
||||
$menu->add_submenu(DOL_URL_ROOT."/fourn/contact.php",$langs->trans("Contacts"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($conf->produit->enabled || $conf->service->enabled)
|
||||
{
|
||||
$menu->add(DOL_URL_ROOT."/product/liste.php?type=0", $langs->trans("Products"));
|
||||
}
|
||||
|
||||
left_menu($menu->liste);
|
||||
$langs->load("bills");
|
||||
if ($user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$menu->add_submenu(DOL_URL_ROOT."/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"));
|
||||
}
|
||||
if ($user->rights->fournisseur->facture->lire)
|
||||
{
|
||||
$menu->add(DOL_URL_ROOT."/fourn/facture/index.php", $langs->trans("Bills"));
|
||||
$menu->add_submenu(DOL_URL_ROOT."/fourn/facture/impayees.php",$langs->trans("Unpayed"));
|
||||
$menu->add_submenu(DOL_URL_ROOT."/fourn/facture/paiement.php", $langs->trans("Payments"));
|
||||
}
|
||||
|
||||
|
||||
$langs->load("orders");
|
||||
if ($user->rights->fournisseur->commande->lire)
|
||||
{
|
||||
$menu->add(DOL_URL_ROOT."/fourn/commande/",$langs->trans("Orders"));
|
||||
}
|
||||
|
||||
$langs->load("products");
|
||||
if ($conf->produit->enabled || $conf->service->enabled)
|
||||
{
|
||||
$menu->add(DOL_URL_ROOT."/product/liste.php?type=0", $langs->trans("Products"));
|
||||
}
|
||||
|
||||
left_menu($menu->liste);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -291,6 +291,7 @@ class MenuLeft {
|
||||
{
|
||||
if ($leftmenu=="suppliers_bills") $newmenu->add_submenu(DOL_URL_ROOT."/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"),2,$user->rights->fournisseur->facture->creer);
|
||||
}
|
||||
if ($leftmenu=="suppliers_bills") $newmenu->add_submenu(DOL_URL_ROOT."/fourn/facture/impayees.php", $langs->trans("Unpayed"),2,$user->rights->fournisseur->facture->lire);
|
||||
if ($leftmenu=="suppliers_bills") $newmenu->add_submenu(DOL_URL_ROOT."/fourn/facture/paiement.php", $langs->trans("Payments"),2,$user->rights->fournisseur->facture->lire);
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,6 +293,7 @@ class MenuLeft {
|
||||
{
|
||||
if ($leftmenu=="suppliers_bills") $newmenu->add_submenu(DOL_URL_ROOT."/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"),2,$user->rights->fournisseur->facture->creer);
|
||||
}
|
||||
if ($leftmenu=="suppliers_bills") $newmenu->add_submenu(DOL_URL_ROOT."/fourn/facture/impayees.php", $langs->trans("Unpayed"),2,$user->rights->fournisseur->facture->lire);
|
||||
if ($leftmenu=="suppliers_bills") $newmenu->add_submenu(DOL_URL_ROOT."/fourn/facture/paiement.php", $langs->trans("Payments"),2,$user->rights->fournisseur->facture->lire);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user