962 lines
25 KiB
SQL
962 lines
25 KiB
SQL
-- phpMyAdmin SQL Dump
|
|
-- version 4.8.3
|
|
-- https://www.phpmyadmin.net/
|
|
--
|
|
-- Host: 127.0.0.1
|
|
-- Generation Time: Dec 12, 2018 at 09:42 PM
|
|
-- Server version: 10.1.37-MariaDB
|
|
-- PHP Version: 7.1.24
|
|
|
|
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 */;
|
|
|
|
--
|
|
-- Database: `dietetique_2`
|
|
--
|
|
|
|
DELIMITER $$
|
|
--
|
|
-- Procedures
|
|
--
|
|
CREATE 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 ;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `access_token`
|
|
--
|
|
|
|
CREATE TABLE `access_token` (
|
|
`id` int(11) NOT NULL,
|
|
`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
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `categorie`
|
|
--
|
|
|
|
CREATE TABLE `categorie` (
|
|
`id_categorie` int(11) NOT NULL,
|
|
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
|
|
`actif` tinyint(1) NOT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `commandes`
|
|
--
|
|
|
|
CREATE TABLE `commandes` (
|
|
`id_commande` int(11) NOT NULL,
|
|
`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
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
|
|
|
|
--
|
|
-- Triggers `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_telephone varchar(255);
|
|
declare v_poste 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.telephone, c.poste, c.courriel into v_nom, v_prenom, v_telephone, v_poste, 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_telephone,
|
|
v_poste,
|
|
v_courriel,
|
|
new.date,
|
|
new.status,
|
|
new.prix_total,
|
|
new.trace_paiement);
|
|
|
|
#commandesproduit
|
|
|
|
if new.status = 'P'
|
|
then
|
|
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 if;
|
|
|
|
end
|
|
$$
|
|
DELIMITER ;
|
|
DELIMITER $$
|
|
CREATE TRIGGER `tau_commandes` AFTER UPDATE ON `commandes` FOR EACH ROW begin
|
|
|
|
DECLARE done INT DEFAULT FALSE;
|
|
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;
|
|
|
|
|
|
if old.status = 'N' then
|
|
|
|
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 if;
|
|
|
|
end
|
|
$$
|
|
DELIMITER ;
|
|
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 ;
|
|
DELIMITER $$
|
|
CREATE TRIGGER `tbi_commandes` BEFORE INSERT ON `commandes` FOR EACH ROW begin
|
|
|
|
set new.date = now();
|
|
|
|
end
|
|
$$
|
|
DELIMITER ;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `commandesproduits`
|
|
--
|
|
|
|
CREATE TABLE `commandesproduits` (
|
|
`id_commande` int(11) NOT NULL,
|
|
`id_produit` int(11) NOT NULL,
|
|
`quantite` int(11) NOT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
--
|
|
-- Triggers `commandesproduits`
|
|
--
|
|
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_prix decimal(20,2);
|
|
declare v_fraisfixe decimal(20,2);
|
|
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,
|
|
p2.prix,
|
|
p.frais_fixe,
|
|
p.limite_achat,
|
|
c2.nom into v_nom, v_description, v_marque, v_achatmin, v_economie, v_unite, v_format, v_prix, v_fraisfixe, 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
|
|
inner join produitsfournisseurs p2 on p.id_produit = p2.id_produit
|
|
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_prix,
|
|
v_fraisfixe,
|
|
v_categorie,
|
|
new.quantite);
|
|
|
|
end
|
|
$$
|
|
DELIMITER ;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `commentaires`
|
|
--
|
|
|
|
CREATE TABLE `commentaires` (
|
|
`id_commentaire` int(11) NOT NULL,
|
|
`id_compte` int(11) NOT NULL,
|
|
`date` datetime NOT NULL,
|
|
`commentaire` varchar(2048) COLLATE utf8_bin NOT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `comptes`
|
|
--
|
|
|
|
CREATE TABLE `comptes` (
|
|
`id_compte` int(11) NOT NULL,
|
|
`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,
|
|
`poste` varchar(255) COLLATE utf8_bin DEFAULT NULL,
|
|
`type` char(1) COLLATE utf8_bin NOT NULL DEFAULT 'U'
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
--
|
|
-- Dumping data for table `comptes`
|
|
--
|
|
|
|
INSERT INTO `comptes` (`id_compte`, `courriel`, `password`, `nom`, `prenom`, `telephone`, `poste`, `type`) VALUES
|
|
(16, '[email protected]', '$2y$10$.mB/c0ntseE6/FtaFkZ3n.rze9Bt7vEGi7A0sHtZZnCV3BG1yye6K', 'Admin', 'Admin', '8193761721', '', 'A');
|
|
|
|
--
|
|
-- Triggers `comptes`
|
|
--
|
|
DELIMITER $$
|
|
CREATE TRIGGER `tbd_comptes` BEFORE DELETE ON `comptes` FOR EACH ROW delete from panier where panier.id_compte = OLD.id_compte
|
|
$$
|
|
DELIMITER ;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `configuration`
|
|
--
|
|
|
|
CREATE TABLE `configuration` (
|
|
`cle` varchar(255) COLLATE utf8_bin NOT NULL,
|
|
`valeur` varchar(4096) COLLATE utf8_bin NOT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
--
|
|
-- Dumping data for table `configuration`
|
|
--
|
|
|
|
INSERT INTO `configuration` (`cle`, `valeur`) VALUES
|
|
('fonctionnement', 'Le fonctionnement d\'un regroupements d\'achats est très simple. Nous faisons affaires avec plusieurs fournisseurs pour pouvoir offrir des prix compétitifs en commandant en vrac.'),
|
|
('mission', 'Bienvenue sur notre site de regroupements d\'achats ! Le but de notre projet est simple : offrir des produits moins chers que les épiceries en achetant en vrac.');
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `datescommandes`
|
|
--
|
|
|
|
CREATE TABLE `datescommandes` (
|
|
`id_periode` int(11) NOT NULL,
|
|
`date_debut` datetime NOT NULL,
|
|
`date_fin` datetime NOT NULL,
|
|
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `datespaiements`
|
|
--
|
|
|
|
CREATE TABLE `datespaiements` (
|
|
`date_debut` datetime NOT NULL,
|
|
`date_fin` datetime NOT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `events`
|
|
--
|
|
|
|
CREATE TABLE `events` (
|
|
`id` int(11) NOT NULL,
|
|
`title` varchar(255) NOT NULL,
|
|
`color` varchar(7) DEFAULT NULL,
|
|
`start` datetime NOT NULL,
|
|
`end` datetime DEFAULT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
--
|
|
-- Triggers `events`
|
|
--
|
|
DELIMITER $$
|
|
CREATE TRIGGER `tad_events` AFTER DELETE ON `events` FOR EACH ROW begin
|
|
|
|
delete from datescommandes where id_periode = old.id;
|
|
|
|
end
|
|
$$
|
|
DELIMITER ;
|
|
DELIMITER $$
|
|
CREATE TRIGGER `tai_events` AFTER INSERT ON `events` FOR EACH ROW begin
|
|
|
|
if new.color = '#0071c5' then
|
|
insert into datescommandes values(new.id, new.start, new.end, new.title);
|
|
end if;
|
|
|
|
end
|
|
$$
|
|
DELIMITER ;
|
|
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 id_periode = old.id;
|
|
|
|
if nb > 0
|
|
then
|
|
update datescommandes
|
|
set date_debut = new.start,
|
|
date_fin = new.end,
|
|
nom = new.title
|
|
where id_periode = old.id;
|
|
else
|
|
insert into datescommandes values (old.id, new.start, new.end, new.title);
|
|
end if;
|
|
|
|
end if;
|
|
|
|
end
|
|
$$
|
|
DELIMITER ;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `format`
|
|
--
|
|
|
|
CREATE TABLE `format` (
|
|
`id_format` int(11) NOT NULL,
|
|
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
|
|
`actif` tinyint(1) NOT NULL DEFAULT '1'
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `fournisseurs`
|
|
--
|
|
|
|
CREATE TABLE `fournisseurs` (
|
|
`id_fournisseur` int(11) NOT NULL,
|
|
`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,
|
|
`role` varchar(255) COLLATE utf8_bin NOT 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
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `fraisgestion`
|
|
--
|
|
|
|
CREATE TABLE `fraisgestion` (
|
|
`id_frais` int(11) NOT NULL,
|
|
`frais` decimal(20,3) NOT NULL DEFAULT '0.000',
|
|
`type` varchar(15) COLLATE utf8_bin NOT NULL,
|
|
`actif` tinyint(1) NOT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
--
|
|
-- Dumping data for table `fraisgestion`
|
|
--
|
|
|
|
INSERT INTO `fraisgestion` (`id_frais`, `frais`, `type`, `actif`) VALUES
|
|
(1, '1.000', 'pourcentage', 1),
|
|
(2, '0.000', 'fixe', 1);
|
|
|
|
--
|
|
-- Triggers `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, new.actif)
|
|
$$
|
|
DELIMITER ;
|
|
DELIMITER $$
|
|
CREATE TRIGGER `tbu_fraisgestion` BEFORE UPDATE ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais, new.type, new.actif)
|
|
$$
|
|
DELIMITER ;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `historiquecommande`
|
|
--
|
|
|
|
CREATE TABLE `historiquecommande` (
|
|
`id_historique` int(11) NOT NULL,
|
|
`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_telephone` varchar(255) COLLATE utf8_bin DEFAULT NULL,
|
|
`c_poste` 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
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
--
|
|
-- Triggers `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 ;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `historiquecommandeproduit`
|
|
--
|
|
|
|
CREATE TABLE `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_prix` decimal(20,2) NOT NULL,
|
|
`p_fraisfixe` decimal(20,2) NOT NULL,
|
|
`p_categorie` varchar(255) COLLATE utf8_bin DEFAULT NULL,
|
|
`quantite` int(11) DEFAULT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `historiquefraisgestion`
|
|
--
|
|
|
|
CREATE TABLE `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,
|
|
`actif` tinyint(1) NOT NULL DEFAULT '1'
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
--
|
|
-- Dumping data for table `historiquefraisgestion`
|
|
--
|
|
|
|
INSERT INTO `historiquefraisgestion` (`id_frais`, `date`, `frais`, `type`, `actif`) VALUES
|
|
(1, '2018-12-06 20:13:47', '1.000', 'pourcentage', 1),
|
|
(2, '2018-12-06 20:13:53', '0.000', 'fixe', 1);
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `panier`
|
|
--
|
|
|
|
CREATE TABLE `panier` (
|
|
`id_compte` int(11) NOT NULL,
|
|
`id_produit` int(11) NOT NULL,
|
|
`quantite` int(11) DEFAULT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `password_resets`
|
|
--
|
|
|
|
CREATE TABLE `password_resets` (
|
|
`id_reset` int(11) NOT NULL,
|
|
`id_compte` int(11) DEFAULT NULL,
|
|
`selector` varchar(255) COLLATE utf8_bin DEFAULT NULL,
|
|
`token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`expires` datetime DEFAULT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `produits`
|
|
--
|
|
|
|
CREATE TABLE `produits` (
|
|
`id_produit` int(11) NOT NULL,
|
|
`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(1024) 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` int(11) NOT NULL,
|
|
`limite_achat` int(11) DEFAULT NULL,
|
|
`categorie` int(11) NOT NULL,
|
|
`frais_fixe` decimal(20,2) NOT NULL DEFAULT '0.00',
|
|
`id_compte` int(11) DEFAULT NULL,
|
|
`status` char(1) COLLATE utf8_bin NOT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
--
|
|
-- Triggers `produits`
|
|
--
|
|
DELIMITER $$
|
|
CREATE TRIGGER `tau_produits` AFTER UPDATE ON `produits` FOR EACH ROW begin
|
|
|
|
if (new.limite_achat != 0) then
|
|
call updatelimiteproduit(new.id_produit, new.limite_achat);
|
|
end if;
|
|
|
|
end
|
|
$$
|
|
DELIMITER ;
|
|
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 ;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `produitsfournisseurs`
|
|
--
|
|
|
|
CREATE TABLE `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
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Table structure for table `tracepaiements`
|
|
--
|
|
|
|
CREATE TABLE `tracepaiements` (
|
|
`id_paiement` int(11) NOT NULL,
|
|
`authorization` varchar(255) COLLATE utf8_bin NOT NULL,
|
|
`invoice` varchar(255) COLLATE utf8_bin NOT NULL,
|
|
`status` char(1) COLLATE utf8_bin NOT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
|
|
|
--
|
|
-- Indexes for dumped tables
|
|
--
|
|
|
|
--
|
|
-- Indexes for table `access_token`
|
|
--
|
|
ALTER TABLE `access_token`
|
|
ADD PRIMARY KEY (`id`);
|
|
|
|
--
|
|
-- Indexes for table `categorie`
|
|
--
|
|
ALTER TABLE `categorie`
|
|
ADD PRIMARY KEY (`id_categorie`);
|
|
|
|
--
|
|
-- Indexes for table `commandes`
|
|
--
|
|
ALTER TABLE `commandes`
|
|
ADD PRIMARY KEY (`id_commande`,`id_compte`) USING BTREE,
|
|
ADD KEY `Commandes_fk0` (`id_compte`),
|
|
ADD KEY `Commandes_fk1` (`trace_paiement`),
|
|
ADD KEY `id_commande` (`id_commande`);
|
|
|
|
--
|
|
-- Indexes for table `commandesproduits`
|
|
--
|
|
ALTER TABLE `commandesproduits`
|
|
ADD PRIMARY KEY (`id_commande`,`id_produit`),
|
|
ADD KEY `CommandesProduits_fk1` (`id_produit`);
|
|
|
|
--
|
|
-- Indexes for table `commentaires`
|
|
--
|
|
ALTER TABLE `commentaires`
|
|
ADD PRIMARY KEY (`id_commentaire`,`id_compte`),
|
|
ADD KEY `Commentaires_fk0` (`id_compte`);
|
|
|
|
--
|
|
-- Indexes for table `comptes`
|
|
--
|
|
ALTER TABLE `comptes`
|
|
ADD PRIMARY KEY (`id_compte`),
|
|
ADD KEY `id_compte` (`id_compte`);
|
|
|
|
--
|
|
-- Indexes for table `configuration`
|
|
--
|
|
ALTER TABLE `configuration`
|
|
ADD PRIMARY KEY (`cle`);
|
|
|
|
--
|
|
-- Indexes for table `datescommandes`
|
|
--
|
|
ALTER TABLE `datescommandes`
|
|
ADD PRIMARY KEY (`id_periode`) USING BTREE;
|
|
|
|
--
|
|
-- Indexes for table `datespaiements`
|
|
--
|
|
ALTER TABLE `datespaiements`
|
|
ADD PRIMARY KEY (`date_debut`,`date_fin`);
|
|
|
|
--
|
|
-- Indexes for table `events`
|
|
--
|
|
ALTER TABLE `events`
|
|
ADD PRIMARY KEY (`id`);
|
|
|
|
--
|
|
-- Indexes for table `format`
|
|
--
|
|
ALTER TABLE `format`
|
|
ADD PRIMARY KEY (`id_format`),
|
|
ADD KEY `id_format` (`id_format`);
|
|
|
|
--
|
|
-- Indexes for table `fournisseurs`
|
|
--
|
|
ALTER TABLE `fournisseurs`
|
|
ADD PRIMARY KEY (`id_fournisseur`);
|
|
|
|
--
|
|
-- Indexes for table `fraisgestion`
|
|
--
|
|
ALTER TABLE `fraisgestion`
|
|
ADD PRIMARY KEY (`id_frais`);
|
|
|
|
--
|
|
-- Indexes for table `historiquecommande`
|
|
--
|
|
ALTER TABLE `historiquecommande`
|
|
ADD PRIMARY KEY (`id_historique`);
|
|
|
|
--
|
|
-- Indexes for table `historiquecommandeproduit`
|
|
--
|
|
ALTER TABLE `historiquecommandeproduit`
|
|
ADD PRIMARY KEY (`id_historique`,`id_produit`),
|
|
ADD KEY `historiquecommandeproduit_id_historique_index` (`id_historique`);
|
|
|
|
--
|
|
-- Indexes for table `historiquefraisgestion`
|
|
--
|
|
ALTER TABLE `historiquefraisgestion`
|
|
ADD PRIMARY KEY (`id_frais`,`date`);
|
|
|
|
--
|
|
-- Indexes for table `panier`
|
|
--
|
|
ALTER TABLE `panier`
|
|
ADD PRIMARY KEY (`id_compte`,`id_produit`) USING BTREE,
|
|
ADD KEY `Panier_fk0` (`id_produit`),
|
|
ADD KEY `id_compte` (`id_compte`);
|
|
|
|
--
|
|
-- Indexes for table `password_resets`
|
|
--
|
|
ALTER TABLE `password_resets`
|
|
ADD PRIMARY KEY (`id_reset`),
|
|
ADD KEY `comptes_fk0` (`id_compte`);
|
|
|
|
--
|
|
-- Indexes for table `produits`
|
|
--
|
|
ALTER TABLE `produits`
|
|
ADD PRIMARY KEY (`id_produit`),
|
|
ADD KEY `Produits_fk0` (`categorie`),
|
|
ADD KEY `Produits_fk1` (`id_compte`),
|
|
ADD KEY `format` (`format`);
|
|
|
|
--
|
|
-- Indexes for table `produitsfournisseurs`
|
|
--
|
|
ALTER TABLE `produitsfournisseurs`
|
|
ADD PRIMARY KEY (`id_produit`,`id_fournisseur`),
|
|
ADD KEY `ProduitsFournisseurs_fk1` (`id_fournisseur`);
|
|
|
|
--
|
|
-- Indexes for table `tracepaiements`
|
|
--
|
|
ALTER TABLE `tracepaiements`
|
|
ADD PRIMARY KEY (`id_paiement`);
|
|
|
|
--
|
|
-- AUTO_INCREMENT for dumped tables
|
|
--
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `access_token`
|
|
--
|
|
ALTER TABLE `access_token`
|
|
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `categorie`
|
|
--
|
|
ALTER TABLE `categorie`
|
|
MODIFY `id_categorie` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `commandes`
|
|
--
|
|
ALTER TABLE `commandes`
|
|
MODIFY `id_commande` int(11) NOT NULL AUTO_INCREMENT;
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `commentaires`
|
|
--
|
|
ALTER TABLE `commentaires`
|
|
MODIFY `id_commentaire` int(11) NOT NULL AUTO_INCREMENT;
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `comptes`
|
|
--
|
|
ALTER TABLE `comptes`
|
|
MODIFY `id_compte` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `events`
|
|
--
|
|
ALTER TABLE `events`
|
|
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `format`
|
|
--
|
|
ALTER TABLE `format`
|
|
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `fournisseurs`
|
|
--
|
|
ALTER TABLE `fournisseurs`
|
|
MODIFY `id_fournisseur` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `fraisgestion`
|
|
--
|
|
ALTER TABLE `fraisgestion`
|
|
MODIFY `id_frais` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `historiquecommande`
|
|
--
|
|
ALTER TABLE `historiquecommande`
|
|
MODIFY `id_historique` int(11) NOT NULL AUTO_INCREMENT;
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `password_resets`
|
|
--
|
|
ALTER TABLE `password_resets`
|
|
MODIFY `id_reset` int(11) NOT NULL AUTO_INCREMENT;
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `produits`
|
|
--
|
|
ALTER TABLE `produits`
|
|
MODIFY `id_produit` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
|
|
|
|
--
|
|
-- AUTO_INCREMENT for table `tracepaiements`
|
|
--
|
|
ALTER TABLE `tracepaiements`
|
|
MODIFY `id_paiement` int(11) NOT NULL AUTO_INCREMENT;
|
|
|
|
--
|
|
-- Constraints for dumped tables
|
|
--
|
|
|
|
--
|
|
-- Constraints for 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`);
|
|
|
|
--
|
|
-- Constraints for 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`);
|
|
|
|
--
|
|
-- Constraints for table `commentaires`
|
|
--
|
|
ALTER TABLE `commentaires`
|
|
ADD CONSTRAINT `Commentaires_fk0` FOREIGN KEY (`id_compte`) REFERENCES `comptes` (`id_compte`);
|
|
|
|
--
|
|
-- Constraints for table `historiquecommandeproduit`
|
|
--
|
|
ALTER TABLE `historiquecommandeproduit`
|
|
ADD CONSTRAINT `histcomprod_fk0` FOREIGN KEY (`id_historique`) REFERENCES `historiquecommande` (`id_historique`);
|
|
|
|
--
|
|
-- Constraints for 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`);
|
|
|
|
--
|
|
-- Constraints for table `password_resets`
|
|
--
|
|
ALTER TABLE `password_resets`
|
|
ADD CONSTRAINT `comptes_fk0` FOREIGN KEY (`id_compte`) REFERENCES `comptes` (`id_compte`);
|
|
|
|
--
|
|
-- Constraints for 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`);
|
|
|
|
--
|
|
-- Constraints for 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 */;
|