Subversion Repositories VORC

Rev

Rev 65 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 65 Rev 152
Line 55... Line 55...
55
}
55
}
Line 56... Line 56...
56
 
56
 
57
sub saveForm {
57
sub saveForm {
Line 58... Line 58...
58
  my $FTS = shift;
58
  my $FTS = shift;
Line 59... Line 59...
59
  
59
  
60
  my $dbh = WebDB::connect ();
-
 
61
  
-
 
62
  if (findConflict ($RCid, [$FTS->{date}, $FTS->{start_time}, $FTS->{end_time}], "personal")) {
-
 
63
  	my $samesame;
-
 
64
    if ($FTS->{$DBFields[0]} ne "NEW") {
-
 
65
    	($samesame) = $dbh->selectrow_array ("select count(*) from shift where id = ? and date = ? and start_time = ? and end_time = ?", undef, $FTS->{id}, $FTS->{date}, $FTS->{start_time}, $FTS->{end_time});    	
60
  my $dbh = getRCDBH ();
66
    }
61
  
67
    
62
  my $conflicts = findConflict ($RCid, [$FTS->{date}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{id}], "personal");
68
    if (!$samesame) {
-
 
69
    	error ("You already have a shift that conflicts with that time.");
63
  if ($conflicts) {
Line 70... Line 64...
70
    	return;
64
   	error ("You already have a shift that conflicts with that time [$conflicts].");
71
  	}
65
    return;
72
  }
66
  }
Line 94... Line 88...
94
	return $FTS->{id};
88
	return $FTS->{id};
95
}
89
}
Line 96... Line 90...
96
 
90
 
97
sub delete_item {
91
sub delete_item {
98
  my $X = shift;
92
  my $X = shift;
99
  my $dbh = WebDB::connect ();
93
  my $dbh = getRCDBH ();
100
  $dbh->do ("delete from $DBTable where $primary = ? and assignee_id = ?", undef, $X->{$primary}, $RCid);
94
  $dbh->do ("delete from $DBTable where $primary = ? and assignee_id = ?", undef, $X->{$primary}, $RCid);
101
  $dbh->disconnect ();
95
  $dbh->disconnect ();
102
  logit ($RCid, "$username deleted personal time ($X->{$primary})");
96
  logit ($RCid, "$username deleted personal time ($X->{$primary})");
103
  print "Shift Deleted: $X->{$primary}", $h->br;
97
  print "Shift Deleted: $X->{$primary}", $h->br;
-
 
98
  print &formField ("Cancel", "Back", "POSTSAVE");
104
  print &formField ("Cancel", "Back", "POSTSAVE");
99
  print &formField ("New", "Add Another...");
Line 105... Line 100...
105
}
100
}
106
 
101
 
Line 180... Line 175...
180
      return;
175
      return;
181
  }
176
  }
Line 182... Line 177...
182
  
177
  
183
  if ($R) {
178
  if ($R) {
184
    # we're dealing with an existing thing.  Get the current values out of the DB...
179
    # we're dealing with an existing thing.  Get the current values out of the DB...
Line 185... Line 180...
185
    my $dbh = WebDB::connect ();
180
    my $dbh = getRCDBH ();
186
    
181
    
187
	  @F{@DBFields} = $dbh->selectrow_array (
182
	  @F{@DBFields} = $dbh->selectrow_array (
188
                     "SELECT ". join (", ", @DBFields) ." FROM $DBTable WHERE $primary = ? and dept = 'PER' and assignee_id = ?",
183
                     "SELECT ". join (", ", @DBFields) ." FROM $DBTable WHERE $primary = ? and dept = 'PER' and assignee_id = ?",
Line 218... Line 213...
218
      $actionbutton = formField ("choice", "Save");
213
      $actionbutton = formField ("choice", "Save");
219
      $actionbutton .= formField ("Cancel");
214
      $actionbutton .= formField ("Cancel");
220
    } else {
215
    } else {
221
      # We're just looking at it...
216
      # We're just looking at it...
222
      print $h->p ("Viewing Personal Time: $R->{$primary}...");
217
      print $h->p ("Viewing Personal Time: $R->{$primary}...");
-
 
218
      $F{"start_time"} = convertTime $F{"start_time"};
-
 
219
      $F{"end_time"} = convertTime $F{"end_time"};
223
      $F{$DBFields[0]} .= $h->input ({ type=>"hidden", name=>$DBFields[0], value=> $F{$DBFields[0]} });
220
      $F{$DBFields[0]} .= $h->input ({ type=>"hidden", name=>$DBFields[0], value=> $F{$DBFields[0]} });
224
      $actionbutton = formField ("choice", "Update");
221
      $actionbutton = formField ("choice", "Update");
225
      if ($view eq "POSTSAVE") {
222
      if ($view eq "POSTSAVE") {
226
        $actionbutton .= formField ("Cancel", "Back", "POSTSAVE");
223
        $actionbutton .= formField ("Cancel", "Back", "POSTSAVE");
227
      } else {
224
      } else {
228
        $actionbutton .= formField ("Cancel", "Back");
225
        $actionbutton .= formField ("Cancel", "Back");
229
      }
226
      }
-
 
227
      $actionbutton .= formField ("New", "Add Another...");
230
    }
228
    }
231
  } else {
229
  } else {
232
    print $h->p ("Adding new Personal Time...");
230
    print $h->p ("Adding new Personal Time...");
Line 233... Line 231...
233
 
231
 
Line 239... Line 237...
239
    $actionbutton = formField ("choice", "Save");
237
    $actionbutton = formField ("choice", "Save");
240
    $actionbutton .= formField ("Cancel");
238
    $actionbutton .= formField ("Cancel");
241
  }
239
  }
Line 242... Line 240...
242
  
240
  
243
  
241
  
244
	print $h->open ("form", { action => url (), method=>"POST" });
242
	print $h->open ("form", { action => url (), method=>"POST", name => "personaltime"});
245
	print $h->div ({ class=>"sp0" },
243
	print $h->div ({ class=>"sp0" },
246
	  $h->div ({ class=>"rTable" }, [ map ({
244
	  $h->div ({ class=>"rTable" }, [ map ({
247
      $h->div ({ class=>"rTableRow" }, [
245
      $h->div ({ class=>"rTableRow" }, [
Line 308... Line 306...
308
		  if ($context eq "POSTSAVE") {
306
		  if ($context eq "POSTSAVE") {
309
		    return $h->input ({ type=>"button", value => $value ne '' ? $value : "Cancel" , onClick=>"window.location.href = '$homeURL'; return false;" });
307
		    return $h->input ({ type=>"button", value => $value ne '' ? $value : "Cancel" , onClick=>"window.location.href = '$homeURL'; return false;" });
310
		  } else {
308
		  } else {
311
		    return $h->input ({ type=>"button", value => $value ne '' ? $value : "Cancel" , onClick=>"history.back(); return false;" })
309
		    return $h->input ({ type=>"button", value => $value ne '' ? $value : "Cancel" , onClick=>"history.back(); return false;" })
312
		  }
310
		  }
-
 
311
		} elsif ($name eq "New") {
-
 
312
		  return $h->input ({ type=>"button", value => $value, name=>$name, onClick => "window.location.href = 'personal_time.pl';"})
313
		} else {
313
		} else {
314
			return $h->input ({ type=>"submit", value => $value, name=>$name })
314
			return $h->input ({ type=>"submit", value => $value, name=>$name })
315
		}
315
		}
Line 316... Line 316...
316
 
316