diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 6340e00c28fb0874286804e3fcf120e90d5e9a82..98e8a14889703140e44d88a5c58691d90202c460 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -133,7 +133,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) */ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) { - print '<form method="post" action="'.DOL_URL_ROOT.'/fourn/facture/index.php">'; + print '<form method="post" action="'.DOL_URL_ROOT.'/fourn/facture/list.php">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<table class="noborder nohover" width="100%">'; print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchASupplierInvoice").'</td></tr>'; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 882554582c10e3c3f924fe87abda64a0296a6704..d8c134c12efba00ca9ea99f115ab92238bc6ee27 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -331,7 +331,7 @@ if ($result) { $var=!$var; print "<tr ".$bc[$var]."><td> </td>"; - print "<td>".$langs->trans("Bills")." <a href=\"".DOL_URL_ROOT."/fourn/facture/index.php?socid=".$objp->socid."\">".$objp->nom."</a></td>\n"; + print "<td>".$langs->trans("Bills")." <a href=\"".DOL_URL_ROOT."/fourn/facture/list.php?socid=".$objp->socid."\">".$objp->nom."</a></td>\n"; if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price(-$objp->amount_ht)."</td>\n"; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index d97a33cb8ea1381e5270e830df85690f6773abb6..f59aa43a6af43cadce9c79110b392407d6b6ce7c 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -151,7 +151,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->ficheinter->enabled', __HANDLER__, 'left', 1501__+MAX_llx_menu__, 'commercial', '', 1500__+MAX_llx_menu__, '/fichinter/fiche.php?action=create&leftmenu=ficheinter', 'NewIntervention', 1, 'interventions', '$user->rights->ficheinter->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->ficheinter->enabled', __HANDLER__, 'left', 1502__+MAX_llx_menu__, 'commercial', '', 1500__+MAX_llx_menu__, '/fichinter/list.php?leftmenu=ficheinter', 'List', 1, 'interventions', '$user->rights->ficheinter->lire', '', 2, 1, __ENTITY__); -- Accountancy - Supplier invoice -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->fournisseur->enabled', __HANDLER__, 'left', 1600__+MAX_llx_menu__, 'accountancy', 'supplier_bills', 6__+MAX_llx_menu__, '/fourn/facture/index.php?leftmenu=suppliers_bills', 'BillsSuppliers', 0, 'bills', '$user->rights->fournisseur->facture->lire', '', 2, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->fournisseur->enabled', __HANDLER__, 'left', 1600__+MAX_llx_menu__, 'accountancy', 'supplier_bills', 6__+MAX_llx_menu__, '/fourn/facture/list.php?leftmenu=suppliers_bills', 'BillsSuppliers', 0, 'bills', '$user->rights->fournisseur->facture->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->fournisseur->enabled', __HANDLER__, 'left', 1601__+MAX_llx_menu__, 'accountancy', '', 1600__+MAX_llx_menu__, '/fourn/facture/fiche.php?action=create&leftmenu=suppliers_bills', 'NewBill', 1, 'bills', '$user->rights->fournisseur->facture->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->fournisseur->enabled', __HANDLER__, 'left', 1602__+MAX_llx_menu__, 'accountancy', '', 1600__+MAX_llx_menu__, '/fourn/facture/impayees.php?leftmenu=suppliers_bills', 'Unpaid', 1, 'bills', '$user->rights->fournisseur->facture->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->fournisseur->enabled', __HANDLER__, 'left', 1603__+MAX_llx_menu__, 'accountancy', '', 1600__+MAX_llx_menu__, '/fourn/facture/paiement.php?leftmenu=suppliers_bills', 'Payments', 1, 'bills', '$user->rights->fournisseur->facture->lire', '', 2, 2, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b76d2920335d49104288164fb2a48315cb98ddb5..7a8ac8312fe3d711f1e136fe1a4a8420123ca11f 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -769,7 +769,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->facture->enabled)) { $langs->load("bills"); - $newmenu->add("/fourn/facture/index.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"),0,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); + $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"),0,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); if (empty($user->societe_id)) { $newmenu->add("/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer); @@ -1041,7 +1041,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->facture->enabled)) { $langs->load("bills"); - $newmenu->add("/fourn/facture/index.php?leftmenu=orders", $langs->trans("Bills"), 0, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'orders'); + $newmenu->add("/fourn/facture/list.php?leftmenu=orders", $langs->trans("Bills"), 0, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'orders'); if (empty($user->societe_id)) { diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index 004e5cbb64896b699ceb598dd228e527562208d3..c5205c47815bb80e442b0bd285ebfdcb3543f81a 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -142,7 +142,7 @@ if ($id > 0 || ! empty($ref)) */ print '<table class="border" width="100%">'; - $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/index.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; + $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; // Reference du facture print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">'; diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index a8fceb2a9989a05273cc574e4f5fa3ad158aedd1..56b8f78762fa4d89cdfffcd8b2bc99d1d1bbad21 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -127,7 +127,7 @@ if ($object->id > 0) print '<table class="border" width="100%">'; - $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/index.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; + $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; // Ref print '<tr><td width="30%" class="nowrap">'.$langs->trans("Ref").'</td><td colspan="3">'; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 7789d673b1e1d8df81e364f26904d34f33f4a87a..5f717cce3d38411f543a7073045a66181f918428 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -1404,7 +1404,7 @@ else */ print '<table class="border" width="100%">'; - $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/index.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; + $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; // Ref print '<tr><td class="nowrap" width="20%">'.$langs->trans("Ref").'</td><td colspan="4">'; @@ -1419,7 +1419,7 @@ else // Third party print '<tr><td>'.$langs->trans('Supplier').'</td><td colspan="4">'.$societe->getNomUrl(1); - print ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/index.php?socid='.$object->socid.'">'.$langs->trans('OtherBills').'</a>)</td>'; + print ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->socid.'">'.$langs->trans('OtherBills').'</a>)</td>'; print '</tr>'; // Type diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php index 540cbebea129dd07895955a86ec2adedb4286b61..7db0dd9ebf92f2ddad5a82d32d38ab764846107a 100644 --- a/htdocs/fourn/facture/index.php +++ b/htdocs/fourn/facture/index.php @@ -1,306 +1 @@ -<?php -/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com> - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - */ - -/** - * \file htdocs/fourn/facture/index.php - * \ingroup fournisseur,facture - * \brief List of suppliers invoices - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - -if (!$user->rights->fournisseur->facture->lire) accessforbidden(); - -$langs->load("companies"); -$langs->load("bills"); - -$socid = GETPOST('socid','int'); - -// Security check -if ($user->societe_id > 0) -{ - $action=''; - $_GET["action"] = ''; - $socid = $user->societe_id; -} - -$mode=GETPOST("mode"); -$modesearch=GETPOST("mode_search"); - -$page=GETPOST("page",'int'); -$sortorder = GETPOST("sortorder",'alpha'); -$sortfield = GETPOST("sortfield",'alpha'); - -if ($page == -1) { $page = 0 ; } -$limit = $conf->liste_limit; -$offset = $limit * $page ; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="fac.datef,fac.rowid"; - -$month = GETPOST('month','int'); -$year = GETPOST('year','int'); - - -/* - * Actions - */ - -if ($mode == 'search') -{ - if ($modesearch == 'soc') - { - $sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s "; - $sql.= " WHERE s.nom LIKE '%".$db->escape($socname)."%'"; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; - } - - $resql=$db->query($sql); - if ($resql) - { - if ( $db->num_rows($resql) == 1) - { - $obj = $db->fetch_object($resql); - $socid = $obj->rowid; - } - $db->free($resql); - } -} - - - - -/* - * View - */ - -$now=dol_now(); -$form=new Form($db); -$htmlother=new FormOther($db); - -llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); - -$sql = "SELECT s.rowid as socid, s.nom, "; -$sql.= " fac.rowid as facid, fac.ref, fac.ref_supplier, fac.datef, 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"; -if (!$user->rights->societe->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"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE fac.entity = ".$conf->entity; -$sql.= " AND fac.fk_soc = s.rowid"; -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 (GETPOST('filtre')) -{ - $filtrearr = explode(",", GETPOST('filtre')); - foreach ($filtrearr as $fil) - { - $filt = explode(":", $fil); - $sql .= " AND " . $filt[0] . " = " . $filt[1]; - } -} - -if (GETPOST("search_ref")) -{ - if (is_numeric(GETPOST("search_ref"))) $sql .= " AND (fac.rowid = ".GETPOST("search_ref",'int')." OR fac.ref = '".$db->escape(GETPOST("search_ref"))."')"; // For backward compatibility - else $sql .= " AND fac.ref LIKE '%".$db->escape(GETPOST("search_ref"))."%'"; -} -if (GETPOST("search_ref_supplier")) -{ - $sql .= " AND fac.ref_supplier LIKE '%".$db->escape(GETPOST("search_ref_supplier"))."%'"; -} -if ($month > 0) -{ - if ($year > 0) - $sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; - else - $sql.= " AND date_format(fac.datef, '%m') = '$month'"; -} -else if ($year > 0) -{ - $sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; -} -if (GETPOST("search_libelle")) -{ - $sql .= " AND fac.libelle LIKE '%".$db->escape(GETPOST("search_libelle"))."%'"; -} - -if (GETPOST("search_societe")) -{ - $sql .= " AND s.nom LIKE '%".$db->escape(GETPOST("search_societe"))."%'"; -} - -if (GETPOST("search_montant_ht")) -{ - $sql .= " AND fac.total_ht = '".$db->escape(price2num(GETPOST("search_montant_ht")))."'"; -} - -if (GETPOST("search_montant_ttc")) -{ - $sql .= " AND fac.total_ttc = '".$db->escape(price2num(GETPOST("search_montant_ttc")))."'"; -} - -$sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($limit+1, $offset); - -$resql = $db->query($sql); -if ($resql) -{ - $num = $db->num_rows($resql); - $i = 0; - - if ($socid) { - $soc = new Societe($db); - $soc->fetch($socid); - } - - $param='&socid='.$socid; - if ($month) $param.='&month='.urlencode($month); - if ($year) $param.='&year=' .urlencode($year); - if (GETPOST("search_ref")) $param.='&search_ref='.urlencode(GETPOST("search_ref")); - if (GETPOST("search_ref_supplier")) $param.='&search_ref_supplier'.urlencode(GETPOST("search_ref_supplier")); - if (GETPOST("search_libelle")) $param.='&search_libelle='.urlencode(GETPOST("search_libelle")); - if (GETPOST("search_societe")) $param.='&search_societe='.urlencode(GETPOST("search_societe")); - if (GETPOST("search_montant_ht")) $param.='&search_montant_ht='.urlencode(GETPOST("search_montant_ht")); - if (GETPOST("search_montant_ttc")) $param.='&search_montant_ttc='.urlencode(GETPOST("search_montant_ttc")); - - print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->nom":""),$page,"index.php",$param,$sortfield,$sortorder,'',$num); - print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">'; - print '<table class="liste" width="100%">'; - print '<tr class="liste_titre">'; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"fac.ref,fac.rowid","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("RefSupplier"),$_SERVER["PHP_SELF"],"ref_supplier","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"fac.datef,fac.rowid","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"fac.date_lim_reglement","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"fac.libelle","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"fac.total_ht","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"fac.total_ttc","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye","",$param,'align="center"',$sortfield,$sortorder); - print "</tr>\n"; - - // Lignes des champs de filtre - - print '<tr class="liste_titre">'; - print '<td class="liste_titre" align="left">'; - print '<input class="flat" size="6" type="text" name="search_ref" value="'.GETPOST("search_ref").'">'; - print '</td>'; - print '<td class="liste_titre" align="left">'; - print '<input class="flat" size="6" type="text" name="search_ref_supplier" value="'.GETPOST("search_ref_supplier").'">'; - print '</td>'; - print '<td class="liste_titre" colspan="1" align="center">'; - print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">'; - //print ' '.$langs->trans('Year').': '; - $syear = $year; - //if ($syear == '') $syear = date("Y"); - $htmlother->select_year($syear?$syear:-1,'year',1, 20, 5); - print '</td>'; - print '<td class="liste_titre"> </td>'; - print '<td class="liste_titre" align="left">'; - print '<input class="flat" size="16" type="text" name="search_libelle" value="'.GETPOST("search_libelle").'">'; - print '</td>'; - print '<td class="liste_titre" align="left">'; - print '<input class="flat" type="text" size="8" name="search_societe" value="'.GETPOST("search_societe").'">'; - print '</td><td class="liste_titre" align="right">'; - print '<input class="flat" type="text" size="8" name="search_montant_ht" value="'.GETPOST("search_montant_ht").'">'; - print '</td><td class="liste_titre" align="right">'; - print '<input class="flat" type="text" size="8" name="search_montant_ttc" value="'.GETPOST("search_montant_ttc").'">'; - print '</td><td class="liste_titre" colspan="2" align="center">'; - print '<input type="image" class="liste_titre" align="right" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; - print '</td>'; - print "</tr>\n"; - - $facturestatic=new FactureFournisseur($db); - $supplierstatic=new Fournisseur($db); - - $var=true; - $total=0; - $total_ttc=0; - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($resql); - $var=!$var; - - print "<tr ".$bc[$var].">"; - print '<td class="nowrap">'; - $facturestatic->id=$obj->facid; - $facturestatic->ref=$obj->ref; - $facturestatic->ref_supplier=$obj->ref_supplier; - print $facturestatic->getNomUrl(1); - print "</td>\n"; - print '<td class="nowrap">'.dol_trunc($obj->ref_supplier,10)."</td>"; - print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datef),'day').'</td>'; - print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->date_echeance),'day'); - if (($obj->paye == 0) && ($obj->fk_statut > 0) && $obj->date_echeance && $db->jdate($obj->date_echeance) < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning"); - print '</td>'; - print '<td>'.dol_trunc($obj->libelle,36).'</td>'; - print '<td>'; - $supplierstatic->id=$obj->socid; - $supplierstatic->nom=$obj->nom; - print $supplierstatic->getNomUrl(1,'',12); - print '<td align="right">'.price($obj->total_ht).'</td>'; - print '<td align="right">'.price($obj->total_ttc).'</td>'; - $total+=$obj->total_ht; - $total_ttc+=$obj->total_ttc; - - // Affiche statut de la facture - print '<td align="right" class="nowrap">'; - // TODO le montant deja paye objp->am n'est pas definie - //print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$objp->am); - print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5); - print '</td>'; - - print "</tr>\n"; - $i++; - - if ($i == min($num,$limit)) - { - // Print total - print '<tr class="liste_total">'; - print '<td class="liste_total" colspan="6" align="left">'.$langs->trans("Total").'</td>'; - print '<td class="liste_total" align="right">'.price($total).'</td>'; - print '<td class="liste_total" align="right">'.price($total_ttc).'</td>'; - print '<td class="liste_total" align="center"> </td>'; - print "</tr>\n"; - } - } - - print "</table>\n"; - print "</form>\n"; - $db->free($resql); -} -else -{ - dol_print_error($db); -} - -$db->close(); - - -llxFooter(); -?> +Url not available \ No newline at end of file diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php new file mode 100644 index 0000000000000000000000000000000000000000..80c20a821ba514e7af2f79db0007085eb94c0ebc --- /dev/null +++ b/htdocs/fourn/facture/list.php @@ -0,0 +1,306 @@ +<?php +/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> + * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com> + * + * 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 3 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, see <http://www.gnu.org/licenses/>. + */ + +/** + * \file htdocs/fourn/facture/list.php + * \ingroup fournisseur,facture + * \brief List of suppliers invoices + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + +if (!$user->rights->fournisseur->facture->lire) accessforbidden(); + +$langs->load("companies"); +$langs->load("bills"); + +$socid = GETPOST('socid','int'); + +// Security check +if ($user->societe_id > 0) +{ + $action=''; + $_GET["action"] = ''; + $socid = $user->societe_id; +} + +$mode=GETPOST("mode"); +$modesearch=GETPOST("mode_search"); + +$page=GETPOST("page",'int'); +$sortorder = GETPOST("sortorder",'alpha'); +$sortfield = GETPOST("sortfield",'alpha'); + +if ($page == -1) { $page = 0 ; } +$limit = $conf->liste_limit; +$offset = $limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) $sortfield="fac.datef,fac.rowid"; + +$month = GETPOST('month','int'); +$year = GETPOST('year','int'); + + +/* + * Actions + */ + +if ($mode == 'search') +{ + if ($modesearch == 'soc') + { + $sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s "; + $sql.= " WHERE s.nom LIKE '%".$db->escape($socname)."%'"; + $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; + } + + $resql=$db->query($sql); + if ($resql) + { + if ( $db->num_rows($resql) == 1) + { + $obj = $db->fetch_object($resql); + $socid = $obj->rowid; + } + $db->free($resql); + } +} + + + + +/* + * View + */ + +$now=dol_now(); +$form=new Form($db); +$htmlother=new FormOther($db); + +llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); + +$sql = "SELECT s.rowid as socid, s.nom, "; +$sql.= " fac.rowid as facid, fac.ref, fac.ref_supplier, fac.datef, 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"; +if (!$user->rights->societe->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"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= " WHERE fac.entity = ".$conf->entity; +$sql.= " AND fac.fk_soc = s.rowid"; +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 (GETPOST('filtre')) +{ + $filtrearr = explode(",", GETPOST('filtre')); + foreach ($filtrearr as $fil) + { + $filt = explode(":", $fil); + $sql .= " AND " . $filt[0] . " = " . $filt[1]; + } +} + +if (GETPOST("search_ref")) +{ + if (is_numeric(GETPOST("search_ref"))) $sql .= " AND (fac.rowid = ".GETPOST("search_ref",'int')." OR fac.ref = '".$db->escape(GETPOST("search_ref"))."')"; // For backward compatibility + else $sql .= " AND fac.ref LIKE '%".$db->escape(GETPOST("search_ref"))."%'"; +} +if (GETPOST("search_ref_supplier")) +{ + $sql .= " AND fac.ref_supplier LIKE '%".$db->escape(GETPOST("search_ref_supplier"))."%'"; +} +if ($month > 0) +{ + if ($year > 0) + $sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + else + $sql.= " AND date_format(fac.datef, '%m') = '$month'"; +} +else if ($year > 0) +{ + $sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; +} +if (GETPOST("search_libelle")) +{ + $sql .= " AND fac.libelle LIKE '%".$db->escape(GETPOST("search_libelle"))."%'"; +} + +if (GETPOST("search_societe")) +{ + $sql .= " AND s.nom LIKE '%".$db->escape(GETPOST("search_societe"))."%'"; +} + +if (GETPOST("search_montant_ht")) +{ + $sql .= " AND fac.total_ht = '".$db->escape(price2num(GETPOST("search_montant_ht")))."'"; +} + +if (GETPOST("search_montant_ttc")) +{ + $sql .= " AND fac.total_ttc = '".$db->escape(price2num(GETPOST("search_montant_ttc")))."'"; +} + +$sql.= $db->order($sortfield,$sortorder); +$sql.= $db->plimit($limit+1, $offset); + +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + if ($socid) { + $soc = new Societe($db); + $soc->fetch($socid); + } + + $param='&socid='.$socid; + if ($month) $param.='&month='.urlencode($month); + if ($year) $param.='&year=' .urlencode($year); + if (GETPOST("search_ref")) $param.='&search_ref='.urlencode(GETPOST("search_ref")); + if (GETPOST("search_ref_supplier")) $param.='&search_ref_supplier'.urlencode(GETPOST("search_ref_supplier")); + if (GETPOST("search_libelle")) $param.='&search_libelle='.urlencode(GETPOST("search_libelle")); + if (GETPOST("search_societe")) $param.='&search_societe='.urlencode(GETPOST("search_societe")); + if (GETPOST("search_montant_ht")) $param.='&search_montant_ht='.urlencode(GETPOST("search_montant_ht")); + if (GETPOST("search_montant_ttc")) $param.='&search_montant_ttc='.urlencode(GETPOST("search_montant_ttc")); + + print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->nom":""),$page,"index.php",$param,$sortfield,$sortorder,'',$num); + print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">'; + print '<table class="liste" width="100%">'; + print '<tr class="liste_titre">'; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"fac.ref,fac.rowid","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("RefSupplier"),$_SERVER["PHP_SELF"],"ref_supplier","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"fac.datef,fac.rowid","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"fac.date_lim_reglement","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"fac.libelle","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"fac.total_ht","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"fac.total_ttc","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye","",$param,'align="center"',$sortfield,$sortorder); + print "</tr>\n"; + + // Lignes des champs de filtre + + print '<tr class="liste_titre">'; + print '<td class="liste_titre" align="left">'; + print '<input class="flat" size="6" type="text" name="search_ref" value="'.GETPOST("search_ref").'">'; + print '</td>'; + print '<td class="liste_titre" align="left">'; + print '<input class="flat" size="6" type="text" name="search_ref_supplier" value="'.GETPOST("search_ref_supplier").'">'; + print '</td>'; + print '<td class="liste_titre" colspan="1" align="center">'; + print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">'; + //print ' '.$langs->trans('Year').': '; + $syear = $year; + //if ($syear == '') $syear = date("Y"); + $htmlother->select_year($syear?$syear:-1,'year',1, 20, 5); + print '</td>'; + print '<td class="liste_titre"> </td>'; + print '<td class="liste_titre" align="left">'; + print '<input class="flat" size="16" type="text" name="search_libelle" value="'.GETPOST("search_libelle").'">'; + print '</td>'; + print '<td class="liste_titre" align="left">'; + print '<input class="flat" type="text" size="8" name="search_societe" value="'.GETPOST("search_societe").'">'; + print '</td><td class="liste_titre" align="right">'; + print '<input class="flat" type="text" size="8" name="search_montant_ht" value="'.GETPOST("search_montant_ht").'">'; + print '</td><td class="liste_titre" align="right">'; + print '<input class="flat" type="text" size="8" name="search_montant_ttc" value="'.GETPOST("search_montant_ttc").'">'; + print '</td><td class="liste_titre" colspan="2" align="center">'; + print '<input type="image" class="liste_titre" align="right" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; + print '</td>'; + print "</tr>\n"; + + $facturestatic=new FactureFournisseur($db); + $supplierstatic=new Fournisseur($db); + + $var=true; + $total=0; + $total_ttc=0; + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($resql); + $var=!$var; + + print "<tr ".$bc[$var].">"; + print '<td class="nowrap">'; + $facturestatic->id=$obj->facid; + $facturestatic->ref=$obj->ref; + $facturestatic->ref_supplier=$obj->ref_supplier; + print $facturestatic->getNomUrl(1); + print "</td>\n"; + print '<td class="nowrap">'.dol_trunc($obj->ref_supplier,10)."</td>"; + print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datef),'day').'</td>'; + print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->date_echeance),'day'); + if (($obj->paye == 0) && ($obj->fk_statut > 0) && $obj->date_echeance && $db->jdate($obj->date_echeance) < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning"); + print '</td>'; + print '<td>'.dol_trunc($obj->libelle,36).'</td>'; + print '<td>'; + $supplierstatic->id=$obj->socid; + $supplierstatic->nom=$obj->nom; + print $supplierstatic->getNomUrl(1,'',12); + print '<td align="right">'.price($obj->total_ht).'</td>'; + print '<td align="right">'.price($obj->total_ttc).'</td>'; + $total+=$obj->total_ht; + $total_ttc+=$obj->total_ttc; + + // Affiche statut de la facture + print '<td align="right" class="nowrap">'; + // TODO le montant deja paye objp->am n'est pas definie + //print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$objp->am); + print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5); + print '</td>'; + + print "</tr>\n"; + $i++; + + if ($i == min($num,$limit)) + { + // Print total + print '<tr class="liste_total">'; + print '<td class="liste_total" colspan="6" align="left">'.$langs->trans("Total").'</td>'; + print '<td class="liste_total" align="right">'.price($total).'</td>'; + print '<td class="liste_total" align="right">'.price($total_ttc).'</td>'; + print '<td class="liste_total" align="center"> </td>'; + print "</tr>\n"; + } + } + + print "</table>\n"; + print "</form>\n"; + $db->free($resql); +} +else +{ + dol_print_error($db); +} + + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index d1143966010737c858addffb9df64ecb4e5c126c..b4bb99dcefc64886a523bd76ab6dcea0bad690ce 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -88,7 +88,7 @@ if ($object->id > 0) print '<table class="border" width="100%">'; - $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/index.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; + $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; // Ref print '<tr><td width="20%" class="nowrap">'.$langs->trans("Ref").'</td><td colspan="3">'; diff --git a/htdocs/index.php b/htdocs/index.php index e2d50d77a6fec6c3a91decdee7b1885ed8962669..a93e0f10a54456e7a774b0b6f717de57e8d249dd 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -416,7 +416,7 @@ if (! empty($conf->fournisseur->enabled) && ! empty($conf->facture->enabled) && $board->load_board($user); $board->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24; $board->label=$langs->trans("SupplierBillsToPay"); - $board->url=DOL_URL_ROOT.'/fourn/facture/index.php?filtre=paye:0'; + $board->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=paye:0'; $board->img=img_object($langs->trans("Bills"),"bill"); $rowspan++; $dashboardlines[]=$board;