Example #1
0
function cdef_edit() {
	global $colors;
	require(CACTI_BASE_PATH . "/include/presets/preset_cdef_arrays.php");
	require_once(CACTI_BASE_PATH . "/lib/presets/preset_cdef_info.php");

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var("id"));
	/* ==================================================== */

	if (!empty($_GET["id"])) {
		$cdef = db_fetch_row("select * from cdef where id=" . $_GET["id"]);
		$header_label = __("[edit: ") . $cdef["name"] . "]";
	}else{
		$header_label = __("[new]");
	}

	print "<form method='post' action='" .  basename($_SERVER["PHP_SELF"]) . "' name='cdef_edit'>\n";
	html_start_box("<strong>". __("CDEF's") . "</strong> $header_label", "100", $colors["header"], 0, "center", "");
	$header_items = array(__("Field"), __("Value"));
	print "<tr><td>";
	html_header($header_items, 2, false, 'header_cdef_edit','left wp100');

	draw_edit_form(array(
		"config" => array(),
		"fields" => inject_form_variables(preset_cdef_form_list(), (isset($cdef) ? $cdef : array()))
		));

	print "</table></td></tr>";		/* end of html_header */
	html_end_box();

	if (!empty($_GET["id"])) {
		html_start_box("", "100", "aaaaaa", "3", "center", "");
		draw_cdef_preview(get_request_var("id"));
		html_end_box();

		html_start_box("<strong>" . __("CDEF Items") . "</strong>", "100", $colors["header"], 0, "center", "cdef.php?action=item_edit&cdef_id=" . $cdef["id"], false, "cdef");
		$header_items = array(__("Item"), __("Item Value"));
		print "<tr><td>";
		html_header($header_items, 2, true, 'cdef_item','left wp100');

		$cdef_items = db_fetch_assoc("select * from cdef_items where cdef_id=" . $_GET["id"] . " order by sequence");

		$i = 0;
		if (sizeof($cdef_items) > 0) {
			foreach ($cdef_items as $cdef_item) {
				form_alternate_row_color($cdef_item["id"], true);
					?>
					<td>
						<a class="linkEditMain" href="<?php print htmlspecialchars("cdef.php?action=item_edit&id=" . $cdef_item["id"] . "&cdef_id=" . $cdef["id"]);?>">Item #<?php print $i;?></a>
					</td>
					<td>
						<em><?php $cdef_item_type = $cdef_item["type"]; print $cdef_item_types[$cdef_item_type];?></em>: <strong><?php print get_cdef_item_name($cdef_item["id"]);?></strong>
					</td>
					<td align="right">
						<a href="<?php print htmlspecialchars("cdef.php?action=item_remove&id=" . $cdef_item["id"] . "&cdef_id=" . $cdef["id"]);?>"><img class="buttonSmall" src="images/delete_icon.gif" alt="<?php print __("Delete");?>" align='middle'></a>
					</td>
			<?php
			form_end_row();
			$i++;
			}
		}
		print "</table></td></tr>";		/* end of html_header */
		html_end_box();
	}
	form_save_button_alt("path!cdef.php");
?>
<script type="text/javascript">
	$('#cdef_item').tableDnD({
		onDrop: function(table, row) {
			$('#AjaxResult').load("lib/ajax/jquery.tablednd/cdef.ajax.php?id=<?php isset($_GET["id"]) ? print $_GET["id"] : print 0;?>&"+$.tableDnD.serialize());
		}
	});
</script>
<?php

}
Example #2
0
function cdef_edit() {
	global $colors, $cdef_item_types, $fields_cdef_edit;

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var("id"));
	/* ==================================================== */

	if (!empty($_GET["id"])) {
		$cdef = db_fetch_row("select * from cdef where id=" . $_GET["id"]);
		$header_label = "[edit: " . $cdef["name"] . "]";
	}else{
		$header_label = "[new]";
	}

	html_start_box("<strong>CDEF's</strong> $header_label", "98%", $colors["header"], "3", "center", "");

	draw_edit_form(array(
		"config" => array(),
		"fields" => inject_form_variables($fields_cdef_edit, (isset($cdef) ? $cdef : array()))
		));

	html_end_box();

	if (!empty($_GET["id"])) {
		html_start_box("", "98%", "aaaaaa", "3", "center", "");
		draw_cdef_preview($_GET["id"]);
		html_end_box();

		html_start_box("<strong>CDEF Items</strong>", "98%", $colors["header"], "3", "center", "cdef.php?action=item_edit&cdef_id=" . $cdef["id"]);

		print "<tr bgcolor='#" . $colors["header_panel"] . "'>";
			DrawMatrixHeaderItem("Item",$colors["header_text"],1);
			DrawMatrixHeaderItem("Item Value",$colors["header_text"],1);
			DrawMatrixHeaderItem("&nbsp;",$colors["header_text"],2);
		print "</tr>";

		$cdef_items = db_fetch_assoc("select * from cdef_items where cdef_id=" . $_GET["id"] . " order by sequence");

		$i = 0;
		if (sizeof($cdef_items) > 0) {
		foreach ($cdef_items as $cdef_item) {
			form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++;
				?>
				<td>
					<a class="linkEditMain" href="cdef.php?action=item_edit&id=<?php print $cdef_item["id"];?>&cdef_id=<?php print $cdef["id"];?>">Item #<?php print $i;?></a>
				</td>
				<td>
					<em><?php $cdef_item_type = $cdef_item["type"]; print $cdef_item_types[$cdef_item_type];?></em>: <strong><?php print get_cdef_item_name($cdef_item["id"]);?></strong>
				</td>
				<td>
					<a href="cdef.php?action=item_movedown&id=<?php print $cdef_item["id"];?>&cdef_id=<?php print $cdef["id"];?>"><img src="images/move_down.gif" border="0" alt="Move Down"></a>
					<a href="cdef.php?action=item_moveup&id=<?php print $cdef_item["id"];?>&cdef_id=<?php print $cdef["id"];?>"><img src="images/move_up.gif" border="0" alt="Move Up"></a>
				</td>
				<td align="right">
					<a href="cdef.php?action=item_remove&id=<?php print $cdef_item["id"];?>&cdef_id=<?php print $cdef["id"];?>"><img src="images/delete_icon.gif" width="10" height="10" border="0" alt="Delete"></a>
				</td>
			</tr>
		<?php
		}
		}
		html_end_box();
	}

	form_save_button("cdef.php");
}
Example #3
0
File: cdef.php Project: MrWnn/cacti
function cdef_edit()
{
    global $cdef_item_types, $fields_cdef_edit;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    /* ==================================================== */
    if (!empty($_REQUEST['id'])) {
        $cdef = db_fetch_row_prepared('SELECT * FROM cdef WHERE id = ?', array(get_request_var_request('id')));
        $header_label = '[edit: ' . htmlspecialchars($cdef['name']) . ']';
    } else {
        $header_label = '[new]';
    }
    html_start_box("<strong>CDEF's</strong> {$header_label}", '100%', '', '3', 'center', '');
    draw_edit_form(array('config' => array(), 'fields' => inject_form_variables($fields_cdef_edit, isset($cdef) ? $cdef : array())));
    html_end_box();
    if (!empty($_REQUEST['id'])) {
        html_start_box('', '100%', '', '3', 'center', '');
        draw_cdef_preview($_REQUEST['id']);
        html_end_box();
        html_start_box('<strong>CDEF Items</strong>', '100%', '', '3', 'center', 'cdef.php?action=item_edit&cdef_id=' . $cdef['id']);
        print "<tr class='tableHeader'>";
        DrawMatrixHeaderItem('Item', '', 1);
        DrawMatrixHeaderItem('Position', '', 1);
        DrawMatrixHeaderItem('Item Value', '', 2);
        print '</tr>';
        $cdef_items = db_fetch_assoc_prepared('SELECT * FROM cdef_items WHERE cdef_id = ? ORDER BY sequence', array(get_request_var_request('id')));
        $i = 0;
        if (sizeof($cdef_items) > 0) {
            foreach ($cdef_items as $cdef_item) {
                form_alternate_row();
                $i++;
                ?>
					<td style='white-space:nowrap;'>
						<a class='linkEditMain' href='<?php 
                print htmlspecialchars('cdef.php?action=item_edit&id=' . $cdef_item['id'] . '&cdef_id=' . $cdef['id']);
                ?>
'>Item #<?php 
                print htmlspecialchars($i);
                ?>
</a>
					</td>
					<td align='left' width='50'>
						<a href='<?php 
                print htmlspecialchars('cdef.php?action=item_movedown&id=' . $cdef_item['id'] . '&cdef_id=' . $cdef['id']);
                ?>
'><img src='images/move_down.gif' border='0' alt='Move Down'></a>
						<a href='<?php 
                print htmlspecialchars('cdef.php?action=item_moveup&id=' . $cdef_item['id'] . '&cdef_id=' . $cdef['id']);
                ?>
'><img src='images/move_up.gif' border='0' alt='Move Up'></a>
					</td>
					<td>
						<em><?php 
                $cdef_item_type = $cdef_item['type'];
                print $cdef_item_types[$cdef_item_type];
                ?>
</em>: <strong><?php 
                print htmlspecialchars(get_cdef_item_name($cdef_item['id']));
                ?>
</strong>
					</td>
					<td align='right'>
						<a href='<?php 
                print htmlspecialchars('cdef.php?action=item_remove&id=' . $cdef_item['id'] . '&cdef_id=' . $cdef['id']);
                ?>
'><img src='images/delete_icon.gif' style='height:10px;width:10px;' border='0' alt='Delete'></a>
					</td>
				</tr>
			<?php 
            }
        }
        html_end_box();
    }
    form_save_button('cdef.php', 'return');
}