<?php 
require_once ("../../config/Cado.php");
require_once ("cAlmacen.php");
$oAlmacen = new cAlmacen();
if($_POST['action']=="editar")
{
	$dts=$oAlmacen->mostrarUno($_POST['alm_id']);
	$dt = mysqli_fetch_array($dts);
	$alm_nom=$dt['tb_almacen_nom'];
	$alm_ven=$dt['tb_almacen_ven'];
	mysqli_free_result($dts);
}
?>
				<form role="form" id="for_alm" method="POST">
					<input name="action_almacen" id="action_almacen" type="hidden" value="<?php echo $_POST['action']?>">
					<input name="hdd_alm_id" id="hdd_alm_id" type="hidden" value="<?php echo $_POST['alm_id']?>">
					<div class="box-header">
						<h3 class="box-title">Información de Almacén</h3>
					</div>
					<div class="box-body">
						<div class="form-group">							
							<div class="row">
								<div class="col-xs-12 col-lg-6">
									<label for="txt_alm_nom">Nombre:</label>
									<input name="txt_alm_nom" type="text" id="txt_alm_nom" value="<?php echo $alm_nom?>" class="form-control">
								</div>
								<div class="col-lg-6 col-xs-12 checkbox">
									<label for="chk_alm_ven">&nbsp;</label> <br>
									<label>
										<input name="chk_alm_ven" type="checkbox" id="chk_alm_ven" value="1" <?php if($alm_ven==1)echo 'checked'?> type="checkbox" title="Almacén para ventas">Para Ventas
									</label>
								</div>
							</div>					
						</div>
					</div>
				</form>
				<div class="box-footer float-right">
					<button type="button" data-dismiss="modal" class="btn btn-default">Cancelar</button>
					<button class="btn btn-primary" id="save_form">Guardar</button>
				</div>
			
<script type="text/javascript">
	
	$('#txt_alm_nom').change(function(){
		$(this).val($(this).val().toUpperCase());
	});
	$("#save_form").click(function() {
		$("#for_alm").submit();
	});
	$(document).ready(function() {
		$('#for_alm').bootstrapValidator({
	    
	      message: 'Valor no valido',
	      feedbackIcons: {
	      	valid: 'glyphicon glyphicon-ok',
	      	invalid: 'glyphicon glyphicon-remove',
	      	validating: 'glyphicon glyphicon-refresh'
	      },
	      fields: {	      	
	      	txt_alm_nom: {
	      		group: '.col-xs-6',
	      		validators: {
	      			notEmpty: {
	      				message: 'Este campo es requerido'
	      			}
	      		}
	      	}
	      }
	  }).on('success.form.bv', function(e) {
	  	
	  	$.ajax({
	  		type: "POST",
	  		url: "../almacen/almacen_reg.php",
	  		async:true,
	  		dataType: "json",
	  		data: $("#for_alm").serialize(),
	  		beforeSend: function() {
	  			
	  		},
	  		success: function(data){	
				$('.modal').modal('hide');
				$('.in').removeClass('modal-backdrop');		
	  			toastr["info"](data.msj);					
	  		},
	  		complete: function(){
				almacen_tabla();
	  			<?php
	  			/* if($_POST['vista']=="almacen_tabla")
	  			{
	  				echo $_POST['vista'].'()';
	  			}
	  			if($_POST['vista']=="cmb_alm_id")
	  			{
	  				echo $_POST['vista'].'()';
	  			} */
	  			?>
	  		}
	  	});
	  });
	});
	
	$('#txt_alm_nom').focus();
	$('#txt_alm_nom').keydown(function(ev) {
		if(ev.keyCode==13){$('#chk_alm_ven').focus(); return false;}
	});
	$('#chk_alm_ven').keydown(function(ev) {
		if(ev.keyCode==13){$('#save_form').focus(); return false;}
	});
</script>