<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
        <meta name="description" content="" />
        <meta name="author" content="" />
        <title>BIO - ALMACÉN</title>
        <link href="https://cdn.jsdelivr.net/npm/simple-datatables@4.0.8/dist/style.css" rel="stylesheet" as="style" />
        <link href="https://cdn.jsdelivr.net/npm/litepicker/dist/css/litepicker.css" rel="stylesheet" as="style" />
        <link href="./view/css/styles.css" rel="stylesheet" as="style" />
        <link href="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css" rel="stylesheet" as="style" />


        <script defer src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/js/all.min.js" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/feather-icons/4.28.0/feather.min.js" crossorigin="anonymous"></script>


        <script src="./view/ckeditor/ckeditor.js" defer></script>


        <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js" crossorigin="anonymous" defer></script>


        <link rel="preload" href="https://cdn.jsdelivr.net/npm/simple-datatables@4.0.8/dist/style.css" as="style" />
        <link rel="preload" href="https://cdn.jsdelivr.net/npm/litepicker/dist/css/litepicker.css" as="style" />
    </head>
    <body class="nav-fixed">

        <?php require_once("./view/menu.phtml") ?>

        <div id="layoutSidenav">

            <?php require_once("./view/menuv.phtml") ?>
            
            <div id="layoutSidenav_content">
            <main>
                    <header class="page-header page-header-dark bg-gradient-primary-to-secondary pb-10">
                        <div class="container-xl px-4">
                            <div class="page-header-content pt-4">
                                <div class="row align-items-center justify-content-between">
                                    <div class="col-auto mt-4">
                                        <h1 class="page-header-title">
                                            <div class="page-header-icon"><i data-feather="package"></i></div>
                                            REPORTE GENERAL
                                        </h1>
                                        <div class="page-header-subtitle">REPORTE GENERAL</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </header>

                    <div class="container-xl px-4 mt-n10">
                        <div class="card mb-4">
                            <div class="card-header">
                                <div class="row align-items-center justify-content-between pt-3">
                                    <div class="col-auto mb-3">
                                        <h1 class="page-header-title">
                                            REPORTE GENERAL
                                        </h1>
                                    </div>
                                    <form  method="post" action="reporte.php">
                                        <div class = 'row'>
                                            <div class="col-md-3">
                                                <label class="small mb-1" for="correo">FECHA INICIO</label>
                                                <input required class="form-control" id="fecha_inicio" name="fecha_inicio" type="date" value=""/>
                                            </div>
                                            <div class="col-md-3">
                                                <label class="small mb-1" for="correo">FECHA FIN</label>
                                                <input required class="form-control" id="fecha_fin" name="fecha_fin" type="date" value=""/>
                                            </div>
                                            <div class="col-md-3 d-flex align-items-end">
                                            <input class="btn btn-primary btn-block" type="submit" name="DESCARGAR" id="DESCARGAR" value="DESCARGAR"/>
                                            </div>
                                        </div>
                                    </form>
                                    
                                </div>
                            </div>
                        
                            <!-- <div class="card-body">    
                                <table id="datatablesSimple" name = "datatablesSimple">
                                    <thead>
                                        <tr>
                                            <th>MOVIMIENTO</th>
                                            <th>SKU</th>
                                            <th>PRODUCTO</th>
                                            <th>CANTIDAD</th>
                                            <th>SERIE</th>
                                            
                                            
                                            
                                            
                                            <th>ALMACEN ORIGEN</th>
                                            <th>ALMACEN DESTINO</th>

                                            <th>TÉCNICO ORIGEN</th>
                                            <th>NOMBRE TÉCNICO ORIGEN</th>
                                            <th>TÉCNICO DESTINO</th>
                                            <th>NOMBRE TÉCNICO DESTINO</th>

                                            <th>FECHA</th>

                                            <th>CÓDIGO CLIENTE</th>
                                            <th>ORDEN TRABAJO</th>
                                            <th>NRO DOCUMENTO</th>
                                            <th>CONTRATA</th>
                                        </tr>
                                    </thead>
                                    <tfoot>
                                        <tr>
                                            <th>MOVIMIENTO</th>
                                            <th>SKU</th>
                                            <th>PRODUCTO</th>
                                            <th>CANTIDAD</th>
                                            <th>SERIE</th>
                                            
                                            
                                            
                                            
                                            <th>ALMACEN ORIGEN</th>
                                            <th>ALMACEN DESTINO</th>

                                            <th>TÉCNICO ORIGEN</th>
                                            <th>NOMBRE TÉCNICO ORIGEN</th>
                                            <th>TÉCNICO DESTINO</th>
                                            <th>NOMBRE TÉCNICO DESTINO</th>

                                            <th>FECHA</th>

                                            <th>CÓDIGO CLIENTE</th>
                                            <th>ORDEN TRABAJO</th>
                                            <th>NRO DOCUMENTO</th>
                                            <th>CONTRATA</th>
                                        </tr>
                                    </tfoot>
                                    <tbody>

                                    <?php
                                    foreach($productos as $producto){
                                    ?>
                                        <tr>
                                            
                                            <td><?=$producto['descripcion']?></td>
                                            <td><?=$producto['sku_cliente']?></td>
                                            <td><?=$producto['nombre_producto']?></td>
                                            <td><?=$producto['cantidad']?></td>
                                            <td><?=$producto['serie']?></td>
                                            <td><?=$producto['almacen_origen']?></td> 
                                            <td><?=$producto['almacen_destino']?></td>
                                            <td><?=$producto['tecnico_origen']?></td>
                                            <?php
                                            if($producto['tecnico_origen'] == '' || $producto['tecnico_origen'] == ' ' || $producto['tecnico_origen'] == null || empty($producto['tecnico_origen']) || !isset($producto['tecnico_origen']) ){
                                                ?>
                                            <td></td>
                                            <?php
                                            }else{
                                            ?>
                                            <td>
                                                            <?php
                                                                $found_key="";
                                                                $found_key = array_search($producto['tecnico_origen'], array_column($trabajadores, 'DOCIDEN'));
                                                            ?>
                                                            <?=$trabajadores[$found_key]['NOMBRES']?>
                                            </td>
                                            <?php

                                            }
                                            ?>

                                            <td><?=$producto['tecnico_destino']?></td>
                                            <?php
                                            if($producto['tecnico_destino'] == '' || $producto['tecnico_destino'] == ' ' || $producto['tecnico_destino'] == null || empty($producto['tecnico_destino']) || !isset($producto['tecnico_destino']) ){
                                                ?>
                                            <td></td>
                                            <?php
                                            }else{
                                            ?>
                                            <td>
                                                <?php
                                                    $found_key="";
                                                    $found_key = array_search($producto['tecnico_destino'], array_column($trabajadores, 'DOCIDEN'));
                                                ?>
                                                <?=$trabajadores[$found_key]['NOMBRES']?>
                                            </td>
                                            <?php

                                            }
                                            ?>
                                            <td><?= date_format($producto['fecha_creacion'], 'Y-m-d H:i') ?></td>
                                            <td><?=$producto['codigo']?></td>
                                            <td><?=$producto['orden']?></td>
                                            <td><?=$producto['nro_documento']?></td>
                                            <td><?=$producto['contrata']?></td>
                                        </tr>
                                    <?php
                                    }
                                    ?>
                                        
                                    </tbody>
                                </table>        
                            </div> -->
                        </div>

                        
                    </div>
                </main>
                <footer class="footer-admin mt-auto footer-light">
                    <div class="container-xl px-4">
                        <div class="row">
                            <div class="col-md-6 small">Copyright &copy; TRINITY ERP - BIO SAC 2022</div>
                            <div class="col-md-6 text-md-end small">
                                <a href="#!">POLÍTICAS DE PRIVACIDAD</a>
                                &middot;
                                <a href="#!">TERMINOS &amp; CONDICIONES</a>
                            </div>
                        </div>
                    </div>
                </footer>
            </div>
        </div>

        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>

        <script src="./view/js/scripts.js" defer></script>
        <script src="./view/js/datatables/datatables-simple-demo.js" defer></script>
        <script src="./view/js/litepicker.js" defer></script>


        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous" defer></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js" crossorigin="anonymous" defer></script>
        <script src="https://cdn.jsdelivr.net/npm/simple-datatables@4.0.8" crossorigin="anonymous" defer></script>
        <script src="https://cdn.jsdelivr.net/npm/litepicker/dist/bundle.js" crossorigin="anonymous" defer></script>
        <script>

            function accesos(id){
                window.location.href="series_tecnico.php?producto="+id+"";
            }

        </script>
    </body>
</html>
