Files
dolibarr/htdocs/telephonie/client/index.php
Rodolphe Quiedeville 8d361e659a Bugfix
2005-09-02 12:23:50 +00:00

162 lines
3.9 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");
if (!$user->rights->telephonie->lire)
accessforbidden();
llxHeader('','Telephonie - Clients');
/*
* 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 ";
$sql .= " AND l.fk_commercial_suiv = ".$user->id;
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$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($resql);
print "<tr $bc[$var]>";
print '<td><a href="my.php">Mes clients suivis</a></td>';
print "<td>".$num."</td>\n";
print "</tr>\n";
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '<br />';
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 .= ",".MAIN_DB_PREFIX."societe_perms as sp";
$sql .= " WHERE l.fk_client_comm = s.idp ";
$sql .= " AND s.idp = sp.fk_soc";
$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1";
$sql .= " GROUP BY s.idp";
$sql .= " ORDER BY s.datec DESC LIMIT 15";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>'.min(15,$num).' derniers clients</td>';
print '<td width="25%" align="center">Nb Lignes';
print "</td></tr>\n";
$var=True;
$ligne = new LigneTel($db);
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$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($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
print '</td></tr>';
print '</table>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>