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 #######################################################################
36 # any custom scripts for this one
37 if (-f "$form->{path}/custom_io.pl") {
38 eval { require "$form->{path}/custom_io.pl"; };
40 if (-f "$form->{path}/$form->{login}_io.pl") {
41 eval { require "$form->{path}/$form->{login}_io.pl"; };
48 # this is for our long dates
49 # $locale->text('January')
50 # $locale->text('February')
51 # $locale->text('March')
52 # $locale->text('April')
53 # $locale->text('May ')
54 # $locale->text('June')
55 # $locale->text('July')
56 # $locale->text('August')
57 # $locale->text('September')
58 # $locale->text('October')
59 # $locale->text('November')
60 # $locale->text('December')
62 # this is for our short month
63 # $locale->text('Jan')
64 # $locale->text('Feb')
65 # $locale->text('Mar')
66 # $locale->text('Apr')
67 # $locale->text('May')
68 # $locale->text('Jun')
69 # $locale->text('Jul')
70 # $locale->text('Aug')
71 # $locale->text('Sep')
72 # $locale->text('Oct')
73 # $locale->text('Nov')
74 # $locale->text('Dec')
78 ########################################
79 # Eintrag fuer Version 2.2.0 geaendert #
80 # neue Optik im Rechnungsformular #
81 ########################################
83 $lxdebug->enter_sub();
85 if ($lizenzen && $form->{vc} eq "customer") {
86 if ($form->{type} =~ /sales_order/) {
87 @column_index = (runningnumber, partnumber, description, ship, qty);
88 } elsif ($form->{type} =~ /sales_quotation/) {
89 @column_index = (runningnumber, partnumber, description, qty);
91 @column_index = (runningnumber, partnumber, description, qty);
94 if ( ($form->{type} =~ /purchase_order/)
95 || ($form->{type} =~ /sales_order/)) {
96 @column_index = (runningnumber, partnumber, description, ship, qty);
98 @column_index = (runningnumber, partnumber, description, qty);
101 ############## ENDE Neueintrag ##################
103 push @column_index, qw(unit);
105 #for pricegroups column
106 if ($form->{type} =~ (/sales_quotation/) or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/)) or (($form->{level} eq undef) and ($form->{type} =~ /invoice/)) or ($form->{type} =~ /sales_order/)) {
107 push @column_index, qw(sellprice_drag);
110 push @column_index, qw(sellprice);
112 if ($form->{vc} eq 'customer') {
113 push @column_index, qw(discount);
116 push @column_index, "linetotal";
118 my $colspan = $#column_index + 1;
120 $form->{invsubtotal} = 0;
121 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
123 ########################################
124 # Eintrag fuer Version 2.2.0 geaendert #
125 # neue Optik im Rechnungsformular #
126 ########################################
127 $column_data{runningnumber} =
128 qq|<th align=left nowrap width=5 class=listheading>|
129 . $locale->text('No.')
131 $column_data{partnumber} =
132 qq|<th align=left nowrap width=12 class=listheading>|
133 . $locale->text('Number')
135 $column_data{description} =
136 qq|<th align=left nowrap width=30 class=listheading>|
137 . $locale->text('Part Description')
140 qq|<th align=left nowrap width=5 class=listheading>|
141 . $locale->text('Ship')
144 qq|<th align=left nowrap width=5 class=listheading>|
145 . $locale->text('Qty')
148 qq|<th align=left nowrap width=5 class=listheading>|
149 . $locale->text('Unit')
151 $column_data{license} =
152 qq|<th align=left nowrap width=10 class=listheading>|
153 . $locale->text('License')
155 $column_data{serialnr} =
156 qq|<th align=left nowrap width=10 class=listheading>|
157 . $locale->text('Serial No.')
159 $column_data{projectnr} =
160 qq|<th align=left nowrap width=10 class=listheading>|
161 . $locale->text('Project')
163 $column_data{sellprice} =
164 qq|<th align=left nowrap width=15 class=listheading>|
165 . $locale->text('Price')
167 $column_data{sellprice_drag} =
168 qq|<th align=left nowrap width=15 class=listheading>|
169 . $locale->text('Pricegroup')
171 $column_data{discount} =
172 qq|<th align=left class=listheading>|
173 . $locale->text('Discount')
175 $column_data{linetotal} =
176 qq|<th align=left nowrap width=10 class=listheading>|
177 . $locale->text('Extended')
180 qq|<th align=left nowrap width=10 class=listheading>|
181 . $locale->text('Bin')
183 ############## ENDE Neueintrag ##################
189 <tr class=listheading>|;
191 map { print "\n$column_data{$_}" } @column_index;
197 $runningnumber = $locale->text('No.');
198 $deliverydate = $locale->text('Delivery Date');
199 $serialnumber = $locale->text('Serial No.');
200 $projectnumber = $locale->text('Project');
201 $partsgroup = $locale->text('Group');
203 $delvar = 'deliverydate';
205 if ($form->{type} =~ /_order$/ || $form->{type} =~ /_quotation$/) {
206 $deliverydate = $locale->text('Required by');
210 for $i (1 .. $numrows) {
215 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
216 } qw(qty ship discount sellprice price_new price_old);
218 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
220 $decimalplaces = ($dec > 2) ? $dec : 2;
224 $form->{"sellprice_$i"} * $form->{"discount_$i"} / 100,
228 $form->round_amount($form->{"sellprice_$i"} - $discount, $decimalplaces);
229 $linetotal = $form->round_amount($linetotal * $form->{"qty_$i"}, 2);
231 # convert " to "
232 map { $form->{"${_}_$i"} =~ s/\"/"/g }
233 qw(partnumber description unit);
235 ########################################
236 # Eintrag fuer Version 2.2.0 geaendert #
237 # neue Optik im Rechnungsformular #
238 ########################################
239 $column_data{runningnumber} =
240 qq|<td><input name="runningnumber_$i" size=5 value=$i></td>|; # HuT
241 ############## ENDE Neueintrag ##################
243 $column_data{partnumber} =
244 qq|<td><input name="partnumber_$i" size=12 value="$form->{"partnumber_$i"}"></td>|;
246 if (($rows = $form->numtextrows($form->{"description_$i"}, 30, 6)) > 1) {
247 $column_data{description} =
248 qq|<td><textarea name="description_$i" rows=$rows cols=30 wrap=soft>$form->{"description_$i"}</textarea></td>|;
250 $column_data{description} =
251 qq|<td><input name="description_$i" size=30 value="$form->{"description_$i"}"></td>|;
255 qq|<td align=right><input name="qty_$i" size=5 value=|.$form->format_amount(\%myconfig, $form->{"qty_$i"},0).qq|></td>|;
257 qq|<td align=right><input name="ship_$i" size=5 value=|
258 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
261 qq|<td><input name="unit_$i" size=5 value="$form->{"unit_$i"}"></td>|;
265 # build in dragdrop for pricesgroups
266 if ($form->{"prices_$i"}) {
267 $price_tmp = $form->format_amount(\%myconfig, $form->{"price_new_$i"}, 2);
269 $column_data{sellprice_drag} =
270 qq|<td align=right><select name="sellprice_drag_$i">$form->{"prices_$i"}</select></td>|;
271 $column_data{sellprice} =
272 qq|<td><input name="sellprice_$i" size=5 value=$price_tmp></td>|;
274 # for last row and report
275 # set pricegroup dragdrop from report menu
276 if ($form->{"sellprice_$i"} != 0) {
278 qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|;
280 $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"};
282 $column_data{sellprice_drag} =
283 qq|<td align=right><select name="sellprice_drag_$i">$prices</select></td>|;
287 $column_data{sellprice_drag} =
288 qq|<td align=right><input name="sellprice_$i" size=9 value=|
289 . $form->format_amount(\%myconfig, $form->{"prices_$i"},
294 $column_data{sellprice} =
295 qq|<td><input name="sellprice_$i" size=5 value=|
296 . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
300 $column_data{discount} =
301 qq|<td align=right><input name="discount_$i" size=3 value=|
302 . $form->format_amount(\%myconfig, $form->{"discount_$i"})
304 $column_data{linetotal} =
306 . $form->format_amount(\%myconfig, $linetotal, 2)
308 $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
310 ########################################
311 # Eintrag fuer Version 2.2.0 geaendert #
312 # neue Optik im Rechnungsformular #
313 ########################################
314 # if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
315 # $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|;
318 # if ($form->{type} !~ /_quotation/) {
319 # $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|;
322 # $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|;
323 ############## ENDE Neueintrag ##################
328 map { print "\n$column_data{$_}" } @column_index;
333 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
334 <input type=hidden name="bo_$i" value=$form->{"bo_$i"}>
336 <input type=hidden name="pricegroup_old_$i" value=$form->{"pricegroup_old_$i"}>
337 <input type=hidden name="price_old_$i" value=$form->{"price_old_$i"}>
338 <input type=hidden name="price_new_$i" value=|.$form->format_amount(\%myconfig,$form->{"price_new_$i"}).qq|>
340 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
341 <input type=hidden name="inventory_accno_$i" value=$form->{"inventory_accno_$i"}>
342 <input type=hidden name="bin_$i" value="$form->{"bin_$i"}">
343 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
344 <input type=hidden name="partnotes_$i" value="$form->{"partnotes_$i"}">
345 <input type=hidden name="income_accno_$i" value=$form->{"income_accno_$i"}>
346 <input type=hidden name="expense_accno_$i" value=$form->{"expense_accno_$i"}>
347 <input type=hidden name="listprice_$i" value="$form->{"listprice_$i"}">
348 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
349 <input type=hidden name="taxaccounts_$i" value="$form->{"taxaccounts_$i"}">
353 ########################################
354 # Eintrag fuer Version 2.2.0 geaendert #
355 # neue Optik im Rechnungsformular #
356 ########################################
360 <td colspan=$colspan>
362 if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
363 my $selected = $form->{"licensenumber_$i"};
365 $form->{"lizenzen_$i"} =~ s/ selected//g;
366 $form->{"lizenzen_$i"} =~
367 s/value="${selected}"\>/value="${selected}" selected\>/;
368 $lizenzen_quoted = $form->{"lizenzen_$i"};
369 $lizenzen_quoted =~ s/\"/"/g;
371 <b>Lizenz\#</b> <select name="licensenumber_$i" size=1>
372 $form->{"lizenzen_$i"}
374 <input type=hidden name="lizenzen_$i" value="${lizenzen_quoted}">
377 if ($form->{type} !~ /_quotation/) {
379 <b>$serialnumber</b> <input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}">|;
383 <b>$projectnumber</b> <input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}">
384 <input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}">
385 <input type=hidden name="project_id_$i" value="$form->{"project_id_$i"}">
391 ############## ENDE Neueintrag ##################
393 map { $form->{"${_}_base"} += $linetotal }
394 (split / /, $form->{"taxaccounts_$i"});
396 $form->{invsubtotal} += $linetotal;
405 $lxdebug->leave_sub();
408 ##################################################
409 # build html-code for pricegroups in variable $form->{prices_$j}
412 my $rowcount = shift;
413 $lxdebug->enter_sub();
414 for $j (1 .. $rowcount) {
416 my $pricegroup_old = $form->{"pricegroup_old_$i"};
417 if ($form->{PRICES}{ $j }) {
421 foreach $item (@{ $form->{PRICES}{ $j } }) {
422 $price = $form->round_amount($myconfig, $item->{price},5);
423 $price = $form->format_amount($myconfig, $item->{price},2);
424 $price = $item->{price};
425 $pricegroup_id = $item->{pricegroup_id};
426 $pricegroup = $item->{pricegroup};
427 # build dragdrop for pricegroups
429 qq|<option value="$price--$pricegroup_id"$item->{selected}>$pricegroup</option>\n|;
432 # set new selectedpricegroup_id and prices for "Preis"
433 if ($item->{selected}) {
434 $form->{"pricegroup_old_$j"} = $pricegroup_id;
435 $form->{"price_new_$j"} = $price;
436 $form->{"sellprice_$j"} = $price;
439 $form->{"prices_$j"} = $prices;
444 $lxdebug->leave_sub();
448 $lxdebug->enter_sub();
449 @column_index = qw(ndx partnumber description onhand sellprice);
451 $column_data{ndx} = qq|<th> </th>|;
452 $column_data{partnumber} =
453 qq|<th class=listheading>| . $locale->text('Number') . qq|</th>|;
454 $column_data{description} =
455 qq|<th class=listheading>| . $locale->text('Part Description') . qq|</th>|;
456 $column_data{sellprice} =
457 qq|<th class=listheading>| . $locale->text('Price') . qq|</th>|;
458 $column_data{onhand} =
459 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
461 # list items with radio button on a form
464 $title = $locale->text('Select from one of the items below');
465 $colspan = $#column_index + 1;
470 <form method=post action=$form->{script}>
474 <th class=listtop colspan=$colspan>$title</th>
477 <tr class=listheading>|;
479 map { print "\n$column_data{$_}" } @column_index;
484 foreach $ref (@{ $form->{item_list} }) {
485 $checked = ($i++) ? "" : "checked";
488 if ($ref->{inventory_accno} > 0) {
489 $ref->{"lizenzen"} = qq|<option></option>|;
490 foreach $item (@{ $form->{LIZENZEN}{ $ref->{"id"} } }) {
491 $ref->{"lizenzen"} .=
492 qq|<option value=\"$item->{"id"}\">$item->{"licensenumber"}</option>|;
494 $ref->{"lizenzen"} .= qq|<option value=-1>Neue Lizenz</option>|;
495 $ref->{"lizenzen"} =~ s/\"/"/g;
499 map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description unit);
502 $form->round_amount($ref->{sellprice} * (1 - $form->{tradediscount}), 2);
504 qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
505 $column_data{partnumber} =
506 qq|<td><input name="new_partnumber_$i" type=hidden value="$ref->{partnumber}">$ref->{partnumber}</td>|;
507 $column_data{description} =
508 qq|<td><input name="new_description_$i" type=hidden value="$ref->{description}">$ref->{description}</td>|;
509 $column_data{sellprice} =
510 qq|<td align=right><input name="new_sellprice_$i" type=hidden value=$ref->{sellprice}>|
511 . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ")
513 $column_data{onhand} =
514 qq|<td align=right><input name="new_onhand_$i" type=hidden value=$ref->{onhand}>|
515 . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
521 <tr class=listrow$j>|;
523 map { print "\n$column_data{$_}" } @column_index;
528 <input name="new_bin_$i" type=hidden value="$ref->{bin}">
529 <input name="new_listprice_$i" type=hidden value=$ref->{listprice}>
530 <input name="new_inventory_accno_$i" type=hidden value=$ref->{inventory_accno}>
531 <input name="new_income_accno_$i" type=hidden value=$ref->{income_accno}>
532 <input name="new_expense_accno_$i" type=hidden value=$ref->{expense_accno}>
533 <input name="new_unit_$i" type=hidden value="$ref->{unit}">
534 <input name="new_weight_$i" type=hidden value="$ref->{weight}">
535 <input name="new_assembly_$i" type=hidden value="$ref->{assembly}">
536 <input name="new_taxaccounts_$i" type=hidden value="$ref->{taxaccounts}">
537 <input name="new_partsgroup_$i" type=hidden value="$ref->{partsgroup}">
539 <input name="new_id_$i" type=hidden value=$ref->{id}>
544 <input name="new_lizenzen_$i" type=hidden value="$ref->{lizenzen}">
551 <tr><td colspan=8><hr size=3 noshade></td></tr>
554 <input name=lastndx type=hidden value=$i>
558 # delete action variable
559 map { delete $form->{$_} } qw(action item_list header);
561 # save all other form variables
562 foreach $key (keys %${form}) {
563 $form->{$key} =~ s/\"/"/g;
564 print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
568 <input type=hidden name=nextsub value=item_selected>
571 <input class=submit type=submit name=action value="|
572 . $locale->text('Continue') . qq|">
579 $lxdebug->leave_sub();
583 $lxdebug->enter_sub();
584 # replace the last row with the checked row
585 $i = $form->{rowcount};
586 $i = $form->{assembly_rows} if ($form->{item} eq 'assembly');
592 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
593 #$form->{"sellprice_$i"} = $form->{"sellprice_$i"};
595 # if there was a price entered, override it
596 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
598 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} }
599 qw(id partnumber description sellprice listprice inventory_accno income_accno expense_accno bin unit weight assembly taxaccounts partsgroup);
602 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } qw(lizenzen);
605 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
607 $decimalplaces = ($dec > 2) ? $dec : 2;
610 $form->{"sellprice_$i"} = $sellprice;
613 # if there is an exchange rate adjust sellprice
614 if (($form->{exchangerate} * 1) != 0) {
615 $form->{"sellprice_$i"} /= $form->{exchangerate};
616 $form->{"sellprice_$i"} =
617 $form->round_amount($form->{"sellprice_$i"}, $decimalplaces);
621 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
622 qw(sellprice listprice weight);
624 $form->{sellprice} += ($form->{"sellprice_$i"} * $form->{"qty_$i"});
625 $form->{weight} += ($form->{"weight_$i"} * $form->{"qty_$i"});
628 $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
630 map { $form->{"${_}_base"} += $amount }
631 (split / /, $form->{"taxaccounts_$i"});
632 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /,
633 $form->{"taxaccounts_$i"}
634 if !$form->{taxincluded};
636 $form->{creditremaining} -= $amount;
638 $form->{"runningnumber_$i"} = $i;
640 # delete all the new_ variables
641 for $i (1 .. $form->{lastndx}) {
642 map { delete $form->{"new_${_}_$i"} }
643 qw(partnumber description sellprice bin listprice inventory_accno income_accno expense_accno unit assembly taxaccounts id);
646 map { delete $form->{$_} } qw(ndx lastndx nextsub);
651 $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
652 } qw(sellprice listprice) if $form->{item} ne 'assembly';
654 # get pricegroups for parts
655 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
657 # build up html code for prices_$i
662 $lxdebug->leave_sub();
666 $lxdebug->enter_sub();
669 $form->{old_callback} = $form->escape($form->{callback}, 1);
670 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
673 delete $form->{action};
675 # save all other form variables in a previousform variable
676 foreach $key (keys %$form) {
679 $form->{$key} =~ s/&/%26/g;
680 $previousform .= qq|$key=$form->{$key}&|;
683 $previousform = $form->escape($previousform, 1);
685 $i = $form->{rowcount};
686 map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description);
693 <h4 class=error>| . $locale->text('Item not on file!') . qq|
696 | . $locale->text('What type of item is this?') . qq|</h4>
698 <form method=post action=ic.pl>
702 <input class=radio type=radio name=item value=part checked> |
703 . $locale->text('Part') . qq|<br>
704 <input class=radio type=radio name=item value=service> |
705 . $locale->text('Service')
708 <input type=hidden name=previousform value="$previousform">
709 <input type=hidden name=partnumber value="$form->{"partnumber_$i"}">
710 <input type=hidden name=description value="$form->{"description_$i"}">
711 <input type=hidden name=rowcount value=$form->{rowcount}>
712 <input type=hidden name=taxaccount2 value=$form->{taxaccounts}>
713 <input type=hidden name=vc value=$form->{vc}>
715 <input type=hidden name=path value=$form->{path}>
716 <input type=hidden name=login value=$form->{login}>
717 <input type=hidden name=password value=$form->{password}>
719 <input type=hidden name=nextsub value=add>
722 <input class=submit type=submit name=action value="|
723 . $locale->text('Continue') . qq|">
730 $lxdebug->leave_sub();
734 $lxdebug->enter_sub();
736 # if we have a display_form
737 if ($form->{display_form}) {
738 &{"$form->{display_form}"};
741 if ( $form->{print_and_post}
742 && $form->{second_run}
743 && ($form->{action} eq "display_form")) {
744 for (keys %$form) { $old_form->{$_} = $form->{$_} }
745 $old_form->{rowcount}++;
747 #$form->{rowcount}--;
748 #$form->{rowcount}--;
750 $form->{print_and_post} = 0;
752 &print_form($old_form);
756 $form->{action} = "";
757 $form->{resubmit} = 0;
759 if ($form->{print_and_post} && !$form->{second_run}) {
760 $form->{second_run} = 1;
761 $form->{action} = "display_form";
763 my $rowcount = $form->{rowcount};
764 # get pricegroups for parts
765 IS->get_pricegroups_for_parts(\%myconfig, \%$form, "new");
766 # build up html code for prices_$i
767 set_pricegroup($rowcount);
770 $form->{resubmit} = 1;
775 $numrows = ++$form->{rowcount};
776 $subroutine = "display_row";
778 if ($form->{item} eq 'part') {
779 #set preisgruppenanzahl
780 $numrows = $form->{price_rows};
781 $subroutine = "price_row";
783 &{$subroutine}($numrows);
785 $numrows = ++$form->{makemodel_rows};
786 $subroutine = "makemodel_row";
788 if ($form->{item} eq 'assembly') {
789 $numrows = ++$form->{price_rows};
790 $subroutine = "price_row";
792 &{$subroutine}($numrows);
794 $numrows = ++$form->{makemodel_rows};
795 $subroutine = "makemodel_row";
797 # create makemodel rows
798 &{$subroutine}($numrows);
800 $numrows = ++$form->{assembly_rows};
801 $subroutine = "assembly_row";
803 if ($form->{item} eq 'service') {
804 $numrows = ++$form->{price_rows};
805 $subroutine = "price_row";
807 &{$subroutine}($numrows);
813 &{$subroutine}($numrows) if $numrows;
817 $lxdebug->leave_sub();
821 $lxdebug->enter_sub();
825 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)
828 # remove any makes or model rows
829 if ($form->{item} eq 'part') {
830 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
831 qw(listprice sellprice lastcost weight rop);
833 @flds = (make, model);
834 for my $i (1 .. ($form->{makemodel_rows})) {
835 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
839 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
844 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
845 $form->{makemodel_rows} = $count;
847 } elsif ($form->{item} eq 'assembly') {
849 $form->{sellprice} = 0;
851 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
852 qw(listprice rop stock);
855 qw(id qty unit bom partnumber description sellprice weight runningnumber partsgroup);
857 for my $i (1 .. ($form->{assembly_rows} - 1)) {
858 if ($form->{"qty_$i"}) {
862 $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
864 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
866 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
868 $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"});
869 $form->{weight} += ($form->{"qty_$i"} * $form->{"weight_$i"});
874 $form->{sellprice} = $form->round_amount($form->{sellprice}, 2);
876 $form->redo_rows(\@flds, \@a, $count, $form->{assembly_rows});
877 $form->{assembly_rows} = $count;
880 @flds = qw(make model);
883 for my $i (1 .. ($form->{makemodel_rows})) {
884 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
888 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
893 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
894 $form->{makemodel_rows} = $count;
898 # this section applies to invoices and orders
899 # remove any empty numbers
900 if ($form->{rowcount}) {
901 for my $i (1 .. $form->{rowcount} - 1) {
902 if ($form->{"partnumber_$i"}) {
906 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
909 if ($form->{"licensenumber_$i"} == -1) {
917 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
918 $form->{rowcount} = $count;
920 $form->{creditremaining} -= &invoicetotal;
927 if ($form->{type} =~ (/sales_quotation/) or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/)) or (($form->{level} eq undef) and ($form->{type} =~ /invoice/)) or ($form->{type} =~ /sales_order/)) {
929 # get pricegroups for parts
930 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
932 # build up html code for prices_$i
939 $lxdebug->leave_sub();
943 $lxdebug->enter_sub();
945 $form->{oldinvtotal} = 0;
947 # add all parts and deduct paid
948 map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
950 my ($amount, $sellprice, $discount, $qty);
952 for my $i (1 .. $form->{rowcount}) {
953 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
954 $discount = $form->parse_amount(\%myconfig, $form->{"discount_$i"});
955 $qty = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
957 #($form->{"sellprice_$i"}, $form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
959 $amount = $sellprice * (1 - $discount / 100) * $qty;
960 map { $form->{"${_}_base"} += $amount }
961 (split / /, $form->{"taxaccounts_$i"});
962 $form->{oldinvtotal} += $amount;
965 map { $form->{oldinvtotal} += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
966 split / /, $form->{taxaccounts}
967 if !$form->{taxincluded};
969 $form->{oldtotalpaid} = 0;
970 for $i (1 .. $form->{paidaccounts}) {
971 $form->{oldtotalpaid} += $form->{"paid_$i"};
974 $lxdebug->leave_sub();
977 return ($form->{oldinvtotal} - $form->{oldtotalpaid});
981 $lxdebug->enter_sub();
982 # check if items are valid
983 if ($form->{rowcount} == 1) {
988 for $i (1 .. $form->{rowcount} - 1) {
989 $form->isblank("partnumber_$i",
990 $locale->text('Number missing in Row') . " $i");
993 $lxdebug->leave_sub();
997 $lxdebug->enter_sub();
998 if ($form->{second_run}) {
999 $form->{print_and_post} = 0;
1001 $form->{ordnumber} = $form->{invnumber};
1003 map { delete $form->{$_} } qw(id printed emailed queued);
1004 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'request_quotation') {
1005 $form->{title} = $locale->text('Add Purchase Order');
1006 $form->{vc} = 'vendor';
1007 $form->{type} = 'purchase_order';
1010 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_quotation') {
1011 $form->{title} = $locale->text('Add Sales Order');
1012 $form->{vc} = 'customer';
1013 $form->{type} = 'sales_order';
1016 $form->{script} = 'oe.pl';
1018 $form->{shipto} = 1;
1020 $form->{rowcount}--;
1022 ($null, $form->{cp_id}) = split /--/, $form->{contact};
1023 $form->{cp_id} *= 1;
1025 require "$form->{path}/$form->{script}";
1027 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1029 $currency = $form->{currency};
1033 $form->{currency} = $currency;
1034 $form->{exchangerate} = "";
1035 $form->{forex} = "";
1036 $form->{exchangerate} = $exchangerate
1040 $form->check_exchangerate(
1041 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1047 $lxdebug->leave_sub();
1051 $lxdebug->enter_sub();
1052 if ($form->{second_run}) {
1053 $form->{print_and_post} = 0;
1055 map { delete $form->{$_} } qw(id printed emailed queued);
1057 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'purchase_order') {
1058 $form->{title} = $locale->text('Add Request for Quotation');
1059 $form->{vc} = 'vendor';
1060 $form->{type} = 'request_quotation';
1063 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_order') {
1064 $form->{title} = $locale->text('Add Quotation');
1065 $form->{vc} = 'customer';
1066 $form->{type} = 'sales_quotation';
1070 ($null, $form->{cp_id}) = split /--/, $form->{contact};
1071 $form->{cp_id} *= 1;
1073 $form->{script} = 'oe.pl';
1075 $form->{shipto} = 1;
1077 $form->{rowcount}--;
1079 require "$form->{path}/$form->{script}";
1081 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1083 $currency = $form->{currency};
1087 $form->{currency} = $currency;
1088 $form->{exchangerate} = "";
1089 $form->{forex} = "";
1090 $form->{exchangerate} = $exchangerate
1094 $form->check_exchangerate(
1095 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1101 $lxdebug->leave_sub();
1105 $lxdebug->enter_sub();
1106 if ($form->{second_run}) {
1107 $form->{print_and_post} = 0;
1108 $form->{resubmit} = 0;
1110 if ($myconfig{role} eq 'admin') {
1112 <th align=right nowrap=true>| . $locale->text('Bcc') . qq|</th>
1113 <td><input name=bcc size=30 value="$form->{bcc}"></td>
1117 if ($form->{formname} =~ /(pick|packing|bin)_list/) {
1118 $form->{email} = $form->{shiptoemail} if $form->{shiptoemail};
1121 $name = $form->{ $form->{vc} };
1123 $title = $locale->text('E-mail') . " $name";
1125 $form->{oldmedia} = $form->{media};
1126 $form->{media} = "email";
1133 <form method=post action=$form->{script}>
1137 <th class=listtop>$title</th>
1139 <tr height="5"></tr>
1144 <th align=right nowrap>| . $locale->text('To') . qq|</th>
1145 <td><input name=email size=30 value="$form->{email}"></td>
1146 <th align=right nowrap>| . $locale->text('Cc') . qq|</th>
1147 <td><input name=cc size=30 value="$form->{cc}"></td>
1150 <th align=right nowrap>| . $locale->text('Subject') . qq|</th>
1151 <td><input name=subject size=30 value="$form->{subject}"></td>
1161 <th align=left nowrap>| . $locale->text('Message') . qq|</th>
1164 <td><textarea name=message rows=15 cols=60 wrap=soft>$form->{message}</textarea></td>
1175 map { delete $form->{$_} }
1176 qw(action email cc bcc subject message formname sendmode format header override);
1178 # save all other variables
1179 foreach $key (keys %$form) {
1180 $form->{$key} =~ s/\"/"/g;
1181 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1188 <td><hr size=3 noshade></td>
1192 <input type=hidden name=nextsub value=send_email>
1195 <input name=action class=submit type=submit value="|
1196 . $locale->text('Continue') . qq|">
1203 $lxdebug->leave_sub();
1207 $lxdebug->enter_sub();
1209 $old_form = new Form;
1211 map { $old_form->{$_} = $form->{$_} } keys %$form;
1212 $old_form->{media} = $form->{oldmedia};
1214 &print_form($old_form);
1216 $lxdebug->leave_sub();
1220 $lxdebug->enter_sub();
1221 $form->{sendmode} = "attachment";
1222 $form->{copies} = 3 unless $form->{copies};
1224 $form->{PD}{ $form->{formname} } = "selected";
1225 $form->{DF}{ $form->{format} } = "";
1226 $form->{OP}{ $form->{media} } = "selected";
1227 $form->{SM}{ $form->{sendmode} } = "selected";
1229 if ($form->{type} eq 'purchase_order') {
1230 $type = qq|<select name=formname>
1231 <option value=purchase_order $form->{PD}{purchase_order}>|
1232 . $locale->text('Purchase Order') . qq|
1233 <option value=bin_list $form->{PD}{bin_list}>|
1234 . $locale->text('Bin List');
1237 if ($form->{type} eq 'sales_order') {
1238 $type = qq|<select name=formname>
1239 <option value=sales_order $form->{PD}{sales_order}>|
1240 . $locale->text('Confirmation') . qq|
1241 <option value=pick_list $form->{PD}{pick_list}>|
1242 . $locale->text('Pick List') . qq|
1243 <option value=packing_list $form->{PD}{packing_list}>|
1244 . $locale->text('Packing List');
1247 if ($form->{type} =~ /_quotation$/) {
1248 $type = qq|<select name=formname>
1249 <option value="$`_quotation" $form->{PD}{"$`_quotation"}>|
1250 . $locale->text('Quotation') . qq|
1254 if ($form->{type} eq 'invoice') {
1255 $type = qq|<select name=formname>
1256 <option value=invoice $form->{PD}{invoice}>| . $locale->text('Invoice');
1259 if ($form->{type} eq 'ship_order') {
1260 $type = qq|<select name=formname>
1261 <option value=pick_list $form->{PD}{pick_list}>|
1262 . $locale->text('Pick List') . qq|
1263 <option value=packing_list $form->{PD}{packing_list}>|
1264 . $locale->text('Packing List');
1267 if ($form->{type} eq 'receive_order') {
1268 $type = qq|<select name=formname>
1269 <option value=bin_list $form->{PD}{bin_list}>|
1270 . $locale->text('Bin List');
1273 if ($form->{media} eq 'email') {
1274 $media = qq|<select name=sendmode>
1275 <option value=attachment $form->{SM}{attachment}>|
1276 . $locale->text('Attachment') . qq|
1277 <option value=inline $form->{SM}{inline}>| . $locale->text('In-line');
1279 $media = qq|<select name=media>
1280 <option value=screen $form->{OP}{screen}>| . $locale->text('Screen');
1281 if ($myconfig{printer} && $latex) {
1283 <option value=printer $form->{OP}{printer}>|
1284 . $locale->text('Printer');
1288 <option value=queue $form->{OP}{queue}>| . $locale->text('Queue');
1292 $format = qq|<select name=format>
1293 <option value=html $form->{DF}{html}>html|;
1296 $format = qq|<select name=format>
1297 <option value=pdf $form->{DF}{pdf}>| . $locale->text('PDF') . qq|
1298 <option value=html $form->{DF}{html}>html
1299 <option value=postscript $form->{DF}{postscript}>|
1300 . $locale->text('Postscript');
1303 $language = qq|<select name=language>
1304 <option value=""></option>|;
1305 %lang = (de => "deutsch", en => "englisch", fr => "französisch");
1306 foreach $item (keys %lang) {
1307 if ($form->{language} eq $item) {
1308 $language .= qq|<option value="$item" selected>$lang{$item}</option>|;
1310 $language .= qq|<option value="$item">$lang{$item}</option>|;
1315 <table width=100% cellspacing=0 cellpadding=0>
1320 <td>$type</select></td>
1321 <td>$language</select</td>
1322 <td>$format</select></td>
1323 <td>$media</select></td>
1326 if ($myconfig{printer} && $latex && $form->{media} ne 'email') {
1328 <td>| . $locale->text('Copies') . qq|
1329 <input name=copies size=2 value=$form->{copies}></td>
1333 $form->{groupitems} = "checked" if $form->{groupitems};
1336 <td>| . $locale->text('Group Items') . qq|</td>
1337 <td><input name=groupitems type=checkbox class=checkbox $form->{groupitems}></td>
1346 if ($form->{printed} =~ /$form->{formname}/) {
1348 <th>\|| . $locale->text('Printed') . qq|\|</th>
1352 if ($form->{emailed} =~ /$form->{formname}/) {
1354 <th>\|| . $locale->text('E-mailed') . qq|\|</th>
1358 if ($form->{queued} =~ /$form->{formname}/) {
1360 <th>\|| . $locale->text('Queued') . qq|\|</th>
1372 $lxdebug->leave_sub();
1376 $lxdebug->enter_sub();
1377 if ($form->{second_run}) {
1378 $form->{print_and_post} = 0;
1380 # if this goes to the printer pass through
1381 if ($form->{media} eq 'printer' || $form->{media} eq 'queue') {
1382 $form->error($locale->text('Select postscript or PDF!'))
1383 if ($form->{format} !~ /(postscript|pdf)/);
1385 $old_form = new Form;
1386 map { $old_form->{$_} = $form->{$_} } keys %$form;
1389 &print_form($old_form);
1391 $lxdebug->leave_sub();
1395 $lxdebug->enter_sub();
1396 my ($old_form) = @_;
1400 $numberfld = "invnumber";
1403 ($form->{display_form}) ? $form->{display_form} : "display_form";
1405 # $form->{"notes"} will be overridden by the customer's/vendor's "notes" field. So save it here.
1406 $form->{ $form->{"formname"} . "notes" } = $form->{"notes"};
1408 if ($form->{formname} eq "invoice") {
1409 $form->{label} = $locale->text('Invoice');
1411 if ($form->{formname} eq "packing_list") {
1413 # this is from an invoice
1414 $form->{label} = $locale->text('Packing List');
1416 if ($form->{formname} eq 'sales_order') {
1419 $form->{"${inv}date"} = $form->{transdate};
1420 $form->{label} = $locale->text('Sales Order');
1421 $numberfld = "sonumber";
1424 if ($form->{formname} eq 'packing_list' && $form->{type} ne 'invoice') {
1426 # we use the same packing list as from an invoice
1429 $form->{invdate} = $form->{"${inv}date"} = $form->{transdate};
1430 $form->{label} = $locale->text('Packing List');
1433 if ($form->{formname} eq 'pick_list') {
1436 $form->{"${inv}date"} =
1437 ($form->{transdate}) ? $form->{transdate} : $form->{invdate};
1438 $form->{label} = $locale->text('Pick List');
1439 $order = 1 unless $form->{type} eq 'invoice';
1441 if ($form->{formname} eq 'purchase_order') {
1444 $form->{"${inv}date"} = $form->{transdate};
1445 $form->{label} = $locale->text('Purchase Order');
1446 $numberfld = "ponumber";
1449 if ($form->{formname} eq 'bin_list') {
1452 $form->{"${inv}date"} = $form->{transdate};
1453 $form->{label} = $locale->text('Bin List');
1456 if ($form->{formname} eq 'sales_quotation') {
1459 $form->{"${inv}date"} = $form->{transdate};
1460 $form->{label} = $locale->text('Quotation');
1461 $numberfld = "sqnumber";
1464 if ($form->{formname} eq 'request_quotation') {
1467 $form->{"${inv}date"} = $form->{transdate};
1468 $form->{label} = $locale->text('Quotation');
1469 $numberfld = "rfqnumber";
1473 $form->isblank("email", $locale->text('E-mail address missing!'))
1474 if ($form->{media} eq 'email');
1475 $form->isblank("${inv}date",
1476 $locale->text($form->{label} . ' Date missing!'));
1478 # $locale->text('Invoice Number missing!')
1479 # $locale->text('Invoice Date missing!')
1480 # $locale->text('Packing List Number missing!')
1481 # $locale->text('Packing List Date missing!')
1482 # $locale->text('Order Number missing!')
1483 # $locale->text('Order Date missing!')
1484 # $locale->text('Quotation Number missing!')
1485 # $locale->text('Quotation Date missing!')
1488 if (!$form->{"${inv}number"} && !$form->{preview}) {
1489 $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld);
1490 if ($form->{media} ne 'email') {
1492 $i = $form->{rowcount};
1493 # get pricegroups for parts
1494 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1496 # build up html code for prices_$i
1499 $form->{rowcount}--;
1508 # Save the email address given in the form because it should override the setting saved for the customer/vendor.
1509 my ($saved_email, $saved_cc, $saved_bcc) =
1510 ($form->{"email"}, $form->{"cc"}, $form->{"bcc"});
1512 $language = $form->{language};
1513 &{"$form->{vc}_details"};
1514 $form->{language} = $language;
1516 $form->{"email"} = $saved_email if ($saved_email);
1517 $form->{"cc"} = $saved_cc if ($saved_cc);
1518 $form->{"bcc"} = $saved_bcc if ($saved_bcc);
1521 foreach $i (1 .. $form->{rowcount}) {
1523 ("partnumber_$i", "description_$i",
1524 "partsgroup_$i", "serialnumber_$i",
1525 "bin_$i", "unit_$i");
1527 map { push @a, "${_}_description" } split / /, $form->{taxaccounts};
1529 $ARAP = ($form->{vc} eq 'customer') ? "AR" : "AP";
1532 # format payment dates
1533 for $i (1 .. $form->{paidaccounts} - 1) {
1534 $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"});
1535 push @a, "${ARAP}_paid_$i", "source_$i", "memo_$i";
1538 $form->format_string(@a);
1540 ($form->{employee}) = split /--/, $form->{employee};
1541 ($form->{warehouse}, $form->{warehouse_id}) = split /--/, $form->{warehouse};
1543 # create the form variables
1545 OE->order_details(\%myconfig, \%$form);
1547 IS->invoice_details(\%myconfig, \%$form, $locale);
1550 map { $form->{$_} = $locale->date(\%myconfig, $form->{$_}, 1) }
1551 ("${inv}date", "${due}date", "shippingdate");
1553 @a = qw(name street zipcode city country);
1557 # if there is no shipto fill it in from billto
1558 foreach $item (@a) {
1559 if ($form->{"shipto$item"}) {
1566 if ( $form->{formname} eq 'purchase_order'
1567 || $form->{formname} eq 'request_quotation') {
1568 $form->{shiptoname} = $myconfig{company};
1569 $form->{shiptostreet} = $myconfig{address};
1571 map { $form->{"shipto$_"} = $form->{$_} } @a;
1575 $form->{notes} =~ s/^\s+//g;
1577 # some of the stuff could have umlauts so we translate them
1579 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptoemail shippingpoint shipvia company address signature employee contact);
1581 push @a, ("${inv}date", "${due}date", email, cc, bcc);
1583 $form->format_string(@a);
1585 $form->{templates} = "$myconfig{templates}";
1586 if ($form->{language} ne "") {
1587 $form->{language} = "_" . $form->{language};
1590 $form->{IN} = "$form->{formname}$form->{language}.html";
1591 if ($form->{format} eq 'postscript') {
1592 $form->{postscript} = 1;
1593 $form->{IN} =~ s/html$/tex/;
1595 if ($form->{format} eq 'pdf') {
1597 $form->{IN} =~ s/html$/tex/;
1600 if ($form->{media} eq 'printer') {
1601 $form->{OUT} = "| $myconfig{printer}";
1602 $form->{printed} .= " $form->{formname}";
1603 $form->{printed} =~ s/^ //;
1605 $printed = $form->{printed};
1607 if ($form->{media} eq 'email') {
1608 $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
1609 unless $form->{subject};
1611 $form->{OUT} = "$sendmail";
1613 $form->{emailed} .= " $form->{formname}";
1614 $form->{emailed} =~ s/^ //;
1616 $emailed = $form->{emailed};
1618 if ($form->{media} eq 'queue') {
1619 %queued = split / /, $form->{queued};
1621 if ($filename = $queued{ $form->{formname} }) {
1622 $form->{queued} =~ s/$form->{formname} $filename//;
1623 unlink "$spool/$filename";
1624 $filename =~ s/\..*$//g;
1630 $filename .= ($form->{postscript}) ? '.ps' : '.pdf';
1631 $form->{OUT} = ">$spool/$filename";
1634 $form->{queued} .= " $form->{formname} $filename";
1636 $form->{queued} =~ s/^ //;
1638 $queued = $form->{queued};
1640 $form->parse_template(\%myconfig, $userspath);
1642 $form->{callback} = "";
1644 if ($form->{media} eq 'email') {
1645 $form->{message} = $locale->text('sent') unless $form->{message};
1647 $message = $form->{message};
1649 # if we got back here restore the previous form
1650 if ($form->{media} =~ /(printer|email|queue)/) {
1652 $form->update_status(\%myconfig)
1653 if ($form->{media} eq 'queue' && $form->{id});
1657 $old_form->{"${inv}number"} = $form->{"${inv}number"};
1659 # restore and display form
1660 map { $form->{$_} = $old_form->{$_} } keys %$old_form;
1662 $form->{queued} = $queued;
1663 $form->{printed} = $printed;
1664 $form->{emailed} = $emailed;
1665 $form->{message} = $message;
1667 $form->{rowcount}--;
1668 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1669 qw(exchangerate creditlimit creditremaining);
1671 for $i (1 .. $form->{paidaccounts}) {
1673 $form->{"${_}_$i"} =
1674 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
1675 } qw(paid exchangerate);
1683 ($form->{media} eq 'printer')
1684 ? $locale->text('sent to printer')
1685 : $locale->text('emailed to') . " $form->{email}";
1686 $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|);
1691 $lxdebug->leave_sub();
1694 sub customer_details {
1695 $lxdebug->enter_sub();
1696 IS->customer_details(\%myconfig, \%$form);
1697 $lxdebug->leave_sub();
1700 sub vendor_details {
1701 $lxdebug->enter_sub();
1703 IR->vendor_details(\%myconfig, \%$form);
1705 $lxdebug->leave_sub();
1709 $lxdebug->enter_sub();
1711 $form->{postasnew} = 1;
1712 map { delete $form->{$_} } qw(printed emailed queued);
1716 $lxdebug->leave_sub();
1720 $lxdebug->enter_sub();
1721 if ($form->{second_run}) {
1722 $form->{print_and_post} = 0;
1725 $title = $form->{title};
1726 $form->{title} = $locale->text('Ship to');
1728 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1729 qw(exchangerate creditlimit creditremaining);
1732 # get details for name
1733 &{"$form->{vc}_details"};
1736 ($form->{vc} eq 'customer')
1737 ? $locale->text('Customer Number')
1738 : $locale->text('Vendor Number');
1740 $i = $form->{rowcount};
1741 # get pricegroups for parts
1742 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1744 # build up html code for prices_$i
1747 $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form";
1749 $form->{rowcount}--;
1756 <form method=post action=$form->{script}>
1762 <tr class=listheading>
1763 <th class=listheading colspan=2 width=50%>|
1764 . $locale->text('Billing Address') . qq|</th>
1765 <th class=listheading width=50%>|
1766 . $locale->text('Shipping Address') . qq|</th>
1768 <tr height="5"></tr>
1770 <th align=right nowrap>$number</th>
1771 <td>$form->{"$form->{vc}number"}</td>
1774 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
1775 <td>$form->{name}</td>
1776 <td><input name=shiptoname size=35 value="$form->{shiptoname}"></td>
1779 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
1780 <td>$form->{street}</td>
1781 <td><input name=shiptostreet size=35 value="$form->{shiptostreet}"></td>
1784 <th align=right nowrap>| . $locale->text('Zipcode') . qq|</th>
1785 <td>$form->{zipcode}</td>
1786 <td><input name=shiptozipcode size=35 value="$form->{shiptozipcode}"></td>
1789 <th align=right nowrap>| . $locale->text('City') . qq|</th>
1790 <td>$form->{city}</td>
1791 <td><input name=shiptocity size=35 value="$form->{shiptocity}"></td>
1794 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
1795 <td>$form->{country}</td>
1796 <td><input name=shiptocountry size=35 value="$form->{shiptocountry}"></td>
1799 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
1800 <td>$form->{contact}</td>
1801 <td><input name=shiptocontact size=35 value="$form->{shiptocontact}"></td>
1804 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
1805 <td>$form->{"$form->{vc}phone"}</td>
1806 <td><input name=shiptophone size=20 value="$form->{shiptophone}"></td>
1809 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
1810 <td>$form->{"$form->{vc}fax"}</td>
1811 <td><input name=shiptofax size=20 value="$form->{shiptofax}"></td>
1814 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
1815 <td>$form->{email}</td>
1816 <td><input name=shiptoemail size=35 value="$form->{shiptoemail}"></td>
1823 <input type=hidden name=nextsub value=$nextsub>
1827 map { delete $form->{$_} }
1828 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail header);
1829 $form->{title} = $title;
1831 foreach $key (keys %$form) {
1832 $form->{$key} =~ s/\"/"/g;
1833 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1841 <input class=submit type=submit name=action value="|
1842 . $locale->text('Continue') . qq|">
1849 $lxdebug->leave_sub();
1853 $lxdebug->enter_sub();
1858 $form->{old_callback} = $form->escape($form->{callback}, 1);
1859 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
1860 $form->{old_callback} = $form->escape($form->{old_callback}, 1);
1863 delete $form->{action};
1864 $customer = $form->{customer};
1865 map { $form->{"old_$_"} = $form->{"${_}_$row"} } qw(partnumber description);
1867 # save all other form variables in a previousform variable
1868 $form->{row} = $row;
1869 foreach $key (keys %$form) {
1872 $form->{$key} =~ s/&/%26/g;
1873 $previousform .= qq|$key=$form->{$key}&|;
1876 $previousform = $form->escape($previousform, 1);
1878 $form->{script} = "licenses.pl";
1880 map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description);
1881 map { $form->{$_} = $form->escape($form->{$_}, 1) }
1882 qw(partnumber description);
1884 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|;
1887 $lxdebug->leave_sub();