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

SF.net SVN: ledger-smb: [2204] trunk



Revision: 2204
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2204&view=rev
Author:   einhverfr
Date:     2008-07-09 22:37:44 -0700 (Wed, 09 Jul 2008)

Log Message:
-----------
Fine-tuning changes to draft approval workflow

Modified Paths:
--------------
    trunk/bin/aa.pl
    trunk/scripts/drafts.pl

Modified: trunk/bin/aa.pl
===================================================================
--- trunk/bin/aa.pl	2008-07-10 00:56:58 UTC (rev 2203)
+++ trunk/bin/aa.pl	2008-07-10 05:37:44 UTC (rev 2204)
@@ -958,7 +958,17 @@
     my $draft = LedgerSMB::DBObject::Draft->new({base => $lsmb});
 
     $draft->approve();
-    $form->info($locale->text('Draft Posted'));
+    if ($form->{callback}){
+        print "Location: $form->{callback}\n";
+        print "Status: 302 Found\n\n";
+        print "<html><body>";
+        my $url = $form->{callback};
+        print qq|If you are not redirected automatically, click <a href="$url">|
+                . qq|here</a>.</body></html>|;
+
+    } else {
+        $form->info($locale->text('Draft Posted'));
+    }
 }
 
 sub update {

Modified: trunk/scripts/drafts.pl
===================================================================
--- trunk/scripts/drafts.pl	2008-07-10 00:56:58 UTC (rev 2203)
+++ trunk/scripts/drafts.pl	2008-07-10 05:37:44 UTC (rev 2204)
@@ -23,12 +23,42 @@
     $template->render($request);
 }
 
+sub list_drafts_draft_approve {
+    my ($request) = @_;
+    my $draft= LedgerSMB::DBObject::Draft->new(base => $request);
+    for my $row (1 .. $draft->{rowcount}){
+        if ($draft->{"draft_" .$draft->{"row_$row"}}){
+             $draft->{id} = $draft->{"row_$row"};
+             $draft->approve;
+        }
+    }
+    search($request);
+}
+
+sub list_drafts_draft_delete {
+    my ($request) = @_;
+    my $draft= LedgerSMB::DBObject::Draft->new(base => $request);
+    for my $row (1 .. $draft->{rowcount}){
+        if ($draft->{"draft_" .$draft->{"row_$row"}}){
+             $draft->{id} = $draft->{"row_$row"};
+             $draft->delete;
+        }
+    }
+    search($request);
+}
+
 sub list_drafts {
     my ($request) = @_;
     my $draft= LedgerSMB::DBObject::Draft->new(base => $request);
+    my $callback = 'drafts.pl?action=list_drafts';
+    for (qw(type reference amount_gy amount_lt)){
+        if (defined $draft->{$_}){
+            $callback .= "&$_=$draft->{$_}";
+        }
+    }
     my @search_results = $draft->search;
     $draft->{script} = "drafts.pl";
-
+    $draft->{callback} = $draft->escape(string => $callback);
     my @columns = 
         qw(select id transdate reference description amount);
 
@@ -83,7 +113,8 @@
 				),
             reference => { 
                   text => $result->{reference},
-                  href => "$request->{type}.pl?action=edit&id=$result->{id}",
+                  href => "$request->{type}.pl?action=edit&id=$result->{id}" .
+				"&callback=$draft->{callback}",
             },
             description => $result->{description},
             transdate => $result->{transdate},


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