showDateField() статический публичный Метод

Display Date form with calendar
static public showDateField ( $name, $options = [] ) : rand
$name name of the element
$options array of possible options: - value : default value to display (default '') - maybeempty : may be empty ? (true by default) - canedit : could not modify element (true by default) - min : minimum allowed date (default '') - max : maximum allowed date (default '') - showyear : should we set/diplay the year? (true by default) - display : boolean display of return string (default true) - rand : specific rand value (default generated one) - yearrange : set a year range to show in drop-down (default '')
Результат rand value used if displayes else string
 public function displayField($canEdit = true)
 {
     if ($canEdit) {
         $required = $canEdit && $this->fields['required'] ? ' required' : '';
         $rand = mt_rand();
         Html::showDateField('formcreator_field_' . $this->fields['id'], array('value' => $this->getValue(), 'rand' => $rand));
         echo '<script type="text/javascript">
               jQuery(document).ready(function($) {
                  $( "#showdate' . $rand . '" ).on("change", function() {
                     formcreatorChangeValueOf(' . $this->fields['id'] . ', this.value);
                  });
                  $( "#resetdate' . $rand . '" ).on("click", function() {
                     formcreatorChangeValueOf(' . $this->fields['id'] . ', "");
                  });
               });
            </script>';
     } else {
         echo $this->getAnswer();
     }
 }
 /**
  * Print the config form for restrictions
  *
  * @return Nothing (display)
  **/
 function showFormInventory()
 {
     global $DB, $CFG_GLPI;
     if (!self::canView()) {
         return false;
     }
     $canedit = Config::canUpdate();
     if ($canedit) {
         echo "<form name='form' action=\"" . Toolbox::getItemTypeFormURL(__CLASS__) . "\" method='post'>";
     }
     echo "<div class='center' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . __('Assets') . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td width='30%'>" . __('Enable the financial and administrative information by default') . "</td>";
     echo "<td  width='20%'>";
     Dropdown::ShowYesNo('auto_create_infocoms', $CFG_GLPI["auto_create_infocoms"]);
     echo "</td><td width='20%'> " . __('Restrict monitor management') . "</td>";
     echo "<td width='30%'>";
     $this->dropdownGlobalManagement("monitors_management_restrict", $CFG_GLPI["monitors_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Software category deleted by the dictionary rules') . "</td><td>";
     SoftwareCategory::dropdown(array('value' => $CFG_GLPI["softwarecategories_id_ondelete"], 'name' => "softwarecategories_id_ondelete"));
     echo "</td><td> " . __('Restrict device management') . "</td><td>";
     $this->dropdownGlobalManagement("peripherals_management_restrict", $CFG_GLPI["peripherals_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Beginning of fiscal year') . "</td><td>";
     Html::showDateField("date_tax", array('value' => $CFG_GLPI["date_tax"], 'maybeempty' => false, 'canedit' => true, 'min' => '', 'max' => '', 'showyear' => false));
     echo "</td><td> " . __('Restrict phone management') . "</td><td>";
     $this->dropdownGlobalManagement("phones_management_restrict", $CFG_GLPI["phones_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Automatic fields (marked by *)') . "</td><td>";
     $tab = array(0 => __('Global'), 1 => __('By entity'));
     Dropdown::showFromArray('use_autoname_by_entity', $tab, array('value' => $CFG_GLPI["use_autoname_by_entity"]));
     echo "</td><td> " . __('Restrict printer management') . "</td><td>";
     $this->dropdownGlobalManagement("printers_management_restrict", $CFG_GLPI["printers_management_restrict"]);
     echo "</td></tr>";
     echo "</table>";
     if (Session::haveRightsOr("transfer", array(CREATE, UPDATE)) && Session::isMultiEntitiesMode()) {
         echo "<br><table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='2'>" . __('Automatic transfer of computers') . "</th></tr>";
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . __('Template for the automatic transfer of computers in another entity') . "</td><td>";
         Transfer::dropdown(array('value' => $CFG_GLPI["transfers_id_auto"], 'name' => "transfers_id_auto", 'emptylabel' => __('No automatic transfer')));
         echo "</td></tr>";
         echo "</table>";
     }
     echo "<br><table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='4'>" . __('Automatically update of the elements related to the computers');
     echo "</th><th colspan='2'>" . __('Unit management') . "</th></tr>";
     echo "<tr><th>&nbsp;</th>";
     echo "<th>" . __('Alternate username') . "</th>";
     echo "<th>" . __('User') . "</th>";
     echo "<th>" . __('Group') . "</th>";
     echo "<th>" . __('Location') . "</th>";
     echo "<th>" . __('Status') . "</th>";
     echo "</tr>";
     $fields = array("contact", "user", "group", "location");
     echo "<tr class='tab_bg_2'>";
     echo "<td> " . __('When connecting or updating') . "</td>";
     $values[0] = __('Do not copy');
     $values[1] = __('Copy');
     foreach ($fields as $field) {
         echo "<td>";
         $fieldname = "is_" . $field . "_autoupdate";
         Dropdown::showFromArray($fieldname, $values, array('value' => $CFG_GLPI[$fieldname]));
         echo "</td>";
     }
     echo "<td>";
     State::dropdownBehaviour("state_autoupdate_mode", __('Copy computer status'), $CFG_GLPI["state_autoupdate_mode"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td> " . __('When disconnecting') . "</td>";
     $values[0] = __('Do not delete');
     $values[1] = __('Clear');
     foreach ($fields as $field) {
         echo "<td>";
         $fieldname = "is_" . $field . "_autoclean";
         Dropdown::showFromArray($fieldname, $values, array('value' => $CFG_GLPI[$fieldname]));
         echo "</td>";
     }
     echo "<td>";
     State::dropdownBehaviour("state_autoclean_mode", __('Clear status'), $CFG_GLPI["state_autoclean_mode"]);
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_2'>";
         echo "<td colspan='6' class='center'>";
         echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">";
         echo "</td></tr>";
     }
     echo "</table></div>";
     Html::closeForm();
 }
Пример #3
0
    $_POST["date2"] = date("Y-m-d");
}
if (!empty($_POST["date1"]) && !empty($_POST["date2"]) && strcmp($_POST["date2"], $_POST["date1"]) < 0) {
    $tmp = $_POST["date1"];
    $_POST["date1"] = $_POST["date2"];
    $_POST["date2"] = $tmp;
}
Report::title();
echo "\n<form method='post' name='form' action='" . $_SERVER['PHP_SELF'] . "'>";
echo "<table class='tab_cadre'><tr class='tab_bg_2'>";
echo "<td class='right'>" . __('Start date') . "</td><td>";
Html::showDateField("date1", array('value' => $_POST["date1"]));
echo "</td><td rowspan='2' class='center'>";
echo "<input type='submit' class='submit' name='submit' value=\"" . __s('Display report') . "\"></td>" . "</tr>\n";
echo "<tr class='tab_bg_2'><td class='right'>" . __('End date') . "</td><td>";
Html::showDateField("date2", array('value' => $_POST["date2"]));
echo "</td></tr>";
echo "</table>\n";
Html::closeForm();
$valeurtot = 0;
$valeurnettetot = 0;
$valeurnettegraphtot = array();
$valeurgraphtot = array();
/** Display an infocom report for items like consumables
 *
 * @param $itemtype  item type
 * @param $begin     begin date
 * @param $end       end date
**/
function display_infocoms_report($itemtype, $begin, $end)
{
Пример #4
0
 /**
  * Display command additional informations
  *
  * @param info
  * @param option
  * @param injectionClass
  *
  * @return nothing
  **/
 static function showAdditionalInformation(PluginDatainjectionInfo $info, $option = array(), $injectionClass, $values = array())
 {
     $name = "info[" . $option['linkfield'] . "]";
     if (isset($_SESSION['datainjection']['infos'][$option['linkfield']])) {
         $value = $_SESSION['datainjection']['infos'][$option['linkfield']];
     } else {
         $value = '';
     }
     switch ($option['displaytype']) {
         case 'text':
         case 'decimal':
             if (empty($value)) {
                 $value = isset($option['default']) ? $option['default'] : '';
             }
             echo "<input type='text' name='{$name}' value='{$value}'";
             if (isset($option['size'])) {
                 echo " size='" . $option['size'] . "'";
             }
             echo ">";
             break;
         case 'dropdown':
             if ($value == '') {
                 $value = 0;
             }
             Dropdown::show(getItemTypeForTable($option['table']), array('name' => $name, 'value' => $value));
             break;
         case 'bool':
             if ($value == '') {
                 $value = 0;
             }
             Dropdown::showYesNo($name, $value);
             break;
         case 'user':
             if ($value == '') {
                 $value = 0;
             }
             User::dropdown(array('name' => $name, 'value' => $value));
             break;
         case 'date':
             Html::showDateField($name, array('value' => $value));
             break;
         case 'multiline_text':
             echo "<textarea cols='45' rows='5' name='{$name}'>{$value}</textarea>";
             break;
         case 'dropdown_integer':
             $minvalue = isset($option['minvalue']) ? $option['minvalue'] : 0;
             $maxvalue = isset($option['maxvalue']) ? $option['maxvalue'] : 0;
             $step = isset($option['step']) ? $option['step'] : 1;
             $default = isset($option['-1']) ? array(-1 => $option['-1']) : array();
             Dropdown::showNumber($name, array('value' => $value, 'min' => $minvalue, 'max' => $maxvalue, 'step' => $step, 'toadd' => $default));
             break;
         case 'template':
             self::dropdownTemplates($name, $option['table']);
             break;
         case 'password':
             echo "<input type='password' name='{$name}' value='' size='20' autocomplete='off'>";
             break;
         default:
             if (method_exists($injectionClass, 'showAdditionalInformation')) {
                 //If type is not a standard type, must be treated by specific injection class
                 $injectionClass->showAdditionalInformation($info, $option);
             }
     }
     if ($info->isMandatory()) {
         echo "&nbsp;*";
     }
 }
Пример #5
0
 /**
  * Print the contract form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  *@return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td><td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('Contract type') . "</td><td >";
     ContractType::dropdown(array('value' => $this->fields["contracttypes_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _x('phone', 'Number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "num");
     echo "</td>";
     echo "<td colspan='2'></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Start date') . "</td>";
     echo "<td>";
     Html::showDateField("begin_date", array('value' => $this->fields["begin_date"]));
     echo "</td>";
     echo "<td>" . __('Initial contract period') . "</td><td>";
     Dropdown::showNumber("duration", array('value' => $this->fields["duration"], 'min' => 1, 'max' => 120, 'step' => 1, 'toadd' => array(0 => Dropdown::EMPTY_VALUE), 'unit' => 'month'));
     if (!empty($this->fields["begin_date"])) {
         echo " -> " . Infocom::getWarrantyExpir($this->fields["begin_date"], $this->fields["duration"], 0, true);
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Notice') . "</td><td>";
     Dropdown::showNumber("notice", array('value' => $this->fields["notice"], 'min' => 0, 'max' => 120, 'step' => 1, 'toadd' => array(), 'unit' => 'month'));
     if (!empty($this->fields["begin_date"]) && $this->fields["notice"] > 0) {
         echo " -> " . Infocom::getWarrantyExpir($this->fields["begin_date"], $this->fields["duration"], $this->fields["notice"], true);
     }
     echo "</td>";
     echo "<td>" . __('Account number') . "</td><td>";
     Html::autocompletionTextField($this, "accounting_number");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Contract renewal period') . "</td><td>";
     Dropdown::showNumber("periodicity", array('value' => $this->fields["periodicity"], 'min' => 12, 'max' => 60, 'step' => 12, 'toadd' => array(0 => Dropdown::EMPTY_VALUE, 1 => sprintf(_n('%d month', '%d months', 1), 1), 2 => sprintf(_n('%d month', '%d months', 2), 2), 3 => sprintf(_n('%d month', '%d months', 3), 3), 6 => sprintf(_n('%d month', '%d months', 6), 6)), 'unit' => 'month'));
     echo "</td>";
     echo "<td>" . __('Invoice period') . "</td>";
     echo "<td>";
     Dropdown::showNumber("billing", array('value' => $this->fields["billing"], 'min' => 12, 'max' => 60, 'step' => 12, 'toadd' => array(0 => Dropdown::EMPTY_VALUE, 1 => sprintf(_n('%d month', '%d months', 1), 1), 2 => sprintf(_n('%d month', '%d months', 2), 2), 3 => sprintf(_n('%d month', '%d months', 3), 3), 6 => sprintf(_n('%d month', '%d months', 6), 6)), 'unit' => 'month'));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Renewal') . "</td><td>";
     self::dropdownContractRenewal("renewal", $this->fields["renewal"]);
     echo "</td>";
     echo "<td>" . __('Max number of items') . "</td><td>";
     Dropdown::showNumber("max_links_allowed", array('value' => $this->fields["max_links_allowed"], 'min' => 1, 'max' => 200, 'step' => 1, 'toadd' => array(0 => __('Unlimited'))));
     echo "</td></tr>";
     if (Entity::getUsedConfig("use_contracts_alert", $this->fields["entities_id"])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Email alarms') . "</td>";
         echo "<td>";
         self::dropdownAlert(array('name' => "alert", 'value' => $this->fields["alert"]));
         Alert::displayLastAlert(__CLASS__, $ID);
         echo "</td>";
         echo "<td colspan='2'>&nbsp;</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'><td class='top'>" . __('Comments') . "</td>";
     echo "<td class='center' colspan='3'>";
     echo "<textarea cols='50' rows='4' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Support hours') . "</td>";
     echo "<td colspan='3'>&nbsp;</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('on week') . "</td>";
     echo "<td colspan='3'>";
     echo "<table width='100%'><tr><td width='20%'>&nbsp;</td>";
     echo "<td width='20%'>";
     echo "<span class='small_space'>" . __('Start') . "</span>";
     echo "</td><td width='20%'>";
     Dropdown::showHours("week_begin_hour", array('value' => $this->fields["week_begin_hour"]));
     echo "</td><td width='20%'>";
     echo "<span class='small_space'>" . __('End') . "</span></td><td width='20%'>";
     Dropdown::showHours("week_end_hour", array('value' => $this->fields["week_end_hour"]));
     echo "</td></tr></table>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('on Saturday') . "</td>";
     echo "<td colspan='3'>";
     echo "<table width='100%'><tr><td width='20%'>";
     Dropdown::showYesNo("use_saturday", $this->fields["use_saturday"]);
     echo "</td><td width='20%'>";
     echo "<span class='small_space'>" . __('Start') . "</span>";
     echo "</td><td width='20%'>";
     Dropdown::showHours("saturday_begin_hour", array('value' => $this->fields["saturday_begin_hour"]));
     echo "</td><td width='20%'>";
     echo "<span class='small_space'>" . __('End') . "</span>";
     echo "</td><td width='20%'>";
     Dropdown::showHours("saturday_end_hour", array('value' => $this->fields["saturday_end_hour"]));
     echo "</td></tr></table>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Sundays and holidays') . "</td>";
     echo "<td colspan='3'>";
     echo "<table width='100%'><tr><td width='20%'>";
     Dropdown::showYesNo("use_monday", $this->fields["use_monday"]);
     echo "</td><td width='20%'>";
     echo "<span class='small_space'>" . __('Start') . "</span>";
     echo "</td><td width='20%'>";
     Dropdown::showHours("monday_begin_hour", array('value' => $this->fields["monday_begin_hour"]));
     echo "</td><td width='20%'>";
     echo "<span class='small_space'>" . __('End') . "</span>";
     echo "</td><td width='20%'>";
     Dropdown::showHours("monday_end_hour", array('value' => $this->fields["monday_end_hour"]));
     echo "</td></tr></table>";
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
Пример #6
0
 /**
  * Show Infocom form for an item (not a standard showForm)
  *
  * @param $item                  CommonDBTM object
  * @param $withtemplate integer  template or basic item (default '')
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $CFG_GLPI;
     // Show Infocom or blank form
     if (!self::canView()) {
         return false;
     }
     if (!$item) {
         echo "<div class='spaced'>" . __('Requested item not found') . "</div>";
     } else {
         $date_tax = $CFG_GLPI["date_tax"];
         $dev_ID = $item->getField('id');
         $ic = new self();
         $option = "";
         if ($withtemplate == 2) {
             $option = " readonly ";
         }
         if (!strpos($_SERVER['PHP_SELF'], "infocoms-show") && in_array($item->getType(), array('CartridgeItem', 'ConsumableItem', 'Software'))) {
             echo "<div class='firstbloc center'>" . __('For this type of item, the financial and administrative information are only a model for the items which you should add.') . "</div>";
         }
         if (!$ic->getFromDBforDevice($item->getType(), $dev_ID)) {
             $input = array('itemtype' => $item->getType(), 'items_id' => $dev_ID, 'entities_id' => $item->getEntityID());
             if ($ic->can(-1, CREATE, $input) && $withtemplate != 2) {
                 echo "<div class='spaced b'>";
                 echo "<table class='tab_cadre_fixe'><tr class='tab_bg_1'><th>";
                 echo sprintf(__('%1$s - %2$s'), $item->getTypeName(1), $item->getName()) . "</th></tr>";
                 echo "<tr class='tab_bg_1'><td class='center'>";
                 Html::showSimpleForm($CFG_GLPI["root_doc"] . "/front/infocom.form.php", 'add', __('Enable the financial and administrative information'), array('itemtype' => $item->getType(), 'items_id' => $dev_ID));
                 echo "</td></tr></table></div>";
             }
         } else {
             // getFromDBforDevice
             $canedit = $ic->canEdit($ic->fields['id']) && $withtemplate != 2;
             echo "<div class='spaced'>";
             if ($canedit) {
                 echo "<form name='form_ic' method='post' action='" . $CFG_GLPI["root_doc"] . "/front/infocom.form.php'>";
             }
             echo "<table class='tab_cadre" . (!strpos($_SERVER['PHP_SELF'], "infocoms-show") ? "_fixe" : "") . "'>";
             echo "<tr><th colspan='4'>" . __('Financial and administrative information') . "</th></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Supplier') . "</td>";
             echo "<td>";
             if ($withtemplate == 2) {
                 echo Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]);
             } else {
                 Supplier::dropdown(array('value' => $ic->fields["suppliers_id"], 'entity' => $item->getEntityID(), 'width' => '70%'));
             }
             echo "</td>";
             if (Budget::canView()) {
                 echo "<td>" . __('Budget') . "</td><td >";
                 Budget::dropdown(array('value' => $ic->fields["budgets_id"], 'entity' => $item->getEntityID(), 'comments' => 1));
             } else {
                 echo "<td colspan='2'>";
             }
             echo "</td></tr>";
             // Can edit calendar ?
             $editcalendar = $withtemplate != 2;
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Order number') . "</td>";
             echo "<td >";
             Html::autocompletionTextField($ic, "order_number", array('option' => $option));
             echo "</td>";
             echo "<td>" . __('Order date') . "</td><td>";
             Html::showDateField("order_date", array('value' => $ic->fields["order_date"], 'maybeempty' => true, 'canedit' => $editcalendar));
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             $istemplate = '';
             if ($item->isTemplate() || in_array($item->getType(), array('CartridgeItem', 'ConsumableItem', 'Software'))) {
                 $istemplate = '*';
             }
             echo "<td>" . sprintf(__('%1$s%2$s'), __('Immobilization number'), $istemplate) . "</td>";
             echo "<td>";
             $objectName = autoName($ic->fields["immo_number"], "immo_number", $withtemplate == 2, 'Infocom', $item->getEntityID());
             Html::autocompletionTextField($ic, "immo_number", array('value' => $objectName, 'option' => $option));
             echo "</td>";
             echo "<td>" . __('Date of purchase') . "</td><td>";
             Html::showDateField("buy_date", array('value' => $ic->fields["buy_date"], 'maybeempty' => true, 'canedit' => $editcalendar));
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Invoice number') . "</td>";
             echo "<td>";
             Html::autocompletionTextField($ic, "bill", array('option' => $option));
             echo "</td>";
             echo "<td>" . __('Delivery date') . "</td><td>";
             Html::showDateField("delivery_date", array('value' => $ic->fields["delivery_date"], 'maybeempty' => true, 'canedit' => $editcalendar));
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Delivery form') . "</td><td>";
             Html::autocompletionTextField($ic, "delivery_number", array('option' => $option));
             echo "</td>";
             echo "<td>" . __('Startup date') . "</td><td>";
             Html::showDateField("use_date", array('value' => $ic->fields["use_date"], 'maybeempty' => true, 'canedit' => $editcalendar));
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . _x('price', 'Value') . "</td>";
             echo "<td><input type='text' name='value' {$option} value='" . Html::formatNumber($ic->fields["value"], true) . "' size='14'></td>";
             echo "<td>" . __('Date of last physical inventory') . "</td><td>";
             Html::showDateField("inventory_date", array('value' => $ic->fields["inventory_date"], 'maybeempty' => true, 'canedit' => $editcalendar));
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Warranty extension value') . "</td>";
             echo "<td><input type='text' {$option} name='warranty_value' value='" . Html::formatNumber($ic->fields["warranty_value"], true) . "' size='14'></td>";
             echo "<td rowspan='5'>" . __('Comments') . "</td>";
             echo "<td rowspan='5' class='middle'>";
             echo "<textarea cols='45' rows='9' name='comment' >" . $ic->fields["comment"];
             echo "</textarea></td></tr>\n";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Account net value') . "</td><td>";
             echo Html::formatNumber(self::Amort($ic->fields["sink_type"], $ic->fields["value"], $ic->fields["sink_time"], $ic->fields["sink_coeff"], $ic->fields["warranty_date"], $ic->fields["use_date"], $date_tax, "n"));
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Amortization type') . "</td><td >";
             if ($withtemplate == 2) {
                 echo self::getAmortTypeName($ic->fields["sink_type"]);
             } else {
                 self::dropdownAmortType("sink_type", $ic->fields["sink_type"]);
             }
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Amortization duration') . "</td><td>";
             if ($withtemplate == 2) {
                 printf(_n('%d year', '%d years', $ic->fields["sink_time"]), $ic->fields["sink_time"]);
             } else {
                 Dropdown::showNumber("sink_time", array('value' => $ic->fields["sink_time"], 'max' => 15, 'unit' => 'year'));
             }
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Amortization coefficient') . "</td>";
             echo "<td>";
             Html::autocompletionTextField($ic, "sink_coeff", array('size' => 14, 'option' => $option));
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             if (!in_array($item->getType(), array('Cartridge', 'CartridgeItem', 'Consumable', 'ConsumableItem', 'Software', 'SoftwareLicense'))) {
                 echo "<td>" . __('TCO (value + tracking cost)') . "</td><td>";
                 echo self::showTco($item->getField('ticket_tco'), $ic->fields["value"]);
             } else {
                 echo "<td colspan='2'>";
             }
             echo "</td>";
             if (!in_array($item->getType(), array('Cartridge', 'CartridgeItem', 'Consumable', 'ConsumableItem', 'Software', 'SoftwareLicense'))) {
                 echo "<td>" . __('Monthly TCO') . "</td><td>";
                 echo self::showTco($item->getField('ticket_tco'), $ic->fields["value"], $ic->fields["warranty_date"]);
             } else {
                 echo "<td colspan='2'>";
             }
             echo "</td></tr>";
             echo "<tr><th colspan='4'>" . __('Warranty information') . "</th></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Start date of warranty') . "</td><td>";
             Html::showDateField("warranty_date", array('value' => $ic->fields["warranty_date"], 'maybeempty' => true, 'canedit' => $editcalendar));
             echo "</td>";
             echo "<td>" . __('Warranty duration') . "</td><td>";
             if ($withtemplate == 2) {
                 // -1 = life
                 if ($ic->fields["warranty_duration"] == -1) {
                     _e('Lifelong');
                 } else {
                     printf(_n('%d month', '%d months', $ic->fields["warranty_duration"]), $ic->fields["warranty_duration"]);
                 }
             } else {
                 Dropdown::showNumber("warranty_duration", array('value' => $ic->fields["warranty_duration"], 'min' => 0, 'max' => 120, 'step' => 1, 'toadd' => array(-1 => __('Lifelong')), 'unit' => 'month'));
             }
             $tmpdat = self::getWarrantyExpir($ic->fields["warranty_date"], $ic->fields["warranty_duration"], 0, true);
             if ($tmpdat) {
                 echo "<span class='small_space'>" . sprintf(__('Valid to %s'), $tmpdat) . "</span>";
             }
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Warranty information') . "</td>";
             echo "<td >";
             Html::autocompletionTextField($ic, "warranty_info", array('option' => $option));
             echo "</td>";
             if ($CFG_GLPI['use_mailing']) {
                 echo "<td>" . __('Alarms on financial and administrative information') . "</td>";
                 echo "<td>";
                 self::dropdownAlert(array('name' => "alert", 'value' => $ic->fields["alert"]));
                 Alert::displayLastAlert('Infocom', $ic->fields['id']);
             } else {
                 echo "</td><td colspan='2'>";
             }
             echo "</td></tr>";
             if ($canedit) {
                 echo "<tr>";
                 echo "<td class='tab_bg_2 center' colspan='2'>";
                 echo "<input type='hidden' name='id' value='" . $ic->fields['id'] . "'>";
                 echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\"\n                      class='submit'>";
                 echo "</td>";
                 echo "<td class='tab_bg_2 center' colspan='2'>";
                 echo "<input type='submit' name='purge' value=\"" . _sx('button', 'Delete permanently') . "\"\n                      class='submit'>";
                 echo "</td></tr>";
                 echo "</table>";
                 Html::closeForm();
             } else {
                 echo "</table>";
             }
             echo "</div>";
         }
     }
 }
Пример #7
0
 /**
  * Print the contact form
  *
  * @param $ID        integer ID of the item
  * @param $options   array of possible options:
  *     - target for the Form
  *     - withtemplate : template or basic item
  *
  * @return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     $rowspan = 3;
     if ($ID > 0) {
         $rowspan++;
     }
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     Dropdown::show('BudgetType', array('value' => $this->fields['budgettypes_id']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _x('price', 'Value') . "</td>";
     echo "<td><input type='text' name='value' size='14'\n                 value='" . Html::formatNumber($this->fields["value"], true) . "'></td>";
     echo "<td rowspan='{$rowspan}' class='middle right'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='{$rowspan}'>" . "<textarea cols='45' rows='4' name='comment' >" . $this->fields["comment"] . "</textarea>" . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Start date') . "</td>";
     echo "<td>";
     Html::showDateField("begin_date", array('value' => $this->fields["begin_date"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('End date') . "</td>";
     echo "<td>";
     Html::showDateField("end_date", array('value' => $this->fields["end_date"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
Пример #8
0
 /**
  * Print the contract cost form
  *
  * @param $ID        integer  ID of the item
  * @param $options   array    options used
  **/
 function showForm($ID, $options = array())
 {
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $options['contracts_id'] = $options['parent']->getField('id');
         $this->check(-1, CREATE, $options);
         $this->initBasedOnPrevious();
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     echo "<input type='hidden' name='contracts_id' value='" . $this->fields['contracts_id'] . "'>";
     Html::autocompletionTextField($this, 'name');
     echo "</td>";
     echo "<td>" . __('Cost') . "</td>";
     echo "<td>";
     echo "<input type='text' name='cost' value='" . Html::formatNumber($this->fields["cost"], true) . "'\n             size='14'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Begin date') . "</td>";
     echo "<td>";
     Html::showDateField("begin_date", array('value' => $this->fields['begin_date']));
     echo "</td>";
     $rowspan = 3;
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}' class='middle'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'><td>" . __('End date') . "</td>";
     echo "<td>";
     Html::showDateField("end_date", array('value' => $this->fields['end_date']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Budget') . "</td>";
     echo "<td>";
     Budget::dropdown(array('value' => $this->fields["budgets_id"]));
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
Пример #9
0
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
$AJAX_INCLUDE = 1;
include '../inc/includes.php';
// Send UTF8 Headers
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();
if (isset($_POST['value']) && strcmp($_POST['value'], '0') == 0) {
    if ($_POST['withtime']) {
        Html::showDateTimeField($_POST['name'], array('value' => $_POST['specificvalue']));
    } else {
        Html::showDateField($_POST['name'], array('value' => $_POST['specificvalue']));
    }
} else {
    echo "<input type='hidden' name='" . $_POST['name'] . "' value='" . $_POST['value'] . "'>";
}
Пример #10
0
 /**
  * Show the availability of a user
  *
  * @since version 0.83
  *
  * @param $params   array of params
  *    must contain :
  *          - begin: begin date to check (default '')
  *          - end: end date to check (default '')
  *          - itemtype : User or Object type (Ticket...)
  *          - foreign key field of the itemtype to define which item to used
  *    optional :
  *          - limitto : limit display to a specific user
  *
  * @return Nothing (display function)
  **/
 static function checkAvailability($params = array())
 {
     global $CFG_GLPI, $DB;
     if (!isset($params['itemtype'])) {
         return false;
     }
     if (!($item = getItemForItemtype($params['itemtype']))) {
         return false;
     }
     if (!isset($params[$item->getForeignKeyField()]) || !$item->getFromDB($params[$item->getForeignKeyField()])) {
         return false;
     }
     // No limit by default
     if (!isset($params['limitto'])) {
         $params['limitto'] = 0;
     }
     if (isset($params['begin']) && !empty($params['begin'])) {
         $begin = $params['begin'];
     } else {
         $begin = date("Y-m-d");
     }
     if (isset($params['end']) && !empty($params['end'])) {
         $end = $params['end'];
     } else {
         $end = date("Y-m-d");
     }
     if ($end < $begin) {
         $end = $begin;
     }
     $realbegin = $begin . " " . $CFG_GLPI["planning_begin"];
     $realend = $end . " " . $CFG_GLPI["planning_end"];
     $users = array();
     switch ($item->getType()) {
         case 'User':
             $users[$item->getID()] = $item->getName();
             break;
         default:
             if (Toolbox::is_a($item, 'CommonITILObject')) {
                 foreach ($item->getUsers(CommonITILActor::ASSIGN) as $data) {
                     $users[$data['users_id']] = getUserName($data['users_id']);
                 }
                 foreach ($item->getGroups(CommonITILActor::ASSIGN) as $data) {
                     foreach (Group_User::getGroupUsers($data['groups_id']) as $data2) {
                         $users[$data2['id']] = formatUserName($data2["id"], $data2["name"], $data2["realname"], $data2["firstname"]);
                     }
                 }
             }
             break;
     }
     asort($users);
     // Use get method to check availability
     echo "<div class='center'><form method='GET' name='form' action='planning.php'>\n";
     echo "<table class='tab_cadre_fixe'>";
     $colspan = 5;
     if (count($users) > 1) {
         $colspan++;
     }
     echo "<tr class='tab_bg_1'><th colspan='{$colspan}'>" . __('Availability') . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Start') . "</td>\n";
     echo "<td>";
     Html::showDateField("begin", array('value' => $begin, 'maybeempty' => false));
     echo "</td>\n";
     echo "<td>" . __('End') . "</td>\n";
     echo "<td>";
     Html::showDateField("end", array('value' => $end, 'maybeempty' => false));
     echo "</td>\n";
     if (count($users) > 1) {
         echo "<td width='40%'>";
         $data = array(0 => __('All'));
         $data += $users;
         Dropdown::showFromArray('limitto', $data, array('width' => '100%', 'value' => $params['limitto']));
         echo "</td>";
     }
     echo "<td class='center'>";
     echo "<input type='hidden' name='" . $item->getForeignKeyField() . "' value=\"" . $item->getID() . "\">";
     echo "<input type='hidden' name='itemtype' value=\"" . $item->getType() . "\">";
     echo "<input type='submit' class='submit' name='checkavailability' value=\"" . _sx('button', 'Search') . "\">";
     echo "</td>\n";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>\n";
     if ($params['limitto'] > 0 && isset($users[$params['limitto']])) {
         $displayuser[$params['limitto']] = $users[$params['limitto']];
     } else {
         $displayuser = $users;
     }
     if (count($displayuser)) {
         foreach ($displayuser as $who => $whoname) {
             $params = array('who' => $who, 'who_group' => 0, 'begin' => $realbegin, 'end' => $realend);
             $interv = array();
             foreach ($CFG_GLPI['planning_types'] as $itemtype) {
                 $interv = array_merge($interv, $itemtype::populatePlanning($params));
             }
             // Print Headers
             echo "<br><div class='center'><table class='tab_cadre_fixe'>";
             $colnumber = 1;
             $plan_begin = explode(":", $CFG_GLPI["planning_begin"]);
             $plan_end = explode(":", $CFG_GLPI["planning_end"]);
             $begin_hour = intval($plan_begin[0]);
             $end_hour = intval($plan_end[0]);
             if ($plan_end[1] != 0) {
                 $end_hour++;
             }
             $colsize = floor((100 - 15) / ($end_hour - $begin_hour));
             $timeheader = '';
             for ($i = $begin_hour; $i < $end_hour; $i++) {
                 $from = ($i < 10 ? '0' : '') . $i;
                 $timeheader .= "<th width='{$colsize}%' colspan='4'>" . $from . ":00</th>";
                 $colnumber += 4;
             }
             // Print Headers
             echo "<tr class='tab_bg_1'><th colspan='{$colnumber}'>";
             echo $whoname;
             echo "</th></tr>";
             echo "<tr class='tab_bg_1'><th width='15%'>&nbsp;</th>";
             echo $timeheader;
             echo "</tr>";
             $day_begin = strtotime($realbegin);
             $day_end = strtotime($realend);
             for ($time = $day_begin; $time < $day_end; $time += DAY_TIMESTAMP) {
                 $current_day = date('Y-m-d', $time);
                 echo "<tr><th>" . Html::convDate($current_day) . "</th>";
                 $begin_quarter = $begin_hour * 4;
                 $end_quarter = $end_hour * 4;
                 for ($i = $begin_quarter; $i < $end_quarter; $i++) {
                     $begin_time = date("Y-m-d H:i:s", strtotime($current_day) + $i * HOUR_TIMESTAMP / 4);
                     $end_time = date("Y-m-d H:i:s", strtotime($current_day) + ($i + 1) * HOUR_TIMESTAMP / 4);
                     // Init activity interval
                     $begin_act = $end_time;
                     $end_act = $begin_time;
                     reset($interv);
                     while ($data = current($interv)) {
                         if ($data["begin"] >= $begin_time && $data["end"] <= $end_time) {
                             // In
                             if ($begin_act > $data["begin"]) {
                                 $begin_act = $data["begin"];
                             }
                             if ($end_act < $data["end"]) {
                                 $end_act = $data["end"];
                             }
                             unset($interv[key($interv)]);
                         } else {
                             if ($data["begin"] < $begin_time && $data["end"] > $end_time) {
                                 // Through
                                 $begin_act = $begin_time;
                                 $end_act = $end_time;
                                 next($interv);
                             } else {
                                 if ($data["begin"] >= $begin_time && $data["begin"] < $end_time) {
                                     // Begin
                                     if ($begin_act > $data["begin"]) {
                                         $begin_act = $data["begin"];
                                     }
                                     $end_act = $end_time;
                                     next($interv);
                                 } else {
                                     if ($data["end"] > $begin_time && $data["end"] <= $end_time) {
                                         //End
                                         $begin_act = $begin_time;
                                         if ($end_act < $data["end"]) {
                                             $end_act = $data["end"];
                                         }
                                         unset($interv[key($interv)]);
                                     } else {
                                         // Defautl case
                                         next($interv);
                                     }
                                 }
                             }
                         }
                     }
                     if ($begin_act < $end_act) {
                         if ($begin_act <= $begin_time && $end_act >= $end_time) {
                             // Activity in quarter
                             echo "<td class='notavailable'>&nbsp;</td>";
                         } else {
                             // Not all the quarter
                             if ($begin_act <= $begin_time) {
                                 echo "<td class='partialavailableend'>&nbsp;</td>";
                             } else {
                                 echo "<td class='partialavailablebegin'>&nbsp;</td>";
                             }
                         }
                     } else {
                         // No activity
                         echo "<td class='available'>&nbsp;</td>";
                     }
                 }
                 echo "</tr>";
             }
             echo "<tr class='tab_bg_1'><td colspan='{$colnumber}'>&nbsp;</td></tr>";
             echo "</table></div>";
         }
     }
     echo "<div><table class='tab_cadre'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Caption') . "</th>";
     echo "<td class='available' colspan=8>" . __('Available') . "</td>";
     echo "<td class='notavailable' colspan=8>" . __('Unavailable') . "</td>";
     echo "</tr>";
     echo "</table></div>";
 }
Пример #11
0
 /**
  * Print the item cost form
  *
  * @param $ID        integer  ID of the item
  * @param $options   array    options used
  **/
 function showForm($ID, $options = array())
 {
     if (isset($options['parent']) && !empty($options['parent'])) {
         $item = $options['parent'];
     }
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $options[static::$items_id] = $item->getField('id');
         $this->check(-1, CREATE, $options);
         $this->initBasedOnPrevious();
     }
     if ($ID > 0) {
         $items_id = $this->fields[static::$items_id];
     } else {
         $items_id = $options['parent']->fields["id"];
     }
     $item = new static::$itemtype();
     if (!$item->getFromDB($items_id)) {
         return false;
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     echo "<input type='hidden' name='" . static::$items_id . "' value='" . $item->fields['id'] . "'>";
     Html::autocompletionTextField($this, 'name');
     echo "</td>";
     echo "<td>" . __('Begin date') . "</td>";
     echo "<td>";
     Html::showDateField("begin_date", array('value' => $this->fields['begin_date']));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Duration') . "</td>";
     echo "<td>";
     Dropdown::showTimeStamp('actiontime', array('value' => $this->fields['actiontime'], 'addfirstminutes' => true));
     echo "</td>";
     echo "<td>" . __('End date') . "</td>";
     echo "<td>";
     Html::showDateField("end_date", array('value' => $this->fields['end_date']));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Time cost') . "</td><td>";
     echo "<input type='text' size='15' name='cost_time' value='" . Html::formatNumber($this->fields["cost_time"], true) . "'>";
     echo "</td>";
     $rowspan = 4;
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}' class='middle'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Fixed cost') . "</td><td>";
     echo "<input type='text' size='15' name='cost_fixed' value='" . Html::formatNumber($this->fields["cost_fixed"], true) . "'>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Material cost') . "</td><td>";
     echo "<input type='text' size='15' name='cost_material' value='" . Html::formatNumber($this->fields["cost_material"], true) . "'>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Budget') . "</td>";
     echo "<td>";
     Budget::dropdown(array('value' => $this->fields["budgets_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
Пример #12
0
            echo "<tr><td>" . __('End date') . '</td><td>';
            Html::showDateField('periodicity[end]', array('value' => $_POST['end']));
            echo "</td></tr>";
            break;
        case 'week':
            echo "<tr><td>" . __('End date') . '</td><td>';
            Html::showDateField('periodicity[end]', array('value' => $_POST['end']));
            echo "</td></tr></table>";
            echo "<table class='tab_glpi'>";
            echo "<tr class='center'><td>&nbsp;</td>";
            $days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
            foreach ($days as $day) {
                echo "<th>" . __($day) . "</th>";
            }
            echo "</tr><tr class='center'><td>" . __('By day') . '</td>';
            foreach ($days as $day) {
                echo "<td><input type='checkbox' name='periodicity[days][{$day}]'></td>";
            }
            echo "</tr>";
            break;
        case 'month':
            echo "<tr><td colspan='2'>";
            $values = array('date' => __('Each month, same date'), 'day' => __('Each month, same day of week'));
            Dropdown::showFromArray('periodicity[subtype]', $values);
            echo "</td></tr>";
            echo "<tr><td>" . __('End date') . '</td><td>';
            Html::showDateField('periodicity[end]', array('value' => $_POST['end']));
            echo "</td></tr>";
    }
    echo '</table>';
}
Пример #13
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!$this->isNewID($ID)) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check(-1, CREATE);
     }
     $this->showFormHeader($options);
     $fields = $this->getAdditionalFields();
     $nb = count($fields);
     echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>";
     echo "<td>";
     if ($this instanceof CommonDevice) {
         // Awfull hack for CommonDevice where name is designation
         Html::autocompletionTextField($this, "designation");
     } else {
         Html::autocompletionTextField($this, "name");
     }
     echo "</td>";
     echo "<td rowspan='" . ($nb + 1) . "'>" . __('Comments') . "</td>";
     echo "<td rowspan='" . ($nb + 1) . "'>\n            <textarea cols='45' rows='" . ($nb + 2) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     foreach ($fields as $field) {
         if ($field['name'] == 'entities_id' && $ID == 0 && !$this->isNewID($ID)) {
             // No display for root entity
             echo "<tr class='tab_bg_1'><td colspan='2'>&nbsp;</td></tr>";
             break;
         }
         if (!isset($field['type'])) {
             $field['type'] = '';
         }
         if ($field['name'] == 'header') {
             echo "<tr class='tab_bg_1'><th colspan='2'>" . $field['label'] . "</th></tr>";
             continue;
         }
         echo "<tr class='tab_bg_1'><td>" . $field['label'];
         if (isset($field['comment']) && !empty($field['comment'])) {
             echo "&nbsp;";
             Html::showToolTip($field['comment']);
         }
         echo "</td><td>";
         switch ($field['type']) {
             case 'UserDropdown':
                 $param = array('name' => $field['name'], 'value' => $this->fields[$field['name']], 'right' => 'interface', 'entity' => $this->fields["entities_id"]);
                 if (isset($field['right'])) {
                     $params['right'] = $field['right'];
                 }
                 User::dropdown($param);
                 break;
             case 'dropdownValue':
                 $params = array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $this->getEntityID());
                 if (isset($field['condition'])) {
                     $params['condition'] = $field['condition'];
                 }
                 Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField($field['name'])), $params);
                 break;
             case 'text':
                 Html::autocompletionTextField($this, $field['name']);
                 break;
             case 'textarea':
                 $cols = 40;
                 $rows = 3;
                 if (isset($field['rows'])) {
                     $rows = $field['rows'];
                 }
                 if (isset($field['cols'])) {
                     $cols = $field['cols'];
                 }
                 echo "<textarea name='" . $field['name'] . "' cols='{$cols}' rows='{$rows}'>" . $this->fields[$field['name']] . "</textarea >";
                 break;
             case 'integer':
                 Dropdown::showNumber($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'timestamp':
                 $param = array('value' => $this->fields[$field['name']]);
                 if (isset($field['min'])) {
                     $param['min'] = $field['min'];
                 }
                 if (isset($field['max'])) {
                     $param['max'] = $field['max'];
                 }
                 if (isset($field['step'])) {
                     $param['step'] = $field['step'];
                 }
                 Dropdown::showTimeStamp($field['name'], $param);
                 break;
             case 'parent':
                 if ($field['name'] == 'entities_id') {
                     $restrict = -1;
                 } else {
                     $restrict = $this->getEntityID();
                 }
                 Dropdown::show(getItemTypeForTable($this->getTable()), array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $restrict, 'used' => $ID > 0 ? getSonsOf($this->getTable(), $ID) : array()));
                 break;
             case 'icon':
                 Dropdown::dropdownIcons($field['name'], $this->fields[$field['name']], GLPI_ROOT . "/pics/icones");
                 if (!empty($this->fields[$field['name']])) {
                     echo "&nbsp;<img style='vertical-align:middle;' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $this->fields[$field['name']] . "'>";
                 }
                 break;
             case 'bool':
                 Dropdown::showYesNo($field['name'], $this->fields[$field['name']]);
                 break;
             case 'color':
                 Html::showColorField($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'date':
                 Html::showDateField($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'datetime':
                 Html::showDateTimeField($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'password':
                 echo "<input type='password' name='password' value='' size='20' autocomplete='off'>";
                 break;
             default:
                 $this->displaySpecificTypeField($ID, $field);
                 break;
         }
         if (isset($field['unit'])) {
             echo "&nbsp;" . $field['unit'];
         }
         echo "</td></tr>\n";
     }
     if (isset($this->fields['is_protected']) && $this->fields['is_protected']) {
         $options['candel'] = false;
     }
     if (isset($_REQUEST['_in_modal'])) {
         echo "<input type='hidden' name='_in_modal' value='1'>";
     }
     $this->showFormButtons($options);
     return true;
 }
Пример #14
0
 /**
  * Select a field using standard system
  *
  * @since version 0.83
  *
  * @param $field_id_or_search_options  integer/string/array id of the search option field
  *                                                             or field name
  *                                                             or search option array
  * @param $name                        string               name of the select (if empty use linkfield)
  *                                                          (default '')
  * @param $values                                           mixed default value to display
  *                                                          (default '')
  * @param $options                     array                of possible options:
  * Parameters which could be used in options array :
  *    - comments : boolean / is the comments displayed near the value (default false)
  *    - any others options passed to specific display method
  *
  * @return return the string to display
  **/
 function getValueToSelect($field_id_or_search_options, $name = '', $values = '', $options = array())
 {
     global $CFG_GLPI;
     $param['comments'] = false;
     $param['html'] = false;
     foreach ($param as $key => $val) {
         if (!isset($options[$key])) {
             $options[$key] = $val;
         }
     }
     $searchoptions = array();
     if (is_array($field_id_or_search_options)) {
         $searchoptions = $field_id_or_search_options;
     } else {
         $searchopt = $this->getSearchOptions();
         // Get if id of search option is passed
         if (is_numeric($field_id_or_search_options)) {
             if (isset($searchopt[$field_id_or_search_options])) {
                 $searchoptions = $searchopt[$field_id_or_search_options];
             }
         } else {
             // Get if field name is passed
             $searchoptions = $this->getSearchOptionByField('field', $field_id_or_search_options, $this->getTable());
         }
     }
     if (count($searchoptions)) {
         $field = $searchoptions['field'];
         // Normalize option
         if (is_array($values)) {
             $value = $values[$field];
         } else {
             $value = $values;
             $values = array($field => $value);
         }
         if (empty($name)) {
             $name = $searchoptions['linkfield'];
         }
         // If not set : set to specific
         if (!isset($searchoptions['datatype'])) {
             $searchoptions['datatype'] = 'specific';
         }
         $options['display'] = false;
         $unit = '';
         if (isset($searchoptions['unit'])) {
             $unit = $searchoptions['unit'];
         }
         if (isset($options[$searchoptions['table'] . '.' . $searchoptions['field']])) {
             $options = array_merge($options, $options[$searchoptions['table'] . '.' . $searchoptions['field']]);
         }
         switch ($searchoptions['datatype']) {
             case "count":
             case "number":
             case "integer":
                 $copytooption = array('min', 'max', 'step', 'toadd', 'unit');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Dropdown::showNumber($name, $options);
             case "decimal":
             case "mac":
             case "ip":
             case "string":
             case "email":
             case "weblink":
                 $this->fields[$name] = $value;
                 return Html::autocompletionTextField($this, $name, $options);
             case "text":
                 $out = '';
                 if (isset($searchoptions['htmltext']) && $searchoptions['htmltext']) {
                     $out = Html::initEditorSystem($name, '', false);
                 }
                 return $out . "<textarea cols='45' rows='5' name='{$name}'>{$value}</textarea>";
             case "bool":
                 return Dropdown::showYesNo($name, $value, -1, $options);
             case "color":
                 return Html::showColorField($name, $options);
             case "date":
             case "date_delay":
                 if (isset($options['relative_dates']) && $options['relative_dates']) {
                     if (isset($searchoptions['maybefuture']) && $searchoptions['maybefuture']) {
                         $options['with_future'] = true;
                     }
                     return Html::showGenericDateTimeSearch($name, $value, $options);
                 }
                 $copytooption = array('min', 'max', 'maybeempty', 'showyear');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Html::showDateField($name, $options);
             case "datetime":
                 if (isset($options['relative_dates']) && $options['relative_dates']) {
                     if (isset($searchoptions['maybefuture']) && $searchoptions['maybefuture']) {
                         $options['with_future'] = true;
                     }
                     $options['with_time'] = true;
                     return Html::showGenericDateTimeSearch($name, $value, $options);
                 }
                 $copytooption = array('mindate', 'maxdate', 'mintime', 'maxtime', 'maybeempty', 'timestep');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Html::showDateTimeField($name, $options);
             case "timestamp":
                 $copytooption = array('addfirstminutes', 'emptylabel', 'inhours', 'max', 'min', 'step', 'toadd', 'display_emptychoice');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Dropdown::showTimeStamp($name, $options);
             case "itemlink":
                 // Do not use dropdown if wanted to select string value instead of ID
                 if (isset($options['itemlink_as_string']) && $options['itemlink_as_string']) {
                     break;
                 }
             case "dropdown":
                 $copytooption = array('condition', 'displaywith', 'emptylabel', 'right', 'toadd');
                 $options['name'] = $name;
                 $options['value'] = $value;
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 if (!isset($options['entity'])) {
                     $options['entity'] = $_SESSION['glpiactiveentities'];
                 }
                 $itemtype = getItemTypeForTable($searchoptions['table']);
                 return $itemtype::dropdown($options);
             case "right":
                 return Profile::dropdownRights(Profile::getRightsFor($searchoptions['rightclass']), $name, $value, array('multiple' => false, 'display' => false));
             case "itemtypename":
                 if (isset($searchoptions['itemtype_list'])) {
                     $options['types'] = $CFG_GLPI[$searchoptions['itemtype_list']];
                 }
                 $copytooption = array('types');
                 $options['value'] = $value;
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 if (isset($options['types'])) {
                     return Dropdown::showItemTypes($name, $options['types'], $options);
                 }
                 return false;
             case "language":
                 $copytooption = array('emptylabel', 'display_emptychoice');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Dropdown::showLanguages($name, $options);
         }
         // Get specific display if available
         $itemtype = getItemTypeForTable($searchoptions['table']);
         if ($item = getItemForItemtype($itemtype)) {
             $specific = $item->getSpecificValueToSelect($searchoptions['field'], $name, $values, $options);
             if (strlen($specific)) {
                 return $specific;
             }
         }
     }
     // default case field text
     $this->fields[$name] = $value;
     return Html::autocompletionTextField($this, $name, $options);
 }
Пример #15
0
 /**
  * Print the Software / license form
  *
  * @param $ID        integer  Id of the version or the template to print
  * @param $options   array    of possible options:
  *     - target form target
  *     - softwares_id ID of the software for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $softwares_id = -1;
     if (isset($options['softwares_id'])) {
         $softwares_id = $options['softwares_id'];
     }
     if ($ID < 0) {
         // Create item
         $this->fields['softwares_id'] = $softwares_id;
         $this->fields['number'] = 1;
         $soft = new Software();
         if ($soft->getFromDB($softwares_id) && in_array($_SESSION['glpiactive_entity'], getAncestorsOf('glpi_entities', $soft->getEntityID()))) {
             $options['entities_id'] = $soft->getEntityID();
         }
     }
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . Software::getTypeName(1) . "</td>";
     echo "<td>";
     if ($ID > 0) {
         $softwares_id = $this->fields["softwares_id"];
     } else {
         echo "<input type='hidden' name='softwares_id' value='{$softwares_id}'>";
     }
     echo "<a href='software.form.php?id=" . $softwares_id . "'>" . Dropdown::getDropdownName("glpi_softwares", $softwares_id) . "</a>";
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     SoftwareLicenseType::dropdown(array('value' => $this->fields["softwarelicensetypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Purchase version') . "</td>";
     echo "<td>";
     SoftwareVersion::dropdown(array('name' => "softwareversions_id_buy", 'softwares_id' => $this->fields["softwares_id"], 'value' => $this->fields["softwareversions_id_buy"]));
     echo "</td>";
     echo "<td>" . __('Inventory number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "otherserial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Version in use') . "</td>";
     echo "<td>";
     SoftwareVersion::dropdown(array('name' => "softwareversions_id_use", 'softwares_id' => $this->fields["softwares_id"], 'value' => $this->fields["softwareversions_id_use"]));
     echo "</td>";
     echo "<td rowspan='" . ($ID > 0 ? '4' : '3') . "' class='middle'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='" . ($ID > 0 ? '4' : '3') . "'>";
     echo "<textarea cols='45' rows='5' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _x('quantity', 'Number') . "</td>";
     echo "<td>";
     Dropdown::showNumber("number", array('value' => $this->fields["number"], 'min' => 1, 'max' => 10000, 'step' => 1, 'toadd' => array(-1 => __('Unlimited'))));
     if ($ID > 0) {
         echo "&nbsp;";
         if ($this->fields['is_valid']) {
             echo "<span class='green'>" . _x('adjective', 'Valid') . '<span>';
         } else {
             echo "<span class='red'>" . _x('adjective', 'Invalid') . '<span>';
         }
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Expiration') . "</td>";
     echo "<td>";
     Html::showDateField('expire', array('value' => $this->fields["expire"]));
     if ($ID && is_null($this->fields["expire"])) {
         echo "<br>" . __('Never expire') . "&nbsp;";
         Html::showToolTip(__('On search engine, use "Expiration contains NULL" to search licenses with no expiration date'));
     }
     Alert::displayLastAlert('SoftwareLicense', $ID);
     echo "</td></tr>\n";
     if ($ID > 0) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Last update') . "</td>";
         echo "<td>" . ($this->fields["date_mod"] ? Html::convDateTime($this->fields["date_mod"]) : __('Never'));
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
Пример #16
0
 /** form for Cartridge
  *
  * @since version 0.84
  *
  * @param $ID      integer  Id of the cartridge
  * @param $options array    of possible options:
  *     - parent Object : the printers where the cartridge is used
  **/
 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI;
     if (isset($options['parent']) && !empty($options['parent'])) {
         $printer = $options['parent'];
     }
     if (!$this->getFromDB($ID)) {
         return false;
     }
     $printer = new Printer();
     $printer->check($this->getField('printers_id'), UPDATE);
     $cartitem = new CartridgeItem();
     $cartitem->getFromDB($this->getField('cartridgeitems_id'));
     $is_old = !empty($this->fields['date_out']);
     $is_used = !empty($this->fields['date_use']);
     $options['colspan'] = 2;
     $options['candel'] = false;
     // Do not permit delete here
     $options['canedit'] = $is_used;
     // Do not permit edit if cart is not used
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Printer', 'Printers', 1) . "</td><td>";
     echo $printer->getLink();
     echo "<input type='hidden' name='printers_id' value='" . $this->getField('printers_id') . "'>\n";
     echo "<input type='hidden' name='cartridgeitems_id' value='" . $this->getField('cartridgeitems_id') . "'>\n";
     echo "</td>\n";
     echo "<td>" . _n('Cartridge model', 'Cartridge models', 1) . "</td>";
     echo "<td>" . $cartitem->getLink() . "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Add date') . "</td>";
     echo "<td>" . Html::convDate($this->fields["date_in"]) . "</td>";
     echo "<td>" . __('Use date') . "</td><td>";
     if ($is_used && !$is_old) {
         Html::showDateField("date_use", array('value' => $this->fields["date_use"], 'maybeempty' => false, 'canedit' => true, 'min' => $this->fields["date_in"]));
     } else {
         echo Html::convDate($this->fields["date_use"]);
     }
     echo "</td></tr>\n";
     if ($is_old) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('End date') . "</td><td>";
         Html::showDateField("date_out", array('value' => $this->fields["date_out"], 'maybeempty' => false, 'canedit' => true, 'min' => $this->fields["date_use"]));
         echo "</td>";
         echo "<td>" . __('Printer counter') . "</td><td>";
         echo "<input type='text' name='pages' value=\"" . $this->fields['pages'] . "\">";
         echo "</td></tr>\n";
     }
     $this->showFormButtons($options);
     return true;
 }
 /**
  * Print the contact form
  *
  * @param $ID        integer ID of the item
  * @param $options   array of possible options:
  *     - target for the Form
  *     - withtemplate : template or basic item
  *
  * @return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     $rowspan = 4;
     if ($ID > 0) {
         $rowspan++;
     }
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td rowspan='{$rowspan}' class='middle right'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='{$rowspan}'>" . "<textarea cols='45' rows='4' name='comment' class='form-control' >" . $this->fields["comment"] . "</textarea>" . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _x('price', 'Value') . "</td>";
     echo "<td><input type='text' name='value' size='14' class='form-control'\n                 value='" . Html::formatNumber($this->fields["value"], true) . "'></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Start date') . "</td>";
     echo "<td>";
     Html::showDateField("begin_date", array('value' => $this->fields["begin_date"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('End date') . "</td>";
     echo "<td>";
     Html::showDateField("end_date", array('value' => $this->fields["end_date"]));
     echo "</td></tr>";
     if ($ID > 0) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Last update') . "</td>";
         echo "<td>";
         echo $this->fields["date_mod"] ? Html::convDateTime($this->fields["date_mod"]) : __('Never');
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
Пример #18
0
 /**
  * Display form for antivirus
  *
  * @param $ID                id of the antivirus
  * @param $options array
  *
  * @return bool TRUE if form is ok
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!Session::haveRight("computer", UPDATE)) {
         return false;
     }
     $comp = new Computer();
     if ($ID > 0) {
         $this->check($ID, READ);
         $comp->getFromDB($this->fields['computers_id']);
     } else {
         $this->check(-1, CREATE, $options);
         $comp->getFromDB($options['computers_id']);
     }
     $this->showFormHeader($options);
     if ($this->isNewID($ID)) {
         echo "<input type='hidden' name='computers_id' value='" . $options['computers_id'] . "'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Computer') . "</td>";
     echo "<td>" . $comp->getLink() . "</td>";
     if (Plugin::haveImport()) {
         echo "<td>" . __('Automatic inventory') . "</td>";
         echo "<td>";
         if ($ID && $this->fields['is_dynamic']) {
             Plugin::doHook("autoinventory_information", $this);
         } else {
             _e('No');
         }
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('Active') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Dropdown::show('Manufacturer', array('value' => $this->fields["manufacturers_id"]));
     echo "</td>";
     echo "<td>" . __('Up to date') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('is_uptodate', $this->fields['is_uptodate']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Antivirus version') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "antivirus_version");
     echo "</td>";
     echo "<td>" . __('Signature database version') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "signature_version");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Expiration date') . "</td>";
     echo "<td>";
     Html::showDateField("date_expiration", array('value' => $this->fields['date_expiration']));
     echo "</td>";
     echo "<td colspan='2'></td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
Пример #19
0
 /**
  * Print the Software / license form
  *
  * @param $ID        integer  Id of the version or the template to print
  * @param $options   array    of possible options:
  *     - target form target
  *     - softwares_id ID of the software for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $softwares_id = -1;
     if (isset($options['softwares_id'])) {
         $softwares_id = $options['softwares_id'];
     }
     if ($ID < 0) {
         // Create item
         $this->fields['softwares_id'] = $softwares_id;
         $this->fields['number'] = 1;
         $soft = new Software();
         if ($soft->getFromDB($softwares_id) && in_array($_SESSION['glpiactive_entity'], getAncestorsOf('glpi_entities', $soft->getEntityID()))) {
             $options['entities_id'] = $soft->getEntityID();
         }
     }
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     // Restore saved value or override with page parameter
     if (!isset($options['template_preview'])) {
         if (isset($_REQUEST)) {
             $saved = Html::cleanPostForTextArea($_REQUEST);
         }
     }
     foreach ($this->fields as $name => $value) {
         if (isset($saved[$name]) && empty($this->fields[$name])) {
             $this->fields[$name] = $saved[$name];
         }
     }
     echo "<input type='hidden' name='withtemplate' value='" . $options['withtemplate'] . "'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . Software::getTypeName(1) . "</td>";
     echo "<td>";
     if ($ID > 0) {
         $softwares_id = $this->fields["softwares_id"];
         echo "<input type='hidden' name='softwares_id' value='{$softwares_id}'>";
         echo "<a href='software.form.php?id=" . $softwares_id . "'>" . Dropdown::getDropdownName("glpi_softwares", $softwares_id) . "</a>";
     } else {
         Dropdown::show('Software', array('condition' => "`is_template`='0' AND `is_deleted`='0'", 'entity' => $_SESSION['glpiactive_entity'], 'entity_sons' => $_SESSION['glpiactive_entity_recursive'], 'on_change' => 'this.form.submit()', 'value' => $softwares_id));
     }
     echo "</td>";
     echo "<td colspan='2'>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_softwarelicense`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td><td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     SoftwareLicenseType::dropdown(array('value' => $this->fields["softwarelicensetypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Publisher') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td >" . __('User') . "</td>";
     echo "<td >";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "");
     echo "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td><td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     echo "<td rowspan='4' class='middle'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='4'>";
     echo "<textarea cols='45' rows='4' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Version in use') . "</td>";
     echo "<td>";
     SoftwareVersion::dropdownForOneSoftware(array('name' => "softwareversions_id_use", 'softwares_id' => $this->fields["softwares_id"], 'value' => $this->fields["softwareversions_id_use"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Purchase version') . "</td>";
     echo "<td>";
     SoftwareVersion::dropdownForOneSoftware(array('name' => "softwareversions_id_buy", 'softwares_id' => $this->fields["softwares_id"], 'value' => $this->fields["softwareversions_id_buy"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _x('quantity', 'Number') . "</td>";
     echo "<td>";
     Dropdown::showNumber("number", array('value' => $this->fields["number"], 'min' => 1, 'max' => 10000, 'step' => 1, 'toadd' => array(-1 => __('Unlimited'))));
     if ($ID > 0) {
         echo "&nbsp;";
         if ($this->fields['is_valid']) {
             echo "<span class='green'>" . _x('adjective', 'Valid') . '<span>';
         } else {
             echo "<span class='red'>" . _x('adjective', 'Invalid') . '<span>';
         }
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Expiration') . "</td>";
     echo "<td>";
     Html::showDateField('expire', array('value' => $this->fields["expire"]));
     if ($ID && is_null($this->fields["expire"])) {
         echo "<br>" . __('Never expire') . "&nbsp;";
         Html::showToolTip(__('On search engine, use "Expiration contains NULL" to search licenses with no expiration date'));
     }
     Alert::displayLastAlert('SoftwareLicense', $ID);
     echo "</td><td colspan='2'></td></tr>\n";
     $this->showFormButtons($options);
     return true;
 }
    public static function show($field, $datas)
    {
        $value = $datas['formcreator_field_' . $field['id']] != 'NULL' ? $datas['formcreator_field_' . $field['id']] : $field['default_values'];
        if ($field['required']) {
            $required = ' required';
        } else {
            $required = '';
        }
        echo '<div class="form-group' . $required . '" id="form-group-field' . $field['id'] . '">';
        echo '<label>';
        echo $field['name'];
        if ($field['required']) {
            echo ' <span class="red">*</span>';
        }
        echo '</label>';
        echo '<div>';
        Html::showDateField('formcreator_field_' . $field['id'], array('value' => $value));
        echo '</div>';
        echo '<div class="help-block">' . html_entity_decode($field['description']) . '</div>';
        switch ($field['show_condition']) {
            case 'notequal':
                $condition = '!=';
                break;
            case 'lower':
                $condition = '<';
                break;
            case 'greater':
                $condition = '>';
                break;
            default:
                $condition = '==';
                break;
        }
        if ($field['show_type'] == 'hide') {
            $conditionnalField = new PluginFormcreatorQuestion();
            $conditionnalField->getFromDB($field['show_field']);
            switch ($conditionnalField->fields['fieldtype']) {
                case 'checkboxes':
                    echo '<script type="text/javascript">
                  var inputElements = document.getElementsByName("formcreator_field_' . $field['show_field'] . '[]");

                  for(var i=0; inputElements[i]; ++i) {
                     inputElements[i].addEventListener("change", function(){showFormGroup' . $field['id'] . '()});
                  }

                  function showFormGroup' . $field['id'] . '() {
                     var checkedValue = false;

                     for(var i=0; inputElements[i]; ++i) {
                        if (inputElements[i].value ' . $condition . ' "' . $field['show_value'] . '" && inputElements[i].checked) {
                           checkedValue = true;
                        }
                     }

                     if(checkedValue) {
                        document.getElementById("form-group-field' . $field['id'] . '").style.display = "block";
                     } else {
                        document.getElementById("form-group-field' . $field['id'] . '").style.display = "none";
                     }
                  }';
                    break;
                case 'multiselect':
                    echo '<script type="text/javascript">
                  var inputElements = document.getElementsByName("formcreator_field_' . $field['show_field'] . '[]")[1];
                  inputElements.addEventListener("change", function(){showFormGroup' . $field['id'] . '()});

                  function showFormGroup' . $field['id'] . '() {
                     var checkedValue = false;

                     for(var i=0; inputElements[i]; ++i) {
                        if (inputElements[i].value ' . $condition . ' "' . $field['show_value'] . '" && inputElements[i].selected) {
                           checkedValue = true;
                        }
                     }

                     if(checkedValue) {
                        document.getElementById("form-group-field' . $field['id'] . '").style.display = "block";
                     } else {
                        document.getElementById("form-group-field' . $field['id'] . '").style.display = "none";
                     }
                  }';
                    break;
                case 'radios':
                    echo '<script type="text/javascript">
                  var inputElements = document.getElementsByName("formcreator_field_' . $field['show_field'] . '");

                  for(var i=0; inputElements[i]; ++i) {
                     inputElements[i].addEventListener("change", function(){showFormGroup' . $field['id'] . '()});
                  }

                  function showFormGroup' . $field['id'] . '() {
                     var checkedValue = false;

                     for(var i=0; inputElements[i]; ++i) {
                        if (inputElements[i].value ' . $condition . ' "' . $field['show_value'] . '" && inputElements[i].checked) {
                           checkedValue = true;
                        }
                     }

                     if(checkedValue) {
                        document.getElementById("form-group-field' . $field['id'] . '").style.display = "block";
                     } else {
                        document.getElementById("form-group-field' . $field['id'] . '").style.display = "none";
                     }
                  }';
                    break;
                default:
                    echo '<script type="text/javascript">
                  document.getElementsByName("formcreator_field_' . $field['show_field'] . '")[0].addEventListener("change", function(){showFormGroup' . $field['id'] . '()});
                  function showFormGroup' . $field['id'] . '() {
                     var field_value = document.getElementsByName("formcreator_field_' . $field['show_field'] . '")[0].value;
                     if(field_value ' . $condition . ' "' . $field['show_value'] . '") {
                        document.getElementById("form-group-field' . $field['id'] . '").style.display = "block";
                     } else {
                        document.getElementById("form-group-field' . $field['id'] . '").style.display = "none";
                     }
                  }';
            }
            echo '
                  Ext.onReady(function() {showFormGroup' . $field['id'] . '()});
               </script>';
        }
        echo '</div>' . PHP_EOL;
    }