Bugzilla – Attachment 44663 Details for
Bug 14739
Add several patrons to a new batch will create a new batch per patron added
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[3.18.x rewrite] Bug 14739 - Add several patrons to a new batch will create a new batch per patron added
318x-rewrite-Bug-14739---Add-several-patrons-to-a-.patch (text/plain), 22.31 KB, created by
Nick Clemens (kidclamp)
on 2015-11-09 17:46:28 UTC
(
hide
)
Description:
[3.18.x rewrite] Bug 14739 - Add several patrons to a new batch will create a new batch per patron added
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2015-11-09 17:46:28 UTC
Size:
22.31 KB
patch
obsolete
>From ef10d2723e7aaf1a4aa82233ac2bbe66ff079afd Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@quecheelibrary.org> >Date: Thu, 10 Sep 2015 06:35:37 -0400 >Subject: [PATCH] [3.18.x rewrite] Bug 14739 - Add several patrons to a new > batch will create a new batch per patron added > >This patch changes the functionality of adding patrons to patroncard batches. Instead of using only the patron search, there is now a textarea which can either be manually populated with borrowernumbers, or can be populated using the patron-search > >To test: >1 - Create a new patron batch >2 - Click the add items button, if there is no data in the borrowrnumber form you should get a popup >3 - Add items to batch using the popup, borrowernumbers should populate to the form >4 - Click add items again and items should be added to a new batch >5 - Create a new batch >6 - Manually enter invalid borrowernumbers to the form >7 - Click add items, batch should return empty >8 - Manually enter valid borrowernumber >9 - Click add items, batch should be updated >10 - Edit an existing batch and confirm add items works as above >11 - Create a new label batch >12 - Click add items with no data, popup item search should appear >13 - Adding items by checking boxes or using 'Add' button - they should populate the text box on the edit batch page >14 - When adding using form the 'Enter by itemnumber' button should be marked automatically >15 - Submit items and confirm they are added to batch >16 - Create a new batch, enter by barcode manually and check 'Enter by itemnumber" >17 - Click add items, no items should be added >18 - Repopulate form with barcodes, check 'Enter by barcode' >19 - Click add items, items should be added correctly >20 - Test various combinations of radio buttons and numbers and using form or not > >Signed-off-by: Barton Chittenden <barton@bywatersolutions.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../prog/en/modules/labels/label-edit-batch.tt | 44 +++++++++++++++------- > .../intranet-tmpl/prog/en/modules/labels/result.tt | 13 ++----- > .../prog/en/modules/patroncards/edit-batch.tt | 42 +++++++++++++++++++-- > .../prog/en/modules/patroncards/members-search.tt | 18 ++++----- > labels/label-edit-batch.pl | 28 ++++++++------ > patroncards/edit-batch.pl | 28 ++++++++++---- > 6 files changed, 117 insertions(+), 56 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt >index 6832d56..532406a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt >@@ -64,14 +64,20 @@ > } > }; > function Add() { >- var barcodes = document.getElementById("barcode"); >- if (barcodes.value == '') { >+ var number_list = document.getElementById("number_list"); >+ if (number_list.value == '') { > 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'); > } > else { >- document.forms["add_by_barcode"].submit(); >+ document.forms["add_by_number"].submit(); > } > }; >+ >+ function add_item(item_number) { >+ $("#itemnum_enter").prop("checked",true); >+ $("#number_list").val($("#number_list").val()+item_number+"\r\n"); >+ }; >+ > function DeDuplicate() { > window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=de_duplicate&batch_id=[% batch_id %]"; > }; >@@ -168,7 +174,11 @@ > <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › > <a href="/cgi-bin/koha/labels/label-home.pl">Labels home</a> › > <a href="/cgi-bin/koha/labels/label-manage.pl?label_element=batch">Manage label batches</a> › >- Manage batch number [% batch_id %] >+ [% IF batch_id %] >+ Manage batch number [% batch_id %] >+ [% ELSE %] >+ Create new batch >+ [% END %] > </div> > <div id="doc3" class="yui-t2"> > <div id="bd"> >@@ -195,17 +205,25 @@ > > <div id="manage-label-batches"> > <div class="hint">Current library: [% LoginBranchname %]</div> >- <form name="add_by_barcode" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post"> >+ <form name="add_by_number" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post"> > <div> > <fieldset class="rows" style="border-bottom: 0px; border: 0px;"> > <ol><li> >- <input type="hidden" name="op" value="add" /> >- <input type="hidden" name="batch_id" value="[% batch_id %]" /> >- <label for="barcode">Add by barcode(s): >- <br /> <span class="hint">One barcode per line.</span> >- <br /> <span class="hint">Leave empty to add via item search.</span> >- </label> >- <textarea rows="5" id="barcode" name="barcode" tabindex="1" class="focus"></textarea> >+ <input type="hidden" name="op" value="add" /> >+ <input type="hidden" name="batch_id" value="[% batch_id %]" /> >+ </li> >+ <li> >+ <input type="radio" name="number_type" id="barcode_enter" value="barcode" checked /> >+ <label for="barcode_enter">Enter by barcode</label><br/> >+ <input type="radio" name="number_type" id="itemnum_enter" value="itemnumber" /> >+ <label for="itemnum_enter">Enter by itemnumber</label> >+ </li> >+ <li> >+ <label for="number_list">Add by barcode(s) or itemnumbers(s): >+ <br /> <span class="hint">One number per line.</span> >+ <br /> <span class="hint">Leave empty to add via item search (itemnunber).</span> >+ </label> >+ <textarea rows="5" id="number_list" name="number_list" tabindex="1" class="focus"></textarea> > </li></ol> > </fieldset> > </div> >@@ -263,7 +281,7 @@ > <ol><li> > <div class="dialog message"> > <h4>There are no items in this batch yet</h4> >- <p>Add items by barcode using the text area above or leave empty to add via item search.</p> >+ <p>Add items by using the text area above or leave empty to add via item search.</p> > </div> > </li></ol> > </fieldset> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tt >index 3b7ce08..65dc131 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tt >@@ -16,27 +16,22 @@ > }); > }); > function add_item(item_number,batch_id,type_id){ >- var getstr=''; >+ var p = window.opener; > if (item_number == 'checked') { > items= new Array; > if(document.resultform.action.length > 0) { > for (var i=0; i < document.resultform.action.length; i++) { > if (document.resultform.action[i].checked) { >- items.push("item_number=" + document.resultform.action[i].value); >+ p.add_item(document.resultform.action[i].value); > } > } >- getstr = items.join("&"); > } else { >- getstr = "item_number="+document.resultform.action.value; >+ p.add_item(document.resultform.action.value); > } > } > else { >- getstr = "item_number="+item_number; >+ p.add_item(item_number); > } >- var myurl = "label-edit-batch.pl?op=add&batch_id="+batch_id+ >- "&"+getstr; >- window.opener.location.href = myurl; >- //top.location.href=myurl; > } > //]]> > </script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt >index 0851936..ad4348a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt >@@ -47,8 +47,19 @@ > } > }; > function Add() { >+ var bor_nums = document.getElementById("bor_num_list"); >+ if (bor_nums.value == '') { > window.open("/cgi-bin/koha/patroncards/members-search.pl?batch_id=[% batch_id %]",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes'); >+ } >+ else { >+ document.forms["add_by_bor_num"].submit(); >+ } > }; >+ >+ function add_user(borrowernumber) { >+ $("#bor_num_list").val($("#bor_num_list").val()+borrowernumber+"\r\n"); >+ } >+ > function DeDuplicate() { > window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&batch_id=[% batch_id %]"; > }; >@@ -144,7 +155,11 @@ > <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › > <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a> › > <a href="/cgi-bin/koha/patroncards/manage.pl?card_element=batch">Manage patron card batches</a> › >- Manage batch number [% batch_id %] >+ [% IF batch_id %] >+ Manage batch number [% batch_id %] >+ [% ELSE %] >+ Create new batch >+ [% END %] > </div> > <div id="doc3" class="yui-t2"> > <div id="bd"> >@@ -169,6 +184,20 @@ > [% INCLUDE 'patroncards-errors.inc' %] > <div id="manage-patroncard-batches"> > <div class="hint">Current library: [% LoginBranchname %]</div> >+ <form name="add_by_bor_num" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post"> >+ <div> >+ <fieldset class="rows" style="border-bottom: 0px; border: 0px;"> >+ <ol><li> >+ <input type="hidden" name="op" value="add" /> >+ <input type="hidden" name="batch_id" value="[% batch_id %]" /> >+ <label for="bor_num_list">Add by borrowernumber(s): >+ <br /> <span class="hint">One borrowernumber per line.</span> >+ </label> >+ <textarea rows="5" id="bor_num_list" name="bor_num_list" tabindex="1" class="focus"></textarea> >+ </li></ol> >+ </fieldset> >+ </div> >+ </form> > [% IF ( table_loop ) %] > <form name="items" class="checkboxed"> > <h2>Items in batch number [% batch_id %]</h2> >@@ -210,9 +239,14 @@ > </table> > </form> > [% ELSE %] >- <div class="dialog message"> >- <h4>There are no items in batch [% batch_id %] yet</h4> >- <p>Use the toolbar above to add items.</p></div> >+ <fieldset class="rows" style="border-bottom: 0px; border: 0px;"> >+ <ol><li> >+ <div class="dialog message"> >+ <h4>There are no items in this batch yet</h4> >+ <p>Add items by borrowernumber using the text area above or leave empty to add via patron search.</p> >+ </div> >+ </li></ol> >+ </fieldset> > [% END %] > </div> > </div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/members-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/members-search.tt >index 50289c1..89b0e31 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/members-search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/members-search.tt >@@ -17,25 +17,21 @@ $(document).ready(function(){ > return false; > }); > }); >-function add_item(borrowernum,batch_id,type_id){ >- var getstr=''; >+function add_item(borrowernum){ >+ var p = window.opener; > if (borrowernum == 'checked') { >- itms= new Array; > if(document.resultform.borrowernumber.length > 0) { > for (var i=0; i < document.resultform.borrowernumber.length; i++) { > if (document.resultform.borrowernumber[i].checked) { >- itms.push("borrower_number=" + document.resultform.borrowernumber[i].value); >+ p.add_user(document.resultform.borrowernumber[i].value); > } > } >- getstr = itms.join("&"); > } else { >- getstr = "borrower_number="+document.resultform.borrowernumber.value; >+ if ( document.resultform.borrowernumber.checked ) { p.add_user(document.resultform.borrowernumber.value); } > } > } else { >- getstr = "borrower_number="+borrowernum; >+ p.add_user(borrowernum); > } >- var myurl = "edit-batch.pl?op=add&batch_id="+batch_id+"&"+getstr; >- window.opener.location.href = myurl; > } > //]]> > </script> >@@ -80,7 +76,7 @@ function add_item(borrowernum,batch_id,type_id){ > [% IF ( resultsloop ) %] > <div id="searchheader"> <h3>Results [% from %] to [% to %] of [% numresults %] found [% IF ( member ) %]for name: '<span class="ex">[% member %]</span>'[% END %] [% IF ( category ) %]with category code: '<span class="ex">[% category %]</span>'[% END %]</h3></div> > [% IF ( paginationbar ) %]<div id="pagination_top" class="pages">[% paginationbar %]</div>[% END %] >-<form name="resultform" action="/cgi-bin/koha/patroncards/members-search.pl" method="get" class="checkboxed"><div style="float: right; margin-top: .5em;"><input type="submit" class="icon addchecked" value="Add checked" onclick="add_item('checked',[% batch_id %]); return false" /> <input type="button" class="close" value="Done" /></div> >+<form name="resultform" action="/cgi-bin/koha/patroncards/members-search.pl" method="get" class="checkboxed"><div style="float: right; margin-top: .5em;"><input type="submit" class="icon addchecked" value="Add checked" onclick="add_item('checked'); return false" /> <input type="button" class="close" value="Done" /></div> > <div style="line-height: 2em; margin-left: .7em;"><a id="CheckAll" href="/cgi-bin/koha/patroncards/members-search.pl">Select All</a><a id="CheckNone" href="/cgi-bin/koha/patroncards/members-search.pl">Clear All</a></div> > <div class="searchresults"> > >@@ -108,7 +104,7 @@ function add_item(borrowernum,batch_id,type_id){ > <td>[% resultsloo.branchcode %]</td> > <td>[% resultsloo.dateexpiry %]</td> > <td>[% resultsloo.borrowernotes %]</td> >- <td><a onclick="add_item('[% resultsloo.borrowernumber %]',[% batch_id %]); return false" href="/cgi-bin/koha/patroncards/edit-batch.pl?borrower_number=[% resultsloo.borrowernumber %]&batch_id=[% batch_id %]&op=add">Add</a></td> >+ <td><a onclick="add_item('[% resultsloo.borrowernumber %]'); return false" href="">Add</a></td> > </tr> > [% END %] > </table> >diff --git a/labels/label-edit-batch.pl b/labels/label-edit-batch.pl >index f73ff34..c768fa5 100755 >--- a/labels/label-edit-batch.pl >+++ b/labels/label-edit-batch.pl >@@ -26,7 +26,7 @@ use CGI; > > use C4::Auth qw(get_template_and_user); > use C4::Output qw(output_html_with_http_headers); >-use C4::Items qw(GetItemnumberFromBarcode); >+use C4::Items qw(GetItem GetItemnumberFromBarcode); > use C4::Creators; > use C4::Labels; > >@@ -57,11 +57,12 @@ my $display_columns = [ {_label_number => {label => 'Label Number', link_field > my $op = $cgi->param('op') || 'edit'; > my @label_ids; > my @item_numbers; >-my $barcode; >-my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || undef; >+my $number_list; >+my $number_type = $cgi->param('number_type') || "barcode"; >+my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || 0; > @label_ids = $cgi->param('label_id') if $cgi->param('label_id'); > @item_numbers = $cgi->param('item_number') if $cgi->param('item_number'); >-$barcode = $cgi->param('barcode') if $cgi->param('barcode'); >+$number_list = $cgi->param('number_list') if $cgi->param('number_list'); > > my $branch_code = C4::Context->userenv->{'branch'}; > >@@ -80,17 +81,22 @@ elsif ($op eq 'delete') { > $errstr = "batch $batch_id was not deleted." if $err; > } > elsif ($op eq 'add') { >- if ($barcode) { >- my @barcodes = split /\n/, $barcode; # $barcode is effectively passed in as a <cr> separated list >- foreach my $number (@barcodes) { >+ if ($number_list) { >+ my @numbers_list = split /\n/, $number_list; # Entries are effectively passed in as a <cr> separated list >+ foreach my $number (@numbers_list) { > $number =~ s/\r$//; # strip any naughty return chars >- if (my $item_number = GetItemnumberFromBarcode($number)) { # we must test in case an invalid barcode is passed in; we effectively disgard them atm >- push @item_numbers, $item_number; >+ if( $number_type eq "itemnumber" && GetItem($number) ) { >+ push @item_numbers, $number; >+ } >+ elsif ($number_type eq "barcode" ) { # we must test in case an invalid barcode is passed in; we effectively disgard them atm >+ if( my $item_number = GetItemnumberFromBarcode($number) ){ >+ push @item_numbers, $item_number; >+ } > } > } > } >- $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id); >- $batch = C4::Labels::Batch->new(branch_code => $branch_code) if $batch == -2; >+ if ($batch_id != 0) {$batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);} >+ if ($batch_id == 0 || $batch == -2) {$batch = C4::Labels::Batch->new(branch_code => $branch_code);} > if ($branch_code){ > foreach my $item_number (@item_numbers) { > $err = $batch->add_item($item_number); >diff --git a/patroncards/edit-batch.pl b/patroncards/edit-batch.pl >index c5f9f59..a882330 100755 >--- a/patroncards/edit-batch.pl >+++ b/patroncards/edit-batch.pl >@@ -29,7 +29,7 @@ use C4::Auth qw(get_template_and_user); > use C4::Output qw(output_html_with_http_headers); > use C4::Creators; > use C4::Patroncards; >- >+use C4::Members qw(GetMember); > my $cgi = new CGI; > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { >@@ -53,12 +53,13 @@ my $display_columns = [ {_card_number => {label => 'Card Number', link_field = > {select => {label => 'Select', value => '_label_id'}}, > ]; > my $op = $cgi->param('op') || 'new'; >-my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || undef; >-my @label_ids = $cgi->param('label_id') if $cgi->param('label_id'); >-my @item_numbers = $cgi->param('item_number') if $cgi->param('item_number'); >-my @borrower_numbers = $cgi->param('borrower_number') if $cgi->param('borrower_number'); >+my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || 0; >+my ( @label_ids, @item_numbers, @borrower_numbers ); >+@label_ids = $cgi->param('label_id') if $cgi->param('label_id'); >+@item_numbers = $cgi->param('item_number') if $cgi->param('item_number'); >+@borrower_numbers = $cgi->param('borrower_number') if $cgi->param('borrower_number'); > my $errstr = $cgi->param('error') || ''; >- >+my $bor_num_list = $cgi->param('bor_num_list') || undef; > my $branch_code = C4::Context->userenv->{'branch'}; > > if ($op eq 'remove') { >@@ -79,12 +80,23 @@ elsif ($op eq 'delete') { > } > } > elsif ($op eq 'add') { >- $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id); >- $batch = C4::Patroncards::Batch->new(branch_code => $branch_code) if $batch == -2; >+if ($bor_num_list) { >+ my @bor_nums_unchecked = split /\n/, $bor_num_list; # $bor_num_list is effectively passed in as a <cr> separated list >+ foreach my $number (@bor_nums_unchecked) { >+ $number =~ s/\r$//; # strip any naughty return chars >+ if ( GetMember(borrowernumber => $number)) { # we must test in case an invalid borrowernumber is passed in; we effectively disgard them atm >+ my $borrower_number = $number; >+ push @borrower_numbers, $borrower_number; >+ } >+ } >+ } >+ if ($batch_id != 0) {$batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);} >+ if ($batch_id == 0 || $batch == -2) {$batch = C4::Patroncards::Batch->new(branch_code => $branch_code);} > if ($branch_code){ > foreach my $borrower_number (@borrower_numbers) { > $err = $batch->add_item($borrower_number); > } >+ $batch_id = $batch->get_attr('batch_id') if $batch_id == 0; #update batch_id if we added to a new batch > if ($err) { > print $cgi->redirect("edit-batch.pl?op=edit&batch_id=$batch_id&error=401"); > exit; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14739
:
42421
|
42445
|
42473
|
42474
|
42623
|
42965
|
43034
|
43038
|
43040
|
43050
|
43052
|
43060
|
43061
|
43062
|
43063
|
43107
|
43108
|
43109
| 44663