@extends('template.layout')

@section('content')

    <div class="portlet light portlet-fit portlet-datatable bordered" style="padding-top: 2 5px;">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject font-green sbold uppercase"> Agregar Oferta </span>
            </div>
        </div>
        <div class="portlet-body">
            @include('alerts.index')
            {{ Form::model($oferta, array('route' => array('oferta.actualizar', $oferta->id), 'id'=>'form-validation', 'method' => 'POST')) }}
            <div class="form-horizontal">
                <div class="form-group hidden">
                    {!! Form::label('id', 'id:', ['class' => 'control-label']) !!}
                    {!! Form::text('id', null, ['class' => 'form-control','required'=>'required']) !!}
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="form-group col-lg-6 col-xs-6" style="margin-right: 10px;">
                            {!! Form::label('nombre_puesto', 'Puesto:', ['class' => 'control-label']) !!}
                            {!! Form::text('nombre_puesto', null, ['class' => 'form-control','required'=>'required']) !!}

                        </div>

                        <div class="form-group col-lg-6 col-xs-6" style="margin-right: 10px;">
                            {!! Form::label('area', 'Area:', ['class' => 'control-label']) !!}
                            {!! Form::text('area', null, ['class' => 'form-control','required'=>'required']) !!}
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="form-group col-lg-6 col-xs-6" style="margin-right: 10px;">
                            {!! Form::label('disponibilidad', 'Disponibilidad:', ['class' => 'control-label']) !!}
                            {!! Form::text('disponibilidad', null, ['class' => 'form-control','required'=>'required']) !!}
                        </div>

                        <div class="form-group col-lg-6 col-xs-6 " style="margin-right: 10px;">
                            {!! Form::label('sueldo', 'Sueldo:', ['class' => 'control-label']) !!}
                            {!! Form::text('sueldo', null, ['class' => 'form-control','required'=>'required']) !!}
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="form-group col-lg-6 col-xs-6" style="margin-right: 10px;">
                            <label class="control-label" for="inicio_entrevista">Fecha inicio entrevista:</label>
                            <div id="inicio_entrevista" class="input-group date date-picker col-lg-12"
                                 data-date-format="dd-mm-yyyy">
                            <span class="input-group-btn">
                                    <button class="btn btn-default" type="button">
                                      <i class="fa fa-calendar"></i>
                                    </button>
                             </span>
                                {!! Form::text('inicio_entrevista', null, array('class' => 'form-control' , 'required' => 'required')) !!}
                            </div>

                        </div>

                        <div class="form-group col-lg-6 col-xs-6" style="margin-right: 10px;">
                            <label class="control-label" for="fin_entrevista">Fecha fin entrevista:</label>
                            <div id="fin_entrevista" class="input-group date date-picker col-lg-12"
                                 data-date-format="dd-mm-yyyy">
                            <span class="input-group-btn">
                                    <button class="btn btn-default" type="button">
                                      <i class="fa fa-calendar"></i>
                                    </button>
                             </span>
                                {!! Form::text('fin_entrevista', null, array('class' => 'form-control' , 'required' => 'required')) !!}
                            </div>

                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="form-group col-lg-4 col-xs-4" style="margin-right: 10px;">
                            {!! Form::label('requisitos', 'Requisitos:', ['class' => 'control-label']) !!}
                            {!! Form::textarea('requisitos', null, array('placeholder' => '','class' => 'form-control ','style' =>  'resize:none; height: 100px;' , 'required' => 'required')) !!}
                        </div>
                        <div class="form-group col-lg-4 col-xs-4" style="margin-right: 10px;">
                            {!! Form::label('beneficios', 'Beneficios:', ['class' => 'control-label']) !!}
                            {!! Form::textarea('beneficios', null, array('placeholder' => '','class' => 'form-control ','style' =>  'resize:none; height: 100px;' , 'required' => 'required')) !!}
                        </div>
                        <div class="form-group col-lg-4 col-xs-4 " style="margin-right: 10px;">
                            {!! Form::label('funciones', 'Funciones:', ['class' => 'control-label']) !!}
                            {!! Form::textarea('funciones', null, array('placeholder' => '','class' => 'form-control ','style' =>  'resize:none; height: 100px;' , 'required' => 'required')) !!}
                        </div>

                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="form-group col-lg-4 col-xs-4" style="margin-right: 10px;">
                            {!! Form::label('direccion', 'Dirección:', ['class' => 'control-label']) !!}
                            {!! Form::text('direccion', null, ['class' => 'form-control','required'=>'required']) !!}
                        </div>
                        <div class="form-group col-lg-4 col-xs-4" style="margin-right: 10px;">
                            {!! Form::label('anio_estimado_egreso', 'Año egreso:', ['class' => 'control-label']) !!}
                            {!! Form::text('anio_estimado_egreso', null, ['class' => 'form-control','required'=>'required']) !!}
                        </div>
                        <div class="form-group col-lg-4 col-xs-4" style="margin-right: 10px;">
                            {!! Form::label('vacantes', 'Vacantes:', ['class' => 'control-label']) !!}
                            {!! Form::number('vacantes', null, ['class' => 'form-control','required'=>'required']) !!}
                        </div>

                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="form-group col-lg-12 col-xs-12" style="margin-right: 10px;">
                            {!! Form::label('especialidades', 'Especialidad:', ['class' => 'control-label']) !!}
                            {!! Form::select('especialidades[]', $especialidades, $especialidad_oferta, ['id'=>'selectEspecialidades','multiple' => 'multiple', 'class' => 'select2','style'=>'width:100%','required'=>'required']) !!}

                        </div>
                    </div>
                </div>

                <div class="form-actions" style="text-align: center; padding-top: 50px;">
                    <a class="btn dark btn-outline" href="{{ url('gestionbolsa/misofertas')}}">Cancelar</a>
                    {!! Form::submit('Guardar', ['class' => 'btn green']) !!}
                </div>

            </div>

            {!! Form::close() !!}


        </div>
    </div>
@endsection

@section('scripts')
    <script>

        $('#inicio_entrevista').datepicker({
            language: 'es',
            autoclose: true,
            startDate: new Date(),
        })
            .on('changeDate', function(e) {
                $('#fin_entrevista').datepicker('setStartDate', e.date);
            });

        $('#fin_entrevista').datepicker({
            language: 'es',
            autoclose: true,
        })
            .on('changeDate', function(e) {
                $('#inicio_entrevista').datepicker('setEndDate', e.date);
            });

        $("#form-validation").validate({
            rules: {
                nombre_puesto: {
                    required:true,
                    pattern: '^[a-zA-Z\s]*$'
                },
                area: {
                    required:true,
                    pattern: '^[a-zA-Z\s]*$'
                },
                disponibilidad: {
                    required:true,
                    pattern: '^[a-zA-Z\s]*$'
                },
                sueldo: {
                    required:true,
                    pattern: '^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$'
                },
                vacantes: {
                    required:true,
                    pattern: '^[1-9]\d*$'
                },
            }
        });
        $('#selectEspecialidades').select2();

    </script>
@endsection