Lines 17-22
package C4::CourseReserves;
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
|
|
20 |
use List::MoreUtils qw(any); |
21 |
|
20 |
use C4::Context; |
22 |
use C4::Context; |
21 |
use C4::Items qw(GetItem ModItem); |
23 |
use C4::Items qw(GetItem ModItem); |
22 |
use C4::Biblio qw(GetBiblioFromItemNumber); |
24 |
use C4::Biblio qw(GetBiblioFromItemNumber); |
Lines 259-265
sub EnableOrDisableCourseItems {
Link Here
|
259 |
) { |
261 |
) { |
260 |
EnableOrDisableCourseItem( |
262 |
EnableOrDisableCourseItem( |
261 |
ci_id => $course_reserve->{'ci_id'}, |
263 |
ci_id => $course_reserve->{'ci_id'}, |
262 |
enabled => 'yes', |
|
|
263 |
); |
264 |
); |
264 |
} |
265 |
} |
265 |
} |
266 |
} |
Lines 274-280
sub EnableOrDisableCourseItems {
Link Here
|
274 |
) { |
275 |
) { |
275 |
EnableOrDisableCourseItem( |
276 |
EnableOrDisableCourseItem( |
276 |
ci_id => $course_reserve->{'ci_id'}, |
277 |
ci_id => $course_reserve->{'ci_id'}, |
277 |
enabled => 'no', |
|
|
278 |
); |
278 |
); |
279 |
} |
279 |
} |
280 |
} |
280 |
} |
Lines 283-292
sub EnableOrDisableCourseItems {
Link Here
|
283 |
|
283 |
|
284 |
=head2 EnableOrDisableCourseItem |
284 |
=head2 EnableOrDisableCourseItem |
285 |
|
285 |
|
286 |
EnableOrDisableCourseItem( ci_id => $ci_id, enabled => $enabled ); |
286 |
EnableOrDisableCourseItem( ci_id => $ci_id ); |
287 |
|
|
|
288 |
enabled => 'yes' to enable course items |
289 |
enabled => 'no' to disable course items |
290 |
|
287 |
|
291 |
=cut |
288 |
=cut |
292 |
|
289 |
|
Lines 295-307
sub EnableOrDisableCourseItem {
Link Here
|
295 |
warn identify_myself(%params) if $DEBUG; |
292 |
warn identify_myself(%params) if $DEBUG; |
296 |
|
293 |
|
297 |
my $ci_id = $params{'ci_id'}; |
294 |
my $ci_id = $params{'ci_id'}; |
298 |
my $enabled = $params{'enabled'}; |
|
|
299 |
|
295 |
|
300 |
return unless ( $ci_id && $enabled ); |
296 |
return unless ( $ci_id ); |
301 |
return unless ( $enabled eq 'yes' || $enabled eq 'no' ); |
|
|
302 |
|
297 |
|
303 |
my $course_item = GetCourseItem( ci_id => $ci_id ); |
298 |
my $course_item = GetCourseItem( ci_id => $ci_id ); |
304 |
|
299 |
|
|
|
300 |
my $info = GetItemCourseReservesInfo( itemnumber => $course_item->{itemnumber} ); |
301 |
|
302 |
my $enabled = any { $_->{course}->{enabled} eq 'yes' } @$info; |
303 |
$enabled = $enabled ? 'yes' : 'no'; |
304 |
|
305 |
## We don't want to 'enable' an already enabled item, |
305 |
## We don't want to 'enable' an already enabled item, |
306 |
## or disable and already disabled item, |
306 |
## or disable and already disabled item, |
307 |
## as that would cause the fields to swap |
307 |
## as that would cause the fields to swap |
Lines 828-837
sub ModCourseReserve {
Link Here
|
828 |
$cr_id = $dbh->last_insert_id( undef, undef, 'course_reserves', 'cr_id' ); |
828 |
$cr_id = $dbh->last_insert_id( undef, undef, 'course_reserves', 'cr_id' ); |
829 |
} |
829 |
} |
830 |
|
830 |
|
831 |
my $course = GetCourse($course_id); |
|
|
832 |
EnableOrDisableCourseItem( |
831 |
EnableOrDisableCourseItem( |
833 |
ci_id => $params{'ci_id'}, |
832 |
ci_id => $params{'ci_id'}, |
834 |
enabled => $course->{'enabled'} |
|
|
835 |
); |
833 |
); |
836 |
|
834 |
|
837 |
return $cr_id; |
835 |
return $cr_id; |
Lines 932-938
sub DelCourseReserve {
Link Here
|
932 |
|
930 |
|
933 |
} |
931 |
} |
934 |
|
932 |
|
935 |
=head2 GetReservesInfo |
933 |
=head2 GetItemCourseReservesInfo |
936 |
|
934 |
|
937 |
my $arrayref = GetItemCourseReservesInfo( itemnumber => $itemnumber ); |
935 |
my $arrayref = GetItemCourseReservesInfo( itemnumber => $itemnumber ); |
938 |
|
936 |
|
939 |
- |
|
|