<?php

include("../../base.php");
if (isset($_GET['clave'])) {


    if ($_GET['type'] == 1) {
        $query = mysqli_query($con ,"select * from  ctmeser where codigo='" . $_GET['clave'] . "'");
        //    echo "select * from valeryus19 where fnumcto='" . trim($_GET['hab']) . "' and (status='HUESPED' or status='MISCELANEOS')";
        $regh = mysqli_fetch_assoc($query);
        //  echo json_encode($regh);
        //  var_dump($query);
        if (mysqli_num_rows($query) == 0) { 
            echo "0";
        } else {  
            echo json_encode($regh);
        }
    } else if ($_GET['type'] == 11) {

$pass=$_GET['clave']; 
        $hp = mysqli_fetch_array(mysqli_query($con ,"select * from fcomhues where cvmesa='" . $_GET['mesa'] . "' and status=1  order by nparte1 desc"));
       // echo "select * from fcomhues where cvmesa=" . $_GET['mesa'] . " and status=1  order by nparte1 desc";
//echo "select * from fcomhues where cvmesa=".$_POST['txtmesa']." and status=1  order by nparte1 desc<br/>";
      //  @$w = mysqli_query($con ,"select * from ctmeser where nparte1='" . $hp['cvmese ro'] . "'");
        //echo "select * from ctmeser where nparte1=" . $hp['cvmesero'] . " and codigo='" . $_GET['clave'] . "'";
        // echo "select codigo from ctmeser where nparte1=".$hp['cvmesero']."";
//echo $pass;

      

$insbrt=mysqli_query($con ,"update dgpemema set cod_ven='".$hp['cvmesero']."' where fpos_mesa='" . $_GET['mesa'] . "' and pagado!='S' and cancela!=1");
        $code="";
        @$w=mysqli_query($con ,"select codigo from ctmeser where nparte1=".$hp['cvmesero']."");
     // echo "select codigo from ctmeser where nparte1=".$hp['cvmesero']."";
//echo $pass; 
		while (@$pas=mysqli_fetch_array($w)){
                    $code=$pas['codigo'];
			if ($pas['codigo']==$pass)
			{                              
				echo "ok";
                                exit();	 
			}else { echo $code;	}
		}
                @$w1=mysqli_query($con ,"select pasw from dgcatven");
		while (@$pas1=mysqli_fetch_array($w1)){
			if ($pas1['pasw']==$pass)
			{
				echo 
				"ok";
                                exit();	 
			}else {	}	
		}
                
      
    }
    else if ($_GET['type'] == 2) {

$pass=$_GET['clave'];
        $hp = mysqli_fetch_array(mysqli_query($con ,"select * from fcomhues where folio='" . $_GET['folio'] . "' and status=1  order by nparte1 desc"));
       // echo "select * from fcomhues where cvmesa=" . $_GET['mesa'] . " and status=1  order by nparte1 desc";
//echo "select * from fcomhues where cvmesa=".$_POST['txtmesa']." and status=1  order by nparte1 desc<br/>";
      //  @$w = mysqli_query($con ,"select * from ctmeser where nparte1='" . $hp['cvmesero'] . "'");
        //echo "select * from ctmeser where nparte1=" . $hp['cvmesero'] . " and codigo='" . $_GET['clave'] . "'";
        // echo "select codigo from ctmeser where nparte1=".$hp['cvmesero']."";
//echo $pass;
        $code="";
        @$w=mysqli_query($con ,"select codigo from ctmeser where nparte1=".$hp['cvmesero']."");
     // echo "select codigo from ctmeser where nparte1=".$hp['cvmesero']."";
//echo $pass; 
		while (@$pas=mysqli_fetch_array($w)){
                    $code=$pas['codigo'];
			if ($pas['codigo']==$pass)
			{                              
				echo "ok";
                                exit();	 
			}else { echo $code;	}
		}
                @$w1=mysqli_query($con ,"select pasw from dgcatven");
		while (@$pas1=mysqli_fetch_array($w1)){
			if ($pas1['pasw']==$pass)
			{
				echo 
				"ok";
                                exit();	 
			}else {	}	
		}
                
      
    }
}
?>
