package model

// Product contains each and every column from the table ps_product.
type Product struct {
	ProductID              uint    `gorm:"column:id_product;primaryKey" json:"product_id" form:"product_id"`
	SupplierID             uint    `gorm:"column:id_supplier" json:"supplier_id" form:"supplier_id"`
	ManufacturerID         uint    `gorm:"column:id_manufacturer" json:"manufacturer_id" form:"manufacturer_id"`
	CategoryDefaultID      uint    `gorm:"column:id_category_default" json:"category_default_id" form:"category_default_id"`
	ShopDefaultID          uint    `gorm:"column:id_shop_default" json:"shop_default_id" form:"shop_default_id"`
	TaxRulesGroupID        uint    `gorm:"column:id_tax_rules_group" json:"tax_rules_group_id" form:"tax_rules_group_id"`
	OnSale                 uint    `gorm:"column:on_sale" json:"on_sale" form:"on_sale"`
	OnlineOnly             uint    `gorm:"column:online_only" json:"online_only" form:"online_only"`
	EAN13                  string  `gorm:"column:ean13;type:varchar(13)" json:"ean13" form:"ean13"`
	ISBN                   string  `gorm:"column:isbn;type:varchar(32)" json:"isbn" form:"isbn"`
	UPC                    string  `gorm:"column:upc;type:varchar(12)" json:"upc" form:"upc"`
	EkoTax                 float32 `gorm:"column:eko_tax;type:decimal(20,6)" json:"eko_tax" form:"eko_tax"`
	Quantity               uint    `gorm:"column:quantity" json:"quantity" form:"quantity"`
	MinimalQuantity        uint    `gorm:"column:minimal_quantity" json:"minimal_quantity" form:"minimal_quantity"`
	LowStockThreshold      uint    `gorm:"column:low_stock_threshold" json:"low_stock_threshold" form:"low_stock_threshold"`
	LowStockAlert          uint    `gorm:"column:low_stock_alert" json:"low_stock_alert" form:"low_stock_alert"`
	Price                  float32 `gorm:"column:price;type:decimal(20,6)" json:"price" form:"price"`
	WholesalePrice         float32 `gorm:"column:wholesale_price;type:decimal(20,6)" json:"wholesale_price" form:"wholesale_price"`
	Unity                  string  `gorm:"column:unity;type:varchar(255)" json:"unity" form:"unity"`
	UnitPriceRatio         float32 `gorm:"column:unit_price_ratio;type:decimal(20,6)" json:"unit_price_ratio" form:"unit_price_ratio"`
	UnitID                 uint    `gorm:"column:id_unit;primaryKey" json:"unit_id" form:"unit_id"`
	AdditionalShippingCost float32 `gorm:"column:additional_shipping_cost;type:decimal(20,2)" json:"additional_shipping_cost" form:"additional_shipping_cost"`
	Reference              string  `gorm:"column:reference;type:varchar(64)" json:"reference" form:"reference"`
	SupplierReference      string  `gorm:"column:supplier_reference;type:varchar(64)" json:"supplier_reference" form:"supplier_reference"`
	Location               string  `gorm:"column:location;type:varchar(64)" json:"location" form:"location"`

	Width                   float32 `gorm:"column:width;type:decimal(20,6)" json:"width" form:"width"`
	Height                  float32 `gorm:"column:height;type:decimal(20,6)" json:"height" form:"height"`
	Depth                   float32 `gorm:"column:depth;type:decimal(20,6)" json:"depth" form:"depth"`
	Weight                  float32 `gorm:"column:weight;type:decimal(20,6)" json:"weight" form:"weight"`
	OutOfStock              uint    `gorm:"column:out_of_stock" json:"out_of_stock" form:"out_of_stock"`
	AdditionalDeliveryTimes uint    `gorm:"column:additional_delivery_times" json:"additional_delivery_times" form:"additional_delivery_times"`
	QuantityDiscount        uint    `gorm:"column:quantity_discount" json:"quantity_discount" form:"quantity_discount"`
	Customizable            uint    `gorm:"column:customizable" json:"customizable" form:"customizable"`
	UploadableFiles         uint    `gorm:"column:uploadable_files" json:"uploadable_files" form:"uploadable_files"`
	TextFields              uint    `gorm:"column:text_fields" json:"text_fields" form:"text_fields"`

	Active            uint   `gorm:"column:active" json:"active" form:"active"`
	RedirectType      string `gorm:"column:redirect_type;type:enum('','404','301-product','302-product','301-category','302-category')" json:"redirect_type" form:"redirect_type"`
	TypeRedirectedID  int    `gorm:"column:id_type_redirected" json:"type_redirected_id" form:"type_redirected_id"`
	AvailableForOrder uint   `gorm:"column:available_for_order" json:"available_for_order" form:"available_for_order"`
	AvailableDate     string `gorm:"column:available_date;type:date" json:"available_date" form:"available_date"`
	ShowCondition     uint   `gorm:"column:show_condition" json:"show_condition" form:"show_condition"`
	Condition         string `gorm:"column:condition;type:enum('new','used','refurbished')" json:"condition" form:"condition"`
	ShowPrice         uint   `gorm:"column:show_price" json:"show_price" form:"show_price"`

	Indexed                 uint   `gorm:"column:indexed" json:"indexed" form:"indexed"`
	Visibility              string `gorm:"column:visibility;type:enum('both','catalog','search','none')" json:"visibility" form:"visibility"`
	CacheIsPack             uint   `gorm:"column:cache_is_pack" json:"cache_is_pack" form:"cache_is_pack"`
	CacheHasAttachments     uint   `gorm:"column:cache_has_attachments" json:"cache_has_attachments" form:"cache_has_attachments"`
	IsVirtual               uint   `gorm:"column:is_virtual" json:"is_virtual" form:"is_virtual"`
	CacheDefaultAttribute   uint   `gorm:"column:cache_default_attribute" json:"cache_default_attribute" form:"cache_default_attribute"`
	DateAdd                 string `gorm:"column:date_add;type:datetime" json:"date_add" form:"date_add"`
	DateUpd                 string `gorm:"column:date_upd;type:datetime" json:"date_upd" form:"date_upd"`
	AdvancedStockManagement uint   `gorm:"column:advanced_stock_management" json:"advanced_stock_management" form:"advanced_stock_management"`
	PackStockType           uint   `gorm:"column:pack_stock_type" json:"pack_stock_type" form:"pack_stock_type"`
	State                   uint   `gorm:"column:state" json:"state" form:"state"`
	DeliveryDays            uint   `gorm:"column:delivery_days" json:"delivery_days" form:"delivery_days"`
}
type ProductInList struct {
	ProductID      uint   `gorm:"column:product_id" json:"product_id" form:"product_id"`
	Name           string `gorm:"column:name" json:"name" form:"name"`
	LinkRewrite    string `gorm:"column:link_rewrite" json:"link_rewrite"`
	ImageLink      string `gorm:"column:image_link" json:"image_link"`
	CategoryName   string `gorm:"column:category_name" json:"category_name" form:"category_name"`
	Reference      string `gorm:"column:reference" json:"reference"`
	VariantsNumber uint   `gorm:"column:variants_number" json:"variants_number"`
	Quantity       int64  `gorm:"column:quantity" json:"quantity"`
}

type ProductFilters struct {
	Sort         string  `json:"sort,omitempty" query:"sort,omitempty" example:"price,asc;name,desc"` // sort rule
	ProductID    uint    `json:"product_id,omitempty" query:"product_id,omitempty" example:"1"`
	Price        float64 `json:"price,omitempty" query:"price,omitempty" example:"123.45"`
	Name         string  `json:"name,omitempty" query:"name,omitempty" example:"Sztabka Złota Britannia"`
	CategoryID   uint    `json:"category_id,omitempty" query:"category_id,omitempty" example:"2"`
	CategoryName string  `json:"category_name,omitempty" query:"category_name,omitempty" example:"Złote Monety"`
	Features     FeatVal `query:"features,omitempty"`
	ActiveSale   bool    `query:"sale_active,omitempty"`
	InStock      uint    `query:"stock,omitempty"`
}

type ScannedCategory struct {
	CategoryID  uint   `gorm:"column:category_id;primaryKey"`
	Name        string `gorm:"column:name"`
	Active      uint   `gorm:"column:active"`
	Position    uint   `gorm:"column:position"`
	ParentID    uint   `gorm:"column:id_parent"`
	IsRoot      uint   `gorm:"column:is_root_category"`
	LinkRewrite string `gorm:"column:link_rewrite"`
	IsoCode     string `gorm:"column:iso_code"`
}
type Category struct {
	CategoryID uint   `json:"category_id" form:"category_id"`
	Label      string `json:"label" form:"label"`
	// Active     bool           `json:"active" form:"active"`
	Params   CategpryParams `json:"params" form:"params"`
	Children []Category     `json:"children" form:"children"`
}

type CategpryParams struct {
	CategoryID  uint   `json:"category_id" form:"category_id"`
	LinkRewrite string `json:"link_rewrite" form:"link_rewrite"`
	Locale      string `json:"locale" form:"locale"`
}

type FeatVal = map[uint][]uint
