update patients form
This commit is contained in:
parent
f10cdedce9
commit
5f98198b67
@ -1,39 +1,70 @@
|
|||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
// --- Chat Widget Logic ---
|
||||||
const chatForm = document.getElementById('chat-form');
|
const chatForm = document.getElementById('chat-form');
|
||||||
const chatInput = document.getElementById('chat-input');
|
const chatInput = document.getElementById('chat-input');
|
||||||
const chatMessages = document.getElementById('chat-messages');
|
const chatMessages = document.getElementById('chat-messages');
|
||||||
|
|
||||||
const appendMessage = (text, sender) => {
|
if (chatForm && chatInput && chatMessages) {
|
||||||
const msgDiv = document.createElement('div');
|
const appendMessage = (text, sender) => {
|
||||||
msgDiv.classList.add('message', sender);
|
const msgDiv = document.createElement('div');
|
||||||
msgDiv.textContent = text;
|
msgDiv.classList.add('message', sender);
|
||||||
chatMessages.appendChild(msgDiv);
|
msgDiv.textContent = text;
|
||||||
chatMessages.scrollTop = chatMessages.scrollHeight;
|
chatMessages.appendChild(msgDiv);
|
||||||
};
|
chatMessages.scrollTop = chatMessages.scrollHeight;
|
||||||
|
};
|
||||||
|
|
||||||
chatForm.addEventListener('submit', async (e) => {
|
chatForm.addEventListener('submit', async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const message = chatInput.value.trim();
|
const message = chatInput.value.trim();
|
||||||
if (!message) return;
|
if (!message) return;
|
||||||
|
|
||||||
appendMessage(message, 'visitor');
|
appendMessage(message, 'visitor');
|
||||||
chatInput.value = '';
|
chatInput.value = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('api/chat.php', {
|
const response = await fetch('api/chat.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ message })
|
body: JSON.stringify({ message })
|
||||||
|
});
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
// Artificial delay for realism
|
||||||
|
setTimeout(() => {
|
||||||
|
appendMessage(data.reply, 'bot');
|
||||||
|
}, 500);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error:', error);
|
||||||
|
appendMessage("Sorry, something went wrong. Please try again.", 'bot');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Patient Form: Auto-calculate DOB from Age ---
|
||||||
|
function calculateDobFromAge(ageInputId, dobInputId) {
|
||||||
|
const ageInput = document.getElementById(ageInputId);
|
||||||
|
const dobInput = document.getElementById(dobInputId);
|
||||||
|
|
||||||
|
if (ageInput && dobInput) {
|
||||||
|
ageInput.addEventListener('input', function() {
|
||||||
|
const age = parseInt(this.value);
|
||||||
|
if (!isNaN(age) && age >= 0) {
|
||||||
|
const currentYear = new Date().getFullYear();
|
||||||
|
const birthYear = currentYear - age;
|
||||||
|
// Default to Jan 1st of the birth year
|
||||||
|
const dob = `${birthYear}-01-01`;
|
||||||
|
dobInput.value = dob;
|
||||||
|
|
||||||
|
// Trigger change event if needed (e.g. for validation or other listeners)
|
||||||
|
dobInput.dispatchEvent(new Event('change'));
|
||||||
|
dobInput.dispatchEvent(new Event('input'));
|
||||||
|
} else {
|
||||||
|
dobInput.value = '';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
// Artificial delay for realism
|
|
||||||
setTimeout(() => {
|
|
||||||
appendMessage(data.reply, 'bot');
|
|
||||||
}, 500);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error:', error);
|
|
||||||
appendMessage("Sorry, something went wrong. Please try again.", 'bot');
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
|
||||||
|
calculateDobFromAge('add_patient_age', 'add_patient_dob');
|
||||||
|
calculateDobFromAge('edit_patient_age', 'edit_patient_dob');
|
||||||
|
});
|
||||||
36
lang.php
36
lang.php
@ -307,6 +307,23 @@ $translations = [
|
|||||||
'upload_failed' => 'File upload failed',
|
'upload_failed' => 'File upload failed',
|
||||||
'profile_updated_successfully' => 'Profile updated successfully',
|
'profile_updated_successfully' => 'Profile updated successfully',
|
||||||
'error_updating_profile' => 'Error updating profile',
|
'error_updating_profile' => 'Error updating profile',
|
||||||
|
'settings_updated_successfully' => 'Settings updated successfully.',
|
||||||
|
'company_details' => 'Company Details',
|
||||||
|
'company_name' => 'Company Name',
|
||||||
|
'company_email' => 'Company Email',
|
||||||
|
'company_phone' => 'Company Phone',
|
||||||
|
'company_address' => 'Company Address',
|
||||||
|
'ctr_no' => 'CR No.',
|
||||||
|
'registration_no' => 'Registration No.',
|
||||||
|
'vat_no' => 'VAT No.',
|
||||||
|
'timezone' => 'Timezone',
|
||||||
|
'working_hours_start' => 'Working Hours Start',
|
||||||
|
'working_hours_end' => 'Working Hours End',
|
||||||
|
'currency_settings' => 'Currency Settings',
|
||||||
|
'currency_symbol' => 'Currency Symbol',
|
||||||
|
'decimal_digits' => 'Decimal Digits',
|
||||||
|
'company_logo' => 'Company Logo',
|
||||||
|
'company_favicon' => 'Company Favicon',
|
||||||
],
|
],
|
||||||
'ar' => [
|
'ar' => [
|
||||||
'dashboard' => 'لوحة التحكم',
|
'dashboard' => 'لوحة التحكم',
|
||||||
@ -615,5 +632,22 @@ $translations = [
|
|||||||
'upload_failed' => 'فشل تحميل الملف',
|
'upload_failed' => 'فشل تحميل الملف',
|
||||||
'profile_updated_successfully' => 'تم تحديث الملف الشخصي بنجاح',
|
'profile_updated_successfully' => 'تم تحديث الملف الشخصي بنجاح',
|
||||||
'error_updating_profile' => 'خطأ في تحديث الملف الشخصي',
|
'error_updating_profile' => 'خطأ في تحديث الملف الشخصي',
|
||||||
|
'settings_updated_successfully' => 'تم تحديث الإعدادات بنجاح.',
|
||||||
|
'company_details' => 'تفاصيل الشركة',
|
||||||
|
'company_name' => 'اسم الشركة',
|
||||||
|
'company_email' => 'البريد الإلكتروني للشركة',
|
||||||
|
'company_phone' => 'هاتف الشركة',
|
||||||
|
'company_address' => 'عنوان الشركة',
|
||||||
|
'ctr_no' => 'رقم السجل التجاري',
|
||||||
|
'registration_no' => 'رقم التسجيل',
|
||||||
|
'vat_no' => 'الرقم الضريبي',
|
||||||
|
'timezone' => 'المنطقة الزمنية',
|
||||||
|
'working_hours_start' => 'بداية ساعات العمل',
|
||||||
|
'working_hours_end' => 'نهاية ساعات العمل',
|
||||||
|
'currency_settings' => 'إعدادات العملة',
|
||||||
|
'currency_symbol' => 'رمز العملة',
|
||||||
|
'decimal_digits' => 'الخانات العشرية',
|
||||||
|
'company_logo' => 'شعار الشركة',
|
||||||
|
'company_favicon' => 'أيقونة الموقع',
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
Loading…
x
Reference in New Issue
Block a user