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

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



Revision: 6390
          http://sourceforge.net/p/ledger-smb/code/6390
Author:   einhverfr
Date:     2014-01-05 13:55:27 +0000 (Sun, 05 Jan 2014)
Log Message:
-----------
File uploads working

Modified Paths:
--------------
    trunk/LedgerSMB/Scripts/template.pm
    trunk/LedgerSMB.pm
    trunk/UI/templates/preview.html

Modified: trunk/LedgerSMB/Scripts/template.pm
===================================================================
--- trunk/LedgerSMB/Scripts/template.pm	2014-01-05 13:35:19 UTC (rev 6389)
+++ trunk/LedgerSMB/Scripts/template.pm	2014-01-05 13:55:27 UTC (rev 6390)
@@ -8,6 +8,7 @@
 use LedgerSMB::Template::DB;
 use LedgerSMB::Report::Listings::Templates;
 use LedgerSMB::Template;
+use LedgerSMB::App_State;
 
 =head1 SYNPOSIS
 
@@ -85,6 +86,29 @@
     display($request);
 }
 
+=head2 upload($request)
+
+Sends the file as an upload.  The template_name and format must match before it 
+will be accepted.
+
+=cut
+
+sub upload {
+    my ($request) = @_;
+    my @fnames =  $request->{_request}->upload_info;
+    $name = $fnames[0];
+    my $fh = $request->{_request}->upload($name);
+    my $fdata = join ("", <$fh>);
+    die "No content" unless $fdata;
+    my $testname = $request->{template_name} . "." . $request->{format};
+    die 'Unexpected file name'
+          unless $name eq $testname;
+    $request->{template} = $fdata;
+    my $dbtemp = LedgerSMB::Template::DB->new(%$request);
+    $dbtemp->save();
+    display($request);
+}
+
 =head1 COPYRIGHT
 
 Copyright (C) 2014 The LedgerSMB Core Team.

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2014-01-05 13:35:19 UTC (rev 6389)
+++ trunk/LedgerSMB.pm	2014-01-05 13:55:27 UTC (rev 6390)
@@ -392,8 +392,7 @@
 
 sub unescape {
     my ($self, $var) = @_;
-    my $q = CGI::Simple->new();
-    return $q->unescapeHTML($var);
+    return $self->{_request}->unescapeHTML($var);
 }
 
 sub open_form {

Modified: trunk/UI/templates/preview.html
===================================================================
--- trunk/UI/templates/preview.html	2014-01-05 13:35:19 UTC (rev 6389)
+++ trunk/UI/templates/preview.html	2014-01-05 13:55:27 UTC (rev 6390)
@@ -30,8 +30,9 @@
 PROCESS button element_data = {
    type = "submit"
    name = "action"
-   text = "upload"
+   text = text("Upload")
   class = "submit"
+  value = "upload"
 };
 ?>
 </form>

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


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits