<?php
session_start();
require_once ("../conexion.php");
require_once('../include/sesiones.php');

$fam_id=$_GET['id']; 
 ?>
<form name="form_tarifa" id="form_tarifa" method="get" action="" target="_blank">

    <label>Categoria</label>
    <select class="form-control" name="fam_id" id="fam_id" required>
        <option value="0">Todos</option>
        <?php
            $datos = mysqli_query($con,"SELECT * FROM familias where empresa='$empresa' and fam_id='$fam_id' order by fam_nombre asc") ;
            $fila = mysqli_fetch_array( $datos );
            echo' <option value="'.$fila['fam_id'].'" selected>'.$fila['fam_nombre'].'</option>';
        ?>
        <?php
            $datos = mysqli_query($con,"SELECT * FROM familias where empresa='$empresa'") ;
            while( $fila = mysqli_fetch_array( $datos ) )
            {
                echo' <option value="'.$fila['fam_id'].'">'.$fila['fam_nombre'].'</option>';
            }
        ?>
    </select>


    <label>Tarifa</label>
    <select class="form-control" name="tar_id" id="tar_id" required>
        <?php
            $datos = mysqli_query($con,"SELECT * FROM tarifas where empresa='$empresa'") ;
            while( $fila = mysqli_fetch_array( $datos ) )
            {
                echo' <option value="'.$fila['tar_id'].'">'.$fila['tar_nombre'].'</option>';
            }
        ?>
    </select>

    <label>Marca</label>
    <select class="form-control" name="mar_id" id="mar_id" required>
        <option value="0">TODOS</option>
        <?php
            $datos = mysqli_query($con,"SELECT * FROM marca where empresa='$empresa'") ;
            while( $fila = mysqli_fetch_array( $datos ) )
            {
                echo' <option value="'.$fila['mar_id'].'">'.strtoupper($fila['mar_nombre']).'</option>';
            }
        ?>
    </select>
    <label>Inventario</label>
    <select class="form-control" name="cantidad" id="cantidad" required>
        <option value="en_stock">En Stock</option>
        <option value="todos">Todos</option>
        <option value="agotados">Agotados</option>
    </select>

    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
        <button type="submit"  class="btn btn-success" name="tarifa" value="tarifa" id="tarifa" dir="libraries/tcpdf/documentos/catalogo.php">Imprimir</button>
    </div>
</form>

<script type="text/javascript">
//funsion para boton del formulario 

$(document).ready(function()
{
  $("button[type=submit]").click(function()
   {
    var accion = $(this).attr('dir');
    $('form').attr('action', accion);
   });
});
</script>