'Delete', 2 => 'Duplicate' ); /* set default action */ if (!isset($_REQUEST['action'])) { $_REQUEST['action'] = ''; } switch ($_REQUEST['action']) { case 'save': form_save(); break; case 'actions': form_actions(); break; case 'item_movedown': item_movedown(); header('Location: cdef.php?action=edit&id=' . $_REQUEST['cdef_id']); break; case 'item_moveup': item_moveup(); header('Location: cdef.php?action=edit&id=' . $_REQUEST['cdef_id']); break; case 'item_remove': item_remove(); header('Location: cdef.php?action=edit&id=' . $_REQUEST['cdef_id']); break; case 'item_edit': top_header(); item_edit(); bottom_footer(); break; case 'edit': top_header(); cdef_edit(); bottom_footer(); break; default: top_header(); cdef(); bottom_footer(); break; } /* -------------------------- Global Form Functions -------------------------- */ function draw_cdef_preview($cdef_id) { ?>
cdef=
' . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM cdef WHERE id = ?', array($matches[1]))) . ''; $cdef_array[$i] = $matches[1]; $i++; } } top_header(); print "
\n"; html_start_box('' . $cdef_actions{$_POST['drp_action']} . '', '60%', '', '3', 'center', ''); if (isset($cdef_array) && sizeof($cdef_array)) { if ($_POST['drp_action'] == '1') { /* delete */ print "

When you click \"Continue\", the folling CDEF(s) will be deleted.

\n"; $save_html = " "; }elseif ($_POST['drp_action'] == '2') { /* duplicate */ print "

When you click \"Continue\", the following CDEFs will be duplicated. You can optionally change the title format for the new CDEFs.

Title Format:
"; form_text_box('title_format', ' (1)', '', '255', '30', 'text'); print "

\n"; $save_html = " "; } }else{ print "You must select at least one CDEF.\n"; $save_html = ""; } print " $save_html \n"; html_end_box(); bottom_footer(); } /* -------------------------- CDEF Item Functions -------------------------- */ function item_movedown() { /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('cdef_id')); /* ==================================================== */ move_item_down('cdef_items', $_REQUEST['id'], 'cdef_id=' . $_REQUEST['cdef_id']); } function item_moveup() { /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('cdef_id')); /* ==================================================== */ move_item_up('cdef_items', $_REQUEST['id'], 'cdef_id=' . $_REQUEST['cdef_id']); } function item_remove() { /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('cdef_id')); /* ==================================================== */ db_execute_prepared('DELETE FROM cdef_items WHERE id = ?', array(get_request_var_request('id'))); } function item_edit() { global $cdef_item_types, $cdef_functions, $cdef_operators, $custom_data_source_types; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('cdef_id')); /* ==================================================== */ if (!empty($_REQUEST['id'])) { $cdef = db_fetch_row_prepared('SELECT * FROM cdef_items WHERE id = ?', array(get_request_var_request('id'))); $current_type = $cdef['type']; $values[$current_type] = $cdef['value']; } html_start_box('', '100%', '', '3', 'center', ''); draw_cdef_preview($_REQUEST['cdef_id']); html_end_box(); print "\n"; html_start_box('CDEF Items [edit: ' . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM cdef WHERE id = ?', array(get_request_var_request('cdef_id')))) . ']', '100%', '', '3', 'center', ''); if (isset($_REQUEST['type_select'])) { $current_type = $_REQUEST['type_select']; }elseif (isset($cdef['type'])) { $current_type = $cdef['type']; }else{ $current_type = '1'; } form_alternate_row();?> CDEF Item Type
Choose what type of CDEF item this is. form_alternate_row();?> CDEF Item Value
Enter a value for this CDEF item. CDEF's $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('CDEF Items', '100%', '', '3', 'center', 'cdef.php?action=item_edit&cdef_id=' . $cdef['id']); print ""; DrawMatrixHeaderItem('Item', '', 1); DrawMatrixHeaderItem('Position', '', 1); DrawMatrixHeaderItem('Item Value', '', 2); print ''; $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++;?> '>Item # '>Move Down '>Move Up : '>Delete CDEF's", '100%', '', '3', 'center', 'cdef.php?action=edit'); ?>
Search '> CDEFs >
'>
0'; }else{ $sql_having = ''; } /* print checkbox form for validation */ print "
\n"; html_start_box('', '100%', '', '3', 'center', ''); $total_rows = db_fetch_cell("SELECT COUNT(rows) FROM ( SELECT cd.id AS rows, SUM(CASE WHEN local_graph_id>0 THEN 1 ELSE 0 END) AS graphs FROM cdef AS cd LEFT JOIN graph_templates_item AS gti ON gti.cdef_id=cd.id $sql_where GROUP BY cd.id $sql_having ) AS rs"); $cdef_list = db_fetch_assoc("SELECT rs.*, SUM(CASE WHEN local_graph_id=0 THEN 1 ELSE 0 END) AS templates, SUM(CASE WHEN local_graph_id>0 THEN 1 ELSE 0 END) AS graphs FROM ( SELECT cd.*, gti.local_graph_id FROM cdef AS cd LEFT JOIN graph_templates_item AS gti ON gti.cdef_id=cd.id GROUP BY cd.id, gti.graph_template_id, gti.local_graph_id ) AS rs $sql_where GROUP BY rs.id $sql_having ORDER BY " . get_request_var_request('sort_column') . ' ' . get_request_var_request('sort_direction') . ' LIMIT ' . (get_request_var_request('rows')*(get_request_var_request('page')-1)) . ',' . get_request_var_request('rows')); $nav = html_nav_bar('cdef.php?filter=' . get_request_var_request('filter'), MAX_DISPLAY_PAGES, get_request_var_request('page'), get_request_var_request('rows'), $total_rows, 5, 'CDEFs', 'page', 'main'); print $nav; $display_text = array( 'name' => array('display' => 'CDEF Name', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The name of this CDEF.'), 'nosort' => array('display' => 'Deletable', 'align' => 'right', 'tip' => 'CDEFs that are in use can not be Deleted. In use is defined as being referenced by a Graph or a Graph Template.'), 'graphs' => array('display' => 'Graphs Using', 'align' => 'right', 'sort' => 'DESC', 'tip' => 'The number of Graphs using this CDEF.'), 'templates' => array('display' => 'Templates Using', 'align' => 'right', 'sort' => 'DESC', 'tip' => 'The number of Graphs Templates using this CDEF.')); html_header_sort_checkbox($display_text, get_request_var_request('sort_column'), get_request_var_request('sort_direction'), false); $i = 0; if (sizeof($cdef_list) > 0) { foreach ($cdef_list as $cdef) { if ($cdef['graphs'] == 0 && $cdef['templates'] == 0) { $disabled = false; }else{ $disabled = true; } form_alternate_row('line' . $cdef['id'], false, $disabled); form_selectable_cell("" . (strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter'), '/') . ')/i', "\\1", htmlspecialchars($cdef['name'])) : htmlspecialchars($cdef['name'])) . '', $cdef['id']); form_selectable_cell($disabled ? 'No':'Yes', $cdef['id'], '', 'text-align:right'); form_selectable_cell($cdef['graphs'], $cdef['id'], '', 'text-align:right'); form_selectable_cell($cdef['templates'], $cdef['id'], '', 'text-align:right'); form_checkbox_cell($cdef['name'], $cdef['id'], $disabled); form_end_row(); } print $nav; }else{ print "No CDEFs\n"; } html_end_box(false); /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($cdef_actions); print "
\n"; }