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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc (-71 lines)
Lines 1-71 Link Here
1
2
<script>
3
    (function () {
4
        /**
5
         * Format the patron response from a Koha RESTful API request.
6
         * @param  {Object}  patron  The patron json object as returned from the Koha RESTful API
7
         * @param  {Object}  config  A configuration object
8
         *                           Valid keys are: `invert_name`, `display_cardnumber` and `url`
9
         * @return {string}          The formatted HTML string
10
         */
11
        window.$patron_to_html = function (patron, config) {
12
            if (patron == null) {
13
                return ""; // empty string for no patron
14
            }
15
16
            var title = null;
17
            if (patron.title != null && patron.title != "") {
18
                title = '<span class="patron-title">' + escape_str(patron.title) + "</span>";
19
            }
20
21
            var name;
22
            var firstname = escape_str(patron.firstname);
23
            var preferred_name = escape_str(patron.preferred_name);
24
            var surname = escape_str(patron.surname);
25
26
            if (patron.middle_name != null && patron.middle_name != "") {
27
                firstname += " " + escape_str(patron.middle_name);
28
                preferred_name += " " + escape_str(patron.middle_name);
29
            }
30
31
            if (patron.other_name != null && patron.other_name != "") {
32
                firstname += " (" + escape_str(patron.other_name) + ")";
33
                preferred_name += " (" + escape_str(patron.other_name) + ")";
34
            }
35
            if (config && config.invert_name) {
36
                name = surname + (preferred_name ? ", " + preferred_name : "");
37
            } else {
38
                name = preferred_name + " " + surname;
39
            }
40
            if (name.replace(" ", "").length == 0) {
41
                if (patron.library) {
42
                    return _("A patron from %s").format(patron.library.name);
43
                } else {
44
                    return _("A patron from another library");
45
                }
46
            }
47
48
            if (config && config.hide_patron_name) {
49
                name = "";
50
            }
51
52
            if (config && config.display_cardnumber) {
53
                if (name.length > 0) {
54
                    name = name + " (" + escape_str(patron.cardnumber) + ")";
55
                } else {
56
                    name = escape_str(patron.cardnumber);
57
                }
58
            }
59
60
            if (config && config.url) {
61
                if (config.url === "circulation_reserves") {
62
                    name = '<a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=' + encodeURIComponent(patron.patron_id) + '#reserves">' + name + "</a>";
63
                } else {
64
                    name = '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=' + encodeURIComponent(patron.patron_id) + '">' + name + "</a>";
65
                }
66
            }
67
68
            return name;
69
        };
70
    })();
71
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc (+1 lines)
Lines 25-30 Link Here
25
[% Asset.js("lib/bootstrap/bootstrap.bundle.min.js") | $raw %]
25
[% Asset.js("lib/bootstrap/bootstrap.bundle.min.js") | $raw %]
26
[% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %]
26
[% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %]
27
<!-- koha core js -->
27
<!-- koha core js -->
28
[% Asset.js("js/patron-format.js") | $raw %]
28
[% Asset.js("js/staff-global.js") | $raw %]
29
[% Asset.js("js/staff-global.js") | $raw %]
29
[% Asset.js("js/form-submit.js",{'type' => 'module'}) | $raw %]
30
[% Asset.js("js/form-submit.js",{'type' => 'module'}) | $raw %]
30
[% INCLUDE 'js-date-format.inc' %]
31
[% INCLUDE 'js-date-format.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-1 lines)
Lines 304-310 Link Here
304
    </script>
304
    </script>
305
    [% INCLUDE 'datatables.inc' %]
305
    [% INCLUDE 'datatables.inc' %]
306
    [% INCLUDE 'js-patron-get-age.inc' %]
306
    [% INCLUDE 'js-patron-get-age.inc' %]
307
    [% INCLUDE 'js-patron-format.inc' %]
308
    [% INCLUDE 'js-patron-format-address.inc' %]
307
    [% INCLUDE 'js-patron-format-address.inc' %]
309
    <script>
308
    <script>
310
        {
309
        {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendors.tt (-1 lines)
Lines 26-32 Link Here
26
[% MACRO jsinclude BLOCK %]
26
[% MACRO jsinclude BLOCK %]
27
    [% INCLUDE 'calendar.inc' %]
27
    [% INCLUDE 'calendar.inc' %]
28
    [% INCLUDE 'datatables.inc' %]
28
    [% INCLUDE 'datatables.inc' %]
29
    [% INCLUDE 'js-patron-format.inc' %]
30
    [% INCLUDE 'js-date-format.inc' %]
29
    [% INCLUDE 'js-date-format.inc' %]
31
    [% INCLUDE 'format_price.inc' %]
30
    [% INCLUDE 'format_price.inc' %]
32
    <script>
31
    <script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-1 lines)
Lines 528-534 Link Here
528
[% MACRO jsinclude BLOCK %]
528
[% MACRO jsinclude BLOCK %]
529
    [% Asset.js("js/acq.js") | $raw %]
529
    [% Asset.js("js/acq.js") | $raw %]
530
    [% IF op == 'add_form' %]
530
    [% IF op == 'add_form' %]
531
        [% INCLUDE 'js-patron-format.inc' %]
532
        <script>
531
        <script>
533
            //<![CDATA[
532
            //<![CDATA[
534
533
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/record_sources.tt (-1 lines)
Lines 27-33 Link Here
27
    [% INCLUDE 'calendar.inc' %]
27
    [% INCLUDE 'calendar.inc' %]
28
    <!-- FIXME: this shouldn't be needed -->
28
    <!-- FIXME: this shouldn't be needed -->
29
    [% INCLUDE 'datatables.inc' %]
29
    [% INCLUDE 'datatables.inc' %]
30
    [% INCLUDE 'js-patron-format.inc' %]
31
    [% INCLUDE 'js-date-format.inc' %]
30
    [% INCLUDE 'js-date-format.inc' %]
32
31
33
    [% Asset.js("js/vue/dist/admin/record_sources.js") | $raw %]
32
    [% Asset.js("js/vue/dist/admin/record_sources.js") | $raw %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt (-1 lines)
Lines 53-59 Link Here
53
    [% INCLUDE 'datatables.inc' %]
53
    [% INCLUDE 'datatables.inc' %]
54
    [% INCLUDE 'calendar.inc' %]
54
    [% INCLUDE 'calendar.inc' %]
55
    [% INCLUDE 'select2.inc' %]
55
    [% INCLUDE 'select2.inc' %]
56
    [% INCLUDE 'js-patron-format.inc' %]
57
    [% INCLUDE 'js-date-format.inc' %]
56
    [% INCLUDE 'js-date-format.inc' %]
58
    [% Asset.js("lib/dayjs/plugin/isSameOrAfter.js") | $raw %]
57
    [% Asset.js("lib/dayjs/plugin/isSameOrAfter.js") | $raw %]
59
    [% Asset.js("lib/dayjs/plugin/isSameOrBefore.js") | $raw %]
58
    [% Asset.js("lib/dayjs/plugin/isSameOrBefore.js") | $raw %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 lines)
Lines 1718-1724 Link Here
1718
    <script>
1718
    <script>
1719
        dayjs.extend(window.dayjs_plugin_isSameOrBefore);
1719
        dayjs.extend(window.dayjs_plugin_isSameOrBefore);
1720
    </script>
1720
    </script>
1721
    [% INCLUDE 'js-patron-format.inc' %]
1722
    [% INCLUDE 'js-biblio-format.inc' %]
1721
    [% INCLUDE 'js-biblio-format.inc' %]
1723
    [% Asset.js("js/browser.js") | $raw %]
1722
    [% Asset.js("js/browser.js") | $raw %]
1724
1723
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-1 lines)
Lines 585-591 Link Here
585
    <script>
585
    <script>
586
        dayjs.extend(window.dayjs_plugin_isSameOrBefore);
586
        dayjs.extend(window.dayjs_plugin_isSameOrBefore);
587
    </script>
587
    </script>
588
    [% INCLUDE 'js-patron-format.inc' %]
589
    [% Asset.js("js/catalog.js") | $raw %]
588
    [% Asset.js("js/catalog.js") | $raw %]
590
    [% Asset.js("js/browser.js") | $raw %]
589
    [% Asset.js("js/browser.js") | $raw %]
591
    [% Asset.js("js/checkout_renewals_modal.js") | $raw %]
590
    [% Asset.js("js/checkout_renewals_modal.js") | $raw %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt (-1 lines)
Lines 62-68 Link Here
62
[% MACRO jsinclude BLOCK %]
62
[% MACRO jsinclude BLOCK %]
63
    [% INCLUDE 'datatables.inc' %]
63
    [% INCLUDE 'datatables.inc' %]
64
    [% INCLUDE 'js-date-format.inc' %]
64
    [% INCLUDE 'js-date-format.inc' %]
65
    [% INCLUDE 'js-patron-format.inc' %]
66
    [% INCLUDE 'js-biblio-format.inc' %]
65
    [% INCLUDE 'js-biblio-format.inc' %]
67
    <script>
66
    <script>
68
        $(document).ready(function() {
67
        $(document).ready(function() {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt (-1 lines)
Lines 468-474 Link Here
468
        dayjs.extend(window.dayjs_plugin_customParseFormat);
468
        dayjs.extend(window.dayjs_plugin_customParseFormat);
469
    </script>
469
    </script>
470
    [% INCLUDE 'calendar.inc' %]
470
    [% INCLUDE 'calendar.inc' %]
471
    [% INCLUDE 'js-patron-format.inc' %]
472
    [% INCLUDE 'datatables.inc' %]
471
    [% INCLUDE 'datatables.inc' %]
473
    <script>
472
    <script>
474
        let pickups = [% To.json(curbside_pickups.unblessed) | $raw %];
473
        let pickups = [% To.json(curbside_pickups.unblessed) | $raw %];
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingbookings.tt (-1 lines)
Lines 115-121 Link Here
115
    [% INCLUDE 'datatables.inc' %]
115
    [% INCLUDE 'datatables.inc' %]
116
    [% INCLUDE 'js-biblio-format.inc' %]
116
    [% INCLUDE 'js-biblio-format.inc' %]
117
    [% INCLUDE 'js-date-format.inc' %]
117
    [% INCLUDE 'js-date-format.inc' %]
118
    [% INCLUDE 'js-patron-format.inc' %]
119
    <script>
118
    <script>
120
        let table_settings = [% TablesSettings.GetTableSettings( 'circ', 'bookings', 'bookings-to-collect', 'json' ) | $raw %];
119
        let table_settings = [% TablesSettings.GetTableSettings( 'circ', 'bookings', 'bookings-to-collect', 'json' ) | $raw %];
121
        $(document).ready(function() {
120
        $(document).ready(function() {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt (-1 lines)
Lines 26-32 Link Here
26
[% MACRO jsinclude BLOCK %]
26
[% MACRO jsinclude BLOCK %]
27
    [% INCLUDE 'calendar.inc' %]
27
    [% INCLUDE 'calendar.inc' %]
28
    [% INCLUDE 'datatables.inc' %]
28
    [% INCLUDE 'datatables.inc' %]
29
    [% INCLUDE 'js-patron-format.inc' %]
30
    [% INCLUDE 'js-date-format.inc' %]
29
    [% INCLUDE 'js-date-format.inc' %]
31
    <script>
30
    <script>
32
        const agreement_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'agreements', 'agreements', 'json' ) | $raw %];
31
        const agreement_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'agreements', 'agreements', 'json' ) | $raw %];
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt (-1 lines)
Lines 1114-1120 Link Here
1114
[% MACRO jsinclude BLOCK %]
1114
[% MACRO jsinclude BLOCK %]
1115
    [% INCLUDE 'datatables.inc' %]
1115
    [% INCLUDE 'datatables.inc' %]
1116
    [% INCLUDE 'js-biblio-format.inc' %]
1116
    [% INCLUDE 'js-biblio-format.inc' %]
1117
    [% INCLUDE 'js-patron-format.inc' %]
1118
    [% INCLUDE 'calendar.inc' %]
1117
    [% INCLUDE 'calendar.inc' %]
1119
    [% INCLUDE 'select2.inc' %]
1118
    [% INCLUDE 'select2.inc' %]
1120
    [% IF metadata_enrichment_services %]
1119
    [% IF metadata_enrichment_services %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/ill-requests.tt (-1 lines)
Lines 50-56 Link Here
50
    [% Asset.js("js/members-menu.js") | $raw %]
50
    [% Asset.js("js/members-menu.js") | $raw %]
51
    [% INCLUDE 'datatables.inc' %]
51
    [% INCLUDE 'datatables.inc' %]
52
    [% INCLUDE 'js-biblio-format.inc' %]
52
    [% INCLUDE 'js-biblio-format.inc' %]
53
    [% INCLUDE 'js-patron-format.inc' %]
54
    [% INCLUDE 'calendar.inc' %]
53
    [% INCLUDE 'calendar.inc' %]
55
    <script>
54
    <script>
56
        var prefilters = '[% prefilters | html %]';
55
        var prefilters = '[% prefilters | html %]';
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt (-1 lines)
Lines 162-168 Link Here
162
    [% INCLUDE 'datatables.inc' %]
162
    [% INCLUDE 'datatables.inc' %]
163
    [% INCLUDE 'modals/checkout_renewals.inc' %]
163
    [% INCLUDE 'modals/checkout_renewals.inc' %]
164
    [% INCLUDE 'js-date-format.inc' %]
164
    [% INCLUDE 'js-date-format.inc' %]
165
    [% INCLUDE 'js-patron-format.inc' %]
166
    [% Asset.js("js/checkout_renewals_modal.js") | $raw %]
165
    [% Asset.js("js/checkout_renewals_modal.js") | $raw %]
167
    <script id="js">
166
    <script id="js">
168
        $(document).ready(function() {
167
        $(document).ready(function() {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/preservation/home.tt (-1 lines)
Lines 22-28 Link Here
22
[% MACRO jsinclude BLOCK %]
22
[% MACRO jsinclude BLOCK %]
23
    [% INCLUDE 'calendar.inc' %]
23
    [% INCLUDE 'calendar.inc' %]
24
    [% INCLUDE 'datatables.inc' %]
24
    [% INCLUDE 'datatables.inc' %]
25
    [% INCLUDE 'js-patron-format.inc' %]
26
    [% INCLUDE 'js-date-format.inc' %]
25
    [% INCLUDE 'js-date-format.inc' %]
27
    [% INCLUDE 'js-biblio-format.inc' %]
26
    [% INCLUDE 'js-biblio-format.inc' %]
28
    <script>
27
    <script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt (-1 lines)
Lines 254-260 Link Here
254
        [% INCLUDE 'datatables.inc' %]
254
        [% INCLUDE 'datatables.inc' %]
255
        [% INCLUDE 'select2.inc' %]
255
        [% INCLUDE 'select2.inc' %]
256
        [% INCLUDE 'js-biblio-format.inc' %]
256
        [% INCLUDE 'js-biblio-format.inc' %]
257
        [% INCLUDE 'js-patron-format.inc' %]
258
        [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
257
        [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
259
        <script>
258
        <script>
260
            let hide_patron_name = [% IF Koha.Preference('HidePatronName') %]true[% ELSE %]false[% END %];
259
            let hide_patron_name = [% IF Koha.Preference('HidePatronName') %]true[% ELSE %]false[% END %];
(-)a/koha-tmpl/intranet-tmpl/prog/js/patron-format.js (-1 / +81 lines)
Line 0 Link Here
0
- 
1
(function () {
2
    /**
3
     * Format the patron response from a Koha RESTful API request.
4
     * @param  {Object}  patron  The patron json object as returned from the Koha RESTful API
5
     * @param  {Object}  config  A configuration object
6
     *                           Valid keys are: `invert_name`, `display_cardnumber` and `url`
7
     * @return {string}          The formatted HTML string
8
     */
9
    window.$patron_to_html = function (patron, config) {
10
        if (patron == null) {
11
            return ""; // empty string for no patron
12
        }
13
14
        var title = null;
15
        if (patron.title != null && patron.title != "") {
16
            title =
17
                '<span class="patron-title">' +
18
                escape_str(patron.title) +
19
                "</span>";
20
        }
21
22
        var name;
23
        var firstname = escape_str(patron.firstname);
24
        var preferred_name = escape_str(patron.preferred_name);
25
        var surname = escape_str(patron.surname);
26
27
        if (patron.middle_name != null && patron.middle_name != "") {
28
            firstname += " " + escape_str(patron.middle_name);
29
            preferred_name += " " + escape_str(patron.middle_name);
30
        }
31
32
        if (patron.other_name != null && patron.other_name != "") {
33
            firstname += " (" + escape_str(patron.other_name) + ")";
34
            preferred_name += " (" + escape_str(patron.other_name) + ")";
35
        }
36
        if (config && config.invert_name) {
37
            name = surname + (preferred_name ? ", " + preferred_name : "");
38
        } else {
39
            name = preferred_name + " " + surname;
40
        }
41
        if (name.replace(" ", "").length == 0) {
42
            if (patron.library) {
43
                return _("A patron from %s").format(patron.library.name);
44
            } else {
45
                return _("A patron from another library");
46
            }
47
        }
48
49
        if (config && config.hide_patron_name) {
50
            name = "";
51
        }
52
53
        if (config && config.display_cardnumber) {
54
            if (name.length > 0) {
55
                name = name + " (" + escape_str(patron.cardnumber) + ")";
56
            } else {
57
                name = escape_str(patron.cardnumber);
58
            }
59
        }
60
61
        if (config && config.url) {
62
            if (config.url === "circulation_reserves") {
63
                name =
64
                    '<a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=' +
65
                    encodeURIComponent(patron.patron_id) +
66
                    '#reserves">' +
67
                    name +
68
                    "</a>";
69
            } else {
70
                name =
71
                    '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=' +
72
                    encodeURIComponent(patron.patron_id) +
73
                    '">' +
74
                    name +
75
                    "</a>";
76
            }
77
        }
78
79
        return name;
80
    };
81
})();

Return to bug 40958