| Line 32... |
Line 32... |
| 32 |
my $DBTable = "class";
|
32 |
my $DBTable = "class";
|
| 33 |
my %FIELDS = (
|
33 |
my %FIELDS = (
|
| 34 |
id => [qw(ClassID 5 auto static )],
|
34 |
id => [qw(ClassID 5 auto static )],
|
| 35 |
name => [qw(ClassName 10 text required )],
|
35 |
name => [qw(ClassName 10 text required )],
|
| 36 |
coach => [qw(Coach 15 select required )],
|
36 |
coach => [qw(Coach 15 select required )],
|
| - |
|
37 |
assistant => [qw(Assistant 17 select )],
|
| 37 |
date => [qw(Date 20 date required )],
|
38 |
date => [qw(Date 20 date required )],
|
| 38 |
location => [qw(Location 25 text required )],
|
39 |
location => [qw(Location 25 text required )],
|
| 39 |
level => [qw(Level 27 text required )],
|
40 |
level => [qw(Level 27 text required )],
|
| 40 |
start_time => [qw(Start 30 time required )],
|
41 |
start_time => [qw(Start 30 time required )],
|
| 41 |
end_time => [qw(End 35 time required )],
|
42 |
end_time => [qw(End 35 time required )],
|
| Line 62... |
Line 63... |
| 62 |
|
63 |
|
| 63 |
my $dbh = WebDB::connect ();
|
64 |
my $dbh = WebDB::connect ();
|
| 64 |
if ($FTS->{$DBFields[0]} eq "NEW") {
|
65 |
if ($FTS->{$DBFields[0]} eq "NEW") {
|
| 65 |
$dbh->do (
|
66 |
$dbh->do (
|
| 66 |
"INSERT INTO $DBTable
|
67 |
"INSERT INTO $DBTable
|
| 67 |
(name,coach,date,location,level,start_time,end_time,capacity,note)
|
68 |
(name,coach,assistant,date,location,level,start_time,end_time,capacity,note)
|
| 68 |
VALUES(?,?,?,?,?,?,?,?)",
|
69 |
VALUES(?,?,?,?,?,?,?,?)",
|
| 69 |
undef,
|
70 |
undef,
|
| 70 |
$FTS->{name}, $FTS->{coach}, $FTS->{date}, $FTS->{location}, $FTS->{level}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{capacity}, $FTS->{note}
|
71 |
$FTS->{name}, $FTS->{coach}, $FTS->{assistant}, $FTS->{date}, $FTS->{location}, $FTS->{level}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{capacity}, $FTS->{note}
|
| 71 |
);
|
72 |
);
|
| 72 |
($FTS->{id}) = $dbh-> selectrow_array ("select max(id) from $DBTable where name = ? and date = ? and location = ? and start_time = ? and end_time = ?", undef, $FTS->{name}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time});
|
73 |
($FTS->{id}) = $dbh-> selectrow_array ("select max(id) from $DBTable where name = ? and date = ? and location = ? and start_time = ? and end_time = ?", undef, $FTS->{name}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time});
|
| Line 73... |
Line 74... |
| 73 |
logit ($RCid, "$username created new class ($FTS->{id}, $FTS->{name}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{capacity})");
|
74 |
logit ($RCid, "$username created new class ($FTS->{id}, $FTS->{name}, $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{capacity})");
|
| Line 77... |
Line 78... |
| 77 |
"INSERT INTO shift
|
78 |
"INSERT INTO shift
|
| 78 |
(dept,role,type,date,location,start_time,end_time,doubletime,note,assignee_id)
|
79 |
(dept,role,type,date,location,start_time,end_time,doubletime,note,assignee_id)
|
| 79 |
VALUES (?,?,?,?,?,?,?,?,?,?)",
|
80 |
VALUES (?,?,?,?,?,?,?,?,?,?)",
|
| 80 |
undef,
|
81 |
undef,
|
| 81 |
"COA", "Coach", "selected", $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, 1, $FTS->{name}, $FTS->{coach}
|
82 |
"COA", "Coach", "selected", $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, 1, $FTS->{name}, $FTS->{coach}
|
| 82 |
);
|
83 |
);
|
| - |
|
84 |
|
| - |
|
85 |
if ($FTS->{assistant}) {
|
| - |
|
86 |
# There's also an assistant coach
|
| - |
|
87 |
$dbh->do (
|
| - |
|
88 |
"INSERT INTO shift
|
| - |
|
89 |
(dept,role,type,date,location,start_time,end_time,doubletime,note,assignee_id)
|
| - |
|
90 |
VALUES (?,?,?,?,?,?,?,?,?,?)",
|
| - |
|
91 |
undef,
|
| - |
|
92 |
"COA", "Assistant Coach", "selected", $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, 0, $FTS->{name}, $FTS->{assistant}
|
| - |
|
93 |
);
|
| - |
|
94 |
}
|
| 83 |
} else {
|
95 |
} else {
|
| 84 |
$dbh->do (
|
96 |
$dbh->do (
|
| 85 |
"UPDATE $DBTable
|
97 |
"UPDATE $DBTable
|
| 86 |
SET name=?, coach=?, date=?, location=?, level=?, start_time=?, end_time=?, capacity=?, note=?
|
98 |
SET name=?, coach=?, assistant=?, date=?, location=?, level=?, start_time=?, end_time=?, capacity=?, note=?
|
| 87 |
WHERE id = ?",
|
99 |
WHERE id = ?",
|
| 88 |
undef,
|
100 |
undef,
|
| 89 |
$FTS->{name}, $FTS->{coach}, $FTS->{date}, $FTS->{location}, $FTS->{level}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{capacity}, $FTS->{note}, $FTS->{id}
|
101 |
$FTS->{name}, $FTS->{coach}, $FTS->{assistant}, $FTS->{date}, $FTS->{location}, $FTS->{level}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{capacity}, $FTS->{note}, $FTS->{id}
|
| 90 |
);
|
102 |
);
|
| 91 |
logit ($RCid, "$username updated class ($FTS->{id}, $FTS->{name}, $FTS->{date}, $FTS->{location}, $FTS->{level}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{capacity})");
|
103 |
logit ($RCid, "$username updated class ($FTS->{id}, $FTS->{name}, $FTS->{date}, $FTS->{location}, $FTS->{level}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{capacity})");
|
| Line 92... |
Line 104... |
| 92 |
|
104 |
|
| 93 |
# Update the volunteer shift for the coach too.
|
105 |
# Update the volunteer shifts for the coach and assistant too.
|
| 94 |
if ($FTS->{classshiftid}) {
|
106 |
if ($FTS->{classshiftid}) {
|
| 95 |
$dbh->do (
|
107 |
$dbh->do (
|
| 96 |
"UPDATE shift
|
108 |
"UPDATE shift
|
| 97 |
SET date=?, location=?, start_time=?, end_time=?, note=?, assignee_id=?
|
109 |
SET date=?, location=?, start_time=?, end_time=?, note=?, assignee_id=?
|
| Line 106... |
Line 118... |
| 106 |
VALUES (?,?,?,?,?,?,?,?,?,?)",
|
118 |
VALUES (?,?,?,?,?,?,?,?,?,?)",
|
| 107 |
undef,
|
119 |
undef,
|
| 108 |
"COA", "Coach", "selected", $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, 1, $FTS->{name}, $FTS->{coach}
|
120 |
"COA", "Coach", "selected", $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, 1, $FTS->{name}, $FTS->{coach}
|
| 109 |
);
|
121 |
);
|
| 110 |
}
|
122 |
}
|
| - |
|
123 |
if ($FTS->{asstclassshiftid}) {
|
| - |
|
124 |
$dbh->do (
|
| - |
|
125 |
"UPDATE shift
|
| - |
|
126 |
SET date=?, location=?, start_time=?, end_time=?, note=?, assignee_id=?
|
| - |
|
127 |
WHERE id = ?",
|
| - |
|
128 |
undef,
|
| - |
|
129 |
$FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, $FTS->{name}, $FTS->{assistant}, $FTS->{asstclassshiftid}
|
| - |
|
130 |
);
|
| - |
|
131 |
} else {
|
| - |
|
132 |
$dbh->do (
|
| - |
|
133 |
"INSERT INTO shift
|
| - |
|
134 |
(dept,role,type,date,location,start_time,end_time,doubletime,note,assignee_id)
|
| - |
|
135 |
VALUES (?,?,?,?,?,?,?,?,?,?)",
|
| - |
|
136 |
undef,
|
| - |
|
137 |
"COA", "Assistant Coach", "selected", $FTS->{date}, $FTS->{location}, $FTS->{start_time}, $FTS->{end_time}, 0, $FTS->{name}, $FTS->{assistant}
|
| - |
|
138 |
);
|
| - |
|
139 |
}
|
| 111 |
}
|
140 |
}
|
| Line 112... |
Line 141... |
| 112 |
|
141 |
|
| 113 |
$dbh->disconnect (); # stored into database successfully.
|
142 |
$dbh->disconnect (); # stored into database successfully.
|
| 114 |
return $FTS->{id};
|
143 |
return $FTS->{id};
|
| Line 121... |
Line 150... |
| 121 |
my $dbh = WebDB::connect ();
|
150 |
my $dbh = WebDB::connect ();
|
| Line 122... |
Line 151... |
| 122 |
|
151 |
|
| 123 |
## First get the shift ID of the volunteer shift of the coach (and then delete it)
|
152 |
## First get the shift ID of the volunteer shift of the coach (and then delete it)
|
| 124 |
my ($classshiftid) = $dbh->selectrow_array (
|
153 |
my ($classshiftid) = $dbh->selectrow_array (
|
| 125 |
"select shift.id from shift
|
154 |
"select shift.id from shift
|
| 126 |
join class where shift.date = class.date and shift.start_time = class.start_time and shift.location = class.location and dept = ? and class.id = ?",
|
155 |
join class where shift.date = class.date and shift.start_time = class.start_time and shift.location = class.location and dept = ? and role = ? and class.id = ?",
|
| 127 |
undef, "COA", $X->{$primary}
|
156 |
undef, "COA", "Coach", $X->{$primary}
|
| 128 |
);
|
157 |
);
|
| - |
|
158 |
$dbh->do ("delete from shift where id = ?", undef, $classshiftid);
|
| - |
|
159 |
|
| - |
|
160 |
my ($asstclassshiftid) = $dbh->selectrow_array (
|
| - |
|
161 |
"select shift.id from shift
|
| - |
|
162 |
join class where shift.date = class.date and shift.start_time = class.start_time and shift.location = class.location and dept = ? and role = ? and class.id = ?",
|
| - |
|
163 |
undef, "COA", "Assistant Coach", $X->{$primary}
|
| - |
|
164 |
);
|
| Line 129... |
Line 165... |
| 129 |
$dbh->do ("delete from shift where id = ?", undef, $classshiftid);
|
165 |
$dbh->do ("delete from shift where id = ?", undef, $asstclassshiftid);
|
| 130 |
|
166 |
|
| 131 |
$dbh->do ("delete from $DBTable where $primary = ?", undef, $X->{$primary});
|
167 |
$dbh->do ("delete from $DBTable where $primary = ?", undef, $X->{$primary});
|
| 132 |
## If we're deleting a class, we need to also delete all of the sign-ups
|
168 |
## If we're deleting a class, we need to also delete all of the sign-ups
|
| Line 144... |
Line 180... |
| 144 |
my $selection = shift // "";
|
180 |
my $selection = shift // "";
|
| Line 145... |
Line 181... |
| 145 |
|
181 |
|
| 146 |
return $h->select ({ name=>"coach" }, [ $h->option (""), fetchDerbyNameWithRCid ("COA", $selection) ]);
|
182 |
return $h->select ({ name=>"coach" }, [ $h->option (""), fetchDerbyNameWithRCid ("COA", $selection) ]);
|
| Line -... |
Line 183... |
| - |
|
183 |
};
|
| - |
|
184 |
|
| - |
|
185 |
sub select_assistant {
|
| - |
|
186 |
my $selection = shift // "";
|
| - |
|
187 |
|
| - |
|
188 |
return $h->select ({ name=>"assistant" }, [ $h->option (""), fetchDerbyNameWithRCid ("COA", $selection) ]);
|
| Line 147... |
Line 189... |
| 147 |
};
|
189 |
};
|
| 148 |
|
190 |
|
| Line 149... |
Line 191... |
| 149 |
|
191 |
|
| Line 197... |
Line 239... |
| 197 |
@F{@DBFields} = $dbh->selectrow_array (
|
239 |
@F{@DBFields} = $dbh->selectrow_array (
|
| 198 |
"SELECT ". join (", ", @DBFields) ." FROM $DBTable WHERE $primary = ?",
|
240 |
"SELECT ". join (", ", @DBFields) ." FROM $DBTable WHERE $primary = ?",
|
| 199 |
undef, $R->{$primary});
|
241 |
undef, $R->{$primary});
|
| Line 200... |
Line 242... |
| 200 |
|
242 |
|
| 201 |
my ($classshiftid) = $dbh->selectrow_array (
|
243 |
my ($classshiftid) = $dbh->selectrow_array (
|
| 202 |
"select id from shift where dept = ? and date = ? and start_time = ? and location = ?",
|
244 |
"select id from shift where dept = ? and role = ? and date = ? and start_time = ? and location = ?",
|
| - |
|
245 |
undef, "COA", "Coach", $F{date}, $F{start_time}, $F{location}
|
| - |
|
246 |
);
|
| - |
|
247 |
my ($asstclassshiftid) = $dbh->selectrow_array (
|
| - |
|
248 |
"select id from shift where dept = ? and role = ? and date = ? and start_time = ? and location = ?",
|
| 203 |
undef, "COA", $F{date}, $F{start_time}, $F{location}
|
249 |
undef, "COA", "Assistant Coach", $F{date}, $F{start_time}, $F{location}
|
| 204 |
);
|
250 |
);
|
| Line 205... |
Line 251... |
| 205 |
$dbh->disconnect ();
|
251 |
$dbh->disconnect ();
|
| 206 |
|
252 |
|
| Line 217... |
Line 263... |
| 217 |
foreach (@DBFields) {
|
263 |
foreach (@DBFields) {
|
| 218 |
$F{$_} = formField ($_, $F{$_});
|
264 |
$F{$_} = formField ($_, $F{$_});
|
| 219 |
}
|
265 |
}
|
| 220 |
$F{$DBFields[0]} .= $h->input ({ type=>"hidden", name=>$DBFields[0], value=> $F{$DBFields[0]} });
|
266 |
$F{$DBFields[0]} .= $h->input ({ type=>"hidden", name=>$DBFields[0], value=> $F{$DBFields[0]} });
|
| 221 |
$F{$DBFields[0]} .= $h->input ({ type=>"hidden", name=>"classshiftid", value=> $classshiftid });
|
267 |
$F{$DBFields[0]} .= $h->input ({ type=>"hidden", name=>"classshiftid", value=> $classshiftid });
|
| - |
|
268 |
$F{$DBFields[0]} .= $h->input ({ type=>"hidden", name=>"asstclassshiftid", value=> $asstclassshiftid });
|
| Line 222... |
Line 269... |
| 222 |
|
269 |
|
| 223 |
$actionbutton = formField ("choice", "Save");
|
270 |
$actionbutton = formField ("choice", "Save");
|
| 224 |
$actionbutton .= formField ("Cancel");
|
271 |
$actionbutton .= formField ("Cancel");
|
| 225 |
} elsif ($view eq "Copy") {
|
272 |
} elsif ($view eq "Copy") {
|
| Line 237... |
Line 284... |
| 237 |
# We're just looking at it...
|
284 |
# We're just looking at it...
|
| 238 |
print $h->p ("Viewing Class: $R->{$primary}...");
|
285 |
print $h->p ("Viewing Class: $R->{$primary}...");
|
| 239 |
$F{$DBFields[0]} .= $h->input ({ type=>"hidden", name=>$DBFields[0], value=> $F{$DBFields[0]} });
|
286 |
$F{$DBFields[0]} .= $h->input ({ type=>"hidden", name=>$DBFields[0], value=> $F{$DBFields[0]} });
|
| 240 |
$coachRCid = $F{coach};
|
287 |
$coachRCid = $F{coach};
|
| 241 |
$F{coach} = $h->a ({ href=>"/schedule/view_user.pl?RCid=$F{coach}" }, getUserDerbyName $F{coach});
|
288 |
$F{coach} = $h->a ({ href=>"/schedule/view_user.pl?RCid=$F{coach}" }, getUserDerbyName $F{coach});
|
| - |
|
289 |
$F{assistant} = $h->a ({ href=>"/schedule/view_user.pl?RCid=$F{assistant}" }, getUserDerbyName $F{assistant});
|
| Line 242... |
Line 290... |
| 242 |
|
290 |
|
| 243 |
$F{start_time} = convertTime $F{start_time};
|
291 |
$F{start_time} = convertTime $F{start_time};
|
| 244 |
$F{end_time} = convertTime $F{end_time};
|
292 |
$F{end_time} = convertTime $F{end_time};
|
| 245 |
# if ($F{assignee_id}) {
|
293 |
# if ($F{assignee_id}) {
|
| Line 350... |
Line 398... |
| 350 |
} else {
|
398 |
} else {
|
| 351 |
$FORM{$_} = param ($_) // "";
|
399 |
$FORM{$_} = param ($_) // "";
|
| 352 |
}
|
400 |
}
|
| 353 |
}
|
401 |
}
|
| 354 |
$FORM{classshiftid} = param ("classshiftid") unless !param ("classshiftid");
|
402 |
$FORM{classshiftid} = param ("classshiftid") unless !param ("classshiftid");
|
| - |
|
403 |
$FORM{asstclassshiftid} = param ("asstclassshiftid") unless !param ("asstclassshiftid");
|
| Line 355... |
Line 404... |
| 355 |
|
404 |
|
| 356 |
# check for required fields
|
405 |
# check for required fields
|
| 357 |
my @errors = ();
|
406 |
my @errors = ();
|
| 358 |
foreach (@requiredFields) {
|
407 |
foreach (@requiredFields) {
|