<?php
session_start(); 
include("DMMYSQLG.php"); 
//include("DSA1000.php");
 $fecha=$dt_empres['fec_alta']; 
mysqli_query($con ,"UPDATE fpos a join dgpemema as b ON a.fol_ven = b.fol_ven set a.status=0, a.fol_ven=0 where a.status=1 and a.fol_ven<>0 and b.cancela=1");
mysqli_query($con ,"update ctmesas set status=0, fol_ven=0 where nparte1 not in (select mesa from fpos where status=1 group by mesa) and status=1" );

include("JQUERY.inc"); 
  @$sqlVIP = mysqli_query($con ,"select *  from valeryus19 where fvip='SI' and date('$fecha') between ffecllegada and ffecsalida and cancelado=0");
   @$sqlESP = mysqli_query($con ,"select *  from valeryus19 where con_1='1' and date('$fecha') between ffecllegada and ffecsalida and cancelado=0");


?>
<!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" type="text/css"/>
        <script type="text/javascript" language="javascript" src="DSSCRIPT.js"></script>
        

        <script type="text/javascript" src="ajax1.js?1"></script>
        <script type="text/javascript" src="ajax2.js?1"></script>
        <script type='text/javascript'>
            var data;
            var ty;
            var mesa;
            var area;
            function abrir(URL, type, m,ar,boton) {
                data = URL;
                ty = type;
                mesa = m;
                area=ar;
                
                if(boton==1)
                $('#btnNew').show();
                else
                $('#btnNew').hide();
                
                
                $("#botonera").dialog({modal: true, width: 400});

        //                              $.fancybox.open({
        //					href :'#botonera',
        //					padding : 5,
        //                                                                 
        //				});  
        //                                $("#botonera").fancybox(); 


            }

   function NewFolio() {
               console.log(mesa);

                $("#botonera").dialog('close');

                $.ajax({
                    url: 'ws_newmesa.php?mesa=' + mesa + "&area=" +area,
                    type: 'get',
                    beforeSend: function () {
                        //  $.fancybox.showLoading();
                    },
                    success: function (response) {
                    
                     if (response.trim() == "0") {
                       $('#a'+area).click();
                       console.log('recargado');
                     }

                        
                       
                       
                    }
                });
            }


        </script>
        <script>
            function getmesero(num) {


                $.ajax({
                    url: 'ws_mesero.php?clave=' + num + "&type=" + ty + "&mesa=" + mesa,
                    type: 'get',
                    beforeSend: function () {
                        //  $.fancybox.showLoading();
                    },
                    success: function (response) {

                        if (response.trim() == "0") {

                            $(".ui-dialog-title").html("ERROR EN LA CLAVE");
                            $(".ui-dialog-title").css('color', "red");
                            $("#Clave").val('');
                            $("#Clave").css('border', "1px solid red");
                        }
                        else {
                            $(".ui-dialog-title").html("CARGANDO INFO");
                            $(".ui-dialog-title").css('color', "#000");
                            if (ty == 1) {
                                //window.open('MESA4000_PR.php?' + data + "&mesero=" + num, 'mainFrame', 'Keypad');
				window.open('CAJA1.php?' + data + "&mesero=" + num+ "&pos=1&cont=1&directo=1", 'mainFrame', 'Keypad');
                            }
                            else {
                                if (response.trim() == "ok") {

                                    window.open('MESA5000_PR.php?' + data + "&mesero=" + num, 'mainFrame', 'Keypad');
                                }
                                else { 
                                      $(".ui-dialog-title").html("ERROR EN LA CLAV0E--"+response);
                            $(".ui-dialog-title").css('color', "red");

                                }
                            }
                        }
                    }
                }); 

            }

        </script>
        <head>
            <link rel="stylesheet" href="css/estilo1.css" type="text/css"/>

            <style type="text/css">
                <!--
                #Layer1 {
                    position:absolute;
                    width:944px;
                    height:149px;
                    z-index:1;
                    left: 93px;
                    top: 240px;
                }
                input.men {
                    width: 95px;
                    height: 95px;
                    font-size: 43px;
                }
                input#Clave {
                    height: 50px;
                    width: 329px;
                    font-size: 50px !important;
                }
            </style>
            <style>
                #regBus{
                    height:400px;
                    overflow:auto;
                }

                .botunn{
                    font-size: 9px;
                    font-family: Verdana,Helvetica;
                    font-weight: bold;
                    color: #FFF;
                    background: #4e83c8; 
                    width: 140px !important;
                    height: 50px !important;
                    border: 1px outset #999;
                    white-space: normal;

                }

                .botoc{
                    font-size:10px;
                    font-family:Verdana,Helvetica;
                    font-weight:bold;
                    color:#FF0000;
                    background:#4e83c8;
                    width:120px;
                    height:20px;
                    border: 1px outset #999

                }
-->

            </style>
<style>
    .post-it {
background:#fefabc; 
padding:15px; 
font-family: 'Gloria Hallelujah', cursive; 
font-size:15px; 
color: #000; 
width:100px; 
float: left;
margin:2px; 
-moz-transform: rotate(7deg);
-webkit-transform: rotate(7deg);
-o-transform: rotate(7deg);
-ms-transform: rotate(7deg);
transform: rotate(7deg);

box-shadow: 0px 4px 6px #333;
-moz-box-shadow: 0px 4px 6px #333;
-webkit-box-shadow: 0px 4px 6px #333;

}
.red{
    background: #FF2F46;
}
.purple{
    background: #e100ff;
    width:160px; 
}
.pin {
  background-color: #aaa;
  display: block;
  height: 16px;
  width: 2px;
  position: absolute;
  left: 50%;
  top: -7px;
  z-index: 1;
}
.pin:after {
  background-color: blue;
  background-image: radial-gradient(25% 25%, circle, hsla(0,0%,100%,.3), hsla(0,0%,0%,.3));
  border-radius: 50%;

  content: '';
  height: 12px;
  left: -5px;
  position: absolute;
  top: -10px;
  width: 12px;
}
 
</style>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
        <body>
            <div align="center">
                <?php
                $sql = mysqli_query($con ,"SELECT * FROM ptventa order by nparte1 ");
                $sql2 = mysqli_query($con ,"SELECT count (*) FROM ptventa");
//	include("DE10000.php");
                ?>
                <table width="752" height="21" border='0'>
                    <tr>
                        <th colspan="8"> 
                            <div align="center">PUNTOS DE VENTA </div>
                        </th></tr>
                </table>
                <table border="0" align="center">
                    <input name="can_par_cob" type="hidden" class="textCanCob" id="can_par_cob" size="5"/>
                    <tr class="condes">
<?php $i = 0;
while ($reg = mysqli_fetch_array($sql)) {
    ?> 		

                            <td class="condes"><div align="center">
                                    <input name="button" type="button" class="botunn" onClick="MostrarCon(<?php echo $reg['nparte1']; ?>)" value="<?php echo $reg['np_desc1']; ?>"> </div></td> 
                                           <?php
                                           ++$i;
                                           if (($i % 5) == 0) {
                                               ?> <tr style="border:none">  </tr>	<?php }
                    }
                                       ?> 
                    </tr>
                </table>
                <div align="center" id="area">

                </div>
                <div align="center" id="mesas">

                </div>
                <div align="center" id="clave">

                </div>

            </div>

            <div align="center">
              <form action="" method="post" name="form1" id="form1">
                <table width="752" height="36">
                  <tr>
                    <td class="condes" ><div align="center"><input name="pagar2" type="button" class="botunn" onClick="envia2('AUD10000_IM.php','_self','form1');" value=" CTAS. ABIERTAS "/>
                    
                    
                    
                    </div></td>
                  
                  </tr>
                </table>
                </form>
                 
            </div>
            
            
              <?php
          
                while($reg = mysqli_fetch_array($sqlVIP))
                {
                    
                echo '    
                <div class="post-it red">
                <i class="pin"></i> 
                <b style="color:blue">'.(($reg['fnumcto']=='')?$reg['fmuncto']:$reg['fnumcto']).'</b> es <b style="color:green">VIP</b>           
                </div>';
              
                      }
              ?>  
        
         <?php
                while($reg = mysqli_fetch_array($sqlESP))
                {
                echo '    
                <div class="post-it purple">
                <i class="pin"></i> 
                <b style="color:blue">'.(($reg['fnumcto']=='')?$reg['fmuncto']:$reg['fnumcto']).'</b> '.$reg['fapellido'].' '.$reg['fnombre'].' <b style="color:darkred">Servicio Especial</b>           
                </div>';
              
                      }
              ?>
            
        </body>


        <div id="botonera" style="display:none;background: #000;color:#fff;height: 100%; min-width: 500px;" title="CLAVE DE MESERO">
            <!--<div class='tltpant'>CLAVE DEL MESERO</div>-->
            <form name="Keypad" id="Keypad"  onsubmit="getmesero(this.Clave.value)" action="#" method="post" enctype="multipart/form-data">
                <table border="0" cellpadding="0">
                    <tbody>
                        <tr><td colspan="3" align="middle">
                                <input name="Clave" onblur="var that = this;
                            setTimeout(function () {
                                that.focus();
                            }, 0);" autofocus="autofocus" id="Clave" type="password" class="emplea" style="text-align: right;font-size:17px" size="25" >
                                    </tr>
                                    <tr>
                                        <td align="center"><div align="center">
                                                <input name="btnSeven" type="button" class="men" onClick="NumPressed(7)" value="  7  " /></div></td>
                                        <td  align="center"><div align="center">
                                                <input name="btnEight" type="button" class="men" onClick="NumPressed(8)" value="  8  " /></div></td>
                                        <td  align="center"><div align="center">
                                                <input name="btnNine" type="button" class="men" onClick="NumPressed(9)" value="  9  " /></div></td>
                                    </tr>
                                    <tr>
                                        <td align="center"><div align="center">
                                                <input name="btnFour" type="button" class="men" onClick="NumPressed(4)" value="  4  " /></div></td>
                                        <td align="center"><div align="center">
                                                <input name="btnFive" type="button" class="men" onClick="NumPressed(5)" value="  5  " /></div></td>
                                        <td align="center"><div align="center">
                                                <input name="btnSix" type="button" class="men" onClick="NumPressed(6)" value="  6  " /></div></td>
                                    </tr>
                                    <tr>
                                        <td align="center"><div align="center">
                                                <input name="btnOne" type="button" class="men" onClick="NumPressed(1)" value="  1  " /></div></td>
                                        <td align="center"><div align="center">
                                                <input name="btnTwo" type="button" class="men" onClick="NumPressed(2)" value="  2  " /></div></td>
                                        <td align="center"><div align="center">
                                                <input name="btnThree" type="button" class="men" onClick="NumPressed(3)" value="  3  " /></div></td>
                                    </tr>
                                    <tr>
                                        <td align="center"><div align="center">
                                                <input name="btnZero" type="button" class="men" onClick="NumPressed(0)" value="  0  " /></div></td>
                                        <td align="center"><div align="center">
                                                <input name="btnok" type="button" onClick="getmesero(document.Keypad.Clave.value)" class="men" id="btnok" value="OK"/></div></td>
                                        <td align="center"><div align="center">
                                                <input name="btnClear" type="button" class="men" onClick="Clear()" value="  X " /></div></td>
                                    </tr>
                                      <tr>
                                        <td align="center"><div align="center">
                                                <input name="btnNew" id="btnNew"  type="button" class="" onClick="NewFolio()" value="nuevo Folio" /></div></td>
                                       
                                    </tr>
                                    </tbody>
                                    </table>
                                    </form>
          
                                    </div>
                                    </html>
                                    <?php mysqli_close($con); ?>
                                    <script language="JavaScript" type="text/javascript">
                                        var FKeyPad = document.Keypad;
                                        var Accum = 0;
                                        var FlagNewNum = false;
                                        var PendingOp = "";
                                        function NumPressed(Num) {
                                            if (FlagNewNum) {
                                                FKeyPad.Clave.value = Num;
                                                FlagNewNum = false;
                                            }

                                            else
                                                FKeyPad.Clave.value += Num;

                                        }
                                        function Operation(Op) {
                                            var Clave = FKeyPad.Clave.value;
                                            if (FlagNewNum && PendingOp != "=")
                                                ;
                                            else
                                            {
                                                FlagNewNum = true;
                                                if ('+' == PendingOp)
                                                    Accum += parseFloat(Clave);
                                                else if ('-' == PendingOp)
                                                    Accum -= parseFloat(Clave);
                                                else if ('/' == PendingOp)
                                                    Accum /= parseFloat(Clave);
                                                else if ('*' == PendingOp)
                                                    Accum *= parseFloat(Clave);
                                                else
                                                    Accum = parseFloat(Clave);
                                                FKeyPad.Clave.value = Accum;
                                                PendingOp = Op;
                                            }
                                        }
                                        function Decimal() {
                                            var curClave = FKeyPad.Clave.value;
                                            if (FlagNewNum) {
                                                curClave = "0.";
                                                FlagNewNum = false;
                                            }
                                            else
                                            {
                                                if (curClave.indexOf(".") == -1)
                                                    curClave += ".";
                                            }
                                            FKeyPad.Clave.value = curClave;
                                        }
                                        function ClearEntry() {
                                            FKeyPad.Clave.value = "";
                                            FlagNewNum = true;
                                        }
                                        function Clear() {
                                            Accum = 0;
                                            PendingOp = "";
                                            ClearEntry();
                                        }
                                        function Neg() {
                                            FKeyPad.Clave.value = parseFloat(FKeyPad.Clave.value) * -1;
                                        }
                                        function Percent() {
                                            FKeyPad.Clave.value = (parseFloat(FKeyPad.Clave.value) / 100) * parseFloat(Accum);
                                        }

                                        $(function () {
                                            $("#Keypad").submit(function (event) {
                                                //console.log('sumbi');
                                                getmesero(FKeyPad.Clave.value);
                                                event.preventDefault();
                                            });
                                        });
                                    </script>
