
@extends("layouts.metor.admin")
@section("content")
@section("title","Update Shifts")

<div class="row">
    <div class="col-xl-12 col-lg-12">
        <div class="alert alert-success my-3" style="display:none;" id="success"></div>
        
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <h4 class="card-title mb-0">Update Shifts</h4>
                <a href="javascript:history.back()" class="btn btn-sm btn-light">
                    <i class="ri-arrow-left-line"></i> Back
                </a>
            </div>
            
            <div class="card-body">
                <form accept-charset="utf-8" name="update-form" id="update-form" >
                    @csrf
                    <div class="row">


<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_shifts['name_req'];}}{{ $dbs_shifts['name_title']; }}:</label>
        <input type = '{{$dbs_shifts['name_html5_type'] }}' name = "name" id = "update-name" autocomplete = 'off' maxlength ='{{  $dbs_shifts['name_max'] }}'  value='{{$row->name}}' @if($dbs_shifts['name_html5_req']!='') {{ $dbs_shifts['name_html5_req'] }} = {{$dbs_shifts['name_html5_req']}} @endif class= 'form-control'  >
        <span class='text-danger' id='update-nameError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_shifts['start_time_req'];}}{{ $dbs_shifts['start_time_title']; }}:</label>
        <input type="{{ $dbs_shifts['start_time_html5_type'] }}" name="start_time" id="update-start_time" autocomplete="off" class="form-control" value='{{ $row->start_time ? substr((string)$row->start_time, 0, 5) : '' }}' @if($dbs_shifts['start_time_html5_req']!='') {{ $dbs_shifts['start_time_html5_req'] }} = {{$dbs_shifts['start_time_html5_req']}} @endif >
        <span class='text-danger' id='update-start_timeError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_shifts['end_time_req'];}}{{ $dbs_shifts['end_time_title']; }}:</label>
        <input type="{{ $dbs_shifts['end_time_html5_type'] }}" name="end_time" id="update-end_time" autocomplete="off" class="form-control" value='{{ $row->end_time ? substr((string)$row->end_time, 0, 5) : '' }}' @if($dbs_shifts['end_time_html5_req']!='') {{ $dbs_shifts['end_time_html5_req'] }} = {{$dbs_shifts['end_time_html5_req']}} @endif >
        <span class='text-danger' id='update-end_timeError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_shifts['late_after_minutes_req'];}}{{ $dbs_shifts['late_after_minutes_title']}}:</label>
        <input type = '{{$dbs_shifts['late_after_minutes_html5_type'] }}' name = "late_after_minutes" id = "update-late_after_minutes" data-maxlen='{{ $dbs_shifts['late_after_minutes_max'] }}' data-scale='{{ $dbs_shifts['late_after_minutes_scale'] ?? '' }}' autocomplete = 'off'   value='{{$row->late_after_minutes}}' @if($dbs_shifts['late_after_minutes_html5_req']!='') {{ $dbs_shifts['late_after_minutes_html5_req'] }} = {{$dbs_shifts['late_after_minutes_html5_req']}} @endif class= 'form-control'   onkeydown='validateNumericInput(event)'  oninput='validateInput(this,{{  $dbs_shifts['late_after_minutes_max'] }})' />
        <span class='text-danger' id='update-late_after_minutesError'></span>
    </div>
</div>

<div class="col-lg-4">
    <div class="mb-3">
        <label class='form-label'>{{ $dbs_shifts['status_req'];}}{{ $dbs_shifts['status_title']; }}:</label><br/>
        <div class="mt-2">
            @php
            $options = $dbs_shifts['status_array'];
            @endphp

            @foreach ($options as $key => $value)
                @php
                $checked = ($key == $row->status) ? 'checked="checked"' : '';
                @endphp

                <label class="btn btn-outline-primary">
                    <input type="radio" name="status" value="{{ $key }}" id="update-status" {{ $checked }}/> {{ $value }}
                </label>
            @endforeach
        </div>
    </div>
</div>

    
                    </div>
                    

                    <div class="p-3 mb-3 rounded">
                        <div class="row justify-content-end g-2">
                            <div class="col-lg-3">
                                <div id="edit-mode">
                                    <button type='submit' name='update-submit' id='update-submit' class='btn btn-outline-secondary w-100' data-args1='{{ route("shifts.update", $row->id) }}' data-args2='admin/shifts' onclick='addUpdate(event,"update")'>
                                        <i class="ri-save-line"></i> Save 
                                    </button>
                                </div>
                            </div>
                            <div class="col-lg-2">
                                <a href="{{ route('shifts.index') }}" class="btn btn-primary w-100">
                                    <i class="ri-close-circle-line"></i> Cancel
                                </a>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

@endsection

