Commit fcff7f0c authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Add cancellation support to the library.

parent a37e0fb9
...@@ -94,6 +94,7 @@ sub CreateCommon($$$$$$$$) ...@@ -94,6 +94,7 @@ sub CreateCommon($$$$$$$$)
$self->{'APPROVED'} = undef; $self->{'APPROVED'} = undef;
$self->{'APPROVER'} = undef; $self->{'APPROVER'} = undef;
$self->{'UUID'} = undef; $self->{'UUID'} = undef;
$self->{'CANCEL'} = undef;
bless($self, $class); bless($self, $class);
...@@ -158,7 +159,8 @@ sub Lookup($$;$$$$) ...@@ -158,7 +159,8 @@ sub Lookup($$;$$$$)
$query_result = DBQueryWarn( "SELECT *, UNIX_TIMESTAMP(start) AS s, " . $query_result = DBQueryWarn( "SELECT *, UNIX_TIMESTAMP(start) AS s, " .
"UNIX_TIMESTAMP(end) AS e, " . "UNIX_TIMESTAMP(end) AS e, " .
"UNIX_TIMESTAMP(created) AS c, " . "UNIX_TIMESTAMP(created) AS c, " .
"UNIX_TIMESTAMP(approved) AS a " . "UNIX_TIMESTAMP(approved) AS a, " .
"UNIX_TIMESTAMP(cancel) AS d " .
"FROM future_reservations " . "FROM future_reservations " .
"WHERE pid_idx='$pid_idx' AND " . "WHERE pid_idx='$pid_idx' AND " .
"nodes='$nodes' AND " . "nodes='$nodes' AND " .
...@@ -184,7 +186,8 @@ sub Lookup($$;$$$$) ...@@ -184,7 +186,8 @@ sub Lookup($$;$$$$)
$query_result = DBQueryWarn( "SELECT *, UNIX_TIMESTAMP(start) AS s, " . $query_result = DBQueryWarn( "SELECT *, UNIX_TIMESTAMP(start) AS s, " .
"UNIX_TIMESTAMP(end) AS e, " . "UNIX_TIMESTAMP(end) AS e, " .
"UNIX_TIMESTAMP(created) AS c, " . "UNIX_TIMESTAMP(created) AS c, " .
"UNIX_TIMESTAMP(approved) AS a " . "UNIX_TIMESTAMP(approved) AS a, " .
"UNIX_TIMESTAMP(cancel) AS d " .
"FROM future_reservations " . "FROM future_reservations " .
"WHERE $clause" ); "WHERE $clause" );
...@@ -202,6 +205,7 @@ sub Lookup($$;$$$$) ...@@ -202,6 +205,7 @@ sub Lookup($$;$$$$)
$self->{'START'} = $record->{'s'}; $self->{'START'} = $record->{'s'};
$self->{'END'} = $record->{'e'}; $self->{'END'} = $record->{'e'};
$self->{'CREATED'} = $record->{'c'}; $self->{'CREATED'} = $record->{'c'};
$self->{'CANCEL'} = $record->{'d'};
$self->{'TYPE'} = $record->{'type'}; $self->{'TYPE'} = $record->{'type'};
$self->{'NODES'} = $record->{'nodes'}; $self->{'NODES'} = $record->{'nodes'};
$self->{'UID'} = $record->{'uid'}; $self->{'UID'} = $record->{'uid'};
...@@ -223,6 +227,7 @@ sub pid_idx($) { return $_[0]->{"PID_IDX"}; } ...@@ -223,6 +227,7 @@ sub pid_idx($) { return $_[0]->{"PID_IDX"}; }
sub eid($) { return $_[0]->{"EID"}; } sub eid($) { return $_[0]->{"EID"}; }
sub start($) { return $_[0]->{"START"}; } sub start($) { return $_[0]->{"START"}; }
sub end($) { return $_[0]->{"END"}; } sub end($) { return $_[0]->{"END"}; }
sub cancel($) { return $_[0]->{"CANCEL"}; }
sub created($) { return $_[0]->{"CREATED"}; } sub created($) { return $_[0]->{"CREATED"}; }
sub type($) { return $_[0]->{"TYPE"}; } sub type($) { return $_[0]->{"TYPE"}; }
sub nodes($) { return $_[0]->{"NODES"}; } sub nodes($) { return $_[0]->{"NODES"}; }
...@@ -288,6 +293,13 @@ sub SetAdminNotes($$) ...@@ -288,6 +293,13 @@ sub SetAdminNotes($$)
$self->{'ADMIN_NOTES'} = $notes; $self->{'ADMIN_NOTES'} = $notes;
} }
sub SetCancel($$)
{
my ($self, $cancel) = @_;
$self->{'CANCEL'} = $cancel;
}
# Mark the reservation as approved. This DOES NOT update the database # Mark the reservation as approved. This DOES NOT update the database
# state: to do so requires an admission control check! See BeginTransaction(), # state: to do so requires an admission control check! See BeginTransaction(),
# IsFeasible(), Book(), etc. # IsFeasible(), Book(), etc.
...@@ -391,6 +403,7 @@ sub Book($;$) ...@@ -391,6 +403,7 @@ sub Book($;$)
my $admin_notes = DBQuoteSpecial( $self->admin_notes() ); my $admin_notes = DBQuoteSpecial( $self->admin_notes() );
my $approved = $self->approved(); my $approved = $self->approved();
my $approver = $self->approver(); my $approver = $self->approver();
my $cancel = $self->cancel();
my $base_query = "SET pid='$pid', " . my $base_query = "SET pid='$pid', " .
"pid_idx='$pid_idx', " . "pid_idx='$pid_idx', " .
...@@ -406,6 +419,8 @@ sub Book($;$) ...@@ -406,6 +419,8 @@ sub Book($;$)
", admin_notes=$admin_notes" : "" ) . ", admin_notes=$admin_notes" : "" ) .
( defined( $approved ) ? ( defined( $approved ) ?
", approved=FROM_UNIXTIME($approved)" : "" ) . ", approved=FROM_UNIXTIME($approved)" : "" ) .
( defined( $cancel ) ?
", cancel=FROM_UNIXTIME($cancel)" : ", cancel=null" ) .
( defined( $approver ) ? ", approver='$approver'" : "" ); ( defined( $approver ) ? ", approver='$approver'" : "" );
my $query_result = my $query_result =
......
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