commit 73b9848fdcfa5a62bfd6ad4f383aeacc6f371772
Author: Geoffrey Richardson <information@kivitendo-premium.de>
Date:   Thu Jul 28 23:02:41 2016 +0200

    $form->{item} nach $form->{part_type} umbenannt
    
    Damit das Feld automatisch dem Datenbanknamen entspricht.

diff --git a/SL/IC.pm b/SL/IC.pm
index 942831bfa..84e913eb3 100644
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -78,10 +78,8 @@ sub get_part {
   $form->{lastmtime} = $form->{mtime};
   $form->{onhand} *= 1;
 
-  die "part needs a part_type" unless $form->{part_type}; # TODO from part_type enum conversion
   # part or service item
-  $form->{item} = $form->{part_type};
-  if ($form->{item} eq 'assembly') {
+  if ($form->{part_type} eq 'assembly') {
 
     # retrieve assembly items
     $query =
@@ -262,7 +260,7 @@ sub _save {
   my $priceupdate = ', priceupdate = current_date';
 
   if ($form->{id}) {
-    my $trans_number = SL::TransNumber->new(type => $form->{item}, dbh => $dbh, number => $form->{partnumber}, id => $form->{id});
+    my $trans_number = SL::TransNumber->new(type => $form->{part_type}, dbh => $dbh, number => $form->{partnumber}, id => $form->{id});
     if (!$trans_number->is_unique) {
       $::lxdebug->leave_sub;
       return 3;
@@ -275,7 +273,7 @@ sub _save {
     # delete makemodel records
     do_query($form, $dbh, qq|DELETE FROM makemodel WHERE parts_id = ?|, conv_i($form->{id}));
 
-    if ($form->{item} eq 'assembly') {
+    if ($form->{part_type} eq 'assembly') {
       # delete assembly records
       do_query($form, $dbh, qq|DELETE FROM assembly WHERE id = ?|, conv_i($form->{id}));
     }
@@ -289,7 +287,7 @@ sub _save {
     $priceupdate        = '' if (all { $previous_values->{$_} == $form->{$_} } qw(sellprice lastcost listprice));
 
   } else {
-    my $trans_number = SL::TransNumber->new(type => $form->{item}, dbh => $dbh, number => $form->{partnumber}, save => 1);
+    my $trans_number = SL::TransNumber->new(type => $form->{part_type}, dbh => $dbh, number => $form->{partnumber}, save => 1);
 
     if ($form->{partnumber} && !$trans_number->is_unique) {
       $::lxdebug->leave_sub;
@@ -299,7 +297,7 @@ sub _save {
     $form->{partnumber} ||= $trans_number->create_unique;
 
     ($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('id')|);
-    do_query($form, $dbh, qq|INSERT INTO parts (id, partnumber, unit, part_type) VALUES (?, ?, ?, ?)|, $form->{id}, $form->{partnumber}, $form->{unit}, $form->{item});
+    do_query($form, $dbh, qq|INSERT INTO parts (id, partnumber, unit, part_type) VALUES (?, ?, ?, ?)|, $form->{id}, $form->{partnumber}, $form->{unit}, $form->{part_type});
 
     $form->{orphaned} = 1;
   }
@@ -310,7 +308,7 @@ sub _save {
   }
 
   my ($subq_inventory, $subq_expense, $subq_income);
-  if ($form->{"item"} eq "part") {
+  if ($form->{part_type} eq "part") {
     $subq_inventory =
       qq|(SELECT bg.inventory_accno_id
           FROM buchungsgruppen bg
@@ -319,7 +317,7 @@ sub _save {
     $subq_inventory = "NULL";
   }
 
-  if ($form->{"item"} ne "assembly") {
+  if ($form->{part_type} ne "assembly") {
     $subq_expense =
       qq|(SELECT tc.expense_accno_id
           FROM taxzone_charts tc
@@ -391,7 +389,7 @@ sub _save {
              $form->{has_sernumber} ? 't' : 'f',
              $form->{not_discountable} ? 't' : 'f',
              $form->{microfiche},
-             $form->{item},
+             $form->{part_type},
              conv_i($partsgroup_id),
              conv_i($form->{price_factor_id}),
              conv_i($form->{id})
@@ -458,7 +456,7 @@ sub _save {
     }
 
   # add assembly records
-  if ($form->{item} eq 'assembly') {
+  if ($form->{part_type} eq 'assembly') {
     # check additional assembly row
     my $i = $form->{assembly_rows};
     # if last row is not empty add them
diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl
index 84fe35186..0405aa051 100644
--- a/bin/mozilla/ic.pl
+++ b/bin/mozilla/ic.pl
@@ -79,9 +79,9 @@ sub add {
 
   $auth->assert('part_service_assembly_edit');
 
-  my $title                = 'Add ' . ucfirst $form->{item};
+  my $title                = 'Add ' . ucfirst $form->{part_type};
   $form->{title}           = $locale->text($title);
-  $form->{callback}        = "$form->{script}?action=add&item=$form->{item}" unless $form->{callback};
+  $form->{callback}        = "$form->{script}?action=add&part_type=$form->{part_type}" unless $form->{callback};
   $form->{unit_changeable} = 1;
 
   IC->get_pricegroups(\%myconfig, \%$form);
@@ -743,7 +743,7 @@ sub edit {
 
   $form->{"original_partnumber"} = $form->{"partnumber"};
 
-  my $title      = 'Edit ' . ucfirst $form->{item};
+  my $title      = 'Edit ' . ucfirst $form->{part_type};
   $form->{title} = $locale->text($title);
 
   &link_part;
@@ -763,8 +763,8 @@ sub link_part {
   map({ $form->{selectcurrency} .= "<option>$_\n" } $::form->get_all_currencies());
 
   # parts and assemblies have the same links
-  my $item = $form->{item};
-  if ($form->{item} eq 'assembly') {
+  my $item = $form->{part_type};
+  if ($form->{part_type} eq 'assembly') {
     $item = 'part';
   }
 
@@ -801,7 +801,7 @@ sub link_part {
   }
   chop $form->{taxaccounts};
 
-  if (($form->{item} eq "part") || ($form->{item} eq "assembly")) {
+  if (($form->{part_type} eq "part") || ($form->{part_type} eq "assembly")) {
     $form->{selectIC_income}  = $form->{selectIC_sale};
     $form->{selectIC_expense} = $form->{selectIC_cogs};
     $form->{IC_income}        = $form->{IC_sale};
@@ -820,7 +820,7 @@ sub link_part {
     map { $form->{selectpartsgroup} .= qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n| } @{ $form->{all_partsgroup} };
   }
 
-  if ($form->{item} eq 'assembly') {
+  if ($form->{part_type} eq 'assembly') {
 
     foreach my $i (1 .. $form->{assembly_rows}) {
       if ($form->{"partsgroup_id_$i"}) {
@@ -851,7 +851,7 @@ sub form_header {
   $form->{description_area} = ($form->{rows} = $form->numtextrows($form->{description}, 40)) > 1;
   $form->{notes_rows}       =  max 4, $form->numtextrows($form->{notes}, 40), $form->numtextrows($form->{formel}, 40);
 
-  map { $form->{"is_$_"}  = ($form->{item} eq $_) } qw(part service assembly);
+  map { $form->{"is_$_"}  = ($form->{part_type} eq $_) } qw(part service assembly);
   map { $form->{$_}       =~ s/"/&quot;/g;        } qw(unit);
 
   $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS',
@@ -879,7 +879,7 @@ sub form_header {
   IC->retrieve_buchungsgruppen(\%myconfig, $form);
   @{ $form->{BUCHUNGSGRUPPEN} } = grep { $_->{id} eq $form->{buchungsgruppen_id} || ($form->{id} && $form->{orphaned}) || !$form->{id} } @{ $form->{BUCHUNGSGRUPPEN} };
 
-  if (($form->{partnumber} ne '') && !SL::TransNumber->new(number => $form->{partnumber}, type => $form->{item}, id => $form->{id})->is_unique) {
+  if (($form->{partnumber} ne '') && !SL::TransNumber->new(number => $form->{partnumber}, type => $form->{part_type}, id => $form->{id})->is_unique) {
     flash('info', $::locale->text('This partnumber is not unique. You should change it.'));
   }
 
@@ -1060,23 +1060,23 @@ sub update {
   # parse pricegroups. and no, don't rely on check_form for this...
   map { $form->{"price_$_"} = $form->parse_amount(\%myconfig, $form->{"price_$_"}) } 1 .. $form->{price_rows};
 
-  unless ($form->{item} eq 'assembly') {
+  unless ($form->{part_type} eq 'assembly') {
     # for assemblies check_form will parse sellprice and listprice, but not for parts or services
     $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) for qw(sellprice listprice ve gv);
   };
 
-  if ($form->{item} eq 'part') {
+  if ($form->{part_type} eq 'part') {
     $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) for qw(weight rop);
   }
 
   # same for makemodel lastcosts
   # but parse_amount not necessary for assembly component lastcosts
-  unless ($form->{item} eq "assembly") {
+  unless ($form->{part_type} eq "assembly") {
     map { $form->{"lastcost_$_"} = $form->parse_amount(\%myconfig, $form->{"lastcost_$_"}) } 1 .. $form->{"makemodel_rows"};
     $form->{lastcost} = $form->parse_amount(\%myconfig, $form->{lastcost});
   }
 
-  if ($form->{item} eq "assembly") {
+  if ($form->{part_type} eq "assembly") {
     my $i = $form->{assembly_rows};
 
     # if last row is empty check the form otherwise retrieve item
@@ -1124,7 +1124,7 @@ sub update {
       }
     }
 
-  } elsif (($form->{item} eq 'part') || ($form->{item} eq 'service')) {
+  } elsif (($form->{part_type} eq 'part') || ($form->{part_type} eq 'service')) {
     &check_form;
   }
 
@@ -1139,13 +1139,13 @@ sub save {
   my ($parts_id, %newform, $amount, $callback);
 
   # check if there is a part number - commented out, cause there is an automatic allocation of numbers
-  # $form->isblank("partnumber", $locale->text(ucfirst $form->{item}." Part Number missing!"));
+  # $form->isblank("partnumber", $locale->text(ucfirst $form->{part_type}." Part Number missing!"));
 
   # check if there is a description
   $form->isblank("description", $locale->text("Part Description missing!"));
 
-  $form->error($locale->text("Inventory quantity must be zero before you can set this $form->{item} obsolete!"))
-    if $form->{obsolete} && $form->{onhand} * 1 && $form->{item} ne 'service';
+  $form->error($locale->text("Inventory quantity must be zero before you can set this $form->{part_type} obsolete!"))
+    if $form->{obsolete} && $form->{onhand} * 1 && $form->{part_type} ne 'service';
 
   if (!$form->{buchungsgruppen_id}) {
     $form->error($locale->text("Parts must have an entry type.") . " " .
@@ -1192,7 +1192,7 @@ sub save {
     $::auth->restore_form_from_session($newform{previousform}, form => $form);
     $form->{taxaccounts} = $newform{taxaccount2};
 
-    if ($form->{item} eq 'assembly') {
+    if ($form->{part_type} eq 'assembly') {
 
       # undo number formatting
       map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
@@ -1387,8 +1387,8 @@ sub display_form {
 
   form_header();
   price_row($::form->{price_rows});
-  makemodel_row(++$::form->{makemodel_rows}) if $::form->{item} =~ /^(part|service)$/;
-  assembly_row(++$::form->{assembly_rows})   if $::form->{item} eq 'assembly';
+  makemodel_row(++$::form->{makemodel_rows}) if $::form->{part_type} =~ /^(part|service)$/;
+  assembly_row(++$::form->{assembly_rows})   if $::form->{part_type} eq 'assembly';
 
   form_footer();
 
diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl
index 3a77b09a0..29ddae380 100644
--- a/bin/mozilla/io.pl
+++ b/bin/mozilla/io.pl
@@ -672,8 +672,8 @@ sub item_selected {
     map {
       $form->{"${_}_$i"} =
           $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
-    } qw(sellprice lastcost qty) if $form->{item} ne 'assembly';
-    $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100.0) if $form->{item} ne 'assembly';
+    } qw(sellprice lastcost qty) if $form->{part_type} ne 'assembly';
+    $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100.0) if $form->{part_type} ne 'assembly';
 
     delete $form->{nextsub};
 
@@ -727,7 +727,7 @@ sub check_form {
   my $count = 0;
 
   # remove any makes or model rows
-  if ($form->{item} eq 'assembly') {
+  if ($form->{part_type} eq 'assembly') {
 
     # fuer assemblies auskommentiert. seiteneffekte? ;-) wird die woanders benoetigt?
     #$form->{sellprice} = 0;
@@ -760,7 +760,7 @@ sub check_form {
     $form->redo_rows(\@flds, \@a, $count, $form->{assembly_rows});
     $form->{assembly_rows} = $count;
 
-  } elsif ($form->{item} !~ m{^(?:part|service)$}) {
+  } elsif ($form->{part_type} !~ m{^(?:part|service)$}) {
     remove_emptied_rows(1);
 
     $form->{creditremaining} -= &invoicetotal;
diff --git a/menus/user/00-erp.yaml b/menus/user/00-erp.yaml
index 43f9e776e..1900d6267 100644
--- a/menus/user/00-erp.yaml
+++ b/menus/user/00-erp.yaml
@@ -54,7 +54,7 @@
   module: ic.pl
   params:
     action: add
-    item: part
+    part_type: part
 - parent: master_data
   id: master_data_add_service
   name: Add Service
@@ -64,7 +64,7 @@
   module: ic.pl
   params:
     action: add
-    item: service
+    part_type: service
 - parent: master_data
   id: master_data_add_assembly
   name: Add Assembly
@@ -74,7 +74,7 @@
   module: ic.pl
   params:
     action: add
-    item: assembly
+    part_type: assembly
 - parent: master_data
   id: master_data_add_project
   name: Add Project
diff --git a/templates/webpages/generic/new_item.html b/templates/webpages/generic/new_item.html
index d6219e689..ef7799b52 100644
--- a/templates/webpages/generic/new_item.html
+++ b/templates/webpages/generic/new_item.html
@@ -9,8 +9,8 @@
 
       <p>
 
-      <input class="radio" type="radio" name="item" value="part" checked>&nbsp;[% 'Part' | $T8 %]<br>
-      <input class="radio" type="radio" name="item" value="service">&nbsp;[% 'Service' | $T8 %]
+      <input class="radio" type="radio" name="part_type" value="part" checked>&nbsp;[% 'Part' | $T8 %]<br>
+      <input class="radio" type="radio" name="part_type" value="service">&nbsp;[% 'Service' | $T8 %]
       <p>
 
       [%- FOREACH var = HIDDENS %]
diff --git a/templates/webpages/ic/form_header.html b/templates/webpages/ic/form_header.html
index cde2642c3..ebd0b5bd2 100644
--- a/templates/webpages/ic/form_header.html
+++ b/templates/webpages/ic/form_header.html
@@ -9,7 +9,7 @@
  <form method="post" name="ic" action="[% script %]">
 
   <input name="id" type="hidden" value="[% HTML.escape(id) %]">
-  <input name="item" type="hidden" value="[% HTML.escape(item) %]">
+  <input name="part_type" type="hidden" value="[% HTML.escape(part_type) %]">
   <input name="title" type="hidden" value="[% HTML.escape(title) %]">
   <input name="makemodel" type="hidden" value="[% HTML.escape(makemodel) %]">
   <input name="onhand" type="hidden" value="[% HTML.escape(onhand) %]">
