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

SF.net SVN: ledger-smb:[3159] trunk/LedgerSMB/Initiate.pm



Revision: 3159
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3159&view=rev
Author:   einhverfr
Date:     2011-05-22 22:00:19 +0000 (Sun, 22 May 2011)

Log Message:
-----------
Ian's patch 2945460

Modified Paths:
--------------
    trunk/LedgerSMB/Initiate.pm

Modified: trunk/LedgerSMB/Initiate.pm
===================================================================
--- trunk/LedgerSMB/Initiate.pm	2011-05-22 21:58:20 UTC (rev 3158)
+++ trunk/LedgerSMB/Initiate.pm	2011-05-22 22:00:19 UTC (rev 3159)
@@ -532,40 +532,35 @@
 {
 
 	my ($self,$form)..hidden..;
-	my $coa = $form->{coa} || 'General';
-	$coa = "$coa.sql" unless $coa =~ /\.sql$/;
-        
-	$locale=$form->{locale};
 
-	my $dir=$ENV{SCRIPT_FILENAME};
+    my @files;
 
-	my $location="/sql/coa/$form->{countrycode}/";
+    my $coa = $form->{coa} || 'General';
+    $coa = "$coa.sql" unless $coa =~ /\.sql$/;
+        
+    my $dir = ($ENV{SCRIPT_FILENAME} =~ m/^(.*\/)/) ? $1 : './';
 
-	$dir =~s/\/[\w\d\.]*$/$location/;
+    $dir .= "/sql/coa/$form->{countrycode}/";
 
-	my $chartdir=$dir."chart/";
-	
-	my $gifidir=$dir."gifi/";
-	@chartdir = LedgerSMB::Initiate->read_directory($form, $chartdir);
+    if($form->{chartaccount}) {
+        my $file = $dir . 'chart/' . $coa;
+        if(-e $file) {
+            push(@files, $file);
+        } else {
+            $logger->error("$file: not found");
+        }
+    }
 
-        my @dest;	
+    if($form->{gifiaccount}) {
+        my $file = $dir . 'gifi/' . $coa;
+        if(-e $file) {
+            push(@files, $file);
+        } else {
+            $logger->error("$file: not found");
+        }
+    }
 
-        my $i;
-	for($i=0;$i<=$#chartdir;$i++)
-	{
-		$dest[$i]=$chartdir.$chartdir[$i] if $chartdir[$i] = $coa;
-	}
-	for(my $j=0;$j<=$#gifidir;$j++,$i++)
-	{
-	  
-		$dest[$i]=$chartdir.$gifidir[$i] if $gifidir[$i] = $coa;
-	
-	}
-
-	
-	return(@dest);
-
-
+    return(@files);
 }
 
 


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