/** * 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'); } }
/** * 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 $alquiler the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return SocioQuery The current query, for fluid interface */ public function filterByAlquiler($alquiler, $comparison = null) { if ($alquiler instanceof Alquiler) { return $this->addUsingAlias(SocioPeer::ID, $alquiler->getSocioId(), $comparison); } elseif ($alquiler instanceof PropelCollection) { return $this->useAlquilerQuery()->filterByPrimaryKeys($alquiler->getPrimaryKeys())->endUse(); } 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; } }
$producto = $pedido->productos()->where('detallepedidoproductos.id', '=', Input::get('detalleid'))->first(); $producto->pivot->estado = 2; $producto->pivot->motivo = Input::get('motivo'); $producto->pivot->save(); return Response::json(['estado' => true, 'msg' => 'Operacion Completada Correctamente']); } }); Route::post('controlhabitacion', function () { if (Request::ajax()) { $pedido = Pedido::find(Input::get('pedido_id')); $alquileres = $pedido->alquiler()->get(); $habitacion = $pedido->habitacion; $preciohora = PrecioHabitacion::where('descripcion', '=', 'hora')->where('habitacion_id', '=', $habitacion->id)->first(); $preciodia = PrecioHabitacion::where('descripcion', '=', 'dia')->where('habitacion_id', '=', $habitacion->id)->first(); foreach ($alquileres as $alquiler) { $oalquiler = Alquiler::find($alquiler->pivot->id); if ($alquiler->pivot->control != 'nulo') { $control = DB::select(DB::raw("SELECT TIMESTAMPDIFF(HOUR, fechacontrol, now()) AS\n\t\t\t\t\t\t\t\t\t\tcontrol FROM detallepedidohabitacion WHERE id\n\t\t\t\t\t\t\t\t\t\t=" . $alquiler->pivot->id . " LIMIT 1")); $tiempotrasncurrido = 0; foreach ($control as $item) { $tiempotrasncurrido = $item->control; } $cantidad = $alquiler->pivot->cantidad; if ($alquiler->pivot->control == 'hora') { $diferencia = $tiempotrasncurrido - $cantidad; if ($diferencia >= 0) { if ($diferencia == 0) { $diferencia = 1; } $newprecio = $alquiler->pivot->precio + $preciohora->precio * $diferencia; if ($newprecio > $preciodia->precio) {
/** * @param Alquiler $alquiler The alquiler object to add. */ protected function doAddAlquiler($alquiler) { $this->collAlquilers[] = $alquiler; $alquiler->setSocio($this); }