Example #1
0
 function showAll($headingName, $titles, $data, $handlers = array(), $mouseType = 0)
 {
     parent::setTitles($titles);
     parent::setData($data);
     parent::setEventHandler($handlers);
     parent::setHeadings($headingName);
     parent::setSortable(true);
     parent::setMouseHandlerType($mouseType);
     return parent::showForm();
 }
Example #2
0
 function get_config($id = '')
 {
     // MUST HAVE<input type='hidden' name='id' value=".$id."></input>
     // the name of the property must follow the conventions plugin_<Classname>_<propertyName>
     // have the form post and make sure the submit button is named widget_update
     // make sure there is also a hidden value giving the name of this Class file
     // Get defaults
     $subquery = "select device_id, enabled FROM plugin_SNMPPoller_devices";
     $result2 = mysql_query($subquery);
     if (!$result2) {
         return "<b>Oops something went wrong, unable to read plugin_SNMPPoller_devices SQL table </b>";
     }
     $devices = array();
     while ($obj = mysql_fetch_object($result2)) {
         $devices[$obj->device_id] = $obj->enabled;
     }
     // Now we have the defaults in $devices;
     $content .= "<h1>Please select the Devices you would like to Monitor with the SNMP poller</h1>";
     $content .= "<form id='configForm' method='post' name='edit_devices'>\r\n\t\t\t<input type='hidden' name='class' value='SNMPPoller'></input>\r\n\t\t\t<input type='hidden' name='id' value=" . $id . "></input> ";
     $select_all = "<input name='all' type='checkbox' value='Select All' onclick=\"checkAll(document.edit_devices['devices[]'],this)\"";
     #$content .= "<table border=1><tr><th>$select_all</th><th>Device</th><th>Device Type</th><th>Location</th></tr>";
     $form = new Form("auto", 4);
     $keyHandlers = array();
     $keyData = array();
     $keyTitle = array();
     foreach (Device::get_devices() as $id => $name) {
         if (array_key_exists($id, $devices) && $devices[$id] == 1) {
             $checked = "checked='yes'";
         } else {
             $checked = "";
         }
         $deviceInfo = new Device($id);
         array_push($keyData, "<input type=checkbox name=devices[] value='{$id}' {$checked} >");
         array_push($keyData, $name);
         array_push($keyData, $deviceInfo->get_type_name());
         array_push($keyData, $deviceInfo->get_location_name());
         #$content .= "<tr><td><input type=checkbox name=devices[] value='$id' $checked ></td>";
         #$content .= "<td>$name</td><td>". $deviceInfo->get_type_name() ."</td>";
         #$content .= "<td>". $deviceInfo->get_location_name() ."</td></tr>";
     }
     #$content .= "</table> <br>";
     //get all the device and display them all in the 3 sections "Device Name", "Device Type", "Location".
     $heading = array($select_all, "Device Name", "Device Type", "Location ");
     $form->setSortable(true);
     // or false for not sortable
     $form->setHeadings($heading);
     $form->setEventHandler($handler);
     $form->setData($keyData);
     $form->setTableWidth("auto");
     $content .= $form->showForm();
     $content .= "<div style='clear:both;'></div><input type='submit' class='submitBut' name='plugin_update' value='Update configuration'/>\r\n\t\t\t</form> ";
     return "{$content}";
 }
Example #3
0
 function get_content()
 {
     $last_events = Event::get_last_events(10);
     $form = new Form();
     $keyData = array();
     $keyHandlers = array();
     foreach ($last_events as $event_id => $status) {
         $event = new Event($event_id);
         $status = 3;
         $status = $event->get_status();
         $status_name = $this->status_array[$status];
         array_push($keyData, "<font color=" . $this->status_collors[$status] . "> {$status_name} </font>");
         array_push($keyData, $event->get_hostname());
         array_push($keyData, $event->get_check_name());
         //array_push($keyData, $event->get_check_name() .".tip.". $event->get_key1() ." ". $event->get_key2());
         array_push($keyData, $this->getHowLongAgo($event->get_insert_date()));
         //	array_push($keyData, $event->get_last_updated());
         $insert_time = strtotime($event->get_insert_date());
         $last_time = strtotime($event->get_last_updated());
         $diff = $this->strTime($last_time - $insert_time);
         array_push($keyData, $diff);
         //	array_push($keyData, $event->get_info_msg() );
         $check_id = $event->get_check_id();
         $check = new Check($check_id);
         if (is_null($check_id)) {
             array_push($keyHandlers, "");
         } else {
             array_push($keyHandlers, "handleEvent('monitor.php?action=showCheck&checkid={$check_id}')");
         }
     }
     $headings = array("Status", "Host", "Service", "Date", "Duration");
     $form->setCols(5);
     $form->setTableWidth("100%");
     $form->setData($keyData);
     $form->setEventHandler($keyHandlers);
     $form->setHeadings($headings);
     $form->setSortable(true);
     return $form->showForm() . " <div style='clear:both'></div>";
 }
Example #4
0
function displayReportProfile()
{
    //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", "Add Check", "Delete Profile", "Create Report");
    $toolIcons = array("edit", "add", "delete", "report");
    $toolHandlers = array("handleEvent('" . $_SERVER['PHP_SELF'] . "?action=editReportProfile&profileid=" . $_GET[profileid] . "')", "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=add_check_to_profile&profileid=" . $_GET[profileid] . "')", "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=deleteReportProfile&profileid=" . $_GET[profileid] . "')", "handleEvent('" . $_SERVER['PHP_SELF'] . "?action=renderProfileReportForm&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;
    }
    // Create left div
    echo "<div style='position: relative; float:left; clear:both; width:;'>";
    $headings = array("Report Profile Details");
    $keyTitle = array("Name.tip.descriptive name for this profile", "Client.tip.Optionally specify the contact client", "Report Type", "Notes");
    $keyHandlers = array();
    $keyData = array();
    // Get contact name
    if ($profile->get_contact_id()) {
        $contact = new Contact($profile->get_contact_id());
        $contact_name = $contact->get_name();
    } else {
        $contact_name = "N/A";
    }
    $keyData = array($profile->get_name(), $contact_name, $report_types[$profile->get_report_type()], nl2br($profile->get_notes()));
    $form->setCols(2);
    $form->setTableWidth("450px");
    $form->setData($keyData);
    $form->setTitles($keyTitle);
    $form->setEventHandler($keyHandlers);
    $form->setHeadings($headings);
    $form->setSortable(false);
    echo $form->showForm();
    echo "</div>";
    // Right div
    echo "<div style='position: relative; float:left; margin-left:25px; width:'>";
    // Now we need to create a link to add checks
    // Here a table of checks
    $checks = $profile->get_checks();
    if ($profile->get_error()) {
        print "error " . $profile->get_error() . "<br>";
    }
    $headings = array("Delete", "Check Name", "Template", "Device");
    $keyHandlers = array();
    $keyData = array();
    foreach ($checks as $check_id => $check_name) {
        $check = new Check($check_id);
        array_push($keyData, "<a href='" . $_SERVER['PHP_SELF'] . "?action=del_check_from_profile&profileid=" . $profile->get_profile_id() . "&checkid=" . $check_id . "'>" . "<img src='icons/Delete.png' height=20px></a>", $check->get_name(), $check->get_template_name(), $check->get_hostname());
    }
    $form2 = new Form("auto");
    $form2->setCols(4);
    $form2->setTableWidth("auto");
    $form2->setData($keyData);
    $form2->setEventHandler($keyHandlers);
    $form2->setHeadings($headings);
    $form2->setSortable(true);
    echo $form2->showForm();
    echo "</div>";
}
Example #5
0
         foreach ($all_vlans as $v_id => $vlan_id) {
             $my_vlan = new Vlan_database($v_id);
             array_push($handlers, "handleEvent('" . $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'] . "&className=" . $_GET['className'] . "&family=vlan&v_id=" . $v_id . "')");
             array_push($data, $my_vlan->get_vlan_id());
             array_push($data, $my_vlan->get_name());
             array_push($data, $my_vlan->get_status());
             array_push($data, $my_vlan->get_location_name());
             array_push($data, $my_vlan->get_assigned_to_name());
             array_push($data, $my_vlan->get_vlan_distinguisher());
             array_push($filters, $my_vlan->get_status());
         }
         $form->setSortable(true);
         // or false for not sortable
         $form->setHeadings($heading);
         $form->setData($data);
         $form->setEventHandler($handlers);
         $form->setFilter($filters);
         //set the table size
         $form->setTableWidth("1024px");
         $form->setTitleWidth("20%");
         //export the search result into csv
         echo "<div id='csv_block' style='clear:both; float:left; margin-bottom:5px; margin-top:10px;'><input type='button' onclick='csv_report(\"plugins/IP%20Manager/export_csv.php?report_name=vlan_report&vlan_id=showALL\")' value='Export to CSV' /></div>";
         echo $form->showForm();
     }
 }
 //update VLAN information when the update is called
 if (isset($_POST['updateInfo'])) {
     $my_vlan = new Vlan_database($v_id);
     $my_vlan->set_name($_POST["name"]);
     $my_vlan->set_status($_POST["status"]);
     $my_vlan->set_location($_POST["location"]);
Example #6
0
function render_service_reports()
{
    $content = "<h1>Service Reports</h1>";
    // Start Filter for  service type
    $allServiceTypes = ServiceType::get_service_types();
    #	$allServiceTypes = array('all' => 'all');
    #$allServiceTypes = array_merge($allServiceTypes, ServiceType::get_service_types());
    $allServiceTypes['all'] = 'all';
    $service_type = $_GET['service_type'];
    $service_filter = $_GET['service_type'];
    if ($service_type == '' || !isset($service_type) || !is_numeric($service_type)) {
        $service_type = 'all';
        $service_filter = '';
    }
    $filter = "\r\n\t\t<FORM>\r\n\t\t<DIV style=\" \">\r\n\t\t<SELECT name'=service_type_report'\r\n\t\t\tonChange=\"window.location='services.php?&action=serviceReports&service_type='+this.options[this.selectedIndex].value;\">";
    foreach ($allServiceTypes as $id => $name) {
        if ($service_type == $id) {
            $selected = "SELECTED";
        } else {
            $selected = '';
        }
        $filter .= "<OPTION value='{$id}' {$selected}>{$name}\n";
    }
    $filter .= "\r\n\t\t</SELECT>\r\n\t\t</DIV>\r\n\t\t</FORM>\r\n\t";
    // End filter
    $max_date = strtotime("2009-01-01");
    $start_date = date("Y-m") . "-01";
    // Get all months since start
    $workdate = strtotime($start_date);
    $now = strtotime("Now");
    $form = new Form(auto, 3);
    $headings = array("Period", "In production", "Out of Production");
    $data = array();
    $x_ax_data = array();
    $y_ax_data = array();
    $handlers = array();
    while ($workdate > $max_date) {
        $sql_enddate = date("Y-m-d", $workdate);
        $month_period = date("m-Y", $workdate);
        // This is for the chart
        $month_label = date("M\nY", $workdate);
        $graph_date = strtotime("-1 month", $workdate);
        $month_label = date("M\nY", $graph_date);
        $sql_startdate = date("Y-m-d", $workdate);
        array_push($x_ax_data, $month_label);
        array_push($y_ax_data, count(Service::get_inprod_services_at_date($sql_startdate, $service_filter)));
        // Add one month
        $workdate = strtotime("-1 month", $workdate);
        $sql_startdate = date("Y-m-d", $workdate);
        $out_of_prod = count(Service::get_outprod_services_diff_date($sql_startdate, $sql_enddate, $service_filter));
        $in_prod = count(Service::get_inprod_services_diff_date($sql_startdate, $sql_enddate, $service_filter));
        array_push($data, "{$sql_startdate} {$sql_enddate}");
        array_push($data, $in_prod);
        array_push($data, $out_of_prod);
        array_push($handlers, "handleEvent('services.php?action=detailedServiceReports&start_date={$sql_startdate}&end_date={$sql_enddate}&service_type={$service_type}')");
    }
    $form->setTableWidth("224px");
    $form->setData($data);
    $form->setEventHandler($handlers);
    $form->setHeadings($headings);
    $form->setSortable(true);
    $content .= "<div style=\"float: left; clear: both; margin-right:28px\">" . $form->showForm() . "</div>";
    // Chart
    //
    // This is the MODEL section:
    //
    include 'open-flash-chart/php-ofc-library/open-flash-chart.php';
    // create an X Axis object
    //
    $y_ax_data = array_reverse($y_ax_data);
    $x_ax_data = array_reverse($x_ax_data);
    $x = new x_axis();
    $x->set_steps(3);
    $x->set_labels_from_array($x_ax_data);
    $max = max($y_ax_data);
    $y = new y_axis();
    $y->set_range(0, $max);
    // Bar
    $bar = new bar();
    $bar->set_values($y_ax_data);
    // Bar
    // ------- LINE 2 -----
    $line_2_default_dot = new dot();
    $line_2_default_dot->size(3)->halo_size(1)->colour('#3D5C56');
    $line_2 = new line();
    $line_2->set_default_dot_style($line_2_default_dot);
    $line_2->set_values($y_ax_data);
    $line_2->set_width(3);
    $line_2->set_colour('#3D5C56');
    $chart = new open_flash_chart();
    $title = new title("In Production Services over Time");
    $title->set_style("{font-size: 10px; font-family: Times New Roman; font-weight: bold; color: #000; text-align: center;}");
    $chart->set_bg_colour('#FFFFFF');
    $chart->set_title($title);
    $chart->add_element($bar);
    //$chart->add_element( $line1 );
    $chart->add_element($line_2);
    $chart->set_x_axis($x);
    $chart->set_y_axis($y);
    //
    // This is the VIEW section:
    // Should print this first.
    //
    $heading = "\r\n\t<script type='text/javascript' src='open-flash-chart/js/json/json2.js'></script>\r\n\t<script type='text/javascript' src='open-flash-chart/js/swfobject.js'></script>\r\n\t<script type='text/javascript'>\r\n\tswfobject.embedSWF('open-flash-chart/open-flash-chart.swf', 'my_chart', '660', '350', '9.0.0');\r\n\t</script>\r\n\r\n\t<script type='text/javascript'>\r\n\r\n\tfunction open_flash_chart_data() {\r\n\t\treturn JSON.stringify(data);\r\n\t}\r\n\r\n\tfunction findSWF(movieName) {\r\n  \t\tif (navigator.appName.indexOf('Microsoft')!= -1) {\r\n    \t\t\treturn window[movieName];\r\n  \t\t} else {\r\n    \t\t\treturn document[movieName];\r\n  \t\t}\r\n\t}\r\n    \r\n\tvar data = " . $chart->toPrettyString() . "\r\n\r\n\t</script>\r\n\r\n\r\n\t<script type=\"text/javascript\">\r\n \r\n\tOFC = {};\r\n \r\n\tOFC.jquery = {\r\n    \tname: 'jQuery',\r\n    \tversion: function(src) { return \$('#'+ src)[0].get_version() },\r\n    \trasterize: function (src, dst) { \$('#'+ dst).replaceWith(OFC.jquery.image(src)) },\r\n    \timage: function(src) { return \"<img src='data:image/png;base64,\" + \$('#'+src)[0].get_img_binary() + \"' />\"},\r\n    \tpopup: function(src) {\r\n        var img_win = window.open('', 'Charts: Export as Image')\r\n        with(img_win.document) {\r\n            write('<html><head><title>Charts: Export as Image<\\/title><\\/head><body>' + OFC.jquery.image(src) + '<\\/body><\\/html>') }\r\n\t\t// stop the 'loading...' message\r\n\t\timg_win.document.close();\r\n     \t}\r\n\t}\r\n \r\n\t// Using_ an object as namespaces is JS Best Practice. I like the Control.XXX style.\r\n\t//if (!Control) {var Control = {}}\r\n\t//if (typeof(Control == \"undefined\")) {var Control = {}}\r\n\tif (typeof(Control == \"undefined\")) {var Control = {OFC: OFC.jquery}}\r\n \r\n \r\n\t// By default, right-clicking on OFC and choosing \"save image locally\" calls this function.\r\n\t// You are free to change the code in OFC and call my wrapper (Control.OFC.your_favorite_save_method)\r\n\t// function save_image() { alert(1); Control.OFC.popup('my_chart') }\r\n\tfunction save_image() { alert(\"Your image will be displayed in a new window\"); OFC.jquery.popup('my_chart') }\r\n\t</script>\r\n\t<div id='my_chart' style='float:left; margin-left:28px;'></div>\r\n\t";
    print " {$content}\n \r\n\t\t<div style=''<b>Select Service Type:</b>{$filter} <br></div>\n\r\n\t\t{$heading} ";
}
Example #7
0
 function show_reports()
 {
     $content = '';
     if (isset($_GET['pid']) && is_numeric($_GET['pid'])) {
         $pid = $_GET['pid'];
     } else {
         return "<b>Sorry invalid profile id " . $_GET['pid'] . "</b>";
     }
     $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> >> <a href='{$this->url}&pid={$pid}&action=show_accounting_profile'>{$profile_name}</a>\n\t\t\t>> Reports</div>";
     $query = "select  id, report_name, date1, date2, \n\t\t\tavg_in, avg_out, max_in, max_out,95_in as in95 ,95_out as out95 ,tot_in,tot_out,\n\t\t\tsample_date1, \tsample_date2\n\t\t\tfrom accounting_reports where profile_id = '{$pid}'";
     $result = mysql_query($query);
     if (!$result) {
         print "failed to execute query {$query}<br>";
         return false;
     }
     $content .= "<h2>{$profile_name} reports</h2>";
     $form = new Form("auto", 16);
     $heading = array("Delete", "Graph", "Report Name", "Start date", "End date", "Average In", "Average out", "Max In", "Max out", "95% In", "95% out", "95% Billing", "Total In", "Total out", "First Sample date", "Last Sample date");
     $data = array();
     $handler = array();
     #$content .= "<p><div align=right><a href='$this->url&pid=$pid&action=create_report'>Create new report</a></div></p>";
     #$content .= "<table><tr><th>Delete</th><th>Report Name</th><th>Start date</th<th>End date</th>";
     #$content .= "<th>Average In</th><th>Average out</th<th>Max In</th><th>Max out</th>";
     #$content .= "<th>95% In</th><th>95% out</th<th>95% Billing</th><th>Total In</th><th>Total out</th>";
     #$content .= "<th>First Sample date</th><th>Last Sample date</th><th>Graph</th></tr>";
     while ($obj = mysql_fetch_object($result)) {
         if ($obj->in95 > $obj->out95) {
             $bill95 = $obj->in95;
         } else {
             $bill95 = $obj->out95;
         }
         /*
         $content .= "<tr onclick=\"handleEvent('$this->url&action=render_saved_report&pid=$pid&report_id=".$obj->id."')\">
         	<td><a href='$this->url&action=del_report&report_id=".$obj->id."&pid=$pid'>
         	<img src='icons/Delete.png' height=17></a></td>";
         $content .= "<td>$obj->report_name</td><td>$obj->date1</td>";
         $content .= "<td>$obj->date2</td>";
         $content .= "<td>". $this->int_to_si($obj->avg_in)."bs</td>";
         $content .= "<td>". $this->int_to_si($obj->avg_out) ."bs</td>";
         $content .= "<td>". $this->int_to_si($obj->max_in) ."bs</td>";
         $content .= "<td>". $this->int_to_si($obj->max_out) ."bs</td>";
         $content .= "<td>". $this->int_to_si($obj->in95) ."bs</td>";
         $content .= "<td>". $this->int_to_si($obj->out95) ."bs</td>";
         $content .= "<td>". $this->int_to_si($bill95) ."bs</td>";
         $content .= "<td>". $this->int_to_si($obj->tot_in)."B</td>";
         $content .="<td>". $this->int_to_si($obj->tot_out) ."B</td>";
         $content .= "<td>$obj->sample_date1</td><td>$obj->sample_date2</td>";
         $content .= "<td><img src=plugins/SCU-Accounting/sql_img.php?report_id=".$obj->id."height=10 width=40></td>";
         $content .= "</tr>";
         */
         $profile_name = $this->get_accounting_profile_name($pid);
         $avg_in = $this->int_to_si($obj->avg_in) . "bs";
         $avg_out = $this->int_to_si($obj->avg_out) . "bs";
         $max_in = $this->int_to_si($obj->max_in) . "bs";
         $max_out = $this->int_to_si($obj->max_out) . "bs";
         $in95 = $this->int_to_si($obj->in95) . "bs";
         $out95 = $this->int_to_si($obj->out95) . "bs";
         $bill95 = $this->int_to_si($bill95) . "bs";
         $tot_in = $this->int_to_si($obj->tot_in) . "B";
         $tot_out = $this->int_to_si($obj->tot_out) . "B";
         $imglink = "plugins/SCU-Accounting/sql_img.php?report_id=" . $obj->id;
         array_push($data, "<a href='{$this->url}&action=del_report&report_id=" . $obj->id . "&pid={$pid}'><img src='icons/Delete.png' height=17></a>", "<a class='screenshot' title='Statistics' rel='{$imglink}'><img src='{$imglink}' height=20 width=44></a>", $obj->report_name, $obj->date1, $obj->date2, $avg_in, $avg_out, $max_in, $max_out, $in95, $out95, $bill95, $tot_in, $tot_out, $obj->sample_date1, $obj->sample_date2);
     }
     $form->setSortable(true);
     // or false for not sortable
     $form->setHeadings($heading);
     $form->setEventHandler($handler);
     $form->setData($data);
     //set the table size
     $form->setTableWidth("100%");
     $content .= $form->showForm();
     return $content;
 }
Example #8
0
function displayPaths()
{
    global $tool, $propertyForm;
    $my_paths = array("path_snmpwalk" => "snmpwalk", "path_snmpget" => "snmpget", "path_rrdupdate" => "rrdupdate", "path_rrdtool" => "rrdtool", "path_rrddir" => "RRD Directory");
    $content = "";
    $content .= "<h1>System Paths</h1>";
    $content .= "<div style='padding-left: 600px;'>\n\t\t\t<a class='tooltip' title='This will try to detect the tools below in the current \$path'><img src='icons/Info.png' height='19'></a>\n\t\t\t<a href='javascript:LoadPage(\"configurations.php?action=paths&mode=autodetect\",\"settingsInfo\")'>\n\t\t\tclick here to Auto Discover paths</a></div>";
    $form = new Form("auto", 2);
    $keyHandlers = array();
    $keyData = array();
    $keyTitle = array();
    $postKeys = array();
    foreach ($my_paths as $id => $path) {
        $property = new Property();
        $value = $property->get_property($id);
        if ($value === false) {
            $value = "WARNING: Property '{$id}' Not Found in Property table, Contact your admininistrator" . $property->get_error();
        }
        $desc = $property->get_desc($id);
        if (is_readable($value)) {
            $check = "<font size='' color='green'>Found!</font>";
            if ($id == 'path_rrdtool') {
                $cmd = "{$value} -v| awk '{print \$2}'|head -1";
                exec($cmd, $output, $return_var);
                if ($output[0] < "1.4") {
                    $check = "<font size='' color='Orange'>Found version {$output['0']}! You need at least RRDtool version 1.4.0 otherwise some graphs won't display correctlty</font>";
                }
            }
        } else {
            $check = "<font size='' color='orange'>Not Found!</font>";
        }
        array_push($postKeys, "{$id}");
        array_push($keyData, "{$value}");
        array_push($keyTitle, "<font size='2'>{$path}</font><br><i>{$desc}</i><br>{$check}");
        #$content .= "<tr><td><input type=checkbox name=devices[] value='$id' $checked ></td>";
        #$content .= "<td>$name</td><td>". $deviceInfo->get_type_name() ."</td>";
        #$content .= "<td>". $deviceInfo->get_location_name() ."</td></tr>";
    }
    #$content .= "</table> <br>";
    //get all the device and display them all in the 3 sections "Device Name", "Device Type", "Location".
    $heading = array("Program", "Path");
    $form->setSortable(true);
    // or false for not sortable
    $form->setHeadings($heading);
    $form->setEventHandler($handler);
    $form->setData($keyData);
    $form->setTitles($keyTitle);
    $form->setTableWidth("800px");
    $form->setDatabase($postKeys);
    $form->setUpdateValue("savePaths");
    $form->setUpdateText("Save Program Paths");
    $content .= $form->editForm();
    print $content;
}
Example #9
0
 function render_list_changes()
 {
     // This renders all the changes p
     $content = "<h1>Change Manager</h1>";
     // Tools menu
     $tool = new EdittingTools();
     if ($_SESSION['access'] >= 50) {
         $toolNames = array("New Change", "List Changes", "Search", "Report");
         $toolIcons = array("add", "stat", "search", "report");
         $toolHandlers = array("window.location.href='{$this->url}&action=new_change'", "window.location.href='{$this->url}&action=render_report'", "window.location.href='{$this->url}&action=search'", "window.location.href='{$this->url}&action=report'");
         $content .= $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
     }
     $content .= $tool->createNewFilters();
     $content .= " <div style=\"clear:both;\"></div><br> ";
     // Prepare query
     $query = "SELECT change_id, title, notes, change_date, planned_change_date, \n\t\t\t\t\tchange_contact_1, change_contact_2, status\n\t\t\t\t\tFROM plugin_ChangeManager_Changes\n\t\t\t\t\tORDER BY change_id DESC";
     $result = mysql_query($query);
     if (!$result) {
         return "<b>Oops something went wrong, unable to select changes </b>";
     }
     $form = new Form("auto", 6);
     $heading = array("Change ID", "Change", "Planned Time", "Contact", "Status", "Actions");
     $data = array();
     $handler = array();
     while ($obj = mysql_fetch_object($result)) {
         $user = new User($obj->change_contact_1);
         $contact_name = $user->get_full_name();
         $actions = "<a href='{$this->url}&action=delete_change&cid={$obj->change_id}&return=list_changes'>\n<img src='icons/Delete.png' height=18></a> ";
         if ($obj->status > 0) {
             $actions .= "<a href='{$this->url}&action=email_change&cid={$obj->change_id}'>\n<img src='icons/Email.png' height=18></a> ";
         }
         array_push($data, $obj->change_id, $obj->title, $obj->planned_change_date, $contact_name, $this->status_values[$obj->status], $actions);
         // Event handler
         $url = $this->url . "&action=show_change&cid={$obj->change_id}";
         array_push($handler, "handleEvent('{$url}')");
     }
     $form->setSortable(true);
     // or false for not sortable
     $form->setHeadings($heading);
     $form->setEventHandler($handler);
     $form->setData($data);
     //set the table size
     #$form->setTableWidth("100%");
     $content .= $form->showForm();
     return $content;
 }