Revision 69597c45
Von Jan Büren vor mehr als 1 Jahr hinzugefügt
| SL/Controller/ShopOrder.pm | ||
|---|---|---|
| sub action_transfer {
 | ||
|   my ( $self ) = @_;
 | ||
|  | ||
|   $::form->{customer} ||= $::form->{partial_transfer_customer_id};
 | ||
|  | ||
|   my $customer = SL::DB::Manager::Customer->find_by(id => $::form->{customer});
 | ||
|   die "Can't find customer" unless $customer;
 | ||
|   die "Can't find customer" unless ref $customer eq 'SL::DB::Customer';
 | ||
|  | ||
|   my $employee = SL::DB::Manager::Employee->current;
 | ||
|   die "Can't find employee" unless $employee;
 | ||
|  | ||
|   die "Can't load shop_order form form->import_id" unless $self->shop_order;
 | ||
|   my $order = $self->shop_order->convert_to_sales_order(customer => $customer, employee => $employee);
 | ||
|   my $order = $self->shop_order->convert_to_sales_order(customer => $customer, employee => $employee,
 | ||
|                                                         pos_ids  => $::form->{pos_ids}               );
 | ||
|  | ||
|   if ($order->{error}){
 | ||
|     flash_later('error',@{$order->{errors}});
 | ||
| ... | ... | |
| =item C<action_transfer>
 | ||
|  | ||
| Transfers one shoporder to an order.
 | ||
| If the optional  $::form->{pos_ids} exists, they will be added
 | ||
| as a param for the convert_to_sales_order method
 | ||
|  | ||
| =item C<action_apply_customer>
 | ||
|  | ||
| SL/DB/ShopOrder.pm | ||
|---|---|---|
|   my $customer  = delete $params{customer};
 | ||
|   my $employee  = delete $params{employee};
 | ||
|   my $transdate = delete $params{transdate} // DateTime->today_local;
 | ||
|  | ||
|   croak "param customer is missing" unless ref($customer) eq 'SL::DB::Customer';
 | ||
|   croak "param employee is missing" unless ref($employee) eq 'SL::DB::Employee';
 | ||
|  | ||
|   # check if caller wants optional partial transfer and create partial soi array
 | ||
|   my $partial_transfer;
 | ||
|   my %pos_ids;
 | ||
|   if ($params{pos_ids}) {
 | ||
|     $partial_transfer = 1;
 | ||
|     %pos_ids          =  %{ delete $params{pos_ids} };
 | ||
|     # TODO check if pos_ids is a valid hash
 | ||
|   }
 | ||
|   my @soi = $partial_transfer
 | ||
|           ? grep { $pos_ids{$_->id} } @{ $self->shop_order_items }
 | ||
|           : @{ $self->shop_order_items };
 | ||
|  | ||
|   require SL::DB::Order;
 | ||
|   require SL::DB::OrderItem;
 | ||
|   require SL::DB::Part;
 | ||
| ... | ... | |
|         discount            => $_->discount,
 | ||
|       );
 | ||
|     }
 | ||
|   }@{ $self->shop_order_items };
 | ||
|  | ||
|   } @soi;
 | ||
|   if(!scalar(@error_report)){
 | ||
|  | ||
|     my $shipto_id;
 | ||
| locale/de/all | ||
|---|---|---|
|   'Create new version'          => 'Neue Version anlegen',
 | ||
|   'Create one from the context menu by right-clicking on this text.' => 'Erstellen Sie einen aus dem Kontextmenü, indem Sie auf diesen Text rechtsklicken.',
 | ||
|   'Create order'                => 'Auftrag erstellen',
 | ||
|   'Create partial order'        => 'Teil-Auftrag erstellen',
 | ||
|   'Create sales invoices with Factur-X/ZUGFeRD data' => 'Verkaufsrechnungen mit Factur-X-/ZUGFeRD-Daten erzeugen',
 | ||
|   'Create sales invoices with Swiss QR-bill' => 'Verkaufsrechnungen mit Schweizer QR-Rechnung erzeugen',
 | ||
|   'Create tables'               => 'Tabellen anlegen',
 | ||
| templates/design40_webpages/shop_order/show.html | ||
|---|---|---|
| </div>
 | ||
|  | ||
| <div class="wrapper" id="wrapper-3">
 | ||
|   <table class="tbl-list" style="width:100%">
 | ||
|     <thead>
 | ||
|       <tr>
 | ||
|         <th>[% 'Position'          | $T8 %]</th>
 | ||
|         <th>[% 'Partnumber'        | $T8 %]</th>
 | ||
|         <th>[% 'Partdescriptipion' | $T8 %]</th>
 | ||
|         <th>[% 'Qty'               | $T8 %]</th>
 | ||
|         <th>[% 'Price'             | $T8 %]</th>
 | ||
|         <th>[% 'Discount'          | $T8 %]</th>
 | ||
|         <th>[% 'Promotion Code'    | $T8 %]</th>
 | ||
|         <th>[% 'Extended'          | $T8 %]</th>
 | ||
|       </tr>
 | ||
|     </thead>
 | ||
|     <tbody>
 | ||
|       [% FOREACH pos = IMPORT.shop_order_items %]
 | ||
|         <tr>
 | ||
|           <td>[% loop.count                                      %]</td>
 | ||
|           <td>[% HTML.escape(pos.partnumber)                     %]</td>
 | ||
|           <td>[% HTML.escape(pos.description)                    %]</td>
 | ||
|           <td>[% pos.quantity_as_number                          %]</td>
 | ||
|           <td>[% pos.price_as_number                             %]</td>
 | ||
|           <td>[% pos.discount_as_number * 100                  %] %</td>
 | ||
|           <td>[% pos.discount_code                               %]</td>
 | ||
|           <td>[% LxERP.format_amount(pos.price * pos.quantity,2) %]</td>
 | ||
|         </tr>
 | ||
|       [% END %]
 | ||
|     </tbody>
 | ||
|   </table>
 | ||
|   <form method="post" action="controller.pl" id="create_partial_order">
 | ||
|   [% L.hidden_tag('import_id', IMPORT.id) %]
 | ||
|     <table class="tbl-list" style="width:100%">
 | ||
|       <thead>
 | ||
|         <tr>
 | ||
|           <th>[% 'Assign'            | $T8 %]</th>
 | ||
|           <th>[% 'Position'          | $T8 %]</th>
 | ||
|           <th>[% 'Partnumber'        | $T8 %]</th>
 | ||
|           <th>[% 'Partdescriptipion' | $T8 %]</th>
 | ||
|           <th>[% 'Qty'               | $T8 %]</th>
 | ||
|           <th>[% 'Price'             | $T8 %]</th>
 | ||
|           <th>[% 'Discount'          | $T8 %]</th>
 | ||
|           <th>[% 'Promotion Code'    | $T8 %]</th>
 | ||
|           <th>[% 'Extended'          | $T8 %]</th>
 | ||
|         </tr>
 | ||
|       </thead>
 | ||
|       <tbody>
 | ||
|         [% FOREACH pos = IMPORT.shop_order_items %]
 | ||
|           <tr>
 | ||
|             <td>[% L.checkbox_tag("pos_ids." _ pos.id _ "[]", value=1, checked=1) %]</td>
 | ||
|             <td>[% loop.count                                      %]</td>
 | ||
|             <td>[% HTML.escape(pos.partnumber)                     %]</td>
 | ||
|             <td>[% HTML.escape(pos.description)                    %]</td>
 | ||
|             <td>[% pos.quantity_as_number                          %]</td>
 | ||
|             <td>[% pos.price_as_number                             %]</td>
 | ||
|             <td>[% pos.discount_as_number * 100                  %] %</td>
 | ||
|             <td>[% pos.discount_code                               %]</td>
 | ||
|             <td>[% LxERP.format_amount(pos.price * pos.quantity,2) %]</td>
 | ||
|           </tr>
 | ||
|         [% END %]
 | ||
|       </tbody>
 | ||
|     </table>
 | ||
|     <div id="partial_transfer" style="float:left; display:none;">
 | ||
|       [% L.hidden_tag('partial_transfer_customer_id') %]
 | ||
|       [% L.ajax_submit_tag('controller.pl?action=ShopOrder/transfer', "#create_partial_order", LxERP.t8('Create partial order')) %]
 | ||
|     </div>
 | ||
|   </form>
 | ||
| </div>
 | ||
|  | ||
|  | ||
| ... | ... | |
|     var cv_id = $("input[type=radio][id="+ this.id + "]").val();
 | ||
|     $('#shop_update_customer_'+ cv_id).css("display", 'block');
 | ||
|     $('#transfer').css("display", 'block');
 | ||
|     $('#partial_transfer').css("display", 'block');
 | ||
|     $('#partial_transfer_customer_id').val(cv_id);
 | ||
|   });
 | ||
| </script>
 | ||
| templates/webpages/shop_order/show.html | ||
|---|---|---|
|   </table>
 | ||
|   <hr>
 | ||
|   <div style="height: 250px; overflow:auto; margin:15px;">
 | ||
|     <table width="99%">
 | ||
|       <tr class="listheading">
 | ||
|         <th>[% 'Position'          | $T8 %]</th>
 | ||
|         <th>[% 'Partnumber'        | $T8 %]</th>
 | ||
|         <th>[% 'Partdescriptipion' | $T8 %]</th>
 | ||
|         <th>[% 'Qty'               | $T8 %]</th>
 | ||
|         <th>[% 'Price'             | $T8 %]</th>
 | ||
|         <th>[% 'Discount'          | $T8 %]</th>
 | ||
|         <th>[% 'Promotion Code'    | $T8 %]</th>
 | ||
|         <th>[% 'Extended'          | $T8 %]</th>
 | ||
|       </tr>
 | ||
|       <tr class="listrow">
 | ||
|       [% FOREACH pos = IMPORT.shop_order_items %]
 | ||
|         <td>[% loop.count                                      %]</td>
 | ||
|         <td>[% HTML.escape(pos.partnumber)                     %]</td>
 | ||
|         <td>[% HTML.escape(pos.description)                    %]</td>
 | ||
|         <td>[% pos.quantity_as_number                          %]</td>
 | ||
|         <td>[% pos.price_as_number                             %]</td>
 | ||
|         <td>[% pos.discount_as_number * 100                    %] %</td>
 | ||
|         <td>[% pos.discount_code                               %]</td>
 | ||
|         <td>[% LxERP.format_amount(pos.price * pos.quantity,2) %]</td>
 | ||
|       </tr>
 | ||
|       [% END %]
 | ||
|     </table>
 | ||
|     <form method="post" action="controller.pl" id="create_partial_order">
 | ||
|     [% L.hidden_tag('import_id', IMPORT.id) %]
 | ||
|       <table width="99%">
 | ||
|         <tr class="listheading">
 | ||
|           <th>[% 'Assign'            | $T8 %]</th>
 | ||
|           <th>[% 'Position'          | $T8 %]</th>
 | ||
|           <th>[% 'Partnumber'        | $T8 %]</th>
 | ||
|           <th>[% 'Partdescriptipion' | $T8 %]</th>
 | ||
|           <th>[% 'Qty'               | $T8 %]</th>
 | ||
|           <th>[% 'Price'             | $T8 %]</th>
 | ||
|           <th>[% 'Discount'          | $T8 %]</th>
 | ||
|           <th>[% 'Promotion Code'    | $T8 %]</th>
 | ||
|           <th>[% 'Extended'          | $T8 %]</th>
 | ||
|         </tr>
 | ||
|         <tr class="listrow">
 | ||
|         [% FOREACH pos = IMPORT.shop_order_items %]
 | ||
|           <td>[% L.checkbox_tag("pos_ids." _ pos.id _ "[]", value=1, checked=1) %]</td>
 | ||
|           <td>[% loop.count                                      %]</td>
 | ||
|           <td>[% HTML.escape(pos.partnumber)                     %]</td>
 | ||
|           <td>[% HTML.escape(pos.description)                    %]</td>
 | ||
|           <td>[% pos.quantity_as_number                          %]</td>
 | ||
|           <td>[% pos.price_as_number                             %]</td>
 | ||
|           <td>[% pos.discount_as_number * 100                    %] %</td>
 | ||
|           <td>[% pos.discount_code                               %]</td>
 | ||
|           <td>[% LxERP.format_amount(pos.price * pos.quantity,2) %]</td>
 | ||
|         </tr>
 | ||
|         [% END %]
 | ||
|       </table>
 | ||
|       <div id="partial_transfer" style="float:left; display:none;">
 | ||
|         [% L.hidden_tag('partial_transfer_customer_id') %]
 | ||
|         [% L.ajax_submit_tag('controller.pl?action=ShopOrder/transfer', "#create_partial_order", LxERP.t8('Create partial order')) %]
 | ||
|       </div>
 | ||
|     </form>
 | ||
|   </div>
 | ||
|   <hr>
 | ||
| <script type="text/javascript">
 | ||
| ... | ... | |
|       var cv_id = $("input[type=radio][id="+ this.id + "]").val();
 | ||
|       $('#shop_update_customer_'+ cv_id).css("display", 'block');
 | ||
|       $('#transfer').css("display", 'block');
 | ||
|       $('#partial_transfer').css("display", 'block');
 | ||
|       $('#partial_transfer_customer_id').val(cv_id);
 | ||
| });
 | ||
| </script>
 | ||
Auch abrufbar als: Unified diff
ShopOrder nur teilweise Positionen für den Auftrag übernehmen