public function action_ajaxmod() { if ($this->req->name) { $db = DB::get_instance(); $mm = new ModeleManager($db); $vm = new VoitureManager($db); $lm = new LocationManager($db); $mod = $mm->getByName($this->req->name); if ($mod) { $listecar = $vm->listing($mod->getIdModele()); $i = 0; $open = false; if ($this->session->ouverte()) { $open = true; } if (!$listecar) { $tab = "undefined"; } foreach ($listecar as $car) { if ($lm->isAvailable($car->getIdVoiture())) { $tab[$i]['disp'] = true; //Test si dans la voiture parcouru est disponible. } else { $tab[$i]['disp'] = false; } $tab[$i]['id'] = $car->getIdVoiture(); $tab[$i]['annee'] = $car->getAnnee(); $tab[$i]['km'] = $car->getKm(); $tab[$i]['description'] = $car->getDescription(); if ($open) { $tab[$i]['open'] = true; } else { $tab[$i]['open'] = false; } $i++; } echo json_encode($tab); exit; } else { Site::redirect('loc'); } } else { Site::redirect('loc'); } }
public function action_ajax() { // Pour afficher les voitures quand on clique sur un modèle if ($this->req->id) { $vm = new VoitureManager(DB::get_instance()); $liste = $vm->listing($this->req->id); $i = 0; $tab = array(); foreach ($liste as $car) { $tab[$i]['idVoiture'] = $car->getIdVoiture(); $tab[$i]['annee'] = $car->getAnnee(); $tab[$i]['km'] = $car->getKm(); $tab[$i]['description'] = $car->getDescription(); $i = $i + 1; } echo json_encode($tab); exit; } else { Site::redirect('index'); } }