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    = CGI->new;
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 / +61 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>Items overdue as of [% todaysdate | html %] &rsaquo; Circulation &rsaquo; Koha</title>
12
<title>Items overdue as of [% todaysdate | html %] &rsaquo; Circulation &rsaquo; Koha</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 32-37 Link Here
32
                Overdues as of [% todaysdate | html %]
45
                Overdues as of [% todaysdate | html %]
33
            </a>
46
            </a>
34
        </li>
47
        </li>
48
    </ol>
35
</nav>
49
</nav>
36
50
37
<div class="main container-fluid">
51
<div class="main container-fluid">
Lines 173-195 Link Here
173
		<li>
187
		<li>
174
			<label>[% patron_attr_filter_loo.description | html %]:</label>
188
			<label>[% patron_attr_filter_loo.description | html %]:</label>
175
            [% IF ( patron_attr_filter_loo.authorised_value_category ) %]
189
            [% IF ( patron_attr_filter_loo.authorised_value_category ) %]
176
                <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>
190
                [% SET authvals = AuthorisedValues.GetAuthValueDropbox( patron_attr_filter_loo.authorised_value_category ) %]
177
				<span id="pattrodue-getready-[% patron_attr_filter_loo.domid | html %]">
191
                <select id="pattrodue-input-[% patron_attr_filter_loo.domid | html %]" name="patron_attr_filter_[% patron_attr_filter_loo.code | html %]" class="pattrodue-input">
178
						<div class="pattrodue-autocomplete">
192
                    <option></option>
179
                            <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" />
193
                    [% FOREACH authval IN authvals %]
180
						</div>
194
                        [% IF ( patron_attr_filter_loo.cgivalue == authval.authorised_value ) -%]
181
				</span>
195
                            <option value="[% authval.authorised_value | html %]" selected="selected">[% authval.lib | html %]</option>
196
                        [% ELSE -%]
197
                            <option value="[% authval.authorised_value | html %]">[% authval.lib | html %]</option>
198
                        [% END %]
199
                    [% END %]
200
                </select>
182
			[% ELSE %]
201
			[% ELSE %]
183
                <input type="text" name="patron_attr_filter_[% patron_attr_filter_loo.code | html %]" value="[% patron_attr_filter_loo.cgivalue | html %]"/>
202
                <input type="text" name="patron_attr_filter_[% patron_attr_filter_loo.code | html %]" value="[% patron_attr_filter_loo.cgivalue | html %]"/>
184
			[% END %]
203
			[% END %]
185
			[% IF ( patron_attr_filter_loo.repeatable ) %]
204
			[% IF ( patron_attr_filter_loo.repeatable ) %]
186
                <a href="#" onclick="clone_parent(this); return false;">Add</a>
205
                <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>
187
                [% IF ( patron_attr_filter_loo.isclone ) %]
206
                [% IF ( patron_attr_filter_loo.isclone ) %]
188
				    <a href="#" onclick="delete_parent(this); return false;" style="visibility: visible">Delete</a>
207
                    <a href="#" class="btn btn-link delete_clone"><i class="fa fa-remove"></i> Delete</a>
189
                [% ELSIF ( patron_attr_filter_loo.ismany ) %]
208
                [% ELSIF ( patron_attr_filter_loo.ismany ) %]
190
				    <a href="#" onclick="delete_parent(this); return false;" style="visibility: visible">Delete</a>
209
                    <a href="#" class="btn btn-link delete_clone"><i class="fa fa-remove"></i> Delete</a>
191
                [% ELSE %]
210
                [% ELSE %]
192
				    <a href="#" onclick="delete_parent(this); return false;" style="visibility: hidden">Delete</a>
211
                    <a href="#" class="btn btn-link delete_clone" style="display:none"><i class="fa fa-remove"></i> Delete</a>
193
                [% END %]
212
                [% END %]
194
			[% END %]
213
			[% END %]
195
		</li>
214
		</li>
Lines 243-300 Link Here
243
    [% INCLUDE 'calendar.inc' %]
262
    [% INCLUDE 'calendar.inc' %]
244
    [% INCLUDE 'datatables.inc' %]
263
    [% INCLUDE 'datatables.inc' %]
245
    [% INCLUDE 'columns_settings.inc' %]
264
    [% INCLUDE 'columns_settings.inc' %]
265
    [% INCLUDE 'select2.inc' %]
246
    <script>
266
    <script>
247
        function clone_parent(node) {
267
        function clone_input( node, original_id ) {
248
            var parent = node.parentNode;
268
            var original = node;
249
            var clone = parent.cloneNode(true);
269
            var clone = original.clone();
250
            parent.parentNode.insertBefore(clone, parent.nextSibling);
270
            var appendid = original_id + "-" + Math.floor(Math.random()*1000+1);
251
            $("a", clone).attr("style", "visibility: visible");
271
            clone.find(".delete_clone").show();
252
            $("input", clone).attr("value", "");
272
            if( clone.find("select").length ){
253
273
                /* <select> element is present */
254
            var theid = $("span", clone).attr("id") || "";
274
                clone.find("select").removeClass("select2-hidden-accessible").removeAttr("data-select2-id").attr("id", appendid );
255
            var theid = $("span", clone).attr("id") || "";
275
                clone.find(".select2").remove();
256
            var parts = theid.match(/^pattrodue-getready-(.*)$/);
276
                original.after( clone );
257
            if (parts && parts.length > 1){
277
                $("#" + appendid ).select2();
258
                var appendid = "-" + Math.floor(Math.random()*1000+1);
278
            } else {
259
                $("span", clone).attr("id",theid+appendid);
279
                clone.attr("id", appendid );
260
280
                original.after( clone );
261
                theid = $("input", clone).attr("id");
262
                $("input", clone).attr("id",theid+appendid);
263
264
                theid = $("div[id]", clone).attr("id");
265
                $("div[id]", clone).attr("id",theid+appendid);
266
267
                var attrcode = $("script", clone).attr("x-code");
268
                var newsuffix = parts[1] + appendid;
269
                create_auto_completion_responder(newsuffix,attrcode);
270
            }
281
            }
271
        }
282
        }
272
283
273
274
        function delete_parent(node) {
275
            var parent = node.parentNode;
276
            parent.parentNode.removeChild(parent);
277
        }
278
279
        function create_auto_completion_responder(uniqueid,attrcode) {
280
            $("#pattrodue-getready-" + uniqueid).ready(function(){
281
                $( "#pattrodue-input-" + uniqueid ).autocomplete({
282
                    source: "/cgi-bin/koha/circ/ypattrodue-attr-search-authvalue.pl/"+attrcode,
283
                    select: function( event, ui ) {
284
                        $( "#pattrodue-input-"+uniqueid ).val( ui.item.description );
285
                        return false;
286
                    }
287
                })
288
                .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
289
                    return $( "<li></li>" )
290
                    .data( "ui-autocomplete-item", item )
291
                    .append( "<a>" + item.description + " (" + item.authorised_value + ")</a>" )
292
                    .appendTo( ul )
293
                    .css("font-size","90%").css("width","13em");
294
                };
295
            });
296
        }
297
298
        function update_date_due_filters_visibility(){
284
        function update_date_due_filters_visibility(){
299
            if( $("#showall").is(":checked")) {
285
            if( $("#showall").is(":checked")) {
300
                $(".date_due_filter").hide();
286
                $(".date_due_filter").hide();
Lines 320-325 Link Here
320
                update_date_due_filters_visibility();
306
                update_date_due_filters_visibility();
321
            });
307
            });
322
            update_date_due_filters_visibility();
308
            update_date_due_filters_visibility();
309
310
            $(".pattrodue-input").each(function(){
311
                $(this).select2();
312
            });
313
314
            $("body").on("click", ".delete_clone", function(e){
315
                e.preventDefault();
316
                $(this).parent().remove();
317
            });
318
319
            $("body").on("click", ".clone-attribute", function(e){
320
                e.preventDefault();
321
                clone_input( $(this).parent(), $(this).data("original-id") );
322
            })
323
        });
323
        });
324
  </script>
324
  </script>
325
[% END %]
325
[% END %]
326
- 

Return to bug 16785