<h3>Otros: Consultas</h3>
<br>
<form method="POST" action="{{ URL::to('/') }}/forms/update/other" accept-charset="UTF-8" >
    <input type="hidden" name="_token" value="{{ csrf_token() }}">

    <input type="hidden" name="type" value="email">
    <input type="hidden" name="id" value="{{ $task->id }}">
    <input type="hidden" id="task_id" name="task_id" value="{{ $task->id }}">
    <h4><i class="fa fa-pencil-square-o" aria-hidden="true"></i> &nbsp;Seleccionar Perfil</h4>

    <hr>

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


    <br>
    <h4><i class="fa fa-pencil-square-o" aria-hidden="true"></i> &nbsp;Datos de la consulta
    </h4>

    <hr>

    <div class="row">
        <div class="col-md-12"><h4></h4>

            <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="form-group">

                <label for="description" class="control-label">Descripción</label>
                <p id="" style="font-size:12px;color:#969696;" class="help-block">Campo de texto para asiento de cambios y opción de carga de archivos.</p>

                <textarea class="form-control summer_other_create" name="description" cols="50" rows="10"
                          id="description">{{ old('description',$task->taskdata->description )}}</textarea>

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

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

        {{--<label for="other_deadline" class="control-label">Deadline:</label>--}}

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

    {{--</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='deleteAttach({{ $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>Subir 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 >

    </div>

    <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({{ $has }});
    var borrador        = true;
    var task_id         = {{ $task->id }};


    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) {


            $.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>    

