<script src="<?php echo base_url(); ?>js/tinymce/tinymce.min.js"></script>
<div class="modal fade" id="modalTareaForm" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="modalTareaFormLabel" aria-hidden="true">
    <div class="modal-dialog modal-xl" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="modalTareaFormLabel">Tarea</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form id="formTarea" action="/tareas/guardar" method="post">
                    <input type="hidden" name="id" id="idTarea" value="0" />
                    <div class="form-group row">
                        <label for="idResponsable" class="col-lg-2 col-form-label">Responsable</label>
                        <div class="col-lg-10">
                            <select id="idResponsable" name ="id_responsable" class="form-control select-id-responsable">
                                <?php
                                    unset($usuariosActivos[0]);
                                    foreach($usuariosActivos as $k => $v) {
                                        echo '<option value="' . $k . '"' . $selected . '>' . $v . '</option>';
                                    }
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="idPrioridadTarea" class="col-lg-2 col-form-label">Prioridad</label>
                        <div class="col-lg-10">
                            <select id="idPrioridadTarea" name ="prioridad" 
                            class="form-control select-id-prioridad-tarea">
                            <?php
                                foreach($prioridades as $k => $v) {
                                    echo '<option value="' . $k . '">' . $v . '</option>';
                                }
                            ?>
                        </select>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="fechaLimite" class="col-lg-2 col-form-label">Fecha Límite</label>
                        <div class="col-lg-10">
                            <input type="date" name="fecha_limite" id="fechaLimite" class="form-control input-fecha-limite">
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="tareaTitulo" class="col-lg-2 col-form-label">Título</label>
                        <div class="col-lg-10">
                            <input type="text" id="tareaTitulo" name="titulo" class="form-control input-titulo" placeholder="Título">
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="tareaDescripcion" class="col-lg-2 col-form-label">Descripción</label>
                        <div class="col-lg-10">
                            <textarea id="tareaDescripcion" class="form-control text-descripcion" name="descripcion" rows="8"></textarea>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="idEstadoTarea" class="col-lg-2 col-form-label">Estado</label>
                        <div class="col-lg-10">
                            <select id="idEstadoTarea" name ="id_estado_tarea" 
                            class="form-control select-id-estado-tarea">
                            <?php
                                foreach($estadosTareas as $k => $v) {
                                    echo '<option value="' . $k . '">' . $v . '</option>';
                                }
                            ?>
                        </select>
                        </div>
                    </div>
                </form>

                <div class="Comentarios">
                    <h5 class="mb-3">Comentarios <span class="cantidad-comentarios badge badge-pill badge-success">0</span></h5>
                    <div class="lista-comentarios">
                    </div>
                </div>

                <div class="copy d-none">
                    <div class="comentario-contenedor mb-4">
                        <div class="comentario-izquierda">
                            <div class="comentario-avatar">L</div>
                        </div>
                        <div class="comentario-derecha">
                            <p class="mb-1"><strong>Nombre Autor</strong><span class="comentario-fecha">Fecha comentario</span></p>
                            <div class="comentario-contenido">Comentario</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger mr-auto btn-eliminar">Eliminar</button>
                <button type="button" class="btn btn-secondary btn-cerrar" data-dismiss="modal">Cerrar</button>
                <button type="button" class="btn btn-primary btn-editar">Editar</button>
            </div>
        </div>
    </div>
</div>

<script>
tinymce.init({
    selector: "#tareaDescripcion",
    language: 'es',
    branding: false,
    menubar: false,
    plugins: [
        'advlist', 'autolink', 'lists', 'link', 'image', 'charmap', 'preview',
        'anchor', 'searchreplace', 'visualblocks', 'fullscreen',
        'insertdatetime', 'media', 'table', 'code', 'help', 'wordcount'
    ],
    toolbar: 'code forecolor bold italic underline link ' +
        'alignleft aligncenter alignright alignjustify ' +
        'bullist numlist table image media blocks help',
    automatic_uploads: true,
    file_picker_types: 'image',
    automatic_uploads: true,
    images_upload_url: '/tareas/cargar_imagen',
});
    <?php
        echo 'var usuarios = ' . json_encode($usuarios) . ';
        ';
    ?>
</script>
