From d399ff3494e632c6e74dd1ec5ecebbfaee5be49f Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Wed, 16 Sep 2009 16:02:35 +0200 Subject: [PATCH] [biblibre-newacq](bug #3611) fix user interface and others This big patch, fix xhtml code, and user interface. It Delete the term of budget period and use it as "Root Budget". It add improvment on UI, adding tooltip, and table tree. --- C4/Budgets.pm | 17 +- admin/aqbudgetperiods.pl | 2 +- admin/aqbudgets.pl | 41 ++- admin/check_parent_total.pl | 21 +- installer/data/mysql/kohastructure.sql | 1 - installer/data/mysql/updatedatabase.pl | 6 + .../prog/en/includes/budgetperiods-admin.inc | 10 +- .../prog/en/includes/budgets-admin-search.inc | 8 - .../prog/en/includes/budgets-admin.inc | 12 +- .../prog/en/lib/jquery/plugins/jquery.qtip.js | 15 ++ .../treetable/images/toggle-collapse-dark.png | Bin 0 -> 2886 bytes .../images/toggle-collapse-light.png | Bin 0 -> 2864 bytes .../treetable/images/toggle-expand-dark.png | Bin 0 -> 2894 bytes .../treetable/images/toggle-expand-light.png | Bin 0 -> 2863 bytes .../plugins/treetable/jquery.treeTable.min.js | 13 + .../stylesheets/jquery.treeTable.css | 43 ++++ .../prog/en/modules/admin/admin-home.tmpl | 4 +- .../en/modules/admin/aqbudgetperiods.tmpl | 75 +++--- .../prog/en/modules/admin/aqbudgets.tmpl | 240 ++++++++++-------- kohaversion.pl | 2 +- t/db_dependent/Budgets.t | 1 - 21 files changed, 292 insertions(+), 219 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.qtip.js create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/treetable/images/toggle-collapse-dark.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/treetable/images/toggle-collapse-light.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/treetable/images/toggle-expand-dark.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/treetable/images/toggle-expand-light.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/treetable/jquery.treeTable.min.js create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/treetable/stylesheets/jquery.treeTable.css diff --git a/C4/Budgets.pm b/C4/Budgets.pm index a78bafe204..d17bfe7207 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -532,9 +532,8 @@ sub GetBudgetHierarchy { # add indent my $depth = $r->{depth} * 2; - my $space = pack "A[$depth]"; - $r->{budget_code_indent} = $space . $r->{budget_code}; - $r->{budget_name_indent} = $space . $r->{budget_name}; + $r->{budget_code_indent} = $r->{budget_code}; + $r->{budget_name_indent} = $r->{budget_name}; foreach my $r3 (@sort) { if ($r3->{budget_id} == $r->{budget_parent_id}) { $parent = $i2; @@ -546,7 +545,7 @@ sub GetBudgetHierarchy { $r->{budget_code_indent} = $r->{budget_code}; $r->{budget_name_indent} = $r->{budget_name}; } - + if (defined $parent) { splice @sort, ($parent + 1), 0, $r; } else { @@ -575,7 +574,7 @@ sub GetBudgetHierarchy { $r->{'budget_spent'} = GetBudgetSpent( $r->{'budget_id'} ); - $r->{'budget_amount_total'} = $r->{'budget_amount'} + $r->{'budget_amount_sublevel'} ; + $r->{'budget_amount_total'} = $r->{'budget_amount'}; # foreach sub-levels my $unalloc_count ; @@ -584,14 +583,8 @@ sub GetBudgetHierarchy { my $sub_budget = GetBudget($sub); $r->{budget_spent_sublevel} += GetBudgetSpent( $sub_budget->{'budget_id'} ); - $unalloc_count += $sub_budget->{'budget_amount'} + $sub_budget->{'budget_amount_sublevel'}; + $unalloc_count += $sub_budget->{'budget_amount'}; } - - $r->{budget_unalloc_sublevel} = $r->{'budget_amount_sublevel'} - $unalloc_count; - - if ( scalar @subs_arr == 0 && $r->{budget_amount_sublevel} > 0 ) { - $r->{warn_no_subs} = 1; - } } return \@sort; } diff --git a/admin/aqbudgetperiods.pl b/admin/aqbudgetperiods.pl index 326385f894..b12f85ebda 100755 --- a/admin/aqbudgetperiods.pl +++ b/admin/aqbudgetperiods.pl @@ -67,7 +67,7 @@ my $budget_period_hashref= $input->Vars; #my $sort1_authcat = $input->param('sort1_authcat'); #my $sort2_authcat = $input->param('sort2_authcat'); -my $pagesize = 10; +my $pagesize = 20; $searchfield =~ s/\,//g; my ($template, $borrowernumber, $cookie, $staff_flags ) = get_template_and_user( diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl index a537908105..8f45e99cb3 100755 --- a/admin/aqbudgets.pl +++ b/admin/aqbudgets.pl @@ -71,9 +71,11 @@ my $budget_permission = $input->param('budget_permission'); my $budget_period_dropbox = $input->param('budget_period_dropbox'); #filtering non budget keys delete $$budget_hash{$_} foreach grep {/filter|^op$|show/} keys %$budget_hash; -my $filter_budgetname = $input->param('filter_budgetname'); my $filter_budgetbranch = $input->param('filter_budgetbranch'); - +my $filter_budgetname = $input->param('filter_budgetname'); +$template->param( + notree => ($filter_budgetbranch or $show_mine) +); # ' ------- get periods stuff ------------------' # IF PERIODID IS DEFINED, GET THE PERIOD - ELSE JUST GET THE ACTIVE PERIOD BY DEFAULT my $period = GetBudgetPeriod($$budget_hash{budget_period_id}); @@ -138,16 +140,14 @@ if ($op eq 'add_form') { } push @values, ''; # if no buget_id is passed then its an add - my $budget_parent_dropbox; - my $budget_parent_id = $budget->{'budget_parent_id'} if $budget; - $budget_parent_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; + my $budget_parent_id; + if ($budget){ + $budget_parent_id = $budget->{'budget_parent_id'} ; + }else{ + $budget_parent_id = $input->param('budget_parent_id'); + } + $budget_parent = GetBudget($budget_parent_id); # build branches select my $branches = GetBranches; @@ -187,7 +187,8 @@ if ($op eq 'add_form') { $template->param( add_validate => 1, dateformat => C4::Dates->new()->visual(), - budget_dropbox => $budget_parent_dropbox, + budget_parent_id => $budget_parent->{'budget_id'}, + budget_parent_name => $budget_parent->{'budget_name'}, budget_perm_dropbox => $budget_perm_dropbox, branchloop_select => \@branchloop_select, %$period, @@ -208,17 +209,16 @@ if ($op eq 'add_form') { ); # END $OP eq DELETE_CONFIRM # called by delete_confirm, used to effectively confirm deletion of data in DB -} else { +} else{ if ( $op eq 'delete_confirmed' ) { my $rc = DelBudget($budget_id); - } - if ( $op eq 'add_validate' ) { + }elsif( $op eq 'add_validate' ) { if ( defined $$budget_hash{budget_id} ) { ModBudget( $budget_hash ); } else { AddBudget( $budget_hash ); } - } + } my $branches = GetBranches(); my $budget_period_dropbox = GetBudgetPeriodsDropbox($$period{budget_period_id} ); $template->param( @@ -226,20 +226,20 @@ if ($op eq 'add_form') { budget_id => $budget_id, %$period, ); + my $moo = GetBudgetHierarchy($$period{budget_period_id}, C4::Context->userenv->{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 ); + my ( $period_alloc_total, $base_alloc_total, $base_spent_total, $base_remaining_total ); use YAML; $debug && warn Dump(@budgets); #This Looks WEIRD to me : should budgets be filtered in such a way ppl who donot own it would not see the amount spent on the budget by others ? foreach my $budget (@budgets) { - # PERMISSIONS unless($staffflags->{'superlibrarian'} % 2 == 1 ) { #IF NO PERMS, THEN DISABLE EDIT/DELETE @@ -280,14 +280,12 @@ if ($op eq 'add_form') { # 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; @@ -312,7 +310,6 @@ if ($op eq 'add_form') { budget_period_total => $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 ), diff --git a/admin/check_parent_total.pl b/admin/check_parent_total.pl index ac7534661f..ec5dd8b6c3 100755 --- a/admin/check_parent_total.pl +++ b/admin/check_parent_total.pl @@ -64,33 +64,30 @@ if ($parent) { $sth->execute( $parent->{'budget_id'} ); my $sum = $sth->fetchrow_hashref; $sth->finish; - - $sub_unalloc = $parent->{'budget_amount_sublevel'} - $sum->{sum}; - + + $sub_unalloc = $parent->{'budget_amount'} - $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'} ); - } + $sub_unalloc += $budget->{'budget_amount'} if ( $budget->{'budget_parent_id'} == $parent_id ) ; } # 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 + my $query = qq| SELECT SUM(budget_amount) as sum FROM aqbudgets WHERE budget_period_id = ?|; my $sth = $dbh->prepare($query); - $sth->execute( $period->{'budget_period_total'} ); + $sth->execute( $period_id ); $period_sum = $sth->fetchrow_hashref; $sth->finish; - $budget_period_unalloc = $period->{'budget_period_total'} - $period_sum->{'sum'}; + $budget_period_unalloc = $period->{'budget_period_total'} - $period_sum->{'sum'} if $period->{'budget_period_total'}; } if ( $parent_id) { - if ( $total > $sub_unalloc ) { + if ( ($total > $sub_unalloc ) && $sub_unalloc ) { $returncode = 1; } -} elsif ( $total > $budget_period_unalloc ) { +} elsif ( ( $total > $budget_period_unalloc ) && $budget_period_unalloc ) { $returncode = 2; } else { diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index e5bc5dc872..e8bd67566f 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2320,7 +2320,6 @@ CREATE TABLE `aqbudgets` ( `budget_name` varchar(80) default NULL, `budget_branchcode` varchar(10) default NULL, `budget_amount` decimal(28,6) NULL default '0.00', - `budget_amount_sublevel` decimal(28,6) NULL default '0.00', `budget_encumb` decimal(28,6) NULL default '0.00', `budget_expend` decimal(28,6) NULL default '0.00', `budget_notes` mediumtext, diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 4af909f0e7..5009cb9287 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -3024,6 +3024,12 @@ COMMENT SetVersion ($DBversion); } +$DBversion = "3.01.00.115"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("ALTER table aqbudgets drop column budget_amount_sublevel;"); + print "Upgrade to $DBversion done drop column budget_amount_sublevel from aqbudgets\n"; + SetVersion ($DBversion); +} =item DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/budgetperiods-admin.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/budgetperiods-admin.inc index 77898f3b5f..368d6a8a65 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/budgetperiods-admin.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/budgetperiods-admin.inc @@ -13,13 +13,13 @@ // 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"), }, + { text: _("Display all root budgets"), url: "/cgi-bin/koha/admin/aqbudgetperiods.pl" }, + { text: _("New root budget"), url: "/cgi-bin/koha/admin/aqbudgetperiods.pl?op=add_form" }, + { text: _("Duplicate root budget"), }, ] new YAHOO.widget.Button({ type: "menu", - label: _("Budget periods"), + label: _("Root Budgets"), name: "periods_button", menu: periods_menu, container: "periods_menuc" @@ -29,7 +29,7 @@ //]]>