@extends('layouts.app')

@section('title')
    {{ $pageInfo['title'] }}
@endsection

@section('admin-content')
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1>{{ $pageInfo['title'] }}</h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-form"><a href="{{ route('admin.dashboard') }}">{{ __('Dashboard') }}</a> / </li>
                        <li class="breadcrumb-form active">&nbsp;{{ $pageInfo['title'] }}</li>
                    </ol>
                </div>
            </div>
        </div>
    </section>

	@php
		use App\Helpers\NextCloudHelper;
	@endphp

    <section class="content">
        <div class="container-fluid">
            <!-- Form Up Country Table -->
            <div class="row">
                <div class="col-12 mt-5">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="header-title">Form Up Country</h4>
                            <div class="data-tables">
								@include('backend.layouts.partials.messages')
								<div class="table-responsive">
									<table id="dataTable-form_up_country">
										<thead class="bg-light text-capitalize">
											<tr>
												<th>#</th>
												<th>Nama</th>
												<th>Rayon</th>
												<th>Tanggal</th>
												<th>Tujuan</th>
												<th>Jarak</th>
												<th>Total</th>
												<th>Bukti 1</th>
												<th>Bukti 2</th>
												<th>Bukti 3</th>
												<th>Account Number</th>
												<th>Status</th>
												@if (auth()->user()->can('approval.approve') || auth()->user()->can('final_approval.approve'))
													<th>Approval</th>
												@endif
												<th>Aksi</th>
											</tr>
										</thead>
										<tbody>
											@foreach ($forms['form_up_country'] as $index => $form)
												<tr>
													<td>{{ $loop->iteration }}</td>
													<td>{{ $form->user->name }}</td>
													<td>{{ $form->rayon->code }}</td>
													<td>{{ \Carbon\Carbon::parse($form->tanggal)->locale('id')->isoFormat('D MMMM Y') }}</td>
													<td>{{ $form->tujuan }}</td>
													<td>{{ $form->jarak }} km</td>
													<td>{{ number_format($form->total, 0, ',', '.') }}</td>
													<td>
														@if ($form->bukti1)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti1) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>
														@if ($form->bukti2)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti2) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>
														@if ($form->bukti3)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti3) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>{{ $form->account_number }}</td>
													<td>
														@if ($form->status == 'On Progress')
															<span class="badge badge-warning text-white">{{ $form->status }}</span>
														@elseif ($form->status == 'Approved' || $form->status == 'Final Approved')
															<span class="badge badge-success text-white">{{ $form->status }}</span>
														@else
															<span class="badge badge-danger text-white">{{ $form->status }}</span>
														@endif
													</td>
													@if (auth()->user()->can('approval.approve'))
														<td>
															{{-- approve / reject button --}}
															@if ($form->status == 'On Progress')
																<form action="{{ route('forms.up-country.approve', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-success btn-sm">
																		Approve
																	</button>
																</form>
																
																<form action="{{ route('forms.up-country.reject', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to reject this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-danger btn-sm">
																		Reject
																	</button>
																</form>
															@else
																@if ($form->approved_at)
																	{{ \Carbon\Carbon::parse($form->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
																@elseif($form->rejected_at)
																	{{ \Carbon\Carbon::parse($form->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
																@else
																	-
																@endif
															@endif
														</td>
													@elseif(auth()->user()->can('final_approval.approve'))
														<td>
															{{-- approve / reject button --}}
															@if ($form->status == 'Approved' && $form->approved_at && !$form->final_approved_at)
																<form action="{{ route('forms.up-country.final-approve', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-success btn-sm">
																		Final Approve
																	</button>
																</form>
															@else
																@if ($form->final_approved_at)
																	<form action="{{ route('forms.up-country.open', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																		@csrf
																		@method('PUT')
																		<button type="submit" class="btn btn-success btn-sm">
																			Open
																		</button>
																	</form>
																@else
																	-
																@endif
															@endif
														</td>
													@endif
													<td>
														@if (auth()->user()->can('forms.country.edit'))
															<a href="{{ route('forms.up-country.edit', $form->id) }}" class="btn btn-warning btn-sm">
																<i class="fas fa-edit text-white"></i>
															</a>
														@endif

														@if (auth()->user()->can('forms.country.delete'))
															<form action="{{ route('forms.up-country.destroy', $form->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this form?');">
																@csrf
																@method('DELETE')
																<button type="submit" class="btn btn-danger btn-sm">
																	<i class="fas fa-trash"></i>
																</button>
															</form>
														@endif
													</td>
												</tr>
											@endforeach
										</tbody>
									</table>
								</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

			<!-- Form Vehicle Running Cost Table -->
            <div class="row">
                <div class="col-12 mt-5">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="header-title">Form Vehicle Running Cost</h4>
                            <div class="data-tables">
								<div class="table-responsive">
									<table id="dataTable-form_vehicle_running_cost">
										<thead class="bg-light text-capitalize">
											<tr>
												<th>#</th>
												<th>Nama</th>
												<th>Tanggal</th>
												<th>Liter</th>
												<th>Harga</th>
												<th>Jarak</th>
												<th>Tipe Bensin</th>
												<th>Nomor Polisi</th>
												<th>Bukti 1</th>
												<th>Bukti 2</th>
												<th>Bukti 3</th>
												<th>Account Number</th>
												<th>Status</th>
												@if (auth()->user()->can('approval.approve') || auth()->user()->can('final_approval.approve'))
													<th>Approval</th>
												@endif
												<th>Aksi</th>
											</tr>
										</thead>
										<tbody>
											@foreach ($forms['form_vehicle_running_cost'] as $index => $form)
												<tr>
													<td>{{ $loop->iteration }}</td>
													<td>{{ $form->user->name }}</td>
													<td>{{ \Carbon\Carbon::parse($form->tanggal)->locale('id')->isoFormat('dddd, D MMMM Y HH:mm:ss') }}</td>
													<td>{{ $form->liter }}</td>
													<td>{{ number_format($form->harga, 0, ',', '.') }}</td>
													<td>{{ $form->jarak }}</td>
													<td>{{ $form->tipe_bensin }}</td>
													<td>{{ $form->nopol }}</td>
													<td>
														@if ($form->bukti1)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti1) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>
														@if ($form->bukti2)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti2) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>
														@if ($form->bukti3)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti3) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>{{ $form->account_number }}</td>
													<td>
														@if ($form->status == 'On Progress')
															<span class="badge badge-warning text-white">{{ $form->status }}</span>
														@elseif ($form->status == 'Approved' || $form->status == 'Final Approved')
															<span class="badge badge-success text-white">{{ $form->status }}</span>
														@else
															<span class="badge badge-danger text-white">{{ $form->status }}</span>
														@endif
													</td>
													@if (auth()->user()->can('approval.approve'))
														<td>
															{{-- approve / reject button --}}
															@if ($form->status == 'On Progress')
																<form action="{{ route('forms.vehicle.approve', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-success btn-sm">
																		Approve
																	</button>
																</form>
																
																<form action="{{ route('forms.vehicle.reject', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to reject this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-danger btn-sm">
																		Reject
																	</button>
																</form>
															@else
																@if ($form->approved_at)
																	{{ \Carbon\Carbon::parse($form->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
																@elseif($form->rejected_at)
																	{{ \Carbon\Carbon::parse($form->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
																@else
																	-
																@endif
															@endif
														</td>
													@elseif(auth()->user()->can('final_approval.approve'))
														<td>
															{{-- approve / reject button --}}
															@if ($form->status == 'Approved' && $form->approved_at && !$form->final_approved_at)
																<form action="{{ route('forms.vehicle.final-approve', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-success btn-sm">
																		Final Approve
																	</button>
																</form>
															@else
																@if ($form->final_approved_at)
																	<form action="{{ route('forms.vehicle.open', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																		@csrf
																		@method('PUT')
																		<button type="submit" class="btn btn-success btn-sm">
																			Open
																		</button>
																	</form>
																@else
																	-
																@endif
															@endif
														</td>
													@endif
													<td>
														@if (auth()->user()->can('forms.vehicle.edit'))
															<a href="{{ route('forms.vehicle.edit', $form->id) }}" class="btn btn-warning btn-sm">
																<i class="fas fa-edit text-white"></i>
															</a>
														@endif

														@if (auth()->user()->can('forms.vehicle.delete'))
															<form action="{{ route('forms.vehicle.destroy', $form->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this form?');">
																@csrf
																@method('DELETE')
																<button type="submit" class="btn btn-danger btn-sm">
																	<i class="fas fa-trash"></i>
																</button>
															</form>
														@endif
													</td>
												</tr>
											@endforeach
										</tbody>
									</table>
								</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Form Entertainment Presentation Table -->
            <div class="row">
                <div class="col-12 mt-5">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="header-title">Form Entertainment Presentation</h4>
                            <div class="data-tables">
								<div class="table-responsive">
									<table id="dataTable-form_entertainment_presentation">
										<thead class="bg-light text-capitalize">
											<tr>
												<th>#</th>
												<th>Nama</th>
												<th>Tanggal</th>
												<th>Jenis</th>
												<th>Keterangan</th>
												<th>Total</th>
												<th>Nama Penerima</th>
												<th>Bukti 1</th>
												<th>Bukti 2</th>
												<th>Bukti 3</th>
												<th>Account Number</th>
												<th>Status</th>
												@if (auth()->user()->can('approval.approve') || auth()->user()->can('final_approval.approve'))
													<th>Approval</th>
												@endif
												<th>Aksi</th>
											</tr>
										</thead>
										<tbody>
											@foreach ($forms['form_entertainment_presentation'] as $index => $form)
												<tr>
													<td>{{ $loop->iteration }}</td>
													<td>{{ $form->user->name }}</td>
													<td>{{ \Carbon\Carbon::parse($form->tanggal)->locale('id')->isoFormat('D MMMM Y') }}</td>
													<td>{{ $form->jenis }}</td>
													<td>{{ $form->keterangan }}</td>
													<td>{{ number_format($form->total, 0, ',', '.') }}</td>
													<td>{{ $form->name }}</td>
													<td>
														@if ($form->bukti1)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti1) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>
														@if ($form->bukti2)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti2) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>
														@if ($form->bukti3)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti3) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>{{ $form->account_number }}</td>
													<td>
														@if ($form->status == 'On Progress')
															<span class="badge badge-warning text-white">{{ $form->status }}</span>
														@elseif ($form->status == 'Approved' || $form->status == 'Final Approved')
															<span class="badge badge-success text-white">{{ $form->status }}</span>
														@else
															<span class="badge badge-danger text-white">{{ $form->status }}</span>
														@endif
													</td>
													@if (auth()->user()->can('approval.approve'))
														<td>
															{{-- approve / reject button --}}
															@if ($form->status == 'On Progress')
																<form action="{{ route('forms.entertainment.approve', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-success btn-sm">
																		Approve
																	</button>
																</form>
																
																<form action="{{ route('forms.entertainment.reject', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to reject this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-danger btn-sm">
																		Reject
																	</button>
																</form>
															@else
																@if ($form->approved_at)
																	{{ \Carbon\Carbon::parse($form->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
																@elseif($form->rejected_at)
																	{{ \Carbon\Carbon::parse($form->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
																@else
																	-
																@endif
															@endif
														</td>
													@elseif(auth()->user()->can('final_approval.approve'))
														<td>
															{{-- approve / reject button --}}
															@if ($form->status == 'Approved' && $form->approved_at && !$form->final_approved_at)
																<form action="{{ route('forms.entertainment.final-approve', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-success btn-sm">
																		Final Approve
																	</button>
																</form>
															@else
																@if ($form->final_approved_at)
																	<form action="{{ route('forms.entertainment.open', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																		@csrf
																		@method('PUT')
																		<button type="submit" class="btn btn-success btn-sm">
																			Open
																		</button>
																	</form>
																@else
																	-
																@endif
															@endif
														</td>
													@endif
													<td>
														@if (auth()->user()->can('forms.entertainment.edit'))
															<a href="{{ route('forms.entertainment.edit', $form->id) }}" class="btn btn-warning btn-sm">
																<i class="fas fa-edit text-white"></i>
															</a>
														@endif

														@if (auth()->user()->can('forms.entertainment.delete'))
															<form action="{{ route('forms.entertainment.destroy', $form->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this form?');">
																@csrf
																@method('DELETE')
																<button type="submit" class="btn btn-danger btn-sm">
																	<i class="fas fa-trash"></i>
																</button>
															</form>
														@endif
													</td>
												</tr>
											@endforeach
										</tbody>
									</table>
								</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Form Meeting Seminar Table -->
            <div class="row">
                <div class="col-12 mt-5">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="header-title">Form Meeting Seminar</h4>
                            <div class="data-tables">
								<div class="table-responsive">
									<table id="dataTable-form_meeting_seminar">
										<thead class="bg-light text-capitalize">
											<tr>
												<th>#</th>
												<th>Nama</th>
												<th>Tanggal</th>
												<th>Allowance</th>
												<th>Transport Ankot</th>
												<th>Hotel</th>
												<th>Total</th>
												<th>Bukti 1</th>
												<th>Bukti 2</th>
												<th>Bukti 3</th>
												<th>Account Number</th>
												<th>Status</th>
												@if (auth()->user()->can('approval.approve') || auth()->user()->can('final_approval.approve'))
													<th>Approval</th>
												@endif
												<th>Aksi</th>
											</tr>
										</thead>
										<tbody>
											@foreach ($forms['form_meeting_seminar'] as $index => $form)
												<tr>
													<td>{{ $loop->iteration }}</td>
													<td>{{ $form->user->name }}</td>
													<td>{{ \Carbon\Carbon::parse($form->created_at)->locale('id')->isoFormat('D MMMM Y') }}</td>
													<td>{{ number_format($form->allowance, 0, ',', '.') }}</td>
													<td>{{ number_format($form->transport_ankot, 0, ',', '.') }}</td>
													<td>{{ number_format($form->hotel, 0, ',', '.') }}</td>
													<td>{{ number_format($form->total, 0, ',', '.') }}</td>
													<td>
														@if ($form->bukti1)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti1) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>
														@if ($form->bukti2)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti2) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>
														@if ($form->bukti3)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti3) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>{{ $form->account_number }}</td>
													<td>
														@if ($form->status == 'On Progress')
															<span class="badge badge-warning text-white">{{ $form->status }}</span>
														@elseif ($form->status == 'Approved' || $form->status == 'Final Approved')
															<span class="badge badge-success text-white">{{ $form->status }}</span>
														@else
															<span class="badge badge-danger text-white">{{ $form->status }}</span>
														@endif
													</td>
													@if (auth()->user()->can('approval.approve'))
														<td>
															{{-- approve / reject button --}}
															@if ($form->status == 'On Progress')
																<form action="{{ route('forms.meeting.approve', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-success btn-sm">
																		Approve
																	</button>
																</form>
																
																<form action="{{ route('forms.meeting.reject', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to reject this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-danger btn-sm">
																		Reject
																	</button>
																</form>
															@else
																@if ($form->approved_at)
																	{{ \Carbon\Carbon::parse($form->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
																@elseif($form->rejected_at)
																	{{ \Carbon\Carbon::parse($form->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
																@else
																	-
																@endif
															@endif
														</td>
													@elseif(auth()->user()->can('final_approval.approve'))
														<td>
															{{-- approve / reject button --}}
															@if ($form->status == 'Approved' && $form->approved_at && !$form->final_approved_at)
																<form action="{{ route('forms.meeting.final-approve', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-success btn-sm">
																		Final Approve
																	</button>
																</form>
															@else
																@if ($form->final_approved_at)
																	<form action="{{ route('forms.meeting.open', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																		@csrf
																		@method('PUT')
																		<button type="submit" class="btn btn-success btn-sm">
																			Open
																		</button>
																	</form>
																@else
																	-
																@endif
															@endif
														</td>
													@endif
													<td>
														@if (auth()->user()->can('forms.meeting.edit'))
															<a href="{{ route('forms.meeting.edit', $form->id) }}" class="btn btn-warning btn-sm">
																<i class="fas fa-edit text-white"></i>
															</a>
														@endif

														@if (auth()->user()->can('forms.meeting.delete'))
															<form action="{{ route('forms.meeting.destroy', $form->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this form?');">
																@csrf
																@method('DELETE')
																<button type="submit" class="btn btn-danger btn-sm">
																	<i class="fas fa-trash"></i>
																</button>
															</form>
														@endif
													</td>
												</tr>
											@endforeach
										</tbody>
									</table>
								</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

			<!-- Form Others Table -->
            <div class="row">
                <div class="col-12 mt-5">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="header-title">Form Others</h4>
                            <div class="data-tables">
								<div class="table-responsive">
									<table id="dataTable-form_others">
										<thead class="bg-light text-capitalize">
											<tr>
												<th>#</th>
												<th>Nama</th>
												<th>Tanggal</th>
												<th>Jenis</th>
												<th>Keterangan</th>
												<th>Total</th>
												<th>Bukti 1</th>
												<th>Bukti 2</th>
												<th>Bukti 3</th>
												<th>Account Number</th>
												<th>Status</th>
												@if (auth()->user()->can('approval.approve') || auth()->user()->can('final_approval.approve'))
													<th>Approval</th>
												@endif
												<th>Aksi</th>
											</tr>
										</thead>
										<tbody>
											@foreach ($forms['form_others'] as $index => $form)
												<tr>
													<td>{{ $loop->iteration }}</td>
													<td>{{ $form->user->name }}</td>
													<td>{{ \Carbon\Carbon::parse($form->tanggal)->locale('id')->isoFormat('D MMMM Y') }}</td>
													<td>{{ $form->kategori->name }}</td>
													<td>{{ $form->keterangan }}</td>
													<td>{{ number_format($form->total, 0, ',', '.') }}</td>
													<td>
														@if ($form->bukti1)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti1) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>
														@if ($form->bukti2)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti2) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>
														@if ($form->bukti3)
															<a href="{{ NextCloudHelper::getFileUrl($form->bukti3) }}" target="_blank">
																Download
															</a>
														@else
															-
														@endif
													</td>
													<td>{{ $form->account_number }}</td>
													<td>
														@if ($form->status == 'On Progress')
															<span class="badge badge-warning text-white">{{ $form->status }}</span>
														@elseif ($form->status == 'Approved' || $form->status == 'Final Approved')
															<span class="badge badge-success text-white">{{ $form->status }}</span>
														@else
															<span class="badge badge-danger text-white">{{ $form->status }}</span>
														@endif
													</td>
													@if (auth()->user()->can('approval.approve'))
														<td>
															{{-- approve / reject button --}}
															@if ($form->status == 'On Progress')
																<form action="{{ route('forms.other.approve', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-success btn-sm">
																		Approve
																	</button>
																</form>
																
																<form action="{{ route('forms.other.reject', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to reject this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-danger btn-sm">
																		Reject
																	</button>
																</form>
															@else
																@if ($form->approved_at)
																	{{ \Carbon\Carbon::parse($form->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
																@elseif($form->rejected_at)
																	{{ \Carbon\Carbon::parse($form->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
																@else
																	-
																@endif
															@endif
														</td>
													@elseif(auth()->user()->can('final_approval.approve'))
														<td>
															{{-- approve / reject button --}}
															@if ($form->status == 'Approved' && $form->approved_at && !$form->final_approved_at)
																<form action="{{ route('forms.other.final-approve', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																	@csrf
																	@method('PUT')
																	<button type="submit" class="btn btn-success btn-sm">
																		Final Approve
																	</button>
																</form>
															@else
																@if ($form->final_approved_at)
																	<form action="{{ route('forms.other.open', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this form?');">
																		@csrf
																		@method('PUT')
																		<button type="submit" class="btn btn-success btn-sm">
																			Open
																		</button>
																	</form>
																@else
																	-
																@endif
															@endif
														</td>
													@endif
													<td>
														@if (auth()->user()->can('forms.other.edit'))
															<a href="{{ route('forms.other.edit', $form->id) }}" class="btn btn-warning btn-sm">
																<i class="fas fa-edit text-white"></i>
															</a>
														@endif

														@if (auth()->user()->can('forms.other.delete'))
															<form action="{{ route('forms.other.destroy', $form->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this form?');">
																@csrf
																@method('DELETE')
																<button type="submit" class="btn btn-danger btn-sm">
																	<i class="fas fa-trash"></i>
																</button>
															</form>
														@endif
													</td>
												</tr>
											@endforeach
										</tbody>
									</table>
								</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
@endsection

@section('scripts')
    <script>
        // Initialize DataTables for each table
        if ($('#dataTable-form_up_country').length) {
            $('#dataTable-form_up_country').DataTable({ responsive: false });
        }
		if ($('#dataTable-form_vehicle_running_cost').length) {
			$('#dataTable-form_vehicle_running_cost').DataTable({ responsive: false });
		}
        if ($('#dataTable-form_entertainment_presentation').length) {
            $('#dataTable-form_entertainment_presentation').DataTable({ responsive: false });
        }
        if ($('#dataTable-form_meeting_seminar').length) {
			$('#dataTable-form_meeting_seminar').DataTable({ responsive: false });
		}
		if ($('#dataTable-form_others').length) {
			$('#dataTable-form_others').DataTable({ responsive: false });
		}
    </script>
@endsection
