chore: version inicial del codigo fuente del LMS Estafeta
This commit is contained in:
@@ -0,0 +1,881 @@
|
||||
<section class="py-md-4 py-2">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1 class="text-secondary font-weight-bolder">Constancias</h1>
|
||||
<p>Sistema de gestión constancias por categoria, se pueden agregar contancias, desactivar y modificar contancias.</p>
|
||||
</div>
|
||||
<div class="col-lg-12 col-md-12 col-12"><a href="../certificate.php" target="_blank" type="button" class="btn btn-default border border-default">Ver Constancia Activa</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="py-md-4 py-2 controller">
|
||||
<div class="container-fluid">
|
||||
<div class="row align-items-center align-self-center">
|
||||
<div class="col-12">
|
||||
<table id="datatable" class="display table table-striped table-bordered" cellspacing="0" width="100%">
|
||||
<thead>
|
||||
<tr></tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="py-md-4 py-2 editor" style="display: none;">
|
||||
<div class="container-fluid">
|
||||
<div class="row align-items-center justify-content-start">
|
||||
<div class="col-12 text-left my-4">
|
||||
<h3 class="title-cat edit" style="display: none;">Editar constancia</h3>
|
||||
<h3 class="title-cat crear" style="display: none;">Crear constancia</h3>
|
||||
</div>
|
||||
<div class="col-12 col-md-10">
|
||||
<form class="formcontroller">
|
||||
<input type="hidden" name="idconstancia" id="idconstancia" value="">
|
||||
<input type="hidden" name="imgfirma" id="imgfirma" value="" required="required">
|
||||
<input type="hidden" name="urlimglogo" id="urlimglogo" value="" required="required">
|
||||
<input type="hidden" name="urlimgfondo" id="urlimgfondo" value="" required="required">
|
||||
<div class="form-group row">
|
||||
<label for="catsuperior" class="col-lg-2 col-md-2 col-12 col-form-label">Categoría</label>
|
||||
<div class="col-lg-8 col-md-10 col-12">
|
||||
<select id="catsuperior" name="catsuperior" required="required" class="form-control col-12" data-live-search="true">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-md-2 col-12 col-form-label" for="representante">Nombre del representante</label>
|
||||
<div class="col-lg-8 col-md-10 col-12">
|
||||
<input id="representante" name="representante" placeholder="Nombre del representante" type="text" class="form-control" required="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-md-2 col-12 col-form-label" for="cargo">Cargo del representante</label>
|
||||
<div class="col-lg-8 col-md-10 col-12">
|
||||
<input id="cargo" name="cargo" placeholder="Cargo del representante" type="text" class="form-control" required="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="habilitado" class="col-lg-2 col-md-2 col-12 col-form-label">Habilitado constancia</label>
|
||||
<div class="col-lg-8 col-md-10 col-12">
|
||||
<select id="habilitado" name="habilitado" class="custom-select" required="required">
|
||||
<option value="1">HABILITADO</option>
|
||||
<option value="0">DESHABILITADO</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="offset-lg-2 col-lg-10 col-md-12 col-12">
|
||||
<h6>Estilos de logo</h6>
|
||||
</div>
|
||||
<div class="offset-lg-2 col-lg-8 col-md-12 col-12">
|
||||
<hr class="border border-primary">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="habilitado_logo" class="col-lg-2 col-md-2 col-12 col-form-label">Habilitado logo</label>
|
||||
<div class="col-lg-8 col-md-10 col-12">
|
||||
<select id="habilitado_logo" name="habilitado_logo" class="custom-select" required="required">
|
||||
<option value="1">HABILITADO</option>
|
||||
<option value="0">DESHABILITADO</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config_logo">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-md-2 col-12 col-form-label">Logo</label>
|
||||
<div class="col-lg-8 col-md-10 col-12">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<p class="text-dark font-weight-bold">Se recomienda usar png y un tamaño de 512px x 512px</p>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 py-2 py-md-0">
|
||||
<div class="UppyDragDrop"></div>
|
||||
<div class="w-100 my-3">
|
||||
<div class="for-ProgressBar"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 py-2 py-md-0 preview" style="display: none;">
|
||||
<div class="card h-100">
|
||||
<div class="card-body text-center">
|
||||
<div class="ThumbnailGenerator"></div>
|
||||
<div class="uploaded-files text-secondary">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="alineacion_logo" class="col-lg-2 col-md-2 col-12 col-form-label">Alineación del logo</label>
|
||||
<div class="col-lg-8 col-md-10 col-12">
|
||||
<select id="alineacion_logo" name="alineacion_logo" class="custom-select" required="required">
|
||||
<option value="center">Centrado</option>
|
||||
<option value="left">Izquierda</option>
|
||||
<option value="right">Derecha</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="offset-lg-2 col-lg-8 col-md-10 col-12">
|
||||
<h6>Estilos de fondo</h6>
|
||||
</div>
|
||||
<div class="offset-lg-2 col-lg-8 col-md-10 col-12">
|
||||
<hr class="border border-primary">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="habilitado_fondo" class="col-lg-2 col-md-2 col-12 col-form-label">Habilitado fondo</label>
|
||||
<div class="col-lg-8 col-md-10 col-12">
|
||||
<select id="habilitado_fondo" name="habilitado_fondo" class="custom-select" required="required">
|
||||
<option value="1">HABILITADO</option>
|
||||
<option value="0">DESHABILITADO</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config_fondo">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-md-2 col-12 col-form-label">Fondo</label>
|
||||
<div class="col-lg-8 col-md-10 col-12">
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-12">
|
||||
<p class="text-dark font-weight-bold">Se recomienda usar png y un tamaño de 1500px x 1060px</p>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 py-2 py-md-0">
|
||||
<div class="UppyDragDropFondo"></div>
|
||||
<div class="w-100 my-3">
|
||||
<div class="for-ProgressBarFondo"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 py-2 py-md-0 previewFondo" style="display: none;">
|
||||
<div class="card h-100">
|
||||
<div class="card-body text-center">
|
||||
<div class="ThumbnailGeneratorFondo"></div>
|
||||
<div class="uploaded-filesFondo text-secondary">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="offset-lg-2 col-lg-10 col-md-10 col-12">
|
||||
<h6>Estilos del contenido</h6>
|
||||
</div>
|
||||
<div class="offset-lg-2 col-lg-8 col-md-10 col-12">
|
||||
<hr class="border border-primary">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="alineacion_content" class="col-lg-2 col-md-2 col-12 col-form-label">Alineación del contenido</label>
|
||||
<div class="col-lg-8 col-md-10 col-12">
|
||||
<select id="alineacion_content" name="alineacion_content" class="custom-select" required="required">
|
||||
<option value="center">Centrado</option>
|
||||
<option value="left">Izquierda</option>
|
||||
<option value="right">Derecha</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-md-2 col-12 col-form-label">Firma</label>
|
||||
<div class="col-lg-8 col-md-10 col-12">
|
||||
|
||||
<canvas id="signature" width="100%" class="col-lg-12 col-md-12 col-12 border border-primary mb-3"></canvas>
|
||||
<img id="preview" class="img-fluid border border-primary mb-3" style="display: none;" />
|
||||
<br>
|
||||
<div style="text-align:center;">
|
||||
<input type="button" id="export" class="btn btn-success btn-sm" value="Guardar firma"/>
|
||||
<input type="button" id="reset" class="btn btn-danger btn-sm" value="Limpiar firma" style="display: none;" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row justify-content-center">
|
||||
<div class="col-12 col-md-6 text-right">
|
||||
<div class="btn btn-warning btn_cancelar">Cancelar</div>
|
||||
<button name="Enviar" type="submit" value="Enviar" class="btn btn-primary">Enviar</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<script type="text/javascript">
|
||||
$(".layer-load").show();
|
||||
var table;
|
||||
jQuery(document).ready(function ($) {
|
||||
function parseJSON(resp) {
|
||||
if (resp == null) return null;
|
||||
if (typeof resp === 'object') return resp;
|
||||
try { return JSON.parse(resp); }
|
||||
catch (e) { console.error('Respuesta no-JSON del servidor:', String(resp).substring(0, 300)); return null; }
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/*********************** FIRMA ****************************************/
|
||||
/**********************************************************************/
|
||||
var canvas = document.getElementById("signature");
|
||||
var w = window.innerWidth;
|
||||
var h = window.innerHeight;
|
||||
var body = $('body').width();
|
||||
var m = $('.mainseccion').width();
|
||||
console.log('tamaño de body: '+body);
|
||||
// Como el lienzo no tiene ningún tamaño, lo especificaremos con JS
|
||||
// El ancho del canvas será el ancho del dispositivo.
|
||||
if (body <= 330) {
|
||||
canvas.width = w-65;
|
||||
canvas.height = h/1.5;
|
||||
}else if(body >= 331 && body <= 660){
|
||||
canvas.width = w-65;
|
||||
canvas.height = h/2;
|
||||
}else if (body >= 661 && body <= 850) {
|
||||
canvas.width = m-65;
|
||||
canvas.height = h/1.5;
|
||||
}else{
|
||||
canvas.width = body/2.5;
|
||||
canvas.height = h/3;
|
||||
}
|
||||
|
||||
|
||||
var signaturePad = new SignaturePad(canvas,{
|
||||
dotSize: 1
|
||||
});
|
||||
|
||||
document.getElementById("export").addEventListener("click",function(e){
|
||||
// Siéntete libre de hacer lo que quieras con la imagen
|
||||
// como exportar a un servidor o incluso guardarlo en el dispositivo.
|
||||
var imageURI = signaturePad.toDataURL();
|
||||
$('#imgfirma').val(imageURI);
|
||||
$('#preview').show();
|
||||
$('#export').hide();
|
||||
$('#reset').show();
|
||||
document.getElementById("preview").src = imageURI;
|
||||
$('#signature').hide();
|
||||
},false);
|
||||
|
||||
document.getElementById("reset").addEventListener("click",function(e){
|
||||
// Limpia el lienzo
|
||||
signaturePad.clear();
|
||||
$('#signature').show();
|
||||
$('#export').show();
|
||||
//$('#reset').hide();
|
||||
$('#preview').hide();
|
||||
$('#imgfirma').val('');
|
||||
},false);
|
||||
|
||||
/**********************************************************************/
|
||||
/****************** UPLOAD LOGO ****************************************/
|
||||
/**********************************************************************/
|
||||
var uppy = Uppy.Core({
|
||||
debug: false,
|
||||
autoProceed: true,
|
||||
allowMultipleUploads: true,
|
||||
locale: Uppy.locales.Spanish,
|
||||
restrictions: {
|
||||
allowedFileTypes: ['image/*']
|
||||
}
|
||||
});
|
||||
uppy.use(Uppy.DragDrop, {
|
||||
target: '.UppyDragDrop',
|
||||
locale: {
|
||||
strings: {
|
||||
browse: 'Buscar',
|
||||
dropHereOr: "Arrastra el archivo aqu\xed o %{browse}",
|
||||
dropHint: "Arrastra el archivo aqu\xed",
|
||||
dropPaste: "Arrastra el archivo aqu\xed, pegar o %{browse}",
|
||||
dropPasteImport: "Arrastra el archivo aqu\xed, pegar, %{browse} o importar desde",
|
||||
}
|
||||
}
|
||||
}).use(Uppy.XHRUpload, {
|
||||
headers: { 'X-CSRF-Token': window.CSRF_TOKEN },
|
||||
endpoint: "constancias_upload_logo.php",
|
||||
formData: true,
|
||||
method: 'post',
|
||||
fieldName: 'files[]'
|
||||
}).use(Uppy.ProgressBar, { target: '.for-ProgressBar', hideAfterFinish: false }).on('upload-success', function (file, response) { onUploadSuccess(file, response) });
|
||||
|
||||
function onUploadSuccess(file, response) {
|
||||
if (response.uploadURL) {
|
||||
var url = response.uploadURL;
|
||||
$("#urlimglogo").val(url);
|
||||
var fileName = file.name;
|
||||
$(".preview").show();
|
||||
$(".uploaded-files").show().addClass('newimg');
|
||||
$(".uploaded-files").html("");
|
||||
$(".uploaded-files").html('<a class="btn-link" href="' + response.uploadURL + '" target="_blank">' +
|
||||
'<img class="img-fluid" src="' + response.uploadURL + '"><br>' + fileName + '</a>');
|
||||
} else {
|
||||
Swal.fire(
|
||||
'',
|
||||
response.body.txt,
|
||||
'error'
|
||||
)
|
||||
uppy.reset();
|
||||
}
|
||||
}
|
||||
/**********************************************************************/
|
||||
/****************** UPLOAD FONDO ****************************************/
|
||||
/**********************************************************************/
|
||||
var uppyFondo = Uppy.Core({
|
||||
debug: false,
|
||||
autoProceed: true,
|
||||
allowMultipleUploads: true,
|
||||
locale: Uppy.locales.Spanish,
|
||||
restrictions: {
|
||||
allowedFileTypes: ['image/*']
|
||||
}
|
||||
});
|
||||
uppyFondo.use(Uppy.DragDrop, {
|
||||
target: '.UppyDragDropFondo',
|
||||
locale: {
|
||||
strings: {
|
||||
browse: 'Buscar',
|
||||
dropHereOr: "Arrastra el archivo aqu\xed o %{browse}",
|
||||
dropHint: "Arrastra el archivo aqu\xed",
|
||||
dropPaste: "Arrastra el archivo aqu\xed, pegar o %{browse}",
|
||||
dropPasteImport: "Arrastra el archivo aqu\xed, pegar, %{browse} o importar desde",
|
||||
}
|
||||
}
|
||||
}).use(Uppy.XHRUpload, {
|
||||
headers: { 'X-CSRF-Token': window.CSRF_TOKEN },
|
||||
endpoint: "constancias_upload_fondo.php",
|
||||
formData: true,
|
||||
method: 'post',
|
||||
fieldName: 'files[]'
|
||||
}).use(Uppy.ProgressBar, { target: '.for-ProgressBarFondo', hideAfterFinish: false }).on('upload-success', function (file, response) { onUploadSuccessFondo(file, response) });
|
||||
|
||||
function onUploadSuccessFondo(file, response) {
|
||||
if (response.uploadURL) {
|
||||
var url = response.uploadURL;
|
||||
$("#urlimgfondo").val(url);
|
||||
var fileName = file.name;
|
||||
$(".previewFondo").show();
|
||||
$(".uploaded-filesFondo").show().addClass('newimgFondo');
|
||||
$(".uploaded-filesFondo").html("");
|
||||
$(".uploaded-filesFondo").html('<a class="btn-link" href="' + response.uploadURL + '" target="_blank">' +
|
||||
'<img class="img-fluid" src="' + response.uploadURL + '"><br>' + fileName + '</a>');
|
||||
} else {
|
||||
Swal.fire(
|
||||
'',
|
||||
response.body.txt,
|
||||
'error'
|
||||
)
|
||||
uppyFondo.reset();
|
||||
}
|
||||
}
|
||||
/**********************************************************************/
|
||||
/****************** DATATABLE *****************************************/
|
||||
/**********************************************************************/
|
||||
function getData() {
|
||||
listadoDeCategorias();
|
||||
$("#datatable").html('<thead><tr></tr></thead>');
|
||||
$.ajax({
|
||||
url: 'constancias.php'
|
||||
}).done(function (data) {
|
||||
var _data = JSON.parse(data);
|
||||
var tableName = "#datatable";
|
||||
var str;
|
||||
$.each(_data.columns, function (k, colObj) {
|
||||
str = '<th>' + colObj + '</th>';
|
||||
$(str).appendTo(tableName + '>thead>tr');
|
||||
});
|
||||
|
||||
table = $('#datatable').DataTable({
|
||||
dom: "Bfrtip",
|
||||
responsive: true,
|
||||
"drawCallback": function (settings) {
|
||||
$("#btn_edit, #btn_habilitar").addClass('disabled');
|
||||
addEventsCheck();
|
||||
},
|
||||
buttons: [{
|
||||
extend: 'excel',
|
||||
text: 'Exportar a Excel'
|
||||
},
|
||||
{
|
||||
text: 'Editar',
|
||||
action: function (e, dt, node, config) {
|
||||
editar(e, dt, node, config);
|
||||
},
|
||||
attr: {
|
||||
id: 'btn_edit'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Alternar habilitar',
|
||||
action: function (e, dt, node, config) {
|
||||
deshabilitar(e, dt, node, config)
|
||||
},
|
||||
attr: {
|
||||
id: 'btn_habilitar'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Crear',
|
||||
action: function (e, dt, node, config) {
|
||||
crear();
|
||||
},
|
||||
attr: {
|
||||
id: 'btn_crear'
|
||||
}
|
||||
}
|
||||
|
||||
],
|
||||
'columnDefs': [{
|
||||
'targets': 0,
|
||||
'checkboxes': { 'selectRow': true }
|
||||
}],
|
||||
|
||||
'order': [
|
||||
[1, 'asc']
|
||||
],
|
||||
data: _data.datos,
|
||||
"language": {
|
||||
"url": "../json/Spanish.json"
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$(".layer-load").hide();
|
||||
})
|
||||
.fail(function () {
|
||||
|
||||
})
|
||||
.always(function () {
|
||||
table.columns.adjust().draw();
|
||||
$(window).resize(function (event) {
|
||||
/* Act on the event */
|
||||
table.columns.adjust().draw();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function reloadData() {
|
||||
listadoDeCategorias();
|
||||
$.ajax({
|
||||
url: 'constancias.php'
|
||||
})
|
||||
.done(function (data) {
|
||||
var NewlyCreatedData = JSON.parse(data);
|
||||
table.clear();
|
||||
table.rows.add(NewlyCreatedData.datos); // Add new data
|
||||
table.columns.adjust().draw(); // Redraw the DataTable
|
||||
table.column(0).checkboxes.deselectAll();
|
||||
})
|
||||
.fail(function () {
|
||||
//console.log("error");
|
||||
})
|
||||
.always(function () {
|
||||
//console.log("complete");
|
||||
});
|
||||
}
|
||||
|
||||
function addEventsCheck() {
|
||||
$("#datatable_wrapper input[type='checkbox']").on('change', function (e) {
|
||||
setTimeout(function (){
|
||||
console.log($("#datatable_wrapper input[type='checkbox']:checked").length);
|
||||
if (table.column(0).checkboxes.selected().length == 0) {
|
||||
$("#btn_edit, #btn_habilitar").addClass('disabled');
|
||||
} else if (table.column(0).checkboxes.selected().length == 1) {
|
||||
$("#btn_edit, #btn_habilitar").removeClass('disabled');
|
||||
} else if (table.column(0).checkboxes.selected().length > 1) {
|
||||
$("#btn_edit").addClass('disabled');
|
||||
$("#btn_habilitar").removeClass('disabled');
|
||||
}
|
||||
}, 150);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/****************** Editar, Deshabilitar, Crear ***********************/
|
||||
/**********************************************************************/
|
||||
|
||||
function listadoDeCategorias() {
|
||||
$(".layer-load").show();
|
||||
$.ajax({
|
||||
url: 'categorias_list.php',
|
||||
type: 'POST'
|
||||
})
|
||||
.done(function (response) {
|
||||
var _data = parseJSON(response);
|
||||
if (_data.code == "1") {
|
||||
$("#catsuperior").html("");
|
||||
var _padres = _.filter(_data.datos, function (n) {
|
||||
return n.padre == 0;
|
||||
});
|
||||
var _datos = _.groupBy(_data.datos, function (n) {
|
||||
return n.padre;
|
||||
});
|
||||
|
||||
$.each(_padres, function (index, val1) {
|
||||
$("#catsuperior").append('<option disabled style="background-color: #959595; color: white;">' + val1.nombre + '</option>');
|
||||
$.each(_datos, function (index, cats) {
|
||||
$.each(cats, function (index, val) {
|
||||
if (val.padre == val1.id || val.nombre == val1.nombre) {
|
||||
if (val.nombre == val1.nombre) {
|
||||
//$("[label='" + val1.nombre + "']").append('<option class="font-weight-bold" value="' + val.id + '">' + val.nombre + '</option>');
|
||||
} else {
|
||||
$("#catsuperior").append('<option value="' + val.id + '">' + val.nombre + '</option>');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
Swal.fire({
|
||||
html: "Sin categorias",
|
||||
icon: "error",
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {},
|
||||
onRender: function () {},
|
||||
onClose: function () {
|
||||
$(".btn_cancelar").click();
|
||||
},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
}
|
||||
$(".layer-load").hide();
|
||||
//$('#catsuperior').selectpicker();
|
||||
//if (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) {
|
||||
//$('#catsuperior').selectpicker('mobile');
|
||||
//}
|
||||
|
||||
})
|
||||
.fail(function () {
|
||||
|
||||
})
|
||||
.always(function () {
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function editar(e, dt, node, config) {
|
||||
var $table = table.table().node();
|
||||
var $chkbox_checked = $('tbody input[type="checkbox"]:checked', $table);
|
||||
$($chkbox_checked).closest('tr')
|
||||
var data = table.row($($chkbox_checked).closest('tr')).data();
|
||||
$("#idconstancia").val(data[0]);
|
||||
$("#catsuperior").find('option').each(function (index, el) {
|
||||
if ($(this).text() == data[2]) {
|
||||
$("#catsuperior").val($(this).attr('value'));
|
||||
//$('#catsuperior').selectpicker('render');
|
||||
}
|
||||
});
|
||||
$("#representante").val(data[3]);
|
||||
$("#cargo").val(data[4]);
|
||||
$("#habilitado").find('option').each(function (index, el) {
|
||||
if ($(this).text() == data[5]) {
|
||||
$("#habilitado").val($(this).attr('value'));
|
||||
}
|
||||
});
|
||||
|
||||
$("#habilitado_logo").find('option').each(function (index, el) {
|
||||
if ($(this).text() == data[6]) {
|
||||
$("#habilitado_logo").val($(this).attr('value'));
|
||||
if ($("#habilitado_logo").val() == '1') {
|
||||
$('.config_logo').show();
|
||||
}else{
|
||||
$('.config_logo').hide();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$('#alineacion_logo').val(data[10]);
|
||||
$('#alineacion_content').val(data[12]);
|
||||
|
||||
$("#habilitado_fondo").find('option').each(function (index, el) {
|
||||
if ($(this).text() == data[7]) {
|
||||
$("#habilitado_fondo").val($(this).attr('value'));
|
||||
if ($("#habilitado_fondo").val() == '1') {
|
||||
$('.config_fondo').show();
|
||||
}else{
|
||||
$('.config_fondo').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (data[8] != null) {
|
||||
var name = String(data[8]).split('/');
|
||||
$("#preview").show();
|
||||
$("#signature").hide();
|
||||
$("#export").hide();
|
||||
$("#preview").attr('src',data[8]);
|
||||
$("#imgfirma").val(data[8]);
|
||||
}
|
||||
$('#reset').show();
|
||||
|
||||
if (data[9] != null) {
|
||||
var name = String(data[9]).split('/');
|
||||
$(".previewFondo").show();
|
||||
$(".uploaded-filesFondo").html('<a class="btn-link" href="' + data[9] + '" target="_blank">' +
|
||||
'<img class="img-fluid" src="' + data[9] + '"><br>' + name[name.length - 1] + '</a>');
|
||||
$("#urlimgfondo").val(data[9]);
|
||||
}
|
||||
|
||||
if (data[10] != null) {
|
||||
var name = String(data[11]).split('/');
|
||||
$(".preview").show();
|
||||
$(".uploaded-files").html('<a class="btn-link" href="' + data[11] + '" target="_blank">' +
|
||||
'<img class="img-fluid" src="' + data[11] + '"><br>' + name[name.length - 1] + '</a>');
|
||||
$("#urlimglogo").val(data[11]);
|
||||
}
|
||||
|
||||
|
||||
$(".newimg").removeClass('newimg');
|
||||
$(".newimg").removeClass('newimgFondo');
|
||||
$(".controller").hide();
|
||||
$(".editor").show();
|
||||
$(".edit").show();
|
||||
$(".crear").hide();
|
||||
}
|
||||
|
||||
function deshabilitar(e, dt, node, config) {
|
||||
var rows_selected = table.column(0).checkboxes.selected();
|
||||
|
||||
var ids = new Array();
|
||||
$.each(rows_selected, function (index, rowId) {
|
||||
ids.push(rowId);
|
||||
});
|
||||
$(".layer-load").show();
|
||||
$.ajax({
|
||||
url: 'constancias_delete.php',
|
||||
type: 'POST',
|
||||
data: { ids: ids },
|
||||
})
|
||||
.done(function (response) {
|
||||
Swal.fire({
|
||||
html: response,
|
||||
icon: "success",
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {},
|
||||
onRender: function () {},
|
||||
onClose: function () {
|
||||
reloadData();
|
||||
},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
})
|
||||
.fail(function () {
|
||||
|
||||
})
|
||||
.always(function () {
|
||||
$(".layer-load").hide();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function crear() {
|
||||
|
||||
$("#idconstancia").val("");
|
||||
$("#imgfirma").val("");
|
||||
$("#urlimglogo").val("");
|
||||
$("#urlimgfondo").val("");
|
||||
$('#catsuperior').prop('selectedIndex',1);
|
||||
$("#representante").val("");
|
||||
$("#cargo").val("");
|
||||
$("#reset").show();
|
||||
|
||||
$("#habilitado").val(1);
|
||||
$(".newimg").removeClass('newimg');
|
||||
$(".newimgFondo").removeClass('newimgFondo');
|
||||
$(".controller").hide();
|
||||
$(".editor").show();
|
||||
$(".edit").hide();
|
||||
$(".crear").show();
|
||||
}
|
||||
|
||||
$("#habilitado_logo").change(function(){
|
||||
if ($(this).val() == '1') {
|
||||
$('.config_logo').show();
|
||||
}else{
|
||||
$('.config_logo').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$("#habilitado_fondo").change(function(){
|
||||
if ($(this).val() == '1') {
|
||||
$('.config_fondo').show();
|
||||
}else{
|
||||
$('.config_fondo').hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#alineacion_logo').prop('selectedIndex',0);
|
||||
$('#alineacion_content').prop('selectedIndex',0);
|
||||
|
||||
|
||||
$(".btn_cancelar").click(function (event) {
|
||||
//$(".newimg").removeClass('newimg');
|
||||
//$(".newimgFondo").removeClass('newimgFondo');
|
||||
if ($(".uploaded-files").hasClass('newimg') || $(".uploaded-filesFondo").hasClass('newimgFondo')) {
|
||||
$(".layer-load").show();
|
||||
|
||||
if ($(".uploaded-files").hasClass('newimg')){
|
||||
$.ajax({
|
||||
url: 'constancias_deletefile_logo.php',
|
||||
type: 'POST',
|
||||
data: { file: $(".uploaded-files a").attr('href') },
|
||||
})
|
||||
.done(function (response) {
|
||||
|
||||
})
|
||||
.fail(function (error) {
|
||||
|
||||
})
|
||||
.always(function () {
|
||||
|
||||
$(".layer-load").hide();
|
||||
$(".preview").hide();
|
||||
$(".ThumbnailGenerator, .uploaded-files").html("");
|
||||
uppy.reset();
|
||||
signaturePad.clear();
|
||||
$(".controller").show();
|
||||
$(".editor").hide();
|
||||
$(".uploaded-files").removeClass('newimg');
|
||||
});
|
||||
}
|
||||
if ($(".uploaded-filesFondo").hasClass('newimgFondo')) {
|
||||
$(".layer-load").show();
|
||||
$.ajax({
|
||||
url: 'constancias_deletefile_fondo.php',
|
||||
type: 'POST',
|
||||
data: { file: $(".uploaded-filesFondo a").attr('href') },
|
||||
})
|
||||
.done(function (response) {
|
||||
|
||||
})
|
||||
.fail(function (error) {
|
||||
|
||||
})
|
||||
.always(function () {
|
||||
|
||||
$(".layer-load").hide();
|
||||
$(".previewFondo").hide();
|
||||
$(".ThumbnailGeneratorFondo, .uploaded-filesFondo").html("");
|
||||
uppyFondo.reset();
|
||||
signaturePad.clear();
|
||||
$(".controller").show();
|
||||
$(".editor").hide();
|
||||
$(".uploaded-filesFondo").removeClass('newimgFondo');
|
||||
});
|
||||
}
|
||||
}else {
|
||||
$(".preview").hide();
|
||||
$(".previewFondo").hide();
|
||||
$(".ThumbnailGenerator, .uploaded-files").html("");
|
||||
$(".ThumbnailGeneratorFondo, .uploaded-filesFondo").html("");
|
||||
uppy.reset();
|
||||
uppyFondo.reset();
|
||||
|
||||
signaturePad.clear();
|
||||
|
||||
$('#preview').hide();
|
||||
$('#signature').show();
|
||||
$('#export').show();
|
||||
$('#reset').hide();
|
||||
|
||||
$(".preview").hide();
|
||||
$(".previewFondo").hide();
|
||||
$(".controller").show();
|
||||
$(".editor").hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$.validator.addMethod('validUrl', function(value, element) {
|
||||
var url = $.validator.methods.url.bind(this);
|
||||
var pattern = new RegExp("^(?:https?://|s?ftps?://)?(?!www | www\.)[A-Za-z0-9_-]+\.+[A-Za-z0-9.\/%&=\?_:;-]+$");
|
||||
return pattern.test("http://localhost/git/estafeta-lms360/site/pkg/scorm_check/index.html");
|
||||
}, 'Por favorsss, escribe una URL válida.');
|
||||
|
||||
$(".formcontroller").validate({
|
||||
submitHandler: function (form) {
|
||||
|
||||
var controller = 'constancias_update.php';
|
||||
if ($(".crear").css("display") == "block") {
|
||||
controller = 'constancias_add.php';
|
||||
}
|
||||
$.ajax({
|
||||
url: controller,
|
||||
type: 'POST',
|
||||
data: $(".formcontroller").serializeArray(),
|
||||
})
|
||||
.done(function (response) {
|
||||
//console.log("success");
|
||||
Swal.fire({
|
||||
html: response,
|
||||
icon:'success',
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {},
|
||||
onRender: function () {},
|
||||
onClose: function () {
|
||||
$(".preview").hide();
|
||||
$(".previewFondo").hide();
|
||||
$(".ThumbnailGenerator, .uploaded-files").html("");
|
||||
$(".ThumbnailGenerator, .uploaded-filesFondo").html("");
|
||||
uppy.reset();
|
||||
uppyFondo.reset();
|
||||
$(".preview").hide();
|
||||
$(".previewFondo").hide();
|
||||
$(".controller").show();
|
||||
$(".editor").hide();
|
||||
reloadData();
|
||||
$(".mainseccion").load("constancias.html", function () {
|
||||
$(".layer-load").hide();
|
||||
});
|
||||
},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
})
|
||||
.fail(function () {
|
||||
//console.log("error");
|
||||
})
|
||||
.always(function () {
|
||||
//console.log("complete");
|
||||
});
|
||||
},
|
||||
rules: {
|
||||
representante: {
|
||||
required: true,
|
||||
maxlength: 254,
|
||||
minlength: 2,
|
||||
normalizer: function( value ) {
|
||||
return $.trim( value );
|
||||
}
|
||||
},
|
||||
cargo: {
|
||||
required: true,
|
||||
maxlength: 254,
|
||||
minlength: 2,
|
||||
normalizer: function( value ) {
|
||||
return $.trim( value );
|
||||
}
|
||||
},
|
||||
imgfirma:{
|
||||
required:true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
getData();
|
||||
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user