Subversion Repositories VORC

Rev

Rev 152 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 152 Rev 254
Line 23... Line 23...
23
my $DepartmentNames = getDepartments ();
23
my $DepartmentNames = getDepartments ();
24
my $username = $user->{derby_name};
24
my $username = $user->{derby_name};
25
my $RCid = $user->{RCid};
25
my $RCid = $user->{RCid};
26
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
26
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
27
my $YEAR = 1900 + (localtime)[5];
27
my $YEAR = 1900 + (localtime)[5];
-
 
28
my $dbh = getRCDBH ();
Line 28... Line 29...
28
 
29
 
29
 
30
 
30
my $pageTitle = "Block Personal Time";
31
my $pageTitle = "Block Personal Time";
Line 55... Line 56...
55
}
56
}
Line 56... Line 57...
56
 
57
 
57
sub saveForm {
58
sub saveForm {
Line -... Line 59...
-
 
59
  my $FTS = shift;
58
  my $FTS = shift;
60
  
Line 59... Line 61...
59
  
61
  $FTS->{start_time} = makeTime24hr ($FTS->{start_time});
60
  my $dbh = getRCDBH ();
62
  $FTS->{end_time} = makeTime24hr ($FTS->{end_time});
61
  
63
  
62
  my $conflicts = findConflict ($RCid, [$FTS->{date}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{id}], "personal");
64
  my $conflicts = findConflict ($RCid, [$FTS->{date}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{id}], "personal");
Line 82... Line 84...
82
  	  undef,
84
  	  undef,
83
  	  $FTS->{id}, "PER", $FTS->{role}, "personal", $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{note}, $RCid);
85
  	  $FTS->{id}, "PER", $FTS->{role}, "personal", $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{note}, $RCid);
84
    logit ($RCid, "$username updated personal time ($FTS->{id}, $FTS->{date}, $FTS->{start_time}, $FTS->{end_time})");
86
    logit ($RCid, "$username updated personal time ($FTS->{id}, $FTS->{date}, $FTS->{start_time}, $FTS->{end_time})");
85
	}
87
	}
Line 86... Line -...
86
	
-
 
87
	$dbh->disconnect ();	 # stored into database successfully.
88
	
88
	return $FTS->{id};
89
	return $FTS->{id};
Line -... Line 90...
-
 
90
}
-
 
91
 
-
 
92
sub makeTime24hr {
-
 
93
  my $time = shift // return;
-
 
94
  
-
 
95
  return $time unless $time =~ /m$/;
-
 
96
  my ($time, $half) = split / /, $time;
-
 
97
  my ($hour, $minute) = split /:/, $time;
-
 
98
  $hour += 12 unless $half eq "am";
-
 
99
  return $hour.":".$minute.":00";
89
}
100
}
90
 
101
 
91
sub delete_item {
-
 
92
  my $X = shift;
102
sub delete_item {
93
  my $dbh = getRCDBH ();
-
 
94
  $dbh->do ("delete from $DBTable where $primary = ? and assignee_id = ?", undef, $X->{$primary}, $RCid);
103
  my $X = shift;
95
  $dbh->disconnect ();
104
  $dbh->do ("delete from $DBTable where $primary = ? and assignee_id = ?", undef, $X->{$primary}, $RCid);
96
  logit ($RCid, "$username deleted personal time ($X->{$primary})");
105
  logit ($RCid, "$username deleted personal time ($X->{$primary})");
97
  print "Shift Deleted: $X->{$primary}", $h->br;
106
  print "Shift Deleted: $X->{$primary}", $h->br;
98
  print &formField ("Cancel", "Back", "POSTSAVE");
107
  print &formField ("Cancel", "Back", "POSTSAVE");
Line 163... Line 172...
163
	display_form (); # blank form
172
	display_form (); # blank form
164
}
173
}
Line 165... Line 174...
165
 
174
 
Line 166... Line 175...
166
print $h->close ("html");
175
print $h->close ("html");
167
 
176
 
168
sub display_form  {
177
sub display_form {
169
  my $R = shift;
178
  my $R = shift;
Line 170... Line 179...
170
  my $view = shift // "";
179
  my $view = shift // "";
Line 175... Line 184...
175
      return;
184
      return;
176
  }
185
  }
Line 177... Line 186...
177
  
186
  
178
  if ($R) {
187
  if ($R) {
179
    # we're dealing with an existing thing.  Get the current values out of the DB...
-
 
180
    my $dbh = getRCDBH ();
-
 
181
    
188
    # we're dealing with an existing thing.  Get the current values out of the DB...
182
	  @F{@DBFields} = $dbh->selectrow_array (
189
	  @F{@DBFields} = $dbh->selectrow_array (
183
                     "SELECT ". join (", ", @DBFields) ." FROM $DBTable WHERE $primary = ? and dept = 'PER' and assignee_id = ?",
190
                     "SELECT ". join (", ", @DBFields) ." FROM $DBTable WHERE $primary = ? and dept = 'PER' and assignee_id = ?",
184
                      undef, $R->{$primary}, $RCid);
-
 
185
	  $dbh->disconnect ();
-
 
186
	  
191
                      undef, $R->{$primary}, $RCid);
187
	  # did we find a record?
192
	  # did we find a record?
Line 188... Line 193...
188
	  error ("You don't seem to have Personal Time with that database ID ($R->{$primary}).") unless defined $F{$DBFields[0]};
193
	  error ("You don't seem to have Personal Time with that database ID ($R->{$primary}).") unless defined $F{$DBFields[0]};
189
    
194