Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 89c9d0aa

Von Moritz Bunkus vor etwa 18 Jahren hinzugefügt

  • ID 89c9d0aafa8b2a1ae33bc590c8dafb0edc9a428c
  • Vorgänger ae1b5cba
  • Nachfolger 377efe44

Datenbankupgrade: In der Tabelle defaults wird jetzt auch der verwendete Kontenrahmen gespeichert. Dieser wird beim Anlegen der Datenbank eingetragen. Das Datenbankupgrade versucht, den Kontenrahmen zu erraten und fragt im Zweifelsfall beim Benutzer nach.

Unterschiede anzeigen:

SL/User.pm
388 388
  $filename = qq|sql/$form->{chart}-chart.sql|;
389 389
  $self->process_query($form, $dbh, $filename);
390 390

  
391
  $query = "UPDATE defaults SET coa = " . $dbh->quote($form->{"chart"});
392
  $dbh->do($query) || $form->dberror($query);
393

  
391 394
  $dbh->disconnect;
392 395

  
393 396
  $main::lxdebug->leave_sub();
locale/de/Pg-upgrade-2.2.0.27-2.2.0.28
1
$self{texts} = {
2
  'Database update error:'      => 'Database update error:',
3
};
4

  
5
$self{subs} = {
6
  'look_for_accno'              => 'look_for_accno',
7
  'mydberror'                   => 'mydberror',
8
  'myshowerror'                 => 'myshowerror',
9
  'update_defaults_add_coa'     => 'update_defaults_add_coa',
10
  'update_defaults_set_coa'     => 'update_defaults_set_coa',
11
  'update_guess_chart_of_accounts' => 'update_guess_chart_of_accounts',
12
  'weiter'                      => 'continue',
13
};
14

  
15
1;
locale/de/all
212 212
  'Change Password'             => 'Passwort ?ndern',
213 213
  'Character Set'               => 'Zeichensatz',
214 214
  'Chart of Accounts'           => 'Konten?bersicht',
215
  'Chart of accounts'           => 'Kontenrahmen',
215 216
  'Check'                       => 'Scheck',
216 217
  'Checks'                      => 'Schecks',
217 218
  'Choose Customer'             => 'Endkunde w?hlen:',
......
711 712
  'Please insert your longdescription below' => 'Bitte den Langtext eingeben',
712 713
  'Please select a customer from the list below.' => 'Bitte einen Endkunden aus der Liste ausw?hlen',
713 714
  'Please select a vendor from the list below.' => 'Bitte einen H?ndler aus der Liste ausw?hlen',
715
  '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.',
714 716
  'Port'                        => 'Port',
715 717
  'Port missing!'               => 'Portangabe fehlt!',
716 718
  'Post'                        => 'Buchen',
......
836 838
  'Select from one of the names below' => 'W?hlen Sie einen der untenstehenden Namen',
837 839
  'Select from one of the projects below' => 'W?hlen Sie eines der untenstehenden Projekte',
838 840
  'Select postscript or PDF!'   => 'Postscript oder PDF ausw?hlen!',
841
  'Select the chart of accounts in use' => 'Benutzten Kontenrahmen auswählen',
839 842
  'Sell Price'                  => 'Verkaufspreis',
840 843
  'Sep'                         => 'Sep',
841 844
  'September'                   => 'September',
sql/Pg-upgrade/Pg-upgrade-2.2.0.27-2.2.0.28.pl
1
#!/usr/bin/perl
2

  
3
die("This script cannot be run from the command line.") unless ($main::form);
4

  
5
sub mydberror {
6
  my ($dbup_locale, $msg) = @_;
7
  die($dbup_locale->text("Database update error:") .
8
      "<br>$msg<br>" . $DBI::errstr);
9
}
10

  
11
sub myshowerror {
12
  my ($msg) = @_;
13

  
14
  print($main::form->parse_html_template("dbupgrade/units_error",
15
                                         { "message" => $msg }));
16
  return 2;
17
}
18

  
19
sub update_defaults_add_coa {
20
  if ($dbh->do("ALTER TABLE defaults ADD COLUMN coa text")) {
21
    $dbh->commit();
22
  } else {
23
    $dbh->rollback();
24
  }
25
  $dbh->begin_work();
26
}
27

  
28
sub update_defaults_set_coa {
29
  my ($coa) = @_;
30

  
31
  $dbh->do("UPDATE defaults SET coa = " . $dbh->quote($coa));
32

  
33
  return 1;
34
}
35

  
36
sub look_for_accno {
37
  my ($accno) = @_;
38

  
39
  my ($result) =
40
    $dbh->selectrow_array("SELECT COUNT(*) FROM chart WHERE accno = " .
41
                          $dbh->quote($accno));
42

  
43
  return $result;
44
}
45

  
46
sub update_guess_chart_of_accounts {
47
  update_defaults_add_coa();
48

  
49
  my $form = $main::form;
50

  
51
  my @valid_coas = map({ s/^sql\///; s/-chart.sql//; $_; } <sql/*-chart.sql>);
52
  $main::lxdebug->dump(0, "mufti", \@valid_coas);
53

  
54
  my $query = "SELECT coa FROM defaults";
55
  my ($coa) = $dbh->selectrow_array($query);
56

  
57
  return 1 if (grep({ $coa eq $_ } @valid_coas));
58

  
59
  return update_defaults_set_coa("Germany-DATEV-SKR04EU")
60
    if (look_for_accno("0135"));
61

  
62
  return update_defaults_set_coa("Germany-DATEV-SKR03EU")
63
    if (look_for_accno("0027"));
64

  
65
  return update_defaults_set_coa("Austria")
66
    if (look_for_accno("0625"));
67

  
68
  return update_defaults_set_coa("France")
69
    if (look_for_accno("131800"));
70

  
71
  return update_defaults_set_coa("Swiss-German")
72
    if (look_for_accno("21235"));
73

  
74
  return update_defaults_set_coa($form->{"coa"})
75
    if (($form->{"action2"} eq "set_coa") &&
76
        grep({ $form->{"coa"} eq $_ } @valid_coas));
77

  
78
  my @coas = map(+{ "name" => $_ }, @valid_coas);
79

  
80
  print($form->parse_html_template("dbupgrade/coa_guess",
81
                                   { "COAS" => \@coas }));
82

  
83
  return 2;
84
}
85

  
86
return update_guess_chart_of_accounts();
sql/lx-office.sql
112 112
        "audittrail" bool default 'f',
113 113
        "articlenumber" text,
114 114
        "servicenumber" text,
115
        "coa" text,
115 116
        "itime" timestamp DEFAULT now(),
116 117
        "mtime" timestamp
117 118
);
templates/webpages/dbupgrade/coa_guess_de.html
1
<div class="listtop">Benutzten Kontenrahmen ausw&auml;hlen</div>
2

  
3
<form name="Form" method="post" action="login.pl">
4

  
5
 <input type="hidden" name="path" value="<TMPL_VAR path ESCAPE=HTML>">
6
 <input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
7
 <input type="hidden" name="hashed_password" value="<TMPL_VAR password ESCAPE=HTML>">
8
 <input type="hidden" name="action" value="login">
9
 <input type="hidden" name="action2" value="">
10

  
11
 <TMPL_IF saved_message>
12
  <p><TMPL_VAR saved_message></p>
13
 </TMPL_IF>
14

  
15
 <p>
16
  Bitte w&auml;hlen Sie den Kontenrahmen aus, der bei dieser Installation verwendet wird.
17
 </p>
18

  
19
 <p>
20
  Kontenrahmen:
21
  <select name="coa"><TMPL_LOOP COAS><option><TMPL_VAR name></option></TMPL_LOOP></select>
22
 </p>
23

  
24
 <input type="submit" onclick="document.Form.action2.value = 'set_coa'; document.Form.submit();" name="dummy" value="Weiter">
25

  
26
</form>
27

  
templates/webpages/dbupgrade/coa_guess_master.html
1
<div class="listtop"><translate>Select the chart of accounts in use</translate></div>
2

  
3
<form name="Form" method="post" action="login.pl">
4

  
5
 <input type="hidden" name="path" value="<TMPL_VAR path ESCAPE=HTML>">
6
 <input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
7
 <input type="hidden" name="hashed_password" value="<TMPL_VAR password ESCAPE=HTML>">
8
 <input type="hidden" name="action" value="login">
9
 <input type="hidden" name="action2" value="">
10

  
11
 <TMPL_IF saved_message>
12
  <p><TMPL_VAR saved_message></p>
13
 </TMPL_IF>
14

  
15
 <p>
16
  <translate>Please select the chart of accounts this installation
17
   is using from the list below.</translate>
18
 </p>
19

  
20
 <p>
21
  <translate>Chart of accounts</translate>:
22
  <select name="coa"><TMPL_LOOP COAS><option><TMPL_VAR name></option></TMPL_LOOP></select>
23
 </p>
24

  
25
 <input type="submit" onclick="document.Form.action2.value = 'set_coa'; document.Form.submit();" name="dummy" value="<translate>Continue</translate>">
26

  
27
</form>
28

  

Auch abrufbar als: Unified diff