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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt (-12 / +26 lines)
Lines 64-77 Link Here
64
                }
64
                }
65
            };
65
            };
66
            function Add() {
66
            function Add() {
67
                var barcodes = document.getElementById("barcode");
67
                var number_list = document.getElementById("number_list");
68
                if (barcodes.value == '') {
68
                if (number_list.value == '') {
69
                    window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=[% batch_id %]&type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
69
                    window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=[% batch_id %]&type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
70
                }
70
                }
71
                else {
71
                else {
72
                    document.forms["add_by_barcode"].submit();
72
                    document.forms["add_by_number"].submit();
73
                }
73
                }
74
            };
74
            };
75
76
            function add_item(item_number) {
77
                $("#itemnum_enter").prop("checked",true);
78
                $("#number_list").val($("#number_list").val()+item_number+"\r\n");
79
            };
80
75
            function DeDuplicate() {
81
            function DeDuplicate() {
76
                window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=de_duplicate&batch_id=[% batch_id %]";
82
                window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=de_duplicate&batch_id=[% batch_id %]";
77
            };
83
            };
Lines 195-211 Link Here
195
201
196
                        <div id="manage-label-batches">
202
                        <div id="manage-label-batches">
197
                            <div class="hint">Current library: [% LoginBranchname %]</div>
203
                            <div class="hint">Current library: [% LoginBranchname %]</div>
198
                            <form name="add_by_barcode" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post">
204
                            <form name="add_by_number" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post">
199
                                <div>
205
                                <div>
200
                                    <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
206
                                    <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
201
                                    <ol><li>
207
                                    <ol><li>
202
                                    <input type="hidden" name="op" value="add" />
208
                                        <input type="hidden" name="op" value="add" />
203
                                    <input type="hidden" name="batch_id" value="[% batch_id %]" />
209
                                        <input type="hidden" name="batch_id" value="[% batch_id %]" />
204
                                    <label for="barcode">Add by barcode(s):
210
                                    </li>
205
                                        <br /> <span class="hint">One barcode per line.</span>
211
                                    <li>
206
                                        <br /> <span class="hint">Leave empty to add via item search.</span>
212
                                        <input type="radio" name="number_type" id="barcode_enter" value="barcode" checked />
207
                                    </label>
213
                                        <label for="barcode_enter">Enter by barcode</label><br/>
208
                                    <textarea rows="5" id="barcode" name="barcode" tabindex="1" class="focus"></textarea>
214
                                        <input type="radio" name="number_type" id="itemnum_enter" value="itemnumber" />
215
                                        <label for="itemnum_enter">Enter by itemnumber</label>
216
                                    </li>
217
                                    <li>
218
                                        <label for="number_list">Add by barcode(s) or itemnumbers(s):
219
                                            <br /> <span class="hint">One number per line.</span>
220
                                            <br /> <span class="hint">Leave empty to add via item search (itemnunber).</span>
221
                                        </label>
222
                                        <textarea rows="5" id="number_list" name="number_list" tabindex="1" class="focus"></textarea>
209
                                    </li></ol>
223
                                    </li></ol>
210
                                    </fieldset>
224
                                    </fieldset>
211
                                </div>
225
                                </div>
Lines 263-269 Link Here
263
                                <ol><li>
277
                                <ol><li>
264
                                    <div class="dialog message">
278
                                    <div class="dialog message">
265
                                        <h4>There are no items in this batch yet</h4>
279
                                        <h4>There are no items in this batch yet</h4>
266
                                        <p>Add items by barcode using the text area above or leave empty to add via item search.</p>
280
                                        <p>Add items by using the text area above or leave empty to add via item search.</p>
267
                                    </div>
281
                                    </div>
268
                                </li></ol>
282
                                </li></ol>
269
                                </fieldset>
283
                                </fieldset>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tt (-9 / +4 lines)
Lines 16-42 Link Here
16
                });
16
                });
17
            });
17
            });
18
            function add_item(item_number,batch_id,type_id){
18
            function add_item(item_number,batch_id,type_id){
19
                var getstr='';
19
                var p = window.opener;
20
                if (item_number == 'checked') {
20
                if (item_number == 'checked') {
21
                    items= new Array;
21
                    items= new Array;
22
                    if(document.resultform.action.length > 0) {
22
                    if(document.resultform.action.length > 0) {
23
                        for (var i=0; i < document.resultform.action.length; i++) {
23
                        for (var i=0; i < document.resultform.action.length; i++) {
24
                            if (document.resultform.action[i].checked) {
24
                            if (document.resultform.action[i].checked) {
25
                                items.push("item_number=" +  document.resultform.action[i].value);
25
                                p.add_item(document.resultform.action[i].value);
26
                            }
26
                            }
27
                        }
27
                        }
28
                        getstr = items.join("&");
29
                    } else {
28
                    } else {
30
                        getstr = "item_number="+document.resultform.action.value;
29
                        p.add_item(document.resultform.action.value);
31
                    }
30
                    }
32
                }
31
                }
33
                else {
32
                else {
34
                    getstr = "item_number="+item_number;
33
                    p.add_item(item_number);
35
                }
34
                }
36
                var myurl = "label-edit-batch.pl?op=add&batch_id="+batch_id+
37
                "&"+getstr;
38
                window.opener.location.href = myurl;
39
                //top.location.href=myurl;
40
            }
35
            }
41
            //]]>
36
            //]]>
42
    </script>
37
    </script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt (-10 / +32 lines)
Lines 46-63 Link Here
46
                    return; // abort delete
46
                    return; // abort delete
47
                }
47
                }
48
            };
48
            };
49
50
            function Add() {
49
            function Add() {
51
                window.open("/cgi-bin/koha/patroncards/add_user_search.pl",
50
                var bor_nums = document.getElementById("bor_num_list");
51
                if (bor_nums.value == '') {
52
                    window.open("/cgi-bin/koha/patroncards/add_user_search.pl",
52
                   'PatronPopup',
53
                   'PatronPopup',
53
                   'width=740,height=450,location=yes,toolbar=no,'
54
                   'width=740,height=450,location=yes,toolbar=no,'
54
                   + 'scrollbars=yes,resize=yes'
55
                   + 'scrollbars=yes,resize=yes');
55
               );
56
                }
56
            }
57
                else {
58
                    document.forms["add_by_bor_num"].submit();
59
                }
60
            };
57
61
58
            function add_user(borrowernumber) {
62
            function add_user(borrowernumber) {
59
                var myurl = "edit-batch.pl?op=add&batch_id=[% batch_id %]&borrower_number="+borrowernumber;
63
                $("#bor_num_list").val($("#bor_num_list").val()+borrowernumber+"\r\n");
60
                window.location.href = myurl;
61
            }
64
            }
62
65
63
            function DeDuplicate() {
66
            function DeDuplicate() {
Lines 180-185 Link Here
180
                    [% INCLUDE 'patroncards-errors.inc' %]
183
                    [% INCLUDE 'patroncards-errors.inc' %]
181
                    <div id="manage-patroncard-batches">
184
                    <div id="manage-patroncard-batches">
182
                        <div class="hint">Current library: [% LoginBranchname %]</div>
185
                        <div class="hint">Current library: [% LoginBranchname %]</div>
186
                            <form name="add_by_bor_num" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post">
187
                                <div>
188
                                    <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
189
                                    <ol><li>
190
                                    <input type="hidden" name="op" value="add" />
191
                                    <input type="hidden" name="batch_id" value="[% batch_id %]" />
192
                                    <label for="bor_num_list">Add by borrowernumber(s):
193
                                        <br /> <span class="hint">One borrowernumber per line.</span>
194
                                    </label>
195
                                    <textarea rows="5" id="bor_num_list" name="bor_num_list" tabindex="1" class="focus"></textarea>
196
                                    </li></ol>
197
                                    </fieldset>
198
                                </div>
199
                            </form>
183
                            [% IF ( table_loop ) %]
200
                            [% IF ( table_loop ) %]
184
                            <form name="items" class="checkboxed">
201
                            <form name="items" class="checkboxed">
185
                                <h2>Items in batch number [% batch_id %]</h2>
202
                                <h2>Items in batch number [% batch_id %]</h2>
Lines 221-229 Link Here
221
                                </table>
238
                                </table>
222
                            </form>
239
                            </form>
223
                            [% ELSE %]
240
                            [% ELSE %]
224
                                <div class="dialog message">
241
                                <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
225
                                <h4>There are no items in batch [% batch_id %] yet</h4>
242
                                <ol><li>
226
                                <p>Use the toolbar above to add items.</p></div>
243
                                    <div class="dialog message">
244
                                        <h4>There are no items in this batch yet</h4>
245
                                        <p>Add items by borrowernumber using the text area above or leave empty to add via patron search.</p>
246
                                    </div>
247
                                </li></ol>
248
                                </fieldset>
227
                            [% END %]
249
                            [% END %]
228
                        </div>
250
                        </div>
229
                    </div>
251
                    </div>
(-)a/labels/label-edit-batch.pl (-11 / +17 lines)
Lines 26-32 use CGI qw ( -utf8 ); Link Here
26
26
27
use C4::Auth qw(get_template_and_user);
27
use C4::Auth qw(get_template_and_user);
28
use C4::Output qw(output_html_with_http_headers);
28
use C4::Output qw(output_html_with_http_headers);
29
use C4::Items qw(GetItemnumberFromBarcode);
29
use C4::Items qw(GetItem GetItemnumberFromBarcode);
30
use C4::Creators;
30
use C4::Creators;
31
use C4::Labels;
31
use C4::Labels;
32
32
Lines 57-67 my $display_columns = [ {_label_number => {label => 'Label Number', link_field Link Here
57
my $op = $cgi->param('op') || 'edit';
57
my $op = $cgi->param('op') || 'edit';
58
my @label_ids;
58
my @label_ids;
59
my @item_numbers;
59
my @item_numbers;
60
my $barcode;
60
my $number_list;
61
my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || undef;
61
my $number_type = $cgi->param('number_type') || "barcode";
62
my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || 0;
62
@label_ids = $cgi->param('label_id') if $cgi->param('label_id');
63
@label_ids = $cgi->param('label_id') if $cgi->param('label_id');
63
@item_numbers = $cgi->param('item_number') if $cgi->param('item_number');
64
@item_numbers = $cgi->param('item_number') if $cgi->param('item_number');
64
$barcode = $cgi->param('barcode') if $cgi->param('barcode');
65
$number_list = $cgi->param('number_list') if $cgi->param('number_list');
65
66
66
my $branch_code = C4::Context->userenv->{'branch'};
67
my $branch_code = C4::Context->userenv->{'branch'};
67
68
Lines 80-96 elsif ($op eq 'delete') { Link Here
80
    $errstr = "batch $batch_id was not deleted." if $err;
81
    $errstr = "batch $batch_id was not deleted." if $err;
81
}
82
}
82
elsif ($op eq 'add') {
83
elsif ($op eq 'add') {
83
    if ($barcode) {
84
    if ($number_list) {
84
        my @barcodes = split /\n/, $barcode; # $barcode is effectively passed in as a <cr> separated list
85
        my @numbers_list = split /\n/, $number_list; # Entries are effectively passed in as a <cr> separated list
85
        foreach my $number (@barcodes) {
86
        foreach my $number (@numbers_list) {
86
            $number =~ s/\r$//; # strip any naughty return chars
87
            $number =~ s/\r$//; # strip any naughty return chars
87
            if (my $item_number = GetItemnumberFromBarcode($number)) {  # we must test in case an invalid barcode is passed in; we effectively disgard them atm
88
            if( $number_type eq "itemnumber" && GetItem($number) ) {
88
                push @item_numbers, $item_number;
89
                push @item_numbers, $number;
90
            }
91
            elsif ($number_type eq "barcode" ) {  # we must test in case an invalid barcode is passed in; we effectively disgard them atm
92
                if( my $item_number = GetItemnumberFromBarcode($number) ){
93
                    push @item_numbers, $item_number;
94
                }
89
            }
95
            }
90
        }
96
        }
91
    }
97
    }
92
    $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
98
    if ($batch_id != 0) {$batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);}
93
    $batch = C4::Labels::Batch->new(branch_code => $branch_code) if $batch == -2;
99
    if ($batch_id == 0 || $batch == -2) {$batch = C4::Labels::Batch->new(branch_code => $branch_code);}
94
    if ($branch_code){
100
    if ($branch_code){
95
        foreach my $item_number (@item_numbers) {
101
        foreach my $item_number (@item_numbers) {
96
            $err = $batch->add_item($item_number);
102
            $err = $batch->add_item($item_number);
(-)a/patroncards/edit-batch.pl (-6 / +16 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 53-64 my $display_columns = [ {_card_number => {label => 'Card Number', link_field = Link Here
53
                        {select         => {label => 'Select', value => '_label_id'}},
53
                        {select         => {label => 'Select', value => '_label_id'}},
54
                      ];
54
                      ];
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') || 0;
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 $bor_num_list = $cgi->param('bor_num_list') || undef;
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
    $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
82
if ($bor_num_list) {
83
    $batch = C4::Patroncards::Batch->new(branch_code => $branch_code) if $batch == -2;
83
        my @bor_nums_unchecked = split /\n/, $bor_num_list; # $bor_num_list is effectively passed in as a <cr> separated list
84
        foreach my $number (@bor_nums_unchecked) {
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
    }
92
    if ($batch_id != 0) {$batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);}
93
    if ($batch_id == 0 || $batch == -2) {$batch = C4::Patroncards::Batch->new(branch_code => $branch_code);}
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