/** * Changes outline order * @param $id * @param $order * @param $direction */ private function changeOutlineOrder($id, $order, $direction) { $data = $this->model->get($id); if ($this->checkAvailability($data)) { $this->model->changeOutlineOrder($id, $order, $direction); } $this->template->outline = $this->model->getOutline($id); if ($this->isAjax()) { $this->redrawControl('outlineList'); $this->redrawControl('flashMessages'); } }
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 addOutlineFormSucceeded($form, $values) { $data = $this->model->get($values->id); if ($data && $data->works == 0 && ($this->user->isInRole("administrator") || $this->user->id == $data->user_id)) { try { $this->model->addOutline($values->id, $values->description); } catch (Exception $e) { $this->flashMessage("Přidání bodu osnovy se nepodařilo.", "danger"); } } else { $this->flashMessage("Bod osnovy nelze přidat.", "danger"); } if (!$this->isAjax()) { $this->redirect('this'); } else { $this->template->outline = $this->model->getOutline($values->id); $this->invalidateControl('outlineList'); $this->invalidateControl('outlineForm'); $this->invalidateControl('flashMessages'); $form->setValues(array(), TRUE); } }