Bug Fixing : 1st Step Bookfund has become Budgets

More bug fixing on Suggestions and Budgets
This commit is contained in:
Henri-Damien LAURENT 2009-08-14 15:40:40 +02:00
parent 7315f1fa54
commit 38b61303bd
6 changed files with 84 additions and 106 deletions

View file

@ -468,40 +468,42 @@ sub DelBudgetPeriod() {
## get information about the record that will be deleted
my $sth = $dbh->prepare(qq|
SELECT budget_period_id
, budget_period_startdate
, budget_period_enddate
, budget_period_amount
, budget_period_ref
, budget_period_description
DELETE
FROM aqbudgetperiods
WHERE budget_period_id=? |
);
$sth->execute($budget_period_id);
my $data = $sth->fetchrow_hashref;
$sth->finish;
return $sth->execute($budget_period_id);
}
# -------------------------------------------------------------------
sub ModBudgetPeriod() {
my ($budget_period_id) = @_;
my $dbh = C4::Context->dbh
; ## $total = number of records linked to the record that must be deleted my $total = 0;
my ($budget_period_information) = @_;
my $dbh = C4::Context->dbh ; ## $total = number of records linked to the record that must be deleted my $total = 0;
## get information about the record that will be deleted
my $sth = $dbh->prepare("
SELECT budget_period_id
, budget_period_startdate
, budget_period_enddate
, budget_period_amount
, budget_period_ref
, budget_period_description
FROM aqbudgetperiods
WHERE budget_period_id=?;"
);
$sth->execute($budget_period_id);
my $data = $sth->fetchrow_hashref;
$sth->finish;
my $budget_period_id=$$budget_period_information{'budget_period_id'};
delete $$budget_period_information{'budget_period_id'};
my @values;
my @keys;
while ( my ($k,$v) = each %$budget_period_information ) {
next if (not $v and $k!~/sort1|note/);
#next if any { $_ eq $k } qw( sort1 note);
push @values, $v;
push @keys, "$k=?";
}
my $query = do { local $"=',';
qq{
UPDATE aqbudgetperiods
SET @keys
WHERE budget_period_id=?
}
};
my $sth=$dbh->prepare($query);
my $data = $sth->execute(@values,$budget_period_id);
return $data;
}
# -------------------------------------------------------------------
@ -644,85 +646,55 @@ sub GetBudgetHierarchy {
sub AddBudget {
my ($budget) = @_;
my $dbh = C4::Context->dbh;
my $query = qq|
INSERT INTO aqbudgets
SET budget_code = ?,
budget_period_id = ?,
budget_parent_id = ?,
budget_name = ?,
budget_branchcode = ?,
budget_amount = ?,
budget_amount_sublevel = ?,
budget_encumb = ?,
budget_expend = ?,
budget_notes = ?,
sort1_authcat = ?,
sort2_authcat = ?,
budget_owner_id = ?,
budget_permission = ?
|;
my $sth = $dbh->prepare($query);
$sth->execute(
$budget->{'budget_code'} ? $budget->{'budget_code'} : undef,
$budget->{'budget_period_id'} ? $budget->{'budget_period_id'} : undef,
$budget->{'budget_parent_id'} ? $budget->{'budget_parent_id'} : undef,
$budget->{'budget_name'} ? $budget->{'budget_name'} : undef,
$budget->{'budget_branchcode'} ? $budget->{'budget_branchcode'} : undef,
$budget->{'budget_amount'} ? $budget->{'budget_amount'} : undef,
$budget->{'budget_amount_sublevel'} ? $budget->{'budget_amount_sublevel'} : undef,
$budget->{'budget_encumb'} ? $budget->{'budget_encumb'} : undef,
$budget->{'budget_expend'} ? $budget->{'budget_expend'} : undef,
$budget->{'budget_notes'} ? $budget->{'budget_notes'} : undef,
$budget->{'sort1_authcat'} ? $budget->{'sort1_authcat'} : undef,
$budget->{'sort2_authcat'} ? $budget->{'sort2_authcat'} : undef,
$budget->{'budget_owner_id'} ? $budget->{'budget_owner_id'} : undef,
$budget->{'budget_permission'} ? $budget->{'budget_permission'} : undef,
);
$sth->finish;
my @keys; my @values;
while ( my ($k,$v) = each %$budget ) {
next unless $v;
push @values, $v;
push @keys , "$k = ?";
}
my $query = do {
local $" = ',';
qq{
INSERT INTO aqbudgets
SET @keys
};
};
#warn $query;
my $sth = $dbh->prepare($query);
$sth->execute(@values);
return $dbh->{'mysql_insertid'};
}
# -------------------------------------------------------------------
sub ModBudget {
my ($budget) = @_;
my $dbh = C4::Context->dbh;
my $query = qq|
UPDATE aqbudgets
SET budget_code = ?,
budget_period_id = ?,
budget_parent_id = ?,
budget_name = ?,
budget_branchcode = ?,
budget_amount = ?,
budget_amount_sublevel = ?,
budget_encumb = ?,
budget_expend = ?,
budget_notes = ?,
sort1_authcat = ?,
sort2_authcat = ?,
budget_owner_id = ?,
budget_permission = ?
WHERE budget_id = ?
|;
my $budgetid=$$budget{'budgetid'};
delete $$budget{'budget_id'};
my @values;
my @keys;
while ( my ($k,$v) = each %$budget ) {
next if (not $v and $k!~/sort1|note/);
#next if any { $_ eq $k } qw( sort1 note);
push @values, $v;
push @keys, "$k=?";
}
my $query = do { local $"=',';
qq{
UPDATE aqbudgets
SET @keys
WHERE budget_id=?
};
};
my $sth = $dbh->prepare($query);
$sth->execute(
$budget->{'budget_code'} ? $budget->{'budget_code'} : undef,
$budget->{'budget_period_id'} ? $budget->{'budget_period_id'} : undef,
$budget->{'budget_parent_id'} ? $budget->{'budget_parent_id'} : undef,
$budget->{'budget_name'} ? $budget->{'budget_name'} : undef,
$budget->{'budget_branchcode'} ? $budget->{'budget_branchcode'} : undef,
$budget->{'budget_amount'} ? $budget->{'budget_amount'} : undef,
$budget->{'budget_amount_sublevel'} ? $budget->{'budget_amount_sublevel'} : undef,
$budget->{'budget_encumb'} ? $budget->{'budget_encumb'} : undef,
$budget->{'budget_expend'} ? $budget->{'budget_expend'} : undef,
$budget->{'budget_notes'} ? $budget->{'budget_notes'} : undef,
$budget->{'sort1_authcat'} ? $budget->{'sort1_authcat'} : undef,
$budget->{'sort2_authcat'} ? $budget->{'sort2_authcat'} : undef,
$budget->{'budget_owner_id'} ? $budget->{'budget_owner_id'} : undef,
$budget->{'budget_permission'} ? $budget->{'budget_permission'} : undef,
$budget->{'budget_id'},
);
$sth->finish;
$sth->execute( @values,$budgetid);
}
# -------------------------------------------------------------------

View file

@ -27,7 +27,7 @@ use C4::Dates qw(format_date);
use C4::SQLHelper qw(:all);
use C4::Debug;
use C4::Letters;
use List::MoreUtils qw(any);
use List::MoreUtils qw<any>;
use base 'Exporter'; # parent would be better there
our $VERSION = 3.01;
our @EXPORT = qw<
@ -201,7 +201,7 @@ sub GetSuggestion {
=head2 GetSuggestionFromBiblionumber
$ordernumber = &GetSuggestionFromBiblionumber($dbh,$biblionumber)
$ordernumber = &GetSuggestionFromBiblionumber($biblionumber)
Get a suggestion from it's biblionumber.
@ -211,12 +211,13 @@ the id of the suggestion which is related to the biblionumber given on input arg
=cut
sub GetSuggestionFromBiblionumber {
my ($dbh,$biblionumber) = @_;
my $query = qq|
my ($biblionumber) = @_;
my $query = q{
SELECT suggestionid
FROM suggestions
WHERE biblionumber=?
|;
};
my $dbh=C4::Context->dbh;
my $sth = $dbh->prepare($query);
$sth->execute($biblionumber);
my ($ordernumber) = $sth->fetchrow;
@ -344,7 +345,7 @@ sub CountSuggestion {
=head2 NewSuggestion
&NewSuggestion($suggestion)
&NewSuggestion($suggestion);
Insert a new suggestion on database with value given on input arg.

View file

@ -69,7 +69,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my $borrower= GetMember('borrowernumber' => $loggedinuser);
my ( $flags, $homebranch )= ($borrower->{'flags'},$borrower->{'branchcode'});
my @results = GetBookFunds($homebranch);
my @results = GetBudgets($homebranch);
my $count = scalar @results;
my $branchname = GetBranchName($homebranch);

View file

@ -224,7 +224,7 @@ if ($op eq 'add_form') {
dateformat => C4::Dates->new()->visual(),
budget_id => $budget->{'budget_id'},
budget_parent_id => $budget->{'budget_parent_id'},
budget_dropbox => $budget_dropbox,
budget_dropbox => $budget_period_dropbox,
budget_perm_dropbox => $budget_perm_dropbox,
budget_code => $budget->{'budget_code'},
budget_code_indent => $budget->{'budget_code_indent'},

View file

@ -2920,11 +2920,11 @@ INSERT INTO permissions (module_bit, code, description) VALUES
(11, 'contracts_manage', 'Manage contracts'),
(11, 'period_manage', 'Manage periods'),
(11, 'budget_manage', 'Manage budgets'),
(11, 'budget_modify', "Modify budget (can't create lines, but can modify existing ones)"),
(11, 'budget_modify', "Modify budget (can't create lines but can modify existing ones)"),
(11, 'planning_manage', 'Manage budget plannings'),
(11, 'order_manage', 'Manage orders & basket'),
(11, 'group_manage', 'Manage orders & basketgroups'),
(11, 'order_receive', 'Manage orders & basket')
(11, 'order_receive', 'Manage orders & basket'),
(11, 'budget_add_del', "Add and delete budgets (but can't modify budgets)");
BUDG_PERM

View file

@ -207,6 +207,11 @@ $template->param(
####################
## Initializing selection lists
#branch display management
my @bookfunds = GetBudgets($branchfilter||'');
map{$_->{'selected'}=1 if ($$suggestion_ref{'bookfundid'} && $_->{'bookfundid'} eq $$suggestion_ref{'bookfundid'})} @bookfunds;
$template->param( bookfundsloop => \@bookfunds);
#branch display management
my $onlymine=C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&