public function setup() { $this->setWidgets(array('idIncidencia' => new sfWidgetFormInputHidden(), 'quiinforma' => new sfWidgetFormChoice(array('choices' => UsuarisPeer::selectTreballadors($this->getOption('IDS')))), 'quiresol' => new sfWidgetFormChoice(array('choices' => UsuarisPeer::selectTreballadors($this->getOption('IDS')))), 'titol' => new sfWidgetFormInputText(array(), array('style' => 'width:400px')), 'descripcio' => new sfWidgetFormTextarea(array(), array('style' => 'width:400px')), 'estat' => new sfWidgetFormChoice(array('choices' => IncidenciesPeer::getEstatSelect())), 'dataalta' => new sfWidgetFormJQueryDate(array('format' => '%day%/%month%/%year%'), array()), 'dataresolucio' => new sfWidgetFormInputHidden(), 'site_id' => new sfWidgetFormInputHidden(), 'actiu' => new sfWidgetFormInputHidden())); $this->setValidators(array('idIncidencia' => new sfValidatorPropelChoice(array('model' => 'Incidencies', 'column' => 'idIncidencia', 'required' => false)), 'quiinforma' => new sfValidatorPropelChoice(array('model' => 'Usuaris', 'column' => 'UsuariID')), 'quiresol' => new sfValidatorPropelChoice(array('model' => 'Usuaris', 'column' => 'UsuariID')), 'titol' => new sfValidatorString(array('required' => false)), 'descripcio' => new sfValidatorString(array('required' => false)), 'estat' => new sfValidatorInteger(), 'dataalta' => new sfValidatorDate(array('required' => false)), 'dataresolucio' => new sfValidatorDate(array('required' => false)), 'site_id' => new sfValidatorPass(), 'actiu' => new sfValidatorPass())); $this->widgetSchema->setLabels(array('quiinforma' => 'Afectat: ', 'quiresol' => 'Responsable: ', 'titol' => 'Titol: ', 'descripcio' => 'Descripció: ', 'estat' => 'Estat: ', 'dataalta' => 'Data d\'alta', 'dataresolucio' => 'Data resolució: ')); $this->widgetSchema->setNameFormat('incidencies[%s]'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); }
/** * 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 = IncidenciesPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setIdincidencia($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setQuiinforma($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setQuiresol($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setTitol($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setDescripcio($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setEstat($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setDataalta($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setDataresolucio($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setSiteId($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setActiu($arr[$keys[9]]); } }
public function executeGIncidencies(sfWebRequest $request) { $this->setLayout('gestio'); $this->IDS = $this->getUser()->getSessionPar('idS'); $this->IDU = $this->getUser()->getSessionPar('idU'); //Netegem cerca if ($request->getParameter('accio') == 'C') { $this->CERCA = $this->getUser()->setSessionPar('cerca', array('text' => '')); $this->PAGINA = $this->getUser()->setSessionPar('pagina', 1); } $this->PAGINA = $this->getUser()->ParReqSesForm($request, 'PAGINA', 1); $this->CERCA = $this->getUser()->ParReqSesForm($request, 'cerca', array('text' => "")); $this->accio = $this->getUser()->ParReqSesForm($request, 'accio', "C"); //Inicialitzem el formulari de cerca $this->FCerca = new CercaForm(); $this->FCerca->bind($this->CERCA); //Inicialitzem variables $this->MODE = array('CONSULTA' => true, 'NOU' => false, 'EDICIO' => false); if ($request->isMethod('POST') || $request->isMethod('GET')) { $accio = $request->getParameter('accio'); if ($request->hasParameter('BCERCA')) { $this->accio = 'C'; } if ($request->hasParameter('BNOU')) { $this->accio = 'N'; } if ($request->hasParameter('BSAVE')) { $this->accio = 'S'; } if ($request->hasParameter('BDELETE')) { $this->accio = 'D'; } } switch ($this->accio) { case 'C': $this->getUser()->addLogAction('inside', 'gIncidencies'); break; case 'N': $this->FIncidencia = IncidenciesPeer::initialize(0, $this->IDU, $this->IDS); $this->MODE['NOU'] = true; break; case 'E': $IDI = $request->getParameter('IDI'); $this->FIncidencia = IncidenciesPeer::initialize($IDI, $this->IDU, $this->IDS); $this->MODE['EDICIO'] = true; break; case 'S': $RP = $request->getParameter('incidencies'); $this->FIncidencia = IncidenciesPeer::initialize($RP['idIncidencia'], $this->IDU, $this->IDS); $this->FIncidencia->bind($RP); if ($this->FIncidencia->isValid()) { $this->FIncidencia->save(); $this->getUser()->addLogAction($accio, 'gIncidencies', $this->FIncidencia->getObject()); myUser::addLogTimeline('alta', 'incidencies', $this->getUser()->getSessionPar('idU'), $this->IDS, $this->FIncidencia->getObject()->getIdincidencia()); $this->redirect('gestio/gIncidencies?accio=C'); } $this->MODE['EDICIO'] = true; break; case 'D': $RP = $request->getParameter('incidencies'); $this->FIncidencia = IncidenciesPeer::initialize($RP['idIncidencia'], $this->IDU, $this->IDS); $this->FIncidencia->getObject()->setActiu(false)->save(); $this->getUser()->addLogAction($accio, 'gIncidencies', $this->FIncidencia->getObject()); myUser::addLogTimeline('baixa', 'incidencies', $this->getUser()->getSessionPar('idU'), $this->IDS, $RP['idIncidencia']); break; $this->INCIDENCIES = IncidenciesPeer::getIncidencies($this->CERCA['text'], $this->PAGINA, $this->IDS, true); } if ($accio == 'RESOLTES') { $this->INCIDENCIES = IncidenciesPeer::getIncidencies($this->CERCA['text'], $this->PAGINA, $this->IDS, false); } else { $this->INCIDENCIES = IncidenciesPeer::getIncidencies($this->CERCA['text'], $this->PAGINA, $this->IDS, true); } }
/** * Returns the number of related Incidencies objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Incidencies objects. * @throws PropelException */ public function countIncidenciessRelatedByQuiresol(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(UsuarisPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collIncidenciessRelatedByQuiresol === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(IncidenciesPeer::QUIRESOL, $this->usuariid); $count = IncidenciesPeer::doCount($criteria, false, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return count of the collection. $criteria->add(IncidenciesPeer::QUIRESOL, $this->usuariid); if (!isset($this->lastIncidenciesRelatedByQuiresolCriteria) || !$this->lastIncidenciesRelatedByQuiresolCriteria->equals($criteria)) { $count = IncidenciesPeer::doCount($criteria, false, $con); } else { $count = count($this->collIncidenciessRelatedByQuiresol); } } else { $count = count($this->collIncidenciessRelatedByQuiresol); } } return $count; }
/** * 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(IncidenciesPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(IncidenciesPeer::DATABASE_NAME); $criteria->add(IncidenciesPeer::IDINCIDENCIA, $pks, Criteria::IN); $objs = IncidenciesPeer::doSelect($criteria, $con); } return $objs; }