Esempio n. 1
0
 function displayAnswers($questions_id)
 {
     $psQuestion = new PluginSurveyticketQuestion();
     $psAnswer = new PluginSurveyticketAnswer();
     $a_answers = $psAnswer->find("`plugin_surveyticket_questions_id`='" . $questions_id . "'");
     $psQuestion->getFromDB($questions_id);
     switch ($psQuestion->fields['type']) {
         case 'dropdown':
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='2' align='center'>";
             echo "<select name='question" . $questions_id . "' id='question" . $questions_id . "' >";
             echo "<option>" . Dropdown::EMPTY_VALUE . "</option>";
             foreach ($a_answers as $data_answer) {
                 echo "<option value='" . $data_answer['id'] . "'>" . $psAnswer->getAnswer($data_answer) . "</option>";
             }
             echo "</select>";
             echo "</td>";
             echo "</tr>";
             break;
         case 'checkbox':
             $i = 0;
             foreach ($a_answers as $data_answer) {
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='40' align='center'>";
                 echo "<input type='checkbox' name='question" . $questions_id . "[]' id='question" . $questions_id . "-" . $i . "' \n                  value='" . $data_answer['id'] . "' />";
                 echo "</td>";
                 echo "<td>";
                 echo $psAnswer->getAnswer($data_answer);
                 echo "</td>";
                 $this->displayAnswertype($data_answer['answertype'], "text-" . $questions_id . "-" . $data_answer['id']);
                 echo "</tr>";
                 $i++;
             }
             break;
         case 'radio':
         case 'yesno':
             $i = 0;
             foreach ($a_answers as $data_answer) {
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='40' align='center'>";
                 echo "<input type='radio' name='question" . $questions_id . "' id='question" . $questions_id . "-" . $i . "' \n                  value='" . $data_answer['id'] . "' />";
                 echo "</td>";
                 echo "<td>";
                 echo $psAnswer->getAnswer($data_answer);
                 echo "</td>";
                 $this->displayAnswertype($data_answer['answertype'], "text-" . $questions_id . "-" . $data_answer['id']);
                 echo "</tr>";
                 $i++;
             }
             break;
         case 'date':
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='2' align='center'>";
             $data_answer = current($a_answers);
             Html::showDateTimeField("question" . $questions_id, array('rand' => "question" . $questions_id));
             echo '<input type="hidden" name="realquestion' . $questions_id . '" id="realquestion' . $questions_id . '" value="' . $data_answer['id'] . '" />';
             echo "</td>";
             echo "</tr>";
             break;
         case 'input':
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='2' align='center'>";
             $data_answer = current($a_answers);
             echo '<input type="text" name="question' . $questions_id . '" id="question' . $questions_id . '" value="" size="71" />';
             echo '<input type="hidden" name="realquestion' . $questions_id . '" id="realquestion' . $questions_id . '" value="' . $data_answer['id'] . '" />';
             echo "</td>";
             echo "</tr>";
             break;
     }
     return count($a_answers);
 }
Esempio n. 2
0
  Surveyticket plugin is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with Surveyticket plugin. If not, see <http://www.gnu.org/licenses/>.

  ------------------------------------------------------------------------

  @package   Surveyticket plugin
  @author    David Durieux
  @copyright Copyright (c) 2012-2013 Surveyticket plugin team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/surveyticket
  @since     2012

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
header("Content-Type: text/html; charset=UTF-8");
//print_r($_POST);
$psSurvey = new PluginSurveyticketSurvey();
$psAnswer = new PluginSurveyticketAnswer();
if ($psAnswer->getFromDB($_POST[$_POST['myname']])) {
    if ($psAnswer->fields['link'] > 0) {
        $psSurvey->displaySurvey($psAnswer->fields['link']);
    }
}
Esempio n. 3
0
  ------------------------------------------------------------------------

  @package   Surveyticket plugin
  @author    David Durieux
  @copyright Copyright (c) 2012-2013 Surveyticket plugin team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/surveyticket
  @since     2012

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Html::header("survey", $_SERVER["PHP_SELF"], "plugins", "surveyticket", "answers");
$psAnswer = new PluginSurveyticketAnswer();
if (isset($_POST["add"])) {
    $psAnswer->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $psAnswer->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            $psAnswer->delete($_POST);
            Html::redirect(Toolbox::getItemTypeSearchURL('PluginSurveyticketAnswer'));
        }
    }
}
if (isset($_GET["id"])) {
Esempio n. 4
0
function plugin_surveyticket_post_init()
{
    if (strpos($_SERVER['PHP_SELF'], "ticket.form.php") && !isset($_GET['id']) && (!isset($_POST['id']) || $_POST['id'] == 0) || strpos($_SERVER['PHP_SELF'], "helpdesk.public.php") && isset($_GET['create_ticket']) || strpos($_SERVER['PHP_SELF'], "tracking.injector.php")) {
        if (isset($_POST)) {
            $psQuestion = new PluginSurveyticketQuestion();
            $psAnswer = new PluginSurveyticketAnswer();
            //print_r($_POST);exit;
            $description = '';
            foreach ($_POST as $question => $answer) {
                if (strstr($question, "question") && !strstr($question, "realquestion")) {
                    $psQuestion->getFromDB(str_replace("question", "", $question));
                    if (is_array($answer)) {
                        // Checkbox
                        $description .= _n('Question', 'Questions', 1, 'surveyticket') . " : " . $psQuestion->fields['name'] . "\n";
                        foreach ($answer as $answers_id) {
                            if ($psAnswer->getFromDB($answers_id)) {
                                $description .= _n('Answer', 'Answers', 1, 'surveyticket') . " : " . $psAnswer->fields['name'] . "\n";
                                $qid = str_replace("question", "", $question);
                                if (isset($_POST["text-" . $qid . "-" . $answers_id]) and $_POST["text-" . $qid . "-" . $answers_id] != '') {
                                    $description .= "Texte : " . $_POST["text-" . $qid . "-" . $answers_id] . "\n";
                                }
                            }
                        }
                        $description .= "\n";
                        unset($_POST[$question]);
                    } else {
                        $real = 0;
                        if (isset($_POST['realquestion' . str_replace("question", "", $question)])) {
                            $realanswer = $answer;
                            $answer = $_POST['realquestion' . str_replace("question", "", $question)];
                            $real = 1;
                        }
                        if ($psAnswer->getFromDB($answer)) {
                            $description .= _n('Question', 'Questions', 1, 'surveyticket') . " : " . $psQuestion->fields['name'] . "\n";
                            if ($real == 1) {
                                $description .= _n('Answer', 'Answers', 1, 'surveyticket') . " : " . $realanswer . "\n";
                            } else {
                                $description .= _n('Answer', 'Answers', 1, 'surveyticket') . " : " . $psAnswer->fields['name'] . "\n";
                            }
                            $qid = str_replace("question", "", $question);
                            if (isset($_POST["text-" . $qid . "-" . $answer]) and $_POST["text-" . $qid . "-" . $answer] != '') {
                                $description .= "Texte : " . $_POST["text-" . $qid . "-" . $answer] . "\n";
                            }
                            $description .= "\n";
                            unset($_POST[$question]);
                        }
                    }
                }
            }
            if ($description != '') {
                $_POST['content'] = addslashes($description);
            }
        }
        if (!isset($_POST['add'])) {
            if (strpos($_SERVER['PHP_SELF'], "ticket.form.php")) {
                Html::header(__('New ticket'), '', "maintain", "ticket");
                PluginSurveyticketSurvey::getCentral();
                Html::footer();
                exit;
            } else {
                if (strpos($_SERVER['PHP_SELF'], "helpdesk.public.php") || strpos($_SERVER['PHP_SELF'], "tracking.injector.php")) {
                    Html::helpHeader(__('Simplified interface'), '', $_SESSION["glpiname"]);
                    PluginSurveyticketSurvey::getHelpdesk();
                    Html::helpFooter();
                    exit;
                }
            }
        }
    }
}
Esempio n. 5
0
    $questions_id = $psQuestion->add($_POST);
    if ($_POST['type'] == 'yesno') {
        $psAnswer->addYesNo($questions_id);
    } else {
        $psAnswer->removeYesNo($questions_id);
    }
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $psQuestion->update($_POST);
        if ($_POST['type'] == 'yesno') {
            $psAnswer->addYesNo($_POST['id']);
        } else {
            $psAnswer->removeYesNo($_POST['id']);
        }
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            $psQuestion->delete($_POST);
            Html::redirect(Toolbox::getItemTypeSearchURL('PluginSurveyticketQuestion'));
        }
    }
}
if (isset($_GET["id"])) {
    $psQuestion->showForm($_GET["id"]);
    $psAnswer = new PluginSurveyticketAnswer();
    $psAnswer->listAnswers($_GET["id"]);
} else {
    $psQuestion->showForm(0);
}
Html::footer();