<?php $action = verifierAction(array('lister', 'voter', 'consulter')); $smarty->assign('action', $action); require_once dirname(__FILE__) . '/../../../sources/Afup/AFUP_Votes.php'; $votes = new AFUP_Votes($bdd); if ($action == 'lister') { $list_champs = '*'; $list_ordre = 'lancement'; $list_sens = 'desc'; $list_filtre = false; $smarty->assign('votes', $votes->obtenirListeVotesOuverts(time(), $list_champs, $list_ordre, $list_filtre)); } else { require_once 'Afup/AFUP_Votes.php'; $votes = new AFUP_Votes($bdd); $formulaire =& instancierFormulaire(); if (isset($_GET['id'])) { $champs = $votes->obtenirPoids($_GET['id'], $droits->obtenirIdentifiant()); $formulaire->setDefaults($champs); $formulaire->addElement('header', null, 'Poids'); $liste_poids = $votes->obtenirListePoids((int) $_GET['id']); if (is_array($liste_poids)) { $poids_total = 0; foreach ($liste_poids as $poids) { $formulaire->addElement('static', 'poids_' . $poids['id_vote'] . '-' . $poids['id_personne_physique'], date('d/m/Y h:i', $poids['date']), $poids['commentaire'] . ' (' . $poids['personne_physique'] . ')<br /><strong>' . $poids['poids'] . '</strong>'); $poids_total += $poids['poids']; } $formulaire->addElement('static', 'poids_total', 'Résultat total', '<strong>' . $poids_total . '</strong>'); } $formulaire->addElement('header', '', 'Voter'); $vote = $votes->obtenir($_GET['id']);
<?php $action = verifierAction(array('lister', 'ajouter', 'modifier')); $smarty->assign('action', $action); require_once dirname(__FILE__) . '/../../../sources/Afup/AFUP_Votes.php'; $votes = new AFUP_Votes($bdd); if ($action == 'lister') { $list_champs = '*'; $list_ordre = 'lancement'; $list_sens = 'desc'; $list_filtre = false; $smarty->assign('votes', $votes->obtenirListe($list_champs, $list_ordre, $list_filtre)); } else { require_once 'Afup/AFUP_Votes.php'; $votes = new AFUP_Votes($bdd); $formulaire =& instancierFormulaire(); if (isset($_GET['id'])) { $champs = $votes->obtenir($_GET['id']); $formulaire->setDefaults($champs); } $formulaire->addElement('header', '', 'Informations'); $formulaire->addElement('date', 'lancement', 'Lancement', array('language' => 'fr', 'minYear' => date('Y'), 'maxYear' => date('Y'))); $formulaire->addElement('date', 'cloture', 'Clôture', array('language' => 'fr', 'minYear' => date('Y'), 'maxYear' => date('Y'))); $formulaire->addElement('textarea', 'question', 'Question', array('cols' => 42, 'rows' => 10)); $formulaire->addElement('header', 'boutons', ''); $formulaire->addElement('submit', 'soumettre', ucfirst($action)); $formulaire->addRule('question', 'Question manquante', 'required'); if ($formulaire->validate()) { if ($action == 'ajouter') { $lancement = $formulaire->exportValue('lancement'); $lancement = mktime(0, 0, 0, $lancement['M'], $lancement['d'], $lancement['Y']);