function orderFormSucceeded(Form $form, $values) { $user = $this->findUser(); $order = new Order($user); $order->setType($values->type); $order->setAmount($values->amount); $order->setName($values->name); $order->setPhone($values->phone); $order->setBusinessName($values->business_name); $order->setIc($values->ic); $order->setDic($values->dic); $order->setAddress($values->address); $order->setInvoiceAddress($values->invoice_address); $order->setShippingMethod($values->shipping_method); $order->setNote($values->note); $price_index = $values->type . '.price_per_unit'; $order->setPricePerUnit(Settings::get($price_index)); $this->em->persist($order); $this->em->flush(); $order->createNum(); $this->em->flush(); $this->orderManager->invoice($order, true); $mail = new Message(); $mail->setFrom(Settings::get('contact.name') . ' <' . Settings::get('contact.email') . '>')->addTo($order->getUser()->getEmail())->setSubject('Your order ' . $order->getNum())->setBody('You have placed a new order on kryo.mossbauer.cz. Please follow payment instructions in attachment.'); $mail->addAttachment(WWW_DIR . '/../temp/' . $order->getInvoiceFileName()); $this->mailer->send($mail); $this->flashMessage('Order has been successfully created!', 'success'); $this->redirect('this'); }
/** * @param $id */ function handleInvoice($id) { /** @var Order $order */ $order = $this->em->find(Order::class, $id); if (!$order) { return; } $this->orderManager->invoice($order); }
function handleFulfill($id) { /** @var Order $order */ $order = $this->em->find(Order::class, $id); if ($order) { $this->orderManager->changeStatus($order, Order::STATUS_FULFILLED); $mail = new Message(); $mail->setFrom(Settings::get('contact.name') . ' <' . Settings::get('contact.email') . '>')->addTo($order->getUser()->getEmail())->setSubject('Order ' . $order->getNum() . ' ready')->setBody('Your order is ready to be shipped / ready for pick up.'); $this->mailer->send($mail); $this->flashMessage("Order {$order->getNum()} fulfilled", 'info'); $this->redirect('this'); } }