X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fic.pl;h=3383316ace35b6504d51637818a490ab4a4d27fa;hb=893bff3a5c0106b467578b470deac53f87173689;hp=daba6887e5944f3d4033c541dd6cd6c698f52fac;hpb=215356761a7aa1afd6d77be3aa1997bac9cf6d0e;p=kivitendo-erp.git diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index daba6887e..3383316ac 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -30,9 +30,9 @@ # Inventory Control module # #====================================================================== -#$locale->text('ea'); use POSIX qw(strftime); +use List::Util qw(max); use SL::IC; use SL::ReportGenerator; @@ -52,18 +52,32 @@ require "bin/mozilla/reportgenerator.pl"; 1; +# Parserhappy(R): +# type=submit $locale->text('Add Part') +# type=submit $locale->text('Add Service') +# type=submit $locale->text('Add Assembly') +# type=submit $locale->text('Edit Part') +# type=submit $locale->text('Edit Service') +# type=submit $locale->text('Edit Assembly') +# $locale->text('Parts') +# $locale->text('Services') +# $locale->text('Inventory quantity must be zero before you can set this part obsolete!') +# $locale->text('Inventory quantity must be zero before you can set this assembly obsolete!') +# $locale->text('Part Number missing!') +# $locale->text('Service Number missing!') +# $locale->text('Assembly Number missing!') +# $locale->text('ea'); + # end of main sub add { $lxdebug->enter_sub(); - $form->{title} = $locale->text('Add ' . ucfirst $form->{item}); - - $form->{callback} = - "$form->{script}?action=add&item=$form->{item}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; + $auth->assert('part_service_assembly_edit'); - $form->{"unit_changeable"} = 1; + $form->{title} = $locale->text('Add ' . ucfirst $form->{item}); + $form->{callback} = "$form->{script}?action=add&item=$form->{item}" unless $form->{callback}; + $form->{unit_changeable} = 1; IC->get_pricegroups(\%myconfig, \%$form); &link_part; @@ -75,32 +89,24 @@ sub add { sub search { $lxdebug->enter_sub(); - # switch for backward sorting - $form->{revers} = 0; - - # memory for which table was sort at last time - $form->{lastsort} = ""; - - # counter for added entries to top100 - $form->{ndxs_counter} = 0; + $auth->assert('part_service_assembly_edit'); - # $locale->text('Parts') - # $locale->text('Services') + $form->{revers} = 0; # switch for backward sorting + $form->{lastsort} = ""; # memory for which table was sort at last time + $form->{ndxs_counter} = 0; # counter for added entries to top100 - my $is_service = $form->{searchitems} eq 'service'; - my $is_assembly = $form->{searchitems} eq 'assembly'; + my %is_xyz = map { +"is_$_" => ($form->{searchitems} eq $_) } qw(part service assembly); $form->{title} = (ucfirst $form->{searchitems}) . "s"; $form->{title} = $locale->text($form->{title}); - $form->{title} = $locale->text('Assemblies') if $is_assembly; + $form->{title} = $locale->text('Assemblies') if ($is_xyz{assembly}); $form->{jsscript} = 1; $form->header; - print $form->parse_html_template('ic/search', { is_assembly => $is_assembly, - is_service => $is_service, - dateformat => $myconfig{dateformat}, }); + print $form->parse_html_template('ic/search', { %is_xyz, + dateformat => $myconfig{dateformat}, }); $lxdebug->leave_sub(); } #end search() @@ -108,6 +114,8 @@ sub search { sub search_update_prices { $lxdebug->enter_sub(); + $auth->assert('part_service_assembly_edit'); + my $pricegroups = IC->get_pricegroups(\%myconfig, \%$form); $form->header; @@ -120,6 +128,8 @@ sub search_update_prices { sub confirm_price_update { $lxdebug->enter_sub(); + $auth->assert('part_service_assembly_edit'); + $form->{nextsub} = "update_prices"; $form->header; @@ -133,6 +143,8 @@ sub confirm_price_update { sub update_prices { $lxdebug->enter_sub(); + $auth->assert('part_service_assembly_edit'); + if (IC->update_prices(\%myconfig, \%$form)) { $form->redirect($form->{update_count} . $locale->text('prices updated!')); } else { @@ -142,256 +154,205 @@ sub update_prices { $lxdebug->leave_sub(); } -sub choice { - $lxdebug->enter_sub(); - - our ($j, $lastndx); - my ($totop100); - - $form->{title} = $locale->text('Top 100 hinzufuegen'); - - $form->header; - - print qq| - - -
{script}> - - {searchitems}> - - - - |; - - print qq| - - - - - - - - - -
| . $locale->text('Part Number') . qq|| . $locale->text('Part Description') . qq|
-
|; - - print qq| - -{login}> -{password}> - - - - - - - - - - - - - - - - - - - - - - - - - -{ndxs_counter}> - -{extras}>|; - - my ($partnumber, $description, $unit, $sellprice, $soldtotal); - # if choice set data - if ($form->{ndx}) { - for (my $i = 0; $i < $form->{ndxs_counter}; $i++) { - - # prepeare data - $partnumber = $form->{"totop100_partnumber_$j"}; - $description = $form->{"totop100_description_$j"}; - $unit = $form->{"totop100_unit_$j"}; - $sellprice = $form->{"totop100_sellprice_$j"}; - $soldtotal = $form->{"totop100_soldtotal_$j"}; - - # insert data into top100 - push @{ $form->{parts} }, - { number => "", - partnumber => "$partnumber", - description => "$description", - unit => "$unit", - sellprice => "$sellprice", - soldtotal => "$soldtotal" }; - } #rof - } #fi - - $totop100 = ""; - - # set data for next page - if (($form->{ndxs_counter}) > 0) { - for (my $i = 1; ($i < $form->{ndxs_counter} + 1); $i++) { - $partnumber = $form->{"totop100_partnumber_$i"}; - $description = $form->{"totop100_description_$i"}; - $unit = $form->{"totop100_unit_$i"}; - $sellprice = $form->{"totop100_sellprice_$i"}; - $soldtotal = $form->{"totop100_soldtotal_$i"}; - - $totop100 .= qq| -{"totop100_partnumber_$i"}> -{"totop100_description_$i"}> -{"totop100_unit_$i"}> -{"totop100_sellprice_$i"}> -{"totop100_soldtotal_$i"}> - |; - } #rof - } #fi - - print $totop100; - - print qq| - -
- - - |; - $lxdebug->leave_sub(); -} #end choice - -sub list { - $lxdebug->enter_sub(); - - our ($lastndx); - our ($partnumber, $description, $unit, $sellprice, $soldtotal); - - my @sortorders = ("", "partnumber", "description", "all"); - my $sortorder = $sortorders[($form->{description} ? 2 : 0) + ($form->{partnumber} ? 1 : 0)]; - IC->get_parts(\%myconfig, \%$form, $sortorder); - - $form->{title} = $locale->text('Top 100 hinzufuegen'); - - $form->header; - - print qq| - -
- - - - - - - - - - - - - |; - - my $j = 0; - my $i = $form->{rows}; - - for ($j = 1; $j <= $i; $j++) { - - print qq| - |; - if ($j == 1) { - print qq| - |; - } else { - print qq| - |; - } - print qq| - - - - - - - - |; - } - - print qq| - -
| . $locale->text('choice part') . qq|
 | . $locale->text('Part Number') . qq|| . $locale->text('Part Description') . qq|| . $locale->text('Unit of measure') . qq|| . $locale->text('Sell Price') . qq|| . $locale->text('soldtotal') . qq|
$form->{"partnumber_$j"}$form->{"description_$j"}$form->{"unit_$j"}$form->{"sellprice_$j"}$form->{"soldtotal_$j"}
- -
- - -{login}> -{password}> - - - - - - - - - - - - - - - - - - - - - - - -{ndxs_counter}>|; - - my $totop100 = ""; - - if (($form->{ndxs_counter}) > 0) { - for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) { - - $partnumber = $form->{"totop100_partnumber_$i"}; - $description = $form->{"totop100_description_$i"}; - $unit = $form->{"totop100_unit_$i"}; - $sellprice = $form->{"totop100_sellprice_$i"}; - $soldtotal = $form->{"totop100_soldtotal_$i"}; - - $totop100 .= qq| -{"totop100_partnumber_$i"}> -{"totop100_description_$i"}> -{"totop100_unit_$i"}> -{"totop100_sellprice_$i"}> -{"totop100_soldtotal_$i"}> - |; - } #rof - } #fi - - print $totop100; - - print qq| - +#sub choice { +# $lxdebug->enter_sub(); +# +# $auth->assert('part_service_assembly_edit'); +# +# our ($j, $lastndx); +# my ($totop100); +# +# $form->{title} = $locale->text('Top 100 hinzufuegen'); +# +# $form->header; +# +# push @custom_hiddens, qw(searchitems title bom titel revers lastsort sort ndxs_counter extras); +# push @custom_hiddens, qw(itemstatus l_linetotal l_partnumber l_description l_onhand l_unit l_sellprice l_linetotalsellprice); +# my @HIDDENS = ( +# +{ name => 'row', value => $j }, +# +{ name => 'nextsub', value => 'item_selected' }, +# +{ name => 'test', value => 'item_selected' }, +# +{ name => 'lastndx', value => $lastndx }, +# map(+{ name => $_, value => $form->{$_} }, @custom_hiddens), +# ); +# +# my ($partnumber, $description, $unit, $sellprice, $soldtotal); +# # if choice set data +## if ($form->{ndx}) { +## for my $i (0 .. $form->{ndxs_counter}) { +## +## # insert data into top100 +## push @{ $form->{parts} }, +## { number => "", +## partnumber => $form->{"totop100_partnumber_$j"}, +## description => $form->{"totop100_description_$j"}, +## unit => $form->{"totop100_unit_$j"}, +## sellprice => $form->{"totop100_sellprice_$j"}, +## soldtotal => $form->{"totop100_soldtotal_$j"}, +## }; +## } #rof +## } #fi +# +# $totop100 = ""; +# +# # set data for next page +# for my $i (1 .. $form->{ndxs_counter}) { +# $partnumber = $form->{"totop100_partnumber_$i"}; +# $description = $form->{"totop100_description_$i"}; +# $unit = $form->{"totop100_unit_$i"}; +# $sellprice = $form->{"totop100_sellprice_$i"}; +# $soldtotal = $form->{"totop100_soldtotal_$i"}; +# +# push @PARTS, { +# totop100_partnumber => $form->{"totop100_partnumber_$i"}, +# totop100_description => $form->{"totop100_description_$i"}, +# totop100_unit => $form->{"totop100_unit_$i"}, +# totop100_sellprice => $form->{"totop100_sellprice_$i"}, +# totop100_soldtotal => $form->{"totop100_soldtotal_$i"}, +# } +# +## $totop100 .= qq| +##{"totop100_partnumber_$i"}> +##{"totop100_description_$i"}> +##{"totop100_unit_$i"}> +##{"totop100_sellprice_$i"}> +##{"totop100_soldtotal_$i"}> +## |; +# } #rof +# +# print $form->parse_html_template('ic/choice', +{ HIDDENS => \@HIDDENS, PARTS => \@PARTS }); +# +# $lxdebug->leave_sub(); +#} #end choice -
- - -|; - $lxdebug->leave_sub(); -} #end list() +#sub list { +# $lxdebug->enter_sub(); +# +# $auth->assert('part_service_assembly_edit'); +# +# our ($lastndx); +# our ($partnumber, $description, $unit, $sellprice, $soldtotal); +# +# my @sortorders = ("", "partnumber", "description", "all"); +# my $sortorder = $sortorders[($form->{description} ? 2 : 0) + ($form->{partnumber} ? 1 : 0)]; +# IC->get_parts(\%myconfig, \%$form, $sortorder); +# +# $form->{title} = $locale->text('Top 100 hinzufuegen'); +# +# $form->header; +# +# print qq| +# +#
+# +# +# +# +# +# +# +# +# +# +# +# +# |; +# +# my $j = 0; +# my $i = $form->{rows}; +# +# for ($j = 1; $j <= $i; $j++) { +# +# print qq| +# |; +# if ($j == 1) { +# print qq| +# |; +# } else { +# print qq| +# |; +# } +# print qq| +# +# +# +# +# +# +# +# |; +# } +# +# print qq| +# +#
| . $locale->text('choice part') . qq|
 | . $locale->text('Part Number') . qq|| . $locale->text('Part Description') . qq|| . $locale->text('Unit of measure') . qq|| . $locale->text('Sell Price') . qq|| . $locale->text('soldtotal') . qq|
$form->{"partnumber_$j"}$form->{"description_$j"}$form->{"unit_$j"}$form->{"sellprice_$j"}$form->{"soldtotal_$j"}
+# +#
+# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +#{ndxs_counter}>|; +# +# my $totop100 = ""; +# +# if (($form->{ndxs_counter}) > 0) { +# for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) { +# +# $partnumber = $form->{"totop100_partnumber_$i"}; +# $description = $form->{"totop100_description_$i"}; +# $unit = $form->{"totop100_unit_$i"}; +# $sellprice = $form->{"totop100_sellprice_$i"}; +# $soldtotal = $form->{"totop100_soldtotal_$i"}; +# +# $totop100 .= qq| +#{"totop100_partnumber_$i"}> +#{"totop100_description_$i"}> +#{"totop100_unit_$i"}> +#{"totop100_sellprice_$i"}> +#{"totop100_soldtotal_$i"}> +# |; +# } #rof +# } #fi +# +# print $totop100; +# +# print qq| +# +# +#
+# +# +#|; +# $lxdebug->leave_sub(); +#} #end list() sub top100 { $lxdebug->enter_sub(); + $auth->assert('part_service_assembly_edit'); + if ($form->{ndx}) { $form->{ndxs_counter}++; @@ -413,6 +374,8 @@ sub top100 { sub addtop100 { $lxdebug->enter_sub(); + $auth->assert('part_service_assembly_edit'); + my ($revers, $lastsort, $callback, $option, $description, $sameitem, $partnumber, $unit, $sellprice, $soldtotal, $totop100, $onhand, $align); my (@column_index, %column_header, %column_data); @@ -442,7 +405,7 @@ sub addtop100 { } #fi $callback = - "$form->{script}?action=top100&login=$form->{login}&password=$form->{password}&searchitems=$form->{searchitems}&itemstatus=$form->{itemstatus}&bom=$form->{bom}&l_linetotal=$form->{l_linetotal}&title=" + "$form->{script}?action=top100&searchitems=$form->{searchitems}&itemstatus=$form->{itemstatus}&bom=$form->{bom}&l_linetotal=$form->{l_linetotal}&title=" . $form->escape($form->{title}, 1); # if we have a serialnumber limit search @@ -545,16 +508,13 @@ sub addtop100 { } if ($form->{serialnumber}) { $callback .= "&serialnumber=$form->{serialnumber}"; - $option .= - $locale->text('Serial Number') . qq| : $form->{serialnumber}
|; + $option .= $locale->text('Serial Number') . qq| : $form->{serialnumber}
|; } if ($form->{description}) { - $callback .= "&description=$form->{description}"; + $callback .= "&description=$form->{description}"; $description = $form->{description}; - $description =~ s/ -/
/g; - $option .= - $locale->text('Part Description') . qq| : $form->{description}
|; + $description =~ s/\n/
/g; + $option .= $locale->text('Part Description') . qq| : $form->{description}
|; } if ($form->{make}) { $callback .= "&make=$form->{make}"; @@ -786,8 +746,8 @@ sub addtop100 { } #rof } #fi # build data for columns + my $i = 0; foreach my $ref (@{ $form->{parts} }) { - my $i = 0; if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) { if ($sameitem ne $ref->{ $form->{sort} }) { @@ -810,8 +770,7 @@ sub addtop100 { $onhand = 0 if ($form->{sold}); } - $ref->{description} =~ s/ -/
/g; + $ref->{description} =~ s/\n/
/g; $column_data{number} = "" @@ -873,15 +832,15 @@ sub addtop100 { $column_data{invnumber} = ($ref->{module} ne 'oe') - ? "{module}.pl?action=edit&type=invoice&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber}" + ? "{module}.pl?action=edit&type=invoice&id=$ref->{trans_id}&callback=$callback>$ref->{invnumber}" : "$ref->{invnumber}"; $column_data{ordnumber} = ($ref->{module} eq 'oe') - ? "{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber}" + ? "{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&callback=$callback>$ref->{ordnumber}" : "$ref->{ordnumber}"; $column_data{quonumber} = ($ref->{module} eq 'oe' && !$ref->{ordnumber}) - ? "{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber}" + ? "{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&callback=$callback>$ref->{quonumber}" : "$ref->{quonumber}"; $column_data{name} = "$ref->{name}"; @@ -953,9 +912,6 @@ sub addtop100 {
{script}> -{login}> -{password}> - @@ -976,7 +932,7 @@ sub addtop100 { print $totop100; print qq| - + @@ -1014,14 +970,17 @@ sub addtop100 { # l_partsgroup l_subtotal l_soldtotal l_deliverydate # # hiddens: -# nextsub login password revers lastsort sort ndxs_counter +# nextsub revers lastsort sort ndxs_counter # sub generate_report { $lxdebug->enter_sub(); + $auth->assert('part_service_assembly_edit'); + my ($revers, $lastsort, $description); $form->{title} = (ucfirst $form->{searchitems}) . "s"; + $form->{title} =~ s/ys$/ies/; $form->{title} = $locale->text($form->{title}); my $revers = $form->{revers}; @@ -1337,6 +1296,8 @@ sub generate_report { sub parts_subtotal { $lxdebug->enter_sub(); + $auth->assert('part_service_assembly_edit'); + # imports our (%column_data, @column_index); our ($subtotalonhand, $totalsellprice, $totallastcost, $totallistprice, $subtotalsellprice, $subtotallastcost, $subtotallistprice); @@ -1380,6 +1341,9 @@ sub parts_subtotal { sub edit { $lxdebug->enter_sub(); + + $auth->assert('part_service_assembly_edit'); + # show history button $form->{javascript} = qq||; #/show hhistory button @@ -1398,6 +1362,8 @@ sub edit { sub link_part { $lxdebug->enter_sub(); + $auth->assert('part_service_assembly_edit'); + IC->create_links("IC", \%myconfig, \%$form); # currencies @@ -1459,10 +1425,7 @@ sub link_part { if (@{ $form->{all_partsgroup} }) { $form->{selectpartsgroup} = qq||; - foreach my $item (@{ $form->{payment_terms} }) { - if ($form->{payment_id} eq $item->{id}) { - $payment .= qq||; - } else { - $payment .= qq||; - } - } - - - if (($rows = $form->numtextrows($form->{notes}, 40)) < 2) { - $rows = 4; - } + $auth->assert('part_service_assembly_edit'); - $notes = - qq||; - if (($rows = $form->numtextrows($form->{description}, 40)) > 1) { - $description = - qq||; - } else { - $description = - qq||; - } + $form->{eur} = $eur; # config dumps into namespace - yuck + $form->{pg_keys} = sub { "$_[0]->{partsgroup}--$_[0]->{id}" }; + $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); - $ean = qq||; - - foreach my $item (split / /, $form->{taxaccounts}) { - $form->{"IC_tax_$item"} = ($form->{"IC_tax_$item"}) ? "checked" : ""; - } + map { $form->{"is_$_"} = ($form->{item} eq $_) } qw(part service assembly); + map { $form->{$_} =~ s/"/"/g; } qw(unit); + + $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS', + 'partsgroup' => 'all_partsgroup'); IC->retrieve_buchungsgruppen(\%myconfig, $form); - if (@{ $form->{BUCHUNGSGRUPPEN} }) { - foreach my $item (@{ $form->{BUCHUNGSGRUPPEN} }) { - if ($item->{id} == $form->{buchungsgruppen_id}) { - $form->{selectbuchungsgruppe} .= - "