// Questo file fa parte di MyTown.
// MyTown è software libero: puoi ridistribuirlo e/o modificarlo secondo
// i termini della GNU Affero General Public License come pubblicata dalla
// Free Software Foundation, versione 3.
// Distribuito senza ALCUNA GARANZIA; vedi la GNU AGPL v3 per i dettagli.
// Copyright (C) Kondor Consulting & Services S.r.l.
// SPDX-License-Identifier: AGPL-3.0-or-later

export interface BookingResourceType {
	bkrt_id: number;
	bkrt_cmp_id: number;
	bkrt_name: string;
	bkrt_type: 'RESTAURANT' | 'BEACH' | 'GENERIC';
	bkrt_description: string;
	bkrt_is_active: boolean;
	bkrt_date_from?: string;
	bkrt_date_to?: string;
}

export interface BookingResourceSlotOverride {
	bkrso_id: number;
	bkrso_cmp_id: number;
	bkrso_resource_id: number;
	bkrso_date: string;                  // YYYY-MM-DD
	bkrso_slot_id: number;
	bkrso_disabled: boolean;
	bkrso_override_x?: number | null;    // % di REF_WIDTH (null = nessun override)
	bkrso_override_y?: number | null;    // % di REF_HEIGHT
	bkrso_reason?: string | null;
	bkrso_created_by?: number | null;
	bkrso_created_at?: string;
	bkrso_updated_at?: string;
}

export interface BookingResource {
	bkr_id: number;
	bkr_cmp_id: number;
	bkr_type_id: number;
	bkr_name: string;
	bkr_code: string;
	bkr_capacity: number;
	bkr_position: string;
	bkr_is_active: boolean;
	bkr_is_combinable?: boolean;
	bkr_notes: string;
	bkrt_name?: string;
	bkrt_type?: string;
}

export interface BookingResourceAssignment {
	bkra_id: number;
	bkra_booking_id: number;
	bkra_resource_id: number;
	bkr_name?: string;
	bkr_capacity?: number;
}

export interface BookingTimeSlot {
	bkts_id: number;
	bkts_cmp_id: number;
	bkts_type_id: number;
	bkts_name: string;
	bkts_start_time: string;
	bkts_end_time: string;
	bkts_is_active: boolean;
	bkts_days_of_week: string;
}

export interface BookingMenuCategory {
	bkmc_id: number;
	bkmc_cmp_id: number;
	bkmc_type_id: number;
	bkmc_name: string;
	bkmc_sort_order: number;
	bkmc_is_active: boolean;
}

export interface BookingMenuItem {
	bkmi_id: number;
	bkmi_cmp_id: number;
	bkmi_category_id: number;
	bkmi_name: string;
	bkmi_description: string;
	bkmi_price: number;
	bkmi_is_active: boolean;
	bkmi_sort_order: number;
	bkmi_allergens: string;
	bkmi_image_url: string;
	bkmc_name?: string;
	selectedQuantity?: number;
}

export interface Booking {
	bkb_id: number;
	bkb_cmp_id: number;
	bkb_resource_id: number | null;
	bkb_time_slot_id: number | null;
	bkb_date: string;
	bkb_date_to?: string;
	bkb_start_time: string;
	bkb_end_time: string;
	bkb_guests_count: number;
	bkb_lettini?: number;
	bkb_sedie?: number;
	bkb_sdraio?: number;
	bkb_customer_name: string;
	bkb_customer_phone: string;
	bkb_customer_email: string;
	bkb_status: 'PENDING' | 'CONFIRMED' | 'COMPLETED' | 'CANCELLED';
	bkb_payment_status: 'UNPAID' | 'PAID';
	bkb_total_amount: number;
	bkb_paid_amount: number;
	bkb_notes: string;
	bkb_internal_notes: string;
	bkb_user_id?: number | null;
	bkb_resource_alias?: string | null;
	bkb_created_by: number;
	bkb_created_at: string;
	bkb_updated_at: string;
	bkr_name?: string;
	bkrt_type?: string;
	bkts_name?: string;
	bkb_resource_ids?: number[];
	totalrows?: number;
}

export interface BookingItem {
	bkbi_id: number;
	bkbi_booking_id: number;
	bkbi_menu_item_id: number;
	bkbi_quantity: number;
	bkbi_unit_price: number;
	bkbi_total_price: number;
	bkbi_notes: string;
	bkbi_send_seq?: number;
	bkbi_created_at?: string;
	bkmi_name?: string;
	bkmc_name?: string;
	// join fields (lista operativa ordini)
	bkr_name?: string;
	bkb_customer_name?: string;
	/** Popolato lato client tramite mapping booking_id → bkrt_type */
	bkrt_type?: string;
	totalrows?: number;
}

export interface BookingPayment {
	bkp_id: number;
	bkp_booking_id: number;
	bkp_amount: number;
	bkp_method: 'CASH' | 'CARD' | 'TRANSFER' | 'OTHER';
	bkp_type: 'BOOKING' | 'ORDER';
	bkp_date: string;
	bkp_notes: string;
	bkp_created_at: string;
}

export interface BookingBeachPricing {
	bbp_id: number;
	bbp_cmp_id: number;
	bbp_type_id: number;
	bbp_element: 'OMBRELLONE' | 'SEDIA' | 'SDRAIO' | 'LETTINO' | 'PALMA';
	bbp_period_name: string;
	bbp_date_from: string | number[];
	bbp_date_to: string | number[];
	bbp_daily_cost: number;
	bbp_hourly_cost: number;
	bbp_weekly_cost: number;
	bbp_monthly_cost: number;
	bbp_seasonal_cost: number;
	bbp_fila: number | null;
	bbp_is_active: boolean;
}

export interface BookingFilter {
	dateFrom: string;
	dateTo: string;
	status: string;
	type_id: number;
}

export interface BookingMenuPreset {
	bkmp_id: number;
	bkmp_cmp_id: number;
	bkmp_name: string;
	bkmp_description: string;
	bkmp_category_ids?: number[];
	bkmp_item_ids?: number[];
}

export interface BookingMenuPresetSchedule {
	bkmps_id: number;
	bkmps_cmp_id: number;
	bkmps_preset_id: number;
	bkmps_date: string;
	bkmp_name?: string;
}
