<script src="<?php echo base_url(); ?>js/tinymce/tinymce.min.js"></script>
<div class="modal fade" id="modalAnuncioForm" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="modalAnuncioFormLabel" aria-hidden="true">
	<div class="modal-dialog modal-xl" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title" id="modalAnuncioFormLabel">Anuncio</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="formAnuncio" action="/anuncios/guardar" method="post">
					<input type="hidden" name="id" id="idAnuncio" value="0" />
					<div class="form-group row">
						<label for="titulo" class="col-lg-2 col-form-label">Título</label>
						<div class="col-lg-10">
							<input type="text" name="titulo" class="form-control input-titulo" placeholder="Título">
						</div>
					</div>
					<div class="form-group row">
						<label for="descripcion" class="col-lg-2 col-form-label">Contenido</label>
						<div class="col-lg-10">
							<textarea id="anuncioContenido" class="form-control text-contenido" name="contenido" rows="8"></textarea>
						</div>
					</div>
				</form>
			</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>

<div class="modal fade" id="modalAnuncioDetalle" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="modalAnuncioDetalleLabel" aria-hidden="true">
	<div class="modal-dialog modal-xl" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title titulo" id="modalAnuncioDetalleLabel">Anuncio</h5>
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<div class="modal-body">
				<input type="hidden" name="id" id="idAnuncioDetalle" value="0" />
				<div class="form-group contenido">
					Contenido
				</div>
				<?php
					if (in_array($_SESSION['usuario']['perfil'], [1, 2, 3])) {
					?>
					<div class="form-group lectores">
						<h5 class="clickable" data-toggle="collapse" href="#collapseTable" title="Ver lectores">Lectores</h5>
						<div id="collapseTable" class="table tabla-lectores collapse">
							<table class="table table-xs tabla-lectores">
								<tr>
									<th>Nombre</th>
									<th class="text-center">Estado</th>
									<th class="text-center">Fecha Visto</th>
									<th class="text-center">Fecha Lectura</th>
								</tr>
								<tbody class="lista-lectores">
								</tbody>
								<tfoot class="lector-copy d-none">
									<tr>
										<td class="nombre-lector"></td>
										<td class="text-center"><span class="estado-lector badge badge-pill"></span></td>
										<td class="fecha-visto text-center"></td>
										<td class="fecha-lectura text-center"></td>
									</tr>
								</tfoot>
							</table>
						</div>
					</div>
				<?php } ?>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-secondary btn-cerrar" data-dismiss="modal">Cerrar</button>
				<button type="button" class="btn btn-primary btn-leer">Marcar como leído</button>
			</div>
		</div>
	</div>
</div>


<script>
	tinymce.init({
		selector: "#anuncioContenido",
		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: '/anuncios/cargar_imagen',
	});

	<?php
		echo 'var usuarios = ' . json_encode($usuarios) . ';
		';
	?>
</script>
