<?php $pack = 'historique-user'; //$data['liensCSS']->add($pack, 'style02.css'); $page['path'] = $path['ressources'] . $pack . '/'; $data['namepage'] = 'Historique'; //$id_media = $_GET['id']; // Fil d'Ariane -- $data['navi']->add('?user=historique', 'Historique'); $page['medias'] = ModelMedia::getTrace($visiteur['id']);
if (isset($_GET['type'])) { $recherche->byType($_GET['type']); } if (isset($_GET['categorie'])) { $recherche->byCat($_GET['categorie']); } if (isset($_GET['nom'])) { $recherche->byName($_GET['nom']); } if (isset($_GET['auteur'])) { $recherche->byAuthor($_GET['auteur']); } if ($critere) { $listeMedia = $recherche->getAll(); } else { $listeMedia = ModelMedia::getAll(); } /* $page['medias'] = array(); foreach($listeMedia as $media) { $nouveauMedia = new Media($media); array_push($page['medias'], $nouveauMedia); }*/ $reqSELECT = $bdd->query("SELECT m.id_media, m.id_categorie, m.id_type, m.id_admin, m.titre_media, m.isbn_media, " . "m.resume_media, m.empruntable_media, m.nom_image FROM medias m WHERE m.empruntable_media=1"); $donnees = $reqSELECT->fetchAll(); $errorNumber = 0; $disabled = ''; if (isset($_GET['err'])) { if (!empty($_GET['err'])) { $errorNumber = intval($_GET['err']);
if (isset($_POST['finalList']) && count($_POST['finalList']) > 0) { $_SESSION['panier'] = array_diff($_SESSION['panier'], $_POST['finalList']); } } } if (isset($_POST['mediaList']) && count($_POST['mediaList']) > 0) { $page['panier'] = array(); if (!isset($_SESSION['panier']) && count($_SESSION['panier']) == 0) { $_SESSION['panier'] = array(); } foreach ($_POST['mediaList'] as $idMedia) { $media = ModelMedia::getAll($idMedia); $nouveauMedia = new Media(current($media)); array_push($page['panier'], $nouveauMedia); array_push($_SESSION['panier'], $idMedia); } if (count($page['panier']) > 0) { if (count($page['panier']) > 3) { $_SESSION['panier'] = array(); header('Location:?user=catalogue&err=100'); } } } if (isset($_SESSION['panier']) && count($_SESSION['panier']) > 0) { $page['panier'] = array(); foreach ($_SESSION['panier'] as $idMedia) { $media = ModelMedia::getAll($idMedia); $nouveauMedia = new Media(current($media)); array_push($page['panier'], $nouveauMedia); } }
function _init() { self::$relationships = array('post' => ORM::has_many('\\Model\\Post\\Media => \\Model\\Post'), 'file' => ORM::belongs_to('\\Model\\File')); self::$fields = array('id' => ORM::field('auto[11]'), 'file_id' => ORM::field('numeric', array(), 'INT'), 'type' => ORM::field('string', array('required'), 'ENUM'), 'span' => ORM::field('numeric', array(), 'INT'), 'alt' => ORM::field('char[3,55]', array('required', 'max_length[55]')), 'modified' => ORM::field('datetime'), 'created' => ORM::field('datetime')); $this->ts_fields = array('modified', '[created]'); }
static function setEmprunts($list) { global $visiteur; global $bdd; $retour = array('valeur' => true, 'message' => 'Enegistrements effectués.'); $i = 0; $listeSec = array(); foreach ($list as $element) { $emprunt = ModelMedia::getAll($element); if (empty($emprunt)) { $retour['message'] = "Ce média n'existe pas !"; } else { if ($i < 3) { array_push($listeSec, $element); $i++; } else { $retour['message'] = "Trop d'emprunts!"; } } } $bdd->beginTransaction(); $lastReservationId = ModelMedia::insertReservation($visiteur['id']); foreach ($list as $element) { $last = ModelMedia::getLastFreeMediaId($element); if (empty($last)) { $retour['message'] = "Aucun exemplaire de libre pour ce média!"; } else { ModelMedia::createLink($last, $lastReservationId); } } $bdd->commit(); return $retour; }
//$data['liensJS']->add('global-user', 'script01.js'); // Fil d'Ariane -- $data['navi']->add('?user', 'Espace utilisateur'); // -- Emprunts -- require_once $path['models'] . 'Media.php'; $page['empruntsFixes'] = ModelMedia::getEmprunts($visiteur['id']); $number = count($page['empruntsFixes']); $page['empruntsSession'] = array(); for ($i = 0; $i < 3; $i++) { if (isset($_SESSION['el' . ($i + 1)])) { $id = intval($_SESSION['el' . ($i + 1)]); $emprunt = ModelMedia::getAll($id); if (empty($emprunt)) { echo "Ce média n'existe pas !"; } else { $last = ModelMedia::getLastFreeMediaId($id); if (empty($last)) { echo "Aucun exemplaire de libre pour ce média!"; } else { if ($number < 3) { array_push($page['empruntsSession'], $emprunt[0]); $number++; } else { echo "Trop d'emprunts !"; } } } } } // echo '<pre>'; //print_r($page['empruntsFixes']);