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 1065-1071 sub GetAuthorisedValueCategories { Link Here
1065
1075
1066
=head2 GetAuthorisedValueByCode
1076
=head2 GetAuthorisedValueByCode
1067
1077
1068
$authhorised_value = GetAuthorisedValueByCode( $category, $authvalcode );
1078
$authorised_value = GetAuthorisedValueByCode( $category, $authvalcode, $opac );
1069
1079
1070
Return the lib attribute from authorised_values from the row identified
1080
Return the lib attribute from authorised_values from the row identified
1071
by the passed category and code
1081
by the passed category and code
Lines 1073-1085 by the passed category and code Link Here
1073
=cut
1083
=cut
1074
1084
1075
sub GetAuthorisedValueByCode {
1085
sub GetAuthorisedValueByCode {
1076
    my ( $category, $authvalcode ) = @_;
1086
    my ( $category, $authvalcode, $opac ) = @_;
1077
1087
1078
    my $dbh = C4::Context->dbh;
1088
    my $dbh = C4::Context->dbh;
1079
    my $sth = $dbh->prepare("SELECT lib FROM authorised_values WHERE category=? AND authorised_value =?");
1089
    my $sth = $dbh->prepare("SELECT lib, lib_opac FROM authorised_values WHERE category=? AND authorised_value =?");
1080
    $sth->execute( $category, $authvalcode );
1090
    $sth->execute( $category, $authvalcode );
1081
    while ( my $data = $sth->fetchrow_hashref ) {
1091
1082
        return $data->{'lib'};
1092
    my $row = $sth->fetchrow_hashref();
1093
1094
    if ( $opac ) {
1095
        return $row->{'lib_opac'} || $row->{'lib'};
1096
    } else {
1097
        return $row->{'lib'};
1083
    }
1098
    }
1084
}
1099
}
1085
1100
(-)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 (+64 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-details.tmpl",
36
        query           => $cgi,
37
        type            => "intranet",
38
        authnotrequired => 0,
39
        flagsrequired   => { coursereserves => 'manage_courses' },
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(
54
    course_id       => $course_id,
55
    include_items   => 1,
56
    include_courses => 1
57
);
58
59
$template->param(
60
    course          => $course,
61
    course_reserves => $course_reserves,
62
);
63
64
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   => { coursereserves => 'manage_courses' },
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 => 1 },
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 => 1 },
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 465-470 CREATE TABLE collections_tracking ( Link Here
465
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
465
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
466
466
467
--
467
--
468
-- Table structure for table `courses`
469
--
470
DROP TABLE IF EXISTS courses;
471
CREATE TABLE `courses` (
472
  `course_id` int(11) NOT NULL AUTO_INCREMENT,
473
  `department` varchar(20) DEFAULT NULL,
474
  `course_number` varchar(255) DEFAULT NULL,
475
  `section` varchar(255) DEFAULT NULL,
476
  `course_name` varchar(255) DEFAULT NULL,
477
  `term` varchar(20) DEFAULT NULL,
478
  `staff_note` mediumtext,
479
  `public_note` mediumtext,
480
  `students_count` varchar(20) DEFAULT NULL,
481
  `enabled` enum('yes','no') NOT NULL DEFAULT 'yes',
482
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
483
   PRIMARY KEY (`course_id`)
484
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
485
486
--
487
-- Table structure for table `course_instructors`
488
--
489
DROP TABLE IF EXISTS course_instructors;
490
CREATE TABLE `course_instructors` (
491
  `course_id` int(11) NOT NULL,
492
  `borrowernumber` int(11) NOT NULL,
493
  PRIMARY KEY (`course_id`,`borrowernumber`),
494
  KEY `borrowernumber` (`borrowernumber`)
495
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
496
497
--
498
-- Table structure for table `course_items`
499
--
500
DROP TABLE IF EXISTS course_items;
501
CREATE TABLE `course_items` (
502
  `ci_id` int(11) NOT NULL AUTO_INCREMENT,
503
  `itemnumber` int(11) NOT NULL,
504
  `itype` varchar(10) DEFAULT NULL,
505
  `ccode` varchar(10) DEFAULT NULL,
506
  `holdingbranch` varchar(10) DEFAULT NULL,
507
  `location` varchar(80) DEFAULT NULL,
508
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no',
509
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
510
   PRIMARY KEY (`ci_id`),
511
   UNIQUE KEY `itemnumber` (`itemnumber`)
512
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
513
514
--
515
-- Table structure for table `course_reserves`
516
--
517
DROP TABLE IF EXISTS course_reserves;
518
CREATE TABLE `course_reserves` (
519
  `cr_id` int(11) NOT NULL AUTO_INCREMENT,
520
  `course_id` int(11) NOT NULL,
521
  `ci_id` int(11) NOT NULL,
522
  `staff_note` mediumtext,
523
  `public_note` mediumtext,
524
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
525
   PRIMARY KEY (`cr_id`),
526
   UNIQUE KEY `psuedo_key` (`course_id`,`ci_id`),
527
   KEY `course_id` (`course_id`)
528
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
529
530
--
468
-- Table structure for table `borrower_branch_circ_rules`
531
-- Table structure for table `borrower_branch_circ_rules`
469
--
532
--
470
533
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 374-376 INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( Link Here
374
INSERT INTO systempreferences (variable,value,explanation,type) VALUES('EnableBorrowerFiles','0','If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo');
374
INSERT INTO systempreferences (variable,value,explanation,type) VALUES('EnableBorrowerFiles','0','If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo');
375
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UpdateTotalIssuesOnCirc','0','Whether to update the totalissues field in the biblio on each circ.',NULL,'YesNo');
375
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UpdateTotalIssuesOnCirc','0','Whether to update the totalissues field in the biblio on each circ.',NULL,'YesNo');
376
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('IntranetSlipPrinterJS','','Use this JavaScript for printing slips. Define at least function printThenClose(). For use e.g. with Firefox PlugIn jsPrintSetup, see http://jsprintsetup.mozdev.org/','','Free');
376
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('IntranetSlipPrinterJS','','Use this JavaScript for printing slips. Define at least function printThenClose(). For use e.g. with Firefox PlugIn jsPrintSetup, see http://jsprintsetup.mozdev.org/','','Free');
377
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo');
(-)a/installer/data/mysql/updatedatabase.pl (+71 lines)
Lines 5635-5640 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5635
    SetVersion($DBversion);
5635
    SetVersion($DBversion);
5636
}
5636
}
5637
5637
5638
$DBversion = "3.09.00.XXX";
5639
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5640
    $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('UseCourseReserves', '0', NULL, 'Enable the course reserves feature.', 'YesNo')");
5641
    $dbh->do("INSERT INTO userflags (bit,flag,flagdesc,defaulton) VALUES ('18','coursereserves','Course Reserves','0')");
5642
    $dbh->do("
5643
CREATE TABLE `courses` (
5644
  `course_id` int(11) NOT NULL AUTO_INCREMENT,
5645
  `department` varchar(20) DEFAULT NULL,
5646
  `course_number` varchar(255) DEFAULT NULL,
5647
  `section` varchar(255) DEFAULT NULL,
5648
  `course_name` varchar(255) DEFAULT NULL,
5649
  `term` varchar(20) DEFAULT NULL,
5650
  `staff_note` mediumtext,
5651
  `public_note` mediumtext,
5652
  `students_count` varchar(20) DEFAULT NULL,
5653
  `enabled` enum('yes','no') NOT NULL DEFAULT 'yes',
5654
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
5655
   PRIMARY KEY (`course_id`)
5656
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
5657
");
5658
5659
$dbh->do("
5660
CREATE TABLE `course_instructors` (
5661
  `course_id` int(11) NOT NULL,
5662
  `borrowernumber` int(11) NOT NULL,
5663
  PRIMARY KEY (`course_id`,`borrowernumber`),
5664
  KEY `borrowernumber` (`borrowernumber`)
5665
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5666
");
5667
5668
$dbh->do("
5669
CREATE TABLE `course_items` (
5670
  `ci_id` int(11) NOT NULL AUTO_INCREMENT,
5671
  `itemnumber` int(11) NOT NULL,
5672
  `itype` varchar(10) DEFAULT NULL,
5673
  `ccode` varchar(10) DEFAULT NULL,
5674
  `holdingbranch` varchar(10) DEFAULT NULL,
5675
  `location` varchar(80) DEFAULT NULL,
5676
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no',
5677
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
5678
   PRIMARY KEY (`ci_id`),
5679
   UNIQUE KEY `itemnumber` (`itemnumber`)
5680
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
5681
");
5682
5683
$dbh->do("
5684
CREATE TABLE `course_reserves` (
5685
  `cr_id` int(11) NOT NULL AUTO_INCREMENT,
5686
  `course_id` int(11) NOT NULL,
5687
  `ci_id` int(11) NOT NULL,
5688
  `staff_note` mediumtext,
5689
  `public_note` mediumtext,
5690
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
5691
   PRIMARY KEY (`cr_id`),
5692
   UNIQUE KEY `psuedo_key` (`course_id`,`ci_id`),
5693
   KEY `course_id` (`course_id`)
5694
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
5695
");
5696
5697
$dbh->do("
5698
INSERT INTO permissions (module_bit, code, description) VALUES
5699
  (18, 'manage_courses', 'Add, edit and delete courses'),
5700
  (18, 'add_reserves', 'Add course reserves'),
5701
  (18, 'delete_reserves', 'Remove course reserves')
5702
;
5703
");
5704
5705
    print "Upgrade to $DBversion done (Add Course Reserves ( system preference UseCourseReserves ))\n";
5706
    SetVersion($DBversion);
5707
}
5708
5638
=head1 FUNCTIONS
5709
=head1 FUNCTIONS
5639
5710
5640
=head2 TableExists($table)
5711
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css (-1 / +1 lines)
Lines 809-815 fieldset.rows .inputnote { Link Here
809
    visibility:visible; /* you propably don't need to change this one */
809
    visibility:visible; /* you propably don't need to change this one */
810
    display:block;
810
    display:block;
811
}
811
}
812
#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 {
812
#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 {
813
	padding-left : 34px;
813
	padding-left : 34px;
814
	background-image: url("../../img/toolbar-new.gif");
814
	background-image: url("../../img/toolbar-new.gif");
815
	background-position : center left;
815
	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 439-441 Circulation: Link Here
439
            - and this password
439
            - and this password
440
            - pref: AutoSelfCheckPass
440
            - pref: AutoSelfCheckPass
441
            - .
441
            - .
442
    Course Reserves:
443
        -
444
            - pref: UseCourseReserves
445
              choices:
446
                  yes: Use
447
                  no: "Don't use"
448
            - course reserves
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (+32 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
            [% IF item.course_reserves.course.enabled == 'yes' %]
8
                [% ShowCourseReserves = 1 %]
9
            [% END %]
10
        [% END %]
11
    [% END %]
12
[% END %]
13
1
[% INCLUDE 'doc-head-open.inc' %]
14
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Catalog &rsaquo;
15
<title>Koha &rsaquo; Catalog &rsaquo;
3
  [% IF ( unknownbiblionumber ) %]
16
  [% IF ( unknownbiblionumber ) %]
Lines 285-290 function verify_images() { Link Here
285
        [% IF ( SpineLabelShowPrintOnBibDetails ) %]<th>Spine label</th>[% END %]
298
        [% IF ( SpineLabelShowPrintOnBibDetails ) %]<th>Spine label</th>[% END %]
286
        [% IF ( hostrecords ) %]<th>Host records</th>[% END %]
299
        [% IF ( hostrecords ) %]<th>Host records</th>[% END %]
287
		[% IF ( analyze ) %]<th>Used in</th><th></th>[% END %]
300
		[% IF ( analyze ) %]<th>Used in</th><th></th>[% END %]
301
                [% IF ( ShowCourseReserves ) %]<th>Course Reserves</th>[% END %]
288
            </tr>
302
            </tr>
289
            [% FOREACH itemloo IN itemloop %]
303
            [% FOREACH itemloo IN itemloop %]
290
                <tr>
304
                <tr>
Lines 421-426 function verify_images() { Link Here
421
                        <td><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?hostbiblionumber=[% itemloo.biblionumber %]&amp;hostitemnumber=[% itemloo.itemnumber %]">Create analytics</a></td>
435
                        <td><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?hostbiblionumber=[% itemloo.biblionumber %]&amp;hostitemnumber=[% itemloo.itemnumber %]">Create analytics</a></td>
422
                [% END %]
436
                [% END %]
423
437
438
                [% IF ShowCourseReserves %]
439
                    <td>
440
                        [% IF itemloo.course_reserves %]
441
                            [% FOREACH r IN itemloo.course_reserves %]
442
                                [% IF r.course.enabled == 'yes' %]
443
                                    <p>
444
                                      <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% r.course.course_id %]">
445
                                         [% r.course.course_name %]
446
                                         <!--[% IF r.course.course_number %] [% r.course.course_number %] [% END %]-->
447
                                         [% IF r.course.section %] [% r.course.section %] [% END %]
448
                                         [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) %] [% END %]
449
                                      </a>
450
                                   </p>
451
                               [% END %]
452
                           [% END %]
453
                       [% END %]
454
                    </td>
455
                [% END %]
424
                </tr>
456
                </tr>
425
            [% END %]
457
            [% END %]
426
        </table>
458
        </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 (+179 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
                    <li><a id="edit_course" href="/cgi-bin/koha/course_reserves/course.pl?course_id=[% course.course_id %]">Edit Course</a></li>
52
                    <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>
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
                                [% END %]
103
                            </td>
104
                            <td>
105
                                 [% IF cr.course_item.ccode %]
106
                                     [% IF cr.course_item.enabled == 'yes' %]
107
                                          [% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %]
108
                                     [% ELSE %]
109
                                         [% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode ) %]
110
                                     [% END %]
111
                                 [% ELSE %]
112
                                     <i>Unchanged</i>
113
                                 [% END %]
114
                            </td>
115
                            <td>
116
                                [% IF cr.course_item.location %]
117
                                     [% IF cr.course_item.enabled == 'yes' %]
118
                                         [% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %]
119
                                    [% ELSE %]
120
                                        [% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) %]
121
                                    [% END %]
122
                                [% ELSE %]
123
                                    <i>Unchanged</i>
124
                                [% END %]
125
                            </td>
126
                            <td>
127
                                [% IF cr.course_item.holdingbranch %]
128
                                    [% IF cr.course_item.enabled == 'yes' %]
129
                                        [% Branches.GetName( cr.item.holdingbranch ) %]
130
                                    [% ELSE %]
131
                                        [% Branches.GetName( cr.course_item.holdingbranch ) %]
132
                                    [% END %]
133
                                [% ELSE %]
134
                                    <i>Unchanged</i>
135
                                [% END %]
136
                            </td>
137
                            <td>[% cr.staff_note %]</td>
138
                            <td>[% cr.public_note %]</td>
139
140
                            [% IF CAN_user_coursereserves_add_reserves %]
141
                                <td><a href="add_items.pl?course_id=[% course.course_id %]&barcode=[% cr.item.barcode %]&action=lookup">Edit</a></td>
142
                            [% END %]
143
144
                            [% IF CAN_user_coursereserves_delete_reserves %]
145
                                <td>
146
                                    [% IF cr.item.onloan %]
147
                                        On Loan
148
                                    [% ELSIF cr.item.itemlost %]
149
                                        Item Lost
150
                                    [% ELSE %]
151
                                        <a href="course-details.pl?course_id=[% course.course_id %]&action=del_reserve&cr_id=[% cr.cr_id %]" onclick="return confirmItemDelete()" >Remove</a>
152
                                    [% END %]
153
154
                                </td>
155
                            [% END %]
156
157
                            <td>
158
                                [% FOREACH course IN cr.courses %]
159
                                    [% UNLESS cr.course_id == course.course_id %]
160
                                        <p>
161
                                            <a href="course-details.pl?course_id=[% course.course_id %]">
162
                                                [% course.course_name %]
163
                                                [% IF course.section %] [% course.section %] [% END %]
164
                                                [% IF course.term %] [% AuthorisedValues.GetByCode( 'TERM', course.term ) %] [% END %]
165
                                            </a>
166
                                        </p>
167
                                    [% END %]
168
                                [% END %]
169
                            </td>
170
                        </tr>
171
                    [% END %]
172
                </tbody>
173
            </table>
174
        </div>
175
    </div>
176
</div>
177
178
179
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt (+102 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
                            <li><a id="new_course" href="/cgi-bin/koha/course_reserves/course.pl">New Course</a></li>
30
                        </ul>
31
                    </div><!-- /toolbar -->
32
33
                    <div id="search-toolbar">
34
                        <script type="text/javascript">
35
                        //<![CDATA[
36
                            function submitSearchForm(p_oEvent){
37
                                $('#search_courses_form').submit();
38
                            }
39
40
                            $(document).ready(function(){
41
                                newCourseButton = new YAHOO.widget.Button("search_courses");
42
                                newCourseButton.on("click", submitSearchForm );
43
                            });
44
                        //]]>
45
                        </script>
46
                        <ul class="toolbar">
47
                            <li><form id="search_courses_form"><input type="text" name="search_on" id="search_on"></form></li>
48
                            <li><a id="search_courses">Search Courses</a></li>
49
                        </ul>
50
                    </div><!-- /toolbar -->
51
52
                    <h1>Courses</h1>
53
                    <table id="course_reserves_table">
54
                        <thead>
55
                            <tr>
56
                                <th>Name</th>
57
                                <th>Dept.</th>
58
                                <th>Course #</th>
59
                                <th>Section</th>
60
                                <th>Term</th>
61
                                <th>Instructors</th>
62
                                <th>Staff Note</th>
63
                                <th>Public Note</th>
64
                                <th># of Students</th>
65
                                <th>Enabled</th>
66
                            </tr>
67
                        </thead>
68
69
                        <tbody>
70
                            [% FOREACH c IN courses %]
71
                                <tr>
72
                                    <td><a href="course-details.pl?course_id=[% c.course_id %]">[% c.course_name %]</a></td>
73
                                    <td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', c.department ) %]</td>
74
                                    <td>[% c.course_number %]</td>
75
                                    <td>[% c.section %]</td>
76
                                    <td>[% AuthorisedValues.GetByCode( 'TERM' c.term ) %]</td>
77
                                    <td>
78
                                        [% FOREACH i IN c.instructors %]
79
                                            <div class="instructor"><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% i.borrowernumber %]">[% i.firstname %] [% i.surname %]</a></div>
80
                                        [% END %]
81
                                    </td>
82
                                    <td>[% c.staff_note %]</td>
83
                                    <td>[% c.public_note %]</td>
84
                                    <td>[% c.students_count %]</td>
85
                                    <td>
86
                                        [% IF c.enabled == 'yes' %]
87
                                            <img src="/intranet-tmpl/prog/img/approve.gif" />
88
                                        [% ELSE %]
89
                                            <img src="http://kohadev:8080/intranet-tmpl/prog/img/deny.gif" />
90
                                        [% END %]
91
                                    </td>
92
                            [% END %]
93
                        </tbody>
94
                    </table>
95
                </div>
96
            </div>
97
        </div>
98
    </div>
99
</div>
100
101
102
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt (+229 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
YAHOO.util.Event.onContentReady("find_instructor", function() {
40
    new function() {
41
        // Define a custom formatter function
42
        this.fnCustomFormatter = function(oResultItem, sQuery) {
43
            var name        = oResultItem[0];
44
            var cardnumber  = oResultItem[1];
45
            var address     = oResultItem[2];
46
            var city        = oResultItem[3];
47
            var zip         = oResultItem[4];
48
49
            var aMarkup = [
50
                "<div class=\"sample-result\">",
51
                name,
52
                " (",
53
                cardnumber,
54
                ")<small> -- ",
55
                address,
56
                ", ",
57
                city,
58
                "<\/small>",
59
                "<\/div>"];
60
            return (aMarkup.join(""));
61
        };
62
63
        // Instantiate one XHR DataSource and define schema as an array:
64
        //     ["Record Delimiter",
65
        //     "Field Delimiter"]
66
        this.oACDS = new YAHOO.widget.DS_XHR("/cgi-bin/koha/circ/ysearch.pl", ["\n", "\t"]);
67
        this.oACDS.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
68
        this.oACDS.maxCacheEntries = 60;
69
        this.oACDS.queryMatchSubset = true;
70
71
        // Instantiate first AutoComplete
72
        var myInput = document.getElementById('find_instructor');
73
        var myContainer = document.getElementById('find_instructor_container');
74
        this.oAutoComp = new YAHOO.widget.AutoComplete(myInput,myContainer,this.oACDS);
75
        this.oAutoComp.formatResult = this.fnCustomFormatter;
76
77
        var myHandler = function(sType, aArgs) {
78
	        var myAC = aArgs[0]; // reference back to the AC instance
79
	        var elLI = aArgs[1]; // reference to the selected LI element
80
	        var oData = aArgs[2]; // object literal of selected item's result data
81
82
                AddInstructor( oData[0], oData[1] );
83
	};
84
85
        this.oAutoComp.itemSelectEvent.subscribe( myHandler );
86
}
87
});
88
89
function AddInstructor( name, cardnumber ) {
90
    div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' onclick='RemoveInstructor(" + cardnumber + ");'> Remove </a> ) <input type='hidden' name='instructors' value='" + cardnumber + "' /></div>";
91
    $('#instructors').append( div );
92
93
    $('#find_instructor').val('').focus();
94
}
95
96
function RemoveInstructor( cardnumber ) {
97
    $( '#borrower_' + cardnumber ).remove();
98
}
99
100
//]]>
101
</script>
102
103
</head>
104
105
<body>
106
107
[% INCLUDE 'header.inc' %]
108
[% INCLUDE 'cat-search.inc' %]
109
110
<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>
111
112
<div id="doc2" class="yui-t7">
113
    <div id="bd">
114
        <div id="yui-main">
115
            <div class="yui-b">
116
                <div class="yui-g">
117
                    <div class="yui-u first">
118
                        <form method="post" action="/cgi-bin/koha/course_reserves/mod_course.pl">
119
                            [% IF course_id %]<input type="hidden" name="course_id" value="[% course_id %]" />[% END %]
120
                            <fieldset class="rows">
121
                                <legend>[% IF course_id %] Edit [% ELSE %] Create [% END %] course</legend>
122
                                <ol>
123
                                    <li>
124
                                        <label class="required" for="department">Department:</label>
125
                                        <select id="department" name="department">
126
                                            <option value="">Select A Department</option>
127
128
                                            [% FOREACH d IN departments %]
129
                                                [% IF d.authorised_value == department %]
130
                                                    <option value="[% d.authorised_value %]" selected="selected">[% d.lib %]</option>
131
                                                [% ELSE %]
132
                                                    <option value="[% d.authorised_value %]">[% d.lib %]</option>
133
                                                [% END %]
134
                                            [% END %]
135
                                        </select>
136
                                    </li>
137
138
                                    <li>
139
                                        <label class="required" for="course_number">Course number:</label>
140
                                        <input id="course_number" name="course_number" type="text" value="[% course_number %]" />
141
                                    </li>
142
143
                                    <li>
144
                                        <label for="section">Section:</label>
145
                                        <input id="section" name="section" type="text" value="[% section %]"/>
146
                                    </li>
147
148
                                    <li>
149
                                        <label class="required" for="course_name">Course name:</label>
150
                                        <input id="course_name" name="course_name" type="text" value="[% course_name %]" />
151
                                    </li>
152
153
                                    <li>
154
                                        <label for="term">Term:</label>
155
                                        <select id="term" name="term">
156
                                            <option value=""></option>
157
158
                                            [% FOREACH t IN terms %]
159
                                                [% IF t.authorised_value == term %]
160
                                                    <option value="[% t.authorised_value %]" selected="selected">[% t.lib %]</option>
161
                                                [% ELSE %]
162
                                                    <option value="[% t.authorised_value %]">[% t.lib %]</option>
163
                                                [% END %]
164
                                            [% END %]
165
                                        </select>
166
                                    </li>
167
168
                                    <!-- TODO: Add Instructors -->
169
                                    <li>
170
                                        <label for="instructors">Instructors:</label>
171
172
                                        <fieldset>
173
                                             <div id="instructors">
174
                                                 [% FOREACH i IN instructors %]
175
                                                     <div id="borrower_[% i.cardnumber %]">
176
                                                         [% i.surname %], [% i.firstname %] ( <a href='#' onclick='RemoveInstructor( [% i.cardnumber %] );'> Remove </a> )
177
                                                         <input type='hidden' name='instructors' value='[% i.cardnumber %]' />
178
                                                     </div>
179
                                                 [% END %]
180
                                             </div>
181
182
                                        </fieldset>
183
184
                                        <fieldset>
185
                                            <label for="find_instructor">Instructor Search:</label>
186
                                            <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit"/>
187
                                            <div id="find_instructor_container"></div>
188
                                        </fieldset>
189
                                    <li>
190
                                        <label for="staff_note">Staff note:</label>
191
                                        <textarea name="staff_note" id="staff_note">[% staff_note %]</textarea>
192
                                    </li>
193
194
                                    <li>
195
                                        <label for="public_note">Public note:</label>
196
                                        <textarea name="public_note" id="public_note">[% public_note %]</textarea>
197
                                    </li>
198
199
                                    <li>
200
                                        <label for="students_count">Number of students:</label>
201
                                        <input id="students_count" name="students_count" type="text" value="[% students_count %]" />
202
                                    </li>
203
204
                                    <li>
205
                                        <label for="enabled">Enabled?</label>
206
                                        [% IF enabled == 'no' %]
207
                                            <input type="checkbox" name="enabled" id="enabled" />
208
                                        [% ELSE %]
209
                                            <input type="checkbox" name="enabled" id="enabled" checked="checked" />
210
                                        [% END %]
211
                                    </li>
212
                                </ol>
213
                            </fieldset>
214
215
                            <fieldset class="action">
216
                                <input type="submit" onclick="Check(this.form); return false;" value="Save" class="submit" />
217
218
                                <a href="/cgi-bin/koha/course_reserves/course-reserves.pl" class="cancel">Cancel</a>
219
                            </fieldset>
220
221
                    </div>
222
                </div>
223
            </div>
224
        </div>
225
    </div>
226
</div>
227
228
229
[% 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 (+28 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
            [% ShowCourseReservesHeader = 1 %]
9
        [% END %]
10
    [% END %]
11
[% END %]
2
12
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 %]
13
[% 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' %]
14
[% INCLUDE 'doc-head-close.inc' %]
Lines 724-729 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
724
        [% ELSIF show_priority %]
734
        [% ELSIF show_priority %]
725
            <th>Item hold queue priority</th>
735
            <th>Item hold queue priority</th>
726
        [% END %]
736
        [% END %]
737
            [% IF ( ShowCourseReservesHeader ) %]<th id="item_coursereserves">Course Reserves</th>[% END %]
727
        </tr></thead>
738
        </tr></thead>
728
	    <tbody>[% FOREACH ITEM_RESULT IN ITEM_RESULTS %]
739
	    <tbody>[% FOREACH ITEM_RESULT IN ITEM_RESULTS %]
729
	    <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 %]
740
	    <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 761-766 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
761
            [% END %]
772
            [% END %]
762
                </td>
773
                </td>
763
        [% END %]
774
        [% END %]
775
776
        [% IF UseCourseReserves %]
777
            <td>
778
                [% IF ITEM_RESULT.course_reserves %]
779
                    [% FOREACH r IN ITEM_RESULT.course_reserves %]
780
                        <p>
781
                            <a href="opac-course-details.pl?course_id=[% r.course.course_id %]">
782
                                [% r.course.course_name %]
783
                                <!--[% IF r.course.course_number %] [% r.course.course_number %] [% END %]-->
784
                                [% IF r.course.section %] [% r.course.section %] [% END %]
785
                                [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) %] [% END %]
786
                            </a>
787
                        </p>
788
                    [% END %]
789
                [% END %]
790
            </td>
791
        [% END %]
764
	    </tr>
792
	    </tr>
765
	    [% END %]</tbody>
793
	    [% END %]</tbody>
766
	</table>
794
	</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 / +6 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 1000-1003 if (C4::Context->preference('OPACLocalCoverImages') == 1) { Link Here
1000
    $template->{VARS}->{localimages} = \@images;
1001
    $template->{VARS}->{localimages} = \@images;
1001
}
1002
}
1002
1003
1004
if ( C4::Context->preference('UseCourseReserves') ) {
1005
    foreach my $i ( @items ) {
1006
        $i->{'course_reserves'} = GetItemReservesInfo( itemnumber => $i->{'itemnumber'} );
1007
    }
1008
}
1003
output_html_with_http_headers $query, $cookie, $template->output;
1009
output_html_with_http_headers $query, $cookie, $template->output;
1004
- 

Return to bug 8215