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

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



Revision: 5173
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5173&view=rev
Author:   ehuelsmann
Date:     2012-11-09 12:14:39 +0000 (Fri, 09 Nov 2012)
Log Message:
-----------
Change setup.pl upgrade Default AR and AP text input boxes to drop downs.

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

Modified: branches/1.3/UI/setup/upgrade_info.html
===================================================================
--- branches/1.3/UI/setup/upgrade_info.html	2012-11-09 08:34:41 UTC (rev 5172)
+++ branches/1.3/UI/setup/upgrade_info.html	2012-11-09 12:14:39 UTC (rev 5173)
@@ -21,19 +21,23 @@
 } ?>
 </div>
 <div class="input_row">
-<?lsmb INCLUDE input element_data = {
+<?lsmb INCLUDE select element_data = {
                             name  = 'default_ar'
-                            type  = 'text'
                            label  = text('Default AR') #'
                             class = 'accno'
+                            options = ar_accounts
+                            value_attr = 'accno'
+                            text_attr = 'desc'
 } ?>
 </div>
 <div class="input_row">
-<?lsmb INCLUDE input element_data = {
+<?lsmb INCLUDE select element_data = {
                             name  = 'default_ap'
-                            type  = 'text'
                            label  = text('Default AP') #'
                             class = 'accno'
+                            options = ap_accounts
+                            value_attr = 'accno'
+                            text_attr = 'desc'
 } ?>
 </div>
 <div class="input_row">

Modified: branches/1.3/scripts/setup.pl
===================================================================
--- branches/1.3/scripts/setup.pl	2012-11-09 08:34:41 UTC (rev 5172)
+++ branches/1.3/scripts/setup.pl	2012-11-09 12:14:39 UTC (rev 5173)
@@ -346,6 +346,34 @@
 
 }
 
+=item _get_linked_accounts
+
+Returns an array of hashrefs with keys ('id', 'accno', 'desc') identifying
+the accounts.
+
+Assumes a connected database.
+
+=cut
+
+sub _get_linked_accounts {
+    my ($request, $link) = @_;
+    my @accounts;
+
+    my $sth = $request->{dbh}->prepare("select id, accno, description
+                                          from chart
+                                         where link = '$link'");
+    $sth->execute();
+    while (my $row = $sth->fetchrow_hashref('NAME_lc')) {
+        push @accounts, { accno => $row->{accno},
+                          desc => "$row->{accno} - $row->{description}",
+                          id => $row->{id}
+        };
+    }
+
+    return @accounts;
+}
+
+
 =item upgrade 
 
 Beginning of the upgrade from 1.2 logic
@@ -431,6 +459,12 @@
              _failed_check($request, $check, $sth);
         }
     }
+
+    @{$request->{ar_accounts}} = _get_linked_accounts($request, "AR");
+    @{$request->{ap_accounts}} = _get_linked_accounts($request, "AP");
+    unshift @{$request->{ar_accounts}}, {};
+    unshift @{$request->{ap_accounts}}, {};
+
     my $template = LedgerSMB::Template->new(
             path => 'UI/setup',
             template => 'upgrade_info',

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