$filename = qq|sql/$form->{chart}-chart.sql|;
$self->process_query($form, $dbh, $filename);
+ $query = "UPDATE defaults SET coa = " . $dbh->quote($form->{"chart"});
+ $dbh->do($query) || $form->dberror($query);
+
$dbh->disconnect;
$main::lxdebug->leave_sub();
--- /dev/null
+$self{texts} = {
+ 'Database update error:' => 'Database update error:',
+};
+
+$self{subs} = {
+ 'look_for_accno' => 'look_for_accno',
+ 'mydberror' => 'mydberror',
+ 'myshowerror' => 'myshowerror',
+ 'update_defaults_add_coa' => 'update_defaults_add_coa',
+ 'update_defaults_set_coa' => 'update_defaults_set_coa',
+ 'update_guess_chart_of_accounts' => 'update_guess_chart_of_accounts',
+ 'weiter' => 'continue',
+};
+
+1;
'Change Password' => 'Passwort ändern',
'Character Set' => 'Zeichensatz',
'Chart of Accounts' => 'Kontenübersicht',
+ 'Chart of accounts' => 'Kontenrahmen',
'Check' => 'Scheck',
'Checks' => 'Schecks',
'Choose Customer' => 'Endkunde wählen:',
'Please insert your longdescription below' => 'Bitte den Langtext eingeben',
'Please select a customer from the list below.' => 'Bitte einen Endkunden aus der Liste auswählen',
'Please select a vendor from the list below.' => 'Bitte einen Händler aus der Liste auswählen',
+ 'Please select the chart of accounts this installation is using from the list below.' => 'Bitte wählen Sie den Kontenrahmen aus, der bei dieser Installation verwendet wird.',
'Port' => 'Port',
'Port missing!' => 'Portangabe fehlt!',
'Post' => 'Buchen',
'Select from one of the names below' => 'Wählen Sie einen der untenstehenden Namen',
'Select from one of the projects below' => 'Wählen Sie eines der untenstehenden Projekte',
'Select postscript or PDF!' => 'Postscript oder PDF auswählen!',
+ 'Select the chart of accounts in use' => 'Benutzten Kontenrahmen auswählen',
'Sell Price' => 'Verkaufspreis',
'Sep' => 'Sep',
'September' => 'September',
--- /dev/null
+#!/usr/bin/perl
+
+die("This script cannot be run from the command line.") unless ($main::form);
+
+sub mydberror {
+ my ($dbup_locale, $msg) = @_;
+ die($dbup_locale->text("Database update error:") .
+ "<br>$msg<br>" . $DBI::errstr);
+}
+
+sub myshowerror {
+ my ($msg) = @_;
+
+ print($main::form->parse_html_template("dbupgrade/units_error",
+ { "message" => $msg }));
+ return 2;
+}
+
+sub update_defaults_add_coa {
+ if ($dbh->do("ALTER TABLE defaults ADD COLUMN coa text")) {
+ $dbh->commit();
+ } else {
+ $dbh->rollback();
+ }
+ $dbh->begin_work();
+}
+
+sub update_defaults_set_coa {
+ my ($coa) = @_;
+
+ $dbh->do("UPDATE defaults SET coa = " . $dbh->quote($coa));
+
+ return 1;
+}
+
+sub look_for_accno {
+ my ($accno) = @_;
+
+ my ($result) =
+ $dbh->selectrow_array("SELECT COUNT(*) FROM chart WHERE accno = " .
+ $dbh->quote($accno));
+
+ return $result;
+}
+
+sub update_guess_chart_of_accounts {
+ update_defaults_add_coa();
+
+ my $form = $main::form;
+
+ my @valid_coas = map({ s/^sql\///; s/-chart.sql//; $_; } <sql/*-chart.sql>);
+ $main::lxdebug->dump(0, "mufti", \@valid_coas);
+
+ my $query = "SELECT coa FROM defaults";
+ my ($coa) = $dbh->selectrow_array($query);
+
+ return 1 if (grep({ $coa eq $_ } @valid_coas));
+
+ return update_defaults_set_coa("Germany-DATEV-SKR04EU")
+ if (look_for_accno("0135"));
+
+ return update_defaults_set_coa("Germany-DATEV-SKR03EU")
+ if (look_for_accno("0027"));
+
+ return update_defaults_set_coa("Austria")
+ if (look_for_accno("0625"));
+
+ return update_defaults_set_coa("France")
+ if (look_for_accno("131800"));
+
+ return update_defaults_set_coa("Swiss-German")
+ if (look_for_accno("21235"));
+
+ return update_defaults_set_coa($form->{"coa"})
+ if (($form->{"action2"} eq "set_coa") &&
+ grep({ $form->{"coa"} eq $_ } @valid_coas));
+
+ my @coas = map(+{ "name" => $_ }, @valid_coas);
+
+ print($form->parse_html_template("dbupgrade/coa_guess",
+ { "COAS" => \@coas }));
+
+ return 2;
+}
+
+return update_guess_chart_of_accounts();
"audittrail" bool default 'f',
"articlenumber" text,
"servicenumber" text,
+ "coa" text,
"itime" timestamp DEFAULT now(),
"mtime" timestamp
);
--- /dev/null
+<div class="listtop">Benutzten Kontenrahmen auswählen</div>
+
+<form name="Form" method="post" action="login.pl">
+
+ <input type="hidden" name="path" value="<TMPL_VAR path ESCAPE=HTML>">
+ <input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
+ <input type="hidden" name="hashed_password" value="<TMPL_VAR password ESCAPE=HTML>">
+ <input type="hidden" name="action" value="login">
+ <input type="hidden" name="action2" value="">
+
+ <TMPL_IF saved_message>
+ <p><TMPL_VAR saved_message></p>
+ </TMPL_IF>
+
+ <p>
+ Bitte wählen Sie den Kontenrahmen aus, der bei dieser Installation verwendet wird.
+ </p>
+
+ <p>
+ Kontenrahmen:
+ <select name="coa"><TMPL_LOOP COAS><option><TMPL_VAR name></option></TMPL_LOOP></select>
+ </p>
+
+ <input type="submit" onclick="document.Form.action2.value = 'set_coa'; document.Form.submit();" name="dummy" value="Weiter">
+
+</form>
+
--- /dev/null
+<div class="listtop"><translate>Select the chart of accounts in use</translate></div>
+
+<form name="Form" method="post" action="login.pl">
+
+ <input type="hidden" name="path" value="<TMPL_VAR path ESCAPE=HTML>">
+ <input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
+ <input type="hidden" name="hashed_password" value="<TMPL_VAR password ESCAPE=HTML>">
+ <input type="hidden" name="action" value="login">
+ <input type="hidden" name="action2" value="">
+
+ <TMPL_IF saved_message>
+ <p><TMPL_VAR saved_message></p>
+ </TMPL_IF>
+
+ <p>
+ <translate>Please select the chart of accounts this installation
+ is using from the list below.</translate>
+ </p>
+
+ <p>
+ <translate>Chart of accounts</translate>:
+ <select name="coa"><TMPL_LOOP COAS><option><TMPL_VAR name></option></TMPL_LOOP></select>
+ </p>
+
+ <input type="submit" onclick="document.Form.action2.value = 'set_coa'; document.Form.submit();" name="dummy" value="<translate>Continue</translate>">
+
+</form>
+