X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FBudgets.pm;h=005bba8d176629a9c015c7ce9117a3670a5da066;hb=fe99800a2e39fba1c6369bdfe3f600119308514a;hp=eeb9b0c15fa208e61a41aadfb379aac7da0bd93f;hpb=593a7d8e6acc92a8bc7842d1beda2983b570613e;p=koha_fer diff --git a/C4/Budgets.pm b/C4/Budgets.pm index eeb9b0c15f..005bba8d17 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -42,6 +42,7 @@ BEGIN { &GetBudgetSpent &GetBudgetOrdered &GetPeriodsCount + &GetChildBudgetsSpent &GetBudgetPeriod &GetBudgetPeriods @@ -76,6 +77,10 @@ BEGIN { # ----------------------------BUDGETS.PM-----------------------------"; +=head1 FUNCTIONS ABOUT BUDGETS + +=cut + sub HideCols { my ( $authcat, @hide_cols ) = @_; my $dbh = C4::Context->dbh; @@ -631,24 +636,13 @@ sub DelBudget { return $rc; } -=head2 FUNCTIONS ABOUT BUDGETS - -=over 2 - -=cut - -=back -=head3 GetBudget +=head2 GetBudget -=over 4 - -&GetBudget($budget_id); + &GetBudget($budget_id); get a specific budget -=back - =cut # ------------------------------------------------------------------- @@ -666,15 +660,38 @@ sub GetBudget { return $result; } -=head3 GetBudgets - -=over 4 +=head2 GetBudgets -&GetBudgets($filter, $order_by); + &GetBudgets($filter, $order_by); gets all budgets -=back +=cut + +# ------------------------------------------------------------------- +sub GetChildBudgetsSpent { + my ( $budget_id ) = @_; + my $dbh = C4::Context->dbh; + my $query = " + SELECT * + FROM aqbudgets + WHERE budget_parent_id=? + "; + my $sth = $dbh->prepare($query); + $sth->execute( $budget_id ); + my $result = $sth->fetchall_arrayref({}); + my $total_spent = GetBudgetSpent($budget_id); + if ($result){ + $total_spent += GetChildBudgetsSpent($_->{"budget_id"}) foreach @$result; + } + return $total_spent; +} + +=head2 GetChildBudgetsSpent + + &GetChildBudgetsSpent($budget-id); + +gets the total spent of the level and sublevels of $budget_id =cut @@ -686,9 +703,9 @@ sub GetBudgets { # ------------------------------------------------------------------- -=head3 GetCurrencies +=head2 GetCurrencies -@currencies = &GetCurrencies; + @currencies = &GetCurrencies; Returns the list of all known currencies. @@ -724,7 +741,7 @@ sub GetCurrency { return $r; } -=head3 ModCurrencies +=head2 ModCurrencies &ModCurrencies($currency, $newrate); @@ -745,15 +762,14 @@ sub ModCurrencies { # ------------------------------------------------------------------- -=head3 ConvertCurrency +=head2 ConvertCurrency -$foreignprice = &ConvertCurrency($currency, $localprice); + $foreignprice = &ConvertCurrency($currency, $localprice); Converts the price C<$localprice> to foreign currency C<$currency> by dividing by the exchange rate, and returns the result. -If no exchange rate is found,e is one -to one. +If no exchange rate is found, e is one to one. =cut @@ -774,9 +790,9 @@ sub ConvertCurrency { return ( $price / $cur ); } -=head3 _columns +=head2 _columns - returns an array containing fieldname followed by PRI as value if PRIMARY Key +returns an array containing fieldname followed by PRI as value if PRIMARY Key =cut @@ -812,6 +828,6 @@ __END__ =head1 AUTHOR -Koha Developement team +Koha Development Team =cut