Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
f2d26e54
Commit
f2d26e54
authored
14 years ago
by
Regis Houssin
Browse files
Options
Downloads
Patches
Plain Diff
Test: auto fill zip and town with jquery
parent
5e800451
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/core/class/html.formcompany.class.php
+4
-4
4 additions, 4 deletions
htdocs/core/class/html.formcompany.class.php
htdocs/societe/ajaxziptown.php
+115
-0
115 additions, 0 deletions
htdocs/societe/ajaxziptown.php
with
119 additions
and
4 deletions
htdocs/core/class/html.formcompany.class.php
+
4
−
4
View file @
f2d26e54
...
@@ -612,8 +612,8 @@ class FormCompany
...
@@ -612,8 +612,8 @@ class FormCompany
*/
*/
function
select_zipcode
(
$selected
=
''
,
$htmlname
=
'zipcode'
)
function
select_zipcode
(
$selected
=
''
,
$htmlname
=
'zipcode'
)
{
{
print
ajax_autocompleter
(
''
,
$htmlname
,
DOL_URL_ROOT
.
'/societe/ajaxziptown.php'
,
''
,
0
)
.
"
\n
"
;
print
ajax_autocompleter
(
''
,
$htmlname
,
DOL_URL_ROOT
.
'/societe/ajaxziptown.php'
)
.
"
\n
"
;
print
'<input id="'
.
$htmlname
.
'" type="text" name="'
.
$htmlname
.
'" size="6" value="'
.
$selected
.
'">'
.
"
\n
"
;
print
'<input id="
search_
'
.
$htmlname
.
'" type="text" name="'
.
$htmlname
.
'" size="6" value="'
.
$selected
.
'">'
.
"
\n
"
;
}
}
/**
/**
...
@@ -621,8 +621,8 @@ class FormCompany
...
@@ -621,8 +621,8 @@ class FormCompany
*/
*/
function
select_town
(
$selected
=
''
,
$htmlname
=
'town'
)
function
select_town
(
$selected
=
''
,
$htmlname
=
'town'
)
{
{
print
ajax_autocompleter
(
''
,
$htmlname
,
DOL_URL_ROOT
.
'/societe/ajaxziptown.php'
,
''
,
0
)
.
"
\n
"
;
print
ajax_autocompleter
(
''
,
$htmlname
,
DOL_URL_ROOT
.
'/societe/ajaxziptown.php'
)
.
"
\n
"
;
print
'<input id="'
.
$htmlname
.
'" type="text" name="'
.
$htmlname
.
'" value="'
.
$selected
.
'">'
.
"
\n
"
;
print
'<input id="
search_
'
.
$htmlname
.
'" type="text" name="'
.
$htmlname
.
'" value="'
.
$selected
.
'">'
.
"
\n
"
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
htdocs/societe/ajaxziptown.php
0 → 100644
+
115
−
0
View file @
f2d26e54
<?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/societe/ajaxziptown.php
* \brief File to return Ajax response on zipcode or town request
* \version $Id$
*/
if
(
!
defined
(
'NOTOKENRENEWAL'
))
define
(
'NOTOKENRENEWAL'
,
1
);
// Disables token renewal
if
(
!
defined
(
'NOREQUIREMENU'
))
define
(
'NOREQUIREMENU'
,
'1'
);
if
(
!
defined
(
'NOREQUIREHTML'
))
define
(
'NOREQUIREHTML'
,
'1'
);
if
(
!
defined
(
'NOREQUIREAJAX'
))
define
(
'NOREQUIREAJAX'
,
'1'
);
if
(
!
defined
(
'NOREQUIRESOC'
))
define
(
'NOREQUIRESOC'
,
'1'
);
if
(
!
defined
(
'NOCSRFCHECK'
))
define
(
'NOCSRFCHECK'
,
'1'
);
require
(
'../main.inc.php'
);
/*
* View
*/
// Ajout directives pour resoudre bug IE
//header('Cache-Control: Public, must-revalidate');
//header('Pragma: public');
//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
top_httphead
();
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
dol_syslog
(
join
(
','
,
$_GET
));
// Generation liste des societes
if
(
!
empty
(
$_GET
[
'zipcode'
])
||
!
empty
(
$_GET
[
'town'
]))
{
$return_arr
=
array
();
// Define filter on text typed
$zipcode
=
$_GET
[
'zipcode'
]
?
$_GET
[
'zipcode'
]
:
''
;
$town
=
$_GET
[
'town'
]
?
$_GET
[
'town'
]
:
''
;
$sql
=
"SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_country"
;
$sql
.
=
", p.code as country_code, p.libelle as country"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"c_ziptown as z"
;
$sql
.
=
", "
.
MAIN_DB_PREFIX
.
"c_pays as p"
;
$sql
.
=
" WHERE z.active = 1"
;
$sql
.
=
" AND p.active = 1"
;
$sql
.
=
" AND z.fk_country = p.rowid"
;
if
(
$zipcode
)
" AND z.zip LIKE '"
.
$db
->
escape
(
$zipcode
)
.
"%'"
;
if
(
$town
)
" AND z.town LIKE '%"
.
$db
->
escape
(
$town
)
.
"%'"
;
$sql
.
=
" ORDER BY z.fk_country, z.zip, z.town"
;
//dol_syslog("ajaxcompanies sql=".$sql);
$resql
=
$db
->
query
(
$sql
);
if
(
$resql
)
{
$num
=
$db
->
num_rows
(
$resql
);
if
(
!
$num
)
{
$sql
=
"SELECT DISTINCT s.cp as zip, s.ville as town, s.fk_departement as fk_county, s.fk_pays as fk_country"
;
$sql
.
=
", p.code as country_code, p.libelle as country"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
'societe as s'
;
$sql
.
=
" LEFT JOIN "
.
MAIN_DB_PREFIX
.
'c_pays as p ON fk_pays = p.rowid'
;
$sql
.
=
" WHERE"
;
if
(
$zipcode
)
$sql
.
=
" s.cp LIKE '"
.
$db
->
escape
(
$zipcode
)
.
"%'"
;
if
(
$town
)
$sql
.
=
" s.ville LIKE '%"
.
$db
->
escape
(
$town
)
.
"%'"
;
$sql
.
=
" ORDER BY s.fk_pays, s.cp, s.ville"
;
$sql
.
=
$db
->
plimit
(
50
);
// Avoid pb with bad criteria
//print $sql;
$resql
=
$db
->
query
(
$sql
);
}
if
(
$resql
)
{
while
(
$row
=
$db
->
fetch_array
(
$resql
))
{
$country
=
$row
[
'fk_country'
]
?
(
$langs
->
trans
(
'Country'
.
$row
[
'country_code'
])
!=
'Country'
.
$row
[
'country_code'
]
?
$langs
->
trans
(
'Country'
.
$row
[
'country_code'
])
:
$row
[
'country'
])
:
''
;
$row_array
[
'label'
]
=
$row
[
'zip'
]
.
' '
.
$row
[
'town'
]
.
' ('
.
$country
.
')'
;
$row_array
[
'zip'
]
=
$row
[
'zip'
];
$row_array
[
'town'
]
=
$row
[
'town'
];
$row_array
[
'fk_country'
]
=
$row
[
'fk_country'
];
array_push
(
$return_arr
,
$row_array
);
}
}
}
echo
json_encode
(
$return_arr
);
}
else
{
}
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment