@extends('template.app') 

@section('meta')
@endsection

@section('title')
    OBF Deletation
@endsection

@section('styles')
    <link href="{{ asset('assets/css/dropify.min.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/css/sweetalert2.bundle.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/css/select2.css') }}" rel="stylesheet">

    <style type="text/css">
        body {
            font-family: Arial, sans-serif;
        }
        table {
            margin-left: 45px;
            width: 100%;
            border-collapse: collapse;
            background-color: white;
            color: black;
        }
        th, td {
            border: 1px solid black;
            padding: 8px;
            text-align: left;
            line-height: 1.8;
        }
        th {
            background-color: #f2f2f2;
        }
        .right-align {
            text-align: right;
        }
        .final-deal {
            background-color: lightgray;
            font-weight: bold;
        }
        .light_gray{
            background-color: lightgray;
        }
        .text-center {
            text-align: center !important;
        }

        @media print {
            body {
                -webkit-print-color-adjust: exact;
                print-color-adjust: exact;
            }
            th, td {
                background-color: inherit !important;
            }
            .final-deal, .light_gray {
                background-color: lightgray !important;
                -webkit-print-color-adjust: exact;
                print-color-adjust: exact;
            }
            .card-body {
                margin-left: -75px;
            }
            .no-print {
                display: none !important;
            }
        }

        input[type="number"]::-webkit-inner-spin-button,
        input[type="number"]::-webkit-outer-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }

        input[type="number"] {
            -moz-appearance: textfield; /* For Firefox */
        }

        .form-group {
            margin-bottom: 0rem!important;
        }

    </style>
@endsection

@section('content')

    <div class="page-breadcrumb">
        <div class="row">
            <div class="col-7 align-self-center">
                <h4 class="page-title text-truncate text-dark font-weight-medium mb-1">OBF Deletation</h4>
                <div class="d-flex align-items-center">
                    <nav aria-label="breadcrumb" class="d-flex justify-content-between align-items-center">
                        <ol class="breadcrumb m-0 p-0">
                            <li class="breadcrumb-item"><a href="{{ route('dashboard') }}" class="text-muted">Dashboard</a></li>
                            <li class="breadcrumb-item"><a href="{{ route('obf') }}" class="text-muted">OBF</a></li>
                            <li class="breadcrumb-item text-muted active" aria-current="page">OBF Deletation</li>
                        </ol>
                    </nav>
                </div>
            </div>

            <div class="col-5 align-self-center">
                <div class="customize-input float-right"></div>
            </div>
        </div>    
    
        <div class="container-fluid" id="content-to-print">
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-body">
                            <div class="col-md-offset-3">
                                <form role="form" enctype="multipart/form-data">
                                    <div class="form-group col-md-12">
                                        <label class="control-label">Customer ID</label>
                                        <input type="text"  name="customer_id" id="customer_id" class="form-control" placeholder="Enter Customer ID" val="">
                                        <span class="kt-form__help error customer_id"></span>
                                    </div>
                                </form>
                                <button class="btn btn-outline-secondary nextBtn btn-lg pull-right submit_once mt-4" id="record_flush" type="submit">Submit</button>
                            </div>    
                        </div>
                    </div>
                </div>
            </div>   
        </div>
    </div>   
 
@endsection    

@section('scripts')
    <script>
        jQuery('#record_flush').on('click', function() {
            var id = $("#customer_id").val();
            $.ajax({
                url: "{{ route('obf_deletation_process') }}",  // Change this to your actual route
                method: "POST",
                data: {
                    _token: "{{ csrf_token() }}", // CSRF token for Laravel
                    id: id
                },
                success: function (response) {
                    if(response.code === 200){
                        toastr.success("Record Fluch Successfully!");
                        setTimeout(function() {
                            window.location.href = "{{ route('obf_deletation') }}";
                        }, 1000);
                    } else {
                         toastr.error("Something went wrong. Please try again!");
                    }
                },
                error: function (xhr) {
                    alert("Something went wrong. Please try again.");
                },
            });
        });
    </script>
@endsection    
