🚀 مُصادَق: تحديث برمجي جديد 2026-05-03 02:10
This commit is contained in:
@@ -355,15 +355,23 @@
|
|||||||
function showAddCompanyModal() {
|
function showAddCompanyModal() {
|
||||||
const modals = document.getElementById('modals');
|
const modals = document.getElementById('modals');
|
||||||
modals.innerHTML = `
|
modals.innerHTML = `
|
||||||
<div class="fixed inset-0 bg-black/60 backdrop-blur-sm z-[100] flex items-center justify-center" id="company-modal">
|
<div class="fixed inset-0 bg-black/60 backdrop-blur-sm z-[100] flex items-center justify-center p-4 overflow-y-auto" id="company-modal">
|
||||||
<div class="glass-panel p-8 rounded-3xl w-full max-w-md border border-white/10 shadow-2xl">
|
<div class="glass-panel p-8 rounded-3xl w-full max-w-lg border border-white/10 shadow-2xl my-auto">
|
||||||
<h3 class="text-2xl font-bold mb-6">إضافة شركة جديدة</h3>
|
<h3 class="text-2xl font-bold mb-6">إضافة شركة جديدة</h3>
|
||||||
<form id="add-company-form" class="space-y-4">
|
<form id="add-company-form" class="space-y-4">
|
||||||
<input type="text" id="comp-name" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none" placeholder="اسم الشركة" required>
|
<div class="grid grid-cols-2 gap-4">
|
||||||
<input type="text" id="comp-tax" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none" placeholder="الرقم الضريبي (مثال: 123456789)" required>
|
<input type="text" id="comp-name" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none" placeholder="الاسم (عربي) *" required>
|
||||||
<div class="flex gap-3 mt-6">
|
<input type="text" id="comp-name-en" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none" placeholder="الاسم (إنجليزي)">
|
||||||
|
<input type="text" id="comp-tax" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none" placeholder="الرقم الضريبي *" required>
|
||||||
|
<input type="text" id="comp-cr" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none" placeholder="السجل التجاري">
|
||||||
|
<input type="text" id="comp-city" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none" placeholder="المدينة">
|
||||||
|
<input type="text" id="comp-address" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none" placeholder="العنوان">
|
||||||
|
<input type="email" id="comp-email" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none" placeholder="البريد الإلكتروني">
|
||||||
|
<input type="text" id="comp-phone" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none" placeholder="رقم الهاتف">
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-3 mt-6 pt-4 border-t border-white/10">
|
||||||
<button type="button" onclick="document.getElementById('company-modal').remove()" class="flex-1 py-3 bg-white/5 hover:bg-white/10 rounded-xl transition">إلغاء</button>
|
<button type="button" onclick="document.getElementById('company-modal').remove()" class="flex-1 py-3 bg-white/5 hover:bg-white/10 rounded-xl transition">إلغاء</button>
|
||||||
<button type="submit" class="flex-1 py-3 bg-primary hover:bg-primary-dark text-white font-bold rounded-xl shadow-lg transition">حفظ</button>
|
<button type="submit" class="flex-1 py-3 bg-primary hover:bg-primary-dark text-white font-bold rounded-xl shadow-lg transition">حفظ الشركة</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -373,13 +381,66 @@
|
|||||||
document.getElementById('add-company-form').onsubmit = async (e) => {
|
document.getElementById('add-company-form').onsubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
try {
|
try {
|
||||||
const name = document.getElementById('comp-name').value;
|
const data = {
|
||||||
const tax = document.getElementById('comp-tax').value;
|
name: document.getElementById('comp-name').value,
|
||||||
await API.post('/companies', { name, tax_identification_number: tax });
|
name_en: document.getElementById('comp-name-en').value || null,
|
||||||
|
tax_identification_number: document.getElementById('comp-tax').value,
|
||||||
|
commercial_registration_number: document.getElementById('comp-cr').value || null,
|
||||||
|
city: document.getElementById('comp-city').value || null,
|
||||||
|
address: document.getElementById('comp-address').value || null,
|
||||||
|
contact_email: document.getElementById('comp-email').value || null,
|
||||||
|
contact_phone: document.getElementById('comp-phone').value || null
|
||||||
|
};
|
||||||
|
await API.post('/companies', data);
|
||||||
document.getElementById('company-modal').remove();
|
document.getElementById('company-modal').remove();
|
||||||
renderCompanies();
|
renderCompanies();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
alert(err.error?.message_ar || 'حدث خطأ');
|
alert(err.error?.message_ar || err.error?.details?.message || err.message || 'حدث خطأ');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function showJoFotaraModal(companyId) {
|
||||||
|
const modals = document.getElementById('modals');
|
||||||
|
modals.innerHTML = `
|
||||||
|
<div class="fixed inset-0 bg-black/60 backdrop-blur-sm z-[100] flex items-center justify-center p-4" id="jofotara-modal">
|
||||||
|
<div class="glass-panel p-8 rounded-3xl w-full max-w-md border border-white/10 shadow-2xl">
|
||||||
|
<h3 class="text-2xl font-bold mb-6">إعدادات الربط مع JoFotara</h3>
|
||||||
|
<form id="jofotara-form" class="space-y-4">
|
||||||
|
<input type="text" id="jf-client-id" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none font-mono" placeholder="Client ID" required>
|
||||||
|
<input type="password" id="jf-secret-key" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none font-mono" placeholder="Secret Key" required>
|
||||||
|
<div class="flex gap-3 mt-6">
|
||||||
|
<button type="button" onclick="document.getElementById('jofotara-modal').remove()" class="flex-1 py-3 bg-white/5 hover:bg-white/10 rounded-xl transition">إلغاء</button>
|
||||||
|
<button type="submit" class="flex-1 py-3 bg-primary hover:bg-primary-dark text-white font-bold rounded-xl shadow-lg transition">حفظ الإعدادات</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
document.getElementById('jofotara-form').onsubmit = async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
try {
|
||||||
|
const client_id = document.getElementById('jf-client-id').value;
|
||||||
|
const secret_key = document.getElementById('jf-secret-key').value;
|
||||||
|
// Note: We need a PUT endpoint to update Jofotara credentials.
|
||||||
|
// Our API has: PUT /api/v1/companies/{id}/jofotara
|
||||||
|
const res = await fetch(`${API.baseUrl}/companies/${companyId}/jofotara`, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': \`Bearer \${API.accessToken}\`
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ client_id, secret_key })
|
||||||
|
});
|
||||||
|
const data = await res.json();
|
||||||
|
if (!res.ok) throw data;
|
||||||
|
|
||||||
|
document.getElementById('jofotara-modal').remove();
|
||||||
|
renderCompanies();
|
||||||
|
} catch(err) {
|
||||||
|
alert(err.error?.message_ar || err.error?.details?.message || 'حدث خطأ أثناء حفظ الإعدادات');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -405,7 +466,7 @@
|
|||||||
document.getElementById('upload-invoice-form').onsubmit = async (e) => {
|
document.getElementById('upload-invoice-form').onsubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
try {
|
try {
|
||||||
const companyId = parseInt(document.getElementById('inv-comp-id').value);
|
const companyId = document.getElementById('inv-comp-id').value; // Keep as string (UUID)
|
||||||
const payload = JSON.parse(document.getElementById('inv-payload').value);
|
const payload = JSON.parse(document.getElementById('inv-payload').value);
|
||||||
|
|
||||||
const btn = e.target.querySelector('button[type="submit"]');
|
const btn = e.target.querySelector('button[type="submit"]');
|
||||||
|
|||||||
Reference in New Issue
Block a user