1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger, Accounting
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
30 # Inventory Control module
32 #======================================================================
34 use POSIX qw(strftime);
35 use List::Util qw(max);
36 use List::MoreUtils qw(any);
40 use SL::ReportGenerator;
48 our ($form, $locale, %myconfig, $lxdebug);
50 require "bin/mozilla/io.pl";
51 require "bin/mozilla/invoice_io.pl";
52 require "bin/mozilla/common.pl";
53 require "bin/mozilla/reportgenerator.pl";
58 # type=submit $locale->text('Add Part')
59 # type=submit $locale->text('Add Service')
60 # type=submit $locale->text('Add Assembly')
61 # type=submit $locale->text('Edit Part')
62 # type=submit $locale->text('Edit Service')
63 # type=submit $locale->text('Edit Assembly')
64 # $locale->text('Parts')
65 # $locale->text('Services')
66 # $locale->text('Inventory quantity must be zero before you can set this part obsolete!')
67 # $locale->text('Inventory quantity must be zero before you can set this assembly obsolete!')
68 # $locale->text('Part Number missing!')
69 # $locale->text('Service Number missing!')
70 # $locale->text('Assembly Number missing!')
71 # $locale->text('ea');
76 $lxdebug->enter_sub();
78 $auth->assert('part_service_assembly_edit');
80 $form->{title} = $locale->text('Add ' . ucfirst $form->{item});
81 $form->{callback} = "$form->{script}?action=add&item=$form->{item}" unless $form->{callback};
82 $form->{unit_changeable} = 1;
84 IC->get_pricegroups(\%myconfig, \%$form);
88 $lxdebug->leave_sub();
92 $lxdebug->enter_sub();
94 $auth->assert('part_service_assembly_edit');
96 $form->{revers} = 0; # switch for backward sorting
97 $form->{lastsort} = ""; # memory for which table was sort at last time
98 $form->{ndxs_counter} = 0; # counter for added entries to top100
100 my %is_xyz = map { +"is_$_" => ($form->{searchitems} eq $_) } qw(part service assembly);
102 $form->{title} = (ucfirst $form->{searchitems}) . "s";
103 $form->{title} = $locale->text($form->{title});
104 $form->{title} = $locale->text('Assemblies') if ($is_xyz{is_assembly});
106 $form->{jsscript} = 1;
110 print $form->parse_html_template('ic/search', { %is_xyz,
111 dateformat => $myconfig{dateformat}, });
113 $lxdebug->leave_sub();
116 sub search_update_prices {
117 $lxdebug->enter_sub();
119 $auth->assert('part_service_assembly_edit');
121 my $pricegroups = IC->get_pricegroups(\%myconfig, \%$form);
125 print $form->parse_html_template('ic/search_update_prices', { PRICE_ROWS => $pricegroups });
127 $lxdebug->leave_sub();
130 sub confirm_price_update {
131 $lxdebug->enter_sub();
133 $auth->assert('part_service_assembly_edit');
136 my $value_found = false;
138 foreach my $idx (qw(sellprice listprice), (1..$form->{price_rows})) {
139 my $name = $idx =~ m/\d/ ? $form->{"pricegroup_${idx}"} : $idx eq 'sellprice' ? $locale->text('Sell Price') : $locale->text('List Price');
140 my $type = $idx =~ m/\d/ ? $form->{"pricegroup_type_${idx}"} : $form->{"${idx}_type"};
141 my $value_idx = $idx =~ m/\d/ ? "price_${idx}" : $idx;
142 my $value = $form->parse_amount(\%myconfig, $form->{$value_idx});
144 if ((0 > $value) && ($type eq 'percent')) {
145 push @errors, $locale->text('You cannot adjust the price for pricegroup "#1" by a negative percentage.', $name);
147 } elsif (!$value && ($form->{$value_idx} ne '')) {
148 push @errors, $locale->text('No valid number entered for pricegroup "#1".', $name);
150 } elsif (0 < $value) {
155 push @errors, $locale->text('No prices will be updated because no prices have been entered.') if (!$value_found);
157 my $num_matches = IC->get_num_matches_for_priceupdate();
162 $form->show_generic_error(join('<br>', @errors), 'back_button' => 1);
165 $form->{nextsub} = "update_prices";
167 map { delete $form->{$_} } qw(action header);
169 print $form->parse_html_template('ic/confirm_price_update', { HIDDENS => [ map { name => $_, value => $form->{$_} }, keys %$form ],
170 num_matches => $num_matches });
172 $lxdebug->leave_sub();
176 $lxdebug->enter_sub();
178 $auth->assert('part_service_assembly_edit');
180 my $num_updated = IC->update_prices(\%myconfig, \%$form);
182 if (-1 != $num_updated) {
183 $form->redirect($locale->text('#1 prices were updated.', $num_updated));
185 $form->error($locale->text('Could not update prices!'));
188 $lxdebug->leave_sub();
192 # $lxdebug->enter_sub();
194 # $auth->assert('part_service_assembly_edit');
196 # our ($j, $lastndx);
199 # $form->{title} = $locale->text('Top 100 hinzufuegen');
203 # push @custom_hiddens, qw(searchitems title bom titel revers lastsort sort ndxs_counter extras);
204 # push @custom_hiddens, qw(itemstatus l_linetotal l_partnumber l_description l_onhand l_unit l_sellprice l_linetotalsellprice);
206 # +{ name => 'row', value => $j },
207 # +{ name => 'nextsub', value => 'item_selected' },
208 # +{ name => 'test', value => 'item_selected' },
209 # +{ name => 'lastndx', value => $lastndx },
210 # map(+{ name => $_, value => $form->{$_} }, @custom_hiddens),
213 # my ($partnumber, $description, $unit, $sellprice, $soldtotal);
214 # # if choice set data
215 ## if ($form->{ndx}) {
216 ## for my $i (0 .. $form->{ndxs_counter}) {
218 ## # insert data into top100
219 ## push @{ $form->{parts} },
221 ## partnumber => $form->{"totop100_partnumber_$j"},
222 ## description => $form->{"totop100_description_$j"},
223 ## unit => $form->{"totop100_unit_$j"},
224 ## sellprice => $form->{"totop100_sellprice_$j"},
225 ## soldtotal => $form->{"totop100_soldtotal_$j"},
232 # # set data for next page
233 # for my $i (1 .. $form->{ndxs_counter}) {
234 # $partnumber = $form->{"totop100_partnumber_$i"};
235 # $description = $form->{"totop100_description_$i"};
236 # $unit = $form->{"totop100_unit_$i"};
237 # $sellprice = $form->{"totop100_sellprice_$i"};
238 # $soldtotal = $form->{"totop100_soldtotal_$i"};
241 # totop100_partnumber => $form->{"totop100_partnumber_$i"},
242 # totop100_description => $form->{"totop100_description_$i"},
243 # totop100_unit => $form->{"totop100_unit_$i"},
244 # totop100_sellprice => $form->{"totop100_sellprice_$i"},
245 # totop100_soldtotal => $form->{"totop100_soldtotal_$i"},
249 ##<input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
250 ##<input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
251 ##<input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
252 ##<input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
253 ##<input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
257 # print $form->parse_html_template('ic/choice', +{ HIDDENS => \@HIDDENS, PARTS => \@PARTS });
259 # $lxdebug->leave_sub();
263 # $lxdebug->enter_sub();
265 # $auth->assert('part_service_assembly_edit');
268 # our ($partnumber, $description, $unit, $sellprice, $soldtotal);
270 # my @sortorders = ("", "partnumber", "description", "all");
271 # my $sortorder = $sortorders[($form->{description} ? 2 : 0) + ($form->{partnumber} ? 1 : 0)];
272 # IC->get_parts(\%myconfig, \%$form, $sortorder);
274 # $form->{title} = $locale->text('Top 100 hinzufuegen');
280 # <form method=post action=ic.pl>
283 # <th class=listtop colspan=6>| . $locale->text('choice part') . qq|</th>
285 # <tr height="5"></tr>
286 # <tr class=listheading>
288 # <th class=listheading>| . $locale->text('Part Number') . qq|</th>
289 # <th class=listheading>| . $locale->text('Part Description') . qq|</th>
290 # <th class=listheading>| . $locale->text('Unit of measure') . qq|</th>
291 # <th class=listheading>| . $locale->text('Sell Price') . qq|</th>
292 # <th class=listheading>| . $locale->text('soldtotal') . qq|</th>
296 # my $i = $form->{rows};
298 # for ($j = 1; $j <= $i; $j++) {
301 # <tr class=listrow| . ($j % 2) . qq|>|;
304 # <td><input name=ndx class=radio type=radio value=$j checked></td>|;
307 # <td><input name=ndx class=radio type=radio value=$j></td>|;
310 # <td><input name="new_partnumber_$j" type=hidden value="$form->{"partnumber_$j"}">$form->{"partnumber_$j"}</td>
311 # <td><input name="new_description_$j" type=hidden value="$form->{"description_$j"}">$form->{"description_$j"}</td>
312 # <td><input name="new_unit_$j" type=hidden value="$form->{"unit_$j"}">$form->{"unit_$j"}</td>
313 # <td><input name="new_sellprice_$j" type=hidden value="$form->{"sellprice_$j"}">$form->{"sellprice_$j"}</td>
314 # <td><input name="new_soldtotal_$j" type=hidden value="$form->{"soldtotal_$j"}">$form->{"soldtotal_$j"}</td>
317 # <input name="new_id_$j" type=hidden value="$form->{"id_$j"}">|;
327 #<input type=hidden name=itemstatus value="$form->{itemstatus}">
328 #<input type=hidden name=l_linetotal value="$form->{l_linetotal}">
329 #<input type=hidden name=l_partnumber value="$form->{l_partnumber}">
330 #<input type=hidden name=l_description value="$form->{l_description}">
331 #<input type=hidden name=l_onhand value="$form->{l_onhand}">
332 #<input type=hidden name=l_unit value="$form->{l_unit}">
333 #<input type=hidden name=l_sellprice value="$form->{l_sellprice}">
334 #<input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
335 #<input type=hidden name=sort value="$form->{sort}">
336 #<input type=hidden name=revers value="$form->{revers}">
337 #<input type=hidden name=lastsort value="$form->{lastsort}">
339 #<input type=hidden name=bom value="$form->{bom}">
340 #<input type=hidden name=titel value="$form->{titel}">
341 #<input type=hidden name=searchitems value="$form->{searchitems}">
343 #<input type=hidden name=row value=$j>
345 #<input type=hidden name=nextsub value=item_selected>
347 #<input name=lastndx type=hidden value=$lastndx>
349 #<input name=ndxs_counter type=hidden value=$form->{ndxs_counter}>|;
353 # if (($form->{ndxs_counter}) > 0) {
354 # for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
356 # $partnumber = $form->{"totop100_partnumber_$i"};
357 # $description = $form->{"totop100_description_$i"};
358 # $unit = $form->{"totop100_unit_$i"};
359 # $sellprice = $form->{"totop100_sellprice_$i"};
360 # $soldtotal = $form->{"totop100_soldtotal_$i"};
363 #<input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
364 #<input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
365 #<input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
366 #<input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
367 #<input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
375 #<input class=submit type=submit name=action value="|
376 # . $locale->text('TOP100') . qq|">
382 # $lxdebug->leave_sub();
386 $lxdebug->enter_sub();
388 $auth->assert('part_service_assembly_edit');
391 $form->{ndxs_counter}++;
393 if ($form->{ndxs_counter} > 0) {
395 my $index = $form->{ndx};
397 $form->{"totop100_partnumber_$form->{ndxs_counter}"} = $form->{"new_partnumber_$index"};
398 $form->{"totop100_description_$form->{ndxs_counter}"} = $form->{"new_description_$index"};
399 $form->{"totop100_unit_$form->{ndxs_counter}"} = $form->{"new_unit_$index"};
400 $form->{"totop100_sellprice_$form->{ndxs_counter}"} = $form->{"new_sellprice_$index"};
401 $form->{"totop100_soldtotal_$form->{ndxs_counter}"} = $form->{"new_soldtotal_$index"};
405 $lxdebug->leave_sub();
409 $lxdebug->enter_sub();
411 $auth->assert('part_service_assembly_edit');
413 my ($revers, $lastsort, $callback, $option, $description, $sameitem,
414 $partnumber, $unit, $sellprice, $soldtotal, $totop100, $onhand, $align);
415 my (@column_index, %column_header, %column_data);
416 my ($totalsellprice, $totallastcost, $totallistprice, $subtotalonhand, $subtotalsellprice, $subtotallastcost, $subtotallistprice);
418 $form->{top100} = "top100";
419 $form->{l_soldtotal} = "Y";
420 $form->{soldtotal} = "soldtotal";
421 $form->{sort} = "soldtotal";
422 $form->{l_qty} = "N";
423 $form->{l_linetotal} = "";
425 $form->{number} = "position";
426 $form->{l_number} = "Y";
430 $form->{title} = $locale->text('Top 100');
432 $revers = $form->{revers};
433 $lastsort = $form->{lastsort};
435 if (($form->{lastsort} eq "") && ($form->{sort} eq undef)) {
437 $form->{lastsort} = "partnumber";
438 $form->{sort} = "partnumber";
442 "$form->{script}?action=top100&searchitems=$form->{searchitems}&itemstatus=$form->{itemstatus}&bom=$form->{bom}&l_linetotal=$form->{l_linetotal}&title="
443 . $form->escape($form->{title}, 1);
445 # if we have a serialnumber limit search
446 if ($form->{serialnumber} || $form->{l_serialnumber}) {
447 $form->{l_serialnumber} = "Y";
448 unless ( $form->{bought}
451 || $form->{quoted}) {
452 $form->{bought} = $form->{sold} = 1;
455 IC->all_parts(\%myconfig, \%$form);
457 if ($form->{itemstatus} eq 'active') {
458 $option .= $locale->text('Active') . " : ";
460 if ($form->{itemstatus} eq 'obsolete') {
461 $option .= $locale->text('Obsolete') . " : ";
463 if ($form->{itemstatus} eq 'orphaned') {
464 $option .= $locale->text('Orphaned') . " : ";
466 if ($form->{itemstatus} eq 'onhand') {
467 $option .= $locale->text('On Hand') . " : ";
468 $form->{l_onhand} = "Y";
470 if ($form->{itemstatus} eq 'short') {
471 $option .= $locale->text('Short') . " : ";
472 $form->{l_onhand} = "Y";
474 if ($form->{onorder}) {
475 $form->{l_ordnumber} = "Y";
476 $callback .= "&onorder=$form->{onorder}";
477 $option .= $locale->text('On Order') . " : ";
479 if ($form->{ordered}) {
480 $form->{l_ordnumber} = "Y";
481 $callback .= "&ordered=$form->{ordered}";
482 $option .= $locale->text('Ordered') . " : ";
485 $form->{l_quonumber} = "Y";
486 $callback .= "&rfq=$form->{rfq}";
487 $option .= $locale->text('RFQ') . " : ";
489 if ($form->{quoted}) {
490 $form->{l_quonumber} = "Y";
491 $callback .= ""ed=$form->{quoted}";
492 $option .= $locale->text('Quoted') . " : ";
494 if ($form->{bought}) {
495 $form->{l_invnumber} = "Y";
496 $callback .= "&bought=$form->{bought}";
497 $option .= $locale->text('Bought') . " : ";
500 $form->{l_invnumber} = "Y";
501 $callback .= "&sold=$form->{sold}";
502 $option .= $locale->text('Sold') . " : ";
509 || $form->{quoted}) {
511 $form->{l_lastcost} = "";
512 $form->{l_name} = "Y";
513 if ($form->{transdatefrom}) {
514 $callback .= "&transdatefrom=$form->{transdatefrom}";
516 . $locale->text('From')
518 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
520 if ($form->{transdateto}) {
521 $callback .= "&transdateto=$form->{transdateto}";
523 . $locale->text('To')
525 . $locale->date(\%myconfig, $form->{transdateto}, 1);
531 if ($form->{partnumber}) {
532 $callback .= "&partnumber=$form->{partnumber}";
533 $option .= $locale->text('Part Number') . qq| : $form->{partnumber}<br>|;
536 $callback .= "&partnumber=$form->{ean}";
537 $option .= $locale->text('EAN') . qq| : $form->{ean}<br>|;
539 if ($form->{partsgroup}) {
540 $callback .= "&partsgroup=$form->{partsgroup}";
541 $option .= $locale->text('Group') . qq| : $form->{partsgroup}<br>|;
543 if ($form->{serialnumber}) {
544 $callback .= "&serialnumber=$form->{serialnumber}";
545 $option .= $locale->text('Serial Number') . qq| : $form->{serialnumber}<br>|;
547 if ($form->{description}) {
548 $callback .= "&description=$form->{description}";
549 $description = $form->{description};
550 $description =~ s/\n/<br>/g;
551 $option .= $locale->text('Part Description') . qq| : $form->{description}<br>|;
554 $callback .= "&make=$form->{make}";
555 $option .= $locale->text('Make') . qq| : $form->{make}<br>|;
557 if ($form->{model}) {
558 $callback .= "&model=$form->{model}";
559 $option .= $locale->text('Model') . qq| : $form->{model}<br>|;
561 if ($form->{drawing}) {
562 $callback .= "&drawing=$form->{drawing}";
563 $option .= $locale->text('Drawing') . qq| : $form->{drawing}<br>|;
565 if ($form->{microfiche}) {
566 $callback .= "µfiche=$form->{microfiche}";
567 $option .= $locale->text('Microfiche') . qq| : $form->{microfiche}<br>|;
569 if ($form->{l_soldtotal}) {
570 $callback .= "&soldtotal=$form->{soldtotal}";
571 $option .= $locale->text('soldtotal') . qq| : $form->{soldtotal}<br>|;
574 my @columns = $form->sort_columns(
575 qw(number partnumber ean description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice lastcost linetotallastcost priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal)
578 if ($form->{l_linetotal}) {
579 $form->{l_onhand} = "Y";
580 $form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
581 if ($form->{l_lastcost}) {
582 $form->{l_linetotallastcost} = "Y";
583 if (($form->{searchitems} eq 'assembly') && !$form->{bom}) {
584 $form->{l_linetotallastcost} = "";
587 $form->{l_linetotallistprice} = "Y" if $form->{l_listprice};
590 if ($form->{searchitems} eq 'service') {
592 # remove bin, weight and rop from list
593 map { $form->{"l_$_"} = "" } qw(bin weight rop);
595 $form->{l_onhand} = "";
597 # qty is irrelevant unless bought or sold
603 || $form->{quoted}) {
604 $form->{l_onhand} = "Y";
606 $form->{l_linetotalsellprice} = "";
607 $form->{l_linetotallastcost} = "";
611 foreach my $item (@columns) {
612 if ($form->{"l_$item"} eq "Y") {
613 push @column_index, $item;
615 # add column to callback
616 $callback .= "&l_$item=Y";
620 if ($form->{l_subtotal} eq 'Y') {
621 $callback .= "&l_subtotal=Y";
624 $column_header{number} =
625 qq|<th class=listheading nowrap>| . $locale->text('number') . qq|</th>|;
626 $column_header{partnumber} =
627 qq|<th nowrap><a class=listheading href=$callback&sort=partnumber&revers=$form->{revers}&lastsort=$form->{lastsort}>|
628 . $locale->text('Part Number')
630 $column_header{description} =
631 qq|<th nowrap><a class=listheading href=$callback&sort=description&revers=$form->{revers}&lastsort=$form->{lastsort}>|
632 . $locale->text('Part Description')
634 $column_header{partsgroup} =
635 qq|<th nowrap><a class=listheading href=$callback&sort=partsgroup>|
636 . $locale->text('Group')
638 $column_header{bin} =
639 qq|<th><a class=listheading href=$callback&sort=bin>|
640 . $locale->text('Bin')
642 $column_header{priceupdate} =
643 qq|<th nowrap><a class=listheading href=$callback&sort=priceupdate>|
644 . $locale->text('Updated')
646 $column_header{onhand} =
647 qq|<th nowrap><a class=listheading href=$callback&sort=onhand&revers=$form->{revers}&lastsort=$form->{lastsort}>|
648 . $locale->text('Qty')
650 $column_header{unit} =
651 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
652 $column_header{listprice} =
653 qq|<th class=listheading nowrap>|
654 . $locale->text('List Price')
656 $column_header{lastcost} =
657 qq|<th class=listheading nowrap>| . $locale->text('Last Cost') . qq|</th>|;
658 $column_header{rop} =
659 qq|<th class=listheading nowrap>| . $locale->text('ROP') . qq|</th>|;
660 $column_header{weight} =
661 qq|<th class=listheading nowrap>| . $locale->text('Weight') . qq|</th>|;
663 $column_header{invnumber} =
664 qq|<th nowrap><a class=listheading href=$callback&sort=invnumber>|
665 . $locale->text('Invoice Number')
667 $column_header{ordnumber} =
668 qq|<th nowrap><a class=listheading href=$callback&sort=ordnumber>|
669 . $locale->text('Order Number')
671 $column_header{quonumber} =
672 qq|<th nowrap><a class=listheading href=$callback&sort=quonumber>|
673 . $locale->text('Quotation')
676 $column_header{name} =
677 qq|<th nowrap><a class=listheading href=$callback&sort=name>|
678 . $locale->text('Name')
681 $column_header{sellprice} =
682 qq|<th class=listheading nowrap>|
683 . $locale->text('Sell Price')
685 $column_header{linetotalsellprice} =
686 qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
687 $column_header{linetotallastcost} =
688 qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
689 $column_header{linetotallistprice} =
690 qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
692 $column_header{image} =
693 qq|<th class=listheading nowrap>| . $locale->text('Image') . qq|</a></th>|;
694 $column_header{drawing} =
695 qq|<th nowrap><a class=listheading href=$callback&sort=drawing>|
696 . $locale->text('Drawing')
698 $column_header{microfiche} =
699 qq|<th nowrap><a class=listheading href=$callback&sort=microfiche>|
700 . $locale->text('Microfiche')
703 $column_header{serialnumber} =
704 qq|<th nowrap><a class=listheading href=$callback&sort=serialnumber>|
705 . $locale->text('Serial Number')
707 $column_header{soldtotal} =
708 qq|<th nowrap><a class=listheading href=$callback&sort=soldtotal&revers=$form->{revers}&lastsort=$form->{lastsort}>|
709 . $locale->text('soldtotal')
713 my $colspan = $#column_index + 1;
720 <th class=listtop colspan=$colspan>$form->{title}</th>
724 <tr><td colspan=$colspan>$option</td></tr>
726 <tr class=listheading>
729 map { print "\n$column_header{$_}" } @column_index;
735 # add order to callback
736 $form->{callback} = $callback .= "&sort=$form->{sort}";
738 # escape callback for href
739 $callback = $form->escape($callback);
741 if (@{ $form->{parts} }) {
742 $sameitem = $form->{parts}->[0]->{ $form->{sort} };
745 # insert numbers for top100
747 foreach my $ref (@{ $form->{parts} }) {
752 # if avaible -> insert choice here
753 if (($form->{ndxs_counter}) > 0) {
754 for (my $i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
755 $partnumber = $form->{"totop100_partnumber_$i"};
756 $description = $form->{"totop100_description_$i"};
757 $unit = $form->{"totop100_unit_$i"};
758 $sellprice = $form->{"totop100_sellprice_$i"};
759 $soldtotal = $form->{"totop100_soldtotal_$i"};
762 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
763 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
764 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
765 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
766 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
770 push @{ $form->{parts} },
772 partnumber => "$partnumber",
773 description => "$description",
775 sellprice => "$sellprice",
776 soldtotal => "$soldtotal" };
779 # build data for columns
781 foreach my $ref (@{ $form->{parts} }) {
783 if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
784 if ($sameitem ne $ref->{ $form->{sort} }) {
786 $sameitem = $ref->{ $form->{sort} };
790 $ref->{exchangerate} = 1 unless $ref->{exchangerate};
791 $ref->{sellprice} *= $ref->{exchangerate};
792 $ref->{listprice} *= $ref->{exchangerate};
793 $ref->{lastcost} *= $ref->{exchangerate};
795 # use this for assemblies
796 $onhand = $ref->{onhand};
799 if ($ref->{assemblyitem}) {
801 $onhand = 0 if ($form->{sold});
804 $ref->{description} =~ s/\n/<br>/g;
806 $column_data{number} =
808 . $form->format_amount(\%myconfig, $ref->{number})
810 $column_data{partnumber} =
811 "<td align=$align>$ref->{partnumber} </a></td>";
812 $column_data{description} = "<td>$ref->{description} </td>";
813 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
815 $column_data{onhand} =
817 . $form->format_amount(\%myconfig, $ref->{onhand})
819 $column_data{sellprice} =
821 . $form->format_amount(\%myconfig, $ref->{sellprice})
823 $column_data{listprice} =
825 . $form->format_amount(\%myconfig, $ref->{listprice})
827 $column_data{lastcost} =
829 . $form->format_amount(\%myconfig, $ref->{lastcost})
832 $column_data{linetotalsellprice} = "<td align=right>"
833 . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{sellprice}, 2)
835 $column_data{linetotallastcost} = "<td align=right>"
836 . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{lastcost}, 2)
838 $column_data{linetotallistprice} = "<td align=right>"
839 . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{listprice}, 2)
842 if (!$ref->{assemblyitem}) {
843 $totalsellprice += $onhand * $ref->{sellprice};
844 $totallastcost += $onhand * $ref->{lastcost};
845 $totallistprice += $onhand * $ref->{listprice};
847 $subtotalonhand += $onhand;
848 $subtotalsellprice += $onhand * $ref->{sellprice};
849 $subtotallastcost += $onhand * $ref->{lastcost};
850 $subtotallistprice += $onhand * $ref->{listprice};
855 . $form->format_amount(\%myconfig, $ref->{rop}) . "</td>";
856 $column_data{weight} =
858 . $form->format_amount(\%myconfig, $ref->{weight})
860 $column_data{unit} = "<td>$ref->{unit} </td>";
861 $column_data{bin} = "<td>$ref->{bin} </td>";
862 $column_data{priceupdate} = "<td>$ref->{priceupdate} </td>";
864 $column_data{invnumber} =
865 ($ref->{module} ne 'oe')
866 ? "<td><a href=$ref->{module}.pl?action=edit&type=invoice&id=$ref->{trans_id}&callback=$callback>$ref->{invnumber}</a></td>"
867 : "<td>$ref->{invnumber}</td>";
868 $column_data{ordnumber} =
869 ($ref->{module} eq 'oe')
870 ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&callback=$callback>$ref->{ordnumber}</a></td>"
871 : "<td>$ref->{ordnumber}</td>";
872 $column_data{quonumber} =
873 ($ref->{module} eq 'oe' && !$ref->{ordnumber})
874 ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&callback=$callback>$ref->{quonumber}</a></td>"
875 : "<td>$ref->{quonumber}</td>";
877 $column_data{name} = "<td>$ref->{name}</td>";
879 $column_data{image} =
881 ? "<td><a href=$ref->{image}><img src=$ref->{image} height=32 border=0></a></td>"
883 $column_data{drawing} =
885 ? "<td><a href=$ref->{drawing}>$ref->{drawing}</a></td>"
887 $column_data{microfiche} =
889 ? "<td><a href=$ref->{microfiche}>$ref->{microfiche}</a></td>"
892 $column_data{serialnumber} = "<td>$ref->{serialnumber}</td>";
894 $column_data{soldtotal} = "<td align=right>$ref->{soldtotal}</td>";
898 print "<tr class=listrow$i>";
900 map { print "\n$column_data{$_}" } @column_index;
907 if ($form->{l_subtotal} eq 'Y') {
911 if ($form->{"l_linetotal"}) {
912 map { $column_data{$_} = "<td> </td>" } @column_index;
913 $column_data{linetotalsellprice} =
914 "<th class=listtotal align=right>"
915 . $form->format_amount(\%myconfig, $totalsellprice, 2)
917 $column_data{linetotallastcost} =
918 "<th class=listtotal align=right>"
919 . $form->format_amount(\%myconfig, $totallastcost, 2)
921 $column_data{linetotallistprice} =
922 "<th class=listtotal align=right>"
923 . $form->format_amount(\%myconfig, $totallistprice, 2)
926 print "<tr class=listtotal>";
928 map { print "\n$column_data{$_}" } @column_index;
935 <tr><td colspan=$colspan><hr size=3 noshade></td></tr>
944 <form method=post action=$form->{script}>
946 <input type=hidden name=itemstatus value="$form->{itemstatus}">
947 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
948 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
949 <input type=hidden name=l_description value="$form->{l_description}">
950 <input type=hidden name=l_onhand value="$form->{l_onhand}">
951 <input type=hidden name=l_unit value="$form->{l_unit}">
952 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
953 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
954 <input type=hidden name=sort value="$form->{sort}">
955 <input type=hidden name=revers value="$form->{revers}">
956 <input type=hidden name=lastsort value="$form->{lastsort}">
957 <input type=hidden name=parts value="$form->{parts}">
959 <input type=hidden name=bom value="$form->{bom}">
960 <input type=hidden name=titel value="$form->{titel}">
961 <input type=hidden name=searchitems value="$form->{searchitems}">|;
966 <!-- <input type=hidden name=ndxs_counter value="$form->{ndxs_counter}">-->
968 <input class=submit type=submit name=action value="|
969 . $locale->text('choice') . qq|">
977 $lxdebug->leave_sub();
982 # Warning, deep magic ahead.
983 # This function parses the requested details, sanity checks them, and converts them into a format thats usable for IC->all_parts
985 # flags coming from the form:
987 # searchitems=part revers=0 lastsort=''
990 # partnumber ean description partsgroup serialnumber make model drawing microfiche
991 # transdatefrom transdateto
994 # itemstatus = active | onhand | short | obsolete | orphaned
995 # action = continue | top100
998 # bought sold onorder ordered rfq quoted
999 # l_partnumber l_description l_serialnumber l_unit l_listprice l_sellprice l_lastcost
1000 # l_linetotal l_priceupdate l_bin l_rop l_weight l_image l_drawing l_microfiche
1001 # l_partsgroup l_subtotal l_soldtotal l_deliverydate
1004 # nextsub revers lastsort sort ndxs_counter
1006 sub generate_report {
1007 $lxdebug->enter_sub();
1009 $auth->assert('part_service_assembly_edit');
1011 my ($revers, $lastsort, $description);
1013 $form->{title} = (ucfirst $form->{searchitems}) . "s";
1014 $form->{title} =~ s/ys$/ies/;
1015 $form->{title} = $locale->text($form->{title});
1017 my $revers = $form->{revers};
1018 my $lastsort = $form->{lastsort};
1020 # sorting and direction of sorting
1021 # ToDO: change this to the simpler field+direction method
1022 if (($form->{lastsort} eq "") && ($form->{sort} eq undef)) {
1023 $form->{revers} = 0;
1024 $form->{lastsort} = "partnumber";
1025 $form->{sort} = "partnumber";
1027 if ($form->{lastsort} eq $form->{sort}) {
1028 $form->{revers} = 1 - $form->{revers};
1030 $form->{revers} = 0;
1031 $form->{lastsort} = $form->{sort};
1035 # special case if we have a serialnumber limit search
1036 # serialnumbers are only given in invoices and orders,
1037 # so they can only pop up in bought, sold, rfq, and quoted stuff
1038 $form->{no_sn_joins} = 'Y' if ( !$form->{bought} && !$form->{sold}
1039 && !$form->{rfq} && !$form->{quoted}
1040 && ($form->{l_serialnumber} || $form->{serialnumber}));
1042 # special case for any checkbox of bought | sold | onorder | ordered | rfq | quoted.
1043 # if any of these are ticked the behavior changes slightly for lastcost
1044 # since all those are aggregation checks for the legder tables this is an internal switch
1045 # refered to as ledgerchecks
1046 $form->{ledgerchecks} = 'Y' if ( $form->{bought} || $form->{sold} || $form->{onorder}
1047 || $form->{ordered} || $form->{rfq} || $form->{quoted});
1049 # if something should be activated if something else is active, enter it here
1050 my %dependencies = (
1051 onhand => [ qw(l_onhand) ],
1052 short => [ qw(l_onhand) ],
1053 onorder => [ qw(l_ordnumber) ],
1054 ordered => [ qw(l_ordnumber) ],
1055 rfq => [ qw(l_quonumber) ],
1056 quoted => [ qw(l_quonumber) ],
1057 bought => [ qw(l_invnumber) ],
1058 sold => [ qw(l_invnumber) ],
1059 ledgerchecks => [ qw(l_name) ],
1060 serialnumber => [ qw(l_serialnumber) ],
1061 no_sn_joins => [ qw(bought sold) ],
1064 # these strings get displayed at the top of the results to indicate the user which switches were used
1066 active => $locale->text('Active'),
1067 obsolete => $locale->text('Obsolete'),
1068 orphaned => $locale->text('Orphaned'),
1069 onhand => $locale->text('On Hand'),
1070 short => $locale->text('Short'),
1071 onorder => $locale->text('On Order'),
1072 ordered => $locale->text('Ordered'),
1073 rfq => $locale->text('RFQ'),
1074 quoted => $locale->text('Quoted'),
1075 bought => $locale->text('Bought'),
1076 sold => $locale->text('Sold'),
1077 transdatefrom => $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1),
1078 transdateto => $locale->text('To (time)') . " " . $locale->date(\%myconfig, $form->{transdateto}, 1),
1079 partnumber => $locale->text('Part Number') . ": '$form->{partnumber}'",
1080 partsgroup => $locale->text('Group') . ": '$form->{partsgroup}'",
1081 serialnumber => $locale->text('Serial Number') . ": '$form->{serialnumber}'",
1082 description => $locale->text('Part Description') . ": '$form->{description}'",
1083 make => $locale->text('Make') . ": '$form->{make}'",
1084 model => $locale->text('Model') . ": '$form->{model}'",
1085 drawing => $locale->text('Drawing') . ": '$form->{drawing}'",
1086 microfiche => $locale->text('Microfiche') . ": '$form->{microfiche}'",
1087 l_soldtotal => $locale->text('soldtotal'),
1090 my @itemstatus_keys = qw(active obsolete orphaned onhand short);
1091 my @callback_keys = qw(onorder ordered rfq quoted bought sold partnumber partsgroup serialnumber description make model
1092 drawing microfiche l_soldtotal l_deliverydate transdatefrom transdateto ean);
1094 # calculate dependencies
1095 for (@itemstatus_keys, @callback_keys) {
1096 next if ($form->{itemstatus} ne $_ && !$form->{$_});
1097 map { $form->{$_} = 'Y' } @{ $dependencies{$_} } if $dependencies{$_};
1100 # generate callback and optionstrings
1102 for my $key (@itemstatus_keys, @callback_keys) {
1103 next if ($form->{itemstatus} ne $key && !$form->{$key});
1104 push @options, $optiontexts{$key};
1107 # special case for lastcost
1108 $form->{l_lastcost} = "" if $form->{ledgerchecks};
1110 if ($form->{description}) {
1111 $description = $form->{description};
1112 $description =~ s/\n/<br>/g;
1115 if ($form->{l_linetotal}) {
1116 $form->{l_onhand} = "Y";
1117 $form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
1118 if ($form->{l_lastcost}) {
1119 $form->{l_linetotallastcost} = "Y";
1120 if (($form->{searchitems} eq 'assembly') && !$form->{bom}) {
1121 $form->{l_linetotallastcost} = "";
1124 $form->{l_linetotallistprice} = "Y" if $form->{l_listprice};
1127 if ($form->{searchitems} eq 'service') {
1129 # remove bin, weight and rop from list
1130 map { $form->{"l_$_"} = "" } qw(bin weight rop);
1132 $form->{l_onhand} = "";
1134 # qty is irrelevant unless bought or sold
1135 if ( $form->{bought}
1140 || $form->{quoted}) {
1141 $form->{l_onhand} = "Y";
1143 $form->{l_linetotalsellprice} = "";
1144 $form->{l_linetotallastcost} = "";
1148 IC->all_parts(\%myconfig, \%$form);
1151 qw(partnumber description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice lastcost linetotallastcost
1152 priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal deliverydate);
1155 'bin' => { 'text' => $locale->text('Bin'), },
1156 'deliverydate' => { 'text' => $locale->text('deliverydate'), },
1157 'description' => { 'text' => $locale->text('Part Description'), },
1158 'drawing' => { 'text' => $locale->text('Drawing'), },
1159 'image' => { 'text' => $locale->text('Image'), },
1160 'invnumber' => { 'text' => $locale->text('Invoice Number'), },
1161 'lastcost' => { 'text' => $locale->text('Last Cost'), },
1162 'linetotallastcost' => { 'text' => $locale->text('Extended'), },
1163 'linetotallistprice' => { 'text' => $locale->text('Extended'), },
1164 'linetotalsellprice' => { 'text' => $locale->text('Extended'), },
1165 'listprice' => { 'text' => $locale->text('List Price'), },
1166 'microfiche' => { 'text' => $locale->text('Microfiche'), },
1167 'name' => { 'text' => $locale->text('Name'), },
1168 'onhand' => { 'text' => $locale->text('Qty'), },
1169 'ordnumber' => { 'text' => $locale->text('Order Number'), },
1170 'partnumber' => { 'text' => $locale->text('Part Number'), },
1171 'partsgroup' => { 'text' => $locale->text('Group'), },
1172 'priceupdate' => { 'text' => $locale->text('Updated'), },
1173 'quonumber' => { 'text' => $locale->text('Quotation'), },
1174 'rop' => { 'text' => $locale->text('ROP'), },
1175 'sellprice' => { 'text' => $locale->text('Sell Price'), },
1176 'serialnumber' => { 'text' => $locale->text('Serial Number'), },
1177 'soldtotal' => { 'text' => $locale->text('soldtotal'), },
1178 'unit' => { 'text' => $locale->text('Unit'), },
1179 'weight' => { 'text' => $locale->text('Weight'), },
1182 map { $column_defs{$_}->{visible} = $form->{"l_$_"} ? 1 : 0 } @columns;
1183 map { $column_defs{$_}->{align} = 'right' } qw(onhand sellprice listprice lastcost linetotalsellprice linetotallastcost linetotallistprice rop weight soldtotal);
1185 my @hidden_variables = (qw(l_subtotal l_linetotal searchitems itemstatus bom), @itemstatus_keys, @callback_keys, map { "l_$_" } @columns);
1186 my $callback = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables);
1188 my @sort_full = qw(partnumber description onhand soldtotal deliverydate);
1189 my @sort_no_revers = qw(partsgroup bin priceupdate invnumber ordnumber quonumber name image drawing serialnumber);
1191 foreach my $col (@sort_full) {
1192 $column_defs{$col}->{link} = join '&', $callback, "sort=$col", map { "$_=" . E($form->{$_}) } qw(revers lastsort);
1194 map { $column_defs{$_}->{link} = "${callback}&sort=$_" } @sort_no_revers;
1196 # add order to callback
1197 $form->{callback} = join '&', ($callback, map { "${_}=" . E($form->{$_}) } qw(sort revers));
1199 my $report = SL::ReportGenerator->new(\%myconfig, $form);
1201 my %attachment_basenames = (
1202 'part' => $locale->text('part_list'),
1203 'service' => $locale->text('service_list'),
1204 'assembly' => $locale->text('assembly_list'),
1207 $report->set_options('top_info_text' => $locale->text('Options') . ': ' . join(', ', grep $_, @options),
1208 'raw_bottom_info_text' => $form->parse_html_template('ic/generate_report_bottom'),
1209 'output_format' => 'HTML',
1210 'title' => $form->{title},
1211 'attachment_basename' => $attachment_basenames{$form->{searchitems}} . strftime('_%Y%m%d', localtime time),
1213 $report->set_options_from_form();
1215 $report->set_columns(%column_defs);
1216 $report->set_column_order(@columns);
1218 $report->set_export_options('generate_report', @hidden_variables, qw(sort revers));
1220 $report->set_sort_indicator($form->{sort}, $form->{revers} ? 0 : 1);
1222 my @subtotal_columns = qw(sellprice listprice lastcost);
1223 my %subtotals = map { $_ => 0 } ('onhand', @subtotal_columns);
1224 my %totals = map { $_ => 0 } @subtotal_columns;
1226 my $same_item = $form->{parts}[0]{ $form->{sort} } if (scalar @{ $form->{parts} });
1228 my $defaults = AM->get_defaults();
1231 foreach my $ref (@{ $form->{parts} }) {
1233 # fresh row, for inserting later
1234 my $row = { map { $_ => { 'data' => $ref->{$_} } } @columns };
1236 $ref->{exchangerate} ||= 1;
1237 $ref->{price_factor} ||= 1;
1238 $ref->{sellprice} *= $ref->{exchangerate} / $ref->{price_factor};
1239 $ref->{listprice} *= $ref->{exchangerate} / $ref->{price_factor};
1240 $ref->{lastcost} *= $ref->{exchangerate} / $ref->{price_factor};
1242 # use this for assemblies
1243 my $onhand = $ref->{onhand};
1245 if ($ref->{assemblyitem}) {
1246 $row->{partnumber}{align} = 'right';
1247 $row->{onhand}{data} = 0;
1248 $onhand = 0 if ($form->{sold});
1251 my $edit_link = build_std_url('action=edit', 'id=' . E($ref->{id}), 'callback');
1252 $row->{partnumber}->{link} = $edit_link;
1253 $row->{description}->{link} = $edit_link;
1255 foreach (qw(sellprice listprice lastcost)) {
1256 $row->{$_}{data} = $form->format_amount(\%myconfig, $ref->{$_}, -2);
1257 $row->{"linetotal$_"}{data} = $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{$_}, 2);
1260 map { $row->{$_}{data} = $form->format_amount(\%myconfig, $ref->{$_}); } qw(onhand rop weight soldtotal);
1262 $row->{weight}->{data} .= ' ' . $defaults->{weightunit};
1264 if (!$ref->{assemblyitem}) {
1265 foreach my $col (@subtotal_columns) {
1266 $totals{$col} += $onhand * $ref->{$col};
1267 $subtotals{$col} += $onhand * $ref->{$col};
1270 $subtotals{onhand} += $onhand;
1274 if ($ref->{module} eq 'oe') {
1275 my $edit_oe_link = build_std_url("script=oe.pl", 'action=edit', 'type=' . E($ref->{customer_id} ne '' ? 'sales_order' : 'purchase_order'), 'id=' . E($ref->{trans_id}), 'callback');
1276 $row->{ordnumber}{link} = $edit_oe_link;
1277 $row->{quonumber}{link} = $edit_oe_link if (!$ref->{ordnumber});
1280 $row->{invnumber}{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'type=invoice', 'id=' . E($ref->{trans_id}), 'callback');
1283 # set properties of images
1284 if ($ref->{image} && (lc $report->{options}->{output_format} eq 'html')) {
1285 $row->{image}{data} = '';
1286 $row->{image}{raw_data} = '<a href="' . H($ref->{image}) . '"><img src="' . H($ref->{image}) . '" height="32" border="0"></a>';
1288 map { $row->{$_}{link} = $ref->{$_} } qw(drawing microfiche);
1290 $report->add_data($row);
1292 my $next_ref = $form->{parts}[$idx + 1];
1294 # insert subtotal rows
1295 if (($form->{l_subtotal} eq 'Y') &&
1297 (!$next_ref->{assemblyitem} && ($same_item ne $next_ref->{ $form->{sort} })))) {
1298 my $row = { map { $_ => { 'class' => 'listsubtotal', } } @columns };
1300 if (($form->{searchitems} ne 'assembly') || !$form->{bom}) {
1301 $row->{onhand}->{data} = $form->format_amount(\%myconfig, $subtotals{onhand});
1304 map { $row->{"linetotal$_"}->{data} = $form->format_amount(\%myconfig, $subtotals{$_}, 2) } @subtotal_columns;
1305 map { $subtotals{$_} = 0 } ('onhand', @subtotal_columns);
1307 $report->add_data($row);
1309 $same_item = $next_ref->{ $form->{sort} };
1315 if ($form->{"l_linetotal"}) {
1316 my $row = { map { $_ => { 'class' => 'listtotal', } } @columns };
1318 map { $row->{"linetotal$_"}->{data} = $form->format_amount(\%myconfig, $totals{$_}, 2) } @subtotal_columns;
1320 $report->add_separator();
1321 $report->add_data($row);
1324 $report->generate_with_headers();
1326 $lxdebug->leave_sub();
1327 } #end generate_report
1329 sub parts_subtotal {
1330 $lxdebug->enter_sub();
1332 $auth->assert('part_service_assembly_edit');
1335 our (%column_data, @column_index);
1336 our ($subtotalonhand, $totalsellprice, $totallastcost, $totallistprice, $subtotalsellprice, $subtotallastcost, $subtotallistprice);
1338 map { $column_data{$_} = "<td> </td>" } @column_index;
1339 $subtotalonhand = 0 if ($form->{searchitems} eq 'assembly' && $form->{bom});
1341 $column_data{onhand} =
1342 "<th class=listsubtotal align=right>"
1343 . $form->format_amount(\%myconfig, $subtotalonhand)
1346 $column_data{linetotalsellprice} =
1347 "<th class=listsubtotal align=right>"
1348 . $form->format_amount(\%myconfig, $subtotalsellprice, 2)
1350 $column_data{linetotallistprice} =
1351 "<th class=listsubtotal align=right>"
1352 . $form->format_amount(\%myconfig, $subtotallistprice, 2)
1354 $column_data{linetotallastcost} =
1355 "<th class=listsubtotal align=right>"
1356 . $form->format_amount(\%myconfig, $subtotallastcost, 2)
1359 $subtotalonhand = 0;
1360 $subtotalsellprice = 0;
1361 $subtotallistprice = 0;
1362 $subtotallastcost = 0;
1364 print "<tr class=listsubtotal>";
1366 map { print "\n$column_data{$_}" } @column_index;
1372 $lxdebug->leave_sub();
1376 $lxdebug->enter_sub();
1378 $auth->assert('part_service_assembly_edit');
1380 # show history button
1381 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
1382 #/show hhistory button
1383 IC->get_part(\%myconfig, \%$form);
1385 $form->{"original_partnumber"} = $form->{"partnumber"};
1387 $form->{title} = $locale->text('Edit ' . ucfirst $form->{item});
1392 $lxdebug->leave_sub();
1396 $lxdebug->enter_sub();
1398 $auth->assert('part_service_assembly_edit');
1400 IC->create_links("IC", \%myconfig, \%$form);
1403 map({ $form->{selectcurrency} .= "<option>$_\n" }
1404 split(/:/, $form->{currencies}));
1406 # parts and assemblies have the same links
1407 my $item = $form->{item};
1408 if ($form->{item} eq 'assembly') {
1412 # build the popup menus
1413 $form->{taxaccounts} = "";
1414 foreach my $key (keys %{ $form->{IC_links} }) {
1415 foreach my $ref (@{ $form->{IC_links}{$key} }) {
1417 # if this is a tax field
1418 if ($key =~ /IC_tax/) {
1419 if ($key =~ /\Q$item\E/) {
1420 $form->{taxaccounts} .= "$ref->{accno} ";
1421 $form->{"IC_tax_$ref->{accno}_description"} =
1422 "$ref->{accno}--$ref->{description}";
1425 if ($form->{amount}{ $ref->{accno} }) {
1426 $form->{"IC_tax_$ref->{accno}"} = "checked";
1429 $form->{"IC_tax_$ref->{accno}"} = "checked";
1434 $form->{"select$key"} .=
1435 "<option $ref->{selected}>$ref->{accno}--$ref->{description}\n";
1436 if ($form->{amount}{$key} eq $ref->{accno}) {
1437 $form->{$key} = "$ref->{accno}--$ref->{description}";
1443 chop $form->{taxaccounts};
1445 if (($form->{item} eq "part") || ($form->{item} eq "assembly")) {
1446 $form->{selectIC_income} = $form->{selectIC_sale};
1447 $form->{selectIC_expense} = $form->{selectIC_cogs};
1448 $form->{IC_income} = $form->{IC_sale};
1449 $form->{IC_expense} = $form->{IC_cogs};
1452 delete $form->{IC_links};
1453 delete $form->{amount};
1455 $form->get_partsgroup(\%myconfig, { all => 1 });
1457 $form->{partsgroup} = "$form->{partsgroup}--$form->{partsgroup_id}";
1459 if (@{ $form->{all_partsgroup} }) {
1460 $form->{selectpartsgroup} = qq|<option>\n|;
1461 map { $form->{selectpartsgroup} .= qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n| } @{ $form->{all_partsgroup} };
1464 if ($form->{item} eq 'assembly') {
1466 foreach my $i (1 .. $form->{assembly_rows}) {
1467 if ($form->{"partsgroup_id_$i"}) {
1468 $form->{"partsgroup_$i"} =
1469 qq|$form->{"partsgroup_$i"}--$form->{"partsgroup_id_$i"}|;
1472 $form->get_partsgroup(\%myconfig);
1474 if (@{ $form->{all_partsgroup} }) {
1475 $form->{selectassemblypartsgroup} = qq|<option>\n|;
1478 $form->{selectassemblypartsgroup} .=
1479 qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n|
1480 } @{ $form->{all_partsgroup} };
1483 $lxdebug->leave_sub();
1487 $lxdebug->enter_sub();
1489 $auth->assert('part_service_assembly_edit');
1491 $form->{eur} = $eur; # config dumps into namespace - yuck
1492 $form->{pg_keys} = sub { "$_[0]->{partsgroup}--$_[0]->{id}" };
1493 $form->{description_area} = ($form->{rows} = $form->numtextrows($form->{description}, 40)) > 1;
1494 $form->{notes_rows} = max 4, $form->numtextrows($form->{notes}, 40), $form->numtextrows($form->{formel}, 40);
1496 map { $form->{"is_$_"} = ($form->{item} eq $_) } qw(part service assembly);
1497 map { $form->{$_} =~ s/"/"/g; } qw(unit);
1499 $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS',
1500 'partsgroup' => 'all_partsgroup',
1501 'vendors' => 'ALL_VENDORS',);
1504 IC->retrieve_buchungsgruppen(\%myconfig, $form);
1505 @{ $form->{BUCHUNGSGRUPPEN} } = grep { $_->{id} eq $form->{buchungsgruppen_id} || ($form->{id} && $form->{orphaned}) || !$form->{id} } @{ $form->{BUCHUNGSGRUPPEN} };
1507 # use JavaScript Calendar or not (yes!)
1508 $form->{jsscript} = 1;
1510 $units = AM->retrieve_units(\%myconfig, $form);
1511 $form->{ALL_UNITS} = [ map +{ name => $_ }, sort { $units->{$a}{sortkey} <=> $units->{$b}{sortkey} } keys %$units ];
1513 $form->{defaults} = AM->get_defaults();
1515 $form->{fokus} = "ic.partnumber";
1518 #print $form->parse_html_template('ic/form_header', { ALL_PRICE_FACTORS => $form->{ALL_PRICE_FACTORS},
1519 # ALL_UNITS => $form->{ALL_UNITS},
1520 # BUCHUNGSGRUPPEN => $form->{BUCHUNGSGRUPPEN},
1521 # payment_terms => $form->{payment_terms},
1522 # all_partsgroup => $form->{all_partsgroup}});
1523 print $form->parse_html_template('ic/form_header');
1524 $lxdebug->leave_sub();
1528 $lxdebug->enter_sub();
1530 $auth->assert('part_service_assembly_edit');
1532 print $form->parse_html_template('ic/form_footer');
1534 $lxdebug->leave_sub();
1538 $lxdebug->enter_sub();
1541 my @mm_data = grep { any { $_ ne '' } @$_{qw(make model)} } map +{ make => $form->{"make_$_"}, model => $form->{"model_$_"} }, 1 .. $numrows;
1542 delete @{$form}{grep { m/^make_\d+/ || m/^model_\d+/ } keys %{ $form }};
1543 print $form->parse_html_template('ic/makemodel', { MM_DATA => [ @mm_data, {} ], mm_rows => scalar @mm_data + 1 });
1545 $lxdebug->leave_sub();
1549 $lxdebug->enter_sub();
1551 my (@column_index, %column_data, %column_header);
1552 my ($nochange, $callback, $previousform, $linetotal, $href);
1554 our ($deliverydate); # ToDO: cjeck if this indeed comes from global context
1557 qw(runningnumber qty unit bom partnumber description partsgroup lastcost total);
1559 if ($form->{previousform}) {
1561 @column_index = qw(qty unit bom partnumber description partsgroup total);
1565 $form->{old_callback} = $form->{callback};
1566 $callback = $form->{callback};
1567 $form->{callback} = "$form->{script}?action=display_form";
1570 map { delete $form->{$_} } qw(action header);
1574 # save form variables in a previousform variable
1575 foreach my $key (sort keys %$form) {
1576 next unless ref $form->{$key} eq '' && $form->{$key};
1577 next if $key =~ /^select/; # get rid of these stupid select things
1580 $form->{$key} =~ s/&/%26/g;
1581 if (any { $key eq $_ } qw(sellprice listprice lastcost)) {
1582 $previousform .= sprintf qq|%s=%s&|, $key, $form->format_amount(\%myconfig, $form->{$key});
1584 $previousform .= qq|$key=$form->{$key}&|;
1588 $previousform = $form->escape($form->escape($previousform, 1));
1589 $form->{callback} = $callback;
1591 $form->{assemblytotal} = 0;
1592 $form->{assembly_purchase_price_total} = 0;
1593 $form->{weight} = 0;
1596 $column_header{runningnumber} =
1597 qq|<th nowrap width=5%>| . $locale->text('No.') . qq|</th>|;
1598 $column_header{qty} =
1599 qq|<th align=left nowrap width=10%>| . $locale->text('Qty') . qq|</th>|;
1600 $column_header{unit} =
1601 qq|<th align=left nowrap width=5%>| . $locale->text('Unit') . qq|</th>|;
1602 $column_header{partnumber} =
1603 qq|<th align=left nowrap width=20%>|
1604 . $locale->text('Part Number')
1606 $column_header{description} =
1607 qq|<th nowrap width=50% align="left">| . $locale->text('Part Description') . qq|</th>|;
1608 $column_header{lastcost} =
1609 qq|<th nowrap width=50%>| . $locale->text('Purchase Prices') . qq|</th>|;
1610 $column_header{total} =
1611 qq|<th align=right nowrap>| . $locale->text('Sale Prices') . qq|</th>|;
1612 $column_header{bom} = qq|<th>| . $locale->text('BOM') . qq|</th>|;
1613 $column_header{partsgroup} = qq|<th>| . $locale->text('Group') . qq|</th>|;
1616 <tr class=listheading>
1617 <th class=listheading>| . $locale->text('Individual Items') . qq|</th>
1625 map { print "\n$column_header{$_}" } @column_index;
1631 for my $i (1 .. $numrows) {
1632 $form->{"partnumber_$i"} =~ s/\"/"/g;
1635 $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / ($form->{"price_factor_$i"} || 1), 4);
1636 $line_purchase_price =
1637 $form->round_amount($form->{"lastcost_$i"} * $form->{"qty_$i"} / ($form->{"price_factor_$i"} || 1), 4); #lastcost == purchase_price | ungenaue datenbankfeld-uebersetzung
1638 $form->{assemblytotal} += $linetotal;
1639 $form->{assembly_purchase_price_total} += $line_purchase_price;
1641 $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
1643 $linetotal = $form->format_amount(\%myconfig, $linetotal, 2);
1644 $line_purchase_price = $form->format_amount(\%myconfig, $line_purchase_price, 2);
1646 if (($i >= 1) && ($i == $numrows)) {
1649 map { $column_data{$_} = qq|<td></td>| }
1650 qw(qty unit partnumber description bom partsgroup);
1653 map { $column_data{$_} = qq|<td></td>| } qw(runningnumber unit bom);
1656 qq|<td><input name="qty_$i" size=5 value="$form->{"qty_$i"}"></td>|;
1657 $column_data{partnumber} =
1658 qq|<td><input name="partnumber_$i" size=15 value="$form->{"partnumber_$i"}"></td>|;
1659 $column_data{description} =
1660 qq|<td><input name="description_$i" size=40 value="$form->{"description_$i"}"></td>|;
1661 $column_data{partsgroup} =
1662 qq|<td><input name="partsgroup_$i" size=10 value="$form->{"partsgroup_$i"}"></td>|;
1668 if ($form->{previousform}) {
1669 $column_data{partnumber} =
1670 qq|<td><input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}">$form->{"partnumber_$i"}</td>|;
1672 qq|<td align=right><input type=hidden name="qty_$i" value="$form->{"qty_$i"}">$form->{"qty_$i"}</td>|;
1675 qq|<td align=center><input type=hidden name="bom_$i" value=$form->{"bom_$i"}>|;
1676 $column_data{bom} .= ($form->{"bom_$i"}) ? "x" : " ";
1677 $column_data{bom} .= qq|</td>|;
1679 $column_data{partsgroup} =
1680 qq|<td><input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">$form->{"partsgroup_$i"}</td>|;
1684 qq|$form->{script}?action=edit&id=$form->{"id_$i"}&rowcount=$i&previousform=$previousform|;
1685 $column_data{partnumber} =
1686 qq|<td><input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"><a href=$href>$form->{"partnumber_$i"}</a></td>|;
1687 $column_data{runningnumber} =
1688 qq|<td><input name="runningnumber_$i" size=3 value="$i"></td>|;
1690 qq|<td><input name="qty_$i" size=5 value="$form->{"qty_$i"}"></td>|;
1692 $form->{"bom_$i"} = ($form->{"bom_$i"}) ? "checked" : "";
1694 qq|<td align=center><input name="bom_$i" type=checkbox class=checkbox value=1 $form->{"bom_$i"}></td>|;
1696 $column_data{partsgroup} =
1697 qq|<td><input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">$form->{"partsgroup_$i"}</td>|;
1700 $column_data{unit} =
1701 qq|<td><input type=hidden name="unit_$i" value="$form->{"unit_$i"}">$form->{"unit_$i"}</td>|;
1702 $column_data{description} =
1703 qq|<td><input type=hidden name="description_$i" value="$form->{"description_$i"}">$form->{"description_$i"}</td>|;
1706 $column_data{lastcost} = qq|<td align=right>$line_purchase_price</td>|;
1707 $column_data{total} = qq|<td align=right>$linetotal</td>|;
1709 $column_data{deliverydate} = qq|<td align=right>$deliverydate</td>|;
1714 map { print "\n$column_data{$_}" } @column_index;
1718 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
1719 <input type=hidden name="sellprice_$i" value=$form->{"sellprice_$i"}>
1720 <input type=hidden name="lastcost_$i" value=$form->{"lastcost_$i"}>
1721 <input type=hidden name="weight_$i" value=$form->{"weight_$i"}>
1722 <input type=hidden name="price_factor_id_$i" value=$form->{"price_factor_id_$i"}>
1723 <input type=hidden name="price_factor_$i" value=$form->{"price_factor_$i"}>
1729 <td colspan="6"></td>
1730 <td>| . $locale->text('Totals') . qq|</td>
1731 <td align="right">| . $form->format_amount(\%myconfig, $form->{assembly_purchase_price_total}, 2) .
1733 <td align="right">| . $form->format_amount(\%myconfig, $form->{assemblytotal}, 2) .
1736 <input type="hidden" name="assembly_rows" value="| . $form->{assembly_rows} .
1743 $lxdebug->leave_sub();
1747 $lxdebug->enter_sub();
1749 # parse pricegroups. and no, don't rely on check_form for this...
1750 map { $form->{"price_$_"} = $form->parse_amount(\%myconfig, $form->{"price_$_"}) } 1 .. $form->{price_rows};
1752 if ($form->{item} eq "assembly") {
1753 my $i = $form->{assembly_rows};
1755 # if last row is empty check the form otherwise retrieve item
1756 if ( ($form->{"partnumber_$i"} eq "")
1757 && ($form->{"description_$i"} eq "")
1758 && ($form->{"partsgroup_$i"} eq "")) {
1764 IC->assembly_item(\%myconfig, \%$form);
1766 my $rows = scalar @{ $form->{item_list} };
1769 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
1772 $form->{makemodel_rows}--;
1776 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1777 qw(partnumber description unit partsgroup);
1778 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1779 keys %{ $form->{item_list}[0] };
1780 $form->{"runningnumber_$i"} = $form->{assembly_rows};
1781 $form->{assembly_rows}++;
1789 $form->{rowcount} = $i;
1790 $form->{assembly_rows}++;
1797 } elsif (($form->{item} eq 'part') || ($form->{item} eq 'service')) {
1801 $lxdebug->leave_sub();
1805 $lxdebug->enter_sub();
1807 $auth->assert('part_service_assembly_edit');
1809 my ($parts_id, %newform, $previousform, $amount, $callback);
1811 # check if there is a part number - commented out, cause there is an automatic allocation of numbers
1812 # $form->isblank("partnumber", $locale->text(ucfirst $form->{item}." Part Number missing!"));
1814 # check if there is a description
1815 $form->isblank("description", $locale->text("Part Description missing!"));
1817 if ($form->{obsolete}) {
1820 "Inventory quantity must be zero before you can set this $form->{item} obsolete!"
1822 if ($form->{onhand} * 1);
1825 if (!$form->{buchungsgruppen_id}) {
1826 $form->error($locale->text("Parts must have an entry type.") . " " .
1827 $locale->text("If you see this message, you most likely just setup your LX-Office and haven't added any entry types. If this is the case, the option is accessible for administrators in the System menu.")
1831 $form->error($locale->text('Description must not be empty!')) unless $form->{description};
1832 $form->error($locale->text('Partnumber must not be set to empty!')) if $form->{id} && !$form->{partnumber};
1835 $lxdebug->message($LXDebug::DEBUG1, "ic.pl: sellprice in save = $form->{sellprice}\n");
1836 if (IC->save(\%myconfig, \%$form) == 3) {
1837 $form->error($locale->text('Partnumber not unique!'));
1839 # saving the history
1840 if(!exists $form->{addition}) {
1841 $form->{snumbers} = qq|partnumber_| . $form->{partnumber};
1842 $form->{addition} = "SAVED";
1843 $form->save_history($form->dbconnect(\%myconfig));
1845 # /saving the history
1846 $parts_id = $form->{id};
1849 # load previous variables
1850 if ($form->{previousform}) {
1852 # save the new form variables before splitting previousform
1853 map { $newform{$_} = $form->{$_} } keys %$form;
1855 $previousform = $form->unescape($form->{previousform});
1857 # don't trample on previous variables
1858 map { delete $form->{$_} } keys %newform;
1860 # now take it apart and restore original values
1861 foreach my $item (split /&/, $previousform) {
1862 my ($key, $value) = split m/=/, $item, 2;
1863 $value =~ s/%26/&/g;
1864 $form->{$key} = $value;
1866 $form->{taxaccounts} = $newform{taxaccount2};
1868 if ($form->{item} eq 'assembly') {
1870 # undo number formatting
1871 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1872 qw(weight listprice sellprice rop);
1874 $form->{assembly_rows}--;
1875 $i = $newform{rowcount};
1876 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
1878 $form->{sellprice} -= $form->{"sellprice_$i"} * $form->{"qty_$i"};
1879 $form->{weight} -= $form->{"weight_$i"} * $form->{"qty_$i"};
1881 # change/add values for assembly item
1882 map { $form->{"${_}_$i"} = $newform{$_} } qw(partnumber description bin unit weight listprice sellprice inventory_accno income_accno expense_accno price_factor_id);
1884 # das ist __voll__ bekloppt, dass so auszurechnen jb 22.5.09
1885 #$form->{sellprice} += $form->{"sellprice_$i"} * $form->{"qty_$i"};
1886 $form->{weight} += $form->{"weight_$i"} * $form->{"qty_$i"};
1890 # set values for last invoice/order item
1891 $i = $form->{rowcount};
1892 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
1894 map { $form->{"${_}_$i"} = $newform{$_} } qw(partnumber description bin unit listprice inventory_accno income_accno expense_accno sellprice lastcost price_factor_id);
1896 $form->{"longdescription_$i"} = $newform{notes};
1898 $form->{"sellprice_$i"} = $newform{lastcost} if ($form->{vendor_id});
1900 if ($form->{exchangerate} != 0) {
1901 $form->{"sellprice_$i"} /= $form->{exchangerate};
1904 $lxdebug->message($LXDebug::DEBUG1, qq|sellprice_$i in previousform 2 = | . $form->{"sellprice_$i"} . qq|\n|);
1906 map { $form->{"taxaccounts_$i"} .= "$_ " } split / /, $newform{taxaccount};
1907 chop $form->{"taxaccounts_$i"};
1908 foreach my $item (qw(description rate taxnumber)) {
1909 my $index = $form->{"taxaccounts_$i"} . "_$item";
1910 $form->{$index} = $newform{$index};
1913 # credit remaining calculation
1914 $amount = $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) * $form->{"qty_$i"};
1916 map { $form->{"${_}_base"} += $amount } (split / /, $form->{"taxaccounts_$i"});
1917 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{"taxaccounts_$i"} if !$form->{taxincluded};
1919 $form->{creditremaining} -= $amount;
1921 # redo number formatting, because invoice parse them!
1922 map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}) } qw(weight listprice sellprice rop);
1925 $form->{"id_$i"} = $parts_id;
1927 # Get the actual price factor (not just the ID) for the marge calculation.
1928 $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS');
1929 foreach my $pfac (@{ $form->{ALL_PRICE_FACTORS} }) {
1930 next if ($pfac->{id} != $newform{price_factor_id});
1931 $form->{"marge_price_factor_$i"} = $pfac->{factor};
1934 delete $form->{ALL_PRICE_FACTORS};
1936 delete $form->{action};
1938 # restore original callback
1939 $callback = $form->unescape($form->{callback});
1940 $form->{callback} = $form->unescape($form->{old_callback});
1941 delete $form->{old_callback};
1943 $form->{makemodel_rows}--;
1945 # put callback together
1946 foreach my $key (keys %$form) {
1948 # do single escape for Apache 2.0
1949 my $value = $form->escape($form->{$key}, 1);
1950 $callback .= qq|&$key=$value|;
1952 $form->{callback} = $callback;
1954 $lxdebug->message($LXDebug::DEBUG1, qq|ic.pl: sellprice_$i nach sub save = | . $form->{"sellprice_$i"} . qq|\n|);
1959 $lxdebug->leave_sub();
1963 $lxdebug->enter_sub();
1965 $auth->assert('part_service_assembly_edit');
1967 # saving the history
1968 if(!exists $form->{addition}) {
1969 $form->{snumbers} = qq|partnumber_| . $form->{partnumber};
1970 $form->{addition} = "SAVED AS NEW";
1971 $form->save_history($form->dbconnect(\%myconfig));
1973 # /saving the history
1975 if ($form->{"original_partnumber"} &&
1976 ($form->{"partnumber"} eq $form->{"original_partnumber"})) {
1977 $form->{partnumber} = "";
1980 $lxdebug->leave_sub();
1984 $lxdebug->enter_sub();
1986 $auth->assert('part_service_assembly_edit');
1988 # saving the history
1989 if(!exists $form->{addition}) {
1990 $form->{snumbers} = qq|partnumber_| . $form->{partnumber};
1991 $form->{addition} = "DELETED";
1992 $form->save_history($form->dbconnect(\%myconfig));
1994 # /saving the history
1995 my $rc = IC->delete(\%myconfig, \%$form);
1998 $form->redirect($locale->text('Item deleted!')) if ($rc > 0);
1999 $form->error($locale->text('Cannot delete item!'));
2001 $lxdebug->leave_sub();
2005 $lxdebug->enter_sub();
2007 $auth->assert('part_service_assembly_edit');
2012 pricegroup => $form->{"pricegroup_$_"},
2013 pricegroup_id => $form->{"pricegroup_id_$_"},
2014 price => $form->{"price_$_"},
2017 print $form->parse_html_template('ic/price_row', { PRICES => \@PRICES });
2019 $lxdebug->leave_sub();
2022 sub parts_language_selection {
2023 $lxdebug->enter_sub();
2025 $auth->assert('part_service_assembly_edit');
2029 my $languages = IC->retrieve_languages(\%myconfig, $form);
2031 if ($form->{language_values} ne "") {
2032 foreach $item (split(/---\+\+\+---/, $form->{language_values})) {
2033 my ($language_id, $translation, $longdescription) = split(/--\+\+--/, $item);
2035 foreach my $language (@{ $languages }) {
2036 next unless ($language->{id} == $language_id);
2038 $language->{translation} = $translation;
2039 $language->{longdescription} = $longdescription;
2045 my @header_sort = qw(name longdescription);
2046 my %header_title = ( "name" => $locale->text("Name"),
2047 "longdescription" => $locale->text("Long Description"),
2051 map(+{ "column_title" => $header_title{$_},
2053 "callback" => $callback,
2057 $form->{"title"} = $locale->text("Language Values");
2059 print $form->parse_html_template("ic/parts_language_selection", { "HEADER" => \@header,
2060 "LANGUAGES" => $languages,
2061 "onload" => $onload });
2063 $lxdebug->leave_sub();
2066 sub continue { call_sub($form->{"nextsub"}); }