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

(-)a/koha-tmpl/opac-tmpl/prog/en/includes/opac-topissues.inc (-2 / +2 lines)
Lines 25-33 Link Here
25
            </li>
25
            </li>
26
            <li><label for="itemtype">Limit to: </label>
26
            <li><label for="itemtype">Limit to: </label>
27
                    <select name="itemtype" id="itemtype" style="width: 10em;">
27
                    <select name="itemtype" id="itemtype" style="width: 10em;">
28
                        <option value="">All item types</option>
28
                        <!-- TMPL_IF NAME="ccodesearch" --><option value="">All collections</option><!-- TMPL_ELSE --><option value="">All item types</option><!-- /TMPL_IF -->
29
                        <!-- TMPL_LOOP name="itemtypeloop" -->
29
                        <!-- TMPL_LOOP name="itemtypeloop" -->
30
                            <!-- TMPL_IF EXPR="itemtype eq description" --><option value="<!-- TMPL_VAR name="value" -->" selected="selected"><!-- TMPL_ELSE --><option value="<!-- TMPL_VAR name="value" -->"><!-- /TMPL_IF -->
30
                            <!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR name="value" -->" selected="selected"><!-- TMPL_ELSE --><option value="<!-- TMPL_VAR name="value" -->"><!-- /TMPL_IF -->
31
                                <!-- TMPL_VAR name="description" -->
31
                                <!-- TMPL_VAR name="description" -->
32
                            </option>
32
                            </option>
33
                        <!-- /TMPL_LOOP -->
33
                        <!-- /TMPL_LOOP -->
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-topissues.tmpl (-11 / +29 lines)
Lines 27-33 function Dopop(link) { Link Here
27
</style>
27
</style>
28
</head>
28
</head>
29
<body id="opac-topissues">
29
<body id="opac-topissues">
30
	<!-- TMPL_IF EXPR="OpacNav||results_loop" --><div id="doc3" class="yui-t1"><!-- TMPL_ELSE --><div id="doc3" class="yui-t7"><!-- /TMPL_IF -->
30
31
<!-- TMPL_IF NAME="results_loop" -->
32
<div id="doc3" class="yui-t1">
33
<!-- TMPL_ELSE -->
34
<!-- TMPL_IF NAME="OpacNav" -->
35
<div id="doc3" class="yui-t1">
36
<!-- TMPL_ELSE -->
37
<div id="doc3" class="yui-t7">
38
<!-- /TMPL_IF -->
39
<!-- /TMPL_IF -->
40
41
	
42
31
   <div id="bd">
43
   <div id="bd">
32
<!-- TMPL_INCLUDE name="masthead.inc" -->
44
<!-- TMPL_INCLUDE name="masthead.inc" -->
33
45
Lines 51-57 function Dopop(link) { Link Here
51
    </caption>
63
    </caption>
52
            <thead><tr>
64
            <thead><tr>
53
                <th>Title</th>
65
                <th>Title</th>
54
                <th>Itemtype</th>
66
                <th><!-- TMPL_IF NAME="ccodesearch" -->Collection<!-- TMPL_ELSE -->Item type<!-- /TMPL_IF --></th>
55
                <th>Checkouts</th>
67
                <th>Checkouts</th>
56
				<!-- TMPL_IF NAME="opacuserlogin" --><th>&nbsp;</th><!-- /TMPL_IF -->
68
				<!-- TMPL_IF NAME="opacuserlogin" --><th>&nbsp;</th><!-- /TMPL_IF -->
57
				
69
				
Lines 100-112 function Dopop(link) { Link Here
100
            </li>
112
            </li>
101
            <li><label for="itemtype">Limit to: </label>
113
            <li><label for="itemtype">Limit to: </label>
102
                    <select name="itemtype" id="itemtype">
114
                    <select name="itemtype" id="itemtype">
103
                        <option value="">All item types</option>
115
                        <!-- TMPL_IF NAME="ccodesearch" --><option value="">All collections</option><!-- TMPL_ELSE --><option value="">All item types</option><!-- /TMPL_IF -->
104
                       <!-- TMPL_LOOP name="itemtypeloop" -->
116
                        <!-- TMPL_LOOP name="itemtypeloop" -->
105
                           <!-- TMPL_IF name="selected" -->
117
                            <!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR name="value" -->" selected="selected"><!-- TMPL_ELSE --><option value="<!-- TMPL_VAR name="value" -->"><!-- /TMPL_IF -->
106
                               <option value="<!-- TMPL_VAR name="value" -->" selected="selected"><!-- TMPL_VAR name="description" --></option>
118
                                <!-- TMPL_VAR name="description" -->
107
                           <!-- TMPL_ELSE -->
119
                            </option>
108
                               <option value="<!-- TMPL_VAR name="value" -->"><!-- TMPL_VAR name="description" --></option>
109
                           <!-- /TMPL_IF -->
110
                        <!-- /TMPL_LOOP -->
120
                        <!-- /TMPL_LOOP -->
111
                    </select></li>
121
                    </select></li>
112
			<li>
122
			<li>
Lines 126-136 function Dopop(link) { Link Here
126
	</div>
136
	</div>
127
</div>
137
</div>
128
</div>
138
</div>
129
</div><!-- TMPL_IF EXPR="OpacNav||results_loop" -->
139
</div>
140
<!-- TMPL_IF NAME="results_loop" -->
141
<div class="yui-b"><div class="container">
142
<!-- TMPL_INCLUDE NAME="opac-topissues.inc" -->
143
<!-- TMPL_IF NAME="OpacNav" --><!--TMPL_INCLUDE NAME="navigation.inc" --><!-- /TMPL_IF -->
144
</div></div>
145
<!-- TMPL_ELSE -->
146
<!-- TMPL_IF NAME="OpacNav" -->
130
<div class="yui-b"><div class="container">
147
<div class="yui-b"><div class="container">
131
<!-- TMPL_IF NAME="results_loop" --><!-- TMPL_INCLUDE NAME="opac-topissues.inc" --><!-- /TMPL_IF -->
132
<!--TMPL_INCLUDE NAME="navigation.inc" -->
148
<!--TMPL_INCLUDE NAME="navigation.inc" -->
133
</div></div>
149
</div></div>
134
<!-- /TMPL_IF -->
150
<!-- /TMPL_IF -->
151
<!-- /TMPL_IF -->
152
135
</div>
153
</div>
136
<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->
154
<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->
(-)a/opac/opac-topissues.pl (-29 / +67 lines)
Lines 57-83 my $limit = $input->param('limit') || 10; Link Here
57
my $branch = $input->param('branch') || '';
57
my $branch = $input->param('branch') || '';
58
my $itemtype = $input->param('itemtype') || '';
58
my $itemtype = $input->param('itemtype') || '';
59
my $timeLimit = $input->param('timeLimit') || 3;
59
my $timeLimit = $input->param('timeLimit') || 3;
60
my $advanced_search_types = C4::Context->preference('AdvancedSearchTypes');
61
60
my $whereclause = '';
62
my $whereclause = '';
61
$whereclause .= 'items.homebranch='.$dbh->quote($branch)." AND " if ($branch);
63
$whereclause .= ' AND items.homebranch='.$dbh->quote($branch) if ($branch);
62
$whereclause .= 'biblioitems.itemtype='.$dbh->quote($itemtype)." AND " if $itemtype;
64
$whereclause .= ' AND TO_DAYS(NOW()) - TO_DAYS(biblio.datecreated) <= '.($timeLimit*30) if $timeLimit < 999;
63
$whereclause .= ' TO_DAYS(NOW()) - TO_DAYS(biblio.datecreated) <= '.($timeLimit*30).' AND ' if $timeLimit < 999;
64
$whereclause =~ s/ AND $// if $whereclause;
65
$whereclause =~ s/ AND $// if $whereclause;
65
$whereclause = " WHERE ".$whereclause if $whereclause;
66
my $query;
66
67
67
my $query = "SELECT datecreated, biblio.biblionumber, title, 
68
if($advanced_search_types eq 'ccode'){
68
                author, sum( items.issues ) AS tot, biblioitems.itemtype,
69
    $whereclause .= ' AND authorised_values.authorised_value='.$dbh->quote($itemtype) if $itemtype;
69
                biblioitems.publishercode,biblioitems.publicationyear,
70
    $query = "SELECT datecreated, biblio.biblionumber, title,
70
                itemtypes.description
71
                    author, sum( items.issues ) AS tot, biblioitems.itemtype,
71
                FROM biblio
72
                    biblioitems.publishercode,biblioitems.publicationyear,
72
                LEFT JOIN items USING (biblionumber)
73
                    authorised_values.lib as description
73
                LEFT JOIN biblioitems USING (biblionumber)
74
                    FROM biblio
74
                LEFT JOIN itemtypes ON itemtypes.itemtype = biblioitems.itemtype
75
                    LEFT JOIN items USING (biblionumber)
75
                $whereclause
76
                    LEFT JOIN biblioitems USING (biblionumber)
76
                GROUP BY biblio.biblionumber
77
                    LEFT JOIN authorised_values ON items.ccode = authorised_values.authorised_value
77
                HAVING tot >0
78
                    WHERE 1
78
                ORDER BY tot DESC
79
                    $whereclause
79
                LIMIT $limit
80
                    AND authorised_values.category = 'ccode' 
80
                ";
81
                    GROUP BY biblio.biblionumber
82
                    HAVING tot >0
83
                    ORDER BY tot DESC
84
                    LIMIT $limit
85
                    ";
86
    $template->param(ccodesearch => 1);
87
}else{
88
    $whereclause .= ' AND biblioitems.itemtype='.$dbh->quote($itemtype) if $itemtype;
89
    $query = "SELECT datecreated, biblio.biblionumber, title,
90
                    author, sum( items.issues ) AS tot, biblioitems.itemtype,
91
                    biblioitems.publishercode,biblioitems.publicationyear,
92
                    itemtypes.description
93
                    FROM biblio
94
                    LEFT JOIN items USING (biblionumber)
95
                    LEFT JOIN biblioitems USING (biblionumber)
96
                    LEFT JOIN itemtypes ON itemtypes.itemtype = biblioitems.itemtype
97
                    WHERE 1
98
                    $whereclause
99
                    GROUP BY biblio.biblionumber
100
                    HAVING tot >0
101
                    ORDER BY tot DESC
102
                    LIMIT $limit
103
                    ";
104
     $template->param(itemtypesearch => 1);
105
}
81
106
82
my $sth = $dbh->prepare($query);
107
my $sth = $dbh->prepare($query);
83
$sth->execute();
108
$sth->execute();
Lines 100-119 $template->param(do_it => 1, Link Here
100
125
101
$template->param( branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'}));
126
$template->param( branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'}));
102
127
103
#doctype
128
# the index parameter is different for item-level itemtypes
129
my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'itemtype';
104
$itemtypes = GetItemTypes;
130
$itemtypes = GetItemTypes;
105
my @itemtypeloop;
131
my @itemtypesloop;
106
foreach my $thisitemtype (sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'}} keys %$itemtypes) {
132
my $selected=1;
133
if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {
134
        foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
107
        my $selected = 1 if $thisitemtype eq $itemtype;
135
        my $selected = 1 if $thisitemtype eq $itemtype;
108
        my %row =(value => $thisitemtype,
136
        my %row =( value => $thisitemtype,
109
                    description => $itemtypes->{$thisitemtype}->{'description'},
137
                   description => $itemtypes->{$thisitemtype}->{'description'},
110
                    selected => $selected,
138
                   selected => $selected,
111
                 );
139
            );
112
        push @itemtypeloop, \%row;
140
        push @itemtypesloop, \%row;
141
        }
142
} else {
143
    my $advsearchtypes = GetAuthorisedValues($advanced_search_types, '', 'opac');
144
        for my $thisitemtype (@$advsearchtypes) {
145
                my $selected = 1 if $thisitemtype->{authorised_value} eq $itemtype;
146
                my %row =( value => $thisitemtype->{authorised_value},
147
                selected => $selected,
148
                description => $thisitemtype->{'lib'},
149
            );
150
                push @itemtypesloop, \%row;
151
        }
113
}
152
}
114
153
115
$template->param(
154
$template->param(
116
                 itemtypeloop =>\@itemtypeloop,
155
                 itemtypeloop =>\@itemtypesloop,
117
                 dateformat    => C4::Context->preference("dateformat"),
156
                 dateformat    => C4::Context->preference("dateformat"),
118
                );
157
                );
119
output_html_with_http_headers $input, $cookie, $template->output;
158
output_html_with_http_headers $input, $cookie, $template->output;
120
- 

Return to bug 3459