@extends('admin.layouts.app')

@section('content')
    <section class="section">
        <div class="section-header">
            <h1>{{ $pageTitle }}</h1>
            <div class="section-header-breadcrumb">
                <div class="breadcrumb-item active"><a href="/admin/">{{trans('admin/main.dashboard')}}</a></div>
                <div class="breadcrumb-item"><a href="/admin/diploma-counters">عدادات برامج الدبلوم</a></div>
                <div class="breadcrumb-item">{{ $pageTitle }}</div>
            </div>
        </div>

        <div class="section-body">
            <div class="card">
                <div class="card-body">
                    <form method="post" action="/admin/diploma-counters/{{ $counter->id }}/update" class="form-horizontal form-bordered" id="diplomaCounterEditForm">
                        {{ csrf_field() }}

                        <div class="row">
                            <div class="col-lg-6">
                                <div class="form-group">
                                    <label for="edit_webinar_id" class="control-label">{{ trans('admin/main.course') }} <span class="text-danger">*</span></label>
                                    <select name="webinar_id" id="edit_webinar_id" class="form-control @error('webinar_id') is-invalid @enderror" required>
                                        <option value="">{{ trans('admin/main.select_course') }}</option>
                                        @foreach($webinars as $webinar)
                                            <option value="{{ $webinar->id }}" {{ ($counter->webinar_id == $webinar->id || old('webinar_id') == $webinar->id) ? 'selected' : '' }}>{{ $webinar->title }}</option>
                                        @endforeach
                                    </select>
                                    <div class="invalid-feedback">@error('webinar_id') {{ $message }} @enderror</div>
                                </div>

                                <div class="form-group">
                                    <label for="edit_orders_count" class="control-label">عدد الطلبات</label>
                                    <input type="number" name="orders_count" id="edit_orders_count" class="form-control @error('orders_count') is-invalid @enderror" value="{{ old('orders_count', $counter->orders_count) }}" min="0">
                                    <div class="invalid-feedback">@error('orders_count') {{ $message }} @enderror</div>
                                </div>

                                <div class="form-group">
                                    <label for="edit_total_sales" class="control-label">إجمالي المبيعات</label>
                                    <input type="number" name="total_sales" id="edit_total_sales" step="0.01" class="form-control @error('total_sales') is-invalid @enderror" value="{{ old('total_sales', $counter->total_sales) }}" min="0">
                                    <div class="invalid-feedback">@error('total_sales') {{ $message }} @enderror</div>
                                </div>

                                <div class="form-group">
                                    <label for="edit_products_count" class="control-label">عدد المنتجات</label>
                                    <input type="number" name="products_count" id="edit_products_count" class="form-control @error('products_count') is-invalid @enderror" value="{{ old('products_count', $counter->products_count) }}" min="0">
                                    <div class="invalid-feedback">@error('products_count') {{ $message }} @enderror</div>
                                </div>
                            </div>

                            <div class="col-lg-6">
                                <div class="form-group">
                                    <label for="edit_completion_rate" class="control-label">نسبة الإنجاز (%)</label>
                                    <input type="number" name="completion_rate" id="edit_completion_rate" class="form-control @error('completion_rate') is-invalid @enderror" value="{{ old('completion_rate', $counter->completion_rate) }}" min="0" max="100">
                                    <div class="invalid-feedback">@error('completion_rate') {{ $message }} @enderror</div>
                                </div>

                                <div class="form-group">
                                    <label for="edit_participants_count" class="control-label">عدد المشاركين</label>
                                    <input type="number" name="participants_count" id="edit_participants_count" class="form-control @error('participants_count') is-invalid @enderror" value="{{ old('participants_count', $counter->participants_count) }}" min="0">
                                    <div class="invalid-feedback">@error('participants_count') {{ $message }} @enderror</div>
                                </div>

                                <div class="form-group">
                                    <div class="custom-control custom-switch">
                                        <input type="checkbox" name="is_active" class="custom-control-input" id="edit_is_active" value="1" {{ ($counter->is_active || old('is_active')) ? 'checked' : '' }}>
                                        <label class="custom-control-label" for="edit_is_active">{{ trans('admin/main.active') }}</label>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-12">
                                <button type="submit" id="editSubmitBtn" class="btn btn-success">{{ trans('public.save') }}</button>
                                <a href="/admin/diploma-counters" class="btn btn-secondary">{{ trans('admin/main.cancel') }}</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
@endsection

