Skip to content

Commit

Permalink
feature: filter by donation form
Browse files Browse the repository at this point in the history
  • Loading branch information
Ante Laca committed Dec 13, 2023
1 parent 584621b commit 8e1075a
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/Exports/DonorsExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class DonorsExport extends Give_Batch_Export
/** @var String */
protected $searchBy;

/**
* @var int
*/
protected $donationForm;

/**
* @inheritdoc
*/
Expand All @@ -44,10 +49,12 @@ public function set_properties($request)
if ($this->postedData['searchBy']) {
$this->searchBy = $this->postedData['searchBy'];
}

$this->donationForm = (int)$this->postedData['forms'];
}

/**
* @since 2.29.0 Include donor created date
* @since 2.29.0 Include donor created date
* @since 2.21.2
*/
public function get_data(): array
Expand Down Expand Up @@ -91,6 +98,22 @@ public function get_data(): array
}
}

/**
* Filter by donation form
*
* @unreleased
*/
if ($this->donationForm) {
$donationQuery
->join(function (JoinQueryBuilder $builder) {
$builder
->leftJoin('give_donationmeta', 'form')
->on('donations.ID', 'form.donation_id')
->andOn('form.meta_key', '_give_payment_form_id', true);
})
->where('form.meta_value', $this->donationForm);
}

$donorQuery->joinRaw("JOIN ({$donationQuery->getSQL()}) AS sub ON donors.id = sub.donorId");

if ($this->shouldIncludeAddress()) {
Expand Down Expand Up @@ -136,7 +159,7 @@ protected function filterExportData(array $exportData): array
}

/**
* @since 2.29.0 Include donor created col
* @since 2.29.0 Include donor created col
* @since 2.21.2
*/
public function csv_cols(): array
Expand Down

0 comments on commit 8e1075a

Please sign in to comment.