Actualizar index2.html

This commit is contained in:
2026-03-29 15:39:23 +00:00
parent f981dba14f
commit 124a5e1ecf

View File

@@ -173,13 +173,20 @@
</div> </div>
<div id="qmActionsContainer" class="mb-4"> <div id="qmActionsContainer" class="mb-4">
<div id="qmDecisionButtons" class="flex gap-3"> <div id="qmDecisionButtons" class="flex flex-col gap-3">
<button onclick="openSignatureArea()" class="flex-1 bg-emerald-50 text-emerald-600 border border-emerald-200 font-black py-4 rounded-2xl flex flex-col items-center justify-center gap-1 uppercase tracking-widest text-[10px] active:scale-95 transition-all hover:bg-emerald-500 hover:text-white">
<i data-lucide="thumbs-up" class="w-5 h-5"></i> Aceptar <button id="btnStripePay" onclick="payWithStripe()" class="hidden w-full bg-indigo-600 text-white border border-indigo-700 font-black py-4 rounded-2xl flex items-center justify-center gap-2 uppercase tracking-widest text-[11px] active:scale-95 transition-all hover:bg-indigo-700 shadow-xl shadow-indigo-500/30">
</button> <i data-lucide="credit-card" class="w-5 h-5"></i> Pagar Presupuesto
<button onclick="rejectBudget()" class="flex-1 bg-rose-50 text-rose-600 border border-rose-200 font-black py-4 rounded-2xl flex flex-col items-center justify-center gap-1 uppercase tracking-widest text-[10px] active:scale-95 transition-all hover:bg-rose-500 hover:text-white">
<i data-lucide="thumbs-down" class="w-5 h-5"></i> Rechazar
</button> </button>
<div class="flex gap-3">
<button onclick="openSignatureArea()" class="flex-1 bg-emerald-50 text-emerald-600 border border-emerald-200 font-black py-4 rounded-2xl flex flex-col items-center justify-center gap-1 uppercase tracking-widest text-[10px] active:scale-95 transition-all hover:bg-emerald-500 hover:text-white">
<i data-lucide="pen-tool" class="w-5 h-5"></i> Firmar y Aceptar
</button>
<button onclick="rejectBudget()" class="flex-1 bg-rose-50 text-rose-600 border border-rose-200 font-black py-4 rounded-2xl flex flex-col items-center justify-center gap-1 uppercase tracking-widest text-[10px] active:scale-95 transition-all hover:bg-rose-500 hover:text-white">
<i data-lucide="thumbs-down" class="w-5 h-5"></i> Rechazar
</button>
</div>
</div> </div>
<div id="qmStatusMessage" class="hidden text-center p-4 rounded-xl font-black text-xs uppercase tracking-widest"></div> <div id="qmStatusMessage" class="hidden text-center p-4 rounded-xl font-black text-xs uppercase tracking-widest"></div>
@@ -520,9 +527,22 @@
const btnContainer = document.getElementById('qmDecisionButtons'); const btnContainer = document.getElementById('qmDecisionButtons');
const msgContainer = document.getElementById('qmStatusMessage'); const msgContainer = document.getElementById('qmStatusMessage');
const sigArea = document.getElementById('qmSignatureArea'); const sigArea = document.getElementById('qmSignatureArea');
const btnStripe = document.getElementById('btnStripePay');
sigArea.classList.add('hidden'); sigArea.classList.add('hidden');
// 🛑 LÓGICA STRIPE: Evaluar si se debe mostrar el botón de pago
let bSet = globalCompanyData?.billing_settings || {};
if (typeof bSet === 'string') { try { bSet = JSON.parse(bSet); } catch(e) {} }
if (bSet.stripe_enabled && bSet.stripe_pk) {
btnStripe.classList.remove('hidden');
btnStripe.classList.add('flex');
} else {
btnStripe.classList.add('hidden');
btnStripe.classList.remove('flex');
}
if (!q.status || q.status === 'pending') { if (!q.status || q.status === 'pending') {
btnContainer.classList.remove('hidden'); btnContainer.classList.remove('hidden');
msgContainer.classList.add('hidden'); msgContainer.classList.add('hidden');
@@ -633,6 +653,26 @@
// --- LÓGICA DE PDF AÑADIDA --- // --- LÓGICA DE PDF AÑADIDA ---
let allServicesGlobalBackup = []; // <--- Variable para no perder los datos del cliente let allServicesGlobalBackup = []; // <--- Variable para no perder los datos del cliente
// 💳 LANZAR PAGO CON STRIPE
async function payWithStripe() {
showToast("⏳ Redirigiendo a pasarela segura...");
try {
const res = await fetch(`${API_URL}/public/portal/${urlToken}/budget/${currentBudgetIdForSignature}/checkout`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
const data = await res.json();
if (data.ok && data.checkout_url) {
window.location.href = data.checkout_url; // Redirigimos a la ventana de pago de Stripe
} else {
showToast(data.error || "❌ Error al iniciar el pago.", true);
}
} catch (e) {
showToast("❌ Error de conexión con el banco.", true);
}
}
async function generatePDF(id) { async function generatePDF(id) {
const budget = currentQuotes.find(b => b.id === id); const budget = currentQuotes.find(b => b.id === id);
if(!budget) return showToast("❌ Error: Presupuesto no encontrado"); if(!budget) return showToast("❌ Error: Presupuesto no encontrado");