mirror of
https://github.com/cheveguerra/Colaborando.git
synced 2026-08-19 00:46:37 +00:00
Se activa la seleccion del depto activo, se corrige el arrastre de activos y de recursos, falta arreglar el acomodo de los recursos en los deptos.
This commit is contained in:
+228
-144
@@ -93,7 +93,9 @@
|
||||
}
|
||||
|
||||
/* Estilos para los departamentos en una columna */
|
||||
.departamentos.card {
|
||||
/* Se ajusta el selector para que apunte a los .card dentro de la columna de departamentos,
|
||||
restaurando el borde gris y eliminando el padding para que la tabla se ajuste. */
|
||||
.column-depts .card {
|
||||
padding: 0;
|
||||
border: solid 3px gray;
|
||||
}
|
||||
@@ -222,6 +224,7 @@
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<div class="main-container">
|
||||
|
||||
<!-- =================================================================
|
||||
@@ -374,58 +377,168 @@
|
||||
================================================================== -->
|
||||
<div class="column column-depts">
|
||||
<h2>DEPARTAMENTOS</h2>
|
||||
<?php
|
||||
$deptos = [
|
||||
["id" => "MarketingYVentas", "nombre" => "MARKETING Y VENTAS", "img" => "depto-marketing.png", "act1_class" => "actPersonalCalificado", "act2_class" => "actFlujoDeEfectivo"],
|
||||
["id" => "Finanzas", "nombre" => "FINANZAS", "img" => "depto-finanzas.png", "act1_class" => "actFlujoDeEfectivo", "act2_class" => "actCreditoEInversion"],
|
||||
["id" => "InvestigacionYDesarrollo", "nombre" => "INVESTIGACIÓN Y DESARROLLO", "img" => "depto-investigacion.png", "act1_class" => "actCreditoEInversion", "act2_class" => "actTecnologia"],
|
||||
["id" => "LogisticaYSistemas", "nombre" => "LOGÍSTICA Y SISTEMAS", "img" => "depto-logistica.png", "act1_class" => "actTecnologia", "act2_class" => "actTransporteYMaquinaria"],
|
||||
["id" => "Operaciones", "nombre" => "OPERACIONES", "img" => "depto-operaciones.png", "act1_class" => "actTransporteYMaquinaria", "act2_class" => "actAnalistas"],
|
||||
["id" => "RecursosHumanos", "nombre" => "RECURSOS HUMANOS", "img" => "depto-recursos.png", "act1_class" => "actPersonalCalificado", "act2_class" => "actAnalistas"]
|
||||
];
|
||||
|
||||
foreach ($deptos as $depto) {
|
||||
?>
|
||||
<div class="card departamentos droppable-asset-recovery" id="<?= $depto['id'] ?>">
|
||||
<table style="width:100%;">
|
||||
<!-- MarketingYVentas -->
|
||||
<div class="card">
|
||||
<table style="width:100%;" class="departamentos droppableRecursos droppable-asset-recovery" id="MarketingYVentas">
|
||||
<tr style="border-bottom: 1px solid gray; height: 35px;">
|
||||
<td style="width: 70%;"><span id="nombreDeptoCh"><?= $depto['nombre'] ?></span></td>
|
||||
<td style="text-align:right;">
|
||||
<span style="border:1px solid black;padding:5px;" class="<?= $depto['act1_class'] ?> draggable activo-item" id="activoCh1">0</span>
|
||||
<span style="border:1px solid black;padding:5px;" class="<?= $depto['act2_class'] ?> draggable activo-item" id="activoCh2">0</span>
|
||||
<td style="width: 70%;"><span id="nombreDeptoCh">MARKETING Y VENTAS</span></td>
|
||||
<td style="text-align:right;" colspan="2">
|
||||
<span style="border:1px solid black;padding:5px;" class="actPersonalCalificado draggable activo-item" id="activoCh1">0</span>
|
||||
<span style="border:1px solid black;padding:5px;" class="actFlujoDeEfectivo draggable activo-item" id="activoCh2">0</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align:middle;">
|
||||
<td colspan="2">
|
||||
<table style="width:100%;">
|
||||
<tr>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/tiempoCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<span style="vertical-align:middle; font-weight:bold; font-size:16px;" id="tiempoCh" class="draggable recurso-item recurso-tiempo">0</span>
|
||||
<div class="beneficio-recurso beneficio-tiempo" style="font-size: 12px; font-weight: bold; color: #28a745;"></div>
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="tiempoCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/personalCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<span style="vertical-align:middle; font-weight:bold; font-size:16px;" id="personalCh" class="draggable recurso-item recurso-personal">0</span>
|
||||
<div class="beneficio-recurso beneficio-personal" style="font-size: 12px; font-weight: bold; color: #28a745;"></div>
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="personalCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/capitalCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<span style="vertical-align:middle; font-weight:bold; font-size:16px;" id="capitalCh" class="draggable recurso-item recurso-capital">0</span>
|
||||
<div class="beneficio-recurso beneficio-capital" style="font-size: 12px; font-weight: bold; color: #28a745;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="border-top: 1px solid gray;">
|
||||
<td colspan="2" style="font-size:11px; text-align:center; background-color: #e0e0e0;">
|
||||
Habilidad Especial: <span id="accionEspecialGde" style="font-weight:bold;"></span>
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="capitalCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Finanzas -->
|
||||
<div class="card">
|
||||
<table style="width:100%;" class="departamentos droppableRecursos droppable-asset-recovery" id="Finanzas">
|
||||
<tr style="border-bottom: 1px solid gray; height: 35px;">
|
||||
<td style="width: 70%;"><span id="nombreDeptoCh">FINANZAS</span></td>
|
||||
<td style="text-align:right;" colspan="2">
|
||||
<span style="border:1px solid black;padding:5px;" class="actFlujoDeEfectivo draggable activo-item" id="activoCh1">0</span>
|
||||
<span style="border:1px solid black;padding:5px;" class="actCreditoEInversion draggable activo-item" id="activoCh2">0</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align:middle;">
|
||||
<td style="text-align:center;">
|
||||
<img src="img/tiempoCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="tiempoCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/personalCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="personalCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/capitalCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="capitalCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- InvestigacionYDesarrollo -->
|
||||
<div class="card">
|
||||
<table style="width:100%;" class="departamentos droppableRecursos droppable-asset-recovery" id="InvestigacionYDesarrollo">
|
||||
<tr style="border-bottom: 1px solid gray; height: 35px;">
|
||||
<td style="width: 70%;"><span id="nombreDeptoCh">INVESTIGACIÓN Y DESARROLLO</span></td>
|
||||
<td style="text-align:right;" colspan="2">
|
||||
<span style="border:1px solid black;padding:5px;" class="actCreditoEInversion draggable activo-item" id="activoCh1">0</span>
|
||||
<span style="border:1px solid black;padding:5px;" class="actTecnologia draggable activo-item" id="activoCh2">0</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align:middle;">
|
||||
<td style="text-align:center;">
|
||||
<img src="img/tiempoCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="tiempoCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/personalCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="personalCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/capitalCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="capitalCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- LogisticaYSistemas -->
|
||||
<div class="card">
|
||||
<table style="width:100%;" class="departamentos droppableRecursos droppable-asset-recovery" id="LogisticaYSistemas">
|
||||
<tr style="border-bottom: 1px solid gray; height: 35px;">
|
||||
<td style="width: 70%;"><span id="nombreDeptoCh">LOGÍSTICA Y SISTEMAS</span></td>
|
||||
<td style="text-align:right;" colspan="2">
|
||||
<span style="border:1px solid black;padding:5px;" class="actTecnologia draggable activo-item" id="activoCh1">0</span>
|
||||
<span style="border:1px solid black;padding:5px;" class="actTransporteYMaquinaria draggable activo-item" id="activoCh2">0</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align:middle;">
|
||||
<td style="text-align:center;">
|
||||
<img src="img/tiempoCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="tiempoCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/personalCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="personalCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/capitalCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="capitalCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Operaciones -->
|
||||
<div class="card">
|
||||
<table style="width:100%;" class="departamentos droppableRecursos droppable-asset-recovery" id="Operaciones">
|
||||
<tr style="border-bottom: 1px solid gray; height: 35px;">
|
||||
<td style="width: 70%;"><span id="nombreDeptoCh">OPERACIONES</span></td>
|
||||
<td style="text-align:right;" colspan="2">
|
||||
<span style="border:1px solid black;padding:5px;" class="actTransporteYMaquinaria draggable activo-item" id="activoCh1">0</span>
|
||||
<span style="border:1px solid black;padding:5px;" class="actAnalistas draggable activo-item" id="activoCh2">0</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align:middle;">
|
||||
<td style="text-align:center;">
|
||||
<img src="img/tiempoCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="tiempoCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/personalCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="personalCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/capitalCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="capitalCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- RecursosHumanos -->
|
||||
<div class="card">
|
||||
<table style="width:100%;" class="departamentos droppableRecursos droppable-asset-recovery" id="RecursosHumanos">
|
||||
<tr style="border-bottom: 1px solid gray; height: 35px;">
|
||||
<td style="width: 70%;"><span id="nombreDeptoCh">RECURSOS HUMANOS</span></td>
|
||||
<td style="text-align:right;" colspan="2">
|
||||
<span style="border:1px solid black;padding:5px;" class="actPersonalCalificado draggable activo-item" id="activoCh1">0</span>
|
||||
<span style="border:1px solid black;padding:5px;" class="actAnalistas draggable activo-item" id="activoCh2">0</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align:middle;">
|
||||
<td style="text-align:center;">
|
||||
<img src="img/tiempoCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="tiempoCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/personalCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="personalCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
<img src="img/capitalCH.png" style="width: 30px; height: 30px; vertical-align: middle;">
|
||||
<div style="vertical-align:middle; display:inline-block; font-weight:bold; font-size:16px;" id="capitalCh" class="draggable recurso-item">0</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<!-- =================================================================
|
||||
@@ -463,12 +576,7 @@
|
||||
actualizarResumenUI();
|
||||
};
|
||||
|
||||
// En resumen.php, la función llenaDepartamentoGde no tiene utilidad y causa problemas.
|
||||
// La sobrescribimos para que no haga nada y así evitamos que deshabilite el 'drop' en las tarjetas.
|
||||
function llenaDepartamentoGde(depto) {
|
||||
console.log(`[RESUMEN] Se bloqueó la llamada a llenaDepartamentoGde para el depto: ${depto}`);
|
||||
// No hacer nada es la solución.
|
||||
}
|
||||
// YA NO SE NECESITA la función local `llenaDepartamentoGde` porque ahora usamos la de jsCode.js
|
||||
|
||||
function formatCurrency(value) {
|
||||
return new Intl.NumberFormat('es-MX', {
|
||||
@@ -480,8 +588,8 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualiza correctamente la UI de una tarjeta de departamento en la pantalla de resumen,
|
||||
* usando selectores de clase para evitar conflictos con IDs duplicados.
|
||||
* Actualiza la UI de una tarjeta de departamento en la pantalla de resumen.
|
||||
* Usa IDs porque ahora la estructura es como en colaborando2.php
|
||||
*/
|
||||
function actualizarTarjetaDepto(deptoId) {
|
||||
const deptoArr = arreglosDeptos['arr' + deptoId];
|
||||
@@ -490,50 +598,13 @@
|
||||
if (!deptoArr || !deptoCard.length) return;
|
||||
|
||||
// Actualizar recursos
|
||||
deptoCard.find('.recurso-tiempo').text(findArrayValue(deptoArr, 'recursoTiempo'));
|
||||
deptoCard.find('.recurso-personal').text(findArrayValue(deptoArr, 'recursoPersonal'));
|
||||
deptoCard.find('.recurso-capital').text(findArrayValue(deptoArr, 'recursoCapital'));
|
||||
|
||||
// --- START: NEW LOGIC FOR BENEFITS ---
|
||||
// Limpiar beneficios anteriores
|
||||
deptoCard.find('.beneficio-recurso').text('');
|
||||
|
||||
const skillSlots = ['habilidadTiempo', 'habilidadPersonal', 'habilidadCapital'];
|
||||
|
||||
skillSlots.forEach(slot => {
|
||||
const skillName = findArrayValue(deptoArr, slot);
|
||||
if (skillName && arreglosCapacitaciones[skillName]) {
|
||||
const skillData = arreglosCapacitaciones[skillName];
|
||||
const beneficio = findArrayValue(skillData, 'beneficio');
|
||||
const tipoRecurso = findArrayValue(skillData, 'tipoRecurso');
|
||||
|
||||
if (beneficio !== 0) { // Solo mostrar si hay beneficio
|
||||
let targetClass = '';
|
||||
let resourceChar = '';
|
||||
if (tipoRecurso === 'Tiempo') {
|
||||
targetClass = '.beneficio-tiempo';
|
||||
resourceChar = 'T';
|
||||
} else if (tipoRecurso === 'Personal') {
|
||||
targetClass = '.beneficio-personal';
|
||||
resourceChar = 'P';
|
||||
} else if (tipoRecurso === 'Capital') {
|
||||
targetClass = '.beneficio-capital';
|
||||
resourceChar = 'C';
|
||||
}
|
||||
|
||||
if (targetClass) {
|
||||
deptoCard.find(targetClass).text(`${beneficio}${resourceChar}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// --- END: NEW LOGIC FOR BENEFITS ---
|
||||
deptoCard.find('#tiempoCh').text(findArrayValue(deptoArr, 'recursoTiempo'));
|
||||
deptoCard.find('#personalCh').text(findArrayValue(deptoArr, 'recursoPersonal'));
|
||||
deptoCard.find('#capitalCh').text(findArrayValue(deptoArr, 'recursoCapital'));
|
||||
|
||||
// Actualizar activos
|
||||
deptoCard.find('.activo-item').first().text(findArrayValue(deptoArr, 'activo1'));
|
||||
deptoCard.find('.activo-item').last().text(findArrayValue(deptoArr, 'activo2'));
|
||||
|
||||
deptoCard.find('#accionEspecialGde').text(findArrayValue(deptoArr, 'accionEspecialQuincenal'));
|
||||
deptoCard.find('#activoCh1').text(findArrayValue(deptoArr, 'activo1'));
|
||||
deptoCard.find('#activoCh2').text(findArrayValue(deptoArr, 'activo2'));
|
||||
}
|
||||
|
||||
function actualizarResumenUI() {
|
||||
@@ -657,6 +728,9 @@
|
||||
|
||||
// --- 5. Inicializar todas las interacciones de Drag & Drop ---
|
||||
inicializarInteraccionesDragDrop();
|
||||
|
||||
// --- 6. Seleccionar el primer departamento para activar la vista
|
||||
// La función original en jsCode.js ya se encarga de esto al final de `continuamos()`
|
||||
}
|
||||
|
||||
function crearTarjetaProyecto(proyecto, esCompletado) {
|
||||
@@ -724,7 +798,7 @@
|
||||
function inicializarInteraccionesDragDrop() {
|
||||
console.log("[RESUMEN] Inicializando interacciones de Drag & Drop...");
|
||||
|
||||
// 1. DRAGGABLE: Activos recuperables de proyectos terminados
|
||||
// 1. DRAGGABLE: Hacemos arrastrables los activos de proyectos terminados.
|
||||
$('.asset-recover').draggable({
|
||||
revert: "invalid",
|
||||
helper: "clone",
|
||||
@@ -736,25 +810,64 @@
|
||||
}
|
||||
});
|
||||
|
||||
// 2. DRAGGABLE: Recursos intercambiables entre departamentos
|
||||
$('.column-depts .recurso-item').draggable({
|
||||
revert: "invalid",
|
||||
helper: "clone",
|
||||
start: function(event, ui) {
|
||||
const sourceDeptoId = $(this).closest('.departamentos').attr('id');
|
||||
ui.helper.data('source-depto', sourceDeptoId);
|
||||
ui.helper.css('z-index', 100);
|
||||
}
|
||||
// La lógica DRAGGABLE para los recursos del departamento activo ya está en jsCode.js.
|
||||
|
||||
// 2. DROPPABLE: Se crea UN SOLO manejador para las tablas de departamento,
|
||||
// que acepta tanto recursos como activos, evitando que una inicialización
|
||||
// sobrescriba a la otra.
|
||||
$('.departamentos.droppableRecursos').droppable({
|
||||
accept: ".recurso-item, .asset-recover", // Acepta ambos tipos de elementos.
|
||||
drop: function(event, ui) {
|
||||
console.log(`[DROP EVENT] -> Elemento soltado en: ${this.id}. Elemento arrastrado:`, ui.draggable[0]);
|
||||
|
||||
// LÓGICA PARA RECURSOS (adaptada de jsCode.js)
|
||||
if (ui.draggable.hasClass('recurso-item')) {
|
||||
console.log("[DROP EVENT] -> Es un 'recurso-item'. Ejecutando lógica de intercambio.");
|
||||
|
||||
var droppedText = ui.draggable.text();
|
||||
var originalValue = parseInt(droppedText) || 0;
|
||||
|
||||
// <<<< LÍNEA CLAVE: Regresa el elemento a su posición original >>>>
|
||||
ui.draggable.css({
|
||||
top: originalPosition.top,
|
||||
left: originalPosition.left
|
||||
});
|
||||
|
||||
// 3. DROPPABLE: Tarjetas de departamento que aceptan activos Y recursos
|
||||
$('.droppable-asset-recovery').droppable({
|
||||
accept: ".asset-recover, .recurso-item", // Acepta ambos tipos de elementos
|
||||
drop: function(event, ui) {
|
||||
$(this).css('background-color', ''); // Limpiar feedback visual al soltar
|
||||
if (originalValue === 0) {
|
||||
console.log("[DROP EVENT] -> Recurso de origen tiene 0. Cancelando.");
|
||||
return;
|
||||
}
|
||||
|
||||
var newValue = originalValue - 1;
|
||||
var audio = new Audio('./Microwave_bell.wav');
|
||||
audio.play();
|
||||
|
||||
// Actualiza el texto del elemento original que se está arrastrando
|
||||
ui.draggable.text(newValue);
|
||||
|
||||
// Determina qué tipo de recurso es y actualiza los arreglos y la UI
|
||||
if (ui.draggable.attr("id") == 'recursoDispTiempoGde') {
|
||||
$('#' + this.id + ' #tiempoCh').text(parseInt($('#' + this.id + ' #tiempoCh').text()) + 1);
|
||||
setArrayValue(arreglosDeptos['arr' + this.id], 'recursoTiempo', parseInt($('#' + this.id + ' #tiempoCh').text()));
|
||||
setArrayValue(arreglosDeptos['arr' + deptoActual], 'recursoTiempo', newValue);
|
||||
$('#' + deptoActual + ' #tiempoCh').text(newValue);
|
||||
} else if (ui.draggable.attr("id") == 'recursoDispPersonalGde') {
|
||||
$('#' + this.id + ' #personalCh').text(parseInt($('#' + this.id + ' #personalCh').text()) + 1);
|
||||
setArrayValue(arreglosDeptos['arr' + this.id], 'recursoPersonal', parseInt($('#' + this.id + ' #personalCh').text()));
|
||||
setArrayValue(arreglosDeptos['arr' + deptoActual], 'recursoPersonal', newValue);
|
||||
$('#' + deptoActual + ' #personalCh').text(newValue);
|
||||
} else if (ui.draggable.attr("id") == 'recursoDispCapitalGde') {
|
||||
$('#' + this.id + ' #capitalCh').text(parseInt($('#' + this.id + ' #capitalCh').text()) + 1);
|
||||
setArrayValue(arreglosDeptos['arr' + this.id], 'recursoCapital', parseInt($('#' + this.id + ' #capitalCh').text()));
|
||||
setArrayValue(arreglosDeptos['arr' + deptoActual], 'recursoCapital', newValue);
|
||||
$('#' + deptoActual + ' #capitalCh').text(newValue);
|
||||
}
|
||||
|
||||
}
|
||||
// LÓGICA PARA ACTIVOS (la que ya estaba en resumen.php)
|
||||
else if (ui.draggable.hasClass('asset-recover')) {
|
||||
console.log("[DROP EVENT] -> Es un 'asset-recover'. Ejecutando lógica de recuperación.");
|
||||
|
||||
// --- LÓGICA PARA SOLTAR ACTIVOS ---
|
||||
if (ui.draggable.hasClass('asset-recover')) {
|
||||
const deptoId = $(this).attr('id');
|
||||
const assetType = ui.draggable.data('asset-type');
|
||||
const assetElementId = ui.draggable.attr('id');
|
||||
@@ -786,20 +899,17 @@
|
||||
const currentCount = parseInt(assetElement.text());
|
||||
assetElement.text(currentCount - 1);
|
||||
|
||||
// --- INICIO: CORRECCIÓN PARA ACTUALIZAR ARREGLO DE PROYECTOS ---
|
||||
const assetIdParts = assetElementId.split('-'); // e.g., "asset-15-0"
|
||||
const assetIdParts = assetElementId.split('-');
|
||||
const projectId = parseInt(assetIdParts[1]);
|
||||
const assetIndex = parseInt(assetIdParts[2]); // 0-based index
|
||||
const assetIndex = parseInt(assetIdParts[2]);
|
||||
|
||||
const projectToUpdate = proyectos.find(p => p.id === projectId);
|
||||
if (projectToUpdate) {
|
||||
const assetSlotName = `activoAsignado${assetIndex + 1}`;
|
||||
if (projectToUpdate[assetSlotName] > 0) {
|
||||
projectToUpdate[assetSlotName]--;
|
||||
console.log(`[RESUMEN] Activo recuperado del proyecto ${projectId}. Slot: ${assetSlotName}, nuevo valor: ${projectToUpdate[assetSlotName]}`);
|
||||
}
|
||||
}
|
||||
// --- FIN: CORRECCIÓN ---
|
||||
actualizarTarjetaDepto(deptoId);
|
||||
var audio = new Audio('./Microwave_bell.wav');
|
||||
audio.play();
|
||||
@@ -813,58 +923,32 @@
|
||||
alert("Recursos insuficientes en el departamento para recuperar este activo.");
|
||||
}
|
||||
}
|
||||
// --- LÓGICA PARA SOLTAR RECURSOS ---
|
||||
else if (ui.draggable.hasClass('recurso-item')) {
|
||||
const targetDeptoId = $(this).attr('id');
|
||||
const sourceDeptoId = ui.helper.data('source-depto');
|
||||
|
||||
if (!sourceDeptoId || targetDeptoId === sourceDeptoId) return;
|
||||
|
||||
let resourceType = '';
|
||||
if (ui.draggable.hasClass('recurso-tiempo')) resourceType = 'recursoTiempo';
|
||||
if (ui.draggable.hasClass('recurso-personal')) resourceType = 'recursoPersonal';
|
||||
if (ui.draggable.hasClass('recurso-capital')) resourceType = 'recursoCapital';
|
||||
|
||||
if (!resourceType) return;
|
||||
|
||||
const sourceDeptoArr = arreglosDeptos['arr' + sourceDeptoId];
|
||||
const targetDeptoArr = arreglosDeptos['arr' + targetDeptoId];
|
||||
const sourceVal = findArrayValue(sourceDeptoArr, resourceType);
|
||||
|
||||
if (sourceVal > 0) {
|
||||
const targetVal = findArrayValue(targetDeptoArr, resourceType);
|
||||
|
||||
setArrayValue(sourceDeptoArr, resourceType, sourceVal - 1);
|
||||
setArrayValue(targetDeptoArr, resourceType, targetVal + 1);
|
||||
|
||||
actualizarTarjetaDepto(sourceDeptoId);
|
||||
actualizarTarjetaDepto(targetDeptoId);
|
||||
|
||||
var audio = new Audio('./Microwave_bell.wav');
|
||||
audio.play();
|
||||
}
|
||||
}
|
||||
},
|
||||
over: function(event, ui) {
|
||||
if (ui.draggable.hasClass('recurso-item') && $(this).attr('id') !== ui.helper.data('source-depto')) {
|
||||
$(this).css('background-color', '#e9f5e9');
|
||||
// Lógica combinada para el 'over'
|
||||
if (ui.draggable.hasClass('recurso-item') && $(this).attr('id') !== deptoActual) {
|
||||
$(this).parent().css('background-color', '#e9f5e9'); // Pinta el div.card
|
||||
} else if (ui.draggable.hasClass('asset-recover')) {
|
||||
$(this).css('background-color', '#e9f5e9');
|
||||
$(this).parent().css('background-color', '#e9f5e9'); // Pinta el div.card
|
||||
}
|
||||
},
|
||||
out: function(event, ui) {
|
||||
$(this).css('background-color', '');
|
||||
$(this).parent().css('background-color', ''); // Limpia el color del div.card
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Listener para los botones de quincena para actualizar la UI
|
||||
$('#bMas, #bMenos').on('click', function() {
|
||||
// Pequeño delay para asegurar que el valor del input se actualice antes de leerlo
|
||||
setTimeout(actualizarResumenUI, 100);
|
||||
});
|
||||
|
||||
// El listener para el click en .departamentos ya está en jsCode.js y funcionará ahora
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user