[Koha-patches] [PATCH 20/78] Budget management
paul.poulain at biblibre.com
paul.poulain at biblibre.com
Thu May 28 18:32:30 CEST 2009
From: Paul Poulain <paul.poulain at biblibre.com>
* budget period management
* budget management (budgets lines are defined for a given budget period)
budget_owner_search is the popup to select a librarian as budget owner
---
admin/aqbudget_owner_search.pl | 121 ++++++
admin/aqbudgetperiods.pl | 281 +++++++++++++
admin/aqbudgets.pl | 412 ++++++++++++++++++++
admin/check_budget_parent.pl | 54 +++
admin/check_parent_total.pl | 103 +++++
.../intranet-tmpl/prog/en/includes/admin-menu.inc | 6 +-
.../prog/en/includes/budgetperiods-admin.inc | 37 ++
.../prog/en/includes/budgets-admin-search.inc | 119 ++++++
.../prog/en/includes/budgets-admin.inc | 124 ++++++
.../en/modules/admin/aqbudget_owner_search.tmpl | 77 ++++
.../prog/en/modules/admin/aqbudgetperiods.tmpl | 316 +++++++++++++++
.../prog/en/modules/admin/aqbudgets.tmpl | 360 +++++++++++++++++
12 files changed, 2007 insertions(+), 3 deletions(-)
create mode 100755 admin/aqbudget_owner_search.pl
create mode 100755 admin/aqbudgetperiods.pl
create mode 100755 admin/aqbudgets.pl
create mode 100755 admin/check_budget_parent.pl
create mode 100755 admin/check_parent_total.pl
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/budgetperiods-admin.inc
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-search.inc
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin.inc
create mode 100755 koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudget_owner_search.tmpl
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tmpl
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tmpl
diff --git a/admin/aqbudget_owner_search.pl b/admin/aqbudget_owner_search.pl
new file mode 100755
index 0000000..cd8d46b
--- /dev/null
+++ b/admin/aqbudget_owner_search.pl
@@ -0,0 +1,121 @@
+#!/usr/bin/perl
+
+# script to find a guarantor
+
+# 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., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+use C4::Auth ;
+use C4::Output;
+use CGI;
+use C4::Dates qw/format_date/;
+use C4::Members;
+
+my $input = new CGI;
+
+my $dbh = C4::Context->dbh;
+
+my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
+ { template_name => "admin/aqbudget_owner_search.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { acquisition => 'budget_modify' },
+ debug => 1,
+ }
+);
+
+my $theme = $input->param('theme') || "default";
+
+# only used if allowthemeoverride is set
+my $member = $input->param('member');
+my $orderby = $input->param('orderby');
+
+my $op = $input->param('op');
+$template->param( $op || else => 1, );
+
+$orderby = "surname,firstname" unless $orderby;
+$member =~ s/,//g; #remove any commas from search string
+$member =~ s/\*/%/g;
+if ( $member eq '' ) {
+ $template->param( results => 0 );
+} else {
+ $template->param( results => 1 );
+}
+
+my ( $count, $count2, $results );
+my @resultsdata;
+my $toggle = 0;
+
+if ( $member ) {
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare(
+ qq| SELECT * from borrowers where surname like ? or firstname like ? or cardnumber like ? |
+ );
+
+ $sth->execute( "$member%", "$member%", "$member%", );
+ my $results = $sth->fetchall_arrayref({});
+
+ foreach my $res (@$results) {
+
+ my $perms = haspermission( $dbh, $res->{'userid'} );
+ my $subperms = get_user_subpermissions ($res->{'userid'} );
+
+
+ # if the member has 'acqui' permission set, then display to table.
+ if ( $perms->{superlibrarian} == 1 ||
+ $perms->{acquisition} == 1 ||
+ $subperms->{acquisition}->{'budget_manage'} ||
+ $subperms->{acquisition}->{'budget_modify'} ||
+ $subperms->{acquisition}->{'budget_add_del'} ) {
+
+ $count2++;
+ #find out stats
+ my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $res->{'borrowerid'} );
+ my $guarantorinfo = uc( $res->{'surname'} ) . " , " . ucfirst( $res->{'firstname'} );
+ my $budget_owner_name = $res->{'firstname'} . ' ' . $res->{'surname'}, my $budget_owner_id = $res->{'borrowernumber'};
+
+ my %row = (
+ toggle => $toggle,
+ count => 1,
+ borrowernumber => $res->{'borrowernumber'},
+ cardnumber => $res->{'cardnumber'},
+ surname => $res->{'surname'},
+ firstname => $res->{'firstname'},
+ categorycode => $res->{'categorycode'},
+ branchcode => $res->{'branchcode'},
+ guarantorinfo => $guarantorinfo,
+ budget_owner_id => $budget_owner_id,
+ budget_owner_name => $budget_owner_name,
+ odissue => "$od/$issue",
+ fines => $fines,
+# borrowernotes => $res->{'borrowernotes'}
+ );
+ $toggle = ( $toggle++ % 2 eq 0 ? 1 : 0 );
+ push( @resultsdata, \%row );
+ }
+ }
+}
+
+$template->param(
+ member => $member,
+ numres => $count2,
+ resultsloop => \@resultsdata
+);
+
+output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/admin/aqbudgetperiods.pl b/admin/aqbudgetperiods.pl
new file mode 100755
index 0000000..08d3a36
--- /dev/null
+++ b/admin/aqbudgetperiods.pl
@@ -0,0 +1,281 @@
+#!/usr/bin/perl
+
+# Copyright 2008 BibLibre, BibLibre, Paul POULAIN
+# SAN Ouest Provence
+#
+# 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., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+=head1 admin/aqbudgetperiods.pl
+
+script to administer the budget periods table
+ This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
+
+ ALGO :
+ this script use an $op to know what to do.
+ if $op is empty or none of the above values,
+ - the default screen is build (with all records, or filtered datas).
+ - the user can clic on add, modify or delete record.
+ if $op=add_form
+ - if primkey exists, this is a modification,so we read the $primkey record
+ - builds the add/modify form
+ if $op=add_validate
+ - the user has just send datas, so we create/modify the record
+ if $op=delete_confirm
+ - we show the record having primkey=$primkey and ask for deletion validation form
+ if $op=delete_confirmed
+ - we delete the record having primkey=$primkey
+
+=cut
+
+## modules
+use strict;
+use Number::Format qw(format_price);
+use CGI;
+use List::Util qw/min/;
+use C4::Dates qw/format_date format_date_in_iso/;
+use C4::Koha;
+use C4::Context;
+use C4::Auth;
+use C4::Output;
+use C4::Acquisition;
+use C4::Budgets;
+use C4::Debug;
+
+my $dbh = C4::Context->dbh;
+
+my $input = new CGI;
+
+my $searchfield = $input->param('searchfield');
+my $budget_period_id = $input->param('budget_period_id');
+my $budget_period_active = $input->param('budget_period_active');
+my $budget_period_locked = $input->param('budget_period_locked');
+my $op = $input->param('op');
+
+#my $sort1_authcat = $input->param('sort1_authcat');
+#my $sort2_authcat = $input->param('sort2_authcat');
+
+my $pagesize = 10;
+$searchfield =~ s/\,//g;
+
+my ($template, $borrowernumber, $cookie, $staff_flags ) = get_template_and_user(
+ { template_name => "admin/aqbudgetperiods.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { acquisition => 'period_manage' },
+ debug => 1,
+ }
+);
+
+my $script_name = "/cgi-bin/koha/admin/aqbudgetperiods.pl"; # ???
+
+my ( $count, $results ) = GetBudgetPeriods();
+### $count
+$template->param( period_button_only => 1 ) if ($count == 0) ;
+
+my $cur = GetCurrency();
+$template->param( cur => $cur->{symbol} );
+my $cur_format = C4::Context->preference("CurrencyFormat");
+my $num;
+
+if ( $cur_format eq 'US' ) {
+ $num = new Number::Format(
+ 'int_curr_symbol' => '',
+ 'mon_thousands_sep' => ',',
+ 'mon_decimal_point' => '.'
+ );
+} elsif ( $cur_format eq 'FR' ) {
+ $num = new Number::Format(
+ 'decimal_fill' => '2',
+ 'decimal_point' => ',',
+ 'int_curr_symbol' => '',
+ 'mon_thousands_sep' => ' ',
+ 'thousands_sep' => ' ',
+ 'mon_decimal_point' => ','
+ );
+}
+
+if ($op) { $template->param( $op => 1 ); }
+else { $template->param( 'else' => 1 ); }
+
+# ADD OR MODIFY A BUDGET PERIOD - BUILD SCREEN
+if ( $op eq 'add_form' ) {
+ ## add or modify a budget period (preparation)
+ ## get information about the budget period that must be modified
+
+# my ( $default, $sort1_authcat_dropbox, $sort1_default, $sort2_default );
+# my ( $default, t );
+
+ if ($budget_period_id) { # MOD
+ my $data;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare(qq|
+ SELECT * FROM aqbudgetperiods
+ WHERE budget_period_id=? | );
+ $sth->execute($budget_period_id);
+ $data = $sth->fetchrow_hashref;
+ $sth->finish;
+
+ # get dropboxes
+ $template->param(
+ budget_period_id => $budget_period_id,
+ budget_period_startdate => format_date( $data->{'budget_period_startdate'} ),
+ budget_period_enddate => format_date( $data->{'budget_period_enddate'} ),
+ budget_period_description => $data->{'budget_period_description'},
+ budget_period_total => sprintf ("%.2f", $data->{'budget_period_total'} ),
+ budget_period_active => $data->{'budget_period_active'},
+ budget_period_locked => $data->{'budget_period_locked'},
+ );
+ } # IF-MOD
+ $template->param( DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), );
+}
+
+elsif ( $op eq 'add_validate' ) {
+## add or modify a budget period (confirmation)
+
+ ## update budget period data
+ if ( $budget_period_id ne '' ) {
+ my $query = '
+ UPDATE aqbudgetperiods
+ SET budget_period_startdate = ?
+ , budget_period_enddate = ?
+ , budget_period_description = ?
+ , budget_period_total = ?
+ , budget_period_locked = ?
+ WHERE budget_period_id = ?
+ ';
+
+ my $sth = $dbh->prepare($query);
+ $sth->execute(
+ $input->param('budget_period_startdate') ? format_date_in_iso( $input->param('budget_period_startdate') ) : undef,
+ $input->param('budget_period_enddate') ? format_date_in_iso( $input->param('budget_period_enddate') ) : undef,
+ $input->param('budget_period_description') ? $input->param('budget_period_description') : undef,
+ $input->param('budget_period_total') ? $input->param('budget_period_total') : undef,
+ $input->param('budget_period_locked') ? $input->param('budget_period_locked') : undef,
+ $input->param('budget_period_id'),
+ );
+
+ # IF PASSED ACTIVE - THEN SET IT IN DB TOO.
+ set_active($budget_period_id) if ( $budget_period_active == 1 );
+
+ } else { # ELSE ITS AN ADD
+ my $query = "
+ INSERT INTO aqbudgetperiods (
+ budget_period_id
+ , budget_period_startdate
+ , budget_period_enddate
+ , budget_period_total
+ , budget_period_description
+ , budget_period_locked )
+ VALUES (?,?,?,?,?,? );
+ ";
+ my $sth = $dbh->prepare($query);
+ $sth->execute(
+ $budget_period_id,
+ $input->param('budget_period_startdate') ? format_date_in_iso( $input->param('budget_period_startdate') ) : undef,
+ $input->param('budget_period_enddate') ? format_date_in_iso( $input->param('budget_period_enddate') ) : undef,
+ $input->param('budget_period_total') ? $input->param('budget_period_total') : undef,
+ $input->param('budget_period_description') ? $input->param('budget_period_description') : undef,
+ $input->param('budget_period_locked') ? $input->param('budget_period_locked') : undef,
+ );
+ $budget_period_id = $dbh->last_insert_id( undef, undef, 'aqbudgetperiods', undef );
+ set_active($budget_period_id) if ( $budget_period_active == 1 );
+ }
+
+ print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=aqbudgetperiods.pl\"></html>"; #YUCK
+ # output_html_with_http_headers $input, $cookie, $template->output; # FIXME: THIS WOULD BE NICER THAN THE PREVIOUS PRINT
+ exit;
+}
+
+#--------------------------------------------------
+elsif ( $op eq 'delete_confirm' ) {
+## delete a budget period (preparation)
+ my $dbh = C4::Context->dbh;
+ ## $total = number of records linked to the record that must be deleted
+ my $total = 0;
+ my $data = GetBudgetPeriod( $budget_period_id);
+
+ $template->param(
+ budget_period_id => $budget_period_id,
+ budget_period_startdate => format_date($data->{'budget_period_startdate'}),
+ budget_period_enddate => format_date($data->{'budget_period_enddate'}),
+ budget_period_total => $num->format_price( $data->{'budget_period_total'} )
+
+# budget_period_active => $data->{'budget_period_active'},
+# budget_period_description => $data->{'budget_period_description'},
+# template => C4::Context->preference('template'), ## ??!?
+ );
+}
+
+elsif ( $op eq 'delete_confirmed' ) {
+## delete the budget period record
+
+ my $dbh = C4::Context->dbh;
+ my $budget_period_id = uc( $input->param('budget_period_id') );
+ my $sth = $dbh->prepare("DELETE FROM aqbudgetperiods WHERE budget_period_id=?");
+ $sth->execute($budget_period_id);
+ $sth->finish;
+ print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=aqbudgetperiods.pl\"></html>";
+ exit;
+}
+
+else {
+
+# DEFAULT - DISPLAY AQPERIODS TABLE
+# -------------------------------------------------------------------
+# display the list of budget periods
+ my ( $count, $results ) = GetBudgetPeriods();
+ my $page = $input->param('page') || 1;
+ my $first = ( $page - 1 ) * $pagesize;
+
+ # if we are on the last page, the number of the last word to display
+ # must not exceed the length of the results array
+ my $last = min( $first + $pagesize - 1, scalar @{$results} - 1, );
+ my $toggle = 0;
+ my @period_loop;
+ foreach my $result ( @{$results}[ $first .. $last ] ) {
+ my $budgetperiod = $result;
+ $budgetperiod->{'budget_period_startdate'} = format_date( $budgetperiod->{'budget_period_startdate'} );
+ $budgetperiod->{'budget_period_enddate'} = format_date( $budgetperiod->{'budget_period_enddate'} );
+ $budgetperiod->{'budget_period_total'} = $num->format_price( $budgetperiod->{'budget_period_total'} );
+ $budgetperiod->{toggle} = ( $toggle++ % 2 eq 0 ? 1 : 0 );
+ $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( $script_name,
+# getnbpages( scalar @{$results},
+# $pagesize ), $page, 'page' )
+ );
+}
+
+output_html_with_http_headers $input, $cookie, $template->output;
+
+sub set_active {
+ my $sth = $dbh->do(
+ "UPDATE aqbudgetperiods
+ SET budget_period_active = 0 "
+ );
+ my $sth = $dbh->do(
+ "UPDATE aqbudgetperiods
+ SET budget_period_active = 1
+ WHERE budget_period_id = $budget_period_id"
+ );
+}
diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl
new file mode 100755
index 0000000..74a4178
--- /dev/null
+++ b/admin/aqbudgets.pl
@@ -0,0 +1,412 @@
+#!/usr/bin/perl
+
+#script to administer the aqbudget table
+
+# 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., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+use CGI;
+use List::Util qw/min/;
+use Number::Format qw(format_price);
+
+use C4::Auth qw/get_user_subpermissions/;
+use C4::Branch; # GetBranches
+use C4::Dates qw/format_date format_date_in_iso/;
+use C4::Auth;
+use C4::Acquisition;
+use C4::Budgets; # 1ST ADD
+use C4::Members; # calls GetSortDetails()
+use C4::Context;
+use C4::Output;
+use C4::Koha;
+use C4::Debug;
+#use POSIX qw(locale_h);
+
+my $input = new CGI;
+my $dbh = C4::Context->dbh;
+
+my ($template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user(
+ { template_name => "admin/aqbudgets.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { acquisition => 'budget_manage' },
+ debug => 0,
+ }
+);
+
+my $op = $input->param('op');
+
+# see if the user want to see all budgets or only owned ones
+my $show_mine = 1; #SHOW BY DEFAULT
+my $show = $input->param('show'); # SET TO 1, BY A FORM SUMBIT
+$show_mine = $input->param('show_mine') if $show == 1;
+
+
+# IF USER DOESNT HAVE PERM FOR AN 'ADD', THEN REDIRECT TO THE DEFAULT VIEW...
+if ( not defined $template->{param_map}->{'CAN_user_acquisition_budget_add_del'} && $op == 'add_form' ) {
+ $op = '';
+}
+
+my $count = GetPeriodsCount();
+$template->param( period_button_only => 1 ) if $count == 0 ;
+my $cur = GetCurrency;
+my $cur_format = C4::Context->preference("CurrencyFormat");
+my $num;
+
+=c
+# TODO: at some stage this currency handling should be done properly
+with locales and POSIX.pm - and a proper 'locales' lookup and syspref
+
+ setlocale( LC_MONETARY , "french");
+ my $num = new Number::Format();
+ my $formatted_number = $num->format_price('123456789.123'):
+
+=cut
+
+if ( $cur_format eq 'FR' ) {
+ $num = new Number::Format(
+ 'decimal_fill' => '2',
+ 'decimal_point' => ',',
+ 'int_curr_symbol' => '',
+ 'mon_thousands_sep' => ' ',
+ 'thousands_sep' => ' ',
+ 'mon_decimal_point' => ','
+ );
+} else { # US by default..
+ $num = new Number::Format(
+ 'int_curr_symbol' => '',
+ 'mon_thousands_sep' => ',',
+ 'mon_decimal_point' => '.'
+ );
+}
+
+# ' ------- get periods stuff ------------------'
+# IF PERIODID IS DEFINED, GET THE PERIOD - ELSE JUST GET THE ACTIVE PERIOD BY DEFAULT
+my $budget_period_id = $input->param('budget_period_id');
+my $period = GetBudgetPeriod($budget_period_id);
+
+# authcats_loop populates the YUI planning button
+my @auth_cats_loop = GetBudgetAuthCats();
+
+my $budget_period_id = $period->{'budget_period_id'};
+my $budget_period_locked = $period->{'budget_period_locked'};
+my $budget_period_description = $period->{'budget_period_description'};
+my $budget_period_total = $period->{'budget_period_total'};
+
+$template->param(
+ budget_period_id => $budget_period_id,
+ budget_period_locked => $budget_period_locked,
+ budget_period_description => $budget_period_description,
+ auth_cats_loop => \@auth_cats_loop,
+);
+# ------- get periods stuff ------------------
+
+my $script_name = "/cgi-bin/koha/admin/aqbudgets.pl";
+my $budget_id = $input->param('budget_id');
+my $budget_code = $input->param('budget_code');
+my $budget_name = $input->param('budget_name');
+my $budget_amount = $input->param('budget_amount');
+my $budget_amount_sublevel = $input->param('budget_amount_sublevel');
+my $budget_encumb = $input->param('budget_encumb');
+my $budget_expend = $input->param('budget_expend');
+my $budget_notes = $input->param('budget_notes');
+my $sort1_authcat = $input->param('sort1_authcat');
+my $sort2_authcat = $input->param('sort2_authcat');
+my $budget_description = $input->param('budget_description');
+my $budget_branchcode = $input->param('budget_branchcode');
+my $budget_owner_id = $input->param('budget_owner_id');
+my $budget_parent_id = $input->param('budget_parent_id');
+my $budget_permission = $input->param('budget_permission');
+my $budget_period_dropbox = $input->param('budget_period_dropbox');
+my $filter_budgetname = $input->param('filter_budgetname');
+my $filter_budgetbranch = $input->param('filter_budgetbranch');
+
+my $pagesize = 20; # del
+
+# USED FOR PERMISSION COMPARSION LATER
+my $borrower_id = $template->{param_map}->{'USER_INFO'}[0]->{'borrowernumber'};
+my $user = GetMemberDetails($borrower_id);
+my $user_branchcode = $user->{'branchcode'};
+
+$template->param(
+ action => $script_name,
+ script_name => $script_name,
+ show_mine => $show_mine,
+ $op || else => 1,
+);
+
+my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
+$sthtemp->execute($borrowernumber);
+my ( $flags, $homebranch ) = $sthtemp->fetchrow;
+
+my ( $budget, $period, $query, $sth );
+
+my $branches = GetBranches;
+my @branchloop2;
+foreach my $thisbranch (keys %$branches) {
+ my %row = (
+ value => $thisbranch,
+ branchname => $branches->{$thisbranch}->{'branchname'},
+ );
+ $row{selected} = 1 if $thisbranch eq $filter_budgetbranch;
+ push @branchloop2, \%row;
+}
+
+#$template->param(
+# budget_id => $budget->{'budget_id'}
+#);
+
+# Used to create form to add or modify a record
+if ($op eq 'add_form') {
+#### ------------------- ADD_FORM -------------------------
+
+#---- if primkey exists, it's a modify action, so read values to modify...
+# pass the period_id to build the dropbox - because we only want to show budgets from this period
+
+ my $dropbox_disabled;
+ if ( defined $budget_id ) { ### MOD
+ $budget = GetBudget($budget_id);
+ $dropbox_disabled = BudgetHasChildren($budget_id);
+ my $borrower = &GetMember( $budget->{budget_owner_id} );
+ $budget->{budget_owner_name} = $borrower->{'firstname'} . ' ' . $borrower->{'surname'};
+ }
+
+ my $sort1_authcat_dropbox = GetAuthcatDropbox( 'sort1_authcat', $budget->{'sort1_authcat'} );
+ my $sort2_authcat_dropbox = GetAuthcatDropbox( 'sort2_authcat', $budget->{'sort2_authcat'} );
+
+ my %labels;
+ my @values;
+ my $hier = GetBudgetHierarchy($budget_period_id);
+ foreach my $r (@$hier) {
+ $r->{budget_code_indent} =~ s/ /\~/g; #
+ $labels{"$r->{budget_id}"} = $r->{budget_code_indent};
+ push @values, $r->{budget_id};
+ }
+ push @values, '';
+ # if no buget_id is passed then its an add
+ my $budget_dropbox;
+ my $budget_parent_id = $budget->{'budget_parent_id'} if $budget;
+ $budget_dropbox = CGI::scrolling_list(
+ -name => 'budget_parent_id',
+ -values => \@values,
+ -default => $budget_parent_id ? $budget_parent_id : undef,
+ -size => 10,
+ -style => "min-width:100px;",
+ -labels => \%labels,
+ );
+ my $budget_parent_dropbox =~ s/\~/ /g; #
+
+ my $branches = GetBranches;
+ my @branchloop_select;
+ foreach my $thisbranch ( keys %$branches ) {
+ my %row = (
+ value => $thisbranch,
+ branchname => $branches->{$thisbranch}->{'branchname'},
+ );
+ $row{selected} = 1 if $thisbranch eq $budget->{'budget_branchcode'};
+ push @branchloop_select, \%row;
+ }
+
+# $period = GetBudgetPeriod($budget->{'budget_period_id'});
+# $budget_period_description = $period->{'budget_period_description'};
+
+ my $budget_perm_dropbox =
+ GetBudgetPermDropbox($budget->{'budget_permission'});
+
+ # if no buget_id is passed then its an add
+ $template->param(
+ add_form => 1,
+ dateformat => C4::Dates->new()->visual(),
+ budget_id => $budget->{'budget_id'},
+ budget_parent_id => $budget->{'budget_parent_id'},
+ budget_parent_dropbox => $budget_parent_dropbox,
+ sort1_authcat_dropbox => $sort1_authcat_dropbox,
+ sort2_authcat_dropbox => $sort2_authcat_dropbox,
+ budget_perm_dropbox => $budget_perm_dropbox,
+ budget_code => $budget->{'budget_code'},
+ budget_code_indent => $budget->{'budget_code_indent'},
+ budget_name => $budget->{'budget_name'},
+ budget_branchcode => $budget->{'budget_branchcode'},
+ budget_amount => sprintf("%.2f", $budget->{'budget_amount'}),
+ budget_amount_sublevel => sprintf("%.2f", $budget->{'budget_amount_sublevel'}),
+ budget_encumb => $budget->{'budget_encumb'},
+ budget_expend => $budget->{'budget_expend'},
+ budget_notes => $budget->{'budget_notes'},
+ budget_description => $budget->{'budget_description'},
+ budget_owner_id => $budget->{'budget_owner_id'},
+ budget_owner_name => $budget->{'budget_owner_name'},
+ budget_permission => $budget->{'budget_permission'},
+ budget_period_id => $budget_period_id,
+ budget_period_description => $budget_period_description,
+ branchloop_select => \@branchloop_select,
+ );
+ # END $OP eq ADD_FORM
+#---------------------- DEFAULT DISPLAPY BELOW ---------------------
+
+# called by default form, used to confirm deletion of data in DB
+} elsif ($op eq 'delete_confirm') {
+
+ my $budget = GetBudget($budget_id);
+ $template->param(
+ budget_id => $budget->{'budget_id'},
+ budget_code => $budget->{'budget_code'},
+ budget_name => $budget->{'budget_name'},
+ budget_amount => $num->format_price( $budget->{'budget_amount'} ),
+ );
+ # END $OP eq DELETE_CONFIRM
+# called by delete_confirm, used to effectively confirm deletion of data in DB
+} else {
+ if ( $op eq 'delete_confirmed' ) {
+ my $rc = DelBudget($budget_id);
+ }
+ if ( $op eq 'add_validate' ) {
+ my %budget_hash = (
+ budget_id => $budget_id,
+ budget_parent_id => $budget_parent_id,
+ budget_period_id => $budget_period_id,
+ budget_code => $budget_code,
+ budget_name => $budget_name,
+ budget_branchcode => $budget_branchcode,
+ budget_amount => $budget_amount,
+ budget_amount_sublevel => $budget_amount_sublevel,
+ budget_encumb => $budget_encumb,
+ budget_expend => $budget_expend,
+ budget_notes => $budget_notes,
+ sort1_authcat => $sort1_authcat,
+ sort2_authcat => $sort2_authcat,
+ budget_description => $budget_description,
+ budget_owner_id => $budget_owner_id,
+ budget_permission => $budget_permission,
+ );
+ if ( defined $budget_id ) {
+ ModBudget( \%budget_hash );
+ } else {
+ AddBudget( \%budget_hash );
+ }
+ }
+ my $branches = GetBranches();
+ my $budget_period_dropbox = GetBudgetPeriodsDropbox($budget_period_id );
+ $template->param(
+ budget_period_dropbox => $budget_period_dropbox,
+ budget_id => $budget_id,
+ budget_period_startdate => $period->{'budget_period_startdate'},
+ budget_period_enddate => $period->{'budget_period_enddate'},
+ );
+ my $moo = GetBudgetHierarchy($budget_period_id, $template->{param_map}->{'USER_INFO'}[0]->{'branchcode'}, $show_mine?$borrower_id:'');
+ my @budgets = @$moo; #FIXME
+
+ my $toggle = 0;
+ my @loop;
+ my $period_total = 0;
+ my ( $period_alloc_total, $base_alloc_total, $sub_alloc_total, $base_spent_total, $base_remaining_total );
+
+ foreach my $budget (@budgets) {
+
+ # PERMISSIONS
+ unless($staffflags->{'superlibrarian'} == 1 ) {
+ #IF NO PERMS, THEN DISABLE EDIT/DELETE
+ unless ( $template->{param_map}->{'CAN_user_acquisition_budget_modify'} ) {
+ $budget->{'budget_lock'} = 1;
+ }
+ # check budget permission
+ if ( $budget_period_locked == 1 ) {
+ $budget->{'budget_lock'} = 1;
+
+ } elsif ( $budget->{budget_permission} == 1 ) {
+
+ if ( $borrower_id != $budget->{'budget_owner_id'} ) {
+ $budget->{'budget_lock'} = 1;
+ }
+ # check parent perms too
+ my $parents_perm = 0;
+ if ( $budget->{depth} > 0 ) {
+ $parents_perm = CheckBudgetParentPerm( $budget, $borrower_id );
+ delete $budget->{'budget_lock'} if $parents_perm == '1';
+ }
+ } elsif ( $budget->{budget_permission} == 2 ) {
+
+ $budget->{'budget_lock'} = 1 if $user_branchcode ne $budget->{budget_branchcode};
+ }
+ } # ...SUPER_LIB END
+
+ # if a budget search doesnt match, next
+ if ($filter_budgetname ) {
+ next unless $budget->{budget_code} =~ m/$filter_budgetname/ ||
+ $budget->{name} =~ m/$filter_budgetname/ ;
+ }
+ if ($filter_budgetbranch ) {
+ next unless $budget->{budget_branchcode} =~ m/$filter_budgetbranch/;
+ }
+
+## TOTALS
+ # adds to total - only if budget is a 'top-level' budget
+ $period_alloc_total += $budget->{'budget_amount_total'} if $budget->{'depth'} == 0;
+ $base_alloc_total += $budget->{'budget_amount'};
+ $sub_alloc_total += $budget->{'budget_amount_sublevel'};
+ $base_spent_total += $budget->{'budget_spent'};
+ $budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'budget_spent'};
+ $base_remaining_total += $budget->{'budget_remaining'};
+
+# if amount == 0 dont display...
+ delete $budget->{'budget_unalloc_sublevel'} if $budget->{'budget_unalloc_sublevel'} == 0 ;
+ delete $budget->{'budget_amount_sublevel'} if $budget->{'budget_amount_sublevel'} == 0 ;
+
+ $budget->{'remaining_pos'} = 1 if $budget->{'budget_remaining'} > 0;
+ $budget->{'remaining_neg'} = 1 if $budget->{'budget_remaining'} < 0;
+ $budget->{'budget_amount'} = $num->format_price( $budget->{'budget_amount'} );
+ $budget->{'budget_spent'} = $num->format_price( $budget->{'budget_spent'} );
+ $budget->{'budget_remaining'} = $num->format_price( $budget->{'budget_remaining'} );
+ $budget->{'budget_amount_total'} = $num->format_price( $budget->{'budget_amount_total'} );
+ $budget->{'budget_amount_sublevel'} = $num->format_price( $budget->{'budget_amount_sublevel'} ) if defined $budget->{'budget_amount_sublevel'};
+ $budget->{'budget_unalloc_sublevel'} = $num->format_price( $budget->{'budget_unalloc_sublevel'} ) if defined $budget->{'budget_unalloc_sublevel'};
+
+ my $borrower = &GetMember( $budget->{budget_owner_id} );
+ $budget->{budget_owner_name} = $borrower->{'firstname'} . ' ' . $borrower->{'surname'};
+ $budget->{budget_borrowernumber} = $borrower->{'borrowernumber'};
+
+ push( @loop, { %{$budget},
+ toggle => $toggle++%2,
+ branchname => $branches->{ $budget->{branchcode} }->{branchname},
+ startdate => format_date($budget->{startdate}),
+ enddate => format_date($budget->{enddate}),
+ }
+ );
+ }
+
+ $template->param(
+ else => 1,
+ budget => \@loop,
+ budget_period_total => $num->format_price($budget_period_total),
+ period_alloc_total => $num->format_price($period_alloc_total),
+ base_alloc_total => $num->format_price($base_alloc_total),
+ sub_alloc_total => $num->format_price($sub_alloc_total),
+ base_spent_total => $num->format_price($base_spent_total),
+ base_remaining_total => $num->format_price($base_remaining_total),
+ period_remaining_total => $num->format_price( $period_alloc_total - $base_alloc_total ),
+ branchloop => \@branchloop2,
+ cur => $cur->{symbol},
+ cur_format => $cur_format,
+ # pagination_bar => pagination_bar(
+ # $script_name, getnbpages(scalar @results, $pagesize),
+ # $page, 'page' ),
+ );
+
+} #---- END $OP eq DEFAULT
+
+output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/admin/check_budget_parent.pl b/admin/check_budget_parent.pl
new file mode 100755
index 0000000..991160e
--- /dev/null
+++ b/admin/check_budget_parent.pl
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+
+# Copyright 2000-2002 Katipo Communications
+#
+# 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., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+use CGI;
+use C4::Context;
+use C4::Output;
+use C4::Auth;
+use C4::Budgets;
+
+=head1
+
+fetches the budget amount fron the DB,
+called by aqbudgets.pl and neworderempty.pl
+
+=cut
+
+my $input = new CGI;
+
+my $budget_id = $input->param('budget_id');
+my $new_parent_id = $input->param('new_parent');
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ { template_name => "acqui/ajax.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ debug => 0,
+ }
+);
+
+my $budget = GetBudget($budget_id);
+my $new_parent_budget = GetBudget($new_parent_id);
+my $result = CheckBudgetParent( $new_parent_budget, $budget );
+$template->param( return => $result );
+
+output_html_with_http_headers $input, $cookie, $template->output;
+1;
diff --git a/admin/check_parent_total.pl b/admin/check_parent_total.pl
new file mode 100755
index 0000000..ac75346
--- /dev/null
+++ b/admin/check_parent_total.pl
@@ -0,0 +1,103 @@
+#!/usr/bin/perl
+
+# Copyright 2000-2002 Katipo Communications
+#
+# 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., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+use CGI;
+use C4::Context;
+use C4::Output;
+use C4::Auth;
+use C4::Budgets;
+
+=head1
+
+This script checks the amount unallocated from the new parent budget , or the period - if no parent_id is given
+
+This script is called from aqbudgets.pl during an 'add' or 'mod' budget, from the JSscript Check() function,
+to determine whether the new parent budget (or period) has enough unallocated funds for the save to complete.
+
+=cut
+
+my $dbh = C4::Context->dbh;
+my $input = new CGI;
+
+my $total = $input->param('total');
+my $budget_id = $input->param('budget_id');
+my $parent_id = $input->param('parent_id');
+my $period_id = $input->param('period_id');
+my $returncode;
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ { template_name => "acqui/ajax.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ debug => 0,
+ }
+);
+my ($period, $parent , $budget);
+$period = GetBudgetPeriod($period_id) if $period_id;
+$parent = GetBudget($parent_id) if defined $parent_id;
+$budget = GetBudget($budget_id) if defined $budget_id;
+
+# CHECK THE PARENT BUDGET FOR ENOUGHT AMOUNT UNALLOCATED, IF NOT THEN RETURN 1
+my ($sub_unalloc , $period_sum, $budget_period_unalloc);
+
+if ($parent) {
+ my $query = " SELECT SUM(budget_amount) as sum FROM aqbudgets where budget_parent_id = ? ";
+ my $sth = $dbh->prepare($query);
+ $sth->execute( $parent->{'budget_id'} );
+ my $sum = $sth->fetchrow_hashref;
+ $sth->finish;
+
+ $sub_unalloc = $parent->{'budget_amount_sublevel'} - $sum->{sum};
+
+# TRICKY.. , IF THE PARENT IS THE CURRENT PARENT - THEN SUBSTRACT CURRENT BUDGET FROM TOTAL
+ if ( $budget->{'budget_parent_id'} == $parent_id ) {
+ $sub_unalloc += ( $budget->{'budget_amount'} + $budget->{'budget_amount_sublevel'} );
+ $budget_period_unalloc += ( $budget->{'budget_amount'} + $budget->{'budget_amount_sublevel'} );
+ }
+}
+
+# ELSE , IF NO PARENT PASSED, THEN CHECK UNALLOCATED FOR PERIOD, IF NOT THEN RETURN 2
+else {
+ my $query = qq| SELECT (SUM(budget_amount_sublevel) + SUM(budget_amount)) as sum
+ FROM aqbudgets WHERE budget_period_id = ?|;
+
+ my $sth = $dbh->prepare($query);
+ $sth->execute( $period->{'budget_period_total'} );
+ $period_sum = $sth->fetchrow_hashref;
+ $sth->finish;
+ $budget_period_unalloc = $period->{'budget_period_total'} - $period_sum->{'sum'};
+}
+
+if ( $parent_id) {
+ if ( $total > $sub_unalloc ) {
+ $returncode = 1;
+ }
+} elsif ( $total > $budget_period_unalloc ) {
+ $returncode = 2;
+
+} else {
+ $returncode = 0;
+}
+
+$template->param( return => $returncode );
+
+output_html_with_http_headers $input, $cookie, $template->output;
+1;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc
index b6b55da..e2d3236 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc
@@ -5,10 +5,10 @@
<h5>Basic parameters</h5>
<ul>
- <li><a href="/cgi-bin/koha/admin/branches.pl">Libraries and groups</a></li>
- <li><a href="/cgi-bin/koha/admin/aqbookfund.pl">Funds and budgets</a></li>
+ <li><a href="/cgi-bin/koha/admin/branches.pl">Libraries, branches, groups</a></li>
+ <li><a href="/cgi-bin/koha/admin/aqbudgets.pl">Budgets, periods, planning</a></li>
<li><a href="/cgi-bin/koha/admin/currency.pl">Currencies and exchange rates</a></li>
- <li><a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a></li>
+ <li><a href="/cgi-bin/koha/admin/itemtypes.pl">Item types and circulation codes</a></li>
</ul>
<h5>Patrons and circulation</h5>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/budgetperiods-admin.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/budgetperiods-admin.inc
new file mode 100644
index 0000000..77898f3
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/budgetperiods-admin.inc
@@ -0,0 +1,37 @@
+<div id="toolbar"><script type="text/javascript">
+ //<![CDATA[
+
+ // prepare DOM for YUI Toolbar
+ $(document).ready(function() {
+ $("#periods_menuc").empty();
+ $("#budgets_menuc").empty();
+ $("#planning_menuc").empty();
+
+ yuiToolbar();
+ });
+
+ // YUI Toolbar Functions
+ function yuiToolbar() {
+ var periods_menu = [
+ { text: _("Display all periods"), url: "/cgi-bin/koha/admin/aqbudgetperiods.pl" },
+ { text: _("New period"), url: "/cgi-bin/koha/admin/aqbudgetperiods.pl?op=add_form" },
+ { text: _("Duplicate period"), },
+ ]
+ new YAHOO.widget.Button({
+ type: "menu",
+ label: _("Budget periods"),
+ name: "periods_button",
+ menu: periods_menu,
+ container: "periods_menuc"
+ });
+ }
+
+ //]]>
+ </script>
+ <ul class="toolbar">
+ <li id="periods_menuc"><a id="periods_menu" href="/cgi-bin/koha/admin/aqbudgetperiods.pl?op=add_form">Budget periods</a></li>
+ <li id="budgets_menuc"><a id="budgets_menu" href="/cgi-bin/koha/cataloguing/addbiblio.pl">Budgets</a></li>
+ <li id="planning_menuc"><a id="planning_menu" href="/cgi-bin/koha/admin/aqplan.pl?budget_period_id=<!-- TMPL_VAR NAME="budget_period_id" -->">Budget planning</a></li>
+
+</ul>
+</div>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-search.inc
new file mode 100644
index 0000000..8fe4b69
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-search.inc
@@ -0,0 +1,119 @@
+
+<h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl"><!-- TMPL_VAR NAME="LibraryName" --></a></h1><!-- Begin Fund Admin Resident Search Box -->
+<!-- TMPL_IF NAME="CAN_user_circulate" --><!-- TMPL_IF NAME="CircAutocompl" --><script type="text/javascript">
+//<![CDATA[
+YAHOO.util.Event.onContentReady("header_search", function() {
+ new function() {
+ // Define a custom formatter function
+ this.fnCustomFormatter = function(oResultItem, sQuery) {
+ var name = oResultItem[0];
+ var cardnumber = oResultItem[1];
+ var address = oResultItem[2];
+ var city = oResultItem[3];
+ var zip = oResultItem[4];
+ var aMarkup = [
+ "<div class=\"sample-result\">",
+ name,
+ " (",
+ cardnumber,
+ ")<small> -- ",
+ address,
+ ", ",
+ city,
+ "</small>",
+ "</div>"];
+ return (aMarkup.join(""));
+ };
+
+ // Instantiate one XHR DataSource and define schema as an array:
+ // ["Record Delimiter",
+ // "Field Delimiter"]
+ this.oACDS = new YAHOO.widget.DS_XHR("/cgi-bin/koha/circ/ysearch.pl", ["\n", "\t"]);
+ this.oACDS.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
+ this.oACDS.maxCacheEntries = 60;
+ this.oACDS.queryMatchSubset = true;
+
+ // Instantiate first AutoComplete
+ var myInput = document.getElementById('findborrower');
+ var myContainer = document.getElementById('yborrowercontainer');
+ this.oAutoComp = new YAHOO.widget.AutoComplete(myInput,myContainer,this.oACDS);
+ //this.oAutoComp.delimChar = ";";
+ //this.oAutoComp.queryDelay = 1;
+ this.oAutoComp.formatResult = this.fnCustomFormatter;
+}
+});
+ //]]>
+ </script> <!-- /TMPL_IF --><!-- /TMPL_IF -->
+<div id="header_search">
+ <div id="budgets_search" class="residentsearch">
+ <p class="tip">Search Budgets:</p>
+
+ <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
+
+
+
+ <label for="filter_budgetname">Name: </label><input type="text" name="filter_budgetname" id="filter_budgetname" size="20" value="<!-- TMPL_VAR name="filter_budgetname" -->" />
+
+
+ <label for="filter_budgetbranch">Library: </label>
+
+ <select name="filter_budgetbranch" id="filter_budgetbranch" style="width:10em;">
+
+ <option value=""></option>
+ <!-- TMPL_LOOP name="branchloop" -->
+ <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="branchname" --></option>
+ <!-- /TMPL_LOOP -->
+ </select>
+
+
+
+
+
+ </select>
+
+
+
+ <input type="hidden" name="budget_period_id" value="<!-- TMPL_VAR NAME="budget_period_id" -->" />
+ <input type="submit" class="submit" name="filter" value="Submit" />
+</form>
+
+ </div>
+ <!-- TMPL_IF NAME="CAN_user_circulate" -->
+ <div id="circ_search" class="residentsearch" style="display:none;">
+ <p class="tip">Enter patron card number or partial name:</p>
+ <form action="/cgi-bin/koha/circ/circulation.pl" method="post">
+ <!-- TMPL_IF NAME="CircAutocompl" -->
+ <div class="autocomplete">
+ <div id="borrowerautocomplete" class="autocomplete">
+ <input autocomplete="off" id="findborrower" name="findborrower" class="focus" type="text" />
+ <div id="yborrowercontainer"></div>
+ <input id="ysearchsubmit" type="submit" class="submit" value="Submit" />
+ <input name="branch" value="<!-- TMPL_VAR name="branch" -->" type="hidden" />
+ <input name="printer" value="" type="hidden" />
+ </div>
+ </div>
+ <!-- TMPL_ELSE -->
+ <input id="findborrower" name="findborrower" size="40" class="focus" type="text" />
+ <input name="branch" value="<!-- TMPL_VAR name="branch" -->" type="hidden" />
+ <input name="printer" value="" type="hidden" />
+ <input value="Submit" class="submit" type="submit" />
+ <!-- /TMPL_IF -->
+ </form>
+ </div>
+ <!-- /TMPL_IF -->
+
+ <!-- TMPL_IF NAME="CAN_user_catalogue" -->
+ <div id="catalog_search" class="residentsearch" style="display:none;">
+ <p class="tip">Enter search keywords:</p>
+ <form action="/cgi-bin/koha/catalogue/search.pl" method="get" id="cat-search-block">
+ <input type="text" name="q" id="search-form" size="40" value="" title="Enter the terms you wish to search for." class="form-text" />
+ <input type="submit" value="Submit" class="submit" />
+ </form>
+ </div><!-- /TMPL_IF -->
+ <ul>
+ <li><a href="/cgi-bin/koha/admin/aqbudgets.pl#budgets_search">Search Budgets</a></li>
+ <!-- TMPL_IF NAME="CAN_user_circulate" --><li><a href="/cgi-bin/koha/circ/circulation.pl#circ_search">Check Out</a></li><!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="CAN_user_catalogue" --><li><a href="/cgi-bin/koha/catalogue/search.pl#catalog_search">Search the Catalog</a></li><!-- /TMPL_IF -->
+ </ul>
+</div>
+<!-- End Suggestions Resident Search Box -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin.inc
new file mode 100644
index 0000000..79dc451
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin.inc
@@ -0,0 +1,124 @@
+<div id="toolbar"><script type="text/javascript">
+ //<![CDATA[
+
+ // prepare DOM for YUI Toolbar
+ $(document).ready(function() {
+ $("#periods_menuc").empty();
+ $("#budgets_menuc").empty();
+
+
+
+// IF THERE IS NO BUDGETS DEFINED YET, THEN DISPLAY PERIOD BUTTON *ONLY*
+<!-- TMPL_UNLESS NAME="period_button_only" -->
+ $("#planning_menuc").empty();
+<!-- /TMPL_UNLESS -->
+
+
+ yuiToolbar();
+ });
+
+ // YUI Toolbar Functions
+
+ function yuiToolbar() {
+ var periods_menu = [
+ { text: _("Display all periods"), url: "/cgi-bin/koha/admin/aqbudgetperiods.pl" },
+ { text: _("New period"), url: "/cgi-bin/koha/admin/aqbudgetperiods.pl?op=add_form" },
+ { text: _("Edit period '<!-- TMPL_VAR NAME="budget_period_description" -->'"), url: "/cgi-bin/koha/admin/aqbudgetperiods.pl?op=add_form&budget_period_id=<!-- TMPL_VAR NAME="budget_period_id" -->" },
+ { text: _("Duplicate period"), },
+ ]
+
+// IF THERE IS NO BUDGETS DEFINED YET, THEN DISPLAY PERIOD BUTTON *ONLY*
+<!-- TMPL_UNLESS NAME="period_button_only" -->
+
+ var budgets_menu = [
+ { text: _("Display budgets"), url: "/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=<!-- TMPL_VAR NAME="budget_period_id" -->" },
+ { text: _("New budget for '<!-- TMPL_VAR NAME="budget_period_description" -->'"), url: "/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_period_id=<!-- TMPL_VAR NAME="budget_period_id" -->"
+ <!-- TMPL_IF NAME="budget_period_locked" -->, id:'disabled' <!-- /TMPL_IF -->
+ <!-- TMPL_UNLESS NAME="CAN_user_acquisition_budget_add_del" -->, id:'disabled' <!-- /TMPL_UNLESS -->
+ },
+ ]
+
+ var planning_menu = [
+
+ { text: _("Plan by MONTHS"),
+ url: "/cgi-bin/koha/admin/aqplan.pl?budget_period_id=<!-- TMPL_VAR NAME="budget_period_id" -->&authcat=MONTHS"
+ <!-- TMPL_UNLESS NAME="CAN_user_acquisition_planning_manage" -->, id:'disabled' <!-- /TMPL_UNLESS -->
+ },
+
+ { text: _("Plan by BRANCHES"),
+ url: "/cgi-bin/koha/admin/aqplan.pl?budget_period_id=<!-- TMPL_VAR NAME="budget_period_id" -->&authcat=BRANCHES"
+ <!-- TMPL_UNLESS NAME="CAN_user_acquisition_planning_manage" -->, id:'disabled' <!-- /TMPL_UNLESS -->
+ },
+
+ { text: _("Plan by ITEMTYPES"),
+ url: "/cgi-bin/koha/admin/aqplan.pl?budget_period_id=<!-- TMPL_VAR NAME="budget_period_id" -->&authcat=ITEMTYPES"
+ <!-- TMPL_UNLESS NAME="CAN_user_acquisition_planning_manage" -->, id:'disabled' <!-- /TMPL_UNLESS -->
+ },
+
+ <!-- TMPL_LOOP NAME="auth_cats_loop" -->
+ { text: _("Plan by <!-- TMPL_VAR NAME="authcat" --> "),
+ url: "/cgi-bin/koha/admin/aqplan.pl?budget_period_id=<!-- TMPL_VAR NAME="budget_period_id" -->&authcat=<!-- TMPL_VAR NAME="authcat" -->"
+ <!-- TMPL_UNLESS NAME="CAN_user_acquisition_planning_manage" -->, id:'disabled' <!-- /TMPL_UNLESS -->
+ },
+
+ <!-- /TMPL_LOOP -->
+
+ ]
+
+
+
+<!-- /TMPL_UNLESS -->
+
+ new YAHOO.widget.Button({
+ type: "menu",
+ label: _("Budget periods"),
+ name: "periods_button",
+ menu: periods_menu,
+ container: "periods_menuc"
+ });
+
+// IF THERE IS NO BUDGETS DEFINED YET, THEN DISPLAY PERIOD BUTTON *ONLY*
+<!-- TMPL_UNLESS NAME="period_button_only" -->
+
+ new YAHOO.widget.Button({
+ type: "menu",
+ label: _("Budgets"),
+ name: "budgets_button",
+ menu: budgets_menu,
+ container: "budgets_menuc"
+ });
+
+
+ new YAHOO.widget.Button({
+ type: "menu",
+ label: _("Budget planning"),
+ name: "planning_button",
+ menu: planning_menu,
+ container: "planning_menuc"
+ });
+
+<!-- /TMPL_UNLESS -->
+
+
+
+
+
+
+
+ } //yui-toolbar...
+
+ //]]>
+ </script>
+ <ul class="toolbar">
+
+ <li id="periods_menuc"><a id="periods_menu" href="/cgi-bin/koha/admin/aqbudgetperiods.pl?op=add_form">Budget periods</a></li>
+
+
+<!-- TMPL_UNLESS NAME="period_button_only" -->
+ <li id="budgets_menuc"><a id="budgets_menu" href="/cgi-bin/koha/cataloguing/addbiblio.pl">Budgets</a></li>
+ <li id="planning_menuc"><a id="planning_menu" href="/cgi-bin/koha/admin/aqplan.pl?budget_period_id=<!-- TMPL_VAR NAME="budget_period_id" -->">Budget planning</a></li>
+<!-- /TMPL_UNLESS -->
+
+
+</ul>
+</div>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudget_owner_search.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudget_owner_search.tmpl
new file mode 100755
index 0000000..0445304
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudget_owner_search.tmpl
@@ -0,0 +1,77 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha › Budget Owner Search</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+ <style type="text/css">
+ #custom-doc { width:44.46em;*width:43.39em;min-width:578px; margin:auto; text-align:left; }
+ </style>
+
+<script type="text/javascript">
+//<![CDATA[
+
+// modify parent window owner element
+function returnOwner(ownerId, ownerName){
+ var top1 = top.opener;
+ top1.document.getElementById('budget_owner_name').innerHTML = ownerName;
+ top1.document.getElementById('budget_owner_id').value = ownerId;
+ window.close();
+}
+//]]>
+</script>
+
+
+</head>
+
+<div id="custom-doc" class="yui-t7">
+ <div id="bd">
+ <div class="yui-g">
+
+
+<h3>Search for Budget Owner</h3>
+ <form action="/cgi-bin/koha/admin/aqbudget_owner_search.pl" method="post">
+ <fieldset>
+ <input type="text" name="member" id="member" value="<!-- TMPL_VAR NAME="member" -->" class="focus" />
+
+
+<!--
+ Ordered by
+ <select name="orderby">
+ <option value="surname,firstname">Surname</option>
+ <option value="cardnumber">Cardnumber</option>
+ </select>
+-->
+
+<input type="submit" class="button" value="Search" /></fieldset>
+<div class="hint">Only staff with superlibrarian or acquisistions permissions are returned from search results</div>
+
+ </form>
+
+
+<!--TMPL_IF NAME="results" -->
+ <p>Searched for <span class="ex"><!-- TMPL_VAR NAME="member" --></span>, <!-- TMPL_VAR Name ="numresults" --> patron(s) found:</p>
+ <table>
+ <tr>
+ <th>Cardnumber</th>
+ <th>Name</th>
+ <th>Branch</th>
+ <th>Categorycode</th>
+ <th>Select?</th>
+ </tr>
+
+ <!-- TMPL_LOOP NAME="resultsloop" -->
+ <!-- TMPL_IF NAME="toggle" --><tr><!-- TMPL_ELSE --><tr class="highlight"><!-- /TMPL_IF -->
+ <td><!-- TMPL_VAR NAME="cardnumber" --></td>
+ <td><!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR NAME="firstname" --></td>
+ <td><!-- TMPL_VAR NAME="branchcode" --></td>
+ <td><!-- TMPL_VAR NAME="categorycode" --></td>
+ <td>
+ <input type="button" value="Select" onclick="returnOwner('<!-- TMPL_VAR NAME="budget_owner_id" -->', '<!-- TMPL_VAR NAME="budget_owner_name" -->');" />
+ </td>
+ </tr>
+ <!-- /TMPL_LOOP -->
+ </table>
+<!--/TMPL_IF-->
+
+<div id="closewindow"><a href="#" class="close">Cancel</a></div>
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tmpl
new file mode 100644
index 0000000..fb7b44c
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tmpl
@@ -0,0 +1,316 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<!-- TMPL_INCLUDE NAME="calendar.inc" -->
+
+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/js/acq.js"></script>
+<script type="text/javascript">
+// #################################################################################
+// Javascript
+// #################################################################################
+ function Check(f) {
+ var ok=1;
+ var _alertString="";
+ var alertString2;
+
+ if (!(isNotNull(f.budget_period_startdate,1))) {
+ _alertString += "\n- " + _("Start date missing");
+ }
+
+ if (!(isNotNull(f.budget_period_enddate,1))) {
+ _alertString += "\n- " + _("End date missing");
+ }
+
+ if ( f.budget_period_startdate > f.budget_period_enddate ) {
+ _alertString += "\n- " + _("Start date must be before end date");
+ }
+
+ if (!(isNotNull(f.budget_period_description,1))) {
+ _alertString += "\n- " + _("Description missing");
+ }
+
+ if (!(isNum(f.budget_period_total))) {
+ _alertString += "\n- " + _("Amount must be a valid number, or empty");
+ }
+
+/*
+ checkBudgetTotal(f) {
+ }
+*/
+
+ if (_alertString.length==0) {
+ f.submit();
+ } else {
+ alertString2 = _("Form not submitted because of the following problem(s)");
+ alertString2 += "\n------------------------------------------------------------------------------------\n";
+ alertString2 += _alertString;
+ alert(alertString2);
+ }
+ }
+</script>
+
+<title>
+ Koha › Administration › Budget periods
+
+ <!-- TMPL_IF name="add_form" -->›
+ <!-- TMPL_IF name="budget_period_id" -->
+ Modify budget period'<!-- TMPL_VAR name="budget_period_id" -->'
+ <!-- TMPL_ELSE -->
+ Add budget period
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_IF -->
+
+ <!-- TMPL_IF name="delete_confirm" -->›
+ Delete budget period '<!-- TMPL_VAR name="budget_period_description" -->'?
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="delete_confirmed" -->›
+ Data Deleted
+ <!-- /TMPL_IF -->
+</title>
+
+
+<head></head>
+
+<body>
+
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="budgets-admin-search.inc" -->
+
+<!-- ################################################################################# -->
+<!-- BREADCRUMBS -->
+<!-- ################################################################################# -->
+
+<div id="breadcrumbs">
+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
+ <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> ›
+
+ <!-- add or modify a budget period -->
+ <!-- ####################################### -->
+ <!-- TMPL_IF name="add_form" -->
+ <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budget periods</a> ›
+ <!-- TMPL_IF name="budget_period_id" -->
+ Modify period <!-- TMPL_VAR name="budget_period_description" -->
+
+ <!-- TMPL_ELSE -->
+ Add budget period
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_IF -->
+
+ <!-- delete a budget period -->
+ <!-- ################################ -->
+ <!-- TMPL_IF name="delete_confirm" -->
+ <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budget periods</a> ›
+ <!-- TMPL_IF name="total" -->
+ Cannot Delete budget period '<!-- TMPL_VAR name="budget_period_description" -->'
+ <!-- TMPL_ELSE -->
+ Delete budget period '<!-- TMPL_VAR name="budget_period_description" -->'?
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_IF -->
+
+ <!-- display budget periods list -->
+ <!-- ########################################## -->
+ <!-- TMPL_IF name="else" -->
+ Budget periods administration
+ <!-- /TMPL_IF -->
+</div>
+
+<div id="doc3" class="yui-t2">
+<div id="bd">
+<div id="yui-main">
+<div class="yui-b">
+
+<!-- TMPL_INCLUDE NAME="budgets-admin.inc" -->
+<! -- FIXME <!-- TMPL_ELSE --> <!-- /TMPL_IF --> -->
+
+<!-- TMPL_IF name="add_form" -->
+ <!-- add or modify a budget period -->
+ <!-- TMPL_IF name="budget_period_id" -->
+ <h3>Modify budget period</h3>
+ <!-- TMPL_ELSE -->
+ <h3>Add budget period</h3>
+<!-- /TMPL_IF -->
+
+<form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" name="Aform" method="post">
+ <fieldset class="rows">
+ <!-- ################################################################################# -->
+ <!-- display information about the budget period that must be added or modified -->
+ <!-- ################################################################################# -->
+ <input type="hidden" name="op" value="add_validate" />
+ <input type="hidden" name="checked" value="0" />
+ <input type="hidden" name="budget_period_id" value="<!-- TMPL_VAR name="budget_period_id" -->" />
+ <ol>
+ <li>
+ <label for="datefrom">Start date</label>
+ <input type="text" size="10" id="budget_period_startdate" name="budget_period_startdate" value="<!-- TMPL_VAR NAME="budget_period_startdate" -->" />
+ <img src="/intranet-tmpl/prog/en/lib/calendar/cal.gif" border="0" id="openCalendarFrom" style="cursor: pointer;" valign="top" />
+ <script type="text/javascript">
+ Calendar.setup({
+ inputField : "budget_period_startdate",
+ ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+ button : "openCalendarFrom",
+ align : "Tl",
+ singleClick : false
+ });
+ </script>
+ </li>
+ <li>
+
+ <label for="budget_period_enddate">End date</label>
+ </th>
+ <td>
+ <input type="text" size="10" id="budget_period_enddate" name="budget_period_enddate" value="<!-- TMPL_VAR NAME="budget_period_enddate" -->" />
+ <img src="/intranet-tmpl/prog/en/lib/calendar/cal.gif" border="0" id="openCalendarTo" style="cursor: pointer;" valign="top" />
+
+ <script type="text/javascript">
+ Calendar.setup({
+ inputField : "budget_period_enddate",
+ ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+ button : "openCalendarTo",
+ align : "Tl",
+ });
+ </script>
+ </li>
+
+ <li>
+ <!-- DESCRIPTION -->
+ <!-- ############################## -->
+ <label for="budget_period_description">Description</label>
+ <input type="text" id="budget_period_description" name="budget_period_description"
+ size="48" maxlength="80" value="<!-- TMPL_VAR name="budget_period_description" -->" />
+ </li>
+
+ <li>
+ <!-- TOTAL -->
+ <!-- ############################## -->
+ <label for="budget_period_total">Total amount</label>
+ <input type="text" id="budget_period_total" name="budget_period_total"
+ size="10" maxlength="80" value="<!-- TMPL_VAR name="budget_period_total" -->" />
+ </li>
+
+ <li>
+ <!-- ACTIVE -->
+ <!-- ############################## -->
+ <label for="budget_period_active">Make Period Active</label>
+ <input type="checkbox" id="budget_period_active" name="budget_period_active" value="1"
+ <!-- TMPL_IF NAME="budget_period_active" -->checked<!-- /TMPL_IF --> />
+ </li>
+
+ <li>
+ <!-- LOCK -->
+ <!-- ############################## -->
+ <label for="budget_period_active">Lock Period</label>
+ <input type="checkbox" id="budget_period_locked" name="budget_period_locked" value="1"
+ <!-- TMPL_IF NAME="budget_period_locked" -->checked<!-- /TMPL_IF --> />
+ </li>
+ </ol>
+ </fieldset>
+
+ <fieldset class="action">
+ <!-- "save changes" button -->
+ <!-- ###################################### -->
+ <input type="button" value="Save Changes" onclick="Check(this.form)" />
+ <!-- <input type="submit" value="Save Changes" /> -->
+ <!-- <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl" class="cancel">Cancel</a> -->
+ </fieldset>
+
+</form>
+
+<!-- /TMPL_IF -->
+
+<!-- ####################################################################### -->
+<!-- delete a budget period -->
+<!-- ####################################################################### -->
+
+<!-- TMPL_IF name="delete_confirm" -->
+ <!-- TMPL_IF name="total" -->
+ <div class="dialog message">
+ <h3>Cannot delete budget period</h3>
+ <p><strong>This record is used <!-- TMPL_VAR name="total" --> times</strong>
+ . Deletion is not possible.</p>
+ <!-- TMPL_ELSE -->
+ <div class="dialog alert">
+ <h3>Delete budget period '<!-- TMPL_VAR name="budget_period_description" -->'?</h3>
+ <!-- /TMPL_IF -->
+
+ <!-- ###################################################################### -->
+ <!-- display information about the budget period that must be deleted -->
+ <!-- ###################################################################### -->
+
+ <table>
+ <tr>
+ <th scope="row">Start date</th>
+ <td><!-- TMPL_VAR name="budget_period_startdate" --></td>
+ </tr>
+
+ <tr>
+ <th scope="row">End date</th>
+ <td><!-- TMPL_VAR name="budget_period_enddate" --></td>
+ </tr>
+
+ <tr>
+ <th scope="row">Total amount</th>
+ <td><!-- TMPL_VAR name="budget_period_total" --></td>
+ </tr>
+ </table>
+
+
+ <!-- ############################################################# -->
+ <!-- "delete" and "quit" buttons -->
+ <!-- ############################################################# -->
+
+ <form action="<!-- TMPL_VAR name="script_name" -->" method="post">
+ <input type="hidden" name="op" value="delete_confirmed" />
+ <input type="hidden" name="budget_period_id" value="<!-- TMPL_VAR name="budget_period_id" -->" />
+ <input type="submit" class="approve" value="Delete" />
+ </form>
+
+ <form action="<!-- TMPL_VAR name="script_name" -->" method="post">
+ <input type="submit" class="deny" value="Quit" />
+ </form>
+
+ </div>
+<!-- /TMPL_IF -->
+<!-- DEFAULT display budget periods list -->
+<!-- TMPL_IF name="else" -->
+ <h2>Budget periods administration</h2>
+ <!-- TMPL_IF name="cur" --><b>Currency = <!-- TMPL_VAR name="cur" --></b><!-- /TMPL_IF -->
+ <table>
+ <tr>
+ <th>Period Name</th>
+ <th>Start Date</th>
+ <th>End Date</th>
+ <th>Active</th>
+ <th>Locked</th>
+ <th>Total</th>
+ <th>Actions</th>
+ </tr>
+
+ <!-- TMPL_LOOP name="period_loop" -->
+ <!-- TMPL_IF NAME="toggle" -->
+ <tr>
+ <!-- TMPL_ELSE -->
+ <tr class="highlight">
+ <!-- /TMPL_IF -->
+ <td><!-- TMPL_VAR name="budget_period_description" --></td>
+ <td><!-- TMPL_VAR name="budget_period_startdate" --></td>
+ <td><!-- TMPL_VAR name="budget_period_enddate" --></td>
+ <td> <font COLOR="#00FF00"> <!-- TMPL_IF name="budget_period_active" -->✓<!-- /TMPL_IF --> </font> </td>
+ <td> <font COLOR="red"> <!-- TMPL_IF name="budget_period_locked" -->X<!-- /TMPL_IF --> </font> </td>
+ <td align='right'><!-- TMPL_VAR NAME="budget_period_total" --></td>
+ <td>
+ <a href="<!-- TMPL_VAR name="script_name" -->?op=add_form&budget_period_id=<!-- TMPL_VAR name="budget_period_id" escape="HTML" -->">Edit</a>
+ <a href="<!-- TMPL_VAR name="script_name"-->?op=delete_confirm&budget_period_id=<!-- TMPL_VAR name="budget_period_id" -->">Delete</a>
+ <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=<!-- TMPL_VAR name="budget_period_id" -->">Budgets</a>
+ </td>
+ </tr>
+ <!-- /TMPL_LOOP -->
+ </table>
+ <div class="paginationBar"><!-- TMPL_VAR NAME="pagination_bar" --></div>
+<!-- /TMPL_IF -->
+
+</div>
+</div>
+<div class="yui-b">
+<!-- TMPL_INCLUDE NAME="admin-menu.inc" -->
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tmpl
new file mode 100644
index 0000000..db599e0
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tmpl
@@ -0,0 +1,360 @@
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<!-- TMPL_INCLUDE NAME="calendar.inc" -->
+<script type="text/javascript" src="<!-- TMPL_VAR NAME='themelang' -->/js/acq.js"></script>
+
+<!-- TMPL_IF name="add_form" -->
+<script type="text/javascript">
+//<![CDATA[
+ //
+ var actTotal ="";
+
+ function ownerRemove(f) {
+ document.getElementById('budget_owner_name').innerHTML = '';
+ }
+
+ function Check(f) {
+ var ok=1;
+ var _alertString="";
+ var alertString2;
+
+ // var actTotal ="";
+
+ if (!(isNotNull(f.budget_code,1))) {
+ _alertString += _("- Budget code missing\n");
+ }
+
+ if (!(isNotNull(f.budget_name,1))) {
+ _alertString += _("- Budget name missing\n");
+ }
+
+ if( ! (isNum(f.budget_amount,0)) && ! (isNum(f.budget_amount_sublevel,0) ) ) {
+ _alertString += _("- Budget base-level and sub-level amount missing or invalid\n");
+ }
+
+ var budgetId;
+ if (typeof(f.budget_id ) != "undefined") {
+ budgetId = f.budget_id.value
+ }
+
+ var newBudgetParent;
+
+// hack to test if selected parent_id in scrolling-list...
+// if value == 'undef' its got a selected_parent :/
+ var chkAdd = f.budget_parent_id.value ;
+ if ( typeof(chkAdd ) != "undefined") {
+ newBudgetParent = f.budget_parent_id.value
+ } else {
+ newBudgetParent = f.budget_parent_id.item(0).value
+ }
+
+ if (budgetId > 0) { ; //its a mod ...
+ // if parent eq curent-budget, fail...
+ if ( newBudgetParent == budgetId ) {
+ _alertString += _("- Budget parent is current budget\n");
+ }
+
+ else if (newBudgetParent) {
+ var result = checkBudgetParent( budgetId , newBudgetParent );
+ if (result) {
+ _alertString += result;
+ }
+ }
+ }
+
+ // else do lookup
+ var budgetTotal = Math.abs(f.budget_amount.value) + Math.abs(f.budget_amount_sublevel.value);
+ var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
+ if (result) {
+ _alertString += result;
+ }
+
+ if (_alertString.length==0) {
+ document.Aform.submit();
+ } else {
+ alertString2 = _("Form not submitted because of the following problem(s)\n");
+ alertString2 += "------------------------------------------------------------------------------------\n\n";
+ alertString2 += _alertString;
+ alert(alertString2);
+ }
+ }
+//]]>
+</script>
+<!-- /TMPL_IF -->
+
+</head>
+<body>
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="budgets-admin-search.inc" -->
+
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
+ <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › <!-- TMPL_IF NAME="else" -->Budgets<!-- /TMPL_IF --><!-- TMPL_IF name="add_form" -->
+ <a href="/cgi-bin/koha/admin/aqbudgets.pl">Budgets</a> › <!-- TMPL_IF NAME="budget_id" -->Modify<!-- TMPL_ELSE -->Add<!-- /TMPL_IF --> Budget<!-- /TMPL_IF --> <!-- TMPL_IF name="delete_confirm" -->
+ <a href="/cgi-bin/koha/admin/aqbudgets.pl">Budgets</a> › Delete Budget?<!-- /TMPL_IF --></div>
+
+<div id="doc3" class="yui-t2">
+<div id="bd">
+<div id="yui-main">
+<div class="yui-b">
+
+<!-- TMPL_INCLUDE NAME="budgets-admin.inc" -->
+<!-- TMPL_IF name="else" -->
+
+<h1>Budgets for '<!-- TMPL_VAR name="budget_period_description" -->'</h1>
+<input type="hidden" name"budget_period_id" value="<!-- TMPL_VAR name= 'budget_period_id' -->" />
+<form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
+ <fieldset>
+ <legend>Budget options</legend>
+ <li><label for="budget_period_dropbox">Select Budget Period:</label>
+ <!-- TMPL_VAR name="budget_period_dropbox" -->
+ <input type="hidden" value="<!-- TMPL_VAR name='budget_period_id' -->" />
+ </li>
+ <li>
+ <label for="budget_branchcode_dropbox">Limit to Branch:</label>
+ <select name="budget_branchcode" >
+ <option value=""></option>
+ <!-- TMPL_LOOP name="branchloop" -->
+ <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="branchname" --></option>
+ <!-- /TMPL_LOOP -->
+ </select>
+
+ <input type="hidden" value="<!-- TMPL_VAR name='budget_period_id' -->" />
+ <li>
+ <!-- TMPL_IF NAME="show_mine" -->
+ <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
+ <!-- TMPL_ELSE -->
+ <input type="checkbox" id="show_mine" name="show_mine" value="1" />
+ <!-- /TMPL_IF -->
+ <label for="show_mine">Show my budgets only</label>
+ </li>
+ <input type="hidden" name="show" value="1" -->
+ <input type="submit" value="Select" />
+</fieldset>
+</form>
+
+<table>
+ <tr>
+ <th>Budget hierarchy</th>
+ <th>Budget name</th>
+ <th>Total<br>allocated</th>
+ <th>Base-level<br>allocated</th>
+ <th>Sub-level<br>allocated (unallocated)</th>
+ <th>Base-level<br>spent</th>
+ <th>Base-level<br>remaining</th>
+ <!--
+ <th>Sub-level<br>spent</th>
+ <th>Encum%</th>
+ <th>Expend%</th>
+ -->
+ <th>Owner</th>
+ <th>Branch</th>
+ <th>Note</th>
+ <th colspan="3">Actions</th>
+ </tr>
+
+<!-- TMPL_LOOP name="budget" -->
+ <!-- TMPL_IF NAME="toggle" -->
+ <tr class="highlight">
+ <!-- TMPL_ELSE -->
+ <tr>
+ <!-- /TMPL_IF -->
+
+ <td><!-- TMPL_VAR NAME="budget_code_indent" --></td>
+ <td><!-- TMPL_VAR NAME="budget_name" --></td>
+ <td align='right'><!-- TMPL_VAR NAME="budget_amount_total" --></td>
+ <td align='right'><!-- TMPL_VAR NAME="budget_amount" --> </td>
+ <!-- TMPL_IF NAME="budget_amount_sublevel" -->
+ <td align='center'><!-- TMPL_VAR NAME="budget_amount_sublevel" -->
+ <!-- TMPL_IF NAME="budget_unalloc_sublevel" -->
+ (<span STYLE="color: green;" > <!-- TMPL_VAR NAME="budget_unalloc_sublevel" --></span>)
+ <!-- /TMPL_IF -->
+ </td>
+ <!-- TMPL_ELSE -->
+ <td align='center'>--</td>
+ <!-- /TMPL_IF -->
+
+ <td align='right'><!-- TMPL_VAR NAME="budget_spent" --> </td>
+ <td align='right'
+ <!-- TMPL_IF NAME="remaining_pos" --> STYLE="color: green;" <!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="remaining_neg" --> STYLE="color: red;" <!-- /TMPL_IF --> >
+ <!-- TMPL_VAR NAME="budget_remaining" --> </td>
+
+ <!--
+ <td><!-- TMPL_VAR NAME="budget_encumb" --></td>
+ <td><!-- TMPL_VAR NAME="budget_expend" --></td>
+ -->
+ <td> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="budget_owner_id" -->"><!-- TMPL_VAR NAME="budget_owner_name" --></a></td>
+
+ <td><!-- TMPL_VAR NAME="budget_branchcode" --></td>
+ <td><!-- TMPL_VAR NAME="budget_notes" --></td>
+ <!-- TMPL_IF NAME='budget_lock'-->
+ <td> <span STYLE="color: gray;" > Edit Delete </span> </td>
+ <!-- TMPL_ELSE -->
+ <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_id=<!-- TMPL_VAR NAME="budget_id" -->&budget_period_id=<!-- TMPL_VAR NAME="budget_period_id" -->" >Edit</a>
+ <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&budget_id=<!-- TMPL_VAR NAME="budget_id" -->">Delete </a></td>
+ <!-- /TMPL_IF -->
+ </tr>
+<!-- /TMPL_LOOP -->
+
+ <tfoot>
+ <tr>
+ <th colspan='2' style='text-align: left;' nowrap>Period allocated <!-- TMPL_VAR NAME='budget_period_total'--> </th>
+ <th nowrap style='text-align: right;' > <!-- TMPL_VAR NAME='period_alloc_total'--></th>
+ <th nowrap style='text-align: right;'> <!-- TMPL_VAR NAME='base_alloc_total'--></th>
+ <th nowrap style='text-align: center;'> <!-- TMPL_VAR NAME='sub_alloc_total'--></th>
+ <th style='text-align: right;' ><!-- TMPL_VAR NAME='base_spent_total'--></th>
+ <th style='text-align: right;' ><!-- TMPL_VAR NAME='base_remaining_total'--></th>
+ <th></th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+ </tfoot>
+</table>
+
+<span><b>Currency = <!-- TMPL_VAR NAME="cur" --> <!-- TMPL_VAR NAME="cur_format" --></b></span><br>
+<div class="paginationBar"><!-- TMPL_VAR NAME="pagination_bar" --></div>
+<!-- /TMPL_IF --> <!-- else -->
+
+<!-- ********************************************************************************************** -->
+<!-- create add/mod entry form -->
+<!-- TMPL_IF name="add_form" -->
+
+<form action="/cgi-bin/koha/admin/aqbudgets.pl" name="Aform" method="post">
+ <fieldset class="rows">
+ <legend><!-- TMPL_IF NAME="budget_id" -->Modify<!-- TMPL_ELSE -->Add<!-- /TMPL_IF --> Budget
+ <!-- TMPL_IF NAME="budget_period_description" -->
+ <!-- TMPL_VAR NAME="budget_name" --> for period <!-- TMPL_VAR NAME="budget_period_description" -->
+ <!-- /TMPL_IF -->
+ </legend>
+
+ <input type="hidden" name="op" value="add_validate" />
+ <input type="hidden" name="checked" value="0" />
+ <ol>
+ <li>
+ <label for="parents">Budget Parent: </label>
+ <!-- TMPL_VAR NAME="budget_parent_dropbox" -->
+
+ <!-- TMPL_IF NAME="budget_id" -->
+ <input type="hidden" name="budget_parent_id" value="<!-- TMPL_VAR NAME="budget_parent_id" -->" />
+ <!-- /TMPL_IF -->
+ </li>
+
+ <li>
+ <label style="color: red;" for="budget_code">Budget Code: </label>
+ <input type="text" name="budget_code" id="budget_code" value="<!-- TMPL_VAR NAME="budget_code" -->" size="30" />
+ </li>
+
+ <li>
+ <label style="color: red;" for="budget_name">Budget Name: </label>
+ <input type="text" name="budget_name" id="budget_name" value="<!-- TMPL_VAR NAME="budget_name" -->" size="60" />
+ </li>
+
+ <div class='hint'>base-level and sub-level amount fields cannot both be empty</div>
+ <li>
+ <label style='white-space: nowrap;' for="budget_amount">Base-level amount: </label>
+ <input type="text" name="budget_amount" id="budget_amount" value="<!-- TMPL_VAR NAME="budget_amount" -->" size="8" />
+ </li>
+
+ <li>
+ <label for="budget_amount_sublevel">Sub-level amount: </label>
+ <input type="text" name="budget_amount_sublevel" id="budget_amount_sublevel" value="<!-- TMPL_VAR NAME="budget_amount_sublevel" -->" size="8" />
+ </li>
+
+ <li>
+ <label for="">Encumberance: </label>
+ <input type="text" name="budget_encumb" id="budget_encumb" value="<!-- TMPL_VAR NAME="budget_encumb" -->" size="8" />
+ </li>
+
+ <li>
+ <label for="">Expenditure: </label>
+ <input type="text" name="budget_expend" id="budget_expend" value="<!-- TMPL_VAR NAME="budget_expend" -->" size="8" />
+ </li>
+
+ <input type="hidden" name="budget_owner_id" id="budget_owner_id" value='<!-- TMPL_VAR NAME="budget_owner_id" -->' />
+ <li>
+ <label for="parents">Owner: </label>
+ <span id="budget_owner_name">
+ <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="budget_owner_id" -->"><!-- TMPL_VAR NAME="budget_owner_name" --></a>
+ </span>
+
+ <!-- FIXME: hardcoded button positions :/ -->
+ <input style="position:absolute; left:600px;" type="button" id="patron_search" value="Edit owner" onclick="ownerPopup(); return false;" />
+ <input style="position:absolute; left:680px;" type="button" id="patron_search" value="Remove owner" onclick="ownerRemove(this.form); return false;" />
+ </li>
+ </td>
+ </tr>
+ </table>
+
+ <li>
+ <label for="branch">Library: </label>
+ <select name="budget_branchcode">
+ <option value=""></option>
+ <!-- TMPL_LOOP name="branchloop_select" -->
+ <option value="<!-- TMPL_VAR name="value" -->"
+ <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF --> >
+ <!-- TMPL_VAR name="branchname" --></option>
+ <!-- /TMPL_LOOP -->
+ </select>
+ </li>
+
+ <li>
+ <label for="branch">Restrict access to: </label>
+ <!-- TMPL_VAR name="budget_perm_dropbox" -->
+ </li>
+
+ <li>
+ <label for="">Notes: </label>
+ <textarea name="budget_notes" id="budget_notes" cols="80" rows="6" ><!-- TMPL_VAR NAME='budget_notes' --></textarea>
+ </li>
+
+ <li>
+ <label style='white-space: nowrap;' for="parents">Planning Category1: </label>
+ <!-- TMPL_VAR NAME="sort1_authcat_dropbox" -->
+ </li>
+ <li>
+ <label style='white-space: nowrap;' for="parents">Planning Category2: </label>
+ <!-- TMPL_VAR NAME="sort2_authcat_dropbox" -->
+ </li>
+ </ol>
+
+ <!-- TMPL_IF NAME="budget_id" -->
+ <input type="hidden" name="budget_id" value="<!-- TMPL_VAR NAME='budget_id' -->" />
+ <!-- /TMPL_IF -->
+ </fieldset>
+
+ <fieldset class="action">
+ <input type="button" value="Submit" onclick="Check(this.form)" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
+ <input type="hidden" name="budget_period_id" value="<!-- TMPL_VAR name='budget_period_id' -->" />
+ </fieldset>
+</form>
+
+<!-- /TMPL_IF --> <!-- add_form -->
+
+<!-- TMPL_IF name="delete_confirm" -->
+<div class="dialog alert"> <h3>Delete Budget <!-- TMPL_VAR NAME="budget_name" -->?</h3>
+<table>
+ <<tr>
+ <th scope="row">Budget Amount:</td>
+ <td><!-- TMPL_VAR NAME="budget_amount" --></td>
+ </tr>
+</table>
+
+<form action="<!-- TMPL_VAR NAME="action" -->" method="post">
+ <input type="hidden" name="op" value="delete_confirmed" />
+ <input type="hidden" name="budget_id" value="<!-- TMPL_VAR NAME="budget_id" -->" />
+ <input type="submit" value="Delete this budget" class="approve" />
+</form>
+
+<form action="<!-- TMPL_VAR NAME="action" -->" method="get">
+ <input type="submit" class="deny" value="No, Do Not Delete" />
+</form>
+</div>
+<!-- /TMPL_IF -->
+
+</div>
+</div>
+<div class="yui-b">
+ <!-- TMPL_INCLUDE NAME="admin-menu.inc" -->
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
--
1.6.0.4
More information about the Koha-patches
mailing list