<div class="modal fade bs-modal-lg" id="Registro" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title caption-subject sbold"> Edición de Cita</h4>
            </div>
            <?php echo e(Form::open(['route' => $accion,'class'=>'form-horizontal','id' => 'form-validation','style'=>'padding: 5px 5px 5px 5px;'])); ?>

            <?php echo e(csrf_field()); ?>

            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <div class="col-md-12 evento-invitado">
                            <h4>Cita</h4>
                            <div class="form-body">
                                <div class="form-group hide">
                                    <?php echo Form::text('id', $cita['id'], array('placeholder' => 'id','class' => 'form-control')); ?>

                                    <?php echo Form::text('id_alm', $cita['id_alm'], array('placeholder' => 'id_alm','class' => 'form-control')); ?>

                                </div>
                                <div class="form-group">
                                    <div class="col-md-12">
                                        <label class="control-label" for="dni">Titulo</label>
                                        <?php echo Form::textarea('titulo', $cita['titulo'], array('placeholder' => 'Titulo','class' => 'form-control', 'required' => 'required', 'maxlength' => '191','size' => '30x5')); ?>

                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-md-12">
                                        <label class="control-label" for="dni">Detalle</label>
                                        <?php echo Form::textarea('detalle', $cita['detalle'], array('placeholder' => 'Detalle','class' => 'form-control', 'required' => 'required', 'maxlength' => '191','size' => '30x5')); ?>

                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-12">
                                        <label class="control-label" for="nombres">Fecha</label>
                                        <div class='input-group date' id="cita_fecha" >
                                            <?php echo Form::text('fecha', \Carbon\Carbon::parse($cita['fecha'])->format('d/m/Y H:i') , array('class' => 'form-control' , 'required' => 'required')); ?>

                                            <span class="input-group-addon">
                                            <span class="glyphicon glyphicon-calendar"></span>
                                        </span>
                                            <?php if($errors->has('fecha')): ?>
                                                <div class="help-block"><?php echo e($errors->first('fecha')); ?></div>
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-12">
                                        <label class="control-label" for="nombres">Asesor</label>
                                        <div class='input-group date' id="cita_fecha" >
                                            <select class="form-control input-md" id="lstPsicologo" name="psicologo" style="width: 100%;"></select>
                                        </span>
                                            <?php if($errors->has('psicologo')): ?>
                                                <div class="help-block"><?php echo e($errors->first('psicologo')); ?></div>
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="submit" id="submit" class="btn btn-primary mt-ladda-btn ladda-button" data-style="slide-down">
                    <span class="ladda-label">Guardar</span>
                    <span class="ladda-spinner"></span>
                </button>
            </div>
        </div>
    </div>

    <?php echo Form::close(); ?>


    <script>

        $("#form").validate({
            submitHandler: function (form) {
                var l = Ladda.create(document.querySelector('#submit'));
                l.start();
                form.submit();
            }
        });



        $("#lstPsicologo").select2({
            minimumInputLength: -1,
            minimumResultsForSearch: -1,
            tags: [],
            ajax: {
                url: "<?php echo e(route('gestion.cita.psicologo.get')); ?>",
                dataType: 'json',
                type: "GET",
                quietMillis: 50,
                processResults: function (data) {
                    return {
                        results: $.map(data, function (item) {
                            return {
                                text: item.nombre,
                                id: item.id
                            }
                        })
                    };
                }
            }
        });

        $("#lstPsicologo").select2("trigger", "select", {
            data: {
                id: "<?php echo e($cita->id_adm); ?>",
                text: "<?php echo e($ps->apellido_paterno." ".$ps->apellido_materno.", ".$ps->nombres); ?>"
            }
        });

        $('#cita_fecha').datetimepicker({
            language: 'es',
            format : 'dd/mm/yyyy hh:ii',
            autoclose: true,
            startDate: '<?php echo e(\Carbon\Carbon::now()); ?>'
        });

    </script>