<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">
        <?php
        require '../../conexion.php';
        require '../../session.php';
        require '../../menu/css_lte.ctp';
        ?>
    </head>
    <body class="hold-transition skin-blue sidebar-mini">
        <div class="wrapper">
            <?php require '../../menu/cabecera.ctp'; ?><!--BARRA DE HERRAMIENTAS-->
            <?php require '../../menu/izquierda.ctp'; ?><!--BARRA DE HERRAMIENTAS-->

            <div class="content-wrapper">
                <div class="content"> 

                    <div class="row">
                        <!--impresion del titulo de la pagina-->
                        <div class="col-lg-12">
                            <?php if (!empty($_SESSION['mensaje'])) { ?>
                                <?php
                                $mensaje = explode("_/_", $_SESSION['mensaje']);
                                if (($mensaje[0] == 'NOTICIA')) {
                                    $class = "success";
                                } else {
                                    $class = "danger";
                                }
                                ?>
                                <div class="alert alert-<?= $class; ?>" role="alert" id="mensaje">
                                    <i class="ion ion-information-circled"></i>
                                    <?php
                                    echo $mensaje[1];
                                    $_SESSION['mensaje'] = '';
                                    ?>
                                </div>
                            <?php } ?>

                            <h3 class="page-header">Stock
                                <a data-toggle="modal" data-target="#registrar" 
                                   class="btn btn-primary btn-circle pull-right" 
                                   rel="tooltip" data-title="Registrar">
                                    <i class="fa fa-plus"></i> AGREGAR
                                </a>   
                            </h3>
                        </div>   

                        <!--Buscador-->
                        <div class="col-lg-12">
                            <div class="panel-heading">
                                <div class="input-group custom-search-form">
                                    <input id="filtrar" type="text" class="form-control" placeholder="Buscar...">
                                    <span class="input-group-btn">
                                        <button class="btn btn-primary" type="button" rel="tooltip" title="Buscar">
                                            <i class="fa fa-search"></i>
                                        </button>
                                    </span>
                                </div>
                            </div>                      
                        </div>
                    </div>


                    <!-- /.row -->
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    Datos
                                </div>
                                <?php
                                $stocks = consultas::get_datos("select * from v_stock1 where cod_suc=".$_SESSION['cod_suc']."order by id_articulo asc ");
                                if (!empty($stocks)) {
                                    ?>                         
                                    <!-- /.panel-heading -->
                                    <div class="panel-body">
                                        <div>
                                            <table id="example1" width="100%" 
                                                   class="table table-striped table-bordered table-hover">
                                                <thead>
                                                    <tr>
                                                        <th class="text-center">Articulo</th>
                                                        <th class="text-center">Deposito</th>
                                                        <th class="text-center">Imagen</th>
                                                        <th class="text-center">Cantidad</th>

                                                    </tr>
                                                </thead>
                                                <tbody class="buscar">
                                                    <?php foreach ($stocks as $stock) { ?> 
                                                        <tr>
                                                            <td class="text-center"><?php echo $stock['art_descri']; ?></td>
                                                            <td class="text-center"><?php echo $stock['dep_descrip']; ?></td>
                                                            <td class="text-center">
                                                                <img height="45px" src="/farmmedi/img/articulos/<?php echo (!empty($stock['art_imagen'])?$stock['art_imagen']:"no-image.jpg") ?>"/>
                                                            <td class="text-center"><?php echo $stock['cantidad']; ?></td> 
                                                        </tr>
                                                    <?php } ?>
                                                </tbody>
                                            </table>                         
                                        </div>
                                    <?php } else { ?>
                                        <div class="alert alert-info alert-dismissable">
                                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">
                                                &times;</button>
                                            <strong>No se encontraron registro....!</strong>
                                        </div>
                                    <?php } ?>  
                                    <!-- /.panel-body -->
                                </div>
                            </div>
                            <!-- /.panel -->
                        </div>
                        <!-- /.col-lg-12 -->
                    </div>

                    <!--registrar-->
                    <div id="registrar" class="modal fade" role="dialog">
                        <div class="modal-dialog">
                            <!-- Modal content-->
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" 
                                            data-dismiss="modal" arial-label="Close">x</button>
                                    <h4 class="modal-title"><strong>Registrar Articulos en Deposito</strong></h4>
                                </div>
                                <form action="stock_control.php" method="post" 
                                      accept-charset="utf-8" class="form-horizontal">
                                    <div class="panel-body se">
                                        <input type="hidden" name="accion"  value="1">
                                        <input type="hidden" name="vsuc" value="0"/> 
                                        <input type="hidden" name="pagina" value="stock_index.php">

                                        <div class="form-group">

                                            <?php
                                            $ciudades = consultas::get_datos("select * from articulos as a where not exists "
                                                            . "(select * from v_stock as s where a.id_articulo=s.id_articulo and cod_suc=" .$_SESSION['cod_suc']. ")" 
                                                            ."and tarti_cod<>3 order by id_articulo");
                                            ?>
                                            <div class="col-md-3" style="left: 100px;">
                                                <label class="col-md-2 control-label">Articulos</label>
                                                <select name="id_articulo" class="form-control select2" style="width: 190px">
                                                    <?php
                                                    if (!empty($ciudades)) {
                                                        foreach ($ciudades as $ciudad) {
                                                            ?>
                                                            <option value="<?php echo $ciudad['id_articulo']; ?>">
                                                                <?php echo $ciudad['art_descri']; ?></option>
                                                            <?php
                                                        }
                                                    } else {
                                                        ?>
                                                        <option value="1">Debe insertar un articulo</option>
                                                    <?php } ?>    
                                                </select>
                                            </div>


                                            <?php $ciudades = consultas::get_datos("select * from deposito where cod_depo<>0 and cod_suc=".$_SESSION['cod_suc']."order by cod_depo"); ?>
                                            <div class="col-md-3" style="left: 150px">
                                                <label class="col-md-2 control-label">Deposito</label>
                                                <select name="cod_depo" class="form-control select2" style="width: 200px">
                                                     <option value="">Seleccione un deposito</option>
                                                    <?php
                                                    if (!empty($ciudades)) {
                                                        foreach ($ciudades as $ciudad) {
                                                            ?>
                                                            <option value="<?php echo $ciudad['cod_depo']; ?>">
                                                                <?php echo $ciudad['dep_descrip']; ?></option>
                                                            <?php
                                                        }
                                                    } else {
                                                        ?>
                                                        <option value="0">Debe insertar un deposito</option>
                                                    <?php } ?>    
                                                </select>
                                            </div>

                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="reset" data-dismiss="modal" class="btn btn-danger pull-left">
                                            <i class="fa fa-close"></i> Cerrar</button>
                                        <button type="submit" class="btn btn-primary pull-right">
                                            <i class="fa fa-floppy-o"></i> Registrar</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <!--fin-->
                </div>
            </div>
        </div> 
        <!--archivos js-->  
        <?php require '../../menu/js_lte.ctp'; ?>

        <script>
            /*PARA TIEMPO DE MENSAJE*/
            $("#mensaje").delay(1000).slideUp(100, function () {
                $(this).alert('close');
            })
        </script>


    </body>
</html>
