Inheritance: extends database
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     echo "<form name='notificationtargets_form' id='notificationtargets_form'\n             method='post' action=' ";
     echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     echo "<table class    ='tab_cadre_fixe'>";
     echo '<tr><th colspan="2">' . __('Access type', 'formcreator') . '</th></tr>';
     echo '<td>' . __('Access', 'formcreator') . '</td>';
     echo '<td>';
     Dropdown::showFromArray('access_rights', array(PluginFormcreatorForm::ACCESS_PUBLIC => __('Public access', 'formcreator'), PluginFormcreatorForm::ACCESS_PRIVATE => __('Private access', 'formcreator'), PluginFormcreatorForm::ACCESS_RESTRICTED => __('Restricted access', 'formcreator')), array('value' => isset($item->fields["access_rights"]) ? $item->fields["access_rights"] : 1));
     echo '</td>';
     if ($item->fields["access_rights"] == PluginFormcreatorForm::ACCESS_RESTRICTED) {
         echo '<tr><th colspan="2">' . self::getTypeName(2) . '</th></tr>';
         $table = getTableForItemType(__CLASS__);
         $table_profile = getTableForItemType('Profile');
         $query = "SELECT p.`id`, p.`name`, IF(f.`plugin_formcreator_profiles_id` IS NOT NULL, 1, 0) AS `profile`\n                   FROM {$table_profile} p\n                   LEFT JOIN {$table} f\n                     ON p.`id` = f.`plugin_formcreator_profiles_id`\n                     AND f.`plugin_formcreator_forms_id` = " . (int) $item->fields['id'];
         $result = $GLOBALS['DB']->query($query);
         while (list($id, $name, $profile) = $GLOBALS['DB']->fetch_array($result)) {
             $checked = $profile ? ' checked' : '';
             echo '<tr><td colspan="2"><label>';
             echo '<input type="checkbox" name="profiles_id[]" value="' . $id . '" ' . $checked . '> ';
             echo $name;
             echo '</label></td></tr>';
         }
     }
     echo '<tr>';
     echo '<td class="center" colspan="2">';
     echo '<input type="hidden" name="profiles_id[]" value="0" />';
     echo '<input type="hidden" name="form_id" value="' . (int) $item->fields['id'] . '" />';
     echo '<input type="submit" name="update" value="' . __('Save') . '" class="submit" />';
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
 }
Example #2
1
 static function showAllItems($myname, $value_type = 0, $value = 0, $entity_restrict = -1, $types, $locations_id = -1, $action = 'showItem')
 {
     global $DB, $CFG_GLPI;
     $rand = mt_rand();
     $plugin = new Plugin();
     echo "<table border='0'><tr><td>\n";
     if ($myname == 'type') {
         $newtypes = array_flip($types);
         unset($newtypes['Location']);
         unset($newtypes['Netpoint']);
         if ($plugin->isActivated("resources")) {
             unset($newtypes['PluginResourcesResource']);
         }
         $types = array_flip($newtypes);
     }
     $rand = Dropdown::showItemTypes($myname, $types, array('emptylabel' => Dropdown::EMPTY_VALUE, 'width' => 150));
     $params = array('type' => '__VALUE__', 'value' => $value, 'myname' => $myname, 'action' => $action, 'entity_restrict' => $entity_restrict, 'locations_id' => $locations_id);
     Ajax::updateItemOnSelectEvent("dropdown_{$myname}{$rand}", "show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params);
     echo "</td><td>\n";
     echo "<span id='show_{$myname}{$rand}'>&nbsp;</span>\n";
     echo "</td></tr></table>\n";
     if ($value > 0) {
         echo "<script type='text/javascript' >\n";
         echo "document.getElementById('item_type{$rand}').value='" . $value_type . "';";
         echo "</script>\n";
         $params["typetable"] = $value_type;
         Ajax::updateItem("show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params);
     }
     return $rand;
 }
Example #3
0
 function showconfigForm()
 {
     global $CFG_GLPI;
     echo "<form name='form' method='post' action='" . $CFG_GLPI["root_doc"] . "/plugins/immobilizationsheets/front/config.form.php'>";
     echo "<div align=\"center\">";
     echo "<table class=\"tab_cadre_fixe\"  cellspacing=\"2\" cellpadding=\"2\">";
     echo "<tr><th colspan=\"2\">" . __('Options', 'immobilizationsheets') . "</th></tr>";
     echo "<tr class='tab_bg_1 top'>";
     echo "<td>" . __('Save sheets in GLPI', 'immobilizationsheets') . ": </td>";
     echo "<td>";
     Dropdown::showYesNo("use_backup", $this->fields["use_backup"]);
     echo "</td>";
     echo "<tr class='tab_bg_1 top'><td>";
     echo __('Default Heading for sheets', 'immobilizationsheets') . ": </td>";
     echo "<td>";
     Dropdown::show('DocumentCategory', array('name' => "documentcategories_id", 'value' => $this->fields["documentcategories_id"]));
     echo "</td>";
     echo "<tr><th colspan='2'>";
     echo "<input type='hidden' name='id' value='1'>";
     echo "<input type=\"submit\" name=\"update_config\" class=\"submit\" value=\"" . __s('Post') . "\" >";
     echo "</th></tr>";
     echo "</table></div>";
     Html::closeForm();
     echo "<br>";
 }
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI, $DB;
     $this->datas['##notimported.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     foreach ($options['notimported'] as $id => $item) {
         $tmp = array();
         $tmp['##notimported.name##'] = $item['name'];
         $tmp['##notimported.serial##'] = $item['serial'];
         $tmp['##notimported.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
         $tmp['##notimported.ocsid##'] = $item['ocsid'];
         $tmp['##notimported.deviceid##'] = $item['ocs_deviceid'];
         $tmp['##notimported.tag##'] = $item['tag'];
         $tmp['##notimported.ocsserver##'] = Dropdown::getDropdownName('glpi_plugin_ocsinventoryng_ocsservers', $item['ocsid']);
         $tmp['##notimported.reason##'] = PluginOcsinventoryngNotimportedcomputer::getReason($item['reason']);
         $url = $CFG_GLPI["url_base"] . "/index.php?redirect=plugin_ocsinventoryng_" . $item['id'];
         $tmp['##notimported.url##'] = urldecode($url);
         $this->datas['notimported'][] = $tmp;
     }
     $this->getTags();
     foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
         if (!isset($this->datas[$tag])) {
             $this->datas[$tag] = $values['label'];
         }
     }
 }
 function displaySpecificTypeField($ID, $field = array())
 {
     global $CFG_GLPI;
     switch ($field['type']) {
         case 'groups':
             $groups = json_decode($this->fields[$field['name']], true);
             if (!empty($groups)) {
                 echo "<table class='tab_cadrehov' cellpadding='5'>";
                 foreach ($groups as $key => $val) {
                     echo "<tr class='tab_bg_1 center'>";
                     echo "<td>";
                     echo Dropdown::getDropdownName("glpi_groups", $val);
                     echo "</td>";
                     echo "<td>";
                     Html::showSimpleForm(Toolbox::getItemTypeFormURL('PluginTimelineticketConfig'), 'delete_groups', _x('button', 'Delete permanently'), array('delete_groups' => 'delete_groups', 'id' => $ID, '_groups_id_assign' => $val), $CFG_GLPI["root_doc"] . "/pics/delete.png");
                     echo " </td>";
                     echo "</tr>";
                 }
                 echo "</table>";
             } else {
                 _e('None');
             }
             break;
     }
 }
 /**
  * Get all data needed for template processing
  **/
 function getDatasForTemplate($event, $options = array())
 {
     global $LANG, $CFG_GLPI;
     $this->datas['##contract.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $events = $this->getEvents();
     $this->datas['##contract.action##'] = $LANG['mailing'][39] . " - " . $events[$event];
     foreach ($options['contracts'] as $id => $contract) {
         $tmp = array();
         $tmp['##contract.name##'] = $contract['name'];
         $tmp['##contract.number##'] = $contract['num'];
         if ($contract['contracttypes_id']) {
             $tmp['##contract.type##'] = Dropdown::getDropdownName('glpi_contracttypes', $contract['contracttypes_id']);
         } else {
             $tmp['##contract.type##'] = "";
         }
         $tmp['##contract.time##'] = getWarrantyExpir($contract["begin_date"], $contract["duration"], $contract["notice"]);
         $tmp['##contract.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=contract_" . $id);
         $this->datas['contracts'][] = $tmp;
     }
     $this->datas['##lang.contract.time##'] = $event == Alert::END ? $LANG['contract'][0] : $LANG['contract'][1];
     $this->getTags();
     foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
         if (!isset($this->datas[$tag])) {
             $this->datas[$tag] = $values['label'];
         }
     }
 }
 function showForm()
 {
     global $DB;
     $query = "SELECT * FROM\n               `" . $this->getTable() . "`\n               ORDER BY `states_id` ASC";
     if ($result = $DB->query($query)) {
         $number = $DB->numrows($result);
         if ($number != 0) {
             echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action='" . $this->getFormURL() . "'>";
             echo "<div align='center'>";
             echo "<table class='tab_cadre_fixe' cellpadding='5'>";
             echo "<tr>";
             echo "<th>" . __('Status') . "</th><th></th>";
             echo "</tr>";
             while ($ligne = $DB->fetch_array($result)) {
                 $ID = $ligne["id"];
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='10'>";
                 echo "<input type='checkbox' name='item[{$ID}]'";
                 if (isset($_POST['check']) && $_POST['check'] == 'all') {
                     echo " checked ";
                 }
                 echo ">";
                 echo "</td>";
                 echo "<td>" . Dropdown::getDropdownName("glpi_states", $ligne["states_id"]) . "</td>";
                 echo "</tr>";
             }
             echo "</table></div>";
             Html::openArrowMassives("massiveaction_form", true);
             Html::closeArrowMassives(array('delete_state' => _sx('button', 'Delete permanently')));
             Html::closeForm();
             echo "<div align='center'><form method='post' action='" . $this->getFormURL() . "'>";
             echo "<table class='tab_cadre_fixe' cellpadding='5'><tr ><th colspan='2'>";
             echo __('Disposal status', 'financialreports') . " : </th></tr>";
             echo "<tr class='tab_bg_1'><td>";
             Dropdown::show('State', array('name' => "states_id", 'value' => $ligne["states_id"]));
             echo "</td>";
             echo "<td>";
             echo "<div align='center'>";
             echo "<input type='submit' name='add_state' value='" . _sx('button', 'Post') . "' class='submit' >";
             echo "</div></td></tr>";
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         } else {
             echo "<div align='center'><form method='post' action='" . $this->getFormURL() . "'>";
             echo "<table class='tab_cadre' cellpadding='5'><tr ><th colspan='2'>";
             echo __('Disposal status', 'financialreports') . " : </th></tr>";
             echo "<tr class='tab_bg_1'><td>";
             Dropdown::show('State', array('name' => "states_id"));
             echo "</td>";
             echo "<td>";
             echo "<div align='center'>";
             echo "<input type='submit' name='add_state' value='" . _sx('button', 'Post') . "' class='submit' >";
             echo "</div></td></tr>";
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         }
     }
 }
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI;
     if ($event == 'AlertNotValidatedTypology') {
         $this->datas['##typology.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
         $this->datas['##lang.typology.entity##'] = __('Entity');
         $this->datas['##typology.action##'] = __('Elements not match with the typology', 'typology');
         $this->datas['##lang.typology.name##'] = PluginTypologyTypology::getTypeName(1);
         $this->datas['##lang.typology.itemtype##'] = __('Type');
         $this->datas['##lang.typology.items_id##'] = __('Name');
         $this->datas['##lang.typology.error##'] = __('Error');
         $this->datas['##lang.typology.url##'] = __('Link to the typology', 'typology');
         $this->datas['##lang.typology.itemurl##'] = __('Link to the element', 'typology');
         $this->datas['##lang.typology.itemuser##'] = __('User');
         $this->datas['##lang.typology.itemlocation##'] = __('Location');
         foreach ($options['items'] as $id => $item) {
             $tmp = array();
             $tmp['##typology.name##'] = $item['name'];
             $itemtype = new $item['itemtype']();
             $itemtype->getFromDB($item["items_id"]);
             $tmp['##typology.itemtype##'] = $itemtype->getTypeName();
             $tmp['##typology.items_id##'] = $itemtype->getName();
             $tmp['##typology.error##'] = PluginTypologyTypology_Item::displayErrors($item['error'], false);
             $tmp['##typology.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_typology_" . $item['plugin_typology_typologies_id']);
             $tmp['##typology.itemurl##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=" . Toolbox::strtolower($item['itemtype']) . "_" . $item["items_id"]);
             $tmp['##typology.itemuser##'] = getUserName($itemtype->fields["users_id"]);
             $tmp['##typology.itemlocation##'] = Dropdown::getDropdownName("glpi_locations", $itemtype->fields['locations_id']);
             $this->datas['typologyitems'][] = $tmp;
         }
     }
 }
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     return;
     $profile = new Profile();
     $found_profiles = $profile->find("`interface` = 'central'");
     $tab_profile = new self();
     $found_tab_profiles = $tab_profile->find("`plugin_custom_tabs_id` = " . $item->getID());
     echo "<form method='POST' action='tabprofile.form.php' />";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . __("Visibility") . "</th></tr>";
     $odd = 0;
     foreach ($found_profiles as $profiles_id => $profile_fields) {
         if ($odd % 2 === 0) {
             echo "<tr>";
         }
         echo "<td>" . $profile_fields['name'] . "</td>";
         echo "<td>";
         Dropdown::showYesNo("tab_profile[{$profiles_id}]", 0);
         echo "</td>";
         if ($odd % 2 === 1) {
             echo "</tr>";
         }
         $odd++;
     }
     if ($odd % 2 === 0) {
         echo "</tr>";
     }
     echo "<tr><td colspan='4'><div class='center'>";
     echo "<input type='submit' name='update' value=\"" . _sx('button', 'Post') . "\" class='submit'>";
     echo "</div></td></tr>";
     echo "</table>";
     Html::closeForm();
     return true;
 }
Example #10
0
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job)
 {
     global $CFG_GLPI, $DB;
     $ID = $job->getField('id');
     //////////////followups///////////
     $query = "SELECT *\n                FROM `glpi_ticketcosts`\n                WHERE `tickets_id` = '{$ID}'\n                ORDER BY `begin_date`";
     $result = $DB->query($query);
     if (!$DB->numrows($result)) {
         $pdf->setColumnsSize(100);
         $pdf->displayLine(__('No ticket cost for this ticket', 'pdf'));
     } else {
         $pdf->setColumnsSize(60, 20, 20);
         $pdf->displayTitle("<b>" . TicketCost::getTypeName($DB->numrows($result)), __('Ticket duration'), CommonITILObject::getActionTime($job->fields['actiontime']) . "</b>");
         $pdf->setColumnsSize(20, 10, 10, 10, 10, 10, 10, 10, 10);
         $pdf->setColumnsAlign('center', 'center', 'center', 'left', 'right', 'right', 'right', 'right', 'right');
         $pdf->displayTitle("<b><i>" . __('Name') . "</i></b>", "<b><i>" . __('Begin date') . "</i></b>", "<b><i>" . __('End date') . "</i></b>", "<b><i>" . __('Budget') . "</i></b>", "<b><i>" . __('Duration') . "</i></b>", "<b><i>" . __('Time cost') . "</i></b>", "<b><i>" . __('Fixed cost') . "</i></b>", "<b><i>" . __('Material cost') . "</i></b>", "<b><i>" . __('Total cost') . "</i></b>");
         while ($data = $DB->fetch_array($result)) {
             $cost = TicketCost::computeTotalCost($data['actiontime'], $data['cost_time'], $data['cost_fixed'], $data['cost_material']);
             $pdf->displayLine($data['name'], Html::convDate($data['begin_date']), Html::convDate($data['end_date']), Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']), CommonITILObject::getActionTime($data['actiontime']), Html::formatNumber($data['cost_time']), Html::formatNumber($data['cost_fixed']), Html::formatNumber($data['cost_material']), Html::formatNumber($cost));
             $total_time += $data['actiontime'];
             $total_costtime += $data['actiontime'] * $data['cost_time'] / HOUR_TIMESTAMP;
             $total_fixed += $data['cost_fixed'];
             $total_material += $data['cost_material'];
             $total += $cost;
         }
         $pdf->setColumnsSize(50, 10, 10, 10, 10, 10);
         $pdf->setColumnsAlign('right', 'right', 'right', 'right', 'right', 'right');
         $pdf->displayLine('<b>' . __('Total'), CommonITILObject::getActionTime($total_time), Html::formatNumber($total_costtime), Html::formatNumber($total_fixed), Html::formatNumber($total_material), Html::formatNumber($total));
     }
     $pdf->displaySpace();
 }
 /**
  * @see Rule::showNewRuleForm()
  **/
 function showNewRuleForm($ID)
 {
     echo "<form method='post' action='" . Toolbox::getItemTypeFormURL('Entity') . "'>";
     echo "<table  class='tab_cadre_fixe'>";
     echo "<tr><th colspan='7'>" . __('Authorizations assignment rules') . "</th></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td><td>";
     Html::autocompletionTextField($this, "name", array('value' => '', 'size' => 33));
     echo '</td><td>' . __('Description') . "</td><td>";
     Html::autocompletionTextField($this, "description", array('value' => '', 'size' => 33));
     echo "</td><td>" . __('Logical operator') . "</td><td>";
     $this->dropdownRulesMatch();
     echo "</td><td rowspan='2' class='tab_bg_2 center middle'>";
     echo "<input type=hidden name='sub_type' value='" . get_class($this) . "'>";
     echo "<input type=hidden name='entities_id' value='-1'>";
     echo "<input type=hidden name='affectentity' value='{$ID}'>";
     echo "<input type=hidden name='_method' value='AddRule'>";
     echo "<input type='submit' name='execute' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td class='center'>" . _n('Profile', 'Profiles', 1) . "</td><td>";
     Profile::dropdown();
     echo "</td><td><span class='small_space'>" . __('Recursive') . "</span></td><td colspan='3'>";
     Dropdown::showYesNo("is_recursive", 0);
     echo "</td></tr>\n";
     echo "</table>";
     Html::closeForm();
 }
 public function displayField($canEdit = true)
 {
     if ($canEdit) {
         $rand = mt_rand();
         $tab_values = array();
         $required = $this->fields['required'] ? ' required' : '';
         $values = $this->getAvailableValues();
         echo '<div class="form_field">';
         if (!empty($this->fields['values'])) {
             foreach ($values as $value) {
                 if (trim($value) != '') {
                     $tab_values[$value] = $value;
                 }
             }
             if ($this->fields['show_empty']) {
                 $tab_values = array('' => '-----') + $tab_values;
             }
             Dropdown::showFromArray('formcreator_field_' . $this->fields['id'], $tab_values, array('value' => static::IS_MULTIPLE ? '' : $this->getValue(), 'values' => static::IS_MULTIPLE ? $this->getValue() : array(), 'rand' => $rand, 'multiple' => static::IS_MULTIPLE));
         }
         echo '</div>' . PHP_EOL;
         echo '<script type="text/javascript">
               jQuery(document).ready(function($) {
                  jQuery("#dropdown_formcreator_field_' . $this->fields['id'] . $rand . '").on("change", function(e) {
                     var selectedValues = jQuery("#dropdown_formcreator_field_' . $this->fields['id'] . $rand . '").val();
                     formcreatorChangeValueOf (' . $this->fields['id'] . ', selectedValues);
                  });
               });
            </script>';
     } else {
         echo '<div class="form_field">';
         echo nl2br($this->getAnswer());
         echo '</div>' . PHP_EOL;
     }
 }
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI;
     $this->datas['##notinfocom.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     $this->datas['##lang.notinfocom.entity##'] = __('Entity');
     $events = $this->getAllEvents();
     $this->datas['##lang.notinfocom.title##'] = $events[$event];
     $this->datas['##lang.notinfocom.name##'] = __('Name');
     $this->datas['##lang.notinfocom.urlname##'] = __('URL');
     $this->datas['##lang.notinfocom.computertype##'] = __('Type');
     $this->datas['##lang.notinfocom.operatingsystem##'] = __('Operating system');
     $this->datas['##lang.notinfocom.state##'] = __('Status');
     $this->datas['##lang.notinfocom.location##'] = __('Location');
     $this->datas['##lang.notinfocom.urluser##'] = __('URL');
     $this->datas['##lang.notinfocom.urlgroup##'] = __('URL');
     $this->datas['##lang.notinfocom.user##'] = __('User');
     $this->datas['##lang.notinfocom.group##'] = __('Group');
     foreach ($options['notinfocoms'] as $id => $notinfocom) {
         $tmp = array();
         $tmp['##notinfocom.urlname##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=computer_" . $notinfocom['id']);
         $tmp['##notinfocom.name##'] = $notinfocom['name'];
         $tmp['##notinfocom.computertype##'] = Dropdown::getDropdownName("glpi_computertypes", $notinfocom['computertypes_id']);
         $tmp['##notinfocom.operatingsystem##'] = Dropdown::getDropdownName("glpi_operatingsystems", $notinfocom['operatingsystems_id']);
         $tmp['##notinfocom.state##'] = Dropdown::getDropdownName("glpi_states", $notinfocom['states_id']);
         $tmp['##notinfocom.location##'] = Dropdown::getDropdownName("glpi_locations", $notinfocom['locations_id']);
         $tmp['##notinfocom.urluser##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=user_" . $notinfocom['users_id']);
         $tmp['##notinfocom.urlgroup##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=group_" . $notinfocom['groups_id']);
         $tmp['##notinfocom.user##'] = getUserName($notinfocom['users_id']);
         $tmp['##notinfocom.group##'] = Dropdown::getDropdownName("glpi_groups", $notinfocom['groups_id']);
         $tmp['##notinfocom.contact##'] = $notinfocom['contact'];
         $this->datas['notinfocoms'][] = $tmp;
     }
 }
 function executeActions($output, $params)
 {
     if (count($this->actions)) {
         foreach ($this->actions as $action) {
             switch ($action->fields["action_type"]) {
                 case "assign":
                     $output[$action->fields["field"]] = $action->fields["value"];
                     break;
                 case "regex_result":
                     //Regex result : assign value from the regex
                     $res = "";
                     if (isset($this->regex_results[0])) {
                         $res .= RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
                     } else {
                         $res .= $action->fields["value"];
                     }
                     if ($res != '' && ($action->fields["field"] != 'user' && $action->fields["field"] != 'otherserial' && $action->fields["field"] != 'software' && $action->fields["field"] != 'softwareversion')) {
                         $res = Dropdown::importExternal(getItemTypeForTable(getTableNameForForeignKeyField($action->fields['field'])), $res);
                     }
                     $output[$action->fields["field"]] = $res;
                     break;
                 default:
                     //plugins actions
                     $executeaction = clone $this;
                     $ouput = $executeaction->executePluginsActions($action, $output, $params);
                     break;
             }
         }
     }
     return $output;
 }
 static function showForGroup(Group $group)
 {
     global $DB;
     $ID = $group->getField('id');
     if (!$group->can($ID, READ)) {
         return false;
     }
     $canedit = $group->can($ID, UPDATE);
     if ($canedit) {
         // Get data
         $item = new self();
         if (!$item->getFromDB($ID)) {
             $item->getEmpty();
         }
         $rand = mt_rand();
         echo "<form name='group_level_form{$rand}' id='group_level_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<input type='hidden' name='" . self::$items_id . "' value='{$ID}' />";
         echo "<div class='spaced'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th>" . __('Level attribution', 'itilcategorygroups') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td class='center'>";
         Dropdown::showFromArray('lvl', array(NULL => "---", 1 => __('Level 1', 'itilcategorygroups'), 2 => __('Level 2', 'itilcategorygroups'), 3 => __('Level 3', 'itilcategorygroups'), 4 => __('Level 4', 'itilcategorygroups')), array('value' => $item->fields['lvl']));
         echo "</td></tr>";
         echo "</td><td class='center'>";
         if ($item->fields["id"]) {
             echo "<input type='hidden' name='id' value='" . $item->fields["id"] . "'>";
             echo "<input type='submit' name='update' value=\"" . __('Save') . "\"\n                   class='submit'>";
         } else {
             echo "<input type='submit' name='add' value=\"" . __('Save') . "\" class='submit'>";
         }
         echo "</td></tr>";
         echo "</table></div>";
         Html::closeForm();
     }
 }
Example #16
0
 /**
  * Configuration form
  **/
 function showForm($id, $options = array())
 {
     $target = $this->getFormURL();
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $canedit = Session::haveRight("profile", "w");
     $prof = new Profile();
     if ($id) {
         $this->getFromDB($id);
         $prof->getFromDB($id);
     }
     echo "<form action='" . $target . "' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2' class='center b'>" . sprintf(_('%1$s %2$s'), 'gestion Vip :', Dropdown::getDropdownName("glpi_groups", $this->fields["id"]));
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>Groupe Vip</td><td>";
     Dropdown::showYesNo("isvip", $this->fields["isvip"]);
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' colspan='2'>";
         echo "<input type='hidden' name='id' value={$id}>";
         echo "<input type='submit' name='update_vip_group' value='Mettre à jour' class='submit'>";
         echo "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
 }
 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $DB, $CFG_GLPIG;
     if (!Session::haveRight("contract", "r")) {
         return false;
     }
     $type = $item->getType();
     $ID = $item->getField('id');
     $con = new Contract();
     $query = "SELECT *\n                FROM `glpi_contracts_items`\n                WHERE `glpi_contracts_items`.`items_id` = '" . $ID . "'\n                      AND `glpi_contracts_items`.`itemtype` = '" . $type . "'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = $j = 0;
     $pdf->setColumnsSize(100);
     if ($number > 0) {
         $pdf->displayTitle('<b>' . _N('Associated contract', 'Associated contracts', 2) . '</b>');
         $pdf->setColumnsSize(19, 19, 19, 16, 11, 16);
         $pdf->displayTitle(__('Name'), _x('phone', 'Number'), __('Contract type'), __('Supplier'), __('Start date'), __('Initial contract period'));
         $i++;
         while ($j < $number) {
             $cID = $DB->result($result, $j, "contracts_id");
             $assocID = $DB->result($result, $j, "id");
             if ($con->getFromDB($cID)) {
                 $pdf->displayLine(empty($con->fields["name"]) ? "(" . $con->fields["id"] . ")" : $con->fields["name"], $con->fields["num"], Html::clean(Dropdown::getDropdownName("glpi_contracttypes", $con->fields["contracttypes_id"])), str_replace("<br>", " ", $con->getSuppliersNames()), Html::convDate($con->fields["begin_date"]), sprintf(_n('%d month', '%d months', $con->fields["duration"]), $con->fields["duration"]));
             }
             $j++;
         }
     } else {
         $pdf->displayTitle("<b>" . __('No item found') . "</b>");
     }
     $pdf->displaySpace();
 }
 function showForm($target)
 {
     global $DB;
     $rand = mt_rand();
     $query = "SELECT *\n                 FROM `" . $this->getTable() . "`\n                 ORDER BY `states_id` ASC ";
     if ($result = $DB->query($query)) {
         $number = $DB->numrows($result);
         if ($number != 0) {
             echo "<div align='center'><form method='post' name='massiveaction_form{$rand}' id='massiveaction_form{$rand}'  action=\"{$target}\">";
             echo "<table class='tab_cadre_fixe' cellpadding='5'>";
             echo "<tr>";
             echo "<th></th><th>" . _n('Status', 'Statuses', 2) . "</th>";
             echo "</tr>";
             while ($ligne = $DB->fetch_array($result)) {
                 $ID = $ligne["id"];
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='10' class='center'>";
                 echo "<input type='hidden' name='id' value='{$ID}'>";
                 echo "<input type='checkbox' name='item[{$ID}]' value='1'>";
                 echo "</td>";
                 echo "<td>" . Dropdown::getDropdownName("glpi_states", $ligne["states_id"]) . "</td>";
                 echo "</tr>";
             }
             Html::openArrowMassives("massiveaction_form{$rand}", true);
             Html::closeArrowMassives(array('delete_state' => __('Delete permanently')));
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         }
     }
 }
Example #19
0
 function showForm($ID, $options = array())
 {
     global $DB;
     $target = $this->getFormURL();
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         $this->check(-1, 'w');
         $this->getEmpty();
     }
     $canedit = $this->can($ID, 'w');
     echo "<form action='" . $target . "' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2' class='center b'>" . sprintf(__('%1$s - %2$s'), __('Print to pdf', 'pdf'), $this->fields["profile"]);
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Print to pdf', 'pdf') . "</td><td>";
     Dropdown::showYesNo("use", isset($this->fields["use"]) ? $this->fields["use"] : '');
     echo "</td></tr>\n";
     if ($canedit) {
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='2' class='center'>";
         echo "<input type='hidden' name='id' value={$ID}>";
         echo "<input type='submit' name='update_user_profile' value='" . _sx('button', 'Update') . "' class='submit'>&nbsp;";
         echo "</td></tr>\n";
     }
     echo "</table>";
     Html::closeForm();
 }
Example #20
0
 static function pdfMain(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
 {
     global $DB;
     $ID = $item->getField('id');
     if (!Session::haveRight('knowbase', 'r') || !Session::haveRight('faq', 'r')) {
         return false;
     }
     $knowbaseitemcategories_id = $item->getField('knowbaseitemcategories_id');
     $fullcategoryname = Html::clean(getTreeValueCompleteName("glpi_knowbaseitemcategories", $knowbaseitemcategories_id));
     $question = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('name'), ENT_QUOTES, "UTF-8")));
     $answer = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('answer'), ENT_QUOTES, "UTF-8")));
     $pdf->setColumnsSize(100);
     if (Toolbox::strlen($fullcategoryname) > 0) {
         $pdf->displayTitle('<b>' . __('Category name') . '</b>');
         $pdf->displayLine($fullcategoryname);
     }
     if (Toolbox::strlen($question) > 0) {
         $pdf->displayTitle('<b>' . __('Subject') . '</b>');
         $pdf->displayText('', $question, 5);
     } else {
         $pdf->displayTitle('<b>' . __('No question found', 'pdf') . '</b>');
     }
     if (Toolbox::strlen($answer) > 0) {
         $pdf->displayTitle('<b>' . __('Content') . '</b>');
         $pdf->displayText('', $answer, 5);
     } else {
         $pdf->displayTitle('<b>' . __('No answer found') . '</b>');
     }
     $pdf->setColumnsSize(50, 15, 15, 10, 10);
     $pdf->displayTitle(__('Writer'), __('Creation date'), __('Last update'), __('FAQ'), _n('View', 'Views', 2));
     $pdf->displayLine(getUserName($item->fields["users_id"]), Html::convDateTime($item->fields["date"]), Html::convDateTime($item->fields["date_mod"]), Dropdown::getYesNo($item->fields["is_faq"]), $item->fields["view"]);
     $pdf->displaySpace();
 }
 static function pdfMain(PluginPdfSimplePDF $pdf, SoftwareLicense $license, $main = true, $cpt = true)
 {
     global $DB;
     $ID = $license->getField('id');
     $pdf->setColumnsSize(100);
     $entity = '';
     if (Session::isMultiEntitiesMode() && !$main) {
         $entity = ' (' . Html::clean(Dropdown::getDropdownName('glpi_entities', $license->fields['entities_id'])) . ')';
     }
     $pdf->displayTitle('<b><i>' . sprintf(__('%1$s: %2$s'), __('ID') . "</i>", $ID . "</b>" . $entity));
     $pdf->setColumnsSize(50, 50);
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), Software::getTypeName(1) . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwares', $license->fields['softwares_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Type') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwarelicensetypes', $license->fields['softwarelicensetypes_id']))));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Name') . '</i></b>', $license->fields['name']), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Serial number') . '</i></b>', $license->fields['serial']));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Purchase version') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwareversions', $license->fields['softwareversions_id_buy']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Inventory number') . '</i></b>', $license->fields['otherserial']));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Version in use') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwareversions', $license->fields['softwareversions_id_use']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Expiration') . '</i></b>', Html::convDate($license->fields['expire'])));
     $col2 = '';
     if ($cpt) {
         $col2 = '<b><i>' . sprintf(__('%1$s: %2$s'), __('Affected computers') . '</i></b>', Computer_SoftwareLicense::countForLicense($ID));
     }
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), _x('quantity', 'Number') . '</i></b>', $license->fields['number'] > 0 ? $license->fields['number'] : __('Unlimited')), $col2);
     $pdf->setColumnsSize(100);
     PluginPdfCommon::mainLine($pdf, $license, 'comment');
     if ($main) {
         $pdf->displaySpace();
     }
 }
Example #22
0
function plugin_barcode_MassiveActionsDisplay($options = array())
{
    switch ($options['itemtype']) {
        case 'Computer':
        case 'Monitor':
        case 'Networking':
        case 'Printer':
        case 'Peripheral':
            switch ($options['action']) {
                case "plugin_barcode_barcode":
                    $barcode = new PluginBarcodeBarcode();
                    $barcode->showFormMassiveAction();
                    break;
                case "plugin_barcode_qrcode":
                    $pbQRcode = new PluginBarcodeQRcode();
                    $pbQRcode->showFormMassiveAction();
                    break;
            }
            break;
        case 'Profile':
            switch ($options['action']) {
                case "plugin_barcode_allow":
                    Dropdown::showYesNo('generate');
                    Dropdown::showYesNo('config');
                    echo "<input type='submit' name='massiveaction' class='submit' value='" . __('Save') . "'>";
                    break;
            }
            break;
    }
    return "";
}
 function showForm($id, $options = array())
 {
     if (!$this->can($id, READ)) {
         return false;
     }
     $this->showFormHeader($options);
     echo "<tr>";
     echo "<td><label>" . __('Name') . " :</label></td>";
     echo "<td style='width:30%'>";
     echo Html::autocompletionTextField($this, "name");
     echo "</td>";
     $rand = mt_rand();
     echo "<td><label for='dropdown_is_active{$rand}'>" . __('Active') . " :</label></td>";
     echo "<td style='width:30%'>";
     Dropdown::showYesNo('is_active', $this->fields['is_active'], -1, array('rand' => $rand));
     echo "</td></tr>";
     $rand = mt_rand();
     echo "<tr>";
     echo "<td><label for='dropdown_itilcategories_id{$rand}'>" . __('Category') . " :</label></td>";
     echo "<td>";
     Dropdown::show('ITILCategory', array('value' => $this->fields['itilcategories_id'], 'rand' => $rand));
     echo "</td><td colspan='2'></td></tr>";
     $rand = mt_rand();
     echo "<tr>";
     echo "<td><label for='dropdown_is_incident{$rand}'>" . __('Visible for an incident') . " :</label></td>";
     echo "<td>";
     Dropdown::showYesNo('is_incident', $this->fields['is_incident'], -1, array('rand' => $rand));
     echo "</td>";
     $rand = mt_rand();
     echo "<td><label for='dropdown_is_request{$rand}'>" . __('Visible for a request') . " :</label></td>";
     echo "<td>";
     Dropdown::showYesNo('is_request', $this->fields['is_request'], -1, array('rand' => $rand));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td><label for='comment'>" . __('Comments') . " : </label></td>";
     echo "<td align='left'>";
     echo "<textarea name='comment' id='comment' style='width:100%; height:70px;'>";
     echo $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr><td colspan='4'><hr></td></tr>";
     echo "<tr><td><label for='groups_id_level1[]'>" . ucfirst(__('Level 1', 'itilcategorygroups')) . " :</label></td>";
     echo "<td>";
     self::multipleDropdownGroup(1, $this->fields['itilcategories_id'], $this->fields['view_all_lvl1']);
     echo "</td>";
     echo "<td><label for='groups_id_level2[]'>" . ucfirst(__('Level 2', 'itilcategorygroups')) . " :</label></td>";
     echo "<td>";
     self::multipleDropdownGroup(2, $this->fields['itilcategories_id'], $this->fields['view_all_lvl2']);
     echo "</td></tr>";
     echo "<tr><td><label for='groups_id_level3[]'>" . ucfirst(__('Level 3', 'itilcategorygroups')) . " :</label></td>";
     echo "<td>";
     self::multipleDropdownGroup(3, $this->fields['itilcategories_id'], $this->fields['view_all_lvl3']);
     echo "</td>";
     echo "<td><label for='groups_id_level4[]'>" . ucfirst(__('Level 4', 'itilcategorygroups')) . " :</label></td>";
     echo "<td>";
     self::multipleDropdownGroup(4, $this->fields['itilcategories_id'], $this->fields['view_all_lvl4']);
     echo "</td></tr>";
     $this->showFormButtons($options);
     Html::closeForm();
 }
Example #24
0
 function __construct($name, $value, $valueTable, $valueField = 'nefub_id', array $where = array(), $orderBy = 'name', $direction = 'ASC', $limit = null)
 {
     parent::__construct($name, (int) $value);
     $rows = Database::select_rows($valueTable, $where, $orderBy, $limit, $direction);
     $this->addOption('Geen', 0);
     foreach ($rows as $row) {
         $this->addOption($row['name'], $row[$valueField]);
     }
 }
 function __construct($name, $value, $min = 0, $max = 99)
 {
     parent::__construct($name, $value);
     $this->addOption('Geen', 0);
     for ($i = 0; $i <= $max; $i++) {
         $this->addOption($i, $i);
     }
     $this->addAttributes(array('class' => 'numeric'));
 }
 public function getAnswer()
 {
     $value = $this->getValue();
     if ($this->fields['values'] == 'User') {
         return getUserName($value);
     } else {
         return Dropdown::getDropdownName(getTableForItemType($this->fields['values']), $value);
     }
 }
		/**
		 * writes HTML for the Selector
		 */
		 function draw_selector() {
		   	global $lang, $statsinfo;
           	$values = createNameValueArray($this->table, $this->namecol, $this->valuecol, $this->cond);		   
		   	echo "<tr><td>";
			echo "<table width=\"185\" cellpadding=\"3\" cellspacing=\"3\" class=\"sidebar_menubox\"><tr><td>";
			echo "<table width='100%' cellpadding='3' cellspacing='0' border='0'>";
			echo "<tr>";
			$dropdown = new Dropdown($this->identifier, $values, 'standardwhite', $this->selected, 100, 1);
			$dropdown->draw();
			echo "</td><td>";
			$lbi = new ButtonInline("changetop", $lang->get('change', 'Change'), 'navelement', 'submit', '', 'f'.$this->identifier);
			echo $lbi->draw();
			echo '<input type="hidden" name="changetop" value="">';
			echo "</td></tr>";
			echo "</tr></table>";
			echo "</td></tr></table>";
			echo "</td></tr>";
		 }
Example #28
0
 function __construct($name, $value)
 {
     parent::__construct($name, (int) $value);
     $query = "SELECT Team.nefub_id, CONCAT(Team.name, ' (', Competition.name, ')') as name\r\n\t\t\t\t\tFROM Team\r\n\t\t\t\t\tLEFT JOIN Competition ON Team.competition_nefub_id = Competition.nefub_id\r\n\t\t\t\t\tORDER BY Team.name ASC, Competition.name ASC";
     $rows = Database::select_rows_by_query($query);
     $this->addOption('Geen', 0);
     foreach ($rows as $row) {
         $this->addOption($row['name'], $row['nefub_id']);
     }
 }
Example #29
0
 /**
  * @since version 0.84
  *
  * @param $row                HTMLTableRow object (default NULL)
  * @param $item               CommonDBTM object (default NULL)
  * @param $father             HTMLTableCell object (default NULL)
  * @param $options   array
  **/
 static function getHTMLTableCellsForItem(HTMLTableRow $row = NULL, CommonDBTM $item = NULL, HTMLTableCell $father = NULL, array $options = array())
 {
     $column_name = __CLASS__;
     if (isset($options['dont_display'][$column_name])) {
         return;
     }
     if ($item->fields["interfacetypes_id"]) {
         $row->addCell($row->getHeaderByName($column_name), Dropdown::getDropdownName("glpi_interfacetypes", $item->fields["interfacetypes_id"]));
     }
 }
 static function dropdownEvents($itemtype, $value = '')
 {
     $events = array();
     $target = NotificationTarget::getInstanceByType($itemtype);
     if ($target) {
         $events = $target->getAllEvents();
     }
     $events[''] = DROPDOWN_EMPTY_VALUE;
     Dropdown::showFromArray('event', $events, array('value' => $value));
 }