示例#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>';
     }
 }
示例#2
0
/**
 * Return item description
 *
 * @param $itemtype
 * @param $ID
 * @param $data
 * @param $num
 * @return string
 */
function plugin_rackview_giveItem($itemtype, $ID, $data, $num)
{
    $searchopt = Search::getOptions($itemtype);
    $NAME = "ITEM_";
    $unit = '';
    if (isset($searchopt[$ID]['unit'])) {
        $unit = $searchopt[$ID]['unit'];
    }
    if (isset($searchopt[$ID]["itemlink_type"])) {
        $link = Toolbox::getItemTypeFormURL($searchopt[$ID]["itemlink_type"]);
    } else {
        $link = Toolbox::getItemTypeFormURL($itemtype);
    }
    $out = "";
    $rackDisplay = "";
    if ($ID == 1) {
        $rack = new PluginRackviewRack();
        $rack->getFromDB($data['id']);
        $rackDisplay = '<div style="float:left; margin-right: 1em" ' . 'class="CSSTableGenerator">' . $rack->buildRack(true) . '</div>';
    }
    $sub = "";
    if (isset($data[$NAME . $num . "_2"])) {
        $sub = $data[$NAME . $num . "_2"];
    }
    $out .= "<a id='" . $itemtype . "_" . $sub . "' href=\"" . $link;
    $out .= strstr($link, '?') ? '&amp;' : '?';
    $out .= 'id=' . $sub;
    if (isset($searchopt[$ID]['forcetab'])) {
        $out .= "&amp;forcetab=" . $searchopt[$ID]['forcetab'];
    }
    $out .= "\">" . $data[$NAME . $num] . $unit;
    if (($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) && isset($data[$NAME . $num . "_2"])) {
        $out .= " (" . $data[$NAME . $num . "_2"] . ")";
    }
    $out .= "</a>";
    if ($rackDisplay != "") {
        $out .= HTML::showToolTip($rackDisplay, array('applyto' => $itemtype . "_" . $sub, 'display' => false));
    }
    return $out;
}
示例#3
0
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/>.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: Dennis Ploeger <*****@*****.**>
// Purpose of file: Ajax method of displaying a rack
// ----------------------------------------------------------------------
include '../../../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();
if (isset($_GET['id'])) {
    $rackId = $_GET['id'];
    $rack = new PluginRackviewRack();
    if ($rack->getFromDB($rackId)) {
        $mini = false;
        if (isset($_GET['mini']) && $_GET['mini'] == 'true') {
            $mini = true;
        }
        if (isset($_GET['startu'])) {
            $rack->showRack($mini, $_GET['startu']);
        } else {
            $rack->showRack($mini);
        }
    }
}
示例#4
0
foreach ($locations as $location) {
    if (!$printMode) {
        print '<a name="' . urlencode($location['completename']) . '"><h2>' . htmlentities($location['completename']) . '</h2></a>';
        print '<div class="rackview_rackSummaryLine"><div>';
    }
    $dbRacks = $DB->request($tableRacks, array('locations_id' => $location['id'], 'ORDER' => 'name'));
    $printBreak = false;
    while ($dbRack = $dbRacks->next()) {
        if ($printBreak) {
            print '<div class="pagebreak"></div>';
            $printBreak = false;
        }
        if (array_key_exists('rack', $_GET) && !in_array($dbRack['id'], $_GET['rack'])) {
            continue;
        }
        $rack = new PluginRackviewRack();
        $rack->getFromDB($dbRack['id']);
        print '<div class="rackview_rackSummary CSSTableGenerator">' . $rack->buildRack(false) . '</div>';
        $rackCount++;
        if ($rackCount == 3) {
            $printBreak = true;
            $rackCount = 0;
        }
    }
    if (!$printMode) {
        print '</div></div>';
    }
}
print '</div>';
if (array_key_exists('action', $_GET) && $_GET['action'] == 'print') {
    print '<script type="text/javascript">window.print();</script>';
示例#5
0
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: Dennis Plöger <*****@*****.**>
// Purpose of file: Rack CRUD form
// ----------------------------------------------------------------------
$NEEDED_ITEMS = array('plugin');
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "-1";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$rack = new PluginRackviewRack();
if (isset($_POST['add'])) {
    $rack->check(-1, 'w', $_POST);
    $newId = $rack->add($_POST);
    Html::redirect($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST['delete']) || isset($_POST['purge'])) {
        $rack->check($_POST['id'], 'w');
        $rack->delete($_POST);
        Html::redirect($CFG_GLPI['root_doc'] . '/plugins/rackview/index.php');
    } else {
        if (isset($_POST['update'])) {
            $rack->check($_POST['id'], 'w');
            $rack->update($_POST);
            Html::redirect($_SERVER['HTTP_REFERER']);
        } else {