Skip to content

Commit

Permalink
Dashboard bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
getpinga committed Feb 27, 2024
1 parent 78594c6 commit ba0a0a6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 33 deletions.
11 changes: 3 additions & 8 deletions cp/app/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,17 @@ public function dashboard(Request $request, Response $response)
'tickets' => $tickets,
]);
} else {
$endDate = new \DateTime();
$startDate = (new \DateTime())->modify('-4 days');

// Format dates for comparison
$startDate = (new \DateTime())->modify('-6 days');
$startDateFormatted = $startDate->format('Y-m-d');
$endDateFormatted = $endDate->format('Y-m-d');

$query = "SELECT DATE(crdate) as date, COUNT(id) as count
FROM domain
WHERE crdate >= :startDate AND crdate <= :endDate
WHERE crdate >= :startDate
GROUP BY DATE(crdate)
ORDER BY DATE(crdate) ASC";

$params = [
':startDate' => $startDateFormatted,
':endDate' => $endDateFormatted,
];

$domainsCount = $db->select($query, $params);
Expand All @@ -88,7 +83,7 @@ public function dashboard(Request $request, Response $response)
$dates[] = $date;
$counts[] = $count;
}

$query = "
SELECT
r.id,
Expand Down
50 changes: 25 additions & 25 deletions cp/resources/views/admin/dashboard/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,30 @@
</div>
</a>
</div>
<div class="col-lg-6 col-xl-4">
<div class="card">
<div class="card-body">
<h3 class="card-title">{{ __('Last 7 Days: Domain Registrations') }}</h3>
<div id="last-7-days"></div>
</div>
</div>
</div>
<div class="col-lg-6 col-xl-4">
<div class="card">
<div class="card-body">
<h3 class="card-title">{{ __('Top Registrars by Domains') }}</h3>
<div id="top-registrars"></div>
</div>
</div>
</div>
<div class="col-lg-6 col-xl-4">
<div class="card">
<div class="card-body">
<h3 class="card-title">{{ __('Support Tickets: Last Week') }}</h3>
<div id="support-tickets"></div>
</div>
</div>
</div>
{% else %}
<div class="col-sm-4 col-lg-4">
<a class="card card-link" href="{{route('listDomains')}}">
Expand Down Expand Up @@ -166,30 +190,6 @@
</a>
</div>
{% endif %}
<div class="col-lg-6 col-xl-4">
<div class="card">
<div class="card-body">
<h3 class="card-title">{{ __('Last 5 Days: Domain Registrations') }}</h3>
<div id="last-5-days"></div>
</div>
</div>
</div>
<div class="col-lg-6 col-xl-4">
<div class="card">
<div class="card-body">
<h3 class="card-title">{{ __('Top Registrars by Domains') }}</h3>
<div id="top-registrars"></div>
</div>
</div>
</div>
<div class="col-lg-6 col-xl-4">
<div class="card">
<div class="card-body">
<h3 class="card-title">{{ __('Support Tickets: Last Week') }}</h3>
<div id="support-tickets"></div>
</div>
</div>
</div>
<div class="col-12 col-md-6 mt-5">
<h3 class="card-title">{{ __('Recent Domains') }}</h3>
<div class="card">
Expand Down Expand Up @@ -265,7 +265,7 @@
var answeredData = JSON.parse('{{ answeredData|raw }}');
var unansweredData = JSON.parse('{{ unansweredData|raw }}');
window.ApexCharts && (new ApexCharts(document.getElementById('last-5-days'), {
window.ApexCharts && (new ApexCharts(document.getElementById('last-7-days'), {
chart: {
type: "bar",
fontFamily: 'inherit',
Expand Down

0 comments on commit ba0a0a6

Please sign in to comment.