public function calculateAdditionalDays(OrderMembership $orderMembership) { $placeMembershipSubscription = $orderMembership->getPlace()->getActiveMembershipSubscription(); $leftDays = $this->calculateLeftDays($placeMembershipSubscription); $orderMembershipPrice = $orderMembership->getMembership()->getPrice(); $subscruptionMembershipPrice = $placeMembershipSubscription->getMembership()->getPrice(); if ($orderMembershipPrice <= 0) { return $leftDays; } $additionalDays = floor($leftDays * $subscruptionMembershipPrice / $orderMembershipPrice); return $additionalDays; }
/** * @FW\Route("/place/{slug}/invoice/membership", name="place_invoice_membership") * @FW\Security("is_granted('edit', place)") * @FW\Template */ public function invoiceMembershipAction(Place $place, Request $request) { $em = $this->getDoctrine()->getManager(); $order = new OrderMembership(); $order->setPlace($place); $order->setUser($this->getUser()); $form = $this->createForm(new OrderMembershipType(), $order); $form->handleRequest($request); if ($form->isValid()) { $amount = $this->processMembership($order); $order->setAmount($amount); $em->persist($order); $em->flush(); return $this->redirectToRoute('order_membership_pay', ['id' => $order->getId()]); } //return ['form' => $form->createView(), 'place' => $place]; return ['form' => $form->createView(), 'place' => $place]; }