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

(-)a/course_reserves/batch_add_items.pl (-37 / +43 lines)
Lines 52-101 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
52
    }
52
    }
53
);
53
);
54
54
55
$template->param( course => GetCourse($course_id) );
55
my $course = GetCourse($course_id);
56
56
57
if ( !$action ) {
57
if ( $course_id && $course ) {
58
    $template->param( action => 'display_form' );
58
    $template->param( course => $course );
59
}
60
elsif ( $action eq 'add' ) {
61
    my @barcodes = uniq( split( /\s\n/, $barcodes ) );
62
63
    my @items;
64
    my @invalid_barcodes;
65
    for my $b (@barcodes) {
66
        my $item = Koha::Items->find( { barcode => $b } );
67
59
68
        if ($item) {
60
    if ( !$action ) {
69
            push( @items, $item );
61
        $template->param( action => 'display_form' );
70
        }
71
        else {
72
            push( @invalid_barcodes, $b );
73
        }
74
    }
62
    }
63
    elsif ( $action eq 'add' ) {
64
        my @barcodes = uniq( split( /\s\n/, $barcodes ) );
65
66
        my @items;
67
        my @invalid_barcodes;
68
        for my $b (@barcodes) {
69
            my $item = Koha::Items->find( { barcode => $b } );
70
71
            if ($item) {
72
                push( @items, $item );
73
            }
74
            else {
75
                push( @invalid_barcodes, $b );
76
            }
77
        }
75
78
76
    foreach my $item (@items) {
79
        foreach my $item (@items) {
77
        my $ci_id = ModCourseItem(
80
            my $ci_id = ModCourseItem(
78
            itemnumber    => $item->id,
81
                itemnumber    => $item->id,
79
            itype         => $itype,
82
                itype         => $itype,
80
            ccode         => $ccode,
83
                ccode         => $ccode,
81
            holdingbranch => $holdingbranch,
84
                holdingbranch => $holdingbranch,
82
            location      => $location,
85
                location      => $location,
83
        );
86
            );
87
88
            my $cr_id = ModCourseReserve(
89
                course_id   => $course_id,
90
                ci_id       => $ci_id,
91
                staff_note  => $staff_note,
92
                public_note => $public_note,
93
            );
94
        }
84
95
85
        my $cr_id = ModCourseReserve(
96
        $template->param(
86
            course_id   => $course_id,
97
            action           => 'display_results',
87
            ci_id       => $ci_id,
98
            items_added      => \@items,
88
            staff_note  => $staff_note,
99
            invalid_barcodes => \@invalid_barcodes,
89
            public_note => $public_note,
100
            course_id        => $course_id,
90
        );
101
        );
91
    }
102
    }
92
103
} else {
93
    $template->param(
104
    $template->param( action => 'invalid_course' );
94
        action           => 'display_results',
95
        items_added      => \@items,
96
        invalid_barcodes => \@invalid_barcodes,
97
        course_id        => $course_id,
98
    );
99
}
105
}
100
106
101
output_html_with_http_headers $cgi, $cookie, $template->output;
107
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_add_items.tt (-1 / +3 lines)
Lines 16-21 Link Here
16
<div class="main container-fluid">
16
<div class="main container-fluid">
17
    <div class="row">
17
    <div class="row">
18
        <div class="col-md-8 col-md-offset-2">
18
        <div class="col-md-8 col-md-offset-2">
19
        [% IF action == 'invalid_course' %]
20
            <div id="invalid-course-error" class="dialog alert">Invalid course!</div>
21
        [% END %]
19
22
20
        [% IF action == 'display_form' %]
23
        [% IF action == 'display_form' %]
21
            <form method="post" action="/cgi-bin/koha/course_reserves/batch_add_items.pl">
24
            <form method="post" action="/cgi-bin/koha/course_reserves/batch_add_items.pl">
22
- 

Return to bug 20467