-- 모모유통 페이지를 FITO menu_info 의 [사용자] 그룹 아래에 대메뉴/소메뉴 2단 구조로 등록
-- 기존 [DASHBOARD] 대메뉴 활용 + 거래처/마스터/매입/출고-정산/통계 5개 신규 대메뉴
BEGIN;

-- 기존 모모 메뉴 정리
DELETE FROM menu_info WHERE objid BETWEEN 9000000 AND 9000599;

-- ===== 신규 대메뉴 (parent = -395553955 [사용자]) =====
INSERT INTO menu_info (objid, menu_type, parent_obj_id, menu_name_kor, menu_name_eng, seq, menu_url, status, system_name, regdate) VALUES
  (9000100, '1', -395553955, '거래처 주문',  'Customer Orders', 600, '', 'active', 'PMS', NOW()),
  (9000200, '1', -395553955, '마스터 관리',  'Master',          650, '', 'active', 'PMS', NOW()),
  (9000300, '1', -395553955, '매입/입고',     'Purchase',        700, '', 'active', 'PMS', NOW()),
  (9000400, '1', -395553955, '출고/정산',     'Outbound',        750, '', 'active', 'PMS', NOW()),
  (9000500, '1', -395553955, '통계',          'Statistics',      800, '', 'active', 'PMS', NOW());

-- ===== 기존 [DASHBOARD] 대메뉴(1837127121) 아래 자식 =====
INSERT INTO menu_info (objid, menu_type, parent_obj_id, menu_name_kor, menu_name_eng, seq, menu_url, status, system_name, regdate) VALUES
  (9000001, '1', 1837127121, '대시보드', 'Dashboard', 1, '/m/dashboard', 'active', 'PMS', NOW());

-- 기존 [DASHBOARD] 대메뉴의 다른 자식(예: dashboard.do)은 비활성화
UPDATE menu_info SET status='inactive' WHERE parent_obj_id = 1837127121 AND objid != 9000001;

-- ===== 거래처 주문 (9000100) =====
INSERT INTO menu_info (objid, menu_type, parent_obj_id, menu_name_kor, menu_name_eng, seq, menu_url, status, system_name, regdate) VALUES
  (9000101, '1', 9000100, '품목 검색',     'Items',     10, '/m/items',          'active', 'PMS', NOW()),
  (9000102, '1', 9000100, '출고 요청',     'New Order', 11, '/m/orders/new',     'active', 'PMS', NOW()),
  (9000103, '1', 9000100, '내 출고 이력',   'My Orders', 12, '/m/orders',         'active', 'PMS', NOW());

-- ===== 마스터 관리 (9000200) =====
INSERT INTO menu_info (objid, menu_type, parent_obj_id, menu_name_kor, menu_name_eng, seq, menu_url, status, system_name, regdate) VALUES
  (9000201, '1', 9000200, '품목 관리',   'Item Master', 10, '/m/admin/items',      'active', 'PMS', NOW()),
  (9000202, '1', 9000200, '매입처 관리', 'Vendors',     11, '/m/admin/vendors',    'active', 'PMS', NOW()),
  (9000203, '1', 9000200, '창고 관리',   'Warehouses',  12, '/m/admin/warehouses', 'active', 'PMS', NOW());

-- ===== 매입/입고 (9000300) =====
INSERT INTO menu_info (objid, menu_type, parent_obj_id, menu_name_kor, menu_name_eng, seq, menu_url, status, system_name, regdate) VALUES
  (9000301, '1', 9000300, '매입 발주', 'Procurements', 10, '/m/admin/procurements', 'active', 'PMS', NOW()),
  (9000302, '1', 9000300, '입고 처리', 'Inbound',      11, '/m/admin/inbounds',     'active', 'PMS', NOW()),
  (9000303, '1', 9000300, '재고 관리', 'Inventory',    12, '/m/admin/inventory',    'active', 'PMS', NOW());

-- ===== 출고/정산 (9000400) =====
INSERT INTO menu_info (objid, menu_type, parent_obj_id, menu_name_kor, menu_name_eng, seq, menu_url, status, system_name, regdate) VALUES
  (9000401, '1', 9000400, '출고 관리',   'Outbound', 10, '/m/admin/orders',   'active', 'PMS', NOW()),
  (9000402, '1', 9000400, '입금 관리',   'Payments', 11, '/m/admin/payments', 'active', 'PMS', NOW()),
  (9000403, '1', 9000400, '계산서 발행', 'Invoices', 12, '/m/admin/invoices', 'active', 'PMS', NOW());

-- ===== 통계 (9000500) =====
INSERT INTO menu_info (objid, menu_type, parent_obj_id, menu_name_kor, menu_name_eng, seq, menu_url, status, system_name, regdate) VALUES
  (9000501, '1', 9000500, '월간 매출',   'Stat Monthly', 10, '/m/admin/statistics',         'active', 'PMS', NOW()),
  (9000502, '1', 9000500, '일자별 매출', 'Stat Daily',   11, '/m/admin/statistics/daily',   'active', 'PMS', NOW()),
  (9000503, '1', 9000500, '원가/마진',   'Margin',       12, '/m/admin/statistics/margin',  'active', 'PMS', NOW());

COMMIT;
