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'); } }