@extends('layouts.app')

@section('content')
    <section class="page-header row">
        <h2> Store Content </h2>
        <ol class="breadcrumb">
            <li><a href="{{ url('') }}"> Dashboard </a></li>
            <li class="active"> Store Content </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">
                    <div class="toolbar-top">
                        <div class="row">
                            <div class="col-lg-7 col-md-6">
                                <a href="{{ url('/manage/store_contents/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>

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

                    <div class="table-responsive">
                        <table class="table table-striped table-hover" id="storeContentTable">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th style="width: 10% !important;">{{ __('core.btn_action') }}</th>
                                <th>Store</th>
                                <th>Region</th>
                                <th>Updated At</th>
                            </tr>
                            </thead>

                            <tbody>
                            @foreach ($rows 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;">
                                                <li>
                                                    <a href="{{ url('/manage/store_contents/' . $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>
                                                <li><a href="javascript://ajax" onclick="DeleteI('{{ $row->id }}');"
                                                       class="tips action-delete btn btn-sm btn-danger btn-fs"
                                                       data-toggle="tooltip" title="{{ __('core.btn_remove') }}">
                                                        <i class="fa fa-trash"></i>
                                                    </a>
                                                </li>
                                            </ul>
                                        </div>

                                    </td>
                                    <td>{{ $row->store->name }}</td>
                                    <td>{{ $row->region_code }}</td>
                                    <td>{{ $row->updated_at }}</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/store_contents/" + chkid,
                    success: function () {
                        window.location.reload();
                    }
                });
            }
        }
    </script>
@endsection