public function getFormulariss() { $C = new Criteria(); $C->add(FormularisPeer::ACTIU, true); $C->add(FormularisPeer::IDFORMULARIS, $this->getIdformularis()); $C->addDescendingOrderByColumn(FormularisPeer::IDFORMULARIS); return FormularisPeer::doSelect($C); }
public static function getFormulariDetall($idU, $idF) { //Carreguem el formulari formulari $OF = FormularisPeer::retrieveByPK($idF); if ($OF instanceof Formularis) { $FORM = $OF->getFormulari(); } else { $FORM = "No s'ha trobat el formulari. "; } //Mirem si l'usuari ja en té algun de creat. $C = new Criteria(); $C->add(FormularisRespostesPeer::IDUSUARIS, $idU); $C->add(FormularisRespostesPeer::IDFORMULARIS, $idF); $C->addDescendingOrderByColumn(FormularisRespostesPeer::IDFORMULARISRESPOSTES); $OFR = FormularisRespostesPeer::doSelectOne($C); //Analitzo el formulari i canvio els codis per inputs pertinents. $ARR = array(); preg_match_all("/#@@(.*)@@#/", $FORM, $ARR); //Serà l'array amb els valors a carregar $A_D = array(); //Si ja hi ha una resposta, reomplim el formulari if ($OFR instanceof FormularisRespostes) { $A_D = unserialize($OFR->getDades()); //Si no hi ha cap registre previ, posem les dades de registre per estalviar feina. } else { $OU = UsuarisPeer::retrieveByPK($idU); if ($OU instanceof Usuaris) { $A_D = array('NOM' => $OU->getNom(), 'COGNOMS' => $OU->getCog1() . ' ' . $OU->getCog2(), 'DNI' => $OU->getDni(), 'POBLACIO' => $OU->getPoblacioString(), 'TELEFON' => $OU->getTelefonString(), 'EMAIL' => $OU->getEmail(), 'ENTITAT' => $OU->getEntitat(), 'ADRECA' => $OU->getAdreca(), 'CODI_POSTAL' => $OU->getCodipostal()); } } //Construim el formulari amb els valors que hem extret del formulari foreach ($ARR[1] as $K => $V) { $A = explode("@@", $V); if ($A[0] == 'text') { if (isset($A_D[$A[1]])) { $FORM = str_replace($ARR[0][$K], '<input type="text" value="' . $A_D[$A[1]] . '" name="formulari[' . $A[1] . ']" ' . $A[2] . ' />', $FORM); } else { $FORM = str_replace($ARR[0][$K], '<input type="text" value="" name="formulari[' . $A[1] . ']" ' . $A[2] . ' />', $FORM); } } elseif ($A[0] == 'checkbox') { if (isset($A_D[$A[1]])) { $FORM = str_replace($ARR[0][$K], '<input type="checkbox" checked="checked" name="formulari[' . $A[1] . ']" ' . $A[2] . ' />', $FORM); } else { $FORM = str_replace($ARR[0][$K], '<input type="checkbox" name="formulari[' . $A[1] . ']" ' . $A[2] . ' />', $FORM); } } } return $FORM; }
/** * 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(FormularisPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(FormularisPeer::DATABASE_NAME); $criteria->add(FormularisPeer::IDFORMULARIS, $pks, Criteria::IN); $objs = FormularisPeer::doSelect($criteria, $con); } return $objs; }
/** * 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 = FormularisPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setIdformularis($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setNom($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setDescripcio($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setFormulari($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setSiteId($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setActiu($arr[$keys[5]]); } }
/** * hospiciActions::executeFormularis() * * Part de mostra dels formularis a l'hospici * * @param mixed $request * @return void */ public function executeForms(sfWebRequest $request) { $this->setLayout('hospici'); $this->setTemplate('indexFormularis'); $this->accio = $request->getParameter('accio', 'index'); //Carrego la cerca $this->CERCA = $this->getUser()->getSessionPar('cerca', array()); $this->DESPLEGABLES = array(); $this->AUTH = $this->getUser()->isAuthenticated(); $this->IDU = $this->getUser()->getSessionPar('idU'); if ($this->accio == 'cerca_formularis' || $this->accio == 'inici') { //Agafo els paràmetres if ($request->getMethod() == 'POST') { $C = $request->getParameter('cerca', array()); } $C['P'] = $request->getParameter('P', 1); //Si em trobo el paràmetre SITE, implica que he entrat per llistat d'entitats i vull veure els formularis. if ($request->hasParameter('SITE')) { $C['SITE'] = $request->getParameter('SITE'); } $C2 = $this->getCercaFormularisComplet($C); //La cerca hauria de tornar el llistat dels formularis que compleixen. $this->LLISTAT_FORMS = FormularisPeer::getFormularisCercaHospici($C2); $this->DESPLEGABLES['SELECT_ENTITATS'] = FormularisPeer::getEntitatsHospici($C2); //Guardem a sessió la cerca "actual" $this->CERCA = $C2; $this->getUser()->setSessionPar('cerca', $this->CERCA); $this->MODE = 'CERCA'; } elseif ($this->accio == 'detall_formularis') { $idU = $this->getUser()->getSessionPar('idU', 0); $idF = $request->getParameter('idF', 0); $this->FORM = FormularisPeer::retrieveByPK($idF); $this->FORM_TEXT = FormularisRespostesPeer::getFormulariDetall($idU, $idF); $this->MODE = 'DETALL'; } }