<?php include('casa/setup.casa.php');
include('inc_scripts.php');
$title = 'Ventas por Catálogo';
echo "<title>".AppName.' - '.$title."</title>";

$buscar = DataForms::GET('id');
$descrip = DataForms::GET('descrip');
$SucCodigo = SucursalUsuario($USID);

function SucursalUsuario($us_codigo){
  $Usuario = new DB();
  $sqlUsuario = "SELECT * FROM rol_usuarios
  WHERE us_id = '$us_codigo';";
  $Usuario->dbSQL($sqlUsuario);
  $Usuario->next();
  $sucursal = $Usuario->dbField('ubica_codigo');

  return $sucursal;
}
?>
<style>
th{background:#156E10;
color:white;
text-align:center;
text-transform:uppercase;}	
</style>
</head>
<body>
	<div class="wrapper">
	
	<?php include('inc_menu.php');?>
		<div class="main-panel">
			<div class="content">
				
			<div class="page-inner">
					
					<div class="row">						
						<div class="col-md-12">
							<div class="card">
								<div class="card-header">
									<div class="d-flex align-items-center">
										<h3 class="card-title"><?php echo $title;?></h3>																																									
									</div>
								</div>
								
								<div class="card-body">		
																									
									<div id='Productos' class="table-responsive">
									<div class="table-responsive">
										<div class="row">	
												<div class="col-md-6">
													<div class="form-group form-group-default">
														<label>Buscar por Item:</label>
														<input id='txtBuscar' value='<?php echo $buscar; ?>' type="text" class="form-control">
														<center><input type="button" value="BUSCAR" id='btnBuscar' class="btn btn-default"></center>
													</div>						
													
												</div>																				
											
												<div class="col-md-6">
													<div class="form-group form-group-default">
														<label>Buscar por Descripción o Nombre de Producto:</label>
														<input id='txtBuscar2' value='<?php echo $descrip; ?>' type="text" class="form-control">
														<center><input type="button" value="BUSCAR" id='btnBuscar2'  class="btn btn-default"></center>
													</div>																										
												</div>																			
											</div>                                     
                                        <div id='catalogos-listado'></div>
									</div>
									<div id='CarritoCompras'></div>
								</div>
							</div>
						</div>
					</div>
				</div>
				
			</div>
			<?php include('inc_pie.php');?>			
	<script src="<?php echo PATH_HOME.'assets/js/jspdf.debug.js';?>"></script>	
		</div>
		<div id='res'></div>
		
	</div>
</body>
</html>
<script>
function Vender(prod){	
	$.post('<?php echo PATH_HOME.'catalogos-registrar.php?reg='. sha1(uniqid()); ?>',{
	 'codigo_venta': '<?php echo substr(sha1(uniqid()),1,7); ?>',
	 'prod_codigo': prod,
    'MxEncoder': '<?php echo sha1(uniqid()); ?>'
	},function(data){
		$('#res').html(data);
	}); 
}

$('#btnBuscar').click(function(){
	let b = $('#txtBuscar').val();
	//self.location = '<?php echo PATH_HOME."catalogos.php?id="; ?>'+b+'&descrip=&nbsp;';
	$('#catalogos-listado').load('<?php echo PATH_HOME."catalogos-listado.php?id="; ?>'+b+'&descrip=&nbsp;');
});
$('#btnBuscar2').click(function(){
	let c = $('#txtBuscar2').val();
	//self.location = '<?php echo PATH_HOME."catalogos.php?id=&descrip="; ?>'+c;
	$('#catalogos-listado').load('<?php echo PATH_HOME."catalogos-listado.php?id=&descrip="; ?>'+c);
});
$('#txtBuscar,#txtBuscar2').click(function(){
	$(this).val('');
});
</script>