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

(-)a/C4/CourseReserves.pm (-2 / +3 lines)
Lines 376-383 sub ModCourseInstructors { Link Here
376
    return unless ( $cardnumbers || $borrowernumbers );
376
    return unless ( $cardnumbers || $borrowernumbers );
377
    return if ( $cardnumbers && $borrowernumbers );
377
    return if ( $cardnumbers && $borrowernumbers );
378
378
379
    my @cardnumbers = @$cardnumbers if ( ref($cardnumbers) eq 'ARRAY' );
379
    my (@cardnumbers, @borrowernumbers);
380
    my @borrowernumbers = @$borrowernumbers
380
    @cardnumbers = @$cardnumbers if ( ref($cardnumbers) eq 'ARRAY' );
381
    @borrowernumbers = @$borrowernumbers
381
      if ( ref($borrowernumbers) eq 'ARRAY' );
382
      if ( ref($borrowernumbers) eq 'ARRAY' );
382
383
383
    my $field  = (@cardnumbers) ? 'cardnumber' : 'borrowernumber';
384
    my $field  = (@cardnumbers) ? 'cardnumber' : 'borrowernumber';
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step1.tt (-3 / +1 lines)
Lines 36-44 $(document).ready(function() { Link Here
36
36
37
                            <fieldset class="rows">
37
                            <fieldset class="rows">
38
                                <legend>Add items: scan barcode</legend>
38
                                <legend>Add items: scan barcode</legend>
39
39
                                <ol>
40
                                    <p>
41
42
                                    <li>
40
                                    <li>
43
                                        <label class="required" for="barcode">Item barcode:</label>
41
                                        <label class="required" for="barcode">Item barcode:</label>
44
                                        <input id="barcode" name="barcode" type="text" />
42
                                        <input id="barcode" name="barcode" type="text" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt (-2 / +6 lines)
Lines 9-15 Link Here
9
//<![CDATA[
9
//<![CDATA[
10
10
11
    function confirmItemDelete(){
11
    function confirmItemDelete(){
12
        return confirm( _('Are you sure you want to delete this item?');
12
        return confirm( _("Are you sure you want to delete this item?"));
13
    }
13
    }
14
14
15
//]]>
15
//]]>
Lines 39-45 Link Here
39
                    });
39
                    });
40
40
41
                    function confirmDelete(p_oEvent){
41
                    function confirmDelete(p_oEvent){
42
                        if ( ! confirm( _('Are you sure you want to delete this course?') ) ) {
42
                        if ( ! confirm( _("Are you sure you want to delete this course?") ) ) {
43
                            YAHOO.util.Event.stopEvent( p_oEvent );
43
                            YAHOO.util.Event.stopEvent( p_oEvent );
44
                        }
44
                        }
45
                    }
45
                    }
Lines 54-59 Link Here
54
            </div><!-- /toolbar -->
54
            </div><!-- /toolbar -->
55
55
56
            <table>
56
            <table>
57
              <tbody>
57
                <tr><th>Course name</th><td>[% course.course_name %]</td></tr>
58
                <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>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>Department</th><td>_[% AuthorisedValues.GetByCode( 'DEPARTMENT', course.department ) %]</td></tr>
Lines 64-71 Link Here
64
                <tr><th>Public note</th><td>[% course.public_note %]</td></tr>
65
                <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>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
                <tr><th>Status</th><td>[% IF course.enabled == 'yes' %]Active[% ELSE %]Inactive[% END %]</td></tr>
68
              </tbody>
67
            </table>
69
            </table>
68
70
71
            [% IF course_reserves %]
69
            <table>
72
            <table>
70
                <thead>
73
                <thead>
71
                    <tr>
74
                    <tr>
Lines 177-182 Link Here
177
                    [% END %]
180
                    [% END %]
178
                </tbody>
181
                </tbody>
179
            </table>
182
            </table>
183
            [% END %]
180
        </div>
184
        </div>
181
    </div>
185
    </div>
182
</div>
186
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt (+2 lines)
Lines 11-16 Link Here
11
 $(document).ready(function() {
11
 $(document).ready(function() {
12
    $("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, {
12
    $("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, {
13
        "sPaginationType": "four_button",
13
        "sPaginationType": "four_button",
14
        "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
15
        "iDisplayLength": 20
14
    }));
16
    }));
15
 });
17
 });
16
});
18
});
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt (-1 / +1 lines)
Lines 55-61 $(document).ready(function(){ Link Here
55
});
55
});
56
56
57
function AddInstructor( name, cardnumber ) {
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>";
58
    div = "<div id='borrower_" + cardnumber + "'>" + name + " ( <a href='#' onclick='RemoveInstructor(" + cardnumber + ");return false;'> Remove </a> ) <input type='hidden' name='instructors' value='" + cardnumber + "' /></div>";
59
    $('#instructors').append( div );
59
    $('#instructors').append( div );
60
60
61
    $('#find_instructor').val('').focus();
61
    $('#find_instructor').val('').focus();
(-)a/t/db_dependent/CourseReserves.t (-18 / +17 lines)
Lines 10-17 use Test::More tests => 16; Link Here
10
use Data::Dumper;
10
use Data::Dumper;
11
11
12
BEGIN {
12
BEGIN {
13
   use_ok('C4::Context');
13
    use_ok('C4::Context');
14
        use_ok('C4::CourseReserves');
14
    use_ok('C4::CourseReserves');
15
}
15
}
16
16
17
my $dbh = C4::Context->dbh;
17
my $dbh = C4::Context->dbh;
Lines 21-58 $dbh->do("TRUNCATE TABLE course_reserves"); Link Here
21
21
22
my $sth = $dbh->prepare("SELECT * FROM borrowers ORDER BY RAND() LIMIT 10");
22
my $sth = $dbh->prepare("SELECT * FROM borrowers ORDER BY RAND() LIMIT 10");
23
$sth->execute();
23
$sth->execute();
24
my @borrowers = @{$sth->fetchall_arrayref({})};
24
my @borrowers = @{ $sth->fetchall_arrayref( {} ) };
25
25
26
$sth = $dbh->prepare("SELECT * FROM items ORDER BY RAND() LIMIT 10");
26
$sth = $dbh->prepare("SELECT * FROM items ORDER BY RAND() LIMIT 10");
27
$sth->execute();
27
$sth->execute();
28
my @items = @{$sth->fetchall_arrayref({})};
28
my @items = @{ $sth->fetchall_arrayref( {} ) };
29
29
30
my $course_id = ModCourse(
30
my $course_id = ModCourse(
31
      course_name => "Test Course",
31
    course_name => "Test Course",
32
  staff_note => "Test staff note",
32
    staff_note  => "Test staff note",
33
       public_note => "Test public note",
33
    public_note => "Test public note",
34
);
34
);
35
35
36
ok( $course_id, "ModCourse created course successfully" );
36
ok( $course_id, "ModCourse created course successfully" );
37
37
38
$course_id = ModCourse(
38
$course_id = ModCourse(
39
     course_id => $course_id,
39
    course_id  => $course_id,
40
       staff_note => "Test staff note 2",
40
    staff_note => "Test staff note 2",
41
);
41
);
42
42
43
my $course = GetCourse( $course_id );
43
my $course = GetCourse($course_id);
44
44
45
ok( $course->{'course_name'} eq "Test Course", "GetCourse returned correct course" );
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" );
46
ok( $course->{'staff_note'}  eq "Test staff note 2", "ModCourse updated course succesfully" );
47
47
48
my $courses = GetCourses();
48
my $courses = GetCourses();
49
ok( $courses->[0]->{'course_name'} eq "Test Course", "GetCourses returns valid array of course data" );
49
ok( $courses->[0]->{'course_name'} eq "Test Course", "GetCourses returns valid array of course data" );
50
50
51
ModCourseInstructors( mode => 'add', course_id => $course_id, borrowernumbers => [ $borrowers[0]->{'borrowernumber'} ] );
51
ModCourseInstructors( mode => 'add', course_id => $course_id, borrowernumbers => [ $borrowers[0]->{'borrowernumber'} ] );
52
$course = GetCourse( $course_id );
52
$course = GetCourse($course_id);
53
ok( $course->{'instructors'}->[0]->{'borrowernumber'} == $borrowers[0]->{'borrowernumber'}, "ModCourseInstructors added instructors correctly");
53
ok( $course->{'instructors'}->[0]->{'borrowernumber'} == $borrowers[0]->{'borrowernumber'}, "ModCourseInstructors added instructors correctly" );
54
54
55
my $course_instructors = GetCourseInstructors( $course_id );
55
my $course_instructors = GetCourseInstructors($course_id);
56
ok( $course_instructors->[0]->{'borrowernumber'} eq $borrowers[0]->{'borrowernumber'}, "GetCourseInstructors returns valid data" );
56
ok( $course_instructors->[0]->{'borrowernumber'} eq $borrowers[0]->{'borrowernumber'}, "GetCourseInstructors returns valid data" );
57
57
58
my $ci_id = ModCourseItem( 'itemnumber' => $items[0]->{'itemnumber'} );
58
my $ci_id = ModCourseItem( 'itemnumber' => $items[0]->{'itemnumber'} );
Lines 77-84 DelCourseReserve( 'cr_id' => $cr_id ); Link Here
77
$course_reserve = GetCourseReserve( 'cr_id' => $cr_id );
77
$course_reserve = GetCourseReserve( 'cr_id' => $cr_id );
78
ok( !defined( $course_reserve->{'cr_id'} ), "DelCourseReserve functions correctly" );
78
ok( !defined( $course_reserve->{'cr_id'} ), "DelCourseReserve functions correctly" );
79
79
80
DelCourse( $course_id );
80
DelCourse($course_id);
81
$course = GetCourse( $course_id );
81
$course = GetCourse($course_id);
82
ok( !defined( $course->{'course_id'} ), "DelCourse deleted course successfully" );
82
ok( !defined( $course->{'course_id'} ), "DelCourse deleted course successfully" );
83
83
84
$dbh->do("TRUNCATE TABLE course_instructors");
84
$dbh->do("TRUNCATE TABLE course_instructors");
85
- 

Return to bug 8215