function DisplayDeviceType() { global $deviceForm; $deviceForm->setCols(2); $device_type_id = $_GET[devtype_id]; if (empty($device_type_id)) { print "Sorry invalid device type<br>"; return; } $devType = new Device_type($device_type_id); $content = "<h1>" . $devType->get_name() . "</h1>"; // Tools menu $tool = new EdittingTools(); if ($_SESSION['access'] >= 50) { $toolNames = array("Edit", "Delete"); $toolIcons = array("edit", "delete"); $toolHandlers = array("window.location.href='devices.php?action=edit_device_type&devtype_id={$device_type_id}'", "window.location.href='devices.php?action=archive_device_type&devtype_id={$device_type_id}'"); $content .= $tool->createNewTools($toolNames, $toolIcons, $toolHandlers); } $content .= " <div style=\"clear:both;\"></div><br> "; $form = new Form("auto", 2); $handler = array(); $values = array(); $titles = array(); $postkeys = array(); $heading = array("Device Type Details"); array_push($postkeys, "Name", "Description", "Vendor", "Class"); array_push($titles, "Name.tip.Short descriptive name for device type", "Description.tip.Device Type description", "Vendor", "Class.tip.This specifies the device type class and is used to group types by function<br>\n\t\t\tTwo examples are console_server and power_control, these two will be availble as control devices"); array_push($values, $devType->get_name(), $devType->get_description(), $devType->get_vendor(), $devType->get_device_class()); $deviceForm->setSortable(false); $deviceForm->setHeadings($heading); $deviceForm->setTitles($titles); $deviceForm->setDatabase($postkeys); $deviceForm->setData($values); $deviceForm->setTableWidth("60%"); $content .= $deviceForm->showForm(); #return $content; print $content; }
function render_show_accounting_profile() { if (isset($_GET['pid']) && is_numeric($_GET['pid'])) { $pid = $_GET['pid']; } else { return "<b>Sorry invalid profile id " . $_GET['pid'] . "</b>"; } $content = ""; $profile_name = $this->get_accounting_profile_name($pid); // Menu bar $content .= "<div style='font-size:10px; font-weight:100px;'>\n\t\t\t<a href='{$this->url}'>Accounting</a> >> {$profile_name}</div><br>"; /* Get all SCU-DCU sources for this profile */ $query = "SELECT accounting_source from accounting_profiles_files\n\t\t\tWHERE profile_id = '{$pid}'"; $result = mysql_query($query); $sources = ''; while ($obj = mysql_fetch_object($result)) { $sources .= "graph_profile_id[]=" . $obj->accounting_source . "&"; } // Remove last & $sources = substr($sources, 0, -1); /* End Get all SCU-DCU sources for this profile */ // Tools menu $tool = new EdittingTools(); if ($_SESSION['access'] >= 50) { $toolNames = array("Edit", "Delete", "Saved Reports", "New Report", "Quick Report"); $toolIcons = array("edit", "delete", "stat", "line", "graph"); $toolHandlers = array("window.location.href='{$this->url}&action=edit_accounting_profile&pid={$pid}'", "window.location.href='{$this->url}&action=del_accounting_profile&pid={$pid}'", "window.location.href='{$this->url}&pid={$pid}&action=show_reports'", "window.location.href='{$this->url}&action=create_report&pid={$pid}'", "window.location.href='{$this->url}&action=graph_profiles&{$sources}&pid={$pid}'"); $content .= $tool->createNewTools($toolNames, $toolIcons, $toolHandlers); } $content .= "<p>"; $query = "Select title, client_id, notes, traffic_cap\n\t\t\tFROM accounting_profiles\n\t\t\tWHERE profile_id = '{$pid}'"; $result = mysql_query($query); if (!$result) { return "<b>Sorry something went wrong</b>" . mysql_error() . $query; } $obj = mysql_fetch_object($result); $contact = new Contact($obj->client_id); $contact_name = $contact->get_name(); if ($contact_name == '') { $contact_name = "n/a"; } $values = array($obj->title, $contact_name, $this->int_to_si($obj->traffic_cap), $obj->notes); $form = new Form("auto", 2); $heading = array("Edit Accounting Profile"); $titles = array("Name", "Client", "Traffic Cap.tip.Configured cap or Contracted rate.", "Notes"); $form->setSortable(false); $form->setHeadings($heading); $form->setTitles($titles); $form->setDatabase($titles); $form->setData($values); //set the table size $form->setTableWidth("1024px"); $form->setTitleWidth("20%"); $content .= $form->ShowForm(1); $content .= "<div style=\"clear:both;\"></div> </p>"; $content .= "</p><p><h2>RRD files</h2>"; $tool2 = new EdittingTools(); if ($_SESSION['access'] >= 50) { $toolNames = array("Add RRD file"); $toolIcons = array("add"); #$formType = array("newDialog"); #$tool2->createNewModal($toolNames, $toolIcons, $formType); $toolHandlers = array("window.location.href='{$this->url}&action=show_add_rrd_to_profile&pid={$pid}'"); $content .= $tool2->createNewTools($toolNames, $toolIcons, $toolHandlers); } $form = new Form("auto", 3); $heading = array("Delete", "Device", "SCU-DCU source"); $data = array(); $title = array(); $handler = array(); #$content .= "<table><tr><th>Delete</th><th>Device</th><th>SCU-DCU sources</th>"; $query = "SELECT accounting_profiles_files.accounting_source,\n\t\t\t\taccounting_sources.title, accounting_sources.device_id,\n\t\t\t\tDevices.name as device_name\n\t\t\tFROM accounting_profiles_files, accounting_sources, Devices\n\t\t\tWHERE profile_id = '{$pid}'\n\t\t\tAND accounting_sources.device_id = Devices.device_id\n\t\t\tAND accounting_profiles_files.accounting_source = accounting_sources.id"; $result = mysql_query($query); if (!$result) { $content .= "<b>No Files found</b>"; } while ($obj = mysql_fetch_object($result)) { #$content .= "<tr><td><a href = '$this->url&action=del_accounting_source_from_profile&pid=$pid&asrc=$obj->accounting_source'><img src='icons/Delete.png' height=20></a></td> <td>$obj->device_name</td><td>$obj->title</td></tr>"; array_push($title, "<a href='{$this->url}&action=del_accounting_source_from_profile&pid={$pid}&asrc={$obj->accounting_source}'><img src='icons/Delete.png' height=20></a>"); array_push($data, $obj->device_name, $obj->title); } #$content .= "</table>"; $form->setSortable(true); // or false for not sortable $form->setHeadings($heading); $form->setTitles($title); $form->setTitleWidth("50px"); $form->setData($data); $form->setTableWidth("500px"); $content .= $form->showForm(); // This is to add normal Interface RRD files // AT, remove this link as it's not fully implemented //$content .= "<a href='$this->url&action=add_device_interface_to_profile&pid=$pid'>Add interface to accounting profile</a>"; // Done return $content; }
} } //Create new tools if it is VLAN if (isset($_GET['family'])) { if ($_GET['family'] == 'vlan') { //Different states based on where VLAN is in if (isset($_GET['v_id'])) { $names = array("Add New VLAN", "Search", "Delete VLAN"); $icons = array("add", "search", "delete"); $handlers = array("window.location.href='" . $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'] . "&className=" . $_GET['className'] . "&family=vlan&action=add'", "window.location.href='" . $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'] . "&className=" . $_GET['className'] . "&family=vlan&action=search'", "window.location.href='" . $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'] . "&className=" . $_GET['className'] . "&family=vlan&v_id=" . $_GET['v_id'] . "&action=delete'"); } else { $names = array("Add New VLAN", "Search", "Show All VLANs"); $icons = array("add", "search", "icons/vlan-01.png"); $handlers = array("window.location.href='" . $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'] . "&className=" . $_GET['className'] . "&family=vlan&action=add'", "window.location.href='" . $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'] . "&className=" . $_GET['className'] . "&family=vlan&action=search'", "window.location.href='" . $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'] . "&className=" . $_GET['className'] . "&family=vlan&action=showAll'"); } echo EdittingTools::createNewTools($names, $icons, $handlers, "VLAN Tool"); } else { echo EdittingTools::createNewModal($names, $icons, $modalID, "IP Tool"); } } else { echo EdittingTools::createNewModal($names, $icons, $modalID, "IP Tool"); } //If it's the vlan overview, create filters if (isset($_GET['family'])) { if ($_GET['family'] == 'vlan' && !isset($_GET['action']) && !isset($_GET['v_id'])) { $listFilter = array("FREE" => "FREE", "RESERVED" => "RESERVED", "ASSIGNED" => "ASSIGNED"); echo EdittingTools::createNewFilters($listFilter); } } //CRUD detection for networks if (!empty($_POST)) {
function render_show_change() { // First determine change id // If not a;ready defined. then check GET if (isset($_GET[cid]) && is_numeric($_GET[cid])) { $cid = mysql_real_escape_string($_GET[cid]); } else { return "<b>Sorry change not found<br></b>"; } //$content = "<h1>Change Details (#$cid) </h1>"; // Tools menu $tool = new EdittingTools(); if ($_SESSION['access'] >= 50) { $toolNames = array("Edit", "Add Device", "Delete Change"); $toolIcons = array("edit", "add", "delete"); $toolHandlers = array("window.location.href='{$this->url}&action=edit_change&cid={$cid}'", "window.location.href='{$this->url}&action=edit_change&cid={$cid}&add_device#new_device'", "window.location.href='{$this->url}&action=delete_change&cid={$cid}&return=show_change'"); $contentH .= $tool->createNewTools($toolNames, $toolIcons, $toolHandlers); } $contentH .= " <div style=\"clear:both;\"></div><br> "; /* First Generic change info */ $query = "SELECT change_id, title, notes, record_date, planned_change_date,change_date,\n\t\t\t\t\tchange_contact_1, change_contact_2, impact, status\n\t\t\t\t\tFROM plugin_ChangeManager_Changes\n\t\t\t\t\tWHERE change_id = '{$cid}'"; $result = mysql_query($query); if (!$result) { return "<b>Oops something went wrong, unable to select changes </b>"; } $values = array(); while ($obj = mysql_fetch_object($result)) { $notes = nl2br($obj->notes); $user1 = new User($obj->change_contact_1); $contact_name1 = $user1->get_full_name(); $user2 = new User($obj->change_contact_2); $contact_name2 = $user2->get_full_name(); $impact_name = $this->impact_values[$obj->impact]; $status_name = $this->status_values[$obj->status]; if (is_null($obj->planned_change_date)) { $planned_change_date = 'Not Specified'; } else { $planned_change_date = $obj->planned_change_date; } if (is_null($obj->change_date)) { $change_date = 'Not Specified'; } else { $change_date = $obj->change_date; } array_push($values, $obj->title, $planned_change_date, $change_date, $contact_name1, $contact_name2, $impact_name, $status_name, $notes); $title = $obj->title; } $content = "<hr align=\"left\" style=\"width:94%;border:1px solid #C0C0C0;\">\n\t\t\t\t\t<h2>CHANGE (#{$cid}): {$title}</h2>\n\t\t\t\t\t<hr align=\"left\" style=\"width:94%;border:1px solid #C0C0C0;\">" . $contentH; $form = new Form("auto", 2); $heading = array("Change Details"); $titles = array("Summary", "Planned Date", "Completion Date", "Primary Contact", "Secondary Contact", "Impact", "Status", "Change Description"); #$fieldType = array(1=>"text_area"); #$form->setFieldType($fieldType); $form->setSortable(false); $form->setHeadings($heading); $form->setTitles($titles); $form->setDatabase($titles); $form->setData($values); //set the table size $form->setTableWidth("94%"); $form->setTitleWidth("20%"); $content .= $form->ShowForm(1); /* Device specific change info */ $query2 = "SELECT device_id, impact, effects, chgby_id, change_date, description,\n\t\t\t\t\tback_out, status, id\n\t\t\t\t\tFROM plugin_ChangeManager_Components\n\t\t\t\t\tWHERE change_id = '{$cid}'"; $result2 = mysql_query($query2); if (!$result2) { return "<b>Oops something went wrong, unable to select changes </b>"; } $content .= "<table style='width:94%; clear:left;' id=\"sortDataTable\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr></tr><td><h2>Device Changes</h2></td></tr></table>"; while ($obj = mysql_fetch_object($result2)) { $dvalues = array(); // Determine device name $device = new Device($obj->device_id); $device_name = $device->get_name(); // Determine device name $user = new User($obj->chgby_id); $fullname = $user->get_full_name(); $effects = stripslashes(nl2br($obj->effects)); $description = stripslashes(nl2br(htmlentities($obj->description))); // For Juniper code we need to keep the indents in place. so replace white spaces as well $description = str_replace(" ", " ", $description); $back_out = stripslashes(nl2br($obj->back_out)); array_push($dvalues, $device_name, $fullname, $description, $effects, $back_out); $heading = array("Device Details: {$device_name} <div style='text-align: right;'> \n<a href='{$this->url}&action=delete_device_component&cid={$cid}&component_id={$obj->id}&return=show_change' style='color:#FFFFFF'>\nDelete <img src='icons/Delete.png' height=20></a></div>"); $titles = array("Device", "Changed By", "Change Details", "Change Effects", "Backout Procedure"); #$fieldType = array(4=>"text_area"); #$fieldType = array(4=>"text_area.height:60px"); $dform = new Form("auto", 2); $dform->setHeadings($heading); $dform->setFieldType($fieldType); $dform->setTitles($titles); $dform->setDatabase($titles); $dform->setData($dvalues); //set the table size $dform->setTableWidth("94%"); $dform->setTitleWidth("20%"); $content .= $dform->ShowForm(1); } return $content; }