Server IP : 192.158.238.246 / Your IP : 18.219.241.228 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/7779/task/7779/cwd/plugins/give/src/API/Endpoints/Reports/ |
Upload File : |
<?php /** * Recent Donations endpoint * * @package Give */ namespace Give\API\Endpoints\Reports; class RecentDonations extends Endpoint { public function __construct() { $this->endpoint = 'recent-donations'; } public function getReport($request) { $paymentObjects = $this->getPayments($request->get_param('start'), $request->get_param('end'), 'date', 50); // Populate $list with arrays in correct shape for frontend RESTList component $data = []; foreach ($paymentObjects as $paymentObject) { $amount = give_currency_symbol($paymentObject->currency, true) . give_format_amount($paymentObject->total, ['sanitize' => false]); $status = null; switch ($paymentObject->status) { case 'publish': $meta = $paymentObject->payment_meta; $status = isset($meta['_give_is_donation_recurring']) && $meta['_give_is_donation_recurring'] ? 'first_renewal' : 'completed'; break; case 'give_subscription': $status = 'renewal'; break; default: $status = $paymentObject->status; } $url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . absint( $paymentObject->ID ) ); $data[] = [ 'type' => 'donation', 'donation' => $paymentObject, 'status' => $status, 'amount' => $amount, 'url' => $url, 'time' => $paymentObject->date, 'donor' => [ 'name' => "{$paymentObject->first_name} {$paymentObject->last_name}", 'id' => $paymentObject->donor_id, ], 'source' => $paymentObject->form_title, ]; } // Return $list of donations for RESTList component return $data; } }