|
Lines 38-43
BEGIN {
Link Here
|
| 38 |
DelCourseReserve |
38 |
DelCourseReserve |
| 39 |
|
39 |
|
| 40 |
SearchCourses |
40 |
SearchCourses |
|
|
41 |
HasCoursesOfType |
| 41 |
|
42 |
|
| 42 |
GetItemCourseReservesInfo |
43 |
GetItemCourseReservesInfo |
| 43 |
); |
44 |
); |
|
Lines 157-163
sub GetCourses {
Link Here
|
| 157 |
my @query_values; |
158 |
my @query_values; |
| 158 |
|
159 |
|
| 159 |
my $query = " |
160 |
my $query = " |
| 160 |
SELECT c.course_id, c.department, c.course_number, c.section, c.course_name, c.term, c.staff_note, c.public_note, c.students_count, c.enabled, c.timestamp |
161 |
SELECT c.course_id, c.course_type, c.department, c.course_number, c.section, c.course_name, c.term, c.staff_note, c.public_note, c.students_count, c.enabled, c.timestamp |
| 161 |
FROM courses c |
162 |
FROM courses c |
| 162 |
LEFT JOIN course_reserves ON course_reserves.course_id = c.course_id |
163 |
LEFT JOIN course_reserves ON course_reserves.course_id = c.course_id |
| 163 |
LEFT JOIN course_items ON course_items.ci_id = course_reserves.ci_id |
164 |
LEFT JOIN course_items ON course_items.ci_id = course_reserves.ci_id |
|
Lines 176-182
sub GetCourses {
Link Here
|
| 176 |
} |
177 |
} |
| 177 |
|
178 |
|
| 178 |
$query .= |
179 |
$query .= |
| 179 |
" GROUP BY c.course_id, c.department, c.course_number, c.section, c.course_name, c.term, c.staff_note, c.public_note, c.students_count, c.enabled, c.timestamp "; |
180 |
" GROUP BY c.course_id, c.course_type, c.department, c.course_number, c.section, c.course_name, c.term, c.staff_note, c.public_note, c.students_count, c.enabled, c.timestamp "; |
| 180 |
|
181 |
|
| 181 |
my $dbh = C4::Context->dbh; |
182 |
my $dbh = C4::Context->dbh; |
| 182 |
my $sth = $dbh->prepare($query); |
183 |
my $sth = $dbh->prepare($query); |
|
Lines 1017-1023
sub CountCourseReservesForItem {
Link Here
|
| 1017 |
|
1018 |
|
| 1018 |
=head2 SearchCourses |
1019 |
=head2 SearchCourses |
| 1019 |
|
1020 |
|
| 1020 |
my $courses = SearchCourses( term => $search_term, enabled => 'yes', thesis_table => 'no' ); |
1021 |
my $courses = SearchCourses( term => $search_term, enabled => 'yes', course_type => 'COURSE' ); |
|
|
1022 |
my $courses = SearchCourses( term => $search_term, enabled => 'yes', course_type => 'RESEARCH_TABLE' ); |
| 1023 |
|
| 1024 |
# For backward compatibility (deprecated): |
| 1025 |
my $courses = SearchCourses( term => $search_term, enabled => 'yes', thesis_table => 'yes' ); |
| 1021 |
|
1026 |
|
| 1022 |
=cut |
1027 |
=cut |
| 1023 |
|
1028 |
|
|
Lines 1026-1037
sub SearchCourses {
Link Here
|
| 1026 |
|
1031 |
|
| 1027 |
my $term = $params{'term'}; |
1032 |
my $term = $params{'term'}; |
| 1028 |
|
1033 |
|
| 1029 |
my $enabled = $params{'enabled'} || '%'; |
1034 |
my $enabled = $params{'enabled'} || '%'; |
| 1030 |
my $thesis_table = $params{'thesis_table'} || 'no'; |
1035 |
|
|
|
1036 |
# Handle course_type parameter (new) or thesis_table parameter (deprecated for backward compatibility) |
| 1037 |
my $course_type; |
| 1038 |
if ( exists $params{'course_type'} ) { |
| 1039 |
$course_type = $params{'course_type'}; |
| 1040 |
} elsif ( exists $params{'thesis_table'} ) { |
| 1041 |
|
| 1042 |
# Backward compatibility: translate thesis_table to course_type |
| 1043 |
$course_type = $params{'thesis_table'} eq 'yes' ? 'RESEARCH_TABLE' : 'COURSE'; |
| 1044 |
} else { |
| 1045 |
|
| 1046 |
# Default to showing regular courses |
| 1047 |
$course_type = '%'; |
| 1048 |
} |
| 1031 |
|
1049 |
|
| 1032 |
my @params; |
1050 |
my @params; |
| 1033 |
my $query = " |
1051 |
my $query = " |
| 1034 |
SELECT c.course_id, c.department, c.course_number, c.section, c.course_name, c.term, c.staff_note, c.public_note, c.students_count, c.enabled, c.timestamp |
1052 |
SELECT c.course_id, c.course_type, c.department, c.course_number, c.section, c.course_name, c.term, c.staff_note, c.public_note, c.students_count, c.enabled, c.timestamp |
| 1035 |
FROM courses c |
1053 |
FROM courses c |
| 1036 |
LEFT JOIN course_instructors ci |
1054 |
LEFT JOIN course_instructors ci |
| 1037 |
ON ( c.course_id = ci.course_id ) |
1055 |
ON ( c.course_id = ci.course_id ) |
|
Lines 1056-1089
sub SearchCourses {
Link Here
|
| 1056 |
) |
1074 |
) |
| 1057 |
AND |
1075 |
AND |
| 1058 |
c.enabled LIKE ? |
1076 |
c.enabled LIKE ? |
|
|
1077 |
AND |
| 1078 |
c.course_type LIKE ? |
| 1059 |
"; |
1079 |
"; |
| 1060 |
|
1080 |
|
| 1061 |
if ( $thesis_table eq 'no' ) { |
|
|
| 1062 |
$query .= " |
| 1063 |
AND |
| 1064 |
c.department != 'TT' |
| 1065 |
"; |
| 1066 |
} else { |
| 1067 |
$query .= " |
| 1068 |
AND |
| 1069 |
c.department = 'TT' |
| 1070 |
"; |
| 1071 |
} |
| 1072 |
|
| 1073 |
$query .= " |
1081 |
$query .= " |
| 1074 |
GROUP BY c.course_id, c.department, c.course_number, c.section, c.course_name, c.term, c.staff_note, c.public_note, c.students_count, c.enabled, c.timestamp |
1082 |
GROUP BY c.course_id, c.course_type, c.department, c.course_number, c.section, c.course_name, c.term, c.staff_note, c.public_note, c.students_count, c.enabled, c.timestamp |
| 1075 |
"; |
1083 |
"; |
| 1076 |
|
1084 |
|
| 1077 |
$term //= ''; |
1085 |
$term //= ''; |
| 1078 |
$term = "%$term%"; |
1086 |
$term = "%$term%"; |
| 1079 |
@params = ($term) x 10; |
1087 |
@params = ($term) x 10; |
| 1080 |
|
1088 |
|
| 1081 |
$query .= " ORDER BY department, course_number, section, term, course_name "; |
1089 |
$query .= " ORDER BY course_type, department, course_number, section, term, course_name "; |
| 1082 |
|
1090 |
|
| 1083 |
my $dbh = C4::Context->dbh; |
1091 |
my $dbh = C4::Context->dbh; |
| 1084 |
my $sth = $dbh->prepare($query); |
1092 |
my $sth = $dbh->prepare($query); |
| 1085 |
|
1093 |
|
| 1086 |
$sth->execute( @params, $enabled ); |
1094 |
$sth->execute( @params, $enabled, $course_type ); |
| 1087 |
|
1095 |
|
| 1088 |
my $courses = $sth->fetchall_arrayref( {} ); |
1096 |
my $courses = $sth->fetchall_arrayref( {} ); |
| 1089 |
|
1097 |
|
|
Lines 1094-1099
sub SearchCourses {
Link Here
|
| 1094 |
return $courses; |
1102 |
return $courses; |
| 1095 |
} |
1103 |
} |
| 1096 |
|
1104 |
|
|
|
1105 |
=head2 HasCoursesOfType |
| 1106 |
|
| 1107 |
my $has_research_tables = HasCoursesOfType( course_type => 'RESEARCH_TABLE', enabled => 'yes' ); |
| 1108 |
|
| 1109 |
Returns true if any courses of the specified type exist. |
| 1110 |
|
| 1111 |
=cut |
| 1112 |
|
| 1113 |
sub HasCoursesOfType { |
| 1114 |
my (%params) = @_; |
| 1115 |
|
| 1116 |
my $course_type = $params{'course_type'} || return 0; |
| 1117 |
my $enabled = $params{'enabled'} || '%'; |
| 1118 |
|
| 1119 |
my $dbh = C4::Context->dbh; |
| 1120 |
my $sth = $dbh->prepare("SELECT COUNT(*) FROM courses WHERE course_type LIKE ? AND enabled LIKE ?"); |
| 1121 |
$sth->execute( $course_type, $enabled ); |
| 1122 |
|
| 1123 |
my ($count) = $sth->fetchrow_array(); |
| 1124 |
return $count > 0; |
| 1125 |
} |
| 1126 |
|
| 1097 |
=head2 whoami |
1127 |
=head2 whoami |
| 1098 |
|
1128 |
|
| 1099 |
Missing POD for whoami. |
1129 |
Missing POD for whoami. |
| 1100 |
- |
|
|