{% extends 'base.html.twig' %}
{% block javascripts_base %}
function initDateFormat( datePicker ) {
var selectedDate = ( typeof datePicker.date === 'undefined' || datePicker.date === null ) ? datePicker.options.defaultDate : datePicker.date;
var shortWeekdays = datePicker.options.i18n.weekdaysShort;
var shortMonths = datePicker.options.i18n.monthsShort;
var day = selectedDate.getDate();
var weekday = shortWeekdays[ selectedDate.getDay() ];
var month = shortMonths[ selectedDate.getMonth() ];
var formattedDate = weekday + ', ' + day + ' ' + month;
document.querySelector(".datepicker-date-display .date-text").innerHTML = formattedDate;
document.querySelector(".datepicker-date-display .year-text").innerHTML = selectedDate.getFullYear();
}
function clickEliminarInforme(e) {
$url_eliminar=e.currentTarget.dataset.url;
debugger;
swal({
title: "Eliminar",
text: "¿Está seguro que quiere eliminar este Informe Psiquiatrico?",
icon: "warning",
buttons: true,
})
.then((aceptar) => {
if (aceptar) {
window.location.href = $url_eliminar;
}
});
}
{% endblock %}
{% block js_document_ready %}
$('#datatable').dataTable({
createdRow: function(row, data, dataIndex) {
$(row).css({"background-color":"transparent"});
},
filter : false,
language: {
"url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
},
aLengthMenu: "",
bAutoWidth: false,
"columns": [
{
"data": "imagen",
render: function(data, type, row, meta) {
console.debug(data);
if (type === 'display') {
imagen = [
'',
].join('');
return imagen;
}
return data;
},
},
{ "data": "apellidos" },
{ "data": "nombres" },
{ "data": "dni" },
{ "data": "fecha_entrevista" },
{ "data": "cargo" },
{
"data": "acciones" ,
render: function(data, type, row, meta) {
if (type === 'display') {
$botones = [
' ',
'visibility',
' ',
].join('');
if(data['editar']!=null)
{
$botones += [
'',
'edit',
'',
].join('');
}
if(data['eliminar']!=null)
{
$botones += [
' ',
'delete',
'',
].join('');
}
return $botones;
}
return data;
},
},
],
order: [[ 1, 'asc' ]],
columnDefs: [
// These are the column name variables that will be sent to the server
{
"name": "imagen",
"searchable": false,
"orderable": false,
"targets": 0
},
{
"name": "dp.apellidos",
"targets": 1
},
{
"name": "dp.nombres",
"targets": 2
},
{
"name": "dp.dni",
"targets": 3
},
{
"name": "i.fechaEntrevista",
"targets": 4
},
{
"name": "carg.nombre",
"orderable": false,
"targets": 5
},
{
"searchable": false,
"orderable": false,
"targets": 6
},
],
"displayStart": {{ app.session.get(constant('App\\Controller\\Informes\\InformesPsiquiatricosController::FORM_CONSULTA_INFORME_PSIQUIATRICO_START')) ?? 0 }},
serverSide: true,
processing: true,
ajax: {
url: '{{ path('informes_psiquiatricos_datos') }}',
type: 'POST'
},
fnDrawCallback: function( oSettings ) {
// Formatear la fecha en el formato día/mes/año
$('#datatable tbody tr').each(function() {
var fechaCell = $(this).find('td:eq(3)'); // Columna de la fecha en la tabla
var fechaValue = fechaCell.text();
// Extraer solo la parte de la fecha (sin la hora)
var fechaParts = fechaValue.split(' ');
if (fechaParts.length > 1)
{
var fechaPart = fechaValue.split(' ')[0];
fechaParts = fechaPart.split('/'); // Suponiendo que la fecha está en formato 'YYYY/MM/DD'
var fechaFormatted = fechaParts[2] + '/' + fechaParts[1] + '/' + fechaParts[0];
fechaCell.text(fechaFormatted);
}
});
}
});
// the "href" attribute of the modal trigger must specify the modal ID that wants to be triggered
{# $('.modal1').modal(); #}
$('select').formSelect();
var select = $('select');
$('.limpiar').click(function(){
$("input[type=text]").val("");
select.prop('selectedIndex', 0); //Sets the first option as selected
select.material_select(); //Update material select
form.submit();
});
$('.datepicker').datepicker({
autoClose: true,
showClearBtn: true,
format: 'dd/mm/yyyy',
container: 'body',
{# defaultDate: p_defaultDate, #}
{# yearRange: p_yearRange, #}
{# maxDate: p_maxDate, #}
{# setDefaultDate: p_setDefaultDate, #}
onDraw: function (datePicker) {
// materialize select dropdown not proper working on mobile and tablets so we make it browser default select
$('.datepicker-container').find('.datepicker-select').addClass('browser-default');
$(".datepicker-container .select-dropdown.dropdown-trigger").remove();
},
onOpen: function (p) {
var instance = M.Datepicker.getInstance(this.el);
var d = instance.el.value.split(/[^0-9]/);
var newDate = new Date(d[2], d[1] - 1, d[0]);
instance.setDate(newDate);
initDateFormat(instance);
},
i18n: {
cancel: 'Cancelar',
clear: 'Limpiar',
done: 'Aceptar',
weekdays: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"],
weekdaysShort: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"],
weekdaysAbbrev: ["D", "L", "M", "M", "J", "V", "S"],
today: 'Hoy',
months: [
'Enero',
'Febrero',
'Marzo',
'Abril',
'Mayo',
'Junio',
'Julio',
'Agosto',
'Septiembre',
'Octubre',
'Noviembre',
'Diciembre'
],
monthsShort: [
'Enero',
'Febrero',
'Marzo',
'Abril',
'Mayo',
'Junio',
'Julio',
'Agosto',
'Septiembre',
'Octubre',
'Noviembre',
'Diciembre'
],
}
});
{% endblock %}
{% block javascripts %}
{{ parent() }}
{% endblock %}
{% block breadcrumb %}
Apellidos | Nombres | DNI | Fecha de la Entrevista | Cargo | Acciones |
---|