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

SF.net SVN: ledger-smb:[4437] branches/1.3



Revision: 4437
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4437&view=rev
Author:   ehuelsmann
Date:     2012-03-10 20:53:34 +0000 (Sat, 10 Mar 2012)
Log Message:
-----------
Allow user to skip the CoA loading step when creating a new company from the webinterface.

Modified Paths:
--------------
    branches/1.3/UI/setup/select_coa.html
    branches/1.3/scripts/setup.pl

Modified: branches/1.3/UI/setup/select_coa.html
===================================================================
--- branches/1.3/UI/setup/select_coa.html	2012-03-10 12:47:01 UTC (rev 4436)
+++ branches/1.3/UI/setup/select_coa.html	2012-03-10 20:53:34 UTC (rev 4437)
@@ -47,7 +47,16 @@
     text = text('Next') 
 } ?>
 </div>
+<div class="inputrow">
+<?lsmb INCLUDE button element_data = {
+    name = 'action'
+   value = 'skip_coa'
+    type = 'submit'
+   class = 'submit'
+    text = text('Skip') 
+} ?>
 </div>
+</div>
 </form>
 </div>
 </body>

Modified: branches/1.3/scripts/setup.pl
===================================================================
--- branches/1.3/scripts/setup.pl	2012-03-10 12:47:01 UTC (rev 4436)
+++ branches/1.3/scripts/setup.pl	2012-03-10 20:53:34 UTC (rev 4437)
@@ -545,40 +545,7 @@
                 );
             }
 
-
-            # One thing to remember here is that the setup.pl does not get the
-            # benefit of the automatic db connection.  So in order to build this
-            # form, we have to manage that ourselves. 
-            #
-            # However we get the benefit of having had to set the environment
-            # variables for the Pg connection above, so don't need to pass much
-            # info. 
-            #
-            # Also I am opting to use the lower-level call_procedure interface
-            # here in order to avoid creating objects just to get argument
-            # mapping going. --CT
-
-            $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
-
-           @{$request->{salutations}} 
-            = $request->call_procedure(procname => 'person__list_salutations' ); 
-          
-           @{$request->{countries}} 
-            = $request->call_procedure(procname => 'location_list_country' ); 
-
-           my $locale = $request->{_locale};
-
-           @{$request->{perm_sets}} = (
-               {id => '0', label => $locale->text('Manage Users')},
-               {id => '1', label => $locale->text('Full Permissions')},
-           );
-
-           my $template = LedgerSMB::Template->new(
-                   path => 'UI/setup',
-                   template => 'new_user',
-	           format => 'HTML',
-           );
-           $template->render($request);
+	    _render_new_user($request);
         } else {
             opendir(COA, "sql/coa/$request->{coa_lc}/chart");
             my @coa = sort (grep !/^(\.|[Ss]ample.*)/, readdir(COA));
@@ -606,6 +573,84 @@
     $template->render($request);
 }
 
+
+=item skip_coa
+
+Entry point when on the CoA selection screen the 'Skip' button
+is being pressed.  This allows the user to load a CoA later.
+
+The CoA loaded at a later time may be a self-defined CoA, i.e. not
+one distributed with the LSMB standard distribution.  The 'Skip'
+button facilitates that scenario.
+
+=cut
+
+sub skip_coa {
+    my ($request) = @_;
+
+    _render_new_user($request);
+}
+
+
+=item _render_new_user
+
+Renders the new user screen. Common functionality to both the
+select_coa and skip_coa functions.
+
+=cut
+
+sub _render_new_user {
+    my ($request) = @_;
+
+    # One thing to remember here is that the setup.pl does not get the
+    # benefit of the automatic db connection.  So in order to build this
+    # form, we have to manage that ourselves. 
+    #
+    # However we get the benefit of having had to set the environment
+    # variables for the Pg connection above, so don't need to pass much
+    # info. 
+    #
+    # Also I am opting to use the lower-level call_procedure interface
+    # here in order to avoid creating objects just to get argument
+    # mapping going. --CT
+
+    my $creds = LedgerSMB::Auth::get_credentials();
+    
+    # ENVIRONMENT NECESSARY
+    $ENV{PGUSER} = $creds->{login};
+    $ENV{PGPASSWORD} = $creds->{password};
+    $ENV{PGDATABASE} = $request->{database};
+
+
+
+
+    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
+    $request->{dbh}->{AutoCommit} = 0;
+
+    @{$request->{salutations}} 
+    = $request->call_procedure(procname => 'person__list_salutations' ); 
+    
+    @{$request->{countries}} 
+    = $request->call_procedure(procname => 'location_list_country' ); 
+
+    my $locale = $request->{_locale};
+
+    @{$request->{perm_sets}} = (
+        {id => '0', label => $locale->text('Manage Users')},
+        {id => '1', label => $locale->text('Full Permissions')},
+        );
+
+    my $template = LedgerSMB::Template->new(
+        path => 'UI/setup',
+        template => 'new_user',
+        format => 'HTML',
+           );
+
+    $template->render($request);
+}
+
+
+
 =item save_user
 
 Saves the administrative user, and then directs to the login page.

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