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

(-)a/C4/Auth.pm (+2 lines)
Lines 203-208 sub get_template_and_user { Link Here
203
            $template->param( CAN_user_reports          => 1 );
203
            $template->param( CAN_user_reports          => 1 );
204
            $template->param( CAN_user_staffaccess      => 1 );
204
            $template->param( CAN_user_staffaccess      => 1 );
205
            $template->param( CAN_user_plugins          => 1 );
205
            $template->param( CAN_user_plugins          => 1 );
206
            $template->param( CAN_user_coursereserves   => 1 );
206
            foreach my $module (keys %$all_perms) {
207
            foreach my $module (keys %$all_perms) {
207
                foreach my $subperm (keys %{ $all_perms->{$module} }) {
208
                foreach my $subperm (keys %{ $all_perms->{$module} }) {
208
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
209
                    $template->param( "CAN_user_${module}_${subperm}" => 1 );
Lines 327-332 sub get_template_and_user { Link Here
327
            noItemTypeImages             => C4::Context->preference("noItemTypeImages"),
328
            noItemTypeImages             => C4::Context->preference("noItemTypeImages"),
328
            marcflavour                  => C4::Context->preference("marcflavour"),
329
            marcflavour                  => C4::Context->preference("marcflavour"),
329
            persona                      => C4::Context->preference("persona"),
330
            persona                      => C4::Context->preference("persona"),
331
            UseCourseReserves            => C4::Context->preference("UseCourseReserves"),
330
    );
332
    );
331
    if ( $in->{'type'} eq "intranet" ) {
333
    if ( $in->{'type'} eq "intranet" ) {
332
        $template->param(
334
        $template->param(
(-)a/C4/CourseReserves.pm (+1122 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
require Exporter;
21
22
use C4::Context;
23
use C4::Items qw(GetItem ModItem);
24
use C4::Biblio qw(GetBiblioFromItemNumber);
25
use C4::Circulation qw(GetOpenIssue);
26
27
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG @FIELDS);
28
29
BEGIN {
30
    @ISA    = qw(Exporter);
31
    @EXPORT = qw(
32
      &GetCourse
33
      &ModCourse
34
      &GetCourses
35
      &DelCourse
36
37
      &GetCourseInstructors
38
      &ModCourseInstructors
39
40
      &GetCourseItem
41
      &ModCourseItem
42
43
      &GetCourseReserve
44
      &ModCourseReserve
45
      &GetCourseReserves
46
      &DelCourseReserve
47
48
      &SearchCourses
49
50
      &GetItemReservesInfo
51
    );
52
53
    $DEBUG = 0;
54
    @FIELDS = ( 'itype', 'ccode', 'holdingbranch', 'location' );
55
}
56
57
=head1 NAME
58
59
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 (
256
                CountCourseReservesForItem(
257
                    ci_id   => $course_reserve->{'ci_id'},
258
                    enabled => 'yes'
259
                )
260
              )
261
            {
262
                EnableOrDisableCourseItem(
263
                    ci_id   => $course_reserve->{'ci_id'},
264
                    enabled => 'yes',
265
                );
266
            }
267
        }
268
    }
269
    if ( $enabled eq 'no' ) {
270
        foreach my $course_reserve (@$course_reserves) {
271
            unless (
272
                CountCourseReservesForItem(
273
                    ci_id   => $course_reserve->{'ci_id'},
274
                    enabled => 'yes'
275
                )
276
              )
277
            {
278
                EnableOrDisableCourseItem(
279
                    ci_id   => $course_reserve->{'ci_id'},
280
                    enabled => 'no',
281
                );
282
            }
283
        }
284
    }
285
}
286
287
=head2 EnableOrDisableCourseItem
288
289
    EnableOrDisableCourseItem( ci_id => $ci_id, enabled => $enabled );
290
291
    enabled => 'yes' to enable course items
292
    enabled => 'no' to disable course items
293
294
=cut
295
296
sub EnableOrDisableCourseItem {
297
    my (%params) = @_;
298
    warn identify_myself(%params) if $DEBUG;
299
300
    my $ci_id   = $params{'ci_id'};
301
    my $enabled = $params{'enabled'};
302
303
    return unless ( $ci_id && $enabled );
304
    return unless ( $enabled eq 'yes' || $enabled eq 'no' );
305
306
    my $course_item = GetCourseItem( ci_id => $ci_id );
307
308
    ## We don't want to 'enable' an already enabled item,
309
    ## or disable and already disabled item,
310
    ## as that would cause the fields to swap
311
    if ( $course_item->{'enabled'} ne $enabled ) {
312
        _SwapAllFields($ci_id);
313
314
        my $query = "
315
            UPDATE course_items
316
            SET enabled = ?
317
            WHERE ci_id = ?
318
        ";
319
320
        C4::Context->dbh->do( $query, undef, $enabled, $ci_id );
321
322
    }
323
324
}
325
326
=head2 GetCourseInstructors
327
328
    @$borrowers = GetCourseInstructors( $course_id );
329
330
=cut
331
332
sub GetCourseInstructors {
333
    my ($course_id) = @_;
334
    warn "C4::CourseReserves::GetCourseInstructors( $course_id )"
335
      if $DEBUG;
336
337
    my $query = "
338
        SELECT * FROM borrowers
339
        RIGHT JOIN course_instructors ON ( course_instructors.borrowernumber = borrowers.borrowernumber )
340
        WHERE course_instructors.course_id = ?
341
    ";
342
343
    my $dbh = C4::Context->dbh;
344
    my $sth = $dbh->prepare($query);
345
    $sth->execute($course_id);
346
347
    return $sth->fetchall_arrayref( {} );
348
}
349
350
=head2 ModCourseInstructors
351
352
    ModCourseInstructors( mode => $mode, course_id => $course_id, [ cardnumbers => $cardnumbers ] OR [ borrowernumbers => $borrowernumbers  );
353
354
    $mode can be 'replace', 'add', or 'delete'
355
356
    $cardnumbers and $borrowernumbers are both references to arrays
357
358
    Use either cardnumbers or borrowernumber, but not both.
359
360
=cut
361
362
sub ModCourseInstructors {
363
    my (%params) = @_;
364
    warn identify_myself(%params) if $DEBUG;
365
366
    my $course_id       = $params{'course_id'};
367
    my $mode            = $params{'mode'};
368
    my $cardnumbers     = $params{'cardnumbers'};
369
    my $borrowernumbers = $params{'borrowernumbers'};
370
371
    return unless ($course_id);
372
    return
373
      unless ( $mode eq 'replace'
374
        || $mode eq 'add'
375
        || $mode eq 'delete' );
376
    return unless ( $cardnumbers || $borrowernumbers );
377
    return if ( $cardnumbers && $borrowernumbers );
378
379
    my @cardnumbers = @$cardnumbers if ( ref($cardnumbers) eq 'ARRAY' );
380
    my @borrowernumbers = @$borrowernumbers
381
      if ( ref($borrowernumbers) eq 'ARRAY' );
382
383
    my $field  = (@cardnumbers) ? 'cardnumber' : 'borrowernumber';
384
    my @fields = (@cardnumbers) ? @cardnumbers : @borrowernumbers;
385
    my $placeholders = join( ',', ('?') x scalar @fields );
386
387
    my $dbh = C4::Context->dbh;
388
389
    $dbh->do( "DELETE FROM course_instructors WHERE course_id = ?",
390
        undef, $course_id )
391
      if ( $mode eq 'replace' );
392
393
    my $query;
394
395
    if ( $mode eq 'add' || $mode eq 'replace' ) {
396
        $query = "
397
            INSERT INTO course_instructors ( course_id, borrowernumber )
398
            SELECT ?, borrowernumber
399
            FROM borrowers
400
            WHERE $field IN ( $placeholders )
401
        ";
402
    }
403
    else {
404
        $query = "
405
            DELETE FROM course_instructors
406
            WHERE course_id = ?
407
            AND borrowernumber IN (
408
                SELECT borrowernumber FROM borrowers WHERE $field IN ( $placeholders )
409
            )
410
        ";
411
    }
412
413
    my $sth = $dbh->prepare($query);
414
415
    $sth->execute( $course_id, @fields ) if (@fields);
416
}
417
418
=head2 GetCourseItem {
419
420
  $course_item = GetCourseItem( itemnumber => $itemnumber [, ci_id => $ci_id );
421
422
=cut
423
424
sub GetCourseItem {
425
    my (%params) = @_;
426
    warn identify_myself(%params) if $DEBUG;
427
428
    my $ci_id      = $params{'ci_id'};
429
    my $itemnumber = $params{'itemnumber'};
430
431
    return unless ( $itemnumber || $ci_id );
432
433
    my $field = ($itemnumber) ? 'itemnumber' : 'ci_id';
434
    my $value = ($itemnumber) ? $itemnumber  : $ci_id;
435
436
    my $query = "SELECT * FROM course_items WHERE $field = ?";
437
    my $dbh   = C4::Context->dbh;
438
    my $sth   = $dbh->prepare($query);
439
    $sth->execute($value);
440
441
    my $course_item = $sth->fetchrow_hashref();
442
443
    if ($course_item) {
444
        $query = "SELECT * FROM course_reserves WHERE ci_id = ?";
445
        $sth   = $dbh->prepare($query);
446
        $sth->execute( $course_item->{'ci_id'} );
447
        my $course_reserves = $sth->fetchall_arrayref( {} );
448
449
        $course_item->{'course_reserves'} = $course_reserves
450
          if ($course_reserves);
451
    }
452
    return $course_item;
453
}
454
455
=head2 ModCourseItem {
456
457
  ModCourseItem( %params );
458
459
  Creates or modifies an existing course item.
460
461
=cut
462
463
sub ModCourseItem {
464
    my (%params) = @_;
465
    warn identify_myself(%params) if $DEBUG;
466
467
    my $itemnumber    = $params{'itemnumber'};
468
    my $itype         = $params{'itype'};
469
    my $ccode         = $params{'ccode'};
470
    my $holdingbranch = $params{'holdingbranch'};
471
    my $location      = $params{'location'};
472
473
    return unless ($itemnumber);
474
475
    my $course_item = GetCourseItem( itemnumber => $itemnumber );
476
477
    my $ci_id;
478
479
    if ($course_item) {
480
        $ci_id = $course_item->{'ci_id'};
481
482
        _UpdateCourseItem(
483
            ci_id       => $ci_id,
484
            course_item => $course_item,
485
            %params
486
        );
487
    }
488
    else {
489
        $ci_id = _AddCourseItem(%params);
490
    }
491
492
    return $ci_id;
493
494
}
495
496
=head2 _AddCourseItem
497
498
    my $ci_id = _AddCourseItem( %params );
499
500
=cut
501
502
sub _AddCourseItem {
503
    my (%params) = @_;
504
    warn identify_myself(%params) if $DEBUG;
505
506
    my ( @fields, @values );
507
508
    push( @fields, 'itemnumber = ?' );
509
    push( @values, $params{'itemnumber'} );
510
511
    foreach (@FIELDS) {
512
        if ( $params{$_} ) {
513
            push( @fields, "$_ = ?" );
514
            push( @values, $params{$_} );
515
        }
516
    }
517
518
    my $query = "INSERT INTO course_items SET " . join( ',', @fields );
519
    my $dbh = C4::Context->dbh;
520
    $dbh->do( $query, undef, @values );
521
522
    my $ci_id = $dbh->last_insert_id( undef, undef, 'course_items', 'ci_id' );
523
524
    return $ci_id;
525
}
526
527
=head2 _UpdateCourseItem
528
529
  _UpdateCourseItem( %params );
530
531
=cut
532
533
sub _UpdateCourseItem {
534
    my (%params) = @_;
535
    warn identify_myself(%params) if $DEBUG;
536
537
    my $ci_id         = $params{'ci_id'};
538
    my $course_item   = $params{'course_item'};
539
    my $itype         = $params{'itype'};
540
    my $ccode         = $params{'ccode'};
541
    my $holdingbranch = $params{'holdingbranch'};
542
    my $location      = $params{'location'};
543
544
    return unless ( $ci_id || $course_item );
545
546
    $course_item = GetCourseItem( ci_id => $ci_id )
547
      unless ($course_item);
548
    $ci_id = $course_item->{'ci_id'} unless ($ci_id);
549
550
    ## Revert fields that had an 'original' value, but now don't
551
    ## Update the item fields to the stored values from course_items
552
    ## and then set those fields in course_items to NULL
553
    my @fields_to_revert;
554
    foreach (@FIELDS) {
555
        if ( !$params{$_} && $course_item->{$_} ) {
556
            push( @fields_to_revert, $_ );
557
        }
558
    }
559
    _RevertFields(
560
        ci_id       => $ci_id,
561
        fields      => \@fields_to_revert,
562
        course_item => $course_item
563
    ) if (@fields_to_revert);
564
565
    ## Update fields that still have an original value, but it has changed
566
    ## This necessitates only changing the current item values, as we still
567
    ## have the original values stored in course_items
568
    my %mod_params;
569
    foreach (@FIELDS) {
570
        if (   $params{$_}
571
            && $course_item->{$_}
572
            && $params{$_} ne $course_item->{$_} )
573
        {
574
            $mod_params{$_} = $params{$_};
575
        }
576
    }
577
    ModItem( \%mod_params, undef, $course_item->{'itemnumber'} );
578
579
    ## Update fields that didn't have an original value, but now do
580
    ## We must save the original value in course_items, and also
581
    ## update the item fields to the new value
582
    my $item = GetItem( $course_item->{'itemnumber'} );
583
    my %mod_params_new;
584
    my %mod_params_old;
585
    foreach (@FIELDS) {
586
        if ( $params{$_} && !$course_item->{$_} ) {
587
            $mod_params_new{$_} = $params{$_};
588
            $mod_params_old{$_} = $item->{$_};
589
        }
590
    }
591
    _ModStoredFields( 'ci_id' => $params{'ci_id'}, %mod_params_old );
592
    ModItem( \%mod_params_new, undef, $course_item->{'itemnumber'} );
593
594
}
595
596
=head2 _ModStoredFields
597
598
    _ModStoredFields( %params );
599
600
    Updates the values for the 'original' fields in course_items
601
    for a given ci_id
602
603
=cut
604
605
sub _ModStoredFields {
606
    my (%params) = @_;
607
    warn identify_myself(%params) if $DEBUG;
608
609
    return unless ( $params{'ci_id'} );
610
611
    my ( @fields_to_update, @values_to_update );
612
613
    foreach (@FIELDS) {
614
        if ( $params{$_} ) {
615
            push( @fields_to_update, $_ );
616
            push( @values_to_update, $params{$_} );
617
        }
618
    }
619
620
    my $query =
621
        "UPDATE course_items SET "
622
      . join( ',', map { "$_=?" } @fields_to_update )
623
      . " WHERE ci_id = ?";
624
625
    C4::Context->dbh->do( $query, undef, @values_to_update, $params{'ci_id'} )
626
      if (@values_to_update);
627
628
}
629
630
=head2 _RevertFields
631
632
    _RevertFields( ci_id => $ci_id, fields => \@fields_to_revert );
633
634
=cut
635
636
sub _RevertFields {
637
    my (%params) = @_;
638
    warn identify_myself(%params) if $DEBUG;
639
640
    my $ci_id       = $params{'ci_id'};
641
    my $course_item = $params{'course_item'};
642
    my $fields      = $params{'fields'};
643
    my @fields      = @$fields;
644
645
    return unless ($ci_id);
646
647
    $course_item = GetCourseItem( ci_id => $params{'ci_id'} )
648
      unless ($course_item);
649
650
    my $mod_item_params;
651
    my @fields_to_null;
652
    foreach my $field (@fields) {
653
        foreach (@FIELDS) {
654
            if ( $field eq $_ && $course_item->{$_} ) {
655
                $mod_item_params->{$_} = $course_item->{$_};
656
                push( @fields_to_null, $_ );
657
            }
658
        }
659
    }
660
    ModItem( $mod_item_params, undef, $course_item->{'itemnumber'} );
661
662
    my $query =
663
        "UPDATE course_items SET "
664
      . join( ',', map { "$_=NULL" } @fields_to_null )
665
      . " WHERE ci_id = ?";
666
667
    C4::Context->dbh->do( $query, undef, $ci_id ) if (@fields_to_null);
668
}
669
670
=head2 _SwapAllFields
671
672
    _SwapAllFields( $ci_id );
673
674
=cut
675
676
sub _SwapAllFields {
677
    my ($ci_id) = @_;
678
    warn "C4::CourseReserves::_SwapFields( $ci_id )" if $DEBUG;
679
680
    my $course_item = GetCourseItem( ci_id => $ci_id );
681
    my $item = GetItem( $course_item->{'itemnumber'} );
682
683
    my %course_item_fields;
684
    my %item_fields;
685
    foreach (@FIELDS) {
686
        if ( $course_item->{$_} ) {
687
            $course_item_fields{$_} = $course_item->{$_};
688
            $item_fields{$_}        = $item->{$_};
689
        }
690
    }
691
692
    ModItem( \%course_item_fields, undef, $course_item->{'itemnumber'} );
693
    _ModStoredFields( %item_fields, ci_id => $ci_id );
694
}
695
696
=head2 GetCourseItems {
697
698
  $course_items = GetCourseItems(
699
      [course_id => $course_id]
700
      [, itemnumber => $itemnumber ]
701
  );
702
703
=cut
704
705
sub GetCourseItems {
706
    my (%params) = @_;
707
    warn identify_myself(%params) if $DEBUG;
708
709
    my $course_id  = $params{'course_id'};
710
    my $itemnumber = $params{'itemnumber'};
711
712
    return unless ($course_id);
713
714
    my @query_keys;
715
    my @query_values;
716
717
    my $query = "SELECT * FROM course_items";
718
719
    if ( keys %params ) {
720
721
        $query .= " WHERE ";
722
723
        foreach my $key ( keys %params ) {
724
            push( @query_keys,   " $key LIKE ? " );
725
            push( @query_values, $params{$key} );
726
        }
727
728
        $query .= join( ' AND ', @query_keys );
729
    }
730
731
    my $dbh = C4::Context->dbh;
732
    my $sth = $dbh->prepare($query);
733
    $sth->execute(@query_values);
734
735
    return $sth->fetchall_arrayref( {} );
736
}
737
738
=head2 DelCourseItem {
739
740
  DelCourseItem( ci_id => $cr_id );
741
742
=cut
743
744
sub DelCourseItem {
745
    my (%params) = @_;
746
    warn identify_myself(%params) if $DEBUG;
747
748
    my $ci_id = $params{'ci_id'};
749
750
    return unless ($ci_id);
751
752
    _RevertFields( ci_id => $ci_id, fields => \@FIELDS );
753
754
    my $query = "
755
        DELETE FROM course_items
756
        WHERE ci_id = ?
757
    ";
758
    C4::Context->dbh->do( $query, undef, $ci_id );
759
}
760
761
=head2 GetCourseReserve {
762
763
  $course_item = GetCourseReserve( %params );
764
765
=cut
766
767
sub GetCourseReserve {
768
    my (%params) = @_;
769
    warn identify_myself(%params) if $DEBUG;
770
771
    my $cr_id     = $params{'cr_id'};
772
    my $course_id = $params{'course_id'};
773
    my $ci_id     = $params{'ci_id'};
774
775
    return unless ( $cr_id || ( $course_id && $ci_id ) );
776
777
    my $dbh = C4::Context->dbh;
778
    my $sth;
779
780
    if ($cr_id) {
781
        my $query = "
782
            SELECT * FROM course_reserves
783
            WHERE cr_id = ?
784
        ";
785
        $sth = $dbh->prepare($query);
786
        $sth->execute($cr_id);
787
    }
788
    else {
789
        my $query = "
790
            SELECT * FROM course_reserves
791
            WHERE course_id = ? AND ci_id = ?
792
        ";
793
        $sth = $dbh->prepare($query);
794
        $sth->execute( $course_id, $ci_id );
795
    }
796
797
    my $course_reserve = $sth->fetchrow_hashref();
798
    return $course_reserve;
799
}
800
801
=head2 ModCourseReserve
802
803
    $id = ModCourseReserve( %params );
804
805
=cut
806
807
sub ModCourseReserve {
808
    my (%params) = @_;
809
    warn identify_myself(%params) if $DEBUG;
810
811
    my $course_id   = $params{'course_id'};
812
    my $ci_id       = $params{'ci_id'};
813
    my $staff_note  = $params{'staff_note'};
814
    my $public_note = $params{'public_note'};
815
816
    return unless ( $course_id && $ci_id );
817
818
    my $course_reserve =
819
      GetCourseReserve( course_id => $course_id, ci_id => $ci_id );
820
    my $cr_id;
821
822
    my $dbh = C4::Context->dbh;
823
824
    if ($course_reserve) {
825
        $cr_id = $course_reserve->{'cr_id'};
826
827
        my $query = "
828
            UPDATE course_reserves
829
            SET staff_note = ?, public_note = ?
830
            WHERE cr_id = ?
831
        ";
832
        $dbh->do( $query, undef, $staff_note, $public_note, $cr_id );
833
    }
834
    else {
835
        my $query = "
836
            INSERT INTO course_reserves SET
837
            course_id = ?,
838
            ci_id = ?,
839
            staff_note = ?,
840
            public_note = ?
841
        ";
842
        $dbh->do( $query, undef, $course_id, $ci_id, $staff_note,
843
            $public_note );
844
        $cr_id =
845
          $dbh->last_insert_id( undef, undef, 'course_reserves', 'cr_id' );
846
    }
847
848
    my $course = GetCourse($course_id);
849
    EnableOrDisableCourseItem(
850
        ci_id   => $params{'ci_id'},
851
        enabled => $course->{'enabled'}
852
    );
853
854
    return $cr_id;
855
}
856
857
=head2 GetCourseReserves {
858
859
  $course_reserves = GetCourseReserves( %params );
860
861
  Required:
862
      course_id OR ci_id
863
  Optional:
864
      include_items   => 1,
865
      include_count   => 1,
866
      include_courses => 1,
867
868
=cut
869
870
sub GetCourseReserves {
871
    my (%params) = @_;
872
    warn identify_myself(%params) if $DEBUG;
873
874
    my $course_id     = $params{'course_id'};
875
    my $ci_id         = $params{'ci_id'};
876
    my $include_items = $params{'include_items'};
877
    my $include_count = $params{'include_count'};
878
    my $include_courses = $params{'include_courses'};
879
880
    return unless ( $course_id || $ci_id );
881
882
    my $field = ($course_id) ? 'course_id' : 'ci_id';
883
    my $value = ($course_id) ? $course_id  : $ci_id;
884
885
    my $query = "
886
        SELECT cr.*, ci.itemnumber
887
        FROM course_reserves cr, course_items ci
888
        WHERE cr.$field = ?
889
        AND cr.ci_id = ci.ci_id
890
    ";
891
    my $dbh = C4::Context->dbh;
892
    my $sth = $dbh->prepare($query);
893
    $sth->execute($value);
894
895
    my $course_reserves = $sth->fetchall_arrayref( {} );
896
897
    if ($include_items) {
898
        foreach my $cr (@$course_reserves) {
899
            $cr->{'course_item'} = GetCourseItem( ci_id => $cr->{'ci_id'} );
900
            $cr->{'item'} = GetBiblioFromItemNumber( $cr->{'itemnumber'} );
901
            $cr->{'issue'} = GetOpenIssue( $cr->{'itemnumber'} );
902
        }
903
    }
904
905
    if ($include_count) {
906
        foreach my $cr (@$course_reserves) {
907
            $cr->{'reserves_count'} =
908
              CountCourseReservesForItem( ci_id => $cr->{'ci_id'} );
909
        }
910
    }
911
912
    if ($include_courses) {
913
        foreach my $cr (@$course_reserves) {
914
            $cr->{'courses'} =
915
              GetCourses( itemnumber => $cr->{'itemnumber'} );
916
        }
917
    }
918
919
    return $course_reserves;
920
}
921
922
=head2 DelCourseReserve {
923
924
  DelCourseReserve( cr_id => $cr_id );
925
926
=cut
927
928
sub DelCourseReserve {
929
    my (%params) = @_;
930
    warn identify_myself(%params) if $DEBUG;
931
932
    my $cr_id = $params{'cr_id'};
933
934
    return unless ($cr_id);
935
936
    my $dbh = C4::Context->dbh;
937
938
    my $course_reserve = GetCourseReserve( cr_id => $cr_id );
939
940
    my $query = "
941
        DELETE FROM course_reserves
942
        WHERE cr_id = ?
943
    ";
944
    $dbh->do( $query, undef, $cr_id );
945
946
    ## If there are no other course reserves for this item
947
    ## delete the course_item as well
948
    unless ( CountCourseReservesForItem( ci_id => $course_reserve->{'ci_id'} ) )
949
    {
950
        DelCourseItem( ci_id => $course_reserve->{'ci_id'} );
951
    }
952
953
}
954
955
=head2 GetReservesInfo
956
957
    my $arrayref = GetItemReservesInfo( itemnumber => $itemnumber );
958
959
    For a given item, returns an arrayref of reserves hashrefs,
960
    with a course hashref under the key 'course'
961
962
=cut
963
964
sub GetItemReservesInfo {
965
    my (%params) = @_;
966
    warn identify_myself(%params) if $DEBUG;
967
968
    my $itemnumber = $params{'itemnumber'};
969
970
    return unless ($itemnumber);
971
972
    my $course_item = GetCourseItem( itemnumber => $itemnumber );
973
974
    return unless ( keys %$course_item );
975
976
    my $course_reserves = GetCourseReserves( ci_id => $course_item->{'ci_id'} );
977
978
    foreach my $cr (@$course_reserves) {
979
        $cr->{'course'} = GetCourse( $cr->{'course_id'} );
980
    }
981
982
    return $course_reserves;
983
}
984
985
=head2 CountCourseReservesForItem
986
987
    $bool = CountCourseReservesForItem( %params );
988
989
    ci_id - course_item id
990
    OR
991
    itemnumber - course_item itemnumber
992
993
    enabled = 'yes' or 'no'
994
    Optional, if not supplied, counts reserves
995
    for both enabled and disabled courses
996
997
=cut
998
999
sub CountCourseReservesForItem {
1000
    my (%params) = @_;
1001
    warn identify_myself(%params) if $DEBUG;
1002
1003
    my $ci_id      = $params{'ci_id'};
1004
    my $itemnumber = $params{'itemnumber'};
1005
    my $enabled    = $params{'enabled'};
1006
1007
    return unless ( $ci_id || $itemnumber );
1008
1009
    my $course_item =
1010
      GetCourseItem( ci_id => $ci_id, itemnumber => $itemnumber );
1011
1012
    my @params = ( $course_item->{'ci_id'} );
1013
    push( @params, $enabled ) if ($enabled);
1014
1015
    my $query = "
1016
        SELECT COUNT(*) AS count
1017
        FROM course_reserves cr
1018
        LEFT JOIN courses c ON ( c.course_id = cr.course_id )
1019
        WHERE ci_id = ?
1020
    ";
1021
    $query .= "AND c.enabled = ?" if ($enabled);
1022
1023
    my $dbh = C4::Context->dbh;
1024
    my $sth = $dbh->prepare($query);
1025
    $sth->execute(@params);
1026
1027
    my $row = $sth->fetchrow_hashref();
1028
1029
    return $row->{'count'};
1030
}
1031
1032
=head2 SearchCourses
1033
1034
    my $courses = SearchCourses( term => $search_term, enabled => 'yes' );
1035
1036
=cut
1037
1038
sub SearchCourses {
1039
    my (%params) = @_;
1040
    warn identify_myself(%params) if $DEBUG;
1041
1042
    my $term = $params{'term'};
1043
1044
    my $enabled = $params{'enabled'} || '%';
1045
1046
    my @params;
1047
    my $query = "SELECT c.* FROM courses c";
1048
1049
    $query .= "
1050
        LEFT JOIN course_instructors ci
1051
            ON ( c.course_id = ci.course_id )
1052
        LEFT JOIN borrowers b
1053
            ON ( ci.borrowernumber = b.borrowernumber )
1054
        LEFT JOIN authorised_values av
1055
            ON ( c.department = av.authorised_value )
1056
        WHERE
1057
            ( av.category = 'DEPARTMENT' OR av.category = 'TERM' )
1058
            AND
1059
            (
1060
                department LIKE ? OR
1061
                course_number LIKE ? OR
1062
                section LIKE ? OR
1063
                course_name LIKE ? OR
1064
                term LIKE ? OR
1065
                public_note LIKE ? OR
1066
                CONCAT(surname,' ',firstname) LIKE ? OR
1067
                CONCAT(firstname,' ',surname) LIKE ? OR
1068
                lib LIKE ? OR
1069
                lib_opac LIKE ?
1070
           )
1071
           AND
1072
           c.enabled LIKE ?
1073
        GROUP BY c.course_id
1074
    ";
1075
1076
    $term   = "%$term%";
1077
    @params = ($term) x 10;
1078
1079
    $query .= " ORDER BY department, course_number, section, term, course_name ";
1080
1081
    my $dbh = C4::Context->dbh;
1082
    my $sth = $dbh->prepare($query);
1083
1084
    $sth->execute(@params, $enabled);
1085
1086
    my $courses = $sth->fetchall_arrayref( {} );
1087
1088
    foreach my $c (@$courses) {
1089
        $c->{'instructors'} = GetCourseInstructors( $c->{'course_id'} );
1090
    }
1091
1092
    return $courses;
1093
}
1094
1095
sub whoami  { ( caller(1) )[3] }
1096
sub whowasi { ( caller(2) )[3] }
1097
1098
sub stringify_params {
1099
    my (%params) = @_;
1100
1101
    my $string = "\n";
1102
1103
    foreach my $key ( keys %params ) {
1104
        $string .= "    $key => " . $params{$key} . "\n";
1105
    }
1106
1107
    return "( $string )";
1108
}
1109
1110
sub identify_myself {
1111
    my (%params) = @_;
1112
1113
    return whowasi() . stringify_params(%params);
1114
}
1115
1116
1;
1117
1118
=head1 AUTHOR
1119
1120
Kyle M Hall <kyle@bywatersolutions.com>
1121
1122
=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 1130-1136 sub IsAuthorisedValueCategory { Link Here
1130
1142
1131
=head2 GetAuthorisedValueByCode
1143
=head2 GetAuthorisedValueByCode
1132
1144
1133
$authhorised_value = GetAuthorisedValueByCode( $category, $authvalcode );
1145
$authorised_value = GetAuthorisedValueByCode( $category, $authvalcode, $opac );
1134
1146
1135
Return the lib attribute from authorised_values from the row identified
1147
Return the lib attribute from authorised_values from the row identified
1136
by the passed category and code
1148
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 (+37 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::Branches;
2
3
# Copyright ByWater Solutions 2012
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Template::Plugin;
23
use base qw( Template::Plugin );
24
25
use C4::Koha;
26
27
sub GetName {
28
    my ( $self, $branchcode ) = @_;
29
30
    my $query = "SELECT branchname FROM branches WHERE branchcode = ?";
31
    my $sth   = C4::Context->dbh->prepare($query);
32
    $sth->execute($branchcode);
33
    my $b = $sth->fetchrow_hashref();
34
    return $b->{'branchname'};
35
}
36
37
1;
(-)a/Koha/Template/Plugin/ItemTypes.pm (+38 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::ItemTypes;
2
3
# Copyright ByWater Solutions 2012
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Template::Plugin;
23
use base qw( Template::Plugin );
24
25
use C4::Koha;
26
27
sub GetDescription {
28
    my ( $self, $itemtype ) = @_;
29
30
    my $query = "SELECT description FROM itemtypes WHERE itemtype = ?";
31
    my $sth   = C4::Context->dbh->prepare($query);
32
    $sth->execute($itemtype);
33
    my $d = $sth->fetchrow_hashref();
34
    return $d->{'description'};
35
36
}
37
38
1;
(-)a/Makefile.PL (+1 lines)
Lines 265-270 my $target_map = { Link Here
265
  './changelanguage.pl'         => 'INTRANET_CGI_DIR',
265
  './changelanguage.pl'         => 'INTRANET_CGI_DIR',
266
  './check_sysprefs.pl'         => 'NONE',
266
  './check_sysprefs.pl'         => 'NONE',
267
  './circ'                      => 'INTRANET_CGI_DIR',
267
  './circ'                      => 'INTRANET_CGI_DIR',
268
  './course_reserves'           => 'INTRANET_CGI_DIR',
268
  './offline_circ'		=> 'INTRANET_CGI_DIR',
269
  './offline_circ'		=> 'INTRANET_CGI_DIR',
269
  './edithelp.pl'               => 'INTRANET_CGI_DIR',
270
  './edithelp.pl'               => 'INTRANET_CGI_DIR',
270
  './etc'                       => { target => 'KOHA_CONF_DIR', trimdir => -1 },
271
  './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;
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'} = GetItemReservesInfo( 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 (+97 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;
32
33
my $cgi = new CGI;
34
35
my $action    = $cgi->param('action')    || '';
36
my $course_id = $cgi->param('course_id') || '';
37
my $barcode   = $cgi->param('barcode')   || '';
38
39
die('No course_id provided') unless ($course_id);
40
41
my $item = GetBiblioFromItemNumber( undef, $barcode );
42
43
my $step = ( $action eq 'lookup' && $item ) ? '2' : '1';
44
45
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46
    {
47
        template_name   => "course_reserves/add_items-step$step.tmpl",
48
        query           => $cgi,
49
        type            => "intranet",
50
        authnotrequired => 0,
51
        flagsrequired   => { coursereserves => 'add_reserves' },
52
    }
53
);
54
$template->param( ERROR_BARCODE_NOT_FOUND => $barcode )
55
  unless ( $barcode && $item && $action eq 'lookup' );
56
57
$template->param( course => GetCourse($course_id) );
58
59
if ( $action eq 'lookup' ) {
60
    my $course_item = GetCourseItem( itemnumber => $item->{'itemnumber'} );
61
    my $course_reserve = ($course_item)
62
      ? GetCourseReserve(
63
        course_id => $course_id,
64
        ci_id     => $course_item->{'ci_id'}
65
      )
66
      : undef;
67
68
    $template->param(
69
        item           => $item,
70
        course_item    => $course_item,
71
        course_reserve => $course_reserve,
72
73
        ccodes    => GetAuthorisedValues('CCODE'),
74
        locations => GetAuthorisedValues('LOC'),
75
        itypes    => GetItemTypes( style => 'array' ),
76
        branches  => GetBranchesLoop(),
77
    );
78
79
}
80
elsif ( $action eq 'add' ) {
81
    my $ci_id = ModCourseItem(
82
        itemnumber    => $cgi->param('itemnumber'),
83
        itype         => $cgi->param('itype'),
84
        ccode         => $cgi->param('ccode'),
85
        holdingbranch => $cgi->param('holdingbranch'),
86
        location      => $cgi->param('location'),
87
    );
88
89
    my $cr_id = ModCourseReserve(
90
        course_id   => $course_id,
91
        ci_id       => $ci_id,
92
        staff_note  => $cgi->param('staff_note'),
93
        public_note => $cgi->param('public_note'),
94
    );
95
}
96
97
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/course_reserves/course-details.pl (+67 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#
4
# Copyright 2012 Bywater Solutions
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
use Modern::Perl;
22
23
use CGI;
24
25
use C4::Auth;
26
use C4::Output;
27
use C4::Koha;
28
29
use C4::CourseReserves;
30
31
my $cgi = new CGI;
32
33
my $action = $cgi->param('action') || '';
34
my $course_id = $cgi->param('course_id');
35
36
my $flagsrequired;
37
$flagsrequired->{coursereserves} = 'delete_reserves' if ( $action eq 'del_reserve' );
38
39
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
40
    {
41
        template_name   => "course_reserves/course-details.tmpl",
42
        query           => $cgi,
43
        type            => "intranet",
44
        authnotrequired => 0,
45
        flagsrequired   => $flagsrequired,
46
    }
47
);
48
49
die("No course_id given") unless ($course_id);
50
51
if ( $action eq 'del_reserve' ) {
52
    DelCourseReserve( cr_id => $cgi->param('cr_id') );
53
}
54
55
my $course          = GetCourse($course_id);
56
my $course_reserves = GetCourseReserves(
57
    course_id       => $course_id,
58
    include_items   => 1,
59
    include_courses => 1
60
);
61
62
$template->param(
63
    course          => $course,
64
    course_reserves => $course_reserves,
65
);
66
67
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/course_reserves/course-reserves.pl (+54 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#
4
# Copyright 2012 Bywater Solutions
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
use Modern::Perl;
22
23
use CGI;
24
25
use C4::Auth;
26
use C4::Output;
27
28
use C4::CourseReserves;
29
30
my $cgi = new CGI;
31
32
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
33
    {
34
        template_name   => "course_reserves/course-reserves.tmpl",
35
        query           => $cgi,
36
        type            => "intranet",
37
        authnotrequired => 0,
38
        flagsrequired   => {},
39
    }
40
);
41
42
my $search_on = $cgi->param('search_on');
43
my %params;
44
if ($search_on) {
45
    $params{'course_name'} = "%$search_on%";
46
}
47
48
my $courses = GetCourses(%params);
49
if ( $search_on && @$courses == 1 ) {
50
    print $cgi->redirect("/cgi-bin/koha/course_reserves/course-details.pl?course_id=" . $courses->[0]->{'course_id'});
51
} else {
52
    $template->param( courses => $courses );
53
    output_html_with_http_headers $cgi, $cookie, $template->output;
54
}
(-)a/course_reserves/course.pl (+55 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;
30
31
my $cgi = new CGI;
32
33
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
34
    {
35
        template_name   => "course_reserves/course.tmpl",
36
        query           => $cgi,
37
        type            => "intranet",
38
        authnotrequired => 0,
39
        flagsrequired   => { coursereserves => 'manage_courses' },
40
    }
41
);
42
43
my $course_id = $cgi->param('course_id');
44
45
if ($course_id) {
46
    my $course = GetCourse($course_id);
47
    $template->param(%$course);
48
}
49
50
$template->param(
51
    departments => GetAuthorisedValues('DEPARTMENT'),
52
    terms => GetAuthorisedValues('TERM'),
53
);
54
55
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/course_reserves/mod_course.pl (+72 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;
29
30
my $cgi = new CGI;
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
32
    {
33
        template_name   => "about.tmpl",
34
        query           => $cgi,
35
        type            => "intranet",
36
        authnotrequired => 0,
37
        flagsrequired   => { coursereserves => 'manage_courses' },
38
    }
39
);
40
41
my $action = $cgi->param('action');
42
43
if ( $action eq 'del' ) {
44
    DelCourse( $cgi->param('course_id') );
45
    print $cgi->redirect("/cgi-bin/koha/course_reserves/course-reserves.pl");
46
}
47
else {
48
    my %params;
49
50
    $params{'course_id'} = $cgi->param('course_id')
51
      if ( $cgi->param('course_id') );
52
    $params{'department'}     = $cgi->param('department');
53
    $params{'course_number'}  = $cgi->param('course_number');
54
    $params{'section'}        = $cgi->param('section');
55
    $params{'course_name'}    = $cgi->param('course_name');
56
    $params{'term'}           = $cgi->param('term');
57
    $params{'staff_note'}     = $cgi->param('staff_note');
58
    $params{'public_note'}    = $cgi->param('public_note');
59
    $params{'students_count'} = $cgi->param('students_count');
60
    $params{'enabled'} = ( $cgi->param('enabled') eq 'on' ) ? 'yes' : 'no';
61
62
    my $course_id = ModCourse(%params);
63
64
    my @instructors = $cgi->param('instructors');
65
    ModCourseInstructors(
66
        mode        => 'replace',
67
        cardnumbers => \@instructors,
68
        course_id   => $course_id
69
    );
70
    print $cgi->redirect(
71
        "/cgi-bin/koha/course_reserves/course-details.pl?course_id=$course_id");
72
}
(-)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 (+3 lines)
Lines 55-60 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
55
   (15, 'routing', 'Crea/Manipola liste di distribuzione dei fascicoli ( routing list)'),
55
   (15, 'routing', 'Crea/Manipola liste di distribuzione dei fascicoli ( routing list)'),
56
   (16, 'execute_reports', 'Esegui reports SQL'),
56
   (16, 'execute_reports', 'Esegui reports SQL'),
57
   (16, 'create_reports', 'Crea reports SQL'),
57
   (16, 'create_reports', 'Crea reports SQL'),
58
   (18, 'manage_courses', 'Add, edit and delete courses'),
59
   (18, 'add_reserves', 'Add course reserves'),
60
   (18, 'delete_reserves', 'Remove course reserves'),
58
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
61
   (19, 'manage', 'Manage plugins ( install / uninstall )'),
59
   (19, 'tool', 'Use tool plugins'),
62
   (19, 'tool', 'Use tool plugins'),
60
   (19, 'report', 'Use report plugins'),
63
   (19, 'report', 'Use report plugins'),
(-)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 424-426 INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES(' Link Here
424
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo');
424
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo');
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 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 6846-6851 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
6846
    SetVersion ($DBversion);
6845
    SetVersion ($DBversion);
6847
}
6846
}
6848
6847
6848
$DBversion = "3.13.00.XXX";
6849
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6850
    $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('UseCourseReserves', '0', NULL, 'Enable the course reserves feature.', 'YesNo')");
6851
    $dbh->do("INSERT INTO userflags (bit,flag,flagdesc,defaulton) VALUES ('18','coursereserves','Course Reserves','0')");
6852
    $dbh->do("
6853
CREATE TABLE `courses` (
6854
  `course_id` int(11) NOT NULL AUTO_INCREMENT,
6855
  `department` varchar(20) DEFAULT NULL,
6856
  `course_number` varchar(255) DEFAULT NULL,
6857
  `section` varchar(255) DEFAULT NULL,
6858
  `course_name` varchar(255) DEFAULT NULL,
6859
  `term` varchar(20) DEFAULT NULL,
6860
  `staff_note` mediumtext,
6861
  `public_note` mediumtext,
6862
  `students_count` varchar(20) DEFAULT NULL,
6863
  `enabled` enum('yes','no') NOT NULL DEFAULT 'yes',
6864
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6865
   PRIMARY KEY (`course_id`)
6866
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
6867
    ");
6868
6869
    $dbh->do("
6870
CREATE TABLE `course_instructors` (
6871
  `course_id` int(11) NOT NULL,
6872
  `borrowernumber` int(11) NOT NULL,
6873
  PRIMARY KEY (`course_id`,`borrowernumber`),
6874
  KEY `borrowernumber` (`borrowernumber`)
6875
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6876
    ");
6877
6878
    $dbh->do("
6879
ALTER TABLE `course_instructors`
6880
  ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
6881
  ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
6882
    ");
6883
6884
    $dbh->do("
6885
CREATE TABLE `course_items` (
6886
  `ci_id` int(11) NOT NULL AUTO_INCREMENT,
6887
  `itemnumber` int(11) NOT NULL,
6888
  `itype` varchar(10) DEFAULT NULL,
6889
  `ccode` varchar(10) DEFAULT NULL,
6890
  `holdingbranch` varchar(10) DEFAULT NULL,
6891
  `location` varchar(80) DEFAULT NULL,
6892
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no',
6893
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6894
   PRIMARY KEY (`ci_id`),
6895
   UNIQUE KEY `itemnumber` (`itemnumber`),
6896
   KEY `holdingbranch` (`holdingbranch`)
6897
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
6898
    ");
6899
6900
    $dbh->do("
6901
ALTER TABLE `course_items`
6902
  ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
6903
  ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
6904
");
6905
6906
    $dbh->do("
6907
CREATE TABLE `course_reserves` (
6908
  `cr_id` int(11) NOT NULL AUTO_INCREMENT,
6909
  `course_id` int(11) NOT NULL,
6910
  `ci_id` int(11) NOT NULL,
6911
  `staff_note` mediumtext,
6912
  `public_note` mediumtext,
6913
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6914
   PRIMARY KEY (`cr_id`),
6915
   UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
6916
   KEY `course_id` (`course_id`)
6917
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
6918
");
6919
6920
    $dbh->do("
6921
ALTER TABLE `course_reserves`
6922
  ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`);
6923
    ");
6924
6925
    $dbh->do("
6926
INSERT INTO permissions (module_bit, code, description) VALUES
6927
  (18, 'manage_courses', 'Add, edit and delete courses'),
6928
  (18, 'add_reserves', 'Add course reserves'),
6929
  (18, 'delete_reserves', 'Remove course reserves')
6930
;
6931
    ");
6932
6933
6934
    print "Upgrade to $DBversion done (Add Course Reserves ( system preference UseCourseReserves ))\n";
6935
    SetVersion($DBversion);
6936
}
6937
6849
=head1 FUNCTIONS
6938
=head1 FUNCTIONS
6850
6939
6851
=head2 TableExists($table)
6940
=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 / +4 lines)
Lines 5-20 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
});
17
});
15
18
16
17
18
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html
19
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html
19
function checkEnter(e){ //e is event object passed from function invocation
20
function checkEnter(e){ //e is event object passed from function invocation
20
	var characterCode; // literal character code will be stored in this variable
21
	var characterCode; // literal character code will be stored in this variable
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+7 lines)
Lines 543-545 Circulation: Link Here
543
            - and this password
543
            - and this password
544
            - pref: AutoSelfCheckPass
544
            - pref: AutoSelfCheckPass
545
            - .
545
            - .
546
    Course Reserves:
547
        -
548
            - pref: UseCourseReserves
549
              choices:
550
                  yes: Use
551
                  no: "Don't use"
552
            - 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 (+63 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Course reserves &rsaquo; Add items</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
6
<script type="text/javascript">
7
//<![CDATA[
8
9
$(document).ready(function() {
10
  $('#barcode').focus();
11
});
12
13
//]]>
14
</script>
15
16
<body>
17
18
[% INCLUDE 'header.inc' %]
19
[% INCLUDE 'cat-search.inc' %]
20
21
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a> &rsaquo; Add reserves for <i><a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% course.course_id %]">[% course.course_name %]</a></i></div>
22
23
<div id="doc2" class="yui-t7">
24
    <div id="bd">
25
        <div id="yui-main">
26
            <div class="yui-b">
27
                <div class="yui-g">
28
                    <div class="yui-u first">
29
                        [% IF ERROR_BARCODE_NOT_FOUND %]
30
                            <div class="error">No item found for barcode [% ERROR_BARCODE_NOT_FOUND %]</div>
31
                        [% END %]
32
33
                        <form method="post" action="/cgi-bin/koha/course_reserves/add_items.pl">
34
                            <input type="hidden" name="course_id" value="[% course.course_id %]" />
35
                            <input type="hidden" name="action" value="lookup" />
36
37
                            <fieldset class="rows">
38
                                <legend>Add items: scan barcode</legend>
39
40
                                    <p>
41
42
                                    <li>
43
                                        <label class="required" for="barcode">Item barcode:</label>
44
                                        <input id="barcode" name="barcode" type="text" />
45
                                    </li>
46
                                </ol>
47
                            </fieldset>
48
49
                            <fieldset class="action">
50
                                <input type="submit" value="Submit" class="submit" />
51
52
                                <a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=[% course.course_id %]" class="cancel">Cancel</a>
53
                            </fieldset>
54
                        </form>
55
                    </div>
56
                </div>
57
            </div>
58
        </div>
59
    </div>
60
</div>
61
62
63
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt (+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 (+185 lines)
Line 0 Link Here
1
[% USE AuthorisedValues %]
2
[% USE ItemTypes %]
3
[% USE Branches %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Course reserves &rsaquo; New course</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
8
<script type="text/javascript">
9
//<![CDATA[
10
11
    function confirmItemDelete(){
12
        return confirm( _('Are you sure you want to delete this item?');
13
    }
14
15
//]]>
16
</script>
17
18
</head>
19
20
<body>
21
22
[% INCLUDE 'header.inc' %]
23
[% INCLUDE 'cat-search.inc' %]
24
25
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a> &rsaquo; Course details for <i>[% course.course_name %]</i></div>
26
27
<div id="doc2" class="yui-t7">
28
    <div id="bd">
29
        <div id="yui-main">
30
            <div id="toolbar">
31
                <script type="text/javascript">
32
                //<![CDATA[
33
                    $(document).ready(function(){
34
                        addItemsButton     = new YAHOO.widget.Button("add_items");
35
                        editCourseButton   = new YAHOO.widget.Button("edit_course");
36
                        deleteCourseButton = new YAHOO.widget.Button("delete_course");
37
38
                        deleteCourseButton.on("click", confirmDelete );
39
                    });
40
41
                    function confirmDelete(p_oEvent){
42
                        if ( ! confirm( _('Are you sure you want to delete this course?') ) ) {
43
                            YAHOO.util.Event.stopEvent( p_oEvent );
44
                        }
45
                    }
46
47
                //]]>
48
                </script>
49
                <ul class="toolbar">
50
                    [% IF CAN_user_coursereserves_add_reserves %]<li><a id="add_items" href="/cgi-bin/koha/course_reserves/add_items.pl?course_id=[% course.course_id %]">Add reserves</a></li>[% END %]
51
                    [% IF ( CAN_user_coursereserves_manage_courses ) %]<li><a id="edit_course" href="/cgi-bin/koha/course_reserves/course.pl?course_id=[% course.course_id %]">Edit course</a></li>[% END %]
52
                    [% IF ( CAN_user_coursereserves_manage_courses ) %]<li><a id="delete_course" href="/cgi-bin/koha/course_reserves/mod_course.pl?course_id=[% course.course_id %]&action=del">Delete course</a></li>[% END %]
53
                </ul>
54
            </div><!-- /toolbar -->
55
56
            <table>
57
                <tr><th>Course name</th><td>[% course.course_name %]</td></tr>
58
                <tr><th>Term</th><td>[% AuthorisedValues.GetByCode( 'TERM', course.term ) %]</td></tr>
59
                <tr><th>Department</th><td>_[% AuthorisedValues.GetByCode( 'DEPARTMENT', course.department ) %]</td></tr>
60
                <tr><th>Course number</th><td>[% course.course_number %]</td></tr>
61
                <tr><th>Section</th><td>[% course.section %]</td></tr>
62
                <tr><th>Instructors</th><td>[% FOREACH i IN course.instructors %]<div class="instructor"><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% i.borrowernumber %]">[% i.firstname %] [% i.surname %]</a></div>[% END %]</td></tr>
63
                <tr><th>Staff note</th><td>[% course.staff_note %]</td></tr>
64
                <tr><th>Public note</th><td>[% course.public_note %]</td></tr>
65
                <tr><th>Students count</th><td>[% course.students_count %]</td></tr>
66
                <tr><th>Status</th><td>[% IF course.enabled == 'yes' %]Active[% ELSE %]Inactive[% END %]</td></tr>
67
            </table>
68
69
            <table>
70
                <thead>
71
                    <tr>
72
                        <th>Title</th>
73
                        <th>Barcode</th>
74
                        <th>Call number</th>
75
                        [% IF item_level_itypes %]<th>Item type</th>[% END %]
76
                        <th>Collection</th>
77
                        <th>Location</th>
78
                        <th>Library</th>
79
                        <th>Staff note</th>
80
                        <th>Public note</th>
81
                        [% IF CAN_user_coursereserves_add_reserves %]<th>&nbsp;<!-- Edit --></th>[% END %]
82
                        [% IF CAN_user_coursereserves_delete_reserves %]<th>&nbsp;<!-- Remove --></th>[% END %]
83
                        <th>Other course reserves</th>
84
                    </tr>
85
                </thead>
86
87
                <tbody>
88
                    [% FOREACH cr IN course_reserves %]
89
                        <tr>
90
                            <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% cr.item.biblionumber %]">[% cr.item.title %]</a></td>
91
                            <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% cr.item.itemnumber %]&biblionumber=[% cr.item.biblionumber %]&bi=[% cr.item.biblioitemnumber %]">[% cr.item.barcode %]</a></td>
92
                            <td>[% cr.item.itemcallnumber %]</td>
93
                            [% IF item_level_itypes %]
94
                            <td>
95
                                [% IF cr.course_item.itype %]
96
                                    [% IF cr.course_item.enabled == 'yes' %]
97
                                        [% ItemTypes.GetDescription( cr.item.itype ) %]
98
                                    [% ELSE %]
99
                                        [% ItemTypes.GetDescription( cr.course_item.itype ) %]
100
                                    [% END %]
101
                                [% ELSE %]
102
                                     <i>Unchanged</i>
103
                                     ([% ItemTypes.GetDescription( cr.item.itype ) %])
104
                                [% END %]
105
                            </td>
106
                            [% END %]
107
                            <td>
108
                                 [% IF cr.course_item.ccode %]
109
                                     [% IF cr.course_item.enabled == 'yes' %]
110
                                          [% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %]
111
                                     [% ELSE %]
112
                                         [% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode ) %]
113
                                     [% END %]
114
                                 [% ELSE %]
115
                                     <i>Unchanged</i>
116
                                     ([% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %])
117
                                 [% END %]
118
                            </td>
119
                            <td>
120
                                [% IF cr.course_item.location %]
121
                                     [% IF cr.course_item.enabled == 'yes' %]
122
                                         [% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %]
123
                                    [% ELSE %]
124
                                        [% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) %]
125
                                    [% END %]
126
                                [% ELSE %]
127
                                    <i>Unchanged</i>
128
                                    ([% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %])
129
                                [% END %]
130
                            </td>
131
                            <td>
132
                                [% IF cr.course_item.holdingbranch %]
133
                                    [% IF cr.course_item.enabled == 'yes' %]
134
                                        [% Branches.GetName( cr.item.holdingbranch ) %]
135
                                    [% ELSE %]
136
                                        [% Branches.GetName( cr.course_item.holdingbranch ) %]
137
                                    [% END %]
138
                                [% ELSE %]
139
                                    <i>Unchanged</i>
140
                                    ([% Branches.GetName( cr.item.holdingbranch ) %])
141
                                [% END %]
142
                            </td>
143
                            <td>[% cr.staff_note %]</td>
144
                            <td>[% cr.public_note %]</td>
145
146
                            [% IF CAN_user_coursereserves_add_reserves %]
147
                                <td><a href="add_items.pl?course_id=[% course.course_id %]&barcode=[% cr.item.barcode %]&action=lookup">Edit</a></td>
148
                            [% END %]
149
150
                            [% IF CAN_user_coursereserves_delete_reserves %]
151
                                <td>
152
                                    [% IF cr.item.onloan %]
153
                                        On Loan
154
                                    [% ELSIF cr.item.itemlost %]
155
                                        Item Lost
156
                                    [% ELSE %]
157
                                        <a href="course-details.pl?course_id=[% course.course_id %]&action=del_reserve&cr_id=[% cr.cr_id %]" onclick="return confirmItemDelete()" >Remove</a>
158
                                    [% END %]
159
160
                                </td>
161
                            [% END %]
162
163
                            <td>
164
                                [% FOREACH course IN cr.courses %]
165
                                    [% UNLESS cr.course_id == course.course_id %]
166
                                        <p>
167
                                            <a href="course-details.pl?course_id=[% course.course_id %]">
168
                                                [% course.course_name %]
169
                                                [% IF course.section %] [% course.section %] [% END %]
170
                                                [% IF course.term %] [% AuthorisedValues.GetByCode( 'TERM', course.term ) %] [% END %]
171
                                            </a>
172
                                        </p>
173
                                    [% END %]
174
                                [% END %]
175
                            </td>
176
                        </tr>
177
                    [% END %]
178
                </tbody>
179
            </table>
180
        </div>
181
    </div>
182
</div>
183
184
185
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt (+119 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
    }));
15
 });
16
});
17
</script>
18
19
</head>
20
<body id="lists_shelves" class="lists">
21
22
[% INCLUDE 'header.inc' %]
23
[% INCLUDE 'cat-search.inc' %]
24
25
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a></div>
26
27
<div id="doc2" class="yui-t7">
28
    <div id="bd">
29
        <div id="yui-main">
30
            <div class="yui-b">
31
                <div class="yui-g">
32
33
                    <div id="toolbar">
34
                        <script type="text/javascript">
35
                        //<![CDATA[
36
                            $(document).ready(function(){
37
                                newCourseButton = new YAHOO.widget.Button("new_course");
38
                            });
39
                        //]]>
40
                        </script>
41
                        <ul class="toolbar">
42
                            [% IF ( CAN_user_coursereserves_manage_courses ) %]
43
                            <li><a id="new_course" href="/cgi-bin/koha/course_reserves/course.pl">New course</a></li>
44
                            [% END %]
45
                        </ul>
46
                    </div><!-- /toolbar -->
47
48
                    <!--
49
                    <div id="search-toolbar">
50
                        <script type="text/javascript">
51
                        //<![CDATA[
52
                            function submitSearchForm(p_oEvent){
53
                                $('#search_courses_form').submit();
54
                            }
55
56
                            $(document).ready(function(){
57
                                newCourseButton = new YAHOO.widget.Button("search_courses");
58
                                newCourseButton.on("click", submitSearchForm );
59
                            });
60
                        //]]>
61
                        </script>
62
                        <ul class="toolbar">
63
                            <li><form id="search_courses_form"><input type="text" name="search_on" id="search_on"></form></li>
64
                            <li><a id="search_courses">Search courses</a></li>
65
                        </ul>
66
                    </div>
67
                    -->
68
69
                    <h1>Courses</h1>
70
                    <table id="course_reserves_table">
71
                        <thead>
72
                            <tr>
73
                                <th>Name</th>
74
                                <th>Dept.</th>
75
                                <th>Course #</th>
76
                                <th>Section</th>
77
                                <th>Term</th>
78
                                <th>Instructors</th>
79
                                <th>Staff note</th>
80
                                <th>Public note</th>
81
                                <th># of Students</th>
82
                                <th>Enabled</th>
83
                            </tr>
84
                        </thead>
85
86
                        <tbody>
87
                            [% FOREACH c IN courses %]
88
                                <tr>
89
                                    <td><a href="course-details.pl?course_id=[% c.course_id %]">[% c.course_name %]</a></td>
90
                                    <td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', c.department ) %]</td>
91
                                    <td>[% c.course_number %]</td>
92
                                    <td>[% c.section %]</td>
93
                                    <td>[% AuthorisedValues.GetByCode( 'TERM' c.term ) %]</td>
94
                                    <td>
95
                                        [% FOREACH i IN c.instructors %]
96
                                            <div class="instructor"><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% i.borrowernumber %]">[% i.firstname %] [% i.surname %]</a></div>
97
                                        [% END %]
98
                                    </td>
99
                                    <td>[% c.staff_note %]</td>
100
                                    <td>[% c.public_note %]</td>
101
                                    <td>[% c.students_count %]</td>
102
                                    <td>
103
                                        [% IF c.enabled == 'yes' %]
104
                                            <img src="/intranet-tmpl/prog/img/approve.gif" />
105
                                        [% ELSE %]
106
                                            <img src="http://kohadev:8080/intranet-tmpl/prog/img/deny.gif" />
107
                                        [% END %]
108
                                    </td>
109
                            [% END %]
110
                        </tbody>
111
                    </table>
112
                </div>
113
            </div>
114
        </div>
115
    </div>
116
</div>
117
118
119
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt (+205 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Course reserves &rsaquo; [% IF course_name %] Edit [% course_name %] [% ELSE %] New course [% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
5
<script type="text/javascript">
6
//<![CDATA[
7
8
    function Check(f) {
9
        var _alertString = "";
10
11
        if( ! $("#department").val() ) {
12
            _alertString += _("- You must choose a department") + "\n";
13
        }
14
15
        if( ! $("#course_number").val() ) {
16
            _alertString += _("- You must choose a course number") + "\n";
17
        }
18
19
        if( ! $("#course_name").val() ) {
20
            _alertString += _("- You must add a course name") + "\n";
21
        }
22
23
        if ( _alertString.length ) {
24
            var alertHeader;
25
            alertHeader = _("Form not submitted because of the following problem(s)");
26
            alertHeader += "\n------------------------------------------------------------------------------------\n\n";
27
28
            alert( alertHeader + _alertString );
29
        } else {
30
            f.submit();
31
        }
32
    }
33
34
//]]>
35
</script>
36
37
<script type="text/javascript">
38
//<![CDATA[
39
$(document).ready(function(){
40
    $( "#find_instructor" ).autocomplete({
41
        source: "/cgi-bin/koha/circ/ysearch.pl",
42
        minLength: 3,
43
        select: function( event, ui ) {
44
            AddInstructor( ui.item.firstname + " " + ui.item.surname, ui.item.cardnumber );
45
            return false;
46
        }
47
    })
48
    .data( "autocomplete" )._renderItem = function( ul, item ) {
49
        return $( "<li></li>" )
50
        .data( "item.autocomplete", item )
51
        .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
52
        .appendTo( ul );
53
    };
54
55
});
56
57
function AddInstructor( name, cardnumber ) {
58
    div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' onclick='RemoveInstructor(" + cardnumber + ");'> Remove </a> ) <input type='hidden' name='instructors' value='" + cardnumber + "' /></div>";
59
    $('#instructors').append( div );
60
61
    $('#find_instructor').val('').focus();
62
}
63
64
function RemoveInstructor( cardnumber ) {
65
    $( '#borrower_' + cardnumber ).remove();
66
}
67
68
//]]>
69
</script>
70
71
</head>
72
73
<body>
74
75
[% INCLUDE 'header.inc' %]
76
[% INCLUDE 'cat-search.inc' %]
77
78
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/course_reserves/course-reserves.pl">Course reserves</a> &rsaquo; [% IF course_name %] Edit <i>[% course_name %]</i> [% ELSE %] New course [% END %]</div>
79
80
<div id="doc2" class="yui-t7">
81
    <div id="bd">
82
        <div id="yui-main">
83
            <div class="yui-b">
84
                <div class="yui-g">
85
                    <div class="yui-u first">
86
                        <form method="post" action="/cgi-bin/koha/course_reserves/mod_course.pl">
87
                            [% IF course_id %]<input type="hidden" name="course_id" value="[% course_id %]" />[% END %]
88
                            <fieldset class="rows">
89
                                <legend>[% IF course_id %] Edit [% ELSE %] Create [% END %] course</legend>
90
                                <ol>
91
                                    <li>
92
                                        <label class="required" for="department">Department:</label>
93
                                        [% 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
                                    <!-- TODO: Add Instructors -->
145
                                    <li>
146
                                        <label for="instructors">Instructors:</label>
147
148
                                        <fieldset>
149
                                             <div id="instructors">
150
                                                 [% FOREACH i IN instructors %]
151
                                                     <div id="borrower_[% i.cardnumber %]">
152
                                                         [% i.surname %], [% i.firstname %] ( <a href='#' onclick='RemoveInstructor( [% i.cardnumber %] );'> Remove </a> )
153
                                                         <input type='hidden' name='instructors' value='[% i.cardnumber %]' />
154
                                                     </div>
155
                                                 [% END %]
156
                                             </div>
157
158
                                        </fieldset>
159
160
                                        <fieldset>
161
                                            <label for="find_instructor">Instructor search:</label>
162
                                            <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit"/>
163
                                            <div id="find_instructor_container"></div>
164
                                        </fieldset>
165
                                    <li>
166
                                        <label for="staff_note">Staff note:</label>
167
                                        <textarea name="staff_note" id="staff_note">[% staff_note %]</textarea>
168
                                    </li>
169
170
                                    <li>
171
                                        <label for="public_note">Public note:</label>
172
                                        <textarea name="public_note" id="public_note">[% public_note %]</textarea>
173
                                    </li>
174
175
                                    <li>
176
                                        <label for="students_count">Number of students:</label>
177
                                        <input id="students_count" name="students_count" type="text" value="[% students_count %]" />
178
                                    </li>
179
180
                                    <li>
181
                                        <label for="enabled">Enabled?</label>
182
                                        [% IF enabled == 'no' %]
183
                                            <input type="checkbox" name="enabled" id="enabled" />
184
                                        [% ELSE %]
185
                                            <input type="checkbox" name="enabled" id="enabled" checked="checked" />
186
                                        [% END %]
187
                                    </li>
188
                                </ol>
189
                            </fieldset>
190
191
                            <fieldset class="action">
192
                                <input type="submit" onclick="Check(this.form); return false;" value="Save" class="submit" />
193
194
                                <a href="/cgi-bin/koha/course_reserves/course-reserves.pl" class="cancel">Cancel</a>
195
                            </fieldset>
196
197
                    </div>
198
                </div>
199
            </div>
200
        </div>
201
    </div>
202
</div>
203
204
205
[% 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 262-267 Link Here
262
262
263
<div id="moresearches">
263
<div id="moresearches">
264
<a href="/cgi-bin/koha/opac-search.pl">Advanced search</a>
264
<a href="/cgi-bin/koha/opac-search.pl">Advanced search</a>
265
[% IF ( UseCourseReserves ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-course-reserves.pl">Course Reserves</a>[% END %]
265
[% IF ( OpacBrowser ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-browser.pl">Browse by hierarchy</a>[% END %]
266
[% IF ( OpacBrowser ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-browser.pl">Browse by hierarchy</a>[% END %]
266
[% IF ( OpacAuthorities ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-authorities-home.pl">Authority search</a>[% END %]
267
[% IF ( OpacAuthorities ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-authorities-home.pl">Authority search</a>[% END %]
267
[% IF ( opacuserlogin && reviewson && OpacShowRecentComments ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %]
268
[% IF ( opacuserlogin && reviewson && OpacShowRecentComments ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %]
(-)a/koha-tmpl/opac-tmpl/prog/en/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 && reviewson && OpacShowRecentComments ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %]
137
[% IF ( opacuserlogin && reviewson && OpacShowRecentComments ) %]<span class="pipe"> | </span><a href="/cgi-bin/koha/opac-showreviews.pl">Recent comments</a>[% END %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-course-details.tt (+63 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE AuthorisedValues %]
3
[% USE ItemTypes %]
4
[% USE Branches %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog
7
[% INCLUDE 'doc-head-close.inc' %]
8
</head>
9
<body id="opac-main">
10
[% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %]
11
   <div id="bd">
12
[% INCLUDE 'masthead.inc' %]
13
14
<div id="doc2" class="yui-t7">
15
    <div id="yui-main">
16
17
        <table>
18
            <tr><th>Course Name</th><td>[% course.course_name %]</td></tr>
19
            <tr><th>Term</th><td>[% AuthorisedValues.GetByCode( 'TERM', course.term ) %]</td></tr>
20
            <tr><th>Department</th><td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', course.department ) %]</td></tr>
21
            <tr><th>Course Number</th><td>[% course.course_number %]</td></tr>
22
            <tr><th>Section</th><td>[% course.section %]</td></tr>
23
            <tr><th>Instructors</th><td>[% FOREACH i IN course.instructors %]<div class="instructor">[% i.firstname %] [% i.surname %]</div>[% END %]</td></tr>
24
            <tr><th>Notes</th><td>[% course.public_note %]</td></tr>
25
        </table>
26
27
        <table>
28
            <thead>
29
                <tr>
30
                    <th>Title</th>
31
                    <th>Item type</th>
32
                    <th>Location</th>
33
                    <th>Collection</th>
34
                    <th>Call number</th>
35
                    <th>Copy</th>
36
                    <th>Status</td>
37
                    <th>Date due</td>
38
                    <th>Notes</th>
39
                </tr>
40
            </thead>
41
42
            <tbody>
43
                [% FOREACH cr IN course_reserves %]
44
                    <tr>
45
                        <td><a href="opac-detail.pl?biblionumber=[% cr.item.biblionumber %]">[% cr.item.title %]</a></td>
46
                        <td>[% ItemTypes.GetDescription( cr.item.itype ) %]</td>
47
                        <td>[% Branches.GetName( cr.item.holdingbranch ) %] <br/> <i>[% AuthorisedValues.GetByCode( 'LOC', cr.item.location ) %]</i></td>
48
                        <td>[% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) %]</td>
49
                        <td>[% cr.item.itemcallnumber %]</td>
50
                        <td>[% cr.item.copynumber %]</td>
51
                        <td>[% INCLUDE 'item-status.inc' item = cr.item %]</td>
52
                        <td>[% cr.issue.date_due | $KohaDates %]</td>
53
                        <td>[% cr.public_note %]</td>
54
                    </tr>
55
                [% END %]
56
            </tbody>
57
        </table>
58
59
    </div>
60
</div>
61
62
63
[% INCLUDE 'opac-bottom.inc' %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-course-reserves.tt (+62 lines)
Line 0 Link Here
1
[% USE AuthorisedValues %]
2
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog
5
[% INCLUDE 'doc-head-close.inc' %]
6
</head>
7
<body id="opac-main">
8
[% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %]
9
   <div id="bd">
10
[% INCLUDE 'masthead.inc' %]
11
12
13
<div id="doc2" class="yui-t7">
14
        <div id="yui-main">
15
            <div class="yui-b">
16
                <div class="yui-g">
17
18
                    <div id="search-toolbar">
19
                        <form id="search_courses_form">
20
                            <input type="text" name="search_on" id="search_on" />
21
                            <input type="submit" value="Search" />
22
                        </form>
23
                    </div><!-- /toolbar -->
24
25
                    <h1>Courses</h1>
26
                    <table id="course_reserves_table">
27
                        <thead>
28
                            <tr>
29
                                <th>Name</th>
30
                                <th>Dept.</th>
31
                                <th>Course #</th>
32
                                <th>Section</th>
33
                                <th>Term</th>
34
                                <th>Instructors</th>
35
                                <th>Notes</th>
36
                            </tr>
37
                        </thead>
38
39
                        <tbody>
40
                            [% FOREACH c IN courses %]
41
                                <tr>
42
                                    <td><a href="opac-course-details.pl?course_id=[% c.course_id %]">[% c.course_name %]</a></td>
43
                                    <td>[% AuthorisedValues.GetByCode( 'DEPARTMENT', c.department, 1 ) %]</td>
44
                                    <td>[% c.course_number %]</td>
45
                                    <td>[% c.section %]</td>
46
                                    <td>[% AuthorisedValues.GetByCode( 'TERM' c.term ) %]</td>
47
                                    <td>
48
                                      [% FOREACH i IN c.instructors %]
49
                                          <div class="instructor">[% i.firstname %] [% i.surname %]</div>
50
                                      [% END %]
51
                                    </td>
52
                                    <td>[% c.public_note %]</td>
53
                            [% END %]
54
                        </tbody>
55
                    </table>
56
                </div>
57
            </div>
58
        </div>
59
</div>
60
61
62
[% INCLUDE 'opac-bottom.inc' %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt (+31 lines)
Lines 1-7 Link Here
1
[% USE KohaDates %]
1
[% USE KohaDates %]
2
[% USE AuthorisedValues %]
2
[% SET TagsShowEnabled = ( TagsEnabled && TagsShowOnDetail ) %]
3
[% SET TagsShowEnabled = ( TagsEnabled && TagsShowOnDetail ) %]
3
[% SET TagsInputEnabled = ( opacuserlogin && TagsEnabled && TagsInputOnDetail ) %]
4
[% SET TagsInputEnabled = ( opacuserlogin && TagsEnabled && TagsInputOnDetail ) %]
4
5
6
[% ShowCourseReservesHeader = 0 %]
7
[% IF UseCourseReserves %]
8
    [% FOREACH ITEM_RESULT IN itemloop %]
9
       [% IF ITEM_RESULT.course_reserves %]
10
           [% FOREACH r IN ITEM_RESULT.course_reserves %]
11
               [% IF r.course.enabled == 'yes' %]
12
                   [% ShowCourseReservesHeader = 1 %]
13
               [% END %]
14
           [% END %]
15
        [% END %]
16
    [% END %]
17
[% END %]
18
5
[% 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 %]
19
[% 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 %]
6
[% INCLUDE 'doc-head-close.inc' %]
20
[% INCLUDE 'doc-head-close.inc' %]
7
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
21
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
Lines 1475-1480 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1475
        [% ELSIF show_priority %]
1489
        [% ELSIF show_priority %]
1476
            <th>Item hold queue priority</th>
1490
            <th>Item hold queue priority</th>
1477
        [% END %]
1491
        [% END %]
1492
        [% IF ( ShowCourseReservesHeader ) %]<th id="item_coursereserves">Course Reserves</th>[% END %]
1478
        </tr></thead>
1493
        </tr></thead>
1479
	    <tbody>[% FOREACH ITEM_RESULT IN items %]
1494
	    <tbody>[% FOREACH ITEM_RESULT IN items %]
1480
      [% IF ITEM_RESULT.this_branch %]<tr class="highlight-row-detail">[% ELSE %]<tr>[% END %]
1495
      [% IF ITEM_RESULT.this_branch %]<tr class="highlight-row-detail">[% ELSE %]<tr>[% END %]
Lines 1522-1527 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1522
            [% END %]
1537
            [% END %]
1523
                </td>
1538
                </td>
1524
        [% END %]
1539
        [% END %]
1540
        [% IF ShowCourseReservesHeader %]
1541
            <td>
1542
                [% IF ITEM_RESULT.course_reserves %]
1543
                    [% FOREACH r IN ITEM_RESULT.course_reserves %]
1544
                        <p>
1545
                            <a href="opac-course-details.pl?course_id=[% r.course.course_id %]">
1546
                                [% r.course.course_name %]
1547
                                <!--[% IF r.course.course_number %] [% r.course.course_number %] [% END %]-->
1548
                                [% IF r.course.section %] [% r.course.section %] [% END %]
1549
                                [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) %] [% END %]
1550
                            </a>
1551
                        </p>
1552
                    [% END %]
1553
                [% END %]
1554
            </td>
1555
        [% END %]
1525
	    </tr>
1556
	    </tr>
1526
	    [% END %]</tbody>
1557
	    [% END %]</tbody>
1527
	</table>
1558
	</table>
(-)a/opac/opac-course-details.pl (+60 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#
4
# Copyright 2012 Bywater Solutions
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
use Modern::Perl;
22
23
use CGI;
24
25
use C4::Auth;
26
use C4::Output;
27
use C4::Koha;
28
29
use C4::CourseReserves;
30
31
my $cgi = new CGI;
32
33
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
34
    {
35
        template_name   => "opac-course-details.tmpl",
36
        query           => $cgi,
37
        type            => "opac",
38
        authnotrequired => 1,
39
        debug           => 1,
40
    }
41
);
42
43
my $action = $cgi->param('action') || '';
44
my $course_id = $cgi->param('course_id');
45
46
die( "No course_id given" ) unless ( $course_id );
47
48
if ( $action eq 'del_reserve' ) {
49
    DelCourseReserve( cr_id => $cgi->param('cr_id') );
50
}
51
52
my $course = GetCourse( $course_id );
53
my $course_reserves = GetCourseReserves( course_id => $course_id, include_items => 1, include_count => 1 );
54
55
$template->param(
56
    course => $course,
57
    course_reserves => $course_reserves,
58
);
59
60
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/opac/opac-course-reserves.pl (+51 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#
4
# Copyright 2012 Bywater Solutions
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
use Modern::Perl;
22
23
use CGI;
24
25
use C4::Auth;
26
use C4::Output;
27
28
use C4::CourseReserves;
29
30
my $cgi = new CGI;
31
32
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
33
    {
34
        template_name   => "opac-course-reserves.tmpl",
35
        query           => $cgi,
36
        type            => "opac",
37
        authnotrequired => 1,
38
        debug           => 1,
39
    }
40
);
41
42
my $search_on = $cgi->param('search_on');
43
44
my $courses = SearchCourses( term => $search_on, enabled => 'yes' );
45
46
if ( @$courses == 1 ) {
47
    print $cgi->redirect("/cgi-bin/koha/opac-course-details.pl?course_id=" . $courses->[0]->{'course_id'});
48
} else {
49
    $template->param( courses => $courses );
50
    output_html_with_http_headers $cgi, $cookie, $template->output;
51
}
(-)a/opac/opac-detail.pl (+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;
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'} = GetItemReservesInfo( 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');
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 = GetItemReservesInfo( 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