<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
  @include('layout.header')
    <style>
        .center {
            height:100%;
            display:flex;
            align-items:center;
            justify-content:center;

        }
        .form-input {
            width:250px;
            padding:20px;
        }
        .form-input img {
            width:100%;
            display:{{''==''?'none':'block'}};
            margin-bottom:10px;
        }
        .form-input input {
            display:none;
        }

        .form-input label {
            height:25px;
            background:#cdcdcd26;
            color:#c9c9c9;
            cursor:pointer;
            width: 75px;
            margin: 0 auto;
        }
    </style>
</head>
<body>

  <div class="container-scroller">
    @include('layout.navbar')
    <!-- partial -->
    @include('layout.breadscrum')
    <div class="container-fluid page-body-wrapper">

      @include('layout.sidebar')

      <!-- partial -->
      <div class="main-panel">
        <div class="content-wrapper">
          <div class="row">

            <div class="col-md-12 grid-margin stretch-card">

                <div class="card">
                    <div class="card-body">
                        <h4 class="card-title text-bold"><i class="mdi mdi-dots-vertical menu-icon"></i>d {{__('general.profile')}}</h4>

                            <div class="row">

                               <div class="col-12">
                                   <form method="GET">
                                    <div class="row mb-3">
                                        <div class="col-md-3">
                                            <input type="date" name="date_from" class="form-control">
                                        </div>
                                        <div class="col-md-3">
                                            <input type="date" name="date_to" class="form-control">
                                        </div>
                                        <div class="col-md-3">
                                            <select name="module" class="form-control">
                                                <option value="">All Modules</option>
                                                <option value="App\Models\User">User</option>
                                                <option value="App\Models\Patient">Patient</option>
                                                <option value="App\Models\Order">Order</option>
                                            </select>
                                        </div>
                                        <div class="col-md-2">
                                            <button class="btn btn-primary">Filter</button>
                                        </div>

                                        </div>

                                    </form>

                                    <table class="table table-bordered">
                                        <thead>
                                        <tr>
                                            <th>User</th>
                                            <th>Action</th>
                                            <th>Module</th>
                                            <th>Description</th>
                                            <th>Date</th>
                                            <th>Detail</th>
                                        </tr>
                                        </thead>

                                        <tbody>
                                        @foreach($activities as $activity)
                                        <tr>
                                            <td>{{ $activity->causer->name ?? 'System' }}</td>
                                            <td>{{ $activity->event }}</td>
                                            <td>{{ class_basename($activity->subject_type) }}</td>
                                            <td>{{ $activity->description }}</td>
                                            <td>{{ $activity->created_at->format('Y-m-d H:i') }}</td>
                                            <td>
                                                <button class="btn btn-sm btn-info" onclick='showDetail(@json($activity->properties))'>View</button>
                                            </td>
                                        </tr>
                                        @endforeach
                                        </tbody>

                                    </table>

                                        {{ $activities->links() }}
                               </div>
                            </div>

                    </div>
                </div>
            </div>

          </div>
        </div>


        @include('layout.footer')
      </div>
    </div>
  </div>
  @include('layout.common_script')

</body>

<script>

function showDetail(data)
{
    let oldData = JSON.stringify(data.old, null, 2);
    let newData = JSON.stringify(data.attributes, null, 2);

    Swal.fire({
        title: 'Change Detail',
        html:
        "<b>Before</b><pre>"+oldData+"</pre>"+
        "<b>After</b><pre>"+newData+"</pre>",
        width:800
    });
}

</html>

