<?php if(!class_exists('raintpl')){exit;}?><?php $tpl = new RainTPL;$tpl_dir_temp = self::$tpl_dir;$tpl->assign( $this->var );$tpl->draw( dirname("header") . ( substr("header",-1,1) != "/" ? "/" : "" ) . basename("header") );?>


<script type="text/javascript" src="<?php echo $fsc->get_js_location('provincias.js');?>"></script>
<script type="text/javascript">
    $(document).ready(function () {
        document.f_custom_search.query.focus();
        if (window.location.hash.substring(1) == 'nuevo') {
            $("#modal_nuevo_proveedor").modal('show');
            document.f_nuevo_proveedor.nombre.focus();
        }
        $("#b_nuevo_proveedor").click(function (event) {
            event.preventDefault();
            $("#modal_nuevo_proveedor").modal('show');
            document.f_nuevo_proveedor.nombre.focus();
        });
    });
</script>

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-7 col-xs-12">
            <div class="btn-group hidden-xs">
                <a class="btn btn-sm btn-default" href="<?php echo $fsc->url();?>" title="Recargar la página">
                    <span class="glyphicon glyphicon-refresh"></span>
                </a>
                <?php if( $fsc->page->is_default() ){ ?>

                <a class="btn btn-sm btn-default active" href="<?php echo $fsc->url();?>&amp;default_page=FALSE" title="Marcada como página de inicio (pulsa de nuevo para desmarcar)">
                    <i class="fa fa-bookmark" aria-hidden="true"></i>
                </a>
                <?php }else{ ?>

                <a class="btn btn-sm btn-default" href="<?php echo $fsc->url();?>&amp;default_page=TRUE" title="Marcar como página de inicio">
                    <i class="fa fa-bookmark-o" aria-hidden="true"></i>
                </a>
                <?php } ?>

            </div>
            <div class="btn-group">
                <a href="#" id="b_nuevo_proveedor" class="btn btn-sm btn-success">
                    <span class="glyphicon glyphicon-plus"></span>
                    <span class="hidden-xs">&nbsp;Nuevo</span>
                </a>
                <?php $loop_var1=$fsc->extensions; $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

                <?php if( $value1->type=='button' ){ ?>

                <a href="index.php?page=<?php echo $value1->from;?><?php echo $value1->params;?>" class="btn btn-sm btn-default"><?php echo $value1->text;?></a>
                <?php } ?>

                <?php } ?>

            </div>
        </div>
        <div class="col-sm-5 col-xs-12 text-right">
            <h2 style="margin-top: 0px;">
                <i class="fa fa-users hidden-xs" aria-hidden="true"></i> Proveedores
                <span class="hidden-xs hidden-sm">/ Acreedores</span>
            </h2>
        </div>
    </div>
</div>

<div id="tab_proveedores" role="tabpanel">
    <ul class="nav nav-tabs">
        <li role="presentation" class="active">
            <a href="<?php echo $fsc->url();?>">
                <span class="glyphicon glyphicon-search"></span>
                <span class="hidden-xs">&nbsp;Resultados</span>
                <span class="badge"><?php echo $fsc->num_resultados;?></span>
            </a>
        </li>
        <?php $loop_var1=$fsc->extensions; $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

        <?php if( $value1->type=='tab' ){ ?>

        <li role="presentation">
            <a href="#ext_<?php echo $value1->name;?>" aria-controls="ext_<?php echo $value1->name;?>" role="tab" data-toggle="tab"><?php echo $value1->text;?></a>
        </li>
        <?php } ?>

        <?php } ?>

    </ul>
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="home">
            <form name="f_custom_search" action="<?php echo $fsc->url();?>" method="post" class="form">
                <div class="container-fluid" style="margin-top: 15px; margin-bottom: 10px;">
                    <div class="row">
                        <div class="col-sm-2">
                            <div class="input-group">
                                <input class="form-control" type="text" name="query" value="<?php echo $fsc->query;?>" autocomplete="off" placeholder="Buscar">
                                <span class="input-group-btn hidden-sm">
                                    <button class="btn btn-primary" type="submit">
                                        <span class="glyphicon glyphicon-search"></span>
                                    </button>
                                </span>
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <select name="tipo" class="form-control" onchange="this.form.submit()">
                                <option value="">Todos</option>
                                <option value="">------</option>
                                <option value="acreedores"<?php if( $fsc->tipo=='acreedores' ){ ?> selected=""<?php } ?>>Acreedores</option>
                                <option value="noacreedores"<?php if( $fsc->tipo=='noacreedores' ){ ?> selected=""<?php } ?>>No acreedores</option>
                            </select>
                        </div>
                        <div class="col-sm-6">
                            <div class="checkbox">
                                <label>
                                    <?php if( $fsc->debaja ){ ?>

                                    <input type="checkbox" name="debaja" value="TRUE" checked="" onchange="this.form.submit()"/>
                                    <?php }else{ ?>

                                    <input type="checkbox" name="debaja" value="TRUE" onchange="this.form.submit()"/>
                                    <?php } ?>

                                    de baja
                                </label>
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <span class="glyphicon glyphicon-sort-by-attributes-alt"></span>
                                </div>
                                <select name="orden" class="form-control" onchange="this.form.submit()">
                                    <?php $loop_var1=$fsc->orden(); $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

                                    <?php if( $fsc->orden==$key1 ){ ?>

                                    <option value="<?php echo $key1;?>" selected=""><?php echo $value1;?></option>
                                    <?php }else{ ?>

                                    <option value="<?php echo $key1;?>"><?php echo $value1;?></option>
                                    <?php } ?>

                                    <?php } ?>

                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th class="text-left">Código + Nombre</th>
                            <th class="text-left"><?php  echo FS_CIFNIF;?></th>
                            <th class="text-left">email</th>
                            <th class="text-left">Teléfono</th>
                            <th class="text-left">Observaciones</th>
                        </tr>
                    </thead>
                    <?php $loop_var1=$fsc->resultados; $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

                    <tr class='clickableRow<?php if( $value1->debaja ){ ?> danger<?php } ?>' href='<?php echo $value1->url();?>'>
                        <td>
                            <a href="<?php echo $value1->url();?>"><?php echo $value1->codproveedor;?></a> <?php echo $value1->nombre;?>

                            <?php if( $value1->nombre!=$value1->razonsocial ){ ?>

                            <span class="label label-default"><?php echo $value1->razonsocial;?></span>
                            <?php } ?>

                            <?php if( $value1->acreedor ){ ?>

                            &nbsp; <span class="glyphicon glyphicon-briefcase" title="Es un acreedor"></span>
                            <?php } ?>

                            <?php if( $value1->debaja ){ ?>

                            &nbsp; <span class="label label-danger hidden-sm" title="proveedor dado de baja">Baja</span>
                            <?php } ?>

                        </td>
                        <td><?php echo $value1->cifnif;?></td>
                        <td><?php echo $value1->email;?></td>
                        <td>
                            <?php if( $value1->telefono1 ){ ?><?php echo $value1->telefono1;?><?php }elseif( $value1->telefono2 ){ ?><?php echo $value1->telefono2;?><?php } ?>

                        </td>
                        <td><?php echo $value1->observaciones_resume();?></td>
                    </tr>
                    <?php }else{ ?>

                    <tr class="warning">
                        <td colspan="5">
                            Ningún proveedor encontrado. Pulsa el botón <b>Nuevo</b> para crear uno.
                        </td>
                    </tr>
                    <?php } ?>

                </table>
            </div>
            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-12 text-center">
                        <ul class="pagination">
                            <?php $loop_var1=$fsc->paginas(); $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

                            <li<?php if( $value1['actual'] ){ ?> class="active"<?php } ?>>
                                <a href="<?php echo $value1['url'];?>"><?php echo $value1['num'];?></a>
                            </li>
                            <?php } ?>

                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <?php $loop_var1=$fsc->extensions; $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

        <?php if( $value1->type=='tab' ){ ?>

        <div role="tabpanel" class="tab-pane" id="ext_<?php echo $value1->name;?>">
            <iframe src="index.php?page=<?php echo $value1->from;?><?php echo $value1->params;?>" width="100%" height="2000" frameborder="0"></iframe>
        </div>
        <?php } ?>

        <?php } ?>

    </div>
</div>

<?php $tpl = new RainTPL;$tpl_dir_temp = self::$tpl_dir;$tpl->assign( $this->var );$tpl->draw( dirname("block/compras_proveedores_nuevo") . ( substr("block/compras_proveedores_nuevo",-1,1) != "/" ? "/" : "" ) . basename("block/compras_proveedores_nuevo") );?>

<?php $tpl = new RainTPL;$tpl_dir_temp = self::$tpl_dir;$tpl->assign( $this->var );$tpl->draw( dirname("footer") . ( substr("footer",-1,1) != "/" ? "/" : "" ) . basename("footer") );?>