private function buildPDFApplication($id, $file = null) { $record = $this->model->get($id); if (!$record) { return; } $set = $this->setModel->get($record->wrk_set_id); $template = new \Nette\Templating\FileTemplate(__DIR__ . '/../../templates/pdf/workApplication-' . $set->template . '.latte'); $template->registerFilter(new \Nette\Latte\Engine()); $template->registerHelperLoader('\\Nette\\Templating\\Helpers::loader'); $templateHeader = new \Nette\Templating\FileTemplate(__DIR__ . '/../../templates/pdf/generalHeader.latte'); $templateHeader->registerFilter(new \Nette\Latte\Engine()); $templateHeader->registerHelperLoader('\\Nette\\Templating\\Helpers::loader'); $templateOddFooter = new \Nette\Templating\FileTemplate(__DIR__ . '/../../templates/pdf/generalOddFooter.latte'); $templateOddFooter->registerFilter(new \Nette\Latte\Engine()); $templateOddFooter->registerHelperLoader('\\Nette\\Templating\\Helpers::loader'); $templateEvenFooter = new \Nette\Templating\FileTemplate(__DIR__ . '/../../templates/pdf/generalEvenFooter.latte'); $templateEvenFooter->registerFilter(new \Nette\Latte\Engine()); $templateEvenFooter->registerHelperLoader('\\Nette\\Templating\\Helpers::loader'); $template->date = new \Nette\DateTime(); $template->work = $record; $template->idea = $this->ideaModel->get($record->wrk_assignment_id); $template->goals = $this->ideaModel->getGoals($record->wrk_assignment_id); $template->outline = $this->ideaModel->getOutline($record->wrk_assignment_id); $template->roles = $this->model->getAssignedRolesForPrintApplication($id); require "../vendor/mpdf/mpdf/mpdf.php"; $mpdf = new \mPDF('', 'A4', 10, 'arial'); $mpdf->mirrorMargins = true; $mpdf->ignore_invalid_utf8 = true; $mpdf->WriteHTML(file_get_contents('css/pdf.css'), 1); $mpdf->SetHTMLHeader($templateHeader->__toString()); $mpdf->SetHTMLFooter($templateEvenFooter->__toString(), "E"); $mpdf->SetHTMLFooter($templateOddFooter->__toString(), "O"); $mpdf->WriteHTML($template->__toString()); if ($file) { $mpdf->Output($file, "F"); return; } $mpdf->Output(); }
public function renderDefault() { $this->template->ideas = $this->model->query("SELECT count(*) as total FROM wrk_assignment")->fetch(); $this->template->assignments = $this->model->query("SELECT count(*) as total FROM wrk_work")->fetch(); $this->template->sets = $this->model->query("SELECT count(*) as total FROM wrk_set")->fetch(); }