25if (!defined(
'NOTOKENRENEWAL')) {
26 define(
'NOTOKENRENEWAL', 1);
28if (!defined(
'NOREQUIREMENU')) {
29 define(
'NOREQUIREMENU',
'1');
31if (!defined(
'NOREQUIREHTML')) {
32 define(
'NOREQUIREHTML',
'1');
34if (!defined(
'NOREQUIREAJAX')) {
35 define(
'NOREQUIREAJAX',
'1');
37if (!defined(
'NOREQUIRESOC')) {
38 define(
'NOREQUIRESOC',
'1');
42require
'../../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
48 $result =
restrictedArea($user,
'societe', 0,
'&societe',
'',
'fk_soc',
'rowid', 0);
70 $return_arr = array();
78 $sql =
"SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country";
79 $sql .=
", c.rowid as fk_country, c.code as country_code, c.label as country";
80 $sql .=
", d.rowid as fk_county, d.code_departement as county_code, d.nom as county";
81 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ziptown as z";
82 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as d ON z.fk_county = d.rowid";
83 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_regions as r ON d.fk_region = r.code_region,";
84 $sql .=
" ".MAIN_DB_PREFIX.
"c_country as c";
85 $sql .=
" WHERE z.fk_pays = c.rowid";
86 $sql .=
" AND z.active = 1 AND c.active = 1";
88 $sql .=
" AND z.zip LIKE '".$db->escape($db->escapeforlike($zipcode)).
"%'";
91 $sql .=
" AND z.town LIKE '%".$db->escape($db->escapeforlike($town)).
"%'";
93 $sql .=
" ORDER BY z.zip, z.town";
94 $sql .= $db->plimit(100);
96 $sql =
"SELECT DISTINCT s.zip, s.town, s.fk_departement as fk_county, s.fk_pays as fk_country";
97 $sql .=
", c.code as country_code, c.label as country";
98 $sql .=
", d.code_departement as county_code , d.nom as county";
99 $sql .=
" FROM ".MAIN_DB_PREFIX.
'societe as s';
100 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as d ON s.fk_departement = d.rowid";
101 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
'c_country as c ON s.fk_pays = c.rowid';
104 $sql .=
" s.zip LIKE '".$db->escape($db->escapeforlike($zipcode)).
"%'";
107 $sql .=
" s.town LIKE '%".$db->escape($db->escapeforlike($town)).
"%'";
109 $sql .=
" ORDER BY s.fk_pays, s.zip, s.town";
110 $sql .= $db->plimit(100);
114 $resql = $db->query($sql);
117 while ($row = $db->fetch_array($resql)) {
118 $country = $row[
'fk_country'] ? ($langs->transnoentitiesnoconv(
'Country'.$row[
'country_code']) !=
'Country'.$row[
'country_code'] ? $langs->transnoentitiesnoconv(
'Country'.$row[
'country_code']) : $row[
'country']) :
'';
119 $county = $row[
'fk_county'] ? ($langs->transnoentitiesnoconv($row[
'county_code']) != $row[
'county_code'] ? $langs->transnoentitiesnoconv($row[
'county_code']) : ($row[
'county'] !=
'-' ? $row[
'county'] :
'')) :
'';
121 $row_array[
'label'] = $row[
'zip'].
' '.$row[
'town'];
122 $row_array[
'label'] .= ($county || $country) ?
' (' :
'';
123 $row_array[
'label'] .= $county;
124 $row_array[
'label'] .= ($county && $country ?
' - ' :
'');
125 $row_array[
'label'] .= $country;
126 $row_array[
'label'] .= ($county || $country) ?
')' :
'';
128 $row_array[
'value'] = $row[
'zip'];
129 $row_array[
'town'] = $row[
'town'];
132 $row_array[
'value'] = $row[
'town'];
133 $row_array[
'zipcode'] = $row[
'zip'];
135 $row_array[
'selectcountry_id'] = $row[
'fk_country'];
136 $row_array[
'state_id'] = $row[
'fk_county'];
139 $row_array[
'states'] = $formcompany->select_state(
'', $row[
'fk_country'],
'');
141 array_push($return_arr, $row_array);
145 echo json_encode($return_arr);
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 dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.