Bugzilla – Attachment 42473 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]
Bug 14739 - Add several patrons to a new batch will create a new batch per patron added
Bug-14739---Add-several-patrons-to-a-new-batch-wil.patch (text/plain), 7.68 KB, created by
Nick Clemens (kidclamp)
on 2015-09-10 10:45:35 UTC
(
hide
)
Description:
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-09-10 10:45:35 UTC
Size:
7.68 KB
patch
obsolete
>From 8df7539fadeb83eaa853dccf6eea61ba781408ac Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@quecheelibrary.org> >Date: Thu, 10 Sep 2015 06:35:37 -0400 >Subject: [PATCH] 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 searhc, 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 popupo >3 - Add items to batch using the popup, borrowernumbers should populate to the form >4 - Click add items again and items hsoul;d 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 >--- > .../prog/en/modules/patroncards/edit-batch.tt | 43 +++++++++++++++++----- > patroncards/edit-batch.pl | 17 +++++++-- > 2 files changed, 47 insertions(+), 13 deletions(-) > >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 25f79d4..ccebbec 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 >@@ -6,6 +6,7 @@ > [% INCLUDE 'datatables.inc' %] > <script type="text/javascript"> > //<![CDATA[ >+ var popup; > function DeleteConfirm() { > var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id %]"); > var answer = confirm(msg); >@@ -46,18 +47,21 @@ > return; // abort delete > } > }; >- > function Add() { >- window.open("/cgi-bin/koha/patroncards/add_user_search.pl", >+ var barcodes = document.getElementById("barcode"); >+ if (barcodes.value == '') { >+ window.open("/cgi-bin/koha/patroncards/add_user_search.pl", > 'PatronPopup', > 'width=740,height=450,location=yes,toolbar=no,' >- + 'scrollbars=yes,resize=yes' >- ); >- } >+ + 'scrollbars=yes,resize=yes'); >+ } >+ else { >+ document.forms["add_by_barcode"].submit(); >+ } >+ }; > > function add_user(borrowernumber) { >- var myurl = "edit-batch.pl?op=add&batch_id=[% batch_id %]&borrower_number="+borrowernumber; >- window.location.href = myurl; >+ $("#barcode").val($("#barcode").val()+borrowernumber+"\r\n"); > } > > function DeDuplicate() { >@@ -180,6 +184,20 @@ > [% INCLUDE 'patroncards-errors.inc' %] > <div id="manage-patroncard-batches"> > <div class="hint">Current library: [% LoginBranchname %]</div> >+ <form name="add_by_barcode" 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="barcode">Add by borrowernumber(s): >+ <br /> <span class="hint">One borrowernumber per line.</span> >+ </label> >+ <textarea rows="5" id="barcode" name="barcode" 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> >@@ -221,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/patroncards/edit-batch.pl b/patroncards/edit-batch.pl >index 9cd9adb..9cd6199 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( > { >@@ -55,10 +55,10 @@ my $display_columns = [ {_card_number => {label => 'Card Number', link_field = > 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 @item_numbers; #= $cgi->param('item_number') if $cgi->param('item_number'); > my @borrower_numbers = $cgi->param('borrower_number') if $cgi->param('borrower_number'); > my $errstr = $cgi->param('error') || ''; >- >+my $barcode = $cgi->param('barcode') if $cgi->param('barcode'); > my $branch_code = C4::Context->userenv->{'branch'}; > > if ($op eq 'remove') { >@@ -79,12 +79,23 @@ elsif ($op eq 'delete') { > } > } > 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) { >+ $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; >+ } >+ } >+ } > $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id); > $batch = C4::Patroncards::Batch->new(branch_code => $branch_code) if $batch == -2; > 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; >-- >1.9.1
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