403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.141.28.197
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/7779/task/7779/cwd/plugins/give/src/API/Endpoints/Reports/DonationsVsIncome.php
<?php

/**
 * Reports base endpoint
 *
 * @package Give
 */

namespace Give\API\Endpoints\Reports;

class DonationsVsIncome extends Endpoint
{

    public function __construct()
    {
        $this->endpoint = 'donations-vs-income';
    }

    public function getReport($request)
    {
        $start = date_create($request->get_param('start'));
        $end = date_create($request->get_param('end'));
        $diff = date_diff($start, $end);

        $data = [];

        switch (true) {
            case ($diff->days > 900):
                $data = $this->get_data($start, $end, 'P1Y', 'Y');
                break;
            case ($diff->days > 700):
                $data = $this->get_data($start, $end, 'P6M', 'F Y');
                break;
            case ($diff->days > 400):
                $data = $this->get_data($start, $end, 'P3M', 'F Y');
                break;
            case ($diff->days > 120):
                $data = $this->get_data($start, $end, 'P1M', 'M Y');
                break;
            case ($diff->days > 30):
                $data = $this->get_data($start, $end, 'P7D', 'M jS');
                break;
            case ($diff->days > 10):
                $data = $this->get_data($start, $end, 'P3D', 'M jS');
                break;
            case ($diff->days > 4):
                $data = $this->get_data($start, $end, 'P1D', 'l');
                break;
            case ($diff->days > 1):
                $data = $this->get_data($start, $end, 'PT6H', 'D ga');
                break;
            case ($diff->days >= 0):
                $data = $this->get_data($start, $end, 'PT1H', 'D ga');
                break;
        }

        return $data;
    }

    public function get_data($start, $end, $interval, $format)
    {
        $stats = new \Give_Payment_Stats();

        $labels = [];
        $donations = [];
        $income = [];
        $periods = [];

        $dateInterval = new \DateInterval($interval);
        while ($start < $end) {
            $periodStart = $start->format('Y-m-d H:i:s');

            // Add interval to get period end
            $periodEnd = clone $start;
            date_add($periodEnd, $dateInterval);

            $label = $periodEnd->format($format);
            $periodEnd = $periodEnd->format('Y-m-d H:i:s');

            $donationsForPeriod = $stats->get_sales(0, $periodStart, $periodEnd);
            $incomeForPeriod = $stats->get_earnings(0, $periodStart, $periodEnd);

            $donations[] = $donationsForPeriod;
            $income[] = $incomeForPeriod;
            $labels[] = $label;
            $periods[] = $periodStart;

            date_add($start, $dateInterval);
        }

        return [
            'periods' => $periods,
            'labels' => $labels,
            'datasets' => [
                [
                    'label' => 'Donations',
                    'data' => $donations,
                ],
                [
                    'label' => 'Income',
                    'data' => $income,
                ],
            ],
        ];
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit