--- /dev/null
+$self{texts} = {
+ 'A unit with this name does already exist.' => 'Eine Einheit mit diesem Namen existiert bereits.',
+ 'Database update error:' => 'Database update error:',
+ 'The base unit does not exist.' => 'Die Basiseinheit existiert nicht.',
+ 'The factor is missing.' => 'Der Faktor fehlt.',
+ 'The name is missing.' => 'Der Name fehlt.',
+ 'The unit has been saved.' => 'Die Einheit wurde gespeichert.',
+};
+
+$self{subs} = {
+ 'mydberror' => 'mydberror',
+ 'myshowerror' => 'myshowerror',
+ 'update_units' => 'update_units',
+ 'update_units_add_unit' => 'update_units_add_unit',
+ 'update_units_assign_known' => 'update_units_assign_known',
+ 'update_units_assign_units' => 'update_units_assign_units',
+ 'update_units_set_default' => 'update_units_set_default',
+ 'update_units_step_3' => 'update_units_step_3',
+ 'update_units_steps_1_2' => 'update_units_steps_1_2',
+ 'einheit_hinzufügen' => 'add_unit',
+ 'einheiten_zuweisen' => 'assign_units',
+};
+
+1;
+++ /dev/null
-$self{texts} = {
- 'A unit with this name does already exist.' => 'Eine Einheit mit diesem Namen existiert bereits.',
- 'Database update error:' => 'Database update error:',
- 'The base unit does not exist.' => 'Die Basiseinheit existiert nicht.',
- 'The factor is missing.' => 'Der Faktor fehlt.',
- 'The name is missing.' => 'Der Name fehlt.',
- 'The unit has been saved.' => 'Die Einheit wurde gespeichert.',
-};
-
-$self{subs} = {
- 'mydberror' => 'mydberror',
- 'myshowerror' => 'myshowerror',
- 'update_units' => 'update_units',
- 'update_units_add_unit' => 'update_units_add_unit',
- 'update_units_assign_known' => 'update_units_assign_known',
- 'update_units_assign_units' => 'update_units_assign_units',
- 'update_units_set_default' => 'update_units_set_default',
- 'update_units_step_3' => 'update_units_step_3',
- 'update_units_steps_1_2' => 'update_units_steps_1_2',
- 'einheit_hinzufügen' => 'add_unit',
- 'einheiten_zuweisen' => 'assign_units',
-};
-
-1;
use SL::AM;
-%dbup_myconfig = ();
-map({ $dbup_myconfig{$_} = $main::form->{$_}; }
- qw(dbname dbuser dbpasswd dbhost dbport dbconnect));
-
sub mydberror {
- my ($dbup_locale, $msg) = @_;
+ my ($msg) = @_;
die($dbup_locale->text("Database update error:") .
"<br>$msg<br>" . $DBI::errstr);
}
}
sub update_units_add_unit {
- my ($dbup_locale, $dbh) = @_;
-
my $form = $main::form;
return 0 unless ($form->{"new_name"});
"VALUES (?, ?, ?, ?)";
$dbh->do($query, undef, $form->{"new_name"}, $base_unit, $factor,
$form->{"unit_type"}) ||
- mydberror($dbup_locale, $query .
+ mydberror($query .
" ($form->{new_name}, $base_unit, $factor, $form->{unit_type})");
$dbh->commit();
$dbh->begin_work();
}
sub update_units_assign_units {
- my ($dbup_locale, $dbh) = @_;
-
my ($query, $sth, @values);
my $form = $main::form;
next unless ($form->{"new_unit_$i"} && $form->{"old_unit_$i"});
@values = ($form->{"new_unit_$i"}, lc($form->{"old_unit_$i"}));
$sth->execute(@values) ||
- mydberror($dbup_locale, $query . " (" . join(", ", @values) . ")");
+ mydberror($query . " (" . join(", ", @values) . ")");
}
}
}
sub update_units_assign_known {
- my ($dbup_locale, $dbh) = @_;
-
my $form = $main::form;
my %unit_name_mapping = (
}
$form->{"rowcount"} = scalar(keys(%unit_name_mapping));
- update_units_assign_units($dbup_locale, $dbh);
+ update_units_assign_units();
}
sub update_units_steps_1_2 {
- my ($dbup_locale, $dbh) = @_;
-
my (%unknown_dimension_units, %unknown_service_units);
my $form = $main::form;
" t.unit IN (SELECT name FROM units))";
}
$sth = $dbh->prepare($query);
- $sth->execute() || mydberror($dbup_locale, $query);
+ $sth->execute() || mydberror($query);
while ($ref = $sth->fetchrow_hashref()) {
if ($ref->{"inventory_accno_id"}) {
}
sub update_units_step_3 {
- my ($dbup_locale, $dbh) = @_;
-
my $form = $main::form;
my $query = "SELECT ";
}
sub update_units_set_default {
- my ($dbup_locale, $dbh) = @_;
-
my $form = $main::form;
foreach my $table (qw(parts invoice orderitems rmaitems)) {
"parts_id IN (SELECT id FROM parts WHERE (inventory_accno_id > 0))";
}
- $dbh->do($query) || mydberror($dbup_locale, $query);
+ $dbh->do($query) || mydberror($query);
if ($table eq "parts") {
$query = "UPDATE $table SET unit = " .
"WHERE (inventory_accno_id ISNULL) OR (inventory_accno_id = 0))";
}
- $dbh->do($query) || mydberror($dbup_locale, $query);
+ $dbh->do($query) || mydberror($query);
}
}
sub update_units {
- my (@dbh) = @_;
-
my $form = $main::form;
my $res;
- my $dbup_locale = Locale->new($main::language, "dbupgrade");
-
print($form->parse_html_template("dbupgrade/units_header"));
if ($form->{"action2"} eq "add_unit") {
- $res = update_units_add_unit($dbup_locale, $dbh);
+ $res = update_units_add_unit();
return $res if ($res);
} elsif ($form->{"action2"} eq "assign_units") {
- update_units_assign_units($dbup_locale, $dbh);
+ update_units_assign_units();
} elsif ($form->{"action2"} eq "set_default") {
- update_units_set_default($dbup_locale, $dbh);
+ update_units_set_default();
}
- update_units_assign_known($dbup_locale, $dbh);
+ update_units_assign_known();
- $res = update_units_steps_1_2($dbup_locale, $dbh);
+ $res = update_units_steps_1_2();
return $res if ($res);
- return update_units_step_3($dbup_locale, $dbh);
+ return update_units_step_3();
}
-update_units($dbh);
+update_units();