&AddBudgetPeriod
&DelBudgetPeriod
- &GetBudgetPeriodsDropbox
- &GetBudgetSortDropbox
&GetAuthvalueDropbox
- &GetBudgetPermDropbox
&ModBudgetPlan
}
# -------------------------------------------------------------------
-sub GetBudgetPermDropbox {
- my ($perm) = @_;
- my %labels;
- $labels{'0'} = 'None';
- $labels{'1'} = 'Owner';
- $labels{'2'} = 'Library';
- my $radio = CGI::scrolling_list(
- -id => 'budget_permission',
- -name => 'budget_permission',
- -values => [ '0', '1', '2' ],
- -default => $perm,
- -labels => \%labels,
- -size => 1,
- );
- return $radio;
-}
-
-# -------------------------------------------------------------------
sub GetBudgetAuthCats {
my ($budget_period_id) = shift;
# now, populate the auth_cats_loop used in the budget planning button
# -------------------------------------------------------------------
sub GetAuthvalueDropbox {
- my ( $name, $authcat, $default ) = @_;
- my @authorised_values;
- my %authorised_lib;
- my $value;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare(
- "SELECT authorised_value,lib
- FROM authorised_values
- WHERE category = ?
- ORDER BY lib"
- );
- $sth->execute( $authcat );
-
- push @authorised_values, '';
- while (my ($value, $lib) = $sth->fetchrow_array) {
- push @authorised_values, $value;
- $authorised_lib{$value} = $lib;
- }
-
- return 0 if keys(%authorised_lib) == 0;
-
- my $budget_authvalue_dropbox = CGI::scrolling_list(
- -values => \@authorised_values,
- -labels => \%authorised_lib,
- -default => $default,
- -override => 1,
- -size => 1,
- -multiple => 0,
- -name => $name,
- -id => $name,
+ my ( $authcat, $default ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare(
+ 'SELECT authorised_value,lib FROM authorised_values
+ WHERE category = ? ORDER BY lib'
);
+ $sth->execute( $authcat );
+ my $option_list = [];
+ my @authorised_values = ( q{} );
+ while (my ($value, $lib) = $sth->fetchrow_array) {
+ push @{$option_list}, {
+ value => $value,
+ label => $lib,
+ default => ($default eq $value),
+ };
+ }
- return $budget_authvalue_dropbox
-}
-
-# -------------------------------------------------------------------
-sub GetBudgetPeriodsDropbox {
- my ($budget_period_id) = @_;
- my %labels;
- my @values;
- my ($active, $periods) = GetBudgetPeriods();
- foreach my $r (@$periods) {
- $labels{"$r->{budget_period_id}"} = $r->{budget_period_description};
- push @values, $r->{budget_period_id};
- }
-
- # if no buget_id is passed then its an add
- my $budget_period_dropbox = CGI::scrolling_list(
- -name => 'budget_period_id',
- -values => \@values,
- -default => $budget_period_id ? $budget_period_id : $active,
- -size => 1,
- -labels => \%labels,
- );
- return $budget_period_dropbox;
+ if ( @{$option_list} ) {
+ return $option_list;
+ }
+ return;
}
# -------------------------------------------------------------------
my $CGIsort1;
if ($budget) { # its a mod ..
if ( defined $budget->{'sort1_authcat'} ) { # with custom Asort* planning values
- $CGIsort1 = GetAuthvalueDropbox( 'sort1', $budget->{'sort1_authcat'}, $data->{'sort1'} );
+ $CGIsort1 = GetAuthvalueDropbox( $budget->{'sort1_authcat'}, $data->{'sort1'} );
}
} elsif ( scalar(@$budgets) ) {
- $CGIsort1 = GetAuthvalueDropbox( 'sort1', @$budgets[0]->{'sort1_authcat'}, '' );
+ $CGIsort1 = GetAuthvalueDropbox( @$budgets[0]->{'sort1_authcat'}, '' );
} else {
- $CGIsort1 = GetAuthvalueDropbox( 'sort1', '', '' );
+ $CGIsort1 = GetAuthvalueDropbox( '', '' );
}
# if CGIsort is successfully fetched, the use it
my $CGIsort2;
if ($budget) {
if ( defined $budget->{'sort2_authcat'} ) {
- $CGIsort2 = GetAuthvalueDropbox( 'sort2', $budget->{'sort2_authcat'}, $data->{'sort2'} );
+ $CGIsort2 = GetAuthvalueDropbox( $budget->{'sort2_authcat'}, $data->{'sort2'} );
}
} elsif ( scalar(@$budgets) ) {
- $CGIsort2 = GetAuthvalueDropbox( 'sort2', @$budgets[0]->{sort2_authcat}, '' );
+ $CGIsort2 = GetAuthvalueDropbox( @$budgets[0]->{sort2_authcat}, '' );
} else {
- $CGIsort2 = GetAuthvalueDropbox( 'sort2', '', '' );
+ $CGIsort2 = GetAuthvalueDropbox( '', '' );
}
if ($CGIsort2) {
+++ /dev/null
-#!/usr/bin/perl
-
-# Copyright 2008-2009 BibLibre SARL
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-use strict;
-#use warnings; FIXME - Bug 2505
-use CGI;
-use C4::Context;
-use C4::Output;
-use C4::Auth;
-use C4::Budgets;
-
-=head1 NAME
-
-fetch_sort_dropbox
-
-=cut
-
-my $input = new CGI;
-
-my $budget_id = $input->param('budget_id');
-my $sort_id = $input->param('sort');
-
-my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
- { template_name => "acqui/ajax.tmpl", # FIXME: REMOVE TMPL DEP?
- query => $input,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => {editcatalogue => 'edit_catalogue'},
- debug => 0,
- }
-);
-
-my $sort_dropbox;
-my $budget = GetBudget($budget_id);
-
-if ( $sort_id == 1 ) {
- $sort_dropbox = GetAuthvalueDropbox( 'sort1', $budget->{'sort1_authcat'}, '' );
-} elsif ( $sort_id == 2 ) {
- $sort_dropbox = GetAuthvalueDropbox( 'sort2', $budget->{'sort2_authcat'}, '' );
-}
-
-#strip off select tags ;/
-$sort_dropbox =~ s/^\<select.*?\"\>//;
-$sort_dropbox =~ s/\<\/select\>$//;
-chomp $sort_dropbox;
-
-$template->param( return => $sort_dropbox );
-output_html_with_http_headers $input, $cookie, $template->output;
-1;
my $CGIsort1;
if ($budget) { # its a mod ..
if ( defined $budget->{'sort1_authcat'} ) { # with custom Asort* planning values
- $CGIsort1 = GetAuthvalueDropbox( 'sort1', $budget->{'sort1_authcat'}, $data->{'sort1'} );
+ $CGIsort1 = GetAuthvalueDropbox( $budget->{'sort1_authcat'}, $data->{'sort1'} );
}
-} elsif(scalar(@$budgets)){
- $CGIsort1 = GetAuthvalueDropbox( 'sort1', @$budgets[0]->{'sort1_authcat'}, '' );
+} elsif(@{$budgets}){
+ $CGIsort1 = GetAuthvalueDropbox( @$budgets[0]->{'sort1_authcat'}, '' );
}else{
- $CGIsort1 = GetAuthvalueDropbox( 'sort1','', '' );
+ $CGIsort1 = GetAuthvalueDropbox( '', '' );
}
# if CGIsort is successfully fetched, the use it
my $CGIsort2;
if ($budget) {
if ( defined $budget->{'sort2_authcat'} ) {
- $CGIsort2 = GetAuthvalueDropbox( 'sort2', $budget->{'sort2_authcat'}, $data->{'sort2'} );
+ $CGIsort2 = GetAuthvalueDropbox( $budget->{'sort2_authcat'}, $data->{'sort2'} );
}
-} elsif(scalar(@$budgets)) {
- $CGIsort2 = GetAuthvalueDropbox( 'sort2', @$budgets[0]->{sort2_authcat}, '' );
+} elsif(@{$budgets}) {
+ $CGIsort2 = GetAuthvalueDropbox( @$budgets[0]->{sort2_authcat}, '' );
}else{
- $CGIsort2 = GetAuthvalueDropbox( 'sort2','', '' );
+ $CGIsort2 = GetAuthvalueDropbox( '', '' );
}
if ($CGIsort2) {
$budgetperiod->{budget_active} = 1;
push( @period_loop, $budgetperiod );
}
- my $budget_period_dropbox = GetBudgetPeriodsDropbox();
$template->param(
- budget_period_dropbox => $budget_period_dropbox,
period_loop => \@period_loop,
pagination_bar => pagination_bar("aqbudgetperiods.pl",getnbpages(scalar(@$results),$pagesize),$page),
);
my $budget_hash = $input->Vars;
my $budget_id = $$budget_hash{budget_id};
my $budget_permission = $input->param('budget_permission');
-my $budget_period_dropbox = $input->param('budget_period_dropbox');
my $filter_budgetbranch = $input->param('filter_budgetbranch');
#filtering non budget keys
delete $$budget_hash{$_} foreach grep {/filter|^op$|show/} keys %$budget_hash;
}
}
my $branches = GetBranches();
- my $budget_period_dropbox = GetBudgetPeriodsDropbox($$period{budget_period_id} );
$template->param(
- budget_period_dropbox => $budget_period_dropbox,
budget_id => $budget_id,
%$period,
);
my $budget_period_enddate = $period->{'budget_period_enddate'};
my $budget_period_locked = $period->{'budget_period_locked'};
my $budget_period_description = $period->{'budget_period_description'};
-my $budget_period_dropbox = GetBudgetPeriodsDropbox($budget_period_id );
$template->param(
budget_period_id => $budget_period_id,
budget_period_locked => $budget_period_locked,
budget_period_description => $budget_period_description,
- budget_period_dropbox => $budget_period_dropbox,
auth_cats_loop => $auth_cats_loop,
);
<li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
<label for="sort1">Planning value1: </label>
- [% IF ( CGIsort1 ) %]
- [% CGIsort1 %]
+ [% IF CGIsort1 %]
+ <select id="sort1" size="1" name="sort1">
+ [% FOREACH sort_opt IN CGIsort1 %]
+ [% IF sort_opt.default %]
+ <option value="[% sort_opt.id %]" selected="selected">[% sort_opt.label %]</option>
+ [% ELSE %]
+ <option value="[% sort_opt.id %]">[% sort_opt.label %]</option>
+ [% END %]
+ [% END %]
+ </select>
[% ELSE %]
-
<input type="text" id="sort1" size="20" name="sort1" value="[% sort1 %]" />
[% END %]
</li>
<li>
<label for="sort2">Planning value2: </label>
- [% IF ( CGIsort2 ) %]
- [% CGIsort2 %]
- [% ELSE %]
- <input type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
+ [% IF CGIsort2 %]
+ <select id="sort2" size="1" name="sort1">
+ [% FOREACH sort_opt IN CGIsort2 %]
+ [% IF sort_opt.default %]
+ <option value="[% sort_opt.id %]" selected="selected">[% sort_opt.label %]</option>
+ [% ELSE %]
+ <option value="[% sort_opt.id %]">[% sort_opt.label %]</option>
+ [% END %]
[% END %]
+ </select>
+ [% ELSE %]
+ <input type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
+ [% END %]
</li>
<li>
<li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
<label for="sort1">Statistic 1: </label>
- [% IF ( CGIsort1 ) %]
- [% CGIsort1 %]
+ [% IF CGIsort1 %]
+ <select id="sort1" size="1" name="sort1">
+ [% FOREACH sort_opt IN CGIsort1 %]
+ [% IF sort_opt.default %]
+ <option value="[% sort_opt.id %]" selected="selected">[% sort_opt.label %]</option>
+ [% ELSE %]
+ <option value="[% sort_opt.id %]">[% sort_opt.label %]</option>
+ [% END %]
+ [% END %]
+ </select>
[% ELSE %]
<input type="text" id="sort1" size="20" name="sort1" value="[% sort1 %]" />
<li>
<label for="sort2">Statistic 2: </label>
- [% IF ( CGIsort2 ) %]
- [% CGIsort2 %]
+ [% IF CGIsort2 %]
+ <select id="sort2" size="1" name="sort1">
+ [% FOREACH sort_opt IN CGIsort2 %]
+ [% IF sort_opt.default %]
+ <option value="[% sort_opt.id %]" selected="selected">[% sort_opt.label %]</option>
+ [% ELSE %]
+ <option value="[% sort_opt.id %]">[% sort_opt.label %]</option>
+ [% END %]
+ [% END %]
+ </select>
[% ELSE %]
<input type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
[% END %]