<!DOCTYPE html>
<html lang="es">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Incidentes</title>
	<!-- <link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/loginF.css"> -->
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.0.0/animate.min.css">
		<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> -->
		<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
			<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
			<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
			<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<!-- <body style="background-color: white;"> -->

<div class="p-5 bg-primary text-white text-center">
	<h3>Portal Registro y Seguimiento de Incidentes</h3>
</div>
<div class="container mt-5">
	<div class="row">
		<div class="col-sm-4">
			<img algin="center" src="https://admsystem.cl/freddy/IMG/incidentes.png" height="200" width="400">
				<form id="frm1" action="../insertardatos.php" method="post" class="was-validated"><br>
					
				<div class="form-floating mb-3 mt-3">
					<input type="text" class="form-control" id="nombre" placeholder="Ingrese su Nombre" name="Nombre" required>
					<label for="nombre">Usuario</label>
					<div class="invalid-feedback">Por favor rellene este campo.</div>
				</div>
				
				<div class="form-floating mb-3 mt-3">
					<input type="num" class="form-control" id="rut" placeholder="11.123.456-7" name="Rut" required>
					<label for="text">Rut</label>
					<div class="invalid-feedback">Por favor rellene este campo.</div>
				</div>

				<div class="form-floating mb-3 mt-3">
					<input type="date" class="form-control" id="Fecha Apertura" placeholder="" name="Fecha_Apertura" required>
					<label for="date">Fecha apertura</label>
					<div class="invalid-feedback">Por favor seleccione calendario.</div>
				</div>

				<div class="form-floating mb-3 mt-3">
					<input type="text" class="form-control" id="problema" placeholder="" name="Problema" required>
					<label for="text">Problema</label>
					<div class="invalid-feedback">Por favor rellene este campo.</div>
				</div>

				<div class="form-floating mb-3 mt-3">
					<input type="text" class="form-control" id="descripcion problema" placeholder="" name="Descripcion_Problema" required>
					<label for="text">Descripcion Problema</label>
					<div class="invalid-feedback">Por favor rellene este campo.</div>
				</div>
					
				<div class="form-floating mb-3 mt-3">
					<input type="text" class="form-control" id="resolutor" placeholder="" name="Resolutor" required>
					<label for="text">Resolutor</label>
					<div class="invalid-feedback">Por favor rellene este campo.</div>
				</div>
					
				<div class="form-floating mb-3 mt-3">
					<input type="text" class="form-control" id="causa" placeholder="" name="Causa" required>
					<label for="text">Causa</label>
					<div class="invalid-feedback">Por favor rellene este campo.</div>
				</div>
					
				<div class="form-floating mb-3 mt-3">
					<input type="text" class="form-control" id="solucion" placeholder="" name="Solucion" required>
					<label for="text">Solucion</label>
					<div class="invalid-feedback">Por favor rellene este campo.</div>
				</div>
					
				<div class="form-floating mb-3 mt-3">
					<input type="date" class="form-control" id="Fecha termino" placeholder="" name="Fecha_Termino" required>
					<label for="date">Fecha termino</label>
					<div class="invalid-feedback">Por favor seleccione calendario.</div>
				</div>
					
					<br>
					<div class="btn-group">
						<button type="button" onclick="ingresar()" class="btn btn-primary">Generar Ticket</button>
						<!-- <button type="button" onclick="eliminar()" class="btn btn-primary">Borrar Registro</button>
						<button type="button" onclick="modificar()" class="btn btn-primary">Moficar Registro</button> -->
					</div>
					<!--<br><br>
					<button type="button" onclick="Enviar();">Generar Ticket</button> -->
					<!-- <button type="button" onclick="ingresar()" class="btn btn-primary" >Eliminar</button> -->
					<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#myModal">Eliminar</button>
				</form>
			<hr class="d-sm-none">
		</div>
		<div class="col-sm-8">
			<br><br><br><br>
									<?php

										include'../conexion/conexion.php';

										$sql = "SELECT * FROM incidentes";

										$ejecutar = mysqli_query($conectar,$sql);

										echo "<h1>BASE DE DATOS</h1><BR>";
										echo "<h2>INCIDENTES</h2>";
										echo"<table class='table'>";
										echo "<thead class='thead-dark'";
										echo "<tr>";
										echo "<th>idIncidentes </th>";
										echo "<th>Nombre</th>";
										echo "<th>Rut</th>";
										echo "<th>Fecha Apertura</th>";
										echo "<th>Problema</th>";
										echo "<th>Descripción Problema</th>";
										echo "<th>Resolutor</th>";
										echo "<th>Causa</th>";
										echo "<th>Solucion</th>";
										echo "<th>Fecha Termino</th>";
										echo "</tr>";
									?>	

									<?php 

										while ($arreglo = mysqli_fetch_array($ejecutar)) {

										echo"<tbody>";
										echo "<td>$arreglo[0]</td>";
										echo "<td>$arreglo[1]</td>";
										echo "<td>$arreglo[2]</td>";
										echo "<td>$arreglo[3]</td>";
										echo "<td>$arreglo[4]</td>";
										echo "<td>$arreglo[5]</td>";
										echo "<td>$arreglo[6]</td>";
										echo "<td>$arreglo[7]</td>";
										echo "<td>$arreglo[8]</td>";
										echo "<td>$arreglo[9]</td>";

										echo"</tbody>";
										
										}

									?>
		
			
		<div class="col-sm-8">
			
									<?php

										// include'datos.php';

										$sql = "SELECT * FROM ticket";

										$ejecutar = mysqli_query($conectar,$sql);

										echo"<table class='table'><br><br><br><br>";
										echo "<h2>REGISTROS GENERADOS</h2>";
										echo "<thead class='thead-dark'";
										echo "<tr>";
										echo "<th>idTicket</th>";
										echo "<th>idIncidentes</th>";
										// echo "<th>Rut</th>";
										echo "<th>Fecha Apertura</th>";
										// echo "<th>Problema</th>";
										// echo "<th>Descripción Problema</th>";
										echo "<th>Resolutor</th>";
										echo "<th>Actividad Realizada</th>";
										echo "<th>Informacion Actual</th>";
										echo "<th>Informacion Anterior</th>";
										echo "</tr>";
									?>	

									<?php 

										while ($arreglo = mysqli_fetch_array($ejecutar)) {

										echo"<tbody>";
										echo "<td>$arreglo[0]</td>";
										echo "<td>$arreglo[1]</td>";
										echo "<td>$arreglo[2]</td>";
										echo "<td>$arreglo[3]</td>";
										echo "<td>$arreglo[4]</td>";
										echo "<td>$arreglo[5]</td>";
										echo "<td>$arreglo[6]</td>";
										// echo "<td>$arreglo[7]</td>";
										// echo "<td>$arreglo[8]</td>";
										// echo "<td>$arreglo[9]</td>";

										echo"</tbody>";
										
										}

									?>
			</div>
		</div>
	</div>
</div>

<!--  -->

<!-- The Modal -->
<div class="modal" id="myModal">
	<div class="modal-dialog modal-fullscreen-sm-down">
		<div class="modal-content">

		<!-- Modal Header -->
		<div class="modal-header">
			<h4 class="modal-title">Eliminar Registro</h4>
			<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
		</div>

			<!-- Modal body -->
			<div class="modal-body">
				<!-- Modal  -->
				<!-- <form action="../modal/mdalEliminar.php" method="post"> -->
					<div class="form-group mx-sm-3 mb-2">
						<label for="incidentes" class="sr-only">Nombre:</label>
							<select name="Nombre" class="form-control" >
								
								<?php
									include'../conexion/conexion.php';

									$sql = "SELECT idIncidentes, Nombre FROM incidentes";

									$ejecutar = mysqli_query($conectar,$sql);

									foreach ($ejecutar as $valores):
								// echo '<option value="'.$valores["Nombre"].'">'.$valores["Nombre"].'</option>';
								?>
									<option value="<?php echo $valores["idIncidentes"]?>"><?php echo $valores["Nombre"]?></option>
								<?php
								endforeach;
								?>
							</select>
							<!-- <input type="submit" value="Eliminar"> -->
					</div>
				<!-- </form> -->
			</div>
			<!-- Modal footer -->
			<div class="modal-footer">
					<a href="mdalEliminar.php?id=<?php echo $valores["idIncidentes"]; ?>"><button type="button" class="btn btn-primary" data-dismiss="">Eliminar</button></a>
					<!-- <button type="button" onclick="eliminar()" class="btn btn-primary">Eliminarr</button> -->
                    <!-- <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button> -->
				<button type="button" class="btn btn-danger" data-bs-dismiss="modal">Cerrar</button>
			</div>
		</div>
	</div>
</div>
<!-- <a class="btn btn-primary" href="editar.php?id=<?php echo $row->id; ?>"><i class="fa fa-pencil fa-lg" aria-hidden="true"></i></a> -->
<!-- <a class="btn btn-primary" href="borrar.php?id=<?php echo $row->id;?>"><i class="fa fa-trash-o fa-lg" aria-hidden="true"></i></a> -->
</body>
<script>
function ingresar() {
	document.getElementById("frm1").submit();
}
// function eliminar() {
// 	document.getElementById("frm2").submit();
// }
// function eliminar() {
// 	window.open('http://www.admsystem.cl/eliminardatos.php/');
// 	// document.getElementById("eliminardatos.php").submit();
// }
</script>
</html>
