Files
dolibarr/htdocs/telephonie/client/index.php
2005-02-21 10:24:12 +00:00

209 lines
4.6 KiB
PHP

<?PHP
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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$
*
*/
require("./pre.inc.php");
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
if (!$user->rights->telephonie->lire)
accessforbidden();
llxHeader('','Telephonie - Ligne');
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socidp = $user->societe_id;
}
/*
* Mode Liste
*
*
*
*/
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="30%" valign="top">';
print '<form method="GET" action="'.DOL_URL_ROOT.'/telephonie/client/liste.php">';
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Recherche client</td>';
print "</tr>\n";
print "<tr $bc[1]>";
print '<td>Nom <input name="search_client" size="12"></td></tr>';
print '</table>';
print '<br />';
$sql = "SELECT distinct s.idp ";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.idp = l.fk_client_comm ";
if ($db->query($sql))
{
$num = $db->num_rows();
$i = 0;
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Clients</td><td valign="center">Nb</td>';
print "</tr>\n";
$var=True;
$row = $db->fetch_row(0);
print "<tr $bc[$var]>";
print "<td>Nombre de clients</td>\n";
print "<td>".$num."</td>\n";
print "</tr>\n";
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '<br />';
$sql = "SELECT distinct s.idp ";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.idp = l.fk_client_comm ";
$sql .= " AND l.fk_commercial_suiv = ".$user->id;
if ($db->query($sql))
{
$num = $db->num_rows();
$i = 0;
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Mes clients suivis</td><td valign="center">Nb</td>';
print "</tr>\n";
$var=True;
$row = $db->fetch_row(0);
print "<tr $bc[$var]>";
print '<td><a href="my.php">Nombre de clients</a></td>';
print "<td>".$num."</td>\n";
print "</tr>\n";
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '<br />';
print '</td>';
print '</td><td valign="top" width="70%" rowspan="3">';
/*
* Liste
*
*/
$sql = "SELECT s.idp as socidp, s.nom, count(l.ligne) as ligne";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
$sql .= " WHERE l.fk_client_comm = s.idp ";
if ($_GET["search_client"])
{
$sel = urldecode($_GET["search_client"]);
$sql .= " AND s.nom LIKE '%".$sel."%'";
}
$sql .= " GROUP BY s.idp";
$sql .= " ORDER BY s.datec DESC LIMIT 15";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0;
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>15 derniers clients</td>';
print '<td width="25%" align="center">Nb Lignes';
print '</td>';
print "</tr>\n";
$var=True;
$ligne = new LigneTel($db);
while ($i < $num)
{
$obj = $db->fetch_object($i);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socidp.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socidp.'">'.stripslashes($obj->nom).'</a></td>';
print '<td align="center">'.$obj->ligne."</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '</td></tr>';
print '</table>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>