1 package C4::CourseReserves;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use List::MoreUtils qw(any);
23 use C4::Circulation qw(GetOpenIssue);
26 use Koha::Course::Instructors;
27 use Koha::Course::Items;
28 use Koha::Course::Reserves;
30 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS @FIELDS);
54 &GetItemCourseReservesInfo
56 %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
58 @FIELDS = ( 'itype', 'ccode', 'homebranch', 'holdingbranch', 'location' );
63 C4::CourseReserves - Koha course reserves module
67 use C4::CourseReserves;
71 This module deals with course reserves.
77 $course = GetCourse( $course_id );
84 my $course = Koha::Courses->find( $course_id );
85 return unless $course;
86 $course = $course->unblessed;
88 my $dbh = C4::Context->dbh;
90 SELECT b.* FROM course_instructors ci
91 LEFT JOIN borrowers b ON ( ci.borrowernumber = b.borrowernumber )
94 my $sth = $dbh->prepare($query);
95 $sth->execute($course_id);
96 $course->{'instructors'} = $sth->fetchall_arrayref( {} );
103 ModCourse( [ course_id => $id ] [, course_name => $course_name ] [etc...] );
110 my $dbh = C4::Context->dbh;
113 if ( defined $params{'course_id'} ) {
114 $course_id = $params{'course_id'};
115 delete $params{'course_id'};
123 $query .= ($course_id) ? ' UPDATE ' : ' INSERT ';
124 $query .= ' courses SET ';
126 foreach my $key ( keys %params ) {
127 push( @query_keys, "$key=?" );
128 push( @query_values, $params{$key} );
130 $query .= join( ',', @query_keys );
133 $query .= " WHERE course_id = ?";
134 push( @query_values, $course_id );
137 $dbh->do( $query, undef, @query_values );
139 $course_id = $course_id
140 || $dbh->last_insert_id( undef, undef, 'courses', 'course_id' );
142 EnableOrDisableCourseItems(
143 course_id => $course_id,
144 enabled => $params{'enabled'}
152 @courses = GetCourses( [ fieldname => $value ] [, fieldname2 => $value2 ] [etc...] );
163 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
165 LEFT JOIN course_reserves ON course_reserves.course_id = c.course_id
166 LEFT JOIN course_items ON course_items.ci_id = course_reserves.ci_id
169 if ( keys %params ) {
173 foreach my $key ( keys %params ) {
174 push( @query_keys, " $key LIKE ? " );
175 push( @query_values, $params{$key} );
178 $query .= join( ' AND ', @query_keys );
181 $query .= " 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 ";
183 my $dbh = C4::Context->dbh;
184 my $sth = $dbh->prepare($query);
185 $sth->execute(@query_values);
187 my $courses = $sth->fetchall_arrayref( {} );
189 foreach my $c (@$courses) {
190 $c->{'instructors'} = GetCourseInstructors( $c->{'course_id'} );
198 DelCourse( $course_id );
203 my ($course_id) = @_;
205 my $course_reserves = GetCourseReserves( course_id => $course_id );
207 foreach my $res (@$course_reserves) {
208 DelCourseReserve( cr_id => $res->{'cr_id'} );
212 DELETE FROM course_instructors
215 C4::Context->dbh->do( $query, undef, $course_id );
221 C4::Context->dbh->do( $query, undef, $course_id );
224 =head2 EnableOrDisableCourseItems
226 EnableOrDisableCourseItems( course_id => $course_id, enabled => $enabled );
228 For each item on reserve for this course,
229 if the course item has no active course reserves,
230 swap the fields for the item to make it 'normal'
233 enabled => 'yes' to enable course items
234 enabled => 'no' to disable course items
238 sub EnableOrDisableCourseItems {
241 my $course_id = $params{'course_id'};
242 my $enabled = $params{'enabled'} || 0;
244 my $lookfor = ( $enabled eq 'yes' ) ? 'no' : 'yes';
246 return unless ( $course_id && $enabled );
247 return unless ( $enabled eq 'yes' || $enabled eq 'no' );
249 my $course_reserves = GetCourseReserves( course_id => $course_id );
251 if ( $enabled eq 'yes' ) {
252 foreach my $course_reserve (@$course_reserves) {
253 if (CountCourseReservesForItem(
254 ci_id => $course_reserve->{'ci_id'},
258 EnableOrDisableCourseItem(
259 ci_id => $course_reserve->{'ci_id'},
264 if ( $enabled eq 'no' ) {
265 foreach my $course_reserve (@$course_reserves) {
267 CountCourseReservesForItem(
268 ci_id => $course_reserve->{'ci_id'},
272 EnableOrDisableCourseItem(
273 ci_id => $course_reserve->{'ci_id'},
280 =head2 EnableOrDisableCourseItem
282 EnableOrDisableCourseItem( ci_id => $ci_id );
286 sub EnableOrDisableCourseItem {
289 my $ci_id = $params{'ci_id'};
291 return unless ( $ci_id );
293 my $course_item = GetCourseItem( ci_id => $ci_id );
295 my $info = GetItemCourseReservesInfo( itemnumber => $course_item->{itemnumber} );
297 my $enabled = any { $_->{course}->{enabled} eq 'yes' } @$info;
298 $enabled = $enabled ? 'yes' : 'no';
300 ## We don't want to 'enable' an already enabled item,
301 ## or disable and already disabled item,
302 ## as that would cause the fields to swap
303 if ( $course_item->{'enabled'} ne $enabled ) {
304 _SwapAllFields($ci_id, $enabled );
312 C4::Context->dbh->do( $query, undef, $enabled, $ci_id );
318 =head2 GetCourseInstructors
320 @$borrowers = GetCourseInstructors( $course_id );
324 sub GetCourseInstructors {
325 my ($course_id) = @_;
328 SELECT * FROM borrowers
329 RIGHT JOIN course_instructors ON ( course_instructors.borrowernumber = borrowers.borrowernumber )
330 WHERE course_instructors.course_id = ?
333 my $dbh = C4::Context->dbh;
334 my $sth = $dbh->prepare($query);
335 $sth->execute($course_id);
337 return $sth->fetchall_arrayref( {} );
340 =head2 ModCourseInstructors
342 ModCourseInstructors( mode => $mode, course_id => $course_id, [ cardnumbers => $cardnumbers ] OR [ borrowernumbers => $borrowernumbers );
344 $mode can be 'replace', 'add', or 'delete'
346 $cardnumbers and $borrowernumbers are both references to arrays
348 Use either cardnumbers or borrowernumber, but not both.
352 sub ModCourseInstructors {
355 my $course_id = $params{'course_id'};
356 my $mode = $params{'mode'};
357 my $cardnumbers = $params{'cardnumbers'};
358 my $borrowernumbers = $params{'borrowernumbers'};
360 return unless ($course_id);
362 unless ( $mode eq 'replace'
364 || $mode eq 'delete' );
365 return unless ( $cardnumbers || $borrowernumbers );
366 return if ( $cardnumbers && $borrowernumbers );
368 my ( @cardnumbers, @borrowernumbers );
369 @cardnumbers = @$cardnumbers if ( ref($cardnumbers) eq 'ARRAY' );
370 @borrowernumbers = @$borrowernumbers
371 if ( ref($borrowernumbers) eq 'ARRAY' );
373 my $field = (@cardnumbers) ? 'cardnumber' : 'borrowernumber';
374 my @fields = (@cardnumbers) ? @cardnumbers : @borrowernumbers;
375 my $placeholders = join( ',', ('?') x scalar @fields );
377 my $dbh = C4::Context->dbh;
379 $dbh->do( "DELETE FROM course_instructors WHERE course_id = ?", undef, $course_id )
380 if ( $mode eq 'replace' );
384 if ( $mode eq 'add' || $mode eq 'replace' ) {
386 INSERT INTO course_instructors ( course_id, borrowernumber )
387 SELECT ?, borrowernumber
389 WHERE $field IN ( $placeholders )
393 DELETE FROM course_instructors
395 AND borrowernumber IN (
396 SELECT borrowernumber FROM borrowers WHERE $field IN ( $placeholders )
401 my $sth = $dbh->prepare($query);
403 $sth->execute( $course_id, @fields ) if (@fields);
406 =head2 GetCourseItem {
408 $course_item = GetCourseItem( itemnumber => $itemnumber [, ci_id => $ci_id );
415 my $ci_id = $params{'ci_id'};
416 my $itemnumber = $params{'itemnumber'};
418 return unless ( $itemnumber || $ci_id );
420 my $field = ($itemnumber) ? 'itemnumber' : 'ci_id';
421 my $value = ($itemnumber) ? $itemnumber : $ci_id;
423 my $query = "SELECT * FROM course_items WHERE $field = ?";
424 my $dbh = C4::Context->dbh;
425 my $sth = $dbh->prepare($query);
426 $sth->execute($value);
428 my $course_item = $sth->fetchrow_hashref();
431 $query = "SELECT * FROM course_reserves WHERE ci_id = ?";
432 $sth = $dbh->prepare($query);
433 $sth->execute( $course_item->{'ci_id'} );
434 my $course_reserves = $sth->fetchall_arrayref( {} );
436 $course_item->{'course_reserves'} = $course_reserves
437 if ($course_reserves);
442 =head2 ModCourseItem {
444 ModCourseItem( %params );
446 Creates or modifies an existing course item.
453 my $itemnumber = $params{'itemnumber'};
455 return unless ($itemnumber);
457 my $course_item = GetCourseItem( itemnumber => $itemnumber );
462 $ci_id = $course_item->{'ci_id'};
466 course_item => $course_item,
470 $ci_id = _AddCourseItem(%params);
477 =head2 _AddCourseItem
479 my $ci_id = _AddCourseItem( %params );
486 $params{homebranch} ||= undef; # Can't be empty string, FK constraint
487 $params{holdingbranch} ||= undef; # Can't be empty string, FK constraint
489 my %data = map { $_ => $params{$_} } @FIELDS;
490 my %enabled = map { $_ . "_enabled" => $params{ $_ . "_enabled" } } @FIELDS;
492 my $ci = Koha::Course::Item->new(
494 itemnumber => $params{itemnumber},
503 =head2 _UpdateCourseItem
505 _UpdateCourseItem( %params );
509 sub _UpdateCourseItem {
512 my $ci_id = $params{'ci_id'};
513 my $course_item = $params{'course_item'};
515 $params{homebranch} ||= undef; # Can't be empty string, FK constraint
516 $params{holdingbranch} ||= undef; # Can't be empty string, FK constraint
518 return unless ( $ci_id || $course_item );
520 $course_item = Koha::Course::Items->find( $ci_id || $course_item->{ci_id} );
522 my %data = map { $_ => $params{$_} } @FIELDS;
523 my %enabled = map { $_ . "_enabled" => $params{ $_ . "_enabled" } } @FIELDS;
525 my $item = Koha::Items->find( $course_item->itemnumber );
527 # Handle updates to changed fields for a course item, both adding and removing
528 if ( $course_item->is_enabled ) {
529 my $item_fields = {};
531 for my $field ( @FIELDS ) {
533 my $field_enabled = $field . '_enabled';
534 my $field_storage = $field . '_storage';
536 # Find newly enabled field and add item value to storage
537 if ( $params{$field_enabled} && !$course_item->$field_enabled ) {
538 $enabled{$field_storage} = $item->$field;
539 $item_fields->{$field} = $params{$field};
541 # Find newly disabled field and copy the storage value to the item, unset storage value
542 elsif ( !$params{$field_enabled} && $course_item->$field_enabled ) {
543 $item_fields->{$field} = $course_item->$field_storage;
544 $enabled{$field_storage} = undef;
546 # The field was already enabled, copy the incoming value to the item.
547 # The "original" ( when not on course reserve ) value is already in the storage field
548 elsif ( $course_item->$field_enabled) {
549 $item_fields->{$field} = $params{$field};
553 $item->set( $item_fields )->store
554 if keys %$item_fields;
557 $course_item->update( { %data, %enabled } );
563 _RevertFields( ci_id => $ci_id, fields => \@fields_to_revert );
565 Copies fields from course item storage back to the actual item
572 my $ci_id = $params{'ci_id'};
574 return unless $ci_id;
576 my $course_item = Koha::Course::Items->find( $ci_id );
578 my $item_fields = {};
579 $item_fields->{itype} = $course_item->itype_storage if $course_item->itype_enabled;
580 $item_fields->{ccode} = $course_item->ccode_storage if $course_item->ccode_enabled;
581 $item_fields->{location} = $course_item->location_storage if $course_item->location_enabled;
582 $item_fields->{homebranch} = $course_item->homebranch_storage if $course_item->homebranch_enabled;
583 $item_fields->{holdingbranch} = $course_item->holdingbranch_storage if $course_item->holdingbranch_enabled;
585 Koha::Items->find( $course_item->itemnumber )
586 ->set( $item_fields )
588 if keys %$item_fields;
590 $course_item->itype_storage(undef);
591 $course_item->ccode_storage(undef);
592 $course_item->location_storage(undef);
593 $course_item->homebranch_storage(undef);
594 $course_item->holdingbranch_storage(undef);
595 $course_item->store();
598 =head2 _SwapAllFields
600 _SwapAllFields( $ci_id );
605 my ( $ci_id, $enabled ) = @_;
607 my $course_item = Koha::Course::Items->find( $ci_id );
608 my $item = Koha::Items->find( $course_item->itemnumber );
610 if ( $enabled eq 'yes' ) { # Copy item fields to course item storage, course item fields to item
611 $course_item->itype_storage( $item->effective_itemtype ) if $course_item->itype_enabled;
612 $course_item->ccode_storage( $item->ccode ) if $course_item->ccode_enabled;
613 $course_item->location_storage( $item->location ) if $course_item->location_enabled;
614 $course_item->homebranch_storage( $item->homebranch ) if $course_item->homebranch_enabled;
615 $course_item->holdingbranch_storage( $item->holdingbranch ) if $course_item->holdingbranch_enabled;
616 $course_item->store();
618 my $item_fields = {};
619 $item_fields->{itype} = $course_item->itype if $course_item->itype_enabled;
620 $item_fields->{ccode} = $course_item->ccode if $course_item->ccode_enabled;
621 $item_fields->{location} = $course_item->location if $course_item->location_enabled;
622 $item_fields->{homebranch} = $course_item->homebranch if $course_item->homebranch_enabled;
623 $item_fields->{holdingbranch} = $course_item->holdingbranch if $course_item->holdingbranch_enabled;
625 Koha::Items->find( $course_item->itemnumber )
626 ->set( $item_fields )
628 if keys %$item_fields;
630 } else { # Copy course item storage to item
631 my $item_fields = {};
632 $item_fields->{itype} = $course_item->itype_storage if $course_item->itype_enabled;
633 $item_fields->{ccode} = $course_item->ccode_storage if $course_item->ccode_enabled;
634 $item_fields->{location} = $course_item->location_storage if $course_item->location_enabled;
635 $item_fields->{homebranch} = $course_item->homebranch_storage if $course_item->homebranch_enabled;
636 $item_fields->{holdingbranch} = $course_item->holdingbranch_storage if $course_item->holdingbranch_enabled;
638 Koha::Items->find( $course_item->itemnumber )
639 ->set( $item_fields )
641 if keys %$item_fields;
643 $course_item->itype_storage(undef);
644 $course_item->ccode_storage(undef);
645 $course_item->location_storage(undef);
646 $course_item->homebranch_storage(undef);
647 $course_item->holdingbranch_storage(undef);
648 $course_item->store();
652 =head2 GetCourseItems {
654 $course_items = GetCourseItems(
655 [course_id => $course_id]
656 [, itemnumber => $itemnumber ]
664 my $course_id = $params{'course_id'};
665 my $itemnumber = $params{'itemnumber'};
667 return unless ($course_id);
672 my $query = "SELECT * FROM course_items";
674 if ( keys %params ) {
678 foreach my $key ( keys %params ) {
679 push( @query_keys, " $key LIKE ? " );
680 push( @query_values, $params{$key} );
683 $query .= join( ' AND ', @query_keys );
686 my $dbh = C4::Context->dbh;
687 my $sth = $dbh->prepare($query);
688 $sth->execute(@query_values);
690 return $sth->fetchall_arrayref( {} );
693 =head2 DelCourseItem {
695 DelCourseItem( ci_id => $cr_id );
702 my $ci_id = $params{'ci_id'};
704 return unless ($ci_id);
706 my $course_item = Koha::Course::Items->find( $ci_id );
707 return unless $course_item;
709 _RevertFields( ci_id => $ci_id ) if $course_item->enabled eq 'yes';
712 DELETE FROM course_items
715 C4::Context->dbh->do( $query, undef, $ci_id );
718 =head2 GetCourseReserve {
720 $course_item = GetCourseReserve( %params );
724 sub GetCourseReserve {
727 my $cr_id = $params{'cr_id'};
728 my $course_id = $params{'course_id'};
729 my $ci_id = $params{'ci_id'};
731 return unless ( $cr_id || ( $course_id && $ci_id ) );
733 my $dbh = C4::Context->dbh;
738 SELECT * FROM course_reserves
741 $sth = $dbh->prepare($query);
742 $sth->execute($cr_id);
745 SELECT * FROM course_reserves
746 WHERE course_id = ? AND ci_id = ?
748 $sth = $dbh->prepare($query);
749 $sth->execute( $course_id, $ci_id );
752 my $course_reserve = $sth->fetchrow_hashref();
753 return $course_reserve;
756 =head2 ModCourseReserve
758 $id = ModCourseReserve( %params );
762 sub ModCourseReserve {
765 my $course_id = $params{'course_id'};
766 my $ci_id = $params{'ci_id'};
767 my $staff_note = $params{'staff_note'};
768 my $public_note = $params{'public_note'};
770 return unless ( $course_id && $ci_id );
772 my $course_reserve = GetCourseReserve( course_id => $course_id, ci_id => $ci_id );
775 my $dbh = C4::Context->dbh;
777 if ($course_reserve) {
778 $cr_id = $course_reserve->{'cr_id'};
781 UPDATE course_reserves
782 SET staff_note = ?, public_note = ?
785 $dbh->do( $query, undef, $staff_note, $public_note, $cr_id );
788 INSERT INTO course_reserves SET
794 $dbh->do( $query, undef, $course_id, $ci_id, $staff_note, $public_note );
795 $cr_id = $dbh->last_insert_id( undef, undef, 'course_reserves', 'cr_id' );
798 EnableOrDisableCourseItem(
799 ci_id => $params{'ci_id'},
805 =head2 GetCourseReserves {
807 $course_reserves = GetCourseReserves( %params );
814 include_courses => 1,
818 sub GetCourseReserves {
821 my $course_id = $params{'course_id'};
822 my $ci_id = $params{'ci_id'};
823 my $include_items = $params{'include_items'};
824 my $include_count = $params{'include_count'};
825 my $include_courses = $params{'include_courses'};
827 return unless ( $course_id || $ci_id );
829 my $field = ($course_id) ? 'course_id' : 'ci_id';
830 my $value = ($course_id) ? $course_id : $ci_id;
833 SELECT cr.*, ci.itemnumber
834 FROM course_reserves cr, course_items ci
836 AND cr.ci_id = ci.ci_id
838 my $dbh = C4::Context->dbh;
839 my $sth = $dbh->prepare($query);
840 $sth->execute($value);
842 my $course_reserves = $sth->fetchall_arrayref( {} );
844 if ($include_items) {
845 foreach my $cr (@$course_reserves) {
846 my $item = Koha::Items->find( $cr->{itemnumber} );
847 my $biblio = $item->biblio;
848 my $biblioitem = $biblio->biblioitem;
849 $cr->{'course_item'} = GetCourseItem( ci_id => $cr->{'ci_id'} );
850 $cr->{'item'} = $item;
851 $cr->{'biblio'} = $biblio;
852 $cr->{'biblioitem'} = $biblioitem;
853 $cr->{'issue'} = GetOpenIssue( $cr->{'itemnumber'} );
857 if ($include_count) {
858 foreach my $cr (@$course_reserves) {
859 $cr->{'reserves_count'} = CountCourseReservesForItem( ci_id => $cr->{'ci_id'} );
863 if ($include_courses) {
864 foreach my $cr (@$course_reserves) {
865 $cr->{'courses'} = GetCourses( itemnumber => $cr->{'itemnumber'} );
869 return $course_reserves;
872 =head2 DelCourseReserve {
874 DelCourseReserve( cr_id => $cr_id );
878 sub DelCourseReserve {
881 my $cr_id = $params{'cr_id'};
883 return unless ($cr_id);
885 my $dbh = C4::Context->dbh;
887 my $course_reserve = GetCourseReserve( cr_id => $cr_id );
890 DELETE FROM course_reserves
893 $dbh->do( $query, undef, $cr_id );
895 ## If there are no other course reserves for this item
896 ## delete the course_item as well
897 unless ( CountCourseReservesForItem( ci_id => $course_reserve->{'ci_id'} ) ) {
898 DelCourseItem( ci_id => $course_reserve->{'ci_id'} );
903 =head2 GetItemCourseReservesInfo
905 my $arrayref = GetItemCourseReservesInfo( itemnumber => $itemnumber );
907 For a given item, returns an arrayref of reserves hashrefs,
908 with a course hashref under the key 'course'
912 sub GetItemCourseReservesInfo {
915 my $itemnumber = $params{'itemnumber'};
917 return unless ($itemnumber);
919 my $course_item = GetCourseItem( itemnumber => $itemnumber );
921 return unless ( keys %$course_item );
923 my $course_reserves = GetCourseReserves( ci_id => $course_item->{'ci_id'} );
925 foreach my $cr (@$course_reserves) {
926 $cr->{'course'} = GetCourse( $cr->{'course_id'} );
929 return $course_reserves;
932 =head2 CountCourseReservesForItem
934 $bool = CountCourseReservesForItem( %params );
936 ci_id - course_item id
938 itemnumber - course_item itemnumber
940 enabled = 'yes' or 'no'
941 Optional, if not supplied, counts reserves
942 for both enabled and disabled courses
946 sub CountCourseReservesForItem {
949 my $ci_id = $params{'ci_id'};
950 my $itemnumber = $params{'itemnumber'};
951 my $enabled = $params{'enabled'};
953 return unless ( $ci_id || $itemnumber );
955 my $course_item = GetCourseItem( ci_id => $ci_id, itemnumber => $itemnumber );
957 my @params = ( $course_item->{'ci_id'} );
958 push( @params, $enabled ) if ($enabled);
961 SELECT COUNT(*) AS count
962 FROM course_reserves cr
963 LEFT JOIN courses c ON ( c.course_id = cr.course_id )
966 $query .= "AND c.enabled = ?" if ($enabled);
968 my $dbh = C4::Context->dbh;
969 my $sth = $dbh->prepare($query);
970 $sth->execute(@params);
972 my $row = $sth->fetchrow_hashref();
974 return $row->{'count'};
979 my $courses = SearchCourses( term => $search_term, enabled => 'yes' );
986 my $term = $params{'term'};
988 my $enabled = $params{'enabled'} || '%';
992 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
994 LEFT JOIN course_instructors ci
995 ON ( c.course_id = ci.course_id )
996 LEFT JOIN borrowers b
997 ON ( ci.borrowernumber = b.borrowernumber )
998 LEFT JOIN authorised_values av
999 ON ( c.department = av.authorised_value )
1001 ( av.category = 'DEPARTMENT' OR av.category = 'TERM' )
1004 department LIKE ? OR
1005 course_number LIKE ? OR
1007 course_name LIKE ? OR
1009 public_note LIKE ? OR
1010 CONCAT(surname,' ',firstname) LIKE ? OR
1011 CONCAT(firstname,' ',surname) LIKE ? OR
1017 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
1022 @params = ($term) x 10;
1024 $query .= " ORDER BY department, course_number, section, term, course_name ";
1026 my $dbh = C4::Context->dbh;
1027 my $sth = $dbh->prepare($query);
1029 $sth->execute( @params, $enabled );
1031 my $courses = $sth->fetchall_arrayref( {} );
1033 foreach my $c (@$courses) {
1034 $c->{'instructors'} = GetCourseInstructors( $c->{'course_id'} );
1040 sub whoami { ( caller(1) )[3] }
1041 sub whowasi { ( caller(2) )[3] }
1043 sub stringify_params {
1048 foreach my $key ( keys %params ) {
1049 $string .= " $key => " . $params{$key} . "\n";
1052 return "( $string )";
1059 Kyle M Hall <kyle@bywatersolutions.com>