// Todo 관련 타입
export interface TodoModel {
  idx: number;
  gcode: string;
  uid: string;
  title: string;
  remark: string;
  flag: boolean;
  expire: string | null;
  seqno: number;
  request: string | null;
  status: string;
  okdate: string | null;
  wuid: string;
  wdate: string;
}

// API 응답 타입
export interface ApiResponse<T = unknown> {
  Success: boolean;
  Message?: string;
  Data?: T;
}

// Dashboard 관련 타입
export interface PurchaseCount {
  NR: number;
  CR: number;
  Message?: string;
}

export interface HolyUser {
  uid: string;
  type: string;
  cate: string;
  sdate: string;
  edate: string;
  title: string;
  name: string;
}

export interface HolyRequestUser {
  uid: string;
  cate: string;
  sdate: string;
  edate: string;
  HolyReason: string;
  name: string;
  holydays: number;
  holytimes: number;
  remark: string;
}

export interface PurchaseItem {
  pdate: string;
  process: string;
  pumname: string;
  pumscale: string;
  pumunit: string;
  pumqtyreq: number;
  pumprice: number;
  pumamt: number;
}

// 상태 관련 타입
export type TodoStatus = '0' | '1' | '2' | '3' | '5';
export type TodoPriority = -1 | 0 | 1 | 2 | 3;

// 로그 타입
export interface LogEntry {
  id: number;
  timestamp: string;
  message: string;
  type: 'info' | 'warning' | 'error';
}

// WebView2 Native Bridge Types
declare global {
  interface Window {
    chrome?: {
      webview?: {
        hostObjects: {
          machine: MachineBridgeInterface;
        };
        addEventListener(type: string, listener: (event: MessageEvent) => void): void;
        removeEventListener(type: string, listener: (event: MessageEvent) => void): void;
        postMessage(message: unknown): void;
      }
    }
  }
}

// 근태 관련 타입 (Holyday 테이블)
export interface KuntaeModel {
  idx: number;
  gcode: string;
  cate: string;          // 구분 (연차, 대체, 휴가 등)
  sdate: string;         // 시작일
  edate: string;         // 종료일
  term: number;          // 사용(일)
  crtime: number;        // 사용(시간)
  termDr: number;        // 발생(일)
  DrTime: number;        // 발생(시간)
  contents: string;      // 내용
  uid: string;           // 사용자 ID
  UserName?: string;     // 사용자 이름 (조인)
  wuid: string;          // 등록자 ID
  wdate: string;         // 등록일
  extcate?: string;      // 외부 소스 카테고리
  extidx?: number;       // 외부 소스 인덱스
}

// 근태 권한 정보 타입
export interface HolydayPermission {
  Success: boolean;
  CurrentUserId: string;
  Level: number;
  CanManage: boolean;
}

// 근태 사용자 목록 타입
export interface HolydayUser {
  uid: string;
  UserName: string;
}

// 근태 잔량 정보 타입
export interface HolydayBalance {
  cate: string;
  TotalGenDays: number;
  TotalGenHours: number;
  TotalUseDays: number;
  TotalUseHours: number;
}

// 업무일지 관련 타입 (기존 - 사용 안함)
export interface JobreportModel {
  idx: number;
  gcode: string;
  uid: string;
  uname: string;
  pdate: string;
  title: string;
  contents: string;
  wuid: string;
  wdate: string;
}

// 업무일지 타입 (vJobReportForUser 뷰 + JobReport 테이블)
export interface JobReportItem {
  idx: number;
  pidx: number;
  pdate: string;
  id: string;           // 사용자 ID (uid -> id)
  name: string;         // 사용자 이름 (username -> name)
  type: string;         // 업무형태
  svalue: string;       // 업무형태 표시값
  hrs: number;
  ot: number;
  otStart?: string;     // 초과근무 시작시간
  otEnd?: string;       // 초과근무 종료시간
  requestpart: string;
  package: string;
  userprocess: string;  // 사용자 공정
  status: string;
  projectName: string;
  description: string;
  ww: string;
  otpms: string;        // OT PMS
  process: string;
  jobgrp?: string;      // 업무분류 (상세 조회 시)
  tag?: string;         // 태그 (상세 조회 시)
}

// 업무일지 사용자 타입
export interface JobReportUser {
  id: string;
  name: string;
  process?: string;
}

// 로그인 관련 타입
export interface UserInfo {
  Id: string;
  Name: string;
  NameE: string;
  Dept: string;
  Email: string;
  Level: number;
  Gcode: string;
}

export interface LoginStatusResponse {
  Success: boolean;
  IsLoggedIn: boolean;
  User: UserInfo | null;
}

export interface LoginResult {
  Success: boolean;
  Message: string;
  RedirectUrl?: string;
  UserName?: string;
  VersionWarning?: string;
}

export interface UserGroup {
  gcode: string;
  name: string;
}

export interface PreviousLoginInfo {
  Success: boolean;
  Data: {
    LastGcode: string;
    LastDept: string;
    LastId: string;
  };
}

// 사용자 정보 상세 타입
export interface UserInfoDetail {
  Id: string;
  NameK: string;
  NameE: string;
  Dept: string;
  Grade: string;
  Email: string;
  Tel: string;
  Hp: string;
  DateIn: string;
  DateO: string;
  Memo: string;
  Process: string;
  State: string;
  UseJobReport: boolean;
  UseUserState: boolean;
  ExceptHoly: boolean;
  Level: number;
}

// 공용코드 관련 타입
export interface CommonCodeGroup {
  code: string;
  svalue: string;
  memo: string;
}

export interface CommonCode {
  idx: number;
  gcode?: string;
  grp: string;
  code: string;
  svalue: string;
  ivalue: number;
  fvalue: number;
  svalue2?: string;
  memo: string;
  wuid?: string;
  wdate?: string;
}

// 품목정보 관련 타입
export interface ItemInfo {
  idx: number;
  sid: string;
  cate: string;
  name: string;
  model: string;
  scale: string;
  unit: string;
  price: number;
  supply: string;
  supplyidx?: number;
  manu: string;
  storage: string;
  disable: boolean;
  memo: string;
}

// 품목 상세 정보 (supplyidx 포함)
export interface ItemDetail extends ItemInfo {
  supplyidx: number;
}

// 공급처 담당자 타입
export interface SupplierStaff {
  idx: number;
  name: string;
  tel: string;
  email: string;
  dept: string;
}

// 구매내역 항목 타입 (입고/발주)
export interface PurchaseHistoryItem {
  idx: number;
  date: string;
  request: string;
  qty: number;
  price: number;
  state: string;
}

// 사용자 목록 관련 타입
export interface GroupUser {
  id: string;
  name: string;
  nameE: string;
  grade: string;
  email: string;
  tel: string;
  indate: string | null;
  outdate: string | null;
  hp: string;
  processs: string;
  state: string;
  memo: string;
  level: number;
  useUserState: boolean;
  useJobReport: boolean;
  exceptHoly: boolean;
  gcode: string;
  dept?: string;
}

// MachineBridge 인터페이스
export interface MachineBridgeInterface {
  // Todo API
  Todo_GetTodos(): Promise<string>;
  Todo_GetTodo(id: number): Promise<string>;
  CreateTodo(title: string, remark: string, expire: string | null, seqno: number, flag: boolean, request: string | null, status: string): Promise<string>;
  Todo_UpdateTodo(idx: number, title: string, remark: string, expire: string | null, seqno: number, flag: boolean, request: string | null, status: string): Promise<string>;
  Todo_DeleteTodo(id: number): Promise<string>;
  GetUrgentTodos(): Promise<string>;

  // Dashboard API
  TodayCountH(): Promise<string>;
  GetHolydayRequestCount(): Promise<string>;
  GetCurrentUserCount(): Promise<string>;
  GetPurchaseWaitCount(): Promise<string>;
  GetHolyUser(): Promise<string>;
  GetHolyRequestUser(): Promise<string>;
  GetPresentUserList(): Promise<string>;
  GetPurchaseNRList(): Promise<string>;
  GetPurchaseCRList(): Promise<string>;

  // Kuntae API
  Kuntae_GetList(sd: string, ed: string): Promise<string>;
  Kuntae_Delete(id: number): Promise<string>;
  Kuntae_ErrorCheck(sd: string, ed: string): Promise<string>;
  Kuntae_FixError(pdate: string): Promise<string>;
  Kuntae_FixErrors(dates: string): Promise<string>;

  // Favorite API
  Favorite_GetList(): Promise<string>;

  // Jobreport API (JobReport 뷰/테이블)
  Jobreport_GetList(sd: string, ed: string, uid: string, cate: string, searchKey: string): Promise<string>;
  Jobreport_GetUsers(): Promise<string>;
  Jobreport_GetDetail(id: number): Promise<string>;
  Jobreport_Add(pdate: string, projectName: string, pidx: number, requestpart: string, package_: string, type: string, process: string, status: string, description: string, hrs: number, ot: number, jobgrp: string, tag: string, otStart: string, otEnd: string): Promise<string>;
  Jobreport_Edit(idx: number, pdate: string, projectName: string, pidx: number, requestpart: string, package_: string, type: string, process: string, status: string, description: string, hrs: number, ot: number, jobgrp: string, tag: string, otStart: string, otEnd: string): Promise<string>;
  Jobreport_Delete(id: number): Promise<string>;
  Jobreport_GetPermission(targetUserId: string): Promise<string>;
  Jobreport_GetLastByProject(pidx: number, projectName: string): Promise<string>;
  Jobreport_GetJobTypes(process: string): Promise<string>;

  // App Info API
  GetAppVersion(): Promise<string>;

  // Login API
  CheckLoginStatus(): Promise<string>;
  Login(gcode: string, id: string, password: string, rememberMe: boolean): Promise<string>;
  Logout(): Promise<string>;
  GetUserGroups(): Promise<string>;
  GetPreviousLoginInfo(): Promise<string>;

  // User API
  GetCurrentUserInfo(): Promise<string>;
  GetUserInfoById(userId: string): Promise<string>;
  SaveUserInfo(jsonData: string): Promise<string>;
  ChangePassword(oldPassword: string, newPassword: string): Promise<string>;

  // Common Code API
  Common_GetGroups(): Promise<string>;
  Common_GetList(grp: string): Promise<string>;
  Common_Save(idx: number, grp: string, code: string, svalue: string, ivalue: number, fvalue: number, svalue2: string, memo: string): Promise<string>;
  Common_Delete(idx: number): Promise<string>;

  // Items API
  Items_GetCategories(): Promise<string>;
  Items_GetList(category: string, searchKey: string): Promise<string>;
  Items_Save(idx: number, sid: string, cate: string, name: string, model: string, scale: string, unit: string, price: number, supply: string, manu: string, storage: string, disable: boolean, memo: string): Promise<string>;
  Items_Delete(idx: number): Promise<string>;
  Items_GetImage(idx: number): Promise<string>;
  Items_SaveImage(idx: number, base64Image: string): Promise<string>;
  Items_DeleteImage(idx: number): Promise<string>;
  Items_GetDetail(idx: number): Promise<string>;
  Items_GetSupplierStaff(supplyIdx: number): Promise<string>;
  Items_GetIncomingHistory(itemIdx: number): Promise<string>;
  Items_GetOrderHistory(itemIdx: number): Promise<string>;

  // UserList API
  UserList_GetCurrentLevel(): Promise<string>;
  UserList_GetList(process: string): Promise<string>;
  UserList_GetUser(userId: string): Promise<string>;
  UserList_SaveGroupUser(userId: string, dept: string, level: number, useUserState: boolean, useJobReport: boolean, exceptHoly: boolean): Promise<string>;
  UserList_SaveUserFull(jsonData: string): Promise<string>;
  UserList_DeleteGroupUser(userId: string): Promise<string>;

  // Holiday API (월별근무표)
  Holiday_GetList(month: string): Promise<string>;
  Holiday_Save(month: string, holidaysJson: string): Promise<string>;
  Holiday_Initialize(month: string): Promise<string>;

  // MailForm API (메일양식)
  MailForm_GetList(): Promise<string>;
  MailForm_GetDetail(idx: number): Promise<string>;
  MailForm_Add(cate: string, title: string, tolist: string, bcc: string, cc: string, subject: string, tail: string, body: string, selfTo: boolean, selfCC: boolean, selfBCC: boolean, exceptmail: string, exceptmailcc: string): Promise<string>;
  MailForm_Edit(idx: number, cate: string, title: string, tolist: string, bcc: string, cc: string, subject: string, tail: string, body: string, selfTo: boolean, selfCC: boolean, selfBCC: boolean, exceptmail: string, exceptmailcc: string): Promise<string>;
  MailForm_Delete(idx: number): Promise<string>;

  // UserGroup API (그룹정보/권한설정)
  UserGroup_GetList(): Promise<string>;
  UserGroup_Add(dept: string, path_kj: string, permission: number, advpurchase: boolean, advkisul: boolean, managerinfo: string, devinfo: string, usemail: boolean): Promise<string>;
  UserGroup_Edit(originalDept: string, dept: string, path_kj: string, permission: number, advpurchase: boolean, advkisul: boolean, managerinfo: string, devinfo: string, usemail: boolean): Promise<string>;
  UserGroup_Delete(dept: string): Promise<string>;
  UserGroup_GetPermissionInfo(): Promise<string>;

  // UserAuth API (사용자 권한)
  UserAuth_CanAccess(): Promise<string>;
  UserAuth_GetList(): Promise<string>;
  UserAuth_Save(idx: number, user: string, account: number, purchase: number, purchaseEB: number, holyday: number, project: number, jobreport: number, scheapp: number, equipment: number, otconfirm: number, holyreq: number, kuntae: number): Promise<string>;
  UserAuth_Delete(idx: number): Promise<string>;
  UserAuth_GetFields(): Promise<string>;

  // 범용 권한 체크 API
  CheckAuth(authType: string, requiredLevel: number): Promise<string>;
  GetMyAuth(): Promise<string>;

  // 프로젝트 검색 API (업무일지용)
  Project_Search(keyword: string): Promise<string>;
  Project_GetUserProjects(): Promise<string>;

  // 프로젝트 목록 API
  Project_GetCategories(): Promise<string>;
  Project_GetProcesses(): Promise<string>;
  Project_GetList(statusFilter: string, category: string, process: string, userFilter: string, yearStart: string, yearEnd: string, dateType: string): Promise<string>;
  Project_GetHistory(projectIdx: number): Promise<string>;
  Project_SaveHistory(idx: number, pidx: number, pdate: string, progress: number, remark: string): Promise<string>;
  Project_GetDailyMemo(projectIdx: number): Promise<string>;

  // Note API (메모장)
  Note_GetList(startDate: string, endDate: string, uid: string): Promise<string>;
  Note_GetDetail(idx: number): Promise<string>;
  Note_Add(pdate: string, title: string, uid: string, description: string, description2: string, share: boolean, guid: string): Promise<string>;
  Note_Edit(idx: number, pdate: string, title: string, uid: string, description: string, description2: string, share: boolean, guid: string): Promise<string>;
  Note_Delete(idx: number): Promise<string>;

  // Board API (게시판 - 패치내역 등)
  Board_GetList(bidx: number, searchKey: string): Promise<string>;
  Board_GetDetail(idx: number): Promise<string>;
  Board_Add(bidx: number, header: string, cate: string, title: string, contents: string): Promise<string>;
  Board_Edit(idx: number, header: string, cate: string, title: string, contents: string): Promise<string>;
  Board_Delete(idx: number): Promise<string>;
  Board_GetReplies(rootIdx: number): Promise<string>;
  Board_AddReply(rootIdx: number, pidx: number, title: string, contents: string, isComment: boolean): Promise<string>;

  // Mail API (메일 발신 내역)
  Mail_GetList(startDate: string, endDate: string, searchKey: string): Promise<string>;
  Mail_AddData(cate: string, subject: string, fromlist: string, tolist: string, cc: string, bcc: string, body: string): Promise<string>;
  Mail_SendDirect(cate: string, subject: string, fromlist: string, tolist: string, cc: string, bcc: string, body: string): Promise<string>;
  Mail_SendOutlook(subject: string, tolist: string, cc: string, bcc: string, body: string): Promise<string>;

  // Customs API (업체정보)
  Customs_GetList(searchKey: string): Promise<string>;
  Customs_GetDetail(idx: number): Promise<string>;

  // License API (라이선스 관리)
  License_GetList(): Promise<string>;
  License_Add(name: string, version: string, meterialNo: string, supply: string, qty: number, uids: string, serialNo: string, remark: string, sdate: string, edate: string, manu: string, expire: boolean): Promise<string>;
  License_Update(idx: number, name: string, version: string, meterialNo: string, supply: string, qty: number, uids: string, serialNo: string, remark: string, sdate: string, edate: string, manu: string, expire: boolean): Promise<string>;
  License_Delete(idx: number): Promise<string>;
  License_OpenFolder(idx: number): Promise<string>;
  License_ExportCSV(filePath: string): Promise<string>;

  // PartList API (파트리스트)
  PartList_GetList(projectIdx: number): Promise<string>;
  PartList_Save(idx: number, projectIdx: number, itemgroup: string, itemname: string, item: string, itemmodel: string, itemscale: string, itemunit: string, qty: number, price: number, itemsupply: string, itemsupplyidx: number, itemmanu: string, itemsid: string, option1: string, remark: string, no: number, qtybuy: number): Promise<string>;
  PartList_Delete(idx: number): Promise<string>;

  // HolidayRequest API (휴가/외출 신청)
  HolidayRequest_GetList(startDate: string, endDate: string, userId: string, userLevel: number): Promise<string>;
  HolidayRequest_Save(idx: number, uid: string, cate: string, sdate: string, edate: string, remark: string, response: string, conf: number, holyReason: string, holyBackup: string, holyLocation: string, holyDays: number, holyTimes: number, stime: string, etime: string): Promise<string>;

  // Settings API
  GetSettings(): Promise<string>;
  SaveSettings(jsonSettings: string): Promise<string>;
}

// 사용자 권한 정보 타입
export interface UserLevelInfo {
  Level: number;
  CurrentUserId: string;
  CanEdit: boolean;
}

// 업무일지 권한 정보 타입
export interface JobReportPermission {
  Success: boolean;
  CurrentUserId: string;
  Level: number;
  CanViewOT: boolean;
}

// 업무형태 타입 (Common 테이블, grp='15')
export interface JobTypeItem {
  idx: number;
  code: string;
  type: string;      // memo - 업무형태
  jobgrp: string;    // svalue - 업무분류
  process: string;   // svalue2 - 공정
}

// 앱 버전 정보 타입
export interface AppVersionInfo {
  Success: boolean;
  ProductName: string;
  ProductVersion: string;
  DisplayVersion: string;
  MaxVersion?: string;
  HasNewVersion?: boolean;
}

// 사용자 전체 정보 저장용 타입
export interface UserFullData {
  id: string;
  name: string;
  nameE: string;
  grade: string;
  email: string;
  tel: string;
  hp: string;
  indate: string;
  outdate: string;
  memo: string;
  processs: string;
  state: string;
  level: number;
  useUserState: boolean;
  useJobReport: boolean;
  exceptHoly: boolean;
}

// 월별근무표 항목 타입
export interface HolidayItem {
  idx: number;
  pdate: string;
  free: boolean;
  memo: string;
  wuid?: string;
  wdate?: string;
}

// 메모장 관련 타입 (EETGW_Note 테이블)
export interface NoteItem {
  idx: number;
  gcode: string;
  pdate: string;           // 날짜
  title: string;           // 제목
  uid: string;             // 작성자 ID
  description: string;     // 내용 (plain text)
  description2: string;    // 내용 (RTF format - not used in web)
  share: boolean;          // 공유 여부
  wuid: string;            // 등록자 ID
  wdate: string;           // 등록일
  guid: string;            // 폴더 GUID
  viewcount?: number;      // 조회수
  viewdate?: string;       // 최종 조회일
}

// 메일양식 항목 타입
export interface MailFormItem {
  idx: number;
  gcode: string;
  cate: string;
  title: string;
  tolist: string;
  bcc: string;
  cc: string;
  subject: string;
  tail: string;
  body: string;
  selfTo: boolean;
  selfCC: boolean;
  selfBCC: boolean;
  wuid: string;
  wdate: string;
  exceptmail: string;
  exceptmailcc: string;
}

// 그룹정보 타입
export interface UserGroupItem {
  dept: string;
  gcode: string;
  path_kj: string;
  permission: number;
  advpurchase: boolean;
  advkisul: boolean;
  managerinfo: string;
  devinfo: string;
  usemail: boolean;
}

// 권한 정보 타입
export interface PermissionInfo {
  index: number;
  name: string;
  label: string;
  description: string;
}

// 사용자 권한 항목 타입 (Auth 테이블)
export interface AuthItem {
  idx: number;
  user: string;
  gcode?: string;
  account: number;
  purchase: number;
  purchaseEB: number;
  holyday: number;
  project: number;
  jobreport: number;
  scheapp: number;
  equipment: number;
  otconfirm: number;
  holyreq: number;
  kuntae: number;
}

// 사용자 권한 필드 정보
export interface AuthFieldInfo {
  field: string;
  label: string;
  description: string;
}

// 범용 권한 체크 응답 타입
export interface CheckAuthResponse {
  Success: boolean;
  CanAccess?: boolean;
  UserLevel?: number;
  AuthLevel?: number;
  EffectiveLevel?: number;
  RequiredLevel?: number;
  AuthType?: string;
  Message?: string;
}

// 내 권한 정보 응답 타입
export interface MyAuthInfo {
  UserLevel: number;
  account: number;
  purchase: number;
  purchaseEB: number;
  holyday: number;
  project: number;
  jobreport: number;
  scheapp: number;
  equipment: number;
  otconfirm: number;
  holyreq: number;
  kuntae: number;
}

// 권한 타입 (FCOMMON DBM.eAuthType과 일치)
export type AuthType = 'purchase' | 'holyday' | 'project' | 'jobreport' | 'savecost' | 'equipment' | 'otconfirm' | 'kuntae' | 'holyreq' | 'account' | 'purchaseEB' | 'scheapp';

// 프로젝트 검색 결과 항목 타입
export interface ProjectSearchItem {
  idx: number;
  name: string;
  userManager: string;
  userMain: string;
  status: string;
  source: 'project' | 'jobreport';
  lastDate?: string;
}

// 근태 오류검사 결과 항목 타입
export interface KuntaeErrorCheckResult {
  Date: string;
  Gubun: string;
  OccurDay: string;
  OccurTime: string;
  UseDay: string;
  UseTime: string;
  CateError: string;
  IsError: boolean;
  IsMagam: boolean;
}

// 근태 오류검사 응답 타입
export interface KuntaeErrorCheckResponse {
  Success: boolean;
  Message?: string;
  OkList?: KuntaeErrorCheckResult[];
  NgList?: KuntaeErrorCheckResult[];
}

// 근태 오류수정 결과 타입
export interface KuntaeFixErrorResult {
  Date: string;
  Success: boolean;
  Message: string;
}

// 즐겨찾기 아이템 타입
export interface FavoriteItem {
  name: string;
  url: string;
}

// 프로젝트 목록 아이템 타입
export interface ProjectListItem {
  idx: number;
  pidx?: number;
  status: string;
  asset?: string;
  level?: number;
  rev?: number;
  process?: string;
  part?: string;
  pdate?: string;
  name: string;
  userManager?: string;
  usermain?: string;
  usersub?: string;
  userhw2?: string;
  reqstaff?: string;
  costo?: number;
  costn?: number;
  cnt?: number;
  remark_req?: string;
  remark_ans?: string;
  sdate?: string;
  ddate?: string;
  edate?: string;
  odate?: string;
  progress?: number;
  bmajoritem?: boolean;
  memo?: string;
  wuid?: number;
  wdate?: string;
  orderno?: string;
  crdue?: string;
  import?: string;
  path?: string;
  userprocess?: string;
  bCost?: boolean;
  bFanOut?: boolean;
  bHighlight?: boolean;
  div?: string;
  model?: string;
  serial?: string;
  championid?: number;
  designid?: number;
  epanelid?: number;
  softwareid?: number;
  effect_tangible?: string;
  effect_intangible?: string;
  name_champion?: string;
  name_design?: string;
  name_epanel?: string;
  name_software?: string;
  category?: string;
  ReqLine?: string;
  ReqSite?: string;
  ReqPackage?: string;
  ReqPlant?: string;
  pno?: number;
  kdate?: string;
  jasmin?: number;
  sfi?: string;
  lasthistory_date?: string;
  lastSchNo?: number;
  cramount?: number;
  panelimage?: string;
  Priority?: number;
  sfi_count?: number;
  ProgressPrj?: number;
  finishrate?: number;
}

// 프로젝트 목록 응답 타입
export interface ProjectListResponse {
  Success: boolean;
  Message?: string;
  Data?: ProjectListItem[];
  StatusCounts?: {
    검토: number;
    진행: number;
    대기: number;
    보류: number;
    완료: number;
    '완료(보고)': number;
    취소: number;
  };
  TotalCosto?: number;
  TotalCostn?: number;
  CurrentUser?: string;
}

// 설정(Settings.cs) 관련 타입
export interface SettingsModel {
  Disable8HourOver: boolean;
  startForm: number; // enum (0:없음, 1:NR구매, 2:프로젝트, 3:업무일지, 4:재고, 5:재고현황, 6:근태, 7:품목)
  DupWindow: boolean;
  Language: string;
  FullScreen: boolean;
  Showbuyerror: boolean;
  NotShowJobreportPRewView: boolean;
  Barcode: string;
  CamIndex: number;
  HideToolbar: number; // enum (0:Left, 1:Right, 2:Top, 3:Bottom, 4:Hide)
  Theme: string;
}

export interface SettingsResponse {
  Success: boolean;
  Message?: string;
  Data?: SettingsModel;
}

// 프로젝트 히스토리 타입
export interface ProjectHistory {
  idx: number;
  pidx: number;
  pdate: string;
  progress?: number;
  remark?: string;
  wuid?: number;
  wdate?: string;
  wname?: string;
}

// 프로젝트 일일 메모 타입
export interface ProjectDailyMemo {
  idx: number;
  pidx: number;
  pdate: string;
  remark?: string;
  wuid?: number;
  wdate?: string;
  wname?: string;
}

// 일별 업무일지 집계 타입
export interface JobReportDayItem {
  uid: string;
  uname: string;
  pdate: string;
  hrs: number;
  ot: number;
  processs: string;
  jobtype: string;
}

// 업무형태별 집계 타입
export interface JobReportTypeItem {
  type: string;
  hrs: number;
  ot: number;
  count: number;
}

// 휴가/외출 신청 타입
export interface HolidayRequest {
  idx: number;
  gcode: string;
  uid: string;
  cate: string;
  sdate: string;
  edate: string;
  Remark?: string;
  wuid?: string;
  wdate?: string;
  dept?: string;
  name?: string;
  grade?: string;
  tel?: string;
  processs?: string;
  Response?: string;
  conf: number;
  HolyReason?: string;
  HolyBackup?: string;
  HolyLocation?: string;
  HolyDays?: number;
  HolyTimes?: number;
  sendmail?: boolean;
  stime?: string;
  etime?: string;
  conf_id?: string;
  conf_time?: string;
}

// 휴가/외출 신청 합계 타입
export interface HolidayRequestSummary {
  ApprovedDays: number;
  ApprovedTimes: number;
  PendingDays: number;
  PendingTimes: number;
}

export interface JobReportDayData {
  items: JobReportDayItem[];
  holidays: HolidayItem[];
}

// Board 게시판 타입 (패치내역 등)
export interface BoardItem {
  idx: number;
  bidx: number;
  header: string;
  cate: string;
  title: string;
  contents: string;
  file: string;
  guid: string;
  url: string;
  wuid: string;
  wdate: string | null;
  project: string;
  pidx: number;
  gcode: string;
  close: boolean;
  remark: string;
  wuid_name: string;
  root_idx?: number | null;
  depth?: number;
  sort_order?: number;
  thread_path?: string;
  is_comment?: boolean;
  reply_count?: number;
}

// Mail 발신 내역 타입
export interface MailItem {
  idx: number;
  gcode: string;
  uid: string;
  subject: string;
  htmlbody: string;
  fromlist: string;
  tolist: string;
  cclist: string;
  bcclist: string;
  project: string;
  cate: string;
  wdate: string | null;
}

// 업체정보 타입
export interface CustomItem {
  idx: number;
  grp: string;
  name: string;
  owner: string;
  ownertel: string;
  address: string;
  tel: string;
  fax: string;
  email: string;
  memo: string;
  wuid: string;
  wdate: string;
  uptae: string;
  staff: string;
  stafftel: string;
  name2: string;
  gcode: string;
}

// 라이선스 타입
export interface LicenseItem {
  idx?: number;
  gcode?: string;
  expire?: boolean;
  name?: string;
  version?: string;
  meterialNo?: string;
  supply?: string;
  qty?: number;
  uids?: string;
  serialNo?: string;
  remark?: string;
  sdate?: string;
  edate?: string;
  manu?: string;
  wuid?: string;
  wdate?: string;
}

// 파트리스트 타입 (ProjectsPart 테이블)
export interface PartListItem {
  idx: number;
  Project: number;
  itemgroup?: string;
  itemname: string;
  item: string;          // 자재번호
  itemmodel?: string;
  itemscale?: string;
  itemunit?: string;
  qty?: number;
  price?: number;
  amt?: number;          // 계산된 금액 (qty * price)
  itemsupply?: string;
  itemsupplyidx?: number;
  itemmanu?: string;
  itemsid?: string;
  option1?: string;
  remark?: string;
  no?: number;
  qtybuy?: number;
  wuid?: string;
  wdate?: string;
}
