showDateFormItem() static public method

Display Date form with calendar
static public showDateFormItem ( $element, $value = '', $maybeempty = true, $can_edit = true, $minDate = '', $maxDate = '', $displayYear = true ) : rand
$element name of the element
$value default value to display (default '')
$maybeempty may be empty ? (true by default)
$can_edit could not modify element (true by default)
$minDate minimum allowed date (default '')
$maxDate maximum allowed date (default '')
$displayYear should we set/diplay the year? (true by default)
return rand value used \deprecated since 0.84 used Html::showDateField instead
Ejemplo n.º 1
0
 /**
  * Show a date selector
  * @param  datetime $date1    date of start
  * @param  datetime $date2    date of ending
  * @param  string $randname random string (to prevent conflict in js selection)
  * @return nothing
  */
 static function showSelector($date1, $date2, $randname)
 {
     $request_string = self::getRequestString($_GET);
     echo "<div class='center'><form method='POST' action='?{$request_string}' name='form'" . " id='mreporting_date_selector'>\n";
     echo "<table class='tab_cadre'><tr class='tab_bg_1'>";
     echo '<td><table><tr class="tab_bg_1">';
     echo "<td>";
     Html::showDateFormItem("date1" . $randname, $date1, false);
     echo "</td>\n";
     echo "<td>";
     Html::showDateFormItem("date2" . $randname, $date2, false);
     echo "</td>\n";
     self::getReportSelectors();
     echo "</tr></table></td>";
     echo "<td rowspan='2' class='center'>";
     echo "<input type='submit' class='button' name='submit' Value=\"" . _sx('button', 'Post') . "\">";
     echo "</td>\n";
     echo "<td class='center'>";
     $_SERVER['REQUEST_URI'] .= "&date1" . $randname . "=" . $date1;
     $_SERVER['REQUEST_URI'] .= "&date2" . $randname . "=" . $date2;
     Bookmark::showSaveButton(Bookmark::URI);
     echo "</td>\n";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>\n";
 }
function displaySearchForm()
{
    global $_SERVER;
    echo "<form action='" . $_SERVER["PHP_SELF"] . "' method='post'>";
    echo "<table class='tab_cadre' cellpadding='5'>";
    echo "<tr class='tab_bg_1' align='center'>";
    echo "<td>";
    echo __('Starting date', 'fusioninventory') . " :";
    echo "</td>";
    echo "<td width='120'>";
    Html::showDateFormItem("glpi_plugin_fusioninventory_date_start", $_SESSION['glpi_plugin_fusioninventory_date_start']);
    echo "</td>";
    echo "<td>";
    echo __('Ending date', 'fusioninventory') . " :";
    echo "</td>";
    echo "<td width='120'>";
    Html::showDateFormItem("glpi_plugin_fusioninventory_date_end", $_SESSION['glpi_plugin_fusioninventory_date_end']);
    echo "</td>";
    echo "<td>";
    echo "<input type='submit' name='reset' value='reset' class='submit' />";
    echo "</td>";
    echo "<td>";
    echo "<input type='submit' value='Valider' class='submit' />";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    Html::closeForm();
}
Ejemplo n.º 3
0
 public function displayCriteria()
 {
     $this->getReport()->startColumn();
     echo $this->getCriteriaLabel($this->getName()) . '&nbsp;:';
     $this->getReport()->endColumn();
     $this->getReport()->startColumn();
     Html::showDateFormItem($this->getName(), $this->getDate(), false);
     $this->getReport()->endColumn();
 }
 public function displayCriteria()
 {
     $this->getReport()->startColumn();
     $name = $this->getCriteriaLabel($this->getName());
     if ($name) {
         echo "{$name}, ";
     }
     echo $this->getCriteriaLabel($this->getName() . "_1") . '&nbsp;:';
     $this->getReport()->endColumn();
     $this->getReport()->startColumn();
     Html::showDateFormItem($this->getName() . "_1", $this->getStartDate(), false);
     $this->getReport()->endColumn();
     $this->getReport()->startColumn();
     if ($name) {
         echo "{$name}, ";
     }
     echo $this->getCriteriaLabel($this->getName() . "_2") . '&nbsp;:';
     $this->getReport()->endColumn();
     $this->getReport()->startColumn();
     Html::showDateFormItem($this->getName() . "_2", $this->getEndDate(), false);
     $this->getReport()->endColumn();
 }
Ejemplo n.º 5
0
 /**
  * Print the acccount form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - withtemplate template or basic computer
  *
  * @return Nothing (display)
  **/
 public function showForm($ID, $options = array())
 {
     if (!$this->canView()) {
         return false;
     }
     $hashclass = new PluginAccountsHash();
     $restrict = getEntitiesRestrictRequest(" ", "glpi_plugin_accounts_hashes", '', '', $hashclass->maybeRecursive());
     if ($ID < 1 && countElementsInTable("glpi_plugin_accounts_hashes", $restrict) == 0) {
         echo "<div class='center'>" . __('There is no encryption key for this entity', 'accounts') . "<br><br>";
         echo "<a href='" . Toolbox::getItemTypeSearchURL('PluginAccountsAccount') . "'>";
         _e('Back');
         echo "</a></div>";
         return false;
     }
     /*
           if ($ID > 0) {
              $this->check($ID, READ);
              if (!Session::haveRight("plugin_accounts_see_all_users", 1)) {
                 $access = 0;
                 if (Session::haveRight("plugin_accounts_my_groups", 1)) {
                    if ($this->fields["groups_id"]) {
                       if (count($_SESSION['glpigroups'])
                                && in_array($this->fields["groups_id"], $_SESSION['glpigroups'])
                       ) {
                          $access = 1;
                       }
                    }
                    if ($this->fields["users_id"]) {
                       if ($this->fields["users_id"] == Session::getLoginUserID())
                          $access = 1;
                    }
                 }
                 if (!Session::haveRight("plugin_accounts_my_groups", 1)
                          && $this->fields["users_id"] == Session::getLoginUserID()
                 )
                    $access = 1;
     
                 if ($access != 1)
                    return false;
              }
           } else {
              // Create item
              $this->check(-1, UPDATE);
              $this->getEmpty();
           }
     */
     $options["formoptions"] = "id = 'account_form'";
     $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>" . __('Status') . "</td><td>";
     Dropdown::show('PluginAccountsAccountState', array('value' => $this->fields["plugin_accounts_accountstates_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Login') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "login");
     echo "</td>";
     echo "<td>" . __('Type') . "</td><td>";
     Dropdown::show('PluginAccountsAccountType', array('value' => $this->fields["plugin_accounts_accounttypes_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     //hash
     $hash = 0;
     $restrict = getEntitiesRestrictRequest(" ", "glpi_plugin_accounts_hashes", '', $this->getEntityID(), $hashclass->maybeRecursive());
     $hashes = getAllDatasFromTable("glpi_plugin_accounts_hashes", $restrict);
     if (!empty($hashes)) {
         foreach ($hashes as $hashe) {
             $hash = $hashe["hash"];
             $hash_id = $hashe["id"];
         }
         $alert = '';
     } else {
         $alert = __('There is no encryption key for this entity', 'accounts');
     }
     $aeskey = new PluginAccountsAesKey();
     //aeskey non enregistre
     if ($hash) {
         if (!$aeskey->getFromDBByHash($hash_id) || !$aeskey->fields["name"]) {
             echo "<td>" . __('Encryption key', 'accounts') . "</div></td><td>";
             echo "<input type='password' autocomplete='off' name='aeskey' id='aeskey'>";
             echo Html::hidden('encrypted_password', array('value' => $this->fields["encrypted_password"], 'id' => 'encrypted_password'));
             echo Html::hidden('good_hash', array('value' => $hash, 'id' => 'good_hash'));
             echo Html::hidden('wrong_key_locale', array('value' => __('Wrong encryption key', 'accounts'), 'id' => 'wrong_key_locale'));
             if (!empty($ID) || $ID > 0) {
                 $url = $this->getFormURL();
                 echo "&nbsp;<input type='button' id='decrypte_link' name='decrypte' value='" . __s('Uncrypt', 'accounts') . "'\n                        class='submit'>";
             }
             echo "</td>";
         } else {
             echo "<td></td><td>";
             echo "</td>";
         }
     } else {
         echo "<td>" . __('Encryption key', 'accounts') . "</div></td><td><div class='red'>";
         echo $alert;
         echo "</div></td>";
     }
     if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
         echo "<td>" . __('Affected User', 'accounts') . "</td><td>";
         if ($this->canCreate()) {
             User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
         } else {
             echo getUserName($this->fields["users_id"]);
         }
         echo "</td>";
     } else {
         echo "<td>" . __('Affected User', 'accounts') . "</td><td>";
         echo getUserName($this->fields["users_id"]);
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Password') . "</td>";
     echo "<td>";
     //aeskey enregistre
     if (isset($hash_id) && $aeskey->getFromDBByHash($hash_id) && $aeskey->fields["name"]) {
         echo Html::hidden('good_hash', array('value' => $hash, 'id' => 'good_hash'));
         echo Html::hidden('aeskey', array('value' => $aeskey->fields["name"], 'id' => 'aeskey', 'autocomplete' => 'off'));
         echo Html::hidden('encrypted_password', array('value' => $this->fields["encrypted_password"], 'id' => 'encrypted_password'));
         echo Html::hidden('wrong_key_locale', array('value' => __('Wrong encryption key', 'accounts'), 'id' => 'wrong_key_locale'));
         echo Html::scriptBlock("auto_decrypt();");
     }
     echo "<input type='text' name='hidden_password' id='hidden_password' size='30' >";
     echo "</td>";
     if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
         echo "<td>" . __('Affected Group', 'accounts') . "</td><td>";
         if (self::canCreate()) {
             Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'condition' => '`is_itemgroup`'));
         } else {
             echo Dropdown::getDropdownName("glpi_groups", $this->fields["groups_id"]);
         }
         echo "</td>";
     } else {
         echo "<td>" . __('Affected Group', 'accounts') . ":\t</td><td>";
         echo Dropdown::getDropdownName("glpi_groups", $this->fields["groups_id"]);
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Creation date') . "</td>";
     echo "<td>";
     Html::showDateFormItem("date_creation", $this->fields["date_creation"], true, true);
     echo "</td>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => "users_id_tech", 'value' => $this->fields["users_id_tech"], 'entity' => $this->fields["entities_id"], 'right' => 'interface'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Expiration date') . "&nbsp;";
     Html::showToolTip(nl2br(__('Empty for infinite', 'accounts')));
     echo "</td>";
     echo "<td>";
     Html::showDateFormItem("date_expiration", $this->fields["date_expiration"], true, true);
     echo "</td>";
     echo "<td>" . __('Group in charge of the hardware') . "</td><td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Others') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "others");
     echo "</td>";
     echo "<td>" . __('Location') . "</td><td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan = '4'>";
     echo "<table cellpadding='2' cellspacing='2' border='0'><tr><td>";
     echo __('Comments') . "</td></tr>";
     echo "<tr><td class='center'>";
     echo "<textarea cols='125' rows='3' name='comment'>" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr></table>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Associable to a ticket') . "</td><td>";
     Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     echo "</td>";
     echo "<td colspan='2'>";
     printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     echo "</td>";
     echo "</tr>";
     if (self::canCreate()) {
         if (empty($ID) || $ID < 0) {
             echo "<tr>";
             echo "<td class='tab_bg_2 top' colspan='4'>";
             echo "<div align='center'>";
             echo "<input type='submit' name='add' id='account_add' value='" . _sx('button', 'Add') . "' class='submit'>";
             echo "</div>";
             echo Html::scriptBlock("\$('#account_form').submit(function(event){\n               if (\$('#hidden_password').val() == '' || \$('#aeskey').val() == '') {\n                  alert('" . __('You have not filled the password and encryption key', 'accounts') . "');\n                  return false;\n               };\n               if (!check_hash()) {\n                  alert('" . __('Wrong encryption key', 'accounts') . "');\n                  return false;\n               } else {\n                  encrypt_password();\n               }\n            });");
             echo "</td>";
             echo "</tr>";
         } else {
             echo "<tr>";
             echo "<td class='tab_bg_2'  colspan='4 top'><div align='center'>";
             echo "<input type='hidden' name='id' value=\"{$ID}\">";
             echo "<input type='submit' name='update' id='account_update' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
             echo Html::scriptBlock("\$('#account_form').submit(function(event){\n               if (\$('#hidden_password').val() == '' || \$('#aeskey').val() == '') {\n                  alert('" . __('Password will not be modified', 'accounts') . "');\n               } else if (!check_hash()) {\n                  alert('" . __('Wrong encryption key', 'accounts') . "');\n                  return false;\n               } else {\n                  encrypt_password();\n               }\n            });");
             if ($this->fields["is_deleted"] == '0') {
                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='delete' value=\"" . _sx('button', 'Put in dustbin') . "\" class='submit'></div>";
             } else {
                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='restore' value=\"" . _sx('button', 'Restore') . "\" class='submit'>";
                 echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='purge' value=\"" . _sx('button', 'Delete permanently') . "\" class='submit'></div>";
             }
             echo "</td>";
             echo "</tr>";
         }
     }
     $options['canedit'] = false;
     $options['candel'] = false;
     $this->showFormButtons($options);
     Html::closeForm();
     return true;
 }
 function showForm($ID, $options = array())
 {
     $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>" . __('User') . "</td><td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "</tr>";
     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><td>";
     Dropdown::show('PluginBadgesBadgeType', array('name' => "plugin_badges_badgetypes_id", 'value' => $this->fields["plugin_badges_badgetypes_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td>";
     echo "<td>" . __('Status') . "</td><td>";
     State::dropdown(array('value' => $this->fields["states_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Affectation date', 'badges') . "</td>";
     echo "<td>";
     Html::showDateFormItem("date_affectation", $this->fields["date_affectation"], true, true);
     echo "</td>";
     echo "<td>" . __('Associable to a ticket') . "</td><td>";
     Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Date of end of validity', 'badges');
     echo "</td>";
     echo "<td>";
     Html::showDateFormItem("date_expiration", $this->fields["date_expiration"], true, true);
     echo "</td>";
     echo "<td colspan='2'>";
     printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Comments') . "</td>";
     echo "<td class='center' colspan='3'><textarea cols='115' rows='5' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
    /**
     * Show printer graph form
     **/
    function showGraph($id, $options = array())
    {
        global $DB, $CFG_GLPI;
        $printer = new Printer();
        $where = '';
        $begin = '';
        $end = '';
        $timeUnit = 'day';
        $graphField = 'pages_total';
        $pagecounters = array();
        $graphType = 'day';
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_begin'])) {
            $begin = $_SESSION['glpi_plugin_fusioninventory_graph_begin'];
        }
        if ($begin == 'NULL' or $begin == '') {
            $begin = date("Y-m-01");
            // first day of current month
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_end'])) {
            $end = $_SESSION['glpi_plugin_fusioninventory_graph_end'];
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_type'])) {
            $graphType = $_SESSION['glpi_plugin_fusioninventory_graph_type'];
        }
        if ($end == 'NULL' or $end == '') {
            $end = date("Y-m-d");
            // today
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_timeUnit'])) {
            $timeUnit = $_SESSION['glpi_plugin_fusioninventory_graph_timeUnit'];
        }
        if (!isset($_SESSION['glpi_plugin_fusioninventory_graph_printersComp'])) {
            $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'] = array();
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_printerCompAdd'])) {
            $printerCompAdd = $_SESSION['glpi_plugin_fusioninventory_graph_printerCompAdd'];
            if (!key_exists($printerCompAdd, $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'])) {
                $oPrinter = new Printer();
                if ($oPrinter->getFromDB($printerCompAdd)) {
                    $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'][$printerCompAdd] = $oPrinter->getField('name');
                }
            }
        } elseif (isset($_SESSION['glpi_plugin_fusioninventory_graph_printerCompRemove'])) {
            unset($_SESSION['glpi_plugin_fusioninventory_graph_printersComp'][$_SESSION['glpi_plugin_fusioninventory_graph_printerCompRemove']]);
        }
        $oPrinter = new Printer();
        $printers = $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'];
        $printersView = $printers;
        // printers without the current printer
        if (isset($printersView[$id])) {
            unset($printersView[$id]);
        } else {
            if ($oPrinter->getFromDB($id)) {
                $printers[$id] = $oPrinter->getField('name');
            }
        }
        $printersList = '';
        foreach ($printers as $printers_id => $printername) {
            if ($printersList != '') {
                $printersList .= '<br/>';
            }
            if ($printers_id == $id) {
                $printersList .= $printername;
            } else {
                $oPrinter->getFromDB($printers_id);
                $printersList .= $oPrinter->getLink(1);
            }
        }
        $printersIds = "";
        foreach (array_keys($printers) as $printerId) {
            if ($printersIds != '') {
                $printersIds .= ', ';
            }
            $printersIds .= $printerId;
        }
        $where = " WHERE `printers_id` IN(" . $printersIds . ")";
        if ($begin != '' || $end != '') {
            $where .= " AND " . getDateRequest("`date`", $begin, $end);
        }
        $group = '';
        switch ($timeUnit) {
            case 'day':
                $group = "GROUP BY `printers_id`, `year`, `month`, `day`";
                break;
            case 'week':
                $group = "GROUP BY `printers_id`, `year`, `month`, `week`";
                break;
            case 'month':
                $group = "GROUP BY `printers_id`, `year`, `month`";
                break;
            case 'year':
                $group = "GROUP BY `printers_id`, `year`";
                break;
        }
        echo "<form method='post' name='snmp_form' id='snmp_form' action='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/printer_info.form.php'>";
        echo "<table class='tab_cadre' cellpadding='5' width='950'>";
        $mapping = new PluginFusioninventoryMapping();
        $maps = $mapping->find("`itemtype`='Printer'");
        foreach ($maps as $mapfields) {
            if (!isset($mapfields["shortlocale"])) {
                $mapfields["shortlocale"] = $mapfields["locale"];
            }
            $pagecounters[$mapfields['name']] = $mapping->getTranslation($mapfields);
        }
        echo "<tr class='tab_bg_1'>";
        echo "<th colspan='4'>";
        echo __('Printed page counter', 'fusioninventory');
        echo "</th>";
        echo "</tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td class='left'>" . __('Start date') . "&nbsp;:</td>";
        echo "<td class='left'>";
        Html::showDateFormItem("graph_begin", $begin);
        echo "</td>";
        echo "<td class='left'>" . __('Time unit', 'fusioninventory') . "&nbsp;:</td>";
        echo "<td class='left'>";
        $elementsTime = array('day' => _n('Day', 'Days', 1), 'week' => __('Week'), 'month' => _n('Month', 'Months', 1), 'year' => __('Year', 'fusioninventory'));
        Dropdown::showFromArray('graph_timeUnit', $elementsTime, array('value' => $timeUnit));
        echo "</td>";
        echo "</tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td class='left'>" . __('End date') . "&nbsp;:</td>";
        echo "<td class='left'>";
        Html::showDateFormItem("graph_end", $end);
        echo "</td>";
        echo "<td class='left'>" . __('Display', 'fusioninventory') . "&nbsp;:</td>";
        echo "<td class='left'>";
        $elements = array('total' => __('Total counter', 'fusioninventory'), 'day' => __('pages per day', 'fusioninventory'));
        Dropdown::showFromArray('graph_type', $elements, array('value' => $graphType));
        echo "</td>";
        echo "</tr>";
        echo "<tr class='tab_bg_2'>";
        echo "<td class='center' colspan='4'>\n              <input type='submit' class='submit' name='graph_plugin_fusioninventory_printer_period'\n                      value='" . __('Update') . "'/>";
        echo "</td>";
        echo "</tr>\n";
        echo "<tr>";
        echo "<th colspan='4'>" . __('Printers to compare', 'fusioninventory') . "</th>";
        echo "</tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td class='left' rowspan='3'>" . __('Printer') . "&nbsp;:</td>";
        echo "<td class='left' rowspan='3'>";
        echo $printersList;
        echo "</td>";
        echo "<td class='left'>" . __('Add a printer', 'fusioninventory') . "&nbsp;:</td>";
        echo "<td class='left'>";
        $printersused = array();
        foreach ($printersView as $printer_id => $name) {
            $printersused[] = $printer_id;
        }
        $printer->getFromDB($id);
        Dropdown::show('Printer', array('name' => 'graph_printerCompAdd', 'entity' => $printer->fields['entities_id'], 'used' => $printersused));
        echo "&nbsp;<input type='submit' value=\"" . __('Add') . "\" class='submit' " . "name='graph_plugin_fusioninventory_printer_add'>";
        echo "</td>";
        echo "</tr>\n";
        echo "<tr class='tab_bg_1'>";
        echo "<td class='left'>" . __('Remove a printer', 'fusioninventory') . "&nbsp;:</td>";
        echo "<td class='left'>";
        $printersTmp = $printersView;
        $printersTmp[0] = "-----";
        asort($printersTmp);
        Dropdown::showFromArray('graph_printerCompRemove', $printersTmp);
        echo "&nbsp;<input type='submit' value=\"" . __('Delete', 'fusioninventory') . "\" " . "class='submit' name='graph_plugin_fusioninventory_printer_remove'>";
        echo "</td>";
        echo "</tr>\n";
        echo "<tr class='tab_bg_1'>";
        echo "<td colspan='2'></td>";
        echo "</tr>";
        echo "</table>";
        Html::closeForm();
        $elementsField = array('pages_total' => $pagecounters['pagecountertotalpages'], 'pages_n_b' => $pagecounters['pagecounterblackpages'], 'pages_color' => $pagecounters['pagecountercolorpages'], 'pages_recto_verso' => $pagecounters['pagecounterrectoversopages'], 'scanned' => $pagecounters['pagecounterscannedpages'], 'pages_total_print' => $pagecounters['pagecountertotalpages_print'], 'pages_n_b_print' => $pagecounters['pagecounterblackpages_print'], 'pages_color_print' => $pagecounters['pagecountercolorpages_print'], 'pages_total_copy' => $pagecounters['pagecountertotalpages_copy'], 'pages_n_b_copy' => $pagecounters['pagecounterblackpages_copy'], 'pages_color_copy' => $pagecounters['pagecountercolorpages_copy'], 'pages_total_fax' => $pagecounters['pagecountertotalpages_fax']);
        echo "<br/>";
        $a_graph = array();
        foreach ($elementsField as $graphField => $name) {
            $query = "SELECT `printers_id`, DAY(`date`)-1 AS `day`, WEEK(`date`) AS `week`,\n                    MONTH(`date`) AS `month`, YEAR(`date`) AS `year`, `date`,\n                    `{$graphField}`\n             FROM `glpi_plugin_fusioninventory_printerlogs`" . $where . " AND `" . $graphField . "` > 0 " . $group;
            $result = $DB->query($query);
            if ($DB->numrows($result) == 0) {
                unset($elementsField[$graphField]);
            }
        }
        foreach ($elementsField as $graphField => $name) {
            $query = "SELECT `printers_id`, DAY(`date`)-1 AS `day`, WEEK(`date`) AS `week`,\n                    MONTH(`date`) AS `month`, YEAR(`date`) AS `year`, `date`,\n                    `{$graphField}`\n             FROM `glpi_plugin_fusioninventory_printerlogs`" . $where . $group . "\n             ORDER BY `year`, `month`, `day`, `printers_id`";
            $input = array();
            $result = $DB->query($query);
            if ($result) {
                if ($DB->numrows($result) != 0) {
                    $pages = array();
                    $data = array();
                    $date = '';
                    while ($data = $DB->fetch_assoc($result)) {
                        switch ($timeUnit) {
                            case 'day':
                                $split = explode(" ", $data['date']);
                                $date = $split[0];
                                break;
                            case 'week':
                                $split = explode(" ", $data['date']);
                                $date = $split[0];
                                break;
                            case 'month':
                                $split = explode(" ", $data['date']);
                                $split2 = explode("-", $split[0]);
                                $date = $split2[0] . "-" . $split2[1];
                                break;
                            case 'year':
                                $split = explode(" ", $data['date']);
                                $split2 = explode("-", $split[0]);
                                $date = $split2[0];
                                break;
                        }
                        if ($graphType == 'day') {
                            if (!isset($pages[$data['printers_id']])) {
                                $pages[$data['printers_id']] = $data[$graphField];
                            } else {
                                $y = $data[$graphField] - $pages[$data['printers_id']];
                                if ($y < 0) {
                                    $y = 0;
                                }
                                $input[] = array('x' => $date, 'y' => $y);
                                if ($data[$graphField] > 0) {
                                    $pages[$data['printers_id']] = $data[$graphField];
                                }
                            }
                        } else {
                            $input[] = array('x' => $date, 'y' => $data[$graphField]);
                        }
                    }
                }
            }
            $continue = 1;
            if ($continue == '0' or $continue == '-1') {
                echo "<table class='tab_cadre' cellpadding='5' width='900'>";
                echo "<tr class='tab_bg_1'>";
                echo "<th>";
                echo $name;
                echo "</th>";
                echo "</tr>";
                echo "<tr class='tab_bg_1'>";
                echo "<td align='center'>";
                if ($continue == '0') {
                    echo __('Too datas to display', 'fusioninventory');
                }
                echo "</td>";
                echo "</tr>";
                echo "</table><br/>";
            } else {
                if (count($input > 0)) {
                    $split = explode(' > ', $name);
                    $a_graph[] = array('key' => $split[count($split) - 1], 'values' => $input);
                }
            }
        }
        // Display graph
        echo '<div id="chartPrinter">' . '<svg style="height: 400px; width: 950px;"></svg>' . '</div>';
        echo "<script type='text/javascript'>\n      function drawGraph() {\n         var chart = nv.models.multiBarChart();\n\n         chart.yAxis\n             .tickFormat(d3.format(',0f'));\n\n        d3.select('#chartPrinter svg')\n           .datum(exampleData())\n          .transition().duration(500).call(chart);\n\n        nv.utils.windowResize(chart.update);\n    }\n    ";
        echo '   function exampleData() {
      return ' . json_encode($a_graph) . '
   }

   drawGraph();
</script>';
    }
Ejemplo n.º 8
0
 /**
  * Display the budget 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(""))
 {
     global $CFG_GLPI;
     $this->initForm($ID, $options);
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name", array('value' => $this->fields["name"]));
     echo "</td>";
     echo "<td>" . __('Budget volume', 'resources') . "</td>";
     echo "<td>";
     Dropdown::show('PluginResourcesBudgetType', array('value' => $this->fields["plugin_resources_budgettypes_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Profession', 'resources') . "</td>";
     echo "<td>";
     $params = array('name' => 'plugin_resources_professions_id', 'value' => $this->fields['plugin_resources_professions_id'], 'entityt' => $this->fields["entities_id"], 'action' => $CFG_GLPI["root_doc"] . "/plugins/resources/ajax/dropdownRank.php", 'span' => 'span_rank', 'sort' => true);
     PluginResourcesResource::showGenericDropdown('PluginResourcesProfession', $params);
     echo "</td>";
     echo "<td>" . __('Rank', 'resources') . "</td><td>";
     echo "<span id='span_rank' name='span_rank'>";
     if ($this->fields["plugin_resources_ranks_id"] > 0) {
         echo Dropdown::getDropdownName('glpi_plugin_resources_ranks', $this->fields["plugin_resources_ranks_id"]);
     } else {
         _e('None');
     }
     echo "</span></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Budget volume', 'resources') . "</td>";
     echo "<td>";
     $options = array('value' => 0);
     Html::autocompletionTextField($this, 'volume', $options);
     echo "</td><td>" . __('Type of budget volume', 'resources') . "</td><td>";
     Dropdown::show('PluginResourcesBudgetVolume', array('value' => $this->fields["plugin_resources_budgetvolumes_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Begin date') . "</td>";
     echo "<td>";
     Html::showDateFormItem("begin_date", $this->fields["begin_date"], true, true);
     echo "</td>";
     echo "<td>" . __('End date') . "</td>";
     echo "<td>";
     Html::showDateFormItem("end_date", $this->fields["end_date"], true, true);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td class='center' colspan='6'>";
     printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     echo "</td>";
     echo "</tr>";
     if ($_SESSION['glpiactiveprofile']['interface'] != 'central') {
         $options['candel'] = false;
     }
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
Ejemplo n.º 9
0
    }
    $INSELECT .= "</optgroup>";
}
echo "<div class='center'><form method='get' name='form' action='stat.tracking.php'>";
echo "<table class='tab_cadre'>";
echo "<tr class='tab_bg_2'><td rowspan='2' class='center'>";
echo "<select name='type'>" . $INSELECT . "</select></td>";
echo "<td class='right'>" . __('Start date') . "</td><td>";
Html::showDateFormItem("date1", $_GET["date1"]);
echo "</td>";
echo "<td class='right'>" . __('Show graphics') . "</td>";
echo "<td rowspan='2' class='center'>";
echo "<input type='hidden' name='itemtype' value=\"" . $_GET["itemtype"] . "\">";
echo "<input type='submit' class='submit' name='submit' value=\"" . __s('Display report') . "\"></td>" . "</tr>";
echo "<tr class='tab_bg_2'><td class='right'>" . __('End date') . "</td><td>";
Html::showDateFormItem("date2", $_GET["date2"]);
echo "</td><td class='center'>";
echo "<input type='hidden' name='value2' value='" . $_GET["value2"] . "'>";
Dropdown::showYesNo('showgraph', $_GET['showgraph']);
echo "</td></tr>";
echo "</table>";
// form using GET method : CRSF not needed
echo "</form>";
echo "</div>";
$val = Stat::getItems($_GET["itemtype"], $_GET["date1"], $_GET["date2"], $_GET["type"], $_GET["value2"]);
$params = array('type' => $_GET["type"], 'date1' => $_GET["date1"], 'date2' => $_GET["date2"], 'value2' => $_GET["value2"], 'start' => $_GET["start"]);
Html::printPager($_GET['start'], count($val), $CFG_GLPI['root_doc'] . '/front/stat.tracking.php', "date1=" . $_GET["date1"] . "&amp;date2=" . $_GET["date2"] . "&amp;type=" . $_GET["type"] . "&amp;showgraph=" . $_GET["showgraph"] . "&amp;itemtype=" . $_GET["itemtype"] . "&amp;value2=" . $_GET['value2'], 'Stat', $params);
if (!$_GET['showgraph']) {
    Stat::show($_GET["itemtype"], $_GET["type"], $_GET["date1"], $_GET["date2"], $_GET['start'], $val, $_GET['value2']);
} else {
    $data = Stat::getDatas($_GET["itemtype"], $_GET["type"], $_GET["date1"], $_GET["date2"], $_GET['start'], $val, $_GET['value2']);
Ejemplo n.º 10
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 (!Session::haveRight("infocom", "r")) {
         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, "w", $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->can($ic->fields['id'], "w") && $withtemplate != 2;
             if ($canedit) {
                 echo "<form name='form_ic' method='post' action='" . $CFG_GLPI["root_doc"] . "/front/infocom.form.php'>";
             }
             echo "<div class='spaced'>";
             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()));
             }
             echo "</td>";
             if (Session::haveRight("budget", "r")) {
                 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::showDateFormItem("order_date", $ic->fields["order_date"], true, $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::showDateFormItem("buy_date", $ic->fields["buy_date"], true, $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::showDateFormItem("delivery_date", $ic->fields["delivery_date"], true, $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::showDateFormItem("use_date", $ic->fields["use_date"], true, $editcalendar);
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Value') . "</td>";
             echo "<td><input type='text' name='value' {$option} value='" . Html::formatNumber($ic->fields["value"], true) . "' size='14'></td>";
             echo "</td>";
             echo "<td>" . __('Date of last physical inventory') . "</td><td>";
             Html::showDateFormItem("inventory_date", $ic->fields["inventory_date"], true, $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::showDateFormItem("warranty_date", $ic->fields["warranty_date"], true, $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::showInteger("warranty_duration", $ic->fields["warranty_duration"], 0, 120, 1, array(-1 => __('Lifelong')), array('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']);
                 echo "</td>";
             } 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='delete' value=\"" . _sx('button', 'Delete permanently') . "\"\n                      class='submit'>";
                 echo "</td></tr>";
                 echo "</table></div>";
                 Html::closeForm();
             } else {
                 echo "</table></div>";
             }
         }
     }
 }
Ejemplo n.º 11
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::showDateTimeFormItem($_POST['name'], $_POST['specificvalue']);
    } else {
        Html::showDateFormItem($_POST['name'], $_POST['specificvalue']);
    }
} else {
    echo "<input type='hidden' name='" . $_POST['name'] . "' value='" . $_POST['value'] . "'>";
}
Ejemplo n.º 12
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 (!Session::haveRight("software", "w")) {
         return false;
     }
     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->showTabs($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::showInteger("number", $this->fields["number"], 1, 1000, 1, array(-1 => __('Unlimited')));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Expiration') . "</td>";
     echo "<td>";
     Html::showDateFormItem('expire', $this->fields["expire"]);
     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);
     $this->addDivForTabs();
     return true;
 }
Ejemplo n.º 13
0
 /**
  * Show the availability of a user
  *
  * @since version 0.83
  *
  * @param $who    ID of the user
  * @param $begin  begin date to check (default '')
  * @param $end    end date to check (default '')
  *
  * @return Nothing (display function)
  **/
 static function checkAvailability($who, $begin = '', $end = '')
 {
     global $CFG_GLPI, $DB;
     if (empty($who)) {
         return false;
     }
     if (empty($begin)) {
         $begin = date("Y-m-d");
     }
     if (empty($end)) {
         $end = date("Y-m-d");
     }
     if ($end < $begin) {
         $end = $begin;
     }
     $realbegin = $begin . " " . $CFG_GLPI["planning_begin"];
     $realend = $end . " " . $CFG_GLPI["planning_end"];
     // Use get method to check availability
     echo "<div class='center'><form method='GET' name='form' action='planning.php'>\n";
     echo "<table class='tab_cadre'>";
     echo "<tr class='tab_bg_1'><th colspan='2'>" . __('Availability') . "</th>";
     echo "<th colspan='3'>" . getUserName($who) . "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Start') . "</td>\n";
     echo "<td>";
     Html::showDateFormItem("begin", $begin, false);
     echo "</td>\n";
     echo "<td>" . __('End') . "</td>\n";
     echo "<td>";
     Html::showDateFormItem("end", $end, false);
     echo "</td>\n";
     echo "<td rowspan='2' class='center'>";
     echo "<input type='hidden' name='users_id' value=\"{$who}\">";
     echo "<input type='submit' class='submit' name='checkavailability' value=\"" . _sx('button', 'Search') . "\">";
     echo "</td>\n";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>\n";
     $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));
     // Print Headers
     echo "<tr class='tab_bg_1'><th width='15%'>&nbsp;</th>";
     for ($i = $begin_hour; $i < $end_hour; $i++) {
         $from = ($i < 10 ? '0' : '') . $i;
         //          $to   = ((($i+1) < 10)?'0':'').($i+1);
         echo "<th width='{$colsize}%' colspan='4'>" . $from . ":00</th>";
         $colnumber += 4;
     }
     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 "<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 "<td colspan='" . ($colnumber - 17) . "'>&nbsp;</td></tr>";
     echo "</table></div>";
 }
function displaySearchForm()
{
    global $_SERVER, $_GET, $CFG_GLPI;
    echo "<form action='" . $_SERVER["PHP_SELF"] . "' method='post'>";
    echo "<table class='tab_cadre' cellpadding='5'>";
    echo "<tr class='tab_bg_1' align='center'>";
    echo "<td>";
    echo __('Initial contract period') . " :";
    $values = array();
    $values["sup"] = ">";
    $values["inf"] = "<";
    $values["equal"] = "=";
    if (isset($_GET["contains"][1])) {
        if (strstr($_GET["contains"][1], "lt;")) {
            $_GET["dropdown_sup_inf"] = "inf";
            $_GET["dropdown_calendar"] = str_replace("lt;", "", $_GET["contains"][1]);
            $_GET["dropdown_calendar"] = str_replace("&", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("\\", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("'", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace(" 00:00:00", "", $_GET["dropdown_calendar"]);
            $_GET["contains"][1] = "<" . $_GET["dropdown_calendar"];
        }
        if (strstr($_GET["contains"][1], "gt;")) {
            $_GET["dropdown_sup_inf"] = "sup";
            $_GET["dropdown_calendar"] = str_replace("gt;", "", $_GET["contains"][1]);
            $_GET["dropdown_calendar"] = str_replace("&", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("\\", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("'", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace(" 00:00:00", "", $_GET["dropdown_calendar"]);
            $_GET["contains"][1] = ">" . $_GET["dropdown_calendar"];
        }
        if (strstr($_GET["contains"][1], "LIKE")) {
            $_GET["dropdown_sup_inf"] = "equal";
            $_GET["dropdown_calendar"] = str_replace("=", "", $_GET["contains"][1]);
            $_GET["dropdown_calendar"] = str_replace("&", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("\\", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("'", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("%", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("LIKE ", "", $_GET["dropdown_calendar"]);
            $_GET["contains"][1] = "LIKE '" . $_GET["dropdown_calendar"] . "%'";
        }
    }
    Dropdown::showFromArray("dropdown_sup_inf", $values, array('value' => isset($_GET["dropdown_sup_inf"]) ? $_GET["dropdown_sup_inf"] : "sup"));
    echo "</td>\n      <td width='120'>";
    Html::showDateFormItem("dropdown_calendar", isset($_GET["dropdown_calendar"]) ? $_GET["dropdown_calendar"] : 0);
    echo "</td>";
    echo "<td>" . __('Location') . "</td>";
    echo "<td>";
    Dropdown::show("Location", array('name' => "location", 'value' => isset($_GET["location"]) ? $_GET["location"] : ""));
    echo "</td>";
    // Display Reset search
    echo "<td>";
    echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/report/ports_date_connections.php?reset_search=reset_search' ><img title=\"" . __('Blank') . "\" alt=\"" . __('Blank') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/reset.png' class='calendrier'></a>";
    echo "</td>";
    echo "<td>";
    //Add parameters to uri to be saved as bookmarks
    $_SERVER["REQUEST_URI"] = buildBookmarkUrl($_SERVER["REQUEST_URI"], $_GET);
    Bookmark::showSaveButton(Bookmark::SEARCH, 'PluginFusioninventoryNetworkport2');
    echo "</td>";
    echo "<td>";
    echo "<input type='submit' value='Valider' class='submit' />";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    Html::closeForm();
}
Ejemplo n.º 15
0
 public function showForm($ID, $options = array())
 {
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     $order_order = new PluginOrderOrder();
     $order_order->getFromDB($this->getOrdersID());
     $order_reference = new PluginOrderReference();
     $order_reference->getFromDB($this->fields["plugin_order_references_id"]);
     $canedit = $order_order->can($this->getOrdersID(), UPDATE) && !$order_order->canUpdateOrder() && !$order_order->isCanceled();
     echo "<input type='hidden' name='plugin_order_orders_id' value='" . $this->getOrdersID() . "'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Reference") . ": </td>";
     echo "<td>";
     $data = array();
     $data["id"] = $this->fields["plugin_order_references_id"];
     $data["name"] = $order_reference->fields["name"];
     echo $order_reference->getReceptionReferenceLink($data);
     echo "</td>";
     echo "<td>" . __("Taken delivery", "order") . "</td>";
     echo "<td>";
     Dropdown::showYesNo('states_id', $this->fields['states_id']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Delivery form") . ": </td>";
     echo "<td>";
     if ($canedit) {
         Html::autocompletionTextField($this, "delivery_number");
     } else {
         echo $this->fields["delivery_number"];
     }
     echo "</td>";
     echo "<td>" . __("Delivery date") . ": </td>";
     echo "<td>";
     if ($canedit) {
         Html::showDateFormItem("delivery_date", $this->fields["delivery_date"], true, 1);
     } else {
         echo Html::convDate($this->fields["delivery_date"]);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Delivery status", "order") . ": </td>";
     echo "<td>";
     if ($canedit) {
         PluginOrderDeliveryState::Dropdown(array('name' => "plugin_order_deliverystates_id", 'value' => $this->fields["plugin_order_deliverystates_id"]));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_deliverystates", $this->fields["plugin_order_deliverystates_id"]);
     }
     echo "</td>";
     echo "<td>" . __("Bill", "order") . "</td>";
     echo "<td>";
     if (Session::haveRight("plugin_order_bill", UPDATE)) {
         PluginOrderBill::Dropdown(array('name' => "plugin_order_bills_id", 'value' => $this->fields["plugin_order_bills_id"]));
     } elseif (Session::haveRight("plugin_order_bill", UPDATE)) {
         echo Dropdown::getDropdownName("glpi_plugin_order_bills", $this->fields["plugin_order_bills_id"]);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td>";
     //comments of order
     echo __("Comments") . ": </td>";
     echo "<td colspan='3'>";
     if ($canedit) {
         echo "<textarea cols='100' rows='4' name='delivery_comment'>" . $this->fields["delivery_comment"] . "</textarea>";
     } else {
         echo $this->fields["delivery_comment"];
     }
     echo "</td>";
     echo "</tr>";
     $options['candel'] = false;
     $this->showFormButtons($options);
     return true;
 }
Ejemplo n.º 16
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $this->initForm($ID, $options);
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>";
     echo "<td>";
     $opt = array();
     if (isset($options['helpdesk_id']) && !empty($options['helpdesk_id'])) {
         $help = new $options['helpdesk_itemtype']();
         if ($help->getFromDB($options['helpdesk_id'])) {
             $opt['value'] = $help->fields["name"];
             echo "<input type='hidden' name='helpdesk_id' value='" . $options['helpdesk_id'] . "'>";
             echo "<input type='hidden' name='helpdesk_itemtype' value='" . $options['helpdesk_itemtype'] . "'>";
         }
     }
     Html::autocompletionTextField($this, "name", $opt);
     echo "</td>";
     //Projet parent
     echo "<td>" . __('Parent project', 'projet') . "</td>";
     echo "<td>";
     PluginProjetProjet_Projet::displayLinkedProjetsTo($ID, $options['withtemplate']);
     if ($this->canCreate() && $options['withtemplate'] < 2) {
         $rand_linked_projet = mt_rand();
         echo "&nbsp;";
         if (!PluginProjetProjet_Projet::getParentProjetsTo($ID)) {
             echo "<img onClick=\"Ext.get('linkedprojet{$rand_linked_projet}').setDisplayed('block')\"\n                       title=\"" . _x('button', 'Add') . "\" alt=\"" . _x('button', 'Add') . "\"\n                       class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         }
         echo "<div style='display:none' id='linkedprojet{$rand_linked_projet}'>";
         PluginProjetProjet_Projet::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : '');
         echo "&nbsp;";
         PluginProjetProjet_Projet::dropdownParent("_link[plugin_projet_projets_id_2]", isset($values["_link"]) ? $values["_link"]['plugin_projet_projets_id_2'] : '', array('id' => $this->fields["id"], 'entities_id' => $this->fields["entities_id"]));
         echo "<input type='hidden' name='_link[plugin_projet_projets_id_1]' value='{$ID}'>\n";
         echo "&nbsp;";
         echo "</div>";
         if (isset($values["_link"]) && !empty($values["_link"]['plugin_projet_projets_id_2'])) {
             echo "<script language='javascript'>Ext.get('linkedprojet{$rand_linked_projet}').\n                   setDisplayed('block');</script>";
         }
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td colspan='2'>" . _n('Responsible', 'Responsibles', 2, 'projet') . "</td>";
     echo "<td colspan='2'>" . __('Planification', 'projet') . "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('User') . "</td><td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Start date') . "</td><td>";
     Html::showDateFormItem("date_begin", $this->fields["date_begin"], true, true);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Group') . "</td><td>";
     Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('End date') . "</td><td>";
     Html::showDateFormItem("date_end", $this->fields["date_end"], true, true);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Estimated duration', 'projet');
     echo "</td>";
     echo "<td>";
     $toadd = array();
     for ($i = 9; $i <= 100; $i++) {
         $toadd[] = $i * DAY_TIMESTAMP;
     }
     Dropdown::showTimeStamp("estimatedtime", array('min' => 0, 'max' => 8 * DAY_TIMESTAMP, 'value' => $this->fields["estimatedtime"], 'addfirstminutes' => false, 'inhours' => false, 'toadd' => $toadd));
     echo "</td>\n";
     echo "<td>" . __('Effective duration', 'projet') . "&nbsp;";
     Html::showToolTip(nl2br(__('Total of effective duration of project tasks', 'projet')));
     echo "</td>";
     echo "<td>" . self::getProjectForecast($ID) . "</td></tr>";
     echo "<tr class='tab_bg_2'><td>";
     echo __('Estimated duration', 'projet') . "&nbsp;" . __('in hours', 'projet');
     echo "</td><td>";
     $time = floor($this->fields["estimatedtime"]);
     $out = Html::formatNumber($time / HOUR_TIMESTAMP, 2);
     echo sprintf(_n('%s hour', '%s hours', $out), $out);
     echo "</td><td>" . __('Linked tickets duration', 'projet') . "&nbsp;";
     Html::showToolTip(nl2br(__('Total of duration of linked tickets for project', 'projet')));
     echo "</td>";
     echo "<td>" . self::getProjectDuration($ID) . "</td></tr>";
     //status
     echo "<tr class='tab_bg_1'><td>" . __('State') . "</td><td>";
     Dropdown::show('PluginProjetProjetState', array('value' => $this->fields["plugin_projet_projetstates_id"]));
     echo "</td>";
     echo "<td>" . __('Display on the global Gantt', 'projet') . "</td><td>";
     Dropdown::showYesNo("show_gantt", $this->fields["show_gantt"]);
     echo "</td></tr>";
     //advance
     echo "<tr class='tab_bg_1'><td>" . __('Progress') . "</td><td>";
     $advance = floor($this->fields["advance"]);
     echo "<select name='advance'>";
     for ($i = 0; $i < 101; $i += 5) {
         echo "<option value='{$i}' ";
         if ($advance == $i) {
             echo "selected";
         }
         echo " >{$i}</option>";
     }
     echo "</select> %";
     echo "<td>" . __('Associable to a ticket') . "</td><td>";
     Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='4'>" . __('Comments') . "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='4'>";
     $value = $this->fields["comment"];
     if (isset($options['helpdesk_id']) && !empty($options['helpdesk_id'])) {
         $help = new $options['helpdesk_itemtype']();
         if ($help->getFromDB($options['helpdesk_id'])) {
             $value = $help->fields["content"];
         }
     }
     echo "<textarea cols='130' rows='4' name='comment' >" . $value . "</textarea>";
     echo "<input type='hidden' name='withtemplate' value='" . $options['withtemplate'] . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='4'>" . __('Description') . "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='4'>";
     echo "<textarea cols='130' rows='4' name='description' >" . $this->fields["description"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td>" . __('Send email', 'projet') . "</td><td>";
     echo "<input type='checkbox' name='send_notification' checked = true";
     echo " value='1'>";
     echo "</td>";
     echo "<td colspan='2'></td>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     if ((!isset($options['withtemplate']) || $options['withtemplate'] == 0) && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         printf(__('Created from the template %s'), $this->fields['template_name']);
         echo "</span>";
     } else {
         echo "&nbsp;";
     }
     echo "</td><td colspan='4'>";
     if (isset($options['withtemplate']) && $options['withtemplate']) {
         //TRANS: %s is the datetime of insertion
         printf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         //TRANS: %s is the datetime of update
         printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     echo "</td></tr>\n";
     echo "</tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
Ejemplo n.º 17
0
if (isset($_GET["date2"])) {
    $_POST["date2"] = $_GET["date2"];
}
if (empty($_POST["date1"]) && empty($_POST["date2"])) {
    $year = date("Y") - 1;
    $_POST["date1"] = date("Y-m-d", mktime(1, 0, 0, date("m"), date("d"), $year));
    $_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;
}
if (!isset($_GET["start"])) {
    $_GET["start"] = 0;
}
Stat::title();
echo "<div class='center'><form method='post' name='form' action='stat.item.php'>";
echo "<table class='tab_cadre'><tr class='tab_bg_2'>";
echo "<td class='right'>" . __('Start date') . "</td><td>";
Html::showDateFormItem("date1", $_POST["date1"]);
echo "</td><td rowspan='2' class='center'>";
echo "<input type='submit' class='submit' name='submit' value='" . __s('Display report') . "'></td></tr>";
echo "<tr class='tab_bg_2'><td class='right'>" . __('End date') . "</td><td>";
Html::showDateFormItem("date2", $_POST["date2"]);
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
Stat::showItems($_SERVER['PHP_SELF'], $_POST["date1"], $_POST["date2"], $_GET['start']);
Html::footer();
         $_GET["date"] = date("Y-m-d");
     }
     if (empty($_GET["locations_id"])) {
         $_GET["locations_id"] = 0;
     }
     if (!isset($_POST["date"])) {
         $_POST["date"] = $_GET["date"];
     }
     if (!isset($_POST["locations_id"])) {
         $_POST["locations_id"] = $_GET["locations_id"];
     }
     echo "<div align='center'><form action=\"./financialreport.php\" method=\"post\">";
     echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
     echo "<td class='right'>" . __('Report date', 'financialreports') . " :</td>";
     echo "<td>";
     Html::showDateFormItem("date", $_POST["date"], true, true);
     echo "</td>";
     echo "<td width='60%'>";
     Dropdown::show('Location', array('name' => "locations_id", 'value' => $_POST["locations_id"], 'entity' => $_SESSION["glpiactive_entity"]));
     echo "</td>";
     echo "<td rowspan='2' class='center'>";
     echo "<input type=\"submit\" class='submit' name=\"choice_date\" value='" . _sx('button', 'Post') . "' />";
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
     echo "<div align='center'>";
     $display = array('displaypc' => $_SESSION["displaypc"], 'displaynotebook' => $_SESSION["displaynotebook"], 'displayserver' => $_SESSION["displayserver"], 'displaymonitor' => $_SESSION["displaymonitor"], 'displayprinter' => $_SESSION["displayprinter"], 'displaynetworking' => $_SESSION["displaynetworking"], 'displayperipheral' => $_SESSION["displayperipheral"], 'displayphone' => $_SESSION["displayphone"], 'displaydisposal' => $_SESSION["displaydisposal"]);
     $report->displayReport($_POST, $display);
     echo "</div>";
 } else {
   function showSyntheseReport($componentscatalogs_id) {
      global $CFG_GLPI;

      if (!isset($_SESSION['glpi_plugin_monitoring']['synthese'])) {
         $_SESSION['glpi_plugin_monitoring']['synthese'] = array();
      }
      if (!isset($_SESSION['glpi_plugin_monitoring']['synthese'][$componentscatalogs_id])) {
         $_SESSION['glpi_plugin_monitoring']['synthese'][$componentscatalogs_id] = array();
      }
      $sess = $_SESSION['glpi_plugin_monitoring']['synthese'][$componentscatalogs_id];
      $pmComponentscatalog_Component = new PluginMonitoringComponentscatalog_Component();
      $pmComponent = new PluginMonitoringComponent();
      $a_options = array();

      $this->getFromDB($componentscatalogs_id);

      echo "<form name='form' method='post'
         action='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/report_componentscatalog.form.php'>";

      echo "<table class='tab_cadre_fixe'>";
      echo '<tr class="tab_bg_1">';
      echo '<th colspan="5">';
      echo __('Report');
      echo "<input type='hidden' name='componentscatalogs_id' value='".$componentscatalogs_id."' />";
      echo "<input type='hidden' name='reporttype' value='synthese' />";
      $a_options['componentscatalogs_id'] = $componentscatalogs_id;
      echo '</th>';
      echo '</tr>';

      echo '<tr class="tab_bg_1">';
      echo '<td>';
      echo '</td>';
      echo '<td colspan="2">';
      $default_value = 12;
      if (isset($sess['synthesenumber'])) {
         $default_value = $sess['synthesenumber'];
      }
      Dropdown::showNumber("synthesenumber", array(
                'value' => $default_value,
                'min'   => 2,
                'max'   => 30)
      );
      $a_options['synthesenumber'] = $default_value;
      echo "&nbsp;";
      $a_time = array('week' => __('Week'),
                      'month' => __('Month'),
                      'year' => __('Year'));
      $default_value = 'week';
      if (isset($sess['synthesenumber'])) {
         $default_value = $sess['synthesenumber'];
      }
      Dropdown::showFromArray("syntheseperiod", $a_time, array('value' => $default_value));
      $a_options['syntheseperiod'] = $default_value;
      echo '</td>';
      echo "<td>".__('End date')." :</td>";
      echo "<td>";
      $default_value = date('Y-m-d');
      if (isset($sess['synthesedate_end'])) {
         $default_value = $sess['synthesedate_end'];
      }
      Html::showDateFormItem("synthesedate_end", $default_value);
      $a_options['synthesedate_end'] = $default_value;
      echo "</td>";
      echo '</tr>';

      echo "</table>";

      echo "<table class='tab_cadre_fixe'>";
      $a_composants = $pmComponentscatalog_Component->find("`plugin_monitoring_componentscalalog_id`='".$componentscatalogs_id."'");
      foreach ($a_composants as $comp_data) {
         $pmComponent->getFromDB($comp_data['plugin_monitoring_components_id']);

         echo "<tr class='tab_bg_1'>";
         echo "<td width='10'>";
         //echo "<input type='checkbox' name='components_id[]' value='".$pmComponent->getID()."' checked />";
         echo "<input type='hidden' name='components_id[]' value='".$pmComponent->getID()."' />";
         $a_options['components_id'][] = $pmComponent->getID();
         echo "</td>";
         echo "<td>";
         echo $pmComponent->getLink();
         echo "</td>";
         echo "</tr>";

         echo "<tr class='tab_bg_1'>";
         echo "<td width='10'>";
         echo "</td>";
         echo "<td>";

         PluginMonitoringToolbox::loadPreferences($pmComponent->getID());

         $a_perfnames = PluginMonitoringServicegraph::getperfdataNames($pmComponent->fields['graph_template']);
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_3'>";
         echo "<td rowspan='".count($a_perfnames)."' width='90'>";
         echo __('Use for report', 'monitoring')."&nbsp;:";

         echo "</td>";
         $i = 0;
         $j = 0;
         if (!isset($_SESSION['glpi_plugin_monitoring']['perfname'][$pmComponent->getID()])) {
            foreach ($a_perfnames as $name) {
               $_SESSION['glpi_plugin_monitoring']['perfname'][$pmComponent->getID()][$name] = 'checked';
            }
         }

         foreach ($a_perfnames as $name) {
            if ($i > 0) {
               echo "<tr class='tab_bg_3'>";
            }
            echo "<td>";
            $checked = "checked";
            if (isset($sess['perfname'])
                 && isset($sess['perfname'][$pmComponent->getID()])) {

               if (isset($sess['perfname'][$pmComponent->getID()])) {
                  $checked = "";
               }
               if (isset($sess['perfname'][$pmComponent->getID()][$name])) {
                  $checked = "checked";
               }
            } else {
               if (isset($_SESSION['glpi_plugin_monitoring']['perfname'][$pmComponent->getID()])) {
                  $checked = "";
               }
               if (isset($_SESSION['glpi_plugin_monitoring']['perfname'][$pmComponent->getID()][$name])) {
                  $checked = $_SESSION['glpi_plugin_monitoring']['perfname'][$pmComponent->getID()][$name];
               }
            }
            echo "<input type='checkbox' name='perfname[".$pmComponent->getID()."][".$name."]' value='".$name."' ".$checked."/> ".$name;
            if ($checked == 'checked') {
               $a_options['perfname'][$pmComponent->getID()][] = $name;
            }
            echo "</td>";
            echo "<td>";
            echo __('Best is high value', 'monitoring').' :';
            echo "</td>";
            echo "<td>";
            $default_value = 1;
            if (isset($sess['perfname_val'])
                 && isset($sess['perfname_val'][$pmComponent->getID()])) {

               if (isset($sess['perfname_val'][$pmComponent->getID()][$name])) {
                  $default_value = $sess['perfname_val'][$pmComponent->getID()][$name];
               }
            }
            Dropdown::showYesNo('perfname_val['.$pmComponent->getID().']['.$name.']', $default_value);
            if ($checked == 'checked') {
               $a_options['perfname_val'][$pmComponent->getID()][$name] = $default_value;
            }
            echo "</td>";
            echo "</tr>";
            $i++;
         }

         echo "</table>";

         echo "</td>";

         echo "</tr>";
      }
      echo "<tr class='tab_bg_1'>";
      echo "<td colspan='2' align='center'>";
      echo "<input type='submit' class='submit' name='update' value='".__('Save')."'/>";
      echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <input type='submit' class='submit' name='generatepdf' value='".__('Generate PDF', 'monitoring')."'/>";
      echo "</td>";
      echo "</tr>";
      echo "</table>";

      Html::closeForm();

      if (isset($_SESSION['plugin_monitoring_report'])) {
//         $a_options = $_SESSION['plugin_monitoring_report'];
      }
      $this->generateSyntheseReport(
              $_SESSION['glpi_plugin_monitoring']['synthese'][$componentscatalogs_id],
              FALSE);
   }
Ejemplo n.º 20
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'), 'w');
     $cartitem = new CartridgeItem();
     $cartitem->getFromDB($this->getField('cartridgeitems_id'), 'w');
     $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::showDateFormItem("date_use", $this->fields["date_use"], false, true, $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::showDateFormItem("date_out", $this->fields["date_out"], false, true, $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;
 }
Ejemplo n.º 21
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);
     $can_edit = $this->can($ID, 'w');
     $this->showTabs($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::showDateFormItem("begin_date", $this->fields["begin_date"]);
     echo "</td>";
     echo "<td>" . __('Initial contract period') . "</td><td>";
     Dropdown::showInteger("duration", $this->fields["duration"], 1, 120, 1, array(0 => Dropdown::EMPTY_VALUE), array('unit' => 'month'));
     if (!empty($this->fields["begin_date"])) {
         echo " -> " . Infocom::getWarrantyExpir($this->fields["begin_date"], $this->fields["duration"], 0, true);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Notice') . "</td><td>";
     Dropdown::showInteger("notice", $this->fields["notice"], 0, 120, 1, array(), 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::showInteger("periodicity", $this->fields["periodicity"], 12, 60, 12, 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)), array('unit' => 'month'));
     echo "</td>";
     echo "<td>" . __('Invoice period') . "</td>";
     echo "<td>";
     Dropdown::showInteger("billing", $this->fields["billing"], 12, 60, 12, 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)), array('unit' => 'month'));
     echo "</td>";
     echo "</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::showInteger("max_links_allowed", $this->fields["max_links_allowed"], 1, 200, 1, array(0 => __('Unlimited')));
     echo "</td>";
     echo "</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'>" . __('Start') . "&nbsp;";
     Dropdown::showHours("week_begin_hour", $this->fields["week_begin_hour"]);
     echo "<span class='small_space'>" . __('End') . "</span>&nbsp;";
     Dropdown::showHours("week_end_hour", $this->fields["week_end_hour"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('on Saturday') . "</td>";
     echo "<td colspan='3'>";
     Dropdown::showYesNo("use_saturday", $this->fields["use_saturday"]);
     echo "<span class='small_space'>" . __('Start') . "</span>&nbsp;";
     Dropdown::showHours("saturday_begin_hour", $this->fields["saturday_begin_hour"]);
     echo "<span class='small_space'>" . __('End') . "</span>&nbsp;";
     Dropdown::showHours("saturday_end_hour", $this->fields["saturday_end_hour"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Sundays and holidays') . "</td>";
     echo "<td colspan='3'>";
     Dropdown::showYesNo("use_monday", $this->fields["use_monday"]);
     echo "<span class='small_space'>" . __('Start') . "</span>&nbsp;";
     Dropdown::showHours("monday_begin_hour", $this->fields["monday_begin_hour"]);
     echo "<span class='small_space'>" . __('End') . "</span>&nbsp;";
     Dropdown::showHours("monday_end_hour", $this->fields["monday_end_hour"]);
     echo "</td></tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
Ejemplo n.º 22
0
 static function prepareHtmlFields($fields, $items_id, $canedit = true, $show_table = true, $massiveaction = false)
 {
     if (empty($fields)) {
         return false;
     }
     //get object associated with this fields
     $tmp = $fields;
     $first_field = array_shift($tmp);
     $container_obj = new PluginFieldsContainer();
     $container_obj->getFromDB($first_field['plugin_fields_containers_id']);
     $items_itemtype = ucfirst($container_obj->fields['itemtype']);
     $classname = "PluginFields" . $items_itemtype . preg_replace('/s$/', '', $container_obj->fields['name']);
     $obj = new $classname();
     //find row for this object with the items_id
     $found_values = $obj->find("plugin_fields_containers_id = " . $first_field['plugin_fields_containers_id'] . " AND items_id = " . $items_id);
     $found_v = array_shift($found_values);
     // find profiles (to check if current profile can edit fields)
     $fprofile = new PluginFieldsProfile();
     $found_p = $fprofile->find("`profiles_id` = '" . $_SESSION['glpiactiveprofile']['id'] . "'\n                                  AND `plugin_fields_containers_id` = '" . $first_field['plugin_fields_containers_id'] . "'");
     $first_found_p = array_shift($found_p);
     // test status for "CommonITILObject" objects
     if (is_subclass_of($items_itemtype, "CommonITILObject")) {
         $items_obj = new $items_itemtype();
         $items_obj->getFromDB($items_id);
         if (in_array($items_obj->fields['status'], $items_obj->getClosedStatusArray()) || in_array($items_obj->fields['status'], $items_obj->getSolvedStatusArray()) || $first_found_p['right'] != CREATE) {
             $canedit = false;
         }
     }
     //show all fields
     $html = "";
     $odd = 0;
     foreach ($fields as $field) {
         if ($field['type'] === 'header') {
             $html .= "<tr class='tab_bg_2'>";
             $html .= "<th colspan='4'>" . $field['label'] . "</td>";
             $html .= "</tr>";
             $odd = 0;
         } else {
             //get value
             $value = "";
             if (is_array($found_v)) {
                 if ($field['type'] == "dropdown") {
                     $value = $found_v["plugin_fields_" . $field['name'] . "dropdowns_id"];
                 } else {
                     $value = $found_v[$field['name']];
                 }
             }
             if (isset($_SESSION['plugin']['fields']['values_sent'])) {
                 if ($field['type'] == "dropdown") {
                     $value = $_SESSION['plugin']['fields']['values_sent']["plugin_fields_" . $field['name'] . "dropdowns_id"];
                 } else {
                     $value = $_SESSION['plugin']['fields']['values_sent'][$field['name']];
                 }
             }
             //get default value
             if (empty($value) && !empty($field['default_value'])) {
                 $value = $field['default_value'];
             }
             //show field
             if ($show_table) {
                 if ($odd % 2 == 0) {
                     $html .= "<tr class='tab_bg_2'>";
                 }
                 $required = $field['mandatory'] == 1 ? "<span class='red'>*</span>" : '';
                 if ($container_obj->fields['itemtype'] == 'Ticket' && $container_obj->fields['type'] == 'dom' && strpos($_SERVER['HTTP_REFERER'], ".injector.php") === false && strpos($_SERVER['HTTP_REFERER'], ".public.php") === false) {
                     $html .= "<th width='13%'>" . $field['label'] . " : {$required}</th>";
                 } else {
                     $html .= "<td>" . $field['label'] . " : {$required}</td>";
                 }
                 $html .= "<td>";
             }
             $readonly = $field['is_readonly'];
             switch ($field['type']) {
                 case 'number':
                 case 'text':
                     $value = Html::cleanInputText($value);
                     if ($canedit && !$readonly) {
                         $html .= "<input type='text' name='" . $field['name'] . "' value=\"{$value}\" />";
                     } else {
                         $html .= $value;
                     }
                     break;
                 case 'textarea':
                     if ($massiveaction) {
                         continue;
                     }
                     if ($canedit && !$readonly) {
                         $html .= "<textarea cols='45' rows='4' name='" . $field['name'] . "'>" . "{$value}</textarea>";
                     } else {
                         $html .= nl2br($value);
                     }
                     break;
                 case 'dropdown':
                     if ($canedit && !$readonly) {
                         //find entity on current object
                         $obj = new $container_obj->fields['itemtype']();
                         $obj->getFromDB($items_id);
                         ob_start();
                         if (strpos($field['name'], "dropdowns_id") !== false) {
                             $dropdown_itemtype = getItemTypeForTable(getTableNameForForeignKeyField($field['name']));
                         } else {
                             $dropdown_itemtype = PluginFieldsDropdown::getClassname($field['name']);
                         }
                         Dropdown::show($dropdown_itemtype, array('value' => $value, 'entity' => $obj->getEntityID()));
                         $html .= ob_get_contents();
                         ob_end_clean();
                     } else {
                         $dropdown_table = "glpi_plugin_fields_" . $field['name'] . "dropdowns";
                         $html .= Dropdown::getDropdownName($dropdown_table, $value);
                     }
                     break;
                 case 'yesno':
                     //in massive action, we must skip display for yesno (possible bug in framework)
                     //otherwise double display of field
                     if ($massiveaction) {
                         continue;
                     }
                     if ($canedit && !$readonly) {
                         ob_start();
                         Dropdown::showYesNo($field['name'], $value);
                         $html .= ob_get_contents();
                         ob_end_clean();
                     } else {
                         $html .= Dropdown::getYesNo($value);
                     }
                     break;
                 case 'date':
                     if ($massiveaction) {
                         continue;
                     }
                     if ($canedit && !$readonly) {
                         ob_start();
                         Html::showDateFormItem($field['name'], $value);
                         $html .= ob_get_contents();
                         ob_end_clean();
                     } else {
                         $html .= Html::convDate($value);
                     }
                     break;
                 case 'datetime':
                     if ($massiveaction) {
                         continue;
                     }
                     if ($canedit && !$readonly) {
                         ob_start();
                         Html::showDateTimeFormItem($field['name'], $value);
                         $html .= ob_get_contents();
                         ob_end_clean();
                     } else {
                         $html .= Html::convDateTime($value);
                     }
                 case 'dropdownuser':
                     if ($massiveaction) {
                         continue;
                     }
                     if ($canedit && !$readonly) {
                         ob_start();
                         User::dropdown(array('name' => $field['name'], 'value' => $value, 'entity' => -1, 'right' => 'all', 'condition' => 'is_active=1 && is_deleted=0'));
                         $html .= ob_get_contents();
                         ob_end_clean();
                     } else {
                         $showuserlink = 0;
                         if (Session::haveRight('user', 'r')) {
                             $showuserlink = 1;
                         }
                         $html .= getUserName($value, $showuserlink);
                     }
             }
             if ($show_table) {
                 $html .= "</td>";
                 if ($odd % 2 == 1) {
                     $html .= "</tr>";
                 }
                 $odd++;
             }
         }
     }
     if ($show_table && $odd % 2 == 1) {
         $html .= "</tr>";
     }
     unset($_SESSION['plugin']['fields']['values_sent']);
     return $html;
 }
Ejemplo n.º 23
0
 public function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     $rand = mt_rand();
     $config = PluginOrderConfig::getConfig();
     $user = new User();
     if (isset($options['withtemplate']) && $options['withtemplate'] == 2) {
         $template = "newcomp";
         $datestring = sprintf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } elseif (isset($options['withtemplate']) && $options['withtemplate'] == 1) {
         $template = "newtemplate";
         $datestring = sprintf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         $template = false;
         $datestring = sprintf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     $canedit = $this->canUpdateOrder() && $this->canUpdate() && !$this->isCanceled();
     $cancancel = self::canCancel() && $this->can($ID, UPDATE) && $this->isCanceled();
     $options['canedit'] = $canedit;
     $options['candel'] = $cancancel;
     if ($template) {
         $this->fields['order_date'] = NULL;
     }
     // Displaying OVER BUDGET ALERT
     if ($this->fields['budgets_id'] > 0) {
         self::displayAlertOverBudget(self::isOverBudget($ID));
     }
     //Display without inside table
     /* title */
     echo "<tr class='tab_bg_1'><td>" . __("Order name", "order") . "*: </td>";
     echo "<td>";
     if ($canedit) {
         $objectName = autoName($this->fields["name"], "name", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
         Html::autocompletionTextField($this, "name", array('value' => $objectName));
     } else {
         echo $this->fields["name"];
     }
     echo "</td>";
     /* date of order */
     echo "<td>" . __("Date of order", "order") . ":</td><td>";
     if ($canedit) {
         if ($this->fields["order_date"] == NULL) {
             Html::showDateFormItem("order_date", date("Y-m-d"), true, true);
         } else {
             Html::showDateFormItem("order_date", $this->fields["order_date"], true, true);
         }
     } else {
         echo Html::convDate($this->fields["order_date"]);
     }
     echo "</td></tr>";
     /* num order */
     echo "<tr class='tab_bg_1'><td>" . __("Order number", "order");
     if ($ID > 0) {
         echo "*";
     } else {
         echo " <span class='red'>*</span>";
     }
     echo ": </td>";
     echo "<td>";
     if ($canedit) {
         $objectOrder = autoName($this->fields["num_order"], "num_order", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
         Html::autocompletionTextField($this, "num_order", array('value' => $objectOrder));
     } else {
         echo $this->fields["num_order"];
     }
     echo "</td>";
     /* type order */
     echo "<td>" . __("Type") . ": </td><td>";
     if ($canedit) {
         PluginOrderOrderType::Dropdown(array('name' => "plugin_order_ordertypes_id", 'value' => $this->fields["plugin_order_ordertypes_id"]));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_ordertypes", $this->fields["plugin_order_ordertypes_id"]);
     }
     echo "</td></tr>";
     /* state */
     echo "<tr class='tab_bg_1'><td>" . __("Order status", "order") . ": </td>";
     echo "<td>";
     if (!$this->getID()) {
         $state = $config->getDraftState();
     } else {
         $state = $this->fields["plugin_order_orderstates_id"];
     }
     if ($canedit) {
         PluginOrderOrderState::Dropdown(array('name' => "plugin_order_orderstates_id", 'value' => $state));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_orderstates", $this->getState());
     }
     echo "</td>";
     /* budget */
     echo "<td>" . __("Budget") . ": </td>";
     echo "<td>";
     if ($canedit) {
         if ($config->canHideInactiveBudgets()) {
             $restrict = " (`end_date` IS NULL) OR (`end_date`> '" . date("Y-m-d") . "')";
         } else {
             $restrict = "";
         }
         Budget::Dropdown(array('name' => "budgets_id", 'value' => $this->fields["budgets_id"], 'entity' => $this->fields["entities_id"], 'comments' => true, 'condition' => $restrict, 'width' => '150px'));
     } else {
         $budget = new Budget();
         if ($this->fields["budgets_id"] > 0 && $budget->can($this->fields["budgets_id"], READ)) {
             echo $budget->getLink();
         } else {
             echo Dropdown::getDropdownName("glpi_budgets", $this->fields["budgets_id"]);
         }
     }
     echo "</td></tr>";
     /* location */
     echo "<tr class='tab_bg_1'><td>" . __("Delivery location", "order") . ": </td>";
     echo "<td>";
     if ($canedit) {
         Location::Dropdown(array('name' => "locations_id", 'value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     } else {
         echo Dropdown::getDropdownName("glpi_locations", $this->fields["locations_id"]);
     }
     echo "</td>";
     /* payment */
     echo "<td>" . __("Payment conditions", "order") . ": </td><td>";
     if ($canedit) {
         PluginOrderOrderPayment::Dropdown(array('name' => "plugin_order_orderpayments_id", 'value' => $this->fields["plugin_order_orderpayments_id"]));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_orderpayments", $this->fields["plugin_order_orderpayments_id"]);
     }
     echo "</td>";
     echo "</tr>";
     /* supplier of order */
     echo "<tr class='tab_bg_1'><td>" . __("Supplier") . ": </td>";
     echo "<td>";
     if ($canedit && !$this->checkIfDetailExists($ID)) {
         $rand = mt_rand();
         Supplier::dropdown(array('name' => "suppliers_id", 'rand' => $rand, 'value' => $this->fields["suppliers_id"], 'entity' => $this->fields["entities_id"]));
         $params = array('suppliers_id' => '__VALUE__', 'fieldname' => 'contacts_id');
         Ajax::updateItemOnSelectEvent("dropdown_suppliers_id{$rand}", "show_contacts_id{$rand}", "../ajax/dropdownSupplier.php", $params);
     } else {
         $supplier = new Supplier();
         if ($supplier->can($this->fields['suppliers_id'], READ)) {
             echo $supplier->getLink();
         } else {
             echo Dropdown::getDropdownName("glpi_suppliers", $this->fields["suppliers_id"]);
         }
     }
     echo "</td>";
     /* port price */
     echo "<td>" . __("Postage", "order") . ": </td>";
     echo "<td>";
     if ($canedit) {
         echo "<input type='number' step='" . PLUGIN_ORDER_NUMBER_STEP . "' name='port_price' size='5'" . " value=\"" . Html::formatNumber($this->fields["port_price"], true) . "\">";
     } else {
         echo Html::formatNumber($this->fields["port_price"]);
     }
     echo "</td>";
     echo "</tr>";
     /* linked contact of the supplier of order */
     echo "<tr class='tab_bg_1'><td>" . __("Contact") . ": </td>";
     echo "<td><span id='show_contacts_id'>";
     if ($canedit) {
         echo "<span id='show_contacts_id{$rand}'>";
         // Make a select box
         $query = "SELECT c.`id`, c.`name`, c.`firstname`\n                   FROM `glpi_contacts` c\n                   LEFT JOIN `glpi_contacts_suppliers` s ON (s.`contacts_id` = c.`id`)\n                   WHERE s.`suppliers_id` = '{$this->fields['suppliers_id']}'\n                   ORDER BY c.`name`";
         $result = $DB->query($query);
         $number = $DB->numrows($result);
         $values = array(0 => Dropdown::EMPTY_VALUE);
         if ($number) {
             while ($data = $DB->fetch_assoc($result)) {
                 $values[$data['id']] = formatUserName('', '', $data['name'], $data['firstname']);
             }
         }
         Dropdown::showFromArray("contacts_id", $values, array('value' => $this->fields['contacts_id'], 'rand' => $rand));
         echo "</span>\n";
     } else {
         echo Dropdown::getDropdownName("glpi_contacts", $this->fields["contacts_id"]);
     }
     echo "</span></td>";
     /* tva port price */
     echo "<td>" . __("VAT", "order") . " " . __("Postage", "order") . ": </td><td>";
     $PluginOrderConfig = new PluginOrderConfig();
     $default_taxes = $PluginOrderConfig->getDefaultTaxes();
     $taxes = empty($ID) || $ID < 0 ? $default_taxes : $this->fields["plugin_order_ordertaxes_id"];
     if ($canedit) {
         PluginOrderOrderTax::Dropdown(array('name' => "plugin_order_ordertaxes_id", 'value' => $taxes, 'display_emptychoice' => true, 'emptylabel' => __("No VAT", "order")));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $taxes);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Associable to a ticket") . "&nbsp;:</td><td>";
     if ($canedit) {
         Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     } else {
         echo Dropdown::getYesNo($this->fields['is_helpdesk_visible']);
     }
     echo "</td>";
     echo "<td>";
     echo __("Estimated due date", "order") . ":";
     if ($this->isDelivered() && $this->fields['deliverydate']) {
         echo "<br/>" . __("Delivery date") . ":";
     }
     echo " </td><td>";
     if ($canedit) {
         if ($this->fields["duedate"] == NULL) {
             Html::showDateFormItem("duedate", '', true, true);
         } else {
             Html::showDateFormItem("duedate", $this->fields["duedate"], true, true);
         }
     } else {
         echo Html::convDate($this->fields["duedate"]);
     }
     if ($this->shouldBeAlreadyDelivered()) {
         echo "<br/><span class='red'>" . __("Due date overtaken", "order") . "</span>";
     }
     if ($this->isDelivered() && $this->fields['deliverydate']) {
         echo "<br/>" . Html::convDate($this->fields['deliverydate']);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' class='center'>" . $datestring;
     if (!$template && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>(" . __("Template name") . "&nbsp;: " . $this->fields['template_name'] . ")</span>";
     }
     echo "</td><td colspan='2'></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     //comments of order
     echo "<td>" . __("Comments") . ":  </td>";
     echo "<td colspan='3' align='center'>";
     if ($canedit) {
         echo "<textarea cols='40' rows='3' name='comment'>" . $this->fields["comment"] . "</textarea>";
     } else {
         echo $this->fields["comment"];
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='2'>" . __("Actor") . "</th>";
     if ($ID > 0 && !$template) {
         echo "<th colspan='2'>" . __("Cost") . "</th></tr>";
     } else {
         echo "<th colspan='2'></th>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2'>";
     echo "<table class='format'>";
     echo "<tr class='tab_bg_1'><td>" . __("Author") . ":</td><td style='width: 170px;'>";
     if ($canedit) {
         if ($template == 'newcomp') {
             $value = Session::getLoginUserID();
         } else {
             $value = $this->fields['users_id'];
         }
         User::Dropdown(array('name' => 'users_id', 'value' => $value, 'right' => 'interface', 'entity' => $this->fields["entities_id"], 'width' => '150px'));
     } else {
         if ($this->fields['users_id']) {
             $output = "";
             if ($user->getFromDB($this->fields['users_id'])) {
                 $output = formatUserName($this->fields['users_id'], $user->fields['name'], $user->fields['realname'], $user->fields['firstname']);
             }
             echo $output;
         }
     }
     echo "</td>";
     echo "<td>" . __("Author group", "order") . ":</td>";
     echo "<td style='width: 180px;'>";
     if ($canedit) {
         if (empty($ID) || $ID < 0) {
             if (!empty($this->fields['groups_id'])) {
                 $groups_id = $this->fields['groups_id'];
             } else {
                 $groups_id = $config->getDefaultAuthorGroup();
             }
         } else {
             $groups_id = $this->fields['groups_id'];
         }
         Group::Dropdown(array('value' => $groups_id, 'width' => '150px'));
     } else {
         echo Dropdown::getDropdownName('glpi_groups', $this->fields['groups_id']);
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Recipient") . ":</td>";
     echo "<td style='width: 170px;'>";
     if ($canedit) {
         if (empty($ID) || $ID < 0) {
             if (!empty($this->fields['users_id_delivery'])) {
                 $users_id = $this->fields['users_id_delivery'];
             } else {
                 $users_id = $config->getDefaultRecipient();
             }
         } else {
             $users_id = $this->fields['users_id_delivery'];
         }
         User::Dropdown(array('name' => 'users_id_delivery', 'value' => $users_id, 'right' => 'all', 'entity' => $this->fields["entities_id"], 'width' => '150px'));
     } else {
         if ($this->fields['users_id_delivery']) {
             $user->getFromDB($this->fields['users_id_delivery']);
             $output = formatUserName($this->fields['users_id'], $user->fields['name'], $user->fields['realname'], $user->fields['firstname']);
             echo $output;
         }
     }
     echo "</td>";
     echo "<td>" . __("Recipient group", "order") . ":</td>";
     echo "<td style='width: 180px;'>";
     if ($canedit) {
         if (empty($ID) || $ID < 0) {
             if (!empty($this->fields['groups_id_delivery'])) {
                 $groups_id = $this->fields['groups_id_delivery'];
             } else {
                 $groups_id = $config->getDefaultRecipientGroup();
             }
         } else {
             $groups_id = $this->fields['groups_id_delivery'];
         }
         Group::Dropdown(array('name' => 'groups_id_delivery', 'value' => $groups_id, 'width' => '150px'));
     } else {
         echo Dropdown::getDropdownName('glpi_groups', $this->fields['groups_id_delivery']);
     }
     echo "</td>";
     echo "</tr></table></td>";
     echo "<td colspan='2'>";
     if ($ID > 0 && !$template) {
         $PluginOrderOrder_Item = new PluginOrderOrder_Item();
         $prices = $PluginOrderOrder_Item->getAllPrices($ID);
         echo "<table class='format'>";
         echo "<tr>";
         echo "<td>" . __("Price tax free", "order") . "</td>";
         echo "<td>" . Html::formatNumber($prices["priceHT"]) . "</td>";
         echo "</tr>";
         // total price (with postage)
         $postagewithTVA = $PluginOrderOrder_Item->getPricesATI($this->fields["port_price"], Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $this->fields["plugin_order_ordertaxes_id"]));
         $priceHTwithpostage = $prices["priceHT"] + $this->fields["port_price"];
         echo "<tr>";
         echo "<td>" . __("Price tax free with postage", "order") . "</td>";
         echo "<td>" . Html::formatNumber($priceHTwithpostage) . "</td>";
         echo "</tr>";
         // total price (with taxes)
         $total = $prices["priceTTC"] + $postagewithTVA;
         echo "<tr>";
         echo "<td>" . __("Price ATI", "order") . "</td>";
         echo "<td>" . Html::formatNumber($total) . "</td>";
         echo "</tr>";
         // total TVA
         $total_tva = $prices["priceTVA"] + ($postagewithTVA - $this->fields["port_price"]);
         echo "<tr>";
         echo "<td>" . __("VAT", "order") . "</td>";
         echo "<td>" . Html::formatNumber($total_tva) . "</td>";
         echo "</tr>";
         echo "</table>";
     }
     echo "</td>";
     echo "</tr>";
     if ($canedit || $cancancel) {
         $this->showFormButtons($options);
     } else {
         echo "</table></div>";
         Html::closeForm();
     }
     return true;
 }
Ejemplo n.º 24
0
 function displayField($canedit, $name, $value, $template, $description = array())
 {
     global $GO_BLACKLIST_FIELDS;
     $searchoption = PluginGenericobjectField::getOptionsWithGlobal($name, get_called_class());
     if (!empty($searchoption) && !in_array($name, self::getFieldsToHide())) {
         $this->startColumn();
         echo $searchoption['name'];
         if (isset($searchoption['autoname']) && $searchoption['autoname'] && $template) {
             echo "*&nbsp;";
         }
         $this->endColumn();
         $this->startColumn();
         switch ($description['Type']) {
             case "int(11)":
                 $fk_table = getTableNameForForeignKeyField($name);
                 if ($fk_table != '') {
                     $itemtype = getItemTypeForTable($fk_table);
                     $dropdown = new $itemtype();
                     $parameters = array('name' => $name, 'value' => $value, 'comments' => true);
                     if ($dropdown->isEntityAssign()) {
                         $parameters["entity"] = $this->fields['entities_id'];
                     }
                     if ($dropdown->maybeRecursive()) {
                         $parameters['entity_sons'] = true;
                     }
                     if (isset($searchoption['condition'])) {
                         $parameters['condition'] = $searchoption['condition'];
                     }
                     Dropdown::show($itemtype, $parameters);
                 } else {
                     $min = $max = $step = 0;
                     if (isset($searchoption['min'])) {
                         $min = $searchoption['min'];
                     } else {
                         $min = 0;
                     }
                     if (isset($searchoption['max'])) {
                         $max = $searchoption['max'];
                     } else {
                         $max = 100;
                     }
                     if (isset($searchoption['step'])) {
                         $step = $searchoption['step'];
                     } else {
                         $step = 1;
                     }
                     Dropdown::showInteger($name, $value, $min, $max, $step);
                 }
                 break;
             case "tinyint(1)":
                 Dropdown::showYesNo($name, $value);
                 break;
             case "varchar(255)":
                 if (isset($searchoption['autoname']) && $searchoption['autoname']) {
                     $objectName = autoName($this->fields[$name], $name, $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
                 } else {
                     $objectName = $this->fields[$name];
                 }
                 Html::autocompletionTextField($this, $name, array('value' => $objectName));
                 break;
             case "longtext":
             case "text":
                 echo "<textarea cols='40' rows='4' name='" . $name . "'>" . $value . "</textarea>";
                 break;
             case "date":
                 Html::showDateFormItem($name, $value, false, true);
                 break;
             case "datetime":
                 Html::showDateTimeFormItem($name, $value, false, true);
                 break;
             default:
             case "float":
                 echo "<input type='text' name='{$name}' value='{$value}'>";
                 break;
             case 'decimal':
                 echo "<input type='text' name='{$name}' value='" . Html::formatNumber($value) . "'>";
                 break;
         }
         $this->endColumn();
     }
 }
Ejemplo n.º 25
0
 function displayAnswertype($type, $name)
 {
     echo "<td>";
     if ($type != '') {
         //echo "<tr class='tab_bg_1'>";
         switch ($type) {
             case 'shorttext':
                 echo "<input type='text' name='" . $name . "' value='' size='71'/>";
                 break;
             case 'longtext':
                 echo "<textarea name='" . $name . "' cols='70'></textarea>";
                 break;
             case 'date':
                 Html::showDateFormItem($name, '', true);
                 break;
             case 'number':
                 break;
         }
     }
     echo "</td>";
 }
 function showForm($ID, $options = array())
 {
     $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>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => "users_id_tech", 'value' => $this->fields["users_id_tech"], 'entity' => $this->fields["entities_id"], 'right' => 'interface'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Type') . "</td><td>";
     Dropdown::show('PluginCertificatesCertificateType', array('name' => "plugin_certificates_certificatetypes_id", 'value' => $this->fields["plugin_certificates_certificatetypes_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     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 "</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>";
     echo "<td>" . _n('Manufacturer', 'Manufacturers', 1) . " (" . __('Root CA', 'certificates') . ")</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('DNS name', 'certificates') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "dns_name");
     echo "</td>";
     echo "<td>" . __('Creation date') . "</td>";
     echo "<td>";
     Html::showDateFormItem("date_query", $this->fields["date_query"], true, true);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('DNS suffix', 'certificates') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "dns_suffix");
     echo "</td>";
     echo "<td>" . __('Expiration date');
     echo "&nbsp;";
     Html::showToolTip(nl2br(__('Empty for infinite', 'certificates')));
     echo "&nbsp;</td>";
     echo "<td>";
     Html::showDateFormItem("date_expiration", $this->fields["date_expiration"], true, true);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . PluginCertificatesCertificateState::getTypeName(1) . "</td>";
     echo "<td>";
     Dropdown::show('PluginCertificatesCertificateState', array('name' => "plugin_certificates_certificatestates_id", 'value' => $this->fields["plugin_certificates_certificatestates_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Notification email', 'certificates') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('mailing', $this->fields["mailing"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Self-signed', 'certificates') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('auto_sign', $this->fields["auto_sign"]);
     echo "</td>";
     echo "<td>" . __('Associable to a ticket') . "</td><td>";
     Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo __('Command used', 'certificates') . "</td><td>";
     echo "<textarea cols='35' rows='4' name='command' >";
     echo $this->fields["command"] . "</textarea>";
     echo "</td>";
     echo "<td>";
     echo __('Certificate request (CSR)', 'certificates') . "</td><td>";
     echo "<textarea cols='35' rows='4' name='certificate_request' >";
     echo $this->fields["certificate_request"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td class='center' colspan='2'>";
     printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     echo "</td>";
     echo "<td>";
     echo self::getTypeName(1) . "</td><td>";
     echo "<textarea cols='35' rows='4' name='certificate_item' >";
     echo $this->fields["certificate_item"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
Ejemplo n.º 27
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $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>" . _n('Context', 'Contexts', 1, 'tasklists') . "</td><td>";
     Dropdown::show('PluginTasklistsTaskType', array('name' => "plugin_tasklists_tasktypes_id", 'value' => $this->fields["plugin_tasklists_tasktypes_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Priority') . "</td>";
     echo "<td>";
     CommonITILObject::dropdownPriority(array('value' => $this->fields['priority'], 'withmajor' => 1));
     echo "</td>";
     echo "<td>" . __('Planned duration') . "</td>";
     echo "<td>";
     $toadd = array();
     //for ($i=9 ; $i<=100 ; $i++) {
     //   $toadd[] = $i*HOUR_TIMESTAMP;
     //}
     Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 50 * DAY_TIMESTAMP, 'step' => DAY_TIMESTAMP, 'value' => $this->fields["actiontime"], 'toadd' => $toadd));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Visibility') . "</td>";
     echo "<td>";
     self::dropdownVisibility(array('value' => $this->fields['visibility']));
     echo "</td>";
     echo "<td>" . __('Due date');
     echo "&nbsp;";
     Html::showToolTip(nl2br(__('Empty for infinite', 'tasklists')));
     echo "</td>";
     echo "<td>";
     Html::showDateFormItem("due_date", $this->fields["due_date"], true, true);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td><td>";
     User::dropdown(array('name' => "users_id", 'value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Percent done') . "</td>";
     echo "<td>";
     Dropdown::showNumber("percent_done", array('value' => $this->fields['percent_done'], 'min' => 0, 'max' => 100, 'step' => 20, 'unit' => '%'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Dropdown::show('Group', array('name' => "groups_id", 'value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Status') . "</td><td>";
     Planning::dropdownState("state", $this->fields["state"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo __('Description') . "</td>";
     echo "<td colspan = '3' class='center'>";
     echo "<textarea cols='100' rows='15' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
Ejemplo n.º 28
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $this->initForm($ID, $options);
     echo "<div align='center'>";
     echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/resourceresting.form.php\">";
     echo "<table class='plugin_resources_wizard' style='margin-top:1px;'>";
     echo "<tr>";
     echo "<td class='plugin_resources_wizard_left_area' valign='top'>";
     echo "<div class='plugin_resources_presentation_logo'>";
     echo "<img src='../pics/newresting.png' alt='newresting' /></div>";
     echo "</td>";
     echo "<td class='plugin_resources_wizard_right_area' style='width:500px' valign='top'>";
     $title = __('Declare a non contract period', 'resources');
     if ($ID > 0) {
         $title = __('Detail of non contract period', 'resources');
     }
     echo "<div class='plugin_resources_wizard_title'>";
     echo $title;
     echo "</div>";
     echo "<table>";
     echo "<tr class='plugin_resources_wizard_explain'>";
     echo "<td>" . PluginResourcesResource::getTypeName(1) . "</td>";
     echo "<td class='left'>";
     PluginResourcesResource::dropdown(array('name' => 'plugin_resources_resources_id', 'value' => $this->fields["plugin_resources_resources_id"], 'entity' => $_SESSION['glpiactiveentities']));
     echo "</td></tr>";
     echo "<tr class='plugin_resources_wizard_explain'><td>";
     echo __('Begin date') . "</td>";
     echo "<td class='left'>";
     Html::showDateFormItem("date_begin", $this->fields["date_begin"], true, true);
     echo "</td></tr>";
     echo "<tr class='plugin_resources_wizard_explain'><td>";
     echo __('End date') . "</td>";
     echo "<td class='left'>";
     Html::showDateFormItem("date_end", $this->fields["date_end"], true, true);
     echo "</td></tr>";
     echo "<tr class='plugin_resources_wizard_explain'><td>";
     echo __('Agency concerned', 'resources') . "</td>";
     echo "<td class='left'>";
     Dropdown::show('Location', array('value' => $this->fields["locations_id"]));
     echo "</td></tr>";
     echo "<tr class='plugin_resources_wizard_explain'><td>";
     echo __('At home', 'resources') . "</td>";
     echo "<td class='left'>";
     Dropdown::showYesNo('at_home', $this->fields['at_home']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='plugin_resources_wizard_explain'><td colspan='2'>";
     echo __('Comments') . "</td></tr>";
     echo "<tr class='plugin_resources_wizard_explain'><td colspan='2'>";
     echo "<textarea cols='70' rows='4' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "</table>";
     echo "</div></td>";
     echo "</tr>";
     echo "<tr><td class='plugin_resources_wizard_button' colspan='2'>";
     echo "<div class='preview'>";
     echo "<a href=\"./resourceresting.form.php\">";
     _e('Declare a non contract period', 'resources');
     echo "</a>";
     echo "&nbsp;/&nbsp;<a href=\"./resourceresting.php\">";
     _e('List of non contract periods', 'resources');
     echo "</a>";
     echo "</div>";
     echo "<div class='next'>";
     if ($ID > 0) {
         echo "<input type='hidden' name='id' value='" . $ID . "' />";
         echo "<input type='hidden' name='plugin_resources_resources_id' value='" . $this->fields["plugin_resources_resources_id"] . "' />";
         echo "<input type='submit' name='updaterestingresources' value=\"" . _sx('button', 'Update') . "\" class='submit' />";
         echo "&nbsp;&nbsp;<input type='submit' name='deleterestingresources' value=\"" . _sx('button', 'Delete permanently') . "\" class='submit' />";
     } else {
         echo "<input type='submit' name='addrestingresources' value='" . _sx('button', 'Add') . "' class='submit' />";
     }
     echo "</div>";
     echo "</td></tr></table>";
     Html::closeForm();
     echo "</div>";
 }
Ejemplo n.º 29
0
 You should have received a copy of the GNU General Public License
 along with GLPI; along with Order. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
 @package   order
 @author    the order plugin team
 @copyright Copyright (c) 2010-2015 Order plugin team
 @license   GPLv2+
            http://www.gnu.org/licenses/gpl.txt
 @link      https://forge.indepnet.net/projects/order
 @link      http://www.glpi-project.org/
 @since     2009
 ---------------------------------------------------------------------- */
include "../../../inc/includes.php";
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
if (!defined('GLPI_ROOT')) {
    die("Can not acces directly to this file");
}
if (isset($_POST["action"])) {
    switch ($_POST["action"]) {
        case "reception":
            echo "</td><td>";
            Html::showDateFormItem("delivery_date", date("Y-m-d"), true, 1);
            echo __("Delivery form") . "&nbsp;";
            echo "<input type='text' name='delivery_number' size='20'><br>";
            echo __("Delivery status", "order") . "&nbsp;";
            PluginOrderDeliveryState::Dropdown(array('name' => "plugin_order_deliverystates_id"));
            echo "<br><input type='submit' name='reception' class='submit' value='" . _sx('button', 'Post') . "'></td>";
            break;
    }
}
Ejemplo n.º 30
0
            echo "</td></tr>";
            break;
        case 'week':
            echo "<tr><td>" . __('End date') . '</td><td>';
            Html::showDateFormItem('periodicity[end]', $_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'>";
            echo "<select name='periodicity[subtype]'>";
            echo "<option value='date'>" . __('Each month, same date') . "</option>\n";
            echo "<option value='day'>" . __('Each month, same day of week') . "</option>\n";
            echo "</select>";
            echo "</td></tr>";
            echo "<tr><td>" . __('End date') . '</td><td>';
            Html::showDateFormItem('periodicity[end]', $_POST['end']);
            echo "</td></tr>";
    }
    echo '</table>';
}