Commit 62d86acb authored by Gary Wong's avatar Gary Wong

Add -N and -A options to reserve, for adding notes and admin notes.

parent 4e09c51e
......@@ -298,9 +298,9 @@ sub Book($)
"end=FROM_UNIXTIME($end), " .
"uid='$uid', " .
"uid_idx='$uid_idx' " .
( defined( $notes ) ? ", notes='$notes'" : "" ) .
( defined( $notes ) ? ", notes=$notes" : "" ) .
( defined( $admin_notes ) ?
", admin_notes='$admin_notes'" : "" ) )
", admin_notes=$admin_notes" : "" ) )
or return -1;
$self->{'IDX'} = $query_result->insertid();
......
......@@ -43,8 +43,8 @@ use Reservation;
sub usage()
{
print STDERR "Usage: reserve [-C] [-f] [-n] -t type [-s start] [-e end] " .
"pid count\n";
print STDERR "Usage: reserve [-C] [-f] [-n] -t type [-s start] [-e end]\n" .
" [-N file] [-A file] pid count\n";
print STDERR " reserve -c idx\n";
print STDERR " reserve -i pid\n";
print STDERR " reserve -l\n";
......@@ -71,21 +71,32 @@ sub fatal($)
" $mesg\n");
}
my $optlist = "hdc:Cfnt:ile:s:";
my $debug = 0;
my $info = 0;
my $list = 0;
my $clear = 0;
my $clear_idx = undef;
my $force = 0;
my $impotent = 0;
my $starttime = time; # default to starting immediately
my $endtime = time + 24 * 60 * 60; # default to ending tomorrow
my $optlist = "c:de:fhilns:t:A:CN:";
my $debug = 0;
my $info = 0;
my $list = 0;
my $clear = 0;
my $clear_idx = undef;
my $force = 0;
my $impotent = 0;
my $starttime = time; # default to starting immediately
my $endtime = time + 24 * 60 * 60; # default to ending tomorrow
my $notes = undef;
my $adminnotes = undef;
my $type;
my $pid;
my $count;
my $project;
sub readfile($) {
local $/ = undef;
my ($filename) = @_;
open( FILE, $filename ) or die "$filename: $!";
my $contents = <FILE>;
close( FILE );
return $contents;
}
#
# Turn off line buffering on output
#
......@@ -151,6 +162,12 @@ if (defined($options{"s"})) {
fatal("Could not parse -s option.");
}
}
if (defined($options{"N"})) {
$notes = readfile( $options{"N"} );
}
if (defined($options{"A"})) {
$adminnotes = readfile( $options{"A"} );
}
if ($info) {
usage() if( @ARGV != 1 );
......@@ -316,6 +333,8 @@ my $uid_idx = $this_user->uid_idx();
my $res = Reservation->Create( $pid, $uid, $starttime, $endtime, $type,
$count );
$res->SetNotes( $notes ) if( defined( $notes ) );
$res->SetAdminNotes( $adminnotes ) if( defined( $adminnotes ) );
print "$res\n" if( $debug );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment