Exemplo n.º 1
0
 public function executeGPromocions(sfWebRequest $request)
 {
     $this->setLayout('gestio');
     $this->IDS = $this->getUser()->getSessionPar('idS');
     $this->IDP = $request->getParameter('IDP', 0);
     $this->ERRORS = array();
     $this->EDICIO = false;
     $this->NOU = false;
     $this->LLISTES = false;
     $this->CURSOS = false;
     $this->PROMOCIONS = array();
     $accio = $request->getParameter('accio', '');
     if ($request->hasParameter('BSAVE')) {
         $accio = 'S';
     } elseif ($request->hasParameter('BDELETE')) {
         $accio = 'D';
     }
     switch ($accio) {
         case 'N':
             $this->FPromocio = PromocionsPeer::initialize(0, $this->IDS);
             $this->NOU = true;
             break;
         case 'E':
             $this->FPromocio = PromocionsPeer::initialize($this->IDP, $this->IDS);
             $this->EDICIO = true;
             break;
         case 'D':
             $RP = $request->getParameter('promocions');
             $this->IDP = $RP['PromocioID'];
             $this->FPromocio = PromocionsPeer::initialize($this->IDP, $this->IDS);
             $OP = $this->FPromocio->getObject();
             $OP->setActiu(false);
             $OP->save();
             $this->getUser()->addLogAction($accio, 'gPromocions', null, $OP);
             break;
         case 'S':
             $RP = $request->getParameter('promocions');
             $this->IDP = $RP['PromocioID'];
             $this->FPromocio = PromocionsPeer::initialize($this->IDP, $this->IDS);
             $this->FPromocio->bind($RP, $request->getFiles('promocions'));
             if ($this->FPromocio->isValid()) {
                 $this->getUser()->addLogAction('save', 'gPromocions', null, $this->FPromocio->getObject());
                 $this->FPromocio->save();
                 $this->redirect('gestio/gPromocions?accio=CC');
             }
             $this->EDICIO = true;
             break;
         case 'CC':
             $this->getUser()->addLogAction('inside', 'gPromocions');
             break;
     }
     $this->PROMOCIONS = PromocionsPeer::getAllPromocions($this->IDS, false);
 }