Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
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
justinfreeman (Agileware)
Core
Commits
401e55ec
Commit
401e55ec
authored
11 years ago
by
deepak-srivastava
Browse files
Options
Downloads
Plain Diff
Merge pull request #962 from deepak-srivastava/hr
CRM-12490, towards issues raised by dgg
parents
f8c36033
1ebef749
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Report/Form/Contribute/Detail.php
+38
-31
38 additions, 31 deletions
CRM/Report/Form/Contribute/Detail.php
with
38 additions
and
31 deletions
CRM/Report/Form/Contribute/Detail.php
+
38
−
31
View file @
401e55ec
...
...
@@ -189,7 +189,7 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
),
'contribution_status_id'
=>
array
(
'title'
=>
ts
(
'Contribution Status'
),
),
'source'
=>
array
(
'title'
=>
ts
(
'Source'
),
'source'
=>
array
(
'title'
=>
ts
(
'Source'
),
),
'payment_instrument_id'
=>
array
(
'title'
=>
ts
(
'Payment Type'
),
),
...
...
@@ -213,6 +213,17 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
),
'filters'
=>
array
(
'contribution_or_soft'
=>
array
(
'title'
=>
ts
(
'Contribution OR Soft Credit?'
),
'clause'
=>
"(1)"
,
'operatorType'
=>
CRM_Report_Form
::
OP_SELECT
,
'type'
=>
CRM_Utils_Type
::
T_STRING
,
'options'
=>
array
(
'both'
=>
ts
(
'Both'
),
'contributions_only'
=>
ts
(
'Contributions Only'
),
'soft_credits_only'
=>
ts
(
'Soft Credits Only'
),
),
),
'receive_date'
=>
array
(
'operatorType'
=>
CRM_Report_Form
::
OP_DATE
),
'currency'
=>
...
...
@@ -348,18 +359,6 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
}
$this
->
_currencyColumn
=
'civicrm_contribution_currency'
;
$this
->
_options
=
array
(
'include_set'
=>
array
(
'title'
=>
ts
(
'Include'
),
'type'
=>
'select'
,
'options'
=>
array
(
'contributions_only'
=>
ts
(
'Contributions Only'
),
'soft_credits_only'
=>
ts
(
'Soft Credits Only'
),
'both'
=>
ts
(
'Both'
),
),
),
);
parent
::
__construct
();
}
...
...
@@ -441,7 +440,7 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
FROM civicrm_contact
{
$this
->
_aliases
[
'civicrm_contact'
]
}
{
$this
->
_aclFrom
}
INNER JOIN civicrm_contribution
{
$this
->
_aliases
[
'civicrm_contribution'
]
}
ON
{
$this
->
_aliases
[
'civicrm_contact'
]
}
.id =
{
$this
->
_aliases
[
'civicrm_contribution'
]
}
.contact_id AND
{
$this
->
_aliases
[
'civicrm_contribution'
]
}
.is_test = 0"
;
if
(
CRM_Utils_Array
::
value
(
'
include_set
'
,
$this
->
_params
)
==
'soft_credits_only'
)
{
if
(
CRM_Utils_Array
::
value
(
'
contribution_or_soft_value
'
,
$this
->
_params
)
==
'soft_credits_only'
)
{
$this
->
_from
.
=
"
INNER JOIN civicrm_contribution_soft contribution_soft_civireport
ON contribution_soft_civireport.contribution_id =
{
$this
->
_aliases
[
'civicrm_contribution'
]
}
.id"
;
...
...
@@ -553,7 +552,7 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
);
// Stats for soft credits
if
(
CRM_Utils_Array
::
value
(
'
include_set
'
,
$this
->
_params
)
!=
'contributions_only'
)
{
if
(
CRM_Utils_Array
::
value
(
'
contribution_or_soft_value
'
,
$this
->
_params
)
!=
'contributions_only'
)
{
$totalAmount
=
$average
=
array
();
$count
=
0
;
$select
=
"
...
...
@@ -612,7 +611,7 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency";
$sql
=
"
{
$select
}
{
$this
->
_from
}
{
$this
->
_groupBy
}
"
;
$tempQuery
=
'CREATE TEMPORARY TABLE civireport_contribution_detail_temp2 AS '
.
$sql
;
CRM_Core_DAO
::
executeQuery
(
$tempQuery
);
if
(
CRM_Utils_Array
::
value
(
'
include_set
'
,
$this
->
_params
)
==
'soft_credits_only'
)
{
if
(
CRM_Utils_Array
::
value
(
'
contribution_or_soft_value
'
,
$this
->
_params
)
==
'soft_credits_only'
)
{
// revise pager : prev, next based on soft-credits only
$this
->
setPager
();
}
...
...
@@ -622,29 +621,36 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency";
$this
->
from
();
// simple reset of ->_from
// 3. Decide where to populate temp3 table from
if
(
CRM_Utils_Array
::
value
(
'
include_set
'
,
$this
->
_params
)
==
'contributions_only'
)
{
$tempQuery
=
"(SELECT * FROM civireport_contribution_detail_temp1
WHERE civicrm_contribution_contribution_id=%1
)"
;
}
else
if
(
CRM_Utils_Array
::
value
(
'
include_set
'
,
$this
->
_params
)
==
'soft_credits_only'
)
{
$tempQuery
=
"(SELECT * FROM civireport_contribution_detail_temp2
WHERE civicrm_contribution_contribution_id=%1
)"
;
if
(
CRM_Utils_Array
::
value
(
'
contribution_or_soft_value
'
,
$this
->
_params
)
==
'contributions_only'
)
{
$tempQuery
=
"(SELECT * FROM civireport_contribution_detail_temp1)"
;
}
else
if
(
CRM_Utils_Array
::
value
(
'
contribution_or_soft_value
'
,
$this
->
_params
)
==
'soft_credits_only'
)
{
$tempQuery
=
"(SELECT * FROM civireport_contribution_detail_temp2)"
;
}
else
{
$tempQuery
=
"
(SELECT * FROM civireport_contribution_detail_temp1
WHERE civicrm_contribution_contribution_id=%1
)
(SELECT * FROM civireport_contribution_detail_temp1)
UNION ALL
(SELECT * FROM civireport_contribution_detail_temp2
WHERE civicrm_contribution_contribution_id=%1
)"
;
(SELECT * FROM civireport_contribution_detail_temp2)"
;
}
// 4. build temp table 3
$query
=
"select distinct civicrm_contribution_contribution_id FROM civireport_contribution_detail_temp1"
;
$dao
=
CRM_Core_DAO
::
executeQuery
(
$query
);
while
(
$dao
->
fetch
())
{
$temp3
=
$temp3
?
'INSERT INTO civireport_contribution_detail_temp3'
:
'CREATE TEMPORARY TABLE civireport_contribution_detail_temp3 AS'
;
$sql
=
"
{
$temp3
}
{
$tempQuery
}
"
;
CRM_Core_DAO
::
executeQuery
(
$sql
,
array
(
1
=>
array
(
$dao
->
civicrm_contribution_contribution_id
,
'Integer'
)));
$sql
=
"CREATE TEMPORARY TABLE civireport_contribution_detail_temp3 AS
{
$tempQuery
}
"
;
CRM_Core_DAO
::
executeQuery
(
$sql
);
// 5. Re-construct order-by to make sense for final query on temp3 table
$orderBy
=
''
;
if
(
!
empty
(
$this
->
_orderByArray
))
{
$aliases
=
array_flip
(
$this
->
_aliases
);
$orderClause
=
array
();
foreach
(
$this
->
_orderByArray
as
$clause
)
{
list
(
$alias
,
$rest
)
=
explode
(
'.'
,
$clause
);
$orderClause
[]
=
$aliases
[
$alias
]
.
"_"
.
$rest
;
}
$orderBy
=
(
!
empty
(
$orderClause
))
?
"ORDER BY "
.
implode
(
', '
,
$orderClause
)
:
''
;
}
//
5
. show result set from temp table 3
//
6
. show result set from temp table 3
$rows
=
array
();
$sql
=
"SELECT * FROM civireport_contribution_detail_temp3"
;
$sql
=
"SELECT * FROM civireport_contribution_detail_temp3
{
$orderBy
}
"
;
$this
->
buildRows
(
$sql
,
$rows
);
// format result set.
...
...
@@ -784,9 +790,10 @@ FROM civireport_contribution_detail_temp2
WHERE civicrm_contribution_contribution_id=
{
$row
[
'civicrm_contribution_contribution_id'
]
}
"
;
$dao
=
CRM_Core_DAO
::
executeQuery
(
$query
);
$string
=
''
;
$separator
=
(
$this
->
_outputMode
!==
'csv'
)
?
"<br/>"
:
' '
;
while
(
$dao
->
fetch
())
{
$url
=
CRM_Utils_System
::
url
(
"civicrm/contact/view"
,
'reset=1&cid='
.
$dao
->
civicrm_contact_id
);
$string
=
$string
.
"
\n
<a href='
{
$url
}
'>
{
$dao
->
civicrm_contact_sort_name
}
</a> "
.
$string
=
$string
.
(
$string
?
$separator
:
''
)
.
"
<a href='
{
$url
}
'>
{
$dao
->
civicrm_contact_sort_name
}
</a> "
.
CRM_Utils_Money
::
format
(
$dao
->
civicrm_contribution_total_amount_sum
,
$dao
->
civicrm_contribution_currency
);
}
$rows
[
$rowNum
][
'civicrm_contribution_soft_credits'
]
=
$string
;
...
...
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