-
-
Save gflower1/141a7671dc98b208b308f6888c7cb75e to your computer and use it in GitHub Desktop.
Fluent Forms Template - Employment Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use FluentForm\App\Services\Emogrifier\Emogrifier; | |
use FluentForm\App\Services\FormBuilder\ShortCodeParser; | |
use FluentForm\Framework\Foundation\Application; | |
use FluentFormPdf\Classes\Templates\TemplateManager; | |
use FluentForm\Framework\Helpers\ArrayHelper as Arr; | |
use FluentFormPdf\Classes\Controller\AvailableOptions as PdfOptions; | |
class ApplicationTemplate extends TemplateManager | |
{ | |
public function __construct(Application $app) | |
{ | |
parent::__construct($app); | |
} | |
public function getDefaultSettings($form) | |
{ | |
return [ | |
'header' => '<h2>PDF Title</h2>', | |
'footer' => '<table width="100%"><tr><td width="50%">{DATE j-m-Y}</td><td width="50%" style="text-align: right;" align="right">{PAGENO}/{nbpg}</td></tr></table>', | |
'body' => '<div id="page1-div" class="page" style="position: relative; font-family: sans-serif; font-size: 14; width: 816px; height: 1056px; background-image: url(https://mikehooks.com/wp-content/themes/Divi/images/application_template.png); background-color: #fff; background-size: 816px 1056px; background-repeat: no-repeat"> | |
<span class="text" style="position:absolute;left:685px;top:48px">{date.m/d/Y}</span> | |
<span style="position:absolute;left:240px;top:224px">{inputs.chained_select}</span> | |
<span style="position:absolute;text-align: right;right:75px;top:224px">{inputs.datetime}</span> | |
<span style="position:absolute;left:110px;top:244px">{inputs.names}</span> | |
<span style="position:absolute;left:580px;top:244px">{inputs.email}</span> | |
<span style="position:absolute;left:215px;top:266px">{inputs.input_mask_1}</span> | |
<span style="position:absolute;left:370px;top:266px">{inputs.phone}</span> | |
<span style="position:absolute;text-align: right;right:75px;top:266px">{inputs.dropdown_1}</span> | |
<span style="position:absolute;text-align: right;right:75px;top:285px">{inputs.names_2}</span> | |
<span style="position:absolute;left:190px;top:285px">{inputs.address_1.address_line_1}</span> | |
<span style="position:absolute;left:190px;top:305px">{inputs.address_1.city}</span> | |
<span style="position:absolute;left:425px;top:305px">{inputs.address_1.state}</span> | |
<span style="position:absolute;left:515px;top:305px">{inputs.address_1.zip}</span> | |
<span style="position:absolute;left:190px;top:325px">{inputs.address_2.address_line_1}</span> | |
<span style="position:absolute;left:190px;top:345px">{inputs.address_2.city}</span> | |
<span style="position:absolute;left:425px;top:345px">{inputs.address_2.state}</span> | |
<span style="position:absolute;left:515px;top:345px">{inputs.address_2.zip}</span> | |
<span style="position:absolute;left:425px;top:934px" >{inputs.phone_1}</span> | |
</div>' | |
]; | |
} | |
public function getSettingsFields() | |
{ | |
return array( | |
[ | |
'key' => 'header', | |
'label' => 'Header Content', | |
'tips' => 'Write your header content which will be shown every page of the PDF', | |
'component' => 'wp-editor' | |
], | |
[ | |
'key' => 'body', | |
'label' => 'PDF Body Content', | |
'tips' => 'Write your Body content for actual PDF body', | |
'component' => 'wp-editor' | |
], | |
[ | |
'key' => 'footer', | |
'label' => 'Footer Content', | |
'tips' => 'Write your Footer content which will be shown every page of the PDF', | |
'component' => 'wp-editor' | |
] | |
); | |
} | |
public function generatePdf($submissionId, $feed, $outPut = 'I', $fileName = '') | |
{ | |
$settings = $feed['settings']; | |
$submission = wpFluent()->table('fluentform_submissions') | |
->where('id', $submissionId) | |
->first(); | |
$formData = json_decode($submission->response, true); | |
$settings = ShortCodeParser::parse($settings, $submissionId, $formData); | |
$htmlBody = $settings['header']; | |
$htmlBody .= $settings['body']; | |
$footer = $settings['footer']; | |
if(!$fileName) { | |
$fileName = ShortCodeParser::parse( $feed['name'], $submissionId, $formData); | |
$fileName = sanitize_title($fileName, 'pdf-file', 'display'); | |
} | |
return $this->pdfBuilder($fileName, $feed, $htmlBody, $footer, $outPut); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment