2022-03-14 19:13:10 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Models\UsersModel;
|
|
|
|
|
|
|
|
class Users extends BaseController
|
|
|
|
{
|
2024-04-07 22:40:57 +02:00
|
|
|
protected object $usersModel;
|
2022-03-14 19:13:10 +01:00
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
2024-04-07 22:40:57 +02:00
|
|
|
$this->usersModel = new UsersModel();
|
2022-03-14 19:13:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
2024-04-07 22:40:57 +02:00
|
|
|
$users = $this->usersModel->findAll();
|
2022-03-14 19:13:10 +01:00
|
|
|
$tplData = [];
|
|
|
|
$tplData['users'] = $users;
|
|
|
|
echo get_header('Users');
|
|
|
|
echo view('users', $tplData);
|
|
|
|
echo get_footer();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function user($username)
|
|
|
|
{
|
|
|
|
//$this->cachePage(3600);
|
2024-04-07 22:40:57 +02:00
|
|
|
$user = $this->usersModel->getUser($username);
|
|
|
|
$userraces = $this->usersModel->getRaces();
|
|
|
|
$raceswon = $this->usersModel->getWon();
|
|
|
|
$racespodiums = $this->usersModel->getPodiums();
|
|
|
|
$racesretired = $this->usersModel->getUnfinisced();
|
|
|
|
$practices = $this->usersModel->getPractices();
|
|
|
|
$qualifies = $this->usersModel->getQualifies();
|
2022-03-14 19:13:10 +01:00
|
|
|
$tplData = [
|
2024-04-07 22:40:57 +02:00
|
|
|
'raceSessions' => $this->usersModel->getRaceSessions(),
|
2022-03-14 19:13:10 +01:00
|
|
|
'userRaces' => $userraces,
|
|
|
|
'racesWon' => $raceswon,
|
|
|
|
'raceswonpercent' => percentStr($raceswon, count($userraces)),
|
|
|
|
'racespodiums' => $racespodiums,
|
|
|
|
'racespodiumpercent' => percentStr($racespodiums->totalPodiums, count($userraces)),
|
|
|
|
'practicescount' => $practices,
|
|
|
|
'qualifiescount' => $qualifies,
|
|
|
|
'racesretired' => $racesretired,
|
|
|
|
'racesretiredpercent' => percentStr($racesretired, count($userraces)),
|
2024-04-07 22:40:57 +02:00
|
|
|
'mostusedcar' => $this->usersModel->getMostUsedCar(),
|
|
|
|
'mostusedtrack' => $this->usersModel->getMostUsedTrack(),
|
|
|
|
'timeontrackPractice' => $this->usersModel->getTimePractice(),
|
|
|
|
'timeontrackQualify' => $this->usersModel->getTimeQualify(),
|
|
|
|
'timeontrackRace' => $this->usersModel->getTimeOnRace(),
|
|
|
|
'timeontrack' => $this->usersModel->getTimeOnTracks(),
|
2022-03-14 19:13:10 +01:00
|
|
|
'user' => $user
|
|
|
|
];
|
2024-04-07 22:40:57 +02:00
|
|
|
log_message('debug', json_encode($tplData['raceSessions']));
|
2022-03-14 19:13:10 +01:00
|
|
|
echo get_header("User: $username");
|
|
|
|
echo view('user', $tplData);
|
|
|
|
echo get_footer();
|
|
|
|
}
|
2024-04-07 22:40:57 +02:00
|
|
|
|
|
|
|
public function login()
|
|
|
|
{
|
|
|
|
echo get_header("Log In");
|
|
|
|
echo view('login');
|
|
|
|
echo get_footer(['dashboard.js']);
|
|
|
|
}
|
2022-03-14 19:13:10 +01:00
|
|
|
}
|