@extends('layouts.main-layout')

@section('title', 'Create Forecast')
    
@section('content')
<style>
    #submit_btn{
        width: 100%;
        background-color: #008080;
        color: #fff;
    }
</style>
    {{-- <div class="container"> --}}
        {{-- <!--ERROR DISPLAY-->
        <div class="row d-flex justify-content-center mb-5">
            <div class="col-md-8">
                @if ($errors->any())
                <div class="alert alert-danger">
                    @foreach ($errors->all() as $error)
                        <li style="color: #fff">{{$error}}</li>
                    @endforeach
                </div>
            @endif
                @if (Session::has('error'))
                <div class="alert alert-danger">
                    <li style="color: #fff;">{{ Session::get('error') }}</li>
                </div>
            @endif
            @if (Session::has('success'))
                <div class="alert alert-success">
                    <li style="color: #fff;">{{ Session::get('success') }}</li>
                </div>
            @endif
            </div>
        </div>
        <!--END OF ERROR DISPLAY--> --}}
        <div class="row  d-flex justify-content-center align-items-center">
            <div class="col-md-8">
                <div class="card">
                    <div class="card-body" style="display: flex; flex-direction: column; align-items: center;">
                        <div class="row mb-4">
                            <h3 class="text-muted">Change Current Price</h3>
                        </div>
                        {{-- {{ dd($price) }} --}}
                        <div class="row">
                           <form action="{{ route('pricesetup.change_price') }}"  method="POST">
                            @csrf    
                                <div class="mb-3" style="width: 250px;">
                                    <label class="form-label" for="previous_price">Current Price</label>
                                    <input class="form-control" 
                                    value="{{ $price->current_price ?? '0.00' }}" 
                                    type="number" step="0.01" name="current_price" id="previous_price" readonly>
                                </div>
                                <div class="mb-3" style="width: 250px;">
                                    <label class="form-label" for="new_price">New Price</label>
                                    <input class="form-control" 
                                    value=""
                                    type="number" step="0.01" min="0" name="new_price" id="new_price" placeholder="Enter new price here...">
                                </div>
                                <div class="mb-3" style="width: 250px;">
                                    <label class="form-label" for="description">Description of Change</label>
                                   <textarea name="description" id="description" cols="40" rows="3" maxlength="230" placeholder="Enter reason for this change"></textarea>
                                </div>
                                <div class="mb-3" style="margin-top: 20px;">
                                    <button class="btn" id="submit_btn">Submit</button>
                                </div>
                            </form> 
                        </div>
                    </div>
                </div>
            </div>
        </div>
    {{-- </div> --}}
  
  <script>
    // function appendHyphen(event, my_element) {
    //   if (event.key === " ") {
    //     const inputElement = document.getElementById(my_element);
    //     // inputElement.value += "-";
    //     inputElement.value = inputElement.value.replace(/\s+/g, '-');
    //   }
    // }

    $(document).ready(function() {
    // Iterate through each input field
    $('input').each(function() {
        // Trim and update the value
        var trimmedValue = $(this).val().trim();
        $(this).val(trimmedValue);
    });
});

  </script>

@endsection