<!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" />
        <link href="https://cdn.jsdelivr.net/npm/litepicker/dist/css/litepicker.css" rel="stylesheet" />
        <link href="./view/css/styles.css" rel="stylesheet" />
        <link rel="icon" type="image/x-icon" href="./view/assets/img/trinity_bio/icono_trinity.png" />
        <script data-search-pseudo-elements 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>
        <style>
            #myInput {
            background-image: url('/css/searchicon.png'); /* Add a search icon to input */
            background-position: 10px 12px; /* Position the search icon */
            background-repeat: no-repeat; /* Do not repeat the icon image */
            width: 100%; /* Full-width */
            font-size: 16px; /* Increase font-size */
            padding: 12px 20px 12px 40px; /* Add some padding */
            border: 1px solid #ddd; /* Add a grey border */
            margin-bottom: 12px; /* Add some space below the input */
            }
        </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>
                                            STOCK TECNICO
                                        </h1>
                                        <div class="page-header-subtitle">STOCK TECNICO</div>
                                        <h1 class="page-header-subtitle">
                                            <div class="page-header-icon"><a href="stock_tecnico.php"><i  style="color: white;" data-feather="corner-up-left"></i></a></div>
                                            ATRÁS
                                        </h1>
                                    </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">
                                                STOCK TECNICO
                                            </h1>
                                        </div>
                                        
                                    </div>
                                </div>

                                <!-- <div class="form-row">
                                            <div class="col-md-4">
                                                <div class="form-group">
                                                &nbsp;<h5>BUSCAR TÉCNICO</h5>
                                                &nbsp;<input type="text" id="myInput" onkeyup="myFunction()" placeholder="BUSCAR TÉCNICO ...">
                                                </div>
                                            </div>
                                </div> -->
                                
                            
                                <div class="card-body">
                                            
                                                    <table id="datatablesSimple" name="datatablesSimple">
                                                        <thead>
                                                            <tr>
                                                                <!-- <th>DOCUMENTO DE IDENTIDAD</th>
                                                                <th>TECNICO</th> -->
                                                                
                                                                <th>SKU CLIENTE</th>
                                                                <th>NOMBRE PRODUCTO</th>
                                                                <th>UNIDAD MEDIDA</th>
                                                                
                                                                
                                                                
                                                                
                                                                <th>DISPONIBLE</th>
                                                                <th>SERIES</th>
                                                            </tr>
                                                        </thead>
                                                        <tfoot>
                                                            <tr>
                                                                <!-- <th>DOCUMENTO DE IDENTIDAD</th>
                                                                <th>TECNICO</th> -->
                                                                
                                                                <th>SKU CLIENTE</th>
                                                                <th>NOMBRE PRODUCTO</th>
                                                                <th>UNIDAD MEDIDA</th>
                                                                
                                                                <th>DISPONIBLE</th>
                                                                <th>SERIES</th>
                                                            </tr>
                                                        </tfoot>
                                                        <tbody>

                                                        <?php
                                                        foreach($productos as $producto){
                                                            if($producto['disponible'] != 0){
                                                        ?>
                                                            <tr>
                                                                <!-- <td><?=$producto['codigo_usuario']?></td>
                                                                <td><?php
                                                                                        $found_key="";
                                                                                        $found_key = array_search($producto['codigo_usuario'], array_column($trabajadores, 'DOCIDEN'));
                                                                                    ?>
                                                                                    <?=$trabajadores[$found_key]['NOMBRES']?>
                                                                </td> -->
                                                                
                                                                <?php
                                                                if($producto['bio'] == 1){
                                                                ?>
                                                                <td><?=$producto['sku']?></td>
                                                                <?php
                                                                }else{
                                                                ?>
                                                                <td><?=$producto['sku_cliente']?></td>
                                                                <?php
                                                                }
                                                                ?>
                                                                <td><?=$producto['nombre_producto']?></td> 
                                                                <td><?=$producto['unidad_medida']?></td>
                                                                <td><?=$producto['disponible']?></td>
                                                                <td>
                                                                    <?php
                                                                    if($producto['id_catalogo_serializado'] == 1){
                                                                    ?>
                                                                    
                                                                    <div onclick="accesos('<?=$producto['id_producto']?>_<?=$producto['id_tecnico']?>')" class="badge bg-primary rounded-pill" type="button">SERIES</div>
                                                                    <?php
                                                                    $series = $ges->get_series_asignacion_tecnico($codigo_u,$producto['id_producto_servicio']); 
                                                                    ?>
                                                                    <?php
                                                                    foreach($series as $pb){

                                                                    ?>
                                                                    <p hidden type="hidden"><?=$pb['serie']?></p>
                                                                    <?php
                                                                    }
                                                                    ?>
                                                                    <?php
                                                                    }
                                                                    ?>
                                                                </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>
            function myFunction() {
            // Declare variables
            var input, filter, table, tr, td, i, txtValue;
            input = document.getElementById("myInput");
            filter = input.value.toUpperCase();
            table = document.getElementById("datatablesSimple");
            tr = table.getElementsByTagName("tr");

            // Loop through all table rows, and hide those who don't match the search query
            for (i = 0; i < tr.length; i++) {
                td = tr[i].getElementsByTagName("td")[0];
                if (td) {
                txtValue = td.textContent || td.innerText;
                if (txtValue.toUpperCase().indexOf(filter) > -1) {
                    tr[i].style.display = "";
                } else {
                    tr[i].style.display = "none";
                }
                }
            }
            }
        </script>
        <script src="https://code.jquery.com/jquery-3.5.1.min.js" crossorigin="anonymous"></script>
        <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
        <script src="./view/js/scripts.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/simple-datatables@4.0.8" crossorigin="anonymous"></script>
        <script src="./view/js/datatables/datatables-simple-demo.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/litepicker/dist/bundle.js" crossorigin="anonymous"></script>
        <script src="./view/js/litepicker.js"></script>
        <script>

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

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