1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| /*
* Instancie un formulaire d'ajout de local
* insert le nouveau local dans la base de donnée en fonction des données du formulaire
*/
//INSTANCE DU FORMULAIRE LOCAL
$form = new Application_Form_Local();
$form->envoyer->setLabel('Ajouter');
$this->view->form = $form;
if ($this->getRequest()->isPost())
{
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData))
{
//RECUPERATION DES DONNEES DU FORMULAIRE
$nomLocal = $form->getValue('nomLocal');
$numPorte = $form->getValue('numPorte');
$metAcces = $form->getValue('metAcces');
//INSTANCE DU MODEL CONTROLEURDEPORTE ET LOCAL PUIS AJOUT DU NOUVEAU CONTROLEUR ET DU LOCAL
$controleur = new Application_Model_DbTable_ControleurDePorte();
$controleur->ajouterControleur($numPorte);
//ici le plus important de l'action
$requete = "SELECT idControleurDePorte FROM controleurdeporte WHERE numPorte =".(int)$numPorte;
$idControleur = mysql_query($requete);
$local = new Application_Model_DbTable_Local();
$local->ajouterLocal($nomLocal,$idControleur,$metAcces);
$this->_helper->redirector('index');
}
else
{
$form->populate($formData);
}
}
} |
Partager