whereIn('id', $submissionIds)
->orderBy('id', $orderBy)
->get();
if (!$form || count($submissionIds) === 0 || count($submissions) !== count($submissionIds)) {
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Exception message, not output
throw new \Exception(__('Invalid Submissions', 'fluentform'));
}
$pdfBody = $this->getBody($submissions, $form);
$pdfCss = '';
return fluentform_sanitize_html($pdfCss . $pdfBody);
}
protected function getBody($submissions, $form)
{
$pdfBody = "";
foreach ($submissions as $index => $submission) {
$formData = json_decode($submission->response, true);
$htmlBody = ShortCodeParser::parse('{all_data}', $submission, $formData, $form, false, true);
$htmlBody = '
Submission - #' . $submission->id . '
' . $htmlBody;
if ($index !== 0 && apply_filters('fluentform/bulk_entries_print_start_on_new_page', __return_true(),
$submission, $form)) {
$htmlBody = '' . $htmlBody;
}
if (apply_filters('fluentform/entry_print_with_notes', __return_true(), $form, $submission)) {
$htmlBody = $this->addNotes($htmlBody, $submission, $form);
}
$pdfBody .= apply_filters('fluentform/entry_print_body', $htmlBody, $submission, $form, $formData);
}
return apply_filters('fluentform/entries_print_body', $pdfBody, $submissions, $form);
}
protected function addNotes($htmlBody, $submission, $form)
{
$notes = (new SubmissionService())->getNotes($submission->id, ['form_id' => $form->id]);
if ($notes && count($notes) > 0) {
$notesHtml = '
Submission Notes
';
foreach ($notes as $note) {
if (isset($note->created_by)) {
$label = '' . $note->created_by . ' - ' . $note->created_at;
} else {
$label = '' . $note->name . ' - ' . $note->created_at;
}
$notesHtml .= '| ' . $label . ' |
|---|
| ' . wp_kses_post($note->value) . ' |
';
}
$htmlBody = $htmlBody . $notesHtml . '
';
}
return $htmlBody;
}
protected function getCss()
{
$mainColor = '#4F4F4F';
$fontSize = 14;
$secondaryColor = '#EAEAEA';
ob_start();
?>
.ff_pdf_wrapper, p, li, td, th {
color: ;
font-size: px;
}
.ff_all_data, table {
empty-cells: show;
border-collapse: collapse;
border: 1px solid ;
width: 100%;
color: ;
}
hr {
color: ;
background-color: ;
}
.ff_all_data th {
border-bottom: 1px solid ;
border-top: 1px solid ;
padding-bottom: 10px !important;
}
.ff_all_data tr td {
padding-left: 30px !important;
padding-top: 15px !important;
padding-bottom: 15px !important;
}
.ff_all_data tr td, .ff_all_data tr th {
border: 1px solid ;
text-align: left;
}
table, .ff_all_data {width: 100%; overflow:wrap;} img.alignright { float: right; margin: 0 0 1em 1em; }
img.alignleft { float: left; margin: 0 10px 10px 0; }
.center-image-wrapper {text-align:center;}
.center-image-wrapper img.aligncenter {display: initial; margin: 0; text-align: center;}
.alignright { float: right; }
.alignleft { float: left; }
.aligncenter { display: block; margin-left: auto; margin-right: auto; text-align: center; }
.invoice_title {
padding-bottom: 10px;
display: block;
}
.ffp_table thead th {
background-color: #e3e8ee;
color: #000;
text-align: left;
vertical-align: bottom;
}
table th {
padding: 5px 10px;
}
.ff_rtl table th, .ff_rtl table td {
text-align: right !important;
}
/* Add CSS for page breaks */
@media print { .ff-new-entry-page-break { page-break-before: always; } }