Ajout log des consultations

This commit is contained in:
Rodolphe Quiedeville 2005-11-23 10:24:30 +00:00
parent afc48ce132
commit e4c0136056
3 changed files with 65 additions and 9 deletions

View File

@ -398,6 +398,7 @@ elseif ($_GET["action"] == 'create_line' && $_GET["client_comm"] > 0 && $user->r
}
else
{
/* Consultation */
if ($_GET["id"])
{
if ($_GET["action"] <> 're-edit')
@ -412,7 +413,7 @@ else
if ($result == 1)
{
$client_comm = new Societe($db);
$client_comm = new TelephonieClient($db);
$client_comm->fetch($contrat->client_comm_id, $user);
}
@ -423,6 +424,9 @@ else
if ( $result && $client_comm->perm_read)
{
$contrat->log_consult($user,'r');
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{
@ -459,8 +463,8 @@ else
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
$client_comm = new Societe($db);
$client_comm->fetch($contrat->client_comm_id);
//$client_comm = new Societe($db);
//$client_comm->fetch($contrat->client_comm_id);
print '<tr><td width="20%">Référence</td><td>'.$contrat->ref.'</td>';
print '<td>Facturé : '.$contrat->facturable.'</td><td align="right">';
@ -523,12 +527,9 @@ else
print '<tr><td width="20%">Commercial Suivi</td>';
print '<td colspan="3">'.$commercial_suiv->fullname.'</td></tr>';
/* Prise d'ordre */
print '<tr><td width="20%">Prise d\'ordre mensuelle</td>';
$po = $contrat->priseordre_totale();
print '<td colspan="3">'.$po.' euros HT</td></tr>';
/*
@ -538,7 +539,6 @@ else
print '</td></tr>';
*/
/* Contacts */
print '<tr><td valign="top" width="20%">Contact facture</td>';
print '<td valign="top" colspan="3">';

View File

@ -59,13 +59,59 @@ print '</table></form>';
print '<br />';
/* Consultations */
$sql = "SELECT s.idp as socidp, s.nom, max(sc.datec) as dam, c.ref, c.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ",".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= ",".MAIN_DB_PREFIX."telephonie_contrat_consult as sc";
$sql .= " WHERE s.idp = c.fk_soc";
$sql .= " AND c.rowid = sc.fk_contrat";
$sql .= " AND sc.fk_user = ".$user->id;
$sql .= " GROUP BY c.rowid";
$sql .= " ORDER BY dam DESC LIMIT 10";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td colspan="2">'.min(10,$num).' dernières fiche contrat consultées</td></tr>';
$var=True;
while ($obj = $db->fetch_object($resql))
{
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socidp.'">';
print img_file();
print '</a>&nbsp;';
$nom = $obj->nom;
if (strlen($obj->nom) > 33)
$nom = substr($obj->nom,0,30)."...";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socidp.'">'.stripslashes($nom).'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/contrat/fiche.php?id='.$obj->rowid.'">'.$obj->ref.'</a></td>';
print "</tr>\n";
$var=!$var;
}
print "</table>";
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
/* ===== */
print '<br />';
$sql = "SELECT distinct statut, count(*) as cc";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat as l";
$sql .= ",".MAIN_DB_PREFIX."societe_perms as sp";
$sql .= " WHERE l.fk_client_comm = sp.fk_soc";
$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1";
$sql .= " GROUP BY statut";
if ($db->query($sql))

View File

@ -594,6 +594,16 @@ class TelephonieContrat {
dolibarr_syslog("Telephonie::Contrat Error". $sql);
}
}
/*
* Log des consultations
*
*/
function log_consult($user,$mode)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_contrat_consult (fk_contrat,fk_user,action)";
$sql .= " VALUES (".$this->id.",".$user->id.",'".$mode."');";
$this->db->query($sql);
}
}
?>