Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
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
Development
CiviCRM Core
Commits
d65de14c
Commit
d65de14c
authored
12 years ago
by
lobo
Browse files
Options
Downloads
Plain Diff
Merge pull request
#399
from agh1/batch-countrystatecounty-4.3
copy of batch-countrystatecounty for 4.3
parents
75a0f31e
fddb3858
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Contact/Form/Task/Batch.php
+23
-0
23 additions, 0 deletions
CRM/Contact/Form/Task/Batch.php
CRM/Core/BAO/Address.php
+5
-3
5 additions, 3 deletions
CRM/Core/BAO/Address.php
templates/CRM/common/stateCountry.tpl
+28
-2
28 additions, 2 deletions
templates/CRM/common/stateCountry.tpl
with
56 additions
and
5 deletions
CRM/Contact/Form/Task/Batch.php
+
23
−
0
View file @
d65de14c
...
...
@@ -67,6 +67,12 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task {
* when not to reset sort_name
*/
protected
$_preserveDefault
=
TRUE
;
/**
* the internal QF names for the state/country/county fields
*/
protected
$_stateCountryCountyFields
=
array
();
/**
* build all the data structures needed to build the form
...
...
@@ -139,11 +145,21 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task {
'organization_name'
,
'household_name'
,
);
$stateCountryMap
=
array
();
foreach
(
$this
->
_contactIds
as
$contactId
)
{
$profileFields
=
$this
->
_fields
;
CRM_Core_BAO_Address
::
checkContactSharedAddressFields
(
$profileFields
,
$contactId
);
foreach
(
$profileFields
as
$name
=>
$field
)
{
// Link state to country, county to state per location per contact
list
(
$prefixName
,
$index
)
=
CRM_Utils_System
::
explode
(
'-'
,
$name
,
2
);
if
(
$prefixName
==
'state_province'
||
$prefixName
==
'country'
||
$prefixName
==
'county'
)
{
$stateCountryMap
[
"
$index
-
$contactId
"
][
$prefixName
]
=
"field_
{
$contactId
}
_
{
$field
[
'name'
]
}
"
;
$this
->
_stateCountryCountyFields
[
"
$index
-
$contactId
"
][
$prefixName
]
=
"field[
{
$contactId
}
][
{
$field
[
'name'
]
}
]"
;
}
CRM_Core_BAO_UFGroup
::
buildProfile
(
$this
,
$field
,
NULL
,
$contactId
);
if
(
in_array
(
$field
[
'name'
],
$preserveDefaultsArray
))
{
...
...
@@ -151,6 +167,10 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task {
}
}
}
CRM_Core_BAO_Address
::
addStateCountryMap
(
$stateCountryMap
);
$this
->
assign
(
'fields'
,
$this
->
_fields
);
...
...
@@ -191,6 +211,9 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task {
}
$this
->
assign
(
'sortName'
,
$sortName
);
// now fix all state country selectors
CRM_Core_BAO_Address
::
fixAllStateSelects
(
$this
,
$defaults
,
$this
->
_stateCountryCountyFields
);
return
$defaults
;
}
...
...
This diff is collapsed.
Click to expand it.
CRM/Core/BAO/Address.php
+
5
−
3
View file @
d65de14c
...
...
@@ -663,11 +663,13 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC,
$config
->
stateCountryMap
=
array_merge
(
$config
->
stateCountryMap
,
$stateCountryMap
);
}
static
function
fixAllStateSelects
(
&
$form
,
&
$defaults
)
{
static
function
fixAllStateSelects
(
&
$form
,
$defaults
,
$batchFieldNames
=
false
)
{
$config
=
CRM_Core_Config
::
singleton
();
$map
=
is_array
(
$batchFieldNames
)
?
$batchFieldNames
:
$config
->
stateCountryMap
;
if
(
!
empty
(
$
config
->
stateCountryM
ap
))
{
foreach
(
$
config
->
stateCountryM
ap
as
$index
=>
$match
)
{
if
(
!
empty
(
$
m
ap
))
{
foreach
(
$
m
ap
as
$index
=>
$match
)
{
if
(
array_key_exists
(
'state_province'
,
$match
)
&&
array_key_exists
(
'country'
,
$match
)
...
...
This diff is collapsed.
Click to expand it.
templates/CRM/common/stateCountry.tpl
+
28
−
2
View file @
d65de14c
...
...
@@ -43,7 +43,21 @@
callbackURL
=
{/
literal
}
"
{
crmURL
p
=
'civicrm/ajax/jqState'
h
=
0
}
"
{
literal
}
cj
(
'
#
'
+
countryID
).
chainSelect
(
'
#
'
+
stateProvinceID
,
callbackURL
,
null
);
cj
(
'
#
'
+
countryID
).
chainSelect
(
'
#
'
+
stateProvinceID
,
callbackURL
,
{
before
:
function
(
target
)
{
if
(
typeof
(
setdefault
)
===
"
undefined
"
)
{
setdefault
=
new
Array
();
}
targetid
=
cj
(
target
).
attr
(
"
id
"
);
eval
(
'
setdefault[targetid] = cj(target).val()
'
);
},
after
:
function
(
target
)
{
targetid
=
cj
(
target
).
attr
(
"
id
"
);
cj
(
target
).
val
(
setdefault
[
targetid
]);
}
}
);
});
{/
literal
}
{/
if
}
...
...
@@ -63,7 +77,19 @@
callbackURL
=
{/
literal
}
"
{
crmURL
p
=
'civicrm/ajax/jqCounty'
h
=
0
}
"
{
literal
}
cj
(
'
#
'
+
stateProvinceID
).
chainSelect
(
'
#
'
+
countyID
,
callbackURL
,
null
);
cj
(
'
#
'
+
stateProvinceID
).
chainSelect
(
'
#
'
+
countyID
,
callbackURL
,
{
before
:
function
(
target
)
{
if
(
typeof
(
setdefault
)
===
"
undefined
"
)
{
setdefault
=
new
Array
();
}
targetid
=
cj
(
target
).
attr
(
"
id
"
);
eval
(
'
setdefault[targetid] = cj(target).val()
'
);
},
after
:
function
(
target
)
{
targetid
=
cj
(
target
).
attr
(
"
id
"
);
cj
(
target
).
val
(
setdefault
[
targetid
]);
}
}
);
});
{/
literal
}
{/
if
}
...
...
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