28if (!defined(
'NOTOKENRENEWAL')) {
29 define(
'NOTOKENRENEWAL', 1);
31if (!defined(
'NOREQUIREMENU')) {
32 define(
'NOREQUIREMENU',
'1');
34if (!defined(
'NOREQUIREHTML')) {
35 define(
'NOREQUIREHTML',
'1');
37if (!defined(
'NOREQUIREAJAX')) {
38 define(
'NOREQUIREAJAX',
'1');
40if (!defined(
'NOREQUIRESOC')) {
41 define(
'NOREQUIRESOC',
'1');
45require
'../../main.inc.php';
46require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
67if ($user->socid > 0) {
68 $socid = $user->socid;
70 accessforbidden(
'Not allowed to access thirdparty id '.
$id.
' with an external user on id '.$socid);
99 echo json_encode(array(
'nom' =>
'ErrorBadParameter',
'label' =>
'ErrorBadParameter',
'key' =>
'ErrorBadParameter',
'value' =>
'ErrorBadParameter'));
103$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";
105 $sql .=
", dictp.code as country_code";
107$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
109 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as dictp ON dictp.rowid = s.fk_pays";
111$sql .=
" WHERE s.entity IN (".getEntity(
'societe').
")";
116 $sql .=
"s.nom LIKE '".$db->escape($db->escapeforlike($socid)).
"%'";
117 $sql .=
" OR s.name_alias LIKE '".$db->escape($db->escapeforlike($socid)).
"%'";
118 $sql .=
" OR s.code_client LIKE '".$db->escape($db->escapeforlike($socid)).
"%'";
119 $sql .=
" OR s.code_fournisseur LIKE '".$db->escape($db->escapeforlike($socid)).
"%'";
121 $sql .=
"s.nom LIKE '%".$db->escape($db->escapeforlike($socid)).
"%'";
122 $sql .=
" OR s.name_alias LIKE '%".$db->escape($db->escapeforlike($socid)).
"%'";
123 $sql .=
" OR s.code_client LIKE '%".$db->escape($db->escapeforlike($socid)).
"%'";
124 $sql .=
" OR s.code_fournisseur LIKE '%".$db->escape($db->escapeforlike($socid)).
"%'";
127 $sql .=
" OR s.rowid = ".((int) $socid);
132if ($user->socid > 0) {
133 $sql .=
" AND s.rowid = ".((int) $user->socid);
136$sql .=
" ORDER BY s.nom ASC";
139$resql = $db->query($sql);
141 while ($row = $db->fetch_array($resql)) {
144 if (($row[
'client']) && (!empty($row[
'code_client']))) {
145 $label = $row[
'code_client'].
' - ';
147 if (($row[
'fournisseur']) && (!empty($row[
'code_fournisseur']))) {
148 $label .= $row[
'code_fournisseur'].
' - ';
152 $label .= $row[
'nom'];
155 $label .= ($row[
'address'] ?
' - '.$row[
'address'] :
'').($row[
'zip'] ?
' - '.$row[
'zip'] :
'').($row[
'town'] ?
' '.$row[
'town'] :
'');
156 if (!empty($row[
'country_code'])) {
157 $label .=
', '.$langs->trans(
'Country'.$row[
'country_code']);
161 $label = preg_replace(
'/('.preg_quote($socid,
'/').
')/i',
'<strong>$1</strong>', $label, 1);
163 $row_array = array();
164 $row_array[
'label'] = $label;
166 $row_array[
'value'] = $row[
'nom'];
167 $row_array[
'key'] = $row[
'rowid'];
169 $row_array[
'name_alias'] = $row[
'name_alias'];
170 $row_array[
'client'] = $row[
'client'];
171 $row_array[
'fournisseur'] = $row[
'fournisseur'];
172 $row_array[
'code_client'] = $row[
'code_client'];
173 $row_array[
'code_fournisseur'] = $row[
'code_fournisseur'];
174 $row_array[
'address'] = $row[
'address'];
175 $row_array[
'zip'] = $row[
'zip'];
176 $row_array[
'town'] = $row[
'town'];
177 $row_array[
'email'] = $row[
'email'];
178 $row_array[
'siren'] = $row[
'siren'];
179 $row_array[
'siret'] = $row[
'siret'];
180 $row_array[
'ape'] = $row[
'ape'];
181 $row_array[
'idprof4'] = $row[
'idprof4'];
182 $row_array[
'idprof5'] = $row[
'idprof5'];
183 $row_array[
'idprof6'] = $row[
'idprof6'];
184 $row_array[
'datec'] = $row[
'datec'];
185 $row_array[
'logo'] = $row[
'logo'];
187 array_push($return_arr, $row_array);
190 echo json_encode($return_arr);
192 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.