Bug 19641: Move patron templates to the footer
authorOwen Leonard <oleonard@myacpl.org>
Thu, 16 Nov 2017 16:08:07 +0000 (16:08 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 15 Feb 2018 16:30:23 +0000 (13:30 -0300)
This patch modifies the staff client patron module templates so that
JavaScript is included in the footer instead of the header.

This patch touches a lot of files because the changes are all
interdependent, affecting a couple of module-wide include files.

To test, apply the patch and test the JavaScript-driven features of the
modified templates: All button controls, DataTables functionality, tabs,
etc.

Patrons -> Patrons home, patron search results
  -> Manage pending modification requests
  -> Patron detail page
    -> Edit patron
      -> Set guarantor
    -> Fines
       -> Account, Pay fines, Create manual invoice, Create manual
          credit
       -> Print receipts for different kinds of charges
    -> Routing lists
    -> Circulation history
    -> Holds history
    -> Notices
    -> Statistics
    -> Files
    -> Purchase suggestions
    -> Discharges
    -> Housebound
    -> Set permissions
    -> Change password
    -> Print summary, slips, and overdues
    -> Update child to adult patron type

Patron toolbar and patron search bar operations should work correctly on
all pages.

This patch also updates the template for searching the Norwegian
national patron database, but it has NOT been tested.

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Zoe Bennett <zoebennett1308@gmail.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
38 files changed:
koha-tmpl/intranet-tmpl/prog/en/includes/borrower_debarments.inc
koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc
koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc
koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt
koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/discharges.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/files.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/member-flags.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-print.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-receipt.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/nl-search.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/routing-lists.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/statistics.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/update-child.tt
koha-tmpl/intranet-tmpl/prog/js/members-menu.js [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/js/messaging-preference-form.js [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js

index 99fba0f..e8e22e8 100644 (file)
@@ -1,31 +1,3 @@
-<script type="text/javascript">
-   //<![CDATA[
-        $(document).ready(function(e){
-            $("div#reldebarments .remove_restriction").on("click",function(){
-                return confirm(_("Remove restriction?"));
-            });
-            var mrform = $("#manual_restriction_form");
-            var mrlink = $("#add_manual_restriction");
-            mrform.hide();
-            mrlink.on("click",function(e){
-                $(this).hide();
-                mrform.show();
-                e.preventDefault();
-            });
-            $("#cancel_manual_restriction").on("click",function(e){
-                mrlink.show();
-                mrform.hide();
-                e.preventDefault();
-            });
-            $(".clear-date").on("click",function(e){
-                e.preventDefault();
-                var fieldID = this.id.replace("clear-date-","");
-                $("#" + fieldID).val("");
-            });
-        })
-    //]]>
-</script>
-
 <div id="reldebarments">
     [% IF ( not debarments.defined || debarments.size < 1 ) %]
         <p>Patron is currently unrestricted.</p>
index 231469b..4269613 100644 (file)
@@ -4,134 +4,6 @@
 [% USE Branches %]
 [% USE AuthorisedValues %]
 [% SET NorwegianPatronDBEnable = Koha.Preference( 'NorwegianPatronDBEnable' ) %]
-<script type="text/javascript">
-//<![CDATA[
-$(document).ready(function(){
-    [% IF CAN_user_borrowers_edit_borrowers %]
-        [% IF ( NorwegianPatronDBEnable == 1 ) %]
-            $("#deletepatronlocal").click(function(){
-                confirm_local_deletion();
-                $(".btn-group").removeClass("open");
-                return false;
-            });
-            $("#deletepatronremote").click(function(){
-                confirm_remote_deletion();
-                $(".btn-group").removeClass("open");
-                return false;
-            });
-            $("#deletepatronboth").click(function(){
-                confirm_both_deletion();
-                $(".btn-group").removeClass("open");
-                return false;
-            });
-        [% ELSE %]
-            $("#deletepatron").click(function(){
-                window.location='/cgi-bin/koha/members/deletemem.pl?member=[% borrowernumber | url%]';
-            });
-        [% END %]
-        $("#renewpatron").click(function(){
-            confirm_reregistration();
-            $(".btn-group").removeClass("open");
-            return false;
-        });
-        [% IF ( is_child ) %]$("#updatechild").click(function(){
-            update_child();
-            $(".btn-group").removeClass("open");
-        });[% END %]
-    [% END %]
-    $("#updatechild, #patronflags, #renewpatron, #deletepatron, #exportbarcodes").tooltip();
-    $("#exportcheckins").click(function(){
-        export_barcodes();
-        $(".btn-group").removeClass("open");
-        return false;
-    });
-    $("#printsummary").click(function(){
-        printx_window("page");
-        $(".btn-group").removeClass("open");
-        return false;
-    });
-    $("#printslip").click(function(){
-        printx_window("slip");
-        $(".btn-group").removeClass("open");
-        return false;
-    });
-    $("#printquickslip").click(function(){
-        printx_window("qslip");
-        $(".btn-group").removeClass("open");
-        return false;
-    });
-    $("#print_overdues").click(function(){
-        window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=[% borrowernumber %]", "printwindow");
-        $(".btn-group").removeClass("open");
-        return false;
-    });
-    $("#searchtohold").click(function(){
-        searchToHold();
-        return false;
-    });
-    $("#select_patron_messages").on("change",function(){
-        $("#borrower_message").val( $(this).val() );
-    });
-});
-function confirm_local_deletion() {
-    var is_confirmed = window.confirm(_("Are you sure you want to delete this patron from the local database? This cannot be undone."));
-    if (is_confirmed) {
-        window.location='/cgi-bin/koha/members/deletemem.pl?member=[% borrowernumber %]&deletelocal=true&deleteremote=false';
-    }
-}
-function confirm_remote_deletion() {
-    var is_confirmed = window.confirm(_("Are you sure you want to delete this patron from the Norwegian national patron database? This cannot be undone."));
-    if (is_confirmed) {
-        window.location='/cgi-bin/koha/members/deletemem.pl?member=[% borrowernumber %]&deletelocal=false&deleteremote=true';
-    }
-}
-function confirm_both_deletion() {
-    var is_confirmed = window.confirm(_("Are you sure you want to delete this patron both from the local database and from the Norwegian national patron database? This cannot be undone."));
-    if (is_confirmed) {
-        window.location='/cgi-bin/koha/members/deletemem.pl?member=[% borrowernumber %]&deletelocal=true&deleteremote=true';
-    }
-}
-
-[% IF ( is_child ) %]function confirm_updatechild() {
-    var is_confirmed = window.confirm(_("Are you sure you want to update this child to an Adult category?  This cannot be undone."));
-    if (is_confirmed) {
-        window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=[% borrowernumber %]&catcode=[% catcode %]&catcode_multi=[% CATCODE_MULTI %]';
-    }
-}
-
-function update_child() {
-    [% IF ( CATCODE_MULTI ) %]
-        window.open('/cgi-bin/koha/members/update-child.pl?op=multi&borrowernumber=[% borrowernumber %]','UpdateChild','width=400,height=300,toolbar=no,scrollbars=yes,resizable=yes');
-    [% ELSE %]
-        confirm_updatechild();
-    [% END %]
-}
-[% END %]
-
-function confirm_reregistration() {
-    var is_confirmed = window.confirm(_("Are you sure you want to renew this patron's registration?"));
-    if (is_confirmed) {
-    window.location = '/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&amp;destination=[% destination %]&amp;reregistration=y';
-    }
-}
-function export_barcodes() {
-    window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=[% borrowernumber %]&amp;op=export_barcodes');
-}
-var slip_re = /slip/;
-function printx_window(print_type) {
-    var handler = print_type.match(slip_re) ? "printslip" : "summary-print";
-    window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=[% borrowernumber %]&amp;print=" + print_type, "printwindow");
-    return false;
-}
-function searchToHold(){
-    var date = new Date();
-    date.setTime(date.getTime() + (10 * 60 * 1000));
-    $.cookie("holdfor", "[% borrowernumber %]", { path: "/", expires: date });
-    location.href="/cgi-bin/koha/catalogue/search.pl";
-}
-//]]>
-</script>
-
 <div id="toolbar" class="btn-toolbar">
     [% IF CAN_user_borrowers_edit_borrowers %]
         [% IF ( guarantor ) %]
index 70761a0..1f2ac94 100644 (file)
@@ -1,28 +1,5 @@
 [% USE Koha %]
 <!-- snippet for form to set borrower and patron category messaging preferences -->
-<script type="text/javascript">//<![CDATA[
-$(document).ready(function(){
-    $(".none").click(function(){
-        if($(this).prop("checked")){
-            var rowid = $(this).attr("id");
-            newid = Number(rowid.replace("none",""));
-            $("#sms"+newid).prop("checked", false);
-            $("#email"+newid).prop("checked", false);
-            $("#phone"+newid).prop("checked", false);
-            $("#digest"+newid).prop("checked", false);
-            $("#rss"+newid).prop("checked", false);
-        }
-    });
-    $(".active_notify").on("change",function(){
-        var attr_id = $(this).data("attr-id");
-        if( $(this).prop("checked") ){
-            $("#none" + attr_id ).prop("checked", false);
-        }
-    });
-    $("#info_digests").tooltip();
-});
-//]]>
-</script>
 
 <input type="hidden" name="modify" value="yes" />
 <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
@@ -32,7 +9,7 @@ $(document).ready(function(){
         [% IF Koha.Preference('SMSSendDriver') %]<th>SMS</th>[% END %]
         [% IF Koha.Preference('TalkingTechItivaPhoneNotification') %]<th>Phone</th>[% END %]
         <th>Email</th>
-        <th>Digests only <i id="info_digests" data-toggle="tooltip" title="You can ask for a digest to reduce the number of messages. Messages will be saved and sent as a single message." data-placement="right" class="icon fa fa-info-sign"></i></th>
+        <th>Digests only <i id="info_digests" data-toggle="tooltip" title="You can ask for a digest to reduce the number of messages. Messages will be saved and sent as a single message." data-placement="right" class="fa fa-info-circle"></i></th>
         <!-- <th>RSS</th> -->
         [% UNLESS ( messaging_form_inactive ) %]<th>Do not notify</th>[% END %]
     </tr>
index 4fbb927..f8c7ec9 100644 (file)
     </ul>
 </div><!-- /header_search -->
 </div><!-- /gradient -->
-<script type="text/javascript">//<![CDATA[
-$(document).ready(function() {
-    $("#filteraction_off, #filteraction_on").on('click', function(e) {
-        e.preventDefault();
-        $('#filters').toggle();
-        $('.filteraction').toggle();
-    });
-    [% IF ( advsearch ) %]
-        $("#filteraction_on").toggle();
-        $("#filters").show();
-    [% ELSE %]
-        $("#filteraction_off").toggle();
-    [% END %]
-    [% SET dateformat = Koha.Preference('dateformat') %]
-    $("#searchfieldstype").change(function() {
-      if ( $(this).val() == 'dateofbirth' ) {
-          [% IF dateformat == 'us' %]
-              var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'MM/DD/YYYY'");
-          [% ELSIF dateformat == 'iso' %]
-              var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'YYYY-MM-DD'");
-          [% ELSIF dateformat == 'metric' %]
-              var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD/MM/YYYY'");
-          [% ELSIF dateformat == 'dmydot' %]
-              var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD.MM.YYYY'");
-          [% END %]
-          $('#searchmember').attr("title",MSG_DATE_FORMAT).tooltip('show');
-      } else {
-          $('#searchmember').tooltip('destroy');
-      }
-    });
-});
-//]]>
-</script>
 <!-- End Patrons Resident Search Box -->
+
+<script type="text/javascript">
+    var advsearch = "[% advsearch %]";
+    var destination = "[% destination %]";
+    var catcode = "[% catcode %]";
+    var dateformat = "[% Koha.Preference('dateformat') %]";
+    var CAN_user_borrowers_edit_borrowers = "[% CAN_user_borrowers_edit_borrowers %]";
+    var NorwegianPatronDBEnable = "[% NorwegianPatronDBEnable %]";
+    var CATCODE_MULTI = "[% CATCODE_MULTI %]";
+    var borrowernumber = "[% borrowernumber %]";
+</script>
index d8c393f..4ad11ea 100644 (file)
 
 [% MACRO jsinclude BLOCK %]
     <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/messaging-preference-form_[% KOHA_VERSION %].js"></script>
     [% INCLUDE 'calendar.inc' %]
     [% INCLUDE 'datatables.inc' %]
     <script type="text/javascript">
index 341d32b..e2345ce 100644 (file)
 [% USE Koha %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patron search</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
-[% INCLUDE 'datatables.inc' %]
-
-<script type="text/javascript">
-//<![CDATA[
-
-var search = 1;
-$(document).ready(function(){
-    $("#info").hide();
-    $("#error").hide();
-
-    [% IF view != "show_results" %]
-        $("#searchresults").hide();
-        search = 0;
-    [% END %]
-
-    // Apply DataTables on the results table
-    dtMemberResults = $("#memberresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
-        'bServerSide': true,
-        'sAjaxSource': "/cgi-bin/koha/svc/members/search",
-        'fnServerData': function(sSource, aoData, fnCallback) {
-            if ( ! search ) {
-                return;
-            }
-            aoData.push({
-                'name': 'searchmember',
-                'value': $("#searchmember_filter").val()
-            },{
-                'name': 'firstletter',
-                'value': $("#firstletter_filter").val()
-            },{
-                'name': 'categorycode',
-                'value': $("#categorycode_filter").val()
-            },{
-                'name': 'branchcode',
-                'value': $("#branchcode_filter").val()
-            },{
-                'name': 'name_sorton',
-                'value': 'borrowers.surname borrowers.firstname'
-            },{
-                'name': 'category_sorton',
-                'value': 'categories.description',
-            },{
-                'name': 'branch_sorton',
-                'value': 'branches.branchname'
-            },{
-                'name': 'template_path',
-                'value': '[% json_template %]',
-            },{
-                'name': 'selection_type',
-                'value': '[% selection_type %]',
-            }
-            [% IF patrons_with_acq_perm_only %]
-            ,{
-                'name': 'has_permission',
-                'value': 'acquisition.order_manage',
-            }
-            [% END %]
-            );
-            $.ajax({
-                'dataType': 'json',
-                'type': 'POST',
-                'url': sSource,
-                'data': aoData,
-                'success': function(json){
-                    fnCallback(json);
-                }
-            });
-        },
-        'aoColumns':[
-            [% FOR column IN columns %]
-                [% IF column == 'action' %]
-                    { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
-                [% ELSIF column == 'address' %]
-                    { 'mDataProp': 'dt_address', 'bSortable': false }
-                [% ELSE %]
-                    { 'mDataProp': 'dt_[% column %]' }
-                [% END %]
-                [% UNLESS loop.last %],[% END %]
-            [% END %]
-        ],
-        'bAutoWidth': false,
-        [% IF patrons_with_acq_perm_only %]
-            'bPaginate': false,
-        [% ELSE %]
-            'sPaginationType': 'full_numbers',
-            "iDisplayLength": [% Koha.Preference('PatronsPerPage') %],
-        [% END %]
-        'aaSorting': [[[% aaSorting || 0 %], 'asc']],
-        'bFilter': false,
-        'bProcessing': true,
-    }));
-
-    $("#searchform").on('submit', filter);
-    $(".filterByLetter").on("click",function(e){
-        e.preventDefault();
-        filterByFirstLetterSurname($(this).text());
-    });
-    $("body").on("click",".add_user",function(e){
-        e.preventDefault();
-        var borrowernumber = $(this).data("borrowernumber");
-        var firstname = $(this).data("firstname");
-        var surname = $(this).data("surname");
-        add_user( borrowernumber, firstname + " " + surname );
-    });
-
-    $("body").on("click",".select_user",function(e){
-        e.preventDefault();
-        var borrowernumber = $(this).data("borrowernumber");
-        var borrower_data = $("#borrower_data"+borrowernumber).val();
-        select_user( borrowernumber, JSON.parse(borrower_data) );
-    });
-
-});
-
-function filter() {
-    search = 1;
-    $("#firstletter_filter").val('');
-    $("#searchresults").show();
-    dtMemberResults.fnDraw();
-    return false;
-}
-
-// User has clicked on a letter
-function filterByFirstLetterSurname(letter) {
-    $("#firstletter_filter").val(letter);
-    search = 1;
-    $("#searchresults").show();
-    dtMemberResults.fnDraw();
-}
-
-
-    // modify parent window owner element
-    [% IF selection_type == 'add' %]
-        function add_user(borrowernumber, borrowername) {
-            var p = window.opener;
-            // In one place (serials/routing.tt), the page is reload on every add
-            // We have to wait for the page to be there
-            function wait_for_opener () {
-                if ( ! $(opener.document).find('body').size() ) {
-                    setTimeout(wait_for_opener, 500);
-                } else {
-                    [%# Note that add_user could sent data instead of borrowername too %]
-                    $("#info").hide();
-                    $("#error").hide();
-                    if ( p.add_user(borrowernumber, borrowername) < 0 ) {
-                        $("#error").html(_("Patron '%s' is already in the list.").format(borrowername));
-                        $("#error").show();
-                    } else {
-                        $("#info").html(_("Patron '%s' added.").format(borrowername));
-                        $("#info").show();
-                    }
-                }
-            }
-            wait_for_opener();
-        }
-    [% ELSIF selection_type == 'select' %]
-        function select_user(borrowernumber, data) {
-            var p = window.opener;
-            p.select_user(borrowernumber, data);
-            window.close();
-        }
-    [% END %]
-//]]>
-</script>
-
 </head>
+
 <body id="common_patron_search" class="common">
 <div id="patron_search" class="yui-t7">
   <div id="bd">
@@ -252,5 +89,169 @@ function filterByFirstLetterSurname(letter) {
 <div id="closewindow"><a href="#" class="btn btn-default btn-default close">Close</a></div>
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+
+    <script type="text/javascript">
+        var search = 1;
+        $(document).ready(function(){
+            $("#info").hide();
+            $("#error").hide();
+
+            [% IF view != "show_results" %]
+                $("#searchresults").hide();
+                search = 0;
+            [% END %]
+
+            // Apply DataTables on the results table
+            dtMemberResults = $("#memberresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
+                'bServerSide': true,
+                'sAjaxSource': "/cgi-bin/koha/svc/members/search",
+                'fnServerData': function(sSource, aoData, fnCallback) {
+                    if ( ! search ) {
+                        return;
+                    }
+                    aoData.push({
+                        'name': 'searchmember',
+                        'value': $("#searchmember_filter").val()
+                    },{
+                        'name': 'firstletter',
+                        'value': $("#firstletter_filter").val()
+                    },{
+                        'name': 'categorycode',
+                        'value': $("#categorycode_filter").val()
+                    },{
+                        'name': 'branchcode',
+                        'value': $("#branchcode_filter").val()
+                    },{
+                        'name': 'name_sorton',
+                        'value': 'borrowers.surname borrowers.firstname'
+                    },{
+                        'name': 'category_sorton',
+                        'value': 'categories.description',
+                    },{
+                        'name': 'branch_sorton',
+                        'value': 'branches.branchname'
+                    },{
+                        'name': 'template_path',
+                        'value': '[% json_template %]',
+                    },{
+                        'name': 'selection_type',
+                        'value': '[% selection_type %]',
+                    }
+                    [% IF patrons_with_acq_perm_only %]
+                    ,{
+                        'name': 'has_permission',
+                        'value': 'acquisition.order_manage',
+                    }
+                    [% END %]
+                    );
+                    $.ajax({
+                        'dataType': 'json',
+                        'type': 'POST',
+                        'url': sSource,
+                        'data': aoData,
+                        'success': function(json){
+                            fnCallback(json);
+                        }
+                    });
+                },
+                'aoColumns':[
+                    [% FOR column IN columns %]
+                        [% IF column == 'action' %]
+                            { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
+                        [% ELSIF column == 'address' %]
+                            { 'mDataProp': 'dt_address', 'bSortable': false }
+                        [% ELSE %]
+                            { 'mDataProp': 'dt_[% column %]' }
+                        [% END %]
+                        [% UNLESS loop.last %],[% END %]
+                    [% END %]
+                ],
+                'bAutoWidth': false,
+                [% IF patrons_with_acq_perm_only %]
+                    'bPaginate': false,
+                [% ELSE %]
+                    'sPaginationType': 'full_numbers',
+                    "iDisplayLength": [% Koha.Preference('PatronsPerPage') %],
+                [% END %]
+                'aaSorting': [[[% aaSorting || 0 %], 'asc']],
+                'bFilter': false,
+                'bProcessing': true,
+            }));
+
+            $("#searchform").on('submit', filter);
+            $(".filterByLetter").on("click",function(e){
+                e.preventDefault();
+                filterByFirstLetterSurname($(this).text());
+            });
+            $("body").on("click",".add_user",function(e){
+                e.preventDefault();
+                var borrowernumber = $(this).data("borrowernumber");
+                var firstname = $(this).data("firstname");
+                var surname = $(this).data("surname");
+                add_user( borrowernumber, firstname + " " + surname );
+            });
+
+            $("body").on("click",".select_user",function(e){
+                e.preventDefault();
+                var borrowernumber = $(this).data("borrowernumber");
+                var borrower_data = $("#borrower_data"+borrowernumber).val();
+                select_user( borrowernumber, JSON.parse(borrower_data) );
+            });
+
+        });
+
+        function filter() {
+            search = 1;
+            $("#firstletter_filter").val('');
+            $("#searchresults").show();
+            dtMemberResults.fnDraw();
+            return false;
+        }
+
+        // User has clicked on a letter
+        function filterByFirstLetterSurname(letter) {
+            $("#firstletter_filter").val(letter);
+            search = 1;
+            $("#searchresults").show();
+            dtMemberResults.fnDraw();
+        }
+
+        // modify parent window owner element
+        [% IF selection_type == 'add' %]
+            function add_user(borrowernumber, borrowername) {
+                var p = window.opener;
+                // In one place (serials/routing.tt), the page is reload on every add
+                // We have to wait for the page to be there
+                function wait_for_opener () {
+                    if ( ! $(opener.document).find('body').size() ) {
+                        setTimeout(wait_for_opener, 500);
+                    } else {
+                        [%# Note that add_user could sent data instead of borrowername too %]
+                        $("#info").hide();
+                        $("#error").hide();
+                        if ( p.add_user(borrowernumber, borrowername) < 0 ) {
+                            $("#error").html(_("Patron '%s' is already in the list.").format(borrowername));
+                            $("#error").show();
+                        } else {
+                            $("#info").html(_("Patron '%s' added.").format(borrowername));
+                            $("#info").show();
+                        }
+                    }
+                }
+                wait_for_opener();
+            }
+        [% ELSIF selection_type == 'select' %]
+            function select_user(borrowernumber, data) {
+                var p = window.opener;
+                p.select_user(borrowernumber, data);
+                window.close();
+            }
+        [% END %]
+    </script>
+[% END %]
+
 [% SET popup_window = 1 %]
 [% INCLUDE 'intranet-bottom.inc' %]
index 38873d0..aef11d3 100644 (file)
@@ -2,42 +2,13 @@
 [% USE KohaDates %]
 [% USE ColumnsSettings %]
 [% USE Price %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; Account for [% INCLUDE 'patron-title.inc' no_html = 1 %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
-[% INCLUDE 'datatables.inc' %]
-[% INCLUDE 'columns_settings.inc' %]
-<script type="text/javascript">
-$(document).ready(function() {
-    var txtActivefilter = _("Filter paid transactions");
-    var txtInactivefilter = _("Show all transactions");
-    var columns_settings = [% ColumnsSettings.GetColumns('members', 'fines', 'account-fines', 'json') %];
-    var table_account_fines = KohaTable("#table_account_fines", {
-        "sPaginationType": "four_button",
-        'aaSorting': [[0, 'desc']],
-        "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
-        "aoColumnDefs": [
-            { "sType": "title-string", "aTargets" : [ "title-string" ] },
-            { "bSortable": false, "bSearchable": false, "aTargets": [-1] }
-        ]
-    }, columns_settings);
-    $("#filter_c").html('<p><a href="#" id="filter_transacs"><i class="fa fa-filter"></i> '+txtActivefilter+'</a>');
-    $('#filter_transacs').click(function(e) {
-        e.preventDefault();
-        if ($(this).hasClass('filtered')) {
-            var filteredValue = '';
-            $(this).html('<i class="fa fa-filter"></i> '+txtActivefilter);
-        } else { //Not filtered. Let's do it!
-            var filteredValue = '^((?!0.00).*)$'; //Filter not matching 0.00 http://stackoverflow.com/a/406408
-            $(this).html('<i class="fa fa-filter"></i> '+txtInactivefilter);
-        }
-        table_account_fines.fnFilter(filteredValue, 4, true, false);
-        $(this).toggleClass('filtered');
-    });
-});
-</script>
 </head>
+
 <body id="pat_borraccount" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
@@ -45,7 +16,6 @@ $(document).ready(function() {
 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Account for [% INCLUDE 'patron-title.inc' %]</div>
 
 <div id="doc3" class="yui-t2">
-   
    <div id="bd">
        <div id="yui-main">
        <div class="yui-b">
@@ -121,7 +91,7 @@ $(document).ready(function() {
         [% IF ( reverse_col) %]
           [% IF ( account.payment ) %]
             <a href="boraccount.pl?action=reverse&amp;accountlines_id=[% account.accountlines_id %]&amp;borrowernumber=[% account.borrowernumber %]" class="btn btn-default btn-xs"><i class="fa fa-undo"></i> Reverse</a>
-          [% ELSE %]
+          [% ELSE %][% SET footerjs = 1 %]
             &nbsp;
           [% END %]
         [% END %]
@@ -150,4 +120,41 @@ $(document).ready(function() {
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    [% INCLUDE 'columns_settings.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript">
+        var dateformat = "[% Koha.Preference('dateformat') %]";
+        $(document).ready(function() {
+            var txtActivefilter = _("Filter paid transactions");
+            var txtInactivefilter = _("Show all transactions");
+            var columns_settings = [% ColumnsSettings.GetColumns('members', 'fines', 'account-fines', 'json') %];
+            var table_account_fines = KohaTable("#table_account_fines", {
+                "sPaginationType": "four_button",
+                'aaSorting': [[0, 'desc']],
+                "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
+                "aoColumnDefs": [
+                    { "sType": "title-string", "aTargets" : [ "title-string" ] },
+                    { "bSortable": false, "bSearchable": false, "aTargets": [-1] }
+                ]
+            }, columns_settings);
+            $("#filter_c").html('<p><a href="#" id="filter_transacs"><i class="fa fa-filter"></i> '+txtActivefilter+'</a>');
+            $('#filter_transacs').click(function(e) {
+                e.preventDefault();
+                if ($(this).hasClass('filtered')) {
+                    var filteredValue = '';
+                    $(this).html('<i class="fa fa-filter"></i> '+txtActivefilter);
+                } else { //Not filtered. Let's do it!
+                    var filteredValue = '^((?!0.00).*)$'; //Filter not matching 0.00 http://stackoverflow.com/a/406408
+                    $(this).html('<i class="fa fa-filter"></i> '+txtInactivefilter);
+                }
+                table_account_fines.fnFilter(filteredValue, 4, true, false);
+                $(this).toggleClass('filtered');
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 82ba917..52ed315 100644 (file)
@@ -1,3 +1,4 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Delete patron [% firstname %] [% surname %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -57,4 +58,9 @@
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 8e316cc..2ae59c3 100644 (file)
@@ -1,6 +1,7 @@
 [% USE KohaDates %]
 [% USE AuthorisedValues %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; [% UNLESS blocking_error  %]Discharge for [% firstname %] [% surname %] ([% cardnumber %])[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -70,4 +71,9 @@
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 91e9091..4e44d6a 100644 (file)
@@ -1,4 +1,5 @@
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; Pending discharge requests</title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -39,4 +40,9 @@
     [% END %]
   </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 5d3c20f..0d73773 100644 (file)
@@ -1,22 +1,11 @@
 [% USE KohaDates %]
 [% USE AuthorisedValues %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Files for [% INCLUDE 'patron-title.inc' no_html = 1 %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript">
-    $(document).ready(function(){
-        $(".confirmdelete").on("click", function(){
-            $(this).parents('tr').addClass("warn");
-            if(confirm(_("Are you sure you want to delete this file?"))){
-                return true;
-            } else {
-                $(this).parents('tr').removeClass("warn");
-                return false;
-            }
-        });
-});
-</script>
 </head>
+
 <body id="pat_files" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
             [% INCLUDE 'circ-menu.inc' %]
         </div>
     </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+    <script type="text/javascript">
+        $(document).ready(function(){
+            $(".confirmdelete").on("click", function(){
+                $(this).parents('tr').addClass("warn");
+                if(confirm(_("Are you sure you want to delete this file?"))){
+                    return true;
+                } else {
+                    $(this).parents('tr').removeClass("warn");
+                    return false;
+                }
+            });
+    });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index ffee159..b5a0728 100644 (file)
@@ -3,30 +3,13 @@
 [% USE AuthorisedValues %]
 [% USE Branches %]
 [% USE ColumnsSettings %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Holds history for [% INCLUDE 'patron-title.inc' no_html = 1 %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
-[% INCLUDE 'datatables.inc' %]
-[% INCLUDE 'columns_settings.inc' %]
-<script type="text/javascript" id="js">
-//<![CDATA[
-
- $(document).ready(function() {
-    var columns_settings = [% ColumnsSettings.GetColumns('members', 'holdshistory', 'holdshistory-table', 'json') %];
-    var table = KohaTable("#table_holdshistory", {
-        "sPaginationType": "four_button",
-        "aaSorting": [[4, 'desc']],
-        "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
-        "aoColumnDefs": [
-            { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
-            { "sType": "title-string", "aTargets" : [ "title-string" ] }
-        ]
-    }, columns_settings);
- });
-//]]>
-</script>
 </head>
+
 <body id="pat_holdshistory" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    [% INCLUDE 'columns_settings.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" id="js">
+        $(document).ready(function() {
+            var columns_settings = [% ColumnsSettings.GetColumns('members', 'holdshistory', 'holdshistory-table', 'json') %];
+            var table = KohaTable("#table_holdshistory", {
+                "sPaginationType": "four_button",
+                "aaSorting": [[4, 'desc']],
+                "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
+                "aoColumnDefs": [
+                    { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
+                    { "sType": "title-string", "aTargets" : [ "title-string" ] }
+                ]
+            }, columns_settings);
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 49e965f..71235a7 100644 (file)
@@ -1,20 +1,12 @@
 [% USE Koha %]
 [% USE KohaDates %]
 [% USE AuthorisedValues %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Housebound &rsaquo; Details for [% INCLUDE 'patron-title.inc' no_html = 1 %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% INCLUDE 'calendar.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-    $(document).ready(function() {
-        $("a.delete").click(function(){
-            return confirm(_("Are you sure you want to delete this delivery?"));
-        });
-    });
-//]]>
-</script>
 </head>
+
 <body id="housebound-home" class="housebound">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
     [% INCLUDE 'circ-menu.inc' %]
   </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'calendar.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("a.delete").click(function(){
+                return confirm(_("Are you sure you want to delete this delivery?"));
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 65a61a5..21d6c55 100644 (file)
@@ -1,16 +1,10 @@
 [% USE Koha %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; Create manual credit</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-$(document).ready(function(){
-        $('#mancredit').preventDoubleFormSubmit();
-        $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
-});
-//]]>
-</script>
 </head>
+
 <body id="pat_mancredit" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
@@ -61,4 +55,15 @@ $(document).ready(function(){
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+    <script type="text/javascript">
+        $(document).ready(function(){
+            $('#mancredit').preventDoubleFormSubmit();
+            $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 8fc1f68..cbcf298 100644 (file)
@@ -1,24 +1,10 @@
 [% USE Koha %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; Create manual invoice</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-    var type_fees = {'L':'','F':'','A':'','N':'','M':''};
-    [% FOREACH invoice_types_loo IN invoice_types_loop %]
-        type_fees['[% invoice_types_loo.authorised_value %]'] = "[% invoice_types_loo.lib %]";
-    [% END %]
-$(document).ready(function(){
-        $('#maninvoice').preventDoubleFormSubmit();
-        $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
-    $("#invoice_type").on("change",function(){
-        this.form.desc.value = this.options[this.selectedIndex].value;
-        this.form.amount.value = type_fees[this.options[this.selectedIndex].value];
-    });
-});
-//]]>
-</script>
 </head>
+
 <body id="pat_maninvoice" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
@@ -82,4 +68,23 @@ $(document).ready(function(){
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+    <script type="text/javascript">
+        var type_fees = {'L':'','F':'','A':'','N':'','M':''};
+        [% FOREACH invoice_types_loo IN invoice_types_loop %]
+            type_fees['[% invoice_types_loo.authorised_value %]'] = "[% invoice_types_loo.lib %]";
+        [% END %]
+        $(document).ready(function(){
+            $('#maninvoice').preventDoubleFormSubmit();
+            $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
+            $("#invoice_type").on("change",function(){
+                this.form.desc.value = this.options[this.selectedIndex].value;
+                this.form.amount.value = type_fees[this.options[this.selectedIndex].value];
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index dc88429..f63db22 100644 (file)
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% PROCESS 'permissions.inc' %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; Set permissions for [% surname %], [% firstname %]</title>
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/treeview/jquery.treeview_[% KOHA_VERSION %].css"/>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.treeview.pack_[% KOHA_VERSION %].js"></script>
-<!-- set up tree -->
-<script type="text/javascript">
-    $(document).ready(function() {
-        $("#permissionstree").treeview({animated: "fast", collapsed: true});
-
-        // Enforce Superlibrarian Privilege Mutual Exclusivity
-        if($('input[id="flag-0"]:checked').length){
-            if ($('input[name="flag"]:checked').length > 1){
-                alert(_("Inconsistency detected! The superlibrarian privilege is mutually exclusive of other privileges, as it includes them all. This patron's privileges will now be reset to include only superlibrarian."));
-            }
-
-            $('input[name="flag"]').each(function() {
-                if($(this).attr('id') != "flag-0"){
-                    $(this).prop('disabled', true);
-                    $(this).prop('checked', false);
-                }
-            });
-        }
-
-        $('input#flag-0').click(function() {
-            if($('input[id="flag-0"]:checked').length){
-                $('input[name="flag"]').each(function() {
-                    if($(this).attr('id') != "flag-0"){
-                        $(this).prop('disabled', true);
-                        $(this).prop('checked', false);
-                    }
-                });
-            }
-            else {
-                $('input[name="flag"]').each(function() {
-                    $(this).prop('disabled', false);
-                });
-            }
-        });
-
-        $(".flag").on("change",function(){
-            if( $(this).hasClass("parent") ){
-                toggleChildren(this);
-            } else {
-                toggleParent(this);
-            }
-        });
-
-    });
-
-    // manage checking/unchecking parent permissions
-    var originalChildStates = {}; /* keep track of subpermission checkbox values
-                                     so that user can recover from accidentally
-                                     toggling a parent/module permission */
-    function selectChildren(parentInput) {
-        var childListId = parentInput.id + '-children';
-        var list = document.getElementById(childListId);
-        var children = [];
-        if (list) {
-            var inputs = list.getElementsByTagName('input');
-            for (var i = 0; i < inputs.length; i++) {
-                if (inputs[i].type == 'checkbox') {
-                    children.push(inputs[i]);
-                }
-            }
-            
-        } 
-        return children;
-    }
-
-    function toggleChildren(parentInput) {
-        var children = selectChildren(parentInput);
-        if (children.length == 0) {
-            return;
-        }
-        var checked = parentInput.checked;
-        if (checked && parentInput.parentNode.className == 'expandable') {
-            /* expand the tree */
-            $(".hitarea", parentInput.parentNode).click();
-        }
-        for (var i = 0; i < children.length; i++) {
-            if (checked) {
-                originalChildStates[children[i].id] = children[i].checked;
-                children[i].checked = checked;
-            } else {
-                if (children[i].id in originalChildStates) {
-                    children[i].checked = originalChildStates[children[i].id];
-                } else {
-                    children[i].checked = checked;
-                }
-            }
-        }
-    }
-
-    function toggleParent(childInput) {
-        originalChildStates[childInput.id] = childInput.checked;
-        if (childInput.checked) {
-            return;
-        }
-        var parentId = childInput.parentNode.parentNode.id.replace(/-children$/, '');;
-        var parentInput = document.getElementById(parentId);
-        if (parentInput) {  
-            parentInput.checked = false;
-        }
-    }
-
-</script>
 </head>
+
 <body id="pat_member-flags" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.treeview.pack_[% KOHA_VERSION %].js"></script>
+    <!-- set up tree -->
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("#permissionstree").treeview({animated: "fast", collapsed: true});
+
+            // Enforce Superlibrarian Privilege Mutual Exclusivity
+            if($('input[id="flag-0"]:checked').length){
+                if ($('input[name="flag"]:checked').length > 1){
+                    alert(_("Inconsistency detected! The superlibrarian privilege is mutually exclusive of other privileges, as it includes them all. This patron's privileges will now be reset to include only superlibrarian."));
+                }
+
+                $('input[name="flag"]').each(function() {
+                    if($(this).attr('id') != "flag-0"){
+                        $(this).prop('disabled', true);
+                        $(this).prop('checked', false);
+                    }
+                });
+            }
+
+            $('input#flag-0').click(function() {
+                if($('input[id="flag-0"]:checked').length){
+                    $('input[name="flag"]').each(function() {
+                        if($(this).attr('id') != "flag-0"){
+                            $(this).prop('disabled', true);
+                            $(this).prop('checked', false);
+                        }
+                    });
+                }
+                else {
+                    $('input[name="flag"]').each(function() {
+                        $(this).prop('disabled', false);
+                    });
+                }
+            });
+
+            $(".flag").on("change",function(){
+                if( $(this).hasClass("parent") ){
+                    toggleChildren(this);
+                } else {
+                    toggleParent(this);
+                }
+            });
+
+        });
+
+        // manage checking/unchecking parent permissions
+        var originalChildStates = {}; /* keep track of subpermission checkbox values
+                                         so that user can recover from accidentally
+                                         toggling a parent/module permission */
+        function selectChildren(parentInput) {
+            var childListId = parentInput.id + '-children';
+            var list = document.getElementById(childListId);
+            var children = [];
+            if (list) {
+                var inputs = list.getElementsByTagName('input');
+                for (var i = 0; i < inputs.length; i++) {
+                    if (inputs[i].type == 'checkbox') {
+                        children.push(inputs[i]);
+                    }
+                }
+            }
+            return children;
+        }
+
+        function toggleChildren(parentInput) {
+            var children = selectChildren(parentInput);
+            if (children.length == 0) {
+                return;
+            }
+            var checked = parentInput.checked;
+            if (checked && parentInput.parentNode.className == 'expandable') {
+                /* expand the tree */
+                $(".hitarea", parentInput.parentNode).click();
+            }
+            for (var i = 0; i < children.length; i++) {
+                if (checked) {
+                    originalChildStates[children[i].id] = children[i].checked;
+                    children[i].checked = checked;
+                } else {
+                    if (children[i].id in originalChildStates) {
+                        children[i].checked = originalChildStates[children[i].id];
+                    } else {
+                        children[i].checked = checked;
+                    }
+                }
+            }
+        }
+
+        function toggleParent(childInput) {
+            originalChildStates[childInput.id] = childInput.checked;
+            if (childInput.checked) {
+                return;
+            }
+            var parentId = childInput.parentNode.parentNode.id.replace(/-children$/, '');;
+            var parentInput = document.getElementById(parentId);
+            if (parentInput) {
+                parentInput.checked = false;
+            }
+        }
+
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index a80d89c..aaa1110 100644 (file)
@@ -1,69 +1,11 @@
 [% USE Koha %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; [% IF ( newpassword ) %]Password updated [% ELSE %]Update password for [% surname %], [% firstname %][% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/JavaScript">
-//<![CDATA[
-
-    function generate_password() {
-        // Always generate a strong password
-        var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-        var length = [% Koha.Preference('minPasswordLength') %];
-        if ( length < 8 ) length = 8;
-        var password='';
-        for ( var i = 0 ; i < length ; i++){
-            password += chars.charAt(Math.floor(Math.random()*chars.length));
-        }
-        return password;
-    }
-    $(document).ready(function() {
-        $("body").on('click', "#fillrandom",function(e) {
-            e.preventDefault();
-            var password = '';
-            var pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{[% Koha.Preference('minPasswordLength') %],}/;
-            while ( ! pattern_regex.test( password ) ) {
-                password = generate_password();
-            }
-            $("#newpassword").val(password);
-            $("#newpassword").attr('type', 'text');
-            $("#newpassword2").val(password);
-            $("#newpassword2").attr('type', 'text');
-        });
-        $("div.hint").eq(0).after(" <div class=\"hint\"><a href=\"#\" id=\"fillrandom\">"+_("Click to fill with a randomly generated suggestion. ")+"<strong>"+_("Passwords will be displayed as text")+"</strong>.</a></div>");
-
-        $(document).ajaxStart(function () {
-            $("input[name^=newpassword]").hide();
-            $("label[for=newpassword2]").hide();
-            $(".hint:last").after($(".loading").show());
-        });
-        $(document).ajaxStop(function () {
-            $("input[name^=newpassword]").show();
-            $("label[for=newpassword2]").show();
-            $(".loading").hide();
-            $("label.error").hide();
-        });
-        [% IF NOMATCH %]
-            $("#newpassword").addClass('focus');
-        [% END %]
-
-        $("#changepasswordf").validate({
-            rules: {
-                newpassword: {
-                    required: true,
-                    password_strong: true,
-                    password_no_spaces: true
-                },
-                newpassword2: {
-                    required: true,
-                    password_match: true
-                }
-            }
-        });
-    });
-//]]>
-</script>
 </head>
+
 <body id="pat_member-password" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+    <script type="text/JavaScript">
+
+        function generate_password() {
+            // Always generate a strong password
+            var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+            var length = [% Koha.Preference('minPasswordLength') %];
+            if ( length < 8 ) length = 8;
+            var password='';
+            for ( var i = 0 ; i < length ; i++){
+                password += chars.charAt(Math.floor(Math.random()*chars.length));
+            }
+            return password;
+        }
+        $(document).ready(function() {
+            $("body").on('click', "#fillrandom",function(e) {
+                e.preventDefault();
+                var password = '';
+                var pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{[% Koha.Preference('minPasswordLength') %],}/;
+                while ( ! pattern_regex.test( password ) ) {
+                    password = generate_password();
+                }
+                $("#newpassword").val(password);
+                $("#newpassword").attr('type', 'text');
+                $("#newpassword2").val(password);
+                $("#newpassword2").attr('type', 'text');
+            });
+            $("div.hint").eq(0).after(" <div class=\"hint\"><a href=\"#\" id=\"fillrandom\">"+_("Click to fill with a randomly generated suggestion. ")+"<strong>"+_("Passwords will be displayed as text")+"</strong>.</a></div>");
+
+            $(document).ajaxStart(function () {
+                $("input[name^=newpassword]").hide();
+                $("label[for=newpassword2]").hide();
+                $(".hint:last").after($(".loading").show());
+            });
+            $(document).ajaxStop(function () {
+                $("input[name^=newpassword]").show();
+                $("label[for=newpassword2]").show();
+                $(".loading").hide();
+                $("label.error").hide();
+            });
+            [% IF NOMATCH %]
+                $("#newpassword").addClass('focus');
+            [% END %]
+
+            $("#changepasswordf").validate({
+                rules: {
+                    newpassword: {
+                        required: true,
+                        password_strong: true,
+                        password_no_spaces: true
+                    },
+                    newpassword2: {
+                        required: true,
+                        password_match: true
+                    }
+                }
+            });
+        });
+    </script>
+    [% PROCESS 'password_check.inc' %]
+    [% PROCESS 'add_password_check' new_password => 'newpassword' %]
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
-[% PROCESS 'password_check.inc' %]
-[% PROCESS 'add_password_check' new_password => 'newpassword' %]
index eb84757..efa97c1 100644 (file)
 [% USE ColumnsSettings %]
 [% USE Branches %]
 [% USE Categories %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
-[% INCLUDE 'datatables.inc' %]
-[% INCLUDE 'columns_settings.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-$(document).ready(function() {
-    $('#add_to_patron_list_submit').prop('disabled', true);
-    $('#new_patron_list').hide();
-
-    $('#add_to_patron_list').change(function() {
-        var value = $('#add_to_patron_list').val();
-        if ( value == 'new' ) {
-            $('#new_patron_list').val('')
-            $('#new_patron_list').show();
-            $('#new_patron_list').focus();
-        } else if ( value ) {
-            $('#new_patron_list').hide();
-            $('#add_to_patron_list_submit').prop('disabled', false);
-        } else {
-            $('#new_patron_list').hide();
-            $('#add_to_patron_list_submit').prop('disabled', true);
-        }
-    });
-
-    $('#new_patron_list').on('input', function() {
-        if ( $('#new_patron_list').val() ) {
-            $('#add_to_patron_list_submit').prop('disabled', false);
-        } else {
-            $('#add_to_patron_list_submit').prop('disabled', true);
-        }
-    });
-
-    $("#add_to_patron_list_submit").on('click', function(e){
-        if ( $('#add_to_patron_list').val() == 'new' ) {
-            if ( $('#new_patron_list').val() ) {
-                $("#add_to_patron_list option").each(function() {
-                    if ( $(this).text() == $('#new_patron_list').val() ) {
-                        alert( _("You already have a list with that name!") );
-                        return false;
-                    }
-                });
-            } else {
-                alert( _("You must give your new patron list a name!") );
-                return false;
-            }
-        }
-
-        if ( $("#memberresultst input:checkbox:checked").length == 0 ) {
-            alert( _("You have not selected any patrons to add to a list!") );
-            return false;
-        }
-
-        var borrowernumbers = [];
-        $("#memberresultst").find("input:checkbox:checked").each(function(){
-            borrowernumbers.push($(this).val());
-        });
-        var data = {
-            add_to_patron_list: $("#add_to_patron_list").val(),
-            new_patron_list: $("#new_patron_list").val(),
-            borrowernumbers: borrowernumbers
-        };
-        $.ajax({
-            data: data,
-            type: 'POST',
-            url: '/cgi-bin/koha/svc/members/add_to_list',
-            success: function(data) {
-                $("#patron_list_dialog").show();
-                $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
-                $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
-                $("#patron_list_dialog > a").html(data.patron_list.name);
-                if ( $('#add_to_patron_list').val() == 'new' ) {
-                    var new_patron_list_added = $("<option>", {
-                        value: data.patron_list.patron_list_id,
-                        text: data.patron_list.name
-                    });
-                    $("#add_to_patron_list optgroup").append(new_patron_list_added);
-                    $("#add_to_patron_list").val(data.patron_list.patron_list_id);
-                    $("#new_patron_list").val('');
-                    $('#add_to_patron_list').change();
-                }
-            },
-            error: function() {
-                alert("an error occurred");
-            }
-        });
-        return true;
-    });
-    $(".filterByLetter").on("click",function(e){
-        e.preventDefault();
-        filterByFirstLetterSurname($(this).text());
-    });
-    $("#select_all").on("click",function(e){
-        e.preventDefault();
-        $(".selection").prop("checked", true);
-    });
-    $("#clear_all").on("click",function(e){
-        e.preventDefault();
-        $(".selection").prop("checked", false);
-    });
-    $("#clear_search").on("click",function(e){
-        e.preventDefault();
-        clearFilters(true);
-    });
-    $("#searchform").on("submit", filter);
-});
-
-var dtMemberResults;
-var search = 1;
-$(document).ready(function() {
-    [% IF searchmember %]
-        $("#searchmember_filter").val("[% searchmember | html %]");
-    [% END %]
-    [% IF searchfieldstype %]
-        $("searchfieldstype_filter").val("[% searchfieldstype %]");
-    [% END %]
-    [% IF searchtype %]
-        $("#searchtype_filter").val("[% searchtype %]");
-    [% END %]
-    [% IF categorycode %]
-        $("#categorycode_filter").val("[% categorycode_filter %]");
-    [% END %]
-    [% IF branchcode %]
-        $("#branchcode_filter").val("[% branchcode_filter %]");
-    [% END %]
-
-    [% IF view != "show_results" %]
-        search = 0;
-    [% ELSE %]
-        $("#searchresults").show();
-    [% END %]
-
-    // Build the aLengthMenu
-    var aLengthMenu = [
-        [%PatronsPerPage %], 10, 20, 50, 100, -1
-    ];
-    jQuery.unique(aLengthMenu);
-    aLengthMenu.sort(function( a, b ){
-        // Put "All" at the end
-        if ( a == -1 ) {
-            return 1;
-        } else if ( b == -1 ) {
-            return -1;
-        }
-        return parseInt(a) < parseInt(b) ? -1 : 1;}
-    );
-    var aLengthMenuLabel = [];
-    $(aLengthMenu).each(function(){
-        if ( this == -1 ) {
-            // Label for -1 is "All"
-            aLengthMenuLabel.push("All");
-        } else {
-            aLengthMenuLabel.push(this);
-        }
-    });
-
-    // Apply DataTables on the results table
-    var columns_settings = [% ColumnsSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) %];
-    [% UNLESS CAN_user_tools_manage_patron_lists %]
-        [%# Remove the first column if we do not display the checkbox %]
-        columns_settings.splice(0, 1);
-    [% END %]
-    dtMemberResults = KohaTable("#memberresultst", {
-        'bServerSide': true,
-        'sAjaxSource': "/cgi-bin/koha/svc/members/search",
-        'fnServerData': function(sSource, aoData, fnCallback) {
-            if ( ! search ) {
-                return;
-            }
-            aoData.push({
-                'name': 'searchmember',
-                'value': $("#searchmember_filter").val()
-            },{
-                'name': 'firstletter',
-                'value': $("#firstletter_filter").val()
-            },{
-                'name': 'searchfieldstype',
-                'value': $("#searchfieldstype_filter").val()
-            },{
-                'name': 'searchtype',
-                'value': $("#searchtype_filter").val()
-            },{
-                'name': 'categorycode',
-                'value': $("#categorycode_filter").val()
-            },{
-                'name': 'branchcode',
-                'value': $("#branchcode_filter").val()
-            },{
-                'name': 'name_sorton',
-                'value': 'borrowers.surname borrowers.firstname'
-            },{
-                'name': 'dateofbirth',
-                'value': 'borrowers.dateofbirth',
-            },{
-                'name': 'category_sorton',
-                'value': 'categories.description',
-            },{
-                'name': 'branch_sorton',
-                'value': 'branches.branchname'
-            },{
-                'name': 'template_path',
-                'value': 'members/tables/members_results.tt',
-            });
-            $.ajax({
-                'dataType': 'json',
-                'type': 'POST',
-                'url': sSource,
-                'data': aoData,
-                'success': function(json){
-                    // redirect if there is only 1 result.
-                    if ( json.aaData.length == 1 ) {
-                        var borrowernumber = json.aaData[0].borrowernumber;
-                        document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
-                        return false;
-                    }
-                    fnCallback(json);
-                }
-            });
-        },
-        'aoColumns':[
-            [% IF CAN_user_tools_manage_patron_lists %]
-              { 'mDataProp': 'dt_borrowernumber', 'bSortable': false },
-            [% END %]
-            { 'mDataProp': 'dt_cardnumber' },
-            { 'mDataProp': 'dt_name' },
-            { 'mDataProp': 'dt_dateofbirth' },
-            { 'mDataProp': 'dt_category' },
-            { 'mDataProp': 'dt_branch' },
-            { 'mDataProp': 'dt_dateexpiry' },
-            { 'mDataProp': 'dt_od_checkouts', 'bSortable': false },
-            { 'mDataProp': 'dt_fines', 'bSortable': false },
-            { 'mDataProp': 'dt_borrowernotes' },
-            { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
-        ],
-        'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
-            /* Center text for 6th column */
-            $("td:eq(5)", nRow).css("text-align", "center");
-
-            return nRow;
-        },
-        'bFilter': false,
-        'bAutoWidth': false,
-        [% IF CAN_user_tools_manage_patron_lists %]
-            'aaSorting': [[2, 'asc']],
-        [% ELSE %]
-            'aaSorting': [[1, 'asc']],
-        [% END %]
-        "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
-        'sPaginationType': 'full_numbers',
-        "iDisplayLength": [% PatronsPerPage %],
-        "bProcessing": true,
-    }, columns_settings);
-    update_searched();
-});
-
-// Update the string "Results found ..."
-function update_searched(){
-    var searched = $("#searchfieldstype_filter").find("option:selected").text();
-    if ( $("#searchmember_filter").val() ) {
-        if ( $("#searchtype_filter").val() == 'start_with' ) {
-            searched += _(" starting with ");
-        } else {
-            searched += _(" containing ");
-        }
-        searched += "'" + $("#searchmember_filter").val() + "'";
-    }
-    if ( $("#firstletter_filter").val() ) {
-        searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
-    }
-    if ( $("#categorycode_filter").val() ) {
-        searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
-    }
-    if ( $("#branchcode_filter").val() ) {
-        searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
-    }
-    $("#searchpattern").text(searched);
-}
-
-// Redraw the table
-function filter() {
-    $("#firstletter_filter").val('');
-    update_searched();
-    search = 1;
-    $("#searchresults").show();
-    dtMemberResults.fnDraw();
-    return false;
-}
-
-// User has clicked on the Clear button
-function clearFilters(redraw) {
-    $("#searchform select").val('');
-    $("#firstletter_filter").val('');
-    $("#searchmember_filter").val('');
-    if(redraw) {
-        search = 1;
-        $("#searchresults").show();
-        dtMemberResults.fnDraw();
-    }
-}
-
-// User has clicked on a letter
-function filterByFirstLetterSurname(letter) {
-    clearFilters(false);
-    $("#firstletter_filter").val(letter);
-    update_searched();
-    search = 1;
-    $("#searchresults").show();
-    dtMemberResults.fnDraw();
-}
-//]]>
-</script>
 </head>
+
 <body id="pat_member" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
@@ -527,4 +220,316 @@ function filterByFirstLetterSurname(letter) {
     [% INCLUDE 'members-menu.inc' %]
   </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    [% INCLUDE 'columns_settings.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $('#add_to_patron_list_submit').prop('disabled', true);
+            $('#new_patron_list').hide();
+
+            $('#add_to_patron_list').change(function() {
+                var value = $('#add_to_patron_list').val();
+                if ( value == 'new' ) {
+                    $('#new_patron_list').val('')
+                    $('#new_patron_list').show();
+                    $('#new_patron_list').focus();
+                } else if ( value ) {
+                    $('#new_patron_list').hide();
+                    $('#add_to_patron_list_submit').prop('disabled', false);
+                } else {
+                    $('#new_patron_list').hide();
+                    $('#add_to_patron_list_submit').prop('disabled', true);
+                }
+            });
+
+            $('#new_patron_list').on('input', function() {
+                if ( $('#new_patron_list').val() ) {
+                    $('#add_to_patron_list_submit').prop('disabled', false);
+                } else {
+                    $('#add_to_patron_list_submit').prop('disabled', true);
+                }
+            });
+
+            $("#add_to_patron_list_submit").on('click', function(e){
+                if ( $('#add_to_patron_list').val() == 'new' ) {
+                    if ( $('#new_patron_list').val() ) {
+                        $("#add_to_patron_list option").each(function() {
+                            if ( $(this).text() == $('#new_patron_list').val() ) {
+                                alert( _("You already have a list with that name!") );
+                                return false;
+                            }
+                        });
+                    } else {
+                        alert( _("You must give your new patron list a name!") );
+                        return false;
+                    }
+                }
+
+                if ( $("#memberresultst input:checkbox:checked").length == 0 ) {
+                    alert( _("You have not selected any patrons to add to a list!") );
+                    return false;
+                }
+
+                var borrowernumbers = [];
+                $("#memberresultst").find("input:checkbox:checked").each(function(){
+                    borrowernumbers.push($(this).val());
+                });
+                var data = {
+                    add_to_patron_list: $("#add_to_patron_list").val(),
+                    new_patron_list: $("#new_patron_list").val(),
+                    borrowernumbers: borrowernumbers
+                };
+                $.ajax({
+                    data: data,
+                    type: 'POST',
+                    url: '/cgi-bin/koha/svc/members/add_to_list',
+                    success: function(data) {
+                        $("#patron_list_dialog").show();
+                        $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
+                        $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
+                        $("#patron_list_dialog > a").html(data.patron_list.name);
+                        if ( $('#add_to_patron_list').val() == 'new' ) {
+                            var new_patron_list_added = $("<option>", {
+                                value: data.patron_list.patron_list_id,
+                                text: data.patron_list.name
+                            });
+                            $("#add_to_patron_list optgroup").append(new_patron_list_added);
+                            $("#add_to_patron_list").val(data.patron_list.patron_list_id);
+                            $("#new_patron_list").val('');
+                            $('#add_to_patron_list').change();
+                        }
+                    },
+                    error: function() {
+                        alert("an error occurred");
+                    }
+                });
+                return true;
+            });
+            $(".filterByLetter").on("click",function(e){
+                e.preventDefault();
+                filterByFirstLetterSurname($(this).text());
+            });
+            $("#select_all").on("click",function(e){
+                e.preventDefault();
+                $(".selection").prop("checked", true);
+            });
+            $("#clear_all").on("click",function(e){
+                e.preventDefault();
+                $(".selection").prop("checked", false);
+            });
+            $("#clear_search").on("click",function(e){
+                e.preventDefault();
+                clearFilters(true);
+            });
+            $("#searchform").on("submit", filter);
+        });
+
+        var dtMemberResults;
+        var search = 1;
+        $(document).ready(function() {
+            [% IF searchmember %]
+                $("#searchmember_filter").val("[% searchmember | html %]");
+            [% END %]
+            [% IF searchfieldstype %]
+                $("searchfieldstype_filter").val("[% searchfieldstype %]");
+            [% END %]
+            [% IF searchtype %]
+                $("#searchtype_filter").val("[% searchtype %]");
+            [% END %]
+            [% IF categorycode %]
+                $("#categorycode_filter").val("[% categorycode_filter %]");
+            [% END %]
+            [% IF branchcode %]
+                $("#branchcode_filter").val("[% branchcode_filter %]");
+            [% END %]
+
+            [% IF view != "show_results" %]
+                search = 0;
+            [% ELSE %]
+                $("#searchresults").show();
+            [% END %]
+
+            // Build the aLengthMenu
+            var aLengthMenu = [
+                [%PatronsPerPage %], 10, 20, 50, 100, -1
+            ];
+            jQuery.unique(aLengthMenu);
+            aLengthMenu.sort(function( a, b ){
+                // Put "All" at the end
+                if ( a == -1 ) {
+                    return 1;
+                } else if ( b == -1 ) {
+                    return -1;
+                }
+                return parseInt(a) < parseInt(b) ? -1 : 1;}
+            );
+            var aLengthMenuLabel = [];
+            $(aLengthMenu).each(function(){
+                if ( this == -1 ) {
+                    // Label for -1 is "All"
+                    aLengthMenuLabel.push("All");
+                } else {
+                    aLengthMenuLabel.push(this);
+                }
+            });
+
+            // Apply DataTables on the results table
+            var columns_settings = [% ColumnsSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) %];
+            [% UNLESS CAN_user_tools_manage_patron_lists %]
+                [%# Remove the first column if we do not display the checkbox %]
+                columns_settings.splice(0, 1);
+            [% END %]
+            dtMemberResults = KohaTable("#memberresultst", {
+                'bServerSide': true,
+                'sAjaxSource': "/cgi-bin/koha/svc/members/search",
+                'fnServerData': function(sSource, aoData, fnCallback) {
+                    if ( ! search ) {
+                        return;
+                    }
+                    aoData.push({
+                        'name': 'searchmember',
+                        'value': $("#searchmember_filter").val()
+                    },{
+                        'name': 'firstletter',
+                        'value': $("#firstletter_filter").val()
+                    },{
+                        'name': 'searchfieldstype',
+                        'value': $("#searchfieldstype_filter").val()
+                    },{
+                        'name': 'searchtype',
+                        'value': $("#searchtype_filter").val()
+                    },{
+                        'name': 'categorycode',
+                        'value': $("#categorycode_filter").val()
+                    },{
+                        'name': 'branchcode',
+                        'value': $("#branchcode_filter").val()
+                    },{
+                        'name': 'name_sorton',
+                        'value': 'borrowers.surname borrowers.firstname'
+                    },{
+                        'name': 'dateofbirth',
+                        'value': 'borrowers.dateofbirth',
+                    },{
+                        'name': 'category_sorton',
+                        'value': 'categories.description',
+                    },{
+                        'name': 'branch_sorton',
+                        'value': 'branches.branchname'
+                    },{
+                        'name': 'template_path',
+                        'value': 'members/tables/members_results.tt',
+                    });
+                    $.ajax({
+                        'dataType': 'json',
+                        'type': 'POST',
+                        'url': sSource,
+                        'data': aoData,
+                        'success': function(json){
+                            // redirect if there is only 1 result.
+                            if ( json.aaData.length == 1 ) {
+                                var borrowernumber = json.aaData[0].borrowernumber;
+                                document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
+                                return false;
+                            }
+                            fnCallback(json);
+                        }
+                    });
+                },
+                'aoColumns':[
+                    [% IF CAN_user_tools_manage_patron_lists %]
+                      { 'mDataProp': 'dt_borrowernumber', 'bSortable': false },
+                    [% END %]
+                    { 'mDataProp': 'dt_cardnumber' },
+                    { 'mDataProp': 'dt_name' },
+                    { 'mDataProp': 'dt_dateofbirth' },
+                    { 'mDataProp': 'dt_category' },
+                    { 'mDataProp': 'dt_branch' },
+                    { 'mDataProp': 'dt_dateexpiry' },
+                    { 'mDataProp': 'dt_od_checkouts', 'bSortable': false },
+                    { 'mDataProp': 'dt_fines', 'bSortable': false },
+                    { 'mDataProp': 'dt_borrowernotes' },
+                    { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
+                ],
+                'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
+                    /* Center text for 6th column */
+                    $("td:eq(5)", nRow).css("text-align", "center");
+
+                    return nRow;
+                },
+                'bFilter': false,
+                'bAutoWidth': false,
+                [% IF CAN_user_tools_manage_patron_lists %]
+                    'aaSorting': [[2, 'asc']],
+                [% ELSE %]
+                    'aaSorting': [[1, 'asc']],
+                [% END %]
+                "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
+                'sPaginationType': 'full_numbers',
+                "iDisplayLength": [% PatronsPerPage %],
+                "bProcessing": true,
+            }, columns_settings);
+            update_searched();
+        });
+
+        // Update the string "Results found ..."
+        function update_searched(){
+            var searched = $("#searchfieldstype_filter").find("option:selected").text();
+            if ( $("#searchmember_filter").val() ) {
+                if ( $("#searchtype_filter").val() == 'start_with' ) {
+                    searched += _(" starting with ");
+                } else {
+                    searched += _(" containing ");
+                }
+                searched += "'" + $("#searchmember_filter").val() + "'";
+            }
+            if ( $("#firstletter_filter").val() ) {
+                searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
+            }
+            if ( $("#categorycode_filter").val() ) {
+                searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
+            }
+            if ( $("#branchcode_filter").val() ) {
+                searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
+            }
+            $("#searchpattern").text(searched);
+        }
+
+        // Redraw the table
+        function filter() {
+            $("#firstletter_filter").val('');
+            update_searched();
+            search = 1;
+            $("#searchresults").show();
+            dtMemberResults.fnDraw();
+            return false;
+        }
+
+        // User has clicked on the Clear button
+        function clearFilters(redraw) {
+            $("#searchform select").val('');
+            $("#firstletter_filter").val('');
+            $("#searchmember_filter").val('');
+            if(redraw) {
+                search = 1;
+                $("#searchresults").show();
+                dtMemberResults.fnDraw();
+            }
+        }
+
+        // User has clicked on a letter
+        function filterByFirstLetterSurname(letter) {
+            clearFilters(false);
+            $("#firstletter_filter").val(letter);
+            update_searched();
+            search = 1;
+            $("#searchresults").show();
+            dtMemberResults.fnDraw();
+        }
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index bc5e3fe..d373666 100644 (file)
 [% USE Koha %]
 [% USE KohaDates %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; [% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron [% IF (firstname) %][% firstname %] [% END %][% IF (surname) %][% surname %] [% END %]([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat_[% KOHA_VERSION %].js"></script>
-[% INCLUDE 'calendar.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-$(document).ready(function() {
-
-        $("#saverecord").css({ 'margin-left': 0 });
-        var original_offset = $("#toolbar").position().top;
-        var additional_height = $("#filters").height();
-        $('#toolbar').fixFloat({ 'originalOffset': original_offset });
-        $("#filteraction_on").on("click", function(){
-            $(window).off('scroll');
-            $("#toolbar").css({ top: original_offset + additional_height });
-            $('#toolbar').fixFloat({ 'originalOffset': original_offset + additional_height });
-        });
-        $("#filteraction_off").on("click", function(){
-            $(window).off('scroll');
-            $("#toolbar").css({ top: original_offset });
-            $('#toolbar').fixFloat({ 'originalOffset': original_offset });
-        })
-
-       [% IF categorycode %]
-               update_category_code( "[% categorycode %]" );
-       [% ELSE %]
-               if ( $("#categorycode_entry").length > 0 ){
-                       var category_code = $("#categorycode_entry").find("option:selected").val();
-                       update_category_code( category_code );
-               }
-       [% END %]
-});
-
-function update_cardnumber_warning(size){
-    var max_len = [% maxlength_cardnumber %];
-    if ( size >= max_len ) {
-        $("#cn_max").show();
-    } else {
-        $("#cn_max").hide();
-    }
-}
-
-$(document).ready(function() {
-    $("#cn_max").hide();
-    var content;
-    $("#cardnumber").on("keydown", function(e){
-        content = $(this).val();
-    });
-    $("#cardnumber").on("keyup", function(e){
-        // .val() will return the value of the input after the key has been released
-        var l = $(this).val().length;
-        if ( l == content.length + 1 ) { l--; }
-        update_cardnumber_warning(l);
-    });
-    $("#cardnumber").bind("paste", function(e){
-        var pastedData = e.originalEvent.clipboardData.getData('text');
-        update_cardnumber_warning(pastedData.length - 1);
-    } );
-    var toggle_quick_add = $(".toggle_quick_add");
-    $(toggle_quick_add).click(function(e){
-        toggle_quick_add.toggle();
-        e.preventDefault();
-        var toggle_to = '';
-        var toggle_from = '';
-        if( $("#entryform:visible").length ) {
-            toggle_to = "#quick_add_form label";
-            toggle_from = "#entryform label";
-        } else {
-            toggle_to="#entryform label";
-            toggle_from = "#quick_add_form label";
-        }
-        $(toggle_from).each(function() {
-            var input_label = $(this).attr('for');
-            if ( input_label == 'sex-male' || input_label == 'sex-none' || input_label == 'sex-female' ) {
-                $(toggle_to+"[for='"+input_label+"']").next().prop('checked', $(this).next().prop('checked') );
-                return;
-            }
-            $(toggle_to+"[for='"+input_label+"']").next().val(  $(this).next().val() );
-        });
-
-        $(".toggler").toggle();
-    });
-
-    $("#save_quick_add").click(function(){
-        $("#quick_add_form").validate();
-        if( $("#quick_add_form").valid()){
-            $('.toggle_quick_add').click();
-            $('#saverecord').click();
-        }
-        else {return false;}
-    });
-
-    $("#entryform").validate({
-        rules: {
-            password: {
-                required: true,
-                password_strong: true,
-                password_no_spaces: true
-            },
-            password2: {
-                required: true,
-                password_match: true
-            }
-        }
-    });
-
-    $("#saverecord").click(function(){
-        if( check_form_borrowers() ){
-            $("#entryform").submit();
-        }
-    });
-
-    $('#duplicate').on('click', function() {
-        $("input[name='op']").val('modify');
-        $("input[name='borrowernumber']").val('[% check_member %]');
-        $("input[name='check_member']").val('');
-        $('#entryform').submit();
-    });
-
-    $('#not-duplicate').on('click', function() {
-        $("input[name='nodouble']").val('1');
-        $('#entryform').submit();
-    });
-});
-
-        var MSG_SEPARATOR = _("Separator must be / in field %s");
-        var MSG_INCORRECT_DAY = _("Invalid day entered in field %s");
-        var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s");
-        var MSG_INCORRECT_YEAR = _("Invalid year entered in field %s");
-        var MSG_DUPLICATE_PATRON = _("Warning: Duplicate patron");
-        var MSG_DUPLICATE_ORGANIZATION = _("Warning: Duplicate organization");
-        var MSG_LATE_EXPIRY = _("Warning: Expiration date falls before enrollment date");
-        var MSG_DUPLICATE_SUSPICION = _("Please confirm whether this is a duplicate patron");
-        var MSG_MONTH = _("%s month")
-        var MSG_MONTHS = _("%s months")
-        var MSG_YEAR = _("%s year")
-        var MSG_YEARS = _("%s years")
-        var LABEL_CHANGE = _("Change");
-        var LABEL_SET_TO_PATRON = _("Set to patron");
-        var LABEL_AGE = _("Age");
-
-//]]>
-</script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/members_[% KOHA_VERSION %].js"></script>
 </head>
+
 <body id="pat_memberentrygen" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
@@ -1284,47 +1144,193 @@ $(document).ready(function() {
             </ol>
         </fieldset>
     </form>
-    <script>
-        $(document).ready(function () {
+[% END %]
+</div>
+</div>
+
+[% UNLESS ( opadd ) %]<div class="yui-b">
+[% INCLUDE 'members-menu.inc' %]
+</div>[% END %]
+[% END %]
+</div>
 
-            $("#entryform,#saverecord").hide();
-            [% q_add_f = Koha.Preference('PatronQuickAddFields').split('\|') %]
-            var qaddfields = [[% FOREACH field IN q_add_f.unique %]"[% field %]",[% END %]];
-            var skipped_fields = ["contactname","contactfirstname","relationship"]; //Guarantor form is pulled as a whole, ignore individual fields
-            $("#entryform label").each(function () {
-                var input_label = $(this).attr('for');
-                if ( input_label == 'sex-female' ) {
-                    input_label='sex';
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat_[% KOHA_VERSION %].js"></script>
+    [% INCLUDE 'calendar.inc' %]
+    <script type="text/javascript">
+        $(document).ready(function() {
+
+                $("#saverecord").css({ 'margin-left': 0 });
+                var original_offset = $("#toolbar").position().top;
+                var additional_height = $("#filters").height();
+                $('#toolbar').fixFloat({ 'originalOffset': original_offset });
+                $("#filteraction_on").on("click", function(){
+                    $(window).off('scroll');
+                    $("#toolbar").css({ top: original_offset + additional_height });
+                    $('#toolbar').fixFloat({ 'originalOffset': original_offset + additional_height });
+                });
+                $("#filteraction_off").on("click", function(){
+                    $(window).off('scroll');
+                    $("#toolbar").css({ top: original_offset });
+                    $('#toolbar').fixFloat({ 'originalOffset': original_offset });
+                })
+
+            [% IF categorycode %]
+                update_category_code( "[% categorycode %]" );
+            [% ELSE %]
+                if ( $("#categorycode_entry").length > 0 ){
+                    var category_code = $("#categorycode_entry").find("option:selected").val();
+                    update_category_code( category_code );
                 }
-                else if ( input_label == 'btitle' ) {
-                    input_label='title';
+            [% END %]
+        });
+
+        function update_cardnumber_warning(size){
+            var max_len = [% maxlength_cardnumber %];
+            if ( size >= max_len ) {
+                $("#cn_max").show();
+            } else {
+                $("#cn_max").hide();
+            }
+        }
+
+        $(document).ready(function() {
+            $("#cn_max").hide();
+            var content;
+            $("#cardnumber").on("keydown", function(e){
+                content = $(this).val();
+            });
+            $("#cardnumber").on("keyup", function(e){
+                // .val() will return the value of the input after the key has been released
+                var l = $(this).val().length;
+                if ( l == content.length + 1 ) { l--; }
+                update_cardnumber_warning(l);
+            });
+            $("#cardnumber").bind("paste", function(e){
+                var pastedData = e.originalEvent.clipboardData.getData('text');
+                update_cardnumber_warning(pastedData.length - 1);
+            } );
+            var toggle_quick_add = $(".toggle_quick_add");
+            $(toggle_quick_add).click(function(e){
+                toggle_quick_add.toggle();
+                e.preventDefault();
+                var toggle_to = '';
+                var toggle_from = '';
+                if( $("#entryform:visible").length ) {
+                    toggle_to = "#quick_add_form label";
+                    toggle_from = "#entryform label";
+                } else {
+                    toggle_to="#entryform label";
+                    toggle_from = "#quick_add_form label";
                 }
-                if ( skipped_fields.indexOf( input_label ) != -1 ) { input_label=""; }
-                if( qaddfields.indexOf( input_label ) != -1 || $(this).attr('class') == 'required' ){
-                   $(this).parent().clone().appendTo("#quick_add_list");
-                   [% UNLESS mandatorypassword %]
-                         if( input_label == 'password' ) $("#entryform label[for='password2']").parent().clone().appendTo("#quick_add_list");
-                   [% END %]
+                $(toggle_from).each(function() {
+                    var input_label = $(this).attr('for');
+                    if ( input_label == 'sex-male' || input_label == 'sex-none' || input_label == 'sex-female' ) {
+                        $(toggle_to+"[for='"+input_label+"']").next().prop('checked', $(this).next().prop('checked') );
+                        return;
+                    }
+                    $(toggle_to+"[for='"+input_label+"']").next().val(  $(this).next().val() );
+                });
+
+                $(".toggler").toggle();
+            });
+
+            $("#save_quick_add").click(function(){
+                $("#quick_add_form").validate();
+                if( $("#quick_add_form").valid()){
+                    $('.toggle_quick_add').click();
+                    $('#saverecord').click();
+                }
+                else {return false;}
+            });
+
+            $("#entryform").validate({
+                rules: {
+                    password: {
+                        required: true,
+                        password_strong: true,
+                        password_no_spaces: true
+                    },
+                    password2: {
+                        required: true,
+                        password_match: true
+                    }
                 }
             });
-                if( $("#memberentry_guarantor").length ) {
-                    $("#memberentry_guarantor").clone().appendTo("#quick_add_list").css("margin",0);
-                    $("#quick_add_form #memberentry_guarantor").append("<p>" + _("Note: Quick add guarantor form populates address fields in full form") + "</p>");
-                    $("#quick_add_list #guarantordelete").prop('id','qagd');
+
+            $("#saverecord").click(function(){
+                if( check_form_borrowers() ){
+                    $("#entryform").submit();
                 }
-            $("#qagd").click(function() { $("#guarantordelete").click(); });
-            $("#quick_add_form").show();
+            });
+
+            $('#duplicate').on('click', function() {
+                $("input[name='op']").val('modify');
+                $("input[name='borrowernumber']").val('[% check_member %]');
+                $("input[name='check_member']").val('');
+                $('#entryform').submit();
+            });
+
+            $('#not-duplicate').on('click', function() {
+                $("input[name='nodouble']").val('1');
+                $('#entryform').submit();
+            });
         });
+
+        var MSG_SEPARATOR = _("Separator must be / in field %s");
+        var MSG_INCORRECT_DAY = _("Invalid day entered in field %s");
+        var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s");
+        var MSG_INCORRECT_YEAR = _("Invalid year entered in field %s");
+        var MSG_DUPLICATE_PATRON = _("Warning: Duplicate patron");
+        var MSG_DUPLICATE_ORGANIZATION = _("Warning: Duplicate organization");
+        var MSG_LATE_EXPIRY = _("Warning: Expiration date falls before enrollment date");
+        var MSG_DUPLICATE_SUSPICION = _("Please confirm whether this is a duplicate patron");
+        var MSG_MONTH = _("%s month")
+        var MSG_MONTHS = _("%s months")
+        var MSG_YEAR = _("%s year")
+        var MSG_YEARS = _("%s years")
+        var LABEL_CHANGE = _("Change");
+        var LABEL_SET_TO_PATRON = _("Set to patron");
+        var LABEL_AGE = _("Age");
+
+        [% IF quickadd && opadd  && !check_member %]
+            $(document).ready(function () {
+
+                $("#entryform,#saverecord").hide();
+                [% q_add_f = Koha.Preference('PatronQuickAddFields').split('\|') %]
+                var qaddfields = [[% FOREACH field IN q_add_f.unique %]"[% field %]",[% END %]];
+                var skipped_fields = ["contactname","contactfirstname","relationship"]; //Guarantor form is pulled as a whole, ignore individual fields
+                $("#entryform label").each(function () {
+                    var input_label = $(this).attr('for');
+                    if ( input_label == 'sex-female' ) {
+                        input_label='sex';
+                    }
+                    else if ( input_label == 'btitle' ) {
+                        input_label='title';
+                    }
+                    if ( skipped_fields.indexOf( input_label ) != -1 ) { input_label=""; }
+                    if( qaddfields.indexOf( input_label ) != -1 || $(this).attr('class') == 'required' ){
+                       $(this).parent().clone().appendTo("#quick_add_list");
+                       [% UNLESS mandatorypassword %]
+                             if( input_label == 'password' ) $("#entryform label[for='password2']").parent().clone().appendTo("#quick_add_list");
+                       [% END %]
+                    }
+                });
+                    if( $("#memberentry_guarantor").length ) {
+                        $("#memberentry_guarantor").clone().appendTo("#quick_add_list").css("margin",0);
+                        $("#quick_add_form #memberentry_guarantor").append("<p>" + _("Note: Quick add guarantor form populates address fields in full form") + "</p>");
+                        $("#quick_add_list #guarantordelete").prop('id','qagd');
+                    }
+                $("#qagd").click(function() { $("#guarantordelete").click(); });
+                $("#quick_add_form").show();
+            });
+        [% END %]
+
     </script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/messaging-preference-form_[% KOHA_VERSION %].js"></script>
 [% END %]
-</div>
-</div>
 
-[% UNLESS ( opadd ) %]<div class="yui-b">
-[% INCLUDE 'members-menu.inc' %]
-</div>[% END %]
-[% END %]
-</div>
 [% INCLUDE 'intranet-bottom.inc' %]
 [% PROCESS 'password_check.inc' %]
 [% PROCESS 'add_password_check' new_password => 'password' %]
index ccc2237..81c883c 100644 (file)
@@ -2,15 +2,12 @@
 [% USE Branches %]
 [% USE Categories %]
 [% USE KohaDates %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; Update patron records</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript">
-    $(function() {
-        $( "#pending_updates" ).accordion();
-    });
-</script>
 </head>
+
 <body id="pat_update" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
 
         </div>
     </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+    <script type="text/javascript">
+        $(function() {
+            $( "#pending_updates" ).accordion();
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 9cf356d..138208c 100644 (file)
@@ -1,5 +1,6 @@
 [% USE Koha %]
 [% USE KohaDates %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Check duplicate patron</title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -78,4 +79,5 @@
        </div>
 </div>
 </div>
+
 [% INCLUDE 'popup-bottom.inc' %]
index 567b18d..35a8410 100644 (file)
@@ -2,11 +2,12 @@
 [% USE Branches %]
 [% USE KohaDates %]
 [% USE Price %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
     <title>Summary for [% firstname %] [% surname %] ([% cardnumber %])</title>
     [% INCLUDE 'doc-head-close.inc' %]
-    [% INCLUDE 'slip-print.inc' #printThenClose %]
 </head>
+
 <body id="pat_moremember-print" class="pat">
     <div id="main">
         <h3><a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% cardnumber %]">Account summary: [% firstname %] [% surname %] ([% cardnumber %])</a></h3>
         </table>
     [% END %]
 
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'slip-print.inc' #printThenClose %]
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 6f0ce08..49d0f55 100644 (file)
@@ -1,13 +1,13 @@
 [% USE Koha %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Print Receipt for [% cardnumber %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon %][% ELSE %][% interface %]/[% theme %]/img/favicon.ico[% END %]" type="image/x-icon" />
- <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/print_[% KOHA_VERSION %].css" />
-
-[% INCLUDE 'slip-print.inc' #printThenClose %]
+<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/print_[% KOHA_VERSION %].css" />
 </head>
+
 <body id="pat_moremember-receipt" class="pat">
 
 <div id="receipt">
@@ -69,5 +69,8 @@ Date due: [% issueloo.date_due %]</p>
             [% END %]
 [% END %]
 
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'slip-print.inc' #printThenClose %]
+[% END %]
 
 [% INCLUDE 'intranet-bottom.inc' %]
index 5ea5ac3..83bcff0 100644 (file)
@@ -3,6 +3,7 @@
 [% USE KohaDates %]
 [% USE AuthorisedValues %]
 [% USE ColumnsSettings %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo;
 [% UNLESS blocking_error %]
 [% END %]
 </title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% INCLUDE 'calendar.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
-[% INCLUDE 'datatables.inc' %]
-[% INCLUDE 'columns_settings.inc' %]
-[% INCLUDE 'strings.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min_[% KOHA_VERSION %].js"></script>
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery-ui-timepicker-addon.min_[% KOHA_VERSION %].js"></script>
-[% INCLUDE 'timepicker.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.rowGrouping_[% KOHA_VERSION %].js"></script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/pages/circulation_[% KOHA_VERSION %].js"></script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/checkouts_[% KOHA_VERSION %].js"></script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/holds_[% KOHA_VERSION %].js"></script>
-<script type="text/JavaScript">
-//<![CDATA[
-/* Set some variable needed in circulation.js */
-var interface = "[% interface %]";
-var theme = "[% theme %]";
-var borrowernumber = "[% borrowernumber %]";
-var branchcode = "[% Branches.GetLoggedInBranchcode() %]";
-var exports_enabled = "[% Koha.Preference('ExportCircHistory') %]";
-var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %]
-var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %];
-var script = "moremember";
-var relatives_borrowernumbers = new Array();
-[% FOREACH b IN relatives_borrowernumbers %]
-    relatives_borrowernumbers.push("[% b %]");
-[% END %]
-
-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.");
-
-columns_settings = [% ColumnsSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) %]
-
-$(document).ready(function() {
-    if ( $('#clubs-tab').length ) {
-        $('#clubs-tab-link').on('click', function() {
-            $('#clubs-tab').text(_("Loading..."));
-            $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
-        });
-    }
-
-    $('#finesholdsissues').tabs({
-        // Correct table sizing for tables hidden in tabs
-        // http://www.datatables.net/examples/api/tabs_and_scrolling.html
-        "show": function(event, ui) {
-            var oTable = $('div.dataTables_wrapper>table', ui.panel).dataTable();
-            if ( oTable.length > 0 ) {
-                oTable.fnAdjustColumnSizing();
-            }
-        },
-        "activate": function( event, ui ) {
-            $('#'+ui.newTab.context.id).click();
-        }
-    } );
-    $("#holdst").dataTable($.extend(true, {}, dataTablesDefaults, {
-        "sDom": 't',
-        "aoColumnDefs": [
-            { "aTargets": [ -1,-2 ], "bSortable": false, "bSearchable": false }
-        ],
-        "aoColumns": [
-            { "sType": "title-string" },{ "sType": "anti-the" },null,null,null,null,null,null
-        ],
-        "bPaginate": false
-    }));
-    [% IF ( picture ) %]
-    // new YAHOO.widget.Button("delpicture");   // FIXME: formatting mismatch between YUI and normal button
-       $('#delpicture').click(function(){
-                return confirm(_("Are you sure you want to delete this patron image? This cannot be undone."));
-       });
-       $('#manage-patron-image').find("input[value*=Upload]").click(function(){
-        if($("#uploadfile").val() == ""){
-            alert(_("Please choose a file to upload"));
-            return false;
-        }
-        return confirm(_("Are you sure you want to replace the current patron image? This cannot be undone."));
-       });[% END %]
-
-    $("#suspend_until").datepicker({
-        onClose: function(dateText, inst) {
-            validate_date(dateText, inst);
-        },
-        minDate: 1, // require that hold suspended until date is after today
-    }).on("change", function(e, value) {
-        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
-    });
-
-    $("#view_restrictions").on("click",function(){
-        $('#debarments-tab-link').click();
-    });
- });
-function uncheck_sibling(me){
-nodename=me.getAttribute("name");
-if (nodename =="barcodes[]"){
-    var Node=me.parentNode.previousSibling;
-    while (Node.nodeName!="TD"){Node=Node.previousSibling}
-    var Nodes=Node.childNodes;
-    for (var i=0;i < Nodes.length;i++){
-      if (Nodes[i].nodeName=="INPUT" && Nodes[i].getAttribute("type")=="checkbox"){
-        Nodes[i].checked=false;
-      }     
-   }   
-
-}else {
-    var Node=me.parentNode.nextSibling;
-    while (Node.nodeName!="TD"){Node=Node.nextSibling}
-    var Nodes=Node.childNodes;
-    for (var i=0;i<Nodes.length;i++){
-      if (Nodes[i].nodeName=="INPUT" && Nodes[i].getAttribute("type")=="checkbox"){
-        Nodes[i].checked=false;
-      }     
-   }   
-}
-}
-function validate1(date) {
-    var today = new Date();
-    if ( date < today ) {
-        return true;
-     } else {
-        return false;
-     }
-};
-//]]>
-</script>
-
 </head>
+
 <body id="pat_moremember" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
@@ -661,4 +540,130 @@ function validate1(date) {
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    [% INCLUDE 'columns_settings.inc' %]
+    [% INCLUDE 'strings.inc' %]
+    [% INCLUDE 'calendar.inc' %]
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery-ui-timepicker-addon.min_[% KOHA_VERSION %].js"></script>
+    [% INCLUDE 'timepicker.inc' %]
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.rowGrouping_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/pages/circulation_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/checkouts_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/holds_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/messaging-preference-form_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript">
+        /* Set some variable needed in circulation.js */
+        var interface = "[% interface %]";
+        var theme = "[% theme %]";
+        var borrowernumber = "[% borrowernumber %]";
+        var branchcode = "[% Branches.GetLoggedInBranchcode() %]";
+        var exports_enabled = "[% Koha.Preference('ExportCircHistory') %]";
+        var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %]
+        var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %];
+        var script = "moremember";
+        var relatives_borrowernumbers = new Array();
+        [% FOREACH b IN relatives_borrowernumbers %]
+            relatives_borrowernumbers.push("[% b %]");
+        [% END %]
+
+        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.");
+
+        columns_settings = [% ColumnsSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) %]
+
+        $(document).ready(function() {
+            if ( $('#clubs-tab').length ) {
+                $('#clubs-tab-link').on('click', function() {
+                    $('#clubs-tab').text(_("Loading..."));
+                    $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber %]');
+                });
+            }
+
+            $('#finesholdsissues').tabs({
+                // Correct table sizing for tables hidden in tabs
+                // http://www.datatables.net/examples/api/tabs_and_scrolling.html
+                "show": function(event, ui) {
+                    var oTable = $('div.dataTables_wrapper>table', ui.panel).dataTable();
+                    if ( oTable.length > 0 ) {
+                        oTable.fnAdjustColumnSizing();
+                    }
+                },
+                "activate": function( event, ui ) {
+                    $('#'+ui.newTab.context.id).click();
+                }
+            } );
+            $("#holdst").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "sDom": 't',
+                "aoColumnDefs": [
+                    { "aTargets": [ -1,-2 ], "bSortable": false, "bSearchable": false }
+                ],
+                "aoColumns": [
+                    { "sType": "title-string" },{ "sType": "anti-the" },null,null,null,null,null,null
+                ],
+                "bPaginate": false
+            }));
+            [% IF ( picture ) %]
+                $('#delpicture').click(function(){
+                     return confirm(_("Are you sure you want to delete this patron image? This cannot be undone."));
+                });
+                $('#manage-patron-image').find("input[value*=Upload]").click(function(){
+                    if($("#uploadfile").val() == ""){
+                        alert(_("Please choose a file to upload"));
+                        return false;
+                    }
+                    return confirm(_("Are you sure you want to replace the current patron image? This cannot be undone."));
+                });
+            [% END %]
+
+            $("#suspend_until").datepicker({
+                onClose: function(dateText, inst) {
+                    validate_date(dateText, inst);
+                },
+                minDate: 1, // require that hold suspended until date is after today
+            }).on("change", function(e, value) {
+                if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
+            });
+
+            $("#view_restrictions").on("click",function(){
+                $('#debarments-tab-link').click();
+            });
+         });
+        function uncheck_sibling(me){
+            nodename=me.getAttribute("name");
+            if (nodename =="barcodes[]"){
+                var Node=me.parentNode.previousSibling;
+                while (Node.nodeName!="TD"){Node=Node.previousSibling}
+                var Nodes=Node.childNodes;
+                for (var i=0;i < Nodes.length;i++){
+                    if (Nodes[i].nodeName=="INPUT" && Nodes[i].getAttribute("type")=="checkbox"){
+                        Nodes[i].checked=false;
+                    }
+                }
+            } else {
+                var Node=me.parentNode.nextSibling;
+                while (Node.nodeName!="TD"){Node=Node.nextSibling}
+                var Nodes=Node.childNodes;
+                for (var i=0;i<Nodes.length;i++){
+                    if (Nodes[i].nodeName=="INPUT" && Nodes[i].getAttribute("type")=="checkbox"){
+                      Nodes[i].checked=false;
+                    }
+               }
+            }
+        }
+
+        function validate1(date) {
+            var today = new Date();
+            if ( date < today ) {
+                return true;
+            } else {
+                return false;
+            }
+        };
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index ae06764..b0b3999 100644 (file)
@@ -1,4 +1,5 @@
 [% USE KohaDates %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Search the Norwegian national patron database</title>
 [% INCLUDE 'doc-head-close.inc' %]
             [% INCLUDE 'circ-menu.inc' %]
         </div>
     </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
 
 [% BLOCK patron_detail %]
index d179d08..fecf201 100644 (file)
@@ -2,35 +2,17 @@
 [% USE AuthorisedValues %]
 [% USE Branches %]
 [% USE KohaDates %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Sent notices for [% INCLUDE 'patron-title.inc' no_html = 1 %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
-[% INCLUDE 'datatables.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-    $(document).ready(function() {
-    $("#noticestable").dataTable($.extend(true, {}, dataTablesDefaults, {
-        "aaSorting": [[ 3, "desc" ]],
-        "aoColumns": [ null,null,null,{ "sType": "title-string" } ],
-        "sPaginationType": "four_button"
-    }));
-
-        $("#noticestable").on("click", ".notice-title", function(e){
-            e.preventDefault();
-            var rowid = $(this).data("noticeid");
-            $("#notice"+rowid).toggle();
-            $("#resend_notice"+rowid).toggle();
-        });
-
-    });
-//]]>
-</script>
 <style type="text/css">
     .notice { display: none; }
     .notice-title { font-weight: bold; display: block; }
 </style>
 </head>
+
 <body id="pat_notices" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("#noticestable").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "aaSorting": [[ 3, "desc" ]],
+                "aoColumns": [ null,null,null,{ "sType": "title-string" } ],
+                "sPaginationType": "four_button"
+            }));
+
+            $("#noticestable").on("click", ".notice-title", function(e){
+                e.preventDefault();
+                var rowid = $(this).data("noticeid");
+                $("#notice"+rowid).toggle();
+                $("#resend_notice"+rowid).toggle();
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index fb10bcb..ba6b33e 100644 (file)
@@ -2,48 +2,12 @@
 [% USE AuthorisedValues %]
 [% USE Branches %]
 [% USE Price %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; Pay Fines for  [% borrower.firstname |html %] [% borrower.surname |html %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min_[% KOHA_VERSION %].js"></script>
-<script type= "text/javascript">
-//<![CDATA[
-function enableCheckboxActions(){
-    // Enable/disable controls if checkboxes are checked
-    var checkedBoxes = $("input.cb:checked");
-    if ($(checkedBoxes).size()) {
-      $("#payselected").prop("disabled",false);
-    } else {
-      $("#payselected").prop("disabled",true);
-    }
-}
-    $(document).ready(function(){
- $('#pay-fines-form').preventDoubleFormSubmit();
-        $("#woall").click(function(event){
-            var msg = _("Are you sure you want to write off %s in outstanding fines? This cannot be undone!").format( "[% total | $Price %]" );
-            var answer = confirm(msg);
-                if (!answer){
-                    event.preventDefault();
-                }
-        });
-        $('#CheckAll').click(function(){
-            $("#finest").checkCheckboxes();
-            enableCheckboxActions();
-            return false;
-        });
-        $('#CheckNone').click(function(){
-            $("#finest").unCheckCheckboxes();
-            enableCheckboxActions();
-            return false;
-        });
-        $(".cb").change(function(){
-            enableCheckboxActions();
-        });
-        enableCheckboxActions();
-    });
-//]]>
-</script>
 </head>
+
 <body id="pat_pay" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
@@ -170,4 +134,46 @@ function enableCheckboxActions(){
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min_[% KOHA_VERSION %].js"></script>
+    <script type= "text/javascript">
+        function enableCheckboxActions(){
+            // Enable/disable controls if checkboxes are checked
+            var checkedBoxes = $("input.cb:checked");
+            if ($(checkedBoxes).size()) {
+              $("#payselected").prop("disabled",false);
+            } else {
+              $("#payselected").prop("disabled",true);
+            }
+        }
+        $(document).ready(function(){
+        $('#pay-fines-form').preventDoubleFormSubmit();
+            $("#woall").click(function(event){
+                var msg = _("Are you sure you want to write off %s in outstanding fines? This cannot be undone!").format( "[% total | $Price %]" );
+                var answer = confirm(msg);
+                    if (!answer){
+                        event.preventDefault();
+                    }
+            });
+            $('#CheckAll').click(function(){
+                $("#finest").checkCheckboxes();
+                enableCheckboxActions();
+                return false;
+            });
+            $('#CheckNone').click(function(){
+                $("#finest").unCheckCheckboxes();
+                enableCheckboxActions();
+                return false;
+            });
+            $(".cb").change(function(){
+                enableCheckboxActions();
+            });
+            enableCheckboxActions();
+        });
+
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 7629874..e85f517 100644 (file)
@@ -1,68 +1,11 @@
 [% USE Koha %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; Collect fine payment for  [% borrower.firstname %] [% borrower.surname %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type= "text/javascript">
-//<![CDATA[
-$(document).ready(function() {
-    $('#payindivfine, #woindivfine, #payfine').preventDoubleFormSubmit();
-    $("#paid").on("change",function(){
-        moneyFormat( this );
-    });
-});
-
-function moneyFormat(textObj) {
-    var newValue = textObj.value;
-    var decAmount = "";
-    var dolAmount = "";
-    var decFlag   = false;
-    var aChar     = "";
-
-    for(i=0; i < newValue.length; i++) {
-        aChar = newValue.substring(i, i+1);
-        if (aChar >= "0" && aChar <= "9") {
-            if(decFlag) {
-                decAmount = "" + decAmount + aChar;
-            }
-            else {
-                dolAmount = "" + dolAmount + aChar;
-            }
-        }
-        if (aChar == ".") {
-            if (decFlag) {
-                dolAmount = "";
-                break;
-            }
-            decFlag = true;
-        }
-    }
-
-    if (dolAmount == "") {
-        dolAmount = "0";
-    }
-// Strip leading 0s
-    if (dolAmount.length > 1) {
-        while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
-            dolAmount = dolAmount.substring(1,dolAmount.length);
-        }
-    }
-    if (decAmount.length > 2) {
-        decAmount = decAmount.substring(0,2);
-    }
-// Pad right side
-    if (decAmount.length == 1) {
-       decAmount = decAmount + "0";
-    }
-    if (decAmount.length == 0) {
-       decAmount = decAmount + "00";
-    }
-
-    textObj.value = dolAmount + "." + decAmount;
-}
-//]]>
-</script>
 </head>
+
 <body id="pat_paycollect" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
@@ -227,5 +170,66 @@ function moneyFormat(textObj) {
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
-[% INCLUDE 'intranet-bottom.inc' %]
 
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+    <script type= "text/javascript">
+        $(document).ready(function() {
+            $('#payindivfine, #woindivfine, #payfine').preventDoubleFormSubmit();
+            $("#paid").on("change",function(){
+                moneyFormat( this );
+            });
+        });
+
+        function moneyFormat(textObj) {
+            var newValue = textObj.value;
+            var decAmount = "";
+            var dolAmount = "";
+            var decFlag   = false;
+            var aChar     = "";
+
+            for(i=0; i < newValue.length; i++) {
+                aChar = newValue.substring(i, i+1);
+                if (aChar >= "0" && aChar <= "9") {
+                    if(decFlag) {
+                        decAmount = "" + decAmount + aChar;
+                    }
+                    else {
+                        dolAmount = "" + dolAmount + aChar;
+                    }
+                }
+                if (aChar == ".") {
+                    if (decFlag) {
+                        dolAmount = "";
+                        break;
+                    }
+                    decFlag = true;
+                }
+            }
+
+            if (dolAmount == "") {
+                dolAmount = "0";
+            }
+        // Strip leading 0s
+            if (dolAmount.length > 1) {
+                while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
+                    dolAmount = dolAmount.substring(1,dolAmount.length);
+                }
+            }
+            if (decAmount.length > 2) {
+                decAmount = decAmount.substring(0,2);
+            }
+        // Pad right side
+            if (decAmount.length == 1) {
+               decAmount = decAmount + "0";
+            }
+            if (decAmount.length == 0) {
+               decAmount = decAmount + "00";
+            }
+
+            textObj.value = dolAmount + "." + decAmount;
+        }
+    </script>
+[% END %]
+
+[% INCLUDE 'intranet-bottom.inc' %]
index f83fc3b..5027672 100644 (file)
@@ -1,12 +1,13 @@
 [% USE Koha %]
 [% USE KohaDates %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Print Receipt for [% cardnumber %]</title>
+<title>Print receipt for [% cardnumber %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/printreceiptinvoice_[% KOHA_VERSION %].css" />
 [% INCLUDE 'blocking_errors.inc' %]
-[% INCLUDE 'slip-print.inc' #printThenClose %]
 </head>
+
 <body id="pat_printfeercpt" class="pat">
 
 <div id="receipt">
@@ -74,4 +75,9 @@
   </tfoot>
 </table>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'slip-print.inc' #printThenClose %]
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index eb6f925..acb8fd2 100644 (file)
@@ -1,10 +1,11 @@
 [% USE Koha %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Print receipt for [% cardnumber %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/printreceiptinvoice_[% KOHA_VERSION %].css" />
-[% INCLUDE 'slip-print.inc' #printThenClose %]
 </head>
+
 <body id="printinvoice" class="pat">
 
 <div id="receipt">
@@ -74,4 +75,9 @@
   </tfoot>
 </table>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'slip-print.inc' #printThenClose %]
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 9ed8cfe..ace0c15 100644 (file)
@@ -1,21 +1,11 @@
 [% USE Koha %]
 [% USE AuthorisedValues  %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; Purchase suggestions for [% INCLUDE 'patron-title.inc' no_html = 1 %]</title>
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
 [% INCLUDE 'doc-head-close.inc' %]
-[% INCLUDE 'datatables.inc' %]
-<script type="text/javascript">
-    $(document).ready(function() {
-        $("#suggestions").dataTable($.extend(true, {}, dataTablesDefaults, {
-            'bPaginate': false,
-            'bFilter': false,
-            'bInfo': false,
-            'sDom': 't'
-        } ));
-    });
-</script>
 </head>
 
 <body id="pat_purchase_suggestions" class="pat">
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("#suggestions").dataTable($.extend(true, {}, dataTablesDefaults, {
+                'bPaginate': false,
+                'bFilter': false,
+                'bInfo': false,
+                'sDom': 't'
+            } ));
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 0a05865..8ca27f4 100644 (file)
@@ -2,39 +2,13 @@
 [% USE Koha %]
 [% USE AuthorisedValues %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Circulation History for [% INCLUDE 'patron-title.inc' no_html = 1 %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
-[% INCLUDE 'datatables.inc' %]
-<script type="text/javascript" id="js">
-//<![CDATA[
-
- $(document).ready(function() {
-    var table = $("#table_readingrec").dataTable($.extend(true, {}, dataTablesDefaults, {
-        "sPaginationType": "four_button",
-        "aaSorting": [],
-        "aoColumnDefs": [
-            { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
-            { "sType": "title-string", "aTargets" : [ "title-string" ] }
-        ]
-    }));
-    var tabs = $("#tabs").tabs({
-        activate: function(e, ui) {
-            var active = tabs.tabs("option", "active" );
-            if ( active == 1 ) {
-                table.fnFilter("standard_checkout", 0);
-            } else if ( active == 2 ) {
-                table.fnFilter("onsite_checkout", 0);
-            } else { // all
-                table.fnFilter('', 0);
-            }
-        }
-    });
- });
-//]]>
-</script>
 </head>
+
 <body id="pat_readingrec" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript" id="js">
+        $(document).ready(function() {
+            var table = $("#table_readingrec").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "sPaginationType": "four_button",
+                "aaSorting": [],
+                "aoColumnDefs": [
+                    { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
+                    { "sType": "title-string", "aTargets" : [ "title-string" ] }
+                ]
+            }));
+            var tabs = $("#tabs").tabs({
+                activate: function(e, ui) {
+                    var active = tabs.tabs("option", "active" );
+                    if ( active == 1 ) {
+                        table.fnFilter("standard_checkout", 0);
+                    } else if ( active == 2 ) {
+                        table.fnFilter("onsite_checkout", 0);
+                    } else { // all
+                        table.fnFilter('', 0);
+                    }
+                }
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 8fadc2b..9311d9a 100644 (file)
@@ -1,10 +1,12 @@
 [% USE Koha %]
 [% USE AuthorisedValues %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Subscription Routing Lists for [% INCLUDE 'patron-title.inc' no_html = 1 %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 </head>
+
 <body id="pat_routing_lists" class="pat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
@@ -80,4 +82,9 @@
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 35d4474..6519628 100644 (file)
@@ -1,6 +1,7 @@
 [% USE Koha %]
 [% USE AuthorisedValues %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo;
 [% UNLESS blocking_error %]
@@ -9,16 +10,6 @@
 </title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
-[% INCLUDE 'datatables.inc' %]
-[% INCLUDE 'calendar.inc' %]
-<script type="text/javascript">
-    $(document).ready(function() {
-        $("#statistics").dataTable($.extend(true, {}, dataTablesDefaults, {
-            "sDom": 't',
-            "bPaginate": false
-        }));
-    });
-</script>
 </head>
 
 <body id="pat_statistics" class="pat">
 [% INCLUDE 'circ-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("#statistics").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "sDom": 't',
+                "bPaginate": false
+            }));
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index d89dc2f..38e1324 100644 (file)
@@ -1,55 +1,21 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Choose Adult category</title>
+<title>Koha &rsaquo; Choose adult category</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
-[% INCLUDE 'datatables.inc' %]
-<script type="text/javascript">
-       $(document).ready(function() {
-        $("#catst").dataTable($.extend(true, {}, dataTablesDefaults, {
-            "sDom": 't',
-            "aaSorting": [[ 2, "asc" ]],
-            "aoColumnDefs": [
-                { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }
-            ],
-            "bPaginate": false
-        }));
-       });
-</script>
-<style type="text/css"> 
-          #custom-doc { width:29em;*width:28.3em;min-width:377px; margin:auto; text-align:left; } 
-</style> 
+<style type="text/css">
+    #custom-doc { width:29em;*width:28.3em;min-width:377px; margin:auto; text-align:left; }
+</style>
 </head>
+
 <body id="pat_update-child" class="pat">
 
 <div id="custom-doc" class="yui-t7">
 <div id="bd">
 
-[% IF ( CONFIRM ) %]
-<script type="text/javascript">
-function confirm_updatechild() {
-    var is_confirmed = window.confirm('Are you sure you want to update this child to an Adult category?  This cannot be undone.');
-   
-    if (is_confirmed) {
-            window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=[% borrowernumber %]&catcode=[% catcode %]&catcode_multi=[% CATCODE_MULTI %]';
-    }
-}
-
-confirm_updatechild([% borrowernumber %]);
-</script>
-[% END %]
-
-[% IF ( SUCCESS ) %]
-<script type="text/javascript">
-self.opener.location.href='/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]';
-window.close();
-</script>
-[% END %]
-
-
-
 [% IF ( MULTI ) %]
 
-    <h3> Choose Adult category </h3>
+    <h3> Choose adult category </h3>
 
     [% IF patron_categories %]
         <form method="post" action="update-child.pl">
@@ -87,10 +53,41 @@ window.close();
         </form>
     [% END %]
 [% END %]
+</div>
 
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("#catst").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "sDom": 't',
+                "aaSorting": [[ 2, "asc" ]],
+                "aoColumnDefs": [
+                    { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }
+                ],
+                "bPaginate": false
+            }));
+        });
+    </script>
+    [% IF ( CONFIRM ) %]
+        <script type="text/javascript">
+            function confirm_updatechild() {
+                var is_confirmed = window.confirm('Are you sure you want to update this child to an Adult category?  This cannot be undone.');
+                if (is_confirmed) {
+                        window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=[% borrowernumber %]&catcode=[% catcode %]&catcode_multi=[% CATCODE_MULTI %]';
+                }
+            }
 
+            confirm_updatechild([% borrowernumber %]);
+        </script>
+    [% END %]
+    [% IF ( SUCCESS ) %]
+        <script type="text/javascript">
+            self.opener.location.href='/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]';
+            window.close();
+        </script>
+    [% END %]
+[% END %]
 
-
-
-</div>
 [% INCLUDE 'popup-bottom.inc' %]
diff --git a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js b/koha-tmpl/intranet-tmpl/prog/js/members-menu.js
new file mode 100644 (file)
index 0000000..421cc7d
--- /dev/null
@@ -0,0 +1,154 @@
+/* global borrowernumber advsearch dateformat _ CAN_user_borrowers_edit_borrowers NorwegianPatronDBEnable CATCODE_MULTI catcode destination */
+
+$(document).ready(function(){
+    $("#filteraction_off, #filteraction_on").on('click', function(e) {
+        e.preventDefault();
+        $('#filters').toggle();
+        $('.filteraction').toggle();
+    });
+    if( advsearch ){
+        $("#filteraction_on").toggle();
+        $("#filters").show();
+    } else {
+        $("#filteraction_off").toggle();
+    }
+    $("#searchfieldstype").change(function() {
+        var MSG_DATE_FORMAT = "";
+        if ( $(this).val() == 'dateofbirth' ) {
+            if( dateformat == 'us' ){
+                MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'MM/DD/YYYY'");
+            } else if( dateformat == 'iso' ){
+                MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'YYYY-MM-DD'");
+            } else if( dateformat == 'metric' ){
+                MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD/MM/YYYY'");
+            } else if( dateformat == 'dmydot' ){
+                MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD.MM.YYYY'");
+            }
+            $('#searchmember').attr("title", MSG_DATE_FORMAT).tooltip('show');
+        } else {
+            $('#searchmember').tooltip('destroy');
+        }
+    });
+
+    if( CAN_user_borrowers_edit_borrowers ){
+        if( NorwegianPatronDBEnable == 1 ){
+            $("#deletepatronlocal").click(function(){
+                confirm_local_deletion();
+                $(".btn-group").removeClass("open");
+                return false;
+            });
+            $("#deletepatronremote").click(function(){
+                confirm_remote_deletion();
+                $(".btn-group").removeClass("open");
+                return false;
+            });
+            $("#deletepatronboth").click(function(){
+                confirm_both_deletion();
+                $(".btn-group").removeClass("open");
+                return false;
+            });
+        } else {
+            $("#deletepatron").click(function(){
+                window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber;
+            });
+        }
+        $("#renewpatron").click(function(){
+            confirm_reregistration();
+            $(".btn-group").removeClass("open");
+            return false;
+        });
+        $("#updatechild").click(function(){
+            update_child();
+            $(".btn-group").removeClass("open");
+        });
+    }
+
+    $("#updatechild, #patronflags, #renewpatron, #deletepatron, #exportbarcodes").tooltip();
+    $("#exportcheckins").click(function(){
+        export_barcodes();
+        $(".btn-group").removeClass("open");
+        return false;
+    });
+    $("#printsummary").click(function(){
+        printx_window("page");
+        $(".btn-group").removeClass("open");
+        return false;
+    });
+    $("#printslip").click(function(){
+        printx_window("slip");
+        $(".btn-group").removeClass("open");
+        return false;
+    });
+    $("#printquickslip").click(function(){
+        printx_window("qslip");
+        $(".btn-group").removeClass("open");
+        return false;
+    });
+    $("#print_overdues").click(function(){
+        window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=" + borrowernumber, "printwindow");
+        $(".btn-group").removeClass("open");
+        return false;
+    });
+    $("#searchtohold").click(function(){
+        searchToHold();
+        return false;
+    });
+    $("#select_patron_messages").on("change",function(){
+        $("#borrower_message").val( $(this).val() );
+    });
+});
+function confirm_local_deletion() {
+    var is_confirmed = window.confirm(_("Are you sure you want to delete this patron from the local database? This cannot be undone."));
+    if (is_confirmed) {
+        window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber + '&deletelocal=true&deleteremote=false';
+    }
+}
+function confirm_remote_deletion() {
+    var is_confirmed = window.confirm(_("Are you sure you want to delete this patron from the Norwegian national patron database? This cannot be undone."));
+    if (is_confirmed) {
+        window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber + '&deletelocal=false&deleteremote=true';
+    }
+}
+function confirm_both_deletion() {
+    var is_confirmed = window.confirm(_("Are you sure you want to delete this patron both from the local database and from the Norwegian national patron database? This cannot be undone."));
+    if (is_confirmed) {
+        window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber + '&deletelocal=true&deleteremote=true';
+    }
+}
+
+function confirm_updatechild() {
+    var is_confirmed = window.confirm(_("Are you sure you want to update this child to an Adult category?  This cannot be undone."));
+    if (is_confirmed) {
+        window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=' + borrowernumber + '&catcode=' + catcode + '&catcode_multi=' + CATCODE_MULTI;
+    }
+}
+
+function update_child() {
+    if( CATCODE_MULTI ){
+        window.open('/cgi-bin/koha/members/update-child.pl?op=multi&borrowernumber=' + borrowernumber,'UpdateChild','width=400,height=300,toolbar=no,scrollbars=yes,resizable=yes');
+    } else {
+        confirm_updatechild();
+    }
+}
+
+function confirm_reregistration() {
+    var is_confirmed = window.confirm(_("Are you sure you want to renew this patron's registration?"));
+    if (is_confirmed) {
+        window.location = '/cgi-bin/koha/members/setstatus.pl?borrowernumber=' + borrowernumber + '&amp;destination=' + destination + '&amp;reregistration=y';
+    }
+}
+function export_barcodes() {
+    window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=' + borrowernumber + '&amp;op=export_barcodes');
+}
+var slip_re = /slip/;
+function printx_window(print_type) {
+    var handler = print_type.match(slip_re) ? "printslip" : "summary-print";
+    window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=" + borrowernumber + "&amp;print=" + print_type, "printwindow");
+    return false;
+}
+function searchToHold(){
+    var date = new Date();
+    date.setTime(date.getTime() + (10 * 60 * 1000));
+    $.cookie("holdfor", borrowernumber, { path: "/", expires: date });
+    location.href="/cgi-bin/koha/catalogue/search.pl";
+}
diff --git a/koha-tmpl/intranet-tmpl/prog/js/messaging-preference-form.js b/koha-tmpl/intranet-tmpl/prog/js/messaging-preference-form.js
new file mode 100644 (file)
index 0000000..67a580b
--- /dev/null
@@ -0,0 +1,20 @@
+$(document).ready(function(){
+    $(".none").click(function(){
+        if($(this).prop("checked")){
+            var rowid = $(this).attr("id");
+            var newid = Number(rowid.replace("none",""));
+            $("#sms"+newid).prop("checked", false);
+            $("#email"+newid).prop("checked", false);
+            $("#phone"+newid).prop("checked", false);
+            $("#digest"+newid).prop("checked", false);
+            $("#rss"+newid).prop("checked", false);
+        }
+    });
+    $(".active_notify").on("change",function(){
+        var attr_id = $(this).data("attr-id");
+        if( $(this).prop("checked") ){
+            $("#none" + attr_id ).prop("checked", false);
+        }
+    });
+    $("#info_digests").tooltip();
+});
index aeeaf8b..cd2ca9b 100644 (file)
@@ -85,6 +85,30 @@ $(document).ready(function() {
         $("#itemSearchFallback").modal("show");
     });
 
+    // Debarments
+    $("div#reldebarments .remove_restriction").on("click",function(){
+        return confirm(_("Remove restriction?"));
+    });
+    var mrform = $("#manual_restriction_form");
+    var mrlink = $("#add_manual_restriction");
+    mrform.hide();
+    mrlink.on("click",function(e){
+        $(this).hide();
+        mrform.show();
+        e.preventDefault();
+    });
+    $("#cancel_manual_restriction").on("click",function(e){
+        mrlink.show();
+        mrform.hide();
+        e.preventDefault();
+    });
+    $(".clear-date").on("click",function(e){
+        e.preventDefault();
+        var fieldID = this.id.replace("clear-date-","");
+        $("#" + fieldID).val("");
+    });
+
+
 });
 
 function export_checkouts(format) {