<h3>Mesa de Noticias: Solicitud Lanzamientos / Novedades</h3>


<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"><a href="{{ URL::to('/') }}/matriz/Matriz txt flyer 2021.doc" download target="_blank">Descargar Matriz para flyers</a>, completar y adjuntar en este mismo formulario antes de enviar.</p>
<form method="POST" action="{{ URL::to('/') }}/forms/update/event" accept-charset="UTF-8">
    <input type="hidden" name="_token" value="{{ csrf_token() }}">

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

    <input type="hidden" name="id" value="{{ $task->id }}">


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


    <br>
    <div class="form-group">
        <label for="" >Título</label><br>
        <input type="text" name="title" value="{{ old('title',$task->taskdata->title) }}" class="form-control">
    </div>
    <div class="row">
        <div class="col-md-12">
            <div class="form-group">
                <label>Descripcion:</label>
                <textarea name="description" id="descripcion" placeholder="Descripcion (80 palabras en lo posible)"
                          class="form-control summer_event_first" rows="5">{{ $task->taskdata->description }}</textarea>
            </div>
        </div>
    </div>


    <!--check
    Nombre: <input type="text" name="nombre" name="mayor_edad" value="1" id="mayoria_edad" >-->
    <br>
    <input type="checkbox" name="event_date_check" value="1" id="dateEvent" checked>Evento sin datos fecha/horario/lugar
    <br>

    <br>

    <div class="row" id="formDate" style="{{ old('event_date',$task->taskdata->event_date) != '' || old('event_time',$task->taskdata->event_time)!= '' || old('event_venue',$task->taskdata->event_venue) != '' ? 'display:block"' : 'display:none' }} ">
        <div class="col-md-4">
            <div class="form-group">
                <label>Fecha:</label>
                <input type="text" name="event_date" id="fecha" class="form-control" placeholder="DD/MM/AAAA"
                       value="{{ old('event_date',$task->taskdata->event_date) }}">
            </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',$task->taskdata->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',$task->taskdata->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', $task->taskdata->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', $task->taskdata->event_is_paid) == '1'}}>
                        Arancelada
                    </label>
                </div>
            </div>
        </div>
        <div class="col-md-3" id="formEvent" style="display:none;">
            <div class="form-group">
                <label>Monto:</label>
                <input type="text"  name="monto" class="form-control" placeholder=""
                       value="{{ old('event_cost', $task->taskdata->event_cost) }}">
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-12">
            <div class="form-group">
                <label>Areas Participantes: </label>
                <textarea name="event_participants" id="participantes" placeholder="" class="form-control summer_event"
                          rows="5">{{ old('event_participants', $task->taskdata->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', $task->taskdata->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', $task->taskdata->event_contact_email) }}">
            </div>
        </div>
        <div class="col-md-4">
            <div class="form-group">
                <label>Telefono :</label>
                <input type="text" name="event_contact_tel" id="telefono" class="form-control"  placeholder=""
                       value="{{ old('event_contact_tel', $task->taskdata->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', $task->taskdata->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', $task->taskdata->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',$task->taskdata->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', $task->taskdata->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->public == 1)--}}
                {{--<li @if($pipeline->hidden == 1)  style="display:none;" @endif>--}}
                    {{--<div class="form-group">--}}
                        {{--<label>&nbsp;</label>--}}
                        {{--<div class="checkbox">--}}
                            {{--<label>--}}
                                {{--<input type="checkbox" value="{{ $pipeline->id }}" name="event_coverage[]"--}}
                                       {{--@if(is_array(old('event_coverage',$task->taskdata->event_coverage)) && in_array(  $pipeline->id , old('event_coverage',$task->taskdata->event_coverage))) checked @endif--}}
                                        {{--@if($pipeline->hidden == 1)  checked @endif>--}}
                                {{--{{ $pipeline->public_name ? $pipeline->public_name : $pipeline->name }}--}}

                            {{--</label>--}}

                        {{--</div>--}}
                    {{--</div>--}}
                {{--</li>--}}
            {{--@endif--}}
            @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', $task->taskdata->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', $task->taskdata->event_interest)) && in_array(1, old('event_interest', $task->taskdata->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',$task->taskdata->event_interest) ) && in_array(2, old('event_interest', $task->taskdata->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', $task->taskdata->event_interest) ) && in_array(3, old('event_interest',$task->taskdata->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', $task->taskdata->event_interest) ) && in_array(4, old('event_interest',$task->taskdata->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',  $task->taskdata->event_interest)) && in_array(5, old('event_interest', $task->taskdata->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',$task->taskdata->event_interviewed) }}</textarea>
            </div>
        </div>
    </div>

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

        {{--<label for="event_deadline" class="control-label">Deadline:</label>--}}
        {{--@if($task->deadline)--}}
            {{--<input class="form-control" name="event_deadline" type="text" id="deadline" value="{{ date('d-m-Y', strtotime(str_replace('/', '-', $task->deadline))) }}">--}}
        {{--@else--}}
            {{--<input class="form-control" name="event_deadline" type="text" id="deadline" value="{{ date('d-m-Y', strtotime(str_replace('/', '-', $task->taskdata->deadline))) }}">--}}
        {{--@endif--}}

    {{--</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',$task->taskdata->event_applicant) }}</textarea>
            </div>
        </div>
    </div>


    <div class="form-group attach_borrador task_element">


            <?php $has= 0; ?>

            @if (is_countable($attachments))

            <label for="adjuntos" class="control-label">Archivos adjuntos:</label><br>
                
                @foreach($task->attachments as $attach)
                    <?php

                      if($attach->pivot->active == "1"){

                       ?>

                         <div class="bdn subattachtask_element subattachtask_{{$attach->id}}" ><a href='{{URL::to('/')}}/uploads/{{$attach->filename}}' target='_blank'>{{ $attach->original_name}}<span class='minidatetask_{{$attach->id}}' style='margin-left: 6px;font-size: 14px;font-style: inherit;'>{{ date('d/m/Y', strtotime($attach->created_at))}}</span></a><button type='button' onclick='deleteAttachTask({{ $attach->id}})' class='btn btn-danger btn-xs stack_deleted elementTheTask'>x</button></div>

                    <?php 
                    $has = 1; 

                    }else{ ?>

                         <div class="datin bdn subattachtask_element subattachtask_{{$attach->id}}" style="color: #979797;margin-left: 0px">{{ $attach->original_name}}<span style='margin-left: 6px;font-size: 14px;font-style: inherit;color: #979797;'>{{ date('d/m/Y', strtotime($attach->created_at))}}</span></div>
                        
                    <?php
                    }
                    ?>

                @endforeach

            @else
                <span class="task_text_borrador">No se encontraron archivos adjuntos</span>
            @endif


<div class="task_temporal_progress">
            <progress class="barProgress_task" max="100" value="0" style="display: none;margin-bottom: 6px;margin-top: 8px"><span id="textProgress_task">22</span></progress>
            <ul id="file-upload-list" class="list-unstyled file-upload-list_task" data-type="task"></ul>
            <ul id="file-upload-progress_task" class="list-unstyled"></ul>
</div>
            <button type="button" id="buttonDownload" style="width: 90px;display:none" class="btn btn-primary">Descargar</button>

            <span class="btn btn-success fileinput-button" style="visibility:hidden">
                <i class="icon-plus icon-white"></i>
                    <span>Elegir Archivos</span>
                    <input id="fileupload" class="fileupload" data-type="task" multiple type="file" name="file" data-url="{{ url('upload') }}" style="display: inline;">
            </span>

        <input type="hidden" name="jsonIdAttachments" id="jsonIdAttachments_task" value="" disabled>
        <input type="hidden" id="task_id" name="task_id" value="{{ $task->id }}">

    </div>


    <hr>

    <div class="form-group">  <!-- Terms Checkbox !-->
        <div class="checkbox">
            <label>
                <input type="checkbox" value="1" class="draft" name="draft" {{ $task->draft == '1' ? '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>


    <input type="button" class="form-control"  value="Enviar" onclick="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>

    var countAtachFiles = parseInt("{{ count($task->attachments) }}");
    var borrador        = true;
    var task_id         = {{ $task->id }};



    function deleteAttachTask(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) {


            $.ajax({

                data: {task:{{ $task->id }},attachitem:id_item},
                headers:{
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
                },
                dataType: 'json',
                url:"{{ URL::to('/') }}/tasks/{{ $task->id }}/deleteAttachtask",
                type:'POST',
                success:  function (data) {

                    if(data.status == "ok"){

                        $(".subattachtask_"+id_item).html("<div class='datin'>"+$(".subattachtask_"+id_item).children().html()+"</div>");
                        $(".subattachtask_"+id_item).css("margin-left","-6px");
                    //  console.log(id_item+" sdss");

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

                            $(".nuevo_div").css("height","38px");
                            // $(".subAttach").html("No se encontraron archivos Adjuntos");
                            $("#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> 