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

(-)a/C4/Utils/DataTables/VirtualShelves.pm (+196 lines)
Line 0 Link Here
1
package C4::Utils::DataTables::VirtualShelves;
2
3
use Modern::Perl;
4
use C4::Branch qw/onlymine/;
5
use C4::Context;
6
use C4::Members qw/GetMemberIssuesAndFines/;
7
use C4::Utils::DataTables;
8
use C4::VirtualShelves;
9
10
sub search {
11
    my ( $params ) = @_;
12
    my $shelfname = $params->{shelfname};
13
    my $count = $params->{count};
14
    my $owner = $params->{owner};
15
    my $sortby = $params->{sortby};
16
    my $type = $params->{type};
17
    my $dt_params = $params->{dt_params};
18
19
    # public is default
20
    $type = 2 if not $type or $type != 1;
21
22
    # If not logged in user, be carreful and set the borrowernumber to 0
23
    # to prevent private lists lack
24
    my $loggedinuser = C4::Context->userenv->{'number'} || 0;
25
26
    my ($iTotalRecords, $iTotalDisplayRecords);
27
28
    my $dbh = C4::Context->dbh;
29
30
    # FIXME refactore the following queries
31
    # We should call C4::VirtualShelves::GetShelves and C4::VirtualShelves::GetAllShelves
32
    # But the code is too dirty to refactor...
33
    my $select = q|
34
        SELECT vs.shelfnumber, vs.shelfname, vs.owner, vs.category AS type,
35
        bo.surname, bo.firstname, vs.sortfield as sortby,
36
        count(vc.biblionumber) as count
37
    |;
38
39
    my $from_total = q|
40
        FROM virtualshelves vs
41
        LEFT JOIN borrowers bo ON vs.owner=bo.borrowernumber
42
    |;
43
44
    my $from = $from_total . q|
45
        LEFT JOIN virtualshelfcontents vc USING( shelfnumber )
46
    |;
47
48
    my @args;
49
    # private
50
    if ( $type == 1 ) {
51
        my $join_vs .= q|
52
            LEFT JOIN virtualshelfshares sh ON sh.shelfnumber = vs.shelfnumber
53
            AND sh.borrowernumber = ?
54
        |;
55
        $from .= $join_vs;
56
        $from_total .= $join_vs;
57
        push @args, $loggedinuser;
58
59
    }
60
61
    my @where_strs;
62
63
    if ( defined $shelfname and $shelfname ne '' ) {
64
        push @where_strs, 'shelfname LIKE ?';
65
        push @args, 'shelfname%';
66
    }
67
    if ( defined $count and $count ne '' ) {
68
        push @where_strs, 'count = ?';
69
        push @args, $count;
70
    }
71
    if ( defined $owner and $owner ne '' ) {
72
        push @where_strs, 'owner LIKE ?';
73
        push @args, 'owner%';
74
        # FIXME search borronumber by name??
75
        # WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?);
76
    }
77
    if ( defined $sortby and $sortby ne '' ) {
78
        push @where_strs, 'sortfield = ?';
79
        push @args, 'sortfield';
80
    }
81
82
83
    push @where_strs, 'category = ?';
84
    push @args, $type;
85
86
    if ( $type == 1 ) {
87
        push @where_strs, '(vs.owner = ? OR sh.borrowernumber = ?)';
88
        push @args, $loggedinuser, $loggedinuser;
89
    }
90
91
    my $where;
92
    $where = " WHERE " . join (" AND ", @where_strs) if @where_strs;
93
    my $orderby = dt_build_orderby($dt_params);
94
    $orderby =~ s|shelfnumber|vs.shelfnumber|;
95
96
    my $limit;
97
    # If iDisplayLength == -1, we want to display all shelves
98
    if ( $dt_params->{iDisplayLength} > -1 ) {
99
        # In order to avoid sql injection
100
        $dt_params->{iDisplayStart} =~ s/\D//g;
101
        $dt_params->{iDisplayLength} =~ s/\D//g;
102
        $dt_params->{iDisplayStart} //= 0;
103
        $dt_params->{iDisplayLength} //= 20;
104
        $limit = "LIMIT $dt_params->{iDisplayStart},$dt_params->{iDisplayLength}";
105
    }
106
107
    my $group_by = " GROUP BY vs.shelfnumber";
108
109
    my $query = join(
110
        " ",
111
        $select,
112
        $from,
113
        ($where ? $where : ""),
114
        $group_by,
115
        ($orderby ? $orderby : ""),
116
        ($limit ? $limit : "")
117
    );
118
    my $sth = $dbh->prepare($query);
119
    $sth->execute(@args);
120
121
    my $shelves = $sth->fetchall_arrayref({});
122
123
    # Get the iTotalDisplayRecords DataTable variable
124
    $query = "SELECT COUNT(vs.shelfnumber) " . $from_total . ($where ? $where : "");
125
    ($iTotalDisplayRecords) = $dbh->selectrow_array( $query, undef, @args );
126
127
    # Get the iTotalRecords DataTable variable
128
    $query = q|SELECT COUNT(vs.shelfnumber)| . $from_total . q| WHERE category = ?|;
129
    $query .= q| AND (vs.owner = ? OR sh.borrowernumber = ?)| if $type == 1;
130
    @args = $type == 1 ? ( $loggedinuser, $type, $loggedinuser, $loggedinuser ) : ( $type );
131
    ( $iTotalRecords ) = $dbh->selectrow_array( $query, undef, @args );
132
133
    for my $shelf ( @$shelves ) {
134
        $shelf->{can_manage_shelf} = C4::VirtualShelves::ShelfPossibleAction( $loggedinuser, $shelf->{shelfnumber}, 'manage' );
135
        $shelf->{can_delete_shelf} = C4::VirtualShelves::ShelfPossibleAction( $loggedinuser, $shelf->{shelfnumber}, 'delete_shelf' );
136
    }
137
    return {
138
        iTotalRecords => $iTotalRecords,
139
        iTotalDisplayRecords => $iTotalDisplayRecords,
140
        shelves => $shelves,
141
    }
142
}
143
144
1;
145
__END__
146
147
=head1 NAME
148
149
C4::Utils::DataTables::VirtualShelves - module for using DataTables with virtual shelves
150
151
=head1 SYNOPSIS
152
153
This module provides routines used by the virtual shelves search
154
155
=head2 FUNCTIONS
156
157
=head3 search
158
159
    my $dt_infos = C4::Utils::DataTables::VirtualShelves->search($params);
160
161
$params is a hashref with some keys:
162
163
=over 4
164
165
=item shelfname
166
167
=item count
168
169
=item sortby
170
171
=item type
172
173
=item dt_params
174
175
=cut
176
177
=back
178
179
=head1 LICENSE
180
181
This file is part of Koha.
182
183
Copyright 2014 BibLibre
184
185
Koha is free software; you can redistribute it and/or modify it
186
under the terms of the GNU General Public License as published by
187
the Free Software Foundation; either version 3 of the License, or
188
(at your option) any later version.
189
190
Koha is distributed in the hope that it will be useful, but
191
WITHOUT ANY WARRANTY; without even the implied warranty of
192
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
193
GNU General Public License for more details.
194
195
You should have received a copy of the GNU General Public License
196
along with Koha; if not, see <http://www.gnu.org/licenses>.
(-)a/C4/VirtualShelves/Page.pm (-4 / +5 lines)
Lines 473-483 sub shelfpage { Link Here
473
        "BiblioDefaultView" . C4::Context->preference("BiblioDefaultView") => 1,
473
        "BiblioDefaultView" . C4::Context->preference("BiblioDefaultView") => 1,
474
        csv_profiles                                                       => GetCsvProfilesLoop('marc')
474
        csv_profiles                                                       => GetCsvProfilesLoop('marc')
475
    );
475
    );
476
    if (   $shelfnumber
476
477
        or $shelves
477
    unless( $shelfnumber or $shelves or $edit ) {
478
        or $edit ) {
478
        # Only used for intranet
479
        $template->param( vseflag => 1 );
479
        $template->param( op => 'list' );
480
    }
480
    }
481
481
    if ($shelves or    # note: this part looks duplicative, but is intentional
482
    if ($shelves or    # note: this part looks duplicative, but is intentional
482
        $edit
483
        $edit
483
      ) {
484
      ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (-115 / +84 lines)
Lines 1-6 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; [% IF ( viewshelf ) %]Lists &rsaquo; Contents of [% shelfname | html %][% ELSE %]Lists[% END %][% IF ( shelves ) %] &rsaquo; Create new list[% END %][% IF ( edit ) %] &rsaquo; Edit list [% shelfname | html %][% END %]</title>
2
<title>Koha &rsaquo; [% IF ( viewshelf ) %]Lists &rsaquo; Contents of [% shelfname | html %][% ELSE %]Lists[% END %][% IF ( shelves ) %] &rsaquo; Create new list[% END %][% IF ( edit ) %] &rsaquo; Edit list [% shelfname | html %][% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
5
[% INCLUDE 'datatables.inc' %]
4
[% IF ( viewshelf ) %]
6
[% IF ( viewshelf ) %]
5
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
7
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
6
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
8
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
Lines 11-16 Link Here
11
var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
13
var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
12
var MSG_REMOVE_FROM_LIST = _("Are you sure you want to remove these items from the list?");
14
var MSG_REMOVE_FROM_LIST = _("Are you sure you want to remove these items from the list?");
13
var MSG_CONFIRM_DELETE_LIST = _("Are you sure you want to remove this list?");
15
var MSG_CONFIRM_DELETE_LIST = _("Are you sure you want to remove this list?");
16
17
[% IF op == 'list' %]
18
$(document).ready(function(){
19
    var type = 1;
20
    var dtListResults = $("#listresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
21
        'bServerSide': true,
22
        'sAjaxSource': "/cgi-bin/koha/svc/virtualshelves/search",
23
        'fnServerData': function(sSource, aoData, fnCallback) {
24
            aoData.push({
25
                'name': 'type',
26
                'value': type,
27
            },
28
            {
29
                'name': 'template_path',
30
                'value': 'virtualshelves/tables/shelves_results.tt',
31
            });
32
            $.ajax({
33
                'dataType': 'json',
34
                'type': 'POST',
35
                'url': sSource,
36
                'data': aoData,
37
                'success': function(json){
38
                    fnCallback(json);
39
                }
40
            });
41
        },
42
        'aoColumns':[
43
            { 'mDataProp': 'dt_type' },
44
            { 'mDataProp': 'dt_shelfname' },
45
            { 'mDataProp': 'dt_count' },
46
            { 'mDataProp': 'dt_owner' },
47
            { 'mDataProp': 'dt_sortby' },
48
            { 'mDataProp': 'dt_action', 'bSortable': false }
49
        ],
50
        "aoColumnDefs": [
51
            { "bVisible": false, "aTargets": [ 'NoVisible' ] }
52
        ],
53
        'bAutoWidth': false,
54
        'sPaginationType': 'full_numbers',
55
        "bProcessing": true,
56
        'bFilter': false
57
    }));
58
59
    dtListResults.fnAddFilters("filter", 750);
60
61
    var tabs = $("#tabs").tabs({
62
        activate: function(e, ui) {
63
            var active = tabs.tabs("option", "active" );
64
            if ( active == 0 ) {
65
                type = 1; // private
66
                dtListResults.fnDraw();
67
            } else if ( active == 1 ) {
68
                type = 2; // public
69
                dtListResults.fnDraw();
70
            }
71
        }
72
    });
73
});
74
[% END %]
75
14
[% IF ( viewshelf ) %]
76
[% IF ( viewshelf ) %]
15
$(document).ready(function(){
77
$(document).ready(function(){
16
    [% IF ( itemsloop ) %]$('#searchheader').fixFloat();[% END %]
78
    [% IF ( itemsloop ) %]$('#searchheader').fixFloat();[% END %]
Lines 514-636 function placeHold () { Link Here
514
</div>
576
</div>
515
[% END %]<!-- /seflag -->
577
[% END %]<!-- /seflag -->
516
578
517
[% UNLESS ( vseflag ) %]
579
[% IF op == 'list' %]
518
        <h2>Lists</h2>
580
    <h2>Lists</h2>
519
        <div class="statictabs">
581
    <div id="tabs" class="toptabs">
520
        <ul>
582
        <ul>
521
        [% IF ( showprivateshelves ) %]
583
            <li id="privateshelves_tab" class="active"><a href="#tab_content">Your lists</a></li>
522
            <li id="privateshelves_tab" class="active"><a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your lists</a></li>
584
            <li id="publicshelves_tab" class="active"><a href="#tab_content">Public lists</a></li>
523
        [% ELSE %]
524
            <li id="privateshelves_tab" class=""><a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your lists</a></li>
525
        [% END %]
526
        [% IF ( showpublicshelves ) %]
527
            <li id="publicshelves_tab" class="active"><a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public lists</a></li>
528
        [% ELSE %]
529
            <li id="publicshelves_tab" class=""><a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public lists</a></li>
530
        [% END %]
531
        </ul>
585
        </ul>
532
        [% IF ( showprivateshelves ) %]
586
533
        <div id="privateshelves" class="tabs-container" style="display:block;">
587
        <div id="tab_content">
534
		[% ELSE %]
588
            <table id="listresultst">
535
        <div id="privateshelves" class="tabs-container" style="display:none;">
589
                <thead>
536
		[% END %]
590
                    <tr>
537
            [% IF ( shelveslooppriv ) %]
591
                        <th class="NoVisible">Type</th>
538
			<div class="pages">[% pagination_bar %]</div>
592
                        <th>List name</th>
539
        		<table>
593
                        <th>Contents</th>
540
        		<tr><th>List Name</th><th>Contents</th><th>Sort by</th><th>Type</th><th>Options</th></tr>
594
                        <th>Owner</th>
541
                [% FOREACH shelveslooppri IN shelveslooppriv %]
595
                        <th>Sort by</th>
542
                    [% IF ( shelveslooppri.toggle ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
596
                        <th>Actions</th>
543
        <td><a href="shelves.pl?[% IF ( shelveslooppri.showprivateshelves ) %]display=privateshelves&amp;[% END %]viewshelf=[% shelveslooppri.shelf %]&amp;shelfoff=[% shelfoff %]">[% shelveslooppri.shelfname |html %]</a></td>
597
                    </tr>
544
        <td>[% shelveslooppri.count %] item(s)</td>
598
                </thead>
545
        <td>[% IF ( shelveslooppri.sortfield == "author" ) %]Author[% ELSIF ( shelveslooppri.sortfield == "copyrightdate" ) %]Year[% ELSIF (shelveslooppri.sortfield == "itemcallnumber") %]Call number[% ELSE %]Title[% END %]</td>
599
                <tbody></tbody>
546
        <td>[% IF ( shelveslooppri.viewcategory1 ) %][% IF !shelveslooppri.shares %]Private[% ELSE %]Shared[% END %][% END %]
600
            </table>
547
			[% IF ( shelveslooppri.viewcategory2 ) %]Public[% END %]
601
        </div>
548
		</td>
602
    </div>
549
        <td>
550
            [% IF ( shelveslooppri.mine ) %]
551
				<form action="merge.pl" method="get">
552
					<input type="hidden" name="shelf" value="[% shelveslooppri.shelf %]" />
553
				</form>
554
				<form action="shelves.pl" method="get">
555
					<input type="hidden" name="shelfnumber" value="[% shelveslooppri.shelf %]" />
556
					<input type="hidden" name="op" value="modif" />
557
                    <input type="hidden" name="display" value="privateshelves" />
558
					<input type="submit" class="editshelf" value="Edit" />
559
				</form>
560
				<form action="shelves.pl" method="post">
561
				    <input type="hidden" name="shelfoff" value="[% shelfoff %]" />
562
					<input type="hidden" name="shelves" value="1" />
563
                    <input type="hidden" name="display" value="privateshelves" />
564
					<input type="hidden" name="DEL-[% shelveslooppri.shelf %]" value="1" />
565
					[% IF ( shelveslooppri.confirm ) %]
566
					<input type="hidden" name="CONFIRM-[% shelveslooppri.confirm %]" value="1" />
567
					<input type="submit" class="approve" value="Confirm" />
568
					[% ELSE %]
569
                    <input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST);" value="Delete" />
570
					[% END %]
571
				</form>
572
			[% ELSE %]
573
				None
574
			[% END %]
575
		</td>
576
		</tr>
577
                [% END %]
578
        </table>
579
            [% ELSE %]
580
            <p>No private lists.</p>
581
            [% END %]<!-- /shelveslooppriv -->
582
		</div><!-- /privateshelves -->
583
584
        [% IF ( showpublicshelves ) %]
585
        <div id="publicshelves" class="tabs-container" style="display:block;">
586
		[% ELSE %]
587
        <div id="publicshelves" class="tabs-container" style="display:none;">
588
		[% END %]
589
        [% IF ( shelvesloop ) %]
590
		<div class="pages">[% pagination_bar %]</div>
591
        <table>
592
        <tr><th>List Name</th><th>Created by</th><th>Contents</th><th>Sort By</th><th>Type</th><th>Options</th></tr>
593
            [% FOREACH shelvesloo IN shelvesloop %]
594
                [% IF ( shelvesloo.toggle ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
595
		<td><a href="shelves.pl?viewshelf=[% shelvesloo.shelf %]">[% shelvesloo.shelfname |html %]</a></td>
596
        <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% shelvesloo.owner %]">[% shelvesloo.ownername %]</td>
597
		<td>[% shelvesloo.count %] item(s)</td>
598
        <td>[% IF ( shelvesloo.sortfield == "author" ) %]Author[% ELSIF ( shelvesloo.sortfield == "copyrightdate" ) %]Year[% ELSIF (shelvesloo.sortfield == "itemcallnumber") %]Call number[% ELSE %]Title[% END %]</td>
599
        <td>[% IF ( shelvesloo.viewcategory1 ) %]Private[% END %]
600
			[% IF ( shelvesloo.viewcategory2 ) %]Public[% END %]
601
		</td>
602
        <td>
603
            [% IF shelvesloo.manageshelf %]
604
				<form action="shelves.pl" method="get">
605
					<input type="hidden" name="shelfnumber" value="[% shelvesloo.shelf %]" />
606
					<input type="hidden" name="op" value="modif" />
607
					<input type="submit" class="editshelf" value="Edit" />
608
				</form>
609
            [% END %]
610
            [% IF shelvesloo.manageshelf OR shelvesloo.allowdeletingshelf %]
611
				<form action="shelves.pl" method="post">
612
				        <input type="hidden" name="shelfoff" value="[% shelfoff %]" />
613
					<input type="hidden" name="shelves" value="1" />
614
					<input type="hidden" name="DEL-[% shelvesloo.shelf %]" value="1" />
615
					[% IF ( shelvesloo.confirm ) %]
616
					<input type="hidden" name="CONFIRM-[% shelvesloo.confirm %]" value="1" />
617
					<input type="submit" class="approve" value="Confirm" />
618
					[% ELSE %]
619
                    <input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST);" value="Delete" />
620
					[% END %]
621
				</form>
622
			[% ELSE %]
623
				None
624
			[% END %]
625
		</td>
626
		</tr>
627
            [% END %]
628
        </table>
629
        [% ELSE %]
630
            [% IF ( showpublicshelves ) %]<p>No public lists.</p>[% END %]
631
        [% END %]<!-- /shelvesloop -->
632
        </div><!-- /publicshelves -->
633
		</div>
634
[% END %]
603
[% END %]
635
604
636
<form id="hold_form" method="get" action="/cgi-bin/koha/reserve/request.pl">
605
<form id="hold_form" method="get" action="/cgi-bin/koha/reserve/request.pl">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt (+31 lines)
Line 0 Link Here
1
{
2
    "sEcho": [% sEcho %],
3
    "iTotalRecords": [% iTotalRecords %],
4
    "iTotalDisplayRecords": [% iTotalDisplayRecords %],
5
    "aaData": [
6
        [% FOREACH data IN aaData %]
7
            {
8
                "dt_type":
9
                    "[% data.type %]",
10
                "dt_shelfname":
11
                    "<a href='cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% data.shelfnumber %]'>[% data.shelfname %]</a>",
12
                "dt_count":
13
                    "[% data.count %] item(s)",
14
                "dt_owner":
15
                    "<a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=[% data.owner %]'>[% data.firstname %] [% data.surname %]</a>",
16
                "dt_sortby":
17
                    [% IF data.sortby == "author" %]"Author"[% ELSIF data.sortby == "copyrightdate" %]"Year"[% ELSIF data.sortby == "itemcallnumber" %]"Call number"[% ELSE %]"Title"[% END %],
18
                "dt_action":
19
                    "<a style=\"cursor:pointer\">[% PROCESS action_form shelfnumber=data.shelfnumber can_manage_shelf=data.can_manage_shelf can_delete_shelf=data.can_delete_shelf type=data.type %]</a>"
20
            }[% UNLESS loop.last %],[% END %]
21
        [% END %]
22
    ]
23
}
24
25
[% BLOCK action_form -%]
26
    [%- IF can_manage_shelf -%]
27
<form action='shelves.pl' method='get'><input type='hidden' name='shelfnumber' value='[% shelfnumber %]' /><input type='hidden' name='op' value='modif' /><input type='submit' class='editshelf' value='Edit' /></form>[% IF can_manage_shelf OR can_delete_shelf %]<form action='shelves.pl' method='post'><input type='hidden' name='shelfoff' value='[% shelfoff %]' /><input type='hidden' name='shelves' value='1' /><input type='hidden' name='DEL-[% shelfnumber %]' value='1' /><input type='hidden' name='CONFIRM-[% shelfnumber %]' value='1' />[% IF type == 1 %]<input type='hidden' name='display' value='privateshelves' />[% ELSE %]<input type='hidden' name='display' value='publicshelves' />[% END %]<input type='submit' class='deleteshelf' onclick='return confirmDelete(MSG_CONFIRM_DELETE_LIST)' value='Delete' /></form>[% END %]
28
    [%- ELSE -%]
29
        None
30
    [%- END -%]
31
[%- END %]
(-)a/svc/virtualshelves/search (-1 / +88 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use CGI;
5
6
use C4::Auth qw( get_template_and_user );
7
use C4::Output qw( output_with_http_headers );
8
use C4::Utils::DataTables qw( dt_get_params );
9
use C4::Utils::DataTables::VirtualShelves qw( search );
10
11
my $input = new CGI;
12
13
exit unless $input->param('template_path');
14
15
my ($template, $user, $cookie) = get_template_and_user({
16
    template_name   => $input->param('template_path'),
17
    query           => $input,
18
    type            => "intranet",
19
    authnotrequired => 0,
20
    flagsrequired   => { borrowers => 1 }
21
});
22
23
my $shelfname = $input->param('shelfname');
24
my $count = $input->param('count');
25
my $owner = $input->param('owner');
26
my $type = $input->param('type');
27
my $sortby = $input->param('sortby');
28
29
# variable information for DataTables (id)
30
my $sEcho = $input->param('sEcho');
31
32
my %dt_params = dt_get_params($input);
33
foreach (grep {$_ =~ /^mDataProp/} keys %dt_params) {
34
    $dt_params{$_} =~ s/^dt_//;
35
}
36
37
my $results = C4::Utils::DataTables::VirtualShelves::search(
38
    {
39
        shelfname => $shelfname,
40
        count => $count,
41
        owner => $owner,
42
        type => $type,
43
        sortby => $sortby,
44
        dt_params => \%dt_params,
45
    }
46
);
47
48
$template->param(
49
    sEcho => $sEcho,
50
    iTotalRecords => $results->{iTotalRecords},
51
    iTotalDisplayRecords => $results->{iTotalDisplayRecords},
52
    aaData => $results->{shelves}
53
);
54
55
output_with_http_headers $input, $cookie, $template->output, 'json';
56
57
__END__
58
59
=head1 NAME
60
61
search - a search script for finding virtual shelves
62
63
=head1 SYNOPSIS
64
65
This script provides a service for template for virtual shelves search using DataTables
66
67
=cut
68
69
=back
70
71
=head1 LICENSE
72
73
Copyright 2014 BibLibre
74
75
This file is part of Koha.
76
77
Koha is free software; you can redistribute it and/or modify it under the
78
terms of the GNU General Public License as published by the Free Software
79
Foundation; either version 2 of the License, or (at your option) any later
80
version.
81
82
Koha is distributed in the hope that it will be useful, but WITHOUT ANY
83
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
84
A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
85
86
You should have received a copy of the GNU General Public License along
87
with Koha; if not, write to the Free Software Foundation, Inc.,
88
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Return to bug 13986