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 AM->unit_select_html($is_part ? $dimension_units :
359 $is_assigned ? $service_units : $all_units,
360 "unit_$i", $this_unit,
361 $is_assigned ? $form->{"unit_$i"} : undef)
364 # build in drop down list for pricesgroups
365 if ($form->{"prices_$i"}) {
366 if ($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"}) {
367 $price_tmp = $form->format_amount(\%myconfig, $form->{"price_new_$i"}, $decimalplaces);
369 $price_tmp = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
372 $column_data{sellprice_pg} =
373 qq|<td align=right><select name="sellprice_pg_$i">$form->{"prices_$i"}</select></td>|;
374 $column_data{sellprice} =
375 qq|<td><input name="sellprice_$i" size=10 value=$price_tmp></td>|;
378 # for last row and report
379 # set pricegroup drop down list from report menu
380 if ($form->{"sellprice_$i"} != 0) {
382 qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|;
384 $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"};
386 $column_data{sellprice_pg} =
387 qq|<td align=right><select name="sellprice_pg_$i">$prices</select></td>|;
392 $column_data{sellprice_pg} = qq|<td align=right> </td>|;
395 $column_data{sellprice} =
396 qq|<td><input name="sellprice_$i" size=10 value=|
397 . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
401 $column_data{discount} =
402 qq|<td align=right><input name="discount_$i" size=3 value=|
403 . $form->format_amount(\%myconfig, $form->{"discount_$i"})
405 $column_data{linetotal} =
407 . $form->format_amount(\%myconfig, $linetotal, 2)
409 $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
411 ########################################
412 # Eintrag fuer Version 2.2.0 geaendert #
413 # neue Optik im Rechnungsformular #
414 ########################################
415 # if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
416 # $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|;
419 # if ($form->{type} !~ /_quotation/) {
420 # $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|;
423 # $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|;
424 ############## ENDE Neueintrag ##################
428 <tr valign=top class=listrow$j>|;
430 map { print "\n$column_data{$_}" } @column_index;
435 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
436 <input type=hidden name="bo_$i" value=$form->{"bo_$i"}>
438 <input type=hidden name="pricegroup_old_$i" value=$form->{"pricegroup_old_$i"}>
439 <input type=hidden name="price_old_$i" value=$form->{"price_old_$i"}>
440 <input type=hidden name="unit_old_$i" value="| . $form->quote($form->{"selected_unit_$i"}) . qq|">
441 <input type=hidden name="price_new_$i" value=|
442 . $form->format_amount(\%myconfig, $form->{"price_new_$i"}) . qq|>
444 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
445 <input type=hidden name="inventory_accno_$i" value=$form->{"inventory_accno_$i"}>
446 <input type=hidden name="bin_$i" value="$form->{"bin_$i"}">
447 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
448 <input type=hidden name="partnotes_$i" value="| . $form->quote($form->{"partnotes_$i"}) . qq|">
449 <input type=hidden name="income_accno_$i" value=$form->{"income_accno_$i"}>
450 <input type=hidden name="expense_accno_$i" value=$form->{"expense_accno_$i"}>
451 <input type=hidden name="listprice_$i" value="$form->{"listprice_$i"}">
452 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
453 <input type=hidden name="taxaccounts_$i" value="$form->{"taxaccounts_$i"}">
454 <input type=hidden name="ordnumber_$i" value="$form->{"ordnumber_$i"}">
455 <input type=hidden name="transdate_$i" value="$form->{"transdate_$i"}">
456 <input type=hidden name="cusordnumber_$i" value="$form->{"cusordnumber_$i"}">
457 <input type=hidden name="longdescription_$i" value="| . $form->quote($form->{"longdescription_$i"}) . qq|">
458 <input type=hidden name="basefactor_$i" value="$form->{"basefactor_$i"}">
462 ########################################
463 # Eintrag fuer Version 2.2.0 geaendert #
464 # neue Optik im Rechnungsformular #
465 ########################################
468 'style="display:none;"' if (!$form->{"show_details"});
472 <tr class=listrow$j $row_style_attr>
473 <td colspan=$colspan>
475 if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
476 my $selected = $form->{"licensenumber_$i"};
478 $form->{"lizenzen_$i"} =~ s/ selected//g;
479 $form->{"lizenzen_$i"} =~
480 s/value="${selected}"\>/value="${selected}" selected\>/;
481 $lizenzen_quoted = $form->{"lizenzen_$i"};
482 $lizenzen_quoted =~ s/\"/"/g;
484 <b>Lizenz\#</b> <select name="licensenumber_$i" size=1>
485 $form->{"lizenzen_$i"}
487 <input type=hidden name="lizenzen_$i" value="${lizenzen_quoted}">
490 if ($form->{type} !~ /_quotation/) {
492 <b>$serialnumber</b> <input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}">|;
495 print qq|<b>$projectnumber</b> | .
496 NTI($cgi->popup_menu('-name' => "project_id_$i",
497 '-values' => \@projectnumber_values,
498 '-labels' => \%projectnumber_labels,
499 '-default' => $form->{"project_id_$i"}));
501 if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) {
503 ($form->{type} eq 'invoice')
505 : 'reqdate'; # invoice uses a different term for the same thing.
507 <b>${$reqdate_term}</b> <input name="${reqdate_term}_$i" size=11 value="$form->{"${reqdate_term}_$i"}">
510 my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : "";
512 <b>|.$locale->text('Subtotal').qq|</b> <input type="checkbox" name="subtotal_$i" value="1" "$subtotalchecked">
518 ############## ENDE Neueintrag ##################
520 map { $form->{"${_}_base"} += $linetotal }
521 (split(/ /, $form->{"taxaccounts_$i"}));
523 $form->{invsubtotal} += $linetotal;
532 $lxdebug->leave_sub();
535 ##################################################
536 # build html-code for pricegroups in variable $form->{prices_$j}
539 $lxdebug->enter_sub();
540 my $rowcount = shift;
541 for $j (1 .. $rowcount) {
542 my $pricegroup_old = $form->{"pricegroup_old_$i"};
543 if ($form->{PRICES}{$j}) {
545 $prices = '<option value="--">' . $locale->text("none (pricegroup)") . '</option>';
547 foreach $item (@{ $form->{PRICES}{$j} }) {
549 #$price = $form->round_amount($myconfig, $item->{price}, 5);
550 #$price = $form->format_amount($myconfig, $item->{price}, 2);
551 $price = $item->{price};
552 $pricegroup_id = $item->{pricegroup_id};
553 $pricegroup = $item->{pricegroup};
555 # build drop down list for pricegroups
557 qq|<option value="$price--$pricegroup_id"$item->{selected}>$pricegroup</option>\n|;
562 # $form->{"${_}_$j"} =
563 # $form->format_amount(\%myconfig, $form->{"${_}_$j"})
564 # } qw(sellprice price_new price_old);
566 # set new selectedpricegroup_id and prices for "Preis"
567 if ($item->{selected} && ($pricegroup_id != 0)) {
568 $form->{"pricegroup_old_$j"} = $pricegroup_id;
569 $form->{"price_new_$j"} = $price;
570 $form->{"sellprice_$j"} = $price;
572 if ($pricegroup_id == 0) {
573 $form->{"price_new_$j"} = $form->{"sellprice_$j"};
576 $form->{"prices_$j"} = $prices;
579 $lxdebug->leave_sub();
583 $lxdebug->enter_sub();
584 @column_index = qw(ndx partnumber description onhand unit sellprice);
586 $column_data{ndx} = qq|<th> </th>|;
587 $column_data{partnumber} =
588 qq|<th class=listheading>| . $locale->text('Number') . qq|</th>|;
589 $column_data{description} =
590 qq|<th class=listheading>| . $locale->text('Part Description') . qq|</th>|;
591 $column_data{sellprice} =
592 qq|<th class=listheading>| . $locale->text('Price') . qq|</th>|;
593 $column_data{onhand} =
594 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
596 qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
597 # list items with radio button on a form
600 $title = $locale->text('Select from one of the items below');
601 $colspan = $#column_index + 1;
606 <form method=post action=$form->{script}>
610 <th class=listtop colspan=$colspan>$title</th>
613 <tr class=listheading>|;
615 map { print "\n$column_data{$_}" } @column_index;
620 foreach $ref (@{ $form->{item_list} }) {
621 $checked = ($i++) ? "" : "checked";
624 if ($ref->{inventory_accno} > 0) {
625 $ref->{"lizenzen"} = qq|<option></option>|;
626 foreach $item (@{ $form->{LIZENZEN}{ $ref->{"id"} } }) {
627 $ref->{"lizenzen"} .=
628 qq|<option value=\"$item->{"id"}\">$item->{"licensenumber"}</option>|;
630 $ref->{"lizenzen"} .= qq|<option value=-1>Neue Lizenz</option>|;
631 $ref->{"lizenzen"} =~ s/\"/"/g;
635 map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description unit);
639 $form->round_amount($ref->{sellprice} * (1 - $form->{tradediscount}), 2);
641 qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
642 $column_data{partnumber} =
643 qq|<td><input name="new_partnumber_$i" type=hidden value="$ref->{partnumber}">$ref->{partnumber}</td>|;
644 $column_data{description} =
645 qq|<td><input name="new_description_$i" type=hidden value="$ref->{description}">$ref->{description}</td>|;
646 $column_data{sellprice} =
647 qq|<td align=right><input name="new_sellprice_$i" type=hidden value=$ref->{sellprice}>|
648 . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ")
650 $column_data{onhand} =
651 qq|<td align=right><input name="new_onhand_$i" type=hidden value=$ref->{onhand}>|
652 . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
655 qq|<td>$ref->{unit}</td>|;
659 <tr class=listrow$j>|;
661 map { print "\n$column_data{$_}" } @column_index;
666 <input name="new_bin_$i" type=hidden value="$ref->{bin}">
667 <input name="new_listprice_$i" type=hidden value=$ref->{listprice}>
668 <input name="new_inventory_accno_$i" type=hidden value=$ref->{inventory_accno}>
669 <input name="new_income_accno_$i" type=hidden value=$ref->{income_accno}>
670 <input name="new_expense_accno_$i" type=hidden value=$ref->{expense_accno}>
671 <input name="new_unit_$i" type=hidden value="$ref->{unit}">
672 <input name="new_weight_$i" type=hidden value="$ref->{weight}">
673 <input name="new_assembly_$i" type=hidden value="$ref->{assembly}">
674 <input name="new_taxaccounts_$i" type=hidden value="$ref->{taxaccounts}">
675 <input name="new_partsgroup_$i" type=hidden value="$ref->{partsgroup}">
676 <input name="new_formel_$i" type=hidden value="$ref->{formel}">
677 <input name="new_longdescription_$i" type=hidden value="| . Q($ref->{longdescription}) . qq|">
678 <input name="new_not_discountable_$i" type=hidden value="$ref->{not_discountable}">
679 <input name="new_part_payment_id_$i" type=hidden value="$ref->{part_payment_id}">
680 <input name="new_partnotes_$i" type="hidden" value="| . Q($ref->{"partnotes"}) . qq|">
682 <input name="new_id_$i" type=hidden value=$ref->{id}>
687 <input name="new_lizenzen_$i" type=hidden value="$ref->{lizenzen}">
694 <tr><td colspan=8><hr size=3 noshade></td></tr>
697 <input name=lastndx type=hidden value=$i>
701 # delete action variable
702 map { delete $form->{$_} } qw(action item_list header);
704 # save all other form variables
705 foreach $key (keys %${form}) {
706 $form->{$key} =~ s/\"/"/g;
707 print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
711 <input type=hidden name=nextsub value=item_selected>
714 <input class=submit type=submit name=action value="|
715 . $locale->text('Continue') . qq|">
722 $lxdebug->leave_sub();
726 $lxdebug->enter_sub();
728 # replace the last row with the checked row
729 $i = $form->{rowcount};
730 $i = $form->{assembly_rows} if ($form->{item} eq 'assembly');
736 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
737 #$form->{"sellprice_$i"} = $form->{"sellprice_$i"};
739 # if there was a price entered, override it
740 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
742 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} }
743 qw(id partnumber description sellprice listprice inventory_accno
744 income_accno expense_accno bin unit weight assembly taxaccounts
745 partsgroup formel longdescription not_discountable partnotes);
746 if ($form->{"part_payment_id_$i"} ne "") {
747 $form->{payment_id} = $form->{"part_payment_id_$i"};
751 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } qw(lizenzen);
754 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
756 $decimalplaces = ($dec > 2) ? $dec : 2;
759 $form->{"sellprice_$i"} = $sellprice;
762 # if there is an exchange rate adjust sellprice
763 if (($form->{exchangerate} * 1) != 0) {
764 $form->{"sellprice_$i"} /= $form->{exchangerate};
765 $form->{"sellprice_$i"} =
766 $form->round_amount($form->{"sellprice_$i"}, $decimalplaces);
770 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
771 qw(sellprice listprice weight);
773 $form->{sellprice} += ($form->{"sellprice_$i"} * $form->{"qty_$i"});
774 $form->{weight} += ($form->{"weight_$i"} * $form->{"qty_$i"});
776 if ($form->{"not_discountable_$i"}) {
777 $form->{"discount_$i"} = 0;
781 $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
783 map { $form->{"${_}_base"} += $amount }
784 (split / /, $form->{"taxaccounts_$i"});
785 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /,
786 $form->{"taxaccounts_$i"}
787 if !$form->{taxincluded};
789 $form->{creditremaining} -= $amount;
791 $form->{"runningnumber_$i"} = $i;
793 # delete all the new_ variables
794 for $i (1 .. $form->{lastndx}) {
795 map { delete $form->{"new_${_}_$i"} }
796 qw(partnumber description sellprice bin listprice inventory_accno income_accno expense_accno unit assembly taxaccounts id);
799 map { delete $form->{$_} } qw(ndx lastndx nextsub);
804 $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
805 } qw(sellprice listprice) if $form->{item} ne 'assembly';
807 # get pricegroups for parts
808 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
810 # build up html code for prices_$i
811 set_pricegroup($form->{rowcount});
815 $lxdebug->leave_sub();
819 $lxdebug->enter_sub();
822 $form->{old_callback} = $form->escape($form->{callback}, 1);
823 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
826 delete $form->{action};
828 # save all other form variables in a previousform variable
829 foreach $key (keys %$form) {
832 $form->{$key} =~ s/&/%26/g;
833 $previousform .= qq|$key=$form->{$key}&|;
836 $previousform = $form->escape($previousform, 1);
838 $i = $form->{rowcount};
839 map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description);
846 <h4 class=error>| . $locale->text('Item not on file!') . qq|
849 | . $locale->text('What type of item is this?') . qq|</h4>
851 <form method=post action=ic.pl>
855 <input class=radio type=radio name=item value=part checked> |
856 . $locale->text('Part') . qq|<br>
857 <input class=radio type=radio name=item value=service> |
858 . $locale->text('Service')
861 <input type=hidden name=previousform value="$previousform">
862 <input type=hidden name=partnumber value="$form->{"partnumber_$i"}">
863 <input type=hidden name=description value="$form->{"description_$i"}">
864 <input type=hidden name=rowcount value=$form->{rowcount}>
865 <input type=hidden name=taxaccount2 value=$form->{taxaccounts}>
866 <input type=hidden name=vc value=$form->{vc}>
868 <input type=hidden name=path value=$form->{path}>
869 <input type=hidden name=login value=$form->{login}>
870 <input type=hidden name=password value=$form->{password}>
872 <input type=hidden name=nextsub value=add>
875 <input class=submit type=submit name=action value="|
876 . $locale->text('Continue') . qq|">
883 $lxdebug->leave_sub();
887 $lxdebug->enter_sub();
891 my $new_rowcount = $form->{"rowcount"} * 1 + 1;
892 $form->{"project_id_${new_rowcount}"} = $form->{"globalproject_id"};
894 $form->language_payment(\%myconfig);
896 # if we have a display_form
897 if ($form->{display_form}) {
898 &{"$form->{display_form}"};
902 Common::webdav_folder($form) if ($webdav);
904 # if ( $form->{print_and_post}
905 # && $form->{second_run}
906 # && ($form->{action} eq "display_form")) {
907 # for (keys %$form) { $old_form->{$_} = $form->{$_} }
908 # $old_form->{rowcount}++;
910 # #$form->{rowcount}--;
911 # #$form->{rowcount}--;
913 # $form->{print_and_post} = 0;
915 # &print_form($old_form);
919 # $form->{action} = "";
920 # $form->{resubmit} = 0;
922 # if ($form->{print_and_post} && !$form->{second_run}) {
923 # $form->{second_run} = 1;
924 # $form->{action} = "display_form";
925 # $form->{rowcount}--;
926 # my $rowcount = $form->{rowcount};
928 # # get pricegroups for parts
929 # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
931 # # build up html code for prices_$i
932 # set_pricegroup($rowcount);
934 # $form->{resubmit} = 1;
939 $numrows = ++$form->{rowcount};
940 $subroutine = "display_row";
942 if ($form->{item} eq 'part') {
944 #set preisgruppenanzahl
945 $numrows = $form->{price_rows};
946 $subroutine = "price_row";
948 &{$subroutine}($numrows);
950 $numrows = ++$form->{makemodel_rows};
951 $subroutine = "makemodel_row";
953 if ($form->{item} eq 'assembly') {
954 $numrows = $form->{price_rows};
955 $subroutine = "price_row";
957 &{$subroutine}($numrows);
959 $numrows = ++$form->{makemodel_rows};
960 $subroutine = "makemodel_row";
962 # create makemodel rows
963 &{$subroutine}($numrows);
965 $numrows = ++$form->{assembly_rows};
966 $subroutine = "assembly_row";
968 if ($form->{item} eq 'service') {
969 $numrows = $form->{price_rows};
970 $subroutine = "price_row";
972 &{$subroutine}($numrows);
978 &{$subroutine}($numrows) if $numrows;
982 $lxdebug->leave_sub();
986 $lxdebug->enter_sub();
990 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)
994 # remove any makes or model rows
995 if ($form->{item} eq 'part') {
996 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
997 qw(listprice sellprice lastcost weight rop);
999 @flds = (make, model);
1000 for my $i (1 .. ($form->{makemodel_rows})) {
1001 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
1005 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1010 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
1011 $form->{makemodel_rows} = $count;
1013 } elsif ($form->{item} eq 'assembly') {
1015 $form->{sellprice} = 0;
1016 $form->{weight} = 0;
1017 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1018 qw(listprice rop stock);
1021 qw(id qty unit bom partnumber description sellprice weight runningnumber partsgroup);
1023 for my $i (1 .. ($form->{assembly_rows} - 1)) {
1024 if ($form->{"qty_$i"}) {
1028 $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
1030 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1032 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
1034 $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"});
1035 $form->{weight} += ($form->{"qty_$i"} * $form->{"weight_$i"});
1040 $form->{sellprice} = $form->round_amount($form->{sellprice}, 2);
1042 $form->redo_rows(\@flds, \@a, $count, $form->{assembly_rows});
1043 $form->{assembly_rows} = $count;
1046 @flds = qw(make model);
1049 for my $i (1 .. ($form->{makemodel_rows})) {
1050 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
1054 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1059 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
1060 $form->{makemodel_rows} = $count;
1064 # this section applies to invoices and orders
1065 # remove any empty numbers
1066 if ($form->{rowcount}) {
1067 for my $i (1 .. $form->{rowcount} - 1) {
1068 if ($form->{"partnumber_$i"}) {
1072 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1075 if ($form->{"licensenumber_$i"} == -1) {
1083 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
1084 $form->{rowcount} = $count;
1086 $form->{creditremaining} -= &invoicetotal;
1093 if ( $form->{type} =~ (/sales_quotation/)
1094 or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
1095 or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
1096 or ($form->{type} =~ /sales_order/)) {
1098 # get pricegroups for parts
1099 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1101 # build up html code for prices_$i
1102 set_pricegroup($form->{rowcount});
1108 $lxdebug->leave_sub();
1112 $lxdebug->enter_sub();
1114 $form->{oldinvtotal} = 0;
1116 # add all parts and deduct paid
1117 map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
1119 my ($amount, $sellprice, $discount, $qty);
1121 for my $i (1 .. $form->{rowcount}) {
1122 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1123 $discount = $form->parse_amount(\%myconfig, $form->{"discount_$i"});
1124 $qty = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
1126 #($form->{"sellprice_$i"}, $form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
1128 $amount = $sellprice * (1 - $discount / 100) * $qty;
1129 map { $form->{"${_}_base"} += $amount }
1130 (split (/ /, $form->{"taxaccounts_$i"}));
1131 $form->{oldinvtotal} += $amount;
1134 map { $form->{oldinvtotal} += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1135 split(/ /, $form->{taxaccounts})
1136 if !$form->{taxincluded};
1138 $form->{oldtotalpaid} = 0;
1139 for $i (1 .. $form->{paidaccounts}) {
1140 $form->{oldtotalpaid} += $form->{"paid_$i"};
1143 $lxdebug->leave_sub();
1146 return ($form->{oldinvtotal} - $form->{oldtotalpaid});
1149 sub validate_items {
1150 $lxdebug->enter_sub();
1152 # check if items are valid
1153 if ($form->{rowcount} == 1) {
1158 for $i (1 .. $form->{rowcount} - 1) {
1159 $form->isblank("partnumber_$i",
1160 $locale->text('Number missing in Row') . " $i");
1163 $lxdebug->leave_sub();
1167 $lxdebug->enter_sub();
1168 if ($form->{second_run}) {
1169 $form->{print_and_post} = 0;
1171 $form->{ordnumber} = $form->{invnumber};
1173 map { delete $form->{$_} } qw(id printed emailed queued);
1174 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'request_quotation') {
1175 $form->{title} = $locale->text('Add Purchase Order');
1176 $form->{vc} = 'vendor';
1177 $form->{type} = 'purchase_order';
1180 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_quotation') {
1181 $form->{title} = $locale->text('Add Sales Order');
1182 $form->{vc} = 'customer';
1183 $form->{type} = 'sales_order';
1186 $form->{script} = 'oe.pl';
1188 $form->{shipto} = 1;
1190 $form->{rowcount}--;
1192 $form->{cp_id} *= 1;
1194 require "$form->{path}/$form->{script}";
1195 my $script = $form->{"script"};
1197 $script =~ s|.pl$||;
1198 $locale = new Locale($language, $script);
1200 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1202 $currency = $form->{currency};
1206 $form->{currency} = $currency;
1207 $form->{exchangerate} = "";
1208 $form->{forex} = "";
1209 $form->{exchangerate} = $exchangerate
1213 $form->check_exchangerate(
1214 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1217 for $i (1 .. $form->{rowcount}) {
1218 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
1219 $form->{"${_}_${i}"})
1220 if ($form->{"${_}_${i}"}) }
1221 qw(ship qty sellprice listprice basefactor));
1227 $lxdebug->leave_sub();
1231 $lxdebug->enter_sub();
1232 if ($form->{second_run}) {
1233 $form->{print_and_post} = 0;
1235 map { delete $form->{$_} } qw(id printed emailed queued);
1237 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'purchase_order') {
1238 $form->{title} = $locale->text('Add Request for Quotation');
1239 $form->{vc} = 'vendor';
1240 $form->{type} = 'request_quotation';
1243 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_order') {
1244 $form->{title} = $locale->text('Add Quotation');
1245 $form->{vc} = 'customer';
1246 $form->{type} = 'sales_quotation';
1250 $form->{cp_id} *= 1;
1252 $form->{script} = 'oe.pl';
1254 $form->{shipto} = 1;
1256 $form->{rowcount}--;
1258 require "$form->{path}/$form->{script}";
1260 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1262 $currency = $form->{currency};
1266 $form->{currency} = $currency;
1267 $form->{exchangerate} = "";
1268 $form->{forex} = "";
1269 $form->{exchangerate} = $exchangerate
1273 $form->check_exchangerate(
1274 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1277 for $i (1 .. $form->{rowcount}) {
1278 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
1279 $form->{"${_}_${i}"})
1280 if ($form->{"${_}_${i}"}) }
1281 qw(ship qty sellprice listprice basefactor));
1287 $lxdebug->leave_sub();
1290 sub request_for_quotation {
1295 $lxdebug->enter_sub();
1296 if ($form->{second_run}) {
1297 $form->{print_and_post} = 0;
1298 $form->{resubmit} = 0;
1300 if ($myconfig{role} eq 'admin') {
1303 <th align="right" nowrap="true">| . $locale->text('Bcc') . qq|</th>
1304 <td><input name="bcc" size="30" value="| . Q($form->{bcc}) . qq|"></td>
1309 if ($form->{formname} =~ /(pick|packing|bin)_list/) {
1310 $form->{email} = $form->{shiptoemail} if $form->{shiptoemail};
1313 if ($form->{"cp_id"} && !$form->{"email"}) {
1314 CT->get_contact(\%myconfig, $form);
1315 $form->{"email"} = $form->{"cp_email"};
1318 $name = $form->{ $form->{vc} };
1320 $title = $locale->text('E-mail') . " $name";
1322 $form->{oldmedia} = $form->{media};
1323 $form->{media} = "email";
1325 my %formname_translations =
1327 "bin_list" => $locale->text('Bin List'),
1328 "credit_note" => $locale->text('Credit Note'),
1329 "invoice" => $locale->text('Invoice'),
1330 "packing_list" => $locale->text('Packing List'),
1331 "pick_list" => $locale->text('Pick List'),
1332 "proforma" => $locale->text('Proforma Invoice'),
1333 "purchase_order" => $locale->text('Purchase Order'),
1334 "request_quotation" => $locale->text('RFQ'),
1335 "sales_order" => $locale->text('Confirmation'),
1336 "sales_quotation" => $locale->text('Quotation'),
1337 "storno_invoice" => $locale->text('Storno Invoice'),
1338 "storno_packing_list" => $locale->text('Storno Packing List'),
1341 my $attachment_filename = $formname_translations{$form->{"formname"}};
1344 if (grep({ $form->{"type"} eq $_ } qw(invoice credit_note))) {
1346 } elsif ($form->{"type"} =~ /_quotation$/) {
1352 if ($attachment_filename && $form->{"${prefix}number"}) {
1353 $attachment_filename .= "_" . $form->{"${prefix}number"} .
1354 ($form->{"format"} =~ /pdf/i ? ".pdf" :
1355 $form->{"format"} =~ /postscript/i ? ".ps" :
1356 $form->{"format"} =~ /opendocument/i ? ".odt" :
1357 $form->{"format"} =~ /html/i ? ".html" : "");
1358 $attachment_filename =~ s/ /_/g;
1361 "ä" => "ae", "ö" => "oe", "ü" => "ue",
1362 "Ä" => "Ae", "Ö" => "Oe", "Ü" => "Ue",
1365 map({ $attachment_filename =~ s/$_/$umlaute{$_}/g; } keys(%umlaute));
1367 $attachment_filename = "";
1370 if ($form->{"email"}) {
1371 $form->{"fokus"} = "Form.subject";
1373 $form->{"fokus"} = "Form.email";
1378 <body onload="fokus()">
1380 <form name="Form" method="post" action="$form->{script}">
1382 <table width="100%">
1383 <tr class="listtop">
1384 <th class="listtop">$title</th>
1386 <tr height="5"></tr>
1391 <th align="right" nowrap>| . $locale->text('To') . qq|</th>
1392 <td><input name="email" size="30" value="| .
1393 Q($form->{"email"}) . qq|"></td>
1396 <th align="right" nowrap>| . $locale->text('Cc') . qq|</th>
1397 <td><input name="cc" size="30" value="| .
1398 Q($form->{"cc"}) . qq|"></td>
1402 <th align="right" nowrap>| . $locale->text('Subject') . qq|</th>
1403 <td><input name="subject" size="30" value="| .
1404 Q($form->{"subject"}) . qq|"></td>
1407 <th align="right" nowrap>| . $locale->text('Attachment name') .
1409 <td><input name="attachment_filename" size="30" value="| .
1410 Q($attachment_filename) . qq|"></td>
1418 <th align="left" nowrap>| . $locale->text('Message') . qq|</th>
1421 <td><textarea name="message" rows="15" cols="60" wrap="soft">| .
1422 H($form->{"message"}) . qq|</textarea></td>
1433 map { delete $form->{$_} }
1434 qw(action email cc bcc subject message formname sendmode format header override);
1436 # save all other variables
1437 foreach $key (keys %$form) {
1438 $form->{$key} =~ s/\"/"/g;
1439 print qq|<input type="hidden" name="$key" value="| . Q($form->{$key}) . qq|">\n|;
1446 <td><hr size="3" noshade></td>
1450 <input type="hidden" name="nextsub" value="send_email">
1453 <input name="action" class="submit" type="submit" value="|
1454 . $locale->text('Continue') . qq|">
1461 $lxdebug->leave_sub();
1465 $lxdebug->enter_sub();
1467 $old_form = new Form;
1469 map { $old_form->{$_} = $form->{$_} } keys %$form;
1470 $old_form->{media} = $form->{oldmedia};
1472 &print_form($old_form);
1474 $lxdebug->leave_sub();
1478 $lxdebug->enter_sub();
1479 $form->{sendmode} = "attachment";
1482 $form->{"format"} ? $form->{"format"} :
1483 $myconfig{"template_format"} ? $myconfig{"template_format"} :
1487 $form->{"copies"} ? $form->{"copies"} :
1488 $myconfig{"copies"} ? $myconfig{"copies"} :
1492 $form->{"media"} ? $form->{"media"} :
1493 $myconfig{"default_media"} ? $myconfig{"default_media"} :
1496 $form->{"printer_id"} =
1497 defined($form->{"printer_id"}) ? $form->{"printer_id"} :
1498 $myconfig{"default_printer_id"} ? $myconfig{"default_printer_id"} :
1501 $form->{PD}{ $form->{formname} } = "selected";
1502 $form->{DF}{ $form->{format} } = "selected";
1503 $form->{OP}{ $form->{media} } = "selected";
1504 $form->{SM}{ $form->{sendmode} } = "selected";
1506 if ($form->{type} eq 'purchase_order') {
1507 $type = qq|<select name=formname>
1508 <option value=purchase_order $form->{PD}{purchase_order}>|
1509 . $locale->text('Purchase Order') . qq|
1510 <option value=bin_list $form->{PD}{bin_list}>|
1511 . $locale->text('Bin List');
1514 if ($form->{type} eq 'credit_note') {
1515 $type = qq|<select name=formname>
1516 <option value=credit_note $form->{PD}{credit_note}>|
1517 . $locale->text('Credit Note');
1520 if ($form->{type} eq 'sales_order') {
1521 $type = qq|<select name=formname>
1522 <option value=sales_order $form->{PD}{sales_order}>|
1523 . $locale->text('Confirmation') . qq|
1524 <option value=proforma $form->{PD}{proforma}>|
1525 . $locale->text('Proforma Invoice') . qq|
1526 <option value=pick_list $form->{PD}{pick_list}>|
1527 . $locale->text('Pick List') . qq|
1528 <option value=packing_list $form->{PD}{packing_list}>|
1529 . $locale->text('Packing List');
1532 if ($form->{type} =~ /_quotation$/) {
1533 $type = qq|<select name=formname>
1534 <option value="$`_quotation" $form->{PD}{"$`_quotation"}>|
1535 . $locale->text('Quotation');
1538 if ($form->{type} eq 'invoice') {
1539 $type = qq|<select name=formname>
1540 <option value=invoice $form->{PD}{invoice}>|
1541 . $locale->text('Invoice') . qq|
1542 <option value=proforma $form->{PD}{proforma}>|
1543 . $locale->text('Proforma Invoice') . qq|
1544 <option value=packing_list $form->{PD}{packing_list}>|
1545 . $locale->text('Packing List');
1548 if ($form->{type} eq 'invoice' && $form->{storno}) {
1549 $type = qq|<select name=formname>
1550 <option value=storno_invoice $form->{PD}{storno_invoice}>|
1551 . $locale->text('Storno Invoice') . qq|
1552 <option value=storno_packing_list $form->{PD}{storno_packing_list}>|
1553 . $locale->text('Storno Packing List');
1556 if ($form->{type} eq 'credit_note') {
1557 $type = qq|<select name=formname>
1558 <option value=credit_note $form->{PD}{credit_note}>|
1559 . $locale->text('Credit Note');
1562 if ($form->{media} eq 'email') {
1563 $media = qq|<select name=sendmode>
1564 <option value=attachment $form->{SM}{attachment}>|
1565 . $locale->text('Attachment') . qq|
1566 <option value=inline $form->{SM}{inline}>| . $locale->text('In-line');
1568 $media = qq|<select name=media>
1569 <option value=screen $form->{OP}{screen}>| . $locale->text('Screen');
1570 if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates) {
1572 <option value=printer $form->{OP}{printer}>|
1573 . $locale->text('Printer');
1575 if ($latex_templates) {
1577 <option value=queue $form->{OP}{queue}>| . $locale->text('Queue');
1581 $format = qq|<select name=format>|;
1582 if ($opendocument_templates && $openofficeorg_writer_bin &&
1583 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
1584 $format .= qq|<option value=opendocument_pdf | .
1585 $form->{DF}{"opendocument_pdf"} . qq|>| .
1586 $locale->text("PDF (OpenDocument/OASIS)") . qq|</option>|;
1589 if ($latex_templates) {
1590 $format .= qq|<option value=pdf $form->{DF}{pdf}>| .
1591 $locale->text('PDF') . qq|</option>|;
1594 $format .= qq|<option value=html $form->{DF}{html}>HTML</option>|;
1596 if ($latex_templates) {
1597 $format .= qq|<option value=postscript $form->{DF}{postscript}>| .
1598 $locale->text('Postscript') . qq|</option>|;
1601 if ($opendocument_templates) {
1602 $format .= qq|<option value=opendocument $form->{DF}{opendocument}>| .
1603 $locale->text("OpenDocument/OASIS") . qq|</option>|;
1605 $format .= qq|</select>|;
1607 if (scalar(keys (%{ $form->{languages} })) !=0) {
1608 $language_select = qq|<select name=language_id>
1609 <option value=""></option>}|;
1610 foreach $item (@{ $form->{languages} }) {
1611 if ($form->{language_id} eq $item->{id}) {
1612 $language_select .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
1614 $language_select .= qq|<option value="$item->{id}">$item->{description}</option>|;
1619 if (scalar(keys (%{ $form->{printers} })) !=0) {
1620 my $selected = !$form->{"printer_id"} ? "selected" : "";
1621 $printer_select = qq|<select name=printer_id $selected>
1622 <option value=""></option>|;
1623 foreach $item (@{ $form->{printers} }) {
1624 $selected = $item->{"id"} == $form->{"printer_id"} ? "selected" : "";
1625 $printer_select .= qq|<option value="$item->{id}" $selected>$item->{printer_description}</option>|;
1632 <table width=100% cellspacing=0 cellpadding=0>
1637 <td>$type</select></td>|;
1638 if (scalar(keys (%{ $form->{languages} })) !=0) {
1640 <td>${language_select}</select></td>|;
1643 <td>$format</select></td>
1644 <td>$media</select></td>|;
1645 if (scalar(keys (%{ $form->{printers} })) !=0) {
1647 <td>$printer_select</select></td>
1651 if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates && $form->{media} ne 'email') {
1653 <td>| . $locale->text('Copies') . qq|
1654 <input name=copies size=2 value=$form->{copies}></td>
1658 $form->{groupitems} = "checked" if $form->{groupitems};
1659 $form->{remove_draft} = "checked" if $form->{remove_draft};
1662 <td>| . $locale->text('Group Items') . qq|</td>
1663 <td><input name=groupitems type=checkbox class=checkbox $form->{groupitems}></td>|;
1666 <td>| . $locale->text('Remove Draft') . qq|</td>
1667 <td><input name=remove_draft type=checkbox class=checkbox $form->{remove_draft}></td>| if (!$form->{id} && $form->{draft_id});
1677 if ($form->{printed} =~ /$form->{formname}/) {
1679 <th>\|| . $locale->text('Printed') . qq|\|</th>
1683 if ($form->{emailed} =~ /$form->{formname}/) {
1685 <th>\|| . $locale->text('E-mailed') . qq|\|</th>
1689 if ($form->{queued} =~ /$form->{formname}/) {
1691 <th>\|| . $locale->text('Queued') . qq|\|</th>
1703 $lxdebug->leave_sub();
1707 $lxdebug->enter_sub();
1709 # if this goes to the printer pass through
1710 if ($form->{media} eq 'printer' || $form->{media} eq 'queue') {
1711 $form->error($locale->text('Select postscript or PDF!'))
1712 if ($form->{format} !~ /(postscript|pdf)/);
1714 $old_form = new Form;
1715 map { $old_form->{$_} = $form->{$_} } keys %$form;
1718 if (!$form->{id} || (($form->{formname} eq "proforma") && !$form->{proforma} && (($form->{type} =~ /_order$/) || ($form->{type} =~ /_quotation$/)))) {
1719 if ($form->{formname} eq "proforma") {
1720 $form->{proforma} = 1;
1722 $form->{print_and_save} = 1;
1723 my $formname = $form->{formname};
1725 $form->{formname} = $formname;
1730 &print_form($old_form);
1732 $lxdebug->leave_sub();
1736 $lxdebug->enter_sub();
1737 my ($old_form) = @_;
1741 $numberfld = "invnumber";
1744 ($form->{display_form}) ? $form->{display_form} : "display_form";
1746 # $form->{"notes"} will be overridden by the customer's/vendor's "notes" field. So save it here.
1747 $form->{ $form->{"formname"} . "notes" } = $form->{"notes"};
1749 if ($form->{formname} eq "invoice") {
1750 $form->{label} = $locale->text('Invoice');
1752 if ($form->{formname} eq "packing_list") {
1754 # this is from an invoice
1755 $form->{label} = $locale->text('Packing List');
1757 if ($form->{formname} eq 'sales_order') {
1760 $form->{"${inv}date"} = $form->{transdate};
1761 $form->{label} = $locale->text('Sales Order');
1762 $numberfld = "sonumber";
1766 if (($form->{type} eq 'invoice') && ($form->{formname} eq 'proforma') ) {
1769 $form->{"${inv}date"} = $form->{invdate};
1770 $form->{label} = $locale->text('Proforma Invoice');
1771 $numberfld = "sonumber";
1775 if (($form->{type} eq 'sales_order') && ($form->{formname} eq 'proforma') ) {
1778 $form->{"${inv}date"} = $form->{transdate};
1779 $form->{"invdate"} = $form->{transdate};
1780 $form->{invnumber} = $form->{ordnumber};
1781 $form->{label} = $locale->text('Proforma Invoice');
1782 $numberfld = "sonumber";
1786 if ($form->{formname} eq 'packing_list' && $form->{type} ne 'invoice') {
1788 # we use the same packing list as from an invoice
1791 $form->{invdate} = $form->{"${inv}date"} = $form->{transdate};
1792 $form->{label} = $locale->text('Packing List');
1794 # set invnumber for template packing_list
1795 $form->{invnumber} = $form->{ordnumber};
1797 if ($form->{formname} eq 'pick_list') {
1800 $form->{"${inv}date"} =
1801 ($form->{transdate}) ? $form->{transdate} : $form->{invdate};
1802 $form->{label} = $locale->text('Pick List');
1803 $order = 1 unless $form->{type} eq 'invoice';
1805 if ($form->{formname} eq 'purchase_order') {
1808 $form->{"${inv}date"} = $form->{transdate};
1809 $form->{label} = $locale->text('Purchase Order');
1810 $numberfld = "ponumber";
1813 if ($form->{formname} eq 'bin_list') {
1816 $form->{"${inv}date"} = $form->{transdate};
1817 $form->{label} = $locale->text('Bin List');
1820 if ($form->{formname} eq 'sales_quotation') {
1823 $form->{"${inv}date"} = $form->{transdate};
1824 $form->{label} = $locale->text('Quotation');
1825 $numberfld = "sqnumber";
1829 if (($form->{type} eq 'sales_quotation') && ($form->{formname} eq 'proforma') ) {
1832 $form->{"${inv}date"} = $form->{transdate};
1833 $form->{"invdate"} = $form->{transdate};
1834 $form->{label} = $locale->text('Proforma Invoice');
1835 $numberfld = "sqnumber";
1839 if ($form->{formname} eq 'request_quotation') {
1842 $form->{"${inv}date"} = $form->{transdate};
1843 $form->{label} = $locale->text('Quotation');
1844 $numberfld = "rfqnumber";
1848 $form->isblank("email", $locale->text('E-mail address missing!'))
1849 if ($form->{media} eq 'email');
1850 $form->isblank("${inv}date",
1851 $locale->text($form->{label})
1853 . $locale->text(' Date missing!'));
1855 # $locale->text('Invoice Number missing!')
1856 # $locale->text('Invoice Date missing!')
1857 # $locale->text('Packing List Number missing!')
1858 # $locale->text('Packing List Date missing!')
1859 # $locale->text('Order Number missing!')
1860 # $locale->text('Order Date missing!')
1861 # $locale->text('Quotation Number missing!')
1862 # $locale->text('Quotation Date missing!')
1865 $form->{what_done} = $form->{formname};
1866 if (!$form->{"${inv}number"} && !$form->{preview} && !$form->{id}) {
1867 $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld);
1868 if ($form->{media} ne 'email') {
1870 # get pricegroups for parts
1871 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1873 # build up html code for prices_$i
1874 set_pricegroup($form->{rowcount});
1876 $form->{rowcount}--;
1879 # saving the history
1880 if(!exists $form->{addition}) {
1881 $form->{addition} = "PRINTED";
1882 $form->save_history($form->dbconnect(\%myconfig));
1884 # /saving the history
1891 # Save the email address given in the form because it should override the setting saved for the customer/vendor.
1892 my ($saved_email, $saved_cc, $saved_bcc) =
1893 ($form->{"email"}, $form->{"cc"}, $form->{"bcc"});
1895 $language_saved = $form->{language_id};
1896 $payment_id_saved = $form->{payment_id};
1898 &{"$form->{vc}_details"}();
1900 $form->{language_id} = $language_saved;
1901 $form->{payment_id} = $payment_id_saved;
1903 $form->{"email"} = $saved_email if ($saved_email);
1904 $form->{"cc"} = $saved_cc if ($saved_cc);
1905 $form->{"bcc"} = $saved_bcc if ($saved_bcc);
1907 my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates);
1908 if ($form->{"language_id"}) {
1909 ($language_tc, $output_numberformat, $output_dateformat, $output_longdates) =
1910 AM->get_language_details(\%myconfig, $form, $form->{language_id});
1912 $output_dateformat = $myconfig{"dateformat"};
1913 $output_numberformat = $myconfig{"numberformat"};
1914 $output_longdates = 1;
1917 ($form->{employee}) = split /--/, $form->{employee};
1919 # create the form variables
1921 OE->order_details(\%myconfig, \%$form);
1923 IS->invoice_details(\%myconfig, \%$form, $locale);
1926 if ($form->{shipto_id}) {
1927 $form->get_shipto(\%myconfig);
1930 @a = qw(name street zipcode city country);
1934 # if there is no shipto fill it in from billto
1935 foreach $item (@a) {
1936 if ($form->{"shipto$item"}) {
1943 if ( $form->{formname} eq 'purchase_order'
1944 || $form->{formname} eq 'request_quotation') {
1945 $form->{shiptoname} = $myconfig{company};
1946 $form->{shiptostreet} = $myconfig{address};
1948 map { $form->{"shipto$_"} = $form->{$_} } @a;
1952 $form->{notes} =~ s/^\s+//g;
1954 $form->{templates} = "$myconfig{templates}";
1956 $form->{language} = $form->get_template_language(\%myconfig);
1957 $form->{printer_code} = $form->get_printer_code(\%myconfig);
1959 if ($form->{language} ne "") {
1960 map({ $form->{"unit"}->[$_] =
1961 AM->translate_units($form, $form->{"language"},
1962 $form->{"unit"}->[$_], $form->{"qty"}->[$_]); }
1963 (0..scalar(@{$form->{"unit"}}) - 1));
1964 $form->{language} = "_" . $form->{language};
1968 format_dates($output_dateformat, $output_longdates,
1969 qw(invdate orddate quodate pldate duedate reqdate transdate
1970 shippingdate deliverydate validitydate paymentdate
1971 datepaid transdate_oe deliverydate_oe
1972 employee_startdate employee_enddate
1974 grep({ /^datepaid_\d+$/ ||
1975 /^transdate_oe_\d+$/ ||
1976 /^deliverydate_oe_\d+$/ ||
1978 /^deliverydate_\d+$/ ||
1982 reformat_numbers($output_numberformat, 2,
1983 qw(invtotal ordtotal quototal subtotal linetotal
1984 listprice sellprice netprice discount
1986 grep({ /^linetotal_\d+$/ ||
1987 /^listprice_\d+$/ ||
1988 /^sellprice_\d+$/ ||
1995 reformat_numbers($output_numberformat, undef,
2000 if ($form->{printer_code} ne "") {
2001 $form->{printer_code} = "_" . $form->{printer_code};
2004 $form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
2005 if ($form->{format} eq 'postscript') {
2006 $form->{postscript} = 1;
2007 $form->{IN} =~ s/html$/tex/;
2008 } elsif ($form->{"format"} =~ /pdf/) {
2010 if ($form->{"format"} =~ /opendocument/) {
2011 $form->{IN} =~ s/html$/odt/;
2013 $form->{IN} =~ s/html$/tex/;
2015 } elsif ($form->{"format"} =~ /opendocument/) {
2016 $form->{"opendocument"} = 1;
2017 $form->{"IN"} =~ s/html$/odt/;
2020 if ($form->{media} eq 'printer') {
2021 $form->{OUT} = "| $form->{printer_command} &>/dev/null";
2022 $form->{printed} .= " $form->{formname}";
2023 $form->{printed} =~ s/^ //;
2025 $printed = $form->{printed};
2027 if ($form->{media} eq 'email') {
2028 $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
2029 unless $form->{subject};
2031 $form->{OUT} = "$sendmail";
2033 $form->{emailed} .= " $form->{formname}";
2034 $form->{emailed} =~ s/^ //;
2036 $emailed = $form->{emailed};
2038 if ($form->{media} eq 'queue') {
2039 %queued = split / /, $form->{queued};
2041 if ($filename = $queued{ $form->{formname} }) {
2042 $form->{queued} =~ s/$form->{formname} $filename//;
2043 unlink "$spool/$filename";
2044 $filename =~ s/\..*$//g;
2050 $filename .= ($form->{postscript}) ? '.ps' : '.pdf';
2051 $form->{OUT} = ">$spool/$filename";
2054 $form->{queued} .= " $form->{formname} $filename";
2056 $form->{queued} =~ s/^ //;
2058 $queued = $form->{queued};
2060 # saving the history
2061 if(!exists $form->{addition}) {
2062 if($form->{media} =~ /printer/) {
2063 $form->{addition} = "PRINTED";
2065 elsif($form->{media} =~ /email/) {
2066 $form->{addition} = "MAILED";
2068 elsif($form->{media} =~ /queue/) {
2069 $form->{addition} = "QUEUED";
2071 elsif($form->{media} =~ /screen/) {
2072 $form->{addition} = "SCREENED";
2074 $form->save_history($form->dbconnect(\%myconfig));
2076 # /saving the history
2078 $form->parse_template(\%myconfig, $userspath);
2080 $form->{callback} = "";
2082 if ($form->{media} eq 'email') {
2083 $form->{message} = $locale->text('sent') unless $form->{message};
2085 $message = $form->{message};
2087 # if we got back here restore the previous form
2088 if ($form->{media} =~ /(printer|email|queue)/) {
2090 $form->update_status(\%myconfig)
2091 if ($form->{media} eq 'queue' && $form->{id});
2095 $old_form->{"${inv}number"} = $form->{"${inv}number"};
2097 # restore and display form
2098 map { $form->{$_} = $old_form->{$_} } keys %$old_form;
2100 $form->{queued} = $queued;
2101 $form->{printed} = $printed;
2102 $form->{emailed} = $emailed;
2103 $form->{message} = $message;
2105 $form->{rowcount}--;
2106 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2107 qw(exchangerate creditlimit creditremaining);
2109 for $i (1 .. $form->{paidaccounts}) {
2111 $form->{"${_}_$i"} =
2112 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2113 } qw(paid exchangerate);
2121 ($form->{media} eq 'printer')
2122 ? $locale->text('sent to printer')
2123 : $locale->text('emailed to') . " $form->{email}";
2124 $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|);
2126 if ($form->{printing}) {
2131 $lxdebug->leave_sub();
2134 sub customer_details {
2135 $lxdebug->enter_sub();
2136 IS->customer_details(\%myconfig, \%$form, @_);
2137 $lxdebug->leave_sub();
2140 sub vendor_details {
2141 $lxdebug->enter_sub();
2143 IR->vendor_details(\%myconfig, \%$form, @_);
2145 $lxdebug->leave_sub();
2149 $lxdebug->enter_sub();
2151 $form->{postasnew} = 1;
2152 map { delete $form->{$_} } qw(printed emailed queued);
2156 $lxdebug->leave_sub();
2160 $lxdebug->enter_sub();
2161 if ($form->{second_run}) {
2162 $form->{print_and_post} = 0;
2165 $title = $form->{title};
2166 $form->{title} = $locale->text('Ship to');
2168 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2169 qw(exchangerate creditlimit creditremaining);
2172 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry
2173 shiptocontact shiptophone shiptofax shiptoemail
2174 shiptodepartment_1 shiptodepartment_2);
2177 (qw(name department_1 department_2 street zipcode city country
2178 contact email phone fax));
2180 # get details for name
2181 &{"$form->{vc}_details"}(@addr_vars);
2184 ($form->{vc} eq 'customer')
2185 ? $locale->text('Customer Number')
2186 : $locale->text('Vendor Number');
2188 # get pricegroups for parts
2189 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
2191 # build up html code for prices_$i
2192 set_pricegroup($form->{rowcount});
2194 $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form";
2196 $form->{rowcount}--;
2203 <form method=post action=$form->{script}>
2209 <tr class=listheading>
2210 <th class=listheading colspan=2 width=50%>|
2211 . $locale->text('Billing Address') . qq|</th>
2212 <th class=listheading width=50%>|
2213 . $locale->text('Shipping Address') . qq|</th>
2215 <tr height="5"></tr>
2217 <th align=right nowrap>$number</th>
2218 <td>$form->{"$form->{vc}number"}</td>
2221 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
2222 <td>$form->{name}</td>
2223 <td><input name=shiptoname size=35 value="$form->{shiptoname}"></td>
2226 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
2227 <td>$form->{department_1}</td>
2228 <td><input name=shiptodepartment_1 size=35 value="$form->{shiptodepartment_1}"></td>
2231 <th align=right nowrap> </th>
2232 <td>$form->{department_2}</td>
2233 <td><input name=shiptodepartment_2 size=35 value="$form->{shiptodepartment_2}"></td>
2236 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
2237 <td>$form->{street}</td>
2238 <td><input name=shiptostreet size=35 value="$form->{shiptostreet}"></td>
2241 <th align=right nowrap>| . $locale->text('Zipcode') . qq|</th>
2242 <td>$form->{zipcode}</td>
2243 <td><input name=shiptozipcode size=35 value="$form->{shiptozipcode}"></td>
2246 <th align=right nowrap>| . $locale->text('City') . qq|</th>
2247 <td>$form->{city}</td>
2248 <td><input name=shiptocity size=35 value="$form->{shiptocity}"></td>
2251 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
2252 <td>$form->{country}</td>
2253 <td><input name=shiptocountry size=35 value="$form->{shiptocountry}"></td>
2256 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2257 <td>$form->{contact}</td>
2258 <td><input name=shiptocontact size=35 value="$form->{shiptocontact}"></td>
2261 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
2262 <td>$form->{phone}</td>
2263 <td><input name=shiptophone size=20 value="$form->{shiptophone}"></td>
2266 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
2267 <td>$form->{fax}</td>
2268 <td><input name=shiptofax size=20 value="$form->{shiptofax}"></td>
2271 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
2272 <td>$form->{email}</td>
2273 <td><input name=shiptoemail size=35 value="$form->{shiptoemail}"></td>
2280 <input type=hidden name=nextsub value=$nextsub>
2284 map({ delete $form->{$_} } (@shipto_vars, qw(header)));
2285 $form->{title} = $title;
2287 foreach $key (keys %$form) {
2288 $form->{$key} =~ s/\"/"/g;
2289 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2297 <input class=submit type=submit name=action value="|
2298 . $locale->text('Continue') . qq|">
2305 $lxdebug->leave_sub();
2309 $lxdebug->enter_sub();
2314 $form->{old_callback} = $form->escape($form->{callback}, 1);
2315 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
2316 $form->{old_callback} = $form->escape($form->{old_callback}, 1);
2319 delete $form->{action};
2320 $customer = $form->{customer};
2321 map { $form->{"old_$_"} = $form->{"${_}_$row"} } qw(partnumber description);
2323 # save all other form variables in a previousform variable
2324 $form->{row} = $row;
2325 foreach $key (keys %$form) {
2328 $form->{$key} =~ s/&/%26/g;
2329 $previousform .= qq|$key=$form->{$key}&|;
2332 $previousform = $form->escape($previousform, 1);
2334 $form->{script} = "licenses.pl";
2336 map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description);
2337 map { $form->{$_} = $form->escape($form->{$_}, 1) }
2338 qw(partnumber description);
2340 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|;
2343 $lxdebug->leave_sub();
2346 sub relink_accounts {
2347 $lxdebug->enter_sub();
2349 $form->{"taxaccounts"} =~ s/\s*$//;
2350 $form->{"taxaccounts"} =~ s/^\s*//;
2351 foreach my $accno (split(/\s*/, $form->{"taxaccounts"})) {
2352 map({ delete($form->{"${accno}_${_}"}); } qw(rate description taxnumber));
2354 $form->{"taxaccounts"} = "";
2356 for (my $i = 1; $i <= $form->{"rowcount"}; $i++) {
2357 if ($form->{"id_$i"}) {
2358 IC->retrieve_accounts(\%myconfig, $form, $form->{"id_$i"}, $i, 1);
2362 $lxdebug->leave_sub();
2366 $lxdebug->enter_sub();
2368 $form->get_duedate(\%myconfig);
2371 $result = "$form->{duedate}";
2374 $lxdebug->leave_sub();