From e2233fb0f0300c9996fa4ef4ceed2bd22c35710a Mon Sep 17 00:00:00 2001
From: Rodolphe Quiedeville <rodolphe@quiedeville.org>
Date: Wed, 7 Sep 2005 08:22:36 +0000
Subject: [PATCH] Modif permissions

---
 htdocs/telephonie/contrat/services.php |  6 ++-
 htdocs/telephonie/ligne/factures.php   | 66 ++++++++++++++++----------
 2 files changed, 46 insertions(+), 26 deletions(-)

diff --git a/htdocs/telephonie/contrat/services.php b/htdocs/telephonie/contrat/services.php
index dcf26fbfd52..dbf11e80a8c 100644
--- a/htdocs/telephonie/contrat/services.php
+++ b/htdocs/telephonie/contrat/services.php
@@ -199,7 +199,8 @@ if ($_GET["id"])
 		      print '<tr class="liste_titre"><td>Service</td>';
 		      print '<td align="right">Montant Factur�</td>';
 		      print '<td align="right">Montant du service</td>';
-		      print "<td>&nbsp;</td>\n";
+		      if ($user->rights->telephonie->ligne->creer)		
+			print "<td>&nbsp;</td>\n";
 		      print '<td align="center">Ajout� par</td>';
 		      print '<td align="center">Ajout� le</td></tr>';
 		      
@@ -218,9 +219,12 @@ if ($_GET["id"])
 			  print '<td align="right">'.price($obj->montant_fac)." euros HT</td>\n";
 			  print '<td align="right">'.price($obj->montant)." euros HT</td>\n";
 
+      if ($user->rights->telephonie->ligne->creer)
+	{
 			  print '<td align="center"><a href="services.php?id='.$contrat->id.'&amp;action=rmservice&amp;service_id='.$obj->serid.'">';
 			  print img_delete();
 			  print "</a></td>";
+	}
 			  print '<td align="center">'.$obj->firstname.' '.$obj->name.'</td>';
 			  print '<td align="center">'.strftime("%d/%m/%y",$obj->date_creat).'</td>';
 			  print "</tr>\n";
diff --git a/htdocs/telephonie/ligne/factures.php b/htdocs/telephonie/ligne/factures.php
index fcab1723e5e..933a51dde04 100644
--- a/htdocs/telephonie/ligne/factures.php
+++ b/htdocs/telephonie/ligne/factures.php
@@ -42,8 +42,21 @@ if ($_GET["id"] or $_GET["numero"])
 	  $result = $ligne->fetch($_GET["numero"]);
 	}
     }
+
+
+  if ($result == 1)
+    {
+      $client_comm = new Societe($db);
+      $client_comm->fetch($ligne->client_comm_id, $user);
+    }
+  
+  if (!$client_comm->perm_read)
+    {
+      print "Lecture non authoris�e";
+    }
+
   
-  if ( $result )
+  if ($result == 1 && $client_comm->perm_read)  
     { 
 	  
       $h=0;
@@ -56,9 +69,11 @@ if ($_GET["id"] or $_GET["numero"])
       $hselected = $h;
       $h++;
 	  
+      /*
       $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/facturesdet.php?id=".$ligne->id;
       $head[$h][1] = $langs->trans('Factures d�taill�es');
       $h++;
+      */
 
       $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/infoc.php?id=".$ligne->id;
       $head[$h][1] = $langs->trans('Infos');
@@ -161,33 +176,34 @@ if ($_GET["id"] or $_GET["numero"])
       print '<tr><td>Facture</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/telephonie/client/facture.php?facid='.$fac->id.'">'.$fac->ref.'</a></td></tr>';
 
       print "</table>\n";
-    }
-  /*
-   *
-   *
-   *
-   */
-
-  $file = DOL_DATA_ROOT."/facture/".$fac->ref."/".$fac->ref.".pdf";
-  $file_img = DOL_DATA_ROOT."/facture/".$fac->ref."/".$fac->ref.".pdf.png";
 
-  if (file_exists($file_img))
-    {
-      print '<br><img src="../showfacture.php?facref='.$fac->ref.'"></img>';
-    }
-  else
-    {
-      if (file_exists("/usr/bin/convert"))
+      /*
+       *
+       *
+       *
+       */
+      
+      $file = DOL_DATA_ROOT."/facture/".$fac->ref."/".$fac->ref.".pdf";
+      $file_img = DOL_DATA_ROOT."/facture/".$fac->ref."/".$fac->ref.".pdf.png";
+      
+      if (file_exists($file_img))
 	{
-	  exec("/usr/bin/convert $file $file_img");
-	
-	  if (file_exists($file_img))
-	    {
-	      print '<br><img src="../showfacture.php?facref='.$fac->ref.'"></img>';
-	    }      
-	  else
+	  print '<br><img src="../showfacture.php?uid='.$user->id.'&amp;facref='.$fac->id.'"></img>';
+	}
+      else
+	{
+	  if (file_exists("/usr/bin/convert"))
 	    {
-	      print "Erreur ";
+	      exec("/usr/bin/convert $file $file_img");
+	      
+	      if (file_exists($file_img))
+		{
+		  print '<br><img src="../showfacture.php?uid='.$user->id.'&amp;facref='.$fac->id.'"></img>';
+		}      
+	      else
+		{
+		  print "Erreur ";
+		}
 	    }
 	}
     }
-- 
GitLab