@extends('layouts.app')

@section('content')
<div class="container">
    <div class="col-md-8 offset-md-2">
        <h1>{{isset($coupon)?'Editar':'Nuevo'}} Cupon</h1>
        <hr>
        @if(isset($coupon))
            {!! Form::model($coupon,['method'=>'put','id'=>'frm']) !!}
        @else
            {!! Form::open(['id'=>'frm']) !!}
        @endif
        <div class="form-group row required">
            {!! Form::label("name","Nombre",["class"=>"col-form-label col-md-3 col-lg-2"]) !!}
            <div class="col-md-8">
                {!! Form::text("name",null,["class"=>"form-control".($errors->has('coupon')?" is-invalid":""),"autofocus",'placeholder'=>'Nombre del cupon']) !!}
                <span id="error-name" class="invalid-feedback"></span>
            </div>
        </div>
        <div class="form-group row required">
            {!! Form::label("percentage","Porcentaje",["class"=>"col-form-label col-md-3 col-lg-2"]) !!}
            <div class="col-md-8">
                {!! Form::text("percentage",null,["class"=>"form-control".($errors->has('percentage')?" is-invalid":""),"autofocus",'placeholder'=>'Porcentaje (opcional)']) !!}
                <span id="error-name" class="invalid-feedback"></span>
            </div>
        </div>
        <div class="form-group row required">
            {!! Form::label("amount","Monto",["class"=>"col-form-label col-md-3 col-lg-2"]) !!}
            <div class="col-md-8">
                {!! Form::text("amount",null,["class"=>"form-control".($errors->has('amount')?" is-invalid":""),"autofocus",'placeholder'=>'Monto (opcional)']) !!}
                <span id="error-name" class="invalid-feedback"></span>
            </div>
        </div>
        <div class="form-group row required">
            {!! Form::label("limit","No. de Cupones",["class"=>"col-form-label col-md-3 col-lg-2"]) !!}
            <div class="col-md-8">
                {!! Form::text("limit",null,["class"=>"form-control".($errors->has('limit')?" is-invalid":""),"autofocus",'placeholder'=>'No. máximo de cupones']) !!}
                <span id="error-name" class="invalid-feedback"></span>
            </div>
        </div>
        @if ($errors->any())
            <div class="alert alert-danger">
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif
        <div class="form-group row">
            <div class="col-md-3 col-lg-2"></div>
            <div class="col-md-4">
                <a href="{{url('coupons')}}" class="btn btn-danger btn-xs">
                    Atrás</a>
                {!! Form::button("Guardar",["type" => "submit","class"=>"btn btn-primary btn-xs"])!!}
            </div>
        </div>
        {!! Form::close() !!}
    </div>
</div>
@endsection
