<?php

if(!isset($_SESSION)) {  session_start();  } 
include("DMMYSQLG.php");
include("DSA1000.php");
//include("DMMYSQLG.php");
//include("DFJSISCI.inc");
include ("varfun.php");
include("DF80000.php"); 
include("JQUERY.inc");
echo ' ';
echo '<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>';
if(isset($_POST['bot']) && $_POST['bot']==""){
    include("caj_checkout_MI.php");
}else{
  	$fecha1 = (isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:"";
	$fecha = chfecha($fecha1,'Y-m-d','d/m/Y');
        $datesys=$dt_empres['fec_alta'];
        $nueva=(isset($_POST['bot']))?$_POST['bot']:"";
	$d1=mysqli_query($con ,"select sum(suma) as suma from valeryus19 where n_reg='".$nueva."' ");
	$suma=mysqli_fetch_array($d1);
	$r = $suma["suma"];
        
	//echo $nueva;
	$info = mysqli_query($con ,"select * from valeryus19 where n_reg = '".$nueva."'");
    $iqjhd = mysqli_fetch_array($info);	
	
	$ksjdi = $iqjhd['fnumcto'];
	
	$hab=mysqli_real_escape_string($con,$ksjdi);

    $hab_tranza=mysqli_fetch_array(mysqli_query($con ,"SELECT count(*) as numRows, ptventa.np_desc1 as ptVta from ctmesas 
		left join ptventa on (ptventa.nparte1=ctmesas.descripcion) 
		left join ctarea on (ctarea.nparte1=ctmesas.area)
		left join fpos on (fpos.mesa=ctmesas.nparte1)
		left join fcomhues on (fcomhues.fol_ven=fpos.fol_ven)
		where ctmesas.status=1 and fpos.status=1 and no_hab='$hab'"));
	
	//if($hab_tranza['numRows']>0){
		//  		$xxx=1;
			//	include('caj_checkout_ME.php'); 
				
		//		}
	//else
	if ($r==0){ 
				
        $sql = mysqli_query($con ,"UPDATE valeryus19 SET fmuncto='$ksjdi', status='HISTORICO', fususali='".$_SESSION['usuario']."', fhorasalid='".date('H:i:s')."', tus='OUT', fecha_real='".date('Y-m-d')."', ffecsalida='$datesys', fnumcto='' WHERE n_reg='".$nueva."'");
		
		$dqwer = mysqli_query($con ,"update valeryus08 set ocupado='#FF0000', nstaamalla='SUCIO', nstarecep='VACIO', status='VACIO' where ncto='$ksjdi'");
		 
		   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
	require_once("caj_checkout_FAC.php");
		
		//$_SESSION['base']='JACARANDAS_ADMIN';
		$params[]="noCache=".date('dmyhis');
		$params[]="t1=".'A'.$iqjhd['n_reg']."";
		$params[]="rd=1";
		$data="?".implode("&",$params);				
		
		//echo '<meta content="0; url=/JACARANDAS-ADM/DV61000_PR.php'.$data.'"  HTTP-EQUIV="REFRESH">';	   
		   
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++		   
		   //include("caj_checkout_MO.php");
		   // include("caj_checkout_CH.php");  
		   
		   ?>
	
	
	<form action="" name="frm1" method="post" onmouseout="openpage('caj_checkout_PR.php','_self');" > 
		<input name="bot" type="hidden"  value="<?php
 echo $nueva; ?>"/>
		<input name="imprct" type="hidden" value="impcrt" onclick="openpage('caj_checkout_CH1.php','_self')" />
		<!--<div align="center"><span class="Estilo22">&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;&iexcl; REGISTRO SALDADO !!!!!!!!</span></div>--> 
		</form>
			<script language='javascript'>
			openpage('caj_checkout_CH1.php','_self');
			document.frm1.submit();
			</script>
<?php
			//echo '<meta content="5; url=caj_checkout_PR.php"  HTTP-EQUIV="REFRESH">';
	}else{
	$xxx=2;
include('caj_checkout_ME.php'); 
/*	echo "	<script language='javascript'>
			alert('ES NECESARIO SALDAR LA CUENTA');
			</script>";	*/
	}
}			

?> 