Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 69597c45

Von Jan Büren vor mehr als 1 Jahr hinzugefügt

  • ID 69597c4596bbcc3f6d0c50346ad56fcd51109924
  • Vorgänger 67e51032
  • Nachfolger fdbb484e

ShopOrder nur teilweise Positionen für den Auftrag übernehmen

Unterschiede anzeigen:

SL/Controller/ShopOrder.pm
135 135
sub action_transfer {
136 136
  my ( $self ) = @_;
137 137

  
138
  $::form->{customer} ||= $::form->{partial_transfer_customer_id};
139

  
138 140
  my $customer = SL::DB::Manager::Customer->find_by(id => $::form->{customer});
139
  die "Can't find customer" unless $customer;
141
  die "Can't find customer" unless ref $customer eq 'SL::DB::Customer';
142

  
140 143
  my $employee = SL::DB::Manager::Employee->current;
141 144
  die "Can't find employee" unless $employee;
142 145

  
143 146
  die "Can't load shop_order form form->import_id" unless $self->shop_order;
144
  my $order = $self->shop_order->convert_to_sales_order(customer => $customer, employee => $employee);
147
  my $order = $self->shop_order->convert_to_sales_order(customer => $customer, employee => $employee,
148
                                                        pos_ids  => $::form->{pos_ids}               );
145 149

  
146 150
  if ($order->{error}){
147 151
    flash_later('error',@{$order->{errors}});
......
370 374
=item C<action_transfer>
371 375

  
372 376
Transfers one shoporder to an order.
377
If the optional  $::form->{pos_ids} exists, they will be added
378
as a param for the convert_to_sales_order method
373 379

  
374 380
=item C<action_apply_customer>
375 381

  
SL/DB/ShopOrder.pm
30 30
  my $customer  = delete $params{customer};
31 31
  my $employee  = delete $params{employee};
32 32
  my $transdate = delete $params{transdate} // DateTime->today_local;
33

  
33 34
  croak "param customer is missing" unless ref($customer) eq 'SL::DB::Customer';
34 35
  croak "param employee is missing" unless ref($employee) eq 'SL::DB::Employee';
35 36

  
37
  # check if caller wants optional partial transfer and create partial soi array
38
  my $partial_transfer;
39
  my %pos_ids;
40
  if ($params{pos_ids}) {
41
    $partial_transfer = 1;
42
    %pos_ids          =  %{ delete $params{pos_ids} };
43
    # TODO check if pos_ids is a valid hash
44
  }
45
  my @soi = $partial_transfer
46
          ? grep { $pos_ids{$_->id} } @{ $self->shop_order_items }
47
          : @{ $self->shop_order_items };
48

  
36 49
  require SL::DB::Order;
37 50
  require SL::DB::OrderItem;
38 51
  require SL::DB::Part;
......
58 71
        discount            => $_->discount,
59 72
      );
60 73
    }
61
  }@{ $self->shop_order_items };
62

  
74
  } @soi;
63 75
  if(!scalar(@error_report)){
64 76

  
65 77
    my $shipto_id;
locale/de/all
903 903
  'Create new version'          => 'Neue Version anlegen',
904 904
  'Create one from the context menu by right-clicking on this text.' => 'Erstellen Sie einen aus dem Kontextmenü, indem Sie auf diesen Text rechtsklicken.',
905 905
  'Create order'                => 'Auftrag erstellen',
906
  'Create partial order'        => 'Teil-Auftrag erstellen',
906 907
  'Create sales invoices with Factur-X/ZUGFeRD data' => 'Verkaufsrechnungen mit Factur-X-/ZUGFeRD-Daten erzeugen',
907 908
  'Create sales invoices with Swiss QR-bill' => 'Verkaufsrechnungen mit Schweizer QR-Rechnung erzeugen',
908 909
  'Create tables'               => 'Tabellen anlegen',
templates/design40_webpages/shop_order/show.html
417 417
</div>
418 418

  
419 419
<div class="wrapper" id="wrapper-3">
420
  <table class="tbl-list" style="width:100%">
421
    <thead>
422
      <tr>
423
        <th>[% 'Position'          | $T8 %]</th>
424
        <th>[% 'Partnumber'        | $T8 %]</th>
425
        <th>[% 'Partdescriptipion' | $T8 %]</th>
426
        <th>[% 'Qty'               | $T8 %]</th>
427
        <th>[% 'Price'             | $T8 %]</th>
428
        <th>[% 'Discount'          | $T8 %]</th>
429
        <th>[% 'Promotion Code'    | $T8 %]</th>
430
        <th>[% 'Extended'          | $T8 %]</th>
431
      </tr>
432
    </thead>
433
    <tbody>
434
      [% FOREACH pos = IMPORT.shop_order_items %]
435
        <tr>
436
          <td>[% loop.count                                      %]</td>
437
          <td>[% HTML.escape(pos.partnumber)                     %]</td>
438
          <td>[% HTML.escape(pos.description)                    %]</td>
439
          <td>[% pos.quantity_as_number                          %]</td>
440
          <td>[% pos.price_as_number                             %]</td>
441
          <td>[% pos.discount_as_number * 100                  %] %</td>
442
          <td>[% pos.discount_code                               %]</td>
443
          <td>[% LxERP.format_amount(pos.price * pos.quantity,2) %]</td>
444
        </tr>
445
      [% END %]
446
    </tbody>
447
  </table>
420
  <form method="post" action="controller.pl" id="create_partial_order">
421
  [% L.hidden_tag('import_id', IMPORT.id) %]
422
    <table class="tbl-list" style="width:100%">
423
      <thead>
424
        <tr>
425
          <th>[% 'Assign'            | $T8 %]</th>
426
          <th>[% 'Position'          | $T8 %]</th>
427
          <th>[% 'Partnumber'        | $T8 %]</th>
428
          <th>[% 'Partdescriptipion' | $T8 %]</th>
429
          <th>[% 'Qty'               | $T8 %]</th>
430
          <th>[% 'Price'             | $T8 %]</th>
431
          <th>[% 'Discount'          | $T8 %]</th>
432
          <th>[% 'Promotion Code'    | $T8 %]</th>
433
          <th>[% 'Extended'          | $T8 %]</th>
434
        </tr>
435
      </thead>
436
      <tbody>
437
        [% FOREACH pos = IMPORT.shop_order_items %]
438
          <tr>
439
            <td>[% L.checkbox_tag("pos_ids." _ pos.id _ "[]", value=1, checked=1) %]</td>
440
            <td>[% loop.count                                      %]</td>
441
            <td>[% HTML.escape(pos.partnumber)                     %]</td>
442
            <td>[% HTML.escape(pos.description)                    %]</td>
443
            <td>[% pos.quantity_as_number                          %]</td>
444
            <td>[% pos.price_as_number                             %]</td>
445
            <td>[% pos.discount_as_number * 100                  %] %</td>
446
            <td>[% pos.discount_code                               %]</td>
447
            <td>[% LxERP.format_amount(pos.price * pos.quantity,2) %]</td>
448
          </tr>
449
        [% END %]
450
      </tbody>
451
    </table>
452
    <div id="partial_transfer" style="float:left; display:none;">
453
      [% L.hidden_tag('partial_transfer_customer_id') %]
454
      [% L.ajax_submit_tag('controller.pl?action=ShopOrder/transfer', "#create_partial_order", LxERP.t8('Create partial order')) %]
455
    </div>
456
  </form>
448 457
</div>
449 458

  
450 459

  
......
454 463
    var cv_id = $("input[type=radio][id="+ this.id + "]").val();
455 464
    $('#shop_update_customer_'+ cv_id).css("display", 'block');
456 465
    $('#transfer').css("display", 'block');
466
    $('#partial_transfer').css("display", 'block');
467
    $('#partial_transfer_customer_id').val(cv_id);
457 468
  });
458 469
</script>
templates/webpages/shop_order/show.html
175 175
  </table>
176 176
  <hr>
177 177
  <div style="height: 250px; overflow:auto; margin:15px;">
178
    <table width="99%">
179
      <tr class="listheading">
180
        <th>[% 'Position'          | $T8 %]</th>
181
        <th>[% 'Partnumber'        | $T8 %]</th>
182
        <th>[% 'Partdescriptipion' | $T8 %]</th>
183
        <th>[% 'Qty'               | $T8 %]</th>
184
        <th>[% 'Price'             | $T8 %]</th>
185
        <th>[% 'Discount'          | $T8 %]</th>
186
        <th>[% 'Promotion Code'    | $T8 %]</th>
187
        <th>[% 'Extended'          | $T8 %]</th>
188
      </tr>
189
      <tr class="listrow">
190
      [% FOREACH pos = IMPORT.shop_order_items %]
191
        <td>[% loop.count                                      %]</td>
192
        <td>[% HTML.escape(pos.partnumber)                     %]</td>
193
        <td>[% HTML.escape(pos.description)                    %]</td>
194
        <td>[% pos.quantity_as_number                          %]</td>
195
        <td>[% pos.price_as_number                             %]</td>
196
        <td>[% pos.discount_as_number * 100                    %] %</td>
197
        <td>[% pos.discount_code                               %]</td>
198
        <td>[% LxERP.format_amount(pos.price * pos.quantity,2) %]</td>
199
      </tr>
200
      [% END %]
201
    </table>
178
    <form method="post" action="controller.pl" id="create_partial_order">
179
    [% L.hidden_tag('import_id', IMPORT.id) %]
180
      <table width="99%">
181
        <tr class="listheading">
182
          <th>[% 'Assign'            | $T8 %]</th>
183
          <th>[% 'Position'          | $T8 %]</th>
184
          <th>[% 'Partnumber'        | $T8 %]</th>
185
          <th>[% 'Partdescriptipion' | $T8 %]</th>
186
          <th>[% 'Qty'               | $T8 %]</th>
187
          <th>[% 'Price'             | $T8 %]</th>
188
          <th>[% 'Discount'          | $T8 %]</th>
189
          <th>[% 'Promotion Code'    | $T8 %]</th>
190
          <th>[% 'Extended'          | $T8 %]</th>
191
        </tr>
192
        <tr class="listrow">
193
        [% FOREACH pos = IMPORT.shop_order_items %]
194
          <td>[% L.checkbox_tag("pos_ids." _ pos.id _ "[]", value=1, checked=1) %]</td>
195
          <td>[% loop.count                                      %]</td>
196
          <td>[% HTML.escape(pos.partnumber)                     %]</td>
197
          <td>[% HTML.escape(pos.description)                    %]</td>
198
          <td>[% pos.quantity_as_number                          %]</td>
199
          <td>[% pos.price_as_number                             %]</td>
200
          <td>[% pos.discount_as_number * 100                    %] %</td>
201
          <td>[% pos.discount_code                               %]</td>
202
          <td>[% LxERP.format_amount(pos.price * pos.quantity,2) %]</td>
203
        </tr>
204
        [% END %]
205
      </table>
206
      <div id="partial_transfer" style="float:left; display:none;">
207
        [% L.hidden_tag('partial_transfer_customer_id') %]
208
        [% L.ajax_submit_tag('controller.pl?action=ShopOrder/transfer', "#create_partial_order", LxERP.t8('Create partial order')) %]
209
      </div>
210
    </form>
202 211
  </div>
203 212
  <hr>
204 213
<script type="text/javascript">
......
207 216
      var cv_id = $("input[type=radio][id="+ this.id + "]").val();
208 217
      $('#shop_update_customer_'+ cv_id).css("display", 'block');
209 218
      $('#transfer').css("display", 'block');
219
      $('#partial_transfer').css("display", 'block');
220
      $('#partial_transfer_customer_id').val(cv_id);
210 221
});
211 222
</script>

Auch abrufbar als: Unified diff