Esempio n. 1
0
 /**
  * Form builder
  *
  * @param FormBuilderInterface $builder
  * @param array $options
  *
  * @return null
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('orderTo', TextareaType::class, array('label' => 'OnlineOrder.orderTo.label'));
     $builder->add('renew', ChoiceType::class, array('label' => 'OnlineOrder.renew.label', 'choices_as_values' => true, 'choices' => OnlineOrder::choiceRenew(), 'expanded' => true, 'attr' => array('choice_label_trans' => true)));
 }
 /**
  * Form builder
  *
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('paymentType', ChoiceType::class, array('label' => 'Order.paymentType.label', 'choices_as_values' => true, 'choices' => OnlineOrder::choicePaymentType(), 'attr' => array('choice_label_trans' => true)));
 }
 /**
  * Get Query for All Entities
  *
  * @return \Doctrine\ORM\Query
  */
 public function getAllByOrderQuery(OnlineOrder $order)
 {
     $qb = $this->createQueryBuilder('t')->join('t.order', 'o')->where('o.id = :id')->setParameter('id', $order->getId())->orderBy('t.priority', 'ASC');
     $query = $qb->getQuery();
     return $query;
 }
Esempio n. 4
0
 /**
  * indexAction
  *
  * @return Response
  */
 public function validateAction()
 {
     $urlFrom = $this->getReferer();
     if (null == $urlFrom || trim($urlFrom) == '') {
         return $this->redirect($this->generateUrl('_admin_order_addGet'));
     }
     $em = $this->getEntityManager();
     $session = $this->getSession();
     $request = $this->getRequest();
     $sc = $this->getSecurityTokenStorage();
     $user = $sc->getToken()->getUser();
     $products = $session->get("OnlineProducts", array());
     if (\count($products) == 0) {
         $this->flashMsgSession("warning", "Panier vide, vous devez d'abord ajouter des produits au panier");
         return $this->redirect($this->generateUrl('_security_onlineProduct'));
     }
     $myProducts = array();
     foreach ($products as $prdId) {
         $myProduct = $em->getRepository("AcfDataBundle:OnlineProduct")->find($prdId);
         if (null != $myProduct && $myProduct->getLockout() == OnlineProduct::LOCKOUT_UNLOCKED) {
             $myProducts[] = $myProduct;
         }
     }
     if (\count($myProducts) == 0) {
         $this->flashMsgSession("warning", "Panier vide, vous devez d'abord ajouter des produits au panier");
         return $this->redirect($this->generateUrl('_security_onlineProduct'));
     }
     $this->gvars['products'] = $myProducts;
     $order = new OnlineOrder();
     $order->setSessId($session->getId());
     $order->setIpAddr($request->getClientIp());
     $order->setStatus(OnlineOrder::ST_NEW);
     $order->setUser($user);
     $orderNewForm = $this->createForm(NewOnlineOrderTForm::class, $order);
     $reqData = $request->request->all();
     if (isset($reqData['NewOnlineOrderForm'])) {
         $orderNewForm->handleRequest($request);
         if ($orderNewForm->isValid()) {
             foreach ($myProducts as $myProduct) {
                 $oproduct = new OnlineOrderProduct($myProduct);
                 $order->addProduct($oproduct);
             }
             $taxes = $em->getRepository('AcfDataBundle:OnlineTaxe')->getAllVisible();
             foreach ($taxes as $taxe) {
                 $otaxe = new OnlineOrderTaxe($taxe);
                 $order->addTaxe($otaxe);
             }
             $order->updateVal();
             $em->persist($order);
             $em->flush();
             $this->flashMsgSession('success', $this->translate('Order.add.success', array('%order%' => $order->getRef())));
             $session->set("OnlineProducts", array());
             $from = $this->getParameter('mail_from');
             $fromName = $this->getParameter('mail_from_name');
             $subject = $this->translate('_mail.order.subject', array('%order%' => $order->getRef()), 'messages');
             $mvars = array();
             $mvars['order'] = $order;
             $admins = $this->getParameter('mailtos');
             $message = \Swift_Message::newInstance();
             $message->setFrom($from, $fromName);
             foreach ($admins as $admin) {
                 $message->addTo($admin['email'], $admin['name']);
             }
             $message->setSubject($subject);
             $mvars['logo'] = $message->embed(\Swift_Image::fromPath($this->getParameter('kernel.root_dir') . '/../web/bundles/acfres/images/logo_acf.jpg'));
             $message->setBody($this->renderView('AcfSecurityBundle:Mail:neworder.html.twig', $mvars), 'text/html');
             $this->sendmail($message);
             return $this->redirect($this->generateUrl('_security_myOrder_editGet', array('uid' => $order->getId())));
         } else {
             $this->flashMsgSession('error', $this->translate('Order.add.failure'));
         }
     } else {
         $this->flashMsgSession('error', $this->translate('Order.add.failure') . " 2");
     }
     $this->gvars['OrderNewForm'] = $orderNewForm->createView();
     $this->gvars['pagetitle_txt'] = $this->translate('pagetitle.myCart.txt');
     $this->gvars['pagetitle'] = $this->translate('pagetitle.myCart');
     return $this->renderResponse('AcfSecurityBundle:Cart:index.html.twig', $this->gvars);
 }
Esempio n. 5
0
 /**
  *
  * @param OnlineOrder $order
  *            Constructor
  */
 public function __construct(OnlineOrder $order = null)
 {
     if (null != $order) {
         $this->val = $order->getVal();
         $this->orderTo = $order->getOrderTo();
         $this->paymentType = $order->getPaymentType();
         $this->user = $order->getUser();
         $this->renew = $order->getRenew();
         foreach ($order->getProducts() as $product) {
             $iproduct = new OnlineInvoiceProduct($product);
             $this->addProduct($iproduct);
         }
         foreach ($order->getTaxes() as $taxe) {
             $itaxe = new OnlineInvoiceTaxe($taxe);
             $this->addTaxe($itaxe);
         }
         $this->setOrder($order);
     } else {
         $this->val = 0;
         $this->paymentType = self::PTYPE_ONLINE;
         $this->renew = self::RENEW_AUTO;
         $this->products = new ArrayCollection();
         $this->taxes = new ArrayCollection();
     }
     $this->status = self::ST_NEW;
     $this->dtCrea = new \DateTime('now');
 }