<?php
require "include/conexionPDO.php";
if(isset($_POST['submit'])){
$nuevo_usuario = array(
"USUARIO" => $_POST['USUARIO'],
"CLAVE" => $_POST['CLAVE'],
"NOMBRE" => $_POST['NOMBRE'],
"APELLIDOP" => $_POST['APELLIDOP'],
"APELLIDOM" => $_POST['APELLIDOM'],
"RUT" => $_POST['RUT'],
"CARGO" => $_POST['CARGO'],
"PERFIL" => $_POST['PERFIL'],
"ESTADO" => $_POST['ESTADO']
);
$sql="insert into usuarios (USUARIO, CLAVE, NOMBRE_USUARIO, APELLIDOP_USUARIO, APELLIDOM_USUARIO, RUT_USUARIO, CARGO, ID_PERFIL, ESTADO) values(:USUARIO, :CLAVE, :NOMBRE, :APELLIDOP, :APELLIDOM, :RUT, :CARGO, :PERFIL, :ESTADO)";
try {
$statement = $conexionPDO->prepare($sql);
$statement->execute($nuevo_usuario);
} catch(PDOException $error){
echo $error->getMessage();
}
}
?>
<?php include "templates/header.php";?>
<!-- Content page-->
<section class="full-box dashboard-contentPage">
<!-- NavBar -->
<nav class="full-box dashboard-Navbar">
<ul class="full-box list-unstyled text-right">
<li class="pull-left">
<a href="#!" class="btn-menu-dashboard"><i class="zmdi zmdi-more-vert"></i></a>
</li>
</ul>
</nav>
<!-- Content page -->
<div class="container-fluid">
<div class="page-header">
<h1 class="text-titles"><i class="zmdi zmdi-account zmdi-hc-fw"></i> Agregar <small>Usuario</small></h1>
</div>
<p class="lead">Registrar solo usuarios autorizador por jefatura</p>
<?php if (isset($_POST['submit']) && $statement) : ?>
<blockquote class="lead"><?php echo $_POST['USUARIO']; ?> se ha añadido correctamente. </blockquote>
<?php endif; ?>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
<ul class="nav nav-tabs" style="margin-bottom: 15px;">
<li class="active"><a href="#new" data-toggle="tab">Nuevo</a></li>
<li><a href="#list" data-toggle="tab">Lista</a></li>
</ul>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="new">
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-md-10 col-md-offset-1">
<form method="post">
<div class="form-group label-floating">
<label class="control-label">Usuario</label>
<input name="USUARIO" id="USUARIO" class="form-control" type="text">
</div>
<div class="form-group label-floating">
<label class="control-label" >Password</label>
<input name="CLAVE" id="CLAVE" class="form-control" type="password">
</div>
<div class="form-group label-floating">
<label class="control-label">nombre</label>
<input name="NOMBRE" id="NOMBRE" class="form-control" type="text">
</div>
<div class="form-group label-floating">
<label class="control-label" >Apellido Paterno</label>
<input name="APELLIDOP" id="APELLIDOP" class="form-control" type="text">
</div>
<div class="form-group label-floating">
<label class="control-label">Apellido Materno</label>
<input name="APELLIDOM" id="APELLIDOM" class="form-control" type="text">
</div>
<div class="form-group label-floating">
<label class="control-label">Rut</label>
<input name="RUT" id="RUT" class="form-control" type="text">
</div>
<div class="form-group label-floating">
<label class="control-label">Cargo</label>
<input name="CARGO" id="CARGO" class="form-control" type="text">
</div>
<div class="form-group label-floating">
<label class="control-label">Perfil</label>
<select name="PERFIL" id="PERFIL" class="form-control">
<?php
include "include/conexion.php";
$query = mysqli_query($conexion,"select ID_PERFIL , PERFIL_USUARIO from perfiles");
while($datos = mysqli_fetch_array($query)){ ?>
<option class="control-option" value=""></option>
<option value="<?php echo $datos['ID_PERFIL']?>"><?php echo $datos['PERFIL_USUARIO']?></option>
<?php } ?>
</select>
<fieldset>
<div class="form-group label-floating">
<label class="control-label">Usuario Activo</label>
<input class="radio-inline" type="radio" name="ESTADO" id="ESTADO" value="Activo" checked>
</div>
<div class="form-group label-floating">
<label class="control-label">Usuario Inactivo</label>
<input class="radio-inline" type="radio" name="ESTADO" id="ESTADO" value="Inactivo">
</div>
</fieldset>
</div>
<p class="text-center">
<input name="submit" class="btn btn-info btn-raised btn-sm" type="submit" value="Grabar">
</p>
</form>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="list">
<div class="table-responsive">
<table class="table table-hover text-center">
<thead>
<tr>
<th class="text-center">Usuario</th>
<th class="text-center">Nombre</th>
<th class="text-center">Apell P</th>
<th class="text-center">Apell M</th>
<th class="text-center">Rut</th>
<th class="text-center">Cargo</th>
<th class="text-center">Perfil</th>
<th class="text-center">Estado</th>
<th class="text-center">Update</th>
<th class="text-center">Delete</th>
</tr>
</thead>
<tbody>
<?php $sql="select * from usuarios inner join perfiles";
$result=mysqli_query($conexion,$sql);
while($mostrar=mysqli_fetch_array($result)){
?>
<tr>
<td><?php echo $mostrar['USUARIO']; ?></td>
<td><?php echo $mostrar['NOMBRE_USUARIO']; ?></td>
<td><?php echo $mostrar['APELLIDOP_USUARIO']; ?></td>
<td><?php echo $mostrar['APELLIDOM_USUARIO']; ?></td>
<td><?php echo $mostrar['RUT_USUARIO']; ?></td>
<td><?php echo $mostrar['CARGO']; ?></td>
<td><?php echo $mostrar['PERFIL_USUARIO']; ?></td>
<td><?php echo $mostrar['ESTADO']; ?></td>
<td><a href="include/update.php" class="btn btn-success btn-raised btn-xs"><i class="zmdi zmdi-refresh"></i></a></td>
<td><a href="#!" class="btn btn-danger btn-raised btn-xs"><i class="zmdi zmdi-delete"></i></a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<?php include "templates/footer.php";?>