<?php

//require_once("class.conectar.php");

//class Area extends Conectar
class Modelo
{

	private $b_idv=array();


		public function buscar_vacaciones($con, $ugid)
		{
			$sql="select v_id as id, ug_id as ugid, v_periodo as per,
			  v_fechaini as fechaini, v_fechafin as fechafin, v_numdias as ndias,
				v_estado from tb_vacaciones where ug_id='$ugid'";
			$res=mysqli_query($con, $sql);
				while ($reg=mysqli_fetch_assoc($res))
				{
					$this->b_idv[]=$reg;
				}
					return $this->b_idv;
		}


		public function buscar_ultimovacaciones($con,$ugid)
		{
			$sql="select v_id as id, ug_id as ugid, v_periodo as per,
			  v_fechaini as fechaini, v_fechafin as fechafin, v_numdias as ndias,
				v_estado from tb_vacaciones where ug_id='$ugid' order by v_id desc limit 1";
			$res=mysqli_query($con, $sql);
				while ($reg=mysqli_fetch_assoc($res))
				{
					$this->b_ult[]=$reg;
				}
					return $this->b_ult;
		}


		public function registrar_vacaciones($con,$idv,$ugid,$per,$fini,$ffin,$ndias,$est)
		{
			$sql ="insert into tb_vacaciones value('$idv','$ugid','$per','$fini','$ffin','$ndias','$est')";
			$res=mysqli_query($con, $sql);
		}


    public function modificar_vacaciones($con,$idv,$ugid,$per,$fini,$ffin,$ndias,$est)
		{
			$sql ="update tb_vacaciones set v_fechaini = '$fini', v_fechafin = '$ffin',
			v_numdias = '$ndias', v_estado = '$est' where v_id='$idv'
			and ug_id='$ugid' and v_periodo='$per'";
			$res=mysqli_query($con, $sql);
		}


		public function eliminar_vacaciones($con,$idv,$ugid)
		{
			$sql="delete from tb_vacaciones where ug_id='$ugid' and v_id='$idv'";
			$res=mysqli_query($con, $sql);
		}


	}

?>
