Ejemplo n.º 1
0
 /**
  * clone of function Ticket::showFormHelpdesk()
  */
 static function getHelpdesk($ID = 0, $ticket_template = false)
 {
     global $DB, $CFG_GLPI;
     // * Added by plugin survey ticket
     $ticket = new Ticket();
     // * End of adding
     if (!Session::haveRight("create_ticket", "1")) {
         return false;
     }
     if (!$ticket_template && (Session::haveRight('validate_incident', 1) || Session::haveRight('validate_request', 1))) {
         $opt = array();
         $opt['reset'] = 'reset';
         $opt['field'][0] = 55;
         // validation status
         $opt['searchtype'][0] = 'equals';
         $opt['contains'][0] = 'waiting';
         $opt['link'][0] = 'AND';
         $opt['field'][1] = 59;
         // validation aprobator
         $opt['searchtype'][1] = 'equals';
         $opt['contains'][1] = Session::getLoginUserID();
         $opt['link'][1] = 'AND';
         $url_validate = $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($opt, '&');
         if (TicketValidation::getNumberTicketsToValidate(Session::getLoginUserID()) > 0) {
             echo "<a href='{$url_validate}' title=\"" . __s('Ticket waiting for your approval') . "\"\n                   alt=\"" . __s('Ticket waiting for your approval') . "\">" . __('Tickets awaiting approval') . "</a><br><br>";
         }
     }
     $query = "SELECT `realname`, `firstname`, `name`\n                FROM `glpi_users`\n                WHERE `id` = '{$ID}'";
     $result = $DB->query($query);
     $email = UserEmail::getDefaultForUser($ID);
     // Set default values...
     $default_values = array('_users_id_requester_notif' => array('use_notification' => $email == "" ? 0 : 1), 'nodelegate' => 1, '_users_id_requester' => 0, 'name' => '', 'content' => '', 'itilcategories_id' => 0, 'locations_id' => 0, 'urgency' => 3, 'itemtype' => '', 'items_id' => 0, 'entities_id' => $_SESSION['glpiactive_entity'], 'plan' => array(), 'global_validation' => 'none', 'due_date' => 'NULL', 'slas_id' => 0, '_add_validation' => 0, 'type' => Entity::getUsedConfig('tickettype', $_SESSION['glpiactive_entity'], '', Ticket::INCIDENT_TYPE), '_right' => "id");
     // Get default values from posted values on reload form
     if (!$ticket_template) {
         if (isset($_POST)) {
             $values = $_POST;
         }
     }
     // Restore saved value or override with page parameter
     $saved = $ticket->restoreInput();
     foreach ($default_values as $name => $value) {
         if (!isset($values[$name])) {
             if (isset($saved[$name])) {
                 $values[$name] = $saved[$name];
             } else {
                 $values[$name] = $value;
             }
         }
     }
     if (!$ticket_template) {
         echo "<form method='post' name='helpdeskform' action='" . $CFG_GLPI["root_doc"] . "/front/tracking.injector.php' enctype='multipart/form-data'>";
     }
     $delegating = User::getDelegateGroupsForUser($values['entities_id']);
     if (count($delegating)) {
         echo "<div class='center'><table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='2'>" . __('This ticket concerns me') . " ";
         $rand = Dropdown::showYesNo("nodelegate", $values['nodelegate']);
         $params = array('nodelegate' => '__VALUE__', 'rand' => $rand, 'right' => "delegate", '_users_id_requester' => $values['_users_id_requester'], '_users_id_requester_notif' => $values['_users_id_requester_notif'], 'use_notification' => $values['_users_id_requester_notif']['use_notification'], 'entity_restrict' => $_SESSION["glpiactive_entity"]);
         Ajax::UpdateItemOnSelectEvent("dropdown_nodelegate" . $rand, "show_result" . $rand, $CFG_GLPI["root_doc"] . "/ajax/dropdownDelegationUsers.php", $params);
         if ($CFG_GLPI['use_check_pref'] && $values['nodelegate']) {
             echo "</th><th>" . __('Check your personnal information');
         }
         echo "</th></tr>";
         echo "<tr class='tab_bg_1'><td colspan='2' class='center'>";
         echo "<div id='show_result{$rand}'>";
         $self = new Ticket();
         if ($values["_users_id_requester"] == 0) {
             $values['_users_id_requester'] = Session::getLoginUserID();
         } else {
             $values['_right'] = "delegate";
         }
         $self->showActorAddFormOnCreate(CommonITILActor::REQUESTER, $values);
         echo "</div>";
         if ($CFG_GLPI['use_check_pref'] && $values['nodelegate']) {
             echo "</td><td class='center'>";
             User::showPersonalInformation(Session::getLoginUserID());
         }
         echo "</td></tr>";
         echo "</table></div>";
         echo "<input type='hidden' name='_users_id_recipient' value='" . Session::getLoginUserID() . "'>";
     } else {
         // User as requester
         $values['_users_id_requester'] = Session::getLoginUserID();
         if ($CFG_GLPI['use_check_pref']) {
             echo "<div class='center'><table class='tab_cadre_fixe'>";
             echo "<tr><th>" . __('Check your personnal information') . "</th></tr>";
             echo "<tr class='tab_bg_1'><td class='center'>";
             User::showPersonalInformation(Session::getLoginUserID());
             echo "</td></tr>";
             echo "</table></div>";
         }
     }
     echo "<input type='hidden' name='_from_helpdesk' value='1'>";
     echo "<input type='hidden' name='requesttypes_id' value='" . RequestType::getDefault('helpdesk') . "'>";
     // Load ticket template if available :
     $tt = $ticket->getTicketTemplateToUse($ticket_template, $values['type'], $values['itilcategories_id'], $_SESSION["glpiactive_entity"]);
     // Predefined fields from template : reset them
     if (isset($values['_predefined_fields'])) {
         $values['_predefined_fields'] = Toolbox::decodeArrayFromInput($values['_predefined_fields']);
     } else {
         $values['_predefined_fields'] = array();
     }
     // Store predefined fields to be able not to take into account on change template
     $predefined_fields = array();
     if (isset($tt->predefined) && count($tt->predefined)) {
         foreach ($tt->predefined as $predeffield => $predefvalue) {
             if (isset($values[$predeffield]) && isset($default_values[$predeffield])) {
                 // Is always default value : not set
                 // Set if already predefined field
                 // Set if ticket template change
                 if ($values[$predeffield] == $default_values[$predeffield] || isset($values['_predefined_fields'][$predeffield]) && $values[$predeffield] == $values['_predefined_fields'][$predeffield] || isset($values['_tickettemplates_id']) && $values['_tickettemplates_id'] != $tt->getID()) {
                     $values[$predeffield] = $predefvalue;
                     $predefined_fields[$predeffield] = $predefvalue;
                 }
             } else {
                 // Not defined options set as hidden field
                 echo "<input type='hidden' name='{$predeffield}' value='{$predefvalue}'>";
             }
         }
     } else {
         // No template load : reset predefined values
         if (count($values['_predefined_fields'])) {
             foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) {
                 if ($values[$predeffield] == $predefvalue) {
                     $values[$predeffield] = $default_values[$predeffield];
                 }
             }
         }
     }
     if ($CFG_GLPI['urgency_mask'] == 1 << 3 || $tt->isHiddenField('urgency')) {
         // Dont show dropdown if only 1 value enabled or field is hidden
         echo "<input type='hidden' name='urgency' value='" . $values['urgency'] . "'>";
     }
     // Display predefined fields if hidden
     if ($tt->isHiddenField('itemtype')) {
         echo "<input type='hidden' name='itemtype' value='" . $values['itemtype'] . "'>";
         echo "<input type='hidden' name='items_id' value='" . $values['items_id'] . "'>";
     }
     if ($tt->isHiddenField('locations_id')) {
         echo "<input type='hidden' name='locations_id' value='" . $values['locations_id'] . "'>";
     }
     echo "<input type='hidden' name='entities_id' value='" . $_SESSION["glpiactive_entity"] . "'>";
     echo "<div class='center'><table class='tab_cadre_fixe'>";
     echo "<tr><th>" . __('Describe the incident or request') . "</th><th>";
     if (Session::isMultiEntitiesMode()) {
         echo "(" . Dropdown::getDropdownName("glpi_entities", $_SESSION["glpiactive_entity"]) . ")";
     }
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type')) . "</td>";
     echo "<td>";
     Ticket::dropdownType('type', array('value' => $values['type'], 'on_change' => 'submit()'));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Category'), $tt->getMandatoryMark('itilcategories_id')) . "</td>";
     echo "<td>";
     $condition = "`is_helpdeskvisible`='1'";
     switch ($values['type']) {
         case Ticket::DEMAND_TYPE:
             $condition .= " AND `is_request`='1'";
             break;
         default:
             // Ticket::INCIDENT_TYPE :
             $condition .= " AND `is_incident`='1'";
     }
     $opt = array('value' => $values['itilcategories_id'], 'condition' => $condition, 'on_change' => 'submit()');
     if ($values['itilcategories_id'] && $tt->isMandatoryField("itilcategories_id")) {
         $opt['display_emptychoice'] = false;
     }
     ITILCategory::dropdown($opt);
     echo "</td></tr>";
     if ($CFG_GLPI['urgency_mask'] != 1 << 3) {
         if (!$tt->isHiddenField('urgency')) {
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . sprintf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency')) . "</td>";
             echo "<td>";
             Ticket::dropdownUrgency(array('value' => $values["urgency"]));
             echo "</td></tr>";
         }
     }
     if (empty($delegating) && NotificationTargetTicket::isAuthorMailingActivatedForHelpdesk()) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Inform me about the actions taken') . "</td>";
         echo "<td>";
         if ($values["_users_id_requester"] == 0) {
             $values['_users_id_requester'] = Session::getLoginUserID();
         }
         $_POST['value'] = $values['_users_id_requester'];
         $_POST['field'] = '_users_id_requester_notif';
         $_POST['use_notification'] = $values['_users_id_requester_notif']['use_notification'];
         include GLPI_ROOT . "/ajax/uemailUpdate.php";
         echo "</td></tr>";
     }
     if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] != 0) {
         if (!$tt->isHiddenField('itemtype')) {
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . sprintf(__('%1$s%2$s'), __('Hardware type'), $tt->getMandatoryMark('itemtype')) . "</td>";
             echo "<td>";
             Ticket::dropdownMyDevices($values['_users_id_requester'], $_SESSION["glpiactive_entity"], $values['itemtype'], $values['items_id']);
             Ticket::dropdownAllDevices("itemtype", $values['itemtype'], $values['items_id'], 0, $values['_users_id_requester'], $_SESSION["glpiactive_entity"]);
             echo "<span id='item_ticket_selection_information'></span>";
             echo "</td></tr>";
         }
     }
     if (!$tt->isHiddenField('locations_id')) {
         echo "<tr class='tab_bg_1'><td>";
         printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id'));
         echo "</td><td>";
         Location::dropdown(array('value' => $values["locations_id"]));
         echo "</td></tr>";
     }
     if (!$tt->isHiddenField('name') || $tt->isPredefinedField('name')) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . sprintf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name')) . "</td>";
         echo "<td><input type='text' maxlength='250' size='80' name='name'\n                    value=\"" . $values['name'] . "\"></td></tr>";
     }
     if (!$tt->isHiddenField('content') || $tt->isPredefinedField('content')) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . sprintf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content')) . "</td>";
         // * Changed by plugin surveyticket
         // * Added by plugin surveyticket
         $psTicketTemplate = new PluginSurveyticketTicketTemplate();
         $psSurvey = new PluginSurveyticketSurvey();
         $plugin_surveyticket_surveys_id = 0;
         $a_tickettemplates = current($psTicketTemplate->find("`tickettemplates_id`='" . $tt->fields['id'] . "'\n                                                      AND `type`='" . $values['type'] . "'\n                                                      AND `is_helpdesk`='1'"));
         if (isset($a_tickettemplates['plugin_surveyticket_surveys_id'])) {
             echo "<td>";
             $psSurvey = new PluginSurveyticketSurvey();
             $psSurvey->getFromDB($a_tickettemplates['plugin_surveyticket_surveys_id']);
             if ($psSurvey->fields['is_active'] == 1) {
                 $plugin_surveyticket_surveys_id = $a_tickettemplates['plugin_surveyticket_surveys_id'];
                 $psSurvey = new PluginSurveyticketSurvey();
                 $psSurvey->startSurvey($plugin_surveyticket_surveys_id);
             }
         } else {
             echo "<td><textarea name='content' cols='80' rows='14'>" . $values['content'] . "</textarea>";
         }
         // * End of change
         echo "</td></tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s (%2$s)'), __('File'), Document::getMaxUploadSize());
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/aide.png' class='pointer' alt='" . __s('Help') . "' onclick=\"window.open('" . $CFG_GLPI["root_doc"] . "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000,height=800')\">";
     echo "&nbsp;";
     Ticket::showDocumentAddButton(60);
     echo "</td>";
     echo "<td><div id='uploadfiles'><input type='file' name='filename[]' value='' size='60'></div>";
     echo "</td></tr>";
     if (!$ticket_template) {
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='2' class='center'>";
         if ($tt->isField('id') && $tt->fields['id'] > 0) {
             echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>";
             echo "<input type='hidden' name='_predefined_fields'\n                   value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">";
         }
         echo "<input type='submit' name='add' value=\"" . __s('Submit message') . "\" class='submit'>";
         echo "</td></tr>";
     }
     echo "</table></div>";
     if (!$ticket_template) {
         Html::closeForm();
     }
 }
Ejemplo 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']);
    }
}
Ejemplo n.º 3
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";
Session::checkLoginUser();
if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
    Html::helpHeader("survey", $_SERVER["PHP_SELF"], "plugins", "surveyticket", "displaysurvey");
} else {
    Html::header("survey", $_SERVER["PHP_SELF"], "plugins", "surveyticket", "displaysurvey");
}
$psSurvey = new PluginSurveyticketSurvey();
$psSurvey->showFormHelpdesk(Session::getLoginUserID());
Html::footer();
Ejemplo 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;
                }
            }
        }
    }
}
Ejemplo n.º 5
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("surveyticket", $_SERVER["PHP_SELF"], "plugins", "surveyticket", "survey");
$psSurvey = new PluginSurveyticketSurvey();
if (isset($_POST["add"])) {
    $psSurvey->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $psSurvey->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            $psSurvey->delete($_POST);
            Html::redirect(Toolbox::getItemTypeSearchURL('PluginSurveyticketSurvey'));
        }
    }
}
if (isset($_GET["id"])) {