@extends('layouts.app')

@section('content')
    <section class="page-header row">
        <h2> Events </h2>
        <ol class="breadcrumb">
            <li><a href="{{ url('') }}"> Dashboard </a></li>
            <li class="active"> Events</li>
        </ol>
    </section>

    <div class="page-content row">
        <div class="page-content-wrapper no-margin">
            <h3 class="section-title"> All Records </h3>
            <div class="sbox">
                <div class="sbox-content">
                    <!-- Toolbar Top -->
                    <div class="toolbar-top">
                        <div class="row">
                            <div class="col-lg-7 col-md-6">
                                <a href="{{ url('/manage/events/create') }}" class="btn btn-primary btn-sm"
                                   title="{{ __('core.btn_create') }}">
                                    <i class=" fa fa-plus "></i> Create New
                                </a>

                                @if($access['is_excel'] ==1)
                                    <div style="display: inline-flex">
                                        <button type="button" id="exportBtn" class="btn btn-success" onclick="moduleExport()" style="display: inline-flex; margin-left: 20px">Export CSV</button>
                                        <div id="exportError" class="text-danger" style="margin: auto 15px; display: none">Error while Exporting Data!</div>
                                    </div>
                                @endif
                            </div>
                            <div class="col-lg-5 col-md-6 text-right toolbar-right"></div>
                        </div>
                    </div>
                    <!-- End Toolbar Top -->

                    <div class="row">
                        {!! (isset($search_map) ? $search_map : '') !!}
                    </div>

                    <!-- Table Grid -->
                    <div class="table-responsive">
                        <table class="table table-striped table-hover" id="eventsTable">
                            <thead>
                            <tr>
                                <th style="width: 3% !important;" class="number"> #</th>
                                <th style="width: 10% !important;">{{ __('core.btn_action') }}</th>
                                <th>Slug</th>
                                <th>Start</th>
                                <th>End</th>
                                <th>Web Status</th>
                                <th>App Status</th>
                                <th>Views Count</th>
                            </tr>
                            </thead>

                            <tbody>
                            @foreach ($rowData as $row)
                                <tr>
                                    <td> {{ $row['id'] }} </td>
                                    <td>
                                        <div class="actions">
                                            <ul class="actions-menu"
                                                style="    list-style-type: none;margin: 0;padding-left: 0;">
                                                @if($access['is_edit'])
                                                    <li>
                                                        <a href="{{ url('/manage/events/'.$row['id'].'/edit') }}"
                                                           data-toggle="tooltip"
                                                           class="tips action-edit btn btn-sm btn-success btn-fs"
                                                           title="{{ __('core.btn_edit') }}">
                                                            <i class="fa fa-edit"></i>
                                                        </a>
                                                    </li>
                                                @endif
                                                @if($access['is_remove'])
                                                    <li>
                                                        <a href="javascript:" onclick="DeleteI('{{ $row['id'] }}');"
                                                           data-toggle="tooltip"
                                                           class="tips action-delete btn btn-sm btn-danger btn-fs"
                                                           title="{{ __('core.btn_remove') }}">
                                                            <i class="fa fa-trash"></i>
                                                        </a>
                                                    </li>
                                                @endif
                                            </ul>
                                        </div>
                                    </td>
                                    <td>{{$row['slug']}}</td>
                                    <td>{{$row['local_start']}}</td>
                                    <td>{{$row['local_end']}}</td>
                                    <td>{{$row['web_status'] ? 'Active' : 'Inactive'}}</td>
                                    <td>{{$row['app_status'] ? 'Active' : 'Inactive'}}</td>
                                    <td>{{$row['views_count']}}</td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        <input type="hidden" name="action_task" value=""/>
                        {!! Form::close() !!}
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        function DeleteI(chkid) {
            if (confirm('Are you sure you want to delete this row?')) {
                $.ajax({
                    type: "DELETE",
                    url: "/manage/events/" + chkid,
                    success: function () {
                        window.location.reload();
                    }
                });
            }
        }
    </script>
@stop