-- 1 CREATION DE DATES COMPTABLES

CREATE TABLE IF NOT EXISTS datecomptable (
    id INT AUTO_INCREMENT PRIMARY KEY,
    codeSociete VARCHAR(20) NOT NULL,
   -- libelle VARCHAR(50) NOT NULL,
    dateDebut DATETIME,
    dateFin DATETIME,
    statut TINYINT NOT NULL,
    dateCreation TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)  ENGINE=INNODB;

-- 2 CREATION DE PRESTATAIRES PAYES

CREATE TABLE IF NOT EXISTS prestatairepaie (
    id INT AUTO_INCREMENT PRIMARY KEY,
    idDateComptable INT,
    codePrestataire VARCHAR(10) NOT NULL,
    codeUtilisateur VARCHAR(10) NOT NULL,
    est_garde BOOLEAN NOT NULL DEFAULT FALSE,
    dateCreation TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)ENGINE=INNODB;

-- 3 -- INSERTION DES DONNEES COMPTABLES
INSERT INTO datecomptable (codeSociete,dateDebut,dateFin,statut)
VALUES  ('vitalis','2022-01-01 00:0:00','2022-01-31 00:0:00',1)

INSERT INTO datecomptable (codeSociete,libelle,dateDebut,dateFin,statut)
VALUES  ('vitalis','2022-02-01','2022-02-28',1)

INSERT INTO datecomptable (codeSociete,libelle,dateDebut,dateFin,statut)
VALUES  ('vitalis','MARS 2022','2022-03-01','2022-03-31',1)

INSERT INTO datecomptable (codeSociete,libelle,dateDebut,dateFin,statut)
VALUES  ('vitalis','AVRIL 2022','2022-04-01','2022-04-30',1)

INSERT INTO datecomptable (codeSociete,libelle,dateDebut,dateFin,statut)
VALUES  ('vitalis','MAI 2022','2022-05-01','2022-05-31',0)

INSERT INTO datecomptable (codeSociete,libelle,dateDebut,dateFin,statut)
VALUES  ('vitalis','JUIN 2022','2022-06-01','2022-06-30',0)

INSERT INTO datecomptable (codeSociete,libelle,dateDebut,dateFin,statut)
VALUES  ('vitalis','JUILLET 2022','2022-07-01','2022-07-31',0)

INSERT INTO datecomptable (codeSociete,libelle,dateDebut,dateFin,statut)
VALUES  ('vitalis','AOUT 2022','2022-08-01','2022-08-31',0)

INSERT INTO datecomptable (codeSociete,libelle,dateDebut,dateFin,statut)
VALUES  ('vitalis','SEPTEMBRE 2022','2022-09-01','2022-09-30',0)

INSERT INTO datecomptable (codeSociete,libelle,dateDebut,dateFin,statut)
VALUES  ('vitalis','OTOBRE 2022','2022-10-01','2022-10-31',0)

INSERT INTO datecomptable (codeSociete,libelle,dateDebut,dateFin,statut)
VALUES  ('vitalis','NOVEMBRE 2022','2022-11-01','2022-11-30',0)

INSERT INTO datecomptable (codeSociete,libelle,dateDebut,dateFin,statut)
VALUES  ('vitalis','OTOBRE 2022','2022-12-01','2022-12-31',0)

-- 4-- table correcte


CREATE TABLE IF NOT EXISTS prestatairepaie (
    id INT AUTO_INCREMENT PRIMARY KEY,
    codePrestataire VARCHAR(10) NOT NULL,    
    dateDebut DATETIME,
    dateFin DATETIME,
    
    chequeDisponible BOOLEAN NOT NULL DEFAULT FALSE,    
    est_garde BOOLEAN NOT NULL DEFAULT FALSE,
    
    codeUtilisateur VARCHAR(10) NOT NULL,
    dateCreation TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)ENGINE=INNODB;

