Initial commit

This commit is contained in:
anthorob committed 2024-04-07 00:59:45 -04:00
1 parent ac59bcc9fa
commit 094972f4c0
262 files changed
+151168

No files matched your search

+891
View File
@@ -0,0 +1,891 @@
-- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Hôte : 127.0.0.1:3306
-- Généré le : lun. 03 déc. 2018 à 06:27
-- Version du serveur : 5.7.23
-- Version de PHP : 7.0.32
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de données : `dietetique_2`
--
DELIMITER $$
--
-- Procédures
--
DROP PROCEDURE IF EXISTS `updatelimiteproduit`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `updatelimiteproduit` (IN `p_id` INT, IN `p_limite` INT) begin
DECLARE done INT DEFAULT FALSE;
declare v_compte int;
declare v_quantite int;
declare c_panier cursor for select id_compte, quantite from panier where id_produit = p_id;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
open c_panier;
panier_loop: loop
fetch c_panier into v_compte, v_quantite;
IF done THEN
LEAVE panier_loop;
END IF;
if v_quantite > p_limite then
update panier set quantite = p_limite where id_compte = v_compte and id_produit = p_id;
end if;
end loop;
close c_panier;
end$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Structure de la table `access_token`
--
DROP TABLE IF EXISTS `access_token`;
CREATE TABLE IF NOT EXISTS `access_token` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_compte` int(11) NOT NULL,
`selector` char(16) COLLATE utf8_bin NOT NULL,
`token` char(64) COLLATE utf8_bin NOT NULL,
`expires` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Structure de la table `categorie`
--
DROP TABLE IF EXISTS `categorie`;
CREATE TABLE IF NOT EXISTS `categorie` (
`id_categorie` int(11) NOT NULL AUTO_INCREMENT,
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
`actif` tinyint(1) NOT NULL,
PRIMARY KEY (`id_categorie`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
--
-- Déchargement des données de la table `categorie`
--
INSERT INTO `categorie` (`id_categorie`, `nom`, `actif`) VALUES
(1, 'Fruits et Légumes', 0),
(2, 'Viandes', 1),
(3, 'Divers', 1);
-- --------------------------------------------------------
--
-- Structure de la table `commandes`
--
DROP TABLE IF EXISTS `commandes`;
CREATE TABLE IF NOT EXISTS `commandes` (
`id_commande` int(11) NOT NULL AUTO_INCREMENT,
`id_compte` int(11) NOT NULL,
`numero_commande` varchar(1024) COLLATE utf8_bin NOT NULL,
`date` datetime NOT NULL,
`status` char(1) COLLATE utf8_bin NOT NULL,
`prix_total` decimal(20,2) NOT NULL,
`trace_paiement` int(11) DEFAULT NULL,
PRIMARY KEY (`id_commande`,`id_compte`) USING BTREE,
KEY `Commandes_fk0` (`id_compte`),
KEY `Commandes_fk1` (`trace_paiement`),
KEY `id_commande` (`id_commande`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
--
-- Déchargement des données de la table `commandes`
--
INSERT INTO `commandes` (`id_commande`, `id_compte`, `numero_commande`, `date`, `status`, `prix_total`, `trace_paiement`) VALUES
(1, 16, 'DIET-5C00CA57366FE16', '2018-11-30 00:27:51', 'P', '22.00', NULL),
(2, 16, 'DIET-5C01425ACB7D916', '2018-11-30 08:59:54', 'P', '1427.90', NULL),
(3, 16, 'DIET-5C0143005B99816', '2018-11-30 09:02:40', 'P', '1122.70', NULL),
(4, 16, 'DIET-5C01462249A4316', '2018-11-30 09:16:02', 'P', '1100.90', NULL),
(5, 16, 'DIET-5C01479668E0A16', '2018-11-30 09:22:14', 'P', '1177.20', NULL),
(6, 16, 'DIET-5C014883AC23116', '2018-11-30 09:26:11', 'P', '1188.10', NULL),
(7, 16, 'DIET-5C0148FD8C9F016', '2018-11-30 09:28:13', 'P', '1133.60', NULL),
(8, 16, 'DIET-5C01494F6AB0716', '2018-11-30 09:29:35', 'P', '1188.10', NULL),
(9, 17, 'DIET-5C014A355E62017', '2018-11-30 09:33:25', 'P', '1188.10', NULL),
(10, 17, 'DIET-5C018CE8EF62917', '2018-11-30 14:18:01', 'P', '1.00', NULL),
(11, 17, 'DIET-5C018DB059E0D17', '2018-11-30 14:21:20', 'P', '1111.80', NULL),
(12, 17, 'DIET-5C01912A7E64817', '2018-11-30 14:36:10', 'P', '1220.80', NULL),
(13, 16, 'DIET-5C04A95BA66BB16', '2018-12-02 22:56:11', 'P', '76.30', NULL),
(14, 16, 'DIET-5C04BDF39C17F16', '2018-12-03 00:24:03', 'P', '13.20', NULL),
(15, 16, 'DIET-5C04BE0E76AB116', '2018-12-03 00:24:30', 'P', '13.20', NULL),
(16, 16, 'DIET-5C04BE1E986B316', '2018-12-03 00:24:46', 'P', '13.20', NULL),
(17, 16, 'DIET-5C04BE85B985916', '2018-12-03 00:26:29', 'P', '16.20', NULL),
(18, 16, 'DIET-5C04C29C051A316', '2018-12-03 00:43:56', 'P', '14.00', NULL),
(19, 16, 'DIET-5C04C3107D75816', '2018-12-03 00:45:52', 'P', '14.00', NULL),
(20, 16, 'DIET-5C04C683903EC16', '2018-12-03 01:00:35', 'P', '113.00', NULL),
(21, 16, 'DIET-5C04C6BDC621916', '2018-12-03 01:01:33', 'P', '103.00', NULL),
(22, 16, 'DIET-5C04CB5F7C1A116', '2018-12-03 01:21:19', 'P', '1103.00', NULL),
(23, 16, 'DIET-5C04CC115926016', '2018-12-03 01:24:17', 'P', '66.00', NULL);
--
-- Déclencheurs `commandes`
--
DROP TRIGGER IF EXISTS `tai_commandes`;
DELIMITER $$
CREATE TRIGGER `tai_commandes` AFTER INSERT ON `commandes` FOR EACH ROW begin
DECLARE done INT DEFAULT FALSE;
declare v_nom varchar(255);
declare v_prenom varchar(255);
declare v_courriel varchar(255);
declare v_produit int;
declare v_quantite decimal;
declare c_panier cursor for select id_produit, quantite from panier where panier.id_compte = new.id_compte;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
select c.nom, c.prenom, c.courriel into v_nom, v_prenom, v_courriel
from comptes c
where c.id_compte = new.id_compte;
insert into historiquecommande
values (null,
new.id_commande,
new.id_compte,
new.numero_commande,
v_nom,
v_prenom,
v_courriel,
new.date,
new.status,
new.prix_total,
new.trace_paiement);
#commandesproduit
open c_panier;
panier_loop: loop
fetch c_panier into v_produit, v_quantite;
IF done THEN
LEAVE panier_loop;
END IF;
insert into commandesproduits values (new.id_commande, v_produit, v_quantite);
end loop;
close c_panier;
delete from panier where panier.id_compte = new.id_compte;
end
$$
DELIMITER ;
DROP TRIGGER IF EXISTS `tbd_commandes`;
DELIMITER $$
CREATE TRIGGER `tbd_commandes` BEFORE DELETE ON `commandes` FOR EACH ROW begin
delete from commandesproduits where commandesproduits.id_commande = old.id_commande;
end
$$
DELIMITER ;
DROP TRIGGER IF EXISTS `tbi_commandes`;
DELIMITER $$
CREATE TRIGGER `tbi_commandes` BEFORE INSERT ON `commandes` FOR EACH ROW begin
set new.date = now();
end
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Structure de la table `commandesproduits`
--
DROP TABLE IF EXISTS `commandesproduits`;
CREATE TABLE IF NOT EXISTS `commandesproduits` (
`id_commande` int(11) NOT NULL,
`id_produit` int(11) NOT NULL,
`quantite` int(11) NOT NULL,
PRIMARY KEY (`id_commande`,`id_produit`),
KEY `CommandesProduits_fk1` (`id_produit`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Déchargement des données de la table `commandesproduits`
--
INSERT INTO `commandesproduits` (`id_commande`, `id_produit`, `quantite`) VALUES
(1, 6, 1),
(1, 7, 1),
(2, 7, 131),
(3, 7, 103),
(4, 7, 101),
(5, 7, 108),
(6, 7, 109),
(7, 7, 104),
(8, 7, 109),
(9, 7, 109),
(10, 7, 103),
(11, 7, 102),
(12, 7, 112),
(13, 6, 5),
(13, 7, 1),
(14, 6, 1),
(15, 6, 1),
(16, 6, 1),
(17, 6, 1),
(18, 7, 1),
(19, 7, 1),
(20, 7, 10),
(21, 7, 10),
(22, 7, 100),
(23, 6, 5);
--
-- Déclencheurs `commandesproduits`
--
DROP TRIGGER IF EXISTS `tai_commandesproduit`;
DELIMITER $$
CREATE TRIGGER `tai_commandesproduit` AFTER INSERT ON `commandesproduits` FOR EACH ROW begin
declare v_nom varchar(255);
declare v_description varchar(1024);
declare v_marque varchar(255);
declare v_achatmin varchar(255);
declare v_economie varchar(255);
declare v_unite varchar(255);
declare v_format varchar(255);
declare v_limite varchar(255);
declare v_categorie varchar(255);
select p.nom,
p.description,
p.marque,
p.achat_minimum,
p.economie,
p.unite,
f2.nom,
p.limite_achat,
c2.nom into v_nom, v_description, v_marque, v_achatmin, v_economie, v_unite, v_format, v_limite, v_categorie
from produits p
inner join format f2 on p.format = f2.id_format
inner join categorie c2 on p.categorie = c2.id_categorie
where p.id_produit = new.id_produit;
insert into historiquecommandeproduit
values ((select id_historique from historiquecommande hc where hc.id_commande = new.id_commande),
new.id_produit,
v_nom,
v_description,
v_marque,
v_achatmin,
v_limite,
v_economie,
v_unite,
v_format,
v_categorie,
new.quantite);
end
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Structure de la table `commentaires`
--
DROP TABLE IF EXISTS `commentaires`;
CREATE TABLE IF NOT EXISTS `commentaires` (
`id_commentaire` int(11) NOT NULL AUTO_INCREMENT,
`id_compte` int(11) NOT NULL,
`date` datetime NOT NULL,
`commentaire` varchar(2048) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id_commentaire`,`id_compte`),
KEY `Commentaires_fk0` (`id_compte`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Structure de la table `comptes`
--
DROP TABLE IF EXISTS `comptes`;
CREATE TABLE IF NOT EXISTS `comptes` (
`id_compte` int(11) NOT NULL AUTO_INCREMENT,
`courriel` varchar(255) COLLATE utf8_bin NOT NULL,
`password` varchar(255) COLLATE utf8_bin NOT NULL,
`nom` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`prenom` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`telephone` varchar(30) COLLATE utf8_bin DEFAULT NULL,
`type` char(1) COLLATE utf8_bin NOT NULL DEFAULT 'U',
PRIMARY KEY (`id_compte`),
KEY `id_compte` (`id_compte`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Déchargement des données de la table `comptes`
--
INSERT INTO `comptes` (`id_compte`, `courriel`, `password`, `nom`, `prenom`, `telephone`, `type`) VALUES
(16, '[email protected]', '$2y$10$.mB/c0ntseE6/FtaFkZ3n.rze9Bt7vEGi7A0sHtZZnCV3BG1yye6K', 'Admin', 'Admin', '8193761721', 'A'),
(17, '[email protected]', '$2y$10$luzF/37bwDBuO6gZP4lJHebEYd2EMqncKSVtujj7gSSQi4orUnOzq', 'panadis', 'michael', '4505687009', 'U');
--
-- Déclencheurs `comptes`
--
DROP TRIGGER IF EXISTS `tbd_comptes`;
DELIMITER $$
CREATE TRIGGER `tbd_comptes` BEFORE DELETE ON `comptes` FOR EACH ROW delete from panier where panier.id_compte = OLD.id_compte
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Structure de la table `configuration`
--
DROP TABLE IF EXISTS `configuration`;
CREATE TABLE IF NOT EXISTS `configuration` (
`cle` varchar(255) COLLATE utf8_bin NOT NULL,
`valeur` varchar(4096) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`cle`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Déchargement des données de la table `configuration`
--
INSERT INTO `configuration` (`cle`, `valeur`) VALUES
('fonctionnement', 'Voici notre fonctionnement'),
('mission', 'Salut, ceci est notre mission');
-- --------------------------------------------------------
--
-- Structure de la table `datescommandes`
--
DROP TABLE IF EXISTS `datescommandes`;
CREATE TABLE IF NOT EXISTS `datescommandes` (
`date_debut` datetime NOT NULL,
`date_fin` datetime NOT NULL,
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`date_debut`,`date_fin`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Déchargement des données de la table `datescommandes`
--
INSERT INTO `datescommandes` (`date_debut`, `date_fin`, `nom`) VALUES
('2018-11-24 00:00:00', '2019-03-10 00:00:00', 'test'),
('2018-12-01 00:00:00', '2018-12-01 00:00:00', 'test2');
-- --------------------------------------------------------
--
-- Structure de la table `datespaiements`
--
DROP TABLE IF EXISTS `datespaiements`;
CREATE TABLE IF NOT EXISTS `datespaiements` (
`date_debut` datetime NOT NULL,
`date_fin` datetime NOT NULL,
PRIMARY KEY (`date_debut`,`date_fin`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Structure de la table `events`
--
DROP TABLE IF EXISTS `events`;
CREATE TABLE IF NOT EXISTS `events` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`color` varchar(7) DEFAULT NULL,
`start` datetime NOT NULL,
`end` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `events`
--
INSERT INTO `events` (`id`, `title`, `color`, `start`, `end`) VALUES
(15, 'test', '#0071c5', '2018-11-24 00:00:00', '2019-03-10 00:00:00'),
(16, 'test2', '#0071c5', '2018-12-01 00:00:00', '2018-12-01 00:00:00');
--
-- Déclencheurs `events`
--
DROP TRIGGER IF EXISTS `tai_events`;
DELIMITER $$
CREATE TRIGGER `tai_events` AFTER INSERT ON `events` FOR EACH ROW begin
if new.color = '#0071c5' then
insert into datescommandes values(new.start, new.end);
end if;
end
$$
DELIMITER ;
DROP TRIGGER IF EXISTS `tau_events`;
DELIMITER $$
CREATE TRIGGER `tau_events` AFTER UPDATE ON `events` FOR EACH ROW begin
declare nb int;
if new.color = '#0071c5'
then
select count(*) into nb from datescommandes where date_debut = old.start
and date_fin = old.end;
if nb > 0
then
update datescommandes
set date_debut = new.start,
date_fin = new.end,
nom = new.title
where date_debut = old.start
and date_fin = old.end;
else
insert into datescommandes values (new.start, new.end, new.title);
end if;
end if;
end
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Structure de la table `format`
--
DROP TABLE IF EXISTS `format`;
CREATE TABLE IF NOT EXISTS `format` (
`id_format` int(11) NOT NULL AUTO_INCREMENT,
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id_format`),
KEY `id_format` (`id_format`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Déchargement des données de la table `format`
--
INSERT INTO `format` (`id_format`, `nom`) VALUES
(1, 'kg');
-- --------------------------------------------------------
--
-- Structure de la table `fournisseurs`
--
DROP TABLE IF EXISTS `fournisseurs`;
CREATE TABLE IF NOT EXISTS `fournisseurs` (
`id_fournisseur` int(11) NOT NULL AUTO_INCREMENT,
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
`succursale` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`nom_contact` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`adresse` varchar(1024) COLLATE utf8_bin DEFAULT NULL,
`ville` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`code_postal` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`telephone` varchar(30) COLLATE utf8_bin DEFAULT NULL,
`tel_poste` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`actif` tinyint(1) NOT NULL,
PRIMARY KEY (`id_fournisseur`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Déchargement des données de la table `fournisseurs`
--
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `succursale`, `nom_contact`, `adresse`, `ville`, `code_postal`, `telephone`, `tel_poste`, `actif`) VALUES
(2, 'Metro', 'Fournier', NULL, '850 Boulevard Thibeau', 'Trois-Rivières', 'G8T7A6', '8193763028', '', 1);
-- --------------------------------------------------------
--
-- Structure de la table `fraisgestion`
--
DROP TABLE IF EXISTS `fraisgestion`;
CREATE TABLE IF NOT EXISTS `fraisgestion` (
`id_frais` int(11) NOT NULL AUTO_INCREMENT,
`frais` decimal(20,3) NOT NULL DEFAULT '0.000',
`type` varchar(15) COLLATE utf8_bin NOT NULL,
`actif` tinyint(1) NOT NULL,
PRIMARY KEY (`id_frais`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Déchargement des données de la table `fraisgestion`
--
INSERT INTO `fraisgestion` (`id_frais`, `frais`, `type`, `actif`) VALUES
(1, '1.100', 'pourcentage', 1),
(2, '3.000', 'fixe', 0);
--
-- Déclencheurs `fraisgestion`
--
DROP TRIGGER IF EXISTS `tbi_fraisgestion`;
DELIMITER $$
CREATE TRIGGER `tbi_fraisgestion` BEFORE INSERT ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais, new.type)
$$
DELIMITER ;
DROP TRIGGER IF EXISTS `tbu_fraisgestion`;
DELIMITER $$
CREATE TRIGGER `tbu_fraisgestion` BEFORE UPDATE ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais, new.type)
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Structure de la table `historiquecommande`
--
DROP TABLE IF EXISTS `historiquecommande`;
CREATE TABLE IF NOT EXISTS `historiquecommande` (
`id_historique` int(11) NOT NULL AUTO_INCREMENT,
`id_commande` int(11) DEFAULT NULL,
`id_compte` int(11) DEFAULT NULL,
`numero_commande` varchar(1024) COLLATE utf8_bin DEFAULT NULL,
`c_nom` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`c_prenom` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`c_courriel` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`date` datetime DEFAULT NULL,
`status` char(1) COLLATE utf8_bin DEFAULT NULL,
`prix_total` decimal(10,2) DEFAULT NULL,
`trace_paiement` int(11) DEFAULT NULL,
PRIMARY KEY (`id_historique`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Déchargement des données de la table `historiquecommande`
--
INSERT INTO `historiquecommande` (`id_historique`, `id_commande`, `id_compte`, `numero_commande`, `c_nom`, `c_prenom`, `c_courriel`, `date`, `status`, `prix_total`, `trace_paiement`) VALUES
(1, 1, 16, 'DIET-5C00CA57366FE16', 'Admin', 'Admin', '[email protected]', '2018-11-30 00:27:51', 'P', '22.00', NULL),
(2, 2, 16, 'DIET-5C01425ACB7D916', 'Admin', 'Admin', '[email protected]', '2018-11-30 08:59:54', 'P', '1427.90', NULL),
(3, 3, 16, 'DIET-5C0143005B99816', 'Admin', 'Admin', '[email protected]', '2018-11-30 09:02:40', 'P', '1122.70', NULL),
(4, 4, 16, 'DIET-5C01462249A4316', 'Admin', 'Admin', '[email protected]', '2018-11-30 09:16:02', 'P', '1100.90', NULL),
(5, 5, 16, 'DIET-5C01479668E0A16', 'Admin', 'Admin', '[email protected]', '2018-11-30 09:22:14', 'P', '1177.20', NULL),
(6, 6, 16, 'DIET-5C014883AC23116', 'Admin', 'Admin', '[email protected]', '2018-11-30 09:26:11', 'P', '1188.10', NULL),
(7, 7, 16, 'DIET-5C0148FD8C9F016', 'Admin', 'Admin', '[email protected]', '2018-11-30 09:28:13', 'P', '1133.60', NULL),
(8, 8, 16, 'DIET-5C01494F6AB0716', 'Admin', 'Admin', '[email protected]', '2018-11-30 09:29:35', 'P', '1188.10', NULL),
(9, 9, 17, 'DIET-5C014A355E62017', 'panadis', 'michael', '[email protected]', '2018-11-30 09:33:25', 'P', '1188.10', NULL),
(10, 10, 17, 'DIET-5C018CE8EF62917', 'panadis', 'michael', '[email protected]', '2018-11-30 14:18:01', 'P', '1.00', NULL),
(11, 11, 17, 'DIET-5C018DB059E0D17', 'panadis', 'michael', '[email protected]', '2018-11-30 14:21:20', 'P', '1111.80', NULL),
(12, 12, 17, 'DIET-5C01912A7E64817', 'panadis', 'michael', '[email protected]', '2018-11-30 14:36:10', 'P', '1220.80', NULL),
(13, 13, 16, 'DIET-5C04A95BA66BB16', 'Admin', 'Admin', '[email protected]', '2018-12-02 22:56:11', 'P', '76.30', NULL),
(14, 14, 16, 'DIET-5C04BDF39C17F16', 'Admin', 'Admin', '[email protected]', '2018-12-03 00:24:03', 'P', '13.20', NULL),
(15, 15, 16, 'DIET-5C04BE0E76AB116', 'Admin', 'Admin', '[email protected]', '2018-12-03 00:24:30', 'P', '13.20', NULL),
(16, 16, 16, 'DIET-5C04BE1E986B316', 'Admin', 'Admin', '[email protected]', '2018-12-03 00:24:46', 'P', '13.20', NULL),
(17, 17, 16, 'DIET-5C04BE85B985916', 'Admin', 'Admin', '[email protected]', '2018-12-03 00:26:29', 'P', '16.20', NULL),
(18, 18, 16, 'DIET-5C04C29C051A316', 'Admin', 'Admin', '[email protected]', '2018-12-03 00:43:56', 'P', '14.00', NULL),
(19, 19, 16, 'DIET-5C04C3107D75816', 'Admin', 'Admin', '[email protected]', '2018-12-03 00:45:52', 'P', '14.00', NULL),
(20, 20, 16, 'DIET-5C04C683903EC16', 'Admin', 'Admin', '[email protected]', '2018-12-03 01:00:35', 'P', '113.00', NULL),
(21, 21, 16, 'DIET-5C04C6BDC621916', 'Admin', 'Admin', '[email protected]', '2018-12-03 01:01:33', 'P', '103.00', NULL),
(22, 22, 16, 'DIET-5C04CB5F7C1A116', 'Admin', 'Admin', '[email protected]', '2018-12-03 01:21:19', 'P', '1103.00', NULL),
(23, 23, 16, 'DIET-5C04CC115926016', 'Admin', 'Admin', '[email protected]', '2018-12-03 01:24:17', 'P', '66.00', NULL);
--
-- Déclencheurs `historiquecommande`
--
DROP TRIGGER IF EXISTS `tbd_historiquecommande`;
DELIMITER $$
CREATE TRIGGER `tbd_historiquecommande` BEFORE DELETE ON `historiquecommande` FOR EACH ROW begin
delete from historiquecommandeproduit where historiquecommandeproduit.id_historique = old.id_historique;
end
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Structure de la table `historiquecommandeproduit`
--
DROP TABLE IF EXISTS `historiquecommandeproduit`;
CREATE TABLE IF NOT EXISTS `historiquecommandeproduit` (
`id_historique` int(11) NOT NULL,
`id_produit` int(11) NOT NULL,
`p_nom` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`p_description` varchar(1024) COLLATE utf8_bin DEFAULT NULL,
`p_marque` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`p_commandemin` int(11) DEFAULT NULL,
`p_limiteachat` int(11) DEFAULT NULL,
`p_economie` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`p_unite` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`p_format` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`p_categorie` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`quantite` int(11) DEFAULT NULL,
PRIMARY KEY (`id_historique`,`id_produit`),
KEY `historiquecommandeproduit_id_historique_index` (`id_historique`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Déchargement des données de la table `historiquecommandeproduit`
--
INSERT INTO `historiquecommandeproduit` (`id_historique`, `id_produit`, `p_nom`, `p_description`, `p_marque`, `p_commandemin`, `p_limiteachat`, `p_economie`, `p_unite`, `p_format`, `p_categorie`, `quantite`) VALUES
(1, 6, 'Farine', 'Une bonne farine', 'Francine', 5, 5, '', '1', 'kg', 'Divers', 1),
(1, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 1),
(2, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 131),
(3, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 103),
(4, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 101),
(5, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 108),
(6, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 109),
(7, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 104),
(8, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 109),
(9, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 109),
(10, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 103),
(11, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 102),
(12, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 112),
(13, 6, 'Farine', 'Une bonne farine', 'Francine', 5, 5, '', '1', 'kg', 'Divers', 5),
(13, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 1),
(14, 6, 'Farine', 'Une bonne farine', 'Francine', 5, 5, '', '1', 'kg', 'Divers', 1),
(15, 6, 'Farine', 'Une bonne farine', 'Francine', 5, 5, '', '1', 'kg', 'Divers', 1),
(16, 6, 'Farine', 'Une bonne farine', 'Francine', 5, 5, '', '1', 'kg', 'Divers', 1),
(17, 6, 'Farine', 'Une bonne farine', 'Francine', 5, 5, '', '1', 'kg', 'Divers', 1),
(18, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 1),
(19, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 1),
(20, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 10),
(21, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 10),
(22, 7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, 0, '', '1', 'kg', 'Viandes', 100),
(23, 6, 'Farine', 'Une bonne farine', 'Francine', 5, 5, '', '1', 'kg', 'Divers', 5);
-- --------------------------------------------------------
--
-- Structure de la table `historiquefraisgestion`
--
DROP TABLE IF EXISTS `historiquefraisgestion`;
CREATE TABLE IF NOT EXISTS `historiquefraisgestion` (
`id_frais` int(11) NOT NULL,
`date` datetime NOT NULL,
`frais` decimal(20,3) NOT NULL,
`type` varchar(15) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id_frais`,`date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Déchargement des données de la table `historiquefraisgestion`
--
INSERT INTO `historiquefraisgestion` (`id_frais`, `date`, `frais`, `type`) VALUES
(1, '2018-12-03 00:12:53', '1.090', 'pourcentage'),
(1, '2018-12-03 00:22:48', '1.100', 'pourcentage'),
(1, '2018-12-03 00:23:35', '1.100', 'pourcentage'),
(1, '2018-12-03 00:23:38', '1.100', 'pourcentage'),
(1, '2018-12-03 00:23:54', '1.100', 'pourcentage'),
(1, '2018-12-03 01:01:03', '1.100', 'pourcentage'),
(1, '2018-12-03 01:18:51', '1.100', 'pourcentage'),
(2, '2018-12-03 00:12:57', '3.000', 'fixe'),
(2, '2018-12-03 00:14:31', '3.000', 'fixe'),
(2, '2018-12-03 00:23:02', '3.000', 'fixe'),
(2, '2018-12-03 01:23:04', '3.000', 'fixe');
-- --------------------------------------------------------
--
-- Structure de la table `panier`
--
DROP TABLE IF EXISTS `panier`;
CREATE TABLE IF NOT EXISTS `panier` (
`id_compte` int(11) NOT NULL,
`id_produit` int(11) NOT NULL,
`quantite` int(11) DEFAULT NULL,
PRIMARY KEY (`id_compte`,`id_produit`) USING BTREE,
KEY `Panier_fk0` (`id_produit`),
KEY `id_compte` (`id_compte`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Structure de la table `produits`
--
DROP TABLE IF EXISTS `produits`;
CREATE TABLE IF NOT EXISTS `produits` (
`id_produit` int(11) NOT NULL AUTO_INCREMENT,
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
`description` varchar(1024) COLLATE utf8_bin DEFAULT NULL,
`marque` varchar(255) COLLATE utf8_bin NOT NULL,
`achat_minimum` int(10) NOT NULL,
`economie` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`image_produit` varchar(1024) COLLATE utf8_bin DEFAULT NULL,
`valeur_nutritive` varchar(1024) COLLATE utf8_bin DEFAULT NULL,
`format` int(11) NOT NULL,
`unite` varchar(15) COLLATE utf8_bin NOT NULL,
`limite_achat` int(11) DEFAULT NULL,
`categorie` int(11) NOT NULL,
`id_compte` int(11) DEFAULT NULL,
`status` char(1) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id_produit`),
KEY `Produits_fk0` (`categorie`),
KEY `Produits_fk1` (`id_compte`),
KEY `format` (`format`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Déchargement des données de la table `produits`
--
INSERT INTO `produits` (`id_produit`, `nom`, `description`, `marque`, `achat_minimum`, `economie`, `image_produit`, `valeur_nutritive`, `format`, `unite`, `limite_achat`, `categorie`, `id_compte`, `status`) VALUES
(6, 'Farine', 'Une bonne farine', 'Francine', 5, '', 'uploads_5bfd4b8be02ad7.90388594.jpg', NULL, 1, '1', 5, 3, NULL, 'A'),
(7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, '', 'uploads_5bf716ec8045c1.37408180.jpg', NULL, 1, '1', 0, 2, NULL, 'A');
--
-- Déclencheurs `produits`
--
DROP TRIGGER IF EXISTS `tau_produits`;
DELIMITER $$
CREATE TRIGGER `tau_produits` AFTER UPDATE ON `produits` FOR EACH ROW begin
call updatelimiteproduit(new.id_produit, new.limite_achat);
end
$$
DELIMITER ;
DROP TRIGGER IF EXISTS `tbd_produits`;
DELIMITER $$
CREATE TRIGGER `tbd_produits` BEFORE DELETE ON `produits` FOR EACH ROW begin
delete from produitsfournisseurs where produitsfournisseurs.id_produit = old.id_produit;
end
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Structure de la table `produitsfournisseurs`
--
DROP TABLE IF EXISTS `produitsfournisseurs`;
CREATE TABLE IF NOT EXISTS `produitsfournisseurs` (
`id_produit` int(11) NOT NULL,
`id_fournisseur` int(11) NOT NULL,
`prix` decimal(10,2) NOT NULL,
`economie` decimal(4,2) DEFAULT NULL,
PRIMARY KEY (`id_produit`,`id_fournisseur`),
KEY `ProduitsFournisseurs_fk1` (`id_fournisseur`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Déchargement des données de la table `produitsfournisseurs`
--
INSERT INTO `produitsfournisseurs` (`id_produit`, `id_fournisseur`, `prix`, `economie`) VALUES
(6, 2, '12.00', NULL),
(7, 2, '10.00', NULL);
-- --------------------------------------------------------
--
-- Structure de la table `tracepaiements`
--
DROP TABLE IF EXISTS `tracepaiements`;
CREATE TABLE IF NOT EXISTS `tracepaiements` (
`id_paiement` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id_paiement`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Contraintes pour les tables déchargées
--
--
-- Contraintes pour la table `commandes`
--
ALTER TABLE `commandes`
ADD CONSTRAINT `Commandes_fk0` FOREIGN KEY (`id_compte`) REFERENCES `comptes` (`id_compte`),
ADD CONSTRAINT `Commandes_fk1` FOREIGN KEY (`trace_paiement`) REFERENCES `tracepaiements` (`id_paiement`);
--
-- Contraintes pour la table `commandesproduits`
--
ALTER TABLE `commandesproduits`
ADD CONSTRAINT `CommandesProduits_fk0` FOREIGN KEY (`id_commande`) REFERENCES `commandes` (`id_commande`),
ADD CONSTRAINT `CommandesProduits_fk1` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`);
--
-- Contraintes pour la table `commentaires`
--
ALTER TABLE `commentaires`
ADD CONSTRAINT `Commentaires_fk0` FOREIGN KEY (`id_compte`) REFERENCES `comptes` (`id_compte`);
--
-- Contraintes pour la table `historiquecommandeproduit`
--
ALTER TABLE `historiquecommandeproduit`
ADD CONSTRAINT `histcomprod_fk0` FOREIGN KEY (`id_historique`) REFERENCES `historiquecommande` (`id_historique`);
--
-- Contraintes pour la table `panier`
--
ALTER TABLE `panier`
ADD CONSTRAINT `panier_fk0` FOREIGN KEY (`id_compte`) REFERENCES `comptes` (`id_compte`),
ADD CONSTRAINT `panier_fk1` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`);
--
-- Contraintes pour la table `produits`
--
ALTER TABLE `produits`
ADD CONSTRAINT `Format_fk2` FOREIGN KEY (`format`) REFERENCES `format` (`id_format`),
ADD CONSTRAINT `Produits_fk0` FOREIGN KEY (`categorie`) REFERENCES `categorie` (`id_categorie`),
ADD CONSTRAINT `Produits_fk1` FOREIGN KEY (`id_compte`) REFERENCES `comptes` (`id_compte`);
--
-- Contraintes pour la table `produitsfournisseurs`
--
ALTER TABLE `produitsfournisseurs`
ADD CONSTRAINT `ProduitsFournisseurs_fk0` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`),
ADD CONSTRAINT `ProduitsFournisseurs_fk1` FOREIGN KEY (`id_fournisseur`) REFERENCES `fournisseurs` (`id_fournisseur`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;