@extends('adminlte::page')

@section('title', 'Generar Licencia')

@section('content_header')
    <h1>Generar Nueva Licencia</h1>
@stop

@section('content')
    <div class="card card-success">
        <form action="{{ route('admin.licenses.store') }}" method="POST">
            @csrf
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label>Cliente</label>
                            <select name="client_id" class="form-control select2" required>
                                <option value="">Seleccione un cliente...</option>
                                @foreach($clients as $client)
                                    <option value="{{ $client->id }}" {{ (isset($selectedClient) && $selectedClient == $client->id) ? 'selected' : '' }}>
                                        {{ $client->name }} ({{ $client->rif_ci }})
                                    </option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label>Serial de Activación (Generado Automáticamente)</label>
                            <div class="input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="fas fa-key"></i></span>
                                </div>
                                <input type="text" name="license_key" value="{{ $preKey }}" class="form-control text-monospace font-weight-bold" readonly>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-md-4">
                        <div class="form-group">
                            <label>Tipo de Plan</label>
                            <select name="type" class="form-control">
                                <option value="MONTHLY">Mensual (30 Días)</option>
                                <option value="YEARLY">Anual (1 Año)</option>
                                <option value="LIFETIME">Vitalicia (De por vida)</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="form-group">
                            <label>Conexiones (Cajas) Permitidas</label>
                            <input type="number" name="max_connections" value="1" min="1" class="form-control">
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="form-group">
                            <label>Estado Inicial</label>
                            <select name="status" class="form-control" readonly>
                                <option value="ACTIVE">ACTIVA</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <button type="submit" class="btn btn-success btn-lg btn-block">
                    <i class="fas fa-save"></i> GUARDAR Y GENERAR
                </button>
            </div>
        </form>
    </div>
@stop