| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FireBox |
| 4 |
* @version 3.1.14 Free |
| 5 |
* |
| 6 |
* @author FirePlugins <[email protected]> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| 9 |
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 |
*/ |
| 11 |
|
| 12 |
if (!defined('ABSPATH')) |
| 13 |
{ |
| 14 |
exit; // Exit if accessed directly. |
| 15 |
} |
| 16 |
wp_enqueue_style( |
| 17 |
'fb-block-form', |
| 18 |
FBOX_MEDIA_PUBLIC_URL . 'css/blocks/form.css', |
| 19 |
[], |
| 20 |
FBOX_VERSION |
| 21 |
); |
| 22 |
|
| 23 |
$submission = $this->data->get('submission'); |
| 24 |
$form_submissions_url = admin_url('admin.php?page=firebox-submissions&form_id=' . $submission->form_id); |
| 25 |
?> |
| 26 |
<div class="fb-edit-submission-page"> |
| 27 |
<div class="submission-page-header mb-3"> |
| 28 |
<h1 class="text-default text-[32px] dark:text-white flex gap-1 items-center fp-admin-page-title"><?php echo 'Submission #' . esc_html($submission->id); ?></h1> |
| 29 |
<a href="<?php echo esc_url($form_submissions_url); ?>" class="fb-go-back"><?php echo esc_html(firebox()->_('FB_BACK_TO_SUBMISSIONS')); ?></a> |
| 30 |
</div> |
| 31 |
<div class="submission-fields"> |
| 32 |
<h3><?php echo esc_html(firebox()->_('FB_USER_SUBMITTED_DATA')); ?></h3> |
| 33 |
<?php if (isset($submission->form->fields) && is_array($submission->form->fields)): ?> |
| 34 |
<table> |
| 35 |
<tbody> |
| 36 |
<?php foreach ($submission->form->fields as $key => $field): ?> |
| 37 |
<tr> |
| 38 |
<td class="fb-submission-field-label"><?php echo esc_html($field->getLabel()); ?></td> |
| 39 |
<td> |
| 40 |
<?php |
| 41 |
$field_id = $field->getOptionValue('id'); |
| 42 |
$submission_meta_item = array_filter($submission->meta, function($meta_item) use ($field_id) { |
| 43 |
return $field_id === $meta_item->meta_key; |
| 44 |
}); |
| 45 |
$submission_meta_item = reset($submission_meta_item); |
| 46 |
$field_value = isset($submission_meta_item->meta_value) ? $submission_meta_item->meta_value : ''; |
| 47 |
|
| 48 |
// Remove pre-selected default choices |
| 49 |
if (in_array($field->getType(), ['checkbox', 'radio'])) |
| 50 |
{ |
| 51 |
$newChoices = $field->getOptionValue('choices'); |
| 52 |
foreach ($newChoices as &$choice) |
| 53 |
{ |
| 54 |
$choice['selected'] = false; |
| 55 |
} |
| 56 |
$field->setOptionValue('choices', $newChoices); |
| 57 |
|
| 58 |
// Set field to appear in 3 columns |
| 59 |
$field->setOptionValue('choiceLayout', 3); |
| 60 |
|
| 61 |
$field->setOptionValue('imageLabels', true); |
| 62 |
} |
| 63 |
|
| 64 |
$field->setValue($field_value); |
| 65 |
$field->setOptionValue('required', false); |
| 66 |
$field->addInputCSSClass('fpf-control-input-item xxlarge'); |
| 67 |
$field->getInput(); |
| 68 |
?> |
| 69 |
</td> |
| 70 |
</tr> |
| 71 |
<?php endforeach; ?> |
| 72 |
</tbody> |
| 73 |
</table> |
| 74 |
<?php else: ?> |
| 75 |
<p><?php echo esc_html(firebox()->_('FB_FORM_DETAILS_NOT_FOUND')); ?></p> |
| 76 |
<?php endif; ?> |
| 77 |
</div> |
| 78 |
<div class="submission-fields"> |
| 79 |
<h3><?php echo esc_html(firebox()->_('FB_SUBMISSION_INFO')); ?></h3> |
| 80 |
<table> |
| 81 |
<tr> |
| 82 |
<td><?php echo esc_html(fpframework()->_('FPF_STATUS')); ?></td> |
| 83 |
<td> |
| 84 |
<?php |
| 85 |
$status_payload = [ |
| 86 |
'name' => 'submission_state', |
| 87 |
'name_prefix' => 'firebox_submission', |
| 88 |
'render_group' => false, |
| 89 |
'choices' => [ |
| 90 |
'published' => fpframework()->_('FPF_PUBLISHED'), |
| 91 |
'unpublished' => fpframework()->_('FPF_UNPUBLISHED') |
| 92 |
], |
| 93 |
'value' => $submission->state === '1' ? 'published' : 'unpublished' |
| 94 |
]; |
| 95 |
$status = new \FPFramework\Base\Fields\Toggle($status_payload); |
| 96 |
$status->render(); |
| 97 |
?> |
| 98 |
</td> |
| 99 |
</tr> |
| 100 |
<tr> |
| 101 |
<td><?php echo esc_html(fpframework()->_('FPF_ID')); ?></td> |
| 102 |
<td><?php echo esc_html($submission->id); ?></td> |
| 103 |
</tr> |
| 104 |
<tr> |
| 105 |
<td><?php echo esc_html(firebox()->_('FB_FORM')); ?></td> |
| 106 |
<td><?php echo isset($submission->form->name) ? esc_html($submission->form->name) : '-'; ?></td> |
| 107 |
</tr> |
| 108 |
<tr> |
| 109 |
<td><?php echo esc_html(fpframework()->_('FPF_VISITOR_ID')); ?></td> |
| 110 |
<td><?php echo esc_html($submission->visitor_id); ?></td> |
| 111 |
</tr> |
| 112 |
<tr> |
| 113 |
<td><?php echo esc_html(fpframework()->_('FPF_USER')); ?></td> |
| 114 |
<td> |
| 115 |
<?php |
| 116 |
if ($submission->user_id !== '0') |
| 117 |
{ |
| 118 |
$user = get_user_by('id', $submission->user_id); |
| 119 |
|
| 120 |
echo '<a href="' . esc_url(get_edit_user_link($submission->user_id)) . '">' . esc_html($user->display_name) . '</a>'; |
| 121 |
} |
| 122 |
else |
| 123 |
{ |
| 124 |
echo '-'; |
| 125 |
} |
| 126 |
?> |
| 127 |
</td> |
| 128 |
</tr> |
| 129 |
<tr> |
| 130 |
<td><?php echo esc_html(firebox()->_('FB_CREATED_DATE')); ?></td> |
| 131 |
<td><?php echo esc_html(get_date_from_gmt($submission->created_at)); ?></td> |
| 132 |
</tr> |
| 133 |
<tr> |
| 134 |
<td><?php echo esc_html(firebox()->_('FB_MODIFIED_DATE')); ?></td> |
| 135 |
<td><?php echo !empty($submission->modified_at) ? esc_html(get_date_from_gmt($submission->modified_at)) : '-'; ?></td> |
| 136 |
</tr> |
| 137 |
</table> |
| 138 |
</div> |
| 139 |
<input type="hidden" name="submission_id" value="<?php echo esc_attr($submission->id); ?>" /> |
| 140 |
<input type="hidden" name="form_id" value="<?php echo esc_attr($submission->form_id); ?>" /> |
| 141 |
<input type="hidden" name="task" value="edit_submission" /> |
| 142 |
</div> |