Fixed two warnings in CP and removed useless JS code

This commit is contained in:
Pinga 2024-08-05 11:34:35 +03:00
parent 02916d435e
commit d34a7b4d89
2 changed files with 23 additions and 10 deletions

View file

@ -75,6 +75,7 @@ class HomeController extends Controller
$dates = [];
$counts = [];
if (is_array($domainsCount) || is_object($domainsCount)) {
foreach ($domainsCount as $row) {
// Extract just the date part from the datetime string
$date = (new \DateTime($row['date']))->format('Y-m-d');
@ -83,6 +84,10 @@ class HomeController extends Controller
$dates[] = $date;
$counts[] = $count;
}
} else {
$dates[] = 'No data';
$counts[] = 0;
}
$query = "
SELECT
@ -135,11 +140,17 @@ class HomeController extends Controller
$answeredData = [];
$unansweredData = [];
if (is_array($results) || is_object($results)) {
foreach ($results as $row) {
$labels3[] = $row['ticket_date'];
$answeredData[] = (int) $row['answered']; // Cast to int for ApexCharts
$unansweredData[] = (int) $row['unanswered']; // Cast to int for ApexCharts
}
} else {
$labels3[] = 0;
$answeredData[] = 0;
$unansweredData[] = 0;
}
$domains = $db->selectValue('SELECT count(id) as domains FROM domain');
$latest_domains = $db->select('SELECT name, crdate FROM domain ORDER BY crdate DESC LIMIT 10');

View file

@ -253,6 +253,7 @@
</div>
{% include 'partials/footer.twig' %}
</div>
{% if registrars %}
<script>
document.addEventListener("DOMContentLoaded", function () {
var dates = JSON.parse('{{ dates|raw }}');
@ -448,4 +449,5 @@
})).render();
});
</script>
{% endif %}
{% endblock %}