Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4694b5fd

Von Tamino Steinert vor 6 Tagen hinzugefügt

  • ID 4694b5fd0c716df62d7dd0b68c9c40a807da3d7f
  • Vorgänger b00c1e17
  • Nachfolger 5618b4b3

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

Unterschiede anzeigen:

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

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

  
266
  my $variant_property_id = $::form->{add_variant_property};
267
  die t8("Please select a variant property") unless ($variant_property_id);
268 266
  my %variant_id_to_values = map {$_->{id} => $_} @{$::form->{variants}};
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"};
267

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

  
274 276
  SL::DB->client->with_transaction(sub {
275
    SL::DB::VariantPropertyPart->new(
276
      part_id             => $self->part->id,
277
      variant_property_id => $variant_property_id,
278
    )->save;
279 277
    foreach my $variant (@{$self->part->variants}) {
280
      SL::DB::VariantPropertyValuePart->new(
281
        part_id                   => $variant->id,
282
        variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"},
278
      $variant->update_attributes(
279
        description         => $variant_id_to_values{$variant->id}->{description},
280
        listprice_as_number => $variant_id_to_values{$variant->id}->{listprice_as_number},
281
        sellprice_as_number => $variant_id_to_values{$variant->id}->{sellprice_as_number},
282
        lastcost_as_number  => $variant_id_to_values{$variant->id}->{lastcost_as_number},
283
        rop_as_number       => $variant_id_to_values{$variant->id}->{rop_as_number},
284
      );
285
    }
286
    if ($variant_property_id) {
287
      SL::DB::VariantPropertyPart->new(
288
        part_id             => $self->part->id,
289
        variant_property_id => $variant_property_id,
283 290
      )->save;
291
      foreach my $variant (@{$self->part->variants}) {
292
        SL::DB::VariantPropertyValuePart->new(
293
          part_id                   => $variant->id,
294
          variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"},
295
        )->save;
296
      }
284 297
    }
285 298
    1;
286 299
  }) 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