Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 04c54ebf

Von Tamino Steinert vor 10 Monaten hinzugefügt

  • ID 04c54ebf7bab800ffd4753d266548b8dc323db1f
  • Vorgänger e8aea3fc
  • Nachfolger 46ee23a1

Varianten: Schnellbearbeitung von Varianten (LP,VK,EK,ROP)

Unterschiede anzeigen:

SL/Controller/Part.pm
259 259
  $self->js->render();
260 260
}
261 261

  
262
sub action_add_variant_property {
262
sub action_update_variants {
263 263
  my ($self) = @_;
264 264

  
265
  my $variant_property_id = $::form->{add_variant_property};
266
  die t8("Please select a variant property") unless ($variant_property_id);
267 265
  my %variant_id_to_values = map {$_->{id} => $_} @{$::form->{variants}};
268
  foreach my $variant (@{$self->part->variants}) {
269
    die t8("Please select a new variant property value for all variants")
270
      unless $variant_id_to_values{$variant->id}->{"add_variant_property_value"};
266

  
267
  my $variant_property_id = $::form->{add_variant_property};
268
  if ($variant_property_id) {
269
    foreach my $variant (@{$self->part->variants}) {
270
      die t8("Please select a new variant property value for all variants")
271
        unless $variant_id_to_values{$variant->id}->{"add_variant_property_value"};
272
    }
271 273
  }
272 274

  
273 275
  SL::DB->client->with_transaction(sub {
274
    SL::DB::VariantPropertyPart->new(
275
      part_id             => $self->part->id,
276
      variant_property_id => $variant_property_id,
277
    )->save;
278 276
    foreach my $variant (@{$self->part->variants}) {
279
      SL::DB::VariantPropertyValuePart->new(
280
        part_id                   => $variant->id,
281
        variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"},
277
      $variant->update_attributes(
278
        description         => $variant_id_to_values{$variant->id}->{description},
279
        listprice_as_number => $variant_id_to_values{$variant->id}->{listprice_as_number},
280
        sellprice_as_number => $variant_id_to_values{$variant->id}->{sellprice_as_number},
281
        lastcost_as_number  => $variant_id_to_values{$variant->id}->{lastcost_as_number},
282
        rop_as_number       => $variant_id_to_values{$variant->id}->{rop_as_number},
283
      );
284
    }
285
    if ($variant_property_id) {
286
      SL::DB::VariantPropertyPart->new(
287
        part_id             => $self->part->id,
288
        variant_property_id => $variant_property_id,
282 289
      )->save;
290
      foreach my $variant (@{$self->part->variants}) {
291
        SL::DB::VariantPropertyValuePart->new(
292
          part_id                   => $variant->id,
293
          variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"},
294
        )->save;
295
      }
283 296
    }
284 297
    1;
285 298
  }) or do {
js/kivi.Part.js
411 411
    $.post("controller.pl", data, kivi.eval_json_result);
412 412
  };
413 413

  
414
  ns.add_variant_property = function() {
414
  ns.update_variants = function() {
415 415
    var data = $('#ic').serializeArray();
416
    data.push({ name: 'action', value: 'Part/add_variant_property' });
416
    data.push({ name: 'action', value: 'Part/update_variants' });
417 417
    $.post("controller.pl", data, kivi.eval_json_result);
418 418
  };
419 419

  
templates/design40_webpages/part/_parent_variant.html
41 41
          </a>
42 42
        </th>
43 43
        [% END %]
44
        <th>[% 'List Price' | $T8 %]</th>
45
        <th>[% 'Sell Price' | $T8 %]</th>
46
        <th>[% 'Last Cost' | $T8 %]</th>
47
        <th>[% 'ROP' | $T8 %]</th>
44 48
        <th>
45 49
          [% L.select_tag("add_variant_property", AVAILABLE_VARIANT_PROPERIES
46 50
            title_key='displayable_name', value_key='id',
47
            with_empty=1, empty_title=LxERP.t8("Variant Property"),
51
            with_empty=1, empty_title=LxERP.t8("Add Variant Property"),
48 52
            onchange='kivi.Part.update_variant_property_value_options();',
49 53
          )%]
50
          [% L.button_tag('kivi.Part.add_variant_property();', LxERP.t8("Insert new")) %]
51 54
        </th>
52 55
      </tr>
53 56
      <tr>
......
70 73
          ) %]
71 74
        </th>
72 75
        <th colspan="[% SELF.part.variant_properties.size + 1 %]"></th>
76
        <th>
77
          [% L.input_tag(
78
                "listprice_as_number_for_selected_variants",
79
                SELF.part.listprice_as_number,
80
                class="reformat_number numeric wi-small",
81
          ) %]
82
          [%- L.button_tag(
83
                'kivi.Part.set_selected_variants_to_value("listprice_as_number")',
84
                "↓",
85
                alt=LxERP.t8('Apply to selected rows'),
86
                title=LxERP.t8('Apply to selected rows'),
87
          ) %]
88
        </th>
89
        <th>
90
          [% L.input_tag(
91
                "sellprice_as_number_for_selected_variants",
92
                SELF.part.sellprice_as_number,
93
                class="reformat_number numeric wi-small",
94
          ) %]
95
          [%- L.button_tag(
96
                'kivi.Part.set_selected_variants_to_value("sellprice_as_number")',
97
                "↓",
98
                alt=LxERP.t8('Apply to selected rows'),
99
                title=LxERP.t8('Apply to selected rows'),
100
          ) %]
101
        </th>
102
        <th>
103
          [% L.input_tag(
104
                "lastcost_as_number_for_selected_variants",
105
                SELF.part.lastcost_as_number,
106
                class="reformat_number numeric wi-small",
107
          ) %]
108
          [%- L.button_tag(
109
                'kivi.Part.set_selected_variants_to_value("lastcost_as_number")',
110
                "↓",
111
                alt=LxERP.t8('Apply to selected rows'),
112
                title=LxERP.t8('Apply to selected rows'),
113
          ) %]
114
        </th>
115
        <th>
116
          [% L.input_tag(
117
                "rop_as_number_for_selected_variants",
118
                SELF.part.rop_as_number,
119
                class="reformat_number numeric wi-small",
120
          ) %]
121
          [%- L.button_tag(
122
                'kivi.Part.set_selected_variants_to_value("rop_as_number")',
123
                "↓",
124
                alt=LxERP.t8('Apply to selected rows'),
125
                title=LxERP.t8('Apply to selected rows'),
126
          ) %]
127
        </th>
73 128
        <th>
74 129
          [% L.select_tag("add_variant_property_value_for_selected_variants", []
75 130
                title_key='displayable_name', value_key='id',
......
100 155
            [% FOREACH variant_property = SELF.part.variant_properties %]
101 156
            <td> [% variant.variant_value(variant_property) %] </td>
102 157
            [% END %]
158
            <td>
159
              [% L.input_tag(
160
                    "variants[].listprice_as_number",
161
                    variant.listprice_as_number,
162
                    class='reformat_number numeric wi-small',
163
              ) %]
164
            </td>
165
            <td>
166
              [% L.input_tag(
167
                    "variants[].sellprice_as_number",
168
                    variant.sellprice_as_number,
169
                    class='reformat_number numeric wi-small',
170
              ) %]
171
            </td>
172
            <td>
173
              [% L.input_tag(
174
                    "variants[].lastcost_as_number",
175
                    variant.lastcost_as_number,
176
                    class='reformat_number numeric wi-small',
177
              ) %]
178
            </td>
179
            <td>
180
              [% L.input_tag(
181
                    "variants[].rop_as_number",
182
                    variant.rop_as_number,
183
                    class='reformat_number numeric wi-small',
184
              ) %]
185
            </td>
103 186
            <td>
104 187
              [% L.select_tag("variants[].add_variant_property_value", []
105 188
                title_key='displayable_name', value_key='id',
......
110 193
        [% END %]
111 194
      </tbody>
112 195
    </table>
196
    [% L.button_tag('kivi.Part.update_variants();', LxERP.t8("Update Variants")) %]
113 197
  </div>
114 198

  
115 199
  <div class="wrapper input-panel">

Auch abrufbar als: Unified diff