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');
43 require
'../../main.inc.php';
44 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
54 if ($user->socid > 0) {
55 $socid = $user->socid;
77 $return_arr = array();
82 $socid =
GETPOST(
'socid',
'int');
85 $socid =
GETPOST(
'id_fourn',
'int');
88 $sql =
"SELECT s.rowid, s.nom";
89 if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
90 $sql .=
", s.client, s.fournisseur, s.code_client, s.code_fournisseur";
92 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
93 $sql .=
", s.address, s.zip, s.town";
94 $sql .=
", dictp.code as country_code";
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
97 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
98 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as dictp ON dictp.rowid = s.fk_pays";
100 $sql .=
" WHERE s.entity IN (".getEntity(
'societe').
")";
104 if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) {
105 $sql .=
"nom LIKE '".$db->escape($socid).
"%'";
106 $sql .=
" OR code_client LIKE '".$db->escape($socid).
"%'";
107 $sql .=
" OR code_fournisseur LIKE '".$db->escape($socid).
"%'";
109 $sql .=
"nom LIKE '%".$db->escape($socid).
"%'";
110 $sql .=
" OR code_client LIKE '%".$db->escape($socid).
"%'";
111 $sql .=
" OR code_fournisseur LIKE '%".$db->escape($socid).
"%'";
113 if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) {
114 $sql .=
" OR rowid = ".((int) $socid);
119 $sql .=
" ORDER BY nom ASC";
122 $resql = $db->query($sql);
124 while ($row = $db->fetch_array(
$resql)) {
126 if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
127 if (($row[
'client']) && (!empty($row[
'code_client']))) {
128 $label = $row[
'code_client'].
' - ';
130 if (($row[
'fournisseur']) && (!empty($row[
'code_fournisseur']))) {
131 $label .= $row[
'code_fournisseur'].
' - ';
135 $label .= $row[
'nom'];
137 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
138 $label .= ($row[
'address'] ?
' - '.$row[
'address'] :
'').($row[
'zip'] ?
' - '.$row[
'zip'] :
'').($row[
'town'] ?
' '.$row[
'town'] :
'');
139 if (!empty($row[
'country_code'])) {
140 $label .=
', '.$langs->trans(
'Country'.$row[
'country_code']);
144 $label = preg_replace(
'/('.preg_quote($socid,
'/').
')/i',
'<strong>$1</strong>', $label, 1);
146 $row_array[
'label'] = $label;
147 $row_array[
'value'] = $row[
'nom'];
148 $row_array[
'key'] = $row[
'rowid'];
150 array_push($return_arr, $row_array);
153 echo json_encode($return_arr);
155 echo json_encode(array(
'nom'=>
'Error',
'label'=>
'Error',
'key'=>
'Error',
'value'=>
'Error'));
158 echo json_encode(array(
'nom'=>
'ErrorBadParameter',
'label'=>
'ErrorBadParameter',
'key'=>
'ErrorBadParameter',
'value'=>
'ErrorBadParameter'));
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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.
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.