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

(-)a/circ/ypattrodue-attr-search-authvalue.pl (-58 lines)
Lines 1-58 Link Here
1
#!/usr/bin/perl
2
3
# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
4
5
# Parts copyright 2012 Athens County Public Libraries
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# Koha is distributed in the hope that it will be useful, but
14
# WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
21
use Modern::Perl;
22
use CGI qw ( -utf8 );
23
use C4::Context;
24
use C4::Auth qw/check_cookie_auth/;
25
use C4::Debug;
26
27
my $input    = new CGI;
28
my $query    = $input->param('term');
29
my $attrcode = $input->path_info || '';
30
$attrcode =~ s|^/||;
31
32
my ( $auth_status, $sessionID ) = check_cookie_auth( $input->cookie('CGISESSID'), { circulate => '*' } );
33
exit 0 if $auth_status ne "ok";
34
35
binmode STDOUT, ":encoding(UTF-8)";
36
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
37
38
print STDERR ">> CALLING $0 (attrcode=$attrcode, query=$query)\n" if $debug;
39
40
my $dbh = C4::Context->dbh;
41
my $sql = qq(SELECT authorised_value, lib description
42
		FROM borrower_attribute_types b, authorised_values v
43
		WHERE b.code=?
44
			AND b.authorised_value_category = v.category
45
			AND v.lib like ?);
46
my $sth = $dbh->prepare($sql);
47
$sth->execute( $attrcode, "$query%" );
48
49
print "[";
50
my $i = 0;
51
while ( my $rec = $sth->fetchrow_hashref ) {
52
    print STDERR ">> attrcode=$attrcode match '$query' ==> $rec->{description} ($rec->{authorised_value})\n" if $debug;
53
    print "{\"description\":\"" . $rec->{description} . "\",\"" .
54
    "authorised_value\":\"" . $rec->{authorised_value} . "\"" .
55
    "}";
56
    $i++;
57
}
58
print "]";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt (-62 / +60 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE AuthorisedValues %]
3
[% USE KohaDates %]
4
[% USE KohaDates %]
4
[%- USE Branches -%]
5
[%- USE Branches -%]
5
[%- USE Price -%]
6
[%- USE Price -%]
Lines 10-18 Link Here
10
[% INCLUDE 'doc-head-open.inc' %]
11
[% INCLUDE 'doc-head-open.inc' %]
11
<title>Koha &rsaquo; Circulation &rsaquo; Items overdue as of [% todaysdate | html %]</title>
12
<title>Koha &rsaquo; Circulation &rsaquo; Items overdue as of [% todaysdate | html %]</title>
12
[% INCLUDE 'doc-head-close.inc' %]
13
[% INCLUDE 'doc-head-close.inc' %]
13
<style>
14
[% FILTER collapse %]
14
    .sql {display:none;}
15
    <style>
15
</style>
16
        .sql {display:none;}
17
        .select2-container--open .select2-dropdown--below,
18
        .select2-search.select2-search--dropdown {
19
            border: 1px solid #AAA;
20
        }
21
        .select2-container--open .select2-dropdown--below,
22
        .select2-search.select2-search--dropdown,
23
        .select2-results {
24
            background-color: #FFF;
25
            width: 20em !important;
26
        }
27
    </style>
28
[% END %]
16
</head>
29
</head>
17
30
18
<body id="circ_overdue" class="circ">
31
<body id="circ_overdue" class="circ">
Lines 160-182 Link Here
160
		<li>
173
		<li>
161
			<label>[% patron_attr_filter_loo.description | html %]:</label>
174
			<label>[% patron_attr_filter_loo.description | html %]:</label>
162
            [% IF ( patron_attr_filter_loo.authorised_value_category ) %]
175
            [% IF ( patron_attr_filter_loo.authorised_value_category ) %]
163
                <script type="text/javascript" x-code="[% patron_attr_filter_loo.code | html %]">create_auto_completion_responder([% patron_attr_filter_loo.domid | html %],"[% patron_attr_filter_loo.code | html %]");</script>
176
                [% SET authvals = AuthorisedValues.GetAuthValueDropbox( patron_attr_filter_loo.authorised_value_category ) %]
164
				<span id="pattrodue-getready-[% patron_attr_filter_loo.domid | html %]">
177
                <select id="pattrodue-input-[% patron_attr_filter_loo.domid | html %]" name="patron_attr_filter_[% patron_attr_filter_loo.code | html %]" class="pattrodue-input">
165
						<div class="pattrodue-autocomplete">
178
                    <option></option>
166
                            <input autocomplete="off" id="pattrodue-input-[% patron_attr_filter_loo.domid | html %]" name="patron_attr_filter_[% patron_attr_filter_loo.code | html %]" value="[% patron_attr_filter_loo.cgivalue | html %]"  class="pattrodue-input" type="text" />
179
                    [% FOREACH authval IN authvals %]
167
						</div>
180
                        [% IF ( patron_attr_filter_loo.cgivalue == authval.authorised_value ) -%]
168
				</span>
181
                            <option value="[% authval.authorised_value | html %]" selected="selected">[% authval.lib | html %]</option>
182
                        [% ELSE -%]
183
                            <option value="[% authval.authorised_value | html %]">[% authval.lib | html %]</option>
184
                        [% END %]
185
                    [% END %]
186
                </select>
169
			[% ELSE %]
187
			[% ELSE %]
170
                <input type="text" name="patron_attr_filter_[% patron_attr_filter_loo.code | html %]" value="[% patron_attr_filter_loo.cgivalue | html %]"/>
188
                <input type="text" name="patron_attr_filter_[% patron_attr_filter_loo.code | html %]" value="[% patron_attr_filter_loo.cgivalue | html %]"/>
171
			[% END %]
189
			[% END %]
172
			[% IF ( patron_attr_filter_loo.repeatable ) %]
190
			[% IF ( patron_attr_filter_loo.repeatable ) %]
173
                <a href="#" onclick="clone_parent(this); return false;">Add</a>
191
                <a href="#" class="btn btn-link clone-attribute" data-original-id="pattrodue-input-[% patron_attr_filter_loo.domid | html %]"><i class="fa fa-plus"></i> Add</a>
174
                [% IF ( patron_attr_filter_loo.isclone ) %]
192
                [% IF ( patron_attr_filter_loo.isclone ) %]
175
				    <a href="#" onclick="delete_parent(this); return false;" style="visibility: visible">Delete</a>
193
                    <a href="#" class="btn btn-link delete_clone"><i class="fa fa-remove"></i> Delete</a>
176
                [% ELSIF ( patron_attr_filter_loo.ismany ) %]
194
                [% ELSIF ( patron_attr_filter_loo.ismany ) %]
177
				    <a href="#" onclick="delete_parent(this); return false;" style="visibility: visible">Delete</a>
195
                    <a href="#" class="btn btn-link delete_clone"><i class="fa fa-remove"></i> Delete</a>
178
                [% ELSE %]
196
                [% ELSE %]
179
				    <a href="#" onclick="delete_parent(this); return false;" style="visibility: hidden">Delete</a>
197
                    <a href="#" class="btn btn-link delete_clone" style="display:none"><i class="fa fa-remove"></i> Delete</a>
180
                [% END %]
198
                [% END %]
181
			[% END %]
199
			[% END %]
182
		</li>
200
		</li>
Lines 230-287 Link Here
230
    [% INCLUDE 'calendar.inc' %]
248
    [% INCLUDE 'calendar.inc' %]
231
    [% INCLUDE 'datatables.inc' %]
249
    [% INCLUDE 'datatables.inc' %]
232
    [% INCLUDE 'columns_settings.inc' %]
250
    [% INCLUDE 'columns_settings.inc' %]
251
    [% INCLUDE 'select2.inc' %]
233
    <script>
252
    <script>
234
        function clone_parent(node) {
253
        function clone_input( node, original_id ) {
235
            var parent = node.parentNode;
254
            var original = node;
236
            var clone = parent.cloneNode(true);
255
            var clone = original.clone();
237
            parent.parentNode.insertBefore(clone, parent.nextSibling);
256
            var appendid = original_id + "-" + Math.floor(Math.random()*1000+1);
238
            $("a", clone).attr("style", "visibility: visible");
257
            clone.find(".delete_clone").show();
239
            $("input", clone).attr("value", "");
258
            if( clone.find("select").length ){
240
259
                /* <select> element is present */
241
            var theid = $("span", clone).attr("id") || "";
260
                clone.find("select").removeClass("select2-hidden-accessible").removeAttr("data-select2-id").attr("id", appendid );
242
            var theid = $("span", clone).attr("id") || "";
261
                clone.find(".select2").remove();
243
            var parts = theid.match(/^pattrodue-getready-(.*)$/);
262
                original.after( clone );
244
            if (parts && parts.length > 1){
263
                $("#" + appendid ).select2();
245
                var appendid = "-" + Math.floor(Math.random()*1000+1);
264
            } else {
246
                $("span", clone).attr("id",theid+appendid);
265
                clone.attr("id", appendid );
247
266
                original.after( clone );
248
                theid = $("input", clone).attr("id");
249
                $("input", clone).attr("id",theid+appendid);
250
251
                theid = $("div[id]", clone).attr("id");
252
                $("div[id]", clone).attr("id",theid+appendid);
253
254
                var attrcode = $("script", clone).attr("x-code");
255
                var newsuffix = parts[1] + appendid;
256
                create_auto_completion_responder(newsuffix,attrcode);
257
            }
267
            }
258
        }
268
        }
259
269
260
261
        function delete_parent(node) {
262
            var parent = node.parentNode;
263
            parent.parentNode.removeChild(parent);
264
        }
265
266
        function create_auto_completion_responder(uniqueid,attrcode) {
267
            $("#pattrodue-getready-" + uniqueid).ready(function(){
268
                $( "#pattrodue-input-" + uniqueid ).autocomplete({
269
                    source: "/cgi-bin/koha/circ/ypattrodue-attr-search-authvalue.pl/"+attrcode,
270
                    select: function( event, ui ) {
271
                        $( "#pattrodue-input-"+uniqueid ).val( ui.item.description );
272
                        return false;
273
                    }
274
                })
275
                .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
276
                    return $( "<li></li>" )
277
                    .data( "ui-autocomplete-item", item )
278
                    .append( "<a>" + item.description + " (" + item.authorised_value + ")</a>" )
279
                    .appendTo( ul )
280
                    .css("font-size","90%").css("width","13em");
281
                };
282
            });
283
        }
284
285
        function update_date_due_filters_visibility(){
270
        function update_date_due_filters_visibility(){
286
            if( $("#showall").is(":checked")) {
271
            if( $("#showall").is(":checked")) {
287
                $(".date_due_filter").hide();
272
                $(".date_due_filter").hide();
Lines 311-316 Link Here
311
                update_date_due_filters_visibility();
296
                update_date_due_filters_visibility();
312
            });
297
            });
313
            update_date_due_filters_visibility();
298
            update_date_due_filters_visibility();
299
300
            $(".pattrodue-input").each(function(){
301
                $(this).select2();
302
            });
303
304
            $("body").on("click", ".delete_clone", function(e){
305
                e.preventDefault();
306
                $(this).parent().remove();
307
            });
308
309
            $("body").on("click", ".clone-attribute", function(e){
310
                e.preventDefault();
311
                clone_input( $(this).parent(), $(this).data("original-id") );
312
            })
314
        });
313
        });
315
  </script>
314
  </script>
316
[% END %]
315
[% END %]
317
- 

Return to bug 16785