Browse Source

Bug 6815: Don't make an AJAX request to generate the modal

moremember-patronimage.pl|tt were not needed.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
22.05.x
Jonathan Druart 2 years ago
committed by Fridolin Somers
parent
commit
43b04cd3be
  1. 80
      koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
  2. 83
      koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-patronimage.tt
  3. 15
      koha-tmpl/intranet-tmpl/prog/js/members-menu.js
  4. 59
      members/moremember-patronimage.pl

80
koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc

@ -180,6 +180,7 @@
[% END %]
</ul></div>
[% IF patronimages && CAN_user_tools_batch_upload_patron_images %]
<!-- Modal -->
<div class="modal" id="patronImageEdit" tabindex="-1" role="dialog" aria-labelledby="patronImageEditLabel">
<div class="modal-dialog" role="document">
@ -189,7 +190,83 @@
<h4 class="modal-title" id="patronImageEditLabel">Patron photo</h4>
</div>
<div class="modal-body">
<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" />
<div id="upload-patron-image" class="patroninfo-section">
<h5>Upload patron photo</h5>
<form method="post" id="picture-upload" action="/cgi-bin/koha/tools/picture-upload.pl"
enctype="multipart/form-data">
[% IF ( patron.image ) %]
<div class="hint">
To update the image for [% patron.title | html %] [% patron.firstname | html %] [% patron.surname | html %], select a new image file and click 'Upload.' <br />Click the 'Delete' button to
remove the current image.
</div>
[% ELSE %]
<div class="hint">
[% patron.title | html %] [% patron.firstname | html %] [% patron.surname | html %] does not currently have an image available. To import an image for [% patron.title | html %] [% patron.firstname | html %] [% patron.surname | html %], enter the name of an image file to upload.
</div>
[% END %]
<p>Only PNG, GIF, JPEG, XPM formats are supported.</p>
<label for="uploadfile">Select the file to upload: </label>
<input type="file" id="uploadfile" name="uploadfile" required="required" />
<div class="action">
<input type="hidden" id="csrf_token" name="csrf_token" value="[% csrf_token | html %]" />
<input type="hidden" id="image" name="filetype" value="image" />
<input type="hidden" id="cardnumber" name="cardnumber" value="[% patron.cardnumber | html %]" />
<input type="hidden" id="borrowernumber" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
<button type="submit" class="btn btn-default btn-xs"><i class="fa fa-upload"></i> Upload photo</button>
<input name="op" type="hidden" value="Upload" />
[% IF ( patron.image ) %]
<a id="delpicture"
href="/cgi-bin/koha/tools/picture-upload.pl?op=Delete&amp;borrowernumber=[% patron.borrowernumber | html %]&amp;csrf_token=[% csrf_token | html %]"
class="btn btn-default btn-xs delete"><i class="fa fa-trash"></i> Delete</a>
[% END %]
</div>
</form>
</div>
<div id="capture-patron-image" class="patroninfo-section">
<h5>Take patron photo</h5>
<form method="post" id="camera-upload" action="/cgi-bin/koha/tools/picture-upload.pl">
<div class="btn-toolbar">
<div class="btn-group">
<button class="btn btn-default" id="takebutton"><i class="fa fa-camera"></i> Take photo</button>
</div>
<div class="btn-group">
<button class="btn btn-default" id="retakebutton" style="display:none;"><i class="fa fa-refresh"></i> Retake photo</button>
</div>
<div class="btn-group">
<a id="downloadbutton" href="#" class="btn btn-default" style="display:none;"><i class="fa fa-download"></i> Download photo</a>
</div>
<div class="btn-group">
<button id="savebutton" type="submit" class="btn btn-default" style="display:none;"><i class="fa fa-hdd-o"></i> Upload</button>
</div>
</div>
<div id="camera">
<video id="viewfinder">Video stream not available.</video>
</div>
<canvas id="canvas" style="display:none"></canvas>
<div id="output" style="display:none">
<img style="width:100%;height:auto;" id="photo" alt="The screen capture will appear in this box.">
</div>
<input type="hidden" name="uploadfilename" value="patron-photo.jpg" />
<textarea id="uploadfiletext" name="uploadfiletext" style="display:none;"></textarea>
<input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
<input type="hidden" name="filetype" value="image" />
<input type="hidden" name="cardnumber" value="[% patron.cardnumber | html %]" />
<input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
<input name="op" type="hidden" value="Upload" />
</form>
</div>
<div class="dialog message" style="display:none" id="camera-error">
<div>
<span class="fa-stack fa-lg">
<i class="fa fa-camera fa-stack-1x"></i>
<i class="fa fa-ban fa-stack-2x text-danger"></i>
</span>
</div>
<div>
<strong>Cannot take patron photo.</strong>
<span id="camera-error-message"></span>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
@ -197,5 +274,6 @@
</div>
</div>
</div>
[% END %]
[% END %]

83
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-patronimage.tt

@ -1,83 +0,0 @@
[% USE Koha %]
[% IF ( Koha.Preference('patronimages') ) %]
[% IF ( CAN_user_tools_batch_upload_patron_images ) %]
<div id="upload-patron-image" class="patroninfo-section">
<h5>Upload patron photo</h5>
<form method="post" id="picture-upload" action="/cgi-bin/koha/tools/picture-upload.pl"
enctype="multipart/form-data">
[% IF ( patron.image ) %]
<div class="hint">
To update the image for [% patron.title | html %] [% patron.firstname | html %] [% patron.surname | html %], select a new image file and click 'Upload.' <br />Click the 'Delete' button to
remove the current image.
</div>
[% ELSE %]
<div class="hint">
[% patron.title | html %] [% patron.firstname | html %] [% patron.surname | html %] does not currently have an image available. To import an image for [% patron.title | html %] [% patron.firstname | html %] [% patron.surname | html %], enter the name of an image file to upload.
</div>
[% END %]
<p>Only PNG, GIF, JPEG, XPM formats are supported.</p>
<label for="uploadfile">Select the file to upload: </label>
<input type="file" id="uploadfile" name="uploadfile" required="required" />
<div class="action">
<input type="hidden" id="csrf_token" name="csrf_token" value="[% csrf_token | html %]" />
<input type="hidden" id="image" name="filetype" value="image" />
<input type="hidden" id="cardnumber" name="cardnumber" value="[% patron.cardnumber | html %]" />
<input type="hidden" id="borrowernumber" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
<button type="submit" class="btn btn-default btn-xs"><i class="fa fa-upload"></i> Upload photo</button>
<input name="op" type="hidden" value="Upload" />
[% IF ( patron.image ) %]
<a id="delpicture"
href="/cgi-bin/koha/tools/picture-upload.pl?op=Delete&amp;borrowernumber=[% patron.borrowernumber | html %]&amp;csrf_token=[% csrf_token | html %]"
class="btn btn-default btn-xs delete"><i class="fa fa-trash"></i> Delete</a>
[% END %]
</div>
</form>
</div>
<div id="capture-patron-image" class="patroninfo-section">
<h5>Take patron photo</h5>
<form method="post" id="camera-upload" action="/cgi-bin/koha/tools/picture-upload.pl">
<div class="btn-toolbar">
<div class="btn-group">
<button class="btn btn-default" id="takebutton"><i class="fa fa-camera"></i> Take photo</button>
</div>
<div class="btn-group">
<button class="btn btn-default" id="retakebutton" style="display:none;"><i class="fa fa-refresh"></i> Retake photo</button>
</div>
<div class="btn-group">
<a id="downloadbutton" href="#" class="btn btn-default" style="display:none;"><i class="fa fa-download"></i> Download photo</a>
</div>
<div class="btn-group">
<button id="savebutton" type="submit" class="btn btn-default" style="display:none;"><i class="fa fa-hdd-o"></i> Upload</button>
</div>
</div>
<div id="camera">
<video id="viewfinder">Video stream not available.</video>
</div>
<canvas id="canvas" style="display:none"></canvas>
<div id="output" style="display:none">
<img style="width:100%;height:auto;" id="photo" alt="The screen capture will appear in this box.">
</div>
<input type="hidden" name="uploadfilename" value="patron-photo.jpg" />
<textarea id="uploadfiletext" name="uploadfiletext" style="display:none;"></textarea>
<input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
<input type="hidden" name="filetype" value="image" />
<input type="hidden" name="cardnumber" value="[% patron.cardnumber | html %]" />
<input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
<input name="op" type="hidden" value="Upload" />
</form>
</div>
<div class="dialog message" style="display:none" id="camera-error">
<div>
<span class="fa-stack fa-lg">
<i class="fa fa-camera fa-stack-1x"></i>
<i class="fa fa-ban fa-stack-2x text-danger"></i>
</span>
</div>
<div>
<strong>Cannot take patron photo.</strong>
<span id="camera-error-message"></span>
</div>
</div>
[% END %]
[% END %]

15
koha-tmpl/intranet-tmpl/prog/js/members-menu.js

@ -99,19 +99,8 @@ $(document).ready(function(){
var borrowernumber = $(this).data("borrowernumber");
var cardnumber = $(this).data("cardnumber");
var modalTitle = $(this).attr("title");
$.ajax({
url: "/cgi-bin/koha/members/moremember-patronimage.pl",
type: "GET",
data: { borrowernumber: borrowernumber, cardnumber: cardnumber },
success: function ( data ) {
$("#patronImageEdit .modal-body").html( data );
$("#patronImageEdit .modal-title").text(modalTitle);
$("#patronImageEdit").modal("show");
},
error: function () {
location.href="/cgi-bin/koha/members/moremember-patronimage.pl?borrowernumber=" + borrowernumber;
}
});
$("#patronImageEdit .modal-title").text(modalTitle);
$("#patronImageEdit").modal("show");
$("#patronImageEdit").on("hidden.bs.modal", function(){
/* Stop using the user's camera when modal is closed */
let viewfinder = document.getElementById("viewfinder");

59
members/moremember-patronimage.pl

@ -1,59 +0,0 @@
#!/usr/bin/perl
# Copyright 2020 Mark Tompsett
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth qw( get_template_and_user );
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
use Koha::Patrons;
use Koha::Token;
my $input = CGI->new;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => 'members/moremember-patronimage.tt',
query => $input,
type => 'intranet',
flagsrequired => { borrowers => 'edit_borrowers' },
}
);
my $borrowernumber = $input->param('borrowernumber');
my $cardnumber = $input->param('cardnumber');
my $patron = Koha::Patrons->find($borrowernumber);
my $logged_in_user = Koha::Patrons->find($loggedinuser);
$template->param(
csrf_token => Koha::Token->new->generate_csrf(
{ session_id => $input->cookie('CGISESSID'), }
),
patron => $patron,
logged_in_user => $logged_in_user,
);
output_html_with_http_headers $input, $cookie, $template->output;
__END__
=head1 moremember-patronimage.pl
script to provide modal window for patron images
=cut
Loading…
Cancel
Save