<h3>Mesa de Noticias: Solicitud Lanzamientos / Novedades</h3>
<br>
<p style="font-size: 20px;font-weight: bold;color:red;">Recuerde que el sistema NO envía avisos de notificaciones, es su responsabilidad entrar a diario para verificar si hay novedades.</p>
<br>
<p style="font-size: 12px">Recuerde que el tiempo mínimo para producción de piezas digitales es de 10 días hábiles, y para gráficas de 30 días hábiles.</p>
<p style="font-size: 12px">Descargar el documento que corresponda, completar y adjuntar en este mismo formulario antes de enviar:</p>
<p style="font-size: 12px"><a href="{{ URL::to('/') }}/matriz/Matriz txt flyer evento.doc" download target="_blank">Matriz para flyers</a></p>
<p style="font-size: 12px"><a href="{{ URL::to('/') }}/matriz/Matriz para programas digitales de eventos.docx" download target="_blank">Matriz para programas digitales 2021</a></p>

<form method="POST" action="{{ URL::to('/') }}/forms/store/event" accept-charset="UTF-8" id="formulariotest" >
    <input type="hidden" name="_token" value="{{ csrf_token() }}">

    <input type="hidden" name="type" value="event">


    @include('task.forms.shared.profile-select-create')

    <br>
    <div class="form-group">
        <label for="" >Título</label><br>
        <input type="text" name="title" value="{{ old('title') }}" class="form-control">
    </div>
   <!-- <hr>-->
    <div class="row" >
        <div class="col-md-12">
            <div class="form-group">
                <label>Descripción:</label>
                <textarea onkeypress="return activarenter(event)" name="description" id="formulariotest" placeholder="Descripción (80 palabras en lo posible)"
                          class="form-control summer_event_first" rows="5">{{ old('description') }}</textarea>
            </div>
        </div>
    </div>
    <!-- <hr>-->
    <div class="row">

        <div class="col-md-4">
            <div class="form-group">

                <div class="checkbox" >
                    <label><!--name="event_is_paid"-id="event_is_paid"-name="event_cost"-->
                        <input type="checkbox" value="1" name="event_date_check" id="dateEvent"
                                {{ old('event_date_check') == '1' }}>
                        Evento sin datos fecha/horario/lugar
                    </label>
                </div>
            </div>
        </div>
    </div>

    <div class="row" id="formDate" style="display:block;">
        <div class="col-md-4">
            <div class="form-group">
                <label>Fecha:</label>
                <input type="text" name="event_date" id="event_date" readonly class="form-control" placeholder="DD/MM/AAAA" value="{{ old('event_date') }}">
                <div class="invalid-feedback" style="color: #dc3545; display: none;">
                    Debe haber una diferencia mínima de 10 días entre la fecha seleccionada y la fecha actual.
                </div>
            </div>
        </div>
        <div class="col-md-4" >
            <div class="form-group">
                <label>Horario:</label>
                <input type="text" name="event_time" id="horario" class="form-control" placeholder="HH:MM"
                       value="{{ old('event_time') }}">
            </div>
        </div>
        <div class="col-md-4" >
            <div class="form-group">
                <label>Lugar:</label>
                <input type="text" name="event_venue" id="lugar" class="form-control" placeholder="Lugar"
                       value="{{ old('event_venue') }}">
            </div>
        </div>
    </div>

<!---->
    <div class="row">
        <div class="col-md-12">
            <div class="form-group">
                <label>Disertante / Expositor:</label>
                <textarea name="event_disexp" id="disexp" placeholder="" class="form-control summer_event"
                          rows="5">{{ old('event_disexp') }}</textarea>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-2">
{{--            <div class="form-group">--}}
{{--                <label>&nbsp;</label>--}}
{{--                <div class="checkbox">--}}
{{--                    <label><!--name="event_is_paid"-id="event_is_paid"-name="event_cost"-->--}}
{{--                        <input type="checkbox" value="1" name="event_is_paid" id="datosEvent"--}}
{{--                                {{ old('event_is_paid') == '1' }}>--}}
{{--                        Arancelada - No Arancelada--}}
{{--                    </label>--}}
{{--                </div>--}}
{{--            </div>--}}
            <ul class="list-inline" id="">
                <li>
                    <div class="form-group">
                        <label>&nbsp;</label>
                        <div class="checkbox">
                            <label>
                                Arancelada
                                <input type="radio" value="1" name="event_is_paid" id="datosEvent" {{ old('event_is_paid') == '1' }}>
                            </label>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="form-group">
                        <label>&nbsp;</label>
                        <div class="checkbox">
                            <label>
                                No arancelada
                                <input type="radio" value="0" name="event_is_paid" id="datosEventNo" {{ old('event_is_paid') == '0' }}>
                            </label>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        <div class="col-md-3" id="formEvent" style="display:none;">
            <div class="form-group">
                <label>Monto:</label>
                <input type="text"  name="event_cost" class="form-control" placeholder=""
                       value="{{ old('event_cost') }}">
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-12">
            <div class="form-group">
                <label>Áreas Participantes: </label>
                <textarea name="event_participants" id="participantes" placeholder="" class="form-control summer_event"
                          rows="5">{{ old('event_participants') }}</textarea>
            </div>
        </div>
    </div>

    <h4>Contacto para Preinscripciones:</h4>
    <p id="" style="font-size:12px;color:#969696;" class="">Escriba "No poseo" sino tiene alguno de los datos de Contacto para Preinscripciones.</p>
    <hr>

    <div class="row">
        <div class="col-md-4">
            <div class="form-group">
                <label>Nombre :</label>
                <input type="text" name="event_contact_name" id="nombre" class="form-control"  placeholder=""
                       value="{{ old('event_contact_name') }}">
            </div>
        </div>
        <div class="col-md-4">
            <div class="form-group">
                <label>Email :</label>
                <input type="email" name="event_contact_email" id="email" class="form-control"  placeholder="@"
                       value="{{ old('event_contact_email') }}">
            </div>
        </div>
        <div class="col-md-4">
            <div class="form-group">
                <label>Teléfono :</label>
                <input type="text" name="event_contact_tel" id="telefono" class="form-control"  placeholder=""
                       value="{{ old('event_contact_tel') }}">
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-4">
            <div class="form-group">
                <label>Sitio Web:</label>
                <input type="text" name="event_web" id="web" class="form-control" placeholder="http://"
                       value="{{ old('event_web') }}">
            </div>
        </div>
        <div class="col-md-4">
            <div class="form-group">
                <label>Twitter:</label>
                <input type="text" name="event_twitter" id="twitter" class="form-control" placeholder=""
                       value="{{ old('event_twitter') }}">
            </div>
        </div>
        <div class="col-md-4">
            <div class="form-group">
                <label>Facebook:</label>
                <input type="text" name="event_facebook" id="facebook" class="form-control" placeholder=""
                       value="{{ old('event_facebook') }}">
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-4">
            <div class="form-group">
                <label>Otro:</label>
                <input type="text" name="event_other" id="otro" class="form-control" placeholder=""
                       value="{{ old('event_other') }}">
            </div>
        </div>
    </div>

    {{--<h4>Adjuntos:</h4>--}}

    {{--<p class="help-block">Imagén del disertante, Logos.<br>--}}
        {{--Si son fotos, adjuntar el epígrafe. Enviar todo el material gráfico posible.</p>--}}

    {{--<div id="fileuploader">Adjuntar</div>--}}
    {{--<input type="hidden" value="" name="task-files" id="task-files">--}}

    <hr>

    {{--<h4><i class="fa fa-check-square-o" aria-hidden="true"></i> &nbsp;Solicitud de cobertura</h4>--}}

    {{--<hr style="margin-bottom:0;">--}}

    {{--<ul class="list-inline" id="cobertura">--}}


        @foreach($pipelines as $index=>$pipeline)

            @if($pipeline->system == 1)
                <li   style="display:none;" >
                    <div class="form-group">
                        <label>&nbsp;</label>
                        <div class="checkbox">
                            <label>
                                <input type="checkbox" value="{{ $pipeline->id }}" name="event_coverage[]" checked >

                                {{ $pipeline->public_name ? $pipeline->public_name : $pipeline->name }}
                            </label>
                        </div>
                    </div>
                </li>
            @endif
        @endforeach
    {{--</ul>--}}

    <h4><i class="fa fa-pencil-square-o" aria-hidden="true"></i> &nbsp;Fundamentación</h4>

    <hr>

    <div class="row">
        <div class="col-md-12">
            <div class="form-group">
                <textarea name="event_foundation" id="fundamentacion"
                          placeholder="(Explique brevemente el objetivo de la solicitud y cuál sería el uso del registro realizado, medios y vías por las que se distribuirá el material resultante)"
                          class="form-control summer_event_second" rows="5">{{ old('event_foundation') }}</textarea>
            </div>
        </div>
    </div>

    <h4><i class="fa fa-check-square-o" aria-hidden="true"></i> &nbsp;Interés</h4>

    <hr style="margin-bottom:0;">

    <ul class="list-inline" id="intereses">
        <li>
            <div class="form-group">
                <label>&nbsp;</label>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" value="1" name="event_interest[]"
                               @if(is_array(old('event_interest')) && in_array(1, old('event_interest'))) checked @endif>
                        Académico
                    </label>
                </div>
            </div>
        </li>
        <li>
            <div class="form-group">
                <label>&nbsp;</label>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" value="2" name="event_interest[]"
                               @if(is_array(old('event_interest')) && in_array(2, old('event_interest'))) checked @endif>
                        Difusión
                    </label>
                </div>
            </div>
        </li>
        <li>
            <div class="form-group">
                <label>&nbsp;</label>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" value="3" name="event_interest[]"
                               @if(is_array(old('event_interest')) && in_array(3, old('event_interest'))) checked @endif>
                        Posicionamiento
                    </label>
                </div>
            </div>
        </li>
        <li>
            <div class="form-group">
                <label>&nbsp;</label>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" value="4" name="event_interest[]"
                               @if(is_array(old('event_interest')) && in_array(4, old('event_interest'))) checked @endif>
                        Promocional
                    </label>
                </div>
            </div>
        </li>
        <li>
            <div class="form-group">
                <label>&nbsp;</label>
                <div class="checkbox">
                    <label>
                        <input type="checkbox" value="5" name="event_interest[]"
                               @if(is_array(old('event_interest')) && in_array(5, old('event_interest'))) checked @endif>
                        Archivo
                    </label>
                </div>
            </div>
        </li>
    </ul>

    <h4><i class="fa fa-pencil-square-o" aria-hidden="true"></i> &nbsp;Posibles Entrevistados</h4>

    <hr>

    <div class="row">
        <div class="col-md-12">
            <div class="form-group">
                <textarea name="event_interviewed" id="entrevistados" placeholder="" class="form-control summer_event"
                          rows="5">{{ old('event_interviewed') }}</textarea>
            </div>
        </div>
    </div>

    {{--<div class="form-group">--}}

        {{--<label for="event_deadline" class="control-label">Deadline:</label>--}}
        {{--<input class="form-control" name="event_deadline" type="text" id="deadline" value="{{ old('event_deadline') }}">--}}
    {{--</div>--}}

    <h4><i class="fa fa-pencil-square-o" aria-hidden="true"></i> &nbsp;Datos de Contacto del Solicitante</h4>

    <hr>

    <div class="row">
        <div class="col-md-12">
            <div class="form-group">
                <textarea name="event_applicant" id="solicitante" placeholder="" class="form-control summer_event"
                          rows="5">{{ old('event_applicant')}}</textarea>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label for="adjuntos" class="control-label">Adjuntos:</label><br>
        <div class="task_text_borrador"></div>
        <div class="task_temporal_progress">
        <progress class="barProgress_task" max="100" value="0" style="display: none;"><span id="textProgress_task">22</span></progress>
        <ul id="file-upload-progress_task" class="list-unstyled">
        </ul>
        <ul id="file-upload-list" class="list-unstyled file-upload-list_task" data-type="task">
        </ul>
        </div>
        <span class="btn btn-success fileinput-button">
            <i class="icon-plus icon-white"></i>
            <span>Subir Archivos</span>
            <input id="fileupload" class="fileupload" multiple type="file" data-type="task" name="file" data-url="{{ url('upload') }}" style="display: inline;">
        </span>

        <input type="hidden" name="jsonIdAttachments" id="jsonIdAttachments_task" value="">
    </div>

    <hr>

    <div class="form-group">  <!-- Terms Checkbox !-->
        <div class="checkbox">
            <label>
                <input type="checkbox" value="1" class="draft" name="draft" {{ (old('draft'))? 'checked="checked"' : '' }}>
                Guardar como borrador
            </label>
            <p id="" style="font-size:12px;color:#969696;" class="">Si envía el formulario con este campo
                tildado, el contenido del formulario se guardará pero no será enviado para su procesamiento.</p>

        </div>
    </div>

    <script>let contDays = 0;</script>
    <input type="button" class="form-control"  value="Enviar" onclick="if (contDays === 1 || document.getElementById('dateEvent').checked == true) { form.submit(); }">

</form>
<style>/*
    .subattach:last-child{

        margin-bottom: 20px;
        
    }*/
    .bdn{
        color: #979797;
        height: 20px;
        font-size: 14px;
    /*  margin-bottom: 10px */
    }
    .stack_deleted{

        position: absolute !important;
        margin-left: 20px;
        line-height: 8px;
        height: 14px;
        font-size: 11px;
        width: 14px;
        padding-left: 3px;

    }
    .sub_enseptiembre{
        margin-bottom: 2px;
    }

    .subattachtask_element:first-child {
    margin-top: 6px;
    }

    .datin{
            margin-left: 6px;
            font-size: 14px;
            font-style: inherit;
            color: #979797;
            opacity: 0.7;
    }

</style>

<script>
    $(document).ready(function(){
        $('#event_date').datepicker({
            onSelect: function (date) {
                $('.invalid-feedback').css('display','none');
                let today = new Date();
                let dd = today.getDate();

                let mm = today.getMonth()+1;
                let yyyy = today.getFullYear();
                if(dd<10)
                {
                    dd='0'+dd;
                }

                if(mm<10)
                {
                    mm='0'+mm;
                }
                today = mm+'/'+dd+'/'+yyyy;

                date = date.split('/');
                let startDate = new Date(today);
                let endDate = new Date(date[1]+'/'+date[0]+'/'+date[2]);
                let numOfDates = getBusinessDatesCount(startDate,endDate)-1;
                if (numOfDates < 10){
                    $('.invalid-feedback').css('display','block');
                    contDays = 0;
                } else {
                    contDays = 1;
                }
            }
        });
    });

    function getBusinessDatesCount(startDate, endDate) {
        let count = 0;
        let curDate = startDate;
        while (curDate <= endDate) {
            let dayOfWeek = curDate.getDay();
            if(!((dayOfWeek == 6) || (dayOfWeek == 0)))
                count++;
            curDate.setDate(curDate.getDate() + 1);
        }
        return count;
    }
    function deleteAttach(id_item){

        

        swal({
          title: 'Confirmar',
          text: "Estas seguro de eliminar el archivo?",
          type: 'warning',
          showCancelButton: true,
          confirmButtonColor: '#d33',
          cancelButtonColor: '#3085d6',
          confirmButtonText: 'Eliminar'
        }).then((result) => {
          if (result.value) {


                tt = JSON.parse($("#jsonIdAttachments_task").val());


                tt.forEach( function(valor, indice, array) {

                    if(valor.id==id_item){

                        tt.splice(indice, 1);

                    }
                 });

                $("#jsonIdAttachments_task").val(JSON.stringify(tt));


                $(".subattachtask_"+id_item).remove();

                if($(".elementTheTask").length==0){

                    $(".nuevo_div").css("height","38px");
                    $("#buttonDownload").hide();

                }

          }
        })


        $(".swal2-confirm").attr("class","btn btn-danger swal2-confirm");
    //  $("swal2-popup").css("width","400px");
        $(".swal2-cancel").css("margin-left","6px");
        $(".swal2-cancel").attr("class","btn btn-primary swal2-cancel");
        $(".swal2-warning").css("width","66px");
        $(".swal2-warning").css("height","66px");
        $(".swal2-icon.swal2-warning").css("line-height","70px");

    }

</script>    
