<?php 
    session_start();
    require '../../conexion.php';
    $tipo = consultas::get_datos("select * from tipo_articulo where tarti_cod =".$_REQUEST['vtipo']);    
    if($tipo[0]['stock']==="1"){
?>
<div class="col-md-3 col-sm-3 col-lg-3">
    <div class="form-group">
        <label >Deposito: </label>
        <?php $depositos = consultas::get_datos("select * from deposito where cod_suc=".$_SESSION['cod_suc']." and cod_depo in(select cod_depo from v_stock where tarti_cod=".$_REQUEST['vtipo'].")"); ?>
        <select name="vdep" class="form-control select2" id="depo" required="" onchange="obtener_articulos()">
                <option value="">Seleccione Deposito</option>
                <?php
                if (!empty($depositos)) {
                    foreach ($depositos as $deposito) { ?>
                        <option value="<?php echo $deposito['cod_depo']; ?>">
                            <?php echo $deposito['dep_descrip']; ?>
                        </option>
                        <?php
                    }
                } else { ?>
                    <option value="0">Debe insertar un deposito</option>
                <?php } ?>
            </select>                             
    </div>                                                    
</div> 
<?php } 
if($tipo[0]['stock']==="0"){ ?>
<div class="col-md-6 col-sm-6 col-lg-6">
    <div class="form-group">
        <label class="control-label">Producto: </label>
        <?php $articulos = consultas::get_datos("select * from v_articulos where tarti_cod=".$_REQUEST['vtipo']); ?>
        <select name="vart" class="form-control select2" id="vart" required="" onchange="obtenerprecio()" onkeyup="obtenerprecio()">
               <option value="">Seleccione Articulo</option>
               <?php
               if (!empty($articulos)) {
                   foreach ($articulos as $articulo) { ?>
                       <option value="<?php echo $articulo['id_articulo']."_".$articulo['pre_venta']; ?>">
                           <?php echo $articulo['art_descri']." ".($articulo['mar_cod']!=="0" ?$articulo['mar_descrip']:""); ?>
                       </option>
                       <?php
                   }
               } else { ?>
                   <option value="0">Debe insertar un Articulo</option>
               <?php } ?>
           </select>
    </div>
</div>    
<?php }else{ ?>
    <div class="col-md-6 col-sm-6 col-lg-6">
        <label class="control-label">Producto: </label>                                                            
        <div id="div_articulos">
            <select name="vart" class="form-control select2" id="vart" required="">
                   <option value="">Seleccione el deposito</option>
            </select>             
        </div>
    </div>
<?php } ?>
<script type="text/javascript">    
    $(".select2").select2();
</script>