26 if (!defined(
'NOTOKENRENEWAL')) {
27 define(
'NOTOKENRENEWAL', 1);
29 if (!defined(
'NOREQUIREMENU')) {
30 define(
'NOREQUIREMENU',
'1');
32 if (!defined(
'NOREQUIREHTML')) {
33 define(
'NOREQUIREHTML',
'1');
35 if (!defined(
'NOREQUIREAJAX')) {
36 define(
'NOREQUIREAJAX',
'1');
38 if (!defined(
'NOREQUIRESOC')) {
39 define(
'NOREQUIRESOC',
'1');
41 if (!defined(
'NOCSRFCHECK')) {
42 define(
'NOCSRFCHECK',
'1');
45 require
'../../main.inc.php';
46 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
56 if ($user->socid > 0) {
57 $socid = $user->socid;
79 $return_arr = array();
84 $socid =
GETPOST(
'socid',
'int');
87 $socid =
GETPOST(
'id_fourn',
'int');
90 $sql =
"SELECT s.rowid, s.nom";
91 if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
92 $sql .=
", s.client, s.fournisseur, s.code_client, s.code_fournisseur";
94 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
95 $sql .=
", s.address, s.zip, s.town";
96 $sql .=
", dictp.code as country_code";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
99 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
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').
")";
106 if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) {
107 $sql .=
"nom LIKE '".$db->escape($socid).
"%'";
108 $sql .=
" OR code_client LIKE '".$db->escape($socid).
"%'";
109 $sql .=
" OR code_fournisseur LIKE '".$db->escape($socid).
"%'";
111 $sql .=
"nom LIKE '%".$db->escape($socid).
"%'";
112 $sql .=
" OR code_client LIKE '%".$db->escape($socid).
"%'";
113 $sql .=
" OR code_fournisseur LIKE '%".$db->escape($socid).
"%'";
115 if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) {
116 $sql .=
" OR rowid = ".((int) $socid);
121 $sql .=
" ORDER BY nom ASC";
124 $resql = $db->query($sql);
126 while ($row = $db->fetch_array(
$resql)) {
128 if (! empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
129 if (($row[
'client']) && (!empty($row[
'code_client']))) {
130 $label = $row[
'code_client'].
' - ';
132 if (($row[
'fournisseur']) && (!empty($row[
'code_fournisseur']))) {
133 $label .= $row[
'code_fournisseur'].
' - ';
137 $label .= $row[
'nom'];
139 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
140 $label .= ($row[
'address'] ?
' - '.$row[
'address'] :
'').($row[
'zip'] ?
' - '.$row[
'zip'] :
'').($row[
'town'] ?
' '.$row[
'town'] :
'');
141 if (!empty($row[
'country_code'])) {
142 $label .=
', '.$langs->trans(
'Country'.$row[
'country_code']);
146 $label = preg_replace(
'/('.preg_quote($socid,
'/').
')/i',
'<strong>$1</strong>', $label, 1);
148 $row_array[
'label'] = $label;
149 $row_array[
'value'] = $row[
'nom'];
150 $row_array[
'key'] = $row[
'rowid'];
152 array_push($return_arr, $row_array);
155 echo json_encode($return_arr);
157 echo json_encode(array(
'nom'=>
'Error',
'label'=>
'Error',
'key'=>
'Error',
'value'=>
'Error'));
160 echo json_encode(array(
'nom'=>
'ErrorBadParameter',
'label'=>
'ErrorBadParameter',
'key'=>
'ErrorBadParameter',
'value'=>
'ErrorBadParameter'));
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype= 'text/html', $forcenocache=0)
Show HTTP header.
Class to manage third parties objects (customers, suppliers, prospects...)
restrictedArea($user, $features, $objectid=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.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.