$id_layout));
$result = process_sql_delete ('tlayout', array ('id' => $id_layout));
if ($result) {
echo '
'.__('Successfully deleted').'
';
clean_cache();
} else {
echo ''.__('Not deleted. Error deleting data').'
';
}
$id_layout = 0;
}
if ($copy_layout) {
// Number of inserts
$ninsert = (int) 0;
// Return from DB the source layout
$layout_src = get_db_all_rows_filter ("tlayout","id = " . $id_layout);
// Name of dst
$name_dst = get_parameter ("name_dst", $layout_src[0]['name'] . " copy");
// Create the new Console
$idGroup = $layout_src[0]['id_group'];
$background = $layout_src[0]['background'];
$height = $layout_src[0]['height'];
$width = $layout_src[0]['width'];
$visualConsoleName = $name_dst;
$values = array('name' => $visualConsoleName, 'id_group' => $idGroup, 'background' => $background, 'height' => $height, 'width' => $width);
$result = process_sql_insert('tlayout', $values);
$idNewVisualConsole = $result;
if($result) {
$ninsert = 1;
// Return from DB the items of the source layout
$data_layout_src = get_db_all_rows_filter ("tlayout_data", "id_layout = " . $id_layout);
if(!empty($data_layout_src)){
for ($a=0;$a < count($data_layout_src); $a++) {
// Changing the source id by the new visual console id
$data_layout_src[$a]['id_layout'] = $idNewVisualConsole;
// Unsetting the source's id
unset($data_layout_src[$a]['id']);
// Configure the cloned Console
$result = process_sql_insert('tlayout_data', $data_layout_src[$a]);
if($result)
$ninsert++;
}// for each item of console
$inserts = count($data_layout_src) + 1;
// If the number of inserts is correct, the copy is completed
if ($ninsert == $inserts) {
echo ''.__('Successfully copied').'
';
clean_cache();
} else {
echo ''.__('Not copied. Error copying data').'
';
}
}
else{
// If the array is empty the copy is completed
echo ''.__('Successfully copied').'
';
clean_cache();
}
}
else {
echo ''.__('Not copied. Error copying data').'
';
}
}
$table->width = '550px';
$table->data = array ();
$table->head = array ();
$table->head[0] = __('Map name');
$table->head[1] = __('Group');
$table->head[2] = __('Items');
$table->head[3] = __('Copy');
$table->head[4] = __('Delete');
$table->align = array ();
$table->align[1] = 'center';
$table->align[2] = 'center';
$table->align[3] = 'center';
$table->align[4] = 'center';
$maps = get_db_all_rows_in_table ('tlayout','name');
if (!$maps) {
echo ''.('No maps defined').'
';
} else {
foreach ($maps as $map) {
if (give_acl ($config['id_user'], $map['id_group'], "IW")){
$data = array ();
$data[0] = ''.$map['name'].'';
$data[1] = print_group_icon ($map['id_group'], true);
$data[2] = get_db_sql ("SELECT COUNT(*) FROM tlayout_data WHERE id_layout = ".$map['id']);
$data[3] = ''.print_image ("images/copy.png", true).'';
$data[4] = ''.print_image ("images/cross.png", true).'';
array_push ($table->data, $data);
}
}
print_table ($table);
}
if (!$maps) {
echo '