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

<?php
//$vars=(isset($_POST['submit']))?$_POST['submit']:"";
//$vart=(isset($_POST['tbus']))?$_POST['tbus']:"";
//$vart2=(isset($_POST['tbus2']))?$_POST['tbus2']:"";
$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'");
 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 cancelado='0' and (status='MISCELANEOS' or status='HUESPED' or (status='HISTORICO' and fecha_real='$fecha')) ORDER BY fnumcto desc");
 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 (isset($reg['tex4'])&&$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') and ($reg['fol_fac']!='')){
		echo '<td style="background:#FF9933"> <div align="center" style="background-color:$reg["almacen"]"><input name="bot" type="radio" value="'. $reg["n_reg"].'" disabled></div></td>';
			}else{
		echo '<td> <div align="center" style="background-color:$reg["almacen"]"><input name="bot" type="radio" value="'. $reg["n_reg"].'"></div></td>';
		}
		
		if ($reg['status']=='HISTORICO'){?>
		
		
		<td style="background:#FF9933;  "> <div align="center">
		<input name="imp" type="button" class="form" value="Imprimir" onClick="openpage('../caj_checkout_CH1.php?bat=<?php echo $reg["n_reg"]; ?>','_self')"></div></td>
	 <?php 
	 
	 
	 echo "<td width='73' style='background:#FF9933'> <div align='center'><strong>A" . $reg["n_reg"] . "</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='202' style='background:#FF9933'> <div align='center'><strong>". $reg["fmuncto"] ."</strong></div></td>";
		echo "<td width='405' 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["suma"] . "</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>";
		echo "<td style='background:#FF9933' width='235'> <div align='center'><strong>".($reg['fol_fac']!=""?($reg['fol_fac']."-".$f_f):"&nbsp;")."</strong></div></td>";
		}else{
		
		if($reg["suma"]<'0'){
		echo "<td width='73'> <div align='center' style='color:#FF0000'><h5>A" . $reg["n_reg"] . "</h5></div></td>";
		}else{
		echo "<td width='73'> <div align='center' style=' '><h5>A" . $reg["n_reg"] . "</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>';
		}
		
		
		if($reg["suma"]<'0'){
		echo "<td width='202'> <div align='center' style='color:#FF0000'><h5>" . $reg["fnumcto"] . "</h5></div></td>";
		echo "<td><div align='center' style='color:#FF0000'><a style=\"text-decoration:underline;cursor:pointer;\" onclick=\"openpage('../caj_checkout_AG-DET.php?bot=".$reg['n_reg']." ','_self')\"><h5>" . $reg["fapellido"] . ' '. $reg["fnombre"] . "</h5></div></a></td>";
		echo "<td width='135'> <div align='center' style='color:#FF0000'><h5>" . $reg["suma"] . "</h5></div></td>";
		$fec1=$reg["ffecllegada"];
		include('DF20000.php');
		echo "<td width='135'> <div align='center' style='color:#FF0000'><h5>" . $f_f . "</h5></div></td>";
		$fec1=$reg["ffecsalida"];
		include('DF20000.php');
		echo "<td width='135'> <div align='center' style='color:#FF0000'><h5>" . $f_f . "</h5></div></td>";
		echo "<td width='135'> <div align='center' style='color:#FF0000'><h5>" . $tar . "</h5></div></td>";
		}else{
		echo "<td width='202'> <div align='center' style=' '><h5>" . $reg["fnumcto"] . "</h5></div></td>";
		echo "<td><div align='center' style=' '><a style=\"text-decoration:underline;cursor:pointer;\" onclick=\"openpage('../caj_checkout_AG-DET.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["suma"] . "</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>";
		}
		
		
		
		
		
		echo "<td style=' ' width='235'> <div align='center'><strong>".($reg['fol_fac']!=""?($reg['fol_fac']."-".$f_f):"&nbsp;")."</strong></div></td>";
		}
		echo "</tr>";
                print_r($f_f);
	}
	mysqli_close($con);   
	?>
	</table>