Commit 3e0f5985 authored by Gabriel Moreau's avatar Gabriel Moreau
Browse files

* Clean code and generic loan select

parent 88c6c876
......@@ -5,7 +5,6 @@ $web_page = true;
// Authenticate
require_once('module/auth-functions.php');
require_once('module/html-functions.php');
require_once('module/base-functions.php');
session_start();
if (empty($_SESSION['logged_user'])) {
......@@ -16,9 +15,6 @@ if (empty($_SESSION['logged_user'])) {
$logged_level = $_SESSION['logged_level'];
}
// recupere l'equipe
$eq = param_get('equipe');
en_tete('Liste des prêts');
?>
......@@ -50,17 +46,12 @@ en_tete('Liste des prêts');
?>
</tr>
<?php // interrogation base de donnees
<?php
if ($pdo = connect_db()) {
// recupere la liste de appareils
$sql = 'SELECT * FROM pret;';
$stmt = $pdo->prepare($sql);
$stmt->execute();
$pret = $stmt->fetchAll(PDO::FETCH_ASSOC);
$loan_fetch = get_loan_listall($pdo);
$num_line = 1;
foreach ($pret as $data) {
foreach ($loan_fetch as $data) {
if ($num_line % 2)
echo '<tr class="impair">'.PHP_EOL;
else
......
......@@ -131,6 +131,16 @@ function get_category_by_id($pdo, $id) {
// ---------------------------------------------------------------------
function get_loan_listall($pdo) {
$sql = 'SELECT * FROM pret;';
$stmt = $pdo->prepare($sql);
$stmt->execute();
$result_fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $result_fetch;
}
// ---------------------------------------------------------------------
function get_supplier_by_id($pdo, $id) {
$sql = 'SELECT id, nom FROM fournisseurs WHERE id = ?;';
$stmt = $pdo->prepare($sql);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment