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

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



Revision: 5824
          http://sourceforge.net/p/ledger-smb/code/5824
Author:   einhverfr
Date:     2013-05-18 14:16:28 +0000 (Sat, 18 May 2013)
Log Message:
-----------
Adding support for setting default formats for invoices.  Feature request 276

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/Form.pm
    trunk/LedgerSMB/Scripts/configuration.pm
    trunk/bin/aa.pl
    trunk/bin/io.pl
    trunk/bin/is.pl

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2013-05-18 12:52:50 UTC (rev 5823)
+++ trunk/Changelog	2013-05-18 14:16:28 UTC (rev 5824)
@@ -14,6 +14,7 @@
 * Session expiration now with configurable behavior (Chris T)
 * Timecard system generalized to allow labor and materials cards too (Chris T)
 * Can now print envelopes or shipping labels from many screens (Chris T)
+* Can now select default formats for printed invoices (Chris T)
 
 Enhancing data integrity
 * No longer allow NULL amounts in acc_trans (Chris T)

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2013-05-18 12:52:50 UTC (rev 5823)
+++ trunk/LedgerSMB/Form.pm	2013-05-18 14:16:28 UTC (rev 5824)
@@ -2550,6 +2550,20 @@
     $self->all_vc( $myconfig, $vc, $module, $dbh, $self->{transdate}, $job );
 }
 
+=item $form->get_setting($setting_name)
+
+Looks up the value in the defaults table and returns it.
+
+=cut
+
+sub get_setting {
+    my ($self, $setting) = @_; 
+    my $sth = $self->{dbh}->prepare('select * from setting_get(?)');
+    $sth->execute($setting);
+    my $ref = $sth->fetchrow_hashref('NAME_lc');
+    return $ref->{value};
+}
+
 =item $form->lastname_used($myconfig, $dbh2, $vc, $module);
 
 Fills the name, currency, ${vc}_id, duedate, and possibly invoice_notes

Modified: trunk/LedgerSMB/Scripts/configuration.pm
===================================================================
--- trunk/LedgerSMB/Scripts/configuration.pm	2013-05-18 12:52:50 UTC (rev 5823)
+++ trunk/LedgerSMB/Scripts/configuration.pm	2013-05-18 14:16:28 UTC (rev 5824)
@@ -47,6 +47,9 @@
        { name => 'templates',
          type => 'SELECT_ONE',
         label => $locale->text('Template Set'), },
+       { name => 'format',
+         type => 'SELECT_ONE',
+        label => $locale->text('Default Format'), },
      ] },
    { title => $locale->text('Security Settings'),
      items => [
@@ -192,11 +195,22 @@
 			     text_attr => 'description',
 			     value_attr => 'code',
 		},
-	'templates'       => {name => 'templates',
+	'templates'        => {name => 'templates',
                            options => _get_template_directories(),
                          text_attr => 'text',
                         value_attr => 'value'
                },
+        'format'           => {name => 'format',
+                           text_attr => 'text',
+                          value_attr => 'value',
+                      default_values => [$request->{'format'}],
+                             options => [{ text => 'HTML',
+                                          value => 'html'},
+                                         { text => 'PDF',
+                                          value => 'pdf'},
+                                         { text => 'Postscript',
+                                          value => 'postscript'}]
+               }
         );
     my $template = LedgerSMB::Template->new_UI(
         user => $LedgerSMB::App_State::User, 

Modified: trunk/bin/aa.pl
===================================================================
--- trunk/bin/aa.pl	2013-05-18 12:52:50 UTC (rev 5823)
+++ trunk/bin/aa.pl	2013-05-18 14:16:28 UTC (rev 5824)
@@ -157,6 +157,7 @@
 }
 
 sub display_form {
+    $form->{format} = $form->get_setting('format') unless $form->{format};
     $form->close_form;
     $form->open_form;
     $form->{dbh}->commit;
@@ -187,7 +188,6 @@
     $taxincluded = $form->{taxincluded};
 
     $form->{formname} = "transaction";
-    $form->{format}   = "postscript" if $myconfig{printer};
     $form->{media}    = $myconfig{printer};
 
     $form->{selectformname} =

Modified: trunk/bin/io.pl
===================================================================
--- trunk/bin/io.pl	2013-05-18 12:52:50 UTC (rev 5823)
+++ trunk/bin/io.pl	2013-05-18 14:16:28 UTC (rev 5824)
@@ -1320,6 +1320,7 @@
 
     my $hiddens = shift;
     my %options;
+    $form->{format} = $form->get_setting('format') unless $form->{format};
     $form->{sendmode} = "attachment";
     $form->{copies} = 1 unless $form->{copies};
 

Modified: trunk/bin/is.pl
===================================================================
--- trunk/bin/is.pl	2013-05-18 12:52:50 UTC (rev 5823)
+++ trunk/bin/is.pl	2013-05-18 14:16:28 UTC (rev 5824)
@@ -279,7 +279,6 @@
     $form->{type}     = "invoice";
     $form->{formname} = "invoice";
     $form->{sortby} ||= "runningnumber";
-    $form->{format} = "postscript" if $myconfig{printer};
     $form->{media} = $myconfig{printer};
 
     $form->{selectformname} =

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