Bug 3669: Moving 'Add a new message' into a pop up box and adding to patron toolbar

This patch moves all the code into an include which can be accessed from the 'Add a new message' link or the patron toolbar.

EDIT: Ensuring modal opens on all pages
EDIT2: Once the form has been submitted the page will redirect to where you submitted the form from.
EDIT3: Fixing indentation of member-add-message.inc
       Ensuring messages save on every page
       Fill branch
       Ensure predefined notes appear
       Form redirects to where it was submitted from, or just the circulation page.
EDIT4: Removing the new include file and moving it all into the modal in the toolbar
EDIT5: Removing swp file and unnecessary code duplication by utilising plugins
EDIT6: Batch checkout fixes
EDIT7: Ensure you do not get JS error from Comment 24 (Batch checkout syspref must be turned on)

To test:
1) Go to a patron circ page (circ/circulation.pl?borrowernumber=X)
2) Click 'Add a new message' under Messages
3) Confirm this brings up the modal to add a message. Confirm clicking Save saves your message. If it is an OPAC message (for the user), confirm it shows as expected on the OPAC.
4) Click Cancel. Confirm this closes the modal.
5) Click 'Add message' button in toolbar. Complete steps 3 and 4.
6) Confirm the modal opens from all other pages with the members toolbar. Confirm predefined notes shows.
	circ/circulation.pl
	members/moremember.pl
	members/routing-lists.pl
	members/statistics.pl
	members/boraccount.pl
	members/pay.pl
	members/maninvoice.pl
	members/mancredit.pl
	members/readingrec.pl
	members/notices.pl
	members/member-flags.pl
	members/member-password.pl
	members/paycollect.pl
	members/files.pl
        turn on BatchCheckouts syspref and put in appropriate patron category
        circ/circulation.pl?borrowernumber=X&batch=1
7) Confirm that the page redirects to where you submitted the form from once you have submitted it.
8) Go to Check Out tab and confirm your message saved (or OPAC, wherever you saved it)

Sponsored-by: Catalyst IT

Followed test plan, works as expected. (Re-tested for comment #24)
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Aleisha 2016-03-24 00:28:42 +00:00 committed by Kyle M Hall
parent 3e566de51f
commit 573f1ac474
9 changed files with 50 additions and 52 deletions

View File

@ -51,5 +51,5 @@ Koha::Patron::Message->new(
}
)->store;
print $input->redirect(
"/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
my $url = $input->referer() // "/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber";
print $input->redirect($url);

View File

@ -658,15 +658,10 @@ $template->param(
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
$template->param( picture => 1 ) if $patron_image;
# get authorised values with type of BOR_NOTES
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
$template->param(
debt_confirmed => $debt_confirmed,
SpecifyDueDate => $duedatespec_allow,
CircAutocompl => C4::Context->preference("CircAutocompl"),
canned_bor_notes_loop => $canned_notes,
debarments => GetDebarments({ borrowernumber => $borrowernumber }),
todaysdate => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
modifications => Koha::Patron::Modifications->GetModifications({ borrowernumber => $borrowernumber }),

View File

@ -1,5 +1,7 @@
[% USE Koha %]
[% USE Borrowers %]
[% USE Branches %]
[% USE AuthorisedValues %]
[% SET NorwegianPatronDBEnable = Koha.Preference( 'NorwegianPatronDBEnable' ) %]
<script type="text/javascript">
//<![CDATA[
@ -170,6 +172,8 @@ function searchToHold(){
<a id="searchtohold" class="btn btn-small" href="#"><i class="fa fa-search"></i> Search to hold</a>
[% END %]
<a id="addnewmessageLabel" href="#add_message_form" data-toggle="modal" class="btn btn-small"><i class="fa fa-comment-o"></i> Add message</a>
<div class="btn-group">
<button class="btn btn-small dropdown-toggle" data-toggle="dropdown">More <span class="caret"></span></button>
<ul class="dropdown-menu">
@ -212,3 +216,44 @@ function searchToHold(){
</ul>
</div>
</div>
<!-- Modal -->
<div id="add_message_form" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="addnewmessageLabel" aria-hidden="true">
<div class="modal-body">
<form method="post" action="/cgi-bin/koha/circ/add_message.pl" id="message_form" name="message_f">
<fieldset id="borrower_messages" class="brief">
<legend>Leave a message</legend>
<ol>
<li>
<label for="message_type">Add a message for:</label>
<select name="message_type" id="message_type">
<option value="L">Staff - Internal note</option>
<option value="B">OPAC - [% firstname %] [% surname %]</option>
</select>
</li>
[% bor_notes = AuthorisedValues.Get( 'BOR_NOTES' ) %]
[% IF bor_notes %]
<li>
<label for="type">Predefined notes: </label>
<select name="type" id="type" onchange="this.form.borrower_message.value=this.options[this.selectedIndex].value;">
<option value="">Select note</option>
[% FOREACH bor_note IN bor_notes %]
<option value="[% bor_note.lib %]">[% bor_note.lib %]</option>
[% END %]
</select>
</li>
[% END %]
<li>
<textarea rows="3" cols="60" name="borrower_message" id="borrower_message" ></textarea>
</li>
</ol>
<input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
<input type="hidden" name="branchcode" value="[% LoginBranchcode %]" />
</fieldset>
</div>
<div class="modal-footer">
<fieldset class="action">
<input type="submit" value="Save" /> </form><a href="#" class="cancel" data-dismiss="modal" aria-hidden="true">Cancel</a>
</fieldset>
</div>
</div>

View File

@ -47,7 +47,6 @@ var relatives_borrowernumbers = new Array();
relatives_borrowernumbers.push("[% b %]");
[% END %]
var MSG_ADD_MESSAGE = _("Add a new message");
var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export");
var MSG_CONFIRM_DELETE_MESSAGE = _("Are you sure you want to delete this message? This cannot be undone.");
@ -140,43 +139,6 @@ $(document).ready(function() {
[% END %]
<!-- INITIAL BLOC : PARAMETERS & BORROWER INFO -->
<div style="display: none;" id="add_message_form">
<form method="post" action="/cgi-bin/koha/circ/add_message.pl" id="message_form" name="message_f">
<fieldset id="borrower_messages" class="brief">
<legend>Leave a message</legend>
<ol>
<li>
<label for="message_type">Add a message for:</label>
<select name="message_type" id="message_type">
<option value="L">Staff - Internal note</option>
<option value="B">OPAC - [% firstname %] [% surname %]</option>
</select>
</li>
[% IF ( canned_bor_notes_loop ) %]
<li>
<label for="type">Predefined notes: </label>
<select name="type" id="type" onchange="this.form.borrower_message.value=this.options[this.selectedIndex].value;">
<option value="">Select note</option>
[% FOREACH canned_bor_notes_loo IN canned_bor_notes_loop %]
<option value="[% canned_bor_notes_loo.lib %]">[% canned_bor_notes_loo.lib %]</option>
[% END %]
</select>
</li>
[% END %]
<li>
<textarea rows="3" cols="60" name="borrower_message" id="borrower_message" ></textarea>
</li>
</ol>
<fieldset class="action">
<input type="submit" value="Save" /> <a href="#" class="cancel">Cancel</a>
</fieldset>
<input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
<input type="hidden" name="branchcode" value="[% branch %]" />
</fieldset>
</form>
</div>
[% IF ( was_renewed ) %]<div class="dialog message">Patron's account has been renewed until [% expiry | $KohaDates %]</div>[% END %]
[% IF additional_materials %]
@ -880,6 +842,7 @@ No patron matched <span class="ex">[% message %]</span>
[% END %]</li>
[% END %]
</ul>
<a id="addnewmessageLabel" href="#add_message_form" data-toggle="modal">Add a new message</a>
</div>
</div>

View File

@ -79,7 +79,7 @@ $(document).ready(function() {
[% END %]
</div>
[% ELSIF borrower and not checkout_infos %]
<form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/circ/circulation.pl">
<form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% borrowernumber %]&batch=1">
<fieldset id="circ_circulation_issue">
<label for="barcode">Checking out to [% INCLUDE 'patron-title.inc' %]</label>
<fieldset class="rows">
@ -110,7 +110,7 @@ $(document).ready(function() {
[% ELSIF borrower %]
[% IF confirmation_needed && CAN_user_circulate_force_checkout %]
<h3>Batch checkout confirmation [% IF borrowernumber %] for [% INCLUDE 'patron-title.inc' invert_name = 1 %] [% END %]</h3>
<form method="post" action="/cgi-bin/koha/circ/circulation.pl" id="mainform" name="mainform" autocomplete="off">
<form method="post" action="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% borrowernumber %]" id="mainform" name="mainform" autocomplete="off">
[% ELSE %]
<h3>Batch checkout information [% IF borrowernumber %] for [% INCLUDE 'patron-title.inc' invert_name = 1 %] [% END %]</h3>
[% END %]

View File

@ -42,7 +42,6 @@ var relatives_borrowernumbers = new Array();
relatives_borrowernumbers.push("[% b %]");
[% END %]
var MSG_ADD_MESSAGE = _("Add a new message");
var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export");
columns_settings = [% ColumnsSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) %]

View File

@ -14,8 +14,6 @@ $(document).ready(function() {
}
});
$("#messages ul").after("<a href=\"#\" id=\"addmessage\">"+MSG_ADD_MESSAGE+"</a>");
$("#borrower_messages .cancel").on("click",function(){
$("#add_message_form").hide();
$("#addmessage").show();

View File

@ -119,7 +119,6 @@ if (C4::Context->preference('ExtendedPatronAttributes')) {
);
}
$template->param(%$data);
$template->param(

View File

@ -88,7 +88,6 @@ if ($borrowernumber) {
##################################################################################
$template->param(%$borrower);
$template->param(