Add statistics feature with bookings tracking functionality

Introduce a scalable statistics architecture including `statistics` class, interface, and related implementations. Added support for tracking new bookings with routes and data handling through `bookings_s` and `statistic_t`. Integrated the feature into the application using autoloaders and response mechanisms.
This commit is contained in:
Jepp9350
2025-01-31 12:32:22 +01:00
parent ca52d3b248
commit e09eedb010
6 changed files with 226 additions and 0 deletions
@@ -0,0 +1,36 @@
<?php
namespace statistics;
use traits\statistic_t;
class bookings_s
{
use statistic_t;
public function get_new_bookings(): self
{
// Get the departments
$departments_o = new \objects\departments_o();
// Get the bookings
$bookings_o = new \objects\bookings_o();
// Get the bookings
$bookings = $bookings_o->getFields(['id', 'department', 'date']);
// Get the departments
$departments = $departments_o->getFields(['id', 'name']);
// Add the labels (months)
$this->labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
// Add the labels, and the data sets
foreach ( $departments as $department ) {
$tmp_department_monthly = [];
foreach ( $this->labels as $label ) {
$tmp_department_monthly[$label] = 0;
}
$this->add_data_set($department['name'], $tmp_department_monthly, ['backgroundColor' => '#FF0000']);
}
return $this;
}
}