Bugzilla – Attachment 5649 Details for
Bug 6943
Create new budget from a copy of a previous budget
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to add feature
0001-port-to-3.6-copy-budgets.patch (text/plain), 5.91 KB, created by
Maxime Pelletier
on 2011-09-29 17:41:44 UTC
(
hide
)
Description:
Patch to add feature
Filename:
MIME Type:
Creator:
Maxime Pelletier
Created:
2011-09-29 17:41:44 UTC
Size:
5.91 KB
patch
obsolete
>From bce6f5d9a1fbb551cb5514868b00bbeff0540b18 Mon Sep 17 00:00:00 2001 >From: Maxime Pelletier <maxime.pelletier@libeo.com> >Date: Thu, 29 Sep 2011 11:35:16 -0400 >Subject: [PATCH] port to 3.6 copy budgets > >--- > C4/Budgets.pm | 46 ++++++++++++++++++++ > admin/aqbudgetperiods.pl | 37 +++++++++------- > .../prog/en/modules/admin/aqbudgetperiods.tt | 38 +++++++++++----- > 3 files changed, 94 insertions(+), 27 deletions(-) > >diff --git a/C4/Budgets.pm b/C4/Budgets.pm >index 7c867e0..3ad433b 100644 >--- a/C4/Budgets.pm >+++ b/C4/Budgets.pm >@@ -588,6 +588,52 @@ sub DelBudget { > } > > >+sub CopyBudget { >+ my ($budgetperiod, $budget_period_id) = @_; >+ my $prev_budget_period_id = $budgetperiod->{'copy_previous_budget'}; >+ my $copy_data_budget = $budgetperiod->{'copy_data_budget'}; >+ #Creates a copy of a selected budget >+ if ($prev_budget_period_id != 0) { >+ #Get all the funds of that budget >+ my $dbh = C4::Context->dbh; >+ my $query = " >+ SELECT * >+ FROM aqbudgets >+ WHERE budget_period_id=?"; >+ my $sth = $dbh->prepare($query); >+ $sth->execute( $prev_budget_period_id ); >+ my $result = $sth->fetchall_arrayref({}); >+ my @budget_is_copy_of; >+ #Copy all the funds to the new budget >+ foreach my $budget (@$result){ >+ $budget->{'budget_period_id'} = $budget_period_id; >+ #Update the parent_id to be the id of the copy of that parent >+ $budget->{'budget_parent_id'} = $budget_is_copy_of[$budget->{'budget_parent_id'}]; >+ my $new_budget_id = C4::Budgets::AddBudget($budget); >+ >+ #Remember this budget is a copy of which >+ $budget_is_copy_of[$budget->{'budget_id'}] = $new_budget_id; >+ >+ if ($copy_data_budget) { >+ #Transfers the orders from the previous fund to the new >+ my $query = " >+ UPDATE aqorders SET budget_id = ? >+ WHERE budget_id=? AND >+ quantityreceived = 0 AND >+ datecancellationprinted IS NULL"; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($new_budget_id, $budget->{'budget_id'} ); >+ } >+ } >+ #Disable the previous budget >+ my $query = " >+ UPDATE aqbudgetperiods SET budget_period_active = 0 >+ WHERE budget_period_id=?"; >+ my $sth = $dbh->prepare($query); >+ $sth->execute( $prev_budget_period_id ); >+ } >+} >+ > =head2 GetBudget > > &GetBudget($budget_id); >diff --git a/admin/aqbudgetperiods.pl b/admin/aqbudgetperiods.pl >index e74935e..4fe172d 100755 >--- a/admin/aqbudgetperiods.pl >+++ b/admin/aqbudgetperiods.pl >@@ -128,7 +128,11 @@ if ( $op eq 'add_form' ) { > $template->param( > %$budgetperiod_hash > ); >- } # IF-MOD >+ } # IF-MOD >+ else{ >+ my $budgets = C4::Budgets::GetBudgetPeriods(); >+ $template->param( budgets => $budgets ); >+ } > $template->param( DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),); > } > >@@ -142,6 +146,7 @@ elsif ( $op eq 'add_validate' ) { > } > else { # ELSE ITS AN ADD > my $budget_period_id=AddBudgetPeriod($budget_period_hashref); >+ C4::Budgets::CopyBudget($budget_period_hashref, $budget_period_id); > } > $op='else'; > } >@@ -154,10 +159,10 @@ elsif ( $op eq 'delete_confirm' ) { > my $total = 0; > my $data = GetBudgetPeriod( $budget_period_id); > >- FormatData($data); >- $$data{'budget_period_total'}=$num->format_price( $data->{'budget_period_total'}); >+ FormatData($data); >+ $$data{'budget_period_total'}=$num->format_price( $data->{'budget_period_total'}); > $template->param( >- %$data >+ %$data > ); > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >index dbbcdd5..de09440 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >@@ -34,8 +34,8 @@ > } > > /* >- checkBudgetTotal(f) { >- } >+ checkBudgetTotal(f) { >+ } > */ > > if (_alertString.length==0) { >@@ -47,13 +47,13 @@ > alert(alertString2); > } > } >- $(document).ready(function() { >- $("#periodsh").tablesorter({ >- widgets : ['zebra'], >- sortList: [[0,0]], >- headers: {6:{sorter:false}} >- }); >- }); >+ $(document).ready(function() { >+ $("#periodsh").tablesorter({ >+ widgets : ['zebra'], >+ sortList: [[0,0]], >+ headers: {6:{sorter:false}} >+ }); >+ }); > </script> > > <title> >@@ -144,6 +144,22 @@ > <input type="hidden" name="op" value="add_validate" /> > <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" /> > <ol> >+ <!-- st_copier_budget_dans_creation - SYS-TECH --> >+ [% UNLESS ( budget_period_id ) %] >+ <li> >+ <label>Copy from a previous budget</label> >+ <select name="copy_previous_budget"> >+ <option value="0"></option> >+ [% FOREACH budget IN budgets %] >+ <option value="[% budget.budget_period_id %]" onclick="$('#budget_period_total').val('[% budget.budget_period_total %]')">[% budget.budget_period_description %]</option> >+ [% END %] >+ </select> >+ <p> >+ <input type="checkbox" name="copy_data_budget" /> Transfer the ordered acquisitions >+ </p> >+ </li> >+ [% END %] >+ <!-- /st_copier_budget_dans_creation - SYS-TECH --> > <li> > <label class="required" for="budget_period_startdate">Start date</label> > <input type="text" size="10" id="budget_period_startdate" name="budget_period_startdate" value="[% budget_period_startdate %]" /> >@@ -157,7 +173,7 @@ > singleClick : false > }); > </script> >- <div class="hint">[% INCLUDE 'date-format.inc' %]</div> >+ <div class="hint">[% INCLUDE 'date-format.inc' %]</div> > </li> > <li> > >-- >1.5.6.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6943
:
5648
|
5649
|
7043
|
7168
|
7309
|
7330