Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7c2886a7

Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt

  • ID 7c2886a7ca732655319fd0a33858174d2396ace8
  • Vorgänger 0d190035
  • Nachfolger 66f2badb

Preisgruppen in Artikelstammdatendialog in gleicher Reihenfolge anzeigen

Fixt #1873.

Unterschiede anzeigen:

SL/IC.pm
109 109
  $form->{amount}{IC_expense} = $form->{expense_accno};
110 110
  $form->{amount}{IC_cogs}    = $form->{expense_accno};
111 111

  
112
  my @pricegroups          = ();
113
  my @pricegroups_not_used = ();
114

  
115 112
  # get prices
116
  $query =
117
    qq|SELECT p.parts_id, p.pricegroup_id, p.price,
118
         (SELECT pg.pricegroup
119
          FROM pricegroup pg
120
          WHERE pg.id = p.pricegroup_id) AS pricegroup
121
       FROM prices p
122
       WHERE (parts_id = ?)
123
       ORDER BY pricegroup|;
124
  $sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id}));
125

  
126
  #for pricegroups
127
  my $i = 1;
128
  while (($form->{"klass_$i"}, $form->{"pricegroup_id_$i"},
129
          $form->{"price_$i"}, $form->{"pricegroup_$i"})
130
         = $sth->fetchrow_array()) {
131
    push @pricegroups, $form->{"pricegroup_id_$i"};
132
    $i++;
133
  }
134

  
135
  $sth->finish;
136

  
137
  # get pricegroups
138
  $query = qq|SELECT id, pricegroup FROM pricegroup|;
139
  $form->{PRICEGROUPS} = selectall_hashref_query($form, $dbh, $query);
140

  
141
  #find not used pricegroups
142
  while (my $tmp = pop(@{ $form->{PRICEGROUPS} })) {
143
    my $in_use = 0;
144
    foreach my $item (@pricegroups) {
145
      if ($item eq $tmp->{id}) {
146
        $in_use = 1;
147
        last;
148
      }
149
    }
150
    push(@pricegroups_not_used, $tmp) unless ($in_use);
151
  }
152

  
153
  # if not used pricegroups are avaible
154
  if (@pricegroups_not_used) {
113
  $query = <<SQL;
114
    SELECT pg.pricegroup, pg.id AS pricegroup_id, COALESCE(pr.price, 0) AS price
115
    FROM pricegroup pg
116
    LEFT JOIN prices pr ON (pr.pricegroup_id = pg.id) AND (pr.parts_id = ?)
117
    ORDER BY lower(pg.pricegroup)
118
SQL
155 119

  
156
    foreach my $name (@pricegroups_not_used) {
157
      $form->{"klass_$i"} = "$name->{id}";
158
      $form->{"pricegroup_id_$i"} = "$name->{id}";
159
      $form->{"pricegroup_$i"}    = "$name->{pricegroup}";
160
      $i++;
161
    }
120
  my $row = 1;
121
  foreach $ref (selectall_hashref_query($form, $dbh, $query, conv_i($form->{id}))) {
122
    $form->{"${_}_${row}"} = $ref->{$_} for qw(pricegroup_id pricegroup price);
123
    $row++;
162 124
  }
163

  
164
  #correct rows
165
  $form->{price_rows} = $i - 1;
125
  $form->{price_rows} = $row - 1;
166 126

  
167 127
  # get makes
168 128
  if ($form->{makemodel}) {
......
241 201
  my $dbh = $form->dbconnect($myconfig);
242 202

  
243 203
  # get pricegroups
244
  my $query = qq|SELECT id, pricegroup FROM pricegroup|;
204
  my $query = qq|SELECT id, pricegroup FROM pricegroup ORDER BY lower(pricegroup)|;
245 205
  my $pricegroups = selectall_hashref_query($form, $dbh, $query);
246 206

  
247 207
  my $i = 1;

Auch abrufbar als: Unified diff