<?php
//ini_set('display_errors',1);

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

require_once("cBanco.php");
$oBanco = new cBanco();
if($_POST['action']=="editar"){

	$dts=$oBanco ->mostrarUno($_POST['ban_id']);

	$dt = mysqli_fetch_array($dts);

	$nom=$dt['tb_banco_nom'];
	$abr=$dt['tb_banco_abr'];

	mysqli_free_result($dts);
}
?>
<form role="form" id="for_ban">
<input name="action" id="action" type="hidden" value="<?php echo $_POST['action']?>">
<input name="hdd_ban_id" id="hdd_ban_id" type="hidden" value="<?php echo $_POST['ban_id']?>">
	<div class="box-header">

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

          </div>

          <div class="box-body">

    
	<div class="form-group">

      <div class="row">

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

          <label for="txt_bannom">Banco:</label>

		  <input name="txt_bannom" id="txt_bannom" type="text" value="<?php echo $nom?>" class="form-control" >

        </div>  
		
		<div class="col-lg-4 col-xs-12">

          <label for="txt_banabr">Banco Abr.:</label>

		    <input name="txt_banabr" id="txt_banabr" type="text" value="<?php echo $abr?>" 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="btn_banco_save">Guardar</button>

          </div>

<script type="text/javascript">
	$('#txt_bannom, #txt_banabr').change(function(){

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

	});
  	$("#btn_banco_save").click(function() {

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

  	});
	$(document).ready(function() {
	

	    $('#for_ban').bootstrapValidator({

	      message: 'This value is not valid',

	      feedbackIcons: {

	        valid: 'glyphicon glyphicon-ok',

	        invalid: 'glyphicon glyphicon-remove',

	        validating: 'glyphicon glyphicon-refresh'

	      },

	      fields: {

	        txt_bannom: {

	          group: '.col-lg-6',

	          validators: {

	            notEmpty: {

	              message: 'Este campo es requerido'

	            }

	          }

	        }, 
			txt_banabr: {

	          group: '.col-lg-4',

	          validators: {

	            notEmpty: {

	              message: 'Este campo es requerido'

	            }

	          }

	        }

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

				type: "POST",

				url: "../banco/banco_reg.php",

				async:true,

				dataType: "json",

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

				beforeSend: function(){

				
				},

				success: function(data){		
				

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

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

						banco_tabla();

				},
				complete: function(){
				}
			});	
	    });
	});
	
	$('#txt_bannom').keydown(function(ev) {
		if(ev.keyCode==13){$('#txt_banabr').focus(); return false;}
	});
	$('#txt_banabr').keydown(function(ev) {
		if(ev.keyCode==13){ $("#btn_banco_save").focus(); return false;}
	});	
</script>