dolibarr/htdocs/fourn/contact.php

133 lines
3.5 KiB
PHP
Raw Normal View History

<?php
2004-01-30 12:00:57 +01:00
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
2002-05-09 16:57:48 +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$
*
2002-05-09 16:57:48 +02:00
*/
2003-09-11 22:18:51 +02:00
require("./pre.inc.php");
2002-05-09 16:57:48 +02:00
$langs->load("companies");
2002-05-09 16:57:48 +02:00
llxHeader();
2003-05-13 16:27:40 +02:00
/*
* S<EFBFBD>curit<EFBFBD> acc<EFBFBD>s client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
2004-11-16 22:40:00 +01:00
$page=$_GET["page"];
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
2003-05-13 16:27:40 +02:00
if ($sortorder == "")
{
2002-05-09 16:57:48 +02:00
$sortorder="ASC";
}
2003-05-13 16:27:40 +02:00
if ($sortfield == "")
{
2002-05-09 16:57:48 +02:00
$sortfield="p.name";
}
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
/*
*
* Mode liste
*
*
*/
$sql = "SELECT s.idp, s.nom, st.libelle as stcomm, p.idp as cidp, p.name, p.firstname, p.email, p.phone ";
2004-01-30 12:00:57 +01:00
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."socpeople as p, ".MAIN_DB_PREFIX."c_stcomm as st";
2003-08-04 14:39:52 +02:00
$sql .= " WHERE s.fk_stcomm = st.id AND s.fournisseur = 1 AND s.idp = p.fk_soc";
2002-05-09 16:57:48 +02:00
if (strlen($stcomm)) {
$sql .= " AND s.fk_stcomm=$stcomm";
}
if (strlen($begin)) {
$sql .= " AND upper(p.name) like '$begin%'";
}
if ($contactname) {
$sql .= " AND lower(p.name) like '%".strtolower($contactname)."%'";
$sortfield = "lower(p.name)";
$sortorder = "ASC";
}
if ($socid) {
$sql .= " AND s.idp = $socid";
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows();
2004-07-30 12:13:11 +02:00
print_barre_liste("Liste des contacts fournisseurs",$page, "contact.php", "",$sortfield,$sortorder,"",$num);
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Lastname"),"contact.php","lower(p.name)", $begin);
print_liste_field_titre($langs->trans("Firstname"),"contact.php","lower(p.firstname)", $begin);
print_liste_field_titre($langs->trans("Company"),"contact.php","lower(s.nom)", $begin);
print '<td>'.$langs->trans("Email").'</td><td>'.$langs->trans("Phone").'</td>';
2004-02-13 16:05:16 +01:00
print "</tr>\n";
2002-05-09 16:57:48 +02:00
$var=True;
$i = 0;
2004-02-13 16:05:16 +01:00
while ($i < min($num,$limit))
{
$obj = $db->fetch_object( $i);
2002-05-09 16:57:48 +02:00
2004-02-13 16:05:16 +01:00
$var=!$var;
print "<tr $bc[$var]>";
2004-02-13 16:05:16 +01:00
print '<td width="13%">'.$obj->name.'</td>';
print '<td width="13%">'.$obj->firstname.'</td>';
print '<td><a href="contact.php?socid='.$obj->idp.'"><img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/filter.png" border="0"></a>&nbsp;';
print "<a href=\"fiche.php?socid=$obj->idp\">$obj->nom</a></td>\n";
print "<td>$obj->email&nbsp;</td>\n";
2004-02-13 16:05:16 +01:00
print '<td>'.$obj->phone.'</td>';
print "</tr>\n";
2004-02-13 16:05:16 +01:00
$i++;
}
print "</table>";
2002-05-09 16:57:48 +02:00
$db->free();
} else {
2004-07-30 12:13:11 +02:00
print_barre_liste("Liste des contacts $label",$page, "contact.php");
2004-02-13 16:05:16 +01:00
2002-05-09 16:57:48 +02:00
print $db->error();
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>