Bug 13021: guarantor search - prepare existing code to be reused
authorJonathan Druart <jonathan.druart@biblibre.com>
Thu, 2 Oct 2014 07:36:53 +0000 (09:36 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 19 Mar 2015 17:19:31 +0000 (14:19 -0300)
The add_user_search tt file will be reuse in next commits, this commit
just moves it in a "common" directory.

Signed-off-by: Morag Hills <the.invinnysible.one@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
acqui/add_user_search.pl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/add_user_search.tt [deleted file]
koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt [new file with mode: 0644]

index 646e217..6b6d18c 100755 (executable)
@@ -29,7 +29,7 @@ my $input = new CGI;
 my $dbh = C4::Context->dbh;
 
 my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
-    {   template_name   => "acqui/add_user_search.tt",
+    {   template_name   => "common/patron_search.tt",
         query           => $input,
         type            => "intranet",
         authnotrequired => 0,
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/add_user_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/add_user_search.tt
deleted file mode 100644 (file)
index 2a7233f..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-[% USE Koha %]
-[% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Patron search</title>
-[% INCLUDE 'doc-head-close.inc' %]
-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.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 %]
-
-    $("#searchmember_filter").on('keyup', function(){
-        filter();
-    });
-    // 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': 'template_path',
-                'value': 'acqui/tables/members_results.tt',
-            }
-            [% 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':[
-            { 'mDataProp': 'dt_cardnumber' },
-            { 'mDataProp': 'dt_name' },
-            { 'mDataProp': 'dt_branch' },
-            { 'mDataProp': 'dt_category' },
-            { 'mDataProp': 'dt_action', 'bSortable': false }
-        ],
-        'bAutoWidth': false,
-        [% IF patrons_with_acq_perm_only %]
-            'bPaginate': false,
-        [% ELSE %]
-            'sPaginationType': 'full_numbers',
-            "iDisplayLength": [% Koha.Preference('PatronsPerPage') %],
-        [% END %]
-        'bFilter': false,
-        'bProcessing': true,
-    }));
-    dtMemberResults.fnAddFilters("filter", 750);
-});
-
-var delay = (function(){
-  var timer = 0;
-  return function(callback, ms){
-    clearTimeout (timer);
-    timer = setTimeout(callback, ms);
-  };
-})();
-
-function filter() {
-    search = 1;
-
-    $("#searchresults").show();
-
-    if ( $("#searchmember_filter").val().length > 0 ) {
-        delay(function(){
-            dtMemberResults.fnDraw();
-        }, 1000);
-    }
-
-    return false;
-}
-
-    // modify parent window owner element
-    function add_user(borrowernumber, borrowername) {
-        var p = window.opener;
-        $("#info").hide();
-        $("#error").hide();
-        if ( p.add_user(borrowernumber, borrowername) < 0 ) {
-            $("#error").html(_("Borrower '%s' is already in the list.").format(borrowername));
-            $("#error").show();
-        } else {
-            $("#info").html(_("Borrower '%s' added.").format(borrowername));
-            $("#info").show();
-
-        }
-    }
-//]]>
-</script>
-
-</head>
-<body>
-<div id="patron_search" class="yui-t7">
-  <div id="bd">
-    <div class="yui-g">
-
-        <h3>Search for patron</h3>
-
-          <label for="searchmember_filter">Search:</label>
-          <input type="text" id="searchmember_filter" value="[% searchmember %]"/>
-
-        [% IF patrons_with_acq_perm_only %]
-            <div class="hint">Only staff with superlibrarian or acquisitions permissions (or order_manage permission if granular permissions are enabled) are returned in the search results</div>
-        [% END %]
-
-        <div id="info" class="dialog message"></div>
-        <div id="error" class="dialog alert"></div>
-
-        <div id="searchresults">
-            <table id="memberresultst">
-                <thead>
-                    <tr>
-                        <th>Card</th>
-                        <th>Name</th>
-                        <th>Library</th>
-                        <th>Category</th>
-                        <th>&nbsp;</th>
-                    </tr>
-                  </thead>
-                <tbody></tbody>
-            </table>
-        </div>
-
-<div id="closewindow"><a href="#" class="close">Close</a></div>
-</div>
-</div>
-[% INCLUDE 'intranet-bottom.inc' %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
new file mode 100644 (file)
index 0000000..2a7233f
--- /dev/null
@@ -0,0 +1,152 @@
+[% USE Koha %]
+[% INCLUDE 'doc-head-open.inc' %]
+<title>Koha &rsaquo; Patron search</title>
+[% INCLUDE 'doc-head-close.inc' %]
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.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 %]
+
+    $("#searchmember_filter").on('keyup', function(){
+        filter();
+    });
+    // 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': 'template_path',
+                'value': 'acqui/tables/members_results.tt',
+            }
+            [% 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':[
+            { 'mDataProp': 'dt_cardnumber' },
+            { 'mDataProp': 'dt_name' },
+            { 'mDataProp': 'dt_branch' },
+            { 'mDataProp': 'dt_category' },
+            { 'mDataProp': 'dt_action', 'bSortable': false }
+        ],
+        'bAutoWidth': false,
+        [% IF patrons_with_acq_perm_only %]
+            'bPaginate': false,
+        [% ELSE %]
+            'sPaginationType': 'full_numbers',
+            "iDisplayLength": [% Koha.Preference('PatronsPerPage') %],
+        [% END %]
+        'bFilter': false,
+        'bProcessing': true,
+    }));
+    dtMemberResults.fnAddFilters("filter", 750);
+});
+
+var delay = (function(){
+  var timer = 0;
+  return function(callback, ms){
+    clearTimeout (timer);
+    timer = setTimeout(callback, ms);
+  };
+})();
+
+function filter() {
+    search = 1;
+
+    $("#searchresults").show();
+
+    if ( $("#searchmember_filter").val().length > 0 ) {
+        delay(function(){
+            dtMemberResults.fnDraw();
+        }, 1000);
+    }
+
+    return false;
+}
+
+    // modify parent window owner element
+    function add_user(borrowernumber, borrowername) {
+        var p = window.opener;
+        $("#info").hide();
+        $("#error").hide();
+        if ( p.add_user(borrowernumber, borrowername) < 0 ) {
+            $("#error").html(_("Borrower '%s' is already in the list.").format(borrowername));
+            $("#error").show();
+        } else {
+            $("#info").html(_("Borrower '%s' added.").format(borrowername));
+            $("#info").show();
+
+        }
+    }
+//]]>
+</script>
+
+</head>
+<body>
+<div id="patron_search" class="yui-t7">
+  <div id="bd">
+    <div class="yui-g">
+
+        <h3>Search for patron</h3>
+
+          <label for="searchmember_filter">Search:</label>
+          <input type="text" id="searchmember_filter" value="[% searchmember %]"/>
+
+        [% IF patrons_with_acq_perm_only %]
+            <div class="hint">Only staff with superlibrarian or acquisitions permissions (or order_manage permission if granular permissions are enabled) are returned in the search results</div>
+        [% END %]
+
+        <div id="info" class="dialog message"></div>
+        <div id="error" class="dialog alert"></div>
+
+        <div id="searchresults">
+            <table id="memberresultst">
+                <thead>
+                    <tr>
+                        <th>Card</th>
+                        <th>Name</th>
+                        <th>Library</th>
+                        <th>Category</th>
+                        <th>&nbsp;</th>
+                    </tr>
+                  </thead>
+                <tbody></tbody>
+            </table>
+        </div>
+
+<div id="closewindow"><a href="#" class="close">Close</a></div>
+</div>
+</div>
+[% INCLUDE 'intranet-bottom.inc' %]