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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt (-10 / +33 lines)
Lines 6-11 Link Here
6
    [% INCLUDE 'datatables.inc' %]
6
    [% INCLUDE 'datatables.inc' %]
7
    <script type="text/javascript">
7
    <script type="text/javascript">
8
        //<![CDATA[
8
        //<![CDATA[
9
           var popup;
9
           function DeleteConfirm() {
10
           function DeleteConfirm() {
10
                var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id %]");
11
                var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id %]");
11
                var answer = confirm(msg);
12
                var answer = confirm(msg);
Lines 46-63 Link Here
46
                    return; // abort delete
47
                    return; // abort delete
47
                }
48
                }
48
            };
49
            };
49
50
            function Add() {
50
            function Add() {
51
                window.open("/cgi-bin/koha/patroncards/add_user_search.pl",
51
                var barcodes = document.getElementById("barcode");
52
                if (barcodes.value == '') {
53
                    window.open("/cgi-bin/koha/patroncards/add_user_search.pl",
52
                   'PatronPopup',
54
                   'PatronPopup',
53
                   'width=740,height=450,location=yes,toolbar=no,'
55
                   'width=740,height=450,location=yes,toolbar=no,'
54
                   + 'scrollbars=yes,resize=yes'
56
                   + 'scrollbars=yes,resize=yes');
55
               );
57
                }
56
            }
58
                else {
59
                    document.forms["add_by_barcode"].submit();
60
                }
61
            };
57
62
58
            function add_user(borrowernumber) {
63
            function add_user(borrowernumber) {
59
                var myurl = "edit-batch.pl?op=add&batch_id=[% batch_id %]&borrower_number="+borrowernumber;
64
                $("#barcode").val($("#barcode").val()+borrowernumber+"\r\n");
60
                window.location.href = myurl;
61
            }
65
            }
62
66
63
            function DeDuplicate() {
67
            function DeDuplicate() {
Lines 180-185 Link Here
180
                    [% INCLUDE 'patroncards-errors.inc' %]
184
                    [% INCLUDE 'patroncards-errors.inc' %]
181
                    <div id="manage-patroncard-batches">
185
                    <div id="manage-patroncard-batches">
182
                        <div class="hint">Current library: [% LoginBranchname %]</div>
186
                        <div class="hint">Current library: [% LoginBranchname %]</div>
187
                            <form name="add_by_barcode" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post">
188
                                <div>
189
                                    <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
190
                                    <ol><li>
191
                                    <input type="hidden" name="op" value="add" />
192
                                    <input type="hidden" name="batch_id" value="[% batch_id %]" />
193
                                    <label for="barcode">Add by borrowernumber(s):
194
                                        <br /> <span class="hint">One borrowernumber per line.</span>
195
                                    </label>
196
                                    <textarea rows="5" id="barcode" name="barcode" tabindex="1" class="focus"></textarea>
197
                                    </li></ol>
198
                                    </fieldset>
199
                                </div>
200
                            </form>
183
                            [% IF ( table_loop ) %]
201
                            [% IF ( table_loop ) %]
184
                            <form name="items" class="checkboxed">
202
                            <form name="items" class="checkboxed">
185
                                <h2>Items in batch number [% batch_id %]</h2>
203
                                <h2>Items in batch number [% batch_id %]</h2>
Lines 221-229 Link Here
221
                                </table>
239
                                </table>
222
                            </form>
240
                            </form>
223
                            [% ELSE %]
241
                            [% ELSE %]
224
                                <div class="dialog message">
242
                                <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
225
                                <h4>There are no items in batch [% batch_id %] yet</h4>
243
                                <ol><li>
226
                                <p>Use the toolbar above to add items.</p></div>
244
                                    <div class="dialog message">
245
                                        <h4>There are no items in this batch yet</h4>
246
                                        <p>Add items by borrowernumber using the text area above or leave empty to add via patron search.</p>
247
                                    </div>
248
                                </li></ol>
249
                                </fieldset>
227
                            [% END %]
250
                            [% END %]
228
                        </div>
251
                        </div>
229
                    </div>
252
                    </div>
(-)a/patroncards/edit-batch.pl (-4 / +14 lines)
Lines 29-35 use C4::Auth qw(get_template_and_user); Link Here
29
use C4::Output qw(output_html_with_http_headers);
29
use C4::Output qw(output_html_with_http_headers);
30
use C4::Creators;
30
use C4::Creators;
31
use C4::Patroncards;
31
use C4::Patroncards;
32
32
use C4::Members qw(GetMember);
33
my $cgi = new CGI;
33
my $cgi = new CGI;
34
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
34
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
35
    {
35
    {
Lines 55-64 my $display_columns = [ {_card_number => {label => 'Card Number', link_field = Link Here
55
my $op = $cgi->param('op') || 'new';
55
my $op = $cgi->param('op') || 'new';
56
my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || undef;
56
my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || undef;
57
my @label_ids = $cgi->param('label_id') if $cgi->param('label_id');
57
my @label_ids = $cgi->param('label_id') if $cgi->param('label_id');
58
my @item_numbers = $cgi->param('item_number') if $cgi->param('item_number');
58
my @item_numbers; #= $cgi->param('item_number') if $cgi->param('item_number');
59
my @borrower_numbers = $cgi->param('borrower_number') if $cgi->param('borrower_number');
59
my @borrower_numbers = $cgi->param('borrower_number') if $cgi->param('borrower_number');
60
my $errstr = $cgi->param('error') || '';
60
my $errstr = $cgi->param('error') || '';
61
61
my $barcode = $cgi->param('barcode') if $cgi->param('barcode');
62
my $branch_code = C4::Context->userenv->{'branch'};
62
my $branch_code = C4::Context->userenv->{'branch'};
63
63
64
if ($op eq 'remove') {
64
if ($op eq 'remove') {
Lines 79-90 elsif ($op eq 'delete') { Link Here
79
    }
79
    }
80
}
80
}
81
elsif ($op eq 'add') {
81
elsif ($op eq 'add') {
82
if ($barcode) {
83
        my @barcodes = split /\n/, $barcode; # $barcode is effectively passed in as a <cr> separated list
84
        foreach my $number (@barcodes) {
85
            $number =~ s/\r$//; # strip any naughty return chars
86
            if ( GetMember(borrowernumber => $number)) {  # we must test in case an invalid borrowernumber is passed in; we effectively disgard them atm
87
                my $borrower_number = $number;
88
                push @borrower_numbers, $borrower_number;
89
            }
90
        }
91
    }
82
    $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
92
    $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
83
    $batch = C4::Patroncards::Batch->new(branch_code => $branch_code) if $batch == -2;
93
    $batch = C4::Patroncards::Batch->new(branch_code => $branch_code) if $batch == -2;
84
    if ($branch_code){
94
    if ($branch_code){
85
        foreach my $borrower_number (@borrower_numbers) {
95
        foreach my $borrower_number (@borrower_numbers) {
86
            $err = $batch->add_item($borrower_number);
96
            $err = $batch->add_item($borrower_number);
87
        }
97
        }
98
        $batch_id = $batch->get_attr('batch_id') if $batch_id == 0; #update batch_id if we added to a new batch
88
        if ($err) {
99
        if ($err) {
89
            print $cgi->redirect("edit-batch.pl?op=edit&batch_id=$batch_id&error=401");
100
            print $cgi->redirect("edit-batch.pl?op=edit&batch_id=$batch_id&error=401");
90
            exit;
101
            exit;
91
- 

Return to bug 14739