@extends('component.app')
@section('title', 'Outlet Laundry')
@section('active10', 'active')
@section('menu1', 'open')
@section('content')
    <div class="content-wrapper">
        <div class="container-xxl flex-grow-1 container-p-y">
            <div class="card">
                <div class="header-menu d-flex justify-content-between align-items-center">
                    <h4 class="card-header">Data Outlet Laundry</h4>
                    <button type="button" class="btn btn-primary me-2" data-bs-toggle="modal"
                        data-bs-target="#staticBackdrop"><i class="bx bx-plus bx-sm"></i> Add</button>
                </div>
                <div class="table-responsive ">
                    <table class="table table-hover" id="Mytable">
                        <thead class="table-primary text-center">
                            <tr>
                                <th scope="col">Id</th>
                                <th scope="col">Brand</th>

                                <th scope="col">Nama Laundry</th>
                                <th scope="col">Email</th>
                                <th scope="col">Alamat</th>
                                <th scope="col">Status</th>
                                <th scope="col">Tgl Daftar</th>
                                <th scope="col">Aktivasi Pro</th>
                                {{-- <th scope="col">Daftar Pro</th> --}}
                                <th scope="col">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach ($data as $data)
                                <tr>
                                    <th scope="row">{{ $data->id }}</th>
                                    <td scope="row">{{ $data->brand->nama_brand }}</td>
                                    <td>{{ $data->nama_laundry }}</td>
                                    <td>{{ $data->email }}</td>
                                    <td>{{ $data->alamat }}</td>

                                    <td>
                                        @if ($data->status == 'pro')
                                            <span class="badge bg-label-success me-1">Pro</span>
                                        @elseif ($data->status == 'trial')
                                            <span class="badge bg-label-danger me-1">Trial</span>
                                        @endif
                                    </td>
                                    <td>{{ Carbon\Carbon::parse($data->tgl_daftar)->format('d M Y') }}
                                    </td>
                                    <td>{{ $data->tgl_pro == null ? '-' : Carbon\Carbon::parse($data->tgl_pro)->format('d M Y') }}
                                    </td>
                                    {{-- <td>
                                        <a href="#" class="btn btn-sm bg-success btn-label-primary">
                                            Pro</a>
                                    </td> --}}
                                    <td><a href="{{ route('laundry.edit', $data->id) }}"
                                            class="btn btn-sm btn-label-secondary"> <i class="bx bx-edit-alt"></i></a>
                                    </td>

                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>

            </div>

            <!-- Modal -->
            <div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
                aria-labelledby="staticBackdropLabel" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content ">
                        <div class="modal-header">
                            <h4 class="modal-title" id="staticBackdropLabel">Tambah Data</h4>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                        </div>
                        <div class="modal-body">
                            <form action="{{ route('laundry.store') }}" method="POST" enctype="multipart/form-data">
                                @csrf
                                <div class="row">
                                    <div class="col-md-6">
                                        <!-- Users ID -->
                                        <h5>Data Admin Pengelola</h5>
                                        <div class="row">
                                            <!-- Kolom Kiri -->
                                            <div class="col-md-12">
                                                <!-- Username -->
                                                <div class="mb-3">
                                                    <label for="username" class="form-label">Username</label>
                                                    <input type="text" class="form-control" id="username"
                                                        name="username" placeholder="Masukkan Username" required>
                                                </div>

                                                <!-- Email -->
                                                <div class="mb-3">
                                                    <label for="email" class="form-label">Email</label>
                                                    <input type="email" class="form-control" id="email"
                                                        name="email_admin" placeholder="Masukkan Email" required>
                                                </div>

                                                <!-- Password -->
                                                <div class="mb-3">
                                                    <label for="password" class="form-label">Password</label>
                                                    <input type="password" class="form-control" id="password"
                                                        name="password" placeholder="Masukkan Password" required>
                                                </div>

                                                <!-- Phone -->
                                                <div class="mb-3">
                                                    <label for="phone" class="form-label">No. Telp</label>
                                                    <input type="text" class="form-control" id="no_telp" name="no_telp"
                                                        placeholder="Masukkan No. Telp" required>
                                                </div>
                                                <!-- Nama -->
                                                <div class="mb-3">
                                                    <label for="nama" class="form-label">Nama</label>
                                                    <input type="text" class="form-control" id="nama" name="nama"
                                                        placeholder="Masukkan Nama" required>
                                                </div>

                                                <!-- Alamat -->
                                                <div class="mb-3">
                                                    <label for="alamat" class="form-label">Alamat</label>
                                                    <textarea class="form-control" id="alamat" name="alamat" placeholder="Masukkan Alamat" rows="3" required></textarea>
                                                </div>

                                                <!-- Foto -->
                                                <div class="mb-3">
                                                    <label for="foto" class="form-label">Foto</label>
                                                    <input type="file" class="form-control" id="foto"
                                                        name="foto">
                                                </div>
                                            </div>


                                        </div>



                                    </div>
                                    <!-- Kolom Kiri -->
                                    <div class="col-md-6">
                                        <!-- Users ID -->
                                        <h5>Data Outlet Laundry</h5>
                                        {{-- {{ dd($brand) }} --}}
                                        @if (Auth::user()->role == 'superadmin')
                                            <div class="mb-3">
                                                <label for="brand_id" class="form-label">Brand ID</label>

                                                <select name="brand_id" id="pelanggan" class="form-select">
                                                    <option value="">--Pilih Brand--</option>


                                                    @foreach ($brand as $brand)
                                                        <option value="{{ $brand->id }}">{{ $brand->id }}
                                                            -{{ $brand->nama_brand }}</option>
                                                    @endforeach

                                                </select>
                                            </div>
                                        @elseif (Auth::user()->role == 'admin')
                                            <div class="mb-3">
                                                <label for="brand_id" class="form-label">Brand ID</label>
                                                <input type="text" class="form-control" id="brand_id"
                                                    name="brand_id" placeholder="Masukkan Brand ID"
                                                    value="{{ $brand->id }} - {{ $brand->nama_brand }}" disabled>
                                                <input type="text" class="form-control" id="brand_id"
                                                    name="brand_id" placeholder="Masukkan Brand ID"
                                                    value="{{ $brand->id }}" hidden>
                                            </div>
                                        @endif



                                        <!-- Nama Laundry -->
                                        <div class="mb-3">
                                            <label for="nama_laundry" class="form-label">Nama Laundry</label>
                                            <input type="text" class="form-control" id="nama_laundry"
                                                name="nama_laundry" placeholder="Masukkan Nama Laundry" required>
                                        </div>

                                        <!-- Alamat -->
                                        <div class="mb-3">
                                            <label for="alamat" class="form-label">Alamat</label>
                                            <textarea class="form-control" id="alamat" name="alamat" placeholder="Masukkan Alamat" rows="3" required></textarea>
                                        </div>

                                        <!-- No Telp -->
                                        <div class="mb-3">
                                            <label for="no_telp" class="form-label">No. Telp</label>
                                            <input type="text" class="form-control" id="no_telp" name="no_telp"
                                                placeholder="Masukkan No. Telp" required>
                                        </div>
                                        <div class="mb-3">
                                            <label for="email" class="form-label">Email</label>
                                            <input type="email" class="form-control" id="email" name="email"
                                                placeholder="Masukkan Email" required>
                                        </div>

                                        <div class="mb-3">
                                            <label for="foto" class="form-label">Foto Outlet</label>
                                            <input type="file" class="form-control" id="foto" name="foto"
                                                accept="image/*" required>
                                        </div>

                                        <!-- Status -->
                                        @if (Auth::user()->role == 'superadmin')
                                            <div class="mb-3">
                                                <label for="status" class="form-label">Status</label>
                                                <select class="form-select" id="status" name="status" required>
                                                    <option value="trial">Trial</option>
                                                    <option value="pro">Pro</option>
                                                </select>
                                            </div>
                                        @endif
                                    </div>


                                </div>

                                <div class="modal-footer">
                                    {{-- <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> --}}
                                    <button type="submit" class="btn btn-primary">Simpan</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            @endsection
