dolibarr/htdocs/fourn/index.php

140 lines
4.4 KiB
PHP
Raw Normal View History

<?php
2005-07-20 14:18:41 +02:00
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2005-01-08 23:20:19 +01:00
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
2003-08-04 14:42:49 +02:00
*
* 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$
*/
2005-04-26 01:25:18 +02:00
/**
2005-08-11 21:04:42 +02:00
\file htdocs/fourn/index.php
\ingroup fournisseur
\brief Page accueil de la zone fournisseurs
\version $Revision$
2005-01-08 23:20:19 +01:00
*/
2003-09-11 22:18:51 +02:00
require("./pre.inc.php");
2004-11-30 20:34:29 +01:00
2005-07-23 16:48:58 +02:00
if (!$user->rights->societe->lire)
accessforbidden();
2005-08-11 21:04:42 +02:00
$page = isset($_GET["page"])?$_GET["page"]:'';
$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:'';
$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:'';
$socname = isset($_GET["socname"])?$_GET["socname"]:'';
$search_nom = isset($_GET["search_nom"])?$_GET["search_nom"]:'';
$search_ville = isset($_GET["search_ville"])?$_GET["search_ville"]:'';
2004-11-30 20:34:29 +01:00
2004-11-30 10:52:01 +01:00
$langs->load("suppliers");
$langs->load("orders");
2004-11-30 20:34:29 +01:00
$langs->load("companies");
llxHeader();
2003-08-04 14:42:49 +02:00
2005-08-11 21:04:42 +02:00
// S<>curit<69> acc<63>s client
$socidp='';
2003-08-04 14:42:49 +02:00
if ($user->societe_id > 0)
{
$action = '';
$socidp = $user->societe_id;
}
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="nom";
2003-08-04 14:42:49 +02:00
2005-01-08 23:20:19 +01:00
/*
* Mode Liste
*
*/
$sql = "SELECT s.idp, s.nom, s.ville,".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st";
$sql.= " WHERE s.fk_stcomm = st.id AND s.fournisseur=1";
if ($socidp) $sql .= " AND s.idp=$socidp";
2003-09-06 12:41:29 +02:00
if ($socname) {
$sql .= " AND lower(s.nom) like '%".strtolower($socname)."%'";
$sortfield = "lower(s.nom)";
$sortorder = "ASC";
}
2005-08-11 21:04:42 +02:00
if ($search_nom)
2004-11-30 20:34:29 +01:00
{
2005-08-11 21:04:42 +02:00
$sql .= " AND s.nom LIKE '%".$search_nom."%'";
2004-11-30 20:34:29 +01:00
}
2005-08-11 21:04:42 +02:00
if ($search_ville)
2004-11-30 20:34:29 +01:00
{
2005-08-11 21:04:42 +02:00
$sql .= " AND s.ville LIKE '%".$search_ville."%'";
2004-11-30 20:34:29 +01:00
}
2004-02-12 19:14:09 +01:00
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
2003-08-04 14:42:49 +02:00
2005-07-20 14:18:41 +02:00
$resql = $db->query($sql);
if ($resql)
2003-09-06 12:41:29 +02:00
{
2005-07-20 14:18:41 +02:00
$num = $db->num_rows($resql);
2003-09-06 12:41:29 +02:00
$i = 0;
print_barre_liste($langs->trans("ListOfSuppliers"), $page, "index.php", "", $sortfield, $sortorder, '', $num);
2004-11-30 20:34:29 +01:00
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
2005-07-01 21:59:21 +02:00
print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","","",'valign="middle"',$sortfield);
print_liste_field_titre($langs->trans("Town"),"index.php","s.ville","","",'valign="middle"',$sortfield);
print_liste_field_titre($langs->trans("DateCreation"),"index.php","datec","","",'align="center"',$sortfield);
print '<td class="liste_titre">&nbsp;</td>';
print "</tr>\n";
2004-11-30 20:34:29 +01:00
print '<tr class="liste_titre">';
print '<form action="index.php" method="GET">';
2005-08-11 21:04:42 +02:00
print '<td class="liste_titre"><input type="text" class="flat" name="search_nom" value="'.$search_nom.'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_ville" value="'.$search_ville.'"></td>';
print '<td class="liste_titre" colspan="2" align="right"><input class="liste_titre" type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'"></td>';
2004-11-30 20:34:29 +01:00
print '</form>';
print '</tr>';
2003-09-06 12:41:29 +02:00
$var=True;
2004-02-12 19:14:09 +01:00
while ($i < min($num,$conf->liste_limit))
2003-09-06 12:41:29 +02:00
{
2005-07-20 14:18:41 +02:00
$obj = $db->fetch_object($resql);
2003-08-04 14:42:49 +02:00
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowSupplier"),"company").'</a>';
2004-02-12 19:14:09 +01:00
print "&nbsp;<a href=\"fiche.php?socid=$obj->idp\">$obj->nom</a></td>\n";
2003-10-21 17:13:38 +02:00
print "<td>".$obj->ville."</td>\n";
print '<td align="center">'.dolibarr_print_date($obj->datec).'</td>';
2005-01-08 23:20:19 +01:00
print "<td>&nbsp;</td>\n";
2003-09-06 12:41:29 +02:00
print "</tr>\n";
2003-08-04 14:42:49 +02:00
$i++;
}
2003-09-06 12:41:29 +02:00
print "</table>";
2005-07-20 14:18:41 +02:00
$db->free($resql);
2003-09-06 12:41:29 +02:00
}
else
{
dolibarr_print_error($db);
2003-09-06 12:41:29 +02:00
}
2003-08-04 14:42:49 +02:00
$db->close();
2005-08-11 21:04:42 +02:00
llxFooter('$Date$ - $Revision$');
2003-08-04 14:42:49 +02:00
?>