@EXPORT = qw(
&GetBudget
+ &GetBudgetByOrderNumber
&GetBudgets
&GetBudgetHierarchy
&AddBudget
&DelBudget
&GetBudgetSpent
&GetBudgetOrdered
+ &GetBudgetName
&GetPeriodsCount
&GetChildBudgetsSpent
return $sum;
}
+=head2 GetBudgetName
+
+ my $budget_name = &GetBudgetName($budget_id);
+
+get the budget_name for a given budget_id
+
+=cut
+
+sub GetBudgetName {
+ my ( $budget_id ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare(
+ qq|
+ SELECT budget_name
+ FROM aqbudgets
+ WHERE budget_id = ?
+ |);
+
+ $sth->execute($budget_id);
+ return $sth->fetchrow_array;
+}
+
# -------------------------------------------------------------------
sub GetBudgetAuthCats {
my ($budget_period_id) = shift;
return $result;
}
+=head2 GetBudgetByOrderNumber
+
+ &GetBudgetByOrderNumber($ordernumber);
+
+get a specific budget by order number
+
+=cut
+
+# -------------------------------------------------------------------
+sub GetBudgetByOrderNumber {
+ my ( $ordernumber ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $query = "
+ SELECT aqbudgets.*
+ FROM aqbudgets, aqorders
+ WHERE ordernumber=?
+ AND aqorders.budget_id = aqbudgets.budget_id
+ ";
+ my $sth = $dbh->prepare($query);
+ $sth->execute( $ordernumber );
+ my $result = $sth->fetchrow_hashref;
+ return $result;
+}
+
=head2 GetChildBudgetsSpent
&GetChildBudgetsSpent($budget-id);
# -------------------------------------------------------------------
sub GetBudgets {
- my ($filters,$orderby) = @_;
+ my $filters = shift;
+ my $orderby = shift || 'budget_name';
return SearchInTable("aqbudgets",$filters, $orderby, undef,undef, undef, "wide");
}
return ( $price / $cur );
}
-=head2 _columns
-
-returns an array containing fieldname followed by PRI as value if PRIMARY Key
-
-=cut
-
-sub _columns(;$) {
- my $tablename=shift||"aqbudgets";
- return @{C4::Context->dbh->selectcol_arrayref("SHOW columns from $tablename",{Columns=>[1,4]})};
-}
-
-sub _filter_fields{
- my $budget=shift;
- my $tablename=shift;
- my @keys;
- my @values;
- my %columns= _columns($tablename);
- #Filter Primary Keys of table
- my $elements=join "|",grep {$columns{$_} ne "PRI"} keys %columns;
- foreach my $field (grep {/\b($elements)\b/} keys %$budget){
- $$budget{$field}=format_date_in_iso($$budget{$field}) if ($field=~/date/ && $$budget{$field} !~C4::Dates->regexp("iso"));
- my $strkeys= " $field = ? ";
- if ($field=~/branch/){
- $strkeys="( $strkeys OR $field='' OR $field IS NULL) ";
- }
- push @values, $$budget{$field};
- push @keys, $strkeys;
- }
- return (\@keys,\@values);
-}
-
END { } # module clean-up code here (global destructor)
1;