Skip to content

Commit

Permalink
Merge pull request #242 from bcgov/pg-bugfix-0047
Browse files Browse the repository at this point in the history
Dev - Donation History Summary/Pledge Summary: Add charity details
  • Loading branch information
techmusicmoney authored Jun 21, 2023
2 parents 0f7b40c + 95ae5cd commit c9790f4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 24 deletions.
22 changes: 16 additions & 6 deletions app/Http/Controllers/DonationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public function index(Request $request) {
->selectRaw("'GF', pledges.user_id, pledges.id, pledges.emplid, campaign_years.calendar_year, type,
'Annual' , 'Bi-Weekly', pledges.pay_period_amount, pledges.goal_amount - pledges.one_time_amount,
(select regions.name from f_s_pools, regions where f_s_pools.region_id = regions.id and f_s_pools.id = pledges.f_s_pool_id),
case when type = 'P' then 0 else (select count(*) from pledge_charities
where pledge_charities.pledge_id = pledges.id
case when type = 'P' then 0 else (select GROUP_CONCAT(charity_name) from pledge_charities, charities
where pledge_charities.charity_id = charities.id
and pledge_charities.pledge_id = pledges.id
and pledge_charities.frequency = 'bi-weekly'
and pledge_charities.deleted_at is null) end");

Expand All @@ -67,8 +68,9 @@ public function index(Request $request) {
->selectRaw("'GF', pledges.user_id, pledges.id, pledges.emplid, campaign_years.calendar_year, type,
'Annual' , 'One-Time', pledges.one_time_amount, pledges.one_time_amount,
(select regions.name from f_s_pools, regions where f_s_pools.region_id = regions.id and f_s_pools.id = pledges.f_s_pool_id),
case when type = 'P' then 0 else (select count(*) from pledge_charities
where pledge_charities.pledge_id = pledges.id
case when type = 'P' then 0 else (select GROUP_CONCAT(charity_name) from pledge_charities, charities
where pledge_charities.charity_id = charities.id
and pledge_charities.pledge_id = pledges.id
and pledge_charities.frequency = 'one-time'
and pledge_charities.deleted_at is null) end");

Expand Down Expand Up @@ -114,11 +116,12 @@ public function index(Request $request) {
case when source = 'P' then 0 else
case when campaign_type = 'Donate Today'
then (select charity_name from charities a, pledge_histories b where a.registration_number = b.charity_bn and b.id = pledge_history_summaries.pledge_history_id)
else (select count(*) from pledge_histories where emplid = pledge_history_summaries.emplid
else (select GROUP_CONCAT(vendor_name1) from pledge_histories where emplid = pledge_history_summaries.emplid
and yearcd = pledge_history_summaries.yearcd
and source = 'Non-Pool'
and campaign_type = pledge_history_summaries.campaign_type
and frequency = pledge_history_summaries.frequency)
and frequency = pledge_history_summaries.frequency
)
end
end as number_of_charities")
->unionAll($annual_pay_period_pledges)
Expand All @@ -137,6 +140,13 @@ public function index(Request $request) {
$totalPledgedDataTillNow += $pledge->pledge;
}

foreach($pledges_by_yearcd as $yearcd => $pledges){
foreach($pledges as $index => $pledge){
$pledges_by_yearcd[$yearcd][$index]->charities = PledgeHistory::join("pledge_history_summaries","pledge_histories.id","pledge_history_summaries.pledge_history_id")->select("vendor_name1")->where("pledge_history_summaries.emplid","=",$user->emplid)->where("pledge_history_summaries.yearcd","=",$yearcd)->where("pledge_history_summaries.source","=","Non-Pool")->where("pledge_history_summaries.campaign_type","=",$pledge->donation_type)->where("pledge_history_summaries.frequency","=",$pledge->frequency)->get();

}
}

// download PDF file with download method
if(isset($request->download_pdf)){
// view()->share('donations.index',compact('pledges', 'currentYear', 'totalPledgedDataTillNow', 'campaignYear',
Expand Down
5 changes: 3 additions & 2 deletions resources/views/donations/partials/history.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
data-id="{{ $pledge->id }}"
data-frequency="{{ $pledge->frequency }}"
data-yearcd="{{ $pledge->yearcd }}">
{{ $pledge->number_of_charities }} {{ $pledge->number_of_charities > 1 ? 'charities' : 'charity' }}
{{ count(explode(",",$pledge->number_of_charities)) }} {{ count(explode(",",$pledge->number_of_charities)) > 1 ? 'charities' : 'charity' }}
</a>

@endswitch
Expand All @@ -79,7 +79,8 @@
data-id="{{ $pledge->id }}"
data-frequency="{{ $pledge->frequency }}"
data-yearcd="{{ $pledge->yearcd }}">
{{ $pledge->number_of_charities }} {{ $pledge->number_of_charities > 1 ? 'charities' : 'charity' }}
{{ count(explode(",",$pledge->number_of_charities)) }} {{ count(explode(",",$pledge->number_of_charities)) > 1 ? 'charities' : 'charity' }}

</a>
@endif
@endif
Expand Down
38 changes: 22 additions & 16 deletions resources/views/donations/partials/pdf.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,28 +95,34 @@
{{ $pledge->region }}
@break
@default
<a type="button" class="more-info"
data-source="{{ $pledge->source }}"
data-type="{{ $pledge->donation_type }}"
data-id="{{ $pledge->id }}"
data-frequency="{{ $pledge->frequency }}"
data-yearcd="{{ $pledge->yearcd }}">
{{ $pledge->number_of_charities }} {{ $pledge->number_of_charities > 1 ? 'charities' : 'charity' }}
</a>
@foreach(explode(",",$pledge->number_of_charities) as $charity)
<a style="cursor:pointer;font-size:10px;" class="more-info"
data-source="{{ $pledge->source }}"
data-type="{{ $pledge->donation_type }}"
data-id="{{ $pledge->id }}"
data-frequency="{{ $pledge->frequency }}"
data-yearcd="{{ $pledge->yearcd }}">
{{$charity}}
</a>
<br>
@endforeach

@endswitch
@else
@if ($pledge->donation_type == 'Donate Today')
{{ $pledge->number_of_charities }}
@else
<a type="button" class="more-info "
data-source="{{ $pledge->source }}"
data-type="{{ $pledge->donation_type }}"
data-id="{{ $pledge->id }}"
data-frequency="{{ $pledge->frequency }}"
data-yearcd="{{ $pledge->yearcd }}">
{{ $pledge->number_of_charities }} {{ $pledge->number_of_charities > 1 ? 'charities' : 'charity' }}
</a>
@foreach(explode(",",$pledge->number_of_charities) as $charity)
<a style="cursor:pointer;font-size:10px;" class="more-info"
data-source="{{ $pledge->source }}"
data-type="{{ $pledge->donation_type }}"
data-id="{{ $pledge->id }}"
data-frequency="{{ $pledge->frequency }}"
data-yearcd="{{ $pledge->yearcd }}">
{{$charity}}
</a>
<br>
@endforeach
@endif
@endif
</td>
Expand Down

0 comments on commit c9790f4

Please sign in to comment.