NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Resumen de tareas AN
// @namespace http://zengarden/zm
// @version 1
// @license MIT
// @author Roberto Orden Erena <rordenerena@gmail.com>
// @match http://zengarden/zm/*/consultas/consTareaDiaria.php
// @require https://code.jquery.com/jquery-3.5.1.slim.min.js
// @grant none
// ==/UserScript==
(function() {
var container = $(".ui-state-default:nth-child(1) th:nth-child(4)");
var btn = $("<input>").attr("type", "button")
.attr("value", "RESUMEN")
.click(() => {
// Conseguir el dato de sumatorio del Ășltimo
var lastEmp = $('tr').filter(function () {
return this.id.match(/^tr_nombre_\d{1,3}$/);
}).get(-1);
var hours = $(lastEmp).nextAll("tr.ui-state-default").find("td:nth-child(2)");
var suma = 0;
hours.each(function(){
let value = parseFloat(this.innerHTML.substring(7).split(" h.")[0]);
suma += value;
})
console.log(suma);
var id = "total_empleado_" + $(lastEmp).attr("id").split("tr_nombre_")[1];
$("#" + id).text("Total: " + suma + " h.");
// Eliminar filas innecesarias que ensucian ver el resumen final
$('tr').filter(function () {
return this.id.match(/^tr_\d{1,3}$/);
}).remove();
$('tr').filter(function () {
return this.id.match(/^tr_dia_\d{1,3}$/);
}).remove();
$("td").css("padding", "5px").css("backgroundColor", "white");
})
.appendTo(container);
})();