Update: 2026-05-04 02:53:16
This commit is contained in:
@@ -28,6 +28,7 @@ $routes = [
|
||||
'v1/invoices' => ['GET', 'invoices/index.php'],
|
||||
'v1/invoices/view' => ['GET', 'invoices/view.php'],
|
||||
'v1/invoices/file' => ['GET', 'invoices/file.php'],
|
||||
'v1/invoices/approve' => ['POST', 'invoices/approve.php'],
|
||||
'v1/invoices/upload' => ['POST', 'invoices/upload.php'],
|
||||
'v1/dashboard/stats' => ['GET', 'dashboard/stats.php'],
|
||||
'v1/tenants' => ['GET', 'tenants/index.php'],
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet">
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrious/4.0.2/qrious.min.js"></script>
|
||||
<style>
|
||||
:root {
|
||||
--emerald: #10b981;
|
||||
@@ -326,8 +327,19 @@
|
||||
</div>
|
||||
|
||||
<div class="p-6 bg-gray-950/50 border-t border-gray-800 flex gap-4">
|
||||
<button class="flex-1 bg-emerald-600 hover:bg-emerald-500 py-3 rounded-xl font-bold transition">✅ اعتماد الفاتورة</button>
|
||||
<button class="flex-1 border border-gray-800 hover:bg-gray-800 py-3 rounded-xl font-bold transition">📝 تعديل البيانات</button>
|
||||
<template x-if="currentInvoice?.status === 'extracted'">
|
||||
<button @click="approveInvoice(currentInvoice.id)" class="flex-1 bg-emerald-600 hover:bg-emerald-500 py-3 rounded-xl font-bold transition flex items-center justify-center gap-2">
|
||||
<span>✅ اعتماد الفاتورة وتوليد QR</span>
|
||||
</button>
|
||||
</template>
|
||||
<template x-if="currentInvoice?.status === 'approved'">
|
||||
<div class="flex-1 flex flex-col items-center justify-center bg-gray-900 rounded-xl p-4 border border-emerald-500/20">
|
||||
<span class="text-xs text-emerald-500 font-bold mb-2">تم الاعتماد لدى جوفوترة</span>
|
||||
<template x-if="currentInvoice?.qr_code">
|
||||
<img :src="'data:image/png;base64,' + generateQRPng(currentInvoice.qr_code)" class="w-24 h-24 rounded bg-white p-1" alt="QR Code">
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -456,6 +468,38 @@
|
||||
}
|
||||
},
|
||||
|
||||
async approveInvoice(id) {
|
||||
if (!confirm('هل أنت متأكد من اعتماد الفاتورة وإرسالها إلى جوفوترة؟')) return;
|
||||
|
||||
const res = await fetch('/index.php?route=v1/invoices/approve', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + this.token(),
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: id })
|
||||
});
|
||||
const json = await res.json();
|
||||
|
||||
if (json.success) {
|
||||
alert('تم الاعتماد بنجاح!');
|
||||
this.viewInvoice(id); // Reload to show QR
|
||||
this.loadInvoices();
|
||||
} else {
|
||||
this.showError(json.message);
|
||||
}
|
||||
},
|
||||
|
||||
generateQRPng(base64Tlv) {
|
||||
const qr = new QRious({
|
||||
value: base64Tlv,
|
||||
size: 200,
|
||||
level: 'M'
|
||||
});
|
||||
// Remove 'data:image/png;base64,' from the return, as the template adds it
|
||||
return qr.toDataURL().split(',')[1];
|
||||
},
|
||||
|
||||
handleFile(e) { this.selectedFile = e.target.files[0]; },
|
||||
|
||||
async uploadInvoice() {
|
||||
|
||||
Reference in New Issue
Block a user