/** * Declares an association between this object and a Alquiler object. * * @param Alquiler $v * @return SocioAlquiler The current object (for fluent API support) * @throws PropelException */ public function setAlquiler(Alquiler $v = null) { if ($v === null) { $this->setAlquilerId(NULL); } else { $this->setAlquilerId($v->getId()); } $this->aAlquiler = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Alquiler object, it will not be re-added. if ($v !== null) { $v->addSocioAlquiler($this); } return $this; }
/** * Exclude object from result * * @param Alquiler $alquiler Object to remove from the list of results * * @return AlquilerQuery The current query, for fluid interface */ public function prune($alquiler = null) { if ($alquiler) { $this->addUsingAlias(AlquilerPeer::ID, $alquiler->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Filter the query by a related Alquiler object * * @param Alquiler|PropelCollection $alquiler The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return SocioAlquilerQuery The current query, for fluid interface */ public function filterByAlquiler($alquiler, $comparison = null) { if ($alquiler instanceof Alquiler) { return $this->addUsingAlias(SocioAlquilerPeer::ALQUILER_ID, $alquiler->getId(), $comparison); } elseif ($alquiler instanceof PropelCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(SocioAlquilerPeer::ALQUILER_ID, $alquiler->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByAlquiler() only accepts arguments of type Alquiler or PropelCollection'); } }
public function executeAlquilarPeliculas(sfWebRequest $request) { //obtengo socio y todas las peliculas que alquila $peliculasId = array(); $peliculasId = $request->getParameter("id_pelis"); $socio = $request->getParameter("id_socio"); //calculo precio total $total_a_cobrar = sizeof($peliculasId) * 8; //corroboro que las peliculas esten todas libres $todo_bien = true; foreach ($peliculasId as $peli_id) { if ($this->peliculaAlquilada($peli_id)) { $todo_bien = false; } } if ($todo_bien) { //cargo el alquiler en la base $alquiler = new Alquiler(); $alquiler->setFechaAlquiler(date("d-m-Y")); $alquiler->setTotalACobrar($total_a_cobrar); $alquiler->setSocioId($socio); $alquiler->save(); //capturo el id de la reserva $id_alquiler = $alquiler->getId(); foreach ($peliculasId as $peli_id) { //cargo el alquiler en socio_alquiler $socio_alquiler = new SocioAlquiler(); $socio_alquiler->setAlquilerId($id_alquiler); $socio_alquiler->setPeliculaId($peli_id); $socio_alquiler->save(); //marco las peliculas como alquiladas $pelicula_alquilada = PeliculaQuery::create()->filterById($peli_id)->update(array('Estado' => 3)); //marco la reserva como alquilada $reserva = ReservasQuery::create()->filterByPeliculaId($peli_id)->filterBySocioId($socio)->filterByAlquilada(false)->filterByExpiroReserva(false)->update(array('Alquilada' => true)); $this->mje = "Las peliculas: se alquilaron correctamente!!"; } } else { $this->mje = "Las peliculas NO se alquilaron!!"; return sfView::ERROR; } }