Skip to content

Commit

Permalink
Ajout des fonctions de désactivation de pilote
Browse files Browse the repository at this point in the history
  • Loading branch information
cvermot committed Mar 14, 2024
1 parent 9d26643 commit f9ad4d0
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 20 deletions.
2 changes: 1 addition & 1 deletion database/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS fichiersFacture (factureId INTEGER PRIMARY KEY AUTOIN
INSERT INTO fichiersFacture (factureId, nomFichier) VALUES (0, 'FactureFictivePourInit');

-- Table: pilote
CREATE TABLE IF NOT EXISTS pilote (piloteId TEXT PRIMARY KEY UNIQUE NOT NULL, nom TEXT NOT NULL, prenom TEXT NOT NULL, aeroclub TEXT NOT NULL, estAyantDroit INTEGER NOT NULL, mail TEXT, telephone TEXT, remarque TEXT, activitePrincipale TEXT REFERENCES activite (nom) NOT NULL);
CREATE TABLE IF NOT EXISTS pilote (piloteId TEXT PRIMARY KEY UNIQUE NOT NULL, nom TEXT NOT NULL, prenom TEXT NOT NULL, aeroclub TEXT NOT NULL, estAyantDroit INTEGER NOT NULL, mail TEXT, telephone TEXT, remarque TEXT, activitePrincipale TEXT REFERENCES activite (nom) NOT NULL, estActif NUMERIC DEFAULT (1) NOT NULL);

-- Table: recettes
CREATE TABLE IF NOT EXISTS recettes (recetteId INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL, typeDeRecette TEXT NOT NULL REFERENCES typeDeRecetteDepense (typeDeRecetteDepenseId), Intitule TEXT NOT NULL, montant REAL NOT NULL, identifiantFormulaireSoumissionCe INTEGER REFERENCES demandeRemboursementSoumises (demandeId));
Expand Down
9 changes: 7 additions & 2 deletions src/AeroDms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,8 @@ void AeroDms::ajouterUneCotisationEnBdd()
statusBar()->showMessage("Cotisation " + QString::number(infosCotisation.annee) + " ajoutée pour le pilote " + db->recupererNomPrenomPilote(infosCotisation.idPilote));

peuplerTableRecettes();
//On peut avoir réactivé un pilote inactif : on réélabore les listes de pilotes
peuplerListesPilotes();
}
}

Expand Down Expand Up @@ -1421,8 +1423,11 @@ void AeroDms::peuplerListesPilotes()
const AeroDmsTypes::Pilote pilote = pilotes.at(i);
const QString nomPrenom = QString(pilote.prenom).append(" ").append(pilote.nom);
listeDeroulantePilote->addItem(nomPrenom, pilote.idPilote);
choixPilote->addItem(nomPrenom, pilote.idPilote);
choixPayeur->addItem(nomPrenom, pilote.idPilote);
if (pilote.estActif)
{
choixPilote->addItem(nomPrenom, pilote.idPilote);
choixPayeur->addItem(nomPrenom, pilote.idPilote);
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/AeroDmsTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,16 @@ const AeroDmsTypes::Vol AeroDmsTypes::K_INIT_VOL = { "",//QString idPilote;
0,//int volId;
0,//int dureeEnMinutes;
0//int baladeId;
};

const AeroDmsTypes::Pilote AeroDmsTypes::K_INIT_PILOTE = { "", //QString idPilote;
"", //QString nom;
"", //QString prenom;
"", //QString aeroclub;
"", //QString activitePrincipale;
false, //bool estAyantDroit;
"", //QString mail;
"", //QString telephone;
"", //QString remarque;
false //bool estActif;
};
2 changes: 2 additions & 0 deletions src/AeroDmsTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ class AeroDmsTypes
QString mail;
QString telephone;
QString remarque;
bool estActif;
};
static const Pilote K_INIT_PILOTE;
typedef QList<Pilote> ListePilotes;

struct HeureDeVolRemboursement
Expand Down
26 changes: 21 additions & 5 deletions src/DialogueGestionPilote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ DialogueGestionPilote::DialogueGestionPilote(ManageDb* db, QWidget* parent) : QD
remarque = new QLineEdit(this);
QLabel* remarqueLabel = new QLabel(tr("Remarque : "), this);

estActif = new QCheckBox(this);
QLabel* estActifLabel = new QLabel(tr("Pilote actif : "), this);
estActif->setChecked(Qt::Checked);

idPilote = "";

QGridLayout* mainLayout = new QGridLayout(this);
Expand Down Expand Up @@ -101,8 +105,10 @@ DialogueGestionPilote::DialogueGestionPilote(ManageDb* db, QWidget* parent) : QD
mainLayout->addWidget(remarqueLabel, 7, 0);
mainLayout->addWidget(remarque, 7, 1);

mainLayout->addWidget(estActifLabel, 8, 0);
mainLayout->addWidget(estActif, 8, 1);

mainLayout->addWidget(buttonBox, 8, 0, 1, 2);
mainLayout->addWidget(buttonBox, 9, 0, 1, 2);

setLayout(mainLayout);

Expand All @@ -119,7 +125,7 @@ void DialogueGestionPilote::peuplerActivitePrincipale()

AeroDmsTypes::Pilote DialogueGestionPilote::recupererInfosPilote()
{
AeroDmsTypes::Pilote pilote;
AeroDmsTypes::Pilote pilote = AeroDmsTypes::K_INIT_PILOTE;

pilote.idPilote = idPilote;
pilote.nom = nom->text().toUpper();
Expand All @@ -130,6 +136,7 @@ AeroDmsTypes::Pilote DialogueGestionPilote::recupererInfosPilote()
pilote.telephone = telephone->text();
pilote.remarque = remarque->text();
pilote.activitePrincipale = activitePrincipale->currentText();
pilote.estActif = estActif->checkState() == Qt::Checked;

//On rince l'affichage en vue d'une éventuelle autre saisie
annulationOuFinSaisie();
Expand Down Expand Up @@ -158,12 +165,20 @@ void DialogueGestionPilote::preparerMiseAJourPilote(const QString p_piloteId)
prenom->setText(pilote.prenom);
if (pilote.estAyantDroit)
{
estAyantDroit->setChecked(true);
estAyantDroit->setChecked(Qt::Checked);
}
else
{
estAyantDroit->setChecked(false);
}
estAyantDroit->setChecked(Qt::Unchecked);
}
if (pilote.estActif)
{
estActif->setChecked(Qt::Checked);
}
else
{
estActif->setChecked(Qt::Unchecked);
}
aeroclub->setText(pilote.aeroclub);
mail->setText(pilote.mail);
telephone->setText(pilote.telephone);
Expand All @@ -186,6 +201,7 @@ void DialogueGestionPilote::annulationOuFinSaisie()
telephone->clear();
remarque->clear();
activitePrincipale->setCurrentIndex(0);
estActif->setChecked(Qt::Checked);

setWindowTitle(tr("Ajouter un pilote"));
okButton->setText(tr("&Ajouter"));
Expand Down
1 change: 1 addition & 0 deletions src/DialogueGestionPilote.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class DialogueGestionPilote : public QDialog
QLineEdit* mail;
QLineEdit* telephone;
QLineEdit* remarque;
QCheckBox* estActif;

QString idPilote;

Expand Down
35 changes: 23 additions & 12 deletions src/ManageDb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,17 @@ AeroDmsTypes::ListePilotes ManageDb::recupererPilotes()
query.exec(sql);

while (query.next()) {
AeroDmsTypes::Pilote pilote;
pilote.idPilote = query.value(0).toString();
pilote.nom = query.value(1).toString();
pilote.prenom = query.value(2).toString();
pilote.aeroclub = query.value(3).toString();
pilote.estAyantDroit = query.value(4).toBool();
pilote.mail = query.value(5).toString();
pilote.telephone = query.value(6).toString();
pilote.remarque = query.value(7).toString();
AeroDmsTypes::Pilote pilote = AeroDmsTypes::K_INIT_PILOTE;
pilote.idPilote = query.value("piloteId").toString();
pilote.nom = query.value("nom").toString();
pilote.prenom = query.value("prenom").toString();
pilote.aeroclub = query.value("aeroclub").toString();
pilote.estAyantDroit = query.value("estAyantDroit").toBool();
pilote.mail = query.value("mail").toString();
pilote.telephone = query.value("telephone").toString();
pilote.remarque = query.value("remarque").toString();
pilote.activitePrincipale = query.value("activitePrincipale").toString();
pilote.estActif = query.value("estActif").toBool();
listeDesPilotes.append(pilote);
}

Expand All @@ -92,7 +94,7 @@ AeroDmsTypes::ListePilotes ManageDb::recupererPilotes()

AeroDmsTypes::Pilote ManageDb::recupererPilote(const QString p_idPilote)
{
AeroDmsTypes::Pilote pilote;
AeroDmsTypes::Pilote pilote = AeroDmsTypes::K_INIT_PILOTE;

QSqlQuery query;
query.prepare("SELECT * FROM pilote WHERE piloteId = :piloteId");
Expand All @@ -109,6 +111,7 @@ AeroDmsTypes::Pilote ManageDb::recupererPilote(const QString p_idPilote)
pilote.telephone = query.value("telephone").toString();
pilote.remarque = query.value("remarque").toString();
pilote.activitePrincipale = query.value("activitePrincipale").toString();
pilote.estActif = query.value("estActif").toBool();
}

return pilote;
Expand Down Expand Up @@ -1177,6 +1180,12 @@ void ManageDb::ajouterCotisation(const AeroDmsTypes::CotisationAnnuelle& p_infos
query.bindValue(":idRecette", idRecette);
query.bindValue(":montantSubvention", p_infosCotisation.montantSubvention);
query.exec();

//Un pilote pour lequel on vient d'ajouter une cotistion est toujours un pilote actif
query.prepare("UPDATE 'pilote' SET 'estActif' =:estActif WHERE piloteId = :piloteId");
query.bindValue(":piloteId", p_infosCotisation.idPilote);
query.bindValue(":estActif", true);
query.exec();
}

//Cette fonction créé (p_pilote.idPilote = "") ou met à jour (p_pilote.idPilote renseigné) un pilote
Expand Down Expand Up @@ -1212,7 +1221,7 @@ AeroDmsTypes::ResultatCreationPilote ManageDb::creerPilote(const AeroDmsTypes::P
}
else
{
query.prepare("INSERT INTO 'pilote' ('piloteId','nom','prenom','aeroclub','estAyantDroit','mail','telephone','remarque','activitePrincipale') VALUES(:piloteId,:nom,:prenom,:aeroclub,:estAyantDroit,:mail,:telephone,:remarque,:activitePrincipale)");
query.prepare("INSERT INTO 'pilote' ('piloteId','nom','prenom','aeroclub','estAyantDroit','mail','telephone','remarque','activitePrincipale','estActif') VALUES(:piloteId,:nom,:prenom,:aeroclub,:estAyantDroit,:mail,:telephone,:remarque,:activitePrincipale,:estActif)");
query.bindValue(":piloteId", piloteId);
query.bindValue(":nom", p_pilote.nom);
query.bindValue(":prenom", p_pilote.prenom);
Expand All @@ -1222,6 +1231,7 @@ AeroDmsTypes::ResultatCreationPilote ManageDb::creerPilote(const AeroDmsTypes::P
query.bindValue(":telephone", p_pilote.telephone);
query.bindValue(":remarque", p_pilote.remarque);
query.bindValue(":activitePrincipale", p_pilote.activitePrincipale);
query.bindValue(":estActif", p_pilote.estActif);

if (!query.exec())
{
Expand All @@ -1232,7 +1242,7 @@ AeroDmsTypes::ResultatCreationPilote ManageDb::creerPilote(const AeroDmsTypes::P
//mise à jour
else
{
query.prepare("UPDATE 'pilote' SET 'nom' = :nom,'prenom' = :prenom,'aeroclub' = :aeroclub,'estAyantDroit' = :estAyantDroit,'mail' = :mail,'telephone' = :telephone,'remarque' = :remarque, 'activitePrincipale' =:activitePrincipale WHERE piloteId = :piloteId");
query.prepare("UPDATE 'pilote' SET 'nom' = :nom,'prenom' = :prenom,'aeroclub' = :aeroclub,'estAyantDroit' = :estAyantDroit,'mail' = :mail,'telephone' = :telephone,'remarque' = :remarque, 'activitePrincipale' =:activitePrincipale, 'estActif' =:estActif WHERE piloteId = :piloteId");
query.bindValue(":piloteId", p_pilote.idPilote);
query.bindValue(":nom", p_pilote.nom);
query.bindValue(":prenom", p_pilote.prenom);
Expand All @@ -1242,6 +1252,7 @@ AeroDmsTypes::ResultatCreationPilote ManageDb::creerPilote(const AeroDmsTypes::P
query.bindValue(":telephone", p_pilote.telephone);
query.bindValue(":remarque", p_pilote.remarque);
query.bindValue(":activitePrincipale", p_pilote.activitePrincipale);
query.bindValue(":estActif", p_pilote.estActif);

if (!query.exec())
{
Expand Down

0 comments on commit f9ad4d0

Please sign in to comment.