'.__('Created successfully').''; $id_layout = mysql_insert_id (); } else { echo '

'.__('Not created. Error inserting data').'

'; } if (defined ('AJAX')) { exit; } } if ($delete_layout) { $sql = sprintf ('DELETE FROM tlayout_data WHERE id_layout = %d', $id_layout); mysql_query ($sql); $sql = sprintf ('DELETE FROM tlayout WHERE id = %d', $id_layout); $result = mysql_query ($sql); if ($result) { echo '

'.__('Deleted successfully').'

'; } else { echo '

'.__('Not deleted. Error deleting data').'

'; } $id_layout = 0; } if ($update_layout) { $name = (string) get_parameter ('name'); $id_group = (int) get_parameter ('id_group'); $width = (int) get_parameter ('width'); $height = (int) get_parameter ('height'); $background = (string) get_parameter ('background'); $bg_info = array (0, 0); if (file_exists ('images/console/background/'.$background)) $bg_info = getimagesize ('images/console/background/'.$background); if (! $width) $width = $bg_info[0]; if (! $height) $height = $bg_info[1]; $sql = sprintf ('UPDATE tlayout SET name = "%s", background = "%s", height = %d, width = %d WHERE id = %d', $name, $background, $height, $width, $id_layout); $result = mysql_query ($sql); if ($result) { echo '

'.__('Update layout successful').'

'; } else { echo '

'.__('Update layout failed').'

'; } if (defined ('AJAX')) { exit; } } if ($get_background_info) { $file = (string) get_parameter ('background'); $info = getimagesize ('images/console/background/'.$file); $info['width'] = $info[0]; $info['height'] = $info[1]; if (defined ('AJAX')) { echo json_encode ($info); exit; } } if ($get_layout_data) { $id_layout_data = (int) get_parameter ('id_layout_data'); $layout_data = get_db_row ('tlayout_data', 'id', $id_layout_data); $layout_data['id_agent'] = give_agent_id_from_module_id ($layout_data['id_agente_modulo']); if (defined ('AJAX')) { echo json_encode ($layout_data); exit; } } if ($create_layout_data) { $layout_data_type = (string) get_parameter ("type"); $layout_data_label = (string) get_parameter ("label"); $layout_data_image = (string) get_parameter ("image"); $layout_data_id_agent_module = (int) get_parameter ("module"); $layout_data_label_color = (string) get_parameter ("label_color"); $layout_data_parent_item = (int) get_parameter ("parent_item"); $layout_data_period = (int) get_parameter ("period"); $layout_data_map_linked = (int) get_parameter ("map_linked"); $layout_data_width = (int) get_parameter ("width"); $layout_data_height = (int) get_parameter ("height"); $sql = sprintf ('INSERT INTO tlayout_data (id_layout, label, id_layout_linked, label_color, image, type, id_agente_modulo, parent_item, period, no_link_color, width, height) VALUES (%d, "%s", %d, "%s", "%s", %d, %d, %d, %d, 1, %d, %d)', $id_layout, $layout_data_label, $layout_data_map_linked, $layout_data_label_color, $layout_data_image, $layout_data_type, $layout_data_id_agent_module, $layout_data_parent_item, $layout_data_period * 3600, $layout_data_width, $layout_data_height); $result = mysql_query ($sql); if ($result) { echo '

'.__('Created successfully').'

'; } else { echo '

'.__('Not created. Error inserting data').'

'; } if (defined ('AJAX')) { exit; } } if ($update_layout_data_coords) { $id_layout_data = (int) get_parameter ('id_layout_data'); $layout_data_x = (int) get_parameter ("coord_x"); $layout_data_y = (int) get_parameter ("coord_y"); $sql = sprintf ('UPDATE tlayout_data SET pos_x = %d, pos_y = %d WHERE id = %d', $layout_data_x, $layout_data_y, $id_layout_data); $result = mysql_query ($sql); if (defined ('AJAX')) { exit; } } if ($delete_layout_data) { $ids_layout_data = (array) get_parameter ('ids_layout_data'); foreach ($ids_layout_data as $id_layout_data) { $sql = sprintf ('UPDATE tlayout_data SET parent_item = 0 WHERE parent_item = %d', $id_layout_data); $result = mysql_query ($sql); $sql = sprintf ('DELETE FROM tlayout_data WHERE id = %d', $id_layout_data); $result = mysql_query ($sql); } if (defined ('AJAX')) { exit; } } if ($update_layout_data) { $id_layout_data = (int) get_parameter ('id_layout_data'); $layout_data_type = (int) get_parameter ("type"); $layout_data_label = (string) get_parameter ("label"); $layout_data_image = (string) get_parameter ("image"); $layout_data_id_agent_module = (int) get_parameter ("module"); $layout_data_label_color = (string) get_parameter ("label_color"); $layout_data_parent_item = (int) get_parameter ("parent_item"); $layout_data_period = (int) get_parameter ("period"); $layout_data_map_linked = (int) get_parameter ("map_linked"); $layout_data_width = (int) get_parameter ("width"); $layout_data_height = (int) get_parameter ("height"); $sql = sprintf ('UPDATE tlayout_data SET image = "%s", label = "%s", label_color = "%s", id_agente_modulo = %d, type = %d, parent_item = %d, period = %d, id_layout_linked = %d, width = %d, height = %d WHERE id = %d', $layout_data_image, $layout_data_label, $layout_data_label_color, $layout_data_id_agent_module, $layout_data_type, $layout_data_parent_item, $layout_data_period * 3600, $layout_data_map_linked, $layout_data_width, $layout_data_height, $id_layout_data); $result = mysql_query ($sql); if ($result) { echo '

'.__('Updated successfully').'

'; } else { echo '

'.__('Not updated. Error updating data').'

'; } } if ($id_layout) { $layout = get_db_row ('tlayout', 'id', $id_layout); $name = $layout['name']; $background = $layout['background']; $id_group = $layout['id_group']; $width = $layout['width']; $height = $layout['height']; } if (! $edit_layout && ! $id_layout) { echo "

".__('Reporting')." > ".__('Map builder')."

"; $table->width = '500px'; $table->data = array (); $table->head = array (); $table->head[0] = __('Map name'); $table->head[1] = __('Group'); $table->head[2] = __('Delete'); $table->align = array (); $table->align[2] = 'center'; $maps = get_db_all_rows_in_table ('tlayout','name'); if (!$maps) echo '
'.('No maps defined').'
'; else { foreach ($maps as $map) { $data = array (); $data[0] = ''.$map['name'].''; $data[1] = ' '; $data[1] .= dame_nombre_grupo ($map['id_group']); $data[2] = ' '; array_push ($table->data, $data); } print_table ($table); } echo '
'; echo '
'; print_input_hidden ('edit_layout', 1); print_submit_button (__('Create'), '', false, 'class="sub wand"'); echo '
'; echo '
'; } else { echo "

".__('Reporting')." > "; echo __('Map builder'); pandora_help ("map_builder"); echo "

"; $backgrounds_list = list_files ('images/console/background/', "jpg", 1, 0); $backgrounds_list = array_merge ($backgrounds_list, list_files ('images/console/background/', "png", 1, 0)); $groups = get_user_groups ($config['id_user']); $table->width = '340px'; $table->data = array (); $table->data[0][0] = __('Name'); $table->data[0][1] = print_input_text ('name', $name, '', 15, 50, true); $table->data[1][0] = __('Group'); $table->data[1][1] = print_select ($groups, 'id_group', $id_group, '', '', '', true); $table->data[2][0] = __('Background'); $table->data[2][1] = print_select ($backgrounds_list, 'background', $background, '', 'None', '', true); if ($id_layout) { $table->data[3][0] = __('Width'); $table->data[3][1] = print_input_text ('width', $width, '', 3, 5, true); $table->data[4][0] = __('Height'); $table->data[4][1] = print_input_text ('height', $height, '', 3, 5, true); } echo '
'; print_table ($table); echo '
'; if ($id_layout) { print_submit_button (__('Update'), 'update_layout', false, 'class="sub upd"'); print_input_hidden ('update_layout', 1); print_input_hidden ('id_layout', $id_layout); } else { print_submit_button (__('Create'), 'create_layout', false, 'class="sub wand"'); print_input_hidden ('create_layout', 1); } echo '
'; echo '
'; if ($id_layout) { /* Show visual map preview */ echo '

'.__('preview').'

'; print_pandora_visual_map ($id_layout, false, true); $images_list = array (); $all_images = list_files ('images/console/icons/', "png", 1, 0); foreach ($all_images as $image_file) { if (strpos ($image_file, "_bad")) continue; if (strpos ($image_file, "_ok")) continue; $image_file = substr ($image_file, 0, strlen ($image_file) - 4); $images_list[$image_file] = $image_file; } echo '
'; /* Layout data trash */ echo '
'; echo '
'; echo '

'.__('Map element trash').'

'; echo __('Drag an element here to delete from the map'); echo ' '; print_input_hidden ('delete_layout_data', 1); print_input_hidden ('id_layout', $id_layout); echo '
'; print_submit_button (__('Delete'), 'delete_buttons', true, 'class="sub delete"'); echo '
'; echo '
'; echo '
'; /* Layout_data editor form */ $intervals = array (); $intervals[1] = __('Hour'); $intervals[2] = "2 ".__('Hours'); $intervals[3] = "3 ".__('Hours'); $intervals[6] = "6 ".__('Hours'); $intervals[12] = "12 ".__('Hours'); $intervals[24] = __('Last day'); $intervals[48] = "2 ". __('days'); $intervals[168] = __('Last week'); $intervals[360] = __('15 days'); $intervals[720] = __('Last Month'); $intervals[1440] = __('Two Months'); $intervals[4320] = __('Six Months'); $all_agents = get_agents_in_group ($id_group); $agents = array (); if ($all_agents !== false) { foreach ($all_agents as $agent) { $agents[$agent['id_agente']] = strtolower($agent['nombre']); } asort($agents); } echo '
'; echo '

'.__('Map element editor').'

'; echo __('Drag an element here to edit the properties'); $table->data = array (); $table->id = 'table_layout_data'; $table->rowstyle = array (); $table->rowstyle[3] = 'display: none'; $table->rowstyle[4] = 'display: none'; $table->data[0][0] = __('Label'); $table->data[0][1] = print_input_text ('label', '', '', 20, 200, true); $table->data[1][0] = __('Label color'); $table->data[1][1] = print_input_text ('label_color', '#000000', '', 7, 7, true); $table->data[2][0] = __('Type'); $table->data[2][1] = print_select (get_layout_data_types (), 'type', '', '', '', '', true); $table->data[3][0] = __('Height'); $table->data[3][1] = print_input_text ('height', '', '', 5, 5, true); $table->data[4][0] = __('Width'); $table->data[4][1] = print_input_text ('width', '', '', 5, 5, true); $table->data[5][0] = __('Agent'); $table->data[5][1] = print_select ($agents, 'agent', '', '', '--', 0, true); $table->data[6][0] = __('Module'); $table->data[6][1] = print_select (array (), 'module', '', '', '--', 0, true); $table->data[7][0] = __('Period'); $table->data[7][1] = print_select ($intervals, 'period', '', '', '--', 0, true); $table->data[8][0] = __('Image'); $table->data[8][1] = print_select ($images_list, 'image', '', '', 'None', '', true); $table->data[8][1] .= '
'; $table->data[9][0] = __('Parent'); $table->data[9][1] = print_select_from_sql ('SELECT id, label FROM tlayout_data WHERE id_layout = '.$id_layout, 'parent_item', '', '', 'None', '', true); $table->data[10][0] = __('Map linked'); $table->data[10][1] = print_select_from_sql ('SELECT id, name FROM tlayout WHERE id != '.$id_layout, 'map_linked', '', '', 'None', '', true); echo '
'; print_table ($table); print_input_hidden ('create_layout_data', 1); print_input_hidden ('update_layout_data', 0); print_input_hidden ('id_layout', $id_layout); print_input_hidden ('id_layout_data', 0); echo '
'; print_submit_button (__('Create'), 'create_layout_data_button', false, 'class="sub wand"'); echo '
'; echo '
'; echo '
'; echo '
'; } } ?>