| Server IP : 172.67.201.108 / Your IP : 216.73.216.11 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/hotel-dev/public_html/classes/lib/ |
Upload File : |
<?php
namespace classes\lib;
class SurveyEngine {
public const QUESTION_TYPES = [
'text_line' => 'Single line text entry',
'text_box' => 'Multiple line text entry',
'email' => 'Email address',
'radio_group' => 'Group of radio buttons',
'checkbox' => 'Single checkbox',
'checkbox_group' => 'Group of checkboxes',
];
public const AUTO_POPULATE_FIELDS = [
'' => 'None',
'last_name' => 'Last Name',
'first_name' => 'First Name',
'combined_name' => 'Combined First and Last Name',
'title' => 'Title',
'org' => 'Hotel/Company',
'email' => 'Email',
];
public const PLACEHOLDERS = [
'last_name' => 'Last Name',
'first_name' => 'First Name',
'title' => 'Title',
'org' => 'Hotel/Company',
'email' => 'Email',
'event_name' => 'Event Name',
'event_date' => 'Event Date',
'event_time' => 'Event Time',
'survey_link' => 'Survey Link - start tag',
'/survey_link' => 'Survey Link - end tag',
];
public static function copy_template(int $source_template_id): int {
global $db;
try {
$db->beginTransaction();
$sql = "
INSERT INTO survey_templates (
description,
default_email_html,
default_email_subject,
default_email_reply_name,
default_email_reply_address,
default_cgr_type_id,
create_date,
update_date,
create_by,
update_by
)
SELECT
CONCAT(description, ' - COPY'),
default_email_html,
default_email_subject,
default_email_reply_name,
default_email_reply_address,
default_cgr_type_id,
NOW(),
NOW(),
:user_id,
:user_id
FROM survey_templates WHERE id = :id
";
$stmt_update = $db->prepare($sql);
$stmt_update->execute([
':id' => $source_template_id,
':user_id' => trim($_SESSION['user_id']),
]);
$new_template_id = last_id();
$sql = "
INSERT INTO survey_template_questions (
survey_template_id,
question_type,
question_text,
required,
read_only,
auto_populate_field,
seq,
answer_list,
horizontal_layout,
create_date,
update_date,
create_by,
update_by
)
SELECT
:new_template_id,
question_type,
question_text,
required,
read_only,
auto_populate_field,
seq,
answer_list,
horizontal_layout,
NOW(),
NOW(),
:user_id,
:user_id
FROM survey_template_questions WHERE survey_template_id = :source_template_id
";
$stmt_update = $db->prepare($sql);
$stmt_update->execute([
':source_template_id' => $source_template_id,
':new_template_id' => $new_template_id,
':user_id' => trim($_SESSION['user_id']),
]);
$db->commit();
} catch(\Exception $e) {
db_err_rollback($e);
}
return $new_template_id;
}
}