Files
sam-sales/salesmanagement/api/seed_packages.php

55 lines
1.9 KiB
PHP

<?php
require_once __DIR__ . '/../../lib/mydb.php';
try {
$pdo = db_connect();
// Check if package_pricing has any packages
$stmt = $pdo->query("SELECT COUNT(*) FROM package_pricing WHERE item_type = 'package' AND is_active = 1");
if ($stmt->fetchColumn() == 0) {
$initialPackages = [
[
"item_type" => "package",
"item_id" => "construction_management",
"item_name" => "공사관리",
"sub_name" => "패키지",
"total_amount" => 0,
"join_fee" => 40000000,
"subscription_fee" => 200000,
"allow_flexible_pricing" => 0
],
[
"item_type" => "package",
"item_id" => "process_government",
"item_name" => "공정/정부지원사업",
"sub_name" => "패키지",
"total_amount" => 0,
"join_fee" => 80000000,
"subscription_fee" => 400000,
"allow_flexible_pricing" => 0
]
];
$stmt = $pdo->prepare("INSERT INTO package_pricing (item_type, item_id, item_name, sub_name, total_amount, join_fee, subscription_fee, allow_flexible_pricing) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
foreach ($initialPackages as $item) {
$stmt->execute([
$item['item_type'],
$item['item_id'],
$item['item_name'],
$item['sub_name'],
$item['total_amount'],
$item['join_fee'],
$item['subscription_fee'],
$item['allow_flexible_pricing']
]);
}
echo "Packages seeded successfully.\n";
} else {
echo "Packages already exist.\n";
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>