<div class="col-md-3 mb-2">
    <div class="card shadow">
        <div class="leads rounded">

            <div class="leads_user_info ">
                <div class="d-flex flex-stack fs-5 py-2 justify-content-between">
                    <div class="fw-bold rotate collapsible active " data-bs-toggle="collapse" href="#" role="button"
                        aria-expanded="true" aria-controls="">Details
                    </div>
                    <span data-bs-toggle="tooltip" data-bs-trigger="hover" data-kt-initialized="1">
                        <a href="#" class="btn btn-sm btn-primary" data-bs-toggle="modal"
                            data-bs-target="#editSupplier">Edit Profile</a>
                    </span>
                </div>
                <hr>
                <div class="separator"></div>
                <div id="kt_user_view_details" class="collapse show">
                    <div class="fs-6">
                        <div class="d-flex align-items-center justify-content-between">
                            <div class="fw-bold mt-3">Name</div>
                            <div class="text-gray-600">{{ $singleSupplierData->supplier_name}}</div>
                        </div>

                        <div class="d-flex align-items-center justify-content-between">
                            <div class="fw-bold mt-3">Email</div>
                            <div class="text-gray-600">{{ $singleSupplierData->supplier_email}}</div>
                        </div>

                        <div class="d-flex align-items-center justify-content-between">
                            <div class="fw-bold mt-3">Mobile</div>
                            <div class="text-gray-600">
                                <p class="mb-0 text-gray-600 text-hover-primary">{{ $singleSupplierData->supplier_phone}}
                                </p>
                            </div>
                        </div>
                        <div class="d-flex align-items-center justify-content-between">

                            <div class="fw-bold mt-3">Address</div>
                            <div class="text-gray-600">{{ $singleSupplierData->supplier_address}}</div>
                        </div>

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

    <div class="card shadow mt-3">
        <div class="leads rounded">

            <div class="leads_user_info ">
                <div class="d-flex flex-stack fs-5 py-2 justify-content-between">
                    <div class="fw-bold rotate collapsible active " data-bs-toggle="collapse" href="#" role="button"
                        aria-expanded="true" aria-controls="">Payment Details
                    </div>
                    <span data-bs-toggle="tooltip" data-bs-trigger="hover" data-kt-initialized="1">
                        <a href="#" class="btn btn-sm btn-success" data-bs-toggle="modal"
                            data-bs-target="#supplierDuePayment">Due Pay</a>
                    </span>
                </div>
                <hr>
                <div class="separator"></div>
                <div id="kt_user_view_details" class="collapse show">
                    <div class="fs-6">
                        <div class="d-flex align-items-center justify-content-between">
                            <div class="fw-bold mt-3">Total Product:</div>
                            <div class="text-gray-600">{{ $subTotalProductQty}}</div>
                        </div>

                        <div class="d-flex align-items-center justify-content-between">
                            <div class="fw-bold mt-3">Net Amount:</div>
                            <div class="text-gray-600">
                                <p class="mb-0 text-primary fw-bolder">{{ $grandTotalProductPrice}}tk</p>
                            </div>
                        </div>

                        <div class="d-flex align-items-center justify-content-between">
                            <div class="fw-bold mt-3">Paid Amount:</div>
                            <div class="text-gray-600">
                                <p class="mb-0 text-success fw-bolder">{{ $totalPaidPrice}}tk</p>
                            </div>
                        </div>

                        <div class="d-flex align-items-center justify-content-between">

                            <div class="fw-bold mt-3">Due Amount:</div>
                            <div class="text-danger fw-bolder">{{ $totalDuePrice}}tk</div>
                        </div>

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


{{-- //Update Supplier... --}}
<div class="modal fade" id="editSupplier" tabindex="-1" aria-labelledby="oneInputModalLabel" aria-hidden="true"
    data-bs-backdrop='static'>
    <div class="modal-dialog modal-dialog-centered max-width-900px">
        <div class="modal-content">
            <div class="modal-header">
                <h1 class="modal-title fs-5" id="oneInputModalLabel">Update Supplier</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <form action="{{route('supplier.update', $singleSupplierData->id)}}" method="post"
                enctype="multipart/form-data">
                @csrf
                @method('put')
                <div class="modal-body p-0">
                    <div class="row px-4 my-4">
                        <div class="col-md-4 mb-3">
                            <div class="form-group">
                                <label for="supplier_name">Supplier Name<span class="text-danger">*</span>
                                </label>
                                <input type="text" name="supplier_name" required class="form-control form-control-solid"
                                    value="{{$singleSupplierData->supplier_name}}" placeholder="Name">
                            </div>

                            @error('supplier_name')
                            <span class=text-danger>{{$message}}</span>
                            @enderror
                        </div>

                        <div class="col-md-4 mb-3">
                            <div class="form-group">
                                <label for="supplier_email">Supplier Email<span class="text-danger"></span>
                                </label>
                                <input type="email" name="supplier_email" class="form-control form-control-solid"
                                    value="{{$singleSupplierData->supplier_email}}" placeholder="Email">
                            </div>

                            @error('supplier_email')
                            <span class=text-danger>{{$message}}</span>
                            @enderror
                        </div>

                        <div class="col-md-4 mb-3">
                            <div class="form-group">
                                <label for="supplier_phone">Mobile<span class="text-danger">*</span>
                                </label>
                                <input type="number" name="supplier_phone" id="supplier_phone" required
                                    class="form-control form-control-solid" value="{{$singleSupplierData->supplier_phone}}"
                                    placeholder="Mobile Number">
                            </div>

                            @error('supplier_phone')
                            <span class=text-danger>{{$message}}</span>
                            @enderror
                        </div>
                        
                        <div class="col-md-6 mb-3">
                            <div class="form-group">
                                <label for="company_name">Company Name<span class="text-danger">*</span>
                                </label>
                                <input type="text" name="company_name" id="company_name" required
                                    class="form-control form-control-solid" value="{{$singleSupplierData->company_name}}"
                                    placeholder="Company Name">
                            </div>

                            @error('company_name')
                            <span class=text-danger>{{$message}}</span>
                            @enderror
                        </div>
                        
                        <div class="col-md-6 mb-3">
                            <div class="form-group">
                                <label for="supplier_address">Address<span class="text-danger">*</span>
                                </label>
                                <input type="text" name="supplier_address" id="supplier_address" required
                                    class="form-control form-control-solid" value="{{$singleSupplierData->supplier_address}}"
                                    placeholder="Address">
                            </div>

                            @error('supplier_address')
                            <span class=text-danger>{{$message}}</span>
                            @enderror
                        </div>
                        

                        <div class="col-md-12 mb-3">
                            <div class="form-group">
                                <label for="note">Notes<span class="text-danger">*</span>
                                </label>

                                <textarea name="note" id="note" cols="10" rows="2"
                                    placeholder="Notes" class="form-control form-control-solid"
                                    required>{{$singleSupplierData->note}}</textarea>
                            </div>

                            @error('note')
                            <span class=text-danger>{{$message}}</span>
                            @enderror
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-success"
                        onclick="return checkValidateForSupplierUpdate()">Update</button>
                    <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Cancel</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    function checkValidateForSupplierUpdate() {
        var mobileNumber = $("#supplier_phone").val();
        
        if (mobileNumber != '' && mobileNumber.length != 11) {
            event.preventDefault();
            toastr.error("Mobile number must be 11 digit.");
        }
        
        return true;
    }
</script>