Ejemplo n.º 1
0
function export_csv()
{
    if (isset($_GET['report_name']) && $_GET['report_name'] != '') {
        $name = $_GET['report_name'];
    } else {
        return "<b>Sorry invalid report name " . $_GET['report_name'] . "</b>";
    }
    $query = "select accounting_reports.id, accounting_reports.profile_id, accounting_reports.report_name, \n\t\t\taccounting_reports.date1, accounting_reports.date2, \n\t\t\taccounting_reports.avg_in, accounting_reports.avg_out, \n\t\t\taccounting_reports.max_in, accounting_reports.max_out,95_in as in95,\n\t\t\taccounting_reports.95_out as out95 , accounting_reports.tot_in, accounting_reports.tot_out,\n\t\t\taccounting_reports.sample_date1,   accounting_reports.sample_date2, \n\t\t\taccounting_reports.traffic_cap, accounting_profiles.client_id\n\t\t\tfrom \n\t\t\taccounting_reports, accounting_profiles where report_name = '{$name}'\n\t\t\tAND accounting_profiles.profile_id =  accounting_reports.profile_id";
    $result = mysql_query($query);
    if (!$result) {
        return "failed to execute query {$query}<br>";
    }
    $heading = array("Client", "Accounting Profile", "Report Name", "Start date", "End date", "Average In (b/s)", "Average out (b/s)", "Max In (b/s)", "Max out (b/s)", "95% In (b/s)", "95% out (b/s)", "95% Billing (b/s)", "95% Billing (Mb/s)", "Committed Traffic (b/s)", "Commitment Status", "Total In (Bytes)", "Total out (Bytes)", "First Sample date", "Last Sample date");
    $content = implode(",", $heading);
    $content .= "\n";
    while ($obj = mysql_fetch_object($result)) {
        $data = array();
        $pid = $obj->profile_id;
        if ($obj->in95 > $obj->out95) {
            $bill95 = $obj->in95;
        } else {
            $bill95 = $obj->out95;
        }
        // Create Mb/s number
        $bill95_mb = round($bill95 / (1000 * 1000), 2);
        // get client name
        $contact_name = "N/A";
        $client_id = $obj->client_id;
        if (!is_null($client_id)) {
            $contact = new Contact($client_id);
            $contact_name = $contact->get_name();
            if ($contact_name != '') {
            } else {
                $contact_name = "N/A";
            }
        }
        if (!$obj->traffic_cap) {
            $cap_ok = "N/A";
        } elseif ($bill95 > $obj->traffic_cap) {
            $cap_ok = "Over Commitment";
        } else {
            $cap_ok = "Under Commitment";
        }
        $profile_name = get_accounting_profile_name($pid);
        array_push($data, $contact_name, $profile_name, $obj->report_name, $obj->date1, $obj->date2, $obj->avg_in, $obj->avg_out, $obj->max_in, $obj->max_out, $obj->in95, $obj->out95, $bill95, $bill95_mb, $obj->traffic_cap, $cap_ok, $obj->tot_in, $obj->tot_out, $obj->sample_date1, $obj->sample_date2);
        $content .= stripslashes(implode(",", $data));
        $content .= "\n";
    }
    return $content;
}
Ejemplo n.º 2
0
function displayAllArchived($groupTypes)
{
    //global the tool and make a tool bar for adding a contact
    global $tool, $contactForm;
    if ($_SESSION['access'] >= 50) {
        $toolNames = array("Add New Contacts", "Contacts", "Contact Types", "Person Types");
        $toolIcons = array("add", "contact", "contact", "contact");
        $toolHandlers = array("handleEvent('contacts.php?action=addGroup')", "handleEvent('contacts.php')", "handleEvent('contacts.php?action=showGroupTypes')", "handleEvent('contacts.php?action=showArchivedGroup')");
    } else {
        $toolNames = array("Contacts", "Contact Types", "Person Types");
        $toolIcons = array("contact", "contact", "contact");
        $toolHandlers = array("handleEvent('contacts.php')", "handleEvent('contacts.php?action=showGroupTypes')", "handleEvent('contacts.php?action=showArchivedGroup')");
    }
    echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
    echo $tool->createNewFilters();
    //get all the contact and display them all in the 2 sections: "Contact Name" and "Contact ID".
    //$allGroupTypes = $groupTypes->get_group_types(1);
    $allGroups = Contact::get_groups(1);
    $keyHandlers = array();
    $keyTitle = array();
    $keyData = array();
    if (isset($allGroups)) {
        foreach ($allGroups as $id => $value) {
            $curGroup = new Contact($id);
            array_push($keyHandlers, "handleEvent('contacts.php?action=showGroup&groupID={$id}')");
            array_push($keyTitle, $curGroup->get_name());
            array_push($keyData, $curGroup->get_group_type_name());
            //$curGroupType = new GroupType($id);
            //array_push($keyData, $curGroupType->get_desc());
        }
    } else {
        $contactForm->warning("There are NO group types available");
    }
    $headings = array("Contacts", "Contact Type");
    $contactForm->setTableWidth("1024px");
    $contactForm->setTitles($keyTitle);
    $contactForm->setData($keyData);
    $contactForm->setEventHandler($keyHandlers);
    $contactForm->setHeadings($headings);
    $contactForm->setSortable(true);
    echo $contactForm->showAll();
}
Ejemplo n.º 3
0
function displayLocations($location)
{
    //global all variables
    global $locationForm, $tool;
    //make the tool bar for this page
    if ($_SESSION['access'] >= 50) {
        $toolNames = array("Edit Location", "Add New Room", "Remove Location");
        $toolIcons = array("edit", "add", "delete");
        $toolHandlers = array("handleEvent('location.php?action=editLocation&locationID=" . $_GET["locationID"] . "')", "handleEvent('location.php?action=addRoom&locationID=" . $_GET["locationID"] . "')", "handleEvent('location.php?action=removeLocation&locationID=" . $_GET["locationID"] . "')");
        echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
    }
    $contactGroup = $location->get_contact_group_id();
    $thisGroup = new Contact($contactGroup);
    $groupName = $thisGroup->get_name();
    $groupTypeName = $thisGroup->get_group_type_name();
    if (isset($groupName) && isset($groupTypeName)) {
        $groupLoc = "<a href='contacts.php?action=showGroup&groupID=" . $contactGroup . "'>" . $groupName . "</a>";
    } else {
        $groupLoc = "N/A";
    }
    $locationType = new LocationType($location->get_location_type());
    $locationHeader = array($location->get_name());
    $locationTitle = array("Description", "Country", "Province", "City", "Address 1", "Address 2", "Zip Code", "Contacts", "Notes", "Location Type");
    $locationInfo = array($location->get_desc(), $location->get_country(), $location->get_province(), $location->get_city(), $location->get_addr_line1(), $location->get_addr_line2(), $location->get_zip_code(), $groupLoc, $location->get_notes(), $locationType->get_name());
    $allRooms = $location->get_rooms();
    $roomTypes = array();
    foreach ($allRooms as $id => $value) {
        $curRoom = new Room($id);
        if (!in_array($curRoom->get_room_type(), $roomTypes) && $_GET['locationID'] == $curRoom->get_location_id()) {
            array_push($roomTypes, $curRoom->get_room_type());
        }
    }
    //if the user is editting this information, make it all editable
    if ($_GET['action'] == editLocation) {
        $locationInfoKey = array("name", "desc", "country", "province", "city", "address1", "address2", "zip", "group", "notes", "type");
        $fieldType = array(8 => "drop_down", 9 => "text_area", 10 => "drop_down");
        $locationHeader = array("Location Information");
        $locationTitle = array("Name", "Description", "Country", "Province", "City", "Address 1", "Address 2", "Zip Code", "Contact", "Notes", "Location Type");
        $locationInfo = array($location->get_name(), $location->get_desc(), $location->get_country(), $location->get_province(), $location->get_city(), $location->get_addr_line1(), $location->get_addr_line2(), $location->get_zip_code(), $thisGroup->get_name(), $location->get_notes(), $locationType->get_name());
        $allLocationType = LocationType::get_location_types();
        $allGroups = Contact::get_groups();
        $locationForm->setHeadings($locationHeader);
        $locationForm->setTitles($locationTitle);
        $locationForm->setData($locationInfo);
        $locationForm->setSortable(false);
        $locationForm->setDatabase($locationInfoKey);
        $locationForm->setUpdateValue("updateLocation");
        $locationForm->setType($allGroups);
        $locationForm->setType($allLocationType);
        $locationForm->setFieldType($fieldType);
        echo $locationForm->editLocationForm();
    } else {
        if ($_GET['action'] == showLocation) {
            $locationForm->setTableWidth("1024px");
            $locationForm->setTitles($locationTitle);
            $locationForm->setData($locationInfo);
            $locationForm->setHeadings($locationHeader);
            $locationForm->setSortable(false);
            echo $locationForm->showAll();
            echo "<div style='clear:left; width:1024px;'>";
            foreach ($roomTypes as $id => $value) {
                $curRoomType = new RoomType($value);
                $roomHeader = array($curRoomType->get_name());
                $roomTitle = array();
                $roomInfo = array();
                $roomHandler = array();
                foreach ($allRooms as $cID => $cValue) {
                    $curRoom = new Room($cID);
                    if ($curRoom->get_room_type() == $value) {
                        array_push($roomTitle, $curRoom->get_name());
                        array_push($roomInfo, $curRoom->get_desc(), "<a href='location.php?action=removeRoom&locationID=" . $_GET['locationID'] . "&roomTypeID=" . $value . "&roomID=" . $cID . "'>Remove</a>");
                        array_push($roomHandler, "handleEvent('location.php?action=showRooms&locationID=" . $_GET['locationID'] . "&roomTypeID=" . $value . "&roomID=" . $cID . "')");
                    }
                }
                //make the tool bar for this page
                /*if ($_SESSION['access'] >= 50)
                		{
                			$toolNames = array("Add New Room", "Edit Room Type", "Remove Room Type");
                			$toolIcons = array("add", "edit", "delete");
                			$toolHandlers = array("handleEvent('location.php?action=addRoom&locationID=".$_GET['locationID']."&roomTypeID=".$value."')",
                								"handleEvent('location.php?action=editRoomType&locationID=".$_GET['locationID']."&roomTypeID=".$value."')",
                								"handleEvent('location.php?action=removeRoomType&locationID=".$_GET['locationID']."&roomTypeID=".$value."')",);
                			echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
                		}*/
                $locationForm->setTableWidth("300px");
                $locationForm->setCols(3);
                $locationForm->setTitles($roomTitle);
                $locationForm->setData($roomInfo);
                $locationForm->setEventHandler($roomHandler);
                $locationForm->setHeadings($roomHeader);
                $locationForm->setSortable(true);
                $locationForm->setFirst(false);
                echo $locationForm->showAll();
            }
            echo "</div>";
        }
    }
}
Ejemplo n.º 4
0
 function get_assigned_to_name()
 {
     if ($this->assigned_to === NULL) {
         return "";
     }
     $assigned_to = new Contact($this->assigned_to);
     return $assigned_to->get_name();
 }
Ejemplo n.º 5
0
function editReportProfile()
{
    //global the tool and make a tool bar for adding a device and display all the archived device, and displaying the IP Report
    global $tool, $form, $report_types;
    include_once 'classes/Contact.php';
    $toolNames = array("Edit Profile", "Delete Profile", "Create Report");
    $toolIcons = array("edit", "delete", "report");
    $toolHandlers = array("handleEvent('" . $_SERVER['PHP_SELF'] . "?action=editReportProfile&profileid=" . $_GET[profileid] . "')", "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=deleteReportProfile&profileid=" . $_GET[profileid] . "')", "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=renderReportProfileReport&profileid=" . $_GET[profileid] . "')");
    echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
    if (is_numeric($_GET[profileid])) {
        $profile = new CheckReportProfile($_GET[profileid]);
    } else {
        $form->warning("Invalid Profile id id");
        return;
    }
    $allGroups[""] = "";
    foreach (Contact::get_groups() as $id => $name) {
        $allGroups[$id] = $name;
    }
    $form->setType($allGroups);
    // Drop down
    $form->setType($report_types);
    // Drop down
    $headings = array("Edit Report Profile Details");
    $postKeys = array("profile_name", "profile_client", "profile_report_type", "profile_notes");
    $keyTitle = array("Name.tip.descriptive name for this profile", "Client.tip.Optionally specify the contact client", "Report Type", "Notes");
    $keyHandlers = array();
    $keyData = array();
    if ($profile->get_contact_id()) {
        $contact = new Contact($profile->get_contact_id());
        $contact_name = $contact->get_name();
    } else {
        $contact_name = "";
    }
    $keyData = array($profile->get_name(), $contact_name, $report_types[$profile->get_report_type()], $profile->get_notes());
    $postKeys = array("profile_name", "profile_client", "profile_report_type", "profile_notes");
    $fieldType[1] = "drop_down";
    $fieldType[2] = "drop_down";
    $fieldType[3] = "text_area";
    $form->setFieldType($fieldType);
    $form->setCols(2);
    $form->setTableWidth("450px");
    $form->setData($keyData);
    $form->setTitles($keyTitle);
    $form->setDatabase($postKeys);
    $form->setHeadings($headings);
    $form->setSortable(false);
    $form->setUpdateValue("updateReportProfile");
    echo $form->editForm();
}
Ejemplo n.º 6
0
         $search_str .= " Name = " . $_GET['title'] . ", ";
     }
     if ($_GET['tags'] != "") {
         $search_str .= " Tags = " . $_GET['tags'] . ", ";
     }
     if ($_GET['location'] != "") {
         $loc = new Location($_GET['location']);
         $search_str .= " Location = " . $loc->get_name() . ", ";
     }
     if ($_GET['owner'] != "") {
         $own = new Contact($_GET['owner']);
         $search_str .= " Owner = " . $own->get_name() . ", ";
     }
     if ($_GET['assigned'] != "") {
         $assign = new Contact($_GET['assigned']);
         $search_str .= " Assigned To = " . $assign->get_name() . ", ";
     }
     if ($_GET['status'] != "") {
         $search_str .= " Status = " . $_GET['status'] . ", ";
     }
     $search_str = rtrim($search_str, ", ");
     //display what is searched and what is found
     Form::success("Searched for:" . $search_str . " | Results Found: " . $result_c_count . " child network(s), " . $result_p_count . " parent network(s)");
 } else {
     //just search for everything if nothing is searched
     $s_results = $IP_Search->search("", "", "", "", "", "", $family);
 }
 //if there's no result display nothing
 if (count($s_results) == 0) {
     $search_str = "";
 }
Ejemplo n.º 7
0
 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;
 }