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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc (-1 / +79 lines)
Lines 180-185 Link Here
180
    [% END %]
180
    [% END %]
181
</ul></div>
181
</ul></div>
182
182
183
[% IF patronimages && CAN_user_tools_batch_upload_patron_images %]
183
<!-- Modal -->
184
<!-- Modal -->
184
<div class="modal" id="patronImageEdit" tabindex="-1" role="dialog" aria-labelledby="patronImageEditLabel">
185
<div class="modal" id="patronImageEdit" tabindex="-1" role="dialog" aria-labelledby="patronImageEditLabel">
185
    <div class="modal-dialog" role="document">
186
    <div class="modal-dialog" role="document">
Lines 189-195 Link Here
189
                <h4 class="modal-title" id="patronImageEditLabel">Patron photo</h4>
190
                <h4 class="modal-title" id="patronImageEditLabel">Patron photo</h4>
190
            </div>
191
            </div>
191
            <div class="modal-body">
192
            <div class="modal-body">
192
                <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" />
193
                <div id="upload-patron-image" class="patroninfo-section">
194
                    <h5>Upload patron photo</h5>
195
                    <form method="post" id="picture-upload" action="/cgi-bin/koha/tools/picture-upload.pl"
196
                        enctype="multipart/form-data">
197
                        [% IF ( patron.image ) %]
198
                            <div class="hint">
199
                                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
200
                                remove the current image.
201
                            </div>
202
                        [% ELSE %]
203
                            <div class="hint">
204
                                [% 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.
205
                            </div>
206
                        [% END %]
207
                        <p>Only PNG, GIF, JPEG, XPM formats are supported.</p>
208
                        <label for="uploadfile">Select the file to upload: </label>
209
                        <input type="file" id="uploadfile" name="uploadfile" required="required" />
210
                        <div class="action">
211
                            <input type="hidden" id="csrf_token" name="csrf_token" value="[% csrf_token | html %]" />
212
                            <input type="hidden" id="image" name="filetype" value="image" />
213
                            <input type="hidden" id="cardnumber" name="cardnumber" value="[% patron.cardnumber | html %]" />
214
                            <input type="hidden" id="borrowernumber" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
215
                            <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-upload"></i> Upload photo</button>
216
                            <input name="op" type="hidden" value="Upload" />
217
                            [% IF ( patron.image ) %]
218
                                <a id="delpicture"
219
                                    href="/cgi-bin/koha/tools/picture-upload.pl?op=Delete&amp;borrowernumber=[% patron.borrowernumber | html %]&amp;csrf_token=[% csrf_token | html %]"
220
                                    class="btn btn-default btn-xs delete"><i class="fa fa-trash"></i> Delete</a>
221
                            [% END %]
222
                        </div>
223
                    </form>
224
                </div>
225
                <div id="capture-patron-image" class="patroninfo-section">
226
                    <h5>Take patron photo</h5>
227
                    <form method="post" id="camera-upload" action="/cgi-bin/koha/tools/picture-upload.pl">
228
                        <div class="btn-toolbar">
229
                            <div class="btn-group">
230
                                <button class="btn btn-default" id="takebutton"><i class="fa fa-camera"></i> Take photo</button>
231
                            </div>
232
                            <div class="btn-group">
233
                                <button class="btn btn-default" id="retakebutton" style="display:none;"><i class="fa fa-refresh"></i> Retake photo</button>
234
                            </div>
235
                            <div class="btn-group">
236
                                <a id="downloadbutton" href="#" class="btn btn-default" style="display:none;"><i class="fa fa-download"></i> Download photo</a>
237
                            </div>
238
                            <div class="btn-group">
239
                                <button id="savebutton" type="submit" class="btn btn-default" style="display:none;"><i class="fa fa-hdd-o"></i> Upload</button>
240
                            </div>
241
                        </div>
242
                        <div id="camera">
243
                            <video id="viewfinder">Video stream not available.</video>
244
                        </div>
245
                        <canvas id="canvas" style="display:none"></canvas>
246
                        <div id="output" style="display:none">
247
                            <img style="width:100%;height:auto;" id="photo" alt="The screen capture will appear in this box.">
248
                        </div>
249
                        <input type="hidden" name="uploadfilename" value="patron-photo.jpg" />
250
                        <textarea id="uploadfiletext" name="uploadfiletext" style="display:none;"></textarea>
251
                        <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
252
                        <input type="hidden" name="filetype" value="image" />
253
                        <input type="hidden" name="cardnumber" value="[% patron.cardnumber | html %]" />
254
                        <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
255
                        <input name="op" type="hidden" value="Upload" />
256
                    </form>
257
                </div>
258
                <div class="dialog message" style="display:none" id="camera-error">
259
                    <div>
260
                        <span class="fa-stack fa-lg">
261
                            <i class="fa fa-camera fa-stack-1x"></i>
262
                            <i class="fa fa-ban fa-stack-2x text-danger"></i>
263
                        </span>
264
                    </div>
265
                    <div>
266
                        <strong>Cannot take patron photo.</strong>
267
                        <span id="camera-error-message"></span>
268
                    </div>
269
                </div>
193
            </div>
270
            </div>
194
            <div class="modal-footer">
271
            <div class="modal-footer">
195
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
272
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
Lines 197-201 Link Here
197
        </div>
274
        </div>
198
    </div>
275
    </div>
199
</div>
276
</div>
277
[% END %]
200
278
201
[% END %]
279
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-patronimage.tt (-83 lines)
Lines 1-83 Link Here
1
[% USE Koha %]
2
3
[% IF ( Koha.Preference('patronimages') ) %]
4
    [% IF ( CAN_user_tools_batch_upload_patron_images ) %]
5
        <div id="upload-patron-image" class="patroninfo-section">
6
            <h5>Upload patron photo</h5>
7
            <form method="post" id="picture-upload" action="/cgi-bin/koha/tools/picture-upload.pl"
8
                enctype="multipart/form-data">
9
                [% IF ( patron.image ) %]
10
                    <div class="hint">
11
                        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
12
                        remove the current image.
13
                    </div>
14
                [% ELSE %]
15
                    <div class="hint">
16
                        [% 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.
17
                    </div>
18
                [% END %]
19
                <p>Only PNG, GIF, JPEG, XPM formats are supported.</p>
20
                <label for="uploadfile">Select the file to upload: </label>
21
                <input type="file" id="uploadfile" name="uploadfile" required="required" />
22
                <div class="action">
23
                    <input type="hidden" id="csrf_token" name="csrf_token" value="[% csrf_token | html %]" />
24
                    <input type="hidden" id="image" name="filetype" value="image" />
25
                    <input type="hidden" id="cardnumber" name="cardnumber" value="[% patron.cardnumber | html %]" />
26
                    <input type="hidden" id="borrowernumber" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
27
                    <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-upload"></i> Upload photo</button>
28
                    <input name="op" type="hidden" value="Upload" />
29
                    [% IF ( patron.image ) %]
30
                        <a id="delpicture"
31
                            href="/cgi-bin/koha/tools/picture-upload.pl?op=Delete&amp;borrowernumber=[% patron.borrowernumber | html %]&amp;csrf_token=[% csrf_token | html %]"
32
                            class="btn btn-default btn-xs delete"><i class="fa fa-trash"></i> Delete</a>
33
                    [% END %]
34
                </div>
35
            </form>
36
        </div>
37
        <div id="capture-patron-image" class="patroninfo-section">
38
            <h5>Take patron photo</h5>
39
            <form method="post" id="camera-upload" action="/cgi-bin/koha/tools/picture-upload.pl">
40
                <div class="btn-toolbar">
41
                    <div class="btn-group">
42
                        <button class="btn btn-default" id="takebutton"><i class="fa fa-camera"></i> Take photo</button>
43
                    </div>
44
                    <div class="btn-group">
45
                        <button class="btn btn-default" id="retakebutton" style="display:none;"><i class="fa fa-refresh"></i> Retake photo</button>
46
                    </div>
47
                    <div class="btn-group">
48
                        <a id="downloadbutton" href="#" class="btn btn-default" style="display:none;"><i class="fa fa-download"></i> Download photo</a>
49
                    </div>
50
                    <div class="btn-group">
51
                        <button id="savebutton" type="submit" class="btn btn-default" style="display:none;"><i class="fa fa-hdd-o"></i> Upload</button>
52
                    </div>
53
                </div>
54
                <div id="camera">
55
                    <video id="viewfinder">Video stream not available.</video>
56
                </div>
57
                <canvas id="canvas" style="display:none"></canvas>
58
                <div id="output" style="display:none">
59
                    <img style="width:100%;height:auto;" id="photo" alt="The screen capture will appear in this box.">
60
                </div>
61
                <input type="hidden" name="uploadfilename" value="patron-photo.jpg" />
62
                <textarea id="uploadfiletext" name="uploadfiletext" style="display:none;"></textarea>
63
                <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
64
                <input type="hidden" name="filetype" value="image" />
65
                <input type="hidden" name="cardnumber" value="[% patron.cardnumber | html %]" />
66
                <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
67
                <input name="op" type="hidden" value="Upload" />
68
            </form>
69
        </div>
70
        <div class="dialog message" style="display:none" id="camera-error">
71
            <div>
72
                <span class="fa-stack fa-lg">
73
                    <i class="fa fa-camera fa-stack-1x"></i>
74
                    <i class="fa fa-ban fa-stack-2x text-danger"></i>
75
                </span>
76
            </div>
77
            <div>
78
                <strong>Cannot take patron photo.</strong>
79
                <span id="camera-error-message"></span>
80
            </div>
81
        </div>
82
    [% END %]
83
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js (-13 / +2 lines)
Lines 99-117 $(document).ready(function(){ Link Here
99
        var borrowernumber = $(this).data("borrowernumber");
99
        var borrowernumber = $(this).data("borrowernumber");
100
        var cardnumber = $(this).data("cardnumber");
100
        var cardnumber = $(this).data("cardnumber");
101
        var modalTitle = $(this).attr("title");
101
        var modalTitle = $(this).attr("title");
102
        $.ajax({
102
        $("#patronImageEdit .modal-title").text(modalTitle);
103
            url: "/cgi-bin/koha/members/moremember-patronimage.pl",
103
        $("#patronImageEdit").modal("show");
104
            type: "GET",
105
            data: { borrowernumber: borrowernumber, cardnumber: cardnumber },
106
            success: function ( data ) {
107
                $("#patronImageEdit .modal-body").html( data );
108
                $("#patronImageEdit .modal-title").text(modalTitle);
109
                $("#patronImageEdit").modal("show");
110
            },
111
            error: function () {
112
                location.href="/cgi-bin/koha/members/moremember-patronimage.pl?borrowernumber=" + borrowernumber;
113
            }
114
        });
115
        $("#patronImageEdit").on("hidden.bs.modal", function(){
104
        $("#patronImageEdit").on("hidden.bs.modal", function(){
116
            /* Stop using the user's camera when modal is closed */
105
            /* Stop using the user's camera when modal is closed */
117
            let viewfinder = document.getElementById("viewfinder");
106
            let viewfinder = document.getElementById("viewfinder");
(-)a/members/moremember-patronimage.pl (-60 lines)
Lines 1-59 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2020 Mark Tompsett
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use CGI qw ( -utf8 );
22
use C4::Auth qw( get_template_and_user );
23
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
24
use Koha::Patrons;
25
use Koha::Token;
26
27
my $input = CGI->new;
28
29
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
30
    {
31
        template_name   => 'members/moremember-patronimage.tt',
32
        query           => $input,
33
        type            => 'intranet',
34
        flagsrequired   => { borrowers => 'edit_borrowers' },
35
    }
36
);
37
38
my $borrowernumber = $input->param('borrowernumber');
39
my $cardnumber     = $input->param('cardnumber');
40
my $patron         = Koha::Patrons->find($borrowernumber);
41
my $logged_in_user = Koha::Patrons->find($loggedinuser);
42
43
$template->param(
44
    csrf_token => Koha::Token->new->generate_csrf(
45
        { session_id => $input->cookie('CGISESSID'), }
46
    ),
47
    patron         => $patron,
48
    logged_in_user => $logged_in_user,
49
);
50
51
output_html_with_http_headers $input, $cookie, $template->output;
52
53
__END__
54
55
=head1 moremember-patronimage.pl
56
57
 script to provide modal window for patron images
58
59
=cut
60
- 

Return to bug 6815