static function set($key, $value) { if (self::$instance == null) { self::init(); } self::$instance->_set($key, $value); }
function invoice(Order $order, $toFile = false) { $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'windows-1250', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 049'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->SetFont('freesans', '', 12, '', 'false'); $pdf->AddPage(); $total_price = $order->getPricePerUnit() * $order->getAmount(); $html = "\n<h1>Faktura F{$order->getNum()}</h1>\n<h3>Dodavatel</h3>\n<table>\n <tr>\n <td>" . str_replace("\n", "<br>", Settings::get('supply.address')) . "</td>\n <td></td>\n </tr>\n <tr>\n <td>IČ:</td>\n <td>" . Settings::get('supply.ic') . "</td>\n </tr>\n <tr>\n <td>DIČ:</td>\n <td>" . Settings::get('supply.dic') . "</td>\n </tr>\n</table>\n\n<h3>Odběratel</h3>\n<table>\n <tr>\n <td>{$order->getName()}</td>\n <td></td>\n </tr>\n <tr>\n <td>" . str_replace("\n", "<br>", $order->getInvoiceAddress()) . "</td>\n <td></td>\n </tr>\n <tr>\n <td>IČ:</td>\n <td>{$order->getIc()}</td>\n </tr>\n <tr>\n <td>DIČ:</td>\n <td>{$order->getDic()}</td>\n </tr>\n</table>\n\n<h3>Položky</h3>\n<table>\n <tr>\n <th><strong>Označení dodávky</strong></th>\n <th><strong>Počet m. j.</strong></th>\n <th><strong>Cena za m.j.</strong></th>\n <th><strong>Celkem</strong></th>\n </tr>\n <tr>\n <td>{$order->getType(true)}</td>\n <td>{$order->getAmount()}</td>\n <td>{$order->getPricePerUnit()},00</td>\n <td>{$total_price},00</td>\n </tr>\n</table>\n\n<h3>Celkem k úhradě: {$total_price},00 Kč</h3>\n "; $pdf->writeHTML($html); $filename = $order->getInvoiceFileName(); if ($toFile) { $pathToFile = WWW_DIR . '/../temp/' . $filename; if (file_exists($pathToFile)) { unlink($pathToFile); } $pdf->Output($pathToFile, 'F'); } else { $pdf->Output($filename, 'I'); } }
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'); }
/** * Returns PDF body based on template name * @param string $name * @param array $data * @return string */ public function getBody($name, array $data) { $pdfTemplate = $this->model->getPdfTemplateBySlug($name); $pdfContent = ''; if (is_array($pdfTemplate)) { if ($pdfTemplate['pdf_external_id']) { $API_KEY = $this->settings->get('pdf_sendwithus_key'); $options = array(); $api = new API($API_KEY, $options); $response = $api->get_template($pdfTemplate['pdf_external_id']); $response = $api->get_template($pdfTemplate['pdf_external_id'], $response->versions[0]->id); $pdfContent = $response->html; } else { $pdfContent = $pdfTemplate['content']; } } $this->template->setContent($pdfContent); $this->template->setData($data); return $this->template->process(); }
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'); } }
protected function createComponentSettingsForm() { $form = new Form(); $form->addText('helium_price', 'Helium price')->setOption('description', 'Kč per unit')->addRule(Form::INTEGER)->setRequired()->setDefaultValue(Settings::get('helium.price_per_unit')); $form->addText('nitrogen_price', 'Nitrogen price')->setOption('description', 'Kč per unit')->addRule(Form::INTEGER)->setRequired()->setDefaultValue(Settings::get('nitrogen.price_per_unit')); $form->addTextArea('address', 'Address', 10, 5)->setOption('description', 'Address to be used in invoices.')->setRequired()->setDefaultValue(Settings::get('supply.address')); $form->addText('ic', 'IČ')->setRequired()->setDefaultValue(Settings::get('supply.ic')); $form->addText('dic', 'DIČ')->setRequired()->setDefaultValue(Settings::get('supply.dic')); $form->addText('name', 'Contact name')->setDefaultValue(Settings::get('contact.name'))->setOption('description', 'Contact name is present in e-mail notification header.')->setRequired(); $form->addText('email', 'Contact e-mail')->setDefaultValue(Settings::get('contact.email'))->setOption('description', 'Contact e-mail for notifications.')->addRule(Form::EMAIL)->setRequired(); $form->addSubmit('proces', 'Save'); $form->onSuccess[] = $this->settingsFormSucceeded; return BootstrapForm::makeBootstrap($form); }