<?php

//Clase de Paises
class clase
{
  	var $nom_tabla = 'valeryus19';
  	var $n_reg;
	var $fcodtarifa;
	var $fnumres;
	var $fnumcto;
	var $fnumctos;
	var $fnumadu;
	var $fnummenor;
	var $ffecllegada;
	var $ffecsalida;
	var $ffecalt;
	var $status;
	var $estact;
	var $ftipocto;
	var $fnum;
	//datos
	var $fcodgrupo;
	var $fcodagen;
	var $fcodmeca;
	var $fplan;
	var $smerf;
	var $fnorasvip;
	var $fhorallega;
	var $codseg;
	
	//forma de pago
	var $fformpago;
	var $fnumtar;
	var $fsaldo;
	var $flimite;
	var $fcodseg;
	var $fdeposito;
	//direccion
	var $fnombre;
	var $fapellido;
	var $flengua;
	var $fempresa;
	var $ftelefono;
	var $fvip;
	var $femail;
	var $fmail;
	var $fdireccion;
	var $fgntd;
	var $fcp;
	var $fpais;
	var $festado;
	var $fciudad;
	var $fvehiculo;
	var $fplacas;
	var $ftelemp;
	//extras
	var $fnumadulx;
	var $fnummenorx;
	var $ftarifaxa;
	var $ftarifaxm;
	var $fmonadu;
	var $fmonmen;
	
	
	
	
	
	
	
	
	var $fhabitacion;
	var $tipo;
	
	
//Funcion de Revicion
	function revisar(){
		$sql = "SELECT * FROM $this->nom_tabla WHERE n_reg = '$this->n_reg' or n_reg = '$this->n_reg'";
	   	$result = mysqli_query($con ,$sql);
	   	$num_salidas=mysqli_num_rows($result); 
		if($num_salidas>=1){
			return "ok";
		}else{
			$error = 'Error N:' . mysqli_errno($con) . ": " . mysqli_error($con);
			return "$error()";  
		}
	}
//Funcion de Agregar
	function agregar(){
		$sql = "insert into $this->nom_tabla (fnombre)VALUES('$this->fnombre')";
//$sql = "insert into $this->nom_tabla (n_reg, fnumres, fcodtarifa, fnumcto, ffecllegada, ffecsalida, fnumadu, fnummenor, fcodgrupo, fcodagen, fcodmeca, fplan, smerf, fnorasvip, fnombre, fapellido, flengua, fempresa, ftelefono, fvip, femail, fmail, fdireccion, fformpago, fnumtar, fsaldo, flimite, fcodseg, fgntd, fcp, fpais, festado, fciudad, fnumadulx, fnummenorx, ftarifaxa, ftarifaxm, fmonadu, fmonmen, fdeposito, fhorallega, fnumctos, ffecalt, status, estact, fvehiculo, fplacas, ftelemp, codseg, ftipocto, fnum, tipo, ftiphuesped, con_1)values('$this->n_reg','$this->fnumres','$this->fcodtarifa','$this->fnumcto','$this->ffecllegada','$this->ffecsalida','$this->fnumadu','$this->fnummenor','$this->fcodgrupo','$this->fcodagen','$this->fcodmeca','$this->fplan','$this->smerf','$this->fnorasvip','$this->fnombre','$this->fapellido','$this->flengua','$this->fempresa','$this->ftelefono','$this->fvip','$this->femail','$this->fmail','$this->fdireccion','$this->fformpago','$this->fnumtar','$this->fsaldo','$this->flimite','$this->fcodseg','$this->fgntd','$this->fcp','$this->fpais','$this->festado','$this->fciudad','$this->fnumadulx','$this->fnummenorx','$this->ftarifaxa','$this->ftarifaxm','$this->fmonadu','$this->fmonmen','$this->fdeposito','$this->fhorallega','$this->fnumctos','$this->ffecalt','$this->status','$this->estact','$this->fvehiculo','$this->fplacas','$this->ftelemp','$this->codseg','$this->ftipocto','$this->fnum', '$this->tipo', '$this->ftiphuesped', '$this->con_1')";		
	   	$result = mysqli_query($con ,$sql);
		if ($result){
			return "ok";
		}else{
			$error = 'Error N:' . mysqli_errno($con) . ": " . mysqli_error($con);
			return "$error()";  
		}
	}
//Funcion de Lista Completa
	function lista_completa(){
		$sql= "SELECT * FROM $this->nom_tabla";
		$lista = mysqli_query($con ,$sql);
		if ($lista){
			return $lista;
		}else{
			$error = 'Error N:' . mysqli_errno($con) . ": " . mysqli_error($con);
			return "$error()";  
		}
	}
//Funcion de Lista con Busqueda
	function lista_busqueda($n_reg){
		$sql= "SELECT * FROM $this->nom_tabla WHERE n_reg = '$n_reg'";
		$lista = mysqli_query($con ,$sql);
		if ($lista){
			return $lista;
		}else{
			$error = 'Error N:' . mysqli_errno($con) . ": " . mysqli_error($con);
			return "$error()";   
		}
	}
//Funcion de Modificar
	function modificar($n_reg){
		$sql = "UPDATE $this->nom_tabla SET fnumres = '$this->fnumres',fcodtarifa = '$this->fcodtarifa',fnumcto= '$this->fnumcto', ffecllegada= '$this->ffecllegada', ffecsalida= '$this->ffecsalida', fnumadu= '$this->fnumadu', fnummenor= '$this->fnummenor', fcodgrupo= '$this->fcodgrupo', fcodagen= '$this->fcodagen', fcodmeca= '$this->fcodmeca', fplan= '$this->fplan', smerf= '$this->smerf', fnorasvip= '$this->fnorasvip', fnombre= '$this->fnombre', fapellido= '$this->fapellido', flengua= '$this->flengua', fempresa= '$this->fempresa', ftelefono= '$this->ftelefono', fvip= '$this->fvip', femail= '$this->femail', fmail= '$this->fmail', fdireccion= '$this->fdireccion', fformpago= '$this->fformpago', fnumtar= '$this->fnumtar', fsaldo= '$this->fsaldo', flimite= '$this->flimite', fcodseg= '$this->fcodseg', fgntd= '$this->fgntd', fcp= '$this->fcp', fpais= '$this->fpais', festado= '$this->festado', fciudad= '$this->fciudad', fnumctos= '$this->fnumctos', status= '$this->status', fplacas= '$this->fplacas', fvehiculo= '$this->fvehiculo', ftelemp= '$this->ftelemp', ftipocto= '$this->ftipocto', fnum= '$this->fnum' where n_reg = '$n_reg' ";
		$result= mysqli_query($con ,$sql);
		if($result){
			return "ok";
		}else{
			$error = 'Error N:' . mysqli_errno($con) . ": " . mysqli_error($con);
			return "$error()"; 
		}
	}
//Funcion de eliminar
	function eliminar($n_reg){   
		$sql = "UPDATE valeryus19 set cancelado = 1  WHERE n_reg = '$n_reg'";
		$resultado = mysqli_query($con ,$sql);
		if($resultado){
			return "ok";
		}else{
			$error = 'Error N:' . mysqli_errno($con) . ": " . mysqli_error($con);
			return "$error()"; 
		}           
	}   
}       
?>