diff --git a/salesmanagement/api/get_performance.php b/salesmanagement/api/get_performance.php index 3a9bb2d..a989045 100644 --- a/salesmanagement/api/get_performance.php +++ b/salesmanagement/api/get_performance.php @@ -50,7 +50,7 @@ try { FROM sales_record WHERE member_id = ? AND status = 'completed' AND contract_date BETWEEN ? AND ? UNION ALL - SELECT p.id, t.name as customer, p.contract_date as contractDate, p.contract_amount as amount + SELECT p.id, t.tenant_name as customer, p.contract_date as contractDate, p.contract_amount as amount FROM sales_tenant_products p JOIN sales_tenants t ON p.tenant_id = t.id WHERE (t.sales_manager_id = ? OR (t.sales_manager_id IS NULL AND t.manager_id = ?)) diff --git a/salesmanagement/api/sales_tenants.php b/salesmanagement/api/sales_tenants.php index 7015450..362f872 100644 --- a/salesmanagement/api/sales_tenants.php +++ b/salesmanagement/api/sales_tenants.php @@ -139,6 +139,24 @@ try { if (!in_array('consultation_type', $cols)) { $pdo->exec("ALTER TABLE `sales_tenant_consultations` ADD COLUMN `consultation_type` varchar(20) DEFAULT 'text' AFTER `attachment_paths` "); } + // 5. sales_tenants 테이블에 sales_manager_id 컬럼 추가 + $check5 = $pdo->query("SHOW COLUMNS FROM `sales_tenants` LIKE 'sales_manager_id'")->fetch(); + if (!$check5) { + $pdo->exec("ALTER TABLE `sales_tenants` ADD COLUMN `sales_manager_id` int(11) DEFAULT NULL AFTER `manager_id` "); + } + + // 6. sales_tenant_products 테이블 컬럼 확인 및 추가 + $prodCols = $pdo->query("SHOW COLUMNS FROM `sales_tenant_products`")->fetchAll(PDO::FETCH_COLUMN); + if (!in_array('operator_confirmed', $prodCols)) { + $pdo->exec("ALTER TABLE `sales_tenant_products` ADD COLUMN `operator_confirmed` tinyint(1) DEFAULT 0 AFTER `contract_date` "); + } + if (!in_array('sub_models', $prodCols)) { + $pdo->exec("ALTER TABLE `sales_tenant_products` ADD COLUMN `sub_models` text DEFAULT NULL AFTER `operator_confirmed` "); + } + if (!in_array('commission_amount', $prodCols)) { + $pdo->exec("ALTER TABLE `sales_tenant_products` ADD COLUMN `commission_amount` decimal(15,2) DEFAULT 0.00 AFTER `commission_rate` "); + } + } catch (Exception $e) { error_log("Migration error: " . $e->getMessage()); }