[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3832] addons/1.3/budgetting/trunk/scripts/budgets. pl



Revision: 3832
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3832&view=rev
Author:   einhverfr
Date:     2011-10-10 20:52:54 +0000 (Mon, 10 Oct 2011)
Log Message:
-----------
More budget workflow stuff

Modified Paths:
--------------
    addons/1.3/budgetting/trunk/scripts/budgets.pl

Modified: addons/1.3/budgetting/trunk/scripts/budgets.pl
===================================================================
--- addons/1.3/budgetting/trunk/scripts/budgets.pl	2011-10-09 23:43:46 UTC (rev 3831)
+++ addons/1.3/budgetting/trunk/scripts/budgets.pl	2011-10-10 20:52:54 UTC (rev 3832)
@@ -41,8 +41,45 @@
 
 sub new_budget {
     my ($request) = @_;
+    my $budget = LedgerSMB::DBObject::Budget->new({base => $request});
+    @{$budget->{projects}} = $budget->list_projects;
+    @{$budget->{departments}} = $budget->list_departments;
+    # TODO:  Add buttons
+    my $template = LedgerSMB::Template->new(
+        user     => $request->{_user},
+        locale   => $request->{_locale},
+        path     => 'UI/budgetting',
+        template => 'budget_entry',
+        format   => 'HTML'
+    );
+
+    $template->render($budget);
 }
 
+=item view_budget
+Reuuires id to be set.  Displays a budget for review.
+
+=cut
+
+sub view_budget {
+    my ($request) = @_;
+    my $budget = LedgerSMB::DBObject::Budget->new(
+           {base => $request, copy => 'base'}
+    );
+    $budget->get($request->{id});
+    @{$budget->{projects}} = $budget->list_projects;
+    @{$budget->{departments}} = $budget->list_departments;
+    # TODO:  Add buttons
+    my $template = LedgerSMB::Template->new(
+        user     => $request->{_user},
+        locale   => $request->{_locale},
+        path     => 'UI/budgetting',
+        template => 'budget_entry',
+        format   => 'HTML'
+    );
+    $template->render($budget);
+}
+
 =item save_budget
 LedgerSMB::DBObject::Budget properties required.  Lines represented by
 [property]_[line number] notation.
@@ -51,6 +88,16 @@
 
 sub save_budget {
     my ($request) = @_;
+    my $budget = LedgerSMB::DBObject::Budget->new({base => $request});
+    for my $rownum (1 .. $request->{rowcount}){
+         my $line = {};
+         for (qw(debits credits account_id description)){
+             $line->{$_} = $request->{"${_}_$rownum"};
+         }
+         push @{$budget->{lines}}, $line;
+    }
+    $budget->save();
+    view_budget($budget); 
 } 
 
 =item approve
@@ -89,6 +136,33 @@
     my ($request) = @_;
 } 
 
+=item begin_search
+No inputs expected or used
+
+=cut
+
+sub begin_search{
+    my ($request) = @_;
+    my $budget = LedgerSMB::DBObject::Budget->new({base => $request});
+    @{$budget->{projects}} = $budget->list_projects;
+    @{$budget->{departments}} = $budget->list_departments;
+    # TODO:  Add buttons
+    my $template = LedgerSMB::Template->new(
+        user     => $request->{_user},
+        locale   => $request->{_locale},
+        path     => 'UI/budgetting',
+        template => 'begin_search',
+        format   => 'HTML'
+    );
+
+    $template->render($budget);
+}
+
+=item search
+See LedgerSMB::Budget's search routine for expected inputs.
+
+=cut
+
 =back
 
 =head1 SEE ALSO

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.