Added new tables with the lists of the most used tracks and cars in the category
This commit is contained in:
parent
053259f186
commit
f1bd63c7ea
3 changed files with 62 additions and 49 deletions
|
@ -130,7 +130,7 @@ class Home extends BaseController
|
||||||
################################
|
################################
|
||||||
*/
|
*/
|
||||||
//list($tplData['mylaps'], $_) = $bestLapsModel->getBests($period, $carCatId, 0, 0);
|
//list($tplData['mylaps'], $_) = $bestLapsModel->getBests($period, $carCatId, 0, 0);
|
||||||
|
/*
|
||||||
$tplData['tracks'] = [];
|
$tplData['tracks'] = [];
|
||||||
$builder = $this->db->table('races');
|
$builder = $this->db->table('races');
|
||||||
$builder->select('track_id, COUNT(*) AS count');
|
$builder->select('track_id, COUNT(*) AS count');
|
||||||
|
@ -160,8 +160,9 @@ class Home extends BaseController
|
||||||
|
|
||||||
$tplData['tracks'] = $tracks;
|
$tplData['tracks'] = $tracks;
|
||||||
$tplData['tracksNames'] = $tracksNames;
|
$tplData['tracksNames'] = $tracksNames;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
/*
|
||||||
$tplData['cars'] = [];
|
$tplData['cars'] = [];
|
||||||
|
|
||||||
$builder = $this->db->table('races r');
|
$builder = $this->db->table('races r');
|
||||||
|
@ -174,7 +175,7 @@ class Home extends BaseController
|
||||||
|
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
if ($query && $query->getNumRows() > 0) $tplData['cars'] = $query->getResult();
|
if ($query && $query->getNumRows() > 0) $tplData['cars'] = $query->getResult();
|
||||||
|
*/
|
||||||
echo get_header('Home', ['minidt.css']);
|
echo get_header('Home', ['minidt.css']);
|
||||||
echo view('main', $tplData);
|
echo view('main', $tplData);
|
||||||
echo get_footer(['minidt.js', 'home_tables.js']);
|
echo get_footer(['minidt.js', 'home_tables.js']);
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
$menu = '<nav>';
|
$menu = '<nav>';
|
||||||
$menuSelect = '<select id="menu-select">';
|
$menuSelect = '<select id="menu-select">';
|
||||||
/*################################
|
|
||||||
## generate the car category selection menu
|
// generate the car category selection menu
|
||||||
################################
|
|
||||||
*/
|
|
||||||
foreach ($carCategoriesList as $cat)
|
foreach ($carCategoriesList as $cat)
|
||||||
{
|
{
|
||||||
$class = '';
|
$class = '';
|
||||||
|
@ -16,19 +14,19 @@
|
||||||
//if no category has been chosen by the user, used the first valid (non empty) one
|
//if no category has been chosen by the user, used the first valid (non empty) one
|
||||||
if ($carCatId == '') $carCatId = $cat->id;
|
if ($carCatId == '') $carCatId = $cat->id;
|
||||||
|
|
||||||
//set a splecial class for the menu item that represent the currently selected class
|
//set a special class for the menu item that represent the currently selected class
|
||||||
if ($carCatId == $cat->id )
|
if ($carCatId == $cat->id )
|
||||||
{
|
{
|
||||||
$class = 'class="selected"';
|
$class = 'class="selected"';
|
||||||
$selected = 'selected';
|
$selected = 'selected';
|
||||||
}
|
}
|
||||||
|
|
||||||
//echo "\n<a href='?cat=".$id."' $class>".$category->name."</a>";
|
|
||||||
$url = rewriteUrl('cat', $cat->id);
|
$url = rewriteUrl('cat', $cat->id);
|
||||||
$menu .= "<a href=\"$url\" $class>{$cat->name}</a>";
|
$menu .= "<a href=\"$url\" $class>{$cat->name}</a>";
|
||||||
$menuSelect .= "<option value=\"$url\" $selected>{$cat->name}</option>";
|
$menuSelect .= "<option value=\"$url\" $selected>{$cat->name}</option>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$menu .= '</nav>';
|
$menu .= '</nav>';
|
||||||
$menuSelect .= '</select>';
|
$menuSelect .= '</select>';
|
||||||
?>
|
?>
|
||||||
|
@ -73,50 +71,18 @@
|
||||||
Most used Tracks<br />
|
Most used Tracks<br />
|
||||||
<small><?php echo $periodString; ?></small>
|
<small><?php echo $periodString; ?></small>
|
||||||
</h3>
|
</h3>
|
||||||
<table class="fullPage responsive cat-table">
|
<div class="table-container">
|
||||||
<thead>
|
<table id="most_used_tracks" class="fullPage responsive cat-table"></table>
|
||||||
<tr>
|
</div>
|
||||||
<th>Track</th>
|
|
||||||
<th>Races</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($tracks as $race): ?>
|
|
||||||
<tr>
|
|
||||||
<td data-title="Track">
|
|
||||||
<?= clickableName($race->track_id, 'track', $tracksNames[$race->track_id]) ?>
|
|
||||||
</td>
|
|
||||||
<td data-title="Races">
|
|
||||||
<?= $race->count ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<h3>
|
<h3>
|
||||||
Top cars<br />
|
Top cars<br />
|
||||||
<small><?php echo $periodString; ?></small>
|
<small><?php echo $periodString; ?></small>
|
||||||
</h3>
|
</h3>
|
||||||
<table class="fullPage responsive cat-table">
|
<div class="table-container">
|
||||||
<thead>
|
<table id="most_used_cars" class="fullPage responsive cat-table"></table>
|
||||||
<tr>
|
</div>
|
||||||
<th>Car</th>
|
|
||||||
<th>Races</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($cars as $car): ?>
|
|
||||||
<tr>
|
|
||||||
<td data-title="Car">
|
|
||||||
<?= clickableName($car->car_id, 'car', $car->name) ?>
|
|
||||||
</td>
|
|
||||||
<td data-title="Races">
|
|
||||||
<?= $car->count ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
period = '<?= $period ?>';
|
period = '<?= $period ?>';
|
||||||
|
|
|
@ -81,3 +81,49 @@ const dt_bests_laps = new MiniDT({
|
||||||
car_cat: car_cat
|
car_cat: car_cat
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dt_most_used_tracks = new MiniDT({
|
||||||
|
target: 'most_used_tracks',
|
||||||
|
url: `${base_url}/api/most_used_tracks`,
|
||||||
|
cols: [
|
||||||
|
{
|
||||||
|
title: 'Track',
|
||||||
|
col: 'track_id',
|
||||||
|
render: (row) => {
|
||||||
|
return linkTag(row.track_id, 'track', row.track_name)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Races',
|
||||||
|
col: 'count',
|
||||||
|
align: 'right'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
params: {
|
||||||
|
period: period,
|
||||||
|
car_cat: car_cat
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const dt_most_used_cars = new MiniDT({
|
||||||
|
target: 'most_used_cars',
|
||||||
|
url: `${base_url}/api/most_used_cars`,
|
||||||
|
cols: [
|
||||||
|
{
|
||||||
|
title: 'Car',
|
||||||
|
col: 'car_id',
|
||||||
|
render: (row) => {
|
||||||
|
return linkTag(row.car_id, 'track', row.name)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Races',
|
||||||
|
col: 'count',
|
||||||
|
align: 'right'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
params: {
|
||||||
|
period: period,
|
||||||
|
car_cat: car_cat
|
||||||
|
}
|
||||||
|
})
|
Loading…
Reference in a new issue