Example #1
0
function api_graph_template_item_moveup($graph_template_item_id) {
	require_once(CACTI_BASE_PATH . "/lib/sys/sequence.php");

	$graph_template_id = db_fetch_cell("select graph_template_id from graph_template_item where id = $graph_template_item_id");

	$last_item = seq_get_item("graph_template_item", "sequence", $graph_template_item_id, "graph_template_id = $graph_template_id", "previous");

	seq_move_item("graph_template_item", $graph_template_item_id, "graph_template_id = $graph_template_id", "up");

	db_execute("update graph_item set sequence = " . db_fetch_cell("select sequence from graph_template_item where id = $graph_template_item_id") . " where graph_template_item_id = $graph_template_item_id");
	db_execute("update graph_item set sequence = " . db_fetch_cell("select sequence from graph_template_item where id = $last_item") . " where graph_template_item_id = $last_item");
}
Example #2
0
function seq_move_item($table_name, $current_id, $group_query, $direction) {
	$new_item = seq_get_item($table_name, "sequence", $current_id, $group_query, ($direction == "down" ? "next" : "previous"));

	$current_sequence = db_fetch_cell("select sequence from $table_name where id=$current_id");
	$new_sequence = db_fetch_cell("select sequence from $table_name where id=$new_item");
	db_execute("update $table_name set sequence=$new_sequence where id=$current_id");
	db_execute("update $table_name set sequence=$current_sequence where id=$new_item");
}