27if (!defined(
'NOTOKENRENEWAL')) {
28 define(
'NOTOKENRENEWAL', 1);
30if (!defined(
'NOREQUIREMENU')) {
31 define(
'NOREQUIREMENU',
'1');
33if (!defined(
'NOREQUIREHTML')) {
34 define(
'NOREQUIREHTML',
'1');
36if (!defined(
'NOREQUIREAJAX')) {
37 define(
'NOREQUIREAJAX',
'1');
39if (!defined(
'NOREQUIRESOC')) {
40 define(
'NOREQUIRESOC',
'1');
44require
'../../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
58if ($user->socid > 0) {
59 $socid = $user->socid;
61 accessforbidden(
'Not allowed to access thirdparty id '.
$id.
' with an external user on id '.$socid);
90 echo json_encode(array(
'nom' =>
'ErrorBadParameter',
'label' =>
'ErrorBadParameter',
'key' =>
'ErrorBadParameter',
'value' =>
'ErrorBadParameter'));
94$sql =
"SELECT s.rowid, s.nom, s.name_alias, s.code_client, s.code_fournisseur, s.address, s.zip, s.town, s.email, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6, s.client, s.fournisseur, s.datec, s.logo";
96 $sql .=
", dictp.code as country_code";
98$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
100 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as dictp ON dictp.rowid = s.fk_pays";
102$sql .=
" WHERE s.entity IN (".getEntity(
'societe').
")";
107 $sql .=
"s.nom LIKE '".$db->escape($db->escapeforlike($socid)).
"%'";
108 $sql .=
" OR s.name_alias LIKE '".$db->escape($db->escapeforlike($socid)).
"%'";
109 $sql .=
" OR s.code_client LIKE '".$db->escape($db->escapeforlike($socid)).
"%'";
110 $sql .=
" OR s.code_fournisseur LIKE '".$db->escape($db->escapeforlike($socid)).
"%'";
112 $sql .=
"s.nom LIKE '%".$db->escape($db->escapeforlike($socid)).
"%'";
113 $sql .=
" OR s.name_alias LIKE '%".$db->escape($db->escapeforlike($socid)).
"%'";
114 $sql .=
" OR s.code_client LIKE '%".$db->escape($db->escapeforlike($socid)).
"%'";
115 $sql .=
" OR s.code_fournisseur LIKE '%".$db->escape($db->escapeforlike($socid)).
"%'";
118 $sql .=
" OR s.rowid = ".((int) $socid);
123if ($user->socid > 0) {
124 $sql .=
" AND s.rowid = ".((int) $user->socid);
127$sql .=
" ORDER BY s.nom ASC";
130$resql = $db->query($sql);
132 while ($row = $db->fetch_array($resql)) {
135 if (($row[
'client']) && (!empty($row[
'code_client']))) {
136 $label = $row[
'code_client'].
' - ';
138 if (($row[
'fournisseur']) && (!empty($row[
'code_fournisseur']))) {
139 $label .= $row[
'code_fournisseur'].
' - ';
143 $label .= $row[
'nom'];
146 $label .= ($row[
'address'] ?
' - '.$row[
'address'] :
'').($row[
'zip'] ?
' - '.$row[
'zip'] :
'').($row[
'town'] ?
' '.$row[
'town'] :
'');
147 if (!empty($row[
'country_code'])) {
148 $label .=
', '.$langs->trans(
'Country'.$row[
'country_code']);
152 $label = preg_replace(
'/('.preg_quote($socid,
'/').
')/i',
'<strong>$1</strong>', $label, 1);
154 $row_array = array();
155 $row_array[
'label'] = $label;
157 $row_array[
'value'] = $row[
'nom'];
158 $row_array[
'key'] = $row[
'rowid'];
160 $row_array[
'name_alias'] = $row[
'name_alias'];
161 $row_array[
'client'] = $row[
'client'];
162 $row_array[
'fournisseur'] = $row[
'fournisseur'];
163 $row_array[
'code_client'] = $row[
'code_client'];
164 $row_array[
'code_fournisseur'] = $row[
'code_fournisseur'];
165 $row_array[
'address'] = $row[
'address'];
166 $row_array[
'zip'] = $row[
'zip'];
167 $row_array[
'town'] = $row[
'town'];
168 $row_array[
'email'] = $row[
'email'];
169 $row_array[
'siren'] = $row[
'siren'];
170 $row_array[
'siret'] = $row[
'siret'];
171 $row_array[
'ape'] = $row[
'ape'];
172 $row_array[
'idprof4'] = $row[
'idprof4'];
173 $row_array[
'idprof5'] = $row[
'idprof5'];
174 $row_array[
'idprof6'] = $row[
'idprof6'];
175 $row_array[
'datec'] = $row[
'datec'];
176 $row_array[
'logo'] = $row[
'logo'];
178 array_push($return_arr, $row_array);
181 echo json_encode($return_arr);
183 echo json_encode(array(
'nom' =>
'Error',
'label' =>
'Error',
'key' =>
'Error',
'value' =>
'Error'));
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage third parties objects (customers, suppliers, prospects...)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.