1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #############################################################################
7 # Veraendert 2005-01-05 - Marco Welter <mawe@linux-studio.de> - Neue Optik #
8 #############################################################################
9 # SQL-Ledger, Accounting
10 # Copyright (c) 1998-2002
12 # Author: Dieter Simader
13 # Email: dsimader@sql-ledger.org
14 # Web: http://www.sql-ledger.org
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #######################################################################
32 # common routines used in is, ir, oe
34 #######################################################################
41 require "$form->{path}/common.pl";
43 # any custom scripts for this one
44 if (-f "$form->{path}/custom_io.pl") {
45 eval { require "$form->{path}/custom_io.pl"; };
47 if (-f "$form->{path}/$form->{login}_io.pl") {
48 eval { require "$form->{path}/$form->{login}_io.pl"; };
55 # this is for our long dates
56 # $locale->text('January')
57 # $locale->text('February')
58 # $locale->text('March')
59 # $locale->text('April')
60 # $locale->text('May ')
61 # $locale->text('June')
62 # $locale->text('July')
63 # $locale->text('August')
64 # $locale->text('September')
65 # $locale->text('October')
66 # $locale->text('November')
67 # $locale->text('December')
69 # this is for our short month
70 # $locale->text('Jan')
71 # $locale->text('Feb')
72 # $locale->text('Mar')
73 # $locale->text('Apr')
74 # $locale->text('May')
75 # $locale->text('Jun')
76 # $locale->text('Jul')
77 # $locale->text('Aug')
78 # $locale->text('Sep')
79 # $locale->text('Oct')
80 # $locale->text('Nov')
81 # $locale->text('Dec')
86 ########################################
87 # Eintrag fuer Version 2.2.0 geaendert #
88 # neue Optik im Rechnungsformular #
89 ########################################
91 $lxdebug->enter_sub();
94 if ($lizenzen && $form->{vc} eq "customer") {
95 if ($form->{type} =~ /sales_order/) {
96 @column_index = (runningnumber, partnumber, description, ship, qty);
97 } elsif ($form->{type} =~ /sales_quotation/) {
98 @column_index = (runningnumber, partnumber, description, qty);
100 @column_index = (runningnumber, partnumber, description, qty);
103 if ( ($form->{type} =~ /purchase_order/)
104 || ($form->{type} =~ /sales_order/)) {
105 @column_index = (runningnumber, partnumber, description, ship, qty);
107 @column_index = (runningnumber, partnumber, description, qty);
110 ############## ENDE Neueintrag ##################
112 my $dimension_units = AM->retrieve_units(\%myconfig, $form, "dimension");
113 my $service_units = AM->retrieve_units(\%myconfig, $form, "service");
114 my $all_units = AM->retrieve_units(\%myconfig, $form);
116 push @column_index, qw(unit);
118 #for pricegroups column
119 if ( $form->{type} =~ (/sales_quotation/)
120 or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
121 or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
122 or ($form->{type} =~ /sales_order/)) {
123 push @column_index, qw(sellprice_pg);
126 push @column_index, qw(sellprice);
128 if ($form->{vc} eq 'customer') {
129 push @column_index, qw(discount);
132 push @column_index, "linetotal";
134 my $colspan = $#column_index + 1;
136 $form->{invsubtotal} = 0;
137 map { $form->{"${_}_base"} = 0 } (split(/ /, $form->{taxaccounts}));
139 ########################################
140 # Eintrag fuer Version 2.2.0 geaendert #
141 # neue Optik im Rechnungsformular #
142 ########################################
143 $column_data{runningnumber} =
144 qq|<th align=left nowrap width=5 class=listheading>|
145 . $locale->text('No.')
147 $column_data{partnumber} =
148 qq|<th align=left nowrap width=12 class=listheading>|
149 . $locale->text('Number')
151 $column_data{description} =
152 qq|<th align=left nowrap width=30 class=listheading>|
153 . $locale->text('Part Description')
155 if ($form->{"type"} eq "purchase_order") {
157 qq|<th align=left nowrap width=5 class=listheading>|
158 . $locale->text('Ship rcvd')
162 qq|<th align=left nowrap width=5 class=listheading>|
163 . $locale->text('Ship')
167 qq|<th align=left nowrap width=5 class=listheading>|
168 . $locale->text('Qty')
171 qq|<th align=left nowrap width=5 class=listheading>|
172 . $locale->text('Unit')
174 $column_data{license} =
175 qq|<th align=left nowrap width=10 class=listheading>|
176 . $locale->text('License')
178 $column_data{serialnr} =
179 qq|<th align=left nowrap width=10 class=listheading>|
180 . $locale->text('Serial No.')
182 $column_data{projectnr} =
183 qq|<th align=left nowrap width=10 class=listheading>|
184 . $locale->text('Project')
186 $column_data{sellprice} =
187 qq|<th align=left nowrap width=15 class=listheading>|
188 . $locale->text('Price')
190 $column_data{sellprice_pg} =
191 qq|<th align=left nowrap width=15 class=listheading>|
192 . $locale->text('Pricegroup')
194 $column_data{discount} =
195 qq|<th align=left class=listheading>|
196 . $locale->text('Discount')
198 $column_data{linetotal} =
199 qq|<th align=left nowrap width=10 class=listheading>|
200 . $locale->text('Extended')
203 qq|<th align=left nowrap width=10 class=listheading>|
204 . $locale->text('Bin')
206 ############## ENDE Neueintrag ##################
208 $myconfig{"show_form_details"} = 1
209 unless (defined($myconfig{"show_form_details"}));
210 $form->{"show_details"} = $myconfig{"show_form_details"}
211 unless (defined($form->{"show_details"}));
212 $form->{"show_details"} = $form->{"show_details"} ? 1 : 0;
213 my $show_details_new = 1 - $form->{"show_details"};
214 my $show_details_checked = $form->{"show_details"} ? "checked" : "";
219 <input type="hidden" name="show_details" value="$form->{show_details}">
220 <input type="checkbox" id="cb_show_details" onclick="show_form_details($show_details_new);" $show_details_checked>
221 <label for="cb_show_details">| . $locale->text("Show details") . qq|</label><br>
223 <tr class=listheading>|;
225 map { print "\n$column_data{$_}" } @column_index;
231 $runningnumber = $locale->text('No.');
232 $deliverydate = $locale->text('Delivery Date');
233 $serialnumber = $locale->text('Serial No.');
234 $projectnumber = $locale->text('Project');
235 $partsgroup = $locale->text('Group');
236 $reqdate = $locale->text('Reqdate');
238 $delvar = 'deliverydate';
240 if ($form->{type} =~ /_order$/ || $form->{type} =~ /_quotation$/) {
241 $deliverydate = $locale->text('Required by');
245 my %projectnumber_labels = ();
246 my @projectnumber_values = ("");
247 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
248 push(@projectnumber_values, $item->{"id"});
249 $projectnumber_labels{$item->{"id"}} = $item->{"projectnumber"};
252 for $i (1 .. $numrows) {
257 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
258 } qw(qty ship discount sellprice price_new price_old) unless ($form->{simple_save});
260 if (!$form->{"unit_old_$i"}) {
261 # Neue Ware aus der Datenbank. In diesem Fall ist unit_$i die
262 # Einheit, wie sie in den Stammdaten hinterlegt wurde.
263 # Es sollte also angenommen werden, dass diese ausgewaehlt war.
264 $form->{"unit_old_$i"} = $form->{"unit_$i"};
269 # Die zuletzt ausgewaehlte mit der aktuell ausgewaehlten Einheit
270 # vergleichen und bei Unterschied den Preis entsprechend umrechnen.
271 $form->{"selected_unit_$i"} = $form->{"unit_$i"} unless ($form->{"selected_unit_$i"});
273 my $check_units = $form->{"inventory_accno_$i"} ? $dimension_units : $service_units;
274 if (!$check_units->{$form->{"selected_unit_$i"}} ||
275 ($check_units->{$form->{"selected_unit_$i"}}->{"base_unit"} ne
276 $all_units->{$form->{"unit_old_$i"}}->{"base_unit"})) {
277 # Die ausgewaehlte Einheit ist fuer diesen Artikel nicht gueltig
278 # (z.B. Dimensionseinheit war ausgewaehlt, es handelt sich aber
279 # um eine Dienstleistung). Dann keinerlei Umrechnung vornehmen.
280 $form->{"unit_old_$i"} = $form->{"selected_unit_$i"} = $form->{"unit_$i"};
282 if ((!$form->{"prices_$i"}) || ($form->{"new_pricegroup_$i"} == $form->{"old_pricegroup_$i"})) {
283 if ($form->{"unit_old_$i"} ne $form->{"selected_unit_$i"}) {
285 if (defined($all_units->{$form->{"unit_old_$i"}}->{"factor"}) &&
286 $all_units->{$form->{"unit_old_$i"}}->{"factor"}) {
287 $basefactor = $all_units->{$form->{"selected_unit_$i"}}->{"factor"} /
288 $all_units->{$form->{"unit_old_$i"}}->{"factor"};
290 $form->{"sellprice_$i"} *= $basefactor;
291 $form->{"unit_old_$i"} = $form->{"selected_unit_$i"};
294 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
296 $decimalplaces = ($dec > 2) ? $dec : 2;
300 $form->{"sellprice_$i"} * $form->{"discount_$i"} / 100,
304 $form->round_amount($form->{"sellprice_$i"} - $discount, $decimalplaces);
305 $linetotal = $form->round_amount($linetotal * $form->{"qty_$i"}, 2);
307 # convert " to "
308 map { $form->{"${_}_$i"} =~ s/\"/"/g }
309 qw(partnumber description unit unit_old);
311 ########################################
312 # Eintrag fuer Version 2.2.0 geaendert #
313 # neue Optik im Rechnungsformular #
314 ########################################
315 $column_data{runningnumber} =
316 qq|<td><input name="runningnumber_$i" size=5 value=$i></td>|; # HuT
317 ############## ENDE Neueintrag ##################
319 $column_data{partnumber} =
320 qq|<td><input name="partnumber_$i" size=12 value="$form->{"partnumber_$i"}"></td>|;
322 if (($rows = $form->numtextrows($form->{"description_$i"}, 30, 6)) > 1) {
323 $column_data{description} =
324 qq|<td><textarea name="description_$i" rows=$rows cols=30 wrap=soft>| . H($form->{"description_$i"}) . qq|</textarea><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|;
326 $column_data{description} =
327 qq|<td><input name="description_$i" size=30 value="| . $form->quote($form->{"description_$i"}) . qq|"><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|;
330 (my $qty_dec) = ($form->{"qty_$i"} =~ /\.(\d+)/);
331 $qty_dec = length $qty_dec;
334 qq|<td align=right><input name="qty_$i" size=5 value=|
335 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec) .qq|>|;
336 if ($form->{"formel_$i"}) {
337 $column_data{qty} .= qq|<button type="button" onclick="calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)">| . $locale->text('*/') . qq|</button>
338 <input type=hidden name="formel_$i" value="$form->{"formel_$i"}"><input type=hidden name="alu_$i" value="$form->{"alu_$i"}"></td>|;
341 qq|<td align=right><input name="ship_$i" size=5 value=|
342 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
345 my $is_part = $form->{"inventory_accno_$i"};
346 my $is_assigned = $form->{"id_$i"};
347 my $this_unit = $form->{"unit_$i"};
348 if ($form->{"selected_unit_$i"} && $this_unit &&
349 $all_units->{$form->{"selected_unit_$i"}} && $all_units->{$this_unit} &&
350 ($all_units->{$form->{"selected_unit_$i"}}->{"base_unit"} eq $all_units->{$this_unit}->{"base_unit"})) {
351 $this_unit = $form->{"selected_unit_$i"};
352 } elsif (!$is_assigned ||
353 ($is_part && !$this_unit && ($all_units->{$this_unit} && ($all_units->{$this_unit}->{"base_unit"} eq $all_units->{"kg"}->{"base_unit"})))) {
357 $column_data{"unit"} = "<td>" .
358 ($qty_readonly ? " " :
359 AM->unit_select_html($is_part ? $dimension_units :
360 $is_assigned ? $service_units : $all_units,
361 "unit_$i", $this_unit,
362 $is_assigned ? $form->{"unit_$i"} : undef))
365 # build in drop down list for pricesgroups
366 if ($form->{"prices_$i"}) {
367 if ($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"}) {
368 $price_tmp = $form->format_amount(\%myconfig, $form->{"price_new_$i"}, $decimalplaces);
370 $price_tmp = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
373 $column_data{sellprice_pg} =
374 qq|<td align=right><select name="sellprice_pg_$i">$form->{"prices_$i"}</select></td>|;
375 $column_data{sellprice} =
376 qq|<td><input name="sellprice_$i" size=10 value=$price_tmp></td>|;
379 # for last row and report
380 # set pricegroup drop down list from report menu
381 if ($form->{"sellprice_$i"} != 0) {
383 qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|;
385 $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"};
387 $column_data{sellprice_pg} =
388 qq|<td align=right><select name="sellprice_pg_$i">$prices</select></td>|;
393 $column_data{sellprice_pg} = qq|<td align=right> </td>|;
396 $column_data{sellprice} =
397 qq|<td><input name="sellprice_$i" size=10 value=|
398 . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
402 $column_data{discount} =
403 qq|<td align=right><input name="discount_$i" size=3 value=|
404 . $form->format_amount(\%myconfig, $form->{"discount_$i"})
406 $column_data{linetotal} =
408 . $form->format_amount(\%myconfig, $linetotal, 2)
410 $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
412 ########################################
413 # Eintrag fuer Version 2.2.0 geaendert #
414 # neue Optik im Rechnungsformular #
415 ########################################
416 # if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
417 # $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|;
420 # if ($form->{type} !~ /_quotation/) {
421 # $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|;
424 # $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|;
425 ############## ENDE Neueintrag ##################
429 <tr valign=top class=listrow$j>|;
431 map { print "\n$column_data{$_}" } @column_index;
436 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
437 <input type=hidden name="bo_$i" value=$form->{"bo_$i"}>
439 <input type=hidden name="pricegroup_old_$i" value=$form->{"pricegroup_old_$i"}>
440 <input type=hidden name="price_old_$i" value=$form->{"price_old_$i"}>
441 <input type=hidden name="unit_old_$i" value="| . $form->quote($form->{"selected_unit_$i"}) . qq|">
442 <input type=hidden name="price_new_$i" value=|
443 . $form->format_amount(\%myconfig, $form->{"price_new_$i"}) . qq|>
445 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
446 <input type=hidden name="inventory_accno_$i" value=$form->{"inventory_accno_$i"}>
447 <input type=hidden name="bin_$i" value="$form->{"bin_$i"}">
448 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
449 <input type=hidden name="partnotes_$i" value="| . $form->quote($form->{"partnotes_$i"}) . qq|">
450 <input type=hidden name="income_accno_$i" value=$form->{"income_accno_$i"}>
451 <input type=hidden name="expense_accno_$i" value=$form->{"expense_accno_$i"}>
452 <input type=hidden name="listprice_$i" value="$form->{"listprice_$i"}">
453 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
454 <input type=hidden name="taxaccounts_$i" value="$form->{"taxaccounts_$i"}">
455 <input type=hidden name="ordnumber_$i" value="$form->{"ordnumber_$i"}">
456 <input type=hidden name="transdate_$i" value="$form->{"transdate_$i"}">
457 <input type=hidden name="cusordnumber_$i" value="$form->{"cusordnumber_$i"}">
458 <input type=hidden name="longdescription_$i" value="| . $form->quote($form->{"longdescription_$i"}) . qq|">
459 <input type=hidden name="basefactor_$i" value="$form->{"basefactor_$i"}">
463 ########################################
464 # Eintrag fuer Version 2.2.0 geaendert #
465 # neue Optik im Rechnungsformular #
466 ########################################
469 'style="display:none;"' if (!$form->{"show_details"});
473 <tr class=listrow$j $row_style_attr>
474 <td colspan=$colspan>
476 if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
477 my $selected = $form->{"licensenumber_$i"};
479 $form->{"lizenzen_$i"} =~ s/ selected//g;
480 $form->{"lizenzen_$i"} =~
481 s/value="${selected}"\>/value="${selected}" selected\>/;
482 $lizenzen_quoted = $form->{"lizenzen_$i"};
483 $lizenzen_quoted =~ s/\"/"/g;
485 <b>Lizenz\#</b> <select name="licensenumber_$i" size=1>
486 $form->{"lizenzen_$i"}
488 <input type=hidden name="lizenzen_$i" value="${lizenzen_quoted}">
491 if ($form->{type} !~ /_quotation/) {
493 <b>$serialnumber</b> <input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}">|;
496 print qq|<b>$projectnumber</b> | .
497 NTI($cgi->popup_menu('-name' => "project_id_$i",
498 '-values' => \@projectnumber_values,
499 '-labels' => \%projectnumber_labels,
500 '-default' => $form->{"project_id_$i"}));
502 if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) {
504 ($form->{type} eq 'invoice')
506 : 'reqdate'; # invoice uses a different term for the same thing.
508 <b>${$reqdate_term}</b> <input name="${reqdate_term}_$i" size=11 value="$form->{"${reqdate_term}_$i"}">
511 my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : "";
513 <b>|.$locale->text('Subtotal').qq|</b> <input type="checkbox" name="subtotal_$i" value="1" "$subtotalchecked">
519 ############## ENDE Neueintrag ##################
521 map { $form->{"${_}_base"} += $linetotal }
522 (split(/ /, $form->{"taxaccounts_$i"}));
524 $form->{invsubtotal} += $linetotal;
533 $lxdebug->leave_sub();
536 ##################################################
537 # build html-code for pricegroups in variable $form->{prices_$j}
540 $lxdebug->enter_sub();
541 my $rowcount = shift;
542 for $j (1 .. $rowcount) {
543 my $pricegroup_old = $form->{"pricegroup_old_$i"};
544 if ($form->{PRICES}{$j}) {
546 $prices = '<option value="--">' . $locale->text("none (pricegroup)") . '</option>';
548 foreach $item (@{ $form->{PRICES}{$j} }) {
550 #$price = $form->round_amount($myconfig, $item->{price}, 5);
551 #$price = $form->format_amount($myconfig, $item->{price}, 2);
552 $price = $item->{price};
553 $pricegroup_id = $item->{pricegroup_id};
554 $pricegroup = $item->{pricegroup};
556 # build drop down list for pricegroups
558 qq|<option value="$price--$pricegroup_id"$item->{selected}>$pricegroup</option>\n|;
563 # $form->{"${_}_$j"} =
564 # $form->format_amount(\%myconfig, $form->{"${_}_$j"})
565 # } qw(sellprice price_new price_old);
567 # set new selectedpricegroup_id and prices for "Preis"
568 if ($item->{selected} && ($pricegroup_id != 0)) {
569 $form->{"pricegroup_old_$j"} = $pricegroup_id;
570 $form->{"price_new_$j"} = $price;
571 $form->{"sellprice_$j"} = $price;
573 if ($pricegroup_id == 0) {
574 $form->{"price_new_$j"} = $form->{"sellprice_$j"};
577 $form->{"prices_$j"} = $prices;
580 $lxdebug->leave_sub();
584 $lxdebug->enter_sub();
585 @column_index = qw(ndx partnumber description onhand unit sellprice);
587 $column_data{ndx} = qq|<th> </th>|;
588 $column_data{partnumber} =
589 qq|<th class=listheading>| . $locale->text('Number') . qq|</th>|;
590 $column_data{description} =
591 qq|<th class=listheading>| . $locale->text('Part Description') . qq|</th>|;
592 $column_data{sellprice} =
593 qq|<th class=listheading>| . $locale->text('Price') . qq|</th>|;
594 $column_data{onhand} =
595 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
597 qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
598 # list items with radio button on a form
601 $title = $locale->text('Select from one of the items below');
602 $colspan = $#column_index + 1;
607 <form method=post action=$form->{script}>
611 <th class=listtop colspan=$colspan>$title</th>
614 <tr class=listheading>|;
616 map { print "\n$column_data{$_}" } @column_index;
621 foreach $ref (@{ $form->{item_list} }) {
622 $checked = ($i++) ? "" : "checked";
625 if ($ref->{inventory_accno} > 0) {
626 $ref->{"lizenzen"} = qq|<option></option>|;
627 foreach $item (@{ $form->{LIZENZEN}{ $ref->{"id"} } }) {
628 $ref->{"lizenzen"} .=
629 qq|<option value=\"$item->{"id"}\">$item->{"licensenumber"}</option>|;
631 $ref->{"lizenzen"} .= qq|<option value=-1>Neue Lizenz</option>|;
632 $ref->{"lizenzen"} =~ s/\"/"/g;
636 map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description unit);
640 $form->round_amount($ref->{sellprice} * (1 - $form->{tradediscount}), 2);
642 qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
643 $column_data{partnumber} =
644 qq|<td><input name="new_partnumber_$i" type=hidden value="$ref->{partnumber}">$ref->{partnumber}</td>|;
645 $column_data{description} =
646 qq|<td><input name="new_description_$i" type=hidden value="$ref->{description}">$ref->{description}</td>|;
647 $column_data{sellprice} =
648 qq|<td align=right><input name="new_sellprice_$i" type=hidden value=$ref->{sellprice}>|
649 . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ")
651 $column_data{onhand} =
652 qq|<td align=right><input name="new_onhand_$i" type=hidden value=$ref->{onhand}>|
653 . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
656 qq|<td>$ref->{unit}</td>|;
660 <tr class=listrow$j>|;
662 map { print "\n$column_data{$_}" } @column_index;
667 <input name="new_bin_$i" type=hidden value="$ref->{bin}">
668 <input name="new_listprice_$i" type=hidden value=$ref->{listprice}>
669 <input name="new_inventory_accno_$i" type=hidden value=$ref->{inventory_accno}>
670 <input name="new_income_accno_$i" type=hidden value=$ref->{income_accno}>
671 <input name="new_expense_accno_$i" type=hidden value=$ref->{expense_accno}>
672 <input name="new_unit_$i" type=hidden value="$ref->{unit}">
673 <input name="new_weight_$i" type=hidden value="$ref->{weight}">
674 <input name="new_assembly_$i" type=hidden value="$ref->{assembly}">
675 <input name="new_taxaccounts_$i" type=hidden value="$ref->{taxaccounts}">
676 <input name="new_partsgroup_$i" type=hidden value="$ref->{partsgroup}">
677 <input name="new_formel_$i" type=hidden value="$ref->{formel}">
678 <input name="new_longdescription_$i" type=hidden value="| . Q($ref->{longdescription}) . qq|">
679 <input name="new_not_discountable_$i" type=hidden value="$ref->{not_discountable}">
680 <input name="new_part_payment_id_$i" type=hidden value="$ref->{part_payment_id}">
681 <input name="new_partnotes_$i" type="hidden" value="| . Q($ref->{"partnotes"}) . qq|">
683 <input name="new_id_$i" type=hidden value=$ref->{id}>
688 <input name="new_lizenzen_$i" type=hidden value="$ref->{lizenzen}">
695 <tr><td colspan=8><hr size=3 noshade></td></tr>
698 <input name=lastndx type=hidden value=$i>
702 # delete action variable
703 map { delete $form->{$_} } qw(action item_list header);
705 # save all other form variables
706 foreach $key (keys %${form}) {
707 $form->{$key} =~ s/\"/"/g;
708 print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
712 <input type=hidden name=nextsub value=item_selected>
715 <input class=submit type=submit name=action value="|
716 . $locale->text('Continue') . qq|">
723 $lxdebug->leave_sub();
727 $lxdebug->enter_sub();
729 # replace the last row with the checked row
730 $i = $form->{rowcount};
731 $i = $form->{assembly_rows} if ($form->{item} eq 'assembly');
737 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
738 #$form->{"sellprice_$i"} = $form->{"sellprice_$i"};
740 # if there was a price entered, override it
741 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
743 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} }
744 qw(id partnumber description sellprice listprice inventory_accno
745 income_accno expense_accno bin unit weight assembly taxaccounts
746 partsgroup formel longdescription not_discountable partnotes);
747 if ($form->{"part_payment_id_$i"} ne "") {
748 $form->{payment_id} = $form->{"part_payment_id_$i"};
752 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } qw(lizenzen);
755 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
757 $decimalplaces = ($dec > 2) ? $dec : 2;
760 $form->{"sellprice_$i"} = $sellprice;
763 # if there is an exchange rate adjust sellprice
764 if (($form->{exchangerate} * 1) != 0) {
765 $form->{"sellprice_$i"} /= $form->{exchangerate};
766 $form->{"sellprice_$i"} =
767 $form->round_amount($form->{"sellprice_$i"}, $decimalplaces);
771 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
772 qw(sellprice listprice weight);
774 $form->{sellprice} += ($form->{"sellprice_$i"} * $form->{"qty_$i"});
775 $form->{weight} += ($form->{"weight_$i"} * $form->{"qty_$i"});
777 if ($form->{"not_discountable_$i"}) {
778 $form->{"discount_$i"} = 0;
782 $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
784 map { $form->{"${_}_base"} += $amount }
785 (split / /, $form->{"taxaccounts_$i"});
786 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /,
787 $form->{"taxaccounts_$i"}
788 if !$form->{taxincluded};
790 $form->{creditremaining} -= $amount;
792 $form->{"runningnumber_$i"} = $i;
794 # delete all the new_ variables
795 for $i (1 .. $form->{lastndx}) {
796 map { delete $form->{"new_${_}_$i"} }
797 qw(partnumber description sellprice bin listprice inventory_accno income_accno expense_accno unit assembly taxaccounts id);
800 map { delete $form->{$_} } qw(ndx lastndx nextsub);
805 $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
806 } qw(sellprice listprice) if $form->{item} ne 'assembly';
808 # get pricegroups for parts
809 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
811 # build up html code for prices_$i
812 set_pricegroup($form->{rowcount});
816 $lxdebug->leave_sub();
820 $lxdebug->enter_sub();
823 $form->{old_callback} = $form->escape($form->{callback}, 1);
824 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
827 delete $form->{action};
829 # save all other form variables in a previousform variable
830 foreach $key (keys %$form) {
833 $form->{$key} =~ s/&/%26/g;
834 $previousform .= qq|$key=$form->{$key}&|;
837 $previousform = $form->escape($previousform, 1);
839 $i = $form->{rowcount};
840 map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description);
847 <h4 class=error>| . $locale->text('Item not on file!') . qq|
850 | . $locale->text('What type of item is this?') . qq|</h4>
852 <form method=post action=ic.pl>
856 <input class=radio type=radio name=item value=part checked> |
857 . $locale->text('Part') . qq|<br>
858 <input class=radio type=radio name=item value=service> |
859 . $locale->text('Service')
862 <input type=hidden name=previousform value="$previousform">
863 <input type=hidden name=partnumber value="$form->{"partnumber_$i"}">
864 <input type=hidden name=description value="$form->{"description_$i"}">
865 <input type=hidden name=rowcount value=$form->{rowcount}>
866 <input type=hidden name=taxaccount2 value=$form->{taxaccounts}>
867 <input type=hidden name=vc value=$form->{vc}>
869 <input type=hidden name=path value=$form->{path}>
870 <input type=hidden name=login value=$form->{login}>
871 <input type=hidden name=password value=$form->{password}>
873 <input type=hidden name=nextsub value=add>
876 <input class=submit type=submit name=action value="|
877 . $locale->text('Continue') . qq|">
884 $lxdebug->leave_sub();
888 $lxdebug->enter_sub();
892 my $new_rowcount = $form->{"rowcount"} * 1 + 1;
893 $form->{"project_id_${new_rowcount}"} = $form->{"globalproject_id"};
895 $form->language_payment(\%myconfig);
897 # if we have a display_form
898 if ($form->{display_form}) {
899 &{"$form->{display_form}"};
903 Common::webdav_folder($form) if ($webdav);
905 # if ( $form->{print_and_post}
906 # && $form->{second_run}
907 # && ($form->{action} eq "display_form")) {
908 # for (keys %$form) { $old_form->{$_} = $form->{$_} }
909 # $old_form->{rowcount}++;
911 # #$form->{rowcount}--;
912 # #$form->{rowcount}--;
914 # $form->{print_and_post} = 0;
916 # &print_form($old_form);
920 # $form->{action} = "";
921 # $form->{resubmit} = 0;
923 # if ($form->{print_and_post} && !$form->{second_run}) {
924 # $form->{second_run} = 1;
925 # $form->{action} = "display_form";
926 # $form->{rowcount}--;
927 # my $rowcount = $form->{rowcount};
929 # # get pricegroups for parts
930 # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
932 # # build up html code for prices_$i
933 # set_pricegroup($rowcount);
935 # $form->{resubmit} = 1;
940 $numrows = ++$form->{rowcount};
941 $subroutine = "display_row";
943 if ($form->{item} eq 'part') {
945 #set preisgruppenanzahl
946 $numrows = $form->{price_rows};
947 $subroutine = "price_row";
949 &{$subroutine}($numrows);
951 $numrows = ++$form->{makemodel_rows};
952 $subroutine = "makemodel_row";
954 if ($form->{item} eq 'assembly') {
955 $numrows = $form->{price_rows};
956 $subroutine = "price_row";
958 &{$subroutine}($numrows);
960 $numrows = ++$form->{makemodel_rows};
961 $subroutine = "makemodel_row";
963 # create makemodel rows
964 &{$subroutine}($numrows);
966 $numrows = ++$form->{assembly_rows};
967 $subroutine = "assembly_row";
969 if ($form->{item} eq 'service') {
970 $numrows = $form->{price_rows};
971 $subroutine = "price_row";
973 &{$subroutine}($numrows);
979 &{$subroutine}($numrows) if $numrows;
983 $lxdebug->leave_sub();
987 $lxdebug->enter_sub();
991 qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values sellprice_pg pricegroup_old price_old price_new unit_old ordnumber transdate longdescription basefactor)
995 # remove any makes or model rows
996 if ($form->{item} eq 'part') {
997 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
998 qw(listprice sellprice lastcost weight rop);
1000 @flds = (make, model);
1001 for my $i (1 .. ($form->{makemodel_rows})) {
1002 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
1006 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1011 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
1012 $form->{makemodel_rows} = $count;
1014 } elsif ($form->{item} eq 'assembly') {
1016 $form->{sellprice} = 0;
1017 $form->{weight} = 0;
1018 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1019 qw(listprice rop stock);
1022 qw(id qty unit bom partnumber description sellprice weight runningnumber partsgroup);
1024 for my $i (1 .. ($form->{assembly_rows} - 1)) {
1025 if ($form->{"qty_$i"}) {
1029 $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
1031 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1033 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
1035 $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"});
1036 $form->{weight} += ($form->{"qty_$i"} * $form->{"weight_$i"});
1041 $form->{sellprice} = $form->round_amount($form->{sellprice}, 2);
1043 $form->redo_rows(\@flds, \@a, $count, $form->{assembly_rows});
1044 $form->{assembly_rows} = $count;
1047 @flds = qw(make model);
1050 for my $i (1 .. ($form->{makemodel_rows})) {
1051 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
1055 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1060 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
1061 $form->{makemodel_rows} = $count;
1065 # this section applies to invoices and orders
1066 # remove any empty numbers
1067 if ($form->{rowcount}) {
1068 for my $i (1 .. $form->{rowcount} - 1) {
1069 if ($form->{"partnumber_$i"}) {
1073 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1076 if ($form->{"licensenumber_$i"} == -1) {
1084 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
1085 $form->{rowcount} = $count;
1087 $form->{creditremaining} -= &invoicetotal;
1094 if ( $form->{type} =~ (/sales_quotation/)
1095 or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
1096 or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
1097 or ($form->{type} =~ /sales_order/)) {
1099 # get pricegroups for parts
1100 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1102 # build up html code for prices_$i
1103 set_pricegroup($form->{rowcount});
1109 $lxdebug->leave_sub();
1113 $lxdebug->enter_sub();
1115 $form->{oldinvtotal} = 0;
1117 # add all parts and deduct paid
1118 map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
1120 my ($amount, $sellprice, $discount, $qty);
1122 for my $i (1 .. $form->{rowcount}) {
1123 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1124 $discount = $form->parse_amount(\%myconfig, $form->{"discount_$i"});
1125 $qty = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
1127 #($form->{"sellprice_$i"}, $form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
1129 $amount = $sellprice * (1 - $discount / 100) * $qty;
1130 map { $form->{"${_}_base"} += $amount }
1131 (split (/ /, $form->{"taxaccounts_$i"}));
1132 $form->{oldinvtotal} += $amount;
1135 map { $form->{oldinvtotal} += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1136 split(/ /, $form->{taxaccounts})
1137 if !$form->{taxincluded};
1139 $form->{oldtotalpaid} = 0;
1140 for $i (1 .. $form->{paidaccounts}) {
1141 $form->{oldtotalpaid} += $form->{"paid_$i"};
1144 $lxdebug->leave_sub();
1147 return ($form->{oldinvtotal} - $form->{oldtotalpaid});
1150 sub validate_items {
1151 $lxdebug->enter_sub();
1153 # check if items are valid
1154 if ($form->{rowcount} == 1) {
1159 for $i (1 .. $form->{rowcount} - 1) {
1160 $form->isblank("partnumber_$i",
1161 $locale->text('Number missing in Row') . " $i");
1164 $lxdebug->leave_sub();
1168 $lxdebug->enter_sub();
1169 if ($form->{second_run}) {
1170 $form->{print_and_post} = 0;
1172 $form->{ordnumber} = $form->{invnumber};
1174 map { delete $form->{$_} } qw(id printed emailed queued);
1175 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'request_quotation') {
1176 $form->{title} = $locale->text('Add Purchase Order');
1177 $form->{vc} = 'vendor';
1178 $form->{type} = 'purchase_order';
1181 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_quotation') {
1182 $form->{title} = $locale->text('Add Sales Order');
1183 $form->{vc} = 'customer';
1184 $form->{type} = 'sales_order';
1187 $form->{script} = 'oe.pl';
1189 $form->{shipto} = 1;
1191 $form->{rowcount}--;
1193 $form->{cp_id} *= 1;
1195 require "$form->{path}/$form->{script}";
1196 my $script = $form->{"script"};
1198 $script =~ s|.pl$||;
1199 $locale = new Locale($language, $script);
1201 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1203 $currency = $form->{currency};
1207 $form->{currency} = $currency;
1208 $form->{exchangerate} = "";
1209 $form->{forex} = "";
1210 $form->{exchangerate} = $exchangerate
1214 $form->check_exchangerate(
1215 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1218 for $i (1 .. $form->{rowcount}) {
1219 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
1220 $form->{"${_}_${i}"})
1221 if ($form->{"${_}_${i}"}) }
1222 qw(ship qty sellprice listprice basefactor));
1228 $lxdebug->leave_sub();
1232 $lxdebug->enter_sub();
1233 if ($form->{second_run}) {
1234 $form->{print_and_post} = 0;
1236 map { delete $form->{$_} } qw(id printed emailed queued);
1238 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'purchase_order') {
1239 $form->{title} = $locale->text('Add Request for Quotation');
1240 $form->{vc} = 'vendor';
1241 $form->{type} = 'request_quotation';
1244 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_order') {
1245 $form->{title} = $locale->text('Add Quotation');
1246 $form->{vc} = 'customer';
1247 $form->{type} = 'sales_quotation';
1251 $form->{cp_id} *= 1;
1253 $form->{script} = 'oe.pl';
1255 $form->{shipto} = 1;
1257 $form->{rowcount}--;
1259 require "$form->{path}/$form->{script}";
1261 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1263 $currency = $form->{currency};
1267 $form->{currency} = $currency;
1268 $form->{exchangerate} = "";
1269 $form->{forex} = "";
1270 $form->{exchangerate} = $exchangerate
1274 $form->check_exchangerate(
1275 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1278 for $i (1 .. $form->{rowcount}) {
1279 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
1280 $form->{"${_}_${i}"})
1281 if ($form->{"${_}_${i}"}) }
1282 qw(ship qty sellprice listprice basefactor));
1288 $lxdebug->leave_sub();
1291 sub request_for_quotation {
1296 $lxdebug->enter_sub();
1297 if ($form->{second_run}) {
1298 $form->{print_and_post} = 0;
1299 $form->{resubmit} = 0;
1301 if ($myconfig{role} eq 'admin') {
1304 <th align="right" nowrap="true">| . $locale->text('Bcc') . qq|</th>
1305 <td><input name="bcc" size="30" value="| . Q($form->{bcc}) . qq|"></td>
1310 if ($form->{formname} =~ /(pick|packing|bin)_list/) {
1311 $form->{email} = $form->{shiptoemail} if $form->{shiptoemail};
1314 if ($form->{"cp_id"} && !$form->{"email"}) {
1315 CT->get_contact(\%myconfig, $form);
1316 $form->{"email"} = $form->{"cp_email"};
1319 $name = $form->{ $form->{vc} };
1321 $title = $locale->text('E-mail') . " $name";
1323 $form->{oldmedia} = $form->{media};
1324 $form->{media} = "email";
1326 my %formname_translations =
1328 "bin_list" => $locale->text('Bin List'),
1329 "credit_note" => $locale->text('Credit Note'),
1330 "invoice" => $locale->text('Invoice'),
1331 "packing_list" => $locale->text('Packing List'),
1332 "pick_list" => $locale->text('Pick List'),
1333 "proforma" => $locale->text('Proforma Invoice'),
1334 "purchase_order" => $locale->text('Purchase Order'),
1335 "request_quotation" => $locale->text('RFQ'),
1336 "sales_order" => $locale->text('Confirmation'),
1337 "sales_quotation" => $locale->text('Quotation'),
1338 "storno_invoice" => $locale->text('Storno Invoice'),
1339 "storno_packing_list" => $locale->text('Storno Packing List'),
1342 my $attachment_filename = $formname_translations{$form->{"formname"}};
1345 if (grep({ $form->{"type"} eq $_ } qw(invoice credit_note))) {
1347 } elsif ($form->{"type"} =~ /_quotation$/) {
1353 if ($attachment_filename && $form->{"${prefix}number"}) {
1354 $attachment_filename .= "_" . $form->{"${prefix}number"} .
1355 ($form->{"format"} =~ /pdf/i ? ".pdf" :
1356 $form->{"format"} =~ /postscript/i ? ".ps" :
1357 $form->{"format"} =~ /opendocument/i ? ".odt" :
1358 $form->{"format"} =~ /html/i ? ".html" : "");
1359 $attachment_filename =~ s/ /_/g;
1362 "ä" => "ae", "ö" => "oe", "ü" => "ue",
1363 "Ä" => "Ae", "Ö" => "Oe", "Ü" => "Ue",
1366 map({ $attachment_filename =~ s/$_/$umlaute{$_}/g; } keys(%umlaute));
1368 $attachment_filename = "";
1371 if ($form->{"email"}) {
1372 $form->{"fokus"} = "Form.subject";
1374 $form->{"fokus"} = "Form.email";
1379 <body onload="fokus()">
1381 <form name="Form" method="post" action="$form->{script}">
1383 <table width="100%">
1384 <tr class="listtop">
1385 <th class="listtop">$title</th>
1387 <tr height="5"></tr>
1392 <th align="right" nowrap>| . $locale->text('To') . qq|</th>
1393 <td><input name="email" size="30" value="| .
1394 Q($form->{"email"}) . qq|"></td>
1397 <th align="right" nowrap>| . $locale->text('Cc') . qq|</th>
1398 <td><input name="cc" size="30" value="| .
1399 Q($form->{"cc"}) . qq|"></td>
1403 <th align="right" nowrap>| . $locale->text('Subject') . qq|</th>
1404 <td><input name="subject" size="30" value="| .
1405 Q($form->{"subject"}) . qq|"></td>
1408 <th align="right" nowrap>| . $locale->text('Attachment name') .
1410 <td><input name="attachment_filename" size="30" value="| .
1411 Q($attachment_filename) . qq|"></td>
1419 <th align="left" nowrap>| . $locale->text('Message') . qq|</th>
1422 <td><textarea name="message" rows="15" cols="60" wrap="soft">| .
1423 H($form->{"message"}) . qq|</textarea></td>
1434 map { delete $form->{$_} }
1435 qw(action email cc bcc subject message formname sendmode format header override);
1437 # save all other variables
1438 foreach $key (keys %$form) {
1439 $form->{$key} =~ s/\"/"/g;
1440 print qq|<input type="hidden" name="$key" value="| . Q($form->{$key}) . qq|">\n|;
1447 <td><hr size="3" noshade></td>
1451 <input type="hidden" name="nextsub" value="send_email">
1454 <input name="action" class="submit" type="submit" value="|
1455 . $locale->text('Continue') . qq|">
1462 $lxdebug->leave_sub();
1466 $lxdebug->enter_sub();
1468 $old_form = new Form;
1470 map { $old_form->{$_} = $form->{$_} } keys %$form;
1471 $old_form->{media} = $form->{oldmedia};
1473 &print_form($old_form);
1475 $lxdebug->leave_sub();
1479 $lxdebug->enter_sub();
1480 $form->{sendmode} = "attachment";
1483 $form->{"format"} ? $form->{"format"} :
1484 $myconfig{"template_format"} ? $myconfig{"template_format"} :
1488 $form->{"copies"} ? $form->{"copies"} :
1489 $myconfig{"copies"} ? $myconfig{"copies"} :
1493 $form->{"media"} ? $form->{"media"} :
1494 $myconfig{"default_media"} ? $myconfig{"default_media"} :
1497 $form->{"printer_id"} =
1498 defined($form->{"printer_id"}) ? $form->{"printer_id"} :
1499 $myconfig{"default_printer_id"} ? $myconfig{"default_printer_id"} :
1502 $form->{PD}{ $form->{formname} } = "selected";
1503 $form->{DF}{ $form->{format} } = "selected";
1504 $form->{OP}{ $form->{media} } = "selected";
1505 $form->{SM}{ $form->{sendmode} } = "selected";
1507 if ($form->{type} eq 'purchase_order') {
1508 $type = qq|<select name=formname>
1509 <option value=purchase_order $form->{PD}{purchase_order}>|
1510 . $locale->text('Purchase Order') . qq|
1511 <option value=bin_list $form->{PD}{bin_list}>|
1512 . $locale->text('Bin List');
1515 if ($form->{type} eq 'credit_note') {
1516 $type = qq|<select name=formname>
1517 <option value=credit_note $form->{PD}{credit_note}>|
1518 . $locale->text('Credit Note');
1521 if ($form->{type} eq 'sales_order') {
1522 $type = qq|<select name=formname>
1523 <option value=sales_order $form->{PD}{sales_order}>|
1524 . $locale->text('Confirmation') . qq|
1525 <option value=proforma $form->{PD}{proforma}>|
1526 . $locale->text('Proforma Invoice') . qq|
1527 <option value=pick_list $form->{PD}{pick_list}>|
1528 . $locale->text('Pick List') . qq|
1529 <option value=packing_list $form->{PD}{packing_list}>|
1530 . $locale->text('Packing List');
1533 if ($form->{type} =~ /_quotation$/) {
1534 $type = qq|<select name=formname>
1535 <option value="$`_quotation" $form->{PD}{"$`_quotation"}>|
1536 . $locale->text('Quotation');
1539 if ($form->{type} eq 'invoice') {
1540 $type = qq|<select name=formname>
1541 <option value=invoice $form->{PD}{invoice}>|
1542 . $locale->text('Invoice') . qq|
1543 <option value=proforma $form->{PD}{proforma}>|
1544 . $locale->text('Proforma Invoice') . qq|
1545 <option value=packing_list $form->{PD}{packing_list}>|
1546 . $locale->text('Packing List');
1549 if ($form->{type} eq 'invoice' && $form->{storno}) {
1550 $type = qq|<select name=formname>
1551 <option value=storno_invoice $form->{PD}{storno_invoice}>|
1552 . $locale->text('Storno Invoice') . qq|
1553 <option value=storno_packing_list $form->{PD}{storno_packing_list}>|
1554 . $locale->text('Storno Packing List');
1557 if ($form->{type} eq 'credit_note') {
1558 $type = qq|<select name=formname>
1559 <option value=credit_note $form->{PD}{credit_note}>|
1560 . $locale->text('Credit Note');
1563 if ($form->{media} eq 'email') {
1564 $media = qq|<select name=sendmode>
1565 <option value=attachment $form->{SM}{attachment}>|
1566 . $locale->text('Attachment') . qq|
1567 <option value=inline $form->{SM}{inline}>| . $locale->text('In-line');
1569 $media = qq|<select name=media>
1570 <option value=screen $form->{OP}{screen}>| . $locale->text('Screen');
1571 if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates) {
1573 <option value=printer $form->{OP}{printer}>|
1574 . $locale->text('Printer');
1576 if ($latex_templates) {
1578 <option value=queue $form->{OP}{queue}>| . $locale->text('Queue');
1582 $format = qq|<select name=format>|;
1583 if ($opendocument_templates && $openofficeorg_writer_bin &&
1584 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
1585 $format .= qq|<option value=opendocument_pdf | .
1586 $form->{DF}{"opendocument_pdf"} . qq|>| .
1587 $locale->text("PDF (OpenDocument/OASIS)") . qq|</option>|;
1590 if ($latex_templates) {
1591 $format .= qq|<option value=pdf $form->{DF}{pdf}>| .
1592 $locale->text('PDF') . qq|</option>|;
1595 $format .= qq|<option value=html $form->{DF}{html}>HTML</option>|;
1597 if ($latex_templates) {
1598 $format .= qq|<option value=postscript $form->{DF}{postscript}>| .
1599 $locale->text('Postscript') . qq|</option>|;
1602 if ($opendocument_templates) {
1603 $format .= qq|<option value=opendocument $form->{DF}{opendocument}>| .
1604 $locale->text("OpenDocument/OASIS") . qq|</option>|;
1606 $format .= qq|</select>|;
1608 if (scalar(keys (%{ $form->{languages} })) !=0) {
1609 $language_select = qq|<select name=language_id>
1610 <option value=""></option>}|;
1611 foreach $item (@{ $form->{languages} }) {
1612 if ($form->{language_id} eq $item->{id}) {
1613 $language_select .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
1615 $language_select .= qq|<option value="$item->{id}">$item->{description}</option>|;
1620 if (scalar(keys (%{ $form->{printers} })) !=0) {
1621 my $selected = !$form->{"printer_id"} ? "selected" : "";
1622 $printer_select = qq|<select name=printer_id $selected>
1623 <option value=""></option>|;
1624 foreach $item (@{ $form->{printers} }) {
1625 $selected = $item->{"id"} == $form->{"printer_id"} ? "selected" : "";
1626 $printer_select .= qq|<option value="$item->{id}" $selected>$item->{printer_description}</option>|;
1633 <table width=100% cellspacing=0 cellpadding=0>
1638 <td>$type</select></td>|;
1639 if (scalar(keys (%{ $form->{languages} })) !=0) {
1641 <td>${language_select}</select></td>|;
1644 <td>$format</select></td>
1645 <td>$media</select></td>|;
1646 if (scalar(keys (%{ $form->{printers} })) !=0) {
1648 <td>$printer_select</select></td>
1652 if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates && $form->{media} ne 'email') {
1654 <td>| . $locale->text('Copies') . qq|
1655 <input name=copies size=2 value=$form->{copies}></td>
1659 $form->{groupitems} = "checked" if $form->{groupitems};
1662 <td>| . $locale->text('Group Items') . qq|</td>
1663 <td><input name=groupitems type=checkbox class=checkbox $form->{groupitems}></td>
1672 if ($form->{printed} =~ /$form->{formname}/) {
1674 <th>\|| . $locale->text('Printed') . qq|\|</th>
1678 if ($form->{emailed} =~ /$form->{formname}/) {
1680 <th>\|| . $locale->text('E-mailed') . qq|\|</th>
1684 if ($form->{queued} =~ /$form->{formname}/) {
1686 <th>\|| . $locale->text('Queued') . qq|\|</th>
1698 $lxdebug->leave_sub();
1702 $lxdebug->enter_sub();
1704 # if this goes to the printer pass through
1705 if ($form->{media} eq 'printer' || $form->{media} eq 'queue') {
1706 $form->error($locale->text('Select postscript or PDF!'))
1707 if ($form->{format} !~ /(postscript|pdf)/);
1709 $old_form = new Form;
1710 map { $old_form->{$_} = $form->{$_} } keys %$form;
1713 if (!$form->{id} || (($form->{formname} eq "proforma") && !$form->{proforma} && (($form->{type} =~ /_order$/) || ($form->{type} =~ /_quotation$/)))) {
1714 if ($form->{formname} eq "proforma") {
1715 $form->{proforma} = 1;
1717 $form->{print_and_save} = 1;
1718 my $formname = $form->{formname};
1720 $form->{formname} = $formname;
1725 &print_form($old_form);
1727 $lxdebug->leave_sub();
1731 $lxdebug->enter_sub();
1732 my ($old_form) = @_;
1736 $numberfld = "invnumber";
1739 ($form->{display_form}) ? $form->{display_form} : "display_form";
1741 # $form->{"notes"} will be overridden by the customer's/vendor's "notes" field. So save it here.
1742 $form->{ $form->{"formname"} . "notes" } = $form->{"notes"};
1744 if ($form->{formname} eq "invoice") {
1745 $form->{label} = $locale->text('Invoice');
1747 if ($form->{formname} eq "packing_list") {
1749 # this is from an invoice
1750 $form->{label} = $locale->text('Packing List');
1752 if ($form->{formname} eq 'sales_order') {
1755 $form->{"${inv}date"} = $form->{transdate};
1756 $form->{label} = $locale->text('Sales Order');
1757 $numberfld = "sonumber";
1761 if (($form->{type} eq 'invoice') && ($form->{formname} eq 'proforma') ) {
1764 $form->{"${inv}date"} = $form->{invdate};
1765 $form->{label} = $locale->text('Proforma Invoice');
1766 $numberfld = "sonumber";
1770 if (($form->{type} eq 'sales_order') && ($form->{formname} eq 'proforma') ) {
1773 $form->{"${inv}date"} = $form->{transdate};
1774 $form->{"invdate"} = $form->{transdate};
1775 $form->{invnumber} = $form->{ordnumber};
1776 $form->{label} = $locale->text('Proforma Invoice');
1777 $numberfld = "sonumber";
1781 if ($form->{formname} eq 'packing_list' && $form->{type} ne 'invoice') {
1783 # we use the same packing list as from an invoice
1786 $form->{invdate} = $form->{"${inv}date"} = $form->{transdate};
1787 $form->{label} = $locale->text('Packing List');
1789 # set invnumber for template packing_list
1790 $form->{invnumber} = $form->{ordnumber};
1792 if ($form->{formname} eq 'pick_list') {
1795 $form->{"${inv}date"} =
1796 ($form->{transdate}) ? $form->{transdate} : $form->{invdate};
1797 $form->{label} = $locale->text('Pick List');
1798 $order = 1 unless $form->{type} eq 'invoice';
1800 if ($form->{formname} eq 'purchase_order') {
1803 $form->{"${inv}date"} = $form->{transdate};
1804 $form->{label} = $locale->text('Purchase Order');
1805 $numberfld = "ponumber";
1808 if ($form->{formname} eq 'bin_list') {
1811 $form->{"${inv}date"} = $form->{transdate};
1812 $form->{label} = $locale->text('Bin List');
1815 if ($form->{formname} eq 'sales_quotation') {
1818 $form->{"${inv}date"} = $form->{transdate};
1819 $form->{label} = $locale->text('Quotation');
1820 $numberfld = "sqnumber";
1824 if (($form->{type} eq 'sales_quotation') && ($form->{formname} eq 'proforma') ) {
1827 $form->{"${inv}date"} = $form->{transdate};
1828 $form->{"invdate"} = $form->{transdate};
1829 $form->{label} = $locale->text('Proforma Invoice');
1830 $numberfld = "sqnumber";
1834 if ($form->{formname} eq 'request_quotation') {
1837 $form->{"${inv}date"} = $form->{transdate};
1838 $form->{label} = $locale->text('Quotation');
1839 $numberfld = "rfqnumber";
1843 $form->isblank("email", $locale->text('E-mail address missing!'))
1844 if ($form->{media} eq 'email');
1845 $form->isblank("${inv}date",
1846 $locale->text($form->{label})
1848 . $locale->text(' Date missing!'));
1850 # $locale->text('Invoice Number missing!')
1851 # $locale->text('Invoice Date missing!')
1852 # $locale->text('Packing List Number missing!')
1853 # $locale->text('Packing List Date missing!')
1854 # $locale->text('Order Number missing!')
1855 # $locale->text('Order Date missing!')
1856 # $locale->text('Quotation Number missing!')
1857 # $locale->text('Quotation Date missing!')
1860 $form->{what_done} = $form->{formname};
1861 if (!$form->{"${inv}number"} && !$form->{preview}) {
1862 $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld);
1863 if ($form->{media} ne 'email') {
1865 # get pricegroups for parts
1866 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1868 # build up html code for prices_$i
1869 set_pricegroup($form->{rowcount});
1871 $form->{rowcount}--;
1874 # saving the history
1875 if(!exists $form->{addition}) {
1876 $form->{addition} = "PRINTED";
1877 $form->save_history($form->dbconnect(\%myconfig));
1879 # /saving the history
1886 # Save the email address given in the form because it should override the setting saved for the customer/vendor.
1887 my ($saved_email, $saved_cc, $saved_bcc) =
1888 ($form->{"email"}, $form->{"cc"}, $form->{"bcc"});
1890 $language_saved = $form->{language_id};
1891 $payment_id_saved = $form->{payment_id};
1893 &{"$form->{vc}_details"}();
1895 $form->{language_id} = $language_saved;
1896 $form->{payment_id} = $payment_id_saved;
1898 $form->{"email"} = $saved_email if ($saved_email);
1899 $form->{"cc"} = $saved_cc if ($saved_cc);
1900 $form->{"bcc"} = $saved_bcc if ($saved_bcc);
1902 my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates);
1903 if ($form->{"language_id"}) {
1904 ($language_tc, $output_numberformat, $output_dateformat, $output_longdates) =
1905 AM->get_language_details(\%myconfig, $form, $form->{language_id});
1907 $output_dateformat = $myconfig{"dateformat"};
1908 $output_numberformat = $myconfig{"numberformat"};
1909 $output_longdates = 1;
1912 ($form->{employee}) = split /--/, $form->{employee};
1914 # create the form variables
1916 OE->order_details(\%myconfig, \%$form);
1918 IS->invoice_details(\%myconfig, \%$form, $locale);
1921 if ($form->{shipto_id}) {
1922 $form->get_shipto(\%myconfig);
1925 @a = qw(name street zipcode city country);
1929 # if there is no shipto fill it in from billto
1930 foreach $item (@a) {
1931 if ($form->{"shipto$item"}) {
1938 if ( $form->{formname} eq 'purchase_order'
1939 || $form->{formname} eq 'request_quotation') {
1940 $form->{shiptoname} = $myconfig{company};
1941 $form->{shiptostreet} = $myconfig{address};
1943 map { $form->{"shipto$_"} = $form->{$_} } @a;
1947 $form->{notes} =~ s/^\s+//g;
1949 $form->{templates} = "$myconfig{templates}";
1951 $form->{language} = $form->get_template_language(\%myconfig);
1952 $form->{printer_code} = $form->get_printer_code(\%myconfig);
1954 if ($form->{language} ne "") {
1955 map({ $form->{"unit"}->[$_] =
1956 AM->translate_units($form, $form->{"language"},
1957 $form->{"unit"}->[$_], $form->{"qty"}->[$_]); }
1958 (0..scalar(@{$form->{"unit"}}) - 1));
1959 $form->{language} = "_" . $form->{language};
1963 format_dates($output_dateformat, $output_longdates,
1964 qw(invdate orddate quodate pldate duedate reqdate transdate
1965 shippingdate deliverydate validitydate paymentdate
1966 datepaid transdate_oe deliverydate_oe
1967 employee_startdate employee_enddate
1969 grep({ /^datepaid_\d+$/ ||
1970 /^transdate_oe_\d+$/ ||
1971 /^deliverydate_oe_\d+$/ ||
1973 /^deliverydate_\d+$/ ||
1977 reformat_numbers($output_numberformat, 2,
1978 qw(invtotal ordtotal quototal subtotal linetotal
1979 listprice sellprice netprice discount
1981 grep({ /^linetotal_\d+$/ ||
1982 /^listprice_\d+$/ ||
1983 /^sellprice_\d+$/ ||
1990 reformat_numbers($output_numberformat, undef,
1995 if ($form->{printer_code} ne "") {
1996 $form->{printer_code} = "_" . $form->{printer_code};
1999 $form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
2000 if ($form->{format} eq 'postscript') {
2001 $form->{postscript} = 1;
2002 $form->{IN} =~ s/html$/tex/;
2003 } elsif ($form->{"format"} =~ /pdf/) {
2005 if ($form->{"format"} =~ /opendocument/) {
2006 $form->{IN} =~ s/html$/odt/;
2008 $form->{IN} =~ s/html$/tex/;
2010 } elsif ($form->{"format"} =~ /opendocument/) {
2011 $form->{"opendocument"} = 1;
2012 $form->{"IN"} =~ s/html$/odt/;
2015 if ($form->{media} eq 'printer') {
2016 $form->{OUT} = "| $form->{printer_command} &>/dev/null";
2017 $form->{printed} .= " $form->{formname}";
2018 $form->{printed} =~ s/^ //;
2020 $printed = $form->{printed};
2022 if ($form->{media} eq 'email') {
2023 $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
2024 unless $form->{subject};
2026 $form->{OUT} = "$sendmail";
2028 $form->{emailed} .= " $form->{formname}";
2029 $form->{emailed} =~ s/^ //;
2031 $emailed = $form->{emailed};
2033 if ($form->{media} eq 'queue') {
2034 %queued = split / /, $form->{queued};
2036 if ($filename = $queued{ $form->{formname} }) {
2037 $form->{queued} =~ s/$form->{formname} $filename//;
2038 unlink "$spool/$filename";
2039 $filename =~ s/\..*$//g;
2045 $filename .= ($form->{postscript}) ? '.ps' : '.pdf';
2046 $form->{OUT} = ">$spool/$filename";
2049 $form->{queued} .= " $form->{formname} $filename";
2051 $form->{queued} =~ s/^ //;
2053 $queued = $form->{queued};
2055 # saving the history
2056 if(!exists $form->{addition}) {
2057 if($form->{media} =~ /printer/) {
2058 $form->{addition} = "PRINTED";
2060 elsif($form->{media} =~ /email/) {
2061 $form->{addition} = "MAILED";
2063 elsif($form->{media} =~ /queue/) {
2064 $form->{addition} = "QUEUED";
2066 elsif($form->{media} =~ /screen/) {
2067 $form->{addition} = "SCREENED";
2069 $form->save_history($form->dbconnect(\%myconfig));
2071 # /saving the history
2073 $form->parse_template(\%myconfig, $userspath);
2075 $form->{callback} = "";
2077 if ($form->{media} eq 'email') {
2078 $form->{message} = $locale->text('sent') unless $form->{message};
2080 $message = $form->{message};
2082 # if we got back here restore the previous form
2083 if ($form->{media} =~ /(printer|email|queue)/) {
2085 $form->update_status(\%myconfig)
2086 if ($form->{media} eq 'queue' && $form->{id});
2090 $old_form->{"${inv}number"} = $form->{"${inv}number"};
2092 # restore and display form
2093 map { $form->{$_} = $old_form->{$_} } keys %$old_form;
2095 $form->{queued} = $queued;
2096 $form->{printed} = $printed;
2097 $form->{emailed} = $emailed;
2098 $form->{message} = $message;
2100 $form->{rowcount}--;
2101 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2102 qw(exchangerate creditlimit creditremaining);
2104 for $i (1 .. $form->{paidaccounts}) {
2106 $form->{"${_}_$i"} =
2107 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2108 } qw(paid exchangerate);
2116 ($form->{media} eq 'printer')
2117 ? $locale->text('sent to printer')
2118 : $locale->text('emailed to') . " $form->{email}";
2119 $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|);
2121 if ($form->{printing}) {
2126 $lxdebug->leave_sub();
2129 sub customer_details {
2130 $lxdebug->enter_sub();
2131 IS->customer_details(\%myconfig, \%$form, @_);
2132 $lxdebug->leave_sub();
2135 sub vendor_details {
2136 $lxdebug->enter_sub();
2138 IR->vendor_details(\%myconfig, \%$form, @_);
2140 $lxdebug->leave_sub();
2144 $lxdebug->enter_sub();
2146 $form->{postasnew} = 1;
2147 map { delete $form->{$_} } qw(printed emailed queued);
2151 $lxdebug->leave_sub();
2155 $lxdebug->enter_sub();
2156 if ($form->{second_run}) {
2157 $form->{print_and_post} = 0;
2160 $title = $form->{title};
2161 $form->{title} = $locale->text('Ship to');
2163 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2164 qw(exchangerate creditlimit creditremaining);
2167 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry
2168 shiptocontact shiptophone shiptofax shiptoemail
2169 shiptodepartment_1 shiptodepartment_2);
2172 (qw(name department_1 department_2 street zipcode city country
2173 contact email phone fax));
2175 # get details for name
2176 &{"$form->{vc}_details"}(@addr_vars);
2179 ($form->{vc} eq 'customer')
2180 ? $locale->text('Customer Number')
2181 : $locale->text('Vendor Number');
2183 # get pricegroups for parts
2184 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
2186 # build up html code for prices_$i
2187 set_pricegroup($form->{rowcount});
2189 $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form";
2191 $form->{rowcount}--;
2198 <form method=post action=$form->{script}>
2204 <tr class=listheading>
2205 <th class=listheading colspan=2 width=50%>|
2206 . $locale->text('Billing Address') . qq|</th>
2207 <th class=listheading width=50%>|
2208 . $locale->text('Shipping Address') . qq|</th>
2210 <tr height="5"></tr>
2212 <th align=right nowrap>$number</th>
2213 <td>$form->{"$form->{vc}number"}</td>
2216 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
2217 <td>$form->{name}</td>
2218 <td><input name=shiptoname size=35 value="$form->{shiptoname}"></td>
2221 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
2222 <td>$form->{department_1}</td>
2223 <td><input name=shiptodepartment_1 size=35 value="$form->{shiptodepartment_1}"></td>
2226 <th align=right nowrap> </th>
2227 <td>$form->{department_2}</td>
2228 <td><input name=shiptodepartment_2 size=35 value="$form->{shiptodepartment_2}"></td>
2231 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
2232 <td>$form->{street}</td>
2233 <td><input name=shiptostreet size=35 value="$form->{shiptostreet}"></td>
2236 <th align=right nowrap>| . $locale->text('Zipcode') . qq|</th>
2237 <td>$form->{zipcode}</td>
2238 <td><input name=shiptozipcode size=35 value="$form->{shiptozipcode}"></td>
2241 <th align=right nowrap>| . $locale->text('City') . qq|</th>
2242 <td>$form->{city}</td>
2243 <td><input name=shiptocity size=35 value="$form->{shiptocity}"></td>
2246 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
2247 <td>$form->{country}</td>
2248 <td><input name=shiptocountry size=35 value="$form->{shiptocountry}"></td>
2251 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2252 <td>$form->{contact}</td>
2253 <td><input name=shiptocontact size=35 value="$form->{shiptocontact}"></td>
2256 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
2257 <td>$form->{phone}</td>
2258 <td><input name=shiptophone size=20 value="$form->{shiptophone}"></td>
2261 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
2262 <td>$form->{fax}</td>
2263 <td><input name=shiptofax size=20 value="$form->{shiptofax}"></td>
2266 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
2267 <td>$form->{email}</td>
2268 <td><input name=shiptoemail size=35 value="$form->{shiptoemail}"></td>
2275 <input type=hidden name=nextsub value=$nextsub>
2279 map({ delete $form->{$_} } (@shipto_vars, qw(header)));
2280 $form->{title} = $title;
2282 foreach $key (keys %$form) {
2283 $form->{$key} =~ s/\"/"/g;
2284 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2292 <input class=submit type=submit name=action value="|
2293 . $locale->text('Continue') . qq|">
2300 $lxdebug->leave_sub();
2304 $lxdebug->enter_sub();
2309 $form->{old_callback} = $form->escape($form->{callback}, 1);
2310 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
2311 $form->{old_callback} = $form->escape($form->{old_callback}, 1);
2314 delete $form->{action};
2315 $customer = $form->{customer};
2316 map { $form->{"old_$_"} = $form->{"${_}_$row"} } qw(partnumber description);
2318 # save all other form variables in a previousform variable
2319 $form->{row} = $row;
2320 foreach $key (keys %$form) {
2323 $form->{$key} =~ s/&/%26/g;
2324 $previousform .= qq|$key=$form->{$key}&|;
2327 $previousform = $form->escape($previousform, 1);
2329 $form->{script} = "licenses.pl";
2331 map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description);
2332 map { $form->{$_} = $form->escape($form->{$_}, 1) }
2333 qw(partnumber description);
2335 qq|$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&customer=$customer&partnumber=$form->{partnumber}&description=$form->{description}&previousform="$previousform"&initial=1|;
2338 $lxdebug->leave_sub();
2341 sub relink_accounts {
2342 $lxdebug->enter_sub();
2344 $form->{"taxaccounts"} =~ s/\s*$//;
2345 $form->{"taxaccounts"} =~ s/^\s*//;
2346 foreach my $accno (split(/\s*/, $form->{"taxaccounts"})) {
2347 map({ delete($form->{"${accno}_${_}"}); } qw(rate description taxnumber));
2349 $form->{"taxaccounts"} = "";
2351 for (my $i = 1; $i <= $form->{"rowcount"}; $i++) {
2352 if ($form->{"id_$i"}) {
2353 IC->retrieve_accounts(\%myconfig, $form, $form->{"id_$i"}, $i, 1);
2357 $lxdebug->leave_sub();
2361 $lxdebug->enter_sub();
2363 $form->get_duedate(\%myconfig);
2366 $result = "$form->{duedate}";
2369 $lxdebug->leave_sub();