Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Extensions
UK Postcodes
Commits
6c8737ee
Commit
6c8737ee
authored
Jan 30, 2015
by
parvez
Browse files
Merge pull request
#1
from rajeshrhino/master
Make the extension backward compatible with CiviCRM 4.4.x
parents
9c75800b
a88252b8
Changes
7
Hide whitespace changes
Inline
Side-by-side
CRM/Civicrmpostcodelookup/Page/Afd.php
View file @
6c8737ee
...
...
@@ -63,7 +63,14 @@ class CRM_Civicrmpostcodelookup_Page_Afd extends CRM_Core_Page {
##Close the XML source##
fclose
(
$filetoparse
);
echo
json_encode
(
$addresslist
);
$config
=
CRM_Core_Config
::
singleton
();
if
(
$config
->
civiVersion
<
4.5
)
{
foreach
(
$addresslist
as
$key
=>
$val
)
{
echo
"
{
$val
[
'label'
]
}
|
{
$val
[
'id'
]
}
\n
"
;
}
}
else
{
echo
json_encode
(
$addresslist
);
}
exit
;
}
...
...
CRM/Civicrmpostcodelookup/Page/Civipostcode.php
View file @
6c8737ee
...
...
@@ -65,7 +65,14 @@ class CRM_Civicrmpostcodelookup_Page_Civipostcode extends CRM_Core_Page {
##Close the JSON source##
fclose
(
$filetoparse
);
echo
json_encode
(
$addresslist
);
$config
=
CRM_Core_Config
::
singleton
();
if
(
$config
->
civiVersion
<
4.5
)
{
foreach
(
$addresslist
as
$key
=>
$val
)
{
echo
"
{
$val
[
'label'
]
}
|
{
$val
[
'id'
]
}
\n
"
;
}
}
else
{
echo
json_encode
(
$addresslist
);
}
exit
;
}
...
...
@@ -94,7 +101,7 @@ class CRM_Civicrmpostcodelookup_Page_Civipostcode extends CRM_Core_Page {
if
(
empty
(
$addressList
))
{
$addressRow
[
"id"
]
=
''
;
$addressRow
[
"value"
]
=
''
;
$addressRow
[
"label"
]
=
'
Error:
Postcode Not Found'
;
$addressRow
[
"label"
]
=
'Postcode Not Found'
;
array_push
(
$addressList
,
$addressRow
);
}
...
...
CRM/Civicrmpostcodelookup/Page/Experian.php
View file @
6c8737ee
...
...
@@ -66,7 +66,15 @@ class CRM_PostcodeLookup_Page_Ajax extends CRM_Core_Page {
$response
[
'address'
]
=
$address
;
}
echo
json_encode
(
$response
);
$config
=
CRM_Core_Config
::
singleton
();
if
(
$config
->
civiVersion
<
4.5
)
{
foreach
(
$response
as
$key
=>
$val
)
{
echo
"
{
$val
[
'label'
]
}
|
{
$val
[
'id'
]
}
\n
"
;
}
}
else
{
echo
json_encode
(
$response
);
}
exit
;
}
...
...
CRM/Civicrmpostcodelookup/Page/PostcodeAnywhere.php
View file @
6c8737ee
...
...
@@ -53,7 +53,14 @@ class CRM_Civicrmpostcodelookup_Page_PostcodeAnywhere extends CRM_Core_Page {
$addresslist
=
self
::
getAddressList
(
$simpleXMLData
,
$postcode
);
}
echo
json_encode
(
$addresslist
);
$config
=
CRM_Core_Config
::
singleton
();
if
(
$config
->
civiVersion
<
4.5
)
{
foreach
(
$addresslist
as
$key
=>
$val
)
{
echo
"
{
$val
[
'label'
]
}
|
{
$val
[
'id'
]
}
\n
"
;
}
}
else
{
echo
json_encode
(
$addresslist
);
}
exit
;
}
...
...
info.xml
View file @
6c8737ee
...
...
@@ -5,19 +5,20 @@
<description>
Extension to enable postcode lookup feature in CiviCRM using AFD, Civipostcode, Experian or PostcodeAnywhere.
</description>
<license>
AGPL-3.0
</license>
<maintainer>
<author>
Parvez
</author>
<author>
Parvez
Saleh
</author>
<email>
parvez@vedaconsulting.co.uk
</email>
</maintainer>
<urls>
<url
desc=
"Main Extension Page"
>
http://
www.vedaconsulting.co.uk
</url>
<url
desc=
"Documentation"
>
http://
www.
vedaconsulting.co.
uk
</url>
<url
desc=
"Support"
>
http://
www.
vedaconsulting.co.
uk
</url>
<url
desc=
"Main Extension Page"
>
http
s
://
civicrm.org/extensions/postcode-lookup-civicrm
</url>
<url
desc=
"Documentation"
>
http
s
://
github.com/
veda
-
consulting
/uk
.co.
vedaconsulting.module.civicrmpostcodelookup/blob/master/README.md
</url>
<url
desc=
"Support"
>
http
s
://
github.com/
veda
-
consulting
/uk
.co.
vedaconsulting.module.civicrmpostcodelookup
</url>
<url
desc=
"Licensing"
>
http://www.gnu.org/licenses/agpl-3.0.html
</url>
</urls>
<releaseDate>
2015-01-05
</releaseDate>
<version>
1.0.alpha
1
</version>
<version>
1.0.alpha
2
</version>
<develStage>
alpha
</develStage>
<compatibility>
<ver>
4.4
</ver>
<ver>
4.5
</ver>
</compatibility>
<comments>
This module is under active development.
</comments>
...
...
templates/CRM/Civicrmpostcodelookup/Form/Postcodelookup.tpl
View file @
6c8737ee
...
...
@@ -32,8 +32,35 @@ cj(document).ready(function(){
}
cj
(
function
()
{
var
sourceUrl
=
CRM
.
url
(
'
civicrm/
{/
literal
}{
$config
->
CiviPostCodeLookupProvider
}{
literal
}
/ajax/search
'
,
{
"json"
:
1
}
);
{/
literal
}{
if
$config
->
civiVersion
<
4.5
}{
literal
}
cj
(
postcodeElement
).
autocomplete
(
sourceUrl
,
{
width
:
400
,
selectFirst
:
false
,
minChars
:
minCharacters
,
matchContains
:
true
,
delay
:
400
,
max
:
1000
,
extraParams
:{
term
:
function
()
{
return
cj
(
postcodeElement
).
val
();
},
number
:
function
()
{
return
cj
(
houseElement
).
val
();
}
}
}).
result
(
function
(
event
,
data
,
formatted
)
{
findAddressValues
(
data
[
1
],
blockNo
);
cj
(
postcodeElement
).
val
(
''
);
return
false
;
});
{/
literal
}{
else
}{
literal
}
cj
(
postcodeElement
).
autocomplete
({
source
:
'
/civicrm/
{/
literal
}{
$config
->
CiviPostCodeLookupProvider
}{
literal
}
/ajax/search
'
,
source
:
sourceUrl
,
minLength
:
minCharacters
,
data
:
{
postcode
:
cj
(
postcodeElement
).
val
(),
number
:
cj
(
houseElement
).
val
(),
mode
:
'0'
}
,
search
:
function
(
event
,
ui
)
{
...
...
@@ -57,15 +84,20 @@ cj(document).ready(function(){
cj
(
"
.ui-autocomplete
"
).
css
(
"
z-index
"
,
1000
);
}
});
{/
literal
}{/
if
}{
literal
}
});
});
function
findAddressValues
(
id
,
blockNo
)
{
cj
(
'
#loaderimage_
'
+
blockNo
).
show
();
setAddressFields
(
false
,
blockNo
);
var
sourceUrl
=
CRM
.
url
(
'
civicrm/
{/
literal
}{
$config
->
CiviPostCodeLookupProvider
}{
literal
}
/ajax/get
'
,
{
"json"
:
1
}
);
cj
.
ajax
({
dataType
:
'
json
'
,
data
:
{
id
:
id
,
mode
:
'0'
}
,
url
:
'
/civicrm/
{/
literal
}{
$config
->
CiviPostCodeLookupProvider
}{
literal
}
/ajax/get
'
,
url
:
sourceUrl
,
success
:
function
(
data
)
{
setAddressFields
(
data
.
address
,
blockNo
);
setAddressFields
(
true
,
blockNo
);
...
...
templates/CRM/Contact/Form/Edit/Address/street_address.tpl
View file @
6c8737ee
...
...
@@ -51,10 +51,38 @@ cj(document).ready(function() {
}
cj
(
function
()
{
var
sourceUrl
=
CRM
.
url
(
'
civicrm/
{/
literal
}{
$config
->
CiviPostCodeLookupProvider
}{
literal
}
/ajax/search
'
,
{
"json"
:
1
}
);
{/
literal
}{
if
$config
->
civiVersion
<
4.5
}{
literal
}
cj
(
postcodeElement
).
autocomplete
(
sourceUrl
,
{
width
:
400
,
selectFirst
:
false
,
minChars
:
minCharacters
,
matchContains
:
true
,
delay
:
400
,
max
:
1000
,
extraParams
:{
term
:
function
()
{
return
cj
(
postcodeElement
).
val
();
},
number
:
function
()
{
return
cj
(
houseElement
).
val
();
}
}
}).
result
(
function
(
event
,
data
,
formatted
)
{
findAddressValues
(
data
[
1
],
blockNo
);
cj
(
postcodeElement
).
val
(
''
);
return
false
;
});
{/
literal
}{
else
}{
literal
}
cj
(
postcodeElement
).
autocomplete
({
source
:
'
/civicrm/
{/
literal
}{
$config
->
CiviPostCodeLookupProvider
}{
literal
}
/ajax/search
'
,
source
:
sourceUrl
,
minLength
:
minCharacters
,
data
:
{
postcode
:
cj
(
postcodeElement
).
val
(),
number
:
cj
(
houseElement
).
val
(),
mode
:
'0'
}
,
//max:
{/
literal
}{
crmSetting
name
=
"search_autocomplete_count"
group
=
"Search Preferences"
}{
literal
}
,
search
:
function
(
event
,
ui
)
{
cj
(
'
#loaderimage_
'
+
blockNo
).
show
();
},
...
...
@@ -76,6 +104,9 @@ cj(document).ready(function() {
cj
(
"
.ui-autocomplete
"
).
css
(
"
z-index
"
,
1000
);
}
});
{/
literal
}{/
if
}{
literal
}
});
});
...
...
@@ -86,10 +117,11 @@ function addslashes (str) {
function
findAddressValues
(
id
,
blockNo
)
{
cj
(
'
#loaderimage_
'
+
blockNo
).
show
();
setAddressFields
(
false
,
blockNo
);
var
sourceUrl
=
CRM
.
url
(
'
civicrm/
{/
literal
}{
$config
->
CiviPostCodeLookupProvider
}{
literal
}
/ajax/get
'
,
{
"json"
:
1
}
);
cj
.
ajax
({
dataType
:
'
json
'
,
data
:
{
id
:
id
}
,
url
:
'
{/
literal
}{
$config
->
userFrameworkBaseURL
}{
literal
}
civicrm/
{/
literal
}{
$config
->
CiviPostCodeLookupProvider
}{
literal
}
/ajax/get
'
,
url
:
sourceUrl
,
success
:
function
(
data
)
{
setAddressFields
(
data
.
address
,
blockNo
);
setAddressFields
(
true
,
blockNo
);
...
...
@@ -142,18 +174,18 @@ function setAddressFields(address, blockNo) {
{
if
!
empty
(
$form.address
.
$blockId.street_address
)
}
<tr
id=
"streetAddress_
{
$blockId
}
"
>
<td
colspan=
"2"
>
{
$form.address
.
$blockId.street_address.label
}
{
help
id
=
"id-street-address"
file
=
"CRM/Contact/Form/Contact.hlp"
}
<br
/>
{
$form.address
.
$blockId.street_address.html
}
{
if
$parseStreetAddress
eq
1
&&
(
$action
eq
1
||
$action
eq
2
)
}
<td
colspan=
"2"
>
{
$form.address
.
$blockId.street_address.label
}
{
help
id
=
"id-street-address"
file
=
"CRM/Contact/Form/Contact.hlp"
}
<br
/>
{
$form.address
.
$blockId.street_address.html
}
{
if
$parseStreetAddress
eq
1
&&
(
$action
eq
1
||
$action
eq
2
)
}
<a
href=
"#"
title=
"
{
ts
}
Edit Address Elements
{/
ts
}
"
onClick=
"processAddressFields( 'addressElements' , '
{
$blockId
}
', 1 );return false;"
>
{
ts
}
Edit Address Elements
{/
ts
}
</a>
{
help
id
=
"id-edit-street-elements"
file
=
"CRM/Contact/Form/Contact.hlp"
}
{/
if
}
</td>
</tr>
</td>
</tr>
{
if
$parseStreetAddress
eq
1
&&
(
$action
eq
1
||
$action
eq
2
)
}
<tr
id=
"addressElements_
{
$blockId
}
"
class=
hiddenElement
>
<tr
id=
"addressElements_
{
$blockId
}
"
class=
hiddenElement
>
<td>
{
$form.address
.
$blockId.street_number.label
}
<br
/>
{
$form.address
.
$blockId.street_number.html
}
...
...
@@ -165,13 +197,13 @@ function setAddressFields(address, blockNo) {
</td>
<td
colspan=
"2"
>
{
$form.address
.
$blockId.street_unit.label
}
<br
/>
{
$form.address
.
$blockId.street_unit.label
}
<br
/>
{
$form.address
.
$blockId.street_unit.html
}
<a
href=
"#"
title=
"
{
ts
}
Edit Street Address
{/
ts
}
"
onClick=
"processAddressFields( 'streetAddress', '
{
$blockId
}
', 1 );return false;"
>
{
ts
}
Edit Complete Street Address
{/
ts
}
</a>
{
help
id
=
"id-edit-complete-street"
file
=
"CRM/Contact/Form/Contact.hlp"
}
</td>
</tr>
{/
if
}
{/
if
}
{
if
$parseStreetAddress
eq
1
}
{
literal
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment