From e4c0136056580db76c15de8f56b9f8897e03a367 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 23 Nov 2005 10:24:30 +0000 Subject: [PATCH] Ajout log des consultations --- htdocs/telephonie/contrat/fiche.php | 14 +++--- htdocs/telephonie/contrat/index.php | 50 ++++++++++++++++++- .../telephonie/telephonie.contrat.class.php | 10 ++++ 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/htdocs/telephonie/contrat/fiche.php b/htdocs/telephonie/contrat/fiche.php index f2e864a65d0..24605955626 100644 --- a/htdocs/telephonie/contrat/fiche.php +++ b/htdocs/telephonie/contrat/fiche.php @@ -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 ''; - $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 ''; print ''; print ''; - /* Prise d'ordre */ print ''; - $po = $contrat->priseordre_totale(); - print ''; /* @@ -538,7 +539,6 @@ else print ''; */ - /* Contacts */ print ''; print '
Référence'.$contrat->ref.'Facturé : '.$contrat->facturable.''; @@ -523,12 +527,9 @@ else print '
Commercial Suivi'.$commercial_suiv->fullname.'
Prise d\'ordre mensuelle'.$po.' euros HT
Contact facture'; diff --git a/htdocs/telephonie/contrat/index.php b/htdocs/telephonie/contrat/index.php index 2647d8f61fe..e6b03801b15 100644 --- a/htdocs/telephonie/contrat/index.php +++ b/htdocs/telephonie/contrat/index.php @@ -59,13 +59,59 @@ print '
'; print '
'; +/* 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 ''; + print ''; + $var=True; + + while ($obj = $db->fetch_object($resql)) + { + print "'; + + print ''; + + print "\n"; + $var=!$var; + } + print "
'.min(10,$num).' dernières fiche contrat consultées
"; + print ''; + print img_file(); + print ' '; + $nom = $obj->nom; + if (strlen($obj->nom) > 33) + $nom = substr($obj->nom,0,30)."..."; + + print ''.stripslashes($nom).''.$obj->ref.'
"; + $db->free($resql); +} +else +{ + print $db->error() . ' ' . $sql; +} + +/* ===== */ +print '
'; + $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)) diff --git a/htdocs/telephonie/telephonie.contrat.class.php b/htdocs/telephonie/telephonie.contrat.class.php index 648b0ccc8f9..248c78636d0 100644 --- a/htdocs/telephonie/telephonie.contrat.class.php +++ b/htdocs/telephonie/telephonie.contrat.class.php @@ -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); + } } ?>