示例#1
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->asso = $this->getRoute()->getObject();
     if (!$this->getUser()->isAuthenticated() || !$this->getUser()->getGuardUser()->hasAccess($this->asso->getLogin(), 0x40)) {
         $this->getUser()->setFlash('error', 'Vous n\'avez pas le droit d\'effectuer cette action.');
         $this->redirect('asso/show?login=' . $this->asso->getLogin());
     }
     $this->materiels = MaterielTable::getInstance()->getAllByAsso($this->asso)->execute();
     $this->emprunts = EmpruntTable::getInstance()->getAllByAsso($this->asso)->execute();
 }
示例#2
0
 public function executeCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $this->materiel = MaterielTable::getInstance()->find($request->getPostParameter('emprunt[materiel_id]'));
     if (!$this->getUser()->isAuthenticated() || !$this->getUser()->getGuardUser()->hasAccess($this->materiel->getAsso()->getLogin(), 0x40)) {
         $this->getUser()->setFlash('error', 'Vous n\'avez pas le droit d\'effectuer cette action.');
         $this->redirect('asso/show?login='******'post')) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             if ($emprunt->emprunter($this->form)) {
                 $this->getUser()->setFlash('success', 'Vous avez emprunté ' . $request->getPostParameter('emprunt[materiel_id]') . 'x ' . $emprunt->getMateriel()->getNom() . '.');
             } else {
                 $this->getUser()->setFlash('error', 'Impossible d\'emprunter ' . $request->getPostParameter('emprunt[materiel_id]') . 'x ' . $emprunt->getMateriel()->getNom() . ', pas assez de stock.');
             }
             $this->redirect('materiel', $this->materiel->getAsso());
         }
     }
     $this->setTemplate('new');
 }