Beispiel #1
0
 /**
  * Print the Tracking right form for the current profile
  *
  * @param $openform     boolean  open the form (true by default)
  * @param $closeform    boolean  close the form (true by default)
  **/
 function showFormTracking($openform = true, $closeform = true)
 {
     global $CFG_GLPI;
     if (!self::canView()) {
         return false;
     }
     echo "<div class='spaced'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         echo "<form method='post' action='" . $this->getFormURL() . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     // Assistance / Tracking-helpdesk
     echo "<tr class='tab_bg_1'><th colspan='2'>" . __('Assistance') . "</th></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . _n('Ticket', 'Tickets', Session::getPluralNumber()) . ': ' . __('Default ticket template') . "</td><td  width='30%'>";
     // Only root entity ones and recursive
     $options = array('value' => $this->fields["tickettemplates_id"], 'entity' => 0);
     if (Session::isMultiEntitiesMode()) {
         $options['condition'] = '`is_recursive`';
     }
     // Only add profile if on root entity
     if (!isset($_SESSION['glpiactiveentities'][0])) {
         $options['addicon'] = false;
     }
     TicketTemplate::dropdown($options);
     echo "</td></tr>\n";
     echo "</table>";
     $matrix_options = array('canedit' => $canedit, 'default_class' => 'tab_bg_2');
     $rights = array(array('itemtype' => 'Ticket', 'label' => _n('Ticket', 'Tickets', Session::getPluralNumber()), 'field' => 'ticket'), array('itemtype' => 'TicketCost', 'label' => _n('Ticket cost', 'Ticket costs', Session::getPluralNumber()), 'field' => 'ticketcost'), array('itemtype' => 'TicketRecurrent', 'label' => __('Recurrent tickets'), 'field' => 'ticketrecurrent'), array('itemtype' => 'TicketTemplate', 'label' => _n('Ticket template', 'Ticket templates', Session::getPluralNumber()), 'field' => 'tickettemplate'));
     $matrix_options['title'] = _n('Ticket', 'Tickets', Session::getPluralNumber());
     $this->displayRightsChoiceMatrix($rights, $matrix_options);
     $rights = array(array('itemtype' => 'TicketFollowup', 'label' => _n('Followup', 'Followups', Session::getPluralNumber()), 'field' => 'followup'), array('itemtype' => 'TicketTask', 'label' => _n('Task', 'Tasks', Session::getPluralNumber()), 'field' => 'task'));
     $matrix_options['title'] = _n('Followup', 'Followups', Session::getPluralNumber()) . " / " . _n('Task', 'Tasks', Session::getPluralNumber());
     $this->displayRightsChoiceMatrix($rights, $matrix_options);
     $rights = array(array('itemtype' => 'TicketValidation', 'label' => _n('Validation', 'Validations', Session::getPluralNumber()), 'field' => 'ticketvalidation'));
     $matrix_options['title'] = _n('Validation', 'Validations', Session::getPluralNumber());
     $this->displayRightsChoiceMatrix($rights, $matrix_options);
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_5'><th colspan='2'>" . __('Association') . "</th>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('See hardware of my groups') . "</td><td>";
     Html::showCheckbox(array('name' => '_show_group_hardware', 'checked' => $this->fields['show_group_hardware']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Link with items for the creation of tickets') . "</td>";
     echo "\n<td>";
     self::getLinearRightChoice(self::getHelpdeskHardwareTypes(true), array('field' => 'helpdesk_hardware', 'value' => $this->fields['helpdesk_hardware']));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Associable items to a ticket') . "</td>";
     echo "<td><input type='hidden' name='_helpdesk_item_types' value='1'>";
     self::dropdownHelpdeskItemtypes(array('values' => $this->fields["helpdesk_item_type"]));
     // Linear_HIT
     // self::getLinearRightChoice(self::getHelpdeskItemtypes(),
     //                               array('field'         => 'helpdesk_item_type',
     //                                     'value'         => $this->fields['helpdesk_item_type'],
     //                                     'check_all'     => true,
     //                                     'zero_on_empty' => false,
     //                                     'max_per_line'  => 4,
     //                                     'check_method'  =>
     //                                     function ($element, $field) {
     //                                        return in_array($element,$field);
     //                                     }));
     echo "</td>";
     echo "</tr>\n";
     echo "</table>";
     $rights = array(array('itemtype' => 'Stat', 'label' => __('Statistics'), 'field' => 'statistic'), array('itemtype' => 'Planning', 'label' => __('Planning'), 'field' => 'planning'));
     $matrix_options['title'] = __('Visibility');
     $this->displayRightsChoiceMatrix($rights, $matrix_options);
     $rights = array(array('itemtype' => 'Problem', 'label' => _n('Problem', 'Problems', Session::getPluralNumber()), 'field' => 'problem'));
     $matrix_options['title'] = _n('Problem', 'Problems', Session::getPluralNumber());
     $this->displayRightsChoiceMatrix($rights, $matrix_options);
     $rights = array(array('itemtype' => 'Change', 'label' => _n('Change', 'Changes', Session::getPluralNumber()), 'field' => 'change'), array('itemtype' => 'ChangeValidation', 'label' => _n('Validation', 'Validations', Session::getPluralNumber()), 'field' => 'changevalidation'));
     $matrix_options['title'] = _n('Change', 'Changes', Session::getPluralNumber());
     $this->displayRightsChoiceMatrix($rights, $matrix_options);
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo "<input type='hidden' name='id' value='" . $this->fields['id'] . "'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Print the mandatory fields
  *
  * @since version 0.83
  *
  * @param $tt                       Ticket Template
  * @param $withtemplate    boolean  Template or basic item (default '')
  *
  * @return Nothing (call to classes members)
  **/
 static function showForTicketTemplate(TicketTemplate $tt, $withtemplate = '')
 {
     global $DB;
     $ID = $tt->fields['id'];
     if (!$tt->getFromDB($ID) || !$tt->can($ID, READ)) {
         return false;
     }
     $canedit = $tt->canEdit($ID);
     $ttm = new self();
     $used = $ttm->getMandatoryFields($ID);
     $fields = $tt->getAllowedFieldsNames(true);
     $simplified_fields = $tt->getSimplifiedInterfaceFields();
     $both_interfaces = sprintf(__('%1$s + %2$s'), __('Simplified interface'), __('Standard interface'));
     $rand = mt_rand();
     $query = "SELECT `glpi_tickettemplatemandatoryfields`.*\n                FROM `glpi_tickettemplatemandatoryfields`\n                WHERE (`tickettemplates_id` = '{$ID}')";
     if ($result = $DB->query($query)) {
         $mandatoryfields = array();
         $used = array();
         if ($numrows = $DB->numrows($result)) {
             while ($data = $DB->fetch_assoc($result)) {
                 $mandatoryfields[$data['id']] = $data;
                 $used[$data['num']] = $data['num'];
             }
         }
         if ($canedit) {
             echo "<div class='firstbloc'>";
             echo "<form name='changeproblem_form{$rand}' id='changeproblem_form{$rand}' method='post'\n                   action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a mandatory field') . "</th></tr>";
             echo "<tr class='tab_bg_2'><td class='right'>";
             echo "<input type='hidden' name='tickettemplates_id' value='{$ID}'>";
             $select_fields = $fields;
             foreach ($select_fields as $key => $val) {
                 if (in_array($key, $simplified_fields)) {
                     $select_fields[$key] = sprintf(__('%1$s (%2$s)'), $val, $both_interfaces);
                 } else {
                     $select_fields[$key] = sprintf(__('%1$s (%2$s)'), $val, __('Standard interface'));
                 }
             }
             Dropdown::showFromArray('num', $select_fields, array('used' => $used));
             echo "</td><td class='center'>";
             echo "&nbsp;<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             echo "</td></tr>";
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         }
         echo "<div class='spaced'>";
         if ($canedit && $numrows) {
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr class='noHover'><th colspan='3'>";
         echo self::getTypeName($DB->numrows($result));
         echo "</th></tr>";
         if ($numrows) {
             $header_begin = "<tr>";
             $header_top = '';
             $header_bottom = '';
             $header_end = '';
             if ($canedit) {
                 $header_top .= "<th width='10'>";
                 $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
                 $header_bottom .= "<th width='10'>";
                 $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
             }
             $header_end .= "<th>" . __('Name') . "</th>";
             $header_end .= "<th>" . __("Profile's interface") . "</th>";
             $header_end .= "</tr>";
             echo $header_begin . $header_top . $header_end;
             foreach ($mandatoryfields as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
                 }
                 echo "<td>" . $fields[$data['num']] . "</td>";
                 echo "<td>";
                 if (in_array($data['num'], $simplified_fields)) {
                     echo $both_interfaces;
                 } else {
                     _e('Standard interface');
                 }
                 echo "</td>";
                 echo "</tr>";
             }
             echo $header_begin . $header_bottom . $header_end;
         } else {
             echo "<tr><th colspan='2'>" . __('No item found') . "</th></tr>";
         }
         echo "</table>";
         if ($canedit && $numrows) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
         echo "</div>";
     }
 }
 /**
  * @param $tt           TicketTemplate object
  * @param $withtemplate (default '')
  **/
 static function showForTicketTemplate(TicketTemplate $tt, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $itilcategory = new self();
     $ID = $tt->fields['id'];
     if (!$tt->getFromDB($ID) || !$tt->can($ID, READ)) {
         return false;
     }
     $ttm = new self();
     $rand = mt_rand();
     echo "<div class='center'>";
     $query = "SELECT `glpi_itilcategories`.*\n                FROM `glpi_itilcategories`\n                WHERE (`tickettemplates_id_incident` = '{$ID}')\n                       OR (`tickettemplates_id_demand` = '{$ID}')\n                ORDER BY `name`";
     if ($result = $DB->query($query)) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='3'>";
         echo "<a href='" . Toolbox::getItemTypeSearchURL($itilcategory->getType()) . "'>";
         echo self::getTypeName($DB->numrows($result));
         echo "</a>";
         echo "</th></tr>";
         $used_incident = array();
         $used_demand = array();
         if ($DB->numrows($result)) {
             echo "<th>" . __('Name') . "</th>";
             echo "<th>" . __('Incident') . "</th>";
             echo "<th>" . __('Request') . "</th>";
             echo "</tr>";
             while ($data = $DB->fetch_assoc($result)) {
                 echo "<tr class='tab_bg_2'>";
                 $itilcategory->getFromDB($data['id']);
                 echo "<td>" . $itilcategory->getLink(array('comments' => true)) . "</td>";
                 if ($data['tickettemplates_id_incident'] == $ID) {
                     echo "<td class='center'>\n                        <img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' alt=\"" . __('OK') . "\" width='14' height='14'>\n                        </td>";
                     $used_incident[] = $data["id"];
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
                 if ($data['tickettemplates_id_demand'] == $ID) {
                     echo "<td class='center'>\n                        <img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' alt=\"" . __('OK') . "\" width='14' height='14'>\n                        </td>";
                     $used_demand[] = $data["id"];
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
             }
         } else {
             echo "<tr><th colspan='3'>" . __('No item found') . "</th></tr>";
         }
         echo "</table></div>";
     }
 }
Beispiel #4
0
 /**
  * @since version 0.84 (before in entitydata.class)
  *
  * @param $entity Entity object
  **/
 static function showHelpdeskOptions(Entity $entity)
 {
     global $CFG_GLPI;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, READ) || !Session::haveRightsOr(self::$rightname, array(self::READHELPDESK, self::UPDATEHELPDESK))) {
         return false;
     }
     $canedit = Session::haveRight(self::$rightname, self::UPDATEHELPDESK) && Session::haveAccessToEntity($ID);
     echo "<div class='spaced'>";
     if ($canedit) {
         echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . _n('Ticket template', 'Ticket templates', 1) . "</td>";
     echo "<td colspan='2'>";
     $toadd = array();
     if ($ID != 0) {
         $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
     }
     $options = array('value' => $entity->fields["tickettemplates_id"], 'entity' => $ID, 'toadd' => $toadd);
     TicketTemplate::dropdown($options);
     if ($entity->fields["tickettemplates_id"] == self::CONFIG_PARENT && $ID != 0) {
         echo "<font class='green'>&nbsp;&nbsp;";
         $tt = new TicketTemplate();
         $tid = self::getUsedConfig('tickettemplates_id', $ID, '', 0);
         if (!$tid) {
             echo Dropdown::EMPTY_VALUE;
         } else {
             if ($tt->getFromDB($tid)) {
                 echo $tt->getLink();
             }
         }
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Calendar') . "</td>";
     echo "<td colspan='2'>";
     $options = array('value' => $entity->fields["calendars_id"], 'emptylabel' => __('24/7'));
     if ($ID != 0) {
         $options['toadd'] = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
     }
     Calendar::dropdown($options);
     if ($entity->fields["calendars_id"] == self::CONFIG_PARENT && $ID != 0) {
         echo "<font class='green'>&nbsp;&nbsp;";
         $calendar = new Calendar();
         $cid = self::getUsedConfig('calendars_id', $ID, '', 0);
         if (!$cid) {
             _e('24/7');
         } else {
             if ($calendar->getFromDB($cid)) {
                 echo $calendar->getLink();
             }
         }
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Tickets default type') . "</td>";
     echo "<td colspan='2'>";
     $toadd = array();
     if ($ID != 0) {
         $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
     }
     Ticket::dropdownType('tickettype', array('value' => $entity->fields["tickettype"], 'toadd' => $toadd));
     if ($entity->fields['tickettype'] == self::CONFIG_PARENT && $ID != 0) {
         echo "<font class='green'>&nbsp;&nbsp;";
         echo Ticket::getTicketTypeName(self::getUsedConfig('tickettype', $ID, '', Ticket::INCIDENT_TYPE));
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td  colspan='2'>" . __('Automatic assignment of tickets') . "</td>";
     echo "<td colspan='2'>";
     $autoassign = self::getAutoAssignMode();
     if ($ID == 0) {
         unset($autoassign[self::CONFIG_PARENT]);
     }
     Dropdown::showFromArray('auto_assign_mode', $autoassign, array('value' => $entity->fields["auto_assign_mode"]));
     if ($entity->fields['auto_assign_mode'] == self::CONFIG_PARENT && $ID != 0) {
         $auto_assign_mode = self::getUsedConfig('auto_assign_mode', $entity->fields['entities_id']);
         echo "<font class='green'>&nbsp;&nbsp;";
         echo $autoassign[$auto_assign_mode];
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr><th colspan='4'>" . __('Automatic closing configuration') . "</th></tr>";
     echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('Automatic closing of solved tickets after') . "</td>";
     echo "<td colspan='2'>";
     $autoclose = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), self::CONFIG_NEVER => __('Never'), 0 => __('Immediatly'));
     if ($ID == 0) {
         unset($autoclose[self::CONFIG_PARENT]);
     }
     Dropdown::showNumber('autoclose_delay', array('value' => $entity->fields['autoclose_delay'], 'min' => 1, 'max' => 99, 'step' => 1, 'toadd' => $autoclose, 'unit' => 'day'));
     if ($entity->fields['autoclose_delay'] == self::CONFIG_PARENT && $ID != 0) {
         $autoclose_mode = self::getUsedConfig('autoclose_delay', $entity->fields['entities_id'], '', self::CONFIG_NEVER);
         echo "<br><font class='green'>&nbsp;&nbsp;";
         if ($autoclose_mode >= 0) {
             printf(_n('%d day', '%d days', $autoclose_mode), $autoclose_mode);
         } else {
             echo $autoclose[$autoclose_mode];
         }
         echo "</font>";
     }
     echo "</td></tr>";
     echo "<tr><th colspan='4'>" . __('Configuring the satisfaction survey') . "</th></tr>";
     echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('Configuring the satisfaction survey') . "</td>";
     echo "<td colspan='2'>";
     /// no inquest case = rate 0
     $typeinquest = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), 1 => __('Internal survey'), 2 => __('External survey'));
     // No inherit from parent for root entity
     if ($ID == 0) {
         unset($typeinquest[self::CONFIG_PARENT]);
         if ($entity->fields['inquest_config'] == self::CONFIG_PARENT) {
             $entity->fields['inquest_config'] = 1;
         }
     }
     $rand = Dropdown::showFromArray('inquest_config', $typeinquest, $options = array('value' => $entity->fields['inquest_config']));
     echo "</td></tr>\n";
     // Do not display for root entity in inherit case
     if ($entity->fields['inquest_config'] == self::CONFIG_PARENT && $ID != 0) {
         $inquestconfig = self::getUsedConfig('inquest_config', $entity->fields['entities_id']);
         $inquestrate = self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_rate');
         echo "<tr class='tab_bg_1'><td colspan='4' class='green center'>";
         if ($inquestrate == 0) {
             _e('Disabled');
         } else {
             echo $typeinquest[$inquestconfig] . '<br>';
             $inqconf = self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_delay');
             printf(_n('%d day', '%d days', $inqconf), $inqconf);
             echo "<br>";
             //TRANS: %d is the percentage. %% to display %
             printf(__('%d%%'), $inquestrate);
             if ($inquestconfig == 2) {
                 echo "<br>";
                 echo self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_URL');
             }
         }
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_1'><td colspan='4'>";
     $_POST = array('inquest_config' => $entity->fields['inquest_config'], 'entities_id' => $ID);
     $params = array('inquest_config' => '__VALUE__', 'entities_id' => $ID);
     echo "<div id='inquestconfig'>";
     include GLPI_ROOT . '/ajax/ticketsatisfaction.php';
     echo "</div>\n";
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' colspan='4'>";
         echo "<input type='hidden' name='id' value='" . $entity->fields["id"] . "'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\"\n                  class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
     } else {
         echo "</table>";
     }
     echo "</div>";
     Ajax::updateItemOnSelectEvent("dropdown_inquest_config{$rand}", "inquestconfig", $CFG_GLPI["root_doc"] . "/ajax/ticketsatisfaction.php", $params);
 }
Beispiel #5
0
 /**
  * Get ticket template to use
  * Use force_template first, then try on template define for type and category
  * then use default template of active profile of connected user and then use default entity one
  *
  * @param $force_template      integer tickettemplate_id to used (case of preview for example)
  *                             (default 0)
  * @param $type                integer type of the ticket (default 0)
  * @param $itilcategories_id   integer ticket category (default 0)
  * @param $entities_id         integer (default -1)
  *
  * @since version 0.84
  *
  * @return ticket template object
  **/
 function getTicketTemplateToUse($force_template = 0, $type = 0, $itilcategories_id = 0, $entities_id = -1)
 {
     // Load ticket template if available :
     $tt = new TicketTemplate();
     $template_loaded = false;
     if ($force_template) {
         // with type and categ
         if ($tt->getFromDBWithDatas($force_template, true)) {
             $template_loaded = true;
         }
     }
     if (!$template_loaded && $type && $itilcategories_id) {
         $categ = new ITILCategory();
         if ($categ->getFromDB($itilcategories_id)) {
             $field = '';
             switch ($type) {
                 case self::INCIDENT_TYPE:
                     $field = 'tickettemplates_id_incident';
                     break;
                 case self::DEMAND_TYPE:
                     $field = 'tickettemplates_id_demand';
                     break;
             }
             if (!empty($field) && $categ->fields[$field]) {
                 // without type and categ
                 if ($tt->getFromDBWithDatas($categ->fields[$field], false)) {
                     $template_loaded = true;
                 }
             }
         }
     }
     // If template loaded from type and category do not check after
     if ($template_loaded) {
         return $tt;
     }
     if (!$template_loaded) {
         // load default profile one if not already loaded
         if (isset($_SESSION['glpiactiveprofile']['tickettemplates_id']) && $_SESSION['glpiactiveprofile']['tickettemplates_id']) {
             // with type and categ
             if ($tt->getFromDBWithDatas($_SESSION['glpiactiveprofile']['tickettemplates_id'], true)) {
                 $template_loaded = true;
             }
         }
     }
     if (!$template_loaded && $entities_id >= 0) {
         // load default entity one if not already loaded
         if ($template_id = Entity::getUsedConfig('tickettemplates_id', $entities_id)) {
             // with type and categ
             if ($tt->getFromDBWithDatas($template_id, true)) {
                 $template_loaded = true;
             }
         }
     }
     // Check if profile / entity set type and category and try to load template for these values
     if ($template_loaded) {
         // template loaded for profile or entity
         $newtype = $type;
         $newitilcategories_id = $itilcategories_id;
         // Get predefined values for ticket template
         if (isset($tt->predefined['itilcategories_id']) && $tt->predefined['itilcategories_id']) {
             $newitilcategories_id = $tt->predefined['itilcategories_id'];
         }
         if (isset($tt->predefined['type']) && $tt->predefined['type']) {
             $newtype = $tt->predefined['type'];
         }
         if ($newtype && $newitilcategories_id) {
             $categ = new ITILCategory();
             if ($categ->getFromDB($newitilcategories_id)) {
                 $field = '';
                 switch ($newtype) {
                     case self::INCIDENT_TYPE:
                         $field = 'tickettemplates_id_incident';
                         break;
                     case self::DEMAND_TYPE:
                         $field = 'tickettemplates_id_demand';
                         break;
                 }
                 if (!empty($field) && $categ->fields[$field]) {
                     // without type and categ
                     if ($tt->getFromDBWithDatas($categ->fields[$field], false)) {
                         $template_loaded = true;
                     }
                 }
             }
         }
     }
     return $tt;
 }
Beispiel #6
0
 public function showForm()
 {
     $this->getFromDB(1);
     echo "<div class='center'>";
     echo "<form name='form' method='post' action='" . $this->getFormURL() . "'>";
     echo "<input type='hidden' name='id' value='1'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . __("Plugin configuration", "order") . "</th></tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Default VAT", "order") . "</td>";
     echo "<td>";
     PluginOrderOrderTax::Dropdown(array('name' => "default_taxes", 'value' => $this->fields["default_taxes"], 'display_emptychoice' => true, 'emptylabel' => __("No VAT", "order")));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Use validation process", "order") . "</td>";
     echo "<td>";
     Dropdown::showYesNo("use_validation", $this->fields["use_validation"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Order generation in ODT", "order") . "</td><td>";
     Dropdown::showYesNo("generate_order_pdf", $this->fields["generate_order_pdf"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Activate suppliers quality satisfaction", "order") . "</td>";
     echo "<td>";
     Dropdown::showYesNo("use_supplier_satisfaction", $this->fields["use_supplier_satisfaction"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Display order's suppliers informations", "order") . "</td><td>";
     Dropdown::showYesNo("use_supplier_informations", $this->fields["use_supplier_informations"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Color to be displayed when order due date is overtaken", "order") . "</td>";
     echo "<td>";
     echo "<input type='color' name='shoudbedelivered_color'\n               value='" . $this->fields['shoudbedelivered_color'] . "'>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Copy order documents when a new item is created", "order") . "</td>";
     echo "<td>";
     Dropdown::showYesNo("copy_documents", $this->fields["copy_documents"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Default heading when adding a document to an order", "order") . "</td>";
     echo "<td>";
     DocumentCategory::Dropdown(array('value' => $this->fields["documentcategories_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Author group", "order") . ' (' . __("Default values") . ")</td>";
     echo "<td>";
     Group::Dropdown(array('value' => $this->fields["groups_id_author"], 'name' => 'groups_id_author'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Recipient group", "order") . ' (' . __("Default values") . ")</td>";
     echo "<td>";
     Group::Dropdown(array('value' => $this->fields["groups_id_recipient"], 'name' => 'groups_id_recipient'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Recipient") . ' (' . __("Default values") . ")</td>";
     echo "<td>";
     User::Dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'right' => 'all', 'entity' => 0));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Hide inactive budgets", 'order') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("hide_inactive_budgets", $this->fields["hide_inactive_budgets"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Transmit budget change to linked assets", 'order') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("transmit_budget_change", $this->fields["transmit_budget_change"]);
     echo "</td>";
     echo "</tr>";
     // Automatic actions
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<th colspan='2'>" . __("Automatic actions when delivery", "order") . "</th>";
     echo "</tr>";
     // ASSETS
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<th colspan='2'>" . __('Item') . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Enable automatic generation", "order") . "</td>";
     echo "<td>";
     Dropdown::showYesNo("generate_assets", $this->canGenerateAsset());
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Default state", "order") . "</td>";
     echo "<td>";
     State::Dropdown(array('name' => 'default_asset_states_id', 'value' => $this->fields["default_asset_states_id"], 'entity' => $_SESSION["glpiactiveentities"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Add order location to item", "order") . "</td>";
     echo "<td>";
     Dropdown::showYesNo("add_location", $this->canAddLocation());
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Add billing details to item", "order") . "</td><td>";
     Dropdown::showYesNo("add_bill_details", $this->canAddBillDetails());
     echo "</td>";
     echo "</tr>";
     if ($this->canGenerateAsset()) {
         echo "<tr class='tab_bg_1' align='center'>";
         echo "<td>" . __("Default name", "order") . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, "generated_name");
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1' align='center'>";
         echo "<td>" . __("Default serial number", "order") . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, "generated_serial");
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1' align='center'>";
         echo "<td>" . __("Default inventory number", "order") . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, "generated_otherserial");
         echo "</td>";
         echo "</tr>";
         // TICKETS
         echo "<tr class='tab_bg_1' align='center'>";
         echo "<th colspan='2'>" . __("Ticket") . "</th>";
         echo "</tr>";
         echo "<tr class='tab_bg_1' align='center'>";
         echo "<td>" . TicketTemplate::getTypeName(1) . "</td>";
         echo "<td>";
         Dropdown::show('TicketTemplate', array('name' => 'tickettemplates_id_delivery', 'value' => $this->fields['tickettemplates_id_delivery']));
         echo "</td>";
         echo "</tr>";
     }
     /* Workflow */
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<th colspan='2'>" . __("Order lifecycle", "order") . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("State before validation", "order") . "</td>";
     echo "<td>";
     PluginOrderOrderState::Dropdown(array('name' => 'order_status_draft', 'value' => $this->fields["order_status_draft"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Waiting for validation state", "order") . "</td>";
     echo "<td>";
     PluginOrderOrderState::Dropdown(array('name' => 'order_status_waiting_approval', 'value' => $this->fields["order_status_waiting_approval"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Validated order state", "order") . "</td>";
     echo "<td>";
     PluginOrderOrderState::Dropdown(array('name' => 'order_status_approved', 'value' => $this->fields["order_status_approved"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Order being delivered state", "order") . "</td>";
     echo "<td>";
     PluginOrderOrderState::Dropdown(array('name' => 'order_status_partially_delivred', 'value' => $this->fields["order_status_partially_delivred"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Order delivered state", "order") . "</td>";
     echo "<td>";
     PluginOrderOrderState::Dropdown(array('name' => 'order_status_completly_delivered', 'value' => $this->fields["order_status_completly_delivered"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Order paied state", "order") . "</td>";
     echo "<td>";
     PluginOrderOrderState::Dropdown(array('name' => 'order_status_paid', 'value' => $this->fields["order_status_paid"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td>" . __("Canceled order state", "order") . "</td>";
     echo "<td>";
     PluginOrderOrderState::Dropdown(array('name' => 'order_status_canceled', 'value' => $this->fields["order_status_canceled"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1' align='center'>";
     echo "<td colspan='2' align='center'>";
     echo "<input type='submit' name='update' value=\"" . _sx("button", "Post") . "\" class='submit' >";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
 /**
  * Print preview for Ticket template
  *
  * @param $tt TicketTemplate object
  *
  * @return Nothing (call to classes members)
  **/
 static function showHelpdeskPreview(TicketTemplate $tt)
 {
     if (!$tt->getID()) {
         return false;
     }
     if ($tt->getFromDBWithDatas($tt->getID())) {
         $ticket = new Ticket();
         $ticket->showFormHelpdesk(Session::getLoginUserID(), $tt->getID());
     }
 }
 public static function install(Migration $migration)
 {
     $table = getTableForItemType(__CLASS__);
     if (!TableExists($table)) {
         $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n                     `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n                     `plugin_formcreator_forms_id` tinyint(1) NOT NULL,\n                     `itemtype` varchar(100) NOT NULL DEFAULT 'PluginFormcreatorTargetTicket',\n                     `items_id` int(11) NOT NULL DEFAULT 0,\n                     `name` varchar(255) NOT NULL DEFAULT ''\n                  ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
         $GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error());
         // Migration from previous version
     } elseif (!FieldExists($table, 'itemtype', false)) {
         // Migration from version 1.5 to 1.6
         if (!FieldExists($table, 'type', false)) {
             $query = "ALTER TABLE `{$table}`\n                      ADD `type` tinyint(1) NOT NULL default '2';";
             $GLOBALS['DB']->query($query);
         }
         // Add new column for link with target items
         $query = "ALTER TABLE `{$table}`\n                     ADD `itemtype` varchar(100) NOT NULL DEFAULT 'PluginFormcreatorTargetTicket',\n                     ADD `items_id` int(11) NOT NULL DEFAULT 0;";
         $GLOBALS['DB']->query($query);
         // Create ticket template for each configuration in DB
         $query = "SELECT t.`urgency`, t.`priority`, t.`itilcategories_id`, t.`type`, f.`entities_id`\n                   FROM `glpi_plugin_formcreator_targets` t, `glpi_plugin_formcreator_forms` f\n                   WHERE f.`id` = t.`plugin_formcreator_forms_id`\n                   GROUP BY t.`urgency`, t.`priority`, t.`itilcategories_id`, t.`type`, f.`entities_id`";
         $result = $GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error());
         $i = 0;
         while ($ligne = $GLOBALS['DB']->fetch_array($result)) {
             $i++;
             $id = $ligne['urgency'] . $ligne['priority'] . $ligne['itilcategories_id'] . $ligne['type'];
             $template = new TicketTemplate();
             $template_id = $template->add(array('name' => 'Template Formcreator ' . $i, 'entities_id' => $ligne['entities_id'], 'is_recursive' => 1));
             $predefinedField = new TicketTemplatePredefinedField();
             // Urgency
             if (!empty($ligne['urgency'])) {
                 $predefinedField->add(array('tickettemplates_id' => $template_id, 'num' => 10, 'value' => $ligne['urgency']));
             }
             // Priority
             if (!empty($ligne['priority'])) {
                 $predefinedField->add(array('tickettemplates_id' => $template_id, 'num' => 3, 'value' => $ligne['priority']));
             }
             // Category
             if (!empty($ligne['itilcategories_id'])) {
                 $predefinedField->add(array('tickettemplates_id' => $template_id, 'num' => 7, 'value' => $ligne['itilcategories_id']));
             }
             // Type
             if (!empty($ligne['type'])) {
                 $predefinedField->add(array('tickettemplates_id' => $template_id, 'num' => 14, 'value' => $ligne['type']));
             }
             $_SESSION["formcreator_tmp"]["ticket_template"]["{$id}"] = $template_id;
         }
         // Prepare Mysql CASE For each ticket template
         $mysql_case_template = "CASE CONCAT(`urgency`, `priority`, `itilcategories_id`, `type`)";
         foreach ($_SESSION["formcreator_tmp"]["ticket_template"] as $id => $value) {
             $mysql_case_template .= " WHEN {$id} THEN {$value} ";
         }
         $mysql_case_template .= "END AS `tickettemplates_id`";
         // Create Target ticket
         $version = plugin_version_formcreator();
         $migration = new Migration($version['version']);
         require_once 'targetticket.class.php';
         PluginFormcreatorTargetTicket::install($migration);
         $table_targetticket = getTableForItemType('PluginFormcreatorTargetTicket');
         $query = "SELECT `id`, `name`, {$mysql_case_template}, `content` FROM `{$table}`;";
         $result = $GLOBALS['DB']->query($query);
         while ($line = $GLOBALS['DB']->fetch_array($result)) {
             // Insert target ticket
             $query_insert = "INSERT INTO {$table_targetticket} SET\n                              `name` = \"{$line['name']}\",\n                              `tickettemplates_id` = \"{$line['tickettemplates_id']}\",\n                              `comment` = \"{$line['content']}\"";
             $GLOBALS['DB']->query($query_insert);
             $targetticket_id = $GLOBALS['DB']->insert_id();
             // Update target with target ticket id
             $query_update = "UPDATE `{$table}` SET `items_id` = {$targetticket_id} WHERE `id` = {$line['id']}";
             $GLOBALS['DB']->query($query_update);
         }
         // Remove useless column content
         $GLOBALS['DB']->query("ALTER TABLE `{$table}` DROP `content`;");
     }
     return true;
 }
 /**
  * Print the predefined fields
  *
  * @since version 0.83
  *
  * @param $tt                       Ticket Template
  * @param $withtemplate    boolean  Template or basic item (default '')
  *
  * @return Nothing (call to classes members)
  **/
 static function showForTicketTemplate(TicketTemplate $tt, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $ID = $tt->fields['id'];
     if (!$tt->getFromDB($ID) || !$tt->can($ID, READ)) {
         return false;
     }
     $canedit = $tt->canEdit($ID);
     $fields = $tt->getAllowedFieldsNames(true, true);
     $searchOption = Search::getOptions('Ticket');
     $ticket = new Ticket();
     $rand = mt_rand();
     $query = "SELECT `glpi_tickettemplatepredefinedfields`.*\n                FROM `glpi_tickettemplatepredefinedfields`\n                WHERE (`tickettemplates_id` = '{$ID}')\n                ORDER BY 'id'";
     $display_options = array('relative_dates' => true, 'comments' => true, 'html' => true);
     if ($result = $DB->query($query)) {
         $predeffields = array();
         $used = array();
         if ($numrows = $DB->numrows($result)) {
             while ($data = $DB->fetch_assoc($result)) {
                 $predeffields[$data['id']] = $data;
                 $used[$data['num']] = $data['num'];
             }
         }
         if ($canedit) {
             echo "<div class='firstbloc'>";
             echo "<form name='changeproblem_form{$rand}' id='changeproblem_form{$rand}' method='post'\n                  action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a predefined field') . "</th></tr>";
             echo "<tr class='tab_bg_2'><td class='right top' width='30%'>";
             echo "<input type='hidden' name='tickettemplates_id' value='{$ID}'>";
             $display_fields[-1] = Dropdown::EMPTY_VALUE;
             $display_fields += $fields;
             // Force validation request as used
             $used[-2] = -2;
             // Unset multiple items
             $multiple = self::getMultiplePredefinedValues();
             foreach ($multiple as $val) {
                 if (isset($used[$val])) {
                     unset($used[$val]);
                 }
             }
             $rand_dp = Dropdown::showFromArray('num', $display_fields, array('used' => $used, 'toadd'));
             echo "</td><td class='top'>";
             $paramsmassaction = array('id_field' => '__VALUE__', 'itemtype' => 'Ticket', 'inline' => true, 'submitname' => _sx('button', 'Add'), 'options' => array('relative_dates' => 1, 'with_time' => 1, 'with_days' => 0, 'with_specific_date' => 0, 'itemlink_as_string' => 1, 'entity' => $tt->getEntityID()));
             Ajax::updateItemOnSelectEvent("dropdown_num" . $rand_dp, "show_massiveaction_field", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionField.php", $paramsmassaction);
             echo "</td><td>";
             echo "<span id='show_massiveaction_field'>&nbsp;</span>\n";
             echo "</td></tr>";
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         }
         echo "<div class='spaced'>";
         if ($canedit && $numrows) {
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr class='noHover'><th colspan='3'>";
         echo self::getTypeName($DB->numrows($result));
         echo "</th></tr>";
         if ($numrows) {
             $header_begin = "<tr>";
             $header_top = '';
             $header_bottom = '';
             $header_end = '';
             if ($canedit) {
                 $header_top .= "<th width='10'>";
                 $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
                 $header_bottom .= "<th width='10'>";
                 $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
             }
             $header_end .= "<th>" . __('Name') . "</th>";
             $header_end .= "<th>" . __('Value') . "</th>";
             $header_end .= "</tr>";
             echo $header_begin . $header_top . $header_end;
             foreach ($predeffields as $data) {
                 if (!isset($fields[$data['num']])) {
                     // could happen when itemtype removed and items_id present
                     continue;
                 }
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
                 }
                 echo "<td>" . $fields[$data['num']] . "</td>";
                 echo "<td>";
                 $display_datas[$searchOption[$data['num']]['field']] = $data['value'];
                 echo $ticket->getValueToDisplay($searchOption[$data['num']], $display_datas, $display_options);
                 echo "</td>";
                 echo "</tr>";
             }
             echo $header_begin . $header_bottom . $header_end;
         } else {
             echo "<tr><th colspan='3'>" . __('No item found') . "</th></tr>";
         }
         echo "</table>";
         if ($canedit && $numrows) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
         echo "</div>";
     }
 }
Beispiel #10
0
 public function generateNewItem($params)
 {
     global $DB;
     // Retrieve plugin configuration
     $config = new PluginOrderConfig();
     $reference = new PluginOrderReference();
     foreach ($params["id"] as $tmp => $values) {
         //If itemtype cannot be generated, go to the new occurence
         if (in_array($values['itemtype'], self::getTypesThanCannotBeGenerared())) {
             continue;
         }
         $entity = $values["entities_id"];
         //------------- Template management -----------------------//
         //Look for a template in the entity
         $templateID = $reference->checkIfTemplateExistsInEntity($values["id"], $values["itemtype"], $entity);
         $item = new $values["itemtype"]();
         if ($values['itemtype']) {
             $order = new PluginOrderOrder();
         }
         $order->getFromDB($values["plugin_order_orders_id"]);
         $reference->getFromDB($params["plugin_order_references_id"]);
         if ($templateID) {
             $item->getFromDB($templateID);
             unset($item->fields["is_template"]);
             unset($item->fields["date_mod"]);
             $fields = array();
             foreach ($item->fields as $key => $value) {
                 if ($value != '' && (!isset($fields[$key]) || $fields[$key] == '' || $fields[$key] == 0)) {
                     $input[$key] = $value;
                 }
             }
             if ($config->getGeneratedAssetState()) {
                 $input["states_id"] = $config->getGeneratedAssetState();
             }
             $input["entities_id"] = $entity;
             $input["serial"] = $values["serial"];
             if ($item->fields['name']) {
                 $input["name"] = autoName($item->fields["name"], "name", $templateID, $values["itemtype"], $entity);
             } else {
                 $input["name"] = $values["name"];
             }
             if ($item->getField('otherserial') != NOT_AVAILABLE) {
                 if ($item->fields['otherserial']) {
                     $input["otherserial"] = autoName($item->fields["otherserial"], "otherserial", $templateID, $values["itemtype"], $entity);
                 } else {
                     $input["otherserial"] = $values["otherserial"];
                 }
             }
             if ($config->canAddLocation()) {
                 $input['locations_id'] = $order->fields['locations_id'];
             }
         } elseif ($values["itemtype"] == 'Contract') {
             $input["name"] = $values["name"];
             $input["entities_id"] = $entity;
             $input['contracttypes_id'] = $reference->fields['types_id'];
         } else {
             if ($config->getGeneratedAssetState()) {
                 $input["states_id"] = $config->getGeneratedAssetState();
             } else {
                 $input["states_id"] = 0;
             }
             $input["entities_id"] = $entity;
             $input["serial"] = $values["serial"];
             $input["otherserial"] = $values["otherserial"];
             $input["name"] = $values["name"];
             // Get bill data
             if ($config->canAddLocation()) {
                 $input['locations_id'] = $order->fields['locations_id'];
             }
             $input["manufacturers_id"] = $reference->fields["manufacturers_id"];
             $typefield = getForeignKeyFieldForTable(getTableForItemType($values["itemtype"] . "Type"));
             $input[$typefield] = $reference->fields["types_id"];
             $modelfield = getForeignKeyFieldForTable(getTableForItemType($values["itemtype"] . "Model"));
             $input[$modelfield] = $reference->fields["models_id"];
         }
         $input = Toolbox::addslashes_deep($input);
         $newID = $item->add($input);
         // Attach new ticket if option is on
         if (isset($params['generate_ticket'])) {
             $tkt = new TicketTemplate();
             if ($tkt->getFromDB($params['generate_ticket']['tickettemplates_id'])) {
                 $input = array();
                 $input = Ticket::getDefaultValues($entity);
                 $ttp = new TicketTemplatePredefinedField();
                 $predefined = $ttp->getPredefinedFields($params['generate_ticket']['tickettemplates_id'], true);
                 if (count($predefined)) {
                     foreach ($predefined as $predeffield => $predefvalue) {
                         $input[$predeffield] = $predefvalue;
                     }
                 }
                 $input['entities_id'] = $entity;
                 $input['_users_id_requester'] = empty($order->fields['users_id']) ? Session::getLoginUserID() : $order->fields['users_id'];
                 $input['items_id'] = $newID;
                 $input['itemtype'] = $values["itemtype"];
                 $ticket = new Ticket();
                 $ticketID = $ticket->add($input);
             }
         }
         //-------------- End template management ---------------------------------//
         $result = $this->createLinkWithItem($values["id"], $newID, $values["itemtype"], $values["plugin_order_orders_id"], $entity, $templateID, false, false);
         //Add item's history
         $new_value = __("Item generated by using order", "order") . ' : ' . $order->fields["name"];
         $order->addHistory($values["itemtype"], '', $new_value, $newID);
         //Add order's history
         $new_value = __("Item generated by using order", "order") . ' : ';
         $new_value .= $item->getTypeName() . " -> " . $item->getField("name");
         $order->addHistory('PluginOrderOrder', '', $new_value, $values["plugin_order_orders_id"]);
         //Copy order documents if needed
         self::copyDocuments($values['itemtype'], $newID, $values["plugin_order_orders_id"], $entity);
         Session::addMessageAfterRedirect(__("Item successfully selected", "order"), true);
     }
 }
 /**
  * Create a ticket based on ticket recurrent infos
  *
  * @param $data array data of a entry of glpi_ticketrecurrents
  *
  * @return boolean
  **/
 static function createTicket($data)
 {
     $result = false;
     $tt = new TicketTemplate();
     // Create ticket based on ticket template and entity information of ticketrecurrent
     if ($tt->getFromDB($data['tickettemplates_id'])) {
         // Get default values for ticket
         $input = Ticket::getDefaultValues($data['entities_id']);
         // Apply tickettemplates predefined values
         $ttp = new TicketTemplatePredefinedField();
         $predefined = $ttp->getPredefinedFields($data['tickettemplates_id'], true);
         if (count($predefined)) {
             foreach ($predefined as $predeffield => $predefvalue) {
                 $input[$predeffield] = $predefvalue;
             }
         }
         // Set date to creation date
         $createtime = strtotime($data['next_creation_date']) + $data['create_before'];
         $input['date'] = date('Y-m-d H:i:s', $createtime);
         if (isset($predefined['date'])) {
             $input['date'] = Html::computeGenericDateTimeSearch($predefined['date'], false, $createtime);
         }
         // Compute due_date if predefined based on create date
         if (isset($predefined['due_date'])) {
             $input['due_date'] = Html::computeGenericDateTimeSearch($predefined['due_date'], false, $createtime);
         }
         // Set entity
         $input['entities_id'] = $data['entities_id'];
         $input['_auto_import'] = true;
         $ticket = new Ticket();
         $input = Toolbox::addslashes_deep($input);
         if ($tid = $ticket->add($input)) {
             $msg = sprintf(__('Ticket %d successfully created'), $tid);
             $result = true;
         } else {
             $msg = __('Ticket creation failed (check mandatory fields)');
         }
     } else {
         $msg = __('Ticket creation failed (no template)');
     }
     $changes[0] = 0;
     $changes[1] = '';
     $changes[2] = addslashes($msg);
     Log::history($data['id'], __CLASS__, $changes, '', Log::HISTORY_LOG_SIMPLE_MESSAGE);
     // Compute next creation date
     $tr = new self();
     if ($tr->getFromDB($data['id'])) {
         $input = array();
         $input['id'] = $data['id'];
         $input['next_creation_date'] = $tr->computeNextCreationDate($data['begin_date'], $data['end_date'], $data['periodicity'], $data['create_before'], $data['calendars_id']);
         $tr->update($input);
     }
     return $result;
 }
 /**
  * Print the hidden fields
  *
  * @since version 0.83
  *
  * @param $tt                       Ticket Template
  * @param $withtemplate    boolean  Template or basic item (default '')
  *
  * @return Nothing (call to classes members)
  **/
 static function showForTicketTemplate(TicketTemplate $tt, $withtemplate = '')
 {
     global $DB;
     $ID = $tt->fields['id'];
     if (!$tt->getFromDB($ID) || !$tt->can($ID, "r")) {
         return false;
     }
     $ttm = new self();
     $used = $ttm->getHiddenFields($ID);
     $canedit = $tt->can($ID, "w");
     $fields = $tt->getAllowedFieldsNames(false, isset($used['itemtype']));
     $rand = mt_rand();
     $query = "SELECT `glpi_tickettemplatehiddenfields`.*\n                FROM `glpi_tickettemplatehiddenfields`\n                WHERE (`tickettemplates_id` = '{$ID}')";
     if ($result = $DB->query($query)) {
         $hiddenfields = array();
         $used = array();
         if ($numrows = $DB->numrows($result)) {
             while ($data = $DB->fetch_assoc($result)) {
                 $hiddenfields[$data['id']] = $data;
                 $used[$data['num']] = $data['num'];
             }
         }
         if ($canedit) {
             echo "<div class='firstbloc'>";
             echo "<form name='changeproblem_form{$rand}' id='changeproblem_form{$rand}' method='post'\n                   action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a hidden field') . "</th></tr>";
             echo "<tr class='tab_bg_2'><td class='right'>";
             echo "<input type='hidden' name='tickettemplates_id' value='{$ID}'>";
             Dropdown::showFromArray('num', $fields, array('used' => $used));
             echo "</td><td class='center'>";
             echo "&nbsp;<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             echo "</td></tr>";
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         }
         echo "<div class='spaced'>";
         if ($canedit && $numrows) {
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => $numrows);
             Html::showMassiveActions(__CLASS__, $massiveactionparams);
         }
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='2'>";
         echo self::getTypeName($DB->numrows($result));
         echo "</th></tr>";
         if ($numrows) {
             echo "<tr>";
             if ($canedit) {
                 echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
             }
             echo "<th>" . __('Name') . "</th>";
             echo "</tr>";
             foreach ($hiddenfields as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
                 }
                 echo "<td>" . $fields[$data['num']] . "</td>";
                 echo "</tr>";
             }
         } else {
             echo "<tr><th colspan='2'>" . __('No item found') . "</th></tr>";
         }
         echo "</table>";
         if ($canedit && $numrows) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions(__CLASS__, $massiveactionparams);
             Html::closeForm();
         }
         echo "</div>";
     }
 }
 function showTicketTemplate($items_id)
 {
     global $CFG_GLPI;
     $ticketTemplate = new TicketTemplate();
     echo "<form method='post' name='form_addquestion' action='" . $CFG_GLPI['root_doc'] . "/plugins/surveyticket/front/tickettemplate.form.php'>";
     echo "<table class='tab_cadre' width='700'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Ticket template') . "&nbsp;:</td>";
     echo "<td>";
     $a_used = array();
     Dropdown::show("TicketTemplate", array("name" => "tickettemplates_id", "used" => $a_used));
     echo "</td>";
     echo "<td>" . __('Type') . "&nbsp;:</td>";
     echo "<td>";
     Ticket::dropdownType("type");
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Simplified interface') . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("is_helpdesk");
     echo "</td>";
     echo "<td>" . __('Standard interface') . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("is_central");
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td class='tab_bg_2 top' colspan='4'>";
     echo "<input type='hidden' name='plugin_surveyticket_surveys_id' value='" . $items_id . "'>";
     echo "<div class='center'>";
     echo "<input type='submit' name='add' value=\"" . __('Add') . "\" class='submit'>";
     echo "</div></td></tr>";
     echo "</table>";
     Html::closeForm();
     // list templates
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>";
     echo __('Ticket template');
     echo "</th>";
     echo "<th>";
     echo __('Type');
     echo "</th>";
     echo "<th>";
     echo __('Simplified interface');
     echo "</th>";
     echo "<th>";
     echo __('Standard interface');
     echo "</th>";
     echo "<th>";
     echo "</th>";
     echo "</tr>";
     $_tickettempaltes = $this->find("`plugin_surveyticket_surveys_id`='" . $items_id . "'");
     foreach ($_tickettempaltes as $data) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>";
         $ticketTemplate->getFromDB($data['tickettemplates_id']);
         echo $ticketTemplate->getLink(1);
         echo "</td>";
         echo "<td>";
         echo Ticket::getTicketTypeName($data['type']);
         echo "</td>";
         echo "<td>";
         echo Dropdown::getYesNo($data['is_helpdesk']);
         echo "</td>";
         echo "<td>";
         echo Dropdown::getYesNo($data['is_central']);
         echo "</td>";
         echo "<td align='center'>";
         echo "<form method='post' name='form_delettickettemplate' action='" . $CFG_GLPI['root_doc'] . "/plugins/surveyticket/front/tickettemplate.form.php'>";
         echo "<input type='hidden' name='id' value='" . $data['id'] . "'>";
         echo "<input type='submit' name='delete' value=\"" . _sx('button', 'Delete permanently') . "\" class='submit'>";
         Html::closeForm();
         echo "</td>";
         echo "</tr>";
     }
     echo "</table>";
 }
Beispiel #14
0
 switch ($target_value['type']) {
     case "1":
         // formulaire par defaut pour les incidents de la catégorie;
         $template_id = $tickettemplates_id_incident;
         break;
     case "2":
         // formulaire par defaut pour les demandes de la catégorie;
         $template_id = $tickettemplates_id_demand;
         break;
     default:
         // sans précision le formulaire est indiqué par défaut;
         $template_id = "1";
         //formulaire par defaut;
         break;
 }
 $tt = new TicketTemplate();
 $tt->getFromDBWithDatas($template_id, true);
 $ttp = new TicketTemplatePredefinedField();
 $predefined = $ttp->getPredefinedFields($template_id, true);
 if (isset($predefined['itemtype'])) {
     $ticket['itemtype'] = $predefined['itemtype'];
 }
 if (isset($predefined['items_id'])) {
     $ticket['items_id'] = $predefined['items_id'];
 }
 if (isset($predefined['_users_id_observer'])) {
     $ticket['_users_id_observer'] = $predefined['_users_id_observer'];
 }
 if (isset($predefined['_users_id_assign'])) {
     $ticket['_users_id_assign'] = $predefined['_users_id_assign'];
 }
Beispiel #15
0
 static function createTicket($data)
 {
     $result = false;
     $tt = new TicketTemplate();
     // Create ticket based on ticket template and entity informations of ticketrecurrent
     if ($tt->getFromDB($data['tickettemplates_id'])) {
         // Get default values for ticket
         $input = Ticket::getDefaultValues($data['entities_id']);
         // Apply tickettemplates predefined values
         $ttp = new TicketTemplatePredefinedField();
         $predefined = $ttp->getPredefinedFields($data['tickettemplates_id'], true);
         if (count($predefined)) {
             foreach ($predefined as $predeffield => $predefvalue) {
                 $input[$predeffield] = $predefvalue;
             }
         }
         // Set date to creation date
         $createtime = date('Y-m-d H:i:s');
         $input['date'] = $createtime;
         // Compute due_date if predefined based on create date
         if (isset($predefined['due_date'])) {
             $input['due_date'] = Html::computeGenericDateTimeSearch($predefined['due_date'], false, $createtime);
         }
         // Set entity
         $input['entities_id'] = $data['entities_id'];
         $input['actiontime'] = $data['actiontime'];
         $res = new PluginResourcesResource();
         if ($res->getFromDB($data['plugin_resources_resources_id'])) {
             $input['users_id_recipient'] = $res->fields['users_id_recipient'];
             $input['_users_id_requester'] = $res->fields['users_id_recipient'];
             if (isset($res->fields['users_id'])) {
                 $input['_users_id_observer'] = $res->fields['users_id'];
             }
             $input['_users_id_assign'] = Session::getLoginUserID();
             $input["itemtype"] = "PluginResourcesResource";
             $input["items_id"] = $data['plugin_resources_resources_id'];
             $input["name"] .= addslashes(" " . PluginResourcesResource::getResourceName($data['plugin_resources_resources_id']));
         }
         //TODO : ADD checklist lists or add config into plugin ?
         $input["content"] .= addslashes("\n\n");
         $input['status'] = Ticket::CLOSED;
         $ticket = new Ticket();
         $input = Toolbox::addslashes_deep($input);
         if ($tid = $ticket->add($input)) {
             $msg = __('Create a end treatment ticket', 'resources') . " OK - ({$tid})";
             // Success
             $result = true;
         } else {
             $msg = __('Failed operation');
             // Failure
         }
     } else {
         $msg = __('No selected element or badly defined operation');
         // Not defined
     }
     if ($tid) {
         $changes[0] = 0;
         $changes[1] = '';
         $changes[2] = addslashes($msg);
         Log::history($data['plugin_resources_resources_id'], "PluginResourcesResource", $changes, '', Log::HISTORY_LOG_SIMPLE_MESSAGE);
     }
     return $result;
 }
Beispiel #16
0
 /**
  * Print the Tracking right form for the current profile
  *
  * @param $openform     boolean  open the form (true by default)
  * @param $closeform    boolean  close the form (true by default)
  **/
 function showFormTracking($openform = true, $closeform = true)
 {
     global $CFG_GLPI;
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     if (($canedit = Session::haveRight("profile", "w")) && $openform) {
         echo "<form method='post' action='" . $this->getFormURL() . "'>";
     }
     echo "<div class='spaced'>";
     echo "<table class='tab_cadre_fixe'>";
     // Assistance / Tracking-helpdesk
     echo "<tr class='tab_bg_1'><th colspan='6'>" . __('Assistance') . "</th></tr>\n";
     echo "<tr class='tab_bg_5'><th colspan='6'>" . __('Creation') . "</th>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Create a ticket') . "</td><td>";
     Dropdown::showYesNo("create_ticket", $this->fields["create_ticket"]);
     echo "</td>";
     echo "<td>" . __('Add a followup to tickets (requester)') . "</td><td>";
     Dropdown::showYesNo("add_followups", $this->fields["add_followups"]);
     echo "</td>";
     echo "<td>" . __('Add a followup to all tickets') . "</td><td>";
     Dropdown::showYesNo("global_add_followups", $this->fields["global_add_followups"]);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Add a followup to tickets of associated groups') . "</td><td>";
     Dropdown::showYesNo("group_add_followups", $this->fields["group_add_followups"]);
     echo "</td>";
     echo "<td>" . __('Add a task to all tickets') . "</td><td>";
     Dropdown::showYesNo("global_add_tasks", $this->fields["global_add_tasks"]);
     echo "</td>";
     echo "<td>" . __('Default ticket template') . "</td><td>";
     // Only root entity ones and recursive
     $options = array('value' => $this->fields["tickettemplates_id"], 'entity' => 0);
     if (Session::isMultiEntitiesMode()) {
         $options['condition'] = '`is_recursive` = 1';
     }
     TicketTemplate::dropdown($options);
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . _n('Ticket cost', 'Ticket costs', 2) . "</td><td>";
     self::dropdownRight("ticketcost", array('value' => $this->fields["ticketcost"]));
     echo "</td>";
     echo "<td>" . _n('Ticket template', 'Ticket templates', 2) . "</td><td>";
     self::dropdownRight("tickettemplate", array('value' => $this->fields["tickettemplate"]));
     echo "</td>";
     echo "<td>" . __('Recurrent tickets') . "</td><td>";
     self::dropdownRight("ticketrecurrent", array('value' => $this->fields["ticketrecurrent"]));
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_5'><th colspan='6'>" . _x('noun', 'Update') . "</th>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Update a ticket') . "</td><td>";
     Dropdown::showYesNo("update_ticket", $this->fields["update_ticket"]);
     echo "</td>";
     echo "<td>" . __('Change the priority') . "</td><td>";
     Dropdown::showYesNo("update_priority", $this->fields["update_priority"]);
     echo "</td>";
     echo "<td>" . __('Edit all tasks') . "</td><td>";
     Dropdown::showYesNo("update_tasks", $this->fields["update_tasks"]);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Update followups (author)') . "</td><td>";
     Dropdown::showYesNo("update_own_followups", $this->fields["update_own_followups"]);
     echo "</td>";
     echo "<td>" . __('Update all followups') . "</td><td>";
     Dropdown::showYesNo("update_followups", $this->fields["update_followups"]);
     echo "</td>\n";
     echo "<td colspan='2'></td></tr>\n";
     echo "<tr class='tab_bg_5'><th colspan='6'>" . __('Deletion') . "</th>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __("Ticket's deletion") . "</td><td>";
     Dropdown::showYesNo("delete_ticket", $this->fields["delete_ticket"]);
     echo "</td>";
     echo "<td>" . __('Delete all followups') . "</td><td>";
     Dropdown::showYesNo("delete_followups", $this->fields["delete_followups"]);
     echo "</td>\n";
     echo "<td>" . __('Delete all validations') . "</td><td>";
     Dropdown::showYesNo("delete_validations", $this->fields["delete_validations"]);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_5'><th colspan='6'>" . __('Approval') . "</th><";
     echo "/tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Create a validation request for a request') . "</td><td>";
     Dropdown::showYesNo("create_request_validation", $this->fields["create_request_validation"]);
     echo "<td>" . __('Create a validation request for an incident') . "</td><td>";
     Dropdown::showYesNo("create_incident_validation", $this->fields["create_incident_validation"]);
     echo "</td>";
     echo "<td colspan='2'></td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Validate a request') . "</td><td>";
     Dropdown::showYesNo("validate_request", $this->fields["validate_request"]);
     echo "<td>" . __('Validate an incident') . "</td><td>";
     Dropdown::showYesNo("validate_incident", $this->fields["validate_incident"]);
     echo "<td colspan='2'></td></tr>\n";
     echo "<tr class='tab_bg_5'><th colspan='6'>" . __('Assignment') . "</th>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('To be in charge of a ticket') . "</td><td>";
     Dropdown::showYesNo("own_ticket", $this->fields["own_ticket"]);
     echo "<td>" . __('Steal a ticket') . "</td><td>";
     Dropdown::showYesNo("steal_ticket", $this->fields["steal_ticket"]);
     echo "</td>";
     echo "<td>" . __('Assign a ticket') . "</td><td>";
     Dropdown::showYesNo("assign_ticket", $this->fields["assign_ticket"]);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_5'><th colspan='6'>" . __('Association') . "</th>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('See hardware of my groups') . "</td><td>";
     Dropdown::showYesNo("show_group_hardware", $this->fields["show_group_hardware"]);
     echo "</td>";
     echo "<td>" . __('Link with items for the creation of tickets') . "</td>";
     echo "\n<td>";
     Dropdown::showFromArray('helpdesk_hardware', self::getHelpdeskHardwareTypes(), array('value' => $this->fields["helpdesk_hardware"]));
     echo "</td>\n";
     echo "<td>" . __('Associable items to a ticket') . "</td>";
     echo "<td><input type='hidden' name='_helpdesk_item_types' value='1'>";
     self::dropdownHelpdeskItemtypes(array('values' => $this->fields["helpdesk_item_type"]));
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_5'><th colspan='6'>" . __('Visibility') . "</th>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('See assigned tickets (personnal + group associated)') . "</td><td>";
     Dropdown::showYesNo("show_assign_ticket", $this->fields["show_assign_ticket"]);
     echo "</td>";
     echo "<td>" . __('See tickets created by my groups') . "</td><td>";
     Dropdown::showYesNo("show_group_ticket", $this->fields["show_group_ticket"]);
     echo "</td>";
     echo "<td>" . __('See all tickets') . "</td><td>";
     Dropdown::showYesNo("show_all_ticket", $this->fields["show_all_ticket"]);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('See public followups and tasks') . "</td><td>";
     Dropdown::showYesNo("observe_ticket", $this->fields["observe_ticket"]);
     echo "</td>";
     echo "<td>" . __('See all followups and tasks (public and private)') . "</td><td>";
     Dropdown::showYesNo("show_full_ticket", $this->fields["show_full_ticket"]);
     echo "</td>";
     echo "<td>" . __('Statistics') . "</td><td>";
     Dropdown::showYesNo("statistic", $this->fields["statistic"]);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('See personnal planning') . "</td><td>";
     Dropdown::showYesNo("show_planning", $this->fields["show_planning"]);
     echo "</td>";
     echo "<td>" . __('See schedule of people in my groups') . "</td><td>";
     Dropdown::showYesNo("show_group_planning", $this->fields["show_group_planning"]);
     echo "</td>";
     echo "<td>" . __('See all plannings') . "</td><td>";
     Dropdown::showYesNo("show_all_planning", $this->fields["show_all_planning"]);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_5'><th colspan='6'>" . _n('Problem', 'Problems', 2);
     echo "</th></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('See all problems') . "</td><td>";
     Dropdown::showYesNo("show_all_problem", $this->fields["show_all_problem"]);
     echo "</td>";
     echo "<td>" . __('See problems (author)') . "</td><td>";
     Dropdown::showYesNo("show_my_problem", $this->fields["show_my_problem"]);
     echo "</td>";
     echo "<td>" . __('Update all problems') . "</td><td>";
     Dropdown::showYesNo("edit_all_problem", $this->fields["edit_all_problem"]);
     echo "</td>";
     echo "</tr>\n";
     //       echo "<tr class='tab_bg_2'>";
     //       echo "<td>".__('Update all changes')."</td><td>";
     //       Dropdown::showYesNo("edit_all_change", $this->fields["edit_all_change"]);
     //       echo "</td>";
     //       echo "<td>".__('See all changes')."</td><td>";
     //       Dropdown::showYesNo("show_all_change", $this->fields["show_all_change"]);
     //       echo "</td>";
     //       echo "<td>".__('See changes (author)')."</td><td>";
     //       Dropdown::showYesNo("show_my_change", $this->fields["show_my_change"]);
     //       echo "</td>";
     //       echo "</tr>\n";
     if ($canedit && $closeform) {
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='6' class='center'>";
         echo "<input type='hidden' name='id' value='" . $this->fields['id'] . "'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</td></tr>\n";
         echo "</table>\n";
         Html::closeForm();
     } else {
         echo "</table>\n";
     }
     echo "</div>";
 }