-- https://www.phpmyadmin.net/
--
-- Hôte : db
-- Généré le :  sam. 26 jan. 2019 à 13:19
-- Version du serveur :  5.7.22
-- Version de PHP :  7.2.4

START TRANSACTION;




--
-- Structure de la table `produit`
--

CREATE TABLE `ca_produit` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`libelle` VARCHAR(500) NOT NULL,
	`ligne1` VARCHAR(100) NOT NULL,
	`ligne2` VARCHAR(100),
	`prix` DECIMAL(10,2) NOT NULL,
	`ordre` INT(5) NOT NULL,
	`active` TINYINT(1) NOT NULL,
    `created_at` datetime NOT NULL,
    `updated_at` datetime NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `ca_produit` (`id`, `libelle`, `ligne1`, `ligne2`, `ordre`, `active`, `created_at`, `updated_at`) VALUES
(1, 'Produit 1', 'Prod', '#1', 1, 1, '2019-01-30 18:00:00', '2019-01-30 18:00:00'),
(2, 'Produit 2', 'Prod', '#2', 1, 1, '2019-01-30 18:00:00', '2019-01-30 18:00:00');





--
-- Structure de la table `caisse_produit`
--

CREATE TABLE `ca_caisse_produit` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`idCaisse` INT(10) NOT NULL,
	`idProduit` INT(10) NOT NULL,
    `created_at` datetime NOT NULL,
    `updated_at` datetime NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `ca_caisse_produit` (`id`, `idCaisse`, `idProduit`, `created_at`, `updated_at`) VALUES
(1, 1, 1, '2019-01-30 18:00:00', '2019-01-30 18:00:00'),
(2, 1, 2, '2019-01-30 18:00:00', '2019-01-30 18:00:00'),
(3, 2, 1, '2019-01-30 18:00:00', '2019-01-30 18:00:00');


ALTER TABLE `ca_caisse_produit`
  ADD CONSTRAINT `fk_caisse_produit_caisse` FOREIGN KEY (`idCaisse`) REFERENCES `ca_caisse` (`id`);

ALTER TABLE `ca_caisse_produit`
  ADD CONSTRAINT `fk_caisse_produit_produit` FOREIGN KEY (`idProduit`) REFERENCES `ca_produit` (`id`);

--
-- Structure de la table `evenement`
--

CREATE TABLE `ca_evenement` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`nom` VARCHAR(500) NOT NULL,
	`dateDebut` date,
	`dateFin` date,
	`active` TINYINT(1) NOT NULL,
    `created_at` datetime NOT NULL,
    `updated_at` datetime NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `ca_evenement` (`id`, `nom`, `dateDebut`, `dateFin`, `active`, `created_at`, `updated_at`) VALUES
(1, 'Evenement 1', '2020-01-01', '2020-01-21', 1, '2019-01-30 18:00:00', '2019-01-30 18:00:00'),
(2, 'Evenement 2', '2020-06-15', '2020-06-30', 1, '2019-01-30 18:00:00', '2019-01-30 18:00:00');




--
-- Structure de la table `transactions`
--

CREATE TABLE `ca_transaction` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`idCaisse` INT(10) NOT NULL,
	`idEvenement` INT(10) NOT NULL,
    `montant` DECIMAL(10,2) NOT NULL,
    `reduction` DECIMAL(10,2) NOT NULL,
    `type` VARCHAR(100) NOT NULL,
    `paiement` VARCHAR(100) NOT NULL,
    `note` VARCHAR(100) NOT NULL,
    `created_at` datetime NOT NULL,
    `updated_at` datetime NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `ca_transaction` (`id`, `idCaisse`, `idEvenement`, `montant`, `reduction`, `type`, `paiement`, `note`, `created_at`, `updated_at`) VALUES
(1, 1, 1, 75, 5, 'surplace', 'espece', 'rien à déclarer', '2019-01-30 18:00:00', '2019-01-30 18:00:00');

ALTER TABLE `ca_transaction`
  ADD CONSTRAINT `fk_transaction_evenement` FOREIGN KEY (`idEvenement`) REFERENCES `ca_evenement` (`id`);
ALTER TABLE `ca_transaction`
  ADD CONSTRAINT `fk_transaction_caisse` FOREIGN KEY (`idCaisse`) REFERENCES `ca_caisse` (`id`);
--
-- Structure de la table `transactions`
--

CREATE TABLE `ca_transaction_produit` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`idTransaction` INT(10) NOT NULL,
	`produitId` INT(10) NOT NULL,
	`produitLibelle` VARCHAR(100) NOT NULL,
    `produitPrix` DECIMAL(10,2) NOT NULL,
    `quantite` INT(5),
    `bop` INT(5),
    `created_at` datetime NOT NULL,
    `updated_at` datetime NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `ca_transaction_produit` (`id`, `idTransaction`, `produitId`, `produitLibelle`, `produitPrix`, `quantite`, `bop`, `created_at`, `updated_at`) VALUES
(1, 1, 1, 'Smash fût', 50, 1, 0, '2019-01-30 18:00:00', '2019-01-30 18:00:00'),
(2, 1, 2, 'Smash 25cl', 3.50, 10, 0, '2019-01-30 18:00:00', '2019-01-30 18:00:00');




ALTER TABLE `ca_transaction_produit`
  ADD CONSTRAINT `fk_transaction_produit` FOREIGN KEY (`produitId`) REFERENCES `ca_produit` (`id`);
ALTER TABLE `ca_transaction_produit`
  ADD CONSTRAINT `fk_transaction` FOREIGN KEY (`idTransaction`) REFERENCES `ca_transaction` (`id`);


