<?php 

class Model_reservations extends CI_Model {	
	public function getDate(){
		$sql = 'SELECT date(NOW()) AS DNESOK';
		$query= $this->db->query($sql);
		return $query->row();
	}	
	
	public function getIDActiveVehicles(){
		$sql = 'SELECT vozidlo.ID_VOZ, vozidlo.Nazov, vozidlo.Pocet_miest FROM vozidlo WHERE vozidlo.Status_vozidla=1 ORDER BY Pocet_miest';
		$query= $this->db->query($sql);
		return $query->result();	
	}
	
	public function getInventoryInfoByDay($id_voz,$date){
	$sql = 'SELECT rezervacia.ID_INV, zakaznik.Mesto FROM rezervacia 
			LEFT JOIN inventura ON rezervacia.ID_INV=inventura.ID_INV 
			LEFT JOIN zakaznik ON zakaznik.ID_Zakaznik=inventura.ID_Zakaznika
			WHERE ID_VOZ='.$id_voz.' AND date(inventura.Datum_zaciatku)<="'.$date.'" AND date(inventura.Datum_konca)>="'.$date.'"';	
	$query= $this->db->query($sql);
	if ($query->num_rows()==0){
		return FALSE;
	} else {
		return $query->row();
	}
	}
	
	}

		
