Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 913fe339

Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt

  • ID 913fe3398532666f18ec4856470fdfec53b1d388
  • Vorgänger 03c310de
  • Nachfolger 9c2d49bb

Dialogbuchen: Die Drop-Down-Boxen bei jedem Formularaufbau aus der Datenbank heraus aufbauen und nicht in $form mitschleifen. Behebt auch den Fehler, dass das Steuerkonto beim initialen Aufbau nicht richtig ausgewählt wurde.

Unterschiede anzeigen:

SL/Form.pm
1526 1526
  $main::lxdebug->leave_sub();
1527 1527
}
1528 1528

  
1529
sub _get_charts {
1530
  $main::lxdebug->enter_sub();
1531

  
1532
  my ($self, $dbh, $params) = @_;
1533

  
1534
  $key = $params->{key};
1535
  $key = "all_charts" unless ($key);
1536
  $self->{$key} = [];
1537

  
1538
  my $transdate = quote_db_date($params->{transdate});
1539

  
1540
  my $query =
1541
    qq|SELECT c.accno, c.description, c.link, tk.taxkey_id, tk.tax_id | .
1542
    qq|FROM chart c | .
1543
    qq|LEFT JOIN taxkeys tk ON | .
1544
    qq|(tk.id = (SELECT id FROM taxkeys | .
1545
    qq|          WHERE taxkeys.chart_id = c.id AND startdate <= $transdate | .
1546
    qq|          ORDER BY startdate DESC LIMIT 1)) | .
1547
    qq|ORDER BY c.accno|;
1548

  
1549
  my $sth = $dbh->prepare($query);
1550
  $sth->execute() || $self->dberror($query);
1551

  
1552
  while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
1553
    push(@{ $self->{$key} }, $ref);
1554
  }
1555
  $sth->finish;
1556

  
1557
  $main::lxdebug->leave_sub();
1558
}
1559

  
1560
sub _get_taxcharts {
1561
  $main::lxdebug->enter_sub();
1562

  
1563
  my ($self, $dbh, $key) = @_;
1564

  
1565
  $key = "all_taxcharts" unless ($key);
1566
  $self->{$key} = [];
1567

  
1568
  my $query = qq|SELECT * FROM tax ORDER BY taxkey|;
1569

  
1570
  my $sth = $dbh->prepare($query);
1571
  $sth->execute() || $self->dberror($query);
1572

  
1573
  while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
1574
    push(@{ $self->{$key} }, $ref);
1575
  }
1576
  $sth->finish;
1577

  
1578
  $main::lxdebug->leave_sub();
1579
}
1580

  
1529 1581
sub get_lists {
1530 1582
  $main::lxdebug->enter_sub();
1531 1583

  
......
1556 1608
    $self->_get_printers($dbh, $params{"printers"});
1557 1609
  }
1558 1610

  
1611
  if ($params{"charts"}) {
1612
    $self->_get_charts($dbh, $params{"charts"});
1613
  }
1614

  
1615
  if ($params{"taxcharts"}) {
1616
    $self->_get_taxcharts($dbh, $params{"taxcharts"});
1617
  }
1618

  
1559 1619
  $dbh->disconnect();
1560 1620

  
1561 1621
  $main::lxdebug->leave_sub();
bin/mozilla/gl.pl
81 81
  # we use this only to set a default date
82 82
  GL->transaction(\%myconfig, \%$form);
83 83

  
84
  map {
85
    $chart .=
86
      "<option value=\"$_->{accno}--$_->{tax_id}\">$_->{accno}--$_->{description}</option>"
87
  } @{ $form->{chart} };
88 84
  map {
89 85
    $tax .=
90 86
      qq|<option value="$_->{id}--$_->{rate}">$_->{taxdescription}  |
91 87
      . ($_->{rate} * 100) . qq| %|
92 88
  } @{ $form->{TAX} };
93 89

  
94
  $form->{chart}     = $chart;
95
  $form->{chartinit} = $chart;
96 90
  $form->{rowcount}  = 2;
97 91

  
98
  $form->{debitchart}  = $chart;
99
  $form->{creditchart} = $chart;
100
  $form->{taxchart}    = $tax;
101

  
102 92
  $form->{debit}  = 0;
103 93
  $form->{credit} = 0;
104 94
  $form->{tax}    = 0;
......
123 113
  $lxdebug->enter_sub();
124 114

  
125 115
  GL->transaction(\%myconfig, \%$form);
126
  map {
127
    $chart .=
128
      "<option value=\"$_->{accno}--$_->{tax_id}\">$_->{accno}--$_->{description}</option>"
129
  } @{ $form->{chart} };
130 116

  
131 117
  map {
132 118
    $tax .=
......
134 120
      . ($_->{rate} * 100) . qq| %|
135 121
  } @{ $form->{TAX} };
136 122

  
137
  $form->{chart} = $chart;
138

  
139
  $form->{taxchart} = $tax;
140

  
141 123
  $form->{amount} = $form->format_amount(\%myconfig, $form->{amount}, 2);
142 124

  
143 125
  # departments
......
1081 1063

  
1082 1064
  $form->{totaldebit}  = 0;
1083 1065
  $form->{totalcredit} = 0;
1084
  my $chart = $form->{chart};
1085
  $chart            = $form->unquote($chart);
1086
  $form->{taxchart} = $form->unquote($form->{taxchart});
1087
  $taxchart         = $form->{taxchart};
1088 1066

  
1089 1067
  my @old_project_ids = ();
1090 1068
  map({ push(@old_project_ids, $form->{"project_id_$_"})
......
1092 1070

  
1093 1071
  $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1094 1072
                                   "all" => 0,
1095
                                   "old_id" => \@old_project_ids });
1073
                                   "old_id" => \@old_project_ids },
1074
                   "charts" => { "key" => "ALL_CHARTS",
1075
                                 "transdate" => $form->{transdate} },
1076
                   "taxcharts" => "ALL_TAXCHARTS");
1096 1077

  
1097 1078
  my %project_labels = ();
1098 1079
  my @project_values = ("");
......
1101 1082
    $project_labels{$item->{"id"}} = $item->{"projectnumber"};
1102 1083
  }
1103 1084

  
1085
  my %chart_labels = ();
1086
  my @chart_values = ();
1087
  my $taxchart_init;
1088
  foreach my $item (@{ $form->{ALL_CHARTS} }) {
1089
    my $key = Q($item->{accno}) . "--" . Q($item->{tax_id});
1090
    $taxchart_init = $item->{taxkey_id} unless (@chart_values);
1091
    push(@chart_values, $key);
1092
    $chart_labels{$key} = H($item->{accno}) . "--" . H($item->{description});
1093
  }
1094

  
1095
  my %taxchart_labels = ();
1096
  my @taxchart_values = ();
1097
  foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
1098
    my $key = Q($item->{id}) . "--" . Q($item->{rate});
1099
    $taxchart_init = $key if ($taxchart_init eq $item->{taxkey});
1100
    push(@taxchart_values, $key);
1101
    $taxchart_labels{$key} = H($item->{taxdescription}) . " " .
1102
      H($item->{rate} * 100) . ' %';
1103
  }
1104

  
1104 1105
  for $i (1 .. $form->{rowcount}) {
1105 1106

  
1106 1107
    $source = qq|
......
1110 1111
    <td><input name="memo_$i" value="$form->{"memo_$i"}" size="16" tabindex=|
1111 1112
      . ($i + 12 + (($i - 1) * 8)) . qq|></td>|;
1112 1113

  
1113
    if ($init) {
1114
      $accno = qq|
1115
      <td><select name="accno_$i" onChange="setTaxkey(this, $i)" style="width:200px" tabindex=|
1116
        . ($i + 5 + (($i - 1) * 8)) . qq|>$form->{chartinit}</select></td>|;
1117
      $tax =
1118
        qq|<td><select id="taxchart_$i" name="taxchart_$i" style="width:200px" tabindex=|
1119
        . ($i + 10 + (($i - 1) * 8))
1120
        . qq|>$form->{taxchart}</select></td>|;
1114
    $accno = qq|<td>| .
1115
      $cgi->popup_menu('-name' => "accno_$i",
1116
                       '-onChange' => "setTaxkey(this, $i)",
1117
                       '-style' => 'width:200px',
1118
                       '-tabindex' => ($i + 5 + (($i - 1) * 8)),
1119
                       '-values' => \@chart_values,
1120
                       '-labels' => \%chart_labels,
1121
                       '-default' => $init ? '' : $form->{"accno_$i"})
1122
      . qq|</td>|;
1123
    $tax = qq|<td>| .
1124
      $cgi->popup_menu('-name' => "taxchart_$i",
1125
                       '-style' => 'width:200px',
1126
                       '-tabindex' => ($i + 10 + (($i - 1) * 8)),
1127
                       '-values' => \@taxchart_values,
1128
                       '-labels' => \%taxchart_labels,
1129
                       '-default' => $init ? $taxchart_init : $form->{"taxchart_$i"})
1130
      . qq|</td>|;
1121 1131

  
1132
    if ($init) {
1122 1133
      $korrektur =
1123 1134
        qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|
1124 1135
        . ($i + 9 + (($i - 1) * 8))
......
1150 1161
      }
1151 1162

  
1152 1163
      if ($i < $form->{rowcount}) {
1153

  
1154
        $accno          = $chart;
1155
        $chart_selected = $form->{"accno_$i"};
1156
        $accno =~
1157
          s/value=\"$chart_selected\"/value=\"$chart_selected\" selected/;
1158
        $accno =
1159
          qq|<td><select name="accno_$i" onChange="setTaxkey(this, $i)" style="width:200px" tabindex=|
1160
          . ($i + 5 + (($i - 1) * 8))
1161
          . qq|>$accno</select></td>|;
1162
        $tax          = $taxchart;
1163
        $tax_selected = $form->{"taxchart_$i"};
1164
        $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
1165
        $tax =
1166
            qq|<td><select id="taxchart_$i" name="taxchart_$i" tabindex=|
1167
          . ($i + 10 + (($i - 1) * 8))
1168
          . qq|>$tax</select></td>|;
1169

  
1170 1164
        if ($form->{transfer}) {
1171 1165
          $checked = ($form->{"fx_transaction_$i"}) ? "1" : "";
1172 1166
          $x = ($checked) ? "x" : "";
......
1182 1176
        $form->hide_form("accno_$i");
1183 1177

  
1184 1178
      } else {
1185

  
1186
        $accno = qq|
1187
      <td><select name="accno_$i" onChange="setTaxkey(this, $i)" style="width:300px" tabindex=|
1188
          . ($i + 5 + (($i - 1) * 8)) . qq|>$chart</select></td>|;
1189
        $tax = qq|
1190
      <td><select id="taxchart_$i" name="taxchart_$i" tabindex=|
1191
          . ($i + 10 + (($i - 1) * 8)) . qq|>$taxchart</select></td>|;
1192

  
1193 1179
        $korrektur =
1194 1180
          qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|
1195 1181
          . ($i + 9 + (($i - 1) * 8))
......
1339 1325
<input type=hidden name=closedto value=$form->{closedto}>
1340 1326
<input type=hidden name=locked value=$form->{locked}>
1341 1327
<input type=hidden name=title value="$title">
1342
<input type=hidden name=taxchart value="$form->{taxchart}">
1343
<input type=hidden name=chart value="$form->{chart}">
1344 1328

  
1345 1329

  
1346 1330
<table width=100%>
......
1532 1516
<form method=post action=$form->{script}>
1533 1517
|;
1534 1518

  
1535
  map { $form->{$_} =~ s/\"/&quot;/g } qw(reference description chart taxchart);
1519
  map { $form->{$_} =~ s/\"/&quot;/g } qw(reference description);
1536 1520

  
1537 1521
  delete $form->{header};
1538 1522

  

Auch abrufbar als: Unified diff