production/Controleur/ControleurTbajouterpays.php
2025-12-02 11:29:44 +00:00

40 lines
1.1 KiB
PHP
Executable File

<?php
require_once 'Framework/Controleur.php';
require_once 'Modele/Pays.php';
require_once 'Modele/Menuvueutilisateur.php';
class ControleurTbajouterpays extends Controleur {
private $menuvue;
private $pays;
public function __construct() {
$this->menuvue = new Menuvueutilisateur();
$this->menuvue->getMenuTbajout('pays');
$this->pays = new pays();
}
public function index()
{
$chemin = $this->menuvue->getChemin('pays');
$this->genererVue(array('chemin' => $chemin));
}
public function ajouter() {
$codeSociete = $this->requete->getSession()->getAttribut('codeSociete');
$codePays = $this->requete->getParametre("codePays");
// Début contrôle doublon
if (!$this->pays->existeligne($codePays)) {
$libelle = $this->requete->getParametre("libelle");
$codePays = strtoupper($codePays);
$libelle = ucfirst($libelle);
$this->pays->ajouter($codeSociete, $codePays, $libelle);
$this->executerAction("index");
}
else
$this->genererVue(array('msgErreur' => 'Ce code existe déjà!'), "index");
// Fin doublon
}
}