CREATE TABLE IF NOT EXISTS oc_gestion_order_status(
	status_key VARCHAR(100) PRIMARY KEY NOT NULL,
	status_label VARCHAR(100) DEFAULT ''
);

INSERT INTO oc_gestion_order_status (status_key, status_label) 
VALUES 
    ('NEW', 'Nouveau'),
    ('ORDERED', 'Commandé'),
    ('CANCELED', 'Annulé');

CREATE TABLE IF NOT EXISTS oc_gestion_orders(
	id INT AUTO_INCREMENT  PRIMARY KEY,
	order_date DATE NOT NULL,
	order_number int NOT NULL,
	order_full_number VARCHAR(100) NOT NULL,
	order_comment VARCHAR(100) DEFAULT '',
	fk_defunt_id int,
	fk_lieu_id int,
	fk_client_id int,
	fk_thanato_id int,
	fk_order_status_key VARCHAR(100),
	fk_calendar_uuid VARCHAR(100),
	id_nextcloud VARCHAR(100)
);

CREATE TABLE IF NOT EXISTS oc_gestion_order_product(
	id INT AUTO_INCREMENT PRIMARY KEY,
	fk_order_id INT NOT NULL,
	fk_product_id INT NOT NULL,
	quantity INT NOT NULL,
	id_nextcloud VARCHAR(100)
);

CREATE TABLE IF NOT EXISTS oc_gestion_thanato_product_discount(
	id INT AUTO_INCREMENT PRIMARY KEY,
	fk_thanato_id INT NOT NULL,
	fk_product_id INT NOT NULL,
	ht_price INT NOT NULL,
	id_nextcloud VARCHAR(100)
);