run:R W Run
1.7 KB
2026-04-08 19:26:11
R W Run
8.34 KB
2026-04-08 19:26:11
R W Run
3.54 KB
2026-04-08 19:26:10
R W Run
1.8 KB
2026-04-08 19:26:10
R W Run
3.59 KB
2026-04-08 19:26:09
R W Run
3.19 KB
2026-04-08 19:26:10
R W Run
4.85 KB
2026-04-08 19:26:12
R W Run
2.47 KB
2026-04-08 19:26:12
R W Run
11.26 KB
2026-04-08 19:26:10
R W Run
1.34 KB
2026-04-08 19:26:10
R W Run
3.54 KB
2026-04-08 19:26:09
R W Run
4.61 KB
2026-04-08 19:26:10
R W Run
37 By
2026-04-08 19:26:09
R W Run
error_log
📄Automation.php
1<?php
2
3namespace WHMCS\Module\Widget;
4
5use WHMCS\Carbon;
6use WHMCS\Module\AbstractWidget;
7
8/**
9 * Automation Widget.
10 *
11 * @copyright Copyright (c) WHMCS Limited 2005-2021
12 * @license https://www.whmcs.com/eula/ WHMCS Eula
13 */
14class Automation extends AbstractWidget
15{
16 protected $title = 'Automation Overview';
17 protected $description = 'An overview of system automation.';
18 protected $weight = 50;
19 protected $cache = true;
20 protected $requiredPermission = 'Configure Automation Settings';
21
22 public function getData()
23 {
24 return localApi('GetAutomationLog', array('startdate' => date("Y-m-d", time() - (7 * 24 * 60 * 60))));
25 }
26
27 public function generateOutput($data)
28 {
29 try {
30 $today = Carbon::createFromFormat('Y-m-d H:i:s', $data['currentDatetime'])->toDateString();
31
32 $lastDailyCronInvocationTime = Carbon::createFromFormat('Y-m-d H:i:s', $data['lastDailyCronInvocationTime']);
33 if ($lastDailyCronInvocationTime->toDateString() == Carbon::today()->toDateString()) {
34 $lastInvokationTime = '<strong>Today</strong> at ' . $lastDailyCronInvocationTime->format('g:i A');
35 } elseif ($lastDailyCronInvocationTime->toDateString() == Carbon::yesterday()->toDateString()) {
36 $lastInvokationTime = '<strong>Yesterday</strong> at ' . $lastDailyCronInvocationTime->format('g:i A');
37 } else {
38 $lastInvokationTime = $lastDailyCronInvocationTime->diffForHumans();
39 }
40
41 if (Carbon::now()->diffInHours($lastDailyCronInvocationTime) > 24) {
42 $lastInvokationTime .= ' <a href="configauto.php" class="label label-danger">Needs Attention</a>';
43 }
44 } catch (\Exception $e) {
45 $lastInvokationTime = '<strong>Never</strong> <a href="configauto.php" class="label label-danger">Needs Attention</a>';
46 }
47
48 if (isset($data['statistics'][$today])) {
49 $invoicesCreatedToday = (int)$data['statistics'][$today]['CreateInvoices']['invoice.created'];
50 $ccCapturesToday = (int)$data['statistics'][$today]['ProcessCreditCardPayments']['captured'];
51 $overdueSuspensionsToday = (int)$data['statistics'][$today]['AutoSuspensions']['suspended'];
52 $closedTicketsToday = (int)$data['statistics'][$today]['CloseInactiveTickets']['closed'];
53 $cancellationsToday = (int)$data['statistics'][$today]['CancellationRequests']['cancellations'];
54
55 $overdueRemindersToday = (int)$data['statistics'][$today]['InvoiceReminders']['unpaid']
56 + $data['statistics'][$today]['InvoiceReminders']['overdue.first']
57 + $data['statistics'][$today]['InvoiceReminders']['overdue.second']
58 + $data['statistics'][$today]['InvoiceReminders']['overdue.third'];
59 } else {
60 $invoicesCreatedToday = $ccCapturesToday = $overdueSuspensionsToday = $closedTicketsToday = $cancellationsToday = $overdueRemindersToday = 0;
61 }
62 $graphData = array();
63 foreach ($data['statistics'] as $date => $statistics) {
64 $graphData['createinvoices'][] = (int) $statistics['CreateInvoices']['invoice.created'];
65 $graphData['processcreditcardpayments'][] = (int) $statistics['ProcessCreditCardPayments']['captured'];
66 $graphData['suspensions'][] = (int) $statistics['AutoSuspensions']['suspended'];
67 $graphData['closetickets'][] = (int) $statistics['CloseInactiveTickets']['closed'];
68 $graphData['cancellationrequests'][] = (int) $statistics['CancellationRequests']['cancellations'];
69 $graphData['invoicereminders'][] = (int) $statistics['InvoiceReminders']['unpaid']
70 + $statistics['InvoiceReminders']['overdue.first']
71 + $statistics['InvoiceReminders']['overdue.second']
72 + $statistics['InvoiceReminders']['overdue.third'];
73 }
74 if (!empty($graphData)) {
75 $invoicesCreatedString = implode(',', $graphData['createinvoices']);
76 $ccCapturesString = implode(',', $graphData['processcreditcardpayments']);
77 $overdueSuspensionsString = implode(',', $graphData['suspensions']);
78 $closedTicketsString = implode(',', $graphData['closetickets']);
79 $cancellationsString = implode(',', $graphData['cancellationrequests']);
80 $overdueRemindersString = implode(',', $graphData['invoicereminders']);
81 } else {
82 $invoicesCreatedString = $ccCapturesString = $overdueSuspensionsString = $closedTicketsString = $cancellationsString = $overdueRemindersString = '';
83 }
84
85 return <<<EOF
86<div class="row">
87 <div class="col-xs-6 col-sm-4 col-md-6">
88 <div class="mini-chart">
89 <a href="automationstatus.php?metric=CreateInvoices">
90 <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>
91 </a>
92 </div>
93 <h4 class="item-title">
94 <span class="title-text">Invoices Created</span>
95 </h4>
96 <p class="item-figure color-blue">{$invoicesCreatedToday}</p>
97 </div>
98 <div class="col-xs-6 col-sm-4 col-md-6">
99 <div class="mini-chart">
100 <a href="automationstatus.php?metric=ProcessCreditCardPayments">
101 <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>
102 </a>
103 </div>
104 <h4 class="item-title">
105 <span class="title-text">Credit Card Captures</span>
106 </h4>
107 <p class="item-figure color-green">{$ccCapturesToday}</p>
108 </div>
109 <div class="col-xs-6 col-sm-4 col-md-6">
110 <div class="mini-chart">
111 <a href="automationstatus.php?metric=AutoSuspensions">
112 <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>
113 </a>
114 </div>
115 <h4 class="item-title">
116 <span class="title-text">Overdue Suspensions</span>
117 </h4>
118 <p class="item-figure color-orange">{$overdueSuspensionsToday}</p>
119 </div>
120 <div class="col-xs-6 col-sm-4 col-md-6">
121 <div class="mini-chart">
122 <a href="automationstatus.php?metric=CloseInactiveTickets">
123 <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>
124 </a>
125 </div>
126 <h4 class="item-title">
127 <span class="title-text">Inactive Tickets Closed</span>
128 </h4>
129 <p class="item-figure color-pink">{$closedTicketsToday}</p>
130 </div>
131 <div class="col-xs-6 col-sm-4 col-md-6">
132 <div class="mini-chart">
133 <a href="automationstatus.php?metric=InvoiceReminders">
134 <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>
135 </a>
136 </div>
137 <h4 class="item-title">
138 <span class="title-text">Overdue Reminders</span>
139 </h4>
140 <p class="item-figure color-grey">{$overdueRemindersToday}</p>
141 </div>
142 <div class="col-xs-6 col-sm-4 col-md-6">
143 <div class="mini-chart">
144 <a href="automationstatus.php?metric=CancellationRequests">
145 <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>
146 </a>
147 </div>
148 <h4 class="item-title">
149 <span class="title-text">Cancellations Processed</span>
150 </h4>
151 <p class="item-figure color-purple">{$cancellationsToday}</p>
152 </div>
153 <div class="col-xs-12 text-footer">
154 <i class="fas fa-check-circle fa-fw"></i>
155 Last Automation Run: {$lastInvokationTime}
156 </div>
157</div>
158
159<script>
160$(document).ready(function() {
161 $.fn.peity.defaults.line = {
162 delimiter: ",",
163 fill: "#92d1d2",
164 height: 32,
165 max: null,
166 min: 0,
167 stroke: "#40babd",
168 strokeWidth: 1,
169 width: 100
170 }
171 $(".peity-line").peity("line");
172});
173</script>
174EOF;
175 }
176}
177