View | Details | Raw Unified | Return to bug 8215
Collapse All | Expand All

(-)a/C4/Auth.pm (-1 / +3 lines)
Lines 194-200 sub get_template_and_user { Link Here
194
            $template->param( CAN_user_reserveforothers => 1 );
194
            $template->param( CAN_user_reserveforothers => 1 );
195
            $template->param( CAN_user_borrow           => 1 );
195
            $template->param( CAN_user_borrow           => 1 );
196
            $template->param( CAN_user_editcatalogue    => 1 );
196
            $template->param( CAN_user_editcatalogue    => 1 );
197
            $template->param( CAN_user_updatecharges     => 1 );
197
            $template->param( CAN_user_updatecharges    => 1 );
198
            $template->param( CAN_user_acquisition      => 1 );
198
            $template->param( CAN_user_acquisition      => 1 );
199
            $template->param( CAN_user_management       => 1 );
199
            $template->param( CAN_user_management       => 1 );
200
            $template->param( CAN_user_tools            => 1 );
200
            $template->param( CAN_user_tools            => 1 );
Lines 202-207 sub get_template_and_user { Link Here
202
            $template->param( CAN_user_serials          => 1 );
202
            $template->param( CAN_user_serials          => 1 );
203
            $template->param( CAN_user_reports          => 1 );
203
            $template->param( CAN_user_reports          => 1 );
204
            $template->param( CAN_user_staffaccess      => 1 );
204
            $template->param( CAN_user_staffaccess      => 1 );
205
            $template->param( CAN_user_coursereserves   => 1 );
205
            foreach my $module (keys %$all_perms) {
206
            foreach my $module (keys %$all_perms) {
206
                foreach my $subperm (keys %{ $all_perms->{$module} }) {
207
                foreach my $subperm (keys %{ $all_perms->{$module} }) {
207
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
208
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
Lines 330-335 sub get_template_and_user { Link Here
330
            using_https                  => $in->{'query'}->https() ? 1 : 0,
331
            using_https                  => $in->{'query'}->https() ? 1 : 0,
331
            noItemTypeImages             => C4::Context->preference("noItemTypeImages"),
332
            noItemTypeImages             => C4::Context->preference("noItemTypeImages"),
332
            marcflavour                  => C4::Context->preference("marcflavour"),
333
            marcflavour                  => C4::Context->preference("marcflavour"),
334
            UseCourseReserves            => C4::Context->preference("UseCourseReserves"),
333
    );
335
    );
334
336
335
    if ( $in->{'type'} eq "intranet" ) {
337
    if ( $in->{'type'} eq "intranet" ) {
(-)a/C4/Koha.pm (-5 / +20 lines)
Lines 41-46 BEGIN { Link Here
41
		&subfield_is_koha_internal_p
41
		&subfield_is_koha_internal_p
42
		&GetPrinters &GetPrinter
42
		&GetPrinters &GetPrinter
43
		&GetItemTypes &getitemtypeinfo
43
		&GetItemTypes &getitemtypeinfo
44
		&GetItemTypesFlat
44
		&GetCcodes
45
		&GetCcodes
45
		&GetSupportName &GetSupportList
46
		&GetSupportName &GetSupportList
46
		&get_itemtypeinfos_of
47
		&get_itemtypeinfos_of
Lines 256-261 sub GetItemTypes { Link Here
256
    return ( \%itemtypes );
257
    return ( \%itemtypes );
257
}
258
}
258
259
260
sub GetItemTypesFlat {
261
    my $dbh   = C4::Context->dbh;
262
    my $query = "SELECT * FROM itemtypes ORDER BY description";
263
    my $sth = $dbh->prepare($query);
264
    $sth->execute;
265
266
    return $sth->fetchall_arrayref({});
267
}
268
259
sub get_itemtypeinfos_of {
269
sub get_itemtypeinfos_of {
260
    my @itemtypes = @_;
270
    my @itemtypes = @_;
261
271
Lines 1066-1072 sub GetAuthorisedValueCategories { Link Here
1066
1076
1067
=head2 GetAuthorisedValueByCode
1077
=head2 GetAuthorisedValueByCode
1068
1078
1069
$authhorised_value = GetAuthorisedValueByCode( $category, $authvalcode );
1079
$authorised_value = GetAuthorisedValueByCode( $category, $authvalcode, $opac );
1070
1080
1071
Return the lib attribute from authorised_values from the row identified
1081
Return the lib attribute from authorised_values from the row identified
1072
by the passed category and code
1082
by the passed category and code
Lines 1074-1086 by the passed category and code Link Here
1074
=cut
1084
=cut
1075
1085
1076
sub GetAuthorisedValueByCode {
1086
sub GetAuthorisedValueByCode {
1077
    my ( $category, $authvalcode ) = @_;
1087
    my ( $category, $authvalcode, $opac ) = @_;
1078
1088
1079
    my $dbh = C4::Context->dbh;
1089
    my $dbh = C4::Context->dbh;
1080
    my $sth = $dbh->prepare("SELECT lib FROM authorised_values WHERE category=? AND authorised_value =?");
1090
    my $sth = $dbh->prepare("SELECT lib, lib_opac FROM authorised_values WHERE category=? AND authorised_value =?");
1081
    $sth->execute( $category, $authvalcode );
1091
    $sth->execute( $category, $authvalcode );
1082
    while ( my $data = $sth->fetchrow_hashref ) {
1092
1083
        return $data->{'lib'};
1093
    my $row = $sth->fetchrow_hashref();
1094
1095
    if ( $opac ) {
1096
        return $row->{'lib_opac'} || $row->{'lib'};
1097
    } else {
1098
        return $row->{'lib'};
1084
    }
1099
    }
1085
}
1100
}
1086
1101
(-)a/Koha/CourseReserves.pm (+1116 lines)
Line 0 Link Here
1
package Koha::CourseReserves;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 2 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along with
15
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16
# Suite 330, Boston, MA  02111-1307 USA
17
18
use Modern::Perl;
19
20
require Exporter;
21
22
use C4::Context;
23
use C4::Items qw(GetItem ModItem);
24
use C4::Biblio qw(GetBiblioFromItemNumber);
25
use C4::Circulation qw(GetOpenIssue);
26
27
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG @FIELDS);
28
29
BEGIN {
30
    @ISA    = qw(Exporter);
31
    @EXPORT = qw(
32
      &GetCourse
33
      &ModCourse
34
      &GetCourses
35
      &DelCourse
36
37
      &GetCourseInstructors
38
      &ModCourseInstructors
39
40
      &GetCourseItem
41
      &ModCourseItem
42
43
      &GetCourseReserve
44
      &ModCourseReserve
45
      &GetCourseReserves
46
      &DelCourseReserve
47
48
      &SearchCourses
49
50
      &GetItemReservesInfo
51
    );
52
53
    $DEBUG = 0;
54
    @FIELDS = ( 'itype', 'ccode', 'holdingbranch', 'location' );
55
}
56
57
=head1 NAME
58
59
Koha::CourseReserves - Koha course reserves module
60
61
=head1 SYNOPSIS
62
63
use Koha::CourseReserves;
64
65
=head1 DESCRIPTION
66
67
This module deals with course reserves.
68
69
=head1 FUNCTIONS
70
71
=head2 GetCourse
72
73
    $course = GetCourse( $course_id );
74
75
=cut
76
77
sub GetCourse {
78
    my ($course_id) = @_;
79
    warn whoami() . "( $course_id )" if $DEBUG;
80
81
    my $query = "SELECT * FROM courses WHERE course_id = ?";
82
    my $dbh   = C4::Context->dbh;
83
    my $sth   = $dbh->prepare($query);
84
    $sth->execute($course_id);
85
86
    my $course = $sth->fetchrow_hashref();
87
88
    $query = "
89
        SELECT b.* FROM course_instructors ci
90
        LEFT JOIN borrowers b ON ( ci.borrowernumber = b.borrowernumber )
91
        WHERE course_id =  ?
92
    ";
93
    $sth = $dbh->prepare($query);
94
    $sth->execute($course_id);
95
    $course->{'instructors'} = $sth->fetchall_arrayref( {} );
96
97
    return $course;
98
}
99
100
=head2 ModCourse
101
102
    ModCourse( [ course_id => $id ] [, course_name => $course_name ] [etc...] );
103
104
=cut
105
106
sub ModCourse {
107
    my (%params) = @_;
108
    warn identify_myself(%params) if $DEBUG;
109
110
    my $dbh = C4::Context->dbh;
111
112
    my $course_id;
113
    if ( defined $params{'course_id'} ) {
114
        $course_id = $params{'course_id'};
115
        delete $params{'course_id'};
116
    }
117
118
    my @query_keys;
119
    my @query_values;
120
121
    my $query;
122
123
    $query .= ($course_id) ? ' UPDATE ' : ' INSERT ';
124
    $query .= ' courses SET ';
125
126
    foreach my $key ( keys %params ) {
127
        push( @query_keys,   "$key=?" );
128
        push( @query_values, $params{$key} );
129
    }
130
    $query .= join( ',', @query_keys );
131
132
    if ($course_id) {
133
        $query .= " WHERE course_id = ?";
134
        push( @query_values, $course_id );
135
    }
136
137
    $dbh->do( $query, undef, @query_values );
138
139
    $course_id = $course_id
140
      || $dbh->last_insert_id( undef, undef, 'courses', 'course_id' );
141
142
    EnableOrDisableCourseItems(
143
        course_id => $course_id,
144
        enabled   => $params{'enabled'}
145
    );
146
147
    return $course_id;
148
}
149
150
=head2 GetCourses
151
152
  @courses = GetCourses( [ fieldname => $value ] [, fieldname2 => $value2 ] [etc...] );
153
154
=cut
155
156
sub GetCourses {
157
    my (%params) = @_;
158
    warn identify_myself(%params) if $DEBUG;
159
160
    my @query_keys;
161
    my @query_values;
162
163
    my $query = "
164
        SELECT courses.*
165
        FROM courses
166
        LEFT JOIN course_reserves ON course_reserves.course_id = courses.course_id
167
        LEFT JOIN course_items ON course_items.ci_id = course_reserves.ci_id
168
    ";
169
170
    if ( keys %params ) {
171
172
        $query .= " WHERE ";
173
174
        foreach my $key ( keys %params ) {
175
            push( @query_keys,   " $key LIKE ? " );
176
            push( @query_values, $params{$key} );
177
        }
178
179
        $query .= join( ' AND ', @query_keys );
180
    }
181
182
    $query .= " GROUP BY courses.course_id ";
183
184
    my $dbh = C4::Context->dbh;
185
    my $sth = $dbh->prepare($query);
186
    $sth->execute(@query_values);
187
188
    my $courses = $sth->fetchall_arrayref( {} );
189
190
    foreach my $c (@$courses) {
191
        $c->{'instructors'} = GetCourseInstructors( $c->{'course_id'} );
192
    }
193
194
    return $courses;
195
}
196
197
=head2 DelCourse
198
199
  DelCourse( $course_id );
200
201
=cut
202
203
sub DelCourse {
204
    my ($course_id) = @_;
205
206
    my $course_reserves = GetCourseReserves( course_id => $course_id );
207
208
    foreach my $res (@$course_reserves) {
209
        DelCourseReserve( cr_id => $res->{'cr_id'} );
210
    }
211
212
    my $query = "
213
        DELETE FROM courses
214
        WHERE course_id = ?
215
    ";
216
    C4::Context->dbh->do( $query, undef, $course_id );
217
}
218
219
=head2 EnableOrDisableCourseItems
220
221
  EnableOrDisableCourseItems( course_id => $course_id, enabled => $enabled );
222
223
  For each item on reserve for this course,
224
  if the course item has no active course reserves,
225
  swap the fields for the item to make it 'normal'
226
  again.
227
228
  enabled => 'yes' to enable course items
229
  enabled => 'no' to disable course items
230
231
=cut
232
233
sub EnableOrDisableCourseItems {
234
    my (%params) = @_;
235
    warn identify_myself(%params) if $DEBUG;
236
237
    my $course_id = $params{'course_id'};
238
    my $enabled   = $params{'enabled'};
239
240
    my $lookfor = ( $enabled eq 'yes' ) ? 'no' : 'yes';
241
242
    return unless ( $course_id && $enabled );
243
    return unless ( $enabled eq 'yes' || $enabled eq 'no' );
244
245
    my $course_reserves = GetCourseReserves( course_id => $course_id );
246
247
    if ( $enabled eq 'yes' ) {
248
        foreach my $course_reserve (@$course_reserves) {
249
            if (
250
                CountCourseReservesForItem(
251
                    ci_id   => $course_reserve->{'ci_id'},
252
                    enabled => 'yes'
253
                )
254
              )
255
            {
256
                EnableOrDisableCourseItem(
257
                    ci_id   => $course_reserve->{'ci_id'},
258
                    enabled => 'yes',
259
                );
260
            }
261
        }
262
    }
263
    if ( $enabled eq 'no' ) {
264
        foreach my $course_reserve (@$course_reserves) {
265
            unless (
266
                CountCourseReservesForItem(
267
                    ci_id   => $course_reserve->{'ci_id'},
268
                    enabled => 'yes'
269
                )
270
              )
271
            {
272
                EnableOrDisableCourseItem(
273
                    ci_id   => $course_reserve->{'ci_id'},
274
                    enabled => 'no',
275
                );
276
            }
277
        }
278
    }
279
}
280
281
=head2 EnableOrDisableCourseItem
282
283
    EnableOrDisableCourseItem( ci_id => $ci_id, enabled => $enabled );
284
285
    enabled => 'yes' to enable course items
286
    enabled => 'no' to disable course items
287
288
=cut
289
290
sub EnableOrDisableCourseItem {
291
    my (%params) = @_;
292
    warn identify_myself(%params) if $DEBUG;
293
294
    my $ci_id   = $params{'ci_id'};
295
    my $enabled = $params{'enabled'};
296
297
    return unless ( $ci_id && $enabled );
298
    return unless ( $enabled eq 'yes' || $enabled eq 'no' );
299
300
    my $course_item = GetCourseItem( ci_id => $ci_id );
301
302
    ## We don't want to 'enable' an already enabled item,
303
    ## or disable and already disabled item,
304
    ## as that would cause the fields to swap
305
    if ( $course_item->{'enabled'} ne $enabled ) {
306
        _SwapAllFields($ci_id);
307
308
        my $query = "
309
            UPDATE course_items
310
            SET enabled = ?
311
            WHERE ci_id = ?
312
        ";
313
314
        C4::Context->dbh->do( $query, undef, $enabled, $ci_id );
315
316
    }
317
318
}
319
320
=head2 GetCourseInstructors
321
322
    @borrowernumbers = GetCourseInstructors( $course_id );
323
324
=cut
325
326
sub GetCourseInstructors {
327
    my ($course_id) = @_;
328
    warn "Koha::CourseReserves::GetCourseInstructors( $course_id )"
329
      if $DEBUG;
330
331
    my $query = "
332
        SELECT * FROM borrowers
333
        RIGHT JOIN course_instructors ON ( course_instructors.borrowernumber = borrowers.borrowernumber )
334
        WHERE course_instructors.course_id = ?
335
    ";
336
337
    my $dbh = C4::Context->dbh;
338
    my $sth = $dbh->prepare($query);
339
    $sth->execute($course_id);
340
341
    return $sth->fetchall_arrayref( {} );
342
}
343
344
=head2 ModCourseInstructors
345
346
    ModCourseInstructors( mode => $mode, course_id => $course_id, [ cardnumbers => $cardnumbers ] OR [ borrowernumbers => $borrowernumbers  );
347
348
    $mode can be 'replace', 'add', or 'delete'
349
350
    $cardnumbers and $borrowernumbers are both references to arrays
351
352
    Use either cardnumbers or borrowernumber, but not both.
353
354
=cut
355
356
sub ModCourseInstructors {
357
    my (%params) = @_;
358
    warn identify_myself(%params) if $DEBUG;
359
360
    my $course_id       = $params{'course_id'};
361
    my $mode            = $params{'mode'};
362
    my $cardnumbers     = $params{'cardnumbers'};
363
    my $borrowernumbers = $params{'borrowernumbers'};
364
365
    return unless ($course_id);
366
    return
367
      unless ( $mode eq 'replace'
368
        || $mode eq 'add'
369
        || $mode eq 'delete' );
370
    return unless ( $cardnumbers || $borrowernumbers );
371
    return if ( $cardnumbers && $borrowernumbers );
372
373
    my @cardnumbers = @$cardnumbers if ( ref($cardnumbers) eq 'ARRAY' );
374
    my @borrowernumbers = @$borrowernumbers
375
      if ( ref($borrowernumbers) eq 'ARRAY' );
376
377
    my $field  = (@cardnumbers) ? 'cardnumber' : 'borrowernumber';
378
    my @fields = (@cardnumbers) ? @cardnumbers : @borrowernumbers;
379
    my $placeholders = join( ',', ('?') x scalar @fields );
380
381
    my $dbh = C4::Context->dbh;
382
383
    $dbh->do( "DELETE FROM course_instructors WHERE course_id = ?",
384
        undef, $course_id )
385
      if ( $mode eq 'replace' );
386
387
    my $query;
388
389
    if ( $mode eq 'add' || $mode eq 'replace' ) {
390
        $query = "
391
            INSERT INTO course_instructors ( course_id, borrowernumber )
392
            SELECT ?, borrowernumber
393
            FROM borrowers
394
            WHERE $field IN ( $placeholders )
395
        ";
396
    }
397
    else {
398
        $query = "
399
            DELETE FROM course_instructors
400
            WHERE course_id = ?
401
            AND borrowernumber IN (
402
                SELECT borrowernumber FROM borrowers WHERE $field IN ( $placeholders )
403
            )
404
        ";
405
    }
406
407
    my $sth = $dbh->prepare($query);
408
409
    $sth->execute( $course_id, @fields ) if (@fields);
410
}
411
412
=head2 GetCourseItem {
413
414
  $course_item = GetCourseItem( itemnumber => $itemnumber [, ci_id => $ci_id );
415
416
=cut
417
418
sub GetCourseItem {
419
    my (%params) = @_;
420
    warn identify_myself(%params) if $DEBUG;
421
422
    my $ci_id      = $params{'ci_id'};
423
    my $itemnumber = $params{'itemnumber'};
424
425
    return unless ( $itemnumber || $ci_id );
426
427
    my $field = ($itemnumber) ? 'itemnumber' : 'ci_id';
428
    my $value = ($itemnumber) ? $itemnumber  : $ci_id;
429
430
    my $query = "SELECT * FROM course_items WHERE $field = ?";
431
    my $dbh   = C4::Context->dbh;
432
    my $sth   = $dbh->prepare($query);
433
    $sth->execute($value);
434
435
    my $course_item = $sth->fetchrow_hashref();
436
437
    if ($course_item) {
438
        $query = "SELECT * FROM course_reserves WHERE ci_id = ?";
439
        $sth   = $dbh->prepare($query);
440
        $sth->execute( $course_item->{'ci_id'} );
441
        my $course_reserves = $sth->fetchall_arrayref( {} );
442
443
        $course_item->{'course_reserves'} = $course_reserves
444
          if ($course_reserves);
445
    }
446
    return $course_item;
447
}
448
449
=head2 ModCourseItem {
450
451
  ModCourseItem( %params );
452
453
  Creates or modifies an existing course item.
454
455
=cut
456
457
sub ModCourseItem {
458
    my (%params) = @_;
459
    warn identify_myself(%params) if $DEBUG;
460
461
    my $itemnumber    = $params{'itemnumber'};
462
    my $itype         = $params{'itype'};
463
    my $ccode         = $params{'ccode'};
464
    my $holdingbranch = $params{'holdingbranch'};
465
    my $location      = $params{'location'};
466
467
    return unless ($itemnumber);
468
469
    my $course_item = GetCourseItem( itemnumber => $itemnumber );
470
471
    my $ci_id;
472
473
    if ($course_item) {
474
        $ci_id = $course_item->{'ci_id'};
475
476
        _UpdateCourseItem(
477
            ci_id       => $ci_id,
478
            course_item => $course_item,
479
            %params
480
        );
481
    }
482
    else {
483
        $ci_id = _AddCourseItem(%params);
484
    }
485
486
    return $ci_id;
487
488
}
489
490
=head2 _AddCourseItem
491
492
    my $ci_id = _AddCourseItem( %params );
493
494
=cut
495
496
sub _AddCourseItem {
497
    my (%params) = @_;
498
    warn identify_myself(%params) if $DEBUG;
499
500
    my ( @fields, @values );
501
502
    push( @fields, 'itemnumber = ?' );
503
    push( @values, $params{'itemnumber'} );
504
505
    foreach (@FIELDS) {
506
        if ( $params{$_} ) {
507
            push( @fields, "$_ = ?" );
508
            push( @values, $params{$_} );
509
        }
510
    }
511
512
    my $query = "INSERT INTO course_items SET " . join( ',', @fields );
513
    my $dbh = C4::Context->dbh;
514
    $dbh->do( $query, undef, @values );
515
516
    my $ci_id = $dbh->last_insert_id( undef, undef, 'course_items', 'ci_id' );
517
518
    return $ci_id;
519
}
520
521
=head2 _UpdateCourseItem
522
523
  _UpdateCourseItem( %params );
524
525
=cut
526
527
sub _UpdateCourseItem {
528
    my (%params) = @_;
529
    warn identify_myself(%params) if $DEBUG;
530
531
    my $ci_id         = $params{'ci_id'};
532
    my $course_item   = $params{'course_item'};
533
    my $itype         = $params{'itype'};
534
    my $ccode         = $params{'ccode'};
535
    my $holdingbranch = $params{'holdingbranch'};
536
    my $location      = $params{'location'};
537
538
    return unless ( $ci_id || $course_item );
539
540
    $course_item = GetCourseItem( ci_id => $ci_id )
541
      unless ($course_item);
542
    $ci_id = $course_item->{'ci_id'} unless ($ci_id);
543
544
    ## Revert fields that had an 'original' value, but now don't
545
    ## Update the item fields to the stored values from course_items
546
    ## and then set those fields in course_items to NULL
547
    my @fields_to_revert;
548
    foreach (@FIELDS) {
549
        if ( !$params{$_} && $course_item->{$_} ) {
550
            push( @fields_to_revert, $_ );
551
        }
552
    }
553
    _RevertFields(
554
        ci_id       => $ci_id,
555
        fields      => \@fields_to_revert,
556
        course_item => $course_item
557
    ) if (@fields_to_revert);
558
559
    ## Update fields that still have an original value, but it has changed
560
    ## This necessitates only changing the current item values, as we still
561
    ## have the original values stored in course_items
562
    my %mod_params;
563
    foreach (@FIELDS) {
564
        if (   $params{$_}
565
            && $course_item->{$_}
566
            && $params{$_} ne $course_item->{$_} )
567
        {
568
            $mod_params{$_} = $params{$_};
569
        }
570
    }
571
    ModItem( \%mod_params, undef, $course_item->{'itemnumber'} );
572
573
    ## Update fields that didn't have an original value, but now do
574
    ## We must save the original value in course_items, and also
575
    ## update the item fields to the new value
576
    my $item = GetItem( $course_item->{'itemnumber'} );
577
    my %mod_params_new;
578
    my %mod_params_old;
579
    foreach (@FIELDS) {
580
        if ( $params{$_} && !$course_item->{$_} ) {
581
            $mod_params_new{$_} = $params{$_};
582
            $mod_params_old{$_} = $item->{$_};
583
        }
584
    }
585
    _ModStoredFields( 'ci_id' => $params{'ci_id'}, %mod_params_old );
586
    ModItem( \%mod_params_new, undef, $course_item->{'itemnumber'} );
587
588
}
589
590
=head2 _ModStoredFields
591
592
    _ModStoredFields( %params );
593
594
    Updates the values for the 'original' fields in course_items
595
    for a given ci_id
596
597
=cut
598
599
sub _ModStoredFields {
600
    my (%params) = @_;
601
    warn identify_myself(%params) if $DEBUG;
602
603
    return unless ( $params{'ci_id'} );
604
605
    my ( @fields_to_update, @values_to_update );
606
607
    foreach (@FIELDS) {
608
        if ( $params{$_} ) {
609
            push( @fields_to_update, $_ );
610
            push( @values_to_update, $params{$_} );
611
        }
612
    }
613
614
    my $query =
615
        "UPDATE course_items SET "
616
      . join( ',', map { "$_=?" } @fields_to_update )
617
      . " WHERE ci_id = ?";
618
619
    C4::Context->dbh->do( $query, undef, @values_to_update, $params{'ci_id'} )
620
      if (@values_to_update);
621
622
}
623
624
=head2 _RevertFields
625
626
    _RevertFields( ci_id => $ci_id, fields => \@fields_to_revert );
627
628
=cut
629
630
sub _RevertFields {
631
    my (%params) = @_;
632
    warn identify_myself(%params) if $DEBUG;
633
634
    my $ci_id       = $params{'ci_id'};
635
    my $course_item = $params{'course_item'};
636
    my $fields      = $params{'fields'};
637
    my @fields      = @$fields;
638
639
    return unless ($ci_id);
640
641
    $course_item = GetCourseItem( ci_id => $params{'ci_id'} )
642
      unless ($course_item);
643
644
    my $mod_item_params;
645
    my @fields_to_null;
646
    foreach my $field (@fields) {
647
        foreach (@FIELDS) {
648
            if ( $field eq $_ && $course_item->{$_} ) {
649
                $mod_item_params->{$_} = $course_item->{$_};
650
                push( @fields_to_null, $_ );
651
            }
652
        }
653
    }
654
    ModItem( $mod_item_params, undef, $course_item->{'itemnumber'} );
655
656
    my $query =
657
        "UPDATE course_items SET "
658
      . join( ',', map { "$_=NULL" } @fields_to_null )
659
      . " WHERE ci_id = ?";
660
661
    C4::Context->dbh->do( $query, undef, $ci_id ) if (@fields_to_null);
662
}
663
664
=head2 _SwapAllFields
665
666
    _SwapAllFields( $ci_id );
667
668
=cut
669
670
sub _SwapAllFields {
671
    my ($ci_id) = @_;
672
    warn "Koha::CourseReserves::_SwapFields( $ci_id )" if $DEBUG;
673
674
    my $course_item = GetCourseItem( ci_id => $ci_id );
675
    my $item = GetItem( $course_item->{'itemnumber'} );
676
677
    my %course_item_fields;
678
    my %item_fields;
679
    foreach (@FIELDS) {
680
        if ( $course_item->{$_} ) {
681
            $course_item_fields{$_} = $course_item->{$_};
682
            $item_fields{$_}        = $item->{$_};
683
        }
684
    }
685
686
    ModItem( \%course_item_fields, undef, $course_item->{'itemnumber'} );
687
    _ModStoredFields( %item_fields, ci_id => $ci_id );
688
}
689
690
=head2 GetCourseItems {
691
692
  $course_items = GetCourseItems(
693
      [course_id => $course_id]
694
      [, itemnumber => $itemnumber ]
695
  );
696
697
=cut
698
699
sub GetCourseItems {
700
    my (%params) = @_;
701
    warn identify_myself(%params) if $DEBUG;
702
703
    my $course_id  = $params{'course_id'};
704
    my $itemnumber = $params{'itemnumber'};
705
706
    return unless ($course_id);
707
708
    my @query_keys;
709
    my @query_values;
710
711
    my $query = "SELECT * FROM course_items";
712
713
    if ( keys %params ) {
714
715
        $query .= " WHERE ";
716
717
        foreach my $key ( keys %params ) {
718
            push( @query_keys,   " $key LIKE ? " );
719
            push( @query_values, $params{$key} );
720
        }
721
722
        $query .= join( ' AND ', @query_keys );
723
    }
724
725
    my $dbh = C4::Context->dbh;
726
    my $sth = $dbh->prepare($query);
727
    $sth->execute(@query_values);
728
729
    return $sth->fetchall_arrayref( {} );
730
}
731
732
=head2 DelCourseItem {
733
734
  DelCourseItem( ci_id => $cr_id );
735
736
=cut
737
738
sub DelCourseItem {
739
    my (%params) = @_;
740
    warn identify_myself(%params) if $DEBUG;
741
742
    my $ci_id = $params{'ci_id'};
743
744
    return unless ($ci_id);
745
746
    _RevertFields( ci_id => $ci_id, fields => \@FIELDS );
747
748
    my $query = "
749
        DELETE FROM course_items
750
        WHERE ci_id = ?
751
    ";
752
    C4::Context->dbh->do( $query, undef, $ci_id );
753
}
754
755
=head2 GetCourseReserve {
756
757
  $course_item = GetCourseReserve( %params );
758
759
=cut
760
761
sub GetCourseReserve {
762
    my (%params) = @_;
763
    warn identify_myself(%params) if $DEBUG;
764
765
    my $cr_id     = $params{'cr_id'};
766
    my $course_id = $params{'course_id'};
767
    my $ci_id     = $params{'ci_id'};
768
769
    return unless ( $cr_id || ( $course_id && $ci_id ) );
770
771
    my $dbh = C4::Context->dbh;
772
    my $sth;
773
774
    if ($cr_id) {
775
        my $query = "
776
            SELECT * FROM course_reserves
777
            WHERE cr_id = ?
778
        ";
779
        $sth = $dbh->prepare($query);
780
        $sth->execute($cr_id);
781
    }
782
    else {
783
        my $query = "
784
            SELECT * FROM course_reserves
785
            WHERE course_id = ? AND ci_id = ?
786
        ";
787
        $sth = $dbh->prepare($query);
788
        $sth->execute( $course_id, $ci_id );
789
    }
790
791
    my $course_reserve = $sth->fetchrow_hashref();
792
    return $course_reserve;
793
}
794
795
=head2 ModCourseReserve
796
797
    $id = ModCourseReserve( %params );
798
799
=cut
800
801
sub ModCourseReserve {
802
    my (%params) = @_;
803
    warn identify_myself(%params) if $DEBUG;
804
805
    my $course_id   = $params{'course_id'};
806
    my $ci_id       = $params{'ci_id'};
807
    my $staff_note  = $params{'staff_note'};
808
    my $public_note = $params{'public_note'};
809
810
    return unless ( $course_id && $ci_id );
811
812
    my $course_reserve =
813
      GetCourseReserve( course_id => $course_id, ci_id => $ci_id );
814
    my $cr_id;
815
816
    my $dbh = C4::Context->dbh;
817
818
    if ($course_reserve) {
819
        $cr_id = $course_reserve->{'cr_id'};
820
821
        my $query = "
822
            UPDATE course_reserves
823
            SET staff_note = ?, public_note = ?
824
            WHERE cr_id = ?
825
        ";
826
        $dbh->do( $query, undef, $staff_note, $public_note, $cr_id );
827
    }
828
    else {
829
        my $query = "
830
            INSERT INTO course_reserves SET
831
            course_id = ?,
832
            ci_id = ?,
833
            staff_note = ?,
834
            public_note = ?
835
        ";
836
        $dbh->do( $query, undef, $course_id, $ci_id, $staff_note,
837
            $public_note );
838
        $cr_id =
839
          $dbh->last_insert_id( undef, undef, 'course_reserves', 'cr_id' );
840
    }
841
842
    my $course = GetCourse($course_id);
843
    EnableOrDisableCourseItem(
844
        ci_id   => $params{'ci_id'},
845
        enabled => $course->{'enabled'}
846
    );
847
848
    return $cr_id;
849
}
850
851
=head2 GetCourseReserves {
852
853
  $course_reserves = GetCourseReserves( %params );
854
855
  Required:
856
      course_id OR ci_id
857
  Optional:
858
      include_items   => 1,
859
      include_count   => 1,
860
      include_courses => 1,
861
862
=cut
863
864
sub GetCourseReserves {
865
    my (%params) = @_;
866
    warn identify_myself(%params) if $DEBUG;
867
868
    my $course_id     = $params{'course_id'};
869
    my $ci_id         = $params{'ci_id'};
870
    my $include_items = $params{'include_items'};
871
    my $include_count = $params{'include_count'};
872
    my $include_courses = $params{'include_courses'};
873
874
    return unless ( $course_id || $ci_id );
875
876
    my $field = ($course_id) ? 'course_id' : 'ci_id';
877
    my $value = ($course_id) ? $course_id  : $ci_id;
878
879
    my $query = "
880
        SELECT cr.*, ci.itemnumber
881
        FROM course_reserves cr, course_items ci
882
        WHERE cr.$field = ?
883
        AND cr.ci_id = ci.ci_id
884
    ";
885
    my $dbh = C4::Context->dbh;
886
    my $sth = $dbh->prepare($query);
887
    $sth->execute($value);
888
889
    my $course_reserves = $sth->fetchall_arrayref( {} );
890
891
    if ($include_items) {
892
        foreach my $cr (@$course_reserves) {
893
            $cr->{'course_item'} = GetCourseItem( ci_id => $cr->{'ci_id'} );
894
            $cr->{'item'} = GetBiblioFromItemNumber( $cr->{'itemnumber'} );
895
            $cr->{'issue'} = GetOpenIssue( $cr->{'itemnumber'} );
896
        }
897
    }
898
899
    if ($include_count) {
900
        foreach my $cr (@$course_reserves) {
901
            $cr->{'reserves_count'} =
902
              CountCourseReservesForItem( ci_id => $cr->{'ci_id'} );
903
        }
904
    }
905
906
    if ($include_courses) {
907
        foreach my $cr (@$course_reserves) {
908
            $cr->{'courses'} =
909
              GetCourses( itemnumber => $cr->{'itemnumber'} );
910
        }
911
    }
912
913
    return $course_reserves;
914
}
915
916
=head2 DelCourseReserve {
917
918
  DelCourseReserve( cr_id => $cr_id );
919
920
=cut
921
922
sub DelCourseReserve {
923
    my (%params) = @_;
924
    warn identify_myself(%params) if $DEBUG;
925
926
    my $cr_id = $params{'cr_id'};
927
928
    return unless ($cr_id);
929
930
    my $dbh = C4::Context->dbh;
931
932
    my $course_reserve = GetCourseReserve( cr_id => $cr_id );
933
934
    my $query = "
935
        DELETE FROM course_reserves
936
        WHERE cr_id = ?
937
    ";
938
    $dbh->do( $query, undef, $cr_id );
939
940
    ## If there are no other course reserves for this item
941
    ## delete the course_item as well
942
    unless ( CountCourseReservesForItem( ci_id => $course_reserve->{'ci_id'} ) )
943
    {
944
        DelCourseItem( ci_id => $course_reserve->{'ci_id'} );
945
    }
946
947
}
948
949
=head2 GetReservesInfo
950
951
    my $arrayref = GetItemReservesInfo( itemnumber => $itemnumber );
952
953
    For a given item, returns an arrayref of reserves hashrefs,
954
    with a course hashref under the key 'course'
955
956
=cut
957
958
sub GetItemReservesInfo {
959
    my (%params) = @_;
960
    warn identify_myself(%params) if $DEBUG;
961
962
    my $itemnumber = $params{'itemnumber'};
963
964
    return unless ($itemnumber);
965
966
    my $course_item = GetCourseItem( itemnumber => $itemnumber );
967
968
    return unless ( keys %$course_item );
969
970
    my $course_reserves = GetCourseReserves( ci_id => $course_item->{'ci_id'} );
971
972
    foreach my $cr (@$course_reserves) {
973
        $cr->{'course'} = GetCourse( $cr->{'course_id'} );
974
    }
975
976
    return $course_reserves;
977
}
978
979
=head2 CountCourseReservesForItem
980
981
    $bool = CountCourseReservesForItem( %params );
982
983
    ci_id - course_item id
984
    OR
985
    itemnumber - course_item itemnumber
986
987
    enabled = 'yes' or 'no'
988
    Optional, if not supplied, counts reserves
989
    for both enabled and disabled courses
990
991
=cut
992
993
sub CountCourseReservesForItem {
994
    my (%params) = @_;
995
    warn identify_myself(%params) if $DEBUG;
996
997
    my $ci_id      = $params{'ci_id'};
998
    my $itemnumber = $params{'itemnumber'};
999
    my $enabled    = $params{'enabled'};
1000
1001
    return unless ( $ci_id || $itemnumber );
1002
1003
    my $course_item =
1004
      GetCourseItem( ci_id => $ci_id, itemnumber => $itemnumber );
1005
1006
    my @params = ( $course_item->{'ci_id'} );
1007
    push( @params, $enabled ) if ($enabled);
1008
1009
    my $query = "
1010
        SELECT COUNT(*) AS count
1011
        FROM course_reserves cr
1012
        LEFT JOIN courses c ON ( c.course_id = cr.course_id )
1013
        WHERE ci_id = ?
1014
    ";
1015
    $query .= "AND c.enabled = ?" if ($enabled);
1016
1017
    my $dbh = C4::Context->dbh;
1018
    my $sth = $dbh->prepare($query);
1019
    $sth->execute(@params);
1020
1021
    my $row = $sth->fetchrow_hashref();
1022
1023
    return $row->{'count'};
1024
}
1025
1026
=head2 SearchCourses
1027
1028
    my $courses = SearchCourses( term => $search_term, enabled => 'yes' );
1029
1030
=cut
1031
1032
sub SearchCourses {
1033
    my (%params) = @_;
1034
    warn identify_myself(%params) if $DEBUG;
1035
1036
    my $term = $params{'term'};
1037
1038
    my $enabled = $params{'enabled'} || '%';
1039
1040
    my @params;
1041
    my $query = "SELECT c.* FROM courses c";
1042
1043
    $query .= "
1044
        LEFT JOIN course_instructors ci
1045
            ON ( c.course_id = ci.course_id )
1046
        LEFT JOIN borrowers b
1047
            ON ( ci.borrowernumber = b.borrowernumber )
1048
        LEFT JOIN authorised_values av
1049
            ON ( c.department = av.authorised_value )
1050
        WHERE
1051
            ( av.category = 'DEPARTMENT' OR av.category = 'TERM' )
1052
            AND
1053
            (
1054
                department LIKE ? OR
1055
                course_number LIKE ? OR
1056
                section LIKE ? OR
1057
                course_name LIKE ? OR
1058
                term LIKE ? OR
1059
                public_note LIKE ? OR
1060
                CONCAT(surname,' ',firstname) LIKE ? OR
1061
                CONCAT(firstname,' ',surname) LIKE ? OR
1062
                lib LIKE ? OR
1063
                lib_opac LIKE ?
1064
           )
1065
           AND
1066
           c.enabled LIKE ?
1067
        GROUP BY c.course_id
1068
    ";
1069
1070
    $term   = "%$term%";
1071
    @params = ($term) x 10;
1072
1073
    $query .= " ORDER BY department, course_number, section, term, course_name ";
1074
1075
    my $dbh = C4::Context->dbh;
1076
    my $sth = $dbh->prepare($query);
1077
1078
    $sth->execute(@params, $enabled);
1079
1080
    my $courses = $sth->fetchall_arrayref( {} );
1081
1082
    foreach my $c (@$courses) {
1083
        $c->{'instructors'} = GetCourseInstructors( $c->{'course_id'} );
1084
    }
1085
1086
    return $courses;
1087
}
1088
1089
sub whoami  { ( caller(1) )[3] }
1090
sub whowasi { ( caller(2) )[3] }
1091
1092
sub stringify_params {
1093
    my (%params) = @_;
1094
1095
    my $string = "\n";
1096
1097
    foreach my $key ( keys %params ) {
1098
        $string .= "    $key => " . $params{$key} . "\n";
1099
    }
1100
1101
    return "( $string )";
1102
}
1103
1104
sub identify_myself {
1105
    my (%params) = @_;
1106
1107
    return whowasi() . stringify_params(%params);
1108
}
1109
1110
1;
1111
1112
=head1 AUTHOR
1113
1114
Kyle M Hall <kyle@bywatersolutions.com>
1115
1116
=cut
(-)a/Koha/Template/Plugin/AuthorisedValues.pm (+32 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::AuthorisedValues;
2
3
# Copyright ByWater Solutions 2012
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Template::Plugin;
23
use base qw( Template::Plugin );
24
25
use C4::Koha;
26
27
sub GetByCode {
28
    my ( $self, $category, $code, $opac ) = @_;
29
    return GetAuthorisedValueByCode( $category, $code, $opac );
30
}
31
32
1;
(-)a/Koha/Template/Plugin/Branches.pm (+37 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::Branches;
2
3
# Copyright ByWater Solutions 2012
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Template::Plugin;
23
use base qw( Template::Plugin );
24
25
use C4::Koha;
26
27
sub GetName {
28
    my ( $self, $branchcode ) = @_;
29
30
    my $query = "SELECT branchname FROM branches WHERE branchcode = ?";
31
    my $sth   = C4::Context->dbh->prepare($query);
32
    $sth->execute($branchcode);
33
    my $b = $sth->fetchrow_hashref();
34
    return $b->{'branchname'};
35
}
36
37
1;
(-)a/Koha/Template/Plugin/ItemTypes.pm (+38 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::ItemTypes;
2
3
# Copyright ByWater Solutions 2012
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Template::Plugin;
23
use base qw( Template::Plugin );
24
25
use C4::Koha;
26
27
sub GetDescription {
28
    my ( $self, $itemtype ) = @_;
29
30
    my $query = "SELECT description FROM itemtypes WHERE itemtype = ?";
31
    my $sth   = C4::Context->dbh->prepare($query);
32
    $sth->execute($itemtype);
33
    my $d = $sth->fetchrow_hashref();
34
    return $d->{'description'};
35
36
}
37
38
1;
(-)a/Makefile.PL (+1 lines)
Lines 261-266 my $target_map = { Link Here
261
  './changelanguage.pl'         => 'INTRANET_CGI_DIR',
261
  './changelanguage.pl'         => 'INTRANET_CGI_DIR',
262
  './check_sysprefs.pl'         => 'NONE',
262
  './check_sysprefs.pl'         => 'NONE',
263
  './circ'                      => 'INTRANET_CGI_DIR',
263
  './circ'                      => 'INTRANET_CGI_DIR',
264
  './course_reserves'           => 'INTRANET_CGI_DIR',
264
  './offline_circ'		=> 'INTRANET_CGI_DIR',
265
  './offline_circ'		=> 'INTRANET_CGI_DIR',
265
  './edithelp.pl'               => 'INTRANET_CGI_DIR',
266
  './edithelp.pl'               => 'INTRANET_CGI_DIR',
266
  './etc'                       => { target => 'KOHA_CONF_DIR', trimdir => -1 },
267
  './etc'                       => { target => 'KOHA_CONF_DIR', trimdir => -1 },
(-)a/catalogue/detail.pl (+6 lines)
Lines 40-45 use C4::VirtualShelves; Link Here
40
use C4::XSLT;
40
use C4::XSLT;
41
use C4::Images;
41
use C4::Images;
42
use Koha::DateUtils;
42
use Koha::DateUtils;
43
use Koha::CourseReserves;
43
44
44
# use Smart::Comments;
45
# use Smart::Comments;
45
46
Lines 264-269 foreach my $item (@items) { Link Here
264
    if ($item->{'materials'} ne ''){
265
    if ($item->{'materials'} ne ''){
265
	$materials_flag = 1;
266
	$materials_flag = 1;
266
    }
267
    }
268
269
    if ( C4::Context->preference('UseCourseReserves') ) {
270
        $item->{'course_reserves'} = GetItemReservesInfo( itemnumber => $item->{'itemnumber'} );
271
    }
272
267
    push @itemloop, $item;
273
    push @itemloop, $item;
268
}
274
}
269
275
(-)a/course_reserves/add_items.pl (+94 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#
4
# Copyright 2012 Bywater Solutions
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
use Modern::Perl;
22
23
use CGI;
24
25
use C4::Auth;
26
use C4::Output;
27
use C4::Koha;
28
use C4::Biblio;
29
use C4::Branch;
30
31
use Koha::CourseReserves;
32
33
my $cgi = new CGI;
34
35
my $action    = $cgi->param('action')    || '';
36
my $course_id = $cgi->param('course_id') || '';
37
my $barcode   = $cgi->param('barcode')   || '';
38
39
die('No course_id provided') unless ($course_id);
40
41
my $item = GetBiblioFromItemNumber( undef, $barcode );
42
43
my $step = ( $action eq 'lookup' && $item ) ? '2' : '1';
44
45
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46
    {
47
        template_name   => "course_reserves/add_items-step$step.tmpl",
48
        query           => $cgi,
49
        type            => "intranet",
50
        authnotrequired => 0,
51
        flagsrequired   => { coursereserves => 'add_reserves' },
52
    }
53
);
54
$template->param( ERROR_BARCODE_NOT_FOUND => $barcode ) unless ( $barcode && $item && $action eq 'lookup' );
55
56
$template->param( course => GetCourse($course_id) );
57
58
if ( $action eq 'lookup' ) {
59
    my $course_item = GetCourseItem( itemnumber => $item->{'itemnumber'} );
60
    my $course_reserve = GetCourseReserve(
61
        course_id => $course_id,
62
        ci_id     => $course_item->{'ci_id'}
63
    ) if ($course_item);
64
65
    $template->param(
66
        item           => $item,
67
        course_item    => $course_item,
68
        course_reserve => $course_reserve,
69
70
        ccodes    => GetAuthorisedValues('CCODE'),
71
        locations => GetAuthorisedValues('LOC'),
72
        itypes    => GetItemTypesFlat(),
73
        branches  => GetBranchesLoop(),
74
    );
75
76
}
77
elsif ( $action eq 'add' ) {
78
    my $ci_id = ModCourseItem(
79
        itemnumber    => $cgi->param('itemnumber'),
80
        itype         => $cgi->param('itype'),
81
        ccode         => $cgi->param('ccode'),
82
        holdingbranch => $cgi->param('holdingbranch'),
83
        location      => $cgi->param('location'),
84
    );
85
86
    my $cr_id = ModCourseReserve(
87
        course_id   => $course_id,
88
        ci_id       => $ci_id,
89
        staff_note  => $cgi->param('staff_note'),
90
        public_note => $cgi->param('public_note'),
91
    );
92
}
93
94
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/course_reserves/course-details.pl (+67 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#
4
# Copyright 2012 Bywater Solutions
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
use Modern::Perl;
22
23
use CGI;
24
25
use C4::Auth;
26
use C4::Output;
27
use C4::Koha;
28
29
use Koha::CourseReserves;
30
31
my $cgi = new CGI;
32
33
my $action = $cgi->param('action') || '';
34
my $course_id = $cgi->param('course_id');
35
36
my $flagsrequired;
37
$flagsrequired->{coursereserves} = 'delete_reserves' if ( $action eq 'del_reserve' );
38
39
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
40
    {
41
        template_name   => "course_reserves/course-details.tmpl",
42
        query           => $cgi,
43
        type            => "intranet",
44
        authnotrequired => 0,
45
        flagsrequired   => $flagsrequired,
46
    }
47
);
48
49
die("No course_id given") unless ($course_id);
50
51
if ( $action eq 'del_reserve' ) {
52
    DelCourseReserve( cr_id => $cgi->param('cr_id') );
53
}
54
55
my $course          = GetCourse($course_id);
56
my $course_reserves = GetCourseReserves(
57
    course_id       => $course_id,
58
    include_items   => 1,
59
    include_courses => 1
60
);
61
62
$template->param(
63
    course          => $course,
64
    course_reserves => $course_reserves,
65
);
66
67
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/course_reserves/course-reserves.pl (+54 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#
4
# Copyright 2012 Bywater Solutions
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
use Modern::Perl;
22
23
use CGI;
24
25
use C4::Auth;
26
use C4::Output;
27
28
use Koha::CourseReserves;
29
30
my $cgi = new CGI;
31
32
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
33
    {
34
        template_name   => "course_reserves/course-reserves.tmpl",
35
        query           => $cgi,
36
        type            => "intranet",
37
        authnotrequired => 0,
38
        flagsrequired   => {},
39
    }
40
);
41
42
my $search_on = $cgi->param('search_on');
43
my %params;
44
if ($search_on) {
45
    $params{'course_name'} = "%$search_on%";
46
}
47
48
my $courses = GetCourses(%params);
49
if ( $search_on && @$courses == 1 ) {
50
    print $cgi->redirect("/cgi-bin/koha/course_reserves/course-details.pl?course_id=" . $courses->[0]->{'course_id'});
51
} else {
52
    $template->param( courses => $courses );
53
    output_html_with_http_headers $cgi, $cookie, $template->output;
54
}
(-)a/course_reserves/course.pl (+57 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#
4
# Copyright 2012 Bywater Solutions
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
use Modern::Perl;
22
23
use CGI;
24
25
use C4::Auth;
26
use C4::Output;
27
use C4::Koha;
28
29
use Koha::CourseReserves;
30
31
my $cgi = new CGI;
32
33
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
34
    {
35
        template_name   => "course_reserves/course.tmpl",
36
        query           => $cgi,
37
        type            => "intranet",
38
        authnotrequired => 0,
39
        flagsrequired   => { coursereserves => 'manage_courses' },
40
    }
41
);
42
43
my $course_id = $cgi->param('course_id');
44
45
if ($course_id) {
46
    my $course = GetCourse($course_id);
47
    $template->param(%$course);
48
}
49
50
$template->param(
51
    departments => GetAuthorisedValues('DEPARTMENT')
52
    ,    ## TODO: use syspref instead of hard coded value.
53
    terms => GetAuthorisedValues('TERM')
54
    ,    ## TODO: use syspref instead of hard coded value.
55
);
56
57
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/course_reserves/mod_course.pl (+76 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#script to modify reserves/requests
4
#written 2/1/00 by chris@katipo.oc.nz
5
#last update 27/1/2000 by chris@katipo.co.nz
6
7
# Copyright 2000-2002 Katipo Communications
8
#
9
# This file is part of Koha.
10
#
11
# Koha is free software; you can redistribute it and/or modify it under the
12
# terms of the GNU General Public License as published by the Free Software
13
# Foundation; either version 2 of the License, or (at your option) any later
14
# version.
15
#
16
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License along
21
# with Koha; if not, write to the Free Software Foundation, Inc.,
22
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24
use Modern::Perl;
25
26
use CGI;
27
28
use C4::Output;
29
use C4::Reserves;
30
use C4::Auth;
31
32
use Koha::CourseReserves;
33
34
my $cgi = new CGI;
35
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
36
    {
37
        template_name   => "about.tmpl",
38
        query           => $cgi,
39
        type            => "intranet",
40
        authnotrequired => 0,
41
        flagsrequired   => { coursereserves => 'manage_courses' },
42
    }
43
);
44
45
my $action = $cgi->param('action');
46
47
if ( $action eq 'del' ) {
48
    DelCourse( $cgi->param('course_id') );
49
    print $cgi->redirect("/cgi-bin/koha/course_reserves/course-reserves.pl");
50
}
51
else {
52
    my %params;
53
54
    $params{'course_id'} = $cgi->param('course_id')
55
      if ( $cgi->param('course_id') );
56
    $params{'department'}     = $cgi->param('department');
57
    $params{'course_number'}  = $cgi->param('course_number');
58
    $params{'section'}        = $cgi->param('section');
59
    $params{'course_name'}    = $cgi->param('course_name');
60
    $params{'term'}           = $cgi->param('term');
61
    $params{'staff_note'}     = $cgi->param('staff_note');
62
    $params{'public_note'}    = $cgi->param('public_note');
63
    $params{'students_count'} = $cgi->param('students_count');
64
    $params{'enabled'} = ( $cgi->param('enabled') eq 'on' ) ? 'yes' : 'no';
65
66
    my $course_id = ModCourse(%params);
67
68
    my @instructors = $cgi->param('instructors');
69
    ModCourseInstructors(
70
        mode        => 'replace',
71
        cardnumbers => \@instructors,
72
        course_id   => $course_id
73
    );
74
    print $cgi->redirect(
75
        "/cgi-bin/koha/course_reserves/course-details.pl?course_id=$course_id");
76
}
(-)a/installer/data/mysql/en/mandatory/userflags.sql (+1 lines)
Lines 15-17 INSERT INTO `userflags` VALUES(14,'editauthorities','Allow to edit authorities', Link Here
15
INSERT INTO `userflags` VALUES(15,'serials','Allow to manage serials subscriptions',0);
15
INSERT INTO `userflags` VALUES(15,'serials','Allow to manage serials subscriptions',0);
16
INSERT INTO `userflags` VALUES(16,'reports','Allow to access to the reports module',0);
16
INSERT INTO `userflags` VALUES(16,'reports','Allow to access to the reports module',0);
17
INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0);
17
INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0);
18
INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0);
(-)a/installer/data/mysql/en/mandatory/userpermissions.sql (-1 / +4 lines)
Lines 51-55 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
51
   (15, 'renew_subscription', 'Renew a subscription'),
51
   (15, 'renew_subscription', 'Renew a subscription'),
52
   (15, 'routing', 'Routing'),
52
   (15, 'routing', 'Routing'),
53
   (16, 'execute_reports', 'Execute SQL reports'),
53
   (16, 'execute_reports', 'Execute SQL reports'),
54
   (16, 'create_reports', 'Create SQL Reports')
54
   (16, 'create_reports', 'Create SQL Reports'),
55
   (18, 'manage_courses', 'Add, edit and delete courses'),
56
   (18, 'add_reserves', 'Add course reserves'),
57
   (18, 'delete_reserves', 'Remove course reserves')
55
;
58
;
(-)a/installer/data/mysql/kohastructure.sql (+63 lines)
Lines 466-471 CREATE TABLE collections_tracking ( Link Here
466
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
466
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
467
467
468
--
468
--
469
-- Table structure for table `courses`
470
--
471
DROP TABLE IF EXISTS courses;
472
CREATE TABLE `courses` (
473
  `course_id` int(11) NOT NULL AUTO_INCREMENT,
474
  `department` varchar(20) DEFAULT NULL,
475
  `course_number` varchar(255) DEFAULT NULL,
476
  `section` varchar(255) DEFAULT NULL,
477
  `course_name` varchar(255) DEFAULT NULL,
478
  `term` varchar(20) DEFAULT NULL,
479
  `staff_note` mediumtext,
480
  `public_note` mediumtext,
481
  `students_count` varchar(20) DEFAULT NULL,
482
  `enabled` enum('yes','no') NOT NULL DEFAULT 'yes',
483
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
484
   PRIMARY KEY (`course_id`)
485
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
486
487
--
488
-- Table structure for table `course_instructors`
489
--
490
DROP TABLE IF EXISTS course_instructors;
491
CREATE TABLE `course_instructors` (
492
  `course_id` int(11) NOT NULL,
493
  `borrowernumber` int(11) NOT NULL,
494
  PRIMARY KEY (`course_id`,`borrowernumber`),
495
  KEY `borrowernumber` (`borrowernumber`)
496
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
497
498
--
499
-- Table structure for table `course_items`
500
--
501
DROP TABLE IF EXISTS course_items;
502
CREATE TABLE `course_items` (
503
  `ci_id` int(11) NOT NULL AUTO_INCREMENT,
504
  `itemnumber` int(11) NOT NULL,
505
  `itype` varchar(10) DEFAULT NULL,
506
  `ccode` varchar(10) DEFAULT NULL,
507
  `holdingbranch` varchar(10) DEFAULT NULL,
508
  `location` varchar(80) DEFAULT NULL,
509
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no',
510
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
511
   PRIMARY KEY (`ci_id`),
512
   UNIQUE KEY `itemnumber` (`itemnumber`)
513
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
514
515
--
516
-- Table structure for table `course_reserves`
517
--
518
DROP TABLE IF EXISTS course_reserves;
519
CREATE TABLE `course_reserves` (
520
  `cr_id` int(11) NOT NULL AUTO_INCREMENT,
521
  `course_id` int(11) NOT NULL,
522
  `ci_id` int(11) NOT NULL,
523
  `staff_note` mediumtext,
524
  `public_note` mediumtext,
525
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
526
   PRIMARY KEY (`cr_id`),
527
   UNIQUE KEY `psuedo_key` (`course_id`,`ci_id`),
528
   KEY `course_id` (`course_id`)
529
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
530
531
--
469
-- Table structure for table `borrower_branch_circ_rules`
532
-- Table structure for table `borrower_branch_circ_rules`
470
--
533
--
471
534
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 371-373 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' Link Here
371
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToUseWhenPrefill','','Define a list of subfields to use when prefilling items (separated by space)','','Free');
371
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToUseWhenPrefill','','Define a list of subfields to use when prefilling items (separated by space)','','Free');
372
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free');
372
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free');
373
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo');
373
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo');
374
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo');
(-)a/installer/data/mysql/updatedatabase.pl (+72 lines)
Lines 5681-5686 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5681
    "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToUseWhenPrefill','','Define a list of subfields to use when prefilling items (separated by space)','','Free');
5681
    "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToUseWhenPrefill','','Define a list of subfields to use when prefilling items (separated by space)','','Free');
5682
    ");
5682
    ");
5683
    print "Upgrade to $DBversion done (Adding PrefillItem and SubfieldsToUseWhenPrefill sysprefs)\n";
5683
    print "Upgrade to $DBversion done (Adding PrefillItem and SubfieldsToUseWhenPrefill sysprefs)\n";
5684
    SetVersion($DBversion);
5684
}
5685
}
5685
5686
5686
$DBversion = "3.09.00.036";
5687
$DBversion = "3.09.00.036";
Lines 5696-5701 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5696
    SetVersion($DBversion);
5697
    SetVersion($DBversion);
5697
}
5698
}
5698
5699
5700
$DBversion = "3.09.00.XXX";
5701
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5702
    $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('UseCourseReserves', '0', NULL, 'Enable the course reserves feature.', 'YesNo')");
5703
    $dbh->do("INSERT INTO userflags (bit,flag,flagdesc,defaulton) VALUES ('18','coursereserves','Course Reserves','0')");
5704
    $dbh->do("
5705
CREATE TABLE `courses` (
5706
  `course_id` int(11) NOT NULL AUTO_INCREMENT,
5707
  `department` varchar(20) DEFAULT NULL,
5708
  `course_number` varchar(255) DEFAULT NULL,
5709
  `section` varchar(255) DEFAULT NULL,
5710
  `course_name` varchar(255) DEFAULT NULL,
5711
  `term` varchar(20) DEFAULT NULL,
5712
  `staff_note` mediumtext,
5713
  `public_note` mediumtext,
5714
  `students_count` varchar(20) DEFAULT NULL,
5715
  `enabled` enum('yes','no') NOT NULL DEFAULT 'yes',
5716
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
5717
   PRIMARY KEY (`course_id`)
5718
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
5719
");
5720
5721
$dbh->do("
5722
CREATE TABLE `course_instructors` (
5723
  `course_id` int(11) NOT NULL,
5724
  `borrowernumber` int(11) NOT NULL,
5725
  PRIMARY KEY (`course_id`,`borrowernumber`),
5726
  KEY `borrowernumber` (`borrowernumber`)
5727
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5728
");
5729
5730
$dbh->do("
5731
CREATE TABLE `course_items` (
5732
  `ci_id` int(11) NOT NULL AUTO_INCREMENT,
5733
  `itemnumber` int(11) NOT NULL,
5734
  `itype` varchar(10) DEFAULT NULL,
5735
  `ccode` varchar(10) DEFAULT NULL,
5736
  `holdingbranch` varchar(10) DEFAULT NULL,
5737
  `location` varchar(80) DEFAULT NULL,
5738
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no',
5739
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
5740
   PRIMARY KEY (`ci_id`),
5741
   UNIQUE KEY `itemnumber` (`itemnumber`)
5742
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
5743
");
5744
5745
$dbh->do("
5746
CREATE TABLE `course_reserves` (
5747
  `cr_id` int(11) NOT NULL AUTO_INCREMENT,
5748
  `course_id` int(11) NOT NULL,
5749
  `ci_id` int(11) NOT NULL,
5750
  `staff_note` mediumtext,
5751
  `public_note` mediumtext,
5752
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
5753
   PRIMARY KEY (`cr_id`),
5754
   UNIQUE KEY `psuedo_key` (`course_id`,`ci_id`),
5755
   KEY `course_id` (`course_id`)
5756
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
5757
");
5758
5759
$dbh->do("
5760
INSERT INTO permissions (module_bit, code, description) VALUES
5761
  (18, 'manage_courses', 'Add, edit and delete courses'),
5762
  (18, 'add_reserves', 'Add course reserves'),
5763
  (18, 'delete_reserves', 'Remove course reserves')
5764
;
5765
");
5766
5767
    print "Upgrade to $DBversion done (Add Course Reserves ( system preference UseCourseReserves ))\n";
5768
    SetVersion($DBversion);
5769
}
5770
5699
=head1 FUNCTIONS
5771
=head1 FUNCTIONS
5700
5772
5701
=head2 TableExists($table)
5773
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css (-1 / +1 lines)
Lines 814-820 fieldset.rows .inputnote { Link Here
814
    visibility:visible; /* you propably don't need to change this one */
814
    visibility:visible; /* you propably don't need to change this one */
815
    display:block;
815
    display:block;
816
}
816
}
817
#newbiblio a, #addchild a, #newentry a, #newshelf a, #newmenuc .first-child, #newsupplier .first-child, #newlabel a, #newtemplate a, #newlabelbatch a, #newpatroncardbatch a, #newprofile a, #newsubscription a, #newdictionary a, #newbasket a, #newrootbudget-button, #budgets_menuc .first-child {
817
#new_course a, #newbiblio a, #addchild a, #newentry a, #newshelf a, #newmenuc .first-child, #newsupplier .first-child, #newlabel a, #newtemplate a, #newlabelbatch a, #newpatroncardbatch a, #newprofile a, #newsubscription a, #newdictionary a, #newbasket a, #newrootbudget-button, #budgets_menuc .first-child {
818
	padding-left : 34px;
818
	padding-left : 34px;
819
	background-image: url("../../img/toolbar-new.gif");
819
	background-image: url("../../img/toolbar-new.gif");
820
	background-position : center left;
820
	background-position : center left;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (+3 lines)
Lines 28-33 Link Here
28
                            [% IF ( CAN_user_serials ) %]
28
                            [% IF ( CAN_user_serials ) %]
29
                            <li><a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a></li>
29
                            <li><a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a></li>
30
                            [% END %]
30
                            [% END %]
31
                            [% IF ( CAN_user_coursereserves ) %]
32
                            <li><a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course Reserves</a></li>
33
                            [% END %]
31
                            [% IF ( CAN_user_reports ) %]
34
                            [% IF ( CAN_user_reports ) %]
32
                            <li><a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a></li>
35
                            <li><a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a></li>
33
                            [% END %]
36
                            [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mainmenu.inc (+3 lines)
Lines 51-56 Link Here
51
    [% IF ( CAN_user_serials ) %]
51
    [% IF ( CAN_user_serials ) %]
52
        <li><a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a></li>
52
        <li><a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a></li>
53
    [% END %]
53
    [% END %]
54
    [% IF ( CAN_user_coursereserves ) %]
55
        <li><a href="/cgi-bin/koha/course_reserves/course_reserves.pl">Course Reserves</a></li>
56
    [% END %]
54
    [% IF ( CAN_user_editcatalogue ) %]
57
    [% IF ( CAN_user_editcatalogue ) %]
55
    </ul></li>
58
    </ul></li>
56
    
59
    
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js (-19 / +10 lines)
Lines 5-15 function _(s) { return s } // dummy function for gettext Link Here
5
5
6
 $(document).ready(function() {
6
 $(document).ready(function() {
7
    $('#header_search').tabs().bind('tabsshow', function(e, ui) { $('#header_search > div:not(.ui-tabs-hide)').find('input').eq(0).focus(); });
7
    $('#header_search').tabs().bind('tabsshow', function(e, ui) { $('#header_search > div:not(.ui-tabs-hide)').find('input').eq(0).focus(); });
8
	$(".close").click(function(){ window.close(); });
8
9
    $(".close").click(function(){ window.close(); });
10
9
    if($("#header_search #checkin_search").length > 0){ $(document).bind('keydown','Alt+r',function (){ $("#header_search").tabs("select","#checkin_search"); $("#ret_barcode").focus(); }); } else { $(document).bind('keydown','Alt+r',function (){ location.href="/cgi-bin/koha/circ/returns.pl"; }); }
11
    if($("#header_search #checkin_search").length > 0){ $(document).bind('keydown','Alt+r',function (){ $("#header_search").tabs("select","#checkin_search"); $("#ret_barcode").focus(); }); } else { $(document).bind('keydown','Alt+r',function (){ location.href="/cgi-bin/koha/circ/returns.pl"; }); }
10
    if($("#header_search #circ_search").length > 0){ $(document).bind('keydown','Alt+u',function (){ $("#header_search").tabs("select","#circ_search"); $("#findborrower").focus(); }); } else { $(document).bind('keydown','Alt+u',function(){ location.href="/cgi-bin/koha/circ/circulation.pl"; }); }
12
    if($("#header_search #circ_search").length > 0){ $(document).bind('keydown','Alt+u',function (){ $("#header_search").tabs("select","#circ_search"); $("#findborrower").focus(); }); } else { $(document).bind('keydown','Alt+u',function(){ location.href="/cgi-bin/koha/circ/circulation.pl"; }); }
11
    if($("#header_search #catalog_search").length > 0){ $(document).bind('keydown','Alt+q',function (){ $("#header_search").tabs("select","#catalog_search"); $("#search-form").focus(); }); } else { $(document).bind('keydown','Alt+q',function(){ location.href="/cgi-bin/koha/catalogue/search.pl"; }); }
13
    if($("#header_search #catalog_search").length > 0){ $(document).bind('keydown','Alt+q',function (){ $("#header_search").tabs("select","#catalog_search"); $("#search-form").focus(); }); } else { $(document).bind('keydown','Alt+q',function(){ location.href="/cgi-bin/koha/catalogue/search.pl"; }); }
14
12
    $(".focus").focus();
15
    $(".focus").focus();
16
17
    $('.noEnterSubmit').keypress(function(e){
18
        if ( e.which == 13 ) return false;
19
        //if ( e.which == 13 ) e.preventDefault();
20
    });
21
13
 });
22
 });
14
23
15
 
24
 
Lines 73-96 YAHOO.util.Event.onContentReady("changelanguage", function () { Link Here
73
	});
82
	});
74
});
83
});
75
			
84
			
76
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html
77
function checkEnter(e){ //e is event object passed from function invocation
78
	var characterCode; // literal character code will be stored in this variable
79
	if(e && e.which){ //if which property of event object is supported (NN4)
80
		e = e;
81
		characterCode = e.which; //character code is contained in NN4's which property
82
	} else {
83
		e = event;
84
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
85
	}
86
87
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
88
		return false;
89
	} else {
90
		return true;
91
	}
92
}
93
94
function clearHoldFor(){
85
function clearHoldFor(){
95
	$.cookie("holdfor",null, { path: "/", expires: 0 });
86
	$.cookie("holdfor",null, { path: "/", expires: 0 });
96
}
87
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+7 lines)
Lines 448-450 Circulation: Link Here
448
            - and this password
448
            - and this password
449
            - pref: AutoSelfCheckPass
449
            - pref: AutoSelfCheckPass
450
            - .
450
            - .
451
    Course Reserves:
452
        -
453
            - pref: UseCourseReserves
454
              choices:
455
                  yes: Use
456
                  no: "Don't use"
457
            - course reserves
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (+34 lines)
Lines 1-3 Link Here
1
[% USE AuthorisedValues %]
2
3
[% ShowCourseReserves = 0 %]
4
[% IF UseCourseReserves %]
5
    [% FOREACH item IN itemloop %]
6
       [% IF item.course_reserves %]
7
           [% FOREACH r IN item.course_reserves %]
8
               [% IF r.course.enabled == 'yes' %]
9
                   [% ShowCourseReserves = 1 %]
10
               [% END %]
11
           [% END %]
12
        [% END %]
13
    [% END %]
14
[% END %]
15
1
[% INCLUDE 'doc-head-open.inc' %]
16
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Catalog &rsaquo;
17
<title>Koha &rsaquo; Catalog &rsaquo;
3
  [% IF ( unknownbiblionumber ) %]
18
  [% IF ( unknownbiblionumber ) %]
Lines 284-289 function verify_images() { Link Here
284
        [% IF ( SpineLabelShowPrintOnBibDetails ) %]<th>Spine label</th>[% END %]
299
        [% IF ( SpineLabelShowPrintOnBibDetails ) %]<th>Spine label</th>[% END %]
285
        [% IF ( hostrecords ) %]<th>Host records</th>[% END %]
300
        [% IF ( hostrecords ) %]<th>Host records</th>[% END %]
286
		[% IF ( analyze ) %]<th>Used in</th><th></th>[% END %]
301
		[% IF ( analyze ) %]<th>Used in</th><th></th>[% END %]
302
                [% IF ( ShowCourseReserves ) %]<th>Course Reserves</th>[% END %]
287
            </tr>
303
            </tr>
288
            [% FOREACH itemloo IN itemloop %]
304
            [% FOREACH itemloo IN itemloop %]
289
                <tr>
305
                <tr>
Lines 420-425 function verify_images() { Link Here
420
                        <td><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?hostbiblionumber=[% itemloo.biblionumber %]&amp;hostitemnumber=[% itemloo.itemnumber %]">Create analytics</a></td>
436
                        <td><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?hostbiblionumber=[% itemloo.biblionumber %]&amp;hostitemnumber=[% itemloo.itemnumber %]">Create analytics</a></td>
421
                [% END %]
437
                [% END %]
422
438
439
                [% IF ShowCourseReserves %]
440
                    <td>
441
                        [% IF itemloo.course_reserves %]
442
                            [% FOREACH r IN itemloo.course_reserves %]
443
                                [% IF r.course.enabled == 'yes' %]
444
                                    <p>
445
                                      <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% r.course.course_id %]">
446
                                         [% r.course.course_name %]
447
                                         <!--[% IF r.course.course_number %] [% r.course.course_number %] [% END %]-->
448
                                         [% IF r.course.section %] [% r.course.section %] [% END %]
449
                                         [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) %] [% END %]
450
                                      </a>
451
                                   </p>
452
                               [% END %]
453
                           [% END %]
454
                       [% END %]
455
                    </td>
456
                [% END %]
423
                </tr>
457
                </tr>
424
            [% END %]
458
            [% END %]
425
        </table>
459
        </table>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-1 / +1 lines)
Lines 9-15 $(document).ready(function(){ Link Here
9
            window.close();
9
            window.close();
10
        [% END %]
10
        [% END %]
11
    [% END %]
11
    [% END %]
12
		$("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
12
		$("fieldset.rows input").addClass("noEnterSubmit");
13
		/* Inline edit/delete links */
13
		/* Inline edit/delete links */
14
		var biblionumber = $("input[name='biblionumber']").attr("value");
14
		var biblionumber = $("input[name='biblionumber']").attr("value");
15
		$("td").click(function(event){
15
		$("td").click(function(event){
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step1.tt (+63 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Course Reserves &rsaquo; Add Items</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
6
<script type="text/javascript">
7
//<![CDATA[
8
9
$(document).ready(function() {
10
  $('#barcode').focus();
11
});
12
13
//]]>
14
</script>
15
16
<body>
17
18
[% INCLUDE 'header.inc' %]
19
[% INCLUDE 'cat-search.inc' %]
20
21
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course Reserves</a> &rsaquo; Add Reserves for <i><a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% course.course_id %]">[% course.course_name %]</a></i></div>
22
23
<div id="doc2" class="yui-t7">
24
    <div id="bd">
25
        <div id="yui-main">
26
            <div class="yui-b">
27
                <div class="yui-g">
28
                    <div class="yui-u first">
29
                        [% IF ERROR_BARCODE_NOT_FOUND %]
30
                            <div class="error">No item found for barcode [% ERROR_BARCODE_NOT_FOUND %]</div>
31
                        [% END %]
32
33
                        <form method="post" action="/cgi-bin/koha/course_reserves/add_items.pl">
34
                            <input type="hidden" name="course_id" value="[% course.course_id %]" />
35
                            <input type="hidden" name="action" value="lookup" />
36
37
                            <fieldset class="rows">
38
                                <legend>Add Items: Scan Barcode</legend>
39
40
                                    <p>
41
42
                                    <li>
43
                                        <label class="required" for="barcode">Item Barcode:</label>
44
                                        <input id="barcode" name="barcode" type="text" />
45
                                    </li>
46
                                </ol>
47
                            </fieldset>
48
49
                            <fieldset class="action">
50
                                <input type="submit" value="Submit" class="submit" />
51
52
                                <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% course.course_id %]" class="cancel">Cancel</a>
53
                            </fieldset>
54
                        </form>
55
                    </div>
56
                </div>
57
            </div>
58
        </div>
59
    </div>
60
</div>
61
62
63
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt (+131 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Course Reserves &rsaquo; Add Items</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
5
<script type="text/javascript">
6
//<![CDATA[
7
$(document).ready(function() {
8
  $('#submit').focus();
9
});
10
//]]>
11
</script>
12
13
</head>
14
15
<body>
16
17
[% INCLUDE 'header.inc' %]
18
[% INCLUDE 'cat-search.inc' %]
19
20
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course Reserves</a> &rsaquo; Reserve <i><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item.biblionumber %]">[% item.title %]</a></i> for <i><a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% course.course_id %]">[% course.course_name %]</a></i></div>
21
22
<div id="doc2" class="yui-t7">
23
    <div id="bd">
24
        <div id="yui-main">
25
            <div class="yui-b">
26
                <div class="yui-g">
27
                    <div class="yui-u first">
28
                        [% IF course_reserve %]<div class="warn" id="already_on_reserve_this">This course already has this item on reserve.<div>[% END %]
29
                        [% IF course_item    %]<div class="warn" id="already_on_reserve">Number of courses reserving this item: [% course_item.course_reserves.size %]<div>[% END %]
30
31
                        <form method="post" action="/cgi-bin/koha/course_reserves/add_items.pl">
32
                            <input type="hidden" name="course_id" value="[% course.course_id %]" />
33
                            <input type="hidden" name="action" value="add" />
34
35
                            <fieldset class="rows">
36
                                <legend>Add <i>[% item.title %]</i> to <i>[% course.course_name %]</i></legend>
37
                                <ol>
38
                                    <li>
39
                                        <label for="barcode">Barcode:</label>
40
                                        <span id="barcode">[% item.barcode %]</span>
41
                                        <input type="hidden" name="itemnumber" value="[% item.itemnumber %]" />
42
                                    </li>
43
44
                                    <li>
45
                                        <label class="required" for="itype">Item Type:</label>
46
                                        <select id="itype" name="itype">
47
                                            <option value="">LEAVE UNCHANGED</option>
48
49
                                            [% FOREACH it IN itypes %]
50
                                                [% IF course_item.itype && ( ( course.enabled == 'yes' && it.itemtype == item.itype ) || ( course.enabled == 'no' && it.itemtype == course_item.itype ) ) %]
51
                                                    <option value="[% it.itemtype %]" selected="selected">[% it.description %]</option>
52
                                                [% ELSE %]
53
                                                    <option value="[% it.itemtype %]">[% it.description %]</option>
54
                                                [% END %]
55
                                            [% END %]
56
                                        </select>
57
                                    </li>
58
59
                                    <li>
60
                                        <label class="required" for="ccode">Collection Code:</label>
61
                                        <select id="ccode" name="ccode">
62
                                            <option value="">LEAVE UNCHANGED</option>
63
64
                                            [% FOREACH c IN ccodes %]
65
                                                [% IF course_item.ccode && ( ( course.enabled == 'yes' && c.authorised_value == item.ccode ) || ( course.enabled == 'no' && c.authorised_value == course_item.ccode ) ) %]
66
                                                    <option value="[% c.authorised_value %]" selected="selected">[% c.lib %]</option>
67
                                                [% ELSE %]
68
                                                    <option value="[% c.authorised_value %]">[% c.lib %]</option>
69
                                                [% END %]
70
                                            [% END %]
71
                                        </select>
72
                                    </li>
73
74
                                    <li>
75
                                        <label class="required" for="location">Shelving Location:</label>
76
                                        <select id="location" name="location">
77
                                            <option value="">LEAVE UNCHANGED</option>
78
79
                                            [% FOREACH s IN locations %]
80
                                                [% IF course_item.location && ( ( course.enabled == 'yes' && s.authorised_value == item.location ) || ( course.enabled == 'no' && s.authorised_value == course_item.location ) ) %]
81
                                                    <option value="[% s.authorised_value %]" selected="selected">[% s.lib %]</option>
82
                                                [% ELSE %]
83
                                                    <option value="[% s.authorised_value %]">[% s.lib %]</option>
84
                                                [% END %]
85
                                            [% END %]
86
                                        </select>
87
                                    </li>
88
89
                                    <li>
90
                                        <label class="required" for="holdingbranch">Holding Library:</label>
91
                                        <select id="holdingbranch" name="holdingbranch">
92
                                            <option value="">LEAVE UNCHANGED</option>
93
94
                                            [% FOREACH b IN branches %]
95
                                                [% IF course_item.holdingbranch && ( ( course.enabled == 'yes' && b.value == item.holdingbranch ) || ( course.enabled == 'no' && b.value == course_item.holdingbranch ) ) %]
96
                                                    <option value="[% b.value %]" selected="selected">[% b.branchname %]</option>
97
                                                [% ELSE %]
98
                                                    <option value="[% b.value %]">[% b.branchname %]</option>
99
                                                [% END %]
100
                                            [% END %]
101
                                        </select>
102
                                    </li>
103
104
                                    <li>
105
                                        <label for="staff_note">Staff note:</label>
106
                                        <textarea name="staff_note" id="staff_note">[% course_reserve.staff_note %]</textarea>
107
                                    </li>
108
109
                                    <li>
110
                                        <label for="public_note">Public note:</label>
111
                                        <textarea name="public_note" id="public_note">[% course_reserve.public_note %]</textarea>
112
                                    </li>
113
114
                                </ol>
115
                            </fieldset>
116
117
                            <fieldset class="action">
118
                                <input type="submit" id="submit" value="Save" class="submit" />
119
120
                                <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% course.course_id %]" class="cancel">Cancel</a>
121
                            </fieldset>
122
123
                    </div>
124
                </div>
125
            </div>
126
        </div>
127
    </div>
128
</div>
129
130
131
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt (+183 lines)
Line 0 Link Here
1
[% USE AuthorisedValues %]
2
[% USE ItemTypes %]
3
[% USE Branches %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Course Reserves &rsaquo; New Course</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
8
<script type="text/javascript">
9
//<![CDATA[
10
11
    function confirmItemDelete(){
12
        return confirm( _('Are you sure you want to delete this item?');
13
    }
14
15
//]]>
16
</script>
17
18
</head>
19
20
<body>
21
22
[% INCLUDE 'header.inc' %]
23
[% INCLUDE 'cat-search.inc' %]
24
25
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course Reserves</a> &rsaquo; Course Details for <i>[% course.course_name %]</i></div>
26
27
<div id="doc2" class="yui-t7">
28
    <div id="bd">
29
        <div id="yui-main">
30
            <div id="toolbar">
31
                <script type="text/javascript">
32
                //<![CDATA[
33
                    $(document).ready(function(){
34
                        addItemsButton     = new YAHOO.widget.Button("add_items");
35
                        editCourseButton   = new YAHOO.widget.Button("edit_course");
36
                        deleteCourseButton = new YAHOO.widget.Button("delete_course");
37
38
                        deleteCourseButton.on("click", confirmDelete );
39
                    });
40
41
                    function confirmDelete(p_oEvent){
42
                        if ( ! confirm( _('Are you sure you want to delete this course?') ) ) {
43
                            YAHOO.util.Event.stopEvent( p_oEvent );
44
                        }
45
                    }
46
47
                //]]>
48
                </script>
49
                <ul class="toolbar">
50
                    [% IF CAN_user_coursereserves_add_reserves %]<li><a id="add_items" href="/cgi-bin/koha/course_reserves/add_items.pl?course_id=[% course.course_id %]">Add Reserves</a></li>[% END %]
51
                    [% IF ( CAN_user_coursereserves_manage_courses ) %]<li><a id="edit_course" href="/cgi-bin/koha/course_reserves/course.pl?course_id=[% course.course_id %]">Edit Course</a></li>[% END %]
52
                    [% IF ( CAN_user_coursereserves_manage_courses ) %]<li><a id="delete_course" href="/cgi-bin/koha/course_reserves/mod_course.pl?course_id=[% course.course_id %]&action=del">Delete Course</a></li>[% END %]
53
                </ul>
54
            </div><!-- /toolbar -->
55
56
            <table>
57
                <tr><th>Course name</th><td>[% course.course_name %]</td></tr>
58
                <tr><th>Term</th><td>[% AuthorisedValues.GetByCode( 'TERM', course.term ) %]</td></tr>
59
                <tr><th>Department</th><td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', course.department ) %]</td></tr>
60
                <tr><th>Course number</th><td>[% course.course_number %]</td></tr>
61
                <tr><th>Section</th><td>[% course.section %]</td></tr>
62
                <tr><th>Instructors</th><td>[% FOREACH i IN course.instructors %]<div class="instructor"><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% i.borrowernumber %]">[% i.firstname %] [% i.surname %]</a></div>[% END %]</td></tr>
63
                <tr><th>Staff note</th><td>[% course.staff_note %]</td></tr>
64
                <tr><th>Public note</th><td>[% course.public_note %]</td></tr>
65
                <tr><th>Students count</th><td>[% course.students_count %]</td></tr>
66
                <tr><th>Status</th><td>[% IF course.enabled == 'yes' %]Active[% ELSE %]Inactive[% END %]</td></tr>
67
            </table>
68
69
            <table>
70
                <thead>
71
                    <tr>
72
                        <th>Title</th>
73
                        <th>Barcode</th>
74
                        <th>Call number</th>
75
                        <th>Item type</th>
76
                        <th>Collection</th>
77
                        <th>Location</th>
78
                        <th>Library</th>
79
                        <th>Staff note</th>
80
                        <th>Public note</th>
81
                        [% IF CAN_user_coursereserves_add_reserves %]<th>&nbsp;<!-- Edit --></th>[% END %]
82
                        [% IF CAN_user_coursereserves_delete_reserves %]<th>&nbsp;<!-- Remove --></th>[% END %]
83
                        <th>Other course reserves</th>
84
                    </tr>
85
                </thead>
86
87
                <tbody>
88
                    [% FOREACH cr IN course_reserves %]
89
                        <tr>
90
                            <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% cr.item.biblionumber %]">[% cr.item.title %]</a></td>
91
                            <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% cr.item.itemnumber %]&biblionumber=[% cr.item.biblionumber %]&bi=[% cr.item.biblioitemnumber %]">[% cr.item.barcode %]</a></td>
92
                            <td>[% cr.item.itemcallnumber %]</td>
93
                            <td>
94
                                [% IF cr.course_item.itype %]
95
                                    [% IF cr.course_item.enabled == 'yes' %]
96
                                        [% ItemTypes.GetDescription( cr.item.itype ) %]
97
                                    [% ELSE %]
98
                                        [% ItemTypes.GetDescription( cr.course_item.itype ) %]
99
                                    [% END %]
100
                                [% ELSE %]
101
                                     <i>Unchanged</i>
102
                                     ([% ItemTypes.GetDescription( cr.item.itype ) %])
103
                                [% END %]
104
                            </td>
105
                            <td>
106
                                 [% IF cr.course_item.ccode %]
107
                                     [% IF cr.course_item.enabled == 'yes' %]
108
                                          [% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %]
109
                                     [% ELSE %]
110
                                         [% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode ) %]
111
                                     [% END %]
112
                                 [% ELSE %]
113
                                     <i>Unchanged</i>
114
                                     ([% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %])
115
                                 [% END %]
116
                            </td>
117
                            <td>
118
                                [% IF cr.course_item.location %]
119
                                     [% IF cr.course_item.enabled == 'yes' %]
120
                                         [% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %]
121
                                    [% ELSE %]
122
                                        [% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) %]
123
                                    [% END %]
124
                                [% ELSE %]
125
                                    <i>Unchanged</i>
126
                                    ([% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %])
127
                                [% END %]
128
                            </td>
129
                            <td>
130
                                [% IF cr.course_item.holdingbranch %]
131
                                    [% IF cr.course_item.enabled == 'yes' %]
132
                                        [% Branches.GetName( cr.item.holdingbranch ) %]
133
                                    [% ELSE %]
134
                                        [% Branches.GetName( cr.course_item.holdingbranch ) %]
135
                                    [% END %]
136
                                [% ELSE %]
137
                                    <i>Unchanged</i>
138
                                    ([% Branches.GetName( cr.item.holdingbranch ) %])
139
                                [% END %]
140
                            </td>
141
                            <td>[% cr.staff_note %]</td>
142
                            <td>[% cr.public_note %]</td>
143
144
                            [% IF CAN_user_coursereserves_add_reserves %]
145
                                <td><a href="add_items.pl?course_id=[% course.course_id %]&barcode=[% cr.item.barcode %]&action=lookup">Edit</a></td>
146
                            [% END %]
147
148
                            [% IF CAN_user_coursereserves_delete_reserves %]
149
                                <td>
150
                                    [% IF cr.item.onloan %]
151
                                        On Loan
152
                                    [% ELSIF cr.item.itemlost %]
153
                                        Item Lost
154
                                    [% ELSE %]
155
                                        <a href="course-details.pl?course_id=[% course.course_id %]&action=del_reserve&cr_id=[% cr.cr_id %]" onclick="return confirmItemDelete()" >Remove</a>
156
                                    [% END %]
157
158
                                </td>
159
                            [% END %]
160
161
                            <td>
162
                                [% FOREACH course IN cr.courses %]
163
                                    [% UNLESS cr.course_id == course.course_id %]
164
                                        <p>
165
                                            <a href="course-details.pl?course_id=[% course.course_id %]">
166
                                                [% course.course_name %]
167
                                                [% IF course.section %] [% course.section %] [% END %]
168
                                                [% IF course.term %] [% AuthorisedValues.GetByCode( 'TERM', course.term ) %] [% END %]
169
                                            </a>
170
                                        </p>
171
                                    [% END %]
172
                                [% END %]
173
                            </td>
174
                        </tr>
175
                    [% END %]
176
                </tbody>
177
            </table>
178
        </div>
179
    </div>
180
</div>
181
182
183
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt (+104 lines)
Line 0 Link Here
1
[% USE AuthorisedValues %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Course Reserves</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
6
</head>
7
<body id="lists_shelves" class="lists">
8
9
[% INCLUDE 'header.inc' %]
10
[% INCLUDE 'cat-search.inc' %]
11
12
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course Reserves</a></div>
13
14
<div id="doc2" class="yui-t7">
15
    <div id="bd">
16
        <div id="yui-main">
17
            <div class="yui-b">
18
                <div class="yui-g">
19
20
                    <div id="toolbar">
21
                        <script type="text/javascript">
22
                        //<![CDATA[
23
                            $(document).ready(function(){
24
                                newCourseButton = new YAHOO.widget.Button("new_course");
25
                            });
26
                        //]]>
27
                        </script>
28
                        <ul class="toolbar">
29
                            [% IF ( CAN_user_coursereserves_manage_courses ) %]
30
                            <li><a id="new_course" href="/cgi-bin/koha/course_reserves/course.pl">New Course</a></li>
31
                            [% END %]
32
                        </ul>
33
                    </div><!-- /toolbar -->
34
35
                    <div id="search-toolbar">
36
                        <script type="text/javascript">
37
                        //<![CDATA[
38
                            function submitSearchForm(p_oEvent){
39
                                $('#search_courses_form').submit();
40
                            }
41
42
                            $(document).ready(function(){
43
                                newCourseButton = new YAHOO.widget.Button("search_courses");
44
                                newCourseButton.on("click", submitSearchForm );
45
                            });
46
                        //]]>
47
                        </script>
48
                        <ul class="toolbar">
49
                            <li><form id="search_courses_form"><input type="text" name="search_on" id="search_on"></form></li>
50
                            <li><a id="search_courses">Search Courses</a></li>
51
                        </ul>
52
                    </div><!-- /toolbar -->
53
54
                    <h1>Courses</h1>
55
                    <table id="course_reserves_table">
56
                        <thead>
57
                            <tr>
58
                                <th>Name</th>
59
                                <th>Dept.</th>
60
                                <th>Course #</th>
61
                                <th>Section</th>
62
                                <th>Term</th>
63
                                <th>Instructors</th>
64
                                <th>Staff Note</th>
65
                                <th>Public Note</th>
66
                                <th># of Students</th>
67
                                <th>Enabled</th>
68
                            </tr>
69
                        </thead>
70
71
                        <tbody>
72
                            [% FOREACH c IN courses %]
73
                                <tr>
74
                                    <td><a href="course-details.pl?course_id=[% c.course_id %]">[% c.course_name %]</a></td>
75
                                    <td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', c.department ) %]</td>
76
                                    <td>[% c.course_number %]</td>
77
                                    <td>[% c.section %]</td>
78
                                    <td>[% AuthorisedValues.GetByCode( 'TERM' c.term ) %]</td>
79
                                    <td>
80
                                        [% FOREACH i IN c.instructors %]
81
                                            <div class="instructor"><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% i.borrowernumber %]">[% i.firstname %] [% i.surname %]</a></div>
82
                                        [% END %]
83
                                    </td>
84
                                    <td>[% c.staff_note %]</td>
85
                                    <td>[% c.public_note %]</td>
86
                                    <td>[% c.students_count %]</td>
87
                                    <td>
88
                                        [% IF c.enabled == 'yes' %]
89
                                            <img src="/intranet-tmpl/prog/img/approve.gif" />
90
                                        [% ELSE %]
91
                                            <img src="http://kohadev:8080/intranet-tmpl/prog/img/deny.gif" />
92
                                        [% END %]
93
                                    </td>
94
                            [% END %]
95
                        </tbody>
96
                    </table>
97
                </div>
98
            </div>
99
        </div>
100
    </div>
101
</div>
102
103
104
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt (+197 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Course Reserves &rsaquo; [% IF course_name %] Edit [% course_name %] [% ELSE %] New Course [% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
5
<script type="text/javascript">
6
//<![CDATA[
7
8
    function Check(f) {
9
        var _alertString = "";
10
11
        if( ! $("#department").val() ) {
12
            _alertString += _("- You must choose a department") + "\n";
13
        }
14
15
        if( ! $("#course_number").val() ) {
16
            _alertString += _("- You must choose a course number") + "\n";
17
        }
18
19
        if( ! $("#course_name").val() ) {
20
            _alertString += _("- You must add a course name") + "\n";
21
        }
22
23
        if ( _alertString.length ) {
24
            var alertHeader;
25
            alertHeader = _("Form not submitted because of the following problem(s)");
26
            alertHeader += "\n------------------------------------------------------------------------------------\n\n";
27
28
            alert( alertHeader + _alertString );
29
        } else {
30
            f.submit();
31
        }
32
    }
33
34
//]]>
35
</script>
36
37
<script type="text/javascript">
38
//<![CDATA[
39
$(document).ready(function(){
40
    $( "#find_instructor" ).autocomplete({
41
        source: "/cgi-bin/koha/circ/ysearch.pl",
42
        minLength: 3,
43
        select: function( event, ui ) {
44
            AddInstructor( ui.item.firstname + " " + ui.item.surname, ui.item.cardnumber );
45
            return false;
46
        }
47
    })
48
    .data( "autocomplete" )._renderItem = function( ul, item ) {
49
        return $( "<li></li>" )
50
        .data( "item.autocomplete", item )
51
        .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
52
        .appendTo( ul );
53
    };
54
55
});
56
57
function AddInstructor( name, cardnumber ) {
58
    div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' onclick='RemoveInstructor(" + cardnumber + ");'> Remove </a> ) <input type='hidden' name='instructors' value='" + cardnumber + "' /></div>";
59
    $('#instructors').append( div );
60
61
    $('#find_instructor').val('').focus();
62
}
63
64
function RemoveInstructor( cardnumber ) {
65
    $( '#borrower_' + cardnumber ).remove();
66
}
67
68
//]]>
69
</script>
70
71
</head>
72
73
<body>
74
75
[% INCLUDE 'header.inc' %]
76
[% INCLUDE 'cat-search.inc' %]
77
78
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course Reserves</a> &rsaquo; [% IF course_name %] Edit <i>[% course_name %]</i> [% ELSE %] New Course [% END %]</div>
79
80
<div id="doc2" class="yui-t7">
81
    <div id="bd">
82
        <div id="yui-main">
83
            <div class="yui-b">
84
                <div class="yui-g">
85
                    <div class="yui-u first">
86
                        <form method="post" action="/cgi-bin/koha/course_reserves/mod_course.pl">
87
                            [% IF course_id %]<input type="hidden" name="course_id" value="[% course_id %]" />[% END %]
88
                            <fieldset class="rows">
89
                                <legend>[% IF course_id %] Edit [% ELSE %] Create [% END %] course</legend>
90
                                <ol>
91
                                    <li>
92
                                        <label class="required" for="department">Department:</label>
93
                                        <select id="department" name="department">
94
                                            <option value="">Select A Department</option>
95
96
                                            [% FOREACH d IN departments %]
97
                                                [% IF d.authorised_value == department %]
98
                                                    <option value="[% d.authorised_value %]" selected="selected">[% d.lib %]</option>
99
                                                [% ELSE %]
100
                                                    <option value="[% d.authorised_value %]">[% d.lib %]</option>
101
                                                [% END %]
102
                                            [% END %]
103
                                        </select>
104
                                    </li>
105
106
                                    <li>
107
                                        <label class="required" for="course_number">Course number:</label>
108
                                        <input id="course_number" name="course_number" type="text" value="[% course_number %]" />
109
                                    </li>
110
111
                                    <li>
112
                                        <label for="section">Section:</label>
113
                                        <input id="section" name="section" type="text" value="[% section %]"/>
114
                                    </li>
115
116
                                    <li>
117
                                        <label class="required" for="course_name">Course name:</label>
118
                                        <input id="course_name" name="course_name" type="text" value="[% course_name %]" />
119
                                    </li>
120
121
                                    <li>
122
                                        <label for="term">Term:</label>
123
                                        <select id="term" name="term">
124
                                            <option value=""></option>
125
126
                                            [% FOREACH t IN terms %]
127
                                                [% IF t.authorised_value == term %]
128
                                                    <option value="[% t.authorised_value %]" selected="selected">[% t.lib %]</option>
129
                                                [% ELSE %]
130
                                                    <option value="[% t.authorised_value %]">[% t.lib %]</option>
131
                                                [% END %]
132
                                            [% END %]
133
                                        </select>
134
                                    </li>
135
136
                                    <!-- TODO: Add Instructors -->
137
                                    <li>
138
                                        <label for="instructors">Instructors:</label>
139
140
                                        <fieldset>
141
                                             <div id="instructors">
142
                                                 [% FOREACH i IN instructors %]
143
                                                     <div id="borrower_[% i.cardnumber %]">
144
                                                         [% i.surname %], [% i.firstname %] ( <a href='#' onclick='RemoveInstructor( [% i.cardnumber %] );'> Remove </a> )
145
                                                         <input type='hidden' name='instructors' value='[% i.cardnumber %]' />
146
                                                     </div>
147
                                                 [% END %]
148
                                             </div>
149
150
                                        </fieldset>
151
152
                                        <fieldset>
153
                                            <label for="find_instructor">Instructor Search:</label>
154
                                            <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit"/>
155
                                            <div id="find_instructor_container"></div>
156
                                        </fieldset>
157
                                    <li>
158
                                        <label for="staff_note">Staff note:</label>
159
                                        <textarea name="staff_note" id="staff_note">[% staff_note %]</textarea>
160
                                    </li>
161
162
                                    <li>
163
                                        <label for="public_note">Public note:</label>
164
                                        <textarea name="public_note" id="public_note">[% public_note %]</textarea>
165
                                    </li>
166
167
                                    <li>
168
                                        <label for="students_count">Number of students:</label>
169
                                        <input id="students_count" name="students_count" type="text" value="[% students_count %]" />
170
                                    </li>
171
172
                                    <li>
173
                                        <label for="enabled">Enabled?</label>
174
                                        [% IF enabled == 'no' %]
175
                                            <input type="checkbox" name="enabled" id="enabled" />
176
                                        [% ELSE %]
177
                                            <input type="checkbox" name="enabled" id="enabled" checked="checked" />
178
                                        [% END %]
179
                                    </li>
180
                                </ol>
181
                            </fieldset>
182
183
                            <fieldset class="action">
184
                                <input type="submit" onclick="Check(this.form); return false;" value="Save" class="submit" />
185
186
                                <a href="/cgi-bin/koha/course_reserves/course-reserves.pl" class="cancel">Cancel</a>
187
                            </fieldset>
188
189
                    </div>
190
                </div>
191
            </div>
192
        </div>
193
    </div>
194
</div>
195
196
197
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt (-1 / +1 lines)
Lines 4-10 Link Here
4
<script type="text/javascript">
4
<script type="text/javascript">
5
//<![CDATA[
5
//<![CDATA[
6
$(document).ready(function(){
6
$(document).ready(function(){
7
	$("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
7
	$("fieldset.rows input").addClass("noEnterSubmit");
8
});
8
});
9
//]]>
9
//]]>
10
</script>
10
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt (-1 / +1 lines)
Lines 4-10 Link Here
4
<script type="text/javascript">
4
<script type="text/javascript">
5
//<![CDATA[
5
//<![CDATA[
6
$(document).ready(function(){
6
$(document).ready(function(){
7
	$("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
7
	$("fieldset.rows input").addClass("noEnterSubmit");
8
});
8
});
9
//]]>
9
//]]>
10
</script>
10
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-1 / +1 lines)
Lines 6-12 Link Here
6
<script type="text/JavaScript">
6
<script type="text/JavaScript">
7
//<![CDATA[
7
//<![CDATA[
8
    $(document).ready(function() {
8
    $(document).ready(function() {
9
		$("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
9
		$("fieldset.rows input").addClass("noEnterSubmit");
10
        $("#guarantordelete").click(function() {
10
        $("#guarantordelete").click(function() {
11
            $("#contact-details").hide().find('a').remove();
11
            $("#contact-details").hide().find('a').remove();
12
            $("#guarantorid, #contactname, #contactfirstname").each(function () { this.value = "" });
12
            $("#guarantorid, #contactname, #contactfirstname").each(function () { this.value = "" });
(-)a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc (+1 lines)
Lines 110-115 Link Here
110
110
111
<div id="moresearches">
111
<div id="moresearches">
112
<a href="/cgi-bin/koha/opac-search.pl">Advanced search</a>
112
<a href="/cgi-bin/koha/opac-search.pl">Advanced search</a>
113
[% IF ( UseCourseReserves ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-course-reserves.pl">Course Reserves</a>[% END %]
113
[% IF ( OpacBrowser ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-browser.pl">Browse by hierarchy</a>[% END %]
114
[% IF ( OpacBrowser ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-browser.pl">Browse by hierarchy</a>[% END %]
114
[% IF ( OpacAuthorities ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-authorities-home.pl">Browse by author or subject</a>[% END %]
115
[% IF ( OpacAuthorities ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-authorities-home.pl">Browse by author or subject</a>[% END %]
115
[% IF ( opacuserlogin && reviewson && OpacShowRecentComments ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %]
116
[% IF ( opacuserlogin && reviewson && OpacShowRecentComments ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-course-details.tt (+63 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE AuthorisedValues %]
3
[% USE ItemTypes %]
4
[% USE Branches %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog
7
[% INCLUDE 'doc-head-close.inc' %]
8
</head>
9
<body id="opac-main">
10
[% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %]
11
   <div id="bd">
12
[% INCLUDE 'masthead.inc' %]
13
14
<div id="doc2" class="yui-t7">
15
    <div id="yui-main">
16
17
        <table>
18
            <tr><th>Course Name</th><td>[% course.course_name %]</td></tr>
19
            <tr><th>Term</th><td>[% AuthorisedValues.GetByCode( 'TERM', course.term ) %]</td></tr>
20
            <tr><th>Department</th><td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', course.department ) %]</td></tr>
21
            <tr><th>Course Number</th><td>[% course.course_number %]</td></tr>
22
            <tr><th>Section</th><td>[% course.section %]</td></tr>
23
            <tr><th>Instructors</th><td>[% FOREACH i IN course.instructors %]<div class="instructor">[% i.firstname %] [% i.surname %]</div>[% END %]</td></tr>
24
            <tr><th>Notes</th><td>[% course.public_note %]</td></tr>
25
        </table>
26
27
        <table>
28
            <thead>
29
                <tr>
30
                    <th>Title</th>
31
                    <th>Item type</th>
32
                    <th>Location</th>
33
                    <th>Collection</th>
34
                    <th>Call number</th>
35
                    <th>Copy</th>
36
                    <th>Status</td>
37
                    <th>Date due</td>
38
                    <th>Notes</th>
39
                </tr>
40
            </thead>
41
42
            <tbody>
43
                [% FOREACH cr IN course_reserves %]
44
                    <tr>
45
                        <td><a href="opac-detail.pl?biblionumber=[% cr.item.biblionumber %]">[% cr.item.title %]</a></td>
46
                        <td>[% ItemTypes.GetDescription( cr.item.itype ) %]</td>
47
                        <td>[% Branches.GetName( cr.item.holdingbranch ) %] <br/> <i>[% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %]</i></td>
48
                        <td>[% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %]</td>
49
                        <td>[% cr.item.itemcallnumber %]</td>
50
                        <td>[% cr.item.copynumber %]</td>
51
                        <td>[% INCLUDE 'item-status.inc' item = cr.item %]</td>
52
                        <td>[% cr.issue.date_due | $KohaDates %]</td>
53
                        <td>[% cr.public_note %]</td>
54
                    </tr>
55
                [% END %]
56
            </tbody>
57
        </table>
58
59
    </div>
60
</div>
61
62
63
[% INCLUDE 'opac-bottom.inc' %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-course-reserves.tt (+62 lines)
Line 0 Link Here
1
[% USE AuthorisedValues %]
2
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog
5
[% INCLUDE 'doc-head-close.inc' %]
6
</head>
7
<body id="opac-main">
8
[% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %]
9
   <div id="bd">
10
[% INCLUDE 'masthead.inc' %]
11
12
13
<div id="doc2" class="yui-t7">
14
        <div id="yui-main">
15
            <div class="yui-b">
16
                <div class="yui-g">
17
18
                    <div id="search-toolbar">
19
                        <form id="search_courses_form">
20
                            <input type="text" name="search_on" id="search_on" />
21
                            <input type="submit" value="Search" />
22
                        </form>
23
                    </div><!-- /toolbar -->
24
25
                    <h1>Courses</h1>
26
                    <table id="course_reserves_table">
27
                        <thead>
28
                            <tr>
29
                                <th>Name</th>
30
                                <th>Dept.</th>
31
                                <th>Course #</th>
32
                                <th>Section</th>
33
                                <th>Term</th>
34
                                <th>Instructors</th>
35
                                <th>Notes</th>
36
                            </tr>
37
                        </thead>
38
39
                        <tbody>
40
                            [% FOREACH c IN courses %]
41
                                <tr>
42
                                    <td><a href="opac-course-details.pl?course_id=[% c.course_id %]">[% c.course_name %]</a></td>
43
                                    <td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', c.department, 1 ) %]</td>
44
                                    <td>[% c.course_number %]</td>
45
                                    <td>[% c.section %]</td>
46
                                    <td>[% AuthorisedValues.GetByCode( 'TERM' c.term ) %]</td>
47
                                    <td>
48
                                      [% FOREACH i IN c.instructors %]
49
                                          <div class="instructor">[% i.firstname %] [% i.surname %]</div>
50
                                      [% END %]
51
                                    </td>
52
                                    <td>[% c.public_note %]</td>
53
                            [% END %]
54
                        </tbody>
55
                    </table>
56
                </div>
57
            </div>
58
        </div>
59
</div>
60
61
62
[% INCLUDE 'opac-bottom.inc' %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt (+32 lines)
Lines 1-4 Link Here
1
[% USE KohaDates %]
1
[% USE KohaDates %]
2
[% USE AuthorisedValues %]
3
4
[% ShowCourseReservesHeader = 0 %]
5
[% IF UseCourseReserves %]
6
    [% FOREACH ITEM_RESULT IN ITEM_RESULTS %]
7
       [% IF ITEM_RESULT.course_reserves %]
8
           [% FOREACH r IN ITEM_RESULT.course_reserves %]
9
               [% IF r.course.enabled == 'yes' %]
10
                   [% ShowCourseReservesHeader = 1 %]
11
               [% END %]
12
           [% END %]
13
        [% END %]
14
    [% END %]
15
[% END %]
2
16
3
[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Details for: [% title |html %][% FOREACH subtitl IN subtitle %], [% subtitl.subfield |html %][% END %]
17
[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Details for: [% title |html %][% FOREACH subtitl IN subtitle %], [% subtitl.subfield |html %][% END %]
4
[% INCLUDE 'doc-head-close.inc' %]
18
[% INCLUDE 'doc-head-close.inc' %]
Lines 740-745 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
740
        [% ELSIF show_priority %]
754
        [% ELSIF show_priority %]
741
            <th>Item hold queue priority</th>
755
            <th>Item hold queue priority</th>
742
        [% END %]
756
        [% END %]
757
            [% IF ( ShowCourseReservesHeader ) %]<th id="item_coursereserves">Course Reserves</th>[% END %]
743
        </tr></thead>
758
        </tr></thead>
744
	    <tbody>[% FOREACH ITEM_RESULT IN ITEM_RESULTS %]
759
	    <tbody>[% FOREACH ITEM_RESULT IN ITEM_RESULTS %]
745
	    <tr>[% IF ( item_level_itypes ) %]<td>[% UNLESS ( noItemTypeImages ) %][% IF ( ITEM_RESULT.imageurl ) %]<img src="[% ITEM_RESULT.imageurl %]" title="[% ITEM_RESULT.description %]" alt="[% ITEM_RESULT.description %]" />[% END %][% END %] [% ITEM_RESULT.description %]</td>[% END %]
760
	    <tr>[% IF ( item_level_itypes ) %]<td>[% UNLESS ( noItemTypeImages ) %][% IF ( ITEM_RESULT.imageurl ) %]<img src="[% ITEM_RESULT.imageurl %]" title="[% ITEM_RESULT.description %]" alt="[% ITEM_RESULT.description %]" />[% END %][% END %] [% ITEM_RESULT.description %]</td>[% END %]
Lines 777-782 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
777
            [% END %]
792
            [% END %]
778
                </td>
793
                </td>
779
        [% END %]
794
        [% END %]
795
796
        [% IF ShowCourseReservesHeader %]
797
            <td>
798
                [% IF ITEM_RESULT.course_reserves %]
799
                    [% FOREACH r IN ITEM_RESULT.course_reserves %]
800
                        <p>
801
                            <a href="opac-course-details.pl?course_id=[% r.course.course_id %]">
802
                                [% r.course.course_name %]
803
                                <!--[% IF r.course.course_number %] [% r.course.course_number %] [% END %]-->
804
                                [% IF r.course.section %] [% r.course.section %] [% END %]
805
                                [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) %] [% END %]
806
                            </a>
807
                        </p>
808
                    [% END %]
809
                [% END %]
810
            </td>
811
        [% END %]
780
	    </tr>
812
	    </tr>
781
	    [% END %]</tbody>
813
	    [% END %]</tbody>
782
	</table>
814
	</table>
(-)a/opac/opac-course-details.pl (+60 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#
4
# Copyright 2012 Bywater Solutions
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
use Modern::Perl;
22
23
use CGI;
24
25
use C4::Auth;
26
use C4::Output;
27
use C4::Koha;
28
29
use Koha::CourseReserves;
30
31
my $cgi = new CGI;
32
33
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
34
    {
35
        template_name   => "opac-course-details.tmpl",
36
        query           => $cgi,
37
        type            => "opac",
38
        authnotrequired => 1,
39
        debug           => 1,
40
    }
41
);
42
43
my $action = $cgi->param('action') || '';
44
my $course_id = $cgi->param('course_id');
45
46
die( "No course_id given" ) unless ( $course_id );
47
48
if ( $action eq 'del_reserve' ) {
49
    DelCourseReserve( cr_id => $cgi->param('cr_id') );
50
}
51
52
my $course = GetCourse( $course_id );
53
my $course_reserves = GetCourseReserves( course_id => $course_id, include_items => 1, include_count => 1 );
54
55
$template->param(
56
    course => $course,
57
    course_reserves => $course_reserves,
58
);
59
60
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/opac/opac-course-reserves.pl (+51 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#
4
# Copyright 2012 Bywater Solutions
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
use Modern::Perl;
22
23
use CGI;
24
25
use C4::Auth;
26
use C4::Output;
27
28
use Koha::CourseReserves;
29
30
my $cgi = new CGI;
31
32
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
33
    {
34
        template_name   => "opac-course-reserves.tmpl",
35
        query           => $cgi,
36
        type            => "opac",
37
        authnotrequired => 1,
38
        debug           => 1,
39
    }
40
);
41
42
my $search_on = $cgi->param('search_on');
43
44
my $courses = SearchCourses( term => $search_on, enabled => 'yes' );
45
46
if ( @$courses == 1 ) {
47
    print $cgi->redirect("/cgi-bin/koha/opac-course-details.pl?course_id=" . $courses->[0]->{'course_id'});
48
} else {
49
    $template->param( courses => $courses );
50
    output_html_with_http_headers $cgi, $cookie, $template->output;
51
}
(-)a/opac/opac-detail.pl (-1 / +7 lines)
Lines 49-54 use MARC::Field; Link Here
49
use List::MoreUtils qw/any none/;
49
use List::MoreUtils qw/any none/;
50
use C4::Images;
50
use C4::Images;
51
use Koha::DateUtils;
51
use Koha::DateUtils;
52
use Koha::CourseReserves;
52
53
53
BEGIN {
54
BEGIN {
54
	if (C4::Context->preference('BakerTaylorEnabled')) {
55
	if (C4::Context->preference('BakerTaylorEnabled')) {
Lines 965-968 if (C4::Context->preference('OpacHighlightedWords')) { Link Here
965
    $template->{VARS}->{query_desc} = $query->param('query_desc');
966
    $template->{VARS}->{query_desc} = $query->param('query_desc');
966
}
967
}
967
968
969
if ( C4::Context->preference('UseCourseReserves') ) {
970
    foreach my $i ( @items ) {
971
        $i->{'course_reserves'} = GetItemReservesInfo( itemnumber => $i->{'itemnumber'} );
972
    }
973
}
974
968
output_html_with_http_headers $query, $cookie, $template->output;
975
output_html_with_http_headers $query, $cookie, $template->output;
969
- 

Return to bug 8215