<?php
require 'head.php';
require 'Conexion/conexion.php';
require_once 'Conexion/ConexionPDO.php';
$compania = $_SESSION['compania'];
$con = new ConexionPDO();
$conexion =  $_SESSION['conexion'];
?>
<title>Informe de Productos Movimiento</title>
<link rel="stylesheet" href="css/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="css/datapicker.css">
<link rel="stylesheet" href="css/select2.css">
<link rel="stylesheet" href="css/select2-bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap-notify.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome.css">
<style type="text/css" media="screen">
    .client-form input[type="text"] {
        width: 100%;
    }

    .client-form select {
        width: 100%;
    }

    .btn {
        box-shadow: 0px 2px 5px 1px grey;
    }

    .client-form input[type="file"] {
        width: 100%
    }

    .dependencia,
    .responsable,
    .fechaIF,
    .periodo,
    .producto,
    .nivel,
    .periodoX {
        display: none;
    }

    #form .form-group {
        margin-bottom: 10px;
    }
</style>
</head>

<body>
    <div class="container-fluid text-center">
        <div class="row content">
            <?php require('menu.php'); ?>
            <div class="col-sm-10 col-md-10 col-lg-10">
                <h2 id="forma-titulo3" align="center" style="margin-bottom: 20px; margin-right: 4px; margin-left: 4px; margin-top: 0px;">Informe de Productos Movimiento</h2>
                <div style="border: 4px solid #020324; border-radius: 10px; margin-left: 4px; margin-right: 4px;" class="client-form">
                    <form name="form" id="form" class="form-horizontal" method="POST" enctype="multipart/form-data" action="" target="_blank">
                        <p align="center" style="margin-bottom: 5px; margin-top: 5px; margin-left: 30px; font-size: 80%">Los campos marcados con <strong style="color:#03C1FB;">*</strong> son obligatorios.</p>
                        <br>
                        <br>
                        <div class="form-group " style="margin-top: -10px">
                            <label for="sltProductoInicial" class="control-label col-sm-5 col-md-5 col-lg-5"><strong class="obligado">*</strong>Producto Inicial:</label>
                            <div class="col-sm-5 col-md-5 col-lg-5 text-left">
                                <select name="sltProductoInicial" id="sltProductoInicial" class="select2 form-control">
                                    <?php
                                    $html = "";
                                    $html .= "<option value=\"\">Producto Inicial</option>";
                                    $resp = $con->Listar("SELECT DISTINCT
                                                       pr.id_unico AS PRODCTO,
                                                       pln.nombre  AS NOM_PLAN,
                                                       pes.valor   AS SERIE
                                            FROM       gf_producto pr
                                            LEFT JOIN  gf_movimiento_producto     mpr ON mpr.producto          = pr.id_unico
                                            LEFT JOIN  gf_detalle_movimiento      dtm ON mpr.detallemovimiento = dtm.id_unico
                                            LEFT JOIN  gf_plan_inventario         pln ON dtm.planmovimiento    = pln.id_unico
                                            LEFT JOIN  gf_producto_especificacion pes ON pes.producto          = pr.id_unico
                                            LEFT JOIN  gf_ficha_inventario        fic ON pes.fichainventario   = fic.id_unico
                                            WHERE      fic.elementoficha   = 6
                                            AND        pln.compania        = $compania
                                            ORDER BY   pr.id_unico ASC");
                                    // $resp = $mysqli->query($sqlp);
                                    // while ($rowp = mysqli_fetch_row($resp)) {
                                    for ($rowp = 0; $rowp < count($resp); $rowp++) {
                                        $html .= "<option value=\"" . $resp[$rowp][0] . "\"> SERIE :" . $resp[$rowp][2] . " NOMBRE :" . ucwords(mb_strtolower($resp[$rowp][1])) . "</option>";
                                    }
                                    echo $html;
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="form-group ">
                            <label for="sltProductoFinal" class="control-label col-sm-5 col-md-5 col-lg-5"><strong class="obligado">*</strong>Producto Final:</label>
                            <div class="col-sm-5 col-md-5 col-lg-5">
                                <select name="sltProductoFinal" id="sltProductoFinal" class="select2 form-control text-left">
                                    <?php
                                    $html = "";
                                    $html .= "<option value=\"\">Producto Final</option>";
                                    $resp = $con->Listar("SELECT DISTINCT
                                                       pr.id_unico AS PRODCTO,
                                                       pln.nombre  AS NOM_PLAN,
                                                       pes.valor   AS SERIE
                                            FROM       gf_producto pr
                                            LEFT JOIN  gf_movimiento_producto     mpr ON mpr.producto          = pr.id_unico
                                            LEFT JOIN  gf_detalle_movimiento      dtm ON mpr.detallemovimiento = dtm.id_unico
                                            LEFT JOIN  gf_plan_inventario         pln ON dtm.planmovimiento    = pln.id_unico
                                            LEFT JOIN  gf_producto_especificacion pes ON pes.producto          = pr.id_unico
                                            LEFT JOIN  gf_ficha_inventario        fic ON pes.fichainventario   = fic.id_unico
                                            WHERE      fic.elementoficha   = 6
                                            AND        pln.compania        = $compania
                                            ORDER BY   pr.id_unico DESC");
                                    // $resp = $mysqli->query($sqlp);
                                    // while ($rowp = mysqli_fetch_row($resp)) {
                                    for ($rowp = 0; $rowp < count($resp); $rowp++) {
                                        $html .= "<option value=\"" . $resp[$rowp][0] . "\"> SERIE :" . $resp[$rowp][2] . " NOMBRE :" . ucwords(mb_strtolower($resp[$rowp][1])) . "</option>";
                                    }
                                    echo $html;
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="optTipoA" class="control-label col-sm-5 col-md-5 col-lg-5"><strong class="obligado">*</strong>Tipo Archivo:</label>
                            <div class="col-sm-5 col-md-5 col-lg-5 text-left">
                                <label for="optPdf" class="radio-inline"><input name="optTipoA" id="optPdf" type="radio" required="">Pdf</label>
                                <label for="optExcel" class="radio-inline"><input name="optTipoA" id="optExcel" type="radio">Excel</label>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12 col-md-12 col-lg-12 text-left">
                                <label for="sltProductoFinal" class="control-label col-sm-5 col-md-5 col-lg-5"></label>
                                <div class="col-sm-1 col-md-1 col-lg-1">
                                    <button type="submit" id="btnPdf" class="btn btn-primary glyphicon glyphicon-print"></button>
                                </div>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
            <?php require('footer.php'); ?>
            <script src="js/jquery-ui.js"></script>
            <script type="text/javascript" src="js/select2.js"></script>
            <script src="dist/jquery.validate.js"></script>
            <script src="js/bootstrap-notify.js"></script>
            <script type="text/javascript" src="js/md5.js"></script>
            <script src="js/plugins/datepicker/bootstrap-datepicker.js"></script>
            <script>
                $(".select2").select2();




                $("#optPdf").click(function() {
                    $("#form").attr("action", "informes_almacen/INF_PRODUCTOS_MOVIMIENTO.php");
                });
                $("#optExcel").click(function() {
                    $("#form").attr("action", "informes_almacen/INF_PRODUCTOS_MOVIMIENTO_EXCEL.php");
                });
            </script>
        </div>
    </div>
</body>

</html>