Laravel.io
<?php
session_start();
require_once './config/config.php';
require_once 'includes/auth_validate.php';
//Get current page.
$page = filter_input(INPUT_GET, 'page');
//Per page limit for pagination.
$pagelimit = 20;
$db = getDbInstance();
if (!$page) {
$page = 1;
}
$db = getDbInstance();
// select the columns / ievadiit no kuraam kolonaam izvadiit datus
$select = array('i_name');
$select2 = array('id', 'gads', 'menesis', 's_energ', 'e_energ', 'udens_k', 'dgaze', 'ddegviela', 'malka', 'atkritumi');
//Start building query according to input parameters.
//Set pagination limit
$db->pageLimit = $pagelimit;
//Get result of the query.
$iestade = $db->arraybuilder()->paginate("iestade", $page, $select);
$energoresurs = $db->arraybuilder()->paginate("energoresurs", $page, $select2);
$total_pages = $db->totalPages;
// get columns for order filter
foreach ($energoresurs as $value) {
foreach ($value as $col_name => $col_value) {
$filter_options[$col_name] = $col_name;
}
//execute only once
break;
}
include_once 'includes/header.php';
?>
<!--Main container start-->
<div id="page-wrapper">
<div class="row">
<div class="col-lg-6">
<h1 class="page-header">Energoresursu pārvaldības panelis</h1>
</div>
</div>
<?php include('./includes/flash_messages.php') ?>
<!-- Begin filter section-->
<div class="well filter-form">
<form class="form form-inline" action="">
<label for ="input_order">Izvēlies iestādi</label>
<select name="filter_col" class="form-control">
<?php //kods ?>
</select>
<label for ="input_order">Izvēlies gadu</label>
<select name="filter_col" class="form-control">
<?php //kods ?>
</select>
<label for ="input_order">Izvēlies mēnesi</label>
<select name="filter_col" class="form-control">
<?php //kods ?>
</select>
<input type="submit" value="Go" class="btn btn-primary">
</form>
</div>
<hr>
<div>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th class="header">#</th>
<th>Iestāde</th>
<th>Gads</th>
<th>Mēnesis</th>
<th>Siltumenerģija (MWh)</th>
<th>Elektroenerģija (KWh)</th>
<th>Ūdens un kanalizācija (m3)</th>
<th>Dabasgāze (m3)</th>
<th>Dīzeļdegviela (l)</th>
<th>Malka (ster)</th>
<th>Atkritumi (m3)</th>
</tr>
</thead>
<tbody>
<?php foreach ($energoresurs as $row) : //šeit man arī'vajadzētu ielikt mainīgo $iestade, bet pēc sintakses tas nebūtu pareizi?>
<tr>
<td><?php echo $row['id'] ?></td>
<td><?php echo htmlspecialchars($row['i_name']) ?></td>
<td><?php echo htmlspecialchars($row['gads']) ?></td>
<td><?php echo htmlspecialchars($row['menesis']) ?></td>
<td><?php echo htmlspecialchars($row['s_energ']) ?></td>
<td><?php echo htmlspecialchars($row['e_energ']) ?></td>
<td><?php echo htmlspecialchars($row['udens_k']) ?></td>
<td><?php echo htmlspecialchars($row['dgaze']) ?></td>
<td><?php echo htmlspecialchars($row['ddegviela'])?></td>
<td><?php echo htmlspecialchars($row['malka']) ?></td>
<td><?php echo htmlspecialchars($row['atkritumi'])?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="text-center">
<?php
if (!empty($_GET)) {
unset($_GET['page']);
$http_query = "?" . http_build_query($_GET);
} else {
$http_query = "?";
}
if ($total_pages > 1) {
echo '<ul class="pagination text-center">';
for ($i = 1; $i <= $total_pages; $i++) {
($page == $i) ? $li_class = ' class="active"' : $li_class = "";
echo '<li' . $li_class . '><a href="management.php' . $http_query . '&page=' . $i . '">' . $i . '</a></li>';
}
echo '</ul></div>';
}
?>
</div>
</div>
<!--Main container end-->
<?php include_once './includes/footer.php'; ?>