/** * init */ public function init() { $this->setPageTitle('COA Setup'); $this->term = $this->getPage()->getTerm(); $this->setup = \coa\Db\CoaSetup::getMapper()->findByCourseId($this->term->courseId); if (!$this->setup) { $this->setup = new \coa\Db\CoaSetup(); $this->setup->courseId = $this->term->courseId; } $ff = \Form\Factory::getInstance(); $this->form = $ff->createForm('settings', $this->setup); $this->form->attach(new Save('update', 'fa fa-arrow-left'))->setRedirectUrl($this->getBackUrl()); $this->form->attach(new Save('save', 'fa fa-refresh'))->setRedirectUrl($this->getUri()); $this->form->attach($ff->createEventLink('cancel'))->setRedirectUrl($this->getBackUrl()); $this->form->addField($ff->createFieldText('pdfTopMargin'))->setLabel('Top Content padding'); if (!$this->setup->pdfBgImage) { $this->form->addField($ff->createFieldFile('pdfBgImage'))->setLabel('Certificate Background')->setNotes('Set the background image of the Certificate. (Recommended Size: 1343x929)'); } else { $delUrl = htmlentities($this->getUri()->set('delBgImage')->toString()); $html = <<<HTML <p> <a href="{$this->setup->getPdfBgImageUrl()->toString()}" target="_blank"><img style="width: 100px;" src="{$this->setup->getPdfBgImageUrl()->toString()}" /></a> <br/> <a href="{$delUrl}">Delete</a> </p> HTML; $this->form->addField($ff->createFieldRenderer('bgImage', $html))->setLabel('Certificate Background')->setNotes('Set the background image of the Certificate. (Recommended Size: 1343x929)'); } $this->form->addField($ff->createFieldTextarea('pdfContent'))->setLabel('Certificate HTML')->setNotes('Available variables: {name}, {dateFrom}, {dateTo}, {date}, {year}, {totalUnits}, {totalPlaces}, {cpd}'); $this->form->addField($ff->createFieldText('emailSubject'))->setLabel('Email Subject'); $this->form->addField($ff->createFieldTextarea('emailContent'))->addCssClass('mce-full')->setNotes('Available variables: {name}, {dateFrom}, {dateTo}, {date}, {year}, {email}, {totalUnits}, {totalPlaces}, {cpd}'); $this->addChild($ff->createFormRenderer($this->form), $this->form->getId()); }
/** * */ public function doPrevCert() { $filter = $this->table->getFilterValues(); $image = $this->setup->getPdfBgImageUrl()->toString(); $dateFrom = $filter['dateFrom']->floor()->toString(\Tk\Date::LONG_DATE); $dateTo = $filter['dateTo']->ceil()->toString(\Tk\Date::LONG_DATE); $tpl = $this->setup->pdfContent; $obj = current($this->getList(true)); $dompdf = $this->makeCert($obj, $dateFrom, $dateTo, $image, $tpl); $dompdf->stream('coaPreview.pdf'); exit; }