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 |
- |
|
|