<!DOCTYPE html>
<html lang="en">
                          
<?php $this->load->view("template/header"); ?>
<?php $this->load->view("template/nav"); ?>
        
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="m-0">Nuevo Perfil</h1>
                </div>
                <!-- /.col -->
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                    <!-- <li class="breadcrumb-item"><a href="#" onclick="mySession()" class="nav-link">Cerrar Sesión</a></li> -->
                    </ol>
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </div>
        <!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <!-- Small boxes (Stat box) -->
            <div class="row">
            <div class="col-md-12">

            <!-- jquery validation -->
            <div class="card card-secondary">
                <div class="card-header">
                    <h3 class="card-title">Datos de  perfil </h3>
                </div>
                <!-- /.card-header -->

                <!-- form start -->
                <form id="quickForm"  autocomplete="off" >
                    <div class="card-body">
                        <div class="row">
                            <div class="col-sm-6">
                                 <label for="exampleInputEmail1">Nombre Perfil</label>
                                <input type="text" name="txt_nombre_perfiles" class="form-control" id="txt_nombre_perfil" placeholder="Nombre de perfil" aria-describedby="exampleInputPassword1-error" aria-invalid="true" maxlenght="125">
                            
                            </div> 
                            <!-- /.col -->

                            <div class="col-sm-6">
                            </br>   
                            <div class="custom-control custom-radio">
                                <input class="custom-control-input" type="radio" id="customRadio1" name="customRadio" value="1">
                                <label for="customRadio1" class="custom-control-label">Activo</label>
                            </div>
                            <div class="custom-control custom-radio">
                                <input class="custom-control-input" type="radio" id="customRadio2" name="customRadio" value="2" >
                                <label for="customRadio2" class="custom-control-label">Inactivo</label>
                            </div>
                            
                            </div>  
                            <!-- /.col -->

                           
                            <!-- /.col -->                                                      
                        </div> 
                        <!-- /.row -->
                    </div>
                    <!-- /.card-body -->

                    <div class="card-footer">
                        <button type="button" class="btn btn-secondary col-md-1 " id="btn_cancelar_perfil" >Cancelar </button>
                        <button style="float: right" type="button" class="btn btn-primary col-md-1 " id="btn_guardar_perfil">Guardar </button>   
                    </div>
                    <!-- /.card footer -->
                </form>
                <!-- /.form -->
            </div> 
            <!-- /.card -->
                
            <!-- Main row -->
            <div class="row">
                <!-- Left col -->
                <section class="col-lg-7 connectedSortable">
                    <!-- Custom tabs (Charts with tabs)-->

                    <!-- /.card -->
                    </section>
                        <!-- /.Left col -->
                        <!-- right col (We are only adding the ID to make the widgets sortable)-->
                    <section class="col-lg-5 connectedSortable">

                </section>
                 <!-- right col -->
            </div>
            <!-- /.row (main row) -->
        </div>
        <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->

<?php $this->load->view("template/footer"); ?>


<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
</aside>
<!-- /.control-sidebar -->

<!--</div>
 ./wrapper -->

<!-- ======================================================================================================================================================================================================= -->
     <!-- jQuery -->
    <script src="<?php echo base_url() ?>assets/plugins/jquery/jquery.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/jquery/jquery.min.js"></script>
    <!-- jQuery UI 1.11.4 -->
    <script src="<?php echo base_url() ?>assets/plugins/jquery-ui/jquery-ui.min.js"></script>
    <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
    <script>
        $.widget.bridge('uibutton', $.ui.button)
    </script>
    <!-- Bootstrap 4 -->
    <script src="<?php echo base_url() ?>assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- ChartJS -->
    <script src="<?php echo base_url() ?>assets/plugins/chart.js/Chart.min.js"></script>
    <!-- Sparkline -->
    <!-- <script src="<?php echo base_url() ?>assets/plugins/sparklines/sparkline.js"></script> -->
    <!-- JQVMap -->
    <script src="<?php echo base_url() ?>assets/plugins/jqvmap/jquery.vmap.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/jqvmap/maps/jquery.vmap.usa.js"></script>
    <!-- jQuery Knob Chart -->
    <script src="<?php echo base_url() ?>assets/plugins/jquery-knob/jquery.knob.min.js"></script>
    <!-- daterangepicker -->
    <script src="<?php echo base_url() ?>assets/plugins/moment/moment.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/daterangepicker/daterangepicker.js"></script>
    <!-- Tempusdominus Bootstrap 4 -->
    <script src="<?php echo base_url() ?>assets/plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
    <!-- Summernote -->
    <script src="<?php echo base_url() ?>assets/plugins/summernote/summernote-bs4.min.js"></script>
    <!-- overlayScrollbars -->
    <script src="<?php echo base_url() ?>assets/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
    <!-- AdminLTE App -->
    <script src="<?php echo base_url() ?>assets/dist/js/adminlte.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="<?php echo base_url() ?>assets/dist/js/demo.js"></script>
    <!-- AdminLTE dashboard demo (This is only for demo purposes) -->
    <!-- <script src="<?php echo base_url() ?>assets/dist/js/pages/dashboard.js"></script> -->
	<!-- SweetAlert -->
	<script src="<?php echo base_url() ?>assets/plugins/sweetalert2/sweetalert2.all.min.js"></script>
    <!-- AdminLTE Datatable components -->
    <script src="<?php echo base_url() ?>assets/plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/jszip/jszip.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/pdfmake/pdfmake.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/pdfmake/vfs_fonts.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-buttons/js/buttons.html5.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-buttons/js/buttons.print.min.js"></script>
    <script src="<?php echo base_url() ?>assets/plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
  
<!-- ======================================================================================================================================================================================================= -->
    <script>
      

	//Boton de busqueda por los parametros.
	$("#btn_guardar_perfil").click(function () {             

		//Captura de valores 
		var nombre_perfil=$("#txt_nombre_perfil").val();
		
		//Validando los datos de entrada
		if(nombre_perfil=='') { Swal.fire("Error al ingresar los datos", "Debe ingresar un nombre del perfil", "error");    return; }
		var radioValue = $("input[name='customRadio']:checked").val();

		if(radioValue==null)  { Swal.fire("Error al ingresar los datos", "Debe seleccionar un estado del perfil", "error"); return; }

		var estado='';
		if(radioValue==1){
			estado='A';
		} 

		if(radioValue==2){
			estado='I';
		}
		

		//llamada a micro servicio de validacion
		$.ajax({

			url: '<?php echo base_url() ?>perfiles/guardarperfiles',//controlador
			type: "POST",//tipo de peticion POST o GET
			headers: {'X-Requested-With': 'XMLHttpRequest'},//Encabezados
			data: {'nombre_perfil': nombre_perfil,'estado_perfil': estado }//formato json Data
							
				
		}).done(function(dato) {
				
			//convierto la respuesta json
			var obj = JSON.parse(dato); 
			if (obj.res == 'ok') {
				//llamamos al controlador
				//Swal.fire("Inforamción",obj.msg, "success");  
				window.location.href="<?php echo base_url() ?>perfiles/listperfiles";
			}else{
			
				Swal.fire("error",obj.msg, "error");  
				
			}
		}); 
    });

	//Boton Cancelar Perfil
	$("#btn_cancelar_perfil").click(function () 
	{ 
		window.location.href="<?php echo base_url() ?>perfiles/listperfiles";
	});




    </script>

</body>

</html>
