Exemple #1
0
 public function changeStatusOrderAction(Request $request)
 {
     $orderId = $request->get('orderId');
     $order = $this->getDoctrine()->getRepository('ShopBundle:Order')->find($orderId);
     if (!$order) {
         return new JsonResponse(array('errors' => true));
     }
     $status = $request->get('status');
     if ($status) {
         $em = $this->getDoctrine()->getEntityManager();
         $order->setStatus((int) $status);
         $em->persist($order);
         $em->flush();
         $mailer = $this->get('mailer');
         $message = \Swift_Message::newInstance()->setSubject("Изменен статус заказа {$orderId} в магазине sweet-smoke.org")->setFrom(array('*****@*****.**' => 'SweetSmoke'))->setTo(array('*****@*****.**', $order->getEmail()))->setContentType('text/html')->setBody($this->renderView("@Shop/Messages/change_status_order.html.twig", array('order' => $order, 'status' => OrderStatus::getAsText($order->getStatus()))));
         $mailer->send($message);
     }
     return new JsonResponse(array('errors' => false));
 }
 public function ordersAction($page)
 {
     $ordersOnPage = $this->getParameter('orders_on_page');
     $repository = $this->getDoctrine()->getRepository('ShopBundle:Order');
     $orders = $repository->getOrders($page, $ordersOnPage);
     foreach ($orders as $order) {
         $this->getDoctrine()->getRepository('ShopBundle:Order')->setOrderProductsArray($order);
     }
     $maxPage = $repository->getMaxPage($ordersOnPage);
     $paginator = $this->get('paginator');
     $pages = $paginator->getPages($page, $maxPage);
     return $this->render('@Shop/admin/orders.html.twig', array('orders' => $orders, 'orderStatuses' => OrderStatus::map(), 'maxPage' => $maxPage, 'pages' => $pages, 'currentPage' => $page));
 }
Exemple #3
0
 public function getTextStatus()
 {
     return OrderStatus::getAsText($this->getStatus());
 }