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 actionDelete($id) { $process = explode(',', $id); foreach ($process as $record) { $selector = $this->model->getClonedSelection(); $data = $selector->where("id = " . $record)->fetch(); if ($data) { if (!$this->user->isInRole("administrator")) { $this->flashMessage("Nemáte oprávnění ke smazání sady " . $data->name . ".", "danger"); } else { try { $this->model->delete($record); $this->flashMessage("Sada " . $data->name . " byla smazána.", "success"); } catch (Exception $e) { $this->flashMessage("Během pokusu o smazání sady " . ${$data}->name . " došlo k chybě.", "danger"); } } } else { $this->flashMessage("Taková sada neexistuje.", "danger"); } } $this->redirect("default"); }