Actualizar index2.html
This commit is contained in:
44
index2.html
44
index2.html
@@ -173,14 +173,21 @@
|
|||||||
</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 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">
|
||||||
|
<i data-lucide="credit-card" class="w-5 h-5"></i> Pagar Presupuesto
|
||||||
|
</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">
|
<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
|
<i data-lucide="pen-tool" class="w-5 h-5"></i> Firmar y Aceptar
|
||||||
</button>
|
</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">
|
<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
|
<i data-lucide="thumbs-down" class="w-5 h-5"></i> Rechazar
|
||||||
</button>
|
</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>
|
||||||
</div>
|
</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");
|
||||||
|
|||||||
Reference in New Issue
Block a user