/**
  * @Route("/register/{order_id}")
  * @Route("/register/{order_id}/{allow_split}", name="payment_cash_confirm")
  * @Template()
  */
 public function registerAction($order_id, $allow_split = false)
 {
     $em = $this->getDoctrine()->getManager();
     $order = $em->find('ClubShopBundle:Order', $order_id);
     $payment = $em->getRepository('ClubShopBundle:PaymentMethod')->findOneBy(array('controller' => $this->container->getParameter('club_payment_cash.controller')));
     $log = new \Club\ShopBundle\Entity\PurchaseLog();
     $log->setOrder($order);
     $log->setPaymentMethod($payment);
     $log->setAmount($order->getAmountLeft());
     $log->setAccepted(true);
     $log->setCurrency($order->getCurrency());
     $form = $this->processForm($log, $order, $allow_split);
     if ($form instanceof RedirectResponse) {
         return $form;
     }
     return array('form' => $form->createView(), 'order' => $order);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getContainer()->get('doctrine.orm.default_entity_manager');
     $product = $em->find('ClubShopBundle:Product', $input->getArgument('product'));
     $location = $em->find('ClubUserBundle:Location', $input->getArgument('location'));
     $payment = $em->find('ClubShopBundle:PaymentMethod', 1);
     $fh = fopen($input->getArgument('file'), 'r');
     while (!feof($fh)) {
         $member_number = trim(fgets($fh, 1024));
         if (strlen($member_number) > 0) {
             $user = $em->getRepository('ClubUserBundle:User')->findOneBy(array('member_number' => $member_number));
             if (!$user) {
                 throw new \Exception('No such user: '******'order');
             $order->createSimpleOrder($user, $location);
             $cart_prod = new \Club\ShopBundle\Entity\CartProduct();
             $cart_prod->setType('subscription');
             $cart_prod->setQuantity(1);
             $cart_prod->setPrice($product->getPrice());
             $cart_prod->setProductName($product->getProductName());
             $cart_prod->setProduct($product);
             foreach ($product->getProductAttributes() as $attr) {
                 $product_attr = new \Club\ShopBundle\Entity\CartProductAttribute();
                 $product_attr->setCartProduct($cart_prod);
                 $product_attr->setValue($attr->getValue());
                 $product_attr->setAttributeName($attr->getAttribute());
                 $cart_prod->addCartProductAttribute($product_attr);
             }
             $order->addCartProduct($cart_prod);
             $order->save();
             $p = new \Club\ShopBundle\Entity\PurchaseLog();
             $p->setAmount($order->getOrder()->getAmountLeft() * 100);
             $p->setCurrency('DKK');
             $p->setAccepted(true);
             $p->setOrder($order->getOrder());
             $p->setPaymentMethod($payment);
             $em->persist($p);
             $order->makePayment($p);
             $em->flush();
         }
     }
     $em->flush();
 }