dropdown() static public method

static public dropdown ( $options = [] )
$options array
 static function showNotificationOptions(Entity $entity)
 {
     global $LANG;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, 'r') || !haveRight('notification', 'r')) {
         return false;
     }
     // Notification right applied
     $canedit = haveRight('notification', 'w') && haveAccessToEntity($ID);
     // Get data
     $entitynotification = new EntityData();
     if (!$entitynotification->getFromDB($ID)) {
         $entitynotification->getEmpty();
     }
     echo "<div class='spaced'>";
     if ($canedit) {
         echo "<form method='post' name=form action='" . getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . $LANG['setup'][240] . "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['setup'][203] . "&nbsp;:&nbsp;</td>";
     echo "<td>";
     autocompletionTextField($entitynotification, "admin_email");
     echo "</td>";
     echo "<td>" . $LANG['setup'][208] . "</td><td>";
     autocompletionTextField($entitynotification, "admin_email_name");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['setup'][207] . "&nbsp;:&nbsp;</td>";
     echo "<td>";
     autocompletionTextField($entitynotification, "admin_reply");
     echo "</td>";
     echo "<td>" . $LANG['setup'][209] . "</td><td>";
     autocompletionTextField($entitynotification, "admin_reply_name");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td class='middle right'>" . $LANG['setup'][204] . "</td>";
     echo "<td colspan='3'>";
     echo "<textarea cols='60' rows='5' name='mailing_signature'>" . $entitynotification->fields["mailing_signature"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr><th colspan='4'>" . $LANG['setup'][242] . "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['setup'][245] . " - " . $LANG['setup'][244] . "</td><td>";
     $default_value = $entitynotification->fields['cartridges_alert_repeat'];
     Alert::dropdown(array('name' => 'cartridges_alert_repeat', 'value' => $default_value, 'inherit_global' => 1));
     echo "</td>";
     echo "<td>" . $LANG['setup'][245] . " - " . $LANG['setup'][243] . "</td><td>";
     $default_value = $entitynotification->fields['consumables_alert_repeat'];
     Alert::dropdown(array('name' => 'consumables_alert_repeat', 'value' => $default_value, 'inherit_global' => 1));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['setup'][264] . "</td><td>";
     $default_value = $entitynotification->fields['use_licenses_alert'];
     Alert::dropdownYesNo(array('name' => "use_licenses_alert", 'value' => $default_value, 'inherit_global' => 1));
     echo "</td>";
     echo "<td>" . $LANG['setup'][246] . "</td><td>";
     $default_value = $entitynotification->fields['use_contracts_alert'];
     Alert::dropdownYesNo(array('name' => "use_contracts_alert", 'value' => $default_value, 'inherit_global' => 1));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['setup'][247] . "</td><td>";
     $default_value = $entitynotification->fields['use_infocoms_alert'];
     Alert::dropdownYesNo(array('name' => "use_infocoms_alert", 'value' => $default_value, 'inherit_global' => 1));
     echo "</td>";
     echo "<td>" . $LANG['setup'][707] . "</td><td>";
     Alert::dropdownIntegerNever('use_reservations_alert', $entitynotification->fields['use_reservations_alert'], array('max' => 99, 'inherit_global' => 1));
     echo "&nbsp;" . $LANG['job'][21] . "</td></tr>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td >" . $LANG['setup'][708] . "</td><td>";
     Alert::dropdownIntegerNever('notclosed_delay', $entitynotification->fields["notclosed_delay"], array('max' => 99, 'inherit_global' => 1));
     echo "&nbsp;" . $LANG['stats'][31] . "</td>";
     echo "<td colspan='2'></td></tr>";
     if ($canedit) {
         echo "<tr>";
         echo "<td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='hidden' name='entities_id' value='{$ID}'>";
         if ($entitynotification->fields["id"]) {
             echo "<input type='hidden' name='id' value='" . $entitynotification->fields["id"] . "'>";
             echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\"\n                   class='submit'>";
         } else {
             echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][7] . "\" class='submit'>";
         }
         echo "</td></tr>";
         echo "</table></form>";
     } else {
         echo "</table>";
     }
     echo "</div>";
 }
Example #2
0
 /**
  * @since version 0.84
  *
  * @param $field
  * @param $name               (default '')
  * @param $values             (default '')
  * @param $options      array
  **/
 static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = array())
 {
     global $DB;
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     $options['display'] = false;
     switch ($field) {
         case 'use_licenses_alert':
         case 'use_contracts_alert':
         case 'use_infocoms_alert':
             $options['name'] = $name;
             $options['value'] = $values[$field];
             return Alert::dropdownYesNo($options);
         case 'cartridges_alert_repeat':
         case 'consumables_alert_repeat':
             $options['name'] = $name;
             $options['value'] = $values[$field];
             return Alert::dropdown($options);
         case 'send_contracts_alert_before_delay':
         case 'send_infocoms_alert_before_delay':
         case 'send_licenses_alert_before_delay':
             $options['unit'] = 'day';
             $options['never_string'] = __('No');
             return Alert::dropdownIntegerNever($name, $values[$field], $options);
         case 'use_reservations_alert':
             $options['unit'] = 'hour';
             return Alert::dropdownIntegerNever($name, $values[$field], $options);
         case 'notclosed_delay':
             $options['unit'] = 'hour';
             return Alert::dropdownIntegerNever($name, $values[$field], $options);
         case 'auto_assign_mode':
             $options['name'] = $name;
             $options['value'] = $values[$field];
             return self::dropdownAutoAssignMode($options);
         case 'tickettype':
             $options['value'] = $values[$field];
             $options['toadd'] = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
             return Ticket::dropdownType($name, $options);
         case 'autofill_buy_date':
         case 'autofill_order_date':
         case 'autofill_delivery_date':
         case 'autofill_use_date':
             $tab[0] = __('No autofill');
             $tab[self::CONFIG_PARENT] = __('Inheritance of the parent entity');
             foreach (getAllDatasFromTable('glpi_states') as $state) {
                 $tab[Infocom::ON_STATUS_CHANGE . '_' . $state['id']] = sprintf(__('Fill when shifting to state %s'), $state['name']);
             }
             $tab[Infocom::COPY_WARRANTY_DATE] = __('Copy the start date of warranty');
             if ($field != 'autofill_buy_date') {
                 $tab[Infocom::COPY_BUY_DATE] = __('Copy the date of purchase');
                 if ($field != 'autofill_order_date') {
                     $tab[Infocom::COPY_ORDER_DATE] = __('Copy the order date');
                     if ($field != 'autofill_delivery_date') {
                         $options[Infocom::COPY_DELIVERY_DATE] = __('Copy the delivery date');
                     }
                 }
             }
             $options['value'] = $values[$field];
             return Dropdown::showFromArray($name, $tab, $options);
         case 'autofill_warranty_date':
             $tab = array(0 => __('No autofill'), Infocom::COPY_BUY_DATE => __('Copy the date of purchase'), Infocom::COPY_ORDER_DATE => __('Copy the order date'), Infocom::COPY_DELIVERY_DATE => __('Copy the delivery date'), self::CONFIG_PARENT => __('Inheritance of the parent entity'));
             $options['value'] = $values[$field];
             return Dropdown::showFromArray($name, $tab, $options);
         case 'inquest_config':
             $typeinquest = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), 1 => __('Internal survey'), 2 => __('External survey'));
             $options['value'] = $values[$field];
             return Dropdown::showFromArray($name, $typeinquest, $options);
         case 'default_contract_alert':
             $options['name'] = $name;
             $options['value'] = $values[$field];
             return Contract::dropdownAlert($options);
         case 'default_infocom_alert':
             $options['name'] = $name;
             $options['value'] = $values[$field];
             return Infocom::dropdownAlert($options);
         case 'entities_id_software':
             $options['toadd'] = array(self::CONFIG_NEVER => __('No change of entity'));
             // Keep software in PC entity
             $options['toadd'][self::CONFIG_PARENT] = __('Inheritance of the parent entity');
             return self::dropdown($options);
     }
     return parent::getSpecificValueToSelect($field, $name, $values, $options);
 }
 function showFormAlerts()
 {
     global $LANG, $CFG_GLPI;
     echo "<form action='" . getItemTypeFormURL(__CLASS__) . "' method='post'>";
     echo "<input type='hidden' name='id' value='1'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><th colspan='4'>" . $LANG['common'][41] . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td >" . $LANG['setup'][246] . "&nbsp;:</td><td>";
     Alert::dropdownYesNo(array('name' => "use_contracts_alert", 'value' => $CFG_GLPI["use_contracts_alert"]));
     echo "</td>";
     echo "<td>" . $LANG['setup'][46] . "&nbsp;:</td><td>";
     Contract::dropdownAlert("default_contract_alert", $CFG_GLPI["default_contract_alert"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td >" . $LANG['setup'][247] . "&nbsp;:</td><td>";
     Alert::dropdownYesNo(array('name' => "use_infocoms_alert", 'value' => $CFG_GLPI["use_infocoms_alert"]));
     echo "</td>";
     echo "<td>" . $LANG['setup'][46] . "&nbsp;:</td><td>";
     Alert::dropdownInfocomAlert($CFG_GLPI["default_infocom_alert"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td >" . $LANG['setup'][264] . "&nbsp;:</td><td>";
     Alert::dropdownYesNo(array('name' => "use_licenses_alert", 'value' => $CFG_GLPI["use_licenses_alert"]));
     echo "</td>";
     echo "<td colspan='2'></td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td >" . $LANG['setup'][707] . "&nbsp;:</td><td>";
     Alert::dropdownIntegerNever('use_reservations_alert', $CFG_GLPI["use_reservations_alert"], array('max' => 99));
     echo "&nbsp;" . $LANG['job'][21] . "</td>";
     echo "<td colspan='2'></td></tr>";
     echo "<tr class='tab_bg_2'><td >" . $LANG['setup'][708] . "&nbsp;:</td><td>";
     Alert::dropdownIntegerNever('notclosed_delay', $CFG_GLPI["notclosed_delay"], array('max' => 99));
     echo "&nbsp;" . $LANG['stats'][31] . "</td>";
     echo "<td colspan='2'></td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . $LANG['setup'][245] . "&nbsp;: " . $LANG['setup'][244] . "&nbsp;:</td><td>";
     Alert::dropdown(array('name' => 'cartridges_alert_repeat', 'value' => $CFG_GLPI["cartridges_alert_repeat"]));
     echo "</td>";
     echo "<td>" . $LANG['setup'][115] . "&nbsp;:</td><td>";
     Dropdown::showInteger('default_alarm_threshold', $CFG_GLPI["default_alarm_threshold"], -1, 100);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td >" . $LANG['setup'][245] . "&nbsp;: " . $LANG['setup'][243] . "&nbsp;:</td><td>";
     Alert::dropdown(array('name' => 'consumables_alert_repeat', 'value' => $CFG_GLPI["consumables_alert_repeat"]));
     echo "</td><td colspan='2'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td class='center' colspan='4'>";
     echo "<input class='submit' type='submit' name='update' value=\"" . $LANG['buttons'][2] . "\">";
     echo "</td></tr>";
     echo "</table></form>";
 }