<?php
 
session_start();
include("DMMYSQLG.php");
?>
<table width="1050" border="0">

<?php

$fecha = $dt_empres['fec_alta'];
echo '<input name="txt_bus" type="hidden" value="'.$_REQUEST['tbus'].'">';
if($_POST['tbus']!=""){
echo '<input name="txt_t1" type="hidden" value="'.$_POST['tbus'].'">';
 @$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE (fnumcto='".$_POST['tbus']."' and (status = 'HUESPED' or status='MISCELANEOS')) or (fmuncto='".$_POST['tbus']."' and status = 'HISTORICO' AND fecha_real = '$fecha') and cancelado='0' ORDER BY fnumcto");
 echo mysqli_error($con);

}elseif($_POST['tbus2']!=""){
 @$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE (fapellido like '%".$_POST['tbus2']."%' and (status = 'HUESPED' or status='MISCELANEOS')) or (status='HISTORICO' and fapellido like '%".$_POST['tbus2']."%' and fecha_real = '$fecha') and cancelado='0' ORDER BY fapellido");
 echo '<input name="txt_bus" type="hidden" value="'.$_POST['tbus'].'">';

}elseif($_POST['tbus']=="" && $_POST['tbus']=="" && $_POST['tbus']==""){
 @$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE (status='HUESPED' or status='MISCELANEOS') or (status='HISTORICO' and fecha_real='$fecha') and cancelado='0' ORDER BY fnumcto asc");
 echo '<input name="txt_bus" type="hidden" value="'.$_POST['tbus'].'">';
}
	echo mysqli_error($con);
	while($reg = mysqli_fetch_array($sql)){
	  	echo "<tr>";
		$fotografia = '../foto/valeryus19/NO_'. $reg["n_reg"] .'.JPG';
		if ($reg['tex4']!=0)
				$tar="" .$reg['tex']."-".$reg['tex4']."";
			else if ($reg['text4']!=0)
			  $tar="".$reg['text1']."-".$reg['text4']."";	
			else if (($reg['tex']!=0)&&($reg['text4']!=0))  
				$tar="" .$reg['tex']."-".$reg['tex4']." | ".$reg['text1']."-".$reg['text4']."";
			else 
			$tar="";
		if ($reg['status']=='HISTORICO'){
		echo '<td width="49" style="background:#FF9933"> <div align="center"><input name="bot" type="radio" value="'.$reg["n_reg"].'" disabled></div></td>';
		echo "<td width='73' style='background:#FF9933'> <div align='center'><strong>" . $reg["n_reg"] . "</strong></div></td>";
		echo "<td width='202' style='background:#FF9933'> <div align='center'><strong>". $reg["fmuncto"] ."</strong></div></td>";
		if (file_exists($fotografia)) {
			echo '<td class="inputcodigo" width="91"><div align="center"><img src="../foto/valeryus19/NO_'.$reg["n_reg"].'.JPG" width="32" height="40">&nbsp</div></td>';
		}else{
			echo '<td class="inputcodigo" width="91"><div align="center"><img src="../foto/Sin_Foto.jpg" width="40" height="40">&nbsp</div></td>';
		}
		echo "<td width='305' style='background:#FF9933'> <div align='center'><strong>" . $reg["fapellido"] . ' '. $reg["fnombre"] . "</strong></div></td>";
		echo "<td width='135' style='background:#FF9933'> <div align='center'><strong>" . $reg["status"] . "</strong></div></td>";
		$fec1=$reg["ffecllegada"];
		include('DF20000.php');
		echo "<td width='135' style='background:#FF9933'> <div align='center'><strong>" . $f_f . "</strong></div></td>";
		$fec1=$reg["fecha_real"];
		include('DF20000.php');
		echo "<td width='135' style='background:#FF9933'> <div align='center'><strong>" . $f_f . "</strong></div></td>";
		echo "<td width='135' style='background:#FF9933'> <div align='center'><strong>" . $tar . "</strong></div></td>";
		}else{
		echo '<td width="49"> <div align="center"><input name="bot" type="radio" value="'.$reg["n_reg"].'"></div></td>';
		echo "<td width='73'> <div align='center' style=' '><h5>" . $reg["n_reg"] . "</h5></div></td>";
		
		if ($reg["folio"]=='EXTRAS'){
		echo "<td width='202'> <div align='center' style=' '><h5>EXTRA-" . $reg["fnumcto"] . "</h5></div></td>";
		}else{
		echo "<td width='202'> <div align='center' style=' '><h5>" . $reg["fnumcto"] . "</h5></div></td>";
		}
		
		if (file_exists($fotografia)) {
			echo '<td class="inputcodigo" width="91"><div align="center"><img src="../foto/valeryus19/NO_'.$reg["n_reg"].'.JPG" width="32" height="40">&nbsp</div></td>';
		}else{
			echo '<td class="inputcodigo" width="91"><div align="center"><img src="../foto/Sin_Foto.jpg" width="40" height="40">&nbsp</div></td>';
		}
		//echo "<td width='305'> <div align='center' style=' '><h5>" . $reg["fapellido"] . ' '. $reg["fnombre"] . "</h5></div></td>";
		echo "<td width='305'> <div align='center' style=' '> <a style=\"text-decoration:underline;cursor:pointer;\" onclick=\"openpage('../valeryus60000_MO.php?bot=".$reg['n_reg']." ','_self')\"><h5>" . $reg["fapellido"] . ' '. $reg["fnombre"] . "</h5></div></a></td>";
		echo "<td width='135'> <div align='center' style=' '><h5>" . $reg["status"] . "</h5></div></td>";
		$fec1=$reg["ffecllegada"];
		
                include('DF20000.php');
		echo "<td width='135'> <div align='center' style=' '><h5>" . $f_f . "</h5></div></td>";
		
                $fec1=$reg["ffecsalida"];
		include('DF20000.php');
		echo "<td width='135'> <div align='center' style=' '><h5>" . $f_f . "</h5></div></td>";
		echo "<td width='135'> <div align='center' style=' '><h5>" . $tar . "</h5></div></td>";
		print_r($f_f);
                
                }
		
		
	
		
		echo "</tr>";
                
	}
	mysqli_close($con);   
	?>
	</table>
