public function executeSupportCreditOrder(Order $order) { $product = $order->getProduct(); $details = $product->getDetails(); $nbCredits = $details['nb_credits']; $this->creditSupportManager->addCreditsToUser($order->getChart()->getOwner(), $nbCredits); }
/** * @EXT\Route( * "/payment/workspace/submit/order/{order}/product/{product}", * name="workspace_product_payment_submit" * ) * @EXT\ParamConverter("authenticatedUser", options={"authenticatedUser" = true}) * @return Response */ public function addOrderToChartAction(Order $order, Product $product) { $chart = $order->getChart(); //check it wasn't already submitted if (false) { $content = $this->renderView('FormaLibreInvoiceBundle:errors:orderAlreadySubmitedException.html.twig'); return new Response($content); } if ($this->session->has('form_price_data')) { $priceSolution = $this->session->get('form_price_data'); $this->session->remove('form_price_data'); $priceSolution = $this->em->getRepository('FormaLibreInvoiceBundle:PriceSolution')->find($priceSolution->getId()); } $form = $this->createForm(new SharedWorkspaceForm($product)); $form->handleRequest($this->request); if ($form->isValid()) { //do that stuff here if (!$this->authorization->isGranted('ROLE_USER')) { $this->session->set('form_price_data', $form->get('price')->getData()); $redirectRoute = $this->router->generate('workspace_product_payment_submit', array('order' => $order->getId(), 'product' => $product->getId(), 'chart' => $chart->getId())); $this->session->set('redirect_route', $redirectRoute); $route = $this->router->generate('claro_security_login', array()); return new RedirectResponse($route); } $priceSolution = $form->get('price')->getData(); } $order->setChart($chart); $order->setProduct($product); $chart->setOwner($this->tokenStorage->getToken()->getUser()); $chart->setIpAdress($_SERVER['REMOTE_ADDR']); $order->setPriceSolution($priceSolution); $order->setChart($chart); if ($this->swsManager->hasFreeTestMonth($chart->getOwner())) { $order->setHasDiscount(true); $this->swsManager->useFreeTestMonth($chart->getOwner()); } $this->em->persist($chart); $this->em->persist($order); $this->em->flush(); return new RedirectResponse($this->router->generate('chart_payment_confirm', array('chart' => $order->getChart()->getId()), true)); throw new \Exception('Errors were found: ' . $form->getErrorsAsString()); }
public function addSharedWorkspace(Order $order) { $priceSolution = $order->getPriceSolution(); $duration = $priceSolution->getMonthDuration(); $product = $order->getProduct(); $user = $order->getChart()->getOwner(); //get the duration right $details = $product->getDetails(); $expDate = new \DateTime(); if ($order->hasDiscount()) { $duration += $this->ch->getParameter('formalibre_test_month_duration'); } $interval = new \DateInterval("P{$duration}M"); $expDate->add($interval); $sws = new SharedWorkspace(); $sws->setOwner($user); $sws->setMaxUser($details['max_users']); $sws->setMaxRes($details['max_resources']); $sws->setMaxStorage($details['max_storage']); $sws->setExpDate($expDate); $sws->setRemoteId(0); //if it wasn't created properly, 0 means somethung went wrong obv. $this->om->persist($sws); $this->om->flush(); return $sws; }