Beispiel #1
0
 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');
     }
 }