mirror of
https://github.com/salesagility/SuiteCRM.git
synced 2025-03-16 06:13:34 +00:00
Survey fix
This commit is contained in:
parent
7922af3146
commit
28302fdad6
1 changed files with 89 additions and 66 deletions
|
@ -2,26 +2,49 @@
|
|||
|
||||
//Grab the survey
|
||||
if (empty($_REQUEST['id'])) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
header('HTTP/1.0 404 Not Found');
|
||||
exit();
|
||||
}
|
||||
$surveyId = $_REQUEST['id'];
|
||||
|
||||
$isValidator = new SuiteValidator();
|
||||
$surveyId = '';
|
||||
|
||||
if (!empty($_REQUEST['id']) && $isValidator->isValidId($_REQUEST['id'])) {
|
||||
$surveyId = $_REQUEST['id'];
|
||||
} else {
|
||||
LoggerManager::getLogger()->warn('Invalid survey ID.');
|
||||
}
|
||||
|
||||
$survey = BeanFactory::getBean('Surveys', $surveyId);
|
||||
|
||||
if (empty($survey->id)) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
header('HTTP/1.0 404 Not Found');
|
||||
exit();
|
||||
}
|
||||
if ($survey->status == 'Closed') {
|
||||
if ($survey->status === 'Closed') {
|
||||
displayClosedPage($survey);
|
||||
exit();
|
||||
}
|
||||
if ($survey->status != 'Public') {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
if ($survey->status !== 'Public') {
|
||||
header('HTTP/1.0 404 Not Found');
|
||||
exit();
|
||||
}
|
||||
$contactId = $_REQUEST['contact'];
|
||||
|
||||
$trackerId = !empty($_REQUEST['tracker']) ? $_REQUEST['tracker'] : '';
|
||||
$contactId = '';
|
||||
|
||||
if (!empty($_REQUEST['contact']) && $isValidator->isValidId($_REQUEST['contact'])) {
|
||||
$contactId = $_REQUEST['contact'];
|
||||
} else {
|
||||
LoggerManager::getLogger()->warn('Invalid contact ID in survey.');
|
||||
}
|
||||
|
||||
$trackerId = '';
|
||||
|
||||
if (!empty($_REQUEST['tracker']) && $isValidator->isValidId($_REQUEST['tracker'])) {
|
||||
$trackerId = $_REQUEST['tracker'];
|
||||
} else {
|
||||
LoggerManager::getLogger()->warn('Invalid tracker ID in survey.');
|
||||
}
|
||||
|
||||
$themeObject = SugarThemeRegistry::current();
|
||||
$companyLogoURL = $themeObject->getImageURL('company_logo.png');
|
||||
|
@ -54,7 +77,7 @@ EOF;
|
|||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
use SuiteCRM\Utility\SuiteValidator; ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
@ -128,15 +151,15 @@ function displaySurvey($survey, $contactId, $trackerId)
|
|||
<input type="hidden" name="tracker" value="<?= $trackerId ?>">
|
||||
<?php
|
||||
$questions = $survey->get_linked_beans('surveys_surveyquestions', 'SurveyQuestions');
|
||||
usort(
|
||||
usort(
|
||||
$questions,
|
||||
function ($a, $b) {
|
||||
return $a->sort_order - $b->sort_order;
|
||||
}
|
||||
);
|
||||
foreach ($questions as $question) {
|
||||
displayQuestion($survey, $question);
|
||||
} ?>
|
||||
foreach ($questions as $question) {
|
||||
displayQuestion($survey, $question);
|
||||
} ?>
|
||||
<button class="btn btn-primary" type="submit"><?php echo $survey->getSubmitText(); ?></button>
|
||||
</form>
|
||||
<?php
|
||||
|
@ -153,32 +176,32 @@ function displayQuestion($survey, $question)
|
|||
<div class="form-group">
|
||||
<?php
|
||||
$options = array();
|
||||
foreach ($question->get_linked_beans(
|
||||
foreach ($question->get_linked_beans(
|
||||
'surveyquestions_surveyquestionoptions',
|
||||
'SurveyQuestionOptions',
|
||||
'sort_order'
|
||||
) as $option) {
|
||||
$optionArr = array();
|
||||
$optionArr['id'] = $option->id;
|
||||
$optionArr['name'] = $option->name;
|
||||
$options[] = $optionArr;
|
||||
}
|
||||
switch ($question->type) {
|
||||
$optionArr = array();
|
||||
$optionArr['id'] = $option->id;
|
||||
$optionArr['name'] = $option->name;
|
||||
$options[] = $optionArr;
|
||||
}
|
||||
switch ($question->type) {
|
||||
|
||||
case "Textbox":
|
||||
echo "<textarea class=\"form-control\" id='question" .
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]'></textarea>";
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]'></textarea>";
|
||||
break;
|
||||
case "Checkbox":
|
||||
echo "<div class='checkbox'><label>";
|
||||
echo "<input id='question" .
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' type='checkbox'/>";
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' type='checkbox'/>";
|
||||
echo "</label></div>";
|
||||
break;
|
||||
case "Radio":
|
||||
|
@ -186,12 +209,12 @@ function displayQuestion($survey, $question)
|
|||
echo "<div class='radio'>";
|
||||
echo "<label>";
|
||||
echo "<input id='question" .
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' value='" .
|
||||
$option['id'] .
|
||||
"' type='radio'/>";
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' value='" .
|
||||
$option['id'] .
|
||||
"' type='radio'/>";
|
||||
echo $option['name'];
|
||||
echo "</label>";
|
||||
echo "</div>";
|
||||
|
@ -238,10 +261,10 @@ function displayQuestion($survey, $question)
|
|||
function displayTextField($question)
|
||||
{
|
||||
echo "<input class=\"form-control\" id='question" .
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' type='text'/>";
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' type='text'/>";
|
||||
}
|
||||
|
||||
function displayScaleField($question)
|
||||
|
@ -254,12 +277,12 @@ function displayScaleField($question)
|
|||
echo "</tr><tr>";
|
||||
for ($x = 1; $x <= $scaleMax; $x++) {
|
||||
echo "<td><input id='question" .
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' value='" .
|
||||
$x .
|
||||
"' type='radio'/></td>";
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' value='" .
|
||||
$x .
|
||||
"' type='radio'/></td>";
|
||||
}
|
||||
echo "</tr></table>";
|
||||
}
|
||||
|
@ -270,12 +293,12 @@ function displayRatingField($question)
|
|||
echo "<div class='starRating'>";
|
||||
for ($x = 1; $x <= $ratingMax; $x++) {
|
||||
echo "<input class='rating' id='question" .
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' value='" .
|
||||
$x .
|
||||
"' type='radio'/>";
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' value='" .
|
||||
$x .
|
||||
"' type='radio'/>";
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
@ -299,15 +322,15 @@ function displayMatrixField($survey, $question, $options)
|
|||
echo "</td>";
|
||||
foreach ($matrixOptions as $x => $matrixOption) {
|
||||
echo "<td style='width:25%'><input id='question" .
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"][" .
|
||||
$option['id'] .
|
||||
"]'
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"][" .
|
||||
$option['id'] .
|
||||
"]'
|
||||
value='" .
|
||||
$x .
|
||||
"' type='radio'/></td>";
|
||||
$x .
|
||||
"' type='radio'/></td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
|
@ -318,10 +341,10 @@ function displayDateTimeField($question)
|
|||
{
|
||||
echo "<div class=\"input-group\">";
|
||||
echo "<input class=\"form-control datetimefield\" id='question" .
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' type='text'/>";
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' type='text'/>";
|
||||
echo "<div class=\"input-group-addon ui-datetimepicker-trigger\"><span class=\"suitepicon suitepicon-module-calendar\"></span></div></div>";
|
||||
}
|
||||
|
||||
|
@ -329,10 +352,10 @@ function displayDateField($question)
|
|||
{
|
||||
echo "<div class=\"input-group\">";
|
||||
echo "<input class=\"form-control datefield\" id='question" .
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' type='text'/>";
|
||||
$question->id .
|
||||
"' name='question[" .
|
||||
$question->id .
|
||||
"]' type='text'/>";
|
||||
echo "<div class=\"input-group-addon ui-datepicker-trigger\"><span class=\"suitepicon suitepicon-module-calendar\"></span></div></div>";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue