<?php

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

//class Area extends Conectar
class Servicio
{

	private $b_serv=array();
  private $b_servxidj=array();
	private $b_servxids=array();
	private $b_uservxidj=array();


		public function buscar_servicio($con,$nom)
		{
			$sql="select s_id as ids, j_id as idj, s_abrev as abrev,
			s_desc as nom from tb_servicio where s_desc like '%$nom%'";
			$res=mysqli_query($con, $sql);
				while ($reg=mysqli_fetch_assoc($res))
				{
					$this->b_serv[]=$reg;
				}
					return $this->b_serv;
		}

		public function buscar_servicioxidj($con,$idj)
		{
			$sql="select s_id as ids, j_id as idj, s_abrev as abrev,
			s_desc as nom from tb_servicio where j_id = '$idj' order by s_desc asc";

			$res=mysqli_query($con, $sql);
				while ($reg=mysqli_fetch_assoc($res))
				{
					$this->b_servxidj[]=$reg;
				}
					return $this->b_servxidj;
		}

		public function buscar_servicioxidsxidj($con,$idj,$ids)
		{
			$sql="select s_id as ids, j_id as idj, s_abrev as abrev,
			s_desc as nom from tb_servicio where j_id = '$idj' and s_id='$ids' order by s_desc asc";
			$res=mysqli_query($con, $sql);
				while ($reg=mysqli_fetch_assoc($res))
				{
					$this->b_servxids[]=$reg;
				}
					return $this->b_servxids;
		}

		public function buscar_ultimoidsxidj($con,$idj)
		{
			$sql="select s_id as ids, j_id as idj, s_abrev as abrev,
			s_desc as nom from tb_servicio where j_id = '$idj' order by s_id desc limit 1";
			$res=mysqli_query($con, $sql);
				while ($reg=mysqli_fetch_assoc($res))
				{
					$this->b_uservxidj[]=$reg;
				}
					return $this->b_uservxidj;
		}

		public function registrar_servicio($con,$idj,$ids,$nom,$abrev)
		{
			$sql ="insert into tb_servicio value('$ids','$idj',upper('$abrev'),upper('$nom'))";
			//echo $sql;
			$res=mysqli_query($con, $sql);
		}


    public function modificar_servicio($con,$idj,$ids,$nom,$abrev)
		{
			$sql ="update tb_servicio set s_desc= upper('$nom'), s_abrev = upper('$abrev')
      where j_id='$idj' and s_id='$ids'";
			$res=mysqli_query($con, $sql);
		}


		public function eliminar_idhxarea($con,$idj,$ids)
		{
			$sql="delete from tb_servicio where j_id='$idj' and s_id='$ids'";
			$res=mysqli_query($con, $sql);
		}


	}

?>
