<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$Fecha1 = date('d-m-Y h:i:s ', time());
$Fecha2 = AddHoras(4);

if(Vencido($Fecha2 )== true){
	echo("Vencido");
}else{
	echo("Vigente");
}
print_r(GetProduct("mano"));
 


?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Welcome to CodeIgniter</title>

	<style type="text/css">

	::selection { background-color: #E13300; color: white; }
	::-moz-selection { background-color: #E13300; color: white; }

	body {
		background-color: #fff;
		margin: 40px;
		font: 13px/20px normal Helvetica, Arial, sans-serif;
		color: #4F5155;
	}

	a {
		color: #003399;
		background-color: transparent;
		font-weight: normal;
	}

	h1 {
		color: #444;
		background-color: transparent;
		border-bottom: 1px solid #D0D0D0;
		font-size: 19px;
		font-weight: normal;
		margin: 0 0 14px 0;
		padding: 14px 15px 10px 15px;
	}

	code {
		font-family: Consolas, Monaco, Courier New, Courier, monospace;
		font-size: 12px;
		background-color: #f9f9f9;
		border: 1px solid #D0D0D0;
		color: #002166;
		display: block;
		margin: 14px 0 14px 0;
		padding: 12px 10px 12px 10px;
	}

	#body {
		margin: 0 15px 0 15px;
	}

	p.footer {
		text-align: right;
		font-size: 11px;
		border-top: 1px solid #D0D0D0;
		line-height: 32px;
		padding: 0 10px 0 10px;
		margin: 20px 0 0 0;
	}

	#container {
		margin: 10px;
		border: 1px solid #D0D0D0;
		box-shadow: 0 0 8px #D0D0D0;
	}
	</style>
</head>
<body>

 <div id="root"></div>
<div id="container">
	<h1>Welcome to CodeIgniter!</h1>
	<form name="formulario" method="post" action="User">

Nombre: <input type="text" name="nombre" value="">

<button  id = "add" >agregar</button>
<button  id = "edit" >modificar</button>
<button  id = "buscar" >buscar</button>
<button  id = "delete" >Eliminar</button>
</form>

<form name="Login" method="post" action="Login">

User: <input type="text" name="Login" id="user" value="">
Password: <input type="password" name="Password" id="password" value="">
<button  id = "login" >Login</button>
<button  id = "Salir" >Salir</button>
</form>

	<div id="body">
		<p>The page you are looking at is being generated dynamically by CodeIgniter.</p>

		<p>If you would like to edit this page you'll find it located at:</p>
		<code>application/views/welcome_message.php</code>

		<p>The corresponding controller for this page is found at:</p>
		<code>application/controllers/Welcome.php</code>

		<p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p>
	</div>

	<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds. <?php echo  (ENVIRONMENT === 'development') ?  'CodeIgniter Version <strong>' . CI_VERSION . '</strong>' : '' ?></p>
</div>

</body>
<script>
window.onload = function(){
	var add =  document.getElementById('add');
	var buscar =  document.getElementById('buscar');
	var Delete =  document.getElementById('delete');
	var edit =  document.getElementById('edit');
	var Salir =  document.getElementById('Salir');

add.onclick = (e)=>{
	  e.preventDefault()
         fetch("http://localhost/CodeIgniter/User", {
                 method: 'POST', // or 'PUT'
                 body: JSON.stringify({"1":"27199128-2","2":"Prueba","3":"4041", "4":"14214", "7":"nkjk","8":"10/12/1987"}), // data can be `string` or {object}!
                 headers:{
	                       "credentials": 'same-origin',
                           "Content-Type": " application/json",
                         }
        })
        .then((res)=>{
	   
       
      })
	  .catch((err)=>{
	       console.log({"Error":err})
         })

}
buscar.onclick = (e)=>{
	  e.preventDefault()
         fetch("http://localhost/CodeIgniter/User", {
                 method: 'GET', // or 'PUT'
                 headers:{
	                       "credentials": 'same-origin',
                           "Content-Type": " application/json",
                         }
        })
        .then((res)=>{
	    res.json()
	         .then(re=>console.log(re))})
        .catch((err)=>{
	       console.log({"Error":err})
         })
      }
edit.onclick = (e)=>{
	  e.preventDefault()
         fetch("http://localhost/CodeIgniter/User", {
                 method: 'PUT', // or 'PUT'
                 body: JSON.stringify({"0":"10","4":"Chanchito"}), // data can be `string` or {object}!
                 headers:{
	                       "credentials": 'same-origin',
                           "Content-Type": " application/json",
                         }
        })
        .then((res)=>{
	    res.json()
	         .then(re=>console.log(re))})
        .catch((err)=>{
	       console.log({"Error":err})
         })
      }


 Delete.onclick = (e)=>{
	  e.preventDefault()
         fetch("http://localhost/CodeIgniter/Classification/0006", {
                 method: 'DELETE', // or 'PUT'
                 headers:{
	                       "credentials": 'same-origin',
                           "Content-Type": " application/json",
                         }
        })
        .then((res)=>{
	     res.json()
	         .then(re=>console.log(re))})
        .catch((err)=>{
	       console.log({"Error":err})
         })
      }

	  Salir.onclick = (e)=>{
	  e.preventDefault()
         fetch("http://localhost/CodeIgniter/Login", {
                 method: 'DELETE', // or 'PUT'
                 headers:{
	                       "credentials": 'same-origin',
                           "Content-Type": " application/json",
                         }
        })
        .then((res)=>{
	     res.json()
	         .then(re=>console.log(re))})
        .catch((err)=>{
	       console.log({"Error":err})
         })
      }


 }

      // Initial state
      
      const initialState = {
        device: {
          isMobile: '{{{ isMobile }}}',
          Secion: "Si"
          
        }
      };

      window.initialState = initialState;
  </script>

    
</html>