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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt (-12 / +26 lines)
Lines 1-12 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Reports &rsaquo; Item Types</title>
2
<title>Koha &rsaquo; Reports &rsaquo; Catalog by Item Types</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
5
<script type="text/javascript">
6
//<![CDATA[
7
$(document).ready(function() {
8
	$("#itemtypest").tablesorter();
9
});
10
//]]>
11
</script>
4
</head>
12
</head>
5
<body>
13
<body>
6
[% INCLUDE 'header.inc' %]
14
[% INCLUDE 'header.inc' %]
7
[% INCLUDE 'cat-search.inc' %]
15
[% INCLUDE 'cat-search.inc' %]
8
16
9
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>[% IF ( do_it ) %] &rsaquo; <a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Item Types</a> &rsaquo; Results[% ELSE %] &rsaquo; Item Types[% END %]</div>
17
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>[% IF ( do_it ) %] &rsaquo; <a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Catalog by Item Type</a> &rsaquo; Results[% ELSE %] &rsaquo; Catalog by Item Type[% END %]</div>
10
18
11
<div id="doc3" class="yui-t2">
19
<div id="doc3" class="yui-t2">
12
   
20
   
Lines 16-44 Link Here
16
24
17
[% IF ( do_it ) %]
25
[% IF ( do_it ) %]
18
[% FOREACH mainloo IN mainloop %]
26
[% FOREACH mainloo IN mainloop %]
19
	<h1>Reports on item types [% IF ( mainloo.branch ) %] for branch = [% mainloo.branch %][% END %]</h1>
27
	<h1>Reports on item types [% IF ( mainloo.branchname ) %] held at [% mainloo.branchname %][% END %]</h1>
20
	<table>
28
	<table id="itemtypest">
29
		<thead>
21
		<tr>
30
		<tr>
22
			<th>Item type</th>
31
			<th>Item type</th>
23
			<th>count</th>
32
			<th>Count</th>
24
		</tr>
33
		</tr>
34
		</thead>
35
		<tfoot>
36
			<tr>
37
				<th>TOTAL</th>
38
				<th>[% mainloo.total %]</th>
39
			</tr>
40
		</tfoot>
41
		<tbody>
25
			[% FOREACH loopitemtyp IN mainloo.loopitemtype %]
42
			[% FOREACH loopitemtyp IN mainloo.loopitemtype %]
26
				<tr>
43
				<tr>
27
					<td>[% loopitemtyp.itemtype %]</td>
44
					<td>[% loopitemtyp.itemtype %]</td>
28
					<td>[% loopitemtyp.count %]</td>
45
					<td>[% loopitemtyp.count %]</td>
29
				</tr>
46
				</tr>
30
			[% END %]
47
			[% END %]
31
			<tr>
48
		</tbody>
32
				<th>TOTAL</th>
33
				<th>[% mainloo.total %]</th>
34
			</tr>
35
	</table>
49
	</table>
36
[% END %]
50
[% END %]
37
[% ELSE %]
51
[% ELSE %]
38
52
	<h3>View a count of items held at your library grouped by item type</h3>
39
	<form method="post" action="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">
53
	<form method="post" action="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">
40
		<fieldset class="rows"><legend>View catalog group by item types</legend><ol><li><label for="value">Select a branch</label> [% CGIbranch %]
54
		<fieldset class="rows"><ol><li><label for="value">Select a library</label> [% CGIbranch %]
41
		<span class="tip">Select none to see all branches</span></li></ol></fieldset>
55
		<span class="tip">Select none to see all libraries</span></li></ol></fieldset>
42
		<fieldset class="action"><input type="submit" value="Submit" />
56
		<fieldset class="action"><input type="submit" value="Submit" />
43
		<input type="hidden" name="report_name" value="[% report_name %]" />
57
		<input type="hidden" name="report_name" value="[% report_name %]" />
44
		<input type="hidden" name="do_it" value="1" /></fieldset>
58
		<input type="hidden" name="do_it" value="1" /></fieldset>
(-)a/reports/itemtypes.plugin (-7 / +14 lines)
Lines 35-54 sub set_parameters { Link Here
35
	my $dbh = C4::Context->dbh;
35
	my $dbh = C4::Context->dbh;
36
	my $branches=GetBranches();
36
	my $branches=GetBranches();
37
	my @branches;
37
	my @branches;
38
	my $default;
38
	my @select_branch;
39
	my @select_branch;
39
	my %select_branches;
40
	my %select_branches;
40
	push @select_branch,"";
41
	push @select_branch,"";
41
	$select_branches{""} = "";
42
	$select_branches{""} = "";
42
	foreach my $branch (keys %$branches) {
43
	for my $branch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
43
		push @select_branch, $branch;
44
		push @select_branch, $branch;
44
		$select_branches{$branch} = $branches->{$branch}->{'branchname'};
45
		$select_branches{$branch} = $branches->{$branch}->{'branchname'};
46
		$default = C4::Context->userenv->{'branch'} if (C4::Context->userenv && C4::Context->userenv->{'branch'});
45
	}
47
	}
46
	my $CGIbranch=CGI::scrolling_list( -name     => 'value',
48
	my $CGIbranch=CGI::scrolling_list( -name     => 'value',
47
				-id => 'value',
49
				-id => 'value',
48
				-values   => \@select_branch,
50
				-values   => \@select_branch,
49
				-labels   => \%select_branches,
51
				-labels   => \%select_branches,
50
				-size     => 1,
52
				-size     => 1,
51
				-multiple => 0 );
53
				-multiple => 0,
54
				-default => $default, );
52
	$template->param(CGIbranch => $CGIbranch);
55
	$template->param(CGIbranch => $CGIbranch);
53
	return $template;
56
	return $template;
54
}
57
}
Lines 65-71 sub calculate { Link Here
65
			FROM itemtypes,items         
68
			FROM itemtypes,items         
66
		WHERE items.itype=itemtypes.itemtype         
69
		WHERE items.itype=itemtypes.itemtype         
67
		AND items.holdingbranch=?            
70
		AND items.holdingbranch=?            
68
		GROUP BY  items.itype");
71
		GROUP BY items.itype
72
		ORDER BY itemtypes.description");
69
73
70
		}
74
		}
71
		else {
75
		else {
Lines 75-81 sub calculate { Link Here
75
		WHERE biblioitems.itemtype=itemtypes.itemtype 
79
		WHERE biblioitems.itemtype=itemtypes.itemtype 
76
		AND items.biblioitemnumber=biblioitems.biblioitemnumber
80
		AND items.biblioitemnumber=biblioitems.biblioitemnumber
77
		AND items.holdingbranch=?
81
		AND items.holdingbranch=?
78
			GROUP BY  biblioitems.itemtype");
82
			GROUP BY  biblioitems.itemtype
83
			ORDER BY itemtypes.description");
79
		}
84
		}
80
		$sth->execute($branch);
85
		$sth->execute($branch);
81
	} else {
86
	} else {
Lines 84-97 sub calculate { Link Here
84
		SELECT description,items.itype AS itemtype, COUNT(*) AS total 
89
		SELECT description,items.itype AS itemtype, COUNT(*) AS total 
85
			FROM itemtypes,items
90
			FROM itemtypes,items
86
		WHERE items.itype=itemtypes.itemtype
91
		WHERE items.itype=itemtypes.itemtype
87
			GROUP BY items.itype");
92
			GROUP BY items.itype
93
			ORDER BY itemtypes.description");
88
		}
94
		}
89
		else {
95
		else {
90
		$sth = $dbh->prepare("SELECT description, biblioitems.itemtype, COUNT(*) AS total
96
		$sth = $dbh->prepare("SELECT description, biblioitems.itemtype, COUNT(*) AS total
91
			FROM itemtypes, biblioitems,items 
97
			FROM itemtypes, biblioitems,items 
92
		WHERE biblioitems.itemtype=itemtypes.itemtype 
98
		WHERE biblioitems.itemtype=itemtypes.itemtype 
93
		AND biblioitems.biblioitemnumber = items.biblioitemnumber
99
		AND biblioitems.biblioitemnumber = items.biblioitemnumber
94
			GROUP BY biblioitems.itemtype");
100
			GROUP BY biblioitems.itemtype
101
			ORDER BY itemtypes.description");
95
		}
102
		}
96
		$sth->execute;
103
		$sth->execute;
97
	}
104
	}
Lines 116-121 sub calculate { Link Here
116
	$globalline{loopitemtype} = \@results;
123
	$globalline{loopitemtype} = \@results;
117
	$globalline{total} = $grantotal;
124
	$globalline{total} = $grantotal;
118
	$globalline{branch} = $branch;
125
	$globalline{branch} = $branch;
126
	$globalline{branchname} = GetBranchName($branch);
119
	push @mainloop,\%globalline;
127
	push @mainloop,\%globalline;
120
	return \@mainloop;
128
	return \@mainloop;
121
}
129
}
122
- 

Return to bug 3431