public function save($conn = null)
 {
     $OPromocions = $this->getObject();
     PromocionsPeer::gestionaOrdre($this->getValue('Ordre'), $OPromocions->getOrdre(), $this->getOption('IDS'));
     parent::save();
     $nom = $OPromocions->getExtensio();
     if (!empty($nom)) {
         $img = new sfImage($this->URL . $nom, 'image/jpg');
         $img->resize(171, 63)->saveAs($this->URL . $nom);
     }
 }
Exemple #2
0
 public static function initialize($idP, $idS)
 {
     $OP = PromocionsPeer::retrieveByPK($idP);
     if (!$OP instanceof Promocions) {
         $OP = new Promocions();
         $OP->setOrdre(0);
         $OP->setSiteId($idS);
         $OP->setActiu(true);
     }
     return new PromocionsForm($OP, array('IDS' => $idS));
 }
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = PromocionsPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setPromocioid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setNom($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setOrdre($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setExtensio($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setIsactiva($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setIsfixa($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setUrl($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setSiteId($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setActiu($arr[$keys[8]]);
     }
 }
 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);
 }
 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;
 }
Exemple #6
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(PromocionsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(PromocionsPeer::DATABASE_NAME);
         $criteria->add(PromocionsPeer::PROMOCIOID, $pks, Criteria::IN);
         $objs = PromocionsPeer::doSelect($criteria, $con);
     }
     return $objs;
 }