예제 #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);
 }
예제 #2
0
 private function getBanners()
 {
     //Inicialitzacions
     $TEMP = array('FIX' => array(), 'VAR' => array());
     $BANNERS = array();
     $C = new Criteria();
     //Selecció i consulta de les promocions
     $i = 0;
     $LOP = PromocionsPeer::getAllPromocions($this->IDS);
     foreach ($LOP as $O) {
         if ($O->getIsfixa()) {
             $TEMP['FIX'][$O->getExtensio()]['URL'] = $O->getUrl();
             $TEMP['FIX'][$O->getExtensio()]['IMG'] = $O->getExtensio();
             $TEMP['FIX'][$O->getExtensio()]['Nom'] = $O->getNom();
         } else {
             $TEMP['VAR'][$i]['URL'] = $O->getUrl();
             $TEMP['VAR'][$i]['Nom'] = $O->getNom();
             $TEMP['VAR'][$i++]['IMG'] = $O->getExtensio();
         }
     }
     //Entrem els BANNERS FIXOS
     foreach ($TEMP['FIX'] as $K => $T) {
         $BANNERS[$T['IMG']] = $T;
     }
     //Entrem els BANNERS VARIABLES
     $M_VAR = sizeof($TEMP['VAR']) - 1;
     //Agafem la mida de l'array de variables
     while (sizeof($BANNERS) < 3 && sizeof($TEMP) > 3) {
         srand(time());
         $NumAleatori = rand(1, $M_VAR);
         $BANNERS[$TEMP['VAR'][$NumAleatori]['IMG']] = $TEMP['VAR'][$NumAleatori];
     }
     return $BANNERS;
 }