Exemple #1
0
 function parametresAction()
 {
     $this->metas(array('DC.Title' => 'Paramètres'));
     $this->branche->append();
     $config = Zend_Registry::get('config');
     $this->view->model = $m = new Wtk_Form_Model('parametres');
     $g = $m->addGroup('metas', "Informations");
     $g->addString('title', 'Titre', $config->metas->title);
     $g->addString('short_title', 'Titre court', $config->system->short_title);
     $g->addString('subject', 'Mots clefs', $config->metas->subject);
     $g->addString('author', 'Créateur du site', $config->metas->author);
     $g->addInteger('creation', 'Date de création du site', $config->metas->creation);
     $g = $m->addGroup('system', 'Système');
     $enum = array();
     foreach (Wtk_Document_Style::listAvailables() as $style) {
         $enum[$style->id] = $style->title;
     }
     $g->addEnum('style', 'Style', $config->system->style, $enum);
     $g->addString('admin', 'E-mail système', $config->system->admin);
     $g = $g->addGroup('mail');
     $i0 = $g->addBool('enable', 'Envoyer les mails', $config->system->mail->enable);
     $i1 = $g->addString('smtp', 'Serveur SMTP', $config->system->mail->smtp);
     $m->addConstraintDepends($i1, $i0);
     $m->addNewSubmission('enregistrer', 'Enregistrer');
     if ($m->validate()) {
         $new = new Strass_Config_Php('strass', $m->get());
         /* Migration en douceur de mouvement vers association. */
         if ($config->system->mouvement) {
             $new->system->association = $config->system->mouvement;
             unset($new->system->mouvement);
         }
         $new->system->short_title = $new->metas->short_title;
         unset($new->metas->short_title);
         $config->merge($new);
         $config->write();
         $this->logger->warn("Configuration mise-à-jour");
         $this->redirectSimple('index');
     }
 }
Exemple #2
0
 function createModel($annee)
 {
     $u = $this->unite;
     $a = $annee;
     $m = new Wtk_Form_Model('inscrire');
     /* Pagination dans la pagination :-) */
     $pm = new Wtk_Pages_Model_Form($m);
     /* Sélection de l'individu à inscrire */
     $g = $m->addGroup('inscription');
     $candidats = $u->findCandidats($a);
     $enum = array();
     $enum['$$nouveau$$'] = 'Inscrire un nouveau';
     foreach ($candidats as $candidat) {
         $enum[$candidat->id] = $candidat->getFullname(false, false);
     }
     $i = $g->addEnum('individu', 'Individu', null, $enum);
     $m->addConstraintRequired($i);
     $roles = $u->findParentTypesUnite()->findRoles();
     $enum = array();
     foreach ($roles as $role) {
         $enum[$role->id . '__'] = $role->titre;
         foreach ($role->findTitres() as $titre) {
             $enum[$role->id . '__' . $titre->nom] = $titre->nom;
         }
     }
     $default = $u->findRolesCandidats($a)->current();
     $g->addEnum('role', 'Rôle', $default ? $default->id . '__' : end(array_keys($enum)), $enum);
     list($debut, $fin) = $this->calculerDates($annee);
     $g->addDate('debut', 'Début', $debut);
     $i0 = $g->addBool('clore', 'Se termine le', false);
     $i1 = $g->addDate('fin', 'Fin', $fin);
     $m->addConstraintDepends($i1, $i0);
     $g->addBool('continuer', "J'ai d'autres inscriptions à enregistrer", false);
     /* Enregistrement d'un nouvel individu */
     $g = $m->addGroup('fiche');
     $m->addConstraintRequired($g->addString('prenom', 'Prénom'));
     $m->addConstraintRequired($g->addString('nom', 'Nom'));
     $tu = $u->findParentTypesUnite();
     if ($tu->sexe == 'm') {
         $g->addEnum('sexe', 'Sexe', null, array('h' => 'Masculin', 'f' => 'Féminin'));
     } else {
         $g->addString('sexe', null, $tu->sexe)->setReadonly();
     }
     $g->addString('portable', "Mobile");
     $g->addString('adelec', "Adélec");
     /* Clore une inscription active */
     $g = $m->addGroup('cloture');
     $g->addBool('clore', "Ne l'est plus depuis", true);
     $g->addDate('fin', "Fin", $debut);
     /* Proposer la succession pour les chefs d'unité et les titres */
     $g = $m->addGroup('succession');
     $g->addBool('succeder', "a passé le flambeau le", false);
     $g->addDate('date', "Succession", $debut);
     return $pm;
 }
 function reinscrireAction()
 {
     $this->view->app = $app = $this->_helper->Inscription();
     $this->metas(array('DC.Title' => "Éditer l'inscription"));
     $this->view->individu = $individu = $app->findParentIndividus();
     $this->assert(null, $individu, 'inscrire', "Vous n'avez pas le droit d'inscrire " . $individu->getFullname() . " dans une unité.");
     $this->view->model = $m = new Wtk_Form_Model('inscription');
     $this->view->unite = $unite = $app->findParentUnites();
     $i = $m->addEnum('role', 'Rôle', $app->role);
     $roles = $individu->findRolesCandidats($unite, false);
     foreach ($roles as $role) {
         $i->addItem($role->id, $role->titre);
     }
     $m->addString('titre', 'Titre', $app->titre);
     $m->addDate('debut', 'Début', $app->debut);
     $i0 = $m->addBool('clore', 'Clore', (bool) $app->fin);
     $i1 = $m->addDate('fin', 'Fin', $app->fin);
     $m->addConstraintDepends($i1, $i0);
     $m->addNewSubmission('enregistrer', "Enregistrer");
     if ($m->validate()) {
         $app->role = $m->role;
         $app->titre = $m->titre;
         $app->debut = $m->debut;
         if ($m->clore) {
             $app->fin = $m->fin;
         } else {
             $app->fin = null;
         }
         $db = $app->getTable()->getAdapter();
         $db->beginTransaction();
         try {
             $app->save();
             $this->logger->info("Inscription éditée");
             $this->_helper->Flash->info("Inscription éditée");
             $db->commit();
         } catch (Exception $e) {
             $db->rollBack();
             throw $e;
         }
         $this->redirectSimple('fiche', 'individus', null, array('individu' => $individu->slug), true);
     }
 }