🚀 مُصادَق: تحديث برمجي جديد 2026-05-03 03:15
This commit is contained in:
@@ -200,7 +200,7 @@
|
||||
let roleLabel = 'مستخدم';
|
||||
|
||||
if (user.role === 'super_admin') { roleColor = 'text-primary'; roleLabel = 'سوبر أدمن'; }
|
||||
else if (user.role === 'admin') { roleColor = 'text-blue-400'; roleLabel = 'مدير النظام'; }
|
||||
else if (user.role === 'admin') { roleColor = 'text-blue-400'; roleLabel = 'مدير شركة'; }
|
||||
else if (user.role === 'accountant') { roleColor = 'text-purple-400'; roleLabel = 'محاسب'; }
|
||||
else if (user.role === 'employee') { roleColor = 'text-orange-400'; roleLabel = 'موظف'; }
|
||||
|
||||
@@ -237,14 +237,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
function showAddUserModal() {
|
||||
async function showAddUserModal() {
|
||||
const currentRole = localStorage.getItem('user_role');
|
||||
let companies = [];
|
||||
let companySelectHtml = '';
|
||||
|
||||
if (currentRole === 'super_admin') {
|
||||
try {
|
||||
const res = await API.get('/companies');
|
||||
companies = res.data;
|
||||
companySelectHtml = `
|
||||
<select id="usr-company" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none">
|
||||
<option value="">-- ربط بشركة (اختياري للسوبر أدمن) --</option>
|
||||
${companies.map(c => `<option value="${c.id}">${c.name}</option>`).join('')}
|
||||
</select>
|
||||
`;
|
||||
} catch (err) { console.error('Failed to fetch companies'); }
|
||||
}
|
||||
|
||||
let optionsHtml = `
|
||||
<option value="accountant">محاسب</option>
|
||||
<option value="employee">موظف</option>
|
||||
`;
|
||||
if (currentRole === 'super_admin') {
|
||||
optionsHtml += `<option value="admin">مدير نظام</option>`;
|
||||
optionsHtml += `<option value="admin">مدير شركة</option>`;
|
||||
}
|
||||
|
||||
const modals = document.getElementById('modals');
|
||||
@@ -259,6 +275,7 @@
|
||||
<select id="usr-role" class="w-full bg-black/20 border border-white/10 rounded-xl px-4 py-3 text-white focus:border-primary outline-none" required>
|
||||
${optionsHtml}
|
||||
</select>
|
||||
${companySelectHtml}
|
||||
|
||||
<div class="flex gap-3 mt-6 pt-4 border-t border-white/10">
|
||||
<button type="button" onclick="document.getElementById('user-modal').remove()" class="flex-1 py-3 bg-white/5 hover:bg-white/10 rounded-xl transition">إلغاء</button>
|
||||
@@ -276,7 +293,8 @@
|
||||
name: document.getElementById('usr-name').value,
|
||||
email: document.getElementById('usr-email').value,
|
||||
password: document.getElementById('usr-password').value,
|
||||
role: document.getElementById('usr-role').value
|
||||
role: document.getElementById('usr-role').value,
|
||||
assigned_company_id: document.getElementById('usr-company')?.value || null
|
||||
};
|
||||
await API.post('/users', data);
|
||||
document.getElementById('user-modal').remove();
|
||||
@@ -390,7 +408,7 @@
|
||||
<svg class="w-5 h-5 text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
|
||||
</div>
|
||||
<div>
|
||||
<p class="font-bold text-sm text-slate-200">${inv.invoice_uuid.substring(0,8)}...</p>
|
||||
<p class="font-bold text-sm text-slate-200">${inv.id ? inv.id.substring(0,8) : ''}...</p>
|
||||
<p class="text-xs text-slate-400 mt-1">${inv.company_name}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -520,7 +538,7 @@
|
||||
const statusColor = inv.status === 'APPROVED' ? 'text-primary' : (inv.status === 'REJECTED' ? 'text-red-400' : 'text-yellow-400');
|
||||
html += `
|
||||
<tr class="hover:bg-white/5 transition-colors">
|
||||
<td class="p-4 font-mono text-xs text-slate-300">${inv.invoice_uuid}</td>
|
||||
<td class="p-4 font-mono text-xs text-slate-300">${inv.id}</td>
|
||||
<td class="p-4 font-bold text-slate-200">${inv.company_id}</td>
|
||||
<td class="p-4 text-slate-400">${new Date(inv.created_at).toLocaleDateString('ar-JO')}</td>
|
||||
<td class="p-4 font-bold ${statusColor}">${inv.status}</td>
|
||||
|
||||
Reference in New Issue
Block a user