Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dataprocessor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Don Wijesooriya
dataprocessor
Commits
0e0c330b
Commit
0e0c330b
authored
5 years ago
by
jaapjansma
Browse files
Options
Downloads
Patches
Plain Diff
Case role filter
parent
3030d808
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Civi/DataProcessor/FilterHandler/CaseRoleFilter.php
+39
-7
39 additions, 7 deletions
Civi/DataProcessor/FilterHandler/CaseRoleFilter.php
templates/CRM/Dataprocessor/Form/Filter/Configuration/CaseRoleFilter.tpl
+5
-0
5 additions, 0 deletions
...ataprocessor/Form/Filter/Configuration/CaseRoleFilter.tpl
with
44 additions
and
7 deletions
Civi/DataProcessor/FilterHandler/CaseRoleFilter.php
+
39
−
7
View file @
0e0c330b
...
...
@@ -25,6 +25,11 @@ class CaseRoleFilter extends AbstractFilterHandler {
*/
protected
$dataSource
;
/**
* @var array
*/
protected
$relationship_type_ids
=
array
();
public
function
__construct
()
{
parent
::
__construct
();
}
...
...
@@ -53,6 +58,10 @@ class CaseRoleFilter extends AbstractFilterHandler {
$this
->
fieldSpecification
->
alias
=
$alias
;
$this
->
fieldSpecification
->
title
=
$title
;
}
if
(
isset
(
$configuration
[
'relationship_types'
])
&&
is_array
(
$configuration
[
'relationship_types'
]))
{
$this
->
relationship_type_ids
=
$configuration
[
'relationship_types'
];
}
}
/**
...
...
@@ -74,16 +83,21 @@ class CaseRoleFilter extends AbstractFilterHandler {
$cids
=
array
(
$cids
);
}
$relationshipTableAlias
=
'civicrm_relationship_'
.
$this
->
fieldSpecification
->
alias
;
$relationshipFilters
=
array
(
new
SqlDataFlow\SimpleWhereClause
(
$relationshipTableAlias
,
'is_active'
,
'='
,
'1'
),
new
SqlDataFlow\SimpleWhereClause
(
$relationshipTableAlias
,
'case_id'
,
'IS NOT NULL'
,
0
),
new
SqlDataFlow\SimpleWhereClause
(
$relationshipTableAlias
,
'contact_id_b'
,
'IN'
,
$cids
),
);
if
(
count
(
$this
->
relationship_type_ids
))
{
$relationshipFilters
[]
=
new
SqlDataFlow\SimpleWhereClause
(
$relationshipTableAlias
,
'relationship_type_id'
,
'IN'
,
$this
->
relationship_type_ids
,
'Integer'
);
}
if
(
$dataFlow
&&
$dataFlow
instanceof
SqlDataFlow
)
{
$whereClause
=
new
SqlDataFlow\InTableWhereClause
(
'case_id'
,
'civicrm_relationship'
,
$relationshipTableAlias
,
array
(
new
SqlDataFlow\SimpleWhereClause
(
$relationshipTableAlias
,
'is_active'
,
'='
,
'1'
),
new
SqlDataFlow\SimpleWhereClause
(
$relationshipTableAlias
,
'case_id'
,
'IS NOT NULL'
,
0
),
new
SqlDataFlow\SimpleWhereClause
(
$relationshipTableAlias
,
'contact_id_b'
,
'IN'
,
$cids
),
),
$relationshipFilters
,
$dataFlow
->
getName
(),
$this
->
fieldSpecification
->
name
,
$filter
[
'op'
]
...
...
@@ -111,18 +125,35 @@ class CaseRoleFilter extends AbstractFilterHandler {
*/
public
function
buildConfigurationForm
(
\CRM_Core_Form
$form
,
$filter
=
array
())
{
$fieldSelect
=
\CRM_Dataprocessor_Utils_DataSourceFields
::
getAvailableFilterFieldsInDataSources
(
$filter
[
'data_processor_id'
]);
$relationshipTypeApi
=
civicrm_api3
(
'RelationshipType'
,
'get'
,
array
(
'is_active'
=>
1
,
'options'
=>
array
(
'limit'
=>
0
)));
$relationshipTypes
=
array
();
foreach
(
$relationshipTypeApi
[
'values'
]
as
$relationship_type
)
{
$relationshipTypes
[
$relationship_type
[
'id'
]]
=
$relationship_type
[
'label_a_b'
];
}
$form
->
add
(
'select'
,
'case_id_field'
,
E
::
ts
(
'Case ID Field'
),
$fieldSelect
,
true
,
array
(
'style'
=>
'min-width:250px'
,
'class'
=>
'crm-select2 huge'
,
'placeholder'
=>
E
::
ts
(
'- select -'
),
));
$form
->
add
(
'select'
,
'relationship_types'
,
E
::
ts
(
'Restrict to roles'
),
$relationshipTypes
,
false
,
array
(
'style'
=>
'min-width:250px'
,
'class'
=>
'crm-select2 huge'
,
'placeholder'
=>
E
::
ts
(
'- Filter on all roles -'
),
'multiple'
=>
true
,
));
if
(
isset
(
$filter
[
'configuration'
]))
{
$configuration
=
$filter
[
'configuration'
];
$defaults
=
array
();
if
(
isset
(
$configuration
[
'field'
])
&&
isset
(
$configuration
[
'datasource'
]))
{
$defaults
[
'field'
]
=
$configuration
[
'datasource'
]
.
'::'
.
$configuration
[
'field'
];
$form
->
setDefaults
(
$defaults
);
$defaults
[
'case_id_field'
]
=
$configuration
[
'datasource'
]
.
'::'
.
$configuration
[
'field'
];
}
if
(
isset
(
$configuration
[
'relationship_types'
]))
{
$defaults
[
'relationship_types'
]
=
$configuration
[
'relationship_types'
];
}
$form
->
setDefaults
(
$defaults
);
}
}
...
...
@@ -147,6 +178,7 @@ class CaseRoleFilter extends AbstractFilterHandler {
list
(
$datasource
,
$field
)
=
explode
(
'::'
,
$submittedValues
[
'case_id_field'
],
2
);
$configuration
[
'field'
]
=
$field
;
$configuration
[
'datasource'
]
=
$datasource
;
$configuration
[
'relationship_types'
]
=
isset
(
$submittedValues
[
'relationship_types'
])
?
$submittedValues
[
'relationship_types'
]
:
array
();
return
$configuration
;
}
...
...
This diff is collapsed.
Click to expand it.
templates/CRM/Dataprocessor/Form/Filter/Configuration/CaseRoleFilter.tpl
+
5
−
0
View file @
0e0c330b
...
...
@@ -4,4 +4,9 @@
<div
class=
"content"
>
{
$form.case_id_field.html
}
</div>
<div
class=
"clear"
></div>
</div>
<div
class=
"crm-section"
>
<div
class=
"label"
>
{
$form.relationship_types.label
}
</div>
<div
class=
"content"
>
{
$form.relationship_types.html
}
</div>
<div
class=
"clear"
></div>
</div>
{/
crmScope
}
\ No newline at end of file
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