<?php

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

//class TipoPersonal extends Conectar
class TipoPersonal
{

	private $l_tp1=array();
	private $b_tp1=array();
	private $b_utp=array();

	public function listar_tipopersonal($con)
	{
		$sql="select tp_id as id, tp_desc as nom, tp_codgh as codgh from
		tb_tipoperson order by tp_desc asc";
		$res=mysqli_query($con, $sql);
		while ($reg=mysqli_fetch_array($res))
		{
			$this->l_tp1[]=$reg;
		}
			return $this->l_tp1;
	}

	//buscar_tipoperso
	public function buscar_tipopersonalxid($con,$idtp)
	{
		$sql="select tp_id as id, tp_desc as nom, tp_codgh as codgh from
		tb_tipoperson where tp_id='$idtp' order by tp_desc asc";
		$res=mysqli_query($con, $sql);
		while ($reg=mysqli_fetch_array($res))
		{
			$this->b_tp1[]=$reg;
		}
			return $this->b_tp1;
	}

	public function buscar_ultimoidtp($con)
	{

		$sql="select tp_id as id, tp_desc as nom, tp_codgh as codgh from
		tb_tipoperson order by tp_id desc limit 1";
		$res=mysqli_query($con,$sql);
		while ($reg=mysqli_fetch_array($res))
		{
			$this->b_utp[]=$reg;
		}
			return $this->b_utp;
	}

	public function registrar_tipopersonal($con,$idtp, $nom, $codsgh)
	{
		$sql="insert into tb_tipoperson value ('$idtp',upper('$nom'),'$codsgh')";
		//echo $sql;
		$res=mysqli_query($con, $sql);
	}

	public function modificar_tipopersonal($con,$idtp, $nom, $codsgh)
	{
		$sql="update tb_tipoperson set tp_desc = upper('$nom'), tp_codgh='$codsgh'
		where tp_id = '$idtp'";
		//echo $sql;
		$res=mysqli_query($con, $sql);
	}

	public function eliminar_tipopersonal($con,$idtp)
	{
		$sql="delete from tb_tipoperson where tp_id='$idtp'";
		$res=mysqli_query($con, $sql);
	}


}
?>
