public function newDummyOrder($client)
 {
     $res = new Order();
     $res->setClient($client);
     return $res;
 }
Пример #2
0
 /**
  * @Route("/basket-save", name="basket_save", options={"expose" = true})
  * @Template()
  */
 public function saveBasketAction(Request $request)
 {
     $session = $request->getSession();
     $lists = $session->get('lists');
     $group = hash('sha256', time());
     $em = $this->getDoctrine()->getManager();
     foreach ($lists as $id => $list) {
         $banner = $this->getDoctrine()->getRepository('AppBundle:banner')->findOneById($id);
         $order = new Order();
         $order->setBanner($banner);
         $order->setClient($this->getUser());
         $order->setPrice($banner->getPrice());
         $order->setOrderGroup($group);
         $order->setStatus(0);
         $order->setEnabled(true);
         $em->persist($order);
         $em->flush($order);
         $em->refresh($order);
         $months = unserialize($lists[$id]['months']);
         foreach ($months as $date => $val) {
             if ($val) {
                 $month = new OrderMonth();
                 $date = new \DateTime($date . '-01 00:00:00');
                 $month->setDate($date);
                 $month->setOrder($order);
                 $month->setEnabled(1);
                 $em->persist($month);
                 $em->flush($month);
                 $em->refresh($month);
             }
         }
     }
     $banners = $this->getDoctrine()->getRepository('AppBundle:Order')->findByOrderGroup($group);
     return array('banners' => $banners, 'group' => $group);
 }