<!doctype html>
<html lang="en">

<head>
    <title>Editar</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="shortcut icon" href="../../img/hardmant3.ico">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>

<body>
<nav class="navbar navbar-light " style="background-color: #005a65;color:#fff;justify-content:center;" >
  <span class="navbar-brand mb-0 h1">HARDMANT- Editar Hojas</span>
</nav>
      
       <!--<center><h3>
        HARDMANT
        <small class="text-muted">Soluciones Informaticas</small>
        </h3>
        </center> -->
    <div class="container mt-3">
        <div class="row">
            <div class="col-10 offset-1 " >
                <?php
                include_once "../../db_empresa.php";
                $conexion = mysqli_connect($db_host, $db_user, $db_pass, $db_database);
                /*------------------------empresa-----
                    $sqlCliente="SELECT id_cliente,nombreCliente
                    from cliente";
                    $resultCliente=mysqli_query($conexion,$sqlCliente);

                */

                
                if ($conexion == false) {
                    echo "Error conexion" . mysqli_error($conexion);
                }
                if (isset($_GET['guardar'])) {
                    $sql = "UPDATE hoja SET
                    nhoja='" . $_GET['nhoja'] . "',
                    empresaH='" . $_GET['empresaH'] . "',
                    retirado='" . $_GET['retirado'] . "',
                    equipo='" . $_GET['equipo'] . "',
                    marca='" . $_GET['marca'] . "',
                    modelo='" . $_GET['modelo'] . "',
                    nserie='" . $_GET['nserie'] . "',
                    fechaIn='" . $_GET['fechaIn'] . "',
                    problema='" . $_GET['problema'] . "',
                    estado='" . $_GET['estado'] . "',
                    codigob='" . $_GET['codigob'] . "',
                    fechaOut='" . $_GET['fechaOut'] . "',
                    entregado='" . $_GET['entregado'] . "',
                    solucion='" . $_GET['solucion'] . "',
                    factura='" . $_GET['factura'] . "'
                    WHERE id='" . $_GET['id'] . "';
                    ";
                    $resultado = mysqli_query($conexion, $sql);
                    if ($resultado == false) {
                        ?>
                        <div class="alert alert-danger alert-dismissible fade show" role="alert">
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                                <span class="sr-only">Close</span>
                            </button>
                            <strong><?php echo "Error al actualizar ".mysqli_error($conexion); ?></strong>
                        </div>
                    <?php

                        } else {
                            ?>
                        <div class="alert alert-primary alert-dismissible fade show" role="alert">
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                                <span class="sr-only">Close</span>
                            </button>
                            <strong>Actualizacion exitosa</strong>
                        </div>
                <?php
                    }
                }
                $sql = "SELECT 
                    `id`, 
                    `nhoja`, 
                    `empresaH`, 
                    `retirado`, 
                    `equipo`, 
                    `marca`, 
                    `modelo`, 
                    `nserie`, 
                    `fechaIn`, 
                    `fechaOut`, 
                    `problema`,
                    `estado`,
                    `codigob`,
                    `solucion`, 
                    `entregado`,
                    `factura` 
                     
                    FROM `hoja`
                    WHERE id='" . $_GET['id'] . "'
                    ;
                    ";

                $resulSet = mysqli_query($conexion, $sql);
                $row = mysqli_fetch_array($resulSet, MYSQLI_ASSOC);
                ?>
                  <form>
                        <div class="form-row">
                                <div class="form-group col-6 offset-0"  style="width:150px;">
                                <label>N° de Hoja</label>
                                <input type="number" class="form-control" id="nhoja" Name="nhoja" value="<?php echo $row['nhoja'] ?>" >
                                </div>
                                <div class="form-group col-6 md-4">
                                <label >Fecha de Ingreso</label>
                                <input type="date" class="form-control" id="fechaIn" Name="fechaIn" value="<?php echo $row['fechaIn'] ?>" >
                                </div>
                                <label for="inputEmail4">Empresa</label>
                                        <select class="form-control input-sm" id="empresaH" name="empresaH">
                                                <option ><?php echo $row['empresaH'] ?></option>
                                                <?php 
                                                $sqlCliente="SELECT id,empresa
                                                from cliente";
                                                $resultCliente=mysqli_query($conexion,$sqlCliente);
                                                ?>
                                                <?php while($verC=mysqli_fetch_row($resultCliente)): ?>
                                                    <option value="<?php echo $verC[1] ?>"><?php echo $verC[1]; ?></option>
                                                <?php endwhile; ?>
                                            </select>

                                         <label >Retirado Por:</label>
                                        <select class="form-control input-sm" id="retirado" name="retirado">
                                                <option><?php echo $row['retirado'] ?></option>
                                                <?php 
                                                $sqlTecnico="SELECT id,nombreTecnico
                                                from tecnicos";
                                                $resultTecnico=mysqli_query($conexion,$sqlTecnico);
                                                ?>
                                                <?php while($verT=mysqli_fetch_row($resultTecnico)): ?>
                                                    <option value="<?php echo $verT[1] ?>"><?php echo $verT[1]; ?></option>
                                                <?php endwhile; ?>
                                            </select>   
                                         <label for="inputEmail4">Tipo de Equipo</label>
                                           <select class="form-control input-sm" id="equipo" name="equipo">
                                                <option><?php echo $row['equipo'] ?></option>
                                                <?php 
                                                $sqlCategoria="SELECT id,nombreCategoria
                                                from categorias";
                                                $resultCategoria=mysqli_query($conexion,$sqlCategoria);
                                                ?>
                                                <?php while($verCa=mysqli_fetch_row($resultCategoria)): ?>
                                                    <option value="<?php echo $verCa[1] ?>"><?php echo $verCa[1]; ?></option>
                                                <?php endwhile; ?>
                                            </select>
                                            <label for="inputPassword4">Marca</label>
                                                <input type="text" class="form-control" id="marca" Name="marca" value="<?php echo $row['marca'] ?>" >
                                            <label for="inputPassword4">Modelo</label>
                                                <input type="text" class="form-control" id="modelo" Name="modelo" value="<?php echo $row['modelo'] ?>" >   
                                            <label for="inputPassword4">N° serie</label>
                                                 <input type="text" class="form-control" id="nserie" Name="nserie" value="<?php echo $row['nserie'] ?>" >  
                                            <label >Problema</label>
                                             <!-- <textarea class="form-control" id="problema" placeholder="Detalle el problema " name ="problema" required></textarea> -->
                                             <input type="text" class="form-control" id="problema" Name="problema" value="<?php echo $row['problema'] ?>" > 
                                             <label for="inputEmail4">Estado</label>
                                        <!--<input type="text" class="form-control" name="estado" value="<?php echo $row['estado'] ?>">-->
                                        <select class="form-control input-sm"  name="estado" value="<?php echo $row['estado'] ?>">
                                            <option value="">Cambiar el estado del Equipo</option>
                                            <option value=" En Reparacion">En reparación</option>
                                            <option value="En espera por repuesto">En espera por repuesto</option>
                                            <option value="Reparado no entregado">Reparado no entregado</option>
                                            <option value="Reparado entregado">Reparado entregado</option>
                                            <option value="Asistencia Remota">Asistencia Remota</option>
                                        </select> 
                                        <label >Codigo de Barra</label>
                                              <input type="text" class="form-control" name="codigob" value="<?php echo $row['codigob'] ?>">
                                        <label for="inputEmail4">Entregado A:</label>
                                               <input type="text" class="form-control" name="entregado" value="<?php echo $row['entregado'] ?>">               

                            </div>
                            
                              
                                    
                                    
                        
                                
                                
                               <div class="form-row">
                                    
                                    
                                    <div class="form-group col-6 md-1">
                                    <label for="inputPassword4">Fecha de Entrega</label>
                                    <input type="date" class="form-control" name="fechaOut" value="<?php echo $row['fechaOut'] ?>">
                                    </div>
                                    
                                
                                    <div class="form-group col-6 md-5">
                                    <label >N° Factura</label>
                                    <input type="number" class="form-control" id="factura"   Name="factura" value="<?php echo $row['factura'] ?>" >
                                    </div>
                                    
                                    

                                </div> 
                                <div class="form-row ">
                                    
                                    <label >Solución</label>
                                    <!--<textarea class="form-control" id="solucion" placeholder="Trabajo Realizado " name ="solucion" ></textarea> -->
                                    <input type="text" class="form-control" id="solucion" Name="solucion" value="<?php echo $row['solucion'] ?>" >
                                

                            </div>   
                       </div>
                     </div>
                     <div class="form-row col-12 offset-0">
                       <label>
                           
                           
                       </label>
                      </div>  


                    
                    
                    


                    
                    



                    
                    
                    
                     


                    
                     <div class="form-row">
                          <div class="form-group col-12 offset-1" >
                                <input type="hidden" name="id" value="<?php echo $row['id'] ?>">
                                <button type="submit" name="guardar" class="btn btn-primary">Guardar</button>
                                <a href="grilla.php" class="btn btn-warning">Regresar</a>
                           </div>
                        </div>   
                </form>
            </div>
        </div>
    </div>
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>

</html>
<?php
mysqli_close($conexion);
?>