| Line 31... |
Line 31... |
| 31 |
type => [qw(Type 20 select required )],
|
31 |
type => [qw(Type 20 select required )],
|
| 32 |
date => [qw(Date 25 date required )],
|
32 |
date => [qw(Date 25 date required )],
|
| 33 |
location => [qw(Location 30 text required )],
|
33 |
location => [qw(Location 30 text required )],
|
| 34 |
start_time => [qw(Start 35 time required )],
|
34 |
start_time => [qw(Start 35 time required )],
|
| 35 |
end_time => [qw(End 40 time required )],
|
35 |
end_time => [qw(End 40 time required )],
|
| - |
|
36 |
doubletime => [qw(DoubleHours 42 switch )],
|
| 36 |
assignee_id => [qw(Assignee 50 auto )],
|
37 |
assignee_id => [qw(Assignee 50 auto )],
|
| 37 |
mod_time => [qw(ModTime 45 number )],
|
38 |
mod_time => [qw(ModTime 45 number )],
|
| 38 |
note => [qw(Notes 55 textarea )],
|
39 |
note => [qw(Notes 55 textarea )],
|
| 39 |
);
|
40 |
);
|
| Line 40... |
Line 41... |
| 40 |
|
41 |
|
| 41 |
|
42 |
|
| 42 |
my %fieldDisplayName = map { $_ => $FIELDS{$_}->[0] } keys %FIELDS;
|
43 |
my %fieldDisplayName = map { $_ => $FIELDS{$_}->[0] } keys %FIELDS;
|
| 43 |
my %fieldType = map { $_ => $FIELDS{$_}->[2] } keys %FIELDS;
|
44 |
my %fieldType = map { $_ => $FIELDS{$_}->[2] } keys %FIELDS;
|
| 44 |
my @requiredFields = sort fieldOrder grep { defined $FIELDS{$_}->[3] } keys %FIELDS;
|
45 |
my @requiredFields = sort fieldOrder grep { defined $FIELDS{$_}->[3] } keys %FIELDS;
|
| 45 |
my @DBFields = sort fieldOrder grep { $fieldType{$_} =~ /^(text|select|number|date|time|auto)/ } keys %FIELDS;
|
46 |
my @DBFields = sort fieldOrder grep { $fieldType{$_} =~ /^(text|select|number|switch|date|time|auto)/ } keys %FIELDS;
|
| Line 46... |
Line 47... |
| 46 |
my @ROFields = sort fieldOrder grep { $fieldType{$_} =~ /^(readonly)/ } keys %FIELDS;
|
47 |
my @ROFields = sort fieldOrder grep { $fieldType{$_} =~ /^(readonly)/ } keys %FIELDS;
|
| 47 |
my $primary = $DBFields[0];
|
48 |
my $primary = $DBFields[0];
|
| Line 53... |
Line 54... |
| 53 |
sub saveForm {
|
54 |
sub saveForm {
|
| 54 |
my $FTS = shift;
|
55 |
my $FTS = shift;
|
| Line 55... |
Line 56... |
| 55 |
|
56 |
|
| 56 |
my $dbh = WebDB::connect ();
|
57 |
my $dbh = WebDB::connect ();
|
| - |
|
58 |
if ($FTS->{$DBFields[0]} eq "NEW") {
|
| 57 |
if ($FTS->{$DBFields[0]} eq "NEW") {
|
59 |
if ($FTS->{mod_time}) {
|
| - |
|
60 |
$dbh->do (
|
| - |
|
61 |
"INSERT INTO $DBTable
|
| - |
|
62 |
(dept,role,type,date,location,start_time,end_time,mod_time,doubletime,note)
|
| - |
|
63 |
VALUES(?,?,?,?,?,?,?,?,?,?)",
|
| - |
|
64 |
undef,
|
| - |
|
65 |
$FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{mod_time}, $FTS->{doubletime}, $FTS->{note}
|
| - |
|
66 |
);
|
| - |
|
67 |
} else {
|
| 58 |
$dbh->do (
|
68 |
$dbh->do (
|
| 59 |
"INSERT INTO $DBTable
|
69 |
"INSERT INTO $DBTable
|
| 60 |
(dept,role,type,date,location,start_time,end_time,note)
|
70 |
(dept,role,type,date,location,start_time,end_time,doubletime,note)
|
| 61 |
VALUES(?,?,?,?,?,?,?,?)",
|
71 |
VALUES(?,?,?,?,?,?,?,?,?)",
|
| 62 |
undef,
|
72 |
undef,
|
| 63 |
$FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{note}
|
73 |
$FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{doubletime}, $FTS->{note}
|
| - |
|
74 |
);
|
| 64 |
);
|
75 |
}
|
| 65 |
($FTS->{id}) = $dbh-> selectrow_array ("select max(id) from $DBTable where dept = ? and role = ? and type = ? and date = ? and location = ? and start_time = ? and end_time = ? and note = ?", undef, $FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{note});
|
76 |
($FTS->{id}) = $dbh-> selectrow_array ("select max(id) from $DBTable where dept = ? and role = ? and type = ? and date = ? and location = ? and start_time = ? and end_time = ? and note = ?", undef, $FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{note});
|
| 66 |
logit ($RCid, "$username created new shift ($FTS->{id}, $FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time})");
|
77 |
logit ($RCid, "$username created new shift ($FTS->{id}, $FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{mod_time}, $FTS->{doubletime})");
|
| 67 |
} else {
|
78 |
} else {
|
| 68 |
if ($FTS->{mod_time}) {
|
79 |
if ($FTS->{mod_time}) {
|
| 69 |
$dbh->do (
|
80 |
$dbh->do (
|
| 70 |
"UPDATE $DBTable
|
81 |
"UPDATE $DBTable
|
| 71 |
SET dept=?, role=?, type=?, date=?, location=?, start_time=?, end_time=?, mod_time=?, note=?
|
82 |
SET dept=?, role=?, type=?, date=?, location=?, start_time=?, end_time=?, mod_time=?, doubletime=?, note=?
|
| 72 |
WHERE id = ?",
|
83 |
WHERE id = ?",
|
| 73 |
undef,
|
84 |
undef,
|
| 74 |
$FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{mod_time}, $FTS->{note}, $FTS->{id}
|
85 |
$FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{mod_time}, $FTS->{doubletime}, $FTS->{note}, $FTS->{id}
|
| 75 |
);
|
86 |
);
|
| 76 |
} else {
|
87 |
} else {
|
| 77 |
$dbh->do (
|
88 |
$dbh->do (
|
| 78 |
"UPDATE $DBTable
|
89 |
"UPDATE $DBTable
|
| 79 |
SET dept=?, role=?, type=?, date=?, location=?, start_time=?, end_time=?, mod_time=null, note=?
|
90 |
SET dept=?, role=?, type=?, date=?, location=?, start_time=?, end_time=?, mod_time=null, doubletime=?, note=?
|
| 80 |
WHERE id = ?",
|
91 |
WHERE id = ?",
|
| 81 |
undef,
|
92 |
undef,
|
| 82 |
$FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{note}, $FTS->{id}
|
93 |
$FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{doubletime}, $FTS->{note}, $FTS->{id}
|
| 83 |
);
|
94 |
);
|
| 84 |
}
|
95 |
}
|
| 85 |
logit ($RCid, "$username updated shift ($FTS->{id}, $FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time})");
|
96 |
logit ($RCid, "$username updated shift ($FTS->{id}, $FTS->{dept}, $FTS->{role}, $FTS->{type}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time})");
|
| Line 216... |
Line 227... |
| 216 |
$temp .= " ".$h->a ({ onClick=>"if (confirm('Really? You want to drop this person from the shift?')==true) { window.open('make_shift_change.pl?change=del&RCid=$F{assignee_id}&id=$F{id}','Confirm Shift Change','resizable,height=260,width=370'); return false; }" }, "[DROP]");
|
227 |
$temp .= " ".$h->a ({ onClick=>"if (confirm('Really? You want to drop this person from the shift?')==true) { window.open('make_shift_change.pl?change=del&RCid=$F{assignee_id}&id=$F{id}','Confirm Shift Change','resizable,height=260,width=370'); return false; }" }, "[DROP]");
|
| 217 |
$F{assignee_id} = $temp;
|
228 |
$F{assignee_id} = $temp;
|
| 218 |
} else {
|
229 |
} else {
|
| 219 |
$F{assignee_id} = $h->a ({ onClick=>"window.open('make_shift_change.pl?change=lookup&id=$F{id}','Confirm Shift Change','resizable,height=260,width=370'); return false;" }, "[ADD USER]");
|
230 |
$F{assignee_id} = $h->a ({ onClick=>"window.open('make_shift_change.pl?change=lookup&id=$F{id}','Confirm Shift Change','resizable,height=260,width=370'); return false;" }, "[ADD USER]");
|
| 220 |
}
|
231 |
}
|
| - |
|
232 |
$F{doubletime} = $F{doubletime} ? "TRUE" : "FALSE";
|
| Line 221... |
Line 233... |
| 221 |
|
233 |
|
| 222 |
$actionbutton = formField ("choice", "Update");
|
234 |
$actionbutton = formField ("choice", "Update");
|
| 223 |
if ($view eq "POSTSAVE") {
|
235 |
if ($view eq "POSTSAVE") {
|
| 224 |
$actionbutton .= formField ("Cancel", "Back", "POSTSAVE");
|
236 |
$actionbutton .= formField ("Cancel", "Back", "POSTSAVE");
|
| Line 299... |
Line 311... |
| 299 |
sub formField {
|
311 |
sub formField {
|
| 300 |
my $name = shift;
|
312 |
my $name = shift;
|
| 301 |
my $value = shift // '';
|
313 |
my $value = shift // '';
|
| 302 |
my $context = shift // '';
|
314 |
my $context = shift // '';
|
| 303 |
my $type = $fieldType{$name} // "button";
|
315 |
my $type = $fieldType{$name} // "button";
|
| 304 |
|
316 |
|
| 305 |
if ($type eq "button") {
|
317 |
if ($type eq "button") {
|
| 306 |
if ($name eq "Cancel") {
|
318 |
if ($name eq "Cancel") {
|
| 307 |
if ($context eq "POSTSAVE") {
|
319 |
if ($context eq "POSTSAVE") {
|
| 308 |
return $h->input ({ type=>"button", value => $value ne '' ? $value : "Cancel" , onClick=>"window.location.href = \"manage_shifts.pl\"; return false;" });
|
320 |
return $h->input ({ type=>"button", value => $value ne '' ? $value : "Cancel" , onClick=>"window.location.href = \"manage_shifts.pl\"; return false;" });
|
| 309 |
} else {
|
321 |
} else {
|
| Line 335... |
Line 347... |
| 335 |
required => [],
|
347 |
required => [],
|
| 336 |
override => 1,
|
348 |
override => 1,
|
| 337 |
size => 30
|
349 |
size => 30
|
| 338 |
});
|
350 |
});
|
| 339 |
} elsif ($type eq "number") {
|
351 |
} elsif ($type eq "number") {
|
| 340 |
return $h->input ({ name=>$name, type=>"number", value=>$value, step=>.25 }),
|
352 |
return $h->input ({ name=>$name, type=>"number", value=>$value, step=>.25 });
|
| - |
|
353 |
} elsif ($type eq "switch") {
|
| - |
|
354 |
if ($value) {
|
| - |
|
355 |
return $h->label ({ class=>"switch" }, [$h->input ({ type=>"checkbox", name=>$name, value=>1, checked=>[] }), $h->span ({ class=>"slider round" })]);
|
| - |
|
356 |
} else {
|
| - |
|
357 |
return $h->label ({ class=>"switch" }, [$h->input ({ type=>"checkbox", name=>$name, value=>1 }), $h->span ({ class=>"slider round" })]);
|
| - |
|
358 |
}
|
| - |
|
359 |
# $F->{department}->{$_} = $h->label ({ class=>"switch" }, [$h->input ({ type=>"checkbox", name=>"DEPT-$_", value=>0, checked=>[] }), $h->span ({ class=>"slider round" })]);
|
| 341 |
} else {
|
360 |
} else {
|
| 342 |
use tableViewer;
|
361 |
use tableViewer;
|
| 343 |
if (inArray ($name, \@requiredFields)) {
|
362 |
if (inArray ($name, \@requiredFields)) {
|
| 344 |
return $h->input ({
|
363 |
return $h->input ({
|
| 345 |
name => $name,
|
364 |
name => $name,
|