From a108a2fef8901caab39039bccf53d4ba9d41fb7d Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Sat, 5 Feb 2011 15:17:00 +0000
Subject: [PATCH] Fix: uniformize code

---
 htdocs/asterisk/cidlookup.php | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/htdocs/asterisk/cidlookup.php b/htdocs/asterisk/cidlookup.php
index 36a6b31805d..5156a3fd27d 100644
--- a/htdocs/asterisk/cidlookup.php
+++ b/htdocs/asterisk/cidlookup.php
@@ -41,10 +41,13 @@ if (empty($phone))
 	exit;
 }
 
-$sql = "select nom from llx_societe s ";
-$sql.= "left join llx_socpeople sp on sp.fk_soc=s.rowid";
-$sql.= " where s.tel='".addslashes($phone)."' or sp.phone='".addslashes($phone)."' or sp.phone_perso='".addslashes($phone)."' or sp.phone_mobile='".addslashes($phone)."'";
-//$sql.= " AND entity=".$conf->entity;
+$sql = "SELECT nom FROM ".MAIN_DB_PREFIX."societe as s";
+$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid";
+$sql.= " WHERE s.entity=".$conf->entity;
+$sql.= " AND (s.tel='".addslashes($phone)."'";
+$sql.= " OR sp.phone='".addslashes($phone)."'";
+$sql.= " OR sp.phone_perso='".addslashes($phone)."'";
+$sql.= " OR sp.phone_mobile='".addslashes($phone)."')";
 $sql.= $db->plimit(1);
 
 dol_syslog('cidlookup search information with phone '.$phone, LOG_DEBUG);
-- 
GitLab