# -*- Perl -*-
#
# This is part of X-RUST 1.0 Beta 4.
#
# Copyright (C) 1996 Craig Ruefenacht <ruefenac@cs.utah.edu> and the
#                    University of Utah, Department of Computer Scinece
#
#                    Shawn T. Amundson <amundson@cs.umn.edu> and the
#                    University of Minnesota Computer Science Department
#
# Abstract: This file contains definitions and subroutines which deal with
#           creating a request in X-Rust.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
# 
# 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.
# 
# You should have received a copy of the GNU General Public License
# along with the source distribution of Inquire, in the license
# directory. If you don't have a copy of it, write to: 
#
# Free Software Foundation, Inc.
# 675 Mass Ave
# Cambridge, MA 02139, USA.
#

#
# $Id: xrust_create.pl,v 1.1.1.1 2000/05/03 19:54:39 wright Exp $
#

#use strict;

use vars qw(%FONTS);

sub create_func {

    #
    # Abstract: Create a request
    
    my ($date) = ctime($^T);
    chomp($date);

    $create_request_q_index = -1;
    $new_request_user = "";
    $new_request_owner = "";
    $new_request_sbuject = "";
    $new_request_priority = "normal";

    my $CRMW = MainWindow->new;
        $CRMW->title('Create Request');
        $create_request = $CRMW->Frame;
        $create_request->pack(-side => 'top', fill => 'x');     
        $create_request_t1 = $create_request->Label(-text => "Create Request",
                                                    -font => $FONTS{'BUTTON_FONT'});
        $create_request_t1->pack(-side => 'top');

        $create_request_right = $CRMW->Frame;
        $create_request_right->pack(-side => 'right',fill => 'x'); 

        @pl = (-side => 'top', -padx => 10, -pady => 5, -fill => 'x');

        $create_request_right_t1 = $create_request_right->Label(-text => "Queue",
								-font => $FONTS{'BUTTON_FONT'},	          
							       );
        $create_request_right_t1->pack(@pl);

        $count = 0;
        $default = 0;
        foreach $each (split(':',$globals->{"alias_name"})) {
            if ($caller_queues[$count]) {
                if (!$default) {
                    $create_request_q_index = $count;
                    $default = 1;
                }

                $radial = $create_request_right->Radiobutton(
                                                           -text     => "$each",
							   -font     => $FONTS{'BUTTON_FONT'},
                                                           -variable => \$create_request_q_index,
                                                           -relief   => 'flat',
                                                           -value    => $count
							    );
                $radial->pack(-side => 'top', -pady => '2', -anchor => 'w');
            }
            $count++;
        }

        $new_request_user = $caller;
        $create_request_right_t2 = $create_request_right->Label(-text => "User",
								-font => $FONTS{'BUTTON_FONT'},
							       );
        $create_request_right_t2->pack(-side => 'top');

        $create_request_right_e2 = $create_request_right->Entry(-relief => 'sunken', -width => 12, 
                                          -textvariable => \$new_request_user
							       );
        $create_request_right_e2->pack(@pl);

        $create_request_right_t3 = $create_request_right->Label(-text => "Owner",
								-font => $FONTS{'BUTTON_FONT'},
							       );
        $create_request_right_t3->pack(-side => 'top');

        $create_request_right_e3 = $create_request_right->Entry(-relief => 'sunken', -width => 12, 
								-textvariable => \$new_request_owner
								);

        $create_request_right_e3->pack(@pl);

        $create_request_right_t4 = $create_request_right->Label(-text => "Subject",
								-font => $FONTS{'BUTTON_FONT'},
							       );
        $create_request_right_t4->pack(-side => 'top');

        $create_request_right_e4 = $create_request_right->Entry(-relief => 'sunken', -width => 12, 
                                          -textvariable => \$new_request_subject,
							       );
        $create_request_right_e4->pack(@pl);

        $create_request_right_t5 = $create_request_right->Label(-relief => 'raised', -text => "Priority",
								-font => $FONTS{'BUTTON_FONT'});
        $create_request_right_t5->pack(-side => 'top');
            
        foreach $each ("high","normal","low") {
            $radial = $create_request_right->Radiobutton(
                                                         -text     => "$each",
							 -font     => $$FONTS{'BUTTON_FONT'},
                                                         -variable => \$new_request_priority,
                                                         -relief   => 'flat',
                                                         -value    => $each);
            $radial->pack(-side => 'top', -pady => '2', -anchor => 'w');
        }

        $create_request_vert_scroll = $CRMW->Scrollbar(-orient => 'vertical');
        $create_request_vert_scroll->pack(-side => 'right', -fill => 'y');

        $create_request_text = $CRMW->Text(
                                           -yscrollcommand =>  [$create_request_vert_scroll => 'set'],
                                           -width          => 70,
                                           -height         => 20, 
                                           -wrap           => none,
                                           -setgrid        => 1);

        $create_request_vert_scroll->configure(-command => [$create_request_text => 'yview']);
        $create_request_text->pack(-expand => 1, -fill => 'both');

        $create_request_buttons = $CRMW->Frame;
        $create_request_buttons->pack(-side => 'bottom', fill => 'x');

        $create_request_buttons_1 = $create_request_buttons->Button
	  (
	   -text => "Execute",
	   -font => $FONTS{'BUTTON_FONT'},
	   -width => 10,
	   -command => sub { 
	       
	       print STDERR "Create in X-Rust NOT Fully IMPLEMENTED YET!!!\n";
	       
	       $CRMW->destroy;
	      }
	  );
    $create_request_buttons_1->pack(-side => 'left', -expand => 'yes', -pady => 2);
    
    $create_request_buttons_2 = $create_request_buttons->Button(
								-text => "Abort",
								-font => $FONTS{'BUTTON_FONT'},
								-width => 10,
								-command => sub { $CRMW->destroy;
										 }
							       );
    $create_request_buttons_2->pack(-side => 'right', -expand => 'yes', -pady => 2);
}


1;




