<%PERL>
unless ($session{in_part} eq $InPart) {
    $session{in_part} = $InPart;
    $session{in_body} = $InBody;
    $m->print("<script><!--\nparent.toolbar.location.reload();\n--></script>");
}
</%PERL>

<& /RG/Elements/PageHeader &>

<table width=100% bgcolor="#7CBEBE" height=30 border=0 cellspacing=0 cellpadding=2><tr valign=top><td class="poptable" valign="top">
<table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td>
<form name="thisform" action="/RG/Report/View.html" method='post' target="view" style="margin: 0">
<input type="hidden" name="Op" value="Change">
<input type="hidden" name="Type" value="FIELD">

&nbsp;

<%PERL>
$m->comp(
    "/Field/$Type",
    %ARGS,
    CF		=> $CF,
    obj		=> $obj,
    dbh		=> $dbh,
    table	=> $table,
    field	=> $field,
    curfield	=> $curfield,
    curtable	=> $curtable,
    tables	=> \@tables,
);
</%PERL>

% if ($Type ne 'null') {

<a class="submit" href='#' onclick='document.thisform.submit();'><img src="img/ok.png" width="19" height="19" align="absmiddle" border="0" alt="<% loc('Change') %>" title="<% loc('Change') %>"

% }

</td><td align="right" width="15%">
<img src="img/3Dtoolbar.png" border="0" align="absmiddle">
<input type="hidden" name="FID" value="<% $FID %>">

<& /RG/Elements/Submit,
    Op		=> 'Leftward',	# loc
    Image	=> 'Left',
    Enabled	=> (
	$FID > 0
    ),
&>
<& /RG/Elements/Submit,
    Op		=> 'Rightward',	# loc
    Image	=> 'Right',
    Enabled	=> (
	$FID < ($Total - 1)
    ),
&>
<& /RG/Elements/Submit,
    Op		=> 'DeleteField',	# loc
    Image	=> 'Field_Delete',
    Enabled	=> 1
&>

</td></tr></table>
</form>

<%INIT>
require RG::Table;
require RG::Parser;
$session{reportPartId} = $Id;

my $obj = $session{ids}[$Id];
my $dbh ||= RG::Parser->new($session{file}, $Conf)->{DBH};
my $table = RG::Table->new(${$obj->this->{table}}, $dbh, $session{vars});
my $field = $table->{FIELDS}[$FID];
my $CF = $Conf->{DB}{$session{db}};

my @tables = @{$table->{TABLE}};
my $curtable = $field->{TABLE};
my $curname  = $field->{NAME};

# XXX: reach inside fnames for non-DATA fields
my $curfield = $field->{FNAME};

$curtable ||= $tables[0] if $#tables == 0;

if ($curtable and $curfield) {
    # resolve conflict tables/fields combinations during selects
    (delete( @{$field}{qw/NAME/} ), $curfield = '')
	unless grep $_->{$curtable}, @{ $table->{FIELDNAME}{$curfield} }
}

</%INIT>
<%ARGS>
$Type	=> 'null'
$FID	=> ''
$Id	=> ''
$InBody	=> undef
$InPart	=> undef
$Descr	=> undef
$Total  => 0
</%ARGS>
