56 lines
2.6 KiB
PHP
56 lines
2.6 KiB
PHP
<?php
|
|
// db/migrations/add_welcome_template.php
|
|
|
|
require_once __DIR__ . '/../../db/config.php';
|
|
|
|
$pdo = db();
|
|
|
|
$templates = [
|
|
[
|
|
'event_name' => '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) {
|
|
// Check if exists
|
|
$stmt = $pdo->prepare("SELECT id FROM notification_templates WHERE event_name = ?");
|
|
$stmt->execute([$t['event_name']]);
|
|
$existing = $stmt->fetch();
|
|
|
|
if (!$existing) {
|
|
$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 {
|
|
// Update existing template to match file content (useful for development)
|
|
$sql = "UPDATE notification_templates SET
|
|
email_subject_en = ?, email_body_en = ?,
|
|
email_subject_ar = ?, email_body_ar = ?,
|
|
whatsapp_body_en = ?, whatsapp_body_ar = ?
|
|
WHERE event_name = ?";
|
|
$pdo->prepare($sql)->execute([
|
|
$t['email_subject_en'],
|
|
$t['email_body_en'],
|
|
$t['email_subject_ar'],
|
|
$t['email_body_ar'],
|
|
$t['whatsapp_body_en'],
|
|
$t['whatsapp_body_ar'],
|
|
$t['event_name']
|
|
]);
|
|
echo "Updated template: {$t['event_name']}\n";
|
|
}
|
|
} |