43 lines
1.8 KiB
PHP
43 lines
1.8 KiB
PHP
<?php
|
|
require_once __DIR__ . '/config/database.php';
|
|
|
|
try {
|
|
$db = Database::getInstance();
|
|
|
|
// 1. Alter jobs table equipment_type
|
|
$db->exec("ALTER TABLE jobs MODIFY equipment_type VARCHAR(100) DEFAULT 'wheelchair'");
|
|
echo "Modified jobs.equipment_type\n";
|
|
|
|
// 2. Alter jobs table priority
|
|
$db->exec("ALTER TABLE jobs MODIFY priority VARCHAR(100) DEFAULT 'normal'");
|
|
echo "Modified jobs.priority\n";
|
|
|
|
// 3. Alter equipments table type
|
|
$db->exec("ALTER TABLE equipments MODIFY type VARCHAR(100) NOT NULL DEFAULT 'wheelchair'");
|
|
echo "Modified equipments.type\n";
|
|
|
|
// 4. Insert default settings for job_priorities and equipment_types
|
|
$priorities = [
|
|
['id' => 'normal', 'name' => 'ทั่วไป (Normal)', 'color' => 'blue'],
|
|
['id' => 'urgent', 'name' => 'ด่วน (Urgency)', 'color' => 'amber'],
|
|
['id' => 'emergency', 'name' => 'ฉุกเฉิน (Emergency)', 'color' => 'red']
|
|
];
|
|
|
|
$equipments = [
|
|
['id' => 'wheelchair', 'name' => 'รถนั่ง (Wheelchair)', 'icon' => 'fa-wheelchair'],
|
|
['id' => 'stretcher', 'name' => 'รถนอน (Stretcher)', 'icon' => 'fa-bed'],
|
|
['id' => 'bed', 'name' => 'เตียง (Bed)', 'icon' => 'fa-bed-pulse']
|
|
];
|
|
|
|
$stmt = $db->prepare("INSERT IGNORE INTO settings (setting_key, setting_value, category, label, input_type) VALUES
|
|
('job_priorities', ?, 'general', 'ระดับความฉุกเฉิน', 'textarea'),
|
|
('equipment_types', ?, 'general', 'ประเภทอุปกรณ์', 'textarea')
|
|
");
|
|
$stmt->execute([json_encode($priorities, JSON_UNESCAPED_UNICODE), json_encode($equipments, JSON_UNESCAPED_UNICODE)]);
|
|
echo "Inserted default settings\n";
|
|
|
|
echo "Done.\n";
|
|
} catch (Exception $e) {
|
|
echo "Error: " . $e->getMessage() . "\n";
|
|
}
|