<?php
session_start();
include("DMMYSQLG.php");
require_once('DFJSISCI.inc');
include('JQUERY.inc');
require_once('DF80000.php');


if(isset($_SESSION['vendedor'])==false ||$_SESSION['vendedor']==''){
header("Location: $url_g");

}
 //var_dump($_SESSION);
 $dt_parame = mysqli_fetch_array(mysqli_query($con ,"SELECT * from dgparame"));
//var_dump($_SESSION); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="CMD2_PR.css?5" type="text/css"/>
<script type="text/javascript" language="javascript" src="DSSCRIPT.js?5"></script>
<script type="text/javascript" language="javascript" src="CMD2_PR.js?f"></script> 

<script language="javascript" type="text/javascript">function BuscarClave(){
   $( "#propi" ).dialog({
      
      show: { 
        effect: "blind",
        duration: 500
      },
      hide: {
        effect: "explode",
        duration: 200
      }
      
    });
  }
function BuscarClave2(){xpos=(screen.width/2)-400;ypos=(screen.height/2)-290;window.open("CALHAB02.php?tpo=2","","toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, width=800, height=500, left="+xpos+", top="+ypos)}function desactiva(){document.mainForm.prop.disabled=false;document.mainForm.hab.disabled=false}function desactiva2(){document.mainForm.rad_tip_des2.disabled=true;document.mainForm.rad_tip_des.disabled=true;document.mainForm.por_desp.disabled=true}
$("#mainForm").submit(function(){return false});</script>
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">body{margin-left:0;margin-top:0;margin-right:0;margin-bottom:0}</style></head>
<body onload="getDetVen(habScrCaj);">
    <div id="propi" style="display:none"></div>
<form name="mainForm" id="mainForm" method="post" onsubmit="return false" action="" target="_self">
<?php
   $bus = mysqli_query($con ,"select fol_ven,id,no_hab from fpos where nparte1=" . $_GET['pos'] . " and mesa=" . $_GET['ms'] . " and status=1 order by id desc limit 1");
                $resul = mysqli_fetch_array($bus);
            $_SESSION['cont'] = $_GET['cont'];
            if ($_GET['pos'] != "") {
                $_GET['pos'];
             
                $folio = $resul['fol_ven'];
                
                $_SESSION['idpos'] = $resul['id']; 
            }
             
            
                                                        @$hab = mysqli_fetch_array(mysqli_query($con ,"select no_hab as habitacion,nparte1,folio from fcomhues where cvmesa='" . $_SESSION['mesa'] . "' and status=1 "));
                                                        $_SESSION['foliohb'] = $hab['folio'];
                                                        $_SESSION['hsp'] = $hab['nparte1'];
														
                                                        if ($resul['no_hab']!='' && $resul['no_hab'] != '0') {
                                                            $_SESSION['habitacion'] = $resul['no_hab'];
                                                            
                                                            $sql_hba=mysqli_query($con ,"select suma, flimite from valeryus19 where fnumcto='". $_SESSION['habitacion']."'"
                                                                    . " and (status='MISCELANEOS') order by fnumcto");
                                                              
                                                            if(mysqli_num_rows($sql_hba)>0){
                                                                while ($hba=mysqli_fetch_array($sql_hba)){
                                                                    if($hba['suma']>=$hba['flimite'])
                                                                          uialert("ALERTA","<b style='color:red'>A ESTA HABITACION SE LE TERMINO SU SALDO</b><br> consumido: ".$hba['suma']."<br>limite:".$hba['flimite'] ."<br>disponible:<b style='color:red; font-size:18px'>".($hba['flimite']-$hba['suma'])."</b>" );
                                                                    else
                                                                         uialert("ALERTA","<b style='color:green'>A ESTA HABITACION TIENE CREDITO ABIERTO </b><br> consumido: ".$hba['suma']."<br>limite:".$hba['flimite']."<br>disponible:<b>".($hba['flimite']-$hba['suma'])."</b>");
                                                                } 
                                                                
                                                             }  else {
                                                                 uialert("ALERTA","LA HABITACION NO TIENE CREDITO EXTRA ABIERTO COMUNICATE A LA RECEPCION ". $_SESSION['habitacion']."");
                                                             }
                                                       
                                                        } else { 
                                                           
                                                            $_SESSION['habitacion'] = '';
                                                        }
                                                       
            ?> 
<div id="foliooo" style="display:none">
    
<input type="text" name="bot" id="bot" value="
                <?php
                if (isset($_GET['fol'])) {
                    if ($_GET['fol'] == 0)
                        echo "";
                    else
                        echo $_GET['fol'];
                }else if (isset($folio)) {
                    echo $folio;
                }
                ?>"> </div>
<input type="hidden" name="bat" id="bat" value="1">
<input type="hidden" name="idDetSel" id="idDetSel" value="">
<input type="hidden" name="virtualKey_focus" id="virtualKey_focus" value="NO_FOCUS">
<table border="0" cellpadding="0" cellspacing="0" align="center" width="98%">
<tr>
<td height="20">&nbsp;</td>
<td height="20" class="titVenta">CAJERO(A):<?php
                                    $_SESSION['punto'] = $_GET['pt'];
                                    $_SESSION['area'] = $_GET['ar'];
                                    $_SESSION['mesa'] = $_GET['ms'];
                                    $_SESSION['msr'] = $_GET['mesero'];
                                      $_SESSION['desc'] = $_GET['desc'];
                                    $dt_clav = mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM dgcatven WHERE   usuario ='".$_SESSION['num_usu']."'"));
                                    $_SESSION['vendedor'] = $dt_clav['cod_ven'];
                                    $_SESSION['tipven'] = 1;
                                    $_SESSION['fecven'] = $dt_empres['fec_alta'];
                                    //$dt_des=mysqli_fetch_array(mysqli_query($con ,"SELECT ctmeser.np_desc1 as mesero, ctmesas.np_desc1 as mesa, fcomhues.no_hab as habit FROM ctmesas,ctmeser,fcomhues WHERE ctmeser.nparte1='".$_SESSION['vendedor']."'")); 
                                    $_SESSION['nomvend'] = $dt_clav['nom_ven'];
                                    echo $dt_clav['nom_ven'] . ' ' . $dt_clav['ap_mat_ven'] . ' ' . $dt_clav['ap_pat_ven'];
                                    ?></td>
<td class="titVenta"><?php echo whatday($_SESSION['fecven']) . ', ' . chfecha($_SESSION['fecven'], 'Y-m-d', 'd de M de Y'); ?></td>
</tr>
<tr>
<td height="70">&nbsp;</td>
<td colspan="4" class="basCellProducto" valign="top">
<div style="width:650px;height:300px" id="divProductos"></div><div style="display:none" id="divScrPag"><?php include("CAJA3_MEN.php"); ?></div>
</td>
</tr>
<tr>
<td width="10" height="80">&nbsp;</td>
<td rowspan=2 class="basCellDetVen" valign="top"><div id="divDetVen"><?php require_once("CAJA12_MEN.php"); ?></div></td>
<td width="340">
<div style="" id="divMenu">
<table width="138" border="0">
<tr>
<td colspan="2" class="cellFootCanDesTit"><div align="left" style="">FOLIO:
<?php
if (isset($folio)) {
    echo $folio;
} else if (!isset($_GET['fol'])) {
    @$fol = mysqli_fetch_array(mysqli_query($con ,"select fol_ven as folio from dgpemema order by fol_ven desc"));
    echo $fol['folio'] + 1;
} else {
    echo $_GET['fol'];
}
?>
</div></td>
<td class="cellFootCanDesTit"><div align="left">No. MESA: <?php
                                                        $msa = mysqli_fetch_array(mysqli_query($con ,"select * from ctmesas where nparte1='" . $_SESSION['mesa'] . "'"));
                                                        echo $msa['np_desc1'];
                                                        ?></div></td>
<td class="cellFootCanDesTit"><div align="left">HABITACION:
<?php
                                                     
                                                        if ($_SESSION['habitacion'] != '0') {
                                                            echo $_SESSION['habitacion'];
                                                        } else {
                                                            echo "----";
                                                            echo $_SESSION['habitacion'] = '';
                                                        }
                                                        ?>
</div></td>
</tr>
<?php
                                                        @$cfol = mysqli_fetch_array(mysqli_query($con ,"select nparte1 from fcomanda order by nparte1 desc limit 1"));
                                                        if (isset($cfol['nparte1'])) {
                                                            $_SESSION['cclav'] = $cfol['nparte1'] + 1;
                                                        } else {
                                                            $_SESSION['cclav'] = '';
                                                        }
                                                        $_SESSION['comand'] = $_GET['comand'];
                                                        ?>
</table>
</div>
</td>
</tr>
<tr>
<td height="80">&nbsp;</td>
<td rowspan="1" class="basCellCalculadora"><div style="width:340px;height:150px" id="divCalculadora"><?php require_once('CAJA22_MEN.php'); ?></div></td>
</tr>
</table>
</form>
</body>
    <script>
    $('#propi').load("CAL20000.php");
    
    </script>
</html>
