<?php

class RegProduccion
{
  private $lis_regproduccion=array();
  private $lis_regproduccion_reg=array();
   private $sum_regproduccion_per=array();
  
  public function listar_regproduccion_per($con,$dni,$anno,$mes)
	{
		$sql="SELECT date_format(regp_fecha,'%d/%m/%Y') as fecha, a.regp_fecha as fecha2, p_dni as dni, (select a_desc from tb_area where a_id = a.a_id) as area, (select act_desc from tb_actividad where act_id=a.act_id) as actividad,a.h_id as idh ,(select h_horario from tb_horario where h_id=a.h_id) as horario, (select th_desc from tb_tipohora where th_id = a.th_id) as tipohora, regp_cant as numpac FROM tb_regproduccion a where a.p_dni='$dni' and year(a.regp_fecha)='$anno' and month(a.regp_fecha)='$mes' order by fecha asc";
		$res=mysqli_query($con, $sql);
		while ($reg=mysqli_fetch_assoc($res))
		{
			$this->lis_regproduccion[]=$reg;
		}
			return $this->lis_regproduccion;
	}
  
  public function listar_regproduccion_reg($con,$dni,$fecha,$idh)
	{
		$sql="SELECT regp_fecha as fecha, p_dni as dni, (select a_desc from tb_area where a_id = a.a_id) as area, (select act_desc from tb_actividad where act_id=a.act_id) as actividad, (select h_horario from tb_horario where h_id=a.h_id) as horario, (select th_desc from tb_tipohora where th_id = a.th_id) as tipohora, regp_cant as numpac FROM tb_regproduccion a where p_dni='$dni' and regp_fecha='$fecha' and h_id='$idh'";
		$res=mysqli_query($con, $sql);
       
		while ($reg=mysqli_fetch_assoc($res))
		{
			$this->lis_regproduccion_reg[]=$reg;
		}
			return $this->lis_regproduccion_reg;
	}
  
  
  public function registrar_regproduccion($con, $dni, $fecha, $idh,$ida,$idact, $idth, $numpac){
    
    $sql="insert into tb_regproduccion (regp_fecha,p_dni,a_id,act_id,h_id,th_id,regp_cant) values('$fecha','$dni','$ida','$idact','$idh','$idth','$numpac')";
    //echo $sql;
		$res=mysqli_query($con, $sql);
  }
  
    public function suma_hrs_regproduccion_per($con,$dni,$anno,$mes){
    
    $sql="SELECT (select a_desc from tb_area where a_id = a.a_id) as area, (select act_desc from tb_actividad where act_id=a.act_id) as actividad,sum((select h_hrs from tb_horario where h_id=a.h_id)) as tthrs, (select th_desc from tb_tipohora where th_id = a.th_id) as tipohora, sum(regp_cant) as ttnumpac FROM tb_regproduccion a where a.p_dni='$dni' and year(a.regp_fecha)='$anno' and month(a.regp_fecha)='$mes' group by actividad,tipohora order by area asc";
    //echo $sql;
		$res=mysqli_query($con, $sql);
      while ($reg=mysqli_fetch_assoc($res))
		{
			$this->sum_regproduccion_per[]=$reg;
		}
			return $this->sum_regproduccion_per;
  }

}

?>