public function crear() { $req = $this->request; $vdt = $this->validarPartido($req->post()); $usuario = $this->session->getUser(); if ($usuario->partido_id) { throw new TurnbackException('No es posible crear un grupo si ya está afilado a otro.'); } $partido = new Partido(); $partido->nombre = $vdt->getData('nombre'); $partido->acronimo = $vdt->getData('acronimo'); $partido->descripcion = $vdt->getData('descripcion'); $partido->fundador = $vdt->getData('fundador'); $partido->fecha_fundacion = $vdt->getData('fecha'); $partido->creador_id = $this->session->user('id'); $partido->creador()->associate($usuario); $partido->save(); $contacto = new Contacto(); $contacto->email = $vdt->getData('email'); $contacto->web = $vdt->getData('url'); $contacto->telefono = $vdt->getData('telefono'); $contacto->contactable()->associate($partido); $contacto->save(); UserlogCtrl::createLog('newPartido', $usuario->id, $partido); ImageManager::crearImagen('partido', $partido->id, $partido->nombre, array(32, 64, 160)); $this->session->update(); $this->flash('success', 'El grupo ' . $partido->nombre . ' fue creado exitosamente.'); $this->redirectTo('shwListaPartido'); }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aPartido !== null) { if ($this->aPartido->isModified() || $this->aPartido->getCulture() && $this->aPartido->getCurrentPartidoI18n()->isModified() || $this->aPartido->isNew()) { $affectedRows += $this->aPartido->save($con); } $this->setPartido($this->aPartido); } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = PartidoI18nPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setNew(false); } else { $affectedRows += PartidoI18nPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aConvocatoria !== null) { if ($this->aConvocatoria->isModified() || $this->aConvocatoria->isNew()) { $affectedRows += $this->aConvocatoria->save($con); } $this->setConvocatoria($this->aConvocatoria); } if ($this->aPartido !== null) { if ($this->aPartido->isModified() || $this->aPartido->isNew()) { $affectedRows += $this->aPartido->save($con); } $this->setPartido($this->aPartido); } if ($this->aPolitico !== null) { if ($this->aPolitico->isModified() || $this->aPolitico->isNew()) { $affectedRows += $this->aPolitico->save($con); } $this->setPolitico($this->aPolitico); } if ($this->aCircunscripcion !== null) { if ($this->aCircunscripcion->isModified() || $this->aCircunscripcion->isNew()) { $affectedRows += $this->aCircunscripcion->save($con); } $this->setCircunscripcion($this->aCircunscripcion); } if ($this->isNew()) { $this->modifiedColumns[] = ListaCallePeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = ListaCallePeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += ListaCallePeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $partido = new Partido(); $partido->codpartido = Input::get('Cod_partido'); $partido->horainicio = Input::get('Hora_inicio'); $partido->horafin = Input::get('Hora_final'); $partido->tipopartido = Input::get('Tipo_partido'); $partido->observacion = Input::get('Observacion'); $partido->codprogramacion = Input::get('Cod_programacion'); $partido->idarbitroporpartido = Input::get('Idarbitro'); $partido->save(); return Redirect::to('partido/'); }
public function editpartido_post($codcampeonato, $codtorneo, $codfixture) { $codEscenario = Input::get('escenario'); $fixture = Fixture::find($codfixture); $equipo1 = $fixture->codEquipo1; $nombre1 = Equipo::find($equipo1)->nombre; $nombre1 = substr($nombre1, 0, 3); $equipo2 = $fixture->codEquipo2; $nombre2 = Equipo::find($equipo2)->nombre; $nombre2 = substr($nombre2, 0, 3); $nrofecha = $fixture->nroFecha; $horaincio = $fixture->hora; $hora = substr($horaincio, 0, 2); $min = substr($horaincio, 3, 2); $horaI = (int) $hora; $minI = (int) $min; $horaI = $horaI + 1; $siguiente = $horaI . ":" . $minI; $fecha = DB::table('tfecha')->where('nroFecha', '=', $nrofecha)->where('codRueda', '=', $codtorneo)->first(); $nro = DB::table('tprogramacion')->count(); $idfecha = $fecha->idFecha; $cop = "PRO" . $idfecha . ($nro + 1); $programacion = new Programacion(); $programacion->codProgramacion = $cop; $programacion->idFecha = $idfecha; $programacion->diaPartido = $fecha->diaFecha; $programacion->nroPartido = $fixture->nroPartido; $programacion->codEscenario = $codEscenario; $programacion->save(); $partido = new Partido(); $cP = "PA" . $nombre1 . $nombre2; $partido->codPartido = $cP; $partido->codProgramacion = $cop; $partido->horaInicio = $horaincio; $partido->horaFin = $siguiente; $partido->tipoPartido = "normal"; $partido->save(); return Redirect::to('/fecha/edit/' . $codcampeonato . '/' . $codtorneo . '/' . $fecha->nroFecha); }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->asfGuardUser !== null) { if ($this->asfGuardUser->isModified() || $this->asfGuardUser->isNew()) { $affectedRows += $this->asfGuardUser->save($con); } $this->setsfGuardUser($this->asfGuardUser); } if ($this->aPartidoRelatedByPartidoVideo1Id !== null) { if ($this->aPartidoRelatedByPartidoVideo1Id->isModified() || $this->aPartidoRelatedByPartidoVideo1Id->isNew()) { $affectedRows += $this->aPartidoRelatedByPartidoVideo1Id->save($con); } $this->setPartidoRelatedByPartidoVideo1Id($this->aPartidoRelatedByPartidoVideo1Id); } if ($this->aPartidoRelatedByPartidoVideo2Id !== null) { if ($this->aPartidoRelatedByPartidoVideo2Id->isModified() || $this->aPartidoRelatedByPartidoVideo2Id->isNew()) { $affectedRows += $this->aPartidoRelatedByPartidoVideo2Id->save($con); } $this->setPartidoRelatedByPartidoVideo2Id($this->aPartidoRelatedByPartidoVideo2Id); } if ($this->isNew()) { $this->modifiedColumns[] = PropuestaPeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = PropuestaPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += PropuestaPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } if ($this->collEnlaces !== null) { foreach ($this->collEnlaces as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collEtiquetaPropuestas !== null) { foreach ($this->collEtiquetaPropuestas as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $handle = fopen("php://stdin", "r"); $line = fgets($handle); while ($line = fgets($handle)) { $data = explode(";", "{$line}"); $c = new Criteria(); $c->add(GeoPeer::NOMBRE, $data[3]); $geos = GeoPeer::doSelect($c); $aGeo = false; foreach ($geos as $geo) { if ($geo->getGeoRelatedByGeoId() != null && $geo->getGeoRelatedByGeoId()->getCodigo() && $geo->getGeoRelatedByGeoId()->getCodigo() != '') { //echo 'geo: ' . $geo->getNombre() . "\n"; $aGeo = $geo; } } if (!$aGeo) { echo 'Geo not found: (' . $data[3] . ")\n"; continue; } $c = new Criteria(); $c->add(PartidoPeer::ABREVIATURA, $data[5]); $partido = PartidoPeer::doSelectOne($c); if (!$partido) { $partido = new Partido(); $partido->setAbreviatura($data[5]); $partido->setIsActive(true); $partido->setNombre($data[5], 'es'); $partido->setNombre($data[5], 'ca'); $partido->save(); echo "Created partido ({$partido})\n"; } $c = new Criteria(); $c->add(CircunscripcionPeer::GEO_ID, $aGeo->getId()); $circu = CircunscripcionPeer::doSelectOne($c); $c = new Criteria(); $c->addJoin(ConvocatoriaPeer::ELECCION_ID, EleccionPeer::ID); $c->addJoin(EleccionInstitucionPeer::ELECCION_ID, EleccionPeer::ID); $c->addJoin(InstitucionPeer::ID, EleccionInstitucionPeer::INSTITUCION_ID); $c->add(InstitucionPeer::GEO_ID, $aGeo->getId()); $convocatoria = ConvocatoriaPeer::doSelectOne($c); if (!$convocatoria) { echo "Convocatoria not found: ({$geo})\n"; continue; } $c = new Criteria(); $c->add(ListaPeer::CONVOCATORIA_ID, $convocatoria->getId()); $c->add(ListaPeer::CIRCUNSCRIPCION_ID, $circu->getId()); $c->add(ListaPeer::PARTIDO_ID, $partido->getId()); $lista = ListaPeer::doSelectOne($c); if (!$lista) { $lista = new Lista(); $lista->setPartido($partido); $lista->setCircunscripcion($circu); $lista->setConvocatoria($convocatoria); $lista->save(); echo "Created lista ({$partido}, {$circu})\n"; } $politicos = false; $c = new Criteria(); $c->add("concat(nombre, ' ', apellidos)", trim($data[2])); //$c->add('fullname', utf8_encode( trim($data[2]) ), Criteria::EQUAL); $politicos = PoliticoPeer::doSelect($c); if (count($politicos) != 0) { echo "(ASIGNADO) " . $data[2] . "\n"; $politico = $politicos[0]; } else { echo "(NUEVO) " . $data[2] . "\n"; $politico = new Politico(); $nombreApellidos = explode(" ", $data[2]); $nombre = array_shift($nombreApellidos); $apellidos = implode(" ", $nombreApellidos); $politico->setNombre($nombre); $politico->setApellidos($apellidos); if ($data[7] != '1') { if (trim($data[10]) != '') { $c = new Criteria(); $c->add(PartidoPeer::ABREVIATURA, $data[5]); $partido = PartidoPeer::doSelectOne($c); if ($partido) { $politico->setPartido($partido); } } else { $politico->setPartido($lista->getPartido()); } } $politico->setSexo($data[1] == "hombre" ? 'H' : 'M'); $politico->save(); $politicoI18n = new PoliticoI18n(); $politicoI18n->setPolitico($politico); $politicoI18n->setCulture('es'); $politicoI18n->save(); $politicoI18n = new PoliticoI18n(); $politicoI18n->setPolitico($politico); $politicoI18n->setCulture('ca'); $politicoI18n->save(); } $c = new Criteria(); $c->add(PoliticoListaPeer::LISTA_ID, $lista->getId()); $c->add(PoliticoListaPeer::POLITICO_ID, $politico->getId()); $pl = PoliticoListaPeer::doSelectOne($c); if (!$pl) { $pl = new PoliticoLista(); $pl->setLista($lista); $pl->setPolitico($politico); } else { echo "Ya estaba.\n"; } $pl->setOrden($data[0]); $pl->save(); } fclose($handle); }
/** * * @param Request $request * @return Response */ public function store(Request $request) { $request_params = $request->all(); $rules = array('establecimiento' => 'required|max:150|min:2', 'idPartido' => 'required', 'idPais' => 'required', 'idProvincia' => 'required', 'calle' => 'required'); $messages = array('required' => 'El :attribute es requerido.', 'max' => 'El :attribute debe poseer un maximo de :max caracteres.', 'min' => 'El :attribute debe poseer un minimo de :min caracteres.'); $validator = Validator::make($request_params, $rules, $messages); $params = $request_params; if ($validator->passes()) { $place = new Places(); $place->establecimiento = $this->getParam($params, 'establecimiento'); $place->calle = $this->getParam($params, 'calle'); $place->tipo = $this->getParam($params, 'tipo'); $place->altura = $this->getParam($params, 'altura'); $place->piso_dpto = $this->getParam($params, 'piso_dpto'); $place->observacion = $this->getParam($params, 'observacion'); $place->cruce = $this->getParam($params, 'cruce'); $place->latitude = $this->getParam($params, 'latitude'); $place->longitude = $this->getParam($params, 'longitude'); $place->barrio_localidad = $this->getParam($params, 'barrio_localidad'); $place->prueba = $this->getParam($params, 'prueba', false); $place->responsable_testeo = $this->getParam($params, 'responsable_testeo'); $place->ubicacion_testeo = $this->getParam($params, 'ubicacion_testeo'); $place->horario_testeo = $this->getParam($params, 'horario_testeo'); $place->mail_testeo = $this->getParam($params, 'mail_testeo'); $place->tel_testeo = $this->getParam($params, 'tel_testeo'); $place->web_testeo = $this->getParam($params, 'web_testeo'); $place->observaciones_testeo = $this->getParam($params, 'observaciones_testeo'); $place->condones = $this->getParam($params, 'condones', false); $place->responsable_distrib = $this->getParam($params, 'responsable_distrib'); $place->ubicacion_distrib = $this->getParam($params, 'ubicacion_distrib'); $place->horario_distrib = $this->getParam($params, 'horario_distrib'); $place->mail_distrib = $this->getParam($params, 'mail_distrib'); $place->tel_distrib = $this->getParam($params, 'tel_distrib'); $place->web_distrib = $this->getParam($params, 'web_distrib'); $place->comentarios_distrib = $this->getParam($params, 'comentarios_distrib'); $place->infectologia = $this->getParam($params, 'infectologia', false); $place->responsable_infectologia = $this->getParam($params, 'responsable_infectologia'); $place->ubicacion_infectologia = $this->getParam($params, 'ubicacion_infectologia'); $place->horario_infectologia = $this->getParam($params, 'horario_infectologia'); $place->mail_infectologia = $this->getParam($params, 'mail_infectologia'); $place->tel_infectologia = $this->getParam($params, 'tel_infectologia'); $place->web_infectologia = $this->getParam($params, 'web_infectologia'); $place->comentarios_infectologia = $this->getParam($params, 'comentarios_infectologia'); $place->vacunatorio = $this->getParam($params, 'vacunatorio', false); $place->responsable_vac = $this->getParam($params, 'responsable_vac'); $place->ubicacion_vac = $this->getParam($params, 'ubicacion_vac'); $place->horario_vac = $this->getParam($params, 'horario_vac'); $place->mail_vac = $this->getParam($params, 'mail_vac'); $place->tel_vac = $this->getParam($params, 'tel_vac'); $place->web_vac = $this->getParam($params, 'web_vac'); $place->comentarios_vac = $this->getParam($params, 'comentarios_vac'); $place->aprobado = 0; $place->idPais = $this->getParam($params, 'idPais'); $place->idProvincia = $this->getParam($params, 'idProvincia'); $place->idPartido = $this->getParam($params, 'idPartido'); if (isset($request_params['otro_partido'])) { if ($request_params['otro_partido'] != '') { $localidad_tmp = DB::table('partido')->where('partido.idPais', $place->idPais)->where('partido.idProvincia', $place->idProvincia)->where('nombre_partido', '=', $request_params['otro_partido'])->select()->get(); if (count($localidad_tmp) === 0) { $localidad = new Partido(); $localidad->nombre_partido = $request_params['otro_partido']; $localidad->idProvincia = $place->idProvincia; $localidad->idPais = $place->idPais; $localidad->habilitado = true; $localidad->updated_at = date("Y-m-d H:i:s"); $localidad->created_at = date("Y-m-d H:i:s"); $localidad->save(); $place->idPartido = $localidad->id; } else { $place->idPartido = $localidad_tmp[0]->id; } } } $place->created_at = date("Y-m-d H:i:s"); $place->updated_at = date("Y-m-d H:i:s"); $place->save(); } return $validator->messages(); }
$organis->save(); $funcion = new Funcionario(); $funcion->usuario()->associate($usuario); $funcion->organismo()->associate($organis); $funcion->save(); $organis = new Organismo(); $organis->nombre = 'Organismo Borrable'; $organis->descripcion = 'Organismo creado para probar borrarlo.'; $organis->cupo = 5; $organis->save(); $partido = new Partido(); $partido->nombre = 'Partido Test'; $partido->acronimo = 'PT'; $partido->descripcion = 'Partido creado para realizar pruebas'; $partido->creador()->associate($usuario); $partido->save(); $contact = new Contacto(); $contact->contactable()->associate($partido); $contact->save(); $usuario->es_jefe = 1; $usuario->partido_id = 1; $usuario->save(); $problem = new Problematica(); $problem->cuerpo = 'Problemática creada para hacer pruebas.'; $problem->save(); $conteni = new Contenido(); $conteni->titulo = 'Primer Problemática'; $conteni->categoria_id = 1; $conteni->autor()->associate($usuario); $conteni->contenible()->associate($problem); $conteni->save();