%# BEGIN LICENSE BLOCK
%# 
%#  Copyright (c) 2002-2003 Jesse Vincent <jesse@bestpractical.com>
%#  
%#  This program is free software; you can redistribute it and/or modify
%#  it under the terms of version 2 of the GNU General Public License 
%#  as published by the Free Software Foundation.
%# 
%#  A copy of that license should have arrived with this
%#  software, but in any event can be snarfed from www.gnu.org.
%# 
%#  This program is distributed in the hope that it will be useful,
%#  but WITHOUT ANY WARRANTY; without even the implied warranty of
%#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%#  GNU General Public License for more details.
%# 
%# END LICENSE BLOCK

<& /RTFM/Admin/Elements/Tabs, 
    subtabs => $tabs, 
    current_tab => 'RTFM/Admin/CustomFields/index.html', 
    current_subtab => 
            "RTFM/Admin/CustomFields/Basics.html?id=" . $id,
    Title => $Title &>
<%INIT>
my $tabs;

if ($id) {
    my $cf = RT::FM::CustomField->new( $session{'CurrentUser'} );
    $cf->Load($id);
    $tabs = {
        C => {
            title => $cf->Name,
            path  => "RTFM/Admin/CustomFields/Basics.html?id=" . $id,

            subtabs => {

                C => { title => loc('Basics'),
                       path  => "RTFM/Admin/CustomFields/Basics.html?id=" . $id,
                },

                F => { title => loc('Group Rights'),
                       path  => "RTFM/Admin/CustomFields/GroupRights.html?id="
                         . $id, },
                G => {
                    title => loc('User Rights'),
                    path => "RTFM/Admin/CustomFields/UserRights.html?id=" . $id,
                },

            } }

    };
}

if ($session{'CurrentUser'}->HasRight( Object => $RT::FM::System, Right => 'AdminCustomField')) {
  $tabs->{"A"} = { title => loc('Select custom field'),
                        path => "RTFM/Admin/CustomFields/index.html",
                           };
  $tabs->{"B"} = { title => loc('New custom field'),
                        path => "RTFM/Admin/CustomFields/Basics.html?Create=1",
                        separator => 1,
                           };
}
  foreach my $tab (sort keys %{$tabs}) {
    if ($tabs->{$tab}->{'path'} eq $current_tab) {
      $tabs->{$tab}->{"current_subtab"} = $current_tab;
    }
  foreach my $subtab (sort keys %{$tabs->{'subtabs'}}) {
    if ($tabs->{$tab}->{subtabs}->{$subtab}->{'path'} eq $current_tab) {
      $tabs->{$tab}->{subtabs}->{$subtab}->{"current_subtab"} = $current_subtab;
    }
  }

  }


</%INIT>
<%ARGS>
$id => undef
$current_subtab => undef
$current_tab => undef
$Title => undef
</%ARGS>
