Ejemplo n.º 1
0
 /**
  * Main frontend data for object modification
  *
  * @param CommonDBTM $item Item to Display
  * @param int $ID
  * @param int $withtemplate
  */
 static function rackview_data($item, $ID, $withtemplate = 0)
 {
     global $CFG_GLPI, $DB, $LANG;
     if (!$withtemplate) {
         print '<table class="tab_cadre_fixe">';
         print '<tr class="tab_bg_2">';
         print '<th colspan="2">' . $LANG['plugin_rackview']['title'] . '</th>';
         print '</tr>';
         print '<tr class="tab_bg_2" valign="top">';
         // Show rack, if all informations have been correctly set
         $result = $DB->request("glpi_plugin_rackview_mount", array("object_type" => $item->getType(), "object_id" => $item->getID()));
         if ($result->numrows() > 0) {
             // Display rack(s)
             print '<td width="50%">';
             while ($mount = $result->next()) {
                 print '<table>';
                 print '<tr valign="top">';
                 print '<td>';
                 // Show rack
                 $rack = new PluginRackviewRack();
                 $rack->getFromDB($mount['rack_id']);
                 print '<div id="rackview_rack_' . $mount['id'] . '" class="CSSTableGenerator">';
                 $rack->showRack(true, 'rackview_startu_' . $mount['id']);
                 print '</div>';
                 print '</td>';
                 print '<td>';
                 // Show mount toolbox
                 PluginRackviewRack::rackview_mount_toolbox($item, 'remount_' . $mount['id'], 'remount', $mount, true);
                 print '</td>';
                 print '</tr>';
                 print '</table>';
             }
         } else {
             print '<td width="50%">';
             print '<div>' . $LANG['plugin_rackview']['label_notmounted'] . '</div>';
         }
         // Show racks to mount
         $result = $DB->request("glpi_plugin_rackview_racks");
         if ($result->numrows() == 0) {
             // no racks have been defined
             print '<div>' . $LANG['plugin_rackview']['label_noracks'] . '</div>';
         } else {
             // Build "mount" toolbox
             print '<table>';
             print '<tr>';
             print '<td>';
             print '<div id="rackview_rack_new" class="CSSTableGenerator">' . $LANG['plugin_rackview']['label_selectarack'] . '</div>';
             print '</td>';
             print '<td>';
             PluginRackviewRack::rackview_mount_toolbox($item);
             print '</td>';
             print '</tr>';
             print '</table>';
         }
         print '</td>';
         // Display rack informations
         $result = $DB->request("glpi_plugin_rackview_object", array("object_type" => $item->getType(), "object_id" => $item->getID()));
         $rack_object = array("size" => "", "object_type" => $item->getType(), "object_id" => $item->getID());
         if ($result->numrows() > 0) {
             $rack_object = $result->next();
         }
         print '<td width="50%">';
         // Form
         print '<form name="form" method="post" action="' . $CFG_GLPI["root_doc"] . '/plugins/rackview/front/plugin_rackview_setobject.php">';
         print '<input type="hidden" name="object_type" ' . 'value="' . $rack_object['object_type'] . '" />';
         print '<input type="hidden" name="object_id" ' . 'value="' . $rack_object['object_id'] . '" />';
         print '<table class="tab_cadre_fixe" style="width: 100%">';
         print '<tr class="tab_bg_1">';
         print '<th colspan="2">' . $LANG['plugin_rackview']['label_data'] . '</th>';
         foreach (array("size") as $field) {
             print '<tr class="tab_bg_1">';
             print '<td title="' . $LANG['plugin_rackview']['help_' . $field] . '">' . $LANG['plugin_rackview']['field_' . $field] . '</td>';
             print '<td>';
             print '<input type="text" name="rackview_size" size="2" ' . 'value="' . $rack_object[$field] . '" />';
             print '</td>';
             print '</tr>';
         }
         print '<tr>';
         print '<td colspan="2" align="center">' . '<input type="submit" class="submit" value="' . $LANG['plugin_rackview']['label_update'] . '" /></td>';
         print '</tr>';
         print '</table>';
         Html::closeForm();
         print '</td>';
         print '</tr>';
         print '</table>';
     }
 }