Server IP : 213.176.29.180  /  Your IP : 18.119.140.2
Web Server : Apache
System : Linux 213.176.29.180.hostiran.name 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
User : webtaragh ( 1001)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/webtaragh/public_html/whmcs/modules/widgets/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/webtaragh/public_html/whmcs/modules/widgets/Automation.php
<?php

namespace WHMCS\Module\Widget;

use WHMCS\Carbon;
use WHMCS\Module\AbstractWidget;

/**
 * Automation Widget.
 *
 * @copyright Copyright (c) WHMCS Limited 2005-2018
 * @license https://www.whmcs.com/license/ WHMCS Eula
 */
class Automation extends AbstractWidget
{
    protected $title = 'بخش فروش';
    protected $description = 'بخش فروش در یک نگاه کلی';
    protected $weight = 20;
    protected $cache = true;
    protected $requiredPermission = 'Configure Automation Settings';

    public function getData()
    {
        return localApi('GetAutomationLog', array('startdate' => date("Y-m-d", time() - (7 * 24 * 60 * 60))));
    }

    public function generateOutput($data)
    {
        try {
            $today = Carbon::createFromFormat('Y-m-d H:i:s', $data['currentDatetime'])->toDateString();

            $lastDailyCronInvocationTime = Carbon::createFromFormat('Y-m-d H:i:s', $data['lastDailyCronInvocationTime']);
            if ($lastDailyCronInvocationTime->toDateString() == Carbon::today()->toDateString()) {
                $lastInvokationTime = '<strong>امروز</strong> at ' . $lastDailyCronInvocationTime->format('g:i A');
            } elseif ($lastDailyCronInvocationTime->toDateString() == Carbon::yesterday()->toDateString()) {
                $lastInvokationTime = '<strong>دیروز</strong> at ' . $lastDailyCronInvocationTime->format('g:i A');
            } else {
                $lastInvokationTime = $lastDailyCronInvocationTime->diffForHumans();
            }

            if (Carbon::now()->diffInHours($lastDailyCronInvocationTime) > 24) {
                $lastInvokationTime .= ' <a href="configauto.php" class="label label-danger">نیاز به اصلاح</a>';
            }
        } catch (\Exception $e) {
            $lastInvokationTime = '<strong>هیچ وقت .</strong> <a href="configauto.php" class="label label-danger">نیاز به اصلاح</a>';
        }

        if (isset($data['statistics'][$today])) {
            $invoicesCreatedToday = (int)$data['statistics'][$today]['CreateInvoices']['invoice.created'];
            $ccCapturesToday = (int)$data['statistics'][$today]['ProcessCreditCardPayments']['captured'];
            $overdueSuspensionsToday = (int)$data['statistics'][$today]['AutoSuspensions']['suspended'];
            $closedTicketsToday = (int)$data['statistics'][$today]['CloseInactiveTickets']['closed'];
            $cancellationsToday = (int)$data['statistics'][$today]['CancellationRequests']['cancellations'];

            $overdueRemindersToday = (int)$data['statistics'][$today]['InvoiceReminders']['unpaid']
                + $data['statistics'][$today]['InvoiceReminders']['overdue.first']
                + $data['statistics'][$today]['InvoiceReminders']['overdue.second']
                + $data['statistics'][$today]['InvoiceReminders']['overdue.third'];
        } else {
            $invoicesCreatedToday = $ccCapturesToday = $overdueSuspensionsToday = $closedTicketsToday = $cancellationsToday = $overdueRemindersToday = 0;
        }
        $graphData = array();
        foreach ($data['statistics'] as $date => $statistics) {
            $graphData['createinvoices'][] = (int) $statistics['CreateInvoices']['invoice.created'];
            $graphData['processcreditcardpayments'][] = (int) $statistics['ProcessCreditCardPayments']['captured'];
            $graphData['suspensions'][] = (int) $statistics['AutoSuspensions']['suspended'];
            $graphData['closetickets'][] = (int) $statistics['CloseInactiveTickets']['closed'];
            $graphData['cancellationrequests'][] = (int) $statistics['CancellationRequests']['cancellations'];
            $graphData['invoicereminders'][] = (int) $statistics['InvoiceReminders']['unpaid']
                + $statistics['InvoiceReminders']['overdue.first']
                + $statistics['InvoiceReminders']['overdue.second']
                + $statistics['InvoiceReminders']['overdue.third'];
        }
        if (!empty($graphData)) {
            $invoicesCreatedString = implode(',', $graphData['createinvoices']);
            $ccCapturesString = implode(',', $graphData['processcreditcardpayments']);
            $overdueSuspensionsString = implode(',', $graphData['suspensions']);
            $closedTicketsString = implode(',', $graphData['closetickets']);
            $cancellationsString = implode(',', $graphData['cancellationrequests']);
            $overdueRemindersString = implode(',', $graphData['invoicereminders']);
        } else {
            $invoicesCreatedString = $ccCapturesString = $overdueSuspensionsString = $closedTicketsString = $cancellationsString = $overdueRemindersString = '';
        }

        return <<<EOF
<div class="row">
    <div class="col-xs-6 col-sm-4 col-md-6">
        <div class="mini-chart">
            <a href="automationstatus.php?metric=CreateInvoices">
                <span class="peity-line" data-peity='{ "fill": "rgba(64, 186, 189, 0.2)", "stroke": "rgba(64, 186, 189, 0.7)", "strokeWidth": 2, "width": 120}'>{$invoicesCreatedString}</span>
            </a>
        </div>
        <h4 class="item-title">
            <span class="title-text">فاکتور ایجاد شده</span>
        </h4>
        <p class="item-figure color-blue">{$invoicesCreatedToday}</p>
    </div>
    <div class="col-xs-6 col-sm-4 col-md-6">
        <div class="mini-chart">
            <a href="automationstatus.php?metric=ProcessCreditCardPayments">
                <span class="peity-line" data-peity='{ "fill": "rgba(132, 217, 145, 0.2)", "stroke": "rgba(132, 217, 145, 0.7)", "strokeWidth": 2, "width": 120}'>{$ccCapturesString}</span>
            </a>
        </div>
        <h4 class="item-title">
            <span class="title-text">کارت های اعتباری</span>
        </h4>
        <p class="item-figure color-green">{$ccCapturesToday}</p>
    </div>
    <div class="col-xs-6 col-sm-4 col-md-6">
        <div class="mini-chart">
            <a href="automationstatus.php?metric=AutoSuspensions">
                <span class="peity-line" data-peity='{ "fill": "rgba(248, 161, 63, 0.2)", "stroke": "rgba(248, 161, 63, 0.7)", "strokeWidth": 2, "width": 120}'>{$overdueSuspensionsString}</span>
            </a>
        </div>
        <h4 class="item-title">
            <span class="title-text">حساب های تعلیق شده</span>
        </h4>
        <p class="item-figure color-orange">{$overdueSuspensionsToday}</p>
    </div>
    <div class="col-xs-6 col-sm-4 col-md-6">
        <div class="mini-chart">
            <a href="automationstatus.php?metric=CloseInactiveTickets">
                <span class="peity-line" data-peity='{ "fill": "rgba(234, 83, 149, 0.2)", "stroke": "rgba(234, 83, 149, 0.7)", "strokeWidth": 2, "width": 120}'>{$closedTicketsString}</span>
            </a>
        </div>
        <h4 class="item-title">
            <span class="title-text">تیکت های بسته شده</span>
        </h4>
        <p class="item-figure color-pink">{$closedTicketsToday}</p>
    </div>
    <div class="col-xs-6 col-sm-4 col-md-6">
        <div class="mini-chart">
            <a href="automationstatus.php?metric=InvoiceReminders">
                <span class="peity-line" data-peity='{ "fill": "rgba(30, 30, 30, 0.2)", "stroke": "rgba(30, 30, 30, 0.4)", "strokeWidth": 2, "width": 120}'>{$overdueRemindersString}</span>
            </a>
        </div>
        <h4 class="item-title">
            <span class="title-text">یادآوری سررسید</span>
        </h4>
        <p class="item-figure color-grey">{$overdueRemindersToday}</p>
    </div>
    <div class="col-xs-6 col-sm-4 col-md-6">
        <div class="mini-chart">
            <a href="automationstatus.php?metric=CancellationRequests">
                <span class="peity-line" data-peity='{ "fill": "rgba(144, 31, 197, 0.2)", "stroke": "rgba(144, 31, 197, 0.7)", "strokeWidth": 2, "width": 120}'>{$cancellationsString}</span>
            </a>
        </div>
        <h4 class="item-title">
            <span class="title-text">درخواست کنسل</span>
        </h4>
        <p class="item-figure color-purple">{$cancellationsToday}</p>
    </div>
    <div class="col-xs-12 text-footer">
        <i class="fas fa-check-circle fa-fw"></i>
        آخرین باری که کرون اجرا شد : {$lastInvokationTime}
    </div>
</div>

<script>
$(document).ready(function() {
    $.fn.peity.defaults.line = {
        delimiter: ",",
        fill: "#92d1d2",
        height: 32,
        max: null,
        min: 0,
        stroke: "#40babd",
        strokeWidth: 1,
        width: 100
    }
    $(".peity-line").peity("line");
});
</script>
EOF;
    }
}