Initial commit
This commit is contained in:
1 parent
ac59bcc9fa
commit
094972f4c0
262 files changed
+151168
No files matched your search
@@ -0,0 +1,663 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.8.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 22, 2018 at 10:31 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`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes'),
|
||||
(2, 'Viandes');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `commandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandes` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`status` char(1) COLLATE utf8_bin NOT NULL,
|
||||
`prix_total` decimal(5,3) 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 v_nom varchar(255);
|
||||
declare v_prenom varchar(255);
|
||||
declare v_courriel varchar(255);
|
||||
|
||||
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 (0,
|
||||
new.id_commande,
|
||||
new.id_compte,
|
||||
v_nom,
|
||||
v_prenom,
|
||||
v_courriel,
|
||||
new.date,
|
||||
new.status,
|
||||
new.prix_total,
|
||||
new.trace_paiement);
|
||||
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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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`, `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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `events`
|
||||
--
|
||||
|
||||
INSERT INTO `events` (`id`, `title`, `color`, `start`, `end`) VALUES
|
||||
(15, 'test', '#0071c5', '2018-11-22 00:00:00', '2018-11-23 00:00:00'),
|
||||
(16, 'test2', '#0071c5', '2018-11-29 00:00:00', '2018-11-29 01:00:00');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fournisseurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `fournisseurs` (
|
||||
`id_fournisseur` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||
`adresse` varchar(1024) COLLATE utf8_bin NOT NULL,
|
||||
`telephone` varchar(30) COLLATE utf8_bin DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `adresse`, `telephone`) VALUES
|
||||
(2, 'Metro', '123 lol', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `historiquecommandeproduit`
|
||||
--
|
||||
|
||||
CREATE TABLE `historiquecommandeproduit` (
|
||||
`id_historique` int(11) DEFAULT NULL,
|
||||
`id_produit` int(11) DEFAULT 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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `panier`
|
||||
--
|
||||
|
||||
CREATE TABLE `panier` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`id_produit` int(11) DEFAULT NULL,
|
||||
`quantite` int(11) 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(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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for 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', 100, '', 'uploads_5bf7168aa89ef2.87995613.jpg', NULL, 1, '1', 69, 1, NULL, 'A'),
|
||||
(7, 'Saucisse', 'Une bonne saucisse', 'La fernandière', 420, '', 'uploads_5bf716ec8045c1.37408180.jpg', NULL, 1, '1', 0, 2, NULL, 'A');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `produitsfournisseurs` (`id_produit`, `id_fournisseur`, `prix`, `economie`) VALUES
|
||||
(6, 2, '5.00', NULL),
|
||||
(7, 2, '10.00', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) 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`),
|
||||
ADD KEY `Commandes_fk0` (`id_compte`),
|
||||
ADD KEY `Commandes_fk1` (`trace_paiement`);
|
||||
|
||||
--
|
||||
-- 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
ADD PRIMARY KEY (`id_historique`);
|
||||
|
||||
--
|
||||
-- Indexes for table `historiquecommandeproduit`
|
||||
--
|
||||
ALTER TABLE `historiquecommandeproduit`
|
||||
ADD KEY `historiquecommandeproduit_id_historique_index` (`id_historique`);
|
||||
|
||||
--
|
||||
-- Indexes for table `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD PRIMARY KEY (`id_compte`, `id_produit`) USING BTREE,
|
||||
ADD KEY `Panier_fk0` (`id_produit`),
|
||||
ADD KEY `Panier_fk1` (`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=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `comptes`
|
||||
--
|
||||
ALTER TABLE `comptes`
|
||||
MODIFY `id_compte` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `events`
|
||||
--
|
||||
ALTER TABLE `events`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `fournisseurs`
|
||||
--
|
||||
ALTER TABLE `fournisseurs`
|
||||
MODIFY `id_fournisseur` 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=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `produits`
|
||||
--
|
||||
ALTER TABLE `produits`
|
||||
MODIFY `id_produit` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
|
||||
|
||||
--
|
||||
-- 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 `historiquecommandeproduit__fk` FOREIGN KEY (`id_historique`) REFERENCES `historiquecommande` (`id_historique`);
|
||||
|
||||
--
|
||||
-- Constraints for table `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD CONSTRAINT `Panier_fk0` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`),
|
||||
ADD CONSTRAINT `panier_ibfk_1` 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 */;
|
||||
@@ -0,0 +1,724 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.8.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 23, 2018 at 03:11 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`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes'),
|
||||
(2, 'Viandes');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `commandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandes` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`status` char(1) COLLATE utf8_bin NOT NULL,
|
||||
`prix_total` decimal(5,3) 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 v_nom varchar(255);
|
||||
declare v_prenom varchar(255);
|
||||
declare v_courriel varchar(255);
|
||||
|
||||
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 (0,
|
||||
new.id_commande,
|
||||
new.id_compte,
|
||||
v_nom,
|
||||
v_prenom,
|
||||
v_courriel,
|
||||
new.date,
|
||||
new.status,
|
||||
new.prix_total,
|
||||
new.trace_paiement);
|
||||
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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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`, `type`) VALUES
|
||||
(16, '[email protected]', '$2y$10$.mB/c0ntseE6/FtaFkZ3n.rze9Bt7vEGi7A0sHtZZnCV3BG1yye6K', 'Admin', 'Admin', '8193761721', 'A');
|
||||
|
||||
--
|
||||
-- Triggers `comptes`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tai_comptes` AFTER INSERT ON `comptes` FOR EACH ROW insert into panier values(NEW.id_compte, null, null)
|
||||
$$
|
||||
DELIMITER ;
|
||||
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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `events`
|
||||
--
|
||||
|
||||
INSERT INTO `events` (`id`, `title`, `color`, `start`, `end`) VALUES
|
||||
(15, 'test', '#0071c5', '2018-11-22 00:00:00', '2018-11-23 00:00:00'),
|
||||
(16, 'test2', '#0071c5', '2018-11-29 00:00:00', '2018-11-29 01:00:00');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `succursale`, `nom_contact`, `adresse`, `ville`, `code_postal`, `telephone`, `tel_poste`) VALUES
|
||||
(2, 'Metro', '', '', '123 lol', '', '', NULL, '');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fraisgestion`
|
||||
--
|
||||
|
||||
CREATE TABLE `fraisgestion` (
|
||||
`id_frais` int(11) NOT NULL,
|
||||
`frais` decimal(4,2) NOT NULL DEFAULT '0.00'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Triggers `fraisgestion`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbi_fraisgestion` BEFORE INSERT ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
DELIMITER ;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbu_fraisgestion` BEFORE UPDATE ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `historiquecommandeproduit`
|
||||
--
|
||||
|
||||
CREATE TABLE `historiquecommandeproduit` (
|
||||
`id_historique` int(11) DEFAULT NULL,
|
||||
`id_produit` int(11) DEFAULT 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
|
||||
) 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(4,2) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `panier`
|
||||
--
|
||||
|
||||
CREATE TABLE `panier` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`id_produit` int(11) DEFAULT NULL,
|
||||
`quantite` int(11) 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(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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for 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', 100, '', 'uploads_5bf7168aa89ef2.87995613.jpg', NULL, 1, '1', 69, 1, NULL, 'A'),
|
||||
(7, 'Saucisse', 'Une bonne saucisse', 'La fernandière', 420, '', 'uploads_5bf716ec8045c1.37408180.jpg', NULL, 1, '1', 0, 2, NULL, 'A');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `produitsfournisseurs` (`id_produit`, `id_fournisseur`, `prix`, `economie`) VALUES
|
||||
(6, 2, '5.00', NULL),
|
||||
(7, 2, '10.00', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) 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`) USING BTREE,
|
||||
ADD KEY `Commandes_fk0` (`id_compte`),
|
||||
ADD KEY `Commandes_fk1` (`trace_paiement`);
|
||||
|
||||
--
|
||||
-- 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 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`) USING BTREE,
|
||||
ADD KEY `Panier_fk0` (`id_produit`);
|
||||
|
||||
--
|
||||
-- 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=3;
|
||||
|
||||
--
|
||||
-- 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=18;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `events`
|
||||
--
|
||||
ALTER TABLE `events`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- 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 for table `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
MODIFY `id_historique` 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=8;
|
||||
|
||||
--
|
||||
-- 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 `historiquecommandeproduit__fk` FOREIGN KEY (`id_historique`) REFERENCES `historiquecommande` (`id_historique`);
|
||||
|
||||
--
|
||||
-- Constraints for table `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD CONSTRAINT `Panier_fk0` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`),
|
||||
ADD CONSTRAINT `panier_ibfk_1` 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 */;
|
||||
@@ -0,0 +1,725 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.8.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 23, 2018 at 03:33 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`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes'),
|
||||
(2, 'Viandes');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `commandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandes` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`status` char(1) COLLATE utf8_bin NOT NULL,
|
||||
`prix_total` decimal(5,3) 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 v_nom varchar(255);
|
||||
declare v_prenom varchar(255);
|
||||
declare v_courriel varchar(255);
|
||||
|
||||
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 (0,
|
||||
new.id_commande,
|
||||
new.id_compte,
|
||||
v_nom,
|
||||
v_prenom,
|
||||
v_courriel,
|
||||
new.date,
|
||||
new.status,
|
||||
new.prix_total,
|
||||
new.trace_paiement);
|
||||
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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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`, `type`) VALUES
|
||||
(16, '[email protected]', '$2y$10$.mB/c0ntseE6/FtaFkZ3n.rze9Bt7vEGi7A0sHtZZnCV3BG1yye6K', 'Admin', 'Admin', '8193761721', 'A');
|
||||
|
||||
--
|
||||
-- Triggers `comptes`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tai_comptes` AFTER INSERT ON `comptes` FOR EACH ROW insert into panier values(NEW.id_compte, null, null)
|
||||
$$
|
||||
DELIMITER ;
|
||||
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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `events`
|
||||
--
|
||||
|
||||
INSERT INTO `events` (`id`, `title`, `color`, `start`, `end`) VALUES
|
||||
(15, 'test', '#0071c5', '2018-11-22 00:00:00', '2018-11-23 00:00:00'),
|
||||
(16, 'test2', '#0071c5', '2018-11-29 00:00:00', '2018-11-29 01:00:00');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `succursale`, `nom_contact`, `adresse`, `ville`, `code_postal`, `telephone`, `tel_poste`) VALUES
|
||||
(2, 'Metro', '', '', '123 lol', '', '', NULL, '');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fraisgestion`
|
||||
--
|
||||
|
||||
CREATE TABLE `fraisgestion` (
|
||||
`id_frais` int(11) NOT NULL,
|
||||
`frais` decimal(4,2) NOT NULL DEFAULT '0.00'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Triggers `fraisgestion`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbi_fraisgestion` BEFORE INSERT ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
DELIMITER ;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbu_fraisgestion` BEFORE UPDATE ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `historiquecommandeproduit`
|
||||
--
|
||||
|
||||
CREATE TABLE `historiquecommandeproduit` (
|
||||
`id_historique` int(11) DEFAULT NULL,
|
||||
`id_produit` int(11) DEFAULT 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
|
||||
) 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(4,2) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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 `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(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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for 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', 100, '', 'uploads_5bf7168aa89ef2.87995613.jpg', NULL, 1, '1', 69, 1, NULL, 'A'),
|
||||
(7, 'Saucisse', 'Une bonne saucisse', 'La fernandière', 420, '', 'uploads_5bf716ec8045c1.37408180.jpg', NULL, 1, '1', 0, 2, NULL, 'A');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `produitsfournisseurs` (`id_produit`, `id_fournisseur`, `prix`, `economie`) VALUES
|
||||
(6, 2, '5.00', NULL),
|
||||
(7, 2, '10.00', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) 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`) USING BTREE,
|
||||
ADD KEY `Commandes_fk0` (`id_compte`),
|
||||
ADD KEY `Commandes_fk1` (`trace_paiement`);
|
||||
|
||||
--
|
||||
-- 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 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 `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=3;
|
||||
|
||||
--
|
||||
-- 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=18;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `events`
|
||||
--
|
||||
ALTER TABLE `events`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- 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 for table `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
MODIFY `id_historique` 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=8;
|
||||
|
||||
--
|
||||
-- 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 `historiquecommandeproduit__fk` 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 `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 */;
|
||||
@@ -0,0 +1,824 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.8.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 23, 2018 at 05:45 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 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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes'),
|
||||
(2, 'Viandes');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `commandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandes` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`status` char(1) COLLATE utf8_bin NOT NULL,
|
||||
`prix_total` decimal(5,3) 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 v_nom varchar(255);
|
||||
declare v_prenom varchar(255);
|
||||
declare v_courriel varchar(255);
|
||||
|
||||
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 (0,
|
||||
new.id_commande,
|
||||
new.id_compte,
|
||||
v_nom,
|
||||
v_prenom,
|
||||
v_courriel,
|
||||
new.date,
|
||||
new.status,
|
||||
new.prix_total,
|
||||
new.trace_paiement);
|
||||
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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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`, `type`) VALUES
|
||||
(16, '[email protected]', '$2y$10$.mB/c0ntseE6/FtaFkZ3n.rze9Bt7vEGi7A0sHtZZnCV3BG1yye6K', 'Admin', 'Admin', '8193761721', 'A');
|
||||
|
||||
--
|
||||
-- Triggers `comptes`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tai_comptes` AFTER INSERT ON `comptes` FOR EACH ROW insert into panier values(NEW.id_compte, null, null)
|
||||
$$
|
||||
DELIMITER ;
|
||||
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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `datescommandes`
|
||||
--
|
||||
|
||||
INSERT INTO `datescommandes` (`date_debut`, `date_fin`, `nom`) VALUES
|
||||
('2018-11-24 00:00:00', '2018-11-26 00:00:00', 'test');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `events`
|
||||
--
|
||||
|
||||
INSERT INTO `events` (`id`, `title`, `color`, `start`, `end`) VALUES
|
||||
(15, 'test', '#0071c5', '2018-11-24 00:00:00', '2018-11-26 00:00:00'),
|
||||
(16, 'test2', '#0071c5', '2018-11-29 00:00:00', '2018-11-29 01:00:00');
|
||||
|
||||
--
|
||||
-- Triggers `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 ;
|
||||
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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `succursale`, `nom_contact`, `adresse`, `ville`, `code_postal`, `telephone`, `tel_poste`) VALUES
|
||||
(2, 'Metro', '', '', '123 lol', '', '', NULL, '');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fraisgestion`
|
||||
--
|
||||
|
||||
CREATE TABLE `fraisgestion` (
|
||||
`id_frais` int(11) NOT NULL,
|
||||
`frais` decimal(4,3) NOT NULL DEFAULT '0.000'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Triggers `fraisgestion`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbi_fraisgestion` BEFORE INSERT ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
DELIMITER ;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbu_fraisgestion` BEFORE UPDATE ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `historiquecommandeproduit`
|
||||
--
|
||||
|
||||
CREATE TABLE `historiquecommandeproduit` (
|
||||
`id_historique` int(11) DEFAULT NULL,
|
||||
`id_produit` int(11) DEFAULT 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
|
||||
) 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(4,3) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `panier`
|
||||
--
|
||||
|
||||
INSERT INTO `panier` (`id_compte`, `id_produit`, `quantite`) VALUES
|
||||
(16, 6, 5);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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(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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for 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', 100, '', 'uploads_5bf7168aa89ef2.87995613.jpg', NULL, 1, '1', 5, 1, NULL, 'A'),
|
||||
(7, 'Saucisse', 'Une bonne saucisse', 'La fernandière', 420, '', 'uploads_5bf716ec8045c1.37408180.jpg', NULL, 1, '1', 0, 2, NULL, 'A');
|
||||
|
||||
--
|
||||
-- Triggers `produits`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tau_produits` AFTER UPDATE ON `produits` FOR EACH ROW begin
|
||||
|
||||
call updatelimiteproduit(new.id_produit, new.limite_achat);
|
||||
|
||||
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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `produitsfournisseurs` (`id_produit`, `id_fournisseur`, `prix`, `economie`) VALUES
|
||||
(6, 2, '5.00', NULL),
|
||||
(7, 2, '10.00', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) 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`) USING BTREE,
|
||||
ADD KEY `Commandes_fk0` (`id_compte`),
|
||||
ADD KEY `Commandes_fk1` (`trace_paiement`);
|
||||
|
||||
--
|
||||
-- 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 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 `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=3;
|
||||
|
||||
--
|
||||
-- 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=18;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `events`
|
||||
--
|
||||
ALTER TABLE `events`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- 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 for table `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
MODIFY `id_historique` 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=8;
|
||||
|
||||
--
|
||||
-- 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 `historiquecommandeproduit__fk` 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 `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 */;
|
||||
@@ -0,0 +1,787 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.8.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 26, 2018 at 10:16 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
|
||||
) 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,
|
||||
`date` datetime NOT NULL,
|
||||
`status` char(1) COLLATE utf8_bin NOT NULL,
|
||||
`prix_total` decimal(5,3) 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 v_nom varchar(255);
|
||||
declare v_prenom varchar(255);
|
||||
declare v_courriel varchar(255);
|
||||
|
||||
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,
|
||||
v_nom,
|
||||
v_prenom,
|
||||
v_courriel,
|
||||
new.date,
|
||||
new.status,
|
||||
new.prix_total,
|
||||
new.trace_paiement);
|
||||
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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`type` char(1) COLLATE utf8_bin NOT NULL DEFAULT 'U'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Triggers `comptes`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tai_comptes` AFTER INSERT ON `comptes` FOR EACH ROW insert into panier values(NEW.id_compte, null, null)
|
||||
$$
|
||||
DELIMITER ;
|
||||
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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `datescommandes`
|
||||
--
|
||||
|
||||
INSERT INTO `datescommandes` (`date_debut`, `date_fin`, `nom`) VALUES
|
||||
('2018-11-24 00:00:00', '2018-11-26 00:00:00', 'test');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `events`
|
||||
--
|
||||
|
||||
INSERT INTO `events` (`id`, `title`, `color`, `start`, `end`) VALUES
|
||||
(15, 'test', '#0071c5', '2018-11-24 00:00:00', '2018-11-26 00:00:00'),
|
||||
(16, 'test2', '#0071c5', '2018-11-29 00:00:00', '2018-11-29 01:00:00');
|
||||
|
||||
--
|
||||
-- Triggers `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, 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 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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `succursale`, `nom_contact`, `adresse`, `ville`, `code_postal`, `telephone`, `tel_poste`) VALUES
|
||||
(2, 'Metro', '', '', '123 lol', '', '', NULL, '');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fraisgestion`
|
||||
--
|
||||
|
||||
CREATE TABLE `fraisgestion` (
|
||||
`id_frais` int(11) NOT NULL,
|
||||
`frais` decimal(4,3) NOT NULL DEFAULT '0.000'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Triggers `fraisgestion`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbi_fraisgestion` BEFORE INSERT ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
DELIMITER ;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbu_fraisgestion` BEFORE UPDATE ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `historiquecommandeproduit`
|
||||
--
|
||||
|
||||
CREATE TABLE `historiquecommandeproduit` (
|
||||
`id_historique` int(11) DEFAULT NULL,
|
||||
`id_produit` int(11) DEFAULT 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
|
||||
) 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(4,3) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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 `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(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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Triggers `produits`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tau_produits` AFTER UPDATE ON `produits` FOR EACH ROW begin
|
||||
|
||||
call updatelimiteproduit(new.id_produit, new.limite_achat);
|
||||
|
||||
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
|
||||
) 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 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 `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 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 for table `events`
|
||||
--
|
||||
ALTER TABLE `events`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- 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 for table `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
MODIFY `id_historique` 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 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 `historiquecommandeproduit__fk` 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 `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 */;
|
||||
@@ -0,0 +1,752 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.8.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 27, 2018 at 02:20 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`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes'),
|
||||
(2, 'Viandes');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `commandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandes` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`status` char(1) COLLATE utf8_bin NOT NULL,
|
||||
`prix_total` decimal(5,3) 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 v_nom varchar(255);
|
||||
declare v_prenom varchar(255);
|
||||
declare v_courriel varchar(255);
|
||||
|
||||
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,
|
||||
v_nom,
|
||||
v_prenom,
|
||||
v_courriel,
|
||||
new.date,
|
||||
new.status,
|
||||
new.prix_total,
|
||||
new.trace_paiement);
|
||||
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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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`, `type`) VALUES
|
||||
(16, '[email protected]', '$2y$10$.mB/c0ntseE6/FtaFkZ3n.rze9Bt7vEGi7A0sHtZZnCV3BG1yye6K', 'Admin', 'Admindddddddddddddddddddddddd', '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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`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 `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 ;
|
||||
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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `succursale`, `nom_contact`, `adresse`, `ville`, `code_postal`, `telephone`, `tel_poste`) VALUES
|
||||
(2, 'Metro', '', '', '123 lol', '', '', NULL, '');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fraisgestion`
|
||||
--
|
||||
|
||||
CREATE TABLE `fraisgestion` (
|
||||
`id_frais` int(11) NOT NULL,
|
||||
`frais` decimal(4,3) NOT NULL DEFAULT '0.000'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Triggers `fraisgestion`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbi_fraisgestion` BEFORE INSERT ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
DELIMITER ;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbu_fraisgestion` BEFORE UPDATE ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `historiquecommandeproduit`
|
||||
--
|
||||
|
||||
CREATE TABLE `historiquecommandeproduit` (
|
||||
`id_historique` int(11) DEFAULT NULL,
|
||||
`id_produit` int(11) DEFAULT 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
|
||||
) 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(4,3) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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 `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(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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Triggers `produits`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tau_produits` AFTER UPDATE ON `produits` FOR EACH ROW begin
|
||||
|
||||
call updatelimiteproduit(new.id_produit, new.limite_achat);
|
||||
|
||||
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
|
||||
) 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 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 `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=3;
|
||||
|
||||
--
|
||||
-- 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=19;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `events`
|
||||
--
|
||||
ALTER TABLE `events`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- 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 for table `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
MODIFY `id_historique` 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 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 `historiquecommandeproduit__fk` 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 `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 */;
|
||||
@@ -0,0 +1,886 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.8.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 28, 2018 at 02:21 AM
|
||||
-- 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 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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes'),
|
||||
(2, 'Viandes'),
|
||||
(3, 'Divers');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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_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 (0,
|
||||
new.id_commande,
|
||||
new.id_compte,
|
||||
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 ;
|
||||
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
|
||||
|
||||
declare num varchar(1024);
|
||||
|
||||
set new.date = now();
|
||||
select CONCAT('DIET-', FLOOR(5 + RAND() * 60), '1', REPLACE(CURDATE(), '-', '')) into num from dual;
|
||||
set new.numero_commande = num;
|
||||
|
||||
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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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`, `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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `datescommandes`
|
||||
--
|
||||
|
||||
INSERT INTO `datescommandes` (`date_debut`, `date_fin`, `nom`) VALUES
|
||||
('2018-11-24 00:00:00', '2018-11-26 00:00:00', 'test');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `events`
|
||||
--
|
||||
|
||||
INSERT INTO `events` (`id`, `title`, `color`, `start`, `end`) VALUES
|
||||
(15, 'test', '#0071c5', '2018-11-24 00:00:00', '2018-11-26 00:00:00'),
|
||||
(16, 'test2', '#0071c5', '2018-11-29 00:00:00', '2018-11-29 01:00:00');
|
||||
|
||||
--
|
||||
-- Triggers `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 ;
|
||||
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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `succursale`, `nom_contact`, `adresse`, `ville`, `code_postal`, `telephone`, `tel_poste`) VALUES
|
||||
(2, 'Metro', '', '', '123 lol', '', '', NULL, '');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fraisgestion`
|
||||
--
|
||||
|
||||
CREATE TABLE `fraisgestion` (
|
||||
`id_frais` int(11) NOT NULL,
|
||||
`frais` decimal(4,3) NOT NULL DEFAULT '0.000'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fraisgestion`
|
||||
--
|
||||
|
||||
INSERT INTO `fraisgestion` (`id_frais`, `frais`) VALUES
|
||||
(1, '1.150');
|
||||
|
||||
--
|
||||
-- Triggers `fraisgestion`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbi_fraisgestion` BEFORE INSERT ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
DELIMITER ;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbu_fraisgestion` BEFORE UPDATE ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
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,
|
||||
`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
|
||||
) 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_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(4,3) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `historiquefraisgestion`
|
||||
--
|
||||
|
||||
INSERT INTO `historiquefraisgestion` (`id_frais`, `date`, `frais`) VALUES
|
||||
(1, '2018-11-27 08:34:41', '1.150');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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 `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(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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for 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', 4, '', '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');
|
||||
|
||||
--
|
||||
-- Triggers `produits`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tau_produits` AFTER UPDATE ON `produits` FOR EACH ROW begin
|
||||
|
||||
call updatelimiteproduit(new.id_produit, new.limite_achat);
|
||||
|
||||
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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `produitsfournisseurs` (`id_produit`, `id_fournisseur`, `prix`, `economie`) VALUES
|
||||
(6, 2, '5.00', NULL),
|
||||
(7, 2, '10.00', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 `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=12;
|
||||
|
||||
--
|
||||
-- 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=21;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `events`
|
||||
--
|
||||
ALTER TABLE `events`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- 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=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
MODIFY `id_historique` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `produits`
|
||||
--
|
||||
ALTER TABLE `produits`
|
||||
MODIFY `id_produit` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
|
||||
|
||||
--
|
||||
-- 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 `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 */;
|
||||
@@ -0,0 +1,884 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.8.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 28, 2018 at 10:47 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 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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes'),
|
||||
(2, 'Viandes'),
|
||||
(3, 'Divers');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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_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 (0,
|
||||
new.id_commande,
|
||||
new.id_compte,
|
||||
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 ;
|
||||
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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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`, `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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `datescommandes`
|
||||
--
|
||||
|
||||
INSERT INTO `datescommandes` (`date_debut`, `date_fin`, `nom`) VALUES
|
||||
('2018-11-24 00:00:00', '2018-11-26 00:00:00', 'test');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `events`
|
||||
--
|
||||
|
||||
INSERT INTO `events` (`id`, `title`, `color`, `start`, `end`) VALUES
|
||||
(15, 'test', '#0071c5', '2018-11-24 00:00:00', '2018-11-26 00:00:00'),
|
||||
(16, 'test2', '#0071c5', '2018-11-29 00:00:00', '2018-11-29 01:00:00');
|
||||
|
||||
--
|
||||
-- Triggers `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 ;
|
||||
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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `succursale`, `nom_contact`, `adresse`, `ville`, `code_postal`, `telephone`, `tel_poste`) VALUES
|
||||
(2, 'Metro', '', '', '123 lol', '', '', NULL, '');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fraisgestion`
|
||||
--
|
||||
|
||||
CREATE TABLE `fraisgestion` (
|
||||
`id_frais` int(11) NOT NULL,
|
||||
`frais` decimal(4,3) NOT NULL DEFAULT '0.000'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fraisgestion`
|
||||
--
|
||||
|
||||
INSERT INTO `fraisgestion` (`id_frais`, `frais`) VALUES
|
||||
(1, '1.000');
|
||||
|
||||
--
|
||||
-- Triggers `fraisgestion`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbi_fraisgestion` BEFORE INSERT ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
DELIMITER ;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbu_fraisgestion` BEFORE UPDATE ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
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,
|
||||
`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
|
||||
) 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_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(4,3) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `historiquefraisgestion`
|
||||
--
|
||||
|
||||
INSERT INTO `historiquefraisgestion` (`id_frais`, `date`, `frais`) VALUES
|
||||
(1, '2018-11-28 16:46:21', '1.000');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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 `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(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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for 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', 4, '', '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');
|
||||
|
||||
--
|
||||
-- Triggers `produits`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tau_produits` AFTER UPDATE ON `produits` FOR EACH ROW begin
|
||||
|
||||
call updatelimiteproduit(new.id_produit, new.limite_achat);
|
||||
|
||||
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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `produitsfournisseurs` (`id_produit`, `id_fournisseur`, `prix`, `economie`) VALUES
|
||||
(6, 2, '5.00', NULL),
|
||||
(7, 2, '10.00', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 `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=17;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- 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=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
MODIFY `id_historique` 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=8;
|
||||
|
||||
--
|
||||
-- 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 `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 */;
|
||||
@@ -0,0 +1,891 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.8.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 29, 2018 at 10:50 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 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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes'),
|
||||
(2, 'Viandes'),
|
||||
(3, 'Divers');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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_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,
|
||||
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 ;
|
||||
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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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`, `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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `datescommandes`
|
||||
--
|
||||
|
||||
INSERT INTO `datescommandes` (`date_debut`, `date_fin`, `nom`) VALUES
|
||||
('2018-11-24 00:00:00', '2018-11-26 00:00:00', 'test');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `events`
|
||||
--
|
||||
|
||||
INSERT INTO `events` (`id`, `title`, `color`, `start`, `end`) VALUES
|
||||
(15, 'test', '#0071c5', '2018-11-24 00:00:00', '2018-11-26 00:00:00'),
|
||||
(16, 'test2', '#0071c5', '2018-11-29 00:00:00', '2018-11-29 01:00:00');
|
||||
|
||||
--
|
||||
-- Triggers `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 ;
|
||||
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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `succursale`, `nom_contact`, `adresse`, `ville`, `code_postal`, `telephone`, `tel_poste`) VALUES
|
||||
(2, 'Metro', 'Fournier', NULL, '850 Boulevard Thibeau', 'Trois-Rivières', 'G8T7A6', '8193763028', '');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fraisgestion`
|
||||
--
|
||||
|
||||
CREATE TABLE `fraisgestion` (
|
||||
`id_frais` int(11) NOT NULL,
|
||||
`frais` decimal(4,3) NOT NULL DEFAULT '0.000'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fraisgestion`
|
||||
--
|
||||
|
||||
INSERT INTO `fraisgestion` (`id_frais`, `frais`) VALUES
|
||||
(1, '1.000');
|
||||
|
||||
--
|
||||
-- Triggers `fraisgestion`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbi_fraisgestion` BEFORE INSERT ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
DELIMITER ;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbu_fraisgestion` BEFORE UPDATE ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
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_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_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(4,3) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `historiquefraisgestion`
|
||||
--
|
||||
|
||||
INSERT INTO `historiquefraisgestion` (`id_frais`, `date`, `frais`) VALUES
|
||||
(1, '2018-11-28 16:46:21', '1.000');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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 `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(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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for 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');
|
||||
|
||||
--
|
||||
-- Triggers `produits`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tau_produits` AFTER UPDATE ON `produits` FOR EACH ROW begin
|
||||
|
||||
call updatelimiteproduit(new.id_produit, new.limite_achat);
|
||||
|
||||
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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `produitsfournisseurs` (`id_produit`, `id_fournisseur`, `prix`, `economie`) VALUES
|
||||
(6, 2, '0.00', NULL),
|
||||
(7, 2, '10.00', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 `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=17;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- 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=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
MODIFY `id_historique` 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=12;
|
||||
|
||||
--
|
||||
-- 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 `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 */;
|
||||
@@ -0,0 +1,894 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.8.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 30, 2018 at 12:18 AM
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`, `actif`) VALUES
|
||||
(1, 'Fruits et Légumes', 0),
|
||||
(2, 'Viandes', 1),
|
||||
(3, 'Divers', 1);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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_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 ;
|
||||
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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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`, `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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `datescommandes`
|
||||
--
|
||||
|
||||
INSERT INTO `datescommandes` (`date_debut`, `date_fin`, `nom`) VALUES
|
||||
('2018-11-24 00:00:00', '2018-11-26 00:00:00', 'test');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `events`
|
||||
--
|
||||
|
||||
INSERT INTO `events` (`id`, `title`, `color`, `start`, `end`) VALUES
|
||||
(15, 'test', '#0071c5', '2018-11-24 00:00:00', '2018-11-26 00:00:00'),
|
||||
(16, 'test2', '#0071c5', '2018-11-29 00:00:00', '2018-11-29 01:00:00');
|
||||
|
||||
--
|
||||
-- Triggers `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 ;
|
||||
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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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;
|
||||
|
||||
--
|
||||
-- Dumping data for 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);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fraisgestion`
|
||||
--
|
||||
|
||||
CREATE TABLE `fraisgestion` (
|
||||
`id_frais` int(11) NOT NULL,
|
||||
`frais` decimal(4,3) NOT NULL DEFAULT '0.000'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fraisgestion`
|
||||
--
|
||||
|
||||
INSERT INTO `fraisgestion` (`id_frais`, `frais`) VALUES
|
||||
(1, '1.000');
|
||||
|
||||
--
|
||||
-- Triggers `fraisgestion`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbi_fraisgestion` BEFORE INSERT ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
DELIMITER ;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tbu_fraisgestion` BEFORE UPDATE ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais)
|
||||
$$
|
||||
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_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_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(4,3) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `historiquefraisgestion`
|
||||
--
|
||||
|
||||
INSERT INTO `historiquefraisgestion` (`id_frais`, `date`, `frais`) VALUES
|
||||
(1, '2018-11-28 16:46:21', '1.000');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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 `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(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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for 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');
|
||||
|
||||
--
|
||||
-- Triggers `produits`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tau_produits` AFTER UPDATE ON `produits` FOR EACH ROW begin
|
||||
|
||||
call updatelimiteproduit(new.id_produit, new.limite_achat);
|
||||
|
||||
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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `produitsfournisseurs` (`id_produit`, `id_fournisseur`, `prix`, `economie`) VALUES
|
||||
(6, 2, '0.00', NULL),
|
||||
(7, 2, '10.00', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 `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=17;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- 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=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
MODIFY `id_historique` 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=12;
|
||||
|
||||
--
|
||||
-- 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 `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 */;
|
||||
@@ -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 */;
|
||||
@@ -0,0 +1,989 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.8.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Dec 05, 2018 at 09:55 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 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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`, `actif`) VALUES
|
||||
(1, 'Fruits et Légumes', 1),
|
||||
(2, 'Viandes', 1),
|
||||
(3, 'Divers', 1);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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_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
|
||||
|
||||
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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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`, `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', 'Voici notre fonctionnement'),
|
||||
('mission', 'Salut, ceci est notre mission');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`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;
|
||||
|
||||
--
|
||||
-- Dumping data for 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');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for 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');
|
||||
|
||||
--
|
||||
-- Triggers `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 ;
|
||||
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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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;
|
||||
|
||||
--
|
||||
-- Dumping data for 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);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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.100', 'pourcentage', 1),
|
||||
(2, '3.000', 'fixe', 0);
|
||||
|
||||
--
|
||||
-- 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_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_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-03 00:12:53', '1.090', 'pourcentage', 1),
|
||||
(1, '2018-12-03 00:22:48', '1.100', 'pourcentage', 1),
|
||||
(1, '2018-12-03 00:23:35', '1.100', 'pourcentage', 1),
|
||||
(1, '2018-12-03 00:23:38', '1.100', 'pourcentage', 1),
|
||||
(1, '2018-12-03 00:23:54', '1.100', 'pourcentage', 1),
|
||||
(1, '2018-12-03 01:01:03', '1.100', 'pourcentage', 1),
|
||||
(1, '2018-12-03 01:18:51', '1.100', 'pourcentage', 1),
|
||||
(2, '2018-12-03 00:12:57', '3.000', 'fixe', 1),
|
||||
(2, '2018-12-03 00:14:31', '3.000', 'fixe', 1),
|
||||
(2, '2018-12-03 00:23:02', '3.000', 'fixe', 1),
|
||||
(2, '2018-12-03 01:23:04', '3.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) COLLATE utf8_bin 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(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,
|
||||
`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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `produits`
|
||||
--
|
||||
|
||||
INSERT INTO `produits` (`id_produit`, `nom`, `description`, `marque`, `achat_minimum`, `economie`, `image_produit`, `valeur_nutritive`, `format`, `unite`, `limite_achat`, `categorie`, `frais_fixe`, `id_compte`, `status`) VALUES
|
||||
(6, 'Farine', 'Une bonne farine', 'Francine', 5, '', 'uploads_5bfd4b8be02ad7.90388594.jpg', NULL, 1, '1', 5, 3, '0.00', NULL, 'A'),
|
||||
(7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, '', 'uploads_5bf716ec8045c1.37408180.jpg', NULL, 1, '1', 0, 2, '0.00', NULL, 'A');
|
||||
|
||||
--
|
||||
-- Triggers `produits`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tau_produits` AFTER UPDATE ON `produits` FOR EACH ROW begin
|
||||
|
||||
call updatelimiteproduit(new.id_produit, new.limite_achat);
|
||||
|
||||
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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `produitsfournisseurs` (`id_produit`, `id_fournisseur`, `prix`, `economie`) VALUES
|
||||
(6, 2, '12.00', NULL),
|
||||
(7, 2, '10.00', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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`);
|
||||
|
||||
--
|
||||
-- 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=2;
|
||||
|
||||
--
|
||||
-- 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=17;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- 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=2;
|
||||
|
||||
--
|
||||
-- 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=8;
|
||||
|
||||
--
|
||||
-- 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 `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 */;
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,974 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.6.4
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Client : 127.0.0.1
|
||||
-- Généré le : Jeu 06 Décembre 2018 à 18:54
|
||||
-- Version du serveur : 5.7.14
|
||||
-- Version de PHP : 7.0.10
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
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
|
||||
--
|
||||
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`
|
||||
--
|
||||
|
||||
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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la 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;
|
||||
|
||||
--
|
||||
-- Contenu de la table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`, `actif`) VALUES
|
||||
(1, 'Fruits et Légumes', 1),
|
||||
(2, 'Viandes', 1),
|
||||
(3, 'Divers', 1);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la 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;
|
||||
|
||||
--
|
||||
-- Déclencheurs `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);
|
||||
|
||||
|
||||
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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la 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;
|
||||
|
||||
--
|
||||
-- Déclencheurs `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_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`
|
||||
--
|
||||
|
||||
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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la 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` int(11) DEFAULT NULL,
|
||||
`type` char(1) COLLATE utf8_bin NOT NULL DEFAULT 'U'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Contenu de la 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', NULL, 'A');
|
||||
|
||||
--
|
||||
-- Déclencheurs `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`
|
||||
--
|
||||
|
||||
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;
|
||||
|
||||
--
|
||||
-- Contenu 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`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`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;
|
||||
|
||||
--
|
||||
-- Contenu 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`
|
||||
--
|
||||
|
||||
CREATE TABLE `datespaiements` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la 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;
|
||||
|
||||
--
|
||||
-- Contenu 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`
|
||||
--
|
||||
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 ;
|
||||
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`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Contenu de la table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la 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(40) 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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Contenu de la table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `succursale`, `nom_contact`, `role`, `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`
|
||||
--
|
||||
|
||||
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;
|
||||
|
||||
--
|
||||
-- Contenu 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`
|
||||
--
|
||||
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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la 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_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;
|
||||
|
||||
--
|
||||
-- Déclencheurs `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`
|
||||
--
|
||||
|
||||
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_categorie` varchar(255) COLLATE utf8_bin DEFAULT NULL,
|
||||
`quantite` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la 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;
|
||||
|
||||
--
|
||||
-- Contenu de la table `historiquefraisgestion`
|
||||
--
|
||||
|
||||
INSERT INTO `historiquefraisgestion` (`id_frais`, `date`, `frais`, `type`, `actif`) VALUES
|
||||
(1, '2018-12-03 00:12:53', '1.090', 'pourcentage', 1),
|
||||
(1, '2018-12-03 00:22:48', '1.100', 'pourcentage', 1),
|
||||
(1, '2018-12-03 00:23:35', '1.100', 'pourcentage', 1),
|
||||
(1, '2018-12-03 00:23:38', '1.100', 'pourcentage', 1),
|
||||
(1, '2018-12-03 00:23:54', '1.100', 'pourcentage', 1),
|
||||
(1, '2018-12-03 01:01:03', '1.100', 'pourcentage', 1),
|
||||
(1, '2018-12-03 01:18:51', '1.100', 'pourcentage', 1),
|
||||
(2, '2018-12-03 00:12:57', '3.000', 'fixe', 1),
|
||||
(2, '2018-12-03 00:14:31', '3.000', 'fixe', 1),
|
||||
(2, '2018-12-03 00:23:02', '3.000', 'fixe', 1),
|
||||
(2, '2018-12-03 01:23:04', '3.000', 'fixe', 1);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la 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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la 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) COLLATE utf8_bin DEFAULT NULL,
|
||||
`expires` datetime DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la 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(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,
|
||||
`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;
|
||||
|
||||
--
|
||||
-- Contenu de la table `produits`
|
||||
--
|
||||
|
||||
INSERT INTO `produits` (`id_produit`, `nom`, `description`, `marque`, `achat_minimum`, `economie`, `image_produit`, `valeur_nutritive`, `format`, `unite`, `limite_achat`, `categorie`, `frais_fixe`, `id_compte`, `status`) VALUES
|
||||
(6, 'Farine', 'Une bonne farine', 'Francine', 5, '', 'uploads_5bfd4b8be02ad7.90388594.jpg', NULL, 1, '1', 5, 3, '0.00', NULL, 'A'),
|
||||
(7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, '', 'uploads_5bf716ec8045c1.37408180.jpg', NULL, 1, '1', 0, 2, '0.00', NULL, 'A');
|
||||
|
||||
--
|
||||
-- Déclencheurs `produits`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tau_produits` AFTER UPDATE ON `produits` FOR EACH ROW begin
|
||||
|
||||
call updatelimiteproduit(new.id_produit, new.limite_achat);
|
||||
|
||||
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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la 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;
|
||||
|
||||
--
|
||||
-- Contenu 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`
|
||||
--
|
||||
|
||||
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;
|
||||
|
||||
--
|
||||
-- Index pour les tables exportées
|
||||
--
|
||||
|
||||
--
|
||||
-- Index pour la table `access_token`
|
||||
--
|
||||
ALTER TABLE `access_token`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Index pour la table `categorie`
|
||||
--
|
||||
ALTER TABLE `categorie`
|
||||
ADD PRIMARY KEY (`id_categorie`);
|
||||
|
||||
--
|
||||
-- Index pour la 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`);
|
||||
|
||||
--
|
||||
-- Index pour la table `commandesproduits`
|
||||
--
|
||||
ALTER TABLE `commandesproduits`
|
||||
ADD PRIMARY KEY (`id_commande`,`id_produit`),
|
||||
ADD KEY `CommandesProduits_fk1` (`id_produit`);
|
||||
|
||||
--
|
||||
-- Index pour la table `commentaires`
|
||||
--
|
||||
ALTER TABLE `commentaires`
|
||||
ADD PRIMARY KEY (`id_commentaire`,`id_compte`),
|
||||
ADD KEY `Commentaires_fk0` (`id_compte`);
|
||||
|
||||
--
|
||||
-- Index pour la table `comptes`
|
||||
--
|
||||
ALTER TABLE `comptes`
|
||||
ADD PRIMARY KEY (`id_compte`),
|
||||
ADD KEY `id_compte` (`id_compte`);
|
||||
|
||||
--
|
||||
-- Index pour la table `configuration`
|
||||
--
|
||||
ALTER TABLE `configuration`
|
||||
ADD PRIMARY KEY (`cle`);
|
||||
|
||||
--
|
||||
-- Index pour la table `datescommandes`
|
||||
--
|
||||
ALTER TABLE `datescommandes`
|
||||
ADD PRIMARY KEY (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- Index pour la table `datespaiements`
|
||||
--
|
||||
ALTER TABLE `datespaiements`
|
||||
ADD PRIMARY KEY (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- Index pour la table `events`
|
||||
--
|
||||
ALTER TABLE `events`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Index pour la table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
ADD PRIMARY KEY (`id_format`),
|
||||
ADD KEY `id_format` (`id_format`);
|
||||
|
||||
--
|
||||
-- Index pour la table `fournisseurs`
|
||||
--
|
||||
ALTER TABLE `fournisseurs`
|
||||
ADD PRIMARY KEY (`id_fournisseur`);
|
||||
|
||||
--
|
||||
-- Index pour la table `fraisgestion`
|
||||
--
|
||||
ALTER TABLE `fraisgestion`
|
||||
ADD PRIMARY KEY (`id_frais`);
|
||||
|
||||
--
|
||||
-- Index pour la table `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
ADD PRIMARY KEY (`id_historique`);
|
||||
|
||||
--
|
||||
-- Index pour la table `historiquecommandeproduit`
|
||||
--
|
||||
ALTER TABLE `historiquecommandeproduit`
|
||||
ADD PRIMARY KEY (`id_historique`,`id_produit`),
|
||||
ADD KEY `historiquecommandeproduit_id_historique_index` (`id_historique`);
|
||||
|
||||
--
|
||||
-- Index pour la table `historiquefraisgestion`
|
||||
--
|
||||
ALTER TABLE `historiquefraisgestion`
|
||||
ADD PRIMARY KEY (`id_frais`,`date`);
|
||||
|
||||
--
|
||||
-- Index pour la 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`);
|
||||
|
||||
--
|
||||
-- Index pour la table `password_resets`
|
||||
--
|
||||
ALTER TABLE `password_resets`
|
||||
ADD PRIMARY KEY (`id_reset`);
|
||||
|
||||
--
|
||||
-- Index pour la 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`);
|
||||
|
||||
--
|
||||
-- Index pour la table `produitsfournisseurs`
|
||||
--
|
||||
ALTER TABLE `produitsfournisseurs`
|
||||
ADD PRIMARY KEY (`id_produit`,`id_fournisseur`),
|
||||
ADD KEY `ProduitsFournisseurs_fk1` (`id_fournisseur`);
|
||||
|
||||
--
|
||||
-- Index pour la table `tracepaiements`
|
||||
--
|
||||
ALTER TABLE `tracepaiements`
|
||||
ADD PRIMARY KEY (`id_paiement`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour les tables exportées
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `access_token`
|
||||
--
|
||||
ALTER TABLE `access_token`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `categorie`
|
||||
--
|
||||
ALTER TABLE `categorie`
|
||||
MODIFY `id_categorie` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `commandes`
|
||||
--
|
||||
ALTER TABLE `commandes`
|
||||
MODIFY `id_commande` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `commentaires`
|
||||
--
|
||||
ALTER TABLE `commentaires`
|
||||
MODIFY `id_commentaire` int(11) NOT NULL AUTO_INCREMENT;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `comptes`
|
||||
--
|
||||
ALTER TABLE `comptes`
|
||||
MODIFY `id_compte` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `events`
|
||||
--
|
||||
ALTER TABLE `events`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `fournisseurs`
|
||||
--
|
||||
ALTER TABLE `fournisseurs`
|
||||
MODIFY `id_fournisseur` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `fraisgestion`
|
||||
--
|
||||
ALTER TABLE `fraisgestion`
|
||||
MODIFY `id_frais` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
MODIFY `id_historique` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `password_resets`
|
||||
--
|
||||
ALTER TABLE `password_resets`
|
||||
MODIFY `id_reset` int(11) NOT NULL AUTO_INCREMENT;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `produits`
|
||||
--
|
||||
ALTER TABLE `produits`
|
||||
MODIFY `id_produit` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `tracepaiements`
|
||||
--
|
||||
ALTER TABLE `tracepaiements`
|
||||
MODIFY `id_paiement` int(11) NOT NULL AUTO_INCREMENT;
|
||||
--
|
||||
-- Contraintes pour les tables exporté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`);
|
||||
|
||||
/*!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 */;
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,422 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.5.4.1
|
||||
-- http://www.phpmyadmin.net
|
||||
--
|
||||
-- Client : localhost
|
||||
-- Généré le : Sam 10 Novembre 2018 à 03:48
|
||||
-- Version du serveur : 5.7.11
|
||||
-- Version de PHP : 7.0.3
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
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`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `access_token`
|
||||
--
|
||||
|
||||
CREATE TABLE `access_token` (
|
||||
`id` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`selector` char(16) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`token` char(64) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`expires` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `categorie`
|
||||
--
|
||||
|
||||
CREATE TABLE `categorie` (
|
||||
`id_categorie` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Contenu de la table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `commandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandes` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`status` char(1) CHARACTER SET latin1 NOT NULL,
|
||||
`prix_total` decimal(5,3) NOT NULL,
|
||||
`trace_paiement` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `commandesproduits`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandesproduits` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_produit` int(11) NOT NULL,
|
||||
`quantité` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `commentaires`
|
||||
--
|
||||
|
||||
CREATE TABLE `commentaires` (
|
||||
`id_commentaire` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`commentaire` varchar(2048) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `comptes`
|
||||
--
|
||||
|
||||
CREATE TABLE `comptes` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`courriel` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`password` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`prenom` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`telephone` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`type` char(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Déclencheurs `comptes`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tai_comptes` AFTER INSERT ON `comptes` FOR EACH ROW insert into panier values(NEW.id_compte, null, null)
|
||||
$$
|
||||
DELIMITER ;
|
||||
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`
|
||||
--
|
||||
|
||||
CREATE TABLE `configuration` (
|
||||
`cle` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`valeur` varchar(4096) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `datespaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `datespaiements` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `fournisseurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `fournisseurs` (
|
||||
`id_fournisseur` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`adresse` varchar(1024) CHARACTER SET latin1 NOT NULL,
|
||||
`telephone` varchar(30) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `panier`
|
||||
--
|
||||
|
||||
CREATE TABLE `panier` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`id_produit` int(11) DEFAULT NULL,
|
||||
`quantite` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `produits`
|
||||
--
|
||||
|
||||
CREATE TABLE `produits` (
|
||||
`id_produit` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`description` varchar(1024) CHARACTER SET latin1 NOT NULL,
|
||||
`marque` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`achat_minimum` int(10) NOT NULL,
|
||||
`economie` decimal(4,2) DEFAULT NULL,
|
||||
`image_produit` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`valeur_nutritive` varchar(1024) CHARACTER SET latin1 DEFAULT NULL,
|
||||
`format` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`unite` varchar(15) CHARACTER SET latin1 NOT NULL,
|
||||
`limite_achat` int(11) DEFAULT NULL,
|
||||
`categorie` int(11) NOT NULL,
|
||||
`id_compte` int(11) DEFAULT NULL,
|
||||
`status` char(1) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Contenu 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
|
||||
(1, 'test produit', 'Ceci est un beau test', 'Costco', 6, NULL, NULL, NULL, 'kg', '2', 50, 1, NULL, 'A');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `produitsfournisseurs` (
|
||||
`id_produit` int(11) NOT NULL,
|
||||
`id_fournisseur` int(11) NOT NULL,
|
||||
`prix` decimal(5,3) NOT NULL,
|
||||
`economie` decimal(4,2) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Index pour les tables exportées
|
||||
--
|
||||
|
||||
--
|
||||
-- Index pour la table `access_token`
|
||||
--
|
||||
ALTER TABLE `access_token`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Index pour la table `categorie`
|
||||
--
|
||||
ALTER TABLE `categorie`
|
||||
ADD PRIMARY KEY (`id_categorie`);
|
||||
|
||||
--
|
||||
-- Index pour la table `commandes`
|
||||
--
|
||||
ALTER TABLE `commandes`
|
||||
ADD PRIMARY KEY (`id_commande`,`id_compte`),
|
||||
ADD KEY `Commandes_fk0` (`id_compte`),
|
||||
ADD KEY `Commandes_fk1` (`trace_paiement`);
|
||||
|
||||
--
|
||||
-- Index pour la table `commandesproduits`
|
||||
--
|
||||
ALTER TABLE `commandesproduits`
|
||||
ADD PRIMARY KEY (`id_commande`,`id_produit`),
|
||||
ADD KEY `CommandesProduits_fk1` (`id_produit`);
|
||||
|
||||
--
|
||||
-- Index pour la table `commentaires`
|
||||
--
|
||||
ALTER TABLE `commentaires`
|
||||
ADD PRIMARY KEY (`id_commentaire`,`id_compte`),
|
||||
ADD KEY `Commentaires_fk0` (`id_compte`);
|
||||
|
||||
--
|
||||
-- Index pour la table `comptes`
|
||||
--
|
||||
ALTER TABLE `comptes`
|
||||
ADD PRIMARY KEY (`id_compte`),
|
||||
ADD KEY `id_compte` (`id_compte`);
|
||||
|
||||
--
|
||||
-- Index pour la table `configuration`
|
||||
--
|
||||
ALTER TABLE `configuration`
|
||||
ADD PRIMARY KEY (`cle`);
|
||||
|
||||
--
|
||||
-- Index pour la table `datescommandes`
|
||||
--
|
||||
ALTER TABLE `datescommandes`
|
||||
ADD PRIMARY KEY (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- Index pour la table `datespaiements`
|
||||
--
|
||||
ALTER TABLE `datespaiements`
|
||||
ADD PRIMARY KEY (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- Index pour la table `fournisseurs`
|
||||
--
|
||||
ALTER TABLE `fournisseurs`
|
||||
ADD PRIMARY KEY (`id_fournisseur`);
|
||||
|
||||
--
|
||||
-- Index pour la table `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD PRIMARY KEY (`id_compte`) USING BTREE,
|
||||
ADD KEY `Panier_fk0` (`id_produit`);
|
||||
|
||||
--
|
||||
-- Index pour la table `produits`
|
||||
--
|
||||
ALTER TABLE `produits`
|
||||
ADD PRIMARY KEY (`id_produit`),
|
||||
ADD KEY `Produits_fk0` (`categorie`),
|
||||
ADD KEY `Produits_fk1` (`id_compte`);
|
||||
|
||||
--
|
||||
-- Index pour la table `produitsfournisseurs`
|
||||
--
|
||||
ALTER TABLE `produitsfournisseurs`
|
||||
ADD PRIMARY KEY (`id_produit`,`id_fournisseur`),
|
||||
ADD KEY `ProduitsFournisseurs_fk1` (`id_fournisseur`);
|
||||
|
||||
--
|
||||
-- Index pour la table `tracepaiements`
|
||||
--
|
||||
ALTER TABLE `tracepaiements`
|
||||
ADD PRIMARY KEY (`id_paiement`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour les tables exportées
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `access_token`
|
||||
--
|
||||
ALTER TABLE `access_token`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `categorie`
|
||||
--
|
||||
ALTER TABLE `categorie`
|
||||
MODIFY `id_categorie` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `commandes`
|
||||
--
|
||||
ALTER TABLE `commandes`
|
||||
MODIFY `id_commande` int(11) NOT NULL AUTO_INCREMENT;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `commentaires`
|
||||
--
|
||||
ALTER TABLE `commentaires`
|
||||
MODIFY `id_commentaire` int(11) NOT NULL AUTO_INCREMENT;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `comptes`
|
||||
--
|
||||
ALTER TABLE `comptes`
|
||||
MODIFY `id_compte` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `fournisseurs`
|
||||
--
|
||||
ALTER TABLE `fournisseurs`
|
||||
MODIFY `id_fournisseur` int(11) NOT NULL AUTO_INCREMENT;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `produits`
|
||||
--
|
||||
ALTER TABLE `produits`
|
||||
MODIFY `id_produit` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `tracepaiements`
|
||||
--
|
||||
ALTER TABLE `tracepaiements`
|
||||
MODIFY `id_paiement` int(11) NOT NULL AUTO_INCREMENT;
|
||||
--
|
||||
-- Contraintes pour les tables exporté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 `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD CONSTRAINT `Panier_fk0` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`),
|
||||
ADD CONSTRAINT `panier_ibfk_1` FOREIGN KEY (`id_compte`) REFERENCES `comptes` (`id_compte`);
|
||||
|
||||
--
|
||||
-- Contraintes pour la table `produits`
|
||||
--
|
||||
ALTER TABLE `produits`
|
||||
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`);
|
||||
|
||||
/*!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 */;
|
||||
@@ -0,0 +1,461 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.6.5.2
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 14, 2018 at 01:49 PM
|
||||
-- Server version: 10.1.21-MariaDB
|
||||
-- PHP Version: 7.1.1
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
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`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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 utf8mb4_unicode_ci NOT NULL,
|
||||
`token` char(64) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`expires` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `categorie`
|
||||
--
|
||||
|
||||
CREATE TABLE `categorie` (
|
||||
`id_categorie` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `commandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandes` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`status` char(1) CHARACTER SET latin1 NOT NULL,
|
||||
`prix_total` decimal(5,3) NOT NULL,
|
||||
`trace_paiement` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `commandesproduits`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandesproduits` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_produit` int(11) NOT NULL,
|
||||
`quantité` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `comptes`
|
||||
--
|
||||
|
||||
CREATE TABLE `comptes` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`courriel` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`password` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`prenom` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`telephone` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`type` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'U'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `comptes`
|
||||
--
|
||||
|
||||
INSERT INTO `comptes` (`id_compte`, `courriel`, `password`, `nom`, `prenom`, `telephone`, `type`) VALUES
|
||||
(13, '[email protected]', '$2y$10$MScllzuG8gxIGoib2YlUBuoJnrq3.i6BFqNn0QTKGQHMyqCXhT43.', 'Robert', 'Anthony', '8199447206', 'A');
|
||||
|
||||
--
|
||||
-- Triggers `comptes`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tai_comptes` AFTER INSERT ON `comptes` FOR EACH ROW insert into panier values(NEW.id_compte, null, null)
|
||||
$$
|
||||
DELIMITER ;
|
||||
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) CHARACTER SET latin1 NOT NULL,
|
||||
`valeur` varchar(4096) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datespaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `datespaiements` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fournisseurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `fournisseurs` (
|
||||
`id_fournisseur` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`adresse` varchar(1024) CHARACTER SET latin1 NOT NULL,
|
||||
`telephone` varchar(30) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `panier`
|
||||
--
|
||||
|
||||
CREATE TABLE `panier` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`id_produit` int(11) DEFAULT NULL,
|
||||
`quantite` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `panier`
|
||||
--
|
||||
|
||||
INSERT INTO `panier` (`id_compte`, `id_produit`, `quantite`) VALUES
|
||||
(13, NULL, NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `produits`
|
||||
--
|
||||
|
||||
CREATE TABLE `produits` (
|
||||
`id_produit` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`description` varchar(1024) CHARACTER SET latin1 NOT NULL,
|
||||
`marque` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`achat_minimum` int(10) NOT NULL,
|
||||
`economie` decimal(4,2) DEFAULT NULL,
|
||||
`image_produit` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`valeur_nutritive` varchar(1024) CHARACTER SET latin1 DEFAULT NULL,
|
||||
`format` int(11) NOT NULL,
|
||||
`unite` varchar(15) CHARACTER SET latin1 NOT NULL,
|
||||
`limite_achat` int(11) DEFAULT NULL,
|
||||
`categorie` int(11) NOT NULL,
|
||||
`id_compte` int(11) DEFAULT NULL,
|
||||
`status` char(1) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `produitsfournisseurs` (
|
||||
`id_produit` int(11) NOT NULL,
|
||||
`id_fournisseur` int(11) NOT NULL,
|
||||
`prix` decimal(5,3) NOT NULL,
|
||||
`economie` decimal(4,2) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- 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`),
|
||||
ADD KEY `Commandes_fk0` (`id_compte`),
|
||||
ADD KEY `Commandes_fk1` (`trace_paiement`);
|
||||
|
||||
--
|
||||
-- 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- Indexes for table `datespaiements`
|
||||
--
|
||||
ALTER TABLE `datespaiements`
|
||||
ADD PRIMARY KEY (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD PRIMARY KEY (`id_compte`) USING BTREE,
|
||||
ADD KEY `Panier_fk0` (`id_produit`);
|
||||
|
||||
--
|
||||
-- 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=2;
|
||||
--
|
||||
-- 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=14;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `fournisseurs`
|
||||
--
|
||||
ALTER TABLE `fournisseurs`
|
||||
MODIFY `id_fournisseur` 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 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 `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD CONSTRAINT `Panier_fk0` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`),
|
||||
ADD CONSTRAINT `panier_ibfk_1` 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`);
|
||||
|
||||
/*!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 */;
|
||||
@@ -0,0 +1,465 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.6.5.2
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 15, 2018 at 07:41 PM
|
||||
-- Server version: 10.1.21-MariaDB
|
||||
-- PHP Version: 7.1.1
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
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`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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 utf8mb4_unicode_ci NOT NULL,
|
||||
`token` char(64) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`expires` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `categorie`
|
||||
--
|
||||
|
||||
CREATE TABLE `categorie` (
|
||||
`id_categorie` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes'),
|
||||
(2, 'Viandes');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `commandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandes` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`status` char(1) CHARACTER SET latin1 NOT NULL,
|
||||
`prix_total` decimal(5,3) NOT NULL,
|
||||
`trace_paiement` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `commandesproduits`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandesproduits` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_produit` int(11) NOT NULL,
|
||||
`quantité` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `comptes`
|
||||
--
|
||||
|
||||
CREATE TABLE `comptes` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`courriel` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`password` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`prenom` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`telephone` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`type` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'U'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Triggers `comptes`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tai_comptes` AFTER INSERT ON `comptes` FOR EACH ROW insert into panier values(NEW.id_compte, null, null)
|
||||
$$
|
||||
DELIMITER ;
|
||||
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) CHARACTER SET latin1 NOT NULL,
|
||||
`valeur` varchar(4096) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datespaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `datespaiements` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fournisseurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `fournisseurs` (
|
||||
`id_fournisseur` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`adresse` varchar(1024) CHARACTER SET latin1 NOT NULL,
|
||||
`telephone` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `adresse`, `telephone`) VALUES
|
||||
(2, 'Metro', '123 lol', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `panier`
|
||||
--
|
||||
|
||||
CREATE TABLE `panier` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`id_produit` int(11) DEFAULT NULL,
|
||||
`quantite` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `panier`
|
||||
--
|
||||
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `produits`
|
||||
--
|
||||
|
||||
CREATE TABLE `produits` (
|
||||
`id_produit` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`description` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`marque` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`achat_minimum` int(10) NOT NULL,
|
||||
`economie` decimal(4,2) DEFAULT NULL,
|
||||
`image_produit` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`valeur_nutritive` varchar(1024) CHARACTER SET latin1 DEFAULT NULL,
|
||||
`format` int(11) NOT NULL,
|
||||
`unite` varchar(15) CHARACTER SET latin1 NOT NULL,
|
||||
`limite_achat` int(11) DEFAULT NULL,
|
||||
`categorie` int(11) NOT NULL,
|
||||
`id_compte` int(11) DEFAULT NULL,
|
||||
`status` char(1) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `produits`
|
||||
--
|
||||
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `produitsfournisseurs` (
|
||||
`id_produit` int(11) NOT NULL,
|
||||
`id_fournisseur` int(11) NOT NULL,
|
||||
`prix` decimal(5,3) NOT NULL,
|
||||
`economie` decimal(4,2) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- 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`),
|
||||
ADD KEY `Commandes_fk0` (`id_compte`),
|
||||
ADD KEY `Commandes_fk1` (`trace_paiement`);
|
||||
|
||||
--
|
||||
-- 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- Indexes for table `datespaiements`
|
||||
--
|
||||
ALTER TABLE `datespaiements`
|
||||
ADD PRIMARY KEY (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD PRIMARY KEY (`id_compte`) USING BTREE,
|
||||
ADD KEY `Panier_fk0` (`id_produit`);
|
||||
|
||||
--
|
||||
-- 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=3;
|
||||
--
|
||||
-- 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=14;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `fournisseurs`
|
||||
--
|
||||
ALTER TABLE `fournisseurs`
|
||||
MODIFY `id_fournisseur` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `produits`
|
||||
--
|
||||
ALTER TABLE `produits`
|
||||
MODIFY `id_produit` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
|
||||
--
|
||||
-- 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 `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD CONSTRAINT `Panier_fk0` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`),
|
||||
ADD CONSTRAINT `panier_ibfk_1` 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`);
|
||||
|
||||
/*!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 */;
|
||||
@@ -0,0 +1,455 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.6.5.2
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 21, 2018 at 09:43 PM
|
||||
-- Server version: 10.1.21-MariaDB
|
||||
-- PHP Version: 7.1.1
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
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`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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 utf8mb4_unicode_ci NOT NULL,
|
||||
`token` char(64) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`expires` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `categorie`
|
||||
--
|
||||
|
||||
CREATE TABLE `categorie` (
|
||||
`id_categorie` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes'),
|
||||
(2, 'Viandes');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `commandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandes` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`status` char(1) CHARACTER SET latin1 NOT NULL,
|
||||
`prix_total` decimal(5,3) NOT NULL,
|
||||
`trace_paiement` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `comptes`
|
||||
--
|
||||
|
||||
CREATE TABLE `comptes` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`courriel` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`password` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`prenom` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`telephone` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`type` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'U'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Triggers `comptes`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tai_comptes` AFTER INSERT ON `comptes` FOR EACH ROW insert into panier values(NEW.id_compte, null, null)
|
||||
$$
|
||||
DELIMITER ;
|
||||
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) CHARACTER SET latin1 NOT NULL,
|
||||
`valeur` varchar(4096) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datespaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `datespaiements` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fournisseurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `fournisseurs` (
|
||||
`id_fournisseur` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`adresse` varchar(1024) CHARACTER SET latin1 NOT NULL,
|
||||
`telephone` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `adresse`, `telephone`) VALUES
|
||||
(2, 'Metro', '123 lol', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `panier`
|
||||
--
|
||||
|
||||
CREATE TABLE `panier` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`id_produit` int(11) DEFAULT NULL,
|
||||
`quantite` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `produits`
|
||||
--
|
||||
|
||||
CREATE TABLE `produits` (
|
||||
`id_produit` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`description` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`marque` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`achat_minimum` int(10) NOT NULL,
|
||||
`economie` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`image_produit` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`valeur_nutritive` varchar(1024) CHARACTER SET latin1 DEFAULT NULL,
|
||||
`format` int(11) NOT NULL,
|
||||
`unite` varchar(15) CHARACTER SET latin1 NOT NULL,
|
||||
`limite_achat` int(11) DEFAULT NULL,
|
||||
`categorie` int(11) NOT NULL,
|
||||
`id_compte` int(11) DEFAULT NULL,
|
||||
`status` char(1) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `produitsfournisseurs` (
|
||||
`id_produit` int(11) NOT NULL,
|
||||
`id_fournisseur` int(11) NOT NULL,
|
||||
`prix` decimal(5,3) NOT NULL,
|
||||
`economie` decimal(4,2) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- 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`),
|
||||
ADD KEY `Commandes_fk0` (`id_compte`),
|
||||
ADD KEY `Commandes_fk1` (`trace_paiement`);
|
||||
|
||||
--
|
||||
-- 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- Indexes for table `datespaiements`
|
||||
--
|
||||
ALTER TABLE `datespaiements`
|
||||
ADD PRIMARY KEY (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD PRIMARY KEY (`id_compte`) USING BTREE,
|
||||
ADD KEY `Panier_fk0` (`id_produit`);
|
||||
|
||||
--
|
||||
-- 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=3;
|
||||
--
|
||||
-- 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=2;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `comptes`
|
||||
--
|
||||
ALTER TABLE `comptes`
|
||||
MODIFY `id_compte` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `fournisseurs`
|
||||
--
|
||||
ALTER TABLE `fournisseurs`
|
||||
MODIFY `id_fournisseur` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `produits`
|
||||
--
|
||||
ALTER TABLE `produits`
|
||||
MODIFY `id_produit` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
|
||||
--
|
||||
-- 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 `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD CONSTRAINT `Panier_fk0` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`),
|
||||
ADD CONSTRAINT `panier_ibfk_1` 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`);
|
||||
|
||||
/*!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 */;
|
||||
@@ -0,0 +1,635 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.6.5.2
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 22, 2018 at 09:39 PM
|
||||
-- Server version: 10.1.21-MariaDB
|
||||
-- PHP Version: 7.1.1
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
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`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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 utf8mb4_unicode_ci NOT NULL,
|
||||
`token` char(64) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`expires` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `categorie`
|
||||
--
|
||||
|
||||
CREATE TABLE `categorie` (
|
||||
`id_categorie` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et L?gumes'),
|
||||
(2, 'Viandes'),
|
||||
(3, 'é');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `commandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandes` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`status` char(1) COLLATE utf8mb4_bin NOT NULL,
|
||||
`prix_total` decimal(5,3) NOT NULL,
|
||||
`trace_paiement` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPACT;
|
||||
|
||||
--
|
||||
-- Triggers `commandes`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tai_commandes` AFTER INSERT ON `commandes` FOR EACH ROW begin
|
||||
|
||||
declare v_nom varchar(255);
|
||||
declare v_prenom varchar(255);
|
||||
declare v_courriel varchar(255);
|
||||
|
||||
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 (0,
|
||||
new.id_commande,
|
||||
new.id_compte,
|
||||
v_nom,
|
||||
v_prenom,
|
||||
v_courriel,
|
||||
new.date,
|
||||
new.status,
|
||||
new.prix_total,
|
||||
new.trace_paiement);
|
||||
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=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- 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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `comptes`
|
||||
--
|
||||
|
||||
CREATE TABLE `comptes` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`courriel` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`password` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`prenom` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`telephone` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`type` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'U'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `comptes`
|
||||
--
|
||||
|
||||
INSERT INTO `comptes` (`id_compte`, `courriel`, `password`, `nom`, `prenom`, `telephone`, `type`) VALUES
|
||||
(14, '[email protected]', '$2y$10$aarrTJd0XPxxsNwowXxA5evKxEk7IcyTnlMvhhgO5UmyFCTptcHvy', 'Robert', 'Anthony', '8199447206', 'U'),
|
||||
(15, '[email protected]', '$2y$10$wpL.s6uzQ1vFm6bqL.Sp.OCk/nG6zTPQdy0nqW1xQXdhcXYYNkEBe', 'Georges', 'Anthony', '8199447206', 'B'),
|
||||
(16, '[email protected]', '$2y$10$.mB/c0ntseE6/FtaFkZ3n.rze9Bt7vEGi7A0sHtZZnCV3BG1yye6K', 'Admin', 'Admin', '8193761721', 'A'),
|
||||
(17, '[email protected]', '$2y$10$Lujrvd4qbHLSROCL9KlVEOA7a26n/dmoYPB343rqxMzKctcoD55eq', 'Lacerte', 'jeremy', '8199999999', 'U');
|
||||
|
||||
--
|
||||
-- Triggers `comptes`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tai_comptes` AFTER INSERT ON `comptes` FOR EACH ROW insert into panier values(NEW.id_compte, null, null)
|
||||
$$
|
||||
DELIMITER ;
|
||||
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) CHARACTER SET latin1 NOT NULL,
|
||||
`valeur` varchar(4096) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datespaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `datespaiements` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fournisseurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `fournisseurs` (
|
||||
`id_fournisseur` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`adresse` varchar(1024) CHARACTER SET latin1 NOT NULL,
|
||||
`telephone` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `adresse`, `telephone`) VALUES
|
||||
(2, 'Metro', '123 lol', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`c_nom` varchar(255) DEFAULT NULL,
|
||||
`c_prenom` varchar(255) DEFAULT NULL,
|
||||
`c_courriel` varchar(255) DEFAULT NULL,
|
||||
`date` datetime DEFAULT NULL,
|
||||
`status` char(1) DEFAULT NULL,
|
||||
`prix_total` decimal(10,2) DEFAULT NULL,
|
||||
`trace_paiement` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `historiquecommandeproduit`
|
||||
--
|
||||
|
||||
CREATE TABLE `historiquecommandeproduit` (
|
||||
`id_historique` int(11) DEFAULT NULL,
|
||||
`id_produit` int(11) DEFAULT NULL,
|
||||
`p_nom` varchar(255) DEFAULT NULL,
|
||||
`p_description` varchar(1024) DEFAULT NULL,
|
||||
`p_marque` varchar(255) DEFAULT NULL,
|
||||
`p_commandemin` int(11) DEFAULT NULL,
|
||||
`p_limiteachat` int(11) DEFAULT NULL,
|
||||
`p_economie` varchar(255) DEFAULT NULL,
|
||||
`p_unite` varchar(255) DEFAULT NULL,
|
||||
`p_format` varchar(255) DEFAULT NULL,
|
||||
`p_categorie` varchar(255) DEFAULT NULL,
|
||||
`quantite` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `panier`
|
||||
--
|
||||
|
||||
CREATE TABLE `panier` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`id_produit` int(11) DEFAULT NULL,
|
||||
`quantite` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `produits`
|
||||
--
|
||||
|
||||
CREATE TABLE `produits` (
|
||||
`id_produit` int(11) NOT NULL,
|
||||
`nom` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`description` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`marque` varchar(255) CHARACTER SET latin1 NOT NULL,
|
||||
`achat_minimum` int(10) NOT NULL,
|
||||
`economie` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`image_produit` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`valeur_nutritive` varchar(1024) CHARACTER SET latin1 DEFAULT NULL,
|
||||
`format` int(11) NOT NULL,
|
||||
`unite` varchar(15) CHARACTER SET latin1 NOT NULL,
|
||||
`limite_achat` int(11) DEFAULT NULL,
|
||||
`categorie` int(11) NOT NULL,
|
||||
`id_compte` int(11) DEFAULT NULL,
|
||||
`status` char(1) CHARACTER SET latin1 NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Stand-in structure for view `v_commande`
|
||||
-- (See below for the actual view)
|
||||
--
|
||||
CREATE TABLE `v_commande` (
|
||||
`id_historique` int(11)
|
||||
,`id_commande` int(11)
|
||||
,`id_compte` int(11)
|
||||
,`c_nom` varchar(255)
|
||||
,`c_prenom` varchar(255)
|
||||
,`c_courriel` varchar(255)
|
||||
,`date` datetime
|
||||
,`status` char(1)
|
||||
,`prix_total` decimal(10,2)
|
||||
,`trace_paiement` int(11)
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure for view `v_commande`
|
||||
--
|
||||
DROP TABLE IF EXISTS `v_commande`;
|
||||
|
||||
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_commande` AS select `historiquecommande`.`id_historique` AS `id_historique`,`historiquecommande`.`id_commande` AS `id_commande`,`historiquecommande`.`id_compte` AS `id_compte`,`historiquecommande`.`c_nom` AS `c_nom`,`historiquecommande`.`c_prenom` AS `c_prenom`,`historiquecommande`.`c_courriel` AS `c_courriel`,`historiquecommande`.`date` AS `date`,`historiquecommande`.`status` AS `status`,`historiquecommande`.`prix_total` AS `prix_total`,`historiquecommande`.`trace_paiement` AS `trace_paiement` from `historiquecommande` ;
|
||||
|
||||
--
|
||||
-- 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`),
|
||||
ADD KEY `Commandes_fk0` (`id_compte`),
|
||||
ADD KEY `Commandes_fk1` (`trace_paiement`);
|
||||
|
||||
--
|
||||
-- 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- Indexes for table `datespaiements`
|
||||
--
|
||||
ALTER TABLE `datespaiements`
|
||||
ADD PRIMARY KEY (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
ADD PRIMARY KEY (`id_historique`);
|
||||
|
||||
--
|
||||
-- Indexes for table `historiquecommandeproduit`
|
||||
--
|
||||
ALTER TABLE `historiquecommandeproduit`
|
||||
ADD KEY `historiquecommandeproduit_id_historique_index` (`id_historique`);
|
||||
|
||||
--
|
||||
-- Indexes for table `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD PRIMARY KEY (`id_compte`) USING BTREE,
|
||||
ADD KEY `Panier_fk0` (`id_produit`);
|
||||
|
||||
--
|
||||
-- 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=2;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `comptes`
|
||||
--
|
||||
ALTER TABLE `comptes`
|
||||
MODIFY `id_compte` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `fournisseurs`
|
||||
--
|
||||
ALTER TABLE `fournisseurs`
|
||||
MODIFY `id_fournisseur` 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=2;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `produits`
|
||||
--
|
||||
ALTER TABLE `produits`
|
||||
MODIFY `id_produit` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
|
||||
--
|
||||
-- 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 `historiquecommandeproduit__fk` FOREIGN KEY (`id_historique`) REFERENCES `historiquecommande` (`id_historique`);
|
||||
|
||||
--
|
||||
-- Constraints for table `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD CONSTRAINT `Panier_fk0` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`),
|
||||
ADD CONSTRAINT `panier_ibfk_1` 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`);
|
||||
|
||||
/*!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 */;
|
||||
@@ -0,0 +1,632 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.8.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Nov 22, 2018 at 09:53 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`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
|
||||
|
||||
--
|
||||
-- Dumping data for table `categorie`
|
||||
--
|
||||
|
||||
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
|
||||
(1, 'Fruits et Légumes'),
|
||||
(2, 'Viandes');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `commandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `commandes` (
|
||||
`id_commande` int(11) NOT NULL,
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`status` char(1) COLLATE utf8_bin NOT NULL,
|
||||
`prix_total` decimal(5,3) 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 v_nom varchar(255);
|
||||
declare v_prenom varchar(255);
|
||||
declare v_courriel varchar(255);
|
||||
|
||||
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 (0,
|
||||
new.id_commande,
|
||||
new.id_compte,
|
||||
v_nom,
|
||||
v_prenom,
|
||||
v_courriel,
|
||||
new.date,
|
||||
new.status,
|
||||
new.prix_total,
|
||||
new.trace_paiement);
|
||||
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_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 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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`, `type`) VALUES
|
||||
(16, '[email protected]', '$2y$10$.mB/c0ntseE6/FtaFkZ3n.rze9Bt7vEGi7A0sHtZZnCV3BG1yye6K', 'Admin', 'Admin', '8193761721', 'A');
|
||||
|
||||
--
|
||||
-- Triggers `comptes`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `tai_comptes` AFTER INSERT ON `comptes` FOR EACH ROW insert into panier values(NEW.id_compte, null, null)
|
||||
$$
|
||||
DELIMITER ;
|
||||
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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `datescommandes`
|
||||
--
|
||||
|
||||
CREATE TABLE `datescommandes` (
|
||||
`date_debut` datetime NOT NULL,
|
||||
`date_fin` datetime 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 `format`
|
||||
--
|
||||
|
||||
CREATE TABLE `format` (
|
||||
`id_format` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `format`
|
||||
--
|
||||
|
||||
INSERT INTO `format` (`id_format`, `nom`) VALUES
|
||||
(1, 'kg');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `fournisseurs`
|
||||
--
|
||||
|
||||
CREATE TABLE `fournisseurs` (
|
||||
`id_fournisseur` int(11) NOT NULL,
|
||||
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
|
||||
`adresse` varchar(1024) COLLATE utf8_bin NOT NULL,
|
||||
`telephone` varchar(30) COLLATE utf8_bin DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for table `fournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `adresse`, `telephone`) VALUES
|
||||
(2, 'Metro', '123 lol', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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,
|
||||
`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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `historiquecommandeproduit`
|
||||
--
|
||||
|
||||
CREATE TABLE `historiquecommandeproduit` (
|
||||
`id_historique` int(11) DEFAULT NULL,
|
||||
`id_produit` int(11) DEFAULT 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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `panier`
|
||||
--
|
||||
|
||||
CREATE TABLE `panier` (
|
||||
`id_compte` int(11) NOT NULL,
|
||||
`id_produit` int(11) DEFAULT NULL,
|
||||
`quantite` int(11) 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(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
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
--
|
||||
-- Dumping data for 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', 100, '', 'uploads_5bf7168aa89ef2.87995613.jpg', NULL, 1, '1', 69, 1, NULL, 'A'),
|
||||
(7, 'Saucisse', 'Une bonne saucisse', 'La fernandière', 420, '', 'uploads_5bf716ec8045c1.37408180.jpg', NULL, 1, '1', 0, 2, NULL, 'A');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
--
|
||||
-- Dumping data for table `produitsfournisseurs`
|
||||
--
|
||||
|
||||
INSERT INTO `produitsfournisseurs` (`id_produit`, `id_fournisseur`, `prix`, `economie`) VALUES
|
||||
(6, 2, '5.00', NULL),
|
||||
(7, 2, '10.00', NULL);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `tracepaiements`
|
||||
--
|
||||
|
||||
CREATE TABLE `tracepaiements` (
|
||||
`id_paiement` int(11) 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`),
|
||||
ADD KEY `Commandes_fk0` (`id_compte`),
|
||||
ADD KEY `Commandes_fk1` (`trace_paiement`);
|
||||
|
||||
--
|
||||
-- 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 (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- Indexes for table `datespaiements`
|
||||
--
|
||||
ALTER TABLE `datespaiements`
|
||||
ADD PRIMARY KEY (`date_debut`,`date_fin`);
|
||||
|
||||
--
|
||||
-- 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 `historiquecommande`
|
||||
--
|
||||
ALTER TABLE `historiquecommande`
|
||||
ADD PRIMARY KEY (`id_historique`);
|
||||
|
||||
--
|
||||
-- Indexes for table `historiquecommandeproduit`
|
||||
--
|
||||
ALTER TABLE `historiquecommandeproduit`
|
||||
ADD KEY `historiquecommandeproduit_id_historique_index` (`id_historique`);
|
||||
|
||||
--
|
||||
-- Indexes for table `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD PRIMARY KEY (`id_compte`) USING BTREE,
|
||||
ADD KEY `Panier_fk0` (`id_produit`);
|
||||
|
||||
--
|
||||
-- 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=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `comptes`
|
||||
--
|
||||
ALTER TABLE `comptes`
|
||||
MODIFY `id_compte` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `format`
|
||||
--
|
||||
ALTER TABLE `format`
|
||||
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `fournisseurs`
|
||||
--
|
||||
ALTER TABLE `fournisseurs`
|
||||
MODIFY `id_fournisseur` 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=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `produits`
|
||||
--
|
||||
ALTER TABLE `produits`
|
||||
MODIFY `id_produit` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
|
||||
|
||||
--
|
||||
-- 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 `historiquecommandeproduit__fk` FOREIGN KEY (`id_historique`) REFERENCES `historiquecommande` (`id_historique`);
|
||||
|
||||
--
|
||||
-- Constraints for table `panier`
|
||||
--
|
||||
ALTER TABLE `panier`
|
||||
ADD CONSTRAINT `Panier_fk0` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`),
|
||||
ADD CONSTRAINT `panier_ibfk_1` 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 */;
|
||||
@@ -0,0 +1,241 @@
|
||||
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;
|
||||
|
||||
|
||||
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 (0,
|
||||
new.id_commande,
|
||||
new.id_compte,
|
||||
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;
|
||||
|
||||
create trigger tbd_commandes
|
||||
before delete
|
||||
on commandes
|
||||
for each row
|
||||
begin
|
||||
|
||||
delete from commandesproduits where commandesproduits.id_commande = old.id_commande;
|
||||
|
||||
end;
|
||||
|
||||
create trigger tbi_commandes
|
||||
before insert
|
||||
on commandes
|
||||
for each row
|
||||
begin
|
||||
|
||||
declare num varchar(1024);
|
||||
|
||||
set new.date = now();
|
||||
select CONCAT('DIET-', FLOOR(5 + RAND() * 60), '1', REPLACE(CURDATE(), '-', '')) into num from dual;
|
||||
set new.numero_commande = num;
|
||||
|
||||
end;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
create trigger tau_produits
|
||||
after update
|
||||
on produits
|
||||
for each row
|
||||
begin
|
||||
|
||||
call updatelimiteproduit(new.id_produit, new.limite_achat);
|
||||
|
||||
end;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
create trigger tai_commandes2
|
||||
after insert
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
create trigger tbd_historiquecommande
|
||||
before delete
|
||||
on historiquecommande
|
||||
for each row
|
||||
begin
|
||||
|
||||
delete from historiquecommandeproduit where historiquecommandeproduit.id_historique = old.id_historique;
|
||||
|
||||
end;
|
||||
Reference in new issue
Block a user