diff --git a/db/migrations/add_welcome_template.php b/db/migrations/add_welcome_template.php new file mode 100644 index 0000000..3cec9df --- /dev/null +++ b/db/migrations/add_welcome_template.php @@ -0,0 +1,40 @@ + 'welcome_message', + 'email_subject_en' => 'Welcome to CargoLink!', + 'email_body_en' => "Dear {user_name},\n\nWelcome to CargoLink! We are excited to have you on board.\n\nYou can now log in to your dashboard and start using our services.\n\nBest regards,\nThe CargoLink Team", + 'email_subject_ar' => 'مرحباً بك في كارجو لينك!', + 'email_body_ar' => "عزيزي {user_name}،\n\nمرحباً بك في كارجو لينك! نحن سعداء بانضمامك إلينا.\n\nيمكنك الآن تسجيل الدخول إلى لوحة التحكم والبدء في استخدام خدماتنا.\n\nتحياتنا،\nفريق كارجو لينك", + 'whatsapp_body_en' => "Welcome to CargoLink, {user_name}! 🚚\n\nWe're glad to have you with us. Log in now to get started: https://cargolink.om", + 'whatsapp_body_ar' => "مرحباً بك في كارجو لينك، {user_name}! 🚚\n\nسعداء بانضمامك إلينا. سجل الدخول الآن للبدء: https://cargolink.om" + ] +]; + +foreach ($templates as $t) { + $stmt = $pdo->prepare("SELECT id FROM notification_templates WHERE event_name = ?"); + $stmt->execute([$t['event_name']]); + + if (!$stmt->fetch()) { + $sql = "INSERT INTO notification_templates (event_name, email_subject_en, email_body_en, email_subject_ar, email_body_ar, whatsapp_body_en, whatsapp_body_ar) VALUES (?, ?, ?, ?, ?, ?, ?)"; + $pdo->prepare($sql)->execute([ + $t['event_name'], + $t['email_subject_en'], + $t['email_body_en'], + $t['email_subject_ar'], + $t['email_body_ar'], + $t['whatsapp_body_en'], + $t['whatsapp_body_ar'] + ]); + echo "Added template: {$t['event_name']}\n"; + } else { + echo "Template already exists: {$t['event_name']}\n"; + } +} + diff --git a/includes/app.php b/includes/app.php index 3132910..7afd31b 100644 --- a/includes/app.php +++ b/includes/app.php @@ -203,7 +203,25 @@ $translations = [ 'select_city_placeholder' => 'Select City', 'loading_cities' => 'Loading...', 'error_loading_cities' => 'Error loading cities', - 'cancel' => 'Cancel' + 'cancel' => 'Cancel', + 'my_profile' => 'My Profile', + 'profile_picture' => 'Profile Picture', + 'change_picture' => 'Change Picture', + 'picture_hint' => 'Click the camera icon to update.', + 'full_name' => 'Full Name', + 'email_address' => 'Email Address', + 'email_hint' => 'Email cannot be changed.', + 'account_role' => 'Account Role', + 'change_password' => 'Change Password', + 'new_password' => 'New Password', + 'confirm_password' => 'Confirm Password', + 'save_changes' => 'Save Changes', + 'passwords_do_not_match' => 'Passwords do not match.', + 'password_too_short' => 'Password must be at least 6 characters.', + 'profile_updated' => 'Profile updated successfully.', + 'password_updated' => 'Password updated successfully.', + 'upload_failed' => 'File upload failed.', + 'invalid_image' => 'Invalid image format. Allowed: JPG, PNG, GIF, WEBP.' ), "ar" => array ( 'app_name' => 'CargoLink', @@ -395,7 +413,25 @@ $translations = [ 'select_city_placeholder' => 'اختر المدينة', 'loading_cities' => 'جاري التحميل...', 'error_loading_cities' => 'خطأ في تحميل المدن', - 'cancel' => 'إلغاء' + 'cancel' => 'إلغاء', + 'my_profile' => 'ملفي الشخصي', + 'profile_picture' => 'صورة الملف الشخصي', + 'change_picture' => 'تغيير الصورة', + 'picture_hint' => 'انقر على أيقونة الكاميرا للتحديث.', + 'full_name' => 'الاسم الكامل', + 'email_address' => 'البريد الإلكتروني', + 'email_hint' => 'لا يمكن تغيير البريد الإلكتروني.', + 'account_role' => 'نوع الحساب', + 'change_password' => 'تغيير كلمة المرور', + 'new_password' => 'كلمة المرور الجديدة', + 'confirm_password' => 'تأكيد كلمة المرور', + 'save_changes' => 'حفظ التغييرات', + 'passwords_do_not_match' => 'كلمات المرور غير متطابقة.', + 'password_too_short' => 'يجب أن تكون كلمة المرور 6 أحرف على الأقل.', + 'profile_updated' => 'تم تحديث الملف الشخصي بنجاح.', + 'password_updated' => 'تم تحديث كلمة المرور بنجاح.', + 'upload_failed' => 'فشل تحميل الملف.', + 'invalid_image' => 'تنسيق الصورة غير صالح. المسموح: JPG, PNG, GIF, WEBP.' ) ]; @@ -609,4 +645,4 @@ function has_permission(string $permissionSlug, ?int $userId = null): bool function format_currency(float $amount): string { return number_format($amount, 3) . ' OMR'; -} \ No newline at end of file +} diff --git a/includes/layout.php b/includes/layout.php index 7e471ce..bc882bf 100644 --- a/includes/layout.php +++ b/includes/layout.php @@ -12,6 +12,20 @@ function render_header(string $title, string $active = '', bool $isFluid = false $appName = get_setting('company_name', t('app_name')); $logoPath = get_setting('logo_path'); $faviconPath = get_setting('favicon_path'); + + $navUserPic = ''; + $navUserName = 'Account'; + if (isset($_SESSION['user_id'])) { + try { + $stmt = db()->prepare("SELECT full_name, profile_picture FROM users WHERE id = ?"); + $stmt->execute([$_SESSION['user_id']]); + $u = $stmt->fetch(); + if ($u) { + $navUserName = $u['full_name']; + $navUserPic = $u['profile_picture']; + } + } catch (Throwable $e) {} + } ?> @@ -96,13 +110,20 @@ function render_header(string $title, string $active = '', bool $isFluid = false
Your logistics partner
+