Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 73b9848f

Von Kivitendo Admin vor etwa 8 Jahren hinzugefügt

  • ID 73b9848fdcfa5a62bfd6ad4f383aeacc6f371772
  • Vorgänger fcde4c20
  • Nachfolger 05531e45

$form->{item} nach $form->{part_type} umbenannt

Damit das Feld automatisch dem Datenbanknamen entspricht.

Unterschiede anzeigen:

SL/IC.pm
78 78
  $form->{lastmtime} = $form->{mtime};
79 79
  $form->{onhand} *= 1;
80 80

  
81
  die "part needs a part_type" unless $form->{part_type}; # TODO from part_type enum conversion
82 81
  # part or service item
83
  $form->{item} = $form->{part_type};
84
  if ($form->{item} eq 'assembly') {
82
  if ($form->{part_type} eq 'assembly') {
85 83

  
86 84
    # retrieve assembly items
87 85
    $query =
......
262 260
  my $priceupdate = ', priceupdate = current_date';
263 261

  
264 262
  if ($form->{id}) {
265
    my $trans_number = SL::TransNumber->new(type => $form->{item}, dbh => $dbh, number => $form->{partnumber}, id => $form->{id});
263
    my $trans_number = SL::TransNumber->new(type => $form->{part_type}, dbh => $dbh, number => $form->{partnumber}, id => $form->{id});
266 264
    if (!$trans_number->is_unique) {
267 265
      $::lxdebug->leave_sub;
268 266
      return 3;
......
275 273
    # delete makemodel records
276 274
    do_query($form, $dbh, qq|DELETE FROM makemodel WHERE parts_id = ?|, conv_i($form->{id}));
277 275

  
278
    if ($form->{item} eq 'assembly') {
276
    if ($form->{part_type} eq 'assembly') {
279 277
      # delete assembly records
280 278
      do_query($form, $dbh, qq|DELETE FROM assembly WHERE id = ?|, conv_i($form->{id}));
281 279
    }
......
289 287
    $priceupdate        = '' if (all { $previous_values->{$_} == $form->{$_} } qw(sellprice lastcost listprice));
290 288

  
291 289
  } else {
292
    my $trans_number = SL::TransNumber->new(type => $form->{item}, dbh => $dbh, number => $form->{partnumber}, save => 1);
290
    my $trans_number = SL::TransNumber->new(type => $form->{part_type}, dbh => $dbh, number => $form->{partnumber}, save => 1);
293 291

  
294 292
    if ($form->{partnumber} && !$trans_number->is_unique) {
295 293
      $::lxdebug->leave_sub;
......
299 297
    $form->{partnumber} ||= $trans_number->create_unique;
300 298

  
301 299
    ($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('id')|);
302
    do_query($form, $dbh, qq|INSERT INTO parts (id, partnumber, unit, part_type) VALUES (?, ?, ?, ?)|, $form->{id}, $form->{partnumber}, $form->{unit}, $form->{item});
300
    do_query($form, $dbh, qq|INSERT INTO parts (id, partnumber, unit, part_type) VALUES (?, ?, ?, ?)|, $form->{id}, $form->{partnumber}, $form->{unit}, $form->{part_type});
303 301

  
304 302
    $form->{orphaned} = 1;
305 303
  }
......
310 308
  }
311 309

  
312 310
  my ($subq_inventory, $subq_expense, $subq_income);
313
  if ($form->{"item"} eq "part") {
311
  if ($form->{part_type} eq "part") {
314 312
    $subq_inventory =
315 313
      qq|(SELECT bg.inventory_accno_id
316 314
          FROM buchungsgruppen bg
......
319 317
    $subq_inventory = "NULL";
320 318
  }
321 319

  
322
  if ($form->{"item"} ne "assembly") {
320
  if ($form->{part_type} ne "assembly") {
323 321
    $subq_expense =
324 322
      qq|(SELECT tc.expense_accno_id
325 323
          FROM taxzone_charts tc
......
391 389
             $form->{has_sernumber} ? 't' : 'f',
392 390
             $form->{not_discountable} ? 't' : 'f',
393 391
             $form->{microfiche},
394
             $form->{item},
392
             $form->{part_type},
395 393
             conv_i($partsgroup_id),
396 394
             conv_i($form->{price_factor_id}),
397 395
             conv_i($form->{id})
......
458 456
    }
459 457

  
460 458
  # add assembly records
461
  if ($form->{item} eq 'assembly') {
459
  if ($form->{part_type} eq 'assembly') {
462 460
    # check additional assembly row
463 461
    my $i = $form->{assembly_rows};
464 462
    # if last row is not empty add them
bin/mozilla/ic.pl
79 79

  
80 80
  $auth->assert('part_service_assembly_edit');
81 81

  
82
  my $title                = 'Add ' . ucfirst $form->{item};
82
  my $title                = 'Add ' . ucfirst $form->{part_type};
83 83
  $form->{title}           = $locale->text($title);
84
  $form->{callback}        = "$form->{script}?action=add&item=$form->{item}" unless $form->{callback};
84
  $form->{callback}        = "$form->{script}?action=add&part_type=$form->{part_type}" unless $form->{callback};
85 85
  $form->{unit_changeable} = 1;
86 86

  
87 87
  IC->get_pricegroups(\%myconfig, \%$form);
......
743 743

  
744 744
  $form->{"original_partnumber"} = $form->{"partnumber"};
745 745

  
746
  my $title      = 'Edit ' . ucfirst $form->{item};
746
  my $title      = 'Edit ' . ucfirst $form->{part_type};
747 747
  $form->{title} = $locale->text($title);
748 748

  
749 749
  &link_part;
......
763 763
  map({ $form->{selectcurrency} .= "<option>$_\n" } $::form->get_all_currencies());
764 764

  
765 765
  # parts and assemblies have the same links
766
  my $item = $form->{item};
767
  if ($form->{item} eq 'assembly') {
766
  my $item = $form->{part_type};
767
  if ($form->{part_type} eq 'assembly') {
768 768
    $item = 'part';
769 769
  }
770 770

  
......
801 801
  }
802 802
  chop $form->{taxaccounts};
803 803

  
804
  if (($form->{item} eq "part") || ($form->{item} eq "assembly")) {
804
  if (($form->{part_type} eq "part") || ($form->{part_type} eq "assembly")) {
805 805
    $form->{selectIC_income}  = $form->{selectIC_sale};
806 806
    $form->{selectIC_expense} = $form->{selectIC_cogs};
807 807
    $form->{IC_income}        = $form->{IC_sale};
......
820 820
    map { $form->{selectpartsgroup} .= qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n| } @{ $form->{all_partsgroup} };
821 821
  }
822 822

  
823
  if ($form->{item} eq 'assembly') {
823
  if ($form->{part_type} eq 'assembly') {
824 824

  
825 825
    foreach my $i (1 .. $form->{assembly_rows}) {
826 826
      if ($form->{"partsgroup_id_$i"}) {
......
851 851
  $form->{description_area} = ($form->{rows} = $form->numtextrows($form->{description}, 40)) > 1;
852 852
  $form->{notes_rows}       =  max 4, $form->numtextrows($form->{notes}, 40), $form->numtextrows($form->{formel}, 40);
853 853

  
854
  map { $form->{"is_$_"}  = ($form->{item} eq $_) } qw(part service assembly);
854
  map { $form->{"is_$_"}  = ($form->{part_type} eq $_) } qw(part service assembly);
855 855
  map { $form->{$_}       =~ s/"/&quot;/g;        } qw(unit);
856 856

  
857 857
  $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS',
......
879 879
  IC->retrieve_buchungsgruppen(\%myconfig, $form);
880 880
  @{ $form->{BUCHUNGSGRUPPEN} } = grep { $_->{id} eq $form->{buchungsgruppen_id} || ($form->{id} && $form->{orphaned}) || !$form->{id} } @{ $form->{BUCHUNGSGRUPPEN} };
881 881

  
882
  if (($form->{partnumber} ne '') && !SL::TransNumber->new(number => $form->{partnumber}, type => $form->{item}, id => $form->{id})->is_unique) {
882
  if (($form->{partnumber} ne '') && !SL::TransNumber->new(number => $form->{partnumber}, type => $form->{part_type}, id => $form->{id})->is_unique) {
883 883
    flash('info', $::locale->text('This partnumber is not unique. You should change it.'));
884 884
  }
885 885

  
......
1060 1060
  # parse pricegroups. and no, don't rely on check_form for this...
1061 1061
  map { $form->{"price_$_"} = $form->parse_amount(\%myconfig, $form->{"price_$_"}) } 1 .. $form->{price_rows};
1062 1062

  
1063
  unless ($form->{item} eq 'assembly') {
1063
  unless ($form->{part_type} eq 'assembly') {
1064 1064
    # for assemblies check_form will parse sellprice and listprice, but not for parts or services
1065 1065
    $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) for qw(sellprice listprice ve gv);
1066 1066
  };
1067 1067

  
1068
  if ($form->{item} eq 'part') {
1068
  if ($form->{part_type} eq 'part') {
1069 1069
    $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) for qw(weight rop);
1070 1070
  }
1071 1071

  
1072 1072
  # same for makemodel lastcosts
1073 1073
  # but parse_amount not necessary for assembly component lastcosts
1074
  unless ($form->{item} eq "assembly") {
1074
  unless ($form->{part_type} eq "assembly") {
1075 1075
    map { $form->{"lastcost_$_"} = $form->parse_amount(\%myconfig, $form->{"lastcost_$_"}) } 1 .. $form->{"makemodel_rows"};
1076 1076
    $form->{lastcost} = $form->parse_amount(\%myconfig, $form->{lastcost});
1077 1077
  }
1078 1078

  
1079
  if ($form->{item} eq "assembly") {
1079
  if ($form->{part_type} eq "assembly") {
1080 1080
    my $i = $form->{assembly_rows};
1081 1081

  
1082 1082
    # if last row is empty check the form otherwise retrieve item
......
1124 1124
      }
1125 1125
    }
1126 1126

  
1127
  } elsif (($form->{item} eq 'part') || ($form->{item} eq 'service')) {
1127
  } elsif (($form->{part_type} eq 'part') || ($form->{part_type} eq 'service')) {
1128 1128
    &check_form;
1129 1129
  }
1130 1130

  
......
1139 1139
  my ($parts_id, %newform, $amount, $callback);
1140 1140

  
1141 1141
  # check if there is a part number - commented out, cause there is an automatic allocation of numbers
1142
  # $form->isblank("partnumber", $locale->text(ucfirst $form->{item}." Part Number missing!"));
1142
  # $form->isblank("partnumber", $locale->text(ucfirst $form->{part_type}." Part Number missing!"));
1143 1143

  
1144 1144
  # check if there is a description
1145 1145
  $form->isblank("description", $locale->text("Part Description missing!"));
1146 1146

  
1147
  $form->error($locale->text("Inventory quantity must be zero before you can set this $form->{item} obsolete!"))
1148
    if $form->{obsolete} && $form->{onhand} * 1 && $form->{item} ne 'service';
1147
  $form->error($locale->text("Inventory quantity must be zero before you can set this $form->{part_type} obsolete!"))
1148
    if $form->{obsolete} && $form->{onhand} * 1 && $form->{part_type} ne 'service';
1149 1149

  
1150 1150
  if (!$form->{buchungsgruppen_id}) {
1151 1151
    $form->error($locale->text("Parts must have an entry type.") . " " .
......
1192 1192
    $::auth->restore_form_from_session($newform{previousform}, form => $form);
1193 1193
    $form->{taxaccounts} = $newform{taxaccount2};
1194 1194

  
1195
    if ($form->{item} eq 'assembly') {
1195
    if ($form->{part_type} eq 'assembly') {
1196 1196

  
1197 1197
      # undo number formatting
1198 1198
      map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
......
1387 1387

  
1388 1388
  form_header();
1389 1389
  price_row($::form->{price_rows});
1390
  makemodel_row(++$::form->{makemodel_rows}) if $::form->{item} =~ /^(part|service)$/;
1391
  assembly_row(++$::form->{assembly_rows})   if $::form->{item} eq 'assembly';
1390
  makemodel_row(++$::form->{makemodel_rows}) if $::form->{part_type} =~ /^(part|service)$/;
1391
  assembly_row(++$::form->{assembly_rows})   if $::form->{part_type} eq 'assembly';
1392 1392

  
1393 1393
  form_footer();
1394 1394

  
bin/mozilla/io.pl
672 672
    map {
673 673
      $form->{"${_}_$i"} =
674 674
          $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
675
    } qw(sellprice lastcost qty) if $form->{item} ne 'assembly';
676
    $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100.0) if $form->{item} ne 'assembly';
675
    } qw(sellprice lastcost qty) if $form->{part_type} ne 'assembly';
676
    $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100.0) if $form->{part_type} ne 'assembly';
677 677

  
678 678
    delete $form->{nextsub};
679 679

  
......
727 727
  my $count = 0;
728 728

  
729 729
  # remove any makes or model rows
730
  if ($form->{item} eq 'assembly') {
730
  if ($form->{part_type} eq 'assembly') {
731 731

  
732 732
    # fuer assemblies auskommentiert. seiteneffekte? ;-) wird die woanders benoetigt?
733 733
    #$form->{sellprice} = 0;
......
760 760
    $form->redo_rows(\@flds, \@a, $count, $form->{assembly_rows});
761 761
    $form->{assembly_rows} = $count;
762 762

  
763
  } elsif ($form->{item} !~ m{^(?:part|service)$}) {
763
  } elsif ($form->{part_type} !~ m{^(?:part|service)$}) {
764 764
    remove_emptied_rows(1);
765 765

  
766 766
    $form->{creditremaining} -= &invoicetotal;
menus/user/00-erp.yaml
54 54
  module: ic.pl
55 55
  params:
56 56
    action: add
57
    item: part
57
    part_type: part
58 58
- parent: master_data
59 59
  id: master_data_add_service
60 60
  name: Add Service
......
64 64
  module: ic.pl
65 65
  params:
66 66
    action: add
67
    item: service
67
    part_type: service
68 68
- parent: master_data
69 69
  id: master_data_add_assembly
70 70
  name: Add Assembly
......
74 74
  module: ic.pl
75 75
  params:
76 76
    action: add
77
    item: assembly
77
    part_type: assembly
78 78
- parent: master_data
79 79
  id: master_data_add_project
80 80
  name: Add Project
templates/webpages/generic/new_item.html
9 9

  
10 10
      <p>
11 11

  
12
      <input class="radio" type="radio" name="item" value="part" checked>&nbsp;[% 'Part' | $T8 %]<br>
13
      <input class="radio" type="radio" name="item" value="service">&nbsp;[% 'Service' | $T8 %]
12
      <input class="radio" type="radio" name="part_type" value="part" checked>&nbsp;[% 'Part' | $T8 %]<br>
13
      <input class="radio" type="radio" name="part_type" value="service">&nbsp;[% 'Service' | $T8 %]
14 14
      <p>
15 15

  
16 16
      [%- FOREACH var = HIDDENS %]
templates/webpages/ic/form_header.html
9 9
 <form method="post" name="ic" action="[% script %]">
10 10

  
11 11
  <input name="id" type="hidden" value="[% HTML.escape(id) %]">
12
  <input name="item" type="hidden" value="[% HTML.escape(item) %]">
12
  <input name="part_type" type="hidden" value="[% HTML.escape(part_type) %]">
13 13
  <input name="title" type="hidden" value="[% HTML.escape(title) %]">
14 14
  <input name="makemodel" type="hidden" value="[% HTML.escape(makemodel) %]">
15 15
  <input name="onhand" type="hidden" value="[% HTML.escape(onhand) %]">

Auch abrufbar als: Unified diff