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

(-)a/C4/Auth.pm (+2 lines)
Lines 205-210 sub get_template_and_user { Link Here
205
            $template->param( CAN_user_reports          => 1 );
205
            $template->param( CAN_user_reports          => 1 );
206
            $template->param( CAN_user_staffaccess      => 1 );
206
            $template->param( CAN_user_staffaccess      => 1 );
207
            $template->param( CAN_user_plugins          => 1 );
207
            $template->param( CAN_user_plugins          => 1 );
208
            $template->param( CAN_user_coursereserves   => 1 );
208
            foreach my $module (keys %$all_perms) {
209
            foreach my $module (keys %$all_perms) {
209
                foreach my $subperm (keys %{ $all_perms->{$module} }) {
210
                foreach my $subperm (keys %{ $all_perms->{$module} }) {
210
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
211
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
Lines 320-325 sub get_template_and_user { Link Here
320
            noItemTypeImages             => C4::Context->preference("noItemTypeImages"),
321
            noItemTypeImages             => C4::Context->preference("noItemTypeImages"),
321
            marcflavour                  => C4::Context->preference("marcflavour"),
322
            marcflavour                  => C4::Context->preference("marcflavour"),
322
            persona                      => C4::Context->preference("persona"),
323
            persona                      => C4::Context->preference("persona"),
324
            UseCourseReserves            => C4::Context->preference("UseCourseReserves"),
323
    );
325
    );
324
    if ( $in->{'type'} eq "intranet" ) {
326
    if ( $in->{'type'} eq "intranet" ) {
325
        $template->param(
327
        $template->param(
(-)a/C4/CourseReserves.pm (+1101 lines)
Line 0 Link Here
1
package C4::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
use C4::Context;
21
use C4::Items qw(GetItem ModItem);
22
use C4::Biblio qw(GetBiblioFromItemNumber);
23
use C4::Circulation qw(GetOpenIssue);
24
25
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG @FIELDS);
26
27
BEGIN {
28
    require Exporter;
29
    @ISA       = qw(Exporter);
30
    @EXPORT_OK = qw(
31
      &GetCourse
32
      &ModCourse
33
      &GetCourses
34
      &DelCourse
35
36
      &GetCourseInstructors
37
      &ModCourseInstructors
38
39
      &GetCourseItem
40
      &ModCourseItem
41
42
      &GetCourseReserve
43
      &ModCourseReserve
44
      &GetCourseReserves
45
      &DelCourseReserve
46
47
      &SearchCourses
48
49
      &GetItemCourseReservesInfo
50
    );
51
    %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
52
53
    $DEBUG = 0;
54
    @FIELDS = ( 'itype', 'ccode', 'holdingbranch', 'location' );
55
}
56
57
=head1 NAME
58
59
C4::CourseReserves - Koha course reserves module
60
61
=head1 SYNOPSIS
62
63
use C4::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 course_instructors
214
        WHERE course_id = ?
215
    ";
216
    C4::Context->dbh->do( $query, undef, $course_id );
217
218
    $query = "
219
        DELETE FROM courses
220
        WHERE course_id = ?
221
    ";
222
    C4::Context->dbh->do( $query, undef, $course_id );
223
}
224
225
=head2 EnableOrDisableCourseItems
226
227
  EnableOrDisableCourseItems( course_id => $course_id, enabled => $enabled );
228
229
  For each item on reserve for this course,
230
  if the course item has no active course reserves,
231
  swap the fields for the item to make it 'normal'
232
  again.
233
234
  enabled => 'yes' to enable course items
235
  enabled => 'no' to disable course items
236
237
=cut
238
239
sub EnableOrDisableCourseItems {
240
    my (%params) = @_;
241
    warn identify_myself(%params) if $DEBUG;
242
243
    my $course_id = $params{'course_id'};
244
    my $enabled = $params{'enabled'} || 0;
245
246
    my $lookfor = ( $enabled eq 'yes' ) ? 'no' : 'yes';
247
248
    return unless ( $course_id && $enabled );
249
    return unless ( $enabled eq 'yes' || $enabled eq 'no' );
250
251
    my $course_reserves = GetCourseReserves( course_id => $course_id );
252
253
    if ( $enabled eq 'yes' ) {
254
        foreach my $course_reserve (@$course_reserves) {
255
            if (CountCourseReservesForItem(
256
                    ci_id   => $course_reserve->{'ci_id'},
257
                    enabled => 'yes'
258
                )
259
              ) {
260
                EnableOrDisableCourseItem(
261
                    ci_id   => $course_reserve->{'ci_id'},
262
                    enabled => 'yes',
263
                );
264
            }
265
        }
266
    }
267
    if ( $enabled eq 'no' ) {
268
        foreach my $course_reserve (@$course_reserves) {
269
            unless (
270
                CountCourseReservesForItem(
271
                    ci_id   => $course_reserve->{'ci_id'},
272
                    enabled => 'yes'
273
                )
274
              ) {
275
                EnableOrDisableCourseItem(
276
                    ci_id   => $course_reserve->{'ci_id'},
277
                    enabled => 'no',
278
                );
279
            }
280
        }
281
    }
282
}
283
284
=head2 EnableOrDisableCourseItem
285
286
    EnableOrDisableCourseItem( ci_id => $ci_id, enabled => $enabled );
287
288
    enabled => 'yes' to enable course items
289
    enabled => 'no' to disable course items
290
291
=cut
292
293
sub EnableOrDisableCourseItem {
294
    my (%params) = @_;
295
    warn identify_myself(%params) if $DEBUG;
296
297
    my $ci_id   = $params{'ci_id'};
298
    my $enabled = $params{'enabled'};
299
300
    return unless ( $ci_id && $enabled );
301
    return unless ( $enabled eq 'yes' || $enabled eq 'no' );
302
303
    my $course_item = GetCourseItem( ci_id => $ci_id );
304
305
    ## We don't want to 'enable' an already enabled item,
306
    ## or disable and already disabled item,
307
    ## as that would cause the fields to swap
308
    if ( $course_item->{'enabled'} ne $enabled ) {
309
        _SwapAllFields($ci_id);
310
311
        my $query = "
312
            UPDATE course_items
313
            SET enabled = ?
314
            WHERE ci_id = ?
315
        ";
316
317
        C4::Context->dbh->do( $query, undef, $enabled, $ci_id );
318
319
    }
320
321
}
322
323
=head2 GetCourseInstructors
324
325
    @$borrowers = GetCourseInstructors( $course_id );
326
327
=cut
328
329
sub GetCourseInstructors {
330
    my ($course_id) = @_;
331
    warn "C4::CourseReserves::GetCourseInstructors( $course_id )"
332
      if $DEBUG;
333
334
    my $query = "
335
        SELECT * FROM borrowers
336
        RIGHT JOIN course_instructors ON ( course_instructors.borrowernumber = borrowers.borrowernumber )
337
        WHERE course_instructors.course_id = ?
338
    ";
339
340
    my $dbh = C4::Context->dbh;
341
    my $sth = $dbh->prepare($query);
342
    $sth->execute($course_id);
343
344
    return $sth->fetchall_arrayref( {} );
345
}
346
347
=head2 ModCourseInstructors
348
349
    ModCourseInstructors( mode => $mode, course_id => $course_id, [ cardnumbers => $cardnumbers ] OR [ borrowernumbers => $borrowernumbers  );
350
351
    $mode can be 'replace', 'add', or 'delete'
352
353
    $cardnumbers and $borrowernumbers are both references to arrays
354
355
    Use either cardnumbers or borrowernumber, but not both.
356
357
=cut
358
359
sub ModCourseInstructors {
360
    my (%params) = @_;
361
    warn identify_myself(%params) if $DEBUG;
362
363
    my $course_id       = $params{'course_id'};
364
    my $mode            = $params{'mode'};
365
    my $cardnumbers     = $params{'cardnumbers'};
366
    my $borrowernumbers = $params{'borrowernumbers'};
367
368
    return unless ($course_id);
369
    return
370
      unless ( $mode eq 'replace'
371
        || $mode eq 'add'
372
        || $mode eq 'delete' );
373
    return unless ( $cardnumbers || $borrowernumbers );
374
    return if ( $cardnumbers && $borrowernumbers );
375
376
    my ( @cardnumbers, @borrowernumbers );
377
    @cardnumbers = @$cardnumbers if ( ref($cardnumbers) eq 'ARRAY' );
378
    @borrowernumbers = @$borrowernumbers
379
      if ( ref($borrowernumbers) eq 'ARRAY' );
380
381
    my $field  = (@cardnumbers) ? 'cardnumber' : 'borrowernumber';
382
    my @fields = (@cardnumbers) ? @cardnumbers : @borrowernumbers;
383
    my $placeholders = join( ',', ('?') x scalar @fields );
384
385
    my $dbh = C4::Context->dbh;
386
387
    $dbh->do( "DELETE FROM course_instructors WHERE course_id = ?", undef, $course_id )
388
      if ( $mode eq 'replace' );
389
390
    my $query;
391
392
    if ( $mode eq 'add' || $mode eq 'replace' ) {
393
        $query = "
394
            INSERT INTO course_instructors ( course_id, borrowernumber )
395
            SELECT ?, borrowernumber
396
            FROM borrowers
397
            WHERE $field IN ( $placeholders )
398
        ";
399
    } else {
400
        $query = "
401
            DELETE FROM course_instructors
402
            WHERE course_id = ?
403
            AND borrowernumber IN (
404
                SELECT borrowernumber FROM borrowers WHERE $field IN ( $placeholders )
405
            )
406
        ";
407
    }
408
409
    my $sth = $dbh->prepare($query);
410
411
    $sth->execute( $course_id, @fields ) if (@fields);
412
}
413
414
=head2 GetCourseItem {
415
416
  $course_item = GetCourseItem( itemnumber => $itemnumber [, ci_id => $ci_id );
417
418
=cut
419
420
sub GetCourseItem {
421
    my (%params) = @_;
422
    warn identify_myself(%params) if $DEBUG;
423
424
    my $ci_id      = $params{'ci_id'};
425
    my $itemnumber = $params{'itemnumber'};
426
427
    return unless ( $itemnumber || $ci_id );
428
429
    my $field = ($itemnumber) ? 'itemnumber' : 'ci_id';
430
    my $value = ($itemnumber) ? $itemnumber  : $ci_id;
431
432
    my $query = "SELECT * FROM course_items WHERE $field = ?";
433
    my $dbh   = C4::Context->dbh;
434
    my $sth   = $dbh->prepare($query);
435
    $sth->execute($value);
436
437
    my $course_item = $sth->fetchrow_hashref();
438
439
    if ($course_item) {
440
        $query = "SELECT * FROM course_reserves WHERE ci_id = ?";
441
        $sth   = $dbh->prepare($query);
442
        $sth->execute( $course_item->{'ci_id'} );
443
        my $course_reserves = $sth->fetchall_arrayref( {} );
444
445
        $course_item->{'course_reserves'} = $course_reserves
446
          if ($course_reserves);
447
    }
448
    return $course_item;
449
}
450
451
=head2 ModCourseItem {
452
453
  ModCourseItem( %params );
454
455
  Creates or modifies an existing course item.
456
457
=cut
458
459
sub ModCourseItem {
460
    my (%params) = @_;
461
    warn identify_myself(%params) if $DEBUG;
462
463
    my $itemnumber    = $params{'itemnumber'};
464
    my $itype         = $params{'itype'};
465
    my $ccode         = $params{'ccode'};
466
    my $holdingbranch = $params{'holdingbranch'};
467
    my $location      = $params{'location'};
468
469
    return unless ($itemnumber);
470
471
    my $course_item = GetCourseItem( itemnumber => $itemnumber );
472
473
    my $ci_id;
474
475
    if ($course_item) {
476
        $ci_id = $course_item->{'ci_id'};
477
478
        _UpdateCourseItem(
479
            ci_id       => $ci_id,
480
            course_item => $course_item,
481
            %params
482
        );
483
    } else {
484
        $ci_id = _AddCourseItem(%params);
485
    }
486
487
    return $ci_id;
488
489
}
490
491
=head2 _AddCourseItem
492
493
    my $ci_id = _AddCourseItem( %params );
494
495
=cut
496
497
sub _AddCourseItem {
498
    my (%params) = @_;
499
    warn identify_myself(%params) if $DEBUG;
500
501
    my ( @fields, @values );
502
503
    push( @fields, 'itemnumber = ?' );
504
    push( @values, $params{'itemnumber'} );
505
506
    foreach (@FIELDS) {
507
        if ( $params{$_} ) {
508
            push( @fields, "$_ = ?" );
509
            push( @values, $params{$_} );
510
        }
511
    }
512
513
    my $query = "INSERT INTO course_items SET " . join( ',', @fields );
514
    my $dbh = C4::Context->dbh;
515
    $dbh->do( $query, undef, @values );
516
517
    my $ci_id = $dbh->last_insert_id( undef, undef, 'course_items', 'ci_id' );
518
519
    return $ci_id;
520
}
521
522
=head2 _UpdateCourseItem
523
524
  _UpdateCourseItem( %params );
525
526
=cut
527
528
sub _UpdateCourseItem {
529
    my (%params) = @_;
530
    warn identify_myself(%params) if $DEBUG;
531
532
    my $ci_id         = $params{'ci_id'};
533
    my $course_item   = $params{'course_item'};
534
    my $itype         = $params{'itype'};
535
    my $ccode         = $params{'ccode'};
536
    my $holdingbranch = $params{'holdingbranch'};
537
    my $location      = $params{'location'};
538
539
    return unless ( $ci_id || $course_item );
540
541
    $course_item = GetCourseItem( ci_id => $ci_id )
542
      unless ($course_item);
543
    $ci_id = $course_item->{'ci_id'} unless ($ci_id);
544
545
    ## Revert fields that had an 'original' value, but now don't
546
    ## Update the item fields to the stored values from course_items
547
    ## and then set those fields in course_items to NULL
548
    my @fields_to_revert;
549
    foreach (@FIELDS) {
550
        if ( !$params{$_} && $course_item->{$_} ) {
551
            push( @fields_to_revert, $_ );
552
        }
553
    }
554
    _RevertFields(
555
        ci_id       => $ci_id,
556
        fields      => \@fields_to_revert,
557
        course_item => $course_item
558
    ) if (@fields_to_revert);
559
560
    ## Update fields that still have an original value, but it has changed
561
    ## This necessitates only changing the current item values, as we still
562
    ## have the original values stored in course_items
563
    my %mod_params;
564
    foreach (@FIELDS) {
565
        if (   $params{$_}
566
            && $course_item->{$_}
567
            && $params{$_} ne $course_item->{$_} ) {
568
            $mod_params{$_} = $params{$_};
569
        }
570
    }
571
    ModItem( \%mod_params, undef, $course_item->{'itemnumber'} ) if %mod_params;
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'} ) if %mod_params_new;
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 = "UPDATE course_items SET " . join( ',', map { "$_=?" } @fields_to_update ) . " WHERE ci_id = ?";
615
616
    C4::Context->dbh->do( $query, undef, @values_to_update, $params{'ci_id'} )
617
      if (@values_to_update);
618
619
}
620
621
=head2 _RevertFields
622
623
    _RevertFields( ci_id => $ci_id, fields => \@fields_to_revert );
624
625
=cut
626
627
sub _RevertFields {
628
    my (%params) = @_;
629
    warn identify_myself(%params) if $DEBUG;
630
631
    my $ci_id       = $params{'ci_id'};
632
    my $course_item = $params{'course_item'};
633
    my $fields      = $params{'fields'};
634
    my @fields      = @$fields;
635
636
    return unless ($ci_id);
637
638
    $course_item = GetCourseItem( ci_id => $params{'ci_id'} )
639
      unless ($course_item);
640
641
    my $mod_item_params;
642
    my @fields_to_null;
643
    foreach my $field (@fields) {
644
        foreach (@FIELDS) {
645
            if ( $field eq $_ && $course_item->{$_} ) {
646
                $mod_item_params->{$_} = $course_item->{$_};
647
                push( @fields_to_null, $_ );
648
            }
649
        }
650
    }
651
    ModItem( $mod_item_params, undef, $course_item->{'itemnumber'} ) if $mod_item_params && %$mod_item_params;
652
653
    my $query = "UPDATE course_items SET " . join( ',', map { "$_=NULL" } @fields_to_null ) . " WHERE ci_id = ?";
654
655
    C4::Context->dbh->do( $query, undef, $ci_id ) if (@fields_to_null);
656
}
657
658
=head2 _SwapAllFields
659
660
    _SwapAllFields( $ci_id );
661
662
=cut
663
664
sub _SwapAllFields {
665
    my ($ci_id) = @_;
666
    warn "C4::CourseReserves::_SwapFields( $ci_id )" if $DEBUG;
667
668
    my $course_item = GetCourseItem( ci_id => $ci_id );
669
    my $item = GetItem( $course_item->{'itemnumber'} );
670
671
    my %course_item_fields;
672
    my %item_fields;
673
    foreach (@FIELDS) {
674
        if ( $course_item->{$_} ) {
675
            $course_item_fields{$_} = $course_item->{$_};
676
            $item_fields{$_}        = $item->{$_};
677
        }
678
    }
679
680
    ModItem( \%course_item_fields, undef, $course_item->{'itemnumber'} ) if %course_item_fields;
681
    _ModStoredFields( %item_fields, ci_id => $ci_id );
682
}
683
684
=head2 GetCourseItems {
685
686
  $course_items = GetCourseItems(
687
      [course_id => $course_id]
688
      [, itemnumber => $itemnumber ]
689
  );
690
691
=cut
692
693
sub GetCourseItems {
694
    my (%params) = @_;
695
    warn identify_myself(%params) if $DEBUG;
696
697
    my $course_id  = $params{'course_id'};
698
    my $itemnumber = $params{'itemnumber'};
699
700
    return unless ($course_id);
701
702
    my @query_keys;
703
    my @query_values;
704
705
    my $query = "SELECT * FROM course_items";
706
707
    if ( keys %params ) {
708
709
        $query .= " WHERE ";
710
711
        foreach my $key ( keys %params ) {
712
            push( @query_keys,   " $key LIKE ? " );
713
            push( @query_values, $params{$key} );
714
        }
715
716
        $query .= join( ' AND ', @query_keys );
717
    }
718
719
    my $dbh = C4::Context->dbh;
720
    my $sth = $dbh->prepare($query);
721
    $sth->execute(@query_values);
722
723
    return $sth->fetchall_arrayref( {} );
724
}
725
726
=head2 DelCourseItem {
727
728
  DelCourseItem( ci_id => $cr_id );
729
730
=cut
731
732
sub DelCourseItem {
733
    my (%params) = @_;
734
    warn identify_myself(%params) if $DEBUG;
735
736
    my $ci_id = $params{'ci_id'};
737
738
    return unless ($ci_id);
739
740
    _RevertFields( ci_id => $ci_id, fields => \@FIELDS );
741
742
    my $query = "
743
        DELETE FROM course_items
744
        WHERE ci_id = ?
745
    ";
746
    C4::Context->dbh->do( $query, undef, $ci_id );
747
}
748
749
=head2 GetCourseReserve {
750
751
  $course_item = GetCourseReserve( %params );
752
753
=cut
754
755
sub GetCourseReserve {
756
    my (%params) = @_;
757
    warn identify_myself(%params) if $DEBUG;
758
759
    my $cr_id     = $params{'cr_id'};
760
    my $course_id = $params{'course_id'};
761
    my $ci_id     = $params{'ci_id'};
762
763
    return unless ( $cr_id || ( $course_id && $ci_id ) );
764
765
    my $dbh = C4::Context->dbh;
766
    my $sth;
767
768
    if ($cr_id) {
769
        my $query = "
770
            SELECT * FROM course_reserves
771
            WHERE cr_id = ?
772
        ";
773
        $sth = $dbh->prepare($query);
774
        $sth->execute($cr_id);
775
    } else {
776
        my $query = "
777
            SELECT * FROM course_reserves
778
            WHERE course_id = ? AND ci_id = ?
779
        ";
780
        $sth = $dbh->prepare($query);
781
        $sth->execute( $course_id, $ci_id );
782
    }
783
784
    my $course_reserve = $sth->fetchrow_hashref();
785
    return $course_reserve;
786
}
787
788
=head2 ModCourseReserve
789
790
    $id = ModCourseReserve( %params );
791
792
=cut
793
794
sub ModCourseReserve {
795
    my (%params) = @_;
796
    warn identify_myself(%params) if $DEBUG;
797
798
    my $course_id   = $params{'course_id'};
799
    my $ci_id       = $params{'ci_id'};
800
    my $staff_note  = $params{'staff_note'};
801
    my $public_note = $params{'public_note'};
802
803
    return unless ( $course_id && $ci_id );
804
805
    my $course_reserve = GetCourseReserve( course_id => $course_id, ci_id => $ci_id );
806
    my $cr_id;
807
808
    my $dbh = C4::Context->dbh;
809
810
    if ($course_reserve) {
811
        $cr_id = $course_reserve->{'cr_id'};
812
813
        my $query = "
814
            UPDATE course_reserves
815
            SET staff_note = ?, public_note = ?
816
            WHERE cr_id = ?
817
        ";
818
        $dbh->do( $query, undef, $staff_note, $public_note, $cr_id );
819
    } else {
820
        my $query = "
821
            INSERT INTO course_reserves SET
822
            course_id = ?,
823
            ci_id = ?,
824
            staff_note = ?,
825
            public_note = ?
826
        ";
827
        $dbh->do( $query, undef, $course_id, $ci_id, $staff_note, $public_note );
828
        $cr_id = $dbh->last_insert_id( undef, undef, 'course_reserves', 'cr_id' );
829
    }
830
831
    my $course = GetCourse($course_id);
832
    EnableOrDisableCourseItem(
833
        ci_id   => $params{'ci_id'},
834
        enabled => $course->{'enabled'}
835
    );
836
837
    return $cr_id;
838
}
839
840
=head2 GetCourseReserves {
841
842
  $course_reserves = GetCourseReserves( %params );
843
844
  Required:
845
      course_id OR ci_id
846
  Optional:
847
      include_items   => 1,
848
      include_count   => 1,
849
      include_courses => 1,
850
851
=cut
852
853
sub GetCourseReserves {
854
    my (%params) = @_;
855
    warn identify_myself(%params) if $DEBUG;
856
857
    my $course_id       = $params{'course_id'};
858
    my $ci_id           = $params{'ci_id'};
859
    my $include_items   = $params{'include_items'};
860
    my $include_count   = $params{'include_count'};
861
    my $include_courses = $params{'include_courses'};
862
863
    return unless ( $course_id || $ci_id );
864
865
    my $field = ($course_id) ? 'course_id' : 'ci_id';
866
    my $value = ($course_id) ? $course_id  : $ci_id;
867
868
    my $query = "
869
        SELECT cr.*, ci.itemnumber
870
        FROM course_reserves cr, course_items ci
871
        WHERE cr.$field = ?
872
        AND cr.ci_id = ci.ci_id
873
    ";
874
    my $dbh = C4::Context->dbh;
875
    my $sth = $dbh->prepare($query);
876
    $sth->execute($value);
877
878
    my $course_reserves = $sth->fetchall_arrayref( {} );
879
880
    if ($include_items) {
881
        foreach my $cr (@$course_reserves) {
882
            $cr->{'course_item'} = GetCourseItem( ci_id => $cr->{'ci_id'} );
883
            $cr->{'item'}        = GetBiblioFromItemNumber( $cr->{'itemnumber'} );
884
            $cr->{'issue'}       = GetOpenIssue( $cr->{'itemnumber'} );
885
        }
886
    }
887
888
    if ($include_count) {
889
        foreach my $cr (@$course_reserves) {
890
            $cr->{'reserves_count'} = CountCourseReservesForItem( ci_id => $cr->{'ci_id'} );
891
        }
892
    }
893
894
    if ($include_courses) {
895
        foreach my $cr (@$course_reserves) {
896
            $cr->{'courses'} = GetCourses( itemnumber => $cr->{'itemnumber'} );
897
        }
898
    }
899
900
    return $course_reserves;
901
}
902
903
=head2 DelCourseReserve {
904
905
  DelCourseReserve( cr_id => $cr_id );
906
907
=cut
908
909
sub DelCourseReserve {
910
    my (%params) = @_;
911
    warn identify_myself(%params) if $DEBUG;
912
913
    my $cr_id = $params{'cr_id'};
914
915
    return unless ($cr_id);
916
917
    my $dbh = C4::Context->dbh;
918
919
    my $course_reserve = GetCourseReserve( cr_id => $cr_id );
920
921
    my $query = "
922
        DELETE FROM course_reserves
923
        WHERE cr_id = ?
924
    ";
925
    $dbh->do( $query, undef, $cr_id );
926
927
    ## If there are no other course reserves for this item
928
    ## delete the course_item as well
929
    unless ( CountCourseReservesForItem( ci_id => $course_reserve->{'ci_id'} ) ) {
930
        DelCourseItem( ci_id => $course_reserve->{'ci_id'} );
931
    }
932
933
}
934
935
=head2 GetReservesInfo
936
937
    my $arrayref = GetItemCourseReservesInfo( itemnumber => $itemnumber );
938
939
    For a given item, returns an arrayref of reserves hashrefs,
940
    with a course hashref under the key 'course'
941
942
=cut
943
944
sub GetItemCourseReservesInfo {
945
    my (%params) = @_;
946
    warn identify_myself(%params) if $DEBUG;
947
948
    my $itemnumber = $params{'itemnumber'};
949
950
    return unless ($itemnumber);
951
952
    my $course_item = GetCourseItem( itemnumber => $itemnumber );
953
954
    return unless ( keys %$course_item );
955
956
    my $course_reserves = GetCourseReserves( ci_id => $course_item->{'ci_id'} );
957
958
    foreach my $cr (@$course_reserves) {
959
        $cr->{'course'} = GetCourse( $cr->{'course_id'} );
960
    }
961
962
    return $course_reserves;
963
}
964
965
=head2 CountCourseReservesForItem
966
967
    $bool = CountCourseReservesForItem( %params );
968
969
    ci_id - course_item id
970
    OR
971
    itemnumber - course_item itemnumber
972
973
    enabled = 'yes' or 'no'
974
    Optional, if not supplied, counts reserves
975
    for both enabled and disabled courses
976
977
=cut
978
979
sub CountCourseReservesForItem {
980
    my (%params) = @_;
981
    warn identify_myself(%params) if $DEBUG;
982
983
    my $ci_id      = $params{'ci_id'};
984
    my $itemnumber = $params{'itemnumber'};
985
    my $enabled    = $params{'enabled'};
986
987
    return unless ( $ci_id || $itemnumber );
988
989
    my $course_item = GetCourseItem( ci_id => $ci_id, itemnumber => $itemnumber );
990
991
    my @params = ( $course_item->{'ci_id'} );
992
    push( @params, $enabled ) if ($enabled);
993
994
    my $query = "
995
        SELECT COUNT(*) AS count
996
        FROM course_reserves cr
997
        LEFT JOIN courses c ON ( c.course_id = cr.course_id )
998
        WHERE ci_id = ?
999
    ";
1000
    $query .= "AND c.enabled = ?" if ($enabled);
1001
1002
    my $dbh = C4::Context->dbh;
1003
    my $sth = $dbh->prepare($query);
1004
    $sth->execute(@params);
1005
1006
    my $row = $sth->fetchrow_hashref();
1007
1008
    return $row->{'count'};
1009
}
1010
1011
=head2 SearchCourses
1012
1013
    my $courses = SearchCourses( term => $search_term, enabled => 'yes' );
1014
1015
=cut
1016
1017
sub SearchCourses {
1018
    my (%params) = @_;
1019
    warn identify_myself(%params) if $DEBUG;
1020
1021
    my $term = $params{'term'};
1022
1023
    my $enabled = $params{'enabled'} || '%';
1024
1025
    my @params;
1026
    my $query = "SELECT c.* FROM courses c";
1027
1028
    $query .= "
1029
        LEFT JOIN course_instructors ci
1030
            ON ( c.course_id = ci.course_id )
1031
        LEFT JOIN borrowers b
1032
            ON ( ci.borrowernumber = b.borrowernumber )
1033
        LEFT JOIN authorised_values av
1034
            ON ( c.department = av.authorised_value )
1035
        WHERE
1036
            ( av.category = 'DEPARTMENT' OR av.category = 'TERM' )
1037
            AND
1038
            (
1039
                department LIKE ? OR
1040
                course_number LIKE ? OR
1041
                section LIKE ? OR
1042
                course_name LIKE ? OR
1043
                term LIKE ? OR
1044
                public_note LIKE ? OR
1045
                CONCAT(surname,' ',firstname) LIKE ? OR
1046
                CONCAT(firstname,' ',surname) LIKE ? OR
1047
                lib LIKE ? OR
1048
                lib_opac LIKE ?
1049
           )
1050
           AND
1051
           c.enabled LIKE ?
1052
        GROUP BY c.course_id
1053
    ";
1054
1055
    $term   = "%$term%";
1056
    @params = ($term) x 10;
1057
1058
    $query .= " ORDER BY department, course_number, section, term, course_name ";
1059
1060
    my $dbh = C4::Context->dbh;
1061
    my $sth = $dbh->prepare($query);
1062
1063
    $sth->execute( @params, $enabled );
1064
1065
    my $courses = $sth->fetchall_arrayref( {} );
1066
1067
    foreach my $c (@$courses) {
1068
        $c->{'instructors'} = GetCourseInstructors( $c->{'course_id'} );
1069
    }
1070
1071
    return $courses;
1072
}
1073
1074
sub whoami  { ( caller(1) )[3] }
1075
sub whowasi { ( caller(2) )[3] }
1076
1077
sub stringify_params {
1078
    my (%params) = @_;
1079
1080
    my $string = "\n";
1081
1082
    foreach my $key ( keys %params ) {
1083
        $string .= "    $key => " . $params{$key} . "\n";
1084
    }
1085
1086
    return "( $string )";
1087
}
1088
1089
sub identify_myself {
1090
    my (%params) = @_;
1091
1092
    return whowasi() . stringify_params(%params);
1093
}
1094
1095
1;
1096
1097
=head1 AUTHOR
1098
1099
Kyle M Hall <kyle@bywatersolutions.com>
1100
1101
=cut
(-)a/C4/Koha.pm (-5 / +17 lines)
Lines 206-215 sub GetSupportList{ Link Here
206
}
206
}
207
=head2 GetItemTypes
207
=head2 GetItemTypes
208
208
209
  $itemtypes = &GetItemTypes();
209
  $itemtypes = &GetItemTypes( style => $style );
210
210
211
Returns information about existing itemtypes.
211
Returns information about existing itemtypes.
212
212
213
Params:
214
    style: either 'array' or 'hash', defaults to 'hash'.
215
           'array' returns an arrayref,
216
           'hash' return a hashref with the itemtype value as the key
217
213
build a HTML select with the following code :
218
build a HTML select with the following code :
214
219
215
=head3 in PERL SCRIPT
220
=head3 in PERL SCRIPT
Lines 242-247 build a HTML select with the following code : Link Here
242
=cut
247
=cut
243
248
244
sub GetItemTypes {
249
sub GetItemTypes {
250
    my ( %params ) = @_;
251
    my $style = defined( $params{'style'} ) ? $params{'style'} : 'hash';
245
252
246
    # returns a reference to a hash of references to itemtypes...
253
    # returns a reference to a hash of references to itemtypes...
247
    my %itemtypes;
254
    my %itemtypes;
Lines 252-261 sub GetItemTypes { Link Here
252
    |;
259
    |;
253
    my $sth = $dbh->prepare($query);
260
    my $sth = $dbh->prepare($query);
254
    $sth->execute;
261
    $sth->execute;
255
    while ( my $IT = $sth->fetchrow_hashref ) {
262
256
        $itemtypes{ $IT->{'itemtype'} } = $IT;
263
    if ( $style eq 'hash' ) {
264
        while ( my $IT = $sth->fetchrow_hashref ) {
265
            $itemtypes{ $IT->{'itemtype'} } = $IT;
266
        }
267
        return ( \%itemtypes );
268
    } else {
269
        return $sth->fetchall_arrayref({});
257
    }
270
    }
258
    return ( \%itemtypes );
259
}
271
}
260
272
261
sub get_itemtypeinfos_of {
273
sub get_itemtypeinfos_of {
Lines 1134-1140 sub IsAuthorisedValueCategory { Link Here
1134
1146
1135
=head2 GetAuthorisedValueByCode
1147
=head2 GetAuthorisedValueByCode
1136
1148
1137
$authhorised_value = GetAuthorisedValueByCode( $category, $authvalcode );
1149
$authorised_value = GetAuthorisedValueByCode( $category, $authvalcode, $opac );
1138
1150
1139
Return the lib attribute from authorised_values from the row identified
1151
Return the lib attribute from authorised_values from the row identified
1140
by the passed category and code
1152
by the passed category and code
(-)a/Koha/Template/Plugin/AuthorisedValues.pm (+34 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 Encode qw{encode decode};
26
27
use C4::Koha;
28
29
sub GetByCode {
30
    my ( $self, $category, $code, $opac ) = @_;
31
    return encode( 'UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) );
32
}
33
34
1;
(-)a/Koha/Template/Plugin/Branches.pm (+38 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
use Encode qw{encode decode};
25
26
use C4::Koha;
27
28
sub GetName {
29
    my ( $self, $branchcode ) = @_;
30
31
    my $query = "SELECT branchname FROM branches WHERE branchcode = ?";
32
    my $sth   = C4::Context->dbh->prepare($query);
33
    $sth->execute($branchcode);
34
    my $b = $sth->fetchrow_hashref();
35
    return encode( 'UTF-8', $b->{'branchname'} );
36
}
37
38
1;
(-)a/Koha/Template/Plugin/ItemTypes.pm (+39 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
use Encode qw{encode decode};
25
26
use C4::Koha;
27
28
sub GetDescription {
29
    my ( $self, $itemtype ) = @_;
30
31
    my $query = "SELECT description FROM itemtypes WHERE itemtype = ?";
32
    my $sth   = C4::Context->dbh->prepare($query);
33
    $sth->execute($itemtype);
34
    my $d = $sth->fetchrow_hashref();
35
    return encode( 'UTF-8', $d->{'description'} );
36
37
}
38
39
1;
(-)a/Makefile.PL (+1 lines)
Lines 266-271 my $target_map = { Link Here
266
  './check_sysprefs.pl'         => 'NONE',
266
  './check_sysprefs.pl'         => 'NONE',
267
  './circ'                      => 'INTRANET_CGI_DIR',
267
  './circ'                      => 'INTRANET_CGI_DIR',
268
  './docs/history.txt'          => { target => 'DOC_DIR', trimdir => -1 },
268
  './docs/history.txt'          => { target => 'DOC_DIR', trimdir => -1 },
269
  './course_reserves'           => 'INTRANET_CGI_DIR',
269
  './offline_circ'		=> 'INTRANET_CGI_DIR',
270
  './offline_circ'		=> 'INTRANET_CGI_DIR',
270
  './edithelp.pl'               => 'INTRANET_CGI_DIR',
271
  './edithelp.pl'               => 'INTRANET_CGI_DIR',
271
  './etc'                       => { target => 'KOHA_CONF_DIR', trimdir => -1 },
272
  './etc'                       => { target => 'KOHA_CONF_DIR', trimdir => -1 },
(-)a/admin/authorised_values.pl (-1 / +1 lines)
Lines 247-253 sub default_form { Link Here
247
    }
247
    }
248
248
249
    # push koha system categories
249
    # push koha system categories
250
    foreach (qw(Asort1 Asort2 Bsort1 Bsort2 SUGGEST DAMAGED LOST REPORT_GROUP REPORT_SUBGROUP)) {
250
    foreach (qw(Asort1 Asort2 Bsort1 Bsort2 SUGGEST DAMAGED LOST REPORT_GROUP REPORT_SUBGROUP DEPARTMENT TERM)) {
251
        push @category_list, $_ unless $categories{$_};
251
        push @category_list, $_ unless $categories{$_};
252
    }
252
    }
253
253
(-)a/catalogue/detail.pl (+5 lines)
Lines 41-46 use C4::XSLT; Link Here
41
use C4::Images;
41
use C4::Images;
42
use Koha::DateUtils;
42
use Koha::DateUtils;
43
use C4::HTML5Media;
43
use C4::HTML5Media;
44
use C4::CourseReserves qw(GetItemCourseReservesInfo);
44
45
45
# use Smart::Comments;
46
# use Smart::Comments;
46
47
Lines 269-274 foreach my $item (@items) { Link Here
269
	$materials_flag = 1;
270
	$materials_flag = 1;
270
    }
271
    }
271
272
273
    if ( C4::Context->preference('UseCourseReserves') ) {
274
        $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
275
    }
276
272
    if ($currentbranch and $currentbranch ne "NO_LIBRARY_SET"
277
    if ($currentbranch and $currentbranch ne "NO_LIBRARY_SET"
273
    and C4::Context->preference('SeparateHoldings')) {
278
    and C4::Context->preference('SeparateHoldings')) {
274
        if ($itembranchcode and $itembranchcode eq $currentbranch) {
279
        if ($itembranchcode and $itembranchcode eq $currentbranch) {
(-)a/course_reserves/add_items.pl (+95 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 C4::CourseReserves qw(GetCourse GetCourseItem GetCourseReserve ModCourseItem ModCourseReserve);
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
my $item = GetBiblioFromItemNumber( undef, $barcode );
40
41
my $step = ( $action eq 'lookup' && $item ) ? '2' : '1';
42
43
my $tmpl = ($course_id) ? "add_items-step$step.tt" : "invalid-course.tt";
44
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
45
    {   template_name   => "course_reserves/$tmpl",
46
        query           => $cgi,
47
        type            => "intranet",
48
        authnotrequired => 0,
49
        flagsrequired   => { coursereserves => 'add_reserves' },
50
    }
51
);
52
$template->param( ERROR_BARCODE_NOT_FOUND => $barcode )
53
  unless ( $barcode && $item && $action eq 'lookup' );
54
55
$template->param( course => GetCourse($course_id) );
56
57
if ( $action eq 'lookup' ) {
58
    my $course_item = GetCourseItem( itemnumber => $item->{'itemnumber'} );
59
    my $course_reserve =
60
      ($course_item)
61
      ? GetCourseReserve(
62
        course_id => $course_id,
63
        ci_id     => $course_item->{'ci_id'}
64
      )
65
      : undef;
66
67
    $template->param(
68
        item           => $item,
69
        course_item    => $course_item,
70
        course_reserve => $course_reserve,
71
72
        ccodes    => GetAuthorisedValues('CCODE'),
73
        locations => GetAuthorisedValues('LOC'),
74
        itypes    => GetItemTypes( style => 'array' ),
75
        branches  => GetBranchesLoop(),
76
    );
77
78
} elsif ( $action eq 'add' ) {
79
    my $ci_id = ModCourseItem(
80
        itemnumber    => $cgi->param('itemnumber'),
81
        itype         => $cgi->param('itype'),
82
        ccode         => $cgi->param('ccode'),
83
        holdingbranch => $cgi->param('holdingbranch'),
84
        location      => $cgi->param('location'),
85
    );
86
87
    my $cr_id = ModCourseReserve(
88
        course_id   => $course_id,
89
        ci_id       => $ci_id,
90
        staff_note  => $cgi->param('staff_note'),
91
        public_note => $cgi->param('public_note'),
92
    );
93
}
94
95
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/course_reserves/course-details.pl (+65 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 C4::CourseReserves qw(DelCourseReserve GetCourse GetCourseReserves);
30
31
my $cgi = new CGI;
32
33
my $action = $cgi->param('action') || '';
34
my $course_id = $cgi->param('course_id');
35
36
my $flagsrequired;
37
$flagsrequired->{coursereserves} = 'delete_reserves' if ( $action eq 'del_reserve' );
38
39
my $tmpl = ($course_id) ? "course-details.tt" : "invalid-course.tt";
40
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
41
    {   template_name   => "course_reserves/$tmpl",
42
        query           => $cgi,
43
        type            => "intranet",
44
        authnotrequired => 0,
45
        flagsrequired   => $flagsrequired,
46
    }
47
);
48
49
if ( $action eq 'del_reserve' ) {
50
    DelCourseReserve( cr_id => $cgi->param('cr_id') );
51
}
52
53
my $course          = GetCourse($course_id);
54
my $course_reserves = GetCourseReserves(
55
    course_id       => $course_id,
56
    include_items   => 1,
57
    include_courses => 1
58
);
59
60
$template->param(
61
    course          => $course,
62
    course_reserves => $course_reserves,
63
);
64
65
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 C4::CourseReserves qw(GetCourses);
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 => '*' },
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 (+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
use C4::Koha;
28
29
use C4::CourseReserves qw(GetCourse);
30
31
my $cgi = new CGI;
32
33
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
34
    {   template_name   => "course_reserves/course.tt",
35
        query           => $cgi,
36
        type            => "intranet",
37
        authnotrequired => 0,
38
        flagsrequired   => { coursereserves => 'manage_courses' },
39
    }
40
);
41
42
my $course_id = $cgi->param('course_id');
43
44
if ($course_id) {
45
    my $course = GetCourse($course_id);
46
    $template->param(%$course);
47
}
48
49
$template->param(
50
    departments => GetAuthorisedValues('DEPARTMENT'),
51
    terms       => GetAuthorisedValues('TERM'),
52
);
53
54
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/course_reserves/mod_course.pl (+69 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2012 ByWater Solutions
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 CGI;
23
24
use C4::Output;
25
use C4::Reserves;
26
use C4::Auth;
27
28
use C4::CourseReserves qw(DelCourse ModCourse ModCourseInstructors);
29
30
my $cgi = new CGI;
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32
    {   template_name   => "about.tmpl",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 0,
36
        flagsrequired   => { coursereserves => 'manage_courses' },
37
    }
38
);
39
40
my $action = $cgi->param('action');
41
42
if ( $action eq 'del' ) {
43
    DelCourse( $cgi->param('course_id') );
44
    print $cgi->redirect("/cgi-bin/koha/course_reserves/course-reserves.pl");
45
} else {
46
    my %params;
47
48
    $params{'course_id'} = $cgi->param('course_id')
49
      if ( $cgi->param('course_id') );
50
    $params{'department'}     = $cgi->param('department');
51
    $params{'course_number'}  = $cgi->param('course_number');
52
    $params{'section'}        = $cgi->param('section');
53
    $params{'course_name'}    = $cgi->param('course_name');
54
    $params{'term'}           = $cgi->param('term');
55
    $params{'staff_note'}     = $cgi->param('staff_note');
56
    $params{'public_note'}    = $cgi->param('public_note');
57
    $params{'students_count'} = $cgi->param('students_count');
58
    $params{'enabled'}        = ( $cgi->param('enabled') eq 'on' ) ? 'yes' : 'no';
59
60
    my $course_id = ModCourse(%params);
61
62
    my @instructors = $cgi->param('instructors');
63
    ModCourseInstructors(
64
        mode        => 'replace',
65
        cardnumbers => \@instructors,
66
        course_id   => $course_id
67
    );
68
    print $cgi->redirect("/cgi-bin/koha/course_reserves/course-details.pl?course_id=$course_id");
69
}
(-)a/installer/data/mysql/de-DE/mandatory/userflags.sql (+1 lines)
Lines 15-18 INSERT INTO `userflags` VALUES(14,'editauthorities','Normdaten ändern',0); Link Here
15
INSERT INTO `userflags` VALUES(15,'serials','Zugriff auf Abonnementverwaltung/Zeitschriftenmodul',0);
15
INSERT INTO `userflags` VALUES(15,'serials','Zugriff auf Abonnementverwaltung/Zeitschriftenmodul',0);
16
INSERT INTO `userflags` VALUES(16,'reports','Zugriff auf Reportmodul',0);
16
INSERT INTO `userflags` VALUES(16,'reports','Zugriff auf Reportmodul',0);
17
INSERT INTO `userflags` VALUES(17,'staffaccess','Berechtigungen/Logins für Bibliotheksmitarbeiter vergeben',0);
17
INSERT INTO `userflags` VALUES(17,'staffaccess','Berechtigungen/Logins für Bibliotheksmitarbeiter vergeben',0);
18
INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0);
18
INSERT INTO `userflags` VALUES(19,'plugins', 'Koha Plugins', '0');
19
INSERT INTO `userflags` VALUES(19,'plugins', 'Koha Plugins', '0');
(-)a/installer/data/mysql/de-DE/mandatory/userpermissions.sql (+3 lines)
Lines 53-58 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
53
   (15, 'routing', 'Umlauflisten verwalten'),
53
   (15, 'routing', 'Umlauflisten verwalten'),
54
   (16, 'execute_reports', 'SQL-Reports ausführen'),
54
   (16, 'execute_reports', 'SQL-Reports ausführen'),
55
   (16, 'create_reports', 'SQL-Reports erstellen'),
55
   (16, 'create_reports', 'SQL-Reports erstellen'),
56
   (18, 'manage_courses', 'Add, edit and delete courses'),
57
   (18, 'add_reserves', 'Add course reserves'),
58
   (18, 'delete_reserves', 'Remove course reserves'),
56
   (19, 'manage', 'Plugins verwealten (installieren/deinstallieren)'),
59
   (19, 'manage', 'Plugins verwealten (installieren/deinstallieren)'),
57
   (19, 'tool', 'Werkzeug-Plugins verwenden'),
60
   (19, 'tool', 'Werkzeug-Plugins verwenden'),
58
   (19, 'report', 'Report-Plugins verwenden'),
61
   (19, 'report', 'Report-Plugins verwenden'),
(-)a/installer/data/mysql/en/mandatory/userflags.sql (-1 / +2 lines)
Lines 15-18 INSERT INTO `userflags` VALUES(14,'editauthorities','Edit Authorities',0); Link Here
15
INSERT INTO `userflags` VALUES(15,'serials','Manage serial subscriptions',0);
15
INSERT INTO `userflags` VALUES(15,'serials','Manage serial subscriptions',0);
16
INSERT INTO `userflags` VALUES(16,'reports','Allow access to the reports module',0);
16
INSERT INTO `userflags` VALUES(16,'reports','Allow access to the reports module',0);
17
INSERT INTO `userflags` VALUES(17,'staffaccess','Allow staff members to modify permissions for other staff members',0);
17
INSERT INTO `userflags` VALUES(17,'staffaccess','Allow staff members to modify permissions for other staff members',0);
18
INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0');
18
INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0);
19
INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0');
(-)a/installer/data/mysql/en/mandatory/userpermissions.sql (+3 lines)
Lines 53-58 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
53
   (15, 'routing', 'Routing'),
53
   (15, 'routing', 'Routing'),
54
   (16, 'execute_reports', 'Execute SQL reports'),
54
   (16, 'execute_reports', 'Execute SQL reports'),
55
   (16, 'create_reports', 'Create SQL Reports'),
55
   (16, 'create_reports', 'Create SQL Reports'),
56
   (18, 'manage_courses', 'Add, edit and delete courses'),
57
   (18, 'add_reserves', 'Add course reserves'),
58
   (18, 'delete_reserves', 'Remove course reserves'),
56
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
59
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
57
   (19, 'tool', 'Use tool plugins'),
60
   (19, 'tool', 'Use tool plugins'),
58
   (19, 'report', 'Use report plugins'),
61
   (19, 'report', 'Use report plugins'),
(-)a/installer/data/mysql/es-ES/mandatory/userflags.sql (+1 lines)
Lines 15-18 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);
18
INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0');
19
INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0');
(-)a/installer/data/mysql/es-ES/mandatory/userpermissions.sql (+3 lines)
Lines 53-58 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
53
   (15, 'routing', 'Routing'),
53
   (15, 'routing', 'Routing'),
54
   (16, 'execute_reports', 'Execute SQL reports'),
54
   (16, 'execute_reports', 'Execute SQL reports'),
55
   (16, 'create_reports', 'Create SQL Reports'),
55
   (16, 'create_reports', 'Create SQL Reports'),
56
   (18, 'manage_courses', 'Add, edit and delete courses'),
57
   (18, 'add_reserves', 'Add course reserves'),
58
   (18, 'delete_reserves', 'Remove course reserves'),
56
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
59
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
57
   (19, 'tool', 'Use tool plugins'),
60
   (19, 'tool', 'Use tool plugins'),
58
   (19, 'report', 'Use report plugins'),
61
   (19, 'report', 'Use report plugins'),
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/userflags.sql (+1 lines)
Lines 16-19 INSERT INTO `userflags` VALUES(13,'tools','Outils (export, import, impression de Link Here
16
INSERT INTO `userflags` VALUES(14,'editauthorities','Gestion des autorités',0);
16
INSERT INTO `userflags` VALUES(14,'editauthorities','Gestion des autorités',0);
17
INSERT INTO `userflags` VALUES(15,'serials','Gestion du module périodique',0);
17
INSERT INTO `userflags` VALUES(15,'serials','Gestion du module périodique',0);
18
INSERT INTO `userflags` VALUES(16,'reports','Accès aux statistiques',0);
18
INSERT INTO `userflags` VALUES(16,'reports','Accès aux statistiques',0);
19
INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0);
19
INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0');
20
INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0');
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql (-1 / +3 lines)
Lines 53-61 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
53
   (15, 'routing', 'Mettre en circulation'),
53
   (15, 'routing', 'Mettre en circulation'),
54
   (16, 'execute_reports', 'Lancer les rapports SQL'),
54
   (16, 'execute_reports', 'Lancer les rapports SQL'),
55
   (16, 'create_reports', 'Créer les rapports SQL Reports'),
55
   (16, 'create_reports', 'Créer les rapports SQL Reports'),
56
   (18, 'manage_courses', 'Add, edit and delete courses'),
57
   (18, 'add_reserves', 'Add course reserves'),
58
   (18, 'delete_reserves', 'Remove course reserves'),
56
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
59
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
57
   (19, 'tool', 'Use tool plugins'),
60
   (19, 'tool', 'Use tool plugins'),
58
   (19, 'report', 'Use report plugins'),
61
   (19, 'report', 'Use report plugins'),
59
   (19, 'configure', 'Configure plugins')
62
   (19, 'configure', 'Configure plugins')
60
61
;
63
;
(-)a/installer/data/mysql/it-IT/necessari/userflags.sql (-1 / +2 lines)
Lines 17-22 INSERT INTO `userflags` VALUES(14,'editauthorities','autorizza la modifica delle Link Here
17
INSERT INTO `userflags` VALUES(15,'serials','autorizza la gestione degli abbonamenti ai periodici',0);
17
INSERT INTO `userflags` VALUES(15,'serials','autorizza la gestione degli abbonamenti ai periodici',0);
18
INSERT INTO `userflags` VALUES(16,'reports','autorizza accesso al modulo dei reports',0);
18
INSERT INTO `userflags` VALUES(16,'reports','autorizza accesso al modulo dei reports',0);
19
INSERT INTO `userflags` VALUES(17,'staffaccess','modifica la login o i permessi degli staff users',0);
19
INSERT INTO `userflags` VALUES(17,'staffaccess','modifica la login o i permessi degli staff users',0);
20
INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0);
20
INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0');
21
INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0');
21
22
22
SET FOREIGN_KEY_CHECKS=1;
23
SET FOREIGN_KEY_CHECKS=1;
(-)a/installer/data/mysql/it-IT/necessari/userpermissions.sql (+7 lines)
Lines 59-63 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
59
   (19, 'tool', 'Usa i plugin di tipo Strumento'),
59
   (19, 'tool', 'Usa i plugin di tipo Strumento'),
60
   (19, 'report', 'Usa i plugin di tipo Report'),
60
   (19, 'report', 'Usa i plugin di tipo Report'),
61
   (19, 'configure', 'Configura i plugin')
61
   (19, 'configure', 'Configura i plugin')
62
   (18, 'manage_courses', 'Add, edit and delete courses'),
63
   (18, 'add_reserves', 'Add course reserves'),
64
   (18, 'delete_reserves', 'Remove course reserves'),
65
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
66
   (19, 'tool', 'Use tool plugins'),
67
   (19, 'report', 'Use report plugins'),
68
   (19, 'configure', 'Configure plugins')
62
;
69
;
63
SET FOREIGN_KEY_CHECKS=1;
70
SET FOREIGN_KEY_CHECKS=1;
(-)a/installer/data/mysql/kohastructure.sql (+102 lines)
Lines 469-474 CREATE TABLE collections_tracking ( Link Here
469
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
469
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
470
470
471
--
471
--
472
-- Table structure for table `courses`
473
--
474
475
-- The courses table stores the courses created for the
476
-- course reserves feature.
477
478
DROP TABLE IF EXISTS courses;
479
CREATE TABLE `courses` (
480
  `course_id` int(11) NOT NULL AUTO_INCREMENT,
481
  `department` varchar(20) DEFAULT NULL, -- Stores the authorised value DEPT
482
  `course_number` varchar(255) DEFAULT NULL, -- An arbitrary field meant to store the "course number" assigned to a course
483
  `section` varchar(255) DEFAULT NULL, -- Also arbitrary, but for the 'section' of a course.
484
  `course_name` varchar(255) DEFAULT NULL,
485
  `term` varchar(20) DEFAULT NULL, -- Stores the authorised value TERM
486
  `staff_note` mediumtext,
487
  `public_note` mediumtext,
488
  `students_count` varchar(20) DEFAULT NULL, -- Meant to be just an estimate of how many students will be taking this course/section
489
  `enabled` enum('yes','no') NOT NULL DEFAULT 'yes', -- Determines whether the course is active
490
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
491
   PRIMARY KEY (`course_id`)
492
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
493
494
--
495
-- Table structure for table `course_instructors`
496
--
497
498
-- The course instructors table links Koha borrowers to the
499
-- courses they are teaching. Many instructors can teach many
500
-- courses. course_instructors is just a many-to-many join table.
501
502
DROP TABLE IF EXISTS course_instructors;
503
CREATE TABLE `course_instructors` (
504
  `course_id` int(11) NOT NULL,
505
  `borrowernumber` int(11) NOT NULL,
506
  PRIMARY KEY (`course_id`,`borrowernumber`),
507
  KEY `borrowernumber` (`borrowernumber`)
508
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
509
510
--
511
-- Constraints for table `course_instructors`
512
--
513
ALTER TABLE `course_instructors`
514
  ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
515
  ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
516
517
--
518
-- Table structure for table `course_items`
519
--
520
521
-- If an item is placed on course reserve for one or more courses
522
-- it will have an entry in this table. No matter how many courses an item
523
-- is part of, it will only have one row in this table.
524
525
DROP TABLE IF EXISTS course_items;
526
CREATE TABLE `course_items` (
527
  `ci_id` int(11) NOT NULL AUTO_INCREMENT,
528
  `itemnumber` int(11) NOT NULL, -- items.itemnumber for the item on reserve
529
  `itype` varchar(10) DEFAULT NULL, -- an optional new itemtype for the item to have while on reserve
530
  `ccode` varchar(10) DEFAULT NULL, -- an optional new category code for the item to have while on reserve
531
  `holdingbranch` varchar(10) DEFAULT NULL, -- an optional new holding branch for the item to have while on reserve
532
  `location` varchar(80) DEFAULT NULL, -- an optional new shelving location for the item to have while on reseve
533
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no', -- If at least one enabled course has this item on reseve, this field will be 'yes', otherwise it will be 'no'
534
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
535
   PRIMARY KEY (`ci_id`),
536
   UNIQUE KEY `itemnumber` (`itemnumber`),
537
   KEY `holdingbranch` (`holdingbranch`)
538
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
539
540
--
541
-- Constraints for table `course_items`
542
--
543
ALTER TABLE `course_items`
544
  ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
545
  ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
546
547
--
548
-- Table structure for table `course_reserves`
549
--
550
551
-- This table connects an item placed on course reserve to a course it is on reserve for.
552
-- There will be a row in this table for each course an item is on reserve for.
553
554
DROP TABLE IF EXISTS course_reserves;
555
CREATE TABLE `course_reserves` (
556
  `cr_id` int(11) NOT NULL AUTO_INCREMENT,
557
  `course_id` int(11) NOT NULL, -- Foreign key to the courses table
558
  `ci_id` int(11) NOT NULL, -- Foreign key to the course_items table
559
  `staff_note` mediumtext, -- Staff only note
560
  `public_note` mediumtext, -- Public, OPAC visible note
561
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
562
   PRIMARY KEY (`cr_id`),
563
   UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
564
   KEY `course_id` (`course_id`)
565
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
566
567
--
568
-- Constraints for table `course_reserves`
569
--
570
ALTER TABLE `course_reserves`
571
  ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`);
572
573
--
472
-- Table structure for table `branch_borrower_circ_rules`
574
-- Table structure for table `branch_borrower_circ_rules`
473
--
575
--
474
576
(-)a/installer/data/mysql/nb-NO/1-Obligatorisk/userflags.sql (+1 lines)
Lines 36-39 INSERT INTO `userflags` VALUES(14,'editauthorities','Tilgang til å endre autori Link Here
36
INSERT INTO `userflags` VALUES(15,'serials','Tilgang til å endre abonnementer',0);
36
INSERT INTO `userflags` VALUES(15,'serials','Tilgang til å endre abonnementer',0);
37
INSERT INTO `userflags` VALUES(16,'reports','Tilgang til rapportmodulen',0);
37
INSERT INTO `userflags` VALUES(16,'reports','Tilgang til rapportmodulen',0);
38
INSERT INTO `userflags` VALUES(17,'staffaccess','Endre innlogging og rettigheter for bibliotekansatte',0);
38
INSERT INTO `userflags` VALUES(17,'staffaccess','Endre innlogging og rettigheter for bibliotekansatte',0);
39
INSERT INTO `userflags` VALUES(18,'coursereserves','Course Reserves',0);
39
INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0');
40
INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0');
(-)a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql (+3 lines)
Lines 73-78 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
73
   (15, 'routing', 'Sirkulasjon'),
73
   (15, 'routing', 'Sirkulasjon'),
74
   (16, 'execute_reports', 'Kjøre SQL-rapporter'),
74
   (16, 'execute_reports', 'Kjøre SQL-rapporter'),
75
   (16, 'create_reports', 'Opprette SQL-rapporter'),
75
   (16, 'create_reports', 'Opprette SQL-rapporter'),
76
   (18, 'manage_courses', 'Add, edit and delete courses'),
77
   (18, 'add_reserves', 'Add course reserves'),
78
   (18, 'delete_reserves', 'Remove course reserves'),
76
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
79
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
77
   (19, 'tool', 'Use tool plugins'),
80
   (19, 'tool', 'Use tool plugins'),
78
   (19, 'report', 'Use report plugins'),
81
   (19, 'report', 'Use report plugins'),
(-)a/installer/data/mysql/pl-PL/mandatory/userflags.sql (+1 lines)
Lines 15-18 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);
18
INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0');
19
INSERT INTO `userflags` VALUES(19, 'plugins', 'Koha plugins', '0');
(-)a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql (+3 lines)
Lines 54-59 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
54
   (15, 'routing', 'Routing'),
54
   (15, 'routing', 'Routing'),
55
   (16, 'execute_reports', 'Execute SQL reports'),
55
   (16, 'execute_reports', 'Execute SQL reports'),
56
   (16, 'create_reports', 'Create SQL Reports'),
56
   (16, 'create_reports', 'Create SQL Reports'),
57
   (18, 'manage_courses', 'Add, edit and delete courses'),
58
   (18, 'add_reserves', 'Add course reserves'),
59
   (18, 'delete_reserves', 'Remove course reserves'),
57
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
60
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
58
   (19, 'tool', 'Use tool plugins'),
61
   (19, 'tool', 'Use tool plugins'),
59
   (19, 'report', 'Use report plugins'),
62
   (19, 'report', 'Use report plugins'),
(-)a/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql (+4 lines)
Lines 18-23 INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES Link Here
18
   (15,'serials',         'Разрешение на управление подпиской периодических изданий',0),
18
   (15,'serials',         'Разрешение на управление подпиской периодических изданий',0),
19
   (16,'reports',         'Разрешение на доступ к модулю отчетов',0),
19
   (16,'reports',         'Разрешение на доступ к модулю отчетов',0),
20
   (17,'staffaccess',     'Смена имени(логина)/привилегий для работников библиотеки',0),
20
   (17,'staffaccess',     'Смена имени(логина)/привилегий для работников библиотеки',0),
21
   (18,'coursereserves',  'Course Reserves',0),
21
   (19,'plugins',         'Koha plugins', '0')
22
   (19,'plugins',         'Koha plugins', '0')
22
;
23
;
23
24
Lines 78-83 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
78
   (15, 'routing',                     'Routing'),
79
   (15, 'routing',                     'Routing'),
79
   (16, 'execute_reports', 'Execute SQL reports'),
80
   (16, 'execute_reports', 'Execute SQL reports'),
80
   (16, 'create_reports', 'Create SQL Reports'),
81
   (16, 'create_reports', 'Create SQL Reports'),
82
   (18, 'manage_courses', 'Add, edit and delete courses'),
83
   (18, 'add_reserves', 'Add course reserves'),
84
   (18, 'delete_reserves', 'Remove course reserves'),
81
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
85
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
82
   (19, 'tool', 'Use tool plugins'),
86
   (19, 'tool', 'Use tool plugins'),
83
   (19, 'report', 'Use report plugins'),
87
   (19, 'report', 'Use report plugins'),
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 425-427 INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( Link Here
425
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPACWhich','PatronBranch','PatronBranch|OpacURLBranch','Decides which branch''s items to emphasize. If PatronBranch, emphasize the logged in user''s library''s items. If OpacURLBranch, highlight the items of the Apache var BRANCHCODE defined in Koha''s Apache configuration file.','Choice');
425
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPACWhich','PatronBranch','PatronBranch|OpacURLBranch','Decides which branch''s items to emphasize. If PatronBranch, emphasize the logged in user''s library''s items. If OpacURLBranch, highlight the items of the Apache var BRANCHCODE defined in Koha''s Apache configuration file.','Choice');
426
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UniqueItemFields', 'barcode', 'Space-separated list of fields that should be unique (used in acquisition module for item creation). Fields must be valid SQL column names of items table', '', 'Free');
426
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UniqueItemFields', 'barcode', 'Space-separated list of fields that should be unique (used in acquisition module for item creation). Fields must be valid SQL column names of items table', '', 'Free');
427
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
427
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
428
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo');
(-)a/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql (+4 lines)
Lines 18-23 INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES Link Here
18
   (15,'serials',         'Дозвіл на керування підпискою періодичних видань',0),
18
   (15,'serials',         'Дозвіл на керування підпискою періодичних видань',0),
19
   (16,'reports',         'Дозвіл на доступ до модуля звітів',0),
19
   (16,'reports',         'Дозвіл на доступ до модуля звітів',0),
20
   (17,'staffaccess',     'Зміна імені(логіну)/привілеїв для працівників бібліотеки',0),
20
   (17,'staffaccess',     'Зміна імені(логіну)/привілеїв для працівників бібліотеки',0),
21
   (18,'coursereserves',  'Course Reserves',0),
21
   (19,'plugins',         'Koha plugins', '0')
22
   (19,'plugins',         'Koha plugins', '0')
22
;
23
;
23
24
Lines 78-83 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
78
   (15, 'routing',                     'Routing'),
79
   (15, 'routing',                     'Routing'),
79
   (16, 'execute_reports', 'Execute SQL reports'),
80
   (16, 'execute_reports', 'Execute SQL reports'),
80
   (16, 'create_reports', 'Create SQL Reports'),
81
   (16, 'create_reports', 'Create SQL Reports'),
82
   (18, 'manage_courses', 'Add, edit and delete courses'),
83
   (18, 'add_reserves', 'Add course reserves'),
84
   (18, 'delete_reserves', 'Remove course reserves'),
81
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
85
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
82
   (19, 'tool', 'Use tool plugins'),
86
   (19, 'tool', 'Use tool plugins'),
83
   (19, 'report', 'Use report plugins'),
87
   (19, 'report', 'Use report plugins'),
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +90 lines)
Lines 5801-5807 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5801
    SetVersion($DBversion);
5801
    SetVersion($DBversion);
5802
}
5802
}
5803
5803
5804
5805
$DBversion = "3.09.00.047";
5804
$DBversion = "3.09.00.047";
5806
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5805
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5807
    # to preserve default behaviour as best as possible, set this new preference differently depending on whether IndependantBranches is set or not
5806
    # to preserve default behaviour as best as possible, set this new preference differently depending on whether IndependantBranches is set or not
Lines 6929-6934 if ( CheckVersion($DBversion) ) { Link Here
6929
    SetVersion ($DBversion);
6928
    SetVersion ($DBversion);
6930
}
6929
}
6931
6930
6931
$DBversion = "3.13.00.XXX";
6932
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6933
    $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('UseCourseReserves', '0', NULL, 'Enable the course reserves feature.', 'YesNo')");
6934
    $dbh->do("INSERT INTO userflags (bit,flag,flagdesc,defaulton) VALUES ('18','coursereserves','Course Reserves','0')");
6935
    $dbh->do("
6936
CREATE TABLE `courses` (
6937
  `course_id` int(11) NOT NULL AUTO_INCREMENT,
6938
  `department` varchar(20) DEFAULT NULL,
6939
  `course_number` varchar(255) DEFAULT NULL,
6940
  `section` varchar(255) DEFAULT NULL,
6941
  `course_name` varchar(255) DEFAULT NULL,
6942
  `term` varchar(20) DEFAULT NULL,
6943
  `staff_note` mediumtext,
6944
  `public_note` mediumtext,
6945
  `students_count` varchar(20) DEFAULT NULL,
6946
  `enabled` enum('yes','no') NOT NULL DEFAULT 'yes',
6947
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6948
   PRIMARY KEY (`course_id`)
6949
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
6950
    ");
6951
6952
    $dbh->do("
6953
CREATE TABLE `course_instructors` (
6954
  `course_id` int(11) NOT NULL,
6955
  `borrowernumber` int(11) NOT NULL,
6956
  PRIMARY KEY (`course_id`,`borrowernumber`),
6957
  KEY `borrowernumber` (`borrowernumber`)
6958
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6959
    ");
6960
6961
    $dbh->do("
6962
ALTER TABLE `course_instructors`
6963
  ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
6964
  ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
6965
    ");
6966
6967
    $dbh->do("
6968
CREATE TABLE `course_items` (
6969
  `ci_id` int(11) NOT NULL AUTO_INCREMENT,
6970
  `itemnumber` int(11) NOT NULL,
6971
  `itype` varchar(10) DEFAULT NULL,
6972
  `ccode` varchar(10) DEFAULT NULL,
6973
  `holdingbranch` varchar(10) DEFAULT NULL,
6974
  `location` varchar(80) DEFAULT NULL,
6975
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no',
6976
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6977
   PRIMARY KEY (`ci_id`),
6978
   UNIQUE KEY `itemnumber` (`itemnumber`),
6979
   KEY `holdingbranch` (`holdingbranch`)
6980
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
6981
    ");
6982
6983
    $dbh->do("
6984
ALTER TABLE `course_items`
6985
  ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
6986
  ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
6987
");
6988
6989
    $dbh->do("
6990
CREATE TABLE `course_reserves` (
6991
  `cr_id` int(11) NOT NULL AUTO_INCREMENT,
6992
  `course_id` int(11) NOT NULL,
6993
  `ci_id` int(11) NOT NULL,
6994
  `staff_note` mediumtext,
6995
  `public_note` mediumtext,
6996
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6997
   PRIMARY KEY (`cr_id`),
6998
   UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
6999
   KEY `course_id` (`course_id`)
7000
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
7001
");
7002
7003
    $dbh->do("
7004
ALTER TABLE `course_reserves`
7005
  ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`);
7006
    ");
7007
7008
    $dbh->do("
7009
INSERT INTO permissions (module_bit, code, description) VALUES
7010
  (18, 'manage_courses', 'Add, edit and delete courses'),
7011
  (18, 'add_reserves', 'Add course reserves'),
7012
  (18, 'delete_reserves', 'Remove course reserves')
7013
;
7014
    ");
7015
7016
7017
    print "Upgrade to $DBversion done (Add Course Reserves ( system preference UseCourseReserves ))\n";
7018
    SetVersion($DBversion);
7019
}
7020
6932
=head1 FUNCTIONS
7021
=head1 FUNCTIONS
6933
7022
6934
=head2 TableExists($table)
7023
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css (-1 / +1 lines)
Lines 754-760 fieldset.rows .inputnote { Link Here
754
    visibility:visible; /* you propably don't need to change this one */
754
    visibility:visible; /* you propably don't need to change this one */
755
    display:block;
755
    display:block;
756
}
756
}
757
#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 {
757
#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 {
758
	padding-left : 34px;
758
	padding-left : 34px;
759
	background-image: url("../../img/toolbar-new.gif");
759
	background-image: url("../../img/toolbar-new.gif");
760
	background-position : center left;
760
	background-position : center left;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (+3 lines)
Lines 24-29 Link Here
24
                            [% IF ( CAN_user_serials ) %]
24
                            [% IF ( CAN_user_serials ) %]
25
                            <li><a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a></li>
25
                            <li><a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a></li>
26
                            [% END %]
26
                            [% END %]
27
                            [% IF ( CAN_user_coursereserves ) %]
28
                            <li><a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course Reserves</a></li>
29
                            [% END %]
27
                            [% IF ( CAN_user_reports ) %]
30
                            [% IF ( CAN_user_reports ) %]
28
                            <li><a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a></li>
31
                            <li><a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a></li>
29
                            [% END %]
32
                            [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js (-3 / +8 lines)
Lines 5-19 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();
13
    $(".validated").validate();
16
    $(".validated").validate();
14
});
15
16
17
18
    $('.noEnterSubmit').keypress(function(e){
19
        if ( e.which == 13 ) return false;
20
    });
21
});
17
22
18
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html
23
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html
19
function checkEnter(e){ //e is event object passed from function invocation
24
function checkEnter(e){ //e is event object passed from function invocation
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+7 lines)
Lines 550-552 Circulation: Link Here
550
            - and this password
550
            - and this password
551
            - pref: AutoSelfCheckPass
551
            - pref: AutoSelfCheckPass
552
            - .
552
            - .
553
    Course Reserves:
554
        -
555
            - pref: UseCourseReserves
556
              choices:
557
                  yes: Use
558
                  no: "Don't use"
559
            - course reserves
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (+34 lines)
Lines 1-3 Link Here
1
[% USE AuthorisedValues %]
2
3
[% ShowCourseReserves = 0 %]
4
[% IF UseCourseReserves %]
5
    [% FOREACH item IN itemloop %]
6
       [% IF item.course_reserves %]
7
           [% FOREACH r IN item.course_reserves %]
8
               [% IF r.course.enabled == 'yes' %]
9
                   [% ShowCourseReserves = 1 %]
10
               [% END %]
11
           [% END %]
12
        [% END %]
13
    [% END %]
14
[% END %]
15
1
[% INCLUDE 'doc-head-open.inc' %]
16
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'greybox.inc' %]
17
[% INCLUDE 'greybox.inc' %]
3
<title>Koha &rsaquo; Catalog &rsaquo;
18
<title>Koha &rsaquo; Catalog &rsaquo;
Lines 370-375 function verify_images() { Link Here
370
                [% IF ( SpineLabelShowPrintOnBibDetails ) %]<th>Spine label</th>[% END %]
385
                [% IF ( SpineLabelShowPrintOnBibDetails ) %]<th>Spine label</th>[% END %]
371
                [% IF ( hostrecords ) %]<th>Host records</th>[% END %]
386
                [% IF ( hostrecords ) %]<th>Host records</th>[% END %]
372
                [% IF ( analyze ) %]<th>Used in</th><th></th>[% END %]
387
                [% IF ( analyze ) %]<th>Used in</th><th></th>[% END %]
388
                [% IF ( ShowCourseReserves ) %]<th>Course Reserves</th>[% END %]
373
            </tr>
389
            </tr>
374
        </thead>
390
        </thead>
375
        <tbody>
391
        <tbody>
Lines 520-525 function verify_images() { Link Here
520
                        <td><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?hostbiblionumber=[% item.biblionumber %]&amp;hostitemnumber=[% item.itemnumber %]">Create analytics</a></td>
536
                        <td><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?hostbiblionumber=[% item.biblionumber %]&amp;hostitemnumber=[% item.itemnumber %]">Create analytics</a></td>
521
                    [% END %]
537
                    [% END %]
522
538
539
                [% IF ShowCourseReserves %]
540
                    <td>
541
                        [% IF item.course_reserves %]
542
                            [% FOREACH r IN item.course_reserves %]
543
                                [% IF r.course.enabled == 'yes' %]
544
                                    <p>
545
                                      <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% r.course.course_id %]">
546
                                         [% r.course.course_name %]
547
                                         <!--[% IF r.course.course_number %] [% r.course.course_number %] [% END %]-->
548
                                         [% IF r.course.section %] [% r.course.section %] [% END %]
549
                                         [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) %] [% END %]
550
                                      </a>
551
                                   </p>
552
                               [% END %]
553
                           [% END %]
554
                       [% END %]
555
                    </td>
556
                [% END %]
523
                </tr>
557
                </tr>
524
            [% END %]
558
            [% END %]
525
        </tbody>
559
        </tbody>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-1 / +1 lines)
Lines 10-16 $(document).ready(function(){ Link Here
10
            window.close();
10
            window.close();
11
        [% END %]
11
        [% END %]
12
    [% END %]
12
    [% END %]
13
		$("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
13
            $("fieldset.rows input").addClass("noEnterSubmit");
14
		/* Inline edit/delete links */
14
		/* Inline edit/delete links */
15
		var biblionumber = $("input[name='biblionumber']").attr("value");
15
		var biblionumber = $("input[name='biblionumber']").attr("value");
16
        $("tr.editable td").click(function(event){
16
        $("tr.editable td").click(function(event){
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step1.tt (+61 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
                                <ol>
40
                                    <li>
41
                                        <label class="required" for="barcode">Item barcode:</label>
42
                                        <input id="barcode" name="barcode" type="text" />
43
                                    </li>
44
                                </ol>
45
                            </fieldset>
46
47
                            <fieldset class="action">
48
                                <input type="submit" value="Submit" class="submit" />
49
50
                                <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% course.course_id %]" class="cancel">Cancel</a>
51
                            </fieldset>
52
                        </form>
53
                    </div>
54
                </div>
55
            </div>
56
        </div>
57
    </div>
58
</div>
59
60
61
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt (+133 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
                                    [% IF item_level_itypes %]
45
                                    <li>
46
                                        <label class="required" for="itype">Item Type:</label>
47
                                        <select id="itype" name="itype">
48
                                            <option value="">LEAVE UNCHANGED</option>
49
50
                                            [% FOREACH it IN itypes %]
51
                                                [% IF course_item.itype && ( ( course.enabled == 'yes' && it.itemtype == item.itype ) || ( course.enabled == 'no' && it.itemtype == course_item.itype ) ) %]
52
                                                    <option value="[% it.itemtype %]" selected="selected">[% it.description %]</option>
53
                                                [% ELSE %]
54
                                                    <option value="[% it.itemtype %]">[% it.description %]</option>
55
                                                [% END %]
56
                                            [% END %]
57
                                        </select>
58
                                    </li>
59
                                    [% END %]
60
61
                                    <li>
62
                                        <label class="required" for="ccode">Collection Code:</label>
63
                                        <select id="ccode" name="ccode">
64
                                            <option value="">LEAVE UNCHANGED</option>
65
66
                                            [% FOREACH c IN ccodes %]
67
                                                [% IF course_item.ccode && ( ( course.enabled == 'yes' && c.authorised_value == item.ccode ) || ( course.enabled == 'no' && c.authorised_value == course_item.ccode ) ) %]
68
                                                    <option value="[% c.authorised_value %]" selected="selected">[% c.lib %]</option>
69
                                                [% ELSE %]
70
                                                    <option value="[% c.authorised_value %]">[% c.lib %]</option>
71
                                                [% END %]
72
                                            [% END %]
73
                                        </select>
74
                                    </li>
75
76
                                    <li>
77
                                        <label class="required" for="location">Shelving Location:</label>
78
                                        <select id="location" name="location">
79
                                            <option value="">LEAVE UNCHANGED</option>
80
81
                                            [% FOREACH s IN locations %]
82
                                                [% IF course_item.location && ( ( course.enabled == 'yes' && s.authorised_value == item.location ) || ( course.enabled == 'no' && s.authorised_value == course_item.location ) ) %]
83
                                                    <option value="[% s.authorised_value %]" selected="selected">[% s.lib %]</option>
84
                                                [% ELSE %]
85
                                                    <option value="[% s.authorised_value %]">[% s.lib %]</option>
86
                                                [% END %]
87
                                            [% END %]
88
                                        </select>
89
                                    </li>
90
91
                                    <li>
92
                                        <label class="required" for="holdingbranch">Holding Library:</label>
93
                                        <select id="holdingbranch" name="holdingbranch">
94
                                            <option value="">LEAVE UNCHANGED</option>
95
96
                                            [% FOREACH b IN branches %]
97
                                                [% IF course_item.holdingbranch && ( ( course.enabled == 'yes' && b.value == item.holdingbranch ) || ( course.enabled == 'no' && b.value == course_item.holdingbranch ) ) %]
98
                                                    <option value="[% b.value %]" selected="selected">[% b.branchname %]</option>
99
                                                [% ELSE %]
100
                                                    <option value="[% b.value %]">[% b.branchname %]</option>
101
                                                [% END %]
102
                                            [% END %]
103
                                        </select>
104
                                    </li>
105
106
                                    <li>
107
                                        <label for="staff_note">Staff note:</label>
108
                                        <textarea name="staff_note" id="staff_note">[% course_reserve.staff_note %]</textarea>
109
                                    </li>
110
111
                                    <li>
112
                                        <label for="public_note">Public note:</label>
113
                                        <textarea name="public_note" id="public_note">[% course_reserve.public_note %]</textarea>
114
                                    </li>
115
116
                                </ol>
117
                            </fieldset>
118
119
                            <fieldset class="action">
120
                                <input type="submit" id="submit" value="Save" class="submit" />
121
122
                                <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% course.course_id %]" class="cancel">Cancel</a>
123
                            </fieldset>
124
125
                    </div>
126
                </div>
127
            </div>
128
        </div>
129
    </div>
130
</div>
131
132
133
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt (+184 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
    $(document).ready(function(){
11
        $("a.delete_item").click(function(){
12
            return confirm( _("Are you sure you want to delete this item?"));
13
        });
14
15
        $("#delete_course").click(function(){
16
            return confirm( _("Are you sure you want to delete this course?") );
17
        });
18
    });
19
20
//]]>
21
</script>
22
23
</head>
24
25
<body>
26
27
[% INCLUDE 'header.inc' %]
28
[% INCLUDE 'cat-search.inc' %]
29
30
<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>
31
32
<div id="doc2" class="yui-t7">
33
    <div id="bd">
34
        <div id="yui-main">
35
            <div id="toolbar">
36
                <ul class="toolbar">
37
                    [% IF CAN_user_coursereserves_add_reserves %]<li><a class="btn" id="add_items" href="/cgi-bin/koha/course_reserves/add_items.pl?course_id=[% course.course_id %]">Add reserves</a></li>[% END %]
38
                    [% IF ( CAN_user_coursereserves_manage_courses ) %]<li><a class="btn" id="edit_course" href="/cgi-bin/koha/course_reserves/course.pl?course_id=[% course.course_id %]">Edit course</a></li>[% END %]
39
                    [% IF ( CAN_user_coursereserves_manage_courses ) %]<li><a class="btn" id="delete_course" href="/cgi-bin/koha/course_reserves/mod_course.pl?course_id=[% course.course_id %]&action=del">Delete course</a></li>[% END %]
40
                </ul>
41
            </div><!-- /toolbar -->
42
43
            <table>
44
              <tbody>
45
                <tr><th>Course name</th><td>[% course.course_name %]</td></tr>
46
                <tr><th>Term</th><td>[% AuthorisedValues.GetByCode( 'TERM', course.term ) %]</td></tr>
47
                <tr><th>Department</th><td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', course.department ) %]</td></tr>
48
                <tr><th>Course number</th><td>[% course.course_number %]</td></tr>
49
                <tr><th>Section</th><td>[% course.section %]</td></tr>
50
                <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>
51
                <tr><th>Staff note</th><td>[% course.staff_note %]</td></tr>
52
                <tr><th>Public note</th><td>[% course.public_note %]</td></tr>
53
                <tr><th>Students count</th><td>[% course.students_count %]</td></tr>
54
                <tr><th>Status</th><td>[% IF course.enabled == 'yes' %]Active[% ELSE %]Inactive[% END %]</td></tr>
55
              </tbody>
56
            </table>
57
58
            [% IF course_reserves %]
59
            <table>
60
                <thead>
61
                    <tr>
62
                        <th>Title</th>
63
                        <th>Barcode</th>
64
                        <th>Call number</th>
65
                        [% IF item_level_itypes %]<th>Item type</th>[% END %]
66
                        <th>Collection</th>
67
                        <th>Location</th>
68
                        <th>Library</th>
69
                        <th>Staff note</th>
70
                        <th>Public note</th>
71
                        [% IF CAN_user_coursereserves_add_reserves %]<th>&nbsp;<!-- Edit --></th>[% END %]
72
                        [% IF CAN_user_coursereserves_delete_reserves %]<th>&nbsp;<!-- Remove --></th>[% END %]
73
                        <th>Other course reserves</th>
74
                    </tr>
75
                </thead>
76
77
                <tbody>
78
                    [% FOREACH cr IN course_reserves %]
79
                        <tr>
80
                            <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% cr.item.biblionumber %]">[% cr.item.title %]</a></td>
81
                            <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>
82
                            <td>[% cr.item.itemcallnumber %]</td>
83
                            [% IF item_level_itypes %]
84
                            <td>
85
                                [% IF cr.course_item.itype %]
86
                                    [% IF cr.course_item.enabled == 'yes' %]
87
                                        [% ItemTypes.GetDescription( cr.item.itype ) %]
88
                                    [% ELSE %]
89
                                        [% ItemTypes.GetDescription( cr.course_item.itype ) %]
90
                                    [% END %]
91
                                [% ELSE %]
92
                                     <i>Unchanged</i>
93
                                     [% IF cr.item.itype %]
94
                                         ([% ItemTypes.GetDescription( cr.item.itype ) %])
95
                                     [% END %]
96
                                [% END %]
97
                            </td>
98
                            [% END %]
99
                            <td>
100
                                 [% IF cr.course_item.ccode %]
101
                                     [% IF cr.course_item.enabled == 'yes' %]
102
                                          [% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %]
103
                                     [% ELSE %]
104
                                         [% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode ) %]
105
                                     [% END %]
106
                                 [% ELSE %]
107
                                     <i>Unchanged</i>
108
                                     [% IF cr.item.ccode %]
109
                                         ([% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %])
110
                                     [% END %]
111
                                 [% END %]
112
                            </td>
113
                            <td>
114
                                [% IF cr.course_item.location %]
115
                                     [% IF cr.course_item.enabled == 'yes' %]
116
                                         [% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %]
117
                                    [% ELSE %]
118
                                        [% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) %]
119
                                    [% END %]
120
                                [% ELSE %]
121
                                    <i>Unchanged</i>
122
                                    [% IF cr.item.location %]
123
                                        ([% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %])
124
                                    [% END %]
125
                                [% END %]
126
                            </td>
127
                            <td>
128
                                [% IF cr.course_item.holdingbranch %]
129
                                    [% IF cr.course_item.enabled == 'yes' %]
130
                                        [% Branches.GetName( cr.item.holdingbranch ) %]
131
                                    [% ELSE %]
132
                                        [% Branches.GetName( cr.course_item.holdingbranch ) %]
133
                                    [% END %]
134
                                [% ELSE %]
135
                                    <i>Unchanged</i>
136
                                    [% IF cr.item.holdingbranch %]
137
                                        ([% Branches.GetName( cr.item.holdingbranch ) %])
138
                                    [% END %]
139
                                [% END %]
140
                            </td>
141
                            <td>[% cr.staff_note %]</td>
142
                            <td>[% cr.public_note %]</td>
143
144
                            [% IF CAN_user_coursereserves_add_reserves %]
145
                                <td><a href="add_items.pl?course_id=[% course.course_id %]&barcode=[% cr.item.barcode %]&action=lookup">Edit</a></td>
146
                            [% END %]
147
148
                            [% IF CAN_user_coursereserves_delete_reserves %]
149
                                <td>
150
                                    [% IF cr.item.onloan %]
151
                                        On Loan
152
                                    [% ELSIF cr.item.itemlost %]
153
                                        Item Lost
154
                                    [% ELSE %]
155
                                        <a href="course-details.pl?course_id=[% course.course_id %]&action=del_reserve&cr_id=[% cr.cr_id %]" class="delete_item" >Remove</a>
156
                                    [% END %]
157
158
                                </td>
159
                            [% END %]
160
161
                            <td>
162
                                [% FOREACH course IN cr.courses %]
163
                                    [% UNLESS cr.course_id == course.course_id %]
164
                                        <p>
165
                                            <a href="course-details.pl?course_id=[% course.course_id %]">
166
                                                [% course.course_name %]
167
                                                [% IF course.section %] [% course.section %] [% END %]
168
                                                [% IF course.term %] [% AuthorisedValues.GetByCode( 'TERM', course.term ) %] [% END %]
169
                                            </a>
170
                                        </p>
171
                                    [% END %]
172
                                [% END %]
173
                            </td>
174
                        </tr>
175
                    [% END %]
176
                </tbody>
177
            </table>
178
            [% END %]
179
        </div>
180
    </div>
181
</div>
182
183
184
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt (+114 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
6
<link rel="stylesheet" type="text/css" href="/intranet-tmpl/prog/en/css/datatables.css" />
7
<script type="text/javascript" src="/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.dataTables.min.js"></script>
8
[% INCLUDE 'datatables-strings.inc' %]
9
<script type="text/javascript" src="/intranet-tmpl/prog/en/js/datatables.js"></script>
10
<script type="text/javascript" id="js">$(document).ready(function() {
11
 $(document).ready(function() {
12
    $("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, {
13
        "sPaginationType": "four_button",
14
        "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
15
        "iDisplayLength": 20
16
    }));
17
 });
18
});
19
</script>
20
21
</head>
22
<body id="lists_shelves" class="lists">
23
24
[% INCLUDE 'header.inc' %]
25
[% INCLUDE 'cat-search.inc' %]
26
27
<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>
28
29
<div id="doc2" class="yui-t7">
30
    <div id="bd">
31
        <div id="yui-main">
32
            <div class="yui-b">
33
                <div class="yui-g">
34
35
                    <div id="toolbar">
36
                        <ul class="toolbar">
37
                            [% IF ( CAN_user_coursereserves_manage_courses ) %]
38
                            <li><a class="btn" id="new_course" href="/cgi-bin/koha/course_reserves/course.pl">New course</a></li>
39
                            [% END %]
40
                        </ul>
41
                    </div><!-- /toolbar -->
42
43
                    <!--
44
                    <div id="search-toolbar">
45
                        <script type="text/javascript">
46
                        //<![CDATA[
47
                            function submitSearchForm(p_oEvent){
48
                                $('#search_courses_form').submit();
49
                            }
50
51
                            $(document).ready(function(){
52
                                newCourseButton = new YAHOO.widget.Button("search_courses");
53
                                newCourseButton.on("click", submitSearchForm );
54
                            });
55
                        //]]>
56
                        </script>
57
                        <ul class="toolbar">
58
                            <li><form id="search_courses_form"><input type="text" name="search_on" id="search_on"></form></li>
59
                            <li><a id="search_courses">Search courses</a></li>
60
                        </ul>
61
                    </div>
62
                    -->
63
64
                    <h1>Courses</h1>
65
                    <table id="course_reserves_table">
66
                        <thead>
67
                            <tr>
68
                                <th>Name</th>
69
                                <th>Dept.</th>
70
                                <th>Course #</th>
71
                                <th>Section</th>
72
                                <th>Term</th>
73
                                <th>Instructors</th>
74
                                <th>Staff note</th>
75
                                <th>Public note</th>
76
                                <th># of Students</th>
77
                                <th>Enabled</th>
78
                            </tr>
79
                        </thead>
80
81
                        <tbody>
82
                            [% FOREACH c IN courses %]
83
                                <tr>
84
                                    <td><a href="course-details.pl?course_id=[% c.course_id %]">[% c.course_name %]</a></td>
85
                                    <td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', c.department ) %]</td>
86
                                    <td>[% c.course_number %]</td>
87
                                    <td>[% c.section %]</td>
88
                                    <td>[% AuthorisedValues.GetByCode( 'TERM' c.term ) %]</td>
89
                                    <td>
90
                                        [% FOREACH i IN c.instructors %]
91
                                            <div class="instructor"><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% i.borrowernumber %]">[% i.firstname %] [% i.surname %]</a></div>
92
                                        [% END %]
93
                                    </td>
94
                                    <td>[% c.staff_note %]</td>
95
                                    <td>[% c.public_note %]</td>
96
                                    <td>[% c.students_count %]</td>
97
                                    <td>
98
                                        [% IF c.enabled == 'yes' %]
99
                                            <img src="/intranet-tmpl/prog/img/approve.gif" />
100
                                        [% ELSE %]
101
                                            <img src="http://kohadev:8080/intranet-tmpl/prog/img/deny.gif" />
102
                                        [% END %]
103
                                    </td>
104
                            [% END %]
105
                        </tbody>
106
                    </table>
107
                </div>
108
            </div>
109
        </div>
110
    </div>
111
</div>
112
113
114
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt (+204 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Course reserves &rsaquo; [% IF course_name %] Edit [% course_name %] [% ELSE %] New course [% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
5
<script type="text/javascript">
6
//<![CDATA[
7
8
    function Check(f) {
9
        var _alertString = "";
10
11
        if( ! $("#department").val() ) {
12
            _alertString += _("- You must choose a department") + "\n";
13
        }
14
15
        if( ! $("#course_number").val() ) {
16
            _alertString += _("- You must choose a course number") + "\n";
17
        }
18
19
        if( ! $("#course_name").val() ) {
20
            _alertString += _("- You must add a course name") + "\n";
21
        }
22
23
        if ( _alertString.length ) {
24
            var alertHeader;
25
            alertHeader = _("Form not submitted because of the following problem(s)");
26
            alertHeader += "\n------------------------------------------------------------------------------------\n\n";
27
28
            alert( alertHeader + _alertString );
29
        } else {
30
            f.submit();
31
        }
32
    }
33
34
//]]>
35
</script>
36
37
<script type="text/javascript">
38
//<![CDATA[
39
$(document).ready(function(){
40
    $( "#find_instructor" ).autocomplete({
41
        source: "/cgi-bin/koha/circ/ysearch.pl",
42
        minLength: 3,
43
        select: function( event, ui ) {
44
            AddInstructor( ui.item.firstname + " " + ui.item.surname, ui.item.cardnumber );
45
            return false;
46
        }
47
    })
48
    .data( "autocomplete" )._renderItem = function( ul, item ) {
49
        return $( "<li></li>" )
50
        .data( "item.autocomplete", item )
51
        .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
52
        .appendTo( ul );
53
    };
54
55
});
56
57
function AddInstructor( name, cardnumber ) {
58
    div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' onclick='RemoveInstructor(" + cardnumber + ");return false;'> Remove </a> ) <input type='hidden' name='instructors' value='" + cardnumber + "' /></div>";
59
    $('#instructors').append( div );
60
61
    $('#find_instructor').val('').focus();
62
}
63
64
function RemoveInstructor( cardnumber ) {
65
    $( '#borrower_' + cardnumber ).remove();
66
}
67
68
//]]>
69
</script>
70
71
</head>
72
73
<body>
74
75
[% INCLUDE 'header.inc' %]
76
[% INCLUDE 'cat-search.inc' %]
77
78
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a> &rsaquo; [% IF course_name %] Edit <i>[% course_name %]</i> [% ELSE %] New course [% END %]</div>
79
80
<div id="doc2" class="yui-t7">
81
    <div id="bd">
82
        <div id="yui-main">
83
            <div class="yui-b">
84
                <div class="yui-g">
85
                    <div class="yui-u first">
86
                        <form method="post" action="/cgi-bin/koha/course_reserves/mod_course.pl">
87
                            [% IF course_id %]<input type="hidden" name="course_id" value="[% course_id %]" />[% END %]
88
                            <fieldset class="rows">
89
                                <legend>[% IF course_id %] Edit [% ELSE %] Create [% END %] course</legend>
90
                                <ol>
91
                                    <li>
92
                                        <label class="required" for="department">Department:</label>
93
                                        [% IF departments %]
94
                                            <select id="department" name="department">
95
                                                <option value="">Select A Department</option>
96
97
                                                [% FOREACH d IN departments %]
98
                                                    [% IF d.authorised_value == department %]
99
                                                        <option value="[% d.authorised_value %]" selected="selected">[% d.lib %]</option>
100
                                                    [% ELSE %]
101
                                                        <option value="[% d.authorised_value %]">[% d.lib %]</option>
102
                                                    [% END %]
103
                                                [% END %]
104
                                            </select>
105
                                        [% ELSE %]
106
                                            <span id="department">No DEPARTMENT authorised values found! Please create one or more authorised values with the category DEPARTMENT.</span>
107
                                        [% END %]
108
                                    </li>
109
110
                                    <li>
111
                                        <label class="required" for="course_number">Course number:</label>
112
                                        <input id="course_number" name="course_number" type="text" value="[% course_number %]" />
113
                                    </li>
114
115
                                    <li>
116
                                        <label for="section">Section:</label>
117
                                        <input id="section" name="section" type="text" value="[% section %]"/>
118
                                    </li>
119
120
                                    <li>
121
                                        <label class="required" for="course_name">Course name:</label>
122
                                        <input id="course_name" name="course_name" type="text" value="[% course_name %]" />
123
                                    </li>
124
125
                                    <li>
126
                                        <label for="term">Term:</label>
127
                                        [% IF terms %]
128
                                            <select id="term" name="term">
129
                                                <option value=""></option>
130
131
                                                [% FOREACH t IN terms %]
132
                                                    [% IF t.authorised_value == term %]
133
                                                        <option value="[% t.authorised_value %]" selected="selected">[% t.lib %]</option>
134
                                                    [% ELSE %]
135
                                                        <option value="[% t.authorised_value %]">[% t.lib %]</option>
136
                                                    [% END %]
137
                                                [% END %]
138
                                            </select>
139
                                        [% ELSE %]
140
                                            <span id="term">No TERM authorised values found! Please create one or more authorised values with the category TERM.</span>
141
                                        [% END %]
142
                                    </li>
143
144
                                    <li>
145
                                        <label for="instructors">Instructors:</label>
146
147
                                        <fieldset>
148
                                             <div id="instructors">
149
                                                 [% FOREACH i IN instructors %]
150
                                                     <div id="borrower_[% i.cardnumber %]">
151
                                                         [% i.surname %], [% i.firstname %] ( <a href='#' onclick='RemoveInstructor( [% i.cardnumber %] );'> Remove </a> )
152
                                                         <input type='hidden' name='instructors' value='[% i.cardnumber %]' />
153
                                                     </div>
154
                                                 [% END %]
155
                                             </div>
156
157
                                        </fieldset>
158
159
                                        <fieldset>
160
                                            <label for="find_instructor">Instructor search:</label>
161
                                            <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit"/>
162
                                            <div id="find_instructor_container"></div>
163
                                        </fieldset>
164
                                    <li>
165
                                        <label for="staff_note">Staff note:</label>
166
                                        <textarea name="staff_note" id="staff_note">[% staff_note %]</textarea>
167
                                    </li>
168
169
                                    <li>
170
                                        <label for="public_note">Public note:</label>
171
                                        <textarea name="public_note" id="public_note">[% public_note %]</textarea>
172
                                    </li>
173
174
                                    <li>
175
                                        <label for="students_count">Number of students:</label>
176
                                        <input id="students_count" name="students_count" type="text" value="[% students_count %]" />
177
                                    </li>
178
179
                                    <li>
180
                                        <label for="enabled">Enabled?</label>
181
                                        [% IF enabled == 'no' %]
182
                                            <input type="checkbox" name="enabled" id="enabled" />
183
                                        [% ELSE %]
184
                                            <input type="checkbox" name="enabled" id="enabled" checked="checked" />
185
                                        [% END %]
186
                                    </li>
187
                                </ol>
188
                            </fieldset>
189
190
                            <fieldset class="action">
191
                                <input type="submit" onclick="Check(this.form); return false;" value="Save" class="submit" />
192
193
                                <a href="/cgi-bin/koha/course_reserves/course-reserves.pl" class="cancel">Cancel</a>
194
                            </fieldset>
195
196
                    </div>
197
                </div>
198
            </div>
199
        </div>
200
    </div>
201
</div>
202
203
204
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/invalid-course.tt (+24 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Course reserves</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
<body id="lists_shelves" class="lists">
5
6
[% INCLUDE 'header.inc' %]
7
[% INCLUDE 'cat-search.inc' %]
8
9
<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>
10
11
<div id="doc2" class="yui-t7">
12
    <div id="bd">
13
        <div id="yui-main">
14
            <div class="yui-b">
15
                <div class="yui-g">
16
                    <p>Invalid course!</p>
17
                </div>
18
            </div>
19
        </div>
20
    </div>
21
</div>
22
23
24
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt (-1 / +1 lines)
Lines 4-11 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); });
8
        $('#mancredit').preventDoubleFormSubmit();
7
        $('#mancredit').preventDoubleFormSubmit();
8
        $("fieldset.rows input").addClass("noEnterSubmit");
9
});
9
});
10
//]]>
10
//]]>
11
</script>
11
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt (-1 / +1 lines)
Lines 4-11 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); });
8
        $('#maninvoice').preventDoubleFormSubmit();
7
        $('#maninvoice').preventDoubleFormSubmit();
8
        $("fieldset.rows input").addClass("noEnterSubmit");
9
});
9
});
10
//]]>
10
//]]>
11
</script>
11
</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/ccsr/en/includes/masthead.inc (+1 lines)
Lines 192-197 Link Here
192
192
193
<div id="moresearches">
193
<div id="moresearches">
194
<a href="/cgi-bin/koha/opac-search.pl">Advanced search</a>
194
<a href="/cgi-bin/koha/opac-search.pl">Advanced search</a>
195
[% IF ( UseCourseReserves ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-course-reserves.pl">Course Reserves</a>[% END %]
195
[% IF ( OpacBrowser ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-browser.pl">Browse by hierarchy</a>[% END %]
196
[% IF ( OpacBrowser ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-browser.pl">Browse by hierarchy</a>[% END %]
196
[% IF ( OpacAuthorities ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-authorities-home.pl">Authority search</a>[% END %]
197
[% IF ( OpacAuthorities ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-authorities-home.pl">Authority search</a>[% END %]
197
[% IF ( opacuserlogin && ( Koha.Preference( 'reviewson' ) == 1 ) && ( Koha.Preference( 'OpacShowRecentComments' ) == 1 ) ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %]
198
[% IF ( opacuserlogin && ( Koha.Preference( 'reviewson' ) == 1 ) && ( Koha.Preference( 'OpacShowRecentComments' ) == 1 ) ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %]
(-)a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc (+1 lines)
Lines 131-136 Link Here
131
131
132
<div id="moresearches">
132
<div id="moresearches">
133
<a href="/cgi-bin/koha/opac-search.pl">Advanced search</a>
133
<a href="/cgi-bin/koha/opac-search.pl">Advanced search</a>
134
[% IF ( UseCourseReserves ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-course-reserves.pl">Course Reserves</a>[% END %]
134
[% IF ( OpacBrowser ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-browser.pl">Browse by hierarchy</a>[% END %]
135
[% IF ( OpacBrowser ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-browser.pl">Browse by hierarchy</a>[% END %]
135
[% IF ( OpacAuthorities ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-authorities-home.pl">Authority search</a>[% END %]
136
[% IF ( OpacAuthorities ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-authorities-home.pl">Authority search</a>[% END %]
136
[% IF ( opacuserlogin && ( Koha.Preference( 'reviewson' ) == 1 ) && ( Koha.Preference( 'OpacShowRecentComments' ) == 1 ) ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %]
137
[% IF ( opacuserlogin && ( Koha.Preference( 'reviewson' ) == 1 ) && ( Koha.Preference( 'OpacShowRecentComments' ) == 1 ) ) %]<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 (+31 lines)
Lines 1-8 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE KohaDates %]
2
[% USE KohaDates %]
3
[% USE AuthorisedValues %]
3
[% SET TagsShowEnabled = ( TagsEnabled && TagsShowOnDetail ) %]
4
[% SET TagsShowEnabled = ( TagsEnabled && TagsShowOnDetail ) %]
4
[% SET TagsInputEnabled = ( opacuserlogin && TagsEnabled && TagsInputOnDetail ) %]
5
[% SET TagsInputEnabled = ( opacuserlogin && TagsEnabled && TagsInputOnDetail ) %]
5
6
7
[% ShowCourseReservesHeader = 0 %]
8
[% IF UseCourseReserves %]
9
    [% FOREACH ITEM_RESULT IN itemloop %]
10
       [% IF ITEM_RESULT.course_reserves %]
11
           [% FOREACH r IN ITEM_RESULT.course_reserves %]
12
               [% IF r.course.enabled == 'yes' %]
13
                   [% ShowCourseReservesHeader = 1 %]
14
               [% END %]
15
           [% END %]
16
        [% END %]
17
    [% END %]
18
[% END %]
19
6
[% 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 %]
20
[% 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 %]
7
[% INCLUDE 'doc-head-close.inc' %]
21
[% INCLUDE 'doc-head-close.inc' %]
8
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
22
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
Lines 1477-1482 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1477
        [% ELSIF show_priority %]
1491
        [% ELSIF show_priority %]
1478
            <th>Item hold queue priority</th>
1492
            <th>Item hold queue priority</th>
1479
        [% END %]
1493
        [% END %]
1494
        [% IF ( ShowCourseReservesHeader ) %]<th id="item_coursereserves">Course Reserves</th>[% END %]
1480
        </tr></thead>
1495
        </tr></thead>
1481
	    <tbody>[% FOREACH ITEM_RESULT IN items %]
1496
	    <tbody>[% FOREACH ITEM_RESULT IN items %]
1482
      [% IF ITEM_RESULT.this_branch %]<tr class="highlight-row-detail">[% ELSE %]<tr>[% END %]
1497
      [% IF ITEM_RESULT.this_branch %]<tr class="highlight-row-detail">[% ELSE %]<tr>[% END %]
Lines 1524-1529 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1524
            [% END %]
1539
            [% END %]
1525
                </td>
1540
                </td>
1526
        [% END %]
1541
        [% END %]
1542
        [% IF ShowCourseReservesHeader %]
1543
            <td>
1544
                [% IF ITEM_RESULT.course_reserves %]
1545
                    [% FOREACH r IN ITEM_RESULT.course_reserves %]
1546
                        <p>
1547
                            <a href="opac-course-details.pl?course_id=[% r.course.course_id %]">
1548
                                [% r.course.course_name %]
1549
                                <!--[% IF r.course.course_number %] [% r.course.course_number %] [% END %]-->
1550
                                [% IF r.course.section %] [% r.course.section %] [% END %]
1551
                                [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) %] [% END %]
1552
                            </a>
1553
                        </p>
1554
                    [% END %]
1555
                [% END %]
1556
            </td>
1557
        [% END %]
1527
	    </tr>
1558
	    </tr>
1528
	    [% END %]</tbody>
1559
	    [% END %]</tbody>
1529
	</table>
1560
	</table>
(-)a/opac/opac-course-details.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
use C4::Koha;
28
29
use C4::CourseReserves qw(GetCourse GetCourseReserves);
30
31
my $cgi = new CGI;
32
33
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
34
    {   template_name   => "opac-course-details.tmpl",
35
        query           => $cgi,
36
        type            => "opac",
37
        authnotrequired => 1,
38
        debug           => 1,
39
    }
40
);
41
42
my $course_id = $cgi->param('course_id');
43
44
die("No course_id given") unless ($course_id);
45
46
my $course = GetCourse($course_id);
47
my $course_reserves = GetCourseReserves( course_id => $course_id, include_items => 1, include_count => 1 );
48
49
$template->param(
50
    course          => $course,
51
    course_reserves => $course_reserves,
52
);
53
54
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/opac/opac-course-reserves.pl (+50 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 C4::CourseReserves qw(SearchCourses);
29
30
my $cgi = new CGI;
31
32
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
33
    {   template_name   => "opac-course-reserves.tmpl",
34
        query           => $cgi,
35
        type            => "opac",
36
        authnotrequired => 1,
37
        debug           => 1,
38
    }
39
);
40
41
my $search_on = $cgi->param('search_on');
42
43
my $courses = SearchCourses( term => $search_on, enabled => 'yes' );
44
45
if ( @$courses == 1 ) {
46
    print $cgi->redirect( "/cgi-bin/koha/opac-course-details.pl?course_id=" . $courses->[0]->{'course_id'} );
47
} else {
48
    $template->param( courses => $courses );
49
    output_html_with_http_headers $cgi, $cookie, $template->output;
50
}
(-)a/opac/opac-detail.pl (+7 lines)
Lines 50-55 use List::MoreUtils qw/any none/; Link Here
50
use C4::Images;
50
use C4::Images;
51
use Koha::DateUtils;
51
use Koha::DateUtils;
52
use C4::HTML5Media;
52
use C4::HTML5Media;
53
use C4::CourseReserves qw(GetItemCourseReservesInfo);
53
54
54
BEGIN {
55
BEGIN {
55
	if (C4::Context->preference('BakerTaylorEnabled')) {
56
	if (C4::Context->preference('BakerTaylorEnabled')) {
Lines 1055-1058 if (C4::Context->preference('OpacHighlightedWords')) { Link Here
1055
}
1056
}
1056
$template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks');
1057
$template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks');
1057
1058
1059
if ( C4::Context->preference('UseCourseReserves') ) {
1060
    foreach my $i ( @items ) {
1061
        $i->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $i->{'itemnumber'} );
1062
    }
1063
}
1064
1058
output_html_with_http_headers $query, $cookie, $template->output;
1065
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/t/db_dependent/CourseReserves.t (-1 / +88 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
#
3
# This is to test C4/Members
4
# It requires a working Koha database with the sample data
5
6
use strict;
7
use warnings;
8
9
use Test::More tests => 16;
10
use Data::Dumper;
11
12
BEGIN {
13
    use_ok('C4::Context');
14
    use_ok('C4::CourseReserves', qw/:all/);
15
}
16
17
my $dbh = C4::Context->dbh;
18
$dbh->do("TRUNCATE TABLE course_instructors");
19
$dbh->do("TRUNCATE TABLE courses");
20
$dbh->do("TRUNCATE TABLE course_reserves");
21
22
my $sth = $dbh->prepare("SELECT * FROM borrowers ORDER BY RAND() LIMIT 10");
23
$sth->execute();
24
my @borrowers = @{ $sth->fetchall_arrayref( {} ) };
25
26
$sth = $dbh->prepare("SELECT * FROM items ORDER BY RAND() LIMIT 10");
27
$sth->execute();
28
my @items = @{ $sth->fetchall_arrayref( {} ) };
29
30
my $course_id = ModCourse(
31
    course_name => "Test Course",
32
    staff_note  => "Test staff note",
33
    public_note => "Test public note",
34
);
35
36
ok( $course_id, "ModCourse created course successfully" );
37
38
$course_id = ModCourse(
39
    course_id  => $course_id,
40
    staff_note => "Test staff note 2",
41
);
42
43
my $course = GetCourse($course_id);
44
45
ok( $course->{'course_name'} eq "Test Course",       "GetCourse returned correct course" );
46
ok( $course->{'staff_note'}  eq "Test staff note 2", "ModCourse updated course succesfully" );
47
48
my $courses = GetCourses();
49
ok( $courses->[0]->{'course_name'} eq "Test Course", "GetCourses returns valid array of course data" );
50
51
ModCourseInstructors( mode => 'add', course_id => $course_id, borrowernumbers => [ $borrowers[0]->{'borrowernumber'} ] );
52
$course = GetCourse($course_id);
53
ok( $course->{'instructors'}->[0]->{'borrowernumber'} == $borrowers[0]->{'borrowernumber'}, "ModCourseInstructors added instructors correctly" );
54
55
my $course_instructors = GetCourseInstructors($course_id);
56
ok( $course_instructors->[0]->{'borrowernumber'} eq $borrowers[0]->{'borrowernumber'}, "GetCourseInstructors returns valid data" );
57
58
my $ci_id = ModCourseItem( 'itemnumber' => $items[0]->{'itemnumber'} );
59
ok( $ci_id, "ModCourseItem returned valid data" );
60
61
my $course_item = GetCourseItem( 'ci_id' => $ci_id );
62
ok( $course_item->{'itemnumber'} eq $items[0]->{'itemnumber'}, "GetCourseItem returns valid data" );
63
64
my $cr_id = ModCourseReserve( 'course_id' => $course_id, 'ci_id' => $ci_id );
65
ok( $cr_id, "ModCourseReserve returns valid data" );
66
67
my $course_reserve = GetCourseReserve( 'course_id' => $course_id, 'ci_id' => $ci_id );
68
ok( $course_reserve->{'cr_id'} eq $cr_id, "GetCourseReserve returns valid data" );
69
70
my $course_reserves = GetCourseReserves( 'course_id' => $course_id );
71
ok( $course_reserves->[0]->{'ci_id'} eq $ci_id, "GetCourseReserves returns valid data." );
72
73
my $info = GetItemCourseReservesInfo( itemnumber => $items[0]->{'itemnumber'} );
74
ok( $info->[0]->{'itemnumber'} eq $items[0]->{'itemnumber'}, "GetItemReservesInfo returns valid data." );
75
76
DelCourseReserve( 'cr_id' => $cr_id );
77
$course_reserve = GetCourseReserve( 'cr_id' => $cr_id );
78
ok( !defined( $course_reserve->{'cr_id'} ), "DelCourseReserve functions correctly" );
79
80
DelCourse($course_id);
81
$course = GetCourse($course_id);
82
ok( !defined( $course->{'course_id'} ), "DelCourse deleted course successfully" );
83
84
$dbh->do("TRUNCATE TABLE course_instructors");
85
$dbh->do("TRUNCATE TABLE courses");
86
$dbh->do("TRUNCATE TABLE course_reserves");
87
88
exit;

Return to bug 8215