<?php
function fecha_alreves($fecha)
{
    $fechaA = '';
    $f = explode(' ', $fecha);
    $f = explode('-', $f[0]);
    //return var_dump($f);
    foreach ($f as $fp) {
        $fechaA = $fp . '-' . $fechaA;
    }
    $fechaA = substr($fechaA, 0, -1);
    return $fechaA;
}

?>

<div class="">

    <div class="page-title">

        <div class="title_left">

            <h3>CARRUSEL</h3>

        </div>

    </div>



    <div class="clearfix"></div>



    <div class="row">

        <div class="col-md-12 col-sm-12 col-xs-12">

            <div class="x_panel">

                <div class="x_title">

                    <h2>Listado Carrusel</h2>

                    <div class="clearfix"></div>

                </div>

                <div class="x_content">


                    @include('admin.carrucel.filtros', compact('data'))

                    <!--filtrado en caso de ir-->
                    @if (count($carrusel) > 0)

                        <div class="">

                            <table class="table table-striped bulk_action borde-tabla " id="tabla">

                                <thead class="fondo-tabla">

                                    <tr class="headings">

                                        <th class="column-title text-center">No.</th>

                                        <th class="column-title text-center">Texto Alternativo </th>

                                        <th class="column-titl text-center">Fecha Inicio </th>

                                        <th class="column-title text-center">Fecha Fin </th>

                                        <th class="column-title no-link last text-center"><span
                                                class="nobr">Acciones</span>

                                        </th>

                                        <th class="bulk-actions" colspan="5">

                                            <a class="antoo" style="color:#fff; font-weight:500;">Bulk Actions (

                                                <span class="action-cnt"> </span> ) <i
                                                    class="fa fa-chevron-down"></i></a>

                                        </th>

                                    </tr>

                                </thead>



                                <tbody>



                                    @foreach ($carrusel as $c)
                                        <?php
                                        
                                        $interar = $loop->iteration;
                                        ?>
                                        <tr class="even pointer">
                                            <td class="text-center" data-label="No.: ">{{ $loop->iteration }}</td>
                                            <td class="" data-label="Texto Alternativo: ">
                                                {{ mb_strtoupper($c->texto_alternativo) }}</td>
                                            <td class="text-center" data-label="Fecha Inicio: ">
                                                {{ fecha_alreves($c->fecha_inicioaviso) }}</td>
                                            <td class="text-center" data-label="Fecha Fin: ">
                                                {{ fecha_alreves($c->fecha_finaviso) }}</td>
                                            <td class="text-center" data-label="Acciones: ">

                                                <div class="btn-group">

                                                    <!-- imagen-->

                                                    <button type="button" class="btn btn-success btn-xs" title="Imagen"
                                                        data-toggle="modal"
                                                        data-target=".bs-example-modal-ig-imagen{{ $loop->iteration }}"><span
                                                            class="fa fa-file-image-o"></span></button>

                                                    <div class="modal fade bs-example-modal-ig-imagen{{ $loop->iteration }}"
                                                        tabindex="-1" role="dialog" aria-hidden="true">

                                                        <div class="modal-dialog modal-lg">

                                                            <div class="modal-content">



                                                                <div class="modal-header">

                                                                    <button type="button" class="close"
                                                                        data-dismiss="modal"><span
                                                                            aria-hidden="true">×</span>

                                                                    </button>

                                                                    <h4 class="modal-title" id="myModalLabel">

                                                                        Imagen

                                                                    </h4>

                                                                </div>

                                                                <div class="modal-body">

                                                                    <img src="{{ 'img/slider/' . $c->imagen }}"
                                                                        width="100%" height="100%">

                                                                </div>

                                                                <div class="modal-footer">

                                                                    <button type="button" class="btn btn-info"
                                                                        data-dismiss="modal">Cerrar</button>

                                                                    <!--<button type="button" class="btn btn-primary">Save changes</button>-->

                                                                </div>



                                                            </div>

                                                        </div>

                                                    </div>


                                                    <!-- documento y url -->

                                                    <?php $docus = explode(',', $c->documento);
                                                    
                                                    ?>

                                                    @if ($c->documento != '')
                                                        @foreach ($docus as $d)
                                                            <button type="button" class="btn btn-primary btn-xs"
                                                                title="Dcumento" data-toggle="modal"
                                                                data-target=".bs-example-modal-ig-documento{{ $interar . $loop->iteration }}"><span
                                                                    class="fa fa-file-pdf-o"></span></button>

                                                            <div class="modal fade bs-example-modal-ig-documento{{ $interar . $loop->iteration }}"
                                                                tabindex="-1" role="dialog" aria-hidden="true">

                                                                <div class="modal-dialog modal-lg">

                                                                    <div class="modal-content">



                                                                        <div class="modal-header">

                                                                            <button type="button" class="close"
                                                                                data-dismiss="modal"><span
                                                                                    aria-hidden="true">×</span>

                                                                            </button>

                                                                            <h4 class="modal-title" id="myModalLabel">

                                                                                Documento</h4>

                                                                        </div>

                                                                        <div class="modal-body">

                                                                            <iframe src="pdf/slider/{{ $d }}"
                                                                                width="100%" height="450px"></iframe>

                                                                        </div>

                                                                        <div class="modal-footer">

                                                                            <button type="button" class="btn btn-info"
                                                                                data-dismiss="modal">Cerrar</button>

                                                                            <!--<button type="button" class="btn btn-primary">Save changes</button>-->

                                                                        </div>



                                                                    </div>

                                                                </div>

                                                            </div>
                                                        @endforeach
                                                    @else
                                                        @if ($c->url != '')
                                                            <a href="{{ $c->url }}" target="_blank"
                                                                class="btn btn-primary btn-xs" data-toggle="tooltip"
                                                                data-placement="left"
                                                                title="{{ $c->url }}"><span
                                                                    class="fa fa-link"></span></a>
                                                        @endif
                                                    @endif

                                                    <button class="btn btn-info btn-xs" type="button"
                                                        title="Modificar carrusel"
                                                        onclick="moificar_carrusel({{ $c->id }});"><i
                                                            class="fa fa-pencil"></i></button>
                                                    @if ($c->estado == 1)
                                                        <!-- Small modal -->
                                                        <button type="button" class="btn btn-danger btn-xs"
                                                            title="Eliminar carrusel"
                                                            onclick="modalConfirmacion('Eliminar carrusel','<p>¿Está seguro de eliminarlo?</p>','delete_carrusel({{ $c->id }});');"><span
                                                                class="fa fa-trash-o"></span></button>
                                                    @endif
                                                </div>



                                            </td>

                                        </tr>
                                    @endforeach

                                </tbody>

                            </table>

                        </div>
                    @else
                        <p class="text-center">No se encontraron registros.</p>
                    @endif
                </div>

            </div>

        </div>

    </div>

</div>
