Auftrags-Controller: Pos.-Zeile ohne Part-Picker, aber mit Nummer u. Beschreibung.
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 17 Aug 2015 10:15:50 +0000 (12:15 +0200)
committerG. Richardson <information@kivitendo-premium.de>
Mon, 16 Nov 2015 15:15:56 +0000 (16:15 +0100)
SL/Controller/Order.pm
templates/webpages/order/tabs/_item_input.html
templates/webpages/order/tabs/_row.html
templates/webpages/order/tabs/basic_data.html

index 6be5b5d..d125968 100644 (file)
@@ -153,57 +153,16 @@ sub action_add_item {
     ->append('#row_table_id tbody', $row_as_html)
     ->val('#add_item_parts_id', '')
     ->val('#add_item_parts_id_name', '')
+    ->val('#add_item_description', '')
     ->val('#add_item_qty_as_number', '')
     ->val('#add_item_sellprice_as_number', '')
     ->val('#add_item_discount_as_percent', '')
-    ->focus('#add_item_parts_id_name')
-    ->off('[id^="order_orderitems"][id$="parts_id"]', 'change', 'set_item_values')
-    ->on('[id^="order_orderitems"][id$="parts_id"]', 'change', 'set_item_values');
+    ->focus('#add_item_parts_id_name');
 
   $self->_js_redisplay_amounts_and_taxes;
   $self->js->render($self);
 }
 
-sub action_set_item_values {
-  my ($self) = @_;
-
-  my $is_new  = $::form->{item_id} =~ m{^new_};
-  my $item_id = $::form->{item_id};
-
-  my $item      = first {$_->id   eq $::form->{item_id}} @{$self->order->items};
-  my $form_attr = first {$_->{id} eq $::form->{item_id}} @{ $::form->{order}->{orderitems} };
-
-  delete $form_attr->{id};
-
-  my $part = SL::DB::Part->new(id => $form_attr->{parts_id})->load;
-
-  my $cv_class    = "SL::DB::" . ucfirst($self->cv);
-  my $cv_discount = $::form->{cv_id}? $cv_class->new(id => $::form->{$self->cv . '_id'})->load->discount :0.0;
-
-
-  my %new_attr;
-  $new_attr{sellprice} = $part->sellprice  if ! $form_attr->{sellprice_as_number};
-  $new_attr{discount}  = $cv_discount      if ! $form_attr->{discount_as_percent};
-  $new_attr{unit}      = $part->unit       if ! $form_attr->{unit};
-  $new_attr{qty}       = 1.0               if ! $form_attr->{qty_as_number};
-
-  $item->assign_attributes(%new_attr);
-
-
-  $self->_recalc();
-
-  $self->js
-    ->val( '#' . $::form->{qty_dom_id},       $item->qty_as_number)
-    ->val( '#' . $::form->{unit_dom_id},      $item->unit)
-    ->val( '#' . $::form->{sellprice_dom_id}, $item->sellprice_as_number)
-    ->val( '#' . $::form->{discount_dom_id},  $item->discount_as_percent)
-    ->run('display_linetotal', $::form->{item_id}, $::form->format_amount(\%::myconfig, $item->{linetotal}, -2));
-
-  $self->_js_redisplay_amounts_and_taxes;
-  $self->js->render($self);
-}
-
-
 sub action_recalc_amounts_and_taxes {
   my ($self) = @_;
 
index e3f4db1..f59c226 100644 (file)
@@ -5,6 +5,7 @@
     <thead>
       <tr class="listheading">
         <th class="listheading" nowrap >[%- 'Part'         | $T8 %] </th>
+        <th class="listheading" nowrap >[%- 'Description'  | $T8 %] </th>
         <th class="listheading" nowrap width="5" >[%- 'Qty'          | $T8 %] </th>
         <th class="listheading" nowrap width="15">[%- 'Price'        | $T8 %] </th>
         <th class="listheading" nowrap width="5" >[%- 'Discount'     | $T8 %] </th>
@@ -14,6 +15,7 @@
     <tbody>
       <tr valign="top" class="listrow">
         <td>[% L.part_picker('add_item.parts_id', '', fat_set_item=1, style='width: 300px', class="add_item_input") %]</td>
+        <td>[% L.input_tag('add_item.description', '', class="add_item_input") %]</td>
         <td>[% L.input_tag('add_item.qty_as_number', '', size = 5, style='text-align:right', class="add_item_input") %]</td>
         <td>[% L.input_tag('add_item.sellprice_as_number', '', size = 10, style='text-align:right', class="add_item_input") %]</td>
         <td>[% L.input_tag('add_item.discount_as_percent', '', size = 5, style='text-align:right', class="add_item_input") %]</td>
index 2201666..0cd3bde 100644 (file)
@@ -6,6 +6,7 @@
 <tr valign="top" class="listrow">
   <td style='display:none'>
     [% L.hidden_tag("order.orderitems[+].id", ITEM.id, id='item_' _ ITEM.id, ) %]
+    [% L.hidden_tag("order.orderitems[].parts_id", ITEM.parts_id) %]
   </td>
   <td align="center" class="dragdrop">
     <img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]">
                      LxERP.t8("X"),
                      confirm=LxERP.t8("Are you sure?")) %]
   <td>
-    [% L.part_picker("order.orderitems[].parts_id",
-                     ITEM.part,
-                     style='width: 300px') %]
+    [% HTML.escape(ITEM.part.partnumber) %]
+  </td>
+  <td>
+    [% L.input_tag("order.orderitems[].description",
+                   ITEM.description,
+                   style='width: 300px') %]
   </td>
   <td>
     [%- L.input_tag("order.orderitems[].qty_as_number",
index a46f789..3bc6455 100644 (file)
               <th class="listheading" style='display:none'></th>
               <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
               <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th>
-              <th class="listheading" nowrap >[%- 'Part'         | $T8 %] </th>
+              <th class="listheading" nowrap width="15">[%- 'Partnumber'  | $T8 %] </th>
+              <th class="listheading" nowrap           >[%- 'Description'  | $T8 %] </th>
               <th class="listheading" nowrap width="5" >[%- 'Qty'          | $T8 %] </th>
               <th class="listheading" nowrap width="5" >[%- 'Price Factor' | $T8 %] </th>
               <th class="listheading" nowrap width="5" >[%- 'Unit'         | $T8 %] </th>
@@ -193,29 +194,6 @@ function delete_order_item_row(clicked) {
   recalc_amounts_and_taxes()
 }
 
-function set_item_values(event) {
-  var cv_id = $('#order_[%- cv_id %]').val();
-  var parts_id = $(event.target).val();
-  var row = $(event.target).parents("tr").first();
-
-  var item_id_dom = $(row).find('[name="order.orderitems[+].id"]');
-  var qty_dom = $(row).find('[id^="order_orderitems"][id$="qty_as_number"]');
-  var unit_dom = $(row).find('[id^="order_orderitems"][id$="unit"]');
-  var sellprice_dom = $(row).find('[id^="order_orderitems"][id$="sellprice_as_number"]');
-  var discount_dom = $(row).find('[id^="order_orderitems"][id$="discount_as_percent"]');
-
-  var data = $('#order_form').serialize();
-  data += '&action=Order/set_item_values';
-  data += '&type=' + $('#type').val();
-  data += '&item_id=' + item_id_dom.val();
-  data += '&qty_dom_id=' + qty_dom.attr("id");
-  data += '&unit_dom_id=' + unit_dom.attr("id");
-  data += '&sellprice_dom_id=' + sellprice_dom.attr("id");
-  data += '&discount_dom_id=' + discount_dom.attr("id");
-
-  $.post("controller.pl", data, kivi.eval_json_result);
-}
-
 function recalc_amounts_and_taxes() {
   var data = $('#order_form').serialize();
   data += '&action=Order/recalc_amounts_and_taxes';
@@ -231,8 +209,8 @@ function display_linetotal(item_id, amount) {
 
 $(function(){
   $('#order_[%- cv_id %]').change(reload_cv_dependend_selections);
-  $('[id^="order_orderitems"][id$="parts_id"]').change(set_item_values);
   $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) });
+  $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_description').val(o.description) });
   $('.add_item_input').keydown(function(event) {
     if(event.keyCode == 13) {
       event.preventDefault();