Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 60d0f05f

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID 60d0f05f9fe667d2c309175d8849428393c6739f
  • Vorgänger 459574b9
  • Nachfolger 464bf573

SimpleSystemSetting: Umstellung von »Sprachen«

Unterschiede anzeigen:

SL/AM.pm
410 410
  return 1;
411 411
}
412 412

  
413
sub language {
414
  $main::lxdebug->enter_sub();
415

  
416
  my ($self, $myconfig, $form, $return_list) = @_;
417

  
418
  my $dbh = SL::DB->client->dbh;
419

  
420
  my $query =
421
    "SELECT id, description, template_code, article_code, " .
422
    "  output_numberformat, output_dateformat, output_longdates " .
423
    "FROM language ORDER BY description";
424

  
425
  my $sth = $dbh->prepare($query);
426
  $sth->execute || $form->dberror($query);
427

  
428
  my $ary = [];
429

  
430
  while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
431
    push(@{ $ary }, $ref);
432
  }
433

  
434
  $sth->finish;
435

  
436
  $main::lxdebug->leave_sub();
437

  
438
  if ($return_list) {
439
    return @{$ary};
440
  } else {
441
    $form->{ALL} = $ary;
442
  }
443
}
444

  
445
sub get_language {
446
  $main::lxdebug->enter_sub();
447

  
448
  my ($self, $myconfig, $form) = @_;
449

  
450
  my $dbh = SL::DB->client->dbh;
451

  
452
  my $query =
453
    "SELECT description, template_code, article_code, " .
454
    "  output_numberformat, output_dateformat, output_longdates " .
455
    "FROM language WHERE id = ?";
456
  my $sth = $dbh->prepare($query);
457
  $sth->execute($form->{"id"}) || $form->dberror($query . " ($form->{id})");
458

  
459
  my $ref = $sth->fetchrow_hashref("NAME_lc");
460

  
461
  map { $form->{$_} = $ref->{$_} } keys %$ref;
462

  
463
  $sth->finish;
464

  
465
  $main::lxdebug->leave_sub();
466
}
467

  
468 413
sub get_language_details {
469 414
  $main::lxdebug->enter_sub();
470 415

  
......
483 428
  return @res;
484 429
}
485 430

  
486
sub save_language {
487
  $main::lxdebug->enter_sub();
488

  
489
  my ($self, $myconfig, $form) = @_;
490

  
491
  SL::DB->client->with_transaction(sub {
492
    my $dbh = SL::DB->client->dbh;
493
    my (@values, $query);
494

  
495
    map({ push(@values, $form->{$_}); }
496
        qw(description template_code article_code
497
           output_numberformat output_dateformat output_longdates));
498

  
499
    # id is the old record
500
    if ($form->{id}) {
501
      $query =
502
        "UPDATE language SET " .
503
        "  description = ?, template_code = ?, article_code = ?, " .
504
        "  output_numberformat = ?, output_dateformat = ?, " .
505
        "  output_longdates = ? " .
506
        "WHERE id = ?";
507
      push(@values, $form->{id});
508
    } else {
509
      $query =
510
        "INSERT INTO language (" .
511
        "  description, template_code, article_code, " .
512
        "  output_numberformat, output_dateformat, output_longdates" .
513
        ") VALUES (?, ?, ?, ?, ?, ?)";
514
    }
515
    do_query($form, $dbh, $query, @values);
516
    1;
517
  }) or do { die SL::DB->client->error };
518

  
519
  $main::lxdebug->leave_sub();
520
}
521

  
522
sub delete_language {
523
  $main::lxdebug->enter_sub();
524

  
525
  my ($self, $myconfig, $form) = @_;
526
  my $query;
527

  
528
  SL::DB->client->with_transaction(sub {
529
    my $dbh = SL::DB->client->dbh;
530

  
531
    foreach my $table (qw(generic_translations units_language)) {
532
      $query = qq|DELETE FROM $table WHERE language_id = ?|;
533
      do_query($form, $dbh, $query, $form->{"id"});
534
    }
535

  
536
    $query = "DELETE FROM language WHERE id = ?";
537
    do_query($form, $dbh, $query, $form->{"id"});
538
    1;
539
  }) or do { die SL::DB->client->error };
540

  
541
  $main::lxdebug->leave_sub();
542
}
543

  
544 431
sub prepare_template_filename {
545 432
  $main::lxdebug->enter_sub();
546 433

  
SL/Controller/SimpleSystemSetting.pm
64 64
    },
65 65
  },
66 66

  
67
  language => {
68
    # Make locales.pl happy: $self->render("simple_system_setting/_language_form")
69
    class  => 'Language',
70
    titles => {
71
      list => t8('Languages'),
72
      add  => t8('Add language'),
73
      edit => t8('Edit language'),
74
    },
75
    list_attributes => [
76
      { method => 'description',   title => t8('Description'), },
77
      { method => 'template_code', title => t8('Template Code'), },
78
      { method => 'article_code',  title => t8('Article Code'), },
79
      {                            title => t8('Number Format'), formatter => sub { $_[0]->output_numberformat || t8('use program settings') } },
80
      {                            title => t8('Date Format'),   formatter => sub { $_[0]->output_dateformat   || t8('use program settings') } },
81
      {                            title => t8('Long Dates'),    formatter => sub { $_[0]->output_longdates ? t8('yes') : t8('no') } },
82
    ],
83
  },
84

  
67 85
  part_classification => {
68 86
    # Make locales.pl happy: $self->render("simple_system_setting/_part_classification_form")
69 87
    class  => 'PartClassification',
......
384 402
  $self->{valid_names} = \@SL::DB::RequirementSpecStatus::valid_names;
385 403
}
386 404

  
405
sub setup_language {
406
  my ($self) = @_;
407

  
408
  $self->{numberformats} = [ '1,000.00', '1000.00', '1.000,00', '1000,00', "1'000.00" ];
409
  $self->{dateformats}   = [ qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd) ];
410
}
411

  
387 412
1;
388 413

  
389 414
__END__
bin/mozilla/am.pl
614 614
  $main::lxdebug->leave_sub();
615 615
}
616 616

  
617
sub add_language {
618
  $main::lxdebug->enter_sub();
619

  
620
  my $form     = $main::form;
621

  
622
  $main::auth->assert('config');
623

  
624
  $form->{title} = "Add";
625

  
626
  $form->{callback} = "am.pl?action=add_language" unless $form->{callback};
627

  
628
  &language_header;
629
  &form_footer;
630

  
631
  $main::lxdebug->leave_sub();
632
}
633

  
634
sub edit_language {
635
  $main::lxdebug->enter_sub();
636

  
637
  my $form     = $main::form;
638
  my %myconfig = %main::myconfig;
639

  
640
  $main::auth->assert('config');
641

  
642
  $form->{title} = "Edit";
643

  
644
  AM->get_language(\%myconfig, \%$form);
645

  
646
  &language_header;
647

  
648
  $form->{orphaned} = 1;
649
  &form_footer;
650

  
651
  $main::lxdebug->leave_sub();
652
}
653

  
654
sub list_language {
655
  $::lxdebug->enter_sub;
656
  $::auth->assert('config');
657

  
658
  AM->language(\%::myconfig, $::form);
659

  
660
  $::form->{callback} = "am.pl?action=list_language";
661
  $::form->{title}   = $::locale->text('Languages');
662

  
663
  $::form->header;
664

  
665
  print $::form->parse_html_template('am/language_list');
666

  
667
  $::lxdebug->leave_sub;
668
}
669

  
670
sub language_header {
671
  $::lxdebug->enter_sub;
672
  $::auth->assert('config');
673

  
674
  # $locale->text('Add Language')
675
  # $locale->text('Edit Language')
676
  $::form->{title} = $::locale->text("$::form->{title} Language");
677

  
678
  $::form->header;
679

  
680
  print $::form->parse_html_template('am/language_header', {
681
    numberformats => [ '1,000.00', '1000.00', '1.000,00', '1000,00', "1'000.00" ],
682
    dateformats => [ qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd) ],
683
  });
684

  
685
  $::lxdebug->leave_sub;
686
}
687

  
688
sub save_language {
689
  $main::lxdebug->enter_sub();
690

  
691
  my $form     = $main::form;
692
  my %myconfig = %main::myconfig;
693
  my $locale   = $main::locale;
694

  
695
  $main::auth->assert('config');
696

  
697
  $form->isblank("description", $locale->text('Language missing!'));
698
  $form->isblank("template_code", $locale->text('Template Code missing!'));
699
  $form->isblank("article_code", $locale->text('Article Code missing!'));
700
  AM->save_language(\%myconfig, \%$form);
701
  $form->redirect($locale->text('Language saved!'));
702

  
703
  $main::lxdebug->leave_sub();
704
}
705

  
706
sub delete_language {
707
  $main::lxdebug->enter_sub();
708

  
709
  my $form     = $main::form;
710
  my %myconfig = %main::myconfig;
711
  my $locale   = $main::locale;
712

  
713
  $main::auth->assert('config');
714

  
715
  AM->delete_language(\%myconfig, \%$form);
716
  $form->redirect($locale->text('Language deleted!'));
717

  
718
  $main::lxdebug->leave_sub();
719
}
720

  
721 617
sub _build_cfg_options {
722 618
  my $form     = $main::form;
723 619
  my %myconfig = %main::myconfig;
locale/de/all
161 161
  'Add Follow-Up'               => 'Wiedervorlage erstellen',
162 162
  'Add Follow-Up for #1'        => 'Wiedervorlage für #1 erstellen',
163 163
  'Add General Ledger Transaction' => 'Dialogbuchen',
164
  'Add Language'                => 'Sprache hinzufügen',
165 164
  'Add Letter'                  => 'Brief hinzufügen',
166 165
  'Add Part'                    => 'Ware erfassen',
167 166
  'Add Price Factor'            => 'Preisfaktor erfassen',
......
199 198
  'Add function block'          => 'Funktionsblock hinzufügen',
200 199
  'Add headers from last uploaded file (csv_import)' => 'Spalten aus der hochgeladenen Datei einfügen',
201 200
  'Add invoices'                => 'Rechnungen hinzufügen',
201
  'Add language'                => 'Sprache hinzufügen',
202 202
  'Add link: select records to link with' => 'Verknüpfungen hinzufügen: zu verknüpfende Belege auswählen',
203 203
  'Add linked record'           => 'Verknüpften Beleg hinzufügen',
204 204
  'Add links'                   => 'Verknüpfungen hinzufügen',
......
309 309
  'Are you sure?'               => 'Sind Sie sicher?',
310 310
  'Article'                     => 'Artikel',
311 311
  'Article Code'                => 'Artikelkürzel',
312
  'Article Code missing!'       => 'Artikelkürzel fehlt',
313 312
  'Article classification'      => 'Artikel-Klassifizierung',
314 313
  'Article type'                => 'Artikeltyp',
315 314
  'Articles'                    => 'Artikel',
......
1082 1081
  'Edit Follow-Up'              => 'Wiedervorlage bearbeiten',
1083 1082
  'Edit Follow-Up for #1'       => 'Wiedervorlage für #1 bearbeiten',
1084 1083
  'Edit General Ledger Transaction' => 'Buchung im Hauptbuch bearbeiten',
1085
  'Edit Language'               => 'Sprache bearbeiten',
1086 1084
  'Edit Letter'                 => 'Brief bearbeiten',
1087 1085
  'Edit Part'                   => 'Ware bearbeiten',
1088 1086
  'Edit Preferences for #1'     => 'Einstellungen von #1 bearbeiten',
......
1119 1117
  'Edit file'                   => 'Datei bearbeiten',
1120 1118
  'Edit general settings'       => 'Grundeinstellungen bearbeiten',
1121 1119
  'Edit greetings'              => 'Anreden bearbeiten',
1120
  'Edit language'               => 'Sprache bearbeiten',
1122 1121
  'Edit note'                   => 'Notiz bearbeiten',
1123 1122
  'Edit part classification'    => 'Artikel-Klassifizierung bearbeiten',
1124 1123
  'Edit partsgroup'             => 'Warengruppe bearbeiten',
......
1627 1626
  'Language'                    => 'Sprache',
1628 1627
  'Language (database ID)'      => 'Sprache (Datenbank-ID)',
1629 1628
  'Language (name)'             => 'Sprache (Name)',
1630
  'Language deleted!'           => 'Sprache gelöscht!',
1631
  'Language missing!'           => 'Sprache fehlt!',
1632
  'Language saved!'             => 'Sprache gespeichert!',
1633 1629
  'Language settings'           => 'Spracheinstellungen',
1634 1630
  'Languages'                   => 'Sprachen',
1635 1631
  'Languages and translations'  => 'Sprachen und Übersetzungen',
......
1678 1674
  'Linked invoices'             => 'Verknüpfte Rechnungen',
1679 1675
  'Liquidity projection'        => 'Liquiditätsübersicht',
1680 1676
  'List Accounts'               => 'Konten anzeigen',
1681
  'List Languages'              => 'Sprachen anzeigen',
1682 1677
  'List Price'                  => 'Listenpreis',
1683 1678
  'List Printers'               => 'Drucker anzeigen',
1684 1679
  'List Transactions'           => 'Buchungsliste',
......
2836 2831
  'Telephone'                   => 'Telefon',
2837 2832
  'Template'                    => 'Druckvorlage',
2838 2833
  'Template Code'               => 'Vorlagenkürzel',
2839
  'Template Code missing!'      => 'Vorlagenkürzel fehlt!',
2840 2834
  'Template database'           => 'Datenbankvorlage',
2841 2835
  'Templates'                   => 'Vorlagen',
2842 2836
  'Terms missing in row '       => '+Tage fehlen in Zeile ',
menus/user/00-erp.yaml
1183 1183
  order: 1900
1184 1184
- parent: system_languages_and_translations
1185 1185
  id: system_languages_and_translations_add_language
1186
  name: Add Language
1186
  name: Languages
1187 1187
  order: 100
1188
  module: am.pl
1189
  params:
1190
    action: add_language
1191
- parent: system_languages_and_translations
1192
  id: system_languages_and_translations_list_languages
1193
  name: List Languages
1194
  order: 200
1195
  module: am.pl
1196 1188
  params:
1197
    action: list_language
1189
    action: SimpleSystemSetting/list
1190
    type: language
1198 1191
- parent: system_languages_and_translations
1199 1192
  id: system_languages_and_translations_greetings
1200 1193
  name: Greetings
templates/webpages/am/language_header.html
1
[%- USE L %]
2
[%- USE HTML %]
3
[%- USE LxERP %]
4
[%- USE T8 %]
5
<h1>[% title | html %]</h1>
6

  
7
<form method=post action=am.pl>
8

  
9
<input type=hidden name=id value='[% id %]'>
10
<input type=hidden name=type value=language>
11

  
12
<table width=100%>
13
  <tr>
14
    <th align=right>[% 'Language' | $T8 %]</th>
15
    <td><input name=description size=30 value="[% description | html %]"></td>
16
  <tr>
17
  <tr>
18
    <th align=right>[% 'Template Code' | $T8 %]</th>
19
    <td><input name=template_code size=5 value="[% template_code | html %]"></td>
20
  </tr>
21
  <tr>
22
    <th align=right>[% 'Article Code' | $T8 %]</th>
23
    <td><input name=article_code size=10 value="[% article_code | html %]"></td>
24
  </tr>
25
  <tr>
26
    <th align=right>[% 'Number Format' | $T8 %]</th>
27
    <td>[% L.select_tag('output_numberformat', numberformats, default = output_numberformat, with_empty = 1, empty_title = LxERP.t8('use program settings')) %]</td>
28
  </tr>
29
  <tr>
30
    <th align=right>[% 'Date Format' | $T8 %]</th>
31
    <td>[% L.select_tag('output_dateformat', dateformats, default = output_dateformat, with_empty = 1, empty_title=LxERP.t8('use program settings')) %]</td>
32
  </tr>
33
  <tr>
34
    <th align=right>[% 'Long Dates' | $T8 %]</th>
35
    <td>[% L.radio_button_tag('output_longdates', checked=output_longdates, label=LxERP.t8('Yes')) %]
36
        [% L.radio_button_tag('output_longdates', checked=!output_longdates, label=LxERP.t8('No')) %]</td>
37
  </tr>
38
  <td colspan=2><hr size=3 noshade></td>
39
  </tr>
40
</table>
templates/webpages/am/language_list.html
1
[%- USE HTML %]
2
[%- USE L %]
3
[%- USE LxERP %]
4
[%- USE T8 %]
5
<h1>[% title | html %]</h1>
6

  
7
<table width=100%>
8
  <tr>
9
    <td>
10
      <table width=100%>
11
        <tr class=listheading>
12
          <th class=listheading>[% 'Description' | $T8 %]</th>
13
          <th class=listheading>[% 'Template Code' | $T8 %]</th>
14
          <th class=listheading>[% 'Article Code' | $T8 %]</th>
15
          <th class=listheading>[% 'Number Format' | $T8 %]</th>
16
          <th class=listheading>[% 'Date Format' | $T8 %]</th>
17
          <th class=listheading>[% 'Long Dates' | $T8 %]</th>
18
        </tr>
19
[%- FOREACH row = ALL %]
20
        <tr valign=top class=listrow[% loop.count % 2 %]>
21
         <td><a href="am.pl?action=edit_language&id=[% row.id | html %]&callback=[% callback | html %]">[% row.description %]</a></td>
22
         <td align=right>[% row.template_code | html %]</td>
23
         <td align=right>[% row.article_code | html %]</td>
24
         <td nowrap>[% row.output_numberformat ? row.output_numberformat : LxERP.t8('use program settings') | html %]</td>
25
         <td nowrap>[% row.output_dateformat   ? row.output_dateformat   : LxERP.t8('use program settings') | html %]</td>
26
         <td nowrap>[% row.output_longdates    ? LxERP.t8('Yes')         : LxERP.t8('No') %]</td>
27
[%- END %]
28
       </tr>
29
      </table>
30
    </td>
31
  </tr>
32
  <tr>
33
  <td><hr size=3 noshade></td>
34
  </tr>
35
</table>
36

  
37
<br>
38
<form method=post action=am.pl>
39

  
40
<input name=callback type=hidden value="[% callback | html %]">
41
<input type=hidden name=type value=language>
42
<input class=submit type=submit name=action value="[% 'Add' | $T8 %]">
43

  
44
  </form>
45

  
templates/webpages/simple_system_setting/_language_form.html
1
[%- USE LxERP -%][%- USE L -%][%- USE HTML -%]
2
[% SET style="width: 250px" %]
3
<table>
4
 <tr>
5
  <th align="right">[% LxERP.t8("Language") %]</th>
6
  <td>[% L.input_tag("object.description", SELF.object.description, style=style, "data-validate"="required", "data-title"=LxERP.t8("Language")) %]</td>
7
 <tr>
8
 <tr>
9
  <th align="right">[% LxERP.t8("Template Code") %]</th>
10
  <td>[% L.input_tag("object.template_code", SELF.object.template_code, style=style) %]</td>
11
 </tr>
12
 <tr>
13
  <th align="right">[% LxERP.t8("Article Code") %]</th>
14
  <td>[% L.input_tag("object.article_code", SELF.object.article_code, style=style) %]</td>
15
 </tr>
16
 <tr>
17
  <th align="right">[% LxERP.t8("Number Format") %]</th>
18
  <td>[% L.select_tag("object.output_numberformat", SELF.numberformats, default=SELF.object.output_numberformat, with_empty=1, empty_title=LxERP.t8("use program settings"), style=style) %]</td>
19
 </tr>
20
 <tr>
21
  <th align="right">[% LxERP.t8("Date Format") %]</th>
22
  <td>[% L.select_tag("object.output_dateformat", SELF.dateformats, default=SELF.object.output_dateformat, with_empty=1, empty_title=LxERP.t8("use program settings"), style=style) %]</td>
23
 </tr>
24
 <tr>
25
  <th align="right">[% LxERP.t8("Long Dates") %]</th>
26
  <td>[% L.yes_no_tag("object.output_longdates", SELF.object.output_longdates, style=style) %]</td>
27
 </tr>
28
</table>

Auch abrufbar als: Unified diff