<?php

	require_once ("../../config/Cado.php");

	require_once ("cImpresora.php");

	$oImpresora = new cImpresora();



	if($_POST['action']=="editar")

	{

	$dts=$oImpresora->mostrarUno($_POST['imp_id']);

	$dt = mysqli_fetch_array($dts);

	$imp_nom=$dt['tb_impresora_nom'];

	$tipo=$dt['tb_impresora_tipo'];

	mysqli_free_result($dts);

	}else{

	$imp_nom = "";

	$tipo ="";

	}

?>



				<form role="form" id="for_imp" method="POST">



					<input name="action_impresora" id="action_impresora" type="hidden" value="<?php echo $_POST['action']?>">

					<input name="hdd_imp_id" id="hdd_imp_id" type="hidden" value="<?php echo $_POST['imp_id']?>">



					<div class="box-header">

						<h3 class="box-title">Registro de Impresora</h3>

					</div>

					<div class="box-body">



						<div class="form-group">

							<div class="row">

								<div class="col-lg-4 col-xs-6">

									<label for="txt_imp_nom">Nombre:</label>

									<input name="txt_imp_nom" type="text" id="txt_imp_nom" value="<?php echo $imp_nom; ?>" class="form-control"> 

								</div>							

								<div class="col-lg-4 col-xs-6">

									<label for="cmb_imp_tipo">Tipo:</label>

									<select name="cmb_imp_tipo" id="cmb_imp_tipo" class="form-control">

										<option <?php if($tipo==1)echo 'selected'?> selected value="1">TICKET</option>

										<option <?php if($tipo==2)echo 'selected'?> value="2">CODIGO DE BARRAS</option>

									</select> 

								</div>

								<div class="col-lg-4 col-xs-6">

									<label for="txt_imp_nomloc">Nombre Local:</label>

									<input name="txt_imp_nomloc" type="text" id="txt_imp_nomloc" value="<?php echo $dt['tb_impresora_nomloc']?>" class="form-control">

								</div>

								<div class="col-lg-4 col-xs-6">

									<label for="txt_imp_ser">Serie:</label>

									<input name="txt_imp_ser" type="text" id="txt_imp_ser" value="<?php echo $dt['tb_impresora_ser']?>" class="form-control">

								</div>

								<div class="col-lg-4 col-xs-6">

									<label for="txt_mar_nom">URL:</label>

									<input name="txt_imp_url" type="text" id="txt_imp_url" value="<?php echo $dt['tb_impresora_url']?>" class="form-control">

								</div>

								<div class="col-lg-4 col-xs-6">

									<label for="txt_mar_nom">IP:</label>

									<input name="txt_imp_ip" type="text" id="txt_imp_ip" value="<?php echo $dt['tb_impresora_ip']?>" class="form-control">

								</div>

							</div>



						</div>

					</div>

				</form>

				<div class="box-footer float-right ">

					<button type="button" data-dismiss="modal" class="btn btn-default cancel">Cancelar</button>

					<button class="btn btn-primary " id="save_form">Guardar</button>

				</div>

			

			<!--

<section class="content" id="form">

	<div class="row">

		<div class="col-xs-12">

			<div class="box box-info">

			

			</div>

		</div>

	</div>

</section>

-->





<script type="text/javascript">



	$(function() {



		$('#txt_mar_nom').focus();



		$('#txt_imp_nom').change(function(){

			$(this).val($(this).val().toUpperCase());

		});



		$("#cancel").click(function() {

			$("#form").hide();

			$("#table").show();

		});



		$("#save_form").click(function() {

			$("#for_imp").submit();

		});



		$(document).ready(function() {

			$('#for_imp').bootstrapValidator({

	      //live: 'disabled',

	      message: 'valor no valido',

	      feedbackIcons: {

	      	valid: 'glyphicon glyphicon-ok',

	      	invalid: 'glyphicon glyphicon-remove',

	      	validating: 'glyphicon glyphicon-refresh'

	      },

	      fields: {

	      	txt_imp_nom: {

	      		group: '.col-lg-2',

	      		validators: {

	      			notEmpty: {

	      				message: 'campo requerido'

	      			}

	      		}

	      	}

	      }

	  }).on('success.form.bv', function(e) {

	  	

	  	$.ajax({

	  		type: "POST",

	  		url: "../impresora/impresora_reg.php",

	  		async:true,

	  		dataType: "json",

	  		data: $("#for_imp").serialize(),

	  		beforeSend: function() {

	  			

	  		},

	  		success: function(data){	

				$('.modal').modal('hide');

				$('.in').removeClass('modal-backdrop');			

				toastr["success"](data.imp_msj);			

	  		},



	  		complete: function(){

	  			impresora_tabla();

	  		}

	  	});

	  });

	});





		$("#txt_mar_nom").keypress(function(e){



		});



		$('#txt_imp_nom').focus();



		$("#txt_imp_nom").keydown(function(e){

			if (e.keyCode == 13){ $("#cmb_imp_tipo").focus(); return false;}

		});



		$("#cmb_imp_tipo").keydown(function(e){

			if (e.keyCode == 13){ $("#txt_imp_nomloc").focus(); return false;}

		});



		$("#txt_imp_nomloc").keydown(function(e){

			if (e.keyCode == 13){ $("#txt_imp_ser").focus(); return false;}

		});



		$("#txt_imp_ser").keydown(function(e){

			if (e.keyCode == 13){ $("#txt_imp_url").focus(); return false;}

		});



		$("#txt_imp_url").keydown(function(e){

			if (e.keyCode == 13){ $("#txt_imp_ip").focus(); return false;}

		});



		$("#txt_imp_ip").keydown(function(e){

			if (e.keyCode == 13){ $('#save_form').focus(); return false;}

		});		



	});























</script>